[evolution/gnome-42] I#1904 - CompEditor: Move whole component between calendars
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-42] I#1904 - CompEditor: Move whole component between calendars
- Date: Wed, 11 May 2022 15:38:39 +0000 (UTC)
commit 48551d0a28c2cbf1e53c90b32b3589d7d340b56c
Author: Milan Crha <mcrha redhat com>
Date: Wed May 11 17:36:19 2022 +0200
I#1904 - CompEditor: Move whole component between calendars
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1904
src/calendar/gui/e-comp-editor.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index c6506e0707..cf09b2eef7 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -802,6 +802,10 @@ ece_save_component_thread (EAlertSinkThreadJobData *job_data,
SaveData *sd = user_data;
const gchar *create_alert_ident, *modify_alert_ident, *remove_alert_ident, *get_alert_ident;
gchar *orig_uid, *new_uid = NULL;
+ gboolean has_recurrences;
+ gboolean is_on_server;
+ gboolean different_clients;
+ gboolean already_moved = FALSE;
g_return_if_fail (sd != NULL);
g_return_if_fail (E_IS_CAL_CLIENT (sd->target_client));
@@ -844,18 +848,29 @@ ece_save_component_thread (EAlertSinkThreadJobData *job_data,
}
orig_uid = g_strdup (i_cal_component_get_uid (sd->component));
-
- if (cal_comp_is_icalcomp_on_server_sync (sd->component, sd->target_client, cancellable, error)) {
+ has_recurrences = e_cal_util_component_has_recurrences (sd->component);
+ is_on_server = cal_comp_is_icalcomp_on_server_sync (sd->component, sd->target_client, cancellable,
error);
+ different_clients = sd->source_client &&
+ !e_source_equal (e_client_get_source (E_CLIENT (sd->target_client)),
+ e_client_get_source (E_CLIENT (sd->source_client)));
+
+ if (!is_on_server && has_recurrences && different_clients &&
+ cal_comp_is_icalcomp_on_server_sync (sd->component, sd->source_client, cancellable, error)) {
+ /* First move the component to the target client, thus it contains all the detached instances
+ and the main component, then modify it there. */
+ sd->success = cal_comp_transfer_item_to_sync (sd->source_client, sd->target_client,
sd->component, FALSE, cancellable, error);
+ is_on_server = sd->success;
+ already_moved = sd->success;
+ }
+
+ if (sd->success && is_on_server) {
ECalComponent *comp;
- gboolean has_recurrences;
e_alert_sink_thread_job_set_alert_ident (job_data, modify_alert_ident);
comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (sd->component));
g_return_if_fail (comp != NULL);
- has_recurrences = e_cal_util_component_has_recurrences (sd->component);
-
if (has_recurrences && sd->recur_mod == E_CAL_OBJ_MOD_ALL)
sd->success = comp_util_sanitize_recurrence_master_sync (comp, sd->target_client,
cancellable, error);
else
@@ -872,7 +887,7 @@ ece_save_component_thread (EAlertSinkThreadJobData *job_data,
sd->target_client, e_cal_component_get_icalcomponent (comp), sd->recur_mod,
E_CAL_OPERATION_FLAG_NONE, cancellable, error);
g_clear_object (&comp);
- } else {
+ } else if (sd->success) {
e_alert_sink_thread_job_set_alert_ident (job_data, create_alert_ident);
sd->success = e_cal_client_create_object_sync (sd->target_client, sd->component,
E_CAL_OPERATION_FLAG_NONE, &new_uid, cancellable, error);
@@ -881,9 +896,7 @@ ece_save_component_thread (EAlertSinkThreadJobData *job_data,
sd->object_created = TRUE;
}
- if (sd->success && sd->source_client &&
- !e_source_equal (e_client_get_source (E_CLIENT (sd->target_client)),
- e_client_get_source (E_CLIENT (sd->source_client))) &&
+ if (sd->success && different_clients && !already_moved &&
cal_comp_is_icalcomp_on_server_sync (sd->component, sd->source_client, cancellable, NULL)) {
ECalObjModType recur_mod = E_CAL_OBJ_MOD_THIS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]