Mercurial > pidgin
diff src/protocols/yahoo/yahoochat.c @ 14084:b7e4180af1db
[gaim-migrate @ 16705]
Don't use the same callback for both gaim_proxy_connect() and
gaim_input_add(). Aside from being a little confusing, it's
hindering some changes I want to make to gaim_proxy_connect().
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 11 Aug 2006 08:08:19 +0000 |
parents | 8934a27fed4b |
children | 10e8eb6a4910 |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoochat.c Fri Aug 11 08:01:16 2006 +0000 +++ b/src/protocols/yahoo/yahoochat.c Fri Aug 11 08:08:19 2006 +0000 @@ -1335,38 +1335,22 @@ yrl->rxlen = 0; } -static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_roomlist_send_cb(gpointer data, gint source, GaimInputCondition cond) { - struct yahoo_roomlist *yrl = data; - GaimRoomlist *list = yrl->list; - struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; - int written, total_len; - - if (source < 0) { - gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); - yahoo_roomlist_cleanup(list, yrl); - return; - } + struct yahoo_roomlist *yrl; + GaimRoomlist *list; + int written, remaining; - if (yrl->txbuf == NULL) { - yrl->fd = source; + yrl = data; + list = yrl->list; - yrl->txbuf = g_strdup_printf( - "GET http://%s/%s HTTP/1.0\r\n" - "Host: %s\r\n" - "Cookie: Y=%s; T=%s\r\n\r\n", - yrl->host, yrl->path, yrl->host, yd->cookie_y, - yd->cookie_t); - } - - total_len = strlen(yrl->txbuf) - yrl->tx_written; - written = write(yrl->fd, yrl->txbuf + yrl->tx_written, total_len); + remaining = strlen(yrl->txbuf) - yrl->tx_written; + written = write(yrl->fd, yrl->txbuf + yrl->tx_written, remaining); if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + gaim_input_remove(yrl->inpa); yrl->inpa = 0; g_free(yrl->txbuf); yrl->txbuf = NULL; @@ -1375,22 +1359,45 @@ return; } - if (written < total_len) { - if (!yrl->inpa) - yrl->inpa = gaim_input_add(yrl->fd, - GAIM_INPUT_WRITE, yahoo_roomlist_got_connected, - yrl); + if (written < remaining) { yrl->tx_written += written; return; } g_free(yrl->txbuf); yrl->txbuf = NULL; - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + + gaim_input_remove(yrl->inpa); yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, - yahoo_roomlist_pending, yrl); + yahoo_roomlist_pending, yrl); + +} + +static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +{ + struct yahoo_roomlist *yrl = data; + GaimRoomlist *list = yrl->list; + struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; + if (source < 0) { + gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); + yahoo_roomlist_cleanup(list, yrl); + return; + } + + yrl->fd = source; + + yrl->txbuf = g_strdup_printf( + "GET http://%s/%s HTTP/1.0\r\n" + "Host: %s\r\n" + "Cookie: Y=%s; T=%s\r\n\r\n", + yrl->host, yrl->path, yrl->host, yd->cookie_y, + yd->cookie_t); + + + yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_WRITE, + yahoo_roomlist_send_cb, yrl); + yahoo_roomlist_send_cb(yrl, yrl->fd, GAIM_INPUT_WRITE); } GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc)