Mercurial > libervia-backend
annotate frontends/src/quick_frontend/constants.py @ 2109:85f3e12e984d
core (memory/cache): file caching handling, first draft:
instead of having file caching handled individually by plugins, a generic module has been added in memory.
- Cache can be global or associated to a profile. In the later case, client.cache can be used.
- Cache are managed with unique ids (which can be any unique unicode, hash uuid, or something else).
- To know if a file is in cache, getFilePath is used: if the file is in cache, its absolute path is returned, else None is returned.
- To cache a file, cacheData is used with at list the source of cache (most of time plugin import name), and unique id. The method return file opened in binary writing mode (so cacheData can - and should - be used with "with" statement).
- 2 files will be created: a metadata file (named after the unique id), and the actual file.
- each file has a end of life time, after it, the cache is invalidated and the file must be requested again.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 05 Jan 2017 20:23:38 +0100 |
parents | b44558286bbb |
children | 4e67d6ffea66 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
1 #!/usr/bin/env python2 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
4 # Primitivus: a SAT frontend |
1766 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
10 # (at your option) any later version. |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
15 # GNU Affero General Public License for more details. |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
19 |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
20 from sat.core import constants |
1342
e31a07a5614d
quick_frontends, primitivus (contact list): added nick observer + implemented onNickUpdate
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
21 from sat.core.i18n import _ |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
22 from collections import OrderedDict # only available from python 2.7 |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
23 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
25 class Const(constants.Const): |
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
26 |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
27 PRESENCE = OrderedDict([("", _("Online")), |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
28 ("chat", _("Free for chat")), |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
29 ("away", _("Away from keyboard")), |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
30 ("dnd", _("Do not disturb")), |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
31 ("xa", _("Extended away"))]) |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
32 |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
33 # from plugin_misc_text_syntaxes |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
34 SYNTAX_XHTML = "XHTML" |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
35 SYNTAX_CURRENT = "@CURRENT@" |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
36 SYNTAX_TEXT = "text" |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
37 |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
38 # XMLUI |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
39 SAT_FORM_PREFIX = "SAT_FORM_" |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
40 SAT_PARAM_SEPARATOR = "_XMLUI_PARAM_" # used to have unique elements names |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
41 XMLUI_STATUS_VALIDATED = "validated" |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
42 XMLUI_STATUS_CANCELLED = constants.Const.XMLUI_DATA_CANCELLED |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
43 |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
44 # Roster |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
45 CONTACT_GROUPS = 'groups' |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
46 CONTACT_RESOURCES = 'resources' |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
47 CONTACT_MAIN_RESOURCE = 'main_resource' |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
48 CONTACT_SPECIAL = 'special' |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
49 CONTACT_SPECIAL_GROUP = 'group' # group chat special entity |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
50 CONTACT_SELECTED = 'selected' |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
51 CONTACT_PROFILE = 'profile' # used in handler to track where the contact is coming from |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
52 CONTACT_SPECIAL_ALLOWED = (CONTACT_SPECIAL_GROUP,) # allowed values for special flag |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
53 CONTACT_DATA_FORBIDDEN = {CONTACT_GROUPS, CONTACT_RESOURCES, CONTACT_MAIN_RESOURCE, CONTACT_SELECTED, CONTACT_PROFILE} # set of forbidden names for contact data |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
54 |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
55 # Chats |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
56 CHAT_ONE2ONE = 'one2one' |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
57 CHAT_GROUP = 'group' |
2007
19b9d3f8a6c7
plugin XEP-0085, quick_frontends, primitivus: chat states are working again
Goffi <goffi@goffi.org>
parents:
1972
diff
changeset
|
58 CHAT_STATE_ICON = { |
19b9d3f8a6c7
plugin XEP-0085, quick_frontends, primitivus: chat states are working again
Goffi <goffi@goffi.org>
parents:
1972
diff
changeset
|
59 "": u" ", |
1385
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1378
diff
changeset
|
60 "active": u'✔', |
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1378
diff
changeset
|
61 "inactive": u'☄', |
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1378
diff
changeset
|
62 "gone": u'✈', |
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1378
diff
changeset
|
63 "composing": u'✎', |
2007
19b9d3f8a6c7
plugin XEP-0085, quick_frontends, primitivus: chat states are working again
Goffi <goffi@goffi.org>
parents:
1972
diff
changeset
|
64 "paused": u"…" |
1385
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1378
diff
changeset
|
65 } |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
66 |
1461
9fce331ba0fd
quick_frontend (constants, quick_app, quick_contact_list): blogging refactoring (not finished):
Goffi <goffi@goffi.org>
parents:
1407
diff
changeset
|
67 # Blogs |
9fce331ba0fd
quick_frontend (constants, quick_app, quick_contact_list): blogging refactoring (not finished):
Goffi <goffi@goffi.org>
parents:
1407
diff
changeset
|
68 ENTRY_MODE_TEXT = "text" |
9fce331ba0fd
quick_frontend (constants, quick_app, quick_contact_list): blogging refactoring (not finished):
Goffi <goffi@goffi.org>
parents:
1407
diff
changeset
|
69 ENTRY_MODE_RICH = "rich" |
9fce331ba0fd
quick_frontend (constants, quick_app, quick_contact_list): blogging refactoring (not finished):
Goffi <goffi@goffi.org>
parents:
1407
diff
changeset
|
70 ENTRY_MODE_XHTML = "xhtml" |
9fce331ba0fd
quick_frontend (constants, quick_app, quick_contact_list): blogging refactoring (not finished):
Goffi <goffi@goffi.org>
parents:
1407
diff
changeset
|
71 |
1327
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
72 # Widgets management |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
73 # FIXME: should be in quick_frontend.constant, but Libervia doesn't inherit from it |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
74 WIDGET_NEW = 'NEW' |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
75 WIDGET_KEEP = 'KEEP' |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
76 WIDGET_RAISE = 'RAISE' |
89dc29afe01c
frontends: merge sat_frontends.constants to sat_frontends.quick_frontend.constants
souliane <souliane@mailoo.org>
parents:
1318
diff
changeset
|
77 WIDGET_RECREATE = 'RECREATE' |
1318
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
78 |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
79 # Updates (generic) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
80 UPDATE_DELETE = 'DELETE' |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
81 UPDATE_MODIFY = 'MODIFY' |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
82 UPDATE_ADD = 'ADD' |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
83 UPDATE_SELECTION = 'SELECTION' |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
84 UPDATE_STRUCTURE = 'STRUCTURE' # high level update (i.e. not item level but organisation of items) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
85 |
2103
b44558286bbb
quick frontend (quick app): added progressFinished and progressError listeners
Goffi <goffi@goffi.org>
parents:
2007
diff
changeset
|
86 LISTENERS = {'avatar', 'nick', 'presence', 'profilePlugged', 'disconnect', 'gotMenus', 'menu', 'notification', 'notificationsClear', 'progressFinished', 'progressError'} |
1972
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
87 |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
88 # Notifications |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
89 NOTIFY_MESSAGE = 'MESSAGE' # a message was received |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
90 NOTIFY_MENTION = 'MENTION' # user was mentionned |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
91 NOTIFY_PROGRESS_END = 'PROGRESS_END' # a progression has finised |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
92 NOTIFY_GENERIC = 'GENERIC' # a notification which has not its own type |