1.3.2
This commit is contained in:
parent
41d31d5874
commit
2d500776dc
|
@ -83,7 +83,7 @@ void COnlineUpdater::GetUpdates(QObject* receiver, const char* member, const QVa
|
|||
m_JobQueue.insert(pReply, pJob);
|
||||
}
|
||||
|
||||
void COnlineUpdater::CheckForUpdates(bool bManual)
|
||||
void COnlineUpdater::CheckForUpdates(bool bManual, bool bDownload)
|
||||
{
|
||||
if (!m_pUpdateProgress.isNull())
|
||||
return;
|
||||
|
@ -94,6 +94,7 @@ void COnlineUpdater::CheckForUpdates(bool bManual)
|
|||
|
||||
QVariantMap Params;
|
||||
Params["manual"] = bManual;
|
||||
Params["download"] = bDownload;
|
||||
GetUpdates(this, SLOT(OnUpdateData(const QVariantMap&, const QVariantMap&)), Params);
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,7 @@ void COnlineUpdater::OnUpdateCheck()
|
|||
void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Params)
|
||||
{
|
||||
bool bManual = Params["manual"].toBool();
|
||||
bool bDownload = Params["download"].toBool();
|
||||
|
||||
if (!m_pUpdateProgress.isNull()) {
|
||||
m_pUpdateProgress->Finish(SB_OK);
|
||||
|
@ -181,15 +183,7 @@ void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Pa
|
|||
QString VersionStr = Data["version"].toString();
|
||||
if (!VersionStr.isEmpty()) //&& VersionStr != GetVersion())
|
||||
{
|
||||
quint8 myVersion[4] = { VERSION_UPD, VERSION_REV, VERSION_MIN, VERSION_MJR }; // ntohl
|
||||
quint32 MyVersion = *(quint32*)&myVersion;
|
||||
|
||||
quint32 Version = 0;
|
||||
QStringList Nums = VersionStr.split(".");
|
||||
for (int i = 0, Bits = 24; i < Nums.count() && Bits >= 0; i++, Bits -= 8)
|
||||
Version |= (Nums[i].toInt() & 0xFF) << Bits;
|
||||
|
||||
if (Version > MyVersion)
|
||||
if (IsVersionNewer(VersionStr))
|
||||
if (bManual || !IgnoredUpdates.contains(VersionStr)) // when checked manually always show result
|
||||
{
|
||||
bNothing = false;
|
||||
|
@ -199,14 +193,17 @@ void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Pa
|
|||
// 'sha256'
|
||||
// 'signature'
|
||||
|
||||
if (!DownloadUrl.isEmpty() && theConf->GetInt("Options/DownloadUpdates", 0) == 1)
|
||||
if (!DownloadUrl.isEmpty() && (bDownload || theConf->GetInt("Options/DownloadUpdates", 0) == 1))
|
||||
{
|
||||
theConf->SetValue("Options/PendingUpdateVersion", VersionStr);
|
||||
DownloadUpdates(DownloadUrl, bManual);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString UpdateMsg = Data["updateMsg"].toString();
|
||||
QString UpdateUrl = Data["updateUrl"].toString();
|
||||
|
||||
QString FullMessage = UpdateMsg.isEmpty() ? tr("<p>There is a new version of Sandboxie-Plus available.<br /><font color='red'>New version:</font> <b>%1</b></p>").arg(VersionStr) : UpdateMsg;
|
||||
QString FullMessage = UpdateMsg.isEmpty() ? tr("<p>There is a new version of Sandboxie-Plus available.<br /><b><font color='red'>New version:</font> %1</b></p>").arg(VersionStr) : UpdateMsg;
|
||||
if (!DownloadUrl.isEmpty())
|
||||
FullMessage += tr("<p>Do you want to download the latest version?</p>");
|
||||
else if (!UpdateUrl.isEmpty())
|
||||
|
@ -230,22 +227,35 @@ void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Pa
|
|||
|
||||
mb.exec();
|
||||
|
||||
if (mb.isChecked())
|
||||
if (mb.isChecked()) {
|
||||
theConf->DelValue("Options/PendingUpdateVersion");
|
||||
theGUI->UpdateLabel();
|
||||
theConf->SetValue("Options/IgnoredUpdates", IgnoredUpdates << VersionStr);
|
||||
}
|
||||
|
||||
if (mb.clickedStandardButton() == QDialogButtonBox::Yes)
|
||||
{
|
||||
if (!DownloadUrl.isEmpty())
|
||||
if (!DownloadUrl.isEmpty())
|
||||
{
|
||||
theConf->SetValue("Options/PendingUpdateVersion", VersionStr);
|
||||
DownloadUpdates(DownloadUrl, bManual);
|
||||
}
|
||||
else
|
||||
QDesktopServices::openUrl(UpdateUrl);
|
||||
}
|
||||
else if (!mb.isChecked())
|
||||
{
|
||||
theConf->SetValue("Options/PendingUpdateVersion", VersionStr);
|
||||
theGUI->UpdateLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bNothing)
|
||||
{
|
||||
theConf->DelValue("Options/PendingUpdateVersion");
|
||||
theGUI->UpdateLabel();
|
||||
theConf->SetValue("Options/NextCheckForUpdates", QDateTime::currentDateTime().addDays(7).toSecsSinceEpoch());
|
||||
|
||||
if (bManual) {
|
||||
|
@ -321,6 +331,38 @@ void COnlineUpdater::OnUpdateDownload()
|
|||
InstallUpdate();
|
||||
}
|
||||
|
||||
bool COnlineUpdater::IsVersionNewer(const QString& VersionStr)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
quint8 myVersion[4] = { VERSION_UPD, VERSION_REV, VERSION_MIN, VERSION_MJR }; // ntohl
|
||||
quint32 MyVersion = *(quint32*)&myVersion;
|
||||
|
||||
quint32 Version = 0;
|
||||
QStringList Nums = VersionStr.split(".");
|
||||
for (int i = 0, Bits = 24; i < Nums.count() && Bits >= 0; i++, Bits -= 8)
|
||||
Version |= (Nums[i].toInt() & 0xFF) << Bits;
|
||||
|
||||
return (Version > MyVersion);
|
||||
}
|
||||
|
||||
void COnlineUpdater::CheckPendingUpdate()
|
||||
{
|
||||
QString VersionStr = theConf->GetString("Options/PendingUpdateVersion");
|
||||
if (!IsVersionNewer(VersionStr)) {
|
||||
theConf->DelValue("Options/PendingUpdateVersion");
|
||||
theConf->DelValue("Options/PendingUpdatePackage");
|
||||
}
|
||||
}
|
||||
|
||||
void COnlineUpdater::DownloadUpdate()
|
||||
{
|
||||
CheckForUpdates(true, true);
|
||||
}
|
||||
|
||||
void COnlineUpdater::InstallUpdate()
|
||||
{
|
||||
QString FilePath = theConf->GetString("Options/PendingUpdatePackage");
|
||||
|
|
|
@ -34,11 +34,13 @@ public:
|
|||
|
||||
void GetUpdates(QObject* receiver, const char* member, const QVariantMap& Params = QVariantMap());
|
||||
|
||||
void DownloadUpdate();
|
||||
void InstallUpdate();
|
||||
|
||||
void UpdateCert();
|
||||
|
||||
void CheckForUpdates(bool bManual = true);
|
||||
void CheckPendingUpdate();
|
||||
void CheckForUpdates(bool bManual = true, bool bDownload = false);
|
||||
void DownloadUpdates(const QString& DownloadUrl, bool bManual);
|
||||
|
||||
private slots:
|
||||
|
@ -52,6 +54,7 @@ private slots:
|
|||
void OnCertCheck();
|
||||
|
||||
protected:
|
||||
bool IsVersionNewer(const QString& VersionStr);
|
||||
|
||||
CNetworkAccessManager* m_RequestManager;
|
||||
CSbieProgressPtr m_pUpdateProgress;
|
||||
|
|
|
@ -745,6 +745,8 @@ void CSandMan::CreateLabel()
|
|||
//fnt.setWeight(QFont::DemiBold);
|
||||
m_pLabel->setFont(fnt);
|
||||
|
||||
COnlineUpdater::Instance()->CheckPendingUpdate();
|
||||
|
||||
UpdateLabel();
|
||||
}
|
||||
|
||||
|
@ -753,24 +755,24 @@ void CSandMan::UpdateLabel()
|
|||
QString LabelText;
|
||||
QString LabelTip;
|
||||
|
||||
if (!theConf->GetString("Options/PendingUpdatePackage").isEmpty())
|
||||
if (!theConf->GetString("Options/PendingUpdatePackage").isEmpty())
|
||||
{
|
||||
LabelText = tr("<a href=\"sbie://update/package\" style=\"color: red;\">There is a new build of Sandboxie-Plus available</a>");
|
||||
|
||||
//QPalette palette = m_pLabel->palette();
|
||||
//palette.setColor(QPalette::Link, Qt::red);
|
||||
//palette.setColor(m_pLabel->backgroundRole(), Qt::yellow);
|
||||
//palette.setColor(m_pLabel->foregroundRole(), Qt::red);
|
||||
//m_pLabel->setAutoFillBackground(true);
|
||||
//m_pLabel->setPalette(palette);
|
||||
|
||||
//m_pLabel->setStyleSheet("QLabel { link-color : red; }");
|
||||
LabelText = tr("<a href=\"sbie://update/package\" style=\"color: red;\">There is a new build of Sandboxie-Plus ready</a>");
|
||||
|
||||
LabelTip = tr("Click to install update");
|
||||
|
||||
//auto neon = new CNeonEffect(10, 4, 180); // 140
|
||||
//m_pLabel->setGraphicsEffect(NULL);
|
||||
}
|
||||
else if (!theConf->GetString("Options/PendingUpdateVersion").isEmpty())
|
||||
{
|
||||
LabelText = tr("<a href=\"sbie://update/check\" style=\"color: red;\">There is a new build of Sandboxie-Plus available</a>");
|
||||
|
||||
LabelTip = tr("Click to download update");
|
||||
|
||||
//auto neon = new CNeonEffect(10, 4, 180); // 140
|
||||
//m_pLabel->setGraphicsEffect(NULL);
|
||||
}
|
||||
else if (g_Certificate.isEmpty())
|
||||
{
|
||||
LabelText = tr("<a href=\"https://sandboxie-plus.com/go.php?to=patreon\">Support Sandboxie-Plus on Patreon</a>");
|
||||
|
@ -2618,6 +2620,8 @@ void CSandMan::OpenUrl(const QUrl& url)
|
|||
QString query = url.query();
|
||||
|
||||
if (scheme == "sbie") {
|
||||
if (path == "/check")
|
||||
return COnlineUpdater::Instance()->DownloadUpdate();
|
||||
if (path == "/package")
|
||||
return COnlineUpdater::Instance()->InstallUpdate();
|
||||
if (path == "/cert")
|
||||
|
|
Loading…
Reference in New Issue