Mercurial > pidgin
changeset 20414:76e736b59aa4
fixes #971, we can only ADL 150 contacts at a time or the notification
server will kill us
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Mon, 14 May 2007 00:40:29 +0000 |
parents | fd7b501cc9c8 |
children | 6f3432091d4b 4c5d68e93ef8 |
files | libpurple/protocols/msn/notification.c |
diffstat | 1 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c Sat May 12 19:35:18 2007 +0000 +++ b/libpurple/protocols/msn/notification.c Mon May 14 00:40:29 2007 +0000 @@ -39,7 +39,7 @@ ****************************************************************************/ static void msn_notification_fqy_yahoo(MsnSession *session, const char *passport); -static void msn_notification_post_adl(MsnCmdProc *cmdproc, char *payload, int payload_len); +static void msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len); static void msn_add_contact_xml(xmlnode *mlNode, const char *passport, int list_op, int type); /************************************************************************** @@ -631,7 +631,7 @@ } static void -msn_notification_post_adl(MsnCmdProc *cmdproc, char *payload, int payload_len) +msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len) { MsnTransaction *trans; @@ -645,29 +645,42 @@ void msn_notification_dump_contact(MsnSession *session) { - MsnUserList *userlist; MsnUser *user; GList *l; xmlnode *adl_node; char *payload; int payload_len; + int adl_count = 0; const char *display_name; - userlist = session->userlist; adl_node = xmlnode_new("ml"); adl_node->child = NULL; xmlnode_set_attrib(adl_node, "l", "1"); - + /*get the userlist*/ - for (l = userlist->users; l != NULL; l = l->next){ + for (l = session->userlist->users; l != NULL; l = l->next){ user = l->data; - msn_add_contact_xml(adl_node,user->passport,user->list_op&MSN_LIST_OP_MASK,user->type); + msn_add_contact_xml(adl_node, user->passport, + user->list_op & MSN_LIST_OP_MASK, user->type); + + /* each ADL command may contain up to 150 contacts */ + if (++adl_count % 150 == 0 || l->next == NULL) { + payload = xmlnode_to_str(adl_node,&payload_len); + + msn_notification_post_adl(session->notification->cmdproc, + payload, payload_len); + + g_free(payload); + xmlnode_free(adl_node); + + if (l->next) { + adl_node = xmlnode_new("ml"); + adl_node->child = NULL; + xmlnode_set_attrib(adl_node, "l", "1"); + } + } } - payload = xmlnode_to_str(adl_node,&payload_len); - xmlnode_free(adl_node); - - msn_notification_post_adl(session->notification->cmdproc,payload,payload_len); display_name = purple_connection_get_display_name(session->account->gc); if (display_name && strcmp(display_name,