[libgdata] core: Virtualise gdata_access_handler_get_rules()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] core: Virtualise gdata_access_handler_get_rules()
- Date: Thu, 14 May 2015 12:40:07 +0000 (UTC)
commit 746739fab55dbc0493ea4a29d68cf545e3f151dc
Author: Philip Withnall <philip withnall collabora co uk>
Date: Tue May 12 20:11:20 2015 +0100
core: Virtualise gdata_access_handler_get_rules()
Add new API:
• GDataAccessHandlerIface.get_rules
as a virtual method backing gdata_access_handler_get_rules().
This does not break ABI as it uses one of the reserved slots in
GDataAccessHandlerIface.
https://bugzilla.gnome.org/show_bug.cgi?id=664353
gdata/gdata-access-handler.c | 53 ++++++++++++++++++++++++++++-------------
gdata/gdata-access-handler.h | 13 ++++++++-
2 files changed, 47 insertions(+), 19 deletions(-)
---
diff --git a/gdata/gdata-access-handler.c b/gdata/gdata-access-handler.c
index a802914..df0304f 100644
--- a/gdata/gdata-access-handler.c
+++ b/gdata/gdata-access-handler.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009–2010 <philip tecnocode co uk>
+ * Copyright (C) Philip Withnall 2009–2010, 2015 <philip tecnocode co uk>
* Copyright (C) Red Hat, Inc. 2015
*
* GData Client is free software; you can redistribute it and/or
@@ -46,19 +46,22 @@
#include "gdata-private.h"
#include "gdata-access-rule.h"
-GType
-gdata_access_handler_get_type (void)
-{
- static GType access_handler_type = 0;
+static GDataFeed *
+gdata_access_handler_real_get_rules (GDataAccessHandler *self,
+ GDataService *service,
+ GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
- if (!access_handler_type) {
- access_handler_type = g_type_register_static_simple (G_TYPE_INTERFACE, "GDataAccessHandler",
- sizeof (GDataAccessHandlerIface),
- NULL, 0, NULL, 0);
- g_type_interface_add_prerequisite (access_handler_type, GDATA_TYPE_ENTRY);
- }
+typedef GDataAccessHandlerIface GDataAccessHandlerInterface;
+G_DEFINE_INTERFACE (GDataAccessHandler, gdata_access_handler,
+ GDATA_TYPE_ENTRY);
- return access_handler_type;
+static void
+gdata_access_handler_default_init (GDataAccessHandlerInterface *iface)
+{
+ iface->get_rules = gdata_access_handler_real_get_rules;
}
typedef struct {
@@ -81,8 +84,12 @@ get_rules_async_data_free (GetRulesAsyncData *self)
}
static GDataFeed *
-_gdata_access_handler_get_rules (GDataAccessHandler *self, GDataService *service, GCancellable *cancellable,
- GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
GError **error)
+gdata_access_handler_real_get_rules (GDataAccessHandler *self,
+ GDataService *service,
+ GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error)
{
GDataAccessHandlerIface *iface;
GDataAuthorizationDomain *domain = NULL;
@@ -131,12 +138,18 @@ _gdata_access_handler_get_rules (GDataAccessHandler *self, GDataService *service
static void
get_rules_thread (GSimpleAsyncResult *result, GDataAccessHandler *access_handler, GCancellable *cancellable)
{
+ GDataAccessHandlerIface *iface;
GError *error = NULL;
GetRulesAsyncData *data = g_simple_async_result_get_op_res_gpointer (result);
/* Execute the query and return */
- data->feed = _gdata_access_handler_get_rules (access_handler, data->service, cancellable,
data->progress_callback, data->progress_user_data,
- &error);
+ iface = GDATA_ACCESS_HANDLER_GET_IFACE (access_handler);
+ g_assert (iface->get_rules != NULL);
+
+ data->feed = iface->get_rules (access_handler, data->service,
+ cancellable, data->progress_callback,
+ data->progress_user_data, &error);
+
if (data->feed == NULL && error != NULL) {
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
@@ -224,10 +237,16 @@ GDataFeed *
gdata_access_handler_get_rules (GDataAccessHandler *self, GDataService *service, GCancellable *cancellable,
GDataQueryProgressCallback progress_callback, gpointer progress_user_data,
GError **error)
{
+ GDataAccessHandlerIface *iface;
+
g_return_val_if_fail (GDATA_IS_ACCESS_HANDLER (self), NULL);
g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return _gdata_access_handler_get_rules (self, service, cancellable, progress_callback,
progress_user_data, error);
+ iface = GDATA_ACCESS_HANDLER_GET_IFACE (self);
+ g_assert (iface->get_rules != NULL);
+
+ return iface->get_rules (self, service, cancellable, progress_callback,
+ progress_user_data, error);
}
diff --git a/gdata/gdata-access-handler.h b/gdata/gdata-access-handler.h
index 9700746..2b45c4a 100644
--- a/gdata/gdata-access-handler.h
+++ b/gdata/gdata-access-handler.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* GData Client
- * Copyright (C) Philip Withnall 2009 <philip tecnocode co uk>
+ * Copyright (C) Philip Withnall 2009, 2015 <philip tecnocode co uk>
*
* GData Client is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -64,6 +64,9 @@ typedef struct _GDataAccessHandler GDataAccessHandler; /* dummy typedef */
* @get_authorization_domain: (allow-none): a function to return the #GDataAuthorizationDomain to be used
for all operations on the access rules
* belonging to this access handler; not implementing this function is equivalent to returning %NULL from
it, which signifies that operations on the
* access rules don't require authorization; new in version 0.9.0
+ * @get_rules: (nullable): a function to query, parse and return a #GDataFeed of
+ * #GDataAccessRules for a given entry — the virtual function for
+ * gdata_access_handler_get_rules(); new in version UNRELEASED
*
* The class structure for the #GDataAccessHandler interface.
*
@@ -75,9 +78,15 @@ typedef struct {
gboolean (*is_owner_rule) (GDataAccessRule *rule);
GDataAuthorizationDomain *(*get_authorization_domain) (GDataAccessHandler *self);
+ GDataFeed *(*get_rules) (GDataAccessHandler *self,
+ GDataService *service,
+ GCancellable *cancellable,
+ GDataQueryProgressCallback progress_callback,
+ gpointer progress_user_data,
+ GError **error);
+
/*< private >*/
/* Padding for future expansion */
- void (*_g_reserved0) (void);
void (*_g_reserved1) (void);
void (*_g_reserved2) (void);
void (*_g_reserved3) (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]