aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-tp-chat.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2007-04-27 04:51:09 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-04-27 04:51:09 +0800
commit69814b0fd3717aadde21b392c875033865903f07 (patch)
tree31af67384bdcdaacc5ea0bf23378dabe42f42474 /libempathy/empathy-tp-chat.c
parent703a7db832de5d180a6880321fcee7919eb6094e (diff)
downloadgsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar.gz
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar.bz2
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar.lz
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar.xz
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.tar.zst
gsoc2013-empathy-69814b0fd3717aadde21b392c875033865903f07.zip
[darcs-to-svn @ Save/restore window geometry]
svn path=/trunk/; revision=6
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r--libempathy/empathy-tp-chat.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 9ddad869d..36ac8a7a8 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -25,6 +25,7 @@
#include <libtelepathy/tp-helpers.h>
#include <libtelepathy/tp-chan-type-text-gen.h>
#include <libtelepathy/tp-chan-iface-chat-state-gen.h>
+#include <libtelepathy/tp-conn.h>
#include "empathy-tp-chat.h"
#include "empathy-contact-manager.h"
@@ -41,6 +42,9 @@
struct _EmpathyTpChatPriv {
EmpathyContactList *list;
+ McAccount *account;
+ gchar *id;
+
TpChan *tp_chan;
DBusGProxy *text_iface;
DBusGProxy *chat_state_iface;
@@ -160,6 +164,10 @@ tp_chat_finalize (GObject *object)
if (priv->list) {
g_object_unref (priv->list);
}
+ if (priv->account) {
+ g_object_unref (priv->account);
+ }
+ g_free (priv->id);
G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object);
}
@@ -181,6 +189,7 @@ empathy_tp_chat_new (McAccount *account,
manager = empathy_session_get_contact_manager ();
priv->list = empathy_contact_manager_get_list (manager, account);
priv->tp_chan = g_object_ref (tp_chan);
+ priv->account = g_object_ref (account);
g_object_ref (priv->list);
priv->text_iface = tp_chan_get_interface (tp_chan,
@@ -360,6 +369,55 @@ empathy_tp_chat_send_state (EmpathyTpChat *chat,
}
}
+const gchar *
+empathy_tp_chat_get_id (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv;
+ MissionControl *mc;
+ TpConn *tp_conn;
+ GArray *handles;
+ gchar **names;
+ GError *error = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
+
+ priv = GET_PRIV (chat);
+
+ if (priv->id) {
+ return priv->id;
+ }
+
+ mc = empathy_session_get_mission_control ();
+ tp_conn = mission_control_get_connection (mc, priv->account, NULL);
+ handles = g_array_new (FALSE, FALSE, sizeof (guint));
+ g_array_append_val (handles, priv->tp_chan->handle);
+
+ if (!tp_conn_inspect_handles (DBUS_G_PROXY (tp_conn),
+ priv->tp_chan->handle_type,
+ handles,
+ &names,
+ &error)) {
+ gossip_debug (DEBUG_DOMAIN,
+ "Couldn't get id: %s",
+ error ? error->message : "No error given");
+ g_clear_error (&error);
+ g_array_free (handles, TRUE);
+ g_object_unref (tp_conn);
+
+ return NULL;
+ }
+
+ /* A handle name is unique only for a specific account */
+ priv->id = g_strdup_printf ("%s/%s",
+ mc_account_get_unique_name (priv->account),
+ *names);
+
+ g_strfreev (names);
+ g_object_unref (tp_conn);
+
+ return priv->id;
+}
+
static void
tp_chat_destroy_cb (TpChan *text_chan,
EmpathyTpChat *chat)