aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-02-20 20:15:45 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-04-22 18:21:13 +0800
commit2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6 (patch)
treea6aa9cf4bb2627229afd3561ccbf00e3d0813904
parent82d5338954ab7bf8e7c3995d6ee04d66d5be6fc6 (diff)
downloadgsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar.gz
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar.bz2
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar.lz
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar.xz
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.tar.zst
gsoc2013-empathy-2c9b0fdb4a5e4187e4bee87a4a12a1d5ddb98bb6.zip
Extract protocol from the connection's object-path and correctly set the special group for xmpp-local contacts.
-rw-r--r--libempathy/empathy-tp-contact-list.c8
-rw-r--r--libempathy/empathy-utils.c29
-rw-r--r--libempathy/empathy-utils.h3
3 files changed, 36 insertions, 4 deletions
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index 051c342c9..636f2ed3f 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -700,7 +700,7 @@ tp_contact_list_constructed (GObject *list)
{
EmpathyTpContactListPriv *priv = GET_PRIV (list);
- const gchar *protocol_name = NULL;
+ gchar *protocol_name = NULL;
const gchar *names[] = {NULL, NULL};
priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
@@ -734,11 +734,13 @@ tp_contact_list_constructed (GObject *list)
/* Check for protocols that does not support contact groups. We can
* put all contacts into a special group in that case.
- * FIXME: Default group should be an information in the profile */
- //protocol_name = tp_connection_get_protocol (priv->connection);
+ * FIXME: Default group should be an information in the profile
+ * FIXME: replace with tp_connection_parse_object_path once released */
+ protocol_name = empathy_connection_get_protocol (priv->connection, NULL);
if (!tp_strdiff (protocol_name, "local-xmpp")) {
priv->protocol_group = _("People nearby");
}
+ g_free (protocol_name);
}
static void
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, "_", '-');
+}
+
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index e6bcfebfc..090de9dfd 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -78,7 +78,8 @@ gboolean empathy_proxy_equal (gconstpointer a,
gconstpointer b);
guint empathy_proxy_hash (gconstpointer key);
gboolean empathy_check_available_state (void);
-
+gchar * empathy_connection_get_protocol (TpConnection *connection,
+ gchar **cm_name);
G_END_DECLS
#endif /* __EMPATHY_UTILS_H__ */