backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument
This commit is contained in:
parent
2c8b91ee6c
commit
fbbb081425
7 changed files with 30 additions and 14 deletions
|
|
@ -464,7 +464,7 @@ class QuickApp(object):
|
|||
self.contact_lists[profile].clearContacts()
|
||||
self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile)
|
||||
|
||||
def actionNewHandler(self, action_data, id_, profile):
|
||||
def actionNewHandler(self, action_data, id_, security_limit, profile):
|
||||
self.actionManager(action_data, profile=profile)
|
||||
|
||||
def newContactHandler(self, jid_s, attributes, groups, profile):
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ class DbusObject(dbus.service.Object):
|
|||
pass
|
||||
|
||||
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
signature='a{ss}ss')
|
||||
def actionNew(self, action_data, id, profile):
|
||||
signature='a{ss}sis')
|
||||
def actionNew(self, action_data, id, security_limit, profile):
|
||||
pass
|
||||
|
||||
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
|
|
@ -590,8 +590,8 @@ class DBusBridge(Bridge):
|
|||
self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
|
||||
self.dbus_bridge = DbusObject(self.session_bus, const_OBJ_PATH)
|
||||
|
||||
def actionNew(self, action_data, id, profile):
|
||||
self.dbus_bridge.actionNew(action_data, id, profile)
|
||||
def actionNew(self, action_data, id, security_limit, profile):
|
||||
self.dbus_bridge.actionNew(action_data, id, security_limit, profile)
|
||||
|
||||
def actionResult(self, answer_type, id, data, profile):
|
||||
self.dbus_bridge.actionResult(answer_type, id, data, profile)
|
||||
|
|
|
|||
|
|
@ -112,14 +112,23 @@ doc_param_3=%(doc_profile)s
|
|||
[actionNew]
|
||||
type=signal
|
||||
category=core
|
||||
sig_in=a{ss}ss
|
||||
sig_in=a{ss}sis
|
||||
doc=A frontend action is requested
|
||||
doc_param_0=action_data: a dict where key can be:
|
||||
- xmlui: a XMLUI need to be displayed
|
||||
- progress: a progress id
|
||||
- meta_*: meta information on the action, used to make automation more easy,
|
||||
some are defined below
|
||||
- meta_from_jid: origin of the request
|
||||
- meta_type: type of the request, can be one of:
|
||||
- C.META_TYPE_FILE: a file transfer request validation
|
||||
- C.META_TYPE_OVERWRITE: a file overwriting confirmation
|
||||
- meta_progress_id: progress id linked to this action
|
||||
doc_param_1=id: action id
|
||||
This id can be used later by frontends to announce to other ones
|
||||
That the action is managed and can now be ignored.
|
||||
doc_param_2=%(doc_profile)s
|
||||
doc_param_2=%(doc_security_limit)s
|
||||
doc_param_3=%(doc_profile)s
|
||||
|
||||
[actionResult]
|
||||
deprecated=
|
||||
|
|
|
|||
|
|
@ -211,6 +211,11 @@ class Const(object):
|
|||
LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
|
||||
|
||||
|
||||
## action constants ##
|
||||
META_TYPE_FILE = "file"
|
||||
META_TYPE_OVERWRITE = "overwrite"
|
||||
|
||||
|
||||
## HARD-CODED ACTIONS IDS (generated with uuid.uuid4) ##
|
||||
AUTHENTICATE_PROFILE_ID = u'b03bbfa8-a4ae-4734-a248-06ce6c7cf562'
|
||||
CHANGE_XMPP_PASSWD_ID = u'878b9387-de2b-413b-950f-e424a147bcd0'
|
||||
|
|
|
|||
|
|
@ -785,14 +785,15 @@ class SAT(service.Service):
|
|||
del client._waiting_conf[conf_id]
|
||||
cb(conf_id, accepted, data, profile)
|
||||
|
||||
def actionNew(self, action_data, profile):
|
||||
def actionNew(self, action_data, security_limit=C.NO_SECURITY_LIMIT, profile=C.PROF_KEY_NONE):
|
||||
"""Shortcut to bridge.actionNew which generate and id
|
||||
|
||||
@param action_data(dict): action data (see bridge documentation)
|
||||
@param security_limit: %(doc_security_limit)s
|
||||
@param profile: %(doc_profile)s
|
||||
"""
|
||||
id_ = unicode(uuid.uuid4())
|
||||
self.bridge.actionNew(action_data, id_, profile)
|
||||
self.bridge.actionNew(action_data, id_, security_limit, profile)
|
||||
|
||||
def registerProgressCb(self, progress_id, callback, profile):
|
||||
"""Register a callback called when progress is requested for id"""
|
||||
|
|
|
|||
|
|
@ -76,6 +76,6 @@ class Watched(object):
|
|||
if old_show == C.PRESENCE_UNAVAILABLE:
|
||||
watched = self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile)
|
||||
if entity in watched or entity.userhostJID() in watched:
|
||||
self.host.actionNew({'xmlui': xml_tools.note(_(NOTIF).format(entity=entity.full())).toXml()}, profile)
|
||||
self.host.actionNew({'xmlui': xml_tools.note(_(NOTIF).format(entity=entity.full())).toXml()}, profile=profile)
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -1249,12 +1249,13 @@ def note(message, title='', level=C.XMLUI_DATA_LVL_INFO):
|
|||
)
|
||||
return note_xmlui
|
||||
|
||||
def deferXMLUI(host, xmlui, profile):
|
||||
def deferXMLUI(host, xmlui, 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 security_limit: %(doc_security_limit)s
|
||||
@return (data): a deferred which fire the data
|
||||
"""
|
||||
assert xmlui.submit_id == ''
|
||||
|
|
@ -1265,10 +1266,10 @@ def deferXMLUI(host, xmlui, profile):
|
|||
return {}
|
||||
|
||||
xmlui.submit_id = host.registerCallback(onSubmit, with_data=True, one_shot=True)
|
||||
host.actionNew({'xmlui': xmlui.toXml()}, profile)
|
||||
host.actionNew({'xmlui': xmlui.toXml()}, profile=profile)
|
||||
return xmlui_d
|
||||
|
||||
def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, profile=None):
|
||||
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):
|
||||
"""Create a submitable dialog and manage it with a deferred
|
||||
|
||||
@param message(unicode): message to display
|
||||
|
|
@ -1283,7 +1284,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, profile)
|
||||
return deferXMLUI(host, dialog, 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