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
|
{ ################################################################################ }
{ # # }
{ # MirandaNG HistoryToDB Plugin v2.5 # }
{ # # }
{ # License: GPLv3 # }
{ # # }
{ # Author: Grigorev Michael (icq: 161867489, email: sleuthhound@gmail.com) # }
{ # # }
{ ################################################################################ }
unit Menu;
{$I jedi.inc}
interface
uses
Windows, Classes, SysUtils, ShellApi, MsgExport, m_api, Database, Global;
type
TMenuItem = record
Name: String;
Icon: String;
Position: Integer;
Proc: TMIRANDASERVICEPARAM;
Flags: DWord;
end;
var
MainMenuItems: Array [1..9] of TMenuItem;
MainMenuHandle: Array [1..9] of THandle;
MenuHandle: Array [1..9] of THandle;
ChildExport: TExportForm;
procedure MenuMainItemsInit; cdecl; forward;
procedure RebuildMainMenu; cdecl; forward;
{$ifdef DELPHIXE_UP}
function MainMenuSync(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuGetContactList(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuCheckUpdate(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuExportAllHistory(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuCheckMD5Hash(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuCheckAndDeleteMD5Hash(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuUpdateContactList(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuSettings(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
function MainMenuAbout(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl; forward;
{$ELSE}
function MainMenuSync(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuGetContactList(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuCheckUpdate(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuExportAllHistory(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuCheckMD5Hash(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuCheckAndDeleteMD5Hash(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuUpdateContactList(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuSettings(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
function MainMenuAbout(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl; forward;
{$endif DELPHIXE_UP}
implementation
uses Contacts, About, FSMonitor;
{ ���������� ���� }
procedure MenuMainItemsInit;
begin
MainMenuItems[1].Name := WideStringToString(GetLangStr('SyncButton'), CP_ACP);
MainMenuItems[1].Icon := 'ICON_0';
MainMenuItems[1].Position := 000000;
MainMenuItems[1].Proc := MainMenuSync;
MainMenuItems[2].Name := WideStringToString(GetLangStr('ExportAllHistoryButton'), CP_ACP);
MainMenuItems[2].Icon := '';
MainMenuItems[2].Position := 100000;
MainMenuItems[2].Proc := MainMenuExportAllHistory;
MainMenuItems[3].Name := WideStringToString(GetLangStr('GetContactListButton'), CP_ACP);
MainMenuItems[3].Icon := '';
MainMenuItems[3].Position := 100001;
MainMenuItems[3].Proc := MainMenuGetContactList;
MainMenuItems[4].Name := WideStringToString(GetLangStr('CheckMD5Hash'), CP_ACP);
MainMenuItems[4].Icon := '';
MainMenuItems[4].Position := 100002;
MainMenuItems[4].Proc := MainMenuCheckMD5Hash;
MainMenuItems[5].Name := WideStringToString(GetLangStr('CheckAndDeleteMD5Hash'), CP_ACP);
MainMenuItems[5].Icon := '';
MainMenuItems[5].Position := 100003;
MainMenuItems[5].Proc := MainMenuCheckAndDeleteMD5Hash;
MainMenuItems[6].Name := WideStringToString(GetLangStr('UpdateContactListButton'), CP_ACP);
MainMenuItems[6].Icon := '';
MainMenuItems[6].Position := 100004;
MainMenuItems[6].Proc := MainMenuUpdateContactList;
MainMenuItems[7].Name := WideStringToString(GetLangStr('CheckUpdateButton'), CP_ACP);
MainMenuItems[7].Icon := '';
MainMenuItems[7].Position := 100004;
MainMenuItems[7].Proc := MainMenuCheckUpdate;
MainMenuItems[8].Name := WideStringToString(GetLangStr('SettingsButton'), CP_ACP);
MainMenuItems[8].Icon := '';
MainMenuItems[8].Position := 200000;
MainMenuItems[8].Proc := MainMenuSettings;
MainMenuItems[9].Name := WideStringToString(GetLangStr('AboutButton'), CP_ACP);
MainMenuItems[9].Icon := '';
MainMenuItems[9].Position := 300000;
MainMenuItems[9].Proc := MainMenuAbout;
end;
{ ����������� ������� � �������� ���� }
procedure RebuildMainMenu;
var
I: Integer;
Mi: TCListMenuItem;
begin
// ������������� ��������� ����
MenuMainItemsInit;
// ������������ ����
for I := Low(MenuHandle) to High(MenuHandle) do
begin
ZeroMemory(@Mi, SizeOf(Mi));
Mi.cbSize := SizeOf(Mi);
Mi.flags := CMIM_FLAGS;
Mi.flags := Mi.flags or CMIM_NAME;
Mi.szName.a := pAnsiChar(AnsiString(MainMenuItems[I].Name));
CallService(MS_CLIST_MODIFYMENUITEM, MenuHandle[I], Windows.LPARAM(@Mi));
if EnableDebug then WriteInLog(ProfilePath, FormatDateTime('dd.mm.yy hh:mm:ss', Now) + ' - ��������� RebuildMainMenu: ' + 'MainMenuName = ' + MainMenuItems[I].Name, 2);
end;
end;
{ ���������������� ������� }
{$ifdef DELPHIXE_UP}
function MainMenuSync(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuSync(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
OnSendMessageToOneComponent('HistoryToDBSync for ' + htdIMClientName + ' ('+MyAccount+')', '002');
end;
{ ������� ������� }
{$ifdef DELPHIXE_UP}
function MainMenuExportAllHistory(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuExportAllHistory(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
if ExportFormDestroy then
ChildExport := TExportForm.Create(nil);
if not ChildExport.Showing then
ChildExport.Show
else
ChildExport.BringFormToFront(ChildExport);
end;
{ ��������� ������ ���������� � ������� ���� }
{$ifdef DELPHIXE_UP}
function MainMenuGetContactList(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuGetContactList(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
var
hContact: Cardinal;
ContactProto, ContactID, ContactName, GroupName: AnsiString;
AccountCount: Integer;
AccountName: ^PPROTOACCOUNT;
begin
// �������� ������ ���������
hContact := db_find_first();
while hContact <> 0 do
begin
ContactProto := GetContactProto(hContact);
ContactID := GetContactID(hContact, ContactProto);
ContactName := GetContactDisplayName(hContact, '', True);
GroupName := GetDBStr(hContact , 'CList' , 'Group' , GetLangStr('ContactNotInTheList'));
if ContactName = '' then
ContactName := TranslateW('Unknown Contact');
if ContactID = '' then
ContactID := TranslateW('Unknown Contact');
if not ((MatchStrings(LowerCase(ContactProto), 'skype*')) or (ContactID = TranslateW('Unknown Contact')) or MatchStrings(LowerCase(ContactProto), 'metacontacts*')) then
WriteInLog(ProfilePath, Format('%s;%s;%s;%d', [ContactID, ContactName, GroupName, StrContactProtoToInt(ContactProto)]), 3);
hContact := db_find_next(hContact);
end;
AccountCount := 0;
// ��������� ������ ���������� � ���� ProtoList.csv
if (CallService(MS_PROTO_ENUMACCOUNTS, Integer(@AccountCount), Integer(@AccountName)) = 0) and (AccountCount <> 0) then
begin
while AccountCount > 0 do
begin
if not((AccountName^.szModuleName = 'MetaContacts') or (MatchStrings(LowerCase(AccountName^.szModuleName), 'skype*'))) then
//if not MatchStrings(LowerCase(AccountName^.szModuleName), 'skype*') then
WriteInLog(ProfilePath, Format('%s;%s;%d;%s;%s;%s', [AccountName^.szModuleName, GetMyContactID(AccountName^.szModuleName), StrContactProtoToInt(AccountName^.szProtoName), GetMyContactDisplayName(AccountName^.szModuleName), '', '']), 4);
Inc(AccountName);
Dec(AccountCount);
end;
end;
// ��������� �����
if ContactListLogOpened then
CloseLogFile(3);
if ProtoListLogOpened then
CloseLogFile(4);
Result := 0;
if (FileExists(ProfilePath + ContactListName)) and (FileExists(ProfilePath + ProtoListName)) then
MsgInf(htdPluginShortName, GetLangStr('SaveContactListCompleted'))
else
MsgInf(htdPluginShortName, GetLangStr('SaveContactListErr'));
end;
{ ��������� ���������� MD5-����� }
{$ifdef DELPHIXE_UP}
function MainMenuCheckMD5Hash(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuCheckMD5Hash(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
OnSendMessageToOneComponent('HistoryToDBSync for ' + htdIMClientName + ' ('+MyAccount+')', '0050');
end;
{ ��������� ���������� MD5-����� � �������� ���������� }
{$ifdef DELPHIXE_UP}
function MainMenuCheckAndDeleteMD5Hash(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuCheckAndDeleteMD5Hash(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
OnSendMessageToOneComponent('HistoryToDBSync for ' + htdIMClientName + ' ('+MyAccount+')', '0051');
end;
{ ������ �� ���������� ������� ����� }
{$ifdef DELPHIXE_UP}
function MainMenuUpdateContactList(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuUpdateContactList(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
if FileExists(ProfilePath+ContactListName) then
OnSendMessageToOneComponent('HistoryToDBSync for ' + htdIMClientName + ' ('+MyAccount+')', '007')
else
MsgInf(htdPluginShortName, Format(GetLangStr('SendUpdateContactListErr'), [ContactListName]));
end;
{ ��������� ���������� }
{$ifdef DELPHIXE_UP}
function MainMenuCheckUpdate(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuCheckUpdate(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
var
WinName: String;
begin
// ���� ���� HistoryToDBUpdater
WinName := 'HistoryToDBUpdater';
if not SearchMainWindow(pWideChar(WinName)) then // ���� HistoryToDBUpdater �� ������, �� ���� ������ ����
begin
WinName := 'HistoryToDBUpdater for ' + htdIMClientName + ' ('+MyAccount+')';
if not SearchMainWindow(pWideChar(WinName)) then // ���� HistoryToDBUpdater �� �������, �� ���������
begin
if FileExists(PluginPath + 'HistoryToDBUpdater.exe') then
begin
// ��������� ������
ShellExecute(0, 'open', PWideChar(PluginPath + 'HistoryToDBUpdater.exe'), PWideChar(' "'+ProfilePath+'"'), nil, SW_SHOWNORMAL);
end
else
MsgInf(htdPluginShortName, Format(GetLangStr('ERR_NO_FOUND_UPDATER'), [PluginPath + 'HistoryToDBUpdater.exe']));
end
else // ����� �������� ������
OnSendMessageToOneComponent(WinName, '0040');
end
else // ����� �������� ������
OnSendMessageToOneComponent(WinName, '0040');
end;
{ ���������� ���� �������� ������� }
{$ifdef DELPHIXE_UP}
function MainMenuSettings(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuSettings(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
var
WinName: String;
begin
Result := 0;
// ���� ���� HistoryToDBViewer
WinName := 'HistoryToDBViewer';
if not SearchMainWindow(pWideChar(WinName)) then // ���� HistoryToDBViewer �� ������, �� ���� ������ ����
begin
WinName := 'HistoryToDBViewer for ' + htdIMClientName + ' ('+MyAccount+')';
if not SearchMainWindow(pWideChar(WinName)) then // ���� HistoryToDBViewer �� �������, �� ���������
begin
if FileExists(PluginPath + 'HistoryToDBViewer.exe') then
begin
// ��������� ������ �� ����� ��������
StopWatch;
WriteCustomINI(ProfilePath, 'SettingsFormRequestSend', '1');
StartWatch(ProfilePath, FILE_NOTIFY_CHANGE_LAST_WRITE, False, @ProfileDirChangeCallBack);
ShellExecute(0, 'open', PWideChar(PluginPath + 'HistoryToDBViewer.exe'), PWideChar(' "'+PluginPath+'" "'+ProfilePath+'" 4'), nil, SW_SHOWNORMAL);
end
else
MsgInf(htdPluginShortName, Format(GetLangStr('ERR_NO_FOUND_VIEWER'), [PluginPath + 'HistoryToDBViewer.exe']));
end
else // ����� �������� ������
OnSendMessageToOneComponent(WinName, '005');
end
else // ����� �������� ������ �� ����� ��������
OnSendMessageToOneComponent(WinName, '005');
end;
{ ���������� ���� � ������� }
{$ifdef DELPHIXE_UP}
function MainMenuAbout(wParam: wParam; lParam: lParam; lParam1: LPARAM): int_ptr; cdecl;
{$ELSE}
function MainMenuAbout(wParam: wParam; lParam: lParam; lParam1: integer): integer; cdecl;
{$endif DELPHIXE_UP}
begin
Result := 0;
AboutForm.Show;
end;
end.
|