[libgdata] documents: Handle cases where export format is same as the original



commit 6386c6188f2a934c00ea645e098aaf89e3987a78
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 15 18:48:33 2016 +0100

    documents: Handle cases where export format is same as the original
    
    ... by falling back to gdata_entry_get_content_uri.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759180

 .../services/documents/gdata-documents-document.c  |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-document.c 
b/gdata/services/documents/gdata-documents-document.c
index 46d0a29..efaeb2a 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -206,6 +206,7 @@
 #include "gdata-documents-presentation.h"
 #include "gdata-documents-spreadsheet.h"
 #include "gdata-documents-text.h"
+#include "gdata-documents-utils.h"
 #include "gdata-download-stream.h"
 #include "gdata-private.h"
 #include "gdata-service.h"
@@ -418,6 +419,7 @@ gchar *
 gdata_documents_document_get_download_uri (GDataDocumentsDocument *self, const gchar *export_format)
 {
        const gchar *format;
+       const gchar *mime_type;
 
        g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
        g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
@@ -449,6 +451,14 @@ gdata_documents_document_get_download_uri (GDataDocumentsDocument *self, const g
        else
                format = export_format;
 
+       /* We use the exportLinks JSON member to do the format conversion during download. Unfortunately, 
there
+        * won't be any hits if the export format matches the original MIME type. We resort to downloadUrl in
+        * those cases.
+        */
+       mime_type = gdata_documents_utils_get_content_type (GDATA_DOCUMENTS_ENTRY (self));
+       if (g_content_type_equals (mime_type, format))
+               return g_strdup (gdata_entry_get_content_uri (GDATA_ENTRY (self)));
+
        return g_strdup (g_hash_table_lookup (self->priv->export_links, format));
 }
 


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