summaryrefslogtreecommitdiff
path: root/plugins/Utils.pas
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Utils.pas')
-rw-r--r--plugins/Utils.pas/base64.pas8
-rw-r--r--plugins/Utils.pas/common.pas54
-rw-r--r--plugins/Utils.pas/contact.pas129
-rw-r--r--plugins/Utils.pas/i_text_const.inc9
-rw-r--r--plugins/Utils.pas/icobuttons.pas2
-rw-r--r--plugins/Utils.pas/mApiCardM.pas68
-rw-r--r--plugins/Utils.pas/memini.pas142
-rw-r--r--plugins/Utils.pas/mirutils.pas18
-rw-r--r--plugins/Utils.pas/protocols.pas38
-rw-r--r--plugins/Utils.pas/sedit.pas16
-rw-r--r--plugins/Utils.pas/strans.pas48
-rw-r--r--plugins/Utils.pas/wrapper.pas22
-rw-r--r--plugins/Utils.pas/zwrapper.pas8
13 files changed, 438 insertions, 124 deletions
diff --git a/plugins/Utils.pas/base64.pas b/plugins/Utils.pas/base64.pas
index 1819efbbd5..d6cebae930 100644
--- a/plugins/Utils.pas/base64.pas
+++ b/plugins/Utils.pas/base64.pas
@@ -5,8 +5,8 @@ interface
uses windows;
{ Base64 encode and decode a string }
-function BASE64Encode(src:pByte;len:integer):PAnsiChar;
-function BASE64Decode(src:PAnsiChar;var dst:pByte):integer;
+function Base64Encode(src:pByte;len:integer):PAnsiChar;
+function Base64Decode(src:PAnsiChar;var dst:pByte):integer;
{******************************************************************************}
{******************************************************************************}
@@ -18,7 +18,7 @@ const
base64chars{:array [0..63] of AnsiChar}:PAnsiChar =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
-function BASE64Encode(src:pByte;len:integer):PAnsiChar;
+function Base64Encode(src:pByte;len:integer):PAnsiChar;
var
dst:PAnsiChar;
begin
@@ -68,7 +68,7 @@ begin
end;
end;
-function BASE64Decode(src:PAnsiChar;var dst:pByte):integer;
+function Base64Decode(src:PAnsiChar;var dst:pByte):integer;
var
slen:integer;
ptr:pByte;
diff --git a/plugins/Utils.pas/common.pas b/plugins/Utils.pas/common.pas
index 88df058957..cd321cbcb7 100644
--- a/plugins/Utils.pas/common.pas
+++ b/plugins/Utils.pas/common.pas
@@ -183,6 +183,8 @@ function StrToInt(src:pWideChar):int64; overload;
function StrToInt(src:PAnsiChar):int64; overload;
function HexToInt(src:pWideChar;len:cardinal=$FFFF):int64; overload;
function HexToInt(src:PAnsiChar;len:cardinal=$FFFF):int64; overload;
+function NumToInt(src:pWideChar):int64; overload;
+function NumToInt(src:pAnsiChar):int64; overload;
// filename work
function ChangeExt (src,ext:PAnsiChar):PAnsiChar;
@@ -210,7 +212,7 @@ implementation
// Murmur 2.0
function Hash(s:pointer; len:integer{const Seed: LongWord=$9747b28c}): LongWord;
var
- hash: LongWord;
+ lhash: LongWord;
k: LongWord;
tmp,data: pByte;
const
@@ -222,7 +224,7 @@ begin
//The default seed, $9747b28c, is from the original C library
// Initialize the hash to a 'random' value
- hash := {seed xor }len;
+ lhash := {seed xor }len;
// Mix 4 bytes at a time into the hash
data := s;
@@ -235,8 +237,8 @@ begin
k := k xor (k shr r);
k := k*m;
- hash := hash*m;
- hash := hash xor k;
+ lhash := lhash*m;
+ lhash := lhash xor k;
inc(data,4);
dec(len,4);
@@ -247,27 +249,27 @@ begin
begin
tmp:=data;
inc(tmp,2);
- hash := hash xor (LongWord(tmp^) shl 16);
+ lhash := lhash xor (LongWord(tmp^) shl 16);
end;
if len >= 2 then
begin
tmp:=data;
inc(tmp);
- hash := hash xor (LongWord(tmp^) shl 8);
+ lhash := lhash xor (LongWord(tmp^) shl 8);
end;
if len >= 1 then
begin
- hash := hash xor (LongWord(data^));
- hash := hash * m;
+ lhash := lhash xor (LongWord(data^));
+ lhash := lhash * m;
end;
// Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
- hash := hash xor (hash shr 13);
- hash := hash * m;
- hash := hash xor (hash shr 15);
+ lhash := lhash xor (lhash shr 13);
+ lhash := lhash * m;
+ lhash := lhash xor (lhash shr 15);
- Result := hash;
+ Result := lhash;
end;
function BSwap(value:dword):dword;
@@ -2054,6 +2056,34 @@ begin
result:=FastAnsiToWideBuf(IntToTime(buf,time),dst);
end;
+function NumToInt(src:pWideChar):int64;
+begin
+ if (src[0]='$') and
+ (AnsiChar(src[1]) in sHexNum) then
+ result:=HexToInt(src+1)
+ else
+ if (src[0]='0') and
+ (src[1]='x') and
+ (AnsiChar(src[2]) in sHexNum) then
+ result:=HexToInt(src+2)
+ else
+ result:=StrToInt(src);
+end;
+
+function NumToInt(src:pAnsiChar):int64;
+begin
+ if (src[0]='$') and
+ (src[1] in sHexNum) then
+ result:=HexToInt(src+1)
+ else
+ if (src[0]='0') and
+ (src[1]='x') and
+ (src[2] in sHexNum) then
+ result:=HexToInt(src+2)
+ else
+ result:=StrToInt(src);
+end;
+
function StrToInt(src:pWideChar):int64;
var
sign:boolean;
diff --git a/plugins/Utils.pas/contact.pas b/plugins/Utils.pas/contact.pas
new file mode 100644
index 0000000000..93bd4f7f73
--- /dev/null
+++ b/plugins/Utils.pas/contact.pas
@@ -0,0 +1,129 @@
+{Contact list in combo}
+unit contact;
+
+interface
+
+uses windows;
+
+procedure FillContactList(list:hwnd; filter:boolean=true;format:pWideChar=nil);
+function FindContact(list:hwnd;contact:THANDLE):integer;
+
+implementation
+
+uses messages, common, m_api, dbsettings, mirutils;
+
+const
+ defformat = '%name% - %uid% (%account%:%group%)';
+
+procedure FillContactList(list:hwnd; filter:boolean=true;format:pWideChar=nil);
+var
+ hContact:THANDLE;
+ buf:array [0..511] of WideChar;
+ buf1:array [0..63] of WideChar;
+ p:PWideChar;
+ uid:pAnsiChar;
+ ldbv:TDBVARIANT;
+ acc:pAnsiChar;
+ lName,
+ lGroup,
+ lAccount,
+ lUID:boolean;
+begin
+ if format=nil then format:=defformat;
+
+ SendMessage(list,CB_RESETCONTENT,0,0);
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+
+ lName :=StrPosW(format,'%name%')<>nil;
+ lGroup :=StrPosW(format,'%group%')<>nil;
+ lAccount:=StrPosW(format,'%account%')<>nil;
+ lUID :=StrPosW(format,'%uid%')<>nil;
+
+ while hContact<>0 do
+ begin
+ if ((not filter) and ((IsContactActive(hContact)+1)>=0)) or // + disabled (not deleted)
+ (filter and (IsContactActive(hContact) >=0)) then
+ begin
+ StrCopyW(buf,format);
+ if lName then
+ StrReplaceW(buf,'%name%',
+ PWideChar(CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,GCDNF_UNICODE)));
+
+ if lGroup then
+ begin
+ p:=DBReadUnicode(hContact,strCList,'Group',nil);
+ StrReplaceW(buf,'%group%',p);
+ mFreeMem(p);
+ end;
+
+ if lAccount then
+ begin
+ acc:=GetContactProtoAcc(hContact);
+ StrReplaceW(buf,'%account%',FastAnsiToWideBuf(acc,buf1));
+ end
+ else
+ acc:=nil;
+
+ if lUID then
+ begin
+ if acc=nil then
+ acc:=GetContactProtoAcc(hContact);
+ if IsChat(hContact) then
+ begin
+ p:=DBReadUnicode(hContact,acc,'ChatRoomID');
+ StrReplaceW(buf,'%uid%',p);
+ mFreeMem(p);
+ end
+ else
+ begin
+ uid:=pAnsiChar(CallProtoService(acc,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0));
+ if uid<>pAnsiChar(CALLSERVICE_NOTFOUND) then
+ begin
+ if DBReadSetting(hContact,acc,uid,@ldbv)=0 then
+ begin
+ case ldbv._type of
+ DBVT_DELETED: p:='[deleted]';
+ DBVT_BYTE : p:=IntToStr(buf1,ldbv.bVal);
+ DBVT_WORD : p:=IntToStr(buf1,ldbv.wVal);
+ DBVT_DWORD : p:=IntToStr(buf1,ldbv.dVal);
+ DBVT_UTF8 : UTF8ToWide(ldbv.szVal.A,p);
+ DBVT_ASCIIZ : AnsiToWide(ldbv.szVal.A,p,MirandaCP);
+ DBVT_WCHAR : p:=ldbv.szVal.W;
+ DBVT_BLOB : p:='blob';
+ end;
+ StrReplaceW(buf,'%uid%',p);
+ if ldbv._type in [DBVT_UTF8,DBVT_ASCIIZ] then
+ mFreeMem(p);
+ DBFreeVariant(@ldbv);
+ end;
+ end;
+ StrReplaceW(buf,'%uid%',nil);
+ end;
+ end;
+
+ SendMessage(list,CB_SETITEMDATA,
+ SendMessageW(list,CB_ADDSTRING,0,tlparam(@buf)),
+ hContact);
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+end;
+
+function FindContact(list:hwnd;contact:THANDLE):integer;
+var
+ j:integer;
+begin
+ result:=0;
+ j:=SendMessage(list,CB_GETCOUNT,0,0);
+ while j>0 do
+ begin
+ dec(j);
+ if THANDLE(SendMessage(list,CB_GETITEMDATA,j,0))=contact then
+ begin
+ result:=j;
+ break;
+ end;
+ end;
+end;
+
+end.
diff --git a/plugins/Utils.pas/i_text_const.inc b/plugins/Utils.pas/i_text_const.inc
new file mode 100644
index 0000000000..f674524725
--- /dev/null
+++ b/plugins/Utils.pas/i_text_const.inc
@@ -0,0 +1,9 @@
+const
+// IDD_TEXTFIELD = ;
+
+ IDC_TYPE = 1025;
+ IDC_SCRIPT_HELP = 1026;
+ IDC_TEXT_WRAP = 1027;
+ IDC_TEXT_SCRIPT = 1028;
+ IDC_TEXT_EDIT_W = 1029;
+ IDC_TEXT_EDIT_NW = 1030;
diff --git a/plugins/Utils.pas/icobuttons.pas b/plugins/Utils.pas/icobuttons.pas
index fdac39e69e..bf58caa054 100644
--- a/plugins/Utils.pas/icobuttons.pas
+++ b/plugins/Utils.pas/icobuttons.pas
@@ -174,7 +174,7 @@ begin
if D.rptvalue<>0 then
begin
- D.rpttimer:=SetTimer(Sender.Handle,dword(Sender),D.rptvalue,@TimerProc);
+ D.rpttimer:=SetTimer(Sender.Handle,uint(Sender),D.rptvalue,@TimerProc);
// D.rpttimer:=SetTimer(Sender.GetWindowHandle,1,D.rptvalue,nil);
end;
end;
diff --git a/plugins/Utils.pas/mApiCardM.pas b/plugins/Utils.pas/mApiCardM.pas
index 8a3011153d..6002ee2dbc 100644
--- a/plugins/Utils.pas/mApiCardM.pas
+++ b/plugins/Utils.pas/mApiCardM.pas
@@ -8,14 +8,16 @@ uses windows,messages;
type
tmApiCard = class
private
- function GetDescription:pAnsiChar;
- function GetResultType :pAnsiChar;
+ function GetDescription:pAnsiChar;
+ function GetResultType :pAnsiChar;
procedure SetCurrentService(item:pAnsiChar);
public
constructor Create(fname:pAnsiChar; lparent:HWND=0);
- destructor Free;
+ destructor Destroy; override;
procedure FillList(combo:HWND; mode:integer=0);
+ function NameFromList(cb:HWND):pAnsiChar;
+ function HashToName(ahash:longword):pAnsiChar;
function FillParams(wnd:HWND{;item:pAnsiChar};wparam:boolean):pAnsiChar;
procedure Show;//(item:pAnsiChar);
@@ -39,7 +41,7 @@ function CreateEventCard (parent:HWND=0):tmApiCard;
implementation
-uses common,io,m_api,mirutils,memini;
+uses common,io,m_api,mirutils,memini,wrapper;
{$r mApiCard.res}
@@ -147,10 +149,54 @@ begin
SendMessage(wnd,CB_SETCURSEL,0,0);
end;
+function tmApiCard.HashToName(ahash:longword):pAnsiChar;
+var
+ p,pp:PAnsiChar;
+begin
+ result:=nil;
+ if storage<>nil then
+ begin
+ p:=GetSectionList(storage,namespace);
+ pp:=p;
+ while p^<>#0 do
+ begin
+ if ahash=Hash(p,StrLen(p)) then
+ begin
+ StrDup(result,p);
+ end;
+ while p^<>#0 do inc(p); inc(p);
+ end;
+ FreeSectionList(pp);
+ end;
+end;
+
+function tmApiCard.NameFromList(cb:HWND):pAnsiChar;
+var
+ buf:array [0..255] of AnsiChar;
+ pc:pAnsiChar;
+ idx:integer;
+begin
+ pc:=GetDlgText(cb,true);
+ idx:=SendMessage(cb,CB_GETCURSEL,0,0);
+ if idx<>CB_ERR then
+ begin
+ SendMessageA(cb,CB_GETLBTEXT,idx,lparam(@buf));
+ // edit field is text from list
+ if StrCmp(pc,@buf)=0 then
+ begin
+ result:=HashToName(CB_GetData(cb,idx));
+ exit;
+ end;
+ end;
+ // no select or changed text
+ result:=pc;
+end;
+
procedure tmApiCard.FillList(combo:hwnd; mode:integer=0);
var
tmpbuf:array [0..127] of AnsiChar;
p,pp,pc:PAnsiChar;
+ idx:integer;
begin
if storage<>nil then
begin
@@ -187,7 +233,8 @@ begin
else // just constant value
pc:=p;
end;
- SendMessageA(combo,CB_ADDSTRING,0,lparam(pc));
+ idx:=SendMessageA(combo,CB_ADDSTRING,0,lparam(pc));
+ SendMessageA(combo,CB_SETITEMDATA,idx,Hash(p,StrLen(p)));
while p^<>#0 do inc(p); inc(p);
end;
FreeSectionList(pp);
@@ -239,7 +286,7 @@ begin
SetDlgItemTextA(Dialog,IDC_HLP_ALIAS,
GetParamSectionStr(current,'alias',''));
-
+
FastAnsiToWideBuf(GetParamSectionStr(current,'return','Undefined'),tmp);
SetDlgItemTextW(Dialog,IDC_HLP_RETURN,TranslateW(tmp));
@@ -367,19 +414,22 @@ begin
if fname<>nil then
begin
ConvertFileName(fname,@INIFile);
+ // CallService(MS_UTILS_PATHTOABSOLUTE,
+ // WPARAM(PAnsiChar(ServiceHlpFile)),LPARAM(INIFile));
if GetFSize(pAnsiChar(@INIFile))=0 then
begin
INIFile[0]:=#0;
end;
parent:=lparent;
end;
- storage:=OpenStorage(@IniFile);
+ storage:=OpenStorage(pAnsiChar(@IniFile));
end;
-destructor tmApiCard.Free;
+destructor tmApiCard.Destroy;
begin
CloseStorage(storage);
-// inherited;
+
+ inherited;
end;
function CreateServiceCard(parent:HWND=0):tmApiCard;
diff --git a/plugins/Utils.pas/memini.pas b/plugins/Utils.pas/memini.pas
index b4f65093bb..d82a84ace9 100644
--- a/plugins/Utils.pas/memini.pas
+++ b/plugins/Utils.pas/memini.pas
@@ -2,10 +2,12 @@ unit memini;
interface
-function OpenStorage(fname:pAnsiChar):pointer;
+function OpenStorage(fname:pWideChar):pointer; overload;
+function OpenStorage(fname:pAnsiChar):pointer; overload;
function OpenStorageBuf(buf:pAnsiChar):pointer;
procedure CloseStorage(storage:pointer);
+//function GetNamespaceList(storage:pointer):pAnsiChar;
function GetSectionList(storage:pointer;namespace:pAnsiChar=nil):pAnsiChar;
procedure FreeSectionList(ptr:pAnsiChar);
@@ -74,9 +76,17 @@ end;
// sections adds 1 by 1, without duplicate check
procedure AddSection(data:pStorage;anamespace,aname:pAnsiChar);
var
+ i:integer;
+ fnhash:integer;
c:AnsiChar;
begin
- // search section with same name?
+ // search section with same name
+ fnhash:=HashOf(anamespace);
+ for i:=0 to data.numsect-1 do
+ begin
+ if data.arSection[i].full=fnhash then
+ exit; // Doing nothing!
+ end;
// add section
if data.numsect>High(data.arSection) then
@@ -87,7 +97,7 @@ begin
begin
fullname:=anamespace;
name :=aname;
- full:=HashOf(anamespace);
+ full :=fnhash;
if anamespace<>aname then
begin
c:=(aname-1)^;
@@ -204,6 +214,7 @@ end;
procedure TranslateData(data:pStorage);
var
pc2,pc1,pc:pAnsiChar;
+ len:integer;
begin
pc:=data^.buffer;
data.numsect:=0;
@@ -227,14 +238,31 @@ begin
//!! without #0 check
pc1:=pc;
pc2:=pc;
- while pc^ in sLatWord do inc(pc);
+//?? while pc^ in sLatWord do inc(pc);
+ {}
+ repeat
+ len:=CharUTF8Len(pc);
+ if (len>1) or (pc^ in sLatWord) then
+ inc(pc,len)
+ else
+ break;
+ until false;
+ {}
// namespace
if pc^=ns_separator then
begin
inc(pc);
pc2:=pc;
end;
- while pc^ <> ']' do inc(pc);
+// while pc^ <> ']' do inc(pc);
+ {}
+ repeat
+ len:=CharUTF8Len(pc);
+ if (len=1) and (pc^ = ']') then
+ break;
+ inc(pc,len);
+ until false;
+ {}
pc^:=#0; //!!
AddSection(data,pc1,pc2);
@@ -258,7 +286,9 @@ begin
pc2:=ProcessParamValue(pc);
AddParam(data,pc1,pc2,false);
- end;
+ end
+ else // wrong thing, skip line
+ while not (pc^ in [#10,#13]) do inc(pc);
end;
end;
@@ -277,34 +307,45 @@ begin
end;
end;
-function OpenStorage(fname:pAnsiChar):pointer;
+function OpenFileStorage(h:THANDLE):pointer;
var
- h:THANDLE;
size:integer;
begin
result:=nil;
- if FileExists(fname) then
+ if h<>THANDLE(INVALID_HANDLE_VALUE) then
begin
- h:=Reset(fname);
- if h<>THANDLE(INVALID_HANDLE_VALUE) then
+ size:=FileSize(h);
+ if size>0 then
begin
- size:=FileSize(h);
- if size>0 then
- begin
- GetMem(result,SizeOf(tStorage));
- FillChar(result^,SizeOf(tStorage),0);
+ GetMem(result,SizeOf(tStorage));
+ FillChar(result^,SizeOf(tStorage),0);
- // save name too?
- GetMem(pStorage(result)^.buffer,size+1);
- BlockRead(h,pStorage(result)^.buffer^,size);
- pStorage(result)^.buffer[size]:=#0;
- end;
- CloseHandle(h);
- TranslateData(pStorage(result));
+ // save name too?
+ GetMem(pStorage(result)^.buffer,size+1);
+ BlockRead(h,pStorage(result)^.buffer^,size);
+ pStorage(result)^.buffer[size]:=#0;
end;
+ CloseHandle(h);
+ TranslateData(pStorage(result));
end;
end;
+function OpenStorage(fname:pWideChar):pointer;
+begin
+ if FileExists(fname) then
+ result:=OpenFileStorage(Reset(fname))
+ else
+ result:=nil;
+end;
+
+function OpenStorage(fname:pAnsiChar):pointer;
+begin
+ if FileExists(fname) then
+ result:=OpenFileStorage(Reset(fname))
+ else
+ result:=nil;
+end;
+
procedure CloseStorage(storage:pointer);
var
i:integer;
@@ -323,10 +364,20 @@ begin
end;
FreeMem(storage);
end;
+{
+function GetNamespaceList(storage:pointer):pAnsiChar;
+begin
+ if storage=nil then
+ begin
+ result:=nil;
+ exit;
+ end;
+end;
+}
function GetSectionList(storage:pointer;namespace:pAnsiChar=nil):pAnsiChar;
var
- i,size,ns:integer;
+ i,lsize,lns:integer;
pc:pAnsiChar;
begin
if storage=nil then
@@ -336,16 +387,30 @@ begin
end;
// calculate size
- size:=0;
- ns:=0;
+ lsize:=0;
if (namespace<>nil) and (namespace^<>#0) then
- ns:=HashOf(namespace);
+ lns:=HashOf(namespace)
+ else
+ lns:=0;
with pStorage(storage)^ do
begin
for i:=0 to HIGH(arSection) do
begin
- if (namespace<>nil) and (namespace^<>#0) then
+ with arSection[i] do
+ begin
+ if (namespace=nil) or
+ ((namespace^=#0) and (name=fullname)) then
+ inc(lsize,StrLen(fullname)+1)
+ else
+ begin
+ if lns<>ns then
+ continue;
+ inc(lsize,StrLen(name)+1);
+ end;
+ end;
+{
+ if (namespace<>nil) and (namespace^<>#0) then //?? ns=0
begin
if ns<>arSection[i].ns then
continue;
@@ -353,15 +418,29 @@ begin
end
else
inc(size,StrLen(arSection[i].fullname)+1);
+}
end;
- inc(size);
+ inc(lsize);
// get memory
- GetMem(pc,size);
+ GetMem(pc,lsize);
result:=pc;
// fill
for i:=0 to HIGH(arSection) do
begin
- if (namespace<>nil) and (namespace^<>#0) then
+ with arSection[i] do
+ begin
+ if (namespace=nil) or
+ ((namespace^=#0) and (name=fullname)) then
+ pc:=StrCopyE(pc,fullname)
+ else
+ begin
+ if lns<>ns then
+ continue;
+ pc:=StrCopyE(pc,name);
+ end;
+ end;
+{
+ if (namespace<>nil) and (namespace^<>#0) then //?? ns=0
begin
if ns<>arSection[i].ns then
continue;
@@ -369,6 +448,7 @@ begin
end
else
pc:=StrCopyE(pc,arSection[i].fullname);
+}
inc(pc);
end;
pc^:=#0;
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas
index ce31833846..1b06920810 100644
--- a/plugins/Utils.pas/mirutils.pas
+++ b/plugins/Utils.pas/mirutils.pas
@@ -5,6 +5,14 @@ interface
uses windows,m_api;
+// for miranda services
+const
+ rtInt = 1;
+ rtWide = 2;
+ rtAnsi = 3;
+ rtUTF8 = 4;
+
+
// icons
function SetButtonIcon(btn:HWND;name:PAnsiChar):HICON;
function RegisterSingleIcon(resname,ilname,descr,group:PAnsiChar):int;
@@ -68,11 +76,14 @@ function LoadImageURL(url:pAnsiChar;size:integer=0):HBITMAP;
implementation
-uses Messages,dbsettings,common,io,freeimage,syswin;
+uses
+ Messages,
+ dbsettings,freeimage,
+ common,io,syswin;
const
clGroup = 'Group';
-// Save / Load contact
+// Save / Load contact
const
opt_cproto = 'cproto';
opt_cuid = 'cuid';
@@ -266,6 +277,9 @@ procedure ShowPopupW(text:pWideChar;title:pWideChar=nil);
var
ppdu:TPOPUPDATAW;
begin
+ if ServiceExists(MS_POPUP_ADDPOPUPW)=0 then
+ exit;
+
FillChar(ppdu,SizeOf(TPOPUPDATAW),0);
if CallService(MS_POPUP_ISSECONDLINESHOWN,0,0)<>0 then
begin
diff --git a/plugins/Utils.pas/protocols.pas b/plugins/Utils.pas/protocols.pas
index a353a5ada5..101c1e4282 100644
--- a/plugins/Utils.pas/protocols.pas
+++ b/plugins/Utils.pas/protocols.pas
@@ -19,11 +19,12 @@ function IsChatSupported (ProtoNum:uint_ptr):bool;
function GetProtoStatus (ProtoNum:uint_ptr):integer;
function GetProtoStatusNum(ProtoNum:uint_ptr):integer;
function GetProtoName (ProtoNum:uint_ptr):PAnsiChar;
+function GetProtoAccName (ProtoNum:uint_ptr):PWideChar;
procedure FillProtoList (list:hwnd;withIcons:bool=false);
procedure CheckProtoList (list:hwnd);
-procedure FillStatusList (proto:cardinal;list:hwnd;withIcons:bool=false);
-procedure CheckStatusList(list:hwnd;ProtoNum:cardinal);
+procedure FillStatusList (proto:uint_ptr;list:hwnd;withIcons:bool=false);
+procedure CheckStatusList(list:hwnd;ProtoNum:uint_ptr);
function CreateProtoList(deepscan:boolean=false):integer;
procedure FreeProtoList;
@@ -205,6 +206,14 @@ begin
result:=nil;
end;
+function GetProtoAccName(ProtoNum:uint_ptr):PWideChar;
+begin
+ if ProtoNum<=NumProto then
+ result:=protos^[ProtoNum].descr
+ else
+ result:=nil;
+end;
+
procedure FillProtoList(list:hwnd;withIcons:bool=false);
var
item:TLVITEMW;
@@ -266,7 +275,7 @@ begin
end;
end;
-procedure FillStatusList(proto:cardinal;list:hwnd;withIcons:bool=false);
+procedure FillStatusList(proto:uint_ptr;list:hwnd;withIcons:bool=false);
procedure AddString(num:integer;enabled:boolean;cli:PCLIST_INTERFACE);
var
@@ -336,7 +345,7 @@ begin
ListView_SetColumnWidth(list,0,LVSCW_AUTOSIZE);
end;
-procedure CheckStatusList(list:hwnd;ProtoNum:cardinal);
+procedure CheckStatusList(list:hwnd;ProtoNum:uint_ptr);
procedure SetStatusMask(stat:integer;state:bool);
var
@@ -571,7 +580,13 @@ begin
wParam:=@i;
lParam:=@j;
end;
- CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,dword(@ics));
+ CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,LPARAM(@ics));
+ end;
+
+ with ics do
+ begin
+ flags:=CSSF_MASK_STATUS;
+ status:=@result;
end;
if title<>nil then
@@ -579,10 +594,9 @@ begin
mGetMem(title^,(i+1)*SizeOf(WideChar));
with ics do
begin
- flags :=CSSF_MASK_NAME or CSSF_UNICODE;
+ flags :=flags or CSSF_MASK_NAME or CSSF_UNICODE;
szName.w:=pWideChar(title^);
end;
- CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,dword(@ics));
end;
if txt<>nil then
@@ -590,18 +604,12 @@ begin
mGetMem(txt^,(j+1)*SizeOf(WideChar));
with ics do
begin
- flags:=CSSF_MASK_MESSAGE or CSSF_UNICODE;
+ flags:=flags or CSSF_MASK_MESSAGE or CSSF_UNICODE;
szMessage.w:=pWideChar(txt^);
end;
- CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,dword(@ics));
end;
- with ics do
- begin
- flags:=CSSF_MASK_STATUS;
- status:=@result;
- end;
- CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,dword(@ics));
+ CallProtoService(proto,PS_GETCUSTOMSTATUSEX,0,LPARAM(@ics));
{
StrCopy(buf,proto);
diff --git a/plugins/Utils.pas/sedit.pas b/plugins/Utils.pas/sedit.pas
index c216cecc09..7f5feeaf52 100644
--- a/plugins/Utils.pas/sedit.pas
+++ b/plugins/Utils.pas/sedit.pas
@@ -25,7 +25,7 @@ const
ACI_DELETE :PAnsiChar = 'ACI_Delete';
const
- API_STRUCT_FILE = 'plugins\services.ini';
+ API_STRUCT_FILE:pAnsiChar = 'plugins\services.ini';
namespace = 'Structure';
{$ENDIF}
@@ -276,7 +276,7 @@ var
p,pc:pAnsiChar;
pw:pWideChar;
begin
- if (element.flags and EF_RETURN)<>0 then
+ if (element.flags and SF_RETURN)<>0 then
ListView_SetCheckState(list,item,true);
li.iItem:=item;
@@ -299,11 +299,11 @@ begin
// flags
{$IFDEF Miranda}
llen:=0;
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
begin
tmp1[llen]:=char_script; inc(llen);
end;
- if (element.flags and EF_MMI)<>0 then
+ if (element.flags and SF_MMI)<>0 then
begin
tmp1[llen]:=char_mmi; inc(llen);
end;
@@ -337,7 +337,7 @@ begin
SST_BYTE,SST_WORD,SST_DWORD,
SST_QWORD,SST_NATIVE: begin
{$IFDEF Miranda}
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
begin
li.iSubItem:=col_data;
UTF8ToWide(element.text,pw);
@@ -382,7 +382,7 @@ begin
li.iSubItem:=col_data;
if (element.etype in [SST_WARR,SST_WPTR])
{$IFDEF Miranda}
- or ((element.flags and EF_SCRIPT)<>0)
+ or ((element.flags and SF_SCRIPT)<>0)
{$ENDIF}
then
begin
@@ -666,11 +666,11 @@ begin
SendMessageW(wnd,LVM_SETITEMSTATE,i,lparam(@li));
{
li.iItem:=i;
- SendMessageW(list,LVM_GETITEMSTATE,i,dword(@li));
+ SendMessageW(list,LVM_GETITEMSTATE,i,lparam(@li));
if (li.state shr 12)>1 then
begin
li.state:=1 shl 12;
- SendMessageW(wnd,LVM_SETITEMSTATE,i,dword(@li));
+ SendMessageW(wnd,LVM_SETITEMSTATE,i,lparam(@li));
end;
}
end;
diff --git a/plugins/Utils.pas/strans.pas b/plugins/Utils.pas/strans.pas
index b70057c33c..b9c9a335f6 100644
--- a/plugins/Utils.pas/strans.pas
+++ b/plugins/Utils.pas/strans.pas
@@ -3,7 +3,7 @@ unit strans;
interface
-uses windows{$IFDEF Miranda}, m_api{$ENDIF};
+uses windows{$IFDEF Miranda}, m_api, mirutils{$ENDIF};
// <align>|[<key>]<type> [(<type alias>)] [<alias>] [arr.len] [value]|
const
char_separator = '|';
@@ -27,10 +27,10 @@ const
SST_PARAM = 10;
SST_UNKNOWN = -1;
const
- EF_RETURN = $00000001;
- EF_SCRIPT = $00000002;
- EF_MMI = $00000004;
- EF_LAST = $00000080;
+ SF_RETURN = $00000001;
+ SF_SCRIPT = $00000002;
+ SF_MMI = $00000004;
+ SF_LAST = $00000080;
type
// int_ptr = to use aligned structure data at start
PStructResult = ^TStructResult;
@@ -71,7 +71,7 @@ const
type
tOneElement = record
etype :integer;
- flags :integer; // EF_MMI,EF_SCRIPT,EF_RETURN
+ flags :integer; // SF_MMI,SF_SCRIPT,SF_RETURN
len :integer; // value length (for arrays and pointers)
align :integer;
alias :array [0..63] of AnsiChar;
@@ -87,12 +87,6 @@ function GetOneElement(txt:pAnsiChar;var res:tOneElement;
SizeOnly:boolean;num:integer=0):integer;
procedure FreeElement(var element:tOneElement);
-{$IFDEF Miranda}
-const
- rtInt = 1;
- rtWide = 2;
-{$ENDIF}
-
function MakeStructure(txt:pAnsiChar;aparam,alast:LPARAM
{$IFDEF Miranda}; restype:integer=rtInt{$ENDIF}):pointer;
@@ -102,7 +96,7 @@ procedure FreeStructure(var struct);
implementation
-uses common{$IFDEF Miranda}, mirutils{$ENDIF};
+uses common;
type
pint_ptr = ^int_ptr;
@@ -182,10 +176,10 @@ begin
while not (txt^ in sWordOnly) do
begin
case txt^ of
- char_return: res.flags:=res.flags or EF_RETURN;
+ char_return: res.flags:=res.flags or SF_RETURN;
{$IFDEF Miranda}
- char_script: res.flags:=res.flags or EF_SCRIPT;
- char_mmi : res.flags:=res.flags or EF_MMI;
+ char_script: res.flags:=res.flags or SF_SCRIPT;
+ char_mmi : res.flags:=res.flags or SF_MMI;
{$ENDIF}
end;
inc(txt);
@@ -261,7 +255,7 @@ begin
SST_BYTE,SST_WORD,SST_DWORD,SST_QWORD,SST_NATIVE: begin
begin
- if (res.flags and EF_SCRIPT)=0 then
+ if (res.flags and SF_SCRIPT)=0 then
begin
pc1:=@res.svalue;
if pc^=char_hex then
@@ -355,7 +349,7 @@ begin
if element.etype in [SST_WARR,SST_WPTR] then
begin
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
datatype:=2 // Wide to Wide (if script done)
else
datatype:=1; // UTF to Wide
@@ -500,7 +494,7 @@ begin
end;
SST_BYTE,SST_WORD,SST_DWORD,
SST_QWORD,SST_NATIVE: begin
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
mFreeMem(element.text);
end;
SST_BARR,SST_WARR,
@@ -562,7 +556,7 @@ begin
GetOneElement(lsrc,element,true);
AdjustSize(summ,element.align,align);
- if ((element.flags and EF_RETURN)<>0) and (code=SST_UNKNOWN) then
+ if ((element.flags and SF_RETURN)<>0) and (code=SST_UNKNOWN) then
begin
code:=element.etype;
alen:=element.len;
@@ -615,7 +609,7 @@ begin
p:=StrScan(pc,char_separator);
GetOneElement(pc,element,false);
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
begin
{$IFDEF Miranda}
if restype=rtInt then
@@ -705,7 +699,7 @@ begin
begin
inc(element.len); // with Zero at the end
{$IFDEF Miranda}
- if (element.flags and EF_MMI)<>0 then
+ if (element.flags and SF_MMI)<>0 then
lsrc:=mir_alloc(element.len*SizeOf(AnsiChar))
else
{$ENDIF}
@@ -719,7 +713,7 @@ begin
if element.len=0 then
begin
{$IFDEF Miranda}
- if (element.flags and EF_SCRIPT)<>0 then
+ if (element.flags and SF_SCRIPT)<>0 then
element.len:=StrLenW(element.text)
else
{$ENDIF}
@@ -732,7 +726,7 @@ begin
begin
inc(element.len); // with Zero at the end
{$IFDEF Miranda}
- if (element.flags and EF_MMI)<>0 then
+ if (element.flags and SF_MMI)<>0 then
lsrc:=mir_alloc(element.len*SizeOf(WideChar))
else
{$ENDIF}
@@ -754,7 +748,7 @@ begin
pc:=p+1;
inc(tmpl);
end;
- tmpl^.flags:=tmpl^.flags or EF_LAST;
+ tmpl^.flags:=tmpl^.flags or SF_LAST;
end;
function GetStructureResult(var struct;atype:pinteger=nil;alen:pinteger=nil):int_ptr;
@@ -812,7 +806,7 @@ begin
//??
value:=pAnsiChar(pint_ptr(pAnsiChar(struct)+tmpl^.offset)^);
{$IFDEF Miranda}
- if (tmpl^.flags and EF_MMI)<>0 then
+ if (tmpl^.flags and SF_MMI)<>0 then
mir_free(value)
else
{$ENDIF}
@@ -820,7 +814,7 @@ begin
end;
end;
inc(tmpl);
- until (tmpl^.flags and EF_LAST)<>0;
+ until (tmpl^.flags and SF_LAST)<>0;
mFreeMem(tmp);
end;
diff --git a/plugins/Utils.pas/wrapper.pas b/plugins/Utils.pas/wrapper.pas
index 91f7b23b0b..fb7b079774 100644
--- a/plugins/Utils.pas/wrapper.pas
+++ b/plugins/Utils.pas/wrapper.pas
@@ -20,11 +20,11 @@ function StringToGUID(const astr:PAnsiChar):TGUID; overload;
function StringToGUID(const astr:PWideChar):TGUID; overload;
// Comboboxes
-function CB_SelectData(cb:HWND;data:dword):lresult; overload;
-function CB_SelectData(Dialog:HWND;id:cardinal;data:dword):lresult; overload;
-function CB_GetData (cb:HWND;idx:integer=-1):lresult;
-function CB_AddStrData (cb:HWND;astr:pAnsiChar;data:integer=0;idx:integer=-1):HWND;
-function CB_AddStrDataW(cb:HWND;astr:pWideChar;data:integer=0;idx:integer=-1):HWND;
+function CB_SelectData(cb:HWND;data:lparam):lresult; overload;
+function CB_SelectData(Dialog:HWND;id:cardinal;data:lparam):lresult; overload;
+function CB_GetData (cb:HWND;idx:integer=-1):lresult; overload;
+function CB_AddStrData (cb:HWND;astr:pAnsiChar;data:lparam=0;idx:integer=-1):HWND;
+function CB_AddStrDataW(cb:HWND;astr:pWideChar;data:lparam=0;idx:integer=-1):HWND;
// CommCtrl - ListView
Procedure ListView_GetItemTextA(hwndLV:hwnd;i:WPARAM;iSubItem:integer;pszText:Pointer;cchTextMax:integer);
@@ -179,14 +179,14 @@ end;
//----- Combobox functions -----
-function CB_SelectData(cb:HWND;data:dword):lresult; overload;
+function CB_SelectData(cb:HWND;data:lparam):lresult; overload;
var
i:integer;
begin
- result:=0;
+ result:=CB_ERR;
for i:=0 to SendMessage(cb,CB_GETCOUNT,0,0)-1 do
begin
- if data=dword(SendMessage(cb,CB_GETITEMDATA,i,0)) then
+ if data=lparam(SendMessage(cb,CB_GETITEMDATA,i,0)) then
begin
result:=i;
break;
@@ -195,7 +195,7 @@ begin
result:=SendMessage(cb,CB_SETCURSEL,result,0);
end;
-function CB_SelectData(Dialog:HWND;id:cardinal;data:dword):lresult; overload;
+function CB_SelectData(Dialog:HWND;id:cardinal;data:lparam):lresult; overload;
begin
result:=CB_SelectData(GetDlgItem(Dialog,id),data);
end;
@@ -210,7 +210,7 @@ begin
result:=SendMessage(cb,CB_GETITEMDATA,idx,0);
end;
-function CB_AddStrData(cb:HWND;astr:pAnsiChar;data:integer=0;idx:integer=-1):HWND;
+function CB_AddStrData(cb:HWND;astr:pAnsiChar;data:lparam=0;idx:integer=-1):HWND;
begin
result:=cb;
if idx<0 then
@@ -220,7 +220,7 @@ begin
SendMessageA(cb,CB_SETITEMDATA,idx,data);
end;
-function CB_AddStrDataW(cb:HWND;astr:pWideChar;data:integer=0;idx:integer=-1):HWND;
+function CB_AddStrDataW(cb:HWND;astr:pWideChar;data:lparam=0;idx:integer=-1):HWND;
begin
result:=cb;
if idx<0 then
diff --git a/plugins/Utils.pas/zwrapper.pas b/plugins/Utils.pas/zwrapper.pas
index bc6be65a43..7ccffafb14 100644
--- a/plugins/Utils.pas/zwrapper.pas
+++ b/plugins/Utils.pas/zwrapper.pas
@@ -6,14 +6,14 @@ function ZDecompressBuf(const inBuffer: Pointer; inSize: Integer; out outBuffer:
implementation
-uses m_api;
+uses zlib;
function ZDecompressBuf(const inBuffer: Pointer; inSize: Integer; out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer): Integer;
var
- zstream : z_stream;
+ zstream : TZStreamRec;
delta : Integer;
begin
- FillChar(zstream, SizeOf(z_stream), 0);
+ FillChar(zstream, SizeOf(TZStreamRec), 0);
delta := (inSize + 255) and not 255;
@@ -38,7 +38,7 @@ begin
Inc(outSize, delta);
ReallocMem(outBuffer, outSize);
- zstream.next_out := PChar(pByte(outBuffer) + zstream.total_out);
+ zstream.next_out := {$IFDEF FPC}PBytef{$ENDIF}(pByte(outBuffer) + zstream.total_out);
zstream.avail_out := delta;
Result := inflate(zstream, Z_NO_FLUSH);
if Result < 0 then Exit;