changeset 31436:1546ad4f93b3

Disconnect other endpoints if the MPOP setting is disabled. Refs #13017.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 02 Dec 2010 06:32:55 +0000
parents 05b3fa3725a1
children 4635d84e3292 703dd6f433a9
files libpurple/protocols/msn/notification.c
diffstat 1 files changed, 31 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Thu Dec 02 06:14:19 2010 +0000
+++ b/libpurple/protocols/msn/notification.c	Thu Dec 02 06:32:55 2010 +0000
@@ -1551,13 +1551,18 @@
 static void
 parse_user_endpoints(MsnUser *user, xmlnode *payloadNode)
 {
+	MsnSession *session;
 	xmlnode *epNode, *capsNode;
 	MsnUserEndpoint data;
 	const char *id;
 	char *caps, *tmp;
+	gboolean is_me;
 
 	purple_debug_info("msn", "Get EndpointData\n");
 
+	session = user->userlist->session;
+	is_me = (user == session->user);
+
 	msn_user_clear_endpoints(user);
 	for (epNode = xmlnode_get_child(payloadNode, "EndpointData");
 	     epNode;
@@ -1565,27 +1570,36 @@
 		id = xmlnode_get_attrib(epNode, "id");
 		capsNode = xmlnode_get_child(epNode, "Capabilities");
 
-		if (capsNode != NULL) {
-			caps = xmlnode_get_data(capsNode);
-
-			data.clientid = strtoul(caps, &tmp, 10);
-			if (tmp && *tmp)
-				data.extcaps = strtoul(tmp + 1, NULL, 10);
-			else
+		/* Disconnect others, if MPOP is disabled */
+		if (is_me
+		 && !purple_account_get_bool(session->account, "mpop", TRUE)
+		 && strncasecmp(id + 1, session->guid, 36) != 0) {
+			purple_debug_info("msn", "Disconnecting Endpoint %s\n", id);
+
+			tmp = g_strdup_printf("%s;%s", user->passport, id);
+			msn_notification_send_uun(session, tmp, MSN_UNIFIED_NOTIFICATION_MPOP, "goawyplzthxbye");
+			g_free(tmp);
+		} else {
+			if (capsNode != NULL) {
+				caps = xmlnode_get_data(capsNode);
+
+				data.clientid = strtoul(caps, &tmp, 10);
+				if (tmp && *tmp)
+					data.extcaps = strtoul(tmp + 1, NULL, 10);
+				else
+					data.extcaps = 0;
+
+				g_free(caps);
+			} else {
+				data.clientid = 0;
 				data.extcaps = 0;
-
-			g_free(caps);
-
-		} else {
-			data.clientid = 0;
-			data.extcaps = 0;
+			}
+
+			msn_user_set_endpoint_data(user, id, &data);
 		}
-
-		msn_user_set_endpoint_data(user, id, &data);
 	}
 
-	/* Need to shortcut this check, probably... */
-	if (user == user->userlist->session->user) {
+	if (is_me && purple_account_get_bool(session->account, "mpop", TRUE)) {
 		for (epNode = xmlnode_get_child(payloadNode, "PrivateEndpointData");
 		     epNode;
 		     epNode = xmlnode_get_next_twin(epNode)) {