[libgdata: 4/7] documents: Fix gdata_documents_service_add_entry_to_folder() to copy "properties" list too



commit e2388739af7939ee7a24cdb398cb741e288cc2a2
Author: Mayank Sharma <mayank8019 gmail com>
Date:   Thu Jul 25 16:56:58 2019 +0530

    documents: Fix gdata_documents_service_add_entry_to_folder() to copy
    "properties" list too
    
    gdata_documents_service_add_entry_to_folder() copies a given GDataEntry
    to a specified parent folder. It did that by creating a local entry.
    This local entry is created from the GDataEntry passed as argument, but
    it didn't copy over the "properties" list. This commit fixes this
    behaviour by copying the "properties" list as well.

 gdata/services/documents/gdata-documents-service.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/gdata/services/documents/gdata-documents-service.c 
b/gdata/services/documents/gdata-documents-service.c
index 524f93f6..f0c919ee 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -258,6 +258,7 @@
 #include <libsoup/soup.h>
 #include <string.h>
 
+#include "gdata-documents-property.h"
 #include "gdata-documents-service.h"
 #include "gdata-documents-utils.h"
 #include "gdata-batchable.h"
@@ -1193,6 +1194,7 @@ gdata_documents_service_add_entry_to_folder (GDataDocumentsService *self, GDataD
        gchar *uri;
        SoupMessage *message;
        guint status;
+       GList *l;
 
        g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
        g_return_val_if_fail (GDATA_IS_DOCUMENTS_ENTRY (entry), NULL);
@@ -1226,6 +1228,18 @@ gdata_documents_service_add_entry_to_folder (GDataDocumentsService *self, GDataD
        gdata_documents_utils_add_content_type (local_entry, content_type);
        add_folder_link_to_entry (local_entry, folder);
 
+       for (l = gdata_documents_entry_get_document_properties (entry); l != NULL; l = l->next) {
+               GDataDocumentsProperty *old_prop;
+               g_autoptr(GDataDocumentsProperty) new_prop = NULL;
+
+               old_prop = GDATA_DOCUMENTS_PROPERTY (l->data);
+
+               new_prop = gdata_documents_property_new (gdata_documents_property_get_key (old_prop));
+               gdata_documents_property_set_value (new_prop, gdata_documents_property_get_value (old_prop));
+               gdata_documents_property_set_visibility (new_prop, gdata_documents_property_get_visibility 
(old_prop));
+               gdata_documents_entry_add_documents_property (local_entry, new_prop);
+       }
+
        message = _gdata_service_build_message (GDATA_SERVICE (self), get_documents_authorization_domain (), 
SOUP_METHOD_POST, uri, NULL, FALSE);
        g_free (uri);
 


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