aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/indicate-interface.xml6
-rw-r--r--libindicate/interests.h6
-rw-r--r--libindicate/server.c70
-rw-r--r--libindicate/server.h10
4 files changed, 86 insertions, 6 deletions
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
<method name="ShowIndicatorToUser">
<arg type="u" name="id" direction="in" />
</method>
+ <method name="ShowInterest">
+ <arg type="s" name="interest" direction="in" />
+ </method>
+ <method name="RemoveInterest">
+ <arg type="s" name="interest" direction="in" />
+ </method>
<!-- Signals -->
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);