[libgdata] documents: add support for Google Drawings
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] documents: add support for Google Drawings
- Date: Mon, 25 Jun 2012 18:48:13 +0000 (UTC)
commit 09d594d6aad97c8a2f7d0d8b0beae159bc797f95
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Jun 23 13:09:04 2012 -0400
documents: add support for Google Drawings
Add a GDataDocumentsDocument subclass to handle drawing docs.
https://bugzilla.gnome.org/show_bug.cgi?id=633548
Makefile.am | 4 +-
docs/reference/gdata-docs.xml | 1 +
docs/reference/gdata-sections.txt | 22 ++++
gdata/gdata.h | 1 +
gdata/gdata.symbols | 2 +
.../services/documents/gdata-documents-document.c | 4 +-
gdata/services/documents/gdata-documents-drawing.c | 72 +++++++++++
gdata/services/documents/gdata-documents-drawing.h | 124 ++++++++++++++++++++
gdata/services/documents/gdata-documents-entry.c | 2 +-
gdata/services/documents/gdata-documents-feed.c | 3 +
gdata/services/documents/gdata-documents-service.c | 3 +
11 files changed, 234 insertions(+), 4 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8a63c23..0e9053c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,7 +86,7 @@ gdata/services/documents/gdata-documents-enums.h: $(gdata_documents_headers) Mak
gdata/services/documents/gdata-documents-enums.c: $(gdata_documents_headers) Makefile gdata/services/documents/gdata-documents-enums.h
$(AM_V_GEN)($(GLIB_MKENUMS) \
- --fhead "#include \"gdata-documents-service.h\"\n#include \"gdata-documents-text.h\"\n#include \"gdata-documents-spreadsheet.h\"\n#include \"gdata-documents-presentation.h\"\n#include \"gdata-documents-enums.h\"" \
+ --fhead "#include \"gdata-documents-service.h\"\n#include \"gdata-documents-text.h\"\n#include \"gdata-documents-spreadsheet.h\"\n#include \"gdata-documents-drawing.h\"\n#include \"gdata-documents-presentation.h\"\n#include \"gdata-documents-enums.h\"" \
--fprod "\n/* enumerations from \"@filename \" */" \
--vhead "GType\n enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
@@ -253,6 +253,7 @@ gdata_documents_headers = \
gdata/services/documents/gdata-documents-text.h \
gdata/services/documents/gdata-documents-presentation.h \
gdata/services/documents/gdata-documents-folder.h \
+ gdata/services/documents/gdata-documents-drawing.h \
gdata/services/documents/gdata-documents-spreadsheet.h \
gdata/services/documents/gdata-documents-upload-query.h
gdatadocumentsinclude_HEADERS = \
@@ -369,6 +370,7 @@ gdata_sources = \
gdata/services/documents/gdata-documents-presentation.c \
gdata/services/documents/gdata-documents-spreadsheet.c \
gdata/services/documents/gdata-documents-folder.c \
+ gdata/services/documents/gdata-documents-drawing.c \
gdata/services/documents/gdata-documents-query.c \
gdata/services/documents/gdata-documents-upload-query.c \
\
diff --git a/docs/reference/gdata-docs.xml b/docs/reference/gdata-docs.xml
index 4688758..d0f5884 100644
--- a/docs/reference/gdata-docs.xml
+++ b/docs/reference/gdata-docs.xml
@@ -157,6 +157,7 @@
<xi:include href="xml/gdata-documents-entry.xml"/>
<xi:include href="xml/gdata-documents-document.xml"/>
<xi:include href="xml/gdata-documents-folder.xml"/>
+ <xi:include href="xml/gdata-documents-drawing.xml"/>
<xi:include href="xml/gdata-documents-presentation.xml"/>
<xi:include href="xml/gdata-documents-spreadsheet.xml"/>
<xi:include href="xml/gdata-documents-text.xml"/>
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index ea3f4ff..3fb2da3 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1742,6 +1742,28 @@ GDataDocumentsTextPrivate
</SECTION>
<SECTION>
+<FILE>gdata-documents-drawing</FILE>
+<TITLE>GDataDocumentsDrawing</TITLE>
+GDATA_DOCUMENTS_DRAWING_JPEG
+GDATA_DOCUMENTS_DRAWING_PDF
+GDATA_DOCUMENTS_DRAWING_PNG
+GDATA_DOCUMENTS_DRAWING_SVG
+GDataDocumentsDrawing
+GDataDocumentsDrawingClass
+gdata_documents_drawing_new
+<SUBSECTION Standard>
+gdata_documents_drawing_get_type
+GDATA_DOCUMENTS_DRAWING
+GDATA_DOCUMENTS_DRAWING_CLASS
+GDATA_DOCUMENTS_DRAWING_GET_CLASS
+GDATA_IS_DOCUMENTS_DRAWING
+GDATA_IS_DOCUMENTS_DRAWING_CLASS
+GDATA_TYPE_DOCUMENTS_DRAWING
+<SUBSECTION Private>
+GDataDocumentsDrawingPrivate
+</SECTION>
+
+<SECTION>
<FILE>gdata-documents-service</FILE>
<TITLE>GDataDocumentsService</TITLE>
GDataDocumentsService
diff --git a/gdata/gdata.h b/gdata/gdata.h
index 5fbe4bf..d0f2537 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -128,6 +128,7 @@
#include <gdata/services/documents/gdata-documents-query.h>
#include <gdata/services/documents/gdata-documents-service.h>
#include <gdata/services/documents/gdata-documents-feed.h>
+#include <gdata/services/documents/gdata-documents-drawing.h>
#include <gdata/services/documents/gdata-documents-enums.h>
#include <gdata/services/documents/gdata-documents-upload-query.h>
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index f7f7b83..012df7c 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -606,6 +606,8 @@ gdata_picasaweb_query_set_location
gdata_picasaweb_visibility_get_type
gdata_documents_presentation_get_type
gdata_documents_presentation_new
+gdata_documents_drawing_get_type
+gdata_documents_drawing_new
gdata_documents_text_get_type
gdata_documents_text_new
gdata_documents_spreadsheet_get_type
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index c9a75d5..d8649f4 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -24,8 +24,8 @@
* @include: gdata/services/documents/gdata-documents-document.h
*
* #GDataDocumentsDocument is a subclass of #GDataDocumentsEntry to represent an arbitrary Google Documents document (i.e. an arbitrary file which
- * isn't a Google Documents presentation, text document or spreadsheet). It is subclassed by #GDataDocumentsPresentation, #GDataDocumentsText and
- * #GDataDocumentsSpreadsheet, which represent those specific types of Google Document, respectively.
+ * isn't a Google Documents presentation, text document, drawing or spreadsheet). It is subclassed by #GDataDocumentsPresentation, #GDataDocumentsText,
+ * #GDataDocumentsDrawing and #GDataDocumentsSpreadsheet, which represent those specific types of Google Document, respectively.
*
* #GDataDocumentsDocument used to be abstract, but was made instantiable in version 0.13.0 to allow for arbitrary file uploads. This can be achieved
* by setting #GDataDocumentsUploadQuery:convert to %FALSE when making an upload using gdata_documents_service_upload_document_resumable(). See the
diff --git a/gdata/services/documents/gdata-documents-drawing.c b/gdata/services/documents/gdata-documents-drawing.c
new file mode 100644
index 0000000..7f87b93
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drawing.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Thibault Saunier 2009 <saunierthibault gmail com>
+ * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
+ * Copyright (C) Cosimo Cecchi 2012 <cosimoc gnome org>
+ *
+ * GData Client is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GData Client is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * SECTION:gdata-documents-drawing
+ * @short_description: GData Documents drawing object
+ * @stability: Unstable
+ * @include: gdata/services/documents/gdata-documents-drawing.h
+ *
+ * #GDataDocumentsDrawing is a subclass of #GDataDocumentsDocument to represent a drawing document from Google Documents.
+ *
+ * For more details of Google Documents' GData API, see the
+ * <ulink type="http" url="https://developers.google.com/google-apps/documents-list/">online documentation</ulink>.
+ *
+ * Since: 0.13.1
+ **/
+
+#include <config.h>
+#include <glib.h>
+
+#include "gdata-documents-drawing.h"
+#include "gdata-parser.h"
+
+G_DEFINE_TYPE (GDataDocumentsDrawing, gdata_documents_drawing, GDATA_TYPE_DOCUMENTS_DOCUMENT)
+
+static void
+gdata_documents_drawing_class_init (GDataDocumentsDrawingClass *klass)
+{
+ GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
+
+ entry_class->kind_term = "http://schemas.google.com/docs/2007#drawing";
+}
+
+static void
+gdata_documents_drawing_init (GDataDocumentsDrawing *self)
+{
+ /* Why am I writing it? */
+}
+
+/**
+ * gdata_documents_drawing_new:
+ * @id: (allow-none): the entry's ID (not the document ID of the drawing document), or %NULL
+ *
+ * Creates a new #GDataDocumentsDrawing with the given entry ID (#GDataEntry:id).
+ *
+ * Return value: (transfer full): a new #GDataDocumentsDrawing, or %NULL; unref with g_object_unref()
+ *
+ * Since: 0.13.1
+ **/
+GDataDocumentsDrawing *
+gdata_documents_drawing_new (const gchar *id)
+{
+ return GDATA_DOCUMENTS_DRAWING (g_object_new (GDATA_TYPE_DOCUMENTS_DRAWING, "id", id, NULL));
+}
diff --git a/gdata/services/documents/gdata-documents-drawing.h b/gdata/services/documents/gdata-documents-drawing.h
new file mode 100644
index 0000000..bcda025
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drawing.h
@@ -0,0 +1,124 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Thibault Saunier 2009 <saunierthibault gmail com>
+ * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
+ * Copyright (C) Cosimo Cecchi 2012 <cosimoc gnome org>
+ *
+ * GData Client is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GData Client is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GDATA_DOCUMENTS_DRAWING_H
+#define GDATA_DOCUMENTS_DRAWING_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/services/documents/gdata-documents-document.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GDATA_DOCUMENTS_DRAWING_JPEG:
+ *
+ * The export format for JPEG image format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="https://developers.google.com/google-apps/documents-list/#valid_download_formats_for_drawings">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.13.1
+ */
+#define GDATA_DOCUMENTS_DRAWING_JPEG "jpeg"
+
+/**
+ * GDATA_DOCUMENTS_DRAWING_PDF:
+ *
+ * The export format for Portable Document Format (PDF).
+ *
+ * For more information, see the
+ * <ulink type="http" url="https://developers.google.com/google-apps/documents-list/#valid_download_formats_for_drawings">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.13.1
+ **/
+#define GDATA_DOCUMENTS_DRAWING_PDF "pdf"
+
+/**
+ * GDATA_DOCUMENTS_DRAWING_PNG:
+ *
+ * The export format for Portable Network Graphics (PNG) image format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="https://developers.google.com/google-apps/documents-list/#valid_download_formats_for_drawings">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.13.1
+ **/
+#define GDATA_DOCUMENTS_DRAWING_PNG "png"
+
+/**
+ * GDATA_DOCUMENTS_DRAWING_SVG:
+ *
+ * The export format for Scalable Vector Graphics (SVG) image format.
+ *
+ * For more information, see the
+ * <ulink type="http" url="https://developers.google.com/google-apps/documents-list/#valid_download_formats_for_drawings">
+ * GData protocol specification</ulink>.
+ *
+ * Since: 0.13.1
+ **/
+#define GDATA_DOCUMENTS_DRAWING_SVG "svg"
+
+
+#define GDATA_TYPE_DOCUMENTS_DRAWING (gdata_documents_drawing_get_type ())
+#define GDATA_DOCUMENTS_DRAWING(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_DOCUMENTS_DRAWING, GDataDocumentsDrawing))
+#define GDATA_DOCUMENTS_DRAWING_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_DOCUMENTS_DRAWING, GDataDocumentsDrawingClass))
+#define GDATA_IS_DOCUMENTS_DRAWING(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDATA_TYPE_DOCUMENTS_DRAWING))
+#define GDATA_IS_DOCUMENTS_DRAWING_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDATA_TYPE_DOCUMENTS_DRAWING))
+#define GDATA_DOCUMENTS_DRAWING_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDATA_TYPE_DOCUMENTS_DRAWING, GDataDocumentsDrawingClass))
+
+typedef struct _GDataDocumentsDrawingPrivate GDataDocumentsDrawingPrivate;
+
+/**
+ * GDataDocumentsDrawing:
+ *
+ * All the fields in the #GDataDocumentsDrawing structure are private and should never be accessed directly.
+ *
+ * Since: 0.13.1
+ **/
+typedef struct {
+ GDataDocumentsDocument parent;
+ GDataDocumentsDrawingPrivate *priv;
+} GDataDocumentsDrawing;
+
+/**
+ * GDataDocumentsDrawingClass:
+ *
+ * All the fields in the #GDataDocumentsDrawingClass structure are private and should never be accessed directly.
+ *
+ * Since: 0.13.1
+ **/
+typedef struct {
+ /*< private >*/
+ GDataDocumentsDocumentClass parent;
+} GDataDocumentsDrawingClass;
+
+GType gdata_documents_drawing_get_type (void) G_GNUC_CONST;
+
+GDataDocumentsDrawing *gdata_documents_drawing_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_DRAWING_H */
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index bf0bc12..1ea3222 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -233,7 +233,7 @@ gdata_documents_entry_class_init (GDataDocumentsEntryClass *klass)
* identify a given document or folder, use its #GDataEntry:id.
*
* Resource IDs have the form:
- * <literal><replaceable>document|spreadsheet|presentation|folder</replaceable>:<replaceable>untyped resource ID</replaceable></literal>; whereas
+ * <literal><replaceable>document|drawing|spreadsheet|presentation|folder</replaceable>:<replaceable>untyped resource ID</replaceable></literal>; whereas
* entry IDs have the form:
* <literal>https://docs.google.com/feeds/id/<replaceable>resource ID</replaceable></literal> in version 3 of the API.
*
diff --git a/gdata/services/documents/gdata-documents-feed.c b/gdata/services/documents/gdata-documents-feed.c
index 882e852..bd02386 100644
--- a/gdata/services/documents/gdata-documents-feed.c
+++ b/gdata/services/documents/gdata-documents-feed.c
@@ -45,6 +45,7 @@
#include "gdata-documents-text.h"
#include "gdata-documents-presentation.h"
#include "gdata-documents-folder.h"
+#include "gdata-documents-drawing.h"
#include "gdata-types.h"
#include "gdata-private.h"
#include "gdata-service.h"
@@ -109,6 +110,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
entry_type = GDATA_TYPE_DOCUMENTS_FOLDER;
} else if (g_strcmp0 (kind, "http://schemas.google.com/docs/2007#file") == 0) {
entry_type = GDATA_TYPE_DOCUMENTS_DOCUMENT;
+ } else if (g_strcmp0 (kind, "http://schemas.google.com/docs/2007#drawing") == 0) {
+ entry_type = GDATA_TYPE_DOCUMENTS_DRAWING;
} else {
g_message ("%s documents are not handled yet", kind);
g_free (kind);
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index 5e5f160..c806ddd 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -257,6 +257,7 @@
#include "gdata-documents-service.h"
#include "gdata-documents-spreadsheet.h"
#include "gdata-documents-text.h"
+#include "gdata-documents-drawing.h"
#include "gdata-documents-presentation.h"
#include "gdata-batchable.h"
#include "gdata-service.h"
@@ -874,6 +875,8 @@ gdata_documents_service_finish_upload (GDataDocumentsService *self, GDataUploadS
new_document_type = GDATA_TYPE_DOCUMENTS_PRESENTATION;
} else if (g_str_has_prefix (term_pos, "document'") == TRUE) {
new_document_type = GDATA_TYPE_DOCUMENTS_TEXT;
+ } else if (g_str_has_prefix (term_pos, "drawing'") == TRUE) {
+ new_document_type = GDATA_TYPE_DOCUMENTS_DRAWING;
}
done:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]