Mercurial > pidgin.yaz
changeset 1771:213607e89598
[gaim-migrate @ 1781]
plug mem leak. don't show evil level if it decreased. mid's utf8 patch for jabber. my girlfriend got an accounting calculator today, you know, with the paper and the printing and things. it's kinda loud. she's really happy about having it. she had bought a different one yesterday but it didn't work so we returned it today. we also went to Albertson's and bought groceries. we bought 72 cans of soda for $15. That's 20 cents per soda. Not bad. we also bought a cow; i'm going to cook it tonight. ben&jerry's ice cream is good.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 30 Apr 2001 01:25:30 +0000 |
parents | 7249312f46dc |
children | 896432d66303 |
files | plugins/jabber/jabber.c src/multi.h src/server.c |
diffstat | 3 files changed, 69 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/jabber/jabber.c Sun Apr 29 01:33:09 2001 +0000 +++ b/plugins/jabber/jabber.c Mon Apr 30 01:25:30 2001 +0000 @@ -470,6 +470,47 @@ return FALSE; } +static unsigned char *utf8_to_str(unsigned char *in) +{ + int n = 0,i = 0; + int inlen; + unsigned char *result; + + if (!in) + return NULL; + + inlen = strlen(in); + + result = (unsigned char*)malloc(inlen+1); + + while(n <= inlen-1) { + long c = (long)in[n]; + if(c<0x80) + result[i++] = (char)c; + else { + if((c&0xC0) == 0xC0) + result[i++] = (char)(((c&0x03)<<6)|(((unsigned char)in[++n])&0x3F)); + else if((c&0xE0) == 0xE0) { + if (n + 2 <= inlen) { + result[i] = (char)(((c&0xF)<<4)|(((unsigned char)in[++n])&0x3F)); + result[i] = (char)(((unsigned char)result[i]) |(((unsigned char)in[++n])&0x3F)); + i++; + } else n += 2; + } + else if((c&0xF0) == 0xF0) + n += 3; + else if((c&0xF8) == 0xF8) + n += 4; + else if((c&0xFC) == 0xFC) + n += 5; + } + n++; + } + result[i] = '\0'; + + return result; +} + static void jabber_handlemessage(gjconn j, jpacket p) { xmlnode y, xmlns; @@ -487,10 +528,14 @@ type = xmlnode_get_attrib(xmlns, "xmlns"); from = jid_full(p->from); - if ((y = xmlnode_get_tag(p->x, "body"))) { + if ((y = xmlnode_get_tag(p->x, "html"))) { + msg = xmlnode_get_data(y); + } else if ((y = xmlnode_get_tag(p->x, "body"))) { msg = xmlnode_get_data(y); } + msg = utf8_to_str(msg); + if (!from || !msg) { return; } @@ -515,6 +560,8 @@ g_free(from); } + free(msg); + } else if (!strcmp(type, "error")) { if ((y = xmlnode_get_tag(p->x, "error"))) { type = xmlnode_get_attrib(y, "code"); @@ -530,9 +577,15 @@ struct conversation *b; static int i = 0; from = jid_full(p->from); - if ((y = xmlnode_get_tag(p->x, "body"))) { + + if ((y = xmlnode_get_tag(p->x, "html"))) { + msg = xmlnode_get_data(y); + } else if ((y = xmlnode_get_tag(p->x, "body"))) { msg = xmlnode_get_data(y); } + + msg = utf8_to_str(msg); + b = find_chat(GJ_GC(j), p->from->user); if (!b) { jid chat = NULL; @@ -569,11 +622,10 @@ g_snprintf(buf, sizeof(buf), "%s", msg); serv_got_chat_in(GJ_GC(j), b->id, p->from->resource, 0, buf, time((time_t)NULL)); } - /* - } else if (msg) { - write_to_conv(b, msg, WFLAG_SYSTEM, NULL); - */ } + + free(msg); + } else { debug_printf("unhandled message %s\n", type); }
--- a/src/multi.h Sun Apr 29 01:33:09 2001 +0000 +++ b/src/multi.h Mon Apr 30 01:25:30 2001 +0000 @@ -71,6 +71,8 @@ char *away; int is_auto_away; + + int evil; }; /* now that we have our struct, we're going to need lots of them. Maybe even a list of them. */
--- a/src/server.c Sun Apr 29 01:33:09 2001 +0000 +++ b/src/server.c Mon Apr 30 01:25:30 2001 +0000 @@ -541,16 +541,21 @@ void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) { - char *buf2 = g_malloc(1024); + char buf2[1024]; GtkWidget *d, *label, *close; - plugin_event(event_warned, gc, name, (void *)lev, 0); - g_snprintf(buf2, 1023, "%s has just been warned by %s.\nYour new warning level is %d%%", + if (gc->evil > lev) { + gc->evil = lev; + return; + } + + gc->evil = lev; + + g_snprintf(buf2, sizeof(buf2), "%s has just been warned by %s.\nYour new warning level is %d%%", gc->username, ((name == NULL)? "an anonymous person" : name), lev); - d = gtk_dialog_new(); gtk_widget_realize(d); aol_icon(d->window);