Allow to build libplasma without KIO. Only issue is that the

copying/moving/removal of folders is defunct (so is the package
install/uninstall).

svn path=/trunk/KDE/kdelibs/; revision=1185865
This commit is contained in:
Kevin Ottens 2010-10-14 12:27:15 +00:00
parent 1c77587903
commit c0f66faad7
11 changed files with 111 additions and 23 deletions

View File

@ -5,7 +5,7 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
set(PLASMA_NO_KDEWEBKIT TRUE) set(PLASMA_NO_KDEWEBKIT TRUE)
set(PLASMA_NO_KNEWSTUFF TRUE) set(PLASMA_NO_KNEWSTUFF TRUE)
set(PLASMA_NO_SOLID TRUE) set(PLASMA_NO_SOLID TRUE)
# set(PLASMA_NO_KIO TRUE) set(PLASMA_NO_KIO TRUE)
endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} include_directories(${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -4,4 +4,5 @@
#cmakedefine PLASMA_NO_KDEWEBKIT #cmakedefine PLASMA_NO_KDEWEBKIT
#cmakedefine PLASMA_NO_KNEWSTUFF #cmakedefine PLASMA_NO_KNEWSTUFF
#cmakedefine PLASMA_NO_SOLID #cmakedefine PLASMA_NO_SOLID
#cmakedefine PLASMA_NO_KIO

View File

@ -22,6 +22,8 @@
#include "containment.h" #include "containment.h"
#include "private/containment_p.h" #include "private/containment_p.h"
#include "config-plasma.h"
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QFile> #include <QFile>
@ -44,9 +46,12 @@
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <ktemporaryfile.h> #include <ktemporaryfile.h>
#include <kwindowsystem.h> #include <kwindowsystem.h>
#ifndef PLASMA_NO_KIO
#include "kio/jobclasses.h" // for KIO::JobFlags #include "kio/jobclasses.h" // for KIO::JobFlags
#include "kio/job.h" #include "kio/job.h"
#include "kio/scheduler.h" #include "kio/scheduler.h"
#endif
#include "abstracttoolbox.h" #include "abstracttoolbox.h"
#include "animator.h" #include "animator.h"
@ -1287,7 +1292,9 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
} }
QObject::connect(AccessManager::self(), SIGNAL(finished(Plasma::AccessAppletJob*)), QObject::connect(AccessManager::self(), SIGNAL(finished(Plasma::AccessAppletJob*)),
q, SLOT(remoteAppletReady(Plasma::AccessAppletJob*))); q, SLOT(remoteAppletReady(Plasma::AccessAppletJob*)));
} else { }
#ifndef PLASMA_NO_KIO
else {
KMimeType::Ptr mime = KMimeType::findByUrl(url); KMimeType::Ptr mime = KMimeType::findByUrl(url);
QString mimeName = mime->name(); QString mimeName = mime->name();
QRectF geom(pos, QSize()); QRectF geom(pos, QSize());
@ -1318,6 +1325,7 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
dropMenus[job] = choices; dropMenus[job] = choices;
} }
#endif
} }
if (dropEvent) { if (dropEvent) {
@ -1403,11 +1411,13 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
void ContainmentPrivate::clearDataForMimeJob(KIO::Job *job) void ContainmentPrivate::clearDataForMimeJob(KIO::Job *job)
{ {
#ifndef PLASMA_NO_KIO
QObject::disconnect(job, 0, q, 0); QObject::disconnect(job, 0, q, 0);
dropPoints.remove(job); dropPoints.remove(job);
KMenu *choices = dropMenus.take(job); KMenu *choices = dropMenus.take(job);
delete choices; delete choices;
job->kill(); job->kill();
#endif // PLASMA_NO_KIO
} }
void ContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job) void ContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job)
@ -1429,6 +1439,7 @@ void ContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job)
void ContainmentPrivate::dropJobResult(KJob *job) void ContainmentPrivate::dropJobResult(KJob *job)
{ {
#ifndef PLASMA_NO_KIO
KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job); KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job);
if (!tjob) { if (!tjob) {
kDebug() << "job is not a KIO::TransferJob, won't handle the drop..."; kDebug() << "job is not a KIO::TransferJob, won't handle the drop...";
@ -1441,10 +1452,12 @@ void ContainmentPrivate::dropJobResult(KJob *job)
// We call mimetypeRetrieved since there might be other mechanisms // We call mimetypeRetrieved since there might be other mechanisms
// for finding suitable applets. Cleanup happens there as well. // for finding suitable applets. Cleanup happens there as well.
mimeTypeRetrieved(qobject_cast<KIO::Job *>(job), QString()); mimeTypeRetrieved(qobject_cast<KIO::Job *>(job), QString());
#endif // PLASMA_NO_KIO
} }
void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimetype) void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimetype)
{ {
#ifndef PLASMA_NO_KIO
kDebug() << "Mimetype Job returns." << mimetype; kDebug() << "Mimetype Job returns." << mimetype;
KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job); KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job);
if (!tjob) { if (!tjob) {
@ -1562,6 +1575,7 @@ void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimetyp
} }
clearDataForMimeJob(job); clearDataForMimeJob(job);
#endif // PLASMA_NO_KIO
} }
const QGraphicsItem *Containment::toolBoxItem() const const QGraphicsItem *Containment::toolBoxItem() const

View File

@ -33,10 +33,6 @@
#include <plasma/applet.h> #include <plasma/applet.h>
#include <plasma/animator.h> #include <plasma/animator.h>
namespace KIO
{
class Job;
}
namespace Plasma namespace Plasma
{ {

View File

@ -33,10 +33,12 @@
#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/copyjob.h>
#include <kio/deletejob.h> #include <kio/deletejob.h>
#include <kio/jobclasses.h> #include <kio/jobclasses.h>
#include <kio/job.h> #include <kio/job.h>
#endif
#include <kmimetype.h> #include <kmimetype.h>
#include <kplugininfo.h> #include <kplugininfo.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
@ -440,17 +442,30 @@ bool Package::installPackage(const QString &package,
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::HideProgressInfo); KIO::CopyJob *job = KIO::move(KUrl(path), KUrl(targetName), KIO::HideProgressInfo);
if (!job->exec()) { bool ok = job->exec();
kWarning() << "Could not move package to destination:" << targetName << " : " << job->errorString(); QString errorString = job->errorString();
#else
bool ok = QFile::rename(path, targetName);
QString errorString("unknown");
#endif
if (!ok) {
kWarning() << "Could not move package to destination:" << targetName << " : " << errorString;
return false; return false;
} }
} else { } else {
// it's a directory containing the stuff, so copy the contents rather // it's a directory containing the stuff, so copy the contents rather
// than move them // than move them
#ifndef PLASMA_NO_KIO
KIO::CopyJob *job = KIO::copy(KUrl(path), KUrl(targetName), KIO::HideProgressInfo); KIO::CopyJob *job = KIO::copy(KUrl(path), KUrl(targetName), KIO::HideProgressInfo);
if (!job->exec()) { bool ok = job->exec();
kWarning() << "Could not copy package to destination:" << targetName << " : " << job->errorString(); #else
bool ok = false; // Qt dunno how to recursively copy directories, so don't bother
QString errorString("unknown");
#endif
if (!ok) {
kWarning() << "Could not copy package to destination:" << targetName << " : " << errorString;
return false; return false;
} }
} }
@ -476,8 +491,15 @@ bool Package::installPackage(const QString &package,
QString serviceName = servicePrefix + meta.pluginName(); QString serviceName = servicePrefix + meta.pluginName();
QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop");
#ifndef PLASMA_NO_KIO
KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO::HideProgressInfo); KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO::HideProgressInfo);
if (job->exec()) { bool ok = job->exec();
QString errorString = job->errorString();
#else
bool ok = QFile::copy(metaPath, service);
QString errorString("unknown");
#endif
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");
@ -488,7 +510,7 @@ bool Package::installPackage(const QString &package,
cg.writeEntry("Icon", iconPath); cg.writeEntry("Icon", iconPath);
} }
} else { } else {
kWarning() << "Could not register package as service (this is not necessarily fatal):" << serviceName << " : " << job->errorString(); kWarning() << "Could not register package as service (this is not necessarily fatal):" << serviceName << " : " << errorString;
} }
} }
@ -518,9 +540,16 @@ bool Package::uninstallPackage(const QString &pluginName,
kWarning() << "Unable to remove " << service; kWarning() << "Unable to remove " << service;
} }
#ifndef PLASMA_NO_KIO
KIO::DeleteJob *job = KIO::del(KUrl(targetName)); KIO::DeleteJob *job = KIO::del(KUrl(targetName));
if (!job->exec()) { ok = job->exec();
kWarning() << "Could not delete package from:" << targetName << " : " << job->errorString(); QString errorString = job->errorString();
#else
ok = QFile::remove(targetName);
QString errorString("unknown");
#endif
if (!ok) {
kWarning() << "Could not delete package from:" << targetName << " : " << errorString;
return false; return false;
} }
@ -553,8 +582,12 @@ bool Package::registerPackage(const PackageMetadata &data, const QString &iconPa
iconPath.right(iconPath.length() - iconPath.lastIndexOf("/"))); iconPath.right(iconPath.length() - iconPath.lastIndexOf("/")));
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); KIO::FileCopyJob *job = KIO::file_copy(iconPath, installedIcon, -1, KIO::HideProgressInfo);
job->exec(); job->exec();
#else
QFile::copy(iconPath, installedIcon);
#endif
} }
return true; return true;

View File

@ -19,12 +19,16 @@
#include "packagestructure.h" #include "packagestructure.h"
#include "config-plasma.h"
#include <QDir> #include <QDir>
#include <QMap> #include <QMap>
#include <QFileInfo> #include <QFileInfo>
#include <kconfiggroup.h> #include <kconfiggroup.h>
#ifndef PLASMA_NO_KIO
#include <kio/job.h> #include <kio/job.h>
#endif
#include <kmimetype.h> #include <kmimetype.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <kservicetypetrader.h> #include <kservicetypetrader.h>
@ -183,7 +187,9 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat)
KConfig config(url.toLocalFile(), KConfig::SimpleConfig); KConfig config(url.toLocalFile(), KConfig::SimpleConfig);
structure->read(&config); structure->read(&config);
PackageStructurePrivate::structures[structure->type()] = structure; PackageStructurePrivate::structures[structure->type()] = structure;
} else { }
#ifndef PLASMA_NO_KIO
else {
KTemporaryFile tmp; KTemporaryFile tmp;
if (tmp.open()) { if (tmp.open()) {
KIO::Job *job = KIO::file_copy(url, KUrl(tmp.fileName()), KIO::Job *job = KIO::file_copy(url, KUrl(tmp.fileName()),
@ -195,6 +201,7 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat)
} }
} }
} }
#endif
return structure; return structure;
} }

View File

@ -34,11 +34,6 @@
class KKeySequenceWidget; class KKeySequenceWidget;
namespace KIO
{
class Job;
}
namespace Plasma namespace Plasma
{ {

View File

@ -19,13 +19,21 @@
#include "associatedapplicationmanager_p.h" #include "associatedapplicationmanager_p.h"
#include "config-plasma.h"
#include <QHash> #include <QHash>
#include <QFile> #include <QFile>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <krun.h>
#include <kicon.h> #include <kicon.h>
#ifndef PLASMA_NO_KIO
#include <krun.h>
#else
#include <QProcess>
#include <QDesktopServices>
#endif
#include "plasma/applet.h" #include "plasma/applet.h"
namespace Plasma namespace Plasma
@ -110,13 +118,30 @@ KUrl::List AssociatedApplicationManager::urls(const Plasma::Applet *applet) cons
void AssociatedApplicationManager::run(Plasma::Applet *applet) void AssociatedApplicationManager::run(Plasma::Applet *applet)
{ {
if (d->applicationNames.contains(applet)) { if (d->applicationNames.contains(applet)) {
#ifndef PLASMA_NO_KIO
bool success = KRun::run(d->applicationNames.value(applet), d->urlLists.value(applet), 0); bool success = KRun::run(d->applicationNames.value(applet), d->urlLists.value(applet), 0);
#else
QString execCommand = d->applicationNames.value(applet);
// Clean-up the %u and friends from the exec command (KRun expect them, not QProcess)
execCommand = execCommand.replace(QRegExp("%[a-z]"), QString());
execCommand = execCommand.trimmed();
QStringList parameters = d->urlLists.value(applet).toStringList();
bool success = QProcess::startDetached(execCommand, parameters);
#endif
if (!success) { if (!success) {
applet->showMessage(KIcon("application-exit"), i18n("There was an error attempting to exec the associated application with this widget."), ButtonOk); applet->showMessage(KIcon("application-exit"), i18n("There was an error attempting to exec the associated application with this widget."), ButtonOk);
} }
} else if (d->urlLists.contains(applet) && !d->urlLists.value(applet).isEmpty()) { } else if (d->urlLists.contains(applet) && !d->urlLists.value(applet).isEmpty()) {
#ifndef PLASMA_NO_KIO
KRun *krun = new KRun(d->urlLists.value(applet).first(), 0); KRun *krun = new KRun(d->urlLists.value(applet).first(), 0);
krun->setAutoDelete(true); krun->setAutoDelete(true);
#else
QDesktopServices::openUrl(d->urlLists.value(applet).first());
#endif
} }
} }

View File

@ -30,6 +30,11 @@ static const int VERTICAL_STACKING_OFFSET = 10000;
class KJob; class KJob;
namespace KIO
{
class Job;
}
namespace Plasma namespace Plasma
{ {

View File

@ -73,7 +73,7 @@ class SaveImageThread : public QRunnable
m_image.save(m_filePath); m_image.save(m_filePath);
} }
}; };
LoadImageThread::LoadImageThread(const QString &filePath) LoadImageThread::LoadImageThread(const QString &filePath)
{ {
m_filePath = filePath; m_filePath = filePath;
@ -638,7 +638,7 @@ void Wallpaper::insertIntoCache(const QString& key, const QImage &image)
KIO::file_delete(d->cachePath(key)); KIO::file_delete(d->cachePath(key));
#else #else
QFile f(d->cachePath(key)); QFile f(d->cachePath(key));
f.remove(): f.remove();
#endif #endif
} else { } else {
QThreadPool::globalInstance()->start(new SaveImageThread(image, d->cachePath(key))); QThreadPool::globalInstance()->start(new SaveImageThread(image, d->cachePath(key)));

View File

@ -19,13 +19,21 @@
#include "videowidget.h" #include "videowidget.h"
#include "config-plasma.h"
#include <QUrl> #include <QUrl>
#include <QTimer> #include <QTimer>
#include <QGraphicsLinearLayout> #include <QGraphicsLinearLayout>
#include <QGraphicsSceneResizeEvent> #include <QGraphicsSceneResizeEvent>
#include <kicon.h> #include <kicon.h>
#include <kiconloader.h>
#ifndef PLASMA_NO_KIO
#include <kfiledialog.h> #include <kfiledialog.h>
#else
#include <QFileDialog>
#endif
#include <phonon/videowidget.h> #include <phonon/videowidget.h>
#include <phonon/mediaobject.h> #include <phonon/mediaobject.h>
@ -150,7 +158,11 @@ void VideoWidgetPrivate::volumeChanged(qreal value)
void VideoWidgetPrivate::showOpenFileDialog() void VideoWidgetPrivate::showOpenFileDialog()
{ {
#ifndef PLASMA_NO_KIO
openFile(KFileDialog::getOpenFileName()); openFile(KFileDialog::getOpenFileName());
#else
openFile(QFileDialog::getOpenFileName());
#endif
} }
void VideoWidgetPrivate::openFile(const QString &path) void VideoWidgetPrivate::openFile(const QString &path)