| 87 | | def __init__(self, JabberServerURL, port=5222, ServerJID=None, namespace='jabber:client', fileIn=None, fileOut=None, **kw): |
|---|
| | 87 | def __init__(self, *args, **kw): |
|---|
| | 88 | # Base code |
|---|
| | 89 | XMLBuilderMixin.__init__(self) |
|---|
| | 90 | |
|---|
| | 91 | if args or kw: |
|---|
| | 92 | apply(self.Startup, args, kw) |
|---|
| | 93 | |
|---|
| | 94 | def __del__(self): |
|---|
| | 95 | self.Shutdown() |
|---|
| | 96 | |
|---|
| | 97 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 98 | #~ Public Methods |
|---|
| | 99 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 100 | |
|---|
| | 101 | def Startup(self, JabberServerURL, port=5222, ServerJID=None, namespace='jabber:client', fileIn=None, fileOut=None, **kw): |
|---|
| 115 | | def __del__(self): |
|---|
| 116 | | self.Shutdown() |
|---|
| 117 | | |
|---|
| 118 | | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 119 | | #~ Public Methods |
|---|
| 120 | | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 126 | def Shutdown(self): |
|---|
| | 127 | """Politely disconnects the socket and parser from the jabber stream""" |
|---|
| | 128 | if __debug__: print 'Disconnecting %s from %s' % (self.__class__.__name__, self.ServerJID) |
|---|
| | 129 | self._SendXMLImmediate('%s' % _xmlJabberFooter) |
|---|
| | 130 | if self._fileIn: print >> self._fileIn, '</stream:stream>' |
|---|
| | 131 | self._socket = None |
|---|
| | 132 | self._parser = None |
|---|
| | 133 | |
|---|
| | 134 | def _SetDebug(self, fileIn, fileOut): |
|---|
| | 135 | """Sets the debug input and output files (or file-like-objects). |
|---|
| | 136 | These can also be passed in when creating the Jabber Client""" |
|---|
| | 137 | self._fileIn = fileIn |
|---|
| | 138 | self._fileOut = fileOut |
|---|
| 134 | | |
|---|
| 135 | | def Shutdown(self): |
|---|
| 136 | | """Politely disconnects the socket and parser from the jabber stream""" |
|---|
| 137 | | if __debug__: print 'Disconnecting %s from %s' % (self.__class__.__name__, self.ServerJID) |
|---|
| 138 | | self._SendXMLImmediate('%s' % _xmlJabberFooter) |
|---|
| 139 | | if self._fileIn: print >> self._fileIn, '</stream:stream>' |
|---|
| 140 | | self._socket = None |
|---|
| 141 | | self._parser = None |
|---|
| 142 | | |
|---|
| 143 | | def _SetDebug(self, fileIn, fileOut): |
|---|
| 144 | | """Sets the debug input and output files (or file-like-objects). |
|---|
| 145 | | These can also be passed in when creating the Jabber Client""" |
|---|
| 146 | | self._fileIn = fileIn |
|---|
| 147 | | self._fileOut = fileOut |
|---|