From ed2d1ab18f4d01088e33982cac48f3447eabb56b Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 25 Dec 2015 12:25:08 +0200 Subject: [PATCH] Make MediaKey a measure --- Build/Installer/Installer.nsi | 9 +++-- Library/Library.vcxproj | 1 + Library/Library.vcxproj.filters | 6 +++ Library/Measure.cpp | 5 +++ .../MeasureMediaKey.cpp | 20 +++++++--- Library/MeasureMediaKey.h | 29 ++++++++++++++ Library/Skin.cpp | 2 +- Plugins/PluginMediaKey/PluginMediaKey.rc | 40 ------------------- Plugins/PluginMediaKey/PluginMediaKey.vcxproj | 35 ---------------- Rainmeter.sln | 10 ----- 10 files changed, 62 insertions(+), 95 deletions(-) rename Plugins/PluginMediaKey/PluginMediaKey.cpp => Library/MeasureMediaKey.cpp (70%) create mode 100644 Library/MeasureMediaKey.h delete mode 100644 Plugins/PluginMediaKey/PluginMediaKey.rc delete mode 100644 Plugins/PluginMediaKey/PluginMediaKey.vcxproj diff --git a/Build/Installer/Installer.nsi b/Build/Installer/Installer.nsi index 303fde39c..7d271f51b 100644 --- a/Build/Installer/Installer.nsi +++ b/Build/Installer/Installer.nsi @@ -648,7 +648,7 @@ SkipIniMove: ${EndIf} Rename "$INSTDIR\Addons" "$INSTDIR\Defaults\Addons" - ${Locate} "$INSTDIR\Plugins" "/L=F /M=*.dll /G=0" "MoveNonDefaultPlugins" + ${Locate} "$INSTDIR\Plugins" "/L=F /M=*.dll /G=0" "HandlePlugins" ${EndIf} !ifdef INCLUDEFILES @@ -767,14 +767,15 @@ Function RenameToRainmeterIni Push $0 FunctionEnd -Function MoveNonDefaultPlugins - ${If} $R7 != "AdvancedCPU.dll" +Function HandlePlugins + ${If} $R7 == "MediaKey.dll" + Delete "$R9" + ${ElseIf} $R7 != "AdvancedCPU.dll" ${AndIf} $R7 != "CoreTemp.dll" ${AndIf} $R7 != "FileView.dll" ${AndIf} $R7 != "FolderInfo.dll" ${AndIf} $R7 != "InputText.dll" ${AndIf} $R7 != "iTunesPlugin.dll" - ${AndIf} $R7 != "MediaKey.dll" ${AndIf} $R7 != "NowPlaying.dll" ${AndIf} $R7 != "PerfMon.dll" ${AndIf} $R7 != "PingPlugin.dll" diff --git a/Library/Library.vcxproj b/Library/Library.vcxproj index 12cf8eb8d..f6cfacf11 100644 --- a/Library/Library.vcxproj +++ b/Library/Library.vcxproj @@ -44,6 +44,7 @@ + diff --git a/Library/Library.vcxproj.filters b/Library/Library.vcxproj.filters index 2d6ef2151..fa52e961b 100644 --- a/Library/Library.vcxproj.filters +++ b/Library/Library.vcxproj.filters @@ -45,6 +45,9 @@ Source Files + + Source Files + Source Files @@ -215,6 +218,9 @@ Header Files + + Header Files + Header Files diff --git a/Library/Measure.cpp b/Library/Measure.cpp index 7df954a2a..b27438e2f 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -8,6 +8,7 @@ #include "StdAfx.h" #include "Measure.h" #include "MeasureCPU.h" +#include "MeasureMediaKey.h" #include "MeasureMemory.h" #include "MeasurePhysicalMemory.h" #include "MeasureVirtualMemory.h" @@ -724,6 +725,10 @@ Measure* Measure::Create(const WCHAR* measure, Skin* skin, const WCHAR* name) { return new MeasureCPU(skin, name); } + else if (_wcsicmp(L"MediaKey", measure) == 0) + { + return new MeasureMediaKey(skin, name); + } else if (_wcsicmp(L"Memory", measure) == 0) { return new MeasureMemory(skin, name); diff --git a/Plugins/PluginMediaKey/PluginMediaKey.cpp b/Library/MeasureMediaKey.cpp similarity index 70% rename from Plugins/PluginMediaKey/PluginMediaKey.cpp rename to Library/MeasureMediaKey.cpp index c3addfa46..292fd8eff 100644 --- a/Plugins/PluginMediaKey/PluginMediaKey.cpp +++ b/Library/MeasureMediaKey.cpp @@ -1,12 +1,21 @@ -/* Copyright (C) 2010 Rainmeter Project Developers +/* Copyright (C) 2015 Rainmeter Project Developers * * This Source Code Form is subject to the terms of the GNU General Public * License; either version 2 of the License, or (at your option) any later * version. If a copy of the GPL was not distributed with this file, You can * obtain one at . */ -#include -#include "../../Library/Export.h" // Rainmeter's exported functions +#include "StdAfx.h" +#include "MeasureMediaKey.h" +#include "Logger.h" + +MeasureMediaKey::MeasureMediaKey(Skin* skin, const WCHAR* name) : Measure(skin, name) +{ +} + +MeasureMediaKey::~MeasureMediaKey() +{ +} void SendKey(WORD key) { @@ -24,8 +33,9 @@ void SendKey(WORD key) SendInput(1, &input, sizeof(INPUT)); } -PLUGIN_EXPORT void ExecuteBang(LPCTSTR args, UINT id) +void MeasureMediaKey::Command(const std::wstring& command) { + const WCHAR* args = command.c_str(); if (_wcsicmp(args, L"NextTrack") == 0) { SendKey(VK_MEDIA_NEXT_TRACK); @@ -56,6 +66,6 @@ PLUGIN_EXPORT void ExecuteBang(LPCTSTR args, UINT id) } else { - RmLog(LOG_WARNING, L"MediaKey.dll: Unknown bang"); + LogErrorF(this, L"Unknown command: %s", args); } } diff --git a/Library/MeasureMediaKey.h b/Library/MeasureMediaKey.h new file mode 100644 index 000000000..69b4fefcb --- /dev/null +++ b/Library/MeasureMediaKey.h @@ -0,0 +1,29 @@ +/* Copyright (C) 2015 Rainmeter Project Developers + * + * This Source Code Form is subject to the terms of the GNU General Public + * License; either version 2 of the License, or (at your option) any later + * version. If a copy of the GPL was not distributed with this file, You can + * obtain one at . */ + +#ifndef RM_LIBRARY_MEASUREMEDIAKEY_H_ +#define RM_LIBRARY_MEASUREMEDIAKEY_H_ + +#include "Measure.h" + +class MeasureMediaKey : public Measure +{ +public: + MeasureMediaKey(Skin* skin, const WCHAR* name); + virtual ~MeasureMediaKey(); + + MeasureMediaKey(const MeasureMediaKey& other) = delete; + MeasureMediaKey& operator=(MeasureMediaKey other) = delete; + + UINT GetTypeID() override { return TypeID(); } + +protected: + void UpdateValue() override {}; + void Command(const std::wstring& command) override; +}; + +#endif diff --git a/Library/Skin.cpp b/Library/Skin.cpp index 8ac3ff34b..7bc26c6e8 100644 --- a/Library/Skin.cpp +++ b/Library/Skin.cpp @@ -2225,7 +2225,7 @@ bool Skin::ReadSkin() PathFindFileName(m_Parser.ReadString(section, L"Plugin", L"", false).c_str()); PathRemoveExtension(plugin); - const WCHAR* const kOldDefaultPlugins[] = { L"" }; + const WCHAR* const kOldDefaultPlugins[] = { L"MediaKey" }; for (const auto* oldDefaultPlugin : kOldDefaultPlugins) { if (_wcsicmp(plugin, oldDefaultPlugin) == 0) diff --git a/Plugins/PluginMediaKey/PluginMediaKey.rc b/Plugins/PluginMediaKey/PluginMediaKey.rc deleted file mode 100644 index aa1db293a..000000000 --- a/Plugins/PluginMediaKey/PluginMediaKey.rc +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "../../Version.h" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION PRODUCTVER - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT_UNKNOWN -{ - BLOCK "StringFileInfo" - { - BLOCK "040904E4" - { - VALUE "FileVersion", "1.0.0.0" - VALUE "LegalCopyright", "© 2010 - Birunthan Mohanathas" - VALUE "ProductName", "Rainmeter" -#ifdef _WIN64 - VALUE "ProductVersion", STRPRODUCTVER " (64-bit)" -#else - VALUE "ProductVersion", STRPRODUCTVER " (32-bit)" -#endif //_WIN64 - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x409, 1252 - } -} \ No newline at end of file diff --git a/Plugins/PluginMediaKey/PluginMediaKey.vcxproj b/Plugins/PluginMediaKey/PluginMediaKey.vcxproj deleted file mode 100644 index 5c08ceda6..000000000 --- a/Plugins/PluginMediaKey/PluginMediaKey.vcxproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4} - DynamicLibrary - MediaKey - - - - - - - - - - - - - - _USRDLL;%(PreprocessorDefinitions) - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Rainmeter.sln b/Rainmeter.sln index 12ea4dcce..30a2d3f31 100644 --- a/Rainmeter.sln +++ b/Rainmeter.sln @@ -49,8 +49,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInputText", "Plugins\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginiTunes", "Plugins\PluginiTunes\PluginiTunes.vcxproj", "{A2DD3CBE-B140-4892-A875-24107FA52518}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginMediaKey", "Plugins\PluginMediaKey\PluginMediaKey.vcxproj", "{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginNowPlaying", "Plugins\PluginNowPlaying\PluginNowPlaying.vcxproj", "{C7FECFCD-E6C6-4F95-BB9A-E1762B043969}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginPerfMon", "Plugins\PluginPerfMon\PluginPerfMon.vcxproj", "{5344B52B-BAC3-479C-B41D-D465B8BDA1AD}" @@ -221,14 +219,6 @@ Global {A2DD3CBE-B140-4892-A875-24107FA52518}.Release|Win32.Build.0 = Release|Win32 {A2DD3CBE-B140-4892-A875-24107FA52518}.Release|x64.ActiveCfg = Release|x64 {A2DD3CBE-B140-4892-A875-24107FA52518}.Release|x64.Build.0 = Release|x64 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|Win32.ActiveCfg = Debug|Win32 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|Win32.Build.0 = Debug|Win32 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|x64.ActiveCfg = Debug|x64 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|x64.Build.0 = Debug|x64 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|Win32.ActiveCfg = Release|Win32 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|Win32.Build.0 = Release|Win32 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|x64.ActiveCfg = Release|x64 - {EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|x64.Build.0 = Release|x64 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.ActiveCfg = Debug|Win32 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.Build.0 = Debug|Win32 {C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|x64.ActiveCfg = Debug|x64