changeset 25886:1a1765a87336

More MSN fixes to go along with f0df27a299120baecf9ea88a9fb24ffe1dbe72fd: Add an FQY error handler so we don't disconnect if something incorrect was sent (unless the server kicked us itself). Decrement the ADL/FQY count when we receive an error about a FQY for a user so that we can continue to login even with bogus email addresses. applied changes from 54f9b89abccda90d90bcd15d12fd091279a7f54e through a1d92d07631246e44303c044d75179ba68158e8b
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 May 2009 23:08:46 +0000
parents b9a90f34b780
children de4393eba497
files libpurple/protocols/msn/notification.c
diffstat 1 files changed, 41 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Sat May 02 21:11:02 2009 +0000
+++ b/libpurple/protocols/msn/notification.c	Sat May 02 23:08:46 2009 +0000
@@ -612,8 +612,19 @@
 static void
 update_contact_network(MsnSession *session, const char *passport, MsnNetwork network)
 {
-	MsnUser *user = msn_userlist_find_user(session->userlist, passport);
+	MsnUser *user;
+
+	if (network == MSN_NETWORK_UNKNOWN)
+	{
+		purple_debug_warning("msn",
+		                     "Ignoring user %s about which server knows nothing.\n",
+		                     passport);
+		session->adl_fqy--;
+		return;
+	}
+
 	/* TODO: Also figure out how to update membership lists */
+	user = msn_userlist_find_user(session->userlist, passport);
 	if (user) {
 		xmlnode *adl_node;
 		char *payload;
@@ -774,13 +785,17 @@
 		purple_debug_info("msn", "Invalid XML in ADL!\n");
 		return;
 	}
-	for (domain_node = xmlnode_get_child(root, "d"); domain_node; domain_node = xmlnode_get_next_twin(domain_node)) {
+	for (domain_node = xmlnode_get_child(root, "d");
+	     domain_node;
+	     domain_node = xmlnode_get_next_twin(domain_node)) {
 		const gchar * domain = NULL;
 		xmlnode *contact_node = NULL;
 
 		domain = xmlnode_get_attrib(domain_node, "n");
 
-		for (contact_node = xmlnode_get_child(domain_node, "c"); contact_node; contact_node = xmlnode_get_next_twin(contact_node)) {
+		for (contact_node = xmlnode_get_child(domain_node, "c");
+		     contact_node;
+		     contact_node = xmlnode_get_next_twin(contact_node)) {
 			const gchar *list;
 			gint list_op = 0;
 
@@ -942,10 +957,10 @@
 
 			passport = g_strdup_printf("%s@%s", local, domain);
 
-			if (type != NULL)
+			if (!g_ascii_isdigit(cmd->command[0]) && type != NULL)
 				network = (MsnNetwork)strtoul(type, NULL, 10);
 			else
-				network = MSN_NETWORK_PASSPORT;
+				network = MSN_NETWORK_UNKNOWN;
 
 			purple_debug_info("msn", "FQY response says %s is from network %d\n",
 			                  passport, network);
@@ -960,6 +975,26 @@
 }
 
 static void
+fqy_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error)
+{
+	MsnCommand *cmd = cmdproc->last_cmd;
+
+	purple_debug_warning("msn", "FQY error %d\n", error);
+	if (cmd->param_count > 1) {
+		cmd->payload_cb = fqy_cmd_post;
+		cmd->payload_len = atoi(cmd->params[1]);
+		cmd->payload_cbdata = GINT_TO_POINTER(error);
+	}
+#if 0
+	/* If the server didn't send us a corresponding email address for this
+	   FQY error, it's probably going to disconnect us. So it isn't necessary
+	   to tell the handler about it. */
+	else if (trans->data)
+		((MsnFqyCb)trans->data)(session, NULL, MSN_NETWORK_UNKNOWN); */
+#endif
+}
+
+static void
 fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
 	purple_debug_info("msn", "Process FQY\n");
@@ -2153,6 +2188,7 @@
 
 	msn_table_add_error(cbs_table, "ADD", add_error);
 	msn_table_add_error(cbs_table, "ADL", adl_error);
+	msn_table_add_error(cbs_table, "FQY", fqy_error);
 	msn_table_add_error(cbs_table, "REG", reg_error);
 	msn_table_add_error(cbs_table, "RMG", rmg_error);
 	msn_table_add_error(cbs_table, "USR", usr_error);