Mercurial > libervia-backend
annotate libervia/backend/core/constants.py @ 4194:3dbaf179c50d
core (launcher): new `wait_for_service` option:
if `wait_for_service` is used in `[DEFAULT]`, the service at the specified host/port is
waited for before starting the backend. This is useful in the situation where we need to
be sure that something is started before running, e.g. in a container.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 13 Dec 2023 22:00:25 +0100 |
parents | 50c919dfe61b |
children | b26339343076 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 2 |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
3 # Libervia: an XMPP client |
3479 | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
914
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
1112
e51e69b7732d
core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
19 try: |
e51e69b7732d
core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
20 from xdg import BaseDirectory |
1004
191f440d11b4
core (constants): use realpath instead of abspath + do not import it when building libervia
souliane <souliane@mailoo.org>
parents:
1003
diff
changeset
|
21 from os.path import expanduser, realpath |
1112
e51e69b7732d
core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
22 except ImportError: |
e51e69b7732d
core (constants): better management of xdg import
Goffi <goffi@goffi.org>
parents:
1111
diff
changeset
|
23 BaseDirectory = None |
3146
320b762cbdf0
core (constants): missing trailing `/`
Goffi <goffi@goffi.org>
parents:
3145
diff
changeset
|
24 from os.path import dirname |
4171
da7d360a87be
core (constants): user platform temporary dir by default for PID files
Goffi <goffi@goffi.org>
parents:
4166
diff
changeset
|
25 import tempfile |
4056
1c4f4aa36d98
plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
4038
diff
changeset
|
26 from typing import Final |
4171
da7d360a87be
core (constants): user platform temporary dir by default for PID files
Goffi <goffi@goffi.org>
parents:
4166
diff
changeset
|
27 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4056
diff
changeset
|
28 from libervia import backend |
930
cbf4122baae7
core, memory: use XDG recommended paths as the defaults for the config and local directories
souliane <souliane@mailoo.org>
parents:
926
diff
changeset
|
29 |
914
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
1a3ba959f0ab
core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 class Const(object): |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
32 |
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
33 ## Application ## |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
34 APP_NAME = "Libervia" |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
35 APP_COMPONENT = "backend" |
4038
c484c2609275
core (constants): fix URL, forgotten `SàT` reference + set new codename to "La Ruche"
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
36 APP_NAME_ALT = "Libervia" |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
37 APP_NAME_FILE = "libervia" |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
38 APP_NAME_FULL = f"{APP_NAME} ({APP_COMPONENT})" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
39 APP_VERSION = ( |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4056
diff
changeset
|
40 backend.__version__ |
4079
10b6ad569157
version: use standard Python's `dev0` instead of Libervia specific `D` for dev version
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
41 ) |
4038
c484c2609275
core (constants): fix URL, forgotten `SàT` reference + set new codename to "La Ruche"
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
42 APP_RELEASE_NAME = "La Ruche" |
c484c2609275
core (constants): fix URL, forgotten `SàT` reference + set new codename to "La Ruche"
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
43 APP_URL = "https://libervia.org" |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
44 |
2105
c96fe007ca41
core(constants): added a constant for profile extension (PLUGIN_EXT):
Goffi <goffi@goffi.org>
parents:
2089
diff
changeset
|
45 ## Runtime ## |
c96fe007ca41
core(constants): added a constant for profile extension (PLUGIN_EXT):
Goffi <goffi@goffi.org>
parents:
2089
diff
changeset
|
46 PLUGIN_EXT = "py" |
3028 | 47 HISTORY_SKIP = "skip" |
2105
c96fe007ca41
core(constants): added a constant for profile extension (PLUGIN_EXT):
Goffi <goffi@goffi.org>
parents:
2089
diff
changeset
|
48 |
c96fe007ca41
core(constants): added a constant for profile extension (PLUGIN_EXT):
Goffi <goffi@goffi.org>
parents:
2089
diff
changeset
|
49 ## Main config ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
50 DEFAULT_BRIDGE = "dbus" |
2088
c02f96756d5c
core: bridge can now be changed in conf
Goffi <goffi@goffi.org>
parents:
2035
diff
changeset
|
51 |
2105
c96fe007ca41
core(constants): added a constant for profile extension (PLUGIN_EXT):
Goffi <goffi@goffi.org>
parents:
2089
diff
changeset
|
52 ## Protocol ## |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
53 XMPP_C2S_PORT = 5222 |
2691
1ecceac3df96
plugin XEP-0198: Stream Management implementation:
Goffi <goffi@goffi.org>
parents:
2684
diff
changeset
|
54 XMPP_MAX_RETRIES = None |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
55 # default port used on Prosody, may differ on other servers |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
56 XMPP_COMPONENT_PORT = 5347 |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
57 |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
58 ## Parameters ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
59 NO_SECURITY_LIMIT = -1 # FIXME: to rename |
2126 | 60 SECURITY_LIMIT_MAX = 0 |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
61 INDIVIDUAL = "individual" |
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
62 GENERAL = "general" |
1222
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
63 # General parameters |
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
64 HISTORY_LIMIT = "History" |
1227
4da2e4d58bd0
memory (params): add parameters "Show offline contacts" and "Show empty groups"
souliane <souliane@mailoo.org>
parents:
1222
diff
changeset
|
65 SHOW_OFFLINE_CONTACTS = "Offline contacts" |
4da2e4d58bd0
memory (params): add parameters "Show offline contacts" and "Show empty groups"
souliane <souliane@mailoo.org>
parents:
1222
diff
changeset
|
66 SHOW_EMPTY_GROUPS = "Empty groups" |
1088
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
67 # Parameters related to connection |
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
68 FORCE_SERVER_PARAM = "Force server" |
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
69 FORCE_PORT_PARAM = "Force port" |
1030
15f43b54d697
core, memory, bridge: added profile password + password encryption:
souliane <souliane@mailoo.org>
parents:
1020
diff
changeset
|
70 # Parameters related to encryption |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
71 PROFILE_PASS_PATH = ("General", "Password") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
72 MEMORY_CRYPTO_NAMESPACE = "crypto" # for the private persistent binary dict |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
73 MEMORY_CRYPTO_KEY = "personal_key" |
1020
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
74 # Parameters for static blog pages |
2126 | 75 # FIXME: blog constants should not be in core constants |
1020
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
76 STATIC_BLOG_KEY = "Blog page" |
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
77 STATIC_BLOG_PARAM_TITLE = "Title" |
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
78 STATIC_BLOG_PARAM_BANNER = "Banner" |
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
79 STATIC_BLOG_PARAM_KEYWORDS = "Keywords" |
adbde4a3a52f
plugin misc_static_blog: renamed from tmp_blog_banner, now also with page's title, meta keywords and description
souliane <souliane@mailoo.org>
parents:
1017
diff
changeset
|
80 STATIC_BLOG_PARAM_DESCRIPTION = "Description" |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
81 |
1092
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
82 ## Menus ## |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
83 MENU_GLOBAL = "GLOBAL" |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
84 MENU_ROOM = "ROOM" |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
85 MENU_SINGLE = "SINGLE" |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
86 MENU_JID_CONTEXT = "JID_CONTEXT" |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
87 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT" |
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
88 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT" |
1357
f296a54af386
core (constants): add menu type MENU_ROOM_OCCUPANT_CONTEXT
souliane <souliane@mailoo.org>
parents:
1298
diff
changeset
|
89 MENU_ROOM_OCCUPANT_CONTEXT = "MENU_ROOM_OCCUPANT_CONTEXT" |
1092
0eefc74c346b
core (menus): constants are used for menu types
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
90 |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
91 ## Profile and entities ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
92 PROF_KEY_NONE = "@NONE@" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
93 PROF_KEY_DEFAULT = "@DEFAULT@" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
94 PROF_KEY_ALL = "@ALL@" |
4184
50c919dfe61b
plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents:
4171
diff
changeset
|
95 #: anybody |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
96 ENTITY_ALL = "@ALL@" |
4184
50c919dfe61b
plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents:
4171
diff
changeset
|
97 #: Bare jids of administrators |
50c919dfe61b
plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents:
4171
diff
changeset
|
98 ENTITY_ADMINS = "@ADMIN@" |
50c919dfe61b
plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents:
4171
diff
changeset
|
99 #: bare jid of client's profile |
50c919dfe61b
plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents:
4171
diff
changeset
|
100 ENTITY_PROFILE_BARE = "@PROFILE_BAREJID@" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
101 ENTITY_ALL_RESOURCES = "@ALL_RESOURCES@" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
102 ENTITY_MAIN_RESOURCE = "@MAIN_RESOURCE@" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
103 ENTITY_CAP_HASH = "CAP_HASH" |
2994
94708a7d3ecf
core, plugin XEP-0045: fixed message type autodetection + ENTITY_TYPE_MUC constant:
Goffi <goffi@goffi.org>
parents:
2975
diff
changeset
|
104 ENTITY_TYPE = "type" |
94708a7d3ecf
core, plugin XEP-0045: fixed message type autodetection + ENTITY_TYPE_MUC constant:
Goffi <goffi@goffi.org>
parents:
2975
diff
changeset
|
105 ENTITY_TYPE_MUC = "MUC" |
1520
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
106 |
1450
7797dda847ae
plugins xep-0277, groupblog: added subscriteToMany to replace massiveSubscribeGroupBlogs + added SatRosterProtocol.getJidsSet
Goffi <goffi@goffi.org>
parents:
1448
diff
changeset
|
107 ## Roster jids selection ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
108 PUBLIC = "PUBLIC" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
109 ALL = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
110 "ALL" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
111 ) # ALL means all known contacts, while PUBLIC means everybody, known or not |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
112 GROUP = "GROUP" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
113 JID = "JID" |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
114 |
1171
0abce7f17782
core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents:
1143
diff
changeset
|
115 ## Messages ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
116 MESS_TYPE_INFO = "info" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
117 MESS_TYPE_CHAT = "chat" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
118 MESS_TYPE_ERROR = "error" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
119 MESS_TYPE_GROUPCHAT = "groupchat" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
120 MESS_TYPE_HEADLINE = "headline" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
121 MESS_TYPE_NORMAL = "normal" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
122 MESS_TYPE_AUTO = "auto" # magic value to let the backend guess the type |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
123 MESS_TYPE_STANDARD = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
124 MESS_TYPE_CHAT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
125 MESS_TYPE_ERROR, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
126 MESS_TYPE_GROUPCHAT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
127 MESS_TYPE_HEADLINE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
128 MESS_TYPE_NORMAL, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
129 ) |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1959
diff
changeset
|
130 MESS_TYPE_ALL = MESS_TYPE_STANDARD + (MESS_TYPE_INFO, MESS_TYPE_AUTO) |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1959
diff
changeset
|
131 |
4148
a8a0fa678ce2
bridge: add `message_update` signal
Goffi <goffi@goffi.org>
parents:
4132
diff
changeset
|
132 # Update |
a8a0fa678ce2
bridge: add `message_update` signal
Goffi <goffi@goffi.org>
parents:
4132
diff
changeset
|
133 |
a8a0fa678ce2
bridge: add `message_update` signal
Goffi <goffi@goffi.org>
parents:
4132
diff
changeset
|
134 MESS_UPDATE_EDIT = "EDIT" |
a8a0fa678ce2
bridge: add `message_update` signal
Goffi <goffi@goffi.org>
parents:
4132
diff
changeset
|
135 MESS_UPDATE_REACTION = "REACTION" |
4166
a1f7040b5a15
plugin XEP-0424: message retraction update:
Goffi <goffi@goffi.org>
parents:
4163
diff
changeset
|
136 MESS_UPDATE_RETRACT = "RETRACT" |
4148
a8a0fa678ce2
bridge: add `message_update` signal
Goffi <goffi@goffi.org>
parents:
4132
diff
changeset
|
137 |
3028 | 138 MESS_EXTRA_INFO = "info_type" |
139 EXTRA_INFO_DECR_ERR = "DECRYPTION_ERROR" | |
140 EXTRA_INFO_ENCR_ERR = "ENCRYPTION_ERROR" | |
4163
3b3cd9453d9b
plugin XEP-0308: implement Last Message Correction
Goffi <goffi@goffi.org>
parents:
4148
diff
changeset
|
141 MESS_EXTRA_EDITIONS = "editions" |
1263 | 142 |
2752
1fa615faec8b
core (constants): added a constant for "encrypted"
Goffi <goffi@goffi.org>
parents:
2694
diff
changeset
|
143 # encryption is a key for plugins |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3794
diff
changeset
|
144 MESS_KEY_ENCRYPTION: Final = "ENCRYPTION" |
2752
1fa615faec8b
core (constants): added a constant for "encrypted"
Goffi <goffi@goffi.org>
parents:
2694
diff
changeset
|
145 # encrypted is a key for frontends |
3028 | 146 MESS_KEY_ENCRYPTED = "encrypted" |
147 MESS_KEY_TRUSTED = "trusted" | |
2646
712cb4ff3e13
core: new EncryptionHandler class which manage encrypted session as a core feature:
Goffi <goffi@goffi.org>
parents:
2628
diff
changeset
|
148 |
3090
4f8bdf50593f
plugin sec aesgcm: new plugin handling `aesgcm:` scheme for e2e encrypted media sharing:
Goffi <goffi@goffi.org>
parents:
3066
diff
changeset
|
149 # File encryption algorithms |
4f8bdf50593f
plugin sec aesgcm: new plugin handling `aesgcm:` scheme for e2e encrypted media sharing:
Goffi <goffi@goffi.org>
parents:
3066
diff
changeset
|
150 ENC_AES_GCM = "AES-GCM" |
4f8bdf50593f
plugin sec aesgcm: new plugin handling `aesgcm:` scheme for e2e encrypted media sharing:
Goffi <goffi@goffi.org>
parents:
3066
diff
changeset
|
151 |
2460
feaacc462fef
core: moved CHAT_* constants from frontends to core constants + uses constants for MESS_TYPE_* in sendMessage
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
152 ## Chat ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
153 CHAT_ONE2ONE = "one2one" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
154 CHAT_GROUP = "group" |
2460
feaacc462fef
core: moved CHAT_* constants from frontends to core constants + uses constants for MESS_TYPE_* in sendMessage
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
155 |
1776
4fc1bf1af48f
plugin XEP-0313: cleaning and improvments:
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
156 ## Presence ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
157 PRESENCE_UNAVAILABLE = "unavailable" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
158 PRESENCE_SHOW_AWAY = "away" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
159 PRESENCE_SHOW_CHAT = "chat" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
160 PRESENCE_SHOW_DND = "dnd" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
161 PRESENCE_SHOW_XA = "xa" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
162 PRESENCE_SHOW = "show" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
163 PRESENCE_STATUSES = "statuses" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
164 PRESENCE_STATUSES_DEFAULT = "default" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
165 PRESENCE_PRIORITY = "priority" |
1171
0abce7f17782
core: a new "info" type is used in newMessage for system messages (not comming from outside)
Goffi <goffi@goffi.org>
parents:
1143
diff
changeset
|
166 |
1776
4fc1bf1af48f
plugin XEP-0313: cleaning and improvments:
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
167 ## Common namespaces ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
168 NS_XML = "http://www.w3.org/XML/1998/namespace" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
169 NS_CLIENT = "jabber:client" |
4011
74d4c9ff893d
plugin XEP-0277: when publisher is not found, check ancestor in both client and component namespaces
Goffi <goffi@goffi.org>
parents:
3934
diff
changeset
|
170 NS_COMPONENT = "jabber:component:accept" |
74d4c9ff893d
plugin XEP-0277: when publisher is not found, check ancestor in both client and component namespaces
Goffi <goffi@goffi.org>
parents:
3934
diff
changeset
|
171 NS_STREAM = (NS_CLIENT, NS_COMPONENT) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
172 NS_FORWARD = "urn:xmpp:forward:0" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
173 NS_DELAY = "urn:xmpp:delay" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
174 NS_XHTML = "http://www.w3.org/1999/xhtml" |
1776
4fc1bf1af48f
plugin XEP-0313: cleaning and improvments:
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
175 |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
176 ## Common XPath ## |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
177 |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
178 IQ_GET = '/iq[@type="get"]' |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
179 IQ_SET = '/iq[@type="set"]' |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
180 |
2109
85f3e12e984d
core (memory/cache): file caching handling, first draft:
Goffi <goffi@goffi.org>
parents:
2105
diff
changeset
|
181 ## Directories ## |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
182 |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
183 # directory for components specific data |
3028 | 184 COMPONENTS_DIR = "components" |
185 CACHE_DIR = "cache" | |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
186 # files in file dir are stored for long term |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
187 # files dir is global, i.e. for all profiles |
3028 | 188 FILES_DIR = "files" |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
189 # FILES_LINKS_DIR is a directory where files owned by a specific profile |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
190 # are linked to the global files directory. This way the directory can be |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
191 # shared per profiles while keeping global directory where identical files |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
192 # shared between different profiles are not duplicated. |
3028 | 193 FILES_LINKS_DIR = "files_links" |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
194 # FILES_TMP_DIR is where profile's partially transfered files are put. |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
195 # Once transfer is completed, they are moved to FILES_DIR |
3028 | 196 FILES_TMP_DIR = "files_tmp" |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
197 |
2169
f472179305a1
tools(templates): workflow improvments:
Goffi <goffi@goffi.org>
parents:
2154
diff
changeset
|
198 ## Templates ## |
3028 | 199 TEMPLATE_TPL_DIR = "templates" |
200 TEMPLATE_THEME_DEFAULT = "default" | |
201 TEMPLATE_STATIC_DIR = "static" | |
3269
1352564e0202
core (constants): added `theme` key
Goffi <goffi@goffi.org>
parents:
3254
diff
changeset
|
202 # templates i18n |
1352564e0202
core (constants): added `theme` key
Goffi <goffi@goffi.org>
parents:
3254
diff
changeset
|
203 KEY_LANG = "lang" |
1352564e0202
core (constants): added `theme` key
Goffi <goffi@goffi.org>
parents:
3254
diff
changeset
|
204 KEY_THEME = "theme" |
926
d609581bf74a
plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents:
923
diff
changeset
|
205 |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
206 ## Plugins ## |
1520
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
207 |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
208 # PLUGIN_INFO keys |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
209 # XXX: we use PI instead of PLUG_INFO which would normally be used |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
210 # to make the header more readable |
3028 | 211 PI_NAME = "name" |
212 PI_IMPORT_NAME = "import_name" | |
213 PI_MAIN = "main" | |
214 PI_HANDLER = "handler" | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
215 PI_TYPE = ( |
3028 | 216 "type" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
217 ) # FIXME: should be types, and should handle single unicode type or tuple of types (e.g. "blog" and "import") |
3028 | 218 PI_MODES = "modes" |
219 PI_PROTOCOLS = "protocols" | |
220 PI_DEPENDENCIES = "dependencies" | |
221 PI_RECOMMENDATIONS = "recommendations" | |
222 PI_DESCRIPTION = "description" | |
223 PI_USAGE = "usage" | |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
224 |
1520
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
225 # Types |
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
226 PLUG_TYPE_XEP = "XEP" |
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
227 PLUG_TYPE_MISC = "MISC" |
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
228 PLUG_TYPE_EXP = "EXP" |
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
229 PLUG_TYPE_SEC = "SEC" |
1806
fd788d24277a
plugin syntax dc_wiki: first draft:
Goffi <goffi@goffi.org>
parents:
1776
diff
changeset
|
230 PLUG_TYPE_SYNTAXE = "SYNTAXE" |
3597
5d108ce026d7
plugin pubsub cache: Pubsub Caching implementation
Goffi <goffi@goffi.org>
parents:
3587
diff
changeset
|
231 PLUG_TYPE_PUBSUB = "PUBSUB" |
1825
4e51f21c687f
plugin blog import: this plugin is the base handling blog importers:
Goffi <goffi@goffi.org>
parents:
1822
diff
changeset
|
232 PLUG_TYPE_BLOG = "BLOG" |
2369
cdaa58e14553
plugin import: generic data import plugin:
Goffi <goffi@goffi.org>
parents:
2305
diff
changeset
|
233 PLUG_TYPE_IMPORT = "IMPORT" |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
234 PLUG_TYPE_ENTRY_POINT = "ENTRY_POINT" |
1520
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
235 |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
236 # Modes |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
237 PLUG_MODE_CLIENT = "client" |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
238 PLUG_MODE_COMPONENT = "component" |
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2132
diff
changeset
|
239 PLUG_MODE_DEFAULT = (PLUG_MODE_CLIENT,) |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
240 PLUG_MODE_BOTH = (PLUG_MODE_CLIENT, PLUG_MODE_COMPONENT) |
1520
9667103a0c10
core (contants): added PROF_KEY_ALL en PLUG_TYPE_* constants
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
241 |
926
d609581bf74a
plugin text commands: refactoring, text now only contain main commands, and other plugin can add commands themselve:
Goffi <goffi@goffi.org>
parents:
923
diff
changeset
|
242 # names of widely used plugins |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
243 TEXT_CMDS = "TEXT-COMMANDS" |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
244 |
1459
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
245 # PubSub event categories |
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
246 PS_PEP = "PEP" |
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
247 PS_MICROBLOG = "MICROBLOG" |
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
248 |
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
249 # PubSub |
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
250 PS_PUBLISH = "publish" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
251 PS_RETRACT = "retract" # used for items |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
252 PS_DELETE = "delete" # used for nodes |
3587
2715da5b2aa7
plugin XEP-0060: handle purge notifications
Goffi <goffi@goffi.org>
parents:
3490
diff
changeset
|
253 PS_PURGE = "purge" # used for nodes |
1459
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
254 PS_ITEM = "item" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
255 PS_ITEMS = "items" # Can contain publish and retract items |
3587
2715da5b2aa7
plugin XEP-0060: handle purge notifications
Goffi <goffi@goffi.org>
parents:
3490
diff
changeset
|
256 PS_EVENTS = (PS_ITEMS, PS_DELETE, PS_PURGE) |
1459
4c4f88d7b156
plugins xep-0060, xep-0163, xep-0277, groupblog: bloging improvments (huge patch, sorry):
Goffi <goffi@goffi.org>
parents:
1454
diff
changeset
|
257 |
2956
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
258 ## MESSAGE/NOTIFICATION LEVELS ## |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
259 |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
260 LVL_INFO = "info" |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
261 LVL_WARNING = "warning" |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
262 LVL_ERROR = "error" |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
263 |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
264 ## XMLUI ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
265 XMLUI_WINDOW = "window" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
266 XMLUI_POPUP = "popup" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
267 XMLUI_FORM = "form" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
268 XMLUI_PARAM = "param" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
269 XMLUI_DIALOG = "dialog" |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
270 XMLUI_DIALOG_CONFIRM = "confirm" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
271 XMLUI_DIALOG_MESSAGE = "message" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
272 XMLUI_DIALOG_NOTE = "note" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
273 XMLUI_DIALOG_FILE = "file" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
274 XMLUI_DATA_ANSWER = "answer" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
275 XMLUI_DATA_CANCELLED = "cancelled" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
276 XMLUI_DATA_TYPE = "type" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
277 XMLUI_DATA_MESS = "message" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
278 XMLUI_DATA_LVL = "level" |
2956
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
279 XMLUI_DATA_LVL_INFO = LVL_INFO |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
280 XMLUI_DATA_LVL_WARNING = LVL_WARNING |
767e1ef6e1bd
core (constants): added generic constants for "info", "warning" and "error" levels
Goffi <goffi@goffi.org>
parents:
2955
diff
changeset
|
281 XMLUI_DATA_LVL_ERROR = LVL_ERROR |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
282 XMLUI_DATA_LVL_DEFAULT = XMLUI_DATA_LVL_INFO |
2035
5c6db4329288
core (constants): added XMLUI_DATA_LVLS constants which group all available levels
Goffi <goffi@goffi.org>
parents:
2004
diff
changeset
|
283 XMLUI_DATA_LVLS = (XMLUI_DATA_LVL_INFO, XMLUI_DATA_LVL_WARNING, XMLUI_DATA_LVL_ERROR) |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
284 XMLUI_DATA_BTNS_SET = "buttons_set" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
285 XMLUI_DATA_BTNS_SET_OKCANCEL = "ok/cancel" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
286 XMLUI_DATA_BTNS_SET_YESNO = "yes/no" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
287 XMLUI_DATA_BTNS_SET_DEFAULT = XMLUI_DATA_BTNS_SET_OKCANCEL |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
288 XMLUI_DATA_FILETYPE = "filetype" |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
289 XMLUI_DATA_FILETYPE_FILE = "file" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
290 XMLUI_DATA_FILETYPE_DIR = "dir" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
291 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
292 |
991
05e02f8b7eb4
core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents:
990
diff
changeset
|
293 ## Logging ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
294 LOG_LVL_DEBUG = "DEBUG" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
295 LOG_LVL_INFO = "INFO" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
296 LOG_LVL_WARNING = "WARNING" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
297 LOG_LVL_ERROR = "ERROR" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
298 LOG_LVL_CRITICAL = "CRITICAL" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
299 LOG_LEVELS = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
300 LOG_LVL_DEBUG, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
301 LOG_LVL_INFO, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
302 LOG_LVL_WARNING, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
303 LOG_LVL_ERROR, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
304 LOG_LVL_CRITICAL, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
305 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
306 LOG_BACKEND_STANDARD = "standard" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
307 LOG_BACKEND_TWISTED = "twisted" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
308 LOG_BACKEND_BASIC = "basic" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
309 LOG_BACKEND_CUSTOM = "custom" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
310 LOG_BASE_LOGGER = "root" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
311 LOG_TWISTED_LOGGER = "twisted" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
312 LOG_OPT_SECTION = "DEFAULT" # section of sat.conf where log options should be |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
313 LOG_OPT_PREFIX = "log_" |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
314 # (option_name, default_value) tuples |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
315 LOG_OPT_COLORS = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
316 "colors", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
317 "true", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
318 ) # true for auto colors, force to have colors even if stdout is not a tty, false for no color |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
319 LOG_OPT_TAINTS_DICT = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
320 "levels_taints_dict", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
321 { |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
322 LOG_LVL_DEBUG: ("cyan",), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
323 LOG_LVL_INFO: (), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
324 LOG_LVL_WARNING: ("yellow",), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
325 LOG_LVL_ERROR: ("red", "blink", r"/!\ ", "blink_off"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
326 LOG_LVL_CRITICAL: ("bold", "red", "Guru Meditation ", "normal_weight"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
327 }, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
328 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
329 LOG_OPT_LEVEL = ("level", "info") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
330 LOG_OPT_FORMAT = ("fmt", "%(message)s") # similar to logging format. |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
331 LOG_OPT_LOGGER = ("logger", "") # regex to filter logger name |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
332 LOG_OPT_OUTPUT_SEP = "//" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
333 LOG_OPT_OUTPUT_DEFAULT = "default" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
334 LOG_OPT_OUTPUT_MEMORY = "memory" |
2975
d86ecc34516e
logs: increased defaut limit for memory output to 300
Goffi <goffi@goffi.org>
parents:
2974
diff
changeset
|
335 LOG_OPT_OUTPUT_MEMORY_LIMIT = 300 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
336 LOG_OPT_OUTPUT_FILE = "file" # file is implicit if only output |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
337 LOG_OPT_OUTPUT = ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
338 "output", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
339 LOG_OPT_OUTPUT_SEP + LOG_OPT_OUTPUT_DEFAULT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
340 ) # //default = normal output (stderr or a file with twistd), path/to/file for a file (must be the first if used), //memory for memory (options can be put in parenthesis, e.g.: //memory(500) for a 500 lines memory) |
991
05e02f8b7eb4
core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents:
990
diff
changeset
|
341 |
1599
e2ed8009e66e
backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument
Goffi <goffi@goffi.org>
parents:
1520
diff
changeset
|
342 ## action constants ## |
e2ed8009e66e
backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument
Goffi <goffi@goffi.org>
parents:
1520
diff
changeset
|
343 META_TYPE_FILE = "file" |
4056
1c4f4aa36d98
plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
4038
diff
changeset
|
344 META_TYPE_CALL = "call" |
1599
e2ed8009e66e
backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument
Goffi <goffi@goffi.org>
parents:
1520
diff
changeset
|
345 META_TYPE_OVERWRITE = "overwrite" |
3405
ecdb3728749e
plugin XEP-0353: Jingle Message Initiation implementation:
Goffi <goffi@goffi.org>
parents:
3379
diff
changeset
|
346 META_TYPE_NOT_IN_ROSTER_LEAK = "not_in_roster_leak" |
4056
1c4f4aa36d98
plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
4038
diff
changeset
|
347 META_SUBTYPE_CALL_AUDIO = "audio" |
1c4f4aa36d98
plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
4038
diff
changeset
|
348 META_SUBTYPE_CALL_VIDEO = "video" |
1599
e2ed8009e66e
backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument
Goffi <goffi@goffi.org>
parents:
1520
diff
changeset
|
349 |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
350 ## HARD-CODED ACTIONS IDS (generated with uuid.uuid4) ## |
3028 | 351 AUTHENTICATE_PROFILE_ID = "b03bbfa8-a4ae-4734-a248-06ce6c7cf562" |
352 CHANGE_XMPP_PASSWD_ID = "878b9387-de2b-413b-950f-e424a147bcd0" | |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
1030
diff
changeset
|
353 |
1104
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
354 ## Text values ## |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
355 BOOL_TRUE = "true" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
356 BOOL_FALSE = "false" |
490a8a4536b6
core (constants): added constants mainly used in XMLUI
Goffi <goffi@goffi.org>
parents:
1092
diff
changeset
|
357 |
1222
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
358 ## Special values used in bridge methods calls ## |
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
359 HISTORY_LIMIT_DEFAULT = -1 |
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
360 HISTORY_LIMIT_NONE = -2 |
e6e0ea4dc835
memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents:
1211
diff
changeset
|
361 |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
362 ## Progress error special values ## |
3028 | 363 PROGRESS_ERROR_DECLINED = "declined" # session has been declined by peer user |
3040 | 364 PROGRESS_ERROR_FAILED = "failed" # something went wrong with the session |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
365 |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
366 ## Files ## |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
367 FILE_TYPE_DIRECTORY = "directory" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
368 FILE_TYPE_FILE = "file" |
3187
d92a144f3589
plugin download: use cache if dest_path is empty:
Goffi <goffi@goffi.org>
parents:
3173
diff
changeset
|
369 # when filename can't be found automatically, this one will be used |
d92a144f3589
plugin download: use cache if dest_path is empty:
Goffi <goffi@goffi.org>
parents:
3173
diff
changeset
|
370 FILE_DEFAULT_NAME = "unnamed" |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
371 |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
372 ## Permissions management ## |
3028 | 373 ACCESS_PERM_READ = "read" |
374 ACCESS_PERM_WRITE = "write" | |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
375 ACCESS_PERMS = {ACCESS_PERM_READ, ACCESS_PERM_WRITE} |
3028 | 376 ACCESS_TYPE_PUBLIC = "public" |
377 ACCESS_TYPE_WHITELIST = "whitelist" | |
2494
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
378 ACCESS_TYPES = (ACCESS_TYPE_PUBLIC, ACCESS_TYPE_WHITELIST) |
d1df08c79a5d
core (constants): new constants to handle files, progress, component, permissions (will be used in the upcoming patches)
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
379 |
2513
2d3c9dcec384
plugin XEP-0264: thumbnails handling implementation
Goffi <goffi@goffi.org>
parents:
2494
diff
changeset
|
380 ## Common data keys ## |
3028 | 381 KEY_THUMBNAILS = "thumbnails" |
382 KEY_PROGRESS_ID = "progress_id" | |
4023
78b5f356900c
component AP gateway: handle attachments
Goffi <goffi@goffi.org>
parents:
4011
diff
changeset
|
383 KEY_ATTACHMENTS = "attachments" |
78b5f356900c
component AP gateway: handle attachments
Goffi <goffi@goffi.org>
parents:
4011
diff
changeset
|
384 KEY_ATTACHMENTS_MEDIA_TYPE = "media_type" |
78b5f356900c
component AP gateway: handle attachments
Goffi <goffi@goffi.org>
parents:
4011
diff
changeset
|
385 KEY_ATTACHMENTS_PREVIEW = "preview" |
78b5f356900c
component AP gateway: handle attachments
Goffi <goffi@goffi.org>
parents:
4011
diff
changeset
|
386 KEY_ATTACHMENTS_RESIZE = "resize" |
78b5f356900c
component AP gateway: handle attachments
Goffi <goffi@goffi.org>
parents:
4011
diff
changeset
|
387 |
2513
2d3c9dcec384
plugin XEP-0264: thumbnails handling implementation
Goffi <goffi@goffi.org>
parents:
2494
diff
changeset
|
388 |
2760
3480d4fdf83a
plugins XEP-0060, XEP-0313: implemented Order-By protoXEP:
Goffi <goffi@goffi.org>
parents:
2752
diff
changeset
|
389 ## Common extra keys/values ## |
3028 | 390 KEY_ORDER_BY = "order_by" |
3597
5d108ce026d7
plugin pubsub cache: Pubsub Caching implementation
Goffi <goffi@goffi.org>
parents:
3587
diff
changeset
|
391 KEY_USE_CACHE = "use_cache" |
3934
e345d93fb6e5
plugin OXPS: OpenPGP for XMPP Pubsub implementation:
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
392 KEY_DECRYPT = "decrypt" |
2760
3480d4fdf83a
plugins XEP-0060, XEP-0313: implemented Order-By protoXEP:
Goffi <goffi@goffi.org>
parents:
2752
diff
changeset
|
393 |
3028 | 394 ORDER_BY_CREATION = 'creation' |
395 ORDER_BY_MODIFICATION = 'modification' | |
2760
3480d4fdf83a
plugins XEP-0060, XEP-0313: implemented Order-By protoXEP:
Goffi <goffi@goffi.org>
parents:
2752
diff
changeset
|
396 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
397 # internationalisation |
3028 | 398 DEFAULT_LOCALE = "en_GB" |
2599
5b26033c49a8
tools (common): moved date_fmt function from template filters to new date_utils module, so it can be used everywhere.
Goffi <goffi@goffi.org>
parents:
2591
diff
changeset
|
399 |
3406
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
400 ## Command Line ## |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
401 |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
402 # Exit codes used by CLI applications |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
403 EXIT_OK = 0 |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
404 EXIT_ERROR = 1 # generic error, when nothing else match |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
405 EXIT_BAD_ARG = 2 # arguments given by user are bad |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
406 EXIT_BRIDGE_ERROR = 3 # can't connect to bridge |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
407 EXIT_BRIDGE_ERRBACK = 4 # something went wrong when calling a bridge method |
3490
509f7a1c67dc
frontends: use new EXIT_BACKEND_NOT_FOUND exit code:
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
408 EXIT_BACKEND_NOT_FOUND = 5 # can't find backend with this bride |
3406
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
409 EXIT_NOT_FOUND = 16 # an item required by a command was not found |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
410 EXIT_DATA_ERROR = 17 # data needed for a command is invalid |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
411 EXIT_MISSING_FEATURE = 18 # a needed plugin or feature is not available |
3433
63d20854df3a
core (constants): added EXIT_CONFLICT
Goffi <goffi@goffi.org>
parents:
3406
diff
changeset
|
412 EXIT_CONFLICT = 19 # an item already exists |
3406
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
413 EXIT_USER_CANCELLED = 20 # user cancelled action |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
414 EXIT_INTERNAL_ERROR = 111 # unexpected error |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
415 EXIT_FILE_NOT_EXE = ( |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
416 126 |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
417 ) # a file to be executed was found, but it was not an executable utility (cf. man 1 exit) |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
418 EXIT_CMD_NOT_FOUND = 127 # a utility to be executed was not found (cf. man 1 exit) |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
419 EXIT_CMD_ERROR = 127 # a utility to be executed returned an error exit code |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
420 EXIT_SIGNAL_INT = 128 # a command was interrupted by a signal (cf. man 1 exit) |
4c15271118a2
core (constants): moved shell exit code constants to core constants:
Goffi <goffi@goffi.org>
parents:
3405
diff
changeset
|
421 |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
422 ## Misc ## |
1003
52ec79aa5bbe
memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
souliane <souliane@mailoo.org>
parents:
1001
diff
changeset
|
423 SAVEFILE_DATABASE = APP_NAME_FILE + ".db" |
942
598fc223cf59
core: more organisation in constants.py
Goffi <goffi@goffi.org>
parents:
930
diff
changeset
|
424 IQ_SET = '/iq[@type="set"]' |
3188
a15773c6c273
memory(cache): extend EOL when a file metadata is retrieved
Goffi <goffi@goffi.org>
parents:
3187
diff
changeset
|
425 ENV_PREFIX = "SAT_" # Prefix used for environment variables |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
426 IGNORE = "ignore" |
3188
a15773c6c273
memory(cache): extend EOL when a file metadata is retrieved
Goffi <goffi@goffi.org>
parents:
3187
diff
changeset
|
427 NO_LIMIT = -1 # used in bridge when a integer value is expected |
a15773c6c273
memory(cache): extend EOL when a file metadata is retrieved
Goffi <goffi@goffi.org>
parents:
3187
diff
changeset
|
428 DEFAULT_MAX_AGE = 1209600 # default max age of cached files, in seconds |
3028 | 429 STANZA_NAMES = ("iq", "message", "presence") |
2691
1ecceac3df96
plugin XEP-0198: Stream Management implementation:
Goffi <goffi@goffi.org>
parents:
2684
diff
changeset
|
430 |
1ecceac3df96
plugin XEP-0198: Stream Management implementation:
Goffi <goffi@goffi.org>
parents:
2684
diff
changeset
|
431 # Stream Hooks |
3028 | 432 STREAM_HOOK_SEND = "send" |
433 STREAM_HOOK_RECEIVE = "receive" | |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
434 |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
435 @classmethod |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
436 def LOG_OPTIONS(cls): |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
437 """Return options checked for logs""" |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
438 # XXX: we use a classmethod so we can use Const inheritance to change default options |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
439 return ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
440 cls.LOG_OPT_COLORS, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
441 cls.LOG_OPT_TAINTS_DICT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
442 cls.LOG_OPT_LEVEL, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
443 cls.LOG_OPT_FORMAT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
444 cls.LOG_OPT_LOGGER, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
445 cls.LOG_OPT_OUTPUT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2599
diff
changeset
|
446 ) |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
447 |
1143
3164b509bc99
core (constants): Bool method allow to convert from python bool to string constant for true/false (in both directions)
Goffi <goffi@goffi.org>
parents:
1113
diff
changeset
|
448 @classmethod |
3794 | 449 def bool(cls, value: str) -> bool: |
1298
e2f71b715708
core: better use of C.bool: C.bool only accept basestring subclasses and return the associated constant, C.boolConst return the associated constant for a boolean value
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
450 """@return (bool): bool value for associated constant""" |
3028 | 451 assert isinstance(value, str) |
4132
8e5333f1b430
core (constants): accept `y` and `t` as `True` values.
Goffi <goffi@goffi.org>
parents:
4079
diff
changeset
|
452 return value.lower() in (cls.BOOL_TRUE, "1", "yes", "on", "y", "t") |
1228
2e1b4e7c8eb8
constants: split C.bool in C.bool and C.str so:
souliane <souliane@mailoo.org>
parents:
1227
diff
changeset
|
453 |
2e1b4e7c8eb8
constants: split C.bool in C.bool and C.str so:
souliane <souliane@mailoo.org>
parents:
1227
diff
changeset
|
454 @classmethod |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
4023
diff
changeset
|
455 def bool_const(cls, value: bool) -> str: |
1298
e2f71b715708
core: better use of C.bool: C.bool only accept basestring subclasses and return the associated constant, C.boolConst return the associated constant for a boolean value
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
456 """@return (str): constant associated to bool value""" |
e2f71b715708
core: better use of C.bool: C.bool only accept basestring subclasses and return the associated constant, C.boolConst return the associated constant for a boolean value
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
457 assert isinstance(value, bool) |
e2f71b715708
core: better use of C.bool: C.bool only accept basestring subclasses and return the associated constant, C.boolConst return the associated constant for a boolean value
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
458 return cls.BOOL_TRUE if value else cls.BOOL_FALSE |
3028 | 459 |
460 | |
461 | |
462 ## Configuration ## | |
463 if ( | |
464 BaseDirectory | |
465 ): # skipped when xdg module is not available (should not happen in backend) | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
466 if "org.libervia.cagou" in BaseDirectory.__file__: |
3028 | 467 # FIXME: hack to make config read from the right location on Android |
468 # TODO: fix it in a more proper way | |
469 | |
470 # we need to use Android API to get downloads directory | |
471 import os.path | |
472 from jnius import autoclass | |
473 | |
3127
2798c86412e1
android: deactivate annoying jnius logs when DEBUG is set
Goffi <goffi@goffi.org>
parents:
3090
diff
changeset
|
474 # we don't want the very verbose jnius log when we are in DEBUG level |
2798c86412e1
android: deactivate annoying jnius logs when DEBUG is set
Goffi <goffi@goffi.org>
parents:
3090
diff
changeset
|
475 import logging |
2798c86412e1
android: deactivate annoying jnius logs when DEBUG is set
Goffi <goffi@goffi.org>
parents:
3090
diff
changeset
|
476 logging.getLogger('jnius').setLevel(logging.WARNING) |
2798c86412e1
android: deactivate annoying jnius logs when DEBUG is set
Goffi <goffi@goffi.org>
parents:
3090
diff
changeset
|
477 logging.getLogger('jnius.reflect').setLevel(logging.WARNING) |
2798c86412e1
android: deactivate annoying jnius logs when DEBUG is set
Goffi <goffi@goffi.org>
parents:
3090
diff
changeset
|
478 |
3028 | 479 Environment = autoclass("android.os.Environment") |
480 | |
481 BaseDirectory = None | |
482 Const.DEFAULT_CONFIG = { | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
483 "local_dir": "/data/data/org.libervia.cagou/app", |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
484 "media_dir": "/data/data/org.libervia.cagou/files/app/media", |
3028 | 485 # FIXME: temporary location for downloads, need to call API properly |
486 "downloads_dir": os.path.join( | |
487 Environment.getExternalStoragePublicDirectory( | |
488 Environment.DIRECTORY_DOWNLOADS | |
489 ).getAbsolutePath(), | |
490 Const.APP_NAME_FILE, | |
491 ), | |
4171
da7d360a87be
core (constants): user platform temporary dir by default for PID files
Goffi <goffi@goffi.org>
parents:
4166
diff
changeset
|
492 "pid_dir": tempfile.gettempdir(), |
3028 | 493 "log_dir": "%(local_dir)s", |
494 } | |
495 Const.CONFIG_FILES = [ | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
496 "/data/data/org.libervia.cagou/files/app/android/" |
3028 | 497 + Const.APP_NAME_FILE |
498 + ".conf" | |
499 ] | |
500 else: | |
501 import os | |
3147
c3e8ddf3a071
core (constants): use parent of "sat" module dir as last config path
Goffi <goffi@goffi.org>
parents:
3146
diff
changeset
|
502 # we use parent of "sat" module dir as last config path, this is useful for |
c3e8ddf3a071
core (constants): use parent of "sat" module dir as last config path
Goffi <goffi@goffi.org>
parents:
3146
diff
changeset
|
503 # per instance configurations (e.g. a dev instance and a main instance) |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4056
diff
changeset
|
504 root_dir = dirname(dirname(backend.__file__)) + '/' |
3028 | 505 Const.CONFIG_PATHS = ( |
3379
9081b6c41328
core: `sat.conf` is now first checked in `/etc/_sat.conf` for system-related settings
Goffi <goffi@goffi.org>
parents:
3269
diff
changeset
|
506 # /etc/_sat.conf is used for system-related settings (e.g. when media_dir |
9081b6c41328
core: `sat.conf` is now first checked in `/etc/_sat.conf` for system-related settings
Goffi <goffi@goffi.org>
parents:
3269
diff
changeset
|
507 # is set by the distribution and has not reason to change, or in a Docker |
9081b6c41328
core: `sat.conf` is now first checked in `/etc/_sat.conf` for system-related settings
Goffi <goffi@goffi.org>
parents:
3269
diff
changeset
|
508 # image) |
9081b6c41328
core: `sat.conf` is now first checked in `/etc/_sat.conf` for system-related settings
Goffi <goffi@goffi.org>
parents:
3269
diff
changeset
|
509 ["/etc/_", "/etc/", "~/", "~/."] |
3028 | 510 + [ |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
511 "{}/".format(path) |
3028 | 512 for path in list(BaseDirectory.load_config_paths(Const.APP_NAME_FILE)) |
513 ] | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
514 # this is to handle legacy sat.conf |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
515 + [ |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
516 "{}/".format(path) |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
517 for path in list(BaseDirectory.load_config_paths("sat")) |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
518 ] |
3145
3f414c897e70
core (constants): don't parse `sat.conf` from current dir anymore + parse root_dir last
Goffi <goffi@goffi.org>
parents:
3144
diff
changeset
|
519 + [root_dir] |
3028 | 520 ) |
521 | |
522 # on recent versions of Flatpak, FLATPAK_ID is set at run time | |
523 # it seems that this is not the case on older versions, | |
524 # but FLATPAK_SANDBOX_DIR seems set then | |
525 if os.getenv('FLATPAK_ID') or os.getenv('FLATPAK_SANDBOX_DIR'): | |
526 # for Flatpak, the conf can't be set in /etc or $HOME, so we have | |
527 # to add /app | |
528 Const.CONFIG_PATHS.append('/app/') | |
529 | |
530 ## Configuration ## | |
531 Const.DEFAULT_CONFIG = { | |
532 "media_dir": "/usr/share/" + Const.APP_NAME_FILE + "/media", | |
533 "local_dir": BaseDirectory.save_data_path(Const.APP_NAME_FILE), | |
534 "downloads_dir": "~/Downloads/" + Const.APP_NAME_FILE, | |
4171
da7d360a87be
core (constants): user platform temporary dir by default for PID files
Goffi <goffi@goffi.org>
parents:
4166
diff
changeset
|
535 "pid_dir": tempfile.gettempdir(), |
3028 | 536 "log_dir": "%(local_dir)s", |
537 } | |
538 | |
539 # List of the configuration filenames sorted by ascending priority | |
540 Const.CONFIG_FILES = [ | |
541 realpath(expanduser(path) + Const.APP_NAME_FILE + ".conf") | |
542 for path in Const.CONFIG_PATHS | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
543 ] + [ |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
544 # legacy sat.conf |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
545 realpath(expanduser(path) + "sat.conf") |
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
546 for path in Const.CONFIG_PATHS |
3028 | 547 ] |
548 |