changeset 23566:a0e957b7b923

Take care of more cleanup in the MSN code. No more C++ style comments. msn_convert_iso8601 was replaced with purple_str_to_time everywhere, so remove it. REM and SYN were removed in MSNP13. REA was removed in MSNP11. PRP and BLP were added already, so remove the TODO. Contact information is now taken from the contact server, so remove all that commented code from the ADL command.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 12 Jul 2008 06:44:19 +0000
parents 9acfa387c0a2
children 3670d6c05da2 a2f06797a1b0
files libpurple/protocols/msn/contact.c libpurple/protocols/msn/group.h libpurple/protocols/msn/msnutils.c libpurple/protocols/msn/nexus.h libpurple/protocols/msn/notification.c libpurple/protocols/msn/soap.c libpurple/protocols/msn/sync.c libpurple/protocols/msn/user.h libpurple/protocols/msn/userlist.c
diffstat 9 files changed, 28 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/contact.c	Sat Jul 12 06:44:19 2008 +0000
@@ -939,8 +939,9 @@
 
 	purple_debug_info("msn", "Contact added successfully\n");
 
-	// the code this block is replacing didn't send ADL for yahoo contacts,
-	// but i haven't confirmed this is WLM's behaviour wrt yahoo contacts
+	/* the code this block is replacing didn't send ADL for yahoo contacts,
+	 * but i haven't confirmed this is WLM's behaviour wrt yahoo contacts
+	 */
 	if ( !msn_user_is_yahoo(session->account, state->who) ) {
 		msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_AL);
 		msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_FL);
@@ -1562,7 +1563,7 @@
 	}
 
 	if ( !strcmp(guid, MSN_INDIVIDUALS_GROUP_ID) || !strcmp(guid, MSN_NON_IM_GROUP_ID) ) {
-		// XXX add back PurpleGroup since it isn't really removed in the server?
+		/* XXX add back PurpleGroup since it isn't really removed in the server? */
 		return;
 	}
 
@@ -1608,7 +1609,7 @@
 	if ( !strcmp(guid, MSN_INDIVIDUALS_GROUP_ID) || !strcmp(guid, MSN_NON_IM_GROUP_ID) ) {
 		MsnCallbackState *new_state = msn_callback_state_dup(state);
 		msn_add_group(session, new_state, new_group_name);
-		// XXX move every buddy there (we probably need to fix concurrent SOAP reqs first)
+		/* XXX move every buddy there (we probably need to fix concurrent SOAP reqs first) */
 	}
 
 	msn_callback_state_set_action(state, MSN_RENAME_GROUP);
--- a/libpurple/protocols/msn/group.h	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/group.h	Sat Jul 12 06:44:19 2008 +0000
@@ -49,9 +49,9 @@
 	char *name;             /**< The name of the group.     */
 };
 
-/**************************************************************************/
-/** @name Group API                                                       */
-/**************************************************************************/
+/**************************************************************************
+ ** @name Group API                                                       *
+ **************************************************************************/
 /*@{*/
 
 /**
@@ -105,4 +105,6 @@
  * @return The name.
  */
 const char *msn_group_get_name(const MsnGroup *group);
+
 #endif /* _MSN_GROUP_H_ */
+
--- a/libpurple/protocols/msn/msnutils.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/msnutils.c	Sat Jul 12 06:44:19 2008 +0000
@@ -23,7 +23,6 @@
  */
 #include "msn.h"
 #include "msnutils.h"
-#include "time.h"
 
 #include "cipher.h"
 
@@ -476,30 +475,6 @@
 	*ret_host = host;
 	*ret_port = port;
 }
-/***************************************************************************
- * MSN Time Related Funciton
- ***************************************************************************/
-#if 0
-int
-msn_convert_iso8601(const char *timestr,struct tm tm_time)
-{
-	char temp[64];
-	struct tm ctime;
-	time_t ts;
-
-	purple_debug_info("msn", "convert string is{%s}\n", timestr);
-	tzset();
-	/*copy string first*/
-	memset(temp, 0, sizeof(temp));
-	strncpy(temp, timestr, strlen(timestr));
-
-	/*convert via strptime()*/
-	memset(&ctime, 0, sizeof(struct tm));
-	strptime(temp, "%d %b %Y %T %Z", &ctime);
-	ts = mktime(&ctime) - timezone;
-	localtime_r(&ts, tm_time);
-}
-#endif
 
 /***************************************************************************
  * MSN Challenge Computing Function
--- a/libpurple/protocols/msn/nexus.h	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/nexus.h	Sat Jul 12 06:44:19 2008 +0000
@@ -186,14 +186,14 @@
 typedef struct _MsnUsrKey MsnUsrKey;
 struct _MsnUsrKey
 {
-	int size; // 28. Does not count data
-	int crypt_mode; // CRYPT_MODE_CBC (1)
-	int cipher_type; // TripleDES (0x6603)
-	int hash_type; // SHA1 (0x8004)
-	int iv_len;    // 8
-	int hash_len;  // 20
-	int cipher_len; // 72
-	// Data
+	int size; /* 28. Does not count data */
+	int crypt_mode; /* CRYPT_MODE_CBC (1) */
+	int cipher_type; /* TripleDES (0x6603) */
+	int hash_type; /* SHA1 (0x8004) */
+	int iv_len;    /* 8 */
+	int hash_len;  /* 20 */
+	int cipher_len; /* 72 */
+	/* Data */
 	char iv[8];
 	char hash[20];
 	char cipher[72];
--- a/libpurple/protocols/msn/notification.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/notification.c	Sat Jul 12 06:44:19 2008 +0000
@@ -228,16 +228,7 @@
 	if (!g_ascii_strcasecmp(cmd->params[1], "OK"))
 	{
 		/* authenticate OK */
-		/* friendly name part no longer true in msnp11 */
-#if 0
-		const char *friendly = purple_url_decode(cmd->params[3]);
-
-		purple_connection_set_display_name(gc, friendly);
-#endif
 		msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN);
-
-//		msn_cmdproc_send(cmdproc, "SYN", "%s", "0");
-		//TODO we should use SOAP contact to fetch contact list
 	}
 	else if (!g_ascii_strcasecmp(cmd->params[1], "SSO"))
 	{
@@ -315,8 +306,6 @@
 	 * to see the Local ID
 	 */
 	msn_cmdproc_send(cmdproc, "CVR",
-//					 "0x0409 winnt 5.1 i386 MSG80BETA 8.0.0689 msmsgs %s",
-//					"0x0804 winnt 5.1 i386 MSNMSGR 8.0.0792 msmsgs %s",
 					"0x0409 winnt 5.1 i386 MSNMSGR 8.5.1288 msmsgs %s",
 					 purple_account_get_username(account));
 }
@@ -722,33 +711,18 @@
 		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)) {
-//			gchar *name = NULL, *friendlyname = NULL, *passport= NULL;
 			const gchar *list;
 			gint list_op = 0;
 
-//			name = xmlnode_get_attrib(contact_node, "n");
 			list = xmlnode_get_attrib(contact_node, "l");
 			if (list != NULL) {
 				list_op = atoi(list);
 			}
-//			friendlyname = xmlnode_get_attrib(contact_node, "f");
-
-//			passport = g_strdup_printf("%s@%s", name, domain);
-
-//			if (friendlyname != NULL) {
-//				decoded_friendlyname = g_strdup(purple_url_decode(friendlyname));
-//			} else {
-//				decoded_friendlyname = g_strdup(passport);
-//			}
 
 			if (list_op & MSN_LIST_RL_OP) {
 				/* someone is adding us */
-//				got_new_entry(cmdproc->session->account->gc, passport, decoded_friendly_name);
 				msn_get_contact_list(cmdproc->session, MSN_PS_PENDING_LIST, NULL);
 			}
-
-//			g_free(decoded_friendly_name);
-//			g_free(passport);
 		}
 	}
 
@@ -802,8 +776,8 @@
 {
 	purple_debug_info("msn", "FQY payload:\n%s\n", payload);
 	g_return_if_fail(cmdproc->session != NULL);
-//	msn_notification_post_adl(cmdproc, payload, len);
-//	msn_get_address_book(cmdproc->session, MSN_AB_SAVE_CONTACT, NULL, NULL);
+/*	msn_notification_post_adl(cmdproc, payload, len); */
+/*	msn_get_address_book(cmdproc->session, MSN_AB_SAVE_CONTACT, NULL, NULL); */
 }
 
 static void
@@ -936,7 +910,7 @@
 			msn_userlist_move_buddy(userlist, data->who, data->old_group_name, group_name);
 			g_free(data->old_group_name);
 		} else {
-			// msn_add_contact_to_group(userlist, data, data->who, group_name);
+			/* msn_add_contact_to_group(userlist, data, data->who, group_name); */
 		}
 	}
 }
@@ -1194,35 +1168,6 @@
 }
 
 static void
-rea_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
-{
-	MsnSession *session;
-	PurpleAccount *account;
-	PurpleConnection *gc;
-	const char *friendly;
-	char *username;
-
-	session = cmdproc->session;
-	account = session->account;
-	username = g_strdup(purple_normalize(account,
-						purple_account_get_username(account)));
-
-	/* Only set display name if our *own* friendly name changed! */
-	if (strcmp(username, purple_normalize(account, cmd->params[2])))
-	{
-		g_free(username);
-		return;
-	}
-
-	g_free(username);
-
-	gc = account->gc;
-	friendly = purple_url_decode(cmd->params[3]);
-
-	purple_connection_set_display_name(gc, friendly);
-}
-
-static void
 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
 	MsnSession *session = cmdproc->session;
@@ -1845,10 +1790,6 @@
 		/* This isn't an official message. */
 		return;
 
-	/*new a oim session*/
-//	session->oim = msn_oim_new(session);
-//	msn_oim_connect(session->oim);
-
 	table = msn_message_get_hashtable_from_body(msg);
 
 	mdata = g_hash_table_lookup(table, "Mail-Data");
@@ -2069,25 +2010,19 @@
 void
 msn_notification_init(void)
 {
-	/* TODO: check prp, blp */
-
 	cbs_table = msn_table_new();
 
 	/* Synchronous */
 	msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL);
 	msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd);
 	msn_table_add_cmd(cbs_table, "ADL", "ILN", iln_cmd);
-//	msn_table_add_cmd(cbs_table, "REM", "REM", rem_cmd);	/* Removed as of MSNP13 */
 	msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd);
 	msn_table_add_cmd(cbs_table, "USR", "XFR", xfr_cmd);
 	msn_table_add_cmd(cbs_table, "USR", "GCF", gcf_cmd);
-//	msn_table_add_cmd(cbs_table, "SYN", "SYN", syn_cmd);	/* Removed as of MSNP13 */
 	msn_table_add_cmd(cbs_table, "CVR", "CVR", cvr_cmd);
 	msn_table_add_cmd(cbs_table, "VER", "VER", ver_cmd);
-	msn_table_add_cmd(cbs_table, "REA", "REA", rea_cmd);
 	msn_table_add_cmd(cbs_table, "PRP", "PRP", prp_cmd);
 	msn_table_add_cmd(cbs_table, "BLP", "BLP", blp_cmd);
-//	msn_table_add_cmd(cbs_table, "BLP", "BLP", NULL);
 	msn_table_add_cmd(cbs_table, "REG", "REG", reg_cmd);
 	msn_table_add_cmd(cbs_table, "ADG", "ADG", adg_cmd);
 	msn_table_add_cmd(cbs_table, "RMG", "RMG", rmg_cmd);
@@ -2125,7 +2060,6 @@
 	msn_table_add_error(cbs_table, "ADL", adl_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, "REA", rea_error); */
 	msn_table_add_error(cbs_table, "USR", usr_error);
 
 	msn_table_add_msg_type(cbs_table,
--- a/libpurple/protocols/msn/soap.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/soap.c	Sat Jul 12 06:44:19 2008 +0000
@@ -288,13 +288,13 @@
 	if(cnt < 0 && errno == EAGAIN && count == 0)
 		return;
 
-	// msn_soap_process could alter errno
+	/* msn_soap_process could alter errno */
 	perrno = errno;
 	msn_soap_process(conn);
 	
 	if (cnt < 0 && perrno != EAGAIN) {
 		purple_debug_info("soap", "read: %s\n", g_strerror(perrno));
-		// It's possible msn_soap_process closed the ssl connection
+		/* It's possible msn_soap_process closed the ssl connection */
 		if (conn->ssl) {
 			purple_ssl_close(conn->ssl);
 			conn->ssl = NULL;
--- a/libpurple/protocols/msn/sync.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/sync.c	Sat Jul 12 06:44:19 2008 +0000
@@ -216,8 +216,6 @@
 void
 msn_sync_init(void)
 {
-	/* TODO: check prp, blp, bpr */
-
 	cbs_table = msn_table_new();
 
 	/* Syncing */
--- a/libpurple/protocols/msn/user.h	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/user.h	Sat Jul 12 06:44:19 2008 +0000
@@ -97,9 +97,9 @@
 				     indexed by the list it belongs to		*/
 };
 
-/**************************************************************************/
-/** @name User API                                                        */
-/**************************************************************************/
+/**************************************************************************
+ ** @name User API                                                        *
+ **************************************************************************/
 /*@{*/
 
 /**
--- a/libpurple/protocols/msn/userlist.c	Sat Jul 12 04:50:47 2008 +0000
+++ b/libpurple/protocols/msn/userlist.c	Sat Jul 12 06:44:19 2008 +0000
@@ -138,36 +138,6 @@
 		return FALSE;
 }
 
-#if 0
-static const char*
-get_friendly_name(MsnUser *user)
-{
-	const char *friendly_name;
-
-	g_return_val_if_fail(user != NULL, NULL);
-
-	friendly_name = msn_user_get_friendly_name(user);
-
-	if (friendly_name != NULL)
-		friendly_name = purple_url_encode(friendly_name);
-	else
-		friendly_name = msn_user_get_passport(user);
-
-	/* this might be a bit of a hack, but it should prevent notification server
-	 * disconnections for people who have buddies with insane friendly names
-	 * who added you to their buddy list from being disconnected. Stu. */
-	/* Shx: What? Isn't the store_name obtained from the server, and hence it's
-	 * below the BUDDY_ALIAS_MAXLEN ? */
-	/* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're
-	 * probably decoding the incoming store_name wrong, or something. bleh. */
-
-	if (strlen(friendly_name) > BUDDY_ALIAS_MAXLEN)
-		friendly_name = msn_user_get_passport(user);
-
-	return friendly_name;
-}
-#endif
-
 /**************************************************************************
  * Server functions
  **************************************************************************/
@@ -256,7 +226,7 @@
 			 *       looked at this.  Maybe we should use the store
 			 *       name instead? --KingAnt
 			 */
-//			got_new_entry(gc, passport, friendly);
+/*			got_new_entry(gc, passport, friendly); */
 		}
 	}
 
@@ -386,7 +356,7 @@
 
 		if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP)))
 		{
-//			got_new_entry(gc, passport, store);
+/*			got_new_entry(gc, passport, store); */
 		}
 	}
 
@@ -779,10 +749,6 @@
 		return;
 	}
 
-	//friendly_name = (user != NULL) ? get_friendly_name(user) : who;
-
-	//purple_debug_info("msn", "store_name = %s\n", store_name);
-
 	/* XXX: see XXX above, this should really be done when we get the response from
 		the server */