Commit graph libervia-backend/sat/core/constants.py
Author SHA1 Message Date
Goffi
018d09caaa Renamed the project from "Salut à Toi" to "Libervia":
This renaming follows the decision taken at the General Assemblee of January 27th 2021 (cf.
https://repos.goffi.org/sat_docs/raw-file/tip/association/2021-01-27%20-%20compte%20rendu%20de%20l%27AG%20extraordinaire.pdf)
2021-03-20 20:42:04 +01:00
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
3f9e61662c core (constants): added EXIT_CONFLICT 2020-12-04 12:30:46 +01:00
Goffi
883a07c591 core (constants): moved shell exit code constants to core constants:
Well defined shell exit code are generally useful, not only for jp, thus constants have been
moved to core.
2020-11-12 14:53:15 +01:00
Goffi
63e61fc036 plugin XEP-0353: Jingle Message Initiation implementation:
This plugin uses the new `XEP-0166_initiate` trigger to initiate a Jingle session with
messages if the peer jid has no resource specified.
On reception, if the sender is not in our roster, a confirmation is requested to user to
avoid leaking presence and IP. If user refuses the session for somebody not in roster,
nothing is sent at all (the request is just ignored).
2020-11-12 14:53:15 +01:00
Goffi
59b7820b3f core: sat.conf is now first checked in /etc/_sat.conf for system-related settings 2020-10-15 16:13:30 +02:00
Goffi
b5a872aed3 core (constants): added theme key 2020-05-18 23:30:55 +02:00
Goffi
88072e0453 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`
2020-04-14 21:00:33 +02:00
Goffi
ddf8cf6ea7 plugin attach: handle large images resizing:
if `C.MESS_KEY_ATTACHMENTS_RESIZE` flag is set for an attachment, it will be checked, and
if it is a large image, a resized copy will be uploaded.
2020-03-22 14:04:16 +01:00
Goffi
3686d7e036 core, bridge: new imageGeneratePreview helped method to generate a thumbnail 2020-03-01 18:48:06 +01:00
Goffi
8777bd07cb tools (images): max_size can now be manually specified in checkImage and dest in resizeImage:
`context` has been removed as it is not used and doesn't seem that useful.
2020-03-01 18:47:05 +01:00
Goffi
7924b601ab core (constants): renamed MESS_KEY_MEDIA_TYPE to MESS_KEY_ATTACHMENTS_MEDIA_TYPE 2020-02-29 16:55:22 +01:00
Goffi
48c56ee57e memory(cache): extend EOL when a file metadata is retrieved 2020-02-26 22:03:15 +01:00
Goffi
f71b40f86f plugin download: use cache if dest_path is empty:
if dest_path is not set, the file will be downloaded in cache. A new name will be
generated using a hash of the uri. If the file is already downloded in cache, it won't be
downloaded again (in this case returned progress_id is an empty string).
2020-02-26 22:03:11 +01:00
Goffi
5b0e084a5d core (xmpp): new message key to handle attachments 2020-02-18 18:17:14 +01:00
Goffi
3d86f0c983 core (constants): use parent of "sat" module dir as last config path 2020-01-29 19:28:08 +01:00
Goffi
6be3915b55 core (constants): missing trailing / 2020-01-29 19:21:16 +01:00
Goffi
21591bce92 core (constants): don't parse sat.conf from current dir anymore + parse root_dir last 2020-01-29 19:12:46 +01:00
Goffi
7f2c6cd8a6 core (constants): parse sat.conf from sat module dir 2020-01-29 19:05:41 +01:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
c82ca04673 android: deactivate annoying jnius logs when DEBUG is set 2020-01-27 19:52:46 +01:00
Goffi
f9a034509c plugin sec aesgcm: new plugin handling aesgcm: scheme for e2e encrypted media sharing:
The scheme is register with download meta plugin, and it is activated with HTTP Upload
(XEP-0363) when `encryption` is used in `options` with the value of C.ENC_AES_GCM.
This is also known as `OMEMO Media Sharing` even if this method is not directly linked to
OMEMO and can be used independently.
2019-12-20 12:28:04 +01:00
Goffi
93a4e488ea core: added imageCheck and imageResize methods:
imageCheck will give a report on image, notably it will tell if it's too big and needs to
be resized before a transfer.

imageResize will create a new image with the requested size and return a path to it.
2019-10-29 20:38:39 +01:00
Goffi
76aadbb3fb jp: jp asyncio port:
/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\

This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).

During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
2019-09-25 08:56:41 +02:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
d21a6a660f 0.8 development starts 2019-07-31 11:31:22 +02:00
Goffi
5e43c6c98c core, plugin XEP-0045: fixed message type autodetection + ENTITY_TYPE_MUC constant:
an old hardcoded value was used in several places to detect if an entity is a MUC, but this
value was not valid anymore. This has been fixed, and ENTITY_TYPE_MUC constant is now used
instead. This fixes message type autodetection for "groupchat" messages.

fixes 300
2019-07-09 09:06:45 +02:00
Goffi
218390a0d9 logs: increased defaut limit for memory output to 300 2019-06-30 15:40:52 +02:00
Goffi
ffb051fca2 core (constants): fixed flatpak config paths for older versions of flatpak:
Older versions of Flatpak don't seem to set FLATPAK_ID, but do set FLATPAK_SANDBOX_DIR, so
this is now checked too to detect flatpak.
2019-06-30 15:39:58 +02:00
Goffi
29c4e048df core (constants): fixed Flatpak config path:
trailing "/" was missing in flatpak config path, resulting in the configuration not being read properly on this platform.
2019-06-27 20:26:00 +02:00
Goffi
e85c55f7a0 core (config): if flatpak is detected, config is also looked after in /app 2019-06-23 17:40:19 +02:00
Goffi
a090b76afd core (constants): added generic constants for "info", "warning" and "error" levels 2019-05-26 22:22:01 +02:00
Goffi
a782b6e6e0 core (constants): "on" can now be used as True value in bool method. 2019-05-26 22:22:00 +02:00
Goffi
1f7d5bfd94 constants: added KEY_LANG which is the key/name used in templates to change language/locale. 2019-04-10 21:04:51 +02:00
Goffi
e89135b8ae plugin XEP-0384: give feedback to client when encryption failed 2019-03-20 09:08:47 +01:00
Goffi
8e338bf913 date update 2019-01-12 12:25:31 +01:00
Goffi
3e63d54e3d plugins XEP-0060, XEP-0313: implemented Order-By protoXEP:
new "order_by" key can be used in extra data, value can be, for now, "creation" or "modification".
2019-01-06 17:36:51 +01:00
Goffi
02dc38762e core (constants): added a constant for "encrypted" 2019-01-04 18:46:02 +01:00
Goffi
ed049c7a9d core: removed whitespace ping (not needed anymore as we handle XMPP ping) 2018-11-19 21:08:25 +01:00
Goffi
05b59775d0 plugin XEP-0198: Stream Management implementation:
- hooks can now be set in stream onElement and send methods
- xmllog refactored to use new hooks
- client.isConnected now uses transport.connected method
- fixed reconnection, SàT will now try to reconnect indefinitely until it success, unresolvable failure happen (e.g. invalid certificate), or explicit disconnection is requested (or a plugin change this behaviour)
- new triggers: "stream_hooks", "disconnecting", "disconnected", and "xml_init" (replace "XML Initialized")
2018-11-18 15:49:46 +01:00
Goffi
18a4d3d544 core: fixed package name for Android 2018-10-05 13:42:06 +02:00
Goffi
e70405cfc2 tools (common/template), jp: refactoring to handle multiple sites:
- site can now be specified in template header before theme, for instance: (some_site/some_theme)path/to/template.ext
- absolute template paths are now implemented, but Renderer must be instanciated with trusted to True for security reason (it's the case for jp)
- a new "front_url_filter" callable can be given to Renderer, which will convert template path to URL seen by end-user (default to real path).
- the "front_url_filter" can be used in templates with… "front_url" filter
- template_data is a new named tuple available in templates, which give site, theme and template relative URL
- search order is site/theme, site/default_theme, and default/default_theme where default link to sat_pubsub templates
- when loading CSS files, files with _noscript suffixes are now loaded, and used when javascript is not available
- "styles_extra.css" is also loaded before "styles.css", useful when a theme want to reuse default style, and just override some rules
- new site can be specified in sat.conf [DEFAULT] section, using sites_path_public_dict or sites_path_private_dict (where sites_path_private_dict won't be used in public frontends, like Libervia)
- "private" argument of Renderer tells the renderer to load private sites or not
- templates are now loaded from "templates" subdirectory, to differenciate them from other data like i18n
- jp template output has been updated to handle those changes, and to manage absolute templates
2018-09-10 08:58:18 +02:00
Goffi
32b4db60c9 core: new EncryptionHandler class which manage encrypted session as a core feature:
Plugin handling encryption can now register using host.registerEncryptionPlugin, and an encryption session can now be started using messageEncryptionStart bridge method.

This will make encryption handling more easy, as we now know if a session is clear or e2e encrypted, and which plugin handle it.
2018-07-29 19:22:56 +02:00
Goffi
f2b1398a9f core, frontends: replaced org\.goffi namespaces by org.salutatoi + fixed generation:
generation of D-Bus bridge has been broken by black formatting tool, this patch fixes this.
2018-07-01 20:37:58 +02:00
Goffi
744cb0c503 code style reformatting using black 2018-06-27 20:14:46 +02:00
Goffi
785af76bc0 tools (common): moved date_fmt function from template filters to new date_utils module, so it can be used everywhere. 2018-06-01 12:04:06 +02:00
Goffi
37c73105e0 core (constants): new downloads_dir config option (default path where files can be downloaded):
use Android API to find downloads_dir on this platform
2018-05-25 10:51:59 +02:00
Goffi
c43f8e6205 core (constants): updated Android constants for Cagou 2018-04-13 18:44:22 +02:00
Goffi
ac954f378d setup: version is now set in SAT/VERSION, sat is not imported anymore in setup 2018-04-05 10:41:08 +02:00