comparison libpurple/protocols/msn/contact.c @ 25458:b1080a1a2cb0

Save and use the CacheKey for ABCH SOAP requests. Fixes #8080.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 15 Feb 2009 21:15:39 +0000
parents 8387f195c4af
children c729cdeb88c8
comparison
equal deleted inserted replaced
25457:3f6dbc414357 25458:b1080a1a2cb0
196 gpointer data) 196 gpointer data)
197 { 197 {
198 MsnCallbackState *state = data; 198 MsnCallbackState *state = data;
199 xmlnode *fault; 199 xmlnode *fault;
200 char *faultcode_str; 200 char *faultcode_str;
201 xmlnode *cachekey;
202 char *changed;
201 203
202 if (resp == NULL) { 204 if (resp == NULL) {
203 purple_debug_error("msn", 205 purple_debug_error("msn",
204 "Operation {%s} failed. No response received from server.\n", 206 "Operation {%s} failed. No response received from server.\n",
205 msn_contact_operation_str(state->action)); 207 msn_contact_operation_str(state->action));
206 return; 208 return;
207 } 209 }
210
211 /* Update CacheKey if necessary */
212 cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKeyChanged");
213 if (cachekey != NULL) {
214 changed = xmlnode_get_data(cachekey);
215 if (changed && !strcmp(changed, "true")) {
216 cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKey");
217 g_free(state->session->abch_cachekey);
218 state->session->abch_cachekey = xmlnode_get_data(cachekey);
219 purple_debug_info("msn", "Updated CacheKey for %s to '%s'.\n",
220 purple_account_get_username(state->session->account),
221 state->session->abch_cachekey);
222 }
223 g_free(changed);
224 }
208 225
209 fault = xmlnode_get_child(resp->xml, "Body/Fault"); 226 fault = xmlnode_get_child(resp->xml, "Body/Fault");
210 227
211 if (fault == NULL) { 228 if (fault == NULL) {
212 /* No errors */ 229 /* No errors */
245 } 262 }
246 263
247 static gboolean 264 static gboolean
248 msn_contact_request(MsnCallbackState *state) 265 msn_contact_request(MsnCallbackState *state)
249 { 266 {
267 xmlnode *cachekey = xmlnode_get_child(state->body,
268 "Header/ABApplicationHeader/CacheKey");
269 if (cachekey != NULL)
270 xmlnode_free(cachekey);
271 if (state->session->abch_cachekey != NULL) {
272 cachekey = xmlnode_new_child(xmlnode_get_child(state->body, "Header/ABApplicationHeader"), "CacheKey");
273 xmlnode_insert_data(cachekey, state->session->abch_cachekey, -1);
274 }
250 if (state->token == NULL) 275 if (state->token == NULL)
251 state->token = xmlnode_get_child(state->body, 276 state->token = xmlnode_get_child(state->body,
252 "Header/ABAuthHeader/TicketToken"); 277 "Header/ABAuthHeader/TicketToken");
253 /* delete old & replace with new token */ 278 /* delete old & replace with new token */
254 xmlnode_free(state->token->child); 279 xmlnode_free(state->token->child);