Make GmailFolder sync GMail labels

When synclabels config flag is set to "yes" for the GMail repo,
offlineimap fetches the message labels along with the messages, and
embeds them into the body under the header X-Keywords (or whatever
'labelsheader' was set to), as a comma separated list.

It also adds an extra pass to savemessageto, that performs label
synchronization on existing messages from GMail to local, the same way
it is done with flags.

We also introduce GmailMaildir repository that adds functionality to
change message labels.  It keeps track of messages modification time,
so one can quickly detect when the labels may have changed.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
Abdó Roig-Maranges
2012-10-16 20:20:35 +02:00
committed by Eygene Ryabinkin
parent 9319ae212b
commit 0e4afa9132
15 changed files with 1071 additions and 69 deletions

View File

@ -142,12 +142,15 @@ class IMAPFolder(BaseFolder):
def _msgs_to_fetch(self, imapobj):
"""
Determines UIDS of messages to be fetched
Determines sequence numbers of messages to be fetched.
Message sequence numbers (MSNs) are more easily compacted
into ranges which makes transactions slightly faster.
Arguments:
- imapobj: instance of IMAPlib
Returns: UID ranges for messages or None if no messages
Returns: range(s) for messages or None if no messages
are to be fetched.
"""
@ -156,7 +159,7 @@ class IMAPFolder(BaseFolder):
# Empty folder, no need to populate message list
return None
# By default examine all UIDs in this folder
# By default examine all messages in this folder
msgsToFetch = '1:*'
maxage = self.config.getdefaultint("Account %s" % self.accountname,
@ -194,7 +197,7 @@ class IMAPFolder(BaseFolder):
self.getrepository(), self, search_cond, res_type, res_data),
OfflineImapError.ERROR.FOLDER)
# Result UIDs are seperated by space, coalesce into ranges
# Resulting MSN are separated by space, coalesce into ranges
msgsToFetch = imaputil.uid_sequence(res_data[0].split())
return msgsToFetch