* 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:
Aaron J. Seigo 2008-09-03 23:55:06 +00:00
parent 124dd4bd63
commit be440d788a
3 changed files with 24 additions and 19 deletions

View File

@ -37,8 +37,8 @@ class ConfigXml;
class NullServiceJob : public ServiceJob
{
public:
NullServiceJob(QObject *parent)
: ServiceJob(QString(), QString(), QMap<QString, QVariant>(), parent)
NullServiceJob(const QString &destination, const QString &operation, QObject *parent)
: ServiceJob(destination, operation, QMap<QString, QVariant>(), parent)
{
}
@ -59,9 +59,9 @@ public:
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);
}
};

View File

@ -133,27 +133,31 @@ KConfigGroup Service::operationDescription(const QString &operationName)
ServiceJob* Service::startOperationCall(const KConfigGroup &description)
{
// TODO: nested groups?
ServiceJob *job = 0;
QString op = description.name();
if (!d->config) {
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();
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());
job = createJob(description.name(), params);
}
}
ServiceJob *job = createJob(description.name(), params);
if (!job) {
job = new NullServiceJob(destination(), op, this);
}
connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobFinished(KJob*)));
QTimer::singleShot(0, job, SLOT(slotStart()));
return job;

View File

@ -83,6 +83,7 @@ QVariant ServiceJob::result() const
void ServiceJob::setResult(const QVariant &result)
{
d->result = result;
emitResult();
}
void ServiceJob::start()