Some KUrl-QUrl porting.

This commit is contained in:
David Faure 2012-03-11 10:28:36 +01:00
parent 13d5508112
commit 2365f2c657
26 changed files with 84 additions and 79 deletions

View File

@ -1594,7 +1594,7 @@ void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimeTyp
if (wallpaper) {
//kDebug() << "Wallpaper dropped:" << tjob->url();
wallpaper->addUrls(KUrl::List() << tjob->url());
wallpaper->addUrls(QList<QUrl>() << tjob->url());
}
} else {
addApplet(actionsToApplets[choice], args, QRectF(posi, QSize()));

View File

@ -28,6 +28,7 @@
#include "plasma/dataenginemanager.h"
#include "plasma/private/remotedataengine_p.h"
#include <servicejob.h>
#include <qurlpathinfo.h>
namespace Plasma
{
@ -57,12 +58,12 @@ void ServiceMonitor::slotJobFinished(Plasma::ServiceJob *job)
kDebug() << "engine does not exist yet!";
#endif
} else {
KUrl engineLocation(location);
QUrlPathInfo engineLocation(location);
engineLocation.setFileName(job->result().toString());
#ifndef NDEBUG
kDebug() << "setting location : " << engineLocation.prettyUrl();
kDebug() << "setting location : " << engineLocation.url();
#endif
m_consumer->m_remoteEngines[pair]->setLocation(engineLocation);
m_consumer->m_remoteEngines[pair]->setLocation(engineLocation.url());
}
}
@ -127,9 +128,9 @@ DataEngine *DataEngineConsumer::dataEngine(const QString &name)
return engine;
}
DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QString &name)
DataEngine *DataEngineConsumer::remoteDataEngine(const QUrl &location, const QString &name)
{
QPair<QString, QString> pair(location.prettyUrl(), name);
QPair<QString, QString> pair(location.toString(), name);
#ifndef NDEBUG
kDebug() << "pair = " << pair;
#endif
@ -143,10 +144,10 @@ DataEngine *DataEngineConsumer::remoteDataEngine(const KUrl &location, const QSt
#ifndef NDEBUG
kDebug() << "new remote dataengine at " << location;
#endif
RemoteDataEngine *engine = new RemoteDataEngine(KUrl());
RemoteDataEngine *engine = new RemoteDataEngine(QUrl());
m_remoteEngines[pair] = engine;
Service *plasmoidService = Service::access(location);
plasmoidService->setDestination(location.prettyUrl());
plasmoidService->setDestination(location.toString());
m_engineNameForService[plasmoidService] = name;
#ifndef NDEBUG
kDebug() << "name = " << name;

View File

@ -56,7 +56,7 @@ public:
DataEngineConsumer();
~DataEngineConsumer();
DataEngine *dataEngine(const QString &name);
DataEngine *remoteDataEngine(const KUrl &location, const QString &name);
DataEngine *remoteDataEngine(const QUrl &location, const QString &name);
private:
QSet<QString> m_loadedEngines;

View File

@ -28,12 +28,13 @@
#include <QTimer>
#include <QUuid>
#include <kurl.h>
#include <qurl.h>
#include <qurlpathinfo.h>
namespace Plasma
{
RemoteDataEngine::RemoteDataEngine(KUrl location, QObject* parent, const QVariantList& args)
RemoteDataEngine::RemoteDataEngine(const QUrl &location, QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args),
m_service(0),
m_location(location),
@ -52,7 +53,7 @@ RemoteDataEngine::~RemoteDataEngine()
{
}
void RemoteDataEngine::setLocation(KUrl location)
void RemoteDataEngine::setLocation(const QUrl &location)
{
m_location = location;
setMinimumPollingInterval(1000);
@ -186,11 +187,11 @@ void RemoteDataEngine::remoteCallFinished(Plasma::ServiceJob *job)
kDebug() << "setting serviceForSource for " << source;
#endif
QString resource = job->result().toString();
KUrl loc = m_location;
QUrlPathInfo loc(m_location);
loc.setFileName(resource);
RemoteService *rs = m_serviceForSource.value(source);
if (rs) {
rs->setLocation(loc);
rs->setLocation(loc.url());
} else {
#ifndef NDEBUG
kDebug() << "no such service?" << source;

View File

@ -36,10 +36,10 @@ class RemoteDataEngine : public Plasma::DataEngine
Q_OBJECT
public:
RemoteDataEngine(KUrl location, QObject* parent = 0, const QVariantList &args = QVariantList());
RemoteDataEngine(const QUrl &location, QObject* parent = 0, const QVariantList &args = QVariantList());
~RemoteDataEngine();
Plasma::Service* serviceForSource(const QString& source);
void setLocation(KUrl location);
void setLocation(const QUrl &location);
protected:
QStringList sources() const;
@ -59,7 +59,7 @@ private:
QHash<QString, RemoteService *> m_serviceForSource;
QHash<QString, RemoteService *> m_pendingServices;
QStringList m_pendingSources;
KUrl m_location;
QUrl m_location;
QString m_uuid;
};

View File

@ -42,9 +42,10 @@
#include <QtJolie/Value>
#include <kdebug.h>
#include <kurl.h>
#include <qurl.h>
#include <qurlpathinfo.h>
namespace Plasma
namespace Plasma
{
RemoteService::RemoteService(QObject* parent)
@ -55,7 +56,7 @@ RemoteService::RemoteService(QObject* parent)
{
}
RemoteService::RemoteService(QObject* parent, KUrl location)
RemoteService::RemoteService(QObject* parent, const QUrl &location)
: Service(parent),
m_location(location),
m_client(0),
@ -83,10 +84,16 @@ void RemoteService::slotReadyForRemoteAccess()
setLocation(m_location);
}
void RemoteService::setLocation(const KUrl &location)
static QByteArray resourcePathFromUrl(const QUrl& location)
{
QUrlPathInfo pi(location);
return pi.path(QUrlPathInfo::StripTrailingSlash).remove(0, 1).toUtf8();
}
void RemoteService::setLocation(const QUrl &location)
{
#ifndef NDEBUG
kDebug() << "Setting RemoteService location to " << location.prettyUrl();
kDebug() << "Setting RemoteService location to " << location;
#endif
m_uuid = QUuid::createUuid().toString();
@ -113,8 +120,7 @@ void RemoteService::setLocation(const KUrl &location)
QDataStream stream(&identityByteArray, QIODevice::WriteOnly);
stream << identity.toPublicCredentials();
Jolie::Message getOpDesc(location.path(KUrl::RemoveTrailingSlash).remove(0, 1).toUtf8(),
"startConnection");
Jolie::Message getOpDesc(resourcePathFromUrl(location), "startConnection");
Jolie::Value data;
data.children(JolieMessage::Field::IDENTITY) << Jolie::Value(identityByteArray);
data.children(JolieMessage::Field::UUID) << Jolie::Value(m_uuid.toAscii());
@ -128,7 +134,11 @@ void RemoteService::setLocation(const KUrl &location)
QString RemoteService::location() const
{
return m_location.prettyUrl();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
return m_location.toString();
#else
return m_location.toDisplayString();
#endif
}
bool RemoteService::isReady() const
@ -151,8 +161,7 @@ void RemoteService::callCompleted(Jolie::PendingCallWatcher *watcher)
kDebug() << "Started connection: fetching .operations";
#endif
m_token = JolieMessage::field(JolieMessage::Field::TOKEN, response);
Jolie::Message getOpDesc(m_location.path(KUrl::RemoveTrailingSlash).remove(0, 1).toUtf8(),
"getOperations");
Jolie::Message getOpDesc(resourcePathFromUrl(m_location), "getOperations");
//TODO: async
Jolie::PendingCall pendingReply = m_client->asyncCall(signMessage(getOpDesc));
Jolie::PendingCallWatcher *watcher = new Jolie::PendingCallWatcher(pendingReply, this);
@ -174,7 +183,7 @@ void RemoteService::callCompleted(Jolie::PendingCallWatcher *watcher)
m_operationsScheme = JolieMessage::field(JolieMessage::Field::OPERATIONSDESCRIPTION, response);
m_token = JolieMessage::field(JolieMessage::Field::TOKEN, response);
m_ready = true;
setName(m_location.prettyUrl());
setName(location());
//if there's stuff in the queue, let it continue.
slotFinished();
}
@ -212,8 +221,7 @@ void RemoteService::callCompleted(Jolie::PendingCallWatcher *watcher)
void RemoteService::slotGotPin(Plasma::ClientPinRequest *request)
{
Jolie::Message getOpDesc(m_location.path(KUrl::RemoveTrailingSlash).remove(0, 1).toUtf8(),
"getOperations");
Jolie::Message getOpDesc(resourcePathFromUrl(m_location), "getOperations");
Jolie::Value value;
value.children(JolieMessage::Field::PARAMETERS) << Jolie::Value(QByteArray());
if (!request->pin().isEmpty()) {
@ -243,8 +251,7 @@ void RemoteService::slotUpdateEnabledOperations()
//TODO: maybe push the get enabled operations also on the queue?
if (!m_busy) {
m_busy = true;
Jolie::Message getOpDesc(m_location.path(KUrl::RemoveTrailingSlash).remove(0, 1).toUtf8(),
"getEnabledOperations");
Jolie::Message getOpDesc(resourcePathFromUrl(m_location), "getEnabledOperations");
Jolie::PendingCall pendingReply = m_client->asyncCall(signMessage(getOpDesc));
Jolie::PendingCallWatcher *watcher = new Jolie::PendingCallWatcher(pendingReply, this);

View File

@ -21,6 +21,7 @@
#include <QtCore/QQueue>
#include <QtJolie/Message>
#include <QtCore/QUrl>
#include "../service.h"
@ -30,7 +31,7 @@ namespace Jolie
class PendingCallWatcher;
}
namespace Plasma
namespace Plasma
{
class ClientPinRequest;
@ -42,10 +43,10 @@ class RemoteService : public Plasma::Service
public:
RemoteService(QObject* parent);
RemoteService(QObject* parent, KUrl location);
RemoteService(QObject* parent, const QUrl &location);
~RemoteService();
void setLocation(const KUrl &location);
void setLocation(const QUrl &location);
QString location() const;
bool isReady() const;
@ -67,7 +68,7 @@ class RemoteService : public Plasma::Service
Jolie::Message signMessage(const Jolie::Message &message) const;
private:
KUrl m_location;
QUrl m_location;
Jolie::Client *m_client;
QByteArray m_token;
QByteArray m_operationsScheme;

View File

@ -43,7 +43,7 @@ namespace Plasma
class AccessAppletJobPrivate
{
public:
AccessAppletJobPrivate(const KUrl &location, AccessAppletJob *owner)
AccessAppletJobPrivate(const QUrl &location, AccessAppletJob *owner)
: q(owner),
location(location),
applet(0)
@ -166,11 +166,11 @@ public:
}
AccessAppletJob *q;
KUrl location;
QUrl location;
Applet *applet;
};
AccessAppletJob::AccessAppletJob(const KUrl &location, QObject *parent)
AccessAppletJob::AccessAppletJob(const QUrl &location, QObject *parent)
: KJob(parent),
d(new AccessAppletJobPrivate(location, this))
{
@ -191,7 +191,7 @@ void AccessAppletJob::start()
{
#ifdef ENABLE_REMOTE_WIDGETS
#ifndef NDEBUG
kDebug() << "fetching a plasmoid from location = " << d->location.prettyUrl();
kDebug() << "fetching a plasmoid from location = " << d->location;
#endif
Service *service = Service::access(d->location);
connect(service, SIGNAL(serviceReady(Plasma::Service*)),

View File

@ -24,7 +24,7 @@
#include <plasma/plasma_export.h>
class KUrl;
class QUrl;
namespace Plasma
{
@ -55,7 +55,7 @@ protected:
* @param location the location of the service
* @param parent the parent object for this service
*/
AccessAppletJob(const KUrl &location, QObject *parent = 0);
AccessAppletJob(const QUrl &location, QObject *parent = 0);
void start();
@ -68,7 +68,7 @@ private:
Q_PRIVATE_SLOT(d, void slotTimeout())
AccessAppletJobPrivate * const d;
friend class AccessManager;
friend class AccessManagerPrivate;
friend class AccessAppletJobPrivate;

View File

@ -35,7 +35,7 @@
#include <kdebug.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include <qurl.h>
#include <QtJolie/Message>
@ -48,7 +48,7 @@ public:
QString name;
QString description;
QString icon;
KUrl url;
QUrl url;
};
RemoteObjectDescription::RemoteObjectDescription()
@ -79,12 +79,12 @@ QString RemoteObjectDescription::name() const
}
void RemoteObjectDescription::setUrl(const KUrl &url)
void RemoteObjectDescription::setUrl(const QUrl &url)
{
d->url = url;
}
KUrl RemoteObjectDescription::url() const
QUrl RemoteObjectDescription::url() const
{
return d->url;
}
@ -136,11 +136,11 @@ AccessManager::~AccessManager()
delete d;
}
AccessAppletJob *AccessManager::accessRemoteApplet(const KUrl &location) const
AccessAppletJob *AccessManager::accessRemoteApplet(const QUrl &location) const
{
AuthorizationManager::self()->d->prepareForServiceAccess();
KUrl resolvedLocation;
QUrl resolvedLocation;
if (location.scheme() == "plasma+zeroconf") {
if (d->zeroconfServices.contains(location.host())) {
resolvedLocation = d->services[location.host()].url();
@ -222,7 +222,7 @@ void AccessManagerPrivate::slotAddService(DNSSD::RemoteService::Ptr service)
kDebug() << "result for resolve = " << ip;
#endif
KUrl url(QString("plasma://%1:%2/%3").arg(ip)
QUrl url(QString("plasma://%1:%2/%3").arg(ip)
.arg(service->port())
.arg(service->serviceName()));

View File

@ -30,7 +30,7 @@
#include <kdebug.h>
class QString;
class KUrl;
class QUrl;
namespace Plasma
{
@ -59,8 +59,8 @@ public:
void setName(const QString &name);
QString name() const;
void setUrl(const KUrl &url);
KUrl url() const;
void setUrl(const QUrl &url);
QUrl url() const;
void setDescription(const QString &description);
QString description() const;
@ -91,7 +91,7 @@ class PLASMA_EXPORT AccessManager : public QObject
* @returns a job that can be used to track when a remote plasmoid is ready for use, and to
* obtain the applet when the package is sent over.
*/
AccessAppletJob *accessRemoteApplet(const KUrl &location) const;
AccessAppletJob *accessRemoteApplet(const QUrl &location) const;
/**
* @returns a list of applets that are announced on the network through zeroconf. Use the

View File

@ -25,7 +25,6 @@
#include <QtCore/QObject>
class QString;
class KUrl;
namespace Plasma
{

View File

@ -25,7 +25,6 @@
#include <QtCore/QObject>
class QString;
class KUrl;
namespace Plasma
{

View File

@ -25,7 +25,6 @@
#include <QtCore/QObject>
class QString;
class KUrl;
namespace QCA
{

View File

@ -25,7 +25,6 @@
#include <QtCore/QObject>
class QString;
class KUrl;
namespace Plasma
{

View File

@ -26,7 +26,7 @@ namespace Plasma
class ServiceAccessJobPrivate
{
public:
ServiceAccessJobPrivate(ServiceAccessJob *owner, KUrl location)
ServiceAccessJobPrivate(ServiceAccessJob *owner, const QUrl& location)
: q(owner),
service(0),
location(location)
@ -45,10 +45,10 @@ public:
ServiceAccessJob *q;
Service *service;
KUrl location;
QUrl location;
};
ServiceAccessJob::ServiceAccessJob(KUrl location, QObject *parent)
ServiceAccessJob::ServiceAccessJob(const QUrl& location, QObject *parent)
: KJob(parent),
d(new ServiceAccessJobPrivate(this, location))
{

View File

@ -25,8 +25,6 @@
#include <plasma/plasma_export.h>
class KUrl;
namespace Plasma
{
@ -55,7 +53,7 @@ protected:
* @param location the location of the service
* @param parent the parent object for this service
*/
ServiceAccessJob(KUrl location, QObject *parent = 0);
ServiceAccessJob(const QUrl& location, QObject *parent = 0);
void start();
@ -64,7 +62,7 @@ private:
Q_PRIVATE_SLOT(d, void slotServiceReady())
ServiceAccessJobPrivate * const d;
friend class AccessManager;
friend class AccessManagerPrivate;
friend class ServiceAccessJobPrivate;

View File

@ -551,13 +551,13 @@ QString Signing::signerOf(const Package &package) const
return d->verifySignature(contents, QString());
}
QString Signing::signerOf(const KUrl &package, const KUrl &signature) const
QString Signing::signerOf(const QUrl &package, const QUrl &signature) const
{
#ifndef NDEBUG
kDebug() << "Checking existence of " << package.pathOrUrl();
kDebug() << "Checking existence of " << package;
#endif
#ifndef NDEBUG
kDebug() << "Checking existence of " << signature.pathOrUrl();
kDebug() << "Checking existence of " << signature;
#endif
if (!package.isLocalFile() || (!signature.isEmpty() && !signature.isLocalFile())) {

View File

@ -146,7 +146,7 @@ public:
* On success, this information can then be used with trustLevelOf and/or
* descriptiveString to get more information on the key.
*/
QString signerOf(const KUrl &package, const KUrl &signature = KUrl()) const ;
QString signerOf(const QUrl &package, const QUrl &signature = QUrl()) const ;
/**
* @return the QString path of the keystore being used.

View File

@ -34,7 +34,7 @@
#include <kmimetype.h>
#include <kshell.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include <qurl.h>
#include <kprotocolinfo.h>
#include "abstractrunner.h"
@ -198,14 +198,14 @@ class RunnerContextPrivate : public QSharedData
type = (space > 0) ? RunnerContext::ShellCommand :
RunnerContext::Executable;
} else {
KUrl url(term);
QUrl url = QUrl::fromUserInput(term);
// check for a normal URL first
//kDebug() << url << KProtocolInfo::protocolClass(url.scheme()) << url.hasHost() <<
// url.host() << url.isLocalFile() << path << path.indexOf('/');
const bool hasProtocol = !url.scheme().isEmpty();
const bool isLocalProtocol = KProtocolInfo::protocolClass(url.scheme()) == ":local";
if (hasProtocol &&
((!isLocalProtocol && url.hasHost()) ||
if (hasProtocol &&
((!isLocalProtocol && !url.host().isEmpty()) ||
(isLocalProtocol && url.scheme() != "file"))) {
// we either have a network protocol with a host, so we can show matches for it
// or we have a non-file url that may be local so a host isn't required

View File

@ -114,7 +114,7 @@ void WallpaperScript::wheelEvent(QGraphicsSceneWheelEvent *event)
Q_UNUSED(event)
}
void WallpaperScript::addUrls(const KUrl::List urls)
void WallpaperScript::addUrls(const QList<QUrl> & urls)
{
Q_UNUSED(urls)
}

View File

@ -139,7 +139,7 @@ public:
/**
* Adds urls (e.g. from a drop)
*/
virtual void addUrls(const KUrl::List urls);
virtual void addUrls(const QList<QUrl>& urls);
protected:
/**

View File

@ -64,7 +64,7 @@ Service::~Service()
delete d;
}
Service *Service::access(const KUrl &url, QObject *parent)
Service *Service::access(const QUrl &url, QObject *parent)
{
return new RemoteService(parent, url);
}

View File

@ -32,6 +32,7 @@
class QGraphicsWidget;
class QIODevice;
class QWidget;
class QUrl;
namespace Plasma
{
@ -105,7 +106,7 @@ public:
* Used to access a service from an url. Always check for the signal serviceReady() that fires
* when this service is actually ready for use.
*/
static Service *access(const KUrl &url, QObject *parent = 0);
static Service *access(const QUrl &url, QObject *parent = 0);
/**
* Sets the destination for this Service to operate on

View File

@ -124,7 +124,7 @@ Wallpaper::~Wallpaper()
delete d;
}
void Wallpaper::addUrls(const KUrl::List &urls)
void Wallpaper::addUrls(const QList<QUrl> &urls)
{
if (d->script) {
d->script->addUrls(urls);

View File

@ -202,7 +202,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
* This is triggered by events in the user interface such as
* drag and drop of files.
*/
virtual void addUrls(const KUrl::List &urls);
virtual void addUrls(const QList<QUrl> &urls);
/**
* This method is called when the wallpaper should be painted.