home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / jabber / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  5.3 KB  |  117 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. status_state_map = {
  5.     'available': 'normal',
  6.     'away': 'away',
  7.     'free for chat': 'chat',
  8.     'do not disturb': 'dnd',
  9.     'extended away': 'xa' }
  10. import disco
  11. import filetransfer
  12. import objects
  13. import jabber_util
  14. import threadstreamsocket
  15. from util.primitives.structures import enum
  16. from pyxmpp.jid import JID
  17. from pyxmpp.presence import Presence
  18. from pyxmpp.jabber.vcard import VCard
  19. from jabber.JabberResource import JabberResource as resource
  20. from jabber.JabberConversation import JabberConversation as conversation
  21. from jabber.JabberBuddy import JabberBuddy as jbuddy
  22. from jabber.JabberContact import JabberContact as jcontact
  23. from jabber.JabberBuddies import JabberBuddies as jbuddies
  24. from jabber.JabberProtocol import JabberProtocol as protocol
  25. from jabber.JabberChat import JabberChat as chat
  26. from jabber.filetransfer.S5BFileXferHandler import SOCKS5Bytestream
  27. from jabber.objects.si import SI_NS
  28. from jabber.objects.bytestreams import BYTESTREAMS_NS
  29. from jabber.objects.si_filetransfer import SI_FILETRANSFER_NS
  30. from jabber.idle_loop import IdleLoopTimer
  31. from PIL import Image
  32.  
  33. class JabberException(Exception):
  34.     pass
  35.  
  36. show_types = (None, u'away', u'xa', u'dnd', u'chat')
  37. available_show_types = (None, u'chat', u'normal')
  38. status_states = enum([
  39.     'Online',
  40.     'Away',
  41.     'Extended Away',
  42.     'Do Not Disturb',
  43.     'Free For Chat'])
  44. features_supported = [
  45.     'http://jabber.org/protocol/disco#info',
  46.     BYTESTREAMS_NS,
  47.     SI_NS,
  48.     SI_FILETRANSFER_NS]
  49. import pyxmpp.jabber.vcard as vcard
  50. vcard.VCard.components.update({
  51.     'FN': (vcard.VCardString, 'optional'),
  52.     'N': (vcard.VCardName, 'optional') })
  53. import pyxmpp.streambase as streambase
  54.  
  55. def _process_node(self, xmlnode):
  56.     ns_uri = xmlnode.ns().getContent()
  57.     if ns_uri == 'http://etherx.jabber.org/streams':
  58.         self._process_stream_node(xmlnode)
  59.         return None
  60.     if ns_uri == self.default_ns_uri:
  61.         stanza = streambase.stanza_factory(xmlnode, self)
  62.         stanza.handler_frees = False
  63.         self.lock.release()
  64.         
  65.         try:
  66.             self.process_stanza(stanza)
  67.         finally:
  68.             self.lock.acquire()
  69.  
  70.     else:
  71.         self.__logger.debug('Unhandled node: %r' % (xmlnode.serialize(),))
  72.  
  73. streambase.StreamBase._process_node = _process_node
  74.  
  75. class VCardPhotoData(vcard.VCardField, vcard.VCardImage):
  76.     
  77.     def __init__(self, value):
  78.         vcard.VCardField.__init__(self, 'PHOTO')
  79.         self.image = value
  80.         self.type = unicode(image_mimetype(value))
  81.         self.uri = None
  82.  
  83.  
  84.  
  85. def image_mimetype(imgdata):
  86.     import StringIO
  87.     return 'image/' + Image.open(StringIO.StringIO(imgdata)).format.lower()
  88.  
  89.  
  90. class VCardAdr(vcard.VCardField, vcard.VCardAdr):
  91.     
  92.     def __init__(self, value):
  93.         vcard.VCardField.__init__(self, 'PHOTO')
  94.         (self.pobox, self.extadr, self.street, self.locality, self.region, self.pcode, self.ctry) = [
  95.             ''] * 7
  96.         self.type = []
  97.  
  98.  
  99.  
  100. def rosterclone(self):
  101.     return type(self)(self.jid, self.subscription, self.name, groups = tuple(self.groups))
  102.  
  103. import pyxmpp.roster as pyxmpp
  104. pyxmpp.roster.RosterItem.clone = rosterclone
  105. from pyxmpp.client import Client
  106. from pyxmpp.jabber.client import JabberClient
  107. from pyxmpp.jabber.disco import DISCO_ITEMS_NS, DISCO_INFO_NS
  108. from pyxmpp.jabber import disco as pyxmpp_disco
  109.  
  110. def authorized(self):
  111.     self.stream.set_iq_get_handler('query', DISCO_ITEMS_NS, self._JabberClient__disco_items)
  112.     self.stream.set_iq_get_handler('query', DISCO_INFO_NS, self._JabberClient__disco_info)
  113.     pyxmpp_disco.register_disco_cache_fetchers(self.cache, self.stream)
  114.     Client.authorized(self)
  115.  
  116. JabberClient.authorized = authorized
  117.