# --------------------------------------------------------------------
# File:   .offlineimaprc
# Author: abdo.roig@gmail.com
# Desc:   offlineimap config with label synchronization from
#         https://github.com/aroig/offlineimap
#---------------------------------------------------------------------

[general]
# global offlineimap settings

# Replaces the default ~/.offlineimap
metadata = ~/Documents/mail/metadata     

accounts = gmail,gchat

ignore-readonly = no
ui = basic





[Account gmail]
# This accound syncs all gmail's email

# repositories
localrepository = gmail-local
remoterepository = gmail-remote

# store cached data in a sqlite database instead of plain text files
# needed to use gmail label syncing. Should be considered experimental.
status_backend = sqlite                  

# This speeds up sync, but then gmail to local label sync may not work.
# quick=-1                               

# Label sync settings
synclabels = yes                         
labelsheader = X-Keywords                
filterheaders = X-Keywords               
ignorelabels = \Important, \Draft        



[Repository gmail-local]

# This repo type is like Maildir with label change detection.
type = GmailMaildir

localfolders = ~/Documents/mail



[Repository gmail-remote]

# This repo type is like IMAP with gmail features, like label sync
type = Gmail

# Encrypt transactions
ssl = yes

# This contains CA certificates, to validate gmail server certificate.
# This path is for Arch Linux, may be different on your distro.
# See https://wiki.archlinux.org/index.php/OfflineIMAP#Gmail_configuration
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

# The password is read from the server imap.google.com in ~/.netrc
remoteuser = abdo.roig@gmail.com


# the realdelete option no longer exists. realdelete = yes could lead to data loss.
# http://permalink.gmane.org/gmane.mail.imap.offlineimap.general/5265  
# realdelete = no

# number of concurrent IMAP connections.
maxconnections = 1                       

# compress data for IMAP communication. Haven't found any speed improvement
# using this.
# usecompression = yes                   

# Translates folder names for the local maildir.
# for example, remote "[Gmail]/All Mail" becomes local "All Mail"
nametrans = lambda foldername: re.sub('^\[Gmail\]/', '', foldername)

# Syncs only "All Mail", "Drafts" and "Trash", and ignore all other remote IMAP folders.
folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail', '[Gmail]/Drafts', '[Gmail]/Trash']





[Account gchat]
# This account syncs only chat logs. I sync them on a separate account to
# enable readonly. Chat logs are readonly on gmail, and without the readonly
# option, label sync failed, when it tried to change them.

localrepository = gchat-local
remoterepository = gchat-remote
status_backend = sqlite

# Label sync settings
synclabels = yes
labelsheader = X-Keywords
filterheaders = X-Keywords
ignorelabels = \Important, \Draft



[Repository gchat-local]
type = GmailMaildir
localfolders = ~/Documents/mail



[Repository gchat-remote]
type = Gmail
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

# Reads password from server imap.google.com in ~/.netrc
remoteuser = abdo.roig@gmail.com

realdelete = no
maxconnections = 1
readonly = yes

nametrans = lambda foldername: re.sub('^\[Gmail\]/', '', foldername)
folderfilter = lambda foldername: foldername in ['[Gmail]/Chats']
