Mercurial > libervia-backend
comparison src/core/constants.py @ 1367:f71a0fc26886
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 10:52:28 +0100 |
parents | f296a54af386 |
children | 73f8582c7c99 |
comparison
equal
deleted
inserted
replaced
1295:1e3b1f9ad6e2 | 1367:f71a0fc26886 |
---|---|
68 MENU_ROOM = "ROOM" | 68 MENU_ROOM = "ROOM" |
69 MENU_SINGLE = "SINGLE" | 69 MENU_SINGLE = "SINGLE" |
70 MENU_JID_CONTEXT = "JID_CONTEXT" | 70 MENU_JID_CONTEXT = "JID_CONTEXT" |
71 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT" | 71 MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT" |
72 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT" | 72 MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT" |
73 MENU_ROOM_OCCUPANT_CONTEXT = "MENU_ROOM_OCCUPANT_CONTEXT" | |
73 | 74 |
74 | 75 |
75 ## Profile and entities ## | 76 ## Profile and entities ## |
76 PROF_KEY_NONE = '@NONE@' | 77 PROF_KEY_NONE = '@NONE@' |
77 PROF_KEY_DEFAULT = '@DEFAULT@' | 78 PROF_KEY_DEFAULT = '@DEFAULT@' |
78 ENTITY_ALL = '@ALL@' | 79 ENTITY_ALL = '@ALL@' |
79 ENTITY_LAST_RESOURCE = 'LAST_RESOURCE' | 80 ENTITY_ALL_RESOURCES = '@ALL_RESOURCES@' |
81 ENTITY_MAIN_RESOURCE = '@MAIN_RESOURCE@' | |
80 ENTITY_CAP_HASH = 'CAP_HASH' | 82 ENTITY_CAP_HASH = 'CAP_HASH' |
81 | 83 |
82 | 84 |
83 ## Messages ## | 85 ## Messages ## |
84 MESS_TYPE_INFO = 'info' | 86 MESS_TYPE_INFO = 'info' |
87 MESS_TYPE_CHAT = 'chat' | |
88 MESS_TYPE_ERROR = 'error' | |
89 MESS_TYPE_GROUPCHAT = 'groupchat' | |
90 MESS_TYPE_HEADLINE = 'headline' | |
91 MESS_TYPE_NORMAL = 'normal' | |
92 | |
93 ## PRESENCE ## | |
94 PRESENCE_UNAVAILABLE = 'unavailable' | |
95 PRESENCE_SHOW_AWAY = 'away' | |
96 PRESENCE_SHOW_CHAT = 'chat' | |
97 PRESENCE_SHOW_DND = 'dnd' | |
98 PRESENCE_SHOW_XA = 'xa' | |
99 PRESENCE_SHOW = 'show' | |
100 PRESENCE_STATUSES = 'statuses' | |
101 PRESENCE_PRIORITY = 'priority' | |
102 | |
85 | 103 |
86 ## Configuration ## | 104 ## Configuration ## |
87 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend) | 105 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend) |
88 | 106 |
89 ## Configuration ## | 107 ## Configuration ## |
200 # XXX: we use a classmethod so we can use Const inheritance to change default options | 218 # XXX: we use a classmethod so we can use Const inheritance to change default options |
201 return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT) | 219 return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT) |
202 | 220 |
203 @classmethod | 221 @classmethod |
204 def bool(cls, value): | 222 def bool(cls, value): |
205 """@return: bool value for any type""" | 223 """@return (bool): bool value for associated constant""" |
206 if isinstance(value, str) or isinstance(value, unicode): # dbus.String is unicode but not str | 224 assert isinstance(value, basestring) |
207 return value.lower() == cls.BOOL_TRUE | 225 return value.lower() == cls.BOOL_TRUE |
208 return bool(value) | |
209 | 226 |
210 @classmethod | 227 @classmethod |
211 def str(cls, value): | 228 def boolConst(cls, value): |
212 """@return: str text value for any type""" | 229 """@return (str): constant associated to bool value""" |
213 if isinstance(value, bool): | 230 assert isinstance(value, bool) |
214 return cls.BOOL_TRUE if value else cls.BOOL_FALSE | 231 return cls.BOOL_TRUE if value else cls.BOOL_FALSE |
215 return str(value) |