diff --git a/package.cpp b/package.cpp index 18b8308f7..abb7690c4 100644 --- a/package.cpp +++ b/package.cpp @@ -22,8 +22,10 @@ #include #include +#include #include #include +#include #include #include @@ -156,7 +158,8 @@ QStringList Package::knownPackages(const QString& packageRoot) // static return packages; } -bool Package::installPackage(const QString& package, const QString& packageRoot) // static +bool Package::installPackage(const QString& package, + const QString& packageRoot) // static { //TODO: report *what* failed if something does fail QDir root(packageRoot); @@ -216,15 +219,29 @@ bool Package::installPackage(const QString& package, const QString& packageRoot) KIO::FileCopyJob* job = KIO::file_move(tempdir, targetName); - bool success = job->exec(); - - if (!success) { + if (!job->exec()) { KIO::SimpleJob* job = KIO::file_delete(tempdir); job->exec(); return false; } - return success; + // and now we register it as a service =) + targetName.append("/metadata.desktop"); + QString service = KStandardDirs::locateLocal("services", + KGlobal::mainComponent().componentName()); + KPluginInfo pluginInfo(targetName); + + if (pluginInfo.pluginName().isEmpty()) { + // should not installing it as a service disqualify it? + // i don't think so since KServiceTypeTrader may not be + // used by the installing app in any case, and the + // package is properly installed - aseigo + return true; + } + + service.append(pluginInfo.pluginName()).append(".desktop"); + job = KIO::file_copy(targetName, service); + return job->exec(); } } // Namespace diff --git a/package.h b/package.h index 95225231c..e4b20ef50 100644 --- a/package.h +++ b/package.h @@ -99,6 +99,9 @@ class PLASMA_EXPORT Package **/ static bool installPackage(const QString& package, const QString& packageRoot); + //TODO implement uninstall + //static bool uninstallPackage(const QString& package, const QString& packageRoot); + private: Q_DISABLE_COPY(Package) class Private;