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

@@ -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);

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();
@@ -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);
} }

View File

@@ -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)
{ {
@@ -822,9 +822,9 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
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;
@@ -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;
@@ -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());

View File

@@ -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);
@@ -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

@@ -355,7 +355,7 @@ bool CMeasure::PreUpdate()
// 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())
{ {
@@ -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);
@@ -540,7 +540,7 @@ 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();
@@ -554,7 +554,7 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
_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));
} }
@@ -562,7 +562,7 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
{ {
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];
@@ -657,63 +657,63 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, cons
{ {
// 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

@@ -37,7 +37,7 @@ 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));
@@ -103,7 +103,7 @@ void CMeasureCalc::UpdateVariableMap(CMeterWindow& 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)
{ {
const char* name = (*iter)->GetANSIName(); const char* name = (*iter)->GetANSIName();
double val = (*iter)->GetValue(); double val = (*iter)->GetValue();

View File

@@ -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)

View File

@@ -51,7 +51,7 @@ 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)
{ {

View File

@@ -51,7 +51,7 @@ 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)
{ {

View File

@@ -51,7 +51,7 @@ 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)
{ {

View File

@@ -53,7 +53,7 @@ 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);
@@ -128,7 +128,7 @@ 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())
{ {
@@ -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);
@@ -206,7 +206,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
} }
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,7 +167,7 @@ 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

@@ -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

@@ -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,39 +479,39 @@ 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);
} }
@@ -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);
} }

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,14 +179,14 @@ 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);

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

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())
{ {
@@ -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;
@@ -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,9 +362,9 @@ 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;
@@ -377,7 +377,7 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
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();

View File

@@ -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;
} }
@@ -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);
} }
@@ -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;

View File

@@ -147,25 +147,25 @@ CMeterWindow::~CMeterWindow()
// Destroy the meters // Destroy the meters
std::list<CMeter*>::iterator j = m_Meters.begin(); std::list<CMeter*>::iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
delete (*j); delete (*j);
} }
// Destroy the measures // Destroy the measures
std::list<CMeasure*>::iterator i = m_Measures.begin(); std::list<CMeasure*>::iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
delete (*i); delete (*i);
} }
if(m_Background) delete m_Background; if (m_Background) delete m_Background;
if(m_DoubleBuffer) delete m_DoubleBuffer; if (m_DoubleBuffer) delete m_DoubleBuffer;
if(m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer); if (m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
if(m_Window) DestroyWindow(m_Window); if (m_Window) DestroyWindow(m_Window);
if(m_FontCollection) if (m_FontCollection)
{ {
CMeterString::FreeFontCache(m_FontCollection); CMeterString::FreeFontCache(m_FontCollection);
delete m_FontCollection; delete m_FontCollection;
@@ -205,7 +205,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
wc.hCursor = NULL; // The cursor should be controlled by using SetCursor() when needed. wc.hCursor = NULL; // The cursor should be controlled by using SetCursor() when needed.
wc.lpszClassName = METERWINDOW_CLASS_NAME; wc.lpszClassName = METERWINDOW_CLASS_NAME;
if(!RegisterClassEx(&wc)) if (!RegisterClassEx(&wc))
{ {
DWORD err = GetLastError(); DWORD err = GetLastError();
@@ -228,7 +228,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
m_Rainmeter->GetInstance(), m_Rainmeter->GetInstance(),
this); this);
if(m_Window == NULL) if (m_Window == NULL)
{ {
throw CError(CError::ERROR_CREATE_WINDOW, __LINE__, __FILE__); throw CError(CError::ERROR_CREATE_WINDOW, __LINE__, __FILE__);
} }
@@ -310,7 +310,7 @@ void CMeterWindow::Refresh(bool init, bool all)
m_Refreshing = true; m_Refreshing = true;
if(!init) if (!init)
{ {
// First destroy everything // First destroy everything
// WriteConfig(); //Not clear why this is needed and it messes up resolution changes // WriteConfig(); //Not clear why this is needed and it messes up resolution changes
@@ -325,7 +325,7 @@ void CMeterWindow::Refresh(bool init, bool all)
SetMouseLeaveEvent(true); SetMouseLeaveEvent(true);
std::list<CMeasure*>::iterator i = m_Measures.begin(); std::list<CMeasure*>::iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
delete (*i); delete (*i);
} }
@@ -333,13 +333,13 @@ void CMeterWindow::Refresh(bool init, bool all)
m_ScriptMeasures.clear(); m_ScriptMeasures.clear();
std::list<CMeter*>::iterator j = m_Meters.begin(); std::list<CMeter*>::iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
delete (*j); delete (*j);
} }
m_Meters.clear(); m_Meters.clear();
if(m_Background) delete m_Background; if (m_Background) delete m_Background;
m_Background = NULL; m_Background = NULL;
m_BackgroundSize.cx = m_BackgroundSize.cy = 0; m_BackgroundSize.cx = m_BackgroundSize.cy = 0;
@@ -393,13 +393,13 @@ void CMeterWindow::Refresh(bool init, bool all)
// Start the timers // Start the timers
if (m_WindowUpdate >= 0) if (m_WindowUpdate >= 0)
{ {
if(0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL)) if (0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL))
{ {
throw CError(L"Unable to create a timer!", __LINE__, __FILE__); throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
} }
} }
if(0 == SetTimer(m_Window, MOUSETIMER, 500, NULL)) // Mouse position is checked twice per sec if (0 == SetTimer(m_Window, MOUSETIMER, 500, NULL)) // Mouse position is checked twice per sec
{ {
throw CError(L"Unable to create a timer!", __LINE__, __FILE__); throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
} }
@@ -506,7 +506,7 @@ void CMeterWindow::MapCoordsToScreen(int& x, int& y, int w, int h)
hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL); hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
if(hMonitor != NULL) if (hMonitor != NULL)
{ {
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi); GetMonitorInfo(hMonitor, &mi);
@@ -556,7 +556,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
{ {
#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING) #define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)
if(!m_ChildWindow) if (!m_ChildWindow)
{ {
HWND winPos = HWND_NOTOPMOST; HWND winPos = HWND_NOTOPMOST;
m_WindowZPosition = zPos; m_WindowZPosition = zPos;
@@ -927,7 +927,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
int result = m_Parser.ReadFormula(strValue, &value); int result = m_Parser.ReadFormula(strValue, &value);
// Formula read fine // Formula read fine
if(result != -1) if (result != -1)
{ {
WCHAR buffer[256]; WCHAR buffer[256];
_snwprintf_s(buffer, _TRUNCATE, L"%f", value); _snwprintf_s(buffer, _TRUNCATE, L"%f", value);
@@ -972,7 +972,7 @@ void CMeterWindow::ShowMeter(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (CompareName((*j), name, group)) if (CompareName((*j), name, group))
{ {
@@ -996,7 +996,7 @@ void CMeterWindow::HideMeter(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (CompareName((*j), name, group)) if (CompareName((*j), name, group))
{ {
@@ -1020,7 +1020,7 @@ void CMeterWindow::ToggleMeter(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (CompareName((*j), name, group)) if (CompareName((*j), name, group))
{ {
@@ -1051,7 +1051,7 @@ void CMeterWindow::MoveMeter(int x, int y, const WCHAR* name)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (CompareName((*j), name, false)) if (CompareName((*j), name, false))
{ {
@@ -1078,7 +1078,7 @@ void CMeterWindow::UpdateMeter(const WCHAR* name, bool group)
bool bActiveTransition = false; bool bActiveTransition = false;
bool bContinue = true; bool bContinue = true;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (bContinue && CompareName((*j), name, group)) if (bContinue && CompareName((*j), name, group))
{ {
@@ -1118,7 +1118,7 @@ void CMeterWindow::EnableMeasure(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
if (CompareName((*i), name, group)) if (CompareName((*i), name, group))
{ {
@@ -1141,7 +1141,7 @@ void CMeterWindow::DisableMeasure(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
if (CompareName((*i), name, group)) if (CompareName((*i), name, group))
{ {
@@ -1164,7 +1164,7 @@ void CMeterWindow::ToggleMeasure(const WCHAR* name, bool group)
if (name == NULL || *name == 0) return; if (name == NULL || *name == 0) return;
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
if (CompareName((*i), name, group)) if (CompareName((*i), name, group))
{ {
@@ -1201,7 +1201,7 @@ void CMeterWindow::UpdateMeasure(const WCHAR* name, bool group)
bool bNetStats = m_HasNetMeasures; bool bNetStats = m_HasNetMeasures;
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
if (CompareName((*i), name, group)) if (CompareName((*i), name, group))
{ {
@@ -1420,7 +1420,7 @@ void CMeterWindow::WindowToScreen()
{ {
pixel = screeny + pixel; pixel = screeny + pixel;
} }
m_ScreenY = pixel - m_AnchorScreenY; m_ScreenY = pixel - m_AnchorScreenY;
} }
/* ScreenToWindow /* ScreenToWindow
@@ -1689,10 +1689,10 @@ void CMeterWindow::WriteConfig()
const std::wstring& iniFile = m_Rainmeter->GetIniFile(); const std::wstring& iniFile = m_Rainmeter->GetIniFile();
const WCHAR* section = m_SkinName.c_str(); const WCHAR* section = m_SkinName.c_str();
if(!iniFile.empty()) if (!iniFile.empty())
{ {
// If position needs to be save, do so. // If position needs to be save, do so.
if(m_SavePosition) if (m_SavePosition)
{ {
ScreenToWindow(); ScreenToWindow();
WritePrivateProfileString(section, L"WindowX", m_WindowX.c_str(), iniFile.c_str()); WritePrivateProfileString(section, L"WindowX", m_WindowX.c_str(), iniFile.c_str());
@@ -1835,7 +1835,7 @@ bool CMeterWindow::ReadSkin()
// Checking for localfonts // Checking for localfonts
std::wstring localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L""); std::wstring localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L"");
// If there is a local font we want to load it // If there is a local font we want to load it
if(!localFont.empty()) if (!localFont.empty())
{ {
m_FontCollection = new PrivateFontCollection(); m_FontCollection = new PrivateFontCollection();
@@ -1850,7 +1850,7 @@ bool CMeterWindow::ReadSkin()
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// It wasn't found in the fonts folder, check the local folder // It wasn't found in the fonts folder, check the local folder
if(nResults != Ok) if (nResults != Ok)
{ {
szFontFile = m_SkinPath; // Get the local path szFontFile = m_SkinPath; // Get the local path
szFontFile += m_SkinName; szFontFile += m_SkinName;
@@ -1859,12 +1859,12 @@ bool CMeterWindow::ReadSkin()
nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// The font wasn't found, check full path. // The font wasn't found, check full path.
if(nResults != Ok) if (nResults != Ok)
{ {
szFontFile = localFont; szFontFile = localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
if(nResults != Ok) if (nResults != Ok)
{ {
std::wstring error = L"Unable to load font file: " + localFont; std::wstring error = L"Unable to load font file: " + localFont;
Log(LOG_ERROR, error.c_str()); Log(LOG_ERROR, error.c_str());
@@ -1893,7 +1893,7 @@ bool CMeterWindow::ReadSkin()
{ {
const std::wstring& strSection = arraySections[i]; const std::wstring& strSection = arraySections[i];
if(_wcsicmp(L"Rainmeter", strSection.c_str()) != 0 && if (_wcsicmp(L"Rainmeter", strSection.c_str()) != 0 &&
_wcsicmp(L"Variables", strSection.c_str()) != 0 && _wcsicmp(L"Variables", strSection.c_str()) != 0 &&
_wcsicmp(L"Metadata", strSection.c_str()) != 0) _wcsicmp(L"Metadata", strSection.c_str()) != 0)
{ {
@@ -1921,7 +1921,7 @@ bool CMeterWindow::ReadSkin()
} }
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure); CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
if(measureScript) if (measureScript)
{ {
m_ScriptMeasures.push_back(measureScript); m_ScriptMeasures.push_back(measureScript);
} }
@@ -1992,7 +1992,7 @@ bool CMeterWindow::ReadSkin()
{ {
// Bind the meters to the measures // Bind the meters to the measures
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
try try
{ {
@@ -2018,7 +2018,7 @@ void CMeterWindow::InitializeMeasures()
{ {
// Initalize all measures // Initalize all measures
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
try try
{ {
@@ -2041,7 +2041,7 @@ void CMeterWindow::InitializeMeters()
{ {
// Initalize all meters // Initalize all meters
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
try try
{ {
@@ -2074,7 +2074,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
// Get the largest meter point // Get the largest meter point
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
int mr = (*j)->GetX() + (*j)->GetW(); int mr = (*j)->GetX() + (*j)->GetW();
w = max(w, mr); w = max(w, mr);
@@ -2252,7 +2252,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
SetWindowSizeVariables(m_WindowW, m_WindowH); SetWindowSizeVariables(m_WindowW, m_WindowH);
// If Background is not set, take a copy from the desktop // If Background is not set, take a copy from the desktop
if(m_Background == NULL) if (m_Background == NULL)
{ {
if (m_BackgroundMode == BGMODE_COPY) if (m_BackgroundMode == BGMODE_COPY)
{ {
@@ -2330,7 +2330,7 @@ void CMeterWindow::CreateRegion(bool clear)
else else
{ {
// Set window region if needed // Set window region if needed
if(!m_BackgroundName.empty()) if (!m_BackgroundName.empty())
{ {
if (m_WindowW != 0 && m_WindowH != 0) if (m_WindowW != 0 && m_WindowH != 0)
{ {
@@ -2435,7 +2435,7 @@ void CMeterWindow::Redraw()
// Draw the meters // Draw the meters
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (!(*j)->GetTransformationMatrix().IsIdentity()) if (!(*j)->GetTransformationMatrix().IsIdentity())
{ {
@@ -2604,7 +2604,7 @@ void CMeterWindow::Update(bool nodraw)
// Update all measures // Update all measures
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
UpdateMeasure((*i), false); UpdateMeasure((*i), false);
} }
@@ -2613,7 +2613,7 @@ void CMeterWindow::Update(bool nodraw)
bool bActiveTransition = false; bool bActiveTransition = false;
bool bUpdate = false; bool bUpdate = false;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (UpdateMeter((*j), bActiveTransition, false)) if (UpdateMeter((*j), bActiveTransition, false))
{ {
@@ -2644,7 +2644,7 @@ void CMeterWindow::Update(bool nodraw)
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason. // if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
// { // {
// std::list<CMeasure*>::iterator i = m_Measures.begin(); // std::list<CMeasure*>::iterator i = m_Measures.begin();
// for( ; i != m_Measures.end(); i++) // for ( ; i != m_Measures.end(); i++)
// { // {
// const char* sz = (*i)->GetStringValue(AUTOSCALE_ON, 1, 1, false); // const char* sz = (*i)->GetStringValue(AUTOSCALE_ON, 1, 1, false);
// if (sz && wcslen(sz) > 0) // if (sz && wcslen(sz) > 0)
@@ -2737,7 +2737,7 @@ LRESULT CMeterWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/ */
LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if(wParam == METERTIMER) if (wParam == METERTIMER)
{ {
Update(false); Update(false);
UpdateAboutStatistics(m_SkinName.c_str()); UpdateAboutStatistics(m_SkinName.c_str());
@@ -2753,12 +2753,12 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
// } // }
//} //}
} }
else if(wParam == TRANSITIONTIMER) else if (wParam == TRANSITIONTIMER)
{ {
// Redraw only if there is active transition still going // Redraw only if there is active transition still going
bool bActiveTransition = false; bool bActiveTransition = false;
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if ((*j)->HasActiveTransition()) if ((*j)->HasActiveTransition())
{ {
@@ -2778,7 +2778,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_ActiveTransition = false; m_ActiveTransition = false;
} }
} }
else if(wParam == MOUSETIMER) else if (wParam == MOUSETIMER)
{ {
if (!m_Rainmeter->IsMenuActive() && !m_Dragging) if (!m_Rainmeter->IsMenuActive() && !m_Dragging)
{ {
@@ -2819,7 +2819,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
} }
} }
else if(wParam == FADETIMER) else if (wParam == FADETIMER)
{ {
DWORD ticks = GetTickCount(); DWORD ticks = GetTickCount();
if (m_FadeStartTime == 0) if (m_FadeStartTime == 0)
@@ -2946,7 +2946,7 @@ void CMeterWindow::ShowWindowIfAppropriate()
} }
} }
if(m_WindowHide) if (m_WindowHide)
{ {
if (!m_Hidden && !inside && !keyDown) if (!m_Hidden && !inside && !keyDown)
{ {
@@ -3063,7 +3063,7 @@ void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meter
bool drawCursor = false; bool drawCursor = false;
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin(); std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
for( ; j != m_Meters.rend(); ++j) for ( ; j != m_Meters.rend(); ++j)
{ {
// Hidden meters are ignored // Hidden meters are ignored
if ((*j)->IsHidden()) continue; if ((*j)->IsHidden()) continue;
@@ -3255,7 +3255,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
try try
{ {
if(wParam == ID_CONTEXT_SKINMENU_EDITSKIN) if (wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
{ {
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \""; std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
command += m_SkinPath; command += m_SkinPath;
@@ -3275,7 +3275,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL); LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
} }
} }
else if(wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER) else if (wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
{ {
std::wstring command = L"\"" + m_SkinPath; std::wstring command = L"\"" + m_SkinPath;
command += L"\\"; command += L"\\";
@@ -3283,48 +3283,48 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
command += L"\""; command += L"\"";
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL); LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
} }
else if(wParam == ID_CONTEXT_SKINMENU_REFRESH) else if (wParam == ID_CONTEXT_SKINMENU_REFRESH)
{ {
Refresh(false); Refresh(false);
} }
else if(wParam == ID_CONTEXT_SKINMENU_VERYTOPMOST) else if (wParam == ID_CONTEXT_SKINMENU_VERYTOPMOST)
{ {
ChangeZPos(ZPOSITION_ONTOPMOST); ChangeZPos(ZPOSITION_ONTOPMOST);
WriteConfig(); WriteConfig();
} }
else if(wParam == ID_CONTEXT_SKINMENU_TOPMOST) else if (wParam == ID_CONTEXT_SKINMENU_TOPMOST)
{ {
ChangeZPos(ZPOSITION_ONTOP); ChangeZPos(ZPOSITION_ONTOP);
WriteConfig(); WriteConfig();
} }
else if(wParam == ID_CONTEXT_SKINMENU_BOTTOM) else if (wParam == ID_CONTEXT_SKINMENU_BOTTOM)
{ {
ChangeZPos(ZPOSITION_ONBOTTOM); ChangeZPos(ZPOSITION_ONBOTTOM);
WriteConfig(); WriteConfig();
} }
else if(wParam == ID_CONTEXT_SKINMENU_NORMAL) else if (wParam == ID_CONTEXT_SKINMENU_NORMAL)
{ {
ChangeZPos(ZPOSITION_NORMAL); ChangeZPos(ZPOSITION_NORMAL);
WriteConfig(); WriteConfig();
} }
else if(wParam == ID_CONTEXT_SKINMENU_ONDESKTOP) else if (wParam == ID_CONTEXT_SKINMENU_ONDESKTOP)
{ {
ChangeZPos(ZPOSITION_ONDESKTOP); ChangeZPos(ZPOSITION_ONDESKTOP);
WriteConfig(); WriteConfig();
} }
else if(wParam == ID_CONTEXT_SKINMENU_KEEPONSCREEN) else if (wParam == ID_CONTEXT_SKINMENU_KEEPONSCREEN)
{ {
SetKeepOnScreen(!m_KeepOnScreen); SetKeepOnScreen(!m_KeepOnScreen);
} }
else if(wParam == ID_CONTEXT_SKINMENU_CLICKTHROUGH) else if (wParam == ID_CONTEXT_SKINMENU_CLICKTHROUGH)
{ {
SetClickThrough(!m_ClickThrough); SetClickThrough(!m_ClickThrough);
} }
else if(wParam == ID_CONTEXT_SKINMENU_DRAGGABLE) else if (wParam == ID_CONTEXT_SKINMENU_DRAGGABLE)
{ {
SetWindowDraggable(!m_WindowDraggable); SetWindowDraggable(!m_WindowDraggable);
} }
else if(wParam == ID_CONTEXT_SKINMENU_HIDEONMOUSE) else if (wParam == ID_CONTEXT_SKINMENU_HIDEONMOUSE)
{ {
if (m_WindowHide == HIDEMODE_NONE) if (m_WindowHide == HIDEMODE_NONE)
{ {
@@ -3337,7 +3337,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
} }
else if(wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN) else if (wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN)
{ {
if (m_WindowHide == HIDEMODE_NONE) if (m_WindowHide == HIDEMODE_NONE)
{ {
@@ -3350,7 +3350,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
} }
else if(wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT) else if (wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT)
{ {
if (m_WindowHide == HIDEMODE_NONE) if (m_WindowHide == HIDEMODE_NONE)
{ {
@@ -3363,25 +3363,25 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
} }
else if(wParam == ID_CONTEXT_SKINMENU_REMEMBERPOSITION) else if (wParam == ID_CONTEXT_SKINMENU_REMEMBERPOSITION)
{ {
SetSavePosition(!m_SavePosition); SetSavePosition(!m_SavePosition);
} }
else if(wParam == ID_CONTEXT_SKINMENU_SNAPTOEDGES) else if (wParam == ID_CONTEXT_SKINMENU_SNAPTOEDGES)
{ {
SetSnapEdges(!m_SnapEdges); SetSnapEdges(!m_SnapEdges);
} }
else if(wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90) else if (wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90)
{ {
m_AlphaValue = (int)(255.0 - 230.0 * (double)(wParam - ID_CONTEXT_SKINMENU_TRANSPARENCY_0) / (double)(ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - ID_CONTEXT_SKINMENU_TRANSPARENCY_0)); m_AlphaValue = (int)(255.0 - 230.0 * (double)(wParam - ID_CONTEXT_SKINMENU_TRANSPARENCY_0) / (double)(ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - ID_CONTEXT_SKINMENU_TRANSPARENCY_0));
WriteConfig(); WriteConfig();
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
} }
else if(wParam == ID_CONTEXT_CLOSESKIN) else if (wParam == ID_CONTEXT_CLOSESKIN)
{ {
m_Rainmeter->DeactivateConfig(this, -1); m_Rainmeter->DeactivateConfig(this, -1);
} }
else if(wParam == ID_CONTEXT_SKINMENU_FROMRIGHT) else if (wParam == ID_CONTEXT_SKINMENU_FROMRIGHT)
{ {
m_WindowXFromRight = !m_WindowXFromRight; m_WindowXFromRight = !m_WindowXFromRight;
@@ -3392,7 +3392,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
} }
} }
else if(wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM) else if (wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM)
{ {
m_WindowYFromBottom = !m_WindowYFromBottom; m_WindowYFromBottom = !m_WindowYFromBottom;
@@ -3403,7 +3403,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
} }
} }
else if(wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE) else if (wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE)
{ {
m_WindowXPercentage = !m_WindowXPercentage; m_WindowXPercentage = !m_WindowXPercentage;
@@ -3414,7 +3414,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
WriteConfig(); WriteConfig();
} }
} }
else if(wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE) else if (wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE)
{ {
m_WindowYPercentage = !m_WindowYPercentage; m_WindowYPercentage = !m_WindowYPercentage;
@@ -3482,8 +3482,8 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
} }
} }
catch(CError& error) catch(CError& error)
{ {
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
@@ -3721,7 +3721,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
if (m_SnapEdges && !(GetKeyState(VK_CONTROL) & 0x8000 || GetKeyState(VK_SHIFT) & 0x8000)) if (m_SnapEdges && !(GetKeyState(VK_CONTROL) & 0x8000 || GetKeyState(VK_SHIFT) & 0x8000))
{ {
// only process movement (ignore anything without winpos values) // only process movement (ignore anything without winpos values)
if(wp->cx != 0 && wp->cy != 0) if (wp->cx != 0 && wp->cy != 0)
{ {
RECT workArea; RECT workArea;
@@ -3729,7 +3729,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
RECT windowRect = {wp->x, wp->y, (wp->x + m_WindowW), (wp->y + m_WindowH)}; RECT windowRect = {wp->x, wp->y, (wp->x + m_WindowW), (wp->y + m_WindowH)};
HMONITOR hMonitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTONULL); HMONITOR hMonitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTONULL);
if(hMonitor != NULL) if (hMonitor != NULL)
{ {
MONITORINFO mi; MONITORINFO mi;
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
@@ -3744,7 +3744,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
// Snap to other windows // Snap to other 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)
{ {
if ((*iter).second != this) if ((*iter).second != this)
{ {
@@ -3780,20 +3780,20 @@ void CMeterWindow::SnapToWindow(CMeterWindow* window, LPWINDOWPOS wp)
if (wp->y < y + h && wp->y + m_WindowH > y) if (wp->y < y + h && wp->y + m_WindowH > y)
{ {
if((wp->x < SNAPDISTANCE + x) && (wp->x > x - SNAPDISTANCE)) wp->x = x; if ((wp->x < SNAPDISTANCE + x) && (wp->x > x - SNAPDISTANCE)) wp->x = x;
if((wp->x < SNAPDISTANCE + x + w) && (wp->x > x + w - SNAPDISTANCE)) wp->x = x + w; if ((wp->x < SNAPDISTANCE + x + w) && (wp->x > x + w - SNAPDISTANCE)) wp->x = x + w;
if((wp->x + m_WindowW < SNAPDISTANCE + x) && (wp->x + m_WindowW > x - SNAPDISTANCE)) wp->x = x - m_WindowW; if ((wp->x + m_WindowW < SNAPDISTANCE + x) && (wp->x + m_WindowW > x - SNAPDISTANCE)) wp->x = x - m_WindowW;
if((wp->x + m_WindowW < SNAPDISTANCE + x + w) && (wp->x + m_WindowW > x + w - SNAPDISTANCE)) wp->x = x + w - m_WindowW; if ((wp->x + m_WindowW < SNAPDISTANCE + x + w) && (wp->x + m_WindowW > x + w - SNAPDISTANCE)) wp->x = x + w - m_WindowW;
} }
if (wp->x < x + w && wp->x + m_WindowW > x) if (wp->x < x + w && wp->x + m_WindowW > x)
{ {
if((wp->y < SNAPDISTANCE + y) && (wp->y > y - SNAPDISTANCE)) wp->y = y; if ((wp->y < SNAPDISTANCE + y) && (wp->y > y - SNAPDISTANCE)) wp->y = y;
if((wp->y < SNAPDISTANCE + y + h) && (wp->y > y + h - SNAPDISTANCE)) wp->y = y + h; if ((wp->y < SNAPDISTANCE + y + h) && (wp->y > y + h - SNAPDISTANCE)) wp->y = y + h;
if((wp->y + m_WindowH < SNAPDISTANCE + y) && (wp->y + m_WindowH > y - SNAPDISTANCE)) wp->y = y - m_WindowH; if ((wp->y + m_WindowH < SNAPDISTANCE + y) && (wp->y + m_WindowH > y - SNAPDISTANCE)) wp->y = y - m_WindowH;
if((wp->y + m_WindowH < SNAPDISTANCE + y + h) && (wp->y + m_WindowH > y + h - SNAPDISTANCE)) wp->y = y + h - m_WindowH; if ((wp->y + m_WindowH < SNAPDISTANCE + y + h) && (wp->y + m_WindowH > y + h - SNAPDISTANCE)) wp->y = y + h - m_WindowH;
} }
} }
@@ -4161,7 +4161,7 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test)
{ {
// Check if the hitpoint was over some meter // Check if the hitpoint was over some meter
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin(); std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
for( ; j != m_Meters.rend(); ++j) for ( ; j != m_Meters.rend(); ++j)
{ {
// Hidden meters are ignored // Hidden meters are ignored
if ((*j)->IsHidden()) continue; if ((*j)->IsHidden()) continue;
@@ -4169,7 +4169,7 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test)
if ((*j)->HitTest(x, y)) if ((*j)->HitTest(x, y))
{ {
std::list<CMeasureScript*>::iterator k = m_ScriptMeasures.begin(); std::list<CMeasureScript*>::iterator k = m_ScriptMeasures.begin();
for( ; k != m_ScriptMeasures.end(); ++k) for ( ; k != m_ScriptMeasures.end(); ++k)
{ {
(*k)->MeterMouseEvent((*j), mouse); (*k)->MeterMouseEvent((*j), mouse);
} }
@@ -4345,7 +4345,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
// Check if the hitpoint was over some meter // Check if the hitpoint was over some meter
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin(); std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
for( ; j != m_Meters.rend(); ++j) for ( ; j != m_Meters.rend(); ++j)
{ {
if (!(*j)->IsHidden() && (*j)->HitTest(x, y)) if (!(*j)->IsHidden() && (*j)->HitTest(x, y))
{ {
@@ -4521,14 +4521,14 @@ LRESULT CALLBACK CMeterWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
{ {
CMeterWindow* Window = NULL; CMeterWindow* Window = NULL;
if(uMsg == WM_CREATE) if (uMsg == WM_CREATE)
{ {
// Fetch this window-object from the CreateStruct // Fetch this window-object from the CreateStruct
Window=(CMeterWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams; Window=(CMeterWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
SetProp(hWnd, L"RAINMETER", Window); SetProp(hWnd, L"RAINMETER", Window);
} }
else if(uMsg == WM_DESTROY) else if (uMsg == WM_DESTROY)
{ {
RemoveProp(hWnd, L"RAINMETER"); RemoveProp(hWnd, L"RAINMETER");
} }
@@ -4805,7 +4805,7 @@ std::wstring CMeterWindow::MakePathAbsolute(const std::wstring& path)
CMeter* CMeterWindow::GetMeter(const std::wstring& meterName) CMeter* CMeterWindow::GetMeter(const std::wstring& meterName)
{ {
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (_wcsicmp((*j)->GetName(), meterName.c_str()) == 0) if (_wcsicmp((*j)->GetName(), meterName.c_str()) == 0)
{ {
@@ -4819,7 +4819,7 @@ CMeter* CMeterWindow::GetMeter(const std::wstring& meterName)
CMeasure* CMeterWindow::GetMeasure(const std::wstring& measureName) CMeasure* CMeterWindow::GetMeasure(const std::wstring& measureName)
{ {
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
if (_wcsicmp((*i)->GetName(), measureName.c_str()) == 0) if (_wcsicmp((*i)->GetName(), measureName.c_str()) == 0)
{ {

View File

@@ -120,7 +120,7 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
{ {
Rainmeter=new CRainmeter; Rainmeter=new CRainmeter;
if(Rainmeter) if (Rainmeter)
{ {
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath); Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath);
} }
@@ -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;
@@ -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();
@@ -1593,9 +1593,9 @@ 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);
} }
/* /*
@@ -1644,7 +1644,7 @@ 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__);
} }
@@ -1656,7 +1656,7 @@ 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';
} }
@@ -1667,7 +1667,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
m_Path = tmpSzPath; m_Path = tmpSzPath;
if(!c_DummyLitestep) InitalizeLitestep(); if (!c_DummyLitestep) InitalizeLitestep();
bool bDefaultIniLocation = false; bool bDefaultIniLocation = false;
@@ -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
@@ -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
@@ -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,7 +2702,7 @@ 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;
} }
@@ -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()
@@ -3080,7 +3080,7 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
{ {
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)
{ {
@@ -3153,7 +3153,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
} }
// 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)
{ {
@@ -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,9 +3648,9 @@ 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);
@@ -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())
{ {
@@ -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)
{ {

View File

@@ -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);
} }

View File

@@ -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

@@ -103,7 +103,7 @@ CTrayWindow::~CTrayWindow()
BOOL CTrayWindow::AddTrayIcon() BOOL CTrayWindow::AddTrayIcon()
{ {
BOOL res = FALSE; BOOL res = FALSE;
if (m_TrayIcon) if (m_TrayIcon)
{ {
@@ -125,7 +125,7 @@ BOOL CTrayWindow::AddTrayIcon()
res = Shell_NotifyIcon(NIM_ADD, &tnid); res = Shell_NotifyIcon(NIM_ADD, &tnid);
} }
return res; return res;
} }
BOOL CTrayWindow::RemoveTrayIcon() BOOL CTrayWindow::RemoveTrayIcon()
@@ -145,12 +145,12 @@ BOOL CTrayWindow::RemoveTrayIcon()
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)
{ {
@@ -166,8 +166,8 @@ BOOL CTrayWindow::ModifyTrayIcon(double value)
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)
@@ -351,7 +351,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
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,7 +382,7 @@ 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;
} }
@@ -400,19 +400,19 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
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)
@@ -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();
@@ -601,7 +601,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
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,7 +673,7 @@ 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()));
@@ -681,7 +681,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
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,14 +833,14 @@ 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__);
} }

View File

@@ -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);
} }

View File

@@ -54,7 +54,7 @@ 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";");
@@ -153,11 +153,11 @@ 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++)
{ {
@@ -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);
// } // }
@@ -244,7 +244,7 @@ double Update2(UINT id)
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;
@@ -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,11 +309,11 @@ 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;

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)) ) if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
return FALSE; return FALSE;
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset); PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
#ifdef UNICODE #ifdef UNICODE
lstrcpy( pszObjInstName, pszName ); lstrcpy( pszObjInstName, pszName );
#else #else
wcstombs( pszObjInstName, pszName, nSize ); wcstombs( pszObjInstName, pszName, nSize );
#endif #endif
return TRUE; 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; DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
// Create a new CPerfCounter. The caller is responsible for deleting it. // Create a new CPerfCounter. The caller is responsible for deleting it.
return new CPerfCounter(pszName, return new CPerfCounter(pszName,
pCounterDef->CounterType, pCounterDef->CounterType,
MakePtr( PBYTE, m_pPerfInstDef, MakePtr( PBYTE, m_pPerfInstDef,
nInstanceDefSize + nInstanceDefSize +
pCounterDef->CounterOffset ), pCounterDef->CounterOffset ),
pCounterDef->CounterSize ); pCounterDef->CounterSize );
} }
CPerfCounter * CPerfCounter *
CPerfObjectInstance::GetCounterByIndex( DWORD index ) CPerfObjectInstance::GetCounterByIndex( DWORD index )
{ {
PPERF_COUNTER_DEFINITION pCurrentCounter; PPERF_COUNTER_DEFINITION pCurrentCounter;
if ( index >= m_nCounters ) if ( index >= m_nCounters )
return 0; return 0;
pCurrentCounter = m_pPerfCntrDef; pCurrentCounter = m_pPerfCntrDef;
// Find the correct PERF_COUNTER_DEFINITION by looping // Find the correct PERF_COUNTER_DEFINITION by looping
for ( DWORD i = 0; i < index; i++ ) for ( DWORD i = 0; i < index; i++ )
{ {
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION, pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter, pCurrentCounter,
pCurrentCounter->ByteLength ); pCurrentCounter->ByteLength );
} }
if ( pCurrentCounter->ByteLength == 0 ) if ( pCurrentCounter->ByteLength == 0 )
return 0; return 0;
return MakeCounter( pCurrentCounter ); 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; PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing // Find the correct PERF_COUNTER_DEFINITION by looping and comparing
for ( DWORD i = 0; i < m_nCounters; i++ ) for ( DWORD i = 0; i < m_nCounters; i++ )
{ {
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx ) if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
return MakeCounter( pCurrentCounter ); return MakeCounter( pCurrentCounter );
// Nope. Not this one. Advance to the next counter // Nope. Not this one. Advance to the next counter
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION, pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
pCurrentCounter, pCurrentCounter,
pCurrentCounter->ByteLength ); pCurrentCounter->ByteLength );
} }
return 0; 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 memcpy( pBuffer, m_pData, m_cbData ); // copy the data
if ( pType ) // If the user wants the type, give it to them if ( pType ) // If the user wants the type, give it to them
*pType = m_type; *pType = m_type;
return TRUE; 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 ) switch ( m_type & 0x70000000 )
{ {
case PERF_DISPLAY_SECONDS: case PERF_DISPLAY_SECONDS:
_tcscat( szTemp, TEXT(" secs") ); break; _tcscat( szTemp, TEXT(" secs") ); break;
case PERF_DISPLAY_PERCENT: case PERF_DISPLAY_PERCENT:
_tcscat( szTemp, TEXT(" %") ); break; _tcscat( szTemp, TEXT(" %") ); break;
case PERF_DISPLAY_PER_SEC: case PERF_DISPLAY_PER_SEC:
_tcscat( szTemp, TEXT(" /sec") ); break; _tcscat( szTemp, TEXT(" /sec") ); break;
} }
lstrcpyn( pszBuffer, szTemp, nSize ); lstrcpyn( pszBuffer, szTemp, nSize );
return TRUE; return TRUE;
} }

View File

@@ -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 // First, get a pointer to the counter data size field
PDWORD pCounterDataSize PDWORD pCounterDataSize
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition, = MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
m_pCurrentObjectInstanceDefinition->ByteLength); m_pCurrentObjectInstanceDefinition->ByteLength);
// Now we can point at the next PPERF_INSTANCE_DEFINITION // Now we can point at the next PPERF_INSTANCE_DEFINITION
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION, m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
m_pCurrentObjectInstanceDefinition, m_pCurrentObjectInstanceDefinition,
m_pCurrentObjectInstanceDefinition->ByteLength m_pCurrentObjectInstanceDefinition->ByteLength
+ *pCounterDataSize); + *pCounterDataSize);
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION // Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition, return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
MakePtr(PPERF_COUNTER_DEFINITION, MakePtr(PPERF_COUNTER_DEFINITION,
m_pObjectList, m_pObjectList,
m_pObjectList->HeaderLength), m_pObjectList->HeaderLength),
m_pObjectList->NumCounters, m_pObjectList->NumCounters,
m_pPerfCounterTitles, m_pPerfCounterTitles,
FALSE ); 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 while ( 1 ) // Loop until we get the data, or we fail unexpectedly
{ {
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA, retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
szConvertedItemNames, 0, 0, szConvertedItemNames, 0, 0,
c_pBuffer, &c_cbBufferSize ); c_pBuffer, &c_cbBufferSize );
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot 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 // The new buffer size will be 4096 bytes bigger than the larger
// of: 1) The previous allocation size, or 2) The size that the // of: 1) The previous allocation size, or 2) The size that the
// RegQueryValueEx call said was necessary. // RegQueryValueEx call said was necessary.
if ( c_cbBufferSize > cbAllocSize ) if ( c_cbBufferSize > cbAllocSize )
cbAllocSize = c_cbBufferSize + 4096; cbAllocSize = c_cbBufferSize + 4096;
else else
cbAllocSize += 4096; cbAllocSize += 4096;
// Allocate a new, larger buffer in preparation to try again. // Allocate a new, larger buffer in preparation to try again.
c_pBuffer = new BYTE[ cbAllocSize ]; c_pBuffer = new BYTE[ cbAllocSize ];
if ( !c_pBuffer ) if ( !c_pBuffer )
break; break;
c_cbBufferSize = cbAllocSize; c_cbBufferSize = cbAllocSize;
} }
// If we get here, the RegQueryValueEx failed unexpectedly. // If we get here, the RegQueryValueEx failed unexpectedly.
return FALSE; 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 // Open the registry key that has the values for the maximum number
// of title strings // of title strings
if ( ERROR_SUCCESS != RegOpenKeyEx( if ( ERROR_SUCCESS != RegOpenKeyEx(
HKEY_LOCAL_MACHINE, HKEY_LOCAL_MACHINE,
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"), TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
0, KEY_READ, &hKeyPerflib ) ) 0, KEY_READ, &hKeyPerflib ) )
return; return;
// Read in the number of title strings // Read in the number of title strings
if ( ERROR_SUCCESS != RegQueryValueEx( if ( ERROR_SUCCESS != RegQueryValueEx(
hKeyPerflib, pszLastIndexRegValue, 0, 0, hKeyPerflib, pszLastIndexRegValue, 0, 0,
(PBYTE)&m_nLastIndex, &cbLastIndex ) ) (PBYTE)&m_nLastIndex, &cbLastIndex ) )
{ {
RegCloseKey( hKeyPerflib ); RegCloseKey( hKeyPerflib );
return; return;
} }
RegCloseKey( hKeyPerflib ); RegCloseKey( hKeyPerflib );
// //
// Now go find and process the raw string data // Now go find and process the raw string data
// //
// Determine how big the raw data in the REG_MULTI_SZ value is // Determine how big the raw data in the REG_MULTI_SZ value is
DWORD cbTitleStrings; DWORD cbTitleStrings;
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings)) if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
return; return;
// Allocate memory for the raw registry title string data // Allocate memory for the raw registry title string data
m_pszRawStrings = new TCHAR[cbTitleStrings]; m_pszRawStrings = new TCHAR[cbTitleStrings];
// Read in the raw title strings // Read in the raw title strings
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings, psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
&cbTitleStrings ) ) &cbTitleStrings ) )
{ {
delete []m_pszRawStrings; delete []m_pszRawStrings;
return; return;
} }
// allocate memory for an array of string pointers. // allocate memory for an array of string pointers.
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ]; m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
if ( !m_TitleStrings ) if ( !m_TitleStrings )
{ {
delete []m_pszRawStrings; delete []m_pszRawStrings;
return; return;
} }
// Initialize the m_TitleStrings to all NULLs, since there may // Initialize the m_TitleStrings to all NULLs, since there may
// be some array slots that aren't used. // be some array slots that aren't used.
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) ); memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
// The raw data entries are an ASCII string index (e.g., "242"), followed // The raw data entries are an ASCII string index (e.g., "242"), followed
// by the corresponding string. Fill in the appropriate slot in the // by the corresponding string. Fill in the appropriate slot in the
// m_TitleStrings array with the pointer to the string name. The end // m_TitleStrings array with the pointer to the string name. The end
// of the list is indicated by a double NULL. // of the list is indicated by a double NULL.
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings; PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
unsigned cbCurrStr; unsigned cbCurrStr;
// While the length of the current string isn't 0... // While the length of the current string isn't 0...
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) ) while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
{ {
// Convert the first string to a binary representation // Convert the first string to a binary representation
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi() unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
if ( index > m_nLastIndex ) if ( index > m_nLastIndex )
break; break;
// Now point to the string following it. This is the title string // Now point to the string following it. This is the title string
pszWorkStr += cbCurrStr + 1; pszWorkStr += cbCurrStr + 1;
// Fill in the appropriate slot in the title strings array. // Fill in the appropriate slot in the title strings array.
m_TitleStrings[index] = pszWorkStr; m_TitleStrings[index] = pszWorkStr;
// Advance to the next index/title pair // Advance to the next index/title pair
pszWorkStr += lstrlen(pszWorkStr) + 1; 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

@@ -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;
@@ -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
} }
/* /*

View File

@@ -99,7 +99,7 @@ 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)
{ {

View File

@@ -192,7 +192,7 @@ 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)
{ {
@@ -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

View File

@@ -140,9 +140,9 @@ double Update2(UINT 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)
{ {
@@ -164,7 +164,7 @@ double Update2(UINT id)
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);
@@ -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;
} }
@@ -229,20 +229,20 @@ void ExecuteBang(LPCTSTR args, UINT id)
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;
} }
@@ -255,21 +255,21 @@ void ExecuteBang(LPCTSTR args, UINT id)
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

@@ -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

@@ -159,7 +159,7 @@ double Update2(UINT 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 ????
} }

View File

@@ -101,7 +101,7 @@ 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)
{ {
@@ -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,9 +433,9 @@ 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);
@@ -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();
} }
@@ -233,8 +233,8 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
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,19 +242,19 @@ 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);
} }
@@ -279,7 +279,7 @@ 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);
} }
@@ -305,12 +305,12 @@ 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);
} }
@@ -322,13 +322,13 @@ DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT 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);
@@ -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);
@@ -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));
@@ -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,8 +535,8 @@ 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;
} }
@@ -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,8 +604,8 @@ 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;
} }
@@ -617,7 +617,7 @@ DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMe
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,38 +24,38 @@
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
@@ -93,16 +93,16 @@ 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);
@@ -114,7 +114,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
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

@@ -603,7 +603,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
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;
@@ -706,7 +706,7 @@ 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;
} }
@@ -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)
@@ -1505,7 +1505,7 @@ 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
} }
/* /*
@@ -1518,7 +1518,7 @@ LPCTSTR GetString(UINT id, UINT flags)
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)
{ {

View File

@@ -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);
@@ -113,7 +113,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
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];
@@ -158,7 +158,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
//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;
} }
@@ -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,11 +217,11 @@ 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
@@ -232,7 +232,7 @@ UINT Update(UINT id)
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];
@@ -260,12 +260,12 @@ LPCTSTR GetString(UINT id, UINT flags)
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);
@@ -280,24 +280,24 @@ LPCTSTR GetString(UINT id, UINT flags)
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));
@@ -312,7 +312,7 @@ LPCTSTR GetString(UINT id, UINT flags)
break; break;
case SSID: case SSID:
if(ERROR_SUCCESS != dwCErr){ if (ERROR_SUCCESS != dwCErr){
bIntfError = true; bIntfError = true;
break; break;
} }
@@ -323,7 +323,7 @@ LPCTSTR GetString(UINT id, UINT flags)
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,7 +339,7 @@ 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;
} }
@@ -351,15 +351,15 @@ LPCTSTR GetString(UINT id, UINT flags)
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;
@@ -369,11 +369,11 @@ 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";
@@ -413,7 +413,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
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,7 +423,7 @@ 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"???";
@@ -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()
@@ -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.

View File

@@ -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)
{ {