]> code.delx.au - offlineimap/blobdiff - offlineimap/imaplibutil.py
Also make bin/offlineimap +x
[offlineimap] / offlineimap / imaplibutil.py
index b486a341a5646f6119bc320e3b6d98aa05982f03..23ba654cb3e5ec217d328f1b1727d12ef08b5a25 100644 (file)
@@ -1,4 +1,4 @@
-# imaplib
+# imaplib utilities
 # Copyright (C) 2002-2007 John Goerzen
 # <jgoerzen@complete.org>
 #
@@ -20,6 +20,10 @@ import re, string, types, binascii, socket, time, random, subprocess, sys, os
 from offlineimap.ui import UIBase
 from imaplib import *
 
+# Import the symbols we need that aren't exported by default
+from imaplib import IMAP4_PORT, IMAP4_SSL_PORT, InternalDate, Mon2num
+
+
 class IMAP4_Tunnel(IMAP4):
     """IMAP4 client class over a tunnel
 
@@ -99,6 +103,14 @@ def new_mesg(self, s, secs=None):
             tm = time.strftime('%M:%S', time.localtime(secs))
             UIBase.getglobalui().debug('imap', '  %s.%02d %s' % (tm, (secs*100)%100, s))
 
+class WrappedIMAP4_SSL(IMAP4_SSL):
+    def open(self, host = '', port = IMAP4_SSL_PORT):
+        IMAP4_SSL.open(self, host, port)
+        self.sslobj = sslwrapper(self.sslobj)
+
+    def readline(self):
+        return self.sslobj.readline()
+
 def new_open(self, host = '', port = IMAP4_PORT):
         """Setup connection to remote server on "host:port"
             (default: localhost:standard IMAP4 port).
@@ -109,7 +121,6 @@ def new_open(self, host = '', port = IMAP4_PORT):
         self.port = port
         res = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
                                  socket.SOCK_STREAM)
-        self.sock = socket.socket(af, socktype, proto)
 
         # Try each address returned by getaddrinfo in turn until we
         # manage to connect to one.