* 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 "wallpaper.h"
|
||||||
#include "paintutils.h"
|
#include "paintutils.h"
|
||||||
|
|
||||||
|
#include "private/associatedapplicationmanager_p.h"
|
||||||
#include "private/authorizationmanager_p.h"
|
#include "private/authorizationmanager_p.h"
|
||||||
#include "private/containment_p.h"
|
#include "private/containment_p.h"
|
||||||
#include "private/extenderapplet_p.h"
|
#include "private/extenderapplet_p.h"
|
||||||
@ -100,10 +101,9 @@
|
|||||||
#include "private/packages_p.h"
|
#include "private/packages_p.h"
|
||||||
#include "private/plasmoidservice.h"
|
#include "private/plasmoidservice.h"
|
||||||
#include "private/popupapplet_p.h"
|
#include "private/popupapplet_p.h"
|
||||||
|
#include "private/remotedataengine_p.h"
|
||||||
#include "private/service_p.h"
|
#include "private/service_p.h"
|
||||||
#include "private/remotedataengine.h"
|
|
||||||
#include "private/internaltoolbox_p.h"
|
#include "private/internaltoolbox_p.h"
|
||||||
#include "private/associatedapplicationmanager_p.h"
|
|
||||||
#include "ui_publish.h"
|
#include "ui_publish.h"
|
||||||
|
|
||||||
#include "config-plasma.h"
|
#include "config-plasma.h"
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
#include "plasma/dataenginemanager.h"
|
#include "plasma/dataenginemanager.h"
|
||||||
#include "plasma/private/remotedataengine.h"
|
#include "plasma/private/remotedataengine_p.h"
|
||||||
#include <servicejob.h>
|
#include <servicejob.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
#include "plasma/dataenginemanager.h"
|
#include "plasma/dataenginemanager.h"
|
||||||
#include "plasma/private/remotedataengine.h"
|
|
||||||
#include <servicejob.h>
|
#include <servicejob.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataEngineConsumer;
|
class DataEngineConsumer;
|
||||||
|
class RemoteDataEngine;
|
||||||
|
|
||||||
class ServiceMonitor : public QObject
|
class ServiceMonitor : public QObject
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "remotedataengine.h"
|
#include "remotedataengine_p.h"
|
||||||
|
|
||||||
#include "remoteservice_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 "remoteservicejob_p.h"
|
||||||
|
|
||||||
|
#include <kconfiggroup.h>
|
||||||
#include <kurl.h>
|
#include <kurl.h>
|
||||||
|
|
||||||
#include <QtCore/QBuffer>
|
#include <QtCore/QBuffer>
|
||||||
@ -31,6 +32,7 @@
|
|||||||
#include "../remote/authorizationmanager.h"
|
#include "../remote/authorizationmanager.h"
|
||||||
#include "authorizationmanager_p.h"
|
#include "authorizationmanager_p.h"
|
||||||
#include "remoteservice_p.h"
|
#include "remoteservice_p.h"
|
||||||
|
#include "servicejob_p.h"
|
||||||
#include "joliemessagehelper_p.h"
|
#include "joliemessagehelper_p.h"
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
@ -46,10 +48,17 @@ RemoteServiceJob::RemoteServiceJob(KUrl location,
|
|||||||
: ServiceJob(destination, operation, parameters, parent),
|
: ServiceJob(destination, operation, parameters, parent),
|
||||||
m_token(initialToken),
|
m_token(initialToken),
|
||||||
m_location(location),
|
m_location(location),
|
||||||
m_service(parent)
|
m_service(parent),
|
||||||
|
m_delayedDesc(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoteServiceJob::~RemoteServiceJob()
|
||||||
|
{
|
||||||
|
delete m_delayedDesc;
|
||||||
|
m_delayedDesc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteServiceJob::start()
|
void RemoteServiceJob::start()
|
||||||
{
|
{
|
||||||
QTimer::singleShot(30000, this, SLOT(timeout()));
|
QTimer::singleShot(30000, this, SLOT(timeout()));
|
||||||
@ -94,11 +103,22 @@ void RemoteServiceJob::start()
|
|||||||
this, SLOT(callCompleted(Jolie::PendingCallWatcher*)));
|
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()
|
void RemoteServiceJob::checkValidity()
|
||||||
{
|
{
|
||||||
if (!m_service->isOperationEnabled(operationName())) {
|
if (!m_service->isOperationEnabled(operationName())) {
|
||||||
setError(-1);
|
setError(-1);
|
||||||
setErrorText(i18n("Job no longer valid, operation is not enabled!"));
|
setErrorText(i18n("Job no longer valid, operation is not enabled!"));
|
||||||
|
} else if (m_delayedDesc) {
|
||||||
|
d->parameters = m_service->parametersFromDescription(*m_delayedDesc);
|
||||||
} else {
|
} else {
|
||||||
KConfigGroup description = m_service->operationDescription(operationName());
|
KConfigGroup description = m_service->operationDescription(operationName());
|
||||||
QMapIterator<QString, QVariant> param(parameters());
|
QMapIterator<QString, QVariant> param(parameters());
|
||||||
@ -111,6 +131,9 @@ void RemoteServiceJob::checkValidity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete m_delayedDesc;
|
||||||
|
m_delayedDesc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteServiceJob::callCompleted(Jolie::PendingCallWatcher *watcher)
|
void RemoteServiceJob::callCompleted(Jolie::PendingCallWatcher *watcher)
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "../servicejob.h"
|
#include "../servicejob.h"
|
||||||
|
|
||||||
|
class KConfigGroup;
|
||||||
|
|
||||||
namespace Jolie
|
namespace Jolie
|
||||||
{
|
{
|
||||||
class PendingCallWatcher;
|
class PendingCallWatcher;
|
||||||
@ -45,8 +47,10 @@ class RemoteServiceJob : public Plasma::ServiceJob
|
|||||||
QMap<QString,QVariant>& parameters,
|
QMap<QString,QVariant>& parameters,
|
||||||
QByteArray initialToken,
|
QByteArray initialToken,
|
||||||
RemoteService *parent);
|
RemoteService *parent);
|
||||||
|
~RemoteServiceJob();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
void setDelayedDescription(const KConfigGroup &desc);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void callCompleted(Jolie::PendingCallWatcher *watcher);
|
void callCompleted(Jolie::PendingCallWatcher *watcher);
|
||||||
@ -58,6 +62,7 @@ class RemoteServiceJob : public Plasma::ServiceJob
|
|||||||
QByteArray m_token;
|
QByteArray m_token;
|
||||||
KUrl m_location;
|
KUrl m_location;
|
||||||
RemoteService *m_service;
|
RemoteService *m_service;
|
||||||
|
KConfigGroup *m_delayedDesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
49
service.cpp
49
service.cpp
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "private/authorizationmanager_p.h"
|
#include "private/authorizationmanager_p.h"
|
||||||
#include "private/remoteservice_p.h"
|
|
||||||
#include "private/service_p.h"
|
#include "private/service_p.h"
|
||||||
#include "private/serviceprovider_p.h"
|
#include "private/serviceprovider_p.h"
|
||||||
|
|
||||||
@ -40,6 +39,8 @@
|
|||||||
#include "configloader.h"
|
#include "configloader.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "private/configloader_p.h"
|
#include "private/configloader_p.h"
|
||||||
|
#include "private/remoteservice_p.h"
|
||||||
|
#include "private/remoteservicejob_p.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -224,19 +225,15 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
|||||||
return params;
|
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;
|
QMap<QString, QVariant> params;
|
||||||
|
|
||||||
|
if (!d->config || !description.isValid()) {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString op = description.name();
|
||||||
foreach (const QString &key, description.keyList()) {
|
foreach (const QString &key, description.keyList()) {
|
||||||
KConfigSkeletonItem *item = d->config->findItem(op, key);
|
KConfigSkeletonItem *item = d->config->findItem(op, key);
|
||||||
if (item) {
|
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 {
|
} else {
|
||||||
kDebug() << "Not a valid group!";
|
kDebug() << "Not a valid group!";
|
||||||
|
@ -192,6 +192,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget);
|
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:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* Emitted when a job associated with this Service completes its task
|
* Emitted when a job associated with this Service completes its task
|
||||||
@ -275,6 +282,7 @@ private:
|
|||||||
friend class GetSource;
|
friend class GetSource;
|
||||||
friend class PackagePrivate;
|
friend class PackagePrivate;
|
||||||
friend class ServiceProvider;
|
friend class ServiceProvider;
|
||||||
|
friend class RemoveService;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
@ -123,6 +123,7 @@ private:
|
|||||||
ServiceJobPrivate * const d;
|
ServiceJobPrivate * const d;
|
||||||
|
|
||||||
friend class ServiceProvider;
|
friend class ServiceProvider;
|
||||||
|
friend class RemoteServiceJob;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
Loading…
Reference in New Issue
Block a user