]> code.delx.au - offlineimap/blobdiff - offlineimap/repository/Base.py
Add Gmail IMAP special support.
[offlineimap] / offlineimap / repository / Base.py
index 945183f48cf59d330bb2bcbf2641bd1d19964331..93e464b3fb44e5bd25a35e8d0a511cb7d3a33fe7 100644 (file)
@@ -1,5 +1,5 @@
 # Base repository support
-# Copyright (C) 2002, 2003, 2006 John Goerzen
+# Copyright (C) 2002-2007 John Goerzen
 # <jgoerzen@complete.org>
 #
 #    This program is free software; you can redistribute it and/or modify
@@ -20,11 +20,13 @@ from offlineimap import CustomConfig
 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 +53,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 +108,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