make the trash and spam folder names in Gmail accounts configurable

This commit is contained in:
Henning Glawe 2008-08-13 01:19:38 +02:00 committed by John Goerzen
parent 9551e9d38e
commit 140be81efd
3 changed files with 24 additions and 8 deletions

View File

@ -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

View File

@ -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:

View File

@ -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')