mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
WebParser reads the resource now only if it has been modified. This can be overridden with ForceReload=1.
This commit is contained in:
parent
40f11d3934
commit
d98c79e0fc
@ -57,6 +57,7 @@ struct UrlData
|
|||||||
std::wstring section;
|
std::wstring section;
|
||||||
std::wstring finishAction;
|
std::wstring finishAction;
|
||||||
bool download;
|
bool download;
|
||||||
|
bool forceReload;
|
||||||
std::wstring downloadedFile;
|
std::wstring downloadedFile;
|
||||||
std::wstring iniFile;
|
std::wstring iniFile;
|
||||||
int debug;
|
int debug;
|
||||||
@ -64,7 +65,7 @@ struct UrlData
|
|||||||
HANDLE dlThreadHandle;
|
HANDLE dlThreadHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
BYTE* DownloadUrl(std::wstring& url, DWORD* dwSize);
|
BYTE* DownloadUrl(std::wstring& url, DWORD* dwSize, bool forceReload);
|
||||||
void ShowError(int lineNumber, WCHAR* errorMsg = NULL);
|
void ShowError(int lineNumber, WCHAR* errorMsg = NULL);
|
||||||
DWORD WINAPI NetworkThreadProc(LPVOID pParam);
|
DWORD WINAPI NetworkThreadProc(LPVOID pParam);
|
||||||
DWORD WINAPI NetworkDownloadThreadProc(LPVOID pParam);
|
DWORD WINAPI NetworkDownloadThreadProc(LPVOID pParam);
|
||||||
@ -189,6 +190,12 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
|||||||
data->download = 1 == _wtoi(tmpSz);
|
data->download = 1 == _wtoi(tmpSz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpSz = ReadConfigString(section, L"ForceReload", L"0");
|
||||||
|
if (tmpSz)
|
||||||
|
{
|
||||||
|
data->forceReload = 1 == _wtoi(tmpSz);
|
||||||
|
}
|
||||||
|
|
||||||
tmpSz = ReadConfigString(section, L"Debug", L"0");
|
tmpSz = ReadConfigString(section, L"Debug", L"0");
|
||||||
if (tmpSz)
|
if (tmpSz)
|
||||||
{
|
{
|
||||||
@ -322,7 +329,7 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
|||||||
UrlData* urlData = (UrlData*)pParam;
|
UrlData* urlData = (UrlData*)pParam;
|
||||||
DWORD dwSize = 0;
|
DWORD dwSize = 0;
|
||||||
|
|
||||||
BYTE* data = DownloadUrl(urlData->url, &dwSize);
|
BYTE* data = DownloadUrl(urlData->url, &dwSize, urlData->forceReload);
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
@ -767,7 +774,7 @@ void Finalize(HMODULE instance, UINT id)
|
|||||||
Downloads the given url and returns the webpage as dynamically allocated string.
|
Downloads the given url and returns the webpage as dynamically allocated string.
|
||||||
You need to delete the returned string after use!
|
You need to delete the returned string after use!
|
||||||
*/
|
*/
|
||||||
BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize)
|
BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
||||||
{
|
{
|
||||||
HINTERNET hUrlDump;
|
HINTERNET hUrlDump;
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
@ -782,7 +789,13 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize)
|
|||||||
err += url;
|
err += url;
|
||||||
Log(err.c_str());
|
Log(err.c_str());
|
||||||
|
|
||||||
hUrlDump = InternetOpenUrl(hRootHandle, url.c_str(), NULL, NULL, INTERNET_FLAG_RELOAD, 0);
|
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
||||||
|
if (forceReload)
|
||||||
|
{
|
||||||
|
flags = INTERNET_FLAG_RELOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
hUrlDump = InternetOpenUrl(hRootHandle, url.c_str(), NULL, NULL, flags, 0);
|
||||||
if (hUrlDump == NULL)
|
if (hUrlDump == NULL)
|
||||||
{
|
{
|
||||||
ShowError(__LINE__);
|
ShowError(__LINE__);
|
||||||
|
Loading…
Reference in New Issue
Block a user