[libgdata] [documents] Added a function to get the document upload URI



commit 372610c967ac8bd1e088a290dd62299b5261dd02
Author: Thibault Saunier <saunierthibault gmail com>
Date:   Mon Aug 10 21:20:25 2009 +0100

    [documents] Added a function to get the document upload URI

 docs/reference/gdata-sections.txt                  |    1 +
 gdata/gdata.symbols                                |    1 +
 gdata/services/documents/gdata-documents-service.c |   37 +++++++++++++++----
 gdata/services/documents/gdata-documents-service.h |    1 +
 4 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index d8c0e68..39b0d9c 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1501,6 +1501,7 @@ gdata_documents_service_upload_document
 gdata_documents_service_update_document
 gdata_documents_service_move_document_to_folder
 gdata_documents_service_remove_document_from_folder
+gdata_documents_service_get_upload_uri
 <SUBSECTION Standard>
 gdata_documents_service_get_type
 GDATA_DOCUMENTS_SERVICE
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index cd4e81c..3114f47 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -640,6 +640,7 @@ gdata_documents_service_query_documents_async
 gdata_documents_service_upload_document
 gdata_documents_service_update_document
 gdata_documents_service_move_document_to_folder
+gdata_documents_service_get_upload_uri
 gdata_documents_service_remove_document_from_folder
 gdata_documents_feed_get_type
 gdata_documents_entry_get_type
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index bd8aefe..3f44e8f 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -479,14 +479,7 @@ gdata_documents_service_upload_document (GDataDocumentsService *self, GDataDocum
 		return NULL;
 	}
 
-	/* Get the upload URI */
-	if (folder != NULL) {
-		const gchar *folder_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (folder));
-		g_assert (folder_id != NULL);
-		upload_uri = g_strconcat ("http://docs.google.com/feeds/folders/private/full/folder%3A";, folder_id, NULL);
-	} else {
-		upload_uri = g_strdup ("http://docs.google.com/feeds/documents/private/full";);
-	}
+	upload_uri = gdata_documents_service_get_upload_uri (folder);
 
 	if (document_file == NULL) {
 		new_document = GDATA_DOCUMENTS_ENTRY (gdata_service_insert_entry (GDATA_SERVICE (self), upload_uri, GDATA_ENTRY (document),
@@ -720,6 +713,34 @@ gdata_documents_service_remove_document_from_folder (GDataDocumentsService *self
 							      cancellable, error);
 }
 
+/**
+ * gdata_documents_service_get_upload_uri:
+ * @folder: the #GDataDocumentsFolder into which to upload the document, or %NULL
+ *
+ * Gets the upload URI for documents for the service.
+ *
+ * If @folder is %NULL, the URI will be the one to upload documents to the "root" folder.
+ *
+ * Return value: the URI permitting the upload of documents to @folder, or %NULL; free with g_free()
+ *
+ * Since: 0.5.0
+ **/
+gchar *
+gdata_documents_service_get_upload_uri (GDataDocumentsFolder *folder)
+{
+	g_return_val_if_fail (folder == NULL || GDATA_IS_DOCUMENTS_FOLDER (folder), NULL);
+
+	/* If we have a folder, return the folder's upload URI */
+	if (folder != NULL) {
+		const gchar *folder_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (folder));
+		g_assert (folder_id != NULL);
+		return g_strconcat ("http://docs.google.com/feeds/folders/private/full/folder%3A";, folder_id, NULL);
+	}
+
+	/* Otherwise return the default upload URI */
+	return g_strdup ("http://docs.google.com/feeds/documents/private/full";);
+}
+
 GDataService *
 _gdata_documents_service_get_spreadsheet_service (GDataDocumentsService *self)
 {
diff --git a/gdata/services/documents/gdata-documents-service.h b/gdata/services/documents/gdata-documents-service.h
index ed5df50..a83e619 100644
--- a/gdata/services/documents/gdata-documents-service.h
+++ b/gdata/services/documents/gdata-documents-service.h
@@ -102,6 +102,7 @@ GDataDocumentsEntry *gdata_documents_service_move_document_to_folder (GDataDocum
 GDataDocumentsEntry *gdata_documents_service_remove_document_from_folder (GDataDocumentsService *self, GDataDocumentsEntry *document,
 									  GDataDocumentsFolder *folder,
 									  GCancellable *cancellable, GError **error) G_GNUC_WARN_UNUSED_RESULT;
+gchar *gdata_documents_service_get_upload_uri (GDataDocumentsFolder *folder);
 
 G_END_DECLS
 #endif /* !GDATA_DOCUMENTS_SERVICE_H */



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