IMAP folder: expose the message keywords
The keywords are in the flag string, so imaputil can just strip the usual \Flags. Signed-off-by: Igor Almeida <igor.contato@gmail.com> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
4e2de8f58a
commit
73a3767d11
@ -420,6 +420,11 @@ class BaseFolder(object):
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
def getmessagekeywords(self, uid):
|
||||
"""Returns the keywords for the specified message."""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
def savemessageflags(self, uid, flags):
|
||||
"""Sets the specified message's flags to the given set.
|
||||
|
||||
|
@ -251,8 +251,10 @@ class IMAPFolder(BaseFolder):
|
||||
uid = long(options['UID'])
|
||||
self.messagelist[uid] = self.msglist_item_initializer(uid)
|
||||
flags = imaputil.flagsimap2maildir(options['FLAGS'])
|
||||
keywords = imaputil.flagsimap2keywords(options['FLAGS'])
|
||||
rtime = imaplibutil.Internaldate2epoch(messagestr)
|
||||
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
|
||||
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime,
|
||||
'keywords': keywords}
|
||||
self.ui.messagelistloaded(self.repository, self, self.getmessagecount())
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
@ -309,6 +311,10 @@ class IMAPFolder(BaseFolder):
|
||||
def getmessageflags(self, uid):
|
||||
return self.messagelist[uid]['flags']
|
||||
|
||||
# Interface from BaseFolder
|
||||
def getmessagekeywords(self, uid):
|
||||
return self.messagelist[uid]['keywords']
|
||||
|
||||
def __generate_randomheader(self, content):
|
||||
"""Returns a unique X-OfflineIMAP header
|
||||
|
||||
|
@ -195,6 +195,14 @@ def flagsimap2maildir(flagstring):
|
||||
retval.add(maildirflag)
|
||||
return retval
|
||||
|
||||
def flagsimap2keywords(flagstring):
|
||||
"""Convert string '(\\Draft \\Deleted somekeyword otherkeyword)' into a
|
||||
keyword set (somekeyword otherkeyword)."""
|
||||
|
||||
imapflagset = set(flagstring[1:-1].split())
|
||||
serverflagset = set([flag for (flag, c) in flagmap])
|
||||
return imapflagset - serverflagset
|
||||
|
||||
def flagsmaildir2imap(maildirflaglist):
|
||||
"""Convert set of flags ([DR]) into a string '(\\Deleted \\Draft)'."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user