Tue, 23 Apr 2024 11:26:04 +0200
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10428
diff
changeset
|
3 | # Copyright (c) 2006 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the Email configuration page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
10 | import smtplib |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
11 | import socket |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
12 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
13 | from PyQt6.QtCore import pyqtSlot |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
14 | |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | from eric7 import Preferences |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9427
diff
changeset
|
16 | from eric7.EricGui.EricOverrideCursor import EricOverrideCursor |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
17 | from eric7.EricWidgets import EricMessageBox |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
18 | from eric7.EricWidgets.EricSimpleHelpDialog import EricSimpleHelpDialog |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
19 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
20 | from .ConfigurationPageBase import ConfigurationPageBase |
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
21 | from .Ui_EmailPage import Ui_EmailPage |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
23 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | class EmailPage(ConfigurationPageBase, Ui_EmailPage): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | Class implementing the Email configuration page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
28 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | def __init__(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
33 | super().__init__() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.setupUi(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.setObjectName("EmailPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
37 | self.__helpDialog = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | |
6825
e659bb96cdfa
Fixed a UI info inconsistency related to installation of Google mail related packages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6823
diff
changeset
|
39 | pipPackages = [ |
e659bb96cdfa
Fixed a UI info inconsistency related to installation of Google mail related packages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6823
diff
changeset
|
40 | "google-api-python-client", |
e659bb96cdfa
Fixed a UI info inconsistency related to installation of Google mail related packages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6823
diff
changeset
|
41 | "google-auth-oauthlib", |
e659bb96cdfa
Fixed a UI info inconsistency related to installation of Google mail related packages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6823
diff
changeset
|
42 | ] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | self.__pipCommand = "pip install --upgrade {0}".format(" ".join(pipPackages)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | # set initial values |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
46 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.mailServerEdit.setText(Preferences.getUser("MailServer")) |
388
174d7a46f58d
Fixed an issue with the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
49 | self.portSpin.setValue(Preferences.getUser("MailServerPort")) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | self.emailEdit.setText(Preferences.getUser("Email")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.signatureEdit.setPlainText(Preferences.getUser("Signature")) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
52 | self.mailAuthenticationGroup.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | Preferences.getUser("MailServerAuthentication") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | self.mailUserEdit.setText(Preferences.getUser("MailServerUser")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | self.mailPasswordEdit.setText(Preferences.getUser("MailServerPassword")) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
57 | encryption = Preferences.getUser("MailServerEncryption") |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
58 | if encryption == "TLS": |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
59 | self.useTlsButton.setChecked(True) |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
60 | elif encryption == "SSL": |
5464
1d4f700489f8
Fixed a bug in the Email configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5443
diff
changeset
|
61 | self.useSslButton.setChecked(True) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
62 | else: |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
63 | self.noEncryptionButton.setChecked(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | def save(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | Public slot to save the Email configuration. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | Preferences.setUser("UseGoogleMailOAuth2", self.googleMailCheckBox.isChecked()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | Preferences.setUser("MailServer", self.mailServerEdit.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | Preferences.setUser("MailServerPort", self.portSpin.value()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | Preferences.setUser("Email", self.emailEdit.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
73 | Preferences.setUser("Signature", self.signatureEdit.toPlainText()) |
3025
67064c71df21
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
74 | Preferences.setUser( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | "MailServerAuthentication", self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | Preferences.setUser("MailServerUser", self.mailUserEdit.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
78 | Preferences.setUser("MailServerPassword", self.mailPasswordEdit.text()) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
79 | if self.useTlsButton.isChecked(): |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
80 | encryption = "TLS" |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
81 | elif self.useSslButton.isChecked(): |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
82 | encryption = "SSL" |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
83 | else: |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
84 | encryption = "No" |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
85 | Preferences.setUser("MailServerEncryption", encryption) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
86 | |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
87 | def __updatePortSpin(self): |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
88 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
89 | Private slot to set the value of the port spin box depending upon |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
90 | the selected encryption method. |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
91 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
92 | if self.useSslButton.isChecked(): |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
93 | self.portSpin.setValue(465) |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
94 | elif self.useTlsButton.isChecked(): |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
95 | self.portSpin.setValue(587) |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
96 | else: |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
97 | self.portSpin.setValue(25) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
99 | @pyqtSlot(bool) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
100 | def on_noEncryptionButton_toggled(self, _checked): |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
101 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
102 | Private slot handling a change of no encryption button. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
103 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
104 | @param _checked current state of the button (unused) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
105 | @type bool |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
106 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
107 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
108 | |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
109 | @pyqtSlot(bool) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
110 | def on_useSslButton_toggled(self, _checked): |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
111 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
112 | Private slot handling a change of SSL encryption button. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
113 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
114 | @param _checked current state of the button (unused) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
115 | @type bool |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
116 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
117 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
118 | |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
119 | @pyqtSlot(bool) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
120 | def on_useTlsButton_toggled(self, _checked): |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
121 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
122 | Private slot handling a change of TLS encryption button. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
124 | @param _checked current state of the button (unused) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
125 | @type bool |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
126 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
127 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
128 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
129 | def __updateTestButton(self): |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
130 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
131 | Private slot to update the enabled state of the test button. |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
132 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
133 | self.testButton.setEnabled( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | and self.mailUserEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | and self.mailPasswordEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
137 | and self.mailServerEdit.text() != "" |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
138 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
140 | @pyqtSlot(str) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
141 | def on_mailServerEdit_textChanged(self, _txt): |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
142 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
143 | Private slot to handle a change of the text of the mail server edit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
144 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
145 | @param _txt current text of the edit (unused) |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
146 | @type str |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
147 | """ |
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
148 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
149 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
150 | @pyqtSlot(bool) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
151 | def on_mailAuthenticationGroup_toggled(self, _checked): |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
152 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
153 | Private slot to handle a change of the state of the authentication |
5443
3ef014765648
Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
154 | group. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
156 | @param _checked state of the group (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
157 | @type bool |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
158 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
159 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
161 | @pyqtSlot(str) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
162 | def on_mailUserEdit_textChanged(self, _txt): |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
163 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
164 | Private slot to handle a change of the text of the user edit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
165 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
166 | @param _txt current text of the edit (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
167 | @type str |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
168 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
169 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
170 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
171 | @pyqtSlot(str) |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
172 | def on_mailPasswordEdit_textChanged(self, _txt): |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
173 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
174 | Private slot to handle a change of the text of the user edit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
175 | |
10692
9becf9ca115c
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
176 | @param _txt current text of the edit (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
177 | @type str |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
178 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
179 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
180 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
181 | @pyqtSlot() |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
182 | def on_testButton_clicked(self): |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
183 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
184 | Private slot to test the mail server login data. |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
185 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
186 | try: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8354
diff
changeset
|
187 | with EricOverrideCursor(): |
7771
787a6b3f8c9f
Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
188 | if self.useSslButton.isChecked(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
189 | server = smtplib.SMTP_SSL( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | self.mailServerEdit.text(), self.portSpin.value(), timeout=10 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
191 | ) |
7771
787a6b3f8c9f
Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
192 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
193 | server = smtplib.SMTP( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | self.mailServerEdit.text(), self.portSpin.value(), timeout=10 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
195 | ) |
7771
787a6b3f8c9f
Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
196 | if self.useTlsButton.isChecked(): |
787a6b3f8c9f
Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
197 | server.starttls() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
198 | server.login(self.mailUserEdit.text(), self.mailPasswordEdit.text()) |
7771
787a6b3f8c9f
Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
199 | server.quit() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8354
diff
changeset
|
200 | EricMessageBox.information( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | self, self.tr("Login Test"), self.tr("""The login test succeeded.""") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
202 | ) |
10050
3750abc45d5e
Corrected some code style issues detected by the extended checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
203 | except (OSError, smtplib.SMTPException) as e: |
3539
0c2dc1446ebf
Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
204 | if isinstance(e, smtplib.SMTPResponseException): |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
205 | errorStr = e.smtp_error.decode() |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
206 | elif isinstance(e, socket.timeout): |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
207 | errorStr = str(e) |
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:
7780
diff
changeset
|
208 | elif isinstance(e, OSError): |
2065
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
209 | try: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
210 | errorStr = e[1] |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
211 | except TypeError: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
212 | errorStr = str(e) |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
213 | else: |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
214 | errorStr = str(e) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8354
diff
changeset
|
215 | EricMessageBox.critical( |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3010
diff
changeset
|
216 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
217 | self.tr("Login Test"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
218 | self.tr("""<p>The login test failed.<br>Reason: {0}</p>""").format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
219 | errorStr |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
220 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
221 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
222 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
223 | @pyqtSlot() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
224 | def on_googleHelpButton_clicked(self): |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
225 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
226 | Private slot to show some help text "how to turn on the Gmail API". |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
227 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
228 | if self.__helpDialog is None: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
229 | try: |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
230 | from eric7.EricNetwork.EricGoogleMail import ( # __IGNORE_WARNING__ |
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
231 | GoogleMailHelp, |
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
232 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
234 | helpStr = GoogleMailHelp() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
235 | except ImportError: |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
236 | helpStr = self.tr( |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
237 | "<p>The Google Mail Client API is not installed." |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
238 | " Use the <b>{0}</b> button to install it.</p>" |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
239 | ).format(self.googleInstallButton.text()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
240 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8354
diff
changeset
|
241 | self.__helpDialog = EricSimpleHelpDialog( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
242 | title=self.tr("Gmail API Help"), helpStr=helpStr, parent=self |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
243 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
244 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
245 | self.__helpDialog.show() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
246 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
247 | @pyqtSlot() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
248 | def on_googleInstallButton_clicked(self): |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
249 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
250 | Private slot to install the required packages for use of Google Mail. |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
251 | """ |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
252 | from eric7.EricNetwork.EricGoogleMailHelpers import installGoogleAPIPackages |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
253 | |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
254 | installGoogleAPIPackages() |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
255 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
256 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
257 | @pyqtSlot() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
258 | def on_googleCheckAgainButton_clicked(self): |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
259 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
260 | Private slot to check again the availability of Google Mail. |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
261 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
262 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
264 | def __checkGoogleMail(self): |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
265 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
266 | Private method to check the Google Mail availability and set the |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
267 | widgets accordingly. |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
268 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
269 | self.googleMailInfoLabel.hide() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
270 | self.googleInstallButton.show() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
271 | self.googleCheckAgainButton.show() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
272 | self.googleHelpButton.setEnabled(True) |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
273 | self.googleMailCheckBox.setEnabled(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
274 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
275 | try: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
276 | from eric7.EricNetwork import EricGoogleMail # __IGNORE_WARNING__ |
10331
c1a2ff7e3575
Modernized some code and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
277 | from eric7.EricNetwork.EricGoogleMailHelpers import ( # noqa: I101 |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
278 | isClientSecretFileAvailable, |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
279 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
280 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
281 | self.googleInstallButton.hide() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
282 | if not isClientSecretFileAvailable(): |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
283 | # secrets file is not installed |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
284 | self.googleMailCheckBox.setChecked(False) |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
285 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
286 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
287 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
288 | "<p>The client secrets file is not present." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
289 | " Has the Gmail API been enabled?</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
290 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
291 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
292 | self.googleMailInfoLabel.show() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
293 | Preferences.setUser("UseGoogleMailOAuth2", False) |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
294 | else: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
295 | self.googleMailCheckBox.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
296 | Preferences.getUser("UseGoogleMailOAuth2") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
297 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
298 | self.googleMailInfoLabel.hide() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
299 | self.googleCheckAgainButton.hide() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
300 | except ImportError: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
301 | # missing libraries, disable Google Mail |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
302 | self.googleMailCheckBox.setChecked(False) |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
303 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
306 | "<p>The Google Mail Client API is not installed." |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
307 | " Use the <b>{0}</b> button to install it.</p>" |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
308 | ).format(self.googleInstallButton.text()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
309 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
310 | self.googleMailInfoLabel.show() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
311 | self.googleHelpButton.setEnabled(False) |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
312 | Preferences.setUser("UseGoogleMailOAuth2", False) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
313 | |
1061
3e21869872e3
Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1032
diff
changeset
|
314 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
315 | def create(_dlg): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | Module function to create the configuration page. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
319 | @param _dlg reference to the configuration dialog (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
320 | @type ConfigurationDialog |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
321 | @return reference to the instantiated page |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10331
diff
changeset
|
322 | @rtype ConfigurationPageBase |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | page = EmailPage() |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
325 | return page |