[evolution-ews] I#21 - Meeting with attachment cannot be saved in 2010



commit 92bc455146b1b1825eb2d78e3a56b495a16940a1
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 26 16:24:36 2018 +0200

    I#21 - Meeting with attachment cannot be saved in 2010
    
    Closes https://gitlab.gnome.org/GNOME/evolution-ews/issues/21

 src/calendar/e-cal-backend-ews.c | 19 +++++++++++++++----
 src/server/e-ews-item.c          | 25 +++++++++++++++++++++++++
 src/server/e-ews-item.h          |  2 ++
 3 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 06d56fa0..48d62424 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2657,7 +2657,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                GHashTable *removed_indexes;
                EwsCalendarConvertData convert_data = { 0 };
                EEwsItem *item = NULL;
-               const EwsId *ews_id = NULL;
+               EwsId *ews_id = NULL;
                const gchar *send_meeting_invitations;
                icalcomponent *icalcomp;
                icalproperty *prop;
@@ -2701,7 +2701,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                        if (item) {
                                g_object_ref (item);
 
-                               ews_id = e_ews_item_get_id (item);
+                               ews_id = e_ews_id_copy (e_ews_item_get_id (item));
                        }
                }
 
@@ -2725,6 +2725,8 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                                g_clear_object (&item);
 
                                item = items_req->data;
+
+                               e_ews_id_free (ews_id);
                                ews_id = NULL;
 
                                if (e_ews_item_get_item_type (item) == E_EWS_ITEM_TYPE_ERROR) {
@@ -2733,7 +2735,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                                        success = FALSE;
                                } else {
                                        item = g_object_ref (item);
-                                       ews_id = e_ews_item_get_id (item);
+                                       ews_id = e_ews_id_copy (e_ews_item_get_id (item));
                                }
                        }
 
@@ -2748,13 +2750,21 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                        g_warn_if_fail (ews_id != NULL);
 
                        if (ews_id && ecb_ews_extract_attachments (icalcomp, &info_attachments)) {
+                               gchar *changekey = NULL;
                                GSList *ids = NULL;
 
                                success = e_ews_connection_create_attachments_sync (cbews->priv->cnc, 
EWS_PRIORITY_MEDIUM,
-                                       ews_id, info_attachments, FALSE, NULL, &ids, cancellable, error);
+                                       ews_id, info_attachments, FALSE, &changekey, &ids, cancellable, 
error);
 
                                g_slist_free_full (info_attachments, (GDestroyNotify) 
e_ews_attachment_info_free);
                                g_slist_free_full (ids, g_free);
+
+                               if (success && changekey) {
+                                       g_free (ews_id->change_key);
+                                       ews_id->change_key = changekey;
+                               } else {
+                                       g_free (changekey);
+                               }
                        }
                }
 
@@ -2789,6 +2799,7 @@ ecb_ews_save_component_sync (ECalMetaBackend *meta_backend,
                }
 
                icalcomponent_free (icalcomp);
+               e_ews_id_free (ews_id);
                g_clear_object (&item);
 
                for (link = (GSList *) instances; link && success; link = g_slist_next (link)) {
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index 6ba5975f..4919c664 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -3223,3 +3223,28 @@ e_ews_item_util_strip_ex_address (const gchar *ex_address)
 
        return ex_address;
 }
+
+EwsId *
+e_ews_id_copy (const EwsId *ews_id)
+{
+       EwsId *copy;
+
+       if (!ews_id)
+               return NULL;
+
+       copy = g_new0 (EwsId, 1);
+       copy->id = g_strdup (ews_id->id);
+       copy->change_key = g_strdup (ews_id->change_key);
+
+       return copy;
+}
+
+void
+e_ews_id_free (EwsId *ews_id)
+{
+       if (ews_id) {
+               g_free (ews_id->id);
+               g_free (ews_id->change_key);
+               g_free (ews_id);
+       }
+}
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index d5487918..fa4a066f 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -477,6 +477,8 @@ void                e_ews_permissions_free (GSList *permissions);
 /* Utility functions */
 const gchar *  e_ews_item_util_strip_ex_address
                                                (const gchar *ex_address);
+EwsId *                e_ews_id_copy                   (const EwsId *ews_id);
+void           e_ews_id_free                   (EwsId *ews_id);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]