19 |
19 |
20 class SyncManager(QObject): |
20 class SyncManager(QObject): |
21 """ |
21 """ |
22 Class implementing the synchronization manager. |
22 Class implementing the synchronization manager. |
23 |
23 |
24 @signal syncError(message) emitted for a general error with the error message (string) |
24 @signal syncError(message) emitted for a general error with the error |
|
25 message (string) |
|
26 @signal syncMessage(message) emitted to give status info about the sync |
|
27 process (string) |
25 """ |
28 """ |
26 syncError = pyqtSignal(str) |
29 syncError = pyqtSignal(str) |
|
30 syncMessage = pyqtSignal(str) |
27 |
31 |
28 def __init__(self, parent=None): |
32 def __init__(self, parent=None): |
29 """ |
33 """ |
30 Constructor |
34 Constructor |
31 |
35 |
50 Public method to show the synchronization dialog. |
54 Public method to show the synchronization dialog. |
51 """ |
55 """ |
52 dlg = SyncAssistantDialog() |
56 dlg = SyncAssistantDialog() |
53 dlg.exec_() |
57 dlg.exec_() |
54 |
58 |
55 def loadSettings(self): |
59 def loadSettings(self, forceUpload=False): |
56 """ |
60 """ |
57 Public method to load the settings. |
61 Public method to load the settings. |
|
62 |
|
63 @keyparam forceUpload flag indicating a forced upload of the files (boolean) |
58 """ |
64 """ |
59 if self.syncEnabled(): |
65 if self.syncEnabled(): |
60 if Preferences.getHelp("SyncType") == 0: |
66 if Preferences.getHelp("SyncType") == 0: |
61 if self.__handler is not None: |
67 if self.__handler is not None: |
62 self.__handler.syncError.disconnect(self.__syncError) |
68 self.__handler.syncError.disconnect(self.__syncError) |
63 self.__handler.syncFinished.disconnect(self.__syncFinished) |
69 self.__handler.syncFinished.disconnect(self.__syncFinished) |
|
70 self.__handler.syncStatus.disconnect(self.__syncStatus) |
|
71 self.__handler.syncMessage.disconnect(self.syncMessage) |
64 self.__handler.shutdown() |
72 self.__handler.shutdown() |
65 self.__handler = FtpSyncHandler(self) |
73 self.__handler = FtpSyncHandler(self) |
66 self.__handler.syncError.connect(self.__syncError) |
74 self.__handler.syncError.connect(self.__syncError) |
67 self.__handler.syncFinished.connect(self.__syncFinished) |
75 self.__handler.syncFinished.connect(self.__syncFinished) |
68 |
76 self.__handler.syncStatus.connect(self.__syncStatus) |
69 self.__handler.initialLoadAndCheck() |
77 self.__handler.syncMessage.connect(self.syncMessage) |
|
78 |
|
79 self.__handler.initialLoadAndCheck(forceUpload=forceUpload) |
70 |
80 |
71 # connect sync manager to bookmarks manager |
81 # connect sync manager to bookmarks manager |
72 if Preferences.getHelp("SyncBookmarks"): |
82 if Preferences.getHelp("SyncBookmarks"): |
73 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().bookmarksSaved\ |
83 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().bookmarksSaved\ |
74 .connect(self.__syncBookmarks) |
84 .connect(self.__syncBookmarks) |
113 pass |
123 pass |
114 else: |
124 else: |
115 if self.__handler is not None: |
125 if self.__handler is not None: |
116 self.__handler.syncError.disconnect(self.__syncError) |
126 self.__handler.syncError.disconnect(self.__syncError) |
117 self.__handler.syncFinished.disconnect(self.__syncFinished) |
127 self.__handler.syncFinished.disconnect(self.__syncFinished) |
|
128 self.__handler.syncStatus.disconnect(self.__syncStatus) |
|
129 self.__handler.syncMessage.disconnect(self.syncMessage) |
118 self.__handler.shutdown() |
130 self.__handler.shutdown() |
119 self.__handler = None |
131 self.__handler = None |
120 |
132 |
121 try: |
133 try: |
122 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().bookmarksSaved\ |
134 Helpviewer.HelpWindow.HelpWindow.bookmarksManager().bookmarksSaved\ |
201 elif type_ == "passwords": |
213 elif type_ == "passwords": |
202 Helpviewer.HelpWindow.HelpWindow.passwordManager().reload() |
214 Helpviewer.HelpWindow.HelpWindow.passwordManager().reload() |
203 elif type_ == "useragents": |
215 elif type_ == "useragents": |
204 Helpviewer.HelpWindow.HelpWindow.userAgentsManager().reload() |
216 Helpviewer.HelpWindow.HelpWindow.userAgentsManager().reload() |
205 |
217 |
|
218 def __syncStatus(self, type_, status, message): |
|
219 """ |
|
220 Private slot to handle a status update of a synchronization event. |
|
221 |
|
222 @param type_ type of the synchronization event (string one |
|
223 of "bookmarks", "history", "passwords" or "useragents") |
|
224 @param status flag indicating success (boolean) |
|
225 @param message status message for the event (string) |
|
226 """ |
|
227 self.syncMessage.emit(message) |
|
228 |
206 def close(self): |
229 def close(self): |
207 """ |
230 """ |
208 Public slot to shut down the synchronization manager. |
231 Public slot to shut down the synchronization manager. |
209 """ |
232 """ |
210 if not self.syncEnabled(): |
233 if not self.syncEnabled(): |