From 652fd60b67f7096f24a2fcc9088ea2948853d750 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sun, 20 Mar 2011 11:36:35 +0200 Subject: [PATCH] Pending or declined invitates should not prevent manual joins When an invitation is received, a channel is created and put in the MUC_STATE_CREATED state. If a manual join is attempted then a JOIN message should be sent on this (created, but not yet ready) channel. Although this is enough to deal with declined invites, the channel is left in the MUC_STATE_CREATED state if we do not leave it ourself. This happens because the PART message triggers a ERR_NOTONCHANNEL due to the fact that a JOIN was never actually sent after creating the channel. To avoid this, the PART is sent only when the channel is not in a state of limbo and it is left immediately afterwards. This is safe because a PART request is always granted by the server. Fixes: https://bugs.freedesktop.org/34258 --- src/idle-muc-channel.c | 14 +++++++++----- src/idle-muc-manager.c | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index 83e0ea2..333b97b 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -1743,13 +1743,17 @@ static void part_from_channel(IdleMUCChannel *obj, const gchar *msg) { priv = IDLE_MUC_CHANNEL_GET_PRIVATE(obj); - if (msg != NULL) { - g_snprintf(cmd, IRC_MSG_MAXLEN + 1, "PART %s :%s", priv->channel_name, msg); - } else { - g_snprintf(cmd, IRC_MSG_MAXLEN + 1, "PART %s", priv->channel_name); + if (priv->state >= MUC_STATE_JOINING) { + if (msg != NULL) { + g_snprintf(cmd, IRC_MSG_MAXLEN + 1, "PART %s :%s", priv->channel_name, msg); + } else { + g_snprintf(cmd, IRC_MSG_MAXLEN + 1, "PART %s", priv->channel_name); + } + + idle_connection_send(priv->connection, cmd); } - idle_connection_send(priv->connection, cmd); + idle_muc_channel_part(obj, priv->connection->parent.self_handle, msg); } static gboolean remove_member(GObject *gobj, TpHandle handle, const gchar *message, GError **error) { diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c index db65b47..823a417 100644 --- a/src/idle-muc-manager.c +++ b/src/idle-muc-manager.c @@ -825,6 +825,10 @@ _muc_manager_request (IdleMUCManager *self, TP_EXPORTABLE_CHANNEL (channel)); return TRUE; } + else + { + idle_muc_channel_join_attempt(channel); + } } else { -- 1.7.4