Skip to content

Commit

Permalink
fix: tip for installation process
Browse files Browse the repository at this point in the history
Add the wine pre-depends flag function;
Add monitoring and tips for UAB file changes;
Adjust the hierarchical signature verification dialog.

Log: Fix tips for installation process.
  • Loading branch information
rb-union committed Oct 9, 2024
1 parent f36a69e commit c61008a
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 130 deletions.
32 changes: 19 additions & 13 deletions src/deb-installer/manager/packagesmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ PackageDependsStatus PackagesManager::checkDependsStatus(const QString &package_
}
}
}
installWineDepends = false; // 标记wine依赖下载线程开启
isDependsExists = false; // 标记多架构依赖冲突
m_pair.first.clear(); // 清空available依赖
m_pair.second.clear(); // 清空broken依赖
GlobalStatus::setWinePreDependsInstalling(false); // mark wine dependent download thread start
isDependsExists = false; // mark multi-schema dependency conflicts
m_pair.first.clear(); // clear available dependencies
m_pair.second.clear(); // clear the broken dependency
if (m_dependsPackages.contains(m_currentPkgMd5))
m_dependsPackages.remove(m_currentPkgMd5);

Expand Down Expand Up @@ -687,13 +687,16 @@ void PackagesManager::slotDealDependResult(int iAuthRes, int iIndex, const QStri
if (!m_errorIndex.contains(m_dependInstallMark[num]))
m_errorIndex.insert(m_dependInstallMark[num], iAuthRes);
}
if (installWineDepends) { // 下载wine依赖失败时,考虑出现依赖缺失的情况

// If the download of a wine dependency fails, might be the dependency is missing
if (GlobalStatus::winePreDependsInstalling()) {
qInfo() << "check wine depends again !" << iIndex;
getPackageDependsStatus(iIndex);
if (!m_dependsPackages.isEmpty()) {
qInfo() << m_dependsPackages.size() << m_dependsPackages.value(m_currentPkgMd5).second.size();
if (m_preparedPackages.size() > 1)
installWineDepends = false;
if (m_preparedPackages.size() > 1) {
GlobalStatus::setWinePreDependsInstalling(false);
}
}
}
emit signalEnableCloseButton(true);
Expand Down Expand Up @@ -808,10 +811,11 @@ PackageDependsStatus PackagesManager::getPackageDependsStatus(const int index)
}
}
}
installWineDepends = false; // 标记wine依赖下载线程开启
isDependsExists = false; // 标记多架构依赖冲突
m_pair.first.clear(); // 清空available依赖
m_pair.second.clear(); // 清空broken依赖

GlobalStatus::setWinePreDependsInstalling(false); // mark wine dependent download thread start
isDependsExists = false; // mark multi-schema dependency conflicts
m_pair.first.clear(); // clear available dependencies
m_pair.second.clear(); // clear the broken dependency
if (m_dependsPackages.contains(m_currentPkgMd5))
m_dependsPackages.remove(m_currentPkgMd5);

Expand All @@ -828,8 +832,10 @@ PackageDependsStatus PackagesManager::getPackageDependsStatus(const int index)
break;
}

if (!m_dependInstallMark.contains(currentPackageMd5)) { // 更换判断依赖错误的标记
installWineDepends = true;
if (!m_dependInstallMark.contains(currentPackageMd5)) {
// replace the marker that the depends error
GlobalStatus::setWinePreDependsInstalling(true);

if (!m_installWineThread->isRunning()) {
m_dependInstallMark.append(currentPackageMd5); // 依赖错误的软件包的标记 更改为md5取代验证下标
qInfo() << "PackagesManager:"
Expand Down
2 changes: 0 additions & 2 deletions src/deb-installer/manager/packagesmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,6 @@ private slots:
private:
AddPackageThread *m_pAddPackageThread = nullptr; // 添加包的线程

bool installWineDepends = false;

bool isDependsExists = false;

int m_validPackageCount = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/deb-installer/model/abstract_package_list_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class AbstractPackageListModel : public QAbstractListModel

// raw output of install/uninstall failures
virtual QString lastProcessError() = 0;
// a package signature verification fails
virtual bool containsSignatureFailed() const = 0;

// trigger install / uninstall
Q_SLOT virtual bool slotInstallPackages() = 0;
Expand Down
68 changes: 9 additions & 59 deletions src/deb-installer/model/deblistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "utils/utils.h"
#include "utils/hierarchicalverify.h"
#include "singleInstallerApplication.h"
#include "view/widgets/error_notify_dialog_helper.h"

#include <DDialog>
#include <DSysInfo>
Expand Down Expand Up @@ -211,7 +212,7 @@ void DebListModel::slotDealDependResult(int authType, int dependIndex, const QSt
case DebListModel::AuthDependsErr: // 安装失败后,状态的修改由debinstaller进行处理
break;
case DebListModel::VerifyDependsErr: // 依赖包分级管控验证签名失败,弹出分级设置提示框
showHierarchicalVerifyWindow();
ErrorNotifyDialogHelper::showHierarchicalVerifyWindow();
break;
default:
break;
Expand Down Expand Up @@ -322,6 +323,7 @@ bool DebListModel::slotInstallPackages()
m_operatingIndex = 0; // 初始化当前操作的index
m_operatingStatusIndex = 0;
m_operatingPackageMd5 = m_packageMd5[m_operatingIndex];
m_hierarchicalVerifyError = false;

// start first
initRowStatus(); // 初始化包的操作状态
Expand All @@ -342,6 +344,7 @@ bool DebListModel::slotUninstallPackage(int index)
m_operatingPackageMd5 = m_packageMd5[m_operatingIndex];
// fix bug : 卸载失败时不提示卸载失败。
m_operatingStatusIndex = index; // 刷新操作状态的index
m_hierarchicalVerifyError = false;

DebFile debFile(m_packagesManager->package(m_operatingIndex)); // 获取到包
if (!debFile.isValid())
Expand Down Expand Up @@ -455,6 +458,11 @@ QString DebListModel::lastProcessError()
return "failed";
}

bool DebListModel::containsSignatureFailed() const
{
return m_hierarchicalVerifyError;
}

QString DebListModel::checkPackageValid(const QString &package_path)
{
return m_packagesManager->checkPackageValid(QStringList(package_path));
Expand Down Expand Up @@ -528,12 +536,6 @@ void DebListModel::bumpInstallIndex()
emit signalWorkerFinished(); // 发送安装完成信号
emit signalWholeProgressChanged(100); // 修改安装进度
emit signalCurrentPacakgeProgressChanged(100);

// 安装结束,弹出分级管控信息提示框
if (m_hierarchicalVerifyError) {
showHierarchicalVerifyWindow();
m_hierarchicalVerifyError = false;
}
return;
}
++m_operatingStatusIndex;
Expand Down Expand Up @@ -1558,58 +1560,6 @@ void DebListModel::showProhibitWindow()
connect(Ddialog, &DDialog::rejected, exitOperate);
}

/**
@brief 弹出分级管控安全等级设置引导提示窗口
*/
void DebListModel::showHierarchicalVerifyWindow()
{
if (!HierarchicalVerify::instance()->isValid()) {
return;
}

DDialog *dialog = new DDialog();
// 限制显示宽度
dialog->setFixedWidth(380);
dialog->setFocusPolicy(Qt::TabFocus);
dialog->setModal(true);
dialog->setWindowFlag(Qt::WindowStaysOnTopHint);

// 设置弹出窗口显示的信息
dialog->setTitle(tr("Unable to install"));
dialog->setMessage(tr("This package does not have a valid digital signature and has been blocked from installing/running. "
"Go to Security Center > Tools > App Security to change the settings."));
dialog->setIcon(QIcon::fromTheme("di_popwarning"));
dialog->addButton(QString(tr("Cancel", "button")), false, DDialog::ButtonNormal);
dialog->addButton(QString(tr("Proceed", "button")), true, DDialog::ButtonRecommend);
dialog->show();

// 拷贝自 ddialog.cpp 用于设置默认对话框高度,避免在大字号/高缩放比下显示不全,在 show() 之后调用。
QLabel *msgLabel = dialog->findChild<QLabel *>("MessageLabel");
if (msgLabel) {
auto dialogStyle = dialog->style();
if (dialogStyle) {
QSize sz =
dialogStyle->itemTextRect(msgLabel->fontMetrics(), msgLabel->rect(), Qt::TextWordWrap, false, msgLabel->text())
.size();
msgLabel->setMinimumHeight(qMax(sz.height(), msgLabel->sizeHint().height()));
}
}

QPushButton *btnPorceed = qobject_cast<QPushButton *>(dialog->getButton(1));
btnPorceed->setFocusPolicy(Qt::TabFocus);
btnPorceed->setFocus();

// 窗口退出操作,包括所有可以退出此窗口的操作
std::function<void(void)> exitOperate = [dialog]() { dialog->deleteLater(); };

connect(dialog, &DDialog::finished, [dialog](int result) {
if (QDialog::Accepted == result) {
HierarchicalVerify::instance()->proceedDefenderSafetyPage();
}
dialog->deleteLater();
});
}

bool DebListModel::checkBlackListApplication()
{
PackageDependsStatus dependsStat = m_packagesManager->getPackageDependsStatus(m_operatingIndex);
Expand Down
6 changes: 1 addition & 5 deletions src/deb-installer/model/deblistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class DebListModel : public AbstractPackageListModel
QStringList getPackageInfo(const QString &package_path) override;

QString lastProcessError() override;
bool containsSignatureFailed() const override;

/**
* @brief checkPackageValid 查找指定包信息
Expand Down Expand Up @@ -399,11 +400,6 @@ private slots:
*/
void showProhibitWindow();

/**
* @brief showHierarchicalVerifyWindow 弹出分级管控安全等级设置引导提示窗口
*/
void showHierarchicalVerifyWindow();

/**
* @brief 检查当前将要安装的包是否在黑名单中。
*
Expand Down
12 changes: 10 additions & 2 deletions src/deb-installer/model/proxy_package_list_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ QString ProxyPackageListModel::lastProcessError()
return errorMessage;
}

bool ProxyPackageListModel::containsSignatureFailed() const
{
auto findItr = std::find_if(m_packageModels.begin(), m_packageModels.end(), [](const ModelInfo &info) {
return info.model->containsSignatureFailed();
});
return findItr != m_packageModels.end();
}

bool ProxyPackageListModel::slotInstallPackages()
{
if (!isWorkerPrepare()) {
Expand Down Expand Up @@ -329,7 +337,7 @@ QPair<ProxyPackageListModel::ModelPtr, int> ProxyPackageListModel::findFromProxy
return qMakePair(nullptr, -1);
}

int ProxyPackageListModel::proxyIndexFormModel(ModelPtr findModel, int index)
int ProxyPackageListModel::proxyIndexFromModel(ModelPtr findModel, int index)
{
if (m_packageModels.isEmpty()) {
return -1;
Expand Down Expand Up @@ -409,7 +417,7 @@ void ProxyPackageListModel::onSourceCurrentProcessPackageIndex(int index)
return;
}

const int proxyIndex = proxyIndexFormModel(sendModel, index);
const int proxyIndex = proxyIndexFromModel(sendModel, index);
Q_EMIT signalCurrentProcessPackageIndex(proxyIndex);

} else {
Expand Down
3 changes: 2 additions & 1 deletion src/deb-installer/model/proxy_package_list_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ProxyPackageListModel : public AbstractPackageListModel
Pkg::DependsStatus checkDependsStatus(const QString &packagePath) override;
QStringList getPackageInfo(const QString &packagePath) override;
QString lastProcessError() override;
bool containsSignatureFailed() const override;

Q_SLOT bool slotInstallPackages() override;
Q_SLOT bool slotUninstallPackage(int index) override;
Expand All @@ -44,7 +45,7 @@ class ProxyPackageListModel : public AbstractPackageListModel
void connectModel(ModelPtr model);

QPair<ModelPtr, int> findFromProxyIndex(int proxyIndex) const;
int proxyIndexFormModel(ModelPtr findModel, int index);
int proxyIndexFromModel(ModelPtr findModel, int index);

// signals forwarded through
Q_SLOT void onSourcePacakgeCountChanged(int count);
Expand Down
1 change: 0 additions & 1 deletion src/deb-installer/singleInstallerApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ bool SingleInstallerApplication::parseCmdLine()
bIsDbus = true;
}
} else {
QStringList paraList = parser.positionalArguments();
for (auto it : paraList) {
if (it.endsWith("ddim")) {
m_ddimFiles.append(it);
Expand Down
20 changes: 19 additions & 1 deletion src/deb-installer/uab/uab_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

namespace Uab {

/**
* @class UabPackage
* @brief Uab package, contains package information and runtime status.
* Store version, install status, operation status, error code, and error message.
*/
UabPackage::UabPackage(const UabPkgInfo::Ptr &metaPtr)
: m_metaPtr(metaPtr)
{
Expand All @@ -21,7 +26,7 @@ const UabPkgInfo::Ptr &UabPackage::info() const

bool UabPackage::isValid() const
{
if (!m_metaPtr) {
if (!m_metaPtr || !fileExists()) {
return false;
}

Expand Down Expand Up @@ -50,6 +55,16 @@ void UabPackage::setProcessError(Pkg::ErrorCode err, const QString &errorString)
m_processError = errorString;
}

bool UabPackage::fileExists() const
{
return m_exists;
}

void UabPackage::markNotExists()
{
m_exists = false;
}

Pkg::DependsStatus UabPackage::dependsStatus() const
{
return m_dependsStatus;
Expand Down Expand Up @@ -113,6 +128,9 @@ void UabPackage::reset()
m_installedVersion.clear();
m_installStatus = Pkg::NotInstalled;

m_errorCode = Pkg::NoError;
m_processError.clear();

if (!Uab::UabBackend::instance()->linglongExists()) {
setDependsStatus(Pkg::DependsBreak);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/deb-installer/uab/uab_package.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class UabPackage
bool isValid() const;
void setDependsStatus(Pkg::DependsStatus status);
void setProcessError(Pkg::ErrorCode err, const QString &errorString);
bool fileExists() const;
void markNotExists();

Pkg::DependsStatus dependsStatus() const;
Pkg::PackageInstallStatus installStatus() const;
Expand All @@ -40,6 +42,8 @@ class UabPackage
private:
Uab::UabPkgInfo::Ptr m_metaPtr;

bool m_exists{true};

Pkg::DependsStatus m_dependsStatus{Pkg::DependsOk}; // package's depends info
Pkg::PackageInstallStatus m_installStatus{Pkg::NotInstalled}; // version check
Pkg::PackageOperationStatus m_operationStatus{Pkg::Prepare}; // status for operation flow
Expand Down
Loading

0 comments on commit c61008a

Please sign in to comment.