From bf4c1a810fad23c6768b6c0ea70b72d9c6ee6d58 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 22 Sep 2013 01:26:40 +0100 Subject: [PATCH] Fixe rejoining room after nickname conflict fixes #241 --- src/muc.c | 4 +++- src/profanity.c | 5 +++++ src/xmpp/presence.c | 10 ++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/muc.c b/src/muc.c index 89391ddd..8760124f 100644 --- a/src/muc.c +++ b/src/muc.c @@ -145,7 +145,9 @@ muc_join_room(const char * const room, const char * const nick) void muc_leave_room(const char * const room) { - g_hash_table_remove(rooms, room); + if (rooms != NULL) { + g_hash_table_remove(rooms, room); + } } /* diff --git a/src/profanity.c b/src/profanity.c index 9c729ca1..613523f9 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -192,6 +192,11 @@ prof_handle_error_message(const char *from, const char *err_msg) } else { cons_show_error("Error received from server: %s", err_msg); } + // remove the room from muc + Jid *room_jid = jid_create(from); + muc_leave_room(room_jid->barejid); + jid_destroy(room_jid); + } else { cons_show_error("Error received from server: %s", err_msg); } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 40e63220..dc91bd58 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -303,10 +303,12 @@ presence_leave_chat_room(const char * const room_jid) xmpp_conn_t *conn = connection_get_conn(); char *nick = muc_get_room_nick(room_jid); - xmpp_stanza_t *presence = stanza_create_room_leave_presence(ctx, room_jid, - nick); - xmpp_send(conn, presence); - xmpp_stanza_release(presence); + if (nick != NULL) { + xmpp_stanza_t *presence = stanza_create_room_leave_presence(ctx, room_jid, + nick); + xmpp_send(conn, presence); + xmpp_stanza_release(presence); + } } static int