Mercurial > libervia-backend
comparison frontends/src/bridge/dbus_bridge.py @ 2144:1d3f73e065e1
core, jp: component handling + client handling refactoring:
- SàT can now handle components
- plugin have now a "modes" key in PLUGIN_INFO where they declare if they can be used with clients and or components. They default to be client only.
- components are really similar to clients, but with some changes in behaviour:
* component has "entry point", which is a special plugin with a componentStart method, which is called just after component is connected
* trigger end with a different suffixes (e.g. profileConnected vs profileConnectedComponent), so a plugin which manage both clients and components can have different workflow
* for clients, only triggers of plugins handling client mode are launched
* for components, only triggers of plugins needed in dependencies are launched. They all must handle component mode.
* component have a sendHistory attribute (False by default) which can be set to True to allow saving sent messages into history
* for convenience, "client" is still used in method even if it can now be a component
* a new "component" boolean attribute tells if we have a component or a client
* components have to add themselve Message protocol
* roster and presence protocols are not added for components
* component default port is 5347 (which is Prosody's default port)
- asyncCreateProfile has been renamed for profileCreate, both to follow new naming convention and to prepare the transition to fully asynchronous bridge
- createProfile has a new "component" attribute. When used to create a component, it must be set to a component entry point
- jp: added --component argument to profile/create
- disconnect bridge method is now asynchronous, this way frontends can know when disconnection is finished
- new PI_* constants for PLUGIN_INFO values (not used everywhere yet)
- client/component connection workflow has been moved to their classes instead of being a host methods
- host.messageSend is now client.sendMessage, and former client.sendMessage is now client.sendMessageData.
- identities are now handled in client.identities list, so it can be updated dynamically by plugins (in the future, frontends should be able to update them too through bridge)
- profileConnecting* profileConnected* profileDisconnected* and getHandler now all use client instead of profile
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Feb 2017 17:55:43 +0100 |
parents | be96beb7ca14 |
children | 1bb9bf1b4150 |
comparison
equal
deleted
inserted
replaced
2143:c3cac21157d4 | 2144:1d3f73e065e1 |
---|---|
162 kwargs['timeout'] = const_TIMEOUT | 162 kwargs['timeout'] = const_TIMEOUT |
163 kwargs['reply_handler'] = callback | 163 kwargs['reply_handler'] = callback |
164 kwargs['error_handler'] = error_handler | 164 kwargs['error_handler'] = error_handler |
165 return self.db_core_iface.addContact(entity_jid, profile_key, **kwargs) | 165 return self.db_core_iface.addContact(entity_jid, profile_key, **kwargs) |
166 | 166 |
167 def asyncCreateProfile(self, profile, password='', callback=None, errback=None): | |
168 if callback is None: | |
169 error_handler = None | |
170 else: | |
171 if errback is None: | |
172 errback = log.error | |
173 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
174 return self.db_core_iface.asyncCreateProfile(profile, password, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | |
175 | |
176 def asyncDeleteProfile(self, profile, callback=None, errback=None): | 167 def asyncDeleteProfile(self, profile, callback=None, errback=None): |
177 if callback is None: | 168 if callback is None: |
178 error_handler = None | 169 error_handler = None |
179 else: | 170 else: |
180 if errback is None: | 171 if errback is None: |
241 error_handler = None | 232 error_handler = None |
242 else: | 233 else: |
243 if errback is None: | 234 if errback is None: |
244 errback = log.error | 235 errback = log.error |
245 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 236 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
246 kwargs={} | 237 return self.db_core_iface.disconnect(profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
247 if callback is not None: | |
248 kwargs['timeout'] = const_TIMEOUT | |
249 kwargs['reply_handler'] = callback | |
250 kwargs['error_handler'] = error_handler | |
251 return self.db_core_iface.disconnect(profile_key, **kwargs) | |
252 | 238 |
253 def getConfig(self, section, name, callback=None, errback=None): | 239 def getConfig(self, section, name, callback=None, errback=None): |
254 if callback is None: | 240 if callback is None: |
255 error_handler = None | 241 error_handler = None |
256 else: | 242 else: |
558 kwargs['timeout'] = const_TIMEOUT | 544 kwargs['timeout'] = const_TIMEOUT |
559 kwargs['reply_handler'] = callback | 545 kwargs['reply_handler'] = callback |
560 kwargs['error_handler'] = error_handler | 546 kwargs['error_handler'] = error_handler |
561 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app, **kwargs) | 547 return self.db_core_iface.paramsRegisterApp(xml, security_limit, app, **kwargs) |
562 | 548 |
549 def profileCreate(self, profile, password='', component='', callback=None, errback=None): | |
550 if callback is None: | |
551 error_handler = None | |
552 else: | |
553 if errback is None: | |
554 errback = log.error | |
555 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
556 return self.db_core_iface.profileCreate(profile, password, component, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | |
557 | |
563 def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None): | 558 def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None): |
564 if callback is None: | 559 if callback is None: |
565 error_handler = None | 560 error_handler = None |
566 else: | 561 else: |
567 if errback is None: | 562 if errback is None: |