diff --git a/Plugins/PluginNowPlaying/Internet.cpp b/Plugins/PluginNowPlaying/Internet.cpp index 765f3e9d..65438b73 100644 --- a/Plugins/PluginNowPlaying/Internet.cpp +++ b/Plugins/PluginNowPlaying/Internet.cpp @@ -60,6 +60,7 @@ void CInternet::Finalize() */ std::wstring CInternet::DownloadUrl(const std::wstring& url, int codepage) { + // From WebParser.cpp std::wstring result; DWORD flags = INTERNET_FLAG_RESYNCHRONIZE; HINTERNET hUrlDump = InternetOpenUrl(c_NetHandle, url.c_str(), NULL, NULL, flags, 0); diff --git a/Plugins/PluginNowPlaying/NowPlaying.cpp b/Plugins/PluginNowPlaying/NowPlaying.cpp index 80be0079..d30f61b9 100644 --- a/Plugins/PluginNowPlaying/NowPlaying.cpp +++ b/Plugins/PluginNowPlaying/NowPlaying.cpp @@ -209,10 +209,6 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) { child->type = MEASURE_ALBUM; } - else if (_wcsicmp(L"LYRICS", str) == 0) - { - child->type = MEASURE_LYRICS; - } else if (_wcsicmp(L"COVER", str) == 0) { child->type = MEASURE_COVER; @@ -239,11 +235,19 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) { child->type = MEASURE_STATE; } + else if (_wcsicmp(L"STATUS", str) == 0) + { + child->type = MEASURE_STATUS; + } else if (_wcsicmp(L"VOLUME", str) == 0) { child->type = MEASURE_VOLUME; maxValue = 100; } + else if (_wcsicmp(L"LYRICS", str) == 0) + { + child->type = MEASURE_LYRICS; + } else if (_wcsicmp(L"FILE", str) == 0) { child->type = MEASURE_FILE; @@ -343,11 +347,14 @@ UINT Update(UINT id) case MEASURE_RATING: return player->GetRating(); + case MEASURE_VOLUME: + return player->GetVolume(); + case MEASURE_STATE: return (UINT)player->GetState(); - case MEASURE_VOLUME: - return player->GetVolume(); + case MEASURE_STATUS: + return (UINT)player->IsInitialized(); } return 0; @@ -389,6 +396,9 @@ LPCTSTR GetString(UINT id, UINT flags) case MEASURE_COVER: return player->GetCoverPath(); + case MEASURE_FILE: + return player->GetFilePath(); + case MEASURE_DURATION: SecondsToTime(player->GetDuration(), parent->disableLeadingZero, buffer); return buffer; @@ -405,21 +415,22 @@ LPCTSTR GetString(UINT id, UINT flags) _itow(player->GetRating(), buffer, 10); return buffer; - case MEASURE_STATE: - _itow(player->GetState(), buffer, 10); - return buffer; - case MEASURE_VOLUME: _itow(player->GetVolume(), buffer, 10); return buffer; - case MEASURE_FILE: - return player->GetFilePath(); + case MEASURE_STATE: + _itow(player->GetState(), buffer, 10); + return buffer; + + case MEASURE_STATUS: + _itow((UINT)player->IsInitialized(), buffer, 10); + return buffer; } } else { - return L"Error: Invalid player."; + return L"Error: Invalid player name."; } return L""; diff --git a/Plugins/PluginNowPlaying/Player.h b/Plugins/PluginNowPlaying/Player.h index a34c74aa..a9d6d601 100644 --- a/Plugins/PluginNowPlaying/Player.h +++ b/Plugins/PluginNowPlaying/Player.h @@ -39,13 +39,14 @@ enum MEASURETYPE MEASURE_ALBUM, MEASURE_LYRICS, MEASURE_COVER, + MEASURE_FILE, MEASURE_DURATION, MEASURE_POSITION, MEASURE_PROGRESS, MEASURE_RATING, - MEASURE_STATE, MEASURE_VOLUME, - MEASURE_FILE + MEASURE_STATE, + MEASURE_STATUS }; class CPlayer diff --git a/Plugins/PluginNowPlaying/PlayerAIMP.cpp b/Plugins/PluginNowPlaying/PlayerAIMP.cpp index 199c6b17..5ff6a691 100644 --- a/Plugins/PluginNowPlaying/PlayerAIMP.cpp +++ b/Plugins/PluginNowPlaying/PlayerAIMP.cpp @@ -23,7 +23,6 @@ CPlayer* CPlayerAIMP::c_Player = NULL; -// TODO /* ** CPlayerAIMP ** diff --git a/Plugins/PluginNowPlaying/PlayerCAD.cpp b/Plugins/PluginNowPlaying/PlayerCAD.cpp index 65bd5316..13295e81 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.cpp +++ b/Plugins/PluginNowPlaying/PlayerCAD.cpp @@ -84,7 +84,7 @@ void CPlayerCAD::Initialize() wc.lpszClassName = L"NowPlayingCADClass"; RegisterClass(&wc); - // Create dummy window + // Create reciever window m_Window = CreateWindow(L"NowPlayingCADClass", L"CD Art Display 1.x Class", WS_DISABLED, @@ -97,6 +97,31 @@ void CPlayerCAD::Initialize() hInstance, this); + // Add WM_USER/WM_COPYDATA to allowed messages from lower level processes + HMODULE hUser32 = LoadLibrary(L"user32.dll"); + if (hUser32) + { + // Try ChangeWindowMessageFilterEx first (Win7+) + FPCHANGEWINDOWMESSAGEFILTEREX ChangeWindowMessageFilterEx = (FPCHANGEWINDOWMESSAGEFILTEREX)GetProcAddress(hUser32, "ChangeWindowMessageFilterEx"); + if (ChangeWindowMessageFilterEx) + { + ChangeWindowMessageFilterEx(m_Window, WM_USER, MSGFLT_ALLOW, NULL); + ChangeWindowMessageFilterEx(m_Window, WM_COPYDATA, MSGFLT_ALLOW, NULL); + } + else + { + // Try ChangeWindowMessageFilter (Vista) + FPCHANGEWINDOWMESSAGEFILTER ChangeWindowMessageFilter = (FPCHANGEWINDOWMESSAGEFILTER)GetProcAddress(hUser32, "ChangeWindowMessageFilter"); + if (ChangeWindowMessageFilter) + { + ChangeWindowMessageFilter(WM_USER, MSGFLT_ALLOW); + ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ALLOW); + } + } + + FreeLibrary(hUser32); + } + WCHAR buffer[MAX_PATH]; LPCTSTR file = g_SettingsFile.c_str(); @@ -177,7 +202,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM switch (lParam) { case IPC_TRACK_CHANGED_NOTIFICATION: - SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK); + PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK); break; case IPC_PLAYER_STATE_CHANGED_NOTIFICATION: @@ -280,7 +305,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (player->m_State != PLAYER_STOPPED) { - SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK); + PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK); } } } diff --git a/Plugins/PluginNowPlaying/PlayerCAD.h b/Plugins/PluginNowPlaying/PlayerCAD.h index 0ad6ad3e..1e015931 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.h +++ b/Plugins/PluginNowPlaying/PlayerCAD.h @@ -21,6 +21,9 @@ #include "Player.h" +typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTER)(UINT message, DWORD dwFlag); +typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTEREX)(HWND hWnd, UINT message, DWORD dwFlag, PCHANGEFILTERSTRUCT pChangeFilterStruct); + class CPlayerCAD : public CPlayer { public: diff --git a/Plugins/PluginNowPlaying/PlayerFoobar.cpp b/Plugins/PluginNowPlaying/PlayerFoobar.cpp index 012d24a4..c3066f80 100644 --- a/Plugins/PluginNowPlaying/PlayerFoobar.cpp +++ b/Plugins/PluginNowPlaying/PlayerFoobar.cpp @@ -284,7 +284,7 @@ void CPlayerFoobar::Pause() */ void CPlayerFoobar::Play() { - SendMessage(m_FooWindow, WM_USER, 0, FOO_PLAY); + SendMessage(m_FooWindow, WM_USER, 0, (m_State == PLAYER_PAUSED) ? FOO_PLAYPAUSE : FOO_PLAY); } /* diff --git a/Plugins/PluginNowPlaying/PlayerWMP.cpp b/Plugins/PluginNowPlaying/PlayerWMP.cpp index f3fda6b3..fc16f830 100644 --- a/Plugins/PluginNowPlaying/PlayerWMP.cpp +++ b/Plugins/PluginNowPlaying/PlayerWMP.cpp @@ -230,7 +230,7 @@ void CPlayerWMP::Initialize() CComPtr spHostObject; CComPtr spHost; CComObject* pRemoteHost; - + m_AxWindow = new CAxWindow(); HRESULT hr = m_AxWindow ? S_OK : E_OUTOFMEMORY; diff --git a/Plugins/PluginNowPlaying/PlayerWinamp.cpp b/Plugins/PluginNowPlaying/PlayerWinamp.cpp index 28b8a143..bf9609c0 100644 --- a/Plugins/PluginNowPlaying/PlayerWinamp.cpp +++ b/Plugins/PluginNowPlaying/PlayerWinamp.cpp @@ -138,20 +138,20 @@ void CPlayerWinamp::UpdateData() m_Volume = (SendMessage(m_Window, WM_WA_IPC, -666, IPC_SETVOLUME) * 100) / 255; // 0 - 255 to 0 - 100 } - BOOL ret; WCHAR wBuffer[MAX_PATH]; char cBuffer[MAX_PATH]; + BOOL ret; if (m_UseUnicodeAPI) { - ret = ReadProcessMemory(m_WinampHandle, m_WinampAddress, &wBuffer, MAX_PATH, NULL); + ret = ReadProcessMemory(m_WinampHandle, m_WinampAddress, &wBuffer, sizeof(wBuffer), NULL); } else { // MediaMonkey doesn't support wide IPC messages int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS); LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTFILE); - ret = ReadProcessMemory(m_WinampHandle, address, &cBuffer, MAX_PATH, NULL); + ret = ReadProcessMemory(m_WinampHandle, address, &cBuffer, sizeof(cBuffer), NULL); mbstowcs(wBuffer, cBuffer, MAX_PATH); } @@ -182,13 +182,13 @@ void CPlayerWinamp::UpdateData() if (m_UseUnicodeAPI) { LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE); - ret = ReadProcessMemory(m_WinampHandle, address, &wBuffer, MAX_PATH, NULL); + ret = ReadProcessMemory(m_WinampHandle, address, &wBuffer, sizeof(wBuffer), NULL); } else { int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS); LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTTITLE); - ReadProcessMemory(m_WinampHandle, m_WinampAddress, &cBuffer, MAX_PATH, NULL); + ReadProcessMemory(m_WinampHandle, m_WinampAddress, &cBuffer, sizeof(cBuffer), NULL); ret = mbstowcs(wBuffer, cBuffer, MAX_PATH); } diff --git a/Plugins/PluginNowPlaying/PluginNowPlaying.rc b/Plugins/PluginNowPlaying/PluginNowPlaying.rc index faa00aec..ec398e92 100644 --- a/Plugins/PluginNowPlaying/PluginNowPlaying.rc +++ b/Plugins/PluginNowPlaying/PluginNowPlaying.rc @@ -12,7 +12,7 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,1,1,0 + FILEVERSION 1,1,2,0 PRODUCTVERSION PRODUCTVER FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -29,7 +29,7 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "FileDescription", "NowPlaying Plugin for Rainmeter" - VALUE "FileVersion", "1.1.1.0" + VALUE "FileVersion", "1.1.2.0" VALUE "InternalName", "NowPlaying" VALUE "LegalCopyright", "Copyright (C) 2011 - Birunthan Mohanathas" VALUE "OriginalFilename", "NowPlaying.dll" diff --git a/Plugins/PluginNowPlaying/SDKs/CAD/cad_sdk.h b/Plugins/PluginNowPlaying/SDKs/CAD/cad_sdk.h index eb9097f3..ed1055a6 100644 --- a/Plugins/PluginNowPlaying/SDKs/CAD/cad_sdk.h +++ b/Plugins/PluginNowPlaying/SDKs/CAD/cad_sdk.h @@ -1,21 +1,3 @@ -/* - Copyright (C) 2011 Birunthan Mohanathas (www.poiru.net) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - #ifndef __CADSDK_H__ #define __CADSDK_H__ @@ -155,10 +137,6 @@ enum IPCMESSAGE // uMsg: WM_USER, wParam: 0, lParam: 801 IPC_GET_CURRENT_LYRICS, - - - IPC_ADDFILE_PLAY_PLAYLIST, - IPC_ADDFILE_QUEUE_PLAYLIST }; #endif