diff options
-rw-r--r-- | libempathy-gtk/empathy-chat-window.c | 11 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 22 | ||||
-rw-r--r-- | libempathy-gtk/empathy-new-message-dialog.c | 15 | ||||
-rw-r--r-- | libempathy-gtk/empathy-private-chat.c | 11 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 30 | ||||
-rw-r--r-- | libempathy/empathy-utils.h | 4 |
6 files changed, 41 insertions, 52 deletions
diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index d1fb7906f..b6409f6a8 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -1626,16 +1626,7 @@ chat_window_drag_data_received (GtkWidget *widget, chat = empathy_chat_window_find_chat (account, id); if (!chat) { - MissionControl *mc; - - mc = empathy_mission_control_new (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_TEXT, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + empathy_chat_with_contact_id (account, id); return; } diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 9b6a98a6a..498d88721 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -183,8 +183,6 @@ static void contact_list_view_row_expand_or_collapse_cb (EmpathyContactLi gpointer user_data); static void contact_list_view_action_cb (GtkAction *action, EmpathyContactListView *view); -static void contact_list_view_action_activated (EmpathyContactListView *view, - EmpathyContact *contact); static void contact_list_view_voip_activated (EmpathyContactListView *view, EmpathyContact *contact); @@ -1314,7 +1312,7 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view, -1); if (contact) { - contact_list_view_action_activated (view, contact); + empathy_chat_with_contact (contact); g_object_unref (contact); } } @@ -1397,7 +1395,7 @@ contact_list_view_action_cb (GtkAction *action, parent = empathy_get_toplevel_window (GTK_WIDGET (view)); if (contact && strcmp (name, "Chat") == 0) { - contact_list_view_action_activated (view, contact); + empathy_chat_with_contact (contact); } else if (contact && strcmp (name, "Call") == 0) { contact_list_view_voip_activated (view, contact); @@ -1436,22 +1434,6 @@ contact_list_view_action_cb (GtkAction *action, } static void -contact_list_view_action_activated (EmpathyContactListView *view, - EmpathyContact *contact) -{ - MissionControl *mc; - - mc = empathy_mission_control_new (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_TEXT, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); -} - -static void contact_list_view_voip_activated (EmpathyContactListView *view, EmpathyContact *contact) { diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 7a3fd9731..80e3b611c 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -56,8 +56,8 @@ new_message_dialog_response_cb (GtkWidget *widget, gint response, EmpathyNewMessageDialog *dialog) { - McAccount *account; - const gchar *id; + McAccount *account; + const gchar *id; account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser)); id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id)); @@ -70,16 +70,7 @@ new_message_dialog_response_cb (GtkWidget *widget, } if (response == GTK_RESPONSE_OK) { - MissionControl *mc; - - mc = empathy_mission_control_new (); - mission_control_request_channel_with_string_handle (mc, - account, - TP_IFACE_CHANNEL_TYPE_TEXT, - id, - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + empathy_chat_with_contact_id (account, id); } else if (response == 3) { EmpathyContactFactory *factory; diff --git a/libempathy-gtk/empathy-private-chat.c b/libempathy-gtk/empathy-private-chat.c index 9af944174..2dd1ba755 100644 --- a/libempathy-gtk/empathy-private-chat.c +++ b/libempathy-gtk/empathy-private-chat.c @@ -251,16 +251,7 @@ private_chat_contact_presence_updated_cb (EmpathyContact *contact, /* If offline message is not supported by CM we need to * request a new Text Channel. */ if (!empathy_chat_is_connected (EMPATHY_CHAT (chat))) { - MissionControl *mc; - - mc = empathy_mission_control_new (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_TEXT, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + empathy_chat_with_contact (contact); } } diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index f322f0288..0e2c4b588 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -451,3 +451,33 @@ empathy_call_contact (EmpathyContact *contact) #endif } +void +empathy_chat_with_contact (EmpathyContact *contact) +{ + MissionControl *mc; + + mc = empathy_mission_control_new (); + mission_control_request_channel (mc, + empathy_contact_get_account (contact), + TP_IFACE_CHANNEL_TYPE_TEXT, + empathy_contact_get_handle (contact), + TP_HANDLE_TYPE_CONTACT, + NULL, NULL); + g_object_unref (mc); +} + +void +empathy_chat_with_contact_id (McAccount *account, const gchar *contact_id) +{ + MissionControl *mc; + + mc = empathy_mission_control_new (); + mission_control_request_channel_with_string_handle (mc, + account, + TP_IFACE_CHANNEL_TYPE_TEXT, + contact_id, + TP_HANDLE_TYPE_CONTACT, + NULL, NULL); + g_object_unref (mc); +} + diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 746e8de5b..1f3700d22 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -89,6 +89,10 @@ gchar * empathy_inspect_handle (McAccount *account, gchar * empathy_inspect_channel (McAccount *account, TpChan *tp_chan); void empathy_call_contact (EmpathyContact *contact); +void empathy_chat_with_contact (EmpathyContact *contact); +void empathy_chat_with_contact_id (McAccount *account, + const gchar *contact_id); + G_END_DECLS #endif /* __EMPATHY_UTILS_H__ */ |