changeset 8396:387ba791d5f9

[gaim-migrate @ 9125] fix a crash in jabber chats when you leave the chat before closing the configuration dialog, and plug a memleak. Thanks deryni for pointing the crash out committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 04 Mar 2004 17:07:56 +0000
parents 09083081643a
children b63debdf5a92
files ChangeLog src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/jabber.c src/protocols/jabber/presence.c src/protocols/jabber/xdata.c src/protocols/jabber/xdata.h
diffstat 7 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 04 05:47:41 2004 +0000
+++ b/ChangeLog	Thu Mar 04 17:07:56 2004 +0000
@@ -53,6 +53,7 @@
 	* Buddy pounces for an account are removed when the account is
 	  deleted (Gary Kramlich)
 	* Various bug and memory leak fixes (Gary Kramlich)
+	* Assorted SSL crashfixes
 
 	Translations:
 	* Catalan translation updated (Xan (DXpublica))
--- a/src/protocols/jabber/chat.c	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/chat.c	Thu Mar 04 17:07:56 2004 +0000
@@ -229,6 +229,12 @@
 
 	g_hash_table_remove(js->chats, jabber_normalize(NULL, room_jid));
 	g_free(room_jid);
+}
+
+void jabber_chat_free(JabberChat *chat)
+{
+	if(chat->config_dialog_handle)
+		gaim_request_close(chat->config_dialog_type, chat->config_dialog_handle);
 
 	g_free(chat->room);
 	g_free(chat->server);
@@ -314,7 +320,8 @@
 				continue;
 
 			if(!strcmp(xmlns, "jabber:x:data")) {
-				jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat);
+				chat->config_dialog_type = GAIM_REQUEST_FIELDS;
+				chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat);
 				return;
 			}
 		}
@@ -358,6 +365,8 @@
 	if(!chat)
 		return;
 
+	chat->config_dialog_handle = NULL;
+
 	if(!chat->muc) {
 		gaim_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"),
 				_("This room is not capable of being configured"));
@@ -386,6 +395,8 @@
 	if(!chat)
 		return;
 
+	chat->config_dialog_handle = NULL;
+
 	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
 			"http://jabber.org/protocol/muc#owner");
 	query = xmlnode_get_child(iq->node, "query");
--- a/src/protocols/jabber/chat.h	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/chat.h	Thu Mar 04 17:07:56 2004 +0000
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "connection.h"
 #include "conversation.h"
+#include "request.h"
 #include "roomlist.h"
 
 #include "jabber.h"
@@ -38,6 +39,8 @@
 	GaimConversation *conv;
 	gboolean muc;
 	gboolean xhtml;
+	GaimRequestType config_dialog_type;
+	void *config_dialog_handle;
 } JabberChat;
 
 GList *jabber_chat_info(GaimConnection *gc);
@@ -46,6 +49,7 @@
 		const char *server);
 JabberChat *jabber_chat_find_by_id(JabberStream *js, int id);
 void jabber_chat_destroy(JabberChat *chat);
+void jabber_chat_free(JabberChat *chat);
 gboolean jabber_chat_find_buddy(GaimConversation *conv, const char *name);
 void jabber_chat_invite(GaimConnection *gc, int id, const char *message,
 		const char *name);
--- a/src/protocols/jabber/jabber.c	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Thu Mar 04 17:07:56 2004 +0000
@@ -400,7 +400,7 @@
 	js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal,
 			g_free, (GDestroyNotify)jabber_buddy_free);
 	js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
-			g_free, NULL);
+			g_free, (GDestroyNotify)jabber_chat_free);
 	js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org"));
 	js->user = jabber_id_new(gaim_account_get_username(account));
 	js->next_id = g_random_int();
--- a/src/protocols/jabber/presence.c	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/presence.c	Thu Mar 04 17:07:56 2004 +0000
@@ -276,7 +276,9 @@
 					const char *code = xmlnode_get_attrib(z, "code");
 					if(code && !strcmp(code, "201")) {
 						chat = jabber_chat_find(js, jid->node, jid->domain);
-						gaim_request_action(js->gc, _("Create New Room"),
+						chat->config_dialog_type = GAIM_REQUEST_ACTION;
+						chat->config_dialog_handle =
+							gaim_request_action(js->gc, _("Create New Room"),
 								_("Create New Room"),
 								_("You are creating a new room.  Would you like to "
 									"configure it, or accept the default settings?"),
--- a/src/protocols/jabber/xdata.c	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/xdata.c	Thu Mar 04 17:07:56 2004 +0000
@@ -146,8 +146,9 @@
 	cb(js, result, user_data);
 }
 
-void jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data)
+void *jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data)
 {
+	void *handle;
 	xmlnode *fn, *x;
 	GaimRequestFields *fields;
 	GaimRequestFieldGroup *group;
@@ -332,7 +333,8 @@
 	if((x = xmlnode_get_child(packet, "instructions")))
 		instructions = xmlnode_get_data(x);
 
-	gaim_request_fields(js->gc, title, title, instructions, fields, _("OK"), G_CALLBACK(jabber_x_data_ok_cb),
+	handle = gaim_request_fields(js->gc, title, title, instructions, fields,
+			_("OK"), G_CALLBACK(jabber_x_data_ok_cb),
 			_("Cancel"), G_CALLBACK(jabber_x_data_cancel_cb), data);
 
 	if(title)
@@ -340,6 +342,7 @@
 	if(instructions)
 		g_free(instructions);
 
+	return handle;
 }
 
 
--- a/src/protocols/jabber/xdata.h	Thu Mar 04 05:47:41 2004 +0000
+++ b/src/protocols/jabber/xdata.h	Thu Mar 04 17:07:56 2004 +0000
@@ -26,6 +26,6 @@
 #include "xmlnode.h"
 
 typedef void (*jabber_x_data_cb)(JabberStream *js, xmlnode *result, gpointer user_data);
-void jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data);
+void *jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data);
 
 #endif /* _GAIM_JABBER_XDATA_H_ */