From 94d2753047cff1e9223e42736884e4d51348b45a Mon Sep 17 00:00:00 2001 From: James Willcox Date: Wed, 26 Oct 2005 03:20:44 +0000 Subject: first pass at updating to the 0.6 apis git-svn-id: file:///home/lennart/svn/public/avahi/trunk@876 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-sharp/ClientException.cs | 64 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'avahi-sharp/ClientException.cs') diff --git a/avahi-sharp/ClientException.cs b/avahi-sharp/ClientException.cs index 2abc57c..3ee0cab 100644 --- a/avahi-sharp/ClientException.cs +++ b/avahi-sharp/ClientException.cs @@ -25,24 +25,78 @@ using System.Runtime.InteropServices; namespace Avahi { + public enum ErrorCode { + Ok = 0, + Failure = -1, + BadState = -2, + InvalidHostName = - 3, + InvalidDomainName = -4, + NoNetwork = -5, + InvalidTTL = -6, + IsPattern = -7, + Collision = -8, + InvalidRecord = -9, + InvalidServiceName = -10, + InvalidServiceType = -11, + InvalidPort = -12, + InvalidKey = -13, + InvalidAddress = -14, + Timeout = -15, + TooManyClients = -16, + TooManyObjects = -17, + TooManyEntries = -18, + OS = -19, + AccessDenied = -20, + InvalidOperation = -21, + DBusError = -22, + NotConnected = -23, + NoMemory = -24, + InvalidObject = -25, + NoDaemon = -26, + InvalidInterface = -27, + InvalidProtocol = -28, + InvalidFlags = -29, + NotFound = -30, + InvalidConfig = -31, + VersionMismatch = -32, + InvalidServiceSubtype = -33, + InvalidPacket = -34, + InvalidDnsError = -35, + DnsFormErr = -36, + DnsServFail = -37, + DnsNxDomain = -38, + DnsNoTimp = -39, + DnsRefused = -40, + DnsYxDomain = -41, + DnsYxRrSet = -42, + DnsNxRrSet = -43, + DnsNotAuth = -44, + DnsNotZone = -45 + } + + public delegate void ErrorCodeHandler (object o, ErrorCode code); + public class ClientException : ApplicationException { - private int code; + private ErrorCode code; [DllImport ("avahi-common")] - private static extern IntPtr avahi_strerror (int code); + private static extern IntPtr avahi_strerror (ErrorCode code); - public int ErrorCode + public ErrorCode ErrorCode { get { return code; } } + + internal ClientException (int code) : this ((ErrorCode) code) { + } - internal ClientException (int code) : base (GetErrorString (code)) + internal ClientException (ErrorCode code) : base (GetErrorString (code)) { this.code = code; } - private static string GetErrorString (int code) + private static string GetErrorString (ErrorCode code) { IntPtr str = avahi_strerror (code); return Utility.PtrToString (str); -- cgit