From: <ka...@us...> - 2010-09-25 10:27:54
|
Revision: 390 http://libyahoo2.svn.sourceforge.net/libyahoo2/?rev=390&view=rev Author: kay21s Date: 2010-09-25 10:27:47 +0000 (Sat, 25 Sep 2010) Log Message: ----------- Add new callback function -- ext_yahoo_chat_room_received, it is called when user has received the response from server after requesting for chat room information Modified Paths: -------------- trunk/libyahoo2/src/libyahoo2.c trunk/libyahoo2/src/sample_client.c trunk/libyahoo2/src/yahoo2_callbacks.h Modified: trunk/libyahoo2/src/libyahoo2.c =================================================================== --- trunk/libyahoo2/src/libyahoo2.c 2010-09-19 18:15:44 UTC (rev 389) +++ trunk/libyahoo2/src/libyahoo2.c 2010-09-25 10:27:47 UTC (rev 390) @@ -3120,7 +3120,7 @@ return info; } -static void parse_chat_cat_xml(int id, const char *xml) +static int parse_chat_cat_xml(int id, const char *xml) { struct yahoo_data *yd = find_conn_by_id(id); struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_CHATCAT); @@ -3129,7 +3129,7 @@ YList *room_list; YList *list_ptr; YList *cat_stack[5]; - int stack_ptr = 0; + int stack_ptr = 0, room_id = 0; YList *temp, *child, *tail, *category; room_list = y_new0(struct _YList, 1); @@ -3138,6 +3138,7 @@ if (content == NULL) { category = find_room_category(yd->chat_room_list, yid->chat_room_id); + room_id = yid->chat_room_id; content = strdup(xml); content = strstr(content, "<chatRooms>"); @@ -3188,6 +3189,7 @@ ((yahoo_chatroom_category *)(category->data))->room_list = room_list->next; } else { + room_id = 0; while(stack_ptr >= 0) { /* prev is used as a pointer linked with its child categories */ @@ -3235,19 +3237,26 @@ yd->chat_room_list = room_list->next; } FREE(room_list); /* free the head node */ + return room_id; } static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, int over) { + int room_id; + if (over) return; if (strstr((char *)yid->rxqueue, "</content>")) { - parse_chat_cat_xml(yid->yd->client_id, (char *)yid->rxqueue); + room_id = parse_chat_cat_xml(yid->yd->client_id, (char *)yid->rxqueue); + YAHOO_CALLBACK(ext_yahoo_chat_room_received) (yid->yd->client_id, room_id); + /* ext_yahoo_chat_cat_xml() needs to be deprecated in future releases */ - YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, - (char *)yid->rxqueue); + if (NULL != YAHOO_CALLBACK(ext_yahoo_chat_cat_xml)) { + YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, + (char *)yid->rxqueue); + } } } Modified: trunk/libyahoo2/src/sample_client.c =================================================================== --- trunk/libyahoo2/src/sample_client.c 2010-09-19 18:15:44 UTC (rev 389) +++ trunk/libyahoo2/src/sample_client.c 2010-09-25 10:27:47 UTC (rev 390) @@ -633,6 +633,20 @@ } } +static void ext_yahoo_chat_room_received(int id, int room_id) +{ + YList *list; + void *ext_data = NULL; + + list = yahoo_get_chat_room_list(id, room_id, ext_data); + if(list) { + if(room_id == 0) + traverse_cat_list(list, 0); + else + traverse_room_list(list); + } +} + static void ext_yahoo_chat_join(int id, const char *me, const char *room, const char * topic, YList *members, void *fd) { print_message(("You [%s] have joined the chatroom %s with topic %s", me, room, topic)); Modified: trunk/libyahoo2/src/yahoo2_callbacks.h =================================================================== --- trunk/libyahoo2/src/yahoo2_callbacks.h 2010-09-19 18:15:44 UTC (rev 389) +++ trunk/libyahoo2/src/yahoo2_callbacks.h 2010-09-25 10:27:47 UTC (rev 390) @@ -727,6 +727,13 @@ */ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_verify) (const char *url, char *vcode); +/** + * After user request the server to send the chat room categories or chat room list, this function + * is called when the response is received + * @param id client id + * @param room_id chat room id, 0 if it is chat room categories + */ + void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_room_received) (int id, int room_id); }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |