[Telepathy-commits] [telepathy-gabble/master] conn-olpc: factor out gabble_olpc_view_close
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:55 PDT 2008
20080804120022-7fe3f-d8534a9bd84e22b2d27a36846cb3938710fb8194.gz
---
src/olpc-view.c | 26 +++++++++++++++++++-------
src/olpc-view.h | 2 ++
tests/twisted/olpc/olpc-activity-search.py | 23 ++++++++++++++---------
3 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/olpc-view.c b/src/olpc-view.c
index 7d5a569..bb58bfc 100644
--- a/src/olpc-view.c
+++ b/src/olpc-view.c
@@ -418,10 +418,24 @@ olpc_view_close (GabbleSvcOLPCView *iface,
DBusGMethodInvocation *context)
{
GabbleOlpcView *self = GABBLE_OLPC_VIEW (iface);
+ GError *error = NULL;
+
+ if (!gabble_olpc_view_close (self, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ }
+
+ gabble_svc_olpc_view_return_from_close (context);
+}
+
+gboolean
+gabble_olpc_view_close (GabbleOlpcView *self,
+ GError **error)
+{
GabbleOlpcViewPrivate *priv = GABBLE_OLPC_VIEW_GET_PRIVATE (self);
LmMessage *msg;
gchar *id_str;
- GError *error = NULL;
id_str = g_strdup_printf ("%u", priv->id);
@@ -450,16 +464,12 @@ olpc_view_close (GabbleSvcOLPCView *iface,
g_free (id_str);
- if (!_gabble_connection_send (priv->conn, msg, &error))
+ if (!_gabble_connection_send (priv->conn, msg, error))
{
- dbus_g_method_return_error (context, error);
lm_message_unref (msg);
- g_error_free (error);
- return;
+ return FALSE;
}
- gabble_svc_olpc_view_return_from_close (context);
-
lm_message_unref (msg);
/* Claim that all the buddies left their activities */
@@ -467,6 +477,8 @@ olpc_view_close (GabbleSvcOLPCView *iface,
(TpHandleSetMemberFunc) buddy_left_activities_foreach, self);
g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
+
+ return TRUE;
}
/* If room is not zero, these buddies are associated with the activity
diff --git a/src/olpc-view.h b/src/olpc-view.h
index 0601f4c..baed633 100644
--- a/src/olpc-view.h
+++ b/src/olpc-view.h
@@ -94,6 +94,8 @@ GPtrArray * gabble_olpc_view_get_buddy_activities (GabbleOlpcView *self,
void gabble_olpc_view_buddies_left_activity (GabbleOlpcView *self,
GArray *buddies, TpHandle room);
+gboolean gabble_olpc_view_close (GabbleOlpcView *self, GError **error);
+
G_END_DECLS
#endif /* #ifndef __GABBLE_OLPC_VIEW_H__ */
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index c9d1180..ed2c8e3 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -475,16 +475,21 @@ def test(q, bus, conn, stream):
['fernand at localhost', 'jean at localhost'])
# close view 0
- close_view(q, view0_iface, '0')
+ call_async(q, view0_iface, 'Close')
+ event_msg, _, _, _ = q.expect_many(
+ EventPattern('stream-message', to='gadget.localhost'),
+ EventPattern('dbus-return', method='Close'),
+ # Jean and Fernand left activity4
+ EventPattern('dbus-signal', signal='ActivitiesChanged',
+ interface='org.laptop.Telepathy.BuddyInfo',
+ args=[handles['jean'], []]),
+ EventPattern('dbus-signal', signal='ActivitiesChanged',
+ interface='org.laptop.Telepathy.BuddyInfo',
+ args=[handles['fernand'], []]))
- # Jean and Fernand left activity4
- q.expect_many(
- EventPattern('dbus-signal', signal='ActivitiesChanged',
- interface='org.laptop.Telepathy.BuddyInfo',
- args=[handles['jean'], []]),
- EventPattern('dbus-signal', signal='ActivitiesChanged',
- interface='org.laptop.Telepathy.BuddyInfo',
- args=[handles['fernand'], []]))
+ close = xpath.queryForNodes('/message/close', event_msg.stanza)
+ assert len(close) == 1
+ assert close[0]['id'] == '0'
# close view 1
close_view(q, view1_iface, '1')
--
1.5.6.5
More information about the Telepathy-commits
mailing list