Added the newmail_hook
When new mail arrives, this hook is triggered, allowing the user to play a sound, or launch a popup. Signed-off-by: Matthew Krafczyk <krafczyk.matthew@gmail.com>
This commit is contained in:
@ -40,6 +40,11 @@ class BaseFolder(object):
|
||||
# Top level dir name is always ''
|
||||
self.root = None
|
||||
self.name = name if not name == self.getsep() else ''
|
||||
self.newmail_hook = None
|
||||
# Only set the newmail_hook if the IMAP folder is named 'INBOX'
|
||||
if self.name == 'INBOX':
|
||||
self.newmail_hook = repository.newmail_hook
|
||||
self.have_newmail = False
|
||||
self.repository = repository
|
||||
self.visiblename = repository.nametrans(name)
|
||||
# In case the visiblename becomes '.' or '/' (top-level) we use
|
||||
@ -781,6 +786,9 @@ class BaseFolder(object):
|
||||
# Got new UID, change the local uid.
|
||||
# Save uploaded status in the statusfolder
|
||||
statusfolder.savemessage(new_uid, message, flags, rtime)
|
||||
# Check whether the mail has been seen
|
||||
if 'S' not in flags:
|
||||
self.have_newmail = True
|
||||
elif new_uid == 0:
|
||||
# Message was stored to dstfolder, but we can't find it's UID
|
||||
# This means we can't link current message to the one created
|
||||
@ -817,6 +825,9 @@ class BaseFolder(object):
|
||||
|
||||
This function checks and protects us from action in dryrun mode."""
|
||||
|
||||
# We have no new mail yet
|
||||
self.have_newmail = False
|
||||
|
||||
threads = []
|
||||
|
||||
copylist = filter(lambda uid: not statusfolder.uidexists(uid),
|
||||
@ -854,6 +865,11 @@ class BaseFolder(object):
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
# Execute new mail hook if we have new mail
|
||||
if self.have_newmail:
|
||||
if self.newmail_hook != None:
|
||||
self.newmail_hook();
|
||||
|
||||
def __syncmessagesto_delete(self, dstfolder, statusfolder):
|
||||
"""Pass 2: Remove locally deleted messages on dst.
|
||||
|
||||
|
Reference in New Issue
Block a user