From 7b3b0277ecc9ea482c01acc1f3e66614329a0a57 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 30 Dec 2011 16:16:22 +0000 Subject: [PATCH] Added new plugin API. --- Library/Export.cpp | 241 ++++++++++++++++++++++++++++++++ Library/Export.h | 110 ++++++++++++--- Library/Library.vcxproj | 13 +- Library/Library.vcxproj.filters | 9 +- Library/Litestep.h | 11 +- Library/MeasurePlugin.cpp | 153 +++++++++++--------- Library/MeasurePlugin.h | 43 ++++-- Library/MeterWindow.cpp | 2 - Library/MeterWindow.h | 2 - Library/RawString.h | 77 ++++++++++ 10 files changed, 555 insertions(+), 106 deletions(-) create mode 100644 Library/Export.cpp create mode 100644 Library/RawString.h diff --git a/Library/Export.cpp b/Library/Export.cpp new file mode 100644 index 00000000..3a627ff8 --- /dev/null +++ b/Library/Export.cpp @@ -0,0 +1,241 @@ +/* + 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" + +extern CRainmeter* Rainmeter; + +static std::wstring g_Buffer; + +BOOL LSLog(int nLevel, LPCWSTR unused, LPCWSTR pszMessage) +{ + // Ignore LOG_DEBUG messages from plugins unless in debug mode + if (nLevel != LOG_DEBUG || Rainmeter->GetDebug()) + { + Log(nLevel, pszMessage); + } + + return TRUE; +} + +LPCWSTR RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures) +{ + 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) +{ + CMeasurePlugin* measure = (CMeasurePlugin*)rm; + CConfigParser& parser = measure->GetMeterWindow()->GetParser(); + return parser.ReadFormula(measure->GetName(), option, defValue); +} + +LPCWSTR RmPathToAbsolute(void* rm, LPCWSTR 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); +} + +// Deprecated! +LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue) +{ + // NULL checking + if (section == NULL) section = L""; + if (option == NULL) option = L""; + if (defValue == NULL) defValue = L""; + + 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 (Rainmeter) + { + if (_sCommand == NULL || *_sCommand == L'\0') + { + return L"noop"; + } + + if (_sData == NULL) _sData = L""; + + 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 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 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 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"; + } + + return L"error:no rainmeter!"; +} diff --git a/Library/Export.h b/Library/Export.h index ed6125b6..8d1205d8 100644 --- a/Library/Export.h +++ b/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,102 @@ #define __EXPORT_H__ #ifdef LIBRARY_EXPORTS -#define EXPORT_PLUGIN __declspec(dllexport) +#define DECLSPEC_LIBRARY __declspec(dllexport) #else -#define EXPORT_PLUGIN __declspec(dllimport) -#endif - -// log level constants -#define LOG_ERROR 1 -#define LOG_WARNING 2 -#define LOG_NOTICE 3 -#define LOG_DEBUG 4 +#define DECLSPEC_LIBRARY __declspec(dllimport) +#endif // LIBRARY_EXPORTS #ifdef __cplusplus -extern "C" +#define LIBRARY_EXPORT extern "C" DECLSPEC_LIBRARY +#define PLUGIN_EXPORT extern "C" __declspec(dllexport) +#else +#define LIBRARY_EXPORT DECLSPEC_LIBRARY +#define PLUGIN_EXPORT __declspec(dllexport) +#endif // __cplusplus + +// +// Exported functions +// + +#ifdef __cplusplus +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 BOOL LSLog(int level, LPCWSTR unused, LPCWSTR message); + +LIBRARY_EXPORT void* RmGet(void* rm, int type); + +enum RMGTYPE { -#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); +/* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue); -#ifdef __cplusplus +/* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data); + +// +// Wrapper functions +// + +#ifndef LIBRARY_EXPORTS +enum LOGLEVEL +{ + LOG_ERROR = 1, + LOG_WARNING = 2, + LOG_NOTICE = 3, + LOG_DEBUG = 4 +}; + +__inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue) +{ + LPCWSTR relativePath = RmReadString(rm, option, defValue, TRUE); + return RmPathToAbsolute(rm, relativePath); } -#endif -#endif \ No newline at end of file +__inline int RmReadInt(void* rm, LPCWSTR option, int defValue) +{ + LPCWSTR value = RmReadString(rm, option, L"", TRUE); + return (*value) ? _wtoi(value) : defValue; +} + +__inline LPCWSTR RmGetMeasureName(void* rm) +{ + return (LPCWSTR)RmGet(rm, RMG_MEASURENAME); +} + +__inline LPCWSTR RmGetSettingsFile(void* rm) +{ + return (LPCWSTR)RmGet(rm, RMG_SETTINGSFILE); +} + +__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 diff --git a/Library/Library.vcxproj b/Library/Library.vcxproj index 1059f33c..03543208 100644 --- a/Library/Library.vcxproj +++ b/Library/Library.vcxproj @@ -657,6 +657,17 @@ MaxSpeed Use + + Disabled + EnableFastChecks + Use + Disabled + EnableFastChecks + MaxSpeed + Use + MaxSpeed + Use + Create Create @@ -837,7 +848,6 @@ - @@ -873,6 +883,7 @@ + diff --git a/Library/Library.vcxproj.filters b/Library/Library.vcxproj.filters index 7431d3a4..51b05101 100644 --- a/Library/Library.vcxproj.filters +++ b/Library/Library.vcxproj.filters @@ -351,6 +351,9 @@ Source Files + + Source Files + @@ -362,9 +365,6 @@ Header Files - - Header Files - Header Files @@ -593,6 +593,9 @@ Header Files + + Header Files + diff --git a/Library/Litestep.h b/Library/Litestep.h index 051888aa..e2fbceb5 100644 --- a/Library/Litestep.h +++ b/Library/Litestep.h @@ -23,7 +23,14 @@ #include #include #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); diff --git a/Library/MeasurePlugin.cpp b/Library/MeasurePlugin.cpp index d5704208..e53aaa4e 100644 --- a/Library/MeasurePlugin.cpp +++ b/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,11 @@ 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_UpdateFunc(), + m_GetStringFunc(), + m_ExecuteBangFunc() { m_MaxValue = 0.0; } @@ -53,7 +52,16 @@ CMeasurePlugin::~CMeasurePlugin() { if (m_Plugin) { - if (FinalizeFunc) FinalizeFunc(m_Plugin, m_ID); + FARPROC finalizeFunc = GetProcAddress(m_Plugin, "Finalize"); + if (IsNewApi()) + { + ((NEWFINALIZE)finalizeFunc)(m_PluginData); + } + else if (finalizeFunc) + { + ((FINALIZE)finalizeFunc)(m_Plugin, m_ID); + } + FreeLibrary(m_Plugin); } } @@ -68,15 +76,20 @@ bool CMeasurePlugin::Update() { if (!CMeasure::PreUpdate()) return false; - if (UpdateFunc) + if (IsNewApi()) { - // Update the plugin - m_Value = UpdateFunc(m_ID); + m_Value = ((NEWUPDATE)m_UpdateFunc)(m_PluginData); } - else if (UpdateFunc2) + else if (m_UpdateFunc) { - // Update the plugin - m_Value = UpdateFunc2(m_ID); + if (m_Update2) + { + m_Value = ((UPDATE2)m_UpdateFunc)(m_ID); + } + else + { + m_Value = ((UPDATE)m_UpdateFunc)(m_ID); + } } // Reset to default @@ -93,13 +106,17 @@ 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; } @@ -118,16 +135,9 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) } m_PluginName.insert(0, Rainmeter->GetPluginPath()); - DWORD err = 0; - m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err); - + m_Plugin = CSystem::RmLoadLibrary(m_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'\\'); if (pos != std::wstring::npos) @@ -135,16 +145,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) 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); - - 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(pluginName.c_str(), NULL); } if (m_Plugin == NULL) @@ -155,48 +156,50 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) } } - 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); - - std::wstring error = L"Plugin: \"" + m_PluginName; - error += L"\" doesn't export Update() or GetString()"; - throw CError(error); + ((NEWINITIALIZE)initializeFunc)(&m_PluginData); + ((NEWRELOAD)m_ReloadFunc)(m_PluginData, this, &m_MaxValue); } - - // Initialize the plugin - m_ID = id++; - if (InitializeFunc) + 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 = ((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 +210,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 +236,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); } -} \ No newline at end of file +} diff --git a/Library/MeasurePlugin.h b/Library/MeasurePlugin.h index cfddafd9..229b0bb0 100644 --- a/Library/MeasurePlugin.h +++ b/Library/MeasurePlugin.h @@ -21,13 +21,20 @@ #include "Measure.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 +49,30 @@ protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); private: + bool IsNewApi() { return m_ReloadFunc != NULL; } + std::wstring m_PluginName; 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 diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index f655aef8..d3151cab 100644 --- a/Library/MeterWindow.cpp +++ b/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); diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 2fbc1d97..fa02dfa1 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -200,7 +200,6 @@ public: 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 @@ private: 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; diff --git a/Library/RawString.h b/Library/RawString.h new file mode 100644 index 00000000..361e62d8 --- /dev/null +++ b/Library/RawString.h @@ -0,0 +1,77 @@ +/* + 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 + +class CRawString +{ +public: + CRawString() : + m_String() + { + } + + CRawString(const WCHAR* str) : + m_String(_wcsdup(str)) + { + } + + ~CRawString() + { + if (m_String) free(m_String); + } + + CRawString& operator=(const WCHAR* rhs) + { + if (m_String) free(m_String); + m_String = _wcsdup(rhs); + return *this; + } + + CRawString& operator=(const CRawString& rhs) + { + if (&rhs != this) + { + if (m_String) free(m_String); + m_String = _wcsdup(rhs.m_String); + } + return *this; + } + + const WCHAR* c_str() const + { + return m_String; + } + + bool empty() const + { + return !(*m_String); + } + +private: + CRawString(const CRawString& p) + { + } + + WCHAR* m_String; +}; + +#endif