Mercurial > pidgin
changeset 19827:349b85feaefa
[gaim-migrate @ 17043]
change the Group operation
committed by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Sat, 26 Aug 2006 11:30:40 +0000 |
parents | 1d1e5163b0eb |
children | e45fae8209c3 |
files | src/protocols/msn/contact.c src/protocols/msn/contact.h src/protocols/msn/msn.c src/protocols/msn/soap.c src/protocols/msn/userlist.c |
diffstat | 5 files changed, 54 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/contact.c Sat Aug 26 09:23:40 2006 +0000 +++ b/src/protocols/msn/contact.c Sat Aug 26 11:30:40 2006 +0000 @@ -330,6 +330,8 @@ MsnUser *user; char *passport,*Name,*uid,*type; + passport = NULL; + contactId= xmlnode_get_child(contactNode,"contactId"); uid = xmlnode_get_data(contactId); @@ -339,7 +341,8 @@ /*setup the Display Name*/ if (!strcmp(type, "Me")){ - char *friendly = xmlnode_get_data(xmlnode_get_child(contactInfo,"displayName")); + char *friendly; + friendly = xmlnode_get_data(xmlnode_get_child(contactInfo,"displayName")); gaim_connection_set_display_name(session->account->gc, gaim_url_decode(friendly)); g_free(friendly); } @@ -361,10 +364,16 @@ } msnEnabled = xmlnode_get_data(messengerEnabledNode); if(!strcmp(msnEnabled,"true")){ + /*Messenger enabled, Get the Passport*/ emailNode = xmlnode_get_child(contactEmailNode,"email"); passport = xmlnode_get_data(emailNode); gaim_debug_info("MsnAB","Yahoo User %s\n",passport); break; + }else{ + /*TODO maybe we can just ignore it in Gaim?*/ + emailNode = xmlnode_get_child(contactEmailNode,"email"); + passport = xmlnode_get_data(emailNode); + gaim_debug_info("MSNAB","Other type user\n"); } g_free(msnEnabled); } @@ -372,6 +381,10 @@ passport = xmlnode_get_data(passportName); } + if(passport == NULL){ + continue; + } + displayName = xmlnode_get_child(contactInfo,"displayName"); if(displayName == NULL){ Name = g_strdup(passport); @@ -379,20 +392,23 @@ Name =xmlnode_get_data(displayName); } - gaim_debug_misc("MsnAB","name:%s,Id:{%s},display:{%s}\n", - passport, - uid, - Name); + gaim_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s}\n", + passport,uid,Name); 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)); user->list_op |= MSN_LIST_FL_OP; + gaim_debug_info("MsnAB","prepare to free Name...\n"); g_free(Name); + gaim_debug_info("MsnAB","prepare to free passport...\n"); g_free(passport); + gaim_debug_info("MsnAB","prepare to free uid...\n"); g_free(uid); + gaim_debug_info("MsnAB","prepare to free type...\n"); g_free(type); + gaim_debug_misc("MsnAB","prepare for guid parse...\n"); groupIds = xmlnode_get_child(contactInfo,"groupIds"); if(groupIds){ for(guid = xmlnode_get_child(groupIds, "guid");guid; @@ -407,28 +423,6 @@ group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID); msn_user_add_group_id(user,group_id); g_free(group_id); -#if 0 - 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){ - 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 } } @@ -489,7 +483,7 @@ static void msn_add_contact_read_cb(gpointer data, gint source, GaimInputCondition cond) { - gaim_debug_info("MaYuan","block read done\n"); + gaim_debug_info("MaYuan","add contact read done\n"); } static void @@ -497,14 +491,14 @@ { MsnSoapConn * soapconn = data; - gaim_debug_info("MaYuan","finish unblock written\n"); + gaim_debug_info("MaYuan","finish add contact written\n"); soapconn->read_cb = msn_add_contact_read_cb; // msn_soap_read_cb(data,source,cond); } /*add a Contact */ void -msn_add_contact(MsnContact *contact,const char *passport,char *groupId) +msn_add_contact(MsnContact *contact,const char *passport,const char *groupId) { MsnSoapReq *soap_request; char *body = NULL; @@ -559,6 +553,7 @@ char *contact_xml = NULL ; MsnSoapReq *soap_request; + g_return_if_fail(contactId == NULL); gaim_debug_info("MaYuan","msn delete a contact,contactId:{%s}...\n",contactId); contact_xml = g_strdup_printf(MSN_CONTACTS_DEL_XML,contactId); body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE,contact_xml); @@ -587,7 +582,6 @@ gaim_debug_info("MaYuan","finish unblock written\n"); soapconn->read_cb = msn_block_read_cb; -// msn_soap_read_cb(data,source,cond); } /*block a Contact*/ @@ -623,7 +617,6 @@ gaim_debug_info("MaYuan","finish unblock written\n"); soapconn->read_cb = msn_unblock_read_cb; -// msn_soap_read_cb(data,source,cond); } /*unblock a contact*/ @@ -727,6 +720,10 @@ char *body = NULL; g_return_if_fail(session != NULL); + /*if group uid we need to del is NULL, + * we need to delete nothing + */ + g_return_if_fail(guid != NULL); contact = session->contact; gaim_debug_info("MaYuan","msn del group...\n");
--- a/src/protocols/msn/contact.h Sat Aug 26 09:23:40 2006 +0000 +++ b/src/protocols/msn/contact.h Sat Aug 26 11:30:40 2006 +0000 @@ -173,12 +173,18 @@ void msn_get_address_book(MsnContact *contact); /*contact SOAP Operation*/ -void msn_add_contact(MsnContact *contact,const char *passport,char *groupId); +void msn_add_contact(MsnContact *contact,const char *passport,const char *groupId); void msn_delete_contact(MsnContact *contact,const char *contactId); /*group operation*/ void msn_add_group(MsnSession *session,const char* group_name); void msn_del_group(MsnSession *session,const char *guid); + +/*contact Block/unblock operation*/ +void msn_block_contact(MsnContact *contact,const char* membership_id); +void msn_unblock_contact(MsnContact *contact,const char* passport); + + #endif/* _MSN_CMDPROC_H_*/
--- a/src/protocols/msn/msn.c Sat Aug 26 09:23:40 2006 +0000 +++ b/src/protocols/msn/msn.c Sat Aug 26 11:30:40 2006 +0000 @@ -1401,9 +1401,14 @@ session = gc->proto_data; cmdproc = session->notification->cmdproc; + /*we can't delete the default group*/ + if(!strcmp(group->name,MSN_INDIVIDUALS_GROUP_NAME)|| + !strcmp(group->name,MSN_NON_IM_GROUP_NAME)){ + return ; + } group_id = msn_userlist_find_group_id(session->userlist, group->name); if (group_id != NULL){ - msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); + msn_del_group(session,group_id); } }
--- a/src/protocols/msn/soap.c Sat Aug 26 09:23:40 2006 +0000 +++ b/src/protocols/msn/soap.c Sat Aug 26 11:30:40 2006 +0000 @@ -27,7 +27,7 @@ #include "soap.h" /*define this Macro to debug soap server action*/ -#define MSN_SOAP_DEBUG +#undef MSN_SOAP_DEBUG /*local function prototype*/ void msn_soap_set_process_step(MsnSoapConn *soapconn, MsnSoapStep step);
--- a/src/protocols/msn/userlist.c Sat Aug 26 09:23:40 2006 +0000 +++ b/src/protocols/msn/userlist.c Sat Aug 26 11:30:40 2006 +0000 @@ -183,18 +183,24 @@ msn_request_add_group(MsnUserList *userlist, const char *who, const char *old_group_name, const char *new_group_name) { + MsnSession *session; MsnCmdProc *cmdproc; MsnMoveBuddy *data; - cmdproc = userlist->session->notification->cmdproc; + session = userlist->session; + cmdproc = session->notification->cmdproc; data = g_new0(MsnMoveBuddy, 1); data->who = g_strdup(who); - if (old_group_name) + if (old_group_name){ data->old_group_name = g_strdup(old_group_name); + /*delete the old group via SOAP action*/ + msn_del_group(session,old_group_name); + } - /*TODO:add new group via SOAP action*/ + /*add new group via SOAP action*/ + msn_add_group(session, new_group_name); } @@ -687,8 +693,10 @@ gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); msn_add_contact(userlist->session->contact,who,group_id); +#if 0 msn_notification_add_buddy(userlist->session->notification, list, who, store_name, group_id); +#endif } void