diff 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
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0050.py	Tue Dec 17 01:46:45 2013 +0100
+++ b/src/plugins/plugin_xep_0050.py	Tue Dec 24 01:31:01 2013 +0100
@@ -227,6 +227,12 @@
     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 @@
     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