changeset 28982:791606778223

merge of 'aee5a93203f807e81fd88cc655fb27908cd17ff3' and 'c7225ba15472ba524ee80edc66505a2829948b95'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 05 Feb 2010 14:40:39 +0000
parents 61ea136df111 (current diff) 1386a0e22ac7 (diff)
children 462cb893521b a538cb73f897 1830fa548302
files
diffstat 10 files changed, 132 insertions(+), 212 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/notification.c	Fri Feb 05 14:40:39 2010 +0000
@@ -1144,7 +1144,7 @@
 
 	msn_user_set_object(user, msnobj);
 
-	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone && user->phone->mobile && user->phone->mobile[0] == '+');
+	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+');
 	msn_user_set_clientid(user, clientid);
 	msn_user_set_network(user, networkid);
 
@@ -1316,7 +1316,7 @@
 	}
 
 	clientid = strtoul(cmd->params[4], NULL, 10);
-	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone && user->phone->mobile && user->phone->mobile[0] == '+');
+	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+');
 
 	msn_user_set_clientid(user, clientid);
 	msn_user_set_network(user, networkid);
@@ -1599,6 +1599,63 @@
 	/*get the payload content*/
 }
 
+static void parse_currentmedia(MsnUser *user, const char *cmedia)
+{
+	char **cmedia_array;
+	int strings = 0;
+
+	if (!cmedia || cmedia[0] == '\0') {
+		purple_debug_info("msn", "No currentmedia string\n");
+		return;
+	}
+
+	purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia);
+
+	cmedia_array = g_strsplit(cmedia, "\\0", 0);
+
+	/*
+	 * 0: Application
+	 * 1: 'Music'/'Games'/'Office'
+	 * 2: '1' if enabled, '0' if not
+	 * 3: Format (eg. {0} by {1})
+	 * 4: Title
+	 * If 'Music':
+	 *  5: Artist
+	 *  6: Album
+	 *  7: ?
+	 */
+#if GLIB_CHECK_VERSION(2,6,0)
+	strings  = g_strv_length(cmedia_array);
+#else
+	while (cmedia_array[++strings] != NULL);
+#endif
+
+	if (strings >= 4 && !strcmp(cmedia_array[2], "1")) {
+		if (user->extinfo == NULL)
+			user->extinfo = g_new0(MsnUserExtendedInfo, 1);
+		else {
+			g_free(user->extinfo->media_album);
+			g_free(user->extinfo->media_artist);
+			g_free(user->extinfo->media_title);
+		}
+
+		if (!strcmp(cmedia_array[1], "Music"))
+			user->extinfo->media_type = CURRENT_MEDIA_MUSIC;
+		else if (!strcmp(cmedia_array[1], "Games"))
+			user->extinfo->media_type = CURRENT_MEDIA_GAMES;
+		else if (!strcmp(cmedia_array[1], "Office"))
+			user->extinfo->media_type = CURRENT_MEDIA_OFFICE;
+		else
+			user->extinfo->media_type = CURRENT_MEDIA_UNKNOWN;
+
+		user->extinfo->media_title = g_strdup(cmedia_array[strings == 4 ? 3 : 4]);
+		user->extinfo->media_artist = strings > 5 ? g_strdup(cmedia_array[5]) : NULL;
+		user->extinfo->media_album = strings > 6 ? g_strdup(cmedia_array[6]) : NULL;
+	}
+
+	g_strfreev(cmedia_array);
+}
+
 /*
  * Get the UBX's PSM info
  * Post it to the User status
@@ -1613,7 +1670,6 @@
 	MsnUser *user;
 	const char *passport;
 	char *psm_str, *str;
-	CurrentMedia *media = NULL;
 
 	session = cmdproc->session;
 	account = session->account;
@@ -1628,18 +1684,27 @@
 		return;
 	}
 
+	/* Free any existing media info for this user */
+	if (user->extinfo) {
+		g_free(user->extinfo->media_album);
+		g_free(user->extinfo->media_artist);
+		g_free(user->extinfo->media_title);
+		user->extinfo->media_album = NULL;
+		user->extinfo->media_artist = NULL;
+		user->extinfo->media_title = NULL;
+	}
+
 	if (len != 0) {
 		psm_str = msn_get_psm(cmd->payload,len);
 		msn_user_set_statusline(user, psm_str);
 		g_free(psm_str);
 
 		str = msn_get_currentmedia(cmd->payload, len);
-		media = msn_parse_currentmedia(str);
+		parse_currentmedia(user, str);
 		g_free(str);
 	} else {
 		msn_user_set_statusline(user, NULL);
 	}
-	msn_user_set_currentmedia(user, media);
 
 	msn_user_update(user);
 }
--- a/libpurple/protocols/msn/state.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/state.c	Fri Feb 05 14:40:39 2010 +0000
@@ -86,60 +86,6 @@
 	return result;
 }
 
-CurrentMedia *msn_parse_currentmedia(const char *cmedia)
-{
-	char **cmedia_array;
-	int strings = 0;
-	CurrentMedia *media = NULL;
-
-	if (!cmedia || cmedia[0] == '\0') {
-		purple_debug_info("msn", "No currentmedia string\n");
-		return NULL;
-	}
-
-	purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia);
-
-	cmedia_array = g_strsplit(cmedia, "\\0", 0);
-
-	/*
-	 * 0: Application
-	 * 1: 'Music'/'Games'/'Office'
-	 * 2: '1' if enabled, '0' if not
-	 * 3: Format (eg. {0} by {1})
-	 * 4: Title
-	 * If 'Music':
-	 *  5: Artist
-	 *  6: Album
-	 *  7: ?
-	 */
-#if GLIB_CHECK_VERSION(2,6,0)
-	strings  = g_strv_length(cmedia_array);
-#else
-	while (cmedia_array[++strings] != NULL);
-#endif
-
-	if (strings >= 4 && !strcmp(cmedia_array[2], "1")) {
-		media = g_new(CurrentMedia, 1);
-
-		if (!strcmp(cmedia_array[1], "Music"))
-			media->type = CURRENT_MEDIA_MUSIC;
-		else if (!strcmp(cmedia_array[1], "Games"))
-			media->type = CURRENT_MEDIA_GAMES;
-		else if (!strcmp(cmedia_array[1], "Office"))
-			media->type = CURRENT_MEDIA_OFFICE;
-		else
-			media->type = CURRENT_MEDIA_UNKNOWN;
-
-		media->title = g_strdup(cmedia_array[strings == 4 ? 3 : 4]);
-		media->artist = strings > 5 ? g_strdup(cmedia_array[5]) : NULL;
-		media->album = strings > 6 ? g_strdup(cmedia_array[6]) : NULL;
-	}
-
-	g_strfreev(cmedia_array);
-
-	return media;
-}
-
 /* get the CurrentMedia info from the XML string */
 char *
 msn_get_currentmedia(char *xml_str, gsize len)
--- a/libpurple/protocols/msn/state.h	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/state.h	Fri Feb 05 14:40:39 2010 +0000
@@ -61,11 +61,6 @@
 
 void msn_set_psm(MsnSession *session);
 
-/**
- * Parse CurrentMedia string.
- */
-CurrentMedia *msn_parse_currentmedia(const char *cmedia);
-
 /* Get the CurrentMedia info from the XML string */
 char * msn_get_currentmedia(char *xml_str,gsize len);
 
--- a/libpurple/protocols/msn/user.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/user.c	Fri Feb 05 14:40:39 2010 +0000
@@ -67,17 +67,14 @@
 	g_free(user->passport);
 	g_free(user->friendly_name);
 	g_free(user->uid);
-	if (user->phone) {
-		g_free(user->phone->home);
-		g_free(user->phone->work);
-		g_free(user->phone->mobile);
-		g_free(user->phone);
-	}
-	if (user->media) {
-		g_free(user->media->artist);
-		g_free(user->media->title);
-		g_free(user->media->album);
-		g_free(user->media);
+	if (user->extinfo) {
+		g_free(user->extinfo->media_album);
+		g_free(user->extinfo->media_artist);
+		g_free(user->extinfo->media_title);
+		g_free(user->extinfo->phone_home);
+		g_free(user->extinfo->phone_mobile);
+		g_free(user->extinfo->phone_work);
+		g_free(user->extinfo);
 	}
 	g_free(user->statusline);
 	g_free(user->invite_message);
@@ -113,24 +110,24 @@
 		purple_prpl_got_user_status_deactive(account, user->passport, "mobile");
 	}
 
-	if (!offline && user->media && user->media->type != CURRENT_MEDIA_UNKNOWN) {
-		if (user->media->type == CURRENT_MEDIA_MUSIC) {
+	if (!offline && user->extinfo && user->extinfo->media_type != CURRENT_MEDIA_UNKNOWN) {
+		if (user->extinfo->media_type == CURRENT_MEDIA_MUSIC) {
 			purple_prpl_got_user_status(account, user->passport, "tune",
-			                            PURPLE_TUNE_ARTIST, user->media->artist,
-			                            PURPLE_TUNE_ALBUM, user->media->album,
-			                            PURPLE_TUNE_TITLE, user->media->title,
+			                            PURPLE_TUNE_ARTIST, user->extinfo->media_artist,
+			                            PURPLE_TUNE_ALBUM, user->extinfo->media_album,
+			                            PURPLE_TUNE_TITLE, user->extinfo->media_title,
 			                            NULL);
-		} else if (user->media->type == CURRENT_MEDIA_GAMES) {
+		} else if (user->extinfo->media_type == CURRENT_MEDIA_GAMES) {
 			purple_prpl_got_user_status(account, user->passport, "tune",
-			                            "game", user->media->title,
+			                            "game", user->extinfo->media_title,
 			                            NULL);
-		} else if (user->media->type == CURRENT_MEDIA_OFFICE) {
+		} else if (user->extinfo->media_type == CURRENT_MEDIA_OFFICE) {
 			purple_prpl_got_user_status(account, user->passport, "tune",
-			                            "office", user->media->title,
+			                            "office", user->extinfo->media_title,
 			                            NULL);
 		} else {
 			purple_debug_warning("msn", "Got CurrentMedia with unknown type %d.\n",
-			                     user->media->type);
+			                     user->extinfo->media_type);
 		}
 	} else {
 		purple_prpl_got_user_status_deactive(account, user->passport, "tune");
@@ -211,19 +208,6 @@
 }
 
 void
-msn_user_set_currentmedia(MsnUser *user, CurrentMedia *media)
-{
-	if (user->media) {
-		g_free(user->media->title);
-		g_free(user->media->album);
-		g_free(user->media->artist);
-		g_free(user->media);
-	}
-
-	user->media = media;
-}
-
-void
 msn_user_set_uid(MsnUser *user, const char *uid)
 {
 	g_return_if_fail(user != NULL);
@@ -370,15 +354,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (!number && !user->phone)
+	if (!number && !user->extinfo)
 		return;
 
-	if (user->phone)
-		g_free(user->phone->home);
+	if (user->extinfo)
+		g_free(user->extinfo->phone_home);
 	else
-		user->phone = g_new0(MsnUserPhoneInfo, 1);
+		user->extinfo = g_new0(MsnUserExtendedInfo, 1);
 
-	user->phone->home = g_strdup(number);
+	user->extinfo->phone_home = g_strdup(number);
 }
 
 void
@@ -386,15 +370,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (!number && !user->phone)
+	if (!number && !user->extinfo)
 		return;
 
-	if (user->phone)
-		g_free(user->phone->work);
+	if (user->extinfo)
+		g_free(user->extinfo->phone_work);
 	else
-		user->phone = g_new0(MsnUserPhoneInfo, 1);
+		user->extinfo = g_new0(MsnUserExtendedInfo, 1);
 
-	user->phone->work = g_strdup(number);
+	user->extinfo->phone_work = g_strdup(number);
 }
 
 void
@@ -402,15 +386,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (!number && !user->phone)
+	if (!number && !user->extinfo)
 		return;
 
-	if (user->phone)
-		g_free(user->phone->mobile);
+	if (user->extinfo)
+		g_free(user->extinfo->phone_mobile);
 	else
-		user->phone = g_new0(MsnUserPhoneInfo, 1);
+		user->extinfo = g_new0(MsnUserExtendedInfo, 1);
 
-	user->phone->mobile = g_strdup(number);
+	user->extinfo->phone_mobile = g_strdup(number);
 }
 
 void
@@ -485,7 +469,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone ? user->phone->home : NULL;
+	return user->extinfo ? user->extinfo->phone_home : NULL;
 }
 
 const char *
@@ -493,7 +477,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone ? user->phone->work : NULL;
+	return user->extinfo ? user->extinfo->phone_work : NULL;
 }
 
 const char *
@@ -501,7 +485,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone ? user->phone->mobile : NULL;
+	return user->extinfo ? user->extinfo->phone_mobile : NULL;
 }
 
 guint
--- a/libpurple/protocols/msn/user.h	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/user.h	Fri Feb 05 14:40:39 2010 +0000
@@ -53,20 +53,25 @@
 	CURRENT_MEDIA_OFFICE
 } CurrentMediaType;
 
-typedef struct _CurrentMedia
+/**
+ * Contains optional info about a user that is fairly uncommon.  We
+ * put this info in in a separate struct to save memory because we
+ * allocate an MsnUser struct for each buddy, but we generally only
+ * need this information for a small percentage of our buddies
+ * (usually less than 1%).  Putting it in a separate struct saves
+ * makes MsnUser smaller by the size of a few pointers.
+ */
+typedef struct _MsnUserExtendedInfo
 {
-	CurrentMediaType type;     /**< Type.   */
-	char *title;    /**< Title.  */
-	char *artist;   /**< Artist. */
-	char *album;    /**< Album.  */
-} CurrentMedia;
+	CurrentMediaType media_type; /**< Type of the user's current media.   */
+	char *media_title;  /**< Title of the user's current media.  */
+	char *media_artist; /**< Artist of the user's current media. */
+	char *media_album;  /**< Album of the user's current media.  */
 
-typedef struct _MsnUserPhoneInfo
-{
-	char *home;     /**< Home phone number.   */
-	char *work;     /**< Work phone number.   */
-	char *mobile;   /**< Mobile phone number. */
-} MsnUserPhoneInfo;
+	char *phone_home;   /**< E.T. uses this.                     */
+	char *phone_work;   /**< Work phone number.                  */
+	char *phone_mobile; /**< Mobile phone number.                */
+} MsnUserExtendedInfo;
 
 /**
  * A user.
@@ -82,11 +87,10 @@
 
 	const char *status;     /**< The state of the user.         */
 	char *statusline;       /**< The state of the user.         */
-	CurrentMedia *media;    /**< Current media of the user.     */
 
 	gboolean idle;          /**< The idle state of the user.    */
 
-	MsnUserPhoneInfo *phone; /**< This user's phone numbers.    */
+	MsnUserExtendedInfo *extinfo; /**< Extended info for the user. */
 
 	gboolean authorized;    /**< Authorized to add this user.   */
 	gboolean mobile;        /**< Signed up with MSN Mobile.     */
@@ -155,15 +159,6 @@
   */
 void msn_user_set_statusline(MsnUser *user, const char *statusline);
 
- /**
-  *  Sets the current media of user.
-  *
-  *  @param user   The user.
-  *  @param cmedia Current media.  This function takes ownership of this
-  *         object and its contents.
-  */
-void msn_user_set_currentmedia(MsnUser *user, CurrentMedia *cmedia);
-
 /**
  * Sets the new state of user.
  *
--- a/libpurple/protocols/msn/userlist.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/msn/userlist.c	Fri Feb 05 14:40:39 2010 +0000
@@ -334,14 +334,10 @@
 
 	for (l = userlist->users; l != NULL; l = l->next) {
 		MsnUser *user = (MsnUser *)l->data;
+		const char *user_number = msn_user_get_mobile_phone(user);
 
-		if (!user->phone || !user->phone->mobile) {
-			continue;
-		}
-
-		if (!g_ascii_strcasecmp(number, user->phone->mobile)) {
+		if (user_number && !g_ascii_strcasecmp(number, user_number))
 			return user;
-		}
 	}
 
 	return NULL;
--- a/libpurple/protocols/myspace/myspace.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Fri Feb 05 14:40:39 2010 +0000
@@ -251,7 +251,6 @@
 	MsimMessage *msg;
 	const gchar *from_username;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(who != NULL, FALSE);
 	g_return_val_if_fail(text != NULL, FALSE);
 
@@ -344,8 +343,6 @@
 {
 	guint rid;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
-
 	rid = session->next_rid++;
 
 	g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb);
@@ -394,8 +391,6 @@
 	gc = purple_account_get_connection(account);
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
-
 	display_name = headline = NULL;
 
 	/* Retrieve display name and/or headline, depending on user preference. */
@@ -442,11 +437,9 @@
 		MsimSession *session;
 		PurpleAccount *account = purple_buddy_get_account(buddy);
 		PurpleConnection *gc = purple_account_get_connection(account);
- 
+
 		session = (MsimSession *)gc->proto_data;
 
-		g_return_if_fail(MSIM_SESSION_VALID(session));
-
 		/* TODO: if (full), do something different? */
 
 		/* TODO: request information? have to figure out how to do
@@ -694,7 +687,6 @@
 	gsize nc_len;
 	gboolean ret;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE);
@@ -783,7 +775,6 @@
 static gboolean
 msim_is_username_set(MsimSession *session, MsimMessage *msg)
 {
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 	g_return_val_if_fail(session->gc != NULL, FALSE);
 
@@ -842,8 +833,6 @@
 
 	session = (MsimSession *)data;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
-
 	delta = time(NULL) - session->last_comm;
 
 	/* purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); */
@@ -970,11 +959,6 @@
 
 	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,
@@ -1215,8 +1199,6 @@
 {
 	MsimMessage *body;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
-
 	/* Set display name to username (otherwise will show email address) */
 	purple_connection_set_display_name(session->gc, session->username);
 
@@ -1382,7 +1364,6 @@
 	gchar *username;
 	gchar *unrecognized_msg;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	/* Helpfully looked up by msim_incoming_resolve() for us. */
@@ -1577,7 +1558,6 @@
 	gchar *msg_text, *username;
 	gboolean rc;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	msg_text = msim_msg_get_string(msg, "msg");
@@ -1797,7 +1777,6 @@
 	gpointer data;
 	guint rid, cmd, dsn, lid;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	msim_store_user_info(session, msg, NULL);
@@ -1848,7 +1827,6 @@
 	gchar *errmsg, *full_errmsg;
 	guint err;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	err = msim_msg_get_integer(msg, "err");
@@ -1962,7 +1940,6 @@
 	gchar *username;
 	MsimMessage *msg, *body;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(userinfo != NULL);
 
 	body = msim_msg_get_dictionary(userinfo, "body");
@@ -1998,7 +1975,6 @@
 static gboolean
 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg)
 {
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) {
@@ -2071,7 +2047,6 @@
 	}
 
 	g_return_if_fail(cond == PURPLE_INPUT_READ);
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 
 	/* Mark down that we got data, so we don't timeout. */
 	session->last_comm = time(NULL);
@@ -2282,31 +2257,27 @@
 	GSList *buddies;
 	MsimSession *session;
 
+	if (gc == NULL) {
+		return;
+	}
+
 	/*
 	 * Free our protocol-specific buddy data.  It almost seems like libpurple
 	 * should call our buddy_free prpl callback so that we don't need to do
 	 * this... but it doesn't, so we do.
 	 */
-	buddies = purple_blist_get_buddies();
+	buddies = purple_find_buddies(purple_connection_get_account(gc), NULL);
 	while (buddies != NULL) {
 		msim_buddy_free(buddies->data);
 		buddies = g_slist_delete_link(buddies, buddies);
 	}
 
-	if (gc == NULL) {
-		return;
-	}
-
 	session = (MsimSession *)gc->proto_data;
 	if (session == NULL)
 		return;
 
 	gc->proto_data = NULL;
 
-	if (!MSIM_SESSION_VALID(session)) {
-		return;
-	}
-
 	if (session->gc->inpa) {
 		purple_input_remove(session->gc->inpa);
 	}
@@ -2348,8 +2319,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
-
 	message_msim = html_to_msim_markup(session, message);
 
 	if (msim_send_bm(session, who, message_msim, MSIM_BM_ACTION_OR_IM_DELAYABLE)) {
@@ -2390,8 +2359,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), 0);
-
 	switch (state) {
 		case PURPLE_TYPING:
 			typing_str = "%typing%";
@@ -2421,8 +2388,6 @@
 	PurpleNotifyUserInfo *user_info;
 	MsimUser *user;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	/* Get user{name,id} from msim_get_info, passed as an MsimMessage for
 	   orthogonality. */
 	msg = (MsimMessage *)data;
@@ -2480,8 +2445,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	/* Obtain uid of buddy. */
 	user = msim_find_user(session, username);
 
@@ -2515,7 +2478,6 @@
 static void
 msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring)
 {
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(statstring != NULL);
 
 	purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n",
@@ -2548,8 +2510,6 @@
 
 	session = (MsimSession *)account->gc->proto_data;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	type = purple_status_get_type(status);
 	pres = purple_status_get_presence(status);
 
@@ -2613,8 +2573,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	status = purple_account_get_active_status(session->account);
 
 	if (time == 0) {
@@ -3005,8 +2963,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
-
 	/* Loop until all data is sent, or a failure occurs. */
 	total_bytes_sent = 0;
 	do {
@@ -3041,7 +2997,6 @@
 {
 	size_t len;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg);
--- a/libpurple/protocols/myspace/session.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/myspace/session.c	Fri Feb 05 14:40:39 2010 +0000
@@ -76,8 +76,6 @@
 void
 msim_session_destroy(MsimSession *session)
 {
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	session->magic = -1;
 
 	g_free(session->rxbuf);
--- a/libpurple/protocols/myspace/session.h	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/myspace/session.h	Fri Feb 05 14:40:39 2010 +0000
@@ -54,9 +54,6 @@
 	guint inbox_handle;                 /**< The handle for the mail check timer */
 } MsimSession;
 
-/* Check if an MsimSession is valid */
-#define MSIM_SESSION_VALID(s) (session != NULL && session->magic == MSIM_SESSION_STRUCT_MAGIC)
-
 MsimSession *msim_session_new(PurpleAccount *acct);
 void msim_session_destroy(MsimSession *session);
 
--- a/libpurple/protocols/myspace/user.c	Fri Feb 05 14:38:53 2010 +0000
+++ b/libpurple/protocols/myspace/user.c	Fri Feb 05 14:40:39 2010 +0000
@@ -414,7 +414,6 @@
 	gchar *username;
 	MsimMessage *body, *body_node;
 
-	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	body = msim_msg_get_dictionary(msg, "body");
@@ -566,7 +565,6 @@
 	gchar *field_name;
 	guint rid, cmd, dsn, lid;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(user != NULL);
 	/* Callback can be null to not call anything, just lookup & store information. */
 	/*g_return_if_fail(cb != NULL);*/
@@ -626,8 +624,6 @@
 
 	purple_debug_info("msim","username_is_set made\n");
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	cmd = msim_msg_get_integer(userinfo, "cmd");
 	dsn = msim_msg_get_integer(userinfo, "dsn");
 	uid = msim_msg_get_integer(userinfo, "uid");
@@ -707,7 +703,6 @@
 	MsimMessage *body;
 	guint rid;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(username != NULL);
 	g_return_if_fail(cb != NULL);
 
@@ -754,9 +749,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
-
 	user_msg = msim_msg_new(
 			"user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set),
 			NULL);
@@ -783,7 +775,6 @@
 	purple_debug_info("msim_username_is_available_cb", "Look up username callback made\n");
 
 	msg = (MsimMessage *)data;
-	g_return_if_fail(MSIM_SESSION_VALID(session));
 	g_return_if_fail(msg != NULL);
 
 	username = msim_msg_get_string(msg, "user");
@@ -851,8 +842,6 @@
 
 	session = (MsimSession *)gc->proto_data;
 
-	g_return_if_fail(MSIM_SESSION_VALID(session));
-
 	purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check);
 
 	user_msg = msim_msg_new(