From fcd8fed654606c80c4ec8a0f6718ba62de331e95 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 13 May 2021 11:31:18 +0300 Subject: pascal version of QuickSearch moved to miranda-deprecated repository --- plugins/QuickSearch/i_ok.inc | 823 ---------- plugins/QuickSearch/ico/default.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/delete.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/down.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/female.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/male.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/new.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/qs.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/reload.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/ico/up.ico | Bin 1150 -> 0 bytes plugins/QuickSearch/make.bat | 28 - plugins/QuickSearch/qs.rc | 168 -- plugins/QuickSearch/quicksearch.dpr | 145 -- plugins/QuickSearch/quicksearch_history.txt | 115 -- plugins/QuickSearch/resource.inc | 69 - plugins/QuickSearch/sr_frame.pas | 211 --- plugins/QuickSearch/sr_global.pas | 832 ---------- plugins/QuickSearch/sr_optdialog.pas | 1002 ------------ plugins/QuickSearch/sr_window.pas | 2284 --------------------------- plugins/QuickSearch/version.rc | 49 - 20 files changed, 5726 deletions(-) delete mode 100644 plugins/QuickSearch/i_ok.inc delete mode 100644 plugins/QuickSearch/ico/default.ico delete mode 100644 plugins/QuickSearch/ico/delete.ico delete mode 100644 plugins/QuickSearch/ico/down.ico delete mode 100644 plugins/QuickSearch/ico/female.ico delete mode 100644 plugins/QuickSearch/ico/male.ico delete mode 100644 plugins/QuickSearch/ico/new.ico delete mode 100644 plugins/QuickSearch/ico/qs.ico delete mode 100644 plugins/QuickSearch/ico/reload.ico delete mode 100644 plugins/QuickSearch/ico/up.ico delete mode 100644 plugins/QuickSearch/make.bat delete mode 100644 plugins/QuickSearch/qs.rc delete mode 100644 plugins/QuickSearch/quicksearch.dpr delete mode 100644 plugins/QuickSearch/quicksearch_history.txt delete mode 100644 plugins/QuickSearch/resource.inc delete mode 100644 plugins/QuickSearch/sr_frame.pas delete mode 100644 plugins/QuickSearch/sr_global.pas delete mode 100644 plugins/QuickSearch/sr_optdialog.pas delete mode 100644 plugins/QuickSearch/sr_window.pas delete mode 100644 plugins/QuickSearch/version.rc (limited to 'plugins') diff --git a/plugins/QuickSearch/i_ok.inc b/plugins/QuickSearch/i_ok.inc deleted file mode 100644 index a861c02938..0000000000 --- a/plugins/QuickSearch/i_ok.inc +++ /dev/null @@ -1,823 +0,0 @@ -{} -//----- Color functions ----- - -var - colorhook:THANDLE; - -type - tqscolor = ( - bkg_norm,fgr_norm, - bkg_odd ,fgr_odd, - bkg_dis ,fgr_dis, - bkg_del ,fgr_del, - bkg_hid ,fgr_hid, - bkg_meta,fgr_meta, - bkg_sub ,fgr_sub - ); -type - tQSColorRec = record - color : TCOLORREF; - setting : PAnsiChar; - descr : PAnsiChar; - end; -const - QSColors: array [tqscolor] of tQSColorRec =( - (color: $00FFFFFF; setting: 'back_norm'; descr: 'Normal background' ), - (color: $00000000; setting: 'fore_norm'; descr: 'Normal foreground' ), - (color: $00EBE6DE; setting: 'back_odd' ; descr: 'Odd background' ), - (color: $00000000; setting: 'fore_odd' ; descr: 'Odd foreground' ), - (color: $008080FF; setting: 'back_dis' ; descr: 'Disabled account background'), - (color: $00000000; setting: 'fore_dis' ; descr: 'Disabled account foreground'), - (color: $008000FF; setting: 'back_del' ; descr: 'Deleted account background' ), - (color: $00000000; setting: 'fore_del' ; descr: 'Deleted account foreground' ), - (color: $0080FFFF; setting: 'back_hid' ; descr: 'Hidden contact background' ), - (color: $00000000; setting: 'fore_hid' ; descr: 'Hidden contact foreground' ), - (color: $00BAE699; setting: 'back_meta'; descr: 'Metacontact background' ), - (color: $00000000; setting: 'fore_meta'; descr: 'Metacontact foreground' ), - (color: $00B3CCC1; setting: 'back_sub' ; descr: 'Subcontact background' ), - (color: $00000000; setting: 'fore_sub' ; descr: 'Subcontact foreground' ) - ); - - -procedure RegisterColors; -var - cid:TColourID; - i:tqscolor; -begin - StrCopy(cid.group,qs_module); - StrCopy(cid.dbSettingsGroup,qs_module); - - for i:=Low(tqscolor) to High(tqscolor) do - begin - StrCopy(cid.name ,QSColors[i].descr); - StrCopy(cid.setting,QSColors[i].setting); - cid.defcolour:=QSColors[i].color; - cid.order :=ORD(i); - ColourRegister(@cid); - end; -end; - -function ColorReload(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - i:tqscolor; -begin - result:=0; - for i:=Low(tqscolor) to High(tqscolor) do - begin - QSColors[i].color:=Colour_Get(qs_module,QSColors[i].descr); - end; -end; - -//----- Item fill ----- - -function int2strw(i:uint_ptr;signed:bool=false):PWideChar; -var - buf:array [0..31] of WideChar; -begin - if signed then - StrDupW(result,IntToStr(buf,int_ptr(i))) - else - StrDupW(result,IntToStr(buf,i)); -end; - -function int2hexw(i:uint_ptr):PWideChar; -var - buf:array [0..31] of WideChar; -begin - StrDupW(result,IntToHex(buf,i)); -end; - -function BuildLastSeenTime(date:integer):PWideChar; -var - pc:pWideChar; - buf:array [0..19] of WideChar; - year,month,day,hours,min:integer; -begin - year:=(date div (60*24*31*356))+1980; - - if year<>0 then - begin - date:= date mod (60*24*31*356); - pc:=@buf; - - month:=date div (60*24*31); - date :=date mod (60*24*31); - day :=date div (60*24); - date :=date mod (60*24); - hours:=date div 60; - min :=date mod 60; - - IntToStr(pc,day,2); - - inc(pc,2); - pc^:='.'; inc(pc); - IntToStr(pc,month,2); - inc(pc,2); - pc^:='.'; inc(pc); - IntToStr(pc,year,4); - inc(pc,4); - pc^:=' '; inc(pc); - pc^:='-'; inc(pc); - pc^:=' '; inc(pc); - IntToStr(pc,hours,2); - inc(pc,2); - pc^:=':'; inc(pc); - IntToStr(pc,min,2); - - StrDupW(result,@buf); - end - else - result:=nil; -end; - -function BuildLastSeenTimeInt(cont:THANDLE;modulename:PAnsiChar):cardinal; -var - day,month,year,hours,minutes:word; -begin - year:=DBReadWord(cont,modulename,'Year',0); - if year<>0 then - begin - month :=DBReadWord(cont,modulename,'Month' ,0); - day :=DBReadWord(cont,modulename,'Day' ,0); - hours :=DBReadWord(cont,modulename,'Hours' ,0); - minutes:=DBReadWord(cont,modulename,'Minutes',0); - result:=minutes+hours*60+day*60*24+month*60*24*31+(year-1980)*60*24*31*356; // was 366 - end - else - result:=0; -end; - -function IPtoStr(ip:dword):PWideChar; -var - p:PWideChar; - buf:array [0..16] of WideChar; -begin - p:=@buf; - IntToStr(buf,ip shr 24); - while p^<>#0 do inc(p); p^:='.'; inc(p); - IntToStr(p,(ip shr 16) and $FF); - while p^<>#0 do inc(p); p^:='.'; inc(p); - IntToStr(p,HIByte(ip)); - while p^<>#0 do inc(p); p^:='.'; inc(p); - IntToStr(p,LOByte(ip)); - StrDupW(result,buf); -end; - -function TimeToStrW(data:dword):PWideChar; -var - strdatetime:array [0..63] of WideChar; -begin - TimeZone_ToStringW(data, 'd - t', @strdatetime, Length(strdatetime)); - StrDupW(result,strdatetime); -end; - -function FindMeta(hMeta:THANDLE;var MetaNum:WPARAM):LPARAM; -var - i:integer; -begin - result:=0; - - for i:=0 to HIGH(FlagBuf) do - begin - with FlagBuf[i] do - begin - if contact=hMeta then - begin - if wparam=0 then // new meta - begin - inc(LastMeta); - wparam :=LastMeta; - lparam :=0; - end; - MetaNum:=wparam; - inc(lparam); - result:=lparam; - break; - end; - end; - end; - -end; - -function DoMeta(hContact:TMCONTACT):pointer; -var - pw:pWideChar; - i:integer; -begin - result:=nil; - - for i:=0 to HIGH(FlagBuf) do - begin - with FlagBuf[i] do - begin - if contact=hContact then - begin - if (flags and QSF_META)<>0 then // adding new meta count - begin - if wparam=0 then - begin - inc(LastMeta); - wparam:=LastMeta; -// lparam:=0; - end; - end - else if (flags and QSF_SUBMETA)<>0 then - begin - lparam:=FindMeta(db_mc_getMeta(hContact),wparam); - end; - - if wparam>0 then - begin - mGetMem(result,32); - pw:=result; - pw[0]:='['; - IntToStr(pw+1,wparam,3); - pw[4]:=']'; - if lparam>0 then - begin - pw[5]:=' '; - IntToStr(pw+6,lparam); - end - else - pw[5]:=#0; - end; - break; - end; - end; - end; - -end; - -procedure LoadOneItem(hContact:THANDLE;column:pcolumnitem;proto:integer; var res:tQSRec); -var - lmodule:PAnsiChar; - pInfo:PWideChar; - DbEvent:TMEVENT; - dbei:TDBEVENTINFO; - data:tSubstData; -begin - res.data:=uint_ptr(-1); - mFreeMem(res.text); - with column^ do - begin - case setting_type of - QST_SCRIPT: begin - res.text:=ParseVarString(script,hContact); - end; - - QST_SERVICE: begin - data.Parameter :=hContact; - data.LastResult:=0; - data.ResultType:=ACF_TYPE_NUMBER; - if ExecuteService(service,data) then - begin - case data.ResultType of - ACF_TYPE_NUMBER: begin - res.data:=data.LastResult; - if (service.flags and ACF_FLAG_HEXNUM)<>0 then - res.text:=int2hexw(data.LastResult) - else - begin - res.text:=int2strw(data.LastResult,(service.flags and ACF_FLAG_SIGNED)<>0); - end; - end; - ACF_TYPE_UNICODE: begin - StrDupW(res.text,PWideChar(data.LastResult)) - end; - end; - ClearSubstData(data); - end - else - res.text:=nil; - - end; - - QST_CONTACTINFO: begin - pInfo := Contact_GetInfo(cnftype,hContact,nil); - if pInfo <> nil then - begin - StrDupW(res.text,pInfo); - mir_free(pInfo); - end; - end; - - QST_SETTING: begin - if module<>nil then - lmodule:=module - else - lmodule:=GetProtoName(proto); - - case datatype of - QSTS_STRING: begin - res.text:=DBReadUnicode(hContact,lmodule,setting,nil) - end; - - QSTS_BYTE: begin - res.data:=DBReadByte(hContact,lmodule,setting,0); - res.text:=int2strw(res.data); - end; - - QSTS_WORD: begin - res.data:=DBReadWord(hContact,lmodule,setting,0); - res.text:=int2strw(res.data); - end; - - QSTS_DWORD: begin - if (module=nil) and (setting=nil) then - begin - res.data:=hContact; - res.text:=int2hexw(res.data); - end - else - begin - res.data:=DBReadDWord(hContact,lmodule,setting,0); - res.text:=int2strw(res.data); - end; - end; - - QSTS_SIGNED: begin - res.data:=DBReadDWord(hContact,lmodule,setting,0); - res.text:=int2strw(res.data,true); - end; - - QSTS_HEXNUM: begin - res.data:=DBReadDWord(hContact,lmodule,setting,0); - res.text:=int2hexw(res.data); - end; - - QSTS_IP: begin - res.data:=DBReadDWord(hContact,lmodule,setting,0); - if res.data<>0 then - res.text:=IPtoStr(res.data); - end; - - QSTS_TIMESTAMP: begin - res.data:=DBReadDWord(hContact,lmodule,setting,0); - if res.data<>0 then - res.text:=TimeToStrW(res.data); - end; - end; - end; - - QST_OTHER: - case other of - QSTO_LASTSEEN: begin - res.data:=BuildLastSeenTimeInt(hContact,'SeenModule'); - res.text:=BuildLastSeenTime(res.data); - end; - - QSTO_DISPLAYNAME: begin - StrDupW(res.text,Clist_GetContactDisplayName(hContact, 0)); - end; - - QSTO_LASTEVENT: begin - DbEvent:=db_event_last(hContact); - if DbEvent<>0 then - begin - ZeroMemory(@dbei,sizeof(dbei)); - db_event_get(DbEvent, @dbei); - res.data:=dbei.timestamp; - res.text:=TimeToStrW(res.data); - end - else - res.data:=0; - end; - - QSTO_METACONTACT: begin - res.text:=DoMeta(hContact); - end; - - QSTO_EVENTCOUNT: begin - res.data:=db_event_count(hContact); - res.text:=int2strw(res.data); - end; - end; - end; - end; -end; - -//----- Initial table filling ----- - -procedure AddContact(num:integer;hContact:TMCONTACT); -var - col:pcolumnitem; - tmpstr:array [0..63] of AnsiChar; - i:integer; -begin - FillChar(FlagBuf[num],SizeOf(tQSFRec),0); - with FlagBuf[num] do - begin - contact:=hContact; - flags :=0; - i:=IsContactActive(hContact,tmpstr); - proto:=FindProto(tmpstr); - - case i of - -2: flags:=flags or QSF_ACCDEL; // deleted account - -1: flags:=flags or QSF_ACCOFF; // disabled account -// 0 : ; // hidden contact - 1 : flags:=flags or QSF_META; // metacontact - 2 : flags:=flags or QSF_SUBMETA; // subMetacontact - end; - if i>0 then - flags:=flags or QSF_INLIST; // normal contact - - if (proto=0) or (i<0) then - status:=ID_STATUS_OFFLINE - else - status:=DBReadWord(contact,GetProtoName(proto),'Status',ID_STATUS_OFFLINE); - - for i:=0 to qsopt.numcolumns-1 do - begin - col:=@qsopt.columns[i]; - // col.flags must me same as colorder[i].flags - if (col.flags and COL_ON)<>0 then - LoadOneItem(contact,col,proto,MainBuf[num,i]); - end; - end; - -end; - -function PrepareToFill:boolean; -var - cnt,cnt1:integer; - hContact:TMCONTACT; - i:integer; -begin - result:=false; - if qsopt.numcolumns=0 then - exit; - // calculating contacts - cnt:=db_get_contact_count(); - if cnt=0 then - exit; - - result:=true; - - // Allocate mem - SetLength(MainBuf,cnt,qsopt.numcolumns); - SetLength(FlagBuf,cnt); - - for i:=0 to cnt-1 do - FillChar(MainBuf[i][0],qsopt.numcolumns*SizeOf(tQSRec),0); - - for i:=0 to qsopt.numcolumns-1 do - begin - with qsopt.columns[i] do - begin - if (flags and COL_ON)<>0 then - flags := flags or COL_INIT; - end; - end; - - // filling buffer - LastMeta:=0; - cnt1:=0; - hContact:=db_find_first(); - while hContact<>0 do - begin - //!! check account - AddContact(cnt1,hContact); - inc(cnt1); - if cnt1=cnt then break; // additional checking - hContact:=db_find_next(hContact); - end; - -end; - -//----- Status bar ----- -type - pSBDataRecord = ^tSBDataRecord; - tSBDataRecord = record - flags :cardinal; - total :cardinal; // in clist - found :cardinal; // by pattern - online:cardinal; // clist online - liston:cardinal; // pattern online - end; - tSBData = array [0..63] of tSBDataRecord; - -procedure DrawSBW(const SBData:tSBData); -var - aPartPos:array [0..63 ] of integer; - buf :array [0..255] of WideChar; - fmtstr :array [0..255] of WideChar; - all:integer; - i,j:integer; - p,pc,po,pd,poff,pa:PWideChar; - rc:TRECT; - dc:HDC; - icon:HICON; - protocnt:integer; -begin - p:=@buf; - // p:=FormatSimpleW('%i users found (%i) Online: %i',[SBData[0].found,Length(FlagBuf),SBData[0].online]); - p:=StrEndW(IntToStr(p,SBData[0].found)); - p:=StrCopyEW(p,TranslateW(' users found (')); - p:=StrEndW(IntToStr(p,Length(FlagBuf))); - p:=StrCopyEW(p,TranslateW(') Online: ')); - IntToStr(p,SBData[0].online); - - dc:=GetDC(StatusBar); - DrawTextW(dc,pWidechar(@buf),-1,rc,DT_CALCRECT); - ReleaseDC(StatusBar,dc); - all:=rc.right-rc.left; - aPartPos[0]:=all; - protocnt:=GetNumProto; - i:=1; - while i<=protocnt do - begin - inc(all,55); - aPartPos[i]:=all; - inc(i); - end; - aPartPos[i]:=-1; - SendMessageW(StatusBar,SB_SETPARTS,protocnt+2,lparam(@aPartPos)); - SendMessageW(StatusBar,SB_SETTEXTW,0,lparam(@buf){p}); - // mFreeMem(p); - - po :=TranslateW('Online'); - pd :=TranslateW('deleted'); - poff:=TranslateW('off'); - pa :=TranslateW('active'); - - for i:=1 to protocnt do - begin - if ((SBData[i].flags and (QSF_ACCDEL or QSF_ACCOFF))<>0) then - begin - icon:=Skin_LoadProtoIcon(nil,ID_STATUS_OFFLINE,0); - end - else - begin - icon:=Skin_LoadProtoIcon(GetProtoName(i),ID_STATUS_ONLINE,0); - end; - - FastAnsiToWideBuf(GetProtoName(i),fmtstr); - - SendMessageW(StatusBar,SB_SETICON,i,icon); - - j:=High(buf);//(SizeOf(buf) div SizeOf(WideChar))-1; - buf[j]:=#0; - - // fill by spaces - p:=@buf[0]; - while j>0 do - begin - dec(j); - p^:=' '; - inc(p); - end; - - if (SBData[i].flags and QSF_ACCDEL)<>0 then - begin - buf [0]:='!'; - pc:=pd; - end - else if (SBData[i].flags and QSF_ACCOFF)<>0 then - begin - buf [0]:='?'; - pc:=poff - end - else - pc:=pa; - - IntToStr(pWideChar(@buf[2]),SBData[i].found); - StrEndW(buf)^:=' '; - SendMessageW(StatusBar,SB_SETTEXTW,i,lparam(@buf)); - -// create tooltip -// FormatSimpleW('%s (%s): %i (%i); %s %i (%i)', -// [fmtstr,pc,found,total,po,liston,online]); - p:=@buf; - p:=StrCopyEW(p,fmtstr); // Protocol - p^:=' '; inc(p); - p^:='('; inc(p); - p:=StrCopyEW(p,pc); // Protocol status - p^:=')'; inc(p); - p^:=':'; inc(p); - p^:=' '; inc(p); - - with SBData[i] do - begin - p:=StrEndW(IntToStr(p,found)); - p^:=' '; inc(p); - p^:='('; inc(p); - p:=StrEndW(IntToStr(p,total)); - p^:=')'; inc(p); - p^:=';'; inc(p); - p^:=' '; inc(p); - p:=StrCopyEW(p,po); - p^:=' '; inc(p); - p:=StrEndW(IntToStr(p,liston)); - p^:=' '; inc(p); - p^:='('; inc(p); - p:=StrEndW(IntToStr(p,online)); - p^:=')'; inc(p); - end; - p^:=#0; - SendMessageW(StatusBar,SB_SETTIPTEXTW,i,lparam(@buf)); - end; - -end; - -procedure UpdateSB; -var - SBData: tSBData; - j:integer; - p:pSBDataRecord; -begin - FillChar(SBData,SizeOf(SBData),0); - - // for all contacts - for j:=0 to HIGH(FlagBuf) do - begin - p:=@SBData[FlagBuf[j].proto]; - p^.flags:=FlagBuf[j].flags; - - inc(p^.total); - - if (p^.flags and QSF_ACTIVE)<>0 then - begin - inc(p^.found); - inc(SBData[0].found); - end; - - if FlagBuf[j].status<>ID_STATUS_OFFLINE then - begin - inc(p^.online); - inc(SBData[0].online); - if (p^.flags and QSF_ACTIVE)<>0 then - begin - inc(p^.liston); - inc(SBData[0].liston); - end; - end; - - end; - - DrawSBW(SBData); -end; - -//----- Patterns ----- - -const - pattern:pWideChar = nil; // edit field text -const - maxpattern = 8; -var - patterns:array [0..maxpattern-1] of record - str:PWideChar; - res:bool; - end; -const - patstr:PWideChar=nil; // work pattern buffer - numpattern:integer=0; - -procedure MakePatternW; -var - lpatptr:PWideChar; - wasquote:bool; -begin - numpattern:=0; - mFreeMem(patstr); - if (pattern<>nil) and (pattern^<>#0) then - begin - wasquote:=false; - StrDupW(patstr,pattern); - lpatptr:=patstr; - repeat - while lpatptr^=' ' do inc(lpatptr); - if lpatptr^<>#0 then - begin - if lpatptr^='"' then - begin - inc(lpatptr); - wasquote:=true; - end - else - begin - patterns[numpattern].str:=lpatptr; - inc(numpattern); - while lpatptr^<>#0 do - begin - if wasquote then - begin - if lpatptr^='"' then - begin - wasquote:=false; - break; - end; - end - else if lpatptr^=' ' then - break; - inc(lpatptr); - end; - if lpatptr^<>#0 then - begin - lpatptr^:=#0; - inc(lpatptr); - end; - end; - if numpattern=maxpattern then break; - end; - until lpatptr^=#0; - end; -end; - -function CheckPatternW(cnt:integer):boolean; -var - lstr:array [0..1023] of WideChar; - i,j:integer; -begin - if numpattern>0 then - begin - for i:=0 to numpattern-1 do - patterns[i].res:=false; - - for i:=0 to qsopt.numcolumns-1 do - begin - if ((qsopt.columns[i].flags and (COL_ON or COL_FILTER))=(COL_ON or COL_FILTER)) and - (MainBuf[cnt,i].text<>nil) then - begin - StrCopyW(lstr,MainBuf[cnt,i].text,HIGH(lstr)); - CharLowerW(lstr); - for j:=0 to numpattern-1 do - if not patterns[j].res then - begin - if StrPosW(lstr,patterns[j].str)<>nil then //!! - patterns[j].res:=true; - end; - end; - end; - - result:=true; - for i:=0 to numpattern-1 do - result:=result and patterns[i].res; - end - else - result:=true; -end; - -//----- support (column index converters) ----- - -{ - ListView - ListView (visible) column - QS - Buffer column - Column - qsopt.columns -} - -function ListViewToColumn(col:integer):LPARAM; -var - i:integer; -begin - for i:=0 to qsopt.numcolumns-1 do - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - begin - dec(col); - if col<0 then - begin - result:=i; - exit; - end; - end; - end; - result:=-1; -end; - -function ColumnToListView(col:integer):LPARAM; -var - i:integer; -begin - result:=-1; - for i:=0 to qsopt.numcolumns-1 do - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - inc(result); - - dec(col); - if col<0 then - break; - end; -end; - -// return buffer index for contact -function FindBufNumber(hContact:THANDLE):integer; -var - i:integer; -begin - for i:=0 to HIGH(FlagBuf) do - begin - if FlagBuf[i].contact=hContact then - begin - result:=i; - exit; - end; - end; - result:=-1; -end; - -function IsColumnMinimized(num:integer):bool; -begin - result:=ListView_GetColumnWidth(grid,num)<=10; -end; diff --git a/plugins/QuickSearch/ico/default.ico b/plugins/QuickSearch/ico/default.ico deleted file mode 100644 index 59707dab07..0000000000 Binary files a/plugins/QuickSearch/ico/default.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/delete.ico b/plugins/QuickSearch/ico/delete.ico deleted file mode 100644 index c2ab44c6eb..0000000000 Binary files a/plugins/QuickSearch/ico/delete.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/down.ico b/plugins/QuickSearch/ico/down.ico deleted file mode 100644 index 79ec3929df..0000000000 Binary files a/plugins/QuickSearch/ico/down.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/female.ico b/plugins/QuickSearch/ico/female.ico deleted file mode 100644 index 581ff41d3b..0000000000 Binary files a/plugins/QuickSearch/ico/female.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/male.ico b/plugins/QuickSearch/ico/male.ico deleted file mode 100644 index b638465f43..0000000000 Binary files a/plugins/QuickSearch/ico/male.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/new.ico b/plugins/QuickSearch/ico/new.ico deleted file mode 100644 index ece3037034..0000000000 Binary files a/plugins/QuickSearch/ico/new.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/qs.ico b/plugins/QuickSearch/ico/qs.ico deleted file mode 100644 index f8c5526cfb..0000000000 Binary files a/plugins/QuickSearch/ico/qs.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/reload.ico b/plugins/QuickSearch/ico/reload.ico deleted file mode 100644 index feadf04bf2..0000000000 Binary files a/plugins/QuickSearch/ico/reload.ico and /dev/null differ diff --git a/plugins/QuickSearch/ico/up.ico b/plugins/QuickSearch/ico/up.ico deleted file mode 100644 index 6efc4d7257..0000000000 Binary files a/plugins/QuickSearch/ico/up.ico and /dev/null differ diff --git a/plugins/QuickSearch/make.bat b/plugins/QuickSearch/make.bat deleted file mode 100644 index 75543684c2..0000000000 --- a/plugins/QuickSearch/make.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off -set p1=%1 -set p2=%2 -if "%p1%" == "" (echo "please specify target platform by adding 'fpc' or 'fpc64' parameter to command line!"&&pause&&goto :EOF) -if "%p2%" == "" (echo "please specify target output directory by adding '15' for bin15 to command line!"&&pause&&goto :EOF) -if /i '%1' == 'fpc' ( - set OUTDIR="..\..\bin%2\Release\Plugins" - set FPCBIN=fpc.exe -) else if /i '%1' == 'fpc64' ( - set OUTDIR="..\..\bin%2\Release64\Plugins" - set FPCBIN=ppcrossx64.exe -) -set PROJECT=QuickSearch - -if not exist %OUTDIR% mkdir %OUTDIR% -md tmp - -brcc32.exe qs.rc -foqs.res -rc version.rc - -%FPCBIN% @..\Utils.pas\fpc.cfg %PROJECT%.dpr %3 %4 %5 %6 %7 %8 %9 -if errorlevel 1 exit /b 1 - -move .\tmp\%PROJECT%.dll %OUTDIR% -move .\tmp\%PROJECT%.map . -del /Q tmp\* -rd tmp -exit /b 0 diff --git a/plugins/QuickSearch/qs.rc b/plugins/QuickSearch/qs.rc deleted file mode 100644 index 35c425a3ab..0000000000 --- a/plugins/QuickSearch/qs.rc +++ /dev/null @@ -1,168 +0,0 @@ -#include "resource.inc" - -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL - -IDD_FRAME DIALOGEX 0, 0, 114, 16, 0 -STYLE DS_SETFONT | WS_CHILD | DS_FIXEDSYS -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0 -{ - PUSHBUTTON "*", IDC_FRAME_OPEN, 2, 2, 12, 12, BS_ICON - EDITTEXT IDC_FRAME_EDIT, 16, 2, 96, 12 -// PUSHBUTTON "<", IDC_FRAME_PREV, 80, 2, 15, 12 -// PUSHBUTTON ">", IDC_FRAME_NEXT, 97, 2, 15, 12 -} - -/* -IDD_SCRIPT DIALOGEX 0, 0, 256, 82, 0 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_VISIBLE | WS_THICKFRAME -CAPTION "Script Editor" -//EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0 -{ - EDITTEXT IDC_EDIT_SCRIPT , 4, 4, 248, 56, - ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - PUSHBUTTON "&OK" , IDOK , 106, 64, 46, 14 - PUSHBUTTON "&Help" , IDHELP , 156, 64, 46, 14 - PUSHBUTTON "C&ancel", IDCANCEL , 206, 64, 46, 14 -} -*/ -IDD_DIALOG1 DIALOGEX 0, 0, 314, 250 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "Ms Shell Dlg",0,0 -{ - CONTROL "Reload" ,IDC_RELOAD ,"MButtonClass",WS_TABSTOP, 2,148,16,16,$18000000 - CONTROL "New" ,IDC_NEW ,"MButtonClass",WS_TABSTOP, 32,148,16,16,$18000000 - CONTROL "Up" ,IDC_UP ,"MButtonClass",WS_TABSTOP, 62,148,16,16,$18000000 - CONTROL "Down" ,IDC_DN ,"MButtonClass",WS_TABSTOP, 80,148,16,16,$18000000 - CONTROL "Delete" ,IDC_DELETE ,"MButtonClass",WS_TABSTOP,112,148,16,16,$18000000 - CONTROL "Default",IDC_DEFAULT,"MButtonClass",WS_TABSTOP,142,148,16,16,$18000000 - - CONTROL "List2",IDC_LIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | - WS_BORDER | WS_TABSTOP,0,2,158,144 - - CONTROL ">>",IDC_B_RESIZE,"Button", BS_FLAT | WS_TABSTOP,160,2,10,246 - - // Common header - CTEXT "Settings",IDC_S_COLSETTING,172,2,139,12, SS_CENTERIMAGE - CONTROL "", IDC_S_LINE, "STATIC", SS_ETCHEDHORZ, 172,14,139,2 - - LTEXT "Title:",IDC_S_TITLE,174,16,137,12, SS_CENTERIMAGE - EDITTEXT IDC_E_TITLE,172,28,139,14, ES_AUTOHSCROLL | WS_TABSTOP - - // TYPE - LTEXT "Type:",IDC_S_VARTYPE,174,44,137,12, SS_CENTERIMAGE - COMBOBOX IDC_C_VARTYPE,172,56,139,80, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | - WS_VSCROLL | WS_TABSTOP - - // SETTING - LTEXT "Data type:" ,IDC_S_DATATYPE, 174,72,137,12, SS_CENTERIMAGE - COMBOBOX IDC_C_DATATYPE, 172,84,139,80, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | - WS_VSCROLL | WS_TABSTOP - - LTEXT "Module:", IDC_S_MODULE, 174,104,137,12, SS_CENTERIMAGE - EDITTEXT IDC_E_MODULE, 172,116,139,14, ES_AUTOHSCROLL | WS_TABSTOP - - LTEXT "Setting:", IDC_S_SETTING, 174,132,137,12, SS_CENTERIMAGE - EDITTEXT IDC_E_SETTING, 172,144,139,14, ES_AUTOHSCROLL | WS_TABSTOP - - // CONTACTINFO - LTEXT "InfoType:",IDC_S_CNFTYPE, 174,72,137,12, SS_CENTERIMAGE - COMBOBOX IDC_C_CNFTYPE, 172,84,139,80, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | - WS_VSCROLL | WS_TABSTOP - - // SERVICE - - // SCRIPT - EDITTEXT IDC_E_SCRIPT, 172,72,139,14, ES_AUTOHSCROLL | WS_TABSTOP - - // -- NO PARAM -- - COMBOBOX IDC_C_OTHER, 172,72,139,150, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - - - PUSHBUTTON "Save", IDC_SETITEM, 259,234,52,14, WS_TABSTOP - - CONTROL "Tool Window Style",IDC_CH_USETOOLSTYLE,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,176,152,12 - CONTROL "Draw Grid",IDC_CH_DRAWGRID,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,188,152,12 - CONTROL "Save search pattern",IDC_CH_SAVEPATTERN,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,200,152,12 - CONTROL "Auto Close mode",IDC_CH_AUTOCLOSE,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,212,152,12 - CONTROL "Sort by Status",IDC_CH_SORTSTATUS,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,224,152,12 - CONTROL "Show Client Icons",IDC_CH_CLIENTICONS,"Button", - BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,3,236,152,12 - GROUPBOX "Additional Options",IDC_CH_GROUP,0,168,158,82 -} - -IDI_QS ICON DISCARDABLE "ico\qs.ico" - -IDI_NEW ICON DISCARDABLE "ico\new.ico" -IDI_UP ICON DISCARDABLE "ico\up.ico" -IDI_DOWN ICON DISCARDABLE "ico\down.ico" -IDI_DELETE ICON DISCARDABLE "ico\delete.ico" -IDI_DEFAULT ICON DISCARDABLE "ico\default.ico" -IDI_RELOAD ICON DISCARDABLE "ico\reload.ico" - -IDI_MALE ICON DISCARDABLE "ico\male.ico" -IDI_FEMALE ICON DISCARDABLE "ico\female.ico" - -IDD_MAIN DIALOGEX 40, 40, 520, 240 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CAPTION | WS_VISIBLE | WS_BORDER | WS_SYSMENU | - WS_DLGFRAME | WS_OVERLAPPED | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "Ms Shell Dlg",0,0 -{ - EDITTEXT IDC_E_SEARCHTEXT, 180,8,276,14, WS_TABSTOP// | ES_LOWERCASE - PUSHBUTTON "Close" , IDCANCEL , 462, 0,52,14, WS_TABSTOP - PUSHBUTTON "Refresh", IDC_REFRESH, 462,16,52,14, WS_TABSTOP - - CONTROL "Show Offline contacts",IDC_CH_SHOWOFFLINE,"Button", - BS_AUTOCHECKBOX | BS_FLAT | BS_MULTILINE | BS_VCENTER | WS_TABSTOP,2,0,96,20 - CONTROL "Colorize",IDC_CH_COLORIZE,"Button", - BS_AUTOCHECKBOX | BS_FLAT | BS_MULTILINE | BS_VCENTER | WS_TABSTOP,2,20,96,10 -// LTEXT "Search for:",-1, 4,4,52,14, SS_CENTERIMAGE - COMBOBOX IDC_CB_PROTOCOLS,100,8,76,80, CBS_DROPDOWNLIST | - CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - CONTROL "", IDC_LIST, "SysListView32", WS_BORDER | WS_TABSTOP | // LVS_SHAREIMAGELISTS | // LVS_EX_SUBITEMIMAGES | - LVS_SHOWSELALWAYS | LVS_REPORT | LVS_NOLABELWRAP, - 2, 32, 516, 194 //, WS_EX_CONTROLPARENT - - CONTROL "", IDC_STATUSBAR, "msctls_statusbar32", - CCS_BOTTOM | 0x0900, // SBT_TOOLTIPS | SBARS_SIZEGRIP - 0,226,520,14 -} -/* -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,2,0 - PRODUCTVERSION 1,4,0,0 - FILEFLAGSMASK $3F - FILEOS 4 - FILETYPE 2 - FILESUBTYPE 0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName","" - VALUE "Comments", "Plugin to quick search for nickname, firstname, lastname, email, uin in your contact list"0 - VALUE "FileDescription", "Quick info search plugin for Miranda NG"0 - VALUE "FileVersion", "1, 4, 2, 0 "0 - VALUE "InternalName", "QuickSearch"0 - VALUE "OriginalFilename", "quicksearch.dll"0 - VALUE "ProductName", "QuickSearch Dynamic Link Library (DLL)"0 - VALUE "ProductVersion", "1, 4, 2, 0 "0 - VALUE "SpecialBuild", "12.09.2012 "0 - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation",0,1200 - END -END -*/ \ No newline at end of file diff --git a/plugins/QuickSearch/quicksearch.dpr b/plugins/QuickSearch/quicksearch.dpr deleted file mode 100644 index 8ea5f85e71..0000000000 --- a/plugins/QuickSearch/quicksearch.dpr +++ /dev/null @@ -1,145 +0,0 @@ -{$include compilers.inc} -{$IFDEF COMPILER_16_UP} - {$WEAKLINKRTTI ON} - {.$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} -{$ENDIF} -{$IMAGEBASE $13100000} -library quicksearch; - -{$R qs.res} -{$R version.res} - -uses -// FastMM4, - Windows, - Messages, - m_api, - sr_optdialog, - sr_global, - sr_window, - sr_frame, - mirutils, - common; - -function OnTTBLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - addtotoolbar; - result:=0; -end; - -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - ttb:TTBButton; -begin - result:=0; - -// toptoolbar - if ServiceExists(MS_TTB_GETBUTTONOPTIONS) then - begin - CallService(MS_TTB_GETBUTTONOPTIONS,(hTTBButton shl 16)+TTBO_ALLDATA,TLPARAM(@ttb)); - ttb.hIconUp:=IcoLib_GetIcon(QS_QS,0); - ttb.hIconDn:=ttb.hIconUp; - CallService(MS_TTB_SETBUTTONOPTIONS,(hTTBButton shl 16)+TTBO_ALLDATA,TLPARAM(@ttb)); - end; - -end; - -const - IconAmount = 9; -const - Icons:array [0..IconAmount-1] of tIconItem = ( - (szDescr: 'Quick Search' ; szName: 'QS' ; defIconID: IDI_QS ; size: 0; hIcolib: 0;), - (szDescr: 'New Column' ; szName: 'New' ; defIconID: IDI_NEW ; size: 0; hIcolib: 0;), - (szDescr: 'Column Up' ; szName: 'Up' ; defIconID: IDI_UP ; size: 0; hIcolib: 0;), - (szDescr: 'Column Down' ; szName: 'Down' ; defIconID: IDI_DOWN ; size: 0; hIcolib: 0;), - (szDescr: 'Delete Column'; szName: 'Delete' ; defIconID: IDI_DELETE ; size: 0; hIcolib: 0;), - (szDescr: 'Default' ; szName: 'Default'; defIconID: IDI_DEFAULT; size: 0; hIcolib: 0;), - (szDescr: 'Reload' ; szName: 'Reload' ; defIconID: IDI_RELOAD ; size: 0; hIcolib: 0;), - (szDescr: 'Male' ; szName: 'Male' ; defIconID: IDI_MALE ; size: 0; hIcolib: 0;), - (szDescr: 'Female' ; szName: 'Female' ; defIconID: IDI_FEMALE ; size: 0; hIcolib: 0;) - ); - -procedure RegisterIcons; -begin - Icon_Register(hInstance, qs_module, @Icons, IconAmount, 'QS'); - HookEvent(ME_SKIN_ICONSCHANGED,@IconChanged); -end; - -function OnOptInitialise(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - odp:TOPTIONSDIALOGPAGE; -begin - ZeroMemory(@odp,sizeof(odp)); - odp.Position :=900003000; - odp.pszTemplate:=PAnsiChar(IDD_DIALOG1); - odp.szTitle.a :=qs_name; - odp.szGroup.a :='Contacts'; - odp.pfnDlgProc :=@sr_optdialog.DlgProcOptions; - odp.flags :=ODPF_BOLDGROUPS; - Options_AddPage(wParam,@odp); - Result:=0; -end; - -function OpenSearchWindow(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; -begin - result:=0; - OpenSrWindow(pointer(wParam),lParam) -end; - -function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - RegisterIcons; - RegisterColors; - - CreateServiceFunction(QS_SHOWSERVICE,@OpenSearchWindow); - AddRemoveMenuItemToMainMenu; - - reghotkeys; - - HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded); - - CreateFrame(0); - - Result:=0; -end; - -function Load():integer;cdecl; -begin - Result:=0; - Langpack_register; - HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise); - HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded); - qsopt.numcolumns:=loadopt_db(qsopt.columns); -end; - -function Unload:integer;cdecl; -begin - result:=0; - removetoolbar; - DestroyFrame; - - CloseSrWindow; - - clear_columns(qsopt.columns); -end; - -exports - Load, Unload; - -begin - DisableThreadLibraryCalls(hInstance); - - PluginInfo.cbSize :=SizeOf(TPLUGININFOEX); - PluginInfo.shortName :='Quick Search'; - PluginInfo.version :=$01040200; - PluginInfo.description:= - 'This plugin allows you to quick search for nickname, '+ - 'firstname, lastname, email, uin in your contact list. '+ - 'And now you may add any setting to display - for example '+ - 'user''s version of Miranda, group or city.'; - PluginInfo.author :='Awkward, based on Bethoven sources'; - PluginInfo.copyright :='(c) 2004-05 Bethoven; 2006-13 Awkward'; - PluginInfo.homepage :='https://miranda-ng.org/p/QuickSearch/'; - PluginInfo.flags :=UNICODE_AWARE; - PluginInfo.uuid :=MIID_QUICKSEARCH; -end. diff --git a/plugins/QuickSearch/quicksearch_history.txt b/plugins/QuickSearch/quicksearch_history.txt deleted file mode 100644 index f7b8af5f18..0000000000 --- a/plugins/QuickSearch/quicksearch_history.txt +++ /dev/null @@ -1,115 +0,0 @@ -Service: - wParam: 0, or pattern string - lParam: 0 - wParam has unicode string; - 1 - Ansi String (only Unicode plugin version) - 2 - wParam is contact handle to select (not realized) - service:"QuickSearch_PLUGIN/Show" - -History: - -1.4.2.0 (27 dec 2013) - Options dialog redesign - Lot of internal changes - "life" sync between option dialog and main window removed - Contact list frame removed -1.4.1.19 () - FastMM4 memory manager used (not native Delphi or miranda) - Fixed some Memory leaks -1.4.1.18 (2 jul 2010) - Doubleclick/Enter on contact set as Clist doubleclick action - Group list sorted now - Fixed main window Refresh action (F5 and button) - Added frame button to open Main QS window -1.4.1.17 (5 may 2010) - Added contact list frame - Fixed columns sort - Added right click on columns header processing - Filter applying just for visible columns now - Added tooltip for hidden columns info - Added several User Info fields - Added button and hotkey F5 to refresh content of main window - Partial code refactoring - Fixed again info showing in window with hidden columns -1.4.0.16 (16 jul 2009) - Fixed info showing in window with hidden columns -1.4.0.15 (13 jul 2009) - Fixed empty line for hidden contacts and contacts of disabled accounts -1.4.0.14 (11 jul 2009) - Added checkbox for hide columns from showing -1.4.0.13 (10 jul 2009) - Added context menu item to combine selected contacts to metacontact - Added new column type for metacontacts - Added colorization for metacontacts -1.4.0.12 (jun 2009) - Fixed fields drawing in options dialog - Added colorisation for not-in-list contacts and on switched off or deleted accounts - Fixes for Statusbar - Fixes for Show/hide offline contacts -1.4.0.11 (13 mar 2009) - Added column type "Variables script" - Added translation to column types - Fixed Show/hide offline contacts behaviour - Fixed one of unicode localization bugs - Fixed contact copying to Clipboard -1.4.0.10 (19 oct 2008) - Some fixes - Some WinAPI/Delphi functions replaced by handmaked - Added support for Miranda core hotkeys (ver 8.0+) - Added:Drag&Drop (realtime) QS list column reordering - In option:list scrolling to newly added items - Added ANSI code part - Fixed: empty LastEvent field was at top of event list -1.4.0.9 (11 sep 2008) - Fixed: Can crashed with content filter - Maked list filling faster - Changed: maximum column amount changing dynamically now - Source changed: AnsiChar replaced by AnsiChar - Removed some codeparts for Miranda v0.5 compatibility - Fixed: wrong QS window width resizing -1.4.0.8 (28 aug 2008) - Fixed crash while adding contact with opened QS window -1.4.0.7 (21 jul 2008) - Added icons for XStatus - Fixed unicode filter - Added internal caching -(29 oct 2007) - Added tooltips for IM-client and gender columns - Changed QS window icon assign code - Changed group of contacts delete code - Added filter groups in "" (start quote must be first AnsiChar or after space) -(19 may 2007) - Added option to save text search pattern -1.4.0.6 (09 mar 2007) - Added: Option to skip 'minimized' columns while copying to Clipboard - Fixed: Abort context menu move contacts to first group in list - Ctrl-C (or &Copy context menu command) copying info with TAB separated fields - Added: new miranda API support -1.4.0.5 (21 jan 2007) - Fixed: Contact menu do not execute action when Auto close mode is ON - Fixed: Gender icon not shown when icolib not installed - Partially solved problem with large system fonts - Fixed: changed menu/toolbar icon was not set at start - Added Gender reading from UserInfo, not only protocol -1.4.0.4 (22 dec 2006) - Added Male/Female icon and special gender processing - Letters and BackSpace works in the list - Ctrl-C in list copying contact info to Clipboard - Added StatusBar - Slightly modified Option page - Added option to disable client icon - Added Updater support - Added IcoLib support -1.4.0.3 (18 dec 2006) - Service was advanced - Fixed: Enter on edit field removes contact from group -1.4.0.2 (17 dec 2006) - Added option to show/hide offline contacts - Added "Stay on top" option to sysmenu - Fixed: context menu shown only one time -1.4.0.1 (17 dec 2006) - Fixed: Options not shown in Miranda before 0.6 version - Small code and interface changes - First item in list now focused automatically - Fixed: search pattern work only with small characters -1.4.0.0 (14 dec 2006) - Initial release \ No newline at end of file diff --git a/plugins/QuickSearch/resource.inc b/plugins/QuickSearch/resource.inc deleted file mode 100644 index 8dfa7fd0fb..0000000000 --- a/plugins/QuickSearch/resource.inc +++ /dev/null @@ -1,69 +0,0 @@ -const - IDD_DIALOG1 = 101; - IDD_MAIN = 102; - IDD_SCRIPT = 103; - IDD_FRAME = 104; - - IDI_QS = 107; - - IDI_NEW = 110; - IDI_UP = 111; - IDI_DOWN = 112; - IDI_DELETE = 113; - IDI_DEFAULT = 114; - IDI_RELOAD = 115; - - IDI_MALE = 120; - IDI_FEMALE = 121; - - IDC_NEW = 1001; - IDC_DELETE = 1002; - IDC_UP = 1003; - IDC_DN = 1004; - IDC_DEFAULT = 1005; - IDC_SETITEM = 1006; - IDC_RELOAD = 1007; - - IDC_LIST = 1010; - IDC_B_RESIZE = 1011; - - IDC_CH_SORTSTATUS = 1030; - IDC_CH_AUTOCLOSE = 1031; - IDC_CH_USETOOLSTYLE = 1032; - IDC_CH_DRAWGRID = 1033; - IDC_CH_CLIENTICONS = 1034; - IDC_CH_SAVEPATTERN = 1035; - IDC_CH_GROUP = 1040; - - IDC_S_COLSETTING = 1020; - IDC_S_LINE = 1021; - - IDC_E_TITLE = 1022; - IDC_S_TITLE = 1023; - IDC_C_VARTYPE = 1024; - IDC_S_VARTYPE = 1025; - - IDC_E_SCRIPT = 2001; - - IDC_S_DATATYPE = 2010; - IDC_C_DATATYPE = 2011; - IDC_S_MODULE = 2012; - IDC_E_MODULE = 2013; - IDC_S_SETTING = 2014; - IDC_E_SETTING = 2015; - - IDC_S_CNFTYPE = 2020; - IDC_C_CNFTYPE = 2021; - - IDC_C_OTHER = 2030; - - - IDC_E_SEARCHTEXT = 1001; - IDC_CH_SHOWOFFLINE = 1031; - IDC_CH_COLORIZE = 1032; - IDC_REFRESH = 1033; - IDC_STATUSBAR = 1034; - IDC_CB_PROTOCOLS = 1035; - - IDC_FRAME_OPEN = 1050; - IDC_FRAME_EDIT = 1051; diff --git a/plugins/QuickSearch/sr_frame.pas b/plugins/QuickSearch/sr_frame.pas deleted file mode 100644 index e3979c5d9e..0000000000 --- a/plugins/QuickSearch/sr_frame.pas +++ /dev/null @@ -1,211 +0,0 @@ -unit sr_frame; - -interface - -uses windows; - -procedure CreateFrame(parent:HWND); -procedure DestroyFrame; - -implementation - -uses commctrl,Messages,m_api,common,wrapper,mirutils,sr_global; - -{$include resource.inc} - -const - frm_back:pAnsiChar = 'Frame background'; -const - FrameWnd:HWND = 0; - FrameId:integer = -1; - OldEditProc:pointer=nil; - pattern:pWideChar=nil; -var - colorhook:THANDLE; - hbr:HBRUSH; - frm_bkg:TCOLORREF; - -function NewEditProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -begin -// result:=0; - case hMessage of - WM_CHAR: begin - if wParam=27 then - begin - // clear edit field - SendMessage(Dialog,WM_SETTEXT,0,0); - result:=0; - end - else if wParam=13 then - begin - CallService(QS_SHOWSERVICE,twparam(pattern),0); - result:=0; - end - else - result:=1; - if result=0 then - exit; - end; - end; - result:=CallWindowProc(OldEditProc,Dialog,hMessage,wParam,lParam); -end; - -function QSDlgResizer(Dialog:HWND;lParam:LPARAM;urc:PUTILRESIZECONTROL):int; cdecl; -begin - case urc^.wId of - IDC_FRAME_OPEN: result:=RD_ANCHORX_LEFT or RD_ANCHORY_CENTRE; - IDC_FRAME_EDIT: result:=RD_ANCHORX_WIDTH or RD_ANCHORY_CENTRE; - else - result:=0; - end; -end; - -function QSFrameProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -var - rc:TRECT; - TI:TTOOLINFOW; - hwndTooltip:HWND; -begin - result:=0; - case hMessage of - WM_DESTROY: begin - DeleteObject(hbr); - hbr:=0; - end; - - WM_INITDIALOG: begin - OldEditProc:=pointer(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_FRAME_EDIT), - GWL_WNDPROC,LONG_PTR(@NewEditProc))); - - hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP, - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - Dialog,0,hInstance,nil); - - FillChar(TI,SizeOf(TI),0); - TI.cbSize :=sizeof(TOOLINFO); - TI.uFlags :=TTF_IDISHWND or TTF_SUBCLASS; - TI.hwnd :=Dialog; - TI.hinst :=hInstance; - TI.uId :=GetDlgItem(Dialog,IDC_FRAME_OPEN); - TI.lpszText:=pWideChar(TranslateW('Open QS window')); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@TI)); - - SetButtonIcon(GetDlgItem(Dialog,IDC_FRAME_OPEN),QS_QS); - end; - - WM_SIZE: begin - Utils_ResizeDialog(Dialog, hInstance, MAKEINTRESOURCEA(IDD_FRAME), @QSDlgResizer); - end; - - WM_ERASEBKGND: begin - GetClientRect(Dialog,rc); - FillRect(wParam,rc,hbr); - result:=1; - end; - - WM_COMMAND: begin - case wParam shr 16 of - EN_CHANGE: begin - mFreeMem(pattern); - pattern:=GetDlgText(Dialog,IDC_FRAME_EDIT); - if pattern<>nil then - CharLowerW(pattern); - end; - - BN_CLICKED: begin - case loword(wParam) of - IDC_FRAME_OPEN: CallService(QS_SHOWSERVICE,twparam(pattern),0); - end; - end; - end; - end; - - else - result:=DefWindowProc(Dialog,hMessage,wParam,lParam); - end; -end; - -function ColorReload(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - result:=0; - frm_bkg:=Colour_Get('QuickSearch',frm_back); - DeleteObject(hbr); - hbr:=CreateSolidBrush(frm_bkg); - - RedrawWindow(FrameWnd,nil,0,RDW_ERASE); -end; - -procedure CreateFrame(parent:HWND); -var - Frame:TCLISTFrame; - wnd:HWND; - tmp:cardinal; - tr:TRECT; - cid:TColourID; -begin - if not ServiceExists(MS_CLIST_FRAMES_ADDFRAME) then - exit; - - hbr:=0; - - if parent=0 then - parent:=cli^.hwndContactList; - - if FrameWnd=0 then - FrameWnd:=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_FRAME),parent,@QSFrameProc); - - if FrameWnd<>0 then - begin - GetWindowRect(FrameWnd,tr); - FillChar(Frame,SizeOf(Frame),0); - with Frame do - begin - cbSize :=SizeOf(Frame); - hWnd :=FrameWnd; - hIcon :=IcoLib_GetIcon(QS_QS,0); - align :=alTop; - height :=tr.bottom-tr.top+2; - Flags :=F_NOBORDER or F_UNICODE; - name.w :='Quick search'; - TBName.w:='Quick search'; - end; - - FrameId:=CallService(MS_CLIST_FRAMES_ADDFRAME,wparam(@Frame),lparam(@g_Plugin)); - if FrameId>=0 then - begin - CallService(MS_CLIST_FRAMES_UPDATEFRAME,FrameId, FU_FMPOS); - - wnd:=cli^.hwndContactList; - tmp:=SendMessage(wnd,CLM_GETEXSTYLE,0,0); - SendMessage(wnd,CLM_SETEXSTYLE,tmp or CLS_EX_SHOWSELALWAYS,0); - - StrCopy(cid.group,'QuickSearch'); - StrCopy(cid.dbSettingsGroup,qs_module); - - StrCopy(cid.name ,frm_back); - StrCopy(cid.setting,'frame_back'); - cid.defcolour:=GetSysColor(COLOR_3DFACE); - cid.order :=0; - ColourRegister(@cid); - - colorhook:=HookEvent(ME_COLOUR_RELOAD,@ColorReload); - ColorReload(0,0); - end; - end; -end; - -procedure DestroyFrame; -begin - if FrameId>=0 then - begin - UnhookEvent(colorhook); - CallService(MS_CLIST_FRAMES_REMOVEFRAME,FrameId,0); - FrameId:=-1; - end; - DestroyWindow(FrameWnd); - FrameWnd:=0; - mFreeMem(pattern); -end; - -end. diff --git a/plugins/QuickSearch/sr_global.pas b/plugins/QuickSearch/sr_global.pas deleted file mode 100644 index 46313225d1..0000000000 --- a/plugins/QuickSearch/sr_global.pas +++ /dev/null @@ -1,832 +0,0 @@ -unit sr_global; - -interface -uses windows,messages,commctrl,m_api,dbsettings,mirutils,awkservices; - -const - QS_QS :PAnsiChar = 'QS_QS'; - QS_NEW :PAnsiChar = 'QS_New'; - QS_ITEM :PAnsiChar = 'QS_Item'; - QS_UP :PAnsiChar = 'QS_Up'; - QS_DOWN :PAnsiChar = 'QS_Down'; - QS_DELETE :PAnsiChar = 'QS_Delete'; - QS_DEFAULT:PAnsiChar = 'QS_Default'; - QS_RELOAD :PAnsiChar = 'QS_Reload'; - QS_MALE :PAnsiChar = 'QS_Male'; - QS_FEMALE :PAnsiChar = 'QS_Female'; -const - qs_module :PAnsiChar = 'QuickSearch'; - qs_name :PAnsiChar = 'Quick Search'; - QS_SHOWSERVICE:PAnsiChar = 'QuickSearch_PLUGIN/Show'; - -const - StatusSort = 1000; - -const //types - QSTS_BYTE = 0; - QSTS_WORD = 1; - QSTS_DWORD = 2; - QSTS_STRING = 3; - QSTS_IP = 4; - QSTS_TIMESTAMP = 5; - QSTS_SIGNED = 6; - QSTS_HEXNUM = 7; - - // must be non-zero for empty-column checking - QST_SETTING = 100; - QST_SCRIPT = 1; - QST_SERVICE = 2; - QST_CONTACTINFO = 3; - QST_OTHER = 200; - - QSTO_LASTSEEN = 0; - QSTO_LASTEVENT = 1; - QSTO_METACONTACT = 2; - QSTO_EVENTCOUNT = 3; - QSTO_DISPLAYNAME = 4; - -const - COL_ON = $0001; // Show column - COL_FILTER = $0004; // Filter column by pattern - // QS window runtime flags - COL_INIT = $0002; // No need to update - COL_XSTATUS = $0100; - COL_GENDER = $0200; - COL_CLIENT = $0400; - COL_GROUP = $0800; - COL_CNTNR = $1000; - COL_REFRESH = $FF02; // mask - -const - QSO_SORTBYSTATUS = $00000001; // Sort by status - QSO_DRAWGRID = $00000002; // Draw listview grid - QSO_TOOLSTYLE = $00000004; // QS window tool style - QSO_SAVEPATTERN = $00000008; // Save filter pattern - QSO_AUTOCLOSE = $00000010; // Close QS window after action - QSO_CLIENTICONS = $00000020; // Show client icons (fingerprint) - - QSO_MAINOPTIONS = $0000FFFF; // mask for common options - - // QS window options - QSO_STAYONTOP = $00010000; // Stay QS window on top - QSO_SHOWOFFLINE = $00020000; // Show offline contacts - QSO_COLORIZE = $00040000; // Colorize lines - QSO_SORTASC = $00080000; // Sort column ascending - -{$include resource.inc} - -type - pcolumnitem = ^tcolumnitem; - tcolumnitem = record - title :PWideChar; - setting_type :word; // QST_* constants - flags :word; // COL_* constants - width :word; - case integer of - // db setting - 0: ( - datatype:word; // QSTS_* constants - module :pAnsiChar; - setting :pAnsiChar; - ); - // script - 1: (script:pWideChar); - // service - 2: (service:tServiceValue); - // contact info - 3: (cnftype:word); // CNF_* constants - // other - 4: (other:word); // QSTO_* constants - end; - tcolumnarray = array of tcolumnitem; - -const - MaxColumnAmount = 64; -type - tqsopt = record - grrect :TRECT; // QS window rect - columns :array [0..MaxColumnAmount-1] of tcolumnitem; - numcolumns:integer; // columns array size (really, needs just for db reading) - columnsort:integer; // sorted column number - flags :dword; // QSO_* options - end; - - -procedure reghotkeys; - -procedure saveopt_wnd; -procedure loadopt_wnd; -function savecolumn(num:integer; const column:tcolumnitem):boolean; -procedure saveopt_db; -function loadopt_db(var columns:array of tcolumnitem):integer; -function loaddefaultcolumns(var columns:array of tcolumnitem):integer; - -function CloneColumns(var dst: array of tcolumnitem; const src:array of tcolumnitem):integer; -function CloneColumn (var dst:tcolumnitem; const src:tcolumnitem):boolean; - -procedure clear_columns(var columns:array of tcolumnitem); -procedure clear_column (var column:tcolumnitem); - -function new_column(var columns:array of tcolumnitem):integer; - -procedure AddRemoveMenuItemToMainMenu; -procedure addtotoolbar; -procedure removetoolbar; - -var - qsopt:tqsopt; - -const - MainMenuItem:integer=0; - hTTBButton :THANDLE=0; - -implementation - -uses common; - -const - HKN_GLOBAL:PAnsiChar = 'QS_Global'; -const - so_mbottom :PAnsiChar = 'mbottom'; - so_mright :PAnsiChar = 'mright'; - so_mtop :PAnsiChar = 'mtop'; - so_mleft :PAnsiChar = 'mleft'; - - so_columnsort :PAnsiChar = 'columnsort'; - so_flags :PAnsiChar = 'flags'; - - so_numcolumns :PAnsiChar = 'numcolumns'; - so_item :PAnsiChar = 'item'; - - so__title :PAnsiChar = '_title'; - so__width :PAnsiChar = '_width'; - so__flags :PAnsiChar = '_flags'; - so__setting_type :PAnsiChar = '_setting_type'; - - so__cnftype :PAnsiChar = '_cnftype'; - - so__datatype :PAnsiChar = '_datatype'; - so__module :PAnsiChar = '_module'; - so__setting :PAnsiChar = '_setting'; - - so__script :PAnsiChar = '_script'; - - so__service :PAnsiChar = '_service'; - so__restype :PAnsiChar = '_restype'; - so__wparam_type :PAnsiChar = '_wparam_type'; - so__lparam_type :PAnsiChar = '_lparam_type'; - so__wparam :PAnsiChar = '_wparam'; - so__lparam :PAnsiChar = '_lparam'; - - so__other :PAnsiChar = '_other'; - -procedure reghotkeys; -var - hkrec:THOTKEYDESC; -begin - FillChar(hkrec,SizeOf(hkrec),0); - with hkrec do - begin - pszName :=HKN_GLOBAL; - pszDescription.a:='QuickSearch window hotkey'; - pszSection.a :=qs_name; - pszService :=QS_SHOWSERVICE; - DefHotKey :=(HOTKEYF_ALT shl 8) or VK_F3; - end; - Hotkey_Register(@hkrec); -end; - -procedure removetoolbar; -begin - if hTTBButton<>0 then - begin - if ServiceExists(MS_TTB_REMOVEBUTTON) then - begin - CallService(MS_TTB_REMOVEBUTTON,WPARAM(hTTBButton),0); - hTTBButton:=0; - end; - end; -end; - -procedure addtotoolbar; -var - ttbopt:TTBButton; -begin - removetoolbar; - - if ServiceExists(MS_TTB_ADDBUTTON) then - begin - ZeroMemory(@ttbopt,sizeof(ttbopt)); - ttbopt.pszService := QS_SHOWSERVICE; - ttbopt.hIconUp := IcoLib_GetIcon(QS_QS,0); - ttbopt.hIconDn := ttbopt.hIconUp; - ttbopt.dwFlags := TTBBF_VISIBLE; - ttbopt.name := qs_module; - ttbopt.pszTooltipUp := qs_name; - ttbopt.pszTooltipDn := qs_name; - hTTBButton:=TopToolbar_AddButton(@ttbopt); - if hTTBButton=THANDLE(-1) then - hTTBButton:=0; - end; -end; - -procedure AddRemoveMenuItemToMainMenu; -var - mi:TMO_MenuItem; -begin - if MainMenuItem<>0 then exit; - - ZeroMemory(@mi,sizeof(mi)); - SET_UID(@mi, '98C2A92A-D93D-43E8-91C3-3BB6BE4344F0'); - mi.szName.a :=qs_name; - mi.position :=500050000; - mi.pszService :=QS_SHOWSERVICE; - mi.hIcon :=IcoLib_GetIcon(QS_QS,0); - MainMenuItem :=Menu_AddMainMenuItem(@mi); -end; - -// -------- column functions --------- - -function CloneColumn(var dst:tcolumnitem; const src:tcolumnitem):boolean; -begin - if src.setting_type=0 then - begin - result:=false; - exit; - end; - - move(src,dst,SizeOf(tcolumnitem)); - StrDupW(dst.title,dst.title); - case dst.setting_type of - QST_SETTING: begin - StrDup(dst.module,dst.module); - StrDup(dst.setting,dst.setting); - end; - QST_SCRIPT: begin - StrDupW(dst.script,dst.script); - end; - QST_SERVICE: begin - CopyServiceValue(dst.service,src.service); - end; - end; - result:=true; -end; - -function CloneColumns(var dst: array of tcolumnitem; const src:array of tcolumnitem):integer; -var - i,cnt:integer; -begin - cnt:=0; - for i:=0 to MaxColumnAmount-1 do - begin - if CloneColumn(dst[cnt],src[i]) then - inc(cnt); - end; - result:=cnt; -end; - -procedure clear_column(var column:tcolumnitem); -begin - if column.setting_type=0 then // empty already - exit; - - mFreeMem(column.title); - case column.setting_type of - QST_SETTING: begin - mFreeMem(column.module); - mFreeMem(column.setting); - end; - QST_SCRIPT: begin - mFreeMem(column.script); - end; - QST_SERVICE: begin - ClearServiceValue(column.service); - end; - QST_CONTACTINFO: begin - end; - QST_OTHER: begin - end; - end; - column.setting_type:=0; // mark as unused -end; - -procedure clear_columns(var columns:array of tcolumnitem); -var - i:integer; -begin - for i:=0 to MaxColumnAmount-1 do - clear_column(columns[i]); -end; - -function new_column(var columns:array of tcolumnitem):integer; -var - i:integer; -begin - result:=MaxColumnAmount-1; - for i:=0 to MaxColumnAmount-1 do - begin - if columns[i].setting_type=0 then // "empty" condition - begin - with columns[i] do - begin - StrDupW(title,'New column'); - width:=64; - flags:=COL_ON; - setting_type:=QST_SETTING; - end; - - result:=i; - break; - end; - end; -end; - -function loaddefaultcolumns(var columns:array of tcolumnitem):integer; -var - i:integer; -begin - clear_columns(columns); - // lazy to renumber if changes - i:=0; - - // account - with columns[i] do - begin - StrDupW(title,TranslateW('Account')); - width :=82; - flags :=COL_ON; - setting_type :=QST_SERVICE; - StrDup (service.service,'Proto/GetContactBaseAccount'); - service.flags :=ACF_TYPE_STRING; - service.w_flags:=ACF_TYPE_PARAM; - service.l_flags:=ACF_TYPE_NUMBER; - service.lparam :=nil; - end; - inc(i); - - // gender - with columns[i] do - begin - StrDupW(title,TranslateW('Gender')); - width :=20; - flags :=COL_ON; - setting_type :=QST_CONTACTINFO; - cnftype :=CNF_GENDER; - end; - inc(i); - - // uin - with columns[i] do - begin - StrDupW(title,TranslateW('UserID')); - width :=80; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_CONTACTINFO; - cnftype :=CNF_UNIQUEID; - end; - inc(i); - - // username(displayname) - with columns[i] do - begin - StrDupW(title,TranslateW('Nickname')); - width :=76; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_OTHER; - other :=QSTO_DISPLAYNAME; - end; - inc(i); - - // firstname - with columns[i] do - begin - StrDupW(title,TranslateW('First name')); - width :=68; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_CONTACTINFO; - cnftype :=CNF_FIRSTNAME; - end; - inc(i); - - // lastname - with columns[i] do - begin - StrDupW(title,TranslateW('Last name')); - width :=66; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_CONTACTINFO; - cnftype :=CNF_LASTNAME; - end; - inc(i); - - // group - with columns[i] do - begin - StrDupW(title,TranslateW('Group')); - width :=80; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_SETTING; - datatype :=QSTS_STRING; - StrDup(module ,'CList'); - StrDup(setting,'Group'); - end; - inc(i); - - // TabSRMM container - with columns[i] do - begin - StrDupW(title,TranslateW('Container')); - width :=80; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_SETTING; - datatype :=QSTS_STRING; - StrDup(module ,'Tab_SRMsg'); - StrDup(setting,'containerW'); - end; - inc(i); - - // email - with columns[i] do - begin - StrDupW(title,TranslateW('E-mail')); - width :=116; - flags :=COL_ON+COL_FILTER; - setting_type :=QST_CONTACTINFO; - cnftype :=CNF_EMAIL; - end; - inc(i); - - // miranda version - with columns[i] do - begin - StrDupW(title,TranslateW('Client ID')); - width :=60; - flags :=COL_ON; - setting_type:=QST_SETTING; - datatype :=QSTS_STRING; - StrDup(setting,'MirVer'); - end; - inc(i); - - // IP version - with columns[i] do - begin - StrDupW(title,TranslateW('Ext IP')); - width :=100; - flags :=0; - setting_type:=QST_SETTING; - datatype :=QSTS_IP; - StrDup(module ,'ICQ'); - StrDup(setting,'IP'); - end; - inc(i); - - // LastSeen - with columns[i] do - begin - StrDupW(title,TranslateW('LastSeen')); - width :=116; - flags :=0; - setting_type:=QST_OTHER; - other :=QSTO_LASTSEEN; - end; - inc(i); - - // last event - with columns[i] do - begin - StrDupW(title,TranslateW('Last Event')); - width :=100; - flags :=0; - setting_type:=QST_OTHER; - other :=QSTO_LASTEVENT; - end; - inc(i); - - // online since - with columns[i] do - begin - StrDupW(title,TranslateW('Online since')); - width :=100; - flags :=0; - setting_type:=QST_SETTING; - datatype :=QSTS_TIMESTAMP; - StrDup(module ,'ICQ'); - StrDup(setting,'LogonTS'); - end; - inc(i); - - // metacontacts - with columns[i] do - begin - StrDupW(title,TranslateW('Metacontact')); - width :=50; - flags :=0; - setting_type:=QST_OTHER; - other :=QSTO_METACONTACT; - end; - inc(i); - - // events - with columns[i] do - begin - StrDupW(title,TranslateW('Event count')); - width :=50; - flags :=0; - setting_type:=QST_OTHER; - other :=QSTO_EVENTCOUNT; - end; - inc(i); - - // Contact add time - with columns[i] do - begin - StrDupW(title,TranslateW('Contact add time')); - width :=80; - flags :=COL_ON; - setting_type :=QST_SETTING; - datatype :=QSTS_TIMESTAMP; - StrDup(module ,'UserInfo'); - StrDup(setting,'ContactAddTime'); - end; - inc(i); - - result:=i; -end; - -// -------- save/load settings --------- - -procedure WriteInt(setting:PAnsiChar;value:int); -begin - DBWriteDword(0,qs_module,setting,value) -end; -procedure WriteWord(setting:PAnsiChar;value:word); -begin - DBWriteWord(0,qs_module,setting,value) -end; -procedure WriteStr(setting:PAnsiChar;value:PAnsiChar); -begin - DBWriteString(0,qs_module,setting,value) -end; -procedure WriteUnicode(setting:PAnsiChar;value:PWideChar); -begin - DBWriteUnicode(0,qs_module,setting,value) -end; - -procedure saveopt_wnd; -begin - WriteInt(so_mbottom ,qsopt.grrect.bottom); - WriteInt(so_mright ,qsopt.grrect.right); - WriteInt(so_mtop ,qsopt.grrect.top); - WriteInt(so_mleft ,qsopt.grrect.left); - - WriteInt(so_flags ,qsopt.flags); - WriteInt(so_columnsort ,qsopt.columnsort); -end; - -function savecolumn(num:integer; const column:tcolumnitem):boolean; -var - buf:array [0..127] of AnsiChar; - p,pp:PAnsiChar; -begin - if column.setting_type=0 then - begin - result:=false; - exit; - end; - result:=true; - - pp:=StrCopyE(buf,so_item); - p:=StrEnd(IntToStr(pp,num)); - with column do - begin - StrCopy(p,so__title); WriteUnicode(buf,title); - StrCopy(p,so__setting_type); WriteWord(buf,setting_type); - StrCopy(p,so__flags); WriteWord(buf,flags and not COL_REFRESH); - StrCopy(p,so__width); WriteWord(buf,width); - case setting_type of - QST_SETTING: begin - StrCopy(p,so__datatype); WriteWord(buf,datatype); - StrCopy(p,so__module ); WriteStr (buf,module); - StrCopy(p,so__setting ); WriteStr (buf,setting); - end; - - QST_SCRIPT: begin - StrCopy(p,so__script); WriteUnicode(buf,script); - end; - - QST_CONTACTINFO: begin - StrCopy(p,so__cnftype); WriteWord(buf,cnftype); - end; - - QST_SERVICE: begin - p^:=#0; - SaveServiceValue(service,qs_module,buf); - end; - - QST_OTHER: begin - StrCopy(p,so__other); WriteWord(buf,other); - end; - end; - end; -end; - -procedure saveopt_db; -var - i,cnt:integer; -begin - DBDeleteGroup(0,qs_module,'item*'); - WriteInt(so_flags,qsopt.flags); - - cnt:=0; - for i:=0 to MaxColumnAmount-1 do - begin - if savecolumn(cnt,qsopt.columns[i]) then - inc(cnt); - end; - WriteWord(so_numcolumns,cnt); -end; - -function GetInt(setting:PAnsiChar;default:integer):integer; -begin - result:=DBReadDWord(0,qs_module,setting,default); -end; -function GetWord(setting:PAnsiChar;default:word):word; -begin - result:=DBReadWord(0,qs_module,setting,default); -end; -function GetStr(setting:PAnsiChar):PAnsiChar; -begin - result:=DBReadString(0,qs_module,setting,nil); -end; -function GetUnicode(setting:PAnsiChar):PWideChar; -begin - result:=DBReadUnicode(0,qs_module,setting,nil); -end; - -{ - if "fast"writing enabled - fill columns accordingly comumn order array -} - -procedure loadopt_wnd; -begin - qsopt.grrect.bottom:=GetInt(so_mbottom,240); - qsopt.grrect.right :=GetInt(so_mright ,550); - qsopt.grrect.top :=GetInt(so_mtop ,0); - qsopt.grrect.left :=GetInt(so_mleft ,0); - - qsopt.columnsort :=GetInt(so_columnsort,StatusSort); - qsopt.flags :=GetInt(so_flags,QSO_SORTBYSTATUS+QSO_DRAWGRID+QSO_CLIENTICONS+ - QSO_COLORIZE+QSO_SORTASC); -end; - -const - ACF_OLD_NUMBER = 1; - ACF_OLD_STRING = 0; - ACF_OLD_UNICODE = 2; - ACF_OLD_PARTYPE = $FF; - -function loadopt_db(var columns:array of tcolumnitem):integer; -var - buf:array [0..127] of AnsiChar; - buf1:array [0..31] of WideChar; - p,pp:PAnsiChar; - tmp:PAnsiChar; - i:integer; -begin - if DBGetSettingType(0,qs_module,so_flags)=DBVT_DELETED then - begin - db_delete_module(0,qs_module); - qsopt.flags:= - QSO_SORTBYSTATUS or QSO_DRAWGRID or - QSO_CLIENTICONS or QSO_COLORIZE or - QSO_SORTASC; - result:=0; - end - else - begin - qsopt.flags:=GetInt(so_flags, - QSO_SORTBYSTATUS or QSO_DRAWGRID or - QSO_CLIENTICONS or QSO_COLORIZE or - QSO_SORTASC); - result:=GetWord(so_numcolumns,0); - end; - - if result=0 then - begin - result:=loaddefaultcolumns(columns); - saveopt_db; - end - else - begin - clear_columns(columns); - - pp:=StrCopyE(buf,so_item); -//?? FillChar(qsopt.columns[0],SizeOf(qsopt.columns),0); - for i:=0 to result-1 do - begin - p:=StrEnd(IntToStr(pp,i)); - with columns[i] do - begin - StrCopy(p,so__setting_type); setting_type:=GetWord(buf,0); - StrCopy(p,so__title); title:=GetUnicode(buf); - StrCopy(p,so__width); width:=GetWord(buf,20); - StrCopy(p,so__flags); flags:=GetWord(buf,COL_ON) and not COL_REFRESH; - - if (title='Nickname') then begin - setting_type:=QST_OTHER; - other:=QSTO_DISPLAYNAME; - continue; - end; - - case setting_type of - QST_SETTING: begin - StrCopy(p,so__datatype); datatype:=GetWord(buf,0); - StrCopy(p,so__module ); module :=GetStr (buf); - StrCopy(p,so__setting ); setting :=GetStr (buf); - end; - - QST_SCRIPT: begin - StrCopy(p,so__script); script:=GetUnicode(buf); - end; - - QST_CONTACTINFO: begin - StrCopy(p,so__cnftype); cnftype:=GetWord(buf,0); - end; - - QST_SERVICE: begin //!!!! - // check for old settings - StrCopy(p,so__service); service.service:=GetStr(buf); - // new format - if service.service=nil then - begin - p^:=#0; - LoadServiceValue(service,qs_module,buf); - end - //----- old format ----- - else - begin - StrCopy(p,so__restype ); service.flags :=ConvertResultFlags(GetInt(buf,0)); - StrCopy(p,so__wparam_type); service.w_flags:=ConvertParamFlags (GetInt(buf,0)); - StrCopy(p,so__lparam_type); service.l_flags:=ConvertParamFlags (GetInt(buf,0)); - - //----- WPARAM ----- - StrCopy(p,so__wparam); - case service.w_flags and ACF_TYPE_MASK of - // cheat - ACF_TYPE_CURRENT: begin - service.w_flags:=(service.w_flags and not ACF_TYPE_CURRENT) or ACF_TYPE_PARAM; - end; - - ACF_TYPE_NUMBER : begin - if DBGetSettingType(0,qs_module,buf) in [DBVT_WORD,DBVT_DWORD] then - StrDupW(PWideChar(service.wparam),IntToStr(buf1,GetInt(buf,0))) - else - service.wparam:=pointer(GetUnicode(buf)); - end; - // ansi convert to unicode - ACF_TYPE_STRING : begin - tmp:=GetStr(buf); - AnsiToWide(tmp,PWideChar(service.wparam),MirandaCP); - mFreeMem(tmp); - end; - ACF_TYPE_UNICODE: service.wparam:=pointer(GetUnicode(buf)); - end; - - //----- LPARAM ----- - StrCopy(p,so__lparam); - case service.l_flags and ACF_TYPE_MASK of - // cheat - ACF_TYPE_CURRENT: begin - service.l_flags:=(service.l_flags and not ACF_TYPE_CURRENT) or ACF_TYPE_PARAM; - end; - - ACF_TYPE_NUMBER : begin - if DBGetSettingType(0,qs_module,buf) in [DBVT_WORD,DBVT_DWORD] then - StrDupW(PWideChar(service.lparam),IntToStr(buf1,GetInt(buf,0))) - else - service.lparam:=pointer(GetUnicode(buf)); - end; - // ansi convert to unicode - ACF_TYPE_STRING : begin - tmp:=GetStr(buf); - AnsiToWide(tmp,PWideChar(service.lparam),MirandaCP); - mFreeMem(tmp); - end; - ACF_TYPE_UNICODE: service.lparam:=pointer(GetUnicode(buf)); - end; - - end; - end; - - QST_OTHER: begin - StrCopy(p,so__other); other:=GetWord(buf,0); - end; - end; - end; - end; - end; -end; - -end. diff --git a/plugins/QuickSearch/sr_optdialog.pas b/plugins/QuickSearch/sr_optdialog.pas deleted file mode 100644 index 1d7e0fb38d..0000000000 --- a/plugins/QuickSearch/sr_optdialog.pas +++ /dev/null @@ -1,1002 +0,0 @@ -unit sr_optdialog; - -interface -uses windows; - -function DlgProcOptions(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; - -implementation - -uses - messages,commctrl, - m_api,common,mirutils,wrapper,dbsettings, - sr_global,sr_window, - editwrapper, - awkservices; - -var - OldListProc:pointer; -var - ServiceBlock:HWND; // single copy, can make it global -var - editcolumns:array [0..MaxColumnAmount-1] of tcolumnitem; - -const - stByte :PWideChar = 'Byte'; - stWord :PWideChar = 'Word'; - stDWord :PWideChar = 'DWord'; - stSigned :PWideChar = 'Signed'; - stHexnum :PWideChar = 'As hex'; - stString :PWideChar = 'String'; - stLastSeen :PWideChar = 'LastSeen'; - stIP :PWideChar = 'IP'; - stContactInfo:PWideChar = 'ContactInfo'; - stLastEvent :PWideChar = 'LastEvent'; - stTimeStamp :PWideChar = 'TimeStamp'; - stService :PWideChar = 'Service'; - stScript :PWideChar = 'Script'; - stMetacontact:PWideChar = 'Metacontact'; - stEventCount :PWideChar = 'EventCount'; - stDisplayName:PWideChar = 'Display name'; - - stSetting :PWideChar = 'DB setting'; - stOther :PWideChar = 'Other'; - -const - cnFirstName = 'FIRSTNAME' ; - cnLastName = 'LASTNAME' ; - cnNick = 'NICK' ; - cnCustomNick = 'CUSTOMNICK'; - cnEmail = 'EMAIL' ; - cnCity = 'CITY' ; - cnState = 'STATE' ; - cnCountry = 'COUNTRY' ; - cnPhone = 'PHONE' ; - cnHomepage = 'HOMEPAGE' ; - cnAbout = 'ABOUT' ; - cnGender = 'GENDER' ; - cnAge = 'AGE' ; - cnFirstLast = 'FIRSTLAST' ; - cnUniqueID = 'UNIQUEID' ; - cnFax = 'FAX' ; - cnCellular = 'CELLULAR' ; - cnTimezone = 'TIMEZONE' ; - cnMyNotes = 'MYNOTES' ; - cnBirthday = 'BIRTHDAY' ; - cnBirthMonth = 'BIRTHMONTH'; - cnBirthYear = 'BIRTHYEAR' ; - cnStreet = 'STREET' ; - cnZIP = 'ZIP' ; - cnLanguage1 = 'LANGUAGE1' ; - cnLanguage2 = 'LANGUAGE2' ; - cnLanguage3 = 'LANGUAGE3' ; - cnCoName = 'CONAME' ; - cnCoDept = 'CODEPT' ; - cnCoPosition = 'COPOSITION'; - cnCoStreet = 'COSTREET' ; - cnCoCity = 'COCITY' ; - cnCoState = 'COSTATE' ; - cnCoZIP = 'COZIP' ; - cnCoCountry = 'COCOUNTRY' ; - cnCoHomepage = 'COHOMEPAGE'; - cnDisplayUID = 'DISPLAYUID'; - -//----- Contact info ----- - -function setcnftype2str(settype:integer):PWideChar; -var - res:pWideChar; -begin - case settype of -// CNF_FIRSTNAME: result:=translate(cnFirstName); - CNF_LASTNAME: res:=cnLastName ; - CNF_NICK: res:=cnNick ; - CNF_CUSTOMNICK: res:=cnCustomNick; - CNF_EMAIL: res:=cnEmail ; - CNF_CITY: res:=cnCity ; - CNF_STATE: res:=cnState ; - CNF_COUNTRY: res:=cnCountry ; - CNF_PHONE: res:=cnPhone ; - CNF_HOMEPAGE: res:=cnHomepage ; - CNF_ABOUT: res:=cnAbout ; - CNF_GENDER: res:=cnGender ; - CNF_AGE: res:=cnAge ; - CNF_FIRSTLAST: res:=cnFirstLast ; - CNF_UNIQUEID: res:=cnUniqueID ; - - CNF_FAX: res:=cnFax ; - CNF_CELLULAR: res:=cnCellular ; - CNF_TIMEZONE: res:=cnTimezone ; - CNF_MYNOTES: res:=cnMyNotes ; - CNF_BIRTHDAY: res:=cnBirthday ; - CNF_BIRTHMONTH: res:=cnBirthMonth; - CNF_BIRTHYEAR: res:=cnBirthYear ; - CNF_STREET: res:=cnStreet ; - CNF_ZIP: res:=cnZIP ; - CNF_LANGUAGE1: res:=cnLanguage1 ; - CNF_LANGUAGE2: res:=cnLanguage2 ; - CNF_LANGUAGE3: res:=cnLanguage3 ; - CNF_CONAME: res:=cnCoName ; - CNF_CODEPT: res:=cnCoDept ; - CNF_COPOSITION: res:=cnCoPosition; - CNF_COSTREET: res:=cnCoStreet ; - CNF_COCITY: res:=cnCoCity ; - CNF_COSTATE: res:=cnCoState ; - CNF_COZIP: res:=cnCoZIP ; - CNF_COCOUNTRY: res:=cnCoCountry ; - CNF_COHOMEPAGE: res:=cnCoHomepage; - CNF_DISPLAYUID: res:=cnDisplayUID; - else - res:=cnFirstName; - end; - result:=TranslateW(res); -end; - -procedure AddCnf(list:HWND;param:integer); -begin -// CB_AddStrDataW(list,setcnftype2str(param),param); - SendMessage(list,CB_SETITEMDATA, - SendMessageW(list,CB_ADDSTRING,0,lparam(setcnftype2str(param))), - param); -end; - -procedure addsetcnftypes(list:HWND); -begin - AddCnf(list,CNF_FIRSTNAME); - AddCnf(list,CNF_LASTNAME); - AddCnf(list,CNF_NICK); - AddCnf(list,CNF_CUSTOMNICK); - AddCnf(list,CNF_EMAIL); - AddCnf(list,CNF_CITY); - AddCnf(list,CNF_STATE); - AddCnf(list,CNF_COUNTRY); - AddCnf(list,CNF_PHONE); - AddCnf(list,CNF_HOMEPAGE); - AddCnf(list,CNF_ABOUT); - AddCnf(list,CNF_GENDER); - AddCnf(list,CNF_AGE); - AddCnf(list,CNF_FIRSTLAST); - AddCnf(list,CNF_UNIQUEID); - - AddCnf(list,CNF_FAX); - AddCnf(list,CNF_CELLULAR); - AddCnf(list,CNF_TIMEZONE); - AddCnf(list,CNF_MYNOTES); - AddCnf(list,CNF_BIRTHDAY); - AddCnf(list,CNF_BIRTHMONTH); - AddCnf(list,CNF_BIRTHYEAR); - AddCnf(list,CNF_STREET); - AddCnf(list,CNF_ZIP); - AddCnf(list,CNF_LANGUAGE1); - AddCnf(list,CNF_LANGUAGE2); - AddCnf(list,CNF_LANGUAGE3); - AddCnf(list,CNF_CONAME); - AddCnf(list,CNF_CODEPT); - AddCnf(list,CNF_COPOSITION); - AddCnf(list,CNF_COSTREET); - AddCnf(list,CNF_COCITY); - AddCnf(list,CNF_COSTATE); - AddCnf(list,CNF_COZIP); - AddCnf(list,CNF_COCOUNTRY); - AddCnf(list,CNF_COHOMEPAGE); - AddCnf(list,CNF_DISPLAYUID); - - SendMessage(list,CB_SETCURSEL,0,0); -end; - - -function GetSelectedItem(list:HWND):integer; -begin - result:=SendMessage(list,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); -end; - -//----- Common interface ----- - -function IconChanged(wParam:WPARAM;lParam:LPARAM;lParam1:LPARAM):int;cdecl; -begin - result:=0; - SetButtonIcon(GetDlgItem(lParam1,IDC_NEW ),QS_NEW); - SetButtonIcon(GetDlgItem(lParam1,IDC_UP ),QS_UP); - SetButtonIcon(GetDlgItem(lParam1,IDC_DN ),QS_DOWN); - SetButtonIcon(GetDlgItem(lParam1,IDC_DELETE ),QS_DELETE); - SetButtonIcon(GetDlgItem(lParam1,IDC_DEFAULT),QS_DEFAULT); - SetButtonIcon(GetDlgItem(lParam1,IDC_RELOAD ),QS_RELOAD); -end; - -procedure CheckDirection(Dialog:HWND;item:integer); -begin - EnableWindow(GetDlgItem(Dialog,IDC_UP),item>0); - - EnableWindow(GetDlgItem(Dialog,IDC_DN), - item<(SendMessage(GetDlgItem(Dialog,IDC_LIST),LVM_GETITEMCOUNT,0,0)-1)); -end; - -//----- Basic screen functions ----- - -procedure InitScreen(Dialog:HWND); -begin - // setting - SendMessage(GetDlgItem(Dialog,IDC_C_DATATYPE),CB_SETCURSEL,0,0); - SetDlgItemTextW(Dialog,IDC_E_MODULE ,nil); - SetDlgItemTextW(Dialog,IDC_E_SETTING,nil); - // script - SetDlgItemTextW(Dialog,IDC_E_SCRIPT,nil); - // service - ClearServiceBlock(ServiceBlock); - // contact info - SendMessage(GetDlgItem(Dialog,IDC_C_CNFTYPE),CB_SETCURSEL,0,0); - // others - SendMessage(GetDlgItem(Dialog,IDC_C_OTHER),CB_SETCURSEL,0,0); -end; - -procedure ClearScreen(Dialog:HWND); -begin - // setting - ShowWindow(GetDlgItem(Dialog,IDC_S_DATATYPE),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_C_DATATYPE),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_S_MODULE ),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_E_MODULE ),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_S_SETTING ),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_E_SETTING ),SW_HIDE); - - // script - ShowEditField(Dialog,IDC_E_SCRIPT,SW_HIDE); - - // service - ShowWindow(ServiceBlock,SW_HIDE); - - // contact info - ShowWindow(GetDlgItem(Dialog,IDC_S_CNFTYPE),SW_HIDE); - ShowWindow(GetDlgItem(Dialog,IDC_C_CNFTYPE),SW_HIDE); - - // others - ShowWindow(GetDlgItem(Dialog,IDC_C_OTHER),SW_HIDE); -end; - -procedure SetupScreen(Dialog:HWND;code:integer); -begin - if not IsWindowVisible(GetDlgItem(Dialog,IDC_E_TITLE)) then - exit; - - case code of - // setting - QST_SETTING: begin - ShowWindow(GetDlgItem(Dialog,IDC_S_DATATYPE),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_C_DATATYPE),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_S_MODULE ),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_E_MODULE ),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_S_SETTING ),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_E_SETTING ),SW_SHOW); - end; - - // script - QST_SCRIPT: begin - ShowEditField(Dialog,IDC_E_SCRIPT,SW_SHOW); - end; - - // service - QST_SERVICE: begin - ShowWindow(ServiceBlock,SW_SHOW); - end; - - // contact info - QST_CONTACTINFO: begin - ShowWindow(GetDlgItem(Dialog,IDC_S_CNFTYPE),SW_SHOW); - ShowWindow(GetDlgItem(Dialog,IDC_C_CNFTYPE),SW_SHOW); - end; - - // others - QST_OTHER: begin - ShowWindow(GetDlgItem(Dialog,IDC_C_OTHER),SW_SHOW); - end; - end; -end; - -//----- single column processing ----- - -procedure FillTableLine(list:HWND;item:integer;const column:tcolumnitem); -begin - LV_SetItemW(list,column.title,item,1); - case column.setting_type of - QST_SETTING: begin - LV_SetItem(list,column.module ,item,2); - LV_SetItem(list,column.setting,item,3); - end; - QST_SCRIPT: begin - LV_SetItemW(list,TranslateW('Script'),item,2); -// LV_SetItemW(list,column.script,item,3); - end; - QST_SERVICE: begin - LV_SetItemW(list,TranslateW('Service') ,item,2); - LV_SetItem (list,column.service.service,item,3); - end; - QST_CONTACTINFO: begin - LV_SetItemW(list,TranslateW('Contact info') ,item,2); - LV_SetItemW(list,setcnftype2str(column.cnftype),item,3); - end; - QST_OTHER: begin - case column.other of - QSTO_METACONTACT: begin - LV_SetItemW(list,TranslateW('Metacontact'),item,2); - end; - end; - end; - end; -end; - -function savecuritem(Dialog:HWND):integer; -var - list:HWND; - i:integer; - idx,lwidth:integer; -begin - list:=GetDlgItem(Dialog,IDC_LIST); - i:=GetSelectedItem(list); - idx:=LV_GetLParam(list,i); - result:=idx; - - lwidth:=editcolumns[idx].width; - clear_column(editcolumns[idx]); - with editcolumns[idx] do - begin - flags:=0; - - if ListView_GetCheckState(list,i)=BST_CHECKED then - flags:=flags or COL_ON or COL_FILTER; - - setting_type:=CB_GetData(GetDlgItem(Dialog,IDC_C_VARTYPE)); - - title:=GetDlgText(Dialog,IDC_E_TITLE); - width:=lwidth; - - case setting_type of - QST_SETTING: begin - datatype:=CB_GetData(GetDlgItem(Dialog,IDC_C_DATATYPE)); - module :=GetDlgText(Dialog,IDC_E_MODULE ,true); - setting :=GetDlgText(Dialog,IDC_E_SETTING,true); - end; - - QST_SCRIPT: begin - script:=GetDlgText(Dialog,IDC_E_SCRIPT); - end; - - QST_CONTACTINFO: begin - cnftype:=CB_GetData(GetDlgItem(Dialog,IDC_C_CNFTYPE)); - end; - - QST_SERVICE: begin - ClearServiceValue(service); - GetSrvBlockValue(ServiceBlock,service); - end; - - QST_OTHER: begin - other:=CB_GetData(GetDlgItem(Dialog,IDC_C_OTHER)); - end; - end; - end; - FillTableLine(list,i,editcolumns[idx]); -end; - -procedure displcurinfo(Dialog:HWND;const column:tcolumnitem); -begin - ClearScreen(Dialog); - SetupScreen(Dialog,column.setting_type); - - SetDlgItemTextW(Dialog,IDC_E_TITLE,column.title); - CB_SelectData(Dialog,IDC_C_VARTYPE,column.setting_type); - - case column.setting_type of - QST_SETTING: begin - CB_SelectData (Dialog,IDC_C_DATATYPE,column.datatype); - SetDlgItemTextA(Dialog,IDC_E_MODULE ,column.module); - SetDlgItemTextA(Dialog,IDC_E_SETTING ,column.setting); - end; - - QST_SCRIPT: begin - SetDlgItemTextW(Dialog,IDC_E_SCRIPT,column.script); - end; - - QST_SERVICE: begin - SetSrvBlockValue(ServiceBlock,column.service); - end; - - QST_CONTACTINFO: begin - CB_SelectData(Dialog,IDC_C_CNFTYPE,column.cnftype); - end; - - QST_OTHER: begin - CB_SelectData(Dialog,IDC_C_OTHER,column.other); - end; - end; -end; - -function add_column(list:HWND;i,idx:integer):integer; -var - li:LV_ITEMA; -begin - result:=i; - zeromemory(@li,sizeof(li)); - li.mask :=LVIF_PARAM; - li.lParam:=idx; - li.iItem :=i; - SendMessage(list,LVM_INSERTITEM,0,lparam(@li)); -end; - -procedure update_list(list:HWND); -var - i,cnt:integer; -begin - ListView_DeleteAllItems(list); - - cnt:=0; - for i:=0 to MaxColumnAmount-1 do - begin - if editcolumns[i].setting_type<>0 then - begin - add_column(list,cnt,i); - FillTableLine(list,cnt,editcolumns[i]); - ListView_SetCheckState(list,cnt,(editcolumns[i].flags and COL_ON)<>0); - inc(cnt); - end; - end; - - ListView_SetItemState(list,0, - LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); -end; - -// fill comboboxes lists - -procedure adddbsettypes(list:HWND); -begin - CB_AddStrDataW(list,TranslateW(stByte) ,QSTS_BYTE); - CB_AddStrDataW(list,TranslateW(stWord) ,QSTS_WORD); - CB_AddStrDataW(list,TranslateW(stDWord) ,QSTS_DWORD); - CB_AddStrDataW(list,TranslateW(stSigned) ,QSTS_SIGNED); - CB_AddStrDataW(list,TranslateW(stHexnum) ,QSTS_HEXNUM); - CB_AddStrDataW(list,TranslateW(stString) ,QSTS_STRING); - CB_AddStrDataW(list,TranslateW(stIP) ,QSTS_IP); - CB_AddStrDataW(list,TranslateW(stTimeStamp),QSTS_TIMESTAMP); - - SendMessage(list,CB_SETCURSEL,0,0); -end; - -procedure addothertypes(list:HWND); -begin - CB_AddStrDataW(list,TranslateW(stLastSeen) ,QSTO_LASTSEEN); - CB_AddStrDataW(list,TranslateW(stLastEvent) ,QSTO_LASTEVENT); - CB_AddStrDataW(list,TranslateW(stMetacontact),QSTO_METACONTACT); - CB_AddStrDataW(list,TranslateW(stEventCount) ,QSTO_EVENTCOUNT); - CB_AddStrDataW(list,TranslateW(stDisplayName),QSTO_DISPLAYNAME); - - SendMessage(list,CB_SETCURSEL,0,0); -end; - -procedure addsettypes(list:HWND); -begin - CB_AddStrDataW(list,TranslateW(stSetting),QST_SETTING); - - CB_AddStrDataW(list,TranslateW(stScript) ,QST_SCRIPT); - CB_AddStrDataW(list,TranslateW(stService) ,QST_SERVICE); - CB_AddStrDataW(list,TranslateW(stContactInfo),QST_CONTACTINFO); - - CB_AddStrDataW(list,TranslateW(stOther),QST_OTHER); - - SendMessage(list,CB_SETCURSEL,0,0); -end; - -procedure addcolumn(handle:HWND;width:word;title:PWideChar); -var - lvcol:LV_COLUMNW; -begin - lvcol.mask :=LVCF_TEXT or LVCF_WIDTH; - lvcol.cx :=width; - lvcol.pszText:=TranslateW(title); - SendMessageW(handle,LVM_INSERTCOLUMNW,0,lparam(@lvcol)); -end; - -function NewListProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -begin - result:=0; - if hMessage=WM_KEYDOWN then - begin - case wParam of - VK_INSERT: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_NEW,0); - exit; - end; - VK_DELETE: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_DELETE,0); - exit; - end; - VK_UP: begin - if (GetKeyState(VK_CONTROL) and $8000)<>0 then - begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_UP,0); - exit; - end; - end; - VK_DOWN: begin - if (GetKeyState(VK_CONTROL) and $8000)<>0 then - begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_DN,0); - exit; - end; - end; - end; - end; - result:=CallWindowProc(OldListProc,Dialog,hMessage,wParam,lParam); -end; - -procedure ResizeControl(Dialog:HWND;id:integer;width:integer); -var - wnd:HWND; - rc:TRECT; -begin - wnd:=GetDlgItem(Dialog,id); - GetWindowRect(wnd,rc); - SetWindowPos(wnd,0,0,0,width,rc.bottom-rc.top,SWP_NOMOVE or SWP_NOZORDER or SWP_SHOWWINDOW); -end; - -procedure DoResize(Dialog:HWND); -var - wSeparator:HWND; - pcw:pWideChar; - rc,rc1:TRECT; - pt:TPOINT; - dx,rside:integer; -begin - GetClientRect(Dialog,rc); - wSeparator:=GetDlgItem(Dialog,IDC_B_RESIZE); - GetWindowRect(wSeparator,rc1); - pt.x:=rc1.left; - pt.y:=0; - ScreenToClient(Dialog,pt); - if pt.x<(rc.right-50) then //!! - begin - rside:=SW_HIDE; - dx:=rc.right-(rc1.right-rc1.left)-4; - pcw:='<'; - end - else - begin - rside:=SW_SHOW; - - GetWindowRect(GetDlgItem(Dialog,IDC_S_COLSETTING),rc); - pt.x:=rc.left; - pt.y:=0; - ScreenToClient(Dialog,pt); - dx:=pt.x-(rc1.right-rc1.left)-4; - pcw:='>'; - end; - SendMessageW(wSeparator,WM_SETTEXT,0,lparam(pcw)); - - // move separator button - SetWindowPos(wSeparator,0,dx+2,2,0,0,SWP_NOSIZE or SWP_NOZORDER or SWP_SHOWWINDOW); - - // resize left side controls - ResizeControl(Dialog,IDC_LIST ,dx); - ResizeControl(Dialog,IDC_CH_GROUP,dx); - - ResizeControl(Dialog,IDC_CH_USETOOLSTYLE,dx-8); - ResizeControl(Dialog,IDC_CH_DRAWGRID ,dx-8); - ResizeControl(Dialog,IDC_CH_SAVEPATTERN ,dx-8); - ResizeControl(Dialog,IDC_CH_AUTOCLOSE ,dx-8); - ResizeControl(Dialog,IDC_CH_SORTSTATUS ,dx-8); - ResizeControl(Dialog,IDC_CH_CLIENTICONS ,dx-8); - - // show/hide setting block (ugly, i know!) - ShowWindow(GetDlgItem(Dialog,IDC_S_COLSETTING),rside); - ShowWindow(GetDlgItem(Dialog,IDC_S_LINE ),rside); - ShowWindow(GetDlgItem(Dialog,IDC_S_TITLE ),rside); - ShowWindow(GetDlgItem(Dialog,IDC_E_TITLE ),rside); - ShowWindow(GetDlgItem(Dialog,IDC_S_VARTYPE ),rside); - ShowWindow(GetDlgItem(Dialog,IDC_C_VARTYPE ),rside); - ShowWindow(GetDlgItem(Dialog,IDC_SETITEM ),rside); - - ClearScreen(Dialog); - - if rside=SW_SHOW then - begin - SetupScreen(Dialog,CB_GetData(GetDlgItem(Dialog,IDC_C_VARTYPE))); - end; -end; - -procedure SetButtons(Dialog:HWND); -var -// ti:TTOOLINFOW; -// hwndTooltip:HWND; - hNew :HWND; - hUp :HWND; - hDown :HWND; - hDelete :HWND; - hDefault:HWND; - hReload :HWND; -begin -{ - hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP, - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - Dialog,0,hInstance,nil); -} - hNew :=GetDlgItem(Dialog,IDC_NEW); - SendMessage(hNew,BUTTONADDTOOLTIP,TWPARAM(TranslateW('New')),BATF_UNICODE); - hUp :=GetDlgItem(Dialog,IDC_UP); - SendMessage(hUp,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Up')),BATF_UNICODE); - hDown :=GetDlgItem(Dialog,IDC_DN); - SendMessage(hDown,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Down')),BATF_UNICODE); - hDelete :=GetDlgItem(Dialog,IDC_DELETE); - SendMessage(hDelete,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Delete')),BATF_UNICODE); - hDefault:=GetDlgItem(Dialog,IDC_DEFAULT); - SendMessage(hDefault,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Default')),BATF_UNICODE); - hReload :=GetDlgItem(Dialog,IDC_RELOAD); - SendMessage(hReload,BUTTONADDTOOLTIP,TWPARAM(TranslateW('Reload')),BATF_UNICODE); -{ - FillChar(ti,SizeOf(ti),0); - ti.cbSize :=sizeof(TOOLINFO); - ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS; - ti.hwnd :=Dialog; - ti.hinst :=hInstance; - ti.uId :=hNew; - ti.lpszText:=TranslateW('New'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hItem; - ti.lpszText:=TranslateW('Save Item'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hUp; - ti.lpszText:=TranslateW('Up'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hDown; - ti.lpszText:=TranslateW('Down'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hDelete; - ti.lpszText:=TranslateW('Delete'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hDefault; - ti.lpszText:=TranslateW('Default'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); - ti.uId :=hReload; - ti.lpszText:=TranslateW('Reload'); - SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti)); -} - SetButtonIcon(hNew ,QS_NEW); - SetButtonIcon(hUp ,QS_UP); - SetButtonIcon(hDown ,QS_DOWN); - SetButtonIcon(hDelete ,QS_DELETE); - SetButtonIcon(hDefault,QS_DEFAULT); - SetButtonIcon(hReload ,QS_RELOAD); - -end; - -procedure AddControls(Dialog:HWND); -var - rc:TRECT; - pt,pt1:TPOINT; - width,height:integer; -begin - // Settings - // Script - MakeEditField(Dialog, IDC_E_SCRIPT); - SetEditFlags (Dialog, IDC_E_SCRIPT,EF_FORCE,EF_FORCES); - - // Service - GetWindowRect(GetDlgItem(Dialog,IDC_C_VARTYPE),rc); - width:=rc.right-rc.left; - pt.x:=rc.left; - pt.y:=rc.bottom; - ScreenToClient(Dialog,pt); - - GetWindowRect(GetDlgItem(Dialog,IDC_SETITEM),rc); - pt1.x:=rc.left; - pt1.y:=rc.top; - ScreenToClient(Dialog,pt1); - - height:=pt1.y-pt.y-2; - ServiceBlock:=CreateServiceBlock(Dialog,pt.x,pt.y,width,height, - ACF_BLOCK_NOSTRUCT+ACF_BLOCK_NOCURRENT); - - // Contact info - // Other -end; - -function DlgProcOptions(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -const - InitDlg:bool = true; - hook:THANDLE = 0; -var - pc:pWideChar; - i,idx:integer; - itemsel:integer; - listhwnd:HWND; - tmpbool:bool; -begin - result:=0; - - case hMessage of - WM_DESTROY: begin - clear_columns(editcolumns); - - if hook<>0 then - UnhookEvent(hook); - - listhwnd:=GetDlgItem(Dialog,IDC_LIST); - DBWriteWord(0,qs_module,'col1',ListView_GetColumnWidth(listhwnd,1)); - DBWriteWord(0,qs_module,'col2',ListView_GetColumnWidth(listhwnd,2)); - DBWriteWord(0,qs_module,'col3',ListView_GetColumnWidth(listhwnd,3)); - end; - - WM_INITDIALOG: begin - InitDlg:=true; - listhwnd:=GetDlgItem(Dialog,IDC_LIST); - - SendMessageW(listhwnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0, - SendMessageW(listhwnd,LVM_GETEXTENDEDLISTVIEWSTYLE,0,0) or - LVS_EX_FULLROWSELECT or LVS_EX_CHECKBOXES); - - addcolumn(listhwnd,DBReadWord(0,qs_module,'col3',95) ,'Setting'); - addcolumn(listhwnd,DBReadWord(0,qs_module,'col2',105),'Module/InfoType'); - addcolumn(listhwnd,DBReadWord(0,qs_module,'col1',85) ,'Title'); - addcolumn(listhwnd,20 ,'#'); - - addsettypes (GetDlgItem(Dialog,IDC_C_VARTYPE)); - adddbsettypes (GetDlgItem(Dialog,IDC_C_DATATYPE)); - addothertypes (GetDlgItem(Dialog,IDC_C_OTHER)); - addsetcnftypes(GetDlgItem(Dialog,IDC_C_CNFTYPE)); - - CheckDlgButton(Dialog,IDC_CH_SORTSTATUS ,ORD((qsopt.flags and QSO_SORTBYSTATUS)<>0)); - CheckDlgButton(Dialog,IDC_CH_AUTOCLOSE ,ORD((qsopt.flags and QSO_AUTOCLOSE)<>0)); - CheckDlgButton(Dialog,IDC_CH_USETOOLSTYLE,ORD((qsopt.flags and QSO_TOOLSTYLE)<>0)); - CheckDlgButton(Dialog,IDC_CH_DRAWGRID ,ORD((qsopt.flags and QSO_DRAWGRID)<>0)); - CheckDlgButton(Dialog,IDC_CH_SAVEPATTERN ,ORD((qsopt.flags and QSO_SAVEPATTERN)<>0)); - CheckDlgButton(Dialog,IDC_CH_CLIENTICONS ,ORD((qsopt.flags and QSO_CLIENTICONS)<>0)); - - SetButtons(Dialog); - - AddControls(Dialog); - - TranslateDialogDefault(Dialog); - - CloneColumns(editcolumns,qsopt.columns); - - update_list(listhwnd); - - hook:=HookEventParam(ME_SKIN_ICONSCHANGED,@IconChanged,Dialog); - - result:=1; - - OldListProc:=pointer(SetWindowLongPtrW(listhwnd,GWL_WNDPROC,LONG_PTR(@NewListProc))); - - DoResize(Dialog); - - InitDlg:=false; - end; - - WM_NOTIFY: begin - case integer(PNMHdr(lParam)^.code) of - - PSN_APPLY: begin - // checkboxes - qsopt.flags:=qsopt.flags and not QSO_MAINOPTIONS; - - if IsDlgButtonChecked(Dialog,IDC_CH_SORTSTATUS)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_SORTBYSTATUS; - - if IsDlgButtonChecked(Dialog,IDC_CH_AUTOCLOSE)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_AUTOCLOSE; - - if IsDlgButtonChecked(Dialog,IDC_CH_USETOOLSTYLE)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_TOOLSTYLE; - - if IsDlgButtonChecked(Dialog,IDC_CH_DRAWGRID)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_DRAWGRID; - - if IsDlgButtonChecked(Dialog,IDC_CH_CLIENTICONS)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_CLIENTICONS; - - if IsDlgButtonChecked(Dialog,IDC_CH_SAVEPATTERN)<>BST_UNCHECKED then - qsopt.flags:=qsopt.flags or QSO_SAVEPATTERN; - - tmpbool:=CloseSrWindow(false); - - listhwnd:=GetDlgItem(Dialog,IDC_LIST); - clear_columns(qsopt.columns); - qsopt.numcolumns:=SendMessage(listhwnd,LVM_GETITEMCOUNT,0,0); - for i:=0 to qsopt.numcolumns-1 do - begin - idx:=LV_GetLParam(listhwnd,i); - with editcolumns[idx] do - begin - if ListView_GetCheckSTate(listhwnd,i)=0 then - flags:=flags and not COL_ON - else - flags:=flags or COL_ON or COL_FILTER; - end; - CloneColumn(qsopt.columns[i],editcolumns[idx]); - end; - - saveopt_db; - - if tmpbool then - OpenSrWindow(nil,qsopt.flags); - result:=1; - end; - - LVN_ITEMCHANGED: begin - if wParam=IDC_LIST then - begin - i:=(PNMLISTVIEW(lParam)^.uOldState and LVNI_FOCUSED)- - (PNMLISTVIEW(lParam)^.uNewState and LVNI_FOCUSED); - if i<0 then // new focus - begin - CheckDirection(Dialog,PNMLISTVIEW(lParam)^.iItem); - InitScreen(Dialog); - displcurinfo(Dialog,editcolumns[PNMLISTVIEW(lParam)^.lParam]); - - result:=1; - end else if (i=0) and not InitDlg then - begin - if (PNMLISTVIEW(lParam)^.uOldState or PNMLISTVIEW(lParam)^.uNewState)=$3000 then - begin - i:=PNMLISTVIEW(lParam)^.uOldState-PNMLISTVIEW(lParam)^.uNewState; - if abs(i)=$1000 then - begin - SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); - result:=1; - end; - end; - end; - end; - end; - - end; - end; - - WM_COMMAND: begin - case wParam shr 16 of - CBN_SELCHANGE: begin - if loword(wParam)=IDC_C_VARTYPE then - begin - ClearScreen(Dialog); - SetupScreen(Dialog,CB_GetData(lParam)); - end; - end; - - BN_CLICKED: begin - if loword(wParam)<>IDC_B_RESIZE then - SendMessage(GetParent(Dialog),PSM_CHANGED,0,0); - - listhwnd:=GetDlgItem(Dialog,IDC_LIST); - result:=1; - case loword(wParam) of - IDC_NEW: begin - i:=GetSelectedItem(listhwnd)+1; - add_column(listhwnd,i,new_column(editcolumns)); - - SendMessage(listhwnd,LVM_ENSUREVISIBLE,i,0); - ListView_SetItemState(listhwnd,i, - LVIS_FOCUSED+LVIS_SELECTED,LVIS_FOCUSED+LVIS_SELECTED); - InitScreen(Dialog); - CheckDirection(Dialog,i); - EnableWindow(GetDlgItem(Dialog,IDC_DELETE),true); - end; - - IDC_DELETE: begin - i:=GetSelectedItem(listhwnd); - clear_column(editcolumns[LV_GetLParam(listhwnd,i)]); - SendMessage(listhwnd,LVM_DELETEITEM,i,0); - - idx:=SendMessage(listhwnd,LVM_GETITEMCOUNT,0,0); - if idx=0 then - begin - EnableWindow(lParam,false); - InitScreen(Dialog); - end - else - begin - if i=idx then dec(i); - ListView_SetItemState(listhwnd,i, - LVIS_FOCUSED+LVIS_SELECTED,LVIS_FOCUSED+LVIS_SELECTED); - end; - CheckDirection(Dialog,i); - end; - - IDC_UP: begin - itemsel:=GetSelectedItem(listhwnd); - if itemsel>0 then - begin - LV_MoveItem(listhwnd,-1,itemsel); - CheckDirection(Dialog,itemsel-1); - end; - end; - - IDC_DN: begin - itemsel:=GetSelectedItem(listhwnd); - if itemsel>=0 then - begin - LV_MoveItem(listhwnd,1,itemsel); - CheckDirection(Dialog,itemsel+1); - end; - end; - - IDC_SETITEM: begin - if SendMessage(listhwnd,LVM_GETITEMCOUNT,0,0)=0 then - begin - add_column(listhwnd,0,0); - ListView_SetItemState(listhwnd,0, - LVIS_FOCUSED+LVIS_SELECTED,LVIS_FOCUSED+LVIS_SELECTED); - EnableWindow(GetDlgItem(Dialog,IDC_DELETE),true); - end; - savecuritem(Dialog); - end; - - IDC_DEFAULT: begin - loaddefaultcolumns(editcolumns); - update_list(listhwnd); - end; - - IDC_RELOAD: begin - loadopt_db(editcolumns); - update_list(listhwnd); - end; - - IDC_B_RESIZE: begin - DoResize(Dialog); - end; - else - result:=0; - end; - end; - end; - end; - - WM_HELP: begin - case CB_GetData(GetDlgItem(Dialog,IDC_C_VARTYPE)) of - QST_SETTING: begin - MessageBoxW(0, - TranslateW('Column content is simple database setting.'), - TranslateW('DB setting'),0); - end; - QST_SCRIPT: begin - MessageBoxW(0, - TranslateW('Column content is script result.'#13#10+ - 'More help from "Help" button in script dialog.'), - TranslateW('Script'),0); - end; - QST_SERVICE: begin - SendMessage(ServiceBlock,WM_HELP,0,0); - end; - QST_CONTACTINFO: begin - MessageBoxW(0, - TranslateW('Column content is contact property (see list). Can be empty.'), - TranslateW('ContactInfo'),0); - end; - QST_OTHER: begin - case CB_GetData(GetDlgItem(Dialog,IDC_C_OTHER)) of - QSTO_LASTSEEN: begin - pc:='Content is last online time.'; - end; - QSTO_LASTEVENT: begin - pc:='Content is time of last contact event.'; - end; - QSTO_METACONTACT: begin - pc:='Content is metacontact info.'; - end; - QSTO_EVENTCOUNT: begin - pc:='Content is count of ALL contact events (not messages only)'; - end; - else - pc:='Unknown'; - end; - MessageBoxW(0,TranslateW(pc),TranslateW('Other info'),0); - end; - end; - result:=1; - end; - -// else -// result:=DefWindowProc(Dialog,hMessage,wParam,lParam); - end; - DefWindowProc(Dialog,hMessage,wParam,lParam); -end; - -end. diff --git a/plugins/QuickSearch/sr_window.pas b/plugins/QuickSearch/sr_window.pas deleted file mode 100644 index a664f092f3..0000000000 --- a/plugins/QuickSearch/sr_window.pas +++ /dev/null @@ -1,2284 +0,0 @@ -unit sr_window; - -interface - -uses windows,m_api; - -function OpenSrWindow(apattern:PWideChar;flags:LPARAM):boolean; -function CloseSrWindow(save:boolean=true):boolean; - -procedure RegisterColors; - -const - grid:HWND = 0; - -implementation - -uses messages,commctrl,sr_global,common,dbsettings,mirutils, - wrapper,protocols,awkservices,editwrapper, mircontacts; - -const - IDM_STAYONTOP = WM_USER+1; - -const - flt_show_offline = $100; -const - strCListDel:PAnsiChar='CList/DeleteContactCommand'; -const - hIconF :HICON = 0; - hIconM :HICON = 0; - mainwnd :HWND = 0; - StatusBar:HWND = 0; -const - OldLVProc :pointer = nil; - OldLVHProc :pointer = nil; - OldEditProc:pointer = nil; -const - QSF_INLIST = $0001; // in constant list - QSF_ACTIVE = $0002; // contact in listview - QSF_DELETED = $0004; // contact deleted - QSF_PATTERN = $0008; // pattern check passed - QSF_ACCDEL = $0010; // account deleted - QSF_ACCOFF = $0020; // account disabled - QSF_META = $0040; // contact is metacontact - QSF_SUBMETA = $0080; // contact is part of metacontact - -type - pQSRec = ^tQSRec; - tQSRec = record // cell - text:PWideChar; - data:uint_ptr; - end; - pQSFRec = ^tQSFRec; - tQSFRec = record // row (contact) - contact:TMCONTACT; - proto :uint_ptr; - flags :dword; - status :dword; -//--- Metacontacts only --- - wparam :WPARAM; - lparam :LPARAM; - end; -var - MainBuf:array of array of tQSRec; - FlagBuf:array of tQSFRec; - LastMeta:integer; - tablecolumns:integer; -var - tstrMale, - tstrFemale, - tstrUnknown:PWideChar; - -const - TIMERID_HOVER = 10; -const - TTShowed:bool=false; - TTInstalled:bool = false; - -var - AdvFilter:cardinal; - -{$i i_ok.inc} - -//----- ----- - -function FindItem(num:integer):integer; -var - fi:LV_FINDINFO; -begin - if num>=0 then - begin - FillChar(fi,SizeOf(fi),0); - fi.flags :=LVFI_PARAM; - fi.lParam:=num; - result:=SendMessage(grid,LVM_FINDITEM,wparam(-1),lparam(@fi)); - end - else - result:=num; -end; - -function GetLVSubItem(x,y:integer):integer; -var - pinfo:LV_HITTESTINFO; -begin - pinfo.flags:=0; - pinfo.pt.x:=x; - pinfo.pt.y:=y; - ScreenToClient(grid,pinfo.pt); - result:=-1; - if integer(SendMessage(grid,LVM_SUBITEMHITTEST,0,tlparam(@pinfo)))<>-1 then - begin - if (pinfo.flags and LVHT_ONITEM)<>0 then - begin - result:=pinfo.iSubItem; - end; - end; -end; - -procedure AddContactToList(hContact:TMCONTACT;num:integer); -var - li:LV_ITEMW; - i:integer; -begin - FillChar(li,SizeOf(li),0); - li.iItem :=100000; //!! need append - li.mask :=LVIF_IMAGE or LVIF_PARAM; - li.iImage:=Clist_GetContactIcon(hContact); - li.lParam:=num; - li.iItem :=SendMessageW(grid,LVM_INSERTITEMW,0,lparam(@li)); - - li.iImage:=0; - li.iSubItem:=0; - for i:=0 to qsopt.numcolumns-1 do - begin - with qsopt.columns[i] do - begin - if (flags and COL_ON)<>0 then - begin - // Client icons preprocess - li.pszText :=MainBuf[num,i].text; - if (((flags and COL_CLIENT)<>0) and - ((qsopt.flags and QSO_CLIENTICONS)<>0) and - (li.pszText<>NIL)) OR - ((flags and (COL_XSTATUS or COL_GENDER))<>0) then - li.mask:=LVIF_IMAGE or LVIF_TEXT - else - li.mask:=LVIF_TEXT; - SendMessageW(grid,LVM_SETITEMW,0,tlparam(@li)); - inc(li.iSubItem); - end; - end; - end; -end; - - -procedure ProcessLine(num:integer;test:boolean=true); -var - p:pQSFRec; - l:boolean; -begin - p:=@FlagBuf[num]; - if (p^.flags and QSF_DELETED)<>0 then - exit; - - if test then - begin - l:=CheckPatternW(num); - if l then - p^.flags:=p^.flags or QSF_PATTERN - else - p^.flags:=p^.flags and not QSF_PATTERN; - end - else - l:=(p^.flags and QSF_PATTERN)<>0;//true; - - if l then - begin - if (p^.flags and QSF_ACTIVE)=0 then - begin - if ((qsopt.flags and QSO_SHOWOFFLINE)<>0) or (p^.status<>ID_STATUS_OFFLINE) then - begin - // check for proto in combo - if (LoByte(AdvFilter)=0) or (p^.proto=LoByte(AdvFilter)) then - begin - p^.flags:=p^.flags or QSF_ACTIVE; - AddContactToList(p^.contact,num); - end; - end; - end - end - else - begin - if (p^.flags and QSF_ACTIVE)<>0 then - begin - p^.flags:=p^.flags and not QSF_ACTIVE; - ListView_DeleteItem(grid,FindItem(num)); - end; - end; -end; - - -function CompareItem(lParam1,lParam2:LPARAM;SortType:LPARAM):int; stdcall; -var - res1,res2:pQSRec; - i1,i2:uint_ptr; - typ1,typ2:boolean; -begin - result:=0; - if SortType=StatusSort then //sort by status - begin - i1:=FlagBuf[lParam1].status; - i2:=FlagBuf[lParam2].status; - // offline - to the end - if i1=ID_STATUS_OFFLINE then i1:=ID_STATUS_OFFLINE+64; - if i2=ID_STATUS_OFFLINE then i2:=ID_STATUS_OFFLINE+64; - // not string parameters - typ1:=false; - typ2:=false; - end - else - begin - res1:=@MainBuf[lParam1,SortType]; - res2:=@MainBuf[lParam2,SortType]; - i1 := res1^.data; - i2 := res2^.data; - typ1:=i1=uint_ptr(-1); - typ2:=i2=uint_ptr(-1); - - if (typ1 and typ2) then // string & string - begin - if (res2.text=nil) and (res1.text=nil) then // nil - result:=0 - else if res2.text=nil then - result:=1 - else if res1.text=nil then - result:=-1 - else - result:=lstrcmpiw(res1.text,res2.text); - end - else if typ1 or typ2 then // string & num - begin - if typ1 then - result:=1 - else - result:=-1; - end; - end; - if not (typ1 or typ2) then // not strings - begin - if i1>i2 then - result:=1 - else if i1=tablecolumns then - qsopt.columnsort:=StatusSort; - - SendMessage(grid,LVM_SORTITEMS,ListViewToColumn(qsopt.columnsort),LPARAM(@CompareItem)); -// ListView_SortItems(grid,@CompareItem,GetQSColumn(qsopt.columnsort)); - - if (qsopt.columnsort<>StatusSort) and ((qsopt.flags and QSO_SORTBYSTATUS)<>0) then - SendMessage(grid,LVM_SORTITEMS,StatusSort,LPARAM(@CompareItem)); -// ListView_SortItems(grid,@CompareItem,StatusSort); -end; - -function AdvancedFilter:integer; -var - p:pQSFRec; - i:integer; - show:boolean; -begin - result:=0; - - SendMessage(grid,WM_SETREDRAW,0,0); - - for i:=0 to HIGH(FlagBuf) do - begin - p:=@FlagBuf[i]; - // firstly = proto - show:=(LoByte(AdvFilter)=0) or (p^.proto=LoByte(AdvFilter)); - // secondary = show/hide offline - show:=show and ((p^.status<>ID_STATUS_OFFLINE) or ((AdvFilter and flt_show_offline)<>0)); - - if (p^.flags and QSF_PATTERN)<>0 then - begin - if show then - begin - if (p^.flags and QSF_ACTIVE)=0 then - ProcessLine(i,false); - end - else - begin - p^.flags:=p^.flags and not QSF_ACTIVE; - ListView_DeleteItem(grid,FindItem(i)); - end; - end; - end; - - SendMessage(grid,WM_SETREDRAW,1,0); - InvalidateRect(grid,nil,false); - - Sort; - UpdateSB; -end; - -procedure FillGrid; -var - cnt:integer; -begin - - SendMessage(grid,WM_SETREDRAW,0,0); - - MakePatternW; - - for cnt:=0 to HIGH(FlagBuf) do - ProcessLine(cnt); - - SendMessage(grid,WM_SETREDRAW,1,0); - InvalidateRect(grid,nil,false); - - Sort; - UpdateSB; - - AdvancedFilter; //!! - - ListView_SetItemState(grid,0,LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); -end; - - -//----- contacts actions ----- - -function GetFocusedhContact:TMCONTACT; -var - i:integer; -begin - i:=LV_GetLParam(grid); - if i=-1 then - result:=0 - else - result:=FlagBuf[i].contact; -end; - -procedure ShowContactMsgDlg(hContact:TMCONTACT); -begin - if hContact<>0 then - begin - ShowContactDialog(hContact); - if (qsopt.flags and QSO_AUTOCLOSE)<>0 then DestroyWindow(mainwnd); - end; -end; - -procedure DeleteOneContact(hContact:TMCONTACT); -begin - if ServiceExists(strCListDel) then - CallService(strCListDel,hContact,0) - else - db_delete_contact(hContact); -end; - -procedure DeleteByList; -var - i,j:integer; -begin - j:=ListView_GetItemCount(grid)-1; - - i:=MessageBoxW(0,TranslateW('Do you really want to delete selected contacts?'), - TranslateW('Warning'),MB_OKCANCEL+MB_ICONWARNING); - - if i=IDOK then - begin - SendMessage(grid,WM_SETREDRAW,0,0); - for i:=j downto 0 do - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - db_delete_contact(FlagBuf[LV_GetLParam(grid,i)].contact); - end; - SendMessage(grid,WM_SETREDRAW,1,0); - end; -end; - -procedure ConvertToMeta; -var - hMeta:TMCONTACT; - tmp:TMCONTACT; - i,j:integer; -begin - j:=ListView_GetItemCount(grid)-1; - - hMeta:=0; - for i:=j downto 0 do // check - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - begin - tmp:=db_mc_getMeta(FlagBuf[LV_GetLParam(grid,i)].contact); - if tmp<>0 then - if hMeta=0 then - hMeta:=tmp - else if tmp<>hMeta then - begin - MessageBoxW(0, - TranslateW('Some of selected contacts in different metacontacts already'), - 'Quick Search',MB_ICONERROR); - exit; - end; - end; - end; - - if hMeta<>0 then - begin - i:=MessageBoxW(0, - TranslateW('One or more contacts in same Meta already. Try to convert anyway?'), - 'Quick Search',MB_YESNO+MB_ICONWARNING); - if i<>IDYES then - exit; - end; - - // convert if needed - for i:=j downto 0 do - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - begin - if hMeta=0 then - db_mc_convertToMeta(FlagBuf[LV_GetLParam(grid,i)].contact) - else - db_mc_addToMeta(FlagBuf[LV_GetLParam(grid,i)].contact,hMeta); - end; - end; -end; - -procedure UpdateLVCell(item,column:integer;text:pWideChar=pWideChar(-1)); -var - li:LV_ITEMW; - contact:TMCONTACT; - row:integer; -begin - contact:=FlagBuf[LV_GetLParam(grid,item)].contact; - // get buffer row from LV item - row:=FindBufNumber(contact); - // get cell text - if text=pWideChar(-1) then - begin - mFreeMem(MainBuf[row,column].text); - LoadOneItem(contact,@qsopt.columns[column],0,MainBuf[row,column]); - text:=MainBuf[row,column].text; - end; - - // rewrite LV cell - zeromemory(@li,sizeof(li)); - li.mask :=LVIF_TEXT; - li.iItem :=item; - li.iSubItem:=ColumnToListView(column); // buffer column to LV subitem - li.pszText :=text; - SendMessageW(grid,LVM_SETITEMW,0,tlparam(@li)); - - // if need to filter and sort, do it - if (qsopt.columns[column].flags and COL_FILTER)<>0 then - ProcessLine(row); - if qsopt.columnsort=li.iSubItem then - Sort; -end; - -procedure MoveToGroup(group:PWideChar); -var - contact:TMCONTACT; - i,j,grcol,row:integer; -begin - j:=ListView_GetItemCount(grid)-1; - // search group column in QS window (if presents) - grcol:=-1; - for i:=0 to qsopt.numcolumns-1 do - begin - with qsopt.columns[i] do - if (flags and COL_GROUP)<>0 then - begin - if (flags and COL_ON)=0 then - flags:=flags and not COL_INIT - else - grcol:=i; - break; - end - end; - // move to new group and changing in LV if needs - for i:=0 to j do - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - begin - contact:=FlagBuf[LV_GetLParam(grid,i)].contact; - // change settings - DBWriteUnicode(contact,strCList,'Group',group); - // update buffer and LV - if ((qsopt.flags and QSO_AUTOCLOSE)=0) and (grcol>=0) then - begin - row:=FindBufNumber(contact); - - mFreeMem(MainBuf[row,grcol].text); - StrDupW (MainBuf[row,grcol].text,group); - -// LoadOneItem(contact,qsopt.columns[grcol],0,MainBuf[row,grcol]); - UpdateLVCell(i,grcol); - end; - end; - end; -end; - -procedure MoveToContainer(container:PWideChar); -var - contact:TMCONTACT; - i,j,grcol,row:integer; -begin - j:=ListView_GetItemCount(grid)-1; - // search container column in QS window (if presents) - grcol:=-1; - - for i:=0 to qsopt.numcolumns-1 do - begin - with qsopt.columns[i] do - if (flags and COL_CNTNR)<>0 then - begin - if (flags and COL_ON)=0 then - flags:=flags and not COL_INIT - else - grcol:=i; - break; - end - end; - - // attach to new container and changing in LV if needs - for i:=0 to j do - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - begin - contact:=FlagBuf[LV_GetLParam(grid,i)].contact; - if container^=#0 then - db_unset(contact,'Tab_SRMsg','containerW') - else - DBWriteUnicode(contact,'Tab_SRMsg','containerW',container); - if ((qsopt.flags and QSO_AUTOCLOSE)=0) and (grcol>=0) then - begin - row:=FindBufNumber(contact); - - mFreeMem(MainBuf[row,grcol].text); - StrDupW (MainBuf[row,grcol].text,container); - -// LoadOneItem(contact,qsopt.columns[grcol],0,MainBuf[row,grcol]); - UpdateLVCell(i,grcol); - end; - end; - end; -end; - -// right now - memory column order, not screen -procedure CopyMultiLinesW; -var - p,buf:PWideChar; - idx:integer; - i,j,k:integer; - tmpcnt,cnt:integer; -begin -{ - lv:LV_COLUMNW; - buf:array [0..127] of WideChar; - - lv.mask :=LVCF_TEXT; - lv.cchTextMax:=128; - lv.pszText :=@buf; - - SendMessageW(LVM_GETCOLUMNW,i,LPARAM(@lv)); - - use lv.pszText, not qsopt.columns[i].title -} - // calculate buffer size, column order not important - cnt:=0; - - k:=0; - while k0 then - inc(cnt,2); - - j:=ListView_GetItemCount(grid)-1; - tmpcnt:=cnt; - for i:=0 to j do - begin - if ListView_GetItemState(grid,i,LVIS_SELECTED)<>0 then - begin - k:=0; - idx:=LV_GetLParam(grid,i); - while kcnt then - inc(cnt,2); - end; - if cnt=0 then - exit; - - inc(cnt); - mGetMem(buf,cnt*SizeOf(WideChar)); - p:=buf; - - // fill info (need visual column order) - k:=0; - while k0 then - begin - k:=0; - idx:=LV_GetLParam(grid,i); - while k':' then - inc(cnt); - - inc(cnt,StrLenW(MainBuf[num,i].text)+2); - end; - end; - if cnt=0 then - exit; - mGetMem(pp,(cnt+1)*SizeOf(WideChar)); - p:=pp; - - i:=0; - while i':' then - begin - p^:=':'; - inc(p); - end; - p^:=' '; inc(p); - p:=StrCopyEW(p,MainBuf[num,i].text); - p^:=#13; (p+1)^:=#10; inc(p,2); - end; - end; - p^:=#0; - - CopyToClipboard(pp,false); - mFreeMem(pp); -end; -} -const - srvhandle:THANDLE=0; - mnuhandle:THANDLE=0; - cmcolumn :integer=-1; - -function ColChangeFunc(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl; -var - pc,pc1:pWideChar; - p:pAnsiChar; - tbuf:array [0..255] of WideChar; - lmodule:pAnsiChar; - contact:integer; - col:pcolumnitem; - qsr:pQSRec; -begin - col:=@qsopt.columns[cmcolumn]; - StrCopyW(StrCopyEW(@tbuf,TranslateW('Editing of column ')),col.title); - contact:=FindBufNumber(wParam); - qsr:=@MainBuf[contact,cmcolumn]; - pc:=qsr.text; - result:=ShowEditBox(grid,pc,@tbuf); - if result=-1 then - exit - else if result=1 then - begin - pc1:=pc; - pc:=ParseVarString(pc1,wParam); - mFreeMem(pc1); - end; - // change buffer value - mFreeMem(qsr.text); - qsr.text:=pc; - if col.datatype<>QSTS_STRING then - begin - qsr.data:=NumToInt(qsr.text); - end; - // change database setting value - if col.module<>nil then - lmodule:=col.module - else - begin - lmodule:=GetProtoName(FlagBuf[contact].proto); - end; - - case col.datatype of - QSTS_BYTE: begin - DBWriteByte(wParam,lmodule, - col.setting,qsr.data); - end; - QSTS_WORD: begin - DBWriteWord(wParam,lmodule, - col.setting,qsr.data); - end; - QSTS_DWORD,QSTS_SIGNED,QSTS_HEXNUM: begin - DBWriteDWord(wParam,lmodule, - col.setting,dword(qsr.data)); - end; - QSTS_STRING: begin - case DBGetSettingType(wParam,lmodule,col.setting) of - DBVT_ASCIIZ: begin - WideToAnsi(qsr.text,p,MirandaCP); - DBWriteString(wParam,lmodule,col.setting,p); - mFreeMem(p); - end; - DBVT_UTF8: begin - WidetoUTF8(qsr.text,p); - DBWriteUTF8(wParam,lmodule,col.setting,p); - mFreeMem(p); - end; - DBVT_DELETED, - DBVT_WCHAR: begin - DBWriteUnicode(wParam,lmodule, - col.setting,qsr.text); - end; - end; - end; - end; - - UpdateLVCell(SendMessage(grid,LVM_GETNEXTITEM,-1,LVNI_FOCUSED),cmcolumn,qsr.text); -end; - -function ShowContactMenu(wnd:HWND;hContact:TMCONTACT;col:integer=-1):HMENU; -var - mi:TMO_MenuItem; - pt:tpoint; - doit:bool; -begin - if hContact<>0 then - begin - doit:=false; - if col>=0 then - begin - col:=ListViewToColumn(col); - if (qsopt.columns[col].setting_type=QST_SETTING) and - // right now, not time or IP - (qsopt.columns[col].datatype<>QSTS_IP) and - (qsopt.columns[col].datatype<>QSTS_TIMESTAMP) then - begin - doit:=true; - - if srvhandle=0 then - srvhandle:=CreateServiceFunction('QS/dummy',@ColChangeFunc); - - cmcolumn:=col; - - FillChar(mi,SizeOf(mi),0); - if mnuhandle=0 then - begin - SET_UID(@mi, 'D384A798-5D4C-48B4-B3E2-30046ED6F481'); - mi.flags :=CMIF_UNICODE; - mi.szName.w :='Change setting through QS'; - mi.pszService:='QS/dummy'; - mnuhandle:=Menu_AddContactMenuItem(@mi); - end - else - Menu_ModifyItem(mnuhandle, nil, INVALID_HANDLE_VALUE, 0); - end; - end; - - GetCursorPos(pt); - result:=Menu_BuildContactMenu(hContact); - if result<>0 then - begin - TrackPopupMenu(result,0,pt.x,pt.y,0,wnd,nil); - DestroyMenu(result); - end; - // Due to stupid miranda logic, we need to clear tails at service processing, not earlier - if doit then - Menu_ShowItem(mnuhandle, 0); - end - else - result:=0; -end; - -function MyStrSort(para1:pointer; para2:pointer):int; cdecl; -begin - result:=StrCmpW(pWideChar(para1),pWideChar(para2)); -end; - -function MakeContainerMenu(idxfrom:integer=100):HMENU; -var - sl:TSortedList; - i:integer; - b:array [0..15] of AnsiChar; - p:pWideChar; -begin - result:=CreatePopupMenu; - AppendMenuW(result,MF_STRING,idxfrom,TranslateW('default')); - AppendMenuW(result,MF_SEPARATOR,0,nil); - FillChar(sl,SizeOf(sl),0); - sl.increment:=16; - sl.sortFunc:=@MyStrSort; - i:=1; - repeat - p:=DBReadUnicode(0,'TAB_ContainersW',IntToStr(b,i),nil); - if p=nil then break; - List_InsertPtr(@sl,p); - inc(i); - until false; - inc(idxfrom); - for i:=0 to sl.realCount-1 do - begin - p:=pWideChar(sl.Items[i]); - AppendMenuW(result,MF_STRING,idxfrom+i,p); - mFreeMem(p); - end; - List_Destroy(@sl); -end; - -procedure ShowMultiPopup(cnt:integer); -var - mmenu,grpmenu,cntmenu:HMENU; - p:PWideChar; - pt:TPOINT; - buf:array [0..255] of WideChar; - i:integer; -begin - mmenu:=CreatePopupMenu; - if mmenu=0 then - exit; - - StrCopyW(buf,TranslateW('Selected')); - p:=@buf; - while p^<>#0 do inc(p); - p^:=' '; inc(p); - - IntToStr(p,cnt); - - while p^<>#0 do inc(p); - p^:=' '; inc(p); - StrCopyW(p,TranslateW('contacts')); - AppendMenuW(mmenu,MF_DISABLED+MF_STRING,0,buf); - AppendMenuW(mmenu,MF_SEPARATOR,0,nil); - AppendMenuW(mmenu,MF_STRING,101,TranslateW('&Delete')); - AppendMenuW(mmenu,MF_STRING,102,TranslateW('&Copy')); - AppendMenuW(mmenu,MF_STRING,103,TranslateW('C&onvert to Meta')); - - cntmenu:=MakeContainerMenu(300); - AppendMenuW(mmenu,MF_POPUP,cntmenu,TranslateW('Attach to &Tab container')); - - grpmenu:=MakeGroupMenu(400); - AppendMenuW(mmenu,MF_POPUP,grpmenu,TranslateW('&Move to Group')); -// grpmenu:=CallService(MS_CLIST_GROUPBUILDMENU,0,0); - - GetCursorPos(pt); - i:=integer(TrackPopupMenu(mmenu,TPM_RETURNCMD+TPM_NONOTIFY,pt.x,pt.y,0,mainwnd,nil)); - case i of - 101: DeleteByList; - 102: begin - CopyMultiLinesW({ListView_GetSelectedCount(grid)}) - end; - 103: ConvertToMeta; - 300..399: begin - if i=300 then // default container, just delete setting - buf[0]:=#0 - else - begin - GetMenuStringW(cntmenu,i,buf,SizeOf(buf),MF_BYCOMMAND); - end; - MoveToContainer(buf); - end; - 400..499: begin - if i=400 then // root group - buf[0]:=#0 - else - begin - GetMenuStringW(grpmenu,i,buf,SizeOf(buf),MF_BYCOMMAND); - end; - MoveToGroup(buf); - end; - end; - DestroyMenu(mmenu); - if (qsopt.flags and QSO_AUTOCLOSE)<>0 then - CloseSrWindow; -end; - -//----- ListView Columns ----- - -procedure ColumnClick(wnd:HWND;num:integer); -var - hdi:THDITEM; - header:HWND; -begin - header:=ListView_GetHeader(wnd); - - zeromemory(@hdi,sizeof(hdi)); - // clear sort mark - hdi.mask:=HDI_FORMAT; - SendMessage(header,HDM_GETITEM,qsopt.columnsort,lparam(@hdi)); - hdi.fmt:=hdi.fmt and not (HDF_SORTDOWN or HDF_SORTUP); - SendMessage(header,HDM_SETITEM,qsopt.columnsort,lparam(@hdi)); - - if qsopt.columnsort<>num then - begin - qsopt.flags:=qsopt.flags or QSO_SORTASC; - qsopt.columnsort:=num; - end - else - qsopt.flags:=qsopt.flags xor QSO_SORTASC; - - // set new sort mark - SendMessage(header,HDM_GETITEM,qsopt.columnsort,lparam(@hdi)); - if (qsopt.flags and QSO_SORTASC)=0 then - hdi.fmt:=hdi.fmt or HDF_SORTDOWN - else - hdi.fmt:=hdi.fmt or HDF_SORTUP; - SendMessage(header,HDM_SETITEM,qsopt.columnsort,lparam(@hdi)); - - Sort; -end; - -procedure FillLVColumn(column,lvcolumn:integer); -var - li:LV_ITEMW; - i:integer; -begin - FillChar(li,SizeOf(li),0); - for i:=0 to ListView_GetItemCount(grid)-1 do - begin - li.iItem :=i; - li.mask :=LVIF_PARAM; - li.iSubItem:=0; - SendMessage(grid,LVM_GETITEM,0,lparam(@li)); - - li.pszText :=MainBuf[li.lParam,column].text; - // Client icons preprocess - if (((qsopt.columns[column].flags and COL_CLIENT)<>0) and - ((qsopt.flags and QSO_CLIENTICONS)<>0) and - (li.pszText<>NIL)) OR - ((qsopt.columns[column].flags and (COL_XSTATUS or COL_GENDER))<>0) then - li.mask:=LVIF_IMAGE or LVIF_TEXT - else - li.mask:=LVIF_TEXT; - li.iSubItem:=lvcolumn; - SendMessageW(grid,LVM_SETITEMW,0,lparam(@li)); - end; -end; - -procedure addcolumn(num:integer;column:pcolumnitem); -var - lvcol:LV_COLUMNW; - hdi:THDITEM; -begin - zeromemory(@lvcol,sizeof(lvcol)); - lvcol.mask :=LVCF_TEXT or LVCF_WIDTH; - lvcol.pszText :=TranslateW(column.title); - lvcol.cx :=column.width; - SendMessageW(grid,LVM_INSERTCOLUMNW,num,lparam(@lvcol)); - - // set checkbox in column header - hdi.mask:=HDI_FORMAT; - if (column.flags and COL_FILTER)<>0 then - hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX or HDF_CHECKED - else - hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX; - SendMessage(ListView_GetHeader(grid),HDM_SETITEM,num,tlparam(@hdi)); -end; - -procedure MakeColumnMenu; -var - column:pcolumnitem; - menu:HMENU; - pt:TPOINT; - flag,id,i,j:integer; -begin - menu:=CreatePopupMenu; - if menu<>0 then - begin - for id:=0 to qsopt.numcolumns-1 do - begin - if (qsopt.columns[id].flags and COL_ON)<>0 then - flag:=MF_CHECKED or MF_STRING - else - flag:=MF_UNCHECKED or MF_STRING; - AppendMenuW(menu,flag,100+id,TranslateW(qsopt.columns[id].title)); - end; - GetCursorPos(pt); - id:=integer(TrackPopupMenu(menu,TPM_RETURNCMD+TPM_NONOTIFY,pt.x,pt.y,0,mainwnd,nil)); - if id>=100 then - begin - dec(id,100); - column:=@qsopt.columns[id]; - // show column - if (column.flags and COL_ON)=0 then - begin - column.flags:=column.flags or COL_ON; - // memory - if (column.flags and COL_INIT)=0 then - begin - for i:=0 to HIGH(MainBuf) do // contacts - begin - LoadOneItem(FlagBuf[i].contact,column,FlagBuf[i].proto,MainBuf[i,id]); - end; - column.flags:=column.flags or COL_INIT; - end; - // screen - i:=ColumnToListView(id); - addcolumn(i,column); - - // fill new column - FillLVColumn(id,i); - end - else - // hide column - begin - j:=0; - - for i:=0 to qsopt.numcolumns-1 do - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - inc(j); - end; - // keep at least one visible column (1 + this) - if j>2 then - begin - SendMessage(grid,LVM_DELETECOLUMN,ColumnToListView(id),0); - column.flags:=column.flags and not COL_ON; - end; - end; - end; - DestroyMenu(menu); - end; -end; - -function NewLVHProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -begin - case hMessage of - WM_RBUTTONUP: begin - result:=0; - exit; - end; - - WM_RBUTTONDOWN: begin - MakeColumnMenu; - end; - end; - result:=CallWindowProc(OldLVHProc,Dialog,hMessage,wParam,lParam); -end; - -var - HintWnd:HWND; - -function NewLVProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -const - OldHItem :integer=0; - OldHSubItem:integer=0; -var - p:PWideChar; - buf :array [0..255] of WideChar; //!! for spec columns and patterns now only - buf1:array [0..127] of AnsiChar; - tmpCursor:TPOINT; - pinfo:LV_HITTESTINFO; - TI:TToolInfoW; - ics:TCUSTOM_STATUS; - - info:TCLCINFOTIP; -// qsr:tQSRec; - i,num:integer; -begin - result:=0; - case hMessage of - - WM_DESTROY: begin - if TTInstalled then - KillTimer(Dialog,TIMERID_HOVER); - end; - - WM_LBUTTONDBLCLK: begin - ShowContactMsgDlg(GetFocusedhContact); - exit; - end; - - WM_CHAR: begin - if wParam=27 then // ESC - begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDCANCEL,0); - exit; - end; - case wParam of - 1: begin - ListView_SetItemState(grid,-1,LVIS_SELECTED,LVIS_SELECTED); - end; - // Ctrl-C - 3: begin -// i:=ListView_GetSelectedCount(grid); - CopyMultiLinesW(); - exit; - end; - // backspace - 8: begin - if pattern<>nil then - begin - StrCopyW(buf,pattern); - p:=StrEndW(buf); - (p-1)^:=#0; - SetDlgItemTextW(mainwnd,IDC_E_SEARCHTEXT,buf); - end; - end; - // letters - 32..127: begin - if pattern<>nil then - StrCopyW(buf,pattern) - else - buf[0]:=#0; - p:=StrEndW(buf); - p^:=WideChar(wParam); - (p+1)^:=#0; - SetDlgItemTextW(mainwnd,IDC_E_SEARCHTEXT,buf); - end; - end - end; - - WM_TIMER: begin - if wParam=TIMERID_HOVER then - begin - KillTimer(Dialog,TIMERID_HOVER); - if GetForegroundWindow<>mainwnd then exit; - i:=LV_GetLParam(grid,OldHItem); - if i>=0 then - begin - FillChar(info,SizeOf(info),0); - with info do - begin - cbSize :=SizeOf(info); - hItem :=FlagBuf[i].contact; - GetCursorPos(ptCursor); - tmpCursor :=ptCursor; -{ - ptCursor.x:=loword(lParam); - ptCursor.y:=hiword(lParam); -} - SendMessage(grid,LVM_GETITEMRECT,OldHItem,tlparam(@rcItem)); - ScreenToClient(grid,tmpCursor); - if not PtInRect(rcItem,tmpCursor) then exit; - end; -// mGetMem(txt,16384*SizeOf(WideChar)); -{ - p:=txt; - for cnt:=0 to HIGH(MainBuf[0]) do - begin - if (qsopt.columns[cnt].flags and COL_ON)=0 then - begin - LoadOneItem(info.hItem,cnt,FlagBuf[i].proto,qsr); - if qsr.text<>nil then - begin - if qsr.text^<>#0 then - begin -//!! need: buffer free space check here -num:=StrLenW(qsopt.columns[cnt].title)+StrLenW(qsr.text)+4; -if (16384-num)>(p-txt) then -begin - - p:=StrCopyEW(p,qsopt.columns[cnt].title); - p^:=':'; inc(p); p^:=' '; inc(p); - p:=StrCopyEW(p,qsr.text); - p^:=#13; inc(p); p^:=#10; inc(p); -end -else -begin - mFreeMem(qsr.text); - break; -end; - end; - mFreeMem(qsr.text); - end; - end; - end; - p^:=#0; -} - CallService(MS_TIPPER_SHOWTIPW,0{twparam(txt)},tlparam(@info)); -// mFreeMem(txt); - TTShowed:=true; - end; - end; - end; - - WM_MOUSEMOVE: begin - pinfo.pt.x:=loword(lParam); - pinfo.pt.y:=hiword(lParam); - pinfo.flags:=0; - if integer(SendMessage(grid,LVM_SUBITEMHITTEST,0,tlparam(@pinfo)))<>-1 then - begin - if ((pinfo.flags and LVHT_ONITEM)<>0) and - ((pinfo.iItem<>OldHItem) or (pinfo.iSubItem<>OldHSubItem)) then - begin - OldHSubItem:=pinfo.iSubItem; - OldHItem :=pinfo.iItem; - - if TTInstalled then - begin - if TTShowed then - begin - TTShowed:=false; - CallService(MS_TIPPER_HIDETIP,0,0); - end; - KillTimer(Dialog, TIMERID_HOVER); - if OldHSubItem=0 then - begin - SetTimer(Dialog, TIMERID_HOVER, 450, nil); - exit; - end; - end; -//!! - with TI do - begin - cbSize:=SizeOf(TI); - uFlags:=TTF_SUBCLASS+TTF_IDISHWND; - hWnd :=mainwnd; - uId :=Dialog; - hInst :=0; - end; - - num:=ListViewToColumn(OldHSubItem); - if (qsopt.columns[num].flags and - (COL_XSTATUS or COL_GENDER))<>0 then - begin - i:=LV_GetLParam(grid,OldHItem); -// TTShowed:=true; - if (qsopt.columns[num].flags and COL_GENDER)<>0 then - begin - case MainBuf[i,num].data of - 77: TI.lpszText:=tstrMale; - 70: TI.lpszText:=tstrFemale; - else - TI.lpszText:=tstrUnknown; - end; - end - else // if (qsopt.columns[num].flags and COL_XSTATUS)<>0 then - begin - StrCopyW(buf,MainBuf[i,num].text); - ics.flags:=CSSF_DEFAULT_NAME or CSSF_MASK_NAME or CSSF_UNICODE; - - StrCopy(StrCopyE(buf1,GetProtoName(FlagBuf[i].proto)),PS_GETCUSTOMSTATUSEX); - - i:=StrToInt(buf); - ics.wParam:=@i; - ics.cbSize:=SizeOf(ics); - ics.szName.w:=@buf; - - CallService(buf1,0,tlparam(@ics)); - TI.lpszText:=TranslateW(@buf); - end; - end - else - begin - TI.lpszText:=nil; -// TTShowed:=false; - end; - SendMessageW(HintWnd,TTM_SETTOOLINFOW,0,tlparam(@TI)); - end - end; - end; - - WM_KEYUP: begin - case wParam of - VK_RETURN: begin - if ListView_GetSelectedCount(grid)=1 then - ShowContactMsgDlg(GetFocusedhContact); - exit; - end; - VK_INSERT: begin - CallService(MS_FINDADD_FINDADD,0,0); - exit; - end; - VK_DELETE: begin - lParam:=ListView_GetSelectedCount(grid); - if lParam>1 then - DeleteByList - else if lParam=1 then - DeleteOneContact(GetFocusedhContact); - exit; - end; - VK_F5: begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDC_REFRESH,0); - exit; - end; - end; - end; - - WM_NOTIFY: begin - case integer(PNMHdr(lParam)^.code) of - HDN_ITEMSTATEICONCLICK: begin - if ((PHDNotify(lParam)^.pitem^.mask and HDI_FORMAT )<>0) and - ((PHDNotify(lParam)^.pitem^.fmt and HDF_CHECKBOX)<>0) then - begin - i:=ListViewToColumn(PHDNotify(lParam)^.{$IFDEF FPC}iItem{$ELSE}Item{$ENDIF}); - - if (PHDNotify(lParam)^.pitem^.fmt and HDF_CHECKED)=0 then // OLD state - begin - qsopt.columns[i].flags:=qsopt.columns[i].flags or COL_FILTER; - PHDNotify(lParam)^.pitem^.fmt:=PHDNotify(lParam)^.pitem^.fmt or HDF_CHECKED - end - else - begin - qsopt.columns[i].flags:=qsopt.columns[i].flags and not COL_FILTER; - PHDNotify(lParam)^.pitem^.fmt:=PHDNotify(lParam)^.pitem^.fmt and not HDF_CHECKED - end; - SendMessage( - PHDNotify(lParam)^.hdr.hWndFrom,HDM_SETITEM, - PHDNotify(lParam)^.{$IFDEF FPC}iItem{$ELSE}Item{$ENDIF},tlparam(PHDNotify(lParam)^.pitem)); -// result:=1; - FillGrid; - exit; - end; - end; - HDN_ENDDRAG: begin - end; - end; - end; - end; - result:=CallWindowProc(OldLVProc,Dialog,hMessage,wParam,lParam); -end; - -//----- Single cell painting ----- - -procedure SetCellColor(lplvcd:PNMLVCUSTOMDRAW;idx:integer); -begin - if (qsopt.flags and QSO_COLORIZE)<>0 then - begin - with FlagBuf[idx] do - begin - if (flags and QSF_ACCDEL)<>0 then - begin - lplvcd^.clrTextBk:=QSColors[bkg_del].color; - lplvcd^.clrText :=QSColors[fgr_del].color; - end - else if (flags and QSF_ACCOFF)<>0 then - begin - lplvcd^.clrTextBk:=QSColors[bkg_dis].color; - lplvcd^.clrText :=QSColors[fgr_dis].color; - end - else if (flags and QSF_META)<>0 then - begin - lplvcd^.clrTextBk:=QSColors[bkg_meta].color; - lplvcd^.clrText :=QSColors[fgr_meta].color; - end - else if (flags and QSF_SUBMETA)<>0 then - begin - lplvcd^.clrTextBk:=QSColors[bkg_sub].color; - lplvcd^.clrText :=QSColors[fgr_sub].color; - end - else if (flags and QSF_INLIST)=0 then - begin - lplvcd^.clrTextBk:=QSColors[bkg_hid].color; - lplvcd^.clrText :=QSColors[fgr_hid].color; - end - else - idx:=-1; - end; - end - else - idx:=-1; - if idx<0 then - begin - if ((qsopt.flags and QSO_DRAWGRID)=0) and odd(lplvcd^.nmcd.dwItemSpec) then - begin - lplvcd^.clrTextBk:=QSColors[bkg_odd].color; - lplvcd^.clrText :=QSColors[fgr_odd].color; - end - else - begin - lplvcd^.clrTextBk:=QSColors[bkg_norm].color; - lplvcd^.clrText :=QSColors[fgr_norm].color; - end; - end; -end; - -function ProcessCustomDraw(lParam:LPARAM):integer; -var - lplvcd:PNMLVCUSTOMDRAW; - h:HICON; - MirVerW:pWideChar; - buf:array [0..255] of AnsiChar; - rc:TRECT; - i,j,sub:integer; -begin - lplvcd:=pointer(lParam); - result:=CDRF_DODEFAULT; - case lplvcd^.nmcd.dwDrawStage of - CDDS_PREPAINT: begin - result:=CDRF_NOTIFYITEMDRAW; - exit; - end; - CDDS_ITEMPREPAINT: begin - result:=CDRF_NOTIFYSUBITEMDRAW; - - SetCellColor(lplvcd,lplvcd^.nmcd.lItemlParam); - - exit; - end; - CDDS_SUBITEM or CDDS_ITEMPREPAINT: begin - - i:=lplvcd^.nmcd.lItemlParam; - SetCellColor(lplvcd,i); - - sub:=ListViewToColumn(lplvcd^.iSubItem); - - if (qsopt.columns[sub].flags and COL_GENDER)<>0 then - begin - ListView_GetSubItemRect(grid,lplvcd^.nmcd.dwItemSpec,lplvcd^.iSubItem,LVIR_ICON,@rc); - - case MainBuf[i,sub].data of - 70: h:=hIconF; - 77: h:=hIconM; - else - h:=0; - end; - if h<>0 then - begin - DrawIconEx(lplvcd^.nmcd.hdc,rc.left+1,rc.top,h,16,16,0,0,DI_NORMAL); - end; - result:=CDRF_SKIPDEFAULT; - end - - else if (qsopt.columns[sub].flags and COL_XSTATUS)<>0 then - begin - j:=StrToInt(MainBuf[i,sub].text); - if j>0 then - begin - StrCopy(StrCopyE(buf,GetProtoName(FlagBuf[i].proto)),PS_GETCUSTOMSTATUSICON); - if ServiceExists(buf) then - begin - h:=CallService(buf,j,LR_SHARED); - - ListView_GetSubItemRect(grid,lplvcd^.nmcd.dwItemSpec,lplvcd^.iSubItem,LVIR_ICON,@rc); - DrawIconEx(lplvcd^.nmcd.hdc,rc.left+1,rc.top,h,16,16,0,0,DI_NORMAL); - end; - end; - result:=CDRF_SKIPDEFAULT; - end - - else if ((qsopt.flags and QSO_CLIENTICONS)<>0) and - ((qsopt.columns[sub].flags and COL_CLIENT)<>0) then - result:=CDRF_NOTIFYPOSTPAINT; - end; - - CDDS_SUBITEM or CDDS_ITEMPOSTPAINT: begin - sub:=ListViewToColumn(lplvcd^.iSubItem); - if (qsopt.columns[sub].flags and COL_CLIENT)<>0 then - begin - MirVerW:=MainBuf[lplvcd^.nmcd.lItemlParam,sub].text; - -//!! - if (MirVerW<>nil) and (MirVerW[0]<>#0) and ServiceExists(MS_FP_GETCLIENTICONW) then - begin - h:=CallService(MS_FP_GETCLIENTICONW,tlparam(MirVerW),0); - ListView_GetSubItemRect(grid,lplvcd^.nmcd.dwItemSpec,lplvcd^.iSubItem,LVIR_ICON,@rc); - DrawIconEx(lplvcd^.nmcd.hdc,rc.left+1,rc.top,h,16,16,0,0,DI_NORMAL); - DestroyIcon(h); - end; - result:=CDRF_SKIPDEFAULT; - end; - end; - end; -end; - - -function NewEditProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -var - li:LV_ITEM; - count,current,next,perpage:integer; -begin - result:=0; - case hMessage of - WM_CHAR: if wParam=27 then - begin - PostMessage(GetParent(Dialog),WM_COMMAND,(BN_CLICKED shl 16)+IDCANCEL,0); - exit; - end; - WM_KEYUP: if wParam=VK_RETURN then - begin - if ListView_GetSelectedCount(grid)=1 then - ShowContactMsgDlg(GetFocusedhContact); - exit; - end; - WM_KEYDOWN: begin - count :=ListView_GetItemCount(grid); - current:=ListView_GetNextItem(grid,-1,LVNI_FOCUSED); - next:=-1; - if count>0 then - case wParam of - VK_NEXT,VK_PRIOR: begin - perpage:=ListView_GetCountPerPage(grid); - if wParam=VK_NEXT then - next:=Min(current+perpage,count) - else - next:=Max(current-perpage,0); - end; - VK_UP: begin - if current>0 then - next:=current-1 - end; - VK_DOWN: begin - if current=0 then - begin - li.statemask:=LVIS_SELECTED; - li.state:=0; - SendMessage(grid,LVM_SETITEMSTATE,twparam(-1),tlparam(@li)); - ListView_SetItemState(grid,next,LVIS_FOCUSED or LVIS_SELECTED, - LVIS_FOCUSED or LVIS_SELECTED); - SendMessage(grid,LVM_ENSUREVISIBLE,next,0); - result:=0; - exit; - end; - end; - end; - result:=CallWindowProc(OldEditProc,Dialog,hMessage,wParam,lParam); -end; - -procedure ClearBuffers; -var - w,h:integer; -begin - for w:=0 to HIGH(MainBuf) do - for h:=0 to HIGH(MainBuf[0]) do - mFreeMem(MainBuf[w,h].text); - - SetLength(MainBuf,0); - SetLength(FlagBuf,0); -end; - -procedure SetSpecialColumns(num:integer); -begin - with qsopt.columns[num] do - begin - if setting_type=QST_SETTING then - begin - if (datatype=QSTS_STRING) and - (StrCmp(module ,'CList')=0) and - (StrCmp(setting,'Group')=0) then - begin - flags:=flags or COL_GROUP - end - - else if (datatype=QSTS_STRING) and - (StrCmp(module ,'Tab_SRMsg' )=0) and - (StrCmp(setting,'containerW')=0) then - begin - flags:=flags or COL_CNTNR - end - - else if (datatype=QSTS_BYTE) and - (lstrcmpia(setting,'XStatusId')=0) then - begin - flags:=flags or COL_XSTATUS; - end - - else if (datatype=QSTS_STRING) and - (StrCmp(setting,'MirVer')=0) and - ServiceExists(MS_FP_GETCLIENTICONW) then - flags:=flags or COL_CLIENT; - - end - else if (setting_type=QST_CONTACTINFO) and (cnftype=CNF_GENDER) then - begin - if hIconF=0 then hIconF:=IcoLib_GetIcon(QS_FEMALE,0); - if hIconM=0 then hIconM:=IcoLib_GetIcon(QS_MALE,0); - flags:=flags or COL_GENDER; - tstrMale :=TranslateW('Male'); - tstrFemale :=TranslateW('Female'); - tstrUnknown:=TranslateW('Unknown'); - end; - - qsopt.columns[num].flags:=flags; - end; -end; - -// Set columns and clear listview -procedure PrepareTable(reset:boolean=false); -var - lvcol:LV_COLUMNW; - hdi:THDITEM; - i:integer; - old:integer; -begin - SendMessage(grid,LVM_DELETEALLITEMS,0,0); - - zeromemory(@hdi,sizeof(hdi)); - hdi.mask:=HDI_FORMAT; - - old:=tablecolumns; - tablecolumns:=0; - zeromemory(@lvcol,sizeof(lvcol)); - lvcol.mask:=LVCF_TEXT or LVCF_WIDTH; - for i:=0 to qsopt.numcolumns-1 do - begin - with qsopt.columns[i] do - begin - if (flags and COL_ON)<>0 then - begin - addcolumn(tablecolumns,@qsopt.columns[i]); - inc(tablecolumns); - end; - - SetSpecialColumns(i); - end; - end; - - if reset then - begin - for i:=old+tablecolumns-1 downto tablecolumns do - begin - SendMessage(grid,LVM_DELETECOLUMN,i,0); - end; - end; - - ListView_SetItemCount(grid,HIGH(FlagBuf)+1); -end; - -//----- Miranda Events ----- - -procedure ChangeStatusPicture(row:integer; hContact:THANDLE; Pic:integer); -var - li:LV_ITEMW; -begin - row:=FindItem(row); - if row>=0 then - begin - li.iItem :=row; - li.iSubItem:=0; - li.mask :=LVIF_IMAGE; - li.iImage :=Pic;//CallService(MS_CLIST_GETCONTACTICON,hContact,0); - SendMessageW(grid,LVM_SETITEMW,0,lparam(@li)); - end; -end; - -function OnStatusChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - j:integer; - oldstat,newstat:integer; -begin - result:=0; - - j:=FindBufNumber(wParam); - if j>=0 then - begin - oldstat:=FlagBuf[j].status; - newstat:=DBReadWord(wParam,GetProtoName(FlagBuf[j].proto),'Status',ID_STATUS_OFFLINE); - FlagBuf[j].status:=newstat; - - if (oldstat<>ID_STATUS_OFFLINE) and (newstat<>ID_STATUS_OFFLINE) then - ChangeStatusPicture(j,wParam,lParam) - else if (oldstat=ID_STATUS_OFFLINE) {and (newstat<>ID_STATUS_OFFLINE)} then - begin - if (qsopt.flags and QSO_SHOWOFFLINE)<>0 then - ChangeStatusPicture(j,wParam,lParam) - else - ProcessLine(j,true) // why false? need to filter! - end - else if {(oldstat<>ID_STATUS_OFFLINE) and} (newstat=ID_STATUS_OFFLINE) then - begin - if (qsopt.flags and QSO_SHOWOFFLINE)<>0 then - ChangeStatusPicture(j,wParam,lParam) - else - begin - FlagBuf[j].flags:=FlagBuf[j].flags and not QSF_ACTIVE; - ListView_DeleteItem(grid,FindItem(j)); - end; - end; - - // refresh table to new filtering - if (qsopt.flags and QSO_SORTBYSTATUS)<>0 then - Sort; - UpdateSB; - end; -end; - -function OnContactAdded(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - i:integer; -begin - result:=0; - // refresh table to add contact - i:=Length(MainBuf); - SetLength(MainBuf,i+1); - SetLength(MainBuf[i],qsopt.numcolumns); - FillChar(MainBuf[i][0],qsopt.numcolumns*SizeOf(tQSRec),0); - SetLength(FlagBuf,i+1); - - AddContact(i,wParam); - ProcessLine(i); - Sort; - UpdateSB; -end; - -function OnContactDeleted(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - i,j:integer; -begin - result:=0; - i:=FindBufNumber(wParam); - if i>=0 then - begin - FlagBuf[i].flags:=(FlagBuf[i].flags or QSF_DELETED) and not QSF_ACTIVE; - for j:=0 to HIGH(MainBuf[0]) do - mFreeMem(MainBuf[i,j].text); - i:=FindItem(i); - if i>=0 then - ListView_DeleteItem(grid,i); - UpdateSB; - end; -end; -{ -function OnAccountChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -begin - result:=0; - - case wParam of - PRAC_ADDED: begin - end; - PRAC_REMOVED: begin - end; - PRAC_CHECKED: begin - with PPROTOACCOUNT(lParam)^ do - begin - if bIsEnabled<>0 then - begin - end - else - begin - end; - end; - end; - end; -end; -} -//----- Main window procedure with support ----- - -function FindAddDlgResizer(Dialog:HWND;lParam:LPARAM;urc:PUTILRESIZECONTROL):int; cdecl; -begin - case urc^.wId of - IDCANCEL: result:=RD_ANCHORX_RIGHT or RD_ANCHORY_TOP; - IDC_REFRESH: result:=RD_ANCHORX_RIGHT or RD_ANCHORY_TOP; - IDC_CH_SHOWOFFLINE: result:=RD_ANCHORX_LEFT or RD_ANCHORY_TOP; - IDC_CH_COLORIZE: result:=RD_ANCHORX_LEFT or RD_ANCHORY_TOP; - IDC_CB_PROTOCOLS: result:=RD_ANCHORX_LEFT or RD_ANCHORY_TOP; - IDC_E_SEARCHTEXT: result:=RD_ANCHORX_WIDTH or RD_ANCHORY_TOP; - IDC_LIST: result:=RD_ANCHORX_WIDTH or RD_ANCHORY_HEIGHT; - IDC_STATUSBAR: result:=RD_ANCHORX_WIDTH or RD_ANCHORY_BOTTOM; - else - result:=0; - end; -end; - -procedure FillProtoCombo(cb:HWND); -var - i:integer; -begin - SendMessage(cb,CB_RESETCONTENT,0,0); - CB_AddStrDataW(cb,TranslateW('All')); - for i:=1 to GetNumProto do - begin - CB_AddStrDataW(cb,GetProtoAccName(i),i); - end; - SendMessage(cb,CB_SETCURSEL,0,0); -end; - -var - hAdd, - hDelete, -// hAccount, - hChange:THANDLE; - -procedure SaveColumnOrder; -var - tmpcolumns:array [0..MaxColumnAmount-1] of integer; - lvc:LV_COLUMNW; - i,idx,num,cnt:integer; -begin - DBDeleteGroup(0,qs_module,'item*'); - idx:=0; - lvc.mask:=LVCF_ORDER or LVCF_WIDTH; - for i:=0 to qsopt.numcolumns-1 do - begin - if qsopt.columns[i].setting_type<>0 then - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - begin - SendMessageW(grid,LVM_GETCOLUMN,idx,tlparam(@lvc)); - qsopt.columns[i].width:=lvc.cx; - tmpcolumns[lvc.iOrder]:=i; - inc(idx); - end; - end; - end; - idx:=0; - cnt:=0; - for i:=0 to qsopt.numcolumns-1 do - begin - if qsopt.columns[i].setting_type<>0 then - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - begin - num:=tmpcolumns[idx]; - inc(idx); - end - else - num:=i; - savecolumn(cnt,qsopt.columns[num]); - inc(cnt); - end - end; -end; - -function QSMainWndProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; -var - smenu:HMENU; - header:HWND; - hdi:THDITEM; - w,h:uint_ptr; - tmp:LONG_PTR; - buf:array [0..255] of WideChar; - colarr:array [0..127] of integer absolute buf; - rc:TRECT; - pt:TPOINT; - TI:tToolInfoW; -begin - result:=0; - case hMessage of - WM_DESTROY: begin - if srvhandle<>0 then DestroyServiceFunction(srvhandle); - if mnuhandle<>0 then Menu_RemoveItem(mnuhandle); - - UnhookEvent(hAdd); - UnhookEvent(hDelete); - UnhookEvent(hChange); - UnhookEvent(colorhook); - - mainwnd:=0; - - StatusBar:=0; - GetWindowRect(Dialog,rc); - - CopyRect(qsopt.grrect,rc); - - // save column width/order - if grid<>0 then - SaveColumnOrder - else - grid:=0; - - saveopt_wnd; - - ListView_SetImageList(GetDlgItem(Dialog,IDC_LIST),0,LVSIL_SMALL); - - if (qsopt.flags and QSO_SAVEPATTERN)<>0 then - begin - DBWriteUnicode(0,qs_module,'pattern',pattern); - end; - - mFreeMem(patstr); - mFreeMem(pattern); - - ClearBuffers; - - end; - - WM_INITDIALOG: begin - srvhandle:=0; - mnuhandle:=0; - - SetWindowTextW(Dialog,'Quick Search'); - - StatusBar:=GetDlgItem(Dialog,IDC_STATUSBAR); - - smenu:=GetSystemMenu(Dialog,false); - InsertMenu (smenu,5,MF_BYPOSITION or MF_SEPARATOR,0,nil); - InsertMenuW(smenu,6,MF_BYPOSITION or MF_STRING, - IDM_STAYONTOP,TranslateW('Stay on Top')); - - if (qsopt.flags and QSO_STAYONTOP)<>0 then - begin - CheckMenuItem(smenu,IDM_STAYONTOP,MF_BYCOMMAND or MF_CHECKED); - SetWindowPos(Dialog,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); - end; - AdvFilter:=0; - CheckDlgButton(Dialog,IDC_CH_SHOWOFFLINE,ORD((qsopt.flags and QSO_SHOWOFFLINE)<>0)); - if (qsopt.flags and QSO_SHOWOFFLINE)<>0 then - begin - AdvFilter:=AdvFilter or flt_show_offline; - end; - - CheckDlgButton(Dialog,IDC_CH_COLORIZE,ORD((qsopt.flags and QSO_COLORIZE)<>0)); - - // Window - mainwnd:=Dialog; - tmp:=GetWindowLongPtrW(Dialog,GWL_EXSTYLE); - if (qsopt.flags and QSO_TOOLSTYLE)<>0 then - tmp:=tmp or WS_EX_TOOLWINDOW - else - tmp:=tmp and not WS_EX_TOOLWINDOW; - SetWindowLongPtrW(Dialog,GWL_EXSTYLE,tmp); - - SendMessage(Dialog,WM_SETICON,ICON_SMALL,IcoLib_GetIcon(QS_QS,0)); - grid:=GetDlgItem(Dialog,IDC_LIST); - - // ListView - ListView_SetImageList(grid,Clist_GetImageList,LVSIL_SMALL); - - tmp:=LVS_EX_FULLROWSELECT or LVS_EX_SUBITEMIMAGES or LVS_EX_HEADERDRAGDROP or - LVS_EX_LABELTIP or LVS_EX_DOUBLEBUFFER; - if (qsopt.flags and QSO_DRAWGRID)<>0 then - tmp:=tmp or LVS_EX_GRIDLINES; - SendMessage(grid,LVM_SETEXTENDEDLISTVIEWSTYLE,0,tmp); - - // ListView header - header:=ListView_GetHeader(grid); - SetWindowLongPtrW(header,GWL_STYLE, - GetWindowLongPtrW(header,GWL_STYLE) or HDS_CHECKBOXES); - - OldLVProc :=pointer(SetWindowLongPtrW(grid,GWL_WNDPROC,LONG_PTR(@NewLVProc))); - OldEditProc:=pointer(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_E_SEARCHTEXT), - GWL_WNDPROC,LONG_PTR(@NewEditProc))); - - OldLVHProc:=pointer(SetWindowLongPtrW( - SendMessage(grid,LVM_GETHEADER,0,0), - GWL_WNDPROC,LONG_PTR(@NewLVHProc))); - - FillProtoCombo(GetDlgItem(Dialog,IDC_CB_PROTOCOLS)); - - PrepareTable; - - if pattern<>nil then - begin - SetDlgItemTextW(Dialog,IDC_E_SEARCHTEXT,pattern) - end - else - begin - buf[0]:=#0; - SetDlgItemTextW(Dialog,IDC_E_SEARCHTEXT,@buf); - FillGrid; - end; - - // Show sorting column - zeromemory(@hdi,sizeof(hdi)); - hdi.mask:=HDI_FORMAT; - SendMessageW(header,HDM_GETITEM,qsopt.columnsort,tlparam(@hdi)); - if (qsopt.flags and QSO_SORTASC)=0 then - hdi.fmt:=hdi.fmt or HDF_SORTDOWN - else - hdi.fmt:=hdi.fmt or HDF_SORTUP; - SendMessageW(header,HDM_SETITEM,qsopt.columnsort,tlparam(@hdi)); - - - TranslateDialogDefault(Dialog); - - SnapToScreen(qsopt.grrect); - with qsopt.grrect do - MoveWindow(Dialog,left,top,right-left,bottom-top,false); - - with TI do - begin - cbSize :=SizeOf(TI); - uFlags :=TTF_SUBCLASS+TTF_IDISHWND; - hWnd :=Dialog; - uId :=grid; - hInst :=0; - lpszText :=nil; - end; - HintWnd:=CreateWindowExW(0,TOOLTIPS_CLASS,nil,0, - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - integer(CW_USEDEFAULT),integer(CW_USEDEFAULT), - Dialog,0,HInstance,NIL); - - SendMessageW(HintWnd,TTM_ADDTOOLW,0,tlparam(@TI)); - colorhook:=HookEvent(ME_COLOUR_RELOAD,@ColorReload); - - hAdd :=HookEvent(ME_DB_CONTACT_ADDED ,@OnContactAdded); - hDelete:=HookEvent(ME_DB_CONTACT_DELETED ,@OnContactDeleted); - hChange:=HookEvent(ME_CLIST_CONTACTICONCHANGED,@OnStatusChanged); -// hAccount:=HookEvent(ME_PROTO_ACCLISTCHANGED ,@OnAccountChanged); - end; - - WM_GETMINMAXINFO: begin - with PMINMAXINFO(lParam)^ do - begin - ptMinTrackSize.x:=300; - ptMinTrackSize.y:=160; - end; - end; - - WM_SIZE: begin - SendMessage(StatusBar,WM_SIZE,0,0); - Utils_ResizeDialog(Dialog, hInstance, MAKEINTRESOURCEA(IDD_MAIN), @FindAddDlgResizer); - end; - - WM_SYSCOMMAND: begin - if wParam=IDM_STAYONTOP then - begin - if (qsopt.flags and QSO_STAYONTOP)<>0 then - begin - h:=MF_BYCOMMAND or MF_UNCHECKED; - w:=HWND_NOTOPMOST; - end - else - begin - h:=MF_BYCOMMAND or MF_CHECKED; - w:=HWND_TOPMOST; - end; - CheckMenuItem(GetSystemMenu(Dialog,false),IDM_STAYONTOP,h); - SetWindowPos(Dialog,w,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); - qsopt.flags:=qsopt.flags xor QSO_STAYONTOP; - exit; - end; - end; - - WM_CONTEXTMENU: begin - if wParam=tWPARAM(GetDlgItem(Dialog,IDC_LIST)) then - begin - w:=ListView_GetSelectedCount(grid); - if w>1 then - ShowMultiPopup(w) - else - begin - ShowContactMenu(Dialog,GetFocusedhContact, - GetLVSubItem(loword(lParam),hiword(lParam))); - end; - end; - end; - - WM_MEASUREITEM: - Menu_MeasureItem(lParam); - WM_DRAWITEM: - Menu_DrawItem(lParam); - - WM_MOUSEMOVE: begin - if TTInstalled then - begin - GetWindowRect(grid,rc); - pt.x:=loword(lParam); - pt.y:=hiword(lParam); - ClientToScreen(Dialog,pt); - if not PtInRect(rc,pt) then - begin - if TTShowed then - begin - TTShowed:=false; - CallService(MS_TIPPER_HIDETIP,0,0); - end; - KillTimer(grid,TIMERID_HOVER); - end; - end; - end; - - WM_KEYDOWN: begin - case wParam of - VK_F5: begin - PostMessage(Dialog,WM_COMMAND,(BN_CLICKED shl 16)+IDC_REFRESH,0); - exit; - end; - end; - end; - - WM_COMMAND: begin - if Clist_MenuProcessCommand(LOWORD(wParam),MPCF_CONTACTMENU,GetFocusedhContact)<>0 then - begin - if (qsopt.flags and QSO_AUTOCLOSE)<>0 then - CloseSrWindow; - exit; - end; - - case wParam shr 16 of - CBN_SELCHANGE: begin - AdvFilter:=(AdvFilter and not $FF) or cardinal(CB_GetData(lParam)); - AdvancedFilter; - end; - - EN_CHANGE: begin - GetDlgItemTextW(Dialog,IDC_E_SEARCHTEXT,buf,sizeOf(buf)); - mFreeMem(pattern); - StrDupW(pattern,buf); - if pattern<>nil then - CharLowerW(pattern); - FillGrid; //!! - end; - - BN_CLICKED: begin - case loword(wParam) of - IDC_CH_SHOWOFFLINE: begin - if IsDlgButtonChecked(Dialog,IDC_CH_SHOWOFFLINE)<>BST_UNCHECKED then - begin - qsopt.flags:=qsopt.flags or QSO_SHOWOFFLINE; - AdvFilter:=AdvFilter or flt_show_offline - end - else - begin - qsopt.flags:=qsopt.flags and not QSO_SHOWOFFLINE; - AdvFilter:=AdvFilter and not flt_show_offline; - end; - AdvancedFilter; - end; - - IDC_CH_COLORIZE: begin - if IsDlgButtonChecked(Dialog,IDC_CH_COLORIZE)=BST_UNCHECKED then - qsopt.flags:=qsopt.flags and not QSO_COLORIZE - else - qsopt.flags:=qsopt.flags or QSO_COLORIZE; - RedrawWindow(grid,nil,0,RDW_INVALIDATE); - end; - - IDC_REFRESH: begin - ClearBuffers; - PrepareToFill; - PrepareTable(true); - FillGrid; - end; - - IDCANCEL: CloseSrWindow(); - end; - end; - end; - end; - - WM_NOTIFY: begin - case integer(PNMHdr(lParam)^.code) of - LVN_COLUMNCLICK: begin - ColumnClick(PNMListView(lParam)^.hdr.hwndFrom,PNMListView(lParam)^.iSubItem); - end; - NM_CUSTOMDRAW: begin - if PNMHdr(lParam)^.hwndFrom=grid then - begin - SetWindowLongPtrW(Dialog,DWL_MSGRESULT,ProcessCustomDraw(lParam)); - result:=1; - end; - end; - end; - end; - -// else -// result:=DefWindowProc(Dialog,hMessage,wParam,lParam); - end; -end; - -//----- base QS window functions ----- - -function CloseSrWindow(save:boolean=true):boolean; -begin - if mainwnd<>0 then - begin - result:=true; - //!! cheat - if not save then - grid:=0; - - DestroyWindow(mainwnd); - - FreeProtoList; - end - else - result:=false; -end; - -function BringToFront:integer; -var - wp:TWINDOWPLACEMENT; -begin - result:=1; - wp.length:=SizeOf(TWINDOWPLACEMENT); - GetWindowPlacement(mainwnd,@wp); - if wp.showCmd=SW_SHOWMINIMIZED then - ShowWindow(mainwnd,SW_RESTORE); - SetForegroundWindow(mainwnd); -end; - -function OpenSRWindow(apattern:PWideChar;flags:LPARAM):boolean; -var - i,j:integer; -begin - result:=true; - if mainwnd<>0 then - begin - BringToFront; - exit; - end; - - j:=0; - for i:=0 to qsopt.numcolumns-1 do - begin - if (qsopt.columns[i].flags and COL_ON)<>0 then - inc(j); - end; - // no even one visible column - if j=0 then - exit; - - TTInstalled := ServiceExists(MS_TIPPER_SHOWTIP); - // too lazy to move pattern and flags to thread - if apattern<>nil then - begin - if flags=0 then - StrDupW(pattern,apattern) - else - AnsiToWide(PAnsiChar(apattern),pattern); - CharLowerW(pattern); - end - else if (qsopt.flags and QSO_SAVEPATTERN)<>0 then - pattern:=DBReadUnicode(0,qs_module,'pattern',nil) - else - pattern:=nil; - - CreateProtoList; - if PrepareToFill then - begin - ColorReload(0,0); - loadopt_wnd; - CreateDialogW(hInstance,PWideChar(IDD_MAIN),0,@QSMainWndProc); - end; -end; - -end. diff --git a/plugins/QuickSearch/version.rc b/plugins/QuickSearch/version.rc deleted file mode 100644 index f8a7987f9c..0000000000 --- a/plugins/QuickSearch/version.rc +++ /dev/null @@ -1,49 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "..\..\include\m_version.h" - ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -#pragma code_page(1252) -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,2,0 - PRODUCTVERSION MIRANDA_VERSION_COREVERSION - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN -// VALUE "Author", __AUTHOR -// VALUE "FileDescription", __DESCRIPTION -// VALUE "FileVersion", __VERSION_STRING -// VALUE "InternalName", __PLUGIN_NAME -// VALUE "LegalCopyright", __COPYRIGHT -// VALUE "OriginalFilename", __FILENAME -// VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3