desktop-data-model r7288 - trunk/engine-dbus



Author: otaylor
Date: Mon Jun 23 20:06:41 2008
New Revision: 7288
URL: http://svn.gnome.org/viewvc/desktop-data-model?rev=7288&view=rev

Log:
- Use 'xmpp' not 'jabber' for protoocol name for XMPP accounts (patch from Marco)
- Don't register a buddy with the core until we have a id/protocol for it
- Use an URL for the buddy resource ID
- Fix things so empathy id => buddy name, empathy name => buddy alias


Modified:
   trunk/engine-dbus/hippo-dbus-empathy.c
   trunk/engine-dbus/hippo-dbus-empathy.h

Modified: trunk/engine-dbus/hippo-dbus-empathy.c
==============================================================================
--- trunk/engine-dbus/hippo-dbus-empathy.c	(original)
+++ trunk/engine-dbus/hippo-dbus-empathy.c	Mon Jun 23 20:06:41 2008
@@ -1,8 +1,25 @@
 /* -*- 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)
@@ -10,14 +27,23 @@
     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;
 

Modified: trunk/engine-dbus/hippo-dbus-empathy.h
==============================================================================
--- trunk/engine-dbus/hippo-dbus-empathy.h	(original)
+++ trunk/engine-dbus/hippo-dbus-empathy.h	Mon Jun 23 20:06:41 2008
@@ -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]