This commit is contained in:
DavidXanatos 2023-12-16 18:13:18 +01:00
parent 841fba9f60
commit 20320d1643
2 changed files with 20 additions and 15 deletions

View File

@ -294,17 +294,27 @@ void COnlineUpdater::LoadState()
QString COnlineUpdater::GetOnNewUpdateOption() const
{
QString OnNewUpdate = theConf->GetString("Options/OnNewUpdate", "ignore");
QString ReleaseChannel = theConf->GetString("Options/ReleaseChannel", "stable");
if (ReleaseChannel != "preview" && (!g_CertInfo.active || g_CertInfo.expired)) // allow revisions for preview channel
if (ReleaseChannel != "preview" && (!g_CertInfo.active || g_CertInfo.expired)) // without active cert, allow revisions for preview channel
return "ignore"; // this service requires a valid certificate
return theConf->GetString("Options/OnNewUpdate", "ignore");
return OnNewUpdate;
}
QString COnlineUpdater::GetOnNewReleaseOption() const
{
QString OnNewRelease = theConf->GetString("Options/OnNewRelease", "download");
if ((g_CertInfo.active && g_CertInfo.expired) && OnNewRelease == "install")
return "download"; // disable auto update on an active but expired personal certificate
if (OnNewRelease == "install" || OnNewRelease == "download") {
QString ReleaseChannel = theConf->GetString("Options/ReleaseChannel", "stable");
if (ReleaseChannel != "preview" && (!g_CertInfo.active || g_CertInfo.expired)) // without active cert, allow automated updates only for preview channel
return "notify"; // this service requires a valid certificate
}
//if ((g_CertInfo.active && g_CertInfo.expired) && OnNewRelease == "install")
// return "download"; // disable auto update on an active but expired personal certificate
return OnNewRelease;
}
@ -489,14 +499,6 @@ bool COnlineUpdater::HandleUpdate()
bool bAllowAuto = g_CertInfo.active && !g_CertInfo.expired; // To use automatic updates a valid certificate is required
//
// if we allow for version updates but not for automatic installation/download of new release
// ignore the release and install it using the version updater
//
if (bNewUpdate && bNewRelease && !bAllowAuto)
bNewRelease = false;
bool bCanRunInstaller = (m_CheckMode == eAuto && OnNewRelease == "install");
bool bIsInstallerReady = false;
if (bNewRelease)
@ -512,7 +514,7 @@ bool COnlineUpdater::HandleUpdate()
// clear when not up to date
theConf->DelValue("Updater/InstallerVersion");
if ((bAllowAuto && (bCanRunInstaller || (m_CheckMode == eAuto && OnNewRelease == "download"))) || AskDownload(Release, bAllowAuto))
if ((bCanRunInstaller || (m_CheckMode == eAuto && OnNewRelease == "download")) || AskDownload(Release, bAllowAuto))
{
if (DownloadInstaller(Release, m_CheckMode == eManual))
return true;

View File

@ -1395,25 +1395,28 @@ void CSettingsWindow::UpdateUpdater()
{
ui.cmbInterval->setEnabled(true);
bool bAllowAuto;
if (ui.radStable->isChecked() && !bOk) {
ui.cmbUpdate->setEnabled(false);
ui.cmbUpdate->setCurrentIndex(ui.cmbUpdate->findData("ignore"));
ui.lblRevision->setText(tr("Supporter certificate required for access"));
bAllowAuto = false;
} else {
ui.cmbUpdate->setEnabled(true);
ui.lblRevision->setText(QString());
bAllowAuto = true;
}
ui.cmbRelease->setEnabled(true);
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(ui.cmbRelease->model());
for (int i = 1; i < ui.cmbRelease->count(); i++) {
QStandardItem* item = model->item(i);
item->setFlags(bOk ? (item->flags() | Qt::ItemIsEnabled) : (item->flags() & ~Qt::ItemIsEnabled));
item->setFlags(bAllowAuto ? (item->flags() | Qt::ItemIsEnabled) : (item->flags() & ~Qt::ItemIsEnabled));
}
if(!bOk)
if(!bAllowAuto)
ui.lblRelease->setText(tr("Supporter certificate required for automation"));
else
ui.lblRelease->setText(QString());