[libgdata] [documents] Specify export format by strings instead of enums
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] [documents] Specify export format by strings instead of enums
- Date: Sat, 21 Aug 2010 23:54:59 +0000 (UTC)
commit 0db5aeece161142093343263652fa5c498e169f6
Author: Philip Withnall <philip tecnocode co uk>
Date: Sat Aug 21 22:37:29 2010 +0100
[documents] Specify export format by strings instead of enums
This makes libgdata more futureproof, as it allows future formats to be used
with old versions of libgdata without modification. API compatibility is
retained with #defines for each old enum member, but this is an ABI break.
docs/reference/gdata-sections.txt | 28 +++--
.../documents/gdata-documents-presentation.c | 20 +--
.../documents/gdata-documents-presentation.h | 89 ++++++++++---
.../documents/gdata-documents-spreadsheet.c | 45 ++-----
.../documents/gdata-documents-spreadsheet.h | 104 ++++++++++++----
gdata/services/documents/gdata-documents-text.c | 23 +---
gdata/services/documents/gdata-documents-text.h | 135 +++++++++++++++----
7 files changed, 298 insertions(+), 146 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index ad439f2..3022846 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1581,9 +1581,13 @@ GDataDocumentsFolderPrivate
<SECTION>
<FILE>gdata-documents-presentation</FILE>
<TITLE>GDataDocumentsPresentation</TITLE>
+GDATA_DOCUMENTS_PRESENTATION_PDF
+GDATA_DOCUMENTS_PRESENTATION_PNG
+GDATA_DOCUMENTS_PRESENTATION_PPT
+GDATA_DOCUMENTS_PRESENTATION_SWF
+GDATA_DOCUMENTS_PRESENTATION_TXT
GDataDocumentsPresentation
GDataDocumentsPresentationClass
-GDataDocumentsPresentationFormat
gdata_documents_presentation_new
gdata_documents_presentation_download_document
gdata_documents_presentation_get_download_uri
@@ -1594,9 +1598,7 @@ GDATA_DOCUMENTS_PRESENTATION_CLASS
GDATA_DOCUMENTS_PRESENTATION_GET_CLASS
GDATA_IS_DOCUMENTS_PRESENTATION
GDATA_IS_DOCUMENTS_PRESENTATION_CLASS
-GDATA_TYPE_DATA_DOCUMENTS_PRESENTATION_FORMAT
GDATA_TYPE_DOCUMENTS_PRESENTATION
-gdata_documents_presentation_format_get_type
<SUBSECTION Private>
GDataDocumentsPresentationPrivate
</SECTION>
@@ -1636,9 +1638,14 @@ GDataDocumentsQueryPrivate
<SECTION>
<FILE>gdata-documents-spreadsheet</FILE>
<TITLE>GDataDocumentsSpreadsheet</TITLE>
+GDATA_DOCUMENTS_SPREADSHEET_CSV
+GDATA_DOCUMENTS_SPREADSHEET_HTML
+GDATA_DOCUMENTS_SPREADSHEET_ODS
+GDATA_DOCUMENTS_SPREADSHEET_PDF
+GDATA_DOCUMENTS_SPREADSHEET_TSV
+GDATA_DOCUMENTS_SPREADSHEET_XLS
GDataDocumentsSpreadsheet
GDataDocumentsSpreadsheetClass
-GDataDocumentsSpreadsheetFormat
gdata_documents_spreadsheet_new
gdata_documents_spreadsheet_download_document
gdata_documents_spreadsheet_get_download_uri
@@ -1649,9 +1656,7 @@ GDATA_DOCUMENTS_SPREADSHEET_CLASS
GDATA_DOCUMENTS_SPREADSHEET_GET_CLASS
GDATA_IS_DOCUMENTS_SPREADSHEET
GDATA_IS_DOCUMENTS_SPREADSHEET_CLASS
-GDATA_TYPE_DATA_DOCUMENTS_SPREADSHEET_FORMAT
GDATA_TYPE_DOCUMENTS_SPREADSHEET
-gdata_documents_spreadsheet_format_get_type
<SUBSECTION Private>
GDataDocumentsSpreadsheetPrivate
</SECTION>
@@ -1659,9 +1664,16 @@ GDataDocumentsSpreadsheetPrivate
<SECTION>
<FILE>gdata-documents-text</FILE>
<TITLE>GDataDocumentsText</TITLE>
+GDATA_DOCUMENTS_TEXT_DOC
+GDATA_DOCUMENTS_TEXT_HTML
+GDATA_DOCUMENTS_TEXT_ODT
+GDATA_DOCUMENTS_TEXT_PDF
+GDATA_DOCUMENTS_TEXT_PNG
+GDATA_DOCUMENTS_TEXT_RTF
+GDATA_DOCUMENTS_TEXT_TXT
+GDATA_DOCUMENTS_TEXT_ZIP
GDataDocumentsText
GDataDocumentsTextClass
-GDataDocumentsTextFormat
gdata_documents_text_new
gdata_documents_text_download_document
gdata_documents_text_get_download_uri
@@ -1672,9 +1684,7 @@ GDATA_DOCUMENTS_TEXT_CLASS
GDATA_DOCUMENTS_TEXT_GET_CLASS
GDATA_IS_DOCUMENTS_TEXT
GDATA_IS_DOCUMENTS_TEXT_CLASS
-GDATA_TYPE_DATA_DOCUMENTS_TEXT_FORMAT
GDATA_TYPE_DOCUMENTS_TEXT
-gdata_documents_text_format_get_type
<SUBSECTION Private>
GDataDocumentsTextPrivate
</SECTION>
diff --git a/gdata/services/documents/gdata-documents-presentation.c b/gdata/services/documents/gdata-documents-presentation.c
index 0107796..c513ddc 100644
--- a/gdata/services/documents/gdata-documents-presentation.c
+++ b/gdata/services/documents/gdata-documents-presentation.c
@@ -46,14 +46,6 @@
static void get_xml (GDataParsable *parsable, GString *xml_string);
-static const gchar *export_formats[] = {
- "pdf", /* GDATA_DOCUMENTS_PRESENTATION_PDF */
- "png", /* GDATA_DOCUMENTS_PRESENTATION_PNG */
- "ppt", /* GDATA_DOCUMENTS_PRESENTATION_PPT */
- "swf", /* GDATA_DOCUMENTS_PRESENTATION_SWF */
- "txt" /* GDATA_DOCUMENTS_PRESENTATION_TXT */
-};
-
G_DEFINE_TYPE (GDataDocumentsPresentation, gdata_documents_presentation, GDATA_TYPE_DOCUMENTS_ENTRY)
static void
@@ -129,7 +121,7 @@ gdata_documents_presentation_new (const gchar *id)
**/
GFile *
gdata_documents_presentation_download_document (GDataDocumentsPresentation *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsPresentationFormat export_format, GFile *destination_file,
+ const gchar *export_format, GFile *destination_file,
gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
{
gchar *link_href;
@@ -138,13 +130,13 @@ gdata_documents_presentation_download_document (GDataDocumentsPresentation *self
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 < G_N_ELEMENTS (export_formats), 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_entry_download_document (GDATA_DOCUMENTS_ENTRY (self), GDATA_SERVICE (service), content_type, link_href,
- destination_file, export_formats[export_format], replace_file_if_exists,
+ destination_file, export_format, replace_file_if_exists,
cancellable, error);
g_free (link_href);
@@ -165,16 +157,16 @@ gdata_documents_presentation_download_document (GDataDocumentsPresentation *self
* Since: 0.5.0
**/
gchar *
-gdata_documents_presentation_get_download_uri (GDataDocumentsPresentation *self, GDataDocumentsPresentationFormat export_format)
+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 < G_N_ELEMENTS (export_formats), 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_formats[export_format], document_id);
+ _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 024bcd1..ff6e102 100644
--- a/gdata/services/documents/gdata-documents-presentation.h
+++ b/gdata/services/documents/gdata-documents-presentation.h
@@ -28,6 +28,71 @@
G_BEGIN_DECLS
+/**
+ * GDATA_DOCUMENTS_PRESENTATION_PDF:
+ *
+ * The export format for Portable Document Format (PDF).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_PRESENTATION_PDF "pdf"
+
+/**
+ * GDATA_DOCUMENTS_PRESENTATION_PNG:
+ *
+ * The export format for Portable Network Graphics (PNG) image format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_PRESENTATION_PNG "png"
+
+/**
+ * GDATA_DOCUMENTS_PRESENTATION_PPT:
+ *
+ * The export format for Microsoft PowerPoint (PPT) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_PRESENTATION_PPT "ppt"
+
+/**
+ * GDATA_DOCUMENTS_PRESENTATION_SWF:
+ *
+ * The export format for Adobe Flash (SWF) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_PRESENTATION_SWF "swf"
+
+/**
+ * GDATA_DOCUMENTS_PRESENTATION_TXT:
+ *
+ * The export format for plain text format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_PRESENTATION_TXT "txt"
+
#define GDATA_TYPE_DOCUMENTS_PRESENTATION (gdata_documents_presentation_get_type ())
#define GDATA_DOCUMENTS_PRESENTATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_DOCUMENTS_PRESENTATION, \
GDataDocumentsPresentation))
@@ -41,26 +106,6 @@ G_BEGIN_DECLS
typedef struct _GDataDocumentsPresentationPrivate GDataDocumentsPresentationPrivate;
/**
- * GDataDocumentsPresentationFormat:
- * @GDATA_DOCUMENTS_PRESENTATION_PDF: the document in PDF format
- * @GDATA_DOCUMENTS_PRESENTATION_PNG: the document in PNG image format
- * @GDATA_DOCUMENTS_PRESENTATION_PPT: the document in Microsoft PowerPoint PPT format
- * @GDATA_DOCUMENTS_PRESENTATION_SWF: the document in Adobe Flash SWF format
- * @GDATA_DOCUMENTS_PRESENTATION_TXT: the document in text format
- *
- * The different available download formats for presentations.
- *
- * Since: 0.4.0
- **/
-typedef enum {
- GDATA_DOCUMENTS_PRESENTATION_PDF = 0,
- GDATA_DOCUMENTS_PRESENTATION_PNG,
- GDATA_DOCUMENTS_PRESENTATION_PPT,
- GDATA_DOCUMENTS_PRESENTATION_SWF,
- GDATA_DOCUMENTS_PRESENTATION_TXT
-} GDataDocumentsPresentationFormat;
-
-/**
* GDataDocumentsPresentation:
*
* All the fields in the #GDataDocumentsPresentation structure are private and should never be accessed directly.
@@ -90,11 +135,11 @@ GDataDocumentsPresentation *gdata_documents_presentation_new (const gchar *id) G
#include <gdata/services/documents/gdata-documents-service.h>
GFile *gdata_documents_presentation_download_document (GDataDocumentsPresentation *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsPresentationFormat export_format, GFile *destination_file,
+ 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,
- GDataDocumentsPresentationFormat export_format) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+ const gchar *export_format) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
G_END_DECLS
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.c b/gdata/services/documents/gdata-documents-spreadsheet.c
index 0a139b5..3b1fcf6 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.c
+++ b/gdata/services/documents/gdata-documents-spreadsheet.c
@@ -45,15 +45,6 @@
static void get_xml (GDataParsable *parsable, GString *xml_string);
-static const struct { const gchar *extension; const gchar *fmcmd; } export_formats[] = {
- { "xls", "4" }, /* GDATA_DOCUMENTS_SPREADSHEET_XLS */
- { "csv", "5" }, /* GDATA_DOCUMENTS_SPREADSHEET_CSV */
- { "pdf", "12" }, /* GDATA_DOCUMENTS_SPREADSHEET_PDF */
- { "ods", "13" }, /* GDATA_DOCUMENTS_SPREADSHEET_ODS */
- { "tsv", "23" }, /* GDATA_DOCUMENTS_SPREADSHEET_TSV */
- { "html", "102" } /* GDATA_DOCUMENTS_SPREADSHEET_HTML */
-};
-
G_DEFINE_TYPE (GDataDocumentsSpreadsheet, gdata_documents_spreadsheet, GDATA_TYPE_DOCUMENTS_ENTRY)
static void
@@ -134,33 +125,28 @@ gdata_documents_spreadsheet_new (const gchar *id)
**/
GFile *
gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsSpreadsheetFormat export_format, gint gid, GFile *destination_file,
+ const gchar *export_format, gint gid, GFile *destination_file,
gboolean replace_file_if_exists, GCancellable *cancellable, GError **error)
{
gchar *link_href;
- const gchar *extension;
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 < G_N_ELEMENTS (export_formats), 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 ((export_format != GDATA_DOCUMENTS_SPREADSHEET_CSV && export_format != GDATA_DOCUMENTS_SPREADSHEET_TSV) ||
- 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);
- extension = export_formats[export_format].extension;
-
/* 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_entry_download_document (GDATA_DOCUMENTS_ENTRY (self), spreadsheet_service, content_type,
- link_href, destination_file, extension, replace_file_if_exists,
+ link_href, destination_file, export_format, replace_file_if_exists,
cancellable, error);
g_free (link_href);
@@ -177,35 +163,32 @@ gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self,
* 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.
*
- * 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).
+ * When requesting a <code class="literal">"csv"</code>, <code class="literal">"tsv"</code>, <code class="literal">"pdf"</code> or
+ * <code class="literal">"html"</code> file you may 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).
*
* Return value: the download URI; free with g_free()
*
* Since: 0.5.0
**/
gchar *
-gdata_documents_spreadsheet_get_download_uri (GDataDocumentsSpreadsheet *self, GDataDocumentsSpreadsheetFormat export_format, gint gid)
+gdata_documents_spreadsheet_get_download_uri (GDataDocumentsSpreadsheet *self, const gchar *export_format, gint gid)
{
- const gchar *document_id, *fmcmd;
+ const gchar *document_id;
g_return_val_if_fail (GDATA_IS_DOCUMENTS_SPREADSHEET (self), NULL);
- g_return_val_if_fail (export_format < G_N_ELEMENTS (export_formats), 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 ((export_format != GDATA_DOCUMENTS_SPREADSHEET_CSV && export_format != GDATA_DOCUMENTS_SPREADSHEET_TSV) ||
- gid != -1, NULL);
document_id = gdata_documents_entry_get_document_id (GDATA_DOCUMENTS_ENTRY (self));
g_assert (document_id != NULL);
- fmcmd = export_formats[export_format].fmcmd;
-
if (gid != -1) {
- return g_strdup_printf ("%s://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&fmcmd=%s&gid=%d",
- _gdata_service_get_scheme (), document_id, fmcmd, gid);
+ return g_strdup_printf ("%s://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&exportFormat=%s&gid=%d",
+ _gdata_service_get_scheme (), document_id, export_format, gid);
} else {
- return g_strdup_printf ("%s://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&fmcmd=%s",
- _gdata_service_get_scheme (), document_id, fmcmd);
+ return g_strdup_printf ("%s://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&exportFormat=%s",
+ _gdata_service_get_scheme (), document_id, export_format);
}
}
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.h b/gdata/services/documents/gdata-documents-spreadsheet.h
index 5a7a847..8456a6b 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.h
+++ b/gdata/services/documents/gdata-documents-spreadsheet.h
@@ -28,6 +28,84 @@
G_BEGIN_DECLS
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_CSV:
+ *
+ * The export format for Comma-Separated Values (CSV) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_CSV "csv"
+
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_ODS:
+ *
+ * The export format for OpenDocument Spreadsheet (ODS) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_ODS "ods"
+
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_PDF:
+ *
+ * The export format for Portable Document Format (PDF).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_PDF "pdf"
+
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_TSV:
+ *
+ * The export format for Tab-Separated Values (TSV) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_TSV "tsv"
+
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_XLS:
+ *
+ * The export format for Microsoft Excel spreadsheet (XLS) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_XLS "xls"
+
+/**
+ * GDATA_DOCUMENTS_SPREADSHEET_HTML:
+ *
+ * The export format for HyperText Markup Language (HTML) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingSpreadsheets">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_SPREADSHEET_HTML "html"
+
#define GDATA_TYPE_DOCUMENTS_SPREADSHEET (gdata_documents_spreadsheet_get_type ())
#define GDATA_DOCUMENTS_SPREADSHEET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_DOCUMENTS_SPREADSHEET, \
GDataDocumentsSpreadsheet))
@@ -41,28 +119,6 @@ G_BEGIN_DECLS
typedef struct _GDataDocumentsSpreadsheetPrivate GDataDocumentsSpreadsheetPrivate;
/**
- * GDataDocumentsSpreadsheetFormat:
- * @GDATA_DOCUMENTS_SPREADSHEET_XLS: Microsoft Excel spreadsheet (XLS) format
- * @GDATA_DOCUMENTS_SPREADSHEET_CSV: Comma-Separated Values (CSV) format
- * @GDATA_DOCUMENTS_SPREADSHEET_PDF: Portable Document Format (PDF)
- * @GDATA_DOCUMENTS_SPREADSHEET_ODS: OpenDocument Spreadsheet (ODS) format
- * @GDATA_DOCUMENTS_SPREADSHEET_TSV: Tab-Separated Values (TSV) format
- * @GDATA_DOCUMENTS_SPREADSHEET_HTML: HyperText Markup Language (HTML) format
- *
- * The different available download formats for spreadsheets.
- *
- * Since: 0.4.0
- **/
-typedef enum {
- GDATA_DOCUMENTS_SPREADSHEET_XLS = 0,
- GDATA_DOCUMENTS_SPREADSHEET_CSV,
- GDATA_DOCUMENTS_SPREADSHEET_PDF,
- GDATA_DOCUMENTS_SPREADSHEET_ODS,
- GDATA_DOCUMENTS_SPREADSHEET_TSV,
- GDATA_DOCUMENTS_SPREADSHEET_HTML
-} GDataDocumentsSpreadsheetFormat;
-
-/**
* GDataDocumentsSpreadsheet:
*
* All the fields in the #GDataDocumentsSpreadsheet structure are private and should never be accessed directly.
@@ -93,10 +149,10 @@ GDataDocumentsSpreadsheet *gdata_documents_spreadsheet_new (const gchar *id) G_G
#include <gdata/services/documents/gdata-documents-service.h>
GFile *gdata_documents_spreadsheet_download_document (GDataDocumentsSpreadsheet *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsSpreadsheetFormat export_format, gint gid, GFile *destination_file,
+ 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, GDataDocumentsSpreadsheetFormat export_format,
+gchar *gdata_documents_spreadsheet_get_download_uri (GDataDocumentsSpreadsheet *self, const gchar *export_format,
gint gid) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
G_END_DECLS
diff --git a/gdata/services/documents/gdata-documents-text.c b/gdata/services/documents/gdata-documents-text.c
index 4b5c719..dadba8a 100644
--- a/gdata/services/documents/gdata-documents-text.c
+++ b/gdata/services/documents/gdata-documents-text.c
@@ -45,17 +45,6 @@
static void get_xml (GDataParsable *parsable, GString *xml_string);
-static const gchar *export_formats[] = {
- "doc", /* GDATA_DOCUMENTS_TEXT_DOC */
- "html", /* GDATA_DOCUMENTS_TEXT_HTML */
- "odt", /* GDATA_DOCUMENTS_TEXT_ODT */
- "pdf", /* GDATA_DOCUMENTS_TEXT_PDF */
- "png", /* GDATA_DOCUMENTS_TEXT_PNG */
- "rtf", /* GDATA_DOCUMENTS_TEXT_RTF */
- "txt", /* GDATA_DOCUMENTS_TEXT_TXT */
- "zip" /* GDATA_DOCUMENTS_TEXT_ZIP */
-};
-
G_DEFINE_TYPE (GDataDocumentsText, gdata_documents_text, GDATA_TYPE_DOCUMENTS_ENTRY)
static void
@@ -131,14 +120,14 @@ gdata_documents_text_new (const gchar *id)
**/
GFile *
gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsTextFormat export_format, GFile *destination_file,
+ 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 < G_N_ELEMENTS (export_formats), 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);
@@ -146,7 +135,7 @@ gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocuments
/* Download the file */
link_href = gdata_documents_text_get_download_uri (self, export_format);
destination_file = _gdata_documents_entry_download_document (GDATA_DOCUMENTS_ENTRY (self), GDATA_SERVICE (service),
- content_type, link_href, destination_file, export_formats[export_format],
+ content_type, link_href, destination_file, export_format,
replace_file_if_exists, cancellable, error);
g_free (link_href);
@@ -167,16 +156,16 @@ gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocuments
* Since: 0.5.0
**/
gchar *
-gdata_documents_text_get_download_uri (GDataDocumentsText *self, GDataDocumentsTextFormat export_format)
+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 < G_N_ELEMENTS (export_formats), 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_formats[export_format], document_id);
+ _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 1f5d10b..0593aec 100644
--- a/gdata/services/documents/gdata-documents-text.h
+++ b/gdata/services/documents/gdata-documents-text.h
@@ -28,6 +28,110 @@
G_BEGIN_DECLS
+/**
+ * GDATA_DOCUMENTS_TEXT_DOC:
+ *
+ * The export format for Microsoft Word (DOC) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_DOC "doc"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_HTML:
+ *
+ * The export format for HyperText Markup Language (HTML) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_HTML "html"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_ODT:
+ *
+ * The export format for OpenDocument Text (ODT) format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_ODT "odt"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_PDF:
+ *
+ * The export format for Portable Document Format (PDF).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_PDF "pdf"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_PNG:
+ *
+ * The export format for Portable Network Graphics (PNG) image format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_PNG "png"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_RTF:
+ *
+ * The export format for Rich Text Format (RTF).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_RTF "rtf"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_TXT:
+ *
+ * The export format for plain text format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_TXT "txt"
+
+/**
+ * GDATA_DOCUMENTS_TEXT_ZIP:
+ *
+ * The export format for a ZIP archive containing images and exported HTML.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.7.0
+ **/
+#define GDATA_DOCUMENTS_TEXT_ZIP "zip"
+
#define GDATA_TYPE_DOCUMENTS_TEXT (gdata_documents_text_get_type ())
#define GDATA_DOCUMENTS_TEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_DOCUMENTS_TEXT, GDataDocumentsText))
#define GDATA_DOCUMENTS_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_DOCUMENTS_TEXT, GDataDocumentsTextClass))
@@ -38,32 +142,6 @@ G_BEGIN_DECLS
typedef struct _GDataDocumentsTextPrivate GDataDocumentsTextPrivate;
/**
- * GDataDocumentsTextFormat:
- * @GDATA_DOCUMENTS_TEXT_DOC: Microsoft Word (DOC) format
- * @GDATA_DOCUMENTS_TEXT_HTML: HyperText Markup Language (HTML) format
- * @GDATA_DOCUMENTS_TEXT_ODT: OpenDocument Text (ODT) format
- * @GDATA_DOCUMENTS_TEXT_PDF: Portable Document Format (PDF)
- * @GDATA_DOCUMENTS_TEXT_PNG: Portable Network Graphics (PNG) image format
- * @GDATA_DOCUMENTS_TEXT_RTF: Rich Text Format (RTF)
- * @GDATA_DOCUMENTS_TEXT_TXT: plain text format
- * @GDATA_DOCUMENTS_TEXT_ZIP: ZIP archive containing images and exported HTML
- *
- * The different available download formats for text documents.
- *
- * Since: 0.4.0
- **/
-typedef enum {
- GDATA_DOCUMENTS_TEXT_DOC = 0,
- GDATA_DOCUMENTS_TEXT_HTML,
- GDATA_DOCUMENTS_TEXT_ODT,
- GDATA_DOCUMENTS_TEXT_PDF,
- GDATA_DOCUMENTS_TEXT_PNG,
- GDATA_DOCUMENTS_TEXT_RTF,
- GDATA_DOCUMENTS_TEXT_TXT,
- GDATA_DOCUMENTS_TEXT_ZIP,
-} GDataDocumentsTextFormat;
-
-/**
* GDataDocumentsText:
*
* All the fields in the #GDataDocumentsText structure are private and should never be accessed directly.
@@ -94,11 +172,10 @@ GDataDocumentsText *gdata_documents_text_new (const gchar *id) G_GNUC_WARN_UNUSE
#include <gdata/services/documents/gdata-documents-service.h>
GFile *gdata_documents_text_download_document (GDataDocumentsText *self, GDataDocumentsService *service, gchar **content_type,
- GDataDocumentsTextFormat export_format, GFile *destination_file,
+ 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,
- GDataDocumentsTextFormat export_format) 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]