aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy/empathy-utils.c')
-rw-r--r--libempathy/empathy-utils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 047dd931e..8b140ad43 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -378,3 +378,32 @@ empathy_check_available_state (void)
return TRUE;
}
+
+gchar *
+empathy_connection_get_protocol (TpConnection *connection,
+ gchar **ret_cmname)
+{
+ const gchar *object_path;
+ const gchar *cmname;
+ const gchar *proto;
+ const gchar *account;
+ gchar *ret;
+
+ g_return_val_if_fail (TP_IS_CONNECTION (connection), NULL);
+
+ /* Object path is in the form:
+ * /org/freedesktop/Telepathy/Connection/cmname/proto/account */
+ object_path = tp_proxy_get_object_path (TP_PROXY (connection));
+ cmname = object_path + strlen ("/org/freedesktop/Telepathy/Connection/");
+ proto = strstr (cmname, "/") + 1;
+ account = strstr (proto, "/") + 1;
+
+ if (ret_cmname) {
+ *ret_cmname = g_strndup (cmname, proto - cmname - 1);
+ g_strdelimit (*ret_cmname, "_", '-');
+ }
+
+ ret = g_strndup (proto, account - proto - 1);
+ return g_strdelimit (ret, "_", '-');
+}
+