* let PackageStructures define their own install routine
* split install in Package into both installing the Package and registering it, allowing PackageStructures to implement their own installation routine without having to reimplement registration svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=779805
This commit is contained in:
parent
ae0510db05
commit
577ea0bbe6
29
package.cpp
29
package.cpp
@ -244,33 +244,38 @@ bool Package::installPackage(const QString& package,
|
||||
return false;
|
||||
}
|
||||
|
||||
KIO::FileCopyJob* job = KIO::file_move(tempdir.name(), targetName, -1,
|
||||
KIO::HideProgressInfo);
|
||||
KIO::FileCopyJob* job = KIO::file_move(tempdir.name(), targetName, -1, KIO::HideProgressInfo);
|
||||
|
||||
if (!job->exec()) {
|
||||
kWarning(505) << "Could not move package to destination:" << targetName;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// no need to remove the temp dir (which has been moved)
|
||||
tempdir.setAutoRemove(false);
|
||||
|
||||
// and now we register it as a service =)
|
||||
targetName.append("/metadata.desktop");
|
||||
QString service = KStandardDirs::locateLocal("services",
|
||||
KGlobal::mainComponent().componentName());
|
||||
KPluginInfo pluginInfo(targetName);
|
||||
|
||||
// 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
|
||||
registerPackage(targetName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Package::registerPackage(const QString &desktopFilePath)
|
||||
{
|
||||
QString service = KStandardDirs::locateLocal("services", KGlobal::mainComponent().componentName());
|
||||
KPluginInfo pluginInfo(desktopFilePath);
|
||||
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
service.append(pluginInfo.pluginName()).append(".desktop");
|
||||
job = KIO::file_copy(targetName, service, -1, KIO::HideProgressInfo);
|
||||
KIO::FileCopyJob *job = KIO::file_copy(desktopFilePath, service, -1, KIO::HideProgressInfo);
|
||||
return job->exec();
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,14 @@ class PLASMA_EXPORT Package
|
||||
static bool installPackage(const QString &package,
|
||||
const QString &packageRoot);
|
||||
|
||||
/**
|
||||
* Registers a package described by the given desktop file
|
||||
*
|
||||
* @arg the full path to the desktop file (must be KPluginInfo compatible)
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
static bool registerPackage(const QString &desktopFilePath);
|
||||
|
||||
//TODO implement uninstall
|
||||
//static bool uninstallPackage(const QString& package, const QString& packageRoot);
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <KStandardDirs>
|
||||
#include <KServiceTypeTrader>
|
||||
|
||||
#include "packages_p.h"
|
||||
#include "package.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -330,6 +330,11 @@ void PackageStructure::write(KConfigBase *config) const
|
||||
}
|
||||
}
|
||||
|
||||
bool PackageStructure::installPackage(const QString &package, const QString &packageRoot)
|
||||
{
|
||||
return Package::installPackage(package, packageRoot);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "packagestructure.moc"
|
||||
|
@ -202,8 +202,19 @@ public:
|
||||
*/
|
||||
void write(KConfigBase *config) const;
|
||||
|
||||
/**
|
||||
* Installs a package matching this package structure. By default simply calls
|
||||
* Plasma::Package::install.
|
||||
*
|
||||
* @param package path to the Plasmagik package
|
||||
* @param packageRoot path to the directory where the package should be
|
||||
* installed to
|
||||
* @return true on successful installation, false otherwise
|
||||
**/
|
||||
virtual bool installPackage(const QString &package, const QString &packageRoot);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
class Private;
|
||||
Private * const d;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user