[libgdata] documents: Fix support for downloading arbitrary documents



commit c31f3d6e8955c37c1351644527917bd9cb082623
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Apr 14 10:27:18 2012 +0100

    documents: Fix support for downloading arbitrary documents
    
    This adds a new authorization domain necessary for downloading arbitrary
    files. I canât test this at the moment, though, due to Google breaking the
    workaround we were using for uploading metadata-only documents.
    (See:
    http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3033)
    
    Thanks Google. Thoogle.

 gdata/services/documents/gdata-documents-service.c |    2 ++
 gdata/tests/documents.c                            |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index d1836d3..5e5f160 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -278,6 +278,7 @@ static gchar *_get_upload_uri_for_query_and_folder (GDataDocumentsUploadQuery *q
 
 _GDATA_DEFINE_AUTHORIZATION_DOMAIN (documents, "writely", "https://docs.google.com/feeds/";)
 _GDATA_DEFINE_AUTHORIZATION_DOMAIN (spreadsheets, "wise", "https://spreadsheets.google.com/feeds/";)
+_GDATA_DEFINE_AUTHORIZATION_DOMAIN (docs_downloads, "writely", "https://docs.googleusercontent.com/";)
 G_DEFINE_TYPE_WITH_CODE (GDataDocumentsService, gdata_documents_service, GDATA_TYPE_SERVICE, G_IMPLEMENT_INTERFACE (GDATA_TYPE_BATCHABLE, NULL))
 
 static void
@@ -348,6 +349,7 @@ get_authorization_domains (void)
 
 	authorization_domains = g_list_prepend (authorization_domains, get_documents_authorization_domain ());
 	authorization_domains = g_list_prepend (authorization_domains, get_spreadsheets_authorization_domain ());
+	authorization_domains = g_list_prepend (authorization_domains, get_docs_downloads_authorization_domain ());
 
 	return authorization_domains;
 }
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index c6e8042..5c0dc85 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -326,6 +326,7 @@ typedef struct {
 	GDataDocumentsSpreadsheet *spreadsheet_document;
 	GDataDocumentsPresentation *presentation_document;
 	GDataDocumentsText *text_document;
+	GDataDocumentsDocument *arbitrary_document;
 } TempDocumentsData;
 
 static void
@@ -367,6 +368,15 @@ set_up_temp_documents (TempDocumentsData *data, gconstpointer service)
 	g_assert (GDATA_IS_DOCUMENTS_TEXT (data->text_document));
 	g_object_unref (document);
 
+	document = GDATA_DOCUMENTS_ENTRY (gdata_documents_document_new (NULL));
+	gdata_entry_set_title (GDATA_ENTRY (document), "Temporary Arbitrary Document");
+	data->arbitrary_document = GDATA_DOCUMENTS_DOCUMENT (
+		gdata_service_insert_entry (GDATA_SERVICE (service), gdata_documents_service_get_primary_authorization_domain (),
+		                            upload_uri, GDATA_ENTRY (document), NULL, NULL)
+	);
+	g_assert (GDATA_IS_DOCUMENTS_DOCUMENT (data->arbitrary_document));
+	g_object_unref (document);
+
 	g_free (upload_uri);
 }
 
@@ -383,6 +393,9 @@ tear_down_temp_documents (TempDocumentsData *data, gconstpointer service)
 	delete_entry (GDATA_DOCUMENTS_ENTRY (data->text_document), GDATA_SERVICE (service));
 	g_object_unref (data->text_document);
 
+	delete_entry (GDATA_DOCUMENTS_ENTRY (data->arbitrary_document), GDATA_SERVICE (service));
+	g_object_unref (data->arbitrary_document);
+
 	/* Delete the folder */
 	tear_down_temp_folder ((TempFolderData*) data, service);
 }
@@ -1226,6 +1239,7 @@ test_download_document (TempDocumentsData *data, gconstpointer service)
 	_test_download_document (GDATA_DOCUMENTS_DOCUMENT (data->spreadsheet_document), GDATA_SERVICE (service));
 	_test_download_document (GDATA_DOCUMENTS_DOCUMENT (data->presentation_document), GDATA_SERVICE (service));
 	_test_download_document (GDATA_DOCUMENTS_DOCUMENT (data->text_document), GDATA_SERVICE (service));
+	_test_download_document (GDATA_DOCUMENTS_DOCUMENT (data->arbitrary_document), GDATA_SERVICE (service));
 }
 
 static void



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