Thu, 20 Oct 2022 19:19:00 +0200
Gmail Interface
- changed the Gmail interface to use the Google API packages for authentication (OAuth2) and sending of emails
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 | |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | from eric7 import Preferences |
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
|
16 | from eric7.EricWidgets import EricMessageBox |
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.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 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
19 | from .ConfigurationPageBase import ConfigurationPageBase |
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
20 | from .Ui_EmailPage import Ui_EmailPage |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
22 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | class EmailPage(ConfigurationPageBase, Ui_EmailPage): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Class implementing the Email configuration page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
27 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | def __init__(self): |
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 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
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
|
32 | super().__init__() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.setupUi(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.setObjectName("EmailPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
36 | self.__helpDialog = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
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
|
38 | 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
|
39 | "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
|
40 | "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
|
41 | ] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | 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
|
43 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | # 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
|
45 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | 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
|
48 | self.portSpin.setValue(Preferences.getUser("MailServerPort")) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | self.emailEdit.setText(Preferences.getUser("Email")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | 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
|
51 | self.mailAuthenticationGroup.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | Preferences.getUser("MailServerAuthentication") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | elif encryption == "SSL": |
5464
1d4f700489f8
Fixed a bug in the Email configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5443
diff
changeset
|
60 | 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
|
61 | 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
|
62 | self.noEncryptionButton.setChecked(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
63 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | def save(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | Public slot to save the Email configuration. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
73 | Preferences.setUser( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
74 | "MailServerAuthentication", self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | 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
|
77 | 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | 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
|
83 | 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
|
84 | Preferences.setUser("MailServerEncryption", encryption) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | |
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
|
86 | 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
|
87 | """ |
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 | 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
|
89 | 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
|
90 | """ |
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 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | self.portSpin.setValue(25) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
97 | |
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
|
98 | @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
|
99 | 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
|
100 | """ |
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 | 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
|
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 | @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
|
104 | @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
|
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 | self.__updatePortSpin() |
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 | @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
|
109 | 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
|
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 | 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
|
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 | @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
|
114 | @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
|
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 | self.__updatePortSpin() |
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 | @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
|
119 | 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
|
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 | 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
|
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 | @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
|
124 | @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
|
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 | self.__updatePortSpin() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
127 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
128 | 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
|
129 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
130 | 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
|
131 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
132 | self.testButton.setEnabled( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
133 | self.mailAuthenticationGroup.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | and self.mailUserEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | and self.mailPasswordEdit.text() != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | 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
|
137 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
138 | |
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
|
139 | @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
|
140 | 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
|
141 | """ |
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 | 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
|
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 | @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
|
145 | @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
|
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 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
148 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
149 | @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
|
150 | 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
|
151 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
152 | 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
|
153 | group. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
154 | |
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 | @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
|
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 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
158 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
159 | @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
|
160 | 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
|
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 | 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
|
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 | @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
|
165 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
166 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
167 | |
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 | @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
|
169 | 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
|
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 | 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
|
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 | @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
|
174 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
175 | self.__updateTestButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
176 | |
1032
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
177 | @pyqtSlot() |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
178 | 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
|
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 | 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
|
181 | """ |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
182 | 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
|
183 | 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
|
184 | if self.useSslButton.isChecked(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
185 | server = smtplib.SMTP_SSL( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
186 | 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
|
187 | ) |
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 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
189 | server = smtplib.SMTP( |
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 | 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
|
193 | server.starttls() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | 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
|
195 | 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
|
196 | EricMessageBox.information( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
197 | 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
|
198 | ) |
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
|
199 | except (smtplib.SMTPException, OSError) as e: |
3539
0c2dc1446ebf
Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
200 | 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
|
201 | 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
|
202 | 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
|
203 | 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
|
204 | 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
|
205 | try: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
206 | 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
|
207 | except TypeError: |
aea3ddf97aca
Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
208 | 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
|
209 | else: |
f7c2e348f6f3
Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
210 | 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
|
211 | EricMessageBox.critical( |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3010
diff
changeset
|
212 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
213 | self.tr("Login Test"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
214 | 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
|
215 | errorStr |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
216 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
217 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
218 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
219 | @pyqtSlot() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
220 | def on_googleHelpButton_clicked(self): |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
221 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
222 | 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
|
223 | """ |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
224 | if self.__helpDialog is None: |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
225 | 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
|
226 | from eric7.EricNetwork.EricGoogleMail import GoogleMailHelp |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
227 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
228 | helpStr = GoogleMailHelp() |
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
229 | 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
|
230 | 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
|
231 | "<p>The Google Mail Client API is not installed." |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
232 | " Use the <b>{0}</b> button to install it.</p>" |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
233 | ).format(self.googleInstallButton.text()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
234 | |
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
|
235 | from eric7.EricWidgets.EricSimpleHelpDialog import EricSimpleHelpDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
236 | |
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
|
237 | self.__helpDialog = EricSimpleHelpDialog( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
238 | 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
|
239 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
240 | |
6559
1265efa7364f
Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
241 | self.__helpDialog.show() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
242 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
243 | @pyqtSlot() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
244 | 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
|
245 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
246 | 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
|
247 | """ |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
248 | from eric7.EricNetwork.EricGoogleMailHelpers import installGoogleAPIPackages |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
249 | |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
250 | installGoogleAPIPackages() |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
251 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
252 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
253 | @pyqtSlot() |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
254 | 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
|
255 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
256 | 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
|
257 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
258 | self.__checkGoogleMail() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
259 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
260 | 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
|
261 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
262 | 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
|
263 | widgets accordingly. |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
264 | """ |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | 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
|
269 | self.googleMailCheckBox.setEnabled(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
270 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
271 | 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
|
272 | from eric7.EricNetwork import EricGoogleMail # __IGNORE_WARNING__ |
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
|
273 | from eric7.EricNetwork.EricGoogleMailHelpers import ( |
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
|
274 | 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
|
275 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
277 | 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
|
278 | 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
|
279 | # 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
|
280 | 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
|
281 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
282 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
283 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
284 | "<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
|
285 | " 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
|
286 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
287 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
288 | 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
|
289 | 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
|
290 | else: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
291 | self.googleMailCheckBox.setChecked( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
292 | Preferences.getUser("UseGoogleMailOAuth2") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
293 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
294 | 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
|
295 | 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
|
296 | except ImportError: |
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
297 | # 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
|
298 | 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
|
299 | self.googleMailCheckBox.setEnabled(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
300 | self.googleMailInfoLabel.setText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
301 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
302 | "<p>The Google Mail Client API is not installed." |
9427
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
303 | " Use the <b>{0}</b> button to install it.</p>" |
905e7af29101
Gmail Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
304 | ).format(self.googleInstallButton.text()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | ) |
6828
bb6667ea9ae7
Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6825
diff
changeset
|
306 | 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
|
307 | 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
|
308 | 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
|
309 | |
1061
3e21869872e3
Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1032
diff
changeset
|
310 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | def create(dlg): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | 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
|
314 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | @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
|
316 | @return reference to the instantiated page (ConfigurationPageBase) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | 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
|
319 | return page |