2018-09-05 02:59:34 +02:00
|
|
|
# Copyright (C) 2006 Stefan Bethge <stefan@lanpartei.de>
|
|
|
|
#
|
|
|
|
# This file is part of Gajim.
|
|
|
|
#
|
|
|
|
# Gajim is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published
|
|
|
|
# by the Free Software Foundation; version 3 only.
|
|
|
|
#
|
|
|
|
# Gajim is distributed in the hope that it will be useful,
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
2018-09-21 23:55:57 +02:00
|
|
|
from typing import Any # pylint: disable=unused-import
|
|
|
|
|
2017-03-04 21:22:46 +01:00
|
|
|
from enum import IntEnum, unique
|
2017-02-07 21:18:41 +01:00
|
|
|
|
2018-09-21 23:55:57 +02: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-09-17 21:11:45 +02:00
|
|
|
import dbus # pylint: disable=unused-variable
|
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:
|
2018-09-17 21:11:45 +02:00
|
|
|
import pybonjour # pylint: disable=unused-variable
|
2010-02-08 15:08:40 +01:00
|
|
|
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
|
2018-09-21 23:55:57 +02:00
|
|
|
Zeroconf = zeroconf_avahi.Zeroconf # type: Any
|
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
|