aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarja Hassinen <marja.hassinen@nokia.com>2010-12-21 09:50:07 +0200
committerMarja Hassinen <marja.hassinen@nokia.com>2010-12-21 09:50:07 +0200
commit8fe4477f8149db26cedb16155e02185d7c7ae2f1 (patch)
tree97c609a09f8e9bb7abe0eda17c90b359f1b63797
parent0ace037efcfcef08236ab6a484ad23bb3e679367 (diff)
lcs: Simplifying the contract between contextkit and plugins.
Emitting ready() when the plugin is already in ready state has no effect. Previously this caused the upper layer to resubscribe. Now, to cause that effect, emit failed() and then ready(). No plugins rely on the old behaviour, afaik.
-rw-r--r--libcontextsubscriber/src/contextkitplugin.cpp33
-rw-r--r--libcontextsubscriber/src/contextkitplugin.h3
-rw-r--r--libcontextsubscriber/src/provider.cpp4
3 files changed, 8 insertions, 32 deletions
diff --git a/libcontextsubscriber/src/contextkitplugin.cpp b/libcontextsubscriber/src/contextkitplugin.cpp
index 5ef4140e..84e5a53f 100644
--- a/libcontextsubscriber/src/contextkitplugin.cpp
+++ b/libcontextsubscriber/src/contextkitplugin.cpp
@@ -89,9 +89,7 @@ ContextKitPlugin::ContextKitPlugin(const QDBusConnection bus, const QString& bus
connection(new QDBusConnection(bus)),
busName(busName),
newProtocol(true),
- defaultNewProtocol(true),
- providerAppearedQueued(false),
- providerAppearedSkip(false)
+ defaultNewProtocol(true)
{
reset();
// Notice if the provider on the dbus comes and goes
@@ -105,7 +103,6 @@ ContextKitPlugin::ContextKitPlugin(const QDBusConnection bus, const QString& bus
// the provider at startup, whether it's present or not.
providerListener->startListening(false);
QMetaObject::invokeMethod(this, "onProviderAppeared", Qt::QueuedConnection);
- providerAppearedQueued = true;
}
void ContextKitPlugin::setDefaultNewProtocol(bool s) {
@@ -128,24 +125,6 @@ void ContextKitPlugin::reset()
/// appears.
void ContextKitPlugin::onProviderAppeared()
{
- // It is possible that this function is called and we have a Subscribe call
- // in progress. This happens when things happen in the following order:
- // 1. the subscriber is started
- // 2. the subscriber optimistically sends the Subscribe call
- // 3. the provider is started (quick enough to handle the Subscribe call)
- // 4. providerListener notices that the provider was started
- // In this case, the plugin is in "ready" state already.
-
- providerAppearedQueued = false;
-
- if (providerAppearedSkip) {
- // Now we had queued this function to be called, but before it was
- // called, waitUntilReadyAndBlock called it. Skip the scheduled call
- // (but not the later calls).
- providerAppearedSkip = false;
- return;
- }
-
contextDebug() << "Provider appeared:" << busName;
reset();
@@ -402,14 +381,10 @@ void ContextKitPlugin::onNewValueChanged(QList<QVariant> value,
void ContextKitPlugin::blockUntilReady()
{
- bool setSkip = providerAppearedQueued; // save this value
+ // This will result in emitting ready() immediately; we don't really block.
+ // This optimistic plugin is in "ready" state even if it's not sure whether
+ // the provider is running.
onProviderAppeared();
- if (setSkip) {
- // Calling onProviderAppeared was already scheduled but we already
- // called it now. Arrange so that the scheduled call is skipped when
- // the event is processed.
- providerAppearedSkip = true;
- }
}
void ContextKitPlugin::blockUntilSubscribed(const QString& key)
diff --git a/libcontextsubscriber/src/contextkitplugin.h b/libcontextsubscriber/src/contextkitplugin.h
index f2c3db94..eed4bdc0 100644
--- a/libcontextsubscriber/src/contextkitplugin.h
+++ b/libcontextsubscriber/src/contextkitplugin.h
@@ -119,9 +119,6 @@ private:
QHash<QString, PendingSubscribeWatcher*> pendingWatchers;
QSet<QString> pendingKeys;
-
- bool providerAppearedQueued;
- bool providerAppearedSkip;
};
QVariant demarshallValue(const QVariant &v);
diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp
index 2395d504..bafad166 100644
--- a/libcontextsubscriber/src/provider.cpp
+++ b/libcontextsubscriber/src/provider.cpp
@@ -215,6 +215,10 @@ void Provider::onPluginReady()
{
contextDebug();
+ // Ignore the signal if the plugin is already in the ready state.
+ if (pluginState == READY)
+ return;
+
QMutexLocker lock(&subscribeLock);
// Renew the subscriptions (if any).
// Renewing happens when a provider has disappeared and now it appeared again.