X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FServiceTypeBrowser.cs;h=e1356d00a4623cf1a2ddae808972273e6bebcafb;hb=e5f8b9380b9cb893dbb3449c7b1635e256752591;hp=dbfff7378058dd9fd12247ff05fd03e78def0426;hpb=84a9392791c574c56ca148157b8b951851208398;p=catta diff --git a/avahi-sharp/ServiceTypeBrowser.cs b/avahi-sharp/ServiceTypeBrowser.cs index dbfff73..e1356d0 100644 --- a/avahi-sharp/ServiceTypeBrowser.cs +++ b/avahi-sharp/ServiceTypeBrowser.cs @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** This file is part of avahi. @@ -22,13 +20,14 @@ using System; using System.Collections; using System.Runtime.InteropServices; +using System.Text; namespace Avahi { internal delegate void ServiceTypeBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent, IntPtr type, IntPtr domain, LookupResultFlags flags, IntPtr userdata); - + public struct ServiceTypeInfo { public int NetworkInterface; @@ -54,7 +53,7 @@ namespace Avahi } public delegate void ServiceTypeInfoHandler (object o, ServiceTypeInfoArgs args); - + public class ServiceTypeBrowser : BrowserBase, IDisposable { private IntPtr handle; @@ -68,10 +67,10 @@ namespace Avahi private ArrayList addListeners = new ArrayList (); private ArrayList removeListeners = new ArrayList (); - + [DllImport ("avahi-client")] private static extern IntPtr avahi_service_type_browser_new (IntPtr client, int iface, int proto, - IntPtr domain, LookupFlags flags, + byte[] domain, LookupFlags flags, ServiceTypeBrowserCallback cb, IntPtr userdata); @@ -89,7 +88,7 @@ namespace Avahi Stop (false); } } - + public event ServiceTypeInfoHandler ServiceTypeRemoved { add { @@ -143,10 +142,12 @@ namespace Avahi return; lock (client) { - IntPtr domainPtr = Utility.StringToPtr (domain); - handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr, flags, + handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, + Utility.StringToBytes (domain), flags, cb, IntPtr.Zero); - Utility.Free (domainPtr); + + if (handle == IntPtr.Zero) + client.ThrowError (); } }