make the trash and spam folder names in Gmail accounts configurable
This commit is contained in:
parent
9551e9d38e
commit
140be81efd
@ -436,3 +436,13 @@ remoteuser = username@gmail.com
|
|||||||
#
|
#
|
||||||
# See http://mail.google.com/support/bin/answer.py?answer=77657&topic=12815
|
# See http://mail.google.com/support/bin/answer.py?answer=77657&topic=12815
|
||||||
realdelete = no
|
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
|
||||||
|
|
||||||
|
@ -36,14 +36,11 @@ class GmailFolder(IMAPFolder):
|
|||||||
http://mail.google.com/support/bin/answer.py?answer=77657&topic=12815
|
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):
|
def __init__(self, imapserver, name, visiblename, accountname, repository):
|
||||||
self.realdelete = repository.getrealdelete(name)
|
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, \
|
IMAPFolder.__init__(self, imapserver, name, visiblename, \
|
||||||
accountname, repository)
|
accountname, repository)
|
||||||
|
|
||||||
@ -52,7 +49,7 @@ class GmailFolder(IMAPFolder):
|
|||||||
if not len(uidlist):
|
if not len(uidlist):
|
||||||
return
|
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,
|
# IMAP expunge is just "remove label" in this folder,
|
||||||
# so map the request into a "move into Trash"
|
# so map the request into a "move into Trash"
|
||||||
|
|
||||||
@ -61,7 +58,7 @@ class GmailFolder(IMAPFolder):
|
|||||||
imapobj.select(self.getfullname())
|
imapobj.select(self.getfullname())
|
||||||
result = imapobj.uid('copy',
|
result = imapobj.uid('copy',
|
||||||
imaputil.listjoin(uidlist),
|
imaputil.listjoin(uidlist),
|
||||||
self.TRASH_FOLDER)
|
self.trash_folder)
|
||||||
assert result[0] == 'OK', \
|
assert result[0] == 'OK', \
|
||||||
"Bad IMAPlib result: %s" % result[0]
|
"Bad IMAPlib result: %s" % result[0]
|
||||||
finally:
|
finally:
|
||||||
|
@ -66,3 +66,12 @@ class GmailRepository(IMAPRepository):
|
|||||||
# XXX: `foldername` is currently ignored - the `realdelete`
|
# XXX: `foldername` is currently ignored - the `realdelete`
|
||||||
# setting is repository-wide
|
# setting is repository-wide
|
||||||
return self.getconfboolean('realdelete', 0)
|
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')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user