core (xmlui), plugin file: added action_extra param to deferXMLUI/deferDialog which is merged to the action data dict when actionNew is called
This commit is contained in:
parent
891a4c33af
commit
de85e24577
2 changed files with 21 additions and 4 deletions
|
|
@ -202,6 +202,10 @@ class FilePlugin(object):
|
|||
self.host,
|
||||
_(CONFIRM_OVERWRITE).format(file_path),
|
||||
_(CONFIRM_OVERWRITE_TITLE),
|
||||
action_extra={'meta_from_jid': peer_jid.full(),
|
||||
'meta_type': C.META_TYPE_OVERWRITE,
|
||||
'meta_progress_id': file_data[PROGRESS_ID_KEY]
|
||||
},
|
||||
profile=profile)
|
||||
exists_d.addCallback(check_overwrite)
|
||||
return exists_d
|
||||
|
|
@ -243,6 +247,10 @@ class FilePlugin(object):
|
|||
_(CONFIRM_TITLE),
|
||||
type_=C.XMLUI_DIALOG_FILE,
|
||||
options={C.XMLUI_DATA_FILETYPE: C.XMLUI_DATA_FILETYPE_DIR},
|
||||
action_extra={'meta_from_jid': peer_jid.full(),
|
||||
'meta_type': C.META_TYPE_FILE,
|
||||
'meta_progress_id': file_data[PROGRESS_ID_KEY]
|
||||
},
|
||||
profile=profile)
|
||||
d.addCallback(self._gotConfirmation, peer_jid, transfer_data, file_data, profile)
|
||||
return d
|
||||
|
|
|
|||
|
|
@ -1249,12 +1249,14 @@ def note(message, title='', level=C.XMLUI_DATA_LVL_INFO):
|
|||
)
|
||||
return note_xmlui
|
||||
|
||||
def deferXMLUI(host, xmlui, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE):
|
||||
def deferXMLUI(host, xmlui, action_extra=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE):
|
||||
"""Create a deferred linked to XMLUI
|
||||
|
||||
@param xmlui(XMLUI): instance of the XMLUI
|
||||
Must be an XMLUI that you can submit, with submit_id set to ''
|
||||
@param profile: %(doc_profile)s
|
||||
@param action_extra(None, dict): extra action to merge with xmlui
|
||||
mainly used to add meta informations (see actionNew doc)
|
||||
@param security_limit: %(doc_security_limit)s
|
||||
@return (data): a deferred which fire the data
|
||||
"""
|
||||
|
|
@ -1266,16 +1268,23 @@ def deferXMLUI(host, xmlui, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_K
|
|||
return {}
|
||||
|
||||
xmlui.submit_id = host.registerCallback(onSubmit, with_data=True, one_shot=True)
|
||||
host.actionNew({'xmlui': xmlui.toXml()}, profile=profile)
|
||||
action_data = {'xmlui': xmlui.toXml()}
|
||||
if action_extra is not None:
|
||||
action_data.update(action_extra)
|
||||
host.actionNew(action_data, profile=profile)
|
||||
return xmlui_d
|
||||
|
||||
def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE):
|
||||
def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None,
|
||||
action_extra=None, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE):
|
||||
"""Create a submitable dialog and manage it with a deferred
|
||||
|
||||
@param message(unicode): message to display
|
||||
@param title(unicode): title of the dialog
|
||||
@param type(unicode): dialog type (C.XMLUI_DIALOG_*)
|
||||
@param options(None, dict): if not None, will be used to update (extend) dialog_opt arguments of XMLUI
|
||||
@param action_extra(None, dict): extra action to merge with xmlui
|
||||
mainly used to add meta informations (see actionNew doc)
|
||||
@param security_limit: %(doc_security_limit)s
|
||||
@param profile: %(doc_profile)s
|
||||
@return (dict): Deferred dict
|
||||
"""
|
||||
|
|
@ -1284,7 +1293,7 @@ def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CON
|
|||
if options is not None:
|
||||
dialog_opt.update(options)
|
||||
dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt=dialog_opt, submit_id='')
|
||||
return deferXMLUI(host, dialog, security_limit, profile)
|
||||
return deferXMLUI(host, dialog, action_extra, security_limit, profile)
|
||||
|
||||
def deferConfirm(*args, **kwargs):
|
||||
"""call deferDialog and return a boolean instead of the whole data dict"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue