This commit is contained in:
DavidXanatos 2022-12-16 15:26:23 +01:00
parent 158a11b8c7
commit 99e1b86d21
2 changed files with 20 additions and 7 deletions

View File

@ -46,6 +46,11 @@ COnlineUpdater::COnlineUpdater(QObject *parent) : QObject(parent)
m_CheckMode = eInit; m_CheckMode = eInit;
int iUpdate = 0;
QString UpdateStr = ParseVersionStr(theConf->GetString("Updater/PendingUpdate"), &iUpdate);
if (!IsVersionNewer(UpdateStr) && (UpdateStr != GetCurrentVersion() || iUpdate <= GetCurrentUpdate()))
theConf->SetValue("Updater/PendingUpdate", ""); // seams update has been applied
bool bIsInstallerReady = false; bool bIsInstallerReady = false;
QString FilePath = theConf->GetString("Updater/InstallerPath"); QString FilePath = theConf->GetString("Updater/InstallerPath");
if (!FilePath.isEmpty() && QFile::exists(FilePath)) { if (!FilePath.isEmpty() && QFile::exists(FilePath)) {
@ -255,7 +260,6 @@ void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Pa
m_UpdateData = Data; m_UpdateData = Data;
bool PendingUpdate = HandleUpdate(); bool PendingUpdate = HandleUpdate();
theConf->SetValue("Updater/PendingUpdate", PendingUpdate);
theGUI->UpdateLabel(); theGUI->UpdateLabel();
if (PendingUpdate) { if (PendingUpdate) {
@ -275,11 +279,14 @@ void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Pa
bool COnlineUpdater::HandleUpdate() bool COnlineUpdater::HandleUpdate()
{ {
QString PendingUpdate;
bool bNewRelease = false; bool bNewRelease = false;
QVariantMap Release = m_UpdateData["release"].toMap(); QVariantMap Release = m_UpdateData["release"].toMap();
QString ReleaseStr = Release["version"].toString(); QString ReleaseStr = Release["version"].toString();
if (IsVersionNewer(ReleaseStr)) { if (IsVersionNewer(ReleaseStr)) {
if (m_CheckMode == eManual || !m_IgnoredUpdates.contains(ReleaseStr)) { if (m_CheckMode == eManual || !m_IgnoredUpdates.contains(ReleaseStr)) {
PendingUpdate = ReleaseStr;
bNewRelease = true; bNewRelease = true;
} }
} }
@ -296,6 +303,8 @@ bool COnlineUpdater::HandleUpdate()
theConf->SetValue("Updater/CurrentUpdate", MakeVersionStr(Update)); // cache result theConf->SetValue("Updater/CurrentUpdate", MakeVersionStr(Update)); // cache result
else else
{ {
if(PendingUpdate.isEmpty())
PendingUpdate = UpdateStr;
if (m_CheckMode == eManual || !m_IgnoredUpdates.contains(UpdateStr)) { if (m_CheckMode == eManual || !m_IgnoredUpdates.contains(UpdateStr)) {
bNewUpdate = true; bNewUpdate = true;
} }
@ -303,6 +312,8 @@ bool COnlineUpdater::HandleUpdate()
} }
} }
theConf->SetValue("Updater/PendingUpdate", PendingUpdate);
// //
// special case: updates allowed be to installed, but releases only allowed to be download // special case: updates allowed be to installed, but releases only allowed to be download
// solution: apply updates silently, then prompt to install new release, else prioritize installing new releases over updating the existing one // solution: apply updates silently, then prompt to install new release, else prioritize installing new releases over updating the existing one

View File

@ -185,6 +185,10 @@ CSandMan::CSandMan(QWidget *parent)
m_bConnectPending = false; m_bConnectPending = false;
m_bStopPending = false; m_bStopPending = false;
m_pUpdater = new COnlineUpdater(this);
m_pMainWidget = new QWidget(this); m_pMainWidget = new QWidget(this);
m_pMenuBar = menuBar(); m_pMenuBar = menuBar();
@ -246,8 +250,6 @@ CSandMan::CSandMan(QWidget *parent)
m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); m_pPopUpWindow->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pProgressDialog->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); m_pProgressDialog->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pUpdater = new COnlineUpdater(this);
//connect(theAPI, SIGNAL(LogMessage(const QString&, bool)), this, SLOT(OnLogMessage(const QString&, bool))); //connect(theAPI, SIGNAL(LogMessage(const QString&, bool)), this, SLOT(OnLogMessage(const QString&, bool)));
connect(theAPI, SIGNAL(LogSbieMessage(quint32, const QStringList&, quint32)), this, SLOT(OnLogSbieMessage(quint32, const QStringList&, quint32))); connect(theAPI, SIGNAL(LogSbieMessage(quint32, const QStringList&, quint32)), this, SLOT(OnLogSbieMessage(quint32, const QStringList&, quint32)));
connect(theAPI, SIGNAL(NotAuthorized(bool, bool&)), this, SLOT(OnNotAuthorized(bool, bool&)), Qt::DirectConnection); connect(theAPI, SIGNAL(NotAuthorized(bool, bool&)), this, SLOT(OnNotAuthorized(bool, bool&)), Qt::DirectConnection);
@ -777,19 +779,19 @@ void CSandMan::UpdateLabel()
QString LabelText; QString LabelText;
QString LabelTip; QString LabelTip;
if (theConf->GetBool("Updater/PendingUpdate")) if (!theConf->GetString("Updater/PendingUpdate").isEmpty())
{ {
QString FilePath = theConf->GetString("Updater/InstallerPath"); QString FilePath = theConf->GetString("Updater/InstallerPath");
if (!FilePath.isEmpty() && QFile::exists(FilePath)) { if (!FilePath.isEmpty() && QFile::exists(FilePath)) {
LabelText = tr("<a href=\"sbie://update/installer\" style=\"color: red;\">There is a new Sandboxie-Plus release ready</a>"); LabelText = tr("<a href=\"sbie://update/installer\" style=\"color: red;\">There is a new Sandboxie-Plus release %1 ready</a>").arg(theConf->GetString("Updater/InstallerVersion"));
LabelTip = tr("Click to run installer"); LabelTip = tr("Click to run installer");
} }
else if (!theConf->GetString("Updater/UpdateVersion").isEmpty()){ else if (!theConf->GetString("Updater/UpdateVersion").isEmpty()){
LabelText = tr("<a href=\"sbie://update/apply\" style=\"color: red;\">There is a new Sandboxie-Plus update ready</a>"); LabelText = tr("<a href=\"sbie://update/apply\" style=\"color: red;\">There is a new Sandboxie-Plus update %1 ready</a>").arg(theConf->GetString("Updater/UpdateVersion"));
LabelTip = tr("Click to apply update"); LabelTip = tr("Click to apply update");
} }
else { else {
LabelText = tr("<a href=\"sbie://update/check\" style=\"color: red;\">There is a new build of Sandboxie-Plus available</a>"); LabelText = tr("<a href=\"sbie://update/check\" style=\"color: red;\">There is a new Sandboxie-Plus update v%1 available</a>").arg(theConf->GetString("Updater/PendingUpdate"));
LabelTip = tr("Click to download update"); LabelTip = tr("Click to download update");
} }