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.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libindicate/server.h') diff --git a/libindicate/server.h b/libindicate/server.h index 8aa0cf1..d5ba9a6 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "indicator.h" +#include "interests.h" G_BEGIN_DECLS @@ -53,7 +54,7 @@ G_BEGIN_DECLS #define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" #define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" - +#define INDICATE_SERVER_SIGNAL_LISTENER_INTERESTED "listener-interested" typedef struct _IndicateServer IndicateServer; struct _IndicateServer { @@ -71,6 +72,7 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); + void (* listener_interested) (IndicateServer * server, IndicateServerInterests * interests); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -82,6 +84,12 @@ 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); + + /* Reserver for future use */ + void (*indicate_server_reserved1)(void); + void (*indicate_server_reserved2)(void); + void (*indicate_server_reserved3)(void); + void (*indicate_server_reserved4)(void); }; GType indicate_server_get_type (void) G_GNUC_CONST; -- cgit v1.2.3 From bae37d985580c258a0244a0a43bd634e2ecb5dd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 15:23:31 -0500 Subject: Change the API so it's more like we're keeping a list of what, and who are interested in. This'll make it easier for us to manage all the DBus nastyness. --- libindicate/server.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libindicate/server.h') diff --git a/libindicate/server.h b/libindicate/server.h index d5ba9a6..969e280 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -54,7 +54,8 @@ G_BEGIN_DECLS #define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" #define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" -#define INDICATE_SERVER_SIGNAL_LISTENER_INTERESTED "listener-interested" +#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added" +#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed" typedef struct _IndicateServer IndicateServer; struct _IndicateServer { @@ -72,7 +73,8 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); - void (* listener_interested) (IndicateServer * server, IndicateServerInterests * interests); + void (* interest_added) (IndicateServer * server, IndicateServerInterests interest); + void (* interest_removed) (IndicateServer * server, IndicateServerInterests interest); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -119,6 +121,9 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato 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); + /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); -- 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.h') 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.h') 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 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 ++++---- libindicate/server.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libindicate/server.h') 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); diff --git a/libindicate/server.h b/libindicate/server.h index 0db5bef..cfb4334 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -80,7 +80,7 @@ struct _IndicateServerClass { gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error); gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error); - gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); + gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); -- cgit v1.2.3