* move remotedataengine.h to remotedataengine_p.h as it's private
* allow queueing for un-ready remote services * always double check that the RemoteServiceJob is really Ok to send; things like operation being ready may have changed, for instance svn path=/trunk/KDE/kdelibs/; revision=1038181
This commit is contained in:
parent
54b7836134
commit
30dc3caf9b
@ -93,6 +93,7 @@
|
||||
#include "wallpaper.h"
|
||||
#include "paintutils.h"
|
||||
|
||||
#include "private/associatedapplicationmanager_p.h"
|
||||
#include "private/authorizationmanager_p.h"
|
||||
#include "private/containment_p.h"
|
||||
#include "private/extenderapplet_p.h"
|
||||
@ -100,10 +101,9 @@
|
||||
#include "private/packages_p.h"
|
||||
#include "private/plasmoidservice.h"
|
||||
#include "private/popupapplet_p.h"
|
||||
#include "private/remotedataengine_p.h"
|
||||
#include "private/service_p.h"
|
||||
#include "private/remotedataengine.h"
|
||||
#include "private/internaltoolbox_p.h"
|
||||
#include "private/associatedapplicationmanager_p.h"
|
||||
#include "ui_publish.h"
|
||||
|
||||
#include "config-plasma.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "plasma/dataenginemanager.h"
|
||||
#include "plasma/private/remotedataengine.h"
|
||||
#include "plasma/private/remotedataengine_p.h"
|
||||
#include <servicejob.h>
|
||||
|
||||
namespace Plasma
|
||||
|
@ -27,13 +27,13 @@
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "plasma/dataenginemanager.h"
|
||||
#include "plasma/private/remotedataengine.h"
|
||||
#include <servicejob.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class DataEngineConsumer;
|
||||
class RemoteDataEngine;
|
||||
|
||||
class ServiceMonitor : public QObject
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "remotedataengine.h"
|
||||
#include "remotedataengine_p.h"
|
||||
|
||||
#include "remoteservice_p.h"
|
||||
|
||||
@ -232,5 +232,5 @@ void RemoteDataEngine::updateSources()
|
||||
|
||||
}
|
||||
|
||||
#include "remotedataengine.moc"
|
||||
#include "remotedataengine_p.moc"
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "remoteservicejob_p.h"
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
#include <kurl.h>
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
@ -31,6 +32,7 @@
|
||||
#include "../remote/authorizationmanager.h"
|
||||
#include "authorizationmanager_p.h"
|
||||
#include "remoteservice_p.h"
|
||||
#include "servicejob_p.h"
|
||||
#include "joliemessagehelper_p.h"
|
||||
#include <qtimer.h>
|
||||
|
||||
@ -46,10 +48,17 @@ RemoteServiceJob::RemoteServiceJob(KUrl location,
|
||||
: ServiceJob(destination, operation, parameters, parent),
|
||||
m_token(initialToken),
|
||||
m_location(location),
|
||||
m_service(parent)
|
||||
m_service(parent),
|
||||
m_delayedDesc(0)
|
||||
{
|
||||
}
|
||||
|
||||
RemoteServiceJob::~RemoteServiceJob()
|
||||
{
|
||||
delete m_delayedDesc;
|
||||
m_delayedDesc = 0;
|
||||
}
|
||||
|
||||
void RemoteServiceJob::start()
|
||||
{
|
||||
QTimer::singleShot(30000, this, SLOT(timeout()));
|
||||
@ -94,11 +103,22 @@ void RemoteServiceJob::start()
|
||||
this, SLOT(callCompleted(Jolie::PendingCallWatcher*)));
|
||||
}
|
||||
|
||||
void RemoteServiceJob::setDelayedDescription(const KConfigGroup &desc)
|
||||
{
|
||||
if (!m_delayedDesc) {
|
||||
m_delayedDesc = new KConfigGroup(desc);
|
||||
} else {
|
||||
*m_delayedDesc = desc;
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteServiceJob::checkValidity()
|
||||
{
|
||||
if (!m_service->isOperationEnabled(operationName())) {
|
||||
setError(-1);
|
||||
setErrorText(i18n("Job no longer valid, operation is not enabled!"));
|
||||
} else if (m_delayedDesc) {
|
||||
d->parameters = m_service->parametersFromDescription(*m_delayedDesc);
|
||||
} else {
|
||||
KConfigGroup description = m_service->operationDescription(operationName());
|
||||
QMapIterator<QString, QVariant> param(parameters());
|
||||
@ -111,6 +131,9 @@ void RemoteServiceJob::checkValidity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete m_delayedDesc;
|
||||
m_delayedDesc = 0;
|
||||
}
|
||||
|
||||
void RemoteServiceJob::callCompleted(Jolie::PendingCallWatcher *watcher)
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include "../servicejob.h"
|
||||
|
||||
class KConfigGroup;
|
||||
|
||||
namespace Jolie
|
||||
{
|
||||
class PendingCallWatcher;
|
||||
@ -45,8 +47,10 @@ class RemoteServiceJob : public Plasma::ServiceJob
|
||||
QMap<QString,QVariant>& parameters,
|
||||
QByteArray initialToken,
|
||||
RemoteService *parent);
|
||||
~RemoteServiceJob();
|
||||
|
||||
void start();
|
||||
void setDelayedDescription(const KConfigGroup &desc);
|
||||
|
||||
private Q_SLOTS:
|
||||
void callCompleted(Jolie::PendingCallWatcher *watcher);
|
||||
@ -58,6 +62,7 @@ class RemoteServiceJob : public Plasma::ServiceJob
|
||||
QByteArray m_token;
|
||||
KUrl m_location;
|
||||
RemoteService *m_service;
|
||||
KConfigGroup *m_delayedDesc;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
49
service.cpp
49
service.cpp
@ -19,7 +19,6 @@
|
||||
|
||||
#include "service.h"
|
||||
#include "private/authorizationmanager_p.h"
|
||||
#include "private/remoteservice_p.h"
|
||||
#include "private/service_p.h"
|
||||
#include "private/serviceprovider_p.h"
|
||||
|
||||
@ -40,6 +39,8 @@
|
||||
#include "configloader.h"
|
||||
#include "version.h"
|
||||
#include "private/configloader_p.h"
|
||||
#include "private/remoteservice_p.h"
|
||||
#include "private/remoteservicejob_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -224,19 +225,15 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
||||
return params;
|
||||
}
|
||||
|
||||
ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject *parent)
|
||||
QMap<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
|
||||
{
|
||||
// TODO: nested groups?
|
||||
ServiceJob *job = 0;
|
||||
QString op = description.isValid() ? description.name() : QString();
|
||||
|
||||
if (!d->config) {
|
||||
kDebug() << "No valid operations scheme has been registered";
|
||||
} else if (!op.isEmpty() && d->config->hasGroup(op)) {
|
||||
if (d->disabledOperations.contains(op)) {
|
||||
kDebug() << "Operation" << op << "is disabled";
|
||||
} else {
|
||||
QMap<QString, QVariant> params;
|
||||
|
||||
if (!d->config || !description.isValid()) {
|
||||
return params;
|
||||
}
|
||||
|
||||
const QString op = description.name();
|
||||
foreach (const QString &key, description.keyList()) {
|
||||
KConfigSkeletonItem *item = d->config->findItem(op, key);
|
||||
if (item) {
|
||||
@ -244,7 +241,33 @@ ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject
|
||||
}
|
||||
}
|
||||
|
||||
job = createJob(description.name(), params);
|
||||
return params;
|
||||
}
|
||||
|
||||
ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject *parent)
|
||||
{
|
||||
// TODO: nested groups?
|
||||
ServiceJob *job = 0;
|
||||
const QString op = description.isValid() ? description.name() : QString();
|
||||
|
||||
RemoteService *rs = qobject_cast<RemoteService *>(this);
|
||||
if (!op.isEmpty() && rs && !rs->isReady()) {
|
||||
// if we have an operation, but a non-ready remote service, just let it through
|
||||
kDebug() << "Remote service is not ready; queueing operation";
|
||||
QMap<QString, QVariant> params;
|
||||
job = createJob(op, params);
|
||||
RemoteServiceJob *rsj = qobject_cast<RemoteServiceJob *>(job);
|
||||
if (rsj) {
|
||||
rsj->setDelayedDescription(description);
|
||||
}
|
||||
} else if (!d->config) {
|
||||
kDebug() << "No valid operations scheme has been registered";
|
||||
} else if (!op.isEmpty() && d->config->hasGroup(op)) {
|
||||
if (d->disabledOperations.contains(op)) {
|
||||
kDebug() << "Operation" << op << "is disabled";
|
||||
} else {
|
||||
QMap<QString, QVariant> params = parametersFromDescription(description);
|
||||
job = createJob(op, params);
|
||||
}
|
||||
} else {
|
||||
kDebug() << "Not a valid group!";
|
||||
|
@ -192,6 +192,13 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget);
|
||||
|
||||
/**
|
||||
* @return a parameter map for the given description
|
||||
* @arg description the configuration values to turn into the parameter map
|
||||
* @since 4.4
|
||||
*/
|
||||
Q_INVOKABLE QMap<QString, QVariant> parametersFromDescription(const KConfigGroup &description);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted when a job associated with this Service completes its task
|
||||
@ -275,6 +282,7 @@ private:
|
||||
friend class GetSource;
|
||||
friend class PackagePrivate;
|
||||
friend class ServiceProvider;
|
||||
friend class RemoveService;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
@ -123,6 +123,7 @@ private:
|
||||
ServiceJobPrivate * const d;
|
||||
|
||||
friend class ServiceProvider;
|
||||
friend class RemoteServiceJob;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
Loading…
Reference in New Issue
Block a user