diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-08-18 17:31:10 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-08-18 18:15:06 +0800 |
commit | 9ddd25f8589ae0cd5ec8e09c4c012e4ccac6a416 (patch) | |
tree | 4e4cfd5b8f801acff74edfdd5072f45d7038e00b /src | |
parent | 7fbf3e0c200b0a3c5086fdce0cc19afe48c429bb (diff) | |
download | gsoc2013-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
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-call-factory.c | 22 | ||||
-rw-r--r-- | src/empathy-call-handler.c | 7 | ||||
-rw-r--r-- | src/empathy-call-observer.c | 21 | ||||
-rw-r--r-- | src/empathy-chat-manager.c | 29 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 14 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 30 | ||||
-rw-r--r-- | src/empathy-streamed-media-factory.c | 15 |
7 files changed, 30 insertions, 108 deletions
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 * |