* always set up a job to run when an operation call is made, even if it fails
* call emitResult() from setResult svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=856872
This commit is contained in:
parent
124dd4bd63
commit
be440d788a
@ -37,8 +37,8 @@ class ConfigXml;
|
|||||||
class NullServiceJob : public ServiceJob
|
class NullServiceJob : public ServiceJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullServiceJob(QObject *parent)
|
NullServiceJob(const QString &destination, const QString &operation, QObject *parent)
|
||||||
: ServiceJob(QString(), QString(), QMap<QString, QVariant>(), parent)
|
: ServiceJob(destination, operation, QMap<QString, QVariant>(), parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ public:
|
|||||||
setName("NullService");
|
setName("NullService");
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceJob *createJob(const QString &, QMap<QString, QVariant> &)
|
ServiceJob *createJob(const QString &operation, QMap<QString, QVariant> &)
|
||||||
{
|
{
|
||||||
return new NullServiceJob(parent());
|
return new NullServiceJob(destination(), operation, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
34
service.cpp
34
service.cpp
@ -133,27 +133,31 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
|||||||
ServiceJob* Service::startOperationCall(const KConfigGroup &description)
|
ServiceJob* Service::startOperationCall(const KConfigGroup &description)
|
||||||
{
|
{
|
||||||
// TODO: nested groups?
|
// TODO: nested groups?
|
||||||
|
ServiceJob *job = 0;
|
||||||
|
QString op = description.name();
|
||||||
if (!d->config) {
|
if (!d->config) {
|
||||||
kDebug() << "No valid operations scheme has been registered";
|
kDebug() << "No valid operations scheme has been registered";
|
||||||
return new NullServiceJob(parent());
|
} else {
|
||||||
}
|
if (d->disabledOperations.contains(op)) {
|
||||||
|
kDebug() << "Operation" << op << "is disabled";
|
||||||
|
} else {
|
||||||
|
d->config->writeConfig();
|
||||||
|
QMap<QString, QVariant> params;
|
||||||
|
foreach (const QString &key, description.keyList()) {
|
||||||
|
KConfigSkeletonItem *item = d->config->findItem(op, key);
|
||||||
|
if (item) {
|
||||||
|
params.insert(key, item->property());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString op = description.name();
|
job = createJob(description.name(), params);
|
||||||
if (d->disabledOperations.contains(op)) {
|
|
||||||
kDebug() << "Operation" << op << "is disabled";
|
|
||||||
return new NullServiceJob(parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
d->config->writeConfig();
|
|
||||||
QMap<QString, QVariant> params;
|
|
||||||
foreach (const QString &key, description.keyList()) {
|
|
||||||
KConfigSkeletonItem *item = d->config->findItem(op, key);
|
|
||||||
if (item) {
|
|
||||||
params.insert(key, item->property());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceJob *job = createJob(description.name(), params);
|
if (!job) {
|
||||||
|
job = new NullServiceJob(destination(), op, this);
|
||||||
|
}
|
||||||
|
|
||||||
connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobFinished(KJob*)));
|
connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobFinished(KJob*)));
|
||||||
QTimer::singleShot(0, job, SLOT(slotStart()));
|
QTimer::singleShot(0, job, SLOT(slotStart()));
|
||||||
return job;
|
return job;
|
||||||
|
@ -83,6 +83,7 @@ QVariant ServiceJob::result() const
|
|||||||
void ServiceJob::setResult(const QVariant &result)
|
void ServiceJob::setResult(const QVariant &result)
|
||||||
{
|
{
|
||||||
d->result = result;
|
d->result = result;
|
||||||
|
emitResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceJob::start()
|
void ServiceJob::start()
|
||||||
|
Loading…
Reference in New Issue
Block a user