Mercurial > pidgin
comparison libpurple/protocols/msn/msn.c @ 17061:cb4380df3005
In MSN we fake sending messages to yourself. This had a small bug in that
the received message would show up *before* the sent message. This fixes
that so that when talking to yourself messages appear in the correct order.
I was discussing this with Stu and he said it was a rather silly thing to
worry about, but I disagree with him.
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 12 May 2007 17:38:04 +0000 |
parents | 21830d70709b |
children | 3aee35e0ecd8 522f618a44b4 |
comparison
equal
deleted
inserted
replaced
17058:f1547260a11e | 17061:cb4380df3005 |
---|---|
71 PurpleNotifyUserInfo *user_info; | 71 PurpleNotifyUserInfo *user_info; |
72 char *photo_url_text; | 72 char *photo_url_text; |
73 | 73 |
74 } MsnGetInfoStepTwoData; | 74 } MsnGetInfoStepTwoData; |
75 | 75 |
76 typedef struct | |
77 { | |
78 PurpleConnection *gc; | |
79 const char *who; | |
80 char *msg; | |
81 PurpleMessageFlags flags; | |
82 time_t when; | |
83 } MsnIMData; | |
84 | |
76 static const char * | 85 static const char * |
77 msn_normalize(const PurpleAccount *account, const char *str) | 86 msn_normalize(const PurpleAccount *account, const char *str) |
78 { | 87 { |
79 static char buf[BUF_LEN]; | 88 static char buf[BUF_LEN]; |
80 char *tmp; | 89 char *tmp; |
725 msn_session_destroy(session); | 734 msn_session_destroy(session); |
726 | 735 |
727 gc->proto_data = NULL; | 736 gc->proto_data = NULL; |
728 } | 737 } |
729 | 738 |
739 static gboolean | |
740 msn_send_me_im(gpointer data) | |
741 { | |
742 MsnIMData *imdata = data; | |
743 serv_got_im(imdata->gc, imdata->who, imdata->msg, imdata->flags, imdata->when); | |
744 g_free(imdata->msg); | |
745 g_free(imdata); | |
746 return FALSE; | |
747 } | |
748 | |
730 static int | 749 static int |
731 msn_send_im(PurpleConnection *gc, const char *who, const char *message, | 750 msn_send_im(PurpleConnection *gc, const char *who, const char *message, |
732 PurpleMessageFlags flags) | 751 PurpleMessageFlags flags) |
733 { | 752 { |
734 PurpleAccount *account; | 753 PurpleAccount *account; |
777 } | 796 } |
778 else | 797 else |
779 { | 798 { |
780 char *body_str, *body_enc, *pre, *post; | 799 char *body_str, *body_enc, *pre, *post; |
781 const char *format; | 800 const char *format; |
801 MsnIMData *imdata = g_new0(MsnIMData, 1); | |
782 /* | 802 /* |
783 * In MSN, you can't send messages to yourself, so | 803 * In MSN, you can't send messages to yourself, so |
784 * we'll fake like we received it ;) | 804 * we'll fake like we received it ;) |
785 */ | 805 */ |
786 body_str = msn_message_to_string(msg); | 806 body_str = msn_message_to_string(msg); |
794 g_free(body_enc); | 814 g_free(body_enc); |
795 g_free(pre); | 815 g_free(pre); |
796 g_free(post); | 816 g_free(post); |
797 | 817 |
798 serv_got_typing_stopped(gc, who); | 818 serv_got_typing_stopped(gc, who); |
799 serv_got_im(gc, who, body_str, flags, time(NULL)); | 819 imdata->gc = gc; |
800 g_free(body_str); | 820 imdata->who = who; |
821 imdata->msg = body_str; | |
822 imdata->flags = flags; | |
823 imdata->when = time(NULL); | |
824 g_idle_add(msn_send_me_im, imdata); | |
801 } | 825 } |
802 | 826 |
803 msn_message_destroy(msg); | 827 msn_message_destroy(msg); |
804 | 828 |
805 return 1; | 829 return 1; |