automatically register packages with sycoca
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=690112
This commit is contained in:
parent
8c8504964e
commit
43a98e8fc1
27
package.cpp
27
package.cpp
@ -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
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user