comparison libpurple/protocols/msn/notification.c @ 20484:98613886411a

Handle special cases in buddy/group management (wrt MSN_INDIVIDUALS_GROUP and MSN_NON_IM_GROUP). Deprecate now unused MSNP protocol commands.
author Carlos Silva <typ0@pidgin.im>
date Fri, 31 Aug 2007 18:12:35 +0000
parents eb93710aec4d
children ff4ae9dde291
comparison
equal deleted inserted replaced
20483:115290ce3b92 20484:98613886411a
591 xmlnode *d_node,*c_node; 591 xmlnode *d_node,*c_node;
592 char **tokens; 592 char **tokens;
593 char *email,*domain; 593 char *email,*domain;
594 char *list_op_str,*type_str; 594 char *list_op_str,*type_str;
595 595
596 purple_debug_info("::","msn_add_contact_xml()\n");
597 purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, type); 596 purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, type);
598 tokens = g_strsplit(passport, "@", 2); 597 tokens = g_strsplit(passport, "@", 2);
599 email = tokens[0]; 598 email = tokens[0];
600 domain = tokens[1]; 599 domain = tokens[1];
601 600
650 649
651 static void 650 static void
652 msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len) 651 msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len)
653 { 652 {
654 MsnTransaction *trans; 653 MsnTransaction *trans;
655 purple_debug_info("::","msn_notification_post_adl()\n"); 654 purple_debug_info("MSN Notification","Sending ADL with payload: %s\n", payload);
656 purple_debug_info("MSNP14","Sending ADL with payload: %s\n", payload);
657 trans = msn_transaction_new(cmdproc, "ADL","%d", strlen(payload)); 655 trans = msn_transaction_new(cmdproc, "ADL","%d", strlen(payload));
658 msn_transaction_set_payload(trans, payload, strlen(payload)); 656 msn_transaction_set_payload(trans, payload, strlen(payload));
659 msn_cmdproc_send_trans(cmdproc, trans); 657 msn_cmdproc_send_trans(cmdproc, trans);
660 } 658 }
661 659
674 purple_debug_info("::","msn_notification_dump_contact()\n"); 672 purple_debug_info("::","msn_notification_dump_contact()\n");
675 adl_node = xmlnode_new("ml"); 673 adl_node = xmlnode_new("ml");
676 adl_node->child = NULL; 674 adl_node->child = NULL;
677 xmlnode_set_attrib(adl_node, "l", "1"); 675 xmlnode_set_attrib(adl_node, "l", "1");
678 676
679
680 /* if ( session->userlist->users == NULL ) {
681 payload = xmlnode_to_str(adl_node,&payload_len);
682
683 msn_notification_post_adl(session->notification->cmdproc,
684 payload, payload_len);
685
686 g_free(payload);
687 xmlnode_free(adl_node);
688 }
689 else { */
690 /*get the userlist*/ 677 /*get the userlist*/
691 for (l = session->userlist->users; l != NULL; l = l->next){ 678 for (l = session->userlist->users; l != NULL; l = l->next){
692 user = l->data; 679 user = l->data;
693 680
694 /* skip RL & PL during initial dump */ 681 /* skip RL & PL during initial dump */
762 blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 749 blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
763 { 750 {
764 } 751 }
765 752
766 static void 753 static void
754 adl_cmd_parse(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload,
755 size_t len)
756 {
757 xmlnode *root, *domain_node;
758
759 purple_debug_misc("MSN Notification", "Parsing received ADL XML data\n");
760
761 g_return_if_fail(payload != NULL);
762
763 root = xmlnode_from_str(payload, (gssize) len);
764
765 if (root == NULL) {
766 purple_debug_info("MSN Notification", "Invalid XML!\n");
767 return;
768 }
769 for (domain_node = xmlnode_get_child(root, "d"); domain_node; domain_node = xmlnode_get_next_twin(domain_node)) {
770 const gchar * domain = NULL;
771 xmlnode *contact_node = NULL;
772
773 domain = xmlnode_get_attrib(domain_node, "n");
774
775 for (contact_node = xmlnode_get_child(domain_node, "c"); contact_node; contact_node = xmlnode_get_next_twin(contact_node)) {
776 // gchar *name = NULL, *friendlyname = NULL, *passport= NULL;
777 const gchar *list;
778 gint list_op = 0;
779
780 // name = xmlnode_get_attrib(contact_node, "n");
781 list = xmlnode_get_attrib(contact_node, "l");
782 if (list != NULL) {
783 list_op = atoi(list);
784 }
785 // friendlyname = xmlnode_get_attrib(contact_node, "f");
786
787 // passport = g_strdup_printf("%s@%s", name, domain);
788
789 // if (friendlyname != NULL) {
790 // decoded_friendlyname = g_strdup(purple_url_decode(friendlyname));
791 // } else {
792 // decoded_friendlyname = g_strdup(passport);
793 // }
794
795 if (list_op & MSN_LIST_RL_OP) {
796 /* someone is adding us */
797 // got_new_entry(cmdproc->session->account->gc, passport, decoded_friendly_name);
798 msn_get_contact_list(cmdproc->session->contact, MSN_PS_PENDING_LIST, NULL);
799 }
800
801 // g_free(decoded_friendly_name);
802 // g_free(passport);
803 }
804 }
805
806 xmlnode_free(root);
807 }
808
809 static void
767 adl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 810 adl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
768 { 811 {
769 msn_session_finish_login(cmdproc->session); 812 MsnSession *session;
813
814 g_return_if_fail(cmdproc != NULL);
815 g_return_if_fail(cmdproc->session != NULL);
816 g_return_if_fail(cmdproc->last_cmd != NULL);
817 g_return_if_fail(cmd != NULL);
818
819 session = cmdproc->session;
820
821 if ( !strcmp(cmd->params[1], "OK")) {
822 /* ADL ack */
823 msn_session_finish_login(session);
824 } else {
825 cmdproc->last_cmd->payload_cb = adl_cmd_parse;
826 }
770 827
771 return; 828 return;
772 } 829 }
773 830
774 static void 831 static void
795 { 852 {
796 purple_debug_info("MSN Notification","FQY payload:\n%s\n", payload); 853 purple_debug_info("MSN Notification","FQY payload:\n%s\n", payload);
797 g_return_if_fail(cmdproc->session != NULL); 854 g_return_if_fail(cmdproc->session != NULL);
798 g_return_if_fail(cmdproc->session->contact != NULL); 855 g_return_if_fail(cmdproc->session->contact != NULL);
799 // msn_notification_post_adl(cmdproc, payload, len); 856 // msn_notification_post_adl(cmdproc, payload, len);
800 msn_get_address_book(cmdproc->session->contact, MSN_AB_SAVE_CONTACT, NULL, NULL); 857 // msn_get_address_book(cmdproc->session->contact, MSN_AB_SAVE_CONTACT, NULL, NULL);
801 } 858 }
802 859
803 static void 860 static void
804 fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 861 fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
805 { 862 {
1661 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL); 1718 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL);
1662 session->contact = msn_contact_new(session); 1719 session->contact = msn_contact_new(session);
1663 #ifdef MSN_PARTIAL_LISTS 1720 #ifdef MSN_PARTIAL_LISTS
1664 /* msn_userlist_load defeats all attempts at trying to detect blist sync issues */ 1721 /* msn_userlist_load defeats all attempts at trying to detect blist sync issues */
1665 msn_userlist_load(session); 1722 msn_userlist_load(session);
1666 msn_get_contact_list(session->contact, clLastChange); 1723 msn_get_contact_list(session->contact, MSN_PS_INITIAL, clLastChange);
1667 #else 1724 #else
1668 /* always get the full list? */ 1725 /* always get the full list? */
1669 msn_get_contact_list(session->contact, NULL); 1726 msn_get_contact_list(session->contact, MSN_PS_INITIAL, NULL);
1670 #endif 1727 #endif
1671 #if 0 1728 #if 0
1672 msn_contact_connect(session->contact); 1729 msn_contact_connect(session->contact);
1673 #endif 1730 #endif
1674 } 1731 }
1970 2027
1971 /* Synchronous */ 2028 /* Synchronous */
1972 msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL); 2029 msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL);
1973 msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd); 2030 msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd);
1974 msn_table_add_cmd(cbs_table, "ADL", "ILN", iln_cmd); 2031 msn_table_add_cmd(cbs_table, "ADL", "ILN", iln_cmd);
1975 msn_table_add_cmd(cbs_table, "REM", "REM", rem_cmd); 2032 // msn_table_add_cmd(cbs_table, "REM", "REM", rem_cmd); /* Removed as of MSNP13 */
1976 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); 2033 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd);
1977 msn_table_add_cmd(cbs_table, "USR", "XFR", xfr_cmd); 2034 msn_table_add_cmd(cbs_table, "USR", "XFR", xfr_cmd);
1978 msn_table_add_cmd(cbs_table, "USR", "GCF", gcf_cmd); 2035 msn_table_add_cmd(cbs_table, "USR", "GCF", gcf_cmd);
1979 msn_table_add_cmd(cbs_table, "SYN", "SYN", syn_cmd); 2036 // msn_table_add_cmd(cbs_table, "SYN", "SYN", syn_cmd); /* Removed as of MSNP13 */
1980 msn_table_add_cmd(cbs_table, "CVR", "CVR", cvr_cmd); 2037 msn_table_add_cmd(cbs_table, "CVR", "CVR", cvr_cmd);
1981 msn_table_add_cmd(cbs_table, "VER", "VER", ver_cmd); 2038 msn_table_add_cmd(cbs_table, "VER", "VER", ver_cmd);
1982 msn_table_add_cmd(cbs_table, "REA", "REA", rea_cmd); 2039 msn_table_add_cmd(cbs_table, "REA", "REA", rea_cmd);
1983 msn_table_add_cmd(cbs_table, "PRP", "PRP", prp_cmd); 2040 msn_table_add_cmd(cbs_table, "PRP", "PRP", prp_cmd);
1984 msn_table_add_cmd(cbs_table, "BLP", "BLP", blp_cmd); 2041 msn_table_add_cmd(cbs_table, "BLP", "BLP", blp_cmd);