aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-chat.c9
-rw-r--r--libempathy/empathy-dispatcher.c13
-rw-r--r--libempathy/empathy-dispatcher.h2
-rw-r--r--src/empathy-chat-manager.c62
-rw-r--r--src/empathy-main-window.c5
-rw-r--r--src/empathy-new-chatroom-dialog.c6
-rw-r--r--src/empathy.c9
7 files changed, 32 insertions, 74 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 9c6a632bc..71fb2e880 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -244,8 +244,8 @@ account_reconnected (EmpathyChat *chat,
account, priv->id, EMPATHY_DISPATCHER_NON_USER_ACTION);
break;
case TP_HANDLE_TYPE_ROOM:
- empathy_dispatcher_join_muc (tp_account_get_connection (account),
- priv->id, EMPATHY_DISPATCHER_NON_USER_ACTION);
+ empathy_dispatcher_join_muc (account, priv->id,
+ EMPATHY_DISPATCHER_NON_USER_ACTION);
break;
case TP_HANDLE_TYPE_NONE:
case TP_HANDLE_TYPE_LIST:
@@ -710,8 +710,9 @@ chat_command_join (EmpathyChat *chat,
TpConnection *connection;
connection = empathy_tp_chat_get_connection (priv->tp_chat);
- empathy_dispatcher_join_muc (connection, rooms[i],
- gtk_get_current_event_time ());
+ empathy_dispatcher_join_muc (
+ empathy_get_account_for_connection (connection), rooms[i],
+ gtk_get_current_event_time ());
}
i++;
}
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index e5abfde8b..a286d5079 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1305,9 +1305,9 @@ dispatcher_request_handles_cb (TpConnection *connection,
}
void
-empathy_dispatcher_join_muc (TpConnection *connection,
- const gchar *roomname,
- gint64 timestamp)
+empathy_dispatcher_join_muc (TpAccount *account,
+ const gchar *roomname,
+ gint64 timestamp)
{
EmpathyDispatcher *self;
EmpathyDispatcherPriv *priv;
@@ -1315,13 +1315,18 @@ empathy_dispatcher_join_muc (TpConnection *connection,
ConnectionData *connection_data;
const gchar *names[] = { roomname, NULL };
TpProxyPendingCall *call;
+ TpConnection *connection;
- g_return_if_fail (TP_IS_CONNECTION (connection));
+ g_return_if_fail (TP_IS_ACCOUNT (account));
g_return_if_fail (!EMP_STR_EMPTY (roomname));
self = empathy_dispatcher_dup_singleton ();
priv = GET_PRIV (self);
+ connection = tp_account_get_connection (account);
+ if (connection == NULL)
+ return;
+
connection_data = g_hash_table_lookup (priv->connections, connection);
g_assert (connection_data != NULL);
diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h
index 918a4286a..7991de085 100644
--- a/libempathy/empathy-dispatcher.h
+++ b/libempathy/empathy-dispatcher.h
@@ -83,7 +83,7 @@ void empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
gint64 timestamp);
/* Request a muc channel */
-void empathy_dispatcher_join_muc (TpConnection *connection,
+void empathy_dispatcher_join_muc (TpAccount *account,
const gchar *roomname,
gint64 timestamp);
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index a3177a3f7..8b9a73b62 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -369,53 +369,11 @@ empathy_chat_manager_closed_chat (EmpathyChatManager *self,
g_queue_get_length (priv->queue));
}
-static void
-connection_ready_cb (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- ChatData *data = user_data;
- EmpathyChatManager *self = chat_manager_singleton;
- EmpathyChatManagerPriv *priv;
-
- /* Extremely unlikely to happen, but I don't really want to keep refs to the
- * chat manager in the ChatData structs as it'll then prevent the manager
- * from being finalized. */
- if (G_UNLIKELY (self == NULL))
- goto out;
-
- priv = GET_PRIV (self);
-
- /* FIXME: Once empathy_dispatcher_join_muc will take a TpAccount instead of
- * a TpConnection we won't have to prepare the connection any more. */
- if (error == NULL)
- {
- if (data->room)
- empathy_dispatcher_join_muc (connection, data->id,
- EMPATHY_DISPATCHER_NON_USER_ACTION);
- else
- empathy_dispatcher_chat_with_contact_id (
- empathy_get_account_for_connection (connection), data->id,
- EMPATHY_DISPATCHER_NON_USER_ACTION);
-
- g_signal_emit (self, signals[CHATS_CHANGED], 0,
- g_queue_get_length (priv->queue));
- }
- else
- {
- DEBUG ("Error readying connection, no chat: %s", error->message);
- }
-
-out:
- chat_data_free (data);
-}
-
void
empathy_chat_manager_undo_closed_chat (EmpathyChatManager *self)
{
EmpathyChatManagerPriv *priv = GET_PRIV (self);
ChatData *data;
- TpConnection *connection;
data = g_queue_pop_tail (priv->queue);
@@ -425,17 +383,17 @@ empathy_chat_manager_undo_closed_chat (EmpathyChatManager *self)
DEBUG ("Removing %s from queue and starting a chat with: %s",
data->room ? "room" : "contact", data->id);
- connection = tp_account_get_connection (data->account);
-
- if (connection != NULL)
- {
- tp_connection_call_when_ready (connection, connection_ready_cb, data);
- }
+ if (data->room)
+ empathy_dispatcher_join_muc (data->account, data->id,
+ EMPATHY_DISPATCHER_NON_USER_ACTION);
else
- {
- DEBUG ("No connection, no chat.");
- chat_data_free (data);
- }
+ empathy_dispatcher_chat_with_contact_id (data->account, data->id,
+ EMPATHY_DISPATCHER_NON_USER_ACTION);
+
+ g_signal_emit (self, signals[CHATS_CHANGED], 0,
+ g_queue_get_length (priv->queue));
+
+ chat_data_free (data);
}
guint
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index d99d2ab0b..ff8bb5e98 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -948,16 +948,13 @@ join_chatroom (EmpathyChatroom *chatroom,
gint64 timestamp)
{
TpAccount *account;
- TpConnection *connection;
const gchar *room;
account = empathy_chatroom_get_account (chatroom);
- connection = tp_account_get_connection (account);
- g_assert (connection != NULL);
room = empathy_chatroom_get_room (chatroom);
DEBUG ("Requesting channel for '%s'", room);
- empathy_dispatcher_join_muc (connection, room, timestamp);
+ empathy_dispatcher_join_muc (account, room, timestamp);
}
typedef struct
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 88003e948..63e766449 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -714,7 +714,7 @@ static void
new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
{
EmpathyAccountChooser *account_chooser;
- TpConnection *connection;
+ TpAccount *account;
const gchar *room;
const gchar *server = NULL;
gchar *room_name = NULL;
@@ -723,7 +723,7 @@ new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server));
account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
- connection = empathy_account_chooser_get_connection (account_chooser);
+ account = empathy_account_chooser_get_account (account_chooser);
if (!EMP_STR_EMPTY (server)) {
room_name = g_strconcat (room, "@", server, NULL);
@@ -734,7 +734,7 @@ new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
g_strstrip (room_name);
DEBUG ("Requesting channel for '%s'", room_name);
- empathy_dispatcher_join_muc (connection, room_name,
+ empathy_dispatcher_join_muc (account, room_name,
gtk_get_current_event_time ());
g_free (room_name);
diff --git a/src/empathy.c b/src/empathy.c
index aefb934eb..c1282808a 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -298,13 +298,10 @@ account_status_changed_cb (TpAccount *account,
GHashTable *details,
EmpathyChatroom *room)
{
- TpConnection *conn;
-
- conn = tp_account_get_connection (account);
- if (conn == NULL)
+ if (new_status != TP_CONNECTION_STATUS_CONNECTED)
return;
- empathy_dispatcher_join_muc (conn,
+ empathy_dispatcher_join_muc (account,
empathy_chatroom_get_room (room), EMPATHY_DISPATCHER_NON_USER_ACTION);
}
@@ -352,7 +349,7 @@ account_manager_chatroom_ready_cb (GObject *source_object,
}
else
{
- empathy_dispatcher_join_muc (conn,
+ empathy_dispatcher_join_muc (account,
empathy_chatroom_get_room (room),
EMPATHY_DISPATCHER_NON_USER_ACTION);
}