75 def __downloadFile(self, type_, fileName, timestamp): |
75 def __downloadFile(self, type_, fileName, timestamp): |
76 """ |
76 """ |
77 Private method to downlaod the given file. |
77 Private method to downlaod the given file. |
78 |
78 |
79 @param type_ type of the synchronization event (string one |
79 @param type_ type of the synchronization event (string one |
80 of "bookmarks", "history", "passwords" or "useragents") |
80 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
81 @param fileName name of the file to be downloaded (string) |
81 @param fileName name of the file to be downloaded (string) |
82 @param timestamp time stamp in seconds of the file to be downloaded (int) |
82 @param timestamp time stamp in seconds of the file to be downloaded (int) |
83 """ |
83 """ |
84 self.syncStatus.emit(type_, self._messages[type_]["RemoteExists"]) |
84 self.syncStatus.emit(type_, self._messages[type_]["RemoteExists"]) |
85 try: |
85 try: |
92 self.trUtf8("Cannot read remote file.\n{0}").format(str(err))) |
92 self.trUtf8("Cannot read remote file.\n{0}").format(str(err))) |
93 self.syncFinished(type_, False, True) |
93 self.syncFinished(type_, False, True) |
94 return |
94 return |
95 |
95 |
96 QCoreApplication.processEvents() |
96 QCoreApplication.processEvents() |
97 ok, error = self.writeFile(QByteArray(data), fileName, timestamp) |
97 ok, error = self.writeFile(QByteArray(data), fileName, type_, timestamp) |
98 if not ok: |
98 if not ok: |
99 self.syncStatus.emit(type_, error) |
99 self.syncStatus.emit(type_, error) |
100 self.syncFinished.emit(type_, ok, True) |
100 self.syncFinished.emit(type_, ok, True) |
101 |
101 |
102 def __uploadFile(self, type_, fileName): |
102 def __uploadFile(self, type_, fileName): |
103 """ |
103 """ |
104 Private method to upload the given file. |
104 Private method to upload the given file. |
105 |
105 |
106 @param type_ type of the synchronization event (string one |
106 @param type_ type of the synchronization event (string one |
107 of "bookmarks", "history", "passwords" or "useragents") |
107 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
108 @param fileName name of the file to be uploaded (string) |
108 @param fileName name of the file to be uploaded (string) |
109 """ |
109 """ |
110 QCoreApplication.processEvents() |
110 QCoreApplication.processEvents() |
111 data = self.readFile(fileName) |
111 data = self.readFile(fileName, type_) |
112 if data.isEmpty(): |
112 if data.isEmpty(): |
113 self.syncStatus.emit(type_, self._messages[type_]["LocalMissing"]) |
113 self.syncStatus.emit(type_, self._messages[type_]["LocalMissing"]) |
114 self.syncFinished(type_, False, False) |
114 self.syncFinished(type_, False, False) |
115 return |
115 return |
116 else: |
116 else: |
130 def __initialSyncFile(self, type_, fileName): |
130 def __initialSyncFile(self, type_, fileName): |
131 """ |
131 """ |
132 Private method to do the initial synchronization of the given file. |
132 Private method to do the initial synchronization of the given file. |
133 |
133 |
134 @param type_ type of the synchronization event (string one |
134 @param type_ type of the synchronization event (string one |
135 of "bookmarks", "history", "passwords" or "useragents") |
135 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
136 @param fileName name of the file to be synchronized (string) |
136 @param fileName name of the file to be synchronized (string) |
137 """ |
137 """ |
138 if not self.__forceUpload and \ |
138 if not self.__forceUpload and \ |
139 os.path.exists(os.path.join(Preferences.getHelp("SyncDirectoryPath"), |
139 os.path.exists(os.path.join(Preferences.getHelp("SyncDirectoryPath"), |
140 self._remoteFiles[type_])) and \ |
140 self._remoteFiles[type_])) and \ |
192 def __syncFile(self, type_, fileName): |
192 def __syncFile(self, type_, fileName): |
193 """ |
193 """ |
194 Private method to synchronize the given file. |
194 Private method to synchronize the given file. |
195 |
195 |
196 @param type_ type of the synchronization event (string one |
196 @param type_ type of the synchronization event (string one |
197 of "bookmarks", "history", "passwords" or "useragents") |
197 of "bookmarks", "history", "passwords", "useragents" or "speeddial") |
198 @param fileName name of the file to be synchronized (string) |
198 @param fileName name of the file to be synchronized (string) |
199 """ |
199 """ |
200 self.syncStatus.emit(type_, self._messages[type_]["Uploading"]) |
200 self.syncStatus.emit(type_, self._messages[type_]["Uploading"]) |
201 self.__uploadFile(type_, fileName) |
201 self.__uploadFile(type_, fileName) |
202 |
202 |