2018-07-22 06:40:16 +08:00
|
|
|
#include "mainwindow.h"
|
2018-11-28 04:54:04 +08:00
|
|
|
#include "host/util.h"
|
2019-06-27 15:09:44 +08:00
|
|
|
#include <winhttp.h>
|
2018-07-22 06:40:16 +08:00
|
|
|
#include <QApplication>
|
|
|
|
|
2019-06-27 15:09:44 +08:00
|
|
|
extern const wchar_t* UPDATE_AVAILABLE;
|
|
|
|
|
2018-07-22 06:40:16 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-06-27 15:09:44 +08:00
|
|
|
std::thread([]
|
|
|
|
{
|
2019-09-01 21:27:51 +08:00
|
|
|
if (!*VERSION) return;
|
2019-06-27 15:09:44 +08:00
|
|
|
using InternetHandle = AutoHandle<Functor<WinHttpCloseHandle>>;
|
|
|
|
// Queries GitHub releases API https://developer.github.com/v3/repos/releases/ and checks the last release tag to check if it's the same
|
|
|
|
if (InternetHandle internet = WinHttpOpen(L"Mozilla/5.0 Textractor", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, 0))
|
|
|
|
if (InternetHandle connection = WinHttpConnect(internet, L"api.github.com", INTERNET_DEFAULT_HTTPS_PORT, 0))
|
|
|
|
if (InternetHandle request = WinHttpOpenRequest(connection, L"GET", L"/repos/Artikash/Textractor/releases", NULL, NULL, NULL, WINHTTP_FLAG_SECURE))
|
|
|
|
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
|
|
|
{
|
|
|
|
char buffer[1000] = {};
|
|
|
|
WinHttpReceiveResponse(request, NULL);
|
|
|
|
WinHttpReadData(request, buffer, 1000, DUMMY);
|
2020-02-12 14:34:03 +08:00
|
|
|
if (abs(strstr(buffer, "/tag/") - strstr(buffer, VERSION)) > 10) TEXTRACTOR_MESSAGE(UPDATE_AVAILABLE);
|
2019-06-27 15:09:44 +08:00
|
|
|
}
|
|
|
|
}).detach();
|
|
|
|
|
2018-12-23 02:05:01 +08:00
|
|
|
QDir::setCurrent(QFileInfo(S(Util::GetModuleFilename().value())).absolutePath());
|
2018-11-28 04:54:04 +08:00
|
|
|
|
2019-06-27 15:09:44 +08:00
|
|
|
QApplication app(argc, argv);
|
2019-07-13 21:45:43 +08:00
|
|
|
app.setFont(QFont("MS Shell Dlg 2", 10));
|
2019-06-27 15:09:44 +08:00
|
|
|
return MainWindow().show(), app.exec();
|
2018-07-22 06:40:16 +08:00
|
|
|
}
|