diff src/protocols/msn/msnslp.c @ 8646:1e211dde3cae

[gaim-migrate @ 9398] Added a patch by shx to clean up the message-handling code and split the command stuff from it, among a few other things. Also, I fixed a crash in message parsing, which I think may close a couple bug reports. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 13 Apr 2004 04:08:22 +0000
parents 06f57183e29f
children f32ee2e97b37
line wrap: on
line diff
--- a/src/protocols/msn/msnslp.c	Tue Apr 13 03:53:37 2004 +0000
+++ b/src/protocols/msn/msnslp.c	Tue Apr 13 04:08:22 2004 +0000
@@ -59,8 +59,7 @@
 
 static void
 msn_slp_session_send_message(MsnSlpSession *slpsession,
-							 MsnMessage *source_msg,
-							 MsnUser *local_user, MsnUser *remote_user,
+							 const char *local_user, const char *remote_user,
 							 const char *header, const char *branch,
 							 int cseq, const char *call_id,
 							 const char *content)
@@ -73,16 +72,6 @@
 	g_return_if_fail(branch     != NULL);
 	g_return_if_fail(call_id    != NULL);
 
-	if (source_msg != NULL)
-	{
-		if (msn_message_is_incoming(source_msg))
-			remote_user = msn_message_get_sender(source_msg);
-		else
-			remote_user = msn_message_get_receiver(source_msg);
-
-		local_user = slpsession->swboard->servconn->session->user;
-	}
-
 	if (branch == NULL)
 		branch = "null";
 
@@ -100,8 +89,8 @@
 		"%s"
 		"\r\n\r\n",
 		header,
-		msn_user_get_passport(remote_user),
-		msn_user_get_passport(local_user),
+		remote_user,
+		local_user,
 		branch, cseq, call_id,
 		(content == NULL ? 0  : (int)strlen(content) + 5),
 		(content == NULL ? "" : content));
@@ -110,9 +99,6 @@
 
 	invite_msg = msn_message_new_msnslp();
 
-	msn_message_set_sender(invite_msg, local_user);
-	msn_message_set_receiver(invite_msg, remote_user);
-
 	msn_message_set_body(invite_msg, body);
 
 	g_free(body);
@@ -123,10 +109,15 @@
 static gboolean
 send_error_500(MsnSlpSession *slpsession, const char *call_id, MsnMessage *msg)
 {
+	MsnUser *local_user;
+
 	g_return_val_if_fail(slpsession != NULL, TRUE);
 	g_return_val_if_fail(msg        != NULL, TRUE);
 
-	msn_slp_session_send_message(slpsession, msg, NULL, NULL,
+	local_user = slpsession->swboard->servconn->session->user;
+
+	msn_slp_session_send_message(slpsession, msg->passport,
+								 msn_user_get_passport(local_user),
 								 "MSNSLP/1.0 500 Internal Error",
 								 slpsession->branch, 1, call_id, NULL);
 
@@ -146,8 +137,6 @@
 	slpsession->remaining_size -= len;
 
 	msg = msn_message_new_msnslp();
-	msn_message_set_sender(msg,   slpsession->receiver);
-	msn_message_set_receiver(msg, slpsession->sender);
 	msn_message_set_bin_data(msg, data, len);
 
 	msn_slp_session_send_msg(slpsession, msg);
@@ -197,15 +186,20 @@
 		 *
 		 * Say BYE-BYE.
 		 */
+		MsnUser *local_user;
 		char *header;
 
 		fclose(slpsession->send_fp);
 		slpsession->send_fp = NULL;
 
 		header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0",
-			msn_user_get_passport(msn_message_get_sender(msg)));
+			msg->passport);
+
+		local_user = slpsession->swboard->servconn->session->user;
 
-		msn_slp_session_send_message(slpsession, msg, NULL, NULL, header,
+		msn_slp_session_send_message(slpsession, msg->passport,
+									 msn_user_get_passport(local_user),
+									 header,
 									 "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32",
 									 0, slpsession->call_id, "");
 
@@ -300,7 +294,10 @@
 
 		if (app_id == 1)
 		{
+			MsnSession *session;
 			MsnMessage *new_msg;
+			MsnUser *local_user;
+			MsnUser *remote_user;
 			char *content;
 			char nil_body[4];
 			struct stat st;
@@ -309,7 +306,12 @@
 			content = g_strdup_printf("SessionID: %d", session_id);
 			msn_slp_session_send_ack(slpsession, msg);
 
-			msn_slp_session_send_message(slpsession, msg, NULL, NULL,
+			session = slpsession->swboard->servconn->session;
+
+			local_user = session->user;
+
+			msn_slp_session_send_message(slpsession, msg->passport,
+										 msn_user_get_passport(local_user),
 										 "MSNSLP/1.0 200 OK",
 										 branch, 1, call_id, content);
 
@@ -319,12 +321,13 @@
 			memset(nil_body, 0, sizeof(nil_body));
 
 			slpsession->session_id = session_id;
-			slpsession->receiver = msn_message_get_sender(msg);
-			slpsession->sender = slpsession->swboard->servconn->session->user;
+
+			remote_user = msn_user_new(session, msg->passport, NULL);
+
+			slpsession->receiver = remote_user;
+			slpsession->sender = session->user;
 
 			new_msg = msn_message_new_msnslp();
-			msn_message_set_sender(new_msg, slpsession->sender);
-			msn_message_set_receiver(new_msg, slpsession->receiver);
 			msn_message_set_bin_data(new_msg, nil_body, 4);
 			new_msg->msnslp_footer.app_id = 1;
 
@@ -532,7 +535,9 @@
 	header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0",
 							 msn_user_get_passport(remote_user));
 
-	msn_slp_session_send_message(slpsession, NULL, local_user, remote_user,
+	msn_slp_session_send_message(slpsession,
+								 msn_user_get_passport(local_user),
+								 msn_user_get_passport(remote_user),
 								 header, slpsession->branch, 0,
 								 slpsession->call_id, content);