comparison src/core/xmpp.py @ 1450:7797dda847ae

plugins xep-0277, groupblog: added subscriteToMany to replace massiveSubscribeGroupBlogs + added SatRosterProtocol.getJidsSet
author Goffi <goffi@goffi.org>
date Sat, 15 Aug 2015 22:20:43 +0200
parents 7590bbf44eed
children 8d61160ee4b8
comparison
equal deleted inserted replaced
1449:389357fd79ce 1450:7797dda847ae
305 try: 305 try:
306 return self._groups[group] 306 return self._groups[group]
307 except KeyError: 307 except KeyError:
308 raise exceptions.UnknownGroupError(group) 308 raise exceptions.UnknownGroupError(group)
309 309
310 def getJidsSet(self, type_, groups=None):
311 """Helper method to get a set of jids
312
313 @param type_(unicode): one of:
314 C.ALL: get all jids from roster
315 C.GROUP: get jids from groups (listed in "groups")
316 @groups(list[unicode]): list of groups used if type_==C.GROUP
317 @return (set(jid.JID)): set of selected jids
318 """
319 if type_ == C.ALL and groups is not None:
320 raise ValueError('groups must not be set for {} type'.format(C.ALL))
321
322 if type_ == C.ALL:
323 return set(self.getJids())
324 elif type_ == C.GROUP:
325 jids = set()
326 for group in groups:
327 jids.update(self.getJidsFromGroup(group))
328 return jids
329 else:
330 raise ValueError(u'Unexpected type_ {}'.format(type_))
331
310 332
311 class SatPresenceProtocol(xmppim.PresenceClientProtocol): 333 class SatPresenceProtocol(xmppim.PresenceClientProtocol):
312 334
313 def __init__(self, host): 335 def __init__(self, host):
314 xmppim.PresenceClientProtocol.__init__(self) 336 xmppim.PresenceClientProtocol.__init__(self)