comparison src/core/xmpp.py @ 501:e9634d2e7b38

core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1: - QuickContactManagement is not used anymore and will be removed, ContactList + Core are used instead - disconnected contacts are now displayed in Primitivus (M-d to show/hide them) - avatars are temporary unavailable in wix - new bridge method: getContactsFromGroup
author Goffi <goffi@goffi.org>
date Tue, 25 Sep 2012 00:58:34 +0200
parents e789917fb59d
children 862c0d6ab974
comparison
equal deleted inserted replaced
500:00d3679976ab 501:e9634d2e7b38
21 21
22 from twisted.internet import task, defer 22 from twisted.internet import task, defer
23 from twisted.words.protocols.jabber import jid, xmlstream 23 from twisted.words.protocols.jabber import jid, xmlstream
24 from wokkel import client, disco, xmppim, generic, compat 24 from wokkel import client, disco, xmppim, generic, compat
25 from logging import debug, info, error 25 from logging import debug, info, error
26 from sat.core import exceptions
26 27
27 28
28 class SatXMPPClient(client.XMPPClient): 29 class SatXMPPClient(client.XMPPClient):
29 30
30 def __init__(self, host_app, profile, user_jid, password, host=None, port=5222): 31 def __init__(self, host_app, profile, user_jid, password, host=None, port=5222):
162 163
163 def getAttributes(self, item): 164 def getAttributes(self, item):
164 """Return dictionary of attributes as used in bridge from a RosterItem 165 """Return dictionary of attributes as used in bridge from a RosterItem
165 @param item: RosterItem 166 @param item: RosterItem
166 @return: dictionary of attributes""" 167 @return: dictionary of attributes"""
167 item_attr = {'to': str(item.subscriptionTo), 168 item_attr = {'to': unicode(item.subscriptionTo),
168 'from': str(item.subscriptionFrom), 169 'from': unicode(item.subscriptionFrom),
169 'ask': str(item.ask) 170 'ask': unicode(item.ask)
170 } 171 }
171 if item.name: 172 if item.name:
172 item_attr['name'] = item.name 173 item_attr['name'] = item.name
173 return item_attr 174 return item_attr
174 175
233 return entity_jid.userhost() in self._jids 234 return entity_jid.userhost() in self._jids
234 235
235 def getItems(self): 236 def getItems(self):
236 """Return all items of the roster""" 237 """Return all items of the roster"""
237 return self._jids.values() 238 return self._jids.values()
239
240 def getJidsFromGroup(self, group):
241 try:
242 return self._groups[group]
243 except KeyError:
244 return exceptions.UnknownGroupError
238 245
239 246
240 class SatPresenceProtocol(xmppim.PresenceClientProtocol): 247 class SatPresenceProtocol(xmppim.PresenceClientProtocol):
241 248
242 def __init__(self, host): 249 def __init__(self, host):