Mercurial > pidgin
comparison libpurple/protocols/bonjour/jabber.c @ 21806:41959f031322
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 10 Dec 2007 03:50:58 +0000 |
parents | d01d9107f263 |
children | 509871e4f61c |
comparison
equal
deleted
inserted
replaced
21804:fb73a6ed8197 | 21806:41959f031322 |
---|---|
237 struct _check_buddy_by_address_t *cbba = data; | 237 struct _check_buddy_by_address_t *cbba = data; |
238 | 238 |
239 /* | 239 /* |
240 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account | 240 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account |
241 * is the same as the account requesting the check then continue to determine | 241 * is the same as the account requesting the check then continue to determine |
242 * whether the buddies IP matches the target IP. | 242 * whether one of the buddies IPs matches the target IP. |
243 */ | 243 */ |
244 if (cbba->bj->account == pb->account) | 244 if (cbba->bj->account == pb->account) |
245 { | 245 { |
246 bb = pb->proto_data; | 246 bb = pb->proto_data; |
247 if ((bb != NULL) && (g_ascii_strcasecmp(bb->ip, cbba->address) == 0)) | 247 if (bb != NULL) { |
248 *(cbba->pb) = pb; | 248 const char *ip; |
249 GSList *tmp = bb->ips; | |
250 | |
251 while(tmp) { | |
252 ip = tmp->data; | |
253 if (ip != NULL && g_ascii_strcasecmp(ip, cbba->address) == 0) { | |
254 *(cbba->pb) = pb; | |
255 break; | |
256 } | |
257 tmp = tmp->next; | |
258 } | |
259 } | |
249 } | 260 } |
250 } | 261 } |
251 | 262 |
252 static void | 263 static void |
253 _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond) | 264 _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond) |
447 if (ret == -1 && errno == EAGAIN) | 458 if (ret == -1 && errno == EAGAIN) |
448 return; | 459 return; |
449 else if (ret <= 0) { | 460 else if (ret <= 0) { |
450 const char *err = g_strerror(errno); | 461 const char *err = g_strerror(errno); |
451 PurpleConversation *conv; | 462 PurpleConversation *conv; |
463 const char *ip = NULL; | |
464 | |
465 /* For better or worse, use the first IP*/ | |
466 if (bb->ips) | |
467 ip = bb->ips->data; | |
452 | 468 |
453 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", | 469 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", |
454 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); | 470 purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); |
455 | 471 |
456 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); | 472 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); |
457 if (conv != NULL) | 473 if (conv != NULL) |
458 purple_conversation_write(conv, NULL, | 474 purple_conversation_write(conv, NULL, |
459 _("Unable to send the message, the conversation couldn't be started."), | 475 _("Unable to send the message, the conversation couldn't be started."), |
502 | 518 |
503 if (ret == -1 && errno == EAGAIN) | 519 if (ret == -1 && errno == EAGAIN) |
504 ret = 0; | 520 ret = 0; |
505 else if (ret <= 0) { | 521 else if (ret <= 0) { |
506 const char *err = g_strerror(errno); | 522 const char *err = g_strerror(errno); |
523 const char *ip = NULL; | |
524 | |
525 /* For better or worse, use the first IP*/ | |
526 if (bb->ips) | |
527 ip = bb->ips->data; | |
507 | 528 |
508 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", | 529 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", |
509 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); | 530 purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); |
510 | 531 |
511 close(client_socket); | 532 close(client_socket); |
512 g_free(stream_start); | 533 g_free(stream_start); |
513 | 534 |
514 return FALSE; | 535 return FALSE; |
542 BonjourJabberConversation *bconv = bb->conversation; | 563 BonjourJabberConversation *bconv = bb->conversation; |
543 | 564 |
544 if (bconv->sent_stream_start == NOT_SENT && !bonjour_jabber_send_stream_init(pb, bconv->socket)) { | 565 if (bconv->sent_stream_start == NOT_SENT && !bonjour_jabber_send_stream_init(pb, bconv->socket)) { |
545 const char *err = g_strerror(errno); | 566 const char *err = g_strerror(errno); |
546 PurpleConversation *conv; | 567 PurpleConversation *conv; |
568 const char *ip = NULL; | |
569 | |
570 /* For better or worse, use the first IP*/ | |
571 if (bb->ips) | |
572 ip = bb->ips->data; | |
547 | 573 |
548 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", | 574 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", |
549 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); | 575 purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); |
550 | 576 |
551 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); | 577 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); |
552 if (conv != NULL) | 578 if (conv != NULL) |
553 purple_conversation_write(conv, NULL, | 579 purple_conversation_write(conv, NULL, |
554 _("Unable to send the message, the conversation couldn't be started."), | 580 _("Unable to send the message, the conversation couldn't be started."), |
719 | 745 |
720 bb->conversation->connect_data = NULL; | 746 bb->conversation->connect_data = NULL; |
721 | 747 |
722 if (source < 0) { | 748 if (source < 0) { |
723 PurpleConversation *conv; | 749 PurpleConversation *conv; |
750 const char *ip = NULL; | |
751 | |
752 /* For better or worse, use the first IP*/ | |
753 if (bb->ips) | |
754 ip = bb->ips->data; | |
724 | 755 |
725 purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n", | 756 purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n", |
726 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, error ? error : "(null)"); | 757 purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, error ? error : "(null)"); |
727 | 758 |
728 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); | 759 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); |
729 if (conv != NULL) | 760 if (conv != NULL) |
730 purple_conversation_write(conv, NULL, | 761 purple_conversation_write(conv, NULL, |
731 _("Unable to send the message, the conversation couldn't be started."), | 762 _("Unable to send the message, the conversation couldn't be started."), |
737 } | 768 } |
738 | 769 |
739 if (!bonjour_jabber_send_stream_init(pb, source)) { | 770 if (!bonjour_jabber_send_stream_init(pb, source)) { |
740 const char *err = g_strerror(errno); | 771 const char *err = g_strerror(errno); |
741 PurpleConversation *conv; | 772 PurpleConversation *conv; |
773 const char *ip = NULL; | |
774 | |
775 /* For better or worse, use the first IP*/ | |
776 if (bb->ips) | |
777 ip = bb->ips->data; | |
742 | 778 |
743 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", | 779 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", |
744 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); | 780 purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); |
745 | 781 |
746 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); | 782 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); |
747 if (conv != NULL) | 783 if (conv != NULL) |
748 purple_conversation_write(conv, NULL, | 784 purple_conversation_write(conv, NULL, |
749 _("Unable to send the message, the conversation couldn't be started."), | 785 _("Unable to send the message, the conversation couldn't be started."), |
780 /* Check if there is a previously open conversation */ | 816 /* Check if there is a previously open conversation */ |
781 if (bb->conversation == NULL) | 817 if (bb->conversation == NULL) |
782 { | 818 { |
783 PurpleProxyConnectData *connect_data; | 819 PurpleProxyConnectData *connect_data; |
784 PurpleProxyInfo *proxy_info; | 820 PurpleProxyInfo *proxy_info; |
821 const char *ip = NULL; | |
822 | |
823 /* For better or worse, use the first IP*/ | |
824 if (bb->ips) | |
825 ip = bb->ips->data; | |
785 | 826 |
786 purple_debug_info("bonjour", "Starting conversation with %s\n", to); | 827 purple_debug_info("bonjour", "Starting conversation with %s\n", to); |
787 | 828 |
788 /* Make sure that the account always has a proxy of "none". | 829 /* Make sure that the account always has a proxy of "none". |
789 * This is kind of dirty, but proxy_connect_none() isn't exposed. */ | 830 * This is kind of dirty, but proxy_connect_none() isn't exposed. */ |
793 purple_account_set_proxy_info(data->account, proxy_info); | 834 purple_account_set_proxy_info(data->account, proxy_info); |
794 } | 835 } |
795 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE); | 836 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE); |
796 | 837 |
797 connect_data = purple_proxy_connect(NULL, data->account, | 838 connect_data = purple_proxy_connect(NULL, data->account, |
798 bb->ip, bb->port_p2pj, _connected_to_buddy, pb); | 839 ip, bb->port_p2pj, _connected_to_buddy, pb); |
799 | 840 |
800 if (connect_data == NULL) { | 841 if (connect_data == NULL) { |
801 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); | 842 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); |
802 return NULL; | 843 return NULL; |
803 } | 844 } |