import re, string, types, binascii, socket, time, random, subprocess, sys, os
from offlineimap.ui import UIBase
+from imaplib import *
-class IMAP4_Tunnel(imaplib.IMAP4):
+class IMAP4_Tunnel(IMAP4):
"""IMAP4 client class over a tunnel
Instantiate with: IMAP4_Tunnel(tunnelcmd)
The result will be in PREAUTH stage."""
def __init__(self, tunnelcmd):
- imaplib.IMAP4.__init__(self, tunnelcmd)
+ IMAP4.__init__(self, tunnelcmd)
def open(self, host, port):
"""The tunnelcmd comes in on host!"""
self.outfd.close()
self.process.wait()
-# FIXME: need to use this in SSL instances
class sslwrapper:
def __init__(self, sslsock):
self.sslsock = sslsock
else:
retval += linebuf
-# FIXME: need to override this in IMAP instances
-
def new_mesg(self, s, secs=None):
if secs is None:
secs = time.time()
tm = time.strftime('%M:%S', time.localtime(secs))
UIBase.getglobalui().debug('imap', ' %s.%02d %s' % (tm, (secs*100)%100, s))
-# FIXME: use this
-def new_open(self, host = '', port = imaplib.IMAP4_PORT):
+def new_open(self, host = '', port = IMAP4_PORT):
"""Setup connection to remote server on "host:port"
(default: localhost:standard IMAP4 port).
This connection will be used by the routines:
# IMAP server support
-# Copyright (C) 2002, 2003 John Goerzen
+# Copyright (C) 2002 - 2007 John Goerzen
# <jgoerzen@complete.org>
#
# This program is free software; you can redistribute it and/or modify
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-from offlineimap import imaplib, imaputil, threadutil
+import imaplib
+from offlineimap import imaplibutil, imaputil, threadutil
from offlineimap.ui import UIBase
from threading import *
import thread, hmac, os
else:
self.selectedfolder = None
-class UsefulIMAP4(UsefulIMAPMixIn, imaplib.IMAP4): pass
-class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplib.IMAP4_SSL): pass
+ def _mesg(self, s, secs=None):
+ imaplibutil.new_mseg(self, s, secs)
+
+class UsefulIMAP4(UsefulIMAPMixIn, imaplib.IMAP4):
+ def open(self, host = '', port = imaplib.IMAP4_PORT):
+ imaplibutil.new_open(self, host, port)
+
+class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplib.IMAP4_SSL):
+ def open(self, host = '', port = imaplib.IMAP4_SSL_PORT):
+ imaplibutil.new_open_ssl(self, host, port)
+
class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplib.IMAP4_Tunnel): pass
class IMAPServer:
UIBase.getglobalui().connecting(self.hostname, self.port)
imapobj = UsefulIMAP4(self.hostname, self.port)
+ imapobj.mustquote = imaplibutil.mustquote
+
if not self.tunnel:
try:
if 'AUTH=CRAM-MD5' in imapobj.capabilities: