[libgdata/wip/rishi/drive: 10/11] documents: Correct the prefix used for resource IDs of folders



commit d3c417fd00e3136cf6964f7516e6749a38ef61de
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Sep 21 14:35:27 2017 +0200

    documents: Correct the prefix used for resource IDs of folders
    
    GDataDocumentsFolders' resource IDs should have the "folder:" prefix,
    not "documents:".
    
    Fallout from d93279623e34c7b275ae3f989b54c6f3a30d5658
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684920

 .../services/documents/gdata-documents-document.c  |   22 ++++++++++++++++++-
 gdata/services/documents/gdata-documents-entry.c   |    5 ----
 gdata/services/documents/gdata-documents-folder.c  |   23 +++++++++++++++++++-
 3 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-document.c 
b/gdata/services/documents/gdata-documents-document.c
index 4a42f41..f5d94cd 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -2,7 +2,7 @@
 /*
  * GData Client
  * Copyright (C) Philip Withnall 2010 <philip tecnocode co uk>
- * Copyright (C) Red Hat, Inc. 2015
+ * Copyright (C) Red Hat, Inc. 2015, 2017
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -203,6 +203,7 @@
 #include "gdata-documents-document.h"
 #include "gdata-documents-drawing.h"
 #include "gdata-documents-entry.h"
+#include "gdata-documents-entry-private.h"
 #include "gdata-documents-presentation.h"
 #include "gdata-documents-spreadsheet.h"
 #include "gdata-documents-text.h"
@@ -213,6 +214,7 @@
 
 static void gdata_documents_document_finalize (GObject *object);
 static gboolean parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error);
+static gboolean post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error);
 
 struct _GDataDocumentsDocumentPrivate {
        GHashTable *export_links; /* owned string → owned string */
@@ -231,6 +233,7 @@ gdata_documents_document_class_init (GDataDocumentsDocumentClass *klass)
 
        gobject_class->finalize = gdata_documents_document_finalize;
        parsable_class->parse_json = parse_json;
+       parsable_class->post_parse_json = post_parse_json;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#file";;
 }
 
@@ -312,6 +315,23 @@ parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GEr
        return GDATA_PARSABLE_CLASS (gdata_documents_document_parent_class)->parse_json (parsable, reader, 
user_data, error);
 }
 
+static gboolean
+post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
+{
+       const gchar *id;
+       gchar *resource_id;
+
+       id = gdata_entry_get_id (GDATA_ENTRY (parsable));
+
+       /* Since the document-id is identical to GDataEntry:id, which is parsed by the parent class, we can't
+        * create the resource-id while parsing. */
+       resource_id = g_strconcat ("document:", id, NULL);
+       _gdata_documents_entry_set_resource_id (GDATA_DOCUMENTS_ENTRY (parsable), resource_id);
+
+       g_free (resource_id);
+       return GDATA_PARSABLE_CLASS (gdata_documents_document_parent_class)->post_parse_json (parsable, 
user_data, error);
+}
+
 /**
  * gdata_documents_document_new:
  * @id: (allow-none): the entry's ID (not the document ID), or %NULL
diff --git a/gdata/services/documents/gdata-documents-entry.c 
b/gdata/services/documents/gdata-documents-entry.c
index f5755c4..535c82e 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -815,7 +815,6 @@ parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GEr
 static gboolean
 post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
 {
-       GDataDocumentsEntryPrivate *priv = GDATA_DOCUMENTS_ENTRY (parsable)->priv;
        GDataLink *_link;
        const gchar *id;
        gchar *uri;
@@ -830,10 +829,6 @@ post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
        g_free (uri);
        g_object_unref (_link);
 
-       /* Since the document-id is identical to GDataEntry:id, which is parsed by the parent class, we can't
-        * create the resource-id while parsing. */
-       priv->resource_id = g_strconcat ("document:", id, NULL);
-
        return TRUE;
 }
 
diff --git a/gdata/services/documents/gdata-documents-folder.c 
b/gdata/services/documents/gdata-documents-folder.c
index b6ddd37..bd59a20 100644
--- a/gdata/services/documents/gdata-documents-folder.c
+++ b/gdata/services/documents/gdata-documents-folder.c
@@ -3,7 +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. 2015, 2016
+ * Copyright (C) Red Hat, Inc. 2015, 2016, 2017
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -84,6 +84,7 @@
 #include <libxml/parser.h>
 #include <string.h>
 
+#include "gdata-documents-entry-private.h"
 #include "gdata-documents-folder.h"
 #include "gdata-documents-utils.h"
 #include "gdata-parser.h"
@@ -91,6 +92,7 @@
 #include "gdata-private.h"
 
 static void gdata_documents_folder_constructed (GObject *object);
+static gboolean post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error);
 
 G_DEFINE_TYPE (GDataDocumentsFolder, gdata_documents_folder, GDATA_TYPE_DOCUMENTS_ENTRY)
 
@@ -98,9 +100,11 @@ static void
 gdata_documents_folder_class_init (GDataDocumentsFolderClass *klass)
 {
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
        GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
 
        gobject_class->constructed = gdata_documents_folder_constructed;
+       parsable_class->post_parse_json = post_parse_json;
        entry_class->kind_term = "http://schemas.google.com/docs/2007#folder";;
 }
 
@@ -119,6 +123,23 @@ gdata_documents_folder_constructed (GObject *object)
                gdata_documents_utils_add_content_type (GDATA_DOCUMENTS_ENTRY (object), 
"application/vnd.google-apps.folder");
 }
 
+static gboolean
+post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
+{
+       const gchar *id;
+       gchar *resource_id;
+
+       id = gdata_entry_get_id (GDATA_ENTRY (parsable));
+
+       /* Since the document-id is identical to GDataEntry:id, which is parsed by the parent class, we can't
+        * create the resource-id while parsing. */
+       resource_id = g_strconcat ("folder:", id, NULL);
+       _gdata_documents_entry_set_resource_id (GDATA_DOCUMENTS_ENTRY (parsable), resource_id);
+
+       g_free (resource_id);
+       return GDATA_PARSABLE_CLASS (gdata_documents_folder_parent_class)->post_parse_json (parsable, 
user_data, error);
+}
+
 /**
  * gdata_documents_folder_new:
  * @id: (allow-none): the entry's ID (not the document ID of the folder), or %NULL


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