Empathy fixes for desktop-data-model



- Includes Marco's fix for XMPP vs. Pidgin from last Tuesday

- Ignore notifications for contacts before their ID is present
  (I was getting warnings)

- Use an URL (or at least quasi-URL) for the buddy resource ID, 
  not the  raw address

- Map:

    empathy ID => buddy "name"
    empathy name => buddy "alias"

  Not completely sure about this one ... didn't trace fully
  through where the empathy name was coming from. But from
  a quick look it seems right.

Look good?

- Owen

Index: engine-dbus/hippo-dbus-empathy.c
===================================================================
--- engine-dbus/hippo-dbus-empathy.c	(revision 7287)
+++ engine-dbus/hippo-dbus-empathy.c	(working copy)
@@ -1,23 +1,49 @@
 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
 #include <config.h>
+#include <string.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-contact-list.h>
 #include "hippo-im.h"
+#include "hippo-dbus-empathy.h"
 
+static char *
+make_buddy_resource_id(EmpathyContact *contact)
+{
+    McAccount *account = empathy_contact_get_account(contact);
+    McProfile *profile = mc_account_get_profile(account);
+
+    const char *protocol = mc_profile_get_protocol_name(profile);
+    const char *id = empathy_contact_get_id(contact);
+
+    if (protocol == NULL || id == NULL)
+        return NULL;
+    
+    return g_strdup_printf("online-desktop:/o/empathy-buddy/%s.%s", protocol, id);
+}
+
 static void
 update_buddy(EmpathyContact *contact)
 {
     EmpathyAvatar *avatar;
     McAccount *account;
     McProfile *profile;
+    const char *protocol;
 
+    char *resource_id = make_buddy_resource_id(contact);
+    if (resource_id == NULL)
+        return;
+
     account = empathy_contact_get_account(contact);
     profile = mc_account_get_profile(account);
+    protocol = mc_profile_get_protocol_name(profile);
 
-    hippo_im_update_buddy(empathy_contact_get_id(contact),
-                          mc_profile_get_protocol_name(profile),
+    if (strcmp(protocol, "jabber") == 0)
+        protocol = "xmpp";
+
+    hippo_im_update_buddy(resource_id,
+                          protocol,
+                          empathy_contact_get_id(contact),
                           empathy_contact_get_name(contact),
-                          NULL, /* alias */
                           empathy_contact_is_online(contact),
                           empathy_contact_get_status(contact),
                           empathy_contact_get_presence_message(contact),
@@ -29,6 +55,7 @@
                                    avatar->token, (gchar *)avatar->data, avatar->len);
     }
 
+    g_free(resource_id);
     g_object_unref (profile);
 }
 
@@ -69,15 +96,21 @@
         g_signal_connect(contact, "notify::avatar",
                          G_CALLBACK (contact_updated_cb), NULL);
     } else {
+        char *resource_id;
         g_signal_handlers_disconnect_by_func(contact,
                                              G_CALLBACK (contact_updated_cb), NULL);
 
-        hippo_im_remove_buddy(empathy_contact_get_id(contact));
+
+        resource_id = make_buddy_resource_id(contact);
+        if (resource_id != NULL) {
+            hippo_im_remove_buddy(resource_id);
+            g_free(resource_id);
+        }
     }
 }
 
 void
-hippo_dbus_init_empathy()
+hippo_dbus_init_empathy(void)
 {
     EmpathyContactManager *manager;
 
Index: engine-dbus/hippo-dbus-empathy.h
===================================================================
--- engine-dbus/hippo-dbus-empathy.h	(revision 7287)
+++ engine-dbus/hippo-dbus-empathy.h	(working copy)
@@ -6,7 +6,7 @@
 
 G_BEGIN_DECLS
 
-void hippo_dbus_init_empathy();
+void hippo_dbus_init_empathy(void);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]