mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Additional changes to 95e6b4b
This commit is contained in:
parent
3c58e4d48c
commit
1414b3022e
@ -29,7 +29,7 @@
|
|||||||
#include "../../Common/StringUtil.h"
|
#include "../../Common/StringUtil.h"
|
||||||
#include "../API/RainmeterAPI.h"
|
#include "../API/RainmeterAPI.h"
|
||||||
|
|
||||||
void ShowError(int lineNumber, WCHAR* errorMsg = nullptr);
|
void ShowError(void* rm, WCHAR* description);
|
||||||
|
|
||||||
class ProxyCachePool
|
class ProxyCachePool
|
||||||
{
|
{
|
||||||
@ -152,7 +152,7 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowError(__LINE__);
|
ShowError(nullptr, L"InternetOpen error");
|
||||||
}
|
}
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
@ -852,8 +852,11 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
|||||||
|
|
||||||
RmLogF(measure->rm, LOG_DEBUG, L"WebParser: Fetching: %s", measure->url.c_str());
|
RmLogF(measure->rm, LOG_DEBUG, L"WebParser: Fetching: %s", measure->url.c_str());
|
||||||
BYTE* data = DownloadUrl(measure->proxy.handle, measure->url, &dwSize, measure->forceReload);
|
BYTE* data = DownloadUrl(measure->proxy.handle, measure->url, &dwSize, measure->forceReload);
|
||||||
|
if (!data)
|
||||||
if (data)
|
{
|
||||||
|
ShowError(measure->rm, L"Fetch error");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (measure->debug == 2)
|
if (measure->debug == 2)
|
||||||
{
|
{
|
||||||
@ -1538,11 +1541,7 @@ BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool for
|
|||||||
hUrlDump = InternetOpenUrlA(handle, urlACP.c_str(), nullptr, 0, flags, 0);
|
hUrlDump = InternetOpenUrlA(handle, urlACP.c_str(), nullptr, 0, flags, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hUrlDump)
|
return nullptr;
|
||||||
{
|
|
||||||
ShowError(__LINE__);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate buffer with 3 extra bytes for triple null termination in case the string is
|
// Allocate buffer with 3 extra bytes for triple null termination in case the string is
|
||||||
@ -1558,8 +1557,9 @@ BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool for
|
|||||||
DWORD readSize;
|
DWORD readSize;
|
||||||
if (!InternetReadFile(hUrlDump, buffer + *dataSize, bufferSize - *dataSize, &readSize))
|
if (!InternetReadFile(hUrlDump, buffer + *dataSize, bufferSize - *dataSize, &readSize))
|
||||||
{
|
{
|
||||||
ShowError(__LINE__);
|
free(buffer);
|
||||||
break;
|
InternetCloseHandle(hUrlDump);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
else if (readSize == 0)
|
else if (readSize == 0)
|
||||||
{
|
{
|
||||||
@ -1587,14 +1587,8 @@ BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool for
|
|||||||
/*
|
/*
|
||||||
Writes the last error to log.
|
Writes the last error to log.
|
||||||
*/
|
*/
|
||||||
void ShowError(int lineNumber, WCHAR* errorMsg)
|
void ShowError(void* rm, WCHAR* description)
|
||||||
{
|
{
|
||||||
if (errorMsg)
|
|
||||||
{
|
|
||||||
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s", lineNumber, errorMsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD dwErr = GetLastError();
|
DWORD dwErr = GetLastError();
|
||||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||||
{
|
{
|
||||||
@ -1607,7 +1601,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
|||||||
dwErr = dwError;
|
dwErr = dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s (ErrorCode=%i)", lineNumber, error, dwErr);
|
RmLogF(rm, LOG_ERROR, L"WebParser: (%s) %s (ErrorCode=%i)", description, error, dwErr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1628,7 +1622,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
|||||||
);
|
);
|
||||||
|
|
||||||
const WCHAR* error = lpMsgBuf ? (WCHAR*)lpMsgBuf : L"Unknown error";
|
const WCHAR* error = lpMsgBuf ? (WCHAR*)lpMsgBuf : L"Unknown error";
|
||||||
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s (ErrorCode=%i)", lineNumber, error, dwErr);
|
RmLogF(rm, LOG_ERROR, L"WebParser: (%s) %s (ErrorCode=%i)", description, error, dwErr);
|
||||||
|
|
||||||
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user