149 ok = True |
149 ok = True |
150 if self.__ftp.currentCommand() == QFtp.Get: |
150 if self.__ftp.currentCommand() == QFtp.Get: |
151 self.__syncIDs[id][1].close() |
151 self.__syncIDs[id][1].close() |
152 ok, error = self.writeFile(self.__syncIDs[id][1].buffer(), |
152 ok, error = self.writeFile(self.__syncIDs[id][1].buffer(), |
153 self.__syncIDs[id][3], |
153 self.__syncIDs[id][3], |
|
154 self.__syncIDs[id][0], |
154 self.__syncIDs[id][4]) |
155 self.__syncIDs[id][4]) |
155 if not ok: |
156 if not ok: |
156 self.syncStatus.emit(self.__syncIDs[id][0], error) |
157 self.syncStatus.emit(self.__syncIDs[id][0], error) |
157 self.syncFinished.emit(self.__syncIDs[id][0], ok, |
158 self.syncFinished.emit(self.__syncIDs[id][0], ok, |
158 self.__syncIDs[id][2]) |
159 self.__syncIDs[id][2]) |
182 def __downloadFile(self, type_, fileName, timestamp): |
183 def __downloadFile(self, type_, fileName, timestamp): |
183 """ |
184 """ |
184 Private method to downlaod the given file. |
185 Private method to downlaod the given file. |
185 |
186 |
186 @param type_ type of the synchronization event (string one |
187 @param type_ type of the synchronization event (string one |
187 of "bookmarks", "history", "passwords" or "useragents") |
188 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
188 @param fileName name of the file to be downloaded (string) |
189 @param fileName name of the file to be downloaded (string) |
189 @param timestamp time stamp in seconds of the file to be downloaded (int) |
190 @param timestamp time stamp in seconds of the file to be downloaded (int) |
190 """ |
191 """ |
191 self.syncStatus.emit(type_, self._messages[type_]["RemoteExists"]) |
192 self.syncStatus.emit(type_, self._messages[type_]["RemoteExists"]) |
192 buffer = QBuffer(self) |
193 buffer = QBuffer(self) |
197 def __uploadFile(self, type_, fileName): |
198 def __uploadFile(self, type_, fileName): |
198 """ |
199 """ |
199 Private method to upload the given file. |
200 Private method to upload the given file. |
200 |
201 |
201 @param type_ type of the synchronization event (string one |
202 @param type_ type of the synchronization event (string one |
202 of "bookmarks", "history", "passwords" or "useragents") |
203 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
203 @param fileName name of the file to be uploaded (string) |
204 @param fileName name of the file to be uploaded (string) |
204 """ |
205 """ |
205 data = self.readFile(fileName) |
206 data = self.readFile(fileName, type_) |
206 if data.isEmpty(): |
207 if data.isEmpty(): |
207 self.syncStatus.emit(type_, self._messages[type_]["LocalMissing"]) |
208 self.syncStatus.emit(type_, self._messages[type_]["LocalMissing"]) |
208 self.syncFinished(type_, False, False) |
209 self.syncFinished(type_, False, False) |
209 else: |
210 else: |
210 id = self.__ftp.put(data, self._remoteFiles[type_]) |
211 id = self.__ftp.put(data, self._remoteFiles[type_]) |
213 def __initialSyncFile(self, type_, fileName): |
214 def __initialSyncFile(self, type_, fileName): |
214 """ |
215 """ |
215 Private method to do the initial synchronization of the given file. |
216 Private method to do the initial synchronization of the given file. |
216 |
217 |
217 @param type_ type of the synchronization event (string one |
218 @param type_ type of the synchronization event (string one |
218 of "bookmarks", "history", "passwords" or "useragents") |
219 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
219 @param fileName name of the file to be synchronized (string) |
220 @param fileName name of the file to be synchronized (string) |
220 """ |
221 """ |
221 if not self.__forceUpload and \ |
222 if not self.__forceUpload and \ |
222 self._remoteFiles[type_] in self.__remoteFilesFound and \ |
223 self._remoteFiles[type_] in self.__remoteFilesFound and \ |
223 QFileInfo(fileName).lastModified() <= \ |
224 QFileInfo(fileName).lastModified() <= \ |
265 def __syncFile(self, type_, fileName): |
266 def __syncFile(self, type_, fileName): |
266 """ |
267 """ |
267 Private method to synchronize the given file. |
268 Private method to synchronize the given file. |
268 |
269 |
269 @param type_ type of the synchronization event (string one |
270 @param type_ type of the synchronization event (string one |
270 of "bookmarks", "history", "passwords" or "useragents") |
271 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
271 @param fileName name of the file to be synchronized (string) |
272 @param fileName name of the file to be synchronized (string) |
272 """ |
273 """ |
273 if self.__state == "initializing": |
274 if self.__state == "initializing": |
274 return |
275 return |
275 |
276 |