]> code.delx.au - offlineimap/blobdiff - offlineimap/repository/Base.py
Finally fix the stupid LocalStatus folder bug, I really hope!
[offlineimap] / offlineimap / repository / Base.py
index 94bce09d7fb21d7eaaf4c2794c5b8892c284456e..ed07b572b87872e3749a9e3ee0eddae90d7cfde1 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}
@@ -63,6 +65,15 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
 
        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
 
@@ -97,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
 
@@ -109,9 +125,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()
@@ -134,6 +153,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.