comparison src/plugins/plugin_xep_0050.py @ 821:38bc9abd6722

plugin XEP-0050: fixed UnknownGroupError management + "@ALL@" profile for status command
author Goffi <goffi@goffi.org>
date Thu, 13 Feb 2014 18:50:56 +0100
parents 1fe00f0c9a91
children 1a759096ccbd
comparison
equal deleted inserted replaced
820:462f2052af26 821:38bc9abd6722
100 forbidden.update(self.client.roster.getJidsFromGroup(group)) 100 forbidden.update(self.client.roster.getJidsFromGroup(group))
101 if requestor.userhostJID() in forbidden: 101 if requestor.userhostJID() in forbidden:
102 return False 102 return False
103 allowed = set(self.allowed_jids) 103 allowed = set(self.allowed_jids)
104 for group in self.allowed_groups: 104 for group in self.allowed_groups:
105 allowed.update(self.client.roster.getJidsFromGroup(group)) 105 try:
106 allowed.update(self.client.roster.getJidsFromGroup(group))
107 except exceptions.UnknownGroupError:
108 warning(_("The groups [%(group)s] is unknown for profile [%(profile)s])" % {'group':group, 'profile':self.client.profile}))
106 if requestor.userhostJID() in allowed: 109 if requestor.userhostJID() in allowed:
107 return True 110 return True
108 return False 111 return False
109 112
110 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): 113 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
216 219
217 def getHandler(self, profile): 220 def getHandler(self, profile):
218 return XEP_0050_handler(self) 221 return XEP_0050_handler(self)
219 222
220 def profileConnected(self, profile): 223 def profileConnected(self, profile):
221 self.addAdHocCommand(self._statusCallback, _("Status"), profile_key="@ALL@") 224 self.addAdHocCommand(self._statusCallback, _("Status"), profile_key=profile)
222 225
223 def profileDisconnected(self, profile): 226 def profileDisconnected(self, profile):
224 try: 227 try:
225 del self.answering[profile] 228 del self.answering[profile]
226 except KeyError: 229 except KeyError:
411 @param forbidden_jids: black list of entities which can't access this command 414 @param forbidden_jids: black list of entities which can't access this command
412 @param forbidden_groups: black list of groups which can't access this command 415 @param forbidden_groups: black list of groups which can't access this command
413 @param profile_key: profile key associated with this command, @ALL@ means can be accessed with every profiles 416 @param profile_key: profile key associated with this command, @ALL@ means can be accessed with every profiles
414 @return: node of the added command, useful to remove the command later 417 @return: node of the added command, useful to remove the command later
415 """ 418 """
419 # FIXME: "@ALL@" for profile_key seems useless and dangerous
416 420
417 node = node.strip() 421 node = node.strip()
418 if not node: 422 if not node:
419 node = "%s_%s" % ('COMMANDS', uuid4()) 423 node = "%s_%s" % ('COMMANDS', uuid4())
420 424