Mercurial > pidgin
comparison libpurple/protocols/msn/contact.c @ 22569:207f51e16b50
another patch from Maiku that "Properly identifies users you have the mobile
number for as mobile" from the addressbook. I don't use this stuff, so
please test.
References #2359
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Thu, 27 Mar 2008 06:32:31 +0000 |
parents | 068b412ba385 |
children | 8041c74e36d7 |
comparison
equal
deleted
inserted
replaced
22568:c65c96e231b5 | 22569:207f51e16b50 |
---|---|
462 g_free(group_id); | 462 g_free(group_id); |
463 g_free(group_name); | 463 g_free(group_name); |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 static gboolean | |
468 msn_parse_addressbook_mobile(xmlnode *contactInfo, char **inout_mobile_number) | |
469 { | |
470 xmlnode *phones; | |
471 char *mobile_number = NULL; | |
472 gboolean mobile = FALSE; | |
473 | |
474 *inout_mobile_number = NULL; | |
475 | |
476 if ((phones = xmlnode_get_child(contactInfo, "phones"))) { | |
477 xmlnode *contact_phone; | |
478 char *phone_type = NULL; | |
479 | |
480 for (contact_phone = xmlnode_get_child(phones, "ContactPhone"); | |
481 contact_phone; | |
482 contact_phone = xmlnode_get_next_twin(contact_phone)) { | |
483 xmlnode *contact_phone_type; | |
484 | |
485 if (!(contact_phone_type = | |
486 xmlnode_get_child(contact_phone, "contactPhoneType"))) | |
487 continue; | |
488 | |
489 phone_type = xmlnode_get_data(contact_phone_type); | |
490 | |
491 if (phone_type && !strcmp(phone_type, "ContactPhoneMobile")) { | |
492 xmlnode *number; | |
493 | |
494 if ((number = xmlnode_get_child(contact_phone, "number"))) { | |
495 xmlnode *messenger_enabled; | |
496 char *is_messenger_enabled = NULL; | |
497 | |
498 mobile_number = xmlnode_get_data(number); | |
499 | |
500 if (mobile_number && | |
501 (messenger_enabled = xmlnode_get_child(contact_phone, "isMessengerEnabled")) | |
502 && (is_messenger_enabled = xmlnode_get_data(messenger_enabled)) | |
503 && !strcmp(is_messenger_enabled, "true")) | |
504 mobile = TRUE; | |
505 | |
506 g_free(is_messenger_enabled); | |
507 } | |
508 } | |
509 | |
510 g_free(phone_type); | |
511 } | |
512 } | |
513 | |
514 *inout_mobile_number = mobile_number; | |
515 return mobile; | |
516 } | |
517 | |
467 static void | 518 static void |
468 msn_parse_addressbook_contacts(MsnContact *contact, xmlnode *node) | 519 msn_parse_addressbook_contacts(MsnContact *contact, xmlnode *node) |
469 { | 520 { |
470 MsnSession *session = contact->session; | 521 MsnSession *session = contact->session; |
471 xmlnode *contactNode; | 522 xmlnode *contactNode; |
472 char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL; | 523 char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL, *mobile_number = NULL; |
524 gboolean mobile = FALSE; | |
473 | 525 |
474 for(contactNode = xmlnode_get_child(node, "Contact"); contactNode; | 526 for(contactNode = xmlnode_get_child(node, "Contact"); contactNode; |
475 contactNode = xmlnode_get_next_twin(contactNode)) { | 527 contactNode = xmlnode_get_next_twin(contactNode)) { |
476 xmlnode *contactId, *contactInfo, *contactType, *passportName, *displayName, *guid, *groupIds; | 528 xmlnode *contactId, *contactInfo, *contactType, *passportName, *displayName, *guid, *groupIds; |
477 MsnUser *user; | 529 MsnUser *user; |
484 | 536 |
485 g_free(passport); | 537 g_free(passport); |
486 g_free(Name); | 538 g_free(Name); |
487 g_free(uid); | 539 g_free(uid); |
488 g_free(type); | 540 g_free(type); |
489 passport = Name = uid = type = NULL; | 541 passport = Name = uid = type = mobile_number = NULL; |
542 mobile = FALSE; | |
490 | 543 |
491 uid = xmlnode_get_data(contactId); | 544 uid = xmlnode_get_data(contactId); |
492 type = xmlnode_get_data(contactType); | 545 type = xmlnode_get_data(contactType); |
493 | 546 |
494 /*setup the Display Name*/ | 547 /*setup the Display Name*/ |
552 if ((displayName = xmlnode_get_child(contactInfo, "displayName"))) | 605 if ((displayName = xmlnode_get_child(contactInfo, "displayName"))) |
553 Name = xmlnode_get_data(displayName); | 606 Name = xmlnode_get_data(displayName); |
554 else | 607 else |
555 Name = g_strdup(passport); | 608 Name = g_strdup(passport); |
556 | 609 |
557 purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s}\n", | 610 mobile = msn_parse_addressbook_mobile(contactInfo, &mobile_number); |
558 passport, uid ? uid : "(null)", Name ? Name : "(null)"); | 611 |
612 purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s} mobile:{%s} mobile number:{%s}\n", | |
613 passport, uid ? uid : "(null)", Name ? Name : "(null)", | |
614 mobile ? "true" : "false", mobile_number ? mobile_number : "(null)"); | |
559 | 615 |
560 user = msn_userlist_find_add_user(session->userlist, passport, Name); | 616 user = msn_userlist_find_add_user(session->userlist, passport, Name); |
561 msn_user_set_uid(user, uid); | 617 msn_user_set_uid(user, uid); |
562 msn_user_set_type(user, usertype); | 618 msn_user_set_type(user, usertype); |
619 msn_user_set_mobile_phone(user, mobile_number); | |
563 | 620 |
564 groupIds = xmlnode_get_child(contactInfo, "groupIds"); | 621 groupIds = xmlnode_get_child(contactInfo, "groupIds"); |
565 if (groupIds) { | 622 if (groupIds) { |
566 for (guid = xmlnode_get_child(groupIds, "guid"); guid; | 623 for (guid = xmlnode_get_child(groupIds, "guid"); guid; |
567 guid = xmlnode_get_next_twin(guid)){ | 624 guid = xmlnode_get_next_twin(guid)){ |
575 /*not in any group,Then set default group*/ | 632 /*not in any group,Then set default group*/ |
576 msn_user_add_group_id(user, MSN_INDIVIDUALS_GROUP_ID); | 633 msn_user_add_group_id(user, MSN_INDIVIDUALS_GROUP_ID); |
577 } | 634 } |
578 | 635 |
579 msn_got_lst_user(session, user, MSN_LIST_FL_OP, NULL); | 636 msn_got_lst_user(session, user, MSN_LIST_FL_OP, NULL); |
637 | |
638 if(mobile && user) | |
639 { | |
640 user->mobile = TRUE; | |
641 purple_prpl_got_user_status(session->account, user->passport, "mobile", NULL); | |
642 purple_prpl_got_user_status(session->account, user->passport, "available", NULL); | |
643 } | |
580 } | 644 } |
581 | 645 |
582 g_free(passport); | 646 g_free(passport); |
583 g_free(Name); | 647 g_free(Name); |
584 g_free(uid); | 648 g_free(uid); |