diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-tp-call.c | 84 | ||||
-rw-r--r-- | libempathy/empathy-tp-call.h | 6 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 172 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 11 | ||||
-rw-r--r-- | libempathy/empathy-tp-group.c | 26 | ||||
-rw-r--r-- | libempathy/empathy-tp-group.h | 5 |
6 files changed, 72 insertions, 232 deletions
diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index e8d13bb0b..82e305a58 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -24,8 +24,6 @@ #include <telepathy-glib/proxy-subclass.h> #include <telepathy-glib/dbus.h> -#include <libmissioncontrol/mc-account.h> - #include <extensions/extensions.h> #include <libempathy/empathy-contact-factory.h> #include <libempathy/empathy-debug.h> @@ -46,7 +44,6 @@ typedef struct _EmpathyTpCallPriv EmpathyTpCallPriv; struct _EmpathyTpCallPriv { - TpConnection *connection; TpChannel *channel; TpProxy *stream_engine; TpDBusDaemon *dbus_daemon; @@ -63,7 +60,6 @@ struct _EmpathyTpCallPriv enum { PROP_0, - PROP_CONNECTION, PROP_CHANNEL, PROP_CONTACT, PROP_IS_INCOMING, @@ -276,59 +272,36 @@ tp_call_request_streams (EmpathyTpCall *call) { EmpathyTpCallPriv *priv = GET_PRIV (call); EmpathyCapabilities capabilities; + TpConnection *connection; empathy_debug (DEBUG_DOMAIN, "Requesting appropriate audio/video streams from contact"); /* FIXME: SIP don't have capabilities interface but we know it supports * only audio and not video. */ - if (!tp_proxy_has_interface_by_id (priv->connection, + g_object_get (priv->channel, "connection", &connection, NULL); + if (!tp_proxy_has_interface_by_id (connection, TP_IFACE_QUARK_CONNECTION_INTERFACE_CAPABILITIES)) capabilities = EMPATHY_CAPABILITIES_AUDIO; else capabilities = empathy_contact_get_capabilities (priv->contact); tp_call_request_streams_for_capabilities (call, capabilities); + g_object_unref (connection); } static void tp_call_group_ready_cb (EmpathyTpCall *call) { - EmpathyTpCallPriv *priv = GET_PRIV (call); - GList *members; - GList *local_pendings; - GList *remote_pendings; + EmpathyTpCallPriv *priv = GET_PRIV (call); + EmpathyPendingInfo *invitation; + invitation = empathy_tp_group_get_invitation (priv->group, &priv->contact); + priv->is_incoming = (invitation != NULL); priv->status = EMPATHY_TP_CALL_STATUS_PENDING; - members = empathy_tp_group_get_members (priv->group); - local_pendings = empathy_tp_group_get_local_pendings (priv->group); - remote_pendings = empathy_tp_group_get_remote_pendings (priv->group); - - if (local_pendings && - empathy_contact_is_user (((EmpathyPendingInfo *) local_pendings->data)->member)) - { - empathy_debug (DEBUG_DOMAIN, - "Incoming call is ready - %p", - ((EmpathyPendingInfo *) local_pendings->data)->member); - priv->is_incoming = TRUE; - priv->contact = g_object_ref (members->data); - } - else if (remote_pendings && empathy_contact_is_user (members->data)) - { - empathy_debug (DEBUG_DOMAIN, - "Outgoing call is ready - %p", remote_pendings->data); - priv->is_incoming = FALSE; - priv->contact = g_object_ref (remote_pendings->data); + if (!priv->is_incoming) tp_call_request_streams (call); - } - - g_list_foreach (members, (GFunc) g_object_unref, NULL); - g_list_free (members); - g_list_foreach (local_pendings, (GFunc) empathy_pending_info_free, NULL); - g_list_free (local_pendings); - g_list_foreach (remote_pendings, (GFunc) g_object_unref, NULL); - g_list_free (remote_pendings); g_object_notify (G_OBJECT (call), "is-incoming"); g_object_notify (G_OBJECT (call), "contact"); @@ -440,10 +413,11 @@ static void tp_call_stream_engine_handle_channel (EmpathyTpCall *call) { EmpathyTpCallPriv *priv = GET_PRIV (call); - const gchar *channel_type; - const gchar *object_path; + gchar *channel_type; + gchar *object_path; guint handle_type; guint handle; + TpProxy *connection; empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine"); @@ -468,6 +442,7 @@ tp_call_stream_engine_handle_channel (EmpathyTpCall *call) call, NULL); g_object_get (priv->channel, + "connection", &connection, "channel-type", &channel_type, "object-path", &object_path, "handle_type", &handle_type, @@ -475,11 +450,15 @@ tp_call_stream_engine_handle_channel (EmpathyTpCall *call) NULL); emp_cli_channel_handler_call_handle_channel (priv->stream_engine, -1, - TP_PROXY (priv->connection)->bus_name, - TP_PROXY (priv->connection)->object_path, + connection->bus_name, + connection->object_path, channel_type, object_path, handle_type, handle, tp_call_async_cb, "calling handle channel", NULL, G_OBJECT (call)); + + g_object_unref (connection); + g_free (channel_type); + g_free (object_path); } static GObject * @@ -490,8 +469,6 @@ tp_call_constructor (GType type, GObject *object; EmpathyTpCall *call; EmpathyTpCallPriv *priv; - MissionControl *mc; - McAccount *account; object = G_OBJECT_CLASS (empathy_tp_call_parent_class)->constructor (type, n_construct_params, construct_params); @@ -514,10 +491,7 @@ tp_call_constructor (GType type, tp_call_request_streams_cb, NULL, NULL, G_OBJECT (call)); /* Setup group interface */ - mc = empathy_mission_control_new (); - account = mission_control_get_account_for_tpconnection (mc, priv->connection, NULL); - priv->group = empathy_tp_group_new (account, priv->channel); - g_object_unref (mc); + priv->group = empathy_tp_group_new (priv->channel); g_signal_connect (G_OBJECT (priv->group), "member-added", G_CALLBACK (tp_call_member_added_cb), call); @@ -545,9 +519,6 @@ tp_call_finalize (GObject *object) g_slice_free (EmpathyTpCallStream, priv->video); g_object_unref (priv->group); - if (priv->connection != NULL) - g_object_unref (priv->connection); - if (priv->channel != NULL) { g_signal_handlers_disconnect_by_func (priv->channel, @@ -587,9 +558,6 @@ tp_call_set_property (GObject *object, switch (prop_id) { - case PROP_CONNECTION: - priv->connection = g_value_dup_object (value); - break; case PROP_CHANNEL: priv->channel = g_value_dup_object (value); break; @@ -609,9 +577,6 @@ tp_call_get_property (GObject *object, switch (prop_id) { - case PROP_CONNECTION: - g_value_set_object (value, priv->connection); - break; case PROP_CHANNEL: g_value_set_object (value, priv->channel); break; @@ -650,11 +615,6 @@ empathy_tp_call_class_init (EmpathyTpCallClass *klass) g_type_class_add_private (klass, sizeof (EmpathyTpCallPriv)); - g_object_class_install_property (object_class, PROP_CONNECTION, - g_param_spec_object ("connection", "connection", "connection", - TELEPATHY_CONN_TYPE, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | - G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); g_object_class_install_property (object_class, PROP_CHANNEL, g_param_spec_object ("channel", "channel", "channel", TELEPATHY_CHAN_TYPE, @@ -697,13 +657,11 @@ empathy_tp_call_init (EmpathyTpCall *call) } EmpathyTpCall * -empathy_tp_call_new (TpConnection *connection, TpChannel *channel) +empathy_tp_call_new (TpChannel *channel) { - g_return_val_if_fail (TP_IS_CONNECTION (connection), NULL); g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL); return g_object_new (EMPATHY_TYPE_TP_CALL, - "connection", connection, "channel", channel, NULL); } diff --git a/libempathy/empathy-tp-call.h b/libempathy/empathy-tp-call.h index f5333bba5..c08c8b657 100644 --- a/libempathy/empathy-tp-call.h +++ b/libempathy/empathy-tp-call.h @@ -21,11 +21,9 @@ #ifndef __EMPATHY_TP_CALL_H__ #define __EMPATHY_TP_CALL_H__ -#include <telepathy-glib/connection.h> +#include <glib.h> #include <telepathy-glib/channel.h> -#include <libmissioncontrol/mission-control.h> - G_BEGIN_DECLS #define EMPATHY_TYPE_TP_CALL (empathy_tp_call_get_type ()) @@ -68,7 +66,7 @@ typedef struct } EmpathyTpCallStream; GType empathy_tp_call_get_type (void) G_GNUC_CONST; -EmpathyTpCall *empathy_tp_call_new (TpConnection *connection, TpChannel *channel); +EmpathyTpCall *empathy_tp_call_new (TpChannel *channel); void empathy_tp_call_accept_incoming_call (EmpathyTpCall *call); void empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call, diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index aada6e163..767aec113 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -48,9 +48,7 @@ struct _EmpathyTpChatPriv { McAccount *account; TpChannel *channel; gchar *id; - MissionControl *mc; gboolean acknowledge; - TpChan *tp_chan; gboolean had_pending_messages; GSList *message_queue; gboolean had_properties_list; @@ -71,8 +69,6 @@ static void tp_chat_iface_init (EmpathyContactListIface *iface); enum { PROP_0, - PROP_ACCOUNT, - PROP_TP_CHAN, PROP_CHANNEL, PROP_ACKNOWLEDGE, PROP_REMOTE_CONTACT, @@ -692,13 +688,35 @@ static void tp_chat_channel_ready_cb (EmpathyTpChat *chat) { EmpathyTpChatPriv *priv = GET_PRIV (chat); + TpConnection *connection; + guint handle, handle_type; + GArray *handles; + gchar **names; empathy_debug (DEBUG_DOMAIN, "Channel ready"); + g_object_get (priv->channel, + "connection", &connection, + "handle", &handle, + "handle_type", &handle_type, + NULL); + + handles = g_array_new (FALSE, FALSE, sizeof (guint)); + g_array_append_val (handles, handle); + tp_cli_connection_run_inspect_handles (connection, -1, + handle_type, handles, + &names, NULL, NULL); + g_array_free (handles, TRUE); + + priv->id = *names; + g_free (names); + priv->ready = TRUE; + g_object_notify (G_OBJECT (chat), "ready"); + if (tp_proxy_has_interface_by_id (priv->channel, TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) { - priv->group = empathy_tp_group_new (priv->account, priv->channel); + priv->group = empathy_tp_group_new (priv->channel); g_signal_connect (priv->group, "member-added", G_CALLBACK (tp_chat_member_added_cb), @@ -712,7 +730,7 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat) } else { priv->remote_contact = empathy_contact_factory_get_from_handle (priv->factory, priv->account, - priv->tp_chan->handle); + handle); g_object_notify (G_OBJECT (chat), "remote-contact"); } @@ -780,9 +798,6 @@ tp_chat_finalize (GObject *object) object); g_object_unref (priv->channel); } - if (priv->tp_chan) { - g_object_unref (priv->tp_chan); - } if (priv->properties) { for (i = 0; i < priv->properties->len; i++) { @@ -808,7 +823,6 @@ tp_chat_finalize (GObject *object) g_object_unref (priv->factory); g_object_unref (priv->user); g_object_unref (priv->account); - g_object_unref (priv->mc); g_free (priv->id); G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object); @@ -826,9 +840,9 @@ tp_chat_constructor (GType type, chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props); priv = GET_PRIV (chat); + priv->account = empathy_channel_get_account (priv->channel); priv->factory = empathy_contact_factory_new (); priv->user = empathy_contact_factory_get_user (priv->factory, priv->account); - priv->mc = empathy_mission_control_new (); g_signal_connect (priv->channel, "invalidated", G_CALLBACK (tp_chat_invalidated_cb), @@ -855,12 +869,6 @@ tp_chat_get_property (GObject *object, EmpathyTpChatPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_ACCOUNT: - g_value_set_object (value, priv->account); - break; - case PROP_TP_CHAN: - g_value_set_object (value, priv->tp_chan); - break; case PROP_CHANNEL: g_value_set_object (value, priv->channel); break; @@ -888,12 +896,6 @@ tp_chat_set_property (GObject *object, EmpathyTpChatPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_ACCOUNT: - priv->account = g_object_ref (g_value_get_object (value)); - break; - case PROP_TP_CHAN: - priv->tp_chan = g_object_ref (g_value_get_object (value)); - break; case PROP_CHANNEL: priv->channel = g_object_ref (g_value_get_object (value)); break; @@ -917,22 +919,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass) object_class->set_property = tp_chat_set_property; g_object_class_install_property (object_class, - PROP_ACCOUNT, - g_param_spec_object ("account", - "channel Account", - "The account associated with the channel", - MC_TYPE_ACCOUNT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_TP_CHAN, - g_param_spec_object ("tp-chan", - "telepathy channel", - "The text channel for the chat", - TELEPATHY_CHAN_TYPE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, PROP_CHANNEL, g_param_spec_object ("channel", "telepathy channel", @@ -1032,98 +1018,13 @@ tp_chat_iface_init (EmpathyContactListIface *iface) } EmpathyTpChat * -empathy_tp_chat_new (McAccount *account, - TpChan *tp_chan, +empathy_tp_chat_new (TpChannel *channel, gboolean acknowledge) { - EmpathyTpChat *chat; - TpChannel *channel; - TpConnection *connection; - MissionControl *mc; - - mc = empathy_mission_control_new (); - connection = mission_control_get_tpconnection (mc, account, NULL); - channel = tp_chan_dup_channel (tp_chan, connection, NULL); - - chat = g_object_new (EMPATHY_TYPE_TP_CHAT, - "account", account, + return g_object_new (EMPATHY_TYPE_TP_CHAT, "channel", channel, - "tp-chan", tp_chan, "acknowledge", acknowledge, NULL); - - g_object_unref (channel); - g_object_unref (connection); - g_object_unref (mc); - - return chat; -} - -EmpathyTpChat * -empathy_tp_chat_new_with_contact (EmpathyContact *contact) -{ - EmpathyTpChat *chat; - MissionControl *mc; - McAccount *account; - TpConn *tp_conn; - TpChan *text_chan; - const gchar *bus_name; - guint handle; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - mc = empathy_mission_control_new (); - account = empathy_contact_get_account (contact); - - if (mission_control_get_connection_status (mc, account, NULL) != 0) { - /* The account is not connected. */ - return NULL; - } - - tp_conn = mission_control_get_connection (mc, account, NULL); - g_return_val_if_fail (tp_conn != NULL, NULL); - bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn)); - handle = empathy_contact_get_handle (contact); - - text_chan = tp_conn_new_channel (tp_get_bus (), - tp_conn, - bus_name, - TP_IFACE_CHANNEL_TYPE_TEXT, - TP_HANDLE_TYPE_CONTACT, - handle, - TRUE); - - chat = empathy_tp_chat_new (account, text_chan, TRUE); - - g_object_unref (tp_conn); - g_object_unref (text_chan); - g_object_unref (mc); - - return chat; -} - -TpChan * -empathy_tp_chat_get_channel (EmpathyTpChat *chat) -{ - EmpathyTpChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - return priv->tp_chan; -} - -McAccount * -empathy_tp_chat_get_account (EmpathyTpChat *chat) -{ - EmpathyTpChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - return priv->account; } void @@ -1171,15 +1072,10 @@ empathy_tp_chat_set_state (EmpathyTpChat *chat, const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat) { - EmpathyTpChatPriv *priv; + EmpathyTpChatPriv *priv = GET_PRIV (chat); g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - if (!priv->id) { - priv->id = empathy_inspect_channel (priv->account, priv->tp_chan); - } + g_return_val_if_fail (priv->ready, NULL); return priv->id; } @@ -1204,3 +1100,13 @@ empathy_tp_chat_is_ready (EmpathyTpChat *chat) return priv->ready; } +McAccount * +empathy_tp_chat_get_account (EmpathyTpChat *chat) +{ + EmpathyTpChatPriv *priv = GET_PRIV (chat); + + g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE); + + return priv->account; +} + diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 3e196fadf..9fa96a5f7 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -24,11 +24,9 @@ #include <glib.h> -#include <libtelepathy/tp-chan.h> +#include <telepathy-glib/channel.h> #include <telepathy-glib/enums.h> -#include <libmissioncontrol/mc-account.h> - #include "empathy-message.h" #include "empathy-contact.h" @@ -55,14 +53,11 @@ struct _EmpathyTpChatClass { }; GType empathy_tp_chat_get_type (void) G_GNUC_CONST; -EmpathyTpChat *empathy_tp_chat_new (McAccount *account, - TpChan *tp_chan, +EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel, gboolean acknowledge); -EmpathyTpChat *empathy_tp_chat_new_with_contact (EmpathyContact *contact); -McAccount * empathy_tp_chat_get_account (EmpathyTpChat *chat); -TpChan * empathy_tp_chat_get_channel (EmpathyTpChat *chat); const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat); EmpathyContact*empathy_tp_chat_get_remote_contact (EmpathyTpChat *chat); +McAccount * empathy_tp_chat_get_account (EmpathyTpChat *chat); gboolean empathy_tp_chat_is_ready (EmpathyTpChat *chat); void empathy_tp_chat_send (EmpathyTpChat *chat, EmpathyMessage *message); diff --git a/libempathy/empathy-tp-group.c b/libempathy/empathy-tp-group.c index ef6697de4..675854b27 100644 --- a/libempathy/empathy-tp-group.c +++ b/libempathy/empathy-tp-group.c @@ -22,6 +22,8 @@ #include <config.h> +#include <libmissioncontrol/mc-account.h> + #include <telepathy-glib/channel.h> #include <telepathy-glib/util.h> #include <telepathy-glib/interfaces.h> @@ -38,11 +40,11 @@ #define DEBUG_DOMAIN "TpGroup" struct _EmpathyTpGroupPriv { - McAccount *account; TpChannel *channel; gboolean ready; EmpathyContactFactory *factory; + McAccount *account; gchar *group_name; guint self_handle; GList *members; @@ -64,7 +66,6 @@ enum { enum { PROP_0, - PROP_ACCOUNT, PROP_CHANNEL, PROP_READY }; @@ -583,6 +584,7 @@ tp_group_constructed (GObject *group) gboolean channel_ready; priv->factory = empathy_contact_factory_new (); + priv->account = empathy_channel_get_account (priv->channel); g_signal_connect (priv->channel, "invalidated", G_CALLBACK (tp_group_invalidated_cb), @@ -607,9 +609,6 @@ tp_group_get_property (GObject *object, EmpathyTpGroupPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_ACCOUNT: - g_value_set_object (value, priv->account); - break; case PROP_CHANNEL: g_value_set_object (value, priv->channel); break; @@ -631,9 +630,6 @@ tp_group_set_property (GObject *object, EmpathyTpGroupPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_ACCOUNT: - priv->account = g_object_ref (g_value_get_object (value)); - break; case PROP_CHANNEL: priv->channel = g_object_ref (g_value_get_object (value)); break; @@ -654,14 +650,6 @@ empathy_tp_group_class_init (EmpathyTpGroupClass *klass) object_class->set_property = tp_group_set_property; g_object_class_install_property (object_class, - PROP_ACCOUNT, - g_param_spec_object ("account", - "channel Account", - "The account associated with the channel", - MC_TYPE_ACCOUNT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, PROP_CHANNEL, g_param_spec_object ("channel", "telepathy channel", @@ -736,15 +724,11 @@ empathy_tp_group_init (EmpathyTpGroup *group) } EmpathyTpGroup * -empathy_tp_group_new (McAccount *account, - TpChannel *channel) +empathy_tp_group_new (TpChannel *channel) { - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL); - return g_object_new (EMPATHY_TYPE_TP_GROUP, - "account", account, "channel", channel, NULL); } diff --git a/libempathy/empathy-tp-group.h b/libempathy/empathy-tp-group.h index 63473b48e..493536466 100644 --- a/libempathy/empathy-tp-group.h +++ b/libempathy/empathy-tp-group.h @@ -25,7 +25,7 @@ #include <glib.h> -#include <libmissioncontrol/mc-account.h> +#include <telepathy-glib/channel.h> #include "empathy-contact.h" @@ -58,8 +58,7 @@ typedef struct { } EmpathyPendingInfo; GType empathy_tp_group_get_type (void) G_GNUC_CONST; -EmpathyTpGroup * empathy_tp_group_new (McAccount *account, - TpChannel *channel); +EmpathyTpGroup * empathy_tp_group_new (TpChannel *channel); void empathy_tp_group_close (EmpathyTpGroup *group); void empathy_tp_group_add_members (EmpathyTpGroup *group, GList *contacts, |