# HG changeset patch # User Stu Tomlinson # Date 1178991484 0 # Node ID cb4380df3005c2a9e6be572965cfd1f330dd9567 # Parent f1547260a11eaa8ac364f76e4da87aba7f1bf4a2 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. diff -r f1547260a11e -r cb4380df3005 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Sat May 12 14:28:59 2007 +0000 +++ b/libpurple/protocols/msn/msn.c Sat May 12 17:38:04 2007 +0000 @@ -73,6 +73,15 @@ } MsnGetInfoStepTwoData; +typedef struct +{ + PurpleConnection *gc; + const char *who; + char *msg; + PurpleMessageFlags flags; + time_t when; +} MsnIMData; + static const char * msn_normalize(const PurpleAccount *account, const char *str) { @@ -727,6 +736,16 @@ gc->proto_data = NULL; } +static gboolean +msn_send_me_im(gpointer data) +{ + MsnIMData *imdata = data; + serv_got_im(imdata->gc, imdata->who, imdata->msg, imdata->flags, imdata->when); + g_free(imdata->msg); + g_free(imdata); + return FALSE; +} + static int msn_send_im(PurpleConnection *gc, const char *who, const char *message, PurpleMessageFlags flags) @@ -779,6 +798,7 @@ { char *body_str, *body_enc, *pre, *post; const char *format; + MsnIMData *imdata = g_new0(MsnIMData, 1); /* * In MSN, you can't send messages to yourself, so * we'll fake like we received it ;) @@ -796,8 +816,12 @@ g_free(post); serv_got_typing_stopped(gc, who); - serv_got_im(gc, who, body_str, flags, time(NULL)); - g_free(body_str); + imdata->gc = gc; + imdata->who = who; + imdata->msg = body_str; + imdata->flags = flags; + imdata->when = time(NULL); + g_idle_add(msn_send_me_im, imdata); } msn_message_destroy(msg);