diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-04-17 15:36:28 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-04-30 11:47:18 +0200 |
commit | 0b291b59709c9da444ed87ec80447ce177145266 (patch) | |
tree | 398c88a333c9655a48edfe69931906b043e64314 | |
parent | b2d1595361a5c85f8f25548e1178e267404ec63a (diff) |
simple-conn: add tp_tests_simple_connection_ensure_room_list_chan()
-rw-r--r-- | tests/lib/simple-conn.c | 49 | ||||
-rw-r--r-- | tests/lib/simple-conn.h | 5 |
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c index 476db0ee9..27f1835e8 100644 --- a/tests/lib/simple-conn.c +++ b/tests/lib/simple-conn.c @@ -25,6 +25,7 @@ #include <telepathy-glib/util.h> #include "textchan-null.h" +#include "room-list-chan.h" #include "util.h" static void conn_iface_init (TpSvcConnectionClass *); @@ -410,6 +411,54 @@ tp_tests_simple_connection_ensure_text_chan (TpTestsSimpleConnection *self, return chan_path; } +static void +room_list_chan_closed_cb (TpBaseChannel *channel, + TpTestsSimpleConnection *self) +{ + g_hash_table_remove (self->priv->channels, GUINT_TO_POINTER (0)); +} + +gchar * +tp_tests_simple_connection_ensure_room_list_chan (TpTestsSimpleConnection *self, + const gchar *server, + GHashTable **props) +{ + TpTestsRoomListChan *chan; + gchar *chan_path; + TpBaseConnection *base_conn = (TpBaseConnection *) self; + + chan = g_hash_table_lookup (self->priv->channels, GUINT_TO_POINTER (0)); + if (chan != NULL) + { + /* Channel already exist, reuse it */ + g_object_get (chan, "object-path", &chan_path, NULL); + } + else + { + chan_path = g_strdup_printf ("%s/RoomListChannel", + base_conn->object_path); + + chan = TP_TESTS_ROOM_LIST_CHAN ( + tp_tests_object_new_static_class ( + TP_TESTS_TYPE_ROOM_LIST_CHAN, + "connection", self, + "object-path", chan_path, + "server", server ? server : "", + NULL)); + + g_signal_connect (chan, "closed", + G_CALLBACK (room_list_chan_closed_cb), self); + + g_hash_table_insert (self->priv->channels, GUINT_TO_POINTER (0), + chan); + } + + if (props != NULL) + g_object_get (chan, "channel-properties", props, NULL); + + return chan_path; +} + void tp_tests_simple_connection_set_get_self_handle_error ( TpTestsSimpleConnection *self, diff --git a/tests/lib/simple-conn.h b/tests/lib/simple-conn.h index 6322f4b86..837400bc3 100644 --- a/tests/lib/simple-conn.h +++ b/tests/lib/simple-conn.h @@ -72,6 +72,11 @@ void tp_tests_simple_connection_set_get_self_handle_error ( gint code, const gchar *message); +gchar * tp_tests_simple_connection_ensure_room_list_chan ( + TpTestsSimpleConnection *self, + const gchar *server, + GHashTable **props); + G_END_DECLS #endif /* #ifndef __TP_TESTS_SIMPLE_CONN_H__ */ |