[Telepathy-commits] [telepathy-gabble/master] re-implement buddy view features to the generic view object

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:19 PDT 2008


20080605155006-7fe3f-078a07e5b7a64e2d5d7709161b2fff296f18142e.gz
---
 src/Makefile.am                         |    6 +-
 src/conn-olpc.c                         |   73 +++---
 src/connection.c                        |    3 +-
 src/connection.h                        |    3 +-
 src/olpc-buddy-view.c                   |  439 -----------------------------
 src/olpc-buddy-view.h                   |   86 ------
 src/olpc-view.c                         |  462 +++++++++++++++++++++++++++++++
 src/olpc-view.h                         |   87 ++++++
 tests/twisted/olpc/olpc-buddy-search.py |   38 ++--
 9 files changed, 604 insertions(+), 593 deletions(-)
 delete mode 100644 src/olpc-buddy-view.c
 delete mode 100644 src/olpc-buddy-view.h
 create mode 100644 src/olpc-view.c
 create mode 100644 src/olpc-view.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 2bfe224..10b0760 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,10 +76,8 @@ libgabble_convenience_la_our_sources = \
     muc-factory.h \
     muc-factory.c \
     namespaces.h \
-    olpc-buddy-view.h \
-    olpc-buddy-view.c \
-    olpc-activity-view.h \
-    olpc-activity-view.c \
+    olpc-view.h \
+    olpc-view.c \
     pubsub.h \
     pubsub.c \
     presence.h \
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index f492c00..31a90a6 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -36,8 +36,7 @@
 #include "pubsub.h"
 #include "disco.h"
 #include "util.h"
-#include "olpc-buddy-view.h"
-#include "olpc-activity-view.h"
+#include "olpc-view.h"
 
 #define ACTIVITY_PAIR_TYPE \
     dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, \
@@ -532,24 +531,24 @@ find_view_having_properties_for_buddy (gpointer id,
                                        gpointer value,
                                        gpointer buddy)
 {
-  GabbleOlpcBuddyView *view = GABBLE_OLPC_BUDDY_VIEW (value);
+  GabbleOlpcView *view = GABBLE_OLPC_VIEW (value);
   TpHandle handle = GPOINTER_TO_UINT (buddy);
 
-  return gabble_olpc_buddy_view_get_properties (view, handle) != NULL;
+  return gabble_olpc_view_get_buddy_properties (view, handle) != NULL;
 }
 
 static GHashTable *
 find_buddy_properties_from_views (GabbleConnection *conn,
                                   TpHandle buddy)
 {
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
-  view = g_hash_table_find (conn->olpc_buddy_views,
+  view = g_hash_table_find (conn->olpc_views,
       find_view_having_properties_for_buddy, GUINT_TO_POINTER (buddy));
   if (view == NULL)
     return NULL;
 
-  return gabble_olpc_buddy_view_get_properties (view, buddy);
+  return gabble_olpc_view_get_buddy_properties (view, buddy);
 }
 
 static void
@@ -2932,7 +2931,7 @@ activity_changed (GabbleConnection *conn,
 
 static gboolean
 add_buddies_to_view_from_node (GabbleConnection *conn,
-                               GabbleOlpcBuddyView *view,
+                               GabbleOlpcView *view,
                                LmMessageNode *node)
 {
   GArray *buddies;
@@ -2987,7 +2986,7 @@ add_buddies_to_view_from_node (GabbleConnection *conn,
     }
 
   /* FIXME: we should update properties when needed */
-  gabble_olpc_buddy_view_add_buddies (view, buddies, buddies_properties);
+  gabble_olpc_view_add_buddies (view, buddies, buddies_properties);
 
   for (i = 0; i < buddies->len; i++)
     tp_handle_unref (contact_repo, g_array_index (buddies, TpHandle, i));
@@ -3005,14 +3004,14 @@ buddy_added (GabbleConnection *conn,
 {
   const gchar *id_str;
   guint id;
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
   id_str = lm_message_node_get_attribute (added, "id");
   if (id_str == NULL)
     return;
 
   id = strtoul (id_str, NULL, 10);
-  view = g_hash_table_lookup (conn->olpc_buddy_views, GUINT_TO_POINTER (id));
+  view = g_hash_table_lookup (conn->olpc_views, GUINT_TO_POINTER (id));
   if (view == NULL)
     {
       DEBUG ("no buddy view with ID %u", id);
@@ -3024,7 +3023,7 @@ buddy_added (GabbleConnection *conn,
 
 static gboolean
 remove_buddies_from_view_from_node (GabbleConnection *conn,
-                                    GabbleOlpcBuddyView *view,
+                                    GabbleOlpcView *view,
                                     LmMessageNode *node)
 {
   TpHandleSet *buddies;
@@ -3057,7 +3056,7 @@ remove_buddies_from_view_from_node (GabbleConnection *conn,
       tp_handle_unref (contact_repo, handle);
     }
 
-  gabble_olpc_buddy_view_remove_buddies (view, buddies);
+  gabble_olpc_view_remove_buddies (view, buddies);
   tp_handle_set_destroy (buddies);
 
   return TRUE;
@@ -3069,14 +3068,14 @@ buddy_removed (GabbleConnection *conn,
 {
   const gchar *id_str;
   guint id;
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
   id_str = lm_message_node_get_attribute (removed, "id");
   if (id_str == NULL)
     return;
 
   id = strtoul (id_str, NULL, 10);
-  view = g_hash_table_lookup (conn->olpc_buddy_views, GUINT_TO_POINTER (id));
+  view = g_hash_table_lookup (conn->olpc_views, GUINT_TO_POINTER (id));
   if (view == NULL)
     {
       DEBUG ("no buddy view with ID %u", id);
@@ -3174,23 +3173,13 @@ conn_olpc_activity_properties_init (GabbleConnection *conn)
   conn->olpc_invited_activities = g_hash_table_new_full (g_direct_hash,
       g_direct_equal, NULL, (GDestroyNotify) tp_handle_set_destroy);
 
-  /* Active buddy views
+  /* Active views
    *
-   * view id guint => GabbleOlpcBuddyView
+   * view id guint => GabbleOlpcView
    */
-  conn->olpc_buddy_views = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+  conn->olpc_views = g_hash_table_new_full (g_direct_hash, g_direct_equal,
       NULL, (GDestroyNotify) g_object_unref);
 
-  /* Active activities views
-   *
-   * view id guint => GabbleOlpcActivityView
-   *
-   * Each activity in the view represents a reference
-   * to an ActivityInfo
-   */
-  conn->olpc_activity_views = g_hash_table_new_full (g_direct_hash,
-      g_direct_equal, NULL, (GDestroyNotify) g_object_unref);
-
   conn->olpc_gadget_buddy = NULL;
   conn->olpc_gadget_activity = NULL;
 
@@ -3218,24 +3207,24 @@ olpc_activity_properties_iface_init (gpointer g_iface,
 }
 
 static void
-buddy_view_closed_cb (GabbleOlpcBuddyView *view,
+buddy_view_closed_cb (GabbleOlpcView *view,
                       GabbleConnection *conn)
 {
   guint id;
 
   g_object_get (view, "id", &id, NULL);
-  g_hash_table_remove (conn->olpc_buddy_views, GUINT_TO_POINTER (id));
+  g_hash_table_remove (conn->olpc_views, GUINT_TO_POINTER (id));
 }
 
-static GabbleOlpcBuddyView *
+static GabbleOlpcView *
 create_buddy_view (GabbleConnection *conn)
 {
   guint id;
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
   /* Look for a free ID */
   for (id = 0; id < G_MAXUINT &&
-      g_hash_table_lookup (conn->olpc_buddy_views, GUINT_TO_POINTER (id))
+      g_hash_table_lookup (conn->olpc_views, GUINT_TO_POINTER (id))
       != NULL; id++);
 
   if (id == G_MAXUINT)
@@ -3244,8 +3233,8 @@ create_buddy_view (GabbleConnection *conn)
       return NULL;
     }
 
-  view = gabble_olpc_buddy_view_new (conn, id);
-  g_hash_table_insert (conn->olpc_buddy_views, GUINT_TO_POINTER (id), view);
+  view = gabble_olpc_view_new (conn, GABBLE_OLPC_VIEW_TYPE_BUDDY, id);
+  g_hash_table_insert (conn->olpc_views, GUINT_TO_POINTER (id), view);
 
   g_signal_connect (view, "closed", G_CALLBACK (buddy_view_closed_cb), conn);
 
@@ -3260,7 +3249,7 @@ buddy_query_result_cb (GabbleConnection *conn,
                        gpointer user_data)
 {
   LmMessageNode *view_node;
-  GabbleOlpcBuddyView *view = GABBLE_OLPC_BUDDY_VIEW (_view);
+  GabbleOlpcView *view = GABBLE_OLPC_VIEW (_view);
 
   view_node = lm_message_node_get_child_with_namespace (reply_msg->node, "view",
       NS_OLPC_BUDDY);
@@ -3282,7 +3271,7 @@ olpc_gadget_request_random_buddies (GabbleSvcOLPCGadget *iface,
   gchar *max_str, *id_str;
   gchar *object_path;
   guint id;
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
   if (!check_gadget_buddy (conn, context))
     return;
@@ -3361,7 +3350,7 @@ olpc_gadget_search_buddies_by_properties (GabbleSvcOLPCGadget *iface,
   gchar *id_str;
   gchar *object_path;
   guint id;
-  GabbleOlpcBuddyView *view;
+  GabbleOlpcView *view;
 
   if (!check_gadget_buddy (conn, context))
     return;
@@ -3423,6 +3412,7 @@ olpc_gadget_search_buddies_by_properties (GabbleSvcOLPCGadget *iface,
   lm_message_unref (query);
 }
 
+#if 0
 static LmHandlerResult
 activity_query_result_cb (GabbleConnection *conn,
                           LmMessage *sent_msg,
@@ -3767,6 +3757,7 @@ olpc_gadget_search_activities_by_participants (GabbleSvcOLPCGadget *iface,
   g_free (object_path);
   lm_message_unref (query);
 }
+#endif
 
 static gboolean
 send_presence_to_gadget (GabbleConnection *conn,
@@ -3840,9 +3831,9 @@ olpc_gadget_iface_init (gpointer g_iface,
     klass, olpc_gadget_##x)
   IMPLEMENT(request_random_buddies);
   IMPLEMENT(search_buddies_by_properties);
-  IMPLEMENT(request_random_activities);
-  IMPLEMENT(search_activities_by_properties);
-  IMPLEMENT(search_activities_by_participants);
+  //IMPLEMENT(request_random_activities);
+  //IMPLEMENT(search_activities_by_properties);
+  //IMPLEMENT(search_activities_by_participants);
   IMPLEMENT(publish);
 #undef IMPLEMENT
 }
diff --git a/src/connection.c b/src/connection.c
index 56f58a8..fb2750b 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -755,8 +755,7 @@ gabble_connection_dispose (GObject *object)
   g_hash_table_destroy (self->olpc_activities_info);
   g_hash_table_destroy (self->olpc_pep_activities);
   g_hash_table_destroy (self->olpc_invited_activities);
-  g_hash_table_destroy (self->olpc_buddy_views);
-  g_hash_table_destroy (self->olpc_activity_views);
+  g_hash_table_destroy (self->olpc_views);
 
   g_hash_table_destroy (self->avatar_requests);
 
diff --git a/src/connection.h b/src/connection.h
index 405d83b..41c6ea5 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -140,8 +140,7 @@ struct _GabbleConnection {
     GHashTable *olpc_activities_info;
     GHashTable *olpc_pep_activities;
     GHashTable *olpc_invited_activities;
-    GHashTable *olpc_buddy_views;
-    GHashTable *olpc_activity_views;
+    GHashTable *olpc_views;
 
     /* OLPC services */
     const gchar *olpc_gadget_buddy;
diff --git a/src/olpc-buddy-view.c b/src/olpc-buddy-view.c
deleted file mode 100644
index a99aabc..0000000
--- a/src/olpc-buddy-view.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * olpc-buddy-view.c - Source for GabbleOlpcBuddyView
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "olpc-buddy-view.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <loudmouth/loudmouth.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/group-mixin.h>
-
-#define DEBUG_FLAG GABBLE_DEBUG_OLPC
-
-#include "debug.h"
-#include "extensions/extensions.h"
-#include "gabble-connection.h"
-#include "gabble-signals-marshal.h"
-#include "namespaces.h"
-#include "util.h"
-
-/* signals */
-enum
-{
-  CLOSED,
-  LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-/* properties */
-enum
-{
-  PROP_CONNECTION = 1,
-  PROP_OBJECT_PATH,
-  PROP_ID,
-  LAST_PROPERTY
-};
-
-typedef struct _GabbleOlpcBuddyViewPrivate GabbleOlpcBuddyViewPrivate;
-struct _GabbleOlpcBuddyViewPrivate
-{
-  GabbleConnection *conn;
-  char *object_path;
-  guint id;
-
-  /* TpHandle => GHashTable * */
-  GHashTable *buddy_properties;
-
-  gboolean dispose_has_run;
-};
-
-static void buddy_view_iface_init (gpointer, gpointer);
-
-G_DEFINE_TYPE_WITH_CODE (
-    GabbleOlpcBuddyView, gabble_olpc_buddy_view, G_TYPE_OBJECT,
-    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_OLPC_BUDDY_VIEW,
-      buddy_view_iface_init);
-    G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP,
-      tp_group_mixin_iface_init));
-
-#define GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE(obj) \
-    ((GabbleOlpcBuddyViewPrivate *) obj->priv)
-
-
-static void
-gabble_olpc_buddy_view_init (GabbleOlpcBuddyView *self)
-{
-  GabbleOlpcBuddyViewPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
-      GABBLE_TYPE_OLPC_BUDDY_VIEW, GabbleOlpcBuddyViewPrivate);
-
-  self->priv = priv;
-
-  priv->buddy_properties = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-      NULL, (GDestroyNotify) g_hash_table_unref);
-
-  priv->dispose_has_run = FALSE;
-}
-
-static void
-gabble_olpc_buddy_view_dispose (GObject *object)
-{
-  GabbleOlpcBuddyView *self = GABBLE_OLPC_BUDDY_VIEW (object);
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  if (priv->dispose_has_run)
-    return;
-
-  if (priv->buddy_properties != NULL)
-    {
-      g_hash_table_destroy (priv->buddy_properties);
-      priv->buddy_properties = NULL;
-    }
-
-  priv->dispose_has_run = TRUE;
-
-  if (G_OBJECT_CLASS (gabble_olpc_buddy_view_parent_class)->dispose)
-    G_OBJECT_CLASS (gabble_olpc_buddy_view_parent_class)->dispose (object);
-}
-
-static void
-gabble_olpc_buddy_view_finalize (GObject *object)
-{
-  GabbleOlpcBuddyView *self = GABBLE_OLPC_BUDDY_VIEW (object);
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  g_free (priv->object_path);
-
-  tp_group_mixin_finalize (object);
-
-  G_OBJECT_CLASS (gabble_olpc_buddy_view_parent_class)->finalize (object);
-}
-
-static void
-gabble_olpc_buddy_view_get_property (GObject *object,
-                                     guint property_id,
-                                     GValue *value,
-                                     GParamSpec *pspec)
-{
-  GabbleOlpcBuddyView *self = GABBLE_OLPC_BUDDY_VIEW (object);
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  switch (property_id)
-    {
-      case PROP_CONNECTION:
-        g_value_set_object (value, priv->conn);
-        break;
-      case PROP_OBJECT_PATH:
-        g_value_set_string (value, priv->object_path);
-        break;
-      case PROP_ID:
-        g_value_set_uint (value, priv->id);
-        break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-        break;
-    }
-}
-
-static void
-gabble_olpc_buddy_view_set_property (GObject *object,
-                                     guint property_id,
-                                     const GValue *value,
-                                     GParamSpec *pspec)
-{
-  GabbleOlpcBuddyView *self = GABBLE_OLPC_BUDDY_VIEW (object);
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  switch (property_id)
-    {
-      case PROP_CONNECTION:
-        priv->conn = g_value_get_object (value);
-        break;
-      case PROP_ID:
-        priv->id = g_value_get_uint (value);
-        break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-        break;
-    }
-}
-
-static GObject *
-gabble_olpc_buddy_view_constructor (GType type,
-                                    guint n_props,
-                                    GObjectConstructParam *props)
-{
-  GObject *obj;
-  GabbleOlpcBuddyViewPrivate *priv;
-  DBusGConnection *bus;
-  TpBaseConnection *conn;
-  TpHandleRepoIface *contact_handles;
-
-  obj = G_OBJECT_CLASS (gabble_olpc_buddy_view_parent_class)->
-           constructor (type, n_props, props);
-
-  priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (GABBLE_OLPC_BUDDY_VIEW (obj));
-  conn = (TpBaseConnection *)priv->conn;
-
-  priv->object_path = g_strdup_printf ("%s/OlpcBuddyView%u",
-      conn->object_path, priv->id);
-  bus = tp_get_bus ();
-  dbus_g_connection_register_g_object (bus, priv->object_path, obj);
-
-  contact_handles = tp_base_connection_get_handles (conn,
-      TP_HANDLE_TYPE_CONTACT);
-  /* initialize group mixin */
-  tp_group_mixin_init (obj, G_STRUCT_OFFSET (GabbleOlpcBuddyView, group),
-      contact_handles, 0);
-
-  /* set initial group flags */
-  tp_group_mixin_change_flags (obj, 0, 0);
-
-  return obj;
-}
-
-static gboolean
-view_add_member (GObject *obj,
-                 TpHandle handle,
-                 const gchar *message,
-                 GError **error)
-{
-  /* this function is never supposed to be called */
-  g_return_val_if_reached (TRUE);
-}
-
-static void
-gabble_olpc_buddy_view_class_init (GabbleOlpcBuddyViewClass *gabble_olpc_buddy_view_class)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (gabble_olpc_buddy_view_class);
-  GParamSpec *param_spec;
-
-  object_class->get_property = gabble_olpc_buddy_view_get_property;
-  object_class->set_property = gabble_olpc_buddy_view_set_property;
-  object_class->constructor = gabble_olpc_buddy_view_constructor;
-
-  g_type_class_add_private (gabble_olpc_buddy_view_class,
-      sizeof (GabbleOlpcBuddyViewPrivate));
-
-  object_class->dispose = gabble_olpc_buddy_view_dispose;
-  object_class->finalize = gabble_olpc_buddy_view_finalize;
-
-   param_spec = g_param_spec_object (
-      "connection",
-      "GabbleConnection object",
-      "Gabble connection object that owns this view object.",
-      GABBLE_TYPE_CONNECTION,
-      G_PARAM_CONSTRUCT_ONLY |
-      G_PARAM_READWRITE |
-      G_PARAM_STATIC_NAME |
-      G_PARAM_STATIC_NICK |
-      G_PARAM_STATIC_BLURB);
-  g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
-
-  param_spec = g_param_spec_string (
-      "object-path",
-      "D-Bus object path",
-      "The D-Bus object path of this view object",
-      NULL,
-      G_PARAM_READABLE |
-      G_PARAM_STATIC_NAME |
-      G_PARAM_STATIC_NICK |
-      G_PARAM_STATIC_BLURB);
-  g_object_class_install_property (object_class, PROP_OBJECT_PATH, param_spec);
-
-  param_spec = g_param_spec_uint (
-      "id",
-      "query ID",
-      "The ID of the query associated with this view",
-      0, G_MAXUINT, 0,
-      G_PARAM_CONSTRUCT_ONLY |
-      G_PARAM_READWRITE |
-      G_PARAM_STATIC_NAME |
-      G_PARAM_STATIC_NICK |
-      G_PARAM_STATIC_BLURB);
-  g_object_class_install_property (object_class, PROP_ID, param_spec);
-
-  signals[CLOSED] =
-    g_signal_new ("closed",
-        G_OBJECT_CLASS_TYPE (gabble_olpc_buddy_view_class),
-        G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-        0,
-        NULL, NULL,
-        gabble_marshal_VOID__VOID,
-        G_TYPE_NONE, 0);
-
-  tp_group_mixin_class_init (object_class,
-      G_STRUCT_OFFSET (GabbleOlpcBuddyViewClass, group_class),
-      view_add_member, NULL);
-}
-
-GabbleOlpcBuddyView *
-gabble_olpc_buddy_view_new (GabbleConnection *conn,
-                            guint id)
-{
-  return g_object_new (GABBLE_TYPE_OLPC_BUDDY_VIEW,
-      "connection", conn,
-      "id", id,
-      NULL);
-}
-
-static void
-olpc_buddy_view_close (GabbleSvcOLPCBuddyView *iface,
-                       DBusGMethodInvocation *context)
-{
-  GabbleOlpcBuddyView *self = GABBLE_OLPC_BUDDY_VIEW (iface);
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-  LmMessage *msg;
-  gchar *id_str;
-  GError *error = NULL;
-
-  id_str = g_strdup_printf ("%u", priv->id);
-
-  msg = lm_message_build (priv->conn->olpc_gadget_buddy,
-      LM_MESSAGE_TYPE_MESSAGE,
-      '(', "close", "",
-        '@', "xmlns", NS_OLPC_BUDDY,
-        '@', "id", id_str,
-      ')', NULL);
-  g_free (id_str);
-
-  if (!_gabble_connection_send (priv->conn, msg, &error))
-    {
-      dbus_g_method_return_error (context, error);
-      lm_message_unref (msg);
-      g_error_free (error);
-      return;
-    }
-
-  gabble_svc_olpc_buddy_view_return_from_close (context);
-
-  lm_message_unref (msg);
-
-  g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
-}
-
-void
-gabble_olpc_buddy_view_add_buddies (GabbleOlpcBuddyView *self,
-                                    GArray *buddies,
-                                    GPtrArray *buddies_properties)
-{
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-  TpIntSet *empty;
-  guint i;
-  TpIntSet *added;
-
-  empty = tp_intset_new ();
-  added = tp_intset_from_array (buddies);
-
-  g_assert (buddies->len == buddies_properties->len);
-
-  /* store properties */
-  for (i = 0; i < buddies->len; i++)
-    {
-      TpHandle handle;
-      GHashTable *properties;
-
-      handle = g_array_index (buddies, TpHandle, i);
-      properties = g_ptr_array_index (buddies_properties, i);
-
-      g_hash_table_insert (priv->buddy_properties, GUINT_TO_POINTER (handle),
-          properties);
-      g_hash_table_ref (properties);
-    }
-
-  tp_group_mixin_change_members (G_OBJECT (self), "",
-      added, empty, empty, empty,
-      0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
-
-  tp_intset_destroy (empty);
-  tp_intset_destroy (added);
-}
-
-static void
-remove_properties_foreach (TpHandleSet *buddies,
-                           TpHandle handle,
-                           GabbleOlpcBuddyView *self)
-{
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  g_hash_table_remove (priv->buddy_properties, GUINT_TO_POINTER (handle));
-}
-
-void
-gabble_olpc_buddy_view_remove_buddies (GabbleOlpcBuddyView *self,
-                                       TpHandleSet *buddies)
-{
-  TpIntSet *empty;
-
-  empty = tp_intset_new ();
-
-  tp_group_mixin_change_members (G_OBJECT (self), "",
-      empty, tp_handle_set_peek (buddies), empty, empty,
-      0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
-
-  tp_handle_set_foreach (buddies,
-      (TpHandleSetMemberFunc) remove_properties_foreach, self);
-
-  tp_intset_destroy (empty);
-}
-
-gboolean
-gabble_olpc_buddy_view_set_properties (GabbleOlpcBuddyView *self,
-                                       TpHandle buddy,
-                                       GHashTable *properties)
-{
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  if (!tp_handle_set_is_member (self->group.members, buddy))
-    {
-      DEBUG ("buddy %d is not member of this view", buddy);
-      return FALSE;
-    }
-
-  g_hash_table_insert (priv->buddy_properties, GUINT_TO_POINTER (buddy),
-      properties);
-  g_hash_table_ref (properties);
-
-  return TRUE;
-}
-
-GHashTable *
-gabble_olpc_buddy_view_get_properties (GabbleOlpcBuddyView *self,
-                                       TpHandle buddy)
-{
-  GabbleOlpcBuddyViewPrivate *priv = GABBLE_OLPC_BUDDY_VIEW_GET_PRIVATE (self);
-
-  return g_hash_table_lookup (priv->buddy_properties, GUINT_TO_POINTER (buddy));
-}
-
-static void
-buddy_view_iface_init (gpointer g_iface,
-                       gpointer iface_data)
-{
-  GabbleSvcOLPCBuddyViewClass *klass = g_iface;
-
-#define IMPLEMENT(x) gabble_svc_olpc_buddy_view_implement_##x (\
-    klass, olpc_buddy_view_##x)
-  IMPLEMENT(close);
-#undef IMPLEMENT
-}
diff --git a/src/olpc-buddy-view.h b/src/olpc-buddy-view.h
deleted file mode 100644
index ee34317..0000000
--- a/src/olpc-buddy-view.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * olpc-buddy-view.h - Header for GabbleOlpcBuddyView
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GABBLE_OLPC_BUDDY_VIEW_H__
-#define __GABBLE_OLPC_BUDDY_VIEW_H__
-
-#include <glib-object.h>
-
-#include <telepathy-glib/group-mixin.h>
-#include <telepathy-glib/enums.h>
-#include <telepathy-glib/handle-repo.h>
-
-#include "gabble-connection.h"
-
-G_BEGIN_DECLS
-
-typedef struct _GabbleOlpcBuddyView GabbleOlpcBuddyView;
-typedef struct _GabbleOlpcBuddyViewClass GabbleOlpcBuddyViewClass;
-
-struct _GabbleOlpcBuddyViewClass {
-  GObjectClass parent_class;
-
-  TpGroupMixinClass group_class;
-};
-
-struct _GabbleOlpcBuddyView {
-  GObject parent;
-
-  TpGroupMixin group;
-
-  gpointer priv;
-};
-
-GType gabble_olpc_buddy_view_get_type (void);
-
-/* TYPE MACROS */
-#define GABBLE_TYPE_OLPC_BUDDY_VIEW \
-  (gabble_olpc_buddy_view_get_type ())
-#define GABBLE_OLPC_BUDDY_VIEW(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_OLPC_BUDDY_VIEW, GabbleOlpcBuddyView))
-#define GABBLE_OLPC_BUDDY_VIEW_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_OLPC_BUDDY_VIEW,\
-                           GabbleOlpcBuddyViewClass))
-#define GABBLE_IS_OLPC_BUDDY_VIEW(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_OLPC_BUDDY_VIEW))
-#define GABBLE_IS_OLPC_BUDDY_VIEW_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_OLPC_BUDDY_VIEW))
-#define GABBLE_OLPC_BUDDY_VIEW_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_OLPC_BUDDY_VIEW,\
-                              GabbleOlpcBuddyViewClass))
-
-GabbleOlpcBuddyView * gabble_olpc_buddy_view_new (GabbleConnection *conn,
-    guint id);
-
-void gabble_olpc_buddy_view_add_buddies (GabbleOlpcBuddyView *self,
-    GArray *handles, GPtrArray *buddies_properties);
-
-
-void gabble_olpc_buddy_view_remove_buddies (GabbleOlpcBuddyView *self,
-    TpHandleSet *handles);
-
-gboolean gabble_olpc_buddy_view_set_properties (GabbleOlpcBuddyView *self,
-    TpHandle buddy, GHashTable *properties);
-
-GHashTable * gabble_olpc_buddy_view_get_properties (GabbleOlpcBuddyView *self,
-    TpHandle buddy);
-
-G_END_DECLS
-
-#endif /* #ifndef __GABBLE_OLPC_BUDDY_VIEW_H__ */
diff --git a/src/olpc-view.c b/src/olpc-view.c
new file mode 100644
index 0000000..6836888
--- /dev/null
+++ b/src/olpc-view.c
@@ -0,0 +1,462 @@
+/*
+ * olpc-buddy-view.c - Source for GabbleOlpcView
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "olpc-view.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <loudmouth/loudmouth.h>
+#include <telepathy-glib/dbus.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_OLPC
+
+#include "debug.h"
+#include "extensions/extensions.h"
+#include "gabble-connection.h"
+#include "gabble-signals-marshal.h"
+#include "namespaces.h"
+#include "util.h"
+
+/* signals */
+enum
+{
+  CLOSED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+/* properties */
+enum
+{
+  PROP_CONNECTION = 1,
+  PROP_TYPE,
+  PROP_OBJECT_PATH,
+  PROP_ID,
+  LAST_PROPERTY
+};
+
+typedef struct _GabbleOlpcViewPrivate GabbleOlpcViewPrivate;
+struct _GabbleOlpcViewPrivate
+{
+  GabbleConnection *conn;
+  /* FIXME: subclass instead of using a type attribute ? */
+  GabbleOlpcViewType type;
+  char *object_path;
+  guint id;
+
+  TpHandleSet *buddies;
+
+  /* TpHandle (owned in priv->buddies) => GHashTable * */
+  GHashTable *buddy_properties;
+
+  gboolean dispose_has_run;
+};
+
+static void view_iface_init (gpointer, gpointer);
+
+G_DEFINE_TYPE_WITH_CODE (
+    GabbleOlpcView, gabble_olpc_view, G_TYPE_OBJECT,
+    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_OLPC_VIEW,
+      view_iface_init));
+
+#define GABBLE_OLPC_VIEW_GET_PRIVATE(obj) \
+    ((GabbleOlpcViewPrivate *) obj->priv)
+
+
+static void
+gabble_olpc_view_init (GabbleOlpcView *self)
+{
+  GabbleOlpcViewPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      GABBLE_TYPE_OLPC_VIEW, GabbleOlpcViewPrivate);
+
+  self->priv = priv;
+
+  priv->buddy_properties = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+      NULL, (GDestroyNotify) g_hash_table_unref);
+
+  priv->dispose_has_run = FALSE;
+}
+
+static void
+gabble_olpc_view_dispose (GObject *object)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (object);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  if (priv->dispose_has_run)
+    return;
+
+  if (priv->buddies != NULL)
+    {
+      tp_handle_set_destroy (priv->buddies);
+      priv->buddies = NULL;
+    }
+
+  if (priv->buddy_properties != NULL)
+    {
+      g_hash_table_destroy (priv->buddy_properties);
+      priv->buddy_properties = NULL;
+    }
+
+  priv->dispose_has_run = TRUE;
+
+  if (G_OBJECT_CLASS (gabble_olpc_view_parent_class)->dispose)
+    G_OBJECT_CLASS (gabble_olpc_view_parent_class)->dispose (object);
+}
+
+static void
+gabble_olpc_view_finalize (GObject *object)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (object);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  g_free (priv->object_path);
+
+  G_OBJECT_CLASS (gabble_olpc_view_parent_class)->finalize (object);
+}
+
+static void
+gabble_olpc_view_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (object);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  switch (property_id)
+    {
+      case PROP_CONNECTION:
+        g_value_set_object (value, priv->conn);
+        break;
+      case PROP_TYPE:
+        g_value_set_uint (value, priv->type);
+        break;
+      case PROP_OBJECT_PATH:
+        g_value_set_string (value, priv->object_path);
+        break;
+      case PROP_ID:
+        g_value_set_uint (value, priv->id);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+gabble_olpc_view_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (object);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  switch (property_id)
+    {
+      case PROP_CONNECTION:
+        priv->conn = g_value_get_object (value);
+        break;
+      case PROP_TYPE:
+        priv->type = g_value_get_uint (value);
+        break;
+      case PROP_ID:
+        priv->id = g_value_get_uint (value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static GObject *
+gabble_olpc_view_constructor (GType type,
+                              guint n_props,
+                              GObjectConstructParam *props)
+{
+  GObject *obj;
+  GabbleOlpcViewPrivate *priv;
+  DBusGConnection *bus;
+  TpBaseConnection *conn;
+  TpHandleRepoIface *contact_handles;
+
+  obj = G_OBJECT_CLASS (gabble_olpc_view_parent_class)->
+           constructor (type, n_props, props);
+
+  priv = GABBLE_OLPC_VIEW_GET_PRIVATE (GABBLE_OLPC_VIEW (obj));
+  conn = (TpBaseConnection *)priv->conn;
+
+  priv->object_path = g_strdup_printf ("%s/OlpcView%u",
+      conn->object_path, priv->id);
+  bus = tp_get_bus ();
+  dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+  contact_handles = tp_base_connection_get_handles (conn,
+      TP_HANDLE_TYPE_CONTACT);
+
+  priv->buddies = tp_handle_set_new (contact_handles);
+
+  return obj;
+}
+
+static void
+gabble_olpc_view_class_init (GabbleOlpcViewClass *gabble_olpc_view_class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (gabble_olpc_view_class);
+  GParamSpec *param_spec;
+
+  object_class->get_property = gabble_olpc_view_get_property;
+  object_class->set_property = gabble_olpc_view_set_property;
+  object_class->constructor = gabble_olpc_view_constructor;
+
+  g_type_class_add_private (gabble_olpc_view_class,
+      sizeof (GabbleOlpcViewPrivate));
+
+  object_class->dispose = gabble_olpc_view_dispose;
+  object_class->finalize = gabble_olpc_view_finalize;
+
+   param_spec = g_param_spec_object (
+      "connection",
+      "GabbleConnection object",
+      "Gabble connection object that owns this view object.",
+      GABBLE_TYPE_CONNECTION,
+      G_PARAM_CONSTRUCT_ONLY |
+      G_PARAM_READWRITE |
+      G_PARAM_STATIC_NAME |
+      G_PARAM_STATIC_NICK |
+      G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+  param_spec = g_param_spec_uint (
+      "type",
+      "view type",
+      "the type of query who creates this view object. A GabbleOlpcViewType",
+      GABBLE_OLPC_VIEW_TYPE_BUDDY, NUM_GABBLE_OLPC_VIEW_TYPE -1,
+      GABBLE_OLPC_VIEW_TYPE_BUDDY,
+      G_PARAM_CONSTRUCT_ONLY |
+      G_PARAM_READWRITE |
+      G_PARAM_STATIC_NAME |
+      G_PARAM_STATIC_NICK |
+      G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_TYPE, param_spec);
+
+  param_spec = g_param_spec_string (
+      "object-path",
+      "D-Bus object path",
+      "The D-Bus object path of this view object",
+      NULL,
+      G_PARAM_READABLE |
+      G_PARAM_STATIC_NAME |
+      G_PARAM_STATIC_NICK |
+      G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_OBJECT_PATH, param_spec);
+
+  param_spec = g_param_spec_uint (
+      "id",
+      "query ID",
+      "The ID of the query associated with this view",
+      0, G_MAXUINT, 0,
+      G_PARAM_CONSTRUCT_ONLY |
+      G_PARAM_READWRITE |
+      G_PARAM_STATIC_NAME |
+      G_PARAM_STATIC_NICK |
+      G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_ID, param_spec);
+
+  signals[CLOSED] =
+    g_signal_new ("closed",
+        G_OBJECT_CLASS_TYPE (gabble_olpc_view_class),
+        G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+        0,
+        NULL, NULL,
+        gabble_marshal_VOID__VOID,
+        G_TYPE_NONE, 0);
+}
+
+GabbleOlpcView *
+gabble_olpc_view_new (GabbleConnection *conn,
+                      GabbleOlpcViewType type,
+                      guint id)
+{
+  return g_object_new (GABBLE_TYPE_OLPC_VIEW,
+      "connection", conn,
+      "type", type,
+      "id", id,
+      NULL);
+}
+
+static void
+olpc_view_get_buddies (GabbleSvcOLPCView *iface,
+                       DBusGMethodInvocation *context)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (iface);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+  GArray *buddies;
+
+  buddies = tp_handle_set_to_array (priv->buddies);
+
+  gabble_svc_olpc_view_return_from_get_buddies (context, buddies);
+
+  g_array_free (buddies, TRUE);
+}
+
+static void
+olpc_view_close (GabbleSvcOLPCView *iface,
+                 DBusGMethodInvocation *context)
+{
+  GabbleOlpcView *self = GABBLE_OLPC_VIEW (iface);
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+  LmMessage *msg;
+  gchar *id_str;
+  GError *error = NULL;
+
+  id_str = g_strdup_printf ("%u", priv->id);
+
+  msg = lm_message_build (priv->conn->olpc_gadget_buddy,
+      LM_MESSAGE_TYPE_MESSAGE,
+      '(', "close", "",
+        '@', "xmlns", NS_OLPC_BUDDY,
+        '@', "id", id_str,
+      ')', NULL);
+  g_free (id_str);
+
+  if (!_gabble_connection_send (priv->conn, msg, &error))
+    {
+      dbus_g_method_return_error (context, error);
+      lm_message_unref (msg);
+      g_error_free (error);
+      return;
+    }
+
+  gabble_svc_olpc_view_return_from_close (context);
+
+  lm_message_unref (msg);
+
+  g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
+}
+
+void
+gabble_olpc_view_add_buddies (GabbleOlpcView *self,
+                              GArray *buddies,
+                              GPtrArray *buddies_properties)
+{
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+  guint i;
+  GArray *empty;
+
+  g_assert (buddies->len == buddies_properties->len);
+
+  empty = g_array_new (FALSE, FALSE, sizeof(TpHandle));
+
+  /* store properties */
+  for (i = 0; i < buddies->len; i++)
+    {
+      TpHandle handle;
+      GHashTable *properties;
+
+      handle = g_array_index (buddies, TpHandle, i);
+      properties = g_ptr_array_index (buddies_properties, i);
+
+      tp_handle_set_add (priv->buddies, handle);
+      g_hash_table_insert (priv->buddy_properties, GUINT_TO_POINTER (handle),
+          properties);
+      g_hash_table_ref (properties);
+    }
+
+  gabble_svc_olpc_view_emit_buddies_changed (self, buddies, empty);
+
+  g_array_free (empty, TRUE);
+}
+
+static void
+remove_properties_foreach (TpHandleSet *buddies,
+                           TpHandle handle,
+                           GabbleOlpcView *self)
+{
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  tp_handle_set_remove (priv->buddies, handle);
+  g_hash_table_remove (priv->buddy_properties, GUINT_TO_POINTER (handle));
+}
+
+void
+gabble_olpc_view_remove_buddies (GabbleOlpcView *self,
+                                 TpHandleSet *buddies)
+{
+  GArray *removed, *empty;
+
+  tp_handle_set_foreach (buddies,
+      (TpHandleSetMemberFunc) remove_properties_foreach, self);
+
+  empty = g_array_new (FALSE, FALSE, sizeof(TpHandle));
+  removed = tp_handle_set_to_array (buddies);
+
+  gabble_svc_olpc_view_emit_buddies_changed (self, empty, removed);
+
+  g_array_free (empty, TRUE);
+  g_array_free (removed, TRUE);
+}
+
+gboolean
+gabble_olpc_view_set_buddy_properties (GabbleOlpcView *self,
+                                       TpHandle buddy,
+                                       GHashTable *properties)
+{
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  if (!tp_handle_set_is_member (priv->buddies, buddy))
+    {
+      DEBUG ("buddy %d is not member of this view", buddy);
+      return FALSE;
+    }
+
+  tp_handle_set_add (priv->buddies, buddy);
+  g_hash_table_insert (priv->buddy_properties, GUINT_TO_POINTER (buddy),
+      properties);
+  g_hash_table_ref (properties);
+
+  return TRUE;
+}
+
+GHashTable *
+gabble_olpc_view_get_buddy_properties (GabbleOlpcView *self,
+                                       TpHandle buddy)
+{
+  GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
+
+  return g_hash_table_lookup (priv->buddy_properties, GUINT_TO_POINTER (buddy));
+}
+
+static void
+view_iface_init (gpointer g_iface,
+                 gpointer iface_data)
+{
+  GabbleSvcOLPCViewClass *klass = g_iface;
+
+#define IMPLEMENT(x) gabble_svc_olpc_view_implement_##x (\
+    klass, olpc_view_##x)
+  IMPLEMENT(get_buddies);
+  IMPLEMENT(close);
+#undef IMPLEMENT
+}
diff --git a/src/olpc-view.h b/src/olpc-view.h
new file mode 100644
index 0000000..ccdc127
--- /dev/null
+++ b/src/olpc-view.h
@@ -0,0 +1,87 @@
+/*
+ * olpc-view.h - Header for GabbleOlpcView
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GABBLE_OLPC_VIEW_H__
+#define __GABBLE_OLPC_VIEW_H__
+
+#include <glib-object.h>
+
+#include <telepathy-glib/enums.h>
+#include <telepathy-glib/handle-repo.h>
+
+#include "gabble-connection.h"
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+  GABBLE_OLPC_VIEW_TYPE_BUDDY,
+  GABBLE_OLPC_VIEW_TYPE_ACTIVITY,
+  NUM_GABBLE_OLPC_VIEW_TYPE
+} GabbleOlpcViewType;
+
+typedef struct _GabbleOlpcView GabbleOlpcView;
+typedef struct _GabbleOlpcViewClass GabbleOlpcViewClass;
+
+struct _GabbleOlpcViewClass {
+  GObjectClass parent_class;
+};
+
+struct _GabbleOlpcView {
+  GObject parent;
+
+  gpointer priv;
+};
+
+GType gabble_olpc_view_get_type (void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_OLPC_VIEW \
+  (gabble_olpc_view_get_type ())
+#define GABBLE_OLPC_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_OLPC_VIEW, GabbleOlpcView))
+#define GABBLE_OLPC_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_OLPC_VIEW,\
+                           GabbleOlpcViewClass))
+#define GABBLE_IS_OLPC_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_OLPC_VIEW))
+#define GABBLE_IS_OLPC_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_OLPC_VIEW))
+#define GABBLE_OLPC_VIEW_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_OLPC_VIEW,\
+                              GabbleOlpcViewClass))
+
+GabbleOlpcView * gabble_olpc_view_new (GabbleConnection *conn,
+    GabbleOlpcViewType type, guint id);
+
+void gabble_olpc_view_add_buddies (GabbleOlpcView *self,
+    GArray *handles, GPtrArray *buddies_properties);
+
+void gabble_olpc_view_remove_buddies (GabbleOlpcView *self,
+    TpHandleSet *handles);
+
+gboolean gabble_olpc_view_set_buddy_properties (GabbleOlpcView *self,
+    TpHandle buddy, GHashTable *properties);
+
+GHashTable * gabble_olpc_view_get_buddy_properties (GabbleOlpcView *self,
+    TpHandle buddy);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_OLPC_VIEW_H__ */
diff --git a/tests/twisted/olpc/olpc-buddy-search.py b/tests/twisted/olpc/olpc-buddy-search.py
index 4dadb5f..1f7f42d 100644
--- a/tests/twisted/olpc/olpc-buddy-search.py
+++ b/tests/twisted/olpc/olpc-buddy-search.py
@@ -143,17 +143,17 @@ def test(q, bus, conn, stream):
 
     view_path = return_event.value[0]
     view0 = bus.get_object(conn.bus_name, view_path)
-    view0_iface = dbus.Interface(view0, 'org.laptop.Telepathy.BuddyView')
-    view0_group_iface = dbus.Interface(view0, 'org.freedesktop.Telepathy.Channel.Interface.Group')
+    view0_iface = dbus.Interface(view0, 'org.laptop.Telepathy.View')
 
-    event = q.expect('dbus-signal', signal='MembersChanged')
-    msg, added, removed, lp, rp, actor, reason = event.args
-    assert (removed, lp, rp) == ([], [], [])
+    event = q.expect('dbus-signal', signal='BuddiesChanged')
+    added, removed = event.args
+    assert removed == []
     assert len(added) == 2
-    handle = added[0]
-    assert conn.InspectHandles(1, [handle])[0] == 'bob at localhost'
+    #assert conn.InspectHandles(1, [handle])[0] == 'bob at localhost'
+    assert sorted(conn.InspectHandles(1, added)) == ['bob at localhost', 'charles at localhost']
 
     # we can now get bob's properties
+    handle = conn.RequestHandles(1, ['bob at localhost'])[0]
     props = buddy_info_iface.GetProperties(handle)
     assert props == {'color': '#005FE4,#00A0FF'}
 
@@ -191,16 +191,16 @@ def test(q, bus, conn, stream):
 
     view_path = return_event.value[0]
     view1 = bus.get_object(conn.bus_name, view_path)
-    view1_iface = dbus.Interface(view1, 'org.laptop.Telepathy.BuddyView')
+    view1_iface = dbus.Interface(view1, 'org.laptop.Telepathy.View')
 
     event = q.expect('dbus-signal', signal='PropertiesChanged')
     handle, props = event.args
     assert conn.InspectHandles(1, [handle])[0] == 'charles at localhost'
     assert props == {'color': '#AABBCC,#001122'}
 
-    event = q.expect('dbus-signal', signal='MembersChanged')
-    msg, added, removed, lp, rp, actor, reason = event.args
-    assert (removed, lp, rp) == ([], [], [])
+    event = q.expect('dbus-signal', signal='BuddiesChanged')
+    added, removed = event.args
+    assert removed == []
     assert len(added) == 1
     handle = added[0]
     assert conn.InspectHandles(1, [handle])[0] == 'charles at localhost'
@@ -226,14 +226,14 @@ def test(q, bus, conn, stream):
     rule['action'] ='error'
     stream.send(message)
 
-    event = q.expect('dbus-signal', signal='MembersChanged')
-    msg, added, removed, lp, rp, actor, reason = event.args
-    assert (removed, lp, rp) == ([], [], [])
+    event = q.expect('dbus-signal', signal='BuddiesChanged')
+    added, removed = event.args
+    assert removed == []
     assert len(added) == 1
     handle = added[0]
     assert conn.InspectHandles(1, added)[0] == 'oscar at localhost'
 
-    members = view0_group_iface.GetMembers()
+    members = view0_iface.GetBuddies()
     members = sorted(conn.InspectHandles(1, members))
     assert sorted(members) == ['bob at localhost', 'charles at localhost',
             'oscar at localhost']
@@ -254,14 +254,14 @@ def test(q, bus, conn, stream):
     rule['action'] ='error'
     stream.send(message)
 
-    event = q.expect('dbus-signal', signal='MembersChanged')
-    msg, added, removed, lp, rp, actor, reason = event.args
-    assert (added, lp, rp) == ([], [], [])
+    event = q.expect('dbus-signal', signal='BuddiesChanged')
+    added, removed = event.args
+    assert added == []
     assert len(removed) == 1
     handle = removed[0]
     assert conn.InspectHandles(1, [handle])[0] == 'bob at localhost'
 
-    members = view0_group_iface.GetMembers()
+    members = view0_iface.GetBuddies()
     members = sorted(conn.InspectHandles(1, members))
     assert sorted(members) == ['charles at localhost', 'oscar at localhost']
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list