[libgdata] [documents] Move download methods to GDataDocumentsDocument
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] [documents] Move download methods to GDataDocumentsDocument
- Date: Sat, 21 Aug 2010 23:55:19 +0000 (UTC)
commit bf10250e65c9832056d0d1515e9dc884b9f57a41
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Aug 22 00:34:34 2010 +0100
[documents] Move download methods to GDataDocumentsDocument
This breaks API by removing the various download methods from
GDataDocumentsPresentation, GDataDocumentsSpreadsheet and GDataDocumentsText.
docs/reference/gdata-sections.txt | 7 +-
gdata/gdata-private.h | 7 -
gdata/gdata.symbols | 7 +-
.../services/documents/gdata-documents-document.c | 117 ++++++++++++++------
.../services/documents/gdata-documents-document.h | 7 +-
.../documents/gdata-documents-presentation.c | 85 --------------
.../documents/gdata-documents-presentation.h | 9 --
.../documents/gdata-documents-spreadsheet.c | 63 -----------
.../documents/gdata-documents-spreadsheet.h | 7 -
gdata/services/documents/gdata-documents-text.c | 84 --------------
gdata/services/documents/gdata-documents-text.h | 9 --
gdata/tests/documents.c | 18 ++--
12 files changed, 104 insertions(+), 316 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 8d00502..9e4503a 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1585,6 +1585,8 @@ GDataDocumentsFolderPrivate
<TITLE>GDataDocumentsDocument</TITLE>
GDataDocumentsDocument
GDataDocumentsDocumentClass
+gdata_documents_document_download
+gdata_documents_document_get_download_uri
<SUBSECTION Standard>
gdata_documents_document_get_type
GDATA_DOCUMENTS_DOCUMENT
@@ -1608,8 +1610,6 @@ GDATA_DOCUMENTS_PRESENTATION_TXT
GDataDocumentsPresentation
GDataDocumentsPresentationClass
gdata_documents_presentation_new
-gdata_documents_presentation_download_document
-gdata_documents_presentation_get_download_uri
<SUBSECTION Standard>
gdata_documents_presentation_get_type
GDATA_DOCUMENTS_PRESENTATION
@@ -1666,7 +1666,6 @@ GDATA_DOCUMENTS_SPREADSHEET_XLS
GDataDocumentsSpreadsheet
GDataDocumentsSpreadsheetClass
gdata_documents_spreadsheet_new
-gdata_documents_spreadsheet_download_document
gdata_documents_spreadsheet_get_download_uri
<SUBSECTION Standard>
gdata_documents_spreadsheet_get_type
@@ -1694,8 +1693,6 @@ GDATA_DOCUMENTS_TEXT_ZIP
GDataDocumentsText
GDataDocumentsTextClass
gdata_documents_text_new
-gdata_documents_text_download_document
-gdata_documents_text_get_download_uri
<SUBSECTION Standard>
gdata_documents_text_get_type
GDATA_DOCUMENTS_TEXT
diff --git a/gdata/gdata-private.h b/gdata/gdata-private.h
index 6ee0387..050948f 100644
--- a/gdata/gdata-private.h
+++ b/gdata/gdata-private.h
@@ -82,13 +82,6 @@ G_GNUC_INTERNAL void _gdata_feed_call_progress_callback (GDataFeed *self, gpoint
G_GNUC_INTERNAL void _gdata_entry_set_updated (GDataEntry *self, GTimeVal *updated);
G_GNUC_INTERNAL void _gdata_entry_set_batch_data (GDataEntry *self, guint id, GDataBatchOperationType type);
-#include "gdata/services/documents/gdata-documents-document.h"
-G_GNUC_INTERNAL GFile *_gdata_documents_document_download_document (GDataDocumentsDocument *self, GDataService *service, gchar **content_type,
- const gchar *download_uri, GFile *destination_directory,
- const gchar *file_extension, gboolean replace_file_if_exists,
- GCancellable *cancellable,
- GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-
#include "gdata/services/documents/gdata-documents-service.h"
G_GNUC_INTERNAL GDataService *_gdata_documents_service_get_spreadsheet_service (GDataDocumentsService *self) G_GNUC_PURE;
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 1068a67..330b592 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -625,15 +625,10 @@ gdata_picasaweb_query_set_location
gdata_picasaweb_visibility_get_type
gdata_documents_presentation_get_type
gdata_documents_presentation_new
-gdata_documents_presentation_download_document
-gdata_documents_presentation_get_download_uri
gdata_documents_text_get_type
gdata_documents_text_new
-gdata_documents_text_download_document
-gdata_documents_text_get_download_uri
gdata_documents_spreadsheet_get_type
gdata_documents_spreadsheet_new
-gdata_documents_spreadsheet_download_document
gdata_documents_spreadsheet_get_download_uri
gdata_documents_folder_get_type
gdata_documents_folder_new
@@ -846,3 +841,5 @@ gdata_batchable_get_type
gdata_batchable_create_operation
gdata_upload_stream_get_method
gdata_documents_document_get_type
+gdata_documents_document_download
+gdata_documents_document_get_download_uri
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index 6d8840d..046074e 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -62,56 +62,58 @@ notify_content_type_cb (GDataDownloadStream *download_stream, GParamSpec *pspec,
*content_type = g_strdup (gdata_download_stream_get_content_type (download_stream));
}
-/*
- * _gdata_documents_document_download_document:
+/**
+ * gdata_documents_document_download:
* @self: a #GDataDocumentsDocument
- * @service: an authenticated #GDataDocumentsService
+ * @service: a #GDataDocumentsService
* @content_type: (out callee-allocates) (transfer full) (allow-none): return location for the document's content type, or %NULL; free with g_free()
- * @download_uri: the URI to download the document
- * @destination_file: the #GFile into which the document file should be saved
- * @file_extension: the extension with which to save the downloaded file
- * @replace_file_if_exists: %TRUE if you want to replace the file if it exists, %FALSE otherwise
+ * @export_format: the format in which the document should be exported
+ * @destination_file: the #GFile into which the text file should be saved
+ * @replace_file_if_exists: %TRUE if the file should be replaced if it already exists, %FALSE otherwise
* @cancellable: optional #GCancellable object, or %NULL
* @error: a #GError, or %NULL
*
- * Downloads and returns the actual file which comprises the document here. If the document doesn't exist, the downloaded document will be an HTML
- * file containing the error explanation.
- * TODO: Is that still true?
+ * Downloads and returns the document file represented by the #GDataDocumentsDocument. If the document doesn't exist, %NULL is returned, but no error
+ * is set in @error.
*
- * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread. If the operation was
- * cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
+ * @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.
+ *
+ * If @self is a #GDataDocumentsSpreadsheet, only the first grid, or sheet, in the spreadsheet will be downloaded for some export formats. To download
+ * a specific a specific grid, use gdata_documents_spreadsheet_get_download_uri() with #GDataDownloadStream to download the grid manually. See the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">GData protocol
+ * specification</ulink> for more information.
*
- * If @replace_file_if_exists is set to %FALSE and the destination file already exists, a %G_IO_ERROR_EXISTS will be returned.
+ * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread. If the operation was
+ * cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
- * If @service isn't authenticated, a %GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED is returned.
+ * If @destination_file is a directory, then the file will be downloaded into this directory with a filename based on the #GDataEntry's title and the
+ * export format. If @replace_file_if_exists is set to %FALSE and the destination file already exists, a %G_IO_ERROR_EXISTS will be returned.
*
- * If there is an error downloading the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
+ * If @service isn't authenticated, a %GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED will be returned.
*
- * If @destination_file is a directory, the file will be downloaded to this directory with the #GDataEntry:title and the appropriate extension as its
- * filename.
+ * If there is an error getting the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
*
* Return value: a #GFile pointing to the downloaded document, or %NULL; unref with g_object_unref()
*
- * Since: 0.4.0
- */
+ * Since: 0.7.0
+ **/
GFile *
-_gdata_documents_document_download_document (GDataDocumentsDocument *self, GDataService *service, gchar **content_type, const gchar *src_uri,
- GFile *destination_file, const gchar *file_extension, gboolean replace_file_if_exists,
- GCancellable *cancellable, GError **error)
+gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsService *service, gchar **content_type, const gchar *export_format,
+ GFile *destination_file, gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
{
const gchar *document_title;
- gchar *default_filename;
+ gchar *default_filename, *download_uri;
GFileOutputStream *dest_stream;
GInputStream *src_stream;
- GFile *actual_file = NULL;
+ GFile *output_file;
GError *child_error = NULL;
/* TODO: async version */
g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
- g_return_val_if_fail (src_uri != NULL, NULL);
+ g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
- g_return_val_if_fail (file_extension != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -122,30 +124,81 @@ _gdata_documents_document_download_document (GDataDocumentsDocument *self, GData
return NULL;
}
- /* Determine a default filename based on the document's title */
+ /* Determine a default filename based on the document's title and export format */
document_title = gdata_entry_get_title (GDATA_ENTRY (self));
- default_filename = g_strdup_printf ("%s.%s", document_title, file_extension);
+ default_filename = g_strdup_printf ("%s.%s", document_title, export_format);
- dest_stream = _gdata_download_stream_find_destination (default_filename, destination_file, &actual_file, replace_file_if_exists, cancellable,
+ dest_stream = _gdata_download_stream_find_destination (default_filename, destination_file, &output_file, replace_file_if_exists, cancellable,
error);
g_free (default_filename);
if (dest_stream == NULL)
return NULL;
+ /* Get the download URI */
+ download_uri = gdata_documents_document_get_download_uri (self, export_format);
+ 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), src_uri);
+ src_stream = gdata_download_stream_new (GDATA_SERVICE (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);
g_object_unref (src_stream);
g_object_unref (dest_stream);
+ g_free (download_uri);
if (child_error != NULL) {
- g_object_unref (actual_file);
+ g_object_unref (output_file);
g_propagate_error (error, child_error);
return NULL;
}
- return actual_file;
+ return output_file;
+}
+
+/**
+ * gdata_documents_document_get_download_uri:
+ * @self: a #GDataDocumentsDocument
+ * @export_format: the format in which the document should be exported when downloaded
+ *
+ * Builds and returns the download URI for the given #GDataDocumentsDocument in the desired format. Note that directly downloading the document using
+ * this URI isn't possible, as authentication is required. You should instead use gdata_download_stream_new() with the URI, and use the resulting
+ * #GInputStream.
+ *
+ * @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()
+ *
+ * Since: 0.7.0
+ **/
+gchar *
+gdata_documents_document_get_download_uri (GDataDocumentsDocument *self, const gchar *export_format)
+{
+ const gchar *content_uri, *scheme;
+
+ g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
+ g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
+
+ content_uri = gdata_entry_get_content_uri (GDATA_ENTRY (self));
+ scheme = _gdata_service_get_scheme ();
+
+ g_assert (content_uri != NULL);
+
+ /* Ensure we're using the correct scheme (HTTP or HTTPS) */
+ if (g_str_has_prefix (content_uri, scheme) == FALSE) {
+ gchar *download_uri, **pieces;
+
+ pieces = g_strsplit (content_uri, ":", 2);
+ g_assert (pieces[0] != NULL && pieces[1] != NULL && pieces[2] == NULL);
+
+ download_uri = g_strdup_printf ("%s:%s&exportFormat=%s", scheme, pieces[1], export_format);
+
+ g_strfreev (pieces);
+
+ return download_uri;
+ }
+
+ return g_strdup_printf ("%s&exportFormat=%s", content_uri, export_format);
}
diff --git a/gdata/services/documents/gdata-documents-document.h b/gdata/services/documents/gdata-documents-document.h
index 49c7392..58c7a05 100644
--- a/gdata/services/documents/gdata-documents-document.h
+++ b/gdata/services/documents/gdata-documents-document.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include <gdata/services/documents/gdata-documents-entry.h>
-#include <gdata/gdata-types.h>
+#include <gdata/services/documents/gdata-documents-service.h>
G_BEGIN_DECLS
@@ -63,6 +63,11 @@ typedef struct {
GType gdata_documents_document_get_type (void) G_GNUC_CONST;
+GFile *gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsService *service, gchar **content_type,
+ const gchar *export_format, GFile *destination_file, gboolean replace_file_if_exists,
+ GCancellable *cancellable, GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+gchar *gdata_documents_document_get_download_uri (GDataDocumentsDocument *self, const gchar *export_format) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
G_END_DECLS
#endif /* !GDATA_DOCUMENTS_DOCUMENT_H */
diff --git a/gdata/services/documents/gdata-documents-presentation.c b/gdata/services/documents/gdata-documents-presentation.c
index f986e58..2496f4d 100644
--- a/gdata/services/documents/gdata-documents-presentation.c
+++ b/gdata/services/documents/gdata-documents-presentation.c
@@ -34,15 +34,8 @@
#include <config.h>
#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
-#include <string.h>
#include "gdata-documents-presentation.h"
-#include "gdata-documents-service.h"
-#include "gdata-parser.h"
-#include "gdata-types.h"
-#include "gdata-private.h"
static void get_xml (GDataParsable *parsable, GString *xml_string);
@@ -92,81 +85,3 @@ gdata_documents_presentation_new (const gchar *id)
{
return GDATA_DOCUMENTS_PRESENTATION (g_object_new (GDATA_TYPE_DOCUMENTS_PRESENTATION, "id", id, NULL));
}
-
-/**
- * gdata_documents_presentation_download_document:
- * @self: a #GDataDocumentsPresentation
- * @service: a #GDataDocumentsService
- * @content_type: (out callee-allocates) (transfer full) (allow-none): return location for the document's content type, or %NULL; free with g_free()
- * @export_format: the format in which the presentation should be exported
- * @destination_file: the #GFile into which the presentation file should be saved
- * @replace_file_if_exists: %TRUE if the file should be replaced if it already exists, %FALSE otherwise
- * @cancellable: optional #GCancellable object, or %NULL
- * @error: a #GError, or %NULL
- *
- * Downloads and returns the presentation file represented by the #GDataDocumentsPresentation. If the document doesn't exist,
- * %NULL is returned, but no error is set in @error. TODO: What?
- *
- * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
- * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
- *
- * If there is an error getting the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
- *
- * If @destination_file is a directory, then the file will be downloaded in this directory with the #GDataEntry:title with
- * the apropriate extension as name.
- *
- * Return value: the document's data, or %NULL; unref with g_object_unref()
- *
- * Since: 0.4.0
- **/
-GFile *
-gdata_documents_presentation_download_document (GDataDocumentsPresentation *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
-{
- gchar *link_href;
-
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_PRESENTATION (self), NULL);
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (service), NULL);
- g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
- g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
- g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* Call the common download method on the parent class */
- link_href = gdata_documents_presentation_get_download_uri (self, export_format);
- destination_file = _gdata_documents_document_download_document (GDATA_DOCUMENTS_DOCUMENT (self), GDATA_SERVICE (service), content_type,
- link_href, destination_file, export_format, replace_file_if_exists,
- cancellable, error);
- g_free (link_href);
-
- return destination_file;
-}
-
-/**
- * gdata_documents_presentation_get_download_uri:
- * @self: a #GDataDocumentsPresentation
- * @export_format: the format in which the presentation should be exported when downloaded
- *
- * Builds and returns the download URI for the given #GDataDocumentsPresentation in the desired format. Note that directly downloading
- * the document using this URI isn't possible, as authentication is required. You should instead use gdata_download_stream_new() with
- * the URI, and use the resulting #GInputStream.
- *
- * Return value: the download URI; free with g_free()
- *
- * Since: 0.5.0
- **/
-gchar *
-gdata_documents_presentation_get_download_uri (GDataDocumentsPresentation *self, const gchar *export_format)
-{
- const gchar *document_id;
-
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_PRESENTATION (self), NULL);
- g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
-
- document_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (self));
- g_assert (document_id != NULL);
-
- return g_strdup_printf ("%s://docs.google.com/feeds/download/presentations/Export?exportFormat=%s&docID=%s",
- _gdata_service_get_scheme (), export_format, document_id);
-}
diff --git a/gdata/services/documents/gdata-documents-presentation.h b/gdata/services/documents/gdata-documents-presentation.h
index a74f84a..415fb52 100644
--- a/gdata/services/documents/gdata-documents-presentation.h
+++ b/gdata/services/documents/gdata-documents-presentation.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gdata/services/documents/gdata-documents-document.h>
-#include <gdata/gdata-types.h>
G_BEGIN_DECLS
@@ -133,14 +132,6 @@ GType gdata_documents_presentation_get_type (void) G_GNUC_CONST;
GDataDocumentsPresentation *gdata_documents_presentation_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-#include <gdata/services/documents/gdata-documents-service.h>
-GFile *gdata_documents_presentation_download_document (GDataDocumentsPresentation *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable,
- GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-gchar *gdata_documents_presentation_get_download_uri (GDataDocumentsPresentation *self,
- const gchar *export_format) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-
G_END_DECLS
#endif /* !GDATA_DOCUMENTS_PRESENTATION_H */
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.c b/gdata/services/documents/gdata-documents-spreadsheet.c
index 845e639..b7ece76 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.c
+++ b/gdata/services/documents/gdata-documents-spreadsheet.c
@@ -39,8 +39,6 @@
#include <string.h>
#include "gdata-documents-spreadsheet.h"
-#include "gdata-parser.h"
-#include "gdata-types.h"
#include "gdata-private.h"
static void get_xml (GDataParsable *parsable, GString *xml_string);
@@ -93,67 +91,6 @@ gdata_documents_spreadsheet_new (const gchar *id)
}
/**
- * gdata_documents_spreadsheet_download_document:
- * @self: a #GDataDocumentsSpreadsheet
- * @service: a #GDataDocumentsService
- * @content_type: (out callee-allocates) (transfer full) (allow-none): return location for the document's content type, or %NULL; free with g_free()
- * @export_format: the format in which the spreadsheet should be exported
- * @gid: (default -1): the <code class="literal">0</code>-based sheet ID to download, or <code class="literal">-1</code>
- * @destination_file: the #GFile into which the spreadsheet file should be saved
- * @replace_file_if_exists: %TRUE if the file should be replaced if it already exists, %FALSE otherwise
- * @cancellable: optional #GCancellable object, or %NULL
- * @error: a #GError, or %NULL
- *
- * Downloads and returns the spreadsheet file represented by the #GDataDocumentsSpreadsheet. If the document doesn't exist,
- * %NULL is returned, but no error is set in @error. TODO: What?
- *
- * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
- * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
- *
- * When requesting a %GDATA_DOCUMENTS_SPREADSHEET_CSV or %GDATA_DOCUMENTS_SPREADSHEET_TSV file you must specify an additional
- * parameter called @gid which indicates which grid, or sheet, you wish to get (the index is <code class="literal">0</code>-based, so
- * GID <code class="literal">1</code> actually refers to the second sheet on a given spreadsheet).
- *
- * If @destination_file is a directory, then the file will be downloaded in this directory with the #GDataEntry:title with
- * the apropriate extension as name.
- *
- * If there is an error getting the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
- *
- * Return value: the document's data, or %NULL; unref with g_object_unref()
- *
- * Since: 0.4.0
- **/
-GFile *
-gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, gint gid, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
-{
- gchar *link_href;
- GDataService *spreadsheet_service;
-
- /* TODO: async version */
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_SPREADSHEET (self), NULL);
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (service), NULL);
- g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
- g_return_val_if_fail (gid >= -1, NULL);
- g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
- g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* Get the spreadsheet service */
- spreadsheet_service = _gdata_documents_service_get_spreadsheet_service (service);
-
- /* Download the document */
- link_href = gdata_documents_spreadsheet_get_download_uri (self, export_format, gid);
- destination_file = _gdata_documents_document_download_document (GDATA_DOCUMENTS_DOCUMENT (self), spreadsheet_service, content_type,
- link_href, destination_file, export_format, replace_file_if_exists,
- cancellable, error);
- g_free (link_href);
-
- return destination_file;
-}
-
-/**
* gdata_documents_spreadsheet_get_download_uri:
* @self: a #GDataDocumentsSpreadsheet
* @export_format: the format in which the spreadsheet should be exported when downloaded
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.h b/gdata/services/documents/gdata-documents-spreadsheet.h
index e40ee3e..a461f5b 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.h
+++ b/gdata/services/documents/gdata-documents-spreadsheet.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gdata/services/documents/gdata-documents-document.h>
-#include <gdata/gdata-types.h>
G_BEGIN_DECLS
@@ -146,12 +145,6 @@ GType gdata_documents_spreadsheet_get_type (void) G_GNUC_CONST;
GDataDocumentsSpreadsheet *gdata_documents_spreadsheet_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-#include <gdata/services/documents/gdata-documents-service.h>
-
-GFile *gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, gint gid, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable,
- GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
gchar *gdata_documents_spreadsheet_get_download_uri (GDataDocumentsSpreadsheet *self, const gchar *export_format,
gint gid) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
diff --git a/gdata/services/documents/gdata-documents-text.c b/gdata/services/documents/gdata-documents-text.c
index bf236c2..0210497 100644
--- a/gdata/services/documents/gdata-documents-text.c
+++ b/gdata/services/documents/gdata-documents-text.c
@@ -34,14 +34,8 @@
#include <config.h>
#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <libxml/parser.h>
-#include <string.h>
#include "gdata-documents-text.h"
-#include "gdata-parser.h"
-#include "gdata-types.h"
-#include "gdata-private.h"
static void get_xml (GDataParsable *parsable, GString *xml_string);
@@ -91,81 +85,3 @@ gdata_documents_text_new (const gchar *id)
{
return GDATA_DOCUMENTS_TEXT (g_object_new (GDATA_TYPE_DOCUMENTS_TEXT, "id", id, NULL));
}
-
-/**
- * gdata_documents_text_download_document:
- * @self: a #GDataDocumentsText
- * @service: a #GDataDocumentsService
- * @content_type: (out callee-allocates) (transfer full) (allow-none): return location for the document's content type, or %NULL; free with g_free()
- * @export_format: the format in which the text document should be exported
- * @destination_file: the #GFile into which the text file should be saved
- * @replace_file_if_exists: %TRUE if the file should be replaced if it already exists, %FALSE otherwise
- * @cancellable: optional #GCancellable object, or %NULL
- * @error: a #GError, or %NULL
- *
- * Downloads and returns the text document file represented by the #GDataDocumentsText. If the document doesn't exist,
- * %NULL is returned, but no error is set in @error. TODO: What?
- *
- * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
- * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
- *
- * If @destination_file is a directory, then the file will be downloaded in this directory with the #GDataEntry:title with
- * the apropriate extension as name.
- *
- * If there is an error getting the document, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
- *
- * Return value: the document's data, or %NULL; unref with g_object_unref()
- *
- * Since: 0.4.0
- **/
-GFile *
-gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
-{
- gchar *link_href;
-
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_TEXT (self), NULL);
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (service), NULL);
- g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
- g_return_val_if_fail (G_IS_FILE (destination_file), NULL);
- g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- /* Download the file */
- link_href = gdata_documents_text_get_download_uri (self, export_format);
- destination_file = _gdata_documents_document_download_document (GDATA_DOCUMENTS_DOCUMENT (self), GDATA_SERVICE (service),
- content_type, link_href, destination_file, export_format,
- replace_file_if_exists, cancellable, error);
- g_free (link_href);
-
- return destination_file;
-}
-
-/**
- * gdata_documents_text_get_download_uri:
- * @self: a #GDataDocumentsText
- * @export_format: the format in which the document should be exported when downloaded
- *
- * Builds and returns the download URI for the given #GDataDocumentsText in the desired format. Note that directly downloading
- * the document using this URI isn't possible, as authentication is required. You should instead use gdata_download_stream_new() with
- * the URI, and use the resulting #GInputStream.
- *
- * Return value: the download URI; free with g_free()
- *
- * Since: 0.5.0
- **/
-gchar *
-gdata_documents_text_get_download_uri (GDataDocumentsText *self, const gchar *export_format)
-{
- const gchar *document_id;
-
- g_return_val_if_fail (GDATA_IS_DOCUMENTS_TEXT (self), NULL);
- g_return_val_if_fail (export_format != NULL && *export_format != '\0', NULL);
-
- document_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (self));
- g_assert (document_id != NULL);
-
- return g_strdup_printf ("%s://docs.google.com/feeds/download/documents/Export?exportFormat=%s&docID=%s",
- _gdata_service_get_scheme (), export_format, document_id);
-}
diff --git a/gdata/services/documents/gdata-documents-text.h b/gdata/services/documents/gdata-documents-text.h
index d02f039..255f510 100644
--- a/gdata/services/documents/gdata-documents-text.h
+++ b/gdata/services/documents/gdata-documents-text.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gdata/services/documents/gdata-documents-document.h>
-#include <gdata/gdata-types.h>
G_BEGIN_DECLS
@@ -169,14 +168,6 @@ GType gdata_documents_text_get_type (void) G_GNUC_CONST;
GDataDocumentsText *gdata_documents_text_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-#include <gdata/services/documents/gdata-documents-service.h>
-
-GFile *gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocumentsService *service, gchar **content_type,
- const gchar *export_format, GFile *destination_file,
- gboolean replace_file_if_exists, GCancellable *cancellable,
- GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-gchar *gdata_documents_text_get_download_uri (GDataDocumentsText *self, const gchar *export_format) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
-
G_END_DECLS
#endif /* !GDATA_DOCUMENTS_TEXT_H */
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 1a78605..6a1dbf2 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -468,17 +468,16 @@ test_download_all_documents (gconstpointer service)
for (i = gdata_feed_get_entries (GDATA_FEED (feed)); i != NULL; i = i->next) {
if (GDATA_IS_DOCUMENTS_PRESENTATION (i->data)) {
destination_file = g_file_new_for_path ("/tmp");
- destination_file = gdata_documents_presentation_download_document (GDATA_DOCUMENTS_PRESENTATION (i->data), GDATA_DOCUMENTS_SERVICE (service),
- &content_type, GDATA_DOCUMENTS_PRESENTATION_PPT, destination_file,
- TRUE, NULL, &error);
-
+ destination_file = gdata_documents_document_download (GDATA_DOCUMENTS_DOCUMENT (i->data), GDATA_DOCUMENTS_SERVICE (service),
+ &content_type, GDATA_DOCUMENTS_PRESENTATION_PPT, destination_file,
+ TRUE, NULL, &error);
} else if (GDATA_IS_DOCUMENTS_SPREADSHEET (i->data)) {
destination_file_name = g_strdup_printf ("/tmp/%s.%s", gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (i->data)), "ods");
destination_file = g_file_new_for_path (destination_file_name);
g_free (destination_file_name);
- destination_file = gdata_documents_spreadsheet_download_document (i->data, GDATA_DOCUMENTS_SERVICE (service),
- &content_type, GDATA_DOCUMENTS_SPREADSHEET_ODS, -1, destination_file,
- TRUE, NULL, &error);
+ destination_file = gdata_documents_document_download (GDATA_DOCUMENTS_DOCUMENT (i->data), GDATA_DOCUMENTS_SERVICE (service),
+ &content_type, GDATA_DOCUMENTS_SPREADSHEET_ODS, destination_file,
+ TRUE, NULL, &error);
g_assert_no_error (error);
destination_display_name = g_string_new (gdata_entry_get_title (GDATA_ENTRY(i->data)));
@@ -496,8 +495,9 @@ test_download_all_documents (gconstpointer service)
destination_file_name = g_strdup_printf ("/tmp/%s.%s", gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (i->data)), "odt");
destination_file = g_file_new_for_path (destination_file_name);
g_free (destination_file_name);
- destination_file = gdata_documents_text_download_document (i->data, GDATA_DOCUMENTS_SERVICE (service), &content_type, GDATA_DOCUMENTS_TEXT_ODT,
- destination_file, TRUE, NULL, &error);
+ destination_file = gdata_documents_document_download (GDATA_DOCUMENTS_DOCUMENT (i->data), GDATA_DOCUMENTS_SERVICE (service),
+ &content_type, GDATA_DOCUMENTS_TEXT_ODT, destination_file, TRUE, NULL,
+ &error);
g_assert_no_error (error);
destination_display_name = g_string_new (gdata_entry_get_title (GDATA_ENTRY(i->data)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]