Mercurial > pidgin
comparison src/protocols/bonjour/jabber.c @ 11693:b91a84e7cbcb
[gaim-migrate @ 13979]
Don't crash on bonjour when IMing a non-existant user. Also better
error reporting, I think.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 18 Oct 2005 04:16:44 +0000 |
parents | 1fd2a974379f |
children | 27ed05facc71 |
comparison
equal
deleted
inserted
replaced
11692:969fb599cc1b | 11693:b91a84e7cbcb |
---|---|
493 data->watcher_id = gaim_input_add(data->socket, GAIM_INPUT_READ, _server_socket_handler, data); | 493 data->watcher_id = gaim_input_add(data->socket, GAIM_INPUT_READ, _server_socket_handler, data); |
494 | 494 |
495 return 0; | 495 return 0; |
496 } | 496 } |
497 | 497 |
498 void | 498 int |
499 bonjour_jabber_send_message(BonjourJabber *data, const gchar *to, const gchar *body) | 499 bonjour_jabber_send_message(BonjourJabber *data, const gchar *to, const gchar *body) |
500 { | 500 { |
501 xmlnode *message_node = NULL; | 501 xmlnode *message_node = NULL; |
502 gchar *message = NULL; | 502 gchar *message = NULL; |
503 gint message_length = -1; | 503 gint message_length = -1; |
504 xmlnode *message_body_node = NULL; | 504 xmlnode *message_body_node = NULL; |
505 xmlnode *message_html_node = NULL; | 505 xmlnode *message_html_node = NULL; |
506 xmlnode *message_html_body_node = NULL; | 506 xmlnode *message_html_body_node = NULL; |
507 xmlnode *message_html_body_font_node = NULL; | 507 xmlnode *message_html_body_font_node = NULL; |
508 xmlnode *message_x_node = NULL; | 508 xmlnode *message_x_node = NULL; |
509 GaimBuddy *gb = gaim_find_buddy(data->account, to); | 509 GaimBuddy *gb = NULL; |
510 BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data; | 510 BonjourBuddy *bb = NULL; |
511 char *conv_message = NULL; | 511 char *conv_message = NULL; |
512 GaimConversation *conversation = NULL; | 512 GaimConversation *conversation = NULL; |
513 char *message_from_ui = NULL; | 513 char *message_from_ui = NULL; |
514 char *stripped_message = NULL; | 514 char *stripped_message = NULL; |
515 | |
516 gb = gaim_find_buddy(data->account, to); | |
517 if (gb == NULL) | |
518 /* You can not send a message to an offline buddy */ | |
519 return -10000; | |
520 | |
521 bb = (BonjourBuddy *)gb->proto_data; | |
515 | 522 |
516 // Enclose the message from the UI within a "font" node | 523 // Enclose the message from the UI within a "font" node |
517 message_body_node = xmlnode_new("body"); | 524 message_body_node = xmlnode_new("body"); |
518 stripped_message = gaim_markup_strip_html(body); | 525 stripped_message = gaim_markup_strip_html(body); |
519 xmlnode_insert_data(message_body_node, stripped_message, strlen(stripped_message)); | 526 xmlnode_insert_data(message_body_node, stripped_message, strlen(stripped_message)); |
570 | 577 |
571 // Free all the data related to the conversation | 578 // Free all the data related to the conversation |
572 g_free(bb->conversation->buddy_name); | 579 g_free(bb->conversation->buddy_name); |
573 g_free(bb->conversation); | 580 g_free(bb->conversation); |
574 bb->conversation = NULL; | 581 bb->conversation = NULL; |
575 return; | 582 return 0; |
576 } | 583 } |
577 | 584 |
578 bb->conversation->stream_started = TRUE; | 585 bb->conversation->stream_started = TRUE; |
579 } | 586 } |
580 | 587 |
581 // Send the message | 588 // Send the message |
582 if (_send_data(bb->conversation->socket, message) == -1) | 589 if (_send_data(bb->conversation->socket, message) == -1) |
583 { | 590 return -10000; |
584 gaim_debug_error("bonjour", "Unable to send the message\n"); | 591 |
585 conv_message = g_strdup("Unable to send the message."); | 592 return 1; |
586 conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, bb->name, data->account); | |
587 gaim_conversation_write(conversation, NULL, conv_message, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
588 } | |
589 } | 593 } |
590 | 594 |
591 void | 595 void |
592 bonjour_jabber_close_conversation(BonjourJabber *data, GaimBuddy *gb) | 596 bonjour_jabber_close_conversation(BonjourJabber *data, GaimBuddy *gb) |
593 { | 597 { |