5 Commits

6 changed files with 26 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
## wCenterWindow ## wCenterWindow
Copyright (c) 2020-2024 Vladislav Salikov aka W0LF.<br> Copyright (c) 2020-2025 Vladislav Salikov aka W0LF.<br>
Program icon made by Kirill Topov. Program icon made by Kirill Topov.
--- ---

Binary file not shown.

View File

@@ -1,4 +1,4 @@
// wCenterWindow // wCenterWindow
// updater.h // updater.h
#include "wCenterWindow.h" #include "wCenterWindow.h"
@@ -46,13 +46,6 @@ UINT WINAPI Updater(void*) {
logger.Out(L"[UPDT] %s(%d): Parsing JSON object", TEXT(__FUNCTION__), __LINE__); logger.Out(L"[UPDT] %s(%d): Parsing JSON object", TEXT(__FUNCTION__), __LINE__);
obj = json.get<picojson::object>(); obj = json.get<picojson::object>();
it = obj.find("message"), it2;
if (it != obj.end()) {
std::string u = (*it).second.get<std::string>();
logger.Out(L"[UPDT] %s(%d): Error! The url is %s", TEXT(__FUNCTION__), __LINE__, u);
return 102;
_endthreadex(102);
}
for (it = obj.begin(); it != obj.end(); it++) { for (it = obj.begin(); it != obj.end(); it++) {
if ((*it).first == "tag_name") j_tag_name = ConvertUtf8ToWide((*it).second.to_str()); if ((*it).first == "tag_name") j_tag_name = ConvertUtf8ToWide((*it).second.to_str());
@@ -70,8 +63,8 @@ UINT WINAPI Updater(void*) {
} }
else { else {
logger.Out(L"[UPDT] %s(%d): Error! Cannot recognize JSON object!", TEXT(__FUNCTION__), __LINE__); logger.Out(L"[UPDT] %s(%d): Error! Cannot recognize JSON object!", TEXT(__FUNCTION__), __LINE__);
return 103; return 102;
_endthreadex(103); _endthreadex(102);
} }
size_t pos = 0; size_t pos = 0;
@@ -133,8 +126,7 @@ bool GetLatestRelease(const std::wstring& urn) {
do { do {
InternetReadFile(hRequest, szData, sizeof(szData), &dwBytesRead); InternetReadFile(hRequest, szData, sizeof(szData), &dwBytesRead);
buffer.append(szData, dwBytesRead); buffer.append(szData, dwBytesRead);
} } while (dwBytesRead != 0);
while (dwBytesRead != 0);
picojson::parse(json, buffer); picojson::parse(json, buffer);
std::string jerr = picojson::get_last_error(); std::string jerr = picojson::get_last_error();
@@ -144,7 +136,18 @@ bool GetLatestRelease(const std::wstring& urn) {
MessageBoxW(NULL, L"Error while parsing JSON object!", szTitle, MB_OK | MB_ICONERROR); MessageBoxW(NULL, L"Error while parsing JSON object!", szTitle, MB_OK | MB_ICONERROR);
ret = false; ret = false;
} }
else {
picojson::object obj = json.get<picojson::object>();
std::string msg, sts;
if (auto search = obj.find("message"); search != obj.end()) {
msg = (search->first) + ": " + (search->second).get<std::string>();
}
if (auto search = obj.find("status"); search != obj.end()) {
sts = (search->first) + ": " + (search->second).get<std::string>();
}
logger.Out(L"[UPDT] %s(%d): Error! %s", TEXT(__FUNCTION__), __LINE__, ConvertUtf8ToWide(msg + ", " + sts).c_str());
ret = false;
}
} }
else { else {
err = GetLastError(); err = GetLastError();

View File

@@ -1,7 +1,8 @@
// wCenterWindow // wCenterWindow
// wCenterWindow.cpp // wCenterWindow.cpp
// TODO: Split main cpp-file to separate files. // TODO: Split main cpp-file to separate files.
// TODO: Make Updater's errors as Windows notifications.
// TODO: Make the automatic updater (download, unzip and replace executable). // TODO: Make the automatic updater (download, unzip and replace executable).
// TODO: Change keyboard low-level hook to RegisterHotKey function. (Is it really needed?) // TODO: Change keyboard low-level hook to RegisterHotKey function. (Is it really needed?)
@@ -230,7 +231,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
HeapFree(hHeap, NULL, szWinClassBuffer); HeapFree(hHeap, NULL, szWinClassBuffer);
HeapFree(hHeap, NULL, szWinTitleBuffer); HeapFree(hHeap, NULL, szWinTitleBuffer);
logger.Out(L"Exit from the %s() function, msg.wParam = 0x%0*tX", TEXT(__FUNCTION__), (sizeof(UINT_PTR) * 2), static_cast<UINT_PTR>(msg.wParam)); logger.Out(L"Exit from the %s() function, msg.wParam = 0x%p", TEXT(__FUNCTION__), msg.wParam);
return static_cast<UINT_PTR>(msg.wParam); return static_cast<UINT_PTR>(msg.wParam);
} }

Binary file not shown.

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>/noupdate</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>
</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -10,7 +11,8 @@
</LocalDebuggerCommandArguments> </LocalDebuggerCommandArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>/noupdate</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>
</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">