# HG changeset patch # User Daniel Atallah # Date 1186626603 0 # Node ID 32a44f7e9c52ee4c92604ed2edc0ceeb92aa150b # Parent a53992a4437aaf628992e0c2cfbce87f243e2ec5# Parent 2bf2bd713955506dda322ecb16fe60209fe5a26e merge of '27e06af9a3657aa4d9664c8f17f3aee8ebc41e65' and '7a479398307e3af8d16c684697d3ec93cd8e491c' diff -r 2bf2bd713955 -r 32a44f7e9c52 libpurple/protocols/bonjour/mdns_avahi.c --- a/libpurple/protocols/bonjour/mdns_avahi.c Thu Aug 09 02:17:18 2007 +0000 +++ b/libpurple/protocols/bonjour/mdns_avahi.c Thu Aug 09 02:30:03 2007 +0000 @@ -19,6 +19,7 @@ #include "mdns_interface.h" #include "debug.h" #include "buddy.h" +#include "bonjour.h" #include #include @@ -32,6 +33,11 @@ #include #include +/* For some reason, this is missing from the Avahi type defines */ +#ifndef AVAHI_DNS_TYPE_NULL +#define AVAHI_DNS_TYPE_NULL 0x0A +#endif + /* data used by avahi bonjour implementation */ typedef struct _avahi_session_impl_data { AvahiClient *client; @@ -40,6 +46,10 @@ AvahiEntryGroup *group; } AvahiSessionImplData; +typedef struct _avahi_buddy_impl_data { + AvahiRecordBrowser *record_browser; +} AvahiBuddyImplData; + static void _resolver_callback(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, @@ -170,6 +180,20 @@ } +static void +_buddy_icon_record_cb(AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, + AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type, + const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata) { + BonjourBuddy *buddy = userdata; + AvahiBuddyImplData *idata = buddy->mdns_impl_data; + + purple_buddy_icons_set_for_user(buddy->account, buddy->name, + g_memdup(rdata, size), size, buddy->phsh); + + avahi_record_browser_free(idata->record_browser); + idata->record_browser = NULL; +} + /**************************** * mdns_interface functions * ****************************/ @@ -339,10 +363,45 @@ } void _mdns_init_buddy(BonjourBuddy *buddy) { + buddy->mdns_impl_data = g_new0(AvahiBuddyImplData, 1); } void _mdns_delete_buddy(BonjourBuddy *buddy) { + AvahiBuddyImplData *idata = buddy->mdns_impl_data; + + g_return_if_fail(idata != NULL); + + if (idata->record_browser != NULL) + avahi_record_browser_free(idata->record_browser); + + g_free(idata); + + buddy->mdns_impl_data = NULL; } void _mdns_retrieve_retrieve_buddy_icon(BonjourBuddy* buddy) { + PurpleConnection *conn = purple_account_get_connection(buddy->account); + BonjourData *bd = conn->proto_data; + AvahiSessionImplData *session_idata = bd->dns_sd_data->mdns_impl_data; + AvahiBuddyImplData *idata = buddy->mdns_impl_data; + gchar *name; + + g_return_if_fail(idata != NULL); + + if (idata->record_browser != NULL) + avahi_record_browser_free(idata->record_browser); + + name = g_strdup_printf("%s." ICHAT_SERVICE "local", buddy->name); + idata->record_browser = avahi_record_browser_new(session_idata->client, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 0, + _buddy_icon_record_cb, buddy); + g_free(name); + + if (!idata->record_browser) { + purple_debug_error("bonjour", + "Unable to initialize record browser. Error: %s\n.", + avahi_strerror(avahi_client_errno(session_idata->client))); } + +} + diff -r 2bf2bd713955 -r 32a44f7e9c52 libpurple/protocols/oscar/family_chat.c diff -r 2bf2bd713955 -r 32a44f7e9c52 pidgin/gtkcellrendererexpander.c