comparison src/protocols/msn/notification.c @ 9158:c30d81b4dd22

[gaim-migrate @ 9942] Patch from Felipe Contreras to sync our MSN prpl with what's in his tree. He says this may fix a couple bugs, but the important thing is the restructuring of how MsnMessages work. Lots of style changes and other stuff as well. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 01 Jun 2004 06:42:20 +0000
parents 8ef82d89faf3
children 502707ca1836
comparison
equal deleted inserted replaced
9157:bd1ea0a717d7 9158:c30d81b4dd22
194 194
195 static void 195 static void
196 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 196 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
197 { 197 {
198 GaimAccount *account; 198 GaimAccount *account;
199
200 account = cmdproc->session->account;
201
202 msn_cmdproc_send(cmdproc, "USR", "TWN I %s",
203 gaim_account_get_username(account));
204 }
205
206 static void
207 inf_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
208 {
209 GaimAccount *account;
199 GaimConnection *gc; 210 GaimConnection *gc;
200 211
201 account = cmdproc->session->account; 212 account = cmdproc->session->account;
202 gc = gaim_account_get_connection(account); 213 gc = gaim_account_get_connection(account);
203 214
204 msn_cmdproc_send(cmdproc, "USR", "TWN I %s", 215 if (strcmp(cmd->params[1], "MD5"))
216 {
217 gaim_connection_error(gc, _("Unable to login using MD5"));
218
219 return;
220 }
221
222 msn_cmdproc_send(cmdproc, "USR", "MD5 I %s",
205 gaim_account_get_username(account)); 223 gaim_account_get_username(account));
206 } 224
207 225 if (cmdproc->error)
208 static void 226 return;
209 inf_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 227
210 { 228 gaim_connection_update_progress(gc, _("Requesting to send password"),
229 5, MSN_CONNECT_STEPS);
230 }
231
232 static void
233 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
234 {
235 MsnSession *session;
211 GaimAccount *account; 236 GaimAccount *account;
212 GaimConnection *gc; 237 GaimConnection *gc;
213
214 account = cmdproc->session->account;
215 gc = gaim_account_get_connection(account);
216
217 if (strcmp(cmd->params[1], "MD5"))
218 {
219 gaim_connection_error(gc, _("Unable to login using MD5"));
220
221 return;
222 }
223
224 msn_cmdproc_send(cmdproc, "USR", "MD5 I %s",
225 gaim_account_get_username(account));
226
227 if (cmdproc->error)
228 return;
229
230 gaim_connection_update_progress(gc, _("Requesting to send password"),
231 5, MSN_CONNECT_STEPS);
232 }
233
234 static void
235 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
236 {
237 MsnSession *session;
238 GaimAccount *account;
239 GaimConnection *gc;
240 char outparams[MSN_BUF_LEN];
241 238
242 session = cmdproc->session; 239 session = cmdproc->session;
243 account = session->account; 240 account = session->account;
244 gc = gaim_account_get_connection(account); 241 gc = gaim_account_get_connection(account);
245 242
308 md5_init(&st); 305 md5_init(&st);
309 md5_append(&st, (const md5_byte_t *)challenge, strlen(challenge)); 306 md5_append(&st, (const md5_byte_t *)challenge, strlen(challenge));
310 md5_append(&st, (const md5_byte_t *)password, strlen(password)); 307 md5_append(&st, (const md5_byte_t *)password, strlen(password));
311 md5_finish(&st, di); 308 md5_finish(&st, di);
312 309
313 g_snprintf(outparams, sizeof(outparams), "MD5 S ");
314
315 for (i = 0; i < 16; i++) 310 for (i = 0; i < 16; i++)
316 g_snprintf(buf + (i*2), 3, "%02x", di[i]); 311 g_snprintf(buf + (i*2), 3, "%02x", di[i]);
317 312
318 msn_cmdproc_send(cmdproc, "USR", "MD5 S %s", buf); 313 msn_cmdproc_send(cmdproc, "USR", "MD5 S %s", buf);
319 314
415 } 410 }
416 411
417 static void 412 static void
418 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 413 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
419 { 414 {
420 gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n");
421
422 cmdproc->payload_cb = msg_cmd_post; 415 cmdproc->payload_cb = msg_cmd_post;
423 cmdproc->servconn->payload_len = atoi(cmd->params[2]); 416 cmdproc->servconn->payload_len = atoi(cmd->params[2]);
424 cmdproc->temp = g_strdup(cmd->params[0]); 417 cmdproc->temp = g_strdup(cmd->params[0]);
425 } 418 }
426 419
429 **************************************************************************/ 422 **************************************************************************/
430 static void 423 static void
431 chl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 424 chl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
432 { 425 {
433 MsnSession *session; 426 MsnSession *session;
434 GaimConnection *gc;
435 MsnTransaction *trans; 427 MsnTransaction *trans;
436 char buf[MSN_BUF_LEN]; 428 char buf[33];
437 const char *challenge_resp; 429 const char *challenge_resp;
438 const char *challenge_str; 430 const char *challenge_str;
439 md5_state_t st; 431 md5_state_t st;
440 md5_byte_t di[16]; 432 md5_byte_t di[16];
441 int i; 433 int i;
442 434
443 session = cmdproc->session; 435 session = cmdproc->session;
444 gc = session->account->gc;
445 436
446 md5_init(&st); 437 md5_init(&st);
447 md5_append(&st, (const md5_byte_t *)cmd->params[1], strlen(cmd->params[1])); 438 md5_append(&st, (const md5_byte_t *)cmd->params[1],
439 strlen(cmd->params[1]));
448 440
449 if (session->protocol_ver >= 8) 441 if (session->protocol_ver >= 8)
450 { 442 {
451 challenge_resp = "VT6PX?UQTM4WM%YR"; 443 challenge_resp = "VT6PX?UQTM4WM%YR";
452 challenge_str = "PROD0038W!61ZTF9"; 444 challenge_str = "PROD0038W!61ZTF9";
548 gc = gaim_account_get_connection(account); 540 gc = gaim_account_get_connection(account);
549 params = g_strsplit(trans->params, " ", 0); 541 params = g_strsplit(trans->params, " ", 0);
550 542
551 list = params[0]; 543 list = params[0];
552 passport = params[1]; 544 passport = params[1];
553
554 reason = "invalid user";
555 545
556 if (!strcmp(list, "FL")) 546 if (!strcmp(list, "FL"))
557 msg = g_strdup("Unable to add user on MSN"); 547 msg = g_strdup("Unable to add user on MSN");
558 else if (!strcmp(list, "BL")) 548 else if (!strcmp(list, "BL"))
559 msg = g_strdup("Unable to block user on MSN"); 549 msg = g_strdup("Unable to block user on MSN");
709 { 699 {
710 GaimConnection *gc; 700 GaimConnection *gc;
711 701
712 gc = cmdproc->session->account->gc; 702 gc = cmdproc->session->account->gc;
713 703
714 serv_got_update(gc, (char *)cmd->params[0], 0, 0, 0, 0, 0); 704 serv_got_update(gc, cmd->params[0], 0, 0, 0, 0, 0);
715 } 705 }
716 706
717 static void 707 static void
718 iln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 708 iln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
719 { 709 {
732 passport = cmd->params[2]; 722 passport = cmd->params[2];
733 friend = gaim_url_decode(cmd->params[3]); 723 friend = gaim_url_decode(cmd->params[3]);
734 724
735 user = msn_users_find_with_passport(session->users, passport); 725 user = msn_users_find_with_passport(session->users, passport);
736 726
737 serv_got_alias(gc, (char *)passport, (char *)friend); 727 serv_got_alias(gc, passport, friend);
738 728
739 msn_user_set_name(user, friend); 729 msn_user_set_name(user, friend);
740 730
741 if (session->protocol_ver >= 9 && cmd->param_count == 6) 731 if (session->protocol_ver >= 9 && cmd->param_count == 6)
742 { 732 {
1148 passport = cmd->params[1]; 1138 passport = cmd->params[1];
1149 friend = gaim_url_decode(cmd->params[2]); 1139 friend = gaim_url_decode(cmd->params[2]);
1150 1140
1151 user = msn_users_find_with_passport(session->users, passport); 1141 user = msn_users_find_with_passport(session->users, passport);
1152 1142
1153 serv_got_alias(gc, (char *)passport, (char *)friend); 1143 serv_got_alias(gc, passport, friend);
1154 1144
1155 msn_user_set_name(user, friend); 1145 msn_user_set_name(user, friend);
1156 1146
1157 if (session->protocol_ver >= 9 && cmd->param_count == 5) 1147 if (session->protocol_ver >= 9 && cmd->param_count == 5)
1158 { 1148 {
1171 else if (!g_ascii_strcasecmp(state, "PHN")) 1161 else if (!g_ascii_strcasecmp(state, "PHN"))
1172 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); 1162 status |= UC_UNAVAILABLE | (MSN_PHONE << 1);
1173 else if (!g_ascii_strcasecmp(state, "LUN")) 1163 else if (!g_ascii_strcasecmp(state, "LUN"))
1174 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); 1164 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1);
1175 1165
1176 serv_got_update(gc, (char *)passport, 1, 0, 0, 0, status); 1166 serv_got_update(gc, passport, 1, 0, 0, 0, status);
1167 }
1168
1169 static void
1170 not_cmd_post(MsnCmdProc *cmdproc, char *payload, size_t len)
1171 {
1172 #if 0
1173 gaim_debug_misc("msn", "Notification: {%s}\n", payload);
1174 #endif
1177 } 1175 }
1178 1176
1179 static void 1177 static void
1180 not_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 1178 not_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
1181 { 1179 {
1182 cmdproc->payload_cb = NULL;
1183 cmdproc->servconn->payload_len = atoi(cmd->params[0]); 1180 cmdproc->servconn->payload_len = atoi(cmd->params[0]);
1181 cmdproc->payload_cb = not_cmd_post;
1184 } 1182 }
1185 1183
1186 static void 1184 static void
1187 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 1185 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
1188 { 1186 {
1275 session->moving_buddy = FALSE; 1273 session->moving_buddy = FALSE;
1276 session->old_group = NULL; 1274 session->old_group = NULL;
1277 1275
1278 if (group == NULL) 1276 if (group == NULL)
1279 { 1277 {
1280 gaim_debug(GAIM_DEBUG_ERROR, "msn", 1278 gaim_debug_error("msn",
1281 "Still don't have a group ID for %s while moving %s!\n", 1279 "Still don't have a group ID for %s while moving %s!\n",
1282 session->dest_group_name, passport); 1280 session->dest_group_name, passport);
1283 1281
1284 g_free(session->dest_group_name); 1282 g_free(session->dest_group_name);
1285 session->dest_group_name = NULL; 1283 session->dest_group_name = NULL;
1284
1285 return;
1286 } 1286 }
1287 1287
1288 g_free(session->dest_group_name); 1288 g_free(session->dest_group_name);
1289 session->dest_group_name = NULL; 1289 session->dest_group_name = NULL;
1290 1290
1430 { 1430 {
1431 fputs("<html>\n" 1431 fputs("<html>\n"
1432 "<head>\n" 1432 "<head>\n"
1433 "<noscript>\n" 1433 "<noscript>\n"
1434 "<meta http-equiv=\"Refresh\" content=\"0; " 1434 "<meta http-equiv=\"Refresh\" content=\"0; "
1435 "url=http://www.hotmail.com\">\n" 1435 "url=http://www.hotmail.com\">\n"
1436 "</noscript>\n" 1436 "</noscript>\n"
1437 "</head>\n\n", 1437 "</head>\n\n",
1438 fd); 1438 fd);
1439 1439
1440 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n"); 1440 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n");
1463 fprintf(fd, "</form></body>\n"); 1463 fprintf(fd, "</form></body>\n");
1464 fprintf(fd, "</html>\n"); 1464 fprintf(fd, "</html>\n");
1465 1465
1466 if (fclose(fd)) 1466 if (fclose(fd))
1467 { 1467 {
1468 gaim_debug(GAIM_DEBUG_ERROR, "msn", 1468 gaim_debug_error("msn",
1469 "Error closing temp passport file: %s\n", 1469 "Error closing temp passport file: %s\n",
1470 strerror(errno)); 1470 strerror(errno));
1471 1471
1472 unlink(session->passport_info.file); 1472 unlink(session->passport_info.file);
1473 g_free(session->passport_info.file); 1473 g_free(session->passport_info.file);
1474 } 1474 }
1475 else 1475 else
1478 * Renaming file with .html extension, so that the 1478 * Renaming file with .html extension, so that the
1479 * win32 open_url will work. 1479 * win32 open_url will work.
1480 */ 1480 */
1481 char *tmp; 1481 char *tmp;
1482 1482
1483 if ((tmp = g_strdup_printf("%s.html", 1483 if ((tmp = g_strdup_printf("%s.html", session->passport_info.file)) != NULL)
1484 session->passport_info.file)) != NULL)
1485 { 1484 {
1486 if (rename(session->passport_info.file, tmp) == 0) 1485 if (rename(session->passport_info.file, tmp) == 0)
1487 { 1486 {
1488 g_free(session->passport_info.file); 1487 g_free(session->passport_info.file);
1489 session->passport_info.file = tmp; 1488 session->passport_info.file = tmp;
1532 msn_switchboard_set_auth_key(swboard, cmd->params[3]); 1531 msn_switchboard_set_auth_key(swboard, cmd->params[3]);
1533 msn_switchboard_set_user(swboard, user); 1532 msn_switchboard_set_user(swboard, user);
1534 1533
1535 if (!msn_switchboard_connect(swboard, host, port)) 1534 if (!msn_switchboard_connect(swboard, host, port))
1536 { 1535 {
1537 gaim_debug(GAIM_DEBUG_ERROR, "msn", 1536 gaim_debug_error("msn",
1538 "Unable to connect to switchboard on %s, port %d\n", 1537 "Unable to connect to switchboard on %s, port %d\n",
1539 host, port); 1538 host, port);
1540 1539
1541 g_free(host); 1540 g_free(host);
1542 1541
1543 return; 1542 return;
1544 } 1543 }
1695 { 1694 {
1696 int count = atoi(unread); 1695 int count = atoi(unread);
1697 1696
1698 if (count != 0) 1697 if (count != 0)
1699 { 1698 {
1700 const char *passport = msn_user_get_passport(session->user); 1699 const char *passport;
1701 const char *file = session->passport_info.file; 1700 const char *file;
1702 gchar *url; 1701 gchar *url;
1702
1703 passport = msn_user_get_passport(session->user);
1704 file = session->passport_info.file;
1703 while (*file && *file == '/') 1705 while (*file && *file == '/')
1704 ++file; 1706 ++file;
1705 url = g_strconcat ("file:///", file, 0); 1707 url = g_strconcat ("file:///", file, 0);
1706 gaim_notify_emails(gc, count, FALSE, NULL, NULL, 1708 gaim_notify_emails(gc, count, FALSE, NULL, NULL,
1707 &passport, (const char **)&url, NULL, NULL); 1709 &passport, (const char **)&url, NULL, NULL);
1753 1755
1754 tmp = g_hash_table_lookup(table, "Subject"); 1756 tmp = g_hash_table_lookup(table, "Subject");
1755 if (tmp != NULL) 1757 if (tmp != NULL)
1756 subject = gaim_mime_decode_field(tmp); 1758 subject = gaim_mime_decode_field(tmp);
1757 1759
1758 if (from != NULL && subject != NULL) 1760 gaim_notify_email(gc,
1759 gaim_notify_email(gc, subject, from, msn_user_get_passport(session->user), 1761 (subject != NULL ? subject : ""),
1760 session->passport_info.file, NULL, NULL); 1762 (from != NULL ? from : ""),
1763 msn_user_get_passport(session->user),
1764 session->passport_info.file, NULL, NULL);
1761 1765
1762 if (from != NULL) 1766 if (from != NULL)
1763 g_free(from); 1767 g_free(from);
1764 1768
1765 if (subject != NULL) 1769 if (subject != NULL)
1794 switch (type) 1798 switch (type)
1795 { 1799 {
1796 case 1: 1800 case 1:
1797 minutes = atoi(g_hash_table_lookup(table, "Arg1")); 1801 minutes = atoi(g_hash_table_lookup(table, "Arg1"));
1798 g_snprintf(buf, sizeof(buf), ngettext( 1802 g_snprintf(buf, sizeof(buf), ngettext(
1799 "The MSN server will shut down for maintenance " 1803 "The MSN server will shut down for maintenance "
1800 "in %d minute. You will automatically be " 1804 "in %d minute. You will automatically be "
1801 "signed out at that time. Please finish any " 1805 "signed out at that time. Please finish any "
1802 "conversations in progress.\n\nAfter the " 1806 "conversations in progress.\n\nAfter the "
1803 "maintenance has been completed, you will be " 1807 "maintenance has been completed, you will be "
1804 "able to successfully sign in.", 1808 "able to successfully sign in.",
1805 "The MSN server will shut down for maintenance " 1809 "The MSN server will shut down for maintenance "
1806 "in %d minutes. You will automatically be " 1810 "in %d minutes. You will automatically be "
1807 "signed out at that time. Please finish any " 1811 "signed out at that time. Please finish any "
1808 "conversations in progress.\n\nAfter the " 1812 "conversations in progress.\n\nAfter the "
1809 "maintenance has been completed, you will be " 1813 "maintenance has been completed, you will be "
1810 "able to successfully sign in.", minutes), 1814 "able to successfully sign in.", minutes),
1811 minutes); 1815 minutes);
1812 default: 1816 default:
1813 break; 1817 break;
1814 } 1818 }
1815 1819
1816 if (*buf != '\0') 1820 if (*buf != '\0')
1920 1924
1921 msn_table_add_error(cbs_table, "ADD", add_error); 1925 msn_table_add_error(cbs_table, "ADD", add_error);
1922 1926
1923 /* Register the message type callbacks. */ 1927 /* Register the message type callbacks. */
1924 msn_table_add_msg_type(cbs_table, 1928 msn_table_add_msg_type(cbs_table,
1925 "text/x-msmsgsprofile", 1929 "text/x-msmsgsprofile",
1926 profile_msg); 1930 profile_msg);
1927 msn_table_add_msg_type(cbs_table, 1931 msn_table_add_msg_type(cbs_table,
1928 "text/x-msmsgsinitialemailnotification", 1932 "text/x-msmsgsinitialemailnotification",
1929 initial_email_msg); 1933 initial_email_msg);
1930 msn_table_add_msg_type(cbs_table, 1934 msn_table_add_msg_type(cbs_table,
1931 "text/x-msmsgsemailnotification", 1935 "text/x-msmsgsemailnotification",
1932 email_msg); 1936 email_msg);
1933 msn_table_add_msg_type(cbs_table, 1937 msn_table_add_msg_type(cbs_table,
1934 "application/x-msmsgssystemmessage", 1938 "application/x-msmsgssystemmessage",
1935 system_msg); 1939 system_msg);
1936 } 1940 }
1937 1941
1938 void 1942 void
1939 msn_notification_end(void) 1943 msn_notification_end(void)
1940 { 1944 {