This commit is contained in:
Birunthan Mohanathas 2012-04-06 20:54:45 +03:00
parent 873b67571a
commit 8c3fd63ffb
3 changed files with 14 additions and 32 deletions

View File

@ -752,7 +752,6 @@ CRainmeter::~CRainmeter()
/* /*
** The main initialization function for the module. ** The main initialization function for the module.
** May throw CErrors !!!!
** **
*/ */
int CRainmeter::Initialize(LPCWSTR szPath) int CRainmeter::Initialize(LPCWSTR szPath)
@ -1019,7 +1018,7 @@ int CRainmeter::Initialize(LPCWSTR szPath)
if (m_Debug) if (m_Debug)
{ {
Log(LOG_DEBUG, L"Enumerating installed font families..."); Log(LOG_DEBUG, L"Enumerating font families...");
CMeterString::EnumerateInstalledFontFamilies(); CMeterString::EnumerateInstalledFontFamilies();
} }
@ -2030,8 +2029,7 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter
} }
else else
{ {
std::wstring error = L"Unknown bang: " + name; LogWithArgs(LOG_ERROR, L"Invalid bang: ", name.c_str());
Log(LOG_ERROR, error.c_str());
} }
} }

View File

@ -186,7 +186,7 @@ public:
bool GetDisableVersionCheck() { return m_DisableVersionCheck; } bool GetDisableVersionCheck() { return m_DisableVersionCheck; }
void SetDisableVersionCheck(bool check); void SetDisableVersionCheck(bool check);
bool GetNewVersion() { return m_NewVersion; } bool GetNewVersion() { return m_NewVersion; }
void SetNewVersion(bool newver) { m_NewVersion = newver; } void SetNewVersion() { m_NewVersion = true; }
bool GetLogging() { return m_Logging; } bool GetLogging() { return m_Logging; }
void StartLogging(); void StartLogging();

View File

@ -25,8 +25,6 @@ extern CRainmeter* Rainmeter;
void CheckVersion(void* dummy) void CheckVersion(void* dummy)
{ {
int version = 0;
HINTERNET hRootHandle = InternetOpen( HINTERNET hRootHandle = InternetOpen(
L"Rainmeter", L"Rainmeter",
INTERNET_OPEN_TYPE_PRECONFIG, INTERNET_OPEN_TYPE_PRECONFIG,
@ -46,38 +44,24 @@ void CheckVersion(void* dummy)
char buffer[16] = {0}; // 16 should be enough for the version number char buffer[16] = {0}; // 16 should be enough for the version number
if (InternetReadFile(hUrlDump, (LPVOID)buffer, 15, &dwSize)) if (InternetReadFile(hUrlDump, (LPVOID)buffer, 15, &dwSize))
{ {
std::string verStr = buffer; int version = atoi(buffer) * 1000000;
size_t pos = verStr.find('.'); char* pos = strchr(buffer, '.');
if (pos != std::wstring::npos) if (pos)
{ {
std::string verMajor = verStr.substr(0, pos); ++pos; // Skip .
std::string verMinor = verStr.substr(pos + 1); version += atoi(pos) * 1000;
version = atoi(verMajor.c_str()) * 1000000; pos = strchr(pos, '.');
if (pos)
pos = verMinor.find('.');
if (pos != std::wstring::npos)
{ {
std::string verMinor1 = verMinor.substr(0, pos); ++pos; // Skip .
std::string verMinor2 = verMinor.substr(pos + 1); version += atoi(pos);
version += atoi(verMinor1.c_str()) * 1000;
version += atoi(verMinor2.c_str());
}
else
{
version += atoi(verMinor.c_str()) * 1000;
} }
} }
if (version > RAINMETER_VERSION) if (version > RAINMETER_VERSION)
{ {
Rainmeter->SetNewVersion(true); Rainmeter->SetNewVersion();
Log(LOG_NOTICE, L"CheckUpdate: Update available");
}
else
{
Rainmeter->SetNewVersion(false);
} }
} }
InternetCloseHandle(hUrlDump); InternetCloseHandle(hUrlDump);
@ -88,5 +72,5 @@ void CheckVersion(void* dummy)
void CheckUpdate() void CheckUpdate()
{ {
_beginthread(CheckVersion, 0, NULL ); _beginthread(CheckVersion, 0, NULL);
} }