From 8c3fd63ffb45b450a891dd7b8035907ee6d457f5 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 6 Apr 2012 20:54:45 +0300 Subject: [PATCH] Tweaks --- Library/Rainmeter.cpp | 6 ++---- Library/Rainmeter.h | 2 +- Library/UpdateCheck.cpp | 38 +++++++++++--------------------------- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 67e4dd81..1d682b3a 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -752,7 +752,6 @@ CRainmeter::~CRainmeter() /* ** The main initialization function for the module. -** May throw CErrors !!!! ** */ int CRainmeter::Initialize(LPCWSTR szPath) @@ -1019,7 +1018,7 @@ int CRainmeter::Initialize(LPCWSTR szPath) if (m_Debug) { - Log(LOG_DEBUG, L"Enumerating installed font families..."); + Log(LOG_DEBUG, L"Enumerating font families..."); CMeterString::EnumerateInstalledFontFamilies(); } @@ -2030,8 +2029,7 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter } else { - std::wstring error = L"Unknown bang: " + name; - Log(LOG_ERROR, error.c_str()); + LogWithArgs(LOG_ERROR, L"Invalid bang: ", name.c_str()); } } diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 0510dc32..babcfb83 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -186,7 +186,7 @@ public: bool GetDisableVersionCheck() { return m_DisableVersionCheck; } void SetDisableVersionCheck(bool check); bool GetNewVersion() { return m_NewVersion; } - void SetNewVersion(bool newver) { m_NewVersion = newver; } + void SetNewVersion() { m_NewVersion = true; } bool GetLogging() { return m_Logging; } void StartLogging(); diff --git a/Library/UpdateCheck.cpp b/Library/UpdateCheck.cpp index b13de8ef..96acb890 100644 --- a/Library/UpdateCheck.cpp +++ b/Library/UpdateCheck.cpp @@ -25,8 +25,6 @@ extern CRainmeter* Rainmeter; void CheckVersion(void* dummy) { - int version = 0; - HINTERNET hRootHandle = InternetOpen( L"Rainmeter", INTERNET_OPEN_TYPE_PRECONFIG, @@ -46,38 +44,24 @@ void CheckVersion(void* dummy) char buffer[16] = {0}; // 16 should be enough for the version number if (InternetReadFile(hUrlDump, (LPVOID)buffer, 15, &dwSize)) { - std::string verStr = buffer; - size_t pos = verStr.find('.'); - if (pos != std::wstring::npos) + int version = atoi(buffer) * 1000000; + char* pos = strchr(buffer, '.'); + if (pos) { - std::string verMajor = verStr.substr(0, pos); - std::string verMinor = verStr.substr(pos + 1); + ++pos; // Skip . + version += atoi(pos) * 1000; - version = atoi(verMajor.c_str()) * 1000000; - - pos = verMinor.find('.'); - if (pos != std::wstring::npos) + pos = strchr(pos, '.'); + if (pos) { - std::string verMinor1 = verMinor.substr(0, pos); - std::string verMinor2 = verMinor.substr(pos + 1); - - version += atoi(verMinor1.c_str()) * 1000; - version += atoi(verMinor2.c_str()); - } - else - { - version += atoi(verMinor.c_str()) * 1000; + ++pos; // Skip . + version += atoi(pos); } } if (version > RAINMETER_VERSION) { - Rainmeter->SetNewVersion(true); - Log(LOG_NOTICE, L"CheckUpdate: Update available"); - } - else - { - Rainmeter->SetNewVersion(false); + Rainmeter->SetNewVersion(); } } InternetCloseHandle(hUrlDump); @@ -88,5 +72,5 @@ void CheckVersion(void* dummy) void CheckUpdate() { - _beginthread(CheckVersion, 0, NULL ); + _beginthread(CheckVersion, 0, NULL); }