comparison libpurple/protocols/msn/oim.c @ 21103:aa875e77e5ce

explicit merge of '3380c786d272dcd9ab1360f49c3e4e51227af663' and 'c0e79d15a4fe4c5b0129fcae5060754b25f72a56' to branch 'im.pidgin.cpw.khc.soap'
author Ka-Hing Cheung <khc@hxbc.us>
date Thu, 25 Oct 2007 07:39:26 +0000
parents f387e8c671a4 90fd0826c6ce
children 7ac87187bbec
comparison
equal deleted inserted replaced
21102:f387e8c671a4 21103:aa875e77e5ce
137 static void 137 static void
138 msn_oim_send_read_cb(MsnSoapMessage *request, MsnSoapMessage *response, 138 msn_oim_send_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
139 gpointer data) 139 gpointer data)
140 { 140 {
141 MsnOim *oim = data; 141 MsnOim *oim = data;
142 xmlnode *faultNode, *challengeNode;
143 MsnOimSendReq *msg = g_queue_pop_head(oim->send_queue); 142 MsnOimSendReq *msg = g_queue_pop_head(oim->send_queue);
144 143
145 g_return_if_fail(msg != NULL); 144 g_return_if_fail(msg != NULL);
146 145
147 if (response == NULL) { 146 if (response == NULL) {
148 purple_debug_info("MSNP14", "cannot send OIM: %s\n", msg->oim_msg); 147 purple_debug_info("MSNP14", "cannot send OIM: %s\n", msg->oim_msg);
149 } else { 148 } else {
150 faultNode = msn_soap_xml_get(response->xml, "Body/Fault"); 149 xmlnode *faultNode = msn_soap_xml_get(response->xml, "Body/Fault");
151 150
152 if (faultNode == NULL) { 151 if (faultNode == NULL) {
153 /*Send OK! return*/ 152 /*Send OK! return*/
154 purple_debug_info("MSNP14", "sent OIM: %s\n", msg->oim_msg); 153 purple_debug_info("MSNP14", "sent OIM: %s\n", msg->oim_msg);
155 } else { 154 } else {
156 /*get the challenge,and repost it*/ 155 xmlnode *faultcode = xmlnode_get_child(faultNode, "faultcode");
157 challengeNode = msn_soap_xml_get(faultNode, 156
158 "detail/LockKeyChallenge"); 157 if (faultcode) {
159 158 char *faultcode_str = xmlnode_get_data(faultcode);
160 if (challengeNode == NULL) { 159
161 purple_debug_info("MSNP14", "can't find lock key for OIM: %s\n", msg); 160 if (g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
162 } else { 161 xmlnode *challengeNode = msn_soap_xml_get(faultNode,
163 char buf[33]; 162 "detail/LockKeyChallenge");
164 163
165 char *challenge = xmlnode_get_data(challengeNode); 164 if (challengeNode == NULL) {
166 msn_handle_chl(challenge, buf); 165 if (oim->challenge) {
167 166 g_free(oim->challenge);
168 g_free(oim->challenge); 167 oim->challenge = NULL;
169 oim->challenge = g_strndup(buf, sizeof(buf)); 168
170 g_free(challenge); 169 purple_debug_info("msnoim","resending OIM: %s\n",
171 purple_debug_info("MSNP14","lockkey:{%s}\n",oim->challenge); 170 msg->oim_msg);
172 171 g_queue_push_head(oim->send_queue, msg);
173 /*repost the send*/ 172 msn_oim_send_msg(oim);
174 purple_debug_info("MSNP14","resending OIM: %s\n", msg->oim_msg); 173 return;
175 g_queue_push_head(oim->send_queue, msg); 174 } else {
176 msn_oim_send_msg(oim); 175 purple_debug_info("msnoim",
177 return; 176 "can't find lock key for OIM: %s\n",
177 msg->oim_msg);
178 }
179 } else {
180 char buf[33];
181
182 char *challenge = xmlnode_get_data(challengeNode);
183 msn_handle_chl(challenge, buf);
184
185 g_free(oim->challenge);
186 oim->challenge = g_strndup(buf, sizeof(buf));
187 g_free(challenge);
188 purple_debug_info("MSNP14","lockkey:{%s}\n",oim->challenge);
189
190 /*repost the send*/
191 purple_debug_info("MSNP14","resending OIM: %s\n", msg->oim_msg);
192 g_queue_push_head(oim->send_queue, msg);
193 msn_oim_send_msg(oim);
194 return;
195 }
196 }
178 } 197 }
179 } 198 }
180 } 199 }
181 200
182 msn_oim_free_send_req(msg); 201 msn_oim_free_send_req(msg);