libgdata/libgdata-cant-open-pdf.patch

290 lines
11 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 9a52e743ce27065b0f5af987d2435e95ad954d65 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 15 Jan 2016 17:46:11 +0100
Subject: [PATCH 1/4] documents: Update URL to Drive v2 API documentation
The previous URL was getting redirected to a web page documenting SDKs
for various platforms instead of the JSON protocol that we need.
https://bugzilla.gnome.org/show_bug.cgi?id=684920
---
gdata/services/documents/gdata-documents-entry.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index 006926a0a6ae..b1e37d302a83 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -839,7 +839,7 @@ get_json (GDataParsable *parsable, JsonBuilder *builder)
}
}
- /* Upload to a folder: https://developers.google.com/drive/web/folder */
+ /* Upload to a folder: https://developers.google.com/drive/v2/web/folder */
json_builder_set_member_name (builder, "parents");
json_builder_begin_array (builder);
--
2.5.0
From be3ba40a57350ee4d914b0391d507722df2b04c1 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 15 Jan 2016 18:44:21 +0100
Subject: [PATCH 2/4] documents: Split out the code to get the content type of
an entry
We will need this in gdata_documents_document_get_download_uri.
https://bugzilla.gnome.org/show_bug.cgi?id=759180
---
gdata/services/documents/gdata-documents-entry.c | 21 ++++----------
gdata/services/documents/gdata-documents-utils.c | 37 ++++++++++++++++++++++--
gdata/services/documents/gdata-documents-utils.h | 6 +++-
3 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index b1e37d302a83..ac713b751e69 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -2,7 +2,7 @@
/*
* GData Client
* Copyright (C) Thibault Saunier 2009 <saunierthibault@gmail.com>
- * Copyright (C) Red Hat, Inc. 2015
+ * Copyright (C) Red Hat, Inc. 2015, 2016
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -816,27 +816,18 @@ get_content_type (void)
static void
get_json (GDataParsable *parsable, JsonBuilder *builder)
{
- GList *categories;
GList *i;
GList *parent_folders_list;
+ const gchar *mime_type;
GDATA_PARSABLE_CLASS (gdata_documents_entry_parent_class)->get_json (parsable, builder);
/* Inserting files: https://developers.google.com/drive/v2/reference/files/insert */
- categories = gdata_entry_get_categories (GDATA_ENTRY (parsable));
- for (i = categories; i != NULL; i = i->next) {
- GDataCategory *category = GDATA_CATEGORY (i->data);
- const gchar *label;
- const gchar *scheme;
-
- label = gdata_category_get_label (category);
- scheme = gdata_category_get_scheme (category);
- if (label != NULL && label[0] != '\0' && g_strcmp0 (scheme, "http://schemas.google.com/g/2005#kind") == 0) {
- json_builder_set_member_name (builder, "mimeType");
- json_builder_add_string_value (builder, label);
- break;
- }
+ mime_type = gdata_documents_utils_get_content_type (GDATA_DOCUMENTS_ENTRY (parsable));
+ if (mime_type != NULL) {
+ json_builder_set_member_name (builder, "mimeType");
+ json_builder_add_string_value (builder, mime_type);
}
/* Upload to a folder: https://developers.google.com/drive/v2/web/folder */
diff --git a/gdata/services/documents/gdata-documents-utils.c b/gdata/services/documents/gdata-documents-utils.c
index ed71dac93723..046b3ec7a43d 100644
--- a/gdata/services/documents/gdata-documents-utils.c
+++ b/gdata/services/documents/gdata-documents-utils.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Red Hat, Inc. 2015
+ * Copyright (C) Red Hat, Inc. 2015, 2016
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,6 @@
* License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gdata-documents-entry.h"
#include "gdata-documents-spreadsheet.h"
#include "gdata-documents-text.h"
#include "gdata-documents-presentation.h"
@@ -62,3 +61,37 @@ gdata_documents_utils_get_type_from_content_type (const gchar *content_type)
return retval;
}
+
+/*
+ * gdata_documents_utils_get_content_type:
+ * @entry: a #GDataDocumentsEntry
+ *
+ * Returns the content type of @entry, if any.
+ *
+ * Return value: (nullable): content type of @entry, %NULL otherwise
+ *
+ * Since: 0.17.5
+ */
+const gchar *
+gdata_documents_utils_get_content_type (GDataDocumentsEntry *entry)
+{
+ GList *categories;
+ GList *i;
+ const gchar *retval = NULL;
+
+ categories = gdata_entry_get_categories (GDATA_ENTRY (entry));
+ for (i = categories; i != NULL; i = i->next) {
+ GDataCategory *category = GDATA_CATEGORY (i->data);
+ const gchar *label;
+ const gchar *scheme;
+
+ label = gdata_category_get_label (category);
+ scheme = gdata_category_get_scheme (category);
+ if (label != NULL && label[0] != '\0' && g_strcmp0 (scheme, "http://schemas.google.com/g/2005#kind") == 0) {
+ retval = label;
+ break;
+ }
+ }
+
+ return retval;
+}
diff --git a/gdata/services/documents/gdata-documents-utils.h b/gdata/services/documents/gdata-documents-utils.h
index 01cc460d3f7c..a2a4b99e07cd 100644
--- a/gdata/services/documents/gdata-documents-utils.h
+++ b/gdata/services/documents/gdata-documents-utils.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Red Hat, Inc. 2015
+ * Copyright (C) Red Hat, Inc. 2015, 2016
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,8 @@
#include <glib.h>
#include <glib-object.h>
+#include <gdata/services/documents/gdata-documents-entry.h>
+
G_BEGIN_DECLS
/* HACK: Used to convert GDataLink:uri to ID and vice-versa. */
@@ -30,6 +32,8 @@ G_BEGIN_DECLS
G_GNUC_INTERNAL GType gdata_documents_utils_get_type_from_content_type (const gchar *content_type);
+G_GNUC_INTERNAL const gchar *gdata_documents_utils_get_content_type (GDataDocumentsEntry *entry);
+
G_END_DECLS
#endif /* !GDATA_DOCUMENTS_UTILS_H */
--
2.5.0
From c0d67d29268613abb5f5faff24c28bd21c2e94b6 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Fri, 15 Jan 2016 18:48:33 +0100
Subject: [PATCH 3/4] 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
---
gdata/services/documents/gdata-documents-document.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index 46d0a2950969..efaeb2afff4a 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));
}
--
2.5.0
From 8aa810047fa4593a53131b855081c4ce4b8003a2 Mon Sep 17 00:00:00 2001
From: Philip Withnall <philip@tecnocode.co.uk>
Date: Sun, 20 Dec 2015 19:19:02 +0000
Subject: [PATCH 4/4] documents: Fix error handling for unknown formats for
document downloads
https://bugzilla.gnome.org/show_bug.cgi?id=759180
---
gdata/services/documents/gdata-documents-document.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index efaeb2afff4a..dbd825e6c34b 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -355,6 +355,8 @@ gdata_documents_document_new (const gchar *id)
* #GInputStream operations on the #GDataDownloadStream will not cancel the entire download; merely the read or close operation in question. See the
* #GDataDownloadStream:cancellable for more details.
*
+ * If the given @export_format is unrecognised or not supported for this document, %GDATA_SERVICE_ERROR_NOT_FOUND will be returned.
+ *
* If @service isn't authenticated, a %GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED will be returned.
*
* If there is an error getting the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
@@ -393,6 +395,13 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
/* Get the download URI and create a stream for it */
download_uri = gdata_documents_document_get_download_uri (self, export_format);
+
+ if (download_uri == NULL) {
+ g_set_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_NOT_FOUND,
+ _("Unknown or unsupported document export format %s."), export_format);
+ return NULL;
+ }
+
download_stream = GDATA_DOWNLOAD_STREAM (gdata_download_stream_new (GDATA_SERVICE (service), domain, download_uri, cancellable));
g_free (download_uri);
@@ -411,7 +420,9 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
* @export_format should be the file extension of the desired output format for the document, from the list accepted by Google Documents. For example:
* %GDATA_DOCUMENTS_PRESENTATION_PDF, %GDATA_DOCUMENTS_SPREADSHEET_ODS or %GDATA_DOCUMENTS_TEXT_ODT.
*
- * Return value: the download URI; free with g_free()
+ * If the @export_format is not recognised or not supported for this document, %NULL is returned.
+ *
+ * Return value: (nullable): the download URI, or %NULL; free with g_free()
*
* Since: 0.7.0
**/
--
2.5.0