-/* $Id$ */
-
/***
This file is part of avahi.
using System.Collections;
using System.Net;
using System.Runtime.InteropServices;
+using System.Text;
using Mono.Unix;
namespace Avahi
private ArrayList foundListeners = new ArrayList ();
private ArrayList timeoutListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_host_name_resolver_new (IntPtr client, int iface, Protocol proto,
- IntPtr hostname, Protocol aproto, LookupFlags flags,
+ byte[] hostname, Protocol aproto, LookupFlags flags,
HostNameResolverCallback cb, IntPtr userdata);
[DllImport ("avahi-client")]
Stop (false);
}
}
-
+
public event EventHandler Timeout
{
add {
(foundListeners.Count == 0 && timeoutListeners.Count == 0))
return;
- IntPtr hostPtr = Utility.StringToPtr (hostname);
-
lock (client) {
- handle = avahi_host_name_resolver_new (client.Handle, iface, proto, hostPtr, aproto, flags,
+ handle = avahi_host_name_resolver_new (client.Handle, iface, proto,
+ Utility.StringToBytes (hostname), aproto, flags,
cb, IntPtr.Zero);
+
+ if (handle == IntPtr.Zero)
+ client.ThrowError ();
}
-
- Utility.Free (hostPtr);
}
private void Stop (bool force)
currentHost = Utility.PtrToString (hostname);
foreach (HostAddressHandler handler in foundListeners)
- handler (this, currentHost, currentAddress);
- break;
- case ResolverEvent.Timeout:
- currentAddress = null;
- currentHost = null;
-
- foreach (EventHandler handler in timeoutListeners)
- handler (this, new EventArgs ());
+ handler (this, new HostAddressArgs (currentHost, currentAddress));
break;
- default:
- EmitResolverEvent (revent);
+ case ResolverEvent.Failure:
+ EmitFailure (client.LastError);
break;
}
}