home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2696 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.2 KB  |  91 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import pythoncom
  5. from exception import Exception
  6. import winerror
  7. from win32com import olectl
  8. import win32com.server.util as win32com
  9. IConnectionPointContainer_methods = [
  10.     'EnumConnectionPoints',
  11.     'FindConnectionPoint']
  12. IConnectionPoint_methods = [
  13.     'EnumConnections',
  14.     'Unadvise',
  15.     'Advise',
  16.     'GetConnectionPointContainer',
  17.     'GetConnectionInterface']
  18.  
  19. class ConnectableServer:
  20.     _public_methods_ = IConnectionPointContainer_methods + IConnectionPoint_methods
  21.     _com_interfaces_ = [
  22.         pythoncom.IID_IConnectionPoint,
  23.         pythoncom.IID_IConnectionPointContainer]
  24.     
  25.     def __init__(self):
  26.         self.cookieNo = 0
  27.         self.connections = { }
  28.  
  29.     
  30.     def EnumConnections(self):
  31.         raise Exception(winerror.E_NOTIMPL)
  32.  
  33.     
  34.     def GetConnectionInterface(self):
  35.         raise Exception(winerror.E_NOTIMPL)
  36.  
  37.     
  38.     def GetConnectionPointContainer(self):
  39.         return win32com.server.util.wrap(self)
  40.  
  41.     
  42.     def Advise(self, pUnk):
  43.         
  44.         try:
  45.             interface = pUnk.QueryInterface(self._connect_interfaces_[0], pythoncom.IID_IDispatch)
  46.         except pythoncom.com_error:
  47.             raise Exception(scode = olectl.CONNECT_E_NOCONNECTION)
  48.  
  49.         self.cookieNo = self.cookieNo + 1
  50.         self.connections[self.cookieNo] = interface
  51.         return self.cookieNo
  52.  
  53.     
  54.     def Unadvise(self, cookie):
  55.         
  56.         try:
  57.             del self.connections[cookie]
  58.         except KeyError:
  59.             raise Exception(scode = winerror.E_UNEXPECTED)
  60.  
  61.  
  62.     
  63.     def EnumConnectionPoints(self):
  64.         raise Exception(winerror.E_NOTIMPL)
  65.  
  66.     
  67.     def FindConnectionPoint(self, iid):
  68.         if iid in self._connect_interfaces_:
  69.             return win32com.server.util.wrap(self)
  70.  
  71.     
  72.     def _BroadcastNotify(self, broadcaster, extraArgs):
  73.         for interface in self.connections.values():
  74.             
  75.             try:
  76.                 apply(broadcaster, (interface,) + extraArgs)
  77.             continue
  78.             except pythoncom.com_error:
  79.                 details = None
  80.                 self._OnNotifyFail(interface, details)
  81.                 continue
  82.             
  83.  
  84.         
  85.  
  86.     
  87.     def _OnNotifyFail(self, interface, details):
  88.         print 'Ignoring COM error to connection - %s' % `details`
  89.  
  90.  
  91.