core: bridge can now be changed in conf
by default DBus bridge is used, but this can be changed in sat.conf's DEFAULT section using "bridge" option.
bridge can be "dbus" (or equivalent "dbus_bridge") or embedded at the moment.
Bridge name used is saved in SAT.bridge_name, and load_bridge method can be used by frontends.
This commit is contained in:
parent
6ad826bb0d
commit
9ce91cf534
2 changed files with 56 additions and 2 deletions
|
|
@ -35,6 +35,10 @@ class Const(object):
|
|||
APP_URL = u'http://salut-a-toi.org'
|
||||
|
||||
|
||||
# Main config ##
|
||||
DEFAULT_BRIDGE = 'dbus'
|
||||
|
||||
|
||||
# Protocol
|
||||
XMPP_C2S_PORT = 5222
|
||||
XMPP_KEEP_ALIFE = 180
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ from twisted.words.protocols.jabber import jid
|
|||
from twisted.words.xish import domish
|
||||
from twisted.internet import reactor
|
||||
from wokkel.xmppim import RosterItem
|
||||
from sat.bridge.dbus_bridge import Bridge
|
||||
from sat.core import xmpp
|
||||
from sat.core import exceptions
|
||||
from sat.core.log import getLogger
|
||||
|
|
@ -34,6 +33,7 @@ from sat.core.constants import Const as C
|
|||
from sat.memory.memory import Memory
|
||||
from sat.tools import trigger
|
||||
from sat.tools import utils
|
||||
from sat.tools.common import dynamic_import
|
||||
from sat.stdui import ui_contact_list, ui_profile_manager
|
||||
from glob import glob
|
||||
from uuid import uuid4
|
||||
|
|
@ -60,8 +60,15 @@ class SAT(service.Service):
|
|||
self.memory = Memory(self)
|
||||
self.trigger = trigger.TriggerManager() # trigger are used to change SàT behaviour
|
||||
|
||||
bridge_name = self.memory.getConfig('', 'bridge', 'dbus')
|
||||
|
||||
bridge_module = dynamic_import.bridge(bridge_name)
|
||||
if bridge_module is None:
|
||||
log.error(u"Can't find bridge module of name {}".format(bridge_name))
|
||||
sys.exit(1)
|
||||
log.info(u"using {} bridge".format(bridge_name))
|
||||
try:
|
||||
self.bridge = Bridge()
|
||||
self.bridge = bridge_module.Bridge()
|
||||
except exceptions.BridgeInitError:
|
||||
log.error(u"Bridge can't be initialised, can't start SàT core")
|
||||
sys.exit(1)
|
||||
|
|
@ -132,6 +139,10 @@ class SAT(service.Service):
|
|||
else:
|
||||
return version
|
||||
|
||||
@property
|
||||
def bridge_name(self):
|
||||
return os.path.splitext(os.path.basename(self.bridge.__file__))[0]
|
||||
|
||||
def _postMemoryInit(self, ignore):
|
||||
"""Method called after memory initialization is done"""
|
||||
log.info(_("Memory initialised"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue