diff libpurple/protocols/bonjour/mdns_avahi.c @ 31018:9c8b28dc6656

The hostname used for a bonjour account should always be the current machine name. This fixes our behavior so the previous statement is always the case. Unfortunately, this means that if the hostname was previously not the current machine name, the bonjour jid ends up looking like "username\40otherhost@hostname". Fixes #12674
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 04 Oct 2010 00:48:25 +0000
parents fcb8fad4f029
children e895aebcb504
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/mdns_avahi.c	Mon Oct 04 00:35:26 2010 +0000
+++ b/libpurple/protocols/bonjour/mdns_avahi.c	Mon Oct 04 00:48:25 2010 +0000
@@ -252,7 +252,7 @@
 			/* A new peer has joined the network and uses iChat bonjour */
 			purple_debug_info("bonjour", "_browser_callback - new service\n");
 			/* Make sure it isn't us */
-			if (purple_utf8_strcasecmp(name, account->username) != 0) {
+			if (purple_utf8_strcasecmp(name, bonjour_get_jid(account)) != 0) {
 				if (!avahi_service_resolver_new(avahi_service_browser_get_client(b),
 						interface, protocol, name, type, domain, protocol,
 						0, _resolver_callback, account)) {
@@ -421,6 +421,8 @@
 
 	data->mdns_impl_data = idata;
 
+	bonjour_dns_sd_set_jid(data->account, avahi_client_get_host_name(idata->client));
+
 	return TRUE;
 }
 
@@ -454,14 +456,14 @@
 			publish_result = avahi_entry_group_add_service_strlst(
 				idata->group, AVAHI_IF_UNSPEC,
 				AVAHI_PROTO_UNSPEC, 0,
-				purple_account_get_username(data->account),
+				bonjour_get_jid(data->account),
 				LINK_LOCAL_RECORD_NAME, NULL, NULL, data->port_p2pj, lst);
 			break;
 		case PUBLISH_UPDATE:
 			publish_result = avahi_entry_group_update_service_txt_strlst(
 				idata->group, AVAHI_IF_UNSPEC,
 				AVAHI_PROTO_UNSPEC, 0,
-				purple_account_get_username(data->account),
+				bonjour_get_jid(data->account),
 				LINK_LOCAL_RECORD_NAME, NULL, lst);
 			break;
 	}
@@ -535,7 +537,7 @@
 		}
 
 		svc_name = g_strdup_printf("%s." LINK_LOCAL_RECORD_NAME "local",
-				purple_account_get_username(data->account));
+				bonjour_get_jid(data->account));
 
 		ret = avahi_entry_group_add_record(idata->buddy_icon_group, AVAHI_IF_UNSPEC,
 			AVAHI_PROTO_UNSPEC, flags, svc_name,