[libgdata/wip/rishi/drive: 3/8] documents: Set the content type for GDataDocumentsDocument sub-classes



commit a0d7e39a31cceac21f14035f7f1a47dbb2118903
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Sep 21 19:19:20 2016 +0200

    documents: Set the content type for GDataDocumentsDocument sub-classes
    
    In Drive v2, every GDataDocumentsDocument sub-class is tied to a
    specific content type. Except PDFs, these are the Drive-specific
    application/vnd.google-apps.* types. This is unlike the older
    Documents v3 API, where you could create a GDataDocumentsDocument to
    represent a random ODF on the hard disk, and the server would interpret
    it as a GDataDocumentsText instance.
    
    Therefore, we should ensure that instances of these sub-classes have
    the corresponding content type attached to them. Otherwise, they will
    be identified as application/octet-stream and exportLinks will be
    missing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684920

 gdata/services/documents/gdata-documents-drawing.c |   16 ++++++++++++++++
 gdata/services/documents/gdata-documents-pdf.c     |   16 ++++++++++++++++
 .../documents/gdata-documents-presentation.c       |   16 ++++++++++++++++
 .../documents/gdata-documents-spreadsheet.c        |   15 +++++++++++++++
 gdata/services/documents/gdata-documents-text.c    |   16 ++++++++++++++++
 5 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-drawing.c 
b/gdata/services/documents/gdata-documents-drawing.c
index b9ce55f..33c1a9f 100644
--- a/gdata/services/documents/gdata-documents-drawing.c
+++ b/gdata/services/documents/gdata-documents-drawing.c
@@ -4,6 +4,7 @@
  * 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>
+ * Copyright (C) Red Hat, Inc. 2016
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,15 +38,21 @@
 #include <glib.h>
 
 #include "gdata-documents-drawing.h"
+#include "gdata-documents-utils.h"
 #include "gdata-parser.h"
+#include "gdata-private.h"
+
+static void gdata_documents_drawing_constructed (GObject *object);
 
 G_DEFINE_TYPE (GDataDocumentsDrawing, gdata_documents_drawing, GDATA_TYPE_DOCUMENTS_DOCUMENT)
 
 static void
 gdata_documents_drawing_class_init (GDataDocumentsDrawingClass *klass)
 {
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
+       gobject_class->constructed = gdata_documents_drawing_constructed;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#drawing";;
 }
 
@@ -55,6 +62,15 @@ gdata_documents_drawing_init (GDataDocumentsDrawing *self)
        /* Why am I writing it? */
 }
 
+static void
+gdata_documents_drawing_constructed (GObject *object)
+{
+       G_OBJECT_CLASS (gdata_documents_drawing_parent_class)->constructed (object);
+
+       if (!_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)))
+               gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), 
"application/vnd.google-apps.drawing");
+}
+
 /**
  * gdata_documents_drawing_new:
  * @id: (allow-none): the entry's ID (not the document ID of the drawing document), or %NULL
diff --git a/gdata/services/documents/gdata-documents-pdf.c b/gdata/services/documents/gdata-documents-pdf.c
index e3b08f0..fd55fc8 100644
--- a/gdata/services/documents/gdata-documents-pdf.c
+++ b/gdata/services/documents/gdata-documents-pdf.c
@@ -4,6 +4,7 @@
  * 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>
+ * Copyright (C) Red Hat, Inc. 2016
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,15 +38,21 @@
 #include <glib.h>
 
 #include "gdata-documents-pdf.h"
+#include "gdata-documents-utils.h"
 #include "gdata-parser.h"
+#include "gdata-private.h"
+
+static void gdata_documents_pdf_constructed (GObject *object);
 
 G_DEFINE_TYPE (GDataDocumentsPdf, gdata_documents_pdf, GDATA_TYPE_DOCUMENTS_DOCUMENT)
 
 static void
 gdata_documents_pdf_class_init (GDataDocumentsPdfClass *klass)
 {
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
+       gobject_class->constructed = gdata_documents_pdf_constructed;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#pdf";;
 }
 
@@ -55,6 +62,15 @@ gdata_documents_pdf_init (GDataDocumentsPdf *self)
        /* Why am I writing it? */
 }
 
+static void
+gdata_documents_pdf_constructed (GObject *object)
+{
+       G_OBJECT_CLASS (gdata_documents_pdf_parent_class)->constructed (object);
+
+       if (!_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)))
+               gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), "application/pdf");
+}
+
 /**
  * gdata_documents_pdf_new:
  * @id: (allow-none): the entry's ID (not the document ID of the pdf document), or %NULL
diff --git a/gdata/services/documents/gdata-documents-presentation.c 
b/gdata/services/documents/gdata-documents-presentation.c
index f08d361..e252d2c 100644
--- a/gdata/services/documents/gdata-documents-presentation.c
+++ b/gdata/services/documents/gdata-documents-presentation.c
@@ -3,6 +3,7 @@
  * GData Client
  * Copyright (C) Thibault Saunier 2009 <saunierthibault gmail com>
  * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
+ * Copyright (C) Red Hat, Inc. 2016
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -36,15 +37,21 @@
 #include <glib.h>
 
 #include "gdata-documents-presentation.h"
+#include "gdata-documents-utils.h"
 #include "gdata-parser.h"
+#include "gdata-private.h"
+
+static void gdata_documents_presentation_constructed (GObject *object);
 
 G_DEFINE_TYPE (GDataDocumentsPresentation, gdata_documents_presentation, GDATA_TYPE_DOCUMENTS_DOCUMENT)
 
 static void
 gdata_documents_presentation_class_init (GDataDocumentsPresentationClass *klass)
 {
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
+       gobject_class->constructed = gdata_documents_presentation_constructed;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#presentation";;
 }
 
@@ -54,6 +61,15 @@ gdata_documents_presentation_init (GDataDocumentsPresentation *self)
        /* Why am I writing it? */
 }
 
+static void
+gdata_documents_presentation_constructed (GObject *object)
+{
+       G_OBJECT_CLASS (gdata_documents_presentation_parent_class)->constructed (object);
+
+       if (!_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)))
+               gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), 
"application/vnd.google-apps.presentation");
+}
+
 /**
  * gdata_documents_presentation_new:
  * @id: (allow-none): the entry's ID (not the document ID of the presentation), or %NULL
diff --git a/gdata/services/documents/gdata-documents-spreadsheet.c 
b/gdata/services/documents/gdata-documents-spreadsheet.c
index 4cadc7d..ee794a7 100644
--- a/gdata/services/documents/gdata-documents-spreadsheet.c
+++ b/gdata/services/documents/gdata-documents-spreadsheet.c
@@ -3,6 +3,7 @@
  * GData Client
  * Copyright (C) Thibault Saunier 2009 <saunierthibault gmail com>
  * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
+ * Copyright (C) Red Hat, Inc. 2016
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -93,16 +94,21 @@
 #include <string.h>
 
 #include "gdata-documents-spreadsheet.h"
+#include "gdata-documents-utils.h"
 #include "gdata-parser.h"
 #include "gdata-private.h"
 
+static void gdata_documents_spreadsheet_constructed (GObject *object);
+
 G_DEFINE_TYPE (GDataDocumentsSpreadsheet, gdata_documents_spreadsheet, GDATA_TYPE_DOCUMENTS_DOCUMENT)
 
 static void
 gdata_documents_spreadsheet_class_init (GDataDocumentsSpreadsheetClass *klass)
 {
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
+       gobject_class->constructed = gdata_documents_spreadsheet_constructed;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#spreadsheet";;
 }
 
@@ -112,6 +118,15 @@ gdata_documents_spreadsheet_init (GDataDocumentsSpreadsheet *self)
        /* Why am I writing it? */
 }
 
+static void
+gdata_documents_spreadsheet_constructed (GObject *object)
+{
+       G_OBJECT_CLASS (gdata_documents_spreadsheet_parent_class)->constructed (object);
+
+       if (!_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)))
+               gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), 
"application/vnd.google-apps.spreadsheet");
+}
+
 /**
  * gdata_documents_spreadsheet_new:
  * @id: (allow-none): the entry's ID (not the document ID of the spreadsheet), or %NULL
diff --git a/gdata/services/documents/gdata-documents-text.c b/gdata/services/documents/gdata-documents-text.c
index 46c397e..d9a9c04 100644
--- a/gdata/services/documents/gdata-documents-text.c
+++ b/gdata/services/documents/gdata-documents-text.c
@@ -3,6 +3,7 @@
  * GData Client
  * Copyright (C) Thibault Saunier 2009 <saunierthibault gmail com>
  * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
+ * Copyright (C) Red Hat, Inc. 2016
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -36,15 +37,21 @@
 #include <glib.h>
 
 #include "gdata-documents-text.h"
+#include "gdata-documents-utils.h"
 #include "gdata-parser.h"
+#include "gdata-private.h"
+
+static void gdata_documents_text_constructed (GObject *object);
 
 G_DEFINE_TYPE (GDataDocumentsText, gdata_documents_text, GDATA_TYPE_DOCUMENTS_DOCUMENT)
 
 static void
 gdata_documents_text_class_init (GDataDocumentsTextClass *klass)
 {
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
+       gobject_class->constructed = gdata_documents_text_constructed;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#document";;
 }
 
@@ -54,6 +61,15 @@ gdata_documents_text_init (GDataDocumentsText *self)
        /* Why am I writing it? */
 }
 
+static void
+gdata_documents_text_constructed (GObject *object)
+{
+       G_OBJECT_CLASS (gdata_documents_text_parent_class)->constructed (object);
+
+       if (!_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)))
+               gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), 
"application/vnd.google-apps.document");
+}
+
 /**
  * gdata_documents_text_new:
  * @id: (allow-none): the entry's ID (not the document ID of the text document), or %NULL


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