Changeset View
Changeset View
Standalone View
Standalone View
src/kpackagetool/kpackagetool.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | #include <QStringList> | 42 | #include <QStringList> | ||
43 | #include <QTimer> | 43 | #include <QTimer> | ||
44 | #include <QUrl> | 44 | #include <QUrl> | ||
45 | #include <QXmlStreamWriter> | 45 | #include <QXmlStreamWriter> | ||
46 | 46 | | |||
47 | #include <iostream> | 47 | #include <iostream> | ||
48 | #include <iomanip> | 48 | #include <iomanip> | ||
49 | 49 | | |||
50 | #include "options.h" | ||||
51 | | ||||
50 | #include "../kpackage/config-package.h" | 52 | #include "../kpackage/config-package.h" | ||
51 | //for the index creation function | 53 | //for the index creation function | ||
52 | #include "../kpackage/private/packagejobthread_p.h" | 54 | #include "../kpackage/private/packagejobthread_p.h" | ||
53 | 55 | | |||
54 | Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, cout, (stdout)) | 56 | Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, cout, (stdout)) | ||
55 | Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, cerr, (stderr)) | 57 | Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, cerr, (stderr)) | ||
56 | 58 | | |||
57 | static QVector<KPluginMetaData> listPackageTypes() | 59 | static QVector<KPluginMetaData> listPackageTypes() | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
126 | PackageTool::~PackageTool() | 128 | PackageTool::~PackageTool() | ||
127 | { | 129 | { | ||
128 | delete d; | 130 | delete d; | ||
129 | } | 131 | } | ||
130 | 132 | | |||
131 | void PackageTool::runMain() | 133 | void PackageTool::runMain() | ||
132 | { | 134 | { | ||
133 | KPackage::PackageStructure structure; | 135 | KPackage::PackageStructure structure; | ||
134 | if (d->parser->isSet(QStringLiteral("hash"))) { | 136 | if (d->parser->isSet(Options::hash)) { | ||
135 | const QString path = d->parser->value(QStringLiteral("hash")); | 137 | const QString path = d->parser->value(Options::hash); | ||
136 | KPackage::Package package(&structure); | 138 | KPackage::Package package(&structure); | ||
137 | package.setPath(path); | 139 | package.setPath(path); | ||
138 | const QString hash = | 140 | const QString hash = | ||
139 | QString::fromLocal8Bit(package.cryptographicHash(QCryptographicHash::Sha1)); | 141 | QString::fromLocal8Bit(package.cryptographicHash(QCryptographicHash::Sha1)); | ||
140 | if (hash.isEmpty()) { | 142 | if (hash.isEmpty()) { | ||
141 | d->coutput(i18n("Failed to generate a Package hash for %1", path)); | 143 | d->coutput(i18n("Failed to generate a Package hash for %1", path)); | ||
142 | exit(9); | 144 | exit(9); | ||
143 | } else { | 145 | } else { | ||
144 | d->coutput(i18n("SHA1 hash for Package at %1: '%2'", package.path(), hash)); | 146 | d->coutput(i18n("SHA1 hash for Package at %1: '%2'", package.path(), hash)); | ||
145 | exit(0); | 147 | exit(0); | ||
146 | } | 148 | } | ||
147 | return; | 149 | return; | ||
148 | } | 150 | } | ||
149 | 151 | | |||
150 | if (d->parser->isSet(QStringLiteral("list-types"))) { | 152 | if (d->parser->isSet(Options::listTypes)) { | ||
151 | d->listTypes(); | 153 | d->listTypes(); | ||
152 | exit(0); | 154 | exit(0); | ||
153 | return; | 155 | return; | ||
154 | } | 156 | } | ||
155 | 157 | | |||
156 | QString type = d->parser->value(QStringLiteral("type")); | 158 | QString type = d->parser->value(Options::type); | ||
157 | d->pluginTypes.clear(); | 159 | d->pluginTypes.clear(); | ||
158 | d->installer = Package(); | 160 | d->installer = Package(); | ||
159 | 161 | | |||
160 | if (d->parser->isSet(QStringLiteral("remove"))) { | 162 | if (d->parser->isSet(Options::remove)) { | ||
161 | d->package = d->parser->value(QStringLiteral("remove")); | 163 | d->package = d->parser->value(Options::remove); | ||
162 | } else if (d->parser->isSet(QStringLiteral("upgrade"))) { | 164 | } else if (d->parser->isSet(Options::upgrade)) { | ||
163 | d->package = d->parser->value(QStringLiteral("upgrade")); | 165 | d->package = d->parser->value(Options::upgrade); | ||
164 | } else if (d->parser->isSet(QStringLiteral("install"))) { | 166 | } else if (d->parser->isSet(Options::install)) { | ||
165 | d->package = d->parser->value(QStringLiteral("install")); | 167 | d->package = d->parser->value(Options::install); | ||
166 | } else if (d->parser->isSet(QStringLiteral("show"))) { | 168 | } else if (d->parser->isSet(Options::show)) { | ||
167 | d->package = d->parser->value(QStringLiteral("show")); | 169 | d->package = d->parser->value(Options::show); | ||
168 | } else if (d->parser->isSet(QStringLiteral("appstream-metainfo"))) { | 170 | } else if (d->parser->isSet(Options::appstream)) { | ||
169 | d->package = d->parser->value(QStringLiteral("appstream-metainfo")); | 171 | d->package = d->parser->value(Options::appstream); | ||
170 | } | 172 | } | ||
171 | 173 | | |||
172 | if (!QDir::isAbsolutePath(d->package)) { | 174 | if (!QDir::isAbsolutePath(d->package)) { | ||
173 | d->packageFile = QDir(QDir::currentPath() + '/' + d->package).absolutePath(); | 175 | d->packageFile = QDir(QDir::currentPath() + '/' + d->package).absolutePath(); | ||
174 | d->packageFile = QFileInfo(d->packageFile).canonicalFilePath(); | 176 | d->packageFile = QFileInfo(d->packageFile).canonicalFilePath(); | ||
175 | if (d->parser->isSet(QStringLiteral("upgrade"))) { | 177 | if (d->parser->isSet(Options::upgrade)) { | ||
176 | d->package = d->packageFile; | 178 | d->package = d->packageFile; | ||
177 | } | 179 | } | ||
178 | } else { | 180 | } else { | ||
179 | d->packageFile = d->package; | 181 | d->packageFile = d->package; | ||
180 | } | 182 | } | ||
181 | 183 | | |||
182 | if (!d->packageFile.isEmpty() && (!d->parser->isSet(QStringLiteral("type")) || | 184 | if (!d->packageFile.isEmpty() && (!d->parser->isSet(Options::type) || | ||
183 | type.compare(i18nc("package type", "wallpaper"), Qt::CaseInsensitive) == 0 || | 185 | type.compare(i18nc("package type", "wallpaper"), Qt::CaseInsensitive) == 0 || | ||
184 | type.compare(QLatin1String("wallpaper"), Qt::CaseInsensitive) == 0)) { | 186 | type.compare(QLatin1String("wallpaper"), Qt::CaseInsensitive) == 0)) { | ||
185 | // Check type for common plasma packages | 187 | // Check type for common plasma packages | ||
186 | KPackage::Package package(&structure); | 188 | KPackage::Package package(&structure); | ||
187 | QString serviceType; | 189 | QString serviceType; | ||
188 | package.setPath(d->packageFile); | 190 | package.setPath(d->packageFile); | ||
189 | 191 | | |||
190 | if (package.isValid() && package.metadata().isValid()) { | 192 | if (package.isValid() && package.metadata().isValid()) { | ||
Show All 22 Lines | 209 | { | |||
213 | 215 | | |||
214 | if (!d->installer.hasValidStructure()) { | 216 | if (!d->installer.hasValidStructure()) { | ||
215 | qWarning() << "Package type" << type << "not found"; | 217 | qWarning() << "Package type" << type << "not found"; | ||
216 | } | 218 | } | ||
217 | 219 | | |||
218 | d->packageRoot = d->installer.defaultPackageRoot(); | 220 | d->packageRoot = d->installer.defaultPackageRoot(); | ||
219 | d->pluginTypes << type; | 221 | d->pluginTypes << type; | ||
220 | } | 222 | } | ||
221 | if (d->parser->isSet(QStringLiteral("show"))) { | 223 | if (d->parser->isSet(Options::show)) { | ||
222 | const QString pluginName = d->package; | 224 | const QString pluginName = d->package; | ||
223 | showPackageInfo(pluginName); | 225 | showPackageInfo(pluginName); | ||
224 | return; | 226 | return; | ||
225 | } else if (d->parser->isSet(QStringLiteral("appstream-metainfo"))) { | 227 | } else if (d->parser->isSet(Options::appstream)) { | ||
226 | const QString pluginName = d->package; | 228 | const QString pluginName = d->package; | ||
227 | showAppstreamInfo(pluginName); | 229 | showAppstreamInfo(pluginName); | ||
228 | return; | 230 | return; | ||
229 | } | 231 | } | ||
230 | 232 | | |||
231 | if (d->parser->isSet(QStringLiteral("list"))) { | 233 | if (d->parser->isSet(Options::list)) { | ||
232 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | 234 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | ||
233 | d->coutput(i18n("Listing service types: %1 in %2", d->pluginTypes.join(QByteArray(", ")), d->packageRoot)); | 235 | d->coutput(i18n("Listing service types: %1 in %2", d->pluginTypes.join(QByteArray(", ")), d->packageRoot)); | ||
234 | listPackages(d->pluginTypes, d->packageRoot); | 236 | listPackages(d->pluginTypes, d->packageRoot); | ||
235 | exit(0); | 237 | exit(0); | ||
236 | 238 | | |||
237 | } else if (d->parser->isSet(QStringLiteral("generate-index"))) { | 239 | } else if (d->parser->isSet(Options::generateIndex)) { | ||
238 | recreateIndex(); | 240 | recreateIndex(); | ||
239 | exit(0); | 241 | exit(0); | ||
240 | 242 | | |||
241 | } else { | 243 | } else { | ||
242 | // install, remove or upgrade | 244 | // install, remove or upgrade | ||
243 | if (!d->installer.isValid()) { | 245 | if (!d->installer.isValid()) { | ||
244 | 246 | | |||
245 | d->installer = KPackage::Package(new KPackage::PackageStructure()); | 247 | d->installer = KPackage::Package(new KPackage::PackageStructure()); | ||
246 | } | 248 | } | ||
247 | 249 | | |||
248 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | 250 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | ||
249 | 251 | | |||
250 | if (d->parser->isSet(QStringLiteral("remove")) || d->parser->isSet(QStringLiteral("upgrade"))) { | 252 | if (d->parser->isSet(Options::remove) || d->parser->isSet(Options::upgrade)) { | ||
251 | QString pkgPath; | 253 | QString pkgPath; | ||
252 | foreach (const QString &t, d->pluginTypes) { | 254 | foreach (const QString &t, d->pluginTypes) { | ||
253 | KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(t); | 255 | KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(t); | ||
254 | pkg.setPath(d->package); | 256 | pkg.setPath(d->package); | ||
255 | if (pkg.isValid()) { | 257 | if (pkg.isValid()) { | ||
256 | pkgPath = pkg.path(); | 258 | pkgPath = pkg.path(); | ||
257 | if (pkgPath.isEmpty() && !d->packageFile.isEmpty()) { | 259 | if (pkgPath.isEmpty() && !d->packageFile.isEmpty()) { | ||
258 | pkgPath = d->packageFile; | 260 | pkgPath = d->packageFile; | ||
259 | } | 261 | } | ||
260 | continue; | 262 | continue; | ||
261 | } | 263 | } | ||
262 | } | 264 | } | ||
263 | if (pkgPath.isEmpty()) { | 265 | if (pkgPath.isEmpty()) { | ||
264 | pkgPath = d->package; | 266 | pkgPath = d->package; | ||
265 | } | 267 | } | ||
266 | 268 | | |||
267 | if (d->parser->isSet(QStringLiteral("upgrade"))) { | 269 | if (d->parser->isSet(Options::upgrade)) { | ||
268 | d->installer.setPath(d->package); | 270 | d->installer.setPath(d->package); | ||
269 | } | 271 | } | ||
270 | QString _p = d->packageRoot; | 272 | QString _p = d->packageRoot; | ||
271 | if (!_p.endsWith('/')) { | 273 | if (!_p.endsWith('/')) { | ||
272 | _p.append('/'); | 274 | _p.append('/'); | ||
273 | } | 275 | } | ||
274 | _p.append(d->package); | 276 | _p.append(d->package); | ||
275 | d->installer.setDefaultPackageRoot(d->packageRoot); | 277 | d->installer.setDefaultPackageRoot(d->packageRoot); | ||
276 | d->installer.setPath(pkgPath); | 278 | d->installer.setPath(pkgPath); | ||
277 | 279 | | |||
278 | if (!d->parser->isSet(QStringLiteral("type"))) { | 280 | if (!d->parser->isSet(Options::type)) { | ||
279 | foreach (const QString &st, d->installer.metadata().serviceTypes()) { | 281 | foreach (const QString &st, d->installer.metadata().serviceTypes()) { | ||
280 | if (!d->pluginTypes.contains(st)) { | 282 | if (!d->pluginTypes.contains(st)) { | ||
281 | d->pluginTypes << st; | 283 | d->pluginTypes << st; | ||
282 | } | 284 | } | ||
283 | } | 285 | } | ||
284 | } | 286 | } | ||
285 | 287 | | |||
286 | QString pluginName; | 288 | QString pluginName; | ||
Show All 25 Lines | 312 | if (installed.contains(pluginName)) { // Assume it's a plugin name | |||
312 | KJob *uninstallJob = d->installer.uninstall(pluginName, d->packageRoot); | 314 | KJob *uninstallJob = d->installer.uninstall(pluginName, d->packageRoot); | ||
313 | connect(uninstallJob, SIGNAL(result(KJob*)), SLOT(packageUninstalled(KJob*))); | 315 | connect(uninstallJob, SIGNAL(result(KJob*)), SLOT(packageUninstalled(KJob*))); | ||
314 | return; | 316 | return; | ||
315 | } else { | 317 | } else { | ||
316 | d->coutput(i18n("Error: Plugin %1 is not installed.", pluginName)); | 318 | d->coutput(i18n("Error: Plugin %1 is not installed.", pluginName)); | ||
317 | exit(2); | 319 | exit(2); | ||
318 | } | 320 | } | ||
319 | } | 321 | } | ||
320 | if (d->parser->isSet(QStringLiteral("install"))) { | 322 | if (d->parser->isSet(Options::install)) { | ||
321 | KJob *installJob = d->installer.install(d->packageFile, d->packageRoot); | 323 | KJob *installJob = d->installer.install(d->packageFile, d->packageRoot); | ||
322 | connect(installJob, SIGNAL(result(KJob*)), SLOT(packageInstalled(KJob*))); | 324 | connect(installJob, SIGNAL(result(KJob*)), SLOT(packageInstalled(KJob*))); | ||
323 | return; | 325 | return; | ||
324 | } | 326 | } | ||
325 | if (d->package.isEmpty()) { | 327 | if (d->package.isEmpty()) { | ||
326 | qWarning() << i18nc("No option was given, this is the error message telling the user he needs at least one, do not translate install, remove, upgrade nor list", "One of install, remove, upgrade or list is required."); | 328 | qWarning() << i18nc("No option was given, this is the error message telling the user he needs at least one, do not translate install, remove, upgrade nor list", "One of install, remove, upgrade or list is required."); | ||
327 | exit(6); | 329 | exit(6); | ||
328 | } | 330 | } | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 481 | if (!parentApp.isEmpty()) { | |||
480 | componentAttributes << QXmlStreamAttribute("type", "addon"); | 482 | componentAttributes << QXmlStreamAttribute("type", "addon"); | ||
481 | } | 483 | } | ||
482 | 484 | | |||
483 | // Compatibility: without appstream-metainfo-output argument we print the XML output to STDOUT | 485 | // Compatibility: without appstream-metainfo-output argument we print the XML output to STDOUT | ||
484 | // with the argument we'll print to the defined path. | 486 | // with the argument we'll print to the defined path. | ||
485 | // TODO: in KF6 we should switch to argument-only. | 487 | // TODO: in KF6 we should switch to argument-only. | ||
486 | QIODevice *outputDevice = cout->device(); | 488 | QIODevice *outputDevice = cout->device(); | ||
487 | QScopedPointer<QFile> outputFile; | 489 | QScopedPointer<QFile> outputFile; | ||
488 | const auto outputPath = d->parser->value("appstream-metainfo-output"); | 490 | const auto outputPath = d->parser->value(Options::appstreamOutput); | ||
489 | if (!outputPath.isEmpty()) { | 491 | if (!outputPath.isEmpty()) { | ||
490 | auto outputUrl = QUrl::fromUserInput(outputPath); | 492 | auto outputUrl = QUrl::fromUserInput(outputPath); | ||
491 | outputFile.reset(new QFile(outputUrl.toLocalFile())); | 493 | outputFile.reset(new QFile(outputUrl.toLocalFile())); | ||
492 | if (!outputFile->open(QFile::WriteOnly | QFile::Text)) { | 494 | if (!outputFile->open(QFile::WriteOnly | QFile::Text)) { | ||
493 | *cerr << "Failed to open output file for writing."; | 495 | *cerr << "Failed to open output file for writing."; | ||
494 | exit(1); | 496 | exit(1); | ||
495 | } | 497 | } | ||
496 | outputDevice = outputFile.data(); | 498 | outputDevice = outputFile.data(); | ||
Show All 40 Lines | |||||
537 | exit(0); | 539 | exit(0); | ||
538 | } | 540 | } | ||
539 | 541 | | |||
540 | QString PackageTool::findPackageRoot(const QString &pluginName, const QString &prefix) | 542 | QString PackageTool::findPackageRoot(const QString &pluginName, const QString &prefix) | ||
541 | { | 543 | { | ||
542 | Q_UNUSED(pluginName); | 544 | Q_UNUSED(pluginName); | ||
543 | Q_UNUSED(prefix); | 545 | Q_UNUSED(prefix); | ||
544 | QString packageRoot; | 546 | QString packageRoot; | ||
545 | if (d->parser->isSet(QStringLiteral("packageroot")) && d->parser->isSet(QStringLiteral("global")) && !d->parser->isSet(QStringLiteral("generate-index"))) { | 547 | if (d->parser->isSet(Options::packageRoot) && d->parser->isSet(Options::global) && !d->parser->isSet(Options::generateIndex)) { | ||
546 | qWarning() << i18nc("The user entered conflicting options packageroot and global, this is the error message telling the user he can use only one", "The packageroot and global options conflict with each other, please select only one."); | 548 | qWarning() << i18nc("The user entered conflicting options packageroot and global, this is the error message telling the user he can use only one", "The packageroot and global options conflict with each other, please select only one."); | ||
547 | ::exit(7); | 549 | ::exit(7); | ||
548 | } else if (d->parser->isSet(QStringLiteral("packageroot"))) { | 550 | } else if (d->parser->isSet(Options::packageRoot)) { | ||
549 | packageRoot = d->parser->value(QStringLiteral("packageroot")); | 551 | packageRoot = d->parser->value(Options::packageRoot); | ||
550 | //qDebug() << "(set via arg) d->packageRoot is: " << d->packageRoot; | 552 | //qDebug() << "(set via arg) d->packageRoot is: " << d->packageRoot; | ||
551 | } else if (d->parser->isSet(QStringLiteral("global"))) { | 553 | } else if (d->parser->isSet(Options::global)) { | ||
552 | auto const paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, d->packageRoot, QStandardPaths::LocateDirectory); | 554 | auto const paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, d->packageRoot, QStandardPaths::LocateDirectory); | ||
553 | if (!paths.isEmpty()) { | 555 | if (!paths.isEmpty()) { | ||
554 | packageRoot = paths.last(); | 556 | packageRoot = paths.last(); | ||
555 | } | 557 | } | ||
556 | } else { | 558 | } else { | ||
557 | packageRoot = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->packageRoot; | 559 | packageRoot = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->packageRoot; | ||
558 | } | 560 | } | ||
559 | return packageRoot; | 561 | return packageRoot; | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 620 | { | |||
647 | } | 649 | } | ||
648 | } | 650 | } | ||
649 | 651 | | |||
650 | void PackageTool::recreateIndex() | 652 | void PackageTool::recreateIndex() | ||
651 | { | 653 | { | ||
652 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | 654 | d->packageRoot = findPackageRoot(d->package, d->packageRoot); | ||
653 | 655 | | |||
654 | if (!QDir::isAbsolutePath(d->packageRoot)) { | 656 | if (!QDir::isAbsolutePath(d->packageRoot)) { | ||
655 | if (d->parser->isSet(QStringLiteral("global"))) { | 657 | if (d->parser->isSet(Options::global)) { | ||
656 | Q_FOREACH(auto const &p, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, d->packageRoot, QStandardPaths::LocateDirectory)) { | 658 | Q_FOREACH(auto const &p, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, d->packageRoot, QStandardPaths::LocateDirectory)) { | ||
657 | d->coutput(i18n("Generating %1/kpluginindex.json", p)); | 659 | d->coutput(i18n("Generating %1/kpluginindex.json", p)); | ||
658 | KPackage::indexDirectory(p, QStringLiteral("kpluginindex.json")); | 660 | KPackage::indexDirectory(p, QStringLiteral("kpluginindex.json")); | ||
659 | } | 661 | } | ||
660 | return; | 662 | return; | ||
661 | } else { | 663 | } else { | ||
662 | d->packageRoot = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->packageRoot; | 664 | d->packageRoot = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + d->packageRoot; | ||
663 | } | 665 | } | ||
664 | } | 666 | } | ||
665 | 667 | | |||
666 | d->coutput(i18n("Generating %1/kpluginindex.json", d->packageRoot)); | 668 | d->coutput(i18n("Generating %1/kpluginindex.json", d->packageRoot)); | ||
667 | KPackage::indexDirectory(d->packageRoot, QStringLiteral("kpluginindex.json")); | 669 | KPackage::indexDirectory(d->packageRoot, QStringLiteral("kpluginindex.json")); | ||
668 | } | 670 | } | ||
669 | 671 | | |||
670 | void PackageTool::packageInstalled(KJob *job) | 672 | void PackageTool::packageInstalled(KJob *job) | ||
671 | { | 673 | { | ||
672 | bool success = (job->error() == KJob::NoError); | 674 | bool success = (job->error() == KJob::NoError); | ||
673 | int exitcode = 0; | 675 | int exitcode = 0; | ||
674 | if (success) { | 676 | if (success) { | ||
675 | if (d->parser->isSet(QStringLiteral("upgrade"))) { | 677 | if (d->parser->isSet(Options::upgrade)) { | ||
676 | d->coutput(i18n("Successfully upgraded %1", d->packageFile)); | 678 | d->coutput(i18n("Successfully upgraded %1", d->packageFile)); | ||
677 | } else { | 679 | } else { | ||
678 | d->coutput(i18n("Successfully installed %1", d->packageFile)); | 680 | d->coutput(i18n("Successfully installed %1", d->packageFile)); | ||
679 | } | 681 | } | ||
680 | } else { | 682 | } else { | ||
681 | d->coutput(i18n("Error: Installation of %1 failed: %2", d->packageFile, job->errorText())); | 683 | d->coutput(i18n("Error: Installation of %1 failed: %2", d->packageFile, job->errorText())); | ||
682 | exitcode = 4; | 684 | exitcode = 4; | ||
683 | } | 685 | } | ||
684 | exit(exitcode); | 686 | exit(exitcode); | ||
685 | } | 687 | } | ||
686 | 688 | | |||
687 | void PackageTool::packageUninstalled(KJob *job) | 689 | void PackageTool::packageUninstalled(KJob *job) | ||
688 | { | 690 | { | ||
689 | bool success = (job->error() == KJob::NoError); | 691 | bool success = (job->error() == KJob::NoError); | ||
690 | int exitcode = 0; | 692 | int exitcode = 0; | ||
691 | if (success) { | 693 | if (success) { | ||
692 | if (d->parser->isSet(QStringLiteral("upgrade"))) { | 694 | if (d->parser->isSet(Options::upgrade)) { | ||
693 | d->coutput(i18n("Upgrading package from file: %1", d->packageFile)); | 695 | d->coutput(i18n("Upgrading package from file: %1", d->packageFile)); | ||
694 | KJob *installJob = d->installer.install(d->packageFile, d->packageRoot); | 696 | KJob *installJob = d->installer.install(d->packageFile, d->packageRoot); | ||
695 | connect(installJob, SIGNAL(result(KJob*)), SLOT(packageInstalled(KJob*))); | 697 | connect(installJob, SIGNAL(result(KJob*)), SLOT(packageInstalled(KJob*))); | ||
696 | return; | 698 | return; | ||
697 | } | 699 | } | ||
698 | d->coutput(i18n("Successfully uninstalled %1", d->packageFile)); | 700 | d->coutput(i18n("Successfully uninstalled %1", d->packageFile)); | ||
699 | } else { | 701 | } else { | ||
700 | d->coutput(i18n("Error: Uninstallation of %1 failed: %2", d->packageFile, job->errorText())); | 702 | d->coutput(i18n("Error: Uninstallation of %1 failed: %2", d->packageFile, job->errorText())); | ||
701 | exitcode = 7; | 703 | exitcode = 7; | ||
702 | } | 704 | } | ||
703 | exit(exitcode); | 705 | exit(exitcode); | ||
704 | } | 706 | } | ||
705 | 707 | | |||
706 | } // namespace KPackage | 708 | } // namespace KPackage | ||
707 | 709 | | |||
708 | #include "moc_kpackagetool.cpp" | 710 | #include "moc_kpackagetool.cpp" |