# HG changeset patch # User Goffi # Date 1447525316 -3600 # Node ID e2ed8009e66e5817069f90cb1438b08c2163feb9 # Parent b144babc26587dfcf14cdd6dadc5adf7e7f33425 backend, bridge, frontends: actionNew has now a security_limit argument + added some docstring to explain data argument diff -r b144babc2658 -r e2ed8009e66e frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Sat Nov 14 19:20:33 2015 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Sat Nov 14 19:21:56 2015 +0100 @@ -464,7 +464,7 @@ 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): diff -r b144babc2658 -r e2ed8009e66e src/bridge/DBus.py --- a/src/bridge/DBus.py Sat Nov 14 19:20:33 2015 +0100 +++ b/src/bridge/DBus.py Sat Nov 14 19:21:56 2015 +0100 @@ -126,8 +126,8 @@ 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 @@ 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) diff -r b144babc2658 -r e2ed8009e66e src/bridge/bridge_constructor/bridge_template.ini --- a/src/bridge/bridge_constructor/bridge_template.ini Sat Nov 14 19:20:33 2015 +0100 +++ b/src/bridge/bridge_constructor/bridge_template.ini Sat Nov 14 19:21:56 2015 +0100 @@ -112,14 +112,23 @@ [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= diff -r b144babc2658 -r e2ed8009e66e src/core/constants.py --- a/src/core/constants.py Sat Nov 14 19:20:33 2015 +0100 +++ b/src/core/constants.py Sat Nov 14 19:21:56 2015 +0100 @@ -211,6 +211,11 @@ 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' diff -r b144babc2658 -r e2ed8009e66e src/core/sat_main.py --- a/src/core/sat_main.py Sat Nov 14 19:20:33 2015 +0100 +++ b/src/core/sat_main.py Sat Nov 14 19:21:56 2015 +0100 @@ -785,14 +785,15 @@ 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""" diff -r b144babc2658 -r e2ed8009e66e src/plugins/plugin_misc_watched.py --- a/src/plugins/plugin_misc_watched.py Sat Nov 14 19:20:33 2015 +0100 +++ b/src/plugins/plugin_misc_watched.py Sat Nov 14 19:21:56 2015 +0100 @@ -76,6 +76,6 @@ 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 diff -r b144babc2658 -r e2ed8009e66e src/tools/xml_tools.py --- a/src/tools/xml_tools.py Sat Nov 14 19:20:33 2015 +0100 +++ b/src/tools/xml_tools.py Sat Nov 14 19:21:56 2015 +0100 @@ -1249,12 +1249,13 @@ ) 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 @@ 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 @@ 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"""