diff --git a/CHANGELOG.md b/CHANGELOG.md index f354a82b..1ca2317b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - on systems in test signing mode sandboxie will by default try outdated offsets - changed Qt5 version to Qt5.15.13 with latest security patches [#3694](https://github.com/sandboxie-plus/Sandboxie/pull/3694) (thanks LumitoLuma) - moved network restrictions from general restrictions tab to an own tab on the network page +- improved certificate retrival UI messages. ### Fixed - fixed Virtualization scheme Version 2 causing extremely slow file deleting speed [#3650](https://github.com/sandboxie-plus/Sandboxie/issues/3650) diff --git a/SandboxiePlus/SandMan/OnlineUpdater.cpp b/SandboxiePlus/SandMan/OnlineUpdater.cpp index 6d9afa8d..d4483edb 100644 --- a/SandboxiePlus/SandMan/OnlineUpdater.cpp +++ b/SandboxiePlus/SandMan/OnlineUpdater.cpp @@ -203,12 +203,12 @@ void CGetFileJob::Finish(QNetworkReply* pReply) SB_PROGRESS COnlineUpdater::GetSupportCert(const QString& Serial, QObject* receiver, const char* member, const QVariantMap& Params) { - QString UpdateKey = GetArguments(g_Certificate, L'\n', L':').value("UPDATEKEY"); + QString UpdateKey = Params["key"].toString(); QUrlQuery Query; if (!Serial.isEmpty()) { Query.addQueryItem("SN", Serial); - if (Serial.length() > 5 && Serial.at(4).toUpper() == 'N') { // node locked business use + if (Serial.length() > 5 && Serial.at(4).toUpper() == 'N') { wchar_t uuid_str[40]; theAPI->GetDriverInfo(-2, uuid_str, sizeof(uuid_str)); Query.addQueryItem("HwId", QString::fromWCharArray(uuid_str)); diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 755ca757..6ed0c7dc 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -2880,13 +2880,7 @@ void CSandMan::OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, qui if (!Message.isEmpty()) { - QMessageBox msgBox(this); - msgBox.setTextFormat(Qt::RichText); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setWindowTitle("Sandboxie-Plus"); - msgBox.setText(Message); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); + ShowMessageBox(this, QMessageBox::Critical, Message); /*msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (msgBox.exec() == QDialogButtonBox::Yes) { OpenUrl(QUrl("https://sandboxie-plus.com/go.php?to=sbie-get-cert")); @@ -2923,6 +2917,17 @@ void CSandMan::OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, qui m_pPopUpWindow->AddLogMessage(MsgCode, MsgData, ProcessId); } +void CSandMan::ShowMessageBox(QWidget* Widget, QMessageBox::Icon Icon, const QString& Message) +{ + QMessageBox msgBox(Widget); + msgBox.setTextFormat(Qt::RichText); + msgBox.setIcon(Icon); + msgBox.setWindowTitle("Sandboxie-Plus"); + msgBox.setText(Message); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); +} + void CSandMan::SaveMessageLog(QIODevice* pFile) { foreach(const SSbieMsg& Msg, m_MessageLog) diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index 612a47b6..c5f84d00 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -48,6 +48,7 @@ public: CAddonManager* GetAddonManager() { return m_AddonManager; } static QString GetVersion(); + static void ShowMessageBox(QWidget* Widget, QMessageBox::Icon Icon, const QString& Message); bool IsImDiskReady() const { return m_ImDiskReady; } diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index 9c378e43..89b48368 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -1288,7 +1288,32 @@ void CSettingsWindow::UpdateCert() void CSettingsWindow::OnGetCert() { - SB_PROGRESS Status = theGUI->m_pUpdater->GetSupportCert(ui.txtSerial->text(), this, SLOT(OnCertData(const QByteArray&, const QVariantMap&))); + QByteArray Certificate = ui.txtCertificate->toPlainText().toUtf8(); + QString Serial = ui.txtSerial->text(); + + QString Message; + if (Serial.length() > 5 && Serial.at(4).toUpper() == 'U') { + Message = tr("You are attempting to use a feature Upgrade-Key without having entered a preexisting supporter certificate. " + "Please note that these type of key (as it is clearly stated in bold on the website) require you to have a preexisting valid supporter certificate, it is useless without one." + "
If you want to use the advanced features you need to obtain booth a standard certificate and the feature upgrade key to unlock advanced functionality."); + } + + if (Serial.length() > 5 && Serial.at(4).toUpper() == 'R') { + Message = tr("You are attempting to use a Renew-Key without having a preexisting supporter certificate. " + "Please note that these type of key (as it is clearly stated in bold on the website) require you to have a preexisting supporter certificate, it is useless without one."); + } + + if (!Message.isEmpty()) { + Message += tr("

If you have not read the product description and got this key by mistake, please contact us by email (provided on our website) to resolve this issue."); + CSandMan::ShowMessageBox(this, QMessageBox::Critical, Message); + return; + } + + QVariantMap Params; + if(!Certificate.isEmpty()) + Params["key"] = GetArguments(Certificate, L'\n', L':').value("UPDATEKEY"); + + SB_PROGRESS Status = theGUI->m_pUpdater->GetSupportCert(Serial, this, SLOT(OnCertData(const QByteArray&, const QVariantMap&)), Params); if (Status.GetStatus() == OP_ASYNC) { theGUI->AddAsyncOp(Status.GetValue()); Status.GetValue()->ShowMessage(tr("Retrieving certificate...")); @@ -1297,6 +1322,14 @@ void CSettingsWindow::OnGetCert() void CSettingsWindow::OnCertData(const QByteArray& Certificate, const QVariantMap& Params) { + if (Certificate.isEmpty()) + { + QString Error = Params["error"].toString(); + qDebug() << Error; + QString Message = tr("Error retriving certificate: %1").arg(Error.isEmpty() ? tr("Unknown Error (probably a network issue)") : Error); + CSandMan::ShowMessageBox(this, QMessageBox::Critical, Message); + return; + } ui.txtCertificate->setPlainText(Certificate); ApplyCert(); } diff --git a/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp b/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp index 9c6843d9..2cb0dd1a 100644 --- a/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp +++ b/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp @@ -355,9 +355,14 @@ bool CCertificatePage::validatePage() if (m_pEvaluate->isChecked()) return true; + QByteArray Certificate = m_pCertificate->toPlainText().toUtf8(); QString Serial = m_pSerial->text(); + if (!Serial.isEmpty()) { - SB_PROGRESS Status = theGUI->m_pUpdater->GetSupportCert(Serial, this, SLOT(OnCertData(const QByteArray&, const QVariantMap&))); + QVariantMap Params; + if(!Certificate.isEmpty()) + Params["key"] = GetArguments(Certificate, L'\n', L':').value("UPDATEKEY"); + SB_PROGRESS Status = theGUI->m_pUpdater->GetSupportCert(Serial, this, SLOT(OnCertData(const QByteArray&, const QVariantMap&)), Params); if (Status.GetStatus() == OP_ASYNC) { theGUI->AddAsyncOp(Status.GetValue()); Status.GetValue()->ShowMessage(tr("Retrieving certificate...")); @@ -365,7 +370,6 @@ bool CCertificatePage::validatePage() return false; } - QByteArray Certificate = m_pCertificate->toPlainText().toUtf8(); if (!Certificate.isEmpty() && Certificate != g_Certificate) return CSettingsWindow::ApplyCertificate(Certificate, this);