[libgdata] Add GDataDocumentsMetadata for quota information



commit 3128c70d3e055a08796f869e9cdb1fabbf135852
Author: Michael Terry <mike mterry name>
Date:   Mon Aug 7 22:27:13 2017 -0400

    Add GDataDocumentsMetadata for quota information
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785885

 Makefile.am                                        |    2 +
 docs/reference/gdata-sections.txt                  |   22 ++
 gdata/gdata-core.symbols                           |    6 +
 gdata/gdata.h                                      |    1 +
 .../services/documents/gdata-documents-metadata.c  |  230 ++++++++++++++++++++
 .../services/documents/gdata-documents-metadata.h  |   76 +++++++
 gdata/services/documents/gdata-documents-service.c |  136 ++++++++++++
 gdata/services/documents/gdata-documents-service.h |    8 +
 8 files changed, 481 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0e4cf63..044193c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -287,6 +287,7 @@ gdatacontactsinclude_HEADERS = \
 gdatadocumentsincludedir = $(gdataincludedir)/services/documents
 gdata_documents_headers = \
        gdata/services/documents/gdata-documents-service.h      \
+       gdata/services/documents/gdata-documents-metadata.h     \
        gdata/services/documents/gdata-documents-feed.h         \
        gdata/services/documents/gdata-documents-entry.h        \
        gdata/services/documents/gdata-documents-query.h        \
@@ -427,6 +428,7 @@ gdata_sources = \
        gdata/services/contacts/gdata-contacts-query.c          \
        \
        gdata/services/documents/gdata-documents-service.c      \
+       gdata/services/documents/gdata-documents-metadata.c     \
        gdata/services/documents/gdata-documents-feed.c         \
        gdata/services/documents/gdata-documents-entry.c        \
        gdata/services/documents/gdata-documents-document.c     \
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 04b5e47..5a33f22 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -1783,6 +1783,9 @@ GDataDocumentsServiceError
 gdata_documents_service_new
 gdata_documents_service_get_primary_authorization_domain
 gdata_documents_service_get_spreadsheet_authorization_domain
+gdata_documents_service_get_metadata
+gdata_documents_service_get_metadata_async
+gdata_documents_service_get_metadata_finish
 gdata_documents_service_query_documents
 gdata_documents_service_query_documents_async
 gdata_documents_service_upload_document
@@ -1815,6 +1818,25 @@ GDataDocumentsServicePrivate
 </SECTION>
 
 <SECTION>
+<FILE>gdata-documents-metadata</FILE>
+<TITLE>GDataDocumentsMetadata</TITLE>
+GDataDocumentsMetadata
+GDataDocumentsMetadataClass
+gdata_documents_metadata_get_quota_total
+gdata_documents_metadata_get_quota_used
+<SUBSECTION Standard>
+gdata_documents_metadata_get_type
+GDATA_DOCUMENTS_METADATA
+GDATA_DOCUMENTS_METADATA_CLASS
+GDATA_DOCUMENTS_METADATA_GET_CLASS
+GDATA_IS_DOCUMENTS_METADATA
+GDATA_IS_DOCUMENTS_METADATA_CLASS
+GDATA_TYPE_METADATA_SERVICE
+<SUBSECTION Private>
+GDataDocumentsMetadataPrivate
+</SECTION>
+
+<SECTION>
 <FILE>gdata-download-stream</FILE>
 <TITLE>GDataDownloadStream</TITLE>
 GDataDownloadStream
diff --git a/gdata/gdata-core.symbols b/gdata/gdata-core.symbols
index e8c4377..fd7c7df 100644
--- a/gdata/gdata-core.symbols
+++ b/gdata/gdata-core.symbols
@@ -628,11 +628,17 @@ gdata_documents_folder_get_type
 gdata_documents_folder_new
 gdata_documents_service_get_type
 gdata_documents_service_new
+gdata_documents_service_get_metadata
+gdata_documents_service_get_metadata_async
+gdata_documents_service_get_metadata_finish
 gdata_documents_service_query_documents
 gdata_documents_service_query_documents_async
 gdata_documents_service_upload_document
 gdata_documents_service_update_document
 gdata_documents_service_get_upload_uri
+gdata_documents_metadata_get_type
+gdata_documents_metadata_get_quota_total
+gdata_documents_metadata_get_quota_used
 gdata_documents_feed_get_type
 gdata_documents_entry_get_type
 gdata_documents_entry_get_path
diff --git a/gdata/gdata.h b/gdata/gdata.h
index 3231219..405993e 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -134,6 +134,7 @@
 #include <gdata/services/documents/gdata-documents-folder.h>
 #include <gdata/services/documents/gdata-documents-query.h>
 #include <gdata/services/documents/gdata-documents-service.h>
+#include <gdata/services/documents/gdata-documents-metadata.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>
diff --git a/gdata/services/documents/gdata-documents-metadata.c 
b/gdata/services/documents/gdata-documents-metadata.c
new file mode 100644
index 0000000..f587af5
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-metadata.c
@@ -0,0 +1,230 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Michael Terry 2017 <mike mterry name>
+ *
+ * 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-metadata
+ * @short_description: GData document service metadata class
+ * @stability: Stable
+ * @include: gdata/services/documents/gdata-documents-metadata.h
+ *
+ * #GDataDocumentsMetadata is a subclass of #GDataParsable to represent Google Drive service metadata.
+ *
+ * For more details of Google Documents' GData API, see the
+ * <ulink type="http" url="https://developers.google.com/drive/v2/web/about-sdk";>online 
documentation</ulink>.
+ *
+ * Since: 0.17.9
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <string.h>
+
+#include "gdata-documents-metadata.h"
+#include "gdata-parser.h"
+#include "gdata-types.h"
+
+static const gchar *get_content_type (void);
+static void gdata_documents_metadata_get_property (GObject *object, guint property_id, GValue *value, 
GParamSpec *pspec);
+static void gdata_documents_metadata_set_property (GObject *object, guint property_id, const GValue *value, 
GParamSpec *pspec);
+static gboolean parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error);
+
+struct _GDataDocumentsMetadataPrivate {
+       goffset quota_total; /* bytes */
+       goffset quota_used; /* bytes */
+       gboolean quota_unlimited;
+};
+
+enum {
+       PROP_QUOTA_TOTAL = 1,
+       PROP_QUOTA_USED,
+};
+
+G_DEFINE_TYPE (GDataDocumentsMetadata, gdata_documents_metadata, GDATA_TYPE_PARSABLE)
+
+static void
+gdata_documents_metadata_class_init (GDataDocumentsMetadataClass *klass)
+{
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (GDataDocumentsMetadataPrivate));
+
+       gobject_class->get_property = gdata_documents_metadata_get_property;
+       gobject_class->set_property = gdata_documents_metadata_set_property;
+
+       parsable_class->parse_json = parse_json;
+       parsable_class->get_content_type = get_content_type;
+
+       /**
+        * GDataDocumentsMetadata:quota-total:
+        *
+        * The user quota limit across all services. Measured in bytes.
+        *
+        * Since: 0.17.9
+        */
+       g_object_class_install_property (gobject_class, PROP_QUOTA_TOTAL,
+                                        g_param_spec_int64 ("quota-total",
+                                                            "Quota total", "The user quota limit across all 
services.",
+                                                            -1, G_MAXINT64, 0,
+                                                            G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+       /**
+        * GDataDocumentsMetadata:quota-used:
+        *
+        * The amount of user quota used up across all services. Measured in bytes.
+        *
+        * Since: 0.17.9
+        */
+       g_object_class_install_property (gobject_class, PROP_QUOTA_USED,
+                                        g_param_spec_int64 ("quota-used",
+                                                            "Quota used", "The amount of user quota used up 
across all services.",
+                                                            0, G_MAXINT64, 0,
+                                                            G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gdata_documents_metadata_init (GDataDocumentsMetadata *self)
+{
+       self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_DOCUMENTS_METADATA, 
GDataDocumentsMetadataPrivate);
+}
+
+static void
+gdata_documents_metadata_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       GDataDocumentsMetadata *self = GDATA_DOCUMENTS_METADATA (object);
+
+       switch (property_id) {
+               case PROP_QUOTA_TOTAL:
+                       g_value_set_int64 (value, gdata_documents_metadata_get_quota_total (self));
+                       break;
+               case PROP_QUOTA_USED:
+                       g_value_set_int64 (value, gdata_documents_metadata_get_quota_used (self));
+                       break;
+               default:
+                       /* We don't have any other property... */
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static void
+gdata_documents_metadata_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec 
*pspec)
+{
+       switch (property_id) {
+               case PROP_QUOTA_TOTAL:
+               case PROP_QUOTA_USED:
+                       /* Read only. */
+               default:
+                       /* We don't have any other property... */
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+       }
+}
+
+static gboolean
+parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
+{
+       GDataDocumentsMetadataPrivate *priv = GDATA_DOCUMENTS_METADATA (parsable)->priv;
+       gboolean success = TRUE;
+       gchar *quota_total = NULL;
+       gchar *quota_used = NULL;
+       gchar *quota_type = NULL;
+
+       /* JSON format: https://developers.google.com/drive/v2/reference/about */
+
+       if (gdata_parser_string_from_json_member (reader, "quotaBytesTotal", P_DEFAULT, &quota_total, 
&success, error) == TRUE) {
+               gchar *end_ptr;
+               guint64 val;
+
+               /* Even though ‘quotaBytesTotal’ is documented as long,
+                * it is actually a string in the JSON.
+                */
+               val = g_ascii_strtoull (quota_total, &end_ptr, 10);
+               if (*end_ptr == '\0')
+                       priv->quota_total = (goffset) val;
+               g_free (quota_total);
+               return success;
+       } else if (gdata_parser_string_from_json_member (reader, "quotaBytesUsedAggregate", P_DEFAULT, 
&quota_used, &success, error) == TRUE) {
+               gchar *end_ptr;
+               guint64 val;
+
+               /* Even though ‘quotaBytesUsedAggregate’ is documented as long,
+                * it is actually a string in the JSON.
+                */
+               val = g_ascii_strtoull (quota_used, &end_ptr, 10);
+               if (*end_ptr == '\0')
+                       priv->quota_used = (goffset) val;
+               g_free (quota_used);
+               return success;
+       } else if (gdata_parser_string_from_json_member (reader, "quotaType", P_DEFAULT, &quota_type, 
&success, error) == TRUE) {
+               if (g_strcmp0 (quota_type, "UNLIMITED") == 0)
+                       priv->quota_unlimited = TRUE;
+               g_free (quota_type);
+               return success;
+       }
+
+       return GDATA_PARSABLE_CLASS (gdata_documents_metadata_parent_class)->parse_json (parsable, reader, 
user_data, error);
+}
+
+static const gchar *
+get_content_type (void)
+{
+       return "application/json";
+}
+
+/**
+ * gdata_documents_metadata_get_quota_total:
+ * @self: a #GDataDocumentsMetadata
+ *
+ * Gets the #GDataDocumentsMetadata:quota-total property.
+ *
+ * Return value: the number of quota bytes available in total. Returns -1 if
+ *               there is no quota limit.
+ *
+ * Since: 0.17.9
+ */
+goffset
+gdata_documents_metadata_get_quota_total (GDataDocumentsMetadata *self)
+{
+       g_return_val_if_fail (GDATA_IS_DOCUMENTS_METADATA (self), 0);
+
+       if (self->priv->quota_unlimited)
+               return -1;
+       else
+               return self->priv->quota_total;
+}
+
+/**
+ * gdata_documents_metadata_get_quota_used:
+ * @self: a #GDataDocumentsMetadata
+ *
+ * Gets the #GDataDocumentsMetadata:quota-used property.
+ *
+ * Return value: the number of quota bytes used by the documents service
+ *
+ * Since: 0.17.9
+ */
+goffset
+gdata_documents_metadata_get_quota_used (GDataDocumentsMetadata *self)
+{
+       g_return_val_if_fail (GDATA_IS_DOCUMENTS_METADATA (self), 0);
+
+       return self->priv->quota_used;
+}
diff --git a/gdata/services/documents/gdata-documents-metadata.h 
b/gdata/services/documents/gdata-documents-metadata.h
new file mode 100644
index 0000000..f0c0b80
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-metadata.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Michael Terry 2017 <mike mterry name>
+ *
+ * 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_METADATA_H
+#define GDATA_DOCUMENTS_METADATA_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/gdata-parsable.h>
+
+G_BEGIN_DECLS
+
+
+#define GDATA_TYPE_DOCUMENTS_METADATA          (gdata_documents_metadata_get_type ())
+#define GDATA_DOCUMENTS_METADATA(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), 
GDATA_TYPE_DOCUMENTS_METADATA, GDataDocumentsMetadata))
+#define GDATA_DOCUMENTS_METADATA_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_DOCUMENTS_METADATA, 
GDataDocumentsMetadataClass))
+#define GDATA_IS_DOCUMENTS_METADATA(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), 
GDATA_TYPE_DOCUMENTS_METADATA))
+#define GDATA_IS_DOCUMENTS_METADATA_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GDATA_TYPE_DOCUMENTS_METADATA))
+#define GDATA_DOCUMENTS_METADATA_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), 
GDATA_TYPE_DOCUMENTS_METADATA, GDataDocumentsMetadataClass))
+
+typedef struct _GDataDocumentsMetadataPrivate  GDataDocumentsMetadataPrivate;
+
+/**
+ * GDataDocumentsMetadata:
+ *
+ * All the fields in the #GDataDocumentsMetadata structure are private and should never be accessed directly.
+ *
+ * Since: 0.17.9
+ */
+typedef struct {
+       GDataParsable parent;
+       GDataDocumentsMetadataPrivate *priv;
+} GDataDocumentsMetadata;
+
+/**
+ * GDataDocumentsMetadataClass:
+ *
+ * All the fields in the #GDataDocumentsMetadataClass structure are private and should never be accessed 
directly.
+ *
+ * Since: 0.17.9
+ */
+typedef struct {
+       /*< private >*/
+       GDataParsableClass parent;
+
+       /*< private >*/
+       /* Padding for future expansion */
+       void (*_g_reserved0) (void);
+       void (*_g_reserved1) (void);
+} GDataDocumentsMetadataClass;
+
+GType gdata_documents_metadata_get_type (void) G_GNUC_CONST;
+
+goffset gdata_documents_metadata_get_quota_total (GDataDocumentsMetadata *self) G_GNUC_PURE;
+goffset gdata_documents_metadata_get_quota_used (GDataDocumentsMetadata *self) G_GNUC_PURE;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_METADATA_H */
diff --git a/gdata/services/documents/gdata-documents-service.c 
b/gdata/services/documents/gdata-documents-service.c
index f9a220c..d405af0 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -411,6 +411,142 @@ gdata_documents_service_get_spreadsheet_authorization_domain (void)
        return get_spreadsheets_authorization_domain ();
 }
 
+/**
+ * gdata_documents_service_get_metadata:
+ * @self: a #GDataDocumentsService
+ * @cancellable: (allow-none): optional #GCancellable object, or %NULL
+ * @error: a #GError, or %NULL
+ *
+ * Gets a #GDataDocumentsMetadata object containing metadata about the documents
+ * service itself, like how large the user quota is.
+ *
+ * Return value: (transfer full): the service's metadata object; unref with g_object_unref()
+ *
+ * Since: 0.17.9
+ */
+GDataDocumentsMetadata *
+gdata_documents_service_get_metadata (GDataDocumentsService *self, GCancellable *cancellable, GError **error)
+{
+       GDataDocumentsMetadata *metadata;
+       const gchar *uri = "https://www.googleapis.com/drive/v2/about";;
+       SoupMessage *message;
+       guint status;
+
+       g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
+       g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+       message = _gdata_service_build_message (GDATA_SERVICE (self), get_documents_authorization_domain (), 
SOUP_METHOD_GET, uri, NULL, FALSE);
+
+       /* Send the message */
+       status = _gdata_service_send_message (GDATA_SERVICE (self), message, cancellable, error);
+
+       if (status == SOUP_STATUS_NONE || status == SOUP_STATUS_CANCELLED) {
+               /* Redirect error or cancelled */
+               g_object_unref (message);
+               return NULL;
+       } else if (status != SOUP_STATUS_OK) {
+               /* Error */
+               GDataServiceClass *klass = GDATA_SERVICE_GET_CLASS (self);
+               g_assert (klass->parse_error_response != NULL);
+               klass->parse_error_response (GDATA_SERVICE (self), GDATA_OPERATION_QUERY, status, 
message->reason_phrase, message->response_body->data,
+                                            message->response_body->length, error);
+               g_object_unref (message);
+               return NULL;
+       }
+
+       /* Parse the JSON; and update the entry */
+       g_assert (message->response_body->data != NULL);
+       metadata = GDATA_DOCUMENTS_METADATA (gdata_parsable_new_from_json (GDATA_TYPE_DOCUMENTS_METADATA, 
message->response_body->data, message->response_body->length,
+                                                                           error));
+       g_object_unref (message);
+
+       return metadata;
+}
+
+static void
+get_metadata_thread (GSimpleAsyncResult *result, GDataDocumentsService *service, GCancellable *cancellable)
+{
+       GDataDocumentsMetadata *metadata;
+       GError *error = NULL;
+
+       /* Copy the metadata and return */
+       metadata = gdata_documents_service_get_metadata (service, cancellable, &error);
+       if (error != NULL) {
+               g_simple_async_result_set_from_error (result, error);
+               g_error_free (error);
+               return;
+       }
+
+       /* Return the metadata */
+       g_simple_async_result_set_op_res_gpointer (result, g_object_ref (metadata), (GDestroyNotify) 
g_object_unref);
+}
+
+/**
+ * gdata_documents_service_get_metadata_async:
+ * @self: a #GDataDocumentsService
+ * @cancellable: (allow-none): optional #GCancellable object, or %NULL
+ * @callback: a #GAsyncReadyCallback to call when the operation is finished, or %NULL
+ * @user_data: (closure): data to pass to the @callback function
+ *
+ * Gets a #GDataDocumentsMetadata object containing metadata about the documents
+ * service itself, like how large the user quota is.
+ *
+ * For more details, see gdata_documents_service_get_metadata(), which is the synchronous version of this 
function.
+ *
+ * When the operation is finished, @callback will be called. You can then call 
gdata_documents_service_get_metadata_finish() to get the results
+ * of the operation.
+ *
+ * Since: 0.17.9
+ */
+void
+gdata_documents_service_get_metadata_async (GDataDocumentsService *self, GCancellable *cancellable,
+                                            GAsyncReadyCallback callback, gpointer user_data)
+{
+       GSimpleAsyncResult *result;
+
+       g_return_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self));
+       g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
+       result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, 
gdata_documents_service_get_metadata_async);
+       g_simple_async_result_run_in_thread (result, (GSimpleAsyncThreadFunc) get_metadata_thread, 
G_PRIORITY_DEFAULT, cancellable);
+       g_object_unref (result);
+}
+
+/**
+ * gdata_documents_service_get_metadata_finish:
+ * @self: a #GDataDocumentsService
+ * @async_result: a #GAsyncResult
+ * @error: a #GError, or %NULL
+ *
+ * Finish an asynchronous operation to get a #GDataDocumentsMetadata started with 
gdata_documents_service_get_metadata_async().
+ *
+ * Return value: (transfer full): the service's metadata object; unref with g_object_unref()
+ *
+ * Since: 0.17.9
+ */
+GDataDocumentsMetadata *
+gdata_documents_service_get_metadata_finish (GDataDocumentsService *self, GAsyncResult *async_result, GError 
**error)
+{
+       GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (async_result);
+       GDataDocumentsMetadata *metadata;
+
+       g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
+       g_return_val_if_fail (G_IS_ASYNC_RESULT (async_result), NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+       g_warn_if_fail (g_simple_async_result_get_source_tag (result) == 
gdata_documents_service_get_metadata_async);
+
+       if (g_simple_async_result_propagate_error (result, error) == TRUE) {
+               return NULL;
+       }
+
+       metadata = g_simple_async_result_get_op_res_gpointer (result);
+       g_assert (GDATA_IS_DOCUMENTS_METADATA (metadata));
+
+       return metadata;
+}
+
 static gchar *
 _query_documents_build_request_uri (GDataDocumentsQuery *query)
 {
diff --git a/gdata/services/documents/gdata-documents-service.h 
b/gdata/services/documents/gdata-documents-service.h
index f9902ae..6b2fc90 100644
--- a/gdata/services/documents/gdata-documents-service.h
+++ b/gdata/services/documents/gdata-documents-service.h
@@ -27,6 +27,7 @@
 #include <gdata/gdata-upload-stream.h>
 #include <gdata/services/documents/gdata-documents-query.h>
 #include <gdata/services/documents/gdata-documents-feed.h>
+#include <gdata/services/documents/gdata-documents-metadata.h>
 
 G_BEGIN_DECLS
 
@@ -94,6 +95,13 @@ GDataDocumentsService *gdata_documents_service_new (GDataAuthorizer *authorizer)
 GDataAuthorizationDomain *gdata_documents_service_get_primary_authorization_domain (void) G_GNUC_CONST;
 GDataAuthorizationDomain *gdata_documents_service_get_spreadsheet_authorization_domain (void) G_GNUC_CONST;
 
+GDataDocumentsMetadata *gdata_documents_service_get_metadata (GDataDocumentsService *self, GCancellable 
*cancellable,
+                                                              GError **error)  G_GNUC_WARN_UNUSED_RESULT 
G_GNUC_MALLOC;
+void gdata_documents_service_get_metadata_async (GDataDocumentsService *self, GCancellable *cancellable,
+                                                 GAsyncReadyCallback callback, gpointer user_data);
+GDataDocumentsMetadata *gdata_documents_service_get_metadata_finish (GDataDocumentsService *self, 
GAsyncResult *async_result,
+                                                                     GError **error) 
G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
 GDataDocumentsFeed *gdata_documents_service_query_documents (GDataDocumentsService *self, 
GDataDocumentsQuery *query, GCancellable *cancellable,
                                                              GDataQueryProgressCallback progress_callback, 
gpointer progress_user_data,
                                                              GError **error) G_GNUC_WARN_UNUSED_RESULT 
G_GNUC_MALLOC;


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