gnome-online-accounts/0001-Ensure-that-the-factory-is-initialized-before-using-.patch
2013-09-27 15:23:25 +02:00

162 lines
5.6 KiB
Diff

From af7ee1e614c89585e688f2e10f34c3254242836d Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Thu, 26 Sep 2013 14:42:14 +0200
Subject: [PATCH 1/2] Ensure that the factory is initialized before using the
account manager
GoaTelepathyProvider is not the only one who uses the account manager.
GoaTpAccountLinker uses it too. We should initialize the client
factory before using the linker so that we really have all required
account and connection features.
Fixes: https://bugzilla.gnome.org/708462
---
src/daemon/goatpaccountlinker.c | 3 +++
src/goabackend/goatelepathyprovider.c | 30 ++----------------------------
src/goabackend/goautils.c | 34 ++++++++++++++++++++++++++++++++++
src/goabackend/goautils.h | 2 ++
4 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/src/daemon/goatpaccountlinker.c b/src/daemon/goatpaccountlinker.c
index ea1eda9..b7142ea 100644
--- a/src/daemon/goatpaccountlinker.c
+++ b/src/daemon/goatpaccountlinker.c
@@ -34,6 +34,7 @@
#include "goatpaccountlinker.h"
#include "goa/goa.h"
#include "goabackend/goalogging.h"
+#include "goabackend/goautils.h"
#define GOA_TP_ACCOUNT_LINKER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOA_TYPE_TP_ACCOUNT_LINKER, \
@@ -579,6 +580,8 @@ goa_tp_account_linker_class_init (GoaTpAccountLinkerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ goa_utils_initialize_client_factory ();
+
g_type_class_add_private (gobject_class,
sizeof (GoaTpAccountLinkerPrivate));
diff --git a/src/goabackend/goatelepathyprovider.c b/src/goabackend/goatelepathyprovider.c
index 434c4ff..7c800bd 100644
--- a/src/goabackend/goatelepathyprovider.c
+++ b/src/goabackend/goatelepathyprovider.c
@@ -30,6 +30,7 @@
#include "goaprovider.h"
#include "goaprovider-priv.h"
#include "goatelepathyprovider.h"
+#include "goautils.h"
typedef struct _GoaTelepathyProviderPrivate GoaTelepathyProviderPrivate;
@@ -1028,39 +1029,12 @@ goa_telepathy_provider_finalize (GObject *object)
}
static void
-initialize_client_factory (void)
-{
- TpSimpleClientFactory *factory;
- TpAccountManager *account_manager;
- GQuark account_features[] = {
- TP_ACCOUNT_FEATURE_STORAGE,
- TP_ACCOUNT_FEATURE_CONNECTION,
- 0};
- GQuark connection_features[] = {
- TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS,
- TP_CONNECTION_FEATURE_CONTACT_INFO,
- 0};
-
- /* We make sure that new instances of Telepathy objects will have all
- * the features we need. */
- factory = tp_simple_client_factory_new (NULL);
- tp_simple_client_factory_add_account_features (factory, account_features);
- tp_simple_client_factory_add_connection_features (factory, connection_features);
-
- account_manager = tp_account_manager_new_with_factory (factory);
- tp_account_manager_set_default (account_manager);
-
- g_object_unref (account_manager);
- g_object_unref (factory);
-}
-
-static void
goa_telepathy_provider_class_init (GoaTelepathyProviderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GoaProviderClass *provider_class = GOA_PROVIDER_CLASS (klass);
- initialize_client_factory ();
+ goa_utils_initialize_client_factory ();
object_class->constructed = goa_telepathy_provider_constructed;
object_class->finalize = goa_telepathy_provider_finalize;
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 375df14..ff49cf7 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -25,6 +25,7 @@
#include <glib/gi18n-lib.h>
#include <libsecret/secret.h>
+#include <telepathy-glib/telepathy-glib.h>
#include "goaprovider.h"
#include "goalogging.h"
@@ -39,6 +40,39 @@ static const SecretSchema secret_password_schema =
}
};
+void
+goa_utils_initialize_client_factory (void)
+{
+ static gsize once_init_value = 0;
+
+ if (g_once_init_enter (&once_init_value))
+ {
+ TpSimpleClientFactory *factory;
+ TpAccountManager *account_manager;
+ GQuark account_features[] = {TP_ACCOUNT_FEATURE_STORAGE,
+ TP_ACCOUNT_FEATURE_CONNECTION,
+ 0};
+ GQuark connection_features[] = {TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS,
+ TP_CONNECTION_FEATURE_CONTACT_INFO,
+ 0};
+
+ /* We make sure that new instances of Telepathy objects will have all
+ * the features we need.
+ */
+ factory = tp_simple_client_factory_new (NULL);
+ tp_simple_client_factory_add_account_features (factory, account_features);
+ tp_simple_client_factory_add_connection_features (factory, connection_features);
+
+ account_manager = tp_account_manager_new_with_factory (factory);
+ tp_account_manager_set_default (account_manager);
+
+ g_object_unref (account_manager);
+ g_object_unref (factory);
+
+ g_once_init_leave (&once_init_value, 1);
+ }
+}
+
gboolean
goa_utils_check_duplicate (GoaClient *client,
const gchar *identity,
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 454e702..eb9af3b 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -36,6 +36,8 @@ G_BEGIN_DECLS
typedef gpointer (*GoaPeekInterfaceFunc) (GoaObject *);
+void goa_utils_initialize_client_factory (void);
+
gboolean goa_utils_check_duplicate (GoaClient *client,
const gchar *identity,
const gchar *presentation_identity,
--
1.8.3.1