summaryrefslogtreecommitdiff
path: root/gdata/services/documents/gdata-documents-document.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2010-08-23 22:04:32 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2010-08-23 22:06:34 +0100
commit33181607696118df9715f18e633a942dc10f470b (patch)
tree2577af051e007dd256c10fe9bb7d2cbbfd0f0a12 /gdata/services/documents/gdata-documents-document.c
parentd0313cce89cab39af917bd9bf1686db76f01b6fa (diff)
downloadlibgdata-33181607696118df9715f18e633a942dc10f470b.tar.gz
documents: Ensure the correct service is used to download spreadsheets
Diffstat (limited to 'gdata/services/documents/gdata-documents-document.c')
-rw-r--r--gdata/services/documents/gdata-documents-document.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index cb95fc66..d0681c8a 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -38,6 +38,7 @@
#include "gdata-documents-document.h"
#include "gdata-documents-entry.h"
+#include "gdata-documents-spreadsheet.h"
#include "gdata-download-stream.h"
#include "gdata-private.h"
#include "gdata-service.h"
@@ -104,6 +105,7 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
{
const gchar *document_title;
gchar *default_filename, *download_uri;
+ GDataService *_service;
GFileOutputStream *dest_stream;
GInputStream *src_stream;
GFile *output_file = NULL;
@@ -117,8 +119,15 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+ /* Horrible hack to force use of the spreadsheet service if the document we're downloading is a spreadsheet. This is necessary because it's
+ * in a different authentication domain. */
+ if (GDATA_IS_DOCUMENTS_SPREADSHEET (self))
+ _service = _gdata_documents_service_get_spreadsheet_service (service);
+ else
+ _service = GDATA_SERVICE (service);
+
/* Ensure we're authenticated first */
- if (gdata_service_is_authenticated (GDATA_SERVICE (service)) == FALSE) {
+ if (gdata_service_is_authenticated (_service) == FALSE) {
g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
_("You must be authenticated to download documents."));
return NULL;
@@ -140,7 +149,7 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
g_assert (download_uri != NULL);
/* Synchronously splice the data from the download stream to the file stream (network -> disk) */
- src_stream = gdata_download_stream_new (GDATA_SERVICE (service), download_uri);
+ src_stream = gdata_download_stream_new (_service, download_uri);
g_signal_connect (src_stream, "notify::content-type", (GCallback) notify_content_type_cb, content_type);
g_output_stream_splice (G_OUTPUT_STREAM (dest_stream), src_stream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
cancellable, &child_error);