Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jabber.c @ 25608:a03a953ba63d
* moving BOSH interfacing from jabber_send to jabber_send_raw
* sending BOSH stream restart after successful SASL login
author | Tobias Markmann <tfar@soc.pidgin.im> |
---|---|
date | Fri, 15 Aug 2008 16:35:32 +0000 |
parents | f775f6021654 |
children | 907ca9a36fe0 |
comparison
equal
deleted
inserted
replaced
25607:f775f6021654 | 25608:a03a953ba63d |
---|---|
344 #endif | 344 #endif |
345 | 345 |
346 if (len == -1) | 346 if (len == -1) |
347 len = strlen(data); | 347 len = strlen(data); |
348 | 348 |
349 if (js->writeh == 0) | 349 if (js->use_bosh) { |
350 ret = jabber_do_send(js, data, len); | 350 xmlnode *xnode = xmlnode_from_str(data, len); |
351 else { | 351 if (xnode) jabber_bosh_connection_send(&(js->bosh), xnode); |
352 ret = -1; | 352 else { |
353 errno = EAGAIN; | 353 purple_connection_error_reason(js->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
354 } | 354 _("Someone tried to send non-XML in a Jabber world.")); |
355 | 355 } |
356 if (ret < 0 && errno != EAGAIN) | 356 } else { |
357 purple_connection_error_reason (js->gc, | |
358 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
359 _("Write error")); | |
360 else if (ret < len) { | |
361 if (ret < 0) | |
362 ret = 0; | |
363 if (js->writeh == 0) | 357 if (js->writeh == 0) |
364 js->writeh = purple_input_add( | 358 ret = jabber_do_send(js, data, len); |
365 js->gsc ? js->gsc->fd : js->fd, | 359 else { |
366 PURPLE_INPUT_WRITE, jabber_send_cb, js); | 360 ret = -1; |
367 purple_circ_buffer_append(js->write_buffer, | 361 errno = EAGAIN; |
368 data + ret, len - ret); | 362 } |
363 | |
364 if (ret < 0 && errno != EAGAIN) | |
365 purple_connection_error_reason (js->gc, | |
366 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
367 _("Write error")); | |
368 else if (ret < len) { | |
369 if (ret < 0) | |
370 ret = 0; | |
371 if (js->writeh == 0) | |
372 js->writeh = purple_input_add( | |
373 js->gsc ? js->gsc->fd : js->fd, | |
374 PURPLE_INPUT_WRITE, jabber_send_cb, js); | |
375 purple_circ_buffer_append(js->write_buffer, | |
376 data + ret, len - ret); | |
377 } | |
369 } | 378 } |
370 return; | 379 return; |
371 } | 380 } |
372 | 381 |
373 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) | 382 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) |
386 | 395 |
387 /* if we get NULL back, we're done processing */ | 396 /* if we get NULL back, we're done processing */ |
388 if(NULL == packet) | 397 if(NULL == packet) |
389 return; | 398 return; |
390 | 399 |
391 if (js->use_bosh) { | 400 txt = xmlnode_to_str(packet, &len); |
392 jabber_bosh_connection_send(&(js->bosh), packet); | 401 jabber_send_raw(js, txt, len); |
393 } else { | 402 g_free(txt); |
394 txt = xmlnode_to_str(packet, &len); | |
395 jabber_send_raw(js, txt, len); | |
396 g_free(txt); | |
397 } | |
398 } | 403 } |
399 | 404 |
400 static void jabber_pong_cb(JabberStream *js, xmlnode *packet, gpointer timeout) | 405 static void jabber_pong_cb(JabberStream *js, xmlnode *packet, gpointer timeout) |
401 { | 406 { |
402 purple_timeout_remove(GPOINTER_TO_INT(timeout)); | 407 purple_timeout_remove(GPOINTER_TO_INT(timeout)); |