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

@ -271,6 +271,22 @@ remoterepository = RemoteExample
#
#maildir-windows-compatible = no
# Specifies if we want to sync GMail lables with the local repository.
# Effective only for GMail IMAP repositories. You should use SQlite
# backend for this to work (see status_backend).
#
#synclabels = no
# Name of the header to use for label storage.
#
#labelsheader = X-Keywords
# Set of labels to be ignored. Comma-separated list. GMail-specific
# labels all start with backslash ('\').
#
#ignorelabels = \Inbox, \Starred, \Sent, \Draft, \Spam, \Trash, \Important
# OfflineIMAP can strip off some headers when your messages are propagated
# back to the IMAP server. This option carries the comma-separated list
@ -283,10 +299,11 @@ remoterepository = RemoteExample
#filterheaders = X-Some-Weird-Header
[Repository LocalExample]
# Each repository requires a "type" declaration. The types supported for
# local repositories are Maildir and IMAP.
# local repositories are Maildir, GmailMaildir and IMAP.
type = Maildir
@ -313,6 +330,24 @@ localfolders = ~/Test
#restoreatime = no
[Repository GmailLocalExample]
# This type of repository enables syncing of Gmail. All Maildir
# configuration settings are also valid here.
#
# This is a separate Repository type from Maildir because it involves
# some extra overhead which sometimes may be significant. We look for
# modified tags in local messages by looking only to the files
# modified since last run. This is usually rather fast, but the first
# time OfflineIMAP runs with synclabels enabled, it will have to check
# the contents of all individual messages for labels and this may take
# a while.
type = GmailMaildir
[Repository RemoteExample]
# And this is the remote repository. We only support IMAP or Gmail here.
@ -658,3 +693,6 @@ remoteuser = username@gmail.com
# Enable 1-way synchronization. See above for explanation.
#
#readonly = False
#
# To enable GMail labels synchronisation, set the option synclabels
# in the corresponding "Account" section.