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/ExternalAPI/delphi/m_music.inc | 31 ++++++------- plugins/Watrack/srv_getinfo.pas | 82 ++++++++++++++++++++++++++++++++-- plugins/Watrack/srv_player.pas | 1 + plugins/Watrack/watrack.dpr | 2 +- 4 files changed, 96 insertions(+), 20 deletions(-) diff --git a/plugins/ExternalAPI/delphi/m_music.inc b/plugins/ExternalAPI/delphi/m_music.inc index 205fdc5bf3..d881708eef 100644 --- a/plugins/ExternalAPI/delphi/m_music.inc +++ b/plugins/ExternalAPI/delphi/m_music.inc @@ -263,16 +263,17 @@ const WAT_OPT_TEMPLATE = $00000100; // (internal) WAT_OPT_IMPLANTANT = $00000200; // [options] use process implantation WAT_OPT_HASURL = $00000400; // [players] URL field present - WAT_OPT_CHANGES = $00000800; // (internal) obtain only chaged values + WAT_OPT_CHANGES = $00000800; // [subplugin] obtain only chaged values // (volume, status, window text, elapsed time) WAT_OPT_APPCOMMAND = $00001000; // [options] Special (multimedia) key support WAT_OPT_CHECKALL = $00002000; // [options] Check all players WAT_OPT_KEEPOLD = $00004000; // [options] Keep Old opened file // WAT_OPT_MULTITHREAD = $00008000; // [options] Use multithread scan WAT_OPT_SINGLEINST = $00010000; // [players] Single player instance - WAT_OPT_PLAYERDATA = $00020000; // (internal) to obtain player data + WAT_OPT_PLAYERDATA = $00020000; // [subplugin] to obtain player data WAT_OPT_CONTAINER = $00040000; // [formats] format is container (need to check full) WAT_OPT_UNKNOWNFMT = $00080000; // [formats] check unknown (not disabled) formats (info from player) + WAT_OPT_INTERNAL = $80000000; // (internal) for memory manager choosing type tReadFormatProc = function(var Info:tSongInfo):boolean; cdecl; @@ -349,11 +350,11 @@ const Returns: previous state } const - MS_WAT_MYSHOWS:pAnsiChar = 'WATrack/MyShows'; + MS_WAT_MYSHOWS:PAnsiChar = 'WATrack/MyShows'; const - MS_WAT_MYSHOWSINFO:pAnsiChar = 'WATrack/MyShowsInfo'; + MS_WAT_MYSHOWSINFO:PAnsiChar = 'WATrack/MyShowsInfo'; // --------- Last FM --------- @@ -363,7 +364,7 @@ const Returns: previous state } const - MS_WAT_LASTFM:pAnsiChar = 'WATrack/LastFM'; + MS_WAT_LASTFM:PAnsiChar = 'WATrack/LastFM'; { Get Info based on currently played song @@ -374,18 +375,18 @@ type pLastFMInfo = ^tLastFMInfo; tLastFMInfo = record request:cardinal; // 0 - artist, 1 - album, 2 - track - artist :pWideChar; // artist - album :pWideChar; // album or similar artists for Artist info request - title :pWideChar; // track title - tags :pWideChar; // tags - info :pWideChar; // artist bio or wiki article - image :pAnsiChar; // photo/cover link - similar:pWideChar; - release:pWideChar; + artist :PWideChar; // artist + album :PWideChar; // album or similar artists for Artist info request + title :PWideChar; // track title + tags :PWideChar; // tags + info :PWideChar; // artist bio or wiki article + image :PAnsiChar; // photo/cover link + similar:PWideChar; + release:PWideChar; trknum :cardinal; end; const - MS_WAT_LASTFMINFO:pAnsiChar = 'WATrack/LastFMInfo'; + MS_WAT_LASTFMINFO:PAnsiChar = 'WATrack/LastFMInfo'; // --------- Templates ---------- @@ -414,6 +415,6 @@ const lParam: 0 note: Shows Macro help window with edit aliases ability } - MS_WAT_MACROHELP:pAnsiChar = 'WATrack/MacroHelp'; + MS_WAT_MACROHELP:PAnsiChar = 'WATrack/MacroHelp'; {$ENDIF M_MUSIC} 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