diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-10 19:12:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-10 19:12:33 +0000 |
commit | 6ad65c4d4fce1d5ce1a1873ee84feaff753c9d48 (patch) | |
tree | 94e232bdd680291eb7192851d71935f89b196fd2 /plugins/Watrack/watrack.dpr | |
parent | 9a4be1a673e76cb205a11076b7d8162eb593feab (diff) |
Watrack:
- event hooks wiped out;
- icons & menus optimization;
- merge of memory leak fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@3963 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Watrack/watrack.dpr')
-rw-r--r-- | plugins/Watrack/watrack.dpr | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/plugins/Watrack/watrack.dpr b/plugins/Watrack/watrack.dpr index a3d7abf464..7c48e5eb29 100644 --- a/plugins/Watrack/watrack.dpr +++ b/plugins/Watrack/watrack.dpr @@ -8,7 +8,7 @@ library WATrack; uses
// FastMM not compatible with FPC, internal for delphi xe
// {$IFNDEF COMPILER_16_UP}{$IFNDEF FPC}fastmm4,{$ENDIF}{$ENDIF}
- m_api,dbsettings,winampapi,
+ m_api,dbsettings,activex,winampapi,
Windows,messages,commctrl,//uxtheme,
srv_format,srv_player,wat_api,wrapper,
common,syswin,HlpDlg,mirutils
@@ -66,7 +66,6 @@ begin move(SongInfo,SongInfoA,SizeOf(tSongInfo));
with SongInfoA do
begin
- FastWideToAnsi(SongInfo.url,url);
if enc=WAT_INF_ANSI then
begin
WideToAnsi(SongInfo.artist ,artist ,cp);
@@ -125,9 +124,15 @@ begin result:=1;
if (lParam=0) or (pSongInfo(lParam).mfile=nil) then exit;
dst:=pointer(lParam);
+
+ p:=dst^.mfile;
+ ClearTrackInfo(dst^,false);
+ dst^.mfile:=p;
+{
StrDupW(p,dst^.mfile);
ClearTrackInfo(dst^,false); //!!!!
dst^.mfile:=p;
+}
// FillChar(dst,SizeOf(dst),0);
// FillChar(si,SizeOf(si),0);
{
@@ -484,25 +489,65 @@ begin CloseHandle(hEvent);
end;
+procedure DoTheDew(load:boolean);
+var
+ ptr:pwModule;
+ newstate:boolean;
+begin
+ ptr:=ModuleLink;
+ while ptr<>nil do
+ begin
+ if @ptr^.Check<>nil then
+ ptr^.Check(load);
+ ptr:=ptr^.Next;
+ end;
+
+ // TTB
+ newstate:=ServiceExists(MS_TTB_ADDBUTTON)<>0;
+ if newstate=(ttbState<>0) then
+ exit;
+
+ if ttbState=0 then
+ begin
+ HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded);
+ end
+ else
+ begin
+ if ServiceExists(MS_TTB_REMOVEBUTTON)>0 then
+ CallService(MS_TTB_REMOVEBUTTON,WPARAM(ttbState),0);
+ ttbState:=0;
+ end;
+end;
+
+function OnPluginLoad(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ DoTheDew(true);
+ result:=0;
+end;
+
+function OnPluginUnload(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ DoTheDew(false);
+ result:=0;
+end;
+
function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
p:PAnsiChar;
begin
- UnhookEvent(onloadhook);
-
CallService(MS_DBEDIT_REGISTERSINGLEMODULE,twparam(PluginShort),0);
hTimer:=0;
+ OleInitialize(nil);
+
if RegisterIcons then
- wsic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged)
- else
- wsic:=0;
+ HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged);
CreateMenus;
if ServiceExists(MS_TTB_ADDBUTTON)<>0 then
- onloadhook:=HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded)
+ HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded)
else
ttbState:=0;
@@ -539,6 +584,9 @@ begin StartMSNHook;
result:=0;
+
+ HookEvent(ME_SYSTEM_MODULELOAD ,@OnPluginLoad);
+ HookEvent(ME_SYSTEM_MODULEUNLOAD,@OnPluginUnLoad);
end;
procedure FreeVariables;
@@ -598,17 +646,14 @@ begin ptr:=ptr^.Next;
end;
-// UnhookEvent(plStatusHook);
- UnhookEvent(hHookShutdown);
- UnhookEvent(opthook);
- if wsic<>0 then UnhookEvent(wsic);
-
FreeServices;
FreeVariables;
DestroyHookableEvent(hHookWATLoaded);
DestroyHookableEvent(hHookWATStatus);
+ OleUnInitialize;
+
//delete cover files
buf[0]:=#0;
GetTempPathW(511,buf);
@@ -637,8 +682,9 @@ begin hHookWATLoaded:=CreateHookableEvent(ME_WAT_MODULELOADED);
hHookWATStatus:=CreateHookableEvent(ME_WAT_NEWSTATUS);
- hHookShutdown :=HookEvent(ME_SYSTEM_OKTOEXIT,@PreShutdown);
- opthook :=HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
+
+ HookEvent(ME_SYSTEM_OKTOEXIT,@PreShutdown);
+ HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
hGFI:=CreateServiceFunction(MS_WAT_GETFILEINFO ,@WATGetFileInfo);
hRGS:=CreateServiceFunction(MS_WAT_RETURNGLOBAL ,@WATReturnGlobal);
@@ -655,7 +701,7 @@ begin FillChar(SongInfoA,SizeOf(SongInfoA),0);
FillChar(SongInfo ,SizeOf(SongInfo ),0);
FillChar(WorkSI ,SizeOf(SongInfo ),0);
- onloadhook:=HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded);
+ HookEvent(ME_SYSTEM_MODULESLOADED,@OnModulesLoaded);
end;
function Unload:int; cdecl;
|