comparison libpurple/protocols/msn/oim.c @ 20439:bee467c81570

A bunch of MSNP14 stuff: Don't store the group id on the group blist node. Fix & tidy up payload length detection for commands (errors can have payloads too) Avoid a crash when connecting to a new account with no contact list Tidy up addressbook parsing slightly Fix crashes when buddy list sync issues are detected Fix initial email notifications, Fixes #1293 Plug a few memory leaks Detect OIM authentication failures correctly NOTE: I have disabled dynamic address book retrieval, instead we now receive the whole address book. This is because the blist sync stuff is still very wonky.
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 27 May 2007 17:00:06 +0000
parents f0bc92602072
children 45e3739de7fd
comparison
equal deleted inserted replaced
20438:0d67ac110e2b 20439:bee467c81570
193 goto oim_send_process_fail; 193 goto oim_send_process_fail;
194 } 194 }
195 faultCodeStr = xmlnode_get_data(faultCodeNode); 195 faultCodeStr = xmlnode_get_data(faultCodeNode);
196 purple_debug_info("MaYuan","fault code:{%s}\n",faultCodeStr); 196 purple_debug_info("MaYuan","fault code:{%s}\n",faultCodeStr);
197 197
198 if(strcmp(faultCodeStr,"q0:AuthenticationFailed")){ 198 if(!strcmp(faultCodeStr,"q0:AuthenticationFailed")){
199 /*other Fault Reason?*/ 199 /*other Fault Reason?*/
200 goto oim_send_process_fail; 200 goto oim_send_process_fail;
201 } 201 }
202 202
203 faultstringNode = xmlnode_get_child(faultNode,"faultstring"); 203 faultstringNode = xmlnode_get_child(faultNode,"faultstring");
207 /* lock key fault reason, 207 /* lock key fault reason,
208 * compute the challenge and resend it 208 * compute the challenge and resend it
209 */ 209 */
210 detailNode = xmlnode_get_child(faultNode, "detail"); 210 detailNode = xmlnode_get_child(faultNode, "detail");
211 if(detailNode == NULL){ 211 if(detailNode == NULL){
212 goto oim_send_process_fail; 212 goto oim_send_process_fail;
213 } 213 }
214 challengeNode = xmlnode_get_child(detailNode,"LockKeyChallenge"); 214 challengeNode = xmlnode_get_child(detailNode,"LockKeyChallenge");
215 if (challengeNode == NULL) {
216 goto oim_send_process_fail;
217 }
215 218
216 g_free(oim->challenge); 219 g_free(oim->challenge);
217 oim->challenge = xmlnode_get_data(challengeNode); 220 oim->challenge = xmlnode_get_data(challengeNode);
218 purple_debug_info("MaYuan","lockkey:{%s}\n",oim->challenge); 221 purple_debug_info("MaYuan","lockkey:{%s}\n",oim->challenge);
219 222
518 * and post it to the soap server to get the Offline Message 521 * and post it to the soap server to get the Offline Message
519 * */ 522 * */
520 void 523 void
521 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg) 524 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg)
522 { 525 {
523 xmlnode *mdNode,*mNode,*ENode,*INode,*rtNode,*nNode; 526 xmlnode *node, *mdNode,*mNode,*ENode,*INode,*rtNode,*nNode;
524 char *passport,*msgid,*nickname, *rTime = NULL; 527 char *passport,*msgid,*nickname, *unread, *rTime = NULL;
525 528
526 mdNode = xmlnode_from_str(xmlmsg, strlen(xmlmsg)); 529 node = xmlnode_from_str(xmlmsg, strlen(xmlmsg));
530
531 ENode = xmlnode_get_child(node, "E");
532 INode = xmlnode_get_child(ENode, "IU");
533 unread = xmlnode_get_data(INode);
534
535 if (unread != NULL)
536 {
537 int count = atoi(unread);
538
539 if (count > 0)
540 {
541 MsnSession *session = oim->session;
542 const char *passport;
543 const char *url;
544
545 passport = msn_user_get_passport(session->user);
546 url = session->passport_info.file;
547
548 purple_notify_emails(session->account->gc, atoi(unread), FALSE, NULL, NULL,
549 &passport, &url, NULL, NULL);
550 }
551 }
552
553 mdNode = xmlnode_get_child(node, "MD");
554 if (mdNode == NULL) {
555 xmlnode_free(node);
556 return;
557 }
527 for(mNode = xmlnode_get_child(mdNode, "M"); mNode; 558 for(mNode = xmlnode_get_child(mdNode, "M"); mNode;
528 mNode = xmlnode_get_next_twin(mNode)){ 559 mNode = xmlnode_get_next_twin(mNode)){
529 /*email Node*/ 560 /*email Node*/
530 ENode = xmlnode_get_child(mNode,"E"); 561 ENode = xmlnode_get_child(mNode,"E");
531 passport = xmlnode_get_data(ENode); 562 passport = xmlnode_get_data(ENode);
535 /*Nickname*/ 566 /*Nickname*/
536 nNode = xmlnode_get_child(mNode,"N"); 567 nNode = xmlnode_get_child(mNode,"N");
537 nickname = xmlnode_get_data(nNode); 568 nickname = xmlnode_get_data(nNode);
538 /*receive time*/ 569 /*receive time*/
539 rtNode = xmlnode_get_child(mNode,"RT"); 570 rtNode = xmlnode_get_child(mNode,"RT");
540 if(rtNode != NULL) 571 if(rtNode != NULL) {
541 rTime = xmlnode_get_data(rtNode); 572 rTime = xmlnode_get_data(rtNode);
542 /* purple_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime);*/ 573 rtNode = NULL;
574 }
575 /* purple_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); */
543 576
544 oim->oim_list = g_list_append(oim->oim_list,msgid); 577 oim->oim_list = g_list_append(oim->oim_list,msgid);
545 msn_oim_post_single_get_msg(oim,msgid); 578 msn_oim_post_single_get_msg(oim,msgid);
546 g_free(passport); 579 g_free(passport);
547 // g_free(msgid); 580 g_free(msgid);
548 g_free(rTime); 581 g_free(rTime);
582 rTime = NULL;
549 g_free(nickname); 583 g_free(nickname);
550 } 584 }
585 xmlnode_free(node);
551 } 586 }
552 587
553 /*Post to get the Offline Instant Message*/ 588 /*Post to get the Offline Instant Message*/
554 static void 589 static void
555 msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) 590 msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid)