home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / plugins / digsby_updater / xmpp.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  2.1 KB  |  45 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from peak.util.addons import AddOn
  5. import hooks
  6. import logging
  7. log = logging.getLogger('d_updater.xmpp')
  8. DIGSBY_UPDATER_NS = 'digsby:updater'
  9.  
  10. class DigsbyUpdateMessageHandler(AddOn):
  11.     
  12.     def setup(self, stream):
  13.         self.stream = stream
  14.         log.debug('setting up "%s" message handler', DIGSBY_UPDATER_NS)
  15.         stream.set_message_handler('normal', self.handle_message, namespace = DIGSBY_UPDATER_NS, priority = 90)
  16.  
  17.     
  18.     def handle_message(self, stanza):
  19.         log.debug('update pushed')
  20.         hooks.notify('digsby.updater.pushed')
  21.         return True
  22.  
  23.  
  24.  
  25. def session_started(protocol, stream, *a, **k):
  26.     if getattr(protocol, 'name', None) != 'digsby':
  27.         return None
  28.     DigsbyUpdateMessageHandler(protocol).setup(stream)
  29.  
  30.  
  31. def initialized(protocol, *a, **k):
  32.     if getattr(protocol, 'name', None) != 'digsby':
  33.         return None
  34.     log.debug('registering "%s" feature', DIGSBY_UPDATER_NS)
  35.     protocol.register_feature(DIGSBY_UPDATER_NS)
  36.  
  37.  
  38. def send_update(protocol, name):
  39.     import pyxmpp
  40.     m = pyxmpp.all.Message(to_jid = pyxmpp.all.JID(name, 'digsby.org'))
  41.     update = m.xmlnode.newChild(None, 'update', None)
  42.     update_ns = update.newNs(DIGSBY_UPDATER_NS, None)
  43.     protocol.send(m)
  44.  
  45.