File indexing completed on 2024-12-08 12:23:27

0001 /*
0002     SPDX-FileCopyrightText: 2011 Aaron Seigo <aseigo@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "packagestructure.h"
0008 #include "kpackage_debug.h"
0009 #include "private/package_p.h"
0010 #include <private/packagejob_p.h>
0011 
0012 namespace KPackage
0013 {
0014 PackageStructure::PackageStructure(QObject *parent, const QVariantList &args)
0015     : QObject(parent)
0016     , d(nullptr)
0017 {
0018     Q_UNUSED(args)
0019 }
0020 
0021 PackageStructure::~PackageStructure()
0022 {
0023 }
0024 
0025 void PackageStructure::initPackage(Package *package)
0026 {
0027     Q_UNUSED(package)
0028 }
0029 
0030 void PackageStructure::pathChanged(Package *package)
0031 {
0032     Q_UNUSED(package)
0033 }
0034 
0035 KJob *PackageStructure::install(Package *package, const QString &archivePath, const QString &packageRoot)
0036 {
0037     PackageJob *j = new PackageJob(package);
0038     j->install(archivePath, packageRoot);
0039     return j;
0040 }
0041 
0042 KJob *PackageStructure::update(Package *package, const QString &archivePath, const QString &packageRoot)
0043 {
0044     PackageJob *j = new PackageJob(package);
0045     j->update(archivePath, packageRoot);
0046     return j;
0047 }
0048 
0049 KJob *PackageStructure::uninstall(Package *package, const QString &packageRoot)
0050 {
0051     PackageJob *j = new PackageJob(package);
0052     const QString pluginID = package->metadata().pluginId();
0053     QString uninstallPath;
0054     // We handle the empty path when uninstalling the package
0055     // If the dir already got deleted the pluginId is an empty string, without this
0056     // check we would delete the package root, BUG: 410682
0057     if (!pluginID.isEmpty()) {
0058         uninstallPath = packageRoot + QLatin1Char('/') + pluginID;
0059     }
0060     j->uninstall(uninstallPath);
0061     return j;
0062 }
0063 
0064 }
0065 
0066 #include "moc_packagestructure.cpp"