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
@@ -1327,6 +1327,89 @@
 	}
 }
 
+static void
+avahi_resolve_host_name_sync_callback (AvahiHostNameResolver *r,
+                                       AvahiIfIndex interface G_GNUC_UNUSED,
+                                       AvahiProtocol protocol G_GNUC_UNUSED,
+                                       AvahiResolverEvent event,
+                                       const char *name G_GNUC_UNUSED,
+                                       const AvahiAddress *address,
+                                       AvahiLookupResultFlags flags G_GNUC_UNUSED, 
+                                       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);
+	}
+	
+	avahi_host_name_resolver_free (r);
+        avahi_simple_poll_quit (data->poll);
+}
+
+static GnomeVFSResult
+avahi_resolve_host_name (AvahiIfIndex interface,
+                         AvahiProtocol protocol,
+                         const char *host_name,
+                         char **address)
+{
+	GnomeVFSResult result = GNOME_VFS_ERROR_GENERIC;
+        struct sync_resolve_data resolve_data;
+        AvahiHostNameResolver *hr = NULL;
+        AvahiClient *client = NULL;
+        int error = 0;
+
+        resolve_data.poll = avahi_simple_poll_new ();
+
+        if (resolve_data.poll == NULL) {
+                g_warning ("Failed to create simple poll object");
+                goto cleanup;
+        }
+
+        client = avahi_client_new (avahi_simple_poll_get (resolve_data.poll), 0, 
+				   avahi_resolve_sync_client_callback, &resolve_data, &error);
+		
+	/* Check wether creating the client object succeeded */
+	if (client == NULL) {
+		g_warning ("Failed to create client: %s\n", avahi_strerror (error));
+		goto cleanup;
+	}
+
+        hr = avahi_host_name_resolver_new (client, interface, protocol, 
+                                           host_name, AVAHI_PROTO_UNSPEC, 0,
+                                           avahi_resolve_host_name_sync_callback, 
+                                           &resolve_data);
+
+        if (hr == NULL) {
+		g_warning ("Failed to resolve host name '%s': %s\n", host_name, avahi_strerror (avahi_client_errno (client)));
+                goto cleanup;
+	}
+
+        for (;;)
+                if (avahi_simple_poll_iterate (resolve_data.poll, -1) != 0)
+                        break;
+        
+	if (resolve_data.got_data) {
+		result = GNOME_VFS_OK;
+                *address = resolve_data.host;
+	} else {
+		result = GNOME_VFS_ERROR_HOST_NOT_FOUND;
+	}
+
+cleanup:
+        if (client)
+                avahi_client_free (client);
+        if (resolve_data.poll)
+                avahi_simple_poll_free (resolve_data.poll);
+
+        return result;
+}
+
 static void
 avahi_resolve_async_callback (AvahiServiceResolver *r,
 			      AvahiIfIndex interface,
