From a9e725a2af2700c64fe2b5e9bd77fdd3d4558848 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 11:21:16 -0600 Subject: Including type information in the creation and destruction of servers --- tests/listen-and-print.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c index b12fd3d..3002d67 100644 --- a/tests/listen-and-print.c +++ b/tests/listen-and-print.c @@ -21,15 +21,15 @@ indicator_modified (IndicateListener * listener, IndicateListenerServer * server } static void -server_added (IndicateListener * listener, IndicateListenerServer * server, gpointer data) +server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { - g_debug("Indicator Server Added: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); + g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type); } static void -server_removed (IndicateListener * listener, IndicateListenerServer * server, gpointer data) +server_removed (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { - g_debug("Indicator Server Removed: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); + g_debug("Indicator Server Removed: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type); } int -- cgit v1.2.3 From 01244bcd32bc6525a3b5e11d2951f36ad591b6e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:14:29 -0600 Subject: Adding an API for getting the type and desktop files --- libindicate/listener.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libindicate/listener.h b/libindicate/listener.h index ddf0281..3bcad00 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -51,6 +51,8 @@ struct _IndicateListenerClass { GType indicate_listener_get_type (void) G_GNUC_CONST; typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data); +typedef void (*indicate_listener_get_type_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); +typedef void (*indicate_listener_get_desktop_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * desktop, gpointer data); /* Create a new listener */ IndicateListener * indicate_listener_new (void); @@ -63,6 +65,14 @@ void indicate_listener_get_property (IndicateListener * liste void indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator); +void indicate_listener_get_type (IndicateListener * listener, + IndicateListenerServer * server, + indicate_listener_get_type_cb callback, + gpointer data); +void indicate_listener_get_desktop (IndicateListener * listener, + IndicateListenerServer * server, + indicate_listener_get_desktop_cb callback, + gpointer data); -- cgit v1.2.3 From ee050d4a2bdb4059a6ba9a1175effed3c71be946 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:14:57 -0600 Subject: Changing type to message.im for testing, now it's different than the messages. --- tests/im-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/im-client.c b/tests/im-client.c index b6e4f09..04f4da3 100644 --- a/tests/im-client.c +++ b/tests/im-client.c @@ -17,7 +17,7 @@ main (int argc, char ** argv) IndicateServer * server = indicate_server_ref_default(); GValue value = {0}; g_value_init(&value, G_TYPE_STRING); - g_value_set_static_string(&value, "message"); + g_value_set_static_string(&value, "message.im"); g_object_set_property(G_OBJECT(server), "type", &value); IndicateIndicatorMessage * indicator; -- cgit v1.2.3 From c6eab162d9397b44d26943e5e3fbf4ffe70aa8f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:16:31 -0600 Subject: Adding in a set_type function and fixing the prototype for set_desktop --- libindicate/server.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libindicate/server.h b/libindicate/server.h index c2b2191..1aaeb47 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -55,7 +55,8 @@ void indicate_server_set_dbus_object (const gchar * obj); /* Sets the desktop file to get data like name and description * out of */ -void indicate_server_set_desktop_file (const gchar * path); +void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path); +void indicate_server_set_type (IndicateServer * server, const gchar * type); /* Show and hide the server on DBus, this allows for the server to * be created, change the object, and then shown. If for some @@ -71,6 +72,7 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato IndicateServer * indicate_server_ref_default (void); void indicate_server_set_default (IndicateServer * server); + /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); -- cgit v1.2.3 From 5a03a064a9555b630674d661ba6296e7f8137c02 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:19:02 -0600 Subject: Adding in functions to match the prototypes. --- libindicate/server.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libindicate/server.c b/libindicate/server.c index 7daedc7..0b46b0a 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -368,6 +368,27 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i return; } +void +indicate_server_set_dbus_object (const gchar * obj) +{ + /* TODO */ + return; +} + +void +indicate_server_set_desktop_file (IndicateServer * server, const gchar * path) +{ + /* TODO */ + return; +} + +void +indicate_server_set_type (IndicateServer * server, const gchar * type) +{ + /* TODO */ + return; +} + static IndicateServer * default_indicate_server = NULL; IndicateServer * -- cgit v1.2.3 From 0fcfc2be936f31c531c5f6ddea00fbc8bc083523 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:28:54 -0600 Subject: Adding in real functions to match the prototypes. --- libindicate/listener.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 2904e62..44f4377 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -645,3 +645,19 @@ indicate_listener_display (IndicateListener * listener, IndicateListenerServer * return; } + +void +indicate_listener_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_type_cb callback, gpointer data) +{ + + + +} + +void +indicate_listener_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_desktop_cb callback, gpointer data) +{ + + + +} -- cgit v1.2.3 From 8bfb5a1b6475f00cb503c794de585f4817c10163 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 15:30:45 -0600 Subject: Avoiding a conflict with GObject's get_type function. --- libindicate/listener.c | 4 ++-- libindicate/listener.h | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 44f4377..ae948e3 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -647,7 +647,7 @@ indicate_listener_display (IndicateListener * listener, IndicateListenerServer * } void -indicate_listener_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_type_cb callback, gpointer data) +indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_type_cb callback, gpointer data) { @@ -655,7 +655,7 @@ indicate_listener_get_type (IndicateListener * listener, IndicateListenerServer } void -indicate_listener_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_desktop_cb callback, gpointer data) +indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_desktop_cb callback, gpointer data) { diff --git a/libindicate/listener.h b/libindicate/listener.h index 3bcad00..44855bd 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -55,24 +55,24 @@ typedef void (*indicate_listener_get_type_cb) (IndicateListener * listener, Indi typedef void (*indicate_listener_get_desktop_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * desktop, gpointer data); /* Create a new listener */ -IndicateListener * indicate_listener_new (void); -void indicate_listener_get_property (IndicateListener * listener, - IndicateListenerServer * server, - IndicateListenerIndicator * indicator, - gchar * property, - indicate_listener_get_property_cb callback, - gpointer data); -void indicate_listener_display (IndicateListener * listener, - IndicateListenerServer * server, - IndicateListenerIndicator * indicator); -void indicate_listener_get_type (IndicateListener * listener, - IndicateListenerServer * server, - indicate_listener_get_type_cb callback, - gpointer data); -void indicate_listener_get_desktop (IndicateListener * listener, - IndicateListenerServer * server, - indicate_listener_get_desktop_cb callback, - gpointer data); +IndicateListener * indicate_listener_new (void); +void indicate_listener_get_property (IndicateListener * listener, + IndicateListenerServer * server, + IndicateListenerIndicator * indicator, + gchar * property, + indicate_listener_get_property_cb callback, + gpointer data); +void indicate_listener_display (IndicateListener * listener, + IndicateListenerServer * server, + IndicateListenerIndicator * indicator); +void indicate_listener_server_get_type (IndicateListener * listener, + IndicateListenerServer * server, + indicate_listener_get_type_cb callback, + gpointer data); +void indicate_listener_server_get_desktop (IndicateListener * listener, + IndicateListenerServer * server, + indicate_listener_get_desktop_cb callback, + gpointer data); -- cgit v1.2.3 From 49220be1da318eb6d3154c585fec5242c6e81194 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 16:49:33 -0600 Subject: Building a way to get properties. Seems like this should be in the DBus libs, but anyway. Here is the code that compiles and claims that it'll do it. More code than I would have liked. --- libindicate/listener.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++-- libindicate/listener.h | 7 ++-- 2 files changed, 101 insertions(+), 8 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index ae948e3..42da50f 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -42,6 +42,7 @@ struct _IndicateListenerPrivate typedef struct { DBusGProxy * proxy; + DBusGProxy * property_proxy; gchar * name; gchar * type; IndicateListener * listener; @@ -291,6 +292,14 @@ proxy_struct_destroy (gpointer data) proxy_data->indicators = NULL; } + if (proxy_data->property_proxy) { + g_object_unref(G_OBJECT(proxy_data->proxy)); + } + + if (proxy_data->property_proxy) { + g_object_unref(G_OBJECT(proxy_data->proxy)); + } + g_free(proxy_data->name); if (proxy_data->type != NULL) { g_free(proxy_data->type); @@ -379,6 +388,7 @@ todo_idle (gpointer data) proxyt->name, "/org/freedesktop/indicate", "org.freedesktop.indicator"); + proxyt->property_proxy = NULL; proxyt->listener = listener; proxyt->indicators = NULL; @@ -646,18 +656,102 @@ indicate_listener_display (IndicateListener * listener, IndicateListenerServer * return; } -void -indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_type_cb callback, gpointer data) +typedef struct { + IndicateListener * listener; + IndicateListenerServer * server; + indicate_listener_get_server_property_cb cb; + gpointer data; +} property_cb_t; + +static void +property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + property_cb_t * propertyt = data; + GError * error = NULL; + GValue property; + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &property, G_TYPE_INVALID); + if (error != NULL) { + g_warning("Unable to get property: %s", error->message); + g_error_free(error); + g_free(propertyt); + return; + } + if (!G_VALUE_HOLDS_STRING(&property)) { + g_warning("Property returned is not a string!"); + g_free(propertyt); + return; + } + + IndicateListener * listener = propertyt->listener; + IndicateListenerServer * server = propertyt->server; + indicate_listener_get_server_property_cb cb = propertyt->cb; + gpointer cb_data = propertyt->data; + + g_free(propertyt); + + gchar * propstr = g_value_dup_string(&property); + + return cb(listener, server, propstr, cb_data); } -void -indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_desktop_cb callback, gpointer data) +static void +get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, const gchar * property_name, gpointer data) { + IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); + + proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); + if (proxyt == NULL) { + g_warning("Looking for a property on an interface that hasn't be setup for indicators."); + // Send NULL to the callback + return; + } + + if (proxyt->property_proxy == NULL) { + DBusGConnection * bus; + gchar * bus_name; + if (proxyt->proxy == priv->dbus_proxy_system) { + bus = priv->system_bus; + bus_name = "system"; + } else { + bus = priv->session_bus; + bus_name = "session"; + } + + proxyt->property_proxy = dbus_g_proxy_new_for_name(bus, + proxyt->name, + "/org/freedesktop/indicate", + DBUS_INTERFACE_PROPERTIES); + } + property_cb_t * localdata = g_new(property_cb_t, 1); + localdata->listener = listener; + localdata->server = server; + localdata->cb = callback; + localdata->data = data; + dbus_g_proxy_begin_call (proxyt->property_proxy, + "Get", + property_cb, + localdata, + G_TYPE_STRING, "org.freedesktop.indicator", + G_TYPE_STRING, property_name, + G_TYPE_INVALID, G_TYPE_INVALID); + + return; +} + +void +indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data) +{ + return get_server_property(listener, server, callback, "type", data); +} + +void +indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data) +{ + return get_server_property(listener, server, callback, "desktop", data); } diff --git a/libindicate/listener.h b/libindicate/listener.h index 44855bd..95303e1 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -51,8 +51,7 @@ struct _IndicateListenerClass { GType indicate_listener_get_type (void) G_GNUC_CONST; typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data); -typedef void (*indicate_listener_get_type_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); -typedef void (*indicate_listener_get_desktop_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * desktop, gpointer data); +typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); /* Create a new listener */ IndicateListener * indicate_listener_new (void); @@ -67,11 +66,11 @@ void indicate_listener_display (IndicateListener * l IndicateListenerIndicator * indicator); void indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, - indicate_listener_get_type_cb callback, + indicate_listener_get_server_property_cb callback, gpointer data); void indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, - indicate_listener_get_desktop_cb callback, + indicate_listener_get_server_property_cb callback, gpointer data); -- cgit v1.2.3 From 3ca33fcc28d7f5b6abe7da934ce7d623e0f929aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 10 Feb 2009 16:52:21 -0600 Subject: Adding to the convience functions for setting the desktop file and the type of the server. --- libindicate/server.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libindicate/server.c b/libindicate/server.c index 0b46b0a..4da934f 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -372,20 +372,27 @@ void indicate_server_set_dbus_object (const gchar * obj) { /* TODO */ + return; } void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path) { - /* TODO */ + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, path); + g_object_set_property(G_OBJECT(server), "desktop", &value); return; } void indicate_server_set_type (IndicateServer * server, const gchar * type) { - /* TODO */ + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, type); + g_object_set_property(G_OBJECT(server), "type", &value); return; } -- cgit v1.2.3 From 584e64c3eb0be0b2c8734ebfea7c4d2087d029db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 16:30:59 -0600 Subject: Adding in a ref-default function so that we can keep one listener around for fun and profit. --- libindicate/listener.c | 18 ++++++++++++++++++ libindicate/listener.h | 1 + 2 files changed, 19 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index efd69fc..5ac03b9 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -243,11 +243,29 @@ indicate_listener_finalize (GObject * obj) IndicateListener * indicate_listener_new (void) { + g_warning("Creating a new listener is general discouraged, please use indicate_listener_ref_default"); + IndicateListener * listener; listener = g_object_new(INDICATE_TYPE_LISTENER, NULL); return listener; } +static IndicateListener * default_indicate_listener = NULL; + +IndicateListener * +indicate_listener_ref_default (void) +{ + if (default_indicate_listener != NULL) { + g_object_ref(default_indicate_listener); + } else { + default_indicate_listener = g_object_new(INDICATE_TYPE_LISTENER, NULL); + g_object_add_weak_pointer(G_OBJECT(default_indicate_listener), + (gpointer *)&default_indicate_listener); + } + + return default_indicate_listener; +} + static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener) { diff --git a/libindicate/listener.h b/libindicate/listener.h index 9ecdfc6..3d8c7ef 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -83,6 +83,7 @@ typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * lis /* Create a new listener */ IndicateListener * indicate_listener_new (void); +IndicateListener * indicate_listener_ref_default (void); void indicate_listener_get_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, -- cgit v1.2.3 From 5feca662d7e9abe470154aeb0f1ce74de1346d32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 17:04:10 -0600 Subject: Adding a check for type in the middle of the state machine for building a server. --- libindicate/listener.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 5ac03b9..61b35d6 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -91,6 +91,7 @@ static void proxy_struct_destroy (gpointer data); static void build_todo_list_cb (DBusGProxy * proxy, char ** names, GError * error, void * data); static void todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener); static gboolean todo_idle (gpointer data); +void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt); static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); static void proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); @@ -450,13 +451,30 @@ todo_idle (gpointer data) dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow", G_CALLBACK(proxy_server_added), proxyt, NULL); - org_freedesktop_indicator_get_indicator_list_async(proxyt->proxy, proxy_get_indicator_list, proxyt); + indicate_listener_server_get_type(listener, (IndicateListenerServer *)proxyt->name, get_type_cb, proxyt); g_hash_table_insert(priv->proxies_possible, proxyt->name, proxyt); return TRUE; } +void +get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) +{ + if (type == NULL) { + /* This is usually caused by an error getting the type, + * which would mean that this isn't an indicator server */ + return; + } + + proxy_t * proxyt = (proxy_t *)data; + + proxy_server_added (proxyt->proxy, type, proxyt); + org_freedesktop_indicator_get_indicator_list_async(proxyt->proxy, proxy_get_indicator_list, proxyt); + + return; +} + typedef struct { guint id; proxy_t * proxyt; @@ -524,10 +542,12 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt) dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified", G_CALLBACK(proxy_indicator_modified), proxyt, NULL); - if (proxyt->type != NULL) { - g_free(proxyt->type); + if (type != NULL) { + if (proxyt->type != NULL) { + g_free(proxyt->type); + } + proxyt->type = g_strdup(type); } - proxyt->type = g_strdup(type); g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, proxyt->name, proxyt->type, TRUE); } @@ -539,7 +559,7 @@ static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt) { if (proxyt->indicators == NULL) { - proxy_server_added (proxy, type, proxyt); + proxy_server_added (proxy, NULL, proxyt); } GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type); -- cgit v1.2.3 From 69bec2a8b6dedf0a6e7ee7bd96ff82a26774ef42 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 17:14:02 -0600 Subject: Removing an annoying warning --- libindicate/listener.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 61b35d6..797ca75 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -771,8 +771,6 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); if (proxyt == NULL) { - g_warning("Looking for a property on an interface that hasn't be setup for indicators."); - // Send NULL to the callback return; } -- cgit v1.2.3 From 609f0c83c117d38da4f4bb1f250f6624d3cbf9c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:10:33 -0600 Subject: Fixing the call, checking both lists of proxies, and adding some debug info. --- docs/reference/libindicate-decl.txt | 27 ++++++++++++++++++++++++++- libindicate/listener.c | 14 ++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/reference/libindicate-decl.txt b/docs/reference/libindicate-decl.txt index fce431d..7143c16 100644 --- a/docs/reference/libindicate-decl.txt +++ b/docs/reference/libindicate-decl.txt @@ -231,12 +231,22 @@ void void IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data + +indicate_listener_get_server_property_cb +void +IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data + indicate_listener_new IndicateListener * void +indicate_listener_ref_default +IndicateListener * +void + + indicate_listener_get_property void IndicateListener * listener,IndicateListenerServer * server,IndicateListenerIndicator * indicator,gchar * property,indicate_listener_get_property_cb callback,gpointer data @@ -246,6 +256,16 @@ IndicateListener * listener,IndicateListenerServer * server,IndicateListenerIndi void IndicateListener * listener,IndicateListenerServer * server,IndicateListenerIndicator * indicator + +indicate_listener_server_get_type +void +IndicateListener * listener,IndicateListenerServer * server,indicate_listener_get_server_property_cb callback,gpointer data + + +indicate_listener_server_get_desktop +void +IndicateListener * listener,IndicateListenerServer * server,indicate_listener_get_server_property_cb callback,gpointer data + INDICATE_TYPE_SERVER #define INDICATE_TYPE_SERVER (indicate_server_get_type ()) @@ -326,7 +346,12 @@ const gchar * obj indicate_server_set_desktop_file void -const gchar * path +IndicateServer * server, const gchar * path + + +indicate_server_set_type +void +IndicateServer * server, const gchar * type indicate_server_show diff --git a/libindicate/listener.c b/libindicate/listener.c index 797ca75..7775c57 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -732,6 +732,7 @@ typedef struct { static void property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + g_debug("Callback for property"); property_cb_t * propertyt = data; GError * error = NULL; @@ -760,15 +761,22 @@ property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) gchar * propstr = g_value_dup_string(&property); + g_debug("\tProperty value: %s", propstr); + return cb(listener, server, propstr, cb_data); } static void get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, const gchar * property_name, gpointer data) { + g_debug("Setting up callback for property: %s", property_name); + IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); - proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); + proxy_t * proxyt = g_hash_table_lookup(priv->proxies_possible, server); + if (proxyt == NULL) { + proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); + } if (proxyt == NULL) { return; @@ -785,6 +793,7 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve bus_name = "session"; } + g_debug("Createing property proxy on %s bus", bus_name); proxyt->property_proxy = dbus_g_proxy_new_for_name(bus, proxyt->name, "/org/freedesktop/indicate", @@ -801,9 +810,10 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve "Get", property_cb, localdata, + NULL, G_TYPE_STRING, "org.freedesktop.indicator", G_TYPE_STRING, property_name, - G_TYPE_INVALID, G_TYPE_INVALID); + G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); return; } -- cgit v1.2.3 From ef78255f9432f0498b589e7c3cb5c9fe20a8b44f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:22:25 -0600 Subject: Basically things are working as the proxyts are now findable. --- libindicate/listener.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 7775c57..1041fb0 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -244,7 +244,7 @@ indicate_listener_finalize (GObject * obj) IndicateListener * indicate_listener_new (void) { - g_warning("Creating a new listener is general discouraged, please use indicate_listener_ref_default"); + g_warning("Creating a new listener is generally discouraged, please use indicate_listener_ref_default"); IndicateListener * listener; listener = g_object_new(INDICATE_TYPE_LISTENER, NULL); @@ -451,10 +451,10 @@ todo_idle (gpointer data) dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow", G_CALLBACK(proxy_server_added), proxyt, NULL); - indicate_listener_server_get_type(listener, (IndicateListenerServer *)proxyt->name, get_type_cb, proxyt); - g_hash_table_insert(priv->proxies_possible, proxyt->name, proxyt); + indicate_listener_server_get_type(listener, (IndicateListenerServer *)proxyt->name, get_type_cb, proxyt); + return TRUE; } @@ -732,15 +732,15 @@ typedef struct { static void property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { - g_debug("Callback for property"); + g_debug("Callback for property %s %s %s", dbus_g_proxy_get_bus_name(proxy), dbus_g_proxy_get_path(proxy), dbus_g_proxy_get_interface(proxy)); property_cb_t * propertyt = data; GError * error = NULL; - GValue property; + GValue property = {0}; dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &property, G_TYPE_INVALID); if (error != NULL) { - g_warning("Unable to get property: %s", error->message); + /* g_warning("Unable to get property: %s", error->message); */ g_error_free(error); g_free(propertyt); return; -- cgit v1.2.3 From 2c02884c93f550c7df6e217c7853ab217c82eccc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:25:44 -0600 Subject: Turning off some debugging, reformatting, and putting the connection into the proxy_t structure --- libindicate/listener.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 1041fb0..e6a8aa6 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -71,6 +71,7 @@ struct _IndicateListenerPrivate typedef struct { DBusGProxy * proxy; DBusGProxy * property_proxy; + DBusGConnection * connection; gchar * name; gchar * type; IndicateListener * listener; @@ -438,6 +439,7 @@ todo_idle (gpointer data) proxyt->property_proxy = NULL; proxyt->listener = listener; proxyt->indicators = NULL; + proxyt->connection = todo->bus; priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1); @@ -732,7 +734,7 @@ typedef struct { static void property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { - g_debug("Callback for property %s %s %s", dbus_g_proxy_get_bus_name(proxy), dbus_g_proxy_get_path(proxy), dbus_g_proxy_get_interface(proxy)); + /* g_debug("Callback for property %s %s %s", dbus_g_proxy_get_bus_name(proxy), dbus_g_proxy_get_path(proxy), dbus_g_proxy_get_interface(proxy)); */ property_cb_t * propertyt = data; GError * error = NULL; @@ -761,7 +763,7 @@ property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) gchar * propstr = g_value_dup_string(&property); - g_debug("\tProperty value: %s", propstr); + /* g_debug("\tProperty value: %s", propstr); */ return cb(listener, server, propstr, cb_data); } @@ -769,8 +771,7 @@ property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) static void get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, const gchar * property_name, gpointer data) { - g_debug("Setting up callback for property: %s", property_name); - + /* g_debug("Setting up callback for property: %s", property_name); */ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); proxy_t * proxyt = g_hash_table_lookup(priv->proxies_possible, server); @@ -783,18 +784,7 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve } if (proxyt->property_proxy == NULL) { - DBusGConnection * bus; - gchar * bus_name; - if (proxyt->proxy == priv->dbus_proxy_system) { - bus = priv->system_bus; - bus_name = "system"; - } else { - bus = priv->session_bus; - bus_name = "session"; - } - - g_debug("Createing property proxy on %s bus", bus_name); - proxyt->property_proxy = dbus_g_proxy_new_for_name(bus, + proxyt->property_proxy = dbus_g_proxy_new_for_name(proxyt->connection, proxyt->name, "/org/freedesktop/indicate", DBUS_INTERFACE_PROPERTIES); @@ -807,13 +797,13 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve localdata->data = data; dbus_g_proxy_begin_call (proxyt->property_proxy, - "Get", - property_cb, - localdata, - NULL, - G_TYPE_STRING, "org.freedesktop.indicator", - G_TYPE_STRING, property_name, - G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); + "Get", + property_cb, + localdata, + NULL, + G_TYPE_STRING, "org.freedesktop.indicator", + G_TYPE_STRING, property_name, + G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); return; } -- cgit v1.2.3 From 734c7ea36fffbc85042bbeccd476b8d2f7609e67 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:29:04 -0600 Subject: Fixing the deallocation to check the right parameters. --- libindicate/listener.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index e6a8aa6..4da6d59 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -341,10 +341,10 @@ proxy_struct_destroy (gpointer data) } if (proxy_data->property_proxy) { - g_object_unref(G_OBJECT(proxy_data->proxy)); + g_object_unref(G_OBJECT(proxy_data->property_proxy)); } - if (proxy_data->property_proxy) { + if (proxy_data->proxy) { g_object_unref(G_OBJECT(proxy_data->proxy)); } -- cgit v1.2.3 From 47decbd2ae092d72010d9adb343bd0fe2d87d8ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:30:21 -0600 Subject: Switching to ref_default --- tests/listen-and-print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c index 53c9778..6e1104d 100644 --- a/tests/listen-and-print.c +++ b/tests/listen-and-print.c @@ -57,7 +57,7 @@ main (int argc, char ** argv) { g_type_init(); - IndicateListener * listener = indicate_listener_new(); + IndicateListener * listener = indicate_listener_ref_default(); g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL); g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_CALLBACK(indicator_removed), NULL); -- cgit v1.2.3 From 2f2fdfe9a4e312dde374e000a02dd61e8a40c608 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 11 Feb 2009 20:31:43 -0600 Subject: Cleaning up some debug messages that aren't as useful anymore --- libindicate/indicator.c | 4 ++-- libindicate/server.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libindicate/indicator.c b/libindicate/indicator.c index 71ce030..c6df80a 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -67,7 +67,7 @@ static GPtrArray * list_properties (IndicateIndicator * indicator); static void indicate_indicator_class_init (IndicateIndicatorClass * class) { - g_debug("Indicator Class Initialized."); + /* g_debug("Indicator Class Initialized."); */ GObjectClass * gobj; gobj = G_OBJECT_CLASS(class); @@ -116,7 +116,7 @@ indicate_indicator_class_init (IndicateIndicatorClass * class) static void indicate_indicator_init (IndicateIndicator * indicator) { - g_debug("Indicator Object Initialized."); + /* g_debug("Indicator Object Initialized."); */ IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); priv->is_visible = FALSE; diff --git a/libindicate/server.c b/libindicate/server.c index a9849fe..0c74376 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -106,7 +106,7 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * static void indicate_server_class_init (IndicateServerClass * class) { - g_debug("Server Class Initialized"); + /* g_debug("Server Class Initialized"); */ GObjectClass * gobj; gobj = G_OBJECT_CLASS(class); @@ -182,7 +182,7 @@ indicate_server_class_init (IndicateServerClass * class) static void indicate_server_init (IndicateServer * server) { - g_debug("Server Object Initialized"); + /* g_debug("Server Object Initialized"); */ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); -- cgit v1.2.3