summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-01-20 09:38:50 +0100
committerOndrej Holy <oholy@redhat.com>2021-02-11 18:03:53 +0100
commit19fbe4b4993ddc249769d4d6827c0939ca22b4af (patch)
tree5471d655aa8c71a83aa101594b9120787a14d1fb
parentc15daee6bc676e1dbeb2dba7e53d794565509da2 (diff)
downloadlibgdata-19fbe4b4993ddc249769d4d6827c0939ca22b4af.tar.gz
documents: Add Shared Drives support
It seems that the existing documents APIs works nicely with the files on Shared Drives (formerly Team Drives), although it is possible that some small changes will be needed to handle differences: https://developers.google.com/drive/api/v2/shared-drives-diffs However, the main problem is that there is no way currently to get the list of Shared Drives IDs and their names. Let's add new APIs for it which will be consequently used by GVfs. Relates: https://gitlab.gnome.org/GNOME/gvfs/-/issues/377 Fixes: https://gitlab.gnome.org/GNOME/libgdata/-/issues/25
-rw-r--r--docs/reference/gdata-sections.txt.in38
-rw-r--r--gdata/gdata-core.symbols6
-rw-r--r--gdata/gdata.h2
-rw-r--r--gdata/services/documents/gdata-documents-drive-query.c98
-rw-r--r--gdata/services/documents/gdata-documents-drive-query.h55
-rw-r--r--gdata/services/documents/gdata-documents-drive.c144
-rw-r--r--gdata/services/documents/gdata-documents-drive.h55
-rw-r--r--gdata/services/documents/gdata-documents-entry.c2
-rw-r--r--gdata/services/documents/gdata-documents-feed.c3
-rw-r--r--gdata/services/documents/gdata-documents-query.c5
-rw-r--r--gdata/services/documents/gdata-documents-service.c96
-rw-r--r--gdata/services/documents/gdata-documents-service.h9
-rw-r--r--gdata/services/documents/meson.build4
-rw-r--r--gdata/symbol.map6
14 files changed, 522 insertions, 1 deletions
diff --git a/docs/reference/gdata-sections.txt.in b/docs/reference/gdata-sections.txt.in
index e159b00b..ca562bc8 100644
--- a/docs/reference/gdata-sections.txt.in
+++ b/docs/reference/gdata-sections.txt.in
@@ -1817,6 +1817,8 @@ 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_query_drives
+gdata_documents_service_query_drives_async
gdata_documents_service_upload_document
gdata_documents_service_upload_document_resumable
gdata_documents_service_update_document
@@ -1866,6 +1868,42 @@ GDataDocumentsMetadataPrivate
</SECTION>
<SECTION>
+<FILE>gdata-documents-drive</FILE>
+<TITLE>GDataDocumentsDrive</TITLE>
+GDataDocumentsDrive
+GDataDocumentsDriveClass
+gdata_documents_drive_get_name
+<SUBSECTION Standard>
+gdata_documents_drive_get_type
+GDATA_DOCUMENTS_DRIVE
+GDATA_DOCUMENTS_DRIVE_CLASS
+GDATA_DOCUMENTS_DRIVE_GET_CLASS
+GDATA_IS_DOCUMENTS_DRIVE
+GDATA_IS_DOCUMENTS_DRIVE_CLASS
+GDATA_TYPE_DOCUMENTS_DRIVE
+<SUBSECTION Private>
+GDataDocumentsDrivePrivate
+</SECTION>
+
+<SECTION>
+<FILE>gdata-documents-drive-query</FILE>
+<TITLE>GDataDocumentsDriveQuery</TITLE>
+GDataDocumentsDriveQuery
+GDataDocumentsDriveQueryClass
+gdata_documents_drive_query_new
+<SUBSECTION Standard>
+gdata_documents_drive_query_get_type
+GDATA_DOCUMENTS_DRIVE_QUERY
+GDATA_DOCUMENTS_DRIVE_QUERY_CLASS
+GDATA_DOCUMENTS_DRIVE_QUERY_GET_CLASS
+GDATA_IS_DOCUMENTS_DRIVE_QUERY
+GDATA_IS_DOCUMENTS_DRIVE_QUERY_CLASS
+GDATA_TYPE_DOCUMENTS_DRIVE_QUERY
+<SUBSECTION Private>
+GDataDocumentsDriveQueryPrivate
+</SECTION>
+
+<SECTION>
<FILE>gdata-download-stream</FILE>
<TITLE>GDataDownloadStream</TITLE>
GDataDownloadStream
diff --git a/gdata/gdata-core.symbols b/gdata/gdata-core.symbols
index 29e94fdb..d742e535 100644
--- a/gdata/gdata-core.symbols
+++ b/gdata/gdata-core.symbols
@@ -633,6 +633,8 @@ 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_query_drives
+gdata_documents_service_query_drives_async
gdata_documents_service_upload_document
gdata_documents_service_update_document
gdata_documents_service_get_upload_uri
@@ -669,6 +671,10 @@ gdata_documents_service_error_get_type
gdata_documents_service_error_quark
gdata_documents_access_rule_get_type
gdata_documents_access_rule_new
+gdata_documents_drive_get_type
+gdata_documents_drive_get_name
+gdata_documents_drive_query_get_type
+gdata_documents_drive_query_new
gdata_download_stream_get_type
gdata_download_stream_new
gdata_download_stream_get_service
diff --git a/gdata/gdata.h b/gdata/gdata.h
index a1ff6ec4..0858accd 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -128,6 +128,8 @@
/* Google Documents*/
#include <gdata/services/documents/gdata-documents-entry.h>
#include <gdata/services/documents/gdata-documents-document.h>
+#include <gdata/services/documents/gdata-documents-drive.h>
+#include <gdata/services/documents/gdata-documents-drive-query.h>
#include <gdata/services/documents/gdata-documents-property.h>
#include <gdata/services/documents/gdata-documents-text.h>
#include <gdata/services/documents/gdata-documents-spreadsheet.h>
diff --git a/gdata/services/documents/gdata-documents-drive-query.c b/gdata/services/documents/gdata-documents-drive-query.c
new file mode 100644
index 00000000..e1914922
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drive-query.c
@@ -0,0 +1,98 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Ondrej Holy 2020 <oholy@redhat.com>
+ *
+ * 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-drive-query
+ * @short_description: GData Documents Drive query object
+ * @stability: Stable
+ * @include: gdata/services/documents/gdata-documents-drive-query.h
+ *
+ * #GDataDocumentsDriveQuery represents a collection of query parameters specific to shared drives, which go above and beyond
+ * those catered for by #GDataQuery.
+ *
+ * For more information on the custom GData query parameters supported by #GDataDocumentsDriveQuery, see the
+ * [online documentation](https://developers.google.com/drive/api/v2/ref-search-terms#drive_properties).
+ *
+ * Since: 0.18.0
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <string.h>
+
+#include "gdata-documents-drive-query.h"
+#include "gdata-private.h"
+
+static void get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboolean *params_started);
+
+G_DEFINE_TYPE (GDataDocumentsDriveQuery, gdata_documents_drive_query, GDATA_TYPE_QUERY)
+
+static void
+gdata_documents_drive_query_class_init (GDataDocumentsDriveQueryClass *klass)
+{
+ GDataQueryClass *query_class = GDATA_QUERY_CLASS (klass);
+
+ query_class->get_query_uri = get_query_uri;
+}
+
+static void
+gdata_documents_drive_query_init (GDataDocumentsDriveQuery *self)
+{
+ /* https://developers.google.com/drive/api/v2/reference/drives/list#parameters */
+ _gdata_query_set_pagination_type (GDATA_QUERY (self),
+ GDATA_QUERY_PAGINATION_TOKENS);
+}
+
+static void
+get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboolean *params_started)
+{
+ guint max_results;
+
+ #define APPEND_SEP g_string_append_c (query_uri, (*params_started == FALSE) ? '?' : '&'); *params_started = TRUE;
+
+ _gdata_query_clear_q_internal (self);
+
+ /* Chain up to the parent class */
+ GDATA_QUERY_CLASS (gdata_documents_drive_query_parent_class)->get_query_uri (self, feed_uri, query_uri, params_started);
+
+ /* https://developers.google.com/drive/api/v2/reference/drives/list */
+ max_results = gdata_query_get_max_results (self);
+ if (max_results > 0) {
+ APPEND_SEP
+ max_results = max_results > 100 ? 100 : max_results;
+ g_string_append_printf (query_uri, "maxResults=%u", max_results);
+ }
+}
+
+/**
+ * gdata_documents_drive_query_new:
+ * @q: (nullable): a query string, or %NULL
+ *
+ * Creates a new #GDataDocumentsDriveQuery with its #GDataQuery:q property set to @q.
+ *
+ * Return value: (transfer full): a new #GDataDocumentsDriveQuery
+ *
+ * Since: 0.18.0
+ */
+GDataDocumentsDriveQuery *
+gdata_documents_drive_query_new (const gchar *q)
+{
+ return g_object_new (GDATA_TYPE_DOCUMENTS_DRIVE_QUERY, "q", q, NULL);
+}
diff --git a/gdata/services/documents/gdata-documents-drive-query.h b/gdata/services/documents/gdata-documents-drive-query.h
new file mode 100644
index 00000000..9668830c
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drive-query.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Ondrej Holy 2020 <oholy@redhat.com>
+ *
+ * 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_DRIVE_QUERY_H
+#define GDATA_DOCUMENTS_DRIVE_QUERY_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/gdata-types.h>
+#include <gdata/gdata-query.h>
+
+G_BEGIN_DECLS
+
+#define GDATA_TYPE_DOCUMENTS_DRIVE_QUERY gdata_documents_drive_query_get_type ()
+G_DECLARE_DERIVABLE_TYPE (GDataDocumentsDriveQuery, gdata_documents_drive_query, GDATA, DOCUMENTS_DRIVE_QUERY, GDataQuery)
+
+/**
+ * GDataDocumentsDriveQueryClass:
+ *
+ * All the fields in the #GDataDocumentsDriveQueryClass structure are private and should never be accessed directly.
+ *
+ * Since: 0.18.0
+ */
+struct _GDataDocumentsDriveQueryClass {
+ /*< private >*/
+ GDataQueryClass parent;
+
+ /*< private >*/
+ /* Padding for future expansion */
+ void (*_g_reserved0) (void);
+ void (*_g_reserved1) (void);
+};
+
+GDataDocumentsDriveQuery *gdata_documents_drive_query_new (const gchar *q) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_DRIVE_QUERY_H */
diff --git a/gdata/services/documents/gdata-documents-drive.c b/gdata/services/documents/gdata-documents-drive.c
new file mode 100644
index 00000000..5063be8b
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drive.c
@@ -0,0 +1,144 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Ondrej Holy 2020 <oholy@redhat.com>
+ *
+ * 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-drive
+ * @short_description: GData documents drive object
+ * @stability: Stable
+ * @include: gdata/services/documents/gdata-documents-drive.h
+ *
+ * #GDataDocumentsDrive is a subclass of #GDataEntry to represent an arbitrary Google Drive shared drive.
+ *
+ * For more details of Google Drive’s GData API, see the [online documentation](https://developers.google.com/drive/v2/web/about-sdk).
+ *
+ * Since: 0.18.0
+ */
+
+#include <config.h>
+#include <glib.h>
+
+#include "gdata-documents-drive.h"
+#include "gdata-private.h"
+
+static void gdata_documents_drive_finalize (GObject *object);
+static void gdata_documents_drive_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static gboolean parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error);
+
+typedef struct {
+ gchar *name;
+} GDataDocumentsDrivePrivate;
+
+enum {
+ PROP_NAME = 1,
+};
+
+G_DEFINE_TYPE_WITH_CODE (GDataDocumentsDrive, gdata_documents_drive, GDATA_TYPE_ENTRY,
+ G_ADD_PRIVATE (GDataDocumentsDrive));
+
+static void
+gdata_documents_drive_class_init (GDataDocumentsDriveClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
+
+ gobject_class->get_property = gdata_documents_drive_get_property;
+ gobject_class->finalize = gdata_documents_drive_finalize;
+
+ parsable_class->parse_json = parse_json;
+
+ /**
+ * GDataDocumentsDrive:name:
+ *
+ * The human-readable name of this shared drive.
+ *
+ * Since: 0.18.0
+ */
+ g_object_class_install_property (gobject_class, PROP_NAME,
+ g_param_spec_string ("name",
+ "Name", "The human-readable name of this shared drive.",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gdata_documents_drive_init (GDataDocumentsDrive *self)
+{
+}
+
+static void
+gdata_documents_drive_finalize (GObject *object)
+{
+ GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (object));
+
+ g_free (priv->name);
+
+ G_OBJECT_CLASS (gdata_documents_drive_parent_class)->finalize (object);
+}
+
+static void
+gdata_documents_drive_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (object));
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+/**
+ * gdata_documents_drive_get_name:
+ * @self: a #GDataDocumentsDrive
+ *
+ * Returns the human-readable name of this shared drive.
+ *
+ * Return value: (nullable): the drives's human-readable name, or %NULL if not set
+ *
+ * Since: 0.18.0
+ */
+const gchar *
+gdata_documents_drive_get_name (GDataDocumentsDrive *self)
+{
+ GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (self);
+
+ return priv->name;
+}
+
+static gboolean
+parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
+{
+ GDataDocumentsDrivePrivate *priv = gdata_documents_drive_get_instance_private (GDATA_DOCUMENTS_DRIVE (parsable));
+ gboolean success = TRUE;
+ gchar *name = NULL;
+
+ /* JSON format: https://developers.google.com/drive/v2/reference/drives */
+
+ if (gdata_parser_string_from_json_member (reader, "name", P_DEFAULT, &name, &success, error) == TRUE) {
+ if (success)
+ priv->name = name;
+ return success;
+ }
+
+ return GDATA_PARSABLE_CLASS (gdata_documents_drive_parent_class)->parse_json (parsable, reader, user_data, error);
+}
diff --git a/gdata/services/documents/gdata-documents-drive.h b/gdata/services/documents/gdata-documents-drive.h
new file mode 100644
index 00000000..63598e37
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-drive.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Ondrej Holy 2020 <oholy@redhat.com>
+ *
+ * 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_DRIVE_H
+#define GDATA_DOCUMENTS_DRIVE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/gdata-entry.h>
+
+G_BEGIN_DECLS
+
+#define GDATA_TYPE_DOCUMENTS_DRIVE gdata_documents_drive_get_type ()
+G_DECLARE_DERIVABLE_TYPE (GDataDocumentsDrive, gdata_documents_drive, GDATA, DOCUMENTS_DRIVE, GDataEntry)
+
+
+/**
+ * GDataDocumentsDriveClass:
+ *
+ * All the fields in the #GDataDocumentsDriveClass structure are private and should never be accessed directly.
+ *
+ * Since: 0.18.0
+ */
+struct _GDataDocumentsDriveClass {
+ /*< private >*/
+ GDataEntryClass parent;
+
+ /*< private >*/
+ /* Padding for future expansion */
+ void (*_g_reserved0) (void);
+ void (*_g_reserved1) (void);
+};
+
+const gchar *gdata_documents_drive_get_name (GDataDocumentsDrive *self) G_GNUC_PURE;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_DRIVE_H */
diff --git a/gdata/services/documents/gdata-documents-entry.c b/gdata/services/documents/gdata-documents-entry.c
index f16cfcd3..07a86386 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -1058,7 +1058,7 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
static gchar *
get_entry_uri (const gchar *id)
{
- return g_strconcat ("https://www.googleapis.com/drive/v2/files/", id, NULL);
+ return g_strconcat ("https://www.googleapis.com/drive/v2/files/", id, "?supportsAllDrives=true", NULL);
}
/**
diff --git a/gdata/services/documents/gdata-documents-feed.c b/gdata/services/documents/gdata-documents-feed.c
index 36370975..9a746e28 100644
--- a/gdata/services/documents/gdata-documents-feed.c
+++ b/gdata/services/documents/gdata-documents-feed.c
@@ -41,6 +41,7 @@
#include "gdata-documents-feed.h"
#include "gdata-documents-utils.h"
+#include "gdata-documents-drive.h"
#include "gdata-types.h"
#include "gdata-private.h"
#include "gdata-service.h"
@@ -159,6 +160,8 @@ parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GEr
if (g_strcmp0 (kind, "drive#file") == 0) {
entry_type = gdata_documents_utils_get_type_from_content_type (mime_type);
+ } else if (g_strcmp0 (kind, "drive#drive") == 0) {
+ entry_type = GDATA_TYPE_DOCUMENTS_DRIVE;
} else {
g_warning ("%s files are not handled yet", kind);
}
diff --git a/gdata/services/documents/gdata-documents-query.c b/gdata/services/documents/gdata-documents-query.c
index 6070c1b0..0a5a8d4b 100644
--- a/gdata/services/documents/gdata-documents-query.c
+++ b/gdata/services/documents/gdata-documents-query.c
@@ -404,6 +404,11 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
max_results = max_results > 1000 ? 1000 : max_results;
g_string_append_printf (query_uri, "maxResults=%u", max_results);
}
+
+ APPEND_SEP
+ g_string_append_printf (query_uri, "includeItemsFromAllDrives=true");
+ APPEND_SEP
+ g_string_append_printf (query_uri, "supportsAllDrives=true");
}
/**
diff --git a/gdata/services/documents/gdata-documents-service.c b/gdata/services/documents/gdata-documents-service.c
index 93bc8f71..fa0b81ec 100644
--- a/gdata/services/documents/gdata-documents-service.c
+++ b/gdata/services/documents/gdata-documents-service.c
@@ -261,6 +261,7 @@
#include "gdata-documents-property.h"
#include "gdata-documents-service.h"
#include "gdata-documents-utils.h"
+#include "gdata-documents-drive.h"
#include "gdata-batchable.h"
#include "gdata-service.h"
#include "gdata-private.h"
@@ -643,6 +644,101 @@ gdata_documents_service_query_documents_async (GDataDocumentsService *self, GDat
g_free (request_uri);
}
+/**
+ * gdata_documents_service_query_drives:
+ * @self: a #GDataDocumentsService
+ * @query: (nullable): a #GDataDocumentsDriveQuery with the query parameters, or %NULL
+ * @cancellable: (nullable): optional #GCancellable object, or %NULL
+ * @progress_callback: (nullable) (scope call) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry is loaded, or %NULL
+ * @progress_user_data: (closure): data to pass to the @progress_callback function
+ * @error: a #GError, or %NULL
+ *
+ * Queries the service to return a list of shared drives matching the given @query.
+ *
+ * For more details, see gdata_service_query().
+ *
+ * Return value: (transfer full): a #GDataDocumentsFeed of query results; unref with g_object_unref()
+ *
+ * Since: 0.18.0
+ */
+GDataDocumentsFeed *
+gdata_documents_service_query_drives (GDataDocumentsService *self, GDataDocumentsDriveQuery *query, GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error)
+{
+ GDataFeed *feed;
+ const gchar *request_uri = "https://www.googleapis.com/drive/v2/drives";
+
+ g_return_val_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self), NULL);
+ g_return_val_if_fail (query == NULL || GDATA_IS_DOCUMENTS_DRIVE_QUERY (query), NULL);
+ g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ /* Ensure we're authenticated first */
+ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)),
+ get_documents_authorization_domain ()) == FALSE) {
+ g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,
+ _("You must be authenticated to query drives."));
+ return NULL;
+ }
+
+ feed = gdata_service_query (GDATA_SERVICE (self), get_documents_authorization_domain (), request_uri, GDATA_QUERY (query),
+ GDATA_TYPE_DOCUMENTS_DRIVE, cancellable, progress_callback, progress_user_data, error);
+
+ return GDATA_DOCUMENTS_FEED (feed);
+}
+
+/**
+ * gdata_documents_service_query_drives_async:
+ * @self: a #GDataDocumentsService
+ * @query: (nullable): a #GDataDocumentsDriveQuery with the query parameters, or %NULL
+ * @cancellable: (nullable): optional #GCancellable object, or %NULL
+ * @progress_callback: (nullable) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry is loaded, or %NULL
+ * @progress_user_data: (closure): data to pass to the @progress_callback function
+ * @destroy_progress_user_data: (nullable): the function to call when @progress_callback will not be called any more, or %NULL. This function will be
+ * called with @progress_user_data as a parameter and can be used to free any memory allocated for it.
+ * @callback: a #GAsyncReadyCallback to call when authentication is finished
+ * @user_data: (closure): data to pass to the @callback function
+ *
+ * Queries the service to return a list of shared drives matching the given @query. @self and
+ * @query are both reffed when this function is called, so can safely be unreffed after this function returns.
+ *
+ * For more details, see gdata_documents_service_query_drives(), which is the synchronous version of this function,
+ * and gdata_service_query_async(), which is the base asynchronous query function.
+ *
+ * Since: 0.18.0
+ */
+void
+gdata_documents_service_query_drives_async (GDataDocumentsService *self, GDataDocumentsDriveQuery *query, GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
+ GDestroyNotify destroy_progress_user_data,
+ GAsyncReadyCallback callback, gpointer user_data)
+{
+ const gchar *request_uri = "https://www.googleapis.com/drive/v2/drives";
+
+ g_return_if_fail (GDATA_IS_DOCUMENTS_SERVICE (self));
+ g_return_if_fail (query == NULL || GDATA_IS_DOCUMENTS_QUERY (query));
+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+ g_return_if_fail (callback != NULL);
+
+ /* Ensure we're authenticated first */
+ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)),
+ get_documents_authorization_domain ()) == FALSE) {
+ g_autoptr(GTask) task = NULL;
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gdata_service_query_async);
+ g_task_return_new_error (task, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, "%s",
+ _("You must be authenticated to query drives."));
+
+ return;
+ }
+
+ gdata_service_query_async (GDATA_SERVICE (self), get_documents_authorization_domain (), request_uri, GDATA_QUERY (query),
+ GDATA_TYPE_DOCUMENTS_DRIVE, cancellable, progress_callback, progress_user_data,
+ destroy_progress_user_data, callback, user_data);
+}
+
static void
add_folder_link_to_entry (GDataDocumentsEntry *entry, GDataDocumentsFolder *folder)
{
diff --git a/gdata/services/documents/gdata-documents-service.h b/gdata/services/documents/gdata-documents-service.h
index ab2ea7e2..da173ad0 100644
--- a/gdata/services/documents/gdata-documents-service.h
+++ b/gdata/services/documents/gdata-documents-service.h
@@ -28,6 +28,7 @@
#include <gdata/services/documents/gdata-documents-query.h>
#include <gdata/services/documents/gdata-documents-feed.h>
#include <gdata/services/documents/gdata-documents-metadata.h>
+#include <gdata/services/documents/gdata-documents-drive-query.h>
G_BEGIN_DECLS
@@ -112,6 +113,14 @@ void gdata_documents_service_query_documents_async (GDataDocumentsService *self,
GDestroyNotify destroy_progress_user_data,
GAsyncReadyCallback callback, gpointer user_data);
+GDataDocumentsFeed *gdata_documents_service_query_drives (GDataDocumentsService *self, GDataDocumentsDriveQuery *query, GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
+ GError **error) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+void gdata_documents_service_query_drives_async (GDataDocumentsService *self, GDataDocumentsDriveQuery *query, GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
+ GDestroyNotify destroy_progress_user_data,
+ GAsyncReadyCallback callback, gpointer user_data);
+
#include <gdata/services/documents/gdata-documents-document.h>
#include <gdata/services/documents/gdata-documents-folder.h>
#include <gdata/services/documents/gdata-documents-upload-query.h>
diff --git a/gdata/services/documents/meson.build b/gdata/services/documents/meson.build
index a0984839..f29cbb0d 100644
--- a/gdata/services/documents/meson.build
+++ b/gdata/services/documents/meson.build
@@ -6,6 +6,8 @@ headers = files(
'gdata-documents-access-rule.h',
'gdata-documents-document.h',
'gdata-documents-drawing.h',
+ 'gdata-documents-drive.h',
+ 'gdata-documents-drive-query.h',
'gdata-documents-entry.h',
'gdata-documents-feed.h',
'gdata-documents-folder.h',
@@ -31,6 +33,8 @@ sources += files(
'gdata-documents-access-rule.c',
'gdata-documents-document.c',
'gdata-documents-drawing.c',
+ 'gdata-documents-drive.c',
+ 'gdata-documents-drive-query.c',
'gdata-documents-entry.c',
'gdata-documents-feed.c',
'gdata-documents-folder.c',
diff --git a/gdata/symbol.map b/gdata/symbol.map
index f8ab89c4..15e58a7b 100644
--- a/gdata/symbol.map
+++ b/gdata/symbol.map
@@ -310,6 +310,10 @@ global:
gdata_documents_document_new;
gdata_documents_drawing_get_type;
gdata_documents_drawing_new;
+ gdata_documents_drive_get_type;
+ gdata_documents_drive_get_name;
+ gdata_documents_drive_query_get_type;
+ gdata_documents_drive_query_new;
gdata_documents_entry_add_documents_property;
gdata_documents_entry_get_document_id;
gdata_documents_entry_get_document_properties;
@@ -378,6 +382,8 @@ global:
gdata_documents_service_new;
gdata_documents_service_query_documents;
gdata_documents_service_query_documents_async;
+ gdata_documents_service_query_drives;
+ gdata_documents_service_query_drives_async;
gdata_documents_service_remove_entry_from_folder;
gdata_documents_service_remove_entry_from_folder_async;
gdata_documents_service_remove_entry_from_folder_finish;