57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#include "mainwindow.h"
|
|
|
|
#include <QApplication>
|
|
#include <QThread>
|
|
#include <QScreen>
|
|
#include "HGUpgrade.h"
|
|
#include "curl/curl.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int type = 0;
|
|
std::string desc;
|
|
std::string pkgPath;
|
|
|
|
for (int i = 1; i < argc; i++)
|
|
{
|
|
char* z = argv[i];
|
|
|
|
if (0 == strcmp(z, "-type=postinstallinfo"))
|
|
type = 1;
|
|
else if (0 == strcmp(z, "-type=postuninstallinfo"))
|
|
type = 2;
|
|
else if (0 == strcmp(z, "-type=upgrade"))
|
|
type = 3;
|
|
else if (z == strstr(z, "-pkgpath="))
|
|
pkgPath = z + strlen("-pkgpath=");
|
|
else if (z == strstr(z, "-desc="))
|
|
desc = z + strlen("-desc=");
|
|
}
|
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
if (1 == type)
|
|
PostInstallInfo(desc);
|
|
else if (2 == type)
|
|
PostUninstallInfo(desc);
|
|
else if (3 == type && !pkgPath.empty())
|
|
{
|
|
QApplication a(argc, argv);
|
|
|
|
while (AppIsRun())
|
|
QThread::msleep(20);
|
|
|
|
MainWindow w(pkgPath, desc);
|
|
QScreen *screen = QGuiApplication::primaryScreen();
|
|
w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2);
|
|
w.show();
|
|
a.exec();
|
|
|
|
if (!AppIsRun())
|
|
RunApp();
|
|
}
|
|
|
|
curl_global_cleanup();
|
|
return 0;
|
|
}
|