Mercurial > libervia-backend
comparison sat_frontends/bridge/dbus_bridge.py @ 3254:6cf4bd6972c2
core, frontends: avatar refactoring:
/!\ huge commit
Avatar logic has been reworked around the IDENTITY plugin: plugins able to handle avatar
or other identity related metadata (like nicknames) register to IDENTITY plugin in the
same way as for other features like download/upload. Once registered, IDENTITY plugin will
call them when suitable in order of priority, and handle caching.
Methods to manage those metadata from frontend now use serialised data.
For now `avatar` and `nicknames` are handled:
- `avatar` is now a dict with `path` + metadata like `media_type`, instead of just a string
path
- `nicknames` is now a list of nicknames in order of priority. This list is never empty,
and `nicknames[0]` should be the preferred nickname to use by frontends in most cases.
In addition to contact specified nicknames, user set nickname (the one set in roster) is
used in priority when available.
Among the side changes done with this commit, there are:
- a new `contactGet` bridge method to get roster metadata for a single contact
- SatPresenceProtocol.send returns a Deferred to check when it has actually been sent
- memory's methods to handle entities data now use `client` as first argument
- metadata filter can be specified with `getIdentity`
- `getAvatar` and `setAvatar` are now part of the IDENTITY plugin instead of XEP-0054 (and
there signature has changed)
- `isRoom` and `getBareOrFull` are now part of XEP-0045 plugin
- jp avatar/get command uses `xdg-open` first when available for `--show` flag
- `--no-cache` has been added to jp avatar/get and identity/get
- jp identity/set has been simplified, explicit options (`--nickname` only for now) are
used instead of `--field`. `--field` may come back in the future if necessary for extra
data.
- QuickContactList `SetContact` now handle None as a value, and doesn't use it to delete the
metadata anymore
- improved cache handling for `metadata` and `nicknames` in quick frontend
- new `default` argument in QuickContactList `getCache`
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 14 Apr 2020 21:00:33 +0200 |
parents | 6d0137022df2 |
children | f300d78f08f3 |
comparison
equal
deleted
inserted
replaced
3253:1af840e84af7 | 3254:6cf4bd6972c2 |
---|---|
206 if errback is None: | 206 if errback is None: |
207 errback = log.error | 207 errback = log.error |
208 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 208 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
209 return self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 209 return self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
210 | 210 |
211 def contactGet(self, arg_0, profile_key="@DEFAULT@", callback=None, errback=None): | |
212 if callback is None: | |
213 error_handler = None | |
214 else: | |
215 if errback is None: | |
216 errback = log.error | |
217 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
218 return self.db_core_iface.contactGet(arg_0, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | |
219 | |
211 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): | 220 def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None): |
212 if callback is None: | 221 if callback is None: |
213 error_handler = None | 222 error_handler = None |
214 else: | 223 else: |
215 if errback is None: | 224 if errback is None: |
881 error_handler = None | 890 error_handler = None |
882 else: | 891 else: |
883 if errback is None: | 892 if errback is None: |
884 errback = log.error | 893 errback = log.error |
885 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 894 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
886 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 895 kwargs={} |
896 if callback is not None: | |
897 kwargs['timeout'] = const_TIMEOUT | |
898 kwargs['reply_handler'] = callback | |
899 kwargs['error_handler'] = error_handler | |
900 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key, **kwargs) | |
887 | 901 |
888 | 902 |
889 class AIOBridge(Bridge): | 903 class AIOBridge(Bridge): |
890 | 904 |
891 def register_signal(self, functionName, handler, iface="core"): | 905 def register_signal(self, functionName, handler, iface="core"): |
973 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 987 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
974 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 988 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |
975 self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | 989 self.db_core_iface.connect(profile_key, password, options, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) |
976 return fut | 990 return fut |
977 | 991 |
992 def contactGet(self, arg_0, profile_key="@DEFAULT@"): | |
993 loop = asyncio.get_running_loop() | |
994 fut = loop.create_future() | |
995 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | |
996 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | |
997 self.db_core_iface.contactGet(arg_0, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | |
998 return fut | |
999 | |
978 def delContact(self, entity_jid, profile_key="@DEFAULT@"): | 1000 def delContact(self, entity_jid, profile_key="@DEFAULT@"): |
979 loop = asyncio.get_running_loop() | 1001 loop = asyncio.get_running_loop() |
980 fut = loop.create_future() | 1002 fut = loop.create_future() |
981 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 1003 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
982 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 1004 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |