From 1668de5a3bb66c88fb99a664697acfbafb662995 Mon Sep 17 00:00:00 2001 From: spx Date: Sun, 31 Oct 2010 20:13:32 +0000 Subject: [PATCH] Code cleanup & cosmetics. --- Library/ConfigParser.cpp | 4 ++-- Library/MeasureCalc.cpp | 2 +- Library/MeasureDiskSpace.cpp | 2 +- Library/MeasureNet.cpp | 8 ++++---- Library/Meter.cpp | 2 +- Library/MeterHistogram.cpp | 2 +- Library/MeterString.cpp | 10 +++++----- Library/MeterWindow.cpp | 28 ++++++++++++++-------------- Library/Rainmeter.cpp | 22 +++++++++++----------- Library/System.cpp | 34 +++++++++++++++++----------------- Library/UpdateCheck.cpp | 8 ++++---- 11 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 3d64f1cb..571556e4 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -719,7 +719,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue) char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.substr(1, result.size() - 2).c_str()).c_str(), &resultValue); if (errMsg != NULL) { - DebugLog(ConvertToWide(errMsg).c_str()); + LSLog(LOG_DEBUG, APPNAME, ConvertToWide(errMsg).c_str()); } return resultValue; @@ -739,7 +739,7 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue) if (errMsg != NULL) { - DebugLog(ConvertToWide(errMsg).c_str()); + LSLog(LOG_DEBUG, APPNAME, ConvertToWide(errMsg).c_str()); return -1; } diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 93baa1f3..ea421882 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -84,7 +84,7 @@ bool CMeasureCalc::Update() char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(m_Formula.c_str()).c_str(), &m_Value); if (errMsg != NULL) { - DebugLog(ConvertToWide(errMsg).c_str()); + LSLog(LOG_DEBUG, APPNAME, ConvertToWide(errMsg).c_str()); } return PostUpdate(); diff --git a/Library/MeasureDiskSpace.cpp b/Library/MeasureDiskSpace.cpp index a8cd05b6..51c0e013 100644 --- a/Library/MeasureDiskSpace.cpp +++ b/Library/MeasureDiskSpace.cpp @@ -173,7 +173,7 @@ void CMeasureDiskSpace::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Drive = parser.ReadString(section, L"Drive", L"C:\\"); if (m_Drive.empty()) { - DebugLog(L"Drive path is not given."); + LSLog(LOG_DEBUG, APPNAME, L"Drive path is not given."); m_Value = 0; m_LabelName = L""; } diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 14056749..0b3a075a 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -114,7 +114,7 @@ void CMeasureNet::UpdateIFTable() if (CRainmeter::GetDebug() && logging) { - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); DebugLog(L"* NETWORK-INTERFACE: Count=%i", c_NumOfTables); for (size_t i = 0; i < c_NumOfTables; ++i) @@ -151,7 +151,7 @@ void CMeasureNet::UpdateIFTable() (ifTable->Table[i].InterfaceAndOperStatusFlags.HardwareInterface == 1) ? L"Yes" : L"No", (ifTable->Table[i].InterfaceAndOperStatusFlags.FilterInterface == 1) ? L"Yes" : L"No"); } - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); } } else @@ -209,7 +209,7 @@ void CMeasureNet::UpdateIFTable() if (CRainmeter::GetDebug() && logging) { - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); DebugLog(L"* NETWORK-INTERFACE: Count=%i", c_NumOfTables); for (size_t i = 0; i < c_NumOfTables; ++i) @@ -246,7 +246,7 @@ void CMeasureNet::UpdateIFTable() DebugLog(L" Type=%s(%i)", type.c_str(), ifTable->table[i].dwType); } - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); } } else diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 74b5b991..409ca025 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -421,7 +421,7 @@ void CMeter::ReadConfig(const WCHAR* section) } else if (!matrix.empty()) { - DebugLog(L"The transformation matrix has incorrect number of values:", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); + DebugLog(L"The transformation matrix has incorrect number of values: %s", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); } std::wstring group = parser.ReadString(section, L"Group", L""); diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 629c1204..4cc9bfd2 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -161,7 +161,7 @@ void CMeterHistogram::Initialize() // A sanity check if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty())) { - LSLog(LOG_DEBUG, L"Rainmeter", L"You need to define SecondaryImage and BothImage also!"); + LSLog(LOG_DEBUG, APPNAME, L"You need to define SecondaryImage and BothImage also!"); if (m_PrimaryBitmap) { diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 13087202..37948681 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -134,7 +134,7 @@ void CMeterString::Initialize() { std::wstring error = L"Error: Couldn't load font family: "; error += m_FontFace; - DebugLog(error.c_str()); + LSLog(LOG_DEBUG, APPNAME, error.c_str()); delete m_FontFamily; m_FontFamily = NULL; @@ -755,23 +755,23 @@ void CMeterString::EnumerateInstalledFontFamilies() } fonts += L", "; } - LSLog(LOG_DEBUG, L"Rainmeter", fonts.c_str()); + LSLog(LOG_DEBUG, APPNAME, fonts.c_str()); } else { - LSLog(LOG_DEBUG, L"Rainmeter", L"Failed to enumerate installed font families: GetFamilies() failed."); + LSLog(LOG_DEBUG, APPNAME, L"Failed to enumerate installed font families: GetFamilies() failed."); } delete [] fontFamilies; } else { - LSLog(LOG_DEBUG, L"Rainmeter", L"There are no installed font families!"); + LSLog(LOG_DEBUG, APPNAME, L"There are no installed font families!"); } } else { - LSLog(LOG_DEBUG, L"Rainmeter", L"Failed to enumerate installed font families: InstalledFontCollection() failed."); + LSLog(LOG_DEBUG, APPNAME, L"Failed to enumerate installed font families: InstalledFontCollection() failed."); } } diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index d69cbb4e..29491f7a 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -258,7 +258,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter) } } - LSLog(LOG_DEBUG, L"Rainmeter", L"Initialization successful."); + LSLog(LOG_DEBUG, APPNAME, L"Initialization successful."); return 0; } @@ -305,7 +305,7 @@ void CMeterWindow::Refresh(bool init, bool all) std::wstring dbg = L"Refreshing skin \"" + m_SkinName; dbg += L"\\" + m_SkinIniFile; dbg += L"\""; - LSLog(LOG_DEBUG, L"Rainmeter", dbg.c_str()); + LSLog(LOG_DEBUG, APPNAME, dbg.c_str()); m_Refreshing = true; @@ -754,7 +754,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) } else { - DebugLog(L"Unable to parse parameters for !RainmeterMove"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse parameters for !RainmeterMove"); } break; @@ -866,12 +866,12 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) } else { - DebugLog(L"Unable to parse coordinates for !RainmeterMoveMeter"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse coordinates for !RainmeterMoveMeter"); } } else { - DebugLog(L"Unable to parse parameters for !RainmeterMoveMeter"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse parameters for !RainmeterMoveMeter"); } break; @@ -913,7 +913,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) } else { - DebugLog(L"Unable to parse parameters for !RainmeterPluginBang"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse parameters for !RainmeterPluginBang"); } } break; @@ -944,7 +944,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) } else { - DebugLog(L"Unable to parse parameters for !RainmeterSetVariable"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse parameters for !RainmeterSetVariable"); } break; } @@ -1177,7 +1177,7 @@ void CMeterWindow::WindowToScreen() { if (CSystem::GetMonitorCount() == 0) { - DebugLog(L"There are no monitors. WindowToScreen function fails."); + LSLog(LOG_DEBUG, APPNAME, L"There are no monitors. WindowToScreen function fails."); return; } @@ -1403,7 +1403,7 @@ void CMeterWindow::ScreenToWindow() if (monitors.empty()) { - DebugLog(L"There are no monitors. ScreenToWindow function fails."); + LSLog(LOG_DEBUG, APPNAME, L"There are no monitors. ScreenToWindow function fails."); return; } @@ -1836,7 +1836,7 @@ bool CMeterWindow::ReadSkin() { std::wstring error = L"Error: Couldn't load font file: "; error += localFont; - DebugLog(error.c_str()); + LSLog(LOG_DEBUG, APPNAME, error.c_str()); } } @@ -1880,7 +1880,7 @@ bool CMeterWindow::ReadSkin() { std::wstring error = L"Error: Couldn't load font file: "; error += localFont; - DebugLog(error.c_str()); + LSLog(LOG_DEBUG, APPNAME, error.c_str()); } } } @@ -2007,14 +2007,14 @@ bool CMeterWindow::ReadSkin() { text += L"\" does not contain\nany valid meters or measures and will be deactivated.\n\nThe file may be damaged or not a Rainmeter skin file."; MessageBox(m_Window, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); - m_Rainmeter->DeactivateConfig(this, -1); + return false; } else { text += L"\" does not contain any meters.\nDo you want to deactivate this skin?"; if (IDYES == MessageBox(m_Window, text.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONEXCLAMATION)) { - m_Rainmeter->DeactivateConfig(this, -1); + return false; } } } @@ -4508,7 +4508,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam) } if (!found) { - DebugLog(L"Unable to send the !bang to a deactivated config."); + LSLog(LOG_DEBUG, APPNAME, L"Unable to send the !bang to a deactivated config."); return 0; // This meterwindow has been deactivated } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 4bd64cb3..8b478b5b 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -248,7 +248,7 @@ void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs) } else { - DebugLog(L"Incorrect number of arguments for the bang!"); + LSLog(LOG_DEBUG, APPNAME, L"Incorrect number of arguments for the bang!"); } } } @@ -286,7 +286,7 @@ void BangGroupWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs) } else { - DebugLog(L"Incorrect number of arguments for the group bang!"); + LSLog(LOG_DEBUG, APPNAME, L"Incorrect number of arguments for the group bang!"); } } } @@ -496,7 +496,7 @@ void RainmeterActivateConfig(HWND, const char* arg) else { // If we got this far, something went wrong - DebugLog(L"Unable to parse the arguments for !RainmeterActivateConfig"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterActivateConfig"); } } } @@ -525,7 +525,7 @@ void RainmeterDeactivateConfig(HWND, const char* arg) } else { - DebugLog(L"Unable to parse the arguments for !RainmeterDeactivateConfig"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterDeactivateConfig"); } } } @@ -556,7 +556,7 @@ void RainmeterToggleConfig(HWND, const char* arg) } else { - DebugLog(L"Unable to parse the arguments for !RainmeterToggleConfig"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterToggleConfig"); } } } @@ -828,7 +828,7 @@ void RainmeterDeactivateConfigGroup(HWND, const char* arg) } else { - DebugLog(L"Unable to parse the arguments for !RainmeterDeactivateConfigGroup"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterDeactivateConfigGroup"); } } } @@ -961,7 +961,7 @@ void RainmeterSkinMenu(HWND, const char* arg) } else { - DebugLog(L"Unable to parse the arguments for !RainmeterSkinMenu"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterSkinMenu"); } } } @@ -1136,7 +1136,7 @@ void RainmeterWriteKeyValue(HWND, const char* arg) } else { - DebugLog(L"Unable to parse the arguments for !RainmeterWriteKeyValue"); + LSLog(LOG_DEBUG, APPNAME, L"Unable to parse the arguments for !RainmeterWriteKeyValue"); } } } @@ -1431,7 +1431,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) } else { - DebugLog(L"Unable to get the My Documents location."); + LSLog(LOG_DEBUG, APPNAME, L"Unable to get the My Documents location."); } } WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), m_IniFile.c_str()); @@ -3767,7 +3767,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation) } if (!bSuccess) { - DebugLog(L"The Rainmeter.ini file is NOT writable."); + LSLog(LOG_DEBUG, APPNAME, L"The Rainmeter.ini file is NOT writable."); std::wstring error; error += L"The Rainmeter.ini file is not writable. This means that the\n"; @@ -3799,7 +3799,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation) } else { - DebugLog(L"The Rainmeter.ini file is writable."); + LSLog(LOG_DEBUG, APPNAME, L"The Rainmeter.ini file is writable."); } } diff --git a/Library/System.cpp b/Library/System.cpp index 34937db6..2b59f45b 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -171,7 +171,7 @@ BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonit if (CRainmeter::GetDebug()) { - DebugLog(info.szDevice); + LSLog(LOG_DEBUG, APPNAME, info.szDevice); DebugLog(L" Flags : %s(0x%08X)", (info.dwFlags & MONITORINFOF_PRIMARY) ? L"PRIMARY " : L"", info.dwFlags); DebugLog(L" Handle : 0x%08X", hMonitor); DebugLog(L" ScrArea : L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)", @@ -270,8 +270,8 @@ void CSystem::SetMultiMonitorInfo() if (logging) { - DebugLog(L"------------------------------"); - DebugLog(L"* EnumDisplayDevices / EnumDisplaySettings API"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"* EnumDisplayDevices / EnumDisplaySettings API"); } DISPLAY_DEVICE dd = {0}; @@ -287,7 +287,7 @@ void CSystem::SetMultiMonitorInfo() if (logging) { - DebugLog(dd.DeviceName); + LSLog(LOG_DEBUG, APPNAME, dd.DeviceName); if (dd.StateFlags & DISPLAY_DEVICE_ACTIVE) { @@ -427,15 +427,15 @@ void CSystem::SetMultiMonitorInfo() if (monitors.empty()) // Failed to enumerate the non-mirroring monitors { - DebugLog(L"Failed to enumerate the non-mirroring monitors. Only EnumDisplayMonitors is used instead."); + LSLog(LOG_DEBUG, APPNAME, L"Failed to enumerate the non-mirroring monitors. Only EnumDisplayMonitors is used instead."); c_Monitors.useEnumDisplayDevices = false; c_Monitors.useEnumDisplayMonitors = true; } if (logging) { - DebugLog(L"------------------------------"); - DebugLog(L"* EnumDisplayMonitors API"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"* EnumDisplayMonitors API"); } if (c_Monitors.useEnumDisplayMonitors) @@ -444,7 +444,7 @@ void CSystem::SetMultiMonitorInfo() if (monitors.empty()) // Failed to enumerate the monitors { - DebugLog(L"Failed to enumerate the monitors. Prepares the dummy monitor information."); + LSLog(LOG_DEBUG, APPNAME, L"Failed to enumerate the monitors. Prepares the dummy monitor information."); c_Monitors.useEnumDisplayMonitors = false; MONITOR_INFO monitor = {0}; @@ -473,7 +473,7 @@ void CSystem::SetMultiMonitorInfo() if (logging) { - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); std::wstring method = L"* METHOD: "; if (c_Monitors.useEnumDisplayDevices) @@ -485,10 +485,10 @@ void CSystem::SetMultiMonitorInfo() { method += c_Monitors.useEnumDisplayMonitors ? L"EnumDisplayMonitors Mode" : L"Dummy Mode"; } - DebugLog(method.c_str()); + LSLog(LOG_DEBUG, APPNAME, method.c_str()); DebugLog(L"* MONITORS: Count=%i, Primary=@%i", monitors.size(), c_Monitors.primary); - DebugLog(L"@0: Virtual screen"); + LSLog(LOG_DEBUG, APPNAME, L"@0: Virtual screen"); DebugLog(L" L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)", c_Monitors.vsL, c_Monitors.vsT, c_Monitors.vsL + c_Monitors.vsW, c_Monitors.vsT + c_Monitors.vsH, c_Monitors.vsW, c_Monitors.vsH); @@ -507,7 +507,7 @@ void CSystem::SetMultiMonitorInfo() DebugLog(L"@%i: %s (inactive), MonitorName: %s", i + 1, monitors[i].deviceName, monitors[i].monitorName); } } - DebugLog(L"------------------------------"); + LSLog(LOG_DEBUG, APPNAME, L"------------------------------"); } } @@ -717,7 +717,7 @@ void CSystem::ChangeZPosInOrder() bool logging = CRainmeter::GetDebug() && DEBUG_VERBOSE; std::vector windowsInZOrder; - if (logging) LSLog(LOG_DEBUG, L"Rainmeter", L"1: ----- BEFORE -----"); + if (logging) LSLog(LOG_DEBUG, APPNAME, L"1: ----- BEFORE -----"); // Retrieve the Rainmeter's meter windows in Z-order EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder)); @@ -730,7 +730,7 @@ void CSystem::ChangeZPosInOrder() if (logging) { - LSLog(LOG_DEBUG, L"Rainmeter", L"2: ----- AFTER -----"); + LSLog(LOG_DEBUG, APPNAME, L"2: ----- AFTER -----"); // Log all windows in Z-order EnumWindows(MyEnumWindowsProc, (LPARAM)NULL); @@ -927,7 +927,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP break; case WM_DWMCOMPOSITIONCHANGED: - DebugLog(L"System: DWM desktop composition has been changed."); + LSLog(LOG_DEBUG, APPNAME, L"System: DWM desktop composition has been changed."); KillTimer(c_Window, TIMER_SHOWDESKTOP); KillTimer(c_Window, TIMER_COMPOSITION); @@ -946,7 +946,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP return 0; case WM_DISPLAYCHANGE: - DebugLog(L"System: Display setting has been changed."); + LSLog(LOG_DEBUG, APPNAME, L"System: Display setting has been changed."); ClearMultiMonitorInfo(); CConfigParser::ClearMultiMonitorVariables(); case WM_SETTINGCHANGE: @@ -954,7 +954,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP { if (uMsg == WM_SETTINGCHANGE) // SPI_SETWORKAREA { - DebugLog(L"System: Work area has been changed."); + LSLog(LOG_DEBUG, APPNAME, L"System: Work area has been changed."); UpdateWorkareaInfo(); CConfigParser::UpdateWorkareaVariables(); } diff --git a/Library/UpdateCheck.cpp b/Library/UpdateCheck.cpp index f4868477..e318130d 100644 --- a/Library/UpdateCheck.cpp +++ b/Library/UpdateCheck.cpp @@ -33,7 +33,7 @@ void CheckVersion(void* dummy) 0); if (hRootHandle == NULL) { - DebugLog(L"CheckUpdate: InternetOpen failed."); + LSLog(LOG_DEBUG, APPNAME, L"CheckUpdate: InternetOpen failed."); return; } @@ -75,18 +75,18 @@ void CheckVersion(void* dummy) else { Rainmeter->SetNewVersion(FALSE); - DebugLog(L"CheckUpdate: No new version available."); + LSLog(LOG_DEBUG, APPNAME, L"CheckUpdate: No new version available."); } } else { - DebugLog(L"CheckUpdate: InternetReadFile failed."); + LSLog(LOG_DEBUG, APPNAME, L"CheckUpdate: InternetReadFile failed."); } InternetCloseHandle(hUrlDump); } else { - DebugLog(L"CheckUpdate: InternetOpenUrl failed."); + LSLog(LOG_DEBUG, APPNAME, L"CheckUpdate: InternetOpenUrl failed."); } InternetCloseHandle(hRootHandle);