eric6/Preferences/ConfigurationPages/EmailPage.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7836
2f0d208b8137
child 8218
7c09585bd960
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
3 # Copyright (c) 2006 - 2021 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
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
12 import sys
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13
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
14 from PyQt5.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
15
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
16 from E5Gui import E5MessageBox
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
17 from E5Gui.E5Application import e5App
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
18 from E5Gui.E5OverrideCursor import E5OverrideCursor
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
19
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
20 from E5Network.E5GoogleMailHelpers 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
21
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
22 from .ConfigurationPageBase import ConfigurationPageBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
23 from .Ui_EmailPage import Ui_EmailPage
0
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 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 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
36 super(EmailPage, self).__init__()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setObjectName("EmailPage")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
6559
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
40 self.__helpDialog = None
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41
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
42 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
43 "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
44 "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
45 ]
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 self.__pipCommand = "pip install --upgrade {0}".format(
e659bb96cdfa Fixed a UI info inconsistency related to installation of Google mail related packages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6823
diff changeset
47 " ".join(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
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()
6559
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
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(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Preferences.getUser("MailServerAuthentication"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.mailUserEdit.setText(Preferences.getUser("MailServerUser"))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 388
diff changeset
59 self.mailPasswordEdit.setText(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 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)
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
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 """
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
73 Preferences.setUser(
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5464
diff changeset
74 "UseGoogleMailOAuth2",
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5464
diff changeset
75 self.googleMailCheckBox.isChecked())
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5464
diff changeset
76 Preferences.setUser(
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
77 "MailServer",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.mailServerEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
79 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
80 "MailServerPort",
388
174d7a46f58d Fixed an issue with the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
81 self.portSpin.value())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
82 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
83 "Email",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.emailEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
85 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
86 "Signature",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.signatureEdit.toPlainText())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
88 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
89 "MailServerAuthentication",
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
90 self.mailAuthenticationGroup.isChecked())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
91 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
92 "MailServerUser",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.mailUserEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
94 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
95 "MailServerPassword",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 Preferences.setUser("MailServerEncryption", encryption)
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
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 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
106 """
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
107 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
108 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
109 """
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 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
111 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
112 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
113 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
114 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
115 self.portSpin.setValue(25)
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
116
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
117 @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
118 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
119 """
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 Private slot handling a change of no encryption 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
121
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
122 @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
123 @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
124 """
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 self.__updatePortSpin()
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
126
3ef014765648 Added capability to use the SSL encryption method (next to StartTLS) in the built in Email dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
127 @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
128 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
129 """
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 Private slot handling a change of SSL encryption 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
131
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
132 @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
133 @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
134 """
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
135 self.__updatePortSpin()
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
136
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
137 @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
138 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
139 """
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 Private slot handling a change of TLS encryption 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
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 @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
143 @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
144 """
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 self.__updatePortSpin()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
147 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
148 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
149 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
150 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
151 self.testButton.setEnabled(
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
152 self.mailAuthenticationGroup.isChecked() and
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
153 self.mailUserEdit.text() != "" and
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3025
diff changeset
154 self.mailPasswordEdit.text() != "" and
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
155 self.mailServerEdit.text() != ""
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
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 @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
159 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
160 """
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
161 Private slot to handle a change of the text of the mail server edit.
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
162
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
163 @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
164 @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
165 """
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
166 self.__updateTestButton()
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
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(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
169 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
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 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
172 group.
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
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
174 @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
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 self.__updateTestButton()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
177
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
178 @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
179 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
180 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
181 Private slot to handle a change of the text of the user edit.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
182
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
183 @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
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 self.__updateTestButton()
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 @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
188 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
189 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
190 Private slot to handle a change of the text of the user edit.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
191
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
192 @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
193 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
194 self.__updateTestButton()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
195
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
196 @pyqtSlot()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
197 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
198 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
199 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
200 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
201 try:
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
202 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
203 if self.useSslButton.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
204 server = smtplib.SMTP_SSL(self.mailServerEdit.text(),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
205 self.portSpin.value(),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
206 timeout=10)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
207 else:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
208 server = smtplib.SMTP(self.mailServerEdit.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
209 self.portSpin.value(),
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
210 timeout=10)
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
211 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
212 server.starttls()
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
213 server.login(self.mailUserEdit.text(),
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
214 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
215 server.quit()
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
216 E5MessageBox.information(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
217 self,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
218 self.tr("Login Test"),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
219 self.tr("""The login test succeeded."""))
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
220 except (smtplib.SMTPException, OSError) as e:
3539
0c2dc1446ebf Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
221 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
222 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
223 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
224 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
225 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
226 try:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
227 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
228 except TypeError:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
229 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
230 else:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
231 errorStr = str(e)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
232 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
233 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
234 self.tr("Login Test"),
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
235 self.tr(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
236 """<p>The login test failed.<br>Reason: {0}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
237 .format(errorStr))
6559
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
238
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
239 @pyqtSlot()
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
240 def on_googleHelpButton_clicked(self):
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
241 """
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
242 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
243 """
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
244 if self.__helpDialog is None:
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
245 try:
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
246 from E5Network.E5GoogleMail import GoogleMailHelp
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
247 helpStr = GoogleMailHelp()
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
248 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
249 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
250 "<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
251 " 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
252 ).format(getInstallCommand())
6559
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
253
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
254 from E5Gui.E5SimpleHelpDialog import E5SimpleHelpDialog
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
255 self.__helpDialog = E5SimpleHelpDialog(
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
256 title=self.tr("Gmail API Help"),
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
257 helpStr=helpStr, parent=self)
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
258
1265efa7364f Some fixes for configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
259 self.__helpDialog.show()
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
260
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
261 @pyqtSlot()
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
262 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
263 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
264 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
265 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
266 pip = e5App().getObject("Pip")
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
267 pip.installPackages(RequiredPackages, interpreter=sys.executable)
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
268 self.__checkGoogleMail()
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
269
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
270 @pyqtSlot()
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
271 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
272 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
273 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
274 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
275 self.__checkGoogleMail()
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
276
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
277 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
278 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
279 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
280 widgets accordingly.
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
281 """
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
282 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
283 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
284 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
285 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
286 self.googleMailCheckBox.setEnabled(True)
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
287
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
288 try:
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
289 import E5Network.E5GoogleMail # __IGNORE_WARNING__
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 from E5Network.E5GoogleMailHelpers import (
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
291 isClientSecretFileAvailable
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
292 )
6828
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
293
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
294 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
295 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
296 # 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
297 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
298 self.googleMailCheckBox.setEnabled(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.googleMailInfoLabel.setText(self.tr(
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
300 "<p>The client secrets file is not present."
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
301 " Has the Gmail API been enabled?</p>"))
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
302 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
303 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
304 else:
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
305 self.googleMailCheckBox.setChecked(
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
306 Preferences.getUser("UseGoogleMailOAuth2"))
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
307 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
308 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
309 except ImportError:
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
310 # 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
311 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
312 self.googleMailCheckBox.setEnabled(False)
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
313 self.googleMailInfoLabel.setText(self.tr(
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
314 "<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
315 " 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
316 ).format(getInstallCommand()))
bb6667ea9ae7 Changed the Google Mail interface to not use obsoleted packages anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6825
diff changeset
317 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
318 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
319 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
320
1061
3e21869872e3 Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1032
diff changeset
321
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 def create(dlg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 Module function to create the configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 @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
327 @return reference to the instantiated page (ConfigurationPageBase)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 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
330 return page

eric ide

mercurial