This commit is contained in:
DavidXanatos 2022-05-15 15:02:58 +02:00
parent 7d8e3fc177
commit bdba0e2ebf
3 changed files with 97 additions and 64 deletions

View File

@ -21,6 +21,7 @@
#include "Views/TraceView.h"
#include "Windows/SelectBoxWindow.h"
#include "../UGlobalHotkey/uglobalhotkeys.h"
#include "Wizards/SetupWizard.h"
#include "Helpers/WinAdmin.h"
CSbiePlusAPI* theAPI = NULL;
@ -355,6 +356,7 @@ void CSandMan::CreateMenus()
m_pStopSvc = m_pMaintenanceItems->addAction(tr("Stop Service"), this, SLOT(OnMaintenance()));
m_pUninstallSvc = m_pMaintenanceItems->addAction(tr("Uninstall Service"), this, SLOT(OnMaintenance()));
m_pMaintenance->addSeparator();
m_pSetupWizard = m_pMaintenance->addAction(CSandMan::GetIcon("Software"), tr("Setup Wizard"), this, SLOT(OnMaintenance()));
if(IsFullyPortable())
m_pUninstallAll = m_pMaintenance->addAction(CSandMan::GetIcon("Uninstall"), tr("Uninstall All"), this, SLOT(OnMaintenance()));
@ -1173,6 +1175,18 @@ void CSandMan::OnStatusChanged()
OnLogMessage(tr("Default sandbox not found; creating: %1").arg("DefaultBox"));
theAPI->CreateBox("DefaultBox");
}
int BusinessUse = theConf->GetInt("Options/BusinessUse", 2);
if (g_CertInfo.business && BusinessUse == 0) // if we have a Business cert switch to that use case
theConf->SetValue("Options/BusinessUse", 1);
int WizardLevel = theConf->GetBool("Options/WizardLevel", 0);
if (WizardLevel == 0) {
if (CSetupWizard::ShowWizard())
UpdateSettings();
else // if user canceled mark that and not show again
theConf->SetValue("Options/WizardLevel", -1);
}
}
else
{
@ -1727,6 +1741,12 @@ void CSandMan::OnMaintenance()
CSbieUtils::RemoveContextMenu2();
}
else if (sender() == m_pSetupWizard) {
if (CSetupWizard::ShowWizard())
UpdateSettings();
return;
}
HandleMaintenance(Status);
}

View File

@ -573,6 +573,41 @@ void CSettingsWindow::SaveSettings()
QPalette palette = QApplication::palette();
if (theGUI->m_DarkTheme)
palette.setColor(QPalette::Text, Qt::black);
ui.lblCertExp->setVisible(false);
bool bRet = ApplyCertificate(Certificate, this);
if (Certificate.isEmpty())
palette.setColor(QPalette::Base, Qt::white);
else if (!bRet)
palette.setColor(QPalette::Base, QColor(255, 192, 192));
else if (g_CertInfo.expired || g_CertInfo.outdated) {
palette.setColor(QPalette::Base, QColor(255, 255, 192));
ui.lblCertExp->setVisible(true);
}
else
palette.setColor(QPalette::Base, QColor(192, 255, 192));
ui.txtCertificate->setPalette(palette);
}
m_CertChanged = false;
}
theConf->SetValue("Options/CheckForUpdates", CSettingsWindow__Chk2Int(ui.chkAutoUpdate->checkState()));
theConf->SetValue("Options/DownloadUpdates", CSettingsWindow__Chk2Int(ui.chkAutoDownload->checkState()));
//theConf->SetValue("Options/InstallUpdates", CSettingsWindow__Chk2Int(ui.chkAutoInstall->checkState()));
theConf->SetValue("Options/NoSupportCheck", ui.chkNoCheck->isChecked());
emit OptionsChanged();
}
bool CSettingsWindow::ApplyCertificate(const QByteArray &Certificate, QWidget* widget)
{
QString CertPath = theAPI->GetSbiePath() + "\\Certificate.dat";
if (!Certificate.isEmpty()) {
@ -597,67 +632,43 @@ void CSettingsWindow::SaveSettings()
WindowsMoveFile(TempPath.replace("/", "\\"), CertPath.replace("/", "\\"));
}
else {
Certificate.clear();
QMessageBox::critical(this, "Sandboxie-Plus", tr("This does not look like a certificate, please enter the entire certificate not just a portion of it."));
QMessageBox::critical(widget, "Sandboxie-Plus", tr("This does not look like a certificate, please enter the entire certificate not just a portion of it."));
return false;
}
}
else if(!g_Certificate.isEmpty()){
WindowsMoveFile(CertPath.replace("/", "\\"), "");
}
if (theGUI->m_DarkTheme)
palette.setColor(QPalette::Text, Qt::black);
ui.lblCertExp->setVisible(false);
if (Certificate.isEmpty())
{
palette.setColor(QPalette::Base, Qt::white);
}
else if (!theAPI->ReloadCert().IsError())
return false;
if (!theAPI->ReloadCert().IsError())
{
g_FeatureFlags = theAPI->GetFeatureFlags();
theGUI->UpdateCertState();
if (g_CertInfo.expired || g_CertInfo.outdated) {
if(g_CertInfo.expired)
QMessageBox::information(this, "Sandboxie-Plus", tr("This certificate is unfortunately expired."));
QMessageBox::information(widget, "Sandboxie-Plus", tr("This certificate is unfortunately expired."));
else
QMessageBox::information(this, "Sandboxie-Plus", tr("This certificate is unfortunately outdated."));
palette.setColor(QPalette::Base, QColor(255, 255, 192));
ui.lblCertExp->setVisible(true);
QMessageBox::information(widget, "Sandboxie-Plus", tr("This certificate is unfortunately outdated."));
}
else {
QMessageBox::information(this, "Sandboxie-Plus", tr("Thank you for supporting the development of Sandboxie-Plus."));
palette.setColor(QPalette::Base, QColor(192, 255, 192));
}
}
else
{
QMessageBox::critical(this, "Sandboxie-Plus", tr("This support certificate is not valid."));
palette.setColor(QPalette::Base, QColor(255, 192, 192));
Certificate.clear();
g_CertInfo.State = 0;
QMessageBox::information(widget, "Sandboxie-Plus", tr("Thank you for supporting the development of Sandboxie-Plus."));
}
g_Certificate = Certificate;
ui.txtCertificate->setPalette(palette);
return true;
}
else
{
QMessageBox::critical(widget, "Sandboxie-Plus", tr("This support certificate is not valid."));
m_CertChanged = false;
g_CertInfo.State = 0;
g_Certificate.clear();
return false;
}
theConf->SetValue("Options/CheckForUpdates", CSettingsWindow__Chk2Int(ui.chkAutoUpdate->checkState()));
theConf->SetValue("Options/DownloadUpdates", CSettingsWindow__Chk2Int(ui.chkAutoDownload->checkState()));
//theConf->SetValue("Options/InstallUpdates", CSettingsWindow__Chk2Int(ui.chkAutoInstall->checkState()));
theConf->SetValue("Options/NoSupportCheck", ui.chkNoCheck->isChecked());
emit OptionsChanged();
}
void CSettingsWindow::apply()

View File

@ -24,6 +24,8 @@ public:
virtual void accept() {}
virtual void reject();
static bool ApplyCertificate(const QByteArray &Certificate, QWidget* widget);
static void LoadCertificate();
signals: