changeset 9363:997c28571364

[gaim-migrate @ 10171] Patches by Felipe (shx) to clean up some code, add some segfault precautions, fix chats so that we'll see the other users in the chat correctly after invites, and to have MSN ignore the local buddy list adds if we're not already signed on (which fixes a *very* annoying bug I was having). Thanks again! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 23 Jun 2004 19:38:58 +0000
parents 72c88ac84afa
children 63f07fa577eb
files src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/session.h src/protocols/msn/switchboard.c src/protocols/msn/sync.c
diffstat 5 files changed, 36 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/msn.c	Wed Jun 23 18:34:37 2004 +0000
+++ b/src/protocols/msn/msn.c	Wed Jun 23 19:38:58 2004 +0000
@@ -294,7 +294,6 @@
 {
 	GaimBuddy *buddy;
 	GaimConnection *gc;
-	MsnUser *user;
 	MsnSession *session;
 	MsnMobileData *data;
 
@@ -304,7 +303,6 @@
 	gc = gaim_account_get_connection(buddy->account);
 
 	session = gc->proto_data;
-	user = msn_userlist_find_user(session->userlist, buddy->name);
 
 	data = g_new0(MsnMobileData, 1);
 	data->gc = gc;
@@ -340,6 +338,9 @@
 	/* TODO: This might move somewhere else, after USR might be */
 	swboard->chat_id = session->conv_seq++;
 	swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat");
+
+	gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
+							gaim_account_get_username(buddy->account), NULL);	
 }
 
 static void
@@ -812,6 +813,9 @@
 	userlist = session->userlist;
 	who = msn_normalize(gc->account, buddy->name);
 
+	if (!session->logged_in)
+		return;
+
 	if (group != NULL && group->name != NULL)
 		gaim_debug_info("msn", "msn_add_buddy: %s, %s\n", who, group->name);
 	else
@@ -842,6 +846,9 @@
 	session = gc->proto_data;
 	userlist = session->userlist;
 
+	if (!session->logged_in)
+		return;
+
 	/* XXX - Does buddy->name need to be msn_normalize'd here?  --KingAnt */
 	msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name);
 }
@@ -857,7 +864,10 @@
 	userlist = session->userlist;
 	user = msn_userlist_find_user(userlist, who);
 
-	if (user->list_op & MSN_LIST_BL_OP)
+	if (!session->logged_in)
+		return;
+
+	if (user != NULL && user->list_op & MSN_LIST_BL_OP)
 		msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL);
 
 	msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
@@ -874,7 +884,10 @@
 	userlist = session->userlist;
 	user = msn_userlist_find_user(userlist, who);
 
-	if (user->list_op & MSN_LIST_AL_OP)
+	if (!session->logged_in)
+		return;
+
+	if (user != NULL && user->list_op & MSN_LIST_AL_OP)
 		msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL);
 
 	msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
@@ -890,11 +903,14 @@
 	session = gc->proto_data;
 	userlist = session->userlist;
 
+	if (!session->logged_in)
+		return;
+
 	user = msn_userlist_find_user(userlist, who);
 
 	msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL);
 
-	if (user->list_op & MSN_LIST_RL_OP)
+	if (user != NULL && user->list_op & MSN_LIST_RL_OP)
 		msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
 }
 
@@ -908,11 +924,14 @@
 	session = gc->proto_data;
 	userlist = session->userlist;
 
+	if (!session->logged_in)
+		return;
+
 	user = msn_userlist_find_user(userlist, who);
 
 	msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL);
 
-	if (user->list_op & MSN_LIST_RL_OP)
+	if (user != NULL && user->list_op & MSN_LIST_RL_OP)
 		msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
 }
 
--- a/src/protocols/msn/notification.c	Wed Jun 23 18:34:37 2004 +0000
+++ b/src/protocols/msn/notification.c	Wed Jun 23 19:38:58 2004 +0000
@@ -689,6 +689,8 @@
 	if (total_users == 0)
 	{
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
+		session->logged_in = TRUE;
+		
 		serv_finish_login(gc);
 	}
 	else
--- a/src/protocols/msn/session.h	Wed Jun 23 18:34:37 2004 +0000
+++ b/src/protocols/msn/session.h	Wed Jun 23 19:38:58 2004 +0000
@@ -51,6 +51,7 @@
 	int dispatch_port;
 
 	gboolean connected;
+	gboolean logged_in; /* temporal flag to ignore local blist adds */
 
 	MsnNotification *notification;
 	MsnNexus *nexus;
--- a/src/protocols/msn/switchboard.c	Wed Jun 23 18:34:37 2004 +0000
+++ b/src/protocols/msn/switchboard.c	Wed Jun 23 19:38:58 2004 +0000
@@ -66,7 +66,11 @@
 	/* gaim_debug_info("msn", "user=[%s], total=%d\n", user,
 	 * swboard->current_users); */
 
-	if (swboard->current_users > 1 || swboard->total_users > 1)
+	if (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)
+	{
+		gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), user, NULL);
+	}
+	else if (swboard->current_users > 1 || swboard->total_users > 1)
 	{
 		if (swboard->conv == NULL ||
 			gaim_conversation_get_type(swboard->conv) != GAIM_CONV_CHAT)
@@ -98,16 +102,6 @@
 										tmp_user, NULL);
 			}
 
-			if (!swboard->invited)
-			{
-				/* gaim_debug_info("msn", "[chat] "
-								"Not invited, so we add im_user [%s].\n",
-								swboard->im_user); */
-
-				gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
-										swboard->im_user, NULL);
-			}
-
 			/* gaim_debug_info("msn", "[chat] We add ourselves.\n"); */
 
 			gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
@@ -117,10 +111,6 @@
 			g_free(swboard->im_user);
 			swboard->im_user = NULL;
 		}
-		else if (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)
-		{
-			gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), user, NULL);
-		}
 	}
 	else if (swboard->conv == NULL)
 	{
@@ -128,7 +118,7 @@
 	}
 	else
 	{
-		gaim_debug_warning("msn", "This should happen!"
+		gaim_debug_warning("msn", "This should not happen!"
 						   "(msn_switchboard_add_user)\n");
 	}
 }
--- a/src/protocols/msn/sync.c	Wed Jun 23 18:34:37 2004 +0000
+++ b/src/protocols/msn/sync.c	Wed Jun 23 19:38:58 2004 +0000
@@ -181,6 +181,8 @@
 		msn_change_status(session, MSN_ONLINE);
 
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
+		session->logged_in = TRUE;
+
 		serv_finish_login(gc);
 
 		msn_sync_destroy(session->sync);