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/indicate-interface.xml | 6 ++++ libindicate/interests.h | 6 ++-- libindicate/server.c | 70 ++++++++++++++++++++++++++++++++++++++ libindicate/server.h | 10 ++++-- 4 files changed, 86 insertions(+), 6 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml index 102df12..9a58f74 100644 --- a/libindicate/indicate-interface.xml +++ b/libindicate/indicate-interface.xml @@ -66,6 +66,12 @@ License version 3 and version 2.1 along with this program. If not, see + + + + + + diff --git a/libindicate/interests.h b/libindicate/interests.h index 1543075..5733199 100644 --- a/libindicate/interests.h +++ b/libindicate/interests.h @@ -34,9 +34,9 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -typedef enum _IndicateServerInterests IndicateServerInterests; -enum _IndicateServerInterests { - INDICATE_INTEREST_END, /**< Finishes a list of interests */ +typedef enum _IndicateInterests IndicateInterests; +enum _IndicateInterests { + INDICATE_INTEREST_NONE, /**< We're of no interest */ INDICATE_INTEREST_SERVER_DISPLAY, /**< Displays the server's existance to the user */ INDICATE_INTEREST_SERVER_SIGNAL, /**< Will send signals to the server to be displayed */ INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */ 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) diff --git a/libindicate/server.h b/libindicate/server.h index 969e280..4d6bbc5 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -73,8 +73,8 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); - void (* interest_added) (IndicateServer * server, IndicateServerInterests interest); - void (* interest_removed) (IndicateServer * server, IndicateServerInterests interest); + void (* interest_added) (IndicateServer * server, IndicateInterests interest); + void (* interest_removed) (IndicateServer * server, IndicateInterests interest); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -86,6 +86,8 @@ struct _IndicateServerClass { gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); guint (*get_next_id) (IndicateServer * server); + gboolean (*show_interest) (IndicateServer * server, IndicateInterests interest); + gboolean (*remove_interest) (IndicateServer * server, IndicateInterests interest); /* Reserver for future use */ void (*indicate_server_reserved1)(void); @@ -122,7 +124,7 @@ IndicateServer * indicate_server_ref_default (void); void indicate_server_set_default (IndicateServer * server); /* Check to see if there is someone, out there, who likes this */ -gboolean indicate_server_check_interest (IndicateServer * server, IndicateServerInterests interest); +gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); /* DBus API */ @@ -134,6 +136,8 @@ gboolean indicate_server_get_indicator_property (IndicateServer * server, guint 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, GError ** error); +gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error); /* 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/indicate-interface.xml | 2 + libindicate/server.c | 94 ++++++++++++++++++++++++++++---------- libindicate/server.h | 17 ++----- 3 files changed, 74 insertions(+), 39 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml index 9a58f74..900b336 100644 --- a/libindicate/indicate-interface.xml +++ b/libindicate/indicate-interface.xml @@ -67,9 +67,11 @@ License version 3 and version 2.1 along with this program. If not, see + + 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 */ diff --git a/libindicate/server.h b/libindicate/server.h index 4d6bbc5..0db5bef 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -86,8 +86,9 @@ struct _IndicateServerClass { gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); guint (*get_next_id) (IndicateServer * server); - gboolean (*show_interest) (IndicateServer * server, IndicateInterests interest); - gboolean (*remove_interest) (IndicateServer * server, IndicateInterests interest); + gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); + gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); + gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest); /* Reserver for future use */ void (*indicate_server_reserved1)(void); @@ -127,18 +128,6 @@ void indicate_server_set_default (IndicateServer * server); gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); -/* 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, GError ** error); -gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error); - /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type); void indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type); -- 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/interests.h | 2 +- libindicate/server.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'libindicate/server.c') diff --git a/libindicate/interests.h b/libindicate/interests.h index 5733199..70c52d9 100644 --- a/libindicate/interests.h +++ b/libindicate/interests.h @@ -42,7 +42,7 @@ enum _IndicateInterests { INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */ INDICATE_INTEREST_INDICATOR_SIGNAL, /**< Will return signals based on individual indicators being responded to */ INDICATE_INTEREST_INDICATOR_COUNT, /**< Only displays a count of the indicators */ - INDICATE_INTEREST_INDICATOR_LAST /**< Makes merges and counting easier */ + INDICATE_INTEREST_LAST /**< Makes merges and counting easier */ }; G_END_DECLS 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/Makefile.am | 8 ++++---- libindicate/listener.c | 9 +++++++-- libindicate/listener.h | 1 - libindicate/server.c | 42 +++++++++++++++++++++--------------------- 4 files changed, 32 insertions(+), 28 deletions(-) (limited to 'libindicate/server.c') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index e594649..c1900a6 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -58,28 +58,28 @@ libindicate_la_LIBADD = \ dbus-indicate-server.h: indicate-interface.xml dbus-binding-tool \ - --prefix=indicate_server \ + --prefix=_indicate_server \ --mode=glib-server \ --output=dbus-indicate-server.h \ $(srcdir)/indicate-interface.xml dbus-indicate-client.h: indicate-interface.xml dbus-binding-tool \ - --prefix=indicate_client \ + --prefix=_indicate_client \ --mode=glib-client \ --output=dbus-indicate-client.h \ $(srcdir)/indicate-interface.xml dbus-listener-server.h: indicate-listener.xml dbus-binding-tool \ - --prefix=indicate_listener \ + --prefix=_indicate_listener \ --mode=glib-server \ --output=dbus-listener-server.h \ $(srcdir)/indicate-listener.xml dbus-listener-client.h: indicate-listener.xml dbus-binding-tool \ - --prefix=indicate_listener \ + --prefix=_indicate_listener \ --mode=glib-client \ --output=dbus-listener-client.h \ $(srcdir)/indicate-listener.xml diff --git a/libindicate/listener.c b/libindicate/listener.c index 92cb2da..0796bf1 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -32,7 +32,6 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "dbus-indicate-client.h" #include "dbus-listener-client.h" -#include "dbus-listener-server.h" /* Errors */ enum { @@ -130,6 +129,12 @@ static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, G static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data); static void proxy_indicators_free (gpointer data); +/* DBus interface */ +gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); + +/* Need the above prototypes */ +#include "dbus-listener-server.h" + /* Code */ static void indicate_listener_class_init (IndicateListenerClass * class) @@ -824,7 +829,7 @@ indicate_listener_get_property_icon (IndicateListener * listener, IndicateListen } gboolean -indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers) +_indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers) { diff --git a/libindicate/listener.h b/libindicate/listener.h index f9bb6bb..3b05f86 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -110,7 +110,6 @@ void indicate_listener_get_property_icon (IndicateListener * l void indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator); -gboolean indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); void indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, 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