automatically register packages with sycoca

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=690112
This commit is contained in:
Aaron J. Seigo 2007-07-20 04:07:00 +00:00
parent 8c8504964e
commit 43a98e8fc1
2 changed files with 25 additions and 5 deletions

View File

@ -22,8 +22,10 @@
#include <KArchiveDirectory> #include <KArchiveDirectory>
#include <KArchiveEntry> #include <KArchiveEntry>
#include <KComponentData>
#include <KIO/FileCopyJob> #include <KIO/FileCopyJob>
#include <KIO/Job> #include <KIO/Job>
#include <KPluginInfo>
#include <KStandardDirs> #include <KStandardDirs>
#include <KZip> #include <KZip>
@ -156,7 +158,8 @@ QStringList Package::knownPackages(const QString& packageRoot) // static
return packages; 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 //TODO: report *what* failed if something does fail
QDir root(packageRoot); QDir root(packageRoot);
@ -216,15 +219,29 @@ bool Package::installPackage(const QString& package, const QString& packageRoot)
KIO::FileCopyJob* job = KIO::file_move(tempdir, targetName); KIO::FileCopyJob* job = KIO::file_move(tempdir, targetName);
bool success = job->exec(); if (!job->exec()) {
if (!success) {
KIO::SimpleJob* job = KIO::file_delete(tempdir); KIO::SimpleJob* job = KIO::file_delete(tempdir);
job->exec(); job->exec();
return false; 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 } // Namespace

View File

@ -99,6 +99,9 @@ class PLASMA_EXPORT Package
**/ **/
static bool installPackage(const QString& package, const QString& packageRoot); static bool installPackage(const QString& package, const QString& packageRoot);
//TODO implement uninstall
//static bool uninstallPackage(const QString& package, const QString& packageRoot);
private: private:
Q_DISABLE_COPY(Package) Q_DISABLE_COPY(Package)
class Private; class Private;