summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebarshi Ray <debarshir@gnome.org>2016-09-21 19:19:20 +0200
committerDebarshi Ray <debarshir@gnome.org>2016-09-23 17:17:00 +0200
commit85c99df27bda67f27eb4c177f27825670c534924 (patch)
tree1df9e6fdc9a56d7019f69f3eb329c1b181ef2484
parent16e601b7c832cbc1e945a7bd9fda61ee2e80299d (diff)
downloadlibgdata-85c99df27bda67f27eb4c177f27825670c534924.tar.gz
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
-rw-r--r--gdata/services/documents/gdata-documents-drawing.c16
-rw-r--r--gdata/services/documents/gdata-documents-pdf.c16
-rw-r--r--gdata/services/documents/gdata-documents-presentation.c16
-rw-r--r--gdata/services/documents/gdata-documents-spreadsheet.c15
-rw-r--r--gdata/services/documents/gdata-documents-text.c16
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 b9ce55f3..33c1a9f4 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 e3b08f09..fd55fc8b 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 f08d361c..e252d2c6 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 4cadc7d6..ee794a7d 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 46c397ef..d9a9c046 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