]> git.0d.be Git - empathy.git/commitdiff
Extract protocol from the connection's object-path and correctly set the special...
authorXavier Claessens <xclaesse@gmail.com>
Fri, 20 Feb 2009 12:15:45 +0000 (13:15 +0100)
committerXavier Claessens <xclaesse@gmail.com>
Wed, 22 Apr 2009 10:21:13 +0000 (12:21 +0200)
libempathy/empathy-tp-contact-list.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index 051c342c99431f71bbcf1469f85c9afdd4c215a8..636f2ed3f89b3c1bd7095f9799b36e7f9836cf20 100644 (file)
@@ -700,7 +700,7 @@ tp_contact_list_constructed (GObject *list)
 {
 
        EmpathyTpContactListPriv *priv = GET_PRIV (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);
        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.
 
        /* 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");
        }
        if (!tp_strdiff (protocol_name, "local-xmpp")) {
                priv->protocol_group = _("People nearby");
        }
+       g_free (protocol_name);
 }
 
 static void
 }
 
 static void
index 047dd931e6a3f2836e54836b763bb21ab284a868..8b140ad4359ad97593a1fbbea0a3cf3373bcb162 100644 (file)
@@ -378,3 +378,32 @@ empathy_check_available_state (void)
 
        return TRUE;
 }
 
        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, "_", '-');
+}
+
index e6bcfebfc68e017145953ee407a3b5d00effd520..090de9dfd0a18a386322483dd50e9f9eb3819312 100644 (file)
@@ -78,7 +78,8 @@ gboolean     empathy_proxy_equal                    (gconstpointer    a,
                                                     gconstpointer    b);
 guint        empathy_proxy_hash                     (gconstpointer    key);
 gboolean     empathy_check_available_state          (void);
                                                     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__ */
 G_END_DECLS
 
 #endif /*  __EMPATHY_UTILS_H__ */