[libgdata] Add support for PDF files



commit 0fd7b768d14350854db00ad393ddc33e05681e1a
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Feb 16 09:14:38 2013 -0500

    Add support for PDF files
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693958

 Makefile.am                                        |    4 +-
 docs/reference/gdata-docs.xml                      |    1 +
 docs/reference/gdata-sections.txt                  |   18 +++++
 gdata/gdata.h                                      |    1 +
 gdata/gdata.symbols                                |    2 +
 .../services/documents/gdata-documents-document.c  |    4 +-
 gdata/services/documents/gdata-documents-entry.c   |    2 +-
 gdata/services/documents/gdata-documents-feed.c    |    3 +
 gdata/services/documents/gdata-documents-pdf.c     |   72 ++++++++++++++++++++
 gdata/services/documents/gdata-documents-pdf.h     |   71 +++++++++++++++++++
 gdata/services/documents/gdata-documents-service.c |    3 +
 11 files changed, 177 insertions(+), 4 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0c2368d..2cb013d 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-drawing.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-pdf.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 \" }," \
@@ -261,6 +261,7 @@ gdata_documents_headers = \
        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-pdf.h          \
        gdata/services/documents/gdata-documents-spreadsheet.h  \
        gdata/services/documents/gdata-documents-upload-query.h
 gdatadocumentsinclude_HEADERS = \
@@ -378,6 +379,7 @@ gdata_sources = \
        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-pdf.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 8d146fc..a9dfc15 100644
--- a/docs/reference/gdata-docs.xml
+++ b/docs/reference/gdata-docs.xml
@@ -159,6 +159,7 @@
                        <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-pdf.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 211b67e..103bf9c 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1765,6 +1765,24 @@ GDataDocumentsDrawingPrivate
 </SECTION>
 
 <SECTION>
+<FILE>gdata-documents-pdf</FILE>
+<TITLE>GDataDocumentsPdf</TITLE>
+GDataDocumentsPdf
+GDataDocumentsPdfClass
+gdata_documents_pdf_new
+<SUBSECTION Standard>
+gdata_documents_pdf_get_type
+GDATA_DOCUMENTS_PDF
+GDATA_DOCUMENTS_PDF_CLASS
+GDATA_DOCUMENTS_PDF_GET_CLASS
+GDATA_IS_DOCUMENTS_PDF
+GDATA_IS_DOCUMENTS_PDF_CLASS
+GDATA_TYPE_DOCUMENTS_PDF
+<SUBSECTION Private>
+GDataDocumentsPdfPrivate
+</SECTION>
+
+<SECTION>
 <FILE>gdata-documents-service</FILE>
 <TITLE>GDataDocumentsService</TITLE>
 GDataDocumentsService
diff --git a/gdata/gdata.h b/gdata/gdata.h
index 2039750..7720508 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -133,6 +133,7 @@
 #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-pdf.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 5d8c7ba..f073ad2 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -608,6 +608,8 @@ gdata_documents_presentation_get_type
 gdata_documents_presentation_new
 gdata_documents_drawing_get_type
 gdata_documents_drawing_new
+gdata_documents_pdf_get_type
+gdata_documents_pdf_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 b4b4a69..71b918f 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, drawing or spreadsheet). It is subclassed by 
#GDataDocumentsPresentation, #GDataDocumentsText,
- * #GDataDocumentsDrawing and #GDataDocumentsSpreadsheet, which represent those specific types of Google 
Document, respectively.
+ * isn't a Google Documents presentation, text document, PDF, drawing or spreadsheet). It is subclassed by 
#GDataDocumentsPresentation, #GDataDocumentsText,
+ * #GDataDocumentsPdf,  #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-entry.c 
b/gdata/services/documents/gdata-documents-entry.c
index 1ea3222..5f03e22 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|drawing|spreadsheet|presentation|folder</replaceable>:<replaceable>untyped 
resource ID</replaceable></literal>; whereas
+        * 
<literal><replaceable>document|drawing|pdf|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 bd02386..4f32db9 100644
--- a/gdata/services/documents/gdata-documents-feed.c
+++ b/gdata/services/documents/gdata-documents-feed.c
@@ -46,6 +46,7 @@
 #include "gdata-documents-presentation.h"
 #include "gdata-documents-folder.h"
 #include "gdata-documents-drawing.h"
+#include "gdata-documents-pdf.h"
 #include "gdata-types.h"
 #include "gdata-private.h"
 #include "gdata-service.h"
@@ -112,6 +113,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
                        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 if (g_strcmp0 (kind, "http://schemas.google.com/docs/2007#pdf";) == 0) {
+                       entry_type = GDATA_TYPE_DOCUMENTS_PDF;
                } else {
                        g_message ("%s documents are not handled yet", kind);
                        g_free (kind);
diff --git a/gdata/services/documents/gdata-documents-pdf.c b/gdata/services/documents/gdata-documents-pdf.c
new file mode 100644
index 0000000..e4035a4
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-pdf.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-pdf
+ * @short_description: GData Documents pdf object
+ * @stability: Unstable
+ * @include: gdata/services/documents/gdata-documents-pdf.h
+ *
+ * #GDataDocumentsPdf is a subclass of #GDataDocumentsDocument to represent a PDF 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.3
+ **/
+
+#include <config.h>
+#include <glib.h>
+
+#include "gdata-documents-pdf.h"
+#include "gdata-parser.h"
+
+G_DEFINE_TYPE (GDataDocumentsPdf, gdata_documents_pdf, GDATA_TYPE_DOCUMENTS_DOCUMENT)
+
+static void
+gdata_documents_pdf_class_init (GDataDocumentsPdfClass *klass)
+{
+       GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
+
+       entry_class->kind_term = "http://schemas.google.com/docs/2007#pdf";;
+}
+
+static void
+gdata_documents_pdf_init (GDataDocumentsPdf *self)
+{
+       /* Why am I writing it? */
+}
+
+/**
+ * gdata_documents_pdf_new:
+ * @id: (allow-none): the entry's ID (not the document ID of the pdf document), or %NULL
+ *
+ * Creates a new #GDataDocumentsPdf with the given entry ID (#GDataEntry:id).
+ *
+ * Return value: (transfer full): a new #GDataDocumentsPdf, or %NULL; unref with g_object_unref()
+ *
+ * Since: 0.13.3
+ **/
+GDataDocumentsPdf *
+gdata_documents_pdf_new (const gchar *id)
+{
+       return GDATA_DOCUMENTS_PDF (g_object_new (GDATA_TYPE_DOCUMENTS_PDF, "id", id, NULL));
+}
diff --git a/gdata/services/documents/gdata-documents-pdf.h b/gdata/services/documents/gdata-documents-pdf.h
new file mode 100644
index 0000000..4600fc7
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-pdf.h
@@ -0,0 +1,71 @@
+/* -*- 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_PDF_H
+#define GDATA_DOCUMENTS_PDF_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/services/documents/gdata-documents-document.h>
+
+G_BEGIN_DECLS
+
+#define GDATA_TYPE_DOCUMENTS_PDF               (gdata_documents_pdf_get_type ())
+#define GDATA_DOCUMENTS_PDF(o)         (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_DOCUMENTS_PDF, 
GDataDocumentsPdf))
+#define GDATA_DOCUMENTS_PDF_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_DOCUMENTS_PDF, 
GDataDocumentsPdfClass))
+#define GDATA_IS_DOCUMENTS_PDF(o)              (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDATA_TYPE_DOCUMENTS_PDF))
+#define GDATA_IS_DOCUMENTS_PDF_CLASS(k)        (G_TYPE_CHECK_CLASS_TYPE ((k), GDATA_TYPE_DOCUMENTS_PDF))
+#define GDATA_DOCUMENTS_PDF_GET_CLASS(o)       (G_TYPE_INSTANCE_GET_CLASS ((o), GDATA_TYPE_DOCUMENTS_PDF, 
GDataDocumentsPdfClass))
+
+typedef struct _GDataDocumentsPdfPrivate       GDataDocumentsPdfPrivate;
+
+/**
+ * GDataDocumentsPdf:
+ *
+ * All the fields in the #GDataDocumentsPdf structure are private and should never be accessed directly.
+ *
+ * Since: 0.13.3
+ **/
+typedef struct {
+       GDataDocumentsDocument parent;
+       GDataDocumentsPdfPrivate *priv;
+} GDataDocumentsPdf;
+
+/**
+ * GDataDocumentsPdfClass:
+ *
+ * All the fields in the #GDataDocumentsPdfClass structure are private and should never be accessed directly.
+ *
+ * Since: 0.13.3
+ **/
+typedef struct {
+       /*< private >*/
+       GDataDocumentsDocumentClass parent;
+} GDataDocumentsPdfClass;
+
+GType gdata_documents_pdf_get_type (void) G_GNUC_CONST;
+
+GDataDocumentsPdf *gdata_documents_pdf_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_PDF_H */
diff --git a/gdata/services/documents/gdata-documents-service.c 
b/gdata/services/documents/gdata-documents-service.c
index 81eb19c..20d82f1 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -258,6 +258,7 @@
 #include "gdata-documents-spreadsheet.h"
 #include "gdata-documents-text.h"
 #include "gdata-documents-drawing.h"
+#include "gdata-documents-pdf.h"
 #include "gdata-documents-presentation.h"
 #include "gdata-batchable.h"
 #include "gdata-service.h"
@@ -877,6 +878,8 @@ gdata_documents_service_finish_upload (GDataDocumentsService *self, GDataUploadS
                new_document_type = GDATA_TYPE_DOCUMENTS_TEXT;
        } else if (g_str_has_prefix (term_pos, "drawing'") == TRUE) {
                new_document_type = GDATA_TYPE_DOCUMENTS_DRAWING;
+       } else if (g_str_has_prefix (term_pos, "pdf'") == TRUE) {
+               new_document_type = GDATA_TYPE_DOCUMENTS_PDF;
        }
 
 done:


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