[Telepathy-commits] [telepathy-gabble/master] pass the requested property when creating muc-channel so text channels requested because of a tubes request have the right requested property (b.fd.o #18738)
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Dec 5 06:59:28 PST 2008
---
src/muc-channel.c | 8 +++-
src/muc-factory.c | 16 +++++---
.../tubes/test-muc-offer-stream-tube-ibb.py | 40 ++++++++++++++++++--
3 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/src/muc-channel.c b/src/muc-channel.c
index 8d34dff..1ad9c9b 100644
--- a/src/muc-channel.c
+++ b/src/muc-channel.c
@@ -232,6 +232,7 @@ struct _GabbleMucChannelPrivate
TpHandle handle;
const gchar *jid;
+ gboolean requested;
guint nick_retry_count;
GString *self_jid;
@@ -840,7 +841,7 @@ gabble_muc_channel_get_property (GObject *object,
}
break;
case PROP_REQUESTED:
- g_value_set_boolean (value, (priv->initiator == base_conn->self_handle));
+ g_value_set_boolean (value, priv->requested);
break;
case PROP_CHANNEL_DESTROYED:
g_value_set_boolean (value, priv->closed);
@@ -913,6 +914,9 @@ gabble_muc_channel_set_property (GObject *object,
g_assert (priv->invitation_message == NULL);
priv->invitation_message = g_value_dup_string (value);
break;
+ case PROP_REQUESTED:
+ priv->requested = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1022,7 +1026,7 @@ gabble_muc_channel_class_init (GabbleMucChannelClass *gabble_muc_channel_class)
param_spec = g_param_spec_boolean ("requested", "Requested?",
"True if this channel was requested by the local user",
FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REQUESTED, param_spec);
param_spec = g_param_spec_string ("invitation-message",
diff --git a/src/muc-factory.c b/src/muc-factory.c
index f294a91..e7ed90d 100644
--- a/src/muc-factory.c
+++ b/src/muc-factory.c
@@ -371,7 +371,8 @@ new_muc_channel (GabbleMucFactory *fac,
TpHandle handle,
gboolean invited,
TpHandle inviter,
- const gchar *message)
+ const gchar *message,
+ gboolean requested)
{
GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
TpBaseConnection *conn = (TpBaseConnection *) priv->conn;
@@ -393,6 +394,7 @@ new_muc_channel (GabbleMucFactory *fac,
"invited", invited,
"initiator-handle", invited ? inviter : conn->self_handle,
"invitation-message", message,
+ "requested", requested,
NULL);
g_signal_connect (chan, "closed", (GCallback) muc_channel_closed_cb, fac);
@@ -477,7 +479,7 @@ do_invite (GabbleMucFactory *fac,
if (g_hash_table_lookup (priv->text_channels,
GUINT_TO_POINTER (room_handle)) == NULL)
{
- new_muc_channel (fac, room_handle, TRUE, inviter_handle, reason);
+ new_muc_channel (fac, room_handle, TRUE, inviter_handle, reason, FALSE);
}
else
{
@@ -1187,7 +1189,8 @@ static gboolean
ensure_muc_channel (GabbleMucFactory *fac,
GabbleMucFactoryPrivate *priv,
TpHandle handle,
- GabbleMucChannel **ret)
+ GabbleMucChannel **ret,
+ gboolean requested)
{
TpBaseConnection *base_conn = (TpBaseConnection *) priv->conn;
@@ -1198,7 +1201,8 @@ ensure_muc_channel (GabbleMucFactory *fac,
/* FIXME: using base_conn->self_handle causes Requested to be TRUE,
* which is incorrect if this is a side-effect of joining a Tubes
* channel */
- *ret = new_muc_channel (fac, handle, FALSE, base_conn->self_handle, NULL);
+ *ret = new_muc_channel (fac, handle, FALSE, base_conn->self_handle, NULL,
+ requested);
return FALSE;
}
@@ -1332,7 +1336,7 @@ gabble_muc_factory_request (GabbleMucFactory *self,
&error))
goto error;
- if (ensure_muc_channel (self, priv, handle, &text_chan))
+ if (ensure_muc_channel (self, priv, handle, &text_chan, TRUE))
{
if (require_new)
{
@@ -1379,7 +1383,7 @@ gabble_muc_factory_request (GabbleMucFactory *self,
request_token, TP_EXPORTABLE_CHANNEL (tubes_chan));
}
}
- else if (ensure_muc_channel (self, priv, handle, &text_chan))
+ else if (ensure_muc_channel (self, priv, handle, &text_chan, FALSE))
{
tubes_chan = new_tubes_channel (self, handle, text_chan,
base_conn->self_handle);
diff --git a/tests/twisted/tubes/test-muc-offer-stream-tube-ibb.py b/tests/twisted/tubes/test-muc-offer-stream-tube-ibb.py
index f2b9a1a..001a4ad 100644
--- a/tests/twisted/tubes/test-muc-offer-stream-tube-ibb.py
+++ b/tests/twisted/tubes/test-muc-offer-stream-tube-ibb.py
@@ -48,6 +48,9 @@ def test(q, bus, conn, stream):
acknowledge_iq(stream, iq_event.stanza)
+ self_handle = conn.GetSelfHandle()
+ self_name = conn.InspectHandles(1, [self_handle])[0]
+
call_async(q, conn, 'RequestHandles', 2,
['chat at conf.localhost'])
@@ -95,25 +98,54 @@ def test(q, bus, conn, stream):
assert conn.InspectHandles(1, [3]) == ['chat at conf.localhost/bob']
bob_handle = 3
- text_created, returned = q.expect_many(
+ old_sig, new_sig, returned = q.expect_many(
# first text channel is created
EventPattern('dbus-signal', signal='NewChannel'),
+ EventPattern('dbus-signal', signal='NewChannels'),
EventPattern('dbus-return', method='RequestChannel'))
- path, type, handle_type, handle, supress = text_created.args
+ path, type, handle_type, handle, supress = old_sig.args
assert type == 'org.freedesktop.Telepathy.Channel.Type.Text'
assert handle_type == 2 #room
assert handle == handles[0]
assert supress == False
+ # check text channel properties
+ text_props = new_sig.args[0][0][1]
+ assert text_props[tp_name_prefix + '.Channel.ChannelType'] ==\
+ 'org.freedesktop.Telepathy.Channel.Type.Text'
+ assert text_props[tp_name_prefix + '.Channel.TargetHandleType'] == 2
+ assert text_props[tp_name_prefix + '.Channel.TargetHandle'] == handle
+ assert text_props[tp_name_prefix + '.Channel.TargetID'] == 'chat at conf.localhost'
+ assert text_props[tp_name_prefix + '.Channel.Requested'] == False
+ assert text_props[tp_name_prefix + '.Channel.InitiatorHandle'] \
+ == self_handle
+ assert text_props[tp_name_prefix + '.Channel.InitiatorID'] \
+ == self_name
+
# tube channel is created
- e = q.expect('dbus-signal', signal='NewChannel')
- path, type, handle_type, handle, supress = e.args
+ old_sig, new_sig = q.expect_many(
+ EventPattern('dbus-signal', signal='NewChannel'),
+ EventPattern('dbus-signal', signal='NewChannels'))
+ path, type, handle_type, handle, supress = old_sig.args
assert type == 'org.freedesktop.Telepathy.Channel.Type.Tubes'
assert handle_type == 2 #room
assert handle == handles[0]
assert supress == True
+ # check tubes channel properties
+ tubes_props = new_sig.args[0][0][1]
+ assert tubes_props[tp_name_prefix + '.Channel.ChannelType'] ==\
+ 'org.freedesktop.Telepathy.Channel.Type.Tubes'
+ assert tubes_props[tp_name_prefix + '.Channel.TargetHandleType'] == 2
+ assert tubes_props[tp_name_prefix + '.Channel.TargetHandle'] == handle
+ assert tubes_props[tp_name_prefix + '.Channel.TargetID'] == 'chat at conf.localhost'
+ assert tubes_props[tp_name_prefix + '.Channel.Requested'] == True
+ assert tubes_props[tp_name_prefix + '.Channel.InitiatorHandle'] \
+ == self_handle
+ assert tubes_props[tp_name_prefix + '.Channel.InitiatorID'] \
+ == self_name
+
tubes_chan = bus.get_object(conn.bus_name, returned.value[0])
tubes_iface = dbus.Interface(tubes_chan,
tp_name_prefix + '.Channel.Type.Tubes')
--
1.5.6.5
More information about the Telepathy-commits
mailing list