2006-07-27 22:36:21 +02:00
|
|
|
## common/zeroconf/zeroconf.py
|
|
|
|
##
|
|
|
|
## Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2006-07-27 22:36:21 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-10-22 13:13:13 +02:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2006-07-27 22:36:21 +02:00
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2006-07-27 22:36:21 +02:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-10-22 13:13:13 +02:00
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2006-07-27 22:36:21 +02:00
|
|
|
|
2017-03-04 21:22:46 +01:00
|
|
|
from enum import IntEnum, unique
|
2017-02-07 21:18:41 +01:00
|
|
|
|
2017-03-04 21:22:46 +01:00
|
|
|
@unique
|
2017-02-07 21:18:41 +01:00
|
|
|
class Constant(IntEnum):
|
|
|
|
NAME = 0
|
|
|
|
DOMAIN = 1
|
|
|
|
RESOLVED_INFO = 2
|
|
|
|
BARE_NAME = 3
|
|
|
|
TXT = 4
|
|
|
|
|
2017-03-04 21:22:46 +01:00
|
|
|
@unique
|
2017-02-07 21:18:41 +01:00
|
|
|
class ConstantRI(IntEnum):
|
|
|
|
INTERFACE = 0
|
|
|
|
PROTOCOL = 1
|
|
|
|
HOST = 2
|
|
|
|
APROTOCOL = 3
|
|
|
|
ADDRESS = 4
|
|
|
|
PORT = 5
|
2006-09-17 17:07:35 +02:00
|
|
|
|
2007-08-06 23:46:51 +02:00
|
|
|
def test_avahi():
|
2010-02-08 15:08:40 +01:00
|
|
|
try:
|
2018-05-23 00:12:43 +02:00
|
|
|
import dbus
|
2010-02-08 15:08:40 +01:00
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
return True
|
2007-08-06 23:46:51 +02:00
|
|
|
|
|
|
|
def test_bonjour():
|
2010-02-08 15:08:40 +01:00
|
|
|
try:
|
|
|
|
import pybonjour
|
|
|
|
except ImportError:
|
|
|
|
return False
|
2017-08-24 23:20:35 +02:00
|
|
|
except WindowsError: # pylint: disable=undefined-variable
|
2010-02-08 15:08:40 +01:00
|
|
|
return False
|
|
|
|
return True
|
2007-08-06 23:46:51 +02:00
|
|
|
|
|
|
|
def test_zeroconf():
|
2010-02-08 15:08:40 +01:00
|
|
|
return test_avahi() or test_bonjour()
|
2007-08-06 23:46:51 +02:00
|
|
|
|
|
|
|
if test_avahi():
|
2017-06-13 23:58:06 +02:00
|
|
|
from gajim.common.zeroconf import zeroconf_avahi
|
2010-02-08 15:08:40 +01:00
|
|
|
Zeroconf = zeroconf_avahi.Zeroconf
|
2007-08-06 23:46:51 +02:00
|
|
|
elif test_bonjour():
|
2017-06-13 23:58:06 +02:00
|
|
|
from gajim.common.zeroconf import zeroconf_bonjour
|
2010-02-08 15:08:40 +01:00
|
|
|
Zeroconf = zeroconf_bonjour.Zeroconf
|