girwriter: Fix indices for delegate parameters
[vala-lang.git] / vapi / avahi-gobject.vapi
blobef9474ec1738ba76516bc5e880be9cee263ae10c
1 /* avahi.vala
2  *
3  * Copyright (C) 2009  Sebastian Noack
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18  *
19  * As a special exception, if you use inline functions from this file, this
20  * file does not by itself cause the resulting executable to be covered by
21  * the GNU Lesser General Public License.
22  *
23  * Author:
24  *  Sebastian Noack <sebastian.noack@gmail.com>
25  */
27 [CCode(cprefix="Ga", lower_case_cprefix="ga_")]
28 namespace Avahi {
29         /* Error handling */
31         [CCode(cheader_filename="avahi-gobject/ga-error.h", cprefix="AVAHI_ERR_")]
32         public errordomain Error {
33                 FAILURE,
34                 BAD_STATE,
35                 INVALID_HOST_NAME,
36                 INVALID_DOMAIN_NAME,
37                 NO_NETWORK,
38                 INVALID_TTL,
39                 IS_PATTERN,
40                 COLLISION,
41                 INVALID_RECORD,
43                 INVALID_SERVICE_NAME,
44                 INVALID_SERVICE_TYPE,
45                 INVALID_PORT,
46                 INVALID_KEY,
47                 INVALID_ADDRESS,
48                 TIMEOUT,
49                 TOO_MANY_CLIENTS,
50                 TOO_MANY_OBJECTS,
51                 TOO_MANY_ENTRIES,
52                 OS,
54                 ACCESS_DENIED,
55                 INVALID_OPERATION,
56                 DBUS_ERROR,
57                 DISCONNECTED,
58                 NO_MEMORY,
59                 INVALID_OBJECT,
60                 NO_DAEMON,
61                 INVALID_INTERFACE,
62                 INVALID_PROTOCOL,
63                 INVALID_FLAGS,
65                 NOT_FOUND,
66                 INVALID_CONFIG,
67                 VERSION_MISMATCH,
68                 INVALID_SERVICE_SUBTYPE,
69                 INVALID_PACKET,
70                 INVALID_DNS_ERROR,
71                 DNS_FORMERR,
72                 DNS_SERVFAIL,
73                 DNS_NXDOMAIN,
74                 DNS_NOTIMP,
76                 DNS_REFUSED,
77                 DNS_YXDOMAIN,
78                 DNS_YXRRSET,
79                 DNS_NXRRSET,
80                 DNS_NOTAUTH,
81                 DNS_NOTZONE,
82                 INVALID_RDATA,
83                 INVALID_DNS_CLASS,
84                 INVALID_DNS_TYPE,
85                 NOT_SUPPORTED,
87                 NOT_PERMITTED,
88                 INVALID_ARGUMENT,
89                 IS_EMPTY,
90                 NO_CHANGE
91         }
93         [CCode(cheader_filename="avahi-gobject/ga-error.h", cname="avahi_strerror")]
94         public unowned string strerror(int errno);
97         /* Network addresses */
99         [SimpleType]
100         [CCode(cheader_filename="avahi-common/address.h", cname="AvahiProtocol", cprefix="AVAHI_PROTO_", lower_case_cprefix="avahi_proto_")]
101         public enum Protocol {
102                 INET,
103                 INET6,
104                 UNSPEC;
106                 [CCode(cname="avahi_af_to_proto")]
107                 public static Protocol from_af(int af);
109                 public unowned string to_string();
110                 public int to_af();
112                 [CCode(cname="AVAHI_PROTO_VALID")]
113                 public bool is_valid();
114         }
116         [SimpleType]
117         [CCode(cheader_filename="avahi-common/address.h", cname="AvahiIfIndex")]
118         public struct Interface {
119                 [CCode(cname="AVAHI_IF_UNSPEC")]
120                 public static Interface UNSPEC;
122                 [CCode(cname="AVAHI_IF_VALID")]
123                 public bool is_valid();
124         }
126         [CCode(cheader_filename="avahi-common/address.h", cname="AvahiAddress", cprefix="avahi_address_")]
127         public struct Address {
128                 public Protocol proto;
130                 [CCode(cname="AVAHI_ADDRESS_STR_MAX")]
131                 public static size_t STR_MAX;
133                 [CCode(cname="avahi_address_parse", instance_pos=-1)]
134                 public Address.parse(string s, Protocol proto=Protocol.UNSPEC);
136                 [CCode(cname="avahi_address_snprint", instance_pos=-1)]
137                 public unowned string to_string(char[] dest=new char[STR_MAX]);
138                 public int cmp(Address other);
139         }
142         /* Linked list of strings used for DNS TXT record data */
144         [CCode(cheader_filename="avahi-common/defs.h", cname="AVAHI_SERVICE_COOKIE_INVALID")]
145         public const uint32 SERVICE_COOKIE_INVALID;
147         [Compact]
148         [CCode(cheader_filename="avahi-common/strlst.h", cname="AvahiStringList", cprefix="avahi_string_list_", dup_function="avahi_string_list_copy", free_function="avahi_string_list_free")]
149         public class StringList {
150                 public StringList next;
151                 [CCode(array_length_cname="size")]
152                 public char[] text;
154                 public StringList(string? txt=null, ...);
155                 public StringList.from_array(string[] array);
157                 [ReturnsModifiedPointer()]
158                 public void add(string text);
159                 [ReturnsModifiedPointer()]
160                 [PrintfFormat]
161                 public void add_printf(string format, ...);
162                 [ReturnsModifiedPointer()]
163                 public void add_arbitrary(char[] text);
164                 [ReturnsModifiedPointer()]
165                 public void add_anonymous(size_t size);
166                 [ReturnsModifiedPointer()]
167                 public void add_many(...);
169                 public string to_string();
170                 public int equal(StringList other);
171                 public StringList copy();
172                 [ReturnsModifiedPointer()]
173                 public void reverse();
174                 public uint length();
176                 public unowned StringList find(string key);
177                 public bool get_pair(out string key, out char[] value);
178                 [ReturnsModifiedPointer()]
179                 public void add_pair(string key, string? value);
180                 [ReturnsModifiedPointer()]
181                 public void add_pair_arbitrary(string key, char[] value);
182                 public uint32 get_service_cookie();
184                 [CCode(cname="avahi_string_list_serialize")]
185                 private size_t _serialize(char[] dest);
186                 [CCode(cname="avahi_string_list_serialize_dup")]
187                 public char[] serialize() {
188                         char[] dest = new char[this.length() * 256];
189                         dest.length = (int) _serialize(dest);
190                         return dest;
191                 }
193                 [CCode(cname="avahi_string_list_parse")]
194                 private static int _parse(char[] data, out StringList dest);
195                 [CCode(cname="avahi_string_list_parse_dup")]
196                 public static StringList parse(char[] data) throws Error {
197                         StringList dest;
199                         int errno = _parse(data, out dest);
200                         if (errno < 0) {
201                                 var err = new Error.FAILURE(strerror(errno));
202                                 err.code = errno;
203                                 throw err;
204                         }
206                         return dest;
207                 }
208         }
211         /* Domain name utility functions */
213         [CCode(cheader_filename="avahi-common/domain.h", lower_case_cprefix="avahi_")]
214         namespace Domain {
215                 public const size_t DOMAIN_NAME_MAX;
216                 public const size_t LABEL_MAX;
218                 [CCode(cname="avahi_normalize_name_strdup")]
219                 public string normalize_name(string s);
220                 [CCode(cname="avahi_domain_equal")]
221                 public bool equal(string a, string b);
222                 [CCode(cname="avahi_domain_hash")]
223                 public uint hash(string name);
224                 public unowned string? get_type_from_subtype(string s);
225                 public unowned string? unescape_label(ref unowned string name, char[] dest=new char[LABEL_MAX]);
227                 [CCode(cname="avahi_escape_label")]
228                 private string? _escape_label(char* src, size_t src_len, ref char* dest, ref size_t dest_len);
229                 [CCode(cname="avahi_escape_label_dup")]
230                 public string? escape_label(string s) {
231                         size_t len = LABEL_MAX * 4;
232                         char* dest = new char[len];
233                         return _escape_label(s, s.size(), ref dest, ref len);
234                 }
236                 [CCode(cname="avahi_service_name_join")]
237                 private int _service_name_join(char* dest, size_t dest_len, string name, string type, string domain);
238                 [CCode(cname="avahi_service_name_join_dup")]
239                 public string service_name_join(string name, string type, string domain) throws Error {
240                         char* dest = new char[DOMAIN_NAME_MAX];
242                         int errno = _service_name_join(dest, DOMAIN_NAME_MAX, name, type, domain);
243                         if (errno < 0) {
244                                 var err = new Error.FAILURE(strerror(errno));
245                                 err.code = errno;
246                                 throw err;
247                         }
249                         return (string) dest;
250                 }
252                 [CCode(cname="avahi_service_name_split")]
253                 private int _service_name_split(string src, char* name,   size_t name_len,
254                                                                                                         char* type,   size_t type_len,
255                                                                                                         char* domain, size_t domain_len);
256                 [CCode(cname="avahi_service_name_split_dup")]
257                 public void service_name_split(string src, out string name, out string type, out string domain) throws Error {
258                         name = (string) new char[LABEL_MAX];
259                         type = (string) new char[DOMAIN_NAME_MAX];
260                         domain = (string) new char[DOMAIN_NAME_MAX];
262                         int errno = _service_name_split(src, name,   LABEL_MAX,
263                                                                                                  type,   DOMAIN_NAME_MAX,
264                                                                                                  domain, DOMAIN_NAME_MAX);
265                         if (errno < 0) {
266                                 var err = new Error.FAILURE(strerror(errno));
267                                 err.code = errno;
268                                 throw err;
269                         }
270                 }
272                 public bool is_valid_service_type_generic(string s);
273                 public bool is_valid_service_type_strict(string s);
274                 public bool is_valid_service_subtype(string s);
275                 public bool is_valid_domain_name(string s);
276                 public bool is_valid_service_name(string s);
277                 public bool is_valid_host_name(string s);
278                 public bool is_valid_fqdn(string s);
280                 [CCode(cheader_filename="avahi-common/address.h")]
281                 public unowned string reverse_lookup_name(Address addr, char[] dest=new char[DOMAIN_NAME_MAX]);
282         }
284         [CCode(cheader_filename="avahi-common/alternative.h", lower_case_cprefix="avahi_alternative_")]
285         namespace Alternative {
286                 public string host_name(string s);
287                 public string service_name(string s);
288         }
291         /* Lookup flags */
293         [CCode(cheader_filename="avahi-gobject/ga-enums.h", cprefix="GA_LOOKUP_RESULT_")]
294         public enum LookupResultFlags {
295                 CACHED,
296                 WIDE_AREA,
297                 MULTICAST,
298                 LOCAL,
299                 OUR_OWN,
300                 STATIC
301         }
303         [Flags]
304         [CCode(cheader_filename="avahi-gobject/ga-enums.h", cprefix="GA_LOOKUP_")]
305         public enum LookupFlags {
306                 NO_FLAGS,
307                 USE_WIDE_AREA,
308                 USE_MULTICAST,
309                 NO_TXT,
310                 NO_ADDRESS
311         }
314         /* Client */
316         [CCode(cheader_filename="avahi-gobject/ga-client.h")]
317         public enum ClientState {
318                 NOT_STARTED,
319                 S_REGISTERING,
320                 S_RUNNING,
321                 S_COLLISION,
322                 FAILURE,
323                 CONNECTING
324         }
326         [Flags]
327         [CCode(cheader_filename="avahi-gobject/ga-client.h", cprefix="GA_CLIENT_FLAG_")]
328         public enum ClientFlags {
329                 NO_FLAGS,
330                 IGNORE_USER_CONFIG,
331                 NO_FAIL
332         }
334         [CCode(cheader_filename="avahi-gobject/ga-client.h")]
335         public class Client : GLib.Object {
336                 public Client(ClientFlags flags=ClientFlags.NO_FLAGS);
338                 public void start() throws Error;
340                 [NoAccessorMethod]
341                 public ClientState state { get; }
342                 [NoAccessorMethod]
343                 public ClientFlags flags { get; construct; }
345                 public signal void state_changed(ClientState state);
346         }
349         /* Record browser */
351         [CCode(cheader_filename="avahi-gobject/ga-record-browser.h")]
352         public class RecordBrowser : GLib.Object {
353                 public RecordBrowser(string name, uint16 type);
354                 public RecordBrowser.full(Interface interface, Protocol protocol, string name, uint16 class, uint16 type, LookupFlags flags=LookupFlags.NO_FLAGS);
356                 public void attach(Client client) throws Error;
358                 [NoAccessorMethod]
359                 public Protocol protocol { get; set; }
360                 [NoAccessorMethod]
361                 public Interface interface { get; set; }
362                 [NoAccessorMethod]
363                 public string name { owned get; set; }
364                 [NoAccessorMethod]
365                 public uint16 type { get; set; }
366                 [NoAccessorMethod]
367                 public uint16 class { get; set; }
368                 [NoAccessorMethod]
369                 public LookupFlags flags { get; set; }
371                 public signal void new_record(Interface interface, Protocol protocol, string name, uint16 class, uint16 type, char[] data, LookupResultFlags flags);
372                 public signal void removed_record(Interface interface, Protocol protocol, string name, uint16 class, uint16 type, char[] data, LookupResultFlags flags);
373                 public signal void all_for_now();
374                 public signal void cache_exhausted();
375                 public signal void failure(GLib.Error error);
376         }
379         /* Service browser */
381         [CCode(cheader_filename="avahi-gobject/ga-service-browser.h")]
382         public class ServiceBrowser : GLib.Object {
383                 public ServiceBrowser(string type);
384                 public ServiceBrowser.full(Interface interface, Protocol protocol, string type, string? domain=null, LookupFlags flags=LookupFlags.NO_FLAGS);
386                 public void attach(Client client) throws Error;
388                 [NoAccessorMethod]
389                 public Protocol protocol { get; set; }
390                 [NoAccessorMethod]
391                 public Protocol aprotocol { get; set; }
392                 [NoAccessorMethod]
393                 public Interface interface { get; set; }
394                 [NoAccessorMethod]
395                 public string type { owned get; set; }
396                 [NoAccessorMethod]
397                 public string? domain { owned get; set; }
398                 [NoAccessorMethod]
399                 public LookupFlags flags { get; set; }
401                 public signal void new_service(Interface interface, Protocol protocol, string name, string type, string domain, LookupResultFlags flags);
402                 public signal void removed_service(Interface interface, Protocol protocol, string name, string type, string domain, LookupResultFlags flags);
403                 public signal void all_for_now();
404                 public signal void cache_exhausted();
405                 public signal void failure(GLib.Error error);
406         }
409         /* Service resolver */
411         [CCode(cheader_filename="avahi-gobject/ga-service-resolver.h")]
412         public class ServiceResolver : GLib.Object {
413                 public ServiceResolver(Interface interface, Protocol protocol, string name, string type, string domain, Protocol address_protocol, LookupFlags flags=LookupFlags.NO_FLAGS);
415                 public void attach(Client client) throws Error;
416                 public bool get_address(out Address address, out uint16 port);
418                 [NoAccessorMethod]
419                 public Protocol protocol { get; set; }
420                 [NoAccessorMethod]
421                 public Protocol aprotocol { get; set; }
422                 [NoAccessorMethod]
423                 public Interface interface { get; set; }
424                 [NoAccessorMethod]
425                 public string name { owned get; set; }
426                 [NoAccessorMethod]
427                 public string type { owned get; set; }
428                 [NoAccessorMethod]
429                 public string domain { owned get; set; }
430                 [NoAccessorMethod]
431                 public LookupFlags flags { get; set; }
433                 public signal void found(Interface interface, Protocol protocol, string name, string type, string domain, string hostname, Address? address, uint16 port, StringList? txt, LookupResultFlags flags);
434                 public signal void failure(GLib.Error error);
435         }
438         /* Entry group */
440         [Flags]
441         [CCode(cheader_filename="avahi-common/defs.h", cname="AvahiPublishFlags", cfrefix="AVAHI_PUBLISH_")]
442         public enum PublishFlags {
443                 UNIQUE,
444                 NO_PROBE,
445                 NO_ANNOUNCE,
446                 ALLOW_MULTIPLE,
447                 NO_REVERSE,
448                 NO_COOKIE,
449                 UPDATE,
450                 USE_WIDE_AREA,
451                 USE_MULTICAST
452         }
454         [CCode(cheader_filename="avahi-gobject/ga-entry-group.h")]
455         public enum EntryGroupState {
456                 UNCOMMITED,
457                 REGISTERING,
458                 ESTABLISHED,
459                 COLLISION,
460                 FAILURE
461         }
463         [Compact]
464         [CCode(cheader_filename="avahi-gobject/ga-entry-group.h", ref_function="", unref_function="")]
465         public class EntryGroupService {
466                 public Interface interface;
467                 public Protocol protocol;
468                 public PublishFlags flags;
469                 public string name;
470                 public string type;
471                 public string domain;
472                 public string host;
473                 public uint16 port;
475                 public void freeze();
476                 public void set(string key, string value) throws Error;
477                 public void set_arbitrary(string key, char[] value) throws Error;
478                 public void remove_key(string key) throws Error;
479                 public void thaw() throws Error;
480         }
482         [CCode(cheader_filename="avahi-gobject/ga-entry-group.h")]
483         public class EntryGroup : GLib.Object {
484                 public EntryGroup();
486                 public void attach(Client client) throws Error;
487                 [CCode(sentinel="")]
488                 public EntryGroupService add_service_strlist(string name, string type, uint16 port, ...) throws Error;
489                 [CCode(sentinel="")]
490                 public EntryGroupService add_service_full_strlist(Interface interface, Protocol protocol, PublishFlags flags, string name, string type, string domain, string host, uint16 port, ...) throws Error;
491                 public EntryGroupService add_service(string name, string type, ...) throws Error;
492                 public EntryGroupService add_service_full(Interface interface, Protocol protocol, PublishFlags flags, string name, string type, string domain, string host, uint16 port, ...) throws Error;
493                 public void add_record(PublishFlags flags, string name, uint16 type, uint32 ttl, char[] data) throws Error;
494                 public void add_record_full(Interface interface, Protocol protocol, PublishFlags flags, string name, uint16 class, uint16 type, uint32 ttl, char[] data) throws Error;
495                 public void commit() throws Error;
496                 public void reset() throws Error;
498                 [NoAccessorMethod]
499                 public EntryGroupState state { get; }
501                 public signal void state_changed(EntryGroupState state);
502         }