From a406c3124486dad7f3ad9886dcf6f188d67e900c Mon Sep 17 00:00:00 2001 From: Marja Hassinen Date: Tue, 9 Nov 2010 15:40:35 +0200 Subject: Fixing some debug/warning inconsistency. --- libcontextsubscriber/src/provider.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp index 8826575c..b889045b 100644 --- a/libcontextsubscriber/src/provider.cpp +++ b/libcontextsubscriber/src/provider.cpp @@ -383,7 +383,9 @@ void Provider::onPluginValueChanged(QString key, QVariant newValue) Q_EMIT valueChanged(key); } else - contextWarning() << "Received a property not subscribed to:" << key; + // Plugins are allowed to send values which are not subscribed to, but + // only if they get them for free. + contextDebug() << "Received a property not subscribed to:" << key; } TimedValue Provider::get(const QString &key) const -- cgit v1.2.3 From c84d29477854ac3ce23d4b2b37ec676c2b7f10da Mon Sep 17 00:00:00 2001 From: Marja Hassinen Date: Tue, 9 Nov 2010 16:09:31 +0200 Subject: libcontextprovider, c api: don't restart services when new keys are added. --- libcontextprovider/src/contextc.cpp | 44 +++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/libcontextprovider/src/contextc.cpp b/libcontextprovider/src/contextc.cpp index 1b140e68..b421cb46 100644 --- a/libcontextprovider/src/contextc.cpp +++ b/libcontextprovider/src/contextc.cpp @@ -141,11 +141,14 @@ void context_provider_stop (void) // be kept alive in case the provider calls init again. } -/// Installs (adds) a \a key to be provided by the service. The callback function \a -/// subscription_changed_cb will be called with the passed user data \a subscription_changed_cb_target -/// when the status of the subscription changes -- when the first subscriber appears or the -/// last subscriber disappears. The \a clear_values_on_subscribe when enabled will automatically -/// clear (set to null/undetermined) the group keys on first subscribe. +/// Installs (adds) a \a key to be provided by the service. The callback +/// function \a subscription_changed_cb will be called with the passed user data +/// \a subscription_changed_cb_target when the status of the subscription +/// changes -- when the first subscriber appears or the last subscriber +/// disappears. The \a clear_values_on_subscribe when enabled will +/// automatically clear (set to null/undetermined) the group keys on first +/// subscribe. This function must be called after context_provider_init but +/// before entering the main loop. void context_provider_install_key (const char* key, int clear_values_on_subscribe, ContextProviderSubscriptionChangedCallback subscription_changed_cb, @@ -161,14 +164,25 @@ void context_provider_install_key (const char* key, listeners->append(new PropertyListener(*cService, key, clear_values_on_subscribe, subscription_changed_cb, subscription_changed_cb_target)); - cService->restart(); + + // Creating the PropertyListener will cause creation of PropertyPrivate, + // which will in turn register the corresponding D-Bus object. We don't + // restart the service here, but add objects to the already opened + // connection (which has also a bus name registered). This can only work if + // the provider doesn't go to the main loop between the bus name + // registration (done by context_provider_init or the provider program) and + // calling this function. } -/// Installs (adds) a \a key_group to be provided by the service. The \a key_group is a NULL-terminated -/// array containing the keys. The callback function \a subscription_changed_cb will be called with the -/// passed user data \a subscription_changed_cb_target when the status of the subscription changes -- -/// when the first subscriber appears or the last subscriber disappears. The \a clear_values_on_subscribe -/// when enabled will automatically clear (set to null/undetermined) the group keys on first subscribe. +/// Installs (adds) a \a key_group to be provided by the service. The \a +/// key_group is a NULL-terminated array containing the keys. The callback +/// function \a subscription_changed_cb will be called with the passed user data +/// \a subscription_changed_cb_target when the status of the subscription +/// changes -- when the first subscriber appears or the last subscriber +/// disappears. The \a clear_values_on_subscribe when enabled will +/// automatically clear (set to null/undetermined) the group keys on first +/// subscribe. This function must be called after context_provider_init but +/// before entering the main loop. void context_provider_install_group (char* const * key_group, int clear_values_on_subscribe, ContextProviderSubscriptionChangedCallback subscription_changed_cb, @@ -193,7 +207,13 @@ void context_provider_install_group (char* const * key_group, listeners->append(new GroupListener(*cService, keys, clear_values_on_subscribe, subscription_changed_cb, subscription_changed_cb_target)); - cService->restart(); + // Creating the PropertyListener will cause creation of PropertyPrivate, + // which will in turn register the corresponding D-Bus object. We don't + // restart the service here, but add objects to the already opened + // connection (which has also a bus name registered). This can only work if + // the provider doesn't go to the main loop between the bus name + // registration (done by context_provider_init or the provider program) and + // calling this function. } /// Sets the \a key to a specified integer \a value. -- cgit v1.2.3