comparison src/plugins/plugin_xep_0050.py @ 753:7f98f53f6997

plugin XEP-0050: fixed getDiscoItems when no commands were added + fixed commands purge on profile disconnection
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 01:31:01 +0100
parents e07afabc4a25
children 86224a13cc1d
comparison
equal deleted inserted replaced
752:f49945d728de 753:7f98f53f6997
225 return XEP_0050_handler(self) 225 return XEP_0050_handler(self)
226 226
227 def profileConnected(self, profile): 227 def profileConnected(self, profile):
228 self.addAdHocCommand(self._statusCallback, _("Status"), profile_key="@ALL@") 228 self.addAdHocCommand(self._statusCallback, _("Status"), profile_key="@ALL@")
229 229
230 def profileDisconnected(self, profile):
231 try:
232 del self.answering[profile]
233 except KeyError:
234 pass
235
230 def _statusCallback(self, command_elt, session_data, action, node, profile): 236 def _statusCallback(self, command_elt, session_data, action, node, profile):
231 """ Ad-hoc command used to change the "show" part of status """ 237 """ Ad-hoc command used to change the "show" part of status """
232 actions = session_data.setdefault('actions',[]) 238 actions = session_data.setdefault('actions',[])
233 actions.append(action) 239 actions.append(action)
234 240
348 return [disco.DiscoFeature(NS_COMMANDS)] + identities 354 return [disco.DiscoFeature(NS_COMMANDS)] + identities
349 355
350 def getDiscoItems(self, requestor, target, nodeIdentifier=''): 356 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
351 ret = [] 357 ret = []
352 if nodeIdentifier == NS_COMMANDS: 358 if nodeIdentifier == NS_COMMANDS:
353 for command in self.plugin_parent.answering[self.parent.profile].values(): 359 for command in self.plugin_parent.answering.get(self.parent.profile,{}).values():
354 if command.isAuthorised(requestor): 360 if command.isAuthorised(requestor):
355 ret.append(disco.DiscoItem(self.parent.jid, command.node, command.getName())) #TODO: manage name language 361 ret.append(disco.DiscoItem(self.parent.jid, command.node, command.getName())) #TODO: manage name language
356 return ret 362 return ret