desktop-data-model r7287 - in trunk: . engine-dbus



Author: marco
Date: Wed May 21 19:42:37 2008
New Revision: 7287
URL: http://svn.gnome.org/viewvc/desktop-data-model?rev=7287&view=rev

Log:
Monitor empathy contacts using libempathy.

Added:
   trunk/engine-dbus/hippo-dbus-empathy.c
   trunk/engine-dbus/hippo-dbus-empathy.h
Modified:
   trunk/Makefile-engine-dbus.am
   trunk/configure.ac
   trunk/engine-dbus/hippo-dbus-server.c

Modified: trunk/Makefile-engine-dbus.am
==============================================================================
--- trunk/Makefile-engine-dbus.am	(original)
+++ trunk/Makefile-engine-dbus.am	Wed May 21 19:42:37 2008
@@ -20,6 +20,8 @@
 	engine-dbus/hippo-dbus-cookies.c		\
 	engine-dbus/hippo-dbus-cookies.h		\
 	engine-dbus/hippo-dbus-helper.c			\
+	engine-dbus/hippo-dbus-empathy.c		\
+	engine-dbus/hippo-dbus-empathy.h		\
 	engine-dbus/hippo-dbus-helper.h			\
 	engine-dbus/hippo-dbus-helper-rename.h		\
 	engine-dbus/hippo-dbus-im-client.c		\

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed May 21 19:42:37 2008
@@ -348,7 +348,7 @@
 PKG_CHECK_MODULES(LIBDDM, gobject-2.0 >= $GLIB2_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED)
 PKG_CHECK_MODULES(LIBHIPPO, gobject-2.0 >= $GLIB2_REQUIRED gthread-2.0)
 PKG_CHECK_MODULES(LIBENGINE, gobject-2.0 >= $GLIB2_REQUIRED gthread-2.0 loudmouth-1.0 >= $LOUDMOUTH_REQUIRED $PCRE_MODULES $SQLITE_MODULES)
-PKG_CHECK_MODULES(DESKTOP_DATA_ENGINE, gtk+-2.0 >= $GTK2_REQUIRED gthread-2.0 loudmouth-1.0 >= $LOUDMOUTH_REQUIRED dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-vfs-2.0 $XSCREENSAVER_PACKAGES $extra_engine_packages)
+PKG_CHECK_MODULES(DESKTOP_DATA_ENGINE, gtk+-2.0 >= $GTK2_REQUIRED gthread-2.0 loudmouth-1.0 >= $LOUDMOUTH_REQUIRED dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-vfs-2.0 $XSCREENSAVER_PACKAGES libempathy $extra_engine_packages)
 
 DESKTOP_DATA_ENGINE_LIBS="$DESKTOP_DATA_ENGINE_LIBS $XSCREENSAVER_LIBS $RESOLV_LIBS"
 DESKTOP_DATA_ENGINE_CFLAGS="$DESKTOP_DATA_ENGINE_CFLAGS $XSCREENSAVER_CFLAGS"

Added: trunk/engine-dbus/hippo-dbus-empathy.c
==============================================================================
--- (empty file)
+++ trunk/engine-dbus/hippo-dbus-empathy.c	Wed May 21 19:42:37 2008
@@ -0,0 +1,90 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+#include <config.h>
+#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-contact-list.h>
+#include "hippo-im.h"
+
+static void
+update_buddy(EmpathyContact *contact)
+{
+    EmpathyAvatar *avatar;
+    McAccount *account;
+    McProfile *profile;
+
+    account = empathy_contact_get_account(contact);
+    profile = mc_account_get_profile(account);
+
+    hippo_im_update_buddy(empathy_contact_get_id(contact),
+                          mc_profile_get_protocol_name(profile),
+                          empathy_contact_get_name(contact),
+                          NULL, /* alias */
+                          empathy_contact_is_online(contact),
+                          empathy_contact_get_status(contact),
+                          empathy_contact_get_presence_message(contact),
+                          NULL /* webdav_url */);
+
+    avatar = empathy_contact_get_avatar(contact);
+    if (avatar != NULL) {
+        hippo_im_update_buddy_icon(empathy_contact_get_id(contact), avatar->format,
+                                   avatar->token, (gchar *)avatar->data, avatar->len);
+    }
+
+    g_object_unref (profile);
+}
+
+static void
+contact_updated_cb (EmpathyContact *contact,
+                    GParamSpec     *param,
+                    gpointer        data)
+{
+    update_buddy(contact);
+}
+
+static void
+contact_list_members_changed_cb (EmpathyContactList *list_iface,
+                                 EmpathyContact     *contact,
+                                 EmpathyContact     *actor,
+                                 guint               reason,
+                                 gchar              *message,
+                                 gboolean            is_member,
+                                 gpointer            data)
+{
+    McAccount *account;
+    McProfile *profile;
+    McPresence presence;
+
+    account = empathy_contact_get_account(contact);
+    profile = mc_account_get_profile(account);
+    presence = empathy_contact_get_presence(contact);
+
+    if (is_member) {
+        update_buddy(contact);
+
+        g_signal_connect(contact, "notify::presence",
+                         G_CALLBACK (contact_updated_cb), NULL);
+        g_signal_connect(contact, "notify::presence-message",
+                         G_CALLBACK (contact_updated_cb), NULL);
+        g_signal_connect(contact, "notify::name",
+                         G_CALLBACK (contact_updated_cb), NULL);
+        g_signal_connect(contact, "notify::avatar",
+                         G_CALLBACK (contact_updated_cb), NULL);
+    } else {
+        g_signal_handlers_disconnect_by_func(contact,
+                                             G_CALLBACK (contact_updated_cb), NULL);
+
+        hippo_im_remove_buddy(empathy_contact_get_id(contact));
+    }
+}
+
+void
+hippo_dbus_init_empathy()
+{
+    EmpathyContactManager *manager;
+
+    manager = empathy_contact_manager_new ();
+
+    g_signal_connect (manager,
+                      "members-changed",
+                      G_CALLBACK (contact_list_members_changed_cb),
+                      NULL);
+}

Added: trunk/engine-dbus/hippo-dbus-empathy.h
==============================================================================
--- (empty file)
+++ trunk/engine-dbus/hippo-dbus-empathy.h	Wed May 21 19:42:37 2008
@@ -0,0 +1,13 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+#ifndef __HIPPO_DBUS_EMPATHY_H__
+#define __HIPPO_DBUS_EMPATHY_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void hippo_dbus_init_empathy();
+
+G_END_DECLS
+
+#endif /* __HIPPO_DBUS_PIDGIN_H__ */

Modified: trunk/engine-dbus/hippo-dbus-server.c
==============================================================================
--- trunk/engine-dbus/hippo-dbus-server.c	(original)
+++ trunk/engine-dbus/hippo-dbus-server.c	Wed May 21 19:42:37 2008
@@ -346,7 +346,8 @@
     hippo_dbus_try_acquire_online_prefs_manager(connection, FALSE);
     
     hippo_dbus_init_local(connection);
-    hippo_dbus_init_pidgin(connection);    
+    hippo_dbus_init_pidgin(connection);
+    hippo_dbus_init_empathy();
     hippo_dbus_init_model(connection);
     
     /* Add Rhythmbox signal match */



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