aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-08-18 17:31:10 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-08-18 18:15:06 +0800
commit9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416 (patch)
tree4e4cfd5b8f801acff74edfdd5072f45d7038e00b
parent7fbf3e0c200b0a3c5086fdce0cc19afe48c429bb (diff)
downloadgsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar.gz
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar.bz2
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar.lz
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar.xz
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.tar.zst
gsoc2013-empathy-9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416.zip
Port to new tp-glib client factory
- EmpathyChannelFactory has been changed to EmpathyClientFactory and inherit from TpAutomaticClientFactory. - We now always use the _with_am variant of TpSimple* constructors - We define our own factory as default. - Replace empathy_get_account_for_connection() by tp_connection_get_account() - The factory is passed to EmpathyTpChat and TpyCallChannel - Use tp_simple_client_factory_ensure_account() instead of tp_account_manager_ensure_account(). - Rely on the factory to prepare connection features. This should ensure that all the TpProxy and TpContact objects created in Empathy are shared and use EmpathyClientFactory. https://bugzilla.gnome.org/show_bug.cgi?id=655799
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c13
-rw-r--r--libempathy-gtk/empathy-log-window.c17
-rw-r--r--libempathy/Makefile.am4
-rw-r--r--libempathy/empathy-channel-factory.c163
-rw-r--r--libempathy/empathy-channel-factory.h58
-rw-r--r--libempathy/empathy-chatroom-manager.c39
-rw-r--r--libempathy/empathy-client-factory.c181
-rw-r--r--libempathy/empathy-client-factory.h56
-rw-r--r--libempathy/empathy-contact.c2
-rw-r--r--libempathy/empathy-ft-factory.c15
-rw-r--r--libempathy/empathy-message.c12
-rw-r--r--libempathy/empathy-tp-chat.c5
-rw-r--r--libempathy/empathy-tp-chat.h4
-rw-r--r--libempathy/empathy-utils.c40
-rw-r--r--libempathy/empathy-utils.h2
-rw-r--r--src/empathy-call-factory.c22
-rw-r--r--src/empathy-call-handler.c7
-rw-r--r--src/empathy-call-observer.c21
-rw-r--r--src/empathy-chat-manager.c29
-rw-r--r--src/empathy-chat-window.c14
-rw-r--r--src/empathy-event-manager.c30
-rw-r--r--src/empathy-streamed-media-factory.c15
-rw-r--r--tests/empathy-chatroom-manager-test.c10
23 files changed, 329 insertions, 430 deletions
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 4b2febd30..277842ff5 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -34,6 +34,7 @@
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
+#include <libempathy/empathy-client-factory.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-groups.h>
@@ -382,7 +383,7 @@ contact_list_view_contact_drag_received (GtkWidget *view,
GtkSelectionData *selection)
{
EmpathyContactListViewPriv *priv;
- TpAccountManager *account_manager;
+ EmpathyClientFactory *factory;
TpConnection *connection = NULL;
TpAccount *account = NULL;
DndGetContactData *data;
@@ -423,12 +424,14 @@ contact_list_view_contact_drag_received (GtkWidget *view,
return FALSE;
}
- account_manager = tp_account_manager_dup ();
+ factory = empathy_client_factory_dup ();
strv = g_strsplit (sel_data, ":", 2);
if (g_strv_length (strv) == 2) {
account_id = strv[0];
contact_id = strv[1];
- account = tp_account_manager_ensure_account (account_manager, account_id);
+ account = tp_simple_client_factory_ensure_account (
+ TP_SIMPLE_CLIENT_FACTORY (factory),
+ account_id, NULL, NULL);
}
if (account) {
connection = tp_account_get_connection (account);
@@ -438,7 +441,7 @@ contact_list_view_contact_drag_received (GtkWidget *view,
DEBUG ("Failed to get connection for account '%s'", account_id);
g_free (new_group);
g_free (old_group);
- g_object_unref (account_manager);
+ g_object_unref (factory);
return FALSE;
}
@@ -454,7 +457,7 @@ contact_list_view_contact_drag_received (GtkWidget *view,
data, (GDestroyNotify) contact_list_view_dnd_get_contact_free,
G_OBJECT (view));
g_strfreev (strv);
- g_object_unref (account_manager);
+ g_object_unref (factory);
return TRUE;
}
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 5620f4b7c..d0f57a6de 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -1041,21 +1041,14 @@ observe_channels (TpSimpleObserver *observer,
static void
log_window_create_observer (EmpathyLogWindow *self)
{
- TpDBusDaemon *dbus;
- GError *error = NULL;
+ TpAccountManager *am;
- dbus = tp_dbus_daemon_dup (&error);
+ am = tp_account_manager_dup ();
- if (dbus == NULL)
- {
- DEBUG ("Could not connect to the bus: %s", error->message);
- g_error_free (error);
- return;
- }
-
- self->priv->observer = tp_simple_observer_new (dbus, TRUE, "LogWindow",
+ self->priv->observer = tp_simple_observer_new_with_am (am, TRUE, "LogWindow",
TRUE, observe_channels,
g_object_ref (self), g_object_unref);
+
self->priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_object_unref, g_object_unref);
@@ -1077,7 +1070,7 @@ log_window_create_observer (EmpathyLogWindow *self)
tp_base_client_register (self->priv->observer, NULL);
- g_object_unref (dbus);
+ g_object_unref (am);
}
static TplEntity *
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index f701f7480..34a706113 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -33,9 +33,9 @@ libempathy_headers = \
empathy-account-settings.h \
empathy-auth-factory.h \
empathy-camera-monitor.h \
- empathy-channel-factory.h \
empathy-chatroom-manager.h \
empathy-chatroom.h \
+ empathy-client-factory.h \
empathy-connection-managers.h \
empathy-connectivity.h \
empathy-contact-groups.h \
@@ -76,9 +76,9 @@ libempathy_handwritten_source = \
empathy-account-settings.c \
empathy-auth-factory.c \
empathy-camera-monitor.c \
- empathy-channel-factory.c \
empathy-chatroom-manager.c \
empathy-chatroom.c \
+ empathy-client-factory.c \
empathy-connection-managers.c \
empathy-connectivity.c \
empathy-contact-groups.c \
diff --git a/libempathy/empathy-channel-factory.c b/libempathy/empathy-channel-factory.c
deleted file mode 100644
index d8b1cd941..000000000
--- a/libempathy/empathy-channel-factory.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2010 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include "empathy-channel-factory.h"
-
-#include "empathy-tp-chat.h"
-#include "empathy-utils.h"
-
-#include <telepathy-glib/telepathy-glib.h>
-
-#include <telepathy-yell/telepathy-yell.h>
-
-static void factory_iface_init (gpointer, gpointer);
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyChannelFactory, empathy_channel_factory,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (TP_TYPE_CLIENT_CHANNEL_FACTORY, factory_iface_init))
-
-struct _EmpathyChannelFactoryPrivate
-{
- TpClientChannelFactory *automatic_factory;
-};
-
-static void
-empathy_channel_factory_dispose (GObject *object)
-{
- EmpathyChannelFactory *self = EMPATHY_CHANNEL_FACTORY (object);
- void (*dispose) (GObject *) =
- G_OBJECT_CLASS (empathy_channel_factory_parent_class)->dispose;
-
- tp_clear_object (&self->priv->automatic_factory);
-
- if (dispose != NULL)
- dispose (object);
-}
-
-static void
-empathy_channel_factory_class_init (EmpathyChannelFactoryClass *cls)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (cls);
-
- g_type_class_add_private (cls, sizeof (EmpathyChannelFactoryPrivate));
-
- object_class->dispose = empathy_channel_factory_dispose;
-}
-
-static void
-empathy_channel_factory_init (EmpathyChannelFactory *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- EMPATHY_TYPE_CHANNEL_FACTORY, EmpathyChannelFactoryPrivate);
-
- self->priv->automatic_factory = TP_CLIENT_CHANNEL_FACTORY (
- tp_automatic_proxy_factory_dup ());
-}
-
-EmpathyChannelFactory *
-empathy_channel_factory_new (void)
-{
- return g_object_new (EMPATHY_TYPE_CHANNEL_FACTORY,
- NULL);
-}
-
-EmpathyChannelFactory *
-empathy_channel_factory_dup (void)
-{
- static EmpathyChannelFactory *singleton = NULL;
-
- if (singleton != NULL)
- return g_object_ref (singleton);
-
- singleton = empathy_channel_factory_new ();
-
- g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer) &singleton);
-
- return singleton;
-}
-
-static TpChannel *
-empathy_channel_factory_create_channel (
- TpClientChannelFactory *factory,
- TpConnection *conn,
- const gchar *path,
- GHashTable *properties,
- GError **error)
-{
- EmpathyChannelFactory *self = (EmpathyChannelFactory *) factory;
- const gchar *chan_type;
-
- chan_type = tp_asv_get_string (properties, TP_PROP_CHANNEL_CHANNEL_TYPE);
-
- if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
- {
- TpAccount *account;
-
- account = empathy_get_account_for_connection (conn);
-
- return TP_CHANNEL (empathy_tp_chat_new (account, conn, path, properties));
- }
- else if (!tp_strdiff (chan_type, TPY_IFACE_CHANNEL_TYPE_CALL))
- {
- return TP_CHANNEL (tpy_call_channel_new (conn, path, properties,
- error));
- }
-
- return tp_client_channel_factory_create_channel (
- self->priv->automatic_factory, conn, path, properties, error);
-}
-
-static GArray *
-empathy_channel_factory_dup_channel_features (
- TpClientChannelFactory *factory,
- TpChannel *channel)
-{
- EmpathyChannelFactory *self = (EmpathyChannelFactory *) factory;
- GArray *features;
- GQuark feature;
-
- features = tp_client_channel_factory_dup_channel_features (
- self->priv->automatic_factory, channel);
-
- if (EMPATHY_IS_TP_CHAT (channel))
- {
- feature = TP_CHANNEL_FEATURE_CHAT_STATES;
- g_array_append_val (features, feature);
-
- feature = EMPATHY_TP_CHAT_FEATURE_READY;
- g_array_append_val (features, feature);
- }
-
- return features;
-}
-
-static void
-factory_iface_init (gpointer g_iface,
- gpointer unused G_GNUC_UNUSED)
-{
- TpClientChannelFactoryInterface *iface = g_iface;
-
- iface->obj_create_channel = empathy_channel_factory_create_channel;
- iface->obj_dup_channel_features =
- empathy_channel_factory_dup_channel_features;
-}
diff --git a/libempathy/empathy-channel-factory.h b/libempathy/empathy-channel-factory.h
deleted file mode 100644
index 7cfcf31f8..000000000
--- a/libempathy/empathy-channel-factory.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 Collabora Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_CHANNEL_FACTORY_H__
-#define __EMPATHY_CHANNEL_FACTORY_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CHANNEL_FACTORY (empathy_channel_factory_get_type ())
-#define EMPATHY_CHANNEL_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHANNEL_FACTORY, EmpathyChannelFactory))
-#define EMPATHY_CHANNEL_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CHANNEL_FACTORY, EmpathyChannelFactoryClass))
-#define EMPATHY_IS_CHANNEL_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHANNEL_FACTORY))
-#define EMPATHY_IS_CHANNEL_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHANNEL_FACTORY))
-#define EMPATHY_CHANNEL_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHANNEL_FACTORY, EmpathyChannelFactoryClass))
-
-typedef struct _EmpathyChannelFactory EmpathyChannelFactory;
-typedef struct _EmpathyChannelFactoryClass EmpathyChannelFactoryClass;
-typedef struct _EmpathyChannelFactoryPrivate EmpathyChannelFactoryPrivate;
-
-struct _EmpathyChannelFactory
-{
- GObject parent;
- EmpathyChannelFactoryPrivate *priv;
-};
-
-struct _EmpathyChannelFactoryClass
-{
- GObjectClass parent_class;
-};
-
-GType empathy_channel_factory_get_type (void) G_GNUC_CONST;
-
-EmpathyChannelFactory * empathy_channel_factory_new (void);
-
-EmpathyChannelFactory * empathy_channel_factory_dup (void);
-
-G_END_DECLS
-#endif /* __EMPATHY_CHANNEL_FACTORY_H__ */
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index 2be475b3a..5e1c0bb45 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -35,9 +35,9 @@
#include <telepathy-glib/simple-observer.h>
#include <telepathy-glib/util.h>
+#include "empathy-client-factory.h"
#include "empathy-tp-chat.h"
#include "empathy-chatroom-manager.h"
-#include "empathy-channel-factory.h"
#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -220,6 +220,8 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
gchar *account_id;
gboolean auto_connect;
gboolean always_urgent;
+ EmpathyClientFactory *factory;
+ GError *error = NULL;
priv = GET_PRIV (manager);
@@ -270,10 +272,17 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
xmlFree (str);
}
- account = tp_account_manager_ensure_account (priv->account_manager,
- account_id);
+ factory = empathy_client_factory_dup ();
+
+ account = tp_simple_client_factory_ensure_account (
+ TP_SIMPLE_CLIENT_FACTORY (factory), account_id, NULL, &error);
+ g_object_unref (factory);
+
if (account == NULL)
{
+ DEBUG ("Failed to create account: %s", error->message);
+ g_error_free (error);
+
g_free (name);
g_free (room);
g_free (account_id);
@@ -545,8 +554,6 @@ empathy_chatroom_manager_constructor (GType type,
EmpathyChatroomManager *self;
EmpathyChatroomManagerPriv *priv;
GError *error = NULL;
- TpDBusDaemon *dbus;
- EmpathyChannelFactory *factory;
if (chatroom_manager_singleton != NULL)
return g_object_ref (chatroom_manager_singleton);
@@ -581,21 +588,10 @@ empathy_chatroom_manager_constructor (GType type,
g_free (dir);
}
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- g_warning ("Failed to get TpDBusDaemon: %s", error->message);
-
- g_error_free (error);
- return obj;
- }
-
/* Setup a room observer */
- priv->observer = tp_simple_observer_new (dbus, TRUE,
+ priv->observer = tp_simple_observer_new_with_am (priv->account_manager, TRUE,
"Empathy.ChatroomManager", TRUE, observe_channels_cb, self, NULL);
- g_object_unref (dbus);
-
tp_base_client_take_observer_filter (priv->observer, tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
TP_IFACE_CHANNEL_TYPE_TEXT,
@@ -603,14 +599,6 @@ empathy_chatroom_manager_constructor (GType type,
TP_HANDLE_TYPE_ROOM,
NULL));
- tp_base_client_add_connection_features_varargs (priv->observer,
- TP_CONNECTION_FEATURE_CAPABILITIES, NULL);
-
- factory = empathy_channel_factory_dup ();
-
- tp_base_client_set_channel_factory (priv->observer,
- TP_CLIENT_CHANNEL_FACTORY (factory));
-
if (!tp_base_client_register (priv->observer, &error))
{
g_critical ("Failed to register Observer: %s", error->message);
@@ -618,7 +606,6 @@ empathy_chatroom_manager_constructor (GType type,
g_error_free (error);
}
- g_object_unref (factory);
return obj;
}
diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c
new file mode 100644
index 000000000..5055a2628
--- /dev/null
+++ b/libempathy/empathy-client-factory.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
+ */
+
+#include <config.h>
+
+#include "empathy-client-factory.h"
+
+#include "empathy-tp-chat.h"
+#include "empathy-utils.h"
+
+#include <telepathy-yell/telepathy-yell.h>
+
+G_DEFINE_TYPE (EmpathyClientFactory, empathy_client_factory,
+ TP_TYPE_AUTOMATIC_CLIENT_FACTORY)
+
+#define chainup ((TpSimpleClientFactoryClass *) \
+ empathy_client_factory_parent_class)
+
+/* FIXME: move to yell */
+static TpyCallChannel *
+call_channel_new_with_factory (TpSimpleClientFactory *factory,
+ TpConnection *conn,
+ const gchar *object_path,
+ const GHashTable *immutable_properties,
+ GError **error)
+{
+ TpProxy *conn_proxy = (TpProxy *) conn;
+
+ g_return_val_if_fail (TP_IS_CONNECTION (conn), NULL);
+ g_return_val_if_fail (object_path != NULL, NULL);
+ g_return_val_if_fail (immutable_properties != NULL, NULL);
+
+ if (!tp_dbus_check_valid_object_path (object_path, error))
+ return NULL;
+
+ return g_object_new (TPY_TYPE_CALL_CHANNEL,
+ "factory", factory,
+ "connection", conn,
+ "dbus-daemon", conn_proxy->dbus_daemon,
+ "bus-name", conn_proxy->bus_name,
+ "object-path", object_path,
+ "handle-type", (guint) TP_UNKNOWN_HANDLE_TYPE,
+ "channel-properties", immutable_properties,
+ NULL);
+}
+
+static TpChannel *
+empathy_client_factory_create_channel (TpSimpleClientFactory *factory,
+ TpConnection *conn,
+ const gchar *path,
+ const GHashTable *properties,
+ GError **error)
+{
+ const gchar *chan_type;
+
+ chan_type = tp_asv_get_string (properties, TP_PROP_CHANNEL_CHANNEL_TYPE);
+
+ if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
+ {
+ TpAccount *account;
+
+ account = tp_connection_get_account (conn);
+
+ return TP_CHANNEL (empathy_tp_chat_new (
+ TP_SIMPLE_CLIENT_FACTORY (factory), account, conn, path,
+ properties));
+ }
+ else if (!tp_strdiff (chan_type, TPY_IFACE_CHANNEL_TYPE_CALL))
+ {
+ return TP_CHANNEL (call_channel_new_with_factory (
+ TP_SIMPLE_CLIENT_FACTORY (factory), conn, path, properties, error));
+ }
+
+ return chainup->create_channel (factory, conn, path, properties, error);
+}
+
+static GArray *
+empathy_client_factory_dup_channel_features (TpSimpleClientFactory *factory,
+ TpChannel *channel)
+{
+ GArray *features;
+ GQuark feature;
+
+ features = chainup->dup_channel_features (factory, channel);
+
+ if (EMPATHY_IS_TP_CHAT (channel))
+ {
+ feature = TP_CHANNEL_FEATURE_CHAT_STATES;
+ g_array_append_val (features, feature);
+
+ feature = EMPATHY_TP_CHAT_FEATURE_READY;
+ g_array_append_val (features, feature);
+ }
+
+ return features;
+}
+
+static GArray *
+empathy_client_factory_dup_connection_features (TpSimpleClientFactory *factory,
+ TpConnection *connection)
+{
+ GArray *features;
+ GQuark feature;
+
+ features = chainup->dup_connection_features (factory, connection);
+
+ feature = TP_CONNECTION_FEATURE_CAPABILITIES;
+ g_array_append_val (features, feature);
+
+ return features;
+}
+
+static void
+empathy_client_factory_class_init (EmpathyClientFactoryClass *cls)
+{
+ TpSimpleClientFactoryClass *simple_class = (TpSimpleClientFactoryClass *) cls;
+
+ simple_class->create_channel = empathy_client_factory_create_channel;
+ simple_class->dup_channel_features =
+ empathy_client_factory_dup_channel_features;
+
+ simple_class->dup_connection_features =
+ empathy_client_factory_dup_connection_features;
+}
+
+static void
+empathy_client_factory_init (EmpathyClientFactory *self)
+{
+}
+
+static EmpathyClientFactory *
+empathy_client_factory_new (TpDBusDaemon *dbus)
+{
+ return g_object_new (EMPATHY_TYPE_CLIENT_FACTORY,
+ "dbus-daemon", dbus,
+ NULL);
+}
+
+EmpathyClientFactory *
+empathy_client_factory_dup (void)
+{
+ static EmpathyClientFactory *singleton = NULL;
+ TpDBusDaemon *dbus;
+ GError *error = NULL;
+
+ if (singleton != NULL)
+ return g_object_ref (singleton);
+
+ dbus = tp_dbus_daemon_dup (&error);
+ if (dbus == NULL)
+ {
+ g_warning ("Failed to get TpDBusDaemon: %s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ singleton = empathy_client_factory_new (dbus);
+ g_object_unref (dbus);
+
+ g_object_add_weak_pointer (G_OBJECT (singleton), (gpointer) &singleton);
+
+ return singleton;
+}
diff --git a/libempathy/empathy-client-factory.h b/libempathy/empathy-client-factory.h
new file mode 100644
index 000000000..c4d88e286
--- /dev/null
+++ b/libempathy/empathy-client-factory.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_CLIENT_FACTORY_H__
+#define __EMPATHY_CLIENT_FACTORY_H__
+
+#include <telepathy-glib/telepathy-glib.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TYPE_CLIENT_FACTORY (empathy_client_factory_get_type ())
+#define EMPATHY_CLIENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CLIENT_FACTORY, EmpathyClientFactory))
+#define EMPATHY_CLIENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CLIENT_FACTORY, EmpathyClientFactoryClass))
+#define EMPATHY_IS_CLIENT_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CLIENT_FACTORY))
+#define EMPATHY_IS_CLIENT_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CLIENT_FACTORY))
+#define EMPATHY_CLIENT_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CLIENT_FACTORY, EmpathyClientFactoryClass))
+
+typedef struct _EmpathyClientFactory EmpathyClientFactory;
+typedef struct _EmpathyClientFactoryClass EmpathyClientFactoryClass;
+typedef struct _EmpathyClientFactoryPrivate EmpathyClientFactoryPrivate;
+
+struct _EmpathyClientFactory
+{
+ TpAutomaticClientFactory parent;
+ EmpathyClientFactoryPrivate *priv;
+};
+
+struct _EmpathyClientFactoryClass
+{
+ TpAutomaticClientFactoryClass parent_class;
+};
+
+GType empathy_client_factory_get_type (void) G_GNUC_CONST;
+
+EmpathyClientFactory * empathy_client_factory_dup (void);
+
+G_END_DECLS
+#endif /* __EMPATHY_CLIENT_FACTORY_H__ */
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index cdca6dc75..d5764894b 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -940,7 +940,7 @@ empathy_contact_get_account (EmpathyContact *contact)
/* FIXME: This assume the account manager already exists */
connection = tp_contact_get_connection (priv->tp_contact);
priv->account =
- g_object_ref (empathy_get_account_for_connection (connection));
+ g_object_ref (tp_connection_get_account (connection));
}
return priv->account;
diff --git a/libempathy/empathy-ft-factory.c b/libempathy/empathy-ft-factory.c
index 5fb238a2b..597bbaf51 100644
--- a/libempathy/empathy-ft-factory.c
+++ b/libempathy/empathy-ft-factory.c
@@ -206,20 +206,13 @@ empathy_ft_factory_init (EmpathyFTFactory *self)
{
EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv);
- TpDBusDaemon *dbus;
- GError *error = NULL;
+ TpAccountManager *am;
self->priv = priv;
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- g_warning ("Failed to get TpDBusDaemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
- priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
+ priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE,
EMPATHY_FT_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, self, NULL);
tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
@@ -231,7 +224,7 @@ empathy_ft_factory_init (EmpathyFTFactory *self)
TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, FALSE,
NULL));
- g_object_unref (dbus);
+ g_object_unref (am);
}
static void
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 06b3308c5..995f49ab7 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -39,6 +39,7 @@
# include <telepathy-logger/call-event.h>
#endif
+#include "empathy-client-factory.h"
#include "empathy-message.h"
#include "empathy-utils.h"
#include "empathy-enum-types.h"
@@ -352,7 +353,7 @@ EmpathyMessage *
empathy_message_from_tpl_log_event (TplEvent *logevent)
{
EmpathyMessage *retval = NULL;
- TpAccountManager *acc_man = NULL;
+ EmpathyClientFactory *factory;
TpAccount *account = NULL;
TplEntity *receiver = NULL;
TplEntity *sender = NULL;
@@ -364,7 +365,7 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
g_return_val_if_fail (TPL_IS_EVENT (logevent), NULL);
- acc_man = tp_account_manager_dup ();
+ factory = empathy_client_factory_dup ();
/* FIXME Currently Empathy shows in the log viewer only valid accounts, so it
* won't be selected any non-existing (ie removed) account.
* When #610455 will be fixed, calling tp_account_manager_ensure_account ()
@@ -376,9 +377,10 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
* If the way EmpathyContact stores the avatar is changes, it might not be
* needed anymore any TpAccount passing and the following call will be
* useless */
- account = tp_account_manager_ensure_account (acc_man,
- tpl_event_get_account_path (logevent));
- g_object_unref (acc_man);
+ account = tp_simple_client_factory_ensure_account (
+ TP_SIMPLE_CLIENT_FACTORY (factory),
+ tpl_event_get_account_path (logevent), NULL, NULL);
+ g_object_unref (factory);
if (TPL_IS_TEXT_EVENT (logevent)) {
TplTextEvent *textevent = TPL_TEXT_EVENT (logevent);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index a690f60e3..fde1e70ba 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -1399,7 +1399,9 @@ tp_chat_iface_init (EmpathyContactListIface *iface)
}
EmpathyTpChat *
-empathy_tp_chat_new (TpAccount *account,
+empathy_tp_chat_new (
+ TpSimpleClientFactory *factory,
+ TpAccount *account,
TpConnection *conn,
const gchar *object_path,
const GHashTable *immutable_properties)
@@ -1411,6 +1413,7 @@ empathy_tp_chat_new (TpAccount *account,
g_return_val_if_fail (immutable_properties != NULL, NULL);
return g_object_new (EMPATHY_TYPE_TP_CHAT,
+ "factory", factory,
"account", account,
"connection", conn,
"dbus-daemon", conn_proxy->dbus_daemon,
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index a69c4924f..810cb5184 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -71,7 +71,9 @@ GQuark empathy_tp_chat_get_feature_ready (void) G_GNUC_CONST;
GType empathy_tp_chat_get_type (void) G_GNUC_CONST;
-EmpathyTpChat *empathy_tp_chat_new (TpAccount *account,
+EmpathyTpChat *empathy_tp_chat_new (
+ TpSimpleClientFactory *factory,
+ TpAccount *account,
TpConnection *connection,
const gchar *object_path,
const GHashTable *immutable_properties);
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 5f9178a55..04a6c7836 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -46,6 +46,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
+#include "empathy-client-factory.h"
#include "empathy-utils.h"
#include "empathy-contact-manager.h"
#include "empathy-individual-manager.h"
@@ -83,6 +84,8 @@ void
empathy_init (void)
{
static gboolean initialized = FALSE;
+ TpAccountManager *am;
+ EmpathyClientFactory *factory;
if (initialized)
return;
@@ -103,6 +106,13 @@ empathy_init (void)
emp_cli_init ();
initialized = TRUE;
+
+ 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);
}
gboolean
@@ -559,36 +569,6 @@ empathy_service_name_to_display_name (const gchar *service_name)
return service_name;
}
-/* Note: this function depends on the account manager having its core feature
- * prepared. */
-TpAccount *
-empathy_get_account_for_connection (TpConnection *connection)
-{
- TpAccountManager *manager;
- TpAccount *account = NULL;
- GList *accounts, *l;
-
- manager = tp_account_manager_dup ();
-
- accounts = tp_account_manager_get_valid_accounts (manager);
-
- for (l = accounts; l != NULL; l = l->next)
- {
- TpAccount *a = l->data;
-
- if (tp_account_get_connection (a) == connection)
- {
- account = a;
- break;
- }
- }
-
- g_list_free (accounts);
- g_object_unref (manager);
-
- return account;
-}
-
gboolean
empathy_account_manager_get_accounts_connected (gboolean *connecting)
{
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 97490b939..90933eded 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -80,8 +80,6 @@ const gchar *empathy_service_name_to_display_name (const gchar *proto_name);
#define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ())
GType empathy_type_dbus_ao (void);
-TpAccount * empathy_get_account_for_connection (TpConnection *connection);
-
gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
void empathy_connect_new_account (TpAccount *account,
diff --git a/src/empathy-call-factory.c b/src/empathy-call-factory.c
index 46ef01aa5..9f3fe16ec 100644
--- a/src/empathy-call-factory.c
+++ b/src/empathy-call-factory.c
@@ -29,7 +29,6 @@
#include <telepathy-yell/telepathy-yell.h>
-#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-request-util.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-utils.h>
@@ -76,28 +75,15 @@ empathy_call_factory_init (EmpathyCallFactory *obj)
{
EmpathyCallFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
EMPATHY_TYPE_CALL_FACTORY, EmpathyCallFactoryPriv);
- TpDBusDaemon *dbus;
- EmpathyChannelFactory *factory;
- GError *error = NULL;
+ TpAccountManager *am;
obj->priv = priv;
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- g_warning ("Failed to get TpDBusDaemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
- priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
+ priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE,
EMPATHY_CALL_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, obj, NULL);
- factory = empathy_channel_factory_new ();
- tp_base_client_set_channel_factory (priv->handler,
- TP_CLIENT_CHANNEL_FACTORY (factory));
- g_object_unref (factory);
-
tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
TPY_IFACE_CHANNEL_TYPE_CALL,
@@ -127,7 +113,7 @@ empathy_call_factory_init (EmpathyCallFactory *obj)
"org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264",
NULL);
- g_object_unref (dbus);
+ g_object_unref (am);
}
static GObject *
diff --git a/src/empathy-call-handler.c b/src/empathy-call-handler.c
index c141b9ffa..cf93a1de3 100644
--- a/src/empathy-call-handler.c
+++ b/src/empathy-call-handler.c
@@ -30,7 +30,6 @@
#include <telepathy-farstream/telepathy-farstream.h>
-#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-tp-contact-factory.h>
@@ -944,7 +943,6 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler,
gint64 timestamp)
{
EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
- EmpathyChannelFactory *channel_factory;
TpAccountChannelRequest *req;
TpAccount *account;
GHashTable *request;
@@ -966,11 +964,6 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler,
req = tp_account_channel_request_new (account, request, timestamp);
- channel_factory = empathy_channel_factory_dup ();
- tp_account_channel_request_set_channel_factory (req,
- TP_CLIENT_CHANNEL_FACTORY (channel_factory));
- g_object_unref (channel_factory);
-
tp_account_channel_request_create_and_handle_channel_async (req, NULL,
empathy_call_handler_request_cb, handler);
diff --git a/src/empathy-call-observer.c b/src/empathy-call-observer.c
index 8ce57a3e1..0fecbdca6 100644
--- a/src/empathy-call-observer.c
+++ b/src/empathy-call-observer.c
@@ -28,7 +28,6 @@
#include <libnotify/notification.h>
-#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-images.h>
@@ -349,31 +348,19 @@ empathy_call_observer_init (EmpathyCallObserver *self)
{
EmpathyCallObserverPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_CALL_OBSERVER, EmpathyCallObserverPriv);
- TpDBusDaemon *dbus;
- EmpathyChannelFactory *factory;
+ TpAccountManager *am;
GError *error = NULL;
self->priv = priv;
self->priv->notify_mgr = empathy_notify_manager_dup_singleton ();
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- DEBUG ("Failed to get TpDBusDaemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
- self->priv->observer = tp_simple_observer_new (dbus, TRUE,
+ self->priv->observer = tp_simple_observer_new_with_am (am, TRUE,
"Empathy.CallObserver", FALSE,
observe_channels, self, NULL);
- factory = empathy_channel_factory_dup ();
- tp_base_client_set_channel_factory (self->priv->observer,
- TP_CLIENT_CHANNEL_FACTORY (factory));
- g_object_unref (factory);
-
/* Observe Call and StreamedMedia channels */
tp_base_client_take_observer_filter (self->priv->observer,
tp_asv_new (
@@ -398,7 +385,7 @@ empathy_call_observer_init (EmpathyCallObserver *self)
g_error_free (error);
}
- g_object_unref (dbus);
+ g_object_unref (am);
}
EmpathyCallObserver *
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index e6ffaa0e9..0e1745edb 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -20,7 +20,6 @@
#include <telepathy-glib/telepathy-glib.h>
#include <telepathy-glib/proxy-subclass.h>
-#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-request-util.h>
#include <libempathy/empathy-utils.h>
@@ -235,35 +234,22 @@ static void
empathy_chat_manager_init (EmpathyChatManager *self)
{
EmpathyChatManagerPriv *priv = GET_PRIV (self);
- TpDBusDaemon *dbus;
+ TpAccountManager *am;
GError *error = NULL;
- EmpathyChannelFactory *factory;
priv->closed_queue = g_queue_new ();
priv->messages = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_hash_table_unref);
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- g_critical ("Failed to get D-Bus daemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
priv->chatroom_mgr = empathy_chatroom_manager_dup_singleton (NULL);
/* Text channels handler */
- priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
+ priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE,
EMPATHY_CHAT_BUS_NAME_SUFFIX, FALSE, handle_channels, self, NULL);
- /* EmpathyTpChat relies on these features being prepared */
- tp_base_client_add_connection_features_varargs (priv->handler,
- TP_CONNECTION_FEATURE_CAPABILITIES, 0);
- tp_base_client_add_channel_features_varargs (priv->handler,
- TP_CHANNEL_FEATURE_CHAT_STATES, 0);
-
- g_object_unref (dbus);
+ g_object_unref (am);
tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
@@ -280,18 +266,11 @@ empathy_chat_manager_init (EmpathyChatManager *self)
TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_NONE,
NULL));
- factory = empathy_channel_factory_dup ();
-
- tp_base_client_set_channel_factory (priv->handler,
- TP_CLIENT_CHANNEL_FACTORY (factory));
-
if (!tp_base_client_register (priv->handler, &error))
{
g_critical ("Failed to register text handler: %s", error->message);
g_error_free (error);
}
-
- g_object_unref (factory);
}
static void
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index c0a08d4dd..171b6358d 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -38,6 +38,7 @@
#include <telepathy-glib/telepathy-glib.h>
+#include <libempathy/empathy-client-factory.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
#include <libempathy/empathy-chatroom-manager.h>
@@ -1827,7 +1828,7 @@ chat_window_drag_data_received (GtkWidget *widget,
EmpathyChat *chat = NULL;
EmpathyChatWindow *old_window;
TpAccount *account = NULL;
- TpAccountManager *account_manager;
+ EmpathyClientFactory *factory;
const gchar *id;
gchar **strv;
const gchar *account_id;
@@ -1835,9 +1836,7 @@ chat_window_drag_data_received (GtkWidget *widget,
id = (const gchar*) gtk_selection_data_get_data (selection);
- /* FIXME: Perhaps should be sure that the account manager is
- * prepared before calling _ensure_account on it. */
- account_manager = tp_account_manager_dup ();
+ factory = empathy_client_factory_dup ();
DEBUG ("DND contact from roster with id:'%s'", id);
@@ -1846,7 +1845,11 @@ chat_window_drag_data_received (GtkWidget *widget,
account_id = strv[0];
contact_id = strv[1];
account =
- tp_account_manager_ensure_account (account_manager, account_id);
+ tp_simple_client_factory_ensure_account (
+ TP_SIMPLE_CLIENT_FACTORY (factory), account_id,
+ NULL, NULL);
+
+ g_object_unref (factory);
if (account != NULL)
chat = empathy_chat_window_find_chat (account, contact_id, FALSE);
}
@@ -1864,7 +1867,6 @@ chat_window_drag_data_received (GtkWidget *widget,
g_strfreev (strv);
return;
}
- g_object_unref (account_manager);
g_strfreev (strv);
old_window = chat_window_find_chat (chat);
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 27f8a0bdb..a6ce22b18 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -31,7 +31,6 @@
#include <telepathy-yell/telepathy-yell.h>
-#include <libempathy/empathy-channel-factory.h>
#include <libempathy/empathy-presence-manager.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-manager.h>
@@ -1371,9 +1370,8 @@ empathy_event_manager_init (EmpathyEventManager *manager)
{
EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv);
- TpDBusDaemon *dbus;
GError *error = NULL;
- EmpathyChannelFactory *factory;
+ TpAccountManager *am;
manager->priv = priv;
@@ -1389,20 +1387,10 @@ empathy_event_manager_init (EmpathyEventManager *manager)
g_signal_connect (priv->contact_manager, "members-changed",
G_CALLBACK (event_manager_members_changed_cb), manager);
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- DEBUG ("Failed to get TpDBusDaemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
- priv->approver = tp_simple_approver_new (dbus, "Empathy.EventManager", FALSE,
- approve_channels, manager, NULL);
-
- /* EmpathyTpChat relies on this feature being prepared */
- tp_base_client_add_connection_features_varargs (priv->approver,
- TP_CONNECTION_FEATURE_CAPABILITIES, 0);
+ priv->approver = tp_simple_approver_new_with_am (am, "Empathy.EventManager",
+ FALSE, approve_channels, manager, NULL);
/* Private text channels */
tp_base_client_take_approver_filter (priv->approver,
@@ -1449,7 +1437,7 @@ empathy_event_manager_init (EmpathyEventManager *manager)
* EmpathyTpChat and its users to not depend on the connection being
* prepared with capabilities. I chose the former, obviously. :-) */
- priv->auth_approver = tp_simple_approver_new (dbus,
+ priv->auth_approver = tp_simple_approver_new_with_am (am,
"Empathy.AuthEventManager", FALSE, approve_channels, manager,
NULL);
@@ -1463,11 +1451,6 @@ empathy_event_manager_init (EmpathyEventManager *manager)
TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION,
NULL));
- factory = empathy_channel_factory_dup ();
-
- tp_base_client_set_channel_factory (priv->approver,
- TP_CLIENT_CHANNEL_FACTORY (factory));
-
if (!tp_base_client_register (priv->approver, &error))
{
DEBUG ("Failed to register Approver: %s", error->message);
@@ -1480,8 +1463,7 @@ empathy_event_manager_init (EmpathyEventManager *manager)
g_error_free (error);
}
- g_object_unref (factory);
- g_object_unref (dbus);
+ g_object_unref (am);
}
EmpathyEventManager *
diff --git a/src/empathy-streamed-media-factory.c b/src/empathy-streamed-media-factory.c
index e044a1b52..9ef5da5e1 100644
--- a/src/empathy-streamed-media-factory.c
+++ b/src/empathy-streamed-media-factory.c
@@ -72,20 +72,13 @@ empathy_streamed_media_factory_init (EmpathyStreamedMediaFactory *obj)
{
EmpathyStreamedMediaFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj,
EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, EmpathyStreamedMediaFactoryPriv);
- TpDBusDaemon *dbus;
- GError *error = NULL;
+ TpAccountManager *am;
obj->priv = priv;
- dbus = tp_dbus_daemon_dup (&error);
- if (dbus == NULL)
- {
- g_warning ("Failed to get TpDBusDaemon: %s", error->message);
- g_error_free (error);
- return;
- }
+ am = tp_account_manager_dup ();
- priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE,
+ priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE,
EMPATHY_AV_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, obj, NULL);
tp_base_client_take_handler_filter (priv->handler, tp_asv_new (
@@ -114,7 +107,7 @@ empathy_streamed_media_factory_init (EmpathyStreamedMediaFactory *obj)
"org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264",
NULL);
- g_object_unref (dbus);
+ g_object_unref (am);
}
static GObject *
diff --git a/tests/empathy-chatroom-manager-test.c b/tests/empathy-chatroom-manager-test.c
index b79e898d0..966027f38 100644
--- a/tests/empathy-chatroom-manager-test.c
+++ b/tests/empathy-chatroom-manager-test.c
@@ -109,7 +109,7 @@ START_TEST (test_empathy_chatroom_manager_dup_singleton)
{ "name1", "room1", TRUE, TRUE },
{ "name2", "room2", FALSE, TRUE }};
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -143,7 +143,7 @@ START_TEST (test_empathy_chatroom_manager_add)
{ "name4", "room4", FALSE, FALSE }};
EmpathyChatroom *chatroom;
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
account = get_test_account ();
@@ -203,7 +203,7 @@ START_TEST (test_empathy_chatroom_manager_remove)
EmpathyChatroom *chatroom;
EmpathyAccountManager *account_mgr;
- account_mgr = empathy_account_manager_dup_singleton ();
+ account_mgr = tp_account_manager_dup ();
account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -260,7 +260,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite)
{ "name2", "room2", FALSE, FALSE }};
EmpathyChatroom *chatroom;
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
@@ -324,7 +324,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom)
{ "name2", "room2", FALSE, TRUE }};
EmpathyChatroom *chatroom;
- account_manager = empathy_account_manager_dup_singleton ();
+ account_manager = tp_account_manager_dup ();
account = get_test_account ();
copy_xml_file (CHATROOM_SAMPLE, "foo.xml");