复制临时文件和校验版本md5修改为在mainwindow执行
This commit is contained in:
parent
8ee1671dae
commit
d37f9632ab
|
@ -56,17 +56,12 @@ void Dialog_updateProgress::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
Dialog_updateProgress *p = (Dialog_updateProgress *)param;
|
Dialog_updateProgress *p = (Dialog_updateProgress *)param;
|
||||||
|
|
||||||
HGResult ret = p->m_versionDll->HttpDownload(p->m_url.toStdString().c_str(), p->m_savePath.toStdString().c_str(), HttpDownloadThreadFunc, p);
|
HGResult ret = p->m_versionDll->HttpDownload(p->m_url.toStdString().c_str(), p->m_savePath.toStdString().c_str(), HttpDownloadThreadFunc, p);
|
||||||
if (HGBASE_ERR_OK == ret)
|
if (HGBASE_ERR_OK != ret)
|
||||||
{
|
|
||||||
emit p->finish();
|
|
||||||
emit p->upgrade(p->m_savePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
QFile::remove(p->m_savePath.toStdString().c_str());
|
QFile::remove(p->m_savePath.toStdString().c_str());
|
||||||
emit p->finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit p->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_updateProgress::on_updateProgress(int value)
|
void Dialog_updateProgress::on_updateProgress(int value)
|
||||||
|
@ -76,7 +71,7 @@ void Dialog_updateProgress::on_updateProgress(int value)
|
||||||
|
|
||||||
void Dialog_updateProgress::on_finish()
|
void Dialog_updateProgress::on_finish()
|
||||||
{
|
{
|
||||||
close();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_updateProgress::on_pushButton_clicked()
|
void Dialog_updateProgress::on_pushButton_clicked()
|
||||||
|
|
|
@ -25,7 +25,6 @@ private:
|
||||||
signals:
|
signals:
|
||||||
void updateProgress(int value);
|
void updateProgress(int value);
|
||||||
void finish();
|
void finish();
|
||||||
void upgrade(QString pkgPath);
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_updateProgress(int value);
|
void on_updateProgress(int value);
|
||||||
void on_finish();
|
void on_finish();
|
||||||
|
|
|
@ -28,16 +28,13 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *vers
|
||||||
{
|
{
|
||||||
QListWidgetItem *listwidgetItem = new QListWidgetItem;
|
QListWidgetItem *listwidgetItem = new QListWidgetItem;
|
||||||
listwidgetItem->setText(QString(m_versionInfo[i].version));
|
listwidgetItem->setText(QString(m_versionInfo[i].version));
|
||||||
listwidgetItem->setData(Qt::UserRole, m_versionInfo[i].url);
|
|
||||||
listwidgetItem->setData(Qt::UserRole+1, m_versionInfo[i].md5);
|
|
||||||
listwidgetItem->setToolTip(tr("upgrade contents: ") + m_versionInfo[i].desc + tr(" bug description: ") + m_versionInfo[i].bugInfo);
|
listwidgetItem->setToolTip(tr("upgrade contents: ") + m_versionInfo[i].desc + tr(" bug description: ") + m_versionInfo[i].bugInfo);
|
||||||
ui->listWidget->addItem(listwidgetItem);
|
ui->listWidget->addItem(listwidgetItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ui->listWidget->count() > 0)
|
if(ui->listWidget->count() > 0)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listWidget->item(0);
|
ui->listWidget->setCurrentRow(0);
|
||||||
item->setSelected(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HGChar currVersion[64] = {0};
|
HGChar currVersion[64] = {0};
|
||||||
|
@ -49,7 +46,6 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *vers
|
||||||
{
|
{
|
||||||
ui->label_detectResult->setText(tr("The current version is the latest! The current version number is : ") + currVersion);
|
ui->label_detectResult->setText(tr("The current version is the latest! The current version number is : ") + currVersion);
|
||||||
ui->pbtn_upgrade->setVisible(false);
|
ui->pbtn_upgrade->setVisible(false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -59,7 +55,6 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *vers
|
||||||
tr(" ,the current version is : ") + currVersion);
|
tr(" ,the current version is : ") + currVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(on_listWidget_itemDoubleClicked(QListWidgetItem*)), Qt::QueuedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog_upgrade::~Dialog_upgrade()
|
Dialog_upgrade::~Dialog_upgrade()
|
||||||
|
@ -67,11 +62,15 @@ Dialog_upgrade::~Dialog_upgrade()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Dialog_upgrade::getVersionNum()
|
||||||
|
{
|
||||||
|
return m_versionNum;
|
||||||
|
}
|
||||||
|
|
||||||
void Dialog_upgrade::on_pbtn_install_clicked()
|
void Dialog_upgrade::on_pbtn_install_clicked()
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listWidget->currentItem();
|
QListWidgetItem *item = ui->listWidget->currentItem();
|
||||||
on_listWidget_itemDoubleClicked(item);
|
on_listWidget_itemDoubleClicked(item);
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_upgrade::on_pbtn_cancel_clicked()
|
void Dialog_upgrade::on_pbtn_cancel_clicked()
|
||||||
|
@ -81,8 +80,6 @@ void Dialog_upgrade::on_pbtn_cancel_clicked()
|
||||||
|
|
||||||
void Dialog_upgrade::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
|
void Dialog_upgrade::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
close();
|
|
||||||
|
|
||||||
HGChar currVersion[64] = {0};
|
HGChar currVersion[64] = {0};
|
||||||
m_versionDll->GetCurrVersion(HGVERSION_APPNAME_SCANNER, currVersion, 64);
|
m_versionDll->GetCurrVersion(HGVERSION_APPNAME_SCANNER, currVersion, 64);
|
||||||
|
|
||||||
|
@ -94,86 +91,10 @@ void Dialog_upgrade::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
|
||||||
QMessageBox::information(this, tr("tip"), tr("Already in current version"));
|
QMessageBox::information(this, tr("tip"), tr("Already in current version"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
QString url = item->data(Qt::UserRole).toString();
|
|
||||||
QString versionNum = item->text();
|
|
||||||
QString md5 = item->data(Qt::UserRole+1).toString();
|
|
||||||
|
|
||||||
HGChar savePath[512];
|
m_versionNum = item->text();
|
||||||
HGBase_GetConfigPath(savePath, 512);
|
|
||||||
HGBase_CreateDir(savePath);
|
|
||||||
strcat(savePath, (versionNum + QString("%1").arg(".exe")).toLatin1().data());
|
|
||||||
|
|
||||||
QFile saveFile(savePath);
|
accept();
|
||||||
saveFile.open(QFile::ReadOnly);
|
|
||||||
QByteArray fileMsg = saveFile.readAll();
|
|
||||||
saveFile.close();
|
|
||||||
QString md5_2 = QCryptographicHash::hash(fileMsg , QCryptographicHash::Md5).toHex();
|
|
||||||
|
|
||||||
QFile f(savePath);
|
|
||||||
if(!f.exists() || md5 != md5_2)
|
|
||||||
{
|
|
||||||
Dialog_updateProgress dlg(m_versionDll, url, savePath);
|
|
||||||
connect(&dlg, SIGNAL(upgrade(QString)), this, SLOT(on_upgrade(QString)), Qt::QueuedConnection);
|
|
||||||
dlg.exec();
|
|
||||||
disconnect(&dlg, SIGNAL(upgrade(QString)), this, SLOT(on_upgrade(QString)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
on_upgrade(savePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_upgrade::on_upgrade(QString pkgPath)
|
|
||||||
{
|
|
||||||
QString curPath = QDir::currentPath();
|
|
||||||
QString tmpPath = QDir::tempPath();
|
|
||||||
QFile file(curPath);
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
file.copy("HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
|
|
||||||
file.copy("HwBase.dll", tmpPath + "/HwBase.dll");
|
|
||||||
file.copy("HwVersion.dll", tmpPath + "/HwVersion.dll");
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
file.copy("LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
|
|
||||||
file.copy("LscBase.dll", tmpPath + "/LscBase.dll");
|
|
||||||
file.copy("LscVersion.dll", tmpPath + "/LscVersion.dll");
|
|
||||||
#else
|
|
||||||
file.copy("HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
|
|
||||||
file.copy("HGBase.dll", tmpPath + "/HGBase.dll");
|
|
||||||
file.copy("HGVersion.dll", tmpPath + "/HGVersion.dll");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
file.copy("msvcp140.dll", tmpPath + "/msvcp140.dll");
|
|
||||||
file.copy("Qt5Core.dll", tmpPath + "/Qt5Core.dll");
|
|
||||||
file.copy("Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
|
|
||||||
file.copy("Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
|
|
||||||
file.copy("vcruntime140.dll", tmpPath + "/vcruntime140.dll");
|
|
||||||
QDir dir;
|
|
||||||
dir.mkdir(tmpPath + "/platforms");
|
|
||||||
file.copy("platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
|
|
||||||
dir.mkdir(tmpPath + "/imageformats");
|
|
||||||
file.copy("imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
|
|
||||||
#else
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
file.copy("HwUpgradeApp", tmpPath + "/HwUpgradeApp");
|
|
||||||
file.copy("libHwBase.so", tmpPath + "/libHwBase.so");
|
|
||||||
file.copy("libHwVersion.so", tmpPath + "/libHwVersion.so");
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
file.copy("LscUpgradeApp", tmpPath + "/LscUpgradeApp");
|
|
||||||
file.copy("libLscBase.so", tmpPath + "/libLscBase.so");
|
|
||||||
file.copy("libLscVersion.so", tmpPath + "/libLscVersion.so");
|
|
||||||
#else
|
|
||||||
file.copy("HGUpgradeApp", tmpPath + "/HGUpgradeApp");
|
|
||||||
file.copy("libHGBase.so", tmpPath + "/libHGBase.so");
|
|
||||||
file.copy("libHGVersion.so", tmpPath + "/libHGVersion.so");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
emit upgradeApp(pkgPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog_upgrade::on_pbtn_selectVersion_clicked()
|
void Dialog_upgrade::on_pbtn_selectVersion_clicked()
|
||||||
|
@ -196,5 +117,4 @@ void Dialog_upgrade::on_pbtn_upgrade_clicked()
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listWidget->item(0);
|
QListWidgetItem *item = ui->listWidget->item(0);
|
||||||
on_listWidget_itemDoubleClicked(item);
|
on_listWidget_itemDoubleClicked(item);
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,27 +17,26 @@ public:
|
||||||
explicit Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, HGUInt versionCount, QWidget *parent = nullptr);
|
explicit Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, HGUInt versionCount, QWidget *parent = nullptr);
|
||||||
~Dialog_upgrade();
|
~Dialog_upgrade();
|
||||||
|
|
||||||
|
QString getVersionNum();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pbtn_install_clicked();
|
void on_pbtn_install_clicked();
|
||||||
|
|
||||||
void on_pbtn_cancel_clicked();
|
void on_pbtn_cancel_clicked();
|
||||||
|
|
||||||
void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
|
void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
|
||||||
void on_upgrade(QString pkgPath);
|
|
||||||
|
|
||||||
void on_pbtn_selectVersion_clicked();
|
void on_pbtn_selectVersion_clicked();
|
||||||
|
|
||||||
void on_pbtn_upgrade_clicked();
|
void on_pbtn_upgrade_clicked();
|
||||||
|
|
||||||
signals:
|
|
||||||
void upgradeApp(QString pkgPath);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Dialog_upgrade *ui;
|
Ui::Dialog_upgrade *ui;
|
||||||
|
|
||||||
VersionDll *m_versionDll;
|
VersionDll *m_versionDll;
|
||||||
HGVersionInfo *m_versionInfo;
|
HGVersionInfo *m_versionInfo;
|
||||||
HGUInt m_versionCount;
|
HGUInt m_versionCount;
|
||||||
|
QString m_versionNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOG_UPGRADE_H
|
#endif // DIALOG_UPGRADE_H
|
||||||
|
|
|
@ -1099,6 +1099,53 @@ void MainWindow::on_statusInfoDblClick()
|
||||||
|
|
||||||
void MainWindow::on_upgradeApp(QString pkgPath)
|
void MainWindow::on_upgradeApp(QString pkgPath)
|
||||||
{
|
{
|
||||||
|
QString curPath = QDir::currentPath();
|
||||||
|
QString tmpPath = QDir::tempPath();
|
||||||
|
QFile file(curPath);
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
#if defined(OEM_HANWANG)
|
||||||
|
file.copy("HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
|
||||||
|
file.copy("HwBase.dll", tmpPath + "/HwBase.dll");
|
||||||
|
file.copy("HwVersion.dll", tmpPath + "/HwVersion.dll");
|
||||||
|
#elif defined(OEM_LISICHENG)
|
||||||
|
file.copy("LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
|
||||||
|
file.copy("LscBase.dll", tmpPath + "/LscBase.dll");
|
||||||
|
file.copy("LscVersion.dll", tmpPath + "/LscVersion.dll");
|
||||||
|
#else
|
||||||
|
file.copy("HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
|
||||||
|
file.copy("HGBase.dll", tmpPath + "/HGBase.dll");
|
||||||
|
file.copy("HGVersion.dll", tmpPath + "/HGVersion.dll");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
file.copy("msvcp140.dll", tmpPath + "/msvcp140.dll");
|
||||||
|
file.copy("Qt5Core.dll", tmpPath + "/Qt5Core.dll");
|
||||||
|
file.copy("Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
|
||||||
|
file.copy("Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
|
||||||
|
file.copy("vcruntime140.dll", tmpPath + "/vcruntime140.dll");
|
||||||
|
QDir dir;
|
||||||
|
dir.mkdir(tmpPath + "/platforms");
|
||||||
|
file.copy("platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
|
||||||
|
dir.mkdir(tmpPath + "/imageformats");
|
||||||
|
file.copy("imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
|
||||||
|
#else
|
||||||
|
#if defined(OEM_HANWANG)
|
||||||
|
file.copy("HwUpgradeApp", tmpPath + "/HwUpgradeApp");
|
||||||
|
file.copy("libHwBase.so", tmpPath + "/libHwBase.so");
|
||||||
|
file.copy("libHwVersion.so", tmpPath + "/libHwVersion.so");
|
||||||
|
#elif defined(OEM_LISICHENG)
|
||||||
|
file.copy("LscUpgradeApp", tmpPath + "/LscUpgradeApp");
|
||||||
|
file.copy("libLscBase.so", tmpPath + "/libLscBase.so");
|
||||||
|
file.copy("libLscVersion.so", tmpPath + "/libLscVersion.so");
|
||||||
|
#else
|
||||||
|
file.copy("HGUpgradeApp", tmpPath + "/HGUpgradeApp");
|
||||||
|
file.copy("libHGBase.so", tmpPath + "/libHGBase.so");
|
||||||
|
file.copy("libHGVersion.so", tmpPath + "/libHGVersion.so");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
|
|
||||||
QStringList argList;
|
QStringList argList;
|
||||||
|
@ -1106,8 +1153,6 @@ void MainWindow::on_upgradeApp(QString pkgPath)
|
||||||
argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str()));
|
argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str()));
|
||||||
argList.push_back(QString("-type=%1").arg("upgrade"));
|
argList.push_back(QString("-type=%1").arg("upgrade"));
|
||||||
|
|
||||||
QString tmpPath = QDir::tempPath();
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
#if defined(HG_CMP_MSC)
|
||||||
#if defined(OEM_HANWANG)
|
#if defined(OEM_HANWANG)
|
||||||
proc.startDetached(tmpPath + "/HwUpgradeApp.exe", argList);
|
proc.startDetached(tmpPath + "/HwUpgradeApp.exe", argList);
|
||||||
|
@ -3172,14 +3217,61 @@ void MainWindow::on_actionact_update_triggered()
|
||||||
if(versionCount > 0)
|
if(versionCount > 0)
|
||||||
{
|
{
|
||||||
Dialog_upgrade dlg(m_versionDll, versionInfo, versionCount, this);
|
Dialog_upgrade dlg(m_versionDll, versionInfo, versionCount, this);
|
||||||
connect(&dlg, SIGNAL(upgradeApp(QString)), this, SLOT(on_upgradeApp(QString)), Qt::QueuedConnection);
|
if (dlg.exec())
|
||||||
dlg.exec();
|
{
|
||||||
disconnect(&dlg, SIGNAL(upgradeApp(QString)), this, SLOT(on_upgradeApp(QString)));
|
QString url, md5;
|
||||||
|
|
||||||
|
QString versionNum = dlg.getVersionNum();
|
||||||
|
for (HGUInt i = 0; i < versionCount; ++i)
|
||||||
|
{
|
||||||
|
if (versionNum == versionInfo[i].version)
|
||||||
|
{
|
||||||
|
url = versionInfo[i].url;
|
||||||
|
md5 = versionInfo[i].md5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!url.isEmpty() && !md5.isEmpty());
|
||||||
|
|
||||||
|
HGChar savePath[512];
|
||||||
|
HGBase_GetConfigPath(savePath, 512);
|
||||||
|
HGBase_CreateDir(savePath);
|
||||||
|
strcat(savePath, (versionNum + QString("%1").arg(".exe")).toLatin1().data());
|
||||||
|
|
||||||
|
QFile saveFile(savePath);
|
||||||
|
saveFile.open(QFile::ReadOnly);
|
||||||
|
QByteArray fileMsg = saveFile.readAll();
|
||||||
|
saveFile.close();
|
||||||
|
QString md5_2 = QCryptographicHash::hash(fileMsg , QCryptographicHash::Md5).toHex();
|
||||||
|
|
||||||
|
QFile f(savePath);
|
||||||
|
if(!f.exists() || md5 != md5_2)
|
||||||
|
{
|
||||||
|
Dialog_updateProgress dlg(m_versionDll, url, savePath, this);
|
||||||
|
if (dlg.exec())
|
||||||
|
{
|
||||||
|
QFile saveFile(savePath);
|
||||||
|
saveFile.open(QFile::ReadOnly);
|
||||||
|
QByteArray fileMsg = saveFile.readAll();
|
||||||
|
saveFile.close();
|
||||||
|
QString md5_2 = QCryptographicHash::hash(fileMsg , QCryptographicHash::Md5).toHex();
|
||||||
|
|
||||||
|
if (md5 == md5_2)
|
||||||
|
{
|
||||||
|
on_upgradeApp(savePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
on_upgradeApp(savePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("error"), tr("get versionlist failed"));
|
QMessageBox::critical(this, tr("error"), tr("get versionlist failed"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
m_versionDll->ReleaseVersionList(versionInfo, versionCount);
|
m_versionDll->ReleaseVersionList(versionInfo, versionCount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue