summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-06 14:21:31 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-07 15:27:05 +0100
commitd96a1a927959b43586a888c56d45ab8b23b60de0 (patch)
tree17a335c606af494a32a8d31162a9e4b32361bbc0
parent70580a776d7b54a950042ea6c08b4949d96f2332 (diff)
connection: add get_jid_for_caps utility function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--gabble/connection.h5
-rw-r--r--src/connection.c29
2 files changed, 34 insertions, 0 deletions
diff --git a/gabble/connection.h b/gabble/connection.h
index 040b11b0..6da5d8a7 100644
--- a/gabble/connection.h
+++ b/gabble/connection.h
@@ -26,6 +26,8 @@
#include <gabble/capabilities-set.h>
#include <gabble/types.h>
+#include <wocky/wocky-xep-0115-capabilities.h>
+
G_BEGIN_DECLS
#define GABBLE_TYPE_CONNECTION (gabble_connection_get_type ())
@@ -60,6 +62,9 @@ WockySession *gabble_connection_get_session (
gchar *gabble_connection_get_full_jid (GabbleConnection *conn);
+const gchar * gabble_connection_get_jid_for_caps (GabbleConnection *conn,
+ WockyXep0115Capabilities *caps);
+
G_END_DECLS
#endif
diff --git a/src/connection.c b/src/connection.c
index b9ec972a..70424d10 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -3828,3 +3828,32 @@ gabble_connection_add_sidecar_own_caps (GabbleConnection *self,
return ver;
}
+
+const gchar *
+gabble_connection_get_jid_for_caps (GabbleConnection *conn,
+ WockyXep0115Capabilities *caps)
+{
+ TpHandle handle;
+ TpBaseConnection *base;
+ TpHandleRepoIface *contact_handles;
+
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+ g_return_val_if_fail (GABBLE_IS_PRESENCE (caps), NULL);
+
+ base = (TpBaseConnection *) conn;
+
+ if ((GabblePresence *) caps == conn->self_presence)
+ {
+ handle = tp_base_connection_get_self_handle (base);
+ }
+ else
+ {
+ handle = gabble_presence_cache_get_handle (conn->presence_cache,
+ (GabblePresence *) caps);
+ }
+
+ contact_handles = tp_base_connection_get_handles (base,
+ TP_HANDLE_TYPE_CONTACT);
+
+ return tp_handle_inspect (contact_handles, handle);
+}