[gnome-online-accounts/wip/rishi/account-remove: 1/10] provider: Add a new vfunc for backend-specific work on account removal



commit f1f6ea49d87915d1fdf6e08913747cdda327bb79
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri May 20 18:48:37 2016 +0200

    provider: Add a new vfunc for backend-specific work on account removal
    
    Some GoaProvider sub-classes (eg., Kerberos and Telepathy) need to
    perform some extra clean up when an account is removed. This virtual
    method will let them hook into the account removal operation to do so.
    
    The default implementation of this virtual method simply returns TRUE.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766733

 src/goabackend/goaprovider-priv.h |   18 +++++++++
 src/goabackend/goaprovider.c      |   73 +++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/goaprovider-priv.h b/src/goabackend/goaprovider-priv.h
index 9926a23..ae06d95 100644
--- a/src/goabackend/goaprovider-priv.h
+++ b/src/goabackend/goaprovider-priv.h
@@ -92,6 +92,14 @@ struct _GoaProviderClass
   guint                   (*get_credentials_generation)   (GoaProvider            *self);
   GIcon                  *(*get_provider_icon)            (GoaProvider            *self,
                                                            GoaObject              *object);
+  void                    (*remove_account)               (GoaProvider            *self,
+                                                           GoaObject              *object,
+                                                           GCancellable           *cancellable,
+                                                           GAsyncReadyCallback     callback,
+                                                           gpointer                user_data);
+  gboolean                (*remove_account_finish)        (GoaProvider            *self,
+                                                           GAsyncResult           *res,
+                                                           GError                **error);
   void                    (*show_account)                 (GoaProvider            *self,
                                                            GoaClient              *client,
                                                            GoaObject              *object,
@@ -118,6 +126,16 @@ void        goa_provider_ensure_builtins_loaded                (void);
 
 void        goa_provider_ensure_extension_points_registered    (void);
 
+void        goa_provider_remove_account                        (GoaProvider             *self,
+                                                                GoaObject               *object,
+                                                                GCancellable            *cancellable,
+                                                                GAsyncReadyCallback      callback,
+                                                                gpointer                 user_data);
+
+gboolean    goa_provider_remove_account_finish                 (GoaProvider             *self,
+                                                                GAsyncResult            *res,
+                                                                GError                 **error);
+
 G_END_DECLS
 
 #endif /* __GOA_PROVIDER_PRIV_H__ */
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 28324fc..336bbcb 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -81,6 +81,17 @@ static guint goa_provider_get_credentials_generation_real (GoaProvider *self);
 
 static GIcon *goa_provider_get_provider_icon_real (GoaProvider *self,
                                                    GoaObject   *object);
+
+static void goa_provider_remove_account_real (GoaProvider          *self,
+                                              GoaObject            *object,
+                                              GCancellable         *cancellable,
+                                              GAsyncReadyCallback   callback,
+                                              gpointer              user_data);
+
+static gboolean goa_provider_remove_account_finish_real (GoaProvider   *self,
+                                                         GAsyncResult  *res,
+                                                         GError       **error);
+
 static void goa_provider_show_account_real (GoaProvider         *provider,
                                             GoaClient           *client,
                                             GoaObject           *object,
@@ -235,6 +246,8 @@ goa_provider_class_init (GoaProviderClass *klass)
   klass->ensure_credentials_sync = goa_provider_ensure_credentials_sync_real;
   klass->get_credentials_generation = goa_provider_get_credentials_generation_real;
   klass->get_provider_icon = goa_provider_get_provider_icon_real;
+  klass->remove_account = goa_provider_remove_account_real;
+  klass->remove_account_finish = goa_provider_remove_account_finish_real;
   klass->show_account = goa_provider_show_account_real;
 
 /**
@@ -1291,6 +1304,66 @@ goa_provider_get_all_finish (GList        **out_providers,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+void
+goa_provider_remove_account (GoaProvider          *self,
+                             GoaObject            *object,
+                             GCancellable         *cancellable,
+                             GAsyncReadyCallback   callback,
+                             gpointer              user_data)
+{
+  g_return_if_fail (GOA_IS_PROVIDER (self));
+  g_return_if_fail (GOA_IS_OBJECT (object));
+  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
+  GOA_PROVIDER_GET_CLASS (self)->remove_account (self, object, cancellable, callback, user_data);
+}
+
+gboolean
+goa_provider_remove_account_finish (GoaProvider   *self,
+                                    GAsyncResult  *res,
+                                    GError       **error)
+{
+  g_return_val_if_fail (GOA_IS_PROVIDER (self), FALSE);
+  g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  return GOA_PROVIDER_GET_CLASS (self)->remove_account_finish (self, res, error);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+goa_provider_remove_account_real (GoaProvider          *self,
+                                  GoaObject            *object,
+                                  GCancellable         *cancellable,
+                                  GAsyncReadyCallback   callback,
+                                  gpointer              user_data)
+{
+  GTask *task;
+
+  task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_source_tag (task, goa_provider_remove_account_real);
+  g_task_return_boolean (task, TRUE);
+  g_object_unref (task);
+}
+
+static gboolean
+goa_provider_remove_account_finish_real (GoaProvider   *self,
+                                         GAsyncResult  *res,
+                                         GError       **error)
+{
+  GTask *task;
+
+  g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
+  task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == goa_provider_remove_account_real);
+
+  return g_task_propagate_boolean (task, error);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 /**
  * goa_provider_set_preseed_data:
  * @self: The #GoaProvider


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