diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-02 05:29:18 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-02 05:29:18 +0800 |
commit | f4d9313a82b4ce88b87bba1427fdbece4f1d00ad (patch) | |
tree | 29ae5b335755543e8bee83a77201e44f7865d5d9 | |
parent | 5cfedc9344ec1de3edf25f82f6bce6a13ae8de39 (diff) | |
download | gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar.gz gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar.bz2 gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar.lz gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar.xz gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.tar.zst gsoc2013-empathy-f4d9313a82b4ce88b87bba1427fdbece4f1d00ad.zip |
Add back empathy_tp_chat_new_with_contact
svn path=/trunk/; revision=526
-rw-r--r-- | libempathy/empathy-tp-chat.c | 43 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 1 |
2 files changed, 44 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 68a0af174..7a7f8dfec 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -561,6 +561,49 @@ empathy_tp_chat_new (McAccount *account, NULL); } +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); + + g_object_unref (tp_conn); + g_object_unref (text_chan); + g_object_unref (mc); + + return chat; +} + gboolean empathy_tp_chat_get_acknowledge (EmpathyTpChat *chat) { diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 7f5ef212e..6de2cad4e 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -57,6 +57,7 @@ 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_with_contact (EmpathyContact *contact); gboolean empathy_tp_chat_get_acknowledge (EmpathyTpChat *chat); void empathy_tp_chat_set_acknowledge (EmpathyTpChat *chat, gboolean acknowledge); |