[libgdata] documents: Add support for editing ACLs using Drive v2
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] documents: Add support for editing ACLs using Drive v2
- Date: Fri, 12 Jun 2015 11:31:54 +0000 (UTC)
commit e2ab462d63e81a32dcca842bccfdd753bd5dd55f
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jun 5 11:54:41 2015 +0200
documents: Add support for editing ACLs using Drive v2
A new sub-class was introduced to set JSON as the content-type for
Drive v2. It was a good opportunity to move the Drive-specific JSON
parsing code from the base class.
New API added:
• GDataDocumentsAccessRule
This new class must be used in place of GDataAccessRule for any
interactions with the Drive API. This is essentially a soft API break,
but it’s unavoidable.
https://bugzilla.gnome.org/show_bug.cgi?id=684920
Makefile.am | 4 +-
docs/reference/gdata-docs.xml | 1 +
docs/reference/gdata-sections.txt | 18 ++
gdata/gdata-access-rule.c | 69 ------
gdata/gdata.h | 1 +
gdata/gdata.symbols | 2 +
.../documents/gdata-documents-access-rule.c | 230 ++++++++++++++++++++
.../documents/gdata-documents-access-rule.h | 74 +++++++
gdata/services/documents/gdata-documents-entry.c | 39 ++++
po/POTFILES.in | 2 +-
10 files changed, 369 insertions(+), 71 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7b4982b..1944ddd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -292,7 +292,8 @@ gdata_documents_headers = \
gdata/services/documents/gdata-documents-drawing.h \
gdata/services/documents/gdata-documents-pdf.h \
gdata/services/documents/gdata-documents-spreadsheet.h \
- gdata/services/documents/gdata-documents-upload-query.h
+ gdata/services/documents/gdata-documents-upload-query.h \
+ gdata/services/documents/gdata-documents-access-rule.h
gdatadocumentsinclude_HEADERS = \
$(gdata_documents_headers) \
gdata/services/documents/gdata-documents-enums.h
@@ -431,6 +432,7 @@ gdata_sources = \
gdata/services/documents/gdata-documents-pdf.c \
gdata/services/documents/gdata-documents-query.c \
gdata/services/documents/gdata-documents-upload-query.c \
+ gdata/services/documents/gdata-documents-access-rule.c \
\
gdata/services/picasaweb/gdata-picasaweb-album.c \
gdata/services/picasaweb/gdata-picasaweb-query.c \
diff --git a/docs/reference/gdata-docs.xml b/docs/reference/gdata-docs.xml
index 4f7ede0..3db99d3 100644
--- a/docs/reference/gdata-docs.xml
+++ b/docs/reference/gdata-docs.xml
@@ -166,6 +166,7 @@
<xi:include href="xml/gdata-documents-presentation.xml"/>
<xi:include href="xml/gdata-documents-spreadsheet.xml"/>
<xi:include href="xml/gdata-documents-text.xml"/>
+ <xi:include href="xml/gdata-documents-access-rule.xml"/>
</chapter>
<chapter>
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 92e68b2..d841848 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -2833,3 +2833,21 @@ GDATA_TYPE_CALENDAR_ACCESS_RULE
<SUBSECTION Private>
GDataCalendarAccessRulePrivate
</SECTION>
+
+<SECTION>
+<FILE>gdata-documents-access-rule</FILE>
+<TITLE>GDataDocumentsAccessRule</TITLE>
+GDataDocumentsAccessRule
+GDataDocumentsAccessRuleClass
+gdata_documents_access_rule_new
+<SUBSECTION Standard>
+gdata_documents_access_rule_get_type
+GDATA_DOCUMENTS_ACCESS_RULE
+GDATA_DOCUMENTS_ACCESS_RULE_CLASS
+GDATA_DOCUMENTS_ACCESS_RULE_GET_CLASS
+GDATA_IS_DOCUMENTS_ACCESS_RULE
+GDATA_IS_DOCUMENTS_ACCESS_RULE_CLASS
+GDATA_TYPE_DOCUMENTS_ACCESS_RULE
+<SUBSECTION Private>
+GDataDocumentsAccessRulePrivate
+</SECTION>
diff --git a/gdata/gdata-access-rule.c b/gdata/gdata-access-rule.c
index 6506b38..e75aa08 100644
--- a/gdata/gdata-access-rule.c
+++ b/gdata/gdata-access-rule.c
@@ -80,7 +80,6 @@
#include <config.h>
#include <glib.h>
-#include <glib/gi18n-lib.h>
#include <libxml/parser.h>
#include <string.h>
@@ -96,12 +95,8 @@ static void get_xml (GDataParsable *parsable, GString *xml_string);
static void gdata_access_rule_set_property (GObject *object, guint property_id, const GValue *value,
GParamSpec *pspec);
static void gdata_access_rule_get_property (GObject *object, guint property_id, GValue *value, GParamSpec
*pspec);
static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError
**error);
-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 _GDataAccessRulePrivate {
- gchar *domain;
- gchar *email;
gchar *role;
gchar *scope_type;
gchar *scope_value;
@@ -138,9 +133,6 @@ gdata_access_rule_class_init (GDataAccessRuleClass *klass)
parsable_class->get_xml = get_xml;
parsable_class->get_namespaces = get_namespaces;
- parsable_class->parse_json = parse_json;
- parsable_class->post_parse_json = post_parse_json;
-
entry_class->kind_term = "http://schemas.google.com/acl/2007#accessRule";
/**
@@ -285,8 +277,6 @@ gdata_access_rule_finalize (GObject *object)
{
GDataAccessRulePrivate *priv = GDATA_ACCESS_RULE (object)->priv;
- g_free (priv->domain);
- g_free (priv->email);
g_free (priv->role);
g_free (priv->scope_type);
g_free (priv->scope_value);
@@ -493,65 +483,6 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
g_hash_table_insert (namespaces, (gchar*) "gAcl", (gchar*) "http://schemas.google.com/acl/2007");
}
-static gboolean
-parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
-{
- GDataAccessRulePrivate *priv = GDATA_ACCESS_RULE (parsable)->priv;
- gboolean success;
- gchar *scope_type = NULL;
-
- if (gdata_parser_string_from_json_member (reader, "authKey", P_REQUIRED | P_NON_EMPTY, &(priv->key),
&success, error) == TRUE ||
- gdata_parser_string_from_json_member (reader, "emailAddress", P_REQUIRED | P_NON_EMPTY,
&(priv->email), &success, error) == TRUE ||
- gdata_parser_string_from_json_member (reader, "domain", P_REQUIRED | P_NON_EMPTY,
&(priv->domain), &success, error) == TRUE ||
- gdata_parser_string_from_json_member (reader, "role", P_REQUIRED | P_NON_EMPTY, &(priv->role),
&success, error) == TRUE) {
- return success;
- } else if (gdata_parser_string_from_json_member (reader, "type", P_REQUIRED | P_NON_EMPTY,
&scope_type, &success, error) == TRUE) {
- if (g_strcmp0 (scope_type, "anyone") == 0) {
- priv->scope_type = g_strdup (GDATA_ACCESS_SCOPE_DEFAULT);
- } else {
- priv->scope_type = scope_type;
- scope_type = NULL;
- }
-
- g_free (scope_type);
- return success;
- }
-
- return GDATA_PARSABLE_CLASS (gdata_access_rule_parent_class)->parse_json (parsable, reader,
user_data, error);
-}
-
-static gboolean
-post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
-{
- GDataAccessRulePrivate *priv = GDATA_ACCESS_RULE (parsable)->priv;
-
- if (g_strcmp0 (priv->scope_type, "group") == 0 || g_strcmp0 (priv->scope_type, "user") == 0) {
- if (priv->email == NULL || priv->email[0] == '\0') {
- g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_PARSING_STRING,
- /* Translators: the parameter is an error message */
- _("Error parsing JSON: %s"),
- "Permission type ‘group’ or ‘user’ needs an ‘emailAddress’ property.");
- return FALSE;
- } else {
- priv->scope_value = priv->email;
- priv->email = NULL;
- }
- } else if (g_strcmp0 (priv->scope_type, "domain") == 0) {
- if (priv->domain == NULL || priv->domain[0] == '\0') {
- g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_PARSING_STRING,
- /* Translators: the parameter is an error message */
- _("Error parsing JSON: %s"),
- "Permission type ‘domain’ needs a ‘domain’ property.");
- return FALSE;
- } else {
- priv->scope_value = priv->domain;
- priv->domain = NULL;
- }
- }
-
- return TRUE;
-}
-
/**
* gdata_access_rule_new:
* @id: the access rule's ID, or %NULL
diff --git a/gdata/gdata.h b/gdata/gdata.h
index f259b26..3231219 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -139,6 +139,7 @@
#include <gdata/services/documents/gdata-documents-pdf.h>
#include <gdata/services/documents/gdata-documents-enums.h>
#include <gdata/services/documents/gdata-documents-upload-query.h>
+#include <gdata/services/documents/gdata-documents-access-rule.h>
/* Google Tasks */
#include <gdata/services/tasks/gdata-tasks-service.h>
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 30c4a30..ae4cfb7 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -659,6 +659,8 @@ gdata_documents_query_add_reader
gdata_documents_query_add_collaborator
gdata_documents_service_error_get_type
gdata_documents_service_error_quark
+gdata_documents_access_rule_get_type
+gdata_documents_access_rule_new
gdata_download_stream_get_type
gdata_download_stream_new
gdata_download_stream_get_service
diff --git a/gdata/services/documents/gdata-documents-access-rule.c
b/gdata/services/documents/gdata-documents-access-rule.c
new file mode 100644
index 0000000..6041392
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-access-rule.c
@@ -0,0 +1,230 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Red Hat, Inc. 2015
+ *
+ * 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-access-rule
+ * @short_description: GData Documents access rule object
+ * @stability: Stable
+ * @include: gdata/services/documents/gdata-documents-access-rule.h
+ *
+ * #GDataDocumentsAccessRule is a subclass of #GDataAccessRule to represent an
+ * access rule affecting users of a Google Documents entry.
+ *
+ * Since: UNRELEASED
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdata-documents-access-rule.h"
+#include "gdata-parser.h"
+#include "gdata-private.h"
+
+static void gdata_documents_access_rule_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);
+static const gchar *get_content_type (void);
+static void get_json (GDataParsable *parsable, JsonBuilder *builder);
+
+typedef struct {
+ gchar *domain;
+ gchar *email;
+ gchar *scope_type;
+} GDataDocumentsAccessRulePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GDataDocumentsAccessRule, gdata_documents_access_rule, GDATA_TYPE_ACCESS_RULE)
+
+static void
+gdata_documents_access_rule_class_init (GDataDocumentsAccessRuleClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
+
+ gobject_class->finalize = gdata_documents_access_rule_finalize;
+ parsable_class->parse_json = parse_json;
+ parsable_class->post_parse_json = post_parse_json;
+ parsable_class->get_content_type = get_content_type;
+ parsable_class->get_json = get_json;
+}
+
+static void
+gdata_documents_access_rule_init (GDataDocumentsAccessRule *self)
+{
+ /* Nothing to do here. */
+}
+
+static void
+gdata_documents_access_rule_finalize (GObject *object)
+{
+ GDataDocumentsAccessRulePrivate *priv;
+
+ priv = gdata_documents_access_rule_get_instance_private (GDATA_DOCUMENTS_ACCESS_RULE (object));
+
+ g_free (priv->domain);
+ g_free (priv->email);
+ g_free (priv->scope_type);
+
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (gdata_documents_access_rule_parent_class)->finalize (object);
+}
+
+static gboolean
+parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
+{
+ GDataDocumentsAccessRulePrivate *priv;
+ gboolean success;
+ gchar *key = NULL;
+ gchar *role = NULL;
+ gchar *scope_type = NULL;
+
+ priv = gdata_documents_access_rule_get_instance_private (GDATA_DOCUMENTS_ACCESS_RULE (parsable));
+
+ /* JSON format: https://developers.google.com/drive/v2/reference/permissions */
+
+ if (gdata_parser_string_from_json_member (reader, "emailAddress", P_REQUIRED | P_NON_EMPTY,
&(priv->email), &success, error) == TRUE ||
+ gdata_parser_string_from_json_member (reader, "domain", P_REQUIRED | P_NON_EMPTY,
&(priv->domain), &success, error) == TRUE) {
+ return success;
+ } else if (gdata_parser_string_from_json_member (reader, "authKey", P_REQUIRED | P_NON_EMPTY, &key,
&success, error) == TRUE) {
+ if (success && key != NULL && key[0] != '\0')
+ _gdata_access_rule_set_key (GDATA_ACCESS_RULE (parsable), key);
+
+ g_free (key);
+ return success;
+ } else if (gdata_parser_string_from_json_member (reader, "role", P_REQUIRED | P_NON_EMPTY, &role,
&success, error) == TRUE) {
+ if (success && role != NULL && role[0] != '\0')
+ gdata_access_rule_set_role (GDATA_ACCESS_RULE (parsable), role);
+
+ g_free (role);
+ return success;
+ } else if (gdata_parser_string_from_json_member (reader, "type", P_REQUIRED | P_NON_EMPTY,
&scope_type, &success, error) == TRUE) {
+ if (g_strcmp0 (scope_type, "anyone") == 0) {
+ priv->scope_type = g_strdup (GDATA_ACCESS_SCOPE_DEFAULT);
+ } else {
+ priv->scope_type = scope_type;
+ scope_type = NULL;
+ }
+
+ g_free (scope_type);
+ return success;
+ }
+
+ return GDATA_PARSABLE_CLASS (gdata_documents_access_rule_parent_class)->parse_json (parsable, reader,
user_data, error);
+}
+
+static gboolean
+post_parse_json (GDataParsable *parsable, gpointer user_data, GError **error)
+{
+ GDataDocumentsAccessRulePrivate *priv;
+
+ priv = gdata_documents_access_rule_get_instance_private (GDATA_DOCUMENTS_ACCESS_RULE (parsable));
+
+ if (g_strcmp0 (priv->scope_type, GDATA_ACCESS_SCOPE_DEFAULT) == 0) {
+ gdata_access_rule_set_scope (GDATA_ACCESS_RULE (parsable), priv->scope_type, NULL);
+ } else if (g_strcmp0 (priv->scope_type, "group") == 0 || g_strcmp0 (priv->scope_type,
GDATA_ACCESS_SCOPE_USER) == 0) {
+ if (priv->email == NULL || priv->email[0] == '\0') {
+ g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_PARSING_STRING,
+ /* Translators: the parameter is an error message */
+ _("Error parsing JSON: %s"),
+ "Permission type ‘group’ or ‘user’ needs an ‘emailAddress’ property.");
+ return FALSE;
+ } else {
+ gdata_access_rule_set_scope (GDATA_ACCESS_RULE (parsable), priv->scope_type,
priv->email);
+ }
+ } else if (g_strcmp0 (priv->scope_type, GDATA_ACCESS_SCOPE_DOMAIN) == 0) {
+ if (priv->domain == NULL || priv->domain[0] == '\0') {
+ g_set_error (error, GDATA_PARSER_ERROR, GDATA_PARSER_ERROR_PARSING_STRING,
+ /* Translators: the parameter is an error message */
+ _("Error parsing JSON: %s"),
+ "Permission type ‘domain’ needs a ‘domain’ property.");
+ return FALSE;
+ } else {
+ gdata_access_rule_set_scope (GDATA_ACCESS_RULE (parsable), priv->scope_type,
priv->domain);
+ }
+ }
+
+ return TRUE;
+}
+
+static const gchar *
+get_content_type (void)
+{
+ return "application/json";
+}
+
+static void
+get_json (GDataParsable *parsable, JsonBuilder *builder)
+{
+ const gchar *key;
+ const gchar *role;
+ const gchar *scope_type;
+ const gchar *scope_value;
+
+ GDATA_PARSABLE_CLASS (gdata_documents_access_rule_parent_class)->get_json (parsable, builder);
+
+ key = gdata_access_rule_get_key (GDATA_ACCESS_RULE (parsable));
+ if (key != NULL && key[0] != '\0') {
+ json_builder_set_member_name (builder, "authKey");
+ json_builder_add_string_value (builder, key);
+ }
+
+ role = gdata_access_rule_get_role (GDATA_ACCESS_RULE (parsable));
+ if (role != NULL && role[0] != '\0') {
+ json_builder_set_member_name (builder, "role");
+ json_builder_add_string_value (builder, role);
+ }
+
+ gdata_access_rule_get_scope (GDATA_ACCESS_RULE (parsable), &scope_type, &scope_value);
+
+ if (scope_type != NULL && scope_type[0] != '\0') {
+ if (g_strcmp0 (scope_type, GDATA_ACCESS_SCOPE_DEFAULT) == 0)
+ scope_type = "anyone";
+
+ json_builder_set_member_name (builder, "type");
+ json_builder_add_string_value (builder, scope_type);
+ }
+
+ if (scope_value != NULL && scope_value[0] != '\0') {
+ json_builder_set_member_name (builder, "value");
+ json_builder_add_string_value (builder, scope_value);
+ }
+}
+
+/**
+ * gdata_documents_access_rule_new:
+ * @id: the access rule's ID, or %NULL
+ *
+ * Creates a new #GDataDocumentsAccessRule with the given ID and default
+ * properties.
+ *
+ * Return value: (transfer full): a new #GDataDocumentsAccessRule; unref with
+ * g_object_unref()
+ *
+ * Since: UNRELEASED
+ */
+GDataDocumentsAccessRule *
+gdata_documents_access_rule_new (const gchar *id)
+{
+ GObject *retval = NULL; /* owned */
+
+ retval = g_object_new (GDATA_TYPE_DOCUMENTS_ACCESS_RULE,
+ "id", id,
+ NULL);
+ return GDATA_DOCUMENTS_ACCESS_RULE (retval);
+}
diff --git a/gdata/services/documents/gdata-documents-access-rule.h
b/gdata/services/documents/gdata-documents-access-rule.h
new file mode 100644
index 0000000..6d5b162
--- /dev/null
+++ b/gdata/services/documents/gdata-documents-access-rule.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Red Hat, Inc. 2015
+ *
+ * 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_ACCESS_RULE_H
+#define GDATA_DOCUMENTS_ACCESS_RULE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/gdata-access-rule.h>
+
+G_BEGIN_DECLS
+
+#define GDATA_TYPE_DOCUMENTS_ACCESS_RULE (gdata_documents_access_rule_get_type ())
+#define GDATA_DOCUMENTS_ACCESS_RULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
GDATA_TYPE_DOCUMENTS_ACCESS_RULE, GDataDocumentsAccessRule))
+#define GDATA_DOCUMENTS_ACCESS_RULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
GDATA_TYPE_DOCUMENTS_ACCESS_RULE, GDataDocumentsAccessRuleClass))
+#define GDATA_IS_DOCUMENTS_ACCESS_RULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
GDATA_TYPE_DOCUMENTS_ACCESS_RULE))
+#define GDATA_IS_DOCUMENTS_ACCESS_RULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
GDATA_TYPE_DOCUMENTS_ACCESS_RULE))
+#define GDATA_DOCUMENTS_ACCESS_RULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
GDATA_TYPE_DOCUMENTS_ACCESS_RULE, GDataDocumentsAccessRuleClass))
+
+/**
+ * GDataDocumentsAccessRule:
+ *
+ * All the fields in the #GDataDocumentsAccessRule structure are private and
+ * should never be accessed directly.
+ *
+ * Since: UNRELEASED
+ */
+typedef struct {
+ GDataAccessRule parent;
+} GDataDocumentsAccessRule;
+
+/**
+ * GDataDocumentsAccessRuleClass:
+ *
+ * All the fields in the #GDataDocumentsAccessRuleClass structure are private
+ * and should never be accessed directly.
+ *
+ * Since: UNRELEASED
+ */
+typedef struct {
+ /*< private >*/
+ GDataAccessRuleClass parent;
+
+ /*< private >*/
+ /* Padding for future expansion */
+ void (*_g_reserved0) (void);
+ void (*_g_reserved1) (void);
+} GDataDocumentsAccessRuleClass;
+
+GType gdata_documents_access_rule_get_type (void) G_GNUC_CONST;
+
+GDataDocumentsAccessRule *
+gdata_documents_access_rule_new (const gchar *id) G_GNUC_WARN_UNUSED_RESULT G_GNUC_MALLOC;
+
+G_END_DECLS
+
+#endif /* !GDATA_DOCUMENTS_ACCESS_RULE_H */
diff --git a/gdata/services/documents/gdata-documents-entry.c
b/gdata/services/documents/gdata-documents-entry.c
index 21ebacd..f107c61 100644
--- a/gdata/services/documents/gdata-documents-entry.c
+++ b/gdata/services/documents/gdata-documents-entry.c
@@ -104,6 +104,7 @@
#include "gdata-types.h"
#include "gdata-private.h"
#include "gdata-access-handler.h"
+#include "gdata-documents-access-rule.h"
#include "gdata-documents-service.h"
#include "gdata-documents-spreadsheet.h"
@@ -300,11 +301,49 @@ get_authorization_domain (GDataAccessHandler *self)
return gdata_documents_service_get_primary_authorization_domain ();
}
+static GDataFeed *
+get_rules (GDataAccessHandler *self,
+ GDataService *service,
+ GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error)
+{
+ GDataAccessHandlerIface *iface;
+ GDataAuthorizationDomain *domain = NULL;
+ GDataFeed *feed;
+ GDataLink *_link;
+ SoupMessage *message;
+
+ _link = gdata_entry_look_up_link (GDATA_ENTRY (self), GDATA_LINK_ACCESS_CONTROL_LIST);
+ g_assert (_link != NULL);
+
+ iface = GDATA_ACCESS_HANDLER_GET_IFACE (self);
+ if (iface->get_authorization_domain != NULL) {
+ domain = iface->get_authorization_domain (self);
+ }
+
+ message = _gdata_service_query (service, domain, gdata_link_get_uri (_link), NULL, cancellable,
error);
+ if (message == NULL) {
+ return NULL;
+ }
+
+ g_assert (message->response_body->data != NULL);
+
+ feed = _gdata_feed_new_from_json (GDATA_TYPE_FEED, message->response_body->data,
message->response_body->length, GDATA_TYPE_DOCUMENTS_ACCESS_RULE,
+ progress_callback, progress_user_data, error);
+
+ g_object_unref (message);
+
+ return feed;
+}
+
static void
gdata_documents_entry_access_handler_init (GDataAccessHandlerIface *iface)
{
iface->is_owner_rule = is_owner_rule;
iface->get_authorization_domain = get_authorization_domain;
+ iface->get_rules = get_rules;
}
static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 20a3f36..cc8ddc2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
gdata/gdata-access-handler.c
-gdata/gdata-access-rule.c
gdata/gdata-client-login-authorizer.c
gdata/gdata-commentable.c
gdata/gdata-download-stream.c
@@ -18,6 +17,7 @@ gdata/services/calendar/gdata-calendar-calendar.c
gdata/services/calendar/gdata-calendar-event.c
gdata/services/calendar/gdata-calendar-service.c
gdata/services/contacts/gdata-contacts-service.c
+gdata/services/documents/gdata-documents-access-rule.c
gdata/services/documents/gdata-documents-document.c
gdata/services/documents/gdata-documents-entry.c
gdata/services/documents/gdata-documents-feed.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]