* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KIO::FileCopyJob* job = KIO::file_move(tempdir.name(), targetName, -1,
|
KIO::FileCopyJob* job = KIO::file_move(tempdir.name(), targetName, -1, KIO::HideProgressInfo);
|
||||||
KIO::HideProgressInfo);
|
|
||||||
|
|
||||||
if (!job->exec()) {
|
if (!job->exec()) {
|
||||||
kWarning(505) << "Could not move package to destination:" << targetName;
|
kWarning(505) << "Could not move package to destination:" << targetName;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to remove the temp dir (which has been moved)
|
// no need to remove the temp dir (which has been moved)
|
||||||
tempdir.setAutoRemove(false);
|
tempdir.setAutoRemove(false);
|
||||||
|
|
||||||
// and now we register it as a service =)
|
// and now we register it as a service =)
|
||||||
targetName.append("/metadata.desktop");
|
targetName.append("/metadata.desktop");
|
||||||
QString service = KStandardDirs::locateLocal("services",
|
|
||||||
KGlobal::mainComponent().componentName());
|
// should not installing it as a service disqualify it?
|
||||||
KPluginInfo pluginInfo(targetName);
|
// 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()) {
|
if (pluginInfo.pluginName().isEmpty()) {
|
||||||
// should not installing it as a service disqualify it?
|
return false;
|
||||||
// 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");
|
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();
|
return job->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,14 @@ class PLASMA_EXPORT Package
|
|||||||
static bool installPackage(const QString &package,
|
static bool installPackage(const QString &package,
|
||||||
const QString &packageRoot);
|
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
|
//TODO implement uninstall
|
||||||
//static bool uninstallPackage(const QString& package, const QString& packageRoot);
|
//static bool uninstallPackage(const QString& package, const QString& packageRoot);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
|
|
||||||
#include "packages_p.h"
|
#include "package.h"
|
||||||
|
|
||||||
namespace Plasma
|
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
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "packagestructure.moc"
|
#include "packagestructure.moc"
|
||||||
|
@ -202,8 +202,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
void write(KConfigBase *config) const;
|
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:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
Private * const d;
|
Private * const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user