summaryrefslogtreecommitdiff
path: root/plugins/Utils.pas/awkservices.pas
blob: 4ab6f851cb2c33e1c11ede347023aa0874416ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
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.