changeset 5333:bbbf616bd924

[gaim-migrate @ 5708] We should now get notifications when the MSN server is about to go down (specifying the number of minutes). This would have been great to have last night ;) Also, added some checks so people can't spoof system messages, e-mail messages, etc. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 08 May 2003 06:14:16 +0000
parents 4d734dbc88dd
children bbf2141d30d0
files src/protocols/msn/notification.c
diffstat 1 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/notification.c	Thu May 08 04:17:01 2003 +0000
+++ b/src/protocols/msn/notification.c	Thu May 08 06:14:16 2003 +0000
@@ -1001,6 +1001,11 @@
 	MsnSession *session = servconn->session;
 	const char *value;
 
+	if (strcmp(servconn->msg_passport, "Hotmail")) {
+		/* This isn't an official message. */
+		return TRUE;
+	}
+
 	if ((value = msn_message_get_attr(msg, "kv")) != NULL)
 		session->passport_info.kv = g_strdup(value);
 
@@ -1021,6 +1026,11 @@
 	GHashTable *table;
 	const char *unread;
 
+	if (strcmp(servconn->msg_passport, "Hotmail")) {
+		/* This isn't an official message. */
+		return TRUE;
+	}
+
 	table = msn_message_get_hashtable_from_body(msg);
 
 	unread = g_hash_table_lookup(table, "Inbox-Unread");
@@ -1042,6 +1052,11 @@
 	GHashTable *table;
 	const char *from, *subject;
 
+	if (strcmp(servconn->msg_passport, "Hotmail")) {
+		/* This isn't an official message. */
+		return TRUE;
+	}
+
 	table = msn_message_get_hashtable_from_body(msg);
 
 	from    = g_hash_table_lookup(table, "From");
@@ -1061,6 +1076,47 @@
 }
 
 static gboolean
+__system_msg(MsnServConn *servconn, const MsnMessage *msg)
+{
+	GHashTable *table;
+	const char *type_s;
+
+	if (strcmp(servconn->msg_passport, "Hotmail")) {
+		/* This isn't an official message. */
+		return TRUE;
+	}
+
+	table = msn_message_get_hashtable_from_body(msg);
+
+	if ((type_s = g_hash_table_lookup(table, "Type")) != NULL) {
+		int type = atoi(type_s);
+		char buf[MSN_BUF_LEN];
+
+		switch (type) {
+			case 1:
+				g_snprintf(buf, sizeof(buf),
+						   _("The MSN server will shut down for maintenance "
+							 "in %d minute(s). You will automatically be "
+							 "signed out at that time. Please finish any "
+						     "conversations in progress.\n\n"
+							 "After the maintenance has been completed, you "
+							 "will be able to successfully sign in."),
+						   atoi(g_hash_table_lookup(table, "Arg1")));
+
+			default:
+				break;
+		}
+
+		if (*buf != '\0') {
+			do_error_dialog(buf, NULL, GAIM_INFO);
+		}
+	}
+
+	g_hash_table_destroy(table);
+
+	return TRUE;
+}
+static gboolean
 __connect_cb(gpointer data, gint source, GaimInputCondition cond)
 {
 	MsnServConn *notification = data;
@@ -1152,6 +1208,9 @@
 		msn_servconn_register_msg_type(notification,
 									   "text/x-msmsgsemailnotification",
 									   __email_msg);
+		msn_servconn_register_msg_type(notification,
+									   "application/x-msmsgssystemmessage",
+									   __system_msg);
 
 		/* Save these for future use. */
 		notification_commands  = notification->commands;