From 9f60fb948c1be4f681332445cf44fb6dc151fe90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 May 2009 15:13:12 -0500 Subject: More error handling in the properties interface. --- libdbusmenu-glib/server.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 6336ffd..02aed24 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -73,6 +73,8 @@ enum { /* Errors */ enum { INVALID_MENUITEM_ID, + INVALID_PROPERTY_NAME, + UNKNOWN_DBUS_ERROR, LAST_ERROR }; @@ -371,6 +373,31 @@ _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * proper return FALSE; } + const gchar * prop = dbusmenu_menuitem_property_get(mi, property); + if (prop == NULL) { + if (error != NULL) { + g_set_error(error, + error_quark(), + INVALID_PROPERTY_NAME, + "The property '%s' does not exist on menuitem with ID of %d", + property, + id); + } + return FALSE; + } + + if (value == NULL) { + if (error != NULL) { + g_set_error(error, + error_quark(), + UNKNOWN_DBUS_ERROR, + "Uhm, yeah. We didn't get anywhere to put the value, that's really weird. Seems impossible really."); + } + return FALSE; + } + + *value = g_strdup(prop); + return TRUE; } -- cgit v1.2.3