From 8d9d2188327226e43ff0b091013917be3150bc7d Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Fri, 5 Jul 2002 12:46:55 +0100 Subject: [PATCH] /head: changeset 82 Modified to allow specifying a reference --- head/debian/changelog | 7 +++++++ head/offlineimap.conf | 7 +++++++ head/offlineimap.py | 10 ++++++++-- head/offlineimap/imapserver.py | 7 ++++--- head/offlineimap/repository/IMAP.py | 2 +- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/head/debian/changelog b/head/debian/changelog index 02ca232..e686142 100644 --- a/head/debian/changelog +++ b/head/debian/changelog @@ -1,3 +1,10 @@ +offlineimap (2.0.3) unstable; urgency=low + + * Added support for specifying references. Closes: #151960. + * Added -d command-line option to enable imaplib debugging. + + -- John Goerzen Thu, 4 Jul 2002 20:39:29 -0500 + offlineimap (2.0.2) unstable; urgency=low * Added support for remotepassfile. Closes: #151943. diff --git a/head/offlineimap.conf b/head/offlineimap.conf index a18f582..1b98b92 100644 --- a/head/offlineimap.conf +++ b/head/offlineimap.conf @@ -118,6 +118,13 @@ remoteuser = username # preauthtunnel = ssh -q imaphost '/usr/bin/imapd ./Maildir' # +# Some IMAP servers need a "reference" which often refers to the +# "folder root". This is most commonly needed with UW IMAP, where +# you might need to specify the directory in which your mail is +# stored. Most users will not need this. +# +# reference = Mail + # Specify local repository. Your IMAP folders will be synchronized # to maildirs created under this path. OfflineIMAP will create the # maildirs for you as needed. diff --git a/head/offlineimap.py b/head/offlineimap.py index 247ee5a..1cb95c9 100644 --- a/head/offlineimap.py +++ b/head/offlineimap.py @@ -23,7 +23,8 @@ import re, os, os.path, offlineimap, sys from ConfigParser import ConfigParser from threading import * -# imaplib.Debug = 5 +if '-d' in sys.argv: + imaplib.Debug = 5 ui = offlineimap.ui.TTY.TTYUI() ui.init_banner() @@ -94,16 +95,21 @@ def syncaccount(accountname, *args): port = config.getint(accountname, "remoteport") ssl = config.getboolean(accountname, "ssl") usetunnel = config.has_option(accountname, "preauthtunnel") + reference = '""' + if config.has_option(accountname, "reference"): + reference = config.get(accountname, "reference") server = None # Connect to the remote server. if usetunnel: server = imapserver.IMAPServer(tunnel = tunnels[accountname], + reference = reference, maxconnections = config.getint(accountname, "maxconnections")) else: server = imapserver.IMAPServer(user, passwords[accountname], host, port, ssl, - config.getint(accountname, "maxconnections")) + config.getint(accountname, "maxconnections"), + reference = reference) remoterepos = repository.IMAP.IMAPRepository(config, accountname, server) # Connect to the Maildirs. diff --git a/head/offlineimap/imapserver.py b/head/offlineimap/imapserver.py index f8ced64..0931f04 100644 --- a/head/offlineimap/imapserver.py +++ b/head/offlineimap/imapserver.py @@ -45,7 +45,8 @@ class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplib.IMAP4_Tunnel): pass class IMAPServer: def __init__(self, username = None, password = None, hostname = None, - port = None, ssl = 1, maxconnections = 1, tunnel = None): + port = None, ssl = 1, maxconnections = 1, tunnel = None, + reference = '""'): self.username = username self.password = password self.hostname = hostname @@ -64,7 +65,7 @@ class IMAPServer: self.assignedconnections = [] self.semaphore = BoundedSemaphore(self.maxconnections) self.connectionlock = Lock() - + self.reference = reference def getdelim(self): """Returns this server's folder delimiter. Can only be called @@ -116,7 +117,7 @@ class IMAPServer: if self.delim == None: self.delim, self.root = \ - imaputil.imapsplit(imapobj.list('""', '""')[1][0])[1:] + imaputil.imapsplit(imapobj.list(self.reference, '""')[1][0])[1:] self.delim = imaputil.dequote(self.delim) self.root = imaputil.dequote(self.root) diff --git a/head/offlineimap/repository/IMAP.py b/head/offlineimap/repository/IMAP.py index 391ea7a..cef804e 100644 --- a/head/offlineimap/repository/IMAP.py +++ b/head/offlineimap/repository/IMAP.py @@ -50,7 +50,7 @@ class IMAPRepository(BaseRepository): retval = [] imapobj = self.imapserver.acquireconnection() try: - listresult = imapobj.list()[1] + listresult = imapobj.list(directory = self.imapserver.reference)[1] finally: self.imapserver.releaseconnection(imapobj) for string in listresult: