comparison src/plugins/plugin_xep_0050.py @ 1494:74ddb4cc2ff9

plugin XEP-0050: return disco for commands only on commands namespace
author Goffi <goffi@goffi.org>
date Tue, 25 Aug 2015 20:02:50 +0200
parents 3265a2639182
children 987e74cbb839
comparison
equal deleted inserted replaced
1493:1285c714a6cc 1494:74ddb4cc2ff9
111 if requestor.userhostJID() in allowed: 111 if requestor.userhostJID() in allowed:
112 return True 112 return True
113 return False 113 return False
114 114
115 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): 115 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
116 if nodeIdentifier != NS_COMMANDS: # FIXME: we should manage other disco nodes here
117 return []
116 # identities = [ID_CMD_LIST if self.node == NS_COMMANDS else ID_CMD_NODE] # FIXME 118 # identities = [ID_CMD_LIST if self.node == NS_COMMANDS else ID_CMD_NODE] # FIXME
117 return [disco.DiscoFeature(NS_COMMANDS)] + self.features 119 return [disco.DiscoFeature(NS_COMMANDS)] + self.features
118 120
119 def getDiscoItems(self, requestor, target, nodeIdentifier=''): 121 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
120 return [] 122 return []
458 client = self.host.getClient(profile_key) 460 client = self.host.getClient(profile_key)
459 d = client.disco.requestItems(to_jid, NS_COMMANDS) 461 d = client.disco.requestItems(to_jid, NS_COMMANDS)
460 d.addCallback(self._items2XMLUI) 462 d.addCallback(self._items2XMLUI)
461 return d 463 return d
462 464
463 def addAdHocCommand(self, callback, label, node="", features = None, timeout = 600, allowed_jids = None, allowed_groups = None, 465 def addAdHocCommand(self, callback, label, node=None, features = None, timeout = 600, allowed_jids = None, allowed_groups = None,
464 allowed_magics = None, forbidden_jids = None, forbidden_groups = None, profile_key=C.PROF_KEY_NONE): 466 allowed_magics = None, forbidden_jids = None, forbidden_groups = None, profile_key=C.PROF_KEY_NONE):
465 """Add an ad-hoc command for the current profile 467 """Add an ad-hoc command for the current profile
466 468
467 @param callback: method associated with this ad-hoc command which return the payload data (see AdHocCommand._sendAnswer), can return a deferred 469 @param callback: method associated with this ad-hoc command which return the payload data (see AdHocCommand._sendAnswer), can return a deferred
468 @param label: label associated with this command on the main menu 470 @param label: label associated with this command on the main menu
469 @param node: disco item node associated with this command. None or "" to use autogenerated node 471 @param node: disco item node associated with this command. None to use autogenerated node
470 @param features: features associated with the payload (list of strings), usualy data form 472 @param features: features associated with the payload (list of strings), usualy data form
471 @param timeout: delay between two requests before canceling the session (in seconds) 473 @param timeout: delay between two requests before canceling the session (in seconds)
472 @param allowed_jids: list of allowed entities 474 @param allowed_jids: list of allowed entities
473 @param allowed_groups: list of allowed roster groups 475 @param allowed_groups: list of allowed roster groups
474 @param allowed_magics: list of allowed magic keys, can be: 476 @param allowed_magics: list of allowed magic keys, can be: