41 @param parent reference to the parent object (QObject) |
41 @param parent reference to the parent object (QObject) |
42 """ |
42 """ |
43 super().__init__(parent) |
43 super().__init__(parent) |
44 |
44 |
45 self._firstTimeSynced = False |
45 self._firstTimeSynced = False |
|
46 |
|
47 self._remoteFiles = { |
|
48 "bookmarks": "Bookmarks", |
|
49 "history": "History", |
|
50 "passwords": "Logins", |
|
51 "useragents": "UserAgentSettings" |
|
52 } |
|
53 |
|
54 self._messages = { |
|
55 "bookmarks": { |
|
56 "RemoteExists": self.trUtf8( |
|
57 "Remote bookmarks file exists! Syncing local copy..."), |
|
58 "RemoteMissing": self.trUtf8( |
|
59 "Remote bookmarks file does NOT exists. Exporting local copy..."), |
|
60 "LocalNewer": self.trUtf8( |
|
61 "Local bookmarks file is NEWER. Exporting local copy..."), |
|
62 "LocalMissing": self.trUtf8( |
|
63 "Local bookmarks file does NOT exist. Skipping synchronization!"), |
|
64 "Uploading": self.trUtf8("Uploading local bookmarks file..."), |
|
65 }, |
|
66 "history": { |
|
67 "RemoteExists": self.trUtf8( |
|
68 "Remote history file exists! Syncing local copy..."), |
|
69 "RemoteMissing": self.trUtf8( |
|
70 "Remote history file does NOT exists. Exporting local copy..."), |
|
71 "LocalNewer": self.trUtf8( |
|
72 "Local history file is NEWER. Exporting local copy..."), |
|
73 "LocalMissing": self.trUtf8( |
|
74 "Local history file does NOT exist. Skipping synchronization!"), |
|
75 "Uploading": self.trUtf8("Uploading local history file..."), |
|
76 }, |
|
77 "passwords": { |
|
78 "RemoteExists": self.trUtf8( |
|
79 "Remote logins file exists! Syncing local copy..."), |
|
80 "RemoteMissing": self.trUtf8( |
|
81 "Remote logins file does NOT exists. Exporting local copy..."), |
|
82 "LocalNewer": self.trUtf8( |
|
83 "Local logins file is NEWER. Exporting local copy..."), |
|
84 "LocalMissing": self.trUtf8( |
|
85 "Local logins file does NOT exist. Skipping synchronization!"), |
|
86 "Uploading": self.trUtf8("Uploading local logins file..."), |
|
87 }, |
|
88 "useragents": { |
|
89 "RemoteExists": self.trUtf8( |
|
90 "Remote user agent settings file exists! Syncing local copy..."), |
|
91 "RemoteMissing": self.trUtf8( |
|
92 "Remote user agent settings file does NOT exists." |
|
93 " Exporting local copy..."), |
|
94 "LocalNewer": self.trUtf8( |
|
95 "Local user agent settings file is NEWER. Exporting local copy..."), |
|
96 "LocalMissing": self.trUtf8( |
|
97 "Local user agent settings file does NOT exist." |
|
98 " Skipping synchronization!"), |
|
99 "Uploading": self.trUtf8("Uploading local user agent settings file..."), |
|
100 }, |
|
101 } |
46 |
102 |
47 def syncBookmarks(self): |
103 def syncBookmarks(self): |
48 """ |
104 """ |
49 Public method to synchronize the bookmarks. |
105 Public method to synchronize the bookmarks. |
50 """ |
106 """ |
113 |
169 |
114 return QByteArray(data) |
170 return QByteArray(data) |
115 |
171 |
116 return QByteArray() |
172 return QByteArray() |
117 |
173 |
118 def writeFile(self, data, fileName): |
174 def writeFile(self, data, fileName, timestamp=0): |
119 """ |
175 """ |
120 Public method to write the data to a file. |
176 Public method to write the data to a file. |
121 |
177 |
122 If encrypted synchronization is enabled, the data will be decrypted using |
178 If encrypted synchronization is enabled, the data will be decrypted using |
123 the relevant encryption key. |
179 the relevant encryption key. |
124 |
180 |
125 @param data data to be written and optionally decrypted (QByteArray) |
181 @param data data to be written and optionally decrypted (QByteArray) |
126 @param fileName name of the file the data is to be written to (string) |
182 @param fileName name of the file the data is to be written to (string) |
|
183 @param timestamp timestamp to be given to the file (int) |
127 @return tuple giving a success flag and an error string (boolean, string) |
184 @return tuple giving a success flag and an error string (boolean, string) |
128 """ |
185 """ |
129 data = bytes(data) |
186 data = bytes(data) |
130 |
187 |
131 if Preferences.getHelp("SyncEncryptData"): |
188 if Preferences.getHelp("SyncEncryptData"): |