File indexing completed on 2024-04-28 05:46:37

0001 /***************************************************************************
0002  *   Copyright (C) 2008-2011 by Daniel Nicoletti                           *
0003  *   dantti12@gmail.com                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 
0021 #include "PkStrings.h"
0022 
0023 #include <QDebug>
0024 
0025 #include <KLocalizedString>
0026 #include <KFormat>
0027 
0028 #include <limits.h>
0029 
0030 using namespace PackageKit;
0031 
0032 QString PkStrings::status(Transaction::Status status, uint speed, qulonglong downloadRemaining)
0033 {
0034     switch (status) {
0035     case Transaction::StatusUnknown:
0036         return i18nc("This is when the transaction status is not known",
0037                      "Unknown state");
0038     case Transaction::StatusSetup:
0039         return i18nc("transaction state, the daemon is in the process of starting",
0040                      "Waiting for service to start");
0041     case Transaction::StatusWait:
0042         return i18nc("transaction state, the transaction is waiting for another to complete",
0043                      "Waiting for other tasks");
0044     case Transaction::StatusRunning :
0045         return i18nc("transaction state, just started",
0046                      "Running task");
0047     case Transaction::StatusQuery :
0048         return i18nc("transaction state, is querying data",
0049                      "Querying");
0050     case Transaction::StatusInfo :
0051         return i18nc("transaction state, getting data from a server",
0052                      "Getting information");
0053     case Transaction::StatusRemove :
0054         return i18nc("transaction state, removing packages",
0055                      "Removing packages");
0056     case Transaction::StatusDownload:
0057         if (speed != 0 && downloadRemaining != 0) {
0058             return i18nc("transaction state, downloading package files",
0059                          "Downloading at %1/s, %2 remaining",
0060                          KFormat().formatByteSize(speed),
0061                          KFormat().formatByteSize(downloadRemaining));
0062         } else if (speed != 0 && downloadRemaining == 0) {
0063             return i18nc("transaction state, downloading package files",
0064                          "Downloading at %1/s",
0065                          KFormat().formatByteSize(speed));
0066         } else if (speed == 0 && downloadRemaining != 0) {
0067             return i18nc("transaction state, downloading package files",
0068                          "Downloading, %1 remaining",
0069                          KFormat().formatByteSize(downloadRemaining));
0070         } else {
0071             return i18nc("transaction state, downloading package files",
0072                          "Downloading");
0073         }
0074     case Transaction::StatusInstall :
0075         return i18nc("transaction state, installing packages",
0076                      "Installing packages");
0077     case Transaction::StatusRefreshCache :
0078         return i18nc("transaction state, refreshing internal lists",
0079                      "Refreshing software list");
0080     case Transaction::StatusUpdate :
0081         return i18nc("transaction state, installing updates",
0082                      "Updating packages");
0083     case Transaction::StatusCleanup :
0084         return i18nc("transaction state, removing old packages, and cleaning config files",
0085                      "Cleaning up packages");
0086     case Transaction::StatusObsolete :
0087         return i18nc("transaction state, obsoleting old packages",
0088                      "Obsoleting packages");
0089     case Transaction::StatusDepResolve :
0090         return i18nc("transaction state, checking the transaction before we do it",
0091                      "Resolving dependencies");
0092     case Transaction::StatusSigCheck :
0093         return i18nc("transaction state, checking if we have all the security keys for the operation",
0094                      "Checking signatures");
0095     case Transaction::StatusTestCommit :
0096         return i18nc("transaction state, when we're doing a test transaction",
0097                      "Testing changes");
0098     case Transaction::StatusCommit :
0099         return i18nc("transaction state, when we're writing to the system package database",
0100                      "Committing changes");
0101     case Transaction::StatusRequest :
0102         return i18nc("transaction state, requesting data from a server",
0103                      "Requesting data");
0104     case Transaction::StatusFinished :
0105         return i18nc("transaction state, all done!",
0106                      "Finished");
0107     case Transaction::StatusCancel :
0108         return i18nc("transaction state, in the process of cancelling",
0109                      "Cancelling");
0110     case Transaction::StatusDownloadRepository :
0111         return i18nc("transaction state, downloading metadata",
0112                      "Downloading repository information");
0113     case Transaction::StatusDownloadPackagelist :
0114         return i18nc("transaction state, downloading metadata",
0115                      "Downloading list of packages");
0116     case Transaction::StatusDownloadFilelist :
0117         return i18nc("transaction state, downloading metadata",
0118                      "Downloading file lists");
0119     case Transaction::StatusDownloadChangelog :
0120         return i18nc("transaction state, downloading metadata",
0121                      "Downloading lists of changes");
0122     case Transaction::StatusDownloadGroup :
0123         return i18nc("transaction state, downloading metadata",
0124                      "Downloading groups");
0125     case Transaction::StatusDownloadUpdateinfo :
0126         return i18nc("transaction state, downloading metadata",
0127                      "Downloading update information");
0128     case Transaction::StatusRepackaging :
0129         return i18nc("transaction state, repackaging delta files",
0130                      "Repackaging files");
0131     case Transaction::StatusLoadingCache :
0132         return i18nc("transaction state, loading databases",
0133                      "Loading cache");
0134     case Transaction::StatusScanApplications :
0135         return i18nc("transaction state, scanning for running processes",
0136                      "Scanning installed applications");
0137     case Transaction::StatusGeneratePackageList :
0138         return i18nc("transaction state, generating a list of packages installed on the system",
0139                      "Generating package lists");
0140     case Transaction::StatusWaitingForLock :
0141         return i18nc("transaction state, when we're waiting for the native tools to exit",
0142                      "Waiting for package manager lock");
0143     case Transaction::StatusWaitingForAuth :
0144         return i18nc("waiting for user to type in a password",
0145                      "Waiting for authentication");
0146     case Transaction::StatusScanProcessList :
0147         return i18nc("we are updating the list of processes",
0148                      "Updating the list of running applications");
0149     case Transaction::StatusCheckExecutableFiles :
0150         return i18nc("we are checking executable files in use",
0151                      "Checking for applications currently in use");
0152     case Transaction::StatusCheckLibraries :
0153         return i18nc("we are checking for libraries in use",
0154                      "Checking for libraries currently in use");
0155     case Transaction::StatusCopyFiles :
0156         return i18nc("we are copying package files to prepare to install",
0157                      "Copying files");
0158     }
0159     qWarning() << "status unrecognised: " << status;
0160     return QString();
0161 }
0162 
0163 QString PkStrings::statusPast(Transaction::Status status)
0164 {
0165     switch (status) {
0166     case Transaction::StatusDownload:
0167         return i18nc("The action of the package, in past tense", "Downloaded");
0168     case Transaction::StatusUpdate:
0169         return i18nc("The action of the package, in past tense", "Updated");
0170     case Transaction::StatusInstall:
0171         return i18nc("The action of the package, in past tense", "Installed");
0172     case Transaction::StatusRemove:
0173         return i18nc("The action of the package, in past tense", "Removed");
0174     case Transaction::StatusCleanup:
0175         return i18nc("The action of the package, in past tense", "Cleaned Up");
0176     case Transaction::StatusObsolete:
0177         return i18nc("The action of the package, in past tense", "Obsoleted");
0178     default : // In this case we don't want to map all enums
0179         qWarning() << "status unrecognised: " << status;
0180         return QString();
0181     }
0182 }
0183 
0184 QString PkStrings::action(Transaction::Role role, Transaction::TransactionFlags flags)
0185 {
0186     switch (role) {
0187     case Transaction::RoleUnknown :
0188         return i18nc("The role of the transaction, in present tense", "Unknown role type");
0189     case Transaction::RoleDependsOn :
0190         return i18nc("The role of the transaction, in present tense", "Getting dependencies");
0191     case Transaction::RoleGetUpdateDetail :
0192         return i18nc("The role of the transaction, in present tense", "Getting update detail");
0193     case Transaction::RoleGetDetails:
0194     case Transaction::RoleGetDetailsLocal:
0195         return i18nc("The role of the transaction, in present tense", "Getting details");
0196     case Transaction::RoleRequiredBy :
0197         return i18nc("The role of the transaction, in present tense", "Getting requires");
0198     case Transaction::RoleGetUpdates :
0199         return i18nc("The role of the transaction, in present tense", "Getting updates");
0200     case Transaction::RoleSearchDetails :
0201         return i18nc("The role of the transaction, in present tense", "Searching details");
0202     case Transaction::RoleSearchFile :
0203         return i18nc("The role of the transaction, in present tense", "Searching for file");
0204     case Transaction::RoleSearchGroup :
0205         return i18nc("The role of the transaction, in present tense", "Searching groups");
0206     case Transaction::RoleSearchName :
0207         return i18nc("The role of the transaction, in present tense", "Searching by package name");
0208     case Transaction::RoleRemovePackages :
0209         if (flags & Transaction::TransactionFlagSimulate) {
0210             return i18nc("The role of the transaction, in present tense", "Simulating removal");
0211         } else if (flags & Transaction::TransactionFlagOnlyDownload) {
0212             return i18nc("The role of the transaction, in present tense", "Downloading packages");
0213         }
0214         return i18nc("The role of the transaction, in present tense", "Removing");
0215     case Transaction::RoleInstallPackages :
0216         if (flags & Transaction::TransactionFlagSimulate) {
0217             return i18nc("The role of the transaction, in present tense", "Simulating install");
0218         } else if (flags & Transaction::TransactionFlagOnlyDownload) {
0219             return i18nc("The role of the transaction, in present tense", "Downloading packages");
0220         }
0221         return i18nc("The role of the transaction, in present tense", "Installing");
0222     case Transaction::RoleInstallFiles :
0223         if (flags & Transaction::TransactionFlagSimulate) {
0224             return i18nc("The role of the transaction, in present tense", "Simulating file install");
0225         } else if (flags & Transaction::TransactionFlagOnlyDownload) {
0226             return i18nc("The role of the transaction, in present tense", "Downloading required packages");
0227         }
0228         return i18nc("The role of the transaction, in present tense", "Installing file");
0229     case Transaction::RoleRefreshCache :
0230         return i18nc("The role of the transaction, in present tense", "Refreshing package cache");
0231     case Transaction::RoleUpdatePackages :
0232         if (flags & Transaction::TransactionFlagSimulate) {
0233             return i18nc("The role of the transaction, in present tense", "Simulating update");
0234         } else if (flags & Transaction::TransactionFlagOnlyDownload) {
0235             return i18nc("The role of the transaction, in present tense", "Downloading updates");
0236         }
0237         return i18nc("The role of the transaction, in present tense", "Updating packages");
0238     case Transaction::RoleCancel :
0239         return i18nc("The role of the transaction, in present tense", "Canceling");
0240     case Transaction::RoleGetRepoList :
0241         return i18nc("The role of the transaction, in present tense", "Getting list of repositories");
0242     case Transaction::RoleRepoEnable :
0243         return i18nc("The role of the transaction, in present tense", "Enabling repository");
0244     case Transaction::RoleRepoSetData :
0245         return i18nc("The role of the transaction, in present tense", "Setting repository data");
0246     case Transaction::RoleResolve :
0247         return i18nc("The role of the transaction, in present tense", "Resolving");
0248     case Transaction::RoleGetFiles:
0249     case Transaction::RoleGetFilesLocal:
0250         return i18nc("The role of the transaction, in present tense", "Getting file list");
0251     case Transaction::RoleWhatProvides :
0252         return i18nc("The role of the transaction, in present tense", "Getting what provides");
0253     case Transaction::RoleInstallSignature :
0254         return i18nc("The role of the transaction, in present tense", "Installing signature");
0255     case Transaction::RoleGetPackages :
0256         return i18nc("The role of the transaction, in present tense", "Getting package lists");
0257     case Transaction::RoleAcceptEula :
0258         return i18nc("The role of the transaction, in present tense", "Accepting EULA");
0259     case Transaction::RoleDownloadPackages :
0260         return i18nc("The role of the transaction, in present tense", "Downloading packages");
0261     case Transaction::RoleGetDistroUpgrades :
0262         return i18nc("The role of the transaction, in present tense", "Getting distribution upgrade information");
0263     case Transaction::RoleGetCategories :
0264         return i18nc("The role of the transaction, in present tense", "Getting categories");
0265     case Transaction::RoleGetOldTransactions :
0266         return i18nc("The role of the transaction, in present tense", "Getting old transactions");
0267     case Transaction::RoleRepairSystem :
0268         return i18nc("The role of the transaction, in present tense", "Repairing system");
0269     case Transaction::RoleRepoRemove:
0270         return i18nc("The role of the transaction, in present tense", "Removing repository");
0271     }
0272     qWarning() << "action unrecognised: " << role;
0273     return QString();
0274 }
0275 
0276 QString PkStrings::actionPast(Transaction::Role action)
0277 {
0278     switch (action) {
0279     case Transaction::RoleUnknown:
0280         return i18nc("The role of the transaction, in past tense", "Unknown role type");
0281     case Transaction::RoleDependsOn :
0282         return i18nc("The role of the transaction, in past tense", "Got dependencies");
0283     case Transaction::RoleGetUpdateDetail :
0284         return i18nc("The role of the transaction, in past tense", "Got update detail");
0285     case Transaction::RoleGetDetails:
0286     case Transaction::RoleGetDetailsLocal:
0287         return i18nc("The role of the transaction, in past tense", "Got details");
0288     case Transaction::RoleRequiredBy :
0289         return i18nc("The role of the transaction, in past tense", "Got requires");
0290     case Transaction::RoleGetUpdates :
0291         return i18nc("The role of the transaction, in past tense", "Got updates");
0292     case Transaction::RoleSearchDetails :
0293         return i18nc("The role of the transaction, in past tense", "Searched for package details");
0294     case Transaction::RoleSearchFile :
0295         return i18nc("The role of the transaction, in past tense", "Searched for file");
0296     case Transaction::RoleSearchGroup :
0297         return i18nc("The role of the transaction, in past tense", "Searched groups");
0298     case Transaction::RoleSearchName :
0299         return i18nc("The role of the transaction, in past tense", "Searched for package name");
0300     case Transaction::RoleRemovePackages :
0301         return i18nc("The role of the transaction, in past tense", "Removed packages");
0302     case Transaction::RoleInstallPackages :
0303         return i18nc("The role of the transaction, in past tense", "Installed packages");
0304     case Transaction::RoleInstallFiles :
0305         return i18nc("The role of the transaction, in past tense", "Installed local files");
0306     case Transaction::RoleRefreshCache :
0307         return i18nc("The role of the transaction, in past tense", "Refreshed package cache");
0308     case Transaction::RoleUpdatePackages :
0309         return i18nc("The role of the transaction, in past tense", "Updated packages");
0310     case Transaction::RoleCancel :
0311         return i18nc("The role of the transaction, in past tense", "Canceled");
0312     case Transaction::RoleGetRepoList :
0313         return i18nc("The role of the transaction, in past tense", "Got list of repositories");
0314     case Transaction::RoleRepoEnable :
0315         return i18nc("The role of the transaction, in past tense", "Enabled repository");
0316     case Transaction::RoleRepoSetData :
0317         return i18nc("The role of the transaction, in past tense", "Set repository data");
0318     case Transaction::RoleResolve :
0319         return i18nc("The role of the transaction, in past tense", "Resolved");
0320     case Transaction::RoleGetFiles:
0321     case Transaction::RoleGetFilesLocal:
0322         return i18nc("The role of the transaction, in past tense", "Got file list");
0323     case Transaction::RoleWhatProvides :
0324         return i18nc("The role of the transaction, in past tense", "Got what provides");
0325     case Transaction::RoleInstallSignature :
0326         return i18nc("The role of the transaction, in past tense", "Installed signature");
0327     case Transaction::RoleGetPackages :
0328         return i18nc("The role of the transaction, in past tense", "Got package lists");
0329     case Transaction::RoleAcceptEula :
0330         return i18nc("The role of the transaction, in past tense", "Accepted EULA");
0331     case Transaction::RoleDownloadPackages :
0332         return i18nc("The role of the transaction, in past tense", "Downloaded packages");
0333     case Transaction::RoleGetDistroUpgrades :
0334         return i18nc("The role of the transaction, in past tense", "Got distribution upgrades");
0335     case Transaction::RoleGetCategories :
0336         return i18nc("The role of the transaction, in past tense", "Got categories");
0337     case Transaction::RoleGetOldTransactions :
0338         return i18nc("The role of the transaction, in past tense", "Got old transactions");
0339     case Transaction::RoleRepairSystem:
0340         return i18nc("The role of the transaction, in past tense", "Repaired system");
0341     case Transaction::RoleRepoRemove:
0342         return i18nc("The role of the transaction, in past tense", "Removed repository");
0343     }
0344     qWarning() << "action unrecognised: " << action;
0345     return QString();
0346 }
0347 
0348 QString PkStrings::infoPresent(Transaction::Info info)
0349 {
0350     switch (info) {
0351     case Transaction::InfoDownloading :
0352         return i18n("Downloading");
0353     case Transaction::InfoUpdating :
0354         return i18n("Updating");
0355     case Transaction::InfoInstalling :
0356         return i18n("Installing");
0357     case Transaction::InfoRemoving :
0358         return i18n("Removing");
0359     case Transaction::InfoCleanup :
0360         return i18n("Cleaning up");
0361     case Transaction::InfoObsoleting :
0362         return i18n("Obsoleting");
0363     case Transaction::InfoReinstalling :
0364         return i18n("Reinstalling");
0365     case Transaction::InfoPreparing :
0366         return i18n("Preparing");
0367     case Transaction::InfoDecompressing :
0368         return i18n("Decompressing");
0369     default :
0370         qWarning() << "info unrecognised:" << info;
0371         return QString();
0372     }
0373 }
0374 
0375 QString PkStrings::infoPast(Transaction::Info info)
0376 {
0377     switch (info) {
0378     case Transaction::InfoDownloading :
0379         return i18n("Downloaded");
0380     case Transaction::InfoUpdating :
0381         return i18n("Updated");
0382     case Transaction::InfoInstalling :
0383         return i18n("Installed");
0384     case Transaction::InfoRemoving :
0385         return i18n("Removed");
0386     case Transaction::InfoCleanup :
0387         return i18n("Cleaned up");
0388     case Transaction::InfoObsoleting :
0389         return i18n("Obsoleted");
0390     case Transaction::InfoReinstalling :
0391         return i18n("Reinstalled");
0392     case Transaction::InfoPreparing :
0393         return i18n("Prepared");
0394     case Transaction::InfoDecompressing :
0395         return i18n("Decompressed");
0396     default :
0397         qWarning() << "info unrecognised: " << info;
0398         return QString();
0399     }
0400 }
0401 
0402 QString PkStrings::error(Transaction::Error error)
0403 {
0404     switch (error) {
0405     case Transaction::ErrorNoNetwork :
0406         return i18n("No network connection available");
0407     case Transaction::ErrorNoCache :
0408         return i18n("No package cache is available");
0409     case Transaction::ErrorOom :
0410         return i18n("Out of memory");
0411     case Transaction::ErrorCreateThreadFailed :
0412         return i18n("Failed to create a thread");
0413     case Transaction::ErrorNotSupported :
0414         return i18n("Not supported by this backend");
0415     case Transaction::ErrorInternalError :
0416         return i18n("An internal system error has occurred");
0417     case Transaction::ErrorGpgFailure :
0418         return i18n("A security trust relationship is not present");
0419     case Transaction::ErrorPackageNotInstalled :
0420         return i18n("The package is not installed");
0421     case Transaction::ErrorPackageNotFound :
0422         return i18n("The package was not found");
0423     case Transaction::ErrorPackageAlreadyInstalled :
0424         return i18n("The package is already installed");
0425     case Transaction::ErrorPackageDownloadFailed :
0426         return i18n("The package download failed");
0427     case Transaction::ErrorGroupNotFound :
0428         return i18n("The group was not found");
0429     case Transaction::ErrorGroupListInvalid :
0430         return i18n("The group list was invalid");
0431     case Transaction::ErrorDepResolutionFailed :
0432         return i18n("Dependency resolution failed");
0433     case Transaction::ErrorFilterInvalid :
0434         return i18n("Search filter was invalid");
0435     case Transaction::ErrorPackageIdInvalid :
0436         return i18n("The package identifier was not well formed");
0437     case Transaction::ErrorTransactionError :
0438         return i18n("Transaction error");
0439     case Transaction::ErrorRepoNotFound :
0440         return i18n("Repository name was not found");
0441     case Transaction::ErrorCannotRemoveSystemPackage :
0442         return i18n("Could not remove a protected system package");
0443     case Transaction::ErrorTransactionCancelled :
0444         return i18n("The task was canceled");
0445     case Transaction::ErrorProcessKill :
0446         return i18n("The task was forcibly canceled");
0447     case Transaction::ErrorFailedConfigParsing :
0448         return i18n("Reading the config file failed");
0449     case Transaction::ErrorCannotCancel :
0450         return i18n("The task cannot be cancelled");
0451     case Transaction::ErrorCannotInstallSourcePackage :
0452         return i18n("Source packages cannot be installed");
0453     case Transaction::ErrorNoLicenseAgreement :
0454         return i18n("The license agreement failed");
0455     case Transaction::ErrorFileConflicts :
0456         return i18n("Local file conflict between packages");
0457     case Transaction::ErrorPackageConflicts :
0458         return i18n("Packages are not compatible");
0459     case Transaction::ErrorRepoNotAvailable :
0460         return i18n("Problem connecting to a software origin");
0461     case Transaction::ErrorFailedInitialization :
0462         return i18n("Failed to initialize");
0463     case Transaction::ErrorFailedFinalise :
0464         return i18n("Failed to finalize");
0465     case Transaction::ErrorCannotGetLock :
0466         return i18n("Cannot get lock");
0467     case Transaction::ErrorNoPackagesToUpdate :
0468         return i18n("No packages to update");
0469     case Transaction::ErrorCannotWriteRepoConfig :
0470         return i18n("Cannot write repository configuration");
0471     case Transaction::ErrorLocalInstallFailed :
0472         return i18n("Local install failed");
0473     case Transaction::ErrorBadGpgSignature :
0474         return i18n("Bad GPG signature");
0475     case Transaction::ErrorMissingGpgSignature :
0476         return i18n("Missing GPG signature");
0477     case Transaction::ErrorRepoConfigurationError :
0478         return i18n("Repository configuration invalid");
0479     case Transaction::ErrorInvalidPackageFile :
0480         return i18n("Invalid package file");
0481     case Transaction::ErrorPackageInstallBlocked :
0482         return i18n("Package install blocked");
0483     case Transaction::ErrorPackageCorrupt :
0484         return i18n("Package is corrupt");
0485     case Transaction::ErrorAllPackagesAlreadyInstalled :
0486         return i18n("All packages are already installed");
0487     case Transaction::ErrorFileNotFound :
0488         return i18n("The specified file could not be found");
0489     case Transaction::ErrorNoMoreMirrorsToTry :
0490         return i18n("No more mirrors are available");
0491     case Transaction::ErrorNoDistroUpgradeData :
0492         return i18n("No distribution upgrade data is available");
0493     case Transaction::ErrorIncompatibleArchitecture :
0494         return i18n("Package is incompatible with this system");
0495     case Transaction::ErrorNoSpaceOnDevice :
0496         return i18n("No space is left on the disk");
0497     case Transaction::ErrorMediaChangeRequired :
0498         return i18n("A media change is required");
0499     case Transaction::ErrorNotAuthorized :
0500         return i18n("Authorization failed");
0501     case Transaction::ErrorUpdateNotFound :
0502         return i18n("Update not found");
0503     case Transaction::ErrorCannotInstallRepoUnsigned :
0504         return i18n("Cannot install from untrusted origin");
0505     case Transaction::ErrorCannotUpdateRepoUnsigned :
0506         return i18n("Cannot update from untrusted origin");
0507     case Transaction::ErrorCannotGetFilelist :
0508         return i18n("Cannot get the file list");
0509     case Transaction::ErrorCannotGetRequires :
0510         return i18n("Cannot get package requires");
0511     case Transaction::ErrorCannotDisableRepository :
0512         return i18n("Cannot disable origin");
0513     case Transaction::ErrorRestrictedDownload :
0514         return i18n("The download failed");
0515     case Transaction::ErrorPackageFailedToConfigure :
0516         return i18n("Package failed to configure");
0517     case Transaction::ErrorPackageFailedToBuild :
0518         return i18n("Package failed to build");
0519     case Transaction::ErrorPackageFailedToInstall :
0520         return i18n("Package failed to install");
0521     case Transaction::ErrorPackageFailedToRemove :
0522         return i18n("Package failed to be removed");
0523     case Transaction::ErrorUpdateFailedDueToRunningProcess :
0524         return i18n("Update failed due to running process");
0525     case Transaction::ErrorPackageDatabaseChanged :
0526         return i18n("The package database was changed");
0527     case Transaction::ErrorProvideTypeNotSupported :
0528         return i18n("Virtual provide type is not supported");
0529     case Transaction::ErrorInstallRootInvalid :
0530         return i18n("Install root is invalid");
0531     case Transaction::ErrorCannotFetchSources :
0532         return i18n("Cannot fetch install sources");
0533     case Transaction::ErrorCancelledPriority :
0534         return i18n("Rescheduled due to priority");
0535     case Transaction::ErrorUnfinishedTransaction:
0536         return i18n("Unfinished transaction");
0537     case Transaction::ErrorLockRequired:
0538         return i18n("Lock required");
0539     case Transaction::ErrorUnknown:
0540         return i18n("Unknown error");
0541     }
0542     qWarning() << "error unrecognised: " << error;
0543     return QString();
0544 }
0545 
0546 QString PkStrings::errorMessage(Transaction::Error error)
0547 {
0548     switch (error) {
0549     case Transaction::ErrorNoNetwork :
0550         return i18n("There is no network connection available.\n"
0551                     "Please check your connection settings and try again");
0552     case Transaction::ErrorNoCache :
0553         return i18n("The package list needs to be rebuilt.\n"
0554                     "This should have been done by the backend automatically.");
0555     case Transaction::ErrorOom :
0556         return i18n("The service that is responsible for handling user requests is out of memory.\n"
0557                     "Please close some programs or restart your computer.");
0558     case Transaction::ErrorCreateThreadFailed :
0559         return i18n("A thread could not be created to service the user request.");
0560     case Transaction::ErrorNotSupported :
0561         return i18n("The action is not supported by this backend.\n"
0562                     "Please report a bug as this should not have happened.");
0563     case Transaction::ErrorInternalError :
0564         return i18n("A problem that we were not expecting has occurred.\n"
0565                     "Please report this bug with the error description.");
0566     case Transaction::ErrorGpgFailure :
0567         return i18n("A security trust relationship could not be made with the software origin.\n"
0568                     "Please check your software signature settings.");
0569     case Transaction::ErrorPackageNotInstalled :
0570         return i18n("The package that is trying to be removed or updated is not already installed.");
0571     case Transaction::ErrorPackageNotFound :
0572         return i18n("The package that is being modified was not found on your system or in any software origin.");
0573     case Transaction::ErrorPackageAlreadyInstalled :
0574         return i18n("The package that is trying to be installed is already installed.");
0575     case Transaction::ErrorPackageDownloadFailed :
0576         return i18n("The package download failed.\n"
0577                     "Please check your network connectivity.");
0578     case Transaction::ErrorGroupNotFound :
0579         return i18n("The group type was not found.\n"
0580                     "Please check your group list and try again.");
0581     case Transaction::ErrorGroupListInvalid :
0582         return i18n("The group list could not be loaded.\n"
0583                     "Refreshing your cache may help, although this is normally a software "
0584                     "origin error.");
0585     case Transaction::ErrorDepResolutionFailed :
0586         return i18n("A package dependency could not be found.\n"
0587                     "More information is available in the detailed report.");
0588     case Transaction::ErrorFilterInvalid :
0589         return i18n("The search filter was not correctly formed.");
0590     case Transaction::ErrorPackageIdInvalid :
0591         return i18n("The package identifier was not well formed when sent to the system daemon.\n"
0592                     "This normally indicates an internal bug and should be reported.");
0593     case Transaction::ErrorTransactionError :
0594         return i18n("An error occurred while running the transaction.\n"
0595                     "More information is available in the detailed report.");
0596     case Transaction::ErrorRepoNotFound :
0597         return i18n("The remote software origin name was not found.\n"
0598                     "You may need to enable an item in Software Origins.");
0599     case Transaction::ErrorCannotRemoveSystemPackage :
0600         return i18n("Removing a protected system package is not allowed.");
0601     case Transaction::ErrorTransactionCancelled :
0602         return i18n("The task was canceled successfully and no packages were changed.");
0603     case Transaction::ErrorProcessKill :
0604         return i18n("The task was canceled successfully and no packages were changed.\n"
0605                     "The backend did not exit cleanly.");
0606     case Transaction::ErrorFailedConfigParsing :
0607         return i18n("The native package configuration file could not be opened.\n"
0608                     "Please make sure your system's configuration is valid.");
0609     case Transaction::ErrorCannotCancel :
0610         return i18n("The task is not safe to be cancelled at this time.");
0611     case Transaction::ErrorCannotInstallSourcePackage :
0612         return i18n("Source packages are not normally installed this way.\n"
0613                     "Check the extension of the file you are trying to install.");
0614     case Transaction::ErrorNoLicenseAgreement :
0615         return i18n("The license agreement was not agreed to.\n"
0616                     "To use this software you have to accept the license.");
0617     case Transaction::ErrorFileConflicts :
0618         return i18n("Two packages provide the same file.\n"
0619                     "This is usually due to mixing packages for different software origins.");
0620     case Transaction::ErrorPackageConflicts :
0621         return i18n("Multiple packages exist that are not compatible with each other.\n"
0622                     "This is usually due to mixing packages from different software origins.");
0623     case Transaction::ErrorRepoNotAvailable :
0624         return i18n("There was a (possibly temporary) problem connecting to a software origins.\n"
0625                     "Please check the detailed error for further details.");
0626     case Transaction::ErrorFailedInitialization :
0627         return i18n("Failed to initialize packaging backend.\n"
0628                     "This may occur if other packaging tools are being used simultaneously.");
0629     case Transaction::ErrorFailedFinalise :
0630         return i18n("Failed to close down the backend instance.\n"
0631                     "This error can normally be ignored.");
0632     case Transaction::ErrorCannotGetLock :
0633         return i18n("Cannot get the exclusive lock on the packaging backend.\n"
0634                     "Please close any other legacy packaging tools that may be open.");
0635     case Transaction::ErrorNoPackagesToUpdate :
0636         return i18n("None of the selected packages could be updated.");
0637     case Transaction::ErrorCannotWriteRepoConfig :
0638         return i18n("The repository configuration could not be modified.");
0639     case Transaction::ErrorLocalInstallFailed :
0640         return i18n("Installing the local file failed.\n"
0641                     "More information is available in the detailed report.");
0642     case Transaction::ErrorBadGpgSignature :
0643         return i18n("The package signature could not be verified.");
0644     case Transaction::ErrorMissingGpgSignature :
0645         return i18n("The package signature was missing and this package is untrusted.\n"
0646                     "This package was not signed with a GPG key when created.");
0647     case Transaction::ErrorRepoConfigurationError :
0648         return i18n("Repository configuration was invalid and could not be read.");
0649     case Transaction::ErrorInvalidPackageFile :
0650         return i18n("The package you are attempting to install is not valid.\n"
0651                     "The package file could be corrupt, or not a proper package.");
0652     case Transaction::ErrorPackageInstallBlocked :
0653         return i18n("Installation of this package was prevented by your packaging system's configuration.");
0654     case Transaction::ErrorPackageCorrupt :
0655         return i18n("The package that was downloaded is corrupt and needs to be downloaded again.");
0656     case Transaction::ErrorAllPackagesAlreadyInstalled :
0657         return i18n("All of the packages selected for install are already installed on the system.");
0658     case Transaction::ErrorFileNotFound :
0659         return i18n("The specified file could not be found on the system.\n"
0660                     "Check that the file still exists and has not been deleted.");
0661     case Transaction::ErrorNoMoreMirrorsToTry :
0662         return i18n("Required data could not be found on any of the configured software origins.\n"
0663                     "There were no more download mirrors that could be tried.");
0664     case Transaction::ErrorNoDistroUpgradeData :
0665         return i18n("Required upgrade data could not be found in any of the configured software origins.\n"
0666                     "The list of distribution upgrades will be unavailable.");
0667     case Transaction::ErrorIncompatibleArchitecture :
0668         return i18n("The package that is trying to be installed is incompatible with this system.");
0669     case Transaction::ErrorNoSpaceOnDevice :
0670         return i18n("There is insufficient space on the device.\n"
0671                     "Free some space on the system disk to perform this operation.");
0672     case Transaction::ErrorMediaChangeRequired :
0673         return i18n("Additional media is required to complete the transaction.");
0674     case Transaction::ErrorNotAuthorized :
0675         return i18n("You have failed to provide correct authentication.\n"
0676                     "Please check any passwords or account settings.");
0677     case Transaction::ErrorUpdateNotFound :
0678         return i18n("The specified update could not be found.\n"
0679                     "It could have already been installed or no longer available on the remote server.");
0680     case Transaction::ErrorCannotInstallRepoUnsigned :
0681         return i18n("The package could not be installed from untrusted origin.");
0682     case Transaction::ErrorCannotUpdateRepoUnsigned :
0683         return i18n("The package could not be updated from untrusted origin.");
0684     case Transaction::ErrorCannotGetFilelist :
0685         return i18n("The file list is not available for this package.");
0686     case Transaction::ErrorCannotGetRequires :
0687         return i18n("The information about what requires this package could not be obtained.");
0688     case Transaction::ErrorCannotDisableRepository :
0689         return i18n("The specified software origin could not be disabled.");
0690     case Transaction::ErrorRestrictedDownload :
0691         return i18n("The download could not be done automatically and should be done manually.\n"
0692                     "More information is available in the detailed report.");
0693     case Transaction::ErrorPackageFailedToConfigure :
0694         return i18n("One of the selected packages failed to configure correctly.\n"
0695                     "More information is available in the detailed report.");
0696     case Transaction::ErrorPackageFailedToBuild :
0697         return i18n("One of the selected packages failed to build correctly.\n"
0698                     "More information is available in the detailed report.");
0699     case Transaction::ErrorPackageFailedToInstall :
0700         return i18n("One of the selected packages failed to install correctly.\n"
0701                     "More information is available in the detailed report.");
0702     case Transaction::ErrorPackageFailedToRemove :
0703         return i18n("One of the selected packages failed to be removed correctly.\n"
0704                     "More information is available in the detailed report.");
0705     case Transaction::ErrorUpdateFailedDueToRunningProcess :
0706         return i18n("A program is running that has to be closed before the update can proceed.\n"
0707                     "More information is available in the detailed report.");
0708     case Transaction::ErrorPackageDatabaseChanged :
0709         return i18n("The package database was changed while the request was running.");
0710     case Transaction::ErrorProvideTypeNotSupported :
0711         return i18n("The virtual provide type is not supported by this system.");
0712     case Transaction::ErrorInstallRootInvalid :
0713         return i18n("The install root is invalid. Please contact your administrator.");
0714     case Transaction::ErrorCannotFetchSources :
0715         return i18n("The list of software could not be downloaded.");
0716     case Transaction::ErrorCancelledPriority :
0717         return i18n("The transaction has been cancelled and will be retried when the system is idle.");
0718     case Transaction::ErrorUnfinishedTransaction :
0719         return i18n("A previous package management transaction was interrupted.");
0720     case Transaction::ErrorLockRequired :
0721         return i18n("A package manager lock is required.");
0722     case Transaction::ErrorUnknown:
0723         return i18n("Unknown error, please report a bug.\n"
0724                     "More information is available in the detailed report.");
0725     }
0726     qWarning() << "error unrecognised: " << error;
0727     return QString();
0728 }
0729 
0730 QString PkStrings::groups(Transaction::Group group)
0731 {
0732     switch (group) {
0733     case Transaction::GroupAccessibility :
0734         return i18nc("The group type", "Accessibility");
0735     case Transaction::GroupAccessories :
0736         return i18nc("The group type", "Accessories");
0737     case Transaction::GroupEducation :
0738         return i18nc("The group type", "Education");
0739     case Transaction::GroupGames :
0740         return i18nc("The group type", "Games");
0741     case Transaction::GroupGraphics :
0742         return i18nc("The group type", "Graphics");
0743     case Transaction::GroupInternet :
0744         return i18nc("The group type", "Internet");
0745     case Transaction::GroupOffice :
0746         return i18nc("The group type", "Office");
0747     case Transaction::GroupOther :
0748         return i18nc("The group type", "Others");
0749     case Transaction::GroupProgramming :
0750         return i18nc("The group type", "Development");
0751     case Transaction::GroupMultimedia :
0752         return i18nc("The group type", "Multimedia");
0753     case Transaction::GroupSystem :
0754         return i18nc("The group type", "System");
0755     case Transaction::GroupDesktopGnome :
0756         return i18nc("The group type", "GNOME desktop");
0757     case Transaction::GroupDesktopKde :
0758         return i18nc("The group type", "KDE desktop");
0759     case Transaction::GroupDesktopXfce :
0760         return i18nc("The group type", "XFCE desktop");
0761     case Transaction::GroupDesktopOther :
0762         return i18nc("The group type", "Other desktops");
0763     case Transaction::GroupPublishing :
0764         return i18nc("The group type", "Publishing");
0765     case Transaction::GroupServers :
0766         return i18nc("The group type", "Servers");
0767     case Transaction::GroupFonts :
0768         return i18nc("The group type", "Fonts");
0769     case Transaction::GroupAdminTools :
0770         return i18nc("The group type", "Admin tools");
0771     case Transaction::GroupLegacy :
0772         return i18nc("The group type", "Legacy");
0773     case Transaction::GroupLocalization :
0774         return i18nc("The group type", "Localization");
0775     case Transaction::GroupVirtualization :
0776         return i18nc("The group type", "Virtualization");
0777     case Transaction::GroupSecurity :
0778         return i18nc("The group type", "Security");
0779     case Transaction::GroupPowerManagement :
0780         return i18nc("The group type", "Power management");
0781     case Transaction::GroupCommunication :
0782         return i18nc("The group type", "Communication");
0783     case Transaction::GroupNetwork :
0784         return i18nc("The group type", "Network");
0785     case Transaction::GroupMaps :
0786         return i18nc("The group type", "Maps");
0787     case Transaction::GroupRepos :
0788         return i18nc("The group type", "Software sources");
0789     case Transaction::GroupScience :
0790         return i18nc("The group type", "Science");
0791     case Transaction::GroupDocumentation :
0792         return i18nc("The group type", "Documentation");
0793     case Transaction::GroupElectronics :
0794         return i18nc("The group type", "Electronics");
0795     case Transaction::GroupCollections ://TODO check this one
0796         return i18nc("The group type", "Package collections");
0797     case Transaction::GroupVendor :
0798         return i18nc("The group type", "Vendor");
0799     case Transaction::GroupNewest :
0800         return i18nc("The group type", "Newest packages");
0801     case Transaction::GroupUnknown:
0802         return i18nc("The group type", "Unknown group");
0803     }
0804     qWarning() << "group unrecognised: " << group;
0805     return QString();
0806 }
0807 
0808 QString PkStrings::info(int state)
0809 {
0810     Transaction::Info stateEnum = static_cast<Transaction::Info>(state);
0811     switch (stateEnum) {
0812     case Transaction::InfoLow :
0813         return i18nc("The type of update", "Trivial update");
0814     case Transaction::InfoNormal :
0815         return i18nc("The type of update", "Normal update");
0816     case Transaction::InfoImportant :
0817         return i18nc("The type of update", "Important update");
0818     case Transaction::InfoSecurity :
0819         return i18nc("The type of update", "Security update");
0820     case Transaction::InfoBugfix :
0821         return i18nc("The type of update", "Bug fix update");
0822     case Transaction::InfoEnhancement :
0823         return i18nc("The type of update", "Enhancement update");
0824     case Transaction::InfoBlocked :
0825         return i18nc("The type of update", "Blocked update");
0826     case Transaction::InfoInstalled :
0827     case Transaction::InfoCollectionInstalled :
0828         return i18nc("The type of update", "Installed");
0829     case Transaction::InfoAvailable :
0830     case Transaction::InfoCollectionAvailable :
0831         return i18nc("The type of update", "Available");
0832     case Transaction::InfoUnknown:
0833         return i18nc("The type of update", "Unknown update");
0834     default : // In this case we don't want to map all enums
0835         qWarning() << "info unrecognised: " << state;
0836         return QString();
0837     }
0838 }
0839 
0840 QString PkStrings::packageQuantity(bool updates, int packages, int selected)
0841 {
0842     if (updates) {
0843         if (packages == 0) {
0844             return i18n("No Updates Available");
0845         } else if (packages == selected) {
0846             return i18ncp("Some updates were selected on the view",
0847                           "1 Update Selected",
0848                           "%1 Updates Selected", packages);
0849         } else if (selected == 0) {
0850             return i18ncp("Some updates are being shown on the screen",
0851                           "1 Update", "%1 Updates",
0852                           packages);
0853         } else {
0854             return i18nc("Type of update, in the case it's just an update", "%1, %2",
0855                          i18ncp("Part of: %1 Updates, %1 Selected", "%1 Update", "%1 Updates", packages),
0856                          i18ncp("Part of: %1 Updates, %1 Selected", "%1 Selected", "%1 Selected", selected));
0857         }
0858     } else {
0859         if (packages == 0) {
0860             return i18n("No Packages");
0861         }
0862         return i18np("1 Package", "%1 Packages", packages);
0863     }
0864 }
0865 
0866 QString PkStrings::restartTypeFuture(Transaction::Restart value)
0867 {
0868     switch (value) {
0869     case Transaction::RestartNone:
0870         return i18n("No restart is necessary");
0871     case Transaction::RestartApplication:
0872         return i18n("You will be required to restart this application");
0873     case Transaction::RestartSession:
0874         return i18n("You will be required to log out and back in");
0875     case Transaction::RestartSystem:
0876         return i18n("A restart will be required");
0877     case Transaction::RestartSecuritySession:
0878         return i18n("You will be required to log out and back in due to a security update.");
0879     case Transaction::RestartSecuritySystem:
0880         return i18n("A restart will be required due to a security update.");
0881     case Transaction::RestartUnknown:
0882         qWarning() << "restartTypeFuture(Transaction::RestartUnknown)";
0883         return QString();
0884     }
0885     qWarning() << "restart unrecognised: " << value;
0886     return QString();
0887 }
0888 
0889 QString PkStrings::restartType(Transaction::Restart value)
0890 {
0891     switch (value) {
0892     case Transaction::RestartNone:
0893         return i18n("No restart is required");
0894     case Transaction::RestartSystem:
0895         return i18n("A restart is required");
0896     case Transaction::RestartSession:
0897         return i18n("You need to log out and log back in");
0898     case Transaction::RestartApplication:
0899         return i18n("You need to restart the application");
0900     case Transaction::RestartSecuritySession:
0901         return i18n("You need to log out and log back in to remain secure.");
0902     case Transaction::RestartSecuritySystem:
0903         return i18n("A restart is required to remain secure.");
0904     case Transaction::RestartUnknown:
0905         qWarning() << "restartType(Transaction::RestartUnknown)";
0906         return QString();
0907     }
0908     qWarning() << "restart unrecognised: " << value;
0909     return QString();
0910 }
0911 
0912 QString PkStrings::updateState(Transaction::UpdateState value)
0913 {
0914     switch (value) {
0915     case Transaction::UpdateStateStable:
0916         return i18n("Stable");
0917     case Transaction::UpdateStateUnstable:
0918         return i18n("Unstable");
0919     case Transaction::UpdateStateTesting:
0920         return i18n("Testing");
0921     case Transaction::UpdateStateUnknown:
0922         qWarning() << "updateState(Transaction::UnknownUpdateState)";
0923         return QString();
0924     }
0925     qWarning() << "value unrecognised: " << value;
0926     return QString();
0927 }
0928 
0929 QString PkStrings::mediaMessage(Transaction::MediaType value, const QString &text)
0930 {
0931     switch (value) {
0932     case Transaction::MediaTypeCd :
0933         return i18n("Please insert the CD labeled '%1', and press continue.", text);
0934     case Transaction::MediaTypeDvd :
0935         return i18n("Please insert the DVD labeled '%1', and press continue.", text);
0936     case Transaction::MediaTypeDisc :
0937         return i18n("Please insert the disc labeled '%1', and press continue.", text);
0938     case Transaction::MediaTypeUnknown:
0939         return i18n("Please insert the medium labeled '%1', and press continue.", text);
0940     }
0941     qWarning() << "value unrecognised: " << value;
0942     return i18n("Please insert the medium labeled '%1', and press continue.", text);
0943 }
0944 
0945 QString PkStrings::daemonError(int value)
0946 {
0947     Transaction::InternalError statusEnum = static_cast<Transaction::InternalError>(value);
0948     switch (statusEnum) {
0949     case Transaction::InternalErrorFailedAuth :
0950         return i18n("You do not have the necessary privileges to perform this action.");
0951     case Transaction::InternalErrorNoTid :
0952         return i18n("Could not get a transaction id from packagekitd.");
0953     case Transaction::InternalErrorAlreadyTid :
0954         return i18n("Cannot connect to this transaction id.");
0955     case Transaction::InternalErrorRoleUnkown :
0956         return i18n("This action is unknown.");
0957     case Transaction::InternalErrorCannotStartDaemon :
0958         return i18n("The packagekitd service could not be started.");
0959     case Transaction::InternalErrorInvalidInput :
0960         return i18n("The query is not valid.");
0961     case Transaction::InternalErrorInvalidFile :
0962         return i18n("The file is not valid.");
0963     case Transaction::InternalErrorFunctionNotSupported :
0964         return i18n("This function is not yet supported.");
0965     case Transaction::InternalErrorDaemonUnreachable :
0966         return i18n("Could not talk to packagekitd.");
0967     case Transaction::InternalErrorFailed:
0968         return i18n("Error talking to packagekitd.");
0969     case Transaction::InternalErrorNone:
0970     case Transaction::InternalErrorUnkown :
0971         return i18n("An unknown error happened.");
0972     }
0973     qWarning() << "value unrecognised: " << value;
0974     return i18n("An unknown error happened.");
0975 }
0976 
0977 QString PkStrings::prettyFormatDuration(unsigned long mSec)
0978 {
0979     return KFormat().formatDuration(mSec);
0980 }
0981 
0982 QString PkStrings::lastCacheRefreshTitle(uint lastTime)
0983 {
0984     unsigned long fifteen = 60 * 60 * 24 * 15;
0985     unsigned long thirty = 60 * 60 * 24 * 30;
0986 
0987     if (lastTime != UINT_MAX && lastTime < fifteen) {
0988         return i18n("Your system is up to date");
0989     } else if (lastTime != UINT_MAX && lastTime > fifteen && lastTime < thirty) {
0990         return i18n("You have no updates");
0991     }
0992     return i18n("Last check for updates was more than a month ago");
0993 }
0994 
0995 QString PkStrings::lastCacheRefreshSubTitle(uint lastTime)
0996 {
0997     unsigned long thirty = 60 * 60 * 24 * 30;
0998 
0999     if (lastTime != UINT_MAX && lastTime < thirty) {
1000         return i18n("Verified %1 ago", PkStrings::prettyFormatDuration(lastTime * 1000));
1001     }
1002     return i18n("It's strongly recommended that you check for new updates now");
1003 }