im.pidgin.pidgin: 65fe5060e09daeac78c60bf74d157d7c2330ea74

kstange at pidgin.im kstange at pidgin.im
Tue Dec 4 00:45:43 EST 2007


-----------------------------------------------------------------
Revision: 65fe5060e09daeac78c60bf74d157d7c2330ea74
Ancestor: 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Author: kstange at pidgin.im
Date: 2007-12-04T05:43:15
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/myspace/session.c
        libpurple/protocols/myspace/session.h

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	e3ca8584f367127ce0ad10203e8117f475173e0f
+++ libpurple/protocols/myspace/myspace.c	ebb9328da8321819324f7ceaa3e19fef751e34f0
@@ -1369,8 +1369,10 @@ msim_check_inbox_cb(MsimSession *session
 	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;
 
 	n = 0;
@@ -1433,6 +1435,11 @@ msim_check_inbox(gpointer data)
 
 	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 @@ msim_we_are_logged_on(MsimSession *sessi
 
 	/* 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);
 	}
============================================================
--- libpurple/protocols/myspace/session.c	00abcaf2a146a77b554f2dd45933de471841442e
+++ libpurple/protocols/myspace/session.c	f120bf5c109b9f70507918c7f4f92285c4528a71
@@ -63,6 +63,7 @@ msim_session_new(PurpleAccount *acct)
 	session->next_rid = 1;
 	session->last_comm = time(NULL);
 	session->inbox_status = 0;
+	session->inbox_handle = 0;
 	
 	return session;
 }
@@ -90,6 +91,11 @@ msim_session_destroy(MsimSession *sessio
 		msim_msg_free(session->server_info);
 	}
 	
+	/* Stop checking the inbox at the end of the session. */
+	if (session->inbox_handle) {
+		purple_timeout_remove(session->inbox_handle);
+	}
+
 	g_free(session);
 }
 
============================================================
--- libpurple/protocols/myspace/session.h	44f91f9124a7c5463a541d5af2d3465bc291e926
+++ libpurple/protocols/myspace/session.h	b03eaaf8edc2bed3f95c57cf46776e4910ab14b3
@@ -45,6 +45,7 @@ typedef struct _MsimSession
 	guint next_rid;                     /**< Next request/response ID */
 	time_t last_comm;                   /**< Time received last communication */
 	guint inbox_status;                 /**< Bit field of inbox notifications */
+	guint inbox_handle;                 /**< The handle for the mail check timer */
 } MsimSession;
 
 /* Check if an MsimSession is valid */


More information about the Commits mailing list