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
|
(*
History++ plugin for Miranda IM: the free IM client for Microsoft* Windows*
Copyright (C) 2006-2009 theMIROn, 2003-2006 Art Fedorov.
History+ parts (C) 2001 Christian Kastner
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
{ -----------------------------------------------------------------------------
hpp_services (historypp project)
Version: 1.5
Created: 05.08.2004
Author: Oxygen
[ Description ]
Module with history's own services
[ History ]
1.5 (05.08.2004)
First version
[ Modifications ]
none
[ Known Issues ]
none
Contributors: theMIROn, Art Fedorov
----------------------------------------------------------------------------- }
unit hpp_services;
interface
uses
Classes, Windows, Controls,
m_api,
HistoryForm, PassForm, PassCheckForm;
var
hHppRichEditItemProcess: THandle;
HstWindowList: TList;
PassFm: TfmPass;
PassCheckFm: TfmPassCheck;
procedure hppRegisterServices;
procedure hppUnregisterServices;
procedure CloseGlobalSearchWindow;
procedure CloseHistoryWindows;
function FindContactWindow(hContact: THandle): THistoryFrm;
function OpenContactHistory(hContact: THandle; Index: Integer = -1): THistoryFrm;
function AllHistoryRichEditProcess(wParam: WPARAM; lParam: LPARAM): Int; cdecl;
implementation
uses
SysUtils, GlobalSearch, EmptyHistoryForm,
hpp_global, {hpp_database,} hpp_itemprocess, hpp_forms,
hpp_options{, hpp_mescatcher, hpp_bookmarks};
// our own processing of RichEdit for all history windows
function AllHistoryRichEditProcess(wParam { hRichEdit } : WPARAM; lParam { PItemRenderDetails } : LPARAM): Int; cdecl;
begin
Result := 0;
if GridOptions.SmileysEnabled then Result := Result or DoSupportSmileys(wParam, lParam);
if GridOptions.MathModuleEnabled then Result := Result or DoSupportMathModule(wParam, lParam);
if GridOptions.AvatarsHistoryEnabled then Result := Result or DoSupportAvatarHistory(wParam, lParam);
end;
procedure CloseHistoryWindows;
var
i: Integer;
begin
try
for i := HstWindowList.Count - 1 downto 0 do
THistoryFrm(HstWindowList[i]).Free;
except
end;
end;
procedure CloseGlobalSearchWindow;
begin
try
if Assigned(fmGlobalSearch) then
fmGlobalSearch.Free;
except
end;
end;
function FindContactWindow(hContact: THandle): THistoryFrm;
var
i: Integer;
begin
Result := nil;
for i := 0 to HstWindowList.Count - 1 do
begin
if THistoryFrm(HstWindowList[i]).hContact = hContact then
begin
Result := THistoryFrm(HstWindowList[i]);
break;
end;
end;
end;
function OpenContactHistory(hContact: THandle; Index: Integer = -1): THistoryFrm;
var
wHistory: THistoryFrm;
NewWindow: Boolean;
begin
// check if window exists, otherwise create one
wHistory := FindContactWindow(hContact);
NewWindow := not Assigned(wHistory);
if NewWindow then
begin
wHistory := THistoryFrm.Create(nil);
HstWindowList.Add(wHistory);
wHistory.WindowList := HstWindowList;
wHistory.hg.Options := GridOptions;
wHistory.hContact := hContact;
wHistory.Load;
end;
if Index <> -1 then
begin
wHistory.ShowAllEvents;
wHistory.ShowItem(index);
end;
if NewWindow then
wHistory.Show
else
BringFormToFront(wHistory); // restore even if minimized
Result := wHistory;
end;
// MS_HISTORY_SHOWCONTACTHISTORY service
// show history called by miranda
function HppShowHistory(wParam { hContact } : WPARAM; lParam { 0 } : LPARAM): uint_ptr; cdecl;
begin
OpenContactHistory(wParam);
Result := 0;
end;
// MS_HPP_GETVERSION service
// See m_historypp.inc for details
function HppGetVersion(wParam { 0 } : WPARAM; lParam { 0 } : LPARAM): uint_ptr; cdecl;
begin
Result := hppVersion;
end;
// MS_HPP_SHOWGLOBALSEARCH service
// See m_historypp.inc for details
function HppShowGlobalSearch(wParam { 0 } : WPARAM; lParam { 0 } : LPARAM): uint_ptr; cdecl;
begin
if not Assigned(fmGlobalSearch) then
begin
fmGlobalSearch := TfmGlobalSearch.Create(nil);
fmGlobalSearch.hg.Options := GridOptions;
fmGlobalSearch.Show;
end
else
BringFormToFront(fmGlobalSearch);
Result := 0;
end;
// MS_HPP_OPENHISTORYEVENT service
// See m_historypp.inc for details
function HppOpenHistoryEvent(wParam { POpenEventParams } : WPARAM; lParam: LPARAM): uint_ptr; cdecl;
var
wHistory: THistoryFrm;
hDbEvent: THandle;
item, sel: Integer;
oep: TOpenEventParams;
begin
if Assigned(POpenEventParams(wParam)) then
begin
oep := POpenEventParams(wParam)^;
hDbEvent := db_event_last(oep.hContact);
item := 0;
sel := -1;
while (hDbEvent <> oep.hDbEvent) and (hDbEvent <> 0) do
begin
hDbEvent := db_event_prev(hDbEvent);
Inc(item);
end;
if hDbEvent = oep.hDbEvent then
sel := item;
wHistory := OpenContactHistory(oep.hContact, sel);
if wHistory.PasswordMode then
if (oep.pPassword <> nil) and CheckPassword(oep.pPassword) then
wHistory.PasswordMode := False;
Result := int_ptr(not wHistory.PasswordMode);
end
else
Result := 0;
end;
// MS_HPP_EMPTYHISTORY service
// See m_historypp.inc for details
function HppEmptyHistory(wParam { hContact } : WPARAM; lParam { 0 } : LPARAM): uint_ptr; cdecl;
var
wHistory: THistoryFrm;
begin
wHistory := FindContactWindow(wParam);
with TEmptyHistoryFrm.Create(wHistory) do
begin
Contact := wParam;
Result := int_ptr(ShowModal = mrYes);
Free;
end;
end;
procedure hppRegisterServices;
begin
HstWindowList := TList.Create;
CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY,@HppShowHistory);
CreateServiceFunction(MS_HPP_EMPTYHISTORY, @HppEmptyHistory);
CreateServiceFunction(MS_HPP_GETVERSION, @HppGetVersion);
CreateServiceFunction(MS_HPP_SHOWGLOBALSEARCH,@HppShowGlobalSearch);
CreateServiceFunction(MS_HPP_OPENHISTORYEVENT,@HppOpenHistoryEvent);
hHppRichEditItemProcess := CreateHookableEvent(ME_HPP_RICHEDIT_ITEMPROCESS);
HookEvent(ME_HPP_RICHEDIT_ITEMPROCESS,AllHistoryRichEditProcess);
end;
procedure hppUnregisterServices;
begin
CloseHistoryWindows;
CloseGlobalSearchWindow;
DestroyHookableEvent(hHppRichEditItemProcess);
HstWindowList.Free;
end;
end.
|