comparison src/core/sat_main.py @ 1092:0eefc74c346b

core (menus): constants are used for menu types
author Goffi <goffi@goffi.org>
date Wed, 25 Jun 2014 20:54:15 +0200
parents 8e0072754413
children 77751f5b2242
comparison
equal deleted inserted replaced
1091:2d035aaea13b 1092:0eefc74c346b
283 283
284 def _authenticateProfile(self, password, profile): 284 def _authenticateProfile(self, password, profile):
285 """Authenticate the profile. 285 """Authenticate the profile.
286 286
287 @param password (string): the SàT profile password 287 @param password (string): the SàT profile password
288 @param profile_key: %(doc_profile_key)s 288 @param profile: %(doc_profile)s
289 @return: Deferred: a deferred None in case of success, a failure otherwise. 289 @return: Deferred: a deferred None in case of success, a failure otherwise.
290 """ 290 """
291 session_data = self.memory.auth_sessions.profileGetUnique(profile) 291 session_data = self.memory.auth_sessions.profileGetUnique(profile)
292 if not password and session_data: 292 if not password and session_data:
293 # XXX: this allows any frontend to connect with the empty password as soon as 293 # XXX: this allows any frontend to connect with the empty password as soon as
769 769
770 return defer.maybeDeferred(callback, *args, **kwargs) 770 return defer.maybeDeferred(callback, *args, **kwargs)
771 771
772 #Menus management 772 #Menus management
773 773
774 def importMenu(self, path, callback, security_limit=C.NO_SECURITY_LIMIT, help_string="", type_="NORMAL"): 774 def importMenu(self, path, callback, security_limit=C.NO_SECURITY_LIMIT, help_string="", type_=C.MENU_GLOBAL):
775 """register a new menu for frontends 775 """register a new menu for frontends
776 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open")) 776 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open"))
777 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open"))) 777 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open")))
778 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback] 778 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback]
779 @param security_limit: %(doc_security_limit)s 779 @param security_limit: %(doc_security_limit)s
780 /!\ security_limit MUST be added to data in launchCallback if used #TODO 780 /!\ security_limit MUST be added to data in launchCallback if used #TODO
781 @param help_string: string used to indicate what the menu do (can be show as a tooltip). 781 @param help_string: string used to indicate what the menu do (can be show as a tooltip).
782 /!\ use D_() instead of _() for translations 782 /!\ use D_() instead of _() for translations
783 @param type: one of: 783 @param type: one of:
784 - GLOBAL: classical menu, can be shown in a menubar on top (e.g. something like File/Open) 784 - C.MENU_GLOBAL: classical menu, can be shown in a menubar on top (e.g. something like File/Open)
785 - ROOM: like a global menu, but only shown in multi-user chat 785 - C.MENU_ROOM: like a global menu, but only shown in multi-user chat
786 - JID_CONTEXT: contextual menu, used with any jid (e.g.: ad hoc commands, jid is already filled) 786 menu_data must contain a "room_jid" data
787 - ROSTER_JID_CONTEXT: like JID_CONTEXT, but restricted to jids in roster. 787 - C.MENU_SINGLE: like a global menu, but only shown in one2one chat
788 - ROSTER_GROUP_CONTEXT: contextual menu, used with group (e.g.: publish microblog, group is already filled) 788 menu_data must contain a "jid" data
789 - C.MENU_JID_CONTEXT: contextual menu, used with any jid (e.g.: ad hoc commands, jid is already filled)
790 menu_data must contain a "jid" data
791 - C.MENU_ROSTER_JID_CONTEXT: like JID_CONTEXT, but restricted to jids in roster.
792 menu_data must contain a "room_jid" data
793 - C.MENU_ROSTER_GROUP_CONTEXT: contextual menu, used with group (e.g.: publish microblog, group is already filled)
794 menu_data must contain a "group" data
789 @return: menu_id (same as callback_id) 795 @return: menu_id (same as callback_id)
790 """ 796 """
791 797
792 if callable(callback): 798 if callable(callback):
793 callback_id = self.registerCallback(callback, with_data=True) 799 callback_id = self.registerCallback(callback, with_data=True)