Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c Mon Dec 10 02:19:56 2007 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Mon Dec 10 03:50:58 2007 +0000 @@ -239,13 +239,24 @@ /* * If the current PurpleBuddy's data is not null and the PurpleBuddy's account * is the same as the account requesting the check then continue to determine - * whether the buddies IP matches the target IP. + * whether one of the buddies IPs matches the target IP. */ if (cbba->bj->account == pb->account) { bb = pb->proto_data; - if ((bb != NULL) && (g_ascii_strcasecmp(bb->ip, cbba->address) == 0)) - *(cbba->pb) = pb; + if (bb != NULL) { + const char *ip; + GSList *tmp = bb->ips; + + while(tmp) { + ip = tmp->data; + if (ip != NULL && g_ascii_strcasecmp(ip, cbba->address) == 0) { + *(cbba->pb) = pb; + break; + } + tmp = tmp->next; + } + } } } @@ -449,9 +460,14 @@ else if (ret <= 0) { const char *err = g_strerror(errno); PurpleConversation *conv; + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); + purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); if (conv != NULL) @@ -504,9 +520,14 @@ ret = 0; else if (ret <= 0) { const char *err = g_strerror(errno); + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); + purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); close(client_socket); g_free(stream_start); @@ -544,9 +565,14 @@ if (bconv->sent_stream_start == NOT_SENT && !bonjour_jabber_send_stream_init(pb, bconv->socket)) { const char *err = g_strerror(errno); PurpleConversation *conv; + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); + purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); if (conv != NULL) @@ -721,9 +747,14 @@ if (source < 0) { PurpleConversation *conv; + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, error ? error : "(null)"); + purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, error ? error : "(null)"); conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); if (conv != NULL) @@ -739,9 +770,14 @@ if (!bonjour_jabber_send_stream_init(pb, source)) { const char *err = g_strerror(errno); PurpleConversation *conv; + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)"); + purple_buddy_get_name(pb), ip ? ip : "(null)", bb->port_p2pj, err ? err : "(null)"); conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account); if (conv != NULL) @@ -782,6 +818,11 @@ { PurpleProxyConnectData *connect_data; PurpleProxyInfo *proxy_info; + const char *ip = NULL; + + /* For better or worse, use the first IP*/ + if (bb->ips) + ip = bb->ips->data; purple_debug_info("bonjour", "Starting conversation with %s\n", to); @@ -795,7 +836,7 @@ purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE); connect_data = purple_proxy_connect(NULL, data->account, - bb->ip, bb->port_p2pj, _connected_to_buddy, pb); + ip, bb->port_p2pj, _connected_to_buddy, pb); if (connect_data == NULL) { purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to);