From 62a14ba4730f52cce31b1b71565554691496df36 Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Sat, 15 Nov 2014 21:15:03 +0000 Subject: Watrack: first trying of fix for Watrack plugin (like Watrack_MPD) work git-svn-id: http://svn.miranda-ng.org/main/trunk@10996 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Watrack/srv_getinfo.pas | 82 +++++++++++++++++++++++++++++++++++++++-- plugins/Watrack/srv_player.pas | 1 + plugins/Watrack/watrack.dpr | 2 +- 3 files changed, 80 insertions(+), 5 deletions(-) (limited to 'plugins/Watrack') diff --git a/plugins/Watrack/srv_getinfo.pas b/plugins/Watrack/srv_getinfo.pas index dda96769b7..39ceddb39f 100644 --- a/plugins/Watrack/srv_getinfo.pas +++ b/plugins/Watrack/srv_getinfo.pas @@ -43,6 +43,30 @@ uses common, msninfo, syswin, wrapper, io, winampapi, srv_player, srv_format; +//----- Miranda cheat ----- +const + CoreDLL = 'mir_core.dll'; +type + tmir_free=procedure(para1:pointer); cdecl; +var + mir_free:tmir_free; + MMCore:THANDLE; + +procedure InitMirandaMM; +begin + MMCore:=LoadLibraryW(CoreDLL); + if MMCore<>0 then + @mir_free:=GetProcAddress(MMCore,PAnsiChar('mir_free')); +end; + +procedure FreeMirandaMM; +begin + if MMCore<>0 then + begin + FreeLibrary(MMCore); + MMCore:=0; + end; +end; //----- get player info ----- @@ -57,6 +81,44 @@ begin result:=nil; end; +procedure MirMMToInt(var txt:PWideChar); +var + tmp:PWideChar; +begin + if txt<>nil then + begin + StrDupW(tmp,txt); mir_free(txt); txt:=tmp; + end; +end; + +procedure GetInfoInt(pl:pPlayerCell;var dst:tSongInfo;flags:cardinal); +begin + tInfoProc(pl^.GetInfo)(dst,flags); + if (pl^.flags and (WAT_OPT_INTERNAL or WAT_OPT_TEMPLATE))=0 then + begin + if (flags and WAT_OPT_PLAYERDATA)<>0 then + begin + // player name and homepage url we got from registration + MirMMToInt(dst.txtver); + end + else if (flags and WAT_OPT_CHANGES)<>0 then + begin + MirMMToInt(dst.wndtext); + end + else + begin + MirMMToInt(dst.artist); + MirMMToInt(dst.title); + MirMMToInt(dst.album); + MirMMToInt(dst.genre); + MirMMToInt(dst.comment); + MirMMToInt(dst.year); + MirMMToInt(dst.lyric); + MirMMToInt(dst.cover); + end; + end; +end; + function GetPlayerInfo(var dst:tSongInfo;flags:cardinal):integer; var plwnd:HWND; @@ -79,7 +141,7 @@ begin dst.icon:=CopyIcon(pl^.icon); if pl^.GetInfo<>nil then - tInfoProc(pl^.GetInfo)(dst,flags or WAT_OPT_PLAYERDATA) + GetInfoInt(pl,dst,flags or WAT_OPT_PLAYERDATA) else if (pl^.flags and WAT_OPT_WINAMPAPI)<>0 then WinampGetInfo(wparam(@dst),flags or WAT_OPT_PLAYERDATA); @@ -112,7 +174,14 @@ begin pl:=GetActivePlayer; if pl^.GetName<>nil then - fname:=tNameProc(pl^.GetName)(dst.plwnd,flags) + begin + fname:=tNameProc(pl^.GetName)(dst.plwnd,flags); + + if (pl^.flags and (WAT_OPT_INTERNAL or WAT_OPT_TEMPLATE))=0 then + begin + MirMMToInt(fname); + end; + end else fname:=nil; @@ -237,7 +306,7 @@ begin pl:=GetActivePlayer; if pl^.GetInfo<>nil then - tInfoProc(pl^.GetInfo)(dst,flags or WAT_OPT_CHANGES) + GetInfoInt(pl,dst,flags or WAT_OPT_CHANGES) else if (pl^.flags and WAT_OPT_WINAMPAPI)<>0 then WinampGetInfo(wparam(@dst),flags or WAT_OPT_CHANGES); @@ -340,7 +409,7 @@ begin // info from player pl:=GetActivePlayer; if pl^.GetInfo<>nil then - tInfoProc(pl^.GetInfo)(dst,flags and not WAT_OPT_CHANGES) + GetInfoInt(pl,dst,flags and not WAT_OPT_CHANGES) else if (pl^.flags and WAT_OPT_WINAMPAPI)<>0 then WinampGetInfo(wparam(@dst),flags and not WAT_OPT_CHANGES); @@ -380,4 +449,9 @@ begin end; end; +initialization + InitMirandaMM; + +finalization + FreeMirandaMM; end. diff --git a/plugins/Watrack/srv_player.pas b/plugins/Watrack/srv_player.pas index 5f16f8c528..61429c345d 100644 --- a/plugins/Watrack/srv_player.pas +++ b/plugins/Watrack/srv_player.pas @@ -370,6 +370,7 @@ begin result:=0; while ptr<>nil do begin + ptr.This.flags:=ptr.This.flags or WAT_OPT_INTERNAL; ServicePlayer(WAT_ACT_REGISTER,lparam(ptr.This)); ptr:=ptr^.Next; inc(result); diff --git a/plugins/Watrack/watrack.dpr b/plugins/Watrack/watrack.dpr index 1080f6d4fe..64128af477 100644 --- a/plugins/Watrack/watrack.dpr +++ b/plugins/Watrack/watrack.dpr @@ -548,7 +548,7 @@ begin dbetd.module :=PluginShort; dbetd.textService:=nil; dbetd.iconService:=nil; - dbetd.eventIcon :=0; + p:='WATrack_Info'; for i:=0 to HIGH(cdbetd) do begin -- cgit v1.2.3