[empathy] Rely on the empathy factory rather than 're-preparing' the AM
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Rely on the empathy factory rather than 're-preparing' the AM
- Date: Fri, 3 Aug 2012 14:13:56 +0000 (UTC)
commit 119351a936be47a235b9fd0d7cce1b73fb8e289e
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Aug 2 15:48:38 2012 +0200
Rely on the empathy factory rather than 're-preparing' the AM
tp_account_manager_prepare_all_async() seems to be a bad idea so, instead,
let's just rely the empathy factory and set it as default.
This makes the code much more symetric with empathy-accounts and shouldn't
prepare that much useless features as we are not going to prepare the contact
list anyway.
.../app-plugin/empathy-app-plugin-widget.c | 20 ++------------------
.../cc-plugins/app-plugin/empathy-app-plugin.c | 15 +++++++++++++++
.../cc-plugins/empathy-accounts-plugin-widget.c | 10 +++-------
.../cc-plugins/empathy-accounts-plugin.c | 16 ++++++++++++++++
4 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin-widget.c b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin-widget.c
index 04cbd7f..d52b3a3 100644
--- a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin-widget.c
+++ b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin-widget.c
@@ -181,7 +181,7 @@ manager_prepared_cb (GObject *source,
GList *accounts;
GError *error = NULL;
- if (!tp_account_manager_prepare_all_finish (manager, result, &error))
+ if (!tp_proxy_prepare_finish (manager, result, &error))
{
g_debug ("Error preparing Account Manager: %s", error->message);
g_clear_error (&error);
@@ -226,7 +226,6 @@ empathy_app_plugin_widget_constructed (GObject *object)
((GObjectClass *) empathy_app_plugin_widget_parent_class)->constructed;
GtkWidget *top;
TpAccountManager *manager;
- TpSimpleClientFactory *factory;
if (chain_up != NULL)
chain_up (object);
@@ -241,22 +240,7 @@ empathy_app_plugin_widget_constructed (GObject *object)
/* Prepare tp's account manager to find the TpAccount corresponding to our
* AgAccount */
manager = tp_account_manager_dup ();
- factory = tp_proxy_get_factory (manager);
- tp_simple_client_factory_add_account_features_varargs (factory,
- TP_ACCOUNT_FEATURE_STORAGE,
- TP_ACCOUNT_FEATURE_CONNECTION,
- 0);
- tp_simple_client_factory_add_connection_features_varargs (factory,
- TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS,
- TP_CONNECTION_FEATURE_CONTACT_INFO,
- 0);
- tp_simple_client_factory_add_contact_features_varargs (factory,
- TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_DATA,
- TP_CONTACT_FEATURE_CONTACT_INFO,
- TP_CONTACT_FEATURE_INVALID,
- 0);
- tp_account_manager_prepare_all_async (manager,
+ tp_proxy_prepare_async (manager, NULL,
manager_prepared_cb, g_object_ref (self));
g_object_unref (manager);
}
diff --git a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c
index 43b86ad..c15a13a 100644
--- a/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c
+++ b/ubuntu-online-accounts/cc-plugins/app-plugin/empathy-app-plugin.c
@@ -22,6 +22,8 @@
#include "empathy-app-plugin.h"
+#include <libempathy/empathy-client-factory.h>
+
#include "empathy-app-plugin-widget.h"
G_DEFINE_TYPE (EmpathyAppPlugin, empathy_app_plugin, AP_TYPE_APPLICATION_PLUGIN)
@@ -60,6 +62,19 @@ empathy_app_plugin_class_init (EmpathyAppPluginClass *klass)
static void
empathy_app_plugin_init (EmpathyAppPlugin *self)
{
+ if (tp_account_manager_can_set_default ())
+ {
+ EmpathyClientFactory *factory;
+ TpAccountManager *am;
+
+ factory = empathy_client_factory_dup ();
+ am = tp_account_manager_new_with_factory (
+ TP_SIMPLE_CLIENT_FACTORY (factory));
+ tp_account_manager_set_default (am);
+
+ g_object_unref (factory);
+ g_object_unref (am);
+ }
}
GType
diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c
index a17c138..8a16904 100644
--- a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c
+++ b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c
@@ -289,7 +289,7 @@ manager_prepared_cb (GObject *source,
GList *accounts;
GError *error = NULL;
- if (!tp_account_manager_prepare_all_finish (manager, result, &error))
+ if (!tp_proxy_prepare_finish (manager, result, &error))
{
g_debug ("Error preparing Account Manager: %s", error->message);
g_clear_error (&error);
@@ -341,16 +341,12 @@ empathy_accounts_plugin_widget_constructed (GObject *object)
if (self->priv->account->id != 0)
{
TpAccountManager *manager;
- TpSimpleClientFactory *factory;
/* Prepare tp's account manager to find the TpAccount corresponding to our
* AgAccount */
manager = tp_account_manager_dup ();
- factory = tp_proxy_get_factory (manager);
- tp_simple_client_factory_add_account_features_varargs (factory,
- TP_ACCOUNT_FEATURE_STORAGE,
- 0);
- tp_account_manager_prepare_all_async (manager,
+
+ tp_proxy_prepare_async (manager, NULL,
manager_prepared_cb, g_object_ref (self));
g_object_unref (manager);
return;
diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
index 858ef65..7431abc 100644
--- a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
+++ b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin.c
@@ -22,6 +22,8 @@
#include "empathy-accounts-plugin.h"
+#include <libempathy/empathy-client-factory.h>
+
#include "empathy-accounts-plugin-widget.h"
G_DEFINE_TYPE (EmpathyAccountsPlugin, empathy_accounts_plugin, AP_TYPE_PLUGIN)
@@ -101,6 +103,20 @@ empathy_accounts_plugin_class_init (
static void
empathy_accounts_plugin_init (EmpathyAccountsPlugin *self)
{
+ if (tp_account_manager_can_set_default ())
+ {
+ EmpathyClientFactory *factory;
+ TpAccountManager *am;
+
+ factory = empathy_client_factory_dup ();
+ am = tp_account_manager_new_with_factory (
+ TP_SIMPLE_CLIENT_FACTORY (factory));
+ tp_account_manager_set_default (am);
+
+ g_object_unref (factory);
+ g_object_unref (am);
+ }
+
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]