Properly handle error conditions from dunstctl

This commit is contained in:
Nikos Tsipinakis 2020-04-09 19:38:27 +02:00
parent 9049bf15b2
commit ec421f1ea1

View File

@ -583,12 +583,14 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection,
{ {
struct dunst_status status = dunst_status_get(); struct dunst_status status = dunst_status_get();
if (STR_EQ(property_name, "running")) if (STR_EQ(property_name, "running")) {
return g_variant_new_boolean(status.running); return g_variant_new_boolean(status.running);
else } else {
//TODO: is NULL as return value allowed? LOG_W("Unknown property!\n");
*error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
return NULL; return NULL;
} }
}
gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection, gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
const gchar *sender, const gchar *sender,
@ -605,10 +607,8 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
return true; return true;
} }
*error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
//FIXME: don't we have to return true on successful setting, but return false, if e.g. the parameter name is wrong?
//return true;
// so like this?
return false; return false;
} }