diff options
author | Ted Gould <ted@canonical.com> | 2009-01-08 15:35:35 -0600 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-01-08 15:35:35 -0600 |
commit | 7e75808fd0afe3dda6aa813ccf9fdb82cab11466 (patch) | |
tree | 4383e2d0e3803bf412fdfc8b05102e6ded61723b | |
parent | e2a3557771a519d9405ccd92a58a0b6ec82624ce (diff) | |
download | libayatana-indicator-7e75808fd0afe3dda6aa813ccf9fdb82cab11466.tar.gz libayatana-indicator-7e75808fd0afe3dda6aa813ccf9fdb82cab11466.tar.bz2 libayatana-indicator-7e75808fd0afe3dda6aa813ccf9fdb82cab11466.zip |
Building a pretty good set of virtual functions and getting them tied together, with errors too.
-rw-r--r-- | libindicate/server.c | 205 | ||||
-rw-r--r-- | libindicate/server.h | 9 |
2 files changed, 214 insertions, 0 deletions
diff --git a/libindicate/server.c b/libindicate/server.c index 0a0eab1..271a335 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -2,6 +2,19 @@ #include "server.h" #include "dbus-indicate-server.h" +/* Errors */ +enum { + NO_GET_DESKTOP, + NO_GET_INDICATOR_COUNT, + NO_GET_INDICATOR_COUNT_BY_TYPE, + NO_GET_INDICATOR_LIST, + NO_GET_INDICATOR_LIST_BY_TYPE, + NO_GET_INDICATOR_PROPERTY, + NO_GET_INDICATOR_PROPERTY_GROUP, + NO_GET_INDICATOR_PROPERTIES, + NO_SHOW_INDICATOR_TO_USER, + LAST_ERROR +}; /* Signals */ enum { @@ -46,3 +59,195 @@ indicate_server_finalize (GObject * obj) return; } + +static GQuark +indicate_server_error_quark (void) +{ + static GQuark quark = 0; + if (quark == 0) { + quark = g_quark_from_static_string (G_LOG_DOMAIN); + } + return quark; +} + +/* Virtual Functions */ +gboolean +indicate_server_get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_desktop (server, desktop_path, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_DESKTOP, + "get_desktop function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_count (server, count, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_COUNT, + "get_indicator_count function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_count_by_type (server, type, count, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_COUNT_BY_TYPE, + "get_indicator_count_by_type function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_list (IndicateServer * server, guint ** indicators, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_list (server, indicators, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_LIST, + "get_indicator_list function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_list_by_type (server, type, indicators, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_LIST_BY_TYPE, + "get_indicator_list_by_type function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_property (server, id, property, value, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_PROPERTY, + "get_indicator_property function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_property_group (IndicateServer * server, guint id, gchar ** properties, gchar *** value, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_property_group (server, id, properties, value, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_PROPERTY_GROUP, + "get_indicator_property_group function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->get_indicator_properties (server, id, properties, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_GET_INDICATOR_PROPERTIES, + "get_indicator_properties function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + +gboolean +indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->show_indicator_to_user (server, id, error); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_SHOW_INDICATOR_TO_USER, + "show_indicator_to_user function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + } + + return TRUE; +} + diff --git a/libindicate/server.h b/libindicate/server.h index 79a314b..28529dd 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -23,6 +23,15 @@ typedef struct _IndicateServerClass IndicateServerClass; struct _IndicateServerClass { GObjectClass parent; + gboolean (*get_desktop) (IndicateServer * server, gchar ** desktop_path, GError **error); + 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, guint ** indicators, GError ** error); + gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, guint ** 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, gchar ** properties, gchar *** value, GError **error); + gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); + gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); }; /* Create a new server */ |