Mercurial > pidgin
annotate src/protocols/jabber/si.c @ 8312:ba12d8b12ab0
[gaim-migrate @ 9036]
I think this is preliminary jabber file sending support. I can't test it
because the new network listening stuff is broken if you run both IPv4 and
IPv6. If someone with a more "normal" setup can let me know if this works,
I'd appreciate it. Note that it's not completely implemented yet, so sending
via a proxy server doesn't work, cancelling transfers doesn't work, error
handling isn't there, and it probably leaks memory. A sane person might even
wonder why I'm committing this. Oh well.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 21 Feb 2004 23:59:49 +0000 |
parents | b5dbd1839716 |
children | cf84056fed27 |
rev | line source |
---|---|
7395 | 1 /* |
2 * gaim - Jabber Protocol Plugin | |
3 * | |
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 #include "internal.h" | |
22 #include "debug.h" | |
23 #include "ft.h" | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8135
diff
changeset
|
24 #include "network.h" |
7395 | 25 #include "notify.h" |
8262 | 26 #include "sha.h" |
7395 | 27 #include "util.h" |
28 | |
29 #include "buddy.h" | |
8312 | 30 #include "disco.h" |
7395 | 31 #include "jabber.h" |
32 #include "iq.h" | |
33 #include "si.h" | |
34 | |
35 #include "si.h" | |
36 | |
8262 | 37 struct bytestreams_streamhost { |
38 char *jid; | |
39 char *host; | |
40 int port; | |
41 }; | |
42 | |
43 typedef struct _JabberSIXfer { | |
44 JabberStream *js; | |
45 | |
46 char *stream_id; | |
47 char *iq_id; | |
48 | |
49 enum { | |
50 STREAM_METHOD_UNKNOWN = 0, | |
51 STREAM_METHOD_BYTESTREAMS = 2 << 1, | |
52 STREAM_METHOD_IBB = 2 << 2, | |
53 STREAM_METHOD_UNSUPPORTED = 2 << 31 | |
54 } stream_method; | |
55 | |
56 GList *streamhosts; | |
57 GaimProxyInfo *gpi; | |
58 } JabberSIXfer; | |
59 | |
60 static GaimXfer* | |
61 jabber_si_xfer_find(JabberStream *js, const char *sid, const char *from) | |
7395 | 62 { |
63 GList *xfers; | |
64 | |
8262 | 65 if(!sid || !from) |
7395 | 66 return NULL; |
67 | |
68 for(xfers = js->file_transfers; xfers; xfers = xfers->next) { | |
69 GaimXfer *xfer = xfers->data; | |
70 JabberSIXfer *jsx = xfer->data; | |
8262 | 71 if(!strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from)) |
7395 | 72 return xfer; |
73 } | |
74 | |
75 return NULL; | |
76 } | |
77 | |
8262 | 78 |
79 static void jabber_si_bytestreams_attempt_connect(GaimXfer *xfer); | |
80 | |
81 static void jabber_si_bytestreams_connect_cb(gpointer data, gint source, GaimInputCondition cond) | |
82 { | |
7395 | 83 GaimXfer *xfer = data; |
84 JabberSIXfer *jsx = xfer->data; | |
8262 | 85 JabberIq *iq; |
86 xmlnode *query, *su; | |
87 struct bytestreams_streamhost *streamhost = jsx->streamhosts->data; | |
7395 | 88 |
8262 | 89 gaim_proxy_info_destroy(jsx->gpi); |
90 | |
91 if(source < 0) { | |
92 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); | |
93 g_free(streamhost->jid); | |
94 g_free(streamhost->host); | |
95 g_free(streamhost); | |
96 jabber_si_bytestreams_attempt_connect(xfer); | |
97 return; | |
98 } | |
99 | |
100 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, "http://jabber.org/protocol/bytestreams"); | |
101 xmlnode_set_attrib(iq->node, "to", xfer->who); | |
102 jabber_iq_set_id(iq, jsx->iq_id); | |
103 query = xmlnode_get_child(iq->node, "query"); | |
104 su = xmlnode_new_child(query, "streamhost-used"); | |
105 xmlnode_set_attrib(su, "jid", streamhost->jid); | |
106 | |
107 jabber_iq_send(iq); | |
108 | |
109 gaim_xfer_start(xfer, source, NULL, -1); | |
110 } | |
111 | |
112 static void jabber_si_bytestreams_attempt_connect(GaimXfer *xfer) | |
113 { | |
114 JabberSIXfer *jsx = xfer->data; | |
115 struct bytestreams_streamhost *streamhost; | |
116 char *dstaddr, *p; | |
117 int i; | |
118 unsigned char hashval[20]; | |
119 | |
120 if(!jsx->streamhosts) { | |
121 JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR); | |
122 xmlnode *error, *condition; | |
123 | |
124 if(jsx->iq_id) | |
125 jabber_iq_set_id(iq, jsx->iq_id); | |
126 | |
127 xmlnode_set_attrib(iq->node, "to", xfer->who); | |
128 error = xmlnode_new_child(iq->node, "error"); | |
129 xmlnode_set_attrib(error, "code", "404"); | |
130 xmlnode_set_attrib(error, "type", "cancel"); | |
131 condition = xmlnode_new_child(error, "condition"); | |
132 xmlnode_set_attrib(condition, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas"); | |
133 xmlnode_new_child(condition, "item-not-found"); | |
134 | |
135 jabber_iq_send(iq); | |
136 | |
137 gaim_xfer_cancel_local(xfer); | |
138 | |
139 return; | |
140 } | |
141 | |
142 streamhost = jsx->streamhosts->data; | |
7395 | 143 |
8262 | 144 jsx->gpi = gaim_proxy_info_new(); |
145 gaim_proxy_info_set_type(jsx->gpi, GAIM_PROXY_SOCKS5); | |
146 gaim_proxy_info_set_host(jsx->gpi, streamhost->host); | |
147 gaim_proxy_info_set_port(jsx->gpi, streamhost->port); | |
148 | |
149 dstaddr = g_strdup_printf("%s%s%s@%s/%s", jsx->stream_id, xfer->who, jsx->js->user->node, | |
150 jsx->js->user->domain, jsx->js->user->resource); | |
151 shaBlock((unsigned char *)dstaddr, strlen(dstaddr), hashval); | |
152 g_free(dstaddr); | |
153 dstaddr = g_malloc(41); | |
154 p = dstaddr; | |
155 for(i=0; i<20; i++, p+=2) | |
156 snprintf(p, 3, "%02x", hashval[i]); | |
157 | |
158 gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); | |
159 g_free(dstaddr); | |
160 } | |
161 | |
162 void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet) | |
163 { | |
164 GaimXfer *xfer; | |
165 JabberSIXfer *jsx; | |
166 xmlnode *query, *streamhost; | |
167 const char *sid, *from; | |
168 | |
169 if(!(from = xmlnode_get_attrib(packet, "from"))) | |
170 return; | |
171 | |
172 if(!(query = xmlnode_get_child(packet, "query"))) | |
173 return; | |
174 | |
175 if(!(sid = xmlnode_get_attrib(query, "sid"))) | |
176 return; | |
177 | |
178 if(!(xfer = jabber_si_xfer_find(js, sid, from))) | |
179 return; | |
180 | |
181 jsx = xfer->data; | |
182 if(jsx->iq_id) | |
183 g_free(jsx->iq_id); | |
184 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); | |
185 | |
186 for(streamhost = xmlnode_get_child(query, "streamhost"); streamhost; | |
187 streamhost = xmlnode_get_next_twin(streamhost)) { | |
188 const char *jid, *host, *port; | |
189 int portnum; | |
190 | |
191 if((jid = xmlnode_get_attrib(streamhost, "jid")) && | |
192 (host = xmlnode_get_attrib(streamhost, "host")) && | |
193 (port = xmlnode_get_attrib(streamhost, "port")) && | |
194 (portnum = atoi(port))) { | |
195 struct bytestreams_streamhost *sh = g_new0(struct bytestreams_streamhost, 1); | |
196 sh->jid = g_strdup(jid); | |
197 sh->host = g_strdup(host); | |
198 sh->port = portnum; | |
199 jsx->streamhosts = g_list_append(jsx->streamhosts, sh); | |
200 } | |
201 } | |
202 | |
203 jabber_si_bytestreams_attempt_connect(xfer); | |
7395 | 204 } |
205 | |
8312 | 206 static void |
207 jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source, | |
208 GaimInputCondition cond) | |
209 { | |
210 GaimXfer *xfer = data; | |
211 char ver, len, method; | |
212 int i; | |
213 char buf[2]; | |
214 | |
215 xfer->fd = source; | |
216 | |
217 read(source, &ver, 1); | |
218 | |
219 if(ver != 0x05) { | |
220 close(source); | |
221 gaim_xfer_cancel_remote(xfer); | |
222 return; | |
223 } | |
224 | |
225 read(source, &len, 1); | |
226 for(i=0; i<len; i++) { | |
227 read(source, &method, 1); | |
228 if(method == 0x00) { | |
229 buf[0] = 0x05; | |
230 buf[1] = 0x00; | |
231 write(source, buf, 2); | |
232 gaim_xfer_start(xfer, source, NULL, 0); | |
233 return; | |
234 } | |
235 } | |
236 | |
237 buf[0] = 0x05; | |
238 buf[1] = 0xFF; | |
239 write(source, buf, 2); | |
240 gaim_xfer_cancel_remote(xfer); | |
241 } | |
242 | |
243 static void | |
244 jabber_si_xfer_bytestreams_send_init(GaimXfer *xfer) | |
245 { | |
246 JabberSIXfer *jsx = xfer->data; | |
247 JabberIq *iq; | |
248 xmlnode *query, *streamhost; | |
249 char *jid, *port; | |
250 int fd; | |
251 | |
252 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, | |
253 "http://jabber.org/protocol/bytestreams"); | |
254 xmlnode_set_attrib(iq->node, "to", xfer->who); | |
255 query = xmlnode_get_child(iq->node, "query"); | |
256 | |
257 xmlnode_set_attrib(query, "sid", jsx->stream_id); | |
258 | |
259 streamhost = xmlnode_new_child(query, "streamhost"); | |
260 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource); | |
261 xmlnode_set_attrib(streamhost, "jid", jid); | |
262 g_free(jid); | |
263 | |
264 if((fd = gaim_network_listen_range(0, 0)) < 0) { | |
265 /* XXX: couldn't open a port, we're fscked */ | |
266 return; | |
267 } | |
268 | |
269 xmlnode_set_attrib(streamhost, "host", gaim_network_get_ip_for_account(jsx->js->gc->account, fd)); | |
270 xfer->local_port = gaim_network_get_port_from_fd(fd); | |
271 port = g_strdup_printf("%d", xfer->local_port); | |
272 xmlnode_set_attrib(streamhost, "port", port); | |
273 g_free(port); | |
274 | |
275 xfer->watcher = gaim_input_add(fd, GAIM_INPUT_READ, | |
276 jabber_si_xfer_bytestreams_send_connected_cb, xfer); | |
277 | |
278 /* XXX: insert proxies here */ | |
279 | |
280 /* XXX: callback to find out which streamhost they used, or see if they | |
281 * screwed it up */ | |
282 jabber_iq_send(iq); | |
283 } | |
284 | |
285 static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet, | |
286 gpointer data) | |
287 { | |
288 GaimXfer *xfer = data; | |
289 xmlnode *si, *feature, *x, *field, *value; | |
290 | |
291 if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) { | |
292 gaim_xfer_cancel_remote(xfer); | |
293 return; | |
294 } | |
295 | |
296 if(!(feature = xmlnode_get_child_with_namespace(si, "feature", "http://jabber.org/protocol/feature-neg"))) { | |
297 gaim_xfer_cancel_remote(xfer); | |
298 return; | |
299 } | |
300 | |
301 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) { | |
302 gaim_xfer_cancel_remote(xfer); | |
303 return; | |
304 } | |
305 | |
306 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { | |
307 const char *var = xmlnode_get_attrib(field, "var"); | |
308 | |
309 if(var && !strcmp(var, "stream-method")) { | |
310 if((value = xmlnode_get_child(field, "value"))) { | |
311 char *val = xmlnode_get_data(value); | |
312 if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) { | |
313 jabber_si_xfer_bytestreams_send_init(xfer); | |
314 g_free(val); | |
315 return; | |
316 } | |
317 g_free(val); | |
318 } | |
319 } | |
320 } | |
321 gaim_xfer_cancel_remote(xfer); | |
322 } | |
323 | |
324 static void jabber_si_xfer_send_request(GaimXfer *xfer) | |
325 { | |
326 JabberSIXfer *jsx = xfer->data; | |
327 JabberIq *iq; | |
328 xmlnode *si, *file, *feature, *x, *field, *option, *value; | |
329 char buf[32]; | |
330 | |
331 xfer->filename = g_path_get_basename(xfer->local_filename); | |
332 | |
333 iq = jabber_iq_new(jsx->js, JABBER_IQ_SET); | |
334 xmlnode_set_attrib(iq->node, "to", xfer->who); | |
335 si = xmlnode_new_child(iq->node, "si"); | |
336 xmlnode_set_attrib(si, "xmlns", "http://jabber.org/protocol/si"); | |
337 jsx->stream_id = jabber_get_next_id(jsx->js); | |
338 xmlnode_set_attrib(si, "id", jsx->stream_id); | |
339 xmlnode_set_attrib(si, "profile", | |
340 "http://jabber.org/protocol/si/profile/file-transfer"); | |
341 | |
342 file = xmlnode_new_child(si, "file"); | |
343 xmlnode_set_attrib(file, "xmlns", | |
344 "http://jabber.org/protocol/si/profile/file-transfer"); | |
345 xmlnode_set_attrib(file, "name", xfer->filename); | |
346 g_snprintf(buf, sizeof(buf), "%d", xfer->size); | |
347 xmlnode_set_attrib(file, "size", buf); | |
348 /* maybe later we'll do hash and date attribs */ | |
349 | |
350 feature = xmlnode_new_child(si, "feature"); | |
351 xmlnode_set_attrib(feature, "xmlns", | |
352 "http://jabber.org/protocol/feature-neg"); | |
353 x = xmlnode_new_child(feature, "x"); | |
354 xmlnode_set_attrib(x, "xmlns", "jabber:x:data"); | |
355 xmlnode_set_attrib(x, "type", "form"); | |
356 field = xmlnode_new_child(x, "field"); | |
357 xmlnode_set_attrib(field, "var", "stream-method"); | |
358 xmlnode_set_attrib(field, "type", "list-single"); | |
359 option = xmlnode_new_child(field, "option"); | |
360 value = xmlnode_new_child(option, "value"); | |
361 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", | |
362 -1); | |
363 /* | |
364 option = xmlnode_new_child(field, "option"); | |
365 value = xmlnode_new_child(option, "value"); | |
366 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); | |
367 */ | |
368 | |
369 jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer); | |
370 | |
371 jabber_iq_send(iq); | |
372 } | |
373 | |
374 void jabber_si_xfer_cancel_send(GaimXfer *xfer) | |
375 { | |
376 gaim_debug(GAIM_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_send\n"); | |
377 } | |
378 | |
379 | |
380 void jabber_si_xfer_cancel_recv(GaimXfer *xfer) | |
381 { | |
382 gaim_debug(GAIM_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_recv\n"); | |
383 } | |
384 | |
385 | |
386 static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who, | |
387 JabberCapabilities capabilities, gpointer data) | |
388 { | |
389 GaimXfer *xfer = data; | |
390 | |
391 if(capabilities & JABBER_CAP_SI_FILE_XFER) { | |
392 jabber_si_xfer_send_request(xfer); | |
393 } else { | |
394 char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who); | |
395 gaim_notify_error(js->gc, _("File Send Failed"), | |
396 _("File Send Failed"), msg); | |
397 g_free(msg); | |
398 } | |
399 } | |
400 | |
8262 | 401 static void jabber_si_xfer_init(GaimXfer *xfer) |
402 { | |
403 JabberSIXfer *jsx = xfer->data; | |
404 JabberIq *iq; | |
8312 | 405 if(gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { |
406 JabberBuddy *jb; | |
407 JabberBuddyResource *jbr = NULL; | |
408 | |
409 jb = jabber_buddy_find(jsx->js, xfer->who, TRUE); | |
410 /* XXX */ | |
411 if(!jb) | |
412 return; | |
8262 | 413 |
8312 | 414 /* XXX: for now, send to the first resource available */ |
415 if(g_list_length(jb->resources) >= 1) { | |
416 char *who; | |
417 jbr = jb->resources->data; | |
418 who = g_strdup_printf("%s/%s", xfer->who, jbr->name); | |
419 g_free(xfer->who); | |
420 xfer->who = who; | |
421 jabber_disco_info_do(jsx->js, who, | |
422 jabber_si_xfer_send_disco_cb, xfer); | |
423 } else { | |
424 return; /* XXX: ick */ | |
425 } | |
426 } else { | |
427 xmlnode *si, *feature, *x, *field, *value; | |
8262 | 428 |
8312 | 429 iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT); |
430 xmlnode_set_attrib(iq->node, "to", xfer->who); | |
431 if(jsx->iq_id) | |
432 jabber_iq_set_id(iq, jsx->iq_id); | |
433 | |
434 si = xmlnode_new_child(iq->node, "si"); | |
435 xmlnode_set_attrib(si, "xmlns", "http://jabber.org/protocol/si"); | |
436 | |
437 feature = xmlnode_new_child(si, "feature"); | |
438 xmlnode_set_attrib(feature, "xmlns", "http://jabber.org/protocol/feature-neg"); | |
8262 | 439 |
8312 | 440 x = xmlnode_new_child(feature, "x"); |
441 xmlnode_set_attrib(x, "xmlns", "jabber:x:data"); | |
442 xmlnode_set_attrib(x, "type", "form"); | |
8262 | 443 |
8312 | 444 field = xmlnode_new_child(x, "field"); |
445 xmlnode_set_attrib(field, "var", "stream-method"); | |
446 | |
447 value = xmlnode_new_child(field, "value"); | |
448 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) | |
449 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1); | |
450 /* | |
451 else if(jsx->stream_method & STREAM_METHOD_IBB) | |
8262 | 452 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); |
453 */ | |
454 | |
8312 | 455 jabber_iq_send(iq); |
456 } | |
8262 | 457 } |
458 | |
8312 | 459 void jabber_si_xfer_ask_send(GaimConnection *gc, const char *name) |
460 { | |
461 JabberStream *js = gc->proto_data; | |
462 GaimXfer *xfer; | |
463 JabberSIXfer *jsx; | |
464 | |
465 if(!gaim_find_buddy(gc->account, name) || !jabber_buddy_find(js, name, FALSE)) | |
466 return; | |
467 | |
468 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, name); | |
8262 | 469 |
8312 | 470 xfer->data = jsx = g_new0(JabberSIXfer, 1); |
471 jsx->js = js; | |
8262 | 472 |
8312 | 473 gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); |
474 gaim_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send); | |
475 | |
476 js->file_transfers = g_list_append(js->file_transfers, xfer); | |
477 | |
478 gaim_xfer_request(xfer); | |
8262 | 479 } |
480 | |
481 void jabber_si_parse(JabberStream *js, xmlnode *packet) | |
482 { | |
483 JabberSIXfer *jsx; | |
484 GaimXfer *xfer; | |
485 xmlnode *si, *file, *feature, *x, *field, *option, *value; | |
486 const char *stream_id, *filename, *filesize_c, *profile; | |
487 size_t filesize = 0; | |
488 | |
489 if(!(si = xmlnode_get_child(packet, "si"))) | |
490 return; | |
491 | |
492 if(!(profile = xmlnode_get_attrib(si, "profile")) || | |
493 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer")) | |
494 return; | |
495 | |
496 if(!(stream_id = xmlnode_get_attrib(si, "id"))) | |
497 return; | |
498 | |
499 if(!(file = xmlnode_get_child(si, "file"))) | |
500 return; | |
501 | |
502 if(!(filename = xmlnode_get_attrib(file, "name"))) | |
503 return; | |
504 | |
505 if((filesize_c = xmlnode_get_attrib(file, "size"))) | |
506 filesize = atoi(filesize_c); | |
507 | |
508 if(!(feature = xmlnode_get_child(si, "feature"))) | |
509 return; | |
510 | |
511 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) | |
512 return; | |
513 | |
514 jsx = g_new0(JabberSIXfer, 1); | |
515 | |
516 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { | |
517 const char *var = xmlnode_get_attrib(field, "var"); | |
518 if(var && !strcmp(var, "stream-method")) { | |
519 for(option = xmlnode_get_child(field, "option"); option; | |
520 option = xmlnode_get_next_twin(option)) { | |
521 if((value = xmlnode_get_child(option, "value"))) { | |
522 char *val; | |
523 if((val = xmlnode_get_data(value))) { | |
524 if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) { | |
525 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; | |
526 /* | |
527 } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) { | |
528 jsx->stream_method |= STREAM_METHOD_IBB; | |
529 */ | |
530 } | |
531 g_free(val); | |
532 } | |
533 } | |
534 } | |
535 } | |
536 } | |
537 | |
538 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) { | |
539 g_free(jsx); | |
540 return; | |
541 } | |
542 | |
543 jsx->js = js; | |
544 jsx->stream_id = g_strdup(stream_id); | |
545 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); | |
546 | |
547 xfer = gaim_xfer_new(js->gc->account, GAIM_XFER_RECEIVE, | |
548 xmlnode_get_attrib(packet, "from")); | |
549 xfer->data = jsx; | |
550 | |
551 gaim_xfer_set_filename(xfer, filename); | |
552 if(filesize > 0) | |
553 gaim_xfer_set_size(xfer, filesize); | |
554 | |
555 gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init); | |
556 | |
557 js->file_transfers = g_list_append(js->file_transfers, xfer); | |
558 | |
559 gaim_xfer_request(xfer); | |
560 } | |
561 | |
7395 | 562 |