diff --git a/CHANGELOG.md b/CHANGELOG.md index 782566ac..15531ad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - added ability to switch fusion theme independant from dark theme +- added ability to download updates from the support page ### Changed - Improved info label diff --git a/Sandboxie/apps/start/aboutdlg.cpp b/Sandboxie/apps/start/aboutdlg.cpp index b6d807f3..9b045635 100644 --- a/Sandboxie/apps/start/aboutdlg.cpp +++ b/Sandboxie/apps/start/aboutdlg.cpp @@ -307,21 +307,11 @@ bool DoAboutDialog(bool bReminder) if (Days < 40) return true; - int Probability = 5; - int Interval; // days - if (Days > 369) { - Interval = 3; - // Probability = 10; - } else if (Days > 120) { - Interval = 5; - // Probability = 20; - } else if (Days > 80) { - Interval = 7; - // Probability = 40; - } else {//if (Days > 40) - Interval = 10; - // Probability = 80; - } + int Interval; // days + if (Days > 730) Interval = 5; + else if (Days > 365) Interval = 10; + else if (Days > 180) Interval = 20; + else Interval = 30; time_t LastReminder = 0; SbieApi_Call(API_GET_SECURE_PARAM, 3, L"LastReminder", (ULONG_PTR)&LastReminder, sizeof(LastReminder)); @@ -330,7 +320,7 @@ bool DoAboutDialog(bool bReminder) return true; } - if ((rand() % Probability) != 0) + if ((rand() % 5) != 0) return true; } diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui index ebd2118d..4ea9bf2a 100644 --- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui @@ -6,7 +6,7 @@ 0 0 - 687 + 634 464 @@ -45,7 +45,7 @@ QTabWidget::North - 2 + 0 @@ -125,7 +125,7 @@ - Count and display the disk space occupied by each sandbox + Count and display the disk space ocupied by each sandbox @@ -194,70 +194,6 @@ - - - - - 75 - true - true - - - - Systray options - - - - - - - Always use DefaultBox - - - - - - - - - - Show Icon in Systray: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - - 75 - true - true - - - - Run Sandboxed - Actions - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -265,87 +201,6 @@ - - - - Add 'Run Un-Sandboxed' to the context menu - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - true - - - - Start Sandbox Manager - - - - - - - Start UI with Windows - - - - - - - Add 'Run Sandboxed' to the explorer context menu - - - - - - - Show a tray notification when automatic box operations are started - - - - - - - Use Compact Box List - - - true - - - @@ -359,6 +214,104 @@ + + + + Always use DefaultBox + + + + + + + + 75 + true + true + + + + Start Sandbox Manager + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Add 'Run Sandboxed' to the explorer context menu + + + + + + + Show Icon in Systray: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + true + + + + Systray options + + + + + + + Start UI with Windows + + + + + + + Use Compact Box List + + + true + + + @@ -372,6 +325,53 @@ + + + + + + + + 75 + true + true + + + + Run Sandboxed - Actions + + + + + + + Add 'Run Un-Sandboxed' to the context menu + + + + + + + Show a tray notification when automatic box operations are started + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -456,7 +456,7 @@ - Show "Pizza" Background in box list * + Show "Pizza" Background in box list* true @@ -466,7 +466,7 @@ - * a partially checked checkbox will leave the behavior to be determined by the view mode. + * indetermined means depanding on the view mode @@ -1033,17 +1033,36 @@ 0 - - - - - 75 - true - true - - + + - Support Settings + + + + :/HelpingHand.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Download Updates automatically @@ -1054,20 +1073,6 @@ - - - - - 75 - true - true - - - - This supporter certificate has expired, please <a href="sbie://update/cert">get an updated certificate</a>. - - - @@ -1107,6 +1112,20 @@ + + + + Search in the Release channel + + + + + + + Install updates automatically + + + @@ -1117,17 +1136,31 @@ - - + + + + + 75 + true + true + + - Download Updates automatically + Support Settings - - + + + + + 75 + true + true + + - Search in the Release channel + This supporter certificate has expired, please <a href="sbie://update/cert">get an updated certificate</a>. @@ -1144,26 +1177,6 @@ - - - - Install updates automatically - - - - - - - - - - :/HelpingHand.png - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - @@ -1177,26 +1190,34 @@ - - - - Qt::Horizontal + + + + - - - 40 - 20 - - - + - + + + + + + + + Check periodically for updates of Sandboxie-Plus + + + + + + + diff --git a/SandboxiePlus/SandMan/OnlineUpdater.cpp b/SandboxiePlus/SandMan/OnlineUpdater.cpp index c9a160f0..abd39419 100644 --- a/SandboxiePlus/SandMan/OnlineUpdater.cpp +++ b/SandboxiePlus/SandMan/OnlineUpdater.cpp @@ -19,7 +19,6 @@ COnlineUpdater::COnlineUpdater(QObject *parent) : QObject(parent) COnlineUpdater* COnlineUpdater::Instance() { - g_pUpdater = NULL; if (!g_pUpdater) g_pUpdater = new COnlineUpdater(theGUI); return g_pUpdater; @@ -37,19 +36,14 @@ void COnlineUpdater::Process() } } -void COnlineUpdater::CheckForUpdates(bool bManual) +void COnlineUpdater::GetUpdates(QObject* receiver, const char* member, const QVariantMap& Params) { - if (!m_pUpdateProgress.isNull()) - return; - - m_pUpdateProgress = CSbieProgressPtr(new CSbieProgress()); - theGUI->AddAsyncOp(m_pUpdateProgress); - m_pUpdateProgress->ShowMessage(tr("Checking for updates...")); + CGetUpdatesJob* pJob = new CGetUpdatesJob(Params, this); + QObject::connect(pJob, SIGNAL(UpdateData(const QVariantMap&, const QVariantMap&)), receiver, member, Qt::QueuedConnection); if (m_RequestManager == NULL) m_RequestManager = new CNetworkAccessManager(30 * 1000, this); - QUrlQuery Query; Query.addQueryItem("software", "sandboxie-plus"); //QString Branche = theConf->GetString("Options/ReleaseBranche"); @@ -65,9 +59,15 @@ void COnlineUpdater::CheckForUpdates(bool bManual) UpdateKey = theAPI->GetGlobalSettings()->GetText("UpdateKey"); // theConf->GetString("Options/UpdateKey"); if (!UpdateKey.isEmpty()) Query.addQueryItem("update_key", UpdateKey); - int UpdateChannel = theConf->GetInt("Options/UpdateChannel", 0); - Query.addQueryItem("channel", QString::number(UpdateChannel)); - Query.addQueryItem("auto", bManual ? "0" : "1"); + if (Params.contains("channel")) + Query.addQueryItem("channel", Params["channel"].toString()); + else { + int UpdateChannel = theConf->GetInt("Options/UpdateChannel", 0); + Query.addQueryItem("channel", QString::number(UpdateChannel)); + } + if(Params.contains("manual")) Query.addQueryItem("auto", Params["manual"].toBool() ? "0" : "1"); + + //QString Test = Query.toString(); QUrl Url("https://sandboxie-plus.com/update.php"); Url.setQuery(Query); @@ -77,24 +77,52 @@ void COnlineUpdater::CheckForUpdates(bool bManual) Request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy); //Request.setRawHeader("Accept-Encoding", "gzip"); QNetworkReply* pReply = m_RequestManager->get(Request); - pReply->setProperty("manual", bManual); + //pReply->setProperty("manual", bManual); connect(pReply, SIGNAL(finished()), this, SLOT(OnUpdateCheck())); + + m_JobQueue.insert(pReply, pJob); +} + +void COnlineUpdater::CheckForUpdates(bool bManual) +{ + if (!m_pUpdateProgress.isNull()) + return; + + m_pUpdateProgress = CSbieProgressPtr(new CSbieProgress()); + theGUI->AddAsyncOp(m_pUpdateProgress); + m_pUpdateProgress->ShowMessage(tr("Checking for updates...")); + + QVariantMap Params; + Params["manual"] = bManual; + GetUpdates(this, SLOT(OnUpdateData(const QVariantMap&, const QVariantMap&)), Params); } void COnlineUpdater::OnUpdateCheck() { - if (m_pUpdateProgress.isNull()) - return; - QNetworkReply* pReply = qobject_cast(sender()); - bool bManual = pReply->property("manual").toBool(); + //bool bManual = pReply->property("manual").toBool(); QByteArray Reply = pReply->readAll(); pReply->deleteLater(); - m_pUpdateProgress->Finish(SB_OK); - m_pUpdateProgress.clear(); + CGetUpdatesJob* pJob = m_JobQueue.take(pReply); + if (!pJob) + return; QVariantMap Data = QJsonDocument::fromJson(Reply).toVariant().toMap(); + + emit pJob->UpdateData(Data, pJob->m_Params); + pJob->deleteLater(); +} + +void COnlineUpdater::OnUpdateData(const QVariantMap& Data, const QVariantMap& Params) +{ + bool bManual = Params["manual"].toBool(); + + if (!m_pUpdateProgress.isNull()) { + m_pUpdateProgress->Finish(SB_OK); + m_pUpdateProgress.clear(); + } + if (Data.isEmpty() || Data["error"].toBool()) { QString Error = Data.isEmpty() ? tr("server not reachable") : Data["errorMsg"].toString(); diff --git a/SandboxiePlus/SandMan/OnlineUpdater.h b/SandboxiePlus/SandMan/OnlineUpdater.h index 4d7844cf..0c4feed2 100644 --- a/SandboxiePlus/SandMan/OnlineUpdater.h +++ b/SandboxiePlus/SandMan/OnlineUpdater.h @@ -5,6 +5,23 @@ #include "SbiePlusAPI.h" +class CGetUpdatesJob : public QObject +{ + Q_OBJECT + +protected: + friend class COnlineUpdater; + + CGetUpdatesJob(const QVariantMap& Params, QObject* parent = nullptr) : QObject(parent) { m_Params = Params; } + virtual ~CGetUpdatesJob() {} + + QVariantMap m_Params; + +signals: + void UpdateData(const QVariantMap& Data, const QVariantMap& Params); +}; + + class COnlineUpdater : public QObject { Q_OBJECT @@ -15,6 +32,8 @@ public: static void Process(); + void GetUpdates(QObject* receiver, const char* member, const QVariantMap& Params = QVariantMap()); + void InstallUpdate(); void UpdateCert(); @@ -23,6 +42,8 @@ public: void DownloadUpdates(const QString& DownloadUrl, bool bManual); private slots: + + void OnUpdateData(const QVariantMap& Data, const QVariantMap& Params); void OnUpdateCheck(); void OnUpdateProgress(qint64 bytes, qint64 bytesTotal); @@ -34,4 +55,5 @@ protected: CNetworkAccessManager* m_RequestManager; CSbieProgressPtr m_pUpdateProgress; + QMap m_JobQueue; }; \ No newline at end of file diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 3aeaa77b..7af8e038 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -2218,15 +2218,18 @@ void CSandMan::OnProcView() void CSandMan::OnSettings() { static CSettingsWindow* pSettingsWindow = NULL; - if (pSettingsWindow == NULL) - { + if (pSettingsWindow == NULL) { pSettingsWindow = new CSettingsWindow(); connect(pSettingsWindow, SIGNAL(OptionsChanged(bool)), this, SLOT(UpdateSettings(bool))); connect(pSettingsWindow, &CSettingsWindow::Closed, [this]() { pSettingsWindow = NULL; - }); + }); SafeShow(pSettingsWindow); } + else { + pSettingsWindow->setWindowState((pSettingsWindow->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + SetForegroundWindow((HWND)pSettingsWindow->winId()); + } } // for old menu @@ -2631,9 +2634,9 @@ void CSandMan::OpenUrl(const QUrl& url) QString CSandMan::GetVersion() { QString Version = QString::number(VERSION_MJR) + "." + QString::number(VERSION_MIN) //.rightJustified(2, '0') -#if VERSION_REV > 0 || VERSION_MJR == 0 +//#if VERSION_REV > 0 || VERSION_MJR == 0 + "." + QString::number(VERSION_REV) -#endif +//#endif #if VERSION_UPD > 0 + QString('a' + VERSION_UPD - 1) #endif diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index 0ee20569..526b8149 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -7,6 +7,7 @@ #include "../QSbieAPI/Sandboxie/SbieTemplates.h" #include "../QSbieAPI/SbieUtils.h" #include "OptionsWindow.h" +#include "../OnlineUpdater.h" QSize CustomTabStyle::sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const { @@ -233,6 +234,10 @@ CSettingsWindow::CSettingsWindow(QWidget *parent) "SIGNATURE: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" ); + connect(ui.lblCurrent, SIGNAL(linkActivated(const QString&)), this, SLOT(OnUpdate(const QString&))); + connect(ui.lblRelease, SIGNAL(linkActivated(const QString&)), this, SLOT(OnUpdate(const QString&))); + connect(ui.lblPreview, SIGNAL(linkActivated(const QString&)), this, SLOT(OnUpdate(const QString&))); + connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab())); // edit @@ -867,7 +872,16 @@ void CSettingsWindow::OnChange() void CSettingsWindow::OnTab() { - if (ui.tabs->currentWidget() == ui.tabEdit) + if (ui.tabs->currentWidget() == ui.tabSupport) + { + if (ui.lblCurrent->text().isEmpty()) { + if (ui.chkAutoUpdate->checkState()) + GetUpdates(); + else + ui.lblCurrent->setText(tr("Check Now")); + } + } + else if (ui.tabs->currentWidget() == ui.tabEdit) { LoadIniSection(); ui.txtIniSection->setReadOnly(true); @@ -1060,6 +1074,59 @@ void CSettingsWindow::SaveIniSection() LoadIniSection(); } +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Update +// + +void CSettingsWindow::GetUpdates() +{ + QVariantMap Params; + Params["channel"] = "all"; + COnlineUpdater::Instance()->GetUpdates(this, SLOT(OnUpdateData(const QVariantMap&, const QVariantMap&)), Params); +} + +void CSettingsWindow::OnUpdateData(const QVariantMap& Data, const QVariantMap& Params) +{ + if (Data.isEmpty() || Data["error"].toBool()) + return; + + m_UpdateData = Data; + QVariantList Channels = m_UpdateData["channels"].toList(); + ui.lblCurrent->setText(tr("%1 (Current)").arg(theGUI->GetVersion())); + if(Channels.length() > 0) ui.lblRelease->setText(tr("%1").arg(Channels[0].toMap().value("version").toString())); + if(Channels.length() > 1) ui.lblPreview->setText(tr("%1").arg(Channels[1].toMap().value("version").toString())); +} + +void CSettingsWindow::OnUpdate(const QString& Channel) +{ + if (Channel == "check") + GetUpdates(); + else + { + QVariantList Channels = m_UpdateData["channels"].toList(); + QVariantMap Data = Channels[Channel.toInt()].toMap(); + + QString VersionStr = Data["version"].toString(); + if (VersionStr.isEmpty()) + return; + + QString DownloadUrl = Data["downloadUrl"].toString(); + // 'sha256' + // 'signature' + + if (!DownloadUrl.isEmpty()) + { + if (QMessageBox("Sandboxie-Plus", tr("Do you want to download the version %1?").arg(VersionStr), QMessageBox::Question, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton, this).exec() == QMessageBox::Yes) + COnlineUpdater::Instance()->DownloadUpdates(DownloadUrl, true); + } + else + { + QString UpdateUrl = Data["updateUrl"].toString(); + QDesktopServices::openUrl(UpdateUrl); + } + } +} + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Support // diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.h b/SandboxiePlus/SandMan/Windows/SettingsWindow.h index e7889b56..b5613ef6 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.h +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.h @@ -106,6 +106,10 @@ private slots: void CertChanged(); void UpdateCert(); + void GetUpdates(); + void OnUpdateData(const QVariantMap& Data, const QVariantMap& Params); + void OnUpdate(const QString& Channel); + protected: void closeEvent(QCloseEvent *e); @@ -124,6 +128,7 @@ protected: bool m_CompatChanged; bool m_FeaturesChanged; bool m_CertChanged; + QVariantMap m_UpdateData; private: diff --git a/SandboxiePlus/SandMan/Windows/SupportDialog.cpp b/SandboxiePlus/SandMan/Windows/SupportDialog.cpp index 546afb69..c5f4406d 100644 --- a/SandboxiePlus/SandMan/Windows/SupportDialog.cpp +++ b/SandboxiePlus/SandMan/Windows/SupportDialog.cpp @@ -59,21 +59,11 @@ bool CSupportDialog::CheckSupport(bool bOnRun) { // Note: the old sandboxie showed a message after 30 days every 12 hours for 5 seconds - int Probability = 5; int Interval; // days - if (Days > 369) { - Interval = 3; - // Probability = 10; - } else if (Days > 120) { - Interval = 5; - // Probability = 20; - } else if (Days > 80) { - Interval = 7; - // Probability = 40; - } else {//if (Days > 40) - Interval = 10; - // Probability = 80; - } + if (Days > 730) Interval = 5; + else if (Days > 365) Interval = 10; + else if (Days > 180) Interval = 20; + else Interval = 30; time_t LastReminder = 0; theAPI->GetSecureParam("LastReminder", &LastReminder, sizeof(LastReminder)); @@ -82,10 +72,7 @@ bool CSupportDialog::CheckSupport(bool bOnRun) return false; } - //if (!m_ReminderShown) - // Probability /= 10; - - if ((qrand() % Probability) != 0) + if ((rand() % 5) != 0) return false; } m_ReminderShown = true;