GFlagsClass *flags_class;
GFlagsValue *flags_value;
GString *flags;
- gboolean success;
+ guint n_valid_uids = 0;
+ gboolean success = TRUE;
g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
g_return_val_if_fail (ids != NULL, FALSE);
flags_value = g_flags_get_first_value (flags_class, mod);
}
- g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
while (ids != NULL) {
ECalComponentId *id = ids->data;
gchar *utf8_uid;
ids = g_slist_next (ids);
- if (id->uid == NULL || *id->uid == '\0')
+ if (id->uid == NULL)
continue;
+ /* Reject empty UIDs with an OBJECT_NOT_FOUND error for
+ * backward-compatibility, even though INVALID_ARG might
+ * be more appropriate. */
+ if (*id->uid == '\0') {
+ g_set_error_literal (
+ error, E_CAL_CLIENT_ERROR,
+ E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND,
+ e_cal_client_error_to_string (
+ E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND));
+ n_valid_uids = 0;
+ success = FALSE;
+ break;
+ }
+
utf8_uid = e_util_utf8_make_valid (id->uid);
if (id->rid != NULL)
utf8_rid = e_util_utf8_make_valid (id->rid);
g_free (utf8_uid);
g_free (utf8_rid);
+
+ n_valid_uids++;
}
- success = e_dbus_calendar_call_remove_objects_sync (
- client->priv->dbus_proxy,
- g_variant_builder_end (&builder),
- flags->str, cancellable, error);
+ if (n_valid_uids > 0) {
+ success = e_dbus_calendar_call_remove_objects_sync (
+ client->priv->dbus_proxy,
+ g_variant_builder_end (&builder),
+ flags->str, cancellable, error);
+ } else {
+ g_variant_builder_clear (&builder);
+ }
g_type_class_unref (flags_class);
g_string_free (flags, TRUE);
g_main_loop_run (fixture->loop);
}
+static void
+test_remove_object_empty_uid (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ ECalClient *cal_client;
+ GError *error = NULL;
+
+ g_test_bug ("697705");
+
+ cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
+
+ e_cal_client_remove_object_sync (
+ cal_client, "", NULL, E_CAL_OBJ_MOD_ALL, NULL, &error);
+ g_assert_error (
+ error, E_CAL_CLIENT_ERROR,
+ E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND);
+}
+
gint
main (gint argc,
gchar **argv)
e_test_server_utils_setup,
test_remove_object_async,
e_test_server_utils_teardown);
+ g_test_add (
+ "/ECalClient/RemoveObject/EmptyUid",
+ ETestServerFixture,
+ &cal_closure,
+ e_test_server_utils_setup,
+ test_remove_object_empty_uid,
+ e_test_server_utils_teardown);
return e_test_server_utils_run ();
}