diff options
Diffstat (limited to 'libindicate')
-rw-r--r-- | libindicate/server.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/libindicate/server.c b/libindicate/server.c index 01e9e35..41b8d56 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -365,10 +365,38 @@ get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indi return TRUE; } +static IndicateIndicator * +get_indicator (IndicateServer * server, guint id, GError **error) +{ + g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); + + GSList * iter; + for (iter = server->indicators; iter != NULL; iter = iter->next) { + IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data); + if (indicate_indicator_get_id(indicator) == id) { + return indicator; + } + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + INVALID_INDICATOR_ID, + "Invalid Indicator ID: %d", + id); + } + return NULL; +} + static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) { + IndicateIndicator * indicator = get_indicator(server, id, error); + if (indicator == NULL) { + return FALSE; + } + *value = indicate_indicator_get_property(indicator, property); return TRUE; } @@ -376,38 +404,24 @@ static gboolean get_indicator_property_group (IndicateServer * server, guint id, gchar ** properties, gchar *** value, GError **error) { - return TRUE; } static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) { - return TRUE; } static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error) { - g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); - - GSList * iter; - for (iter = server->indicators; iter != NULL; iter = iter->next) { - IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data); - if (indicate_indicator_get_id(indicator) == id) { - indicate_indicator_user_display(indicator); - return TRUE; - } + IndicateIndicator * indicator = get_indicator(server, id, error); + if (indicator == NULL) { + return FALSE; } - if (error) { - g_set_error(error, - indicate_server_error_quark(), - INVALID_INDICATOR_ID, - "show_indicator_id can't be done on and invalid ID: %d", - id); - } - return FALSE; + indicate_indicator_user_display(indicator); + return TRUE; } |