core: dynamics menus refactoring:

- menu now use generic callback system, with extra data
    - asyncMenuCall is removed in favor of launchAction
    - menu_id (== callback_id) is used to identify menu instead of category/name/type tuple
    - i18n is managed throught deferred translation, and returned with _i18n suffix
        e.g.: menu (D_('File'), D_('Open')): (u'File', u'Open') is menu_path, (u'Fichier', u'Ouvrir') is french menu_path_i18n.
    - type actually can have the following values:
        - NORMAL: classical menu
        - JID_CONTEXT: contextual menu, used with any jid
        - ROSTER_JID_CONTEXT: like JID_CONTEXT, but restricted to jids in roster.
        - ROSTER_GROUP_CONTEXT: contextual menu, use with groups
    - security_limit is used, in the same way as for parameters
    - when using importMenu, callback can be an actual callback, or one already registered with registerCallback
This commit is contained in:
Goffi 2013-12-29 17:10:14 +01:00
commit b7bf434cd2
8 changed files with 129 additions and 132 deletions

View file

@ -191,12 +191,6 @@ class DbusObject(dbus.service.Object):
def addContact(self, entity_jid, profile_key="@DEFAULT@"):
return self._callback("addContact", unicode(entity_jid), unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssss', out_signature='s',
async_callbacks=('callback', 'errback'))
def asyncCallMenu(self, category, name, menu_type, profile_key, callback=None, errback=None):
return self._callback("asyncCallMenu", unicode(category), unicode(name), unicode(menu_type), unicode(profile_key), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='s', out_signature='',
async_callbacks=('callback', 'errback'))
@ -288,16 +282,16 @@ class DbusObject(dbus.service.Object):
return self._callback("getLastResource", unicode(contact_jid), unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='sss', out_signature='s',
in_signature='ss', out_signature='s',
async_callbacks=None)
def getMenuHelp(self, category, name, menu_type):
return self._callback("getMenuHelp", unicode(category), unicode(name), unicode(menu_type))
def getMenuHelp(self, menu_id, language):
return self._callback("getMenuHelp", unicode(menu_id), unicode(language))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='', out_signature='a(sss)',
in_signature='si', out_signature='a(ssasas)',
async_callbacks=None)
def getMenus(self, ):
return self._callback("getMenus", )
def getMenus(self, language, security_limit):
return self._callback("getMenus", unicode(language), security_limit)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssss', out_signature='s',

View file

@ -1,6 +1,7 @@
[DEFAULT]
doc_profile=profile: Name of the profile.
doc_profile_key=profile_key: Profile key which can be either a magic (eg: @DEFAULT@) or the name of an existing profile.
doc_security_limit=security_limit: -1 means no security then the higher the most secure
;signals
@ -410,7 +411,7 @@ doc=Change a parameter
doc_param_0=name: Name of the parameter to change
doc_param_1=value: New Value of the parameter
doc_param_2=category: Category of the parameter to change
doc_param_3=security_limit: -1 means no security then the higher the most secure
doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s
[getParamA]
@ -439,7 +440,7 @@ doc=Helper method to get a parameter's attribute
doc_param_0=name: as for [setParam]
doc_param_1=category: as for [setParam]
doc_param_2=attribute: Name of the attribute
doc_param_3=security_limit: -1 means no security then the higher the most secure
doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s
[getParamsUI]
@ -451,7 +452,7 @@ sig_out=s
param_0_default=-1
param_1_default="@DEFAULT@"
doc=Return a SàT XMLUI for parameters
doc_param_0=security_limit: -1 means no security then the higher the most secure
doc_param_0=%(doc_security_limit)s
doc_param_1=%(doc_profile_key)s
[getParams]
@ -463,7 +464,7 @@ sig_out=s
param_0_default=-1
param_1_default="@DEFAULT@"
doc=Return XML of parameters
doc_param_0=security_limit: -1 means no security then the higher the most secure
doc_param_0=%(doc_security_limit)s
doc_param_1=%(doc_profile_key)s
[getParamsForCategory]
@ -476,7 +477,7 @@ param_1_default=-1
param_2_default="@DEFAULT@"
doc=Return a xml of all params in a category
doc_param_0=category: Category to get
doc_param_1=security_limit: -1 means no security then the higher the most secure
doc_param_1=%(doc_security_limit)s
doc_param_2=%(doc_profile_key)s
[getParamsCategories]
@ -576,36 +577,26 @@ doc_return=dict with progress information:
[getMenus]
type=method
category=core
sig_in=
sig_out=a(sss)
sig_in= si
sig_out=a(ssasas)
doc=Get all additional menus
doc_param_0=language: language in which the menu should be translated (empty string for default)
doc_param_1=security_limit: %(doc_security_limit)s
doc_return=list of tuple with the following value:
- menu_id: menu id (same as callback id)
- menu_type: Type which can be:
* NORMAL: Classical application menu
- category: Category of the menu
- name: Name of the menu
- menu_path: raw path of the menu
- menu_path_i18n: translated path of the menu
[getMenuHelp]
type=method
category=core
sig_in=sss
sig_in=ss
sig_out=s
param_2="NORMAL"
doc=Get help information for a menu
doc_param_0=category: Category of the menu
doc_param_1=name: Name of the menu
doc_param_2=menu_type: Type of the menu as in [getMenus] return value
doc_return=Help string
doc_param_0=menu_id: id of the menu (same as callback_id)
doc_param_1=language: language in which the menu should be translated (empty string for default)
doc_return=Translated help string
[asyncCallMenu]
async=
type=method
category=core
sig_in=ssss
sig_out=s
doc=Execute action associated with a menu
doc_param_0=category: as in [getMenuHelp]
doc_param_1=name: as in [getMenuHelp]
doc_param_2=menu_type: as in [getMenuHelp]
doc_param_3=%(doc_profile_key)s
doc_return=return a XMLUI or empty string if it is a one shot action