summaryrefslogtreecommitdiff
path: root/plugins/QuickSearch
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/QuickSearch
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/QuickSearch')
-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
4 files changed, 118 insertions, 136 deletions
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;