[empathy] UOA: Use an AgManager singleton
- From: Xavier Claessens <xclaesse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] UOA: Use an AgManager singleton
- Date: Mon, 27 Aug 2012 13:47:46 +0000 (UTC)
commit c3933b7972672e533c33cf9f401a1dea83ba1368
Author: Xavier Claessens <xavier claessens collabora co uk>
Date: Fri Aug 24 13:13:07 2012 +0200
UOA: Use an AgManager singleton
This is especially useful in empathy-keyring where it would reload
all accounts each time we set a password.
https://bugzilla.gnome.org/show_bug.cgi?id=680776
libempathy/Makefile.am | 2 +
libempathy/empathy-uoa-auth-handler.c | 7 +--
libempathy/empathy-uoa-utils.c | 49 ++++++++++++++++++++
libempathy/empathy-uoa-utils.h | 35 ++++++++++++++
.../cc-plugins/empathy-accounts-plugin.c | 7 ++-
5 files changed, 95 insertions(+), 5 deletions(-)
---
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 2274b99..36de4d6 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -104,6 +104,8 @@ goa_sources = \
uoa_sources = \
empathy-uoa-auth-handler.c \
empathy-uoa-auth-handler.h \
+ empathy-uoa-utils.c \
+ empathy-uoa-utils.h \
$(NULL)
pkglib_LTLIBRARIES = libempathy.la
diff --git a/libempathy/empathy-uoa-auth-handler.c b/libempathy/empathy-uoa-auth-handler.c
index d1b0465..9b1eade 100644
--- a/libempathy/empathy-uoa-auth-handler.c
+++ b/libempathy/empathy-uoa-auth-handler.c
@@ -33,10 +33,9 @@
#include "empathy-debug.h"
#include "empathy-utils.h"
#include "empathy-uoa-auth-handler.h"
+#include "empathy-uoa-utils.h"
#include "empathy-sasl-mechanisms.h"
-#define SERVICE_TYPE "IM"
-
struct _EmpathyUoaAuthHandlerPriv
{
AgManager *manager;
@@ -50,7 +49,7 @@ empathy_uoa_auth_handler_init (EmpathyUoaAuthHandler *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_UOA_AUTH_HANDLER, EmpathyUoaAuthHandlerPriv);
- self->priv->manager = ag_manager_new_for_service_type (SERVICE_TYPE);
+ self->priv->manager = empathy_uoa_manager_dup ();
}
static void
@@ -259,7 +258,7 @@ empathy_uoa_auth_handler_start (EmpathyUoaAuthHandler *self,
account = ag_manager_get_account (self->priv->manager, id);
if (account != NULL)
- l = ag_account_list_services_by_type (account, SERVICE_TYPE);
+ l = ag_account_list_services_by_type (account, EMPATHY_UOA_SERVICE_TYPE);
if (l == NULL)
{
DEBUG ("Couldn't find IM service for AgAccountId %u", id);
diff --git a/libempathy/empathy-uoa-utils.c b/libempathy/empathy-uoa-utils.c
new file mode 100644
index 0000000..f63a151
--- /dev/null
+++ b/libempathy/empathy-uoa-utils.c
@@ -0,0 +1,49 @@
+/*
+ * empathy-uoa-utils.c - Source for UOA utilities
+ * Copyright (C) 2012 Collabora Ltd.
+ * @author Xavier Claessens <xavier claessens collabora co uk>
+ *
+ * This library 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.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include "empathy-debug.h"
+#include "empathy-uoa-utils.h"
+
+static AgManager *singleton = NULL;
+
+void
+empathy_uoa_manager_set_default (AgManager *manager)
+{
+ if (singleton != NULL)
+ return;
+
+ singleton = manager;
+ g_object_add_weak_pointer ((GObject *) singleton, (gpointer) &singleton);
+}
+
+AgManager *
+empathy_uoa_manager_dup (void)
+{
+ if (singleton != NULL)
+ return g_object_ref (singleton);
+
+ singleton = ag_manager_new_for_service_type (EMPATHY_UOA_SERVICE_TYPE);
+ g_object_add_weak_pointer ((GObject *) singleton, (gpointer) &singleton);
+
+ return singleton;
+}
diff --git a/libempathy/empathy-uoa-utils.h b/libempathy/empathy-uoa-utils.h
new file mode 100644
index 0000000..2cd7a41
--- /dev/null
+++ b/libempathy/empathy-uoa-utils.h
@@ -0,0 +1,35 @@
+/*
+ * empathy-utils.h - Header for UOA utilities
+ * Copyright (C) 2012 Collabora Ltd.
+ * @author Xavier Claessens <xavier claessens collabora co uk>
+ *
+ * This library 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.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __EMPATHY_UOA_UTILS_H__
+#define __EMPATHY_UOA_UTILS_H__
+
+#include <libaccounts-glib/ag-manager.h>
+
+#define EMPATHY_UOA_SERVICE_TYPE "IM"
+
+G_BEGIN_DECLS
+
+void empathy_uoa_manager_set_default (AgManager *manager);
+AgManager *empathy_uoa_manager_dup (void);
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_UOA_UTILS_H__*/
diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
index 7431abc..939912a 100644
--- a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
+++ b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
@@ -23,6 +23,7 @@
#include "empathy-accounts-plugin.h"
#include <libempathy/empathy-client-factory.h>
+#include <libempathy/empathy-uoa-utils.h>
#include "empathy-accounts-plugin-widget.h"
@@ -38,9 +39,13 @@ widget_done_cb (EmpathyAccountsPluginWidget *widget,
static GtkWidget *
empathy_accounts_plugin_build_widget (ApPlugin *plugin)
{
+ AgAccount *account;
GtkWidget *widget;
- widget = empathy_accounts_plugin_widget_new (ap_plugin_get_account (plugin));
+ account = ap_plugin_get_account (plugin);
+ empathy_uoa_manager_set_default (ag_account_get_manager (account));
+
+ widget = empathy_accounts_plugin_widget_new (account);
g_signal_connect (widget, "done",
G_CALLBACK (widget_done_cb), plugin);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]