diff --git a/Apper/Settings/Settings.cpp b/Apper/Settings/Settings.cpp index 8154aa9..1d78828 100644 --- a/Apper/Settings/Settings.cpp +++ b/Apper/Settings/Settings.cpp @@ -1,334 +1,332 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "Settings.h" #include "ui_Settings.h" #include "OriginModel.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace PackageKit; Settings::Settings(Transaction::Roles roles, QWidget *parent) : QWidget(parent), ui(new Ui::Settings), m_roles(roles) { ui->setupUi(this); auto action = new QAction(i18n("Refresh Cache"), this); connect(action, &QAction::triggered, this, &Settings::refreshCache); connect(action, &QAction::triggered, ui->messageWidget, &KMessageWidget::animatedHide); ui->messageWidget->addAction(action); ui->messageWidget->setText(i18n("A repository was changed, it's highly recommended to refresh the cache")); ui->messageWidget->hide(); if (!(m_roles & Transaction::RoleRefreshCache)) { ui->intervalL->setEnabled(false); ui->intervalCB->setEnabled(false); } if (!(m_roles & Transaction::RoleGetDistroUpgrades)) { ui->distroIntervalCB->setEnabled(false); } m_originModel = new OriginModel(this); connect(m_originModel, &OriginModel::refreshRepoList, this, &Settings::refreshRepoModel); connect(m_originModel, &OriginModel::refreshRepoList, ui->messageWidget, &KMessageWidget::animatedShow); auto proxy = new QSortFilterProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(m_originModel); ui->originTV->setModel(proxy); ui->originTV->header()->setDefaultAlignment(Qt::AlignCenter); // This is needed to keep the oring right ui->originTV->header()->setSortIndicator(0, Qt::AscendingOrder); proxy->sort(0); if (!(m_roles & Transaction::RoleGetRepoList)) { // Disables the group box ui->originTV->setEnabled(false); ui->showOriginsCB->setEnabled(false); } ui->distroIntervalCB->addItem(i18nc("Inform about distribution upgrades", "Never"), Enum::DistroNever); ui->distroIntervalCB->addItem(i18nc("Inform about distribution upgrades", "Only stable"), Enum::DistroStable); // Ignore unstable distros upgrades for now #ifndef false ui->distroIntervalCB->addItem(i18nc("Inform about distribution upgrades", "Stable and development"), Enum::DistroDevelopment); #endif ui->intervalCB->addItem(i18nc("Hourly refresh the package cache", "Hourly"), Enum::Hourly); ui->intervalCB->addItem(i18nc("Daily refresh the package cache", "Daily"), Enum::Daily); ui->intervalCB->addItem(i18nc("Weekly refresh the package cache", "Weekly"), Enum::Weekly); ui->intervalCB->addItem(i18nc("Monthly refresh the package cache", "Monthly"), Enum::Monthly); ui->intervalCB->addItem(i18nc("Never refresh package cache", "Never"), Enum::Never); ui->autoCB->addItem(i18nc("No updates will be automatically installed", "None"), Enum::None); ui->autoCB->addItem(i18n("Download only"), Enum::DownloadOnly); ui->autoCB->addItem(i18n("Security only"), Enum::Security); ui->autoCB->addItem(i18n("All updates"), Enum::All); connect(ui->autoConfirmCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); connect(ui->appLauncherCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); connect(ui->distroIntervalCB, QOverload::of(&KComboBox::currentIndexChanged), this, &Settings::checkChanges); connect(ui->intervalCB, QOverload::of(&KComboBox::currentIndexChanged), this, &Settings::checkChanges); connect(ui->checkUpdatesBatteryCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); connect(ui->checkUpdatesMobileCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); connect(ui->autoCB, QOverload::of(&KComboBox::currentIndexChanged), this, &Settings::checkChanges); connect(ui->installUpdatesBatteryCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); connect(ui->installUpdatesMobileCB, &QCheckBox::stateChanged, this, &Settings::checkChanges); // Setup the busy cursor m_busySeq = new KPixmapSequenceOverlayPainter(this); m_busySeq->setSequence(KPixmapSequence("process-working", KIconLoader::SizeSmallMedium)); m_busySeq->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); m_busySeq->setWidget(ui->originTV->viewport()); #ifndef EDIT_ORIGNS_DESKTOP_NAME ui->editOriginsPB->hide(); #endif //EDIT_ORIGNS_DESKTOP_NAME } Settings::~Settings() { delete ui; } void Settings::on_editOriginsPB_clicked() { #ifdef EDIT_ORIGNS_DESKTOP_NAME KToolInvocation::startServiceByDesktopName(EDIT_ORIGNS_DESKTOP_NAME); #endif //EDIT_ORIGNS_DESKTOP_NAME } void Settings::refreshRepoModel() { on_showOriginsCB_stateChanged(ui->showOriginsCB->checkState()); } // TODO update the repo list connecting to repo changed signal void Settings::on_showOriginsCB_stateChanged(int state) { Transaction *transaction = Daemon::getRepoList(state == Qt::Checked ? Transaction::FilterNone : Transaction::FilterNotDevel); connect(transaction, &Transaction::repoDetail, m_originModel, &OriginModel::addOriginItem); connect(transaction, &Transaction::finished, m_originModel, &OriginModel::finished); connect(transaction, &Transaction::finished, m_busySeq, &KPixmapSequenceOverlayPainter::stop); connect(transaction, &Transaction::finished, this, &Settings::checkChanges); m_busySeq->start(); KConfig config("apper"); KConfigGroup originsDialog(&config, "originsDialog"); bool showDevel = originsDialog.readEntry("showDevel", false); if (showDevel != ui->showOriginsCB->isChecked()) { originsDialog.writeEntry("showDevel", ui->showOriginsCB->isChecked()); } } bool Settings::hasChanges() const { KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); KConfigGroup transaction(&config, "Transaction"); KConfigGroup checkUpdateGroup(&config, "CheckUpdate"); if (ui->distroIntervalCB->itemData(ui->distroIntervalCB->currentIndex()).toUInt() != static_cast(checkUpdateGroup.readEntry(CFG_DISTRO_UPGRADE, Enum::DistroUpgradeDefault)) || ui->intervalCB->itemData(ui->intervalCB->currentIndex()).toUInt() != static_cast(checkUpdateGroup.readEntry(CFG_INTERVAL, Enum::TimeIntervalDefault)) || ui->checkUpdatesBatteryCB->isChecked() != checkUpdateGroup.readEntry(CFG_CHECK_UP_BATTERY, DEFAULT_CHECK_UP_BATTERY) || ui->checkUpdatesMobileCB->isChecked() != checkUpdateGroup.readEntry(CFG_CHECK_UP_MOBILE, DEFAULT_CHECK_UP_MOBILE) || ui->autoCB->itemData(ui->autoCB->currentIndex()).toUInt() != static_cast(checkUpdateGroup.readEntry(CFG_AUTO_UP, Enum::AutoUpdateDefault)) || ui->installUpdatesBatteryCB->isChecked() != checkUpdateGroup.readEntry(CFG_INSTALL_UP_BATTERY, DEFAULT_INSTALL_UP_BATTERY) || ui->installUpdatesMobileCB->isChecked() != checkUpdateGroup.readEntry(CFG_INSTALL_UP_MOBILE, DEFAULT_INSTALL_UP_MOBILE) || ui->autoConfirmCB->isChecked() != !requirementsDialog.readEntry("autoConfirm", false) || ui->appLauncherCB->isChecked() != transaction.readEntry("ShowApplicationLauncher", true)) { return true; } return false; } void Settings::checkChanges() { emit changed(hasChanges()); // Check if interval update is never bool enabled = ui->intervalCB->itemData(ui->intervalCB->currentIndex()).toUInt() != Enum::Never; ui->checkUpdatesBatteryCB->setEnabled(enabled); ui->checkUpdatesMobileCB->setEnabled(enabled); ui->autoInsL->setEnabled(enabled); ui->autoCB->setEnabled(enabled); if (enabled) { enabled = ui->autoCB->itemData(ui->autoCB->currentIndex()).toUInt() != Enum::None; } ui->installUpdatesMobileCB->setEnabled(enabled); ui->installUpdatesBatteryCB->setEnabled(enabled); } void Settings::load() { KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); ui->autoConfirmCB->setChecked(!requirementsDialog.readEntry("autoConfirm", false)); KConfigGroup transaction(&config, "Transaction"); ui->appLauncherCB->setChecked(transaction.readEntry("ShowApplicationLauncher", true)); KConfigGroup checkUpdateGroup(&config, "CheckUpdate"); uint distroUpgrade = checkUpdateGroup.readEntry(CFG_DISTRO_UPGRADE, Enum::DistroUpgradeDefault); int ret = ui->distroIntervalCB->findData(distroUpgrade); if (ret == -1) { ui->distroIntervalCB->setCurrentIndex(ui->distroIntervalCB->findData(Enum::DistroUpgradeDefault)); } else { ui->distroIntervalCB->setCurrentIndex(ret); } uint interval = checkUpdateGroup.readEntry(CFG_INTERVAL, Enum::TimeIntervalDefault); ret = ui->intervalCB->findData(interval); if (ret == -1) { // this is if someone change the file by hand... - KFormat f; -// ui->intervalCB->addItem(KLocale::global()->prettyFormatDuration(interval * 1000), interval); - ui->intervalCB->addItem(f.formatDuration(interval * 1000), interval); + ui->intervalCB->addItem(KFormat().formatSpelloutDuration(interval * 1000), interval); ui->intervalCB->setCurrentIndex(ui->intervalCB->count() - 1); } else { ui->intervalCB->setCurrentIndex(ret); } ui->checkUpdatesBatteryCB->setChecked(checkUpdateGroup.readEntry(CFG_CHECK_UP_BATTERY, DEFAULT_CHECK_UP_BATTERY)); ui->checkUpdatesMobileCB->setChecked(checkUpdateGroup.readEntry(CFG_CHECK_UP_MOBILE, DEFAULT_CHECK_UP_MOBILE)); uint autoUpdate = checkUpdateGroup.readEntry(CFG_AUTO_UP, Enum::AutoUpdateDefault); ret = ui->autoCB->findData(autoUpdate); if (ret == -1) { // this is if someone change the file by hand... ui->autoCB->setCurrentIndex(ui->autoCB->findData(Enum::AutoUpdateDefault)); } else { ui->autoCB->setCurrentIndex(ret); } ui->installUpdatesBatteryCB->setChecked(checkUpdateGroup.readEntry(CFG_INSTALL_UP_BATTERY, DEFAULT_INSTALL_UP_BATTERY)); ui->installUpdatesMobileCB->setChecked(checkUpdateGroup.readEntry(CFG_INSTALL_UP_MOBILE, DEFAULT_INSTALL_UP_MOBILE)); // Load origns list if (m_roles & Transaction::RoleGetRepoList) { KConfigGroup originsDialog(&config, "originsDialog"); bool showDevel = originsDialog.readEntry("showDevel", false); ui->showOriginsCB->setChecked(showDevel); refreshRepoModel(); ui->originTV->setEnabled(true); } else { ui->originTV->setEnabled(false); } // hide battery options if we are on a desktop computer const QList listBattery = Solid::Device::listFromType(Solid::DeviceInterface::Battery, QString()); bool notFound = true; for (const Solid::Device &device : listBattery) { const Solid::Battery *battery = device.as(); if (battery && battery->type() == Solid::Battery::PrimaryBattery) { notFound = false; break; } } if (notFound) { ui->checkUpdatesBatteryCB->hide(); ui->installUpdatesBatteryCB->hide(); } } void Settings::save() { KConfig config("apper"); KConfigGroup requirementsDialog(&config, "requirementsDialog"); requirementsDialog.writeEntry("autoConfirm", !ui->autoConfirmCB->isChecked()); KConfigGroup transaction(&config, "Transaction"); transaction.writeEntry("ShowApplicationLauncher", ui->appLauncherCB->isChecked()); KConfigGroup checkUpdateGroup(&config, "CheckUpdate"); checkUpdateGroup.writeEntry("distroUpgrade", ui->distroIntervalCB->itemData(ui->distroIntervalCB->currentIndex()).toUInt()); checkUpdateGroup.writeEntry("interval", ui->intervalCB->itemData(ui->intervalCB->currentIndex()).toUInt()); checkUpdateGroup.writeEntry("checkUpdatesOnBattery", ui->checkUpdatesBatteryCB->isChecked()); checkUpdateGroup.writeEntry("checkUpdatesOnMobile", ui->checkUpdatesMobileCB->isChecked()); checkUpdateGroup.writeEntry("autoUpdate", ui->autoCB->itemData(ui->autoCB->currentIndex()).toUInt()); checkUpdateGroup.writeEntry("installUpdatesOnBattery", ui->installUpdatesBatteryCB->isChecked()); checkUpdateGroup.writeEntry("installUpdatesOnMobile", ui->installUpdatesMobileCB->isChecked()); } void Settings::defaults() { ui->autoConfirmCB->setChecked(true); ui->appLauncherCB->setChecked(true); ui->distroIntervalCB->setCurrentIndex(ui->distroIntervalCB->findData(Enum::DistroUpgradeDefault)); ui->intervalCB->setCurrentIndex(ui->intervalCB->findData(Enum::TimeIntervalDefault)); ui->autoCB->setCurrentIndex(ui->autoCB->findData(Enum::AutoUpdateDefault) ); checkChanges(); } void Settings::showGeneralSettings() { ui->stackedWidget->setCurrentIndex(0); } void Settings::showRepoSettings() { ui->stackedWidget->setCurrentIndex(1); } diff --git a/Apper/TransactionHistory.cpp b/Apper/TransactionHistory.cpp index ef62a34..238c556 100644 --- a/Apper/TransactionHistory.cpp +++ b/Apper/TransactionHistory.cpp @@ -1,87 +1,86 @@ /*************************************************************************** * Copyright (C) 2009-2010 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "TransactionHistory.h" #include "TransactionFilterModel.h" #include "TransactionModel.h" #include #include #include #include #include #include #include #include TransactionHistory::TransactionHistory(QWidget *parent) : QWidget(parent) { setupUi(this); m_transactionModel = new TransactionModel(this); m_proxyModel = new TransactionFilterModel(this); m_proxyModel->setSourceModel(m_transactionModel); m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_proxyModel->setFilterKeyColumn(-1); treeView->setModel(m_proxyModel); treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); // Get the data refreshList(); } TransactionHistory::~TransactionHistory() { } void TransactionHistory::setFilterRegExp(const QString ®exp) { m_proxyModel->setFilterRegExp(regexp); } void TransactionHistory::on_treeView_customContextMenuRequested(const QPoint &pos) { auto menu = new QMenu(this); QAction *action; action = menu->addAction(i18n("Refresh transactions list")); connect(action, &QAction::triggered, this, &TransactionHistory::refreshList); menu->exec(treeView->viewport()->mapToGlobal(pos)); delete menu; } void TransactionHistory::refreshList() { // Refresh transaction list m_transactionModel->clear(); Transaction *transaction = Daemon::getOldTransactions(0); connect(transaction, &Transaction::transaction, m_transactionModel, &TransactionModel::addTransaction); // Refresh time QString text; uint time = Daemon::global()->getTimeSinceAction(Transaction::RoleRefreshCache) * 1000; -// text = i18n("Time since last cache refresh: %1", KLocale::global()->prettyFormatDuration(time)); - text = i18n("Time since last cache refresh: %1", KFormat().formatDuration(time)); + text = i18n("Time since last cache refresh: %1", KFormat().formatSpelloutDuration(time)); timeCacheLabel->setText(text); } diff --git a/libapper/CustomProgressBar.cpp b/libapper/CustomProgressBar.cpp index 66298c2..f8193a3 100644 --- a/libapper/CustomProgressBar.cpp +++ b/libapper/CustomProgressBar.cpp @@ -1,51 +1,49 @@ /*************************************************************************** * Copyright (C) 2009-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "CustomProgressBar.h" #include #include CustomProgressBar::CustomProgressBar(QWidget *parent) : QProgressBar(parent), m_remaining(0) { } CustomProgressBar::~CustomProgressBar() { } QString CustomProgressBar::text() const { if (m_remaining) { - KFormat f; -// return i18n("%1 remaining", f.prettyFormatDuration(m_remaining * 1000)); - return i18n("%1 remaining", f.formatDuration(m_remaining * 1000)); + return i18n("%1 remaining", KFormat().formatSpelloutDuration(m_remaining * 1000)); } else { return QProgressBar::text(); } } void CustomProgressBar::setRemaining(uint remaining) { m_remaining = remaining; } #include "moc_CustomProgressBar.cpp" diff --git a/libapper/PkStrings.cpp b/libapper/PkStrings.cpp index cb26064..be1819d 100644 --- a/libapper/PkStrings.cpp +++ b/libapper/PkStrings.cpp @@ -1,1063 +1,1070 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "PkStrings.h" #include #include //#include #include Q_DECLARE_LOGGING_CATEGORY(APPER_LIB) using namespace PackageKit; QString PkStrings::status(Transaction::Status status, uint speed, qulonglong downloadRemaining) { switch (status) { case Transaction::StatusUnknown: return i18nc("This is when the transaction status is not known", "Unknown state"); case Transaction::StatusSetup: return i18nc("transaction state, the daemon is in the process of starting", "Waiting for service to start"); case Transaction::StatusWait: return i18nc("transaction state, the transaction is waiting for another to complete", "Waiting for other tasks"); case Transaction::StatusRunning : return i18nc("transaction state, just started", "Running task"); case Transaction::StatusQuery : return i18nc("transaction state, is querying data", "Querying"); case Transaction::StatusInfo : return i18nc("transaction state, getting data from a server", "Getting information"); case Transaction::StatusRemove : return i18nc("transaction state, removing packages", "Removing packages"); case Transaction::StatusDownload: if (speed != 0 && downloadRemaining != 0) { KFormat f; return i18nc("transaction state, downloading package files", "Downloading at %1/s, %2 remaining", f.formatByteSize(speed), f.formatByteSize(downloadRemaining)); } else if (speed != 0 && downloadRemaining == 0) { KFormat f; return i18nc("transaction state, downloading package files", "Downloading at %1/s", f.formatByteSize(speed)); } else if (speed == 0 && downloadRemaining != 0) { KFormat f; return i18nc("transaction state, downloading package files", "Downloading, %1 remaining", f.formatByteSize(downloadRemaining)); } else { return i18nc("transaction state, downloading package files", "Downloading"); } case Transaction::StatusInstall : return i18nc("transaction state, installing packages", "Installing packages"); case Transaction::StatusRefreshCache : return i18nc("transaction state, refreshing internal lists", "Refreshing software list"); case Transaction::StatusUpdate : return i18nc("transaction state, installing updates", "Updating packages"); case Transaction::StatusCleanup : return i18nc("transaction state, removing old packages, and cleaning config files", "Cleaning up packages"); case Transaction::StatusObsolete : return i18nc("transaction state, obsoleting old packages", "Obsoleting packages"); case Transaction::StatusDepResolve : return i18nc("transaction state, checking the transaction before we do it", "Resolving dependencies"); case Transaction::StatusSigCheck : return i18nc("transaction state, checking if we have all the security keys for the operation", "Checking signatures"); case Transaction::StatusTestCommit : return i18nc("transaction state, when we're doing a test transaction", "Testing changes"); case Transaction::StatusCommit : return i18nc("transaction state, when we're writing to the system package database", "Committing changes"); case Transaction::StatusRequest : return i18nc("transaction state, requesting data from a server", "Requesting data"); case Transaction::StatusFinished : return i18nc("transaction state, all done!", "Finished"); case Transaction::StatusCancel : return i18nc("transaction state, in the process of cancelling", "Cancelling"); case Transaction::StatusDownloadRepository : return i18nc("transaction state, downloading metadata", "Downloading repository information"); case Transaction::StatusDownloadPackagelist : return i18nc("transaction state, downloading metadata", "Downloading list of packages"); case Transaction::StatusDownloadFilelist : return i18nc("transaction state, downloading metadata", "Downloading file lists"); case Transaction::StatusDownloadChangelog : return i18nc("transaction state, downloading metadata", "Downloading lists of changes"); case Transaction::StatusDownloadGroup : return i18nc("transaction state, downloading metadata", "Downloading groups"); case Transaction::StatusDownloadUpdateinfo : return i18nc("transaction state, downloading metadata", "Downloading update information"); case Transaction::StatusRepackaging : return i18nc("transaction state, repackaging delta files", "Repackaging files"); case Transaction::StatusLoadingCache : return i18nc("transaction state, loading databases", "Loading cache"); case Transaction::StatusScanApplications : return i18nc("transaction state, scanning for running processes", "Scanning installed applications"); case Transaction::StatusGeneratePackageList : return i18nc("transaction state, generating a list of packages installed on the system", "Generating package lists"); case Transaction::StatusWaitingForLock : return i18nc("transaction state, when we're waiting for the native tools to exit", "Waiting for package manager lock"); case Transaction::StatusWaitingForAuth : return i18nc("waiting for user to type in a password", "Waiting for authentication"); case Transaction::StatusScanProcessList : return i18nc("we are updating the list of processes", "Updating the list of running applications"); case Transaction::StatusCheckExecutableFiles : return i18nc("we are checking executable files in use", "Checking for applications currently in use"); case Transaction::StatusCheckLibraries : return i18nc("we are checking for libraries in use", "Checking for libraries currently in use"); case Transaction::StatusCopyFiles : return i18nc("we are copying package files to prepare to install", "Copying files"); + case Transaction::StatusRunHook : + return i18nc("we are running hooks pre or post transaction", + "Running hooks"); } qCWarning(APPER_LIB) << "status unrecognised: " << status; return QString(); } QString PkStrings::status(int status, uint speed, qulonglong downloadRemaining) { return PkStrings::status(static_cast(status), speed, downloadRemaining); } QString PkStrings::statusPast(Transaction::Status status) { switch (status) { case Transaction::StatusDownload: return i18nc("The action of the package, in past tense", "Downloaded"); case Transaction::StatusUpdate: return i18nc("The action of the package, in past tense", "Updated"); case Transaction::StatusInstall: return i18nc("The action of the package, in past tense", "Installed"); case Transaction::StatusRemove: return i18nc("The action of the package, in past tense", "Removed"); case Transaction::StatusCleanup: return i18nc("The action of the package, in past tense", "Cleaned Up"); case Transaction::StatusObsolete: return i18nc("The action of the package, in past tense", "Obsoleted"); default : // In this case we don't want to map all enums qCWarning(APPER_LIB) << "status unrecognised: " << status; return QString(); } } QString PkStrings::action(Transaction::Role role, Transaction::TransactionFlags flags) { switch (role) { case Transaction::RoleUnknown : return i18nc("The role of the transaction, in present tense", "Unknown role type"); case Transaction::RoleDependsOn : return i18nc("The role of the transaction, in present tense", "Getting dependencies"); case Transaction::RoleGetUpdateDetail : return i18nc("The role of the transaction, in present tense", "Getting update detail"); case Transaction::RoleGetDetails: case Transaction::RoleGetDetailsLocal: return i18nc("The role of the transaction, in present tense", "Getting details"); case Transaction::RoleRequiredBy : return i18nc("The role of the transaction, in present tense", "Getting requires"); case Transaction::RoleGetUpdates : return i18nc("The role of the transaction, in present tense", "Getting updates"); case Transaction::RoleSearchDetails : return i18nc("The role of the transaction, in present tense", "Searching details"); case Transaction::RoleSearchFile : return i18nc("The role of the transaction, in present tense", "Searching for file"); case Transaction::RoleSearchGroup : return i18nc("The role of the transaction, in present tense", "Searching groups"); case Transaction::RoleSearchName : return i18nc("The role of the transaction, in present tense", "Searching by package name"); case Transaction::RoleRemovePackages : if (flags & Transaction::TransactionFlagSimulate) { return i18nc("The role of the transaction, in present tense", "Simulating removal"); } else if (flags & Transaction::TransactionFlagOnlyDownload) { return i18nc("The role of the transaction, in present tense", "Downloading packages"); } return i18nc("The role of the transaction, in present tense", "Removing"); case Transaction::RoleInstallPackages : if (flags & Transaction::TransactionFlagSimulate) { return i18nc("The role of the transaction, in present tense", "Simulating install"); } else if (flags & Transaction::TransactionFlagOnlyDownload) { return i18nc("The role of the transaction, in present tense", "Downloading packages"); } return i18nc("The role of the transaction, in present tense", "Installing"); case Transaction::RoleInstallFiles : if (flags & Transaction::TransactionFlagSimulate) { return i18nc("The role of the transaction, in present tense", "Simulating file install"); } else if (flags & Transaction::TransactionFlagOnlyDownload) { return i18nc("The role of the transaction, in present tense", "Downloading required packages"); } return i18nc("The role of the transaction, in present tense", "Installing file"); case Transaction::RoleRefreshCache : return i18nc("The role of the transaction, in present tense", "Refreshing package cache"); case Transaction::RoleUpdatePackages : if (flags & Transaction::TransactionFlagSimulate) { return i18nc("The role of the transaction, in present tense", "Simulating update"); } else if (flags & Transaction::TransactionFlagOnlyDownload) { return i18nc("The role of the transaction, in present tense", "Downloading updates"); } return i18nc("The role of the transaction, in present tense", "Updating packages"); case Transaction::RoleCancel : return i18nc("The role of the transaction, in present tense", "Canceling"); case Transaction::RoleGetRepoList : return i18nc("The role of the transaction, in present tense", "Getting list of repositories"); case Transaction::RoleRepoEnable : return i18nc("The role of the transaction, in present tense", "Enabling repository"); case Transaction::RoleRepoSetData : return i18nc("The role of the transaction, in present tense", "Setting repository data"); case Transaction::RoleResolve : return i18nc("The role of the transaction, in present tense", "Resolving"); case Transaction::RoleGetFiles: case Transaction::RoleGetFilesLocal: return i18nc("The role of the transaction, in present tense", "Getting file list"); case Transaction::RoleWhatProvides : return i18nc("The role of the transaction, in present tense", "Getting what provides"); case Transaction::RoleInstallSignature : return i18nc("The role of the transaction, in present tense", "Installing signature"); case Transaction::RoleGetPackages : return i18nc("The role of the transaction, in present tense", "Getting package lists"); case Transaction::RoleAcceptEula : return i18nc("The role of the transaction, in present tense", "Accepting EULA"); case Transaction::RoleDownloadPackages : return i18nc("The role of the transaction, in present tense", "Downloading packages"); case Transaction::RoleGetDistroUpgrades : return i18nc("The role of the transaction, in present tense", "Getting distribution upgrade information"); case Transaction::RoleGetCategories : return i18nc("The role of the transaction, in present tense", "Getting categories"); case Transaction::RoleGetOldTransactions : return i18nc("The role of the transaction, in present tense", "Getting old transactions"); case Transaction::RoleRepairSystem : return i18nc("The role of the transaction, in present tense", "Repairing system"); case Transaction::RoleRepoRemove: return i18nc("The role of the transaction, in present tense", "Removing repository"); + case Transaction::RoleUpgradeSystem: + return i18nc("The role of the transaction, in present tense", "Upgrading the system"); } qCWarning(APPER_LIB) << "action unrecognised: " << role; return QString(); } QString PkStrings::action(int role, int flags) { return PkStrings::action(static_cast(role), static_cast(flags)); } QString PkStrings::actionPast(Transaction::Role action) { switch (action) { case Transaction::RoleUnknown: return i18nc("The role of the transaction, in past tense", "Unknown role type"); case Transaction::RoleDependsOn : return i18nc("The role of the transaction, in past tense", "Got dependencies"); case Transaction::RoleGetUpdateDetail : return i18nc("The role of the transaction, in past tense", "Got update detail"); case Transaction::RoleGetDetails: case Transaction::RoleGetDetailsLocal: return i18nc("The role of the transaction, in past tense", "Got details"); case Transaction::RoleRequiredBy : return i18nc("The role of the transaction, in past tense", "Got requires"); case Transaction::RoleGetUpdates : return i18nc("The role of the transaction, in past tense", "Got updates"); case Transaction::RoleSearchDetails : return i18nc("The role of the transaction, in past tense", "Searched for package details"); case Transaction::RoleSearchFile : return i18nc("The role of the transaction, in past tense", "Searched for file"); case Transaction::RoleSearchGroup : return i18nc("The role of the transaction, in past tense", "Searched groups"); case Transaction::RoleSearchName : return i18nc("The role of the transaction, in past tense", "Searched for package name"); case Transaction::RoleRemovePackages : return i18nc("The role of the transaction, in past tense", "Removed packages"); case Transaction::RoleInstallPackages : return i18nc("The role of the transaction, in past tense", "Installed packages"); case Transaction::RoleInstallFiles : return i18nc("The role of the transaction, in past tense", "Installed local files"); case Transaction::RoleRefreshCache : return i18nc("The role of the transaction, in past tense", "Refreshed package cache"); case Transaction::RoleUpdatePackages : return i18nc("The role of the transaction, in past tense", "Updated packages"); case Transaction::RoleCancel : return i18nc("The role of the transaction, in past tense", "Canceled"); case Transaction::RoleGetRepoList : return i18nc("The role of the transaction, in past tense", "Got list of repositories"); case Transaction::RoleRepoEnable : return i18nc("The role of the transaction, in past tense", "Enabled repository"); case Transaction::RoleRepoSetData : return i18nc("The role of the transaction, in past tense", "Set repository data"); case Transaction::RoleResolve : return i18nc("The role of the transaction, in past tense", "Resolved"); case Transaction::RoleGetFiles: case Transaction::RoleGetFilesLocal: return i18nc("The role of the transaction, in past tense", "Got file list"); case Transaction::RoleWhatProvides : return i18nc("The role of the transaction, in past tense", "Got what provides"); case Transaction::RoleInstallSignature : return i18nc("The role of the transaction, in past tense", "Installed signature"); case Transaction::RoleGetPackages : return i18nc("The role of the transaction, in past tense", "Got package lists"); case Transaction::RoleAcceptEula : return i18nc("The role of the transaction, in past tense", "Accepted EULA"); case Transaction::RoleDownloadPackages : return i18nc("The role of the transaction, in past tense", "Downloaded packages"); case Transaction::RoleGetDistroUpgrades : return i18nc("The role of the transaction, in past tense", "Got distribution upgrades"); case Transaction::RoleGetCategories : return i18nc("The role of the transaction, in past tense", "Got categories"); case Transaction::RoleGetOldTransactions : return i18nc("The role of the transaction, in past tense", "Got old transactions"); case Transaction::RoleRepairSystem: return i18nc("The role of the transaction, in past tense", "Repaired system"); case Transaction::RoleRepoRemove: return i18nc("The role of the transaction, in past tense", "Removed repository"); + case Transaction::RoleUpgradeSystem: + return i18nc("The role of the transaction, in past tense", "Upgraded the system"); } qCWarning(APPER_LIB) << "action unrecognised: " << action; return QString(); } QString PkStrings::infoPresent(Transaction::Info info) { switch (info) { case Transaction::InfoDownloading : return i18n("Downloading"); case Transaction::InfoUpdating : return i18n("Updating"); case Transaction::InfoInstalling : return i18n("Installing"); case Transaction::InfoRemoving : return i18n("Removing"); case Transaction::InfoCleanup : return i18n("Cleaning up"); case Transaction::InfoObsoleting : return i18n("Obsoleting"); case Transaction::InfoReinstalling : return i18n("Reinstalling"); case Transaction::InfoPreparing : return i18n("Preparing"); case Transaction::InfoDecompressing : return i18n("Decompressing"); default : qCWarning(APPER_LIB) << "info unrecognised:" << info; return QString(); } } QString PkStrings::infoPast(Transaction::Info info) { switch (info) { case Transaction::InfoDownloading : return i18n("Downloaded"); case Transaction::InfoUpdating : return i18n("Updated"); case Transaction::InfoInstalling : return i18n("Installed"); case Transaction::InfoRemoving : return i18n("Removed"); case Transaction::InfoCleanup : return i18n("Cleaned up"); case Transaction::InfoObsoleting : return i18n("Obsoleted"); case Transaction::InfoReinstalling : return i18n("Reinstalled"); case Transaction::InfoPreparing : return i18n("Prepared"); case Transaction::InfoDecompressing : return i18n("Decompressed"); default : qCWarning(APPER_LIB) << "info unrecognised: " << info; return QString(); } } QString PkStrings::error(Transaction::Error error) { switch (error) { case Transaction::ErrorNoNetwork : return i18n("No network connection available"); case Transaction::ErrorNoCache : return i18n("No package cache is available"); case Transaction::ErrorOom : return i18n("Out of memory"); case Transaction::ErrorCreateThreadFailed : return i18n("Failed to create a thread"); case Transaction::ErrorNotSupported : return i18n("Not supported by this backend"); case Transaction::ErrorInternalError : return i18n("An internal system error has occurred"); case Transaction::ErrorGpgFailure : return i18n("A security trust relationship is not present"); case Transaction::ErrorPackageNotInstalled : return i18n("The package is not installed"); case Transaction::ErrorPackageNotFound : return i18n("The package was not found"); case Transaction::ErrorPackageAlreadyInstalled : return i18n("The package is already installed"); case Transaction::ErrorPackageDownloadFailed : return i18n("The package download failed"); case Transaction::ErrorGroupNotFound : return i18n("The group was not found"); case Transaction::ErrorGroupListInvalid : return i18n("The group list was invalid"); case Transaction::ErrorDepResolutionFailed : return i18n("Dependency resolution failed"); case Transaction::ErrorFilterInvalid : return i18n("Search filter was invalid"); case Transaction::ErrorPackageIdInvalid : return i18n("The package identifier was not well formed"); case Transaction::ErrorTransactionError : return i18n("Transaction error"); case Transaction::ErrorRepoNotFound : return i18n("Repository name was not found"); case Transaction::ErrorCannotRemoveSystemPackage : return i18n("Could not remove a protected system package"); case Transaction::ErrorTransactionCancelled : return i18n("The task was canceled"); case Transaction::ErrorProcessKill : return i18n("The task was forcibly canceled"); case Transaction::ErrorFailedConfigParsing : return i18n("Reading the config file failed"); case Transaction::ErrorCannotCancel : return i18n("The task cannot be cancelled"); case Transaction::ErrorCannotInstallSourcePackage : return i18n("Source packages cannot be installed"); case Transaction::ErrorNoLicenseAgreement : return i18n("The license agreement failed"); case Transaction::ErrorFileConflicts : return i18n("Local file conflict between packages"); case Transaction::ErrorPackageConflicts : return i18n("Packages are not compatible"); case Transaction::ErrorRepoNotAvailable : return i18n("Problem connecting to a software origin"); case Transaction::ErrorFailedInitialization : return i18n("Failed to initialize"); case Transaction::ErrorFailedFinalise : return i18n("Failed to finalize"); case Transaction::ErrorCannotGetLock : return i18n("Cannot get lock"); case Transaction::ErrorNoPackagesToUpdate : return i18n("No packages to update"); case Transaction::ErrorCannotWriteRepoConfig : return i18n("Cannot write repository configuration"); case Transaction::ErrorLocalInstallFailed : return i18n("Local install failed"); case Transaction::ErrorBadGpgSignature : return i18n("Bad GPG signature"); case Transaction::ErrorMissingGpgSignature : return i18n("Missing GPG signature"); case Transaction::ErrorRepoConfigurationError : return i18n("Repository configuration invalid"); case Transaction::ErrorInvalidPackageFile : return i18n("Invalid package file"); case Transaction::ErrorPackageInstallBlocked : return i18n("Package install blocked"); case Transaction::ErrorPackageCorrupt : return i18n("Package is corrupt"); case Transaction::ErrorAllPackagesAlreadyInstalled : return i18n("All packages are already installed"); case Transaction::ErrorFileNotFound : return i18n("The specified file could not be found"); case Transaction::ErrorNoMoreMirrorsToTry : return i18n("No more mirrors are available"); case Transaction::ErrorNoDistroUpgradeData : return i18n("No distribution upgrade data is available"); case Transaction::ErrorIncompatibleArchitecture : return i18n("Package is incompatible with this system"); case Transaction::ErrorNoSpaceOnDevice : return i18n("No space is left on the disk"); case Transaction::ErrorMediaChangeRequired : return i18n("A media change is required"); case Transaction::ErrorNotAuthorized : return i18n("Authorization failed"); case Transaction::ErrorUpdateNotFound : return i18n("Update not found"); case Transaction::ErrorCannotInstallRepoUnsigned : return i18n("Cannot install from untrusted origin"); case Transaction::ErrorCannotUpdateRepoUnsigned : return i18n("Cannot update from untrusted origin"); case Transaction::ErrorCannotGetFilelist : return i18n("Cannot get the file list"); case Transaction::ErrorCannotGetRequires : return i18n("Cannot get package requires"); case Transaction::ErrorCannotDisableRepository : return i18n("Cannot disable origin"); case Transaction::ErrorRestrictedDownload : return i18n("The download failed"); case Transaction::ErrorPackageFailedToConfigure : return i18n("Package failed to configure"); case Transaction::ErrorPackageFailedToBuild : return i18n("Package failed to build"); case Transaction::ErrorPackageFailedToInstall : return i18n("Package failed to install"); case Transaction::ErrorPackageFailedToRemove : return i18n("Package failed to be removed"); case Transaction::ErrorUpdateFailedDueToRunningProcess : return i18n("Update failed due to running process"); case Transaction::ErrorPackageDatabaseChanged : return i18n("The package database was changed"); case Transaction::ErrorProvideTypeNotSupported : return i18n("Virtual provide type is not supported"); case Transaction::ErrorInstallRootInvalid : return i18n("Install root is invalid"); case Transaction::ErrorCannotFetchSources : return i18n("Cannot fetch install sources"); case Transaction::ErrorCancelledPriority : return i18n("Rescheduled due to priority"); case Transaction::ErrorUnfinishedTransaction: return i18n("Unfinished transaction"); case Transaction::ErrorLockRequired: return i18n("Lock required"); case Transaction::ErrorUnknown: return i18n("Unknown error"); } qCWarning(APPER_LIB) << "error unrecognised: " << error; return QString(); } QString PkStrings::errorMessage(Transaction::Error error) { switch (error) { case Transaction::ErrorNoNetwork : return i18n("There is no network connection available.\n" "Please check your connection settings and try again"); case Transaction::ErrorNoCache : return i18n("The package list needs to be rebuilt.\n" "This should have been done by the backend automatically."); case Transaction::ErrorOom : return i18n("The service that is responsible for handling user requests is out of memory.\n" "Please close some programs or restart your computer."); case Transaction::ErrorCreateThreadFailed : return i18n("A thread could not be created to service the user request."); case Transaction::ErrorNotSupported : return i18n("The action is not supported by this backend.\n" "Please report a bug as this should not have happened."); case Transaction::ErrorInternalError : return i18n("A problem that we were not expecting has occurred.\n" "Please report this bug with the error description."); case Transaction::ErrorGpgFailure : return i18n("A security trust relationship could not be made with the software origin.\n" "Please check your software signature settings."); case Transaction::ErrorPackageNotInstalled : return i18n("The package that is trying to be removed or updated is not already installed."); case Transaction::ErrorPackageNotFound : return i18n("The package that is being modified was not found on your system or in any software origin."); case Transaction::ErrorPackageAlreadyInstalled : return i18n("The package that is trying to be installed is already installed."); case Transaction::ErrorPackageDownloadFailed : return i18n("The package download failed.\n" "Please check your network connectivity."); case Transaction::ErrorGroupNotFound : return i18n("The group type was not found.\n" "Please check your group list and try again."); case Transaction::ErrorGroupListInvalid : return i18n("The group list could not be loaded.\n" "Refreshing your cache may help, although this is normally a software " "origin error."); case Transaction::ErrorDepResolutionFailed : return i18n("A package dependency could not be found.\n" "More information is available in the detailed report."); case Transaction::ErrorFilterInvalid : return i18n("The search filter was not correctly formed."); case Transaction::ErrorPackageIdInvalid : return i18n("The package identifier was not well formed when sent to the system daemon.\n" "This normally indicates an internal bug and should be reported."); case Transaction::ErrorTransactionError : return i18n("An error occurred while running the transaction.\n" "More information is available in the detailed report."); case Transaction::ErrorRepoNotFound : return i18n("The remote software origin name was not found.\n" "You may need to enable an item in Software Origins."); case Transaction::ErrorCannotRemoveSystemPackage : return i18n("Removing a protected system package is not allowed."); case Transaction::ErrorTransactionCancelled : return i18n("The task was canceled successfully and no packages were changed."); case Transaction::ErrorProcessKill : return i18n("The task was canceled successfully and no packages were changed.\n" "The backend did not exit cleanly."); case Transaction::ErrorFailedConfigParsing : return i18n("The native package configuration file could not be opened.\n" "Please make sure your system's configuration is valid."); case Transaction::ErrorCannotCancel : return i18n("The task is not safe to be cancelled at this time."); case Transaction::ErrorCannotInstallSourcePackage : return i18n("Source packages are not normally installed this way.\n" "Check the extension of the file you are trying to install."); case Transaction::ErrorNoLicenseAgreement : return i18n("The license agreement was not agreed to.\n" "To use this software you have to accept the license."); case Transaction::ErrorFileConflicts : return i18n("Two packages provide the same file.\n" "This is usually due to mixing packages for different software origins."); case Transaction::ErrorPackageConflicts : return i18n("Multiple packages exist that are not compatible with each other.\n" "This is usually due to mixing packages from different software origins."); case Transaction::ErrorRepoNotAvailable : return i18n("There was a (possibly temporary) problem connecting to a software origins.\n" "Please check the detailed error for further details."); case Transaction::ErrorFailedInitialization : return i18n("Failed to initialize packaging backend.\n" "This may occur if other packaging tools are being used simultaneously."); case Transaction::ErrorFailedFinalise : return i18n("Failed to close down the backend instance.\n" "This error can normally be ignored."); case Transaction::ErrorCannotGetLock : return i18n("Cannot get the exclusive lock on the packaging backend.\n" "Please close any other legacy packaging tools that may be open."); case Transaction::ErrorNoPackagesToUpdate : return i18n("None of the selected packages could be updated."); case Transaction::ErrorCannotWriteRepoConfig : return i18n("The repository configuration could not be modified."); case Transaction::ErrorLocalInstallFailed : return i18n("Installing the local file failed.\n" "More information is available in the detailed report."); case Transaction::ErrorBadGpgSignature : return i18n("The package signature could not be verified."); case Transaction::ErrorMissingGpgSignature : return i18n("The package signature was missing and this package is untrusted.\n" "This package was not signed with a GPG key when created."); case Transaction::ErrorRepoConfigurationError : return i18n("Repository configuration was invalid and could not be read."); case Transaction::ErrorInvalidPackageFile : return i18n("The package you are attempting to install is not valid.\n" "The package file could be corrupt, or not a proper package."); case Transaction::ErrorPackageInstallBlocked : return i18n("Installation of this package was prevented by your packaging system's configuration."); case Transaction::ErrorPackageCorrupt : return i18n("The package that was downloaded is corrupt and needs to be downloaded again."); case Transaction::ErrorAllPackagesAlreadyInstalled : return i18n("All of the packages selected for install are already installed on the system."); case Transaction::ErrorFileNotFound : return i18n("The specified file could not be found on the system.\n" "Check that the file still exists and has not been deleted."); case Transaction::ErrorNoMoreMirrorsToTry : return i18n("Required data could not be found on any of the configured software origins.\n" "There were no more download mirrors that could be tried."); case Transaction::ErrorNoDistroUpgradeData : return i18n("Required upgrade data could not be found in any of the configured software origins.\n" "The list of distribution upgrades will be unavailable."); case Transaction::ErrorIncompatibleArchitecture : return i18n("The package that is trying to be installed is incompatible with this system."); case Transaction::ErrorNoSpaceOnDevice : return i18n("There is insufficient space on the device.\n" "Free some space on the system disk to perform this operation."); case Transaction::ErrorMediaChangeRequired : return i18n("Additional media is required to complete the transaction."); case Transaction::ErrorNotAuthorized : return i18n("You have failed to provide correct authentication.\n" "Please check any passwords or account settings."); case Transaction::ErrorUpdateNotFound : return i18n("The specified update could not be found.\n" "It could have already been installed or no longer available on the remote server."); case Transaction::ErrorCannotInstallRepoUnsigned : return i18n("The package could not be installed from untrusted origin."); case Transaction::ErrorCannotUpdateRepoUnsigned : return i18n("The package could not be updated from untrusted origin."); case Transaction::ErrorCannotGetFilelist : return i18n("The file list is not available for this package."); case Transaction::ErrorCannotGetRequires : return i18n("The information about what requires this package could not be obtained."); case Transaction::ErrorCannotDisableRepository : return i18n("The specified software origin could not be disabled."); case Transaction::ErrorRestrictedDownload : return i18n("The download could not be done automatically and should be done manually.\n" "More information is available in the detailed report."); case Transaction::ErrorPackageFailedToConfigure : return i18n("One of the selected packages failed to configure correctly.\n" "More information is available in the detailed report."); case Transaction::ErrorPackageFailedToBuild : return i18n("One of the selected packages failed to build correctly.\n" "More information is available in the detailed report."); case Transaction::ErrorPackageFailedToInstall : return i18n("One of the selected packages failed to install correctly.\n" "More information is available in the detailed report."); case Transaction::ErrorPackageFailedToRemove : return i18n("One of the selected packages failed to be removed correctly.\n" "More information is available in the detailed report."); case Transaction::ErrorUpdateFailedDueToRunningProcess : return i18n("A program is running that has to be closed before the update can proceed.\n" "More information is available in the detailed report."); case Transaction::ErrorPackageDatabaseChanged : return i18n("The package database was changed while the request was running."); case Transaction::ErrorProvideTypeNotSupported : return i18n("The virtual provide type is not supported by this system."); case Transaction::ErrorInstallRootInvalid : return i18n("The install root is invalid. Please contact your administrator."); case Transaction::ErrorCannotFetchSources : return i18n("The list of software could not be downloaded."); case Transaction::ErrorCancelledPriority : return i18n("The transaction has been cancelled and will be retried when the system is idle."); case Transaction::ErrorUnfinishedTransaction : return i18n("A previous package management transaction was interrupted."); case Transaction::ErrorLockRequired : return i18n("A package manager lock is required."); case Transaction::ErrorUnknown: return i18n("Unknown error, please report a bug.\n" "More information is available in the detailed report."); } qCWarning(APPER_LIB) << "error unrecognised: " << error; return QString(); } QString PkStrings::groups(Transaction::Group group) { switch (group) { case Transaction::GroupAccessibility : return i18nc("The group type", "Accessibility"); case Transaction::GroupAccessories : return i18nc("The group type", "Accessories"); case Transaction::GroupEducation : return i18nc("The group type", "Education"); case Transaction::GroupGames : return i18nc("The group type", "Games"); case Transaction::GroupGraphics : return i18nc("The group type", "Graphics"); case Transaction::GroupInternet : return i18nc("The group type", "Internet"); case Transaction::GroupOffice : return i18nc("The group type", "Office"); case Transaction::GroupOther : return i18nc("The group type", "Others"); case Transaction::GroupProgramming : return i18nc("The group type", "Development"); case Transaction::GroupMultimedia : return i18nc("The group type", "Multimedia"); case Transaction::GroupSystem : return i18nc("The group type", "System"); case Transaction::GroupDesktopGnome : return i18nc("The group type", "GNOME desktop"); case Transaction::GroupDesktopKde : return i18nc("The group type", "KDE desktop"); case Transaction::GroupDesktopXfce : return i18nc("The group type", "XFCE desktop"); case Transaction::GroupDesktopOther : return i18nc("The group type", "Other desktops"); case Transaction::GroupPublishing : return i18nc("The group type", "Publishing"); case Transaction::GroupServers : return i18nc("The group type", "Servers"); case Transaction::GroupFonts : return i18nc("The group type", "Fonts"); case Transaction::GroupAdminTools : return i18nc("The group type", "Admin tools"); case Transaction::GroupLegacy : return i18nc("The group type", "Legacy"); case Transaction::GroupLocalization : return i18nc("The group type", "Localization"); case Transaction::GroupVirtualization : return i18nc("The group type", "Virtualization"); case Transaction::GroupSecurity : return i18nc("The group type", "Security"); case Transaction::GroupPowerManagement : return i18nc("The group type", "Power management"); case Transaction::GroupCommunication : return i18nc("The group type", "Communication"); case Transaction::GroupNetwork : return i18nc("The group type", "Network"); case Transaction::GroupMaps : return i18nc("The group type", "Maps"); case Transaction::GroupRepos : return i18nc("The group type", "Software sources"); case Transaction::GroupScience : return i18nc("The group type", "Science"); case Transaction::GroupDocumentation : return i18nc("The group type", "Documentation"); case Transaction::GroupElectronics : return i18nc("The group type", "Electronics"); case Transaction::GroupCollections ://TODO check this one return i18nc("The group type", "Package collections"); case Transaction::GroupVendor : return i18nc("The group type", "Vendor"); case Transaction::GroupNewest : return i18nc("The group type", "Newest packages"); case Transaction::GroupUnknown: return i18nc("The group type", "Unknown group"); } qCWarning(APPER_LIB) << "group unrecognised: " << group; return QString(); } QString PkStrings::info(int state) { Transaction::Info stateEnum = static_cast(state); switch (stateEnum) { case Transaction::InfoLow : return i18nc("The type of update", "Trivial update"); case Transaction::InfoNormal : return i18nc("The type of update", "Normal update"); case Transaction::InfoImportant : return i18nc("The type of update", "Important update"); case Transaction::InfoSecurity : return i18nc("The type of update", "Security update"); case Transaction::InfoBugfix : return i18nc("The type of update", "Bug fix update"); case Transaction::InfoEnhancement : return i18nc("The type of update", "Enhancement update"); case Transaction::InfoBlocked : return i18nc("The type of update", "Blocked update"); case Transaction::InfoInstalled : case Transaction::InfoCollectionInstalled : return i18nc("The type of update", "Installed"); case Transaction::InfoAvailable : case Transaction::InfoCollectionAvailable : return i18nc("The type of update", "Available"); case Transaction::InfoUnknown: return i18nc("The type of update", "Unknown update"); default : // In this case we don't want to map all enums qCWarning(APPER_LIB) << "info unrecognised: " << state; return QString(); } } QString PkStrings::packageQuantity(bool updates, int packages, int selected) { if (updates) { if (packages == 0) { return i18n("No Updates Available"); } else if (packages == selected) { return i18ncp("Some updates were selected on the view", "1 Update Selected", "%1 Updates Selected", packages); } else if (selected == 0) { return i18ncp("Some updates are being shown on the screen", "1 Update", "%1 Updates", packages); } else { return i18nc("Type of update, in the case it's just an update", "%1, %2", i18ncp("Part of: %1 Updates, %1 Selected", "%1 Update", "%1 Updates", packages), i18ncp("Part of: %1 Updates, %1 Selected", "%1 Selected", "%1 Selected", selected)); } } else { if (packages == 0) { return i18n("No Packages"); } return i18np("1 Package", "%1 Packages", packages); } } QString PkStrings::restartTypeFuture(Transaction::Restart value) { switch (value) { case Transaction::RestartNone: return i18n("No restart is necessary"); case Transaction::RestartApplication: return i18n("You will be required to restart this application"); case Transaction::RestartSession: return i18n("You will be required to log out and back in"); case Transaction::RestartSystem: return i18n("A restart will be required"); case Transaction::RestartSecuritySession: return i18n("You will be required to log out and back in due to a security update."); case Transaction::RestartSecuritySystem: return i18n("A restart will be required due to a security update."); case Transaction::RestartUnknown: qCWarning(APPER_LIB) << "restartTypeFuture(Transaction::RestartUnknown)"; return QString(); } qCWarning(APPER_LIB) << "restart unrecognised: " << value; return QString(); } QString PkStrings::restartType(Transaction::Restart value) { switch (value) { case Transaction::RestartNone: return i18n("No restart is required"); case Transaction::RestartSystem: return i18n("A restart is required"); case Transaction::RestartSession: return i18n("You need to log out and log back in"); case Transaction::RestartApplication: return i18n("You need to restart the application"); case Transaction::RestartSecuritySession: return i18n("You need to log out and log back in to remain secure."); case Transaction::RestartSecuritySystem: return i18n("A restart is required to remain secure."); case Transaction::RestartUnknown: qCWarning(APPER_LIB) << "restartType(Transaction::RestartUnknown)"; return QString(); } qCWarning(APPER_LIB) << "restart unrecognised: " << value; return QString(); } QString PkStrings::updateState(Transaction::UpdateState value) { switch (value) { case Transaction::UpdateStateStable: return i18n("Stable"); case Transaction::UpdateStateUnstable: return i18n("Unstable"); case Transaction::UpdateStateTesting: return i18n("Testing"); case Transaction::UpdateStateUnknown: qCWarning(APPER_LIB) << "updateState(Transaction::UnknownUpdateState)"; return QString(); } qCWarning(APPER_LIB) << "value unrecognised: " << value; return QString(); } QString PkStrings::mediaMessage(Transaction::MediaType value, const QString &text) { switch (value) { case Transaction::MediaTypeCd : return i18n("Please insert the CD labeled '%1', and press continue.", text); case Transaction::MediaTypeDvd : return i18n("Please insert the DVD labeled '%1', and press continue.", text); case Transaction::MediaTypeDisc : return i18n("Please insert the disc labeled '%1', and press continue.", text); case Transaction::MediaTypeUnknown: return i18n("Please insert the medium labeled '%1', and press continue.", text); } qCWarning(APPER_LIB) << "value unrecognised: " << value; return i18n("Please insert the medium labeled '%1', and press continue.", text); } //QString PkStrings::message(Transaction::Message value) //{ // switch (value) { // case Transaction::MessageBrokenMirror : // return i18n("A mirror is possibly broken"); // case Transaction::MessageConnectionRefused : // return i18n("The connection was refused"); // case Transaction::MessageParameterInvalid : // return i18n("The parameter was invalid"); // case Transaction::MessagePriorityInvalid : // return i18n("The priority was invalid"); // case Transaction::MessageBackendError : // return i18n("Backend warning"); // case Transaction::MessageDaemonError : // return i18n("Daemon warning"); // case Transaction::MessageCacheBeingRebuilt : // return i18n("The package list cache is being rebuilt"); // case Transaction::MessageUntrustedPackage : // return i18n("An untrusted package was installed"); // case Transaction::MessageNewerPackageExists : // return i18n("A newer package exists"); // case Transaction::MessageCouldNotFindPackage : // return i18n("Could not find package"); // case Transaction::MessageConfigFilesChanged : // return i18n("Configuration files were changed"); // case Transaction::MessagePackageAlreadyInstalled : // return i18n("Package is already installed"); // case Transaction::MessageAutoremoveIgnored : // return i18n("Automatic cleanup is being ignored"); // case Transaction::MessageRepoMetadataDownloadFailed : // return i18n("Software source download failed"); // case Transaction::MessageRepoForDevelopersOnly : // return i18n("This software source is for developers only"); // case Transaction::MessageOtherUpdatesHeldBack : // return i18n("Other updates have been held back"); // case Transaction::MessageUnknown: // qCWarning(APPER_LIB) << "message(Enum::UnknownMessageType)"; // return QString(); // } // qCWarning(APPER_LIB) << "value unrecognised: " << value; // return QString(); //} QString PkStrings::daemonError(int value) { Transaction::InternalError statusEnum = static_cast(value); switch (statusEnum) { case Transaction::InternalErrorFailedAuth : return i18n("You do not have the necessary privileges to perform this action."); case Transaction::InternalErrorNoTid : return i18n("Could not get a transaction id from packagekitd."); case Transaction::InternalErrorAlreadyTid : return i18n("Cannot connect to this transaction id."); case Transaction::InternalErrorRoleUnkown : return i18n("This action is unknown."); case Transaction::InternalErrorCannotStartDaemon : return i18n("The packagekitd service could not be started."); case Transaction::InternalErrorInvalidInput : return i18n("The query is not valid."); case Transaction::InternalErrorInvalidFile : return i18n("The file is not valid."); case Transaction::InternalErrorFunctionNotSupported : return i18n("This function is not yet supported."); case Transaction::InternalErrorDaemonUnreachable : return i18n("Could not talk to packagekitd."); case Transaction::InternalErrorFailed: return i18n("Error talking to packagekitd."); case Transaction::InternalErrorNone: case Transaction::InternalErrorUnkown : return i18n("An unknown error happened."); } qCWarning(APPER_LIB) << "value unrecognised: " << value; return i18n("An unknown error happened."); } QString PkStrings::prettyFormatDuration(unsigned long mSec) { - KFormat f; - return f.formatDuration(mSec); + + return KFormat().formatSpelloutDuration(mSec); } QString PkStrings::lastCacheRefreshTitle(uint lastTime) { unsigned long fifteen = 60 * 60 * 24 * 15; unsigned long tirty = 60 * 60 * 24 * 30; if (lastTime != UINT_MAX && lastTime < fifteen) { return i18n("Your system is up to date"); } else if (lastTime != UINT_MAX && lastTime > fifteen && lastTime < tirty) { return i18n("You have no updates"); } return i18n("Last check for updates was more than a month ago"); } QString PkStrings::lastCacheRefreshSubTitle(uint lastTime) { unsigned long tirty = 60 * 60 * 24 * 30; if (lastTime != UINT_MAX && lastTime < tirty) { return i18n("Verified %1 ago", PkStrings::prettyFormatDuration(lastTime * 1000)); } return i18n("It's strongly recommended that you check for new updates now"); } #include "moc_PkStrings.cpp" diff --git a/libapper/PkTransaction.cpp b/libapper/PkTransaction.cpp index 302e28a..5de07ef 100644 --- a/libapper/PkTransaction.cpp +++ b/libapper/PkTransaction.cpp @@ -1,777 +1,783 @@ /*************************************************************************** * Copyright (C) 2008-2018 by Daniel Nicoletti * * dantti12@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * ***************************************************************************/ #include #include "PkTransaction.h" #include #include #include #include #include #include #include #include #include #include #include #include "Enum.h" #include "PkStrings.h" #include "RepoSig.h" #include "LicenseAgreement.h" #include "PkIcons.h" #include "ApplicationLauncher.h" #include "PackageModel.h" #include "Requirements.h" #include "PkTransactionProgressModel.h" #include "PkTransactionWidget.h" Q_DECLARE_LOGGING_CATEGORY(APPER_LIB) class PkTransactionPrivate { public: bool allowDeps; bool jobWatcher; bool handlingActionRequired; bool showingError; //This might replace the above qulonglong downloadSizeRemaining; PkTransaction::ExitStatus exitStatus; Transaction::Status status; Transaction::TransactionFlags flags; Transaction::Role originalRole; Transaction::Error error; Transaction::Role role; QStringList packages; ApplicationLauncher *launcher; QStringList files; QStringList newPackages; PackageModel *simulateModel; PkTransactionProgressModel *progressModel; QWidget *parentWindow; QDBusObjectPath tid; Transaction *transaction; }; PkTransaction::PkTransaction(QObject *parent) : QObject(parent), d(new PkTransactionPrivate) { // for sanity we are finished till some transaction is set d->allowDeps = false; d->jobWatcher = false; d->handlingActionRequired = false; d->showingError = false; d->downloadSizeRemaining = 0; d->exitStatus = Success; d->status = Transaction::StatusUnknown; // for sanity we are trusted till an error is given and the user accepts d->flags = Transaction::TransactionFlagOnlyTrusted; d->originalRole = Transaction::RoleUnknown; d->role = Transaction::RoleUnknown; d->error = Transaction::ErrorUnknown; d->launcher = 0; d->simulateModel = 0; d->progressModel = new PkTransactionProgressModel(this); d->parentWindow = qobject_cast(parent); d->transaction = 0; } PkTransaction::~PkTransaction() { // DO NOT disconnect the transaction here, // it might not exist when this happen delete d; } void PkTransaction::installFiles(const QStringList &files) { // if (Daemon::global()->roles() & Transaction::RoleInstallFiles) { d->originalRole = Transaction::RoleInstallFiles; d->files = files; d->flags = Transaction::TransactionFlagOnlyTrusted | Transaction::TransactionFlagSimulate; setupTransaction(Daemon::installFiles(files, d->flags)); // } else { // showError(i18n("Current backend does not support installing files."), i18n("Error")); // } } void PkTransaction::installPackages(const QStringList &packages) { // if (Daemon::global()->roles() & Transaction::RoleInstallPackages) { d->originalRole = Transaction::RoleInstallPackages; d->packages = packages; d->flags = Transaction::TransactionFlagOnlyTrusted | Transaction::TransactionFlagSimulate; setupTransaction(Daemon::installPackages(d->packages, d->flags)); // } else { // showError(i18n("Current backend does not support installing packages."), i18n("Error")); // } } void PkTransaction::removePackages(const QStringList &packages) { // if (Daemon::global()->roles() & Transaction::RoleRemovePackages) { d->originalRole = Transaction::RoleRemovePackages; d->allowDeps = true; // *was* false, Default to avoid dependencies removal unless simulate says so, except for https://bugs.kde.org/show_bug.cgi?id=315063 d->packages = packages; d->flags = Transaction::TransactionFlagOnlyTrusted | Transaction::TransactionFlagSimulate; setupTransaction(Daemon::removePackages(d->packages, d->allowDeps, AUTOREMOVE, d->flags)); // } else { // showError(i18n("The current backend does not support removing packages."), i18n("Error")); // } } void PkTransaction::updatePackages(const QStringList &packages, bool downloadOnly) { // if (Daemon::global()->roles() & Transaction::RoleUpdatePackages) { d->originalRole = Transaction::RoleUpdatePackages; d->packages = packages; if (downloadOnly) { // Don't simulate if we are just downloading d->flags = Transaction::TransactionFlagOnlyDownload; } else { d->flags = Transaction::TransactionFlagOnlyTrusted | Transaction::TransactionFlagSimulate; } setupTransaction(Daemon::updatePackages(d->packages, d->flags)); // } else { // showError(i18n("The current backend does not support updating packages."), i18n("Error")); // } } void PkTransaction::refreshCache(bool force) { setupTransaction(Daemon::refreshCache(force)); } void PkTransaction::installPackages() { setupTransaction(Daemon::installPackages(d->packages, d->flags)); } void PkTransaction::installFiles() { setupTransaction(Daemon::installFiles(d->files, d->flags)); } void PkTransaction::removePackages() { setupTransaction(Daemon::removePackages(d->packages, d->allowDeps, AUTOREMOVE, d->flags)); } void PkTransaction::updatePackages() { setupTransaction(Daemon::updatePackages(d->packages, d->flags)); } void PkTransaction::requeueTransaction() { auto requires = qobject_cast(sender()); if (requires) { // As we have requires allow deps removal d->allowDeps = true; if (!requires->trusted()) { // Set only trusted to false, to do as the user asked setTrusted(false); } } // Delete the simulate model if (d->simulateModel) { d->simulateModel->deleteLater(); d->simulateModel = 0; } // We are not handling any required action yet for the requeued transaction. // Without this a second license agreement f.e. does not get shown, // see http://bugs.kde.org/show_bug.cgi?id=326619 d->handlingActionRequired = false; switch (d->originalRole) { case Transaction::RoleRemovePackages: removePackages(); break; case Transaction::RoleInstallPackages: installPackages(); break; case Transaction::RoleInstallFiles: installFiles(); break; case Transaction::RoleUpdatePackages: updatePackages(); break; default : setExitStatus(Failed); return; } } void PkTransaction::slotErrorCode(Transaction::Error error, const QString &details) { qCDebug(APPER_LIB) << "errorCode: " << error << details; d->error = error; if (d->handlingActionRequired) { // We are already handling required actions // like eulaRequired() and repoSignatureRequired() return; } switch (error) { case Transaction::ErrorTransactionCancelled: case Transaction::ErrorProcessKill: // these errors should be ignored break; case Transaction::ErrorGpgFailure: case Transaction::ErrorBadGpgSignature: case Transaction::ErrorMissingGpgSignature: case Transaction::ErrorCannotInstallRepoUnsigned: case Transaction::ErrorCannotUpdateRepoUnsigned: { + if (d->role == Transaction::RoleRefreshCache) { + // We are not installing anything + KMessageBox::information(d->parentWindow, details, PkStrings::error(error)); + return; + } + d->handlingActionRequired = true; int ret = KMessageBox::warningYesNo(d->parentWindow, i18n("You are about to install unsigned packages that can compromise your system, " "as it is impossible to verify if the software came from a trusted " "source.\n\nAre you sure you want to proceed with the installation?"), i18n("Installing unsigned software")); if (ret == KMessageBox::Yes) { // Set only trusted to false, to do as the user asked setTrusted(false); requeueTransaction(); } else { setExitStatus(Cancelled); } d->handlingActionRequired = false; return; } default: d->showingError = true; showSorry(PkStrings::error(error), PkStrings::errorMessage(error), QString(details).replace('\n', "
")); // when we receive an error we are done setExitStatus(Failed); } } void PkTransaction::slotEulaRequired(const QString &eulaID, const QString &packageID, const QString &vendor, const QString &licenseAgreement) { if (d->handlingActionRequired) { // if its true means that we alread passed here d->handlingActionRequired = false; return; } else { d->handlingActionRequired = true; } auto eula = new LicenseAgreement(eulaID, packageID, vendor, licenseAgreement, d->parentWindow); connect(eula, &LicenseAgreement::accepted, this, &PkTransaction::acceptEula); connect(eula, &LicenseAgreement::rejected, this, &PkTransaction::reject); showDialog(eula); } void PkTransaction::acceptEula() { auto eula = qobject_cast(sender()); if (eula) { qCDebug(APPER_LIB) << "Accepting EULA" << eula->id(); setupTransaction(Daemon::acceptEula(eula->id())); } else { qCWarning(APPER_LIB) << "something is broken, slot is bound to LicenseAgreement but signalled from elsewhere."; } } void PkTransaction::slotChanged() { auto transaction = qobject_cast(sender()); d->downloadSizeRemaining = transaction->downloadSizeRemaining(); d->role = transaction->role(); if (!d->jobWatcher) { return; } QDBusObjectPath _tid = transaction->tid(); if (d->tid != _tid && !(d->flags & Transaction::TransactionFlagSimulate)) { d->tid = _tid; // if the transaction changed and // the user wants the watcher send the tid QDBusMessage message; message = QDBusMessage::createMethodCall(QLatin1String("org.kde.apperd"), QLatin1String("/"), QLatin1String("org.kde.apperd"), QLatin1String("WatchTransaction")); // Use our own cached tid to avoid crashes message << qVariantFromValue(_tid); if (!QDBusConnection::sessionBus().send(message)) { qCWarning(APPER_LIB) << "Failed to put WatchTransaction on the DBus queue"; } } } void PkTransaction::slotMediaChangeRequired(Transaction::MediaType type, const QString &id, const QString &text) { Q_UNUSED(id) d->handlingActionRequired = true; int ret = KMessageBox::questionYesNo(d->parentWindow, PkStrings::mediaMessage(type, text), i18n("A media change is required"), KStandardGuiItem::cont(), KStandardGuiItem::cancel()); d->handlingActionRequired = false; // if the user clicked continue we got yes if (ret == KMessageBox::Yes) { requeueTransaction(); } else { setExitStatus(Cancelled); } } void PkTransaction::slotRepoSignature(const QString &packageID, const QString &repoName, const QString &keyUrl, const QString &keyUserid, const QString &keyId, const QString &keyFingerprint, const QString &keyTimestamp, Transaction::SigType type) { if (d->handlingActionRequired) { // if its true means that we alread passed here d->handlingActionRequired = false; return; } else { d->handlingActionRequired = true; } auto repoSig = new RepoSig(packageID, repoName, keyUrl, keyUserid, keyId, keyFingerprint, keyTimestamp, type, d->parentWindow); connect(repoSig, &RepoSig::accepted, this, &PkTransaction::installSignature); connect(repoSig, &RepoSig::rejected, this, &PkTransaction::reject); showDialog(repoSig); } void PkTransaction::installSignature() { auto repoSig = qobject_cast(sender()); if (repoSig) { qCDebug(APPER_LIB) << "Installing Signature" << repoSig->keyID(); setupTransaction(Daemon::installSignature(repoSig->sigType(), repoSig->keyID(), repoSig->packageID())); } else { qCWarning(APPER_LIB) << "something is broken, slot is bound to RepoSig but signalled from elsewhere."; } } void PkTransaction::slotFinished(Transaction::Exit status) { // Clear the model to don't keep trash when reusing the transaction d->progressModel->clear(); Requirements *requires = 0; Transaction::Role _role = qobject_cast(sender())->role(); d->transaction = 0; // Will be deleted later qCDebug(APPER_LIB) << status << _role; switch (_role) { case Transaction::RoleInstallSignature: case Transaction::RoleAcceptEula: if (status == Transaction::ExitSuccess) { // if the required action was performed with success // requeue our main transaction requeueTransaction(); return; } break; default: break; } switch(status) { case Transaction::ExitSuccess: // Check if we are just simulating if (d->flags & Transaction::TransactionFlagSimulate) { // Disable the simulate flag d->flags ^= Transaction::TransactionFlagSimulate; d->simulateModel->finished(); // Remove the transaction packages for (const QString &packageID : qAsConst(d->packages)) { d->simulateModel->removePackage(packageID); } d->newPackages = d->simulateModel->packagesWithInfo(Transaction::InfoInstalling); if (_role == Transaction::RoleInstallPackages) { d->newPackages << d->packages; d->newPackages.removeDuplicates(); } requires = new Requirements(d->simulateModel, d->parentWindow); requires->setDownloadSizeRemaining(d->downloadSizeRemaining); connect(requires, &Requirements::accepted, this, &PkTransaction::requeueTransaction); connect(requires, &Requirements::rejected, this, &PkTransaction::reject); if (requires->shouldShow()) { showDialog(requires); } else { requires->deleteLater(); // Since we removed the Simulate Flag this will procced // with the actual action requeueTransaction(); } } else { KConfig config("apper"); KConfigGroup transactionGroup(&config, "Transaction"); bool showApp = transactionGroup.readEntry("ShowApplicationLauncher", true); if (showApp && !d->newPackages.isEmpty() && (_role == Transaction::RoleInstallPackages || _role == Transaction::RoleInstallFiles || _role == Transaction::RoleRemovePackages || _role == Transaction::RoleUpdatePackages)) { // When installing files or updates that involves new packages // try to resolve the available packages at simulation time // to maybe show the user the new applications that where installed if (d->launcher) { delete d->launcher; } d->launcher = new ApplicationLauncher(d->parentWindow); connect(d->transaction, &Transaction::files, d->launcher, &ApplicationLauncher::files); setupTransaction(Daemon::getFiles(d->newPackages)); d->newPackages.clear(); return; // avoid the exit code } else if (_role == Transaction::RoleGetFiles && d->launcher && d->launcher->hasApplications()) { // if we have a launcher and the laucher has applications // show them to the user showDialog(d->launcher); connect(d->launcher, &ApplicationLauncher::finished, this, &PkTransaction::setExitStatus); return; } setExitStatus(Success); } break; case Transaction::ExitNeedUntrusted: case Transaction::ExitKeyRequired: case Transaction::ExitEulaRequired: case Transaction::ExitMediaChangeRequired: qCDebug(APPER_LIB) << "finished KeyRequired or EulaRequired: " << status; if (!d->handlingActionRequired) { qCDebug(APPER_LIB) << "Not Handling Required Action"; setExitStatus(Failed); } break; case Transaction::ExitCancelled: // Avoid crash in case we are showing an error if (!d->showingError) { setExitStatus(Cancelled); } break; case Transaction::ExitFailed: if (!d->handlingActionRequired && !d->showingError) { qCDebug(APPER_LIB) << "Yep, we failed."; setExitStatus(Failed); } break; default : qCDebug(APPER_LIB) << "finished default" << status; setExitStatus(Failed); break; } } PkTransaction::ExitStatus PkTransaction::exitStatus() const { return d->exitStatus; } bool PkTransaction::isFinished() const { qCDebug(APPER_LIB) << d->transaction->status() << d->transaction->role(); return d->transaction->status() == Transaction::StatusFinished; } PackageModel *PkTransaction::simulateModel() const { return d->simulateModel; } uint PkTransaction::percentage() const { if (d->transaction) { return d->transaction->percentage(); } return 0; } uint PkTransaction::remainingTime() const { if (d->transaction) { return d->transaction->remainingTime(); } return 0; } uint PkTransaction::speed() const { if (d->transaction) { return d->transaction->speed(); } return 0; } qulonglong PkTransaction::downloadSizeRemaining() const { if (d->transaction) { return d->transaction->downloadSizeRemaining(); } return 0; } Transaction::Status PkTransaction::status() const { if (d->transaction) { return d->transaction->status(); } return Transaction::StatusUnknown; } Transaction::Role PkTransaction::role() const { if (d->transaction) { return d->transaction->role(); } return Transaction::RoleUnknown; } bool PkTransaction::allowCancel() const { if (d->transaction) { return d->transaction->allowCancel(); } return false; } Transaction::TransactionFlags PkTransaction::transactionFlags() const { if (d->transaction) { return d->transaction->transactionFlags(); } return Transaction::TransactionFlagNone; } void PkTransaction::getUpdateDetail(const QString &packageID) { setupTransaction(Daemon::getUpdateDetail(packageID)); } void PkTransaction::getUpdates() { setupTransaction(Daemon::getUpdates()); } void PkTransaction::cancel() { if (d->transaction) { d->transaction->cancel(); } } void PkTransaction::setTrusted(bool trusted) { if (trusted) { d->flags |= Transaction::TransactionFlagOnlyTrusted; } else { d->flags ^= Transaction::TransactionFlagOnlyTrusted; } } void PkTransaction::setExitStatus(int status) { qCDebug(APPER_LIB) << status; if (d->launcher) { d->launcher->deleteLater(); d->launcher = 0; } d->exitStatus = static_cast(status); if (!d->handlingActionRequired || !d->showingError) { emit finished(d->exitStatus); } } void PkTransaction::reject() { setExitStatus(Cancelled); } void PkTransaction::setupTransaction(Transaction *transaction) { // Clear the model to don't keep trash when reusing the transaction d->progressModel->clear(); d->transaction = transaction; if (!(transaction->transactionFlags() & Transaction::TransactionFlagSimulate) && transaction->role() != Transaction::RoleGetUpdates && transaction->role() != Transaction::RoleGetUpdateDetail) { connect(transaction, &Transaction::repoDetail, d->progressModel, &PkTransactionProgressModel::currentRepo); connect(transaction, &Transaction::package, d->progressModel, &PkTransactionProgressModel::currentPackage); connect(transaction, &Transaction::itemProgress, d->progressModel, &PkTransactionProgressModel::itemProgress); } connect(transaction, &Transaction::updateDetail, this, &PkTransaction::updateDetail); connect(transaction, &Transaction::package, this, &PkTransaction::package); connect(transaction, &Transaction::errorCode, this, &PkTransaction::errorCode); // Required actions connect(transaction, &Transaction::allowCancelChanged, this, &PkTransaction::allowCancelChanged); connect(transaction, &Transaction::downloadSizeRemainingChanged, this, &PkTransaction::downloadSizeRemainingChanged); connect(transaction, &Transaction::elapsedTimeChanged, this, &PkTransaction::elapsedTimeChanged); connect(transaction, &Transaction::isCallerActiveChanged, this, &PkTransaction::isCallerActiveChanged); connect(transaction, &Transaction::lastPackageChanged, this, &PkTransaction::lastPackageChanged); connect(transaction, &Transaction::percentageChanged, this, &PkTransaction::percentageChanged); connect(transaction, &Transaction::remainingTimeChanged, this, &PkTransaction::remainingTimeChanged); connect(transaction, &Transaction::roleChanged, this, &PkTransaction::roleChanged); connect(transaction, &Transaction::speedChanged, this, &PkTransaction::speedChanged); connect(transaction, &Transaction::statusChanged, this, &PkTransaction::statusChanged); connect(transaction, &Transaction::transactionFlagsChanged, this, &PkTransaction::transactionFlagsChanged); connect(transaction, &Transaction::uidChanged, this, &PkTransaction::uidChanged); connect(transaction, &Transaction::downloadSizeRemainingChanged, this, &PkTransaction::slotChanged); connect(transaction, &Transaction::errorCode, this, &PkTransaction::slotErrorCode); connect(transaction, &Transaction::eulaRequired, this, &PkTransaction::slotEulaRequired); connect(transaction, &Transaction::mediaChangeRequired, this, &PkTransaction::slotMediaChangeRequired); connect(transaction, &Transaction::repoSignatureRequired, this, &PkTransaction::slotRepoSignature); connect(transaction, &Transaction::finished, this, &PkTransaction::slotFinished); if (d->flags & Transaction::TransactionFlagSimulate) { d->simulateModel = new PackageModel(this); connect(d->transaction, &Transaction::package, d->simulateModel, &PackageModel::addNotSelectedPackage); } #ifdef HAVE_DEBCONFKDE QString _tid = transaction->tid().path(); QString socket; // Build a socket path like /tmp/1761_edeceabd_data_debconf socket = QLatin1String("/tmp") % _tid % QLatin1String("_debconf"); QDBusMessage message; message = QDBusMessage::createMethodCall(QLatin1String("org.kde.apperd"), QLatin1String("/"), QLatin1String("org.kde.apperd"), QLatin1String("SetupDebconfDialog")); // Use our own cached tid to avoid crashes message << qVariantFromValue(_tid); message << qVariantFromValue(socket); if (d->parentWindow) { message << qVariantFromValue(static_cast(d->parentWindow->effectiveWinId())); } else { message << qVariantFromValue(0u); } if (!QDBusConnection::sessionBus().send(message)) { qCWarning(APPER_LIB) << "Failed to put SetupDebconfDialog message in DBus queue"; } transaction->setHints(QLatin1String("frontend-socket=") % socket); #endif //HAVE_DEBCONFKDE } void PkTransaction::showDialog(QDialog *dlg) { auto widget = qobject_cast(d->parentWindow); if (!widget || widget->isCancelVisible()) { dlg->setModal(d->parentWindow); dlg->show(); } else { dlg->setProperty("embedded", true); emit dialog(dlg); } } void PkTransaction::showError(const QString &title, const QString &description, const QString &details) { auto widget = qobject_cast(d->parentWindow); if (!widget || widget->isCancelVisible()) { if (details.isEmpty()) { if (d->parentWindow) { KMessageBox::error(d->parentWindow, description, title); } else { KMessageBox::errorWId(0, description, title); } } else { KMessageBox::detailedError(d->parentWindow, description, details, title); } } else { emit errorMessage(title, description, details); } } void PkTransaction::showSorry(const QString &title, const QString &description, const QString &details) { auto widget = qobject_cast(d->parentWindow); if (!widget || widget->isCancelVisible()) { if (details.isEmpty()) { KMessageBox::sorry(d->parentWindow, description, title); } else { KMessageBox::detailedSorry(d->parentWindow, description, details, title); } } else { emit sorry(title, description, details); } } QString PkTransaction::title() const { return PkStrings::action(d->originalRole, d->flags); } Transaction::Role PkTransaction::cachedRole() const { return d->role; } Transaction::TransactionFlags PkTransaction::flags() const { return d->flags; } PkTransactionProgressModel *PkTransaction::progressModel() const { return d->progressModel; } void PkTransaction::enableJobWatcher(bool enable) { d->jobWatcher = enable; } #include "moc_PkTransaction.cpp"