File indexing completed on 2024-11-24 04:54:59
0001 /* 0002 * SPDX-FileCopyrightText: 2012-2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * SPDX-FileCopyrightText: 2013 Lukas Appelhans <l.appelhans@gmx.de> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #include "PackageKitMessages.h" 0009 #include <Daemon> 0010 #include <KLocalizedString> 0011 0012 namespace PackageKitMessages 0013 { 0014 QString errorMessage(PackageKit::Transaction::Error error, const QString &errorMessage) 0015 { 0016 switch (error) { 0017 case PackageKit::Transaction::ErrorOom: 0018 return i18n("Out of memory"); 0019 case PackageKit::Transaction::ErrorNoNetwork: 0020 return i18n("No network connection available"); 0021 case PackageKit::Transaction::ErrorNotSupported: 0022 return i18n("Operation not supported"); 0023 case PackageKit::Transaction::ErrorInternalError: { 0024 if (errorMessage.isEmpty()) { 0025 return i18n("Internal error"); 0026 } else { 0027 return i18n("Internal error: %1", errorMessage); 0028 } 0029 } 0030 case PackageKit::Transaction::ErrorGpgFailure: 0031 return i18n("GPG failure"); 0032 case PackageKit::Transaction::ErrorPackageIdInvalid: 0033 return i18n("PackageID invalid"); 0034 case PackageKit::Transaction::ErrorPackageNotInstalled: 0035 return i18n("Package not installed"); 0036 case PackageKit::Transaction::ErrorPackageNotFound: 0037 return i18n("Package not found"); 0038 case PackageKit::Transaction::ErrorPackageAlreadyInstalled: 0039 return i18n("Package is already installed"); 0040 case PackageKit::Transaction::ErrorPackageDownloadFailed: 0041 return i18n("Package download failed"); 0042 case PackageKit::Transaction::ErrorGroupNotFound: 0043 return i18n("Package group not found"); 0044 case PackageKit::Transaction::ErrorGroupListInvalid: 0045 return i18n("Package group list invalid"); 0046 case PackageKit::Transaction::ErrorDepResolutionFailed: 0047 return i18n("Dependency resolution failed"); 0048 case PackageKit::Transaction::ErrorFilterInvalid: 0049 return i18n("Filter invalid"); 0050 case PackageKit::Transaction::ErrorCreateThreadFailed: 0051 return i18n("Failed while creating a thread"); 0052 case PackageKit::Transaction::ErrorTransactionError: 0053 return i18n("Transaction failure"); 0054 case PackageKit::Transaction::ErrorTransactionCancelled: 0055 return i18n("Transaction canceled"); 0056 case PackageKit::Transaction::ErrorNoCache: 0057 return i18n("No Cache available"); 0058 case PackageKit::Transaction::ErrorRepoNotFound: 0059 return i18n("Cannot find repository"); 0060 case PackageKit::Transaction::ErrorCannotRemoveSystemPackage: 0061 return i18n("Cannot remove system package"); 0062 case PackageKit::Transaction::ErrorProcessKill: 0063 return i18n("The PackageKit daemon has crashed"); 0064 case PackageKit::Transaction::ErrorFailedInitialization: 0065 return i18n("Initialization failure"); 0066 case PackageKit::Transaction::ErrorFailedFinalise: 0067 return i18n("Failed to finalize transaction"); 0068 case PackageKit::Transaction::ErrorFailedConfigParsing: 0069 return i18n("Config parsing failed"); 0070 case PackageKit::Transaction::ErrorCannotCancel: 0071 return i18n("Cannot cancel transaction"); 0072 case PackageKit::Transaction::ErrorCannotGetLock: 0073 return i18n("Cannot obtain lock"); 0074 case PackageKit::Transaction::ErrorNoPackagesToUpdate: 0075 return i18n("No packages to update"); 0076 case PackageKit::Transaction::ErrorCannotWriteRepoConfig: 0077 return i18n("Cannot write repo config"); 0078 case PackageKit::Transaction::ErrorLocalInstallFailed: 0079 return i18n("Local install failed"); 0080 case PackageKit::Transaction::ErrorBadGpgSignature: 0081 return i18n("Bad GPG signature found"); 0082 case PackageKit::Transaction::ErrorMissingGpgSignature: 0083 return i18n("No GPG signature found"); 0084 case PackageKit::Transaction::ErrorCannotInstallSourcePackage: 0085 return i18n("Cannot install source package"); 0086 case PackageKit::Transaction::ErrorRepoConfigurationError: 0087 return i18n("Repo configuration error"); 0088 case PackageKit::Transaction::ErrorNoLicenseAgreement: 0089 return i18n("No license agreement"); 0090 case PackageKit::Transaction::ErrorFileConflicts: 0091 return i18n("File conflicts found"); 0092 case PackageKit::Transaction::ErrorPackageConflicts: 0093 return i18n("Package conflict found"); 0094 case PackageKit::Transaction::ErrorRepoNotAvailable: 0095 return i18n("Repo not available"); 0096 case PackageKit::Transaction::ErrorInvalidPackageFile: 0097 return i18n("Invalid package file"); 0098 case PackageKit::Transaction::ErrorPackageInstallBlocked: 0099 return i18n("Package install blocked"); 0100 case PackageKit::Transaction::ErrorPackageCorrupt: 0101 return i18n("Corrupt package found"); 0102 case PackageKit::Transaction::ErrorAllPackagesAlreadyInstalled: 0103 return i18n("All packages already installed"); 0104 case PackageKit::Transaction::ErrorFileNotFound: 0105 return i18n("File not found"); 0106 case PackageKit::Transaction::ErrorNoMoreMirrorsToTry: 0107 return i18n("No more mirrors available"); 0108 case PackageKit::Transaction::ErrorNoDistroUpgradeData: 0109 return i18n("No distro upgrade data"); 0110 case PackageKit::Transaction::ErrorIncompatibleArchitecture: 0111 return i18n("Incompatible architecture"); 0112 case PackageKit::Transaction::ErrorNoSpaceOnDevice: 0113 return i18n("No space on device left"); 0114 case PackageKit::Transaction::ErrorMediaChangeRequired: 0115 return i18n("A media change is required"); 0116 case PackageKit::Transaction::ErrorNotAuthorized: 0117 return i18n("You have no authorization to execute this operation"); 0118 case PackageKit::Transaction::ErrorUpdateNotFound: 0119 return i18n("Update not found"); 0120 case PackageKit::Transaction::ErrorCannotInstallRepoUnsigned: 0121 return i18n("Cannot install from unsigned repo"); 0122 case PackageKit::Transaction::ErrorCannotUpdateRepoUnsigned: 0123 return i18n("Cannot update from unsigned repo"); 0124 case PackageKit::Transaction::ErrorCannotGetFilelist: 0125 return i18n("Cannot get file list"); 0126 case PackageKit::Transaction::ErrorCannotGetRequires: 0127 return i18n("Cannot get requires"); 0128 case PackageKit::Transaction::ErrorCannotDisableRepository: 0129 return i18n("Cannot disable repository"); 0130 case PackageKit::Transaction::ErrorRestrictedDownload: 0131 return i18n("Restricted download detected"); 0132 case PackageKit::Transaction::ErrorPackageFailedToConfigure: 0133 return i18n("Package failed to configure"); 0134 case PackageKit::Transaction::ErrorPackageFailedToBuild: 0135 return i18n("Package failed to build"); 0136 case PackageKit::Transaction::ErrorPackageFailedToInstall: 0137 return i18n("Package failed to install"); 0138 case PackageKit::Transaction::ErrorPackageFailedToRemove: 0139 return i18n("Package failed to remove"); 0140 case PackageKit::Transaction::ErrorUpdateFailedDueToRunningProcess: 0141 return i18n("Update failed due to running process"); 0142 case PackageKit::Transaction::ErrorPackageDatabaseChanged: 0143 return i18n("The package database changed"); 0144 case PackageKit::Transaction::ErrorProvideTypeNotSupported: 0145 return i18n("The provided type is not supported"); 0146 case PackageKit::Transaction::ErrorInstallRootInvalid: 0147 return i18n("Install root is invalid"); 0148 case PackageKit::Transaction::ErrorCannotFetchSources: 0149 return i18nc("Failed to sync your Linux distro repositories or other sources of packages", "Cannot fetch sources"); 0150 case PackageKit::Transaction::ErrorCancelledPriority: 0151 return i18n("Canceled priority"); 0152 case PackageKit::Transaction::ErrorUnfinishedTransaction: 0153 return i18n("Unfinished transaction"); 0154 case PackageKit::Transaction::ErrorLockRequired: 0155 return i18n("Lock required"); 0156 case PackageKit::Transaction::ErrorUnknown: 0157 default: { 0158 int idx = PackageKit::Transaction::staticMetaObject.indexOfEnumerator("Error"); 0159 QMetaEnum metaenum = PackageKit::Transaction::staticMetaObject.enumerator(idx); 0160 return i18n("Unknown error %1.", QString::fromLatin1(metaenum.valueToKey(error))); 0161 } 0162 } 0163 } 0164 0165 QString restartMessage(PackageKit::Transaction::Restart restart, const QString &pkgid) 0166 { 0167 switch (restart) { 0168 case PackageKit::Transaction::RestartApplication: 0169 return i18n("'%1' was changed and suggests to be restarted.", PackageKit::Daemon::packageName(pkgid)); 0170 case PackageKit::Transaction::RestartSession: 0171 return i18n("A change by '%1' suggests your session to be restarted.", PackageKit::Daemon::packageName(pkgid)); 0172 case PackageKit::Transaction::RestartSecuritySession: 0173 return i18n("'%1' was updated for security reasons, a restart of the session is recommended.", PackageKit::Daemon::packageName(pkgid)); 0174 case PackageKit::Transaction::RestartSecuritySystem: 0175 return i18n("'%1' was updated for security reasons, a restart of the system is recommended.", PackageKit::Daemon::packageName(pkgid)); 0176 case PackageKit::Transaction::RestartSystem: 0177 case PackageKit::Transaction::RestartUnknown: 0178 case PackageKit::Transaction::RestartNone: 0179 default: 0180 return i18n("A change by '%1' suggests your system to be restarted.", PackageKit::Daemon::packageName(pkgid)); 0181 } 0182 } 0183 0184 QString restartMessage(PackageKit::Transaction::Restart restart) 0185 { 0186 switch (restart) { 0187 case PackageKit::Transaction::RestartApplication: 0188 return i18n("The application will have to be restarted."); 0189 case PackageKit::Transaction::RestartSession: 0190 return i18n("The session will have to be restarted"); 0191 case PackageKit::Transaction::RestartSystem: 0192 return i18n("The system will have to be restarted."); 0193 case PackageKit::Transaction::RestartSecuritySession: 0194 return i18n("For security, the session will have to be restarted."); 0195 case PackageKit::Transaction::RestartSecuritySystem: 0196 return i18n("For security, the system will have to be restarted."); 0197 case PackageKit::Transaction::RestartUnknown: 0198 case PackageKit::Transaction::RestartNone: 0199 default: 0200 return QString(); 0201 } 0202 } 0203 0204 QString statusMessage(PackageKit::Transaction::Status status) 0205 { 0206 switch (status) { 0207 case PackageKit::Transaction::StatusWait: 0208 return i18n("Waiting…"); 0209 case PackageKit::Transaction::StatusRefreshCache: 0210 return i18n("Refreshing Cache…"); 0211 case PackageKit::Transaction::StatusSetup: 0212 return i18n("Setup…"); 0213 case PackageKit::Transaction::StatusRunning: 0214 return i18n("Processing…"); 0215 case PackageKit::Transaction::StatusRemove: 0216 return i18n("Remove…"); 0217 case PackageKit::Transaction::StatusDownload: 0218 return i18n("Downloading…"); 0219 case PackageKit::Transaction::StatusInstall: 0220 return i18n("Installing…"); 0221 case PackageKit::Transaction::StatusUpdate: 0222 return i18n("Updating…"); 0223 case PackageKit::Transaction::StatusCleanup: 0224 return i18n("Cleaning up…"); 0225 // case PackageKit::Transaction::StatusObsolete: 0226 case PackageKit::Transaction::StatusDepResolve: 0227 return i18n("Resolving dependencies…"); 0228 case PackageKit::Transaction::StatusSigCheck: 0229 return i18n("Checking signatures…"); 0230 case PackageKit::Transaction::StatusTestCommit: 0231 return i18n("Test committing…"); 0232 case PackageKit::Transaction::StatusCommit: 0233 return i18n("Committing…"); 0234 // StatusRequest, 0235 case PackageKit::Transaction::StatusFinished: 0236 return i18n("Finished"); 0237 case PackageKit::Transaction::StatusCancel: 0238 return i18n("Canceled"); 0239 case PackageKit::Transaction::StatusWaitingForLock: 0240 return i18n("Waiting for lock…"); 0241 case PackageKit::Transaction::StatusWaitingForAuth: 0242 return i18n("Waiting for authorization…"); 0243 // StatusScanProcessList, 0244 // StatusCheckExecutableFiles, 0245 // StatusCheckLibraries, 0246 case PackageKit::Transaction::StatusCopyFiles: 0247 return i18n("Copying files…"); 0248 case PackageKit::Transaction::StatusUnknown: 0249 default: 0250 return i18n("Unknown Status"); 0251 } 0252 } 0253 0254 QString statusDetail(PackageKit::Transaction::Status status) 0255 { 0256 switch (status) { 0257 case PackageKit::Transaction::StatusWait: 0258 return i18n("We are waiting for something."); 0259 case PackageKit::Transaction::StatusSetup: 0260 return i18n("Setting up transaction…"); 0261 case PackageKit::Transaction::StatusRunning: 0262 return i18n("The transaction is currently working…"); 0263 case PackageKit::Transaction::StatusRemove: 0264 return i18n("The transaction is currently removing packages…"); 0265 case PackageKit::Transaction::StatusDownload: 0266 return i18n("The transaction is currently downloading packages…"); 0267 case PackageKit::Transaction::StatusInstall: 0268 return i18n("The transactions is currently installing packages…"); 0269 case PackageKit::Transaction::StatusUpdate: 0270 return i18n("The transaction is currently updating packages…"); 0271 case PackageKit::Transaction::StatusCleanup: 0272 return i18n("The transaction is currently cleaning up…"); 0273 // case PackageKit::Transaction::StatusObsolete, 0274 case PackageKit::Transaction::StatusDepResolve: 0275 return i18n("The transaction is currently resolving the dependencies of the packages it will install…"); 0276 case PackageKit::Transaction::StatusSigCheck: 0277 return i18n("The transaction is currently checking the signatures of the packages…"); 0278 case PackageKit::Transaction::StatusTestCommit: 0279 return i18n("The transaction is currently testing the commit of this set of packages…"); 0280 case PackageKit::Transaction::StatusCommit: 0281 return i18n("The transaction is currently committing its set of packages…"); 0282 // StatusRequest, 0283 case PackageKit::Transaction::StatusFinished: 0284 return i18n("The transaction has finished!"); 0285 case PackageKit::Transaction::StatusCancel: 0286 return i18n("The transaction was canceled"); 0287 case PackageKit::Transaction::StatusWaitingForLock: 0288 return i18n("The transaction is currently waiting for the lock…"); 0289 case PackageKit::Transaction::StatusWaitingForAuth: 0290 return i18n("Waiting for the user to authorize the transaction…"); 0291 // StatusScanProcessList, 0292 // StatusCheckExecutableFiles, 0293 // StatusCheckLibraries, 0294 case PackageKit::Transaction::StatusCopyFiles: 0295 return i18n("The transaction is currently copying files…"); 0296 case PackageKit::Transaction::StatusRefreshCache: 0297 return i18n("Currently refreshing the repository cache…"); 0298 case PackageKit::Transaction::StatusUnknown: 0299 default: { 0300 int idx = PackageKit::Transaction::staticMetaObject.indexOfEnumerator("Status"); 0301 QMetaEnum metaenum = PackageKit::Transaction::staticMetaObject.enumerator(idx); 0302 return i18n("Unknown status %1.", QString::fromLatin1(metaenum.valueToKey(status))); 0303 } 0304 } 0305 } 0306 0307 QString updateStateMessage(PackageKit::Transaction::UpdateState state) 0308 { 0309 switch (state) { 0310 case PackageKit::Transaction::UpdateStateUnknown: 0311 return QString(); 0312 case PackageKit::Transaction::UpdateStateStable: 0313 return i18nc("update state", "Stable"); 0314 case PackageKit::Transaction::UpdateStateUnstable: 0315 return i18nc("update state", "Unstable"); 0316 case PackageKit::Transaction::UpdateStateTesting: 0317 return i18nc("update state", "Testing"); 0318 } 0319 return QString(); 0320 } 0321 0322 QString info(PackageKit::Transaction::Info info) 0323 { 0324 switch (info) { 0325 case PackageKit::Transaction::InfoUnknown: 0326 return i18n("Unknown"); 0327 case PackageKit::Transaction::InfoInstalled: 0328 return i18n("Installed"); 0329 case PackageKit::Transaction::InfoAvailable: 0330 return i18n("Not Installed"); 0331 case PackageKit::Transaction::InfoLow: 0332 return i18n("Low"); 0333 case PackageKit::Transaction::InfoEnhancement: 0334 return i18n("Enhancement"); 0335 case PackageKit::Transaction::InfoNormal: 0336 return i18n("Normal"); 0337 case PackageKit::Transaction::InfoBugfix: 0338 return i18n("Bugfix"); 0339 case PackageKit::Transaction::InfoImportant: 0340 return i18n("Important"); 0341 case PackageKit::Transaction::InfoSecurity: 0342 return i18n("Security"); 0343 case PackageKit::Transaction::InfoBlocked: 0344 return i18n("Blocked"); 0345 case PackageKit::Transaction::InfoDownloading: 0346 return i18n("Downloading"); 0347 case PackageKit::Transaction::InfoUpdating: 0348 return i18n("Updating"); 0349 case PackageKit::Transaction::InfoInstalling: 0350 return i18n("Installing"); 0351 case PackageKit::Transaction::InfoRemoving: 0352 return i18n("Removing"); 0353 case PackageKit::Transaction::InfoCleanup: 0354 return i18n("Cleanup"); 0355 case PackageKit::Transaction::InfoObsoleting: 0356 return i18n("Obsoleting"); 0357 case PackageKit::Transaction::InfoCollectionInstalled: 0358 return i18n("Collection Installed"); 0359 case PackageKit::Transaction::InfoCollectionAvailable: 0360 return i18n("Collection Available"); 0361 case PackageKit::Transaction::InfoFinished: 0362 return i18n("Finished"); 0363 case PackageKit::Transaction::InfoReinstalling: 0364 return i18n("Reinstalling"); 0365 case PackageKit::Transaction::InfoDowngrading: 0366 return i18n("Downgrading"); 0367 case PackageKit::Transaction::InfoPreparing: 0368 return i18n("Preparing"); 0369 case PackageKit::Transaction::InfoDecompressing: 0370 return i18n("Decompressing"); 0371 case PackageKit::Transaction::InfoUntrusted: 0372 return i18n("Untrusted"); 0373 case PackageKit::Transaction::InfoTrusted: 0374 return i18n("Trusted"); 0375 case PackageKit::Transaction::InfoUnavailable: 0376 return i18n("Unavailable"); 0377 } 0378 return {}; 0379 } 0380 }