From b76642fa768fd6fb34abc2a02a8bdf548081add7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 14:49:02 -0500 Subject: Getting some interests in the game. --- libindicate/server.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 39753d2..ec5d957 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -28,6 +28,7 @@ License version 3 and version 2.1 along with this program. If not, see */ #include "server.h" +#include "interests-priv.h" #include "dbus-indicate-server.h" /* Errors */ -- cgit v1.2.3 From 58403a8f18f9463ed95446a1ae227fdb97441900 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 15:54:55 -0500 Subject: Adding new functions show_interest and remove_interest into the API. Now to fill in the backend. --- libindicate/server.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index ec5d957..bd7c4dd 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -43,6 +43,8 @@ enum { NO_GET_INDICATOR_PROPERTIES, NO_SHOW_INDICATOR_TO_USER, INVALID_INDICATOR_ID, + NO_SHOW_INTEREST, + NO_REMOVE_INTEREST, LAST_ERROR }; @@ -866,6 +868,74 @@ indicate_server_get_next_id (IndicateServer * server) return 0; } +static IndicateInterests +interest_string_to_enum (gchar * interest_string) +{ + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_DISPLAY)) { + return INDICATE_INTEREST_SERVER_DISPLAY; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_SIGNAL)) { + return INDICATE_INTEREST_SERVER_SIGNAL; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_DISPLAY)) { + return INDICATE_INTEREST_INDICATOR_DISPLAY; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_SIGNAL)) { + return INDICATE_INTEREST_INDICATOR_SIGNAL; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_COUNT)) { + return INDICATE_INTEREST_INDICATOR_COUNT; + } + + return INDICATE_INTEREST_NONE; +} + +gboolean +indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->show_interest (server, interest_string_to_enum(interest)); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_SHOW_INTEREST, + "show_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + return FALSE; + } + + return TRUE; +} + +gboolean +indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->remove_interest (server, interest_string_to_enum(interest)); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_REMOVE_INTEREST, + "remove_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + return FALSE; + } + + return TRUE; +} + /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type) -- cgit v1.2.3 From 6e51efbeaceab68fdf66e53c66afe7a94c82d7cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 10:49:35 -0500 Subject: Switching around the show_interest and remove_interest functions so that they are now asyncronous. Not that being asynchronous is important but more that now they get the Method Invocation interface that we can use to find out the sender of the message. Changed various APIs as a result of this, and moved the DBus functions to be internal. --- libindicate/server.c | 94 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 25 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index bd7c4dd..597bf74 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -29,7 +29,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "server.h" #include "interests-priv.h" -#include "dbus-indicate-server.h" +#include +#include /* Errors */ enum { @@ -45,6 +46,8 @@ enum { INVALID_INDICATOR_ID, NO_SHOW_INTEREST, NO_REMOVE_INTEREST, + SHOW_INTEREST_FAILED, + REMOVE_INTEREST_FAILED, LAST_ERROR }; @@ -106,6 +109,23 @@ static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +/* 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); +gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); +gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); +gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); +gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); +gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); + +/* Has to be after the dbus prototypes */ +#include "dbus-indicate-server.h" + + + /* Code */ static void indicate_server_class_init (IndicateServerClass * class) @@ -895,45 +915,69 @@ interest_string_to_enum (gchar * interest_string) } gboolean -indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error) +indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); if (class != NULL) { - return class->show_interest (server, interest_string_to_enum(interest)); - } - - if (error) { - g_set_error(error, - indicate_server_error_quark(), - NO_SHOW_INTEREST, - "show_interest function doesn't exist for this server class: %s", - G_OBJECT_TYPE_NAME(server)); - return FALSE; + if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ + dbus_g_method_return(method); + return TRUE; + } else { + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + SHOW_INTEREST_FAILED, + "Unable to show interest: %s", + interest); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; + } } - return TRUE; + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + NO_SHOW_INTEREST, + "show_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; } gboolean -indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error) +indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); if (class != NULL) { - return class->remove_interest (server, interest_string_to_enum(interest)); - } - - if (error) { - g_set_error(error, - indicate_server_error_quark(), - NO_REMOVE_INTEREST, - "remove_interest function doesn't exist for this server class: %s", - G_OBJECT_TYPE_NAME(server)); - return FALSE; + if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ + dbus_g_method_return(method); + return TRUE; + } else { + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + REMOVE_INTEREST_FAILED, + "Unable to remove interest: %s", + interest); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; + } } - return TRUE; + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + NO_REMOVE_INTEREST, + "remove_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; } /* Signal emission functions for sub-classes of the server */ -- cgit v1.2.3 From b87476878dde5c5eed23e474073922b65e5f2ff5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:05:35 -0500 Subject: I can't believe I messed up this one. Luckily it doesn't seem to have caused any bugs. Man. --- libindicate/server.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 597bf74..a907dea 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -713,7 +713,7 @@ indicate_server_get_indicator_count (IndicateServer * server, guint * count, GEr { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_count != NULL) { return class->get_indicator_count (server, count, error); } @@ -734,7 +734,7 @@ indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * ty { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_count_by_type != NULL) { return class->get_indicator_count_by_type (server, type, count, error); } @@ -755,7 +755,7 @@ indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicator { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_list != NULL) { return class->get_indicator_list (server, indicators, error); } @@ -776,7 +776,7 @@ indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * typ { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_list_by_type != NULL) { return class->get_indicator_list_by_type (server, type, indicators, error); } @@ -797,7 +797,7 @@ indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_property != NULL) { return class->get_indicator_property (server, id, property, value, error); } @@ -818,7 +818,7 @@ indicate_server_get_indicator_property_group (IndicateServer * server, guint id, { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_property_group != NULL) { return class->get_indicator_property_group (server, id, properties, value, error); } @@ -839,7 +839,7 @@ indicate_server_get_indicator_properties (IndicateServer * server, guint id, gch { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_properties != NULL) { return class->get_indicator_properties (server, id, properties, error); } @@ -860,7 +860,7 @@ indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GErro { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->show_indicator_to_user != NULL) { return class->show_indicator_to_user (server, id, error); } @@ -881,7 +881,7 @@ indicate_server_get_next_id (IndicateServer * server) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_next_id != NULL) { return class->get_next_id (server); } @@ -919,7 +919,7 @@ indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGM { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->show_interest != NULL) { if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ dbus_g_method_return(method); return TRUE; @@ -952,7 +952,7 @@ indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBus { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->remove_interest != NULL) { if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ dbus_g_method_return(method); return TRUE; -- cgit v1.2.3 From 5ebb3c4f87cf9965183c055d52193e656c59193b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:11:20 -0500 Subject: Woot! Now we have some real functions to call! --- libindicate/server.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index a907dea..e11a4a3 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -108,6 +108,9 @@ static gboolean show_indicator_to_user (IndicateServer * server, guint id, GErro static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); +static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); +static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -206,6 +209,9 @@ indicate_server_class_init (IndicateServerClass * class) class->get_indicator_properties = get_indicator_properties; class->show_indicator_to_user = show_indicator_to_user; class->get_next_id = get_next_id; + class->show_interest = show_interest; + class->remove_interest = remove_interest; + class->check_interest = check_interest; return; } @@ -362,6 +368,29 @@ get_next_id (IndicateServer * server) return priv->current_id; } +static gboolean +show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) +{ + + + return FALSE; +} + +static gboolean +remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) +{ + + return FALSE; +} + +static gboolean +check_interest (IndicateServer * server, IndicateInterests intrest) +{ + + + return FALSE; +} + static void indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server) { -- cgit v1.2.3 From 1212c8e00290669f251067fb22ccf7f16f4719df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:34:56 -0500 Subject: Adding the interest removed and interest added signals in. --- libindicate/server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index e11a4a3..e560ba8 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -59,6 +59,8 @@ enum { SERVER_SHOW, SERVER_HIDE, SERVER_DISPLAY, + INTEREST_ADDED, + INTEREST_REMOVED, LAST_SIGNAL }; @@ -185,6 +187,20 @@ indicate_server_class_init (IndicateServerClass * class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[INTEREST_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_ADDED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicateServerClass, interest_added), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); + signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicateServerClass, interest_removed), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); g_object_class_install_property (gobj, PROP_DESKTOP, g_param_spec_string("desktop", "Desktop File", -- cgit v1.2.3 From f94b485955374f9ef6c4cb8521f610711edf54ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 13:34:40 -0500 Subject: Adding in folks support. --- libindicate/server.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index e560ba8..3a8907c 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -88,11 +88,20 @@ struct _IndicateServerPrivate // TODO: Should have a more robust way to track this, but this'll work for now guint num_hidden; + + gboolean interests[INDICATE_INTEREST_LAST]; + GList * interestedfolks; }; #define INDICATE_SERVER_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_SERVER, IndicateServerPrivate)) +typedef struct _IndicateServerInterestedFolk IndicateServerInterestedFolk; +struct _IndicateServerInterestedFolk { + gchar * sender; + gboolean interests[INDICATE_INTEREST_LAST]; +}; + /* Define Type */ G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT); @@ -113,6 +122,10 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); +static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b); +static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk); +static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value); +static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -247,6 +260,13 @@ indicate_server_init (IndicateServer * server) priv->type = NULL; priv->desktop = NULL; + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + priv->interestedfolks = NULL; + + return; } @@ -1060,3 +1080,45 @@ indicate_server_emit_server_display (IndicateServer *server) g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE); } + +/* *** Folks stuff *** */ + +static gint +indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b) +{ + return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender); +} + +static void +indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk) +{ + folk->sender = NULL; + + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + folk->interests[i] = FALSE; + } + + return; +} + +static void +indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value) +{ + folk->interests[interest] = value; + return; +} + +static void +indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests) +{ + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (folk->interests[i]) { + interests[i] = TRUE; + } + } + + return; +} +/* *** End Folks *** */ -- cgit v1.2.3 From 6e4299654841510621000077ebd71423db03cde3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 14:08:55 -0500 Subject: Fleshing out the interest setting and removing functions. --- libindicate/server.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 3a8907c..a121984 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -407,24 +407,75 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + IndicateServerInterestedFolk localfolk; + localfolk.sender = sender; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); - return FALSE; + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); + IndicateServerInterestedFolk * folkpointer = NULL; + if (entry == NULL) { + folkpointer = g_new(IndicateServerInterestedFolk, 1); + indicate_server_interested_folks_init(folkpointer); + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); + } else { + folkpointer = (IndicateServerInterestedFolk *)entry->data; + } + + indicate_server_interested_folk_set(folkpointer, interest, TRUE); + if (!priv->interests[interest]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_ADDED], 0, interest, TRUE); + priv->interests[interest] = TRUE; + } + + return TRUE; } static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + IndicateServerInterestedFolk localfolk; + localfolk.sender = sender; - return FALSE; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); + IndicateServerInterestedFolk * folkpointer = NULL; + if (entry == NULL) { + folkpointer = g_new(IndicateServerInterestedFolk, 1); + indicate_server_interested_folks_init(folkpointer); + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); + } else { + folkpointer = (IndicateServerInterestedFolk *)entry->data; + } + + indicate_server_interested_folk_set(folkpointer, interest, FALSE); + + if (priv->interests[interest]) { + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + + GList * listi = NULL; + for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { + folkpointer = (IndicateServerInterestedFolk *)listi->data; + inkscape_server_interested_folk_copy(folkpointer, priv->interests); + } + + if (!priv->interests[interest]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, interest, TRUE); + } + } + + return TRUE; } static gboolean check_interest (IndicateServer * server, IndicateInterests intrest) { - - - return FALSE; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + return priv->interests[interest]; } static void -- cgit v1.2.3 From 26bfe1c6a952952d404130f783e7399cb28e496f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 15:23:10 -0500 Subject: Connecting in the DBus messaging that we need. --- libindicate/server.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index a121984..0dba9fa 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -78,6 +78,8 @@ typedef struct _IndicateServerPrivate IndicateServerPrivate; struct _IndicateServerPrivate { DBusGConnection *connection; + DBusGProxy * dbus_proxy; + gchar * path; GSList * indicators; gboolean visible; @@ -116,6 +118,7 @@ static gboolean get_indicator_property (IndicateServer * server, guint id, gchar static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server); static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); @@ -373,6 +376,17 @@ indicate_server_show (IndicateServer * server) priv->visible = TRUE; g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE); + + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + NULL); + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_owner_change), server, NULL); return; } @@ -388,14 +402,36 @@ indicate_server_hide (IndicateServer * server) priv->visible = FALSE; + /* Delete interested parties */ + g_list_foreach(priv->interestedfolks, (GFunc)g_free, NULL); + g_list_free(priv->interestedfolks); + priv->interestedfolks = NULL; + + /* Signal the lack of interest */ + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (priv->interests[i]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); + } + priv->interests[i] = FALSE; + } + g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE); + g_object_unref(G_OBJECT(priv->dbus_proxy)); dbus_g_connection_unref (priv->connection); priv->connection = NULL; return; } +static void +dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) +{ + + +} + static guint get_next_id (IndicateServer * server) { @@ -422,7 +458,7 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere folkpointer = (IndicateServerInterestedFolk *)entry->data; } - indicate_server_interested_folk_set(folkpointer, interest, TRUE); + indicate_server_interested_folks_set(folkpointer, interest, TRUE); if (!priv->interests[interest]) { g_signal_emit(G_OBJECT(server), signals[INTEREST_ADDED], 0, interest, TRUE); priv->interests[interest] = TRUE; @@ -449,7 +485,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte folkpointer = (IndicateServerInterestedFolk *)entry->data; } - indicate_server_interested_folk_set(folkpointer, interest, FALSE); + indicate_server_interested_folks_set(folkpointer, interest, FALSE); if (priv->interests[interest]) { guint i; @@ -460,7 +496,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { folkpointer = (IndicateServerInterestedFolk *)listi->data; - inkscape_server_interested_folk_copy(folkpointer, priv->interests); + indicate_server_interested_folks_copy(folkpointer, priv->interests); } if (!priv->interests[interest]) { @@ -472,7 +508,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte } static gboolean -check_interest (IndicateServer * server, IndicateInterests intrest) +check_interest (IndicateServer * server, IndicateInterests interest) { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); return priv->interests[interest]; -- cgit v1.2.3 From 682684874b40d4a18ae0ebec29e4d42c5184501e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:12:19 -0500 Subject: Filling in the dbus owner changing code. Now we should catch those. --- libindicate/server.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 0dba9fa..ca3257b 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -428,8 +428,46 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { + if (prev != NULL) { + /* We only care about people leaving the bus */ + return; + } + + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + + IndicateServerInterestedFolk searchitem; + searchitem.sender = (gchar *)name; + GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); + + if (entry == NULL) { + return; + } + IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data; + priv->interestedfolks = g_list_remove(priv->interestedfolks, entry); + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + + GList * listi = NULL; + for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { + IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; + indicate_server_interested_folks_copy(folkpointer, priv->interests); + } + + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (folk->interests[i] != priv->interests[i]) { + /* We can only remove interest here. Think about it for a + moment and I think you'll be cool with it. */ + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); + } + } + + g_free(folk); + + return; } static guint -- cgit v1.2.3 From 5c9e92e513666fcffea8841d5b5005953c7f7d37 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:35:38 -0500 Subject: Adding a bunch of debugging messages and fixing the lifecycle for the folk pointer. Lots'o'fun. But things seem to be working. --- libindicate/server.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index ca3257b..4346ae0 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -126,9 +126,10 @@ static gboolean show_interest (IndicateServer * server, gchar * sender, Indicate static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b); -static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk); +static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender); static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value); static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests); +static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -403,7 +404,7 @@ indicate_server_hide (IndicateServer * server) priv->visible = FALSE; /* Delete interested parties */ - g_list_foreach(priv->interestedfolks, (GFunc)g_free, NULL); + g_list_foreach(priv->interestedfolks, (GFunc)indicate_server_interested_folks_destroy, NULL); g_list_free(priv->interestedfolks); priv->interestedfolks = NULL; @@ -428,11 +429,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - if (prev != NULL) { + g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } + g_debug("\tBeing removed, interesting"); IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -440,11 +443,12 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { + g_debug("\tWe don't have it, not interesting"); return; } IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data; - priv->interestedfolks = g_list_remove(priv->interestedfolks, entry); + priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data); guint i; for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { @@ -454,13 +458,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; + g_debug("\tRebuild list from folk: %s", folkpointer->sender); indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); if (folk->interests[i] != priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ + g_debug("\tOh, and it was interested in %d. Not anymore.", i); g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } @@ -481,6 +488,7 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + g_debug("Someone is showing interest. %s in %d", sender, interest); IndicateServerInterestedFolk localfolk; localfolk.sender = sender; @@ -490,7 +498,7 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere IndicateServerInterestedFolk * folkpointer = NULL; if (entry == NULL) { folkpointer = g_new(IndicateServerInterestedFolk, 1); - indicate_server_interested_folks_init(folkpointer); + indicate_server_interested_folks_init(folkpointer, sender); priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); } else { folkpointer = (IndicateServerInterestedFolk *)entry->data; @@ -517,7 +525,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte IndicateServerInterestedFolk * folkpointer = NULL; if (entry == NULL) { folkpointer = g_new(IndicateServerInterestedFolk, 1); - indicate_server_interested_folks_init(folkpointer); + indicate_server_interested_folks_init(folkpointer, sender); priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); } else { folkpointer = (IndicateServerInterestedFolk *)entry->data; @@ -1215,9 +1223,9 @@ indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b) } static void -indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk) +indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender) { - folk->sender = NULL; + folk->sender = g_strdup(sender); guint i; for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { @@ -1246,4 +1254,12 @@ indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboo return; } + +static void +indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk) +{ + g_free(folk->sender); + g_free(folk); + return; +} /* *** End Folks *** */ -- cgit v1.2.3 From 2f66ceb474f6d42368873742c99100b8c4ef62d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:36:27 -0500 Subject: Hiding debug --- libindicate/server.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 4346ae0..4e47040 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -429,13 +429,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - g_debug("\tBeing removed, interesting"); + /* g_debug("\tBeing removed, interesting"); */ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -443,7 +443,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - g_debug("\tWe don't have it, not interesting"); + /* g_debug("\tWe don't have it, not interesting"); */ return; } @@ -458,16 +458,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - g_debug("\tRebuild list from folk: %s", folkpointer->sender); + /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ if (folk->interests[i] != priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - g_debug("\tOh, and it was interested in %d. Not anymore.", i); + /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } @@ -488,7 +488,7 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { - g_debug("Someone is showing interest. %s in %d", sender, interest); + /* g_debug("Someone is showing interest. %s in %d", sender, interest); */ IndicateServerInterestedFolk localfolk; localfolk.sender = sender; -- cgit v1.2.3 From 68fb067b6dc1a2153205ec8b210813a610d66d24 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:38:47 -0500 Subject: Putting in some protection from crazy values --- libindicate/server.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 4e47040..e6041de 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -488,6 +488,10 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) { + return FALSE; + } + /* g_debug("Someone is showing interest. %s in %d", sender, interest); */ IndicateServerInterestedFolk localfolk; localfolk.sender = sender; @@ -516,6 +520,10 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) { + return FALSE; + } + IndicateServerInterestedFolk localfolk; localfolk.sender = sender; -- cgit v1.2.3 From d93da3d5d79786e5402a8d70a30468e95e82d55b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 12:27:31 -0500 Subject: Hiding all of the functions that part of the DBus interface in that now they're all prefixed with '_' so that they don't get exported as part of the library symbols. This should simplify everything a little bit for implementors. --- libindicate/server.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index e6041de..004c386 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -132,16 +132,16 @@ static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk); /* 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); -gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); -gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); -gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); -gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); -gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); -gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); -gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +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); +gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); +gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); +gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); +gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); /* Has to be after the dbus prototypes */ #include "dbus-indicate-server.h" @@ -231,7 +231,7 @@ indicate_server_class_init (IndicateServerClass * class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); dbus_g_object_type_install_info(INDICATE_TYPE_SERVER, - &dbus_glib_indicate_server_object_info); + &dbus_glib__indicate_server_object_info); class->get_indicator_count = get_indicator_count; class->get_indicator_count_by_type = get_indicator_count_by_type; @@ -915,7 +915,7 @@ show_indicator_to_user (IndicateServer * server, guint id, GError ** error) /* Virtual Functions */ gboolean -indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error) +_indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -936,7 +936,7 @@ indicate_server_get_indicator_count (IndicateServer * server, guint * count, GEr } gboolean -indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) +_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -957,7 +957,7 @@ indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * ty } gboolean -indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) +_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -978,7 +978,7 @@ indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicator } gboolean -indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -999,7 +999,7 @@ indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * typ } gboolean -indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) +_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1020,7 +1020,7 @@ indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar } gboolean -indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error) +_indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1041,7 +1041,7 @@ indicate_server_get_indicator_property_group (IndicateServer * server, guint id, } gboolean -indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) +_indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1062,7 +1062,7 @@ indicate_server_get_indicator_properties (IndicateServer * server, guint id, gch } gboolean -indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error) +_indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1121,7 +1121,7 @@ interest_string_to_enum (gchar * interest_string) } gboolean -indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) +_indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1154,7 +1154,7 @@ indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGM } gboolean -indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) +_indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); -- cgit v1.2.3 From 42492db6a41dc304820d744470f86644765b0aa9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Apr 2009 21:42:16 -0500 Subject: * Some debug messages * Making the comparison of interests detect changings properly * Correctly use g_list_remove in several cases making for long lists * Using g_list_prepend instead of append because it's faster. * Checking whether we've got proxies before destroying them. --- libindicate/server.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 004c386..520d47c 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -419,9 +419,15 @@ indicate_server_hide (IndicateServer * server) g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE); - g_object_unref(G_OBJECT(priv->dbus_proxy)); - dbus_g_connection_unref (priv->connection); - priv->connection = NULL; + if (priv->dbus_proxy != NULL) { + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } + + if (priv->connection != NULL) { + dbus_g_connection_unref (priv->connection); + priv->connection = NULL; + } return; } @@ -429,13 +435,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ + g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - /* g_debug("\tBeing removed, interesting"); */ + g_debug("\tBeing removed, interesting"); IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -443,7 +449,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - /* g_debug("\tWe don't have it, not interesting"); */ + g_debug("\tWe don't have it, not interesting"); return; } @@ -458,16 +464,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ + g_debug("\tRebuild list from folk: %s", folkpointer->sender); indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ - if (folk->interests[i] != priv->interests[i]) { + g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + if (folk->interests[i] && !priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ + g_debug("\tOh, and it was interested in %d. Not anymore.", i); g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } -- cgit v1.2.3 From 912a2a1a79b9c5eaa3442a7945d8f9390dd2d522 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 10:15:39 -0500 Subject: Hiding some debugging messages. --- libindicate/server.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 520d47c..ed81d54 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -435,13 +435,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - g_debug("\tBeing removed, interesting"); + /* g_debug("\tBeing removed, interesting"); */ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -449,7 +449,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - g_debug("\tWe don't have it, not interesting"); + /* g_debug("\tWe don't have it, not interesting"); */ return; } @@ -464,16 +464,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - g_debug("\tRebuild list from folk: %s", folkpointer->sender); + /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ if (folk->interests[i] && !priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - g_debug("\tOh, and it was interested in %d. Not anymore.", i); + /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } -- cgit v1.2.3 From 3e1e51261167c74fa81819cebaafce944e14b310 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 17:40:25 -0500 Subject: Making it so that we don't register the object twice. This is really a work around, but it's atleast fixes the crasher. Which sucked. We need to work with the dbus folks to make this better. --- libindicate/server.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index ed81d54..1be8ee5 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -84,6 +84,7 @@ struct _IndicateServerPrivate GSList * indicators; gboolean visible; guint current_id; + gboolean registered; gchar * desktop; gchar * type; @@ -260,6 +261,7 @@ indicate_server_init (IndicateServer * server) priv->indicators = NULL; priv->num_hidden = 0; priv->visible = FALSE; + priv->registered = FALSE; priv->current_id = 0; priv->type = NULL; priv->desktop = NULL; @@ -371,9 +373,13 @@ indicate_server_show (IndicateServer * server) priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(priv->connection, - priv->path, - G_OBJECT(server)); + if (!priv->registered) { + dbus_g_connection_register_g_object(priv->connection, + priv->path, + G_OBJECT(server)); + priv->registered = TRUE; + } + priv->visible = TRUE; g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE); -- cgit v1.2.3 From eba8697a790029397d771a3871f431abc4fc0029 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 20:52:05 -0500 Subject: Patch from Eitan Isaacson to remove a ref/unref infinite loop that effectively made it so that we kept our objects forever. While we love them, at some point we need to say goodbye. --- libindicate/server.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index 1be8ee5..e5bf731 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -610,8 +610,10 @@ indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indi { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); - g_object_ref(indicator); - priv->indicators = g_slist_prepend(priv->indicators, indicator); + if (g_slist_find (priv->indicators, indicator) != NULL) + return; + + priv->indicators = g_slist_prepend(priv->indicators, indicator); if (!indicate_indicator_is_visible(indicator)) { priv->num_hidden++; @@ -631,6 +633,9 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + if (g_slist_find (priv->indicators, indicator) == NULL) + return; + priv->indicators = g_slist_remove(priv->indicators, indicator); if (indicate_indicator_is_visible(indicator)) { g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); @@ -642,7 +647,6 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server); g_signal_handlers_disconnect_by_func(indicator, indicator_modified_cb, server); - g_object_unref(indicator); return; } -- cgit v1.2.3 From 9a7bcf39b419f9ac30eb44c14e5f7f17a34cc15b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:08:27 -0500 Subject: Patch from Eitan Isaacson to correct prototype. Had to be adjusted slightly as the prototypes had moved. --- libindicate/server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/server.c b/libindicate/server.c index e5bf731..9e33516 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -114,7 +114,7 @@ static void indicate_server_finalize (GObject * obj); static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error); static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -136,7 +136,7 @@ static void indicate_server_interested_folks_destroy(IndicateServerInterestedFol 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); gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -798,7 +798,7 @@ get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** err } static gboolean -get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); @@ -994,7 +994,7 @@ _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicato } gboolean -_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); -- cgit v1.2.3