diff libpurple/protocols/myspace/myspace.c @ 21758:430827922828

Avoid checking for new message in the inbox when not actually connected. This helps avoid a half-dozen assertions by not trying to act on a closed socket.
author Kevin Stange <kevin@simguy.net>
date Tue, 04 Dec 2007 05:43:15 +0000
parents b2c2e935a150
children 41489d141def
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Tue Dec 04 02:50:44 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue Dec 04 05:43:15 2007 +0000
@@ -1369,7 +1369,9 @@
 	msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply);
 
 	body = msim_msg_get_dictionary(reply, "body");
-	g_return_if_fail(body != NULL);
+
+	if (body == NULL)
+		return;
 
 	old_inbox_status = session->inbox_status;
 
@@ -1433,6 +1435,11 @@
 
 	session = (MsimSession *)data;
 
+	if (!MSIM_SESSION_VALID(session)) {
+		purple_debug_info("msim", "msim_check_inbox: session invalid, stopping the mail check.\n");
+		return FALSE;
+	}
+
 	purple_debug_info("msim", "msim_check_inbox: checking mail\n");
 	g_return_val_if_fail(msim_send(session, 
 			"persist", MSIM_TYPE_INTEGER, 1,
@@ -1645,7 +1652,7 @@
 
 	/* Check mail if they want to. */
 	if (purple_account_get_check_mail(session->account)) {
-		purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, 
+		session->inbox_handle = purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, 
 				(GSourceFunc)msim_check_inbox, session);
 		msim_check_inbox(session);
 	}