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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
{$IFDEF M_API_UNIT}
//----- CListint -----
function IsHContactGroup (h:TMCONTACT):bool;
function IsHContactInfo (h:TMCONTACT):bool;
function IsHContactContact(h:TMCONTACT):bool;
function CLCDEFAULT_BKCOLOUR:dword;
function CLCDEFAULT_TEXTCOLOUR:dword;
function CLCDEFAULT_SELBKCOLOUR:dword;
function CLCDEFAULT_SELTEXTCOLOUR:dword;
function CLCDEFAULT_HOTTEXTCOLOUR:dword;
function CreateVersionString(version:dword;buf:PAnsiChar):PAnsiChar;
function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsiChar;
function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
function Netlib_CloseHandle(Handle: THANDLE): int;
function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
function mir_hashstr (const key:PAnsiChar):uint; {inline;}
function mir_hashstrW(const key:PWideChar):uint; {inline;}
function lrtrim (str:PAnsiChar):PAnsiChar; {inline}
function lrtrimp(str:PAnsiChar):PAnsiChar; {inline}
function mir_utf8decodeA(const src:PAnsiChar):PAnsiChar; {inline}
function Translate (sz: PAnsiChar): PAnsiChar;
function Translatew(sz: PWideChar): PWideChar;
function TranslateString (const sz:AnsiString):AnsiString;
function TranslateWideString(const sz:WideString):WideString;
function TranslateUnicodeString(sz: UnicodeString): UnicodeString;
procedure TranslateDialogDefault(hwndDlg: THANDLE);
procedure TranslateMenu(hMenu: HMENU);
function Langpack_Register:int_ptr;
function CreateProtoServiceFunction(const szModule, szService: PAnsiChar; serviceProc: TMIRANDASERVICE): int_ptr;
function Srmm_AddIcon (sid: PStatusIconData):int_ptr;
procedure Srmm_RemoveIcon(sid: PStatusIconData);
procedure Srmm_ModifyIcon(hContact:TMCONTACT; sid:PStatusIconData);
function Srmm_GetNthIcon(hContact:TMCONTACT; index:int):pStatusIconData;
function SkinAddNewSound(const name, description, defaultFile: PAnsiChar): int_ptr;
function SkinPlaySound (const name: PAnsiChar): int_ptr;
function Menu_AddContextFrameMenuItem(mi:PMO_MenuItem):HGENMENU;
function Menu_AddMainMenuItem (mi:PMO_MenuItem):HGENMENU;
function Menu_AddContactMenuItem (mi:PMO_MenuItem):HGENMENU;
function Menu_AddStatusMenuItem (mi:PMO_MenuItem):HGENMENU;
function Menu_AddProtoMenuItem (mi:PMO_MenuItem):HGENMENU;
function Menu_AddTrayMenuItem (mi:PMO_MenuItem):HGENMENU;
procedure SET_UID(pmi:PMO_MenuItem; strguid:PAnsiChar);
function UserInfo_AddPage(wParam:WPARAM; odp:POPTIONSDIALOGPAGE):int_ptr;
function Options_AddPage (wParam:WPARAM; odp:POPTIONSDIALOGPAGE):int_ptr;
function Hotkey_Register(hk:PHOTKEYDESC):int_ptr;
function Skin_AddIcon(si:PSKINICONDESC):THANDLE;
procedure Icon_Register (hInst:HINST; const szSection:PAnsiChar; pIcons:pIconItem ; iCount:size_t; prefix:PAnsiChar);
procedure Icon_RegisterW(hInst:HINST; const szSection:PWideChar; pIcons:pIconItemW; iCount:size_t; prefix:PAnsiChar);
procedure FontRegister (pFontID:pFontID);
procedure FontRegisterW(pFontID:pFontIDW);
procedure ColourRegister (pColorID:pColourID);
procedure ColourRegisterW(pColorID:pColourIDW);
procedure EffectRegister (pEffectID:pEffectID);
procedure EffectRegisterW(pEffectID:pEffectIDW);
function TopToolbar_AddButton(pButton:PTTBButton):THANDLE;
function Options_Open (ood:POPENOPTIONSDIALOG):int_ptr;
function Options_OpenPage(ood:POPENOPTIONSDIALOG):HWND;
procedure MIcoTab_AddItem (hwnd:HWND; lptzName:PAnsiChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool);
procedure MIcoTab_AddItemW(hwnd:HWND; lptzName:PWideChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool);
function Crypto_RegisterEngine(pProvider:PCRYPTO_PROVIDER):THANDLE;
procedure Crypto_EnumProviders(var numProvs:int; var pResult:array of PCRYPTO_PROVIDER);
function Crypto_GetProvider(pszName:PAnsiChar):PCRYPTO_PROVIDER;
{$ELSE}
var
hLangpack:int = 0;
function _AddMainMenuItem(mi:PMO_MenuItem) : HGENMENU; stdcall;
external AppDll name 'Menu_AddMainMenuItem';
function _AddContactMenuItem(mi:PMO_MenuItem; pszProto:PAnsiChar) : HGENMENU; stdcall;
external AppDll name 'Menu_AddContactMenuItem';
function _AddProtoMenuItem(mi:PMO_MenuItem; pszProto:PAnsiChar) : HGENMENU; stdcall;
external AppDll name 'Menu_AddProtoMenuItem';
function _AddStatusMenuItem(mi:PMO_MenuItem; pszProto:PAnsiChar) : HGENMENU; stdcall;
external AppDll name 'Menu_AddStatusMenuItem';
function _AddTrayMenuItem(mi:PMO_MenuItem) : HGENMENU; stdcall;
external AppDll name 'Menu_AddTrayMenuItem';
//----- CListint -----
function IsHContactGroup(h:TMCONTACT):bool;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=(h xor HCONTACT_ISGROUP)<(HCONTACT_ISGROUP xor HCONTACT_ISINFO);
end;
function IsHContactInfo(h:TMCONTACT):bool;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=(h and HCONTACT_ISINFO)=HCONTACT_ISINFO;
end;
function IsHContactContact(h:TMCONTACT):bool;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=(h and HCONTACT_ISGROUP)=0;
end;
function CLCDEFAULT_BKCOLOUR:dword;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=GetSysColor(COLOR_3DFACE);
end;
function CLCDEFAULT_TEXTCOLOUR:dword;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=GetSysColor(COLOR_WINDOWTEXT);
end;
function CLCDEFAULT_SELBKCOLOUR:dword;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=GetSysColor(COLOR_HIGHLIGHT);
end;
function CLCDEFAULT_SELTEXTCOLOUR:dword;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=GetSysColor(COLOR_HIGHLIGHTTEXT);
end;
function CLCDEFAULT_HOTTEXTCOLOUR:dword;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=RGB(0,0,255);
end;
function CreateVersionString(version:dword;buf:PAnsiChar):PAnsiChar;
var
vers:array [0..3] of integer;
begin
vers[0]:=(version shr 24) and $FF;
vers[1]:=(version shr 16) and $FF;
vers[2]:=(version shr 8) and $FF;
vers[3]:=version and $FF;
wvsprintfa(buf,'%d.%d.%d.%d',@vers);
result:=buf;
end;
function CreateVersionStringPlugin(pluginInfo:PPluginInfoEx;buf:PAnsiChar):PAnsiChar;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=CreateVersionString(pluginInfo^.version,buf);
end;
function PLUGIN_MAKE_VERSION(a,b,c,d: Cardinal): int;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
Result := (a shl 24) or (b shl 16) or (c shl 8) or d;
end;
function PLUGIN_CMP_VERSION(verA: LongInt; verB: LongInt): int;
begin
Result := 0;
{ could be used to compare for severity of age for positive values, if a<b
results are minus values, 0 for equal, positive if a is newer }
Inc(Result, (verA and $FF ) - (verB and $FF));
Inc(Result, (verA and $FF00 ) - (verB and $FF00));
Inc(Result, (verA and $FF0000 ) - (verB and $FF0000));
Inc(Result, (verA and $FF000000) - (verB and $FF000000));
end;
function Netlib_CloseHandle(Handle: THANDLE): int;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
Result := CallService(MS_NETLIB_CLOSEHANDLE, Handle, 0);
end;
function Netlib_GetBase64DecodedBufferSize(const cchEncoded: int): int;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
Result := (cchEncoded shr 2) * 3;
end;
function Netlib_GetBase64EncodedBufferSize(const cbDecoded: int): int;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
Result := (cbDecoded * 4+11) div 12*4+1;
end;
function Netlib_Send(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
var
nlb: TNETLIBBUFFER;
begin
nlb.buf := buf;
nlb.len := len;
nlb.flags := flags;
Result := CallService(MS_NETLIB_SEND, wParam(hConn), lParam(@nlb));
end;
function Netlib_Recv(hConn: THANDLE; const buf: PAnsiChar; len: int; flags: int): int_ptr;
var
nlb: TNETLIBBUFFER;
begin
nlb.buf := buf;
nlb.len := len;
nlb.flags := flags;
Result := CallService(MS_NETLIB_RECV, wParam(hConn), lParam(@nlb));
end;
procedure Netlib_Log(hNetLib: THANDLE; const sz: PAnsiChar);
{$IFDEF AllowInline}inline;{$ENDIF}
begin
CallService(MS_NETLIB_LOG, hNetLib, lParam(sz));
end;
function mir_hashstr(const key:PAnsiChar):uint; {inline;}
var
len:int;
begin
if key=NIL then
result:=0
else
begin
len:=lstrlena(key);
result:=mir_hash(key, len);
end;
end;
function mir_hashstrW(const key:PWideChar):uint; {inline;}
var
len:int;
begin
if key=NIL then
result:=0
else
begin
len:=lstrlenw(key);
result:=mir_hash(key, len*SizeOF(WideChar));
end;
end;
function lrtrim(str:PAnsiChar):PAnsiChar;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=ltrim(rtrim(str));
end;
function lrtrimp(str:PAnsiChar):PAnsiChar;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=ltrimp(rtrim(str));
end;
function mir_utf8decodeA(const src:PAnsiChar):PAnsiChar;
type
pPWideChar = ^PWidechar;
var
tmp:PAnsiChar;
begin
tmp:=mir_strdup(src);
mir_utf8decode(tmp,pPWideChar(nil)^);
result:=tmp;
end;
function TranslateW(sz: PWideChar): PWideChar;
begin
result:=TranslateW_LP(sz, hLangpack);
end;
function Translate(sz: PAnsiChar): PAnsiChar;
begin
result:=TranslateA_LP(sz, hLangpack);
end;
function TranslateString(const sz:AnsiString):AnsiString;
begin
Result:=AnsiString(TranslateA_LP(PAnsiChar(sz),hLangpack));
end;
function TranslateWideString(const sz:WideString):WideString;
begin
Result:=WideString(TranslateW_LP(PWideChar(sz),hLangpack));
end;
function TranslateUnicodeString(sz: UnicodeString): UnicodeString;
begin
Result:=UnicodeString(TranslateW_LP(PWideChar(sz),hLangpack));
end;
procedure TranslateDialogDefault(hwndDlg: THANDLE);
begin
TranslateDialog_LP(hwndDlg,hLangpack);
end;
procedure TranslateMenu(hMenu: HMENU);
begin
TranslateMenu_LP(hMenu,hLangpack);
end;
function Langpack_Register:int_ptr;
begin
mir_getLP(PluginInfo, hLangpack);
result:=hLangpack;
end;
function CreateProtoServiceFunction(const szModule, szService: PAnsiChar; serviceProc: TMIRANDASERVICE): int_ptr;
var
szStr: array [0..MAXMODULELABELLENGTH*2] of AnsiChar;
begin
if (szModule=nil) or (szService=nil) then
begin
result:=0;
exit;
end;
lstrcpya(@szStr, szModule);
lstrcata(@szStr, szService);
Result := CreateServiceFunction(szStr, @serviceProc);
end;
// Hidden variable hLangpack - do not use Inline style
function Srmm_AddIcon(sid: PStatusIconData):int_ptr;
begin
result:=CallService(MS_MSG_ADDICON, hLangpack, LPARAM(sid));
end;
procedure Srmm_RemoveIcon(sid: PStatusIconData);
{$IFDEF AllowInline}inline;{$ENDIF}
begin
CallService(MS_MSG_REMOVEICON, 0, LPARAM(sid));
end;
procedure Srmm_ModifyIcon(hContact:TMCONTACT; sid:PStatusIconData);
{$IFDEF AllowInline}inline;{$ENDIF}
begin
CallService(MS_MSG_GETNTHICON, hContact, LPARAM(sid));
end;
function Srmm_GetNthIcon(hContact:TMCONTACT; index:int):PStatusIconData;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
result:=PStatusIconData(CallService(MS_MSG_GETNTHICON, hContact, index));
end;
function SkinAddNewSound(const name, description, defaultFile: PAnsiChar): int_ptr;
var
ssd: TSKINSOUNDDESCEX;
begin
FillChar(ssd,SizeOf(ssd),0);
ssd.cbSize := sizeof(ssd);
ssd.pszName := name;
ssd.pszDescription.a := description;
ssd.pszDefaultFile.a := defaultFile;
Result := CallService(MS_SKIN_ADDNEWSOUND, hLangpack, lParam(@ssd));
end;
function SkinPlaySound (const name: PAnsiChar): int_ptr;
{$IFDEF AllowInline}inline;{$ENDIF}
begin
Result := CallService(MS_SKIN_PLAYSOUND, 0, lParam(name));
end;
function Menu_AddContextFrameMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=CallService(MS_CLIST_ADDCONTEXTFRAMEMENUITEM, 0,LPARAM(mi));
end;
function Menu_AddMainMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=_AddMainMenuItem(mi);
end;
function Menu_AddContactMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=_AddContactMenuItem(mi, nil);
end;
function Menu_AddStatusMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=_AddStatusMenuItem(mi, nil);
end;
function Menu_AddProtoMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=_AddProtoMenuItem(mi, nil);
end;
function Menu_AddTrayMenuItem(mi:PMO_MenuItem):HGENMENU;
begin
mi^.hLangpack:=hLangpack;
result:=_AddTrayMenuItem(mi);
end;
function UserInfo_AddPage(wParam:WPARAM; odp:POPTIONSDIALOGPAGE):int_ptr;
begin
odp^.hLangpack:=hLangpack;
result:=CallService(MS_USERINFO_ADDPAGE, wParam, LPARAM(odp));
end;
function Options_AddPage(wParam:WPARAM; odp:POPTIONSDIALOGPAGE):int_ptr;
begin
odp^.hLangpack:=hLangpack;
result:=CallService(MS_OPT_ADDPAGE, wParam, LPARAM(odp));
end;
function Hotkey_Register(hk:PHOTKEYDESC):int_ptr;
begin
result:=CallService(MS_HOTKEY_REGISTER, hLangpack, LPARAM(hk));
end;
function Skin_AddIcon(si:PSKINICONDESC):THANDLE;
begin
result:=IcoLib_AddIcon(si, hLangpack);
end;
procedure Icon_Register(hInst:HINST; const szSection:PAnsiChar; pIcons:pIconItem; iCount:size_t; prefix:PAnsiChar);
begin
mir_Icon_Register(hInst, szSection, pIcons, iCount, prefix, hLangpack);
end;
procedure Icon_RegisterW(hInst:HINST; const szSection:PWideChar; pIcons:pIconItemW; iCount:size_t; prefix:PAnsiChar);
begin
mir_Icon_RegisterW(hInst, szSection, pIcons, iCount, prefix, hLangpack);
end;
procedure FontRegister(pFontID:pFontID);
begin
CallService(MS_FONT_REGISTERA, WPARAM(pFontID), hLangpack);
end;
procedure FontRegisterW(pFontID:pFontIDW);
begin
CallService(MS_FONT_REGISTERW, WPARAM(pFontID), hLangpack);
end;
procedure ColourRegister(pColorID:pColourID);
begin
CallService(MS_COLOUR_REGISTERA, WPARAM(pColorID), hLangpack);
end;
procedure ColourRegisterW(pColorID:pColourIDW);
begin
CallService(MS_COLOUR_REGISTERW, WPARAM(pColorID), hLangpack);
end;
procedure EffectRegister(pEffectID:pEffectID);
begin
CallService(MS_EFFECT_REGISTERA, WPARAM(pEffectID), hLangpack);
end;
procedure EffectRegisterW(pEffectID:pEffectIDW);
begin
CallService(MS_EFFECT_REGISTERW, WPARAM(pEffectID), hLangpack);
end;
function TopToolbar_AddButton(pButton:PTTBButton):THANDLE;
begin
result:=CallService(MS_TTB_ADDBUTTON, WPARAM(pButton), hLangpack);
end;
function Options_Open(ood:POPENOPTIONSDIALOG):int_ptr;
begin
result:=CallService(MS_OPT_OPENOPTIONS, hLangpack, LPARAM(ood));
end;
function Options_OpenPage(ood:POPENOPTIONSDIALOG):HWND;
begin
result:=CallService(MS_OPT_OPENOPTIONSPAGE, hLangpack, LPARAM(ood));
end;
procedure MIcoTab_AddItem(hwnd:HWND; lptzName:PAnsiChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool);
var
mit:tMIcoTab;
begin
if bSharedIcon then
mit.flag := MITCF_SHAREDICON
else
mit.flag := 0;
mit.hIcon := hIcon;
mit.szName.a := lptzName;
mit.data := data;
SendMessage(hwnd, ITCM_ADDITEM, WPARAM(@mit), 0);
end;
procedure MIcoTab_AddItemW(hwnd:HWND; lptzName:PWideChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool);
var
mit:tMIcoTab;
begin
if bSharedIcon then
mit.flag := MITCF_SHAREDICON or MITCF_UNICODE
else
mit.flag := MITCF_UNICODE;
mit.hIcon := hIcon;
mit.szName.w := lptzName;
mit.data := data;
SendMessage(hwnd, ITCM_ADDITEM, WPARAM(@mit), 0);
end;
function Crypto_RegisterEngine(pProvider:PCRYPTO_PROVIDER):THANDLE;
begin
result:=THANDLE(CallService(MS_CRYPTO_REGISTER_ENGINE, hLangpack, LPARAM(pProvider)));
end;
procedure Crypto_EnumProviders(var numProvs:int; var pResult:array of PCRYPTO_PROVIDER);
begin
CallService(MS_CRYPTO_ENUM_PROVIDERS, WPARAM(numProvs), LPARAM(@pResult));
end;
function Crypto_GetProvider(pszName:PAnsiChar):PCRYPTO_PROVIDER;
begin
result:=PCRYPTO_PROVIDER(CallService(MS_CRYPTO_GET_PROVIDER, 0, LPARAM(pszName)));
end;
function UuidFromStringA(StringUuid:PAnsiChar; var Uuid:TGUID) : integer; stdcall; external 'Rpcrt4.dll';
procedure SET_UID(pmi:PMO_MenuItem; strguid:PAnsiChar);
begin
UuidFromStringA(strguid, pmi.uid);
end;
initialization
cli:=PCLIST_INTERFACE(CallService(MS_CLIST_RETRIEVE_INTERFACE,0,0));
{$ENDIF}
|