plugin XEP-0050: fixed getDiscoItems when no commands were added + fixed commands purge on profile disconnection

This commit is contained in:
Goffi 2013-12-24 01:31:01 +01:00
commit 7d60564e23

View file

@ -227,6 +227,12 @@ class XEP_0050(object):
def profileConnected(self, profile):
self.addAdHocCommand(self._statusCallback, _("Status"), profile_key="@ALL@")
def profileDisconnected(self, profile):
try:
del self.answering[profile]
except KeyError:
pass
def _statusCallback(self, command_elt, session_data, action, node, profile):
""" Ad-hoc command used to change the "show" part of status """
actions = session_data.setdefault('actions',[])
@ -350,7 +356,7 @@ class XEP_0050_handler(XMPPHandler):
def getDiscoItems(self, requestor, target, nodeIdentifier=''):
ret = []
if nodeIdentifier == NS_COMMANDS:
for command in self.plugin_parent.answering[self.parent.profile].values():
for command in self.plugin_parent.answering.get(self.parent.profile,{}).values():
if command.isAuthorised(requestor):
ret.append(disco.DiscoItem(self.parent.jid, command.node, command.getName())) #TODO: manage name language
return ret