X-Git-Url: https://code.delx.au/offlineimap/blobdiff_plain/d839be3c61888a837bf2de52939eca9831e68dfc..fa766b61bcf5dcc1f241c96521b56304a0e3ba11:/offlineimap/repository/Base.py diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py index cfca83e..ec56d61 100644 --- a/offlineimap/repository/Base.py +++ b/offlineimap/repository/Base.py @@ -1,5 +1,5 @@ # Base repository support -# Copyright (C) 2002, 2003 John Goerzen +# Copyright (C) 2002-2007 John Goerzen # # # This program is free software; you can redistribute it and/or modify @@ -14,17 +14,20 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from offlineimap import CustomConfig +from offlineimap.ui import UIBase import os.path def LoadRepository(name, account, reqtype): + from offlineimap.repository.Gmail import GmailRepository from offlineimap.repository.IMAP import IMAPRepository, MappedIMAPRepository from offlineimap.repository.Maildir import MaildirRepository if reqtype == 'remote': # For now, we don't support Maildirs on the remote side. - typemap = {'IMAP': IMAPRepository} + typemap = {'IMAP': IMAPRepository, + 'Gmail': GmailRepository} elif reqtype == 'local': typemap = {'IMAP': MappedIMAPRepository, 'Maildir': MaildirRepository} @@ -51,6 +54,27 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): if not os.path.exists(self.uiddir): os.mkdir(self.uiddir, 0700) + # The 'restoreatime' config parameter only applies to local Maildir + # mailboxes. + def restore_atime(self): + if self.config.get('Repository ' + self.name, 'type').strip() != \ + 'Maildir': + return + + if not self.config.has_option('Repository ' + self.name, 'restoreatime') or not self.config.getboolean('Repository ' + self.name, 'restoreatime'): + return + + return self.restore_folder_atimes() + + def connect(self): + """Establish a connection to the remote, if necessary. This exists + so that IMAP connections can all be established up front, gathering + passwords as needed. It was added in order to support the + error recovery -- we need to connect first outside of the error + trap in order to validate the password, and that's the point of + this function.""" + pass + def holdordropconnections(self): pass @@ -85,6 +109,11 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): """Returns a list of ALL folders on this server.""" return [] + def forgetfolders(self): + """Forgets the cached list of folders, if any. Useful to run + after a sync run.""" + pass + def getsep(self): raise NotImplementedError @@ -97,9 +126,12 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): def getfolder(self, foldername): raise NotImplementedError - def syncfoldersto(self, dest): + def syncfoldersto(self, dest, copyfolders): """Syncs the folders in this repository to those in dest. - It does NOT sync the contents of those folders.""" + It does NOT sync the contents of those folders. + + For every time dest.makefolder() is called, also call makefolder() + on each folder in copyfolders.""" src = self srcfolders = src.getfolders() destfolders = dest.getfolders() @@ -122,6 +154,8 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): for key in srchash.keys(): if not key in desthash: dest.makefolder(key) + for copyfolder in copyfolders: + copyfolder.makefolder(key.replace(dest.getsep(), copyfolder.getsep())) # # Find deleted folders. @@ -131,6 +165,17 @@ class BaseRepository(CustomConfig.ConfigHelperMixin): #for key in desthash.keys(): # if not key in srchash: # dest.deletefolder(key) + + + ##### Find any folders that aren't being synced + ignoredfolders = [] + for key in desthash.keys(): + if not key in srchash: + ignoredfolders.append(key) + + ignoredfolders.sort() + if ignoredfolders != []: + UIBase.getglobalui().warn("Found local folders that are not being synced: %s" % (", ".join(ignoredfolders))) ##### Keepalive