Mercurial > pidgin
comparison libpurple/protocols/msn/notification.c @ 21563:1b174854bb80
merge of '30fcf2f336afb635b62a5c3ed3adb3e1fa1dd2d1'
and 'bb60447c0a8c79afca320f4dc689096f4788e7fa'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 17 Nov 2007 01:55:21 +0000 |
parents | 6de09629f091 |
children | ab0fd591c7c5 |
comparison
equal
deleted
inserted
replaced
20755:774f4924e74e | 21563:1b174854bb80 |
---|---|
228 static void | 228 static void |
229 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 229 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
230 { | 230 { |
231 MsnSession *session; | 231 MsnSession *session; |
232 PurpleAccount *account; | 232 PurpleAccount *account; |
233 PurpleConnection *gc; | |
234 | 233 |
235 session = cmdproc->session; | 234 session = cmdproc->session; |
236 account = session->account; | 235 account = session->account; |
237 gc = purple_account_get_connection(account); | |
238 | 236 |
239 if (!g_ascii_strcasecmp(cmd->params[1], "OK")) | 237 if (!g_ascii_strcasecmp(cmd->params[1], "OK")) |
240 { | 238 { |
241 /* authenticate OK */ | 239 /* authenticate OK */ |
242 /* friendly name part no longer true in msnp11 */ | 240 /* friendly name part no longer true in msnp11 */ |
262 elems = g_strsplit(cmd->params[3], ",", 0); | 260 elems = g_strsplit(cmd->params[3], ",", 0); |
263 | 261 |
264 for (cur = elems; *cur != NULL; cur++) | 262 for (cur = elems; *cur != NULL; cur++) |
265 { | 263 { |
266 tokens = g_strsplit(*cur, "=", 2); | 264 tokens = g_strsplit(*cur, "=", 2); |
267 if(tokens[0]&&tokens[1]) | 265 if(tokens[0] && tokens[1]) |
268 { | 266 { |
269 purple_debug_info("MSNP14","challenge %p,key:%s,value:%s\n", | 267 purple_debug_info("MSNP14","challenge %p,key:%s,value:%s\n", |
270 session->nexus->challenge_data,tokens[0],tokens[1]); | 268 session->nexus->challenge_data,tokens[0],tokens[1]); |
271 g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]); | 269 g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]); |
272 } | 270 /* Don't free each of the tokens, only the array. */ |
273 /* Don't free each of the tokens, only the array. */ | 271 g_free(tokens); |
274 g_free(tokens); | 272 } else |
273 g_strfreev(tokens); | |
275 } | 274 } |
276 | 275 |
277 g_strfreev(elems); | 276 g_strfreev(elems); |
278 | 277 |
279 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START); | 278 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START); |
413 } | 412 } |
414 else | 413 else |
415 { | 414 { |
416 g_return_if_fail(cmd->payload_cb != NULL); | 415 g_return_if_fail(cmd->payload_cb != NULL); |
417 | 416 |
418 purple_debug_info("MSNP14","MSG payload:{%s}\n",cmd->payload); | 417 purple_debug_info("MSNP14","MSG payload:{%.*s}\n",cmd->payload_len, cmd->payload); |
419 cmd->payload_cb(cmdproc, cmd, cmd->payload, cmd->payload_len); | 418 cmd->payload_cb(cmdproc, cmd, cmd->payload, cmd->payload_len); |
420 } | 419 } |
421 } | 420 } |
422 | 421 |
423 /*send Message to Yahoo Messenger*/ | 422 /*send Message to Yahoo Messenger*/ |
448 MsnMessage *msg; | 447 MsnMessage *msg; |
449 PurpleConnection *gc; | 448 PurpleConnection *gc; |
450 const char *passport; | 449 const char *passport; |
451 const char *content_type; | 450 const char *content_type; |
452 | 451 |
453 purple_debug_info("MSNP14","Process UBM payload:%s\n",payload); | 452 purple_debug_info("MSNP14","Process UBM payload:%.*s\n", len, payload); |
454 msg = msn_message_new_from_cmd(cmdproc->session, cmd); | 453 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
455 | 454 |
456 msn_message_parse_payload(msg, payload, len,MSG_LINE_DEM,MSG_BODY_DEM); | 455 msn_message_parse_payload(msg, payload, len,MSG_LINE_DEM,MSG_BODY_DEM); |
457 #ifdef MSN_DEBUG_NS | 456 #ifdef MSN_DEBUG_NS |
458 msn_message_show_readable(msg, "Notification", TRUE); | 457 msn_message_show_readable(msg, "Notification", TRUE); |
464 content_type = msn_message_get_content_type(msg); | 463 content_type = msn_message_get_content_type(msg); |
465 purple_debug_info("MSNP14","type:%d\n",content_type); | 464 purple_debug_info("MSNP14","type:%d\n",content_type); |
466 if(!strcmp(content_type,"text/plain")){ | 465 if(!strcmp(content_type,"text/plain")){ |
467 const char *value; | 466 const char *value; |
468 const char *body; | 467 const char *body; |
469 char *body_str; | |
470 char *body_enc; | 468 char *body_enc; |
471 char *body_final = NULL; | 469 char *body_final = NULL; |
472 size_t body_len; | 470 size_t body_len; |
473 | 471 |
474 body = msn_message_get_bin_data(msg, &body_len); | 472 body = msn_message_get_bin_data(msg, &body_len); |
475 body_str = g_strndup(body, body_len); | 473 body_enc = g_markup_escape_text(body, body_len); |
476 body_enc = g_markup_escape_text(body_str, -1); | |
477 g_free(body_str); | |
478 | 474 |
479 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) { | 475 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) { |
480 char *pre, *post; | 476 char *pre, *post; |
481 | 477 |
482 msn_parse_format(value, &pre, &post); | 478 msn_parse_format(value, &pre, &post); |
485 g_free(pre); | 481 g_free(pre); |
486 g_free(post); | 482 g_free(post); |
487 } | 483 } |
488 g_free(body_enc); | 484 g_free(body_enc); |
489 serv_got_im(gc, passport, body_final, 0, time(NULL)); | 485 serv_got_im(gc, passport, body_final, 0, time(NULL)); |
486 g_free(body_final); | |
490 } | 487 } |
491 if(!strcmp(content_type,"text/x-msmsgscontrol")){ | 488 if(!strcmp(content_type,"text/x-msmsgscontrol")){ |
492 if(msn_message_get_attr(msg, "TypingUser") != NULL){ | 489 if(msn_message_get_attr(msg, "TypingUser") != NULL){ |
493 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, | 490 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, |
494 PURPLE_TYPING); | 491 PURPLE_TYPING); |
531 cmdproc->last_cmd->payload_cb = ubm_cmd_post; | 528 cmdproc->last_cmd->payload_cb = ubm_cmd_post; |
532 cmdproc->servconn->payload_len = atoi(cmd->params[2]); | 529 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
533 }else{ | 530 }else{ |
534 g_return_if_fail(cmd->payload_cb != NULL); | 531 g_return_if_fail(cmd->payload_cb != NULL); |
535 | 532 |
536 purple_debug_info("MSNP14","UBM payload:{%s}\n",cmd->payload); | 533 purple_debug_info("MSNP14","UBM payload:{%.*s}\n", cmd->payload_len, cmd->payload); |
537 ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); | 534 ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); |
538 } | 535 } |
539 } | 536 } |
540 | 537 |
541 /************************************************************************** | 538 /************************************************************************** |
735 trans = msn_transaction_new(cmdproc, "FQY","%d", strlen(payload)); | 732 trans = msn_transaction_new(cmdproc, "FQY","%d", strlen(payload)); |
736 msn_transaction_set_payload(trans, payload, strlen(payload)); | 733 msn_transaction_set_payload(trans, payload, strlen(payload)); |
737 msn_cmdproc_send_trans(cmdproc, trans); | 734 msn_cmdproc_send_trans(cmdproc, trans); |
738 | 735 |
739 g_free(payload); | 736 g_free(payload); |
740 g_free(tokens); | 737 g_strfreev(tokens); |
741 } | 738 } |
742 | 739 |
743 static void | 740 static void |
744 blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 741 blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
745 { | 742 { |
1201 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 1198 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
1202 { | 1199 { |
1203 MsnSession *session = cmdproc->session; | 1200 MsnSession *session = cmdproc->session; |
1204 const char *type, *value, *friendlyname; | 1201 const char *type, *value, *friendlyname; |
1205 | 1202 |
1206 purple_debug_info("MSN Notification", "prp_cmd()\n"); | |
1207 | |
1208 g_return_if_fail(cmd->param_count >= 3); | 1203 g_return_if_fail(cmd->param_count >= 3); |
1209 | 1204 |
1210 type = cmd->params[2]; | 1205 type = cmd->params[2]; |
1211 | 1206 |
1212 if (cmd->param_count == 4) | 1207 if (cmd->param_count == 4) |
1414 | 1409 |
1415 if ((fd = purple_mkstemp(&session->passport_info.file, FALSE)) == NULL) | 1410 if ((fd = purple_mkstemp(&session->passport_info.file, FALSE)) == NULL) |
1416 { | 1411 { |
1417 purple_debug_error("msn", | 1412 purple_debug_error("msn", |
1418 "Error opening temp passport file: %s\n", | 1413 "Error opening temp passport file: %s\n", |
1419 strerror(errno)); | 1414 g_strerror(errno)); |
1420 } | 1415 } |
1421 else | 1416 else |
1422 { | 1417 { |
1423 #ifdef _WIN32 | 1418 #ifdef _WIN32 |
1424 fputs("<!-- saved from url=(0013)about:internet -->\n", fd); | 1419 fputs("<!-- saved from url=(0013)about:internet -->\n", fd); |
1463 | 1458 |
1464 if (fclose(fd)) | 1459 if (fclose(fd)) |
1465 { | 1460 { |
1466 purple_debug_error("msn", | 1461 purple_debug_error("msn", |
1467 "Error closing temp passport file: %s\n", | 1462 "Error closing temp passport file: %s\n", |
1468 strerror(errno)); | 1463 g_strerror(errno)); |
1469 | 1464 |
1470 g_unlink(session->passport_info.file); | 1465 g_unlink(session->passport_info.file); |
1471 g_free(session->passport_info.file); | 1466 g_free(session->passport_info.file); |
1472 session->passport_info.file = NULL; | 1467 session->passport_info.file = NULL; |
1473 } | 1468 } |
1616 ubx_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, | 1611 ubx_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, |
1617 size_t len) | 1612 size_t len) |
1618 { | 1613 { |
1619 MsnSession *session; | 1614 MsnSession *session; |
1620 PurpleAccount *account; | 1615 PurpleAccount *account; |
1621 PurpleConnection *gc; | |
1622 MsnUser *user; | 1616 MsnUser *user; |
1623 const char *passport; | 1617 const char *passport; |
1624 char *psm_str, *currentmedia_str, *str; | 1618 char *psm_str, *str; |
1625 | 1619 CurrentMedia media = {NULL, NULL, NULL}; |
1626 /*get the payload content*/ | |
1627 // purple_debug_info("MSNP14","UBX {%s} payload{%s}\n",cmd->params[0], cmd->payload); | |
1628 | 1620 |
1629 session = cmdproc->session; | 1621 session = cmdproc->session; |
1630 account = session->account; | 1622 account = session->account; |
1631 gc = purple_account_get_connection(account); | |
1632 | 1623 |
1633 passport = cmd->params[0]; | 1624 passport = cmd->params[0]; |
1634 user = msn_userlist_find_user(session->userlist, passport); | 1625 user = msn_userlist_find_user(session->userlist, passport); |
1635 | 1626 |
1636 psm_str = msn_get_psm(cmd->payload,len); | 1627 psm_str = msn_get_psm(cmd->payload,len); |
1637 currentmedia_str = msn_parse_currentmedia( | 1628 msn_user_set_statusline(user, psm_str); |
1638 str = msn_get_currentmedia(cmd->payload, len)); | 1629 g_free(psm_str); |
1630 | |
1631 str = msn_get_currentmedia(cmd->payload, len); | |
1632 if (msn_parse_currentmedia(str, &media)) | |
1633 msn_user_set_currentmedia(user, &media); | |
1634 else | |
1635 msn_user_set_currentmedia(user, NULL); | |
1639 g_free(str); | 1636 g_free(str); |
1640 | 1637 |
1641 msn_user_set_statusline(user, psm_str); | |
1642 msn_user_set_currentmedia(user, currentmedia_str); | |
1643 msn_user_update(user); | 1638 msn_user_update(user); |
1644 | |
1645 g_free(psm_str); | |
1646 g_free(currentmedia_str); | |
1647 } | 1639 } |
1648 | 1640 |
1649 static void | 1641 static void |
1650 ubx_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 1642 ubx_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
1651 { | 1643 { |
1795 if (strcmp(msg->remote_user, "Hotmail")) | 1787 if (strcmp(msg->remote_user, "Hotmail")) |
1796 /* This isn't an official message. */ | 1788 /* This isn't an official message. */ |
1797 return; | 1789 return; |
1798 | 1790 |
1799 /*new a oim session*/ | 1791 /*new a oim session*/ |
1800 session->oim = msn_oim_new(session); | 1792 // session->oim = msn_oim_new(session); |
1801 // msn_oim_connect(session->oim); | 1793 // msn_oim_connect(session->oim); |
1802 | 1794 |
1803 table = msn_message_get_hashtable_from_body(msg); | 1795 table = msn_message_get_hashtable_from_body(msg); |
1804 | 1796 |
1805 mdata = g_hash_table_lookup(table, "Mail-Data"); | 1797 mdata = g_hash_table_lookup(table, "Mail-Data"); |