summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2015-02-26 14:30:30 +0000
committerAlexey Kulakov <panda75@bk.ru>2015-02-26 14:30:30 +0000
commit02f53972b1806473e55b1164a70f5d8ddccc1450 (patch)
tree90dbcc1871169e77f2905d6164073f9b0cca4ff1 /plugins
parent04b7963d0402dc29527f8e2301b47f4a06cbd825 (diff)
Delphi: Service and parameters API reworked
QS: adapted for new service API Actman: updated for new service API git-svn-id: http://svn.miranda-ng.org/main/trunk@12274 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Actman/actman.dpr1
-rw-r--r--plugins/Actman/iac_call.pas133
-rw-r--r--plugins/Actman/iac_global.pas20
-rw-r--r--plugins/Actman/iac_service.pas439
-rw-r--r--plugins/Actman/services.ini7
-rw-r--r--plugins/QuickSearch/i_ok.inc64
-rw-r--r--plugins/QuickSearch/sr_global.pas158
-rw-r--r--plugins/QuickSearch/sr_optdialog.pas30
-rw-r--r--plugins/QuickSearch/sr_window.pas2
-rw-r--r--plugins/Utils.pas/awkservices.pas327
-rw-r--r--plugins/Utils.pas/mirutils.pas9
-rw-r--r--plugins/Utils.pas/sparam.pas611
-rw-r--r--plugins/Utils.pas/srvblock.pas267
-rw-r--r--plugins/Utils.pas/strans.pas105
14 files changed, 1331 insertions, 842 deletions
diff --git a/plugins/Actman/actman.dpr b/plugins/Actman/actman.dpr
index 6e7e2d6f3c..f66f265381 100644
--- a/plugins/Actman/actman.dpr
+++ b/plugins/Actman/actman.dpr
@@ -35,6 +35,7 @@ uses
wrapper,
dbsettings,
mirutils,
+ awkservices,
global,
lowlevelc,
dlgshare,
diff --git a/plugins/Actman/iac_call.pas b/plugins/Actman/iac_call.pas
index f5235e2f2e..0ff306e4b9 100644
--- a/plugins/Actman/iac_call.pas
+++ b/plugins/Actman/iac_call.pas
@@ -6,7 +6,7 @@ implementation
uses
windows, messages, commctrl,
- sparam,
+ awkservices,
common, wrapper, memini,
iac_global, global,
m_api, dbsettings, mirutils;
@@ -26,6 +26,7 @@ const
opt_dllname = 'dllname';
opt_funcname = 'funcname';
opt_argcount = 'argcount';
+ opt_restype = 'restype';
opt_argf = 'argtype';
opt_argn = 'argname';
opt_argv = 'argvalue';
@@ -35,6 +36,7 @@ type
private
dllname:pAnsiChar;
funcname:pAnsiChar;
+ restype:dword;
argcount:integer;
argf:array [0..MaxArgCount-1] of dword;
@@ -86,6 +88,7 @@ constructor tCallAction.Create(uid:dword);
begin
inherited Create(uid);
+ restype:=ACF_TYPE_NUMBER;
argcount:=0;
dllname :=nil;
funcname:=nil;
@@ -110,6 +113,7 @@ function tCallAction.DoAction(var WorkData:tWorkData):LRESULT;
var
hDLL:THANDLE;
pp:pointer;
+ subst:tSubstData;
res:LRESULT;
largv:array [0..MaxArgCount-1] of uint_ptr;
i:integer;
@@ -136,12 +140,21 @@ begin
pp:=GetProcAddress(hDLL,funcname);
if pp<>nil then
begin
- // prepare arguments?
+ subst.Parameter :=WorkData.Parameter;
+ subst.LastResult:=WorkData.LastResult;
+ case WorkData.ResultType of
+ rtInt : subst.ResultType:=ACF_TYPE_NUMBER;
+ rtWide: subst.ResultType:=ACF_TYPE_UNICODE;
+{!!
+ rtAnsi:
+ rtUTF8:
+} end;
+
for i:=0 to argcount-1 do
begin
- largv[i]:=argv[i];
-//!! PreProcess(argf[i],LPARAM(largv[i]),WorkData);
+ largv[i]:=PrepareParameter(argf[i],LPARAM(argv[i]),subst);
end;
+
// call function
case argcount of
0: begin
@@ -198,33 +211,44 @@ begin
else
res:=sp8(pp)(largv[0],largv[1],largv[2],largv[3],largv[4],largv[5],largv[6],largv[7]);
end;
+ else
+ res:=0;
end;
ClearResult(WorkData);
// result type processing
- if (flags and (ACF_RSTRING or ACF_UNICODE))<>0 then
- begin
- if (flags and ACF_RUNICODE)=0 then
- AnsiToWide(pAnsiChar(res),pWideChar(WorkData.LastResult),MirandaCP)
- else
- StrDupW(pWideChar(WorkData.LastResult),pWideChar(res));
- WorkData.ResultType:=rtWide;
+ case restype and ACF_TYPE_MASK of
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
+ WorkData.ResultType:=rtWide;
+ if (restype and ACF_TYPE_MASK)=ACF_TYPE_STRING then
+ AnsiToWide(pAnsiChar(res),pWideChar(WorkData.LastResult),MirandaCP)
+ else
+ StrDupW(pWideChar(WorkData.LastResult),pWideChar(res));
- if (flags and ACF_RFREEMEM)<>0 then
- mFreeMem(pAnsiChar(res)); //?? Miranda MM??
- end
- else if (flags and ACF_RSTRUCT)=0 then
- begin
- WorkData.ResultType:=rtInt
-{!!!!
- end
- else if (flags and ACF_RSTRUCT)<>0 then
- begin
- PostProcess(flags ,lwparam,WorkData);
- PostProcess(flags2,llparam,WorkData);
+ if (restype and ACF_FLAG_FREEMEM)<>0 then
+ mir_free(pointer(res));
+ end;
+
+ ACF_TYPE_NUMBER: begin
+ WorkData.ResultType:=rtInt;
+ WorkData.LastResult:=res;
+ end;
+(*
+ ACF_TYPE_STRUCT: begin
+{
+ PostProcess(flags ,lwparam,WorkData);
+ PostProcess(flags2,llparam,WorkData);
}
+ end;
+*)
end;
+ for i:=0 to argcount-1 do
+ begin
+ ReleaseParameter(argf[i],LPARAM(largv[i]));
+ end;
+
end;
// FreeDllHandle(hDLL);
if loaded then
@@ -235,12 +259,11 @@ end;
procedure LoadParam(section:PAnsiChar;flags:dword; var param:pointer);
begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
- begin
- if (flags and ACF_STRUCT)<>0 then
- param:=DBReadUTF8(0,DBBranch,section,nil)
- else
- param:=DBReadUnicode(0,DBBranch,section,nil);
+ case flags of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: param:=DBReadUnicode(0,DBBranch,section,nil);
+ ACF_TYPE_STRUCT : param:=DBReadUTF8 (0,DBBranch,section,nil);
end;
end;
@@ -249,11 +272,20 @@ var
section: array [0..127] of AnsiChar;
pc,p,pd,ppd:pAnsiChar;
i:integer;
+ old:boolean;
begin
inherited Load(node,fmt);
case fmt of
0: begin
+ // if no restype setting, then ConvertRresultFlags and old:=true;
pc:=StrCopyE(section,pAnsiChar(node));
+
+ StrCopy(pc,opt_restype ); restype :=DBReadDWord (0,DBBranch,section,dword(-1));
+ old:=restype=dword(-1);
+ if old then
+ begin
+ restype:=ConvertResultFlags(flags);
+ end;
StrCopy(pc,opt_dllname ); dllname :=DBReadString(0,DBBranch,section);
StrCopy(pc,opt_funcname); funcname:=DBReadString(0,DBBranch,section);
StrCopy(pc,opt_argcount); argcount:=DBReadByte (0,DBBranch,section);
@@ -262,8 +294,7 @@ begin
pd:=nil;
for i:=0 to argcount-1 do
begin
- IntToStr(StrCopyE(pc,opt_argf),i); argf[i]:=DBReadDWord (0,DBBranch,section);
- IntToStr(StrCopyE(pc,opt_argn),i); p :=DBReadString(0,DBBranch,section);
+ IntToStr(StrCopyE(pc,opt_argn),i); p:=DBReadString(0,DBBranch,section);
if (p=nil) or (p^=#0) then
begin
if pd=nil then
@@ -274,7 +305,18 @@ begin
else
StrCopy(argn[i],p);
mFreeMem(p);
- IntToStr(StrCopyE(pc,opt_argv),i); LoadParam(section,argf[i],pointer(argv[i]));
+
+ if not old then
+ begin
+ LoadParamValue(argf[i],pointer(argv[i]),DBBranch,section);
+ end
+ else
+ begin
+ IntToStr(StrCopyE(pc,opt_argf),i); argf[i]:=DBReadDWord(0,DBBranch,section);
+ argf[i]:=ConvertParamFlags(argf[i]);
+ IntToStr(StrCopyE(pc,opt_argv),i);
+ LoadParam(section,argf[i] and ACF_TYPE_MASK,pointer(argv[i]));
+ end;
end;
end;
end;
@@ -285,20 +327,6 @@ begin
end;
end;
-procedure SaveParam(section:PAnsiChar;flags:dword; param:pointer);
-begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
- begin
- if pointer(param)<>nil then
- begin
- if (flags and ACF_STRUCT)<>0 then
- DBWriteUTF8(0,DBBranch,section,param)
- else
- DBWriteUnicode(0,DBBranch,section,param);
- end;
- end;
-end;
-
procedure tCallAction.Save(node:pointer;fmt:integer);
var
section: array [0..127] of AnsiChar;
@@ -312,13 +340,13 @@ begin
StrCopy(pc,opt_dllname ); DBWriteString(0,DBBranch,section,dllname);
StrCopy(pc,opt_funcname); DBWriteString(0,DBBranch,section,funcname);
StrCopy(pc,opt_argcount); DBWriteByte (0,DBBranch,section,argcount);
+ StrCopy(pc,opt_restype ); DBWriteDWord (0,DBBranch,section,restype);
if argcount>0 then
begin
for i:=0 to argcount-1 do
begin
- IntToStr(StrCopyE(pc,opt_argf),i); DBWriteDWord (0,DBBranch,section,argf[i]);
IntToStr(StrCopyE(pc,opt_argn),i); DBWriteString(0,DBBranch,section,argn[i]);
- IntToStr(StrCopyE(pc,opt_argv),i); SaveParam(section,argf[i],pointer(argv[i]));
+ SaveParamValue(argf[i],pointer(argv[i]),DBBranch,section);
end;
end;
end;
@@ -530,7 +558,7 @@ begin
mFreeMem(pe^.argv[i]);
StrDup(pAnsiChar(pe^.argv[i]),GetParamSectionStr(sect,buf,''));
- pe^.argf[i]:=ACF_TEMPLATE;
+ pe^.argf[i]:=ACF_FLAG_TEMPLATE;
end;
ChangeArgNumber(Dialog,cnt);
FillParam(GetArgumentWindow(Dialog),pointer(pe^.argv[0]));
@@ -666,7 +694,8 @@ begin
pt.x:=rc.left;
pt.y:=rc.bottom;
ScreenToClient(Dialog,pt);
- wnd1:=CreateResultBlock(Dialog,0,pt.y+2,rc.right-rc.left,ACF_NOVISUAL);
+ wnd1:=CreateResultBlock(Dialog,0,pt.y+2,rc.right-rc.left,
+ ACF_BLOCK_NOVISUAL or ACF_BLOCK_NOSTRUCT);
SetWindowLongPtrW(wnd,GWLP_USERDATA,wnd1);
ShowWindow(wnd1,SW_HIDE);
@@ -753,7 +782,7 @@ begin
SendMessage(wnd1,CB_SETCURSEL,0,0);
SetParamValue (GetArgumentWindow(Dialog),argf[0],pointer(argv[0]));
- SetResultValue(GetResultWindow (Dialog),flags);
+ SetResultValue(GetResultWindow (Dialog),restype);
end;
end;
@@ -802,7 +831,7 @@ begin
end;
end;
- flags:=flags or GetResultValue(GetResultWindow(Dialog));
+ restype:=GetResultValue(GetResultWindow(Dialog));
if IsDlgButtonChecked(Dialog,IDC_CDECL)<>BST_UNCHECKED then
flags:=flags or ACF_CDECL;
{!!
diff --git a/plugins/Actman/iac_global.pas b/plugins/Actman/iac_global.pas
index 03425c6027..df4f14bd05 100644
--- a/plugins/Actman/iac_global.pas
+++ b/plugins/Actman/iac_global.pas
@@ -6,6 +6,14 @@ uses
windows, messages,
m_api;
+
+const
+ rtUnkn = 0;
+ rtInt = 1;
+ rtWide = 2;
+ rtAnsi = 3;
+ rtUTF8 = 4;
+
var
xmlparser:TXML_API_W;
@@ -268,18 +276,6 @@ begin
else if rt^<>rtUnkn then
begin
result:=NumToInt(pWideChar(lr^));
-{
- if (pWideChar(WorkData.LastResult)[0]='$') and
- (AnsiChar(pWideChar(WorkData.LastResult)[1]) in sHexNum) then
- result:=HexToInt(pWideChar(WorkData.LastResult)+1)
- else
- if (pWideChar(WorkData.LastResult)[0]='0') and
- (pWideChar(WorkData.LastResult)[1]='x') and
- (AnsiChar(pWideChar(WorkData.LastResult)[2]) in sHexNum) then
- result:=HexToInt(pWideChar(WorkData.LastResult)+2)
- else
- result:=StrToInt(pWideChar(WorkData.LastResult));
-}
end;
end;
diff --git a/plugins/Actman/iac_service.pas b/plugins/Actman/iac_service.pas
index 205bc67a6f..f9b2b6ba15 100644
--- a/plugins/Actman/iac_service.pas
+++ b/plugins/Actman/iac_service.pas
@@ -10,35 +10,15 @@ uses
m_api,
sedit,strans,mApiCardM,
mirutils,mircontacts,dbsettings, editwrapper,
- sparam,srvblock,
+ awkservices,
syswin,wrapper,common;
{$resource iac_service.res}
const
- ACF_PARNUM = $00000001; // Param is number
- ACF_UNICODE = $00000002; // Param is Unicode string
- ACF_CURRENT = $00000004; // Param is ignored, used current user handle
- // from current message window
- ACF_RESULT = $00000008; // Param is previous action result
- ACF_PARAM = $00000010; // Param is Call parameter
- ACF_STRUCT = $00000020;
- ACF_PARTYPE = ACF_PARNUM or ACF_UNICODE or
- ACF_CURRENT or ACF_RESULT or
- ACF_PARAM or ACF_STRUCT;
-
- ACF_RSTRING = $00010000; // Service result is string
- ACF_RUNICODE = $00020000; // Service result is Widestring
- ACF_RSTRUCT = $00040000; // Service result in structure
- ACF_RFREEMEM = $00080000; // Need to free memory
-{
- ACF_SCRIPT_PARAM set in "sparam" unit
- ACF_SCRIPT_SERVICE set in "srvblock" unit
-}
- // dummy
- ACF_STRING = 0;
-
-const // V2
+// V3
+ ACF_SCRIPT_SERVICE = $00800000;
+// V2
ACF2_SRV_WPAR = $00000001;
ACF2_SRV_LPAR = $00000002;
ACF2_SRV_SRVC = $00000004;
@@ -89,10 +69,7 @@ const
type
tServiceAction = class(tBaseAction)
private
- service:PAnsiChar;
- wparam :pWideChar;
- lparam :pWideChar;
- flags2 :dword;
+ service:tServiceValue;
public
constructor Create(uid:dword);
destructor Destroy; override;
@@ -111,17 +88,9 @@ begin
inherited Create(uid);
end;
-procedure ClearParam(flags:dword; var param);
-begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
- mFreeMem(pointer(param));
-end;
-
destructor tServiceAction.Destroy;
begin
- mFreeMem(service);
- ClearParam(flags ,wparam);
- ClearParam(flags2,lparam);
+ ClearServiceValue(service);
inherited Destroy;
end;
@@ -134,192 +103,67 @@ begin
tServiceAction(result).flags2 :=flags2;
StrDup(tServiceAction(result).service,service);
- if (flags and (ACF_PARNUM or ACF_RESULT or ACF_PARAM))=0 then
+ if (flags and (ACF_NUMBER or ACF_RESULT or ACF_PARAM))=0 then
StrDup(pAnsiChar(tServiceAction(result).wparam),pAnsiChar(wparam))
- else if ((flags and ACF_PARNUM)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then
+ else if ((flags and ACF_NUMBER)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then
StrDup(pAnsiChar(tServiceAction(result).wparam),pAnsiChar(wparam))
else
tServiceAction(result).wparam:=wparam;
- if (flags2 and (ACF_PARNUM or ACF_RESULT or ACF_PARAM))=0 then
+ if (flags2 and (ACF_NUMBER or ACF_RESULT or ACF_PARAM))=0 then
StrDup(pAnsiChar(tServiceAction(result).lparam),pAnsiChar(lparam))
- else if ((flags2 and ACF_PARNUM)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then
+ else if ((flags2 and ACF_NUMBER)<>0) and ((flags and ACF_SCRIPT_PARAM)<>0) then
StrDup(pAnsiChar(tServiceAction(result).lparam),pAnsiChar(lparam))
else
tServiceAction(result).lparam:=lparam;
end;
}
-procedure PreProcess(flags:dword;var l_param:LPARAM;const WorkData:tWorkData);
-var
- tmp1:pWideChar;
-begin
- with WorkData do
- begin
- if (flags and ACF_STRUCT)<>0 then
- begin
- l_param:=uint_ptr(MakeStructure(pAnsiChar(l_param),Parameter,LastResult,ResultType))
- end
- else if (flags and ACF_PARAM)<>0 then
- begin
- l_param:=Parameter;
- end
- else if (flags and ACF_RESULT)<>0 then
- begin
- l_param:=LastResult;
- end
- else if (flags and ACF_CURRENT)<>0 then
- begin
- l_param:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus});
- end
- else
- begin
- if (flags and ACF_SCRIPT_PARAM)<>0 then
- l_param:=uint_ptr(ParseVarString(pWideChar(l_param),Parameter));
-
- tmp1:=pWideChar(l_param);
- if (flags and ACF_PARNUM)=0 then
- begin
- if (flags and ACF_UNICODE)=0 then
- WideToAnsi(tmp1,pAnsiChar(l_param),MirandaCP)
- else
- StrDupW(pWideChar(l_param),tmp1);
- end
- else
- l_param:=NumToInt(tmp1);
-
- if (flags and ACF_SCRIPT_PARAM)<>0 then
- mFreeMem(tmp1);
- end;
- end;
-end;
-
-procedure PostProcess(flags:dword;var l_param:LPARAM; var WorkData:tWorkData);
-var
- code:integer;
- len:integer;
- pc:pAnsiChar;
-begin
- if (flags and ACF_STRUCT)<>0 then
- begin
- with WorkData do
- begin
- LastResult:=GetStructureResult(l_param,@code,@len);
- case code of
-{
- SST_LAST: begin
- result:=LastResult;
- end;
-}
- SST_PARAM: begin //??
- LastResult:=Parameter;
- ResultType:=rtInt;
- end;
- SST_BYTE,SST_WORD,SST_DWORD,
- SST_QWORD,SST_NATIVE: begin
- ResultType:=rtInt;
- end;
- SST_BARR: begin
- StrDup(pAnsiChar(pc),pAnsiChar(LastResult),len);
- AnsiToWide(pAnsiChar(pc),PWideChar(LastResult),MirandaCP);
- mFreeMem(pAnsiChar(pc));
- ResultType:=rtWide;
- end;
- SST_WARR: begin
- StrDupW(pWideChar(LastResult),pWideChar(LastResult),len);
- ResultType:=rtWide;
- end;
- SST_BPTR: begin
- AnsiToWide(pAnsiChar(LastResult),pWideChar(LastResult),MirandaCP);
- ResultType:=rtWide;
- end;
- SST_WPTR: begin
- StrDupW(pWideChar(LastResult),pWideChar(LastResult));
- ResultType:=rtWide;
- end;
- end;
- FreeStructure(l_param);
- l_param:=0;
- end
- end;
-end;
function tServiceAction.DoAction(var WorkData:tWorkData):LRESULT;
var
- buf:array [0..255] of AnsiChar;
- lservice:pAnsiChar;
- lwparam,llparam:TLPARAM;
- res:int_ptr;
+ subst:tSubstData;
begin
result:=0;
- lservice:=service;
- lwparam :=TLPARAM(wparam);
- llparam :=TLPARAM(lparam);
- // Service name processing
- if (flags and ACF_SCRIPT_SERVICE)<>0 then
- lservice:=ParseVarString(lservice,WorkData.Parameter);
-
- StrCopy(buf,lservice);
- if StrPos(lservice,protostr)<>nil then
- if CallService(MS_DB_CONTACT_IS,WorkData.Parameter,0)=0 then
- begin
- if (flags and ACF_SCRIPT_SERVICE)<>0 then
- mFreeMem(lservice);
- exit;
- end
- else
- StrReplace(buf,protostr,GetContactProtoAcc(WorkData.Parameter));
+ subst.Parameter :=WorkData.Parameter;
+ subst.LastResult:=WorkData.LastResult;
+ case WorkData.ResultType of
+ rtInt : subst.ResultType:=ACF_TYPE_NUMBER;
+ rtWide: subst.ResultType:=ACF_TYPE_UNICODE;
+{!!
+ rtAnsi:
+ rtUTF8:
+}
+ end;
- if ServiceExists(buf)<>0 then
+ if ExecuteService(service,subst) then
begin
-
- PreProcess(flags ,lwparam,WorkData);
- PreProcess(flags2,llparam,WorkData);
-
- res:=CallServiceSync(buf,lwparam,llparam);
ClearResult(WorkData);
- // result type processing
- if (flags and (ACF_RSTRING or ACF_UNICODE))<>0 then
- begin
-//!! delete old or not?
- if (flags and ACF_RUNICODE)=0 then
- AnsiToWide(pAnsiChar(res),pWideChar(WorkData.LastResult),MirandaCP)
- else
- StrDupW(pWideChar(WorkData.LastResult),pWideChar(res));
- WorkData.ResultType:=rtWide;
+ // result type processing
+ case subst.ResultType of
+ ACF_TYPE_UNICODE: begin
+ WorkData.ResultType:=rtWide;
+ StrDupW(pWideChar(WorkData.LastResult),pWideChar(subst.LastResult));
+ end;
- if (flags and ACF_RFREEMEM)<>0 then
- mFreeMem(pAnsiChar(res)); //?? Miranda MM??
- end
- else if (flags and ACF_RSTRUCT)=0 then
- WorkData.ResultType:=rtInt
- else if (flags and ACF_RSTRUCT)<>0 then
- begin
- PostProcess(flags ,lwparam,WorkData);
- PostProcess(flags2,llparam,WorkData);
+ ACF_TYPE_NUMBER: begin
+ WorkData.ResultType:=rtInt;
+ WorkData.LastResult:=subst.LastResult;
+ end;
end;
- // free string (ansi+unicode) parameters
- if ((flags and ACF_PARTYPE)=ACF_STRING) or
- ((flags and ACF_PARTYPE)=ACF_UNICODE) then
- mFreeMem(pointer(lwparam));
- if ((flags2 and ACF_PARTYPE)=ACF_STRING) or
- ((flags2 and ACF_PARTYPE)=ACF_UNICODE) then
- mFreeMem(pointer(llparam));
+ ClearSubstData(subst);
end;
- if (flags and ACF_SCRIPT_SERVICE)<>0 then
- mFreeMem(lservice);
end;
procedure LoadParam(section:PAnsiChar;flags:dword; var param:pointer);
begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
- begin
- if (flags and ACF_STRUCT)<>0 then
- param:=DBReadUTF8(0,DBBranch,section,nil)
- else
- param:=DBReadUnicode(0,DBBranch,section,nil);
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: param:=DBReadUnicode(0,DBBranch,section,nil);
+ ACF_TYPE_STRUCT : param:=DBReadUTF8 (0,DBBranch,section,nil);
end;
end;
@@ -327,27 +171,27 @@ function ReadParam(act:HXML; var param:pWideChar;isvar:boolean):dword;
var
tmp:pWideChar;
begin
- result:=0;
+ result:=ACF_TYPE_NUMBER;
if act=0 then
exit;
with xmlparser do
begin
tmp:=getAttrValue(act,ioType);
- if lstrcmpiw(tmp,ioCurrent)=0 then result:=result or ACF_CURRENT
- else if lstrcmpiw(tmp,ioResult )=0 then result:=result or ACF_RESULT
- else if lstrcmpiw(tmp,ioParam )=0 then result:=result or ACF_PARAM
+ if lstrcmpiw(tmp,ioCurrent)=0 then result:=ACF_TYPE_CURRENT
+ else if lstrcmpiw(tmp,ioResult )=0 then result:=ACF_TYPE_RESULT
+ else if lstrcmpiw(tmp,ioParam )=0 then result:=ACF_TYPE_PARAM
else if lstrcmpiw(tmp,ioStruct )=0 then
begin
- result:=result or ACF_STRUCT;
+ result:=ACF_TYPE_STRUCT;
//!!!! param:=ReadStruct(act);
end
else
begin
StrDupW(pWideChar(param),getAttrValue(act,ioValue));
- if lstrcmpiw(tmp,ioNumber )=0 then result:=result or ACF_PARNUM
- else if lstrcmpiw(tmp,ioUnicode)=0 then result:=result or ACF_UNICODE;
-// else if lstrcmpiw(tmp,ioAnsi)=0 then;
+ if lstrcmpiw(tmp,ioNumber )=0 then result:=ACF_TYPE_NUMBER
+ else if lstrcmpiw(tmp,ioUnicode)=0 then result:=ACF_TYPE_UNICODE
+ else if lstrcmpiw(tmp,ioAnsi )=0 then result:=ACF_TYPE_STRING;
end;
end;
end;
@@ -372,7 +216,7 @@ begin
begin
UTF8ToWide(GetParamSectionInt(node,StrCopy(pc1,ioValue)),param);
- if lstrcmpi(pc,ioNumber )=0 then result:=result or ACF_PARNUM
+ if lstrcmpi(pc,ioNumber )=0 then result:=result or ACF_NUMBER
else if lstrcmpi(pc,ioUnicode)=0 then result:=result or ACF_UNICODE;
// else if lstrcmpi(pc,ioAnsi)=0 then;
end;
@@ -393,18 +237,31 @@ begin
0: begin
pc:=StrCopyE(section,pAnsiChar(node));
- StrCopy(pc,opt_service); service:=DBReadString(0,DBBranch,section,nil);
- StrCopy(pc,opt_flags2 ); flags2 :=DBReadDword (0,DBBranch,section);
-
- StrCopy(pc,opt_wparam); LoadParam(section,flags ,pointer(wparam));
- StrCopy(pc,opt_lparam); LoadParam(section,flags2,pointer(lparam));
+ StrCopy(pc,opt_flags2 ); service.l_flags:=DBReadDword(0,DBBranch,section,dword(-1));
+ StrCopy(pc,opt_service);
+ if service.l_flags=dword(-1) then
+ begin
+ LoadServiceValue(service,DBBranch,section);
+ end
+ else
+ begin
+ service.service:=DBReadString(0,DBBranch,section,nil);
+ service.flags :=ConvertResultFlags(flags);
+ service.w_flags:=ConvertParamFlags (flags);
+ service.l_flags:=ConvertParamFlags (service.l_flags);
+ if (flags and ACF_SCRIPT_SERVICE)<>0 then
+ service.flags:=service.flags or ACF_FLAG_SCRIPT;
+
+ StrCopy(pc,opt_wparam); LoadParam(section,service.w_flags,pointer(service.wparam));
+ StrCopy(pc,opt_lparam); LoadParam(section,service.l_flags,pointer(service.lparam));
+ end;
end;
100: begin
pc:=StrCopyE(section,pAnsiChar(node));
- StrCopy(pc,opt_service); service:=DBReadString(0,DBBranch,section,nil);
- StrCopy(pc,opt_flags2 ); flags2 :=DBReadDword (0,DBBranch,section);
+ StrCopy(pc,opt_service); service.service:=DBReadString(0,DBBranch,section,nil);
+ StrCopy(pc,opt_flags2 ); service.l_flags:=DBReadDword (0,DBBranch,section);
if (flags and (ACF_OLD_WCURRENT or ACF_OLD_WRESULT or ACF_OLD_WPARAM))=0 then
@@ -412,11 +269,11 @@ begin
StrCopy(pc,opt_wparam);
if (flags and ACF_OLD_WSTRUCT)<>0 then
- wparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil))
- else if ((flags and ACF_OLD_WPARNUM)=0) or ((flags2 and ACF2_SRV_WPAR)<>0) then
- wparam:=DBReadUnicode(0,DBBranch,section,nil)
+ service.wparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil))
+ else if ((flags and ACF_OLD_WPARNUM)=0) or ((service.l_flags and ACF2_SRV_WPAR)<>0) then
+ service.wparam:=DBReadUnicode(0,DBBranch,section,nil)
else
- StrDupW(wparam,IntToStr(buf,DBReadDWord(0,DBBranch,section)));
+ StrDupW(PWideChar(service.wparam),IntToStr(buf,DBReadDWord(0,DBBranch,section)));
end;
if (flags and (ACF_OLD_LCURRENT or ACF_OLD_LRESULT or ACF_OLD_LPARAM))=0 then
@@ -424,69 +281,82 @@ begin
StrCopy(pc,opt_lparam);
if (flags and ACF_OLD_LSTRUCT)<>0 then
- lparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil))
- else if ((flags and ACF_OLD_LPARNUM)=0) or ((flags2 and ACF2_SRV_LPAR)<>0) then
- lparam:=DBReadUnicode(0,DBBranch,section,nil)
+ service.lparam:=PWideChar(DBReadUTF8(0,DBBranch,section,nil))
+ else if ((flags and ACF_OLD_LPARNUM)=0) or ((service.l_flags and ACF2_SRV_LPAR)<>0) then
+ service.lparam:=DBReadUnicode(0,DBBranch,section,nil)
else
- StrDupW(lparam,IntToStr(buf,DBReadDWord(0,DBBranch,section)));
+ StrDupW(PWideChar(service.lparam),IntToStr(buf,DBReadDWord(0,DBBranch,section)));
end;
lflags :=flags;
- lflags2:=flags2;
+ lflags2:=service.l_flags;
flags :=flags and not ACF_MASK;
- flags2:=0;
-
- if (lflags2 and ACF2_SRV_SRVC)<>0 then flags:=flags or ACF_SCRIPT_SERVICE;
-
- if (lflags and ACF_OLD_WPARNUM )<>0 then flags:=flags or ACF_PARNUM;
- if (lflags and ACF_OLD_WUNICODE)<>0 then flags:=flags or ACF_UNICODE;
- if (lflags and ACF_OLD_WCURRENT)<>0 then flags:=flags or ACF_CURRENT;
- if (lflags and ACF_OLD_WRESULT )<>0 then flags:=flags or ACF_RESULT;
- if (lflags and ACF_OLD_WPARAM )<>0 then flags:=flags or ACF_PARAM;
- if (lflags and ACF_OLD_WSTRUCT )<>0 then flags:=flags or ACF_STRUCT;
- if (lflags2 and ACF2_SRV_WPAR )<>0 then flags:=flags or ACF_SCRIPT_PARAM;
-
- if (lflags and ACF_OLD_LPARNUM )<>0 then flags2:=flags2 or ACF_PARNUM;
- if (lflags and ACF_OLD_LUNICODE)<>0 then flags2:=flags2 or ACF_UNICODE;
- if (lflags and ACF_OLD_LCURRENT)<>0 then flags2:=flags2 or ACF_CURRENT;
- if (lflags and ACF_OLD_LRESULT )<>0 then flags2:=flags2 or ACF_RESULT;
- if (lflags and ACF_OLD_LPARAM )<>0 then flags2:=flags2 or ACF_PARAM;
- if (lflags and ACF_OLD_LSTRUCT )<>0 then flags2:=flags2 or ACF_STRUCT;
- if (lflags2 and ACF2_SRV_LPAR )<>0 then flags2:=flags2 or ACF_SCRIPT_PARAM;
-
- if (lflags and ACF_OLD_STRING )<>0 then flags:=flags or ACF_RSTRING;
- if (lflags and ACF_OLD_UNICODE)<>0 then flags:=flags or ACF_RUNICODE;
- if (lflags and ACF_OLD_STRUCT )<>0 then flags:=flags or ACF_RSTRUCT;
- if (lflags2 and ACF2_FREEMEM )<>0 then flags:=flags or ACF_RFREEMEM;
+ service.flags :=0;
+ service.w_flags:=0;
+ service.l_flags:=0;
+
+ if (lflags and ACF_OLD_WPARNUM )<>0 then service.w_flags:=ACF_TYPE_NUMBER
+ else if (lflags and ACF_OLD_WUNICODE)<>0 then service.w_flags:=ACF_TYPE_UNICODE
+ else if (lflags and ACF_OLD_WCURRENT)<>0 then service.w_flags:=ACF_TYPE_CURRENT
+ else if (lflags and ACF_OLD_WRESULT )<>0 then service.w_flags:=ACF_TYPE_RESULT
+ else if (lflags and ACF_OLD_WPARAM )<>0 then service.w_flags:=ACF_TYPE_PARAM
+ else if (lflags and ACF_OLD_WSTRUCT )<>0 then service.w_flags:=ACF_TYPE_STRUCT
+ else service.w_flags:=ACF_TYPE_STRING;
+ if (lflags2 and ACF2_SRV_WPAR)<>0 then
+ service.w_flags:=service.w_flags or ACF_FLAG_SCRIPT;
+
+ if (lflags and ACF_OLD_LPARNUM )<>0 then service.l_flags:=ACF_TYPE_NUMBER
+ else if (lflags and ACF_OLD_LUNICODE)<>0 then service.l_flags:=ACF_TYPE_UNICODE
+ else if (lflags and ACF_OLD_LCURRENT)<>0 then service.l_flags:=ACF_TYPE_CURRENT
+ else if (lflags and ACF_OLD_LRESULT )<>0 then service.l_flags:=ACF_TYPE_RESULT
+ else if (lflags and ACF_OLD_LPARAM )<>0 then service.l_flags:=ACF_TYPE_PARAM
+ else if (lflags and ACF_OLD_LSTRUCT )<>0 then service.l_flags:=ACF_TYPE_STRUCT
+ else service.l_flags:=ACF_TYPE_STRING;
+ if (lflags2 and ACF2_SRV_LPAR)<>0 then
+ service.l_flags:=service.l_flags or ACF_FLAG_SCRIPT;
+
+ if (lflags and ACF_OLD_STRING )<>0 then service.flags:=ACF_TYPE_STRING
+ else if (lflags and ACF_OLD_UNICODE)<>0 then service.flags:=ACF_TYPE_UNICODE
+ else if (lflags and ACF_OLD_STRUCT )<>0 then service.flags:=ACF_TYPE_STRUCT
+ else service.flags:=ACF_TYPE_NUMBER;
+ if (lflags2 and ACF2_FREEMEM )<>0 then service.flags:=service.flags or ACF_FLAG_FREEMEM;
+ if (lflags2 and ACF2_SRV_SRVC)<>0 then service.flags:=service.flags or ACF_FLAG_SCRIPT;
end;
1: begin
+ service.flags :=0;
+ service.w_flags:=0;
+ service.l_flags:=0;
+
with xmlparser do
begin
- FastWideToAnsi(getAttrValue(HXML(node),ioService),service);
+ FastWideToAnsi(getAttrValue(HXML(node),ioService),service.service);
//!!!! StrDupW(service,getAttrValue(HXML(node),ioService));
if StrToInt(getAttrValue(HXML(node),ioVariables))=1 then
- flags:=flags or ACF_SCRIPT_SERVICE;
+ service.flags:=service.flags or ACF_FLAG_SCRIPT;
sub:=getNthChild(HXML(node),ioWParam,0);
if StrToInt(getAttrValue(sub,ioVariables))=1 then
- flags:=flags or ACF_SCRIPT_PARAM;
- flags:=flags or ReadParam(sub,wparam,(flags and ACF_SCRIPT_PARAM)<>0);
+ service.w_flags:=service.w_flags or ACF_FLAG_SCRIPT;
+ service.w_flags:=service.w_flags or
+ ReadParam(sub,PWideChar(service.wparam),(service.w_flags and ACF_FLAG_SCRIPT)<>0);
sub:=getNthChild(HXML(node),ioLParam,0);
if StrToInt(getAttrValue(sub,ioVariables))=1 then
- flags2:=flags2 or ACF_SCRIPT_PARAM;
- flags2:=flags2 or ReadParam(sub,lparam,(flags2 and ACF_SCRIPT_PARAM)<>0);
+ service.l_flags:=service.l_flags or ACF_FLAG_SCRIPT;
+ service.l_flags:=service.l_flags or
+ ReadParam(sub,PWideChar(service.lparam),(service.l_flags and ACF_FLAG_SCRIPT)<>0);
sub:=getNthChild(HXML(node),ioOutput,0);
- if StrToInt(getAttrValue(sub,ioFree))=1 then flags:=flags or ACF_RFREEMEM;
+ if StrToInt(getAttrValue(sub,ioFree))=1 then
+ service.flags:=service.flags or ACF_FLAG_FREEMEM;
tmp:=getAttrValue(sub,ioType);
- if lstrcmpiw(tmp,ioUnicode)=0 then flags:=flags or ACF_RUNICODE
- else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_RSTRING
- else if lstrcmpiw(tmp,ioStruct )=0 then flags:=flags or ACF_RSTRUCT
- else if lstrcmpiw(tmp,ioInt )=0 then ;
+ if lstrcmpiw(tmp,ioUnicode)=0 then service.flags:=service.flags or ACF_TYPE_UNICODE
+ else if lstrcmpiw(tmp,ioAnsi )=0 then service.flags:=service.flags or ACF_TYPE_STRING
+ else if lstrcmpiw(tmp,ioStruct )=0 then service.flags:=service.flags or ACF_TYPE_STRUCT
+ else if lstrcmpiw(tmp,ioInt )=0 then service.flags:=service.flags or ACF_TYPE_NUMBER;
end;
end;
{
@@ -516,20 +386,6 @@ begin
end;
end;
-procedure SaveParam(section:PAnsiChar;flags:dword; param:pointer);
-begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
- begin
- if pointer(param)<>nil then
- begin
- if (flags and ACF_STRUCT)<>0 then
- DBWriteUTF8(0,DBBranch,section,param)
- else
- DBWriteUnicode(0,DBBranch,section,param);
- end;
- end;
-end;
-
procedure tServiceAction.Save(node:pointer;fmt:integer);
var
section: array [0..127] of AnsiChar;
@@ -541,11 +397,8 @@ begin
0: begin
pc:=StrCopyE(section,pAnsiChar(node));
- StrCopy(pc,opt_service); DBWriteString(0,DBBranch,section,service);
- StrCopy(pc,opt_flags2 ); DBWriteDWord (0,DBBranch,section,flags2);
-
- StrCopy(pc,opt_wparam); SaveParam(section,flags ,pointer(wparam));
- StrCopy(pc,opt_lparam); SaveParam(section,flags2,pointer(lparam));
+ StrCopy(pc,opt_service);
+ SaveServiceValue(service,DBBranch,section);
end;
{
1: begin
@@ -557,12 +410,18 @@ begin
end;
//----- Dialog realization -----
+{
+function EnableThemeDialogTexture(hwnd: HWND; dwFlags: DWORD): HRESULT; stdcall;
+external 'uxtheme.dll' name 'EnableThemeDialogTexture';
+function IsThemeDialogTextureEnabled(hwnd: HWND): BOOL; stdcall;
+external 'uxtheme.dll' name 'IsThemeDialogTextureEnabled';
+}
function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
var
ServiceBlock:HWND;
rc:TRECT;
- sv:tServiceValue;
+ b:bool;
begin
result:=0;
@@ -572,25 +431,25 @@ begin
WM_INITDIALOG: begin
GetClientRect(Dialog,rc);
- ServiceBlock:=CreateServiceBlock(Dialog,0,0,rc.right,rc.bottom,ACF_NOVISUAL or ACF_SCRIPT_EXPAND);
+ ServiceBlock:=CreateServiceBlock(Dialog,0,0,rc.right,rc.bottom,
+ ACF_BLOCK_NOVISUAL or ACF_BLOCK_EXPAND);
SetWindowLongPtrW(Dialog,GWLP_USERDATA,ServiceBlock);
SetServiceListMode(ServiceBlock,DBReadByte(0,DBBranch,'SrvListMode'));
-
+{
+ b:=IsThemeDialogTextureEnabled(Dialog);
+ if b then
+ begin
+ b:=IsThemeDialogTextureEnabled(ServiceBlock);
+ if not b then
+ EnableThemeDialogTexture(ServiceBlock,2);
+ end;
+}
TranslateDialogDefault(Dialog);
end;
WM_ACT_SETVALUE: begin
ServiceBlock:=GetWindowLongPtrW(Dialog,GWLP_USERDATA);
- with tServiceAction(lParam) do
- begin
- sv.service:=service;
- sv.w_flag :=flags;
- sv.wparam :=wparam;
- sv.l_flag :=flags2;
- sv.lparam :=lparam;
- sv.flags :=flags;
- end;
- SetSrvBlockValue(ServiceBlock,sv);
+ SetSrvBlockValue(ServiceBlock,tServiceAction(lParam).service);
end;
WM_ACT_RESET: begin
@@ -601,13 +460,7 @@ begin
with tServiceAction(lParam) do
begin
ServiceBlock:=GetWindowLongPtrW(Dialog,GWLP_USERDATA);
- GetSrvBlockValue(ServiceBlock,sv);
-
- service:=sv.service;
- wparam :=sv.wparam;
- lparam :=sv.lparam;
- flags2 :=sv.l_flag;
- flags :=sv.flags or sv.w_flag;
+ GetSrvBlockValue(ServiceBlock,tServiceAction(lParam).service);
end;
end;
diff --git a/plugins/Actman/services.ini b/plugins/Actman/services.ini
index 4b651f1fdd..09f7f097a5 100644
--- a/plugins/Actman/services.ini
+++ b/plugins/Actman/services.ini
@@ -52,6 +52,13 @@ lparam=0
return=int 0, if successful
descr=Show All Titlebars
+[Service:CList/GetContactDisplayName]
+alias=MS_CLIST_GETCONTACTDISPLAYNAME
+wparam=hContact
+lparam=1 will never return the user's custom name|2 will return Unicode instead of AnsiChar|4 will not use the cache
+return=str
+descr=Gets the string that the contact list will use to represent a contact
+
[Service:CList/MenuBuildContact]
alias=MS_CLIST_MENUBUILDCONTACT
wparam=hContact
diff --git a/plugins/QuickSearch/i_ok.inc b/plugins/QuickSearch/i_ok.inc
index a5bdf7c715..81f132e0ac 100644
--- a/plugins/QuickSearch/i_ok.inc
+++ b/plugins/QuickSearch/i_ok.inc
@@ -260,13 +260,11 @@ end;
procedure LoadOneItem(hContact:THANDLE;column:pcolumnitem;proto:integer; var res:tQSRec);
var
- tmp:int_ptr;
- lmodule,srv:PAnsiChar;
- lwparam,llparam:TLPARAM;
+ lmodule:PAnsiChar;
DbEvent:TMEVENT;
cni:TCONTACTINFO;
dbei:TDBEVENTINFO;
- b:bool;
+ data:tSubstData;
begin
res.data:=uint_ptr(-1);
mFreeMem(res.text);
@@ -279,44 +277,30 @@ begin
end;
QST_SERVICE: begin
- case wparam._type of
- ACF_CURRENT: lwparam:=hContact;
- ACF_NUMBER : lwparam:=NumToInt(wparam.value);
- else
- lwparam:=TLPARAM(wparam.value);
- end;
- case lparam._type of
- ACF_CURRENT: llparam:=hContact;
- ACF_NUMBER : llparam:=NumToInt(lparam.value);
- else
- llparam:=TLPARAM(lparam.value);
- end;
-
- if (restype and ACF_SCRIPT_SERVICE)<>0 then
- srv:=ParseVarString(service,hContact,nil)
- else
- srv:=service;
-
- tmp:=int_ptr(CallService(srv,TWPARAM(lwparam),TLPARAM(llparam)));
- if (restype and ACF_SCRIPT_SERVICE)<>0 then
- mFreeMem(srv);
-
- if tmp=CALLSERVICE_NOTFOUND then exit;
- if (restype and ACF_RSTRING)<>0 then
- AnsiToWide(PAnsiChar(tmp),res.text)
- else if (restype and ACF_RUNICODE)<>0 then
- StrDupW(res.text,PWideChar(tmp))
- else// if (restype and ACF_RNUMBER)<>0 then
+ data.Parameter :=hContact;
+ data.LastResult:=0;
+ data.ResultType:=ACF_TYPE_NUMBER;
+ if ExecuteService(service,data) then
begin
- res.data:=tmp;
- if (restype and ACF_RHEXNUM)<>0 then
- res.text:=int2hexw(tmp)
- else
- begin
- b:=(restype and ACF_RSIGNED)<>0;
- res.text:=int2strw(tmp,b);
+ 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;
- end;
+ ClearSubstData(data);
+ end
+ else
+ res.text:=nil;
+
end;
QST_CONTACTINFO: begin
diff --git a/plugins/QuickSearch/sr_global.pas b/plugins/QuickSearch/sr_global.pas
index fa817ae0f6..c7cb5af022 100644
--- a/plugins/QuickSearch/sr_global.pas
+++ b/plugins/QuickSearch/sr_global.pas
@@ -1,7 +1,7 @@
unit sr_global;
interface
-uses windows,messages,commctrl,m_api,dbsettings,mirutils;
+uses windows,messages,commctrl,m_api,dbsettings,mirutils,awkservices;
const
QS_QS :PAnsiChar = 'QS_QS';
@@ -75,12 +75,6 @@ const
{$include resource.inc}
type
- tserviceparam = record
- value:pWideChar;
- _type:dword;
- end;
-
-type
pcolumnitem = ^tcolumnitem;
tcolumnitem = record
title :PWideChar;
@@ -97,12 +91,7 @@ type
// script
1: (script:pWideChar);
// service
- 2: (
- service:pAnsiChar;
- wparam :tserviceparam;
- lparam :tserviceparam;
- restype:dword;
- );
+ 2: (service:tServiceValue);
// contact info
3: (cnftype:word); // CNF_* constants
// other
@@ -153,7 +142,7 @@ const
implementation
-uses common, sparam;
+uses common;
const
HKN_GLOBAL:PAnsiChar = 'QS_Global';
@@ -294,11 +283,7 @@ begin
StrDupW(dst.script,dst.script);
end;
QST_SERVICE: begin
- StrDup(dst.service,dst.service);
- if (dst.wparam._type=ACF_STRING) or (dst.wparam._type=ACF_UNICODE) then
- StrDupW(pWideChar(dst.wparam.value),pWideChar(dst.wparam.value));
- if (dst.lparam._type=ACF_STRING) or (dst.lparam._type=ACF_UNICODE) then
- StrDupW(pWideChar(dst.lparam.value),pWideChar(dst.lparam.value));
+ CopyServiceValue(dst.service,src.service);
end;
end;
result:=true;
@@ -332,11 +317,7 @@ begin
mFreeMem(column.script);
end;
QST_SERVICE: begin
- mFreeMem(column.service);
- if (column.wparam._type=ACF_STRING) or (column.wparam._type=ACF_UNICODE) then
- mFreeMem(pointer(column.wparam.value));
- if (column.wparam._type=ACF_STRING) or (column.wparam._type=ACF_UNICODE) then
- mFreeMem(pointer(column.lparam.value));
+ ClearServiceValue(column.service);
end;
QST_CONTACTINFO: begin
end;
@@ -392,11 +373,11 @@ begin
width :=82;
flags :=COL_ON;
setting_type :=QST_SERVICE;
- StrDup (service,MS_PROTO_GETCONTACTBASEACCOUNT);
- restype :=ACF_RSTRING;
- wparam._type :=ACF_CURRENT;
- lparam._type :=ACF_NUMBER;
- lparam.value :=nil;
+ StrDup (service.service,MS_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);
@@ -429,11 +410,11 @@ begin
width :=76;
flags :=COL_ON+COL_FILTER;
setting_type :=QST_SERVICE;
- StrDup(service,MS_CLIST_GETCONTACTDISPLAYNAME);
- restype :=ACF_RUNICODE;
- wparam._type :=ACF_CURRENT;
- lparam._type :=ACF_NUMBER;
- lparam.value :='2'; // 0 for ANSI
+ StrDup(service.service,MS_CLIST_GETCONTACTDISPLAYNAME);
+ service.flags :=ACF_TYPE_UNICODE;
+ service.w_flags:=ACF_TYPE_PARAM;
+ service.l_flags:=ACF_TYPE_NUMBER;
+ StrDupW(pWideChar(service.lparam),'2'); // 0 for ANSI
end;
inc(i);
@@ -660,22 +641,8 @@ begin
end;
QST_SERVICE: begin
- StrCopy(p,so__service ); WriteStr(buf,service);
- StrCopy(p,so__restype ); WriteInt(buf,restype);
- StrCopy(p,so__wparam_type); WriteInt(buf,wparam._type);
- StrCopy(p,so__lparam_type); WriteInt(buf,lparam._type);
- StrCopy(p,so__wparam);
- case wparam._type of
- ACF_NUMBER : WriteUnicode(buf,wparam.value);
- ACF_STRING : WriteStr (buf,pointer(wparam.value));
- ACF_UNICODE: WriteUnicode(buf,pointer(wparam.value));
- end;
- StrCopy(p,so__lparam);
- case lparam._type of
- ACF_NUMBER : WriteUnicode(buf,lparam.value);
- ACF_STRING : WriteStr (buf,pointer(lparam.value));
- ACF_UNICODE: WriteUnicode(buf,pointer(lparam.value));
- end;
+ p^:=#0;
+ SaveServiceValue(service,qs_module,buf);
end;
QST_OTHER: begin
@@ -735,11 +702,18 @@ begin
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
@@ -795,32 +769,68 @@ begin
StrCopy(p,so__cnftype); cnftype:=GetWord(buf,0);
end;
- QST_SERVICE: begin
- StrCopy(p,so__service); service:=GetStr(buf);
- StrCopy(p,so__restype); restype:=GetInt(buf,0);
- StrCopy(p,so__wparam_type); wparam._type:=GetInt(buf,0);
- StrCopy(p,so__lparam_type); lparam._type:=GetInt(buf,0);
- StrCopy(p,so__wparam);
- case wparam._type of
- ACF_NUMBER : begin
- if DBGetSettingType(0,qs_module,so__wparam)=DBVT_DWORD then
- StrDupW(wparam.value,IntToStr(buf1,GetInt(buf,0)))
- else
- wparam.value:=pointer(GetUnicode(buf));
+ 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;
- ACF_STRING : wparam.value:=pointer(GetStr(buf));
- ACF_UNICODE: wparam.value:=pointer(GetUnicode(buf));
- end;
- StrCopy(p,so__lparam);
- case lparam._type of
- ACF_NUMBER : begin
- if DBGetSettingType(0,qs_module,so__lparam)=DBVT_DWORD then
- StrDupW(lparam.value,IntToStr(buf1,GetInt(buf,0)))
- else
- lparam.value:=pointer(GetUnicode(buf));
+
+ //----- 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;
- ACF_STRING : lparam.value:=pointer(GetStr(buf));
- ACF_UNICODE: lparam.value:=pointer(GetUnicode(buf));
+
end;
end;
diff --git a/plugins/QuickSearch/sr_optdialog.pas b/plugins/QuickSearch/sr_optdialog.pas
index c73843677d..727f19bbb6 100644
--- a/plugins/QuickSearch/sr_optdialog.pas
+++ b/plugins/QuickSearch/sr_optdialog.pas
@@ -11,7 +11,8 @@ uses
messages,commctrl,
m_api,common,mirutils,wrapper,dbsettings,
sr_global,sr_window,
- sparam,editwrapper,srvblock;
+ editwrapper,
+ awkservices;
var
OldListProc:pointer;
@@ -305,8 +306,8 @@ begin
// LV_SetItemW(list,column.script,item,3);
end;
QST_SERVICE: begin
- LV_SetItemW(list,TranslateW('Service'),item,2);
- LV_SetItem (list,column.service ,item,3);
+ 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);
@@ -325,7 +326,6 @@ end;
function savecuritem(Dialog:HWND):integer;
var
list:HWND;
- srvalue:tServiceValue;
i:integer;
idx,lwidth:integer;
begin
@@ -364,13 +364,8 @@ begin
end;
QST_SERVICE: begin
- GetSrvBlockValue(ServiceBlock,srvalue);
- service :=srvalue.service;
- wparam.value:=srvalue.wparam;
- wparam._type:=srvalue.w_flag;
- lparam.value:=srvalue.lparam;
- lparam._type:=srvalue.l_flag;
- restype :=srvalue.flags;
+ ClearServiceValue(service);
+ GetSrvBlockValue(ServiceBlock,service);
end;
QST_OTHER: begin
@@ -382,8 +377,6 @@ begin
end;
procedure displcurinfo(Dialog:HWND;const column:tcolumnitem);
-var
- srvalue:tServiceValue;
begin
ClearScreen(Dialog);
SetupScreen(Dialog,column.setting_type);
@@ -403,13 +396,7 @@ begin
end;
QST_SERVICE: begin
- srvalue.service:=column.service;
- srvalue.wparam :=pointer(column.wparam.value);
- srvalue.w_flag :=column.wparam._type;
- srvalue.lparam :=pointer(column.lparam.value);
- srvalue.l_flag :=column.lparam._type;
- srvalue.flags :=column.restype;
- SetSrvBlockValue(ServiceBlock,srvalue);
+ SetSrvBlockValue(ServiceBlock,column.service);
end;
QST_CONTACTINFO: begin
@@ -703,7 +690,8 @@ begin
ScreenToClient(Dialog,pt1);
height:=pt1.y-pt.y-2;
- ServiceBlock:=CreateServiceBlock(Dialog,pt.x,pt.y,width,height,ACF_NOSTRUCT);
+ ServiceBlock:=CreateServiceBlock(Dialog,pt.x,pt.y,width,height,
+ ACF_BLOCK_NOSTRUCT+ACF_BLOCK_NOCURRENT);
// Contact info
// Other
diff --git a/plugins/QuickSearch/sr_window.pas b/plugins/QuickSearch/sr_window.pas
index fa2a983367..7fdfcbe373 100644
--- a/plugins/QuickSearch/sr_window.pas
+++ b/plugins/QuickSearch/sr_window.pas
@@ -15,7 +15,7 @@ const
implementation
uses messages,commctrl,sr_global,common,dbsettings,mirutils,
- wrapper,protocols,sparam,srvblock,editwrapper, mircontacts;
+ wrapper,protocols,awkservices,editwrapper, mircontacts;
const
IDM_STAYONTOP = WM_USER+1;
diff --git a/plugins/Utils.pas/awkservices.pas b/plugins/Utils.pas/awkservices.pas
new file mode 100644
index 0000000000..4ab6f851cb
--- /dev/null
+++ b/plugins/Utils.pas/awkservices.pas
@@ -0,0 +1,327 @@
+unit awkservices;
+
+interface
+
+uses windows;
+
+//===== Basic parameter and result type flags =====
+
+const
+ ACF_TYPE_NUMBER = $00; // Parameter is number
+ ACF_TYPE_STRING = $01; // Parameter is ANSI String
+ ACF_TYPE_UNICODE = $02; // Parameter is Unicode string
+ ACF_TYPE_STRUCT = $03; // Parameter is (result is in) structure
+//----- Additional parameter types -----
+ ACF_TYPE_PARAM = $08; // Parameter is Call parameter
+ ACF_TYPE_CURRENT = $09; // Parameter is ignored, used current user handle from current message window
+ ACF_TYPE_RESULT = $0A; // Parameter is previous action result
+
+ ACF_TYPE_MASK = $0F; // parameter/result type mask
+
+
+//===== Flags =====
+
+const
+ ACF_FLAG_SCRIPT = $00000200; // Parameter or service name is script
+
+//----- Parameter flags -----
+const
+ ACF_FLAG_TEMPLATE = $00000100; // Parameter is text from template (with possible comments)
+
+//----- Service result flags -----
+const
+ ACF_FLAG_FREEMEM = $00000100; // Need to free memory
+ // visual view (controlled by ACF_NOVISUAL flag in dialogs)
+ ACF_FLAG_HEXNUM = $00001000; // Show number as hex
+ ACF_FLAG_SIGNED = $00002000; // Show number as signed
+
+
+//===== Block creation flags =====
+
+const
+ // Common block flags
+ ACF_BLOCK_NOSTATIC = $01000000; // No label text in block
+ ACF_BLOCK_NOBORDER = $02000000; // No group border around block
+ ACF_BLOCK_NOSTRUCT = $04000000; // don't add structure as param type
+ // Param only
+ ACF_BLOCK_NOCURRENT = $08000000; // don't show "Current contact" type in list (slow processing)
+ // Result only
+ ACF_BLOCK_NOVISUAL = $08000000; // don't show number view styles
+ // Service only
+ ACF_BLOCK_EXPAND = $10000000; // all service subblocks are visible
+
+
+//===== Types =====
+
+// can be placed to srvblock module if no function exports here
+type
+ pServiceValue = ^tServiceValue;
+ tServiceValue = record
+ service:PAnsiChar;
+ wparam,
+ lparam: pointer;
+ w_flags,
+ l_flags,
+ flags:dword; // result etc
+ end;
+
+type
+ pSubstData = ^tSubstData;
+ tSubstData = record
+ Parameter :LPARAM;
+ LastResult:uint_ptr;
+ ResultType:integer; // ACF_TYPE_* const (ACF_TYPE_NUMBER or ACF_TYPE_UNICODE right now)
+ end;
+
+
+procedure ClearSubstData(var data:tSubstData);
+
+{}
+//----- Parameter dialog -----
+
+function CreateParamBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
+function ClearParamFields(Dialog:HWND):HWND;
+function FillParam (Dialog:HWND;txt:PAnsiChar):integer;
+function SetParamValue (Dialog:HWND; flags:dword; value:pointer):boolean;
+function GetParamValue (Dialog:HWND;var flags:dword;var value:pointer):boolean;
+function SetParamLabel (Dialog:HWND; lbl:PWideChar):HWND;
+
+//----- Parameter value -----
+
+procedure SaveParamValue( flags:dword; param:pointer; module,setting:PAnsiChar);
+procedure LoadParamValue(var flags:dword; var param:pointer; module,setting:PAnsiChar);
+procedure ClearParam ( flags:dword; var param);
+function DuplicateParam( flags:dword; var asparam,adparam):dword;
+{??
+function TranslateParam(param:uint_ptr;flags:dword;hContact:TMCONTACT):uint_ptr;
+}
+
+//----- Execution -----
+
+function PrepareParameter(flags:dword;const aparam:LPARAM; const data:tSubstData):LPARAM;
+procedure ReleaseParameter(flags:dword;var aparam:LPARAM);
+
+//----- result dialog -----
+
+function CreateResultBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
+function ClearResultFields(Dialog:HWND):HWND;
+function SetResultValue (Dialog:HWND;flags:dword):integer;
+function GetResultValue (Dialog:HWND):dword;
+
+//----- Old flags converting -----
+
+function ConvertParamFlags (flags:dword):dword;
+function ConvertResultFlags(flags:dword):dword;
+
+
+//----- Service dialog -----
+
+function CreateServiceBlock(parent:HWND;x,y,width,height:integer;flags:dword=0):HWND;
+procedure ClearServiceBlock (Dialog:HWND);
+procedure SetServiceListMode(Dialog:HWND;mode:integer);
+
+function SetSrvBlockValue(Dialog:HWND;const value:tServiceValue):boolean;
+function GetSrvBlockValue(Dialog:HWND;var value:tServiceValue):boolean;
+// service setting for templates
+procedure SetSrvBlockService(Dialog:HWND; service:PAnsiChar);
+function GetSrvBlockService(Dialog:HWND):PAnsiChar;
+
+//----- ServiceValue functions -----
+
+procedure CopyServiceValue (var dst :tServiceValue; const src:tServiceValue);
+procedure ClearServiceValue(var data:tServiceValue);
+procedure SaveServiceValue (const data:tServiceValue; module,setting:PAnsiChar);
+procedure LoadServiceValue (var data:tServiceValue; module,setting:PAnsiChar);
+
+//----- Service execute -----
+
+function ExecuteService(const service:tServiceValue; var data:tSubstData):boolean;
+{}
+
+implementation
+
+uses
+ common
+ ,sparam
+ ,srvblock;
+
+procedure ClearSubstData(var data:tSubstData);
+begin
+ case data.ResultType of
+ ACF_TYPE_STRING, // this condition must be never existing rigth now
+ ACF_TYPE_UNICODE: mFreeMem(data.LastResult);
+ end;
+end;
+
+//==================================================
+
+//----- Parameter dialog -----
+
+function CreateParamBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
+begin
+ result:=sparam.CreateParamBlock(parent,x,y,width,flags);
+end;
+
+function ClearParamFields(Dialog:HWND):HWND;
+begin
+ result:=sparam.ClearParamFields(Dialog);
+end;
+
+function FillParam(Dialog:HWND;txt:PAnsiChar):integer;
+begin
+ result:=sparam.FillParam(Dialog,txt);
+end;
+
+function SetParamValue(Dialog:HWND; flags:dword; value:pointer):boolean;
+begin
+ result:=sparam.SetParamValue(Dialog,flags,value);
+end;
+
+function GetParamValue(Dialog:HWND;var flags:dword;var value:pointer):boolean;
+begin
+ result:=sparam.GetParamValue(Dialog,flags,value);
+end;
+
+function SetParamLabel(Dialog:HWND; lbl:PWideChar):HWND;
+begin
+ result:=sparam.SetParamLabel(Dialog,lbl);
+end;
+
+//----- Parameter value -----
+
+procedure SaveParamValue(flags:dword; param:pointer; module,setting:PAnsiChar);
+begin
+ sparam.SaveParamValue(flags,param,module,setting);
+end;
+
+procedure LoadParamValue(var flags:dword; var param:pointer; module,setting:PAnsiChar);
+begin
+ sparam.LoadParamValue(flags,param,module,setting);
+end;
+
+procedure ClearParam(flags:dword; var param);
+begin
+ sparam.ClearParam(flags,param);
+end;
+
+function DuplicateParam(flags:dword; var asparam,adparam):dword;
+begin
+ result:=sparam.DuplicateParam(flags,asparam,adparam);
+end;
+
+//----- Execution -----
+
+function PrepareParameter(flags:dword;const aparam:LPARAM; const data:tSubstData):LPARAM;
+begin
+ result:=sparam.PrepareParameter(flags,aparam,data);
+end;
+
+procedure ReleaseParameter(flags:dword;var aparam:LPARAM);
+begin
+ sparam.ReleaseParameter(flags,aparam);
+end;
+
+//----- result dialog -----
+
+function CreateResultBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
+begin
+ result:=sparam.CreateResultBlock(parent,x,y,width,flags);
+end;
+
+function ClearResultFields(Dialog:HWND):HWND;
+begin
+ result:=sparam.ClearResultFields(Dialog);
+end;
+
+function SetResultValue(Dialog:HWND;flags:dword):integer;
+begin
+ result:=sparam.SetResultValue(Dialog,flags);
+end;
+
+function GetResultValue(Dialog:HWND):dword;
+begin
+ result:=sparam.GetResultValue(Dialog);
+end;
+
+//----- Old flags converting -----
+
+function ConvertParamFlags(flags:dword):dword;
+begin
+ result:=sparam.ConvertParamFlags(flags);
+end;
+
+function ConvertResultFlags(flags:dword):dword;
+begin
+ result:=sparam.ConvertResultFlags(flags);
+end;
+
+
+//----- Service dialog -----
+
+function CreateServiceBlock(parent:HWND;x,y,width,height:integer;flags:dword=0):HWND;
+begin
+ result:=srvblock.CreateServiceBlock(parent,x,y,width,height,flags)
+end;
+
+procedure ClearServiceBlock(Dialog:HWND);
+begin
+ srvblock.ClearServiceBlock(Dialog)
+end;
+
+procedure SetServiceListMode(Dialog:HWND;mode:integer);
+begin
+ srvblock.SetServiceListMode(Dialog,mode);
+end;
+
+function SetSrvBlockValue(Dialog:HWND;const value:tServiceValue):boolean;
+begin
+ result:=srvblock.SetSrvBlockValue(Dialog,value);
+end;
+
+function GetSrvBlockValue(Dialog:HWND;var value:tServiceValue):boolean;
+begin
+ result:=srvblock.GetSrvBlockValue(Dialog,value);
+end;
+
+// service setting for templates
+procedure SetSrvBlockService(Dialog:HWND; service:PAnsiChar);
+begin
+ srvblock.SetSrvBlockService(Dialog,service);
+end;
+
+function GetSrvBlockService(Dialog:HWND):PAnsiChar;
+begin
+ result:=srvblock.GetSrvBlockService(Dialog);
+end;
+
+//----- ServiceValue functions -----
+
+procedure CopyServiceValue(var dst:tServiceValue; const src:tServiceValue);
+begin
+ srvblock.CopyServiceValue(dst,src);
+end;
+
+procedure ClearServiceValue(var data:tServiceValue);
+begin
+ srvblock.ClearServiceValue(data);
+end;
+
+procedure SaveServiceValue(const data:tServiceValue; module,setting:PAnsiChar);
+begin
+ srvblock.SaveServiceValue(data,module,setting);
+end;
+
+procedure LoadServiceValue(var data:tServiceValue; module,setting:PAnsiChar);
+begin
+ srvblock.LoadServiceValue(data,module,setting);
+end;
+
+//----- Service execute -----
+
+function ExecuteService(const service:tServiceValue; var data:tSubstData):boolean;
+begin
+ result:=srvblock.ExecuteService(service,data);
+end;
+
+
+end.
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas
index d02fbcd7e8..4d16e5cf4b 100644
--- a/plugins/Utils.pas/mirutils.pas
+++ b/plugins/Utils.pas/mirutils.pas
@@ -5,15 +5,6 @@ interface
uses windows,m_api;
-// for miranda services
-const
- rtUnkn = 0;
- rtInt = 1;
- rtWide = 2;
- rtAnsi = 3;
- rtUTF8 = 4;
-
-
// icons
function SetButtonIcon(btn:HWND;name:PAnsiChar):HICON;
function RegisterSingleIcon(resname,ilname,descr,group:PAnsiChar):int;
diff --git a/plugins/Utils.pas/sparam.pas b/plugins/Utils.pas/sparam.pas
index 7dbfc12d21..134fc63cae 100644
--- a/plugins/Utils.pas/sparam.pas
+++ b/plugins/Utils.pas/sparam.pas
@@ -6,44 +6,9 @@ unit sparam;
interface
-uses windows, m_api;
+uses windows, m_api, awkservices;
-const
- // parameter flags
- ACF_NUMBER = $00000001; // Param is number
- ACF_UNICODE = $00000002; // Param is Unicode string
- ACF_CURRENT = $00000004; // Param is ignored, used current user handle
- // from current message window
- ACF_RESULT = $00000008; // Param is previous action result
- ACF_PARAM = $00000010; // Param is Call parameter
- ACF_STRUCT = $00000020;
- ACF_PARTYPE = ACF_NUMBER or ACF_UNICODE or
- ACF_CURRENT or ACF_RESULT or
- ACF_PARAM or ACF_STRUCT;
- ACF_SIGNED = $00002000; // for future
- ACF_TEMPLATE = $00000800;
- ACF_SCRIPT_PARAM = $00001000;
- // dummy
- ACF_STRING = 0;
- ACF_RNUMBER = 0;
-
- // result flags
- ACF_RSTRING = $00010000; // Service result is string
- ACF_RUNICODE = $00020000; // Service result is Widestring
- ACF_RSTRUCT = $00040000; // Service result in structure
- ACF_RFREEMEM = $00080000; // Need to free memory
- ACF_RHEXNUM = $00100000; // Show number as hex
- ACF_RSIGNED = $00200000; // Show number as signed
-
- ACF_RTYPE = ACF_RSTRING or ACF_RUNICODE or
- ACF_RSTRUCT or ACF_RFREEMEM or
- ACF_RHEXNUM or ACF_RSIGNED;
-
- // parameter / result block creation flags
- ACF_NOSTATIC = $01000000; // No label text in block
- ACF_NOBORDER = $02000000; // No group border around block
- ACF_NOSTRUCT = $04000000; // don't add structure as param type
- ACF_NOVISUAL = $08000000; // don't show number view styles
+//----- Parameter dialog -----
function CreateParamBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
function ClearParamFields(Dialog:HWND):HWND;
@@ -52,14 +17,32 @@ function SetParamValue (Dialog:HWND; flags:dword; value:pointer):boolean
function GetParamValue (Dialog:HWND;var flags:dword;var value:pointer):boolean;
function SetParamLabel (Dialog:HWND; lbl:PWideChar):HWND;
-procedure ClearParam (flags:dword; var param);
-function DuplicateParam(flags:dword; var sparam,dparam):dword;
+//----- Parameter value -----
+
+procedure SaveParamValue( flags:dword; param:pointer; module,setting:PAnsiChar);
+procedure LoadParamValue(var flags:dword; var param:pointer; module,setting:PAnsiChar);
+procedure ClearParam ( flags:dword; var param);
+function DuplicateParam( flags:dword; var sparam,dparam):dword;
+{??
function TranslateParam(param:uint_ptr;flags:dword;hContact:TMCONTACT):uint_ptr;
+}
+
+//----- Execution -----
+
+function PrepareParameter(flags:dword;const aparam:LPARAM; const data:tSubstData):LPARAM;
+procedure ReleaseParameter(flags:dword;var aparam:LPARAM);
+
+//----- result dialog -----
function CreateResultBlock(parent:HWND;x,y,width:integer;flags:dword=0):THANDLE;
function ClearResultFields(Dialog:HWND):HWND;
-function SetResultValue(Dialog:HWND;flags:dword):integer;
-function GetResultValue(Dialog:HWND):dword;
+function SetResultValue (Dialog:HWND;flags:dword):integer;
+function GetResultValue (Dialog:HWND):dword;
+
+//----- Old flags converting -----
+
+function ConvertParamFlags (flags:dword):dword;
+function ConvertResultFlags(flags:dword):dword;
implementation
@@ -67,7 +50,9 @@ uses
messages,
common, editwrapper, wrapper, syswin,
sedit, strans,
- mirutils;
+ dbsettings,mirutils,mircontacts;
+
+//----- Parameter dialog -----
const
IDC_FLAG_PAR = 2150;
@@ -92,20 +77,20 @@ begin
num);
end;
-
//----- Dialog functions -----
procedure MakeParamTypeList(wnd:HWND; flags:dword);
begin
SendMessage(wnd,CB_RESETCONTENT,0,0);
- InsertString(wnd,ACF_NUMBER ,'number value');
- InsertString(wnd,ACF_STRING ,'ANSI string');
- InsertString(wnd,ACF_UNICODE,'Unicode string');
- InsertString(wnd,ACF_CURRENT,'current contact');
- InsertString(wnd,ACF_RESULT ,'last result');
- InsertString(wnd,ACF_PARAM ,'parameter');
- if (flags and ACF_NOSTRUCT)=0 then
- InsertString(wnd,ACF_STRUCT ,'structure');
+ InsertString(wnd, ACF_TYPE_NUMBER , 'number value');
+ InsertString(wnd, ACF_TYPE_STRING , 'ANSI string');
+ InsertString(wnd, ACF_TYPE_UNICODE, 'Unicode string');
+ if (flags and ACF_BLOCK_NOCURRENT)=0 then
+ InsertString(wnd, ACF_TYPE_CURRENT, 'current contact');
+ InsertString(wnd, ACF_TYPE_RESULT , 'last result');
+ InsertString(wnd, ACF_TYPE_PARAM , 'parameter');
+ if (flags and ACF_BLOCK_NOSTRUCT)=0 then
+ InsertString(wnd, ACF_TYPE_STRUCT, 'structure');
SendMessage(wnd,CB_SETCURSEL,0,0);
end;
@@ -119,15 +104,15 @@ begin
result:=false;
end;
-// Set parameter type by parameter template
+// Set parameter type by parameter template for non-numbers
function FixParam(buf:PAnsiChar):integer;
begin
- if StrCmp(buf,'hContact' )=0 then result:=ACF_CURRENT
- else if StrCmp(buf,'parameter' )=0 then result:=ACF_PARAM
- else if StrCmp(buf,'result' )=0 then result:=ACF_RESULT
- else if StrCmp(buf,'structure' )=0 then result:=ACF_STRUCT
- else if StrCmp(buf,'Unicode text')=0 then result:=ACF_UNICODE
- else result:=ACF_STRING;
+ if StrCmp(buf,'hContact' )=0 then result:=ACF_TYPE_CURRENT
+ else if StrCmp(buf,'parameter' )=0 then result:=ACF_TYPE_PARAM
+ else if StrCmp(buf,'result' )=0 then result:=ACF_TYPE_RESULT
+ else if StrCmp(buf,'structure' )=0 then result:=ACF_TYPE_STRUCT
+ else if StrCmp(buf,'Unicode text')=0 then result:=ACF_TYPE_UNICODE
+ else result:=ACF_TYPE_STRING;
end;
function FixParamControls(Dialog:HWND;atype:dword):dword;
@@ -140,7 +125,7 @@ begin
wnd :=GetDlgItem(Dialog,IDC_EDIT_PAR);
wnd1:=GetDlgItem(Dialog,IDC_STRUCT);
- if atype=ACF_STRUCT then
+ if atype=ACF_TYPE_STRUCT then
begin
ShowEditField(wnd ,SW_HIDE);
ShowWindow (wnd1,SW_SHOW);
@@ -150,11 +135,11 @@ begin
ShowEditField(wnd ,SW_SHOW);
ShowWindow (wnd1,SW_HIDE);
- if atype in [ACF_CURRENT,ACF_RESULT,ACF_PARAM] then
+ if atype in [ACF_TYPE_CURRENT,ACF_TYPE_RESULT,ACF_TYPE_PARAM] then
EnableEditField(wnd,false)
else
begin
- if atype=ACF_NUMBER then //!!
+ if atype=ACF_TYPE_NUMBER then
begin
if SendMessageW(wnd,WM_GETTEXTLENGTH,0,0)=0 then
begin
@@ -169,7 +154,7 @@ begin
end;
// get line from template
-function GetParamLine(src:PAnsiChar;dst:PWideChar;var ltype:integer):PAnsiChar;
+function GetParamLine(src:PAnsiChar;dst:PWideChar;var ltype:dword):PAnsiChar;
var
pp,pc:PAnsiChar;
j:integer;
@@ -198,7 +183,7 @@ begin
FastAnsiToWideBuf(pp+1,dst+j);
StrCopyW(dst+j,TranslateW(dst+j));
end;
- ltype:=ACF_NUMBER;
+ ltype:=ACF_TYPE_NUMBER;
end
else
begin
@@ -221,7 +206,7 @@ var
bufw:array [0..2047] of WideChar;
wnd:HWND;
p,pc:PAnsiChar;
- ltype:integer;
+ ltype:dword;
begin
wnd:=GetDlgItem(Dialog,IDC_EDIT_PAR);
SendMessage(wnd,CB_RESETCONTENT,0,0);
@@ -235,14 +220,14 @@ begin
result:=ltype;
SendMessageW(wnd,CB_ADDSTRING,0,lparam(@bufw));
- if result=ACF_STRUCT then
+ if result=ACF_TYPE_STRUCT then
break
else
p:=pc;
until pc=nil;
end
else
- result:=ACF_NUMBER;
+ result:=ACF_TYPE_NUMBER;
SendMessage(wnd,CB_SETCURSEL,0,0);
CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_PAR),result);
@@ -256,8 +241,8 @@ begin
wnd:=GetDlgItem(Dialog,IDC_EDIT_PAR);
SendMessage (wnd,CB_RESETCONTENT,0,0);
SetEditFlags (wnd,EF_ALL,0);
- CB_SelectData(Dialog,IDC_FLAG_PAR,ACF_NUMBER);
- FixParamControls(Dialog,ACF_NUMBER);
+ CB_SelectData(Dialog,IDC_FLAG_PAR,ACF_TYPE_NUMBER);
+ FixParamControls(Dialog,ACF_TYPE_NUMBER);
result:=Dialog;
end;
@@ -302,7 +287,7 @@ begin
i:=CB_GetData(GetDlgItem(Dialog,loword(wParam)));
- if i=ACF_STRUCT then
+ if i=ACF_TYPE_STRUCT then
begin
ShowEditField(wnd ,SW_HIDE);
ShowWindow (wnd1,SW_SHOW);
@@ -312,11 +297,11 @@ begin
ShowEditField(wnd ,SW_SHOW);
ShowWindow (wnd1,SW_HIDE);
- if i in [ACF_CURRENT,ACF_RESULT,ACF_PARAM] then
+ if i in [ACF_TYPE_CURRENT,ACF_TYPE_RESULT,ACF_TYPE_PARAM] then
EnableEditField(wnd,false)
else
begin
- if i=ACF_NUMBER then
+ if i=ACF_TYPE_NUMBER then
begin
pcw:='0';
SendMessageW(wnd,WM_SETTEXT,0,TLParam(pcw));
@@ -383,7 +368,7 @@ begin
yo:=0;
// group border
- if (flags and ACF_NOBORDER)=0 then
+ if (flags and ACF_BLOCK_NOBORDER)=0 then
begin
group:=CreateWindowW('BUTTON','Param',WS_CHILD+WS_VISIBLE+WS_GROUP+BS_GROUPBOX,
0,0,dx,dy, result,IDC_GROUP_PAR,hInstance,nil);
@@ -397,7 +382,7 @@ begin
end;
// label
- if (flags and ACF_NOSTATIC)=0 then
+ if (flags and ACF_BLOCK_NOSTATIC)=0 then
begin
if width<=150 then
@@ -426,7 +411,7 @@ begin
if fullline then
begin
xo:=gx;
- if (flags and ACF_NOSTATIC)=0 then
+ if (flags and ACF_BLOCK_NOSTATIC)=0 then
inc(yo,rc.bottom);
end;
ctrl:=CreateWindowW('COMBOBOX',nil,WS_CHILD+WS_VISIBLE+WS_VSCROLL+CBS_DROPDOWNLIST+CBS_AUTOHSCROLL,
@@ -451,7 +436,7 @@ begin
// resize group and dialog
MoveWindow(result,x,y,dx,yo,false);
- if (flags and ACF_NOBORDER)=0 then
+ if (flags and ACF_BLOCK_NOBORDER)=0 then
MoveWindow(group,0,0,dx,yo,false);
ClearParamFields(result);
@@ -499,67 +484,57 @@ begin
result:=true;
wnd:=GetDlgItem(Dialog,IDC_EDIT_PAR);
- if (flags and ACF_TEMPLATE)<>0 then
+ if (flags and ACF_FLAG_TEMPLATE)<>0 then
begin
vtype:=FillParam(Dialog,value);
end
- else if (flags and ACF_PARAM)<>0 then
- begin
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Parameter')));
- EnableWindow(wnd,false);
- vtype:=ACF_PARAM;
- end
- else if (flags and ACF_RESULT)<>0 then
- begin
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Last result')));
- EnableWindow(wnd,false);
- vtype:=ACF_RESULT;
- end
- else if (flags and ACF_CURRENT)<>0 then
- begin
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Current user')));
- EnableWindow(wnd,false);
- vtype:=ACF_CURRENT;
- end
- else if (flags and ACF_STRUCT)<>0 then
- begin
- vtype:=ACF_STRUCT;
-
- ShowEditField(wnd,SW_HIDE);
- wnd1:=GetDlgItem(Dialog,IDC_STRUCT);
- ShowWindow(wnd1,SW_SHOW);
- // delete old value
- pc:=PAnsiChar(GetWindowLongPtrW(wnd1,GWLP_USERDATA));
- mFreeMem(pc);
- // set newly allocated
- SetWindowLongPtrW(wnd1,GWLP_USERDATA,long_ptr(StrDup(pc,PAnsiChar(value))));
-//!!!!!!!!
- end
- else if (flags and ACF_NUMBER)<>0 then
- begin
- vtype:=ACF_NUMBER;
- if value=nil then
- pcw:='0'
- else
- pcw:=value;
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(pcw));
- end
- else if (flags and ACF_UNICODE)<>0 then
- begin
- vtype:=ACF_UNICODE;
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(value));
- end
else
begin
- vtype:=ACF_STRING;
- SendMessageW(wnd,WM_SETTEXT,0,LPARAM(value));
+ vtype:=flags and ACF_TYPE_MASK;
+ case vtype of
+ ACF_TYPE_PARAM: begin
+ SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Parameter')));
+ EnableWindow(wnd,false);
+ end;
+ ACF_TYPE_RESULT: begin
+ SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Last result')));
+ EnableWindow(wnd,false);
+ end;
+ ACF_TYPE_CURRENT: begin
+ SendMessageW(wnd,WM_SETTEXT,0,LPARAM(TranslateW('Current user')));
+ EnableWindow(wnd,false);
+ end;
+ ACF_TYPE_STRUCT: begin
+ ShowEditField(wnd,SW_HIDE);
+ wnd1:=GetDlgItem(Dialog,IDC_STRUCT);
+ ShowWindow(wnd1,SW_SHOW);
+ // delete old value
+ pc:=PAnsiChar(GetWindowLongPtrW(wnd1,GWLP_USERDATA));
+ mFreeMem(pc);
+ // set newly allocated
+ SetWindowLongPtrW(wnd1,GWLP_USERDATA,long_ptr(StrDup(pc,PAnsiChar(value))));
+ //!!!!!!!!
+ end;
+ ACF_TYPE_NUMBER: begin
+ if value=nil then
+ pcw:='0'
+ else
+ pcw:=value;
+ SendMessageW(wnd,WM_SETTEXT,0,LPARAM(pcw));
+ end;
+ ACF_TYPE_UNICODE,
+ ACF_TYPE_STRING: begin
+ SendMessageW(wnd,WM_SETTEXT,0,LPARAM(value));
+ end;
+ end;
end;
- SetEditFlags(wnd,EF_SCRIPT,ord((flags and ACF_SCRIPT_PARAM)<>0));
+ SetEditFlags(wnd,EF_SCRIPT,ord((flags and ACF_FLAG_SCRIPT)<>0));
CB_SelectData(GetDlgItem(Dialog,IDC_FLAG_PAR),vtype);
FixParamControls(Dialog,vtype);
end;
+//?? preserve ACF_TEMPLATE flag??
function GetParamValue(Dialog:HWND;var flags:dword;var value:pointer):boolean;
var
wnd:HWND;
@@ -571,93 +546,179 @@ begin
end;
result:=true;
- flags:=0;
value:=nil;
wnd:=GetDlgItem(Dialog,IDC_EDIT_PAR);
- case CB_GetData(GetDlgItem(Dialog,IDC_FLAG_PAR)) of
- ACF_PARAM: begin
- flags:=flags or ACF_PARAM
- end;
- ACF_RESULT: begin
- flags:=flags or ACF_RESULT
- end;
- ACF_CURRENT: begin
- flags:=flags or ACF_CURRENT
- end;
- ACF_NUMBER: begin
- flags:=flags or ACF_NUMBER;
+ flags:=CB_GetData(GetDlgItem(Dialog,IDC_FLAG_PAR));
+ case flags of
+ ACF_TYPE_UNICODE,
+ ACF_TYPE_STRING,
+ ACF_TYPE_NUMBER: begin
value:=GetDlgText(wnd);
end;
- ACF_STRUCT: begin
- flags:=flags or ACF_STRUCT;
+ ACF_TYPE_STRUCT: begin
StrDup(PAnsiChar(value),
PAnsiChar(GetWindowLongPtrW(GetDlgItem(Dialog,IDC_STRUCT),GWLP_USERDATA)));
end;
- ACF_UNICODE: begin
- flags:=flags or ACF_UNICODE;
- value:=GetDlgText(wnd);
- end;
- ACF_STRING: value:=GetDlgText(wnd);
end;
if (GetEditFlags(wnd) and EF_SCRIPT)<>0 then
- flags:=flags or ACF_SCRIPT_PARAM;
+ flags:=flags or ACF_FLAG_SCRIPT;
end;
-//----- Additional functions -----
+//----- Parameter value -----
+
+const
+ ioflags:PAnsiChar = 'flags';
+ iovalue:PAnsiChar = 'value';
+
+procedure SaveParamValue(flags:dword; param:pointer; module,setting:PAnsiChar);
+var
+ buf:array [0..127] of AnsiChar;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(buf,setting); p^:='/'; inc(p);
+ StrCopy(p,ioflags); DBWriteDWord(0,module,buf,flags);
+ StrCopy(p,iovalue);
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: DBWriteUnicode(0,module,buf,param);
+ ACF_TYPE_STRUCT : DBWriteString (0,module,buf,param);
+ end;
+end;
+
+procedure LoadParamValue(var flags:dword; var param:pointer; module,setting:PAnsiChar);
+var
+ buf:array [0..127] of AnsiChar;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(buf,setting); p^:='/'; inc(p);
+ StrCopy(p,ioflags); flags:=DBReadDWord(0,module,buf);
+ StrCopy(p,iovalue);
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: param:=DBReadUnicode(0,module,buf);
+ ACF_TYPE_STRUCT : param:=DBReadString (0,module,buf);
+ end;
+end;
procedure ClearParam(flags:dword; var param);
begin
- if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
+{
+ if not ((flags and ACF_TYPE_MASK) in [ACF_TYPE_CURRENT, ACF_TYPE_RESULT, ACF_TYPE_PARAM]) then
mFreeMem(pointer(param));
+}
+ case flags of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE,
+ ACF_TYPE_STRUCT : mFreeMem(pointer(param));
+ end;
+end;
+
+//----- Execution -----
+
+function PrepareParameter(flags:dword;const aparam:LPARAM; const data:tSubstData):LPARAM;
+var
+ tmp1:PWideChar;
+ typ:dword;
+begin
+ typ:=flags and ACF_TYPE_MASK;
+ case typ of
+ ACF_TYPE_STRUCT: begin
+ result:=uint_ptr(MakeStructure(pAnsiChar(aparam),
+ data.Parameter,data.LastResult,data.ResultType=ACF_TYPE_NUMBER))
+ end;
+
+ ACF_TYPE_PARAM: begin
+ result:=data.Parameter;
+ end;
+
+ ACF_TYPE_RESULT: begin
+ result:=data.LastResult;
+ end;
+
+ ACF_TYPE_CURRENT: begin
+ result:=WndToContact(WaitFocusedWndChild(GetForegroundwindow){GetFocus});
+ end;
+
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
+ if (flags and ACF_FLAG_SCRIPT)<>0 then
+ tmp1:=ParseVarString(pWideChar(aparam),data.Parameter)
+ else
+ tmp1:=pWideChar(aparam);
+
+ if typ<>ACF_TYPE_NUMBER then
+ begin
+ if typ<>ACF_TYPE_UNICODE then
+ WideToAnsi(tmp1,pAnsiChar(result),MirandaCP)
+ else
+ StrDupW(pWideChar(result),tmp1);
+ end
+ else
+ result:=NumToInt(tmp1);
+
+ if (flags and ACF_FLAG_SCRIPT)<>0 then
+ mFreeMem(tmp1);
+ end;
+ else
+ result:=0;
+ end;
+end;
+
+procedure ReleaseParameter(flags:dword;var aparam:LPARAM);
+begin
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: mFreeMem(pointer(aparam));
+ ACF_TYPE_STRUCT : FreeStructure(aparam);
+ end;
end;
+//----- Additional functions -----
+
function DuplicateParam(flags:dword; var sparam,dparam):dword;
var
tmpdst:array [0..2047] of WideChar;
- ltype:integer;
+ ltype:dword;
begin
mFreeMem(dparam);
- if (flags and ACF_TEMPLATE)<>0 then
+ if (flags and ACF_FLAG_TEMPLATE)<>0 then
begin
- flags:=flags and not (ACF_TEMPLATE or ACF_PARTYPE);
+ flags:=flags and not (ACF_FLAG_TEMPLATE or ACF_TYPE_MASK);
GetParamLine(PAnsiChar(sparam),tmpdst,ltype);
+ flags:=flags or ltype;
case ltype of
- ACF_NUMBER: begin
- flags:=flags or ACF_NUMBER;
- StrDupW(PWideChar(dparam),PWideChar(@tmpdst));
- end;
- ACF_STRING: begin
- flags:=flags or ACF_STRING;
- StrDupW(PWideChar(dparam),PWideChar(@tmpdst));
- end;
- ACF_UNICODE: begin
- flags:=flags or ACF_UNICODE;
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
StrDupW(PWideChar(dparam),PWideChar(@tmpdst));
end;
- ACF_STRUCT: begin
- flags:=flags or ACF_STRUCT;
+ ACF_TYPE_STRUCT: begin
StrDup(PAnsiChar(dparam),PAnsiChar(sparam)+10); //10=StrLen('structure|')
end;
- ACF_CURRENT: flags:=flags or ACF_CURRENT;
- ACF_RESULT : flags:=flags or ACF_RESULT;
- ACF_PARAM : flags:=flags or ACF_PARAM;
end;
end
- else if (flags and (ACF_CURRENT or ACF_RESULT or ACF_PARAM))=0 then
+ else
begin
- if (flags and ACF_NUMBER)<>0 then
- StrDupW(PWideChar(dparam),PWideChar(sparam))
- else if (flags and ACF_STRUCT)<>0 then
- StrDup(PAnsiChar(dparam),PAnsiChar(sparam))
- else if (flags and ACF_UNICODE)<>0 then
- StrDupW(PWideChar(dparam),PWideChar(sparam))
- else
- StrDupW(PWideChar(dparam),PWideChar(sparam));
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
+ StrDupW(PWideChar(dparam),PWideChar(sparam))
+ end;
+ ACF_TYPE_STRUCT: begin
+ StrDup(PAnsiChar(dparam),PAnsiChar(sparam))
+ end;
+ end;
end;
result:=flags;
end;
+{??
function TranslateParam(param:uint_ptr;flags:dword;hContact:TMCONTACT):uint_ptr;
var
tmp1:PWideChar;
@@ -666,21 +727,27 @@ begin
result:=uint_ptr(ParseVarString(PWideChar(param),hContact));
tmp1:=PWideChar(result);
- if (flags and ACF_NUMBER)=0 then
- begin
- if (flags and ACF_UNICODE)=0 then
- WideToAnsi(tmp1,PAnsiChar(result),MirandaCP)
- else
+ case flags and ACF_TYPE_MASK of
+ ACF_TYPE_NUMBER: begin
+ result:=NumToInt(tmp1);
+ end;
+ ACF_TYPE_UNICODE: begin
StrDupW(PWideChar(result),tmp1);
+ end;
+ ACF_TYPE_STRING,
+ ACF_TYPE_STRUCT: begin
+ WideToAnsi(tmp1,PAnsiChar(result),MirandaCP)
+ end;
end
else
- result:=NumToInt(tmp1);
if (flags and ACF_SCRIPT_PARAM)<>0 then
mFreeMem(tmp1);
end;
+}
-//===== result block =====
+
+//----- Result dialog -----
function ClearResultFields(Dialog:HWND):HWND;
var
@@ -693,7 +760,7 @@ begin
CheckDlgButton(Dialog,IDC_RES_FREEMEM,BST_UNCHECKED);
ShowWindow(GetDlgItem(Dialog,IDC_RES_FREEMEM),SW_HIDE);
- CB_SelectData(Dialog,IDC_RES_TYPE,ACF_RNUMBER);
+ CB_SelectData(Dialog,IDC_RES_TYPE,ACF_TYPE_NUMBER);
w:=GetDlgItem(Dialog,IDC_RES_HEXNUM);
if w<>0 then
@@ -706,11 +773,11 @@ end;
procedure MakeResultTypeList(wnd:HWND;flags:dword);
begin
SendMessage(wnd,CB_RESETCONTENT,0,0);
- InsertString(wnd,ACF_RNUMBER ,'number value');
- InsertString(wnd,ACF_RSTRING ,'ANSI string');
- InsertString(wnd,ACF_RUNICODE,'Unicode string');
- if (flags and ACF_NOSTRUCT)=0 then
- InsertString(wnd,ACF_RSTRUCT ,'structure');
+ InsertString(wnd, ACF_TYPE_NUMBER , 'number value');
+ InsertString(wnd, ACF_TYPE_STRING , 'ANSI string');
+ InsertString(wnd, ACF_TYPE_UNICODE, 'Unicode string');
+ if (flags and ACF_BLOCK_NOSTRUCT)=0 then
+ InsertString(wnd, ACF_TYPE_STRUCT, 'structure');
SendMessage(wnd,CB_SETCURSEL,0,0);
end;
@@ -759,15 +826,16 @@ begin
case loword(wParam) of
IDC_RES_TYPE: begin
case CB_GetData(lParam) of
- ACF_RNUMBER: begin
+ ACF_TYPE_NUMBER: begin
i:=SW_HIDE;
j:=SW_SHOW;
end;
- ACF_RSTRUCT: begin
+ ACF_TYPE_STRUCT: begin
i:=SW_HIDE;
j:=SW_HIDE;
end;
- ACF_RSTRING,ACF_RUNICODE: begin
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
i:=SW_SHOW;
j:=SW_HIDE;
end;
@@ -816,7 +884,7 @@ begin
yo:=0;
// group border
- if (flags and ACF_NOBORDER)=0 then
+ if (flags and ACF_BLOCK_NOBORDER)=0 then
begin
group:=CreateWindowW('BUTTON','Result',WS_CHILD+WS_VISIBLE+WS_GROUP+BS_GROUPBOX,
0,0,dx,dy, result,0,hInstance,nil);
@@ -830,7 +898,7 @@ begin
end;
// label
- if (flags and ACF_NOSTATIC)=0 then
+ if (flags and ACF_BLOCK_NOSTATIC)=0 then
begin
if width<=150 then
begin
@@ -858,7 +926,7 @@ begin
if fullline then
begin
xo:=gx;
- if (flags and ACF_NOSTATIC)=0 then
+ if (flags and ACF_BLOCK_NOSTATIC)=0 then
inc(yo,rc.bottom);
end;
ctrl:=CreateWindowW('COMBOBOX',nil,WS_CHILD+WS_VISIBLE+WS_VSCROLL+CBS_DROPDOWNLIST+CBS_AUTOHSCROLL,
@@ -876,7 +944,7 @@ begin
SendMessageW(ctrl,WM_SETFONT,hf,0);
inc(yo,rc.bottom+4);
- if (flags and ACF_NOVISUAL)=0 then
+ if (flags and ACF_BLOCK_NOVISUAL)=0 then
begin
dec(yo,rc.bottom+4);
@@ -893,7 +961,7 @@ begin
// resize group and dialog
MoveWindow(result,x,y,dx,yo,false);
- if (flags and ACF_NOBORDER)=0 then
+ if (flags and ACF_BLOCK_NOBORDER)=0 then
MoveWindow(group,0,0,dx,yo,false);
ClearResultFields(result);
@@ -907,49 +975,47 @@ var
begin
if Dialog=0 then
begin
- result:=ACF_RNUMBER;
+ result:=ACF_TYPE_NUMBER;
exit;
end;
// RESULT
+ result:=flags and ACF_TYPE_MASK;
+
sh :=SW_HIDE;
sh1:=SW_HIDE;
w:=GetDlgItem(Dialog,IDC_RES_HEXNUM);
- if (flags and ACF_RSTRUCT)<>0 then
- result:=ACF_RSTRUCT
- else if (flags and (ACF_RSTRING or ACF_RUNICODE))<>0 then
- begin
- sh:=SW_SHOW;
- if (flags and ACF_RFREEMEM)<>0 then
- btn:=BST_CHECKED
- else
- btn:=BST_UNCHECKED;
- CheckDlgButton(Dialog,IDC_RES_FREEMEM,btn);
+ case result of
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
+ sh:=SW_SHOW;
- if (flags and ACF_RUNICODE)<>0 then
- result:=ACF_RUNICODE
- else
- result:=ACF_RSTRING;
- end
- else
- begin
- result:=ACF_RNUMBER;
- if w<>0 then
- begin
- sh1:=SW_SHOW;
- if (flags and ACF_RSIGNED)<>0 then
+ if (flags and ACF_FLAG_FREEMEM)<>0 then
btn:=BST_CHECKED
else
btn:=BST_UNCHECKED;
- CheckDlgButton(Dialog,IDC_RES_SIGNED,btn);
- if (flags and ACF_RHEXNUM)<>0 then
- btn:=BST_CHECKED
- else
- btn:=BST_UNCHECKED;
- CheckDlgButton(Dialog,IDC_RES_HEXNUM,btn);
+ CheckDlgButton(Dialog,IDC_RES_FREEMEM,btn);
+ end;
+
+ ACF_TYPE_NUMBER: begin
+ if w<>0 then
+ begin
+ sh1:=SW_SHOW;
+ if (flags and ACF_FLAG_SIGNED)<>0 then
+ btn:=BST_CHECKED
+ else
+ btn:=BST_UNCHECKED;
+ CheckDlgButton(Dialog,IDC_RES_SIGNED,btn);
+ if (flags and ACF_FLAG_HEXNUM)<>0 then
+ btn:=BST_CHECKED
+ else
+ btn:=BST_UNCHECKED;
+ CheckDlgButton(Dialog,IDC_RES_HEXNUM,btn);
+ end;
end;
end;
+
ShowWindow(GetDlgItem(Dialog,IDC_RES_FREEMEM),sh);
if w<>0 then
begin
@@ -963,33 +1029,92 @@ function GetResultValue(Dialog:HWND):dword;
begin
if Dialog=0 then
begin
- result:=ACF_RNUMBER;
+ result:=ACF_TYPE_NUMBER;
exit;
end;
- case CB_GetData(GetDlgItem(Dialog,IDC_RES_TYPE)) of
- ACF_RSTRING: begin
- result:=ACF_RSTRING;
+ result:=CB_GetData(GetDlgItem(Dialog,IDC_RES_TYPE));
+ case result of
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
if IsDlgButtonChecked(Dialog,IDC_RES_FREEMEM)=BST_CHECKED then
- result:=result or ACF_RFREEMEM;
+ result:=result or ACF_FLAG_FREEMEM;
end;
- ACF_RUNICODE: begin
- result:={!!atavizm ACF_RSTRING or }ACF_RUNICODE;
- if IsDlgButtonChecked(Dialog,IDC_RES_FREEMEM)=BST_CHECKED then
- result:=result or ACF_RFREEMEM;
+ ACF_TYPE_NUMBER: begin
+ if GetDlgItem(Dialog,IDC_RES_HEXNUM)<>0 then
+ begin
+ if IsDlgButtonChecked(Dialog,IDC_RES_SIGNED)=BST_CHECKED then
+ result:=result or ACF_FLAG_SIGNED
+ else if IsDlgButtonChecked(Dialog,IDC_RES_HEXNUM)=BST_CHECKED then
+ result:=result or ACF_FLAG_HEXNUM;
+ end;
end;
- ACF_RSTRUCT: result:=ACF_RSTRUCT;
+ end;
+
+end;
+
+//--------------------------------
+
+const
+ // parameter flags
+ ACF_OLD_NUMBER = $00000001;
+ ACF_OLD_UNICODE = $00000002;
+ ACF_OLD_CURRENT = $00000004;
+
+ ACF_OLD_RESULT = $00000008;
+ ACF_OLD_PARAM = $00000010;
+ ACF_OLD_STRUCT = $00000020;
+ ACF_PARTYPE = ACF_OLD_NUMBER or ACF_OLD_UNICODE or
+ ACF_OLD_CURRENT or ACF_OLD_RESULT or
+ ACF_OLD_PARAM or ACF_OLD_STRUCT;
+ ACF_OLD_TEMPLATE = $00000800;
+ ACF_OLD_SCRIPT_PARAM = $00001000;
+ // dummy
+ ACF_OLD_STRING = 0;
+ ACF_OLD_RNUMBER = 0;
+
+ ACF_OLD_RSTRING = $00010000;
+ ACF_OLD_RUNICODE = $00020000;
+ ACF_OLD_RSTRUCT = $00040000;
+ ACF_OLD_RFREEMEM = $00080000;
+ ACF_OLD_RHEXNUM = $00100000;
+ ACF_OLD_RSIGNED = $00200000;
+
+ ACF_RTYPE = ACF_OLD_RSTRING or ACF_OLD_RUNICODE or ACF_OLD_RSTRUCT;
+
+ ACF_OLD_SCRIPT_SERVICE = $00800000;
+
+function ConvertParamFlags(flags:dword):dword;
+begin
+ case flags and ACF_PARTYPE of
+ ACF_OLD_NUMBER : result:=ACF_TYPE_NUMBER;
+ ACF_OLD_UNICODE: result:=ACF_TYPE_UNICODE;
+ ACF_OLD_CURRENT: result:=ACF_TYPE_CURRENT;
+ ACF_OLD_RESULT : result:=ACF_TYPE_RESULT;
+ ACF_OLD_PARAM : result:=ACF_TYPE_PARAM;
+ ACF_OLD_STRUCT : result:=ACF_TYPE_STRUCT;
+ ACF_OLD_STRING : result:=ACF_TYPE_STRING;
else
- result:=ACF_RNUMBER;
- if GetDlgItem(Dialog,IDC_RES_HEXNUM)<>0 then
- begin
- if IsDlgButtonChecked(Dialog,IDC_RES_SIGNED)=BST_CHECKED then
- result:=result or ACF_RSIGNED
- else if IsDlgButtonChecked(Dialog,IDC_RES_HEXNUM)=BST_CHECKED then
- result:=result or ACF_RHEXNUM;
- end;
+ result:=ACF_TYPE_NUMBER;
end;
+ if (flags and ACF_OLD_TEMPLATE )<>0 then result:=result or ACF_FLAG_TEMPLATE;
+ if (flags and ACF_OLD_SCRIPT_PARAM)<>0 then result:=result or ACF_FLAG_SCRIPT;
+end;
+function ConvertResultFlags(flags:dword):dword;
+begin
+ case flags and ACF_RTYPE of
+ ACF_OLD_RNUMBER : result:=ACF_TYPE_NUMBER;
+ ACF_OLD_RUNICODE: result:=ACF_TYPE_UNICODE;
+ ACF_OLD_RSTRUCT : result:=ACF_TYPE_STRUCT;
+ ACF_OLD_RSTRING : result:=ACF_TYPE_STRING;
+ else
+ result:=ACF_TYPE_NUMBER;
+ end;
+ if (flags and ACF_OLD_RFREEMEM)<>0 then result:=result or ACF_FLAG_FREEMEM;
+ if (flags and ACF_OLD_RHEXNUM )<>0 then result:=result or ACF_FLAG_HEXNUM;
+ if (flags and ACF_OLD_RSIGNED )<>0 then result:=result or ACF_FLAG_SIGNED;
+ if (flags and ACF_OLD_SCRIPT_SERVICE)<>0 then result:=result or ACF_FLAG_SCRIPT;
end;
end.
diff --git a/plugins/Utils.pas/srvblock.pas b/plugins/Utils.pas/srvblock.pas
index cd58f8c6c4..ac01db8190 100644
--- a/plugins/Utils.pas/srvblock.pas
+++ b/plugins/Utils.pas/srvblock.pas
@@ -6,41 +6,44 @@ unit srvblock;
interface
uses
- windows;
+ windows,
+ awkservices;
-const
- ACF_SCRIPT_SERVICE = $00800000; // high bit in low byte of hight word (lower uses in actions
- ACF_SCRIPT_EXPAND = $10000000; // all subblocks are visible (block creation only)
-
-type
- pServiceValue = ^tServiceValue;
- tServiceValue = record
- service:PAnsiChar;
- wparam,
- lparam: pointer;
- w_flag,
- l_flag,
- flags:dword; // result etc
- end;
+//----- Service dialog -----
function CreateServiceBlock(parent:HWND;x,y,width,height:integer;flags:dword=0):HWND;
-procedure ClearServiceBlock(Dialog:HWND);
+procedure ClearServiceBlock (Dialog:HWND);
procedure SetServiceListMode(Dialog:HWND;mode:integer);
function SetSrvBlockValue(Dialog:HWND;const value:tServiceValue):boolean;
function GetSrvBlockValue(Dialog:HWND;var value:tServiceValue):boolean;
-
-// service setting will load templates
+// service setting for templates
procedure SetSrvBlockService(Dialog:HWND; service:PAnsiChar);
function GetSrvBlockService(Dialog:HWND):PAnsiChar;
+//----- ServiceValue functions -----
+
+procedure CopyServiceValue (var dst :tServiceValue; const src:tServiceValue);
+procedure ClearServiceValue(var data:tServiceValue);
+procedure SaveServiceValue (const data:tServiceValue; module,setting:PAnsiChar);
+procedure LoadServiceValue (var data:tServiceValue; module,setting:PAnsiChar);
+
+//----- Service execute -----
+
+function ExecuteService(const service:tServiceValue; var data:tSubstData):boolean;
+
+
implementation
uses
messages,
- common, m_api,
+ common, m_api, syswin,
wrapper,Editwrapper,
- mApiCardM, sparam;
+ dbsettings,mApiCardM,
+ mirutils,mircontacts,
+ sparam,strans;
+
+//----- Service dialog -----
const
IDC_S_SERVICE = 2040;
@@ -177,26 +180,6 @@ begin
if pc<>nil then
begin
FillParam(GetWPar(Dialog),pc);
-(*
- if GetDlgItemTextA(Dialog,IDC_EDIT_WPAR,buf1,SizeOf(buf1))>0 then
- case FixParam(Dialog,@buf1,IDC_FLAG_WPAR) of
- ptStruct: begin
- if setvalue then
- begin
- struct:=PAnsiChar(SetWindowLongPtrW(GetDlgItem(Dialog,IDC_WSTRUCT),GWLP_USERDATA,
- long_ptr(StrDup(struct,StrScan(pc,'|')+1))));
- mFreeMem(struct);
- end;
-
-{ struct:=PAnsiChar(GetWindowLongPtrW(GetDlgItem(Dialog,IDC_WSTRUCT),GWLP_USERDATA));
- mFreeMem(struct);
- StrDup(struct,StrScan(pc,'|')+1);
- SetWindowLongPtrW(GetDlgItem(Dialog,IDC_WSTRUCT),GWLP_USERDATA,long_ptr(struct));
-// AnsiToWide(StrScan(pc,'|')+1,wstruct,MirandaCP);
-}
- end;
- end;
-*)
mFreeMem(pc);
end;
@@ -208,18 +191,12 @@ begin
end;
pc:=ApiCard.ResultType;
- flag:=ACF_RNUMBER;
+ flag:=ACF_TYPE_NUMBER;
if pc<>nil then
begin
- if lstrcmpia(pc,'struct')=0 then flag:=ACF_RSTRUCT
- else if lstrcmpia(pc,'str')=0 then
- begin
- flag:=ACF_RSTRING;
- end
- else if lstrcmpia(pc,'wide')=0 then
- begin
- flag:=ACF_RUNICODE;
- end;
+ if lstrcmpia(pc,'struct')=0 then flag:=ACF_TYPE_STRUCT
+ else if lstrcmpia(pc,'str' )=0 then flag:=ACF_TYPE_STRING
+ else if lstrcmpia(pc,'wide' )=0 then flag:=ACF_TYPE_UNICODE;
mFreeMem(pc);
end;
@@ -335,7 +312,7 @@ begin
inc(dy,rc.bottom+2);
MakeEditField(result,IDC_C_SERVICE);
- if (flags and ACF_SCRIPT_EXPAND)<>0 then
+ if (flags and ACF_BLOCK_EXPAND)<>0 then
bs:=WS_CHILD+BS_AUTOCHECKBOX+BS_PUSHLIKE
else
bs:=WS_CHILD+WS_VISIBLE+BS_AUTOCHECKBOX+BS_PUSHLIKE;
@@ -345,34 +322,34 @@ begin
ctrl:=CreateWindowW('BUTTON','wParam',bs,
0,dy,dx,rc.bottom, result,IDC_CLOSE_WPAR,hInstance,nil);
SendMessageW(ctrl,WM_SETFONT,hf,0);
- if (flags and ACF_SCRIPT_EXPAND)=0 then
+ if (flags and ACF_BLOCK_EXPAND)=0 then
inc(dy,rc.bottom+4);
wnd:=CreateParamBlock(result,0,dy,dx,flags);
SetWindowLongPtrW(ctrl,GWLP_USERDATA,wnd);
SetParamLabel(wnd,'wParam');
GetClientRect(wnd,rc1);
- if (flags and ACF_SCRIPT_EXPAND)<>0 then
+ if (flags and ACF_BLOCK_EXPAND)<>0 then
inc(dy,rc1.bottom+8);
// lParam button+block
ctrl:=CreateWindowW('BUTTON','lParam',bs,
0,dy,dx,rc.bottom, result,IDC_CLOSE_LPAR,hInstance,nil);
SendMessageW(ctrl,WM_SETFONT,hf,0);
- if (flags and ACF_SCRIPT_EXPAND)=0 then
+ if (flags and ACF_BLOCK_EXPAND)=0 then
inc(dy,rc.bottom+4);
wnd:=CreateParamBlock(result,0,dy,dx,flags);
SetWindowLongPtrW(ctrl,GWLP_USERDATA,wnd);
SetParamLabel(wnd,'lParam');
- if (flags and ACF_SCRIPT_EXPAND)<>0 then
+ if (flags and ACF_BLOCK_EXPAND)<>0 then
inc(dy,rc1.bottom+8);
// result button+block
ctrl:=CreateWindowW('BUTTON','Result',bs,
0,dy,dx,rc.bottom, result,IDC_CLOSE_RES,hInstance,nil);
SendMessageW(ctrl,WM_SETFONT,hf,0);
- if (flags and ACF_SCRIPT_EXPAND)=0 then
+ if (flags and ACF_BLOCK_EXPAND)=0 then
inc(dy,rc.bottom+4);
wnd:=CreateResultBlock(result,0,dy,dx,flags);
@@ -382,7 +359,7 @@ begin
// autoresize panel
if height=0 then
begin
- if (flags and ACF_SCRIPT_EXPAND)=0 then
+ if (flags and ACF_BLOCK_EXPAND)=0 then
begin
if rc1.bottom>rc.bottom then
h:=rc1.bottom
@@ -401,7 +378,7 @@ begin
ApiCard.FillList(srv);
SetWindowLongPtrW(srvs,GWLP_USERDATA,long_ptr(ApiCard));
- if (flags and ACF_SCRIPT_EXPAND)=0 then
+ if (flags and ACF_BLOCK_EXPAND)=0 then
ShowBlock(result,IDC_CLOSE_WPAR);
end;
@@ -413,9 +390,9 @@ begin
SetDlgItemTextA(Dialog,IDC_C_SERVICE,'');
SetEditFlags(GetDlgItem(Dialog,IDC_C_SERVICE),EF_SCRIPT,0);
- SetParamValue (GetWPar(Dialog),ACF_NUMBER,nil);
- SetParamValue (GetLPar(Dialog),ACF_NUMBER,nil);
- SetResultValue(GetRes (Dialog),ACF_RNUMBER);
+ SetParamValue (GetWPar(Dialog),ACF_TYPE_NUMBER,nil);
+ SetParamValue (GetLPar(Dialog),ACF_TYPE_NUMBER,nil);
+ SetResultValue(GetRes (Dialog),ACF_TYPE_NUMBER);
end;
procedure SetServiceListMode(Dialog:HWND;mode:integer);
@@ -445,11 +422,11 @@ begin
SetDlgItemTextA(Dialog,IDC_C_SERVICE,value.service);
SetEditFlags(GetDlgItem(Dialog,IDC_C_SERVICE),EF_SCRIPT,
- ord((value.flags and ACF_SCRIPT_SERVICE)<>0));
+ ord((value.flags and ACF_FLAG_SCRIPT)<>0));
- SetParamValue (GetWPar(Dialog),value.w_flag,value.wparam);
- SetParamValue (GetLPar(Dialog),value.l_flag,value.lparam);
- SetResultValue(GetRes (Dialog),value.flags and ACF_RTYPE);
+ SetParamValue (GetWPar(Dialog),value.w_flags,value.wparam);
+ SetParamValue (GetLPar(Dialog),value.l_flags,value.lparam);
+ SetResultValue(GetRes (Dialog),value.flags);
end;
function GetSrvBlockValue(Dialog:HWND;var value:tServiceValue):boolean;
@@ -467,12 +444,12 @@ begin
ApiCard:=GetApiCard(Dialog);
value.service:=ApiCard.NameFromList(GetDlgItem(Dialog,IDC_C_SERVICE));
- GetParamValue(GetWPar(Dialog),value.w_flag,value.wparam);
- GetParamValue(GetLPar(Dialog),value.l_flag,value.lparam);
+ GetParamValue(GetWPar(Dialog),value.w_flags,value.wparam);
+ GetParamValue(GetLPar(Dialog),value.l_flags,value.lparam);
value.flags:=GetResultValue(GetRes(Dialog));
if (GetEditFlags(Dialog,IDC_C_SERVICE) and EF_SCRIPT)<>0 then
- value.flags:=value.flags or ACF_SCRIPT_SERVICE;
+ value.flags:=value.flags or ACF_FLAG_SCRIPT;
end;
procedure SetSrvBlockService(Dialog:HWND; service:PAnsiChar);
@@ -494,4 +471,158 @@ begin
result:=GetDlgText(Dialog,IDC_C_SERVICE);
end;
+//----- ServiceValue functions -----
+
+procedure CopyServiceValue(var dst:tServiceValue; const src:tServiceValue);
+begin
+ move(src,dst,SizeOf(tServiceValue));
+ StrDup(dst.service,dst.service);
+
+ case dst.w_flags of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: StrDupW(pWideChar(dst.wparam),pWideChar(dst.wparam));
+ ACF_TYPE_STRUCT : StrDup (pAnsiChar(dst.wparam),pAnsiChar(dst.wparam));
+ end;
+
+ case dst.l_flags of
+ ACF_TYPE_NUMBER,
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: StrDupW(pWideChar(dst.lparam),pWideChar(dst.lparam));
+ ACF_TYPE_STRUCT : StrDup (pAnsiChar(dst.lparam),pAnsiChar(dst.lparam));
+ end;
+end;
+
+const
+ iosection:PAnsiChar = '/service/';
+ ioflags :PAnsiChar = 'flags';
+ ioservice:PAnsiChar = 'service';
+ iowparam :PAnsiChar = 'wparam';
+ iolparam :PAnsiChar = 'lparam';
+
+procedure SaveServiceValue(const data:tServiceValue; module,setting:PAnsiChar);
+var
+ buf:array [0..127] of AnsiChar;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(StrCopyE(buf,setting),iosection);
+ StrCopy(p,ioflags); DBWriteDWord (0,module,buf,data.flags);
+ StrCopy(p,ioservice); DBWriteString (0,module,buf,data.service);
+ StrCopy(p,iowparam); SaveParamValue(data.w_flags,data.wparam,module,buf);
+ StrCopy(p,iolparam); SaveParamValue(data.l_flags,data.lparam,module,buf);
+end;
+
+procedure LoadServiceValue(var data:tServiceValue; module,setting:PAnsiChar);
+var
+ buf:array [0..127] of AnsiChar;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(StrCopyE(buf,setting),iosection);
+ StrCopy(p,ioflags); data.flags :=DBReadDWord (0,module,buf);
+ StrCopy(p,ioservice); data.service:=DBReadString(0,module,buf);
+ StrCopy(p,iowparam); LoadParamValue(data.w_flags,data.wparam,module,buf);
+ StrCopy(p,iolparam); LoadParamValue(data.l_flags,data.lparam,module,buf);
+end;
+
+procedure ClearServiceValue(var data:tServiceValue);
+begin
+ mFreeMem(data.service);
+
+ ClearParam(data.w_flags,data.wparam);
+ ClearParam(data.l_flags,data.lparam);
+
+ FillChar(data,SizeOf(tServiceValue),0);
+end;
+
+//----- Service execute -----
+
+const
+ protostr='<proto>';
+
+function ExecuteService(const service:tServiceValue; var data:tSubstData):boolean;
+var
+ buf:array [0..255] of AnsiChar;
+ lservice:PAnsiChar;
+ lwparam,llparam:TLPARAM;
+ wp,lp:PWideChar;
+ res:int_ptr;
+begin
+ result:=false;
+
+ // Service name processing
+ if (service.flags and ACF_FLAG_SCRIPT)<>0 then
+ lservice:=ParseVarString(service.service,data.Parameter)
+ else
+ lservice:=service.service;
+
+ StrCopy(buf,lservice);
+
+ if (service.flags and ACF_FLAG_SCRIPT)<>0 then
+ mFreeMem(lservice);
+
+ if StrPos(buf,protostr)<>nil then
+ if CallService(MS_DB_CONTACT_IS,data.Parameter,0)<>0 then
+ StrReplace(buf,protostr,GetContactProtoAcc(data.Parameter))
+ else
+ Exit;
+
+ if ServiceExists(buf)<>0 then
+ begin
+ result:=true;
+
+ lwparam:=PrepareParameter(service.w_flags,TLPARAM(service.wparam),data);
+ llparam:=PrepareParameter(service.l_flags,TLPARAM(service.lparam),data);
+
+ res:=CallServiceSync(buf,lwparam,llparam);
+ ClearSubstData(data);
+
+ // result type processing
+ case service.flags and ACF_TYPE_MASK of
+ ACF_TYPE_STRING,
+ ACF_TYPE_UNICODE: begin
+ data.ResultType:=ACF_TYPE_UNICODE;
+
+ if (service.flags and ACF_TYPE_MASK)=ACF_TYPE_STRING then
+ AnsiToWide(pAnsiChar(res),pWideChar(data.LastResult),MirandaCP)
+ else
+ StrDupW(pWideChar(data.LastResult),pWideChar(res));
+
+ if (service.flags and ACF_FLAG_FREEMEM)<>0 then // Miranda Memory manager used
+ mir_free(pointer(res));
+ end;
+
+ ACF_TYPE_NUMBER: begin
+ data.LastResult:=res;
+ data.ResultType:=ACF_TYPE_NUMBER;
+ end;
+
+ ACF_TYPE_STRUCT: begin
+ data.ResultType:=ACF_TYPE_UNICODE;
+
+ if (service.w_flags and ACF_TYPE_MASK)=ACF_TYPE_STRUCT then
+ begin
+ wp:=GetStructureResult(lwparam);
+ end
+ else
+ wp:=nil;
+
+ lp:=nil;
+ if (service.l_flags and ACF_TYPE_MASK)=ACF_TYPE_STRUCT then
+ begin
+ if wp=nil then
+ lp:=GetStructureResult(llparam);
+ end;
+
+ if wp<>nil then
+ PWideChar(data.LastResult):=wp
+ else
+ PWideChar(data.LastResult):=lp;
+ end;
+ end;
+
+ ReleaseParameter(service.w_flags,lwparam);
+ ReleaseParameter(service.l_flags,llparam);
+ end;
+end;
+
end.
diff --git a/plugins/Utils.pas/strans.pas b/plugins/Utils.pas/strans.pas
index 1edc2f83ec..350f937018 100644
--- a/plugins/Utils.pas/strans.pas
+++ b/plugins/Utils.pas/strans.pas
@@ -4,6 +4,7 @@ unit strans;
interface
uses windows{$IFDEF Miranda}, m_api, mirutils{$ENDIF};
+
// <align>|[<key>]<type> [(<type alias>)] [<alias>] [arr.len] [value]|
const
char_separator = '|';
@@ -33,14 +34,7 @@ const
SF_MMI = $00000004;
SF_SIZE = $00000008;
SF_LAST = $00000080;
-type
- // int_ptr = to use aligned structure data at start
- PStructResult = ^TStructResult;
- TStructResult = record
- typ :int_ptr;
- len :int_ptr;
- offset:int_ptr;
- end;
+
type
TStructType = record
typ :integer;
@@ -69,7 +63,6 @@ const
{$ENDIF}
);
-
type
tOneElement = record
etype :integer;
@@ -84,26 +77,31 @@ type
true : (text :pointer);
end;
+//----- Editor connect -----
function GetOneElement(txt:PAnsiChar;var res:tOneElement;
SizeOnly:boolean;num:integer=0):integer;
procedure FreeElement(var element:tOneElement);
-function MakeStructure(txt:PAnsiChar;aparam,alast:LPARAM
- {$IFDEF Miranda}; restype:integer=rtInt{$ENDIF}):pointer;
+//----- Execute -----
-function GetStructureResult(var struct;atype:pinteger=nil;alen:pinteger=nil):int_ptr;
+function MakeStructure(txt:PAnsiChar;aparam,alast:LPARAM; isNumber:boolean=true):pointer;
+
+function GetStructureResult(var struct):PWideChar;
procedure FreeStructure(var struct);
+
implementation
uses common;
type
- pint_ptr = ^int_ptr;
- TWPARAM = WPARAM;
- TLPARAM = LPARAM;
+ puint64 = ^uint64;
+ pint_ptr = ^int_ptr;
+ puint_ptr = ^uint_ptr;
+ TWPARAM = WPARAM;
+ TLPARAM = LPARAM;
type
pShortTemplate = ^tShortTemplate;
@@ -113,6 +111,15 @@ type
offset:word;
end;
+type
+ // int_ptr = to use aligned structure data at start
+ PStructResult = ^TStructResult;
+ TStructResult = record
+ typ :int_ptr;
+ len :int_ptr;
+ offset:int_ptr;
+ end;
+
// adjust offset to field
function AdjustSize(var summ:int_ptr;eleadjust:integer;adjust:integer):integer;
var
@@ -120,7 +127,7 @@ var
begin
// packed, byte or array of byte
if adjust=0 then
- adjust:={$IFDEF WIN32}4{$ELSE}8{$ENDIF}; // SizeOf(int_ptr);
+ adjust:=SizeOf(pointer);
if (adjust=1) or (eleadjust=1) then
else
@@ -507,8 +514,7 @@ begin
end;
end;
-function MakeStructure(txt:PAnsiChar;aparam,alast:LPARAM
- {$IFDEF Miranda}; restype:integer=rtInt{$ENDIF}):pointer;
+function MakeStructure(txt:PAnsiChar;aparam,alast:LPARAM; isNumber:boolean=true):pointer;
var
summ:int_ptr;
lsrc:PAnsiChar;
@@ -620,7 +626,7 @@ begin
if (element.flags and SF_SCRIPT)<>0 then
begin
{$IFDEF Miranda}
- if restype=rtInt then
+ if isNumber then
pLast:=IntToStr(buf,alast)
else
pLast:=PWideChar(alast);
@@ -759,7 +765,7 @@ begin
tmpl^.flags:=tmpl^.flags or SF_LAST;
end;
-function GetStructureResult(var struct;atype:pinteger=nil;alen:pinteger=nil):int_ptr;
+function GetResultPrivate(var struct;atype:pinteger=nil;alen:pinteger=nil):uint_ptr;
var
loffset,ltype:integer;
begin
@@ -775,22 +781,63 @@ begin
SST_LAST : result:=0;
SST_PARAM: result:=0;
- SST_BYTE : result:=PByte (PAnsiChar(struct)+loffset)^;
- SST_WORD : result:=pWord (PAnsiChar(struct)+loffset)^;
- SST_DWORD : result:=pDword (PAnsiChar(struct)+loffset)^;
- SST_QWORD : result:=pint64 (PAnsiChar(struct)+loffset)^;
- SST_NATIVE: result:=pint_ptr(PAnsiChar(struct)+loffset)^;
+ SST_BYTE : result:=PByte (PAnsiChar(struct)+loffset)^;
+ SST_WORD : result:=pWord (PAnsiChar(struct)+loffset)^;
+ SST_DWORD : result:=pDword (PAnsiChar(struct)+loffset)^;
+ SST_QWORD : result:=puint64 (PAnsiChar(struct)+loffset)^;
+ SST_NATIVE: result:=puint_ptr(PAnsiChar(struct)+loffset)^;
- SST_BARR: result:=int_ptr(PAnsiChar(struct)+loffset); //??
- SST_WARR: result:=int_ptr(PAnsiChar(struct)+loffset); //??
+ SST_BARR: result:=uint_ptr(PAnsiChar(struct)+loffset); //??
+ SST_WARR: result:=uint_ptr(PAnsiChar(struct)+loffset); //??
- SST_BPTR: result:=pint_ptr(PAnsiChar(struct)+loffset)^; //??
- SST_WPTR: result:=pint_ptr(PAnsiChar(struct)+loffset)^; //??
+ SST_BPTR: result:=puint_ptr(PAnsiChar(struct)+loffset)^; //??
+ SST_WPTR: result:=puint_ptr(PAnsiChar(struct)+loffset)^; //??
else
result:=0;
end;
end;
+function GetStructureResult(var struct):PWideChar;
+var
+ buf:array [0..31] of WideChar;
+ pc:pAnsiChar;
+ data:uint_ptr;
+ code:integer;
+ len:integer;
+begin
+ data:=GetResultPrivate(struct,@code,@len);
+ case code of
+ SST_BYTE,SST_WORD,SST_DWORD,
+ SST_QWORD,SST_NATIVE: begin
+ StrDupW(result,IntToStr(buf,data));
+ end;
+
+ SST_BARR: begin
+ StrDup(pc,pAnsiChar(data),len);
+ AnsiToWide(pc,result{$IFDEF Miranda},MirandaCP{$ENDIF});
+ mFreeMem(pc);
+ end;
+
+ SST_WARR: begin
+ StrDupW(result,pWideChar(data),len);
+ end;
+
+ SST_BPTR: begin
+ AnsiToWide(pAnsiChar(data),result{$IFDEF Miranda},MirandaCP{$ENDIF});
+ end;
+
+ SST_WPTR: begin
+ StrDupW(result,pWideChar(data));
+ end;
+ else
+ result:=nil;
+ end;
+{
+ FreeStructure(struct); //??
+ uint_ptr(struct):=0;
+}
+end;
+
procedure FreeStructure(var struct);
var
value:PAnsiChar;