changeset 23260:5793bcea224c

Fix the chat-room rejoining bug where the list appears empty. Closes #5541.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 01 Jun 2008 18:08:14 +0000
parents babaa9794e1b
children b4ed2512be3b 4ac5db6e39f3
files libpurple/protocols/jabber/chat.c libpurple/protocols/jabber/chat.h libpurple/protocols/jabber/presence.c
diffstat 3 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/chat.c	Sun Jun 01 04:48:51 2008 +0000
+++ b/libpurple/protocols/jabber/chat.c	Sun Jun 01 18:08:14 2008 +0000
@@ -308,7 +308,7 @@
 
 	jabber_chat_part(chat, NULL);
 
-	chat->conv = NULL;
+	chat->left = TRUE;
 }
 
 void jabber_chat_destroy(JabberChat *chat)
--- a/libpurple/protocols/jabber/chat.h	Sun Jun 01 04:48:51 2008 +0000
+++ b/libpurple/protocols/jabber/chat.h	Sun Jun 01 18:08:14 2008 +0000
@@ -49,6 +49,7 @@
 	PurpleRequestType config_dialog_type;
 	void *config_dialog_handle;
 	GHashTable *members;
+	gboolean left;
 } JabberChat;
 
 GList *jabber_chat_info(PurpleConnection *gc);
--- a/libpurple/protocols/jabber/presence.c	Sun Jun 01 04:48:51 2008 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sun Jun 01 18:08:14 2008 +0000
@@ -49,7 +49,7 @@
 	xmlnode *presence = user_data;
 	char *chat_full_jid;
 
-	if(!chat->conv)
+	if(!chat->conv || chat->left)
 		return;
 
 	chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server,
@@ -581,13 +581,13 @@
 		if(state == JABBER_BUDDY_STATE_ERROR) {
 			char *title, *msg = jabber_parse_error(js, packet, NULL);
 
-			if(chat->conv) {
+			if (!chat->conv) {
+				title = g_strdup_printf(_("Error joining chat %s"), from);
+				purple_serv_got_join_chat_failed(js->gc, chat->components);
+			} else {
 				title = g_strdup_printf(_("Error in chat %s"), from);
 				if (g_hash_table_size(chat->members) == 0)
 					serv_got_chat_left(js->gc, chat->id);
-			} else {
-				title = g_strdup_printf(_("Error joining chat %s"), from);
-				purple_serv_got_join_chat_failed(js->gc, chat->components);
 			}
 			purple_notify_error(js->gc, title, title, msg);
 			g_free(title);
@@ -609,8 +609,9 @@
 
 			/* If we haven't joined the chat yet, we don't care that someone
 			 * left, or it was us leaving after we closed the chat */
-			if(!chat->conv) {
-				if(jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
+			if (!chat->conv || chat->left) {
+				if (chat->left &&
+						jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
 					jabber_chat_destroy(chat);
 				jabber_id_free(jid);
 				g_free(status);