diff options
author | Ted Gould <ted@canonical.com> | 2009-05-15 15:13:12 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-05-15 15:13:12 -0500 |
commit | 9f60fb948c1be4f681332445cf44fb6dc151fe90 (patch) | |
tree | 31256d2151c2f5a755cf842e840a8e167af00da5 /libdbusmenu-glib | |
parent | 56fad3ec6db3ef3cb589446a11a45d06da339dd9 (diff) | |
download | libdbusmenu-9f60fb948c1be4f681332445cf44fb6dc151fe90.tar.gz libdbusmenu-9f60fb948c1be4f681332445cf44fb6dc151fe90.tar.bz2 libdbusmenu-9f60fb948c1be4f681332445cf44fb6dc151fe90.zip |
More error handling in the properties interface.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/server.c | 27 |
1 files changed, 27 insertions, 0 deletions
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; } |