comparison src/core/sat_main.py @ 2086:4633cfcbcccb

bridge (D-Bus): bad design fixes: - renamed outputed module to dbus_bridge (to avoid uppercase and conflict with dbus module) - class name is now Bridge for both frontend and core (make discovery/import more easy) - register renamed to register_method in core, and register_signal in frontend
author Goffi <goffi@goffi.org>
date Mon, 03 Oct 2016 21:15:39 +0200
parents 046449cc2bff
children c02f96756d5c
comparison
equal deleted inserted replaced
2085:da4097de5a95 2086:4633cfcbcccb
23 from twisted.internet import defer 23 from twisted.internet import defer
24 from twisted.words.protocols.jabber import jid 24 from twisted.words.protocols.jabber import jid
25 from twisted.words.xish import domish 25 from twisted.words.xish import domish
26 from twisted.internet import reactor 26 from twisted.internet import reactor
27 from wokkel.xmppim import RosterItem 27 from wokkel.xmppim import RosterItem
28 from sat.bridge.DBus import DBusBridge 28 from sat.bridge.dbus_bridge import Bridge
29 from sat.core import xmpp 29 from sat.core import xmpp
30 from sat.core import exceptions 30 from sat.core import exceptions
31 from sat.core.log import getLogger 31 from sat.core.log import getLogger
32 log = getLogger(__name__) 32 log = getLogger(__name__)
33 from sat.core.constants import Const as C 33 from sat.core.constants import Const as C
59 59
60 self.memory = Memory(self) 60 self.memory = Memory(self)
61 self.trigger = trigger.TriggerManager() # trigger are used to change SàT behaviour 61 self.trigger = trigger.TriggerManager() # trigger are used to change SàT behaviour
62 62
63 try: 63 try:
64 self.bridge = DBusBridge() 64 self.bridge = Bridge()
65 except exceptions.BridgeInitError: 65 except exceptions.BridgeInitError:
66 log.error(u"Bridge can't be initialised, can't start SàT core") 66 log.error(u"Bridge can't be initialised, can't start SàT core")
67 sys.exit(1) 67 sys.exit(1)
68 self.bridge.register("getReady", lambda: self.initialised) 68 self.bridge.register_method("getReady", lambda: self.initialised)
69 self.bridge.register("getVersion", lambda: self.full_version) 69 self.bridge.register_method("getVersion", lambda: self.full_version)
70 self.bridge.register("getFeatures", self.getFeatures) 70 self.bridge.register_method("getFeatures", self.getFeatures)
71 self.bridge.register("getProfileName", self.memory.getProfileName) 71 self.bridge.register_method("getProfileName", self.memory.getProfileName)
72 self.bridge.register("getProfilesList", self.memory.getProfilesList) 72 self.bridge.register_method("getProfilesList", self.memory.getProfilesList)
73 self.bridge.register("getEntityData", lambda jid_, keys, profile: self.memory.getEntityData(jid.JID(jid_), keys, profile)) 73 self.bridge.register_method("getEntityData", lambda jid_, keys, profile: self.memory.getEntityData(jid.JID(jid_), keys, profile))
74 self.bridge.register("getEntitiesData", self.memory._getEntitiesData) 74 self.bridge.register_method("getEntitiesData", self.memory._getEntitiesData)
75 self.bridge.register("asyncCreateProfile", self.memory.asyncCreateProfile) 75 self.bridge.register_method("asyncCreateProfile", self.memory.asyncCreateProfile)
76 self.bridge.register("asyncDeleteProfile", self.memory.asyncDeleteProfile) 76 self.bridge.register_method("asyncDeleteProfile", self.memory.asyncDeleteProfile)
77 self.bridge.register("profileStartSession", self.memory.startSession) 77 self.bridge.register_method("profileStartSession", self.memory.startSession)
78 self.bridge.register("profileIsSessionStarted", self.memory._isSessionStarted) 78 self.bridge.register_method("profileIsSessionStarted", self.memory._isSessionStarted)
79 self.bridge.register("profileSetDefault", self.memory.profileSetDefault) 79 self.bridge.register_method("profileSetDefault", self.memory.profileSetDefault)
80 self.bridge.register("asyncConnect", self._asyncConnect) 80 self.bridge.register_method("asyncConnect", self._asyncConnect)
81 self.bridge.register("disconnect", self.disconnect) 81 self.bridge.register_method("disconnect", self.disconnect)
82 self.bridge.register("getContacts", self.getContacts) 82 self.bridge.register_method("getContacts", self.getContacts)
83 self.bridge.register("getContactsFromGroup", self.getContactsFromGroup) 83 self.bridge.register_method("getContactsFromGroup", self.getContactsFromGroup)
84 self.bridge.register("getMainResource", self.memory._getMainResource) 84 self.bridge.register_method("getMainResource", self.memory._getMainResource)
85 self.bridge.register("getPresenceStatuses", self.memory._getPresenceStatuses) 85 self.bridge.register_method("getPresenceStatuses", self.memory._getPresenceStatuses)
86 self.bridge.register("getWaitingSub", self.memory.getWaitingSub) 86 self.bridge.register_method("getWaitingSub", self.memory.getWaitingSub)
87 self.bridge.register("messageSend", self._messageSend) 87 self.bridge.register_method("messageSend", self._messageSend)
88 self.bridge.register("getConfig", self._getConfig) 88 self.bridge.register_method("getConfig", self._getConfig)
89 self.bridge.register("setParam", self.setParam) 89 self.bridge.register_method("setParam", self.setParam)
90 self.bridge.register("getParamA", self.memory.getStringParamA) 90 self.bridge.register_method("getParamA", self.memory.getStringParamA)
91 self.bridge.register("asyncGetParamA", self.memory.asyncGetStringParamA) 91 self.bridge.register_method("asyncGetParamA", self.memory.asyncGetStringParamA)
92 self.bridge.register("asyncGetParamsValuesFromCategory", self.memory.asyncGetParamsValuesFromCategory) 92 self.bridge.register_method("asyncGetParamsValuesFromCategory", self.memory.asyncGetParamsValuesFromCategory)
93 self.bridge.register("getParamsUI", self.memory.getParamsUI) 93 self.bridge.register_method("getParamsUI", self.memory.getParamsUI)
94 self.bridge.register("getParamsCategories", self.memory.getParamsCategories) 94 self.bridge.register_method("getParamsCategories", self.memory.getParamsCategories)
95 self.bridge.register("paramsRegisterApp", self.memory.paramsRegisterApp) 95 self.bridge.register_method("paramsRegisterApp", self.memory.paramsRegisterApp)
96 self.bridge.register("historyGet", self.memory._historyGet) 96 self.bridge.register_method("historyGet", self.memory._historyGet)
97 self.bridge.register("setPresence", self._setPresence) 97 self.bridge.register_method("setPresence", self._setPresence)
98 self.bridge.register("subscription", self.subscription) 98 self.bridge.register_method("subscription", self.subscription)
99 self.bridge.register("addContact", self._addContact) 99 self.bridge.register_method("addContact", self._addContact)
100 self.bridge.register("updateContact", self._updateContact) 100 self.bridge.register_method("updateContact", self._updateContact)
101 self.bridge.register("delContact", self._delContact) 101 self.bridge.register_method("delContact", self._delContact)
102 self.bridge.register("isConnected", self.isConnected) 102 self.bridge.register_method("isConnected", self.isConnected)
103 self.bridge.register("launchAction", self.launchCallback) 103 self.bridge.register_method("launchAction", self.launchCallback)
104 self.bridge.register("actionsGet", self.actionsGet) 104 self.bridge.register_method("actionsGet", self.actionsGet)
105 self.bridge.register("progressGet", self._progressGet) 105 self.bridge.register_method("progressGet", self._progressGet)
106 self.bridge.register("progressGetAll", self._progressGetAll) 106 self.bridge.register_method("progressGetAll", self._progressGetAll)
107 self.bridge.register("getMenus", self.getMenus) 107 self.bridge.register_method("getMenus", self.getMenus)
108 self.bridge.register("getMenuHelp", self.getMenuHelp) 108 self.bridge.register_method("getMenuHelp", self.getMenuHelp)
109 self.bridge.register("discoInfos", self.memory.disco._discoInfos) 109 self.bridge.register_method("discoInfos", self.memory.disco._discoInfos)
110 self.bridge.register("discoItems", self.memory.disco._discoItems) 110 self.bridge.register_method("discoItems", self.memory.disco._discoItems)
111 self.bridge.register("saveParamsTemplate", self.memory.save_xml) 111 self.bridge.register_method("saveParamsTemplate", self.memory.save_xml)
112 self.bridge.register("loadParamsTemplate", self.memory.load_xml) 112 self.bridge.register_method("loadParamsTemplate", self.memory.load_xml)
113 113
114 self.memory.initialized.addCallback(self._postMemoryInit) 114 self.memory.initialized.addCallback(self._postMemoryInit)
115 115
116 @property 116 @property
117 def version(self): 117 def version(self):