| 1141 } |
1141 } |
| 1142 |
1142 |
| 1143 static void yahoo_chatxml_state_destroy(struct yahoo_chatxml_state *s) |
1143 static void yahoo_chatxml_state_destroy(struct yahoo_chatxml_state *s) |
| 1144 { |
1144 { |
| 1145 g_queue_free(s->q); |
1145 g_queue_free(s->q); |
| 1146 if (s->room.name) |
1146 g_free(s->room.name); |
| 1147 g_free(s->room.name); |
1147 g_free(s->room.topic); |
| 1148 if (s->room.topic) |
1148 g_free(s->room.id); |
| 1149 g_free(s->room.topic); |
|
| 1150 if (s->room.id) |
|
| 1151 g_free(s->room.id); |
|
| 1152 g_free(s); |
1149 g_free(s); |
| 1153 } |
1150 } |
| 1154 |
1151 |
| 1155 static void yahoo_chatlist_start_element(GMarkupParseContext *context, |
1152 static void yahoo_chatlist_start_element(GMarkupParseContext *context, |
| 1156 const gchar *ename, const gchar **anames, |
1153 const gchar *ename, const gchar **anames, |
| 1296 guchar *start; |
1293 guchar *start; |
| 1297 struct yahoo_chatxml_state *s; |
1294 struct yahoo_chatxml_state *s; |
| 1298 |
1295 |
| 1299 len = read(yrl->fd, buf, sizeof(buf)); |
1296 len = read(yrl->fd, buf, sizeof(buf)); |
| 1300 |
1297 |
| |
1298 if (len < 0 && errno == EAGAIN) |
| |
1299 return; |
| |
1300 |
| 1301 if (len <= 0) { |
1301 if (len <= 0) { |
| 1302 if (yrl->parse) |
1302 if (yrl->parse) |
| 1303 g_markup_parse_context_end_parse(yrl->parse, NULL); |
1303 g_markup_parse_context_end_parse(yrl->parse, NULL); |
| 1304 yahoo_roomlist_cleanup(list, yrl); |
1304 yahoo_roomlist_cleanup(list, yrl); |
| 1305 return; |
1305 return; |
| 1336 |
1336 |
| 1337 static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) |
1337 static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) |
| 1338 { |
1338 { |
| 1339 struct yahoo_roomlist *yrl = data; |
1339 struct yahoo_roomlist *yrl = data; |
| 1340 GaimRoomlist *list = yrl->list; |
1340 GaimRoomlist *list = yrl->list; |
| 1341 char *buf, *cookie; |
|
| 1342 struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; |
1341 struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; |
| |
1342 int written, total_len; |
| 1343 |
1343 |
| 1344 if (source < 0) { |
1344 if (source < 0) { |
| 1345 gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); |
1345 gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); |
| 1346 yahoo_roomlist_cleanup(list, yrl); |
1346 yahoo_roomlist_cleanup(list, yrl); |
| 1347 return; |
1347 return; |
| 1348 } |
1348 } |
| 1349 |
1349 |
| 1350 yrl->fd = source; |
1350 if (yrl->txbuf == NULL) { |
| 1351 |
1351 yrl->fd = source; |
| 1352 cookie = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t); |
1352 |
| 1353 buf = g_strdup_printf("GET http://%s/%s HTTP/1.0\r\nHost: %s\r\nCookie: %s\r\n\r\n", |
1353 yrl->txbuf = g_strdup_printf( |
| 1354 yrl->host, yrl->path, yrl->host, cookie); |
1354 "GET http://%s/%s HTTP/1.0\r\n" |
| 1355 write(yrl->fd, buf, strlen(buf)); |
1355 "Host: %s\r\n" |
| 1356 g_free(cookie); |
1356 "Cookie: Y=%s; T=%s\r\n\r\n", |
| 1357 g_free(buf); |
1357 yrl->host, yrl->path, yrl->host, yd->cookie_y, |
| 1358 yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, yahoo_roomlist_pending, yrl); |
1358 yd->cookie_t); |
| |
1359 } |
| |
1360 |
| |
1361 total_len = strlen(yrl->txbuf) - yrl->tx_written; |
| |
1362 written = write(yrl->fd, yrl->txbuf + yrl->tx_written, total_len); |
| |
1363 |
| |
1364 if (written < 0 && errno == EAGAIN) |
| |
1365 written = 0; |
| |
1366 else if (written <= 0) { |
| |
1367 if (yrl->inpa) |
| |
1368 gaim_input_remove(yrl->inpa); |
| |
1369 yrl->inpa = 0; |
| |
1370 g_free(yrl->txbuf); |
| |
1371 yrl->txbuf = NULL; |
| |
1372 gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); |
| |
1373 yahoo_roomlist_cleanup(list, yrl); |
| |
1374 return; |
| |
1375 } |
| |
1376 |
| |
1377 if (written < total_len) { |
| |
1378 if (!yrl->inpa) |
| |
1379 yrl->inpa = gaim_input_add(yrl->fd, |
| |
1380 GAIM_INPUT_WRITE, yahoo_roomlist_got_connected, |
| |
1381 yrl); |
| |
1382 yrl->tx_written += written; |
| |
1383 return; |
| |
1384 } |
| |
1385 |
| |
1386 g_free(yrl->txbuf); |
| |
1387 yrl->txbuf = NULL; |
| |
1388 if (yrl->inpa) |
| |
1389 gaim_input_remove(yrl->inpa); |
| |
1390 yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, |
| |
1391 yahoo_roomlist_pending, yrl); |
| 1359 |
1392 |
| 1360 } |
1393 } |
| 1361 |
1394 |
| 1362 GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc) |
1395 GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc) |
| 1363 { |
1396 { |