Mercurial > pidgin.yaz
changeset 20447:18ecdee88ed0
Add Pending list to recognized lists during contact list parsing
Don't try pushing Reverse or Pending lists to notification server
Improvements to detecting Yahoo users so Passports with @yahoo.com addresses
will work better. Fixes #1331
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Mon, 28 May 2007 16:12:25 +0000 |
parents | 9e585c2dbf07 |
children | c1ff701bcb0c |
files | libpurple/protocols/msn/contact.c libpurple/protocols/msn/msn.h libpurple/protocols/msn/notification.c libpurple/protocols/msn/user.c libpurple/protocols/msn/userlist.h |
diffstat | 5 files changed, 47 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c Mon May 28 02:20:41 2007 +0000 +++ b/libpurple/protocols/msn/contact.c Mon May 28 16:12:25 2007 +0000 @@ -96,6 +96,8 @@ return MSN_LIST_BL_OP; }else if(!strcmp(role,"Reverse")){ return MSN_LIST_RL_OP; + }else if(!strcmp(role,"Pending")){ + return MSN_LIST_PL_OP; } return 0; } @@ -340,6 +342,7 @@ xmlnode *contactId,*contactInfo,*contactType,*passportName,*displayName,*guid; xmlnode *groupIds; MsnUser *user; + MsnUserType usertype; char *passport,*Name,*uid,*type; passport = NULL; @@ -359,7 +362,7 @@ g_free(friendly); continue; /* Not adding own account as buddy to buddylist */ } - + usertype = msn_get_user_type(type); passportName = xmlnode_get_child(contactInfo,"passportName"); if(passportName == NULL){ xmlnode *emailsNode, *contactEmailNode, *emailNode; @@ -385,6 +388,7 @@ emailNode = xmlnode_get_child(contactEmailNode,"email"); passport = xmlnode_get_data(emailNode); purple_debug_info("MsnAB","Yahoo User %s\n",passport); + usertype = MSN_USER_TYPE_YAHOO; break; }else{ /*TODO maybe we can just ignore it in Purple?*/ @@ -414,7 +418,7 @@ user = msn_userlist_find_add_user(session->userlist, passport,Name); msn_user_set_uid(user,uid); - msn_user_set_type(user,msn_get_user_type(type)); + msn_user_set_type(user, usertype); g_free(Name); g_free(passport); g_free(uid);
--- a/libpurple/protocols/msn/msn.h Mon May 28 02:20:41 2007 +0000 +++ b/libpurple/protocols/msn/msn.h Mon May 28 16:12:25 2007 +0000 @@ -97,7 +97,8 @@ MSN_LIST_FL_OP = 0x01, MSN_LIST_AL_OP = 0x02, MSN_LIST_BL_OP = 0x04, - MSN_LIST_RL_OP = 0x08 + MSN_LIST_RL_OP = 0x08, + MSN_LIST_PL_OP = 0x10 } MsnListOp; #define MSN_LIST_OP_MASK 0x07
--- a/libpurple/protocols/msn/notification.c Mon May 28 02:20:41 2007 +0000 +++ b/libpurple/protocols/msn/notification.c Mon May 28 16:12:25 2007 +0000 @@ -40,7 +40,7 @@ static void msn_notification_fqy_yahoo(MsnSession *session, const char *passport); 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, MsnUserType type); +static void msn_add_contact_xml(MsnSession *session, xmlnode *mlNode, const char *passport, int list_op, MsnUserType type); /************************************************************************** * Main @@ -584,15 +584,15 @@ * Buddy Lists **************************************************************************/ /* add contact to xmlnode */ -static void -msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op, MsnUserType type) +static void +msn_add_contact_xml(MsnSession *session, xmlnode *mlNode,const char *passport,int list_op, MsnUserType type) { xmlnode *d_node,*c_node; char **tokens; char *email,*domain; char *list_op_str,*type_str; - purple_debug_info("MaYuan","passport:%s\n",passport); + purple_debug_info("MaYuan","passport:%s type: %d\n",passport, type); tokens = g_strsplit(passport, "@", 2); email = tokens[0]; domain = tokens[1]; @@ -627,21 +627,20 @@ purple_debug_info("MaYuan","list_op:%d\n",list_op); xmlnode_set_attrib(c_node,"l",list_op_str); g_free(list_op_str); -#if 0 - type_str = g_strdup_printf("%d",type); - xmlnode_set_attrib(c_node,"t",type_str); -#else - if(g_strrstr(domain,"yahoo") != NULL){ - type_str = g_strdup_printf("%d", MSN_USER_TYPE_YAHOO); - }else{ - /*passport*/ - type_str = g_strdup_printf("%d", MSN_USER_TYPE_PASSPORT); + + if (type != MSN_USER_TYPE_UNKNOWN) { + type_str = g_strdup_printf("%d", type); + } else { + if (msn_user_is_yahoo(session->account, passport)) + type_str = g_strdup_printf("%d", MSN_USER_TYPE_YAHOO); + else + type_str = g_strdup_printf("%d", MSN_USER_TYPE_PASSPORT); } /*mobile*/ //type_str = g_strdup_printf("4"); xmlnode_set_attrib(c_node,"t",type_str); g_free(type_str); -#endif + xmlnode_insert_child(d_node, c_node); g_strfreev(tokens); @@ -677,7 +676,12 @@ /*get the userlist*/ for (l = session->userlist->users; l != NULL; l = l->next){ user = l->data; - msn_add_contact_xml(adl_node, user->passport, + + /* skip RL & PL during initial dump */ + if (!(user->list_op & MSN_LIST_OP_MASK)) + continue; + + msn_add_contact_xml(session, adl_node, user->passport, user->list_op & MSN_LIST_OP_MASK, user->type); /* each ADL command may contain up to 150 contacts */ @@ -1863,7 +1867,7 @@ adl_node = xmlnode_new("ml"); adl_node->child = NULL; - msn_add_contact_xml(adl_node,who,1,MSN_USER_TYPE_PASSPORT); + msn_add_contact_xml(notification->session,adl_node,who,1,MSN_USER_TYPE_PASSPORT); payload = xmlnode_to_str(adl_node,&payload_len); xmlnode_free(adl_node); @@ -1893,7 +1897,7 @@ rml_node = xmlnode_new("ml"); rml_node->child = NULL; - msn_add_contact_xml(rml_node,who,1,MSN_USER_TYPE_PASSPORT); + msn_add_contact_xml(notification->session,rml_node,who,1,MSN_USER_TYPE_PASSPORT); payload = xmlnode_to_str(rml_node,&payload_len); xmlnode_free(rml_node);
--- a/libpurple/protocols/msn/user.c Mon May 28 02:20:41 2007 +0000 +++ b/libpurple/protocols/msn/user.c Mon May 28 16:12:25 2007 +0000 @@ -340,13 +340,25 @@ return PURPLE_BUDDY_IS_ONLINE(buddy); } -/*check to see if user is yahoo user? - * TODO: we need to identify it via contact parse - */ gboolean msn_user_is_yahoo(PurpleAccount *account, const char *name) { - return (strstr(name,"yahoo") != NULL); + MsnSession *session = NULL; + MsnUser *user; + PurpleConnection *gc; + + gc = purple_account_get_connection(account); + if (gc != NULL) + session = gc->proto_data; + + if ((session != NULL) && (session->protocol_ver == WLM_PROT_VER)) + return FALSE; + + if ((session != NULL) && (user = msn_userlist_find_user(session->userlist, name)) != NULL) + { + return (user->type == MSN_USER_TYPE_YAHOO); + } + return (strstr(name,"@yahoo.") != NULL); } void