diff options
author | Alexey Kulakov <panda75@bk.ru> | 2012-07-04 13:17:29 +0000 |
---|---|---|
committer | Alexey Kulakov <panda75@bk.ru> | 2012-07-04 13:17:29 +0000 |
commit | a5a3db4393d85407ff4c5668d88860e06158abd0 (patch) | |
tree | bcc8f716833034e33984a539ab7d1debfdd6a7d3 /plugins/HistoryPlusPlus/hpp_services.pas | |
parent | 88ec2ae53ddc811d08763b2fb3a0073b571a321c (diff) |
History++ sources upload (all files, no project)
git-svn-id: http://svn.miranda-ng.org/main/trunk@756 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryPlusPlus/hpp_services.pas')
-rw-r--r-- | plugins/HistoryPlusPlus/hpp_services.pas | 265 |
1 files changed, 265 insertions, 0 deletions
diff --git a/plugins/HistoryPlusPlus/hpp_services.pas b/plugins/HistoryPlusPlus/hpp_services.pas new file mode 100644 index 0000000000..378f2aa382 --- /dev/null +++ b/plugins/HistoryPlusPlus/hpp_services.pas @@ -0,0 +1,265 @@ +(*
+ 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,
+ hpp_options,
+ HistoryForm, PassForm, PassCheckForm;
+
+var
+ hAllHistoryRichEditProcess,
+ hHppShowHistory,
+ hHppEmptyHistory,
+ hHppGetVersion,
+ hHppShowGlobalSearch,
+ hHppOpenHistoryEvent,
+ 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_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): int_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): int_ptr; cdecl;
+begin
+ Result := hppVersion;
+end;
+
+// MS_HPP_SHOWGLOBALSEARCH service
+// See m_historypp.inc for details
+function HppShowGlobalSearch(wParam { 0 } : WPARAM; lParam { 0 } : LPARAM): int_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): int_ptr; cdecl;
+var
+ wHistory: THistoryFrm;
+ hDbEvent: THandle;
+ item, sel: Integer;
+ oep: TOpenEventParams;
+begin
+ if Assigned(POpenEventParams(wParam)) then
+ begin
+ oep := POpenEventParams(wParam)^;
+ hDbEvent := CallService(MS_DB_EVENT_FINDLAST, oep.hContact, 0);
+ item := 0;
+ sel := -1;
+ while (hDbEvent <> oep.hDbEvent) and (hDbEvent <> 0) do
+ begin
+ hDbEvent := CallService(MS_DB_EVENT_FINDPREV, hDbEvent, 0);
+ 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): int_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;
+
+ hHppShowHistory := CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY,HppShowHistory);
+ hHppEmptyHistory := CreateServiceFunction(MS_HPP_EMPTYHISTORY, HppEmptyHistory);
+ hHppGetVersion := CreateServiceFunction(MS_HPP_GETVERSION, HppGetVersion);
+ hHppShowGlobalSearch := CreateServiceFunction(MS_HPP_SHOWGLOBALSEARCH,HppShowGlobalSearch);
+ hHppOpenHistoryEvent := CreateServiceFunction(MS_HPP_OPENHISTORYEVENT,HppOpenHistoryEvent);
+
+ hHppRichEditItemProcess := CreateHookableEvent(ME_HPP_RICHEDIT_ITEMPROCESS);
+ hAllHistoryRichEditProcess := HookEvent(ME_HPP_RICHEDIT_ITEMPROCESS,AllHistoryRichEditProcess);
+end;
+
+procedure hppUnregisterServices;
+begin
+ CloseHistoryWindows;
+ CloseGlobalSearchWindow;
+ UnhookEvent(hAllHistoryRichEditProcess);
+ DestroyServiceFunction(hHppShowHistory);
+ DestroyServiceFunction(hHppEmptyHistory);
+ DestroyServiceFunction(hHppGetVersion);
+ DestroyServiceFunction(hHppShowGlobalSearch);
+ DestroyServiceFunction(hHppOpenHistoryEvent);
+ DestroyServiceFunction(hHppEmptyHistory);
+ DestroyHookableEvent(hHppRichEditItemProcess);
+ HstWindowList.Free;
+end;
+
+end.
|