From c83141656e851440048bbf3d3a6875809d06ed86 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Tue, 9 Jul 2002 03:32:35 +0100 Subject: [PATCH] /head: changeset 86 Added folderincludes capability --- head/debian/changelog | 4 ++- head/offlineimap.conf | 39 ++++++++++++++++++++++++----- head/offlineimap/folder/IMAP.py | 7 +++--- head/offlineimap/repository/IMAP.py | 9 ++++++- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/head/debian/changelog b/head/debian/changelog index 455ce1e..cb7aa5e 100644 --- a/head/debian/changelog +++ b/head/debian/changelog @@ -1,6 +1,8 @@ offlineimap (2.0.5) unstable; urgency=low - * Placeholder + * Fixed a folderfilter example. Partially fixes #152079. + * Added folderincludes capability. Partially fixes #152079. + * More fixes for read-only folders. -- John Goerzen Fri, 5 Jul 2002 09:21:52 -0500 diff --git a/head/offlineimap.conf b/head/offlineimap.conf index e4c2a41..50fca86 100644 --- a/head/offlineimap.conf +++ b/head/offlineimap.conf @@ -79,6 +79,15 @@ footer = "\n" # for each account listed in general/accounts above. [Test] + +########## Basic settings + +# Specify local repository. Your IMAP folders will be synchronized +# to maildirs created under this path. OfflineIMAP will create the +# maildirs for you as needed. + +localfolders = ~/Test + # Specify the remote hostname. remotehost = examplehost @@ -118,6 +127,9 @@ remoteuser = username # preauthtunnel = ssh -q imaphost '/usr/bin/imapd ./Maildir' # +########## Advanced settings + + # 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 @@ -125,12 +137,6 @@ remoteuser = username # # 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. - -localfolders = ~/Test - # You can specify a folder translator. This must be a eval-able # Python expression that takes a foldername arg and returns the new # value. I suggest a lambda. This example below will remove "INBOX." from @@ -179,6 +185,27 @@ localfolders = ~/Test # # folderfilter = lambda foldername: 0 +# You can specify folderincludes to include additional folders. +# It should return a Python list. This might be used to include a +# folder that was excluded by your folderfilter rule, to include a +# folder that your server does not specify with its LIST option, or +# to include a folder that is outside your basic reference. Some examples: +# +# To include debian.user and debian.personal: +# +# folderincludes = ['debian.user', 'debian.personal'] +# +# To include your INBOX (UW IMAPd users will find this useful if they +# specify a reference): +# +# folderincludes = ['INBOX'] +# +# To specify a long list: +# +# folderincludes = ['box1', 'box2', 'box3', 'box4', +# 'box5', 'box6'] + + # OfflineIMAP can use multiple connections to the server in order # to perform multiple synchronization actions simultaneously. # This may place a higher burden on the server. In most cases, diff --git a/head/offlineimap/folder/IMAP.py b/head/offlineimap/folder/IMAP.py index 03ac6db..4085417 100644 --- a/head/offlineimap/folder/IMAP.py +++ b/head/offlineimap/folder/IMAP.py @@ -46,9 +46,10 @@ class IMAPFolder(BaseFolder): def getuidvalidity(self): imapobj = self.imapserver.acquireconnection() try: - x = imapobj.status(self.getfullname(), '(UIDVALIDITY)')[1][0] - except imapobj.readonly: - pass + try: + x = imapobj.status(self.getfullname(), '(UIDVALIDITY)')[1][0] + except imapobj.readonly: + pass finally: self.imapserver.releaseconnection(imapobj) uidstring = imaputil.imapsplit(x)[1] diff --git a/head/offlineimap/repository/IMAP.py b/head/offlineimap/repository/IMAP.py index be0ef8d..d0833ce 100644 --- a/head/offlineimap/repository/IMAP.py +++ b/head/offlineimap/repository/IMAP.py @@ -31,10 +31,13 @@ class IMAPRepository(BaseRepository): self.folders = None self.nametrans = lambda foldername: foldername self.folderfilter = lambda foldername: 1 + self.folderincludes = [] if config.has_option(accountname, 'nametrans'): self.nametrans = eval(config.get(accountname, 'nametrans')) if config.has_option(accountname, 'folderfilter'): self.folderfilter = eval(config.get(accountname, 'folderfilter')) + if config.has_option(accountname, 'folderincludes'): + self.folderincludes = eval(config.get(accountname, 'folderincludes')) def getsep(self): return self.imapserver.delim @@ -61,7 +64,11 @@ class IMAPRepository(BaseRepository): foldername = imaputil.dequote(name) if not self.folderfilter(foldername): continue - retval.append(folder.IMAP.IMAPFolder(self.imapserver, name, + retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername, + self.nametrans(foldername), + self.accountname)) + for foldername in self.folderincludes: + retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername, self.nametrans(foldername), self.accountname)) retval.sort(lambda x, y: cmp(x.getvisiblename(), y.getvisiblename()))