[Telepathy-commits] [telepathy-gabble/master] Implement ActivityGadgetAvailable and BuddyGadgetAvailable D-Bus properties

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


---
 src/conn-olpc.c                      |   23 +++++++++++++++++++++++
 src/conn-olpc.h                      |    3 +++
 src/connection.c                     |   10 ++++++++++
 tests/twisted/olpc/gadget-publish.py |   15 ++++++++++++++-
 4 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 68e7421..7e69953 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -4432,6 +4432,29 @@ conn_olpc_presence_cb (LmMessageHandler *handler,
 }
 
 void
+conn_olpc_gadget_propeties_getter (GObject *object,
+                                   GQuark interface,
+                                   GQuark name,
+                                   GValue *value,
+                                   gpointer getter_data)
+{
+  GabbleConnection *conn = GABBLE_CONNECTION (object);
+
+  if (!tp_strdiff (g_quark_to_string (name), "ActivityGadgetAvailable"))
+    {
+      g_value_set_boolean (value, check_gadget_activity (conn, NULL));
+    }
+  else if (!tp_strdiff (g_quark_to_string (name), "BuddyGadgetAvailable"))
+    {
+      g_value_set_boolean (value, check_gadget_buddy (conn, NULL));
+    }
+  else
+    {
+      g_assert_not_reached ();
+    }
+}
+
+void
 olpc_gadget_iface_init (gpointer g_iface,
                         gpointer iface_data)
 {
diff --git a/src/conn-olpc.h b/src/conn-olpc.h
index 19428f8..1a020b1 100644
--- a/src/conn-olpc.h
+++ b/src/conn-olpc.h
@@ -64,6 +64,9 @@ LmHandlerResult conn_olpc_msg_cb (LmMessageHandler *handler,
 LmHandlerResult conn_olpc_presence_cb (LmMessageHandler *handler,
     LmConnection *connection, LmMessage *presence, gpointer user_data);
 
+void conn_olpc_gadget_propeties_getter (GObject *object, GQuark interface,
+    GQuark name, GValue *value, gpointer getter_data);
+
 void olpc_gadget_iface_init (gpointer g_iface, gpointer iface_data);
 
 #endif /* __CONN_OLPC_H__ */
diff --git a/src/connection.c b/src/connection.c
index 62d35e1..37e4155 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -511,12 +511,22 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class)
         { "RequestableChannelClasses", NULL, NULL },
         { NULL }
   };
+  static TpDBusPropertiesMixinPropImpl olpc_gadget_props[] = {
+        { "ActivityGadgetAvailable", NULL, NULL },
+        { "BuddyGadgetAvailable", NULL, NULL },
+        { NULL }
+  };
   static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
         { GABBLE_IFACE_CONNECTION_INTERFACE_REQUESTS,
           gabble_conn_requests_get_dbus_property,
           NULL,
           requests_props,
         },
+        { GABBLE_IFACE_OLPC_GADGET,
+          conn_olpc_gadget_propeties_getter,
+          NULL,
+          olpc_gadget_props,
+        },
         { NULL }
   };
   GObjectClass *object_class = G_OBJECT_CLASS (gabble_connection_class);
diff --git a/tests/twisted/olpc/gadget-publish.py b/tests/twisted/olpc/gadget-publish.py
index ff66062..3efb767 100644
--- a/tests/twisted/olpc/gadget-publish.py
+++ b/tests/twisted/olpc/gadget-publish.py
@@ -4,7 +4,7 @@ test OLPC search activity
 
 import dbus
 
-from servicetest import call_async, EventPattern
+from servicetest import call_async, EventPattern, tp_name_prefix
 from gabbletest import exec_test, make_result_iq, acknowledge_iq, sync_stream, \
     elem
 
@@ -37,11 +37,24 @@ def test(q, bus, conn, stream):
         EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
 
     acknowledge_iq(stream, iq_event.stanza)
+
+    props = conn.GetAll(
+            'org.laptop.Telepathy.Gadget',
+            dbus_interface='org.freedesktop.DBus.Properties')
+    assert props['ActivityGadgetAvailable'] == False
+    assert props['BuddyGadgetAvailable'] == False
+
     announce_gadget(q, stream, disco_event.stanza)
 
     q.expect_many(EventPattern('dbus-signal', signal='BuddyGadgetDiscovered'),
             EventPattern('dbus-signal', signal='ActivityGadgetDiscovered'))
 
+    props = conn.GetAll(
+            'org.laptop.Telepathy.Gadget',
+            dbus_interface='org.freedesktop.DBus.Properties')
+    assert props['ActivityGadgetAvailable'] == True
+    assert props['BuddyGadgetAvailable'] == True
+
     gadget_iface = dbus.Interface(conn, 'org.laptop.Telepathy.Gadget')
 
     call_async(q, gadget_iface, 'Publish', True)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list