changeset 23488:8aa7e01bc4d5

An MSN patch from Masca to check if there's a SB available before sending OIM's. References #4877.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 20 Jun 2008 04:58:20 +0000
parents d65150b5622f
children 20da64b2e104
files libpurple/protocols/msn/msn.c
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Tue Jun 17 05:38:12 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Jun 20 04:58:20 2008 +0000
@@ -1095,6 +1095,8 @@
 {
 	PurpleAccount *account;
 	PurpleBuddy *buddy = purple_find_buddy(gc->account, who);
+	MsnSession *session;
+	MsnSwitchBoard *swboard;
 	MsnMessage *msg;
 	char *msgformat;
 	char *msgtext;
@@ -1104,6 +1106,9 @@
 	account = purple_connection_get_account(gc);
 	username = purple_account_get_username(account);
 
+	session = gc->proto_data;
+	swboard = msn_session_find_swboard(session, who);
+
 	if (buddy) {
 		PurplePresence *p = purple_buddy_get_presence(buddy);
 		if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
@@ -1115,13 +1120,12 @@
 	}
 
 	msn_import_html(message, &msgformat, &msgtext);
-	/* this is incorrect, we should try to initiate a connection to the
-	   buddy first, and only falls back if that fails. Otherwise we can
-	   only send offline message to invisible buddies */
 	if (msn_user_is_online(account, who)||
-		msn_user_is_yahoo(account, who)){
-		/*User online,then send Online Instant Message*/
-
+		msn_user_is_yahoo(account, who) ||
+		swboard != NULL){
+		/*User online or have a swboard open because it's invisible
+		 * and sent us a message,then send Online Instant Message*/
+ 
 		if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
 		{
 			g_free(msgformat);
@@ -1140,13 +1144,10 @@
 		purple_debug_info("MSNP14","prepare to send online Message\n");
 		if (g_ascii_strcasecmp(who, username))
 		{
-			MsnSession *session;
-			MsnSwitchBoard *swboard;
 			MsnEmoticon *smile;
 			GSList *smileys;
 			GString *emoticons = NULL;
 
-			session = gc->proto_data;
 			if(msn_user_is_yahoo(account,who)){
 				/*we send the online and offline Message to Yahoo User via UBM*/
 				purple_debug_info("MSNP14","send to Yahoo User\n");
@@ -1203,11 +1204,9 @@
 		msn_message_destroy(msg);
 	} else {
 		/*send Offline Instant Message,only to MSN Passport User*/
-		MsnSession *session;
 		char *friendname;
 
 		purple_debug_info("MSNP14","prepare to send offline Message\n");
-		session = gc->proto_data;
 
 		friendname = msn_encode_mime(account->username);
 		msn_oim_prep_send_msg_info(session->oim,