# HG changeset patch # User Richard Laager # Date 1180936513 0 # Node ID 678d78b7fa34baa213addcb298d3a84684f6a764 # Parent 541a6b0112c6396db1b684f794699207268ef05f# Parent 6608a7ab0fd96d269c99e78d326ef4f4eea9967c propagate from branch 'im.pidgin.pidgin' (head a58972b72c7aa0fa0899c5a6b96e51cd6c427ab4) to branch 'im.pidgin.pidgin.2.1.0' (head 03df10bd904eed59317242a557aed2b8430d9630) diff -r 541a6b0112c6 -r 678d78b7fa34 COPYRIGHT --- a/COPYRIGHT Mon Jun 04 05:47:51 2007 +0000 +++ b/COPYRIGHT Mon Jun 04 05:55:13 2007 +0000 @@ -8,6 +8,7 @@ Dave Ahlswede Manuel Amador Matt Amato +Elliott Sales de Andrade Geoffrey Antos Daniel Atallah Paul Aurich diff -r 541a6b0112c6 -r 678d78b7fa34 ChangeLog --- a/ChangeLog Mon Jun 04 05:47:51 2007 +0000 +++ b/ChangeLog Mon Jun 04 05:55:13 2007 +0000 @@ -21,12 +21,16 @@ version 2.0.2 (??/??/????): Pidgin: * Added a custom conversation font option to preferences + * Fixed smiley ordering in the insert smiley popup to be more intuitive libpurple: * Moving an ICQ buddy from one group to another no longer re-requests authorization from that person (Rene Hausleitner) * Added nullprpl, an example protocol plugin (Ryan Barrett) * Fixed SOCKS5 bug which caused Jabber file receiving to fail + * Remove MSN's random "Authorization Failed" dialogs + * Fix MSN to correctly detect incorrect passwords and disable the account + * Get User Info on MSN is now more reliable & accurate Finch: * Auto account reconnecting diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/idle.c --- a/libpurple/idle.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/idle.c Mon Jun 04 05:55:13 2007 +0000 @@ -121,7 +121,7 @@ gboolean report_idle; GList *l; gint away_seconds = 0; - gint idle_recheck_interval; + gint idle_recheck_interval = 0; purple_signal_emit(purple_blist_get_handle(), "update-idle"); diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/plugins/joinpart.c --- a/libpurple/plugins/joinpart.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/plugins/joinpart.c Mon Jun 04 05:55:13 2007 +0000 @@ -210,7 +210,7 @@ * we don't have to worry one will be called after this. */ g_hash_table_destroy((GHashTable *)data[0]); - g_source_remove(GPOINTER_TO_UINT(data[1])); + purple_timeout_remove(GPOINTER_TO_UINT(data[1])); g_free(data); return TRUE; diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/plugins/log_reader.c --- a/libpurple/plugins/log_reader.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/plugins/log_reader.c Mon Jun 04 05:55:13 2007 +0000 @@ -1482,46 +1482,66 @@ * "> * Then, replace the next " " (or add this if the end-of-line is reached) with: * + * + * As implemented, this isn't perfect, but it should cover common cases. */ link_temp_line = NULL; - while ((link = g_strstr_len(line, strlen(line), "(Link: "))) { - GString *temp; + while ((link = strstr(line, "(Link: "))) + { + char *tmp = link; - if (!*link) - continue; + link += 7; + if (*link) + { + char *end_paren; + char *space; + GString *temp; - *link = '\0'; - link++; + if (!(end_paren = strstr(link, ")"))) + { + /* Something is not as we expect. Bail out. */ + break; + } - temp = g_string_new(line); - g_string_append(temp, " tag. */ + g_string_append(temp, "= 6) { - link += (sizeof("(Link: ") - 1); + /* Finish the tag. */ + g_string_append(temp, "\">"); + + /* The \r is a bit of a hack to keep there from being a \r in + * the link text, which may not matter. */ + if ((space = strstr(end_paren, " ")) || (space = strstr(end_paren, "\r"))) + { + g_string_append_len(temp, end_paren + 1, space - end_paren - 1); - while (*link && *link != ')') { - g_string_append_c(temp, *link); - link++; + /* Close the tag. */ + g_string_append(temp, ""); + + space++; + if (*space) + { + g_string_append_c(temp, ' '); + /* Keep the rest of the line. */ + g_string_append(temp, space); + } } - if (link) { - link++; - - g_string_append(temp, "\">"); - while (*link && *link != ' ') { - g_string_append_c(temp, *link); - link++; - } + else + { + /* There is no space before the end of the line. */ + g_string_append(temp, end_paren + 1); + /* Close the tag. */ g_string_append(temp, ""); } - g_string_append(temp, link); - - /* Free the last round's line. */ - if (link_temp_line) - g_free(line); - - line = temp->str; - g_string_free(temp, FALSE); + g_free(link_temp_line); + line = g_string_free(temp, FALSE); /* Save this memory location so we can free it later. */ link_temp_line = line; @@ -1661,8 +1681,7 @@ g_string_append_c(formatted, '\n'); - if (link_temp_line) - g_free(link_temp_line); + g_free(link_temp_line); c++; line = c; diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/plugins/perl/perl-handlers.c --- a/libpurple/plugins/perl/perl-handlers.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/plugins/perl/perl-handlers.c Mon Jun 04 05:55:13 2007 +0000 @@ -184,7 +184,7 @@ timeout_handlers = g_list_remove(timeout_handlers, handler); if (handler->iotag > 0) - g_source_remove(handler->iotag); + purple_timeout_remove(handler->iotag); if (handler->callback != NULL) SvREFCNT_dec(handler->callback); @@ -405,7 +405,7 @@ timeout_handlers = g_list_append(timeout_handlers, handler); - handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); + handler->iotag = purple_timeout_add(seconds * 1000, perl_timeout_cb, handler); } void diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/oscar/flap_connection.c --- a/libpurple/protocols/oscar/flap_connection.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/oscar/flap_connection.c Mon Jun 04 05:55:13 2007 +0000 @@ -303,7 +303,7 @@ } } - if (conn->fd != -1) + if (conn->fd >= 0) { if (conn->type == SNAC_FAMILY_LOCATE) flap_connection_send_close(od, conn); @@ -792,7 +792,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -853,7 +853,7 @@ break; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -902,7 +902,7 @@ ret = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); if (ret <= 0) { - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) + if (ret < 0 && ((errno == EAGAIN)) || ((errno == EWOULDBLOCK))) /* No worries */ return; @@ -936,7 +936,7 @@ purple_circ_buffer_append(conn->buffer_outgoing, bs->data, count); /* If we haven't already started writing stuff, then start the cycle */ - if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) + if ((conn->watcher_outgoing == 0) && (conn->fd >= 0)) { conn->watcher_outgoing = purple_input_add(conn->fd, PURPLE_INPUT_WRITE, send_cb, conn); diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/oscar/odc.c --- a/libpurple/protocols/oscar/odc.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/oscar/odc.c Mon Jun 04 05:55:13 2007 +0000 @@ -447,7 +447,7 @@ return; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/oscar/oscar.c Mon Jun 04 05:55:13 2007 +0000 @@ -1604,8 +1604,7 @@ straight_to_hell, pos) == NULL) { char buf[256]; - if (pos->modname) - g_free(pos->modname); + g_free(pos->modname); g_free(pos); g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. " "Check %s for updates."), PURPLE_WEBSITE); diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/oscar/peer.c --- a/libpurple/protocols/oscar/peer.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/oscar/peer.c Mon Jun 04 05:55:13 2007 +0000 @@ -173,12 +173,12 @@ purple_input_remove(conn->watcher_outgoing); conn->watcher_outgoing = 0; } - if (conn->listenerfd != -1) + if (conn->listenerfd >= 0) { close(conn->listenerfd); conn->listenerfd = -1; } - if (conn->fd != -1) + if (conn->fd >= 0) { close(conn->fd); conn->fd = -1; @@ -310,7 +310,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -360,7 +360,7 @@ return; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -422,7 +422,7 @@ wrotelen = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); if (wrotelen <= 0) { - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) + if (wrotelen < 0 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) /* No worries */ return; @@ -462,7 +462,7 @@ purple_circ_buffer_append(conn->buffer_outgoing, bs->data, bs->len); /* If we haven't already started writing stuff, then start the cycle */ - if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) + if ((conn->watcher_outgoing == 0) && (conn->fd >= 0)) { conn->watcher_outgoing = purple_input_add(conn->fd, PURPLE_INPUT_WRITE, send_cb, conn); @@ -596,7 +596,7 @@ purple_debug_info("oscar", "Accepting connection on listener socket.\n"); conn->fd = accept(conn->listenerfd, &addr, &addrlen); - if (conn->fd == -1) + if (conn->fd < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No connection yet--no worries */ @@ -640,7 +640,7 @@ conn = data; conn->listen_data = NULL; - if (listenerfd == -1) + if (listenerfd < 0) { /* Could not open listener socket */ peer_connection_trynext(conn); diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/oscar/peer_proxy.c --- a/libpurple/protocols/oscar/peer_proxy.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/oscar/peer_proxy.c Mon Jun 04 05:55:13 2007 +0000 @@ -224,7 +224,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -285,7 +285,8 @@ return; } - if (read == -1) + /* If there was an error then close the connection */ + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/silc/silc.c --- a/libpurple/protocols/silc/silc.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/silc/silc.c Mon Jun 04 05:55:13 2007 +0000 @@ -119,12 +119,12 @@ NULL, 0); } -static int +static gboolean silcpurple_scheduler(gpointer *context) { SilcPurple sg = (SilcPurple)context; silc_client_run_one(sg->client); - return 1; + return TRUE; } static void @@ -361,11 +361,7 @@ } /* Schedule SILC using Glib's event loop */ -#ifndef _WIN32 - sg->scheduler = g_timeout_add(5, (GSourceFunc)silcpurple_scheduler, sg); -#else - sg->scheduler = g_timeout_add(300, (GSourceFunc)silcpurple_scheduler, sg); -#endif + sg->scheduler = purple_timeout_add(300, (GSourceFunc)silcpurple_scheduler, sg); } static int @@ -396,8 +392,8 @@ if (sg->conn) silc_client_close_connection(sg->client, sg->conn); - g_source_remove(sg->scheduler); - g_timeout_add(1, (GSourceFunc)silcpurple_close_final, sg); + purple_timeout_remove(sg->scheduler); + purple_timeout_add(1, (GSourceFunc)silcpurple_close_final, sg); } diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/protocols/yahoo/yahoo.c --- a/libpurple/protocols/yahoo/yahoo.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon Jun 04 05:55:13 2007 +0000 @@ -2310,7 +2310,7 @@ * are you trying to pull? */ guchar *start; - purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!"); + purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!\n"); start = memchr(yd->rxqueue + 1, 'Y', yd->rxlen - 1); if (start) { @@ -2377,7 +2377,11 @@ } if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), + error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2405,7 +2409,11 @@ } if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), + error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2507,12 +2515,16 @@ if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { + gchar *tmp; g_free(yd->auth); yd->auth = NULL; if (gc->inpa) purple_input_remove(gc->inpa); gc->inpa = 0; - purple_connection_error(gc, _("Unable to connect.")); + tmp = g_strdup_printf(_("Lost connection with %s:\n%s"), + "login.yahoo.com:80", strerror(errno)); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2533,7 +2545,11 @@ PurpleConnection *gc = data; if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"), + "login.yahoo.com:80", error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2616,8 +2632,7 @@ if (error_message != NULL) { - /* TODO: Include error_message in the message below */ - purple_connection_error(gc, _("Unable to connect.")); + purple_connection_error(gc, error_message); return; } diff -r 541a6b0112c6 -r 678d78b7fa34 libpurple/util.c --- a/libpurple/util.c Mon Jun 04 05:47:51 2007 +0000 +++ b/libpurple/util.c Mon Jun 04 05:55:13 2007 +0000 @@ -47,6 +47,7 @@ } website; char *url; + int num_times_redirected; gboolean full; char *user_agent; gboolean http11; @@ -1285,14 +1286,17 @@ pt->dest_tag = y; \ tags = g_list_prepend(tags, pt); \ } \ - xhtml = g_string_append(xhtml, "<" y); \ - c += strlen("<" x ); \ - xhtml = g_string_append(xhtml, innards->str); \ - xhtml = g_string_append_c(xhtml, '>'); \ + if(xhtml) { \ + xhtml = g_string_append(xhtml, "<" y); \ + xhtml = g_string_append(xhtml, innards->str); \ + xhtml = g_string_append_c(xhtml, '>'); \ + } \ c = p + 1; \ } else { \ - xhtml = g_string_append(xhtml, "<"); \ - plain = g_string_append_c(plain, '<'); \ + if(xhtml) \ + xhtml = g_string_append(xhtml, "<"); \ + if(plain) \ + plain = g_string_append_c(plain, '<'); \ c++; \ } \ g_string_free(innards, TRUE); \ @@ -1301,16 +1305,19 @@ if(!g_ascii_strncasecmp(c, "<" x, strlen("<" x)) && \ (*(c+strlen("<" x)) == '>' || \ !g_ascii_strncasecmp(c+strlen("<" x), "/>", 2))) { \ - xhtml = g_string_append(xhtml, "<" y); \ + if(xhtml) \ + xhtml = g_string_append(xhtml, "<" y); \ c += strlen("<" x); \ if(*c != '/') { \ struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \ pt->src_tag = x; \ pt->dest_tag = y; \ tags = g_list_prepend(tags, pt); \ - xhtml = g_string_append_c(xhtml, '>'); \ + if(xhtml) \ + xhtml = g_string_append_c(xhtml, '>'); \ } else { \ - xhtml = g_string_append(xhtml, "/>");\ + if(xhtml) \ + xhtml = g_string_append(xhtml, "/>");\ } \ c = strchr(c, '>') + 1; \ continue; \ @@ -1320,11 +1327,18 @@ purple_markup_html_to_xhtml(const char *html, char **xhtml_out, char **plain_out) { - GString *xhtml = g_string_new(""); - GString *plain = g_string_new(""); + GString *xhtml = NULL; + GString *plain = NULL; GList *tags = NULL, *tag; const char *c = html; + g_return_if_fail(xhtml_out != NULL || plain_out != NULL); + + if(xhtml_out) + xhtml = g_string_new(""); + if(plain_out) + plain = g_string_new(""); + while(c && *c) { if(*c == '<') { if(*(c+1) == '/') { /* closing tag */ @@ -1340,7 +1354,8 @@ if(tag) { while(tags) { struct purple_parse_tag *pt = tags->data; - g_string_append_printf(xhtml, "", pt->dest_tag); + if(xhtml) + g_string_append_printf(xhtml, "", pt->dest_tag); if(tags == tag) break; tags = g_list_remove(tags, pt); @@ -1358,8 +1373,10 @@ if(*end == '>') { c = end+1; } else { - xhtml = g_string_append(xhtml, "<"); - plain = g_string_append_c(plain, '<'); + if(xhtml) + xhtml = g_string_append(xhtml, "<"); + if(plain) + plain = g_string_append_c(plain, '<'); c++; } } @@ -1388,7 +1405,8 @@ ALLOW_TAG("span"); ALLOW_TAG("strong"); ALLOW_TAG("ul"); - + ALLOW_TAG("img"); + /* we skip
because it's not legal in XHTML-IM. However, * we still want to send something sensible, so we put a * linebreak in its place.
also needs special handling @@ -1399,8 +1417,9 @@ !g_ascii_strncasecmp(c+3, "/>", 2) || !g_ascii_strncasecmp(c+3, " />", 3))) { c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, "
"); - if(*c != '\n') + if(xhtml) + xhtml = g_string_append(xhtml, "
"); + if(plain && *c != '\n') plain = g_string_append_c(plain, '\n'); continue; } @@ -1444,7 +1463,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { @@ -1453,7 +1473,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if (xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { @@ -1462,7 +1483,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 5)) { @@ -1471,7 +1493,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 5)) { @@ -1480,7 +1503,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "' || *(c+5) == ' ')) { @@ -1574,7 +1598,10 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); if(style->len) - g_string_append_printf(xhtml, "", g_strstrip(style->str)); + { + if(xhtml) + g_string_append_printf(xhtml, "", g_strstrip(style->str)); + } else pt->ignore = TRUE; g_string_free(style, TRUE); @@ -1594,7 +1621,8 @@ color = g_string_append_c(color, *q); q++; } - g_string_append_printf(xhtml, "", g_strstrip(color->str)); + if(xhtml) + g_string_append_printf(xhtml, "", g_strstrip(color->str)); g_string_free(color, TRUE); if ((c = strchr(c, '>')) != NULL) c++; @@ -1615,14 +1643,17 @@ if(!g_ascii_strncasecmp(c, ""); if(p) { - xhtml = g_string_append(xhtml, "