This commit is contained in:
DavidXanatos 2022-08-12 00:09:35 +02:00
parent ba166e24ed
commit 8f732c9aa5
9 changed files with 395 additions and 271 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<width>634</width>
<height>464</height>
</rect>
</property>
@ -45,7 +45,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@ -125,7 +125,7 @@
<item row="9" column="1" colspan="2">
<widget class="QCheckBox" name="chkMonitorSize">
<property name="text">
<string>Count and display the disk space occupied by each sandbox</string>
<string>Count and display the disk space ocupied by each sandbox</string>
</property>
</widget>
</item>
@ -194,70 +194,6 @@
<layout class="QGridLayout" name="gridLayout_14">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_13">
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Systray options</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QCheckBox" name="chkAlwaysDefault">
<property name="text">
<string>Always use DefaultBox</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="cmbTrayBoxes"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Show Icon in Systray:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Run Sandboxed - Actions</string>
</property>
</widget>
</item>
<item row="11" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="chkSvcStart">
<property name="text">
@ -265,87 +201,6 @@
</property>
</widget>
</item>
<item row="6" column="2" colspan="3">
<widget class="QCheckBox" name="chkShellMenu2">
<property name="text">
<string>Add 'Run Un-Sandboxed' to the context menu</string>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1" colspan="2">
<widget class="QComboBox" name="cmbSysTray"/>
</item>
<item row="11" column="3" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Start Sandbox Manager</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="chkAutoStart">
<property name="text">
<string>Start UI with Windows</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="chkShellMenu">
<property name="text">
<string>Add 'Run Sandboxed' to the explorer context menu</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<widget class="QCheckBox" name="chkBoxOpsNotify">
<property name="text">
<string>Show a tray notification when automatic box operations are started</string>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QCheckBox" name="chkCompactTray">
<property name="text">
<string>Use Compact Box List</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
@ -359,6 +214,104 @@
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QCheckBox" name="chkAlwaysDefault">
<property name="text">
<string>Always use DefaultBox</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Start Sandbox Manager</string>
</property>
</widget>
</item>
<item row="11" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="chkShellMenu">
<property name="text">
<string>Add 'Run Sandboxed' to the explorer context menu</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Show Icon in Systray:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="3" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Systray options</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="chkAutoStart">
<property name="text">
<string>Start UI with Windows</string>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QCheckBox" name="chkCompactTray">
<property name="text">
<string>Use Compact Box List</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_9">
<property name="orientation">
@ -372,6 +325,53 @@
</property>
</spacer>
</item>
<item row="8" column="1" colspan="2">
<widget class="QComboBox" name="cmbSysTray"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Run Sandboxed - Actions</string>
</property>
</widget>
</item>
<item row="6" column="2" colspan="3">
<widget class="QCheckBox" name="chkShellMenu2">
<property name="text">
<string>Add 'Run Un-Sandboxed' to the context menu</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<widget class="QCheckBox" name="chkBoxOpsNotify">
<property name="text">
<string>Show a tray notification when automatic box operations are started</string>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="cmbTrayBoxes"/>
</item>
</layout>
</item>
</layout>
@ -456,7 +456,7 @@
<item row="4" column="1" colspan="2">
<widget class="QCheckBox" name="chkBackground">
<property name="text">
<string>Show &quot;Pizza&quot; Background in box list *</string>
<string>Show &quot;Pizza&quot; Background in box list*</string>
</property>
<property name="tristate">
<bool>true</bool>
@ -466,7 +466,7 @@
<item row="11" column="2" colspan="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>* a partially checked checkbox will leave the behavior to be determined by the view mode.</string>
<string>* indetermined means depanding on the view mode</string>
</property>
</widget>
</item>
@ -1033,17 +1033,36 @@
<property name="leftMargin">
<number>0</number>
</property>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<item row="1" column="0" rowspan="5" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Support Settings</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="../Resources/SandMan.qrc">:/HelpingHand.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="12" column="4">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="3" colspan="3">
<widget class="QCheckBox" name="chkAutoDownload">
<property name="text">
<string>Download Updates automatically</string>
</property>
</widget>
</item>
@ -1054,20 +1073,6 @@
</property>
</widget>
</item>
<item row="5" column="2" colspan="4">
<widget class="QLabel" name="lblCertExp">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>This supporter certificate has expired, please &lt;a href=&quot;sbie://update/cert&quot;&gt;get an updated certificate&lt;/a&gt;.</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="4">
<widget class="QPlainTextEdit" name="txtCertificate">
<property name="maximumSize">
@ -1107,6 +1112,20 @@
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QRadioButton" name="radRelease">
<property name="text">
<string>Search in the Release channel</string>
</property>
</widget>
</item>
<item row="11" column="3" colspan="3">
<widget class="QCheckBox" name="chkAutoInstall">
<property name="text">
<string>Install updates automatically</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="4">
<widget class="QLabel" name="lblSupportCert">
<property name="text">
@ -1117,17 +1136,31 @@
</property>
</widget>
</item>
<item row="10" column="3" colspan="3">
<widget class="QCheckBox" name="chkAutoDownload">
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Download Updates automatically</string>
<string>Support Settings</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QRadioButton" name="radRelease">
<item row="5" column="2" colspan="4">
<widget class="QLabel" name="lblCertExp">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Search in the Release channel</string>
<string>This supporter certificate has expired, please &lt;a href=&quot;sbie://update/cert&quot;&gt;get an updated certificate&lt;/a&gt;.</string>
</property>
</widget>
</item>
@ -1144,26 +1177,6 @@
</property>
</spacer>
</item>
<item row="11" column="3" colspan="3">
<widget class="QCheckBox" name="chkAutoInstall">
<property name="text">
<string>Install updates automatically</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="5" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../Resources/SandMan.qrc">:/HelpingHand.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="12" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
@ -1177,26 +1190,34 @@
</property>
</spacer>
</item>
<item row="12" column="4">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="8" column="5">
<widget class="QLabel" name="lblRelease">
<property name="text">
<string/>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="7" column="2" colspan="4">
<item row="9" column="5">
<widget class="QLabel" name="lblPreview">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="2" colspan="3">
<widget class="QCheckBox" name="chkAutoUpdate">
<property name="text">
<string>Check periodically for updates of Sandboxie-Plus</string>
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QLabel" name="lblCurrent">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -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<QNetworkReply*>(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();

View File

@ -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<QNetworkReply*, CGetUpdatesJob*> m_JobQueue;
};

View File

@ -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

View File

@ -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("<a href=\"check\">Check Now</a>"));
}
}
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("<a href=\"0\">%1</a>").arg(Channels[0].toMap().value("version").toString()));
if(Channels.length() > 1) ui.lblPreview->setText(tr("<a href=\"1\">%1</a>").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
//

View File

@ -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:

View File

@ -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;