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

@ -254,6 +254,15 @@ class UIBase(object):
"for that message." % (
str(uidlist), self.getnicename(destfolder), destfolder))
def labelstoreadonly(self, destfolder, uidlist, labels):
if self.config.has_option('general', 'ignore-readonly') and \
self.config.getboolean('general', 'ignore-readonly'):
return
self.warn("Attempted to modify labels for messages %s in folder %s[%s], "
"but that folder is read-only. No labels have been modified "
"for that message." % (
str(uidlist), self.getnicename(destfolder), destfolder))
def deletereadonly(self, destfolder, uidlist):
if self.config.has_option('general', 'ignore-readonly') and \
self.config.getboolean('general', 'ignore-readonly'):
@ -361,6 +370,25 @@ class UIBase(object):
self.logger.info("Deleting flag %s from %d messages on %s" % (
", ".join(flags), len(uidlist), dest))
def addinglabels(self, uidlist, label, dest):
self.logger.info("Adding label %s to %d messages on %s" % (
label, len(uidlist), dest))
def deletinglabels(self, uidlist, label, dest):
self.logger.info("Deleting label %s from %d messages on %s" % (
label, len(uidlist), dest))
def settinglabels(self, uid, num, num_to_set, labels, dest):
self.logger.info("Setting labels to message %d on %s (%d of %d): %s" % (
uid, dest, num, num_to_set, ", ".join(labels)))
def collectingdata(self, uidlist, source):
if uidlist:
self.logger.info("Collecting data from %d messages on %s" % (
len(uidlist), source))
else:
self.logger.info("Collecting data from messages on %s" % source)
def serverdiagnostics(self, repository, type):
"""Connect to repository and output useful information for debugging"""
conn = None