]> git.meshlink.io Git - catta/blob - avahi-sharp/ClientException.cs
first pass at updating to the 0.6 apis
[catta] / avahi-sharp / ClientException.cs
1 /* $Id$ */
2
3 /***
4   This file is part of avahi.
5
6   avahi is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as
8   published by the Free Software Foundation; either version 2.1 of the
9   License, or (at your option) any later version.
10
11   avahi is distributed in the hope that it will be useful, but WITHOUT
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14   Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with avahi; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19   USA.
20 ***/
21
22
23 using System;
24 using System.Runtime.InteropServices;
25
26 namespace Avahi
27 {
28     public enum ErrorCode {
29         Ok = 0,
30         Failure = -1,
31         BadState = -2,
32         InvalidHostName = - 3,
33         InvalidDomainName = -4,
34         NoNetwork = -5,
35         InvalidTTL = -6,
36         IsPattern = -7,
37         Collision = -8,
38         InvalidRecord = -9,
39         InvalidServiceName = -10,
40         InvalidServiceType = -11,
41         InvalidPort = -12,
42         InvalidKey = -13,
43         InvalidAddress = -14,
44         Timeout = -15,
45         TooManyClients = -16,
46         TooManyObjects = -17,
47         TooManyEntries = -18,
48         OS = -19,
49         AccessDenied = -20,
50         InvalidOperation = -21,
51         DBusError = -22,
52         NotConnected = -23,
53         NoMemory = -24,
54         InvalidObject = -25,
55         NoDaemon = -26,
56         InvalidInterface = -27,
57         InvalidProtocol = -28,
58         InvalidFlags = -29,
59         NotFound = -30,
60         InvalidConfig = -31,
61         VersionMismatch = -32,
62         InvalidServiceSubtype = -33,
63         InvalidPacket = -34,
64         InvalidDnsError = -35,
65         DnsFormErr = -36,
66         DnsServFail = -37,
67         DnsNxDomain = -38,
68         DnsNoTimp = -39,
69         DnsRefused = -40,
70         DnsYxDomain = -41,
71         DnsYxRrSet = -42,
72         DnsNxRrSet = -43,
73         DnsNotAuth = -44,
74         DnsNotZone = -45
75     }
76
77     public delegate void ErrorCodeHandler (object o, ErrorCode code);
78     
79     public class ClientException : ApplicationException
80     {
81         private ErrorCode code;
82
83         [DllImport ("avahi-common")]
84         private static extern IntPtr avahi_strerror (ErrorCode code);
85         
86         public ErrorCode ErrorCode
87         {
88             get { return code; }
89         }
90
91         internal ClientException (int code) : this ((ErrorCode) code) {
92         }
93         
94         internal ClientException (ErrorCode code) : base (GetErrorString (code))
95         {
96             this.code = code;
97         }
98
99         private static string GetErrorString (ErrorCode code)
100         {
101             IntPtr str = avahi_strerror (code);
102             return Utility.PtrToString (str);
103         }
104     }
105 }