package.cpp | package.cpp | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
#include <QRegExp> | #include <QRegExp> | |||
#include <QtNetwork/QHostInfo> | #include <QtNetwork/QHostInfo> | |||
#ifdef QCA2_FOUND | #ifdef QCA2_FOUND | |||
#include <QtCrypto> | #include <QtCrypto> | |||
#endif | #endif | |||
#include <karchive.h> | #include <karchive.h> | |||
#include <kcomponentdata.h> | #include <kcomponentdata.h> | |||
#include <kdesktopfile.h> | #include <kdesktopfile.h> | |||
#ifndef PLASMA_NO_KIO | ||||
#include <kio/copyjob.h> | ||||
#include <kio/deletejob.h> | ||||
#include <kio/jobclasses.h> | ||||
#include <kio/job.h> | ||||
#endif | ||||
#include <kmimetype.h> | #include <kmimetype.h> | |||
#include <kplugininfo.h> | #include <kplugininfo.h> | |||
#include <kstandarddirs.h> | #include <kstandarddirs.h> | |||
#include <ktar.h> | #include <ktar.h> | |||
#include <ktempdir.h> | #include <ktempdir.h> | |||
#include <ktemporaryfile.h> | #include <ktemporaryfile.h> | |||
#include <kzip.h> | #include <kzip.h> | |||
#include <kdebug.h> | #include <kdebug.h> | |||
#include "authorizationmanager.h" | #include "authorizationmanager.h" | |||
#include "packagemetadata.h" | #include "packagemetadata.h" | |||
#include "private/authorizationmanager_p.h" | #include "private/authorizationmanager_p.h" | |||
#include "private/package_p.h" | #include "private/package_p.h" | |||
#include "private/plasmoidservice_p.h" | #include "private/plasmoidservice_p.h" | |||
#include "private/service_p.h" | #include "private/service_p.h" | |||
namespace Plasma | namespace Plasma | |||
{ | { | |||
#ifdef PLASMA_NO_KIO // Provide some convenience for dealing with folders | ||||
bool copyFolder(QString sourcePath, QString targetPath) | bool copyFolder(QString sourcePath, QString targetPath) | |||
{ | { | |||
QDir source(sourcePath); | QDir source(sourcePath); | |||
if(!source.exists()) | if(!source.exists()) | |||
return false; | return false; | |||
QDir target(targetPath); | QDir target(targetPath); | |||
if(!target.exists()) { | if(!target.exists()) { | |||
QString targetName = target.dirName(); | QString targetName = target.dirName(); | |||
target.cdUp(); | target.cdUp(); | |||
skipping to change at line 121 | skipping to change at line 113 | |||
if (!removeFolder(folderPath + QDir::separator() + subFolderName)) { | if (!removeFolder(folderPath + QDir::separator() + subFolderName)) { | |||
return false; | return false; | |||
} | } | |||
} | } | |||
QString folderName = folder.dirName(); | QString folderName = folder.dirName(); | |||
folder.cdUp(); | folder.cdUp(); | |||
return folder.rmdir(folderName); | return folder.rmdir(folderName); | |||
} | } | |||
#endif // PLASMA_NO_KIO | ||||
Package::Package() | Package::Package() | |||
: d(new PackagePrivate(PackageStructure::Ptr(0), QString())) | : d(new PackagePrivate(PackageStructure::Ptr(0), QString())) | |||
{ | { | |||
} | } | |||
Package::Package(const QString &packageRoot, const QString &package, | Package::Package(const QString &packageRoot, const QString &package, | |||
PackageStructure::Ptr structure) | PackageStructure::Ptr structure) | |||
: d(new PackagePrivate(structure, packageRoot, package)) | : d(new PackagePrivate(structure, packageRoot, package)) | |||
{ | { | |||
} | } | |||
skipping to change at line 571 | skipping to change at line 561 | |||
} | } | |||
targetName = packageRoot + '/' + targetName; | targetName = packageRoot + '/' + targetName; | |||
if (QFile::exists(targetName)) { | if (QFile::exists(targetName)) { | |||
kWarning() << targetName << "already exists"; | kWarning() << targetName << "already exists"; | |||
return false; | return false; | |||
} | } | |||
if (archivedPackage) { | if (archivedPackage) { | |||
// it's in a temp dir, so just move it over. | // it's in a temp dir, so just move it over. | |||
#ifndef PLASMA_NO_KIO | ||||
KIO::CopyJob *job = KIO::move(KUrl(path), KUrl(targetName), KIO::Hi | ||||
deProgressInfo); | ||||
const bool ok = job->exec(); | ||||
const QString errorString = job->errorString(); | ||||
#else | ||||
const bool ok = copyFolder(path, targetName); | const bool ok = copyFolder(path, targetName); | |||
removeFolder(path); | removeFolder(path); | |||
const QString errorString("unknown"); | ||||
#endif | ||||
if (!ok) { | if (!ok) { | |||
kWarning() << "Could not move package to destination:" << targe tName << " : " << errorString; | kWarning() << "Could not move package to destination:" << targe tName; | |||
return false; | return false; | |||
} | } | |||
} else { | } else { | |||
kDebug() << "************************** 12"; | ||||
// it's a directory containing the stuff, so copy the contents rath er | // it's a directory containing the stuff, so copy the contents rath er | |||
// than move them | // than move them | |||
#ifndef PLASMA_NO_KIO | ||||
KIO::CopyJob *job = KIO::copy(KUrl(path), KUrl(targetName), KIO::Hi | ||||
deProgressInfo); | ||||
const bool ok = job->exec(); | ||||
const QString errorString = job->errorString(); | ||||
#else | ||||
const bool ok = copyFolder(path, targetName); | const bool ok = copyFolder(path, targetName); | |||
const QString errorString("unknown"); | kDebug() << "************************** 13"; | |||
#endif | ||||
if (!ok) { | if (!ok) { | |||
kWarning() << "Could not copy package to destination:" << targe tName << " : " << errorString; | kWarning() << "Could not copy package to destination:" << targe tName; | |||
return false; | return false; | |||
} | } | |||
} | } | |||
if (archivedPackage) { | if (archivedPackage) { | |||
// no need to remove the temp dir (which has been successfully move d if it's an archive) | // no need to remove the temp dir (which has been successfully move d if it's an archive) | |||
tempdir.setAutoRemove(false); | tempdir.setAutoRemove(false); | |||
} | } | |||
if (!servicePrefix.isEmpty()) { | if (!servicePrefix.isEmpty()) { | |||
// and now we register it as a service =) | // and now we register it as a service =) | |||
kDebug() << "************************** 1"; | ||||
QString metaPath = targetName + "/metadata.desktop"; | QString metaPath = targetName + "/metadata.desktop"; | |||
kDebug() << "************************** 2"; | ||||
KDesktopFile df(metaPath); | KDesktopFile df(metaPath); | |||
KConfigGroup cg = df.desktopGroup(); | KConfigGroup cg = df.desktopGroup(); | |||
kDebug() << "************************** 3"; | ||||
// Q: should not installing it as a service disqualify it? | // Q: should not installing it as a service disqualify it? | |||
// Q: i don't think so since KServiceTypeTrader may not be | // Q: i don't think so since KServiceTypeTrader may not be | |||
// used by the installing app in any case, and the | // used by the installing app in any case, and the | |||
// package is properly installed - aseigo | // package is properly installed - aseigo | |||
//TODO: reduce code duplication with registerPackage below | //TODO: reduce code duplication with registerPackage below | |||
QString serviceName = servicePrefix + meta.pluginName(); | QString serviceName = servicePrefix + meta.pluginName(); | |||
QString service = KStandardDirs::locateLocal("services", serviceNam e + ".desktop"); | QString service = KStandardDirs::locateLocal("services", serviceNam e + ".desktop"); | |||
#ifndef PLASMA_NO_KIO | kDebug() << "************************** 4"; | |||
KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO:: | ||||
HideProgressInfo); | ||||
const bool ok = job->exec(); | ||||
const QString errorString = job->errorString(); | ||||
#else | ||||
const bool ok = QFile::copy(metaPath, service); | const bool ok = QFile::copy(metaPath, service); | |||
const QString errorString("unknown"); | kDebug() << "************************** 5"; | |||
#endif | ||||
if (ok) { | if (ok) { | |||
// the icon in the installed file needs to point to the icon in the | // the icon in the installed file needs to point to the icon in the | |||
// installation dir! | // installation dir! | |||
QString iconPath = targetName + '/' + cg.readEntry("Icon"); | QString iconPath = targetName + '/' + cg.readEntry("Icon"); | |||
QFile icon(iconPath); | QFile icon(iconPath); | |||
if (icon.exists()) { | if (icon.exists()) { | |||
KDesktopFile df(service); | KDesktopFile df(service); | |||
KConfigGroup cg = df.desktopGroup(); | KConfigGroup cg = df.desktopGroup(); | |||
cg.writeEntry("Icon", iconPath); | cg.writeEntry("Icon", iconPath); | |||
} | } | |||
} else { | } else { | |||
kWarning() << "Could not register package as service (this is n ot necessarily fatal):" << serviceName << " : " << errorString; | kWarning() << "Could not register package as service (this is n ot necessarily fatal):" << serviceName; | |||
} | } | |||
kDebug() << "************************** 7"; | ||||
} | } | |||
return true; | return true; | |||
} | } | |||
bool Package::uninstallPackage(const QString &pluginName, | bool Package::uninstallPackage(const QString &pluginName, | |||
const QString &packageRoot, | const QString &packageRoot, | |||
const QString &servicePrefix) // static | const QString &servicePrefix) // static | |||
{ | { | |||
// We need to remove the package directory and its metadata file. | // We need to remove the package directory and its metadata file. | |||
skipping to change at line 671 | skipping to change at line 648 | |||
QString serviceName = servicePrefix + pluginName; | QString serviceName = servicePrefix + pluginName; | |||
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); | QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); | |||
kDebug() << "Removing service file " << service; | kDebug() << "Removing service file " << service; | |||
bool ok = QFile::remove(service); | bool ok = QFile::remove(service); | |||
if (!ok) { | if (!ok) { | |||
kWarning() << "Unable to remove " << service; | kWarning() << "Unable to remove " << service; | |||
} | } | |||
#ifndef PLASMA_NO_KIO | ||||
KIO::DeleteJob *job = KIO::del(KUrl(targetName)); | ||||
ok = job->exec(); | ||||
const QString errorString = job->errorString(); | ||||
#else | ||||
ok = removeFolder(targetName); | ok = removeFolder(targetName); | |||
const QString errorString("unknown"); | const QString errorString("unknown"); | |||
#endif | ||||
if (!ok) { | if (!ok) { | |||
kWarning() << "Could not delete package from:" << targetName << " : " << errorString; | kWarning() << "Could not delete package from:" << targetName << " : " << errorString; | |||
return false; | return false; | |||
} | } | |||
return true; | return true; | |||
} | } | |||
bool Package::registerPackage(const PackageMetadata &data, const QString &i conPath) | bool Package::registerPackage(const PackageMetadata &data, const QString &i conPath) | |||
{ | { | |||
skipping to change at line 713 | skipping to change at line 684 | |||
cg.writeEntry("X-KDE-ServiceTypes", serviceTypes); | cg.writeEntry("X-KDE-ServiceTypes", serviceTypes); | |||
cg.writeEntry("X-KDE-PluginInfo-EnabledByDefault", true); | cg.writeEntry("X-KDE-PluginInfo-EnabledByDefault", true); | |||
QFile icon(iconPath); | QFile icon(iconPath); | |||
if (icon.exists()) { | if (icon.exists()) { | |||
//FIXME: the '/' search will break on non-UNIX. do we care? | //FIXME: the '/' search will break on non-UNIX. do we care? | |||
QString installedIcon("plasma_applet_" + data.pluginName() + | QString installedIcon("plasma_applet_" + data.pluginName() + | |||
iconPath.right(iconPath.length() - iconPath.l astIndexOf("/"))); | iconPath.right(iconPath.length() - iconPath.l astIndexOf("/"))); | |||
cg.writeEntry("Icon", installedIcon); | cg.writeEntry("Icon", installedIcon); | |||
installedIcon = KStandardDirs::locateLocal("icon", installedIcon); | installedIcon = KStandardDirs::locateLocal("icon", installedIcon); | |||
#ifndef PLASMA_NO_KIO | ||||
KIO::FileCopyJob *job = KIO::file_copy(iconPath, installedIcon, -1, | ||||
KIO::HideProgressInfo); | ||||
job->exec(); | ||||
#else | ||||
QFile::copy(iconPath, installedIcon); | QFile::copy(iconPath, installedIcon); | |||
#endif | ||||
} | } | |||
return true; | return true; | |||
} | } | |||
bool Package::createPackage(const PackageMetadata &metadata, | bool Package::createPackage(const PackageMetadata &metadata, | |||
const QString &source, | const QString &source, | |||
const QString &destination, | const QString &destination, | |||
const QString &icon) // static | const QString &icon) // static | |||
{ | { | |||
End of changes. 21 change blocks. | ||||
49 lines changed or deleted | 11 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |