comparison src/protocols/msn/notification.c @ 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 b716ffc25d2d
children bbf2141d30d0
comparison
equal deleted inserted replaced
5332:4d734dbc88dd 5333:bbbf616bd924
999 __profile_msg(MsnServConn *servconn, const MsnMessage *msg) 999 __profile_msg(MsnServConn *servconn, const MsnMessage *msg)
1000 { 1000 {
1001 MsnSession *session = servconn->session; 1001 MsnSession *session = servconn->session;
1002 const char *value; 1002 const char *value;
1003 1003
1004 if (strcmp(servconn->msg_passport, "Hotmail")) {
1005 /* This isn't an official message. */
1006 return TRUE;
1007 }
1008
1004 if ((value = msn_message_get_attr(msg, "kv")) != NULL) 1009 if ((value = msn_message_get_attr(msg, "kv")) != NULL)
1005 session->passport_info.kv = g_strdup(value); 1010 session->passport_info.kv = g_strdup(value);
1006 1011
1007 if ((value = msn_message_get_attr(msg, "sid")) != NULL) 1012 if ((value = msn_message_get_attr(msg, "sid")) != NULL)
1008 session->passport_info.sid = g_strdup(value); 1013 session->passport_info.sid = g_strdup(value);
1019 MsnSession *session = servconn->session; 1024 MsnSession *session = servconn->session;
1020 struct gaim_connection *gc = session->account->gc; 1025 struct gaim_connection *gc = session->account->gc;
1021 GHashTable *table; 1026 GHashTable *table;
1022 const char *unread; 1027 const char *unread;
1023 1028
1029 if (strcmp(servconn->msg_passport, "Hotmail")) {
1030 /* This isn't an official message. */
1031 return TRUE;
1032 }
1033
1024 table = msn_message_get_hashtable_from_body(msg); 1034 table = msn_message_get_hashtable_from_body(msg);
1025 1035
1026 unread = g_hash_table_lookup(table, "Inbox-Unread"); 1036 unread = g_hash_table_lookup(table, "Inbox-Unread");
1027 1037
1028 if (unread != NULL) 1038 if (unread != NULL)
1040 MsnSession *session = servconn->session; 1050 MsnSession *session = servconn->session;
1041 struct gaim_connection *gc = session->account->gc; 1051 struct gaim_connection *gc = session->account->gc;
1042 GHashTable *table; 1052 GHashTable *table;
1043 const char *from, *subject; 1053 const char *from, *subject;
1044 1054
1055 if (strcmp(servconn->msg_passport, "Hotmail")) {
1056 /* This isn't an official message. */
1057 return TRUE;
1058 }
1059
1045 table = msn_message_get_hashtable_from_body(msg); 1060 table = msn_message_get_hashtable_from_body(msg);
1046 1061
1047 from = g_hash_table_lookup(table, "From"); 1062 from = g_hash_table_lookup(table, "From");
1048 subject = g_hash_table_lookup(table, "Subject"); 1063 subject = g_hash_table_lookup(table, "Subject");
1049 1064
1058 g_hash_table_destroy(table); 1073 g_hash_table_destroy(table);
1059 1074
1060 return TRUE; 1075 return TRUE;
1061 } 1076 }
1062 1077
1078 static gboolean
1079 __system_msg(MsnServConn *servconn, const MsnMessage *msg)
1080 {
1081 GHashTable *table;
1082 const char *type_s;
1083
1084 if (strcmp(servconn->msg_passport, "Hotmail")) {
1085 /* This isn't an official message. */
1086 return TRUE;
1087 }
1088
1089 table = msn_message_get_hashtable_from_body(msg);
1090
1091 if ((type_s = g_hash_table_lookup(table, "Type")) != NULL) {
1092 int type = atoi(type_s);
1093 char buf[MSN_BUF_LEN];
1094
1095 switch (type) {
1096 case 1:
1097 g_snprintf(buf, sizeof(buf),
1098 _("The MSN server will shut down for maintenance "
1099 "in %d minute(s). You will automatically be "
1100 "signed out at that time. Please finish any "
1101 "conversations in progress.\n\n"
1102 "After the maintenance has been completed, you "
1103 "will be able to successfully sign in."),
1104 atoi(g_hash_table_lookup(table, "Arg1")));
1105
1106 default:
1107 break;
1108 }
1109
1110 if (*buf != '\0') {
1111 do_error_dialog(buf, NULL, GAIM_INFO);
1112 }
1113 }
1114
1115 g_hash_table_destroy(table);
1116
1117 return TRUE;
1118 }
1063 static gboolean 1119 static gboolean
1064 __connect_cb(gpointer data, gint source, GaimInputCondition cond) 1120 __connect_cb(gpointer data, gint source, GaimInputCondition cond)
1065 { 1121 {
1066 MsnServConn *notification = data; 1122 MsnServConn *notification = data;
1067 MsnSession *session = notification->session; 1123 MsnSession *session = notification->session;
1150 "text/x-msmsgsinitialemailnotification", 1206 "text/x-msmsgsinitialemailnotification",
1151 __initial_email_msg); 1207 __initial_email_msg);
1152 msn_servconn_register_msg_type(notification, 1208 msn_servconn_register_msg_type(notification,
1153 "text/x-msmsgsemailnotification", 1209 "text/x-msmsgsemailnotification",
1154 __email_msg); 1210 __email_msg);
1211 msn_servconn_register_msg_type(notification,
1212 "application/x-msmsgssystemmessage",
1213 __system_msg);
1155 1214
1156 /* Save these for future use. */ 1215 /* Save these for future use. */
1157 notification_commands = notification->commands; 1216 notification_commands = notification->commands;
1158 notification_msg_types = notification->msg_types; 1217 notification_msg_types = notification->msg_types;
1159 } 1218 }