Mon, 01 Feb 2021 10:38:16 +0100
Merged with default branch to prepare a new release.
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
3 | # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module containing a base class for synchronization handlers. |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
10 | import os |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
11 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
12 | from PyQt5.QtCore import QObject, pyqtSignal, QByteArray |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
13 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
14 | import Preferences |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
15 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
16 | from Utilities.crypto import dataEncrypt, dataDecrypt |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | class SyncHandler(QObject): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Base class for synchronization handlers. |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
23 | @signal syncStatus(type_, message) emitted to indicate the synchronization |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
24 | status (string one of "bookmarks", "history", "passwords", |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
25 | "useragents" or "speeddial", string) |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
26 | @signal syncError(message) emitted for a general error with the error |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
27 | message (string) |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
28 | @signal syncMessage(message) emitted to send a message about |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
29 | synchronization (string) |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
30 | @signal syncFinished(type_, done, download) emitted after a |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
31 | synchronization has finished (string one of "bookmarks", "history", |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
32 | "passwords", "useragents" or "speeddial", boolean, boolean) |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
34 | syncStatus = pyqtSignal(str, str) |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | syncError = pyqtSignal(str) |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
36 | syncMessage = pyqtSignal(str) |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | syncFinished = pyqtSignal(str, bool, bool) |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | def __init__(self, parent=None): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | Constructor |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | @param parent reference to the parent object (QObject) |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
45 | super(SyncHandler, self).__init__(parent) |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self._firstTimeSynced = False |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
48 | |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
49 | self._remoteFiles = { |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
50 | "bookmarks": "Bookmarks", |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
51 | "history": "History", |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
52 | "passwords": "Logins", |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
53 | "useragents": "UserAgentSettings", |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
54 | "speeddial": "SpeedDial", |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
55 | } |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
56 | |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
57 | self._messages = { |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
58 | "bookmarks": { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
59 | "RemoteExists": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
60 | "Remote bookmarks file exists! Syncing local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
61 | "RemoteMissing": self.tr( |
4776
7f4c8e5f3385
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4774
diff
changeset
|
62 | "Remote bookmarks file does NOT exist. Exporting" |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
63 | " local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
64 | "LocalNewer": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
65 | "Local bookmarks file is NEWER. Exporting local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
66 | "LocalMissing": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
67 | "Local bookmarks file does NOT exist. Skipping" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
68 | " synchronization!"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
69 | "Uploading": self.tr("Uploading local bookmarks file..."), |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
70 | }, |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
71 | "history": { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
72 | "RemoteExists": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
73 | "Remote history file exists! Syncing local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
74 | "RemoteMissing": self.tr( |
4776
7f4c8e5f3385
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4774
diff
changeset
|
75 | "Remote history file does NOT exist. Exporting" |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
76 | " local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
77 | "LocalNewer": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
78 | "Local history file is NEWER. Exporting local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
79 | "LocalMissing": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
80 | "Local history file does NOT exist. Skipping" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
81 | " synchronization!"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
82 | "Uploading": self.tr("Uploading local history file..."), |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
83 | }, |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
84 | "passwords": { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
85 | "RemoteExists": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
86 | "Remote logins file exists! Syncing local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
87 | "RemoteMissing": self.tr( |
4776
7f4c8e5f3385
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4774
diff
changeset
|
88 | "Remote logins file does NOT exist. Exporting" |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
89 | " local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
90 | "LocalNewer": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
91 | "Local logins file is NEWER. Exporting local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
92 | "LocalMissing": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
93 | "Local logins file does NOT exist. Skipping" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
94 | " synchronization!"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
95 | "Uploading": self.tr("Uploading local logins file..."), |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
96 | }, |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
97 | "useragents": { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
98 | "RemoteExists": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
99 | "Remote user agent settings file exists! Syncing local" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
100 | " copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
101 | "RemoteMissing": self.tr( |
4776
7f4c8e5f3385
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4774
diff
changeset
|
102 | "Remote user agent settings file does NOT exist." |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
103 | " Exporting local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
104 | "LocalNewer": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
105 | "Local user agent settings file is NEWER. Exporting" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
106 | " local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
107 | "LocalMissing": self.tr( |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
108 | "Local user agent settings file does NOT exist." |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
109 | " Skipping synchronization!"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
110 | "Uploading": self.tr( |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
111 | "Uploading local user agent settings file..."), |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
112 | }, |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
113 | "speeddial": { |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
114 | "RemoteExists": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
115 | "Remote speed dial settings file exists! Syncing local" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
116 | " copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
117 | "RemoteMissing": self.tr( |
4776
7f4c8e5f3385
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4774
diff
changeset
|
118 | "Remote speed dial settings file does NOT exist." |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
119 | " Exporting local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
120 | "LocalNewer": self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
121 | "Local speed dial settings file is NEWER. Exporting" |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
122 | " local copy..."), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
123 | "LocalMissing": self.tr( |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
124 | "Local speed dial settings file does NOT exist." |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
125 | " Skipping synchronization!"), |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
126 | "Uploading": self.tr( |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
127 | "Uploading local speed dial settings file..."), |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
128 | }, |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
129 | } |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | def syncBookmarks(self): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | Public method to synchronize the bookmarks. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
134 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
135 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
136 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | raise NotImplementedError |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | def syncHistory(self): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | Public method to synchronize the history. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
143 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
144 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
145 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | raise NotImplementedError |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | def syncPasswords(self): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Public method to synchronize the passwords. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
152 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
153 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
154 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | raise NotImplementedError |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | def syncUserAgents(self): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | Public method to synchronize the user agents. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
161 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
162 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
163 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | raise NotImplementedError |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
167 | def syncSpeedDial(self): |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
168 | """ |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
169 | Public method to synchronize the speed dial data. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
170 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
171 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
172 | must be implemented by subclasses |
1700
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
173 | """ |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
174 | raise NotImplementedError |
40c911b8c0dd
Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1695
diff
changeset
|
175 | |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
176 | def initialLoadAndCheck(self, forceUpload): |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | Public method to do the initial check. |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
179 | |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7836
diff
changeset
|
180 | @param forceUpload flag indicating a forced upload of the files |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
181 | (boolean) |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
182 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
183 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | raise NotImplementedError |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | def shutdown(self): |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | Public method to shut down the handler. |
2954
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
190 | |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
191 | @exception NotImplementedError raised to indicate that this method |
bf0215fe12d1
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
192 | must be implemented by subclasses |
1626
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | """ |
a77c8ea8582c
Added capability to synchronise bookmarks, history, passwords and user agent settings via an FTP server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | raise NotImplementedError |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
195 | |
1701
9eee32bac32e
Added option to only encrypt passwords upon synchronisation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1700
diff
changeset
|
196 | def readFile(self, fileName, type_): |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
197 | """ |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
198 | Public method to read a file. |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
199 | |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
200 | If encrypted synchronization is enabled, the data will be encrypted |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
201 | using the relevant encryption key. |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
202 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
203 | @param fileName name of the file to be read (string) |
1701
9eee32bac32e
Added option to only encrypt passwords upon synchronisation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1700
diff
changeset
|
204 | @param type_ type of the synchronization event (string one |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
205 | of "bookmarks", "history", "passwords", "useragents" or |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
206 | "speeddial") |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
207 | @return data of the file, optionally encrypted (QByteArray) |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
208 | """ |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
209 | if os.path.exists(fileName): |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
210 | try: |
7785
9978016560ec
Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7781
diff
changeset
|
211 | with open(fileName, "rb") as inputFile: |
9978016560ec
Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7781
diff
changeset
|
212 | data = inputFile.read() |
7836
2f0d208b8137
Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7785
diff
changeset
|
213 | except OSError: |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
214 | return QByteArray() |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
215 | |
7269
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
216 | if ( |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
217 | Preferences.getWebBrowser("SyncEncryptData") and |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
218 | (not Preferences.getWebBrowser("SyncEncryptPasswordsOnly") or |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
219 | (Preferences.getWebBrowser("SyncEncryptPasswordsOnly") and |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
220 | type_ == "passwords")) |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
221 | ): |
4774
2c6ffa778c3b
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
222 | key = Preferences.getWebBrowser("SyncEncryptionKey") |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
223 | if not key: |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
224 | return QByteArray() |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
225 | |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
226 | data, ok = dataEncrypt( |
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
227 | data, key, |
4774
2c6ffa778c3b
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
228 | keyLength=Preferences.getWebBrowser( |
2c6ffa778c3b
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
229 | "SyncEncryptionKeyLength"), |
1682
0eefcc28fa74
Changed the hash iterations for sync encryption to 100 and made the key length user configurable (user can optimize for speed).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1680
diff
changeset
|
230 | hashIterations=100) |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
231 | if not ok: |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
232 | return QByteArray() |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
233 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
234 | return QByteArray(data) |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
235 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
236 | return QByteArray() |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
237 | |
1701
9eee32bac32e
Added option to only encrypt passwords upon synchronisation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1700
diff
changeset
|
238 | def writeFile(self, data, fileName, type_, timestamp=0): |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
239 | """ |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
240 | Public method to write the data to a file. |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
241 | |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
242 | If encrypted synchronization is enabled, the data will be decrypted |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
243 | using the relevant encryption key. |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
244 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
245 | @param data data to be written and optionally decrypted (QByteArray) |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
246 | @param fileName name of the file the data is to be written to (string) |
1701
9eee32bac32e
Added option to only encrypt passwords upon synchronisation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1700
diff
changeset
|
247 | @param type_ type of the synchronization event (string one |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
248 | of "bookmarks", "history", "passwords", "useragents" or |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
249 | "speeddial") |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
250 | @param timestamp timestamp to be given to the file (int) |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
251 | @return tuple giving a success flag and an error string (boolean, |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
252 | string) |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
253 | """ |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
254 | data = bytes(data) |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
255 | |
7269
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
256 | if ( |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
257 | Preferences.getWebBrowser("SyncEncryptData") and |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
258 | (not Preferences.getWebBrowser("SyncEncryptPasswordsOnly") or |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
259 | (Preferences.getWebBrowser("SyncEncryptPasswordsOnly") and |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
260 | type_ == "passwords")) |
0c63ea7f94bd
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
261 | ): |
4774
2c6ffa778c3b
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
262 | key = Preferences.getWebBrowser("SyncEncryptionKey") |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
263 | if not key: |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
264 | return False, self.tr("Invalid encryption key given.") |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
265 | |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
266 | data, ok = dataDecrypt( |
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
267 | data, key, |
4774
2c6ffa778c3b
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
268 | keyLength=Preferences.getWebBrowser("SyncEncryptionKeyLength")) |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
269 | if not ok: |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
270 | return False, self.tr("Data cannot be decrypted.") |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
271 | |
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
272 | try: |
7785
9978016560ec
Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7781
diff
changeset
|
273 | with open(fileName, "wb") as outputFile: |
9978016560ec
Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7781
diff
changeset
|
274 | outputFile.write(data) |
1695
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
275 | if timestamp > 0: |
7b115f986d48
Added capability to synchronize bookmarks, history, passwords and user agent settings via a shared directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1682
diff
changeset
|
276 | os.utime(fileName, (timestamp, timestamp)) |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
277 | return True, "" |
7836
2f0d208b8137
Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7785
diff
changeset
|
278 | except OSError as error: |
1680
28e57079dab5
Added capability to encrypt the synchronized data (web browser).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1626
diff
changeset
|
279 | return False, str(error) |