aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-chat.c4
-rw-r--r--libempathy/empathy-tp-contact-list.c2
-rw-r--r--src/empathy-call-chandler.c5
-rw-r--r--src/empathy-status-icon.c134
-rw-r--r--src/empathy.c38
5 files changed, 78 insertions, 105 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 0dbc25a41..3be3302f6 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1572,10 +1572,10 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
EmpathyTpChat *tp_chat)
{
EmpathyChatPriv *priv;
- TpChan *tp_chan;
g_return_if_fail (EMPATHY_IS_CHAT (chat));
g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
+ g_return_if_fail (empathy_tp_chat_is_ready (tp_chat));
priv = GET_PRIV (chat);
@@ -1594,8 +1594,6 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
priv->tp_chat = g_object_ref (tp_chat);
priv->id = g_strdup (empathy_tp_chat_get_id (tp_chat));
priv->account = g_object_ref (empathy_tp_chat_get_account (tp_chat));
- tp_chan = empathy_tp_chat_get_channel (tp_chat);
- priv->handle_type = tp_chan->handle_type;
g_signal_connect (tp_chat, "message-received",
G_CALLBACK (chat_message_received_cb),
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index b22c5f9ea..8dbbc6100 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -403,7 +403,7 @@ tp_contact_list_add_channel (EmpathyTpContactList *list,
object_path, channel_type,
handle_type, handle, NULL);
- group = empathy_tp_group_new (priv->account, channel);
+ group = empathy_tp_group_new (channel);
empathy_run_until_ready (group);
g_object_unref (channel);
diff --git a/src/empathy-call-chandler.c b/src/empathy-call-chandler.c
index 07b992ea1..313fe73c6 100644
--- a/src/empathy-call-chandler.c
+++ b/src/empathy-call-chandler.c
@@ -47,13 +47,12 @@ weak_notify (gpointer data,
static void
new_channel_cb (EmpathyChandler *chandler,
- TpConn *connection,
- TpChan *channel,
+ TpChannel *channel,
MissionControl *mc)
{
EmpathyTpCall *call;
- call = empathy_tp_call_new (connection, channel);
+ call = empathy_tp_call_new (channel);
empathy_call_window_new (call);
g_object_unref (call);
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index aee16682b..0cafbfdd8 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -92,13 +92,11 @@ struct _StatusIconEvent {
static void empathy_status_icon_class_init (EmpathyStatusIconClass *klass);
static void empathy_status_icon_init (EmpathyStatusIcon *icon);
static void status_icon_finalize (GObject *object);
-static void status_icon_text_filter_new_channel (EmpathyFilter *filter,
- TpConn *tp_conn,
- TpChan *tp_chan,
+static void status_icon_text_filter_new_channel (EmpathyFilter *filter,
+ TpChannel *channel,
EmpathyStatusIcon *icon);
-static void status_icon_call_filter_new_channel (EmpathyFilter *filter,
- TpConn *tp_conn,
- TpChan *tp_chan,
+static void status_icon_call_filter_new_channel (EmpathyFilter *filter,
+ TpChannel *channel,
EmpathyStatusIcon *icon);
static void status_icon_message_received_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
@@ -292,24 +290,17 @@ empathy_status_icon_new (GtkWindow *window)
static void
status_icon_text_filter_new_channel (EmpathyFilter *filter,
- TpConn *tp_conn,
- TpChan *tp_chan,
+ TpChannel *channel,
EmpathyStatusIcon *icon)
{
- EmpathyStatusIconPriv *priv;
- McAccount *account;
- EmpathyTpChat *tp_chat;
-
- priv = GET_PRIV (icon);
-
- account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
+ EmpathyTpChat *tp_chat;
- empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered for contact %s",
- empathy_inspect_channel (account, tp_chan));
+ empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered for contact %p",
+ channel);
- tp_chat = empathy_tp_chat_new (account, tp_chan, FALSE);
+ tp_chat = empathy_tp_chat_new (channel, FALSE);
g_object_set_data (G_OBJECT (tp_chat), "filter", filter);
- g_object_unref (account);
+ g_object_set_data (G_OBJECT (tp_chat), "channel", channel);
g_signal_connect (tp_chat, "message-received",
G_CALLBACK (status_icon_message_received_cb),
@@ -343,68 +334,60 @@ status_icon_message_received_cb (EmpathyTpChat *tp_chat,
}
static void
-status_icon_call_member_added_cb (EmpathyTpGroup *group,
- EmpathyContact *member,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyStatusIcon *icon)
-{
- EmpathyFilter *filter;
-
- if (empathy_contact_is_user (member)) {
- /* We are member, it's an outgoing call, we can dispatch
- * the channel without asking the user */
- empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
- filter = g_object_get_data (G_OBJECT (group), "filter");
- empathy_filter_process (filter,
- empathy_tp_group_get_channel (group),
- TRUE);
- g_object_unref (group);
- }
-}
-
-static void
status_icon_event_call_cb (StatusIconEvent *event)
{
- EmpathyFilter *filter;
EmpathyTpGroup *group;
+ EmpathyFilter *filter;
+ TpChannel *channel;
empathy_debug (DEBUG_DOMAIN, "Dispatching call channel");
group = event->user_data;
filter = g_object_get_data (G_OBJECT (group), "filter");
- empathy_filter_process (filter,
- empathy_tp_group_get_channel (group),
- TRUE);
+ channel = g_object_get_data (G_OBJECT (group), "channel");
+ empathy_filter_process (filter, channel, TRUE);
g_object_unref (group);
}
static void
-status_icon_call_local_pending_cb (EmpathyTpGroup *group,
- EmpathyContact *member,
- EmpathyContact *actor,
- guint reason,
- const gchar *message,
- EmpathyStatusIcon *icon)
+status_icon_call_filter_new_channel (EmpathyFilter *filter,
+ TpChannel *channel,
+ EmpathyStatusIcon *icon)
{
- StatusIconEvent *event;
+ EmpathyTpGroup *group;
+ EmpathyPendingInfo *invitation;
+ EmpathyContact *contact = NULL;
+
+ empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
+
+ /* FIXME: We have to check if the user is member or local-pending to
+ * know if it's an incoming or outgoing call because of the way we
+ * request media channels MC can't know if it's incoming or outgoing */
+ group = empathy_tp_group_new (channel);
+ empathy_run_until_ready (group);
- if (empathy_contact_is_user (member)) {
- gchar *msg;
+ invitation = empathy_tp_group_get_invitation (group, &contact);
+ if (!invitation) {
+ empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
+ empathy_filter_process (filter, channel, TRUE);
+ } else {
+ StatusIconEvent *event;
+ gchar *msg;
/* We are local pending, it's an incoming call, we need to ask
* the user if he wants to accept the call. */
- empathy_contact_run_until_ready (member,
+ empathy_contact_run_until_ready (contact,
EMPATHY_CONTACT_READY_NAME,
NULL);
empathy_debug (DEBUG_DOMAIN, "INCOMING call, add event");
msg = g_strdup_printf (_("Incoming call from %s:\n%s"),
- empathy_contact_get_name (member),
- message);
+ empathy_contact_get_name (contact),
+ invitation->message);
+ g_object_set_data (G_OBJECT (group), "filter", filter);
+ g_object_set_data (G_OBJECT (group), "channel", channel);
event = status_icon_event_new (icon, EMPATHY_IMAGE_VOIP, msg);
event->func = status_icon_event_call_cb;
event->user_data = group;
@@ -413,37 +396,6 @@ status_icon_call_local_pending_cb (EmpathyTpGroup *group,
}
static void
-status_icon_call_filter_new_channel (EmpathyFilter *filter,
- TpConn *tp_conn,
- TpChan *tp_chan,
- EmpathyStatusIcon *icon)
-{
- EmpathyStatusIconPriv *priv;
- McAccount *account;
- EmpathyTpGroup *group;
-
- priv = GET_PRIV (icon);
-
- account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
-
- empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
-
- /* FIXME: We have to check if the user is member or local-pending to
- * know if it's an incoming or outgoing call because of the way we
- * request media channels MC can't know if it's incoming or outgoing */
- group = empathy_tp_group_new (account, tp_chan);
- g_object_set_data (G_OBJECT (group), "filter", filter);
- g_object_unref (account);
-
- g_signal_connect (group, "member-added",
- G_CALLBACK (status_icon_call_member_added_cb),
- icon);
- g_signal_connect (group, "local-pending",
- G_CALLBACK (status_icon_call_local_pending_cb),
- icon);
-}
-
-static void
status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
{
EmpathyStatusIconPriv *priv;
@@ -745,14 +697,14 @@ status_icon_event_msg_cb (StatusIconEvent *event)
{
EmpathyFilter *filter;
EmpathyTpChat *tp_chat;
+ TpChannel *channel;
empathy_debug (DEBUG_DOMAIN, "Dispatching text channel");
tp_chat = event->user_data;
filter = g_object_get_data (G_OBJECT (tp_chat), "filter");
- empathy_filter_process (filter,
- empathy_tp_chat_get_channel (tp_chat),
- TRUE);
+ channel = g_object_get_data (G_OBJECT (tp_chat), "channel");
+ empathy_filter_process (filter, channel, TRUE);
g_object_unref (tp_chat);
}
diff --git a/src/empathy.c b/src/empathy.c
index fdde610eb..431d84bda 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -33,6 +33,8 @@
#include <libebook/e-book.h>
#include <telepathy-glib/util.h>
+#include <telepathy-glib/channel.h>
+#include <telepathy-glib/connection.h>
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mission-control.h>
@@ -58,17 +60,36 @@ static BaconMessageConnection *connection = NULL;
static void
new_text_channel_cb (EmpathyChandler *chandler,
- TpConn *tp_conn,
- TpChan *tp_chan,
+ TpChannel *channel,
MissionControl *mc)
{
EmpathyTpChat *tp_chat;
+ TpConnection *connection;
+ guint handle_type;
+ guint handle;
+ gchar **names;
McAccount *account;
EmpathyChat *chat;
gchar *id;
-
- account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
- id = empathy_inspect_channel (account, tp_chan);
+ GArray *handles;
+
+ g_object_get (channel,
+ "connection", &connection,
+ "handle-type", &handle_type,
+ "handle", &handle,
+ 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);
+ id = *names;
+ g_free (names);
+ g_object_unref (connection);
+ g_array_free (handles, TRUE);
+
+ account = empathy_channel_get_account (channel);
chat = empathy_chat_window_find_chat (account, id);
g_free (id);
@@ -76,7 +97,8 @@ new_text_channel_cb (EmpathyChandler *chandler,
/* The chat already exists */
if (!empathy_chat_get_tp_chat (chat)) {
/* The chat died, give him the new text channel */
- tp_chat = empathy_tp_chat_new (account, tp_chan, TRUE);
+ tp_chat = empathy_tp_chat_new (channel, TRUE);
+ empathy_run_until_ready (tp_chat);
empathy_chat_set_tp_chat (chat, tp_chat);
g_object_unref (tp_chat);
}
@@ -86,7 +108,9 @@ new_text_channel_cb (EmpathyChandler *chandler,
return;
}
- tp_chat = empathy_tp_chat_new (account, tp_chan, TRUE);
+ tp_chat = empathy_tp_chat_new (channel, TRUE);
+ empathy_run_until_ready (tp_chat);
+
chat = empathy_chat_new (tp_chat);
empathy_chat_window_present_chat (chat);