Mercurial > pidgin
comparison libpurple/protocols/msn/oim.c @ 24872:955bfda56492
Apparently X-OIM-Proxy was not a good way to decide that we received a
multi-part message. Now always just split if a boundary is available from
the content-type. Try and match the telephone number before the using the
address from the From line.
Fixes #7901.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 27 Dec 2008 09:32:38 +0000 |
parents | fbd1a82247ba |
children | 2aa4b88bdcf8 |
comparison
equal
deleted
inserted
replaced
24871:bd2f4c6add99 | 24872:955bfda56492 |
---|---|
594 msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str) | 594 msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str) |
595 { | 595 { |
596 MsnMessage *message; | 596 MsnMessage *message; |
597 const char *date; | 597 const char *date; |
598 const char *from; | 598 const char *from; |
599 const char *boundary; | |
599 char *decode_msg = NULL; | 600 char *decode_msg = NULL; |
600 gsize body_len; | 601 gsize body_len; |
601 char **tokens; | 602 char **tokens; |
602 char *passport = NULL; | 603 char *passport = NULL; |
603 time_t stamp; | 604 time_t stamp; |
606 | 607 |
607 msn_message_parse_payload(message, msg_str, strlen(msg_str), | 608 msn_message_parse_payload(message, msg_str, strlen(msg_str), |
608 MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM); | 609 MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM); |
609 purple_debug_info("msn", "oim body:{%s}\n", message->body); | 610 purple_debug_info("msn", "oim body:{%s}\n", message->body); |
610 | 611 |
611 if (!strcmp(msn_message_get_attr(message, "X-OIMProxy"), "MOSMS")) { | 612 boundary = msn_message_get_attr(message, "boundary"); |
612 char *boundary; | 613 |
614 if (boundary != NULL) { | |
615 char *bounds; | |
613 char **part; | 616 char **part; |
614 | 617 |
615 from = msn_message_get_attr(message, "X-OIM-originatingSource"); | 618 bounds = g_strdup_printf("--%s" MSG_OIM_LINE_DEM, boundary); |
616 | 619 tokens = g_strsplit(message->body, bounds, 0); |
617 /* Match number to user's mobile number, FROM is a phone number | |
618 if the other side pages you using your phone number */ | |
619 if (!strncmp(from, "tel:+", 5)) { | |
620 MsnUser *user = msn_userlist_find_user_with_mobile_phone( | |
621 rdata->oim->session->userlist, from + 4); | |
622 | |
623 if (user && user->passport) | |
624 passport = g_strdup(user->passport); | |
625 } | |
626 if (passport == NULL) | |
627 passport = g_strdup(from); | |
628 | |
629 boundary = g_strdup_printf("--%s" MSG_OIM_LINE_DEM, | |
630 msn_message_get_attr(message, "boundary")); | |
631 tokens = g_strsplit(message->body, boundary, 0); | |
632 | 620 |
633 /* tokens+1 to skip the "This is a multipart message..." text */ | 621 /* tokens+1 to skip the "This is a multipart message..." text */ |
634 for (part = tokens+1; *part != NULL; part++) { | 622 for (part = tokens+1; *part != NULL; part++) { |
635 MsnMessage *multipart; | 623 MsnMessage *multipart; |
636 const char *type; | 624 const char *type; |
646 } | 634 } |
647 msn_message_destroy(multipart); | 635 msn_message_destroy(multipart); |
648 } | 636 } |
649 | 637 |
650 g_strfreev(tokens); | 638 g_strfreev(tokens); |
651 g_free(boundary); | 639 g_free(bounds); |
652 | 640 |
653 if (decode_msg == NULL) { | 641 if (decode_msg == NULL) { |
654 purple_debug_error("msn", "Couldn't find text/plain OIM message.\n"); | 642 purple_debug_error("msn", "Couldn't find text/plain OIM message.\n"); |
655 g_free(passport); | 643 msn_message_destroy(message); |
656 return; | 644 return; |
657 } | 645 } |
658 } else { | 646 } else { |
647 decode_msg = (char *)purple_base64_decode(message->body, &body_len); | |
648 } | |
649 | |
650 from = msn_message_get_attr(message, "X-OIM-originatingSource"); | |
651 | |
652 /* Match number to user's mobile number, FROM is a phone number | |
653 if the other side pages you using your phone number */ | |
654 if (!strncmp(from, "tel:+", 5)) { | |
655 MsnUser *user = msn_userlist_find_user_with_mobile_phone( | |
656 rdata->oim->session->userlist, from + 4); | |
657 | |
658 if (user && user->passport) | |
659 passport = g_strdup(user->passport); | |
660 } | |
661 | |
662 if (passport == NULL) { | |
659 char *start, *end; | 663 char *start, *end; |
660 | 664 |
661 from = msn_message_get_attr(message, "From"); | 665 from = msn_message_get_attr(message, "From"); |
662 decode_msg = (char *)purple_base64_decode(message->body, &body_len); | |
663 | 666 |
664 tokens = g_strsplit(from, " ", 2); | 667 tokens = g_strsplit(from, " ", 2); |
665 if (tokens[1] != NULL) | 668 if (tokens[1] != NULL) |
666 from = (const char *)tokens[1]; | 669 from = (const char *)tokens[1]; |
667 | 670 |
685 */ | 688 */ |
686 msn_oim_post_delete_msg(rdata); | 689 msn_oim_post_delete_msg(rdata); |
687 | 690 |
688 g_free(passport); | 691 g_free(passport); |
689 g_free(decode_msg); | 692 g_free(decode_msg); |
693 msn_message_destroy(message); | |
690 } | 694 } |
691 | 695 |
692 /* Parse the XML data, | 696 /* Parse the XML data, |
693 * prepare to report the OIM to user | 697 * prepare to report the OIM to user |
694 */ | 698 */ |