修改HGUpgrade依赖HGVersion和HGBase
This commit is contained in:
parent
8862712f14
commit
26421a48c8
|
@ -1,422 +1,15 @@
|
||||||
#include "HGUpgrade.h"
|
#include "HGUpgrade.h"
|
||||||
#include "base/HGDef.h"
|
#include "base/HGDef.h"
|
||||||
#include "base/HGInc.h"
|
#include "base/HGInc.h"
|
||||||
#include "base/HGMd5.h"
|
#include "version/HGVersion.h"
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "curl/curl.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <HGString.h>
|
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
#include <iphlpapi.h>
|
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void GetMacAddrList(std::vector<std::string> &macList)
|
bool AppIsRun(const std::string& appName)
|
||||||
{
|
{
|
||||||
macList.clear();
|
if (appName == HGVERSION_APPNAME_SCANNER)
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
|
|
||||||
PIP_ADAPTER_INFO pAdapterInfo = (PIP_ADAPTER_INFO)malloc(ulOutBufLen);
|
|
||||||
|
|
||||||
ULONG nRet = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
|
|
||||||
if (ERROR_BUFFER_OVERFLOW == nRet)
|
|
||||||
{
|
|
||||||
free(pAdapterInfo);
|
|
||||||
pAdapterInfo = nullptr;
|
|
||||||
pAdapterInfo = (PIP_ADAPTER_INFO)malloc(ulOutBufLen);
|
|
||||||
|
|
||||||
nRet = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ERROR_SUCCESS == nRet)
|
|
||||||
{
|
|
||||||
PIP_ADAPTER_INFO pAdapter = pAdapterInfo;
|
|
||||||
while (nullptr != pAdapter)
|
|
||||||
{
|
|
||||||
DWORD dwCharacteristics = 0;
|
|
||||||
|
|
||||||
HKEY hKey = nullptr;
|
|
||||||
RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}", 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
|
|
||||||
if (nullptr != hKey)
|
|
||||||
{
|
|
||||||
DWORD dwIndex = 0;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
CHAR szValueName[256];
|
|
||||||
if (ERROR_SUCCESS != RegEnumKeyA(hKey, dwIndex, szValueName, 256))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HKEY hKey2 = nullptr;
|
|
||||||
RegOpenKeyExA(hKey, szValueName, 0, KEY_QUERY_VALUE, &hKey2);
|
|
||||||
if (nullptr != hKey2)
|
|
||||||
{
|
|
||||||
DWORD dwType;
|
|
||||||
CHAR szData[256] = { 0 };
|
|
||||||
DWORD cbData = 256;
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueExA(hKey2, "NetCfgInstanceId", nullptr, &dwType, (LPBYTE)szData, &cbData) && REG_SZ == dwType)
|
|
||||||
{
|
|
||||||
if (0 == _stricmp(szData, pAdapter->AdapterName))
|
|
||||||
{
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueExA(hKey2, "Characteristics", nullptr, &dwType, (LPBYTE)szData, &cbData) && REG_DWORD == dwType)
|
|
||||||
{
|
|
||||||
dwCharacteristics = *(DWORD*)szData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey2);
|
|
||||||
}
|
|
||||||
|
|
||||||
++dwIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((dwCharacteristics & 0x4))
|
|
||||||
{
|
|
||||||
std::string strMacAddr;
|
|
||||||
for (UINT i = 0; i < pAdapter->AddressLength; i++)
|
|
||||||
{
|
|
||||||
char str[10];
|
|
||||||
sprintf(str, "%02x", pAdapter->Address[i]);
|
|
||||||
strMacAddr += str;
|
|
||||||
if (i != pAdapter->AddressLength - 1)
|
|
||||||
strMacAddr += "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
macList.push_back(strMacAddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pAdapter = pAdapter->Next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(pAdapterInfo);
|
|
||||||
pAdapterInfo = nullptr;
|
|
||||||
#else
|
|
||||||
DIR *dir = opendir("/sys/class/net");
|
|
||||||
if (nullptr != dir)
|
|
||||||
{
|
|
||||||
printf("opendir success\n");
|
|
||||||
|
|
||||||
struct dirent *ent;
|
|
||||||
while ((ent = readdir(dir)) != nullptr)
|
|
||||||
{
|
|
||||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strstr(ent->d_name, "docker") == ent->d_name || strstr(ent->d_name, "sit") == ent->d_name
|
|
||||||
|| strstr(ent->d_name, "ip6tnl") == ent->d_name || strcmp(ent->d_name, "lo") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
printf("name %s\n", ent->d_name);
|
|
||||||
|
|
||||||
char addrPath[256];
|
|
||||||
sprintf(addrPath, "/sys/class/net/%s/address", ent->d_name);
|
|
||||||
|
|
||||||
FILE *file = fopen(addrPath, "rb");
|
|
||||||
if (nullptr != file)
|
|
||||||
{
|
|
||||||
char mac[1025] = {0};
|
|
||||||
fread(mac, 1, 1024, file);
|
|
||||||
|
|
||||||
int len = (int)strlen(mac);
|
|
||||||
for (int i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
if (mac[i] == ':')
|
|
||||||
mac[i] = '-';
|
|
||||||
else if (mac[i] == '\n')
|
|
||||||
mac[i] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(mac) > 0)
|
|
||||||
{
|
|
||||||
macList.push_back(mac);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("mac %s\n", mac);
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("fopen fail\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("opendir fail\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string GetCurrVersion()
|
|
||||||
{
|
|
||||||
std::string version = "0.0.0.0";
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
std::string regName = "SOFTWARE\\HanvonScan";
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
std::string regName = "SOFTWARE\\LanxumScan";
|
|
||||||
#else
|
|
||||||
std::string regName = "SOFTWARE\\HuaGoScan";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HKEY hKey = nullptr;
|
|
||||||
RegOpenKeyExA(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
|
||||||
if (nullptr != hKey)
|
|
||||||
{
|
|
||||||
CHAR szData[MAX_PATH] = { 0 };
|
|
||||||
DWORD cbData = MAX_PATH;
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueExA(hKey, "AppVersion", nullptr, nullptr, (LPBYTE)szData, &cbData))
|
|
||||||
{
|
|
||||||
version = szData;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
std::string appName = "com.hanvonchina.hanvonscan";
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
std::string appName = "com.lanxumchina.lanxumscan";
|
|
||||||
#else
|
|
||||||
std::string appName = "com.huagaochina.huagoscan";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string cmd = "dpkg -l " + appName;
|
|
||||||
FILE *fp = popen(cmd.c_str(), "r");
|
|
||||||
if (nullptr != fp)
|
|
||||||
{
|
|
||||||
char buff[2048] = {0};
|
|
||||||
fread(buff, 2048, 1, fp);
|
|
||||||
|
|
||||||
char *p = strstr(buff, appName.c_str());
|
|
||||||
if (nullptr != p)
|
|
||||||
{
|
|
||||||
char *p2 = p + appName.size();
|
|
||||||
while (!isdigit(*p2) && '.' != *p2)
|
|
||||||
++p2;
|
|
||||||
|
|
||||||
int len = (int)strlen(p2);
|
|
||||||
for (int i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
if (!isdigit(p2[i]) && '.' != p2[i])
|
|
||||||
{
|
|
||||||
p2[i] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
version = p2;
|
|
||||||
}
|
|
||||||
|
|
||||||
pclose(fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
|
|
||||||
{
|
|
||||||
std::string data((const char*) ptr, (size_t) size * nmemb);
|
|
||||||
|
|
||||||
*((std::stringstream*) stream) << data << std::endl;
|
|
||||||
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool Greater(const std::string &str1, const std::string &str2)
|
|
||||||
{
|
|
||||||
return str1 > str2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// type:1表示安装 2表示卸载 src:来源 desc: 说明
|
|
||||||
static bool PostInfo(int type, const std::string &desc)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
CURL* curl = curl_easy_init();
|
|
||||||
if (nullptr != curl)
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
|
|
||||||
std::string url = "http://up.appqy.com/api/recode";
|
|
||||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
||||||
|
|
||||||
std::vector<std::string> macList;
|
|
||||||
GetMacAddrList(macList);
|
|
||||||
if (macList.empty())
|
|
||||||
macList.push_back("00-00-00-00-00-00");
|
|
||||||
|
|
||||||
std::sort(macList.begin(), macList.end(), Greater);
|
|
||||||
std::string strMacAddrTotal;
|
|
||||||
for (int i = 0; i < (int)macList.size(); ++i)
|
|
||||||
{
|
|
||||||
strMacAddrTotal += macList[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
HGByte md5[16] = {0};
|
|
||||||
HGBase_MakeMd5((const HGByte *)strMacAddrTotal.c_str(), strMacAddrTotal.size(), md5);
|
|
||||||
char md5Str[64] = {0};
|
|
||||||
char *pstr = md5Str;
|
|
||||||
for (int i = 0; i < 16; ++i)
|
|
||||||
{
|
|
||||||
sprintf(pstr, "%02x", md5[i]);
|
|
||||||
pstr += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string version = GetCurrVersion();
|
|
||||||
|
|
||||||
std::string osName, archName, oemName;
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
osName = "Windows";
|
|
||||||
archName = "unknown";
|
|
||||||
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
GetNativeSystemInfo(&si);
|
|
||||||
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
|
||||||
archName = "x64";
|
|
||||||
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
|
||||||
archName = "x86";
|
|
||||||
|
|
||||||
#else
|
|
||||||
osName = "Linux";
|
|
||||||
archName = "unknown";
|
|
||||||
|
|
||||||
FILE *fp = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
|
||||||
if (nullptr != fp)
|
|
||||||
{
|
|
||||||
char buff[1024] = {0};
|
|
||||||
fread(buff, 1024, 1, fp);
|
|
||||||
|
|
||||||
int len = (int)strlen(buff);
|
|
||||||
for (int i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
if (buff[i] == '\n')
|
|
||||||
buff[i] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
osName = buff;
|
|
||||||
pclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = popen("arch", "r");
|
|
||||||
if (nullptr != fp)
|
|
||||||
{
|
|
||||||
char buff[1024] = {0};
|
|
||||||
fread(buff, 1024, 1, fp);
|
|
||||||
|
|
||||||
int len = (int)strlen(buff);
|
|
||||||
for (int i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
if (buff[i] == '\n')
|
|
||||||
buff[i] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
archName = buff;
|
|
||||||
pclose(fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
oemName = "Hanvon";
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
oemName = "Lanxum";
|
|
||||||
#else
|
|
||||||
oemName = "Huago";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string source = osName + "-" + archName + "-" + oemName;
|
|
||||||
|
|
||||||
char json[1024];
|
|
||||||
sprintf(json, "{\"type\":%d, \"mac\":\"%s\", \"localid\":\"%s\", \"v\":\"%s\", \"ref\":\"%s\", \"desc\":\"%s\"}",
|
|
||||||
type, macList[0].c_str(), md5Str, version.c_str(), source.c_str(), desc.c_str());
|
|
||||||
|
|
||||||
struct curl_slist* headers = nullptr;
|
|
||||||
headers = curl_slist_append(headers, "Content-Type:application/json;charset=UTF-8");
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
|
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out);
|
|
||||||
|
|
||||||
/* Perform the request, res will get the return code */
|
|
||||||
CURLcode res = curl_easy_perform(curl);
|
|
||||||
/* Check for errors */
|
|
||||||
if (res != CURLE_OK)
|
|
||||||
fprintf(stderr, "curl_easy_perform() failed: %s", curl_easy_strerror(res));
|
|
||||||
else
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
curl_slist_free_all(headers);
|
|
||||||
|
|
||||||
std::string str_json = out.str(); // 返回值
|
|
||||||
printf("%s\n", str_json.c_str());
|
|
||||||
|
|
||||||
/* always cleanup */
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PostInstallInfo(const std::string &desc)
|
|
||||||
{
|
|
||||||
return PostInfo(1, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PostUninstallInfo(const std::string &desc)
|
|
||||||
{
|
|
||||||
return PostInfo(2, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Upgrade(const std::string& pkgPath)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
|
|
||||||
PROCESS_INFORMATION ProcessInfo;
|
|
||||||
STARTUPINFOA StartupInfo;
|
|
||||||
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
|
||||||
StartupInfo.cb = sizeof(StartupInfo);
|
|
||||||
|
|
||||||
char command[256];
|
|
||||||
sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent");
|
|
||||||
if (CreateProcessA(nullptr, command, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &StartupInfo, &ProcessInfo))
|
|
||||||
{
|
|
||||||
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
|
||||||
CloseHandle(ProcessInfo.hThread);
|
|
||||||
CloseHandle(ProcessInfo.hProcess);
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
std::string cmd = "dpkg -i \"" + pkgPath + "\"";
|
|
||||||
if (0 == system(cmd.c_str()))
|
|
||||||
ret = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppIsRun()
|
|
||||||
{
|
{
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
|
@ -520,7 +113,42 @@ bool AppIsRun()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunApp()
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Upgrade(const std::string& pkgPath)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
|
PROCESS_INFORMATION ProcessInfo;
|
||||||
|
STARTUPINFOA StartupInfo;
|
||||||
|
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
||||||
|
StartupInfo.cb = sizeof(StartupInfo);
|
||||||
|
|
||||||
|
char command[256];
|
||||||
|
sprintf(command, "%s %s", pkgPath.c_str(), "/verysilent");
|
||||||
|
if (CreateProcessA(nullptr, command, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &StartupInfo, &ProcessInfo))
|
||||||
|
{
|
||||||
|
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
||||||
|
CloseHandle(ProcessInfo.hThread);
|
||||||
|
CloseHandle(ProcessInfo.hProcess);
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::string cmd = "dpkg -i \"" + pkgPath + "\"";
|
||||||
|
if (0 == system(cmd.c_str()))
|
||||||
|
ret = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunApp(const std::string& appName)
|
||||||
|
{
|
||||||
|
if (appName == HGVERSION_APPNAME_SCANNER)
|
||||||
{
|
{
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
|
@ -568,3 +196,4 @@ void RunApp()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,19 +3,13 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// 上传安装日志
|
// 判断app是否在运行
|
||||||
bool PostInstallInfo(const std::string &desc);
|
bool AppIsRun(const std::string& appName);
|
||||||
|
|
||||||
// 上传卸载日志
|
|
||||||
bool PostUninstallInfo(const std::string &desc);
|
|
||||||
|
|
||||||
// 升级安装, 使用之前的安装路径
|
// 升级安装, 使用之前的安装路径
|
||||||
bool Upgrade(const std::string& pkgPath);
|
bool Upgrade(const std::string& pkgPath);
|
||||||
|
|
||||||
// 判断app是否在运行
|
|
||||||
bool AppIsRun();
|
|
||||||
|
|
||||||
// 运行app
|
// 运行app
|
||||||
void RunApp();
|
void RunApp(const std::string& appName);
|
||||||
|
|
||||||
#endif /* __HGUPGRADE_H__ */
|
#endif /* __HGUPGRADE_H__ */
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include "version/HGVersion.h"
|
||||||
#include "HGUpgrade.h"
|
#include "HGUpgrade.h"
|
||||||
#include "curl/curl.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int type = 0;
|
std::string type;
|
||||||
|
std::string appName;
|
||||||
std::string desc;
|
std::string desc;
|
||||||
std::string pkgPath;
|
std::string pkgPath;
|
||||||
|
|
||||||
|
@ -16,29 +17,41 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char* z = argv[i];
|
char* z = argv[i];
|
||||||
|
|
||||||
if (0 == strcmp(z, "-type=postinstallinfo"))
|
if (z == strstr(z, "-type="))
|
||||||
type = 1;
|
type = z + strlen("-type=");
|
||||||
else if (0 == strcmp(z, "-type=postuninstallinfo"))
|
else if (z == strstr(z, "-appName="))
|
||||||
type = 2;
|
appName = z + strlen("-appName=");
|
||||||
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="))
|
else if (z == strstr(z, "-desc="))
|
||||||
desc = z + strlen("-desc=");
|
desc = z + strlen("-desc=");
|
||||||
|
else if (z == strstr(z, "-pkgpath="))
|
||||||
|
pkgPath = z + strlen("-pkgpath=");
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
if ("postinstallinfo" == type && !appName.empty())
|
||||||
|
{
|
||||||
if (1 == type)
|
HGVersionMgr mgr = nullptr;
|
||||||
PostInstallInfo(desc);
|
HGVersion_CreateMgr(&mgr);
|
||||||
else if (2 == type)
|
if (nullptr != mgr)
|
||||||
PostUninstallInfo(desc);
|
{
|
||||||
else if (3 == type && !pkgPath.empty())
|
HGVersion_PostInstallInfo(mgr, appName.c_str(), desc.c_str());
|
||||||
|
HGVersion_DestroyMgr(mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ("postuninstallinfo" == type && !appName.empty())
|
||||||
|
{
|
||||||
|
HGVersionMgr mgr = nullptr;
|
||||||
|
HGVersion_CreateMgr(&mgr);
|
||||||
|
if (nullptr != mgr)
|
||||||
|
{
|
||||||
|
HGVersion_PostUninstallInfo(mgr, appName.c_str(), desc.c_str());
|
||||||
|
HGVersion_DestroyMgr(mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ("upgrade" == type && !appName.empty() && !pkgPath.empty())
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
while (AppIsRun())
|
while (AppIsRun(appName))
|
||||||
QThread::msleep(20);
|
QThread::msleep(20);
|
||||||
|
|
||||||
MainWindow w(pkgPath);
|
MainWindow w(pkgPath);
|
||||||
|
@ -47,10 +60,9 @@ int main(int argc, char *argv[])
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
|
|
||||||
if (!AppIsRun())
|
if (!AppIsRun(appName))
|
||||||
RunApp();
|
RunApp(appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_global_cleanup();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,27 +24,24 @@ TARGET = HuaGoScanUpgrade
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||||
DEFINES += CURL_STATICLIB
|
LIBS += -ladvapi32
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/windows/include
|
|
||||||
LIBS += -lIphlpapi -lwldap32 -lws2_32
|
|
||||||
|
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
LIBS += -L../../../../sdk/lib/win/x86/Release -lHGBase -lHGVersion
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
LIBS += -L../../../third_party/libcurl/windows/lib/x86 -llibcurl
|
|
||||||
DESTDIR = ../../../../release/win/x86/Release/
|
DESTDIR = ../../../../release/win/x86/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
LIBS += -L../../../third_party/libcurl/windows/lib/x86 -llibcurld
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
LIBS += -L../../../../sdk/lib/win/x64/Release -lHGBase -lHGVersion
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
LIBS += -L../../../third_party/libcurl/windows/lib/x64 -llibcurl
|
|
||||||
DESTDIR = ../../../../release/win/x64/Release/
|
DESTDIR = ../../../../release/win/x64/Release/
|
||||||
}
|
}
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
LIBS += -L../../../third_party/libcurl/windows/lib/x64 -llibcurld
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,19 +52,11 @@ unix {
|
||||||
ARCH = $$system(arch)
|
ARCH = $$system(arch)
|
||||||
message($$ARCH)
|
message($$ARCH)
|
||||||
|
|
||||||
LIBS += -ldl -lpthread
|
|
||||||
|
|
||||||
contains(DISTRIBUTION, UnionTech){
|
contains(DISTRIBUTION, UnionTech){
|
||||||
message('UOS')
|
message('UOS')
|
||||||
DEFINES += UOS
|
DEFINES += UOS
|
||||||
contains(ARCH, x86_64){
|
contains(ARCH, x86_64){
|
||||||
|
LIBS += -L../../../../release/uos/x86_64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/uos/amd64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/uos/amd64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/uos/amd64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/uos/amd64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/uos/amd64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/uos/x86_64/
|
DESTDIR = ../../../../release/uos/x86_64/
|
||||||
}
|
}
|
||||||
|
@ -76,13 +65,7 @@ unix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(ARCH, aarch64){
|
contains(ARCH, aarch64){
|
||||||
|
LIBS += -L../../../../release/uos/aarch64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/uos/aarch64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/uos/aarch64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/uos/aarch64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/uos/aarch64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/uos/aarch64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/uos/aarch64/
|
DESTDIR = ../../../../release/uos/aarch64/
|
||||||
}
|
}
|
||||||
|
@ -91,13 +74,7 @@ unix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(ARCH, mips64){
|
contains(ARCH, mips64){
|
||||||
|
LIBS += -L../../../../release/uos/mips64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/uos/mips64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/uos/mips64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/uos/mips64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/uos/mips64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/uos/mips64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/uos/mips64/
|
DESTDIR = ../../../../release/uos/mips64/
|
||||||
}
|
}
|
||||||
|
@ -109,13 +86,7 @@ unix {
|
||||||
message('KYLIN')
|
message('KYLIN')
|
||||||
DEFINES += KYLIN
|
DEFINES += KYLIN
|
||||||
contains(ARCH, x86_64){
|
contains(ARCH, x86_64){
|
||||||
|
LIBS += -L../../../../release/kylin/x86_64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/kylin/amd64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/kylin/amd64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/kylin/amd64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/kylin/amd64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/kylin/amd64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/kylin/x86_64/
|
DESTDIR = ../../../../release/kylin/x86_64/
|
||||||
}
|
}
|
||||||
|
@ -124,13 +95,7 @@ unix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(ARCH, aarch64){
|
contains(ARCH, aarch64){
|
||||||
|
LIBS += -L../../../../release/kylin/aarch64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/kylin/aarch64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/kylin/aarch64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/kylin/aarch64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/kylin/aarch64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/kylin/aarch64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/kylin/aarch64/
|
DESTDIR = ../../../../release/kylin/aarch64/
|
||||||
}
|
}
|
||||||
|
@ -139,13 +104,7 @@ unix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contains(ARCH, mips64){
|
contains(ARCH, mips64){
|
||||||
|
LIBS += -L../../../../release/kylin/mips64 -lHGBase -lHGVersion
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/kylin/mips64/include
|
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libuuid/kylin/mips64/include
|
|
||||||
LIBS += -L../../../third_party/libcurl/kylin/mips64/lib -lcurl
|
|
||||||
LIBS += -L../../../third_party/zlib/kylin/mips64/lib -lz
|
|
||||||
LIBS += -L../../../third_party/libuuid/kylin/mips64/lib -luuid
|
|
||||||
|
|
||||||
CONFIG(release, debug|release) {
|
CONFIG(release, debug|release) {
|
||||||
DESTDIR = ../../../../release/kylin/mips64/
|
DESTDIR = ../../../../release/kylin/mips64/
|
||||||
}
|
}
|
||||||
|
@ -157,27 +116,16 @@ unix {
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../../../app/upgrade/
|
INCLUDEPATH += $$PWD/../../../app/upgrade/
|
||||||
INCLUDEPATH += $$PWD/../../../utility/
|
|
||||||
INCLUDEPATH += $$PWD/../../../modules/
|
INCLUDEPATH += $$PWD/../../../modules/
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
../../../app/upgrade/HGUpgrade.cpp \
|
../../../app/upgrade/HGUpgrade.cpp \
|
||||||
../../../app/upgrade/main.cpp \
|
../../../app/upgrade/main.cpp \
|
||||||
../../../app/upgrade/mainwindow.cpp \
|
../../../app/upgrade/mainwindow.cpp \
|
||||||
../../../modules/base/HGIni.cpp \
|
|
||||||
../../../modules/base/HGMd5.cpp \
|
|
||||||
../../../modules/base/HGUtility.cpp \
|
|
||||||
../../../modules/base/HGThread.cpp \
|
|
||||||
../../../utility/HGString.cpp \
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../../../app/upgrade/HGUpgrade.h \
|
../../../app/upgrade/HGUpgrade.h \
|
||||||
../../../app/upgrade/mainwindow.h \
|
../../../app/upgrade/mainwindow.h \
|
||||||
../../../modules/base/HGIni.h \
|
|
||||||
../../../modules/base/HGMd5.h \
|
|
||||||
../../../modules/base/HGUtility.h \
|
|
||||||
../../../modules/base/HGThread.h \
|
|
||||||
../../../utility/HGString.h \
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
../../../app/upgrade/mainwindow.ui
|
../../../app/upgrade/mainwindow.ui
|
||||||
|
|
Loading…
Reference in New Issue