Mercurial > pidgin
changeset 19787:b99512bd6d85
[gaim-migrate @ 16547]
initial Good version,
Can see others' online and offline status.
Can chat.
Some bug exist!
Committed by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Sun, 23 Jul 2006 12:19:10 +0000 |
parents | 23258253c7a0 |
children | 8b4653986e8e |
files | src/protocols/msn/contact.c src/protocols/msn/group.h src/protocols/msn/notification.c src/protocols/msn/session.c src/protocols/msn/user.c src/protocols/msn/userlist.c |
diffstat | 6 files changed, 94 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/contact.c Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/contact.c Sun Jul 23 12:19:10 2006 +0000 @@ -28,6 +28,7 @@ #include "soap.h" #include "contact.h" #include "xmlnode.h" +#include "group.h" /*new a contact*/ MsnContact * @@ -220,6 +221,7 @@ xmlnode *groups,*group,*groupname,*groupId,*groupInfo; xmlnode *contacts,*contactNode,*contactId,*contactInfo,*contactType,*passportName,*displayName,*groupIds,*guid; xmlnode *ab; + char *group_name,*group_id; session = contact->session; gaim_debug_misc("xml","parse addressbook:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len); @@ -236,43 +238,64 @@ gaim_debug_misc("xml","response{%p},name:%s\n",response,response->name); result =xmlnode_get_child(response,"ABFindAllResult"); gaim_debug_misc("xml","result{%p},name:%s\n",result,result->name); + + /*Process Group List*/ groups =xmlnode_get_child(result,"groups"); for(group = xmlnode_get_child(groups, "Group"); group; group = xmlnode_get_next_twin(group)){ - char * name,*group_id; - groupId = xmlnode_get_child(group,"groupId"); - group_id = xmlnode_get_data(groupId); - groupInfo = xmlnode_get_child(group,"groupInfo"); - groupname = xmlnode_get_child(groupInfo,"name"); - name = xmlnode_get_data(groupname); + groupId = xmlnode_get_child(group,"groupId"); + group_id = xmlnode_get_data(groupId); + groupInfo = xmlnode_get_child(group,"groupInfo"); + groupname = xmlnode_get_child(groupInfo,"name"); + group_name = xmlnode_get_data(groupname); - msn_group_new(session->userlist, group_id, name); + msn_group_new(session->userlist, group_id, group_name); + + if (group_id == NULL){ + /* Group of ungroupped buddies */ + continue; + } - if (group_id == NULL) - /* Group of ungroupped buddies */ - continue; + gaim_debug_misc("MsnContact","group_id:%s name:%s\n",group_id,group_name); + if ((gaim_find_group(group_name)) == NULL){ + GaimGroup *g = gaim_group_new(group_name); + gaim_blist_add_group(g, NULL); + } + } + /*add a default No group to set up the no group Membership*/ + group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID); + group_name = g_strdup(MSN_INDIVIDUALS_GROUP_NAME); + msn_group_new(session->userlist,group_id , group_name); + if (group_id != NULL){ + gaim_debug_misc("MsnContact","group_id:%s name:%s,value:%d\n",group_id,group_name,*group_name=='\0'); + if ((gaim_find_group(group_name)) == NULL){ + GaimGroup *g = gaim_group_new(group_name); + gaim_blist_add_group(g, NULL); + } + } + g_free(group_name); + g_free(group_id); - if ((gaim_find_group(name)) == NULL){ - GaimGroup *g = gaim_group_new(name); - gaim_blist_add_group(g, NULL); - } + /*add a default No group to set up the no group Membership*/ + group_id = g_strdup(MSN_NON_IM_GROUP_ID); + group_name = g_strdup(MSN_NON_IM_GROUP_NAME); + msn_group_new(session->userlist,group_id , group_name); + if (group_id != NULL){ + gaim_debug_misc("MsnContact","group_id:%s name:%s,value:%d\n",group_id,group_name,*group_name=='\0'); + if ((gaim_find_group(group_name)) == NULL){ + GaimGroup *g = gaim_group_new(group_name); + gaim_blist_add_group(g, NULL); + } + } + g_free(group_name); + g_free(group_id); - gaim_debug_misc("group","name:%s,Id:{%s}\n",name,group_id); - } - + /*Process contact List*/ contacts =xmlnode_get_child(result,"contacts"); for(contactNode = xmlnode_get_child(contacts, "Contact"); contactNode; contactNode = xmlnode_get_next_twin(contactNode)){ MsnUser *user; - xmlnode *messengerEnableNode; char *passport,*Name,*uid,*type; - char *messengerEnable; - - messengerEnableNode = xmlnode_get_child(contactNode,"isMessengerEnabled"); - messengerEnable = xmlnode_get_data(messengerEnableNode); - if(!g_strcasecmp(messengerEnable,"false")){ - continue; - } contactId= xmlnode_get_child(contactNode,"contactId"); uid = xmlnode_get_data(contactId); @@ -305,38 +328,42 @@ msn_user_set_type(user,msn_get_user_type(type)); user->list_op |= 1; + gaim_debug_misc("MsnContact","\n"); groupIds = xmlnode_get_child(contactInfo,"groupIds"); if(groupIds){ for(guid = xmlnode_get_child(groupIds, "guid");guid; guid = xmlnode_get_next_twin(guid)){ - char *group_id; - group_id = xmlnode_get_data(guid); msn_user_add_group_id(user,group_id); gaim_debug_misc("contact","guid:%s\n",group_id); } }else{ + group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID); + msn_user_add_group_id(user,group_id); + g_free(group_id); +#if 0 + /*not in any group,Then set default group*/ char *name,*group_id; name = g_strdup(MSN_INDIVIDUALS_GROUP_NAME); group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID); + gaim_debug_misc("MsnContact","group_id:%s name:%s\n",group_id,name); msn_user_add_group_id(user,group_id); msn_group_new(session->userlist, group_id, name); - if (group_id == NULL) - /* Group of ungroupped buddies */ - continue; - - if ((gaim_find_group(name)) == NULL){ + if (group_id != NULL){ + gaim_debug_misc("MsnContact","group_id:%s name:%s,value:%d\n",group_id,name,*name=='\0'); + if ((gaim_find_group(name)) == NULL){ GaimGroup *g = gaim_group_new(name); gaim_blist_add_group(g, NULL); + } } gaim_debug_misc("contact","guid is NULL\n"); g_free(name); g_free(group_id); - +#endif } }
--- a/src/protocols/msn/group.h Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/group.h Sun Jul 23 12:19:10 2006 +0000 @@ -40,9 +40,12 @@ #define MSN_GROUP_IDS "<guid>9e57e654-59f0-44d1-aedc-0a7500b7e51f</guid>" #define MSN_DELETE_GROUP_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>Timer</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABGroupDelete xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><groupFilter><groupIds>%s</groupIds></groupFilter></ABGroupDelete></soap:Body></soap:Envelope>" -#define MSN_INDIVIDUALS_GROUP_ID "0" +#define MSN_INDIVIDUALS_GROUP_ID "123" #define MSN_INDIVIDUALS_GROUP_NAME "Other Contacts" +#define MSN_NON_IM_GROUP_ID "email" +#define MSN_NON_IM_GROUP_NAME "Non-IM Contacts" + /** * A group. */
--- a/src/protocols/msn/notification.c Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/notification.c Sun Jul 23 12:19:10 2006 +0000 @@ -713,6 +713,7 @@ GaimConnection *gc; MsnUser *user; MsnObject *msnobj; + int wlmclient; const char *state, *passport, *friendly; session = cmdproc->session; @@ -721,7 +722,8 @@ state = cmd->params[1]; passport = cmd->params[2]; - friendly = gaim_url_decode(cmd->params[3]); + wlmclient = atoi(cmd->params[3]); + friendly = gaim_url_decode(cmd->params[4]); user = msn_userlist_find_user(session->userlist, passport); @@ -729,8 +731,8 @@ msn_user_set_friendly_name(user, friendly); - if (session->protocol_ver >= 9 && cmd->param_count == 6){ - msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[5])); + if (session->protocol_ver >= 9 && cmd->param_count == 7){ + msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[6])); msn_user_set_object(user, msnobj); } @@ -762,6 +764,7 @@ MsnUser *user; MsnObject *msnobj; int clientid; + int wlmclient; const char *state, *passport, *friendly; session = cmdproc->session; @@ -770,7 +773,8 @@ state = cmd->params[0]; passport = cmd->params[1]; - friendly = gaim_url_decode(cmd->params[2]); + wlmclient = atoi(cmd->params[2]); + friendly = gaim_url_decode(cmd->params[3]); user = msn_userlist_find_user(session->userlist, passport); @@ -779,15 +783,15 @@ msn_user_set_friendly_name(user, friendly); if (session->protocol_ver >= 9){ - if (cmd->param_count == 5){ - msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[4])); + if (cmd->param_count == 6){ + msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[5])); msn_user_set_object(user, msnobj); }else{ msn_user_set_object(user, NULL); } } - clientid = atoi(cmd->params[3]); + clientid = atoi(cmd->params[4]); user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE); msn_user_set_state(user, state);
--- a/src/protocols/msn/session.c Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/session.c Sun Jul 23 12:19:10 2006 +0000 @@ -234,12 +234,15 @@ /* The core used to use msn_add_buddy to add all buddies before * being logged in. This no longer happens, so we manually iterate * over the whole buddy list to identify sync issues. */ - - for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { + for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next){ GaimGroup *group = (GaimGroup *)gnode; const char *group_name = group->name; if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; + if(!g_strcasecmp(group_name, MSN_INDIVIDUALS_GROUP_NAME) + || !g_strcasecmp(group_name,MSN_NON_IM_GROUP_NAME)){ + continue; + } for(cnode = gnode->child; cnode; cnode = cnode->next) { if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) continue; @@ -248,7 +251,7 @@ if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (GaimBuddy *)bnode; - if(b->account == gc->account) { + if(b->account == gc->account){ MsnUser *remote_user; gboolean found = FALSE; @@ -256,11 +259,14 @@ remote_user = msn_userlist_find_user(session->userlist, b->name); if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)){ - char *group_id; + const char *group_id; GList *l; group_id = msn_userlist_find_group_id(remote_user->userlist, group_name); + if(group_id == NULL){ + continue; + } for (l = remote_user->group_ids; l != NULL; l = l->next){ if (!g_strcasecmp(group_id ,l->data)){
--- a/src/protocols/msn/user.c Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/user.c Sun Jul 23 12:19:10 2006 +0000 @@ -261,9 +261,11 @@ group_name = msn_userlist_find_group_name(userlist, id); + gaim_debug_info("User","group id:%s,name:%s,user:%s\n",id,group_name,passport); + g = gaim_find_group(group_name); - if ((id == 0) && (g == NULL)){ + if ((id == NULL) && (g == NULL)){ g = gaim_group_new(group_name); gaim_blist_add_group(g, NULL); }
--- a/src/protocols/msn/userlist.c Sun Jul 23 09:19:12 2006 +0000 +++ b/src/protocols/msn/userlist.c Sun Jul 23 12:19:10 2006 +0000 @@ -468,11 +468,13 @@ for (l = userlist->users; l != NULL; l = l->next){ MsnUser *user = (MsnUser *)l->data; - +// gaim_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport); g_return_val_if_fail(user->passport != NULL, NULL); - if (!g_strcasecmp(passport, user->passport)) + if (!g_strcasecmp(passport, user->passport)){ +// gaim_debug_info("MsnUserList","return:%p\n",user); return user; + } } return NULL; @@ -516,11 +518,10 @@ g_return_val_if_fail(userlist != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); - for (l = userlist->groups; l != NULL; l = l->next) - { + for (l = userlist->groups; l != NULL; l = l->next){ MsnGroup *group = l->data; - if ((group->name != NULL) && !g_ascii_strcasecmp(name, group->name)) + if ((group->name != NULL) && !g_strcasecmp(name, group->name)) return group; }