comparison libpurple/protocols/msn/oim.c @ 20538:90fd0826c6ce

finish converting the rest of stuff to the new soap api, signing on, getting address book seems to work, other blist management stuff not tested yet
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 24 Oct 2007 06:35:54 +0000
parents d52d299cfde3
children aa875e77e5ce e64e6fbd1351
comparison
equal deleted inserted replaced
20537:c49b886231d5 20538:90fd0826c6ce
136 static void 136 static void
137 msn_oim_send_read_cb(MsnSoapMessage *request, MsnSoapMessage *response, 137 msn_oim_send_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
138 gpointer data) 138 gpointer data)
139 { 139 {
140 MsnOim *oim = data; 140 MsnOim *oim = data;
141 xmlnode *faultNode, *challengeNode;
142 MsnOimSendReq *msg = g_queue_pop_head(oim->send_queue); 141 MsnOimSendReq *msg = g_queue_pop_head(oim->send_queue);
143 142
144 g_return_if_fail(msg != NULL); 143 g_return_if_fail(msg != NULL);
145 144
146 if (response == NULL) { 145 if (response == NULL) {
147 purple_debug_info("MSNP14", "cannot send OIM: %s\n", msg->oim_msg); 146 purple_debug_info("MSNP14", "cannot send OIM: %s\n", msg->oim_msg);
148 } else { 147 } else {
149 faultNode = msn_soap_xml_get(response->xml, "Body/Fault"); 148 xmlnode *faultNode = msn_soap_xml_get(response->xml, "Body/Fault");
150 149
151 if (faultNode == NULL) { 150 if (faultNode == NULL) {
152 /*Send OK! return*/ 151 /*Send OK! return*/
153 purple_debug_info("MSNP14", "sent OIM: %s\n", msg->oim_msg); 152 purple_debug_info("MSNP14", "sent OIM: %s\n", msg->oim_msg);
154 } else { 153 } else {
155 /*get the challenge,and repost it*/ 154 xmlnode *faultcode = xmlnode_get_child(faultNode, "faultcode");
156 challengeNode = msn_soap_xml_get(faultNode, 155
157 "detail/LockKeyChallenge"); 156 if (faultcode) {
158 157 char *faultcode_str = xmlnode_get_data(faultcode);
159 if (challengeNode == NULL) { 158
160 purple_debug_info("MSNP14", "can't find lock key for OIM: %s\n", msg); 159 if (g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
161 } else { 160 xmlnode *challengeNode = msn_soap_xml_get(faultNode,
162 char buf[33]; 161 "detail/LockKeyChallenge");
163 162
164 char *challenge = xmlnode_get_data(challengeNode); 163 if (challengeNode == NULL) {
165 msn_handle_chl(challenge, buf); 164 if (oim->challenge) {
166 165 g_free(oim->challenge);
167 g_free(oim->challenge); 166 oim->challenge = NULL;
168 oim->challenge = g_strndup(buf, sizeof(buf)); 167
169 g_free(challenge); 168 purple_debug_info("msnoim","resending OIM: %s\n",
170 purple_debug_info("MSNP14","lockkey:{%s}\n",oim->challenge); 169 msg->oim_msg);
171 170 g_queue_push_head(oim->send_queue, msg);
172 /*repost the send*/ 171 msn_oim_send_msg(oim);
173 purple_debug_info("MSNP14","resending OIM: %s\n", msg->oim_msg); 172 return;
174 g_queue_push_head(oim->send_queue, msg); 173 } else {
175 msn_oim_send_msg(oim); 174 purple_debug_info("msnoim",
176 return; 175 "can't find lock key for OIM: %s\n",
176 msg->oim_msg);
177 }
178 } else {
179 char buf[33];
180
181 char *challenge = xmlnode_get_data(challengeNode);
182 msn_handle_chl(challenge, buf);
183
184 g_free(oim->challenge);
185 oim->challenge = g_strndup(buf, sizeof(buf));
186 g_free(challenge);
187 purple_debug_info("MSNP14","lockkey:{%s}\n",oim->challenge);
188
189 /*repost the send*/
190 purple_debug_info("MSNP14","resending OIM: %s\n", msg->oim_msg);
191 g_queue_push_head(oim->send_queue, msg);
192 msn_oim_send_msg(oim);
193 return;
194 }
195 }
177 } 196 }
178 } 197 }
179 } 198 }
180 199
181 msn_oim_free_send_req(msg); 200 msn_oim_free_send_req(msg);