1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2012 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* MSN module - All the SOAPy XML stuff. |
---|
8 | Some manager at Microsoft apparently thought MSNP wasn't XMLy enough so |
---|
9 | someone stepped up and changed that. This is the result. Kilobytes and |
---|
10 | more kilobytes of XML vomit to transfer tiny bits of informaiton. */ |
---|
11 | |
---|
12 | /* |
---|
13 | This program is free software; you can redistribute it and/or modify |
---|
14 | it under the terms of the GNU General Public License as published by |
---|
15 | the Free Software Foundation; either version 2 of the License, or |
---|
16 | (at your option) any later version. |
---|
17 | |
---|
18 | This program is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | GNU General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License with |
---|
24 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
25 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
26 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
27 | */ |
---|
28 | |
---|
29 | #include "http_client.h" |
---|
30 | #include "soap.h" |
---|
31 | #include "msn.h" |
---|
32 | #include "bitlbee.h" |
---|
33 | #include "url.h" |
---|
34 | #include "misc.h" |
---|
35 | #include "sha1.h" |
---|
36 | #include "base64.h" |
---|
37 | #include "xmltree.h" |
---|
38 | #include <ctype.h> |
---|
39 | #include <errno.h> |
---|
40 | |
---|
41 | /* This file tries to make SOAP stuff pretty simple to do by letting you just |
---|
42 | provide a function to build a request, a few functions to parse various |
---|
43 | parts of the response, and a function to run when the full response was |
---|
44 | received and parsed. See the various examples below. */ |
---|
45 | |
---|
46 | typedef enum { |
---|
47 | MSN_SOAP_OK, |
---|
48 | MSN_SOAP_RETRY, |
---|
49 | MSN_SOAP_REAUTH, |
---|
50 | MSN_SOAP_ABORT, |
---|
51 | } msn_soap_result_t; |
---|
52 | |
---|
53 | struct msn_soap_req_data; |
---|
54 | typedef int (*msn_soap_func) (struct msn_soap_req_data *); |
---|
55 | |
---|
56 | struct msn_soap_req_data { |
---|
57 | void *data; |
---|
58 | struct im_connection *ic; |
---|
59 | int ttl; |
---|
60 | char *error; |
---|
61 | |
---|
62 | char *url, *action, *payload; |
---|
63 | struct http_request *http_req; |
---|
64 | |
---|
65 | const struct xt_handler_entry *xml_parser; |
---|
66 | msn_soap_func build_request, handle_response, free_data; |
---|
67 | }; |
---|
68 | |
---|
69 | static int msn_soap_send_request(struct msn_soap_req_data *req); |
---|
70 | static void msn_soap_free(struct msn_soap_req_data *soap_req); |
---|
71 | static void msn_soap_debug_print(const char *headers, const char *payload); |
---|
72 | |
---|
73 | static int msn_soap_start(struct im_connection *ic, |
---|
74 | void *data, |
---|
75 | msn_soap_func build_request, |
---|
76 | const struct xt_handler_entry *xml_parser, |
---|
77 | msn_soap_func handle_response, |
---|
78 | msn_soap_func free_data) |
---|
79 | { |
---|
80 | struct msn_soap_req_data *req = g_new0(struct msn_soap_req_data, 1); |
---|
81 | |
---|
82 | req->ic = ic; |
---|
83 | req->data = data; |
---|
84 | req->xml_parser = xml_parser; |
---|
85 | req->build_request = build_request; |
---|
86 | req->handle_response = handle_response; |
---|
87 | req->free_data = free_data; |
---|
88 | req->ttl = 3; |
---|
89 | |
---|
90 | return msn_soap_send_request(req); |
---|
91 | } |
---|
92 | |
---|
93 | static void msn_soap_handle_response(struct http_request *http_req); |
---|
94 | |
---|
95 | static int msn_soap_send_request(struct msn_soap_req_data *soap_req) |
---|
96 | { |
---|
97 | char *http_req; |
---|
98 | char *soap_action = NULL; |
---|
99 | url_t url; |
---|
100 | |
---|
101 | soap_req->build_request(soap_req); |
---|
102 | |
---|
103 | if (soap_req->action) { |
---|
104 | soap_action = g_strdup_printf("SOAPAction: \"%s\"\r\n", soap_req->action); |
---|
105 | } |
---|
106 | |
---|
107 | url_set(&url, soap_req->url); |
---|
108 | http_req = g_strdup_printf(SOAP_HTTP_REQUEST, url.file, url.host, |
---|
109 | soap_action ? soap_action : "", |
---|
110 | strlen(soap_req->payload), soap_req->payload); |
---|
111 | |
---|
112 | msn_soap_debug_print(http_req, soap_req->payload); |
---|
113 | |
---|
114 | soap_req->http_req = http_dorequest(url.host, url.port, url.proto == PROTO_HTTPS, |
---|
115 | http_req, msn_soap_handle_response, soap_req); |
---|
116 | |
---|
117 | g_free(http_req); |
---|
118 | g_free(soap_action); |
---|
119 | |
---|
120 | return soap_req->http_req != NULL; |
---|
121 | } |
---|
122 | |
---|
123 | static void msn_soap_handle_response(struct http_request *http_req) |
---|
124 | { |
---|
125 | struct msn_soap_req_data *soap_req = http_req->data; |
---|
126 | int st; |
---|
127 | |
---|
128 | if (g_slist_find(msn_connections, soap_req->ic) == NULL) { |
---|
129 | msn_soap_free(soap_req); |
---|
130 | return; |
---|
131 | } |
---|
132 | |
---|
133 | msn_soap_debug_print(http_req->reply_headers, http_req->reply_body); |
---|
134 | |
---|
135 | if (http_req->body_size > 0) { |
---|
136 | struct xt_parser *parser; |
---|
137 | struct xt_node *err; |
---|
138 | |
---|
139 | parser = xt_new(soap_req->xml_parser, soap_req); |
---|
140 | xt_feed(parser, http_req->reply_body, http_req->body_size); |
---|
141 | if (http_req->status_code == 500 && |
---|
142 | (err = xt_find_path(parser->root, "soap:Body/soap:Fault/detail/errorcode")) && |
---|
143 | err->text_len > 0) { |
---|
144 | if (strcmp(err->text, "PassportAuthFail") == 0) { |
---|
145 | xt_free(parser); |
---|
146 | st = MSN_SOAP_REAUTH; |
---|
147 | goto fail; |
---|
148 | } |
---|
149 | /* TODO: Handle/report other errors. */ |
---|
150 | } |
---|
151 | |
---|
152 | xt_handle(parser, NULL, -1); |
---|
153 | xt_free(parser); |
---|
154 | } |
---|
155 | |
---|
156 | if (http_req->status_code != 200) { |
---|
157 | soap_req->error = g_strdup(http_req->status_string); |
---|
158 | } |
---|
159 | |
---|
160 | st = soap_req->handle_response(soap_req); |
---|
161 | |
---|
162 | fail: |
---|
163 | g_free(soap_req->url); |
---|
164 | g_free(soap_req->action); |
---|
165 | g_free(soap_req->payload); |
---|
166 | g_free(soap_req->error); |
---|
167 | soap_req->url = soap_req->action = soap_req->payload = soap_req->error = NULL; |
---|
168 | |
---|
169 | if (st == MSN_SOAP_RETRY && --soap_req->ttl) { |
---|
170 | msn_soap_send_request(soap_req); |
---|
171 | } else if (st == MSN_SOAP_REAUTH) { |
---|
172 | struct msn_data *md = soap_req->ic->proto_data; |
---|
173 | |
---|
174 | if (!(md->flags & MSN_REAUTHING)) { |
---|
175 | /* Nonce shouldn't actually be touched for re-auths. */ |
---|
176 | msn_soap_passport_sso_request(soap_req->ic, "blaataap"); |
---|
177 | md->flags |= MSN_REAUTHING; |
---|
178 | } |
---|
179 | md->soapq = g_slist_append(md->soapq, soap_req); |
---|
180 | } else { |
---|
181 | soap_req->free_data(soap_req); |
---|
182 | g_free(soap_req); |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | static char *msn_soap_abservice_build(const char *body_fmt, const char *scenario, const char *ticket, ...) |
---|
187 | { |
---|
188 | va_list params; |
---|
189 | char *ret, *format, *body; |
---|
190 | |
---|
191 | format = g_markup_printf_escaped(SOAP_ABSERVICE_PAYLOAD, scenario, ticket); |
---|
192 | |
---|
193 | va_start(params, ticket); |
---|
194 | body = g_strdup_vprintf(body_fmt, params); |
---|
195 | va_end(params); |
---|
196 | |
---|
197 | ret = g_strdup_printf(format, body); |
---|
198 | g_free(body); |
---|
199 | g_free(format); |
---|
200 | |
---|
201 | return ret; |
---|
202 | } |
---|
203 | |
---|
204 | static void msn_soap_debug_print(const char *headers, const char *payload) |
---|
205 | { |
---|
206 | char *s; |
---|
207 | |
---|
208 | if (!getenv("BITLBEE_DEBUG")) { |
---|
209 | return; |
---|
210 | } |
---|
211 | fprintf(stderr, "\n\x1b[90mSOAP:\n"); |
---|
212 | |
---|
213 | if (headers) { |
---|
214 | if ((s = strstr(headers, "\r\n\r\n"))) { |
---|
215 | write(2, headers, s - headers + 4); |
---|
216 | } else { |
---|
217 | write(2, headers, strlen(headers)); |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | if (payload) { |
---|
222 | struct xt_node *xt = xt_from_string(payload, 0); |
---|
223 | if (xt) { |
---|
224 | xt_print(xt); |
---|
225 | } |
---|
226 | xt_free_node(xt); |
---|
227 | } |
---|
228 | fprintf(stderr, "\n\x1b[97m\n"); |
---|
229 | } |
---|
230 | |
---|
231 | int msn_soapq_flush(struct im_connection *ic, gboolean resend) |
---|
232 | { |
---|
233 | struct msn_data *md = ic->proto_data; |
---|
234 | |
---|
235 | while (md->soapq) { |
---|
236 | if (resend) { |
---|
237 | msn_soap_send_request((struct msn_soap_req_data*) md->soapq->data); |
---|
238 | } else { |
---|
239 | msn_soap_free((struct msn_soap_req_data*) md->soapq->data); |
---|
240 | } |
---|
241 | md->soapq = g_slist_remove(md->soapq, md->soapq->data); |
---|
242 | } |
---|
243 | |
---|
244 | return MSN_SOAP_OK; |
---|
245 | } |
---|
246 | |
---|
247 | static void msn_soap_free(struct msn_soap_req_data *soap_req) |
---|
248 | { |
---|
249 | soap_req->free_data(soap_req); |
---|
250 | g_free(soap_req->url); |
---|
251 | g_free(soap_req->action); |
---|
252 | g_free(soap_req->payload); |
---|
253 | g_free(soap_req->error); |
---|
254 | g_free(soap_req); |
---|
255 | } |
---|
256 | |
---|
257 | |
---|
258 | /* passport_sso: Authentication MSNP15+ */ |
---|
259 | |
---|
260 | struct msn_soap_passport_sso_data { |
---|
261 | char *nonce; |
---|
262 | char *secret; |
---|
263 | char *error; |
---|
264 | char *redirect; |
---|
265 | }; |
---|
266 | |
---|
267 | static int msn_soap_passport_sso_build_request(struct msn_soap_req_data *soap_req) |
---|
268 | { |
---|
269 | struct msn_soap_passport_sso_data *sd = soap_req->data; |
---|
270 | struct im_connection *ic = soap_req->ic; |
---|
271 | struct msn_data *md = ic->proto_data; |
---|
272 | char pass[MAX_PASSPORT_PWLEN + 1]; |
---|
273 | |
---|
274 | if (sd->redirect) { |
---|
275 | soap_req->url = sd->redirect; |
---|
276 | sd->redirect = NULL; |
---|
277 | } |
---|
278 | /* MS changed this URL and broke the old MSN-specific one. The generic |
---|
279 | one works, forwarding us to a msn.com URL that works. Takes an extra |
---|
280 | second, but that's better than not being able to log in at all. :-/ |
---|
281 | else if( g_str_has_suffix( ic->acc->user, "@msn.com" ) ) |
---|
282 | soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL_MSN ); |
---|
283 | */ |
---|
284 | else { |
---|
285 | soap_req->url = g_strdup(SOAP_PASSPORT_SSO_URL); |
---|
286 | } |
---|
287 | |
---|
288 | strncpy(pass, ic->acc->pass, MAX_PASSPORT_PWLEN); |
---|
289 | pass[MAX_PASSPORT_PWLEN] = '\0'; |
---|
290 | soap_req->payload = g_markup_printf_escaped(SOAP_PASSPORT_SSO_PAYLOAD, |
---|
291 | ic->acc->user, pass, md->pp_policy); |
---|
292 | |
---|
293 | return MSN_SOAP_OK; |
---|
294 | } |
---|
295 | |
---|
296 | static xt_status msn_soap_passport_sso_token(struct xt_node *node, gpointer data) |
---|
297 | { |
---|
298 | struct msn_soap_req_data *soap_req = data; |
---|
299 | struct msn_soap_passport_sso_data *sd = soap_req->data; |
---|
300 | struct msn_data *md = soap_req->ic->proto_data; |
---|
301 | struct xt_node *p; |
---|
302 | char *id; |
---|
303 | |
---|
304 | if ((id = xt_find_attr(node, "Id")) == NULL) { |
---|
305 | return XT_HANDLED; |
---|
306 | } |
---|
307 | id += strlen(id) - 1; |
---|
308 | if (*id == '1' && |
---|
309 | (p = xt_find_path(node, "../../wst:RequestedProofToken/wst:BinarySecret")) && |
---|
310 | p->text) { |
---|
311 | sd->secret = g_strdup(p->text); |
---|
312 | } |
---|
313 | |
---|
314 | *id -= '1'; |
---|
315 | if (*id >= 0 && *id < sizeof(md->tokens) / sizeof(md->tokens[0])) { |
---|
316 | g_free(md->tokens[(int) *id]); |
---|
317 | md->tokens[(int) *id] = g_strdup(node->text); |
---|
318 | } |
---|
319 | |
---|
320 | return XT_HANDLED; |
---|
321 | } |
---|
322 | |
---|
323 | static xt_status msn_soap_passport_failure(struct xt_node *node, gpointer data) |
---|
324 | { |
---|
325 | struct msn_soap_req_data *soap_req = data; |
---|
326 | struct msn_soap_passport_sso_data *sd = soap_req->data; |
---|
327 | struct xt_node *code = xt_find_node(node->children, "faultcode"); |
---|
328 | struct xt_node *string = xt_find_node(node->children, "faultstring"); |
---|
329 | struct xt_node *reqstatus = xt_find_path(node, "psf:pp/psf:reqstatus"); |
---|
330 | struct xt_node *url; |
---|
331 | |
---|
332 | if (code == NULL || code->text_len == 0) { |
---|
333 | sd->error = g_strdup("Unknown error"); |
---|
334 | } else if (strcmp(code->text, "psf:Redirect") == 0 && |
---|
335 | (url = xt_find_node(node->children, "psf:redirectUrl")) && |
---|
336 | url->text_len > 0) { |
---|
337 | sd->redirect = g_strdup(url->text); |
---|
338 | } else if (reqstatus && strcmp(reqstatus->text, "0x800488fe") == 0) { |
---|
339 | char *msg = "Location blocked. Log in to live.com, go to recent activity and click 'this was me'"; |
---|
340 | sd->error = g_strdup_printf("%s (%s)", code->text, msg); |
---|
341 | } else { |
---|
342 | sd->error = g_strdup_printf("%s (%s)", code->text, string && string->text_len ? |
---|
343 | string->text : "no description available"); |
---|
344 | } |
---|
345 | |
---|
346 | return XT_HANDLED; |
---|
347 | } |
---|
348 | |
---|
349 | static const struct xt_handler_entry msn_soap_passport_sso_parser[] = { |
---|
350 | { "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", msn_soap_passport_sso_token }, |
---|
351 | { "S:Fault", "S:Envelope", msn_soap_passport_failure }, |
---|
352 | { "S:Fault", "wst:RequestSecurityTokenResponse", msn_soap_passport_failure }, |
---|
353 | { NULL, NULL, NULL } |
---|
354 | }; |
---|
355 | |
---|
356 | static char *msn_key_fuckery(char *key, int key_len, char *type) |
---|
357 | { |
---|
358 | unsigned char hash1[20 + strlen(type) + 1]; |
---|
359 | unsigned char hash2[20]; |
---|
360 | char *ret; |
---|
361 | |
---|
362 | sha1_hmac(key, key_len, type, 0, hash1); |
---|
363 | strcpy((char *) hash1 + 20, type); |
---|
364 | sha1_hmac(key, key_len, (char *) hash1, sizeof(hash1) - 1, hash2); |
---|
365 | |
---|
366 | /* This is okay as hash1 is read completely before it's overwritten. */ |
---|
367 | sha1_hmac(key, key_len, (char *) hash1, 20, hash1); |
---|
368 | sha1_hmac(key, key_len, (char *) hash1, sizeof(hash1) - 1, hash1); |
---|
369 | |
---|
370 | ret = g_malloc(24); |
---|
371 | memcpy(ret, hash2, 20); |
---|
372 | memcpy(ret + 20, hash1, 4); |
---|
373 | return ret; |
---|
374 | } |
---|
375 | |
---|
376 | static int msn_soap_passport_sso_handle_response(struct msn_soap_req_data *soap_req) |
---|
377 | { |
---|
378 | struct msn_soap_passport_sso_data *sd = soap_req->data; |
---|
379 | struct im_connection *ic = soap_req->ic; |
---|
380 | struct msn_data *md = ic->proto_data; |
---|
381 | char *key1, *key2, *key3, *blurb64; |
---|
382 | int key1_len; |
---|
383 | unsigned char *padnonce, *des3res; |
---|
384 | |
---|
385 | struct { |
---|
386 | unsigned int uStructHeaderSize; // 28. Does not count data |
---|
387 | unsigned int uCryptMode; // CRYPT_MODE_CBC (1) |
---|
388 | unsigned int uCipherType; // TripleDES (0x6603) |
---|
389 | unsigned int uHashType; // SHA1 (0x8004) |
---|
390 | unsigned int uIVLen; // 8 |
---|
391 | unsigned int uHashLen; // 20 |
---|
392 | unsigned int uCipherLen; // 72 |
---|
393 | unsigned char iv[8]; |
---|
394 | unsigned char hash[20]; |
---|
395 | unsigned char cipherbytes[72]; |
---|
396 | } blurb = { |
---|
397 | GUINT32_TO_LE(28), |
---|
398 | GUINT32_TO_LE(1), |
---|
399 | GUINT32_TO_LE(0x6603), |
---|
400 | GUINT32_TO_LE(0x8004), |
---|
401 | GUINT32_TO_LE(8), |
---|
402 | GUINT32_TO_LE(20), |
---|
403 | GUINT32_TO_LE(72), |
---|
404 | }; |
---|
405 | |
---|
406 | if (sd->redirect) { |
---|
407 | return MSN_SOAP_RETRY; |
---|
408 | } |
---|
409 | |
---|
410 | if (md->soapq) { |
---|
411 | md->flags &= ~MSN_REAUTHING; |
---|
412 | return msn_soapq_flush(ic, TRUE); |
---|
413 | } |
---|
414 | |
---|
415 | if (sd->secret == NULL) { |
---|
416 | msn_auth_got_passport_token(ic, NULL, sd->error ? sd->error : soap_req->error); |
---|
417 | return MSN_SOAP_OK; |
---|
418 | } |
---|
419 | |
---|
420 | key1_len = base64_decode(sd->secret, (unsigned char **) &key1); |
---|
421 | |
---|
422 | key2 = msn_key_fuckery(key1, key1_len, "WS-SecureConversationSESSION KEY HASH"); |
---|
423 | key3 = msn_key_fuckery(key1, key1_len, "WS-SecureConversationSESSION KEY ENCRYPTION"); |
---|
424 | |
---|
425 | sha1_hmac(key2, 24, sd->nonce, 0, blurb.hash); |
---|
426 | padnonce = g_malloc(strlen(sd->nonce) + 8); |
---|
427 | strcpy((char *) padnonce, sd->nonce); |
---|
428 | memset(padnonce + strlen(sd->nonce), 8, 8); |
---|
429 | |
---|
430 | random_bytes(blurb.iv, 8); |
---|
431 | |
---|
432 | ssl_des3_encrypt((unsigned char *) key3, 24, padnonce, strlen(sd->nonce) + 8, blurb.iv, &des3res); |
---|
433 | memcpy(blurb.cipherbytes, des3res, 72); |
---|
434 | |
---|
435 | blurb64 = base64_encode((unsigned char *) &blurb, sizeof(blurb)); |
---|
436 | msn_auth_got_passport_token(ic, blurb64, NULL); |
---|
437 | |
---|
438 | g_free(padnonce); |
---|
439 | g_free(blurb64); |
---|
440 | g_free(des3res); |
---|
441 | g_free(key1); |
---|
442 | g_free(key2); |
---|
443 | g_free(key3); |
---|
444 | |
---|
445 | return MSN_SOAP_OK; |
---|
446 | } |
---|
447 | |
---|
448 | static int msn_soap_passport_sso_free_data(struct msn_soap_req_data *soap_req) |
---|
449 | { |
---|
450 | struct msn_soap_passport_sso_data *sd = soap_req->data; |
---|
451 | |
---|
452 | g_free(sd->nonce); |
---|
453 | g_free(sd->secret); |
---|
454 | g_free(sd->error); |
---|
455 | g_free(sd->redirect); |
---|
456 | g_free(sd); |
---|
457 | |
---|
458 | return MSN_SOAP_OK; |
---|
459 | } |
---|
460 | |
---|
461 | int msn_soap_passport_sso_request(struct im_connection *ic, const char *nonce) |
---|
462 | { |
---|
463 | struct msn_soap_passport_sso_data *sd = g_new0(struct msn_soap_passport_sso_data, 1); |
---|
464 | |
---|
465 | sd->nonce = g_strdup(nonce); |
---|
466 | |
---|
467 | return msn_soap_start(ic, sd, msn_soap_passport_sso_build_request, |
---|
468 | msn_soap_passport_sso_parser, |
---|
469 | msn_soap_passport_sso_handle_response, |
---|
470 | msn_soap_passport_sso_free_data); |
---|
471 | } |
---|
472 | |
---|
473 | |
---|
474 | /* memlist: Fetching the membership list (NOT address book) */ |
---|
475 | |
---|
476 | static int msn_soap_memlist_build_request(struct msn_soap_req_data *soap_req) |
---|
477 | { |
---|
478 | struct msn_data *md = soap_req->ic->proto_data; |
---|
479 | |
---|
480 | soap_req->url = g_strdup(SOAP_MEMLIST_URL); |
---|
481 | soap_req->action = g_strdup(SOAP_MEMLIST_ACTION); |
---|
482 | soap_req->payload = msn_soap_abservice_build(SOAP_MEMLIST_PAYLOAD, "Initial", md->tokens[1]); |
---|
483 | |
---|
484 | return 1; |
---|
485 | } |
---|
486 | |
---|
487 | static xt_status msn_soap_memlist_member(struct xt_node *node, gpointer data) |
---|
488 | { |
---|
489 | bee_user_t *bu; |
---|
490 | struct msn_buddy_data *bd; |
---|
491 | struct xt_node *p; |
---|
492 | char *role = NULL, *handle = NULL; |
---|
493 | struct msn_soap_req_data *soap_req = data; |
---|
494 | struct im_connection *ic = soap_req->ic; |
---|
495 | |
---|
496 | if ((p = xt_find_path(node, "../../MemberRole"))) { |
---|
497 | role = p->text; |
---|
498 | } |
---|
499 | |
---|
500 | if ((p = xt_find_node(node->children, "PassportName"))) { |
---|
501 | handle = p->text; |
---|
502 | } |
---|
503 | |
---|
504 | if (!role || !handle || |
---|
505 | !((bu = bee_user_by_handle(ic->bee, ic, handle)) || |
---|
506 | (bu = bee_user_new(ic->bee, ic, handle, 0)))) { |
---|
507 | return XT_HANDLED; |
---|
508 | } |
---|
509 | |
---|
510 | bd = bu->data; |
---|
511 | if (strcmp(role, "Allow") == 0) { |
---|
512 | bd->flags |= MSN_BUDDY_AL; |
---|
513 | ic->permit = g_slist_prepend(ic->permit, g_strdup(handle)); |
---|
514 | } else if (strcmp(role, "Block") == 0) { |
---|
515 | bd->flags |= MSN_BUDDY_BL; |
---|
516 | ic->deny = g_slist_prepend(ic->deny, g_strdup(handle)); |
---|
517 | } else if (strcmp(role, "Reverse") == 0) { |
---|
518 | bd->flags |= MSN_BUDDY_RL; |
---|
519 | } else if (strcmp(role, "Pending") == 0) { |
---|
520 | bd->flags |= MSN_BUDDY_PL; |
---|
521 | } |
---|
522 | |
---|
523 | if (getenv("BITLBEE_DEBUG")) { |
---|
524 | fprintf(stderr, "%p %s %d\n", bu, handle, bd->flags); |
---|
525 | } |
---|
526 | |
---|
527 | return XT_HANDLED; |
---|
528 | } |
---|
529 | |
---|
530 | static const struct xt_handler_entry msn_soap_memlist_parser[] = { |
---|
531 | { "Member", "Members", msn_soap_memlist_member }, |
---|
532 | { NULL, NULL, NULL } |
---|
533 | }; |
---|
534 | |
---|
535 | static int msn_soap_memlist_handle_response(struct msn_soap_req_data *soap_req) |
---|
536 | { |
---|
537 | msn_soap_addressbook_request(soap_req->ic); |
---|
538 | |
---|
539 | return MSN_SOAP_OK; |
---|
540 | } |
---|
541 | |
---|
542 | static int msn_soap_memlist_free_data(struct msn_soap_req_data *soap_req) |
---|
543 | { |
---|
544 | return 0; |
---|
545 | } |
---|
546 | |
---|
547 | int msn_soap_memlist_request(struct im_connection *ic) |
---|
548 | { |
---|
549 | return msn_soap_start(ic, NULL, msn_soap_memlist_build_request, |
---|
550 | msn_soap_memlist_parser, |
---|
551 | msn_soap_memlist_handle_response, |
---|
552 | msn_soap_memlist_free_data); |
---|
553 | } |
---|
554 | |
---|
555 | /* Variant: Adding/Removing people */ |
---|
556 | struct msn_soap_memlist_edit_data { |
---|
557 | char *handle; |
---|
558 | gboolean add; |
---|
559 | msn_buddy_flags_t list; |
---|
560 | }; |
---|
561 | |
---|
562 | static int msn_soap_memlist_edit_build_request(struct msn_soap_req_data *soap_req) |
---|
563 | { |
---|
564 | struct msn_data *md = soap_req->ic->proto_data; |
---|
565 | struct msn_soap_memlist_edit_data *med = soap_req->data; |
---|
566 | char *add, *scenario, *list; |
---|
567 | |
---|
568 | soap_req->url = g_strdup(SOAP_MEMLIST_URL); |
---|
569 | if (med->add) { |
---|
570 | soap_req->action = g_strdup(SOAP_MEMLIST_ADD_ACTION); |
---|
571 | add = "Add"; |
---|
572 | } else { |
---|
573 | soap_req->action = g_strdup(SOAP_MEMLIST_DEL_ACTION); |
---|
574 | add = "Delete"; |
---|
575 | } |
---|
576 | switch (med->list) { |
---|
577 | case MSN_BUDDY_AL: |
---|
578 | scenario = "BlockUnblock"; |
---|
579 | list = "Allow"; |
---|
580 | break; |
---|
581 | case MSN_BUDDY_BL: |
---|
582 | scenario = "BlockUnblock"; |
---|
583 | list = "Block"; |
---|
584 | break; |
---|
585 | case MSN_BUDDY_RL: |
---|
586 | scenario = "Timer"; |
---|
587 | list = "Reverse"; |
---|
588 | break; |
---|
589 | case MSN_BUDDY_PL: |
---|
590 | default: |
---|
591 | scenario = "Timer"; |
---|
592 | list = "Pending"; |
---|
593 | break; |
---|
594 | } |
---|
595 | soap_req->payload = msn_soap_abservice_build(SOAP_MEMLIST_EDIT_PAYLOAD, |
---|
596 | scenario, md->tokens[1], add, list, med->handle, add); |
---|
597 | |
---|
598 | return 1; |
---|
599 | } |
---|
600 | |
---|
601 | static int msn_soap_memlist_edit_handle_response(struct msn_soap_req_data *soap_req) |
---|
602 | { |
---|
603 | return MSN_SOAP_OK; |
---|
604 | } |
---|
605 | |
---|
606 | static int msn_soap_memlist_edit_free_data(struct msn_soap_req_data *soap_req) |
---|
607 | { |
---|
608 | struct msn_soap_memlist_edit_data *med = soap_req->data; |
---|
609 | |
---|
610 | g_free(med->handle); |
---|
611 | g_free(med); |
---|
612 | |
---|
613 | return 0; |
---|
614 | } |
---|
615 | |
---|
616 | int msn_soap_memlist_edit(struct im_connection *ic, const char *handle, gboolean add, int list) |
---|
617 | { |
---|
618 | struct msn_soap_memlist_edit_data *med; |
---|
619 | |
---|
620 | med = g_new0(struct msn_soap_memlist_edit_data, 1); |
---|
621 | med->handle = g_strdup(handle); |
---|
622 | med->add = add; |
---|
623 | med->list = list; |
---|
624 | |
---|
625 | return msn_soap_start(ic, med, msn_soap_memlist_edit_build_request, |
---|
626 | NULL, |
---|
627 | msn_soap_memlist_edit_handle_response, |
---|
628 | msn_soap_memlist_edit_free_data); |
---|
629 | } |
---|
630 | |
---|
631 | |
---|
632 | /* addressbook: Fetching the membership list (NOT address book) */ |
---|
633 | |
---|
634 | static int msn_soap_addressbook_build_request(struct msn_soap_req_data *soap_req) |
---|
635 | { |
---|
636 | struct msn_data *md = soap_req->ic->proto_data; |
---|
637 | |
---|
638 | soap_req->url = g_strdup(SOAP_ADDRESSBOOK_URL); |
---|
639 | soap_req->action = g_strdup(SOAP_ADDRESSBOOK_ACTION); |
---|
640 | soap_req->payload = msn_soap_abservice_build(SOAP_ADDRESSBOOK_PAYLOAD, "Initial", md->tokens[1]); |
---|
641 | |
---|
642 | return 1; |
---|
643 | } |
---|
644 | |
---|
645 | static xt_status msn_soap_addressbook_group(struct xt_node *node, gpointer data) |
---|
646 | { |
---|
647 | struct xt_node *p; |
---|
648 | char *id = NULL, *name = NULL; |
---|
649 | struct msn_soap_req_data *soap_req = data; |
---|
650 | struct msn_data *md = soap_req->ic->proto_data; |
---|
651 | |
---|
652 | if ((p = xt_find_path(node, "../groupId"))) { |
---|
653 | id = p->text; |
---|
654 | } |
---|
655 | |
---|
656 | if ((p = xt_find_node(node->children, "name"))) { |
---|
657 | name = p->text; |
---|
658 | } |
---|
659 | |
---|
660 | if (id && name) { |
---|
661 | struct msn_group *mg = g_new0(struct msn_group, 1); |
---|
662 | mg->id = g_strdup(id); |
---|
663 | mg->name = g_strdup(name); |
---|
664 | md->groups = g_slist_prepend(md->groups, mg); |
---|
665 | } |
---|
666 | |
---|
667 | if (getenv("BITLBEE_DEBUG")) { |
---|
668 | fprintf(stderr, "%s %s\n", id, name); |
---|
669 | } |
---|
670 | |
---|
671 | return XT_HANDLED; |
---|
672 | } |
---|
673 | |
---|
674 | static xt_status msn_soap_addressbook_contact(struct xt_node *node, gpointer data) |
---|
675 | { |
---|
676 | bee_user_t *bu; |
---|
677 | struct msn_buddy_data *bd; |
---|
678 | struct xt_node *p; |
---|
679 | char *id = NULL, *type = NULL, *handle = NULL, *is_msgr = "false", |
---|
680 | *display_name = NULL, *group_id = NULL; |
---|
681 | struct msn_soap_req_data *soap_req = data; |
---|
682 | struct im_connection *ic = soap_req->ic; |
---|
683 | struct msn_group *group; |
---|
684 | |
---|
685 | if ((p = xt_find_path(node, "../contactId"))) { |
---|
686 | id = p->text; |
---|
687 | } |
---|
688 | if ((p = xt_find_node(node->children, "contactType"))) { |
---|
689 | type = p->text; |
---|
690 | } |
---|
691 | if ((p = xt_find_node(node->children, "passportName"))) { |
---|
692 | handle = p->text; |
---|
693 | } |
---|
694 | if ((p = xt_find_node(node->children, "displayName"))) { |
---|
695 | display_name = p->text; |
---|
696 | } |
---|
697 | if ((p = xt_find_node(node->children, "isMessengerUser"))) { |
---|
698 | is_msgr = p->text; |
---|
699 | } |
---|
700 | if ((p = xt_find_path(node, "groupIds/guid"))) { |
---|
701 | group_id = p->text; |
---|
702 | } |
---|
703 | |
---|
704 | if (type && g_strcasecmp(type, "me") == 0) { |
---|
705 | set_t *set = set_find(&ic->acc->set, "display_name"); |
---|
706 | g_free(set->value); |
---|
707 | set->value = g_strdup(display_name); |
---|
708 | |
---|
709 | /* Try to fetch the profile; if the user has one, that's where |
---|
710 | we can find the persistent display_name. */ |
---|
711 | if ((p = xt_find_node(node->children, "CID")) && p->text) { |
---|
712 | msn_soap_profile_get(ic, p->text); |
---|
713 | } |
---|
714 | |
---|
715 | return XT_HANDLED; |
---|
716 | } |
---|
717 | |
---|
718 | if (!bool2int(is_msgr) || handle == NULL) { |
---|
719 | return XT_HANDLED; |
---|
720 | } |
---|
721 | |
---|
722 | if (!(bu = bee_user_by_handle(ic->bee, ic, handle)) && |
---|
723 | !(bu = bee_user_new(ic->bee, ic, handle, 0))) { |
---|
724 | return XT_HANDLED; |
---|
725 | } |
---|
726 | |
---|
727 | bd = bu->data; |
---|
728 | bd->flags |= MSN_BUDDY_FL; |
---|
729 | g_free(bd->cid); |
---|
730 | bd->cid = g_strdup(id); |
---|
731 | |
---|
732 | imcb_rename_buddy(ic, handle, display_name); |
---|
733 | |
---|
734 | if (group_id && (group = msn_group_by_id(ic, group_id))) { |
---|
735 | imcb_add_buddy(ic, handle, group->name); |
---|
736 | } |
---|
737 | |
---|
738 | if (getenv("BITLBEE_DEBUG")) { |
---|
739 | fprintf(stderr, "%s %s %s %s\n", id, type, handle, display_name); |
---|
740 | } |
---|
741 | |
---|
742 | return XT_HANDLED; |
---|
743 | } |
---|
744 | |
---|
745 | static const struct xt_handler_entry msn_soap_addressbook_parser[] = { |
---|
746 | { "contactInfo", "Contact", msn_soap_addressbook_contact }, |
---|
747 | { "groupInfo", "Group", msn_soap_addressbook_group }, |
---|
748 | { NULL, NULL, NULL } |
---|
749 | }; |
---|
750 | |
---|
751 | static int msn_soap_addressbook_handle_response(struct msn_soap_req_data *soap_req) |
---|
752 | { |
---|
753 | GSList *l; |
---|
754 | int wtf = 0; |
---|
755 | |
---|
756 | for (l = soap_req->ic->bee->users; l; l = l->next) { |
---|
757 | struct bee_user *bu = l->data; |
---|
758 | struct msn_buddy_data *bd = bu->data; |
---|
759 | |
---|
760 | if (bu->ic == soap_req->ic && bd) { |
---|
761 | msn_buddy_ask(bu); |
---|
762 | |
---|
763 | if ((bd->flags & (MSN_BUDDY_AL | MSN_BUDDY_BL)) == |
---|
764 | (MSN_BUDDY_AL | MSN_BUDDY_BL)) { |
---|
765 | /* both allow and block, delete block, add wtf */ |
---|
766 | bd->flags &= ~MSN_BUDDY_BL; |
---|
767 | wtf++; |
---|
768 | } |
---|
769 | |
---|
770 | |
---|
771 | if ((bd->flags & (MSN_BUDDY_AL | MSN_BUDDY_BL)) == 0) { |
---|
772 | /* neither allow or block, add allow */ |
---|
773 | bd->flags |= MSN_BUDDY_AL; |
---|
774 | } |
---|
775 | } |
---|
776 | } |
---|
777 | |
---|
778 | if (wtf) { |
---|
779 | imcb_log(soap_req->ic, "Warning: %d contacts were in both your " |
---|
780 | "block and your allow list. Assuming they're all " |
---|
781 | "allowed. Use the official WLM client once to fix " |
---|
782 | "this.", wtf); |
---|
783 | } |
---|
784 | |
---|
785 | msn_auth_got_contact_list(soap_req->ic); |
---|
786 | |
---|
787 | return MSN_SOAP_OK; |
---|
788 | } |
---|
789 | |
---|
790 | static int msn_soap_addressbook_free_data(struct msn_soap_req_data *soap_req) |
---|
791 | { |
---|
792 | return 0; |
---|
793 | } |
---|
794 | |
---|
795 | int msn_soap_addressbook_request(struct im_connection *ic) |
---|
796 | { |
---|
797 | return msn_soap_start(ic, NULL, msn_soap_addressbook_build_request, |
---|
798 | msn_soap_addressbook_parser, |
---|
799 | msn_soap_addressbook_handle_response, |
---|
800 | msn_soap_addressbook_free_data); |
---|
801 | } |
---|
802 | |
---|
803 | /* Variant: Change our display name. */ |
---|
804 | static int msn_soap_ab_namechange_build_request(struct msn_soap_req_data *soap_req) |
---|
805 | { |
---|
806 | struct msn_data *md = soap_req->ic->proto_data; |
---|
807 | |
---|
808 | soap_req->url = g_strdup(SOAP_ADDRESSBOOK_URL); |
---|
809 | soap_req->action = g_strdup(SOAP_AB_NAMECHANGE_ACTION); |
---|
810 | soap_req->payload = msn_soap_abservice_build(SOAP_AB_NAMECHANGE_PAYLOAD, |
---|
811 | "Timer", md->tokens[1], (char *) soap_req->data); |
---|
812 | |
---|
813 | return 1; |
---|
814 | } |
---|
815 | |
---|
816 | static int msn_soap_ab_namechange_handle_response(struct msn_soap_req_data *soap_req) |
---|
817 | { |
---|
818 | /* TODO: Ack the change? Not sure what the NAKs look like.. */ |
---|
819 | return MSN_SOAP_OK; |
---|
820 | } |
---|
821 | |
---|
822 | static int msn_soap_ab_namechange_free_data(struct msn_soap_req_data *soap_req) |
---|
823 | { |
---|
824 | g_free(soap_req->data); |
---|
825 | return 0; |
---|
826 | } |
---|
827 | |
---|
828 | int msn_soap_addressbook_set_display_name(struct im_connection *ic, const char *new) |
---|
829 | { |
---|
830 | return msn_soap_start(ic, g_strdup(new), |
---|
831 | msn_soap_ab_namechange_build_request, |
---|
832 | NULL, |
---|
833 | msn_soap_ab_namechange_handle_response, |
---|
834 | msn_soap_ab_namechange_free_data); |
---|
835 | } |
---|
836 | |
---|
837 | /* Add a contact. */ |
---|
838 | static int msn_soap_ab_contact_add_build_request(struct msn_soap_req_data *soap_req) |
---|
839 | { |
---|
840 | struct msn_data *md = soap_req->ic->proto_data; |
---|
841 | bee_user_t *bu = soap_req->data; |
---|
842 | |
---|
843 | soap_req->url = g_strdup(SOAP_ADDRESSBOOK_URL); |
---|
844 | soap_req->action = g_strdup(SOAP_AB_CONTACT_ADD_ACTION); |
---|
845 | soap_req->payload = msn_soap_abservice_build(SOAP_AB_CONTACT_ADD_PAYLOAD, |
---|
846 | "ContactSave", md->tokens[1], bu->handle, |
---|
847 | bu->fullname ? bu->fullname : bu->handle); |
---|
848 | |
---|
849 | return 1; |
---|
850 | } |
---|
851 | |
---|
852 | static xt_status msn_soap_ab_contact_add_cid(struct xt_node *node, gpointer data) |
---|
853 | { |
---|
854 | struct msn_soap_req_data *soap_req = data; |
---|
855 | bee_user_t *bu = soap_req->data; |
---|
856 | struct msn_buddy_data *bd = bu->data; |
---|
857 | |
---|
858 | g_free(bd->cid); |
---|
859 | bd->cid = g_strdup(node->text); |
---|
860 | |
---|
861 | return XT_HANDLED; |
---|
862 | } |
---|
863 | |
---|
864 | static const struct xt_handler_entry msn_soap_ab_contact_add_parser[] = { |
---|
865 | { "guid", "ABContactAddResult", msn_soap_ab_contact_add_cid }, |
---|
866 | { NULL, NULL, NULL } |
---|
867 | }; |
---|
868 | |
---|
869 | static int msn_soap_ab_contact_add_handle_response(struct msn_soap_req_data *soap_req) |
---|
870 | { |
---|
871 | /* TODO: Ack the change? Not sure what the NAKs look like.. */ |
---|
872 | return MSN_SOAP_OK; |
---|
873 | } |
---|
874 | |
---|
875 | static int msn_soap_ab_contact_add_free_data(struct msn_soap_req_data *soap_req) |
---|
876 | { |
---|
877 | return 0; |
---|
878 | } |
---|
879 | |
---|
880 | int msn_soap_ab_contact_add(struct im_connection *ic, bee_user_t *bu) |
---|
881 | { |
---|
882 | return msn_soap_start(ic, bu, |
---|
883 | msn_soap_ab_contact_add_build_request, |
---|
884 | msn_soap_ab_contact_add_parser, |
---|
885 | msn_soap_ab_contact_add_handle_response, |
---|
886 | msn_soap_ab_contact_add_free_data); |
---|
887 | } |
---|
888 | |
---|
889 | /* Remove a contact. */ |
---|
890 | static int msn_soap_ab_contact_del_build_request(struct msn_soap_req_data *soap_req) |
---|
891 | { |
---|
892 | struct msn_data *md = soap_req->ic->proto_data; |
---|
893 | const char *cid = soap_req->data; |
---|
894 | |
---|
895 | soap_req->url = g_strdup(SOAP_ADDRESSBOOK_URL); |
---|
896 | soap_req->action = g_strdup(SOAP_AB_CONTACT_DEL_ACTION); |
---|
897 | soap_req->payload = msn_soap_abservice_build(SOAP_AB_CONTACT_DEL_PAYLOAD, |
---|
898 | "Timer", md->tokens[1], cid); |
---|
899 | |
---|
900 | return 1; |
---|
901 | } |
---|
902 | |
---|
903 | static int msn_soap_ab_contact_del_handle_response(struct msn_soap_req_data *soap_req) |
---|
904 | { |
---|
905 | /* TODO: Ack the change? Not sure what the NAKs look like.. */ |
---|
906 | return MSN_SOAP_OK; |
---|
907 | } |
---|
908 | |
---|
909 | static int msn_soap_ab_contact_del_free_data(struct msn_soap_req_data *soap_req) |
---|
910 | { |
---|
911 | g_free(soap_req->data); |
---|
912 | return 0; |
---|
913 | } |
---|
914 | |
---|
915 | int msn_soap_ab_contact_del(struct im_connection *ic, bee_user_t *bu) |
---|
916 | { |
---|
917 | struct msn_buddy_data *bd = bu->data; |
---|
918 | |
---|
919 | return msn_soap_start(ic, g_strdup(bd->cid), |
---|
920 | msn_soap_ab_contact_del_build_request, |
---|
921 | NULL, |
---|
922 | msn_soap_ab_contact_del_handle_response, |
---|
923 | msn_soap_ab_contact_del_free_data); |
---|
924 | } |
---|
925 | |
---|
926 | |
---|
927 | |
---|
928 | /* Storage stuff: Fetch profile. */ |
---|
929 | static int msn_soap_profile_get_build_request(struct msn_soap_req_data *soap_req) |
---|
930 | { |
---|
931 | struct msn_data *md = soap_req->ic->proto_data; |
---|
932 | |
---|
933 | soap_req->url = g_strdup(SOAP_STORAGE_URL); |
---|
934 | soap_req->action = g_strdup(SOAP_PROFILE_GET_ACTION); |
---|
935 | soap_req->payload = g_markup_printf_escaped(SOAP_PROFILE_GET_PAYLOAD, |
---|
936 | md->tokens[3], (char *) soap_req->data); |
---|
937 | |
---|
938 | return 1; |
---|
939 | } |
---|
940 | |
---|
941 | static xt_status msn_soap_profile_get_result(struct xt_node *node, gpointer data) |
---|
942 | { |
---|
943 | struct msn_soap_req_data *soap_req = data; |
---|
944 | struct im_connection *ic = soap_req->ic; |
---|
945 | struct msn_data *md = soap_req->ic->proto_data; |
---|
946 | struct xt_node *dn; |
---|
947 | |
---|
948 | if ((dn = xt_find_node(node->children, "DisplayName")) && dn->text) { |
---|
949 | set_t *set = set_find(&ic->acc->set, "display_name"); |
---|
950 | g_free(set->value); |
---|
951 | set->value = g_strdup(dn->text); |
---|
952 | |
---|
953 | md->flags |= MSN_GOT_PROFILE_DN; |
---|
954 | } |
---|
955 | |
---|
956 | return XT_HANDLED; |
---|
957 | } |
---|
958 | |
---|
959 | static xt_status msn_soap_profile_get_rid(struct xt_node *node, gpointer data) |
---|
960 | { |
---|
961 | struct msn_soap_req_data *soap_req = data; |
---|
962 | struct msn_data *md = soap_req->ic->proto_data; |
---|
963 | |
---|
964 | g_free(md->profile_rid); |
---|
965 | md->profile_rid = g_strdup(node->text); |
---|
966 | |
---|
967 | return XT_HANDLED; |
---|
968 | } |
---|
969 | |
---|
970 | static const struct xt_handler_entry msn_soap_profile_get_parser[] = { |
---|
971 | { "ExpressionProfile", "GetProfileResult", msn_soap_profile_get_result }, |
---|
972 | { "ResourceID", "GetProfileResult", msn_soap_profile_get_rid }, |
---|
973 | { NULL, NULL, NULL } |
---|
974 | }; |
---|
975 | |
---|
976 | static int msn_soap_profile_get_handle_response(struct msn_soap_req_data *soap_req) |
---|
977 | { |
---|
978 | struct msn_data *md = soap_req->ic->proto_data; |
---|
979 | |
---|
980 | md->flags |= MSN_GOT_PROFILE; |
---|
981 | msn_ns_finish_login(soap_req->ic); |
---|
982 | |
---|
983 | return MSN_SOAP_OK; |
---|
984 | } |
---|
985 | |
---|
986 | static int msn_soap_profile_get_free_data(struct msn_soap_req_data *soap_req) |
---|
987 | { |
---|
988 | g_free(soap_req->data); |
---|
989 | return 0; |
---|
990 | } |
---|
991 | |
---|
992 | int msn_soap_profile_get(struct im_connection *ic, const char *cid) |
---|
993 | { |
---|
994 | return msn_soap_start(ic, g_strdup(cid), |
---|
995 | msn_soap_profile_get_build_request, |
---|
996 | msn_soap_profile_get_parser, |
---|
997 | msn_soap_profile_get_handle_response, |
---|
998 | msn_soap_profile_get_free_data); |
---|
999 | } |
---|
1000 | |
---|
1001 | /* Update profile (display name). */ |
---|
1002 | static int msn_soap_profile_set_dn_build_request(struct msn_soap_req_data *soap_req) |
---|
1003 | { |
---|
1004 | struct msn_data *md = soap_req->ic->proto_data; |
---|
1005 | |
---|
1006 | soap_req->url = g_strdup(SOAP_STORAGE_URL); |
---|
1007 | soap_req->action = g_strdup(SOAP_PROFILE_SET_DN_ACTION); |
---|
1008 | soap_req->payload = g_markup_printf_escaped(SOAP_PROFILE_SET_DN_PAYLOAD, |
---|
1009 | md->tokens[3], md->profile_rid, (char *) soap_req->data); |
---|
1010 | |
---|
1011 | return 1; |
---|
1012 | } |
---|
1013 | |
---|
1014 | static const struct xt_handler_entry msn_soap_profile_set_dn_parser[] = { |
---|
1015 | { NULL, NULL, NULL } |
---|
1016 | }; |
---|
1017 | |
---|
1018 | static int msn_soap_profile_set_dn_handle_response(struct msn_soap_req_data *soap_req) |
---|
1019 | { |
---|
1020 | return MSN_SOAP_OK; |
---|
1021 | } |
---|
1022 | |
---|
1023 | static int msn_soap_profile_set_dn_free_data(struct msn_soap_req_data *soap_req) |
---|
1024 | { |
---|
1025 | g_free(soap_req->data); |
---|
1026 | return 0; |
---|
1027 | } |
---|
1028 | |
---|
1029 | int msn_soap_profile_set_dn(struct im_connection *ic, const char *dn) |
---|
1030 | { |
---|
1031 | return msn_soap_start(ic, g_strdup(dn), |
---|
1032 | msn_soap_profile_set_dn_build_request, |
---|
1033 | msn_soap_profile_set_dn_parser, |
---|
1034 | msn_soap_profile_set_dn_handle_response, |
---|
1035 | msn_soap_profile_set_dn_free_data); |
---|
1036 | } |
---|