]> git.meshlink.io Git - catta/blob - avahi-python/avahi/__init__.py
build-sys: fix previous commit for recent automake
[catta] / avahi-python / avahi / __init__.py
1 # This file is part of avahi.
2 #
3 # avahi is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU Lesser General Public License as
5 # published by the Free Software Foundation; either version 2 of the
6 # License, or (at your option) any later version.
7 #
8 # avahi is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11 # License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with avahi; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16 # USA.
17
18 # Some definitions matching those in avahi-common/defs.h
19
20 import dbus
21
22 SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5)
23
24 ENTRY_GROUP_UNCOMMITED, ENTRY_GROUP_REGISTERING, ENTRY_GROUP_ESTABLISHED, ENTRY_GROUP_COLLISION, ENTRY_GROUP_FAILURE = range(0, 5)
25
26 DOMAIN_BROWSER_BROWSE, DOMAIN_BROWSER_BROWSE_DEFAULT, DOMAIN_BROWSER_REGISTER, DOMAIN_BROWSER_REGISTER_DEFAULT, DOMAIN_BROWSER_BROWSE_LEGACY = range(0, 5)
27
28 PROTO_UNSPEC, PROTO_INET, PROTO_INET6  = -1, 0, 1
29
30 IF_UNSPEC = -1
31
32 PUBLISH_UNIQUE = 1
33 PUBLISH_NO_PROBE = 2
34 PUBLISH_NO_ANNOUNCE = 4
35 PUBLISH_ALLOW_MULTIPLE = 8
36 PUBLISH_NO_REVERSE = 16
37 PUBLISH_NO_COOKIE = 32
38 PUBLISH_UPDATE = 64
39 PUBLISH_USE_WIDE_AREA = 128
40 PUBLISH_USE_MULTICAST = 256
41
42 LOOKUP_USE_WIDE_AREA = 1
43 LOOKUP_USE_MULTICAST = 2
44 LOOKUP_NO_TXT = 4
45 LOOKUP_NO_ADDRESS = 8
46
47 LOOKUP_RESULT_CACHED = 1
48 LOOKUP_RESULT_WIDE_AREA = 2
49 LOOKUP_RESULT_MULTICAST = 4
50 LOOKUP_RESULT_LOCAL = 8
51 LOOKUP_RESULT_OUR_OWN = 16
52 LOOKUP_RESULT_STATIC = 32
53
54 SERVICE_COOKIE = "org.freedesktop.Avahi.cookie"
55 SERVICE_COOKIE_INVALID = 0
56
57 DBUS_NAME = "org.freedesktop.Avahi"
58 DBUS_INTERFACE_SERVER = DBUS_NAME + ".Server"
59 DBUS_PATH_SERVER = "/"
60 DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup"
61 DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser"
62 DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser"
63 DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser"
64 DBUS_INTERFACE_ADDRESS_RESOLVER = DBUS_NAME + ".AddressResolver"
65 DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver"
66 DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver"
67 DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser"
68
69 def byte_array_to_string(s):
70     r = ""
71     
72     for c in s:
73         
74         if c >= 32 and c < 127:
75             r += "%c" % c
76         else:
77             r += "."
78
79     return r
80
81 def txt_array_to_string_array(t):
82     l = []
83
84     for s in t:
85         l.append(byte_array_to_string(s))
86
87     return l
88
89
90 def string_to_byte_array(s):
91     r = []
92
93     for c in s:
94         r.append(dbus.Byte(ord(c)))
95
96     return r
97
98 def string_array_to_txt_array(t):
99     l = []
100
101     for s in t:
102         l.append(string_to_byte_array(s))
103
104     return l
105
106 def dict_to_txt_array(txt_dict):
107     l = []
108
109     for k,v in txt_dict.items():
110         l.append(string_to_byte_array("%s=%s" % (k,v)))
111
112     return l