Wed, 13 Jul 2022 14:55:47 +0200
Reformatted the source code using the 'Black' utility.
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 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8366
diff
changeset
|
3 | # Copyright (c) 2006 - 2022 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 | |
8358
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
15 | from EricWidgets import EricMessageBox |
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
16 | from EricWidgets.EricApplication import ericApp |
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
17 | from EricGui.EricOverrideCursor import EricOverrideCursor |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
18 | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
19 | from EricNetwork.EricGoogleMailHelpers import getInstallCommand, RequiredPackages |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
20 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
21 | from .ConfigurationPageBase import ConfigurationPageBase |
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
22 | from .Ui_EmailPage import Ui_EmailPage |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
9016
6f079c524e99
Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
24 | import Globals |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | import Preferences |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
27 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | class EmailPage(ConfigurationPageBase, Ui_EmailPage): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | Class implementing the Email configuration page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | def __init__(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
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
|
37 | super().__init__() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.setupUi(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.setObjectName("EmailPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
41 | self.__helpDialog = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
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
|
43 | 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
|
44 | "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
|
45 | "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
|
46 | ] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | 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
|
48 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | # 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
|
50 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | 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
|
53 | self.portSpin.setValue(Preferences.getUser("MailServerPort")) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.emailEdit.setText(Preferences.getUser("Email")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | 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
|
56 | self.mailAuthenticationGroup.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | Preferences.getUser("MailServerAuthentication") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | elif encryption == "SSL": |
5464
1d4f700489f8
Fixed a bug in the Email configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5443
diff
changeset
|
65 | 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
|
66 | 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
|
67 | self.noEncryptionButton.setChecked(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | def save(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | Public slot to save the Email configuration. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | 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
|
78 | Preferences.setUser( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | "MailServerAuthentication", self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | 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
|
82 | 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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | 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
|
89 | Preferences.setUser("MailServerEncryption", encryption) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | |
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
|
91 | 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
|
92 | """ |
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 | 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
|
94 | 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
|
95 | """ |
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 | 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
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | 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
|
101 | self.portSpin.setValue(25) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
102 | |
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
|
103 | @pyqtSlot(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
|
104 | def on_noEncryptionButton_toggled(self, checked): |
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 | """ |
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 | 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
|
107 | |
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
|
108 | @param checked current state of the button |
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 | @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
|
110 | """ |
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 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
112 | |
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
|
113 | @pyqtSlot(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
|
114 | def on_useSslButton_toggled(self, checked): |
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 | """ |
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 | 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
|
117 | |
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
|
118 | @param checked current state of the button |
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 | @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
|
120 | """ |
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 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
122 | |
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
|
123 | @pyqtSlot(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
|
124 | def on_useTlsButton_toggled(self, checked): |
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 | """ |
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 | 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
|
127 | |
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
|
128 | @param checked current state of the button |
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
|
129 | @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
|
130 | """ |
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
|
131 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
132 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
133 | 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
|
134 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
135 | 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
|
136 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
137 | self.testButton.setEnabled( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
138 | self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | and self.mailUserEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | and self.mailPasswordEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
141 | 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
|
142 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
143 | |
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
|
144 | @pyqtSlot(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
|
145 | def on_mailServerEdit_textChanged(self, txt): |
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 | """ |
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 | 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
|
148 | |
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
|
149 | @param txt current text of the edit (string) |
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
|
150 | @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
|
151 | """ |
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
|
152 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
153 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
154 | @pyqtSlot(bool) |
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
|
155 | 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
|
156 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
157 | 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
|
158 | group. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
159 | |
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
|
160 | @param checked state of the group (boolean) |
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 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
162 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
163 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
164 | @pyqtSlot(str) |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
165 | def on_mailUserEdit_textChanged(self, txt): |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
166 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
167 | 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
|
168 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
169 | @param txt current text of the edit (string) |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
170 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
171 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
172 | |
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 | @pyqtSlot(str) |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
174 | def on_mailPasswordEdit_textChanged(self, txt): |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
175 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
176 | 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
|
177 | |
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 | @param txt current text of the edit (string) |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
179 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
180 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
181 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
182 | @pyqtSlot() |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
183 | 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
|
184 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
185 | 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
|
186 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
187 | 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
|
188 | 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
|
189 | if self.useSslButton.isChecked(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | server = smtplib.SMTP_SSL( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
191 | 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
|
192 | ) |
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
|
193 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | server = smtplib.SMTP( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
195 | 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
|
196 | ) |
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
|
197 | 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
|
198 | server.starttls() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
199 | 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
|
200 | 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
|
201 | EricMessageBox.information( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
202 | 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
|
203 | ) |
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
|
204 | except (smtplib.SMTPException, OSError) as e: |
3539
0c2dc1446ebf
Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | 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
|
209 | 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
|
210 | try: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
211 | 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
|
212 | except TypeError: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
213 | 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
|
214 | else: |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
215 | 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
|
216 | EricMessageBox.critical( |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3010
diff
changeset
|
217 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
218 | self.tr("Login Test"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
219 | 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
|
220 | errorStr |
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 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
223 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
224 | @pyqtSlot() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
225 | def on_googleHelpButton_clicked(self): |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
226 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
227 | 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
|
228 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
229 | if self.__helpDialog is None: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
230 | try: |
8354
12ebd3934fef
Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
231 | from EricNetwork.EricGoogleMail import GoogleMailHelp |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
232 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
233 | helpStr = GoogleMailHelp() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
234 | 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
|
235 | 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
|
236 | "<p>The Google Mail Client API 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
|
237 | " Use <code>{0}</code> to install it.</p>" |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
238 | ).format(getInstallCommand()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
239 | |
8358
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
240 | from EricWidgets.EricSimpleHelpDialog import EricSimpleHelpDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
241 | |
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
|
242 | self.__helpDialog = EricSimpleHelpDialog( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
243 | 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
|
244 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
245 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
246 | self.__helpDialog.show() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
247 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
248 | @pyqtSlot() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
249 | 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
|
250 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
251 | 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
|
252 | """ |
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
|
253 | pip = ericApp().getObject("Pip") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
254 | pip.installPackages(RequiredPackages, interpreter=Globals.getPythonExecutable()) |
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: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | import EricNetwork.EricGoogleMail # __IGNORE_WARNING__ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
277 | from EricNetwork.EricGoogleMailHelpers import isClientSecretFileAvailable |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
279 | 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
|
280 | 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
|
281 | # 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
|
282 | 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
|
283 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
284 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
285 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
286 | "<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
|
287 | " 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
|
288 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
289 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
290 | 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
|
291 | 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
|
292 | else: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
293 | self.googleMailCheckBox.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | Preferences.getUser("UseGoogleMailOAuth2") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
296 | 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
|
297 | 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
|
298 | except ImportError: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
299 | # 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
|
300 | 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
|
301 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
302 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | "<p>The Google Mail Client API is not installed." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | " Use <code>{0}</code> to install it.</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
306 | ).format(getInstallCommand()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
307 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | |
1061
3e21869872e3
Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1032
diff
changeset
|
312 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | def create(dlg): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | 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
|
316 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | @param dlg reference to the configuration dialog |
2964
84b65fb9e780
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2632
diff
changeset
|
318 | @return reference to the instantiated page (ConfigurationPageBase) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | 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
|
321 | return page |