Mercurial > pidgin
comparison libpurple/protocols/msn/contact.c @ 25141:5ace6c024230
propagate from branch 'im.pidgin.pidgin' (head 7821a3549d7d99473e999dc067afc4218addcc1e)
to branch 'local.struct.hiding' (head 4235f268e41a5ad75efa1010b697599c0c0dd28a)
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 31 Oct 2008 07:59:46 +0000 |
parents | c6ad3932b565 7ec9a1ae93d7 |
children |
comparison
equal
deleted
inserted
replaced
25131:c6ad3932b565 | 25141:5ace6c024230 |
---|---|
939 MsnCallbackState *state = data; | 939 MsnCallbackState *state = data; |
940 MsnSession *session = state->session; | 940 MsnSession *session = state->session; |
941 | 941 |
942 MsnUserList *userlist; | 942 MsnUserList *userlist; |
943 MsnUser *user; | 943 MsnUser *user; |
944 xmlnode *guid; | |
944 | 945 |
945 g_return_if_fail(session != NULL); | 946 g_return_if_fail(session != NULL); |
946 | 947 |
947 userlist = session->userlist; | 948 userlist = session->userlist; |
948 | 949 |
958 | 959 |
959 msn_notification_send_fqy(session, state->who); | 960 msn_notification_send_fqy(session, state->who); |
960 | 961 |
961 user = msn_userlist_find_add_user(userlist, state->who, state->who); | 962 user = msn_userlist_find_add_user(userlist, state->who, state->who); |
962 msn_user_add_group_id(user, state->guid); | 963 msn_user_add_group_id(user, state->guid); |
964 | |
965 guid = xmlnode_get_child(resp->xml, | |
966 "Body/ABContactAddResponse/ABContactAddResult/guid"); | |
967 if (guid != NULL) { | |
968 char *uid = xmlnode_get_data(guid); | |
969 msn_user_set_uid(user, uid); | |
970 purple_debug_info("msn", "Set %s guid to %s.\n", state->who, uid); | |
971 g_free(uid); | |
972 } | |
963 } | 973 } |
964 | 974 |
965 /* add a Contact in MSN_INDIVIDUALS_GROUP */ | 975 /* add a Contact in MSN_INDIVIDUALS_GROUP */ |
966 void | 976 void |
967 msn_add_contact(MsnSession *session, MsnCallbackState *state, const char *passport) | 977 msn_add_contact(MsnSession *session, MsnCallbackState *state, const char *passport) |
1014 purple_debug_info("msn", "Contact %s added to group %s successfully on server, but failed in the local list\n", state->who, state->new_group_name); | 1024 purple_debug_info("msn", "Contact %s added to group %s successfully on server, but failed in the local list\n", state->who, state->new_group_name); |
1015 } | 1025 } |
1016 | 1026 |
1017 if (state->action & MSN_ADD_BUDDY) { | 1027 if (state->action & MSN_ADD_BUDDY) { |
1018 MsnUser *user = msn_userlist_find_user(userlist, state->who); | 1028 MsnUser *user = msn_userlist_find_user(userlist, state->who); |
1029 xmlnode *guid = xmlnode_get_child(resp->xml, | |
1030 "Body/ABGroupContactAddResponse/ABGroupContactAddResult/guid"); | |
1031 | |
1032 if (guid != NULL) { | |
1033 char *uid = xmlnode_get_data(guid); | |
1034 msn_user_set_uid(user, uid); | |
1035 purple_debug_info("msn", "Set %s guid to %s.\n", state->who, uid); | |
1036 g_free(uid); | |
1037 } | |
1019 | 1038 |
1020 if ( !msn_user_is_yahoo(state->session->account, state->who) ) { | 1039 if ( !msn_user_is_yahoo(state->session->account, state->who) ) { |
1021 msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_AL); | 1040 msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_AL); |
1022 msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_FL); | 1041 msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_FL); |
1023 } | 1042 } |
1109 } | 1128 } |
1110 } | 1129 } |
1111 | 1130 |
1112 /*delete a Contact*/ | 1131 /*delete a Contact*/ |
1113 void | 1132 void |
1114 msn_delete_contact(MsnSession *session, const char *contactId) | 1133 msn_delete_contact(MsnSession *session, MsnUser *user) |
1115 { | 1134 { |
1116 gchar *body = NULL; | 1135 gchar *body = NULL; |
1117 gchar *contact_id_xml = NULL ; | 1136 gchar *contact_id_xml = NULL ; |
1118 MsnCallbackState *state; | 1137 MsnCallbackState *state; |
1119 | 1138 |
1120 g_return_if_fail(contactId != NULL); | 1139 if (user->uid != NULL) { |
1121 contact_id_xml = g_strdup_printf(MSN_CONTACT_ID_XML, contactId); | 1140 contact_id_xml = g_strdup_printf(MSN_CONTACT_ID_XML, user->uid); |
1141 purple_debug_info("msn", "Deleting contact with contactId: %s\n", user->uid); | |
1142 } else { | |
1143 contact_id_xml = g_strdup_printf(MSN_CONTACT_XML, user->passport); | |
1144 purple_debug_info("msn", "Deleting contact with passport: %s\n", user->passport); | |
1145 } | |
1122 | 1146 |
1123 state = msn_callback_state_new(session); | 1147 state = msn_callback_state_new(session); |
1124 msn_callback_state_set_uid(state, contactId); | 1148 msn_callback_state_set_uid(state, user->uid); |
1125 | 1149 |
1126 /* build SOAP request */ | 1150 /* build SOAP request */ |
1127 purple_debug_info("msn", "Deleting contact with contactId: %s\n", contactId); | |
1128 body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE, contact_id_xml); | 1151 body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE, contact_id_xml); |
1129 | 1152 |
1130 state->body = xmlnode_from_str(body, -1); | 1153 state->body = xmlnode_from_str(body, -1); |
1131 state->post_action = MSN_CONTACT_DEL_SOAP_ACTION; | 1154 state->post_action = MSN_CONTACT_DEL_SOAP_ACTION; |
1132 state->post_url = MSN_ADDRESS_BOOK_POST_URL; | 1155 state->post_url = MSN_ADDRESS_BOOK_POST_URL; |
1189 state = msn_callback_state_new(session); | 1212 state = msn_callback_state_new(session); |
1190 msn_callback_state_set_who(state, passport); | 1213 msn_callback_state_set_who(state, passport); |
1191 msn_callback_state_set_guid(state, groupId); | 1214 msn_callback_state_set_guid(state, groupId); |
1192 msn_callback_state_set_old_group_name(state, group_name); | 1215 msn_callback_state_set_old_group_name(state, group_name); |
1193 | 1216 |
1194 contact_id_xml = g_strdup_printf(MSN_CONTACT_ID_XML, user->uid); | 1217 if (user->uid != NULL) |
1218 contact_id_xml = g_strdup_printf(MSN_CONTACT_ID_XML, user->uid); | |
1219 else | |
1220 contact_id_xml = g_strdup_printf(MSN_CONTACT_XML, passport); | |
1195 body = g_strdup_printf(MSN_CONTACT_DEL_GROUP_TEMPLATE, contact_id_xml, groupId); | 1221 body = g_strdup_printf(MSN_CONTACT_DEL_GROUP_TEMPLATE, contact_id_xml, groupId); |
1196 | 1222 |
1197 state->body = xmlnode_from_str(body, -1); | 1223 state->body = xmlnode_from_str(body, -1); |
1198 state->post_action = MSN_CONTACT_DEL_GROUP_SOAP_ACTION; | 1224 state->post_action = MSN_CONTACT_DEL_GROUP_SOAP_ACTION; |
1199 state->post_url = MSN_ADDRESS_BOOK_POST_URL; | 1225 state->post_url = MSN_ADDRESS_BOOK_POST_URL; |