changeset 30494:d7ecbc47f647

Disable direct connections when the account option is off.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 21 May 2010 04:05:14 +0000
parents 2b2549680b5d
children 4bcb8e537fc0
files libpurple/protocols/msn/slp.c
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/slp.c	Fri May 21 03:53:06 2010 +0000
+++ b/libpurple/protocols/msn/slp.c	Fri May 21 04:05:14 2010 +0000
@@ -325,6 +325,10 @@
 
 	purple_debug_info("msn", "process_transresp\n");
 
+	/* Direct connections are disabled. */
+	if (!purple_account_get_bool(slpcall->slplink->session->account, "direct_connect", TRUE))
+		return FALSE;
+
 	g_return_val_if_fail(dc != NULL, FALSE);
 	g_return_val_if_fail(dc->state == DC_STATE_CLOSED, FALSE);
 
@@ -712,8 +716,21 @@
 
 		purple_debug_info("msn", "got_invite: transreqbody received\n");
 
+		/* Direct connections may be disabled. */
+		if (!purple_account_get_bool(slplink->session->account, "direct_connect", TRUE)) {
+			msn_slp_send_ok(slpcall, branch,
+				"application/x-msnmsgr-transrespbody",
+				"Bridge: TCPv1\r\n"
+				"Listening: false\r\n"
+				"Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
+				"\r\n");
+			msn_slpcall_session_init(slpcall);
+
+			return;
+		}
+
 		/* Don't do anything if we already have a direct connection */
-		if (slpcall->slplink->dc != NULL)
+		if (slplink->dc != NULL)
 			return;
 
 		bridges = get_token(content, "Bridges: ", "\r\n");
@@ -806,10 +823,17 @@
 		char *content;
 		char *header;
 		char *nonce = NULL;
+		MsnSession *session = slpcall->slplink->session;
 		MsnSlpMessage *msg;
 		MsnDirectConn *dc;
 		MsnUser *user;
 
+		if (!purple_account_get_bool(session->account, "direct_connect", TRUE)) {
+			/* Don't attempt a direct connection if disabled. */
+			msn_slpcall_session_init(slpcall);
+			return;
+		}
+
 		if (slpcall->slplink->dc != NULL) {
 			/* If we already have an established direct connection
 			 * then just start the transfer.
@@ -818,7 +842,7 @@
 			return;
 		}
 
-		user = msn_userlist_find_user(slpcall->slplink->session->userlist,
+		user = msn_userlist_find_user(session->userlist,
 		                              slpcall->slplink->remote_user);
 		if (!user || !(user->clientid & 0xF0000000))	{
 			/* Just start a normal SB transfer. */