去掉HGUpgrade工程的OEM宏
This commit is contained in:
parent
7475ef902b
commit
29522a0395
|
@ -4062,6 +4062,7 @@ void MainWindow::upgradeApp(QString pkgPath)
|
|||
|
||||
QStringList argList;
|
||||
argList.push_back(QString("-appName=%1").arg(HGVERSION_APPNAME_SCANNER));
|
||||
argList.push_back(QString("-oemName=%1").arg(m_oemName));
|
||||
argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str()));
|
||||
argList.push_back(QString("-type=%1").arg("upgrade"));
|
||||
argList.push_back(QString("-language=%1").arg(m_currLang.toStdString().c_str()));
|
||||
|
|
|
@ -8,27 +8,27 @@
|
|||
#include <psapi.h>
|
||||
#endif
|
||||
|
||||
bool AppIsRun(const std::string& appName)
|
||||
bool AppIsRun(const HGChar *appName, const HGChar* oemName)
|
||||
{
|
||||
if (appName == HGVERSION_APPNAME_SCANNER)
|
||||
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
|
||||
std::wstring appPath;
|
||||
std::wstring regName;
|
||||
|
||||
#if defined(OEM_HANWANG)
|
||||
std::wstring regName = L"SOFTWARE\\HanvonScan";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
std::wstring regName = L"SOFTWARE\\LanxumScan";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
std::wstring regName = L"SOFTWARE\\CumtennScan";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
std::wstring regName = L"SOFTWARE\\MicrotekScan";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
std::wstring regName = L"SOFTWARE\\UniScan";
|
||||
#else
|
||||
std::wstring regName = L"SOFTWARE\\HuaGoScan";
|
||||
#endif
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
regName = L"SOFTWARE\\HanvonScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
regName = L"SOFTWARE\\LanxumScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
regName = L"SOFTWARE\\CumtennScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
regName = L"SOFTWARE\\MicrotekScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
regName = L"SOFTWARE\\UniScan";
|
||||
else
|
||||
regName = L"SOFTWARE\\HuaGoScan";
|
||||
|
||||
HKEY hKey = nullptr;
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
||||
|
@ -99,47 +99,69 @@ bool AppIsRun(const std::string& appName)
|
|||
printf("osName=%s\n", osName.c_str());
|
||||
if (osName.find("UnionTech") != std::string::npos)
|
||||
{
|
||||
#if defined(OEM_HANWANG)
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
{
|
||||
cmd = "ps -wef | grep HanvonScan";
|
||||
appPath = "/opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
{
|
||||
cmd = "ps -wef | grep LanxumScan";
|
||||
appPath = "/opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
{
|
||||
cmd = "ps -wef | grep CumtennScan";
|
||||
appPath = "/opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
{
|
||||
cmd = "ps -wef | grep MicrotekScan";
|
||||
appPath = "/opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
{
|
||||
cmd = "ps -wef | grep UniScan";
|
||||
appPath = "/opt/apps/com.unischina.uniscan/files/bin/UniScan";
|
||||
#else
|
||||
cmd = "ps -wef | grep HuaGoScan";
|
||||
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(OEM_HANWANG)
|
||||
cmd = "ps -wef | grep HuaGoScan";
|
||||
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
{
|
||||
cmd = "ps -wef | grep HanvonScan";
|
||||
appPath = "/opt/apps/scanner-driver-hanvon/bin/HanvonScan";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
{
|
||||
cmd = "ps -wef | grep LanxumScan";
|
||||
appPath = "/opt/apps/scanner-driver-lanxum/bin/LanxumScan";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
{
|
||||
cmd = "ps -wef | grep CumtennScan";
|
||||
appPath = "/opt/apps/scanner-driver-cumtenn/bin/CumtennScan";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
{
|
||||
cmd = "ps -wef | grep MicrotekScan";
|
||||
appPath = "/opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
}
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
{
|
||||
cmd = "ps -wef | grep UniScan";
|
||||
appPath = "/opt/apps/scanner-driver-unis/bin/UniScan";
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = "ps -wef | grep HuaGoScan";
|
||||
appPath = "/opt/apps/scanner-driver-huagao/bin/HuaGoScan";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
@ -167,27 +189,27 @@ bool AppIsRun(const std::string& appName)
|
|||
return false;
|
||||
}
|
||||
|
||||
void RunApp(const std::string& appName)
|
||||
void RunApp(const HGChar *appName, const HGChar* oemName)
|
||||
{
|
||||
if (appName == HGVERSION_APPNAME_SCANNER)
|
||||
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
|
||||
std::wstring appPath;
|
||||
std::wstring regName;
|
||||
|
||||
#if defined(OEM_HANWANG)
|
||||
std::wstring regName = L"SOFTWARE\\HanvonScan";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
std::wstring regName = L"SOFTWARE\\LanxumScan";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
std::wstring regName = L"SOFTWARE\\CumtennScan";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
std::wstring regName = L"SOFTWARE\\MicrotekScan";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
std::wstring regName = L"SOFTWARE\\UniScan";
|
||||
#else
|
||||
std::wstring regName = L"SOFTWARE\\HuaGoScan";
|
||||
#endif
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
regName = L"SOFTWARE\\HanvonScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
regName = L"SOFTWARE\\LanxumScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
regName = L"SOFTWARE\\CumtennScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
regName = L"SOFTWARE\\MicrotekScan";
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
regName = L"SOFTWARE\\UniScan";
|
||||
else
|
||||
regName = L"SOFTWARE\\HuaGoScan";
|
||||
|
||||
HKEY hKey = nullptr;
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
||||
|
@ -224,35 +246,33 @@ void RunApp(const std::string& appName)
|
|||
printf("osName=%s\n", osName.c_str());
|
||||
if (osName.find("UnionTech") != std::string::npos)
|
||||
{
|
||||
#if defined(OEM_HANWANG)
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
appPath = "sh /opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan.sh &";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
appPath = "sh /opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan.sh &";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
appPath = "sh /opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan.sh &";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
appPath = "sh /opt/apps/com.unischina.uniscan/files/bin/UniScan.sh &";
|
||||
#else
|
||||
else
|
||||
appPath = "sh /opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan.sh &";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(OEM_HANWANG)
|
||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||
appPath = "sh /opt/apps/scanner-driver-hanvon/bin/HanvonScan.sh &";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||
appPath = "sh /opt/apps/scanner-driver-lanxum/bin/LanxumScan.sh &";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||
appPath = "sh /opt/apps/scanner-driver-cumtenn/bin/CumtennScan.sh &";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||
appPath = "sh /opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan.sh &";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||
appPath = "sh /opt/apps/scanner-driver-unis/bin/UniScan.sh &";
|
||||
#else
|
||||
else
|
||||
appPath = "sh /opt/apps/scanner-driver-huagao/bin/HuaGoScan.sh &";
|
||||
#endif
|
||||
}
|
||||
|
||||
system(appPath.c_str());
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#ifndef __HGUPGRADE_H__
|
||||
#define __HGUPGRADE_H__
|
||||
|
||||
#include "base/HGDef.h"
|
||||
#include <string>
|
||||
|
||||
// 判断app是否在运行
|
||||
bool AppIsRun(const std::string& appName);
|
||||
bool AppIsRun(const HGChar *appName, const HGChar* oemName);
|
||||
|
||||
// 运行app
|
||||
void RunApp(const std::string& appName);
|
||||
void RunApp(const HGChar *appName, const HGChar* oemName);
|
||||
|
||||
#endif /* __HGUPGRADE_H__ */
|
||||
|
|
|
@ -13,6 +13,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
std::string type;
|
||||
std::string appName;
|
||||
std::string oemName;
|
||||
std::string desc;
|
||||
std::string pkgPath;
|
||||
std::string appLang;
|
||||
|
@ -25,6 +26,8 @@ int main(int argc, char *argv[])
|
|||
type = z + strlen("-type=");
|
||||
else if (z == strstr(z, "-appName="))
|
||||
appName = z + strlen("-appName=");
|
||||
else if (z == strstr(z, "-oemName="))
|
||||
oemName = z + strlen("-oemName=");
|
||||
else if (z == strstr(z, "-desc="))
|
||||
desc = z + strlen("-desc=");
|
||||
else if (z == strstr(z, "-pkgpath="))
|
||||
|
@ -38,48 +41,32 @@ int main(int argc, char *argv[])
|
|||
appLang = "chinese";
|
||||
}
|
||||
|
||||
const HGChar *oemName = nullptr;
|
||||
|
||||
#if defined(OEM_HANWANG)
|
||||
oemName = HGVERSION_OEMNAME_HANVON;
|
||||
#elif defined(OEM_LISICHENG)
|
||||
oemName = HGVERSION_OEMNAME_LANXUM;
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
oemName = HGVERSION_OEMNAME_CUMTENN;
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
oemName = HGVERSION_OEMNAME_MICROTEK;
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
oemName = HGVERSION_OEMNAME_UNIS;
|
||||
#else
|
||||
oemName = HGVERSION_OEMNAME_HUAGO;
|
||||
#endif
|
||||
|
||||
if ("postinstallinfo" == type && !appName.empty())
|
||||
if ("postinstallinfo" == type && !appName.empty() && !oemName.empty())
|
||||
{
|
||||
HGVersionMgr mgr = nullptr;
|
||||
HGVersion_CreateMgr(&mgr);
|
||||
|
||||
if (nullptr != mgr)
|
||||
{
|
||||
HGVersion_PostInstallInfo(mgr, appName.c_str(), oemName, desc.c_str());
|
||||
HGVersion_PostInstallInfo(mgr, appName.c_str(), oemName.c_str(), desc.c_str());
|
||||
HGVersion_DestroyMgr(mgr);
|
||||
}
|
||||
}
|
||||
else if ("postuninstallinfo" == type && !appName.empty())
|
||||
else if ("postuninstallinfo" == type && !appName.empty() && !oemName.empty())
|
||||
{
|
||||
HGVersionMgr mgr = nullptr;
|
||||
HGVersion_CreateMgr(&mgr);
|
||||
if (nullptr != mgr)
|
||||
{
|
||||
HGVersion_PostUninstallInfo(mgr, appName.c_str(), oemName, desc.c_str());
|
||||
HGVersion_PostUninstallInfo(mgr, appName.c_str(), oemName.c_str(), desc.c_str());
|
||||
HGVersion_DestroyMgr(mgr);
|
||||
}
|
||||
}
|
||||
else if ("upgrade" == type && !appName.empty() && !pkgPath.empty())
|
||||
else if ("upgrade" == type && !appName.empty() && !oemName.empty() && !pkgPath.empty())
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
while (AppIsRun(appName))
|
||||
while (AppIsRun(appName.c_str(), oemName.c_str()))
|
||||
QThread::msleep(20);
|
||||
|
||||
QString translator_upgrade_name = ":translation/Upgrade_zh_CN.qm";
|
||||
|
@ -92,7 +79,7 @@ int main(int argc, char *argv[])
|
|||
if (translator_upgrade.load(translator_upgrade_name))
|
||||
a.installTranslator(&translator_upgrade);
|
||||
|
||||
MainWindow w(appName, pkgPath);
|
||||
MainWindow w(pkgPath);
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2);
|
||||
w.show();
|
||||
|
@ -105,8 +92,8 @@ int main(int argc, char *argv[])
|
|||
QMessageBox::Ok);
|
||||
msg.exec();
|
||||
|
||||
if (!AppIsRun(appName))
|
||||
RunApp(appName);
|
||||
if (!AppIsRun(appName.c_str(), oemName.c_str()))
|
||||
RunApp(appName.c_str(), oemName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
#include <tlhelp32.h>
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(const std::string &appName, const std::string& pkgPath, QWidget *parent)
|
||||
MainWindow::MainWindow(const std::string& pkgPath, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_appName(appName)
|
||||
, m_pkgPath(pkgPath)
|
||||
, m_thread(nullptr)
|
||||
, m_success(false)
|
||||
|
|
|
@ -13,7 +13,7 @@ class MainWindow : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(const std::string &appName, const std::string &pkgPath, QWidget *parent = nullptr);
|
||||
MainWindow(const std::string &pkgPath, QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
bool isInstallSuccess();
|
||||
|
@ -29,7 +29,6 @@ private:
|
|||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
std::string m_appName;
|
||||
std::string m_pkgPath;
|
||||
HGThread m_thread;
|
||||
bool m_success;
|
||||
|
|
Loading…
Reference in New Issue