[Telepathy-commits] [telepathy-gabble/master] add skeleton for Gadget.Publish() method

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


20080523123612-7fe3f-658255c11af706fc0092b3e820b1ac057ae2222d.gz
---
 extensions/OLPC_Gadget.xml           |   14 +++++++
 src/conn-olpc.c                      |   10 +++++
 tests/twisted/olpc/gadget-publish.py |   71 ++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/olpc/gadget-publish.py

diff --git a/extensions/OLPC_Gadget.xml b/extensions/OLPC_Gadget.xml
index 89bf492..d13f9bf 100644
--- a/extensions/OLPC_Gadget.xml
+++ b/extensions/OLPC_Gadget.xml
@@ -128,6 +128,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</p>
       </tp:possible-errors>
     </method>
 
+    <method name="Publish">
+      <arg direction="in" name="publish" type="b">
+         <tp:docstring>
+          A boolean indicating if we want to publish your informations to Gadget.
+        </tp:docstring>
+      </arg>
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>Publish your informations to Gadget so other users can search for you.</p>
+      </tp:docstring>
+      <tp:possible-errors>
+        <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/>
+      </tp:possible-errors>
+    </method>
+
     <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
       <p>An interface on connections to interact with the Gadget component.</p>
     </tp:docstring>
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 68497a9..14576db 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -3678,6 +3678,15 @@ olpc_gadget_search_activities_by_participants (GabbleSvcOLPCGadget *iface,
   lm_message_unref (query);
 }
 
+static void
+olpc_gadget_publish (GabbleSvcOLPCGadget *iface,
+                     gboolean publish,
+                     DBusGMethodInvocation *context)
+{
+  /* TODO */
+  gabble_svc_olpc_gadget_return_from_publish (context);
+}
+
 void
 olpc_gadget_iface_init (gpointer g_iface,
                         gpointer iface_data)
@@ -3691,5 +3700,6 @@ olpc_gadget_iface_init (gpointer g_iface,
   IMPLEMENT(request_random_activities);
   IMPLEMENT(search_activities_by_properties);
   IMPLEMENT(search_activities_by_participants);
+  IMPLEMENT(publish);
 #undef IMPLEMENT
 }
diff --git a/tests/twisted/olpc/gadget-publish.py b/tests/twisted/olpc/gadget-publish.py
new file mode 100644
index 0000000..63fd501
--- /dev/null
+++ b/tests/twisted/olpc/gadget-publish.py
@@ -0,0 +1,71 @@
+"""
+test OLPC search activity
+"""
+
+import dbus
+
+from servicetest import call_async, EventPattern
+from gabbletest import exec_test, make_result_iq, acknowledge_iq, sync_stream
+
+from twisted.words.xish import domish, xpath
+from twisted.words.protocols.jabber.client import IQ
+
+NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
+NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
+NS_OLPC_CURRENT_ACTIVITY = "http://laptop.org/xmpp/current-activity"
+NS_OLPC_ACTIVITY_PROPS = "http://laptop.org/xmpp/activity-properties"
+NS_OLPC_BUDDY = "http://laptop.org/xmpp/buddy"
+NS_OLPC_ACTIVITY = "http://laptop.org/xmpp/activity"
+
+NS_PUBSUB = "http://jabber.org/protocol/pubsub"
+NS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
+NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
+
+
+NS_AMP = "http://jabber.org/protocol/amp"
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+
+    _, iq_event, disco_event = q.expect_many(
+        EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
+        EventPattern('stream-iq', to=None, query_ns='vcard-temp',
+            query_name='vCard'),
+        EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
+
+    acknowledge_iq(stream, iq_event.stanza)
+
+    # announce Gadget service
+    reply = make_result_iq(stream, disco_event.stanza)
+    query = xpath.queryForNodes('/iq/query', reply)[0]
+    item = query.addElement((None, 'item'))
+    item['jid'] = 'gadget.localhost'
+    stream.send(reply)
+
+    # wait for Gadget disco#info query
+    event = q.expect('stream-iq', to='gadget.localhost', query_ns=NS_DISCO_INFO)
+    reply = make_result_iq(stream, event.stanza)
+    query = xpath.queryForNodes('/iq/query', reply)[0]
+    identity = query.addElement((None, 'identity'))
+    identity['category'] = 'collaboration'
+    identity['type'] = 'gadget'
+    identity['name'] = 'OLPC Gadget'
+    feature = query.addElement((None, 'feature'))
+    feature['var'] = NS_OLPC_BUDDY
+    feature = query.addElement((None, 'feature'))
+    feature['var'] = NS_OLPC_ACTIVITY
+    stream.send(reply)
+
+    gadget_iface = dbus.Interface(conn, 'org.laptop.Telepathy.Gadget')
+
+    sync_stream(q, stream)
+
+    call_async(q, gadget_iface, 'Publish', True)
+
+    # TODO
+
+    q.expect('dbus-return', method='Publish')
+
+
+if __name__ == '__main__':
+    exec_test(test)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list