mech_imap
parent
de41f90943
commit
f2a43a948a
|
@ -9,7 +9,7 @@ from twisted.internet import protocol, ssl
|
|||
from twisted.mail import imap4
|
||||
|
||||
from serpent.config import conf
|
||||
from serpent.imap.mailbox import IMAPMailbox
|
||||
from serpent.imap.mailbox import ExtendedMaildir
|
||||
from serpent.misc import IMAP_HDELIM, IMAP_MBOX_REG, IMAP_ACC_CONN_NUM
|
||||
from shutil import rmtree, move
|
||||
|
||||
|
@ -29,7 +29,7 @@ class IMAPUserAccount(object):
|
|||
if m not in IMAP_MBOX_REG[self.dir].keys():
|
||||
if isinstance(m, str):
|
||||
m = m.encode('imap4-utf-7')
|
||||
IMAP_MBOX_REG[self.dir][m] = IMAPMailbox(os.path.join(self.dir, m))
|
||||
IMAP_MBOX_REG[self.dir][m] = ExtendedMaildir(os.path.join(self.dir, m))
|
||||
IMAP_MBOX_REG[self.dir][m]._start_monitor()
|
||||
self.subscribe(m)
|
||||
|
||||
|
@ -37,7 +37,7 @@ class IMAPUserAccount(object):
|
|||
if isinstance(path, str):
|
||||
path = path.encode('imap4-utf-7')
|
||||
fullPath = os.path.join(self.dir, path)
|
||||
mbox = IMAPMailbox(fullPath)
|
||||
mbox = ExtendedMaildir(fullPath)
|
||||
mbox._start_monitor()
|
||||
return mbox
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ class ExtendedMaildir(Maildir):
|
|||
oldpath = os.path.join(self._path, subpath)
|
||||
newsubdir = os.path.split(subpath)[0]
|
||||
newname = key + self.colon + info
|
||||
if 'S' not in sflags and newsubdir == 'new':
|
||||
if 'S' in sflags and newsubdir == 'new':
|
||||
newsubdir = 'cur'
|
||||
if 'S' not in sflags and newsubdir == 'cur':
|
||||
newsubdir = 'new'
|
||||
newpath = os.path.join(self._path, newsubdir, newname)
|
||||
if hasattr(os, 'link'):
|
||||
os.link(oldpath, newpath)
|
||||
|
@ -27,8 +29,9 @@ class ExtendedMaildir(Maildir):
|
|||
return info[2:]
|
||||
else:
|
||||
return ''
|
||||
def add_flag(self, flag):
|
||||
self.set_flags(''.join(set(self.get_flags()) | set(flag)))
|
||||
def remove_flag(self, flag):
|
||||
if self.get_flags():
|
||||
self.set_flags(''.join(set(self.get_flags()) - set(flag)))
|
||||
def add_flag(self, key, flag):
|
||||
self.set_flags(key, ''.join(set(self.get_flags(key)) | set(flag)))
|
||||
def remove_flag(self, key, flag):
|
||||
if flag not in self.get_flags(key): return True
|
||||
if self.get_flags(key):
|
||||
self.set_flags(key, ''.join(set(self.get_flags(key)) - set(flag)))
|
Loading…
Reference in New Issue