Cosmetic changes to code.

This commit is contained in:
Birunthan Mohanathas
2011-03-29 19:21:57 +00:00
parent 5882f12c49
commit a92bdd9b18
65 changed files with 1642 additions and 1642 deletions

View File

@@ -61,7 +61,7 @@ enum RetValue
RetError = 1 RetError = 1
}; };
/* /*
** WinMain ** WinMain
** **
** The Main-function ** The Main-function
@@ -94,22 +94,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
return RetSuccess; return RetSuccess;
} }
if(!hPrevInstance) if (!hPrevInstance)
{ {
if (!InitApplication(hInstance, WinClass)) return RetError; if (!InitApplication(hInstance, WinClass)) return RetError;
} }
hWnd=InitInstance(hInstance, WinClass, WinName); hWnd=InitInstance(hInstance, WinClass, WinName);
if(!hWnd) return RetError; if (!hWnd) return RetError;
// Remove quotes from the commandline // Remove quotes from the commandline
WCHAR Path[MAX_PATH+1] = {0}; WCHAR Path[MAX_PATH+1] = {0};
if(lpCmdLine) if (lpCmdLine)
{ {
size_t Pos = 0; size_t Pos = 0;
for(size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i) for (size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i)
{ {
if(lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i]; if (lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
} }
} }
@@ -118,7 +118,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
// Check that the DLL is available // Check that the DLL is available
HMODULE module = GetModuleHandle(L"Rainmeter.dll"); HMODULE module = GetModuleHandle(L"Rainmeter.dll");
if(module == NULL) if (module == NULL)
{ {
MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR); MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
DestroyWindow(hWnd); DestroyWindow(hWnd);
@@ -134,7 +134,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
} }
// Run the standard window message loop // Run the standard window message loop
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{ {
if (bRet == -1) // error if (bRet == -1) // error
{ {
@@ -144,15 +144,15 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
else else
{ {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
} }
if (hMutex) ReleaseMutex(hMutex); if (hMutex) ReleaseMutex(hMutex);
return (int)msg.wParam; return (int)msg.wParam;
} }
/* /*
** InitApplication ** InitApplication
** **
** Creates the windowclass ** Creates the windowclass
@@ -169,14 +169,14 @@ BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass)
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RAINMETER)); wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RAINMETER));
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = WinClass; wc.lpszClassName = WinClass;
return RegisterClass(&wc); return RegisterClass(&wc);
} }
/* /*
** InitInstance ** InitInstance
** **
** Creates the window. This is just an invisible window. The real window ** Creates the window. This is just an invisible window. The real window
@@ -201,7 +201,7 @@ HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinNa
); );
} }
/* /*
** Bang ** Bang
** **
** Sends bangs to the DLL ** Sends bangs to the DLL
@@ -231,7 +231,7 @@ void Bang(const WCHAR* command)
} }
} }
/* /*
** RmLoadSystemLibrary ** RmLoadSystemLibrary
** **
** Loads a system dll from system32 directory. ** Loads a system dll from system32 directory.
@@ -254,7 +254,7 @@ HMODULE RmLoadSystemLibrary(LPCWSTR lpLibFileName)
return NULL; return NULL;
} }
/* /*
** IsRunning ** IsRunning
** **
** Checks whether Rainmeter.exe is running. ** Checks whether Rainmeter.exe is running.
@@ -330,7 +330,7 @@ BOOL IsRunning(HANDLE* hMutex)
return FALSE; return FALSE;
} }
/* /*
** MainWndProc ** MainWndProc
** **
** The main window procedure ** The main window procedure

View File

@@ -127,7 +127,7 @@ void UpdateAboutDialog()
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for( ; iter != windows.end(); ++iter) for ( ; iter != windows.end(); ++iter)
{ {
if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0) if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0)
{ {
@@ -200,7 +200,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for( ; iter != windows.end(); ++iter) for ( ; iter != windows.end(); ++iter)
{ {
if (current == selected) if (current == selected)
{ {
@@ -213,7 +213,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
int index = 0; int index = 0;
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
const WCHAR* name = (*i)->GetName(); const WCHAR* name = (*i)->GetName();
const WCHAR* val = (*i)->GetStats(); const WCHAR* val = (*i)->GetStats();
@@ -229,7 +229,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
if (name && *name) if (name && *name)
{ {
if (index < count) if (index < count)
{ {
ListView_SetItemText(widget, index, 0, (WCHAR*)name); ListView_SetItemText(widget, index, 0, (WCHAR*)name);
} }
@@ -237,7 +237,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
{ {
LVITEM vitem; LVITEM vitem;
vitem.mask = LVIF_TEXT; vitem.mask = LVIF_TEXT;
vitem.iItem = index; vitem.iItem = index;
vitem.iSubItem = 0; vitem.iSubItem = 0;
vitem.pszText = (WCHAR*)name; vitem.pszText = (WCHAR*)name;
ListView_InsertItem(widget, &vitem); ListView_InsertItem(widget, &vitem);
@@ -273,7 +273,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
} }
} }
void UpdateWidgets() void UpdateWidgets()
{ {
HWND widget; HWND widget;
widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES); widget = GetDlgItem(g_DialogWin, IDC_ABOUT_ENTRIES);
@@ -284,8 +284,8 @@ void UpdateWidgets()
if (selected == 0) if (selected == 0)
{ {
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_TEXT; lvc.mask = LVCF_TEXT;
lvc.pszText = L"Time"; lvc.pszText = L"Time";
ListView_SetColumn(widget, 0, &lvc); ListView_SetColumn(widget, 0, &lvc);
lvc.pszText = L"Type"; lvc.pszText = L"Type";
@@ -295,8 +295,8 @@ void UpdateWidgets()
} }
else if (selected == 1) else if (selected == 1)
{ {
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_TEXT; lvc.mask = LVCF_TEXT;
lvc.pszText = L"Plugin"; lvc.pszText = L"Plugin";
ListView_SetColumn(widget, 0, &lvc); ListView_SetColumn(widget, 0, &lvc);
lvc.pszText = L"Version"; lvc.pszText = L"Version";
@@ -344,8 +344,8 @@ void UpdateWidgets()
} }
else else
{ {
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_TEXT; lvc.mask = LVCF_TEXT;
lvc.pszText = L"Measure"; lvc.pszText = L"Measure";
ListView_SetColumn(widget, 0, &lvc); ListView_SetColumn(widget, 0, &lvc);
lvc.pszText = L"Range"; lvc.pszText = L"Range";
@@ -390,7 +390,7 @@ void ScanPlugins()
info.author = author; info.author = author;
} }
} }
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion"); GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
if (GetVersionFunc) if (GetVersionFunc)
{ {
@@ -444,13 +444,13 @@ void RepositionControls(HWND hwndDlg)
widget = GetDlgItem(hwndDlg, IDC_STATISTICS); widget = GetDlgItem(hwndDlg, IDC_STATISTICS);
SetWindowPos(widget, NULL, (r.right < 800) ? (18 + ((r.right - 28) / 3)) : 275, 130, (r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287), r.bottom - 170, SWP_NOZORDER); SetWindowPos(widget, NULL, (r.right < 800) ? (18 + ((r.right - 28) / 3)) : 275, 130, (r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287), r.bottom - 170, SWP_NOZORDER);
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH; lvc.mask = LVCF_WIDTH;
lvc.cx = ((r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287)) - 200; lvc.cx = ((r.right < 800) ? (2 * ((r.right - 28) / 3)) : (r.right - 287)) - 200;
ListView_SetColumn(widget, 2, &lvc); ListView_SetColumn(widget, 2, &lvc);
} }
BOOL OnInitAboutDialog(HWND window) BOOL OnInitAboutDialog(HWND window)
{ {
WCHAR tmpSz[256]; WCHAR tmpSz[256];
HWND widget; HWND widget;
@@ -477,7 +477,7 @@ BOOL OnInitAboutDialog(HWND window)
size_t namelength = skinName.length(); size_t namelength = skinName.length();
int currwidth = (int)SendMessage(widget, LB_GETHORIZONTALEXTENT, NULL, NULL); int currwidth = (int)SendMessage(widget, LB_GETHORIZONTALEXTENT, NULL, NULL);
if(6 * (int)namelength > currwidth) if (6 * (int)namelength > currwidth)
{ {
SendMessage(widget, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL); SendMessage(widget, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
} }
@@ -498,8 +498,8 @@ BOOL OnInitAboutDialog(HWND window)
//ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); //ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
LVCOLUMN lvc; LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0; lvc.iSubItem = 0;
lvc.pszText = L"Time"; lvc.pszText = L"Time";
lvc.cx = 110; lvc.cx = 110;
@@ -521,7 +521,7 @@ BOOL OnInitAboutDialog(HWND window)
return TRUE; return TRUE;
} }
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
@@ -551,7 +551,7 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
case IDC_DISABLE_VERSION_CHECK: case IDC_DISABLE_VERSION_CHECK:
if (IsDlgButtonChecked(hwndDlg, IDC_DISABLE_VERSION_CHECK)) if (IsDlgButtonChecked(hwndDlg, IDC_DISABLE_VERSION_CHECK))
{ {
Rainmeter->SetDisableVersionCheck(TRUE); Rainmeter->SetDisableVersionCheck(TRUE);
} }
else else
{ {
@@ -580,7 +580,7 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa
UpdateWidgets(); UpdateWidgets();
UpdateAboutStatistics(); UpdateAboutStatistics();
return TRUE; return TRUE;
} }
break; break;
} }
break; break;

View File

@@ -96,7 +96,7 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
SetBuiltInVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath()); SetBuiltInVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath());
SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename)); SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename));
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath()); SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath());
SetBuiltInVariable(L"CRLF", L"\n"); SetBuiltInVariable(L"CRLF", L"\n");
if (meterWindow) if (meterWindow)
{ {
@@ -141,7 +141,7 @@ void CConfigParser::ReadVariables()
/** /**
** Sets a new value for the variable. The DynamicVariables must be set to 1 in the ** Sets a new value for the variable. The DynamicVariables must be set to 1 in the
** meter/measure for the changes to be applied. ** meter/measure for the changes to be applied.
** **
** \param variables ** \param variables
** \param strVariable ** \param strVariable
** \param strValue ** \param strValue
@@ -155,7 +155,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
/** /**
** Gets a value for the variable. ** Gets a value for the variable.
** **
** \param strVariable ** \param strVariable
** \param strValue ** \param strValue
** \return true if variable is found ** \return true if variable is found
@@ -216,7 +216,7 @@ void CConfigParser::ResetMonitorVariables(CMeterWindow* meterWindow)
** SetMultiMonitorVariables ** SetMultiMonitorVariables
** **
** Sets new values for the SCREENAREA/WORKAREA variables. ** Sets new values for the SCREENAREA/WORKAREA variables.
** **
*/ */
void CConfigParser::SetMultiMonitorVariables(bool reset) void CConfigParser::SetMultiMonitorVariables(bool reset)
{ {
@@ -322,7 +322,7 @@ void CConfigParser::SetMultiMonitorVariables(bool reset)
** SetAutoSelectedMonitorVariables ** SetAutoSelectedMonitorVariables
** **
** Sets new SCREENAREA/WORKAREA variables for present monitor. ** Sets new SCREENAREA/WORKAREA variables for present monitor.
** **
*/ */
void CConfigParser::SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow) void CConfigParser::SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow)
{ {
@@ -440,7 +440,7 @@ void CConfigParser::SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow)
/** /**
** Replaces environment and internal variables in the given string. ** Replaces environment and internal variables in the given string.
** **
** \param result The string where the variables are returned. The string is modified. ** \param result The string where the variables are returned. The string is modified.
*/ */
bool CConfigParser::ReplaceVariables(std::wstring& result) bool CConfigParser::ReplaceVariables(std::wstring& result)
@@ -460,7 +460,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
size_t pos = std::wstring::npos; size_t pos = std::wstring::npos;
bool loop = true; bool loop = true;
do do
{ {
pos = result.find(L'#', start); pos = result.find(L'#', start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
@@ -499,7 +499,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
/** /**
** Replaces measures in the given string. ** Replaces measures in the given string.
** **
** \param result The string where the measure values are returned. The string is modified. ** \param result The string where the measure values are returned. The string is modified.
*/ */
bool CConfigParser::ReplaceMeasures(std::wstring& result) bool CConfigParser::ReplaceMeasures(std::wstring& result)
@@ -514,7 +514,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
size_t pos = std::wstring::npos; size_t pos = std::wstring::npos;
size_t pos2 = std::wstring::npos; size_t pos2 = std::wstring::npos;
bool loop = true; bool loop = true;
do do
{ {
pos = result.find(L'[', start); pos = result.find(L'[', start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
@@ -764,7 +764,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue); return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
} }
// Returns an int if the formula was read successfully, -1 for failure. // Returns 1 if the formula was read successfully, -1 for failure.
// Pass a pointer to a double. // Pass a pointer to a double.
int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue) int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
{ {
@@ -772,7 +772,7 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
if (result.size() > 0 && result[0] == L'(' && result[result.size() - 1] == L')') if (result.size() > 0 && result[0] == L'(' && result[result.size() - 1] == L')')
{ {
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.substr(1, result.size() - 2).c_str()).c_str(), resultValue); char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.substr(1, result.size() - 2).c_str()).c_str(), resultValue);
if (errMsg != NULL) if (errMsg != NULL)
{ {
Log(LOG_ERROR, ConvertToWide(errMsg).c_str()); Log(LOG_ERROR, ConvertToWide(errMsg).c_str());
@@ -816,15 +816,15 @@ RECT CConfigParser::ReadRECT(LPCTSTR section, LPCTSTR key, const RECT& defValue)
std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters) std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters)
{ {
std::vector<std::wstring> tokens; std::vector<std::wstring> tokens;
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0); // skip delimiters at beginning. std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0); // skip delimiters at beginning.
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos); // find first "non-delimiter". std::wstring::size_type pos = str.find_first_of(delimiters, lastPos); // find first "non-delimiter".
while (std::wstring::npos != pos || std::wstring::npos != lastPos) while (std::wstring::npos != pos || std::wstring::npos != lastPos)
{ {
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
} }
return tokens; return tokens;
@@ -840,7 +840,7 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp) double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp)
{ {
std::wstring::size_type pos; std::wstring::size_type pos;
// Ignore inline comments which start with ';' // Ignore inline comments which start with ';'
if ((pos = string.find_first_of(L';')) != std::wstring::npos) if ((pos = string.find_first_of(L';')) != std::wstring::npos)
{ {
@@ -878,7 +878,7 @@ double CConfigParser::ParseDouble(const std::wstring& string, double defValue, b
** ParseColor ** ParseColor
** **
** This is a helper method that parses the color values from the given string. ** This is a helper method that parses the color values from the given string.
** The color can be supplied as three/four comma separated values or as one ** The color can be supplied as three/four comma separated values or as one
** hex-value. ** hex-value.
** **
*/ */
@@ -886,7 +886,7 @@ Color CConfigParser::ParseColor(LPCTSTR string)
{ {
int R, G, B, A; int R, G, B, A;
if(wcschr(string, L',') != NULL) if (wcschr(string, L',') != NULL)
{ {
WCHAR* parseSz = _wcsdup(string); WCHAR* parseSz = _wcsdup(string);
WCHAR* token; WCHAR* token;
@@ -936,7 +936,7 @@ Color CConfigParser::ParseColor(LPCTSTR string)
A = 255; A = 255;
} }
free(parseSz); free(parseSz);
} }
else else
{ {
const WCHAR* start = string; const WCHAR* start = string;
@@ -949,8 +949,8 @@ Color CConfigParser::ParseColor(LPCTSTR string)
if (wcslen(string) > 6 && !iswspace(string[6])) if (wcslen(string) > 6 && !iswspace(string[6]))
{ {
swscanf(string, L"%02x%02x%02x%02x", &R, &G, &B, &A); swscanf(string, L"%02x%02x%02x%02x", &R, &G, &B, &A);
} }
else else
{ {
swscanf(string, L"%02x%02x%02x", &R, &G, &B); swscanf(string, L"%02x%02x%02x", &R, &G, &B);
A = 255; // Opaque A = 255; // Opaque
@@ -1029,7 +1029,7 @@ RECT CConfigParser::ParseRECT(LPCTSTR string)
//============================================================================== //==============================================================================
/** /**
** Reads the given ini file and fills the m_Values and m_Keys maps. ** Reads the given ini file and fills the m_Values and m_Keys maps.
** **
** \param iniFile The ini file to be read. ** \param iniFile The ini file to be read.
*/ */
void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings, const std::wstring& iniFile, int depth) void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings, const std::wstring& iniFile, int depth)
@@ -1067,7 +1067,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
WCHAR* epos = NULL; WCHAR* epos = NULL;
// Get all the sections // Get all the sections
while(true) while (true)
{ {
items[0] = 0; items[0] = 0;
int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniRead.c_str()); int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniRead.c_str());
@@ -1117,7 +1117,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
std::list<std::wstring>::const_iterator iter = sections.begin(); std::list<std::wstring>::const_iterator iter = sections.begin();
for ( ; iter != sections.end(); ++iter) for ( ; iter != sections.end(); ++iter)
{ {
while(true) while (true)
{ {
items[0] = 0; items[0] = 0;
int res = GetPrivateProfileString((*iter).c_str(), NULL, NULL, items, size, iniRead.c_str()); int res = GetPrivateProfileString((*iter).c_str(), NULL, NULL, items, size, iniRead.c_str());
@@ -1139,7 +1139,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
{ {
std::wstring strKey = pos; std::wstring strKey = pos;
while(true) while (true)
{ {
buffer[0] = 0; buffer[0] = 0;
int res = GetPrivateProfileString((*iter).c_str(), strKey.c_str(), L"", buffer, bufferSize, iniRead.c_str()); int res = GetPrivateProfileString((*iter).c_str(), strKey.c_str(), L"", buffer, bufferSize, iniRead.c_str());
@@ -1184,7 +1184,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
//============================================================================== //==============================================================================
/** /**
** Sets the value for the key under the given section. ** Sets the value for the key under the given section.
** **
** \param strSection The name of the section. ** \param strSection The name of the section.
** \param strKey The name of the key. ** \param strKey The name of the key.
** \param strValue The value for the key. ** \param strValue The value for the key.
@@ -1211,7 +1211,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
//============================================================================== //==============================================================================
/** /**
** Returns the value for the key under the given section. ** Returns the value for the key under the given section.
** **
** \param strSection The name of the section. ** \param strSection The name of the section.
** \param strKey The name of the key. ** \param strKey The name of the key.
** \param strDefault The default value for the key. ** \param strDefault The default value for the key.
@@ -1234,7 +1234,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
//============================================================================== //==============================================================================
/** /**
** Returns a list of keys under the given section. ** Returns a list of keys under the given section.
** **
** \param strSection The name of the section. ** \param strSection The name of the section.
** \return A list of keys under the given section. ** \return A list of keys under the given section.
*/ */

View File

@@ -19,7 +19,7 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "Error.h" #include "Error.h"
const WCHAR* CError::c_ErrorStrings[] = const WCHAR* CError::c_ErrorStrings[] =
{ {
L"User defined error", L"User defined error",
L"Out of memory", L"Out of memory",
@@ -28,7 +28,7 @@ const WCHAR* CError::c_ErrorStrings[] =
L"Unable to create window" L"Unable to create window"
}; };
/* /*
** GetString ** GetString
** **
** Returns the error string ** Returns the error string
@@ -38,10 +38,10 @@ const std::wstring& CError::GetString()
{ {
// static WCHAR Buffer[16]; // static WCHAR Buffer[16];
if (m_Error != ERROR_USER) if (m_Error != ERROR_USER)
{ {
m_String = c_ErrorStrings[m_Error]; m_String = c_ErrorStrings[m_Error];
// if (m_File) // if (m_File)
// { // {
// _snwprintf_s(Buffer, _TRUNCATE, L"%i", m_Line); // _snwprintf_s(Buffer, _TRUNCATE, L"%i", m_Line);
// //
@@ -53,5 +53,5 @@ const std::wstring& CError::GetString()
// } // }
} }
return m_String; return m_String;
} }

View File

@@ -128,7 +128,7 @@ BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen)
void VarExpansion(LPSTR buffer, LPCSTR value) void VarExpansion(LPSTR buffer, LPCSTR value)
{ {
// Use the lsapi.dll version of the method if possible // Use the lsapi.dll version of the method if possible
if (fpVarExpansion) if (fpVarExpansion)
{ {
fpVarExpansion(buffer, value); fpVarExpansion(buffer, value);
} }
@@ -281,7 +281,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup; PSID AdministratorsGroup;
// Initialize SID. // Initialize SID.
if( !AllocateAndInitializeSid( &NtAuthority, if (!AllocateAndInitializeSid( &NtAuthority,
2, 2,
SECURITY_BUILTIN_DOMAIN_RID, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, DOMAIN_ALIAS_RID_ADMINS,
@@ -294,7 +294,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
else else
{ {
// Check whether the token is present in admin group. // Check whether the token is present in admin group.
if( !CheckTokenMembership( NULL, if (!CheckTokenMembership( NULL,
AdministratorsGroup, AdministratorsGroup,
&IsInAdminGroup )) &IsInAdminGroup ))
{ {
@@ -318,7 +318,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd) HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
{ {
// Use the lsapi.dll version of the method if possible // Use the lsapi.dll version of the method if possible
if (fpLSExecute) if (fpLSExecute)
{ {
std::string asc = ConvertToAscii(szCommand); std::string asc = ConvertToAscii(szCommand);
return fpLSExecute(Owner, asc.c_str(), nShowCmd); return fpLSExecute(Owner, asc.c_str(), nShowCmd);
@@ -386,7 +386,7 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz
//void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent) //void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent)
//{ //{
// // Use the lsapi.dll version of the method if possible // // Use the lsapi.dll version of the method if possible
// if (fpTransparentBltLS) // if (fpTransparentBltLS)
// { // {
// fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent); // fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent);
// } // }
@@ -506,9 +506,9 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
// Add timestamp // Add timestamp
static DWORD startTime = 0; static DWORD startTime = 0;
DWORD time = GetTickCount(); DWORD time = GetTickCount();
if (startTime == 0) if (startTime == 0)
{ {
startTime = time; startTime = time;
} }
@@ -516,7 +516,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
_snwprintf_s(buffer, _TRUNCATE, L"(%02i:%02i:%02i.%03i) ", (time - startTime) / (1000 * 60* 60), ((time - startTime) / (1000 * 60)) % 60, ((time - startTime) / 1000) % 60, (time - startTime) % 1000); _snwprintf_s(buffer, _TRUNCATE, L"(%02i:%02i:%02i.%03i) ", (time - startTime) / (1000 * 60* 60), ((time - startTime) / (1000 * 60)) % 60, ((time - startTime) / 1000) % 60, (time - startTime) % 1000);
std::wstring message(buffer); std::wstring message(buffer);
logInfo.timestamp = message; logInfo.timestamp = message;
message += pszMessage; message += pszMessage;
#ifdef _DEBUG #ifdef _DEBUG
@@ -546,7 +546,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
} }
// Use the lsapi.dll version of the method if possible // Use the lsapi.dll version of the method if possible
if (fpLSLog) if (fpLSLog)
{ {
std::string asc = ConvertToAscii(message.c_str()); std::string asc = ConvertToAscii(message.c_str());
std::string mod = ConvertToAscii(pszModule); std::string mod = ConvertToAscii(pszModule);
@@ -612,7 +612,7 @@ void LogWithArgs(int nLevel, const WCHAR* format, ... )
{ {
WCHAR* buffer = new WCHAR[4096]; WCHAR* buffer = new WCHAR[4096];
va_list args; va_list args;
va_start( args, format ); va_start( args, format );
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler); _invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
_CrtSetReportMode(_CRT_ASSERT, 0); _CrtSetReportMode(_CRT_ASSERT, 0);

View File

@@ -116,7 +116,7 @@ void CMeasure::Initialize()
** **
** Reads the common configs for all Measures. The inherited classes ** Reads the common configs for all Measures. The inherited classes
** must call the base implementation if they overwrite this method. ** must call the base implementation if they overwrite this method.
** **
*/ */
void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section) void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
@@ -185,7 +185,7 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
/* /*
** CheckSubstitute ** CheckSubstitute
** **
** Substitutes part of the text ** Substitutes part of the text
*/ */
const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer) const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
@@ -208,7 +208,7 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
size_t start = 0; size_t start = 0;
size_t pos = std::wstring::npos; size_t pos = std::wstring::npos;
do do
{ {
pos = str.find(m_Substitute[i], start); pos = str.find(m_Substitute[i], start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
@@ -221,7 +221,7 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
} }
return str.c_str(); return str.c_str();
} }
else else
{ {
return buffer; return buffer;
@@ -230,19 +230,19 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
/* /*
** ParseSubstitute ** ParseSubstitute
** **
** Reads the buffer for "Name":"Value"-pairs separated with comma and ** Reads the buffer for "Name":"Value"-pairs separated with comma and
** fills the map with the parsed data. ** fills the map with the parsed data.
*/ */
bool CMeasure::ParseSubstitute(std::wstring buffer) bool CMeasure::ParseSubstitute(std::wstring buffer)
{ {
if (buffer.empty()) return true; if (buffer.empty()) return true;
while (!buffer.empty()) while (!buffer.empty())
{ {
std::wstring word1 = ExtractWord(buffer); std::wstring word1 = ExtractWord(buffer);
std::wstring sep = ExtractWord(buffer); std::wstring sep = ExtractWord(buffer);
if (sep != L":") return false; if (sep != L":") return false;
std::wstring word2 = ExtractWord(buffer); std::wstring word2 = ExtractWord(buffer);
if (word1 != word2) if (word1 != word2)
@@ -252,7 +252,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
} }
sep = ExtractWord(buffer); sep = ExtractWord(buffer);
if (!sep.empty() && sep != L",") return false; if (!sep.empty() && sep != L",") return false;
} }
return true; return true;
@@ -262,7 +262,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
** ExtractWord ** ExtractWord
** **
** Returns the first word from the buffer. The word can be inside quotes. ** Returns the first word from the buffer. The word can be inside quotes.
** If not, the separators are ' ', '\t', ',' and ':'. Whitespaces are removed ** If not, the separators are ' ', '\t', ',' and ':'. Whitespaces are removed
** and buffer _will_ be modified. ** and buffer _will_ be modified.
*/ */
std::wstring CMeasure::ExtractWord(std::wstring& buffer) std::wstring CMeasure::ExtractWord(std::wstring& buffer)
@@ -270,7 +270,7 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
std::wstring::size_type end, len; std::wstring::size_type end, len;
std::wstring ret; std::wstring ret;
if (buffer.empty()) return ret; if (buffer.empty()) return ret;
len = buffer.size(); len = buffer.size();
@@ -334,28 +334,28 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
** PreUpdate ** PreUpdate
** **
** The base implementation of the update method. This includes the code ** The base implementation of the update method. This includes the code
** that is common for all measures. This is called every time the measure ** that is common for all measures. This is called every time the measure
** is updated. The inherited classes must call the base implementation if ** is updated. The inherited classes must call the base implementation if
** they overwrite this method. If this method returns false, the update ** they overwrite this method. If this method returns false, the update
** needs not to be done. ** needs not to be done.
** **
*/ */
bool CMeasure::PreUpdate() bool CMeasure::PreUpdate()
{ {
if (IsDisabled()) if (IsDisabled())
{ {
m_Value = 0.0; // Disable measures return 0 as value m_Value = 0.0; // Disable measures return 0 as value
return false; return false;
} }
// Only update the counter if the divider // Only update the counter if the divider
++m_UpdateCounter; ++m_UpdateCounter;
if (m_UpdateCounter < m_UpdateDivider) return false; if (m_UpdateCounter < m_UpdateDivider) return false;
m_UpdateCounter = 0; m_UpdateCounter = 0;
// If we're logging the maximum value of the measure, check if // If we're logging the maximum value of the measure, check if
// the new value is greater than the old one, and update if necessary. // the new value is greater than the old one, and update if necessary.
if(m_LogMaxValue) if (m_LogMaxValue)
{ {
if (m_MedianMaxValues.empty()) if (m_MedianMaxValues.empty())
{ {
@@ -369,7 +369,7 @@ bool CMeasure::PreUpdate()
m_MedianPos %= MEDIAN_SIZE; m_MedianPos %= MEDIAN_SIZE;
std::vector<double> medianArray; std::vector<double> medianArray;
medianArray = m_MedianMaxValues; medianArray = m_MedianMaxValues;
std::sort(medianArray.begin(), medianArray.end()); std::sort(medianArray.begin(), medianArray.end());
m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]); m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]);
@@ -382,11 +382,11 @@ bool CMeasure::PreUpdate()
if (m_MeterWindow) if (m_MeterWindow)
{ {
// Check the IfEqualValue // Check the IfEqualValue
if(!m_IfEqualAction.empty()) if (!m_IfEqualAction.empty())
{ {
if((int)m_Value == (int)m_IfEqualValue) if ((int)m_Value == (int)m_IfEqualValue)
{ {
if(!m_IfEqualCommited) if (!m_IfEqualCommited)
{ {
m_IfEqualCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop m_IfEqualCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow);
@@ -399,11 +399,11 @@ bool CMeasure::PreUpdate()
} }
// Check the IfAboveValue // Check the IfAboveValue
if(!m_IfAboveAction.empty()) if (!m_IfAboveAction.empty())
{ {
if(m_Value > m_IfAboveValue) if (m_Value > m_IfAboveValue)
{ {
if(!m_IfAboveCommited) if (!m_IfAboveCommited)
{ {
m_IfAboveCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop m_IfAboveCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow);
@@ -416,11 +416,11 @@ bool CMeasure::PreUpdate()
} }
// Check the IfBelowValue // Check the IfBelowValue
if(!m_IfBelowAction.empty()) if (!m_IfBelowAction.empty())
{ {
if(m_Value < m_IfBelowValue) if (m_Value < m_IfBelowValue)
{ {
if(!m_IfBelowCommited) if (!m_IfBelowCommited)
{ {
m_IfBelowCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop m_IfBelowCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow);
@@ -441,7 +441,7 @@ bool CMeasure::PreUpdate()
** **
** Does post measuring things to the value. All measures must call this ** Does post measuring things to the value. All measures must call this
** after they have set the m_Value. ** after they have set the m_Value.
** **
*/ */
bool CMeasure::PostUpdate() bool CMeasure::PostUpdate()
{ {
@@ -474,8 +474,8 @@ bool CMeasure::PostUpdate()
/* /*
** GetValue ** GetValue
** **
** Returns the value of the measure. ** Returns the value of the measure.
** **
*/ */
double CMeasure::GetValue() double CMeasure::GetValue()
{ {
@@ -491,8 +491,8 @@ double CMeasure::GetValue()
/* /*
** GetRelativeValue ** GetRelativeValue
** **
** Returns the relative value of the measure (0.0 - 1.0). ** Returns the relative value of the measure (0.0 - 1.0).
** **
*/ */
double CMeasure::GetRelativeValue() double CMeasure::GetRelativeValue()
{ {
@@ -516,8 +516,8 @@ double CMeasure::GetRelativeValue()
/* /*
** GetValueRange ** GetValueRange
** **
** Returns the value range. ** Returns the value range.
** **
*/ */
double CMeasure::GetValueRange() double CMeasure::GetValueRange()
{ {
@@ -529,7 +529,7 @@ double CMeasure::GetValueRange()
** **
** This method returns the value as text string. The actual value is ** This method returns the value as text string. The actual value is
** get with GetValue() so we don't have to worry about m_Invert. ** get with GetValue() so we don't have to worry about m_Invert.
** **
** autoScale If true, scale the value automatically to some sensible range. ** autoScale If true, scale the value automatically to some sensible range.
** scale The scale to use if autoScale is false. ** scale The scale to use if autoScale is false.
** decimals Number of decimals used in the value. If -1, get rid of ".00000" for dynamic variables. ** decimals Number of decimals used in the value. If -1, get rid of ".00000" for dynamic variables.
@@ -540,29 +540,29 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
static WCHAR buffer[MAX_LINE_LENGTH]; static WCHAR buffer[MAX_LINE_LENGTH];
WCHAR format[32]; WCHAR format[32];
if(percentual) if (percentual)
{ {
double val = 100.0 * GetRelativeValue(); double val = 100.0 * GetRelativeValue();
if (decimals == 0) if (decimals == 0)
{ {
_snwprintf_s(buffer, _TRUNCATE, L"%i", (int)val); _snwprintf_s(buffer, _TRUNCATE, L"%i", (int)val);
} }
else else
{ {
_snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals); _snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals);
_snwprintf_s(buffer, _TRUNCATE, format, val); _snwprintf_s(buffer, _TRUNCATE, format, val);
} }
} }
else if(autoScale != AUTOSCALE_OFF) else if (autoScale != AUTOSCALE_OFF)
{ {
GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer)); GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer));
} }
else else
{ {
double val = GetValue() / scale; double val = GetValue() / scale;
if(decimals == 0) if (decimals == 0)
{ {
val += (val >= 0) ? 0.5 : -0.5; val += (val >= 0) ? 0.5 : -0.5;
_snwprintf_s(buffer, _TRUNCATE, L"%lli", (LONGLONG)val); _snwprintf_s(buffer, _TRUNCATE, L"%lli", (LONGLONG)val);
@@ -592,7 +592,7 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
WCHAR format[32]; WCHAR format[32];
double value = 0; double value = 0;
if(decimals == 0) if (decimals == 0)
{ {
wcsncpy_s(format, L"%.0f", _TRUNCATE); wcsncpy_s(format, L"%.0f", _TRUNCATE);
} }
@@ -603,22 +603,22 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
int index = (autoScale == AUTOSCALE_1000 || autoScale == AUTOSCALE_1000K) ? AUTOSCALE_INDEX_1000 : AUTOSCALE_INDEX_1024; int index = (autoScale == AUTOSCALE_1000 || autoScale == AUTOSCALE_1000K) ? AUTOSCALE_INDEX_1000 : AUTOSCALE_INDEX_1024;
if(theValue > (g_TblScale[index][0] * 0.99)) if (theValue > (g_TblScale[index][0] * 0.99))
{ {
wcsncat_s(format, L" T", _TRUNCATE); wcsncat_s(format, L" T", _TRUNCATE);
value = theValue / g_TblScale[index][0]; value = theValue / g_TblScale[index][0];
} }
else if(theValue > (g_TblScale[index][1] * 0.99)) else if (theValue > (g_TblScale[index][1] * 0.99))
{ {
wcsncat_s(format, L" G", _TRUNCATE); wcsncat_s(format, L" G", _TRUNCATE);
value = theValue / g_TblScale[index][1]; value = theValue / g_TblScale[index][1];
} }
else if(theValue > (g_TblScale[index][2] * 0.99)) else if (theValue > (g_TblScale[index][2] * 0.99))
{ {
wcsncat_s(format, L" M", _TRUNCATE); wcsncat_s(format, L" M", _TRUNCATE);
value = theValue / g_TblScale[index][2]; value = theValue / g_TblScale[index][2];
} }
else if(autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99)) else if (autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99))
{ {
wcsncat_s(format, L" k", _TRUNCATE); wcsncat_s(format, L" k", _TRUNCATE);
value = theValue / g_TblScale[index][3]; value = theValue / g_TblScale[index][3];
@@ -651,69 +651,69 @@ const WCHAR* CMeasure::GetStats()
** **
** Creates the given measure. This is the factory method for the measures. ** Creates the given measure. This is the factory method for the measures.
** If new measures are implemented this method needs to be updated. ** If new measures are implemented this method needs to be updated.
** **
*/ */
CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name) CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name)
{ {
// Comparison is caseinsensitive // Comparison is caseinsensitive
if(*measure == L'\0') if (*measure == L'\0')
{ {
return NULL; return NULL;
} }
else if(_wcsicmp(L"CPU", measure) == 0) else if (_wcsicmp(L"CPU", measure) == 0)
{ {
return new CMeasureCPU(meterWindow, name); return new CMeasureCPU(meterWindow, name);
} }
else if(_wcsicmp(L"Memory", measure) == 0) else if (_wcsicmp(L"Memory", measure) == 0)
{ {
return new CMeasureMemory(meterWindow, name); return new CMeasureMemory(meterWindow, name);
} }
else if(_wcsicmp(L"NetIn", measure) == 0) else if (_wcsicmp(L"NetIn", measure) == 0)
{ {
return new CMeasureNetIn(meterWindow, name); return new CMeasureNetIn(meterWindow, name);
} }
else if(_wcsicmp(L"NetOut", measure) == 0) else if (_wcsicmp(L"NetOut", measure) == 0)
{ {
return new CMeasureNetOut(meterWindow, name); return new CMeasureNetOut(meterWindow, name);
} }
else if(_wcsicmp(L"NetTotal", measure) == 0) else if (_wcsicmp(L"NetTotal", measure) == 0)
{ {
return new CMeasureNetTotal(meterWindow, name); return new CMeasureNetTotal(meterWindow, name);
} }
else if(_wcsicmp(L"PhysicalMemory", measure) == 0) else if (_wcsicmp(L"PhysicalMemory", measure) == 0)
{ {
return new CMeasurePhysicalMemory(meterWindow, name); return new CMeasurePhysicalMemory(meterWindow, name);
} }
else if(_wcsicmp(L"SwapMemory", measure) == 0) else if (_wcsicmp(L"SwapMemory", measure) == 0)
{ {
return new CMeasureVirtualMemory(meterWindow, name); return new CMeasureVirtualMemory(meterWindow, name);
} }
else if(_wcsicmp(L"FreeDiskSpace", measure) == 0) else if (_wcsicmp(L"FreeDiskSpace", measure) == 0)
{ {
return new CMeasureDiskSpace(meterWindow, name); return new CMeasureDiskSpace(meterWindow, name);
} }
else if(_wcsicmp(L"Uptime", measure) == 0) else if (_wcsicmp(L"Uptime", measure) == 0)
{ {
return new CMeasureUptime(meterWindow, name); return new CMeasureUptime(meterWindow, name);
} }
else if(_wcsicmp(L"Time", measure) == 0) else if (_wcsicmp(L"Time", measure) == 0)
{ {
return new CMeasureTime(meterWindow, name); return new CMeasureTime(meterWindow, name);
} }
else if(_wcsicmp(L"Plugin", measure) == 0) else if (_wcsicmp(L"Plugin", measure) == 0)
{ {
return new CMeasurePlugin(meterWindow, name); return new CMeasurePlugin(meterWindow, name);
} }
else if(_wcsicmp(L"Registry", measure) == 0) else if (_wcsicmp(L"Registry", measure) == 0)
{ {
return new CMeasureRegistry(meterWindow, name); return new CMeasureRegistry(meterWindow, name);
} }
else if(_wcsicmp(L"Calc", measure) == 0) else if (_wcsicmp(L"Calc", measure) == 0)
{ {
return new CMeasureCalc(meterWindow, name); return new CMeasureCalc(meterWindow, name);
} }
else if(_wcsicmp(L"script", measure) == 0) else if (_wcsicmp(L"script", measure) == 0)
{ {
return new CMeasureScript(meterWindow, name); return new CMeasureScript(meterWindow, name);
} }

View File

@@ -50,7 +50,7 @@ ULONG CMeasureCPU::c_BufferSize = 0;
// OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit // OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit
// // variable that receives // // variable that receives
// // the number of bytes // // the number of bytes
// // written to the buffer // // written to the buffer
// ); // );
/* /*

View File

@@ -37,10 +37,10 @@ CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeas
m_HighBound(100), m_HighBound(100),
m_UpdateRandom(false) m_UpdateRandom(false)
{ {
if(!c_RandSeeded) if (!c_RandSeeded)
{ {
c_RandSeeded = true; c_RandSeeded = true;
srand((unsigned)time(0)); srand((unsigned)time(0));
} }
rand(); rand();
@@ -98,12 +98,12 @@ void CMeasureCalc::UpdateVariableMap(CMeterWindow& meterWindow)
} }
// Create the variable map // Create the variable map
c_VarMap = Strmap_Create(sizeof(double), 0); c_VarMap = Strmap_Create(sizeof(double), 0);
const std::list<CMeasure*>& measures = meterWindow.GetMeasures(); const std::list<CMeasure*>& measures = meterWindow.GetMeasures();
std::list<CMeasure*>::const_iterator iter = measures.begin(); std::list<CMeasure*>::const_iterator iter = measures.begin();
for( ; iter != measures.end(); ++iter) for ( ; iter != measures.end(); ++iter)
{ {
const char* name = (*iter)->GetANSIName(); const char* name = (*iter)->GetANSIName();
double val = (*iter)->GetValue(); double val = (*iter)->GetValue();
@@ -172,9 +172,9 @@ void CMeasureCalc::FormulaReplace()
(loc == 0 || IsDelimiter(*(m_Formula.c_str() + loc - 1))) && (loc == 0 || IsDelimiter(*(m_Formula.c_str() + loc - 1))) &&
(loc == (m_Formula.length() - 6) || IsDelimiter(*(m_Formula.c_str() + loc + 6)))) (loc == (m_Formula.length() - 6) || IsDelimiter(*(m_Formula.c_str() + loc + 6))))
{ {
int range = (m_HighBound - m_LowBound) + 1; int range = (m_HighBound - m_LowBound) + 1;
srand((unsigned) rand()); srand((unsigned) rand());
int randNumber = m_LowBound + (int)(range * rand()/(RAND_MAX + 1.0)); int randNumber = m_LowBound + (int)(range * rand()/(RAND_MAX + 1.0));
WCHAR buffer[32]; WCHAR buffer[32];
_snwprintf_s(buffer, _TRUNCATE, L"%i", randNumber); _snwprintf_s(buffer, _TRUNCATE, L"%i", randNumber);

View File

@@ -47,7 +47,7 @@ CMeasureDiskSpace::~CMeasureDiskSpace()
/* /*
** Update ** Update
** **
** Updates the current disk free space value. ** Updates the current disk free space value.
** **
*/ */
bool CMeasureDiskSpace::Update() bool CMeasureDiskSpace::Update()
@@ -127,7 +127,7 @@ bool CMeasureDiskSpace::Update()
*/ */
const WCHAR* CMeasureDiskSpace::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual) const WCHAR* CMeasureDiskSpace::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
{ {
if (m_Label) if (m_Label)
{ {
return CheckSubstitute(m_LabelName.c_str()); return CheckSubstitute(m_LabelName.c_str());
} }

View File

@@ -44,7 +44,7 @@ CMeasureMemory::~CMeasureMemory()
/* /*
** Update ** Update
** **
** Updates the current total memory value. ** Updates the current total memory value.
** **
*/ */
bool CMeasureMemory::Update() bool CMeasureMemory::Update()

View File

@@ -35,7 +35,7 @@ extern CRainmeter* Rainmeter;
/* /*
** CMeasureNet ** CMeasureNet
** **
** The constructor. This is the base class for the net-meters. ** The constructor. This is the base class for the net-meters.
** **
*/ */
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name), CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
@@ -394,7 +394,7 @@ ULONG64 CMeasureNet::GetNetStatsValue(NET net)
if (m_Interface == 0) if (m_Interface == 0)
{ {
// Get all interfaces // Get all interfaces
for(size_t i = 0; i < statsSize; ++i) for (size_t i = 0; i < statsSize; ++i)
{ {
// Ignore the loopback and filter interfaces // Ignore the loopback and filter interfaces
if (c_NumOfTables == statsSize) if (c_NumOfTables == statsSize)
@@ -482,15 +482,15 @@ void CMeasureNet::ReadConfig(CConfigParser& parser, const WCHAR* section, NET ne
} }
double maxValue = parser.ReadFloat(section, L"MaxValue", -1); double maxValue = parser.ReadFloat(section, L"MaxValue", -1);
if (maxValue == -1) if (maxValue == -1)
{ {
maxValue = parser.ReadFloat(section, netName, -1); maxValue = parser.ReadFloat(section, netName, -1);
if (maxValue == -1) if (maxValue == -1)
{ {
maxValue = value; maxValue = value;
} }
} }
m_Interface = parser.ReadInt(section, L"Interface", 0); m_Interface = parser.ReadInt(section, L"Interface", 0);
m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0); m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0);
@@ -527,7 +527,7 @@ void CMeasureNet::UpdateStats()
} }
while (c_OldStatValues.size() < statsSize) while (c_OldStatValues.size() < statsSize)
{ {
c_OldStatValues.push_back(0); c_OldStatValues.push_back(0);
} }
@@ -622,7 +622,7 @@ void CMeasureNet::WriteStats(const std::wstring& iniFile)
WCHAR buffer2[64]; WCHAR buffer2[64];
size_t statsSize = c_StatValues.size() / 2; size_t statsSize = c_StatValues.size() / 2;
_snwprintf_s(buffer, _TRUNCATE, L"%i", (int)statsSize); _snwprintf_s(buffer, _TRUNCATE, L"%i", (int)statsSize);
WritePrivateProfileString(L"Statistics", L"NetStatsCount", buffer, iniFile.c_str()); WritePrivateProfileString(L"Statistics", L"NetStatsCount", buffer, iniFile.c_str());

View File

@@ -44,14 +44,14 @@ CMeasureNetIn::~CMeasureNetIn()
/* /*
** Update ** Update
** **
** Updates the current net in value. ** Updates the current net in value.
** **
*/ */
bool CMeasureNetIn::Update() bool CMeasureNetIn::Update()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (!CMeasureNet::PreUpdate()) return false;
if(c_Table == NULL) return false; if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@@ -61,7 +61,7 @@ bool CMeasureNetIn::Update()
{ {
ULONG64 value = 0; ULONG64 value = 0;
if (!m_FirstTime) if (!m_FirstTime)
{ {
value = GetNetOctets(NET_IN); value = GetNetOctets(NET_IN);
if (value > m_InOctets) if (value > m_InOctets)

View File

@@ -44,14 +44,14 @@ CMeasureNetOut::~CMeasureNetOut()
/* /*
** Update ** Update
** **
** Updates the current net out value. ** Updates the current net out value.
** **
*/ */
bool CMeasureNetOut::Update() bool CMeasureNetOut::Update()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (!CMeasureNet::PreUpdate()) return false;
if(c_Table == NULL) return false; if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@@ -61,7 +61,7 @@ bool CMeasureNetOut::Update()
{ {
ULONG64 value = 0; ULONG64 value = 0;
if (!m_FirstTime) if (!m_FirstTime)
{ {
value = GetNetOctets(NET_OUT); value = GetNetOctets(NET_OUT);
if (value > m_OutOctets) if (value > m_OutOctets)

View File

@@ -44,14 +44,14 @@ CMeasureNetTotal::~CMeasureNetTotal()
/* /*
** Update ** Update
** **
** Updates the current net total value. ** Updates the current net total value.
** **
*/ */
bool CMeasureNetTotal::Update() bool CMeasureNetTotal::Update()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (!CMeasureNet::PreUpdate()) return false;
if(c_Table == NULL) return false; if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@@ -61,7 +61,7 @@ bool CMeasureNetTotal::Update()
{ {
ULONG64 value = 0; ULONG64 value = 0;
if (!m_FirstTime) if (!m_FirstTime)
{ {
value = GetNetOctets(NET_TOTAL); value = GetNetOctets(NET_TOTAL);
if (value > m_TotalOctets) if (value > m_TotalOctets)

View File

@@ -44,7 +44,7 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory()
/* /*
** Update ** Update
** **
** Updates the current physical memory value. ** Updates the current physical memory value.
** **
*/ */
bool CMeasurePhysicalMemory::Update() bool CMeasurePhysicalMemory::Update()

View File

@@ -49,11 +49,11 @@ CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name) : C
** The destructor ** The destructor
** **
*/ */
CMeasurePlugin::~CMeasurePlugin() CMeasurePlugin::~CMeasurePlugin()
{ {
if (m_Plugin) if (m_Plugin)
{ {
if(FinalizeFunc) FinalizeFunc(m_Plugin, m_ID); if (FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
FreeLibrary(m_Plugin); FreeLibrary(m_Plugin);
} }
} }
@@ -78,12 +78,12 @@ bool CMeasurePlugin::Update()
} }
SetCurrentDirectory(dir.c_str()); SetCurrentDirectory(dir.c_str());
if(UpdateFunc) if (UpdateFunc)
{ {
// Update the plugin // Update the plugin
m_Value = UpdateFunc(m_ID); m_Value = UpdateFunc(m_ID);
} }
else if(UpdateFunc2) else if (UpdateFunc2)
{ {
// Update the plugin // Update the plugin
m_Value = UpdateFunc2(m_ID); m_Value = UpdateFunc2(m_ID);
@@ -113,13 +113,13 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_PluginName = parser.ReadString(section, L"Plugin", L""); m_PluginName = parser.ReadString(section, L"Plugin", L"");
size_t pos = m_PluginName.rfind(L"."); size_t pos = m_PluginName.rfind(L".");
if (pos == std::wstring::npos) if (pos == std::wstring::npos)
{ {
m_PluginName += L".dll"; m_PluginName += L".dll";
} }
pos = m_PluginName.rfind(L'\\'); pos = m_PluginName.rfind(L'\\');
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
m_PluginName.insert(0, L"..\\"); m_PluginName.insert(0, L"..\\");
} }
@@ -127,8 +127,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
DWORD err = 0; DWORD err = 0;
m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err); m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err);
if(m_Plugin == NULL) if (m_Plugin == NULL)
{ {
if (CRainmeter::GetDebug()) if (CRainmeter::GetDebug())
{ {
@@ -137,7 +137,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
// Try to load from Rainmeter's folder // Try to load from Rainmeter's folder
pos = m_PluginName.rfind(L'\\'); pos = m_PluginName.rfind(L'\\');
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1); std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1);
@@ -160,7 +160,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
throw CError(error, __LINE__, __FILE__); throw CError(error, __LINE__, __FILE__);
} }
} }
InitializeFunc = (INITIALIZE)GetProcAddress(m_Plugin, "Initialize"); InitializeFunc = (INITIALIZE)GetProcAddress(m_Plugin, "Initialize");
FinalizeFunc = (FINALIZE)GetProcAddress(m_Plugin, "Finalize"); FinalizeFunc = (FINALIZE)GetProcAddress(m_Plugin, "Finalize");
UpdateFunc = (UPDATE)GetProcAddress(m_Plugin, "Update"); UpdateFunc = (UPDATE)GetProcAddress(m_Plugin, "Update");
@@ -179,7 +179,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
// Initialize the plugin // Initialize the plugin
m_ID = id++; m_ID = id++;
if(InitializeFunc) if (InitializeFunc)
{ {
WCHAR buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buffer); GetCurrentDirectory(MAX_PATH, buffer);
@@ -200,13 +200,13 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
SetCurrentDirectory(buffer); SetCurrentDirectory(buffer);
std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet"); std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet");
if (szMaxValue == L"NotSet") if (szMaxValue == L"NotSet")
{ {
m_MaxValue = maxValue; m_MaxValue = maxValue;
} }
} }
if(m_MaxValue == 0) if (m_MaxValue == 0)
{ {
m_MaxValue = 1; m_MaxValue = 1;
m_LogMaxValue = true; m_LogMaxValue = true;
@@ -221,7 +221,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
*/ */
const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual) const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
{ {
if(GetStringFunc) if (GetStringFunc)
{ {
const WCHAR* ret = GetStringFunc(m_ID, 0); const WCHAR* ret = GetStringFunc(m_ID, 0);
if (ret) return CheckSubstitute(ret); if (ret) return CheckSubstitute(ret);

View File

@@ -42,7 +42,7 @@ CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name)
*/ */
CMeasureRegistry::~CMeasureRegistry() CMeasureRegistry::~CMeasureRegistry()
{ {
if(m_RegKey) RegCloseKey(m_RegKey); if (m_RegKey) RegCloseKey(m_RegKey);
} }
/* /*
@@ -55,13 +55,13 @@ bool CMeasureRegistry::Update()
{ {
if (!CMeasure::PreUpdate()) return false; if (!CMeasure::PreUpdate()) return false;
if(m_RegKey != NULL) if (m_RegKey != NULL)
{ {
DWORD size = 4096; DWORD size = 4096;
WCHAR* data = new WCHAR[size]; WCHAR* data = new WCHAR[size];
DWORD type = 0; DWORD type = 0;
if(RegQueryValueEx(m_RegKey, if (RegQueryValueEx(m_RegKey,
m_RegValueName.c_str(), m_RegValueName.c_str(),
NULL, NULL,
(LPDWORD)&type, (LPDWORD)&type,
@@ -120,31 +120,31 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
CMeasure::ReadConfig(parser, section); CMeasure::ReadConfig(parser, section);
const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER"); const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0) if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
{ {
m_HKey = HKEY_CLASSES_ROOT; m_HKey = HKEY_CLASSES_ROOT;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
{ {
m_HKey = HKEY_CURRENT_CONFIG; m_HKey = HKEY_CURRENT_CONFIG;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
{ {
m_HKey = HKEY_CURRENT_USER; m_HKey = HKEY_CURRENT_USER;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
{ {
m_HKey = HKEY_LOCAL_MACHINE; m_HKey = HKEY_LOCAL_MACHINE;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
{ {
m_HKey = HKEY_CLASSES_ROOT; m_HKey = HKEY_CLASSES_ROOT;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
{ {
m_HKey = HKEY_PERFORMANCE_DATA; m_HKey = HKEY_PERFORMANCE_DATA;
} }
else if(_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0) else if (_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
{ {
m_HKey = HKEY_DYN_DATA; m_HKey = HKEY_DYN_DATA;
} }
@@ -167,8 +167,8 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
// Try to open the key // Try to open the key
if(m_RegKey) RegCloseKey(m_RegKey); if (m_RegKey) RegCloseKey(m_RegKey);
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
} }
/* /*

View File

@@ -13,7 +13,7 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : C
m_pLuaScript(), m_pLuaScript(),
m_bUpdateDefined(false), m_bUpdateDefined(false),
m_bGetValueDefined(false), m_bGetValueDefined(false),
m_bGetStringValueDefined(false), m_bGetStringValueDefined(false),
m_bInitializeDefined(false) m_bInitializeDefined(false)
{ {
LuaManager::Init(); LuaManager::Init();
@@ -84,7 +84,7 @@ void CMeasureScript::SetValue(double d)
** **
** This method returns the value as text string. The actual value is ** This method returns the value as text string. The actual value is
** get with GetValue() so we don't have to worry about m_Invert. ** get with GetValue() so we don't have to worry about m_Invert.
** **
** autoScale If true, scale the value automatically to some sensible range. ** autoScale If true, scale the value automatically to some sensible range.
** scale The scale to use if autoScale is false. ** scale The scale to use if autoScale is false.
** decimals Number of decimals used in the value. ** decimals Number of decimals used in the value.
@@ -95,7 +95,7 @@ const WCHAR* CMeasureScript::GetStringValue(AUTOSCALE autoScale, double scale, i
if (m_bGetStringValueDefined && m_pLuaScript && m_pLuaScript->IsInitialized()) if (m_bGetStringValueDefined && m_pLuaScript && m_pLuaScript->IsInitialized())
{ {
m_strValue = m_pLuaScript->RunFunctionString(g_strGetStringValueFunction); m_strValue = m_pLuaScript->RunFunctionString(g_strGetStringValueFunction);
return CheckSubstitute(m_strValue.c_str()); return CheckSubstitute(m_strValue.c_str());
} }
@@ -106,7 +106,7 @@ static void stackDump(lua_State *L)
{ {
int i = lua_gettop(L); int i = lua_gettop(L);
LuaManager::LuaLog(LOG_DEBUG, " ---------------- Stack Dump ----------------" ); LuaManager::LuaLog(LOG_DEBUG, " ---------------- Stack Dump ----------------" );
while(i) while (i)
{ {
int t = lua_type(L, i); int t = lua_type(L, i);
switch (t) switch (t)
@@ -194,7 +194,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
lua_pushnil(L); lua_pushnil(L);
while(lua_next(L, -2)) while (lua_next(L, -2))
{ {
lua_pop(L, 1); lua_pop(L, 1);

View File

@@ -25,7 +25,7 @@ int GetYearDay(int year, int month, int day)
int yearDay = 0; int yearDay = 0;
UINT dates[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; UINT dates[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
for (int i = 0; i < month - 1; ++i) for (int i = 0; i < month - 1; ++i)
{ {
yearDay += dates[i]; yearDay += dates[i];
} }
@@ -51,8 +51,8 @@ CMeasureTime::CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name) : CMeas
m_Time() m_Time()
{ {
/* Set time zone from TZ environment variable. If TZ is not set, /* Set time zone from TZ environment variable. If TZ is not set,
* the operating system is queried to obtain the default value * the operating system is queried to obtain the default value
* for the variable. * for the variable.
*/ */
_tzset(); _tzset();
} }
@@ -174,7 +174,7 @@ const WCHAR* CMeasureTime::GetStringValue(AUTOSCALE autoScale, double scale, int
{ {
static WCHAR tmpSz[MAX_LINE_LENGTH]; static WCHAR tmpSz[MAX_LINE_LENGTH];
struct tm today; struct tm today;
tmpSz[0] = 0; tmpSz[0] = 0;
SYSTEMTIME sysToday; SYSTEMTIME sysToday;

View File

@@ -44,7 +44,7 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory()
/* /*
** Update ** Update
** **
** Updates the current virtual memory value. ** Updates the current virtual memory value.
** **
*/ */
bool CMeasureVirtualMemory::Update() bool CMeasureVirtualMemory::Update()

View File

@@ -139,7 +139,7 @@ int CMeter::GetX(bool abs)
} }
} }
} }
return m_X; return m_X;
} }
/* /*
@@ -187,7 +187,7 @@ int CMeter::GetY(bool abs)
} }
} }
} }
return m_Y; return m_Y;
} }
/* /*
@@ -262,7 +262,7 @@ void CMeter::Hide()
** ReadConfig ** ReadConfig
** **
** Reads the meter-specific configs from the ini-file. The base implementation ** Reads the meter-specific configs from the ini-file. The base implementation
** reads the common settings for all meters. The inherited classes must call ** reads the common settings for all meters. The inherited classes must call
** the base implementation if they overwrite this method. ** the base implementation if they overwrite this method.
** **
*/ */
@@ -453,9 +453,9 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
// Go through the list and check it there is a measure for us // Go through the list and check it there is a measure for us
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
if(_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0) if (_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
{ {
m_Measure = (*i); m_Measure = (*i);
return; return;
@@ -479,42 +479,42 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
*/ */
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name) CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name)
{ {
if(_wcsicmp(L"HISTOGRAM", meter) == 0) if (_wcsicmp(L"HISTOGRAM", meter) == 0)
{ {
return new CMeterHistogram(meterWindow, name); return new CMeterHistogram(meterWindow, name);
} }
else if(_wcsicmp(L"STRING", meter) == 0) else if (_wcsicmp(L"STRING", meter) == 0)
{ {
return new CMeterString(meterWindow, name); return new CMeterString(meterWindow, name);
} }
else if(_wcsicmp(L"BAR", meter) == 0) else if (_wcsicmp(L"BAR", meter) == 0)
{ {
return new CMeterBar(meterWindow, name); return new CMeterBar(meterWindow, name);
} }
else if(_wcsicmp(L"BITMAP", meter) == 0) else if (_wcsicmp(L"BITMAP", meter) == 0)
{ {
return new CMeterBitmap(meterWindow, name); return new CMeterBitmap(meterWindow, name);
} }
else if(_wcsicmp(L"IMAGE", meter) == 0) else if (_wcsicmp(L"IMAGE", meter) == 0)
{ {
return new CMeterImage(meterWindow, name); return new CMeterImage(meterWindow, name);
} }
else if(_wcsicmp(L"LINE", meter) == 0) else if (_wcsicmp(L"LINE", meter) == 0)
{ {
return new CMeterLine(meterWindow, name); return new CMeterLine(meterWindow, name);
} }
else if(_wcsicmp(L"ROUNDLINE", meter) == 0) else if (_wcsicmp(L"ROUNDLINE", meter) == 0)
{ {
return new CMeterRoundLine(meterWindow, name); return new CMeterRoundLine(meterWindow, name);
} }
else if(_wcsicmp(L"ROTATOR", meter) == 0) else if (_wcsicmp(L"ROTATOR", meter) == 0)
{ {
return new CMeterRotator(meterWindow, name); return new CMeterRotator(meterWindow, name);
} }
else if(_wcsicmp(L"BUTTON", meter) == 0) else if (_wcsicmp(L"BUTTON", meter) == 0)
{ {
return new CMeterButton(meterWindow, name); return new CMeterButton(meterWindow, name);
} }
// Error // Error
std::wstring error = L"Meter="; std::wstring error = L"Meter=";
@@ -566,7 +566,7 @@ void CMeter::SetAllMeasures(const std::vector<CMeasure*>& measures)
m_AllMeasures.push_back(m_Measure); m_AllMeasures.push_back(m_Measure);
std::vector<CMeasure*>::const_iterator i = measures.begin(); std::vector<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
m_AllMeasures.push_back(*i); m_AllMeasures.push_back(*i);
} }
@@ -583,7 +583,7 @@ void CMeter::ReadMeasureNames(CConfigParser& parser, const WCHAR* section, std::
int i = 2; int i = 2;
bool loop = true; bool loop = true;
do do
{ {
_snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i); _snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i);
const std::wstring& measure = parser.ReadString(section, tmpName, L""); const std::wstring& measure = parser.ReadString(section, tmpName, L"");
@@ -620,7 +620,7 @@ bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std:
size_t start = 0; size_t start = 0;
size_t pos = std::wstring::npos; size_t pos = std::wstring::npos;
do do
{ {
pos = str.find(buffer, start); pos = str.find(buffer, start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
@@ -646,7 +646,7 @@ void CMeter::ReplaceToolTipMeasures(std::wstring& str)
std::vector<std::wstring> stringValues; std::vector<std::wstring> stringValues;
if (!m_AllMeasures.empty()) if (!m_AllMeasures.empty())
{ {
// Get the values for the measures // Get the values for the measures
for (size_t i = 0, isize = m_AllMeasures.size(); i < isize; ++i) for (size_t i = 0, isize = m_AllMeasures.size(); i < isize; ++i)
{ {
@@ -683,7 +683,7 @@ void CMeter::CreateToolTip(CMeterWindow* meterWindow)
} }
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS, TOOLTIPS_CLASS,
NULL, NULL,
style, style,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -732,7 +732,7 @@ void CMeter::UpdateToolTip()
ti.lpszText = (PTSTR) text.c_str(); ti.lpszText = (PTSTR) text.c_str();
ti.rect = GetMeterRect(); ti.rect = GetMeterRect();
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti); SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, NULL, m_ToolTipWidth); SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, NULL, m_ToolTipWidth);
if (!m_ToolTipTitle.empty()) if (!m_ToolTipTitle.empty())
@@ -861,7 +861,7 @@ bool CMeter::Draw(Graphics& graphics)
Pen dark(darkColor); Pen dark(darkColor);
// The bevel is drawn outside the meter // The bevel is drawn outside the meter
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4); Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
DrawBevel(graphics, rect, light, dark); DrawBevel(graphics, rect, light, dark);
} }

View File

@@ -66,7 +66,7 @@ void CMeterBar::Initialize()
CMeter::Initialize(); CMeter::Initialize();
// Load the bitmaps if defined // Load the bitmaps if defined
if(!m_ImageName.empty()) if (!m_ImageName.empty())
{ {
m_Image.LoadImage(m_ImageName, m_NeedsReload); m_Image.LoadImage(m_ImageName, m_NeedsReload);
@@ -120,11 +120,11 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_Flip = parser.ReadInt(section, L"Flip", 0) == 1; m_Flip = parser.ReadInt(section, L"Flip", 0) == 1;
const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0) if (_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
{ {
m_Orientation = VERTICAL; m_Orientation = VERTICAL;
} }
else if(_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0) else if (_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
{ {
m_Orientation = HORIZONTAL; m_Orientation = HORIZONTAL;
} }
@@ -179,23 +179,23 @@ bool CMeterBar::Update()
*/ */
bool CMeterBar::Draw(Graphics& graphics) bool CMeterBar::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
int x = GetX(); int x = GetX();
int y = GetY(); int y = GetY();
Bitmap* drawBitmap = m_Image.GetImage(); Bitmap* drawBitmap = m_Image.GetImage();
if(m_Orientation == VERTICAL) if (m_Orientation == VERTICAL)
{ {
int barSize = m_H - 2 * m_Border; int barSize = m_H - 2 * m_Border;
int size = (int)(barSize * m_Value); int size = (int)(barSize * m_Value);
size = min(barSize, size); size = min(barSize, size);
size = max(0, size); size = max(0, size);
if (drawBitmap) if (drawBitmap)
{ {
if (m_Flip) if (m_Flip)
{ {
if (m_Border > 0) if (m_Border > 0)
{ {
@@ -227,7 +227,7 @@ bool CMeterBar::Draw(Graphics& graphics)
else else
{ {
SolidBrush brush(m_Color); SolidBrush brush(m_Color);
if (m_Flip) if (m_Flip)
{ {
Rect r(x, y, m_W, size); Rect r(x, y, m_W, size);
graphics.FillRectangle(&brush, r); graphics.FillRectangle(&brush, r);
@@ -248,7 +248,7 @@ bool CMeterBar::Draw(Graphics& graphics)
if (drawBitmap) if (drawBitmap)
{ {
if (m_Flip) if (m_Flip)
{ {
if (m_Border > 0) if (m_Border > 0)
{ {
@@ -280,7 +280,7 @@ bool CMeterBar::Draw(Graphics& graphics)
else else
{ {
SolidBrush brush(m_Color); SolidBrush brush(m_Color);
if (m_Flip) if (m_Flip)
{ {
Rect r(x + m_W - size, y, size, m_H); Rect r(x + m_W - size, y, size, m_H);
graphics.FillRectangle(&brush, r); graphics.FillRectangle(&brush, r);

View File

@@ -69,7 +69,7 @@ void CMeterBitmap::Initialize()
CMeter::Initialize(); CMeter::Initialize();
// Load the bitmaps if defined // Load the bitmaps if defined
if(!m_ImageName.empty()) if (!m_ImageName.empty())
{ {
m_Image.LoadImage(m_ImageName, m_NeedsReload); m_Image.LoadImage(m_ImageName, m_NeedsReload);
@@ -80,7 +80,7 @@ void CMeterBitmap::Initialize()
m_W = bitmap->GetWidth(); m_W = bitmap->GetWidth();
m_H = bitmap->GetHeight(); m_H = bitmap->GetHeight();
if(m_H > m_W) if (m_H > m_W)
{ {
m_H = m_H / m_FrameCount; m_H = m_H / m_FrameCount;
} }
@@ -195,15 +195,15 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
if(_wcsicmp(align.c_str(), L"LEFT") == 0) if (_wcsicmp(align.c_str(), L"LEFT") == 0)
{ {
m_Align = ALIGN_LEFT; m_Align = ALIGN_LEFT;
} }
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0) else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
{ {
m_Align = ALIGN_RIGHT; m_Align = ALIGN_RIGHT;
} }
else if(_wcsicmp(align.c_str(), L"CENTER") == 0) else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
{ {
m_Align = ALIGN_CENTER; m_Align = ALIGN_CENTER;
} }
@@ -290,11 +290,11 @@ bool CMeterBitmap::HasActiveTransition()
*/ */
bool CMeterBitmap::Draw(Graphics& graphics) bool CMeterBitmap::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
int newY, newX; int newY, newX;
if(m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
Bitmap* bitmap = m_Image.GetImage(); Bitmap* bitmap = m_Image.GetImage();
@@ -383,7 +383,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false"); // LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
if(bitmap->GetHeight() > bitmap->GetWidth()) if (bitmap->GetHeight() > bitmap->GetWidth())
{ {
newX = 0; newX = 0;
newY = m_H * frame; newY = m_H * frame;
@@ -449,7 +449,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false"); // LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
if(bitmap->GetHeight() > bitmap->GetWidth()) if (bitmap->GetHeight() > bitmap->GetWidth())
{ {
newX = 0; newX = 0;
newY = frame * m_H; newY = frame * m_H;

View File

@@ -83,7 +83,7 @@ void CMeterButton::Initialize()
} }
// Load the bitmaps if defined // Load the bitmaps if defined
if(!m_ImageName.empty()) if (!m_ImageName.empty())
{ {
m_Image.LoadImage(m_ImageName, m_NeedsReload); m_Image.LoadImage(m_ImageName, m_NeedsReload);
@@ -94,7 +94,7 @@ void CMeterButton::Initialize()
m_W = bitmap->GetWidth(); m_W = bitmap->GetWidth();
m_H = bitmap->GetHeight(); m_H = bitmap->GetHeight();
if(m_H > m_W) if (m_H > m_W)
{ {
m_H = m_H / BUTTON_FRAMES; m_H = m_H / BUTTON_FRAMES;
} }
@@ -112,7 +112,7 @@ void CMeterButton::Initialize()
Graphics graphics(&bitmapPart); Graphics graphics(&bitmapPart);
Rect r(0, 0, m_W, m_H); Rect r(0, 0, m_W, m_H);
if(bitmap->GetHeight() > bitmap->GetWidth()) if (bitmap->GetHeight() > bitmap->GetWidth())
{ {
graphics.DrawImage(bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel); graphics.DrawImage(bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel);
} }
@@ -198,7 +198,7 @@ bool CMeterButton::Update()
*/ */
bool CMeterButton::Draw(Graphics& graphics) bool CMeterButton::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
if (m_Bitmaps[m_State] == NULL) return false; // Unable to continue if (m_Bitmaps[m_State] == NULL) return false; // Unable to continue
@@ -207,7 +207,7 @@ bool CMeterButton::Draw(Graphics& graphics)
// Blit the image // Blit the image
graphics.DrawCachedBitmap(m_Bitmaps[m_State], x, y); graphics.DrawCachedBitmap(m_Bitmaps[m_State], x, y);
return true; return true;
} }

View File

@@ -109,7 +109,7 @@ void CMeterHistogram::Initialize()
// A sanity check // A sanity check
if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty())) if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty()))
{ {
Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!"); Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!");
m_PrimaryImage.DisposeImage(); m_PrimaryImage.DisposeImage();
m_SecondaryImage.DisposeImage(); m_SecondaryImage.DisposeImage();
@@ -385,7 +385,7 @@ bool CMeterHistogram::Update()
*/ */
bool CMeterHistogram::Draw(Graphics& graphics) bool CMeterHistogram::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics) || if (!CMeter::Draw(graphics) ||
(m_Measure && !m_PrimaryValues) || (m_Measure && !m_PrimaryValues) ||
(m_SecondaryMeasure && !m_SecondaryValues)) return false; (m_SecondaryMeasure && !m_SecondaryValues)) return false;
@@ -517,13 +517,13 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
{ {
CMeter::BindMeasure(measures); CMeter::BindMeasure(measures);
if(!m_SecondaryMeasureName.empty()) if (!m_SecondaryMeasureName.empty())
{ {
// Go through the list and check it there is a secondary measure for us // Go through the list and check it there is a secondary measure for us
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0) if (_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
{ {
m_SecondaryMeasure = (*i); m_SecondaryMeasure = (*i);
CMeter::SetAllMeasures(m_SecondaryMeasure); CMeter::SetAllMeasures(m_SecondaryMeasure);
@@ -535,6 +535,6 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += m_SecondaryMeasureName; error += m_SecondaryMeasureName;
error += L"]!"; error += L"]!";
throw CError(error, __LINE__, __FILE__); throw CError(error, __LINE__, __FILE__);
} }
} }

View File

@@ -228,7 +228,7 @@ bool CMeterImage::Update()
*/ */
bool CMeterImage::Draw(Graphics& graphics) bool CMeterImage::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
if (m_Image.IsLoaded()) if (m_Image.IsLoaded())
{ {
@@ -284,9 +284,9 @@ bool CMeterImage::Draw(Graphics& graphics)
{ {
const RECT m = m_ScaleMargins; const RECT m = m_ScaleMargins;
if (m.top > 0) if (m.top > 0)
{ {
if (m.left > 0) if (m.left > 0)
{ {
// Top-Left // Top-Left
Rect r(x, y, m.left, m.top); Rect r(x, y, m.left, m.top);
@@ -297,7 +297,7 @@ bool CMeterImage::Draw(Graphics& graphics)
Rect r(x + m.left, y, drawW - m.left - m.right, m.top); Rect r(x + m.left, y, drawW - m.left - m.right, m.top);
graphics.DrawImage(drawBitmap, r, m.left, 0, imageW - m.left - m.right, m.top, UnitPixel); graphics.DrawImage(drawBitmap, r, m.left, 0, imageW - m.left - m.right, m.top, UnitPixel);
if (m.right > 0) if (m.right > 0)
{ {
// Top-Right // Top-Right
Rect r(x + drawW - m.right, y, m.right, m.top); Rect r(x + drawW - m.right, y, m.right, m.top);
@@ -305,7 +305,7 @@ bool CMeterImage::Draw(Graphics& graphics)
} }
} }
if (m.left > 0) if (m.left > 0)
{ {
// Left // Left
Rect r(x, y + m.top, m.left, drawH - m.top - m.bottom); Rect r(x, y + m.top, m.left, drawH - m.top - m.bottom);
@@ -316,16 +316,16 @@ bool CMeterImage::Draw(Graphics& graphics)
Rect r(x + m.left, y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom); Rect r(x + m.left, y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom);
graphics.DrawImage(drawBitmap, r, m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom, UnitPixel); graphics.DrawImage(drawBitmap, r, m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom, UnitPixel);
if (m.right > 0) if (m.right > 0)
{ {
// Right // Right
Rect r(x + drawW - m.right, y + m.top, m.right, drawH - m.top - m.bottom); Rect r(x + drawW - m.right, y + m.top, m.right, drawH - m.top - m.bottom);
graphics.DrawImage(drawBitmap, r, imageW - m.right, m.top, m.right, imageH - m.top - m.bottom, UnitPixel); graphics.DrawImage(drawBitmap, r, imageW - m.right, m.top, m.right, imageH - m.top - m.bottom, UnitPixel);
} }
if (m.bottom > 0) if (m.bottom > 0)
{ {
if (m.left > 0) if (m.left > 0)
{ {
// Bottom-Left // Bottom-Left
Rect r(x, y + drawH - m.bottom, m.left, m.bottom); Rect r(x, y + drawH - m.bottom, m.left, m.bottom);
@@ -336,7 +336,7 @@ bool CMeterImage::Draw(Graphics& graphics)
Rect r(x + m.left, y + drawH - m.bottom, drawW - m.left - m.right, m.bottom); Rect r(x + m.left, y + drawH - m.bottom, drawW - m.left - m.right, m.bottom);
graphics.DrawImage(drawBitmap, r, m.left, imageH - m.bottom, imageW - m.left - m.right, m.bottom, UnitPixel); graphics.DrawImage(drawBitmap, r, m.left, imageH - m.bottom, imageW - m.left - m.right, m.bottom, UnitPixel);
if (m.right > 0) if (m.right > 0)
{ {
// Bottom-Right // Bottom-Right
Rect r(x + drawW - m.right, y + drawH - m.bottom, m.right, m.bottom); Rect r(x + drawW - m.right, y + drawH - m.bottom, m.right, m.bottom);
@@ -366,9 +366,9 @@ void CMeterImage::BindMeasure(const std::list<CMeasure*>& measures)
{ {
// Go through the list and check it there is a secondary measures for us // Go through the list and check it there is a secondary measures for us
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
{ {
m_Measures.push_back(*i); m_Measures.push_back(*i);
break; break;

View File

@@ -208,7 +208,7 @@ bool CMeterLine::Update()
*/ */
bool CMeterLine::Draw(Graphics& graphics) bool CMeterLine::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics) || m_W == 0) return false; if (!CMeter::Draw(graphics) || m_W == 0) return false;
double maxValue = 0.0; double maxValue = 0.0;
int counter = 0; int counter = 0;
@@ -264,7 +264,7 @@ bool CMeterLine::Draw(Graphics& graphics)
maxValue = 1.0; maxValue = 1.0;
} }
} }
int x = GetX(); int x = GetX();
int y = GetY(); int y = GetY();
@@ -277,7 +277,7 @@ bool CMeterLine::Draw(Graphics& graphics)
// Check the highest power of 2 that fits in maxLines // Check the highest power of 2 that fits in maxLines
int power = 2; int power = 2;
while(power < maxLines) while (power < maxLines)
{ {
power *= 2; power *= 2;
} }
@@ -362,22 +362,22 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
{ {
// Go through the list and check it there is a secondary measure for us // Go through the list and check it there is a secondary measure for us
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
{ {
m_Measures.push_back(*i); m_Measures.push_back(*i);
break; break;
} }
} }
if (i == measures.end()) if (i == measures.end())
{ {
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += (*j); error += (*j);
error += L"]!"; error += L"]!";
throw CError(error, __LINE__, __FILE__); throw CError(error, __LINE__, __FILE__);
} }
} }
CMeter::SetAllMeasures(m_Measures); CMeter::SetAllMeasures(m_Measures);

View File

@@ -65,7 +65,7 @@ void CMeterRotator::Initialize()
CMeter::Initialize(); CMeter::Initialize();
// Load the bitmaps if defined // Load the bitmaps if defined
if(!m_ImageName.empty()) if (!m_ImageName.empty())
{ {
m_Image.LoadImage(m_ImageName, m_NeedsReload); m_Image.LoadImage(m_ImageName, m_NeedsReload);
} }
@@ -157,7 +157,7 @@ bool CMeterRotator::Update()
*/ */
bool CMeterRotator::Draw(Graphics& graphics) bool CMeterRotator::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
if (m_Image.IsLoaded()) if (m_Image.IsLoaded())
{ {

View File

@@ -73,7 +73,7 @@ void CMeterRoundLine::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0); m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0);
m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0); m_LineStart = parser.ReadFormula(section, L"LineStart", -1.0);
m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
@@ -123,7 +123,7 @@ bool CMeterRoundLine::Update()
*/ */
bool CMeterRoundLine::Draw(Graphics& graphics) bool CMeterRoundLine::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
// Calculate the center of for the line // Calculate the center of for the line
int x = GetX(); int x = GetX();
@@ -154,14 +154,14 @@ bool CMeterRoundLine::Draw(Graphics& graphics)
REAL s_sin = (REAL)sin(m_StartAngle); REAL s_sin = (REAL)sin(m_StartAngle);
REAL e_cos = (REAL)cos(angle); REAL e_cos = (REAL)cos(angle);
REAL e_sin = (REAL)sin(angle); REAL e_sin = (REAL)sin(angle);
//Create a path to surround the arc //Create a path to surround the arc
GraphicsPath path; GraphicsPath path;
path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle); path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle);
path.AddLine((REAL)lineStart * s_cos + cx, (REAL)lineStart * s_sin + cy, (REAL)lineLength * s_cos + cx, (REAL)lineLength * s_sin + cy); path.AddLine((REAL)lineStart * s_cos + cx, (REAL)lineStart * s_sin + cy, (REAL)lineLength * s_cos + cx, (REAL)lineLength * s_sin + cy);
path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle); path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle);
path.AddLine((REAL)lineLength * e_cos + cx, (REAL)lineLength * e_sin + cy, (REAL)lineStart * e_cos + cx, (REAL)lineStart * e_sin + cy); path.AddLine((REAL)lineLength * e_cos + cx, (REAL)lineLength * e_sin + cy, (REAL)lineStart * e_cos + cx, (REAL)lineStart * e_sin + cy);
graphics.FillPath(&solidBrush, &path); graphics.FillPath(&solidBrush, &path);
} }
else else

View File

@@ -107,7 +107,7 @@ int CMeterString::GetX(bool abs)
{ {
int x = CMeter::GetX(); int x = CMeter::GetX();
if (!abs) if (!abs)
{ {
switch(m_Align) switch(m_Align)
{ {
@@ -199,7 +199,7 @@ void CMeterString::Initialize()
// It couldn't find the font family: Log it. // It couldn't find the font family: Log it.
if (Ok != status) if (Ok != status)
{ {
std::wstring error = L"Unable to load font family: " + m_FontFace; std::wstring error = L"Unable to load font family: " + m_FontFace;
Log(LOG_ERROR, error.c_str()); Log(LOG_ERROR, error.c_str());
@@ -259,7 +259,7 @@ void CMeterString::Initialize()
} }
else else
{ {
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style); m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif (), size, style);
} }
Status status = m_Font->GetLastStatus(); Status status = m_Font->GetLastStatus();
@@ -361,15 +361,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_Scale = wcstod(scale.c_str(), NULL); m_Scale = wcstod(scale.c_str(), NULL);
const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT"); const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT");
if(_wcsicmp(align.c_str(), L"LEFT") == 0) if (_wcsicmp(align.c_str(), L"LEFT") == 0)
{ {
m_Align = ALIGN_LEFT; m_Align = ALIGN_LEFT;
} }
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0) else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
{ {
m_Align = ALIGN_RIGHT; m_Align = ALIGN_RIGHT;
} }
else if(_wcsicmp(align.c_str(), L"CENTER") == 0) else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
{ {
m_Align = ALIGN_CENTER; m_Align = ALIGN_CENTER;
} }
@@ -383,19 +383,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE"); const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE");
if(_wcsicmp(stringCase.c_str(), L"NONE") == 0) if (_wcsicmp(stringCase.c_str(), L"NONE") == 0)
{ {
m_textCase = TEXTCASE_NONE; m_textCase = TEXTCASE_NONE;
} }
else if(_wcsicmp(stringCase.c_str(), L"UPPER") == 0) else if (_wcsicmp(stringCase.c_str(), L"UPPER") == 0)
{ {
m_textCase = TEXTCASE_UPPER; m_textCase = TEXTCASE_UPPER;
} }
else if(_wcsicmp(stringCase.c_str(), L"LOWER") == 0) else if (_wcsicmp(stringCase.c_str(), L"LOWER") == 0)
{ {
m_textCase = TEXTCASE_LOWER; m_textCase = TEXTCASE_LOWER;
} }
else if(_wcsicmp(stringCase.c_str(), L"PROPER") == 0) else if (_wcsicmp(stringCase.c_str(), L"PROPER") == 0)
{ {
m_textCase = TEXTCASE_PROPER; m_textCase = TEXTCASE_PROPER;
} }
@@ -409,19 +409,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL"); const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL");
if(_wcsicmp(style.c_str(), L"NORMAL") == 0) if (_wcsicmp(style.c_str(), L"NORMAL") == 0)
{ {
m_Style = NORMAL; m_Style = NORMAL;
} }
else if(_wcsicmp(style.c_str(), L"BOLD") == 0) else if (_wcsicmp(style.c_str(), L"BOLD") == 0)
{ {
m_Style = BOLD; m_Style = BOLD;
} }
else if(_wcsicmp(style.c_str(), L"ITALIC") == 0) else if (_wcsicmp(style.c_str(), L"ITALIC") == 0)
{ {
m_Style = ITALIC; m_Style = ITALIC;
} }
else if(_wcsicmp(style.c_str(), L"BOLDITALIC") == 0) else if (_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
{ {
m_Style = BOLDITALIC; m_Style = BOLDITALIC;
} }
@@ -435,15 +435,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE"); const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE");
if(_wcsicmp(effect.c_str(), L"NONE") == 0) if (_wcsicmp(effect.c_str(), L"NONE") == 0)
{ {
m_Effect = EFFECT_NONE; m_Effect = EFFECT_NONE;
} }
else if(_wcsicmp(effect.c_str(), L"SHADOW") == 0) else if (_wcsicmp(effect.c_str(), L"SHADOW") == 0)
{ {
m_Effect = EFFECT_SHADOW; m_Effect = EFFECT_SHADOW;
} }
else if(_wcsicmp(effect.c_str(), L"BORDER") == 0) else if (_wcsicmp(effect.c_str(), L"BORDER") == 0)
{ {
m_Effect = EFFECT_BORDER; m_Effect = EFFECT_BORDER;
} }
@@ -498,7 +498,7 @@ bool CMeterString::Update()
{ {
if (!stringValues.empty()) if (!stringValues.empty())
{ {
m_String += stringValues[0]; m_String += stringValues[0];
} }
} }
else if (!stringValues.empty()) else if (!stringValues.empty())
@@ -556,7 +556,7 @@ bool CMeterString::Update()
*/ */
bool CMeterString::Draw(Graphics& graphics) bool CMeterString::Draw(Graphics& graphics)
{ {
if(!CMeter::Draw(graphics)) return false; if (!CMeter::Draw(graphics)) return false;
return DrawString(graphics, NULL); return DrawString(graphics, NULL);
} }
@@ -572,7 +572,7 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
if (m_Font == NULL) return false; if (m_Font == NULL) return false;
StringFormat stringFormat; StringFormat stringFormat;
if (m_AntiAlias) if (m_AntiAlias)
{ {
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias); graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
@@ -650,7 +650,7 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
rcEffect.Offset(-1, 1); rcEffect.Offset(-1, 1);
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush); graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush);
} }
SolidBrush solidBrush(m_Color); SolidBrush solidBrush(m_Color);
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, m_Rect, &stringFormat, &solidBrush); graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, m_Rect, &stringFormat, &solidBrush);
@@ -680,9 +680,9 @@ void CMeterString::BindMeasure(const std::list<CMeasure*>& measures)
{ {
// Go through the list and check it there is a secondary measures for us // Go through the list and check it there is a secondary measures for us
std::list<CMeasure*>::const_iterator i = measures.begin(); std::list<CMeasure*>::const_iterator i = measures.begin();
for( ; i != measures.end(); ++i) for ( ; i != measures.end(); ++i)
{ {
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
{ {
m_Measures.push_back(*i); m_Measures.push_back(*i);
break; break;

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
endPos = spacePos; endPos = spacePos;
} }
std::wstring newStr = arg.substr(0, endPos); std::wstring newStr = arg.substr(0, endPos);
arg.erase(0, endPos + 1); arg.erase(0, endPos + 1);
if (newStr.size() > 0 || quotePos == 0) if (newStr.size() > 0 || quotePos == 0)
@@ -105,7 +105,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
return result; return result;
} }
/* /*
** initModuleEx ** initModuleEx
** **
@@ -115,18 +115,18 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath) int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
{ {
int Result=1; int Result=1;
try try
{ {
Rainmeter=new CRainmeter; Rainmeter=new CRainmeter;
if(Rainmeter) if (Rainmeter)
{ {
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath); Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath);
} }
} }
catch(CError& error) catch(CError& error)
{ {
MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
@@ -142,7 +142,7 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
*/ */
void quitModule(HINSTANCE dllInst) void quitModule(HINSTANCE dllInst)
{ {
if(Rainmeter) if (Rainmeter)
{ {
Rainmeter->Quit(dllInst); Rainmeter->Quit(dllInst);
delete Rainmeter; delete Rainmeter;
@@ -162,7 +162,7 @@ void Initialize(bool DummyLS, LPCTSTR CmdLine)
CRainmeter::SetCommandLine(CmdLine); CRainmeter::SetCommandLine(CmdLine);
} }
/* /*
** ExecuteBang ** ExecuteBang
** **
** Runs a bang command. This is called from the main application ** Runs a bang command. This is called from the main application
@@ -188,14 +188,14 @@ void ExecuteBang(LPCTSTR szBang)
*/ */
LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue) LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue)
{ {
if (Rainmeter) if (Rainmeter)
{ {
CConfigParser* parser = Rainmeter->GetCurrentParser(); CConfigParser* parser = Rainmeter->GetCurrentParser();
if (parser) if (parser)
{ {
return parser->ReadString(section, key, defValue, false).c_str(); return parser->ReadString(section, key, defValue, false).c_str();
} }
} }
return NULL; return NULL;
} }
@@ -210,7 +210,7 @@ LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue)
*/ */
LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData) LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
{ {
if (Rainmeter) if (Rainmeter)
{ {
static std::wstring result; static std::wstring result;
@@ -359,7 +359,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
} }
return L"noop"; return L"noop";
} }
return L"error:no rainmeter!"; return L"error:no rainmeter!";
} }
@@ -372,7 +372,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
*/ */
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs) void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs)
{ {
if(Rainmeter) if (Rainmeter)
{ {
std::vector<std::wstring> subStrings = CRainmeter::ParseString(arg); std::vector<std::wstring> subStrings = CRainmeter::ParseString(arg);
size_t subStringsSize = subStrings.size(); size_t subStringsSize = subStrings.size();
@@ -1397,7 +1397,7 @@ void RainmeterTrayMenuWide()
*/ */
void RainmeterResetStatsWide() void RainmeterResetStatsWide()
{ {
if (Rainmeter) if (Rainmeter)
{ {
Rainmeter->ResetStats(); Rainmeter->ResetStats();
} }
@@ -1486,7 +1486,7 @@ void RainmeterWriteKeyValueWide(const WCHAR* arg)
{ {
double value; double value;
formula = mw->GetParser().ReadFormula(strValue, &value); formula = mw->GetParser().ReadFormula(strValue, &value);
// Formula read fine // Formula read fine
if (formula != -1) if (formula != -1)
{ {
@@ -1565,7 +1565,7 @@ void RainmeterQuitWide()
GlobalConfig CRainmeter::c_GlobalConfig = {0}; GlobalConfig CRainmeter::c_GlobalConfig = {0};
bool CRainmeter::c_Debug = false; bool CRainmeter::c_Debug = false;
/* /*
** CRainmeter ** CRainmeter
** **
** Constructor ** Constructor
@@ -1593,12 +1593,12 @@ CRainmeter::CRainmeter() :
INITCOMMONCONTROLSEX initCtrls = {sizeof(INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES}; INITCOMMONCONTROLSEX initCtrls = {sizeof(INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES};
InitCommonControlsEx(&initCtrls); InitCommonControlsEx(&initCtrls);
// Initialize GDI+. // Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput; GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL); GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL);
} }
/* /*
** ~CRainmeter ** ~CRainmeter
** **
** Destructor ** Destructor
@@ -1633,7 +1633,7 @@ CRainmeter::~CRainmeter()
GdiplusShutdown(m_GDIplusToken); GdiplusShutdown(m_GDIplusToken);
} }
/* /*
** Initialize ** Initialize
** **
** The main initialization function for the module. ** The main initialization function for the module.
@@ -1644,10 +1644,10 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{ {
int Result=0; int Result=0;
if(Parent==NULL || Instance==NULL) if (Parent==NULL || Instance==NULL)
{ {
throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__); throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__);
} }
m_Instance = Instance; m_Instance = Instance;
@@ -1656,18 +1656,18 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
// Remove the module's name from the path // Remove the module's name from the path
WCHAR* pos = wcsrchr(tmpSzPath, L'\\'); WCHAR* pos = wcsrchr(tmpSzPath, L'\\');
if(pos) if (pos)
{ {
*(pos + 1) = L'\0'; *(pos + 1) = L'\0';
} }
else else
{ {
tmpSzPath[0] = L'\0'; tmpSzPath[0] = L'\0';
} }
m_Path = tmpSzPath; m_Path = tmpSzPath;
if(!c_DummyLitestep) InitalizeLitestep(); if (!c_DummyLitestep) InitalizeLitestep();
bool bDefaultIniLocation = false; bool bDefaultIniLocation = false;
@@ -1761,7 +1761,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
// Read the skin folder from the ini file // Read the skin folder from the ini file
tmpSzPath[0] = L'\0'; tmpSzPath[0] = L'\0';
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0) if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
{ {
m_SkinPath = tmpSzPath; m_SkinPath = tmpSzPath;
ExpandEnvironmentVariables(m_SkinPath); ExpandEnvironmentVariables(m_SkinPath);
@@ -1901,7 +1901,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
ScanForConfigs(m_SkinPath); ScanForConfigs(m_SkinPath);
ScanForThemes(GetSettingsPath() + L"Themes"); ScanForThemes(GetSettingsPath() + L"Themes");
if(m_ConfigStrings.empty()) if (m_ConfigStrings.empty())
{ {
std::wstring error = L"There are no available skins at:\n" + m_SkinPath; std::wstring error = L"There are no available skins at:\n" + m_SkinPath;
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR); MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
@@ -1926,7 +1926,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
} }
// If we're running as Litestep's plugin, register the !bangs // If we're running as Litestep's plugin, register the !bangs
if(!c_DummyLitestep) if (!c_DummyLitestep)
{ {
int Msgs[] = { LM_GETREVID, 0 }; int Msgs[] = { LM_GETREVID, 0 };
// Register RevID message to Litestep // Register RevID message to Litestep
@@ -2013,7 +2013,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
return Result; // Alles OK return Result; // Alles OK
} }
/* /*
** CheckSkinVersions ** CheckSkinVersions
** **
** Checks if any of the skins in the program folder are newer than in the skin folder. ** Checks if any of the skins in the program folder are newer than in the skin folder.
@@ -2143,7 +2143,7 @@ void CRainmeter::CheckSkinVersions()
} }
} }
/* /*
** CompareVersions ** CompareVersions
** **
** Compares two version strings. Returns 0 if they are equal, 1 if A > B and -1 if A < B. ** Compares two version strings. Returns 0 if they are equal, 1 if A > B and -1 if A < B.
@@ -2159,7 +2159,7 @@ int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& st
std::vector<std::wstring> arrayB = CConfigParser::Tokenize(strB, L"."); std::vector<std::wstring> arrayB = CConfigParser::Tokenize(strB, L".");
size_t arrayASize = arrayA.size(); size_t arrayASize = arrayA.size();
size_t arrayBSize = arrayB.size(); size_t arrayBSize = arrayB.size();
size_t len = max(arrayASize, arrayBSize); size_t len = max(arrayASize, arrayBSize);
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
{ {
@@ -2181,7 +2181,7 @@ int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& st
return 0; return 0;
} }
/* /*
** CreateDefaultConfigFile ** CreateDefaultConfigFile
** **
** Creates the default Rainmeter.ini file. ** Creates the default Rainmeter.ini file.
@@ -2202,7 +2202,7 @@ void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile)
{ {
// The default.ini wasn't found -> create new // The default.ini wasn't found -> create new
std::ofstream out(strFile.c_str(), std::ios::out); std::ofstream out(strFile.c_str(), std::ios::out);
if (out) if (out)
{ {
out << std::string("[Rainmeter]\n\n[illustro\\System]\nActive=1\n"); out << std::string("[Rainmeter]\n\n[illustro\\System]\nActive=1\n");
out.close(); out.close();
@@ -2264,11 +2264,11 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
m_ConfigStrings[configIndex].active = iniIndex + 1; m_ConfigStrings[configIndex].active = iniIndex + 1;
WriteActive(skinConfig, iniIndex); WriteActive(skinConfig, iniIndex);
try try
{ {
CreateMeterWindow(skinPath, skinConfig, skinIniFile); CreateMeterWindow(skinPath, skinConfig, skinIniFile);
} }
catch(CError& error) catch(CError& error)
{ {
MessageBox(NULL, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(NULL, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
@@ -2375,7 +2375,7 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater)
{ {
// Delete all meter windows // Delete all meter windows
delete (*iter).second; delete (*iter).second;
} }
else if ((*iter).second == meterWindow) else if ((*iter).second == meterWindow)
{ {
m_Meters.erase(iter); m_Meters.erase(iter);
@@ -2525,7 +2525,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
return 0; return 0;
} }
/* /*
** Quit ** Quit
** **
** Called when the module quits ** Called when the module quits
@@ -2534,7 +2534,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
void CRainmeter::Quit(HINSTANCE dllInst) void CRainmeter::Quit(HINSTANCE dllInst)
{ {
// If we're running as Litestep's plugin, unregister the !bangs // If we're running as Litestep's plugin, unregister the !bangs
if(!c_DummyLitestep) if (!c_DummyLitestep)
{ {
int Msgs[] = { LM_GETREVID, 0 }; int Msgs[] = { LM_GETREVID, 0 };
// Unregister RevID message // Unregister RevID message
@@ -2608,7 +2608,7 @@ void CRainmeter::Quit(HINSTANCE dllInst)
} }
} }
/* /*
** ScanForConfigs ** ScanForConfigs
** **
** Scans all the subfolders and locates the ini-files. ** Scans all the subfolders and locates the ini-files.
@@ -2624,10 +2624,10 @@ void CRainmeter::ScanForConfigs(const std::wstring& path)
int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse) int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse)
{ {
WIN32_FIND_DATA fileData; // Data structure describes the file found WIN32_FIND_DATA fileData; // Data structure describes the file found
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
HANDLE hSearch; // Search handle returned by FindFirstFile HANDLE hSearch; // Search handle returned by FindFirstFile
HANDLE hSearchIni; // Search handle returned by FindFirstFile HANDLE hSearchIni; // Search handle returned by FindFirstFile
if (!base.empty()) if (!base.empty())
{ {
@@ -2644,7 +2644,7 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
do do
{ {
if(hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found if (hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found
// Check whether the extension is ".ini" // Check whether the extension is ".ini"
std::wstring ext = fileDataIni.cFileName; std::wstring ext = fileDataIni.cFileName;
@@ -2673,12 +2673,12 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
// Scan for folders // Scan for folders
std::wstring files = path + base; std::wstring files = path + base;
files += L"*"; files += L"*";
hSearch = FindFirstFile(files.c_str(), &fileData); hSearch = FindFirstFile(files.c_str(), &fileData);
do do
{ {
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
!(wcscmp(L"Backup", fileData.cFileName) == 0 && base.empty()) && // Skip the backup folder !(wcscmp(L"Backup", fileData.cFileName) == 0 && base.empty()) && // Skip the backup folder
wcscmp(L".", fileData.cFileName) != 0 && wcscmp(L".", fileData.cFileName) != 0 &&
wcscmp(L"..", fileData.cFileName) != 0) wcscmp(L"..", fileData.cFileName) != 0)
@@ -2702,12 +2702,12 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
} }
} while(FindNextFile(hSearch, &fileData)); } while(FindNextFile(hSearch, &fileData));
FindClose(hSearch); FindClose(hSearch);
return index; return index;
} }
/* /*
** ScanForThemes ** ScanForThemes
** **
** Scans the given folder for themes ** Scans the given folder for themes
@@ -2717,16 +2717,16 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
m_Themes.clear(); m_Themes.clear();
WIN32_FIND_DATA fileData; // Data structure describes the file found WIN32_FIND_DATA fileData; // Data structure describes the file found
HANDLE hSearch; // Search handle returned by FindFirstFile HANDLE hSearch; // Search handle returned by FindFirstFile
// Scan for folders // Scan for folders
std::wstring folders = path + L"\\*"; std::wstring folders = path + L"\\*";
hSearch = FindFirstFile(folders.c_str(), &fileData); hSearch = FindFirstFile(folders.c_str(), &fileData);
do do
{ {
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
wcscmp(L".", fileData.cFileName) != 0 && wcscmp(L".", fileData.cFileName) != 0 &&
wcscmp(L"..", fileData.cFileName) != 0) wcscmp(L"..", fileData.cFileName) != 0)
{ {
@@ -2734,7 +2734,7 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
} }
} while(FindNextFile(hSearch, &fileData)); } while(FindNextFile(hSearch, &fileData));
FindClose(hSearch); FindClose(hSearch);
} }
void CRainmeter::SaveSettings() void CRainmeter::SaveSettings()
@@ -3076,11 +3076,11 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
} }
else else
{ {
if (meterWindow) if (meterWindow)
{ {
const std::list<CMeasure*>& measures = meterWindow->GetMeasures(); const std::list<CMeasure*>& measures = meterWindow->GetMeasures();
std::list<CMeasure*>::const_iterator iter = measures.begin(); std::list<CMeasure*>::const_iterator iter = measures.begin();
for( ; iter != measures.end(); ++iter) for ( ; iter != measures.end(); ++iter)
{ {
if (_wcsicmp((*iter)->GetName(), measureName.c_str()) == 0) if (_wcsicmp((*iter)->GetName(), measureName.c_str()) == 0)
{ {
@@ -3111,7 +3111,7 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
** Runs the given command or bang ** Runs the given command or bang
** **
*/ */
void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow) void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
{ {
if (command == NULL) return; if (command == NULL) return;
@@ -3151,11 +3151,11 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
PlaySound(NULL, NULL, SND_PURGE); PlaySound(NULL, NULL, SND_PURGE);
return; return;
} }
// Run the command // Run the command
if(strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep()) if (strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())
{ {
if (meterWindow) if (meterWindow)
{ {
// Fake WM_COPY to deliver bangs // Fake WM_COPY to deliver bangs
COPYDATASTRUCT CopyDataStruct; COPYDATASTRUCT CopyDataStruct;
@@ -3168,7 +3168,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
{ {
std::wstring bang, arg; std::wstring bang, arg;
size_t pos = strCommand.find(L' '); size_t pos = strCommand.find(L' ');
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
bang = strCommand.substr(0, pos); bang = strCommand.substr(0, pos);
strCommand.erase(0, pos + 1); strCommand.erase(0, pos + 1);
@@ -3191,7 +3191,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
/* /*
** ReadGeneralSettings ** ReadGeneralSettings
** **
** Reads the general settings from the Rainmeter.ini file ** Reads the general settings from the Rainmeter.ini file
** **
*/ */
@@ -3326,7 +3326,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
} }
delete [] tmpSz; delete [] tmpSz;
if (!skinName.empty()) if (!skinName.empty())
{ {
if (!SetActiveConfig(skinName, skinIni)) if (!SetActiveConfig(skinName, skinIni))
@@ -3355,7 +3355,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
} }
} }
/* /*
** SetActiveConfig ** SetActiveConfig
** **
** Makes the given config active. If the config cannot be found this returns false. ** Makes the given config active. If the config cannot be found this returns false.
@@ -3382,7 +3382,7 @@ bool CRainmeter::SetActiveConfig(const std::wstring& skinName, const std::wstrin
return false; return false;
} }
/* /*
** RefreshAll ** RefreshAll
** **
** Refreshes all active meter windows. ** Refreshes all active meter windows.
@@ -3479,7 +3479,7 @@ void CRainmeter::RefreshAll()
} }
} }
/* /*
** UpdateDesktopWorkArea ** UpdateDesktopWorkArea
** **
** Applies given DesktopWorkArea and DesktopWorkArea@n. ** Applies given DesktopWorkArea and DesktopWorkArea@n.
@@ -3603,7 +3603,7 @@ void CRainmeter::ReadStats()
{ {
WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH]; WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
if(GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0) if (GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
{ {
m_StatsDate = tmpSz; m_StatsDate = tmpSz;
} }
@@ -3648,12 +3648,12 @@ void CRainmeter::ResetStats()
{ {
// Set the stats-date string // Set the stats-date string
struct tm *newtime; struct tm *newtime;
time_t long_time; time_t long_time;
time(&long_time); time(&long_time);
newtime = localtime(&long_time); newtime = localtime(&long_time);
m_StatsDate = _wasctime(newtime); m_StatsDate = _wasctime(newtime);
m_StatsDate.resize(m_StatsDate.size() - 1); m_StatsDate.resize(m_StatsDate.size() - 1);
// Only Net measure has stats at the moment // Only Net measure has stats at the moment
CMeasureNet::ResetStats(); CMeasureNet::ResetStats();
} }
@@ -3664,7 +3664,7 @@ void CRainmeter::ResetStats()
** Opens the context menu in given coordinates. ** Opens the context menu in given coordinates.
** **
*/ */
void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{ {
if (!m_MenuActive) if (!m_MenuActive)
{ {
@@ -3673,10 +3673,10 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
// Show context menu, if no actions were executed // Show context menu, if no actions were executed
HMENU menu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_CONTEXT_MENU)); HMENU menu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_CONTEXT_MENU));
if(menu) if (menu)
{ {
HMENU subMenu = GetSubMenu(menu, 0); HMENU subMenu = GetSubMenu(menu, 0);
if(subMenu) if (subMenu)
{ {
if (!GetDummyLitestep()) if (!GetDummyLitestep())
{ {
@@ -3798,7 +3798,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
// Show context menu // Show context menu
TrackPopupMenu( TrackPopupMenu(
subMenu, subMenu,
TPM_RIGHTBUTTON | TPM_LEFTALIGN, TPM_RIGHTBUTTON | TPM_LEFTALIGN,
pos.x, pos.x,
pos.y, pos.y,
0, 0,
@@ -3893,7 +3893,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
HMENU posMenu = GetSubMenu(settingsMenu, 0); HMENU posMenu = GetSubMenu(settingsMenu, 0);
if (posMenu) if (posMenu)
{ {
switch(meterWindow->GetWindowZPosition()) switch(meterWindow->GetWindowZPosition())
{ {
case ZPOSITION_ONDESKTOP: case ZPOSITION_ONDESKTOP:
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_ONDESKTOP, MF_BYCOMMAND | MF_CHECKED);
@@ -3915,10 +3915,10 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED);
} }
if(meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED); if (meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED); if (meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED); if (meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if(meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED); if (meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
if (!c_DummyLitestep) if (!c_DummyLitestep)
{ {
@@ -3949,17 +3949,17 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
value = max(0, value); value = max(0, value);
CheckMenuItem(alphaMenu, value, MF_BYPOSITION | MF_CHECKED); CheckMenuItem(alphaMenu, value, MF_BYPOSITION | MF_CHECKED);
if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN) if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN)
{ {
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
} }
else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT) else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT)
{ {
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
} }
else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE) else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
{ {
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
@@ -4011,7 +4011,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str()); InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION); SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION);
ChangeSkinIndex(skinMenu, index); ChangeSkinIndex(skinMenu, index);
// Add the variants menu // Add the variants menu
@@ -4247,7 +4247,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
if (bSuccess) if (bSuccess)
{ {
bSuccess = (wcscmp(L"TRUE", tmpSz) == 0); bSuccess = (wcscmp(L"TRUE", tmpSz) == 0);
WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str()); WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str());
} }
if (!bSuccess) if (!bSuccess)
{ {

View File

@@ -573,7 +573,7 @@ HWND CSystem::GetDefaultShellWindow()
** **
** Finds the Shell's desktop window or WorkerW window. ** Finds the Shell's desktop window or WorkerW window.
** If the window is not found, this function returns NULL. ** If the window is not found, this function returns NULL.
** **
** Note for WorkerW: ** Note for WorkerW:
** **
** In Earlier Windows / 7 (without Aero): ** In Earlier Windows / 7 (without Aero):
@@ -982,7 +982,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
// Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows // Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for( ; iter != windows.end(); ++iter) for ( ; iter != windows.end(); ++iter)
{ {
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0); PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
} }
@@ -1118,7 +1118,7 @@ HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError, bool ignor
// return fEnabled; // return fEnabled;
//} //}
/* /*
** CopyFiles ** CopyFiles
** **
** Copies files and folders from one location to another. ** Copies files and folders from one location to another.
@@ -1149,7 +1149,7 @@ bool CSystem::CopyFiles(const std::wstring& strFrom, const std::wstring& strTo,
return true; return true;
} }
/* /*
** RemoveFile ** RemoveFile
** **
** Removes a file even if a file is read-only. ** Removes a file even if a file is read-only.
@@ -1167,7 +1167,7 @@ bool CSystem::RemoveFile(const std::wstring& file)
return (DeleteFile(file.c_str()) != 0); return (DeleteFile(file.c_str()) != 0);
} }
/* /*
** GetIniFileMappingList ** GetIniFileMappingList
** **
** Retrieves the "IniFileMapping" entries from Registry. ** Retrieves the "IniFileMapping" entries from Registry.
@@ -1199,7 +1199,7 @@ void CSystem::GetIniFileMappingList(std::vector<std::wstring>& iniFileMappings)
} }
} }
/* /*
** GetTemporaryFile ** GetTemporaryFile
** **
** Prepares a temporary file if iniFile is included in the "IniFileMapping" entries. ** Prepares a temporary file if iniFile is included in the "IniFileMapping" entries.

View File

@@ -600,7 +600,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
WCHAR* parseSz = _wcsdup(crop.c_str()); WCHAR* parseSz = _wcsdup(crop.c_str());
WCHAR* token; WCHAR* token;
token = wcstok(parseSz, L","); token = wcstok(parseSz, L",");
if (token) if (token)
{ {
@@ -673,7 +673,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::vector<Gdiplus::REAL> matrix2 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix2]); std::vector<Gdiplus::REAL> matrix2 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix2]);
if (matrix2.size() == 5) if (matrix2.size() == 5)
{ {
for(int i = 0; i < 4; ++i) // The fifth column must be 0. for (int i = 0; i < 4; ++i) // The fifth column must be 0.
{ {
m_ColorMatrix->m[1][i] = matrix2[i]; m_ColorMatrix->m[1][i] = matrix2[i];
} }
@@ -686,7 +686,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::vector<Gdiplus::REAL> matrix3 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix3]); std::vector<Gdiplus::REAL> matrix3 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix3]);
if (matrix3.size() == 5) if (matrix3.size() == 5)
{ {
for(int i = 0; i < 4; ++i) // The fifth column must be 0. for (int i = 0; i < 4; ++i) // The fifth column must be 0.
{ {
m_ColorMatrix->m[2][i] = matrix3[i]; m_ColorMatrix->m[2][i] = matrix3[i];
} }
@@ -699,7 +699,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::vector<Gdiplus::REAL> matrix4 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix4]); std::vector<Gdiplus::REAL> matrix4 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix4]);
if (matrix4.size() == 5) if (matrix4.size() == 5)
{ {
for(int i = 0; i < 4; ++i) // The fifth column must be 0. for (int i = 0; i < 4; ++i) // The fifth column must be 0.
{ {
m_ColorMatrix->m[3][i] = matrix4[i]; m_ColorMatrix->m[3][i] = matrix4[i];
} }
@@ -712,7 +712,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::vector<Gdiplus::REAL> matrix5 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix5]); std::vector<Gdiplus::REAL> matrix5 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix5]);
if (matrix5.size() == 5) if (matrix5.size() == 5)
{ {
for(int i = 0; i < 4; ++i) // The fifth column must be 1. for (int i = 0; i < 4; ++i) // The fifth column must be 1.
{ {
m_ColorMatrix->m[4][i] = matrix5[i]; m_ColorMatrix->m[4][i] = matrix5[i];
} }
@@ -721,19 +721,19 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix)); m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix));
std::wstring flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE"); std::wstring flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE");
if(_wcsicmp(flip.c_str(), L"NONE") == 0) if (_wcsicmp(flip.c_str(), L"NONE") == 0)
{ {
m_Flip = RotateNoneFlipNone; m_Flip = RotateNoneFlipNone;
} }
else if(_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0) else if (_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0)
{ {
m_Flip = RotateNoneFlipX; m_Flip = RotateNoneFlipX;
} }
else if(_wcsicmp(flip.c_str(), L"VERTICAL") == 0) else if (_wcsicmp(flip.c_str(), L"VERTICAL") == 0)
{ {
m_Flip = RotateNoneFlipY; m_Flip = RotateNoneFlipY;
} }
else if(_wcsicmp(flip.c_str(), L"BOTH") == 0) else if (_wcsicmp(flip.c_str(), L"BOTH") == 0)
{ {
m_Flip = RotateNoneFlipXY; m_Flip = RotateNoneFlipXY;
} }

View File

@@ -57,12 +57,12 @@ CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
wc.hInstance = instance; wc.hInstance = instance;
wc.hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDI_WINDOW)); wc.hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDI_WINDOW));
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = L"RainmeterTrayClass"; wc.lpszClassName = L"RainmeterTrayClass";
RegisterClass(&wc); RegisterClass(&wc);
m_Window = CreateWindowEx( m_Window = CreateWindowEx(
WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW,
L"RainmeterTrayClass", L"RainmeterTrayClass",
@@ -92,7 +92,7 @@ CTrayWindow::~CTrayWindow()
delete m_Bitmap; delete m_Bitmap;
delete m_Measure; delete m_Measure;
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i) for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
{ {
DestroyIcon(m_TrayIcons[i]); DestroyIcon(m_TrayIcons[i]);
} }
@@ -101,10 +101,10 @@ CTrayWindow::~CTrayWindow()
if (m_Window) DestroyWindow(m_Window); if (m_Window) DestroyWindow(m_Window);
} }
BOOL CTrayWindow::AddTrayIcon() BOOL CTrayWindow::AddTrayIcon()
{ {
BOOL res = FALSE; BOOL res = FALSE;
if (m_TrayIcon) if (m_TrayIcon)
{ {
DestroyIcon(m_TrayIcon); DestroyIcon(m_TrayIcon);
@@ -116,41 +116,41 @@ BOOL CTrayWindow::AddTrayIcon()
if (m_TrayIcon) if (m_TrayIcon)
{ {
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)}; NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window; tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY; tnid.uID = IDI_TRAY;
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
tnid.uCallbackMessage = WM_TRAY_NOTIFYICON; tnid.uCallbackMessage = WM_TRAY_NOTIFYICON;
tnid.hIcon = m_TrayIcon; tnid.hIcon = m_TrayIcon;
wcsncpy_s(tnid.szTip, L"Rainmeter", _TRUNCATE); wcsncpy_s(tnid.szTip, L"Rainmeter", _TRUNCATE);
res = Shell_NotifyIcon(NIM_ADD, &tnid); res = Shell_NotifyIcon(NIM_ADD, &tnid);
} }
return res; return res;
} }
BOOL CTrayWindow::RemoveTrayIcon() BOOL CTrayWindow::RemoveTrayIcon()
{ {
BOOL res = FALSE; BOOL res = FALSE;
if (m_TrayIcon) if (m_TrayIcon)
{ {
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)}; NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window; tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY; tnid.uID = IDI_TRAY;
tnid.uFlags = 0; tnid.uFlags = 0;
res = Shell_NotifyIcon(NIM_DELETE, &tnid); res = Shell_NotifyIcon(NIM_DELETE, &tnid);
DestroyIcon(m_TrayIcon); DestroyIcon(m_TrayIcon);
m_TrayIcon = NULL; m_TrayIcon = NULL;
} }
return res; return res;
} }
BOOL CTrayWindow::ModifyTrayIcon(double value) BOOL CTrayWindow::ModifyTrayIcon(double value)
{ {
BOOL res = FALSE; BOOL res = FALSE;
if (m_TrayIcon) if (m_TrayIcon)
{ {
@@ -159,22 +159,22 @@ BOOL CTrayWindow::ModifyTrayIcon(double value)
} }
m_TrayIcon = CreateTrayIcon(value); m_TrayIcon = CreateTrayIcon(value);
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)}; NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window; tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY; tnid.uID = IDI_TRAY;
tnid.uFlags = NIF_ICON; tnid.uFlags = NIF_ICON;
tnid.hIcon = m_TrayIcon; tnid.hIcon = m_TrayIcon;
res = Shell_NotifyIcon(NIM_MODIFY, &tnid); res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
return res; return res;
} }
HICON CTrayWindow::CreateTrayIcon(double value) HICON CTrayWindow::CreateTrayIcon(double value)
{ {
if (m_Measure != NULL) if (m_Measure != NULL)
{ {
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM) if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
{ {
m_TrayValues[m_TrayPos] = value; m_TrayValues[m_TrayPos] = value;
m_TrayPos = (m_TrayPos + 1) % TRAYICON_SIZE; m_TrayPos = (m_TrayPos + 1) % TRAYICON_SIZE;
@@ -205,9 +205,9 @@ HICON CTrayWindow::CreateTrayIcon(double value)
trayBitmap.GetHICON(&icon); trayBitmap.GetHICON(&icon);
return icon; return icon;
} }
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0)) else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
{ {
if (m_TrayIcons.size() > 0) if (m_TrayIcons.size() > 0)
{ {
size_t frame = 0; size_t frame = 0;
size_t frameCount = m_TrayIcons.size(); size_t frameCount = m_TrayIcons.size();
@@ -224,7 +224,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
int frameCount = 0; int frameCount = 0;
int newX, newY; int newX, newY;
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight()) if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
{ {
frameCount = m_Bitmap->GetWidth() / TRAYICON_SIZE; frameCount = m_Bitmap->GetWidth() / TRAYICON_SIZE;
} }
@@ -237,7 +237,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
frame = (int)(value * frameCount); frame = (int)(value * frameCount);
frame = min((frameCount - 1), frame); frame = min((frameCount - 1), frame);
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight()) if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
{ {
newX = frame * TRAYICON_SIZE; newX = frame * TRAYICON_SIZE;
newY = 0; newY = 0;
@@ -255,7 +255,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
// Blit the image // Blit the image
Rect r(0, 0, TRAYICON_SIZE, TRAYICON_SIZE); Rect r(0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
graphics.DrawImage(m_Bitmap, r, newX, newY, TRAYICON_SIZE, TRAYICON_SIZE, UnitPixel); graphics.DrawImage(m_Bitmap, r, newX, newY, TRAYICON_SIZE, TRAYICON_SIZE, UnitPixel);
HICON icon; HICON icon;
trayBitmap.GetHICON(&icon); trayBitmap.GetHICON(&icon);
return icon; return icon;
@@ -274,7 +274,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
delete m_Measure; delete m_Measure;
m_Measure = NULL; m_Measure = NULL;
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i) for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
{ {
DestroyIcon(m_TrayIcons[i]); DestroyIcon(m_TrayIcons[i]);
} }
@@ -308,13 +308,13 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
m_MeterType = TRAY_METER_TYPE_NONE; m_MeterType = TRAY_METER_TYPE_NONE;
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", L"HISTOGRAM"); std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", L"HISTOGRAM");
if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0) if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
{ {
m_MeterType = TRAY_METER_TYPE_HISTOGRAM; m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0)); m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0)); m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
} }
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0) else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
{ {
m_MeterType = TRAY_METER_TYPE_BITMAP; m_MeterType = TRAY_METER_TYPE_BITMAP;
@@ -324,16 +324,16 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
if (!imageName.empty()) if (!imageName.empty())
{ {
imageName.insert(0, Rainmeter->GetSkinPath()); imageName.insert(0, Rainmeter->GetSkinPath());
if (imageName.size() > 3) if (imageName.size() > 3)
{ {
std::wstring extension = imageName.substr(imageName.size() - 3); std::wstring extension = imageName.substr(imageName.size() - 3);
if (extension == L"ico" || extension == L"ICO") if (extension == L"ico" || extension == L"ICO")
{ {
int count = 1; int count = 1;
HICON hIcon = NULL; HICON hIcon = NULL;
// Load the icons // Load the icons
do do
{ {
WCHAR buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
_snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++); _snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++);
@@ -345,13 +345,13 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
} }
} }
if (m_TrayIcons.empty()) if (m_TrayIcons.empty())
{ {
// No icons found so load as bitmap // No icons found so load as bitmap
delete m_Bitmap; delete m_Bitmap;
m_Bitmap = new Bitmap(imageName.c_str()); m_Bitmap = new Bitmap(imageName.c_str());
Status status = m_Bitmap->GetLastStatus(); Status status = m_Bitmap->GetLastStatus();
if(Ok != status) if (Ok != status)
{ {
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str()); LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
delete m_Bitmap; delete m_Bitmap;
@@ -382,12 +382,12 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
static CTrayWindow* tray = NULL; static CTrayWindow* tray = NULL;
if(uMsg == WM_CREATE) if (uMsg == WM_CREATE)
{ {
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams; tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
} }
switch(uMsg) switch(uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
if (Rainmeter && tray) if (Rainmeter && tray)
@@ -395,24 +395,24 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (wParam == ID_CONTEXT_ABOUT) if (wParam == ID_CONTEXT_ABOUT)
{ {
OpenAboutDialog(tray->GetWindow(), Rainmeter->GetInstance()); OpenAboutDialog(tray->GetWindow(), Rainmeter->GetInstance());
} }
else if (wParam == ID_CONTEXT_DOWNLOADS) else if (wParam == ID_CONTEXT_DOWNLOADS)
{ {
LSExecute(NULL, RAINMETER_DOWNLOADS, SW_SHOWNORMAL); LSExecute(NULL, RAINMETER_DOWNLOADS, SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_SHOW_HELP) else if (wParam == ID_CONTEXT_SHOW_HELP)
{ {
LSExecute(NULL, revision_beta ? RAINMETER_MANUALBETA : RAINMETER_MANUAL, SW_SHOWNORMAL); LSExecute(NULL, revision_beta ? RAINMETER_MANUALBETA : RAINMETER_MANUAL, SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_NEW_VERSION) else if (wParam == ID_CONTEXT_NEW_VERSION)
{ {
LSExecute(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL); LSExecute(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_REFRESH) else if (wParam == ID_CONTEXT_REFRESH)
{ {
PostMessage(tray->GetWindow(), WM_TRAY_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL); PostMessage(tray->GetWindow(), WM_TRAY_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
} }
else if(wParam == ID_CONTEXT_SHOWLOGFILE) else if (wParam == ID_CONTEXT_SHOWLOGFILE)
{ {
// Check if the file exists // Check if the file exists
const std::wstring& log = Rainmeter->GetLogFile(); const std::wstring& log = Rainmeter->GetLogFile();
@@ -423,57 +423,57 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
} }
else if(wParam == ID_CONTEXT_STARTLOG) else if (wParam == ID_CONTEXT_STARTLOG)
{ {
Rainmeter->StartLogging(); Rainmeter->StartLogging();
} }
else if(wParam == ID_CONTEXT_STOPLOG) else if (wParam == ID_CONTEXT_STOPLOG)
{ {
Rainmeter->StopLogging(); Rainmeter->StopLogging();
} }
else if(wParam == ID_CONTEXT_DELETELOGFILE) else if (wParam == ID_CONTEXT_DELETELOGFILE)
{ {
Rainmeter->DeleteLogFile(); Rainmeter->DeleteLogFile();
} }
else if(wParam == ID_CONTEXT_DEBUGLOG) else if (wParam == ID_CONTEXT_DEBUGLOG)
{ {
Rainmeter->SetDebug(!CRainmeter::GetDebug()); Rainmeter->SetDebug(!CRainmeter::GetDebug());
} }
else if(wParam == ID_CONTEXT_DISABLEDRAG) else if (wParam == ID_CONTEXT_DISABLEDRAG)
{ {
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging()); Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
} }
else if(wParam == ID_CONTEXT_EDITCONFIG) else if (wParam == ID_CONTEXT_EDITCONFIG)
{ {
std::wstring command = Rainmeter->GetConfigEditor() + L" \""; std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
command += Rainmeter->GetIniFile(); command += Rainmeter->GetIniFile();
command += L"\""; command += L"\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_MANAGETHEMES) else if (wParam == ID_CONTEXT_MANAGETHEMES)
{ {
std::wstring command = L"\"" + Rainmeter->GetAddonPath(); std::wstring command = L"\"" + Rainmeter->GetAddonPath();
command += L"RainThemes\\RainThemes.exe\""; command += L"RainThemes\\RainThemes.exe\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_MANAGESKINS) else if (wParam == ID_CONTEXT_MANAGESKINS)
{ {
std::wstring command = L"\"" + Rainmeter->GetAddonPath(); std::wstring command = L"\"" + Rainmeter->GetAddonPath();
command += L"RainBrowser\\RainBrowser.exe\""; command += L"RainBrowser\\RainBrowser.exe\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_QUIT) else if (wParam == ID_CONTEXT_QUIT)
{ {
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0); if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
quitModule(Rainmeter->GetInstance()); quitModule(Rainmeter->GetInstance());
} }
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER) else if (wParam == ID_CONTEXT_OPENSKINSFOLDER)
{ {
std::wstring command = L"\"" + Rainmeter->GetSkinPath(); std::wstring command = L"\"" + Rainmeter->GetSkinPath();
command += L"\""; command += L"\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST) else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
{ {
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST; int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
@@ -487,7 +487,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
} }
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST) else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
{ {
wParam = wParam & 0x0ffff; wParam = wParam & 0x0ffff;
@@ -523,7 +523,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (index < (int)windows.size()) if (index < (int)windows.size())
{ {
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for( ; iter != windows.end(); ++iter) for ( ; iter != windows.end(); ++iter)
{ {
--index; --index;
if (index < 0) if (index < 0)
@@ -540,11 +540,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_TRAY_NOTIFYICON: case WM_TRAY_NOTIFYICON:
{ {
UINT uMouseMsg = (UINT)lParam; UINT uMouseMsg = (UINT)lParam;
std::wstring bang; std::wstring bang;
switch(uMouseMsg) switch(uMouseMsg)
{ {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
bang = Rainmeter->GetTrayExecuteL(); bang = Rainmeter->GetTrayExecuteL();
@@ -589,7 +589,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
COPYDATASTRUCT cds; COPYDATASTRUCT cds;
if(wParam == RAINMETER_QUERY_ID_SKINS_PATH) if (wParam == RAINMETER_QUERY_ID_SKINS_PATH)
{ {
const std::wstring& path = Rainmeter->GetSkinPath(); const std::wstring& path = Rainmeter->GetSkinPath();
@@ -598,10 +598,10 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
cds.lpData = (LPVOID) path.c_str(); cds.lpData = (LPVOID) path.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_SETTINGS_PATH) else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
{ {
std::wstring path = Rainmeter->GetSettingsPath(); std::wstring path = Rainmeter->GetSettingsPath();
@@ -613,7 +613,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_PLUGINS_PATH) else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
{ {
const std::wstring& path = Rainmeter->GetPluginPath(); const std::wstring& path = Rainmeter->GetPluginPath();
@@ -625,7 +625,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_PROGRAM_PATH) else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
{ {
const std::wstring& path = Rainmeter->GetPath(); const std::wstring& path = Rainmeter->GetPath();
@@ -637,7 +637,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_LOG_PATH) else if (wParam == RAINMETER_QUERY_ID_LOG_PATH)
{ {
const std::wstring& path = Rainmeter->GetLogFile(); const std::wstring& path = Rainmeter->GetLogFile();
@@ -649,7 +649,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR) else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
{ {
const std::wstring& editor = Rainmeter->GetConfigEditor(); const std::wstring& editor = Rainmeter->GetConfigEditor();
@@ -661,7 +661,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_COMMAND_LINE) else if (wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
{ {
std::wstring commandline = Rainmeter->GetCommandLine(); std::wstring commandline = Rainmeter->GetCommandLine();
@@ -673,15 +673,15 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_VERSION_CHECK) else if (wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
{ {
UINT versioncheck = (Rainmeter->GetDisableVersionCheck() * (Rainmeter->GetDisableVersionCheck() + Rainmeter->GetNewVersion())); UINT versioncheck = (Rainmeter->GetDisableVersionCheck() * (Rainmeter->GetDisableVersionCheck() + Rainmeter->GetNewVersion()));
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) versioncheck); SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) versioncheck);
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_IS_DEBUGGING) else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
{ {
BOOL debug = Rainmeter->GetDebug(); BOOL debug = Rainmeter->GetDebug();
@@ -689,7 +689,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_STATS_DATE) else if (wParam == RAINMETER_QUERY_ID_STATS_DATE)
{ {
const std::wstring& date = Rainmeter->GetStatsDate(); const std::wstring& date = Rainmeter->GetStatsDate();
@@ -701,7 +701,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_L) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteL(); const std::wstring& tray = Rainmeter->GetTrayExecuteL();
@@ -713,7 +713,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_R) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteR(); const std::wstring& tray = Rainmeter->GetTrayExecuteR();
@@ -725,7 +725,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_M) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteM(); const std::wstring& tray = Rainmeter->GetTrayExecuteM();
@@ -737,7 +737,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DL) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteDL(); const std::wstring& tray = Rainmeter->GetTrayExecuteDL();
@@ -749,7 +749,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DR) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteDR(); const std::wstring& tray = Rainmeter->GetTrayExecuteDR();
@@ -761,7 +761,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DM) else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
{ {
const std::wstring& tray = Rainmeter->GetTrayExecuteDM(); const std::wstring& tray = Rainmeter->GetTrayExecuteDM();
@@ -773,7 +773,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_IS_LITESTEP) else if (wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
{ {
BOOL islitestep = !Rainmeter->GetDummyLitestep(); BOOL islitestep = !Rainmeter->GetDummyLitestep();
@@ -785,19 +785,19 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 1; return 1;
case WM_COPYDATA: case WM_COPYDATA:
if(Rainmeter) if (Rainmeter)
{ {
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam; COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
if(cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE) if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
{ {
std::wstring SkinName((LPTSTR) cds->lpData); std::wstring SkinName((LPTSTR) cds->lpData);
std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows(); std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName); std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName);
if(iter != MeterWindows.end()) if (iter != MeterWindows.end())
{ {
return (LRESULT) iter->second->GetWindow(); return (LRESULT) iter->second->GetWindow();
} }
return NULL; return NULL;
} }
} }
return 1; return 1;
@@ -833,17 +833,17 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
break; break;
case LM_GETREVID: case LM_GETREVID:
if(lParam != NULL) if (lParam != NULL)
{ {
char* Buffer=(char*)lParam; char* Buffer=(char*)lParam;
if(wParam==0) if (wParam==0)
{ {
sprintf(Buffer, "Rainmeter.dll: %s", APPVERSION); sprintf(Buffer, "Rainmeter.dll: %s", APPVERSION);
} }
else if(wParam==1) else if (wParam==1)
{ {
sprintf(Buffer, "Rainmeter.dll: %s %s, Rainy", APPVERSION, __DATE__); sprintf(Buffer, "Rainmeter.dll: %s %s, Rainy", APPVERSION, __DATE__);
} }
else else
{ {
Buffer[0] = 0; Buffer[0] = 0;

View File

@@ -68,7 +68,7 @@ void CheckVersion(void* dummy)
version += atoi(verMinor.c_str()) * 1000; version += atoi(verMinor.c_str()) * 1000;
} }
} }
if (version > RAINMETER_VERSION) if (version > RAINMETER_VERSION)
{ {
Rainmeter->SetNewVersion(TRUE); Rainmeter->SetNewVersion(TRUE);

View File

@@ -19,7 +19,7 @@ void LuaManager::Init()
{ {
if (c_pState == 0) if (c_pState == 0)
{ {
// initialize Lua // initialize Lua
c_pState = lua_open(); c_pState = lua_open();
//load Lua base libraries //load Lua base libraries
@@ -57,7 +57,7 @@ void LuaManager::ReportErrors(lua_State * L)
{ {
LuaLog(LOG_ERROR, "Script: %s", lua_tostring(L, -1)); LuaLog(LOG_ERROR, "Script: %s", lua_tostring(L, -1));
lua_pop(L, 1); lua_pop(L, 1);
} }
void LuaManager::LuaLog(int nLevel, const char* format, ... ) void LuaManager::LuaLog(int nLevel, const char* format, ... )
{ {

View File

@@ -21,14 +21,14 @@ std::wstring to_wstring(lua_State* L, int arg, void* type)
const wchar_t* to_wchar (lua_State* L, int arg, void* type) const wchar_t* to_wchar (lua_State* L, int arg, void* type)
{ {
// We have a static wstring here so we can keep a copy of the string // We have a static wstring here so we can keep a copy of the string
// passed in alive while its being passed around. // passed in alive while its being passed around.
// This isn't exactly safe, but we shouldn't really have to worry as // This isn't exactly safe, but we shouldn't really have to worry as
// Rainmeter isn't threaded. // Rainmeter isn't threaded.
static std::wstring str; static std::wstring str;
str = ConvertToWide(lua_tostring(L,arg)); str = ConvertToWide(lua_tostring(L,arg));
return str.c_str(); return str.c_str();
} }

View File

@@ -16,11 +16,11 @@ LuaScript::LuaScript(lua_State* p_pState, const char* p_strFile) : m_pState(p_pS
lua_newtable(m_pState); lua_newtable(m_pState);
// Create the metatable that will store the global table // Create the metatable that will store the global table
lua_createtable(m_pState, 0, 1); lua_createtable(m_pState, 0, 1);
// Push the global teble // Push the global teble
lua_pushvalue(m_pState, LUA_GLOBALSINDEX); lua_pushvalue(m_pState, LUA_GLOBALSINDEX);
// Set the __index of the table to be the global table // Set the __index of the table to be the global table
lua_setfield(m_pState, -2, "__index"); lua_setfield(m_pState, -2, "__index");
@@ -102,7 +102,7 @@ double LuaScript::RunFunctionDouble(const char* p_strFuncName)
// Push the function onto the stack // Push the function onto the stack
lua_getfield(m_pState, -1, p_strFuncName); lua_getfield(m_pState, -1, p_strFuncName);
if(lua_pcall(m_pState, 0, 1, 0)) if (lua_pcall(m_pState, 0, 1, 0))
{ {
LuaManager::ReportErrors(m_pState); LuaManager::ReportErrors(m_pState);
} }
@@ -188,7 +188,7 @@ bool LuaScript::FunctionExists(const char* p_strFuncName)
// Push the function onto the stack // Push the function onto the stack
lua_getfield(m_pState, -1, p_strFuncName); lua_getfield(m_pState, -1, p_strFuncName);
if (lua_isfunction( m_pState, -1)) if (lua_isfunction( m_pState, -1))
{ {
bExists = true; bExists = true;
} }

View File

@@ -52,9 +52,9 @@ static std::map<UINT, CPUMeasure*> g_CPUMeasures;
void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames) void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
{ {
WCHAR* token; WCHAR* token;
token = wcstok(names, L";"); token = wcstok(names, L";");
while(token != NULL) while (token != NULL)
{ {
splittedNames.push_back(token); splittedNames.push_back(token);
token = wcstok(NULL, L";"); token = wcstok(NULL, L";");
@@ -63,7 +63,7 @@ void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -110,7 +110,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
bool CheckProcess(CPUMeasure* measure, const std::wstring& name) bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
{ {
if (measure->includes.empty()) if (measure->includes.empty())
{ {
for (size_t i = 0; i < measure->excludes.size(); i++) for (size_t i = 0; i < measure->excludes.size(); i++)
{ {
@@ -141,7 +141,7 @@ bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
double Update2(UINT id) double Update2(UINT id)
{ {
static DWORD oldTime = 0; static DWORD oldTime = 0;
// Only update twice per second // Only update twice per second
DWORD time = GetTickCount(); DWORD time = GetTickCount();
if (oldTime == 0 || time - oldTime > 500) if (oldTime == 0 || time - oldTime > 500)
@@ -153,25 +153,25 @@ double Update2(UINT id)
LONGLONG newValue = 0; LONGLONG newValue = 0;
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id); std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
if(i != g_CPUMeasures.end()) if (i != g_CPUMeasures.end())
{ {
CPUMeasure* measure = (*i).second; CPUMeasure* measure = (*i).second;
if(measure) if (measure)
{ {
for (size_t i = 0; i < g_Processes.size(); i++) for (size_t i = 0; i < g_Processes.size(); i++)
{ {
// Check process include/exclude // Check process include/exclude
if (CheckProcess(measure, g_Processes[i].name)) if (CheckProcess(measure, g_Processes[i].name))
{ {
if (g_Processes[i].oldValue != 0) if (g_Processes[i].oldValue != 0)
{ {
if (measure->topProcess == 0) if (measure->topProcess == 0)
{ {
// Add all values together // Add all values together
newValue += g_Processes[i].newValue - g_Processes[i].oldValue; newValue += g_Processes[i].newValue - g_Processes[i].oldValue;
} }
else else
{ {
// Find the top process // Find the top process
if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue) if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue)
@@ -197,14 +197,14 @@ double Update2(UINT id)
// //
// // Then substract the excluded processes // // Then substract the excluded processes
// std::vector< std::wstring >::iterator j = measure->excludes.begin(); // std::vector< std::wstring >::iterator j = measure->excludes.begin();
// for( ; j != measure->excludes.end(); j++) // for ( ; j != measure->excludes.end(); j++)
// { // {
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time"); // longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
// newValue += longvalue; // Adding means actually substraction // newValue += longvalue; // Adding means actually substraction
// } // }
// //
// // Compare with the old value // // Compare with the old value
// if(measure->oldValue != 0) // if (measure->oldValue != 0)
// { // {
// int val = 10000000 - (UINT)(newValue - measure->oldValue); // int val = 10000000 - (UINT)(newValue - measure->oldValue);
// if (val < 0) val = 0; // if (val < 0) val = 0;
@@ -216,14 +216,14 @@ double Update2(UINT id)
// { // {
// // Add the included processes // // Add the included processes
// std::vector< std::wstring >::iterator j = measure->includes.begin(); // std::vector< std::wstring >::iterator j = measure->includes.begin();
// for( ; j != measure->includes.end(); j++) // for ( ; j != measure->includes.end(); j++)
// { // {
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time"); // longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
// newValue += longvalue; // newValue += longvalue;
// } // }
// //
// // Compare with the old value // // Compare with the old value
// if(measure->oldValue != 0) // if (measure->oldValue != 0)
// { // {
// value = (UINT)(newValue - measure->oldValue); // value = (UINT)(newValue - measure->oldValue);
// } // }
@@ -241,14 +241,14 @@ double Update2(UINT id)
This function is called when the value should be This function is called when the value should be
returned as a string. returned as a string.
*/ */
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id); std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
if(i != g_CPUMeasures.end()) if (i != g_CPUMeasures.end())
{ {
CPUMeasure* measure = (*i).second; CPUMeasure* measure = (*i).second;
if (measure->topProcess == 2) if (measure->topProcess == 2)
{ {
return measure->topProcessName.c_str(); return measure->topProcessName.c_str();
} }
@@ -266,7 +266,7 @@ void Finalize(HMODULE instance, UINT id)
{ {
// delete the measure // delete the measure
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id); std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
if(i != g_CPUMeasures.end()) if (i != g_CPUMeasures.end())
{ {
delete (*i).second; delete (*i).second;
g_CPUMeasures.erase(i); g_CPUMeasures.erase(i);
@@ -291,17 +291,17 @@ void UpdateProcesses()
CPerfSnapshot snapshot(&g_CounterTitles); CPerfSnapshot snapshot(&g_CounterTitles);
CPerfObjectList objList(&snapshot, &g_CounterTitles); CPerfObjectList objList(&snapshot, &g_CounterTitles);
if(snapshot.TakeSnapshot(L"Process")) if (snapshot.TakeSnapshot(L"Process"))
{ {
pPerfObj = objList.GetPerfObject(L"Process"); pPerfObj = objList.GetPerfObject(L"Process");
if(pPerfObj) if (pPerfObj)
{ {
for(pObjInst = pPerfObj->GetFirstObjectInstance(); for (pObjInst = pPerfObj->GetFirstObjectInstance();
pObjInst != NULL; pObjInst != NULL;
pObjInst = pPerfObj->GetNextObjectInstance()) pObjInst = pPerfObj->GetNextObjectInstance())
{ {
if(pObjInst->GetObjectInstanceName(name, 256)) if (pObjInst->GetObjectInstanceName(name, 256))
{ {
if (_wcsicmp(name, L"_Total") == 0) if (_wcsicmp(name, L"_Total") == 0)
{ {
@@ -309,20 +309,20 @@ void UpdateProcesses()
} }
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time"); pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
if(pPerfCntr != NULL) if (pPerfCntr != NULL)
{ {
pPerfCntr->GetData(data, 256, NULL); pPerfCntr->GetData(data, 256, NULL);
if(pPerfCntr->GetSize() == 8) if (pPerfCntr->GetSize() == 8)
{ {
ProcessValues values; ProcessValues values;
values.name = name; values.name = name;
values.oldValue = 0; values.oldValue = 0;
// Check if we can find the old value // Check if we can find the old value
for (size_t i = 0; i < g_Processes.size(); i++) for (size_t i = 0; i < g_Processes.size(); i++)
{ {
if (!g_Processes[i].found && g_Processes[i].name == name) if (!g_Processes[i].found && g_Processes[i].name == name)
{ {
values.oldValue = g_Processes[i].newValue; values.oldValue = g_Processes[i].newValue;
g_Processes[i].found = true; g_Processes[i].found = true;

View File

@@ -61,7 +61,7 @@ float getHighestTemp();
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -73,10 +73,10 @@ float getHighestTemp();
*/ */
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
/* /*
Read our own settings from the ini-file Read our own settings from the ini-file
The ReadConfigString can be used for this purpose. Plugins The ReadConfigString can be used for this purpose. Plugins
can also read the config some other way (e.g. with can also read the config some other way (e.g. with
GetPrivateProfileInt, but in that case the variables GetPrivateProfileInt, but in that case the variables
do not work. do not work.
*/ */
@@ -100,7 +100,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
} }
} }
return 0; return 0;
} }

View File

@@ -17,34 +17,34 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
HANDLE hdlMutex; HANDLE hdlMutex;
hdlMutex = CreateMutex(NULL,FALSE,CORE_TEMP_MUTEX_OBJECT); hdlMutex = CreateMutex(NULL,FALSE,CORE_TEMP_MUTEX_OBJECT);
if (hdlMutex == NULL) if (hdlMutex == NULL)
{ {
return false; return false;
} }
WaitForSingleObject(hdlMutex, INFINITE); WaitForSingleObject(hdlMutex, INFINITE);
hdlMemory = OpenFileMapping( hdlMemory = OpenFileMapping(
FILE_MAP_READ, // Read only permission. FILE_MAP_READ, // Read only permission.
TRUE, TRUE,
CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject" CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject"
if (hdlMemory == NULL) if (hdlMemory == NULL)
{ {
ReleaseMutex(hdlMutex); ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex); CloseHandle(hdlMutex);
return false; return false;
} }
pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0); pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0);
if (pSharedData == NULL) if (pSharedData == NULL)
{ {
CloseHandle(hdlMemory); CloseHandle(hdlMemory);
hdlMemory = NULL; hdlMemory = NULL;
ReleaseMutex(hdlMutex); ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex); CloseHandle(hdlMutex);
return false; return false;
} }
__try __try
{ {
@@ -59,7 +59,7 @@ bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
UnmapViewOfFile(pSharedData); UnmapViewOfFile(pSharedData);
CloseHandle(hdlMemory); CloseHandle(hdlMemory);
ReleaseMutex(hdlMutex); ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex); CloseHandle(hdlMutex);
return bRet; return bRet;

View File

@@ -97,7 +97,7 @@ static FolderInfo* GetFolderInfo(const wchar_t* aPath, const wchar_t* aIniPath)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -139,7 +139,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
if (_wcsicmp(strIncludeSubFolders, L"1") == 0) { if (_wcsicmp(strIncludeSubFolders, L"1") == 0) {
measureInfo->Folder->IncludeSubFolders(true); measureInfo->Folder->IncludeSubFolders(true);
} }
const wchar_t* strShowHiddenFiles = ReadConfigString(section, L"IncludeHiddenFiles", L""); const wchar_t* strShowHiddenFiles = ReadConfigString(section, L"IncludeHiddenFiles", L"");
if (_wcsicmp(strShowHiddenFiles, L"1") == 0) { if (_wcsicmp(strShowHiddenFiles, L"1") == 0) {
measureInfo->Folder->IncludeHiddenFiles(true); measureInfo->Folder->IncludeHiddenFiles(true);

View File

@@ -19,119 +19,119 @@
#include "makeptr.h" #include "makeptr.h"
CPerfObjectInstance::CPerfObjectInstance( CPerfObjectInstance::CPerfObjectInstance(
PPERF_INSTANCE_DEFINITION const pPerfInstDef, PPERF_INSTANCE_DEFINITION const pPerfInstDef,
PPERF_COUNTER_DEFINITION const pPerfCntrDef, PPERF_COUNTER_DEFINITION const pPerfCntrDef,
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles, DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
BOOL fDummy) BOOL fDummy)
{ {
m_pPerfInstDef = pPerfInstDef; m_pPerfInstDef = pPerfInstDef;
m_pPerfCntrDef = pPerfCntrDef; m_pPerfCntrDef = pPerfCntrDef;
m_nCounters = nCounters; m_nCounters = nCounters;
m_pPerfCounterTitles = pPerfCounterTitles; m_pPerfCounterTitles = pPerfCounterTitles;
m_fDummy = fDummy; m_fDummy = fDummy;
} }
BOOL BOOL
CPerfObjectInstance::GetObjectInstanceName( CPerfObjectInstance::GetObjectInstanceName(
PTSTR pszObjInstName, DWORD nSize ) PTSTR pszObjInstName, DWORD nSize )
{ {
if ( m_fDummy ) if ( m_fDummy )
{ {
*pszObjInstName = 0; // Return an empty string *pszObjInstName = 0; // Return an empty string
return FALSE; return FALSE;
} }
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
return FALSE;
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset); if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
return FALSE;
#ifdef UNICODE
lstrcpy( pszObjInstName, pszName ); PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
#else
wcstombs( pszObjInstName, pszName, nSize ); #ifdef UNICODE
#endif lstrcpy( pszObjInstName, pszName );
#else
return TRUE; wcstombs( pszObjInstName, pszName, nSize );
#endif
return TRUE;
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef ) CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
{ {
// Look up the name of this counter in the title database // Look up the name of this counter in the title database
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex( PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
pCounterDef->CounterNameTitleIndex ); pCounterDef->CounterNameTitleIndex );
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
// Create a new CPerfCounter. The caller is responsible for deleting it. DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
return new CPerfCounter(pszName,
pCounterDef->CounterType, // Create a new CPerfCounter. The caller is responsible for deleting it.
MakePtr( PBYTE, m_pPerfInstDef, return new CPerfCounter(pszName,
nInstanceDefSize + pCounterDef->CounterType,
pCounterDef->CounterOffset ), MakePtr( PBYTE, m_pPerfInstDef,
pCounterDef->CounterSize ); nInstanceDefSize +
pCounterDef->CounterOffset ),
pCounterDef->CounterSize );
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::GetCounterByIndex( DWORD index ) CPerfObjectInstance::GetCounterByIndex( DWORD index )
{ {
PPERF_COUNTER_DEFINITION pCurrentCounter; PPERF_COUNTER_DEFINITION pCurrentCounter;
if ( index >= m_nCounters )
return 0;
pCurrentCounter = m_pPerfCntrDef;
// Find the correct PERF_COUNTER_DEFINITION by looping if ( index >= m_nCounters )
for ( DWORD i = 0; i < index; i++ ) return 0;
{
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter,
pCurrentCounter->ByteLength );
}
if ( pCurrentCounter->ByteLength == 0 ) pCurrentCounter = m_pPerfCntrDef;
return 0;
return MakeCounter( pCurrentCounter ); // Find the correct PERF_COUNTER_DEFINITION by looping
for ( DWORD i = 0; i < index; i++ )
{
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter,
pCurrentCounter->ByteLength );
}
if ( pCurrentCounter->ByteLength == 0 )
return 0;
return MakeCounter( pCurrentCounter );
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::GetFirstCounter( void ) CPerfObjectInstance::GetFirstCounter( void )
{ {
m_currentCounter = 0; m_currentCounter = 0;
return GetCounterByIndex( m_currentCounter ); return GetCounterByIndex( m_currentCounter );
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::GetNextCounter( void ) CPerfObjectInstance::GetNextCounter( void )
{ {
m_currentCounter++; m_currentCounter++;
return GetCounterByIndex( m_currentCounter ); return GetCounterByIndex( m_currentCounter );
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName ) CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
{ {
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName); DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
if ( cntrIdx == 0 ) if ( cntrIdx == 0 )
return 0; return 0;
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
for ( DWORD i = 0; i < m_nCounters; i++ )
{
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
return MakeCounter( pCurrentCounter );
// Nope. Not this one. Advance to the next counter
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter,
pCurrentCounter->ByteLength );
}
return 0; // Find the correct PERF_COUNTER_DEFINITION by looping and comparing
for ( DWORD i = 0; i < m_nCounters; i++ )
{
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
return MakeCounter( pCurrentCounter );
// Nope. Not this one. Advance to the next counter
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter,
pCurrentCounter->ByteLength );
}
return 0;
} }

View File

@@ -19,65 +19,65 @@
#include "makeptr.h" #include "makeptr.h"
CPerfObjectList::CPerfObjectList( CPerfObjectList::CPerfObjectList(
CPerfSnapshot * const pPerfSnapshot, CPerfSnapshot * const pPerfSnapshot,
CPerfTitleDatabase * const pPerfTitleDatabase ) CPerfTitleDatabase * const pPerfTitleDatabase )
{ {
m_pPerfSnapshot = pPerfSnapshot; m_pPerfSnapshot = pPerfSnapshot;
m_pPerfCounterTitles = pPerfTitleDatabase; m_pPerfCounterTitles = pPerfTitleDatabase;
} }
CPerfObject * CPerfObject *
CPerfObjectList::GetFirstPerfObject( void ) CPerfObjectList::GetFirstPerfObject( void )
{ {
m_currentObjectListIndex = 0; m_currentObjectListIndex = 0;
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() ) if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
return 0; return 0;
m_pCurrObjectType = m_pCurrObjectType =
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer(); (PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles ); return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
} }
CPerfObject * CPerfObject *
CPerfObjectList::GetNextPerfObject( void ) CPerfObjectList::GetNextPerfObject( void )
{ {
// Are we at the last object in the list? Return NULL if so. // Are we at the last object in the list? Return NULL if so.
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() ) if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
return 0; return 0;
// Advance to the next PERF_OBJECT_TYPE structure // Advance to the next PERF_OBJECT_TYPE structure
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE, m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
m_pCurrObjectType, m_pCurrObjectType,
m_pCurrObjectType->TotalByteLength ); m_pCurrObjectType->TotalByteLength );
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles ); return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
} }
CPerfObject * CPerfObject *
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName ) CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
{ {
DWORD objListIdx DWORD objListIdx
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName ); = m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
if ( 0 == objListIdx ) if ( 0 == objListIdx )
return 0; return 0;
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking // Point at first PERF_OBJECT_TYPE, and loop through the list, looking
// for one that matches. // for one that matches.
PPERF_OBJECT_TYPE pCurrObjectType = PPERF_OBJECT_TYPE pCurrObjectType =
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer(); (PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ ) for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
{ {
// Is this the one that matches? // Is this the one that matches?
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx ) if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles); return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
// Nope... try the next object type // Nope... try the next object type
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE, pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
pCurrObjectType, pCurrObjectType,
pCurrObjectType->TotalByteLength ); pCurrObjectType->TotalByteLength );
} }
return 0; return 0;
} }

View File

@@ -19,105 +19,105 @@
#include "perfcntr.h" #include "perfcntr.h"
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type, CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
PBYTE const pData, DWORD cbData ) PBYTE const pData, DWORD cbData )
{ {
m_pszName = _tcsdup( pszName ); m_pszName = _tcsdup( pszName );
m_type = type; m_type = type;
m_cbData = cbData; m_cbData = cbData;
m_pData = new BYTE[m_cbData]; m_pData = new BYTE[m_cbData];
memcpy( m_pData, pData, m_cbData ); memcpy( m_pData, pData, m_cbData );
} }
CPerfCounter::~CPerfCounter( void ) CPerfCounter::~CPerfCounter( void )
{ {
free( m_pszName ); free( m_pszName );
delete []m_pData; delete []m_pData;
} }
BOOL BOOL
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType ) CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
{ {
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
return FALSE; return FALSE;
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
if ( pType ) // If the user wants the type, give it to them memcpy( pBuffer, m_pData, m_cbData ); // copy the data
*pType = m_type;
if ( pType ) // If the user wants the type, give it to them
return TRUE; *pType = m_type;
return TRUE;
} }
BOOL BOOL
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex ) CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
{ {
// Do better formatting!!! Check length!!! // Do better formatting!!! Check length!!!
PTSTR pszPrefix = TEXT(""); PTSTR pszPrefix = TEXT("");
TCHAR szTemp[512]; TCHAR szTemp[512];
// First, ascertain the basic type (number, counter, text, or zero) // First, ascertain the basic type (number, counter, text, or zero)
switch ( m_type & 0x00000C00 ) switch ( m_type & 0x00000C00 )
{ {
case PERF_TYPE_ZERO: case PERF_TYPE_ZERO:
{ {
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE; wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
} }
case PERF_TYPE_TEXT: case PERF_TYPE_TEXT:
{ {
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE; wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
} }
case PERF_TYPE_COUNTER: case PERF_TYPE_COUNTER:
{ {
switch( m_type & 0x00070000 ) switch( m_type & 0x00070000 )
{ {
case PERF_COUNTER_RATE: case PERF_COUNTER_RATE:
pszPrefix = TEXT("counter rate "); break; pszPrefix = TEXT("counter rate "); break;
case PERF_COUNTER_FRACTION: case PERF_COUNTER_FRACTION:
pszPrefix = TEXT("counter fraction "); break; pszPrefix = TEXT("counter fraction "); break;
case PERF_COUNTER_BASE: case PERF_COUNTER_BASE:
pszPrefix = TEXT("counter base "); break; pszPrefix = TEXT("counter base "); break;
case PERF_COUNTER_ELAPSED: case PERF_COUNTER_ELAPSED:
pszPrefix = TEXT("counter elapsed "); break; pszPrefix = TEXT("counter elapsed "); break;
case PERF_COUNTER_QUEUELEN: case PERF_COUNTER_QUEUELEN:
pszPrefix = TEXT("counter queuelen "); break; pszPrefix = TEXT("counter queuelen "); break;
case PERF_COUNTER_HISTOGRAM: case PERF_COUNTER_HISTOGRAM:
pszPrefix = TEXT("counter histogram "); break; pszPrefix = TEXT("counter histogram "); break;
default: default:
pszPrefix = TEXT("counter value "); break; pszPrefix = TEXT("counter value "); break;
} }
} }
} }
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u"); PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
switch ( m_cbData ) switch ( m_cbData )
{ {
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData); case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
break; break;
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData); case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
break; break;
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData); case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
break; break;
case 8: // Danger! Assumes little-endian (X86) byte ordering case 8: // Danger! Assumes little-endian (X86) byte ordering
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix, wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break; *(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
break; break;
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData ); default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
} }
switch ( m_type & 0x70000000 )
{
case PERF_DISPLAY_SECONDS:
_tcscat( szTemp, TEXT(" secs") ); break;
case PERF_DISPLAY_PERCENT:
_tcscat( szTemp, TEXT(" %") ); break;
case PERF_DISPLAY_PER_SEC:
_tcscat( szTemp, TEXT(" /sec") ); break;
}
lstrcpyn( pszBuffer, szTemp, nSize ); switch ( m_type & 0x70000000 )
{
return TRUE; case PERF_DISPLAY_SECONDS:
_tcscat( szTemp, TEXT(" secs") ); break;
case PERF_DISPLAY_PERCENT:
_tcscat( szTemp, TEXT(" %") ); break;
case PERF_DISPLAY_PER_SEC:
_tcscat( szTemp, TEXT(" /sec") ); break;
}
lstrcpyn( pszBuffer, szTemp, nSize );
return TRUE;
} }

View File

@@ -42,7 +42,7 @@ static std::map<UINT, PerfMeasure*> g_Measures;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -105,21 +105,21 @@ double Update2(UINT id)
double value = 0; double value = 0;
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id); std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
if(i != g_Measures.end()) if (i != g_Measures.end())
{ {
PerfMeasure* measure = (*i).second; PerfMeasure* measure = (*i).second;
if(measure) if (measure)
{ {
ULONGLONG longvalue; ULONGLONG longvalue;
longvalue = GetPerfData(measure->ObjectName.c_str(), longvalue = GetPerfData(measure->ObjectName.c_str(),
measure->InstanceName.c_str(), measure->InstanceName.c_str(),
measure->CounterName.c_str()); measure->CounterName.c_str());
if(measure->Difference) if (measure->Difference)
{ {
// Compare with the old value // Compare with the old value
if(!measure->FirstTime) if (!measure->FirstTime)
{ {
value = (double)(longvalue - measure->OldValue); value = (double)(longvalue - measure->OldValue);
} }
@@ -145,7 +145,7 @@ void Finalize(HMODULE instance, UINT id)
{ {
// delete the measure // delete the measure
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id); std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
if(i != g_Measures.end()) if (i != g_Measures.end())
{ {
delete (*i).second; delete (*i).second;
g_Measures.erase(i); g_Measures.erase(i);
@@ -166,7 +166,7 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
WCHAR name[256]; WCHAR name[256];
ULONGLONG value = 0; ULONGLONG value = 0;
if(ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0) if (ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
{ {
// Unable to continue // Unable to continue
return 0; return 0;
@@ -175,21 +175,21 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
CPerfSnapshot snapshot(&g_CounterTitles); CPerfSnapshot snapshot(&g_CounterTitles);
CPerfObjectList objList(&snapshot, &g_CounterTitles); CPerfObjectList objList(&snapshot, &g_CounterTitles);
if(snapshot.TakeSnapshot(ObjectName)) if (snapshot.TakeSnapshot(ObjectName))
{ {
pPerfObj = objList.GetPerfObject(ObjectName); pPerfObj = objList.GetPerfObject(ObjectName);
if(pPerfObj) if (pPerfObj)
{ {
for(pObjInst = pPerfObj->GetFirstObjectInstance(); for (pObjInst = pPerfObj->GetFirstObjectInstance();
pObjInst != NULL; pObjInst != NULL;
pObjInst = pPerfObj->GetNextObjectInstance()) pObjInst = pPerfObj->GetNextObjectInstance())
{ {
if (InstanceName != NULL && wcslen(InstanceName) > 0) if (InstanceName != NULL && wcslen(InstanceName) > 0)
{ {
if(pObjInst->GetObjectInstanceName(name, 256)) if (pObjInst->GetObjectInstanceName(name, 256))
{ {
if(_wcsicmp(InstanceName, name) != 0) if (_wcsicmp(InstanceName, name) != 0)
{ {
delete pObjInst; delete pObjInst;
continue; continue;
@@ -203,23 +203,23 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
} }
pPerfCntr = pObjInst->GetCounterByName(CounterName); pPerfCntr = pObjInst->GetCounterByName(CounterName);
if(pPerfCntr != NULL) if (pPerfCntr != NULL)
{ {
pPerfCntr->GetData(data, 256, NULL); pPerfCntr->GetData(data, 256, NULL);
if(pPerfCntr->GetSize() == 1) if (pPerfCntr->GetSize() == 1)
{ {
value = *(BYTE*)data; value = *(BYTE*)data;
} }
else if(pPerfCntr->GetSize() == 2) else if (pPerfCntr->GetSize() == 2)
{ {
value = *(WORD*)data; value = *(WORD*)data;
} }
else if(pPerfCntr->GetSize() == 4) else if (pPerfCntr->GetSize() == 4)
{ {
value = *(DWORD*)data; value = *(DWORD*)data;
} }
else if(pPerfCntr->GetSize() == 8) else if (pPerfCntr->GetSize() == 8)
{ {
value = *(ULONGLONG*)data; value = *(ULONGLONG*)data;
} }

View File

@@ -19,78 +19,78 @@
#include "makeptr.h" #include "makeptr.h"
CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList, CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
CPerfTitleDatabase * const pPerfCounterTitles) CPerfTitleDatabase * const pPerfCounterTitles)
{ {
m_pObjectList = pObjectList; m_pObjectList = pObjectList;
m_pPerfCounterTitles = pPerfCounterTitles; m_pPerfCounterTitles = pPerfCounterTitles;
} }
CPerfObjectInstance * CPerfObjectInstance *
CPerfObject::GetFirstObjectInstance( void ) CPerfObject::GetFirstObjectInstance( void )
{ {
m_currentObjectInstance = 0; m_currentObjectInstance = 0;
if ( m_currentObjectInstance >= GetObjectInstanceCount() ) if ( m_currentObjectInstance >= GetObjectInstanceCount() )
return 0; return 0;
// Point at the first PERF_INSTANCE_DEFINITION // Point at the first PERF_INSTANCE_DEFINITION
m_pCurrentObjectInstanceDefinition = m_pCurrentObjectInstanceDefinition =
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList, MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
m_pObjectList->DefinitionLength ); m_pObjectList->DefinitionLength );
return new CPerfObjectInstance( return new CPerfObjectInstance(
m_pCurrentObjectInstanceDefinition, m_pCurrentObjectInstanceDefinition,
MakePtr(PPERF_COUNTER_DEFINITION, MakePtr(PPERF_COUNTER_DEFINITION,
m_pObjectList, m_pObjectList->HeaderLength), m_pObjectList, m_pObjectList->HeaderLength),
m_pObjectList->NumCounters, m_pObjectList->NumCounters,
m_pPerfCounterTitles, m_pPerfCounterTitles,
m_pObjectList->NumInstances == m_pObjectList->NumInstances ==
PERF_NO_INSTANCES ? TRUE : FALSE ); PERF_NO_INSTANCES ? TRUE : FALSE );
} }
CPerfObjectInstance * CPerfObjectInstance *
CPerfObject::GetNextObjectInstance( void ) CPerfObject::GetNextObjectInstance( void )
{ {
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES ) if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
return 0; return 0;
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() ) if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
return 0; return 0;
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However, // Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
// following the current PERF_INSTANCE_DEFINITION is the counter data, // following the current PERF_INSTANCE_DEFINITION is the counter data,
// which is also of variable length. So, we gotta take that into // which is also of variable length. So, we gotta take that into
// account when finding the next PERF_INSTANCE_DEFINITION // account when finding the next PERF_INSTANCE_DEFINITION
// First, get a pointer to the counter data size field
PDWORD pCounterDataSize
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
m_pCurrentObjectInstanceDefinition->ByteLength);
// Now we can point at the next PPERF_INSTANCE_DEFINITION // First, get a pointer to the counter data size field
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION, PDWORD pCounterDataSize
m_pCurrentObjectInstanceDefinition, = MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
m_pCurrentObjectInstanceDefinition->ByteLength m_pCurrentObjectInstanceDefinition->ByteLength);
+ *pCounterDataSize);
// Now we can point at the next PPERF_INSTANCE_DEFINITION
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition, m_pCurrentObjectInstanceDefinition,
MakePtr(PPERF_COUNTER_DEFINITION, m_pCurrentObjectInstanceDefinition->ByteLength
m_pObjectList, + *pCounterDataSize);
m_pObjectList->HeaderLength),
m_pObjectList->NumCounters, // Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
m_pPerfCounterTitles, return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
FALSE ); MakePtr(PPERF_COUNTER_DEFINITION,
m_pObjectList,
m_pObjectList->HeaderLength),
m_pObjectList->NumCounters,
m_pPerfCounterTitles,
FALSE );
} }
BOOL BOOL
CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize ) CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize )
{ {
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex( PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
m_pObjectList->ObjectNameTitleIndex ); m_pObjectList->ObjectNameTitleIndex );
if ( !pszName ) if ( !pszName )
return FALSE; return FALSE;
lstrcpyn( pszObjTypeName, pszName, nSize ); lstrcpyn( pszObjTypeName, pszName, nSize );
return TRUE; return TRUE;
} }

View File

@@ -21,145 +21,145 @@ PBYTE CPerfSnapshot::c_pBuffer = NULL;
DWORD CPerfSnapshot::c_cbBufferSize = 0; DWORD CPerfSnapshot::c_cbBufferSize = 0;
CPerfSnapshot::CPerfSnapshot( CPerfSnapshot::CPerfSnapshot(
CPerfTitleDatabase * pCounterTitles ) CPerfTitleDatabase * pCounterTitles )
{ {
m_pPerfDataHeader = 0; m_pPerfDataHeader = 0;
m_pCounterTitles = pCounterTitles; m_pCounterTitles = pCounterTitles;
} }
CPerfSnapshot::~CPerfSnapshot( void ) CPerfSnapshot::~CPerfSnapshot( void )
{ {
DisposeSnapshot(); DisposeSnapshot();
} }
BOOL BOOL
CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems ) CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems )
{ {
DisposeSnapshot(); // Clear out any current snapshot DisposeSnapshot(); // Clear out any current snapshot
// Convert the input string (e.g., "Process") into the form required // Convert the input string (e.g., "Process") into the form required
// by the HKEY_PERFORMANCE_DATA key (e.g., "232") // by the HKEY_PERFORMANCE_DATA key (e.g., "232")
TCHAR szConvertedItemNames[ 256 ]; TCHAR szConvertedItemNames[ 256 ];
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames, if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
sizeof(szConvertedItemNames) ) ) sizeof(szConvertedItemNames) ) )
return FALSE; return FALSE;
DWORD cbAllocSize = 0; DWORD cbAllocSize = 0;
LONG retValue; LONG retValue;
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
{
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
szConvertedItemNames, 0, 0,
c_pBuffer, &c_cbBufferSize );
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot while ( 1 ) // Loop until we get the data, or we fail unexpectedly
{ {
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
szConvertedItemNames, 0, 0,
c_pBuffer, &c_cbBufferSize );
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
{
m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer; m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer;
// Verify that the signature is a unicode "PERF" // Verify that the signature is a unicode "PERF"
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) ) if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
break; break;
return TRUE; return TRUE;
} }
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
break; // code means something break; // code means something
// bad happened, so bail out. // bad happened, so bail out.
// If we get here, our buffer wasn't big enough. Delete it and // If we get here, our buffer wasn't big enough. Delete it and
// try again with a bigger buffer. // try again with a bigger buffer.
delete [] c_pBuffer; delete [] c_pBuffer;
// The new buffer size will be 4096 bytes bigger than the larger
// of: 1) The previous allocation size, or 2) The size that the
// RegQueryValueEx call said was necessary.
if ( c_cbBufferSize > cbAllocSize )
cbAllocSize = c_cbBufferSize + 4096;
else
cbAllocSize += 4096;
// Allocate a new, larger buffer in preparation to try again. // The new buffer size will be 4096 bytes bigger than the larger
c_pBuffer = new BYTE[ cbAllocSize ]; // of: 1) The previous allocation size, or 2) The size that the
if ( !c_pBuffer ) // RegQueryValueEx call said was necessary.
break; if ( c_cbBufferSize > cbAllocSize )
cbAllocSize = c_cbBufferSize + 4096;
else
cbAllocSize += 4096;
c_cbBufferSize = cbAllocSize; // Allocate a new, larger buffer in preparation to try again.
} c_pBuffer = new BYTE[ cbAllocSize ];
if ( !c_pBuffer )
break;
// If we get here, the RegQueryValueEx failed unexpectedly. c_cbBufferSize = cbAllocSize;
return FALSE; }
// If we get here, the RegQueryValueEx failed unexpectedly.
return FALSE;
} }
void void
CPerfSnapshot::DisposeSnapshot( void ) CPerfSnapshot::DisposeSnapshot( void )
{ {
m_pPerfDataHeader = 0; m_pPerfDataHeader = 0;
} }
void void
CPerfSnapshot::CleanUp( void ) CPerfSnapshot::CleanUp( void )
{ {
delete [] c_pBuffer; delete [] c_pBuffer;
c_pBuffer = 0; c_pBuffer = 0;
c_cbBufferSize = 0; c_cbBufferSize = 0;
} }
DWORD DWORD
CPerfSnapshot::GetNumObjectTypes( void ) CPerfSnapshot::GetNumObjectTypes( void )
{ {
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0; return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
} }
BOOL BOOL
CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize ) CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize )
{ {
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out. if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
return FALSE; return FALSE;
// Make sure the input buffer size is big enough // Make sure the input buffer size is big enough
if ( nSize < m_pPerfDataHeader->SystemNameLength ) if ( nSize < m_pPerfDataHeader->SystemNameLength )
return FALSE; return FALSE;
// Make a unicode string point to the system name string // Make a unicode string point to the system name string
// that's stored in the PERF_DATA_BLOCK // that's stored in the PERF_DATA_BLOCK
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader, LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
m_pPerfDataHeader->SystemNameOffset ); m_pPerfDataHeader->SystemNameOffset );
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer #ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
lstrcpy( pszSystemName, lpwszName ); lstrcpy( pszSystemName, lpwszName );
#else #else
wcstombs( pszSystemName, lpwszName, nSize ); wcstombs( pszSystemName, lpwszName, nSize );
#endif #endif
return TRUE; return TRUE;
} }
PVOID PVOID
CPerfSnapshot::GetPostHeaderPointer( void ) CPerfSnapshot::GetPostHeaderPointer( void )
{ {
// Returns a header to the first byte following the PERF_DATA_BLOCK // Returns a header to the first byte following the PERF_DATA_BLOCK
// (including the variable length system name string at the end) // (including the variable length system name string at the end)
return m_pPerfDataHeader ? return m_pPerfDataHeader ?
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength) MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
: 0; : 0;
} }
BOOL BOOL
CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn, CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn,
PTSTR pszOut, DWORD nSize ) PTSTR pszOut, DWORD nSize )
{ {
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) ) if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
return FALSE; return FALSE;
DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn); DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn);
if ( objectID ) if ( objectID )
pszOut += wsprintf( pszOut, TEXT("%u "), objectID ); pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
else else
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn ); pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
return TRUE; return TRUE;
} }

View File

@@ -16,143 +16,143 @@
#include "Titledb.h" #include "Titledb.h"
CPerfTitleDatabase::CPerfTitleDatabase( CPerfTitleDatabase::CPerfTitleDatabase(
PERFORMANCE_TITLE_TYPE titleType ) PERFORMANCE_TITLE_TYPE titleType )
{ {
m_nLastIndex = 0; m_nLastIndex = 0;
m_TitleStrings = 0; m_TitleStrings = 0;
m_pszRawStrings = 0; m_pszRawStrings = 0;
// Determine the appropriate strings to pass to RegOpenKeyEx // Determine the appropriate strings to pass to RegOpenKeyEx
PTSTR psz009RegValue, pszLastIndexRegValue; PTSTR psz009RegValue, pszLastIndexRegValue;
if ( PERF_TITLE_COUNTER == titleType ) if ( PERF_TITLE_COUNTER == titleType )
{ {
psz009RegValue = TEXT("Counter 009"); psz009RegValue = TEXT("Counter 009");
pszLastIndexRegValue = TEXT("Last Counter"); pszLastIndexRegValue = TEXT("Last Counter");
} }
else if ( PERF_TITLE_EXPLAIN == titleType ) else if ( PERF_TITLE_EXPLAIN == titleType )
{ {
psz009RegValue = TEXT("Explain 009"); psz009RegValue = TEXT("Explain 009");
pszLastIndexRegValue = TEXT("Last Help"); pszLastIndexRegValue = TEXT("Last Help");
} }
else else
return; return;
// Find out the max number of entries // Find out the max number of entries
HKEY hKeyPerflib = 0; HKEY hKeyPerflib = 0;
DWORD cbLastIndex; DWORD cbLastIndex;
// Open the registry key that has the values for the maximum number
// of title strings
if ( ERROR_SUCCESS != RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
0, KEY_READ, &hKeyPerflib ) )
return;
// Read in the number of title strings // Open the registry key that has the values for the maximum number
if ( ERROR_SUCCESS != RegQueryValueEx( // of title strings
hKeyPerflib, pszLastIndexRegValue, 0, 0, if ( ERROR_SUCCESS != RegOpenKeyEx(
(PBYTE)&m_nLastIndex, &cbLastIndex ) ) HKEY_LOCAL_MACHINE,
{ TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
RegCloseKey( hKeyPerflib ); 0, KEY_READ, &hKeyPerflib ) )
return; return;
}
RegCloseKey( hKeyPerflib );
//
// Now go find and process the raw string data
//
// Determine how big the raw data in the REG_MULTI_SZ value is // Read in the number of title strings
DWORD cbTitleStrings; if ( ERROR_SUCCESS != RegQueryValueEx(
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings)) hKeyPerflib, pszLastIndexRegValue, 0, 0,
return; (PBYTE)&m_nLastIndex, &cbLastIndex ) )
{
RegCloseKey( hKeyPerflib );
return;
}
// Allocate memory for the raw registry title string data RegCloseKey( hKeyPerflib );
m_pszRawStrings = new TCHAR[cbTitleStrings];
// Read in the raw title strings
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
&cbTitleStrings ) )
{
delete []m_pszRawStrings;
return;
}
// allocate memory for an array of string pointers. //
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ]; // Now go find and process the raw string data
if ( !m_TitleStrings ) //
{
delete []m_pszRawStrings;
return;
}
// Initialize the m_TitleStrings to all NULLs, since there may // Determine how big the raw data in the REG_MULTI_SZ value is
// be some array slots that aren't used. DWORD cbTitleStrings;
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) ); if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
return;
// The raw data entries are an ASCII string index (e.g., "242"), followed // Allocate memory for the raw registry title string data
// by the corresponding string. Fill in the appropriate slot in the m_pszRawStrings = new TCHAR[cbTitleStrings];
// m_TitleStrings array with the pointer to the string name. The end
// of the list is indicated by a double NULL.
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings; // Read in the raw title strings
unsigned cbCurrStr; if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
&cbTitleStrings ) )
{
delete []m_pszRawStrings;
return;
}
// While the length of the current string isn't 0... // allocate memory for an array of string pointers.
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) ) m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
{ if ( !m_TitleStrings )
// Convert the first string to a binary representation {
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi() delete []m_pszRawStrings;
return;
}
if ( index > m_nLastIndex ) // Initialize the m_TitleStrings to all NULLs, since there may
break; // be some array slots that aren't used.
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
// Now point to the string following it. This is the title string
pszWorkStr += cbCurrStr + 1;
// Fill in the appropriate slot in the title strings array. // The raw data entries are an ASCII string index (e.g., "242"), followed
m_TitleStrings[index] = pszWorkStr; // by the corresponding string. Fill in the appropriate slot in the
// m_TitleStrings array with the pointer to the string name. The end
// Advance to the next index/title pair // of the list is indicated by a double NULL.
pszWorkStr += lstrlen(pszWorkStr) + 1;
} PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
unsigned cbCurrStr;
// While the length of the current string isn't 0...
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
{
// Convert the first string to a binary representation
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
if ( index > m_nLastIndex )
break;
// Now point to the string following it. This is the title string
pszWorkStr += cbCurrStr + 1;
// Fill in the appropriate slot in the title strings array.
m_TitleStrings[index] = pszWorkStr;
// Advance to the next index/title pair
pszWorkStr += lstrlen(pszWorkStr) + 1;
}
} }
CPerfTitleDatabase::~CPerfTitleDatabase( ) CPerfTitleDatabase::~CPerfTitleDatabase( )
{ {
delete []m_TitleStrings; delete []m_TitleStrings;
m_TitleStrings = 0; m_TitleStrings = 0;
delete []m_pszRawStrings; delete []m_pszRawStrings;
m_pszRawStrings = 0; m_pszRawStrings = 0;
m_nLastIndex = 0; m_nLastIndex = 0;
} }
PTSTR PTSTR
CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index ) CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index )
{ {
if ( index > m_nLastIndex ) // Is index within range? if ( index > m_nLastIndex ) // Is index within range?
return 0; return 0;
return m_TitleStrings[ index ]; return m_TitleStrings[ index ];
} }
unsigned unsigned
CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString ) CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString )
{ {
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) ) if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
return 0; return 0;
// Loop through all the non-null string array entries, doing a case- // Loop through all the non-null string array entries, doing a case-
// insensitive comparison. If found, return the correpsonding index // insensitive comparison. If found, return the correpsonding index
for ( unsigned i = 1; i <= m_nLastIndex; i++ ) for ( unsigned i = 1; i <= m_nLastIndex; i++ )
{ {
if ( m_TitleStrings[i] ) if ( m_TitleStrings[i] )
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) ) if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
return i; return i;
} }
return 0; return 0;
} }

View File

@@ -63,7 +63,7 @@ typedef struct tagIPINFO
typedef IPINFO* PIPINFO; typedef IPINFO* PIPINFO;
static std::map<UINT, pingData*> g_Values; static std::map<UINT, pingData*> g_Values;
static CRITICAL_SECTION g_CriticalSection; static CRITICAL_SECTION g_CriticalSection;
static bool g_Initialized = false; static bool g_Initialized = false;
static HINSTANCE g_ICMPInstance = NULL; static HINSTANCE g_ICMPInstance = NULL;
@@ -99,7 +99,7 @@ std::string ConvertToAscii(LPCTSTR str)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -127,7 +127,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
g_IcmpSendEcho = (IcmpSendEcho)GetProcAddress(g_ICMPInstance,"IcmpSendEcho"); g_IcmpSendEcho = (IcmpSendEcho)GetProcAddress(g_ICMPInstance,"IcmpSendEcho");
g_IcmpSendEcho2 = (IcmpSendEcho2)GetProcAddress(g_ICMPInstance,"IcmpSendEcho2"); g_IcmpSendEcho2 = (IcmpSendEcho2)GetProcAddress(g_ICMPInstance,"IcmpSendEcho2");
} }
g_Initialized = true; g_Initialized = true;
} }
@@ -143,7 +143,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
if (pData->destAddr == INADDR_NONE) if (pData->destAddr == INADDR_NONE)
{ {
WSADATA wsaData; WSADATA wsaData;
if (WSAStartup(0x0101, &wsaData) == 0) if (WSAStartup(0x0101, &wsaData) == 0)
{ {
LPHOSTENT pHost; LPHOSTENT pHost;
@@ -184,7 +184,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
pData->timeoutValue = wcstod(data, NULL); pData->timeoutValue = wcstod(data, NULL);
} }
if (valid) if (valid)
{ {
g_Values[id] = pData; g_Values[id] = pData;
@@ -210,10 +210,10 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
DWORD res = g_IcmpSendEcho( DWORD res = g_IcmpSendEcho(
hIcmpFile, hIcmpFile,
pData->destAddr, pData->destAddr,
NULL, NULL,
0, 0,
NULL, NULL,
reply, reply,
replySize, replySize,
pData->timeout); pData->timeout);
@@ -236,7 +236,7 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
pData->threadHandle = 0; pData->threadHandle = 0;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
} }
return 0; // thread completed successfully return 0; // thread completed successfully
} }
/* /*
@@ -299,7 +299,7 @@ void Finalize(HMODULE instance, UINT id)
} }
// Last instance deletes the critical section // Last instance deletes the critical section
if (g_Values.empty()) if (g_Values.empty())
{ {
if (g_ICMPInstance) if (g_ICMPInstance)
{ {

View File

@@ -26,7 +26,7 @@
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point #include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
typedef struct _PROCESSOR_POWER_INFORMATION typedef struct _PROCESSOR_POWER_INFORMATION
{ {
ULONG Number; ULONG Number;
ULONG MaxMhz; ULONG MaxMhz;
@@ -69,7 +69,7 @@ FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -99,20 +99,20 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
/* Read our own settings from the ini-file */ /* Read our own settings from the ini-file */
LPCTSTR type = ReadConfigString(section, L"PowerState", L""); LPCTSTR type = ReadConfigString(section, L"PowerState", L"");
if(type) if (type)
{ {
if (_wcsicmp(L"ACLINE", type) == 0) if (_wcsicmp(L"ACLINE", type) == 0)
{ {
powerState = POWER_ACLINE; powerState = POWER_ACLINE;
} }
else if (_wcsicmp(L"STATUS", type) == 0) else if (_wcsicmp(L"STATUS", type) == 0)
{ {
powerState = POWER_STATUS; powerState = POWER_STATUS;
} }
else if (_wcsicmp(L"STATUS2", type) == 0) else if (_wcsicmp(L"STATUS2", type) == 0)
{ {
powerState = POWER_STATUS2; powerState = POWER_STATUS2;
} }
else if (_wcsicmp(L"LIFETIME", type) == 0) else if (_wcsicmp(L"LIFETIME", type) == 0)
{ {
powerState= POWER_LIFETIME; powerState= POWER_LIFETIME;
@@ -122,7 +122,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
g_Formats[id] = format; g_Formats[id] = format;
} }
} }
else if (_wcsicmp(L"MHZ", type) == 0) else if (_wcsicmp(L"MHZ", type) == 0)
{ {
powerState= POWER_MHZ; powerState= POWER_MHZ;
@@ -237,7 +237,7 @@ double Update2(UINT id)
This function is called when the value should be This function is called when the value should be
returned as a string. returned as a string.
*/ */
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
static WCHAR buffer[256]; static WCHAR buffer[256];

View File

@@ -94,7 +94,7 @@ std::wstring ConvertToWide(LPCSTR str)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -129,7 +129,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
size_t start = 0; size_t start = 0;
size_t pos = ext.find(L';'); size_t pos = ext.find(L';');
while (pos != std::wstring::npos) while (pos != std::wstring::npos)
{ {
qData.fileFilters.push_back(ext.substr(start, pos - start)); qData.fileFilters.push_back(ext.substr(start, pos - start));
start = pos + 1; start = pos + 1;
@@ -157,9 +157,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
} }
if (PathIsDirectory(qData.pathname.c_str())) if (PathIsDirectory(qData.pathname.c_str()))
{ {
if (qData.pathname[qData.pathname.size() - 1] != L'\\') if (qData.pathname[qData.pathname.size() - 1] != L'\\')
{ {
qData.pathname += L"\\"; qData.pathname += L"\\";
} }
@@ -168,7 +168,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
ScanFolder(qData, bSubfolders, qData.pathname); ScanFolder(qData, bSubfolders, qData.pathname);
} }
} }
if (!qData.pathname.empty()) if (!qData.pathname.empty())
{ {
g_Values[id] = qData; g_Values[id] = qData;
@@ -192,11 +192,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
hSearch = FindFirstFile(searchPath.c_str(), &fileData); hSearch = FindFirstFile(searchPath.c_str(), &fileData);
do do
{ {
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{ {
if (bSubfolders) if (bSubfolders)
{ {
if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0) if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0)
{ {
@@ -206,11 +206,11 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
} }
else else
{ {
if (!qData.fileFilters.empty()) if (!qData.fileFilters.empty())
{ {
for (int i = 0; i < qData.fileFilters.size(); i++) for (int i = 0; i < qData.fileFilters.size(); i++)
{ {
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str())) if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
{ {
qData.files.push_back(path + fileData.cFileName); qData.files.push_back(path + fileData.cFileName);
break; break;
@@ -223,7 +223,7 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
} }
} }
} }
while(FindNextFile(hSearch, &fileData)); while (FindNextFile(hSearch, &fileData));
} }
#define BUFFER_SIZE 4096 #define BUFFER_SIZE 4096
@@ -262,7 +262,7 @@ double Update2(UINT id)
qData.value.erase(); qData.value.erase();
if (0xFEFF == *(WCHAR*)buffer) if (0xFEFF == *(WCHAR*)buffer)
{ {
// It's unicode // It's unicode
WCHAR* wBuffer = (WCHAR*)buffer; WCHAR* wBuffer = (WCHAR*)buffer;
@@ -270,7 +270,7 @@ double Update2(UINT id)
// Read until we find the first separator // Read until we find the first separator
WCHAR* sepPos1 = NULL; WCHAR* sepPos1 = NULL;
WCHAR* sepPos2 = NULL; WCHAR* sepPos2 = NULL;
do do
{ {
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file); size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
buffer[len] = 0; buffer[len] = 0;
@@ -299,7 +299,7 @@ double Update2(UINT id)
while (sepPos1 == NULL); while (sepPos1 == NULL);
// Find the second separator // Find the second separator
do do
{ {
sepPos2 = wcsstr(sepPos1, qData.separator.c_str()); sepPos2 = wcsstr(sepPos1, qData.separator.c_str());
if (sepPos2 == NULL) if (sepPos2 == NULL)
@@ -343,7 +343,7 @@ double Update2(UINT id)
// Read until we find the first separator // Read until we find the first separator
char* sepPos1 = NULL; char* sepPos1 = NULL;
char* sepPos2 = NULL; char* sepPos2 = NULL;
do do
{ {
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file); size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
aBuffer[len] = 0; aBuffer[len] = 0;
@@ -370,7 +370,7 @@ double Update2(UINT id)
while (sepPos1 == NULL); while (sepPos1 == NULL);
// Find the second separator // Find the second separator
do do
{ {
sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str()); sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str());
if (sepPos2 == NULL) if (sepPos2 == NULL)
@@ -419,11 +419,11 @@ double Update2(UINT id)
} }
} }
} }
return 0; return 0;
} }
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
std::map<UINT, quoteData>::iterator i = g_Values.find(id); std::map<UINT, quoteData>::iterator i = g_Values.find(id);
if (i != g_Values.end()) if (i != g_Values.end())

View File

@@ -70,7 +70,7 @@ id The identifier for the measure. This is used to identify the measures
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
MEASURETYPE dataType = NUMRECYCLE; // 1 for numRecycled, 2 for sizeRecycled MEASURETYPE dataType = NUMRECYCLE; // 1 for numRecycled, 2 for sizeRecycled
/* Read our own settings from the ini-file */ /* Read our own settings from the ini-file */
LPCTSTR type = ReadConfigString(section, L"RecycleType", L"COUNT"); LPCTSTR type = ReadConfigString(section, L"RecycleType", L"COUNT");
if (type) if (type)
@@ -78,11 +78,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
if (_wcsicmp(L"COUNT", type) == 0) if (_wcsicmp(L"COUNT", type) == 0)
{ {
dataType = NUMRECYCLE; dataType = NUMRECYCLE;
} }
else if (_wcsicmp(L"SIZE", type) == 0) else if (_wcsicmp(L"SIZE", type) == 0)
{ {
dataType = SIZERECYCLE; dataType = SIZERECYCLE;
} }
else else
{ {
std::wstring error = L"RecycleType="; std::wstring error = L"RecycleType=";
@@ -93,9 +93,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
} }
g_Values[id] = dataType; g_Values[id] = dataType;
LPCTSTR drives = ReadConfigString(section, L"Drives", L"ALL"); LPCTSTR drives = ReadConfigString(section, L"Drives", L"ALL");
if (drives && wcslen(drives) > 0) if (drives && wcslen(drives) > 0)
{ {
@@ -105,7 +105,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
g_DriveList[id] = L"ALL"; g_DriveList[id] = L"ALL";
} }
return 0; return 0;
} }
@@ -116,7 +116,7 @@ void Tokenize(const std::wstring& str, std::vector<std::wstring>& tokens, const
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0); std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter". // Find first "non-delimiter".
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos); std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);
while (std::wstring::npos != pos || std::wstring::npos != lastPos) while (std::wstring::npos != pos || std::wstring::npos != lastPos)
{ {
// Found a token, add it to the vector. // Found a token, add it to the vector.
@@ -136,13 +136,13 @@ double Update2(UINT id)
{ {
MEASURETYPE dataType = g_Values[id]; MEASURETYPE dataType = g_Values[id];
std::wstring driveSet = g_DriveList[id]; std::wstring driveSet = g_DriveList[id];
SHQUERYRBINFO RecycleBinInfo = { 0 }; SHQUERYRBINFO RecycleBinInfo = { 0 };
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0) if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
{ {
if(SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK) if (SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
{ {
if (dataType == SIZERECYCLE) if (dataType == SIZERECYCLE)
{ {
@@ -160,15 +160,15 @@ double Update2(UINT id)
} }
} }
std::vector<std::wstring> tokens; std::vector<std::wstring> tokens;
std::wstring toSplit(driveSet.begin(), driveSet.end()); std::wstring toSplit(driveSet.begin(), driveSet.end());
double retVal = 0; double retVal = 0;
Tokenize(toSplit, tokens, L"|"); Tokenize(toSplit, tokens, L"|");
for(int i=0;i < tokens.size(); i++) for (int i=0;i < tokens.size(); i++)
{ {
double tempVal; double tempVal;
std::wstring strd = tokens.at(i); std::wstring strd = tokens.at(i);
SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info SHQueryRecycleBin( strd.c_str(), &RecycleBinInfo ); // Get recycle bin info
if (dataType == SIZERECYCLE) if (dataType == SIZERECYCLE)
{ {
tempVal = (double)RecycleBinInfo.i64Size; // size in bytes tempVal = (double)RecycleBinInfo.i64Size; // size in bytes
@@ -179,7 +179,7 @@ double Update2(UINT id)
} }
retVal += tempVal; retVal += tempVal;
} }
return (retVal); return (retVal);
} }
@@ -209,14 +209,14 @@ LPCTSTR GetPluginAuthor()
void ExecuteBang(LPCTSTR args, UINT id) void ExecuteBang(LPCTSTR args, UINT id)
{ {
std::wstring bang = args; std::wstring bang = args;
std::wstring driveSet = g_DriveList[id]; std::wstring driveSet = g_DriveList[id];
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0) if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
{ //Empty the Recycle Bin { //Empty the Recycle Bin
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0) if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
{ {
if(SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK) if (SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
{ {
return; return;
} }
@@ -226,23 +226,23 @@ void ExecuteBang(LPCTSTR args, UINT id)
} }
} }
std::vector<std::wstring> tokens; std::vector<std::wstring> tokens;
std::wstring toSplit(driveSet.begin(), driveSet.end()); std::wstring toSplit(driveSet.begin(), driveSet.end());
Tokenize(toSplit, tokens, L"|"); Tokenize(toSplit, tokens, L"|");
for(int i=0;i < tokens.size(); i++) for (int i=0;i < tokens.size(); i++)
{ {
std::wstring strd = tokens.at(i); std::wstring strd = tokens.at(i);
SHEmptyRecycleBin( NULL, strd.c_str(), NULL ); // empty bin SHEmptyRecycleBin( NULL, strd.c_str(), NULL ); // empty bin
} }
return; return;
} }
else else
{ {
if (_wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0) if (_wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0)
{ //Empty the Recycle Bin (no prompt) { //Empty the Recycle Bin (no prompt)
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0) if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
{ {
if(SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK) if (SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
{ {
return; return;
} }
@@ -252,24 +252,24 @@ void ExecuteBang(LPCTSTR args, UINT id)
} }
} }
std::vector<std::wstring> tokens; std::vector<std::wstring> tokens;
std::wstring toSplit(driveSet.begin(), driveSet.end()); std::wstring toSplit(driveSet.begin(), driveSet.end());
Tokenize(toSplit, tokens, L"|"); Tokenize(toSplit, tokens, L"|");
for(int i=0;i < tokens.size(); i++) for (int i=0;i < tokens.size(); i++)
{ {
std::wstring strd = tokens.at(i); std::wstring strd = tokens.at(i);
SHEmptyRecycleBin( NULL, strd.c_str(), SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ); // empty bin SHEmptyRecycleBin( NULL, strd.c_str(), SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ); // empty bin
} }
return; return;
} }
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0) else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
{ //Open the Recycle Bin folder { //Open the Recycle Bin folder
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}"); //system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
std::wstring szCmd = L"explorer.exe"; std::wstring szCmd = L"explorer.exe";
std::wstring szParm= L"/N,::{645FF040-5081-101B-9F08-00AA002F954E}"; std::wstring szParm= L"/N,::{645FF040-5081-101B-9F08-00AA002F954E}";
ShellExecute(NULL,L"open",szCmd.c_str(),szParm.c_str(),NULL,SW_SHOW); ShellExecute(NULL,L"open",szCmd.c_str(),szParm.c_str(),NULL,SW_SHOW);
return; return;
} }
} }
} }

View File

@@ -77,7 +77,7 @@ BOOL CALLBACK EnumWindowProc ( HWND hWnd, LPARAM lParam )
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -186,7 +186,7 @@ UINT Update(UINT id)
{ {
if (processName) if (processName)
{ {
if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded)) if (EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
{ {
if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer))) if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer)))
{ {

View File

@@ -36,7 +36,7 @@ __declspec( dllexport ) LPCTSTR GetPluginAuthor();
#pragma pack(1) #pragma pack(1)
struct SpeedFanData struct SpeedFanData
{ {
WORD version; WORD version;
WORD flags; WORD flags;
@@ -50,7 +50,7 @@ struct SpeedFanData
INT volts[32]; INT volts[32];
}; };
enum SensorType enum SensorType
{ {
TYPE_TEMP, TYPE_TEMP,
TYPE_FAN, TYPE_FAN,
@@ -73,7 +73,7 @@ static std::map<UINT, UINT> g_Numbers;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -99,15 +99,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
if (_wcsicmp(L"C", scale) == 0) if (_wcsicmp(L"C", scale) == 0)
{ {
g_Scales[id] = SCALE_CENTIGRADE; g_Scales[id] = SCALE_CENTIGRADE;
} }
else if (_wcsicmp(L"F", scale) == 0) else if (_wcsicmp(L"F", scale) == 0)
{ {
g_Scales[id] = SCALE_FARENHEIT; g_Scales[id] = SCALE_FARENHEIT;
} }
else if (_wcsicmp(L"K", scale) == 0) else if (_wcsicmp(L"K", scale) == 0)
{ {
g_Scales[id] = SCALE_KELVIN; g_Scales[id] = SCALE_KELVIN;
} }
else else
{ {
std::wstring error = L"SpeedFanScale="; std::wstring error = L"SpeedFanScale=";
@@ -118,15 +118,15 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
} }
} }
else if (_wcsicmp(L"FAN", type) == 0) else if (_wcsicmp(L"FAN", type) == 0)
{ {
g_Types[id] = TYPE_FAN; g_Types[id] = TYPE_FAN;
} }
else if (_wcsicmp(L"VOLTAGE", type) == 0) else if (_wcsicmp(L"VOLTAGE", type) == 0)
{ {
g_Types[id] = TYPE_VOLT; g_Types[id] = TYPE_VOLT;
} }
else else
{ {
std::wstring error = L"SpeedFanType="; std::wstring error = L"SpeedFanType=";
@@ -137,7 +137,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
} }
LPCTSTR data = ReadConfigString(section, L"SpeedFanNumber", L"0"); LPCTSTR data = ReadConfigString(section, L"SpeedFanNumber", L"0");
if (data) if (data)
{ {
@@ -153,13 +153,13 @@ The function returns the new value.
*/ */
double Update2(UINT id) double Update2(UINT id)
{ {
double value = 0.0; double value = 0.0;
std::map<UINT, SensorType>::const_iterator type = g_Types.find(id); std::map<UINT, SensorType>::const_iterator type = g_Types.find(id);
std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id); std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id);
std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id); std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id);
if(type == g_Types.end() || number == g_Numbers.end()) if (type == g_Types.end() || number == g_Numbers.end())
{ {
return 0.0; // No id in the map. How this can be ???? return 0.0; // No id in the map. How this can be ????
} }
@@ -179,7 +179,7 @@ double Update2(UINT id)
return value; return value;
} }
} }
return 0.0; return 0.0;
} }
@@ -216,10 +216,10 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
{ {
SpeedFanData* ptr; SpeedFanData* ptr;
HANDLE hData; HANDLE hData;
hData = OpenFileMapping(FILE_MAP_READ, FALSE, L"SFSharedMemory_ALM"); hData = OpenFileMapping(FILE_MAP_READ, FALSE, L"SFSharedMemory_ALM");
if (hData == NULL) return false; if (hData == NULL) return false;
ptr = (SpeedFanData*)MapViewOfFile(hData, FILE_MAP_READ, 0, 0, 0); ptr = (SpeedFanData*)MapViewOfFile(hData, FILE_MAP_READ, 0, 0, 0);
if (ptr == 0) if (ptr == 0)
{ {
@@ -229,7 +229,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
if (ptr->version == 1) if (ptr->version == 1)
{ {
switch(type) switch(type)
{ {
case TYPE_TEMP: case TYPE_TEMP:
if (number < ptr->NumTemps) if (number < ptr->NumTemps)
@@ -272,7 +272,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
UnmapViewOfFile(ptr); UnmapViewOfFile(ptr);
CloseHandle(hData); CloseHandle(hData);
return true; return true;
} }

View File

@@ -37,7 +37,7 @@ __declspec( dllexport ) UINT GetPluginVersion();
__declspec( dllexport ) LPCTSTR GetPluginAuthor(); __declspec( dllexport ) LPCTSTR GetPluginAuthor();
} }
typedef struct typedef struct
{ {
int count; //Number of monitors int count; //Number of monitors
HMONITOR m_Monitors[32]; //Monitor info HMONITOR m_Monitors[32]; //Monitor info
@@ -87,7 +87,7 @@ static std::map<UINT, UINT> g_Datas;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -101,109 +101,109 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
/* Read our own settings from the ini-file */ /* Read our own settings from the ini-file */
LPCTSTR type = ReadConfigString(section, L"SysInfoType", L""); LPCTSTR type = ReadConfigString(section, L"SysInfoType", L"");
if(type) if (type)
{ {
if (_wcsicmp(L"COMPUTER_NAME", type) == 0) if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
{ {
g_Types[id] = COMPUTER_NAME; g_Types[id] = COMPUTER_NAME;
} }
else if (_wcsicmp(L"USER_NAME", type) == 0) else if (_wcsicmp(L"USER_NAME", type) == 0)
{ {
g_Types[id] = USER_NAME; g_Types[id] = USER_NAME;
} }
else if (_wcsicmp(L"WORK_AREA", type) == 0) else if (_wcsicmp(L"WORK_AREA", type) == 0)
{ {
g_Types[id] = WORK_AREA; g_Types[id] = WORK_AREA;
} }
else if (_wcsicmp(L"SCREEN_SIZE", type) == 0) else if (_wcsicmp(L"SCREEN_SIZE", type) == 0)
{ {
g_Types[id] = SCREEN_SIZE; g_Types[id] = SCREEN_SIZE;
} }
else if (_wcsicmp(L"RAS_STATUS", type) == 0) else if (_wcsicmp(L"RAS_STATUS", type) == 0)
{ {
g_Types[id] = RAS_STATUS; g_Types[id] = RAS_STATUS;
} }
else if (_wcsicmp(L"OS_VERSION", type) == 0) else if (_wcsicmp(L"OS_VERSION", type) == 0)
{ {
g_Types[id] = OS_VERSION; g_Types[id] = OS_VERSION;
} }
else if (_wcsicmp(L"OS_BITS", type) == 0) else if (_wcsicmp(L"OS_BITS", type) == 0)
{ {
g_Types[id] = OS_BITS; g_Types[id] = OS_BITS;
} }
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0) else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
{ {
g_Types[id] = ADAPTER_DESCRIPTION; g_Types[id] = ADAPTER_DESCRIPTION;
} }
else if (_wcsicmp(L"NET_MASK", type) == 0) else if (_wcsicmp(L"NET_MASK", type) == 0)
{ {
g_Types[id] = NET_MASK; g_Types[id] = NET_MASK;
} }
else if (_wcsicmp(L"IP_ADDRESS", type) == 0) else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
{ {
g_Types[id] = IP_ADDRESS; g_Types[id] = IP_ADDRESS;
} }
else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0) else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
{ {
g_Types[id] = GATEWAY_ADDRESS; g_Types[id] = GATEWAY_ADDRESS;
} }
else if (_wcsicmp(L"HOST_NAME", type) == 0) else if (_wcsicmp(L"HOST_NAME", type) == 0)
{ {
g_Types[id] = HOST_NAME; g_Types[id] = HOST_NAME;
} }
else if (_wcsicmp(L"DOMAIN_NAME", type) == 0) else if (_wcsicmp(L"DOMAIN_NAME", type) == 0)
{ {
g_Types[id] = DOMAIN_NAME; g_Types[id] = DOMAIN_NAME;
} }
else if (_wcsicmp(L"DNS_SERVER", type) == 0) else if (_wcsicmp(L"DNS_SERVER", type) == 0)
{ {
g_Types[id] = DNS_SERVER; g_Types[id] = DNS_SERVER;
} }
else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0) else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0)
{ {
g_Types[id] = WORK_AREA_TOP; g_Types[id] = WORK_AREA_TOP;
} }
else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0) else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0)
{ {
g_Types[id] = WORK_AREA_LEFT; g_Types[id] = WORK_AREA_LEFT;
} }
else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0) else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0)
{ {
g_Types[id] = WORK_AREA_WIDTH; g_Types[id] = WORK_AREA_WIDTH;
} }
else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0) else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0)
{ {
g_Types[id] = WORK_AREA_HEIGHT; g_Types[id] = WORK_AREA_HEIGHT;
} }
else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0) else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0)
{ {
g_Types[id] = SCREEN_WIDTH; g_Types[id] = SCREEN_WIDTH;
} }
else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0) else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0)
{ {
g_Types[id] = SCREEN_HEIGHT; g_Types[id] = SCREEN_HEIGHT;
} }
else if (_wcsicmp(L"NUM_MONITORS", type) == 0) else if (_wcsicmp(L"NUM_MONITORS", type) == 0)
{ {
g_Types[id] = NUM_MONITORS; g_Types[id] = NUM_MONITORS;
} }
else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0) else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0)
{ {
g_Types[id] = VIRTUAL_SCREEN_TOP; g_Types[id] = VIRTUAL_SCREEN_TOP;
} }
else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0) else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0)
{ {
g_Types[id] = VIRTUAL_SCREEN_LEFT; g_Types[id] = VIRTUAL_SCREEN_LEFT;
} }
else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0) else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0)
{ {
g_Types[id] = VIRTUAL_SCREEN_WIDTH; g_Types[id] = VIRTUAL_SCREEN_WIDTH;
} }
else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0) else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0)
{ {
g_Types[id] = VIRTUAL_SCREEN_HEIGHT; g_Types[id] = VIRTUAL_SCREEN_HEIGHT;
} }
else else
{ {
std::wstring error = L"SysInfoType="; std::wstring error = L"SysInfoType=";
@@ -248,7 +248,7 @@ std::wstring ConvertToWide(LPCSTR str)
This function is called when the value should be This function is called when the value should be
returned as a string. returned as a string.
*/ */
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
static WCHAR buffer[4096]; static WCHAR buffer[4096];
UINT data; UINT data;
@@ -256,8 +256,8 @@ LPCTSTR GetString(UINT id, UINT flags)
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id); std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id); std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
if(typeIter == g_Types.end()) return NULL; if (typeIter == g_Types.end()) return NULL;
if(dataIter == g_Datas.end()) if (dataIter == g_Datas.end())
{ {
data = 0; data = 0;
} }
@@ -321,11 +321,11 @@ LPCTSTR GetString(UINT id, UINT flags)
if (data >= 1000) if (data >= 1000)
{ {
data = data-999; data = data-999;
for(UINT i=0; i<ipTable->dwNumEntries; i++) for (UINT i=0; i<ipTable->dwNumEntries; i++)
{ {
if((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue; if ((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
data--; data--;
if(data==0) if (data==0)
{ {
DWORD ip = ipTable->table[i].dwAddr; DWORD ip = ipTable->table[i].dwAddr;
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256); wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
@@ -423,8 +423,8 @@ double Update2(UINT id)
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id); std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id); std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
if(typeIter == g_Types.end()) return NULL; if (typeIter == g_Types.end()) return NULL;
if(dataIter == g_Datas.end()) if (dataIter == g_Datas.end())
{ {
data = 0; data = 0;
} }
@@ -433,16 +433,16 @@ double Update2(UINT id)
data = (*dataIter).second; data = (*dataIter).second;
} }
if(data) //For speed purposes, only check if they specify a non-primary monitor. if (data) //For speed purposes, only check if they specify a non-primary monitor.
{ {
if(GetSystemMetrics(SM_CMONITORS)>32) if (GetSystemMetrics(SM_CMONITORS)>32)
{ {
std::wstring error = L"That's alot of monitors! 32 is the max."; std::wstring error = L"That's alot of monitors! 32 is the max.";
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR); MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
exit(-1); exit(-1);
} }
m_Monitors.count = 0; m_Monitors.count = 0;
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors)); EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, (LPARAM)(&m_Monitors));
} }
@@ -633,17 +633,17 @@ BOOL CheckConnection()
static HRASCONN g_hRasConn=NULL; static HRASCONN g_hRasConn=NULL;
RASCONNSTATUS rasStatus; RASCONNSTATUS rasStatus;
LPRASCONN lpRasConn=NULL; LPRASCONN lpRasConn=NULL;
DWORD cbBuf=0; DWORD cbBuf=0;
DWORD cConn=1; DWORD cConn=1;
DWORD dwRet=0; DWORD dwRet=0;
if(g_hRasConn==NULL) { if (g_hRasConn==NULL) {
// Enumerate connections // Enumerate connections
cbBuf=sizeof(RASCONN); cbBuf=sizeof(RASCONN);
if(((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) { if (((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
lpRasConn->dwSize=sizeof(RASCONN); lpRasConn->dwSize=sizeof(RASCONN);
if(0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) { if (0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
if(cConn!=0) { if (cConn!=0) {
g_hRasConn=lpRasConn->hrasconn; g_hRasConn=lpRasConn->hrasconn;
} }
} }
@@ -651,19 +651,19 @@ BOOL CheckConnection()
} }
} }
if(g_hRasConn!=NULL) { if (g_hRasConn!=NULL) {
// get connection status // get connection status
rasStatus.dwSize=sizeof(RASCONNSTATUS); rasStatus.dwSize=sizeof(RASCONNSTATUS);
dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus ); dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus );
if(dwRet==0) { if (dwRet==0) {
// Check for connection // Check for connection
if(rasStatus.rasconnstate==RASCS_Connected) return TRUE; if (rasStatus.rasconnstate==RASCS_Connected) return TRUE;
} else { } else {
g_hRasConn=NULL; g_hRasConn=NULL;
} }
} }
return FALSE; return FALSE;
} }
UINT GetPluginVersion() UINT GetPluginVersion()

View File

@@ -45,28 +45,28 @@ DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR i
{ {
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T(""))); std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
if(TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id); if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
else if(TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id); else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
else if(TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id); else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
else if(TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id); else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
else if(TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id); else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
else if(TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id); else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
else if(TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id); else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
else if(TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id); else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
return NULL; return NULL;
} }
UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section) UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{ {
if(InstanceCount == 0) if (InstanceCount == 0)
{ {
hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window")); hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window"));
hWndMessageWindow = CreateMessageWindow(); hWndMessageWindow = CreateMessageWindow();
} }
InstanceCount++; InstanceCount++;
if(!PluginRegistered && FindDexpotWindow()) if (!PluginRegistered && FindDexpotWindow())
{ {
SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow); SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0); CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
@@ -82,9 +82,9 @@ UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
void DexpotMeasure::Finalize() void DexpotMeasure::Finalize()
{ {
InstanceCount--; InstanceCount--;
if(InstanceCount == 0) if (InstanceCount == 0)
{ {
if(PluginRegistered) if (PluginRegistered)
{ {
SendNotifyMessage(hWndDexpot, DEX_UNREGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow); SendNotifyMessage(hWndDexpot, DEX_UNREGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
PluginRegistered = FALSE; PluginRegistered = FALSE;
@@ -113,7 +113,7 @@ void DexpotMeasure::OnDexpotStarted()
BOOL DexpotMeasure::FindDexpotWindow() BOOL DexpotMeasure::FindDexpotWindow()
{ {
if(IsWindow(hWndDexpot)) return TRUE; if (IsWindow(hWndDexpot)) return TRUE;
hWndDexpot = FindWindow(DEXPOTCLASS, DEXPOTTITLE); hWndDexpot = FindWindow(DEXPOTCLASS, DEXPOTTITLE);
return hWndDexpot != NULL; return hWndDexpot != NULL;
} }
@@ -153,14 +153,14 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
{ {
case DEX_SWITCHED: case DEX_SWITCHED:
CurrentDesktop = HIWORD(lParam); CurrentDesktop = HIWORD(lParam);
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i) for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
{ {
(*i)->OnSwitched(LOWORD(lParam), HIWORD(lParam), LOWORD(wParam), HIWORD(wParam)); (*i)->OnSwitched(LOWORD(lParam), HIWORD(lParam), LOWORD(wParam), HIWORD(wParam));
} }
return 0; return 0;
case DEX_DESKTOPCOUNTCHANGED: case DEX_DESKTOPCOUNTCHANGED:
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i) for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
{ {
(*i)->OnDesktopCountChanged((int)wParam); (*i)->OnDesktopCountChanged((int)wParam);
} }
@@ -168,21 +168,21 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
case DEX_SHUTDOWN: case DEX_SHUTDOWN:
PluginRegistered = FALSE; PluginRegistered = FALSE;
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i) for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
{ {
(*i)->OnShutdown(); (*i)->OnShutdown();
} }
return 0; return 0;
case DEX_DESKTOPCONFIGURATIONCHANGED: case DEX_DESKTOPCONFIGURATIONCHANGED:
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i) for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
{ {
(*i)->OnDesktopConfigurationChanged(); (*i)->OnDesktopConfigurationChanged();
} }
return 0; return 0;
case WM_COPYDATA: case WM_COPYDATA:
if((HWND) wParam == hWndDexpot) if ((HWND) wParam == hWndDexpot)
{ {
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam; COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
switch(LOWORD(cds->dwData)) switch(LOWORD(cds->dwData))
@@ -198,17 +198,17 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
return 0; return 0;
default: default:
if(message == WM_DEXPOTSTARTED) if (message == WM_DEXPOTSTARTED)
{ {
hWndDexpot = (HWND) wParam; hWndDexpot = (HWND) wParam;
if(!hWndDexpot) FindDexpotWindow(); if (!hWndDexpot) FindDexpotWindow();
if(hWndDexpot) if (hWndDexpot)
{ {
SendMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow); SendMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0); CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
PluginRegistered = TRUE; PluginRegistered = TRUE;
} }
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i) for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
{ {
(*i)->OnDexpotStarted(); (*i)->OnDexpotStarted();
} }
@@ -222,7 +222,7 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
/* /*
* DexpotDesktopCountMeasure * DexpotDesktopCountMeasure
* *
*/ */
DexpotDesktopCountMeasure::DexpotDesktopCountMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotDesktopCountMeasure::DexpotDesktopCountMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
@@ -230,11 +230,11 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{ {
DesktopCount = 0; DesktopCount = 0;
OnChange = ReadConfigString(section, _T("VDOnChange"), _T("")); OnChange = ReadConfigString(section, _T("VDOnChange"), _T(""));
CountType = Total; CountType = Total;
LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T("")); LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
if(_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns; if (_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
else if(_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows; else if (_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
DexpotMeasure::Initialize(iniFile, section); DexpotMeasure::Initialize(iniFile, section);
return 20; return 20;
@@ -242,25 +242,25 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
void DexpotDesktopCountMeasure::InitializeData() void DexpotDesktopCountMeasure::InitializeData()
{ {
if(PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0); if (PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
} }
UINT DexpotDesktopCountMeasure::Update() UINT DexpotDesktopCountMeasure::Update()
{ {
if(CountType == Rows) return 1; if (CountType == Rows) return 1;
else return DesktopCount; else return DesktopCount;
} }
void DexpotDesktopCountMeasure::OnDesktopCountChanged(int NewCount) void DexpotDesktopCountMeasure::OnDesktopCountChanged(int NewCount)
{ {
DesktopCount = NewCount; DesktopCount = NewCount;
if(OnChange.length()) SendBang(OnChange); if (OnChange.length()) SendBang(OnChange);
} }
/* /*
* DexpotCurrentDesktopMeasure * DexpotCurrentDesktopMeasure
* *
*/ */
DexpotCurrentDesktopMeasure::DexpotCurrentDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotCurrentDesktopMeasure::DexpotCurrentDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
@@ -279,13 +279,13 @@ UINT DexpotCurrentDesktopMeasure::Update()
void DexpotCurrentDesktopMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger) void DexpotCurrentDesktopMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
{ {
if(OnChange.length()) SendBang(OnChange); if (OnChange.length()) SendBang(OnChange);
} }
/* /*
* DexpotVDMActiveMeasure * DexpotVDMActiveMeasure
* *
*/ */
DexpotVDMActiveMeasure::DexpotVDMActiveMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}; DexpotVDMActiveMeasure::DexpotVDMActiveMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {};
@@ -305,30 +305,30 @@ UINT DexpotVDMActiveMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
void DexpotVDMActiveMeasure::OnShutdown() void DexpotVDMActiveMeasure::OnShutdown()
{ {
if(OnDeactivate.length()) SendBang(OnDeactivate); if (OnDeactivate.length()) SendBang(OnDeactivate);
} }
void DexpotVDMActiveMeasure::OnDexpotStarted() void DexpotVDMActiveMeasure::OnDexpotStarted()
{ {
if(OnActivate.length()) SendBang(OnActivate); if (OnActivate.length()) SendBang(OnActivate);
} }
/* /*
* DexpotSwitchDesktopMeasure * DexpotSwitchDesktopMeasure
* *
*/ */
DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args) void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
{ {
if(PluginRegistered) if (PluginRegistered)
{ {
DWORD Desktop; DWORD Desktop;
if(_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1); if (_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
else if(_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2); else if (_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
else if(_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3); else if (_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
else Desktop = _ttoi(args); else Desktop = _ttoi(args);
SendNotifyMessage(hWndDexpot, DEX_SWITCHDESKTOP, 0, Desktop); SendNotifyMessage(hWndDexpot, DEX_SWITCHDESKTOP, 0, Desktop);
@@ -338,7 +338,7 @@ void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
/* /*
* DexpotScreenshotMeasure * DexpotScreenshotMeasure
* *
*/ */
DexpotScreenshotMeasure::DexpotScreenshotMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotScreenshotMeasure::DexpotScreenshotMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
@@ -356,7 +356,7 @@ UINT DexpotScreenshotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
UINT DexpotScreenshotMeasure::Update() UINT DexpotScreenshotMeasure::Update()
{ {
if(RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop)) if (RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
{ {
UpdateScreenshot(); UpdateScreenshot();
} }
@@ -375,7 +375,7 @@ void DexpotScreenshotMeasure::InitializeData()
void DexpotScreenshotMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger) void DexpotScreenshotMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
{ {
if(DesktopNumber == FromDesktop || DesktopNumber == 0) if (DesktopNumber == FromDesktop || DesktopNumber == 0)
{ {
UpdateScreenshot(); UpdateScreenshot();
} }
@@ -385,11 +385,11 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
{ {
int Desktop = DesktopNumber == 0 ? CurrentDesktop : DesktopNumber; int Desktop = DesktopNumber == 0 ? CurrentDesktop : DesktopNumber;
int nBytes = 0; int nBytes = 0;
BYTE *pBytes = NULL; BYTE *pBytes = NULL;
HANDLE fm; HANDLE fm;
HANDLE mutex; HANDLE mutex;
if(!IsWindow(hWndDexpot)) return; if (!IsWindow(hWndDexpot)) return;
int DesktopWidth = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPWIDTH, Desktop, 0); int DesktopWidth = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPWIDTH, Desktop, 0);
int DesktopHeight = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPHEIGHT, Desktop, 0); int DesktopHeight = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPHEIGHT, Desktop, 0);
@@ -398,9 +398,9 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
WaitForSingleObject(mutex, 2000); WaitForSingleObject(mutex, 2000);
fm = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, DesktopWidth * DesktopHeight * 4, L"Local\\DexpotScreenshotFilemap"); fm = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, DesktopWidth * DesktopHeight * 4, L"Local\\DexpotScreenshotFilemap");
pBytes = (BYTE*) MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0); pBytes = (BYTE*) MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if(pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0); if (pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
if(nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4) if (nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
{ {
HDC ScreenDC; HDC ScreenDC;
HDC MemDC; HDC MemDC;
@@ -415,10 +415,10 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
int ScaledHeight = Height; int ScaledHeight = Height;
int ScaledWidth = Width; int ScaledWidth = Width;
if(ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f); if (ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
if(ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f); if (ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
if(ScaledHeight == 0) ScaledHeight = DesktopHeight; if (ScaledHeight == 0) ScaledHeight = DesktopHeight;
if(ScaledWidth == 0) ScaledWidth = DesktopWidth; if (ScaledWidth == 0) ScaledWidth = DesktopWidth;
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER)); ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -433,7 +433,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
MemDC = CreateCompatibleDC(ScreenDC); MemDC = CreateCompatibleDC(ScreenDC);
MemDC2 = CreateCompatibleDC(ScreenDC); MemDC2 = CreateCompatibleDC(ScreenDC);
OriginalBitmap = CreateCompatibleBitmap(ScreenDC, DesktopWidth, DesktopHeight); OriginalBitmap = CreateCompatibleBitmap(ScreenDC, DesktopWidth, DesktopHeight);
SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0); SetDIBits(MemDC2, OriginalBitmap, 0, DesktopHeight, pBytes, &bmi, 0);
OldBitmap2 = SelectObject(MemDC2, (HGDIOBJ) OriginalBitmap); OldBitmap2 = SelectObject(MemDC2, (HGDIOBJ) OriginalBitmap);
nBytes = ScaledWidth * ScaledHeight * 4; nBytes = ScaledWidth * ScaledHeight * 4;
@@ -453,7 +453,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
bmfh.bfType = 0x4d42; bmfh.bfType = 0x4d42;
std::ofstream ofs(OutputFile.c_str(), std::ios_base::binary); std::ofstream ofs(OutputFile.c_str(), std::ios_base::binary);
if(ofs) if (ofs)
{ {
ofs.write((char*) &bmfh, sizeof(BITMAPFILEHEADER)); ofs.write((char*) &bmfh, sizeof(BITMAPFILEHEADER));
ofs.write((char*) &bmi, sizeof(BITMAPINFOHEADER)); ofs.write((char*) &bmi, sizeof(BITMAPINFOHEADER));
@@ -479,7 +479,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
/* /*
* DexpotDesktopNameMeasure * DexpotDesktopNameMeasure
* *
*/ */
DexpotDesktopNameMeasure::DexpotDesktopNameMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotDesktopNameMeasure::DexpotDesktopNameMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
@@ -492,7 +492,7 @@ UINT DexpotDesktopNameMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags) LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
{ {
UINT Desktop = (DesktopNumber == 0 ? CurrentDesktop : DesktopNumber) - 1; UINT Desktop = (DesktopNumber == 0 ? CurrentDesktop : DesktopNumber) - 1;
if(Desktop >= 0 && Desktop < DesktopNames.size()) if (Desktop >= 0 && Desktop < DesktopNames.size())
{ {
return DesktopNames[Desktop].c_str(); return DesktopNames[Desktop].c_str();
} }
@@ -505,18 +505,18 @@ LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
void DexpotDesktopNameMeasure::InitializeData() void DexpotDesktopNameMeasure::InitializeData()
{ {
if(PluginRegistered) if (PluginRegistered)
{ {
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0); int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
DesktopNames.resize(DesktopCount); DesktopNames.resize(DesktopCount);
if(DesktopNumber == 0) if (DesktopNumber == 0)
{ {
for(int i = 1; i <= DesktopCount; i++) for (int i = 1; i <= DesktopCount; i++)
{ {
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, i, (LPARAM) hWndMessageWindow); SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, i, (LPARAM) hWndMessageWindow);
} }
} }
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount) else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
{ {
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, DesktopNumber, (LPARAM) hWndMessageWindow); SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, DesktopNumber, (LPARAM) hWndMessageWindow);
} }
@@ -535,14 +535,14 @@ void DexpotDesktopNameMeasure::OnDesktopCountChanged(int NewCount)
void DexpotDesktopNameMeasure::SetDesktopName(UINT Desktop, std::wstring &Name) void DexpotDesktopNameMeasure::SetDesktopName(UINT Desktop, std::wstring &Name)
{ {
if(--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1); if (--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
if(Desktop >= 0) DesktopNames[Desktop] = Name; if (Desktop >= 0) DesktopNames[Desktop] = Name;
} }
/* /*
* DexpotDesktopWallpaperMeasure * DexpotDesktopWallpaperMeasure
* *
*/ */
DexpotDesktopWallpaperMeasure::DexpotDesktopWallpaperMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotDesktopWallpaperMeasure::DexpotDesktopWallpaperMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
@@ -554,12 +554,12 @@ UINT DexpotDesktopWallpaperMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags) LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
{ {
if(DesktopNumber == 0) if (DesktopNumber == 0)
{ {
SystemParametersInfo(SPI_GETDESKWALLPAPER, STRINGBUFFER_SIZE, StringBuffer, 0); SystemParametersInfo(SPI_GETDESKWALLPAPER, STRINGBUFFER_SIZE, StringBuffer, 0);
return StringBuffer; return StringBuffer;
} }
else if(DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size()) else if (DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
{ {
return DesktopWallpapers[DesktopNumber - 1].c_str(); return DesktopWallpapers[DesktopNumber - 1].c_str();
} }
@@ -570,18 +570,18 @@ LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
void DexpotDesktopWallpaperMeasure::InitializeData() void DexpotDesktopWallpaperMeasure::InitializeData()
{ {
if(PluginRegistered) if (PluginRegistered)
{ {
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0); int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
DesktopWallpapers.resize(DesktopCount); DesktopWallpapers.resize(DesktopCount);
if(DesktopNumber == 0) if (DesktopNumber == 0)
{ {
for(int i = 1; i <= DesktopCount; i++) for (int i = 1; i <= DesktopCount; i++)
{ {
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, i, (LPARAM) hWndMessageWindow); SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, i, (LPARAM) hWndMessageWindow);
} }
} }
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount) else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
{ {
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, DesktopNumber, (LPARAM) hWndMessageWindow); SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, DesktopNumber, (LPARAM) hWndMessageWindow);
} }
@@ -604,20 +604,20 @@ void DexpotDesktopWallpaperMeasure::OnDesktopCountChanged(int NewCount)
void DexpotDesktopWallpaperMeasure::SetDesktopWallpaper(UINT Desktop, std::wstring &Wallpaper) void DexpotDesktopWallpaperMeasure::SetDesktopWallpaper(UINT Desktop, std::wstring &Wallpaper)
{ {
if(--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1); if (--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
if(Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper; if (Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
} }
/* /*
* DexpotCommandMeasure * DexpotCommandMeasure
* *
*/ */
DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {} DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMeasure(instance, id) {}
void DexpotCommandMeasure::ExecuteBang(LPCTSTR args) void DexpotCommandMeasure::ExecuteBang(LPCTSTR args)
{ {
if(PluginRegistered) if (PluginRegistered)
{ {
COPYDATASTRUCT cds; COPYDATASTRUCT cds;

View File

@@ -28,7 +28,7 @@ std::map<std::wstring, VirtuaWinMeasure::MeasureType> VirtuaWinMeasure::StringTo
VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id) VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id)
{ {
if(StringToType.size() == 0) if (StringToType.size() == 0)
{ {
StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive)); StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive));
StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal)); StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal));
@@ -45,7 +45,7 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{ {
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T(""))); std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString); std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
if(i != StringToType.end()) if (i != StringToType.end())
{ {
Type = i->second; Type = i->second;
} }
@@ -62,9 +62,9 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
case DesktopCountTotal: case DesktopCountTotal:
{ {
LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T("")); LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
if(_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns; if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
else if(_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows; else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
if(FindVirtuaWinWindow()) if (FindVirtuaWinWindow())
{ {
return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0); return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
} }
@@ -81,7 +81,7 @@ void VirtuaWinMeasure::Finalize()
UINT VirtuaWinMeasure::Update() UINT VirtuaWinMeasure::Update()
{ {
if(!FindVirtuaWinWindow()) if (!FindVirtuaWinWindow())
{ {
return 0; return 0;
} }
@@ -130,7 +130,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
{ {
INT32 Desktop; INT32 Desktop;
if(!FindVirtuaWinWindow()) return; if (!FindVirtuaWinWindow()) return;
switch(Type) switch(Type)
{ {
@@ -142,7 +142,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
BOOL VirtuaWinMeasure::FindVirtuaWinWindow() BOOL VirtuaWinMeasure::FindVirtuaWinWindow()
{ {
if(IsWindow(vwHandle)) return TRUE; if (IsWindow(vwHandle)) return TRUE;
vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass")); vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass"));
return vwHandle != NULL; return vwHandle != NULL;
} }

View File

@@ -24,43 +24,43 @@
This plugin aims to give Rainmeter skins access to various virtual desktop This plugin aims to give Rainmeter skins access to various virtual desktop
managers through a common interface. The following VDMs are supported: managers through a common interface. The following VDMs are supported:
* Dexpot * Dexpot
* VirtuaWin * VirtuaWin
To add support for another virtual desktop manager, To add support for another virtual desktop manager,
1) implement a new class derived from VDMeasure 1) implement a new class derived from VDMeasure
2) include its header file below 2) include its header file below
3) add a new case for the "VDManager" config string in the Initialize 3) add a new case for the "VDManager" config string in the Initialize
funtion below funtion below
Different types of measures are identified using the "VDMeasureType" config Different types of measures are identified using the "VDMeasureType" config
string, i.e. string, i.e.
[VirtualDesktopsMeasure] [VirtualDesktopsMeasure]
Measure=Plugin Measure=Plugin
Plugin=VirtualDesktops.dll Plugin=VirtualDesktops.dll
VDManager=SomeVDM VDManager=SomeVDM
VDMeasureType=... VDMeasureType=...
The following basic measure types have to be implemented: The following basic measure types have to be implemented:
* VDMActive: returns 1 when the VDM is running, 0 otherwise * VDMActive: returns 1 when the VDM is running, 0 otherwise
* DesktopCount: returns the number of virtual desktops available; when * DesktopCount: returns the number of virtual desktops available; when
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns "VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
the number of columns or rows, respectively, in a grid of the number of columns or rows, respectively, in a grid of
desktops desktops
* CurrentDesktop: returns the number of the currently active desktop * CurrentDesktop: returns the number of the currently active desktop
* SwitchDesktop: when sent a desktop number as a bang, switches to the * SwitchDesktop: when sent a desktop number as a bang, switches to the
corresponding desktop corresponding desktop
You're welcome to add any other measure types that suit the feature set of You're welcome to add any other measure types that suit the feature set of
the virtual desktop manager in question. Examples can be found in the the virtual desktop manager in question. Examples can be found in the
existing implementations. existing implementations.
*/ */
#include "DexpotMeasure.h" #include "DexpotMeasure.h"
@@ -92,29 +92,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
VDMeasure *Measure = NULL; VDMeasure *Measure = NULL;
LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T("")); LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));
if(_tcsicmp(VDManager, _T("Dexpot")) == 0) if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
{ {
Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section); Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
} }
else if(_tcsicmp(VDManager, _T("VirtuaWin")) == 0) else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
{ {
Measure = new VirtuaWinMeasure(instance, id); Measure = new VirtuaWinMeasure(instance, id);
} }
if(Measure) if (Measure)
{ {
Measures.insert(std::make_pair(id, Measure)); Measures.insert(std::make_pair(id, Measure));
return Measure->Initialize(iniFile, section); return Measure->Initialize(iniFile, section);
} }
return 0; return 0;
} }
UINT Update(UINT id) UINT Update(UINT id)
{ {
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id); std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
if(i != Measures.end()) if (i != Measures.end())
{ {
return i->second->Update(); return i->second->Update();
} }
@@ -125,7 +125,7 @@ UINT Update(UINT id)
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id); std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
if(i != Measures.end()) if (i != Measures.end())
{ {
return i->second->GetString(flags); return i->second->GetString(flags);
} }
@@ -136,7 +136,7 @@ LPCTSTR GetString(UINT id, UINT flags)
void ExecuteBang(LPCTSTR args, UINT id) void ExecuteBang(LPCTSTR args, UINT id)
{ {
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id); std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
if(i != Measures.end()) if (i != Measures.end())
{ {
i->second->ExecuteBang(args); i->second->ExecuteBang(args);
} }
@@ -145,7 +145,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
void Finalize(HMODULE instance, UINT id) void Finalize(HMODULE instance, UINT id)
{ {
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id); std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
if(i != Measures.end()) if (i != Measures.end())
{ {
i->second->Finalize(); i->second->Finalize();
delete i->second; delete i->second;

View File

@@ -76,7 +76,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam);
void Log(const WCHAR* string); void Log(const WCHAR* string);
void ParseData(UrlData* urlData, LPCSTR parseData); void ParseData(UrlData* urlData, LPCSTR parseData);
CRITICAL_SECTION g_CriticalSection; CRITICAL_SECTION g_CriticalSection;
bool g_Initialized = false; bool g_Initialized = false;
static std::map<UINT, UrlData*> g_UrlData; static std::map<UINT, UrlData*> g_UrlData;
@@ -290,7 +290,7 @@ void FillCharacterEntityReferences()
g_CERs[L"lsaquo"] = (WCHAR)8249; g_CERs[L"lsaquo"] = (WCHAR)8249;
g_CERs[L"rsaquo"] = (WCHAR)8250; g_CERs[L"rsaquo"] = (WCHAR)8250;
g_CERs[L"euro"] = (WCHAR)8364; g_CERs[L"euro"] = (WCHAR)8364;
// for ISO 8859-1 characters // for ISO 8859-1 characters
g_CERs[L"nbsp"] = (WCHAR)160; g_CERs[L"nbsp"] = (WCHAR)160;
g_CERs[L"iexcl"] = (WCHAR)161; g_CERs[L"iexcl"] = (WCHAR)161;
@@ -388,7 +388,7 @@ void FillCharacterEntityReferences()
g_CERs[L"yacute"] = (WCHAR)253; g_CERs[L"yacute"] = (WCHAR)253;
g_CERs[L"thorn"] = (WCHAR)254; g_CERs[L"thorn"] = (WCHAR)254;
g_CERs[L"yuml"] = (WCHAR)255; g_CERs[L"yuml"] = (WCHAR)255;
// for symbols, mathematical symbols, and Greek letters // for symbols, mathematical symbols, and Greek letters
g_CERs[L"fnof"] = (WCHAR)402; g_CERs[L"fnof"] = (WCHAR)402;
g_CERs[L"Alpha"] = (WCHAR)913; g_CERs[L"Alpha"] = (WCHAR)913;
@@ -565,7 +565,7 @@ HWND FindMeterWindow(HWND parent = NULL)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -577,7 +577,7 @@ HWND FindMeterWindow(HWND parent = NULL)
*/ */
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{ {
LPCTSTR tmpSz; LPCTSTR tmpSz;
if (!g_Initialized) if (!g_Initialized)
{ {
@@ -602,10 +602,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
data->proxy = ReadConfigString(section, L"ProxyServer", L""); data->proxy = ReadConfigString(section, L"ProxyServer", L"");
data->downloadFile = ReadConfigString(section, L"DownloadFile", L""); data->downloadFile = ReadConfigString(section, L"DownloadFile", L"");
data->debugFileLocation = ReadConfigString(section, L"Debug2File", L"c:\\WebParserDump.txt"); data->debugFileLocation = ReadConfigString(section, L"Debug2File", L"c:\\WebParserDump.txt");
if(data->debugFileLocation.find(L"\\") == std::wstring::npos) if (data->debugFileLocation.find(L"\\") == std::wstring::npos)
{ {
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1); std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
str += data->debugFileLocation; str += data->debugFileLocation;
Log(str.c_str()); Log(str.c_str());
data->debugFileLocation = str; data->debugFileLocation = str;
@@ -706,12 +706,12 @@ double Update2(UINT id)
// Find the data for this instance (the data structure is not changed by anyone so this should be safe) // Find the data for this instance (the data structure is not changed by anyone so this should be safe)
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id); std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
if(urlIter != g_UrlData.end()) if (urlIter != g_UrlData.end())
{ {
urlData = (*urlIter).second; urlData = (*urlIter).second;
} }
if (urlData) if (urlData)
{ {
if (urlData->download && urlData->regExp.empty() && urlData->url.find(L'[') == std::wstring::npos) if (urlData->download && urlData->regExp.empty() && urlData->url.find(L'[') == std::wstring::npos)
{ {
@@ -749,7 +749,7 @@ double Update2(UINT id)
{ {
// Make sure that the thread is not writing to the result at the same time // Make sure that the thread is not writing to the result at the same time
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
if (!urlData->resultString.empty()) if (!urlData->resultString.empty())
{ {
value = wcstod(urlData->resultString.c_str(), NULL); value = wcstod(urlData->resultString.c_str(), NULL);
@@ -837,7 +837,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
urlData->threadHandle = 0; urlData->threadHandle = 0;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
return 0; // thread completed successfully return 0; // thread completed successfully
} }
void ParseData(UrlData* urlData, LPCSTR parseData) void ParseData(UrlData* urlData, LPCSTR parseData)
@@ -851,12 +851,12 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
int ovector[OVECCOUNT]; int ovector[OVECCOUNT];
int rc; int rc;
int flags = PCRE_UTF8; int flags = PCRE_UTF8;
if (urlData->codepage == 0) if (urlData->codepage == 0)
{ {
flags = 0; flags = 0;
} }
// Compile the regular expression in the first argument // Compile the regular expression in the first argument
re = pcre_compile( re = pcre_compile(
ConvertWideToUTF8(urlData->regExp.c_str()).c_str(), // the pattern ConvertWideToUTF8(urlData->regExp.c_str()).c_str(), // the pattern
@@ -864,7 +864,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
&error, // for error message &error, // for error message
&erroffset, // for error offset &erroffset, // for error offset
NULL); // use default character tables NULL); // use default character tables
if (re != NULL) if (re != NULL)
{ {
// Compilation succeeded: match the subject in the second argument // Compilation succeeded: match the subject in the second argument
@@ -878,7 +878,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
} }
dwSize = strlen(parseData); dwSize = strlen(parseData);
rc = pcre_exec( rc = pcre_exec(
re, // the compiled pattern re, // the compiled pattern
NULL, // no extra data - we didn't study the pattern NULL, // no extra data - we didn't study the pattern
@@ -888,8 +888,8 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
0, // default options 0, // default options
ovector, // output vector for substring information ovector, // output vector for substring information
OVECCOUNT); // number of elements in the output vector OVECCOUNT); // number of elements in the output vector
if (rc >= 0) if (rc >= 0)
{ {
if (rc == 0) if (rc == 0)
@@ -941,7 +941,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
log += L"] Not enough substrings!"; log += L"] Not enough substrings!";
Log(log.c_str()); Log(log.c_str());
// Clear the old result // Clear the old result
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
urlData->resultString.clear(); urlData->resultString.clear();
if (urlData->download) if (urlData->download)
@@ -975,7 +975,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
std::string szResult(substring_start, substring_length); std::string szResult(substring_start, substring_length);
if (!((*i).second)->regExp.empty()) if (!((*i).second)->regExp.empty())
{ {
// Change the index and parse the substring // Change the index and parse the substring
int index = (*i).second->stringIndex; int index = (*i).second->stringIndex;
@@ -985,9 +985,9 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
} }
else else
{ {
// Set the result // Set the result
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
// Substitude the [measure] with szResult // Substitude the [measure] with szResult
std::wstring wzResult = ConvertUTF8ToWide(szResult.c_str()); std::wstring wzResult = ConvertUTF8ToWide(szResult.c_str());
std::wstring wzUrl = ((*i).second)->url; std::wstring wzUrl = ((*i).second)->url;
@@ -1024,7 +1024,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
log += L"] Not enough substrings!"; log += L"] Not enough substrings!";
Log(log.c_str()); Log(log.c_str());
// Clear the old result // Clear the old result
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
((*i).second)->resultString.clear(); ((*i).second)->resultString.clear();
if ((*i).second->download) if ((*i).second->download)
@@ -1076,7 +1076,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
} }
// Release memory used for the compiled pattern // Release memory used for the compiled pattern
pcre_free(re); pcre_free(re);
} }
else else
@@ -1114,7 +1114,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
} }
else else
{ {
if (!urlData->finishAction.empty()) if (!urlData->finishAction.empty())
{ {
HWND wnd = FindMeterWindow(); HWND wnd = FindMeterWindow();
@@ -1156,7 +1156,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
url = urlData->resultString; url = urlData->resultString;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
std::wstring::size_type pos = url.find(L':'); std::wstring::size_type pos = url.find(L':');
if (pos == std::wstring::npos && !url.empty()) // No protocol if (pos == std::wstring::npos && !url.empty()) // No protocol
{ {
@@ -1420,8 +1420,8 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
urlData->downloadedFile = fullpath; urlData->downloadedFile = fullpath;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
if (!urlData->finishAction.empty()) if (!urlData->finishAction.empty())
{ {
HWND wnd = FindMeterWindow(); HWND wnd = FindMeterWindow();
@@ -1505,20 +1505,20 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
urlData->dlThreadHandle = 0; urlData->dlThreadHandle = 0;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
return 0; // thread completed successfully return 0; // thread completed successfully
} }
/* /*
This function is called when the value should be This function is called when the value should be
returned as a string. returned as a string.
*/ */
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
static std::wstring resultString; static std::wstring resultString;
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id); std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
if(urlIter != g_UrlData.end()) if (urlIter != g_UrlData.end())
{ {
EnterCriticalSection(&g_CriticalSection); EnterCriticalSection(&g_CriticalSection);
if (((*urlIter).second)->download) if (((*urlIter).second)->download)
@@ -1546,7 +1546,7 @@ void Finalize(HMODULE instance, UINT id)
{ {
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id); std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
if(urlIter != g_UrlData.end()) if (urlIter != g_UrlData.end())
{ {
if (((*urlIter).second)->threadHandle) if (((*urlIter).second)->threadHandle)
{ {
@@ -1555,7 +1555,7 @@ void Finalize(HMODULE instance, UINT id)
TerminateThread(((*urlIter).second)->threadHandle, 0); TerminateThread(((*urlIter).second)->threadHandle, 0);
(*urlIter).second->threadHandle = NULL; (*urlIter).second->threadHandle = NULL;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
} }
@@ -1566,7 +1566,7 @@ void Finalize(HMODULE instance, UINT id)
TerminateThread(((*urlIter).second)->dlThreadHandle, 0); TerminateThread(((*urlIter).second)->dlThreadHandle, 0);
(*urlIter).second->dlThreadHandle = NULL; (*urlIter).second->dlThreadHandle = NULL;
LeaveCriticalSection(&g_CriticalSection); LeaveCriticalSection(&g_CriticalSection);
} }
@@ -1618,7 +1618,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
std::wstring err = L"WebParser: Fetching URL: "; std::wstring err = L"WebParser: Fetching URL: ";
err += url; err += url;
Log(err.c_str()); Log(err.c_str());
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE; DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
if (forceReload) if (forceReload)
{ {
@@ -1662,14 +1662,14 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
{ {
break; break;
} }
// Determine the buffer size to hold the new data and the data // Determine the buffer size to hold the new data and the data
// already written (if any). // already written (if any).
nBufferSize = *dwDataSize + dwSize; nBufferSize = *dwDataSize + dwSize;
// Allocate the output buffer. // Allocate the output buffer.
lpOutPut = new BYTE[nBufferSize + 2]; lpOutPut = new BYTE[nBufferSize + 2];
// Make sure the buffer is not the initial buffer. // Make sure the buffer is not the initial buffer.
if (lpHolding != NULL) if (lpHolding != NULL)
{ {
@@ -1695,7 +1695,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
// End with double null // End with double null
lpOutPut[dwSize] = 0; lpOutPut[dwSize] = 0;
lpOutPut[dwSize + 1] = 0; lpOutPut[dwSize + 1] = 0;
// Increment the number of buffers read. // Increment the number of buffers read.
++nCounter; ++nCounter;
@@ -1703,7 +1703,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
memset(lpData, 0, CHUNK_SIZE); memset(lpData, 0, CHUNK_SIZE);
} }
} while (TRUE); } while (TRUE);
// Close the HINTERNET handle. // Close the HINTERNET handle.
InternetCloseHandle(hUrlDump); InternetCloseHandle(hUrlDump);
@@ -1734,7 +1734,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
if (errorMsg == NULL) if (errorMsg == NULL)
{ {
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR) if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
{ {
WCHAR szBuffer[1024]; WCHAR szBuffer[1024];
DWORD dwError, dwLen = 1024; DWORD dwError, dwLen = 1024;
@@ -1757,10 +1757,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
{ {
LPVOID lpMsgBuf = NULL; LPVOID lpMsgBuf = NULL;
FormatMessage( FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK, FORMAT_MESSAGE_MAX_WIDTH_MASK,
GetModuleHandle(L"wininet"), GetModuleHandle(L"wininet"),
@@ -1768,10 +1768,10 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, (LPTSTR) &lpMsgBuf,
0, 0,
NULL NULL
); );
if (lpMsgBuf == NULL) if (lpMsgBuf == NULL)
{ {
err += L"Unknown error"; err += L"Unknown error";
} }

View File

@@ -73,7 +73,7 @@ PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -90,9 +90,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
DWORD dwErr; DWORD dwErr;
g_Instances++; g_Instances++;
//Create WINLAN API Handle //Create WINLAN API Handle
if(hClient == NULL){ if (hClient == NULL){
dwErr = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient ); dwErr = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient );
if( ERROR_SUCCESS != dwErr ){ if ( ERROR_SUCCESS != dwErr ){
WCHAR buffer[256]; WCHAR buffer[256];
wsprintf(buffer, L"WifiStatus.dll: Unable to open WLAN API Handle. Error code (%d): %s",(int)dwErr,getDot11str(dwErr,5)); wsprintf(buffer, L"WifiStatus.dll: Unable to open WLAN API Handle. Error code (%d): %s",(int)dwErr,getDot11str(dwErr,5));
Log(buffer); Log(buffer);
@@ -100,9 +100,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
} }
//Query list of WLAN interfaces //Query list of WLAN interfaces
if(pIntfList == NULL){ if (pIntfList == NULL){
dwErr= WlanEnumInterfaces(hClient, NULL, &pIntfList); dwErr= WlanEnumInterfaces(hClient, NULL, &pIntfList);
if(( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){ if (( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
WCHAR buffer[256]; WCHAR buffer[256];
wsprintf(buffer, L"WifiStatus.dll: Unable to find any WLAN interfaces/adapters. Error code %d",(int) dwErr); wsprintf(buffer, L"WifiStatus.dll: Unable to find any WLAN interfaces/adapters. Error code %d",(int) dwErr);
Log(buffer); Log(buffer);
@@ -111,22 +111,22 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
//Select a WLAN interface, default 0. //Select a WLAN interface, default 0.
LPCTSTR data = ReadConfigString(section, L"WifiIntfID", L""); LPCTSTR data = ReadConfigString(section, L"WifiIntfID", L"");
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){ if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
if(_wtoi(data) < (int)pIntfList->dwNumberOfItems){ if (_wtoi(data) < (int)pIntfList->dwNumberOfItems){
pInterface = &pIntfList->InterfaceInfo[_wtoi(data)]; pInterface = &pIntfList->InterfaceInfo[_wtoi(data)];
} else { } else {
WCHAR buffer[256]; WCHAR buffer[256];
wsprintf(buffer, L"WifiStatus.dll: Adapter is disabled or invalid (WifiIntfID=%s), fix INTF ID(default=0) or enable the adapter.",data); wsprintf(buffer, L"WifiStatus.dll: Adapter is disabled or invalid (WifiIntfID=%s), fix INTF ID(default=0) or enable the adapter.",data);
Log(buffer); Log(buffer);
pInterface = &pIntfList->InterfaceInfo[0]; pInterface = &pIntfList->InterfaceInfo[0];
} }
} else { } else {
pInterface = &pIntfList->InterfaceInfo[0]; pInterface = &pIntfList->InterfaceInfo[0];
} }
//Select LIST style //Select LIST style
data = ReadConfigString(section, L"WifiListStyle", L""); data = ReadConfigString(section, L"WifiListStyle", L"");
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){ if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
if ( (_wtoi(data) >= 0) && (_wtoi(data) <= 3)){ if ( (_wtoi(data) >= 0) && (_wtoi(data) <= 3)){
g_meas_data[id].listStyle = _wtoi(data); g_meas_data[id].listStyle = _wtoi(data);
@@ -135,7 +135,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
wsprintf(buffer, L"WifiStatus.dll: Invalid List Style given (WifiListStyle=%s), defaulting to 0.",data); wsprintf(buffer, L"WifiStatus.dll: Invalid List Style given (WifiListStyle=%s), defaulting to 0.",data);
Log(buffer); Log(buffer);
g_meas_data[id].listStyle = 0; g_meas_data[id].listStyle = 0;
} }
} else { } else {
g_meas_data[id].listStyle = 0; g_meas_data[id].listStyle = 0;
} }
@@ -151,29 +151,29 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
wsprintf(buffer, L"WifiStatus.dll: Invalid List Limit given (WifiListLimit=%s), defaulting to 5.",data); wsprintf(buffer, L"WifiStatus.dll: Invalid List Limit given (WifiListLimit=%s), defaulting to 5.",data);
Log(buffer); Log(buffer);
g_meas_data[id].listMax = 5; g_meas_data[id].listMax = 5;
} }
} else { } else {
g_meas_data[id].listMax = 5; g_meas_data[id].listMax = 5;
} }
//Select type of measure //Select type of measure
MEASURETYPE infoType = UNKNOWN; MEASURETYPE infoType = UNKNOWN;
LPCTSTR type = ReadConfigString(section, L"WifiInfoType", L""); LPCTSTR type = ReadConfigString(section, L"WifiInfoType", L"");
if(type){ if (type){
if (_wcsicmp(L"SSID", type) == 0){ if (_wcsicmp(L"SSID", type) == 0){
infoType=SSID; infoType=SSID;
} }
else if (_wcsicmp(L"QUALITY", type) == 0){ else if (_wcsicmp(L"QUALITY", type) == 0){
infoType=QUALITY; infoType=QUALITY;
} }
else if (_wcsicmp(L"ENCRYPTION", type) == 0){ else if (_wcsicmp(L"ENCRYPTION", type) == 0){
infoType=ENCRYPTION; infoType=ENCRYPTION;
} }
else if (_wcsicmp(L"AUTH", type) == 0){ else if (_wcsicmp(L"AUTH", type) == 0){
infoType=AUTH; infoType=AUTH;
} }
else if (_wcsicmp(L"LIST", type) == 0){ else if (_wcsicmp(L"LIST", type) == 0){
infoType=LIST; infoType=LIST;
} }
else if (_wcsicmp(L"PHY", type) == 0){ else if (_wcsicmp(L"PHY", type) == 0){
infoType=PHY; infoType=PHY;
} else { } else {
@@ -202,11 +202,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
*/ */
UINT Update(UINT id) UINT Update(UINT id)
{ {
if(pInterface == NULL) return NULL; if (pInterface == NULL) return NULL;
//Get measure id, and identify type //Get measure id, and identify type
//std::map<UINT, MEASURETYPE>::iterator typeIter = g_Types.find(id); //std::map<UINT, MEASURETYPE>::iterator typeIter = g_Types.find(id);
//if(typeIter == g_Types.end()) return NULL; //if (typeIter == g_Types.end()) return NULL;
MEASURETYPE current_type = g_meas_data[id].type; MEASURETYPE current_type = g_meas_data[id].type;
switch(current_type) switch(current_type)
{ {
@@ -217,23 +217,23 @@ UINT Update(UINT id)
DWORD dwErr; DWORD dwErr;
GUID& intfGUID = pInterface->InterfaceGuid; GUID& intfGUID = pInterface->InterfaceGuid;
dwErr = WlanQueryInterface( hClient, &intfGUID, wlan_intf_opcode_current_connection, NULL, &outsize, (PVOID*)&wlan_cattr, NULL ); dwErr = WlanQueryInterface( hClient, &intfGUID, wlan_intf_opcode_current_connection, NULL, &outsize, (PVOID*)&wlan_cattr, NULL );
if( ERROR_SUCCESS != dwErr){ if ( ERROR_SUCCESS != dwErr){
return 0; return 0;
} }
int retval = (int)wlan_cattr->wlanAssociationAttributes.wlanSignalQuality; int retval = (int)wlan_cattr->wlanAssociationAttributes.wlanSignalQuality;
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr); if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
return retval; return retval;
//Transfer rates will go here //Transfer rates will go here
} }
return NULL; return NULL;
} }
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
if(pInterface == NULL) return NULL; if (pInterface == NULL) return NULL;
//Some variables for data manipulation in this function //Some variables for data manipulation in this function
static WCHAR buffer[128]; static WCHAR buffer[128];
bool bNetList = false; //whether to return buffer or netlist bool bNetList = false; //whether to return buffer or netlist
@@ -258,14 +258,14 @@ LPCTSTR GetString(UINT id, UINT flags)
UINT listMax = g_meas_data[id].listMax; UINT listMax = g_meas_data[id].listMax;
switch(current_type) switch(current_type)
{ {
case LIST: case LIST:
if(ERROR_SUCCESS != dwLErr){return L"Error";} if (ERROR_SUCCESS != dwLErr){return L"Error";}
if (!g_meas_data[id].listInit){//Check if netlist has memory allocated already if (!g_meas_data[id].listInit){//Check if netlist has memory allocated already
//Size of network name can be up to 64 chars, set to 80 to add room for delimiters //Size of network name can be up to 64 chars, set to 80 to add room for delimiters
g_meas_data[id].netlist = (WCHAR*)malloc( 80 * sizeof(WCHAR) * g_meas_data[id].listMax); g_meas_data[id].netlist = (WCHAR*)malloc( 80 * sizeof(WCHAR) * g_meas_data[id].listMax);
if(g_meas_data[id].netlist == NULL){ if (g_meas_data[id].netlist == NULL){
WCHAR debug[256]; WCHAR debug[256];
wsprintf(debug, L"WifiStatus.dll: Unable to allocate memory for network list."); wsprintf(debug, L"WifiStatus.dll: Unable to allocate memory for network list.");
Log(buffer); Log(buffer);
@@ -275,32 +275,32 @@ LPCTSTR GetString(UINT id, UINT flags)
} }
g_meas_data[id].listInit = true; g_meas_data[id].listInit = true;
} }
memset(g_meas_data[id].netlist,'\0', (80 * sizeof(WCHAR) * g_meas_data[id].listMax)); memset(g_meas_data[id].netlist,'\0', (80 * sizeof(WCHAR) * g_meas_data[id].listMax));
memset(buffer,'\0',128); memset(buffer,'\0',128);
//Check all items in WLAN NETWORK LIST //Check all items in WLAN NETWORK LIST
for(int i=0; i < (int)pwnl->dwNumberOfItems ; i++){ for (int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
if(printed == g_meas_data[id].listMax) if (printed == g_meas_data[id].listMax)
break; break;
//SSID is in UCHAR, convert to WCHAR //SSID is in UCHAR, convert to WCHAR
mbstowcs(buffer,(char*)pwnl->Network[i].dot11Ssid.ucSSID,pwnl->Network[i].dot11Ssid.uSSIDLength); mbstowcs(buffer,(char*)pwnl->Network[i].dot11Ssid.ucSSID,pwnl->Network[i].dot11Ssid.uSSIDLength);
//Prevent duplicates that result from profiles, check using SSID //Prevent duplicates that result from profiles, check using SSID
if((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){ if ((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
printed++; printed++;
if(listStyle > 0){ if (listStyle > 0){
wsprintf(g_meas_data[id].netlist,L"%s%s",g_meas_data[id].netlist,buffer); wsprintf(g_meas_data[id].netlist,L"%s%s",g_meas_data[id].netlist,buffer);
memset(buffer,'\0',128); memset(buffer,'\0',128);
if(listStyle == 1 || listStyle == 3){ if (listStyle == 1 || listStyle == 3){
//ADD PHY type //ADD PHY type
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4)); wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
} }
if(listStyle == 2 || listStyle == 3){ if (listStyle == 2 || listStyle == 3){
//ADD cipher and authentication //ADD cipher and authentication
wsprintf(buffer,L"%s (%s:%s)",buffer,getDot11str(pwnl->Network[i].dot11DefaultCipherAlgorithm,1) wsprintf(buffer,L"%s (%s:%s)",buffer,getDot11str(pwnl->Network[i].dot11DefaultCipherAlgorithm,1)
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2)); ,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
} }
} }
wsprintf(g_meas_data[id].netlist,L"%s%s\n",g_meas_data[id].netlist,buffer); wsprintf(g_meas_data[id].netlist,L"%s%s\n",g_meas_data[id].netlist,buffer);
@@ -310,9 +310,9 @@ LPCTSTR GetString(UINT id, UINT flags)
}//end for }//end for
bNetList=true; bNetList=true;
break; break;
case SSID: case SSID:
if(ERROR_SUCCESS != dwCErr){ if (ERROR_SUCCESS != dwCErr){
bIntfError = true; bIntfError = true;
break; break;
} }
@@ -321,9 +321,9 @@ LPCTSTR GetString(UINT id, UINT flags)
//If not connected yet add current status //If not connected yet add current status
wcscat(buffer,getDot11str(wlan_cattr->isState,3)); wcscat(buffer,getDot11str(wlan_cattr->isState,3));
break; break;
case PHY: case PHY:
if(ERROR_SUCCESS != dwCErr){ if (ERROR_SUCCESS != dwCErr){
bIntfError = true; bIntfError = true;
break; break;
} }
@@ -331,7 +331,7 @@ LPCTSTR GetString(UINT id, UINT flags)
break; break;
case ENCRYPTION: case ENCRYPTION:
if(ERROR_SUCCESS != dwCErr){ if (ERROR_SUCCESS != dwCErr){
bIntfError = true; bIntfError = true;
break; break;
} }
@@ -339,27 +339,27 @@ LPCTSTR GetString(UINT id, UINT flags)
break; break;
case AUTH: case AUTH:
if(ERROR_SUCCESS != dwCErr){ if (ERROR_SUCCESS != dwCErr){
bIntfError = true; bIntfError = true;
break; break;
} }
wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2)); wcscpy(buffer,getDot11str(wlan_cattr->wlanSecurityAttributes.dot11AuthAlgorithm,2));
break; break;
default: //InfoType does not refer to a string measure default: //InfoType does not refer to a string measure
bInvalidType= true; bInvalidType= true;
break; break;
} }
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr); if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
if(pwnl!=NULL)WlanFreeMemory(pwnl); if (pwnl!=NULL)WlanFreeMemory(pwnl);
if(bNetList) if (bNetList)
return g_meas_data[id].netlist; return g_meas_data[id].netlist;
if(bIntfError) if (bIntfError)
return L"-1"; return L"-1";
else { else {
if(bInvalidType) if (bInvalidType)
return NULL; return NULL;
else else
return buffer; return buffer;
@@ -367,13 +367,13 @@ LPCTSTR GetString(UINT id, UINT flags)
} }
/* /*
switches from winlanapi.h + SDK switches from winlanapi.h + SDK
in: -DOT11 ENUM (converted to int) in: -DOT11 ENUM (converted to int)
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings) -type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
out: String to be returned by measure out: String to be returned by measure
*/ */
LPCTSTR getDot11str(int dot11enum,int type){ LPCTSTR getDot11str(int dot11enum,int type){
if(type ==1){ if (type ==1){
switch(dot11enum){ switch(dot11enum){
case DOT11_CIPHER_ALGO_NONE: case DOT11_CIPHER_ALGO_NONE:
return L"NONE"; return L"NONE";
@@ -390,7 +390,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
case DOT11_CIPHER_ALGO_WEP: case DOT11_CIPHER_ALGO_WEP:
return L"WEP"; return L"WEP";
default: default:
return L"???"; return L"???";
} }
} }
else if (type == 2){ else if (type == 2){
@@ -410,10 +410,10 @@ LPCTSTR getDot11str(int dot11enum,int type){
case DOT11_AUTH_ALGO_RSNA_PSK: case DOT11_AUTH_ALGO_RSNA_PSK:
return L"WPA2-Personal"; return L"WPA2-Personal";
default: default:
return L"???"; return L"???";
} }
} }
else if(type==3){ else if (type==3){
switch(dot11enum){ switch(dot11enum){
case wlan_interface_state_connected: case wlan_interface_state_connected:
return L""; return L"";
@@ -423,14 +423,14 @@ LPCTSTR getDot11str(int dot11enum,int type){
return L"(connecting...)"; return L"(connecting...)";
} }
} }
else if(type==4){ else if (type==4){
switch(dot11enum){ switch(dot11enum){
case dot11_phy_type_unknown: case dot11_phy_type_unknown:
return L"???"; return L"???";
case dot11_phy_type_dsss: case dot11_phy_type_dsss:
return L"DSSS"; return L"DSSS";
case dot11_phy_type_erp: case dot11_phy_type_erp:
return L"802.11g"; return L"802.11g";
case dot11_phy_type_fhss: case dot11_phy_type_fhss:
return L"FHSS"; return L"FHSS";
case dot11_phy_type_hrdsss: case dot11_phy_type_hrdsss:
@@ -476,11 +476,11 @@ void Finalize(HMODULE instance, UINT id)
g_meas_data.erase(i1); g_meas_data.erase(i1);
} }
g_Instances--; g_Instances--;
if(hClient != NULL && g_Instances == 0){ if (hClient != NULL && g_Instances == 0){
WlanCloseHandle(hClient, NULL); WlanCloseHandle(hClient, NULL);
hClient = NULL; hClient = NULL;
} }
if(pIntfList != NULL && g_Instances == 0){ if (pIntfList != NULL && g_Instances == 0){
WlanFreeMemory(pIntfList); WlanFreeMemory(pIntfList);
pIntfList = NULL; pIntfList = NULL;
} }

View File

@@ -33,7 +33,7 @@
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point #include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
#define SAFE_RELEASE(punk) \ #define SAFE_RELEASE(punk) \
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; } if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
/* The exported functions */ /* The exported functions */
extern "C" extern "C"
@@ -148,7 +148,7 @@ HRESULT RegisterDevice(PCWSTR devID)
hr = S_FALSE; hr = S_FALSE;
} }
UnInitCom(); UnInitCom();
return hr; return hr;
} }
std::wstring GetDefaultID() std::wstring GetDefaultID()
@@ -216,7 +216,7 @@ bool GetWin7AudioState(const VolumeAction action)
UINT GetIndex() UINT GetIndex()
{ {
std::wstring id_default = L""; std::wstring id_default = L"";
if (InitCom()) id_default = GetDefaultID(); if (InitCom()) id_default = GetDefaultID();
UnInitCom(); UnInitCom();
@@ -275,7 +275,7 @@ bool SetWin7Volume(UINT volume, int offset = 0)
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -294,7 +294,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
UINT count; UINT count;
if (!pCollection || (S_OK != pCollection->GetCount(&count))) if (!pCollection || (S_OK != pCollection->GetCount(&count)))
{ {
UnInitCom(); UnInitCom();
return 0; return 0;
@@ -302,10 +302,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
endpointIDs = std::vector<std::wstring>(count); endpointIDs = std::vector<std::wstring>(count);
for (UINT i = 0; i < count; i++) for (UINT i = 0; i < count; i++)
{ {
IMMDevice *pEndpoint = 0; IMMDevice *pEndpoint = 0;
// Get pointer to endpoint number i. // Get pointer to endpoint number i.
if (pCollection->Item(i, &pEndpoint) == S_OK) if (pCollection->Item(i, &pEndpoint) == S_OK)
{ {
// Get the endpoint ID string. // Get the endpoint ID string.
@@ -339,13 +339,13 @@ This function is called when new value should be measured.
The function returns the new value. The function returns the new value.
*/ */
double Update2(UINT id) double Update2(UINT id)
{ {
GetWin7AudioState(GET_VOLUME); GetWin7AudioState(GET_VOLUME);
double volume = is_mute == TRUE ? -1.0 : floor(master_volume * 100.0 + 0.5); // rounding up at 0.5 double volume = is_mute == TRUE ? -1.0 : floor(master_volume * 100.0 + 0.5); // rounding up at 0.5
return volume > 100.0 ? 100.0 : volume; return volume > 100.0 ? 100.0 : volume;
} }
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
static WCHAR result[256]; static WCHAR result[256];
wsprintf(result, L"ERROR"); wsprintf(result, L"ERROR");

View File

@@ -53,7 +53,7 @@ static std::map<UINT, windowData> g_Values;
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -107,7 +107,7 @@ This function is called when new value should be measured.
The function returns the new value. The function returns the new value.
*/ */
double Update2(UINT id) double Update2(UINT id)
{ {
std::map<UINT, windowData>::iterator i = g_Values.find(id); std::map<UINT, windowData>::iterator i = g_Values.find(id);
if (i != g_Values.end()) if (i != g_Values.end())
{ {
@@ -134,7 +134,7 @@ double Update2(UINT id)
return 0; return 0;
} }
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
static WCHAR buffer[256]; static WCHAR buffer[256];

View File

@@ -310,7 +310,7 @@ static bool updateCurrentTrack()
IITArtworkPtr artwork; IITArtworkPtr artwork;
ITArtworkFormat artworkFormat; ITArtworkFormat artworkFormat;
if (count > 0 && if (count > 0 &&
SUCCEEDED(artworkCollection->get_Item(1, &artwork)) && SUCCEEDED(artworkCollection->get_Item(1, &artwork)) &&
SUCCEEDED(artwork->get_Format(&artworkFormat))) SUCCEEDED(artwork->get_Format(&artworkFormat)))
{ {
_bstr_t path; _bstr_t path;
@@ -427,7 +427,7 @@ static void initEventHandler()
/* /*
This function is called when the measure is initialized. This function is called when the measure is initialized.
The function must return the maximum value that can be measured. The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this track the maximum value automatically. The parameters for this
function are: function are:
@@ -469,7 +469,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
} }
const wchar_t* type = ReadConfigString(section, L"Command", L""); const wchar_t* type = ReadConfigString(section, L"Command", L"");
for(int i = 0; i < COMMAND_COUNT; i++) for (int i = 0; i < COMMAND_COUNT; i++)
{ {
if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0) if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0)
{ {
@@ -552,7 +552,7 @@ This function is called when the value should be
returned as a string. returned as a string.
*/ */
#define BUFFER_SIZE 256 #define BUFFER_SIZE 256
LPCTSTR GetString(UINT id, UINT flags) LPCTSTR GetString(UINT id, UINT flags)
{ {
//Error Check //Error Check
static wchar_t buffer[BUFFER_SIZE]; static wchar_t buffer[BUFFER_SIZE];