diff options
author | Ted Gould <ted@canonical.com> | 2009-04-01 15:54:55 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-04-01 15:54:55 -0500 |
commit | 58403a8f18f9463ed95446a1ae227fdb97441900 (patch) | |
tree | 5a55a281d9fa0b2a4ee6c1cab2c481c56d96ebff /libindicate/server.c | |
parent | 966a1e53a3544b748d25a4679a8d085bcd916cbd (diff) | |
download | libayatana-indicator-58403a8f18f9463ed95446a1ae227fdb97441900.tar.gz libayatana-indicator-58403a8f18f9463ed95446a1ae227fdb97441900.tar.bz2 libayatana-indicator-58403a8f18f9463ed95446a1ae227fdb97441900.zip |
Adding new functions show_interest and remove_interest into the API. Now to fill in the backend.
Diffstat (limited to 'libindicate/server.c')
-rw-r--r-- | libindicate/server.c | 70 |
1 files changed, 70 insertions, 0 deletions
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) |