diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 1ae2529f..2beccae4 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -503,7 +503,7 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT std::map::iterator iter = m_Measures.find(var); if (iter != m_Measures.end()) { - std::wstring value = (*iter).second->GetStringValue(true, 1, 5, false); + std::wstring value = (*iter).second->GetStringValue(false, 1, 5, false); // Measure found, replace it with the value result.replace(result.begin() + pos, result.begin() + end + 1, value); diff --git a/Library/Library.rc b/Library/Library.rc index 4acc2520..0e5da218 100644 --- a/Library/Library.rc +++ b/Library/Library.rc @@ -155,7 +155,7 @@ END IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 234, 225 STYLE DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "Rainmeter" -FONT 8, "MS Sans Serif" +FONT 8, "MS Shell Dlg 2" BEGIN CONTROL "List1",IDC_STATISTICS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 67c4be8a..2fcec76d 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -551,7 +551,6 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage) // Clear the file logFile = _wfopen(logfile.c_str(), L"w"); - fputwc(0xFEFF, logFile); fclose(logFile); } else @@ -562,7 +561,7 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage) if (logFound == 1) { - logFile = _wfopen(logfile.c_str(), L"a+"); + logFile = _wfopen(logfile.c_str(), L"a+, ccs=UTF-8"); if (logFile) { switch(nLevel) diff --git a/Library/StdAfx.h b/Library/StdAfx.h index ee63914a..944bcae5 100644 --- a/Library/StdAfx.h +++ b/Library/StdAfx.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,7 @@ #include #include #include +#include // RUNTIME #include diff --git a/Plugins/PluginWebParser/WebParser.cpp b/Plugins/PluginWebParser/WebParser.cpp index 2a12c7fe..55253017 100644 --- a/Plugins/PluginWebParser/WebParser.cpp +++ b/Plugins/PluginWebParser/WebParser.cpp @@ -145,6 +145,26 @@ std::wstring ConvertToWide(LPCSTR str) return szWide; } +std::string ConvertToACP(LPCWSTR str) +{ + std::string szAscii; + + if (str && *str) + { + int strLen = (int)wcslen(str) + 1; + int bufLen = WideCharToMultiByte(CP_ACP, 0, str, strLen, NULL, 0, NULL, NULL); + if (bufLen > 0) + { + char* tmpSz = new char[bufLen]; + tmpSz[0] = 0; + WideCharToMultiByte(CP_ACP, 0, str, strLen, tmpSz, bufLen, NULL, NULL); + szAscii = tmpSz; + delete [] tmpSz; + } + } + return szAscii; +} + HWND FindMeterWindow() { HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL); @@ -206,7 +226,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) UrlData* data = new UrlData; data->section = section; - data->updateRate = 1; + data->updateRate = 600; data->updateCounter = 0; data->iniFile = iniFile; @@ -399,12 +419,18 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam) { // Dump to a file - // Convert to a narrow string - std::string path(urlData->debugFileLocation.begin(), urlData->debugFileLocation.end()); - - FILE* file = fopen(path.c_str(), "wb"); - fwrite(data, sizeof(BYTE), dwSize, file); - fclose(file); + FILE* file = _wfopen(urlData->debugFileLocation.c_str(), L"wb"); + if (file) + { + fwrite(data, sizeof(BYTE), dwSize, file); + fclose(file); + } + else + { + std::wstring error = L"WebParser: Failed to dump debug data: "; + error += urlData->debugFileLocation; + Log(error.c_str()); + } } ParseData(urlData, (LPCSTR)data); @@ -486,7 +512,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData) for (int i = 0; i < rc; i++) { WCHAR buffer[1024]; - char* substring_start = (char*)(parseData + ovector[2 * i]); + const char* substring_start = parseData + ovector[2 * i]; int substring_length = ovector[2 * i + 1] - ovector[2 * i]; substring_length = min(substring_length, 256); std::string tmpStr(substring_start, substring_length); @@ -499,7 +525,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData) int substring_length = ovector[2 * urlData->stringIndex + 1] - ovector[2 * urlData->stringIndex]; EnterCriticalSection(&g_CriticalSection); - std::string szResult((char*)substring_start, substring_length); + std::string szResult(substring_start, substring_length); urlData->resultString = ConvertToWide(szResult.c_str()); LeaveCriticalSection(&g_CriticalSection); } @@ -522,7 +548,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData) const char* substring_start = parseData + ovector[2 * ((*i).second)->stringIndex]; int substring_length = ovector[2 * ((*i).second)->stringIndex + 1] - ovector[2 * ((*i).second)->stringIndex]; - std::string szResult((char*)substring_start, substring_length); + std::string szResult(substring_start, substring_length); if (!((*i).second)->regExp.empty()) { @@ -1080,8 +1106,17 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload) hUrlDump = InternetOpenUrl(hRootHandle, url.c_str(), NULL, NULL, flags, 0); if (hUrlDump == NULL) { - ShowError(__LINE__); - return NULL; + if (wcsnicmp(url.c_str(), L"file://", 7) == 0) // file scheme + { + std::string urlACP = ConvertToACP(url.c_str()); + hUrlDump = InternetOpenUrlA(hRootHandle, urlACP.c_str(), NULL, NULL, flags, 0); + } + + if (hUrlDump == NULL) + { + ShowError(__LINE__); + return NULL; + } } *dwDataSize = 0; @@ -1167,7 +1202,8 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload) void ShowError(int lineNumber, WCHAR* errorMsg) { WCHAR szBuffer[4096]; - LPVOID lpMsgBuf = NULL; + + DWORD dwErr = GetLastError(); WCHAR buffer[16]; wsprintf(buffer, L"%i", lineNumber); @@ -1178,22 +1214,33 @@ void ShowError(int lineNumber, WCHAR* errorMsg) if (errorMsg == NULL) { - if (GetLastError() == ERROR_INTERNET_EXTENDED_ERROR) + if (dwErr == ERROR_INTERNET_EXTENDED_ERROR) { DWORD dwError, dwLen = 4096; if (InternetGetLastResponseInfo(&dwError, szBuffer, &dwLen)) { err += szBuffer; + wsprintf(buffer, L"%i", dwError); } + else + { + err += L"Unknown error"; + wsprintf(buffer, L"%i", dwErr); + } + + err += L" (ErrorCode="; + err += buffer; + err += L")"; } else { - DWORD dwErr = GetLastError(); + LPVOID lpMsgBuf = NULL; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language @@ -1204,15 +1251,18 @@ void ShowError(int lineNumber, WCHAR* errorMsg) if (lpMsgBuf == NULL) { - err += L"Unknown error: "; - wsprintf(buffer, L"%i", dwErr); - err += buffer; + err += L"Unknown error"; } else { err += (LPTSTR)lpMsgBuf; LocalFree(lpMsgBuf); } + + wsprintf(buffer, L"%i", dwErr); + err += L" (ErrorCode="; + err += buffer; + err += L")"; } } else