summaryrefslogtreecommitdiff
path: root/ohmd/ohm-plugin.c
diff options
context:
space:
mode:
authorRob Taylor <rob.taylor@codethink.co.uk>2007-08-18 17:17:12 +0100
committerRob Taylor <rob.taylor@codethink.co.uk>2007-08-22 15:17:50 +0100
commite0150c441c87eb2e203c1d33a6003f62ff49337e (patch)
tree7a61ac464faab4c88bb5d1c99185bdfc89beed51 /ohmd/ohm-plugin.c
parent1b3a9e232dfde6d115d20275376c4e817ad3109d (diff)
support for a plugin to listen on its own keys
Allow a plugin to listen to changes on a key it sets. A plugin will not be notified when it sets the key itself only when another plugin sets the key.
Diffstat (limited to 'ohmd/ohm-plugin.c')
-rw-r--r--ohmd/ohm-plugin.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ohmd/ohm-plugin.c b/ohmd/ohm-plugin.c
index 4012e48..1480ebd 100644
--- a/ohmd/ohm-plugin.c
+++ b/ohmd/ohm-plugin.c
@@ -59,6 +59,7 @@ struct _OhmPluginPrivate
GPtrArray *hal_udis;
OhmPluginHalPropMod hal_property_changed_cb;
OhmPluginHalCondition hal_condition_cb;
+ const char *key_being_set;
};
G_DEFINE_TYPE (OhmPlugin, ohm_plugin, G_TYPE_OBJECT)
@@ -154,7 +155,13 @@ ohm_plugin_conf_set_key (OhmPlugin *plugin,
gboolean ret;
error = NULL;
+ /* key_being_set is used to stop a plugin changing a key notifying
+ * itself if it's interest in that key
+ */
+ plugin->priv->key_being_set = key;
ret = ohm_conf_set_key_internal (plugin->priv->conf, key, value, TRUE, &error);
+ plugin->priv->key_being_set = NULL;
+
if (ret == FALSE) {
g_error ("Cannot set key: %s", error->message);
g_error_free (error);
@@ -164,9 +171,17 @@ ohm_plugin_conf_set_key (OhmPlugin *plugin,
gboolean
ohm_plugin_notify (OhmPlugin *plugin,
- int id,
- int value)
+ const char *key,
+ int id,
+ int value)
{
+ /* check that it wasn't this plugin that changed the key in
+ * the first place
+ */
+ if (plugin->priv->key_being_set &&
+ strcmp(plugin->priv->key_being_set, key) == 0)
+ return TRUE;
+
plugin->desc->notify (plugin, id, value);
return TRUE;
}