From 140be81efd72f3a78fa175e744bb761731cb6d71 Mon Sep 17 00:00:00 2001 From: Henning Glawe Date: Wed, 13 Aug 2008 01:19:38 +0200 Subject: [PATCH] make the trash and spam folder names in Gmail accounts configurable --- offlineimap.conf | 10 ++++++++++ offlineimap/folder/Gmail.py | 13 +++++-------- offlineimap/repository/Gmail.py | 9 +++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/offlineimap.conf b/offlineimap.conf index b6ed990..6e12296 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -436,3 +436,13 @@ remoteuser = username@gmail.com # # See http://mail.google.com/support/bin/answer.py?answer=77657&topic=12815 realdelete = no + +# The trash folder name may be different from [Gmail]/Trash +# for example on german googlemail, this setting should be +# +# trashfolder = [Google Mail]/Papierkorb +# +# The same is valid for the spam folder +# +# spamfolder = [Google Mail]/Spam + diff --git a/offlineimap/folder/Gmail.py b/offlineimap/folder/Gmail.py index 48460d9..374132a 100644 --- a/offlineimap/folder/Gmail.py +++ b/offlineimap/folder/Gmail.py @@ -36,14 +36,11 @@ class GmailFolder(IMAPFolder): http://mail.google.com/support/bin/answer.py?answer=77657&topic=12815 """ - #: Where deleted mail should be moved - TRASH_FOLDER='[Gmail]/Trash' - - #: Gmail will really delete messages upon EXPUNGE in these folders - REAL_DELETE_FOLDERS = [ TRASH_FOLDER, '[Gmail]/Spam' ] - def __init__(self, imapserver, name, visiblename, accountname, repository): self.realdelete = repository.getrealdelete(name) + self.trash_folder = repository.gettrashfolder(name) + #: Gmail will really delete messages upon EXPUNGE in these folders + self.real_delete_folders = [ self.trash_folder, repository.getspamfolder() ] IMAPFolder.__init__(self, imapserver, name, visiblename, \ accountname, repository) @@ -52,7 +49,7 @@ class GmailFolder(IMAPFolder): if not len(uidlist): return - if self.realdelete and not (self.getname() in self.REAL_DELETE_FOLDERS): + if self.realdelete and not (self.getname() in self.real_delete_folders): # IMAP expunge is just "remove label" in this folder, # so map the request into a "move into Trash" @@ -61,7 +58,7 @@ class GmailFolder(IMAPFolder): imapobj.select(self.getfullname()) result = imapobj.uid('copy', imaputil.listjoin(uidlist), - self.TRASH_FOLDER) + self.trash_folder) assert result[0] == 'OK', \ "Bad IMAPlib result: %s" % result[0] finally: diff --git a/offlineimap/repository/Gmail.py b/offlineimap/repository/Gmail.py index f26e7b9..4793db7 100644 --- a/offlineimap/repository/Gmail.py +++ b/offlineimap/repository/Gmail.py @@ -66,3 +66,12 @@ class GmailRepository(IMAPRepository): # XXX: `foldername` is currently ignored - the `realdelete` # setting is repository-wide return self.getconfboolean('realdelete', 0) + + def gettrashfolder(self, foldername): + #: Where deleted mail should be moved + return self.getconf('trashfolder','[Gmail]/Trash') + + def getspamfolder(self): + #: Gmail also deletes messages upon EXPUNGE in the Spam folder + return self.getconf('spamfolder','[Gmail]/Spam') +