]> code.delx.au - offlineimap/blobdiff - offlineimap/repository/Base.py
Initial stab at showing list of folders that aren't being synced
[offlineimap] / offlineimap / repository / Base.py
index a6c62cd5f70d71477480c2c5930d3e204402c99c..ec56d61f74063265e7a9e5ff4b7867aae5226470 100644 (file)
 #    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}
@@ -123,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()
@@ -148,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.
@@ -157,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