Helpviewer/Sync/SyncHandler.py

changeset 1701
9eee32bac32e
parent 1700
40c911b8c0dd
child 2302
f29e9405c851
--- a/Helpviewer/Sync/SyncHandler.py	Sun Mar 11 16:46:46 2012 +0100
+++ b/Helpviewer/Sync/SyncHandler.py	Sun Mar 11 17:20:43 2012 +0100
@@ -158,7 +158,7 @@
         """
         raise NotImplementedError
     
-    def readFile(self, fileName):
+    def readFile(self, fileName, type_):
         """
         Public method to read a file.
         
@@ -166,6 +166,8 @@
         the relevant encryption key.
         
         @param fileName name of the file to be read (string)
+        @param type_ type of the synchronization event (string one
+            of "bookmarks", "history", "passwords", "useragents" or "speeddial")
         @return data of the file, optionally encrypted (QByteArray)
         """
         if os.path.exists(fileName):
@@ -176,7 +178,10 @@
             except IOError:
                 return QByteArray()
             
-            if Preferences.getHelp("SyncEncryptData"):
+            if Preferences.getHelp("SyncEncryptData") and \
+               (not Preferences.getHelp("SyncEncryptPasswordsOnly") or \
+                (Preferences.getHelp("SyncEncryptPasswordsOnly") and \
+                 type_ == "passwords")):
                 key = Preferences.getHelp("SyncEncryptionKey")
                 if not key:
                     return QByteArray()
@@ -191,7 +196,7 @@
         
         return QByteArray()
     
-    def writeFile(self, data, fileName, timestamp=0):
+    def writeFile(self, data, fileName, type_, timestamp=0):
         """
         Public method to write the data to a file.
         
@@ -200,12 +205,16 @@
         
         @param data data to be written and optionally decrypted (QByteArray)
         @param fileName name of the file the data is to be written to (string)
+        @param type_ type of the synchronization event (string one
+            of "bookmarks", "history", "passwords", "useragents" or "speeddial")
         @param timestamp timestamp to be given to the file (int)
         @return tuple giving a success flag and an error string (boolean, string)
         """
         data = bytes(data)
         
-        if Preferences.getHelp("SyncEncryptData"):
+        if Preferences.getHelp("SyncEncryptData") and \
+           (not Preferences.getHelp("SyncEncryptPasswordsOnly") or \
+            (Preferences.getHelp("SyncEncryptPasswordsOnly") and type_ == "passwords")):
             key = Preferences.getHelp("SyncEncryptionKey")
             if not key:
                 return False, self.trUtf8("Invalid encryption key given.")

eric ide

mercurial