annotate frontends/src/primitivus/constants.py @ 1963:a2bc5089c2eb

backend, frontends: message refactoring (huge commit): /!\ several features are temporarily disabled, like notifications in frontends next step in refactoring, with the following changes: - jp: updated jp message to follow changes in backend/bridge - jp: added --lang, --subject, --subject_lang, and --type options to jp message + fixed unicode handling for jid - quick_frontend (QuickApp, QuickChat): - follow backend changes - refactored chat, message are now handled in OrderedDict and uid are kept so they can be updated - Message and Occupant classes handle metadata, so frontend just have to display them - Primitivus (Chat): - follow backend/QuickFrontend changes - info & standard messages are handled in the same MessageWidget class - improved/simplified handling of messages, removed update() method - user joined/left messages are merged when next to each other - a separator is shown when message is received while widget is out of focus, so user can quickly see the new messages - affiliation/role are shown (in a basic way for now) in occupants panel - removed "/me" messages handling, as it will be done by a backend plugin - message language is displayed when available (only one language per message for now) - fixed :history and :search commands - core (constants): new constants for messages type, XML namespace, entity type - core: *Message methods renamed to follow new code sytle (e.g. sendMessageToBridge => messageSendToBridge) - core (messages handling): fixed handling of language - core (messages handling): mes_data['from'] and ['to'] are now jid.JID - core (core.xmpp): reorganised message methods, added getNick() method to client.roster - plugin text commands: fixed plugin and adapted to new messages behaviour. client is now used in arguments instead of profile - plugins: added information for cancellation reason in CancelError calls - plugin XEP-0045: various improvments, but this plugin still need work: - trigger is used to avoid message already handled by the plugin to be handled a second time - changed the way to handle history, the last message from DB is checked and we request only messages since this one, in seconds (thanks Poezio folks :)) - subject reception is waited before sending the roomJoined signal, this way we are sure that everything including history is ready - cmd_* method now follow the new convention with client instead of profile - roomUserJoined and roomUserLeft messages are removed, the events are now handled with info message with a "ROOM_USER_JOINED" info subtype - probably other forgotten stuffs :p
author Goffi <goffi@goffi.org>
date Mon, 20 Jun 2016 18:41:53 +0200
parents 2daf7b4c6756
children 5fbe09b9b568
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
495
a726b234d3bf primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
a726b234d3bf primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
diff changeset
4 # Primitivus: a SAT frontend
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1658
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
495
a726b234d3bf primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
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: 587
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: 587
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: 587
diff changeset
10 # (at your option) any later version.
495
a726b234d3bf primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
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: 587
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: 587
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: 587
diff changeset
15 # GNU Affero General Public License for more details.
495
a726b234d3bf primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 587
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: 587
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
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
20 from sat_frontends.quick_frontend import constants
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
21
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
22
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
23 class Const(constants.Const):
495
a726b234d3bf primitivus: moved constants in a separate file
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 APP_NAME = "Primitivus"
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
26 PALETTE = [
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
27 ('title', 'black', 'light gray', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
28 ('title_focus', 'white,bold', 'light gray', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
29 ('selected', 'default', 'dark red'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
30 ('selected_focus', 'default,bold', 'dark red'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
31 ('default', 'default', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
32 ('default_focus', 'default,bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
33 ('alert', 'default,underline', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
34 ('alert_focus', 'default,bold,underline', 'default'),
1963
a2bc5089c2eb backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
35 # Messages
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
36 ('date', 'light gray', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
37 ('my_nick', 'dark red,bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
38 ('other_nick', 'dark cyan,bold', 'default'),
1173
cae023216bba primivitus: info messages now use "info_msg" attribute (yellow)
Goffi <goffi@goffi.org>
parents: 1159
diff changeset
39 ('info_msg', 'yellow', 'default', 'bold'),
1963
a2bc5089c2eb backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
40 ('msg_lang', 'dark cyan', 'default'),
a2bc5089c2eb backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
41
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
42 ('menubar', 'light gray,bold', 'dark red'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
43 ('menubar_focus', 'light gray,bold', 'dark green'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
44 ('selected_menu', 'light gray,bold', 'dark green'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
45 ('menuitem', 'light gray,bold', 'dark red'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
46 ('menuitem_focus', 'light gray,bold', 'dark green'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
47 ('notifs', 'black,bold', 'yellow'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
48 ('notifs_focus', 'dark red', 'yellow'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
49 ('card_neutral', 'dark gray', 'white', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
50 ('card_neutral_selected', 'dark gray', 'dark green', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
51 ('card_special', 'brown', 'white', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
52 ('card_special_selected', 'brown', 'dark green', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
53 ('card_red', 'dark red', 'white', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
54 ('card_red_selected', 'dark red', 'dark green', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
55 ('card_black', 'black', 'white', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
56 ('card_black_selected', 'black', 'dark green', 'standout,underline'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
57 ('directory', 'dark cyan, bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
58 ('directory_focus', 'dark cyan, bold', 'dark green'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
59 ('separator', 'brown', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
60 ('warning', 'light red', 'default'),
1636
e00f450c25fc primitivus: fixed progress panel
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
61 ('progress_normal', 'default', 'brown'),
e00f450c25fc primitivus: fixed progress panel
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
62 ('progress_complete', 'default', 'dark green'),
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
63 ('show_disconnected', 'dark gray', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
64 ('show_normal', 'default', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
65 ('show_normal_focus', 'default, bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
66 ('show_chat', 'dark green', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
67 ('show_chat_focus', 'dark green, bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
68 ('show_away', 'brown', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
69 ('show_away_focus', 'brown, bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
70 ('show_dnd', 'dark red', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
71 ('show_dnd_focus', 'dark red, bold', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
72 ('show_xa', 'dark red', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
73 ('show_xa_focus', 'dark red, bold', 'default'),
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
74 ('resource', 'light blue', 'default'),
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
75 ('resource_main', 'dark blue', 'default'),
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
76 ('status', 'yellow', 'default'),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
77 ('status_focus', 'yellow, bold', 'default'),
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 736
diff changeset
78 ('param_selected','default, bold', 'dark red'),
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 736
diff changeset
79 ('table_selected','default, bold', 'default'),
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
80 ]
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
81 PRESENCE = {"unavailable": (u'⨯', "show_disconnected"),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
82 "": (u'✔', "show_normal"),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
83 "chat": (u'✆', "show_chat"),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
84 "away": (u'✈', "show_away"),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
85 "dnd": (u'✖', "show_dnd"),
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
86 "xa": (u'☄', "show_xa")
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
87 }
1010
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
88 LOG_OPT_SECTION = APP_NAME.lower()
73a0b7f94674 primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
89 LOG_OPT_OUTPUT = ('output', constants.Const.LOG_OPT_OUTPUT_SEP + constants.Const.LOG_OPT_OUTPUT_MEMORY)
736
6246eb6d64a0 frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents: 609
diff changeset
90
1159
85fd02356dba primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents: 1010
diff changeset
91 CONFIG_SECTION = APP_NAME.lower()
85fd02356dba primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents: 1010
diff changeset
92 CONFIG_OPT_KEY_PREFIX = "KEY_"
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
93
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
94 MENU_ID_MAIN = "MAIN_MENU"
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
95 MENU_ID_WIDGET = "WIDGET_MENU"
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
96
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
97 MODE_NORMAL = 'NORMAL'
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
98 MODE_INSERTION = 'INSERTION'
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
99 MODE_COMMAND = 'COMMAND'
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
100
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
101 GROUP_DATA_FOLDED = 'folded'
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
102
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1173
diff changeset
103 # contacts and contact list
1658
683b76c1145d quick_frontend, primitivus: display the number of alerts for each contact and not only a symbol (*)
souliane <souliane@mailoo.org>
parents: 1636
diff changeset
104 ALERT_HEADER='(%i) '