]> git.0d.be Git - empathy.git/commitdiff
Add convinience functions empathy_chat_with_contact() and empathy_chat_with_contact_i...
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 1 Jan 2008 21:29:21 +0000 (21:29 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 1 Jan 2008 21:29:21 +0000 (21:29 +0000)
svn path=/trunk/; revision=527

libempathy-gtk/empathy-chat-window.c
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-new-message-dialog.c
libempathy-gtk/empathy-private-chat.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index d1fb7906f806e55646dee1be06907c7914b3f046..b6409f6a8f30c404ae7b79c88bbcce40d2ad50b9 100644 (file)
@@ -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;
                }
 
index 9b6a98a6abc41e5bcb1417e5fb778f494ff2e9fd..498d887213f2c6cdbdee9bed77bb2d20e19e644c 100644 (file)
@@ -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);
@@ -1435,22 +1433,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)
index 7a3fd9731ed143872c8caf95f537e6c401432528..80e3b611ccf4716228c12534d0058510b8b5c218 100644 (file)
@@ -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;
index 9af944174f3aa5cbe9945feb46033bbb2b9ffa97..2dd1ba7554dc31bf68673d5f92ae966a28955a0c 100644 (file)
@@ -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);
                }
        }
 
index f322f0288a1f73f8c90f991e4ea81c84105d79f6..0e2c4b588d5a8f79913c7d38a8528526146b83d3 100644 (file)
@@ -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);
+}
+
index 746e8de5b7e794cfc60dc212e60daffe369f80fe..1f3700d22858f7a096859573b254432e11b36d79 100644 (file)
@@ -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__ */