From c3a168743616db6606702db5ad0fecab4dfee3da Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 24 Apr 2014 14:55:20 +0000 Subject: Miranda API update Watrack refactoring, API changes git-svn-id: http://svn.miranda-ng.org/main/trunk@9068 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/delphi/m_popup.inc | 10 +- plugins/ExternalAPI/delphi/m_music.inc | 96 +-- plugins/ExternalAPI/m_music.h | 213 ++--- plugins/ListeningTo/src/players/watrack.cpp | 2 +- plugins/Utils.pas/common.pas | 12 +- plugins/Utils.pas/mirutils.pas | 16 +- plugins/Utils.pas/wrapper.pas | 2 +- plugins/Watrack/HlpDlg.pas | 2 +- plugins/Watrack/i_opt_1.inc | 27 +- plugins/Watrack/i_options.inc | 11 +- plugins/Watrack/i_vars.inc | 3 +- plugins/Watrack/kolframe/frm_frame.inc | 4 +- plugins/Watrack/kolframe/kolframe.pas | 5 +- plugins/Watrack/lastfm/lastfm.pas | 3 +- plugins/Watrack/macros.pas | 2 +- plugins/Watrack/myrtf.pas | 2 +- plugins/Watrack/myshows/i_myshows_api.inc | 2 +- plugins/Watrack/myshows/i_myshows_opt.inc | 1 + plugins/Watrack/myshows/myshows.pas | 14 +- plugins/Watrack/players/pl_apollo.pas | 4 +- plugins/Watrack/players/pl_bs.pas | 2 +- plugins/Watrack/players/pl_cowon.pas | 10 +- plugins/Watrack/players/pl_foobar.pas | 16 +- plugins/Watrack/players/pl_itunes.pas | 10 +- plugins/Watrack/players/pl_lastfm.pas | 4 +- plugins/Watrack/players/pl_mmonkey.pas | 4 +- plugins/Watrack/players/pl_mradio.pas | 12 +- plugins/Watrack/players/pl_vlc.pas | 6 +- plugins/Watrack/players/pl_winamp.pas | 2 +- plugins/Watrack/players/pl_wmp.pas | 2 +- plugins/Watrack/popup/popups.pas | 39 +- plugins/Watrack/proto/proto.pas | 4 +- plugins/Watrack/res/i_const.inc | 3 +- plugins/Watrack/res/watrack.rc | 8 +- plugins/Watrack/res/watrack.res | Bin 5656 -> 4616 bytes plugins/Watrack/srv_format.pas | 313 ++++--- plugins/Watrack/srv_getinfo.pas | 383 +++++++++ plugins/Watrack/srv_player.pas | 1204 +++++++++------------------ plugins/Watrack/stat/statlog.pas | 9 +- plugins/Watrack/status/i_hotkey.inc | 2 +- plugins/Watrack/status/i_st_vars.inc | 1 + plugins/Watrack/status/i_status.inc | 2 +- plugins/Watrack/templates/i_text.inc | 6 +- plugins/Watrack/templates/i_variables.inc | 12 +- plugins/Watrack/wat_api.pas | 136 +++ plugins/Watrack/waticons.pas | 8 + plugins/Watrack/watrack.dpr | 310 +++---- plugins/Watrack/winampapi.pas | 15 +- plugins/Watrack_MPD/src/main.cpp | 14 +- plugins/mRadio/rbass.pas | 1 + 50 files changed, 1499 insertions(+), 1470 deletions(-) create mode 100644 plugins/Watrack/srv_getinfo.pas diff --git a/include/delphi/m_popup.inc b/include/delphi/m_popup.inc index b73c884c1d..5c079764f9 100644 --- a/include/delphi/m_popup.inc +++ b/include/delphi/m_popup.inc @@ -189,13 +189,6 @@ You may pass additional creation flags via lParam: } MS_POPUP_GETPLUGINDATA:PAnsiChar = 'Popup/GetPluginData'; -{ - wParam = 0 - lParam = 0 - Returns: 0 if the user has chosen not to have the second line, 1 if he choose to have the second line. -} - MS_POPUP_ISSECONDLINESHOWN:PAnsiChar = 'Popup/IsSecondLineShown'; - { Requests an action or an answer from Popup module. wParam = (WPARAM)wpQuery @@ -232,7 +225,7 @@ You may pass additional creation flags via lParam: { wParam = hPopupWindow lParam = lpzNewText - returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown. (but you could call PUIsSecondLineShown() before changing the text...) + returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown. Changes the text displayed in the second line of the popup. } MS_POPUP_CHANGETEXTW:PAnsiChar = 'Popup/ChangetextW'; @@ -337,6 +330,7 @@ type colorText :TCOLORREF; PluginWindowProc:pointer; iSeconds :int; + lParam :LPARAM; //APF_RETURN_HWND, APF_CUSTOM_POPUP ... as above end; const diff --git a/plugins/ExternalAPI/delphi/m_music.inc b/plugins/ExternalAPI/delphi/m_music.inc index b17a25879d..205fdc5bf3 100644 --- a/plugins/ExternalAPI/delphi/m_music.inc +++ b/plugins/ExternalAPI/delphi/m_music.inc @@ -23,10 +23,10 @@ type wndtext :PAnsiChar; // window title player :PAnsiChar; // player name plyver :dword; // player version - icon :THANDLE; // player icon + icon :HICON; // player icon fsize :dword; // media file size vbr :dword; - status :integer; // WAT_MES_* const + status :integer; // WAT_PLS_* plwnd :HWND; // player window // video part codec :dword; @@ -44,26 +44,26 @@ type type pSongInfo=^tSongInfo; tSongInfo = record - artist :PWideChar; - title :PWideChar; - album :PWideChar; - genre :PWideChar; - comment :PWideChar; - year :PWideChar; - mfile :PWideChar; // media file + artist :pWideChar; + title :pWideChar; + album :pWideChar; + genre :pWideChar; + comment :pWideChar; + year :pWideChar; + mfile :pWideChar; // media file kbps :dword; khz :dword; channels :dword; track :dword; total :dword; // music length time :dword; // elapsed time - wndtext :PWideChar; // window title - player :PWideChar; // player name + wndtext :pWideChar; // window title + player :pWideChar; // player name plyver :dword; // player version - icon :THANDLE; // player icon + icon :HICON; // player icon fsize :dword; // media file size vbr :dword; - status :integer; // WAT_MES_* const + status :integer; // WAT_PLS_* plwnd :HWND; // player window // video part codec :dword; @@ -71,9 +71,9 @@ type height :dword; fps :dword; date :int64; - txtver :PWideChar; - lyric :PWideChar; - cover :PWideChar; // cover path + txtver :pWideChar; + lyric :pWideChar; + cover :pWideChar; // cover path volume :dword; url :PWideChar; // player homepage winampwnd:HWND; @@ -93,12 +93,6 @@ const WAT_RES_NEWFILE = 3; WAT_RES_NEWPLAYER = 4; -// result for MS_WAT_GETMUSICINFO service -const - WAT_PLS_NORMAL = WAT_RES_OK; - WAT_PLS_NOMUSIC = WAT_RES_DISABLED; - WAT_PLS_NOTFOUND = WAT_RES_NOTFOUND; - const WAT_INF_UNICODE = 0; WAT_INF_ANSI = 1; @@ -114,13 +108,13 @@ const wParam : WAT_INF_* constant lParam : pointer to pSongInfo (Unicode) or pSongInfoA (ANSI/UTF8) Affects: Fill structure by currently played music info - returns: WAT_PLS_* constant + returns: WAT_RES_* constant note: pointer will be point to global SongInfo structure of plugin warning: Non-Unicode data filled only by request if lParam=0 only internal SongInfo structure will be filled Example: var p:pSongInfo; - CallService(MS_WAT_GETMUSICINFO,0,dword(@p)); + CallService(MS_WAT_GETMUSICINFO,0,lparam(@p)); } MS_WAT_GETMUSICINFO:PAnsiChar = 'WATrack/GetMusicInfo'; { @@ -182,10 +176,16 @@ const } MS_WAT_PLUGINSTATUS:PAnsiChar = 'WATrack/PluginStatus'; +// ---------- events ------------ + +{ + ME_WAT_MODULELOADED + wParam: 0, lParam: 0 +} ME_WAT_MODULELOADED:PAnsiChar = 'WATrack/ModuleLoaded'; const - WAT_EVENT_PLAYERSTATUS = 1; // WAT_PLS_* in loword, WAT_MES_* in hiword + WAT_EVENT_PLAYERSTATUS = 1; // WAT_PLS_* WAT_EVENT_NEWTRACK = 2; // SongInfo ptr WAT_EVENT_PLUGINSTATUS = 3; // 0-enabled; 1-dis.temporary; 2-dis.permanent WAT_EVENT_NEWPLAYER = 4; // @@ -234,13 +234,12 @@ const // ----------- Formats and players ----------- -// media file status - -const - WAT_MES_STOPPED = 0; - WAT_MES_PLAYING = 1; - WAT_MES_PAUSED = 2; - WAT_MES_UNKNOWN = -1; +const // player status + WAT_PLS_NOTFOUND = 0; // player not found + WAT_PLS_PLAYING = 1; + WAT_PLS_PAUSED = 2; + WAT_PLS_STOPPED = 3; // player stopped, no music even searched + WAT_PLS_UNKNOWN = 4; // player found with unknown state const WAT_ACT_REGISTER = 1; @@ -269,10 +268,11 @@ const 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_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_CONTAINER = $00040000; // [formats] format is container (need to check full) + WAT_OPT_UNKNOWNFMT = $00080000; // [formats] check unknown (not disabled) formats (info from player) type tReadFormatProc = function(var Info:tSongInfo):boolean; cdecl; @@ -309,7 +309,7 @@ type tInitProc = function():integer;cdecl; tDeInitProc = function():integer;cdecl; tStatusProc = function(wnd:HWND):integer;cdecl; - tNameProc = function(wnd:HWND;flags:integer):PWideChar;cdecl; + tNameProc = function(wnd:HWND;flags:integer):pWideChar;cdecl; tCheckProc = function(wnd:HWND;flags:integer):HWND;cdecl; tInfoProc = function(var SongInfo:tSongInfo;flags:integer):integer;cdecl; tCommandProc = function(wnd:HWND;command:integer;value:integer):integer;cdecl; @@ -317,7 +317,7 @@ type pPlayerCell = ^tPlayerCell; tPlayerCell = record Desc :PAnsiChar; // Short player name - flags :cardinal; + flags :dword; Icon :HICON; // can be 0. for registration only Init :pointer; // tInitProc; can be NIL. initialize any data DeInit :pointer; // tDeInitProc; can be NIL. finalize player processing @@ -349,11 +349,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 +363,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 +374,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 +414,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/ExternalAPI/m_music.h b/plugins/ExternalAPI/m_music.h index f89dae99a0..24aacf22a9 100644 --- a/plugins/ExternalAPI/m_music.h +++ b/plugins/ExternalAPI/m_music.h @@ -4,73 +4,75 @@ #define MIID_WATRACK {0xfc6c81f4, 0x837e, 0x4430, {0x96, 0x01, 0xa0, 0xaa, 0x43, 0x17, 0x7a, 0xe3}} typedef struct tSongInfoA { - CHAR* artist; - CHAR* title; - CHAR* album; - CHAR* genre; - CHAR* comment; - CHAR* year; - CHAR* mfile; // media file - DWORD kbps; - DWORD khz; - DWORD channels; - DWORD track; - DWORD total; // music length - DWORD time; // elapsed time - CHAR* wndtext; // window title - CHAR* player; // player name - DWORD plyver; // player version - HANDLE icon; // player icon - DWORD fsize; // media file size - DWORD vbr; - int status; // WAT_MES_* const - HWND plwnd; // player window - // video part - DWORD codec; - DWORD width; - DWORD height; - DWORD fps; - __int64 date; - CHAR* txtver; - CHAR* lyric; - CHAR* cover; - DWORD volume; - CHAR* url; // player homepage + CHAR* artist; + CHAR* title; + CHAR* album; + CHAR* genre; + CHAR* comment; + CHAR* year; + CHAR* mfile; // media file + DWORD kbps; + DWORD khz; + DWORD channels; + DWORD track; + DWORD total; // music length + DWORD time; // elapsed time + CHAR* wndtext; // window title + CHAR* player; // player name + DWORD plyver; // player version + HICON icon; // player icon + DWORD fsize; // media file size + DWORD vbr; + int status; // WAT_MES_* const + HWND plwnd; // player window + // video part + DWORD codec; + DWORD width; + DWORD height; + DWORD fps; + __int64 date; + CHAR* txtver; + CHAR* lyric; + CHAR* cover; + DWORD volume; + CHAR* url; // player homepage + HWND winampwnd; // player window } SONGINFOA, *LPSONGINFOA; typedef struct tSongInfo { - WCHAR* artist; - WCHAR* title; - WCHAR* album; - WCHAR* genre; - WCHAR* comment; - WCHAR* year; - WCHAR* mfile; // media file - DWORD kbps; - DWORD khz; - DWORD channels; - DWORD track; - DWORD total; // music length - DWORD time; // elapsed time - WCHAR* wndtext; // window title - WCHAR* player; // player name - DWORD* plyver; // player version - HANDLE icon; // player icon - DWORD fsize; // media file size - DWORD vbr; - int status; // WAT_MES_* const - HWND plwnd; // player window - // video part - DWORD codec; - DWORD width; - DWORD height; - DWORD fps; - __int64 date; - WCHAR* txtver; - WCHAR* lyric; - WCHAR* cover; // cover path - DWORD volume; - WCHAR* url; // player homepage + WCHAR* artist; + WCHAR* title; + WCHAR* album; + WCHAR* genre; + WCHAR* comment; + WCHAR* year; + WCHAR* mfile; // media file + DWORD kbps; + DWORD khz; + DWORD channels; + DWORD track; + DWORD total; // music length + DWORD time; // elapsed time + WCHAR* wndtext; // window title + WCHAR* player; // player name + DWORD plyver; // player version + HICON icon; // player icon + DWORD fsize; // media file size + DWORD vbr; + int status; // WAT_MES_* const + HWND plwnd; // player window + // video part + DWORD codec; + DWORD width; + DWORD height; + DWORD fps; + __int64 date; + WCHAR* txtver; + WCHAR* lyric; + WCHAR* cover; + DWORD volume; + WCHAR* url; // player homepage + HWND winampwnd; // player window } SONGINFO, *LPSONGINFO; #if defined(_UNICODE) @@ -79,7 +81,7 @@ typedef struct tSongInfo { #else #define WAT_INF_TCHAR WAT_INF_ANSI #define SongInfoT tSongInfoA -#endif +#endif // result codes #define WAT_RES_UNKNOWN -2 @@ -92,11 +94,6 @@ typedef struct tSongInfo { #define WAT_RES_NEWFILE 3 #define WAT_RES_NEWPLAYER 4 -// result for MS_WAT_GETMUSICINFO service -#define WAT_PLS_NORMAL WAT_RES_OK -#define WAT_PLS_NOMUSIC WAT_RES_DISABLED -#define WAT_PLS_NOTFOUND WAT_RES_NOTFOUND - #define WAT_INF_UNICODE 0 #define WAT_INF_ANSI 1 #define WAT_INF_UTF8 2 @@ -106,13 +103,13 @@ typedef struct tSongInfo { wParam : WAT_INF_* constant lParam : pointer to LPSONGINGO (Unicode) or LPSONGINFOA (ANSI/UTF8) Affects: Fill structure by currently played music info - returns: WAT_PLS_* constant + returns: WAT_RES_* constant note: pointer will be point to global SONGINFO structure of plugin warning: Non-Unicode data filled only by request if lParam=0 only internal SongInfo structure will be filled Example: LPSONGINFO p; - PluginLink->CallService(MS_WAT_GETMUSICINFO,0,(DWORD)&p); + PluginLink->CallService(MS_WAT_GETMUSICINFO,0,(LPARAM)&p); */ #define MS_WAT_GETMUSICINFO "WATrack/GetMusicInfo" @@ -122,7 +119,7 @@ typedef struct tSongInfo { Affects: Fill structure by info from file named in SongInfo.mfile returns: 0, if success note: fields, which values can't be obtained, leaves old values. - you must free given strings by miranda mir_free + you must free given strings by miranda mmi.free */ #define MS_WAT_GETFILEINFO "WATrack/GetFileInfo" @@ -229,12 +226,13 @@ typedef struct tSongInfo { // ----------- Formats and players ----------- -// media file status +// player status -#define WAT_MES_STOPPED 0 -#define WAT_MES_PLAYING 1 -#define WAT_MES_PAUSED 2 -#define WAT_MES_UNKNOWN -1 +#define WAT_PLS_NOTFOUUND 0 +#define WAT_PLS_PLAYING 1 +#define WAT_PLS_PAUSED 2 +#define WAT_PLS_STOPPED 3 +#define WAT_PLS_UNKNOWN 4 #define WAT_ACT_REGISTER 1 #define WAT_ACT_UNREGISTER 2 @@ -261,9 +259,11 @@ typedef struct tSongInfo { #define WAT_OPT_APPCOMMAND 0x01000 // Special (multimedia) key support #define WAT_OPT_CHECKALL 0x02000 // Check all players #define WAT_OPT_KEEPOLD 0x04000 // Keep Old opened file -#define WAT_OPT_MULTITHREAD 0x08000 // Use multithread scan +//#define WAT_OPT_MULTITHREAD 0x08000 // Use multithread scan #define WAT_OPT_SINGLEINST 0x10000 // Single player instance #define WAT_OPT_PLAYERDATA 0x20000 // (internal) to obtain player data +#define WAT_OPT_CONTAINER 0x40000 // [formats] format is container (need to check full) +#define WAT_OPT_UNKNOWNFMT 0x80000 // [formats] check unknown (not disabled) formats (info from player) typedef BOOL (__cdecl *LPREADFORMATPROC)(LPSONGINFO Info); @@ -304,18 +304,18 @@ typedef int (__cdecl *LPINFOPROC) (LPSONGINFO Info, int flags); typedef int (__cdecl *LPCOMMANDPROC)(HWND wnd, int command, int value); typedef struct tPlayerCell { - CHAR* Desc; // Short player name - UINT flags; - HICON Icon; // can be 0. for registration only - LPINITPROC Init; // LPINITPROC; can be NULL. initialize any data - LPDEINITPROC DeInit; // LPDEINITPROC; can be NULL. finalize player processing - LPCHECKPROC Check; // check player - LPSTATUSPROC GetStatus; // tStatusProc; can be NULL. get player status - LPNAMEPROC GetName; // can be NULL. get media filename - LPINFOPROC GetInfo; // can be NULL. get info from player - LPCOMMANDPROC Command; // can be NULL. send command to player - CHAR* URL; // only if WAT_OPT_HASURL flag present - WCHAR* Notes; // any tips, notes etc for this player + CHAR* Desc; // Short player name + UINT flags; + HICON Icon; // can be 0. for registration only + LPINITPROC Init; // LPINITPROC; can be NULL. initialize any data + LPDEINITPROC DeInit; // LPDEINITPROC; can be NULL. finalize player processing + LPCHECKPROC Check; // check player + LPSTATUSPROC GetStatus; // tStatusProc; can be NULL. get player status + LPNAMEPROC GetName; // can be NULL. get media filename + LPINFOPROC GetInfo; // can be NULL. get info from player + LPCOMMANDPROC Command; // can be NULL. send command to player + CHAR* URL; // only if WAT_OPT_HASURL flag present + WCHAR* Notes; // any tips, notes etc for this player } PLAYERCELL, *LPPLAYERCELL; /* @@ -328,6 +328,17 @@ typedef struct tPlayerCell { */ #define MS_WAT_PLAYER "WATrack/Player" +// --------- MyShows.ru --------- + +/* + Toggle MyShows scrobbling status + wParam,lParam=0 + Returns: previous state +*/ +#define MS_WAT_MYSHOWS "WATrack/MyShows" + +#define MS_WAT_MYSHOWSINFO "WATrack/MyShowsInfo" + // --------- Last FM --------- /* @@ -343,16 +354,16 @@ typedef struct tPlayerCell { lParam: int language (first 2 bytes - 2-letters language code) */ typedef struct tLastFMInfo { - UINT request; // 0 - artist, 1 - album, 2 - track - WCHAR* artist; // artist - WCHAR* album; // album or similar artists for Artist info request - WCHAR* title; // track title - WCHAR* tags; // tags - WCHAR* info; // artist bio or wiki article - WCHAR* image; // photo/cover link - WCHAR* similar; - WCHAR* release; - UINT trknum; + UINT request; // 0 - artist, 1 - album, 2 - track + WCHAR* artist; // artist + WCHAR* album; // album or similar artists for Artist info request + WCHAR* title; // track title + WCHAR* tags; // tags + WCHAR* info; // artist bio or wiki article + WCHAR* image; // photo/cover link + WCHAR* similar; + WCHAR* release; + UINT trknum; }PLASTFMINFO, *LPLASTFMINFO; #define MS_WAT_LASTFMINFO "WATrack/LastFMInfo" diff --git a/plugins/ListeningTo/src/players/watrack.cpp b/plugins/ListeningTo/src/players/watrack.cpp index f7bd7e757c..eab20cf7c5 100644 --- a/plugins/ListeningTo/src/players/watrack.cpp +++ b/plugins/ListeningTo/src/players/watrack.cpp @@ -96,7 +96,7 @@ void WATrack::GetData() FreeData(); // See if something is playing - if (playing != WAT_PLS_NORMAL + if (playing == WAT_RES_NOTFOUND || si == NULL || si->status != 1 || ( IsEmpty(si->artist) && IsEmpty(si->title)) ) diff --git a/plugins/Utils.pas/common.pas b/plugins/Utils.pas/common.pas index 37d9400cbf..d6eafbf0e6 100644 --- a/plugins/Utils.pas/common.pas +++ b/plugins/Utils.pas/common.pas @@ -76,8 +76,8 @@ procedure ShellSort(size:integer;Compare,Swap:tSortProc); //----- String processing ----- -function FormatStrW(fmt:pWideChar; arr:array of pWideChar):pWideChar; -function FormatSimpleW(fmt:pWideChar; arr:array of const):pWideChar; +function FormatStrW (fmt:pWideChar; const arr:array of pWideChar):pWideChar; +function FormatSimpleW(fmt:pWideChar; const arr:array of const):pWideChar; const SIGN_UNICODE = $FEFF; @@ -1293,7 +1293,7 @@ end; //----- String processing ----- -function FormatStrW(fmt:pWideChar; arr:array of pWideChar):pWideChar; +function FormatStrW(fmt:pWideChar; const arr:array of pWideChar):pWideChar; var i,len:integer; pc:pWideChar; @@ -1333,7 +1333,7 @@ begin pc^:=#0; end; -function FormatSimpleW(fmt:pWideChar; arr:array of const):pWideChar; +function FormatSimpleW(fmt:pWideChar; const arr:array of const):pWideChar; var i,len:integer; pc:pWideChar; @@ -2036,7 +2036,7 @@ var begin result:=dst; dst^:=#0; - if fname<>nil then + if (fname<>nil) and (fname^<>#0) then begin pc:=StrEndW(fname)-1; while (pc>fname) and ((pc^='"') or (pc^=' ')) do dec(pc); @@ -2073,7 +2073,7 @@ var begin result:=dst; dst^:=#0; - if fname<>nil then + if (fname<>nil) and (fname^<>#0) then begin pc:=StrEnd(fname)-1; while (pc>fname) and ((pc^='"') or (pc^=' ')) do dec(pc); diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 1f79cc1d4e..918f615390 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -285,19 +285,11 @@ begin exit; FillChar(ppdu,SizeOf(TPOPUPDATAW),0); - if CallService(MS_POPUP_ISSECONDLINESHOWN,0,0)<>0 then - begin - StrCopyW(ppdu.lpwzText,text,MAX_SECONDLINE-1); - if title<>nil then - StrCopyW(ppdu.lpwzContactName,title,MAX_CONTACTNAME-1) - else - ppdu.lpwzContactName[0]:=' '; - end + StrCopyW(ppdu.lpwzText,text,MAX_SECONDLINE-1); + if title<>nil then + StrCopyW(ppdu.lpwzContactName,title,MAX_CONTACTNAME-1) else - begin - StrCopyW(ppdu.lpwzContactName,text,MAX_CONTACTNAME-1); - ppdu.lpwzText[0]:=' '; - end; + ppdu.lpwzContactName[0]:=' '; CallService(MS_POPUP_ADDPOPUPW,wparam(@ppdu),APF_NO_HISTORY); end; diff --git a/plugins/Utils.pas/wrapper.pas b/plugins/Utils.pas/wrapper.pas index 5976df78fa..9e9e8b4b78 100644 --- a/plugins/Utils.pas/wrapper.pas +++ b/plugins/Utils.pas/wrapper.pas @@ -536,7 +536,7 @@ end; procedure GetUnitSize(wnd:HWND; var baseUnitX, baseUnitY: integer); var - DC :HDC; + dc :HDC; hfo :HFONT; tm :TTEXTMETRIC; size:TSIZE; diff --git a/plugins/Watrack/HlpDlg.pas b/plugins/Watrack/HlpDlg.pas index a27a93c85c..33ec22be96 100644 --- a/plugins/Watrack/HlpDlg.pas +++ b/plugins/Watrack/HlpDlg.pas @@ -80,4 +80,4 @@ begin result:=CreateDialogW(hInstance,COLORDLG,parent,@ColorHelpDlg); end; -end. \ No newline at end of file +end. diff --git a/plugins/Watrack/i_opt_1.inc b/plugins/Watrack/i_opt_1.inc index fe9c4c45aa..faec7ef0be 100644 --- a/plugins/Watrack/i_opt_1.inc +++ b/plugins/Watrack/i_opt_1.inc @@ -92,14 +92,6 @@ begin 'or firewall alarm.'); CheckDlgButton(Dialog,IDC_IMPLANTANT,UseImplant); - MakeHint(Dialog,IDC_MTHCHECK, - 'Use this option if WATrack freeze while player running. Slower processing.'); - CheckDlgButton(Dialog,IDC_MTHCHECK,MTHCheck); - - MakeHint(Dialog,IDC_TIMEOUT, - 'Timeout (ms) for separate thread handles checking.'); - SetDlgItemInt(Dialog,IDC_TIMEOUT,TimeoutForThread,false); - MakeHint(Dialog,IDC_KEEPOLD, 'Keep opened file as active, not newly founded.'); CheckDlgButton(Dialog,IDC_KEEPOLD,KeepOld); @@ -108,6 +100,10 @@ begin 'Check all marked players for active (started and playing) or stop at first founded'); CheckDlgButton(Dialog,IDC_CHECKALL,CheckAll); + MakeHint(Dialog,IDC_CHECKUNKN, + 'Check unknown file formats if player gives info.'); + CheckDlgButton(Dialog,IDC_CHECKUNKN,CheckUnknown); + // MakeHint(Dialog,IDC_COVERFN, // 'Cover filename searching templates'); SetDlgItemTextW(Dialog,IDC_COVERFN,CoverPaths); @@ -228,16 +224,17 @@ begin StartTimer; end; +{ TimeoutForThread:=GetDlgItemInt(Dialog,IDC_TIMEOUT,tmp,false); if TimeoutForThread>=100 then TimeoutForThread:=SysWin.ThreadTimeout; - - CheckTime :=IsDlgButtonChecked(Dialog,IDC_CHECKTIME); - UseImplant:=IsDlgButtonChecked(Dialog,IDC_IMPLANTANT); - MTHCheck :=IsDlgButtonChecked(Dialog,IDC_MTHCHECK); - KeepOld :=IsDlgButtonChecked(Dialog,IDC_KEEPOLD); - mmkeyemu :=IsDlgButtonChecked(Dialog,IDC_APPCOMMAND); - CheckAll :=IsDlgButtonChecked(Dialog,IDC_CHECKALL); +} + CheckTime :=IsDlgButtonChecked(Dialog,IDC_CHECKTIME); + UseImplant :=IsDlgButtonChecked(Dialog,IDC_IMPLANTANT); + KeepOld :=IsDlgButtonChecked(Dialog,IDC_KEEPOLD); + mmkeyemu :=IsDlgButtonChecked(Dialog,IDC_APPCOMMAND); + CheckAll :=IsDlgButtonChecked(Dialog,IDC_CHECKALL); + CheckUnknown:=IsDlgButtonChecked(Dialog,IDC_CHECKUNKN); mFreeMem(CoverPaths); CoverPaths:=GetDlgText(Dialog,IDC_COVERFN); diff --git a/plugins/Watrack/i_options.inc b/plugins/Watrack/i_options.inc index 16d1af242f..16a70ccd89 100644 --- a/plugins/Watrack/i_options.inc +++ b/plugins/Watrack/i_options.inc @@ -23,12 +23,10 @@ const opt_CheckTime :PAnsiChar = 'checktime'; opt_coverpaths:PAnsiChar = 'coverpaths'; opt_Implantant:PAnsiChar = 'useimplantant'; - opt_MTHCheck :PAnsiChar = 'mthcheck'; opt_KeepOld :PAnsiChar = 'keepold'; opt_mmkeyemu :PAnsiChar = 'mmkeyemu'; opt_CheckAll :PAnsiChar = 'checkall'; - - opt_ThTimeout :PAnsiChar = 'thtimeout'; + opt_CheckUnkn :PAnsiChar = 'checkunknown'; procedure _loadopt; begin @@ -40,9 +38,9 @@ begin globhotkey :=DBReadWord(0,PluginShort,opt_HotKey ,defhotkey); CheckTime :=DBReadByte(0,PluginShort,opt_CheckTime ,BST_CHECKED); UseImplant :=DBReadByte(0,PluginShort,opt_Implantant,BST_UNCHECKED); - MTHCheck :=DBReadByte(0,PluginShort,opt_MTHCheck ,BST_CHECKED); KeepOld :=DBReadByte(0,PluginShort,opt_KeepOld ,BST_UNCHECKED); CheckAll :=DBReadByte(0,PluginShort,opt_CheckAll ,BST_UNCHECKED); + CheckUnknown :=DBReadByte(0,PluginShort,opt_CheckUnkn ,BST_UNCHECKED); mTimer :=DBReadWord(0,PluginShort,opt_Timer ,3000); if mTimer<500 then mTimer:=mTimer*1000; @@ -50,20 +48,17 @@ begin CoverPaths :=DBReadUnicode(0,PluginShort,opt_coverpaths,defcoverpaths); mmkeyemu :=DBReadByte (0,PluginShort,opt_mmkeyemu ,BST_UNCHECKED); - - TimeoutForThread:=DBReadByte(0,PluginShort,opt_ThTimeout,SysWin.ThreadTimeout); end; procedure _saveopt; begin DBWriteWord(0,PluginShort,opt_InsHotKey ,inshotkey); DBWriteWord(0,PluginShort,opt_HotKey ,globhotkey); - DBWriteByte(0,PluginShort,opt_ThTimeout ,TimeoutForThread); DBWriteByte(0,PluginShort,opt_CheckTime ,CheckTime); DBWriteByte(0,PluginShort,opt_Implantant,UseImplant); - DBWriteByte(0,PluginShort,opt_MTHCheck ,MTHCheck); DBWriteByte(0,PluginShort,opt_KeepOld ,KeepOld); DBWriteByte(0,PluginShort,opt_CheckAll ,CheckAll); + DBWriteByte(0,PluginShort,opt_CheckUnkn ,CheckUnknown); DBWriteWord(0,PluginShort,opt_Timer ,mTimer); DBWriteWord(0,PluginShort,opt_UserCP ,UserCP); diff --git a/plugins/Watrack/i_vars.inc b/plugins/Watrack/i_vars.inc index 66d136f355..14afb05c09 100644 --- a/plugins/Watrack/i_vars.inc +++ b/plugins/Watrack/i_vars.inc @@ -14,11 +14,10 @@ var hMenuDisable:THANDLE; var CoverPaths:PWideChar; - MTHCheck, KeepOld, UseImplant, CheckAll, + CheckUnknown, CheckTime:dword; mmkeyemu: dword; mTimer:dword; - TimeoutForThread:cardinal; diff --git a/plugins/Watrack/kolframe/frm_frame.inc b/plugins/Watrack/kolframe/frm_frame.inc index b1e6d9e262..9f58abb9cd 100644 --- a/plugins/Watrack/kolframe/frm_frame.inc +++ b/plugins/Watrack/kolframe/frm_frame.inc @@ -63,7 +63,7 @@ begin if D.Trackbar<>nil then begin - if (CallService(MS_WAT_GETMUSICINFO,WAT_INF_CHANGES,tlparam(@psi))<>WAT_PLS_NOTFOUND) then + if (CallService(MS_WAT_GETMUSICINFO,WAT_INF_CHANGES,tlparam(@psi))<>WAT_RES_NOTFOUND) then begin SetTrackBarPosition(D.Trackbar,(psi^.time*1000) div D.UpdInterval) end; @@ -412,7 +412,7 @@ begin RegisterButtonIcons; D.Trackbar:=MakeNewTrackbar(@self); // for case when TB creating after track start (fastest way) - // can use (CallService(MS_WAT_GETMUSICINFO,WAT_INF_CHANGES,tlparam(@psi))<>WAT_PLS_NOTFOUND) + // can use (CallService(MS_WAT_GETMUSICINFO,WAT_INF_CHANGES,tlparam(@psi))<>WAT_RES_NOTFOUND) psi:=pointer(CallService(MS_WAT_RETURNGLOBAL,WAT_INF_UNICODE,1)); TrackbarSetRange(D.Trackbar,D.UpdInterval,psi^.total); end; diff --git a/plugins/Watrack/kolframe/kolframe.pas b/plugins/Watrack/kolframe/kolframe.pas index 8120e34f0e..49a541a206 100644 --- a/plugins/Watrack/kolframe/kolframe.pas +++ b/plugins/Watrack/kolframe/kolframe.pas @@ -106,8 +106,7 @@ begin case wParam of WAT_EVENT_PLAYERSTATUS: begin case integer(loword(lParam)) of - WAT_PLS_NORMAL : exit; - WAT_PLS_NOMUSIC : begin + WAT_PLS_STOPPED : begin if D.HideNoMusic then HideFrame(D.FrameId) else @@ -119,6 +118,8 @@ begin SetFrameTitle(PluginShort,0,0); // frame update code there end; + else + exit; end; FrameCtrl.ResetFrame; end; diff --git a/plugins/Watrack/lastfm/lastfm.pas b/plugins/Watrack/lastfm/lastfm.pas index 46098c558b..6d50b68d14 100644 --- a/plugins/Watrack/lastfm/lastfm.pas +++ b/plugins/Watrack/lastfm/lastfm.pas @@ -119,7 +119,8 @@ begin WAT_EVENT_PLAYERSTATUS: begin case integer(loword(lParam)) of - WAT_PLS_NOMUSIC,WAT_PLS_NOTFOUND: begin + WAT_PLS_STOPPED, + WAT_PLS_NOTFOUND: begin if hTimer<>0 then begin KillTimer(0,hTimer); diff --git a/plugins/Watrack/macros.pas b/plugins/Watrack/macros.pas index cdbe52991e..e26c8d697f 100644 --- a/plugins/Watrack/macros.pas +++ b/plugins/Watrack/macros.pas @@ -90,4 +90,4 @@ const implementation -end. \ No newline at end of file +end. diff --git a/plugins/Watrack/myrtf.pas b/plugins/Watrack/myrtf.pas index 0e1751017a..24d1cabc81 100644 --- a/plugins/Watrack/myrtf.pas +++ b/plugins/Watrack/myrtf.pas @@ -207,7 +207,7 @@ begin end; SendMessage(wnd,EM_SETSEL,sstart,sstart+integer(StrLenW(txt))-CharCount(txt)); - mGetMem(tmp,RTFBufferSize); + mGetMem (tmp ,RTFBufferSize); FillChar(tmp^,RTFBufferSize,0); ReadRTF(wnd,tmp); ReplaceTags(tmp); diff --git a/plugins/Watrack/myshows/i_myshows_api.inc b/plugins/Watrack/myshows/i_myshows_api.inc index 2e9f51773d..8a54e47e17 100644 --- a/plugins/Watrack/myshows/i_myshows_api.inc +++ b/plugins/Watrack/myshows/i_myshows_api.inc @@ -154,7 +154,7 @@ var buf:array [0..511] of AnsiChar; // bufw:array [0..511] of WideChar; res,pc:PAnsiChar; - epId:pAnsiChar; + {img,}epId:pAnsiChar; shId:pWideChar; // imgw:pWideChar; jn,jroot:PJSONNODE; diff --git a/plugins/Watrack/myshows/i_myshows_opt.inc b/plugins/Watrack/myshows/i_myshows_opt.inc index 42b9e88cee..125d4deda5 100644 --- a/plugins/Watrack/myshows/i_myshows_opt.inc +++ b/plugins/Watrack/myshows/i_myshows_opt.inc @@ -13,6 +13,7 @@ begin DBWriteString(0,PluginShort,optLogin ,msh_login); DBWriteByte (0,PluginShort,optTries ,msh_tries); DBWriteByte (0,PluginShort,optScrobPos,msh_scrobpos); +// DBWriteWord (0,PluginShort,optTries ,msh_timeout); DBWriteByte (0,PluginShort,optScrobble,msh_on and 1); end; diff --git a/plugins/Watrack/myshows/myshows.pas b/plugins/Watrack/myshows/myshows.pas index f09cc3cf08..75e5e182d5 100644 --- a/plugins/Watrack/myshows/myshows.pas +++ b/plugins/Watrack/myshows/myshows.pas @@ -27,8 +27,10 @@ type end; var msh_tries, +// msh_timeout, msh_scrobpos:integer; sic:THANDLE; +// slastinf:THANDLE; slast:THANDLE; MSData:tMyShowsData; const @@ -90,7 +92,7 @@ begin if (msh_login <>nil) and (msh_login^ <>#0) and (msh_password<>nil) and (msh_password^<>#0) then - mir_forkthread(@ThScrobble,nil); + {CloseHandle}(mir_forkthread(@ThScrobble,nil)); end; function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl; @@ -109,6 +111,7 @@ begin begin if pSongInfo(lParam).width>0 then // for video only begin +//!! if ServiceExists(MS_JSON_GETINTERFACE)<>0 then begin timervalue:=integer(pSongInfo(lParam).total)*10*msh_scrobpos; // 1000(msec) div 100(%) if timervalue=0 then @@ -145,7 +148,8 @@ begin WAT_EVENT_PLAYERSTATUS: begin case integer(loword(lParam)) of - WAT_PLS_NOMUSIC,WAT_PLS_NOTFOUND: begin + WAT_PLS_STOPPED, + WAT_PLS_NOTFOUND: begin if hTimer<>0 then begin KillTimer(0,hTimer); @@ -254,6 +258,7 @@ end; var plStatusHook:THANDLE; + function InitProc(aGetStatus:boolean=false):integer; begin // slastinf:=CreateServiceFunction(MS_WAT_MYSHOWSINFO,@SrvMyShowsInfo); @@ -285,7 +290,9 @@ end; procedure DeInitProc(aSetDisable:boolean); begin if aSetDisable then - SetModStatus(0); + SetModStatus(0) + else +;// DestroyServiceFunction(slastinf); DestroyServiceFunction(slast); UnhookEvent(plStatusHook); @@ -320,7 +327,6 @@ begin mmyshows.Check :=nil; mmyshows.ModuleName:='MyShows.ru'; ModuleLink :=@mmyshows; - end; begin diff --git a/plugins/Watrack/players/pl_apollo.pas b/plugins/Watrack/players/pl_apollo.pas index 1658f48b1d..9d73749eda 100644 --- a/plugins/Watrack/players/pl_apollo.pas +++ b/plugins/Watrack/players/pl_apollo.pas @@ -66,7 +66,7 @@ var tmpwnd:HWND; ps:array [0..255] of AnsiChar; begin - if GetStatus(wnd)<>WAT_MES_STOPPED then + if GetStatus(wnd)<>WAT_PLS_STOPPED then begin tmpwnd:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETCURRENTLYPLAYEDFILENAME,0); ps[0]:=#0; @@ -209,7 +209,7 @@ begin begin with SongInfo do begin - if (status<>WAT_MES_STOPPED) and + if (status<>WAT_PLS_STOPPED) and (mfile<>nil) and (StrPosW(mfile,'://')<>nil) and (album=nil) then album:=GetRemoteTitle(plwnd); end; diff --git a/plugins/Watrack/players/pl_bs.pas b/plugins/Watrack/players/pl_bs.pas index efcd6c26d4..b3f6ef2b28 100644 --- a/plugins/Watrack/players/pl_bs.pas +++ b/plugins/Watrack/players/pl_bs.pas @@ -194,7 +194,7 @@ begin if (flags and WAT_OPT_CHANGES)<>0 then begin volume:=GetVolume(plwnd); - if status<>WAT_MES_STOPPED then + if status<>WAT_PLS_STOPPED then time:=GetElapsedTime(plwnd); end else diff --git a/plugins/Watrack/players/pl_cowon.pas b/plugins/Watrack/players/pl_cowon.pas index fb2d985038..0ac7027426 100644 --- a/plugins/Watrack/players/pl_cowon.pas +++ b/plugins/Watrack/players/pl_cowon.pas @@ -195,11 +195,11 @@ function GetStatus(wnd:HWND):integer; cdecl; begin result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_STATUS); case result of - MCI_MODE_STOP : result:=WAT_MES_STOPPED; - MCI_MODE_PAUSE: result:=WAT_MES_PAUSED; - MCI_MODE_PLAY : result:=WAT_MES_PLAYING; + MCI_MODE_STOP : result:=WAT_PLS_STOPPED; + MCI_MODE_PAUSE: result:=WAT_PLS_PAUSED; + MCI_MODE_PLAY : result:=WAT_PLS_PLAYING; else - result:=WAT_MES_UNKNOWN; + result:=WAT_PLS_UNKNOWN; end; end; @@ -317,7 +317,7 @@ begin begin wndtext:=GetWndText; volume :=GetVolume(plwnd); - if status<>WAT_MES_STOPPED then + if status<>WAT_PLS_STOPPED then // if time=0 then time:=GetElapsedTime(plwnd); end diff --git a/plugins/Watrack/players/pl_foobar.pas b/plugins/Watrack/players/pl_foobar.pas index 7802440ad6..d2a8343c0b 100644 --- a/plugins/Watrack/players/pl_foobar.pas +++ b/plugins/Watrack/players/pl_foobar.pas @@ -13,12 +13,12 @@ uses {$IFDEF KOL_MCK}err,{$ENDIF} {$IFDEF KOL_MCK} ,kolcomobj {$ELSE} - ,mComObj + ,ComObj {$ENDIF} ; const - COMName:PAnsiChar = 'Foobar2000.Application.0.7'; + COMName:PWideChar = 'Foobar2000.Application.0.7'; const dummywnd = 'uninteresting'; const @@ -38,7 +38,7 @@ const var WinampWindow:HWND; -function proc(awnd:hwnd;param:pdword):boolean; stdcall; +function proc(awnd:HWND;param:pdword):boolean; stdcall; var s:array [0..255] of AnsiChar; begin @@ -258,23 +258,23 @@ var winampwnd:HWND; begin try - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; v:=GetActiveOleObject(COMName); tmp:=v.Playback.IsPaused; if tmp then - result:=WAT_MES_PAUSED + result:=WAT_PLS_PAUSED else begin tmp:=v.Playback.IsPlaying; if tmp then - result:=WAT_MES_PLAYING; + result:=WAT_PLS_PLAYING; end; except winampwnd:=WinampFindWindow(wnd); if winampwnd<>0 then result:=WinampGetStatus(winampwnd) else - result:=WAT_MES_UNKNOWN; + result:=WAT_PLS_UNKNOWN; end; v:=null; end; @@ -430,7 +430,7 @@ begin else if (flags and WAT_OPT_CHANGES)<>0 then begin volume:=GetVolume(v); - if status<>WAT_MES_STOPPED then + if status<>WAT_PLS_STOPPED then time:=GetElapsedTime(v); end else diff --git a/plugins/Watrack/players/pl_itunes.pas b/plugins/Watrack/players/pl_itunes.pas index d3f5bbc546..9fb13eefa3 100644 --- a/plugins/Watrack/players/pl_itunes.pas +++ b/plugins/Watrack/players/pl_itunes.pas @@ -12,7 +12,7 @@ uses windows,common,srv_player,wat_api {$IFDEF KOL_MCK} ,kolcomobj {$ELSE} - ,mComObj + ,ComObj {$ENDIF} ; @@ -99,11 +99,11 @@ begin v:=CreateOleObject(COMName); tmp:=v.PlayerState; if tmp=1 then - result:=WAT_MES_PLAYING + result:=WAT_PLS_PLAYING else - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; except - result:=WAT_MES_UNKNOWN; + result:=WAT_PLS_UNKNOWN; end; v:=Null; end; @@ -316,7 +316,7 @@ begin else if (flags and WAT_OPT_CHANGES)<>0 then begin volume:=GetVolume(v); - if status<>WAT_MES_STOPPED then + if status<>WAT_PLS_STOPPED then time:=GetElapsedTime(v); end else diff --git a/plugins/Watrack/players/pl_lastfm.pas b/plugins/Watrack/players/pl_lastfm.pas index 56ed3c7d4b..5735789b4a 100644 --- a/plugins/Watrack/players/pl_lastfm.pas +++ b/plugins/Watrack/players/pl_lastfm.pas @@ -76,9 +76,9 @@ var begin txt:=GetWndText(wnd); if StrCmpW(txt,LFMText,Length(LFMText))<>0 then - result:=WAT_MES_PLAYING + result:=WAT_PLS_PLAYING else - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; mFreeMem(txt); end; diff --git a/plugins/Watrack/players/pl_mmonkey.pas b/plugins/Watrack/players/pl_mmonkey.pas index bf96543478..fbfa54a05f 100644 --- a/plugins/Watrack/players/pl_mmonkey.pas +++ b/plugins/Watrack/players/pl_mmonkey.pas @@ -12,12 +12,12 @@ uses windows,messages,winampapi,common,srv_player,wat_api {$IFDEF KOL_MCK} ,kolcomobj {$ELSE} - ,mComObj + ,ComObj {$ENDIF} ; const - COMName:PAnsiChar = 'SongsDB.SDBApplication'; + COMName:PWideChar = 'SongsDB.SDBApplication'; const WM_WA_IPC = WM_USER; diff --git a/plugins/Watrack/players/pl_mradio.pas b/plugins/Watrack/players/pl_mradio.pas index b694fb912c..779d0cf13d 100644 --- a/plugins/Watrack/players/pl_mradio.pas +++ b/plugins/Watrack/players/pl_mradio.pas @@ -217,19 +217,19 @@ function GetStatus:integer; cdecl; begin if CurrentStation<>0 then begin - result:=WAT_MES_PLAYING; + result:=WAT_PLS_PLAYING; case CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET) of - RD_STATUS_PAUSED : result:=WAT_MES_PAUSED; + RD_STATUS_PAUSED : result:=WAT_PLS_PAUSED; RD_STATUS_STOPPED: begin - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; mFreeMem(prevfile); end; RD_STATUS_NOSTATION, - RD_STATUS_ABORT : result:=WAT_MES_UNKNOWN; + RD_STATUS_ABORT : result:=WAT_PLS_UNKNOWN; end; end else - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; end; function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl; @@ -260,7 +260,7 @@ begin isRemote:=StrPosW(mfile,'://')<>nil; if (prevfile=nil) or isRemote or (StrCmpW(prevfile,mfile)<>0) then begin - ClearTrackInfo(SongInfo,false); + ClearTrackInfo(SongInfo); mFreeMem(prevfile); StrDupW(prevfile,mfile); diff --git a/plugins/Watrack/players/pl_vlc.pas b/plugins/Watrack/players/pl_vlc.pas index f9bf7f0342..1a8f3185f1 100644 --- a/plugins/Watrack/players/pl_vlc.pas +++ b/plugins/Watrack/players/pl_vlc.pas @@ -12,7 +12,7 @@ uses windows,common,srv_player,wat_api,syswin,wrapper {$IFDEF KOL_MCK} ,kolcomobj {$ELSE} - ,mComObj + ,ComObj {$ENDIF} ; @@ -160,9 +160,9 @@ begin v:=CreateOleObject(COMName); tmp:=v.Playing; if tmp then - result:=WAT_MES_PLAYING + result:=WAT_PLS_PLAYING else - result:=WAT_MES_STOPPED; + result:=WAT_PLS_STOPPED; except result:=inherited GetStatus; end; diff --git a/plugins/Watrack/players/pl_winamp.pas b/plugins/Watrack/players/pl_winamp.pas index e107cb81f6..1b68759ab2 100644 --- a/plugins/Watrack/players/pl_winamp.pas +++ b/plugins/Watrack/players/pl_winamp.pas @@ -101,7 +101,7 @@ begin result:=nil; if (flags and WAT_OPT_IMPLANTANT)<>0 then begin - if SendMessage(wnd,WM_WA_IPC,0,IPC_ISPLAYING)<>WAT_MES_STOPPED then + if SendMessage(wnd,WM_WA_IPC,0,IPC_ISPLAYING)<>WAT_PLS_STOPPED then begin fpos :=SendMessage(wnd,WM_USER,0 ,IPC_GETLISTPOS); fname:=SendMessage(wnd,WM_USER,fpos,IPC_GETPLAYLISTFILE); diff --git a/plugins/Watrack/players/pl_wmp.pas b/plugins/Watrack/players/pl_wmp.pas index 41a8ad98fa..971cb28ac6 100644 --- a/plugins/Watrack/players/pl_wmp.pas +++ b/plugins/Watrack/players/pl_wmp.pas @@ -12,7 +12,7 @@ uses windows,common,messages,srv_player,wat_api {$IFDEF KOL_MCK} ,kolcomobj {$ELSE} - ,mComObj + ,ComObj {$ENDIF} ; diff --git a/plugins/Watrack/popup/popups.pas b/plugins/Watrack/popup/popups.pas index eda32a07ce..67ac946579 100644 --- a/plugins/Watrack/popup/popups.pas +++ b/plugins/Watrack/popup/popups.pas @@ -150,16 +150,10 @@ var Icon:HICON; sec:integer; cb,ct:TCOLORREF; - line:boolean; tmp:pAnsiChar; begin - line:=CallService(MS_POPUP_ISSECONDLINESHOWN,0,0)<>0; - descr:=PWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(PopText))); - if line then - title:=PWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(PopTitle))) - else - title:=nil; + title:=PWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(PopTitle))); if (descr<>nil) or (title<>nil) then begin @@ -204,13 +198,8 @@ begin colorText :=ct; PluginWindowProc:=@DumbPopupDlgProc; - if line then - begin - pzTitle.w:=title; - pzText .w:=descr; - end - else - pzTitle.w:=descr; + pzTitle.w:=title; + pzText .w:=descr; if ActionList=nil then flag:=0 @@ -245,22 +234,14 @@ begin FillChar(ppdu^,SizeOf(TPOPUPDATAW),0); with ppdu^ do begin - if line then - begin - if title<>nil then - StrCopyW(lpwzContactName,title,MAX_CONTACTNAME-1) - else - lpwzContactName[0]:=' '; - if descr<>nil then - StrCopyW(lpwzText,descr,MAX_SECONDLINE-1) - else - lpwzText[0]:=' '; - end + if title<>nil then + StrCopyW(lpwzContactName,title,MAX_CONTACTNAME-1) + else + lpwzContactName[0]:=' '; + if descr<>nil then + StrCopyW(lpwzText,descr,MAX_SECONDLINE-1) else - begin - StrCopyW(ppdu^.lpwzContactName,title,MAX_CONTACTNAME-1); lpwzText[0]:=' '; - end; lchIcon :=Icon; PluginWindowProc:=@DumbPopupDlgProc; @@ -301,7 +282,7 @@ begin result:=0; if DisablePlugin<>dsEnabled then exit; - if CallService(MS_WAT_GETMUSICINFO,0,tlparam(@si))=WAT_PLS_NORMAL then + if CallService(MS_WAT_GETMUSICINFO,0,tlparam(@si))=WAT_RES_OK then begin if PopupPresent then ShowPopup(si) diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas index d2b2d8b4d4..ec7c9bc84e 100644 --- a/plugins/Watrack/proto/proto.pas +++ b/plugins/Watrack/proto/proto.pas @@ -158,7 +158,7 @@ begin if present then begin - if CallService(MS_WAT_GETMUSICINFO,0,0)=WAT_PLS_NOTFOUND then + if CallService(MS_WAT_GETMUSICINFO,0,0)=WAT_RES_NOTFOUND then s:=nil else begin @@ -257,7 +257,7 @@ begin curpos:=nil; if DisablePlugin<>dsPermanent then begin - if CallService(MS_WAT_GETMUSICINFO,0,0)=WAT_PLS_NOTFOUND then + if CallService(MS_WAT_GETMUSICINFO,0,0)=WAT_RES_NOTFOUND then begin s:=#0#0#0'No player found at this time'; textpos:=s+3; diff --git a/plugins/Watrack/res/i_const.inc b/plugins/Watrack/res/i_const.inc index b1cafde523..bf61a75874 100644 --- a/plugins/Watrack/res/i_const.inc +++ b/plugins/Watrack/res/i_const.inc @@ -7,7 +7,6 @@ const IDC_TIMER = 1026; IDC_CHECKTIME = 1027; IDC_IMPLANTANT = 1028; - IDC_MTHCHECK = 1029; IDC_KEEPOLD = 1030; IDC_STAT_TIMER = 1031; IDC_COVERFN = 1032; @@ -17,7 +16,7 @@ const IDC_CHK_FORMAT = 1036; IDC_APPCOMMAND = 1037; IDC_CHECKALL = 1038; - IDC_TIMEOUT = 1039; + IDC_CHECKUNKN = 1039; {DLG 0 - modules} IDC_MODULEGROUP = 1025; diff --git a/plugins/Watrack/res/watrack.rc b/plugins/Watrack/res/watrack.rc index 2d3e6585d2..fe24df8b56 100644 --- a/plugins/Watrack/res/watrack.rc +++ b/plugins/Watrack/res/watrack.rc @@ -16,10 +16,7 @@ FONT 8, "MS Shell Dlg", 0, 0 AUTOCHECKBOX "Emulate Multimedia keys" , IDC_APPCOMMAND, 192, 84, 108, 16, BS_VCENTER | BS_MULTILINE | BS_NOTIFY AUTOCHECKBOX "Use process implantation" , IDC_IMPLANTANT, 192, 100, 108, 16, BS_VCENTER | BS_MULTILINE | BS_NOTIFY AUTOCHECKBOX "Check all players" , IDC_CHECKALL , 192, 116, 108, 16, BS_VCENTER | BS_MULTILINE | BS_NOTIFY - AUTOCHECKBOX "Other thread handle check" , IDC_MTHCHECK , 192, 132, 108, 16, BS_VCENTER | BS_MULTILINE | BS_NOTIFY - - EDITTEXT IDC_TIMEOUT , 192, 149, 20, 12, ES_RIGHT | ES_NUMBER - LTEXT "Timeout, ms", -1, 214, 148, 86, 14, SS_CENTERIMAGE + AUTOCHECKBOX "Check unknown formats" , IDC_CHECKUNKN , 192, 132, 108, 16, BS_VCENTER | BS_MULTILINE | BS_NOTIFY CONTROL "", IDC_PLAYERLIST, "SysListView32", WS_BORDER | WS_TABSTOP | LVS_NOCOLUMNHEADER | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, @@ -72,7 +69,7 @@ FONT 8, "MS Shell Dlg", 0, 0 { GROUPBOX "Switch ON these modules", IDC_MODULEGROUP, 2, 2, 188, 218, WS_TABSTOP } - +/* LANGUAGE 0,0 VS_VERSION_INFO VERSIONINFO FILEVERSION 0,0,6,12 @@ -102,3 +99,4 @@ BEGIN VALUE "Translation",0,1200 END END +*/ \ No newline at end of file diff --git a/plugins/Watrack/res/watrack.res b/plugins/Watrack/res/watrack.res index 29b014c408..49df939baa 100644 Binary files a/plugins/Watrack/res/watrack.res and b/plugins/Watrack/res/watrack.res differ diff --git a/plugins/Watrack/srv_format.pas b/plugins/Watrack/srv_format.pas index 58c046c712..c5f2cef6ed 100644 --- a/plugins/Watrack/srv_format.pas +++ b/plugins/Watrack/srv_format.pas @@ -5,25 +5,30 @@ interface uses windows,wat_api; +// dialog procedures procedure DefFillFormatList (hwndList:HWND); procedure DefCheckFormatList(hwndList:HWND); -function ProcessFormatLink:integer; -function GetFileFormatInfo(var dst:tSongInfo):integer; -function CheckExt(fname:pWideChar):integer; +// init/free procedures +function ProcessFormatLink:integer; +procedure ClearFormats; -function DeleteKnownExt(src:pWideChar):pWideChar; -function KnownFileType(fname:PWideChar):boolean; -function isContainer(fname:PWideChar):boolean; +function CheckExt (fname:pWideChar):integer; +// support functions +function DeleteKnownExt(fname:pWideChar):pWideChar; +function KnownFileType (fname:PWideChar):boolean; +function isContainer (fname:PWideChar):boolean; +// miranda-like service function function ServiceFormat(wParam:WPARAM;lParam:LPARAM):integer;cdecl; +// internal helper (can be moved to implementation section) procedure RegisterFormat(ext:PAnsiChar;proc:tReadFormatProc;flags:dword=0); -procedure ClearFormats; type MusEnumProc = function(param:PAnsiChar;lParam:LPARAM):bool;stdcall; function EnumFormats(param:MusEnumProc;lParam:LPARAM):bool; +function GetActiveFormat:pMusicFormat; type pwFormat = ^twFormat; @@ -35,10 +40,12 @@ type const FormatLink:pwFormat=nil; + implementation uses CommCtrl,common; + type pFmtArray = ^tFmtArray; tFmtArray = array [0..10] of tMusicFormat; @@ -52,18 +59,10 @@ const FmtNum:integer=0; FmtMax:integer=0; -function ProcessFormatLink:integer; -var - ptr:pwFormat; + +function GetActiveFormat:pMusicFormat; begin - result:=0; - ptr:=FormatLink; - while ptr<>nil do - begin - RegisterFormat(@ptr.This.ext,ptr.This.proc,ptr.This.flags); - inc(result); - ptr:=ptr^.Next; - end; + result:=@fmtLink^[0]; end; function EnumFormats(param:MusEnumProc;lParam:LPARAM):bool; @@ -111,6 +110,8 @@ begin result:=WAT_RES_NOTFOUND; end; +//----- dialog procedures ----- + procedure DefFillFormatList(hwndList:HWND); var item:LV_ITEMA; @@ -173,218 +174,210 @@ begin end; end; -function DeleteKnownExt(src:pWideChar):pWideChar; -var - s :array [0..7] of WideChar; - ss:array [0..7] of AnsiChar; - i,j:integer; -begin - GetExt(src,s); - if s[0]<>#0 then - begin - int64(ss):=0; - i:=0; - while (s[i]<>#0) and (i<8) do - begin - ss[i]:=AnsiChar(s[i]); - inc(i); - end; - j:=0; - while j#0 then begin + // translate ext to int64 i:=0; + int64(ss):=0; while (s[i]<>#0) and (i<8) do begin ss[i]:=AnsiChar(s[i]); inc(i); end; + + // search number i:=0; while i=0 then begin - result:=(fmtLink^[0].flags and WAT_OPT_CONTAINER)<>0; - end - else - result:=false; + i:=StrLen(fmtLink^[i].ext); + fname[integer(StrLenW(fname))-i-1]:=#0; + end; + + result:=fname; end; -function GetFileFormatInfo(var dst:tSongInfo):integer; +function KnownFileType(fname:PWideChar):boolean; +var + i:integer; begin - result:=CheckExt(dst.mfile); - if result=WAT_RES_OK then + result:=false; + + i:=FindExt(fname); + if i>=0 then begin - fmtLink^[0].proc(dst); + if ((fmtLink^[i].flags and WAT_OPT_DISABLED)=0) then + result:=true; end; end; function CheckExt(fname:pWideChar):integer; var - i:integer; tmp:tMusicFormat; - ls:array [0..7] of WideChar; - ss:array [0..7] of AnsiChar; + i:integer; begin - GetExt(fname,ls); - i:=0; - int64(ss):=0; - while (ls[i]<>#0) and (i<8) do + i:=FindExt(fname); + if i>=0 then begin - ss[i]:=AnsiChar(ls[i]); - inc(i); - end; - i:=0; - while i0 then - begin - tmp:=fmtLink^[i]; - move(fmtLink^[0],fmtLink^[1],SizeOf(tMusicFormat)*i); - fmtLink^[0]:=tmp; - end; - result:=WAT_RES_OK; - exit; - end - else - break; - end; - inc(i); - end; - result:=WAT_RES_NOTFOUND; + // move to top + tmp:=fmtLink^[i]; + move(fmtLink^[0],fmtLink^[1],SizeOf(tMusicFormat)*i); + fmtLink^[0]:=tmp; + + result:=WAT_RES_OK; + end + else + result:=WAT_RES_DISABLED; + end + else + result:=WAT_RES_NOTFOUND; end; +function isContainer(fname:PWideChar):boolean; +begin + if CheckExt(fname)=WAT_RES_OK then + begin + result:=(fmtLink^[0].flags and WAT_OPT_CONTAINER)<>0; + end + else + result:=false; +end; + + function ServiceFormat(wParam:WPARAM;lParam:LPARAM):integer;cdecl; var p:integer; nl:pFmtArray; begin result:=WAT_RES_NOTFOUND; - if LoWord(wParam)<>WAT_ACT_REGISTER then - p:=FindFormat(PAnsiChar(lParam)) - else - p:=0; - case LoWord(wParam) of - WAT_ACT_REGISTER: begin - if @pMusicFormat(lParam)^.proc=nil then + + if LoWord(wParam)=WAT_ACT_REGISTER then + begin + if @pMusicFormat(lParam)^.proc=nil then + exit; + + p:=FindFormat(pMusicFormat(lParam)^.ext); + if (p=WAT_RES_NOTFOUND) or ((wParam and WAT_ACT_REPLACE)<>0) then + begin + if (p<>WAT_RES_NOTFOUND) and ((fmtLink^[p].flags and WAT_OPT_ONLYONE)<>0) then exit; - p:=FindFormat(pMusicFormat(lParam)^.ext); - if (p=WAT_RES_NOTFOUND) or ((wParam and WAT_ACT_REPLACE)<>0) then + + if FmtNum=FmtMax then // expand array when append begin - if (p<>WAT_RES_NOTFOUND) and ((fmtLink^[p].flags and WAT_OPT_ONLYONE)<>0) then - exit; - if FmtNum=FmtMax then // expand array when append + if FmtMax=0 then + FmtMax:=StartSize + else + inc(FmtMax,Step); + GetMem(nl,FmtMax*SizeOf(tMusicFormat)); + if fmtLink<>nil then begin - if FmtMax=0 then - FmtMax:=StartSize - else - inc(FmtMax,Step); - GetMem(nl,FmtMax*SizeOf(tMusicFormat)); - if fmtLink<>nil then - begin - move(fmtLink^,nl^,FmtNum*SizeOf(tMusicFormat)); - FreeMem(fmtLink); - end; - fmtLink:=nl; + move(fmtLink^,nl^,FmtNum*SizeOf(tMusicFormat)); + FreeMem(fmtLink); end; - if p=WAT_RES_NOTFOUND then - begin - p:=FmtNum; - result:=WAT_RES_OK; - inc(FmtNum); - end - else - result:=int_ptr(@fmtLink^[p].proc); - move(pMusicFormat(lParam)^,fmtLink^[p],SizeOf(tMusicFormat));// fill + fmtLink:=nl; end; - end; - WAT_ACT_UNREGISTER: begin - if p<>WAT_RES_NOTFOUND then + + if p=WAT_RES_NOTFOUND then begin - dec(FmtNum); - if pWAT_RES_NOTFOUND then - begin - fmtLink^[p].flags:=fmtLink^[p].flags or WAT_OPT_DISABLED; - result:=WAT_RES_DISABLED - end; - end; - WAT_ACT_ENABLE: begin - if p<>WAT_RES_NOTFOUND then - begin - fmtLink^[p].flags:=fmtLink^[p].flags and not WAT_OPT_DISABLED; - result:=WAT_RES_ENABLED - end; + inc(FmtNum); + end + else + result:=int_ptr(@fmtLink^[p].proc); + + move(pMusicFormat(lParam)^,fmtLink^[p],SizeOf(tMusicFormat));// fill end; - WAT_ACT_GETSTATUS: begin - if p<>WAT_RES_NOTFOUND then - begin - if (fmtLink^[p].flags and WAT_OPT_DISABLED)<>0 then - result:=WAT_RES_DISABLED - else + end + else + begin + p:=FindFormat(PAnsiChar(lParam)); + if p<>WAT_RES_NOTFOUND then + case LoWord(wParam) of + WAT_ACT_UNREGISTER: begin + dec(FmtNum); + if p0 then + result:=WAT_RES_DISABLED + else + result:=WAT_RES_ENABLED; + end; end; - end; + end; end; +//----- init/free procedures ----- + procedure RegisterFormat(ext:PAnsiChar;proc:tReadFormatProc;flags:dword=0); var tmp:tMusicFormat; begin FillChar(tmp,SizeOf(tMusicFormat),0); StrCopy (tmp.ext,ext,7); - tmp.proc:=proc; + tmp.proc :=proc; tmp.flags:=flags; ServiceFormat(WAT_ACT_REGISTER,LPARAM(@tmp)); end; +function ProcessFormatLink:integer; +var + ptr:pwFormat; +begin + result:=0; + ptr:=FormatLink; + while ptr<>nil do + begin + RegisterFormat(@ptr.This.ext, ptr.This.proc, ptr.This.flags); + inc(result); + ptr:=ptr^.Next; + end; +end; + procedure ClearFormats; begin if FmtNum>0 then diff --git a/plugins/Watrack/srv_getinfo.pas b/plugins/Watrack/srv_getinfo.pas new file mode 100644 index 0000000000..dda96769b7 --- /dev/null +++ b/plugins/Watrack/srv_getinfo.pas @@ -0,0 +1,383 @@ +unit srv_getinfo; + +interface + +uses wat_api; + +function GetPlayerInfo(var dst:tSongInfo;flags:cardinal):integer; +{ + WAT_RES_OK + WAT_RES_NEWPLAYER + WAT_RES_NOTFOUND +} + +function GetFileInfo(var dst:tSongInfo;flags:cardinal;timeout:cardinal):integer; +{ + WAT_RES_OK + WAT_RES_NEWFILE + WAT_RES_UNKNOWN + WAT_RES_NOTFOUND +} + +function GetChangingInfo(var dst:tSongInfo;flags:cardinal):integer; +{ + WAT_RES_OK +} + +function GetInfo(var dst:tSongInfo;flags:cardinal):integer; +{ + WAT_RES_OK + WAT_RES_NEWFILE +} +function GetFileFormatInfo(var dst:tSongInfo):integer; +{ + WAT_RES_OK + WAT_RES_NOTFOUND +} + + +implementation + +uses + windows, + common, msninfo, syswin, wrapper, io, winampapi, + srv_player, srv_format; + + +//----- get player info ----- + +function DefGetVersionText(ver:integer):pWideChar; +begin + if ver<>0 then + begin + mGetMem(result,10*SizeOf(WideChar)); + IntToHex(result,ver); + end + else + result:=nil; +end; + +function GetPlayerInfo(var dst:tSongInfo;flags:cardinal):integer; +var + plwnd:HWND; + pl:pPlayerCell; + PlayerChanged:bool; +begin + plwnd:=CheckAllPlayers(flags,dst.status,PlayerChanged); + + if plwnd<>HWND(WAT_RES_NOTFOUND) then + begin + if PlayerChanged then + begin + ClearPlayerInfo(dst); + + pl:=GetActivePlayer; + AnsiToWide(pl^.Desc,dst.player); + dst.plwnd:=plwnd; + FastAnsiToWide(pl^.URL,dst.url); + if pl^.icon<>0 then + dst.icon:=CopyIcon(pl^.icon); + + if pl^.GetInfo<>nil then + tInfoProc(pl^.GetInfo)(dst,flags or WAT_OPT_PLAYERDATA) + else if (pl^.flags and WAT_OPT_WINAMPAPI)<>0 then + WinampGetInfo(wparam(@dst),flags or WAT_OPT_PLAYERDATA); + + if (pl^.flags and WAT_OPT_PLAYERINFO)=0 then + if dst.txtver=NIL then dst.txtver:=DefGetVersionText(dst.plyver); + + result:=WAT_RES_NEWPLAYER; + end + else + begin + dst.plwnd:=plwnd; // to prevent same player, another instance + result:=WAT_RES_OK; + end + end + else + result:=WAT_RES_NOTFOUND; +end; + +//----- get file info ----- + +function GetFileInfo(var dst:tSongInfo;flags:cardinal;timeout:cardinal):integer; +var + ftime:int64; + f:THANDLE; + fname:pWideChar; + pl:pPlayerCell; + remote,FileChanged:boolean; + tmp:integer; +begin + pl:=GetActivePlayer; + + if pl^.GetName<>nil then + fname:=tNameProc(pl^.GetName)(dst.plwnd,flags) + else + fname:=nil; + + if (fname=nil) and (dst.plwnd<>0) then + begin + tmp:=0; + if (flags and WAT_OPT_KEEPOLD)<>0 then tmp:=tmp or gffdOld; + fname:=GetFileFromWnd(dst.plwnd,KnownFileType,tmp,timeout); + end; + + if fname<>nil then + begin + remote:=StrPosW(fname,'://')<>nil; + // file changing time (local/lan only) + if not remote then + begin + f:=Reset(fname); + + if f<>THANDLE(INVALID_HANDLE_VALUE) then + begin + GetFileTime(f,nil,nil,@ftime); + CloseHandle(f); + end; + end; + // same file + if (dst.mfile<>nil) and (lstrcmpiw(dst.mfile,fname)=0) then + begin + if (not remote) and ((flags and WAT_OPT_CHECKTIME)<>0) then + FileChanged:=dst.date<>ftime + else + FileChanged:=false; + end + else // new filename + begin + FileChanged:=true; + end; + + // if not proper ext (we don't working with it) + //!!!! check for remotes + if (not remote) and (CheckExt(fname)=WAT_RES_NOTFOUND) then + begin + if (flags and WAT_OPT_UNKNOWNFMT)<>0 then + begin + ClearFileInfo(dst); + + dst.mfile:=fname; + dst.date :=ftime; + dst.fsize:=GetFSize(dst.mfile); + + result:=WAT_RES_UNKNOWN; + end + else + begin + mFreeMem(fname); + result:=WAT_RES_NOTFOUND; + end; + end + else if FileChanged {or isContainer(fname)} then + begin + ClearFileInfo(dst); + + dst.mfile:=fname; //!! must be when format recognized or remote + dst.date :=ftime; //!! + dst.fsize:=GetFSize(dst.mfile); + result:=WAT_RES_NEWFILE; + end + else + begin + result:=WAT_RES_OK; + mFreeMem(fname); + end; + end + else + begin + result:=WAT_RES_NOTFOUND; + end; +end; + +//----- get changing info ----- + +function DefGetWndText(pl:pPlayerCell; wnd:HWND):pWideChar; +var + p:pWideChar; +begin + if wnd<>0 then + begin + result:=GetDlgText(wnd); + if result<>nil then + begin + if (pl^.flags and WAT_OPT_TEMPLATE)<>0 then + begin + with pTmplCell(pl^.Check)^ do + begin + if p_prefix<>nil then + begin + p:=StrPosW(result,p_prefix); + if p=result then + StrCopyW(result,result+StrLenW(p_prefix)); + end; + if p_postfix<>nil then + begin + p:=StrPosW(result,p_postfix); + if p<>nil then + p^:=#0; + end; + end; + end; + end; + end + else + result:=nil; +end; + +function GetChangingInfo(var dst:tSongInfo;flags:cardinal):integer; +var + pl:pPlayerCell; +begin + result:=WAT_RES_OK; + + ClearChangingInfo(dst); + + pl:=GetActivePlayer; + + if pl^.GetInfo<>nil then + tInfoProc(pl^.GetInfo)(dst,flags or WAT_OPT_CHANGES) + else if (pl^.flags and WAT_OPT_WINAMPAPI)<>0 then + WinampGetInfo(wparam(@dst),flags or WAT_OPT_CHANGES); + + if (pl^.flags and WAT_OPT_PLAYERINFO)=0 then + if dst.wndtext=NIL then dst.wndtext:=DefGetWndText(pl,dst.plwnd); +end; + +//----- get track info ----- + +function GetSeparator(str:pWideChar):dword; +begin + result:=StrIndexW(str,' '#$2013' '); + if result=0 then + result:=StrIndexW(str,' - '); + if result<>0 then + begin + result:=result-1 + (3 SHL 16); + exit; + end; + result:=StrIndexW(str,#$2013); + if result=0 then + result:=StrIndexW(str,'-'); + if result>0 then + result:=result-1 + (1 SHL 16); +end; + +function DefGetTitle(wnd:HWND;fname,wndtxt:pWideChar):pWideChar; +var + i:integer; + tmp:pWideChar; +begin + if fname<>nil then + tmp:=DeleteKnownExt(ExtractW(fname,true)) + else + tmp:=wndtxt; + if tmp=nil then + begin + result:=nil; + exit; + end; + StrDupW(result,tmp); + i:=GetSeparator(result); + if i>0 then + StrCopyW(result,result+LoWord(i)+HiWord(i)); + if fname<>nil then + mFreeMem(tmp); +end; + +function DefGetArtist(wnd:HWND;fname,wndtxt:pWideChar):pWideChar; +var + i:integer; + tmp:pWideChar; +begin + if fname<>nil then + tmp:=DeleteKnownExt(ExtractW(fname,true)) + else + tmp:=wndtxt; + if tmp=nil then + begin + result:=nil; + exit; + end; + StrDupW(result,tmp); + i:=GetSeparator(result); + if i>0 then + result[LoWord(i)]:=#0; + if fname<>nil then + mFreeMem(tmp); +end; + +function GetFileFormatInfo(var dst:tSongInfo):integer; +var + fmt:pMusicFormat; +begin + result:=CheckExt(dst.mfile); + if result=WAT_RES_OK then + begin + fmt:=GetActiveFormat; + fmt^.proc(dst); + end; +end; + +function GetInfo(var dst:tSongInfo;flags:cardinal):integer; +var + oldartist,oldtitle:pWideChar; + fname:pWideChar; + pl:pPlayerCell; + lmsnInfo:pMSNInfo; + remote:boolean; +begin + result:=WAT_RES_OK; + + remote:=StrPosW(dst.mfile,'://')<>nil; + +// if remote or ((plyLink^[0].flags and WAT_OPT_PLAYERINFO)<>0) then + oldartist:=dst.artist; oldtitle:=dst.title; + + ClearTrackInfo(dst); + + // info from player + pl:=GetActivePlayer; + if pl^.GetInfo<>nil then + tInfoProc(pl^.GetInfo)(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); + + // info from file + GetFileFormatInfo(dst); + + if (pl^.flags and WAT_OPT_PLAYERINFO)=0 then + with dst do + begin + if remote then + fname:=nil + else + fname:=mfile; + + lmsnInfo:=GetMSNInfo; + + if lmsnInfo<>nil then + begin + if artist=NIL then StrDupW(artist,lmsnInfo.msnArtist); + if title =NIL then StrDupW(title ,lmsnInfo.msnTitle); + if album =NIL then StrDupW(album ,lmsnInfo.msnAlbum); + end; + + if artist=NIL then artist:=DefGetArtist(plwnd,fname,wndtext); + if title =NIL then title :=DefGetTitle (plwnd,fname,wndtext); + end; + + if remote or ((pl^.flags and WAT_OPT_PLAYERINFO)<>0) or + isContainer(dst.mfile) then + begin + if (oldartist=oldtitle) or + ((oldartist<>nil) and (StrCmpW(dst.artist,oldartist)<>0)) or + ((oldtitle <>nil) and (StrCmpW(dst.title ,oldtitle )<>0)) then + begin + result:=WAT_RES_NEWFILE; + end; + end; +end; + +end. diff --git a/plugins/Watrack/srv_player.pas b/plugins/Watrack/srv_player.pas index be55c6f2a2..5f16f8c528 100644 --- a/plugins/Watrack/srv_player.pas +++ b/plugins/Watrack/srv_player.pas @@ -5,17 +5,17 @@ interface uses windows,common,wat_api; -function GetPlayerNote(name:PAnsiChar):pWideChar; - -function SetPlayerIcons(fname:pAnsiChar):integer; - -function LoadFromFile(fname:PAnsiChar):integer; +// init/free procedures function ProcessPlayerLink:integer; - +procedure ClearPlayers; +// miranda-style function for new player registering function ServicePlayer(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; -function SendCommand (wParam:WPARAM;lParam:LPARAM;flags:integer):int_ptr; +// next 2 functions are public coz in watrack they going with GetAddonFileName funcion +// which uses some miranda things +function SetPlayerIcons(fname:pAnsiChar):integer; +function LoadFromFile(fname:PAnsiChar):integer; -procedure ClearPlayers; +function SendCommand(wParam:WPARAM;lParam:LPARAM;flags:integer):int_ptr; // options procedures procedure DefFillPlayerList (hwndList:HWND); @@ -25,24 +25,21 @@ type MusEnumProc = function(param:PAnsiChar;lParam:LPARAM):bool;stdcall; function EnumPlayers(param:MusEnumProc;lParam:LPARAM):bool; +function GetPlayerNote(name:PAnsiChar):pWideChar; +function CheckAllPlayers(flags:integer;var status:integer; var PlayerChanged:bool):HWND; +function GetActivePlayer:pPlayerCell; -// "Get info" procedures -function CheckPlayers (var dst:tSongInfo;flags:cardinal):integer; -function CheckFile (var dst:tSongInfo;flags:cardinal;timeout:cardinal):integer; -function GetChangingInfo(var dst:tSongInfo;flags:cardinal):integer; -function GetInfo (var dst:tSongInfo;flags:cardinal):integer; - -// support procedures -procedure ClearSongInfoData(var dst:tSongInfo;withFree:bool); -procedure ClearPlayerInfo (var dst:tSongInfo;withFree:bool); -procedure ClearFileInfo (var dst:tSongInfo;withFree:bool); -procedure ClearChangingInfo(var dst:tSongInfo;withFree:bool); -procedure ClearTrackInfo (var dst:tSongInfo;withFree:bool); - -procedure CopyPlayerInfo (const src:tSongInfo;var dst:tSongInfo); -procedure CopyFileInfo (const src:tSongInfo;var dst:tSongInfo); -procedure CopyChangingInfo(const src:tSongInfo;var dst:tSongInfo); -procedure CopyTrackInfo (const src:tSongInfo;var dst:tSongInfo); +type + pTmplCell = ^tTmplCell; + tTmplCell = record + p_class, + p_text :PAnsiChar; + p_class1, + p_text1 :PAnsiChar; + p_file :PAnsiChar; + p_prefix :pWideChar; + p_postfix:pWideChar; + end; type pwPlayer = ^twPlayer; @@ -54,28 +51,17 @@ type const PlayerLink:pwPlayer=nil; + implementation uses - shellapi,CommCtrl - ,appcmdapi,io,syswin,wrapper,srv_format,winampapi,msninfo,memini; + CommCtrl, shellapi, + appcmdapi,winampapi,memini,syswin; type pPlyArray = ^tPlyArray; tPlyArray = array [0..10] of tPlayerCell; -type - pTmplCell = ^tTmplCell; - tTmplCell = record - p_class, - p_text :PAnsiChar; - p_class1, - p_text1 :PAnsiChar; - p_file :PAnsiChar; - p_prefix :pWideChar; - p_postfix:pWideChar; - end; - const StartSize = 32; Step = 8; @@ -86,81 +72,7 @@ const PlyNum:integer=0; PlyMax:integer=0; -function ProcessPlayerLink:integer; -var - ptr:pwPlayer; -begin - ptr:=PlayerLink; - result:=0; - while ptr<>nil do - begin - ServicePlayer(WAT_ACT_REGISTER,lparam(ptr.This)); - ptr:=ptr^.Next; - inc(result); - end; -end; - -function SetPlayerIcons(fname:pAnsiChar):integer; -var - i,j:integer; - buf:array [0..255] of AnsiChar; - p,pp:pAnsiChar; - lhIcon:HICON; -begin - result:=LoadLibraryA(fname); - if result<>0 then - begin - p:=StrCopyE(buf,'Player_'); - i:=0; - while i0 then - begin - if Icon<>0 then - DestroyIcon(Icon); - Icon:=lhIcon; - end; - end; - inc(i); - end; - FreeLibrary(result); - end; -end; - -function EnumPlayers(param:MusEnumProc;lParam:LPARAM):bool; -var - tmp:pPlyArray; - i,j:integer; -begin - if (PlyNum>0) and (@param<>nil) then - begin - GetMem(tmp,PlyNum*SizeOf(tPlayerCell)); - move(PlyLink^,tmp^,PlyNum*SizeOf(tPlayerCell)); - i:=0; - j:=PlyNum; - repeat - if not param(tmp^[i].Desc,lParam) then break; - inc(i); - until i=j; - FreeMem(tmp); - result:=true; - end - else - result:=false; -end; +//----- Support functions ----- procedure PreProcess; // BASS to start var @@ -175,11 +87,7 @@ begin tmp:=plyLink^[i]; move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*i); plyLink^[0]:=tmp; -{ - move(plyLink^[i],tmp,SizeOf(tPlayerCell)); - move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*i); - move(tmp,plyLink^[0],SizeOf(tPlayerCell)); -} + break; end; inc(i); @@ -189,11 +97,6 @@ begin tmp:=plyLink^[0]; move(plyLink^[1],plyLink^[0],SizeOf(tPlayerCell)*(PlyNum-1)); plyLink^[PlyNum-1]:=tmp; -{ - move(plyLink^[0],tmp,SizeOf(tPlayerCell)); - move(plyLink^[1],plyLink^[0],SizeOf(tPlayerCell)*(PlyNum-1)); - move(tmp,plyLink^[PlyNum-1],SizeOf(tPlayerCell)); -} end; end; @@ -211,11 +114,6 @@ begin tmp:=plyLink^[i]; move(plyLink^[i+1],plyLink^[i],SizeOf(tPlayerCell)*(PlyNum-i-1)); plyLink^[PlyNum-1]:=tmp; -{ - move(plyLink^[i],tmp,SizeOf(tPlayerCell)); - move(plyLink^[i+1],plyLink^[i],SizeOf(tPlayerCell)*(PlyNum-i-1)); - move(tmp,plyLink^[PlyNum-1],SizeOf(tPlayerCell)); -}// break; i:=1; dec(j); continue; @@ -244,83 +142,48 @@ begin result:=WAT_RES_NOTFOUND; end; -function GetPlayerNote(name:PAnsiChar):pWideChar; -var - i:integer; +//----- public functions ----- + +function GetActivePlayer:pPlayerCell; begin - i:=FindPlayer(name); - if i>=0 then - result:=plyLink^[i].Notes - else - result:=nil; + result:=@plyLink^[0]; end; -procedure DefFillPlayerList(hwndList:HWND); +function EnumPlayers(param:MusEnumProc;lParam:LPARAM):bool; var - item:LV_ITEMA; - lvc:TLVCOLUMN; - i,newItem:integer; - - il:HIMAGELIST; //!! + tmp:pPlyArray; + i,j:integer; begin - FillChar(item,SizeOf(item),0); - FillChar(lvc,SizeOf(lvc),0); - ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES); - lvc.mask:=LVCF_FMT or LVCF_WIDTH; - - lvc.fmt:=LVCFMT_LEFT; - lvc.cx:=160; - ListView_InsertColumn(hwndList,0,lvc); - - item.mask:=LVIF_TEXT or LVIF_IMAGE; //!! - i:=0; - - il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); //!! - while i0) and (@param<>nil) then begin - item.iImage:=ImageList_AddIcon(il,plyLink^[i].Icon); - item.iItem:=i; - item.pszText:=plyLink^[i].Desc; - newItem:=SendMessageA(hwndList,LVM_INSERTITEMA,0,lparam(@item)); - if newItem>=0 then - begin - if (plyLink^[i].flags and WAT_OPT_DISABLED)=0 then - ListView_SetCheckState(hwndList,newItem,TRUE); - end; - inc(i); - end; - ImageList_Destroy(SendMessage(hwndList,LVM_SETIMAGELIST,LVSIL_SMALL,il)); //!! -// ListView_SetColumnWidth(hwndList,0,LVSCW_AUTOSIZE); + GetMem(tmp,PlyNum*SizeOf(tPlayerCell)); + move(PlyLink^,tmp^,PlyNum*SizeOf(tPlayerCell)); + i:=0; + j:=PlyNum; + repeat + if not param(tmp^[i].Desc,lParam) then break; + inc(i); + until i=j; + FreeMem(tmp); + result:=true; + end + else + result:=false; end; -procedure DefCheckPlayerList(hwndList:HWND); +function GetPlayerNote(name:PAnsiChar):pWideChar; var - i,j,k:integer; - item:LV_ITEMA; - szTemp:array [0..109] of AnsiChar; - p:pPlayerCell; + i:integer; begin - FillChar(item,SizeOf(item),0); - item.mask :=LVIF_TEXT; - item.pszText :=@szTemp; - item.cchTextMax:=100; - k:=ListView_GetItemCount(hwndList)-1; - for i:=0 to k do - begin - item.iItem:=i; - SendMessageA(hwndList,LVM_GETITEMA,0,lparam(@item)); - j:=FindPlayer(item.pszText); - if j<>WAT_RES_NOTFOUND then - begin - p:=@plyLink^[j]; - if ListView_GetCheckState(hwndList,i)=0 then - p^.flags:=p^.flags or WAT_OPT_DISABLED - else - p^.flags:=p^.flags and not WAT_OPT_DISABLED; - end; - end; + i:=FindPlayer(name); + if i>=0 then + result:=plyLink^[i].Notes + else + result:=nil; end; +//----- Init/free ----- + procedure ClearTemplate(tmpl:pTmplCell); begin with tmpl^ do @@ -344,170 +207,200 @@ var tmp:tPlayerCell; begin result:=WAT_RES_ERROR; + if LoWord(wParam)=WAT_ACT_REGISTER then begin if pPlayerCell(lParam)^.Check=nil then exit; - p:=0; - end - else - p:=FindPlayer(PAnsiChar(lParam)); - case LoWord(wParam) of - WAT_ACT_REGISTER: begin - p:=FindPlayer(pPlayerCell(lParam)^.Desc); - if (p=WAT_RES_NOTFOUND) or ((wParam and WAT_ACT_REPLACE)<>0) then + p:=FindPlayer(pPlayerCell(lParam)^.Desc); + if (p=WAT_RES_NOTFOUND) or ((wParam and WAT_ACT_REPLACE)<>0) then + begin + if (p<>WAT_RES_NOTFOUND) and ((plyLink^[p].flags and WAT_OPT_ONLYONE)<>0) then + exit; + + if p=WAT_RES_NOTFOUND then begin - if (p<>WAT_RES_NOTFOUND) and ((plyLink^[p].flags and WAT_OPT_ONLYONE)<>0) then - exit; + p:=PlyNum; + result:=WAT_RES_OK; - if p=WAT_RES_NOTFOUND then + if PlyNum=PlyMax then // expand array when append begin - p:=PlyNum; - result:=WAT_RES_OK; - - if PlyNum=PlyMax then // expand array when append + if PlyMax=0 then + PlyMax:=StartSize + else + inc(PlyMax,Step); + GetMem(nl,PlyMax*SizeOf(tPlayerCell)); + if plyLink<>nil then begin - if PlyMax=0 then - PlyMax:=StartSize - else - inc(PlyMax,Step); - GetMem(nl,PlyMax*SizeOf(tPlayerCell)); - if plyLink<>nil then - begin - move(plyLink^,nl^,PlyNum*SizeOf(tPlayerCell)); - FreeMem(plyLink); - end; - plyLink:=nl; + move(plyLink^,nl^,PlyNum*SizeOf(tPlayerCell)); + FreeMem(plyLink); end; - FillChar(plyLink^[p],SizeOf(tPlayerCell),0); + plyLink:=nl; + end; + + FillChar(plyLink^[p],SizeOf(tPlayerCell),0); // doubling notes - if (pPlayerCell(lParam)^.Notes<>nil) and - ((pPlayerCell(lParam)^.flags and WAT_OPT_TEMPLATE)=0) then - begin - i:=(StrLenW(pPlayerCell(lParam)^.Notes)+1)*SizeOf(WideChar); - GetMem(plyLink^[p].Notes,i); - move(pPlayerCell(lParam)^.Notes^,plyLink^[p].Notes^,i); - end - else - plyLink^[p].Notes:=pPlayerCell(lParam)^.Notes; + if (pPlayerCell(lParam)^.Notes<>nil) and + ((pPlayerCell(lParam)^.flags and WAT_OPT_TEMPLATE)=0) then + begin + i:=(StrLenW(pPlayerCell(lParam)^.Notes)+1)*SizeOf(WideChar); + GetMem(plyLink^[p].Notes,i); + move(pPlayerCell(lParam)^.Notes^,plyLink^[p].Notes^,i); + end + else + plyLink^[p].Notes:=pPlayerCell(lParam)^.Notes; // doubling description - i:=StrLen(pPlayerCell(lParam)^.Desc)+1; - GetMem(plyLink^[p].Desc,i); - move(pPlayerCell(lParam)^.Desc^,plyLink^[p].Desc^,i); + i:=StrLen(pPlayerCell(lParam)^.Desc)+1; + GetMem(plyLink^[p].Desc,i); + move(pPlayerCell(lParam)^.Desc^,plyLink^[p].Desc^,i); // doubling url - if pPlayerCell(lParam)^.URL<>nil then - begin - with plyLink^[p] do - begin - i:=StrLen(pPlayerCell(lParam)^.URL)+1; - GetMem(URL,i); - move(pPlayerCell(lParam)^.URL^,URL^,i); - end; - end - else - plyLink^[p].URL:=nil; - - inc(PlyNum); - end - else // existing player - begin - if (plyLink^[p].flags and WAT_OPT_TEMPLATE)=0 then - result:=int_ptr(plyLink^[p].Check) - else - begin // remove any info from templates - result:=WAT_RES_OK; - ClearTemplate(pTmplCell(plyLink^[p].Check)); - end; - end; - // fill info - with plyLink^[p] do + if pPlayerCell(lParam)^.URL<>nil then begin - flags:=pPlayerCell(lParam)^.flags; - if URL<>nil then - flags:=flags or WAT_OPT_HASURL; - if pPlayerCell(lParam)^.Icon<>0 then + with plyLink^[p] do begin - if icon<>0 then - DestroyIcon(icon); - icon:=CopyIcon(pPlayerCell(lParam)^.Icon); + i:=StrLen(pPlayerCell(lParam)^.URL)+1; + GetMem(URL,i); + move(pPlayerCell(lParam)^.URL^,URL^,i); end; - Init :=pPlayerCell(lParam)^.Init; - DeInit :=pPlayerCell(lParam)^.DeInit; - Check :=pPlayerCell(lParam)^.Check; - GetStatus:=pPlayerCell(lParam)^.GetStatus; - GetName :=pPlayerCell(lParam)^.GetName; - GetInfo :=pPlayerCell(lParam)^.GetInfo; - Command :=pPlayerCell(lParam)^.Command; - if Init<>nil then - tInitProc(Init); - end; + end + else + plyLink^[p].URL:=nil; -// PreProcess; - PostProcess; - end; - end; + inc(PlyNum); + end - WAT_ACT_UNREGISTER: begin - if p<>WAT_RES_NOTFOUND then + else // existing player begin - dec(PlyNum); - if plyLink^[p].DeInit<>nil then - tDeInitProc(plyLink^[p].DeInit); - FreeMem(plyLink^[p].Desc); - if (plyLink^[p].flags and WAT_OPT_TEMPLATE)<>0 then + if (plyLink^[p].flags and WAT_OPT_TEMPLATE)=0 then + result:=int_ptr(plyLink^[p].Check) + else + begin // remove any info from templates + result:=WAT_RES_OK; ClearTemplate(pTmplCell(plyLink^[p].Check)); - if pWAT_RES_NOTFOUND then + // fill info + with plyLink^[p] do begin - plyLink^[p].flags:=plyLink^[p].flags or WAT_OPT_DISABLED; - result:=WAT_RES_DISABLED + flags:=pPlayerCell(lParam)^.flags; + if URL<>nil then + flags:=flags or WAT_OPT_HASURL; + if pPlayerCell(lParam)^.Icon<>0 then + begin + if icon<>0 then + DestroyIcon(icon); + icon:=CopyIcon(pPlayerCell(lParam)^.Icon); + end; + Init :=pPlayerCell(lParam)^.Init; + DeInit :=pPlayerCell(lParam)^.DeInit; + Check :=pPlayerCell(lParam)^.Check; + GetStatus:=pPlayerCell(lParam)^.GetStatus; + GetName :=pPlayerCell(lParam)^.GetName; + GetInfo :=pPlayerCell(lParam)^.GetInfo; + Command :=pPlayerCell(lParam)^.Command; + if Init<>nil then + tInitProc(Init); end; - end; - WAT_ACT_ENABLE: begin - if p<>WAT_RES_NOTFOUND then - begin - plyLink^[p].flags:=plyLink^[p].flags and not WAT_OPT_DISABLED; - result:=WAT_RES_ENABLED - end; +// PreProcess; + PostProcess; end; + end + else + begin + p:=FindPlayer(PAnsiChar(lParam)); + if p<>WAT_RES_NOTFOUND then + case LoWord(wParam) of + WAT_ACT_UNREGISTER: begin + dec(PlyNum); + if plyLink^[p].DeInit<>nil then + tDeInitProc(plyLink^[p].DeInit); + FreeMem(plyLink^[p].Desc); + if (plyLink^[p].flags and WAT_OPT_TEMPLATE)<>0 then + ClearTemplate(pTmplCell(plyLink^[p].Check)); + if pWAT_RES_NOTFOUND then - begin - if (plyLink^[p].flags and WAT_OPT_DISABLED)<>0 then - result:=WAT_RES_DISABLED - else + result:=WAT_RES_OK; + end; + + WAT_ACT_DISABLE: begin + plyLink^[p].flags:=plyLink^[p].flags or WAT_OPT_DISABLED; + result:=WAT_RES_DISABLED; + end; + + WAT_ACT_ENABLE: begin + plyLink^[p].flags:=plyLink^[p].flags and not WAT_OPT_DISABLED; result:=WAT_RES_ENABLED; + end; + + WAT_ACT_GETSTATUS: begin + if (plyLink^[p].flags and WAT_OPT_DISABLED)<>0 then + result:=WAT_RES_DISABLED + else + result:=WAT_RES_ENABLED; + end; + + WAT_ACT_SETACTIVE: begin + if p>0 then + begin + tmp:=plyLink^[p]; + move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*p); + plyLink^[0]:=tmp; + end; + // PreProcess; + // PostProcess; + end; + end; - end; - WAT_ACT_SETACTIVE: begin - if p>0 then + end; +end; + +function ProcessPlayerLink:integer; +var + ptr:pwPlayer; +begin + ptr:=PlayerLink; + result:=0; + while ptr<>nil do + begin + ServicePlayer(WAT_ACT_REGISTER,lparam(ptr.This)); + ptr:=ptr^.Next; + inc(result); + end; +end; + +procedure ClearPlayers; +begin + if PlyNum>0 then + begin + repeat + dec(PlyNum); + with plyLink^[PlyNum] do begin - tmp:=plyLink^[p]; - move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*p); - plyLink^[0]:=tmp; -{ - move(plyLink^[p],tmp ,SizeOf(tPlayerCell)); - move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*p); - move(tmp ,plyLink^[0],SizeOf(tPlayerCell)); -} + if DeInit<>nil then + tDeInitProc(DeInit); + FreeMem(Desc); + if URL<>nil then + FreeMem(URL); + if icon<>0 then + DestroyIcon(icon); + if (flags and WAT_OPT_TEMPLATE)<>0 then + begin + ClearTemplate(pTmplCell(Check)); + mFreeMem(Notes); + end + else if Notes<>nil then + FreeMem(Notes); end; -// PreProcess; -// PostProcess; - end; - + until PlyNum=0; + FreeMem(plyLink); end; end; @@ -552,27 +445,137 @@ begin if ServicePlayer(WAT_ACT_REGISTER,lparam(@rec))=WAT_RES_ERROR then begin - ClearTemplate(pcell); -// mFreeMem(rec.URL); - mFreeMem(rec.Notes); - end - else - inc(NumPlayers); - - while ptr^<>#0 do inc(ptr); - inc(ptr); + ClearTemplate(pcell); +// mFreeMem(rec.URL); + mFreeMem(rec.Notes); + end + else + inc(NumPlayers); + + while ptr^<>#0 do inc(ptr); + inc(ptr); + end; + + FreeSectionList(buf); + CloseStorage(st); + result:=NumPlayers; +end; + +function SetPlayerIcons(fname:pAnsiChar):integer; +var + i,j:integer; + buf:array [0..255] of AnsiChar; + p,pp:pAnsiChar; + lhIcon:HICON; +begin + result:=LoadLibraryA(fname); + if result<>0 then + begin + p:=StrCopyE(buf,'Player_'); + i:=0; + while i0 then + begin + if Icon<>0 then + DestroyIcon(Icon); + Icon:=lhIcon; + end; + end; + inc(i); + end; + FreeLibrary(result); + end; +end; + +//----- options procedures ----- + +procedure DefFillPlayerList(hwndList:HWND); +var + item:LV_ITEMA; + lvc:TLVCOLUMN; + i,newItem:integer; + + il:HIMAGELIST; //!! +begin + FillChar(item,SizeOf(item),0); + FillChar(lvc,SizeOf(lvc),0); + ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES); + lvc.mask:=LVCF_FMT or LVCF_WIDTH; + + lvc.fmt:=LVCFMT_LEFT; + lvc.cx:=160; + ListView_InsertColumn(hwndList,0,lvc); + + item.mask:=LVIF_TEXT or LVIF_IMAGE; //!! + i:=0; + + il:=ImageList_Create(16,16,ILC_COLOR32 or ILC_MASK,0,1); //!! + while i=0 then + begin + if (plyLink^[i].flags and WAT_OPT_DISABLED)=0 then + ListView_SetCheckState(hwndList,newItem,TRUE); + end; + inc(i); + end; + ImageList_Destroy(SendMessage(hwndList,LVM_SETIMAGELIST,LVSIL_SMALL,il)); //!! +// ListView_SetColumnWidth(hwndList,0,LVSCW_AUTOSIZE); +end; + +procedure DefCheckPlayerList(hwndList:HWND); +var + i,j,k:integer; + item:LV_ITEMA; + szTemp:array [0..109] of AnsiChar; + p:pPlayerCell; +begin + FillChar(item,SizeOf(item),0); + item.mask :=LVIF_TEXT; + item.pszText :=@szTemp; + item.cchTextMax:=100; + k:=ListView_GetItemCount(hwndList)-1; + for i:=0 to k do + begin + item.iItem:=i; + SendMessageA(hwndList,LVM_GETITEMA,0,lparam(@item)); + j:=FindPlayer(item.pszText); + if j<>WAT_RES_NOTFOUND then + begin + p:=@plyLink^[j]; + if ListView_GetCheckState(hwndList,i)=0 then + p^.flags:=p^.flags or WAT_OPT_DISABLED + else + p^.flags:=p^.flags and not WAT_OPT_DISABLED; + end; end; - - FreeSectionList(buf); - CloseStorage(st); - result:=NumPlayers; end; +//----- Active player search ----- + function CheckTmpl(lwnd:HWND;cell:pTmplCell;flags:integer):HWND; var tmp,EXEName:PAnsiChar; - ltmp,lcycle:boolean; lclass,ltext:PAnsiChar; + ltmp,lcycle:boolean; begin lclass:=cell.p_class; ltext :=cell.p_text; @@ -596,6 +599,7 @@ begin end; exit; until false; + // repeat for alternative window if lcycle then break; lclass:=cell.p_class1; ltext :=cell.p_text1; @@ -605,22 +609,26 @@ begin end; // find active player -function CheckAllPlayers(flags:integer;var status:integer; var PlayerChanged:bool):integer; +function CheckAllPlayers(flags:integer;var status:integer; var PlayerChanged:bool):HWND; const PrevPlayerName:PAnsiChar=nil; var - stat,act,oldstat,i,j:integer; - tmp:tPlayerCell; wwnd,lwnd:HWND; + tmp:tPlayerCell; + fname:pWideChar; + stat,act,oldstat,i,j:integer; begin + result:=HWND(WAT_RES_NOTFOUND); + i:=0; - result:=WAT_RES_NOTFOUND; PlayerChanged:=true; PreProcess; oldstat:=-1; act:=-1; - stat:=WAT_MES_UNKNOWN; + // for case when no any player enabled/registered + stat:=WAT_PLS_UNKNOWN; wwnd:=0; + while i0 then begin lwnd:=CheckTmpl(lwnd,plyLink^[i].Check,plyLink^[i].flags); @@ -642,6 +652,7 @@ begin stat:=WinampGetStatus(wwnd); end; end + // separate processing else begin with plyLink^[i] do @@ -651,9 +662,11 @@ begin stat:=tStatusProc(GetStatus)(lwnd); end; end; + + // player window found if (lwnd<>THANDLE(WAT_RES_NOTFOUND)) and (lwnd<>0) then begin - if (stat=WAT_MES_PLAYING) or ((flags and WAT_OPT_CHECKALL)=0) then + if (stat=WAT_PLS_PLAYING) or ((flags and WAT_OPT_CHECKALL)=0) then begin act :=i; result:=lwnd; @@ -662,9 +675,9 @@ begin else begin case stat of - WAT_MES_STOPPED: j:=00; - WAT_MES_UNKNOWN: j:=10; - WAT_MES_PAUSED : j:=20; + WAT_PLS_STOPPED: j:=00; + WAT_PLS_UNKNOWN: j:=10; + WAT_PLS_PAUSED : j:=20; else j:=00; end; @@ -678,46 +691,63 @@ begin end else break; + if (plyLink^[i].flags and WAT_OPT_SINGLEINST)<>0 then break; + until false; - if (result<>WAT_RES_NOTFOUND) and (result<>0) and - ((stat=WAT_MES_PLAYING) or ((flags and WAT_OPT_CHECKALL)=0)) then + + if (result<>HWND(WAT_RES_NOTFOUND)) and (result<>0) and + ((stat=WAT_PLS_PLAYING) or ((flags and WAT_OPT_CHECKALL)=0)) then break; end; inc(i); end; + // hmm, we found player if act>=0 then begin if result=1 then result:=0 //!! for example, mradio else if wwnd<>0 then result:=wwnd; + if act>0 then // to first position begin tmp:=plyLink^[act]; move(plyLink^[0],plyLink^[1],SizeOf(tPlayerCell)*act); plyLink^[0]:=tmp; -{ - move(plyLink^[act],tmp ,SizeOf(tPlayerCell)); - move(plyLink^[0 ],plyLink^[1],SizeOf(tPlayerCell)*act); - move(tmp ,plyLink^[0],SizeOf(tPlayerCell)); -} end; + if PrevPlayerName=plyLink^[0].Desc then PlayerChanged:=false else + begin PrevPlayerName:=plyLink^[0].Desc; + // get player icon if didn't has it before + if (plyLink^[0].icon=0) and (result>0) then + begin + if GetEXEByWnd(result,fname)<>nil then + begin + plyLink^[0].icon:=ExtractIconW(hInstance,fname,0); + if plyLink^[0].icon=1 then + plyLink^[0].icon:=0; + mFreeMem(fname); + end; + end; + end; status:=stat; end else begin PrevPlayerName:=nil; - status:=WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16; + status:=WAT_PLS_NOTFOUND; end; + PostProcess; end; +//----- Send command to player ----- + function TranslateToApp(code:integer):integer; begin case code of @@ -759,468 +789,4 @@ begin end; end; -// Get Info (default) - -function GetSeparator(str:pWideChar):dword; -begin - result:=StrIndexW(str,' '#$2013' '); - if result=0 then - result:=StrIndexW(str,' - '); - if result<>0 then - begin - result:=result-1 + (3 SHL 16); - exit; - end; - result:=StrIndexW(str,#$2013); - if result=0 then - result:=StrIndexW(str,'-'); - if result>0 then - result:=result-1 + (1 SHL 16); -end; - -function DefGetTitle(wnd:HWND;fname,wndtxt:pWideChar):pWideChar; -var - i:integer; - tmp:pWideChar; -begin - if fname<>nil then - tmp:=DeleteKnownExt(ExtractW(fname,true)) - else - tmp:=wndtxt; - if tmp=nil then - begin - result:=nil; - exit; - end; - StrDupW(result,tmp); - i:=GetSeparator(result); - if i>0 then - StrCopyW(result,result+LoWord(i)+HiWord(i)); - if fname<>nil then - mFreeMem(tmp); -end; - -function DefGetArtist(wnd:HWND;fname,wndtxt:pWideChar):pWideChar; -var - i:integer; - tmp:pWideChar; -begin - if fname<>nil then - tmp:=DeleteKnownExt(ExtractW(fname,true)) - else - tmp:=wndtxt; - if tmp=nil then - begin - result:=nil; - exit; - end; - StrDupW(result,tmp); - i:=GetSeparator(result); - if i>0 then - result[LoWord(i)]:=#0; - if fname<>nil then - mFreeMem(tmp); -end; - -function DefGetVersionText(ver:integer):pWideChar; -begin - if ver<>0 then - begin - mGetMem(result,10*SizeOf(WideChar)); - IntToHex(result,ver); - end - else - result:=nil; -end; - -function DefGetWndText(wnd:HWND):pWideChar; -var - p:pWideChar; -begin - if wnd<>0 then - begin - result:=GetDlgText(wnd); - if result<>nil then - begin - if (plyLink^[0].flags and WAT_OPT_TEMPLATE)<>0 then - begin - with pTmplCell(plyLink^[0].Check)^ do - begin - if p_prefix<>nil then - begin - p:=StrPosW(result,p_prefix); - if p=result then - StrCopyW(result,result+StrLenW(p_prefix)); - end; - if p_postfix<>nil then - begin - p:=StrPosW(result,p_postfix); - if p<>nil then - p^:=#0; - end; - end; - end; - end; - end - else - result:=nil; -end; - -procedure ClearSongInfoData(var dst:tSongInfo;withFree:bool); -begin - ClearPlayerInfo (dst,withFree); - ClearChangingInfo(dst,withFree); - ClearFileInfo (dst,withFree); - ClearTrackInfo (dst,withFree); -end; - -procedure CopyChangingInfo(const src:tSongInfo;var dst:tSongInfo); -begin - dst.time :=src.time; - dst.volume :=src.volume; - dst.wndtext:=src.wndtext; -end; - -procedure ClearChangingInfo(var dst:tSongInfo;withFree:bool); -begin - dst.time :=0; - dst.volume:=0; - - if withFree then - mFreeMem(dst.wndtext) - else - dst.wndtext:=nil; -end; - -procedure CopyFileInfo(const src:tSongInfo;var dst:tSongInfo); -begin - dst.fsize:=src.fsize; - dst.date :=src.date; - dst.mfile:=src.mfile; -end; - -procedure ClearFileInfo(var dst:tSongInfo;withFree:bool); -begin - if withFree then - mFreeMem(dst.mfile) - else - dst.mfile:=nil; - dst.fsize:=0; - dst.date :=0; -end; - -procedure CopyPlayerInfo(const src:tSongInfo;var dst:tSongInfo); -begin - dst.player :=src.player; - dst.txtver :=src.txtver; - dst.url :=src.url; - dst.icon :=src.icon; - dst.plyver :=src.plyver; - dst.plwnd :=src.plwnd; - dst.winampwnd:=src.winampwnd; -end; - -procedure ClearPlayerInfo(var dst:tSongInfo;withFree:bool); -begin - if withFree then - begin - mFreeMem(dst.player); - mFreeMem(dst.txtver); - mFreeMem(dst.url); - if dst.icon<>0 then - DestroyIcon(dst.icon); - end - else - begin - dst.player:=nil; - dst.txtver:=nil; - dst.url :=nil; - end; - dst.icon :=0; - dst.plyver :=0; - dst.plwnd :=0; - dst.winampwnd:=0; -end; - -procedure CopyTrackInfo(const src:tSongInfo;var dst:tSongInfo); -begin - dst.artist :=src.artist; - dst.title :=src.title; - dst.album :=src.album; - dst.genre :=src.genre; - dst.comment :=src.comment; - dst.year :=src.year; - dst.lyric :=src.lyric; - dst.cover :=src.cover; - dst.kbps :=src.kbps; - dst.khz :=src.khz; - dst.channels:=src.channels; - dst.track :=src.track; - dst.total :=src.total; - dst.vbr :=src.vbr; - dst.codec :=src.codec; - dst.width :=src.width; - dst.height :=src.height; - dst.fps :=src.fps; -end; - -procedure ClearTrackInfo(var dst:tSongInfo;withFree:bool); -begin - if withFree then - begin - mFreeMem(dst.artist); - mFreeMem(dst.title); - mFreeMem(dst.album); - mFreeMem(dst.genre); - mFreeMem(dst.comment); - mFreeMem(dst.year); - mFreeMem(dst.lyric); - mFreeMem(dst.cover); - end - else - begin - dst.artist :=nil; - dst.title :=nil; - dst.album :=nil; - dst.genre :=nil; - dst.comment:=nil; - dst.year :=nil; - dst.lyric :=nil; - dst.cover :=nil; - end; - dst.kbps :=0; - dst.khz :=0; - dst.channels:=0; - dst.track :=0; - dst.total :=0; - dst.vbr :=0; - dst.codec :=0; - dst.width :=0; - dst.height :=0; - dst.fps :=0; -end; - -function CheckPlayers(var dst:tSongInfo;flags:cardinal):integer; -var - PlayerChanged:bool; - fname:pWideChar; -begin - result:=CheckAllPlayers(flags,dst.status,PlayerChanged); - - if result<>WAT_RES_NOTFOUND then - begin - if PlayerChanged then - begin - ClearPlayerInfo(dst,false); - AnsiToWide(plyLink^[0].Desc,dst.player); - dst.plwnd:=result; - FastAnsiToWide(plyLink^[0].URL,dst.url); - if plyLink^[0].icon<>0 then - dst.icon:=CopyIcon(plyLink^[0].icon) - else if result<>0 then - begin - if GetEXEByWnd(dst.plwnd,fname)<>nil then - begin - dst.icon:=ExtractIconW(hInstance,fname,0); - if dst.icon=1 then - dst.icon:=0; - if dst.icon<>0 then - plyLink^[0].icon:=CopyIcon(dst.icon); - mFreeMem(fname); - end; - end; - - if plyLink^[0].GetInfo<>nil then - tInfoProc(plyLink^[0].GetInfo)(dst,flags or WAT_OPT_PLAYERDATA) - else if (plyLink^[0].flags and WAT_OPT_WINAMPAPI)<>0 then - WinampGetInfo(wparam(@dst),flags or WAT_OPT_PLAYERDATA); - - if (plyLink^[0].flags and WAT_OPT_PLAYERINFO)=0 then - if dst.txtver=NIL then dst.txtver:=DefGetVersionText(dst.plyver); - - result:=WAT_RES_NEWPLAYER; - end - else - begin - dst.plwnd:=result; // to prevent same player, another instance - result:=WAT_RES_OK; - end - end; -end; - -function CheckFile(var dst:tSongInfo;flags:cardinal;timeout:cardinal):integer; -var - fname:pWideChar; - tmp:integer; - remote,FileChanged:boolean; - f:THANDLE; - ftime:int64; -begin - if plyLink^[0].GetName<>nil then - fname:=tNameProc(plyLink^[0].GetName)(dst.plwnd,flags) - else - fname:=nil; - - if (fname=nil) and (dst.plwnd<>0) then - begin - tmp:=0; - if (flags and WAT_OPT_MULTITHREAD)<>0 then tmp:=tmp or gffdMultiThread; - if (flags and WAT_OPT_KEEPOLD )<>0 then tmp:=tmp or gffdOld; - fname:=GetFileFromWnd(dst.plwnd,KnownFileType,tmp,timeout); - end; - - if fname<>nil then - begin - remote:=StrPosW(fname,'://')<>nil; - // file changing time (local/lan only) - if not remote then - begin - f:=Reset(fname); - - if f<>THANDLE(INVALID_HANDLE_VALUE) then - begin - GetFileTime(f,nil,nil,@ftime); - CloseHandle(f); - end; - end; - // same file - if (dst.mfile<>nil) and (lstrcmpiw(dst.mfile,fname)=0) then - begin - if (not remote) and ((flags and WAT_OPT_CHECKTIME)<>0) then - FileChanged:=dst.date<>ftime - else - FileChanged:=false; - end - else // new filename - begin - FileChanged:=true; - end; - - // if not proper ext (we don't working with it) - //!!!! check for remotes - if (not remote) and (CheckExt(fname)=WAT_RES_NOTFOUND) then - begin - mFreeMem(fname); - result:=WAT_RES_NOTFOUND; - exit; - end; - if FileChanged {or isContainer(fname)} then - begin - ClearFileInfo(dst,false); - dst.mfile:=fname; //!! must be when format recognized or remote - dst.date:=ftime; //!! - dst.fsize:=GetFSize(dst.mfile); - result:=WAT_RES_NEWFILE; - end - else - begin - result:=WAT_RES_OK; - mFreeMem(fname); - end; - end - else - begin - result:=WAT_RES_NOTFOUND; - end; -end; - -// Get Info - main procedure -function GetChangingInfo(var dst:tSongInfo;flags:cardinal):integer; -begin - result:=WAT_RES_OK; - - ClearChangingInfo(dst,false); - - if plyLink^[0].GetInfo<>nil then - tInfoProc(plyLink^[0].GetInfo)(dst,flags or WAT_OPT_CHANGES) - else if (plyLink^[0].flags and WAT_OPT_WINAMPAPI)<>0 then - WinampGetInfo(wparam(@dst),flags or WAT_OPT_CHANGES); - - if (plyLink^[0].flags and WAT_OPT_PLAYERINFO)=0 then - if dst.wndtext=NIL then dst.wndtext:=DefGetWndText(dst.plwnd); -end; - -function GetInfo(var dst:tSongInfo;flags:cardinal):integer; -var - oldartist,oldtitle:pWideChar; - fname:pWideChar; - remote:boolean; - lmsnInfo:pMSNInfo; -begin - result:=WAT_RES_OK; - remote:=StrPosW(dst.mfile,'://')<>nil; - -// if remote or ((plyLink^[0].flags and WAT_OPT_PLAYERINFO)<>0) then - oldartist:=dst.artist; oldtitle:=dst.title; - - ClearTrackInfo(dst,false); - - // info from player - if plyLink^[0].GetInfo<>nil then - tInfoProc(plyLink^[0].GetInfo)(dst,flags and not WAT_OPT_CHANGES) - else if (plyLink^[0].flags and WAT_OPT_WINAMPAPI)<>0 then - WinampGetInfo(wparam(@dst),flags and not WAT_OPT_CHANGES); - // info from file - GetFileFormatInfo(dst); - - if (plyLink^[0].flags and WAT_OPT_PLAYERINFO)=0 then - with dst do - begin - if remote then - fname:=nil - else - fname:=mfile; - - lmsnInfo:=GetMSNInfo; - - if lmsnInfo<>nil then - begin - if artist=NIL then StrDupW(artist,lmsnInfo.msnArtist); - if title =NIL then StrDupW(title ,lmsnInfo.msnTitle); - if album =NIL then StrDupW(album ,lmsnInfo.msnAlbum); - end; - - if artist=NIL then artist:=DefGetArtist(plwnd,fname,wndtext); - if title =NIL then title :=DefGetTitle (plwnd,fname,wndtext); - end; - if remote or ((plyLink^[0].flags and WAT_OPT_PLAYERINFO)<>0) or - isContainer(dst.mfile) then - begin - if (oldartist=oldtitle) or - ((oldartist<>nil) and (StrCmpW(dst.artist,oldartist)<>0)) or - ((oldtitle <>nil) and (StrCmpW(dst.title ,oldtitle )<>0)) then - begin - result:=WAT_RES_NEWFILE; - end; - end; -end; - -procedure ClearPlayers; -begin - if PlyNum>0 then - begin - repeat - dec(PlyNum); - with plyLink^[PlyNum] do - begin - if DeInit<>nil then - tDeInitProc(DeInit); - FreeMem(Desc); - if URL<>nil then - FreeMem(URL); - if icon<>0 then - DestroyIcon(icon); - if (flags and WAT_OPT_TEMPLATE)<>0 then - begin - ClearTemplate(pTmplCell(Check)); - mFreeMem(Notes); - end - else if Notes<>nil then - FreeMem(Notes); - end; - until PlyNum=0; - FreeMem(plyLink); - end; -end; - end. diff --git a/plugins/Watrack/stat/statlog.pas b/plugins/Watrack/stat/statlog.pas index 6cbcaf35b7..d5a0318a69 100644 --- a/plugins/Watrack/stat/statlog.pas +++ b/plugins/Watrack/stat/statlog.pas @@ -142,7 +142,7 @@ begin (si^.album =NIL) and (si^.mfile=NIL) then exit; f:=Append(fname); -// if dword(f)=INVALID_HANDLE_VALUE then f:=Rewrite(fname); +// if THANDLE(f)=INVALID_HANDLE_VALUE then f:=Rewrite(fname); if f=THANDLE(INVALID_HANDLE_VALUE) then exit; FillChar(buf,SizeOf(buf),0); lp:=@buf; @@ -414,6 +414,7 @@ var begin Lock:=true; ConvertFileName(fname,buf1); +// CallService(MS_UTILS_PATHTOABSOLUTE,twparam(fname),tlparam(@buf1)); Root:=BuildTree(buf1,buf); if Root<>nil then begin @@ -458,13 +459,14 @@ begin else fname:=PAnsiChar(wParam); ConvertFileName(fname,log); +// CallService(MS_UTILS_PATHTOABSOLUTE,twparam(fname),tlparam(@log)); AppendStat(log,pSongInfo(lParam)); end; function PackLog(wParam:WPARAM;lParam:LPARAM):integer;cdecl; begin result:=0; - mir_forkthread(@ThPackLog,nil); + {CloseHandle}(mir_forkthread(@ThPackLog,nil)); end; function MakeReport(wParam:WPARAM;lParam:LPARAM):integer;cdecl; @@ -489,6 +491,9 @@ begin ConvertFileName(r,report); ConvertFileName(l,template); ConvertFileName(StatName,log); +// CallService(MS_UTILS_PATHTOABSOLUTE,twparam(r),tlparam(@report)); +// CallService(MS_UTILS_PATHTOABSOLUTE,twparam(l),tlparam(@template)); +// CallService(MS_UTILS_PATHTOABSOLUTE,twparam(StatName),tlparam(@log)); if DoAddExt=BST_CHECKED then ChangeExt(report,'htm'); if StatOut(report,log,template) then diff --git a/plugins/Watrack/status/i_hotkey.inc b/plugins/Watrack/status/i_hotkey.inc index 3ad23ae656..115be86655 100644 --- a/plugins/Watrack/status/i_hotkey.inc +++ b/plugins/Watrack/status/i_hotkey.inc @@ -12,7 +12,7 @@ begin result:=0; if DisablePlugin=dsPermanent then exit; - if Loword(LastStatus)<>WAT_PLS_NORMAL then + if LastStatus in [WAT_PLS_NOTFOUND,WAT_PLS_STOPPED] then exit; // i:=CallService(MS_WAT_GETMUSICINFO,0,0); if UseMessages=BST_CHECKED then diff --git a/plugins/Watrack/status/i_st_vars.inc b/plugins/Watrack/status/i_st_vars.inc index 4db2bbb44c..e1696c3621 100644 --- a/plugins/Watrack/status/i_st_vars.inc +++ b/plugins/Watrack/status/i_st_vars.inc @@ -18,6 +18,7 @@ var XStatusSet :cardinal; ClearXStat :cardinal; hINS :THANDLE; +// hLTo :THANDLE; plStatusHook :THANDLE; const diff --git a/plugins/Watrack/status/i_status.inc b/plugins/Watrack/status/i_status.inc index a7e3d2e5ef..0392a797ad 100644 --- a/plugins/Watrack/status/i_status.inc +++ b/plugins/Watrack/status/i_status.inc @@ -63,7 +63,7 @@ begin WAT_EVENT_PLAYERSTATUS: begin LastStatus:=lParam; - if (loword(lParam)=WAT_PLS_NORMAL) then + if not (lParam in [WAT_PLS_NOTFOUND,WAT_PLS_STOPPED]) then exit; doClear:=true; end; diff --git a/plugins/Watrack/templates/i_text.inc b/plugins/Watrack/templates/i_text.inc index fa0c966728..f6f7406b49 100644 --- a/plugins/Watrack/templates/i_text.inc +++ b/plugins/Watrack/templates/i_text.inc @@ -87,10 +87,10 @@ begin Replace(ls,mn_length,IntToTime(ws,Info^.total)); Replace(ls,mn_total ,ws); case Info^.status of - WAT_MES_PLAYING: pp:=splPlaying; - WAT_MES_PAUSED : pp:=splPaused; + WAT_PLS_PLAYING: pp:=splPlaying; + WAT_PLS_PAUSED : pp:=splPaused; else - {WAT_MES_STOPPED:} pp:=splStopped; + {WAT_PLS_STOPPED:} pp:=splStopped; end; Replace(ls,mn_status,TranslateW(pp)); Replace(ls,mn_nstatus,pp); diff --git a/plugins/Watrack/templates/i_variables.inc b/plugins/Watrack/templates/i_variables.inc index a43c77b8c2..d022aa3a07 100644 --- a/plugins/Watrack/templates/i_variables.inc +++ b/plugins/Watrack/templates/i_variables.inc @@ -73,14 +73,14 @@ begin else if WriteCBR<>0 then ws:=chCBR; mn_status: case si^.status of - WAT_MES_STOPPED: ws:=TranslateW(splStopped); - WAT_MES_PLAYING: ws:=TranslateW(splPlaying); - WAT_MES_PAUSED : ws:=TranslateW(splPaused); + WAT_PLS_STOPPED: ws:=TranslateW(splStopped); + WAT_PLS_PLAYING: ws:=TranslateW(splPlaying); + WAT_PLS_PAUSED : ws:=TranslateW(splPaused); end; mn_nstatus: case si^.status of - WAT_MES_STOPPED: ws:=splStopped; - WAT_MES_PLAYING: ws:=splPlaying; - WAT_MES_PAUSED : ws:=splPaused; + WAT_PLS_STOPPED: ws:=splStopped; + WAT_PLS_PLAYING: ws:=splPlaying; + WAT_PLS_PAUSED : ws:=splPaused; end; mn_mono: begin case si^.channels of diff --git a/plugins/Watrack/wat_api.pas b/plugins/Watrack/wat_api.pas index 52fd0f2650..2f842df838 100644 --- a/plugins/Watrack/wat_api.pas +++ b/plugins/Watrack/wat_api.pas @@ -8,6 +8,19 @@ uses windows; function GenreName(idx:cardinal):pWideChar; +// support procedures +procedure ClearSongInfoData(var dst:tSongInfo); +procedure ClearPlayerInfo (var dst:tSongInfo); +procedure ClearFileInfo (var dst:tSongInfo); +procedure ClearChangingInfo(var dst:tSongInfo); +procedure ClearTrackInfo (var dst:tSongInfo); + +procedure CopyPlayerInfo (const src:tSongInfo;var dst:tSongInfo); +procedure CopyFileInfo (const src:tSongInfo;var dst:tSongInfo); +procedure CopyChangingInfo(const src:tSongInfo;var dst:tSongInfo); +procedure CopyTrackInfo (const src:tSongInfo;var dst:tSongInfo); + + implementation uses common; @@ -180,4 +193,127 @@ begin result:=nil; end; +//----- support procedures ----- + +// changing data +procedure ClearChangingInfo(var dst:tSongInfo); +begin + dst.time :=0; + dst.volume:=0; + + mFreeMem(dst.wndtext); +end; + +procedure CopyChangingInfo(const src:tSongInfo;var dst:tSongInfo); +begin + dst.time :=src.time; + dst.volume :=src.volume; + + StrDupW(dst.wndtext,src.wndtext); +end; + +// file data +procedure ClearFileInfo(var dst:tSongInfo); +begin + mFreeMem(dst.mfile); + + dst.fsize:=0; + dst.date :=0; +end; + +procedure CopyFileInfo(const src:tSongInfo;var dst:tSongInfo); +begin + StrDupW(dst.mfile,src.mfile); + + dst.fsize:=src.fsize; + dst.date :=src.date; +end; + +// player data +procedure ClearPlayerInfo(var dst:tSongInfo); +begin + mFreeMem(dst.player); + mFreeMem(dst.txtver); + mFreeMem(dst.url); + + if dst.icon<>0 then + DestroyIcon(dst.icon); + dst.icon :=0; + + dst.plyver :=0; + dst.plwnd :=0; + dst.winampwnd:=0; +end; + +procedure CopyPlayerInfo(const src:tSongInfo;var dst:tSongInfo); +begin + StrDupW(dst.player,src.player); + StrDupW(dst.txtver,src.txtver); + StrDupW(dst.url ,src.url); + + if src.icon<>0 then + dst.icon:=CopyIcon(src.icon); + + dst.plyver :=src.plyver; + dst.plwnd :=src.plwnd; + dst.winampwnd:=src.winampwnd; +end; + +// track data +procedure ClearTrackInfo(var dst:tSongInfo); +begin + mFreeMem(dst.artist); + mFreeMem(dst.title); + mFreeMem(dst.album); + mFreeMem(dst.genre); + mFreeMem(dst.comment); + mFreeMem(dst.year); + mFreeMem(dst.lyric); + mFreeMem(dst.cover); + + dst.kbps :=0; + dst.khz :=0; + dst.channels:=0; + dst.track :=0; + dst.total :=0; + dst.vbr :=0; + dst.codec :=0; + dst.width :=0; + dst.height :=0; + dst.fps :=0; +end; + +procedure CopyTrackInfo(const src:tSongInfo;var dst:tSongInfo); +begin + StrDupW(dst.artist ,src.artist); + StrDupW(dst.title ,src.title); + StrDupW(dst.album ,src.album); + StrDupW(dst.genre ,src.genre); + StrDupW(dst.comment,src.comment); + StrDupW(dst.year ,src.year); + StrDupW(dst.lyric ,src.lyric); + StrDupW(dst.cover ,src.cover); + + dst.kbps :=src.kbps; + dst.khz :=src.khz; + dst.channels:=src.channels; + dst.track :=src.track; + dst.total :=src.total; + dst.vbr :=src.vbr; + dst.codec :=src.codec; + dst.width :=src.width; + dst.height :=src.height; + dst.fps :=src.fps; +end; + + +procedure ClearSongInfoData(var dst:tSongInfo); +begin + ClearPlayerInfo (dst); + ClearChangingInfo(dst); + ClearFileInfo (dst); + ClearTrackInfo (dst); +end; + + end. diff --git a/plugins/Watrack/waticons.pas b/plugins/Watrack/waticons.pas index b6a9bbc2b4..396fdd887e 100644 --- a/plugins/Watrack/waticons.pas +++ b/plugins/Watrack/waticons.pas @@ -51,13 +51,17 @@ var begin result:=true; sid.szDefaultFile.a:='icons\'+ICOCtrlName; +// ConvertFileName(sid.szDefaultFile.a,buf); PathToAbsolute(sid.szDefaultFile.a,buf); +// CallService(MS_UTILS_PATHTOABSOLUTE,wparam(sid.szDefaultFile),lparam(@buf)); hIconDLL:=LoadLibraryA(buf); if hIconDLL=0 then // not found begin sid.szDefaultFile.a:='plugins\'+ICOCtrlName; +// ConvertFileName(sid.szDefaultFile.a,buf); PathToAbsolute(sid.szDefaultFile.a,buf); +// CallService(MS_UTILS_PATHTOABSOLUTE,wparam(sid.szDefaultFile),lparam(@buf)); hIconDLL:=LoadLibraryA(buf); end; @@ -142,13 +146,17 @@ begin if not IconsLoaded then begin path:='icons\'+ICOCtrlName; +// ConvertFileName(sid.szDefaultFile.a,buf); PathToAbsolute(path,buf); +// CallService(MS_UTILS_PATHTOABSOLUTE,wparam(path),lparam(@buf)); hIconDLL:=LoadLibraryA(buf); if hIconDLL=0 then // not found begin sid.szDefaultFile.a:='plugins\'+ICOCtrlName; +// ConvertFileName(sid.szDefaultFile.a,buf); PathToAbsolute(path,buf); +// CallService(MS_UTILS_PATHTOABSOLUTE,wparam(path),lparam(@buf)); hIconDLL:=LoadLibraryA(buf); end; diff --git a/plugins/Watrack/watrack.dpr b/plugins/Watrack/watrack.dpr index 27d9547c1e..1587727c1b 100644 --- a/plugins/Watrack/watrack.dpr +++ b/plugins/Watrack/watrack.dpr @@ -6,11 +6,11 @@ {$IMAGEBASE $13000000} library WATrack; uses - // FastMM not compatible with FPC, internal for delphi xe +// FastMM not compatible with FPC, internal for delphi xe // {$IFNDEF COMPILER_16_UP}{$IFNDEF FPC}fastmm4,{$ENDIF}{$ENDIF} - m_api,dbsettings,activex,winampapi, + m_api,dbsettings,{activex,}winampapi, Windows,messages,commctrl,//uxtheme, - srv_format,srv_player,wat_api,wrapper, + srv_format,srv_player,srv_getinfo,wat_api,wrapper, common,syswin,HlpDlg,mirutils ,global,waticons,io,macros, msninfo ,myshows in 'myshows\myshows.pas' @@ -21,9 +21,9 @@ uses ,status in 'status\status.pas' ,tmpl in 'status\tmpl.pas' ,templates in 'templates\templates.pas' -{$IFDEF KOL_MCK} +{.$IFDEF KOL_MCK} ,kolframe in 'kolframe\kolframe.pas' -{$ENDIF} +{.$ENDIF} {$include lst_players.inc} {$include lst_formats.inc} ; @@ -62,7 +62,7 @@ function ReturnInfo(enc:WPARAM;cp:LPARAM=CP_ACP):pointer; begin if enc<>WAT_INF_UNICODE then begin - ClearSongInfoData(tSongInfo(SongInfoA),true); + ClearSongInfoData(tSongInfo(SongInfoA)); move(SongInfo,SongInfoA,SizeOf(tSongInfo)); with SongInfoA do begin @@ -126,13 +126,9 @@ begin dst:=pointer(lParam); p:=dst^.mfile; - ClearTrackInfo(dst^,false); - dst^.mfile:=p; -{ - StrDupW(p,dst^.mfile); - ClearTrackInfo(dst^,false); //!!!! + ClearTrackInfo(dst^); dst^.mfile:=p; -} + // FillChar(dst,SizeOf(dst),0); // FillChar(si,SizeOf(si),0); { @@ -171,15 +167,19 @@ const var flags:cardinal; buf:PWideChar; + + newplayer, + newstatus, + newtrack :bool; + OldPlayerStatus:integer; - stat:integer; - newplayer:bool; begin result:=WAT_RES_NOTFOUND; if DisablePlugin=dsPermanent then exit; //----- Return old info if main timer ----- + if giused<>0 then begin result:=WAT_RES_OK; @@ -192,215 +192,165 @@ begin OldPlayerStatus:=WorkSI.status; + newstatus:=false; + newtrack :=false; + //----- Checking player ----- - // get player status too + flags:=0; if CheckAll<>BST_UNCHECKED then flags:=flags or WAT_OPT_CHECKALL; - // no need old data, clear -// ClearPlayerInfo(WorkSI,false); - result:=CheckPlayers(WorkSI,flags); - if result=WAT_RES_NEWPLAYER then - begin - newplayer:=true; - NotifyEventHooks(hHookWATStatus,WAT_EVENT_NEWPLAYER,tlparam(@WorkSI)); + + result:=GetPlayerInfo(WorkSI,flags); + + newplayer:=result=WAT_RES_NEWPLAYER; + if newplayer then result:=WAT_RES_OK; - end - else // !!!! (need to add) must remember about same player, another instance - newplayer:=false; - // Checking player status + //----- Checking player status ----- + if result=WAT_RES_OK then begin - if not newplayer then //!!cheat - SongInfo.plwnd:=WorkSI.plwnd; - // player stopped - no need file info - if WorkSI.status=WAT_MES_STOPPED then + if WorkSI.status=WAT_PLS_STOPPED then begin - ClearFileInfo (WorkSI,false); - ClearChangingInfo(WorkSI,false); - ClearTrackInfo (WorkSI,false); - - if Hiword(OldPlayerStatus)<>WAT_MES_STOPPED then - begin - NotifyEventHooks(hHookWATStatus,WAT_EVENT_PLAYERSTATUS,WAT_MES_STOPPED); - end; - - ClearFileInfo (SongInfo,true); - ClearChangingInfo(SongInfo,true); - ClearTrackInfo (SongInfo,true); - if newplayer then - begin - ClearPlayerInfo(SongInfo,true); - CopyPlayerInfo (WorkSI,SongInfo); - end; - WorkSI.status:=(WAT_MES_STOPPED shl 16) or (WAT_PLS_NOMUSIC and $FFFF); - SongInfo.status:=WorkSI.status; + newstatus:=OldPlayerStatus<>WAT_PLS_STOPPED; end + //----- Get file (no file, new file, maybe new) ----- else begin - //----- Get file (no file, new file, maybe new) ----- // file info will be replaced (name most important only) flags:=0; - if CheckTime <>BST_UNCHECKED then flags:=flags or WAT_OPT_CHECKTIME; - if UseImplant<>BST_UNCHECKED then flags:=flags or WAT_OPT_IMPLANTANT; - if MTHCheck <>BST_UNCHECKED then flags:=flags or WAT_OPT_MULTITHREAD; - if KeepOld <>BST_UNCHECKED then flags:=flags or WAT_OPT_KEEPOLD; + if CheckUnknown<>BST_UNCHECKED then flags:=flags or WAT_OPT_UNKNOWNFMT; + if CheckTime <>BST_UNCHECKED then flags:=flags or WAT_OPT_CHECKTIME; + if UseImplant <>BST_UNCHECKED then flags:=flags or WAT_OPT_IMPLANTANT; + if KeepOld <>BST_UNCHECKED then flags:=flags or WAT_OPT_KEEPOLD; // requirement - old file name - result:=CheckFile(WorkSI,flags,TimeoutForThread); - - // here - place for Playerstatus event - // high word - song status (play, pause,stop, nothing) - // low word - player status (normal,no music, nothing) - case WorkSI.status of - WAT_MES_PLAYING, - WAT_MES_PAUSED: stat:=WAT_PLS_NORMAL; - WAT_MES_UNKNOWN: // depends of file search - begin - if result=WAT_RES_NOTFOUND then - stat:=WAT_PLS_NOMUSIC - else - stat:=WAT_PLS_NORMAL; - end; - else // really, this way blocked already - {WAT_MES_STOPPED:} stat:=WAT_PLS_NOMUSIC; - end; - WorkSI.status:=(WorkSI.status shl 16) or (stat and $FFFF); + result:=GetFileInfo(WorkSI,flags,0); - if OldPlayerStatus<>WorkSI.status then - begin - NotifyEventHooks(hHookWATStatus,WAT_EVENT_PLAYERSTATUS,WorkSI.status); - end; - - // no playing file - clear all file info - if stat=WAT_PLS_NOMUSIC then - begin - ClearFileInfo (WorkSI,false); - ClearChangingInfo(WorkSI,false); - ClearTrackInfo (WorkSI,false); + if (WorkSI.status=WAT_PLS_UNKNOWN ) and // player in unknown state + (result =WAT_RES_NOTFOUND) then // and known media not found + WorkSI.status:=WAT_PLS_STOPPED; - ClearFileInfo (SongInfo,true); - ClearChangingInfo(SongInfo,true); - ClearTrackInfo (SongInfo,true); + newstatus:=OldPlayerStatus<>WorkSI.status; - if newplayer then - begin - ClearPlayerInfo(SongInfo,true); - CopyPlayerInfo (WorkSI,SongInfo); - end; - SongInfo.status:=WorkSI.status; - end; // now time for changes (window text, volume) // just when music presents - if stat=WAT_PLS_NORMAL then + if WorkSI.status<>WAT_PLS_STOPPED then begin GetChangingInfo(WorkSI,flags); // full info requires // "no music" case blocked +{?? + WorkSI.status=WAT_PLS_PLAYING and result=WAT_RES_UNKNOWN +} if (result=WAT_RES_NEWFILE) or // new file + (result=WAT_RES_UNKNOWN) or // unknown file (enabled by flag in GetFileInfo) ((result=WAT_RES_OK) and // if not new but... (((wParam and WAT_INF_CHANGES)=0) or // ... ask for full info (StrPosW(WorkSI.mfile,'://')<>nil) or // ... or remote file isContainer(WorkSI.mfile))) then // ... or container like CUE begin // requirement: old artist/title for remote files - stat:=GetInfo(WorkSI,flags); - - // covers - if (WorkSI.cover=nil) or (WorkSI.cover^=#0) then - GetCover(WorkSI.cover,WorkSI.mfile) - else - begin - mGetMem(buf,MAX_PATH*SizeOf(WideChar)); - GetTempPathW(MAX_PATH,buf); - if StrCmpW(buf,WorkSI.cover,StrLenW(buf))=0 then - begin - GetExt(WorkSI.cover,StrCatEW(buf,'\wat_cover.')); - DeleteFileW(buf); - MoveFileW(WorkSI.cover,buf); - mFreeMem(WorkSI.cover); - WorkSI.cover:=buf; - end - else - mFreeMem(buf); - end; - // lyric - if (WorkSI.lyric=nil) or (WorkSI.lyric^=#0) then - GetLyric(WorkSI.lyric,WorkSI.mfile); - -// file info will be updated anyway, so - just update it - if result=WAT_RES_NEWFILE then - begin - ClearFileInfo(SongInfo,true); - CopyFileInfo (WorkSI,SongInfo); - end; - ClearTrackInfo(SongInfo,true); - CopyTrackInfo (WorkSI,SongInfo); - - if newplayer then - begin - ClearPlayerInfo(SongInfo,true); - CopyPlayerInfo (WorkSI,SongInfo); - end; - ClearChangingInfo(SongInfo,true); - CopyChangingInfo (WorkSI,SongInfo); - SongInfo.status:=WorkSI.status; - - if stat=WAT_RES_NEWFILE then - result:=WAT_RES_NEWFILE; - - if result=WAT_RES_NEWFILE then - NotifyEventHooks(hHookWATStatus,WAT_EVENT_NEWTRACK,tlparam(@SongInfo)); - end - else // just changing infos - begin - if newplayer then - begin - ClearPlayerInfo(SongInfo,true); - CopyPlayerInfo (WorkSI,SongInfo); - end; - ClearChangingInfo(SongInfo,true); - CopyChangingInfo (WorkSI,SongInfo); - SongInfo.status:=WorkSI.status; + result:=GetInfo(WorkSI,flags); + newtrack:=result=WAT_RES_NEWFILE; end; end; end; - if lParam<>0 then - ppointer(lParam)^:=ReturnInfo(wParam and $FF); end //----- Player not found ----- else begin if OldPlayerStatus<>WorkSI.status then begin - ClearSongInfoData(WorkSI,false); // player info must be empty anyway - ClearSongInfoData(SongInfo,true); - SongInfo.status:=WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16; - - NotifyEventHooks(hHookWATStatus,WAT_EVENT_PLAYERSTATUS, - WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16); + WorkSI.status:=WAT_PLS_NOTFOUND; + newstatus:=true; end; + end; -{ - if OldPlayerStatus<>WorkSI.status then + //----- Copy all data to public (WorkSI to SongInfo) ----- + + SongInfo.status:=WorkSI.status; + + if WorkSI.status=WAT_PLS_NOTFOUND then + begin + ClearSongInfoData(WorkSI); + + ClearSongInfoData(SongInfo); + + if lParam<>0 then + ppointer(lParam)^:=nil; + end + else + begin + if not newplayer then // for another player instance + SongInfo.plwnd:=WorkSI.plwnd + else begin - NotifyEventHooks(hHookWATStatus,WAT_EVENT_PLAYERSTATUS, - WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16); + ClearPlayerInfo(SongInfo); + CopyPlayerInfo (WorkSI,SongInfo); end; - ClearSongInfoData(WorkSI,false); // player info must be empty anyway - WorkSI.status:=WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16; + if (WorkSI.status=WAT_PLS_STOPPED) or // no music + (result=WAT_RES_NOTFOUND) then // or unknown media file + begin + ClearFileInfo (WorkSI); + ClearChangingInfo(WorkSI); + ClearTrackInfo (WorkSI); - ClearSongInfoData(SongInfo,true); - SongInfo.status:=WAT_PLS_NOTFOUND+WAT_MES_UNKNOWN shl 16; -} + ClearFileInfo (SongInfo); + ClearChangingInfo(SongInfo); + ClearTrackInfo (SongInfo); + end + else + begin + ClearChangingInfo(SongInfo); + CopyChangingInfo (WorkSI,SongInfo); + + if newtrack then + begin + // covers + if (WorkSI.cover=nil) or (WorkSI.cover^=#0) then + GetCover(WorkSI.cover,WorkSI.mfile) + else + begin + mGetMem(buf,MAX_PATH*SizeOf(WideChar)); + GetTempPathW(MAX_PATH,buf); + if StrCmpW(buf,WorkSI.cover,StrLenW(buf))=0 then + begin + GetExt(WorkSI.cover,StrCatEW(buf,'\wat_cover.')); + DeleteFileW(buf); + MoveFileW(WorkSI.cover,buf); + mFreeMem(WorkSI.cover); + WorkSI.cover:=buf; + end + else + mFreeMem(buf); + end; + // lyric + if (WorkSI.lyric=nil) or (WorkSI.lyric^=#0) then + GetLyric(WorkSI.lyric,WorkSI.mfile); + + ClearFileInfo(SongInfo); + CopyFileInfo (WorkSI,SongInfo); + + ClearTrackInfo(SongInfo); + CopyTrackInfo (WorkSI,SongInfo); + end; + end; if lParam<>0 then - ppointer(lParam)^:=nil; + ppointer(lParam)^:=ReturnInfo(wParam and $FF); + end; + //----- Events ----- + + if newplayer then NotifyEventHooks(hHookWATStatus,WAT_EVENT_NEWPLAYER ,tlparam(@SongInfo)); + if newstatus then NotifyEventHooks(hHookWATStatus,WAT_EVENT_PLAYERSTATUS,SongInfo.status); + if newtrack then NotifyEventHooks(hHookWATStatus,WAT_EVENT_NEWTRACK ,tlparam(@SongInfo)); + giused:=0; end; @@ -509,6 +459,11 @@ begin if ttbState=0 then begin +{ + onloadhook:=0; + OnTTBLoaded(0,0); + if ttbState=0 then +} HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded); end else @@ -552,9 +507,10 @@ var dbetd:TDBEVENTTYPEDESCR; i:integer; begin + hTimer:=0; - OleInitialize(nil); +//!! OleInitialize(nil); if RegisterIcons then HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); @@ -568,6 +524,7 @@ begin ProcessFormatLink; ProcessPlayerLink; + // next 2 blocks here coz GetAddonFileName uses some Miranda things p:=GetAddonFileName(nil,'player','plugins','ini'); if p<>nil then begin @@ -622,9 +579,9 @@ end; procedure FreeVariables; begin - ClearSongInfoData(SongInfo ,true); - ClearSongInfoData(tSongInfo(SongInfoA),true); - ClearSongInfoData(WorkSI ,false); // not necessary really + ClearSongInfoData(SongInfo); + ClearSongInfoData(tSongInfo(SongInfoA)); + ClearSongInfoData(WorkSI); mFreeMem(CoverPaths); ClearFormats; ClearPlayers; @@ -666,7 +623,7 @@ begin DestroyHookableEvent(hHookWATLoaded); DestroyHookableEvent(hHookWATStatus); - OleUnInitialize; +//!! OleUnInitialize; //delete cover files buf[0]:=#0; @@ -729,5 +686,4 @@ exports begin DisableThreadLibraryCalls(hInstance); - end. diff --git a/plugins/Watrack/winampapi.pas b/plugins/Watrack/winampapi.pas index e53e88a247..0b61525027 100644 --- a/plugins/Watrack/winampapi.pas +++ b/plugins/Watrack/winampapi.pas @@ -99,16 +99,21 @@ function WinampGetStatus(wnd:HWND):integer; begin result:=SendMessage(wnd,WM_WA_IPC,0,IPC_ISPLAYING); // 0 - stopped, 1 - playing - if result>1 then - result:=WAT_MES_PAUSED; + case result of + 0: result:=WAT_PLS_STOPPED; + 1: result:=WAT_PLS_PLAYING; + else + if result>1 then + result:=WAT_PLS_PAUSED; + end; { if result=0 then // !! only for remote media! begin result:=SendMessage(wnd,WM_WA_IPC,0,IPC_ISFULLSTOP); if result<>0 then - result:=WAT_MES_STOPPED + result:=WAT_PLS_STOPPED else - result:=WAT_MES_PLAYING; + result:=WAT_PLS_PLAYING; end; } end; @@ -193,7 +198,7 @@ begin else if (lParam and WAT_OPT_CHANGES)<>0 then begin volume:=GetVolume(wnd); - if status<>WAT_MES_STOPPED then + if status<>WAT_PLS_STOPPED then time:=GetElapsedTime(wnd); // wndtext:=WinampGetWindowText(wnd); end diff --git a/plugins/Watrack_MPD/src/main.cpp b/plugins/Watrack_MPD/src/main.cpp index dd9a9feea0..13ca0b6396 100755 --- a/plugins/Watrack_MPD/src/main.cpp +++ b/plugins/Watrack_MPD/src/main.cpp @@ -256,14 +256,14 @@ int Parser() tmp[i] = ptr[i]; tmp[i] = '\0'; if(strstr(tmp, "play")) - gbState = WAT_MES_PLAYING; + gbState = WAT_PLS_PLAYING; if(strstr(tmp, "pause")) - gbState = WAT_MES_PAUSED; + gbState = WAT_PLS_PAUSED; if(strstr(tmp, "stop")) - gbState = WAT_MES_STOPPED; + gbState = WAT_PLS_STOPPED; } else if(!gbState) - gbState = WAT_MES_UNKNOWN; + gbState = WAT_PLS_UNKNOWN; return 0; } @@ -297,9 +297,9 @@ LPCHECKPROC CheckPlayer(HWND wnd, int flags) return 0; } if(Parser()) - return (LPCHECKPROC)WAT_MES_STOPPED; + return (LPCHECKPROC)WAT_PLS_STOPPED; if(Connected) - return (LPCHECKPROC)WAT_MES_PLAYING; + return (LPCHECKPROC)WAT_PLS_PLAYING; return 0; } @@ -384,7 +384,7 @@ LPCOMMANDPROC SendCommand(HWND wnd, int command, int value) Netlib_Send(ghConnection, "previous\n", (int)strlen("previous\n"), 0); break; case WAT_CTRL_PLAY: //add resuming support - if(gbState != WAT_MES_PAUSED) + if(gbState != WAT_PLS_PAUSED) Netlib_Send(ghConnection, "play\n", (int)strlen("play\n"), 0); else Netlib_Send(ghConnection, "pause 0\n", (int)strlen("pause 0\n"), 0); diff --git a/plugins/mRadio/rbass.pas b/plugins/mRadio/rbass.pas index ebdb33f913..79f6f653ad 100644 --- a/plugins/mRadio/rbass.pas +++ b/plugins/mRadio/rbass.pas @@ -393,6 +393,7 @@ begin repeat StrCopyW(pc,fd.cFileName); if BASS_PluginLoad(pAnsiChar(basspath),BASS_UNICODE)=0 then + break; until not FindNextFileW(fh,fd); FindClose(fh); end; -- cgit v1.2.3