From f84491ec838fc6f9350e24f1f0a1759dcbbf5841 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Thu, 10 Nov 2011 12:09:50 +0000 Subject: [PATCH] NowPlaying.dll: - Fixed that album name and cover were not always displayed with Winamp due to r1018 - Shuffle and repeat state is now rechecked on track change with iTunes - Improved performance when reading file tags/cover - Updated iTunes SDK files --- Library/System.cpp | 59 +++++++++++-------- Library/System.h | 2 + Plugins/PluginNowPlaying/NowPlaying.cpp | 16 ++--- Plugins/PluginNowPlaying/Player.cpp | 2 +- Plugins/PluginNowPlaying/PlayerITunes.cpp | 21 +++++++ Plugins/PluginNowPlaying/PlayerWinamp.cpp | 7 ++- Plugins/PluginNowPlaying/PluginNowPlaying.rc | 6 +- .../SDKs/iTunes/iTunesCOMInterface.h | 48 ++++++++++++++- .../SDKs/iTunes/iTunesCOMInterface_i.c | 2 +- 9 files changed, 121 insertions(+), 42 deletions(-) diff --git a/Library/System.cpp b/Library/System.cpp index 3f5eb71a..124e51c4 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -102,30 +102,7 @@ void CSystem::Initialize(HINSTANCE instance) SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS); SetWindowPos(c_HelperWindow, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS); - OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)}; - if (GetVersionEx((OSVERSIONINFO*)&osvi)) - { - if (osvi.dwMajorVersion == 5) - { - // Not checking for osvi.dwMinorVersion >= 1 because Rainmeter won't run on pre-XP - c_Platform = OSPLATFORM_XP; - } - else if (osvi.dwMajorVersion == 6) - { - if (osvi.dwMinorVersion == 0) - { - c_Platform = OSPLATFORM_VISTA; // Vista, Server 2008 - } - else - { - c_Platform = OSPLATFORM_7; // 7, Server 2008R2 - } - } - else // newer OS - { - c_Platform = OSPLATFORM_7; - } - } + SetOSPlatform(); c_Monitors.monitors.reserve(8); SetMultiMonitorInfo(); @@ -564,6 +541,40 @@ void CSystem::UpdateWorkareaInfo() } } +/* +** SetOSPlatform +** +** Sets the OS platform. +** +*/ +void CSystem::SetOSPlatform() +{ + OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)}; + if (GetVersionEx((OSVERSIONINFO*)&osvi)) + { + if (osvi.dwMajorVersion == 5) + { + // Not checking for osvi.dwMinorVersion >= 1 because Rainmeter won't run on pre-XP + c_Platform = OSPLATFORM_XP; + } + else if (osvi.dwMajorVersion == 6) + { + if (osvi.dwMinorVersion == 0) + { + c_Platform = OSPLATFORM_VISTA; // Vista, Server 2008 + } + else + { + c_Platform = OSPLATFORM_7; // 7, Server 2008R2 + } + } + else // newer OS + { + c_Platform = OSPLATFORM_7; + } + } +} + /* ** GetDefaultShellWindow ** diff --git a/Library/System.h b/Library/System.h index 68777812..2c13c07c 100644 --- a/Library/System.h +++ b/Library/System.h @@ -97,6 +97,8 @@ private: static void ClearMultiMonitorInfo() { c_Monitors.monitors.clear(); } static void UpdateWorkareaInfo(); + static void SetOSPlatform(); + static HWND GetDefaultShellWindow(); static HWND GetWorkerW(); static void ChangeZPosInOrder(); diff --git a/Plugins/PluginNowPlaying/NowPlaying.cpp b/Plugins/PluginNowPlaying/NowPlaying.cpp index 00ce8423..db07652e 100644 --- a/Plugins/PluginNowPlaying/NowPlaying.cpp +++ b/Plugins/PluginNowPlaying/NowPlaying.cpp @@ -407,31 +407,31 @@ LPCTSTR GetString(UINT id, UINT flags) return buffer; case MEASURE_PROGRESS: - _itow(player->GetDuration() ? ((player->GetPosition() * 100) / player->GetDuration()) : 0, buffer, 10); + _itow_s(player->GetDuration() ? ((player->GetPosition() * 100) / player->GetDuration()) : 0, buffer, 10); return buffer; case MEASURE_RATING: - _itow(player->GetRating(), buffer, 10); + _itow_s(player->GetRating(), buffer, 10); return buffer; case MEASURE_VOLUME: - _itow(player->GetVolume(), buffer, 10); + _itow_s(player->GetVolume(), buffer, 10); return buffer; case MEASURE_STATE: - _itow(player->GetState(), buffer, 10); + _itow_s(player->GetState(), buffer, 10); return buffer; case MEASURE_STATUS: - _itow((int)player->IsInitialized(), buffer, 10); + _itow_s((int)player->IsInitialized(), buffer, 10); return buffer; case MEASURE_SHUFFLE: - _itow((int)player->GetShuffle(), buffer, 10); + _itow_s((int)player->GetShuffle(), buffer, 10); return buffer; case MEASURE_REPEAT: - _itow((int)player->GetRepeat(), buffer, 10); + _itow_s((int)player->GetRepeat(), buffer, 10); return buffer; } } @@ -440,7 +440,7 @@ LPCTSTR GetString(UINT id, UINT flags) return L"Error: Invalid player name"; } - return L""; + return NULL; } /* diff --git a/Plugins/PluginNowPlaying/Player.cpp b/Plugins/PluginNowPlaying/Player.cpp index 2763f341..5b83dd55 100644 --- a/Plugins/PluginNowPlaying/Player.cpp +++ b/Plugins/PluginNowPlaying/Player.cpp @@ -124,7 +124,7 @@ void CPlayer::UpdateMeasure() */ void CPlayer::FindCover() { - TagLib::FileRef fr(m_FilePath.c_str()); + TagLib::FileRef fr(m_FilePath.c_str(), false); if (!fr.isNull() && CCover::GetEmbedded(fr, m_TempCoverPath)) { m_CoverPath = m_TempCoverPath; diff --git a/Plugins/PluginNowPlaying/PlayerITunes.cpp b/Plugins/PluginNowPlaying/PlayerITunes.cpp index f329932f..58adf191 100644 --- a/Plugins/PluginNowPlaying/PlayerITunes.cpp +++ b/Plugins/PluginNowPlaying/PlayerITunes.cpp @@ -372,6 +372,27 @@ void CPlayerITunes::OnTrackChange() tmpVal /= 20L; m_Rating = (UINT)tmpVal; + IITPlaylist* playlist; + hr = track->get_Playlist(&playlist); + if (SUCCEEDED(hr)) + { + VARIANT_BOOL shuffle; + hr = playlist->get_Shuffle(&shuffle); + if (SUCCEEDED(hr)) + { + m_Shuffle = (bool)shuffle; + } + + ITPlaylistRepeatMode repeat; + hr = playlist->get_SongRepeat(&repeat); + if (SUCCEEDED(hr)) + { + m_Repeat = (bool)repeat; + } + + playlist->Release(); + } + IITFileOrCDTrack* file; hr = track->QueryInterface(&file); if (SUCCEEDED(hr)) diff --git a/Plugins/PluginNowPlaying/PlayerWinamp.cpp b/Plugins/PluginNowPlaying/PlayerWinamp.cpp index b9c77220..1b6746eb 100644 --- a/Plugins/PluginNowPlaying/PlayerWinamp.cpp +++ b/Plugins/PluginNowPlaying/PlayerWinamp.cpp @@ -178,7 +178,7 @@ void CPlayerWinamp::UpdateData() m_Shuffle = (bool)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_SHUFFLE); m_Repeat = (bool)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_REPEAT); - TagLib::FileRef fr(wBuffer); + TagLib::FileRef fr(wBuffer, false); TagLib::Tag* tag = fr.tag(); if (tag) { @@ -207,7 +207,7 @@ void CPlayerWinamp::UpdateData() } std::wstring trackFolder = CCover::GetFileFolder(m_FilePath); - if (!m_Album.empty()) + if (tag && !m_Album.empty()) { // Winamp stores covers usually as %album%.jpg std::wstring file = m_Album; @@ -257,7 +257,8 @@ void CPlayerWinamp::UpdateData() m_CoverPath.clear(); } } - else if (tag) + + if (tag) { return; } diff --git a/Plugins/PluginNowPlaying/PluginNowPlaying.rc b/Plugins/PluginNowPlaying/PluginNowPlaying.rc index f14bf88d..7127e057 100644 --- a/Plugins/PluginNowPlaying/PluginNowPlaying.rc +++ b/Plugins/PluginNowPlaying/PluginNowPlaying.rc @@ -12,9 +12,9 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,1,3,6 + FILEVERSION 1,1,3,7 PRODUCTVERSION PRODUCTVER - FILEFLAGSMASK 0x17L + FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG #else @@ -29,7 +29,7 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "FileDescription", "NowPlaying Plugin for Rainmeter" - VALUE "FileVersion", "1.1.3.6" + VALUE "FileVersion", "1.1.3.7" VALUE "InternalName", "NowPlaying" VALUE "LegalCopyright", "Copyright (C) 2011 - Birunthan Mohanathas" VALUE "OriginalFilename", "NowPlaying.dll" diff --git a/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface.h b/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface.h index a07780e1..24440f22 100644 --- a/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface.h +++ b/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface.h @@ -4,7 +4,7 @@ /* File created by MIDL compiler version 6.00.0366 */ -/* at Wed Jun 25 17:02:20 2008 +/* at Wed Nov 05 13:21:00 2008 */ /* Compiler settings for iTunesCOMInterface.idl: Oicf, W1, Zp8, env=Win32 (32b run) @@ -263,7 +263,7 @@ void __RPC_USER MIDL_user_free( void * ); typedef /* [public][v1_enum][uuid] */ DECLSPEC_UUID("4B73428D-2F56-4833-8E5D-65590E45FEAD") enum __MIDL___MIDL_itf_iTunesCOMInterface_0000_0001 { kITTypeLibrary_MajorVersion = 1, - kITTypeLibrary_MinorVersion = 11 + kITTypeLibrary_MinorVersion = 12 } ITVersion; typedef /* [public][v1_enum][uuid] */ DECLSPEC_UUID("4C25623B-F990-4ebd-8970-F29A70084B8C") @@ -12390,6 +12390,12 @@ EXTERN_C const IID IID_IITFileOrCDTrack; virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_Playlists( /* [retval][out] */ IITPlaylistCollection **iPlaylistCollection) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Location( + /* [in] */ BSTR location) = 0; + + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ReleaseDate( + /* [retval][out] */ DATE *releaseDate) = 0; + }; #else /* C style interface */ @@ -12929,6 +12935,14 @@ EXTERN_C const IID IID_IITFileOrCDTrack; IITFileOrCDTrack * This, /* [retval][out] */ IITPlaylistCollection **iPlaylistCollection); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Location )( + IITFileOrCDTrack * This, + /* [in] */ BSTR location); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ReleaseDate )( + IITFileOrCDTrack * This, + /* [retval][out] */ DATE *releaseDate); + END_INTERFACE } IITFileOrCDTrackVtbl; @@ -13336,6 +13350,12 @@ EXTERN_C const IID IID_IITFileOrCDTrack; #define IITFileOrCDTrack_get_Playlists(This,iPlaylistCollection) \ (This)->lpVtbl -> get_Playlists(This,iPlaylistCollection) +#define IITFileOrCDTrack_put_Location(This,location) \ + (This)->lpVtbl -> put_Location(This,location) + +#define IITFileOrCDTrack_get_ReleaseDate(This,releaseDate) \ + (This)->lpVtbl -> get_ReleaseDate(This,releaseDate) + #endif /* COBJMACROS */ @@ -14036,6 +14056,30 @@ void __RPC_STUB IITFileOrCDTrack_get_Playlists_Stub( DWORD *_pdwStubPhase); +/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IITFileOrCDTrack_put_Location_Proxy( + IITFileOrCDTrack * This, + /* [in] */ BSTR location); + + +void __RPC_STUB IITFileOrCDTrack_put_Location_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IITFileOrCDTrack_get_ReleaseDate_Proxy( + IITFileOrCDTrack * This, + /* [retval][out] */ DATE *releaseDate); + + +void __RPC_STUB IITFileOrCDTrack_get_ReleaseDate_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + #endif /* __IITFileOrCDTrack_INTERFACE_DEFINED__ */ diff --git a/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface_i.c b/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface_i.c index 9402c13e..92e9c4c2 100644 --- a/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface_i.c +++ b/Plugins/PluginNowPlaying/SDKs/iTunes/iTunesCOMInterface_i.c @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 6.00.0366 */ -/* at Wed Jun 25 17:02:20 2008 +/* at Wed Nov 05 13:21:00 2008 */ /* Compiler settings for iTunesCOMInterface.idl: Oicf, W1, Zp8, env=Win32 (32b run)