Skip to content
Browse files

Reintegrated 2.3 branch into trunk

  • Loading branch information...
1 parent c3335ad commit c3ed2e5fa36ff3c7fed89d241e3b531a717970f6 @poiru poiru committed Jan 8, 2012
Showing with 5,240 additions and 2,593 deletions.
  1. +2 −2 Application/Application.vcxproj
  2. +56 −4 Library/DialogAbout.cpp
  3. +248 −0 Library/Export.cpp
  4. +89 −17 Library/Export.h
  5. +23 −7 Library/Library.vcxproj
  6. +6 −3 Library/Library.vcxproj.filters
  7. +9 −2 Library/Litestep.h
  8. +118 −80 Library/MeasurePlugin.cpp
  9. +34 −13 Library/MeasurePlugin.h
  10. +0 −2 Library/MeterWindow.cpp
  11. +0 −2 Library/MeterWindow.h
  12. +91 −0 Library/RawString.h
  13. +7 −0 Plugins/API/DllExporter/AssemblyInfo.cs
  14. +101 −0 Plugins/API/DllExporter/DllExporter.csproj
  15. +155 −0 Plugins/API/DllExporter/Program.cs
  16. +130 −0 Plugins/API/Rainmeter.cs
  17. +2 −2 Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcxproj
  18. +34 −108 Plugins/PluginCoreTemp/PluginCoreTemp.cpp
  19. +3 −10 Plugins/PluginCoreTemp/PluginCoreTemp.rc
  20. +2 −2 Plugins/PluginCoreTemp/PluginCoreTemp.vcxproj
  21. +2 −2 Plugins/PluginExample/PluginExample.vcxproj
  22. +7 −0 Plugins/PluginExampleCS/AssemblyInfo.cs
  23. +154 −0 Plugins/PluginExampleCS/Plugin.cs
  24. +100 −0 Plugins/PluginExampleCS/PluginExampleCS.csproj
  25. +2 −2 Plugins/PluginFolderInfo/PluginFolderInfo.vcxproj
  26. +24 −77 Plugins/PluginFolderInfo/PluginFolderInfo.vcxproj.filters
  27. +7 −0 Plugins/PluginInputText/AssemblyInfo.cs
  28. +105 −0 Plugins/PluginInputText/InputBox.Designer.cs
  29. +323 −0 Plugins/PluginInputText/InputBox.cs
  30. +120 −0 Plugins/PluginInputText/InputBox.resx
  31. +173 −0 Plugins/PluginInputText/Main.cs
  32. +476 −0 Plugins/PluginInputText/PluginCode.cs
  33. +114 −0 Plugins/PluginInputText/PluginInputText.csproj
  34. +766 −0 Plugins/PluginInputText/Rainmeter.cs
  35. +5 −37 Plugins/PluginMediaKey/PluginMediaKey.cpp
  36. +5 −12 Plugins/PluginMediaKey/PluginMediaKey.rc
  37. +2 −2 Plugins/PluginMediaKey/PluginMediaKey.vcxproj
  38. +1 −1 Plugins/PluginNowPlaying/Internet.cpp
  39. +386 −479 Plugins/PluginNowPlaying/NowPlaying.cpp
  40. +16 −30 Plugins/PluginNowPlaying/NowPlaying.h
  41. +2 −2 Plugins/PluginNowPlaying/Player.cpp
  42. +21 −21 Plugins/PluginNowPlaying/Player.h
  43. +3 −3 Plugins/PluginNowPlaying/PlayerAIMP.cpp
  44. +7 −7 Plugins/PluginNowPlaying/PlayerCAD.cpp
  45. +5 −5 Plugins/PluginNowPlaying/PlayerFoobar.cpp
  46. +5 −5 Plugins/PluginNowPlaying/PlayerITunes.cpp
  47. +2 −2 Plugins/PluginNowPlaying/PlayerSpotify.cpp
  48. +1 −1 Plugins/PluginNowPlaying/PlayerWLM.cpp
  49. +9 −9 Plugins/PluginNowPlaying/PlayerWMP.cpp
  50. +2 −2 Plugins/PluginNowPlaying/PlayerWinamp.cpp
  51. +3 −10 Plugins/PluginNowPlaying/PluginNowPlaying.rc
  52. +2 −2 Plugins/PluginNowPlaying/PluginNowPlaying.vcxproj
  53. +2 −2 Plugins/PluginPerfMon/PluginPerfMon.vcxproj
  54. +105 −232 Plugins/PluginPing/Ping.cpp
  55. +3 −10 Plugins/PluginPing/PluginPing.rc
  56. +6 −6 Plugins/PluginPing/PluginPing.vcxproj
  57. +10 −4 Plugins/PluginPower/PluginPower.vcxproj
  58. +137 −236 Plugins/PluginPower/PowerPlugin.cpp
  59. +35 −80 Plugins/PluginProcess/PluginProcess.cpp
  60. +1 −1 Plugins/PluginProcess/PluginProcess.rc
  61. +2 −2 Plugins/PluginProcess/PluginProcess.vcxproj
  62. +4 −11 Plugins/PluginQuote/PluginQuote.rc
  63. +2 −2 Plugins/PluginQuote/PluginQuote.vcxproj
  64. +205 −306 Plugins/PluginQuote/Quote.cpp
  65. +4 −11 Plugins/PluginRecycleManager/PluginRecycleManager.rc
  66. +2 −2 Plugins/PluginRecycleManager/PluginRecycleManager.vcxproj
  67. +69 −148 Plugins/PluginRecycleManager/RecycleManager.cpp
  68. +4 −11 Plugins/PluginResMon/PluginResMon.rc
  69. +2 −2 Plugins/PluginResMon/PluginResMon.vcxproj
  70. +64 −135 Plugins/PluginResMon/ResMon.cpp
  71. +4 −11 Plugins/PluginSpeedFan/PluginSpeedFan.rc
  72. +2 −2 Plugins/PluginSpeedFan/PluginSpeedFan.vcxproj
  73. +60 −150 Plugins/PluginSpeedFan/SpeedFanPlugin.cpp
  74. +2 −2 Plugins/PluginSysInfo/PluginSysInfo.vcxproj
  75. +2 −2 Plugins/PluginVirtualDesktops/PluginVirtualDesktops.vcxproj
  76. +2 −2 Plugins/PluginWebParser/PluginWebParser.vcxproj
  77. +2 −2 Plugins/PluginWifiStatus/PluginWifiStatus.vcxproj
  78. +2 −2 Plugins/PluginWin7Audio/PluginWin7Audio.vcxproj
  79. +2 −2 Plugins/PluginWindowMessage/PluginWindowMessage.vcxproj
  80. +68 −147 Plugins/PluginWindowMessage/WindowMessagePlugin.cpp
  81. +2 −2 Plugins/PluginiTunes/PluginiTunes.vcxproj
  82. +3 −0 Rainmeter.props
  83. +129 −89 Rainmeter.sln
  84. +264 −0 RainmeterCPP.sln
  85. +55 −0 RainmeterCS.sln
  86. +11 −0 Version.cs
  87. +13 −14 Version.h
View
4 Application/Application.vcxproj
@@ -67,10 +67,10 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x32\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)TestBench\x64\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x32\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
View
60 Library/DialogAbout.cpp
@@ -869,13 +869,66 @@ void CDialogAbout::CTabPlugins::Initialize()
// Try to get the version and author
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
+ const WCHAR* path = tmpSz.c_str();
+
+ vitem.iItem = index;
+ vitem.pszText = fileData.cFileName;
+
+ // Try to get version and author from file resources first
+ DWORD handle;
+ DWORD versionSize = GetFileVersionInfoSize(path, &handle);
+ if (versionSize)
+ {
+ bool found = false;
+ void* data = new BYTE[versionSize];
+ if (GetFileVersionInfo(path, 0, versionSize, data))
+ {
+ UINT len;
+ struct LANGCODEPAGE
+ {
+ WORD wLanguage;
+ WORD wCodePage;
+ } *lcp;
+
+ if (VerQueryValue(data, L"\\VarFileInfo\\Translation", (LPVOID*)&lcp, &len))
+ {
+ WCHAR key[64];
+ LPWSTR value;
+
+ _snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\ProductName", lcp[0].wLanguage, lcp[0].wCodePage);
+ if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len) &&
+ wcscmp(value, L"Rainmeter") == 0)
+ {
+ ListView_InsertItem(item, &vitem);
+ ++index;
+ found = true;
+
+ _snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\FileVersion", lcp[0].wLanguage, lcp[0].wCodePage);
+ if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
+ {
+ ListView_SetItemText(item, vitem.iItem, 1, value);
+ }
+
+ _snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\LegalCopyright", lcp[0].wLanguage, lcp[0].wCodePage);
+ if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
+ {
+ ListView_SetItemText(item, vitem.iItem, 2, value);
+ }
+ }
+ }
+ }
+
+ delete [] data;
+ if (found) continue;
+ }
+
+ // Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
DWORD err = 0;
- HMODULE dll = CSystem::RmLoadLibrary(tmpSz.c_str(), &err, true);
+ HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
if (dll)
{
- vitem.iItem = index;
- vitem.pszText = fileData.cFileName;
ListView_InsertItem(item, &vitem);
+ ++index;
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
if (GetVersionFunc)
@@ -896,7 +949,6 @@ void CDialogAbout::CTabPlugins::Initialize()
}
}
- ++index;
FreeLibrary(dll);
}
else
View
248 Library/Export.cpp
@@ -0,0 +1,248 @@
+/*
+ Copyright (C) 2011 Birunthan Mohanathas, Peter Souza
+
+ 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.
+*/
+
+#include "StdAfx.h"
+#include "Rainmeter.h"
+#include "Export.h"
+#include "MeterWindow.h"
+#include "Measure.h"
+#include "MeasurePlugin.h"
+
+#define NULLCHECK(str) { if ((str) == NULL) { (str) = L""; } }
+
+extern CRainmeter* Rainmeter;
+
+static std::wstring g_Buffer;
+
+LPCWSTR RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures)
+{
+ NULLCHECK(option);
+ NULLCHECK(defValue);
+
+ CMeasurePlugin* measure = (CMeasurePlugin*)rm;
+ CConfigParser& parser = measure->GetMeterWindow()->GetParser();
+ return parser.ReadString(measure->GetName(), option, defValue, (bool)replaceMeasures).c_str();
+}
+
+double RmReadFormula(void* rm, LPCWSTR option, double defValue)
+{
+ NULLCHECK(option);
+
+ CMeasurePlugin* measure = (CMeasurePlugin*)rm;
+ CConfigParser& parser = measure->GetMeterWindow()->GetParser();
+ return parser.ReadFormula(measure->GetName(), option, defValue);
+}
+
+LPCWSTR RmPathToAbsolute(void* rm, LPCWSTR relativePath)
+{
+ NULLCHECK(relativePath);
+
+ CMeasurePlugin* measure = (CMeasurePlugin*)rm;
+ g_Buffer = relativePath;
+ measure->GetMeterWindow()->MakePathAbsolute(g_Buffer);
+ return g_Buffer.c_str();
+}
+
+void* RmGet(void* rm, int type)
+{
+ CMeasurePlugin* measure = (CMeasurePlugin*)rm;
+
+ switch (type)
+ {
+ case RMG_MEASURENAME:
+ {
+ return (void*)measure->GetName();
+ }
+
+ case RMG_SKIN:
+ {
+ return (void*)measure->GetMeterWindow();
+ }
+
+ case RMG_SETTINGSFILE:
+ {
+ g_Buffer = Rainmeter->GetSettingsPath();
+ g_Buffer += L"Plugins.ini";
+ return (void*)g_Buffer.c_str();
+ }
+ }
+
+ return NULL;
+}
+
+void RmExecute(void* skin, LPCWSTR command)
+{
+ CMeterWindow* mw = (CMeterWindow*)skin;
+
+ // Fake WM_COPYDATA message to deliver bang
+ COPYDATASTRUCT cds;
+ cds.cbData = 1;
+ cds.dwData = 1;
+ cds.lpData = (void*)command;
+ mw->OnCopyData(WM_COPYDATA, NULL, (LPARAM)&cds);
+}
+
+BOOL LSLog(int nLevel, LPCWSTR unused, LPCWSTR pszMessage)
+{
+ NULLCHECK(pszMessage);
+
+ // Ignore LOG_DEBUG messages from plugins unless in debug mode
+ if (nLevel != LOG_DEBUG || Rainmeter->GetDebug())
+ {
+ Log(nLevel, pszMessage);
+ }
+
+ return TRUE;
+}
+
+// Deprecated!
+LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue)
+{
+ NULLCHECK(section);
+ NULLCHECK(option);
+ NULLCHECK(defValue);
+
+ CConfigParser* parser = Rainmeter->GetCurrentParser();
+ if (parser)
+ {
+ return parser->ReadString(section, option, defValue, false).c_str();
+ }
+
+ return defValue;
+}
+
+// Deprecated!
+LPCWSTR PluginBridge(LPCWSTR _sCommand, LPCWSTR _sData)
+{
+ if (_sCommand == NULL || *_sCommand == L'\0')
+ {
+ return L"noop";
+ }
+
+ NULLCHECK(_sData);
+
+ std::wstring sCommand = _sCommand;
+ std::transform(sCommand.begin(), sCommand.end(), sCommand.begin(), ::towlower);
+
+ // Command GetConfig
+ // Data unquoted full path and filename given to the plugin on initialize
+ // (note: this is CaSe-SeNsItIvE!)
+ // Execution none
+ // Result the config name if found or a blank string if not
+ if (sCommand == L"getconfig")
+ {
+ // returns the config name, lookup by INI file
+
+ CMeterWindow *meterWindow = Rainmeter->GetMeterWindowByINI(_sData);
+ if (meterWindow)
+ {
+ g_Buffer = L"\"";
+ g_Buffer += meterWindow->GetSkinName();
+ g_Buffer += L"\"";
+ return g_Buffer.c_str();
+ }
+
+ return L"";
+ }
+
+ // Command GetWindow
+ // Data [the config name]
+ // Execution none
+ // Result the HWND to the specified config window if found, 'error' otherwise
+ if (sCommand == L"getwindow")
+ {
+ std::vector<std::wstring> subStrings = CRainmeter::ParseString(_sData);
+
+ if (subStrings.size() >= 1)
+ {
+ const std::wstring& config = subStrings[0];
+
+ CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
+ if (meterWindow)
+ {
+ WCHAR buf1[64];
+ _snwprintf_s(buf1, _TRUNCATE, L"%lu", PtrToUlong(meterWindow->GetWindow()));
+ g_Buffer = buf1;
+ return g_Buffer.c_str();
+ }
+ }
+
+ return L"error";
+ }
+
+ // Command GetVariable
+ // Data [the config name]
+ // Execution none
+ // Result the value of the variable
+ if (sCommand == L"getvariable")
+ {
+ std::vector<std::wstring> subStrings = CRainmeter::ParseString(_sData);
+
+ if (subStrings.size() >= 2)
+ {
+ const std::wstring& config = subStrings[0];
+
+ CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
+ if (meterWindow)
+ {
+ const std::wstring& variable = subStrings[1];
+ std::wstring result_from_parser;
+
+ if (meterWindow->GetParser().GetVariable(variable, result_from_parser))
+ {
+ g_Buffer = result_from_parser;
+ return g_Buffer.c_str();
+ }
+ }
+ }
+
+ return L"";
+ }
+
+ // Command SetVariable
+ // Data [the config name] [variable data]
+ // Execution the indicated variable is updated
+ // Result 'success' if the config was found, 'error' otherwise
+ if (sCommand == L"setvariable")
+ {
+ std::vector<std::wstring> subStrings = CRainmeter::ParseString(_sData);
+
+ if (subStrings.size() >= 2)
+ {
+ const std::wstring& config = subStrings[0];
+ std::wstring arguments;
+
+ for (size_t i = 1, isize = subStrings.size(); i < isize; ++i)
+ {
+ if (i != 1) arguments += L" ";
+ arguments += subStrings[i];
+ }
+
+ CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
+ if (meterWindow)
+ {
+ meterWindow->RunBang(BANG_SETVARIABLE, arguments.c_str());
+ return L"success";
+ }
+ }
+
+ return L"error";
+ }
+
+ return L"noop";
+}
View
106 Library/Export.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2004 Kimmo Pekkola
+ Copyright (C) 2011 Kimmo Pekkola, Birunthan Mohanathas
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -20,28 +20,100 @@
#define __EXPORT_H__
#ifdef LIBRARY_EXPORTS
-#define EXPORT_PLUGIN __declspec(dllexport)
+#define LIBRARY_DECLSPEC __declspec(dllexport)
#else
-#define EXPORT_PLUGIN __declspec(dllimport)
-#endif
+#define LIBRARY_DECLSPEC __declspec(dllimport)
+#endif // LIBRARY_EXPORTS
-// log level constants
-#define LOG_ERROR 1
-#define LOG_WARNING 2
-#define LOG_NOTICE 3
-#define LOG_DEBUG 4
+#ifdef __cplusplus
+#define LIBRARY_EXPORT extern "C" LIBRARY_DECLSPEC
+#define PLUGIN_EXPORT extern "C" __declspec(dllexport)
+#else
+#define LIBRARY_EXPORT LIBRARY_DECLSPEC
+#define PLUGIN_EXPORT __declspec(dllexport)
+#endif // __cplusplus
+
+//
+// Exported functions
+//
#ifdef __cplusplus
-extern "C"
+LIBRARY_EXPORT LPCWSTR RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE);
+#else
+LIBRARY_EXPORT LPCWSTR RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures);
+#endif // __cplusplus
+
+LIBRARY_EXPORT double RmReadFormula(void* rm, LPCWSTR option, double defValue);
+
+LIBRARY_EXPORT LPCWSTR RmPathToAbsolute(void* rm, LPCWSTR relativePath);
+
+LIBRARY_EXPORT void RmExecute(void* skin, LPCWSTR command);
+
+LIBRARY_EXPORT void* RmGet(void* rm, int type);
+
+enum RmGetType
{
-#endif
+ RMG_MEASURENAME = 0,
+ RMG_SKIN = 1,
+ RMG_SETTINGSFILE = 2
+};
- EXPORT_PLUGIN BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage);
- EXPORT_PLUGIN LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue);
- EXPORT_PLUGIN LPCTSTR PluginBridge(LPCTSTR sCommand, LPCTSTR sData);
+LIBRARY_EXPORT BOOL LSLog(int type, LPCWSTR unused, LPCWSTR message);
-#ifdef __cplusplus
+/* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue);
+
+/* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data);
+
+//
+// Wrapper functions
+//
+
+#ifndef LIBRARY_EXPORTS
+__inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue)
+{
+ LPCWSTR relativePath = RmReadString(rm, option, defValue, TRUE);
+ return RmPathToAbsolute(rm, relativePath);
+}
+
+__inline int RmReadInt(void* rm, LPCWSTR option, int defValue)
+{
+ LPCWSTR value = RmReadString(rm, option, L"", TRUE);
+ return (*value) ? _wtoi(value) : defValue;
+}
+
+__inline double RmReadDouble(void* rm, LPCWSTR option, double defValue)
+{
+ LPCWSTR value = RmReadString(rm, option, L"", TRUE);
+ return (*value) ? wcstod(value, NULL) : defValue;
+}
+
+__inline LPCWSTR RmGetMeasureName(void* rm)
+{
+ return (LPCWSTR)RmGet(rm, RMG_MEASURENAME);
+}
+
+__inline LPCWSTR RmGetSettingsFile()
+{
+ return (LPCWSTR)RmGet(NULL, RMG_SETTINGSFILE);
}
-#endif
-#endif
+__inline void* RmGetSkin(void* rm)
+{
+ return (void*)RmGet(rm, RMG_SKIN);
+}
+
+__inline void RmLog(int level, LPCWSTR message)
+{
+ LSLog(level, NULL, message);
+}
+
+enum LOGLEVEL
+{
+ LOG_ERROR = 1,
+ LOG_WARNING = 2,
+ LOG_NOTICE = 3,
+ LOG_DEBUG = 4
+};
+#endif // LIBRARY_EXPORTS
+
+#endif
View
30 Library/Library.vcxproj
@@ -67,10 +67,10 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x32\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)TestBench\x64\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x32\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
@@ -115,14 +115,15 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../TestBench/x32/Debug/Rainmeter.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x32/Debug/Rainmeter.pdb</ProgramDatabaseFile>
<ImportLibrary>.\x32/Debug/Rainmeter.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
+ <DelayLoadDLLs>Winmm.dll;Version.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -158,14 +159,15 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../TestBench/x64/Debug/Rainmeter.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64/Debug/Rainmeter.pdb</ProgramDatabaseFile>
<ImportLibrary>.\x64/Debug/Rainmeter.lib</ImportLibrary>
<TargetMachine>MachineX64</TargetMachine>
+ <DelayLoadDLLs>Winmm.dll;Version.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -204,7 +206,7 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../TestBench/x32/Release/Rainmeter.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>lua/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -215,6 +217,7 @@
<MergeSections>.rdata=.text</MergeSections>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DelayLoadDLLs>Winmm.dll;Version.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -250,7 +253,7 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../TestBench/x64/Release/Rainmeter.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -260,6 +263,7 @@
<MergeSections>.rdata=.text</MergeSections>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DelayLoadDLLs>Winmm.dll;Version.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -657,6 +661,17 @@
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="Export.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
+ </ClCompile>
<ClCompile Include="StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
@@ -837,7 +852,6 @@
<ClInclude Include="DialogAbout.h" />
<ClInclude Include="DisableThreadLibraryCalls.h" />
<ClInclude Include="Error.h" />
- <ClInclude Include="Export.h" />
<ClInclude Include="Group.h" />
<ClInclude Include="Litestep.h" />
<ClInclude Include="DialogManage.h" />
@@ -873,7 +887,9 @@
<ClInclude Include="pcre-8.10\pcre_internal.h" />
<ClInclude Include="pcre-8.10\ucp.h" />
<ClInclude Include="Rainmeter.h" />
+ <ClInclude Include="Export.h" />
<ClInclude Include="RainmeterQuery.h" />
+ <ClInclude Include="RawString.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="System.h" />
View
9 Library/Library.vcxproj.filters
@@ -351,6 +351,9 @@
<ClCompile Include="DialogManage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Export.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ConfigParser.h">
@@ -362,9 +365,6 @@
<ClInclude Include="Error.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="Export.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="Group.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -593,6 +593,9 @@
<ClInclude Include="DialogManage.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="Export.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Library.rc">
View
11 Library/Litestep.h
@@ -23,7 +23,14 @@
#include <comdef.h>
#include <string>
#include "Error.h"
-#include "Export.h"
+
+enum LOGLEVEL
+{
+ LOG_ERROR = 1,
+ LOG_WARNING = 2,
+ LOG_NOTICE = 3,
+ LOG_DEBUG = 4
+};
void InitalizeLitestep();
void FinalizeLitestep();
@@ -38,7 +45,7 @@ std::string ConvertToUTF8(LPCWSTR str);
std::wstring ConvertUTF8ToWide(LPCSTR str);
void Log(int nLevel, const WCHAR* message);
-void LogWithArgs(int nLevel, const WCHAR* format, ... );
+void LogWithArgs(int nLevel, const WCHAR* format, ...);
void LogError(CError& error);
void RunCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, bool asAdmin = false);
View
198 Library/MeasurePlugin.cpp
@@ -19,6 +19,7 @@
#include "StdAfx.h"
#include "MeasurePlugin.h"
#include "Rainmeter.h"
+#include "Export.h"
#include "System.h"
#include "Error.h"
@@ -32,13 +33,13 @@ extern CRainmeter* Rainmeter;
*/
CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Plugin(),
+ m_ReloadFunc(),
m_ID(),
- InitializeFunc(),
- UpdateFunc(),
- UpdateFunc2(),
- FinalizeFunc(),
- GetStringFunc(),
- ExecuteBangFunc()
+ m_Update2(false),
+ m_PluginData(),
+ m_UpdateFunc(),
+ m_GetStringFunc(),
+ m_ExecuteBangFunc()
{
m_MaxValue = 0.0;
}
@@ -53,7 +54,19 @@ CMeasurePlugin::~CMeasurePlugin()
{
if (m_Plugin)
{
- if (FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
+ FARPROC finalizeFunc = GetProcAddress(m_Plugin, "Finalize");
+ if (finalizeFunc)
+ {
+ if (IsNewApi())
+ {
+ ((NEWFINALIZE)finalizeFunc)(m_PluginData);
+ }
+ else
+ {
+ ((FINALIZE)finalizeFunc)(m_Plugin, m_ID);
+ }
+ }
+
FreeLibrary(m_Plugin);
}
}
@@ -68,19 +81,27 @@ bool CMeasurePlugin::Update()
{
if (!CMeasure::PreUpdate()) return false;
- if (UpdateFunc)
- {
- // Update the plugin
- m_Value = UpdateFunc(m_ID);
- }
- else if (UpdateFunc2)
+ if (m_UpdateFunc)
{
- // Update the plugin
- m_Value = UpdateFunc2(m_ID);
- }
+ if (IsNewApi())
+ {
+ m_Value = ((NEWUPDATE)m_UpdateFunc)(m_PluginData);
+ }
+ else
+ {
+ if (m_Update2)
+ {
+ m_Value = ((UPDATE2)m_UpdateFunc)(m_ID);
+ }
+ else
+ {
+ m_Value = ((UPDATE)m_UpdateFunc)(m_ID);
+ }
+ }
- // Reset to default
- CSystem::ResetWorkingDirectory();
+ // Reset to default
+ CSystem::ResetWorkingDirectory();
+ }
return PostUpdate();
}
@@ -93,110 +114,111 @@ bool CMeasurePlugin::Update()
*/
void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
- static UINT id = 1;
+ static UINT id = 0;
CMeasure::ReadConfig(parser, section);
if (m_Initialized)
{
- // DynamicVariables doesn't work with plugins, so stop here.
+ if (IsNewApi())
+ {
+ ((NEWRELOAD)m_ReloadFunc)(m_PluginData, this, &m_MaxValue);
+ }
+
+ // DynamicVariables doesn't work with old plugins
return;
}
- m_PluginName = parser.ReadString(section, L"Plugin", L"");
+ std::wstring pluginName = parser.ReadString(section, L"Plugin", L"");
- size_t pos = m_PluginName.rfind(L'.');
+ size_t pos = pluginName.rfind(L'.');
if (pos == std::wstring::npos)
{
- m_PluginName += L".dll";
+ pluginName += L".dll";
}
- pos = m_PluginName.rfind(L'\\');
+ pos = pluginName.rfind(L'\\');
if (pos != std::wstring::npos)
{
- m_PluginName.insert(0, L"..\\");
+ pluginName.insert(0, L"..\\");
}
- m_PluginName.insert(0, Rainmeter->GetPluginPath());
-
- DWORD err = 0;
- m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err);
+ pluginName.insert(0, Rainmeter->GetPluginPath());
+ m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str(), NULL);
if (m_Plugin == NULL)
{
- if (Rainmeter->GetDebug())
- {
- LogWithArgs(LOG_ERROR, L"Plugin: Unable to load \"%s\" (%u)", m_PluginName.c_str(), err);
- }
-
// Try to load from Rainmeter's folder
- pos = m_PluginName.rfind(L'\\');
+ pos = pluginName.rfind(L'\\');
if (pos != std::wstring::npos)
{
- std::wstring pluginName = Rainmeter->GetPath();
- pluginName.append(m_PluginName, pos + 1, m_PluginName.length() - (pos + 1));
-
- err = 0;
- m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str(), &err);
+ std::wstring pluginName2 = Rainmeter->GetPath();
+ pluginName2.append(pluginName, pos + 1, pluginName.length() - (pos + 1));
- if (m_Plugin == NULL)
- {
- if (Rainmeter->GetDebug())
- {
- LogWithArgs(LOG_ERROR, L"Plugin: Unable to load \"%s\" (%u)", pluginName.c_str(), err);
- }
- }
+ m_Plugin = CSystem::RmLoadLibrary(pluginName2.c_str(), NULL);
}
if (m_Plugin == NULL)
{
- std::wstring error = L"Plugin: \"" + m_PluginName;
+ std::wstring error = L"Plugin: \"" + pluginName;
error += L"\" not found";
throw CError(error);
}
}
- InitializeFunc = (INITIALIZE)GetProcAddress(m_Plugin, "Initialize");
- FinalizeFunc = (FINALIZE)GetProcAddress(m_Plugin, "Finalize");
- UpdateFunc = (UPDATE)GetProcAddress(m_Plugin, "Update");
- UpdateFunc2 = (UPDATE2)GetProcAddress(m_Plugin, "Update2");
- GetStringFunc = (GETSTRING)GetProcAddress(m_Plugin, "GetString");
- ExecuteBangFunc = (EXECUTEBANG)GetProcAddress(m_Plugin, "ExecuteBang");
+ FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize");
+ m_ReloadFunc = GetProcAddress(m_Plugin, "Reload");
+ m_UpdateFunc = GetProcAddress(m_Plugin, "Update");
+ m_GetStringFunc = GetProcAddress(m_Plugin, "GetString");
+ m_ExecuteBangFunc = GetProcAddress(m_Plugin, "ExecuteBang");
- if (UpdateFunc == NULL && UpdateFunc2 == NULL && GetStringFunc == NULL)
+ // Remove current directory from DLL search path
+ SetDllDirectory(L"");
+
+ if (IsNewApi())
{
- FreeLibrary(m_Plugin);
+ m_PluginData = (void*)id;
- std::wstring error = L"Plugin: \"" + m_PluginName;
- error += L"\" doesn't export Update() or GetString()";
- throw CError(error);
- }
+ if (initializeFunc)
+ {
+ ((NEWINITIALIZE)initializeFunc)(&m_PluginData);
+ }
- // Initialize the plugin
- m_ID = id++;
- if (InitializeFunc)
+ ((NEWRELOAD)m_ReloadFunc)(m_PluginData, this, &m_MaxValue);
+ }
+ else
{
- // Remove current directory from DLL search path
- SetDllDirectory(L"");
+ m_ID = id;
- double maxValue;
- maxValue = InitializeFunc(m_Plugin, parser.GetFilename().c_str(), section, m_ID);
+ if (!m_UpdateFunc)
+ {
+ m_UpdateFunc = GetProcAddress(m_Plugin, "Update2");
+ m_Update2 = true;
+ }
- // Reset to default
- SetDllDirectory(L"");
- CSystem::ResetWorkingDirectory();
+ double maxValue = 0;
+ if (initializeFunc)
+ {
+ maxValue = ((INITIALIZE)initializeFunc)(m_Plugin, parser.GetFilename().c_str(), section, m_ID);
+ }
const std::wstring& szMaxValue = parser.ReadString(section, L"MaxValue", L"");
if (szMaxValue.empty())
{
m_MaxValue = maxValue;
}
- }
- if (m_MaxValue == 0)
- {
- m_MaxValue = 1;
- m_LogMaxValue = true;
+ if (m_MaxValue == 0)
+ {
+ m_MaxValue = 1;
+ m_LogMaxValue = true;
+ }
}
+
+ // Reset to default
+ SetDllDirectory(L"");
+ CSystem::ResetWorkingDirectory();
+
+ ++id;
}
/*
@@ -207,9 +229,18 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
*/
const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
{
- if (GetStringFunc)
+ if (m_GetStringFunc)
{
- const WCHAR* ret = GetStringFunc(m_ID, 0);
+ const WCHAR* ret;
+ if (IsNewApi())
+ {
+ ret = ((NEWGETSTRING)m_GetStringFunc)(m_PluginData);
+ }
+ else
+ {
+ ret = ((GETSTRING)m_GetStringFunc)(m_ID, 0);
+ }
+
if (ret) return CheckSubstitute(ret);
}
@@ -224,12 +255,19 @@ const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, i
*/
void CMeasurePlugin::ExecuteBang(const WCHAR* args)
{
- if (ExecuteBangFunc)
+ if (m_ExecuteBangFunc)
{
- ExecuteBangFunc(args, m_ID);
+ if (IsNewApi())
+ {
+ ((NEWEXECUTEBANG)m_ExecuteBangFunc)(m_PluginData, args);
+ }
+ else
+ {
+ ((EXECUTEBANG)m_ExecuteBangFunc)(args, m_ID);
+ }
}
else
{
CMeasure::ExecuteBang(args);
}
-}
+}
View
47 Library/MeasurePlugin.h
@@ -20,14 +20,22 @@
#define __MEASUREPLUGIN_H__
#include "Measure.h"
+#include "Export.h"
-typedef UINT (*INITIALIZE)(HMODULE, LPCTSTR, LPCTSTR, UINT);
+typedef UINT (*INITIALIZE)(HMODULE, LPCTSTR, LPCTSTR, UINT);
typedef VOID (*FINALIZE)(HMODULE, UINT);
-typedef UINT (*UPDATE)(UINT);
-typedef double (*UPDATE2)(UINT);
-typedef LPCTSTR (*GETSTRING)(UINT, UINT);
+typedef UINT (*UPDATE)(UINT);
+typedef double (*UPDATE2)(UINT);
+typedef LPCTSTR (*GETSTRING)(UINT, UINT);
typedef void (*EXECUTEBANG)(LPCTSTR, UINT);
+typedef void (*NEWINITIALIZE)(void*);
+typedef void (*NEWRELOAD)(void*, void*, double*);
+typedef void (*NEWFINALIZE)(void*);
+typedef double (*NEWUPDATE)(void*);
+typedef LPCWSTR (*NEWGETSTRING)(void*);
+typedef void (*NEWEXECUTEBANG)(void*, const WCHAR*);
+
class CMeasurePlugin : public CMeasure
{
public:
@@ -42,16 +50,29 @@ class CMeasurePlugin : public CMeasure
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
private:
- std::wstring m_PluginName;
+ bool IsNewApi() { return m_ReloadFunc != NULL; }
+
HMODULE m_Plugin;
- UINT m_ID;
-
- INITIALIZE InitializeFunc;
- FINALIZE FinalizeFunc;
- UPDATE UpdateFunc;
- UPDATE2 UpdateFunc2;
- GETSTRING GetStringFunc;
- EXECUTEBANG ExecuteBangFunc;
+
+ void* m_ReloadFunc;
+
+ union
+ {
+ struct
+ {
+ UINT m_ID;
+ bool m_Update2;
+ };
+
+ struct
+ {
+ void* m_PluginData;
+ };
+ };
+
+ void* m_UpdateFunc;
+ void* m_GetStringFunc;
+ void* m_ExecuteBangFunc;
};
#endif
View
2 Library/MeterWindow.cpp
@@ -2110,8 +2110,6 @@ bool CMeterWindow::ReadSkin()
MessageBox(m_Window, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
- m_Author = m_Parser.ReadString(L"Rainmeter", L"Author", L"");
-
static const RECT defMargins = {0};
m_BackgroundMargins = m_Parser.ReadRECT(L"Rainmeter", L"BackgroundMargins", defMargins);
m_DragMargins = m_Parser.ReadRECT(L"Rainmeter", L"DragMargins", defMargins);
View
2 Library/MeterWindow.h
@@ -200,7 +200,6 @@ class CMeterWindow : public CGroup
CConfigParser& GetParser() { return m_Parser; }
- const std::wstring& GetSkinAuthor() { return m_Author; }
const std::wstring& GetSkinName() { return m_SkinName; }
const std::wstring& GetSkinIniFile() { return m_SkinIniFile; }
std::wstring GetSkinRootPath();
@@ -375,7 +374,6 @@ class CMeterWindow : public CGroup
bool m_MouseOver;
- std::wstring m_Author; // Skin's author
std::wstring m_ConfigGroup;
std::wstring m_BackgroundName; // Name of the background image
RECT m_BackgroundMargins;
View
91 Library/RawString.h
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2011 Birunthan Mohanathas
+
+ 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 __RAWSTRING_H__
+#define __RAWSTRING_H__
+
+#include <windows.h>
+
+class CRawString
+{
+public:
+ CRawString() :
+ m_String()
+ {
+ }
+
+ CRawString(const WCHAR* str) :
+ m_String(str_alloc(str))
+ {
+ }
+
+ ~CRawString()
+ {
+ clear();
+ }
+
+ CRawString& operator=(const WCHAR* rhs)
+ {
+ clear();
+ m_String = str_alloc(rhs);
+ return *this;
+ }
+
+ CRawString& operator=(const CRawString& rhs)
+ {
+ if (&rhs != this)
+ {
+ clear();
+ m_String = str_alloc(rhs.m_String);
+ }
+ return *this;
+ }
+
+ const WCHAR* c_str() const
+ {
+ return m_String ? m_String : L"";
+ }
+
+ bool empty() const
+ {
+ return !m_String || !(*m_String);
+ }
+
+ void clear()
+ {
+ if (m_String)
+ {
+ free(m_String);
+ m_String = NULL;
+ }
+ }
+
+private:
+ CRawString(const CRawString& p)
+ {
+ }
+
+ WCHAR* str_alloc(const WCHAR* str)
+ {
+ return str ? _wcsdup(str) : NULL;
+ }
+
+ WCHAR* m_String;
+};
+
+#endif
View
7 Plugins/API/DllExporter/AssemblyInfo.cs
@@ -0,0 +1,7 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyCopyright("© 2011 - Birunthan Mohanathas")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyProduct("Rainmeter")]
View
101 Plugins/API/DllExporter/DllExporter.csproj
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{49D56CA5-54AB-45C9-A245-EAE588FCBFE1}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DllExporter</RootNamespace>
+ <AssemblyName>DllExporter</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>1607</NoWarn>
+ <StartAction>Program</StartAction>
+ <StartProgram>TestBench\x32\Debug\Rainmeter.exe</StartProgram>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>1607</NoWarn>
+ <StartAction>Program</StartAction>
+ <StartProgram>TestBench\x32\Release\Rainmeter.exe</StartProgram>
+ </PropertyGroup>
+ <PropertyGroup>
+ <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <NoWarn>1607</NoWarn>
+ <StartAction>Program</StartAction>
+ <StartProgram>TestBench\x64\Debug\Rainmeter.exe</StartProgram>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>none</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <NoWarn>1607</NoWarn>
+ <StartAction>Program</StartAction>
+ <StartProgram>TestBench\x64\Release\Rainmeter.exe</StartProgram>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>move "$(TargetPath)" "$(SolutionDir)Plugins\API\DllExporter.exe"</PostBuildEvent>
+ </PropertyGroup>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
155 Plugins/API/DllExporter/Program.cs
@@ -0,0 +1,155 @@
+/*
+ Copyright (C) 2011 Birunthan Mohanathas
+
+ 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.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace DllExporter
+{
+ class Program
+ {
+ static int Main(string[] args)
+ {
+ string configurationName = args[0];
+ string platformTarget = args[1];
+ string targetDirectory = args[2];
+ string targetDllName = targetDirectory + args[3];
+ string targetIlName = targetDllName + ".il";
+ string targetResName = targetDllName + ".res";
+ string ilasmPath = args[4];
+ string ildasmPath = args[5];
+
+ System.IO.Directory.SetCurrentDirectory(targetDirectory);
+
+ bool is64 = platformTarget.ToLower().Equals("x64");
+ bool isDebug = configurationName.ToLower().Equals("debug");
+
+ // Disassemble
+ Process ildasmProc = new Process();
+ string ildasmArgs = string.Format("/nobar /output={0} {1}", targetIlName, targetDllName);
+ ildasmProc.StartInfo = new ProcessStartInfo(ildasmPath, ildasmArgs);
+ ildasmProc.StartInfo.UseShellExecute = false;
+ ildasmProc.StartInfo.CreateNoWindow = false;
+ ildasmProc.StartInfo.RedirectStandardOutput = true;
+ ildasmProc.Start();
+ ildasmProc.WaitForExit();
+
+ if (ildasmProc.ExitCode != 0)
+ {
+ Console.WriteLine("DllExporter error: Unable to disassemble!");
+ Console.WriteLine(ildasmProc.StandardOutput.ReadToEnd());
+ return ildasmProc.ExitCode;
+ }
+
+ bool hasResource = System.IO.File.Exists(targetResName);
+
+ // Read disassembly and find methods marked with DllExport attribute
+ List<string> lines = new List<string>(System.IO.File.ReadAllLines(targetIlName));
+ int attributeIndex = 0;
+ int exportCount = 0;
+ while (true)
+ {
+ attributeIndex = lines.FindIndex(attributeIndex, new Predicate<string>(x => x.Contains(".custom instance void") && x.Contains("DllExport::.ctor()")));
+ if (attributeIndex < 8) break;
+
+ int methodIndex = lines.FindLastIndex(attributeIndex, attributeIndex, new Predicate<string>(x => x.Contains(".method")));
+ if (methodIndex == -1)
+ {
+ Console.WriteLine("DllExporter error: Unable to parse disassembly (.method not found)!");
+ return 1;
+ }
+
+ int functionIndex = lines.FindIndex(methodIndex, new Predicate<string>(x => x.Contains("(")));
+ if (functionIndex == -1)
+ {
+ Console.WriteLine("DllExporter error: Unable to parse disassembly (bracket not found)!");
+ return 1;
+ }
+
+ int bracketPos = lines[functionIndex].IndexOf('(');
+ int functionNamePos = lines[functionIndex].LastIndexOf(' ', bracketPos);
+ string functionName = lines[functionIndex].Substring(functionNamePos, bracketPos - functionNamePos);
+
+ // Change calling convention to cdecl
+ lines[functionIndex] = string.Format("{0} modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) {1}", lines[functionIndex].Substring(0, functionNamePos - 1), lines[functionIndex].Substring(functionNamePos));
+
+ int attributeBeginPos = lines[attributeIndex].IndexOf('.');
+ string spaces = new string(' ', attributeBeginPos);
+
+ // Replace attribute with export
+ ++exportCount;
+ lines[attributeIndex] = string.Format("{0}.export [{1}] as {2}", spaces, exportCount, functionName);
+
+ ++attributeIndex;
+ }
+
+ if (exportCount == 0)
+ {
+ Console.WriteLine("DllExporter warning: Nothing found to export.");
+ }
+
+ // Remove the DllExport class
+ int classIndex = lines.FindIndex(new Predicate<string>(x => x.Contains(".class ") && x.EndsWith(".DllExport")));
+ if (classIndex == -1)
+ {
+ Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class not found)!");
+ return 1;
+ }
+ else
+ {
+ int classEndIndex = lines.FindIndex(classIndex, new Predicate<string>(x => x.Contains("} // end of class") && x.EndsWith(".DllExport")));
+ if (classEndIndex == -1)
+ {
+ Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class end not found)!");
+ return 1;
+ }
+
+ lines.RemoveRange(classIndex, classEndIndex - classIndex + 2);
+ }
+
+ // Write everything back
+ System.IO.File.WriteAllLines(targetIlName, lines.ToArray());
+
+ // Reassemble
+ Process ilasmProc = new Process();
+ string resource = hasResource ? string.Format("/resource={0} ", targetResName) : "";
+ string ilasmArgs = string.Format("/nologo /quiet /dll {0} {1} /output={2} {3}{4}", isDebug ? "/debug /pdb" : "/optimize", is64 ? "/x64 /PE64" : "", targetDllName, resource, targetIlName);
+ ilasmProc.StartInfo = new ProcessStartInfo(ilasmPath, ilasmArgs);
+ ilasmProc.StartInfo.UseShellExecute = false;
+ ilasmProc.StartInfo.CreateNoWindow = false;
+ ilasmProc.StartInfo.RedirectStandardOutput = true;
+ ilasmProc.Start();
+ ilasmProc.WaitForExit();
+
+ if (ilasmProc.ExitCode != 0)
+ {
+ Console.WriteLine("DllExporter error: Unable to assemble!");
+ Console.WriteLine(ilasmProc.StandardOutput.ReadToEnd());
+ return ilasmProc.ExitCode;
+ }
+
+ // Cleanup
+ System.IO.File.Delete(targetIlName);
+ System.IO.File.Delete(targetResName);
+
+ return 0;
+ }
+ }
+}
View
130 Plugins/API/Rainmeter.cs
@@ -0,0 +1,130 @@
+/*
+ Copyright (C) 2011 Birunthan Mohanathas
+
+ 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.
+*/
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Rainmeter
+{
+ /// <summary>
+ /// Wrapper around the Rainmeter C API.
+ /// </summary>
+ public class API
+ {
+ private IntPtr m_Rm;
+
+ public API(IntPtr rm)
+ {
+ m_Rm = rm;
+ }
+
+ public static unsafe char* ToUnsafe(string s)
+ {
+ fixed (char* p = s) return p;
+ }
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)]
+ private extern static unsafe char* RmReadString(void* rm, char* option, char* defValue, int replaceMeasures);
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)]
+ private extern static unsafe double RmReadFormula(void* rm, char* option, double defValue);
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)]
+ private extern static unsafe char* RmPathToAbsolute(void* rm, char* relativePath);
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)]
+ private extern static unsafe void RmExecute(void* rm, char* command);
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)]
+ private extern static unsafe void* RmGet(void* rm, int type);
+
+ [DllImport("Rainmeter.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
+ private extern static unsafe int LSLog(int type, char* unused, char* message);
+
+ private enum RmGetType
+ {
+ MeasureName = 0,
+ Skin = 1,
+ SettingsFile = 2
+ }
+
+ public enum LogType
+ {
+ Error = 1,
+ Warning = 2,
+ Notice = 3,
+ Debug = 4
+ }
+
+ public unsafe string ReadString(string option, string defValue)
+ {
+ char* value = RmReadString((void*)m_Rm, ToUnsafe(option), ToUnsafe(defValue), 1);
+ return new string(value);
+ }
+
+ public unsafe string ReadPath(string option, string defValue)
+ {
+ char* relativePath = RmReadString((void*)m_Rm, ToUnsafe(option), ToUnsafe(defValue), 1);
+ char* value = RmPathToAbsolute((void*)m_Rm, relativePath);
+ return new string(value);
+ }
+
+ public unsafe double ReadFormula(string option, double defValue)
+ {
+ return RmReadFormula((void*)m_Rm, ToUnsafe(option), defValue);
+ }
+
+ public unsafe int ReadInt(string option, int defValue)
+ {
+ string value = ReadString(option, "");
+ return Convert.ToInt32(value);
+ }
+
+ public unsafe string GetMeasureName()
+ {
+ char* value = (char*)RmGet((void*)m_Rm, (int)RmGetType.MeasureName);
+ return new string(value);
+ }
+
+ public unsafe IntPtr GetSkin()
+ {
+ return (IntPtr)RmGet((void*)m_Rm, (int)RmGetType.Skin);
+ }
+
+ public static unsafe void Execute(IntPtr skin, string command)
+ {
+ RmExecute((void*)skin, ToUnsafe(command));
+ }
+
+ public static unsafe void Log(LogType type, string message)
+ {
+ LSLog((int)type, null, ToUnsafe(message));
+ }
+ }
+
+ /// <summary>
+ /// Dummy attribute to mark method as exported for DllExporter.exe.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Method)]
+ public class DllExport : Attribute
+ {
+ public DllExport()
+ {
+ }
+ }
+}
View
4 Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcxproj
@@ -73,10 +73,10 @@
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x32\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)TestBench\x64\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AdvancedCPU</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedCPU</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedCPU</TargetName>
View
142 Plugins/PluginCoreTemp/PluginCoreTemp.cpp
@@ -17,25 +17,11 @@
*/
#include <windows.h>
-#include <tchar.h>
-#include <map>
-
+#include <wchar.h>
#include "CoreTempProxy.h"
-
#include "../../Library/Export.h" // Rainmeter's exported functions
-
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
-extern "C"
-{
- __declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
- __declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
- __declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
- __declspec( dllexport ) double Update2(UINT id);
- __declspec( dllexport ) UINT GetPluginVersion();
- __declspec( dllexport ) LPCTSTR GetPluginAuthor();
-}
-
typedef enum eMeasureType
{
MeasureTemperature,
@@ -49,85 +35,62 @@ typedef enum eMeasureType
MeasureCpuName
};
-std::map<UINT, eMeasureType> g_Types;
-std::map<UINT, int> g_Indexes;
+struct MeasureData
+{
+ eMeasureType type;
+ int index;
+
+ MeasureData() : type(), index() {}
+};
+
CoreTempProxy proxy;
eMeasureType convertStringToMeasureType(LPCWSTR i_String);
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2);
float getHighestTemp();
-/*
- This function is called when the measure is initialized.
- The function must return the maximum value that can be measured.
- The return value can also be 0, which means that Rainmeter will
- track the maximum value automatically. The parameters for this
- function are:
-
- instance The instance of this DLL
- iniFile The name of the ini-file (usually Rainmeter.ini)
- section The name of the section in the ini-file for this measure
- id The identifier for the measure. This is used to identify the measures that use the same plugin.
-*/
-UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
+PLUGIN_EXPORT void Initialize(void** data)
{
- /*
- Read our own settings from the ini-file
- The ReadConfigString can be used for this purpose. Plugins
- can also read the config some other way (e.g. with
- GetPrivateProfileInt, but in that case the variables
- do not work.
- */
- LPCTSTR data = ReadConfigString(section, L"CoreTempType", L"Temperature");
- if (data)
- {
- eMeasureType type = convertStringToMeasureType(data);
+ MeasureData* measure = new MeasureData;
+ *data = measure;
+}
- g_Types[id] = type;
- if (type == MeasureTemperature || type == MeasureTjMax || type == MeasureLoad)
- {
- data = ReadConfigString(section, L"CoreTempIndex", L"0");
- if (data)
- {
- g_Indexes[id] = _wtoi(data);
- }
- else
- {
- g_Indexes[id] = 0;
- LSLog(LOG_WARNING, NULL, L"CoreTemp.dll: Selected CoreTempType requires CoreTempIndex, assuming 0");
- }
- }
- }
+PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
+{
+ MeasureData* measure = (MeasureData*)data;
+
+ LPCWSTR value = RmReadString(rm, L"CoreTempType", L"Temperature");
+ eMeasureType type = convertStringToMeasureType(value);
- return 0;
+ if (type == MeasureTemperature || type == MeasureTjMax || type == MeasureLoad)
+ {
+ measure->index = RmReadInt(rm, L"CoreTempIndex", 0);
+ }
}
-/*
- This function is called when new value should be measured.
- The function returns the new value.
-*/
-double Update2(UINT id)
+PLUGIN_EXPORT double Update(void* data)
{
+ MeasureData* measure = (MeasureData*)data;
double result = 0;
if (proxy.GetData())
{
- switch (g_Types[id])
+ switch (measure->type)
{
case MeasureTemperature:
- result = proxy.GetTemp(g_Indexes[id]);
+ result = proxy.GetTemp(measure->index);
break;
case MeasureMaxTemperature:
result = getHighestTemp();
break;
case MeasureTjMax:
- result = proxy.GetTjMax(g_Indexes[id]);
+ result = proxy.GetTjMax(measure->index);
break;
case MeasureLoad:
- result = proxy.GetCoreLoad(g_Indexes[id]);
+ result = proxy.GetCoreLoad(measure->index);
break;
case MeasureVid:
@@ -151,11 +114,12 @@ double Update2(UINT id)
return result;
}
-LPCTSTR GetString(UINT id, UINT flags)
+PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
- static WCHAR buffer[256];
+ MeasureData* measure = (MeasureData*)data;
+ static WCHAR buffer[128];
- switch (g_Types[id])
+ switch (measure->type)
{
case MeasureVid:
_snwprintf_s(buffer, _TRUNCATE, L"%.4f", proxy.GetVID());
@@ -172,44 +136,6 @@ LPCTSTR GetString(UINT id, UINT flags)
return buffer;
}
-/*
- If the measure needs to free resources before quitting.
- The plugin can export Finalize function, which is called
- when Rainmeter quits (or refreshes).
-*/
-void Finalize(HMODULE instance, UINT id)
-{
- std::map<UINT, eMeasureType>::iterator i1 = g_Types.find(id);
- if (i1 != g_Types.end())
- {
- g_Types.erase(i1);
- }
-
- std::map<UINT, int>::iterator i2 = g_Indexes.find(id);
- if (i2 != g_Indexes.end())
- {
- g_Indexes.erase(i2);
- }
-}
-
-/*
- Returns the version number of the plugin. The value
- can be calculated like this: Major * 1000 + Minor.
- So, e.g. 2.31 would be 2031.
-*/
-UINT GetPluginVersion()
-{
- return 1000;
-}
-
-/*
- Returns the author of the plugin for the about dialog.
-*/
-LPCTSTR GetPluginAuthor()
-{
- return L"Arthur Liberman - ALCPU (arthur_liberman@hotmail.com)";
-}
-
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2)
{
return _wcsicmp(i_String1, i_Strting2) == 0;
@@ -258,7 +184,7 @@ eMeasureType convertStringToMeasureType(LPCWSTR i_String)
else
{
result = MeasureTemperature;
- LSLog(LOG_WARNING, NULL, L"CoreTemp.dll: Invalid CoreTempType");
+ RmLog(LOG_WARNING, L"CoreTemp.dll: Invalid CoreTempType");
}
return result;
View
13 Plugins/PluginCoreTemp/PluginCoreTemp.rc
@@ -1,10 +1,5 @@
-// Microsoft Developer Studio generated resource script.
-//
-
+#include <windows.h>
#include "../../Version.h"
-#define APSTUDIO_READONLY_SYMBOLS
-#include "windows.h"
-#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
@@ -18,7 +13,7 @@ VS_VERSION_INFO VERSIONINFO
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
- FILEFLAGS 0x0L
+ FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
@@ -28,10 +23,8 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
- VALUE "FileDescription", "CoreTemp Plugin for Rainmeter"
VALUE "FileVersion", "1.0.0.0"
- VALUE "InternalName", "PluginCoreTemp"
- VALUE "LegalCopyright", "Copyright (C) 2011 - Arthur Liberman"
+ VALUE "LegalCopyright", "� 2011 - Arthur Liberman"
VALUE "OriginalFilename", "CoreTemp.dll"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
View
4 Plugins/PluginCoreTemp/PluginCoreTemp.vcxproj
@@ -68,10 +68,10 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x32\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)TestBench\x64\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x32\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
View
4 Plugins/PluginExample/PluginExample.vcxproj
@@ -73,10 +73,10 @@
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)TestBench\x32\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x32\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)TestBench\x64\$(Configuration)\Plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ExamplePlugin</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ExamplePlugin</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ExamplePlugin</TargetName>
View
7 Plugins/PluginExampleCS/AssemblyInfo.cs
@@ -0,0 +1,7 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyCopyright("© 2011 - Birunthan Mohanathas")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyInformationalVersion(Rainmeter.Version.Informational)]
+[assembly: AssemblyProduct("Rainmeter")]
View
154 Plugins/PluginExampleCS/Plugin.cs
@@ -0,0 +1,154 @@
+/*
+ Copyright (C) 2011 Birunthan Mohanathas
+
+ 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.
+*/
+
+// Define/undefine to control exports. Undefine to infrom that this plugin does not support
+// a particular function.
+#define ExportUpdate
+#undef ExportGetString
+#undef ExportExecuteBang
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Rainmeter;
+
+namespace ExampleCS
+{
+ /// <summary>
+ /// Represents a measure. Members are specific to a measure. Methods are called by Rainmeter
+ /// when needed.
+ /// </summary>
+ internal class Measure
+ {
+ /// <summary>
+ /// Called when a measure is created.
+ /// </summary>
+ internal Measure()
+ {
+ }
+
+ /// <summary>
+ /// Called when a measure is destroyed. Use this rather than a destructor to perform
+ /// cleanup.
+ /// </summary>
+ internal void Cleanup()
+ {
+ }
+
+ /// <summary>
+ /// Called when the measure settings must be (re)read.
+ /// </summary>
+ internal void Reload(Rainmeter.API rm)
+ {
+ // Examples:
+ // string value = rm.ReadString("TestOption", "DefaultValue");
+ // double value = rm.ReadFormula("TestOption", 20);
+ }
+
+ /// <summary>
+ /// Called when the measure settings must be (re)read.
+ /// </summary>
+#if ExportUpdate
+ internal double Update()
+ {
+ return 42.0;
+ }
+#endif
+
+ /// <summary>
+ /// Called when the string representation of the measure value is required.
+ /// </summary>
+ /// <remarks>
+ /// Can be called multiple times per update cycle. Do not call heavy functions here.
+ /// Instead create a string member, set it in Update, and simply return it here.
+ /// </remarks>
+#if ExportGetString
+ internal string GetString()
+ {
+ return "Hello, world!";
+ }
+#endif
+
+ /// <summary>
+ /// Called when as a result of a !CommandMeasure bang aimed at the measure.
+ /// </summary>
+#if ExportExecuteBang
+ internal void ExecuteBang(string args)
+ {
+ }
+#endif
+ }
+
+ /// <summary>
+ /// Handles communication between Rainmeter and the plugin.
+ /// </summary>
+ public static class Plugin
+ {
+ [DllExport]
+ public unsafe static void Initialize(void** data)
+ {
+ IntPtr dataPtr = (IntPtr)((void*)*data);
+ Measures.Add(dataPtr, new Measure());
+ }
+
+ [DllExport]
+ public unsafe static void Finalize(void* data)
+ {
+ IntPtr dataPtr = (IntPtr)data;
+ Measures[dataPtr].Cleanup();
+ Measures.Remove(dataPtr);
+ }
+
+ [DllExport]
+ public unsafe static void Reload(void* data, void* rm, double* maxValue)
+ {
+ IntPtr dataPtr = (IntPtr)data;
+ Measures[dataPtr].Reload(new Rainmeter.API((IntPtr)rm));
+ }
+
+#if ExportUpdate
+ [DllExport]
+ public unsafe static double Update(void* data)
+ {
+ IntPtr dataPtr = (IntPtr)data;
+ return Measures[dataPtr].Update();
+ }
+#endif
+
+#if ExportGetString
+ [DllExport]
+ public unsafe static char* GetString(void* data)
+ {
+ IntPtr dataPtr = (IntPtr)data;
+ return Rainmeter.API.ToUnsafe(Measures[dataPtr].GetString());
+ }
+#endif
+
+#if ExportExecuteBang
+ [DllExport]
+ public unsafe static void ExecuteBang(void* data, char* args)
+ {
+ IntPtr dataPtr = (IntPtr)data;
+ Measures[dataPtr].ExecuteBang(new string(args));
+ Measures.Remove(dataPtr);
+ }
+#endif
+
+ internal static Dictionary<IntPtr, Measure> Measures = new Dictionary<IntPtr, Measure>();
+ }
+}
View
100 Plugins/PluginExampleCS/PluginExampleCS.csproj
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D31F73ED-3978-44FA-B599-49584BA30D3A}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ExampleCS</RootNamespace>
+ <AssemblyName>ExampleCS</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation />
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>$(SolutionDir)TestBench\x32\Debug\Plugins\</OutputPath>
+ <DefineConstants>TRACE;DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <NoWarn>1607</NoWarn>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>$(SolutionDir)TestBench\x32\Release\Plugins\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <NoWarn>1607</NoWarn>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>$(SolutionDir)TestBench\x64\Debug\Plugins\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;X64</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <NoWarn>1607</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=