From 45fede4d562c636dd6ea2a8625ca7495381a434b Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Sat, 3 Jul 2004 19:35:55 +0000 Subject: [PATCH] Added support for GetCapabilities. --- ChangeLog | 6 ++++++ libnotify/notify.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ libnotify/notify.h | 9 +++++++++ 3 files changed, 64 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1a5bb96..a9e41f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jul 03 12:35:35 PDT 2004 Christian Hammond + + * libnotify/notify.c: + * libnotify/notify.h: + - Added support for GetCapabilities. + Sat Jul 03 12:27:58 PDT 2004 Christian Hammond * libnotify/notify.c: diff --git a/libnotify/notify.c b/libnotify/notify.c index 0609581..847f97e 100644 --- a/libnotify/notify.c +++ b/libnotify/notify.c @@ -457,6 +457,8 @@ notify_get_server_info(char **ret_name, char **ret_vendor, char **ret_version) version = dbus_message_iter_get_string(&iter); dbus_message_iter_next(&iter); + dbus_message_unref(reply); + if (ret_name != NULL) *ret_name = g_strdup(name); @@ -473,6 +475,53 @@ notify_get_server_info(char **ret_name, char **ret_vendor, char **ret_version) return TRUE; } +GList * +notify_get_server_caps(void) +{ + DBusMessage *message, *reply; + DBusMessageIter iter; + DBusError error; + GList *caps = NULL; + char **temp_array; + int num_items, i; + + message = _notify_dbus_message_new("GetCapabilities", NULL); + + g_return_val_if_fail(message != NULL, FALSE); + + dbus_error_init(&error); + + reply = dbus_connection_send_with_reply_and_block(_dbus_conn, message, + -1, &error); + + dbus_message_unref(message); + + if (dbus_error_is_set(&error)) + { + print_error("Error sending GetCapabilities: %s\n", error.message); + + dbus_error_free(&error); + + return FALSE; + } + + dbus_error_free(&error); + + dbus_message_iter_init(reply, &iter); + + if (!dbus_message_iter_get_string_array(&iter, &temp_array, &num_items)) + return NULL; + + dbus_message_unref(reply); + + for (i = 0; i < num_items; i++) + caps = g_list_append(caps, g_strdup(temp_array[i])); + + dbus_free_string_array(temp_array); + + return caps; +} + /************************************************************************** * Icon API **************************************************************************/ diff --git a/libnotify/notify.h b/libnotify/notify.h index 1ca73d8..1d436c9 100644 --- a/libnotify/notify.h +++ b/libnotify/notify.h @@ -91,6 +91,15 @@ void notify_close(NotifyHandle *handle); gboolean notify_get_server_info(char **ret_name, char **ret_vendor, char **ret_version); +/** + * Returns the server's capabilities. + * + * The returned list and the strings inside must all be freed. + * + * @return The list of capabilities, or NULL on error. + */ +GList *notify_get_server_caps(void); + /*@}*/ /**************************************************************************/