# HG changeset patch # User Mark Doliner # Date 1076650632 0 # Node ID b248c1f4efbd31a02e851a4d686976e9891e5cc8 # Parent b51ed4506180235a813e3cec052c10325fcedab0 [gaim-migrate @ 8973] 1) Minor changes to the network listen code again. Tim, let me know if you have any other suggestions. 2) Changed how charsets are handled in oscar a tad bit. I think this should guarantee that Gaim doesn't crash when people send funky messages, or have funky away messages or really anything that is using a charset that isn't utf8, iso-8859-1, ucs-2be, or ascii. Ethan, this should fix the problem with that person's away message. Although, the message itself still looks kinda funky to me. The encoding is Windows-31J, which is apparently a valid iconv encoding? You would know more than I. 3) Fix the following crash: 1. IM yourself a message on AIM 2. Do NOT begin to type a second message, but instead hit CTRL+up committer: Tailor Script diff -r b51ed4506180 -r b248c1f4efbd plugins/autorecon.c --- a/plugins/autorecon.c Thu Feb 12 23:51:39 2004 +0000 +++ b/plugins/autorecon.c Fri Feb 13 05:37:12 2004 +0000 @@ -53,9 +53,9 @@ info->delay = INITIAL; } else { info->delay = MIN(2 * info->delay, MAXTIME); + if (info->timeout != 0) + g_source_remove(info->timeout); } - if (info->timeout != 0) - g_source_remove(info->timeout); info->timeout = g_timeout_add(info->delay, do_signon, account); } else if (info != NULL) { g_hash_table_remove(hash, account); diff -r b51ed4506180 -r b248c1f4efbd src/gtkimhtml.c --- a/src/gtkimhtml.c Thu Feb 12 23:51:39 2004 +0000 +++ b/src/gtkimhtml.c Fri Feb 13 05:37:12 2004 +0000 @@ -2428,7 +2428,7 @@ span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); } if (size != -1) { - span = g_malloc(sizeof(GtkIMHtmlFormatSpan)); + span = g_malloc0(sizeof(GtkIMHtmlFormatSpan)); span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); span->end = NULL; span->buffer = imhtml->text_buffer; @@ -2458,7 +2458,7 @@ span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); } - span = g_malloc(sizeof(GtkIMHtmlFormatSpan)); + span = g_malloc0(sizeof(GtkIMHtmlFormatSpan)); span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); span->end = NULL; span->buffer = imhtml->text_buffer; @@ -2487,7 +2487,7 @@ span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); } - span = g_malloc(sizeof(GtkIMHtmlFormatSpan)); + span = g_malloc0(sizeof(GtkIMHtmlFormatSpan)); span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); span->end = NULL; span->tag = NULL; diff -r b51ed4506180 -r b248c1f4efbd src/network.c --- a/src/network.c Thu Feb 12 23:51:39 2004 +0000 +++ b/src/network.c Fri Feb 13 05:37:12 2004 +0000 @@ -189,19 +189,23 @@ return listenfd; } -int gaim_network_listen(short port) +int gaim_network_listen(unsigned short port) { + g_return_val_if_fail(port != 0, -1); + return gaim_network_do_listen(port); } -int gaim_network_listen_range(short start, short end) +int gaim_network_listen_range(unsigned short start, unsigned short end) { int ret = -1; - if (gaim_prefs_get_bool("/core/network/ports_range_use") || - (start > end) || (start < 0) || (end < 0)) { + if (gaim_prefs_get_bool("/core/network/ports_range_use")) { start = gaim_prefs_get_int("/core/network/ports_range_start"); end = gaim_prefs_get_int("/core/network/ports_range_end"); + } else { + if (end < start) + end = start; } for (; start <= end; start++) { diff -r b51ed4506180 -r b248c1f4efbd src/network.h --- a/src/network.h Thu Feb 12 23:51:39 2004 +0000 +++ b/src/network.h Fri Feb 13 05:37:12 2004 +0000 @@ -88,10 +88,10 @@ const char *gaim_network_get_ip_for_account(const GaimAccount *account, int fd); /** - * Attempts to open a listening port ONLY on the specified port number. - * You probably want to use gaim_network_listen_range() instead of this. - * This function is useful, for example, if you wanted to write a telnet - * server as a Gaim plugin, and you had to listen on port 23. Why anyone + * Attempts to open a listening port ONLY on the specified port number. + * You probably want to use gaim_network_listen_range() instead of this. + * This function is useful, for example, if you wanted to write a telnet + * server as a Gaim plugin, and you HAD to listen on port 23. Why anyone * would want to do that is beyond me. * * This opens a listening port. The caller will want to set up a watcher @@ -100,18 +100,18 @@ * the listening socket, and add a new watcher on the new socket accept * returned. * - * @param port The port number to bind to. + * @param port The port number to bind to. Must be greater than 0. * * @return The file descriptor of the listening socket, or -1 if * no socket could be established. */ -int gaim_network_listen(short port); +int gaim_network_listen(unsigned short port); /** - * Opens a listening port selected from a range of ports. The range of + * Opens a listening port selected from a range of ports. The range of * ports used is chosen in the following manner: * If a range is specified in preferences, these values are used. - * If a non-0 values are passed to the function as parameters, these + * If a non-0 values are passed to the function as parameters, these * values are used. * Otherwise a port is chosen at random by the kernel. * @@ -126,10 +126,11 @@ * @param end The highest possible port in the range of ports to listen on, * or 0 to pick a random port. Users are allowed to override this * arg in prefs. + * * @return The file descriptor of the listening socket, or -1 if * no socket could be established. */ -int gaim_network_listen_range(short start, short end); +int gaim_network_listen_range(unsigned short start, unsigned short end); /** * Gets a port number from a file descriptor. diff -r b51ed4506180 -r b248c1f4efbd src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Thu Feb 12 23:51:39 2004 +0000 +++ b/src/protocols/oscar/oscar.c Fri Feb 13 05:37:12 2004 +0000 @@ -375,8 +375,8 @@ return AIM_IMFLAGS_UNICODE; } else { gaim_debug(GAIM_DEBUG_WARNING, "oscar", - "Unrecognized character encoding '%s', falling back to ASCII\n", encoding); - return 0; + "Unrecognized character encoding '%s', attempting to convert to utf8 anyway\n", encoding); + return 99; } } @@ -387,7 +387,7 @@ switch (flags) { case 0: - utf8 = g_strndup(text, textlen); + utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL); break; case AIM_IMFLAGS_ISO_8859_1: utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); @@ -395,6 +395,12 @@ case AIM_IMFLAGS_UNICODE: utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); break; + case 99: + utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); + if (utf8 == NULL) { + utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL); + } + break; } return utf8;