Index: libgnomevfs/gnome-vfs-dns-sd.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-dns-sd.c,v
retrieving revision 1.19
diff -u -r1.19 gnome-vfs-dns-sd.c
--- libgnomevfs/gnome-vfs-dns-sd.c	27 Feb 2006 10:32:22 -0000	1.19
+++ libgnomevfs/gnome-vfs-dns-sd.c	28 Feb 2006 21:44:01 -0000
@@ -1429,8 +1429,10 @@
 	GnomeVFSDNSSDService service;
 	GHashTable *hash;
 	size_t text_len;
+	char *resolved = NULL;
+	const char *host;
 	char *text;
-	char host[128];
+	char a[128];
 
 	handle = user_data;
 	if (event == AVAHI_RESOLVER_FOUND) {
@@ -1443,8 +1445,22 @@
 		service.name = (char *)name;
 		service.type = (char *)type;
 		service.domain = (char *)domain;
+
+
+		if (address) {
+			avahi_address_snprint (a, sizeof(a), address);
+			host = a;
+		} else {
+			g_assert (NULL != host_name);
+
+			if (g_str_has_suffix (host_name, ".local") &&
+			    GNOME_VFS_OK == avahi_resolve_host_name (interface, protocol, host_name, &resolved)) {
+				host = resolved;
+			} else {
+				host = host_name;
+			}
+		}
 		
-		avahi_address_snprint (host, sizeof(host), address);
 		handle->callback (handle,
 				  GNOME_VFS_OK,
 				  &service,
@@ -1454,11 +1470,14 @@
 				  handle->text_len,
 				  handle->text,
 				  handle->callback_data);
+
+		g_free (resolved);
+		
 		if (hash) {
 			g_hash_table_destroy (hash);
 		}
-		g_free (text);
 
+		g_free (text);
 	} else if (event == AVAHI_RESOLVER_FAILURE) {
 		handle->callback (handle,
 				  GNOME_VFS_ERROR_HOST_NOT_FOUND,
@@ -1638,7 +1657,8 @@
 		if (client) {
 			sr = avahi_service_resolver_new (client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
 							 name, type, domain, AVAHI_PROTO_UNSPEC, 
-							 0, avahi_resolve_async_callback, handle);
+							 AVAHI_LOOKUP_NO_ADDRESS,
+							 avahi_resolve_async_callback, handle);
 			if (sr != NULL) {
 				handle->avahi_sr = sr;
 				*handle_out = handle;
@@ -2078,13 +2098,13 @@
 			     void *user_data)
 {
 	struct sync_resolve_data *data;
-	char a[128];
 
 	data = user_data;
 	if (event == AVAHI_RESOLVER_FOUND) {
 		data->got_data = TRUE;
-		avahi_address_snprint (a, sizeof(a), address);
-		data->host = g_strdup (a);
+		data->protocol = protocol;
+		data->interface = interface;
+		data->host = g_strdup (host_name);
 		data->port = port;
 		data->text_len = avahi_string_list_serialize (txt, NULL, 0);
 		data->text = g_malloc (data->text_len);
@@ -2176,6 +2196,7 @@
 		AvahiServiceResolver *sr;
 		int error;
 		struct sync_resolve_data resolve_data = {0};
+		AvahiLookupFlags flags = AVAHI_LOOKUP_NO_ADDRESS;
 
 		simple_poll = avahi_simple_poll_new ();
 		resolve_data.poll = simple_poll;
@@ -2193,10 +2214,13 @@
 			avahi_simple_poll_free (simple_poll);
 			return GNOME_VFS_ERROR_GENERIC;
 		}
-		
+
+		if (!text && !text_raw_out)
+			flags|= AVAHI_LOOKUP_NO_TXT;
+
 		sr = avahi_service_resolver_new (client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
 						 name, type, domain, AVAHI_PROTO_UNSPEC, 
-						 0, avahi_resolve_sync_callback, &resolve_data);
+						 flags, avahi_resolve_sync_callback, &resolve_data);
 		if (sr == NULL) {
 			g_warning ("Failed to resolve service '%s': %s\n", name, avahi_strerror (avahi_client_errno (client)));
 			avahi_client_free (client);
@@ -2213,8 +2237,19 @@
 		avahi_simple_poll_free (simple_poll);
 
 		if (resolve_data.got_data) {
-			*host = resolve_data.host;
+			GnomeVFSResult result = GNOME_VFS_OK;
+			
+			if (g_str_has_suffix (resolve_data.host, ".local")) {
+				result = avahi_resolve_host_name (
+					resolve_data.interface, resolve_data.protocol,
+					resolve_data.host, host);
+				g_free (resolve_data.host);
+			} else {
+				*host = resolve_data.host;
+			}
+
 			*port = resolve_data.port;
+
 			if (text != NULL)
 				*text = decode_txt_record (resolve_data.text, resolve_data.text_len);
 			if (text_raw_len_out != NULL && text_raw_out) {
@@ -2223,7 +2258,7 @@
 			} else {
 				g_free (resolve_data.text);
 			}
-			return GNOME_VFS_OK;
+			return result;
 		}
 		
 		return GNOME_VFS_ERROR_HOST_NOT_FOUND;
