[Telepathy-commits] [telepathy-gabble/master] ugly and incomplete implementation of Publish
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:14 PDT 2008
20080527115447-7fe3f-fae01ff09b0c9a49c65d1c611b2d333d9e25f170.gz
---
src/conn-olpc.c | 55 +++++++++++++++++++++++++++++++++-
tests/twisted/olpc/gadget-publish.py | 7 ++--
2 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 53ec7e5..507b827 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -3726,12 +3726,65 @@ olpc_gadget_search_activities_by_participants (GabbleSvcOLPCGadget *iface,
lm_message_unref (query);
}
+static gboolean
+send_presence_to_gadget (GabbleConnection *conn,
+ LmMessageSubType sub_type,
+ GError **error)
+{
+ LmMessage *message;
+ gboolean ret;
+
+ message = lm_message_new_with_sub_type (conn->olpc_gadget_buddy,
+ LM_MESSAGE_TYPE_PRESENCE, sub_type);
+
+ ret = _gabble_connection_send (conn, message, error);
+
+ lm_message_unref (message);
+
+ return ret;
+}
+
static void
olpc_gadget_publish (GabbleSvcOLPCGadget *iface,
gboolean publish,
DBusGMethodInvocation *context)
{
- /* TODO */
+ GabbleConnection *conn = GABBLE_CONNECTION (iface);
+
+ if (!check_gadget_buddy (conn, context))
+ return;
+
+ if (publish)
+ {
+ GError *error = NULL;
+
+ /* FIXME: we should check if we are already registered before */
+ /* FIXME: add to roster ? */
+ /* FIXME: this is ugly. We should use roster and/or
+ * gabble-roster-channel if possible */
+
+ if (!send_presence_to_gadget (conn, LM_MESSAGE_SUB_TYPE_SUBSCRIBE,
+ &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ if (!send_presence_to_gadget (conn, LM_MESSAGE_SUB_TYPE_SUBSCRIBED,
+ &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ }
+ else
+ {
+ /* TODO */
+ ;
+ }
+
gabble_svc_olpc_gadget_return_from_publish (context);
}
diff --git a/tests/twisted/olpc/gadget-publish.py b/tests/twisted/olpc/gadget-publish.py
index 424306c..42c11c0 100644
--- a/tests/twisted/olpc/gadget-publish.py
+++ b/tests/twisted/olpc/gadget-publish.py
@@ -65,9 +65,10 @@ def test(q, bus, conn, stream):
call_async(q, gadget_iface, 'Publish', True)
- # TODO
-
- q.expect('dbus-return', method='Publish')
+ q.expect_many(
+ EventPattern('stream-presence', presence_type='subscribe'),
+ EventPattern('stream-presence', presence_type='subscribed'),
+ EventPattern('dbus-return', method='Publish'))
if __name__ == '__main__':
--
1.5.6.5
More information about the Telepathy-commits
mailing list