Mercurial > pidgin
diff libpurple/protocols/yahoo/yahoochat.c @ 32672:3828a61c44da
A boring and large patch so I can merge heads.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 23 Dec 2011 08:21:58 +0000 |
parents | a8cc50c2279f |
children |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoochat.c Mon Aug 22 22:46:08 2011 +0000 +++ b/libpurple/protocols/yahoo/yahoochat.c Fri Dec 23 08:21:58 2011 +0000 @@ -53,7 +53,7 @@ /* special function to log us on to the yahoo chat service */ static void yahoo_chat_online(PurpleConnection *gc) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; const char *rll; @@ -101,7 +101,7 @@ YahooData *yd; GSList *l; - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); for (l = yd->confs; l; l = l->next) { PurpleConversation *c = l->data; @@ -372,7 +372,7 @@ static void yahoo_chat_join(PurpleConnection *gc, const char *dn, const char *room, const char *topic, const char *id) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; char *room2; gboolean utf8 = TRUE; @@ -400,7 +400,7 @@ /* this is a confirmation of yahoo_chat_online(); */ void yahoo_process_chat_online(PurpleConnection *gc, struct yahoo_packet *pkt) { - YahooData *yd = (YahooData *) gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); if (pkt->status == 1) { yd->chat_online = TRUE; @@ -432,7 +432,7 @@ /* this is basicly the opposite of chat_online */ void yahoo_process_chat_logout(PurpleConnection *gc, struct yahoo_packet *pkt) { - YahooData *yd = (YahooData *) gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); GSList *l; for (l = pkt->hash; l; l = l->next) { @@ -462,7 +462,7 @@ void yahoo_process_chat_join(PurpleConnection *gc, struct yahoo_packet *pkt) { PurpleAccount *account = purple_connection_get_account(gc); - YahooData *yd = (YahooData *) gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); PurpleConversation *c = NULL; GSList *l; GList *members = NULL; @@ -786,7 +786,7 @@ static int yahoo_conf_send(PurpleConnection *gc, const char *dn, const char *room, GList *members, const char *what) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; GList *who; char *msg, *msg2; @@ -843,7 +843,7 @@ static void yahoo_conf_invite(PurpleConnection *gc, PurpleConversation *c, const char *dn, const char *buddy, const char *room, const char *msg) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; GList *members; char *msg2 = NULL; @@ -873,7 +873,7 @@ static void yahoo_chat_leave(PurpleConnection *gc, const char *room, const char *dn, gboolean logout) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; char *eroom; @@ -924,7 +924,7 @@ static int yahoo_chat_send(PurpleConnection *gc, const char *dn, const char *room, const char *what, PurpleMessageFlags flags) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; int me = 0; char *msg1, *msg2, *room2; @@ -969,7 +969,7 @@ static void yahoo_chat_invite(PurpleConnection *gc, const char *dn, const char *buddy, const char *room, const char *msg) { - YahooData *yd = gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; char *room2, *msg2 = NULL; gboolean utf8 = TRUE; @@ -997,7 +997,7 @@ YahooData *yd; struct yahoo_packet *pkt; - yd = gc->proto_data; + yd = purple_connection_get_protocol_data(gc); if (yd->wm) { g_return_if_fail(yd->ycht != NULL); @@ -1029,7 +1029,7 @@ void yahoo_c_leave(PurpleConnection *gc, int id) { - YahooData *yd = (YahooData *) gc->proto_data; + YahooData *yd = purple_connection_get_protocol_data(gc); PurpleConversation *c; if (!yd) @@ -1056,7 +1056,7 @@ int ret; YahooData *yd; - yd = (YahooData *) gc->proto_data; + yd = purple_connection_get_protocol_data(gc); if (!yd) return -1; @@ -1114,7 +1114,7 @@ char *room, *topic, *type; PurpleConversation *c; - yd = (YahooData *) gc->proto_data; + yd = purple_connection_get_protocol_data(gc); if (!yd) return; @@ -1166,7 +1166,7 @@ PurpleConversation *c; c = purple_find_chat(gc, id); - if (!c || !c->name) + if (!c || !purple_conversation_get_name(c)) return; if (id != YAHOO_CHAT_ID) { @@ -1375,7 +1375,9 @@ purple_roomlist_set_in_progress(list, FALSE); if (yrl) { - list->proto_data = g_list_remove(list->proto_data, yrl); + GList *proto_data = purple_roomlist_get_proto_data(list); + proto_data = g_list_remove(proto_data, yrl); + purple_roomlist_set_proto_data(list, proto_data); yahoo_roomlist_destroy(yrl); } @@ -1451,7 +1453,7 @@ yrl->inpa = 0; g_free(yrl->txbuf); yrl->txbuf = NULL; - purple_notify_error(purple_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); + purple_notify_error(purple_account_get_connection(purple_roomlist_get_account(list)), NULL, _("Unable to connect"), _("Fetching the room list failed.")); yahoo_roomlist_cleanup(list, yrl); return; } @@ -1474,10 +1476,12 @@ { struct yahoo_roomlist *yrl = data; PurpleRoomlist *list = yrl->list; - YahooData *yd = purple_account_get_connection(list->account)->proto_data; + PurpleAccount *account = purple_roomlist_get_account(list); + PurpleConnection *pc = purple_account_get_connection(account); + YahooData *yd = purple_connection_get_protocol_data(pc); if (source < 0) { - purple_notify_error(purple_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); + purple_notify_error(pc, NULL, _("Unable to connect"), _("Fetching the room list failed.")); yahoo_roomlist_cleanup(list, yrl); return; } @@ -1506,6 +1510,7 @@ struct yahoo_roomlist *yrl; const char *rll, *rlurl; char *url; + GList *proto_data; account = purple_connection_get_account(gc); @@ -1556,7 +1561,9 @@ return NULL; } - rl->proto_data = g_list_append(rl->proto_data, yrl); + proto_data = purple_roomlist_get_proto_data(rl); + proto_data = g_list_append(proto_data, yrl); + purple_roomlist_set_proto_data(rl, proto_data); purple_roomlist_set_in_progress(rl, TRUE); return rl; @@ -1566,8 +1573,8 @@ { GList *l, *k; - k = l = list->proto_data; - list->proto_data = NULL; + k = l = purple_roomlist_get_proto_data(list); + purple_roomlist_set_proto_data(list, NULL); purple_roomlist_set_in_progress(list, FALSE); @@ -1580,36 +1587,42 @@ void yahoo_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category) { + PurpleAccount *account; struct yahoo_roomlist *yrl; char *url; char *id; const char *rll; + GList *proto_data; - if (category->type != PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) + if (purple_roomlist_room_get_type(category) != PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) return; - if (!(id = g_list_nth_data(category->fields, 1))) { + if (!(id = g_list_nth_data(purple_roomlist_room_get_fields(category), 1))) { purple_roomlist_set_in_progress(list, FALSE); return; } - rll = purple_account_get_string(list->account, "room_list_locale", + account = purple_roomlist_get_account(list); + rll = purple_account_get_string(account, "room_list_locale", YAHOO_ROOMLIST_LOCALE); if (rll != NULL && *rll != '\0') { url = g_strdup_printf("%s?chatroom_%s=0&intl=%s", - purple_account_get_string(list->account,"room_list", + purple_account_get_string(account,"room_list", YAHOO_ROOMLIST_URL), id, rll); } else { url = g_strdup_printf("%s?chatroom_%s=0", - purple_account_get_string(list->account,"room_list", + purple_account_get_string(account,"room_list", YAHOO_ROOMLIST_URL), id); } yrl = g_new0(struct yahoo_roomlist, 1); yrl->list = list; yrl->cat = category; - list->proto_data = g_list_append(list->proto_data, yrl); + + proto_data = purple_roomlist_get_proto_data(list); + proto_data = g_list_append(proto_data, yrl); + purple_roomlist_set_proto_data(list, proto_data); purple_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL); g_free(url); @@ -1617,11 +1630,11 @@ yrl->ucat = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat); purple_roomlist_room_add(list, yrl->ucat); - if (purple_proxy_connect(purple_account_get_connection(list->account), - list->account, yrl->host, 80, + if (purple_proxy_connect(purple_account_get_connection(account), + account, yrl->host, 80, yahoo_roomlist_got_connected, yrl) == NULL) { - purple_notify_error(purple_account_get_connection(list->account), + purple_notify_error(purple_account_get_connection(account), NULL, _("Connection problem"), _("Unable to fetch room list.")); purple_roomlist_ref(list); yahoo_roomlist_cleanup(list, yrl);