11 import socket |
11 import socket |
12 import sys |
12 import sys |
13 |
13 |
14 from PyQt6.QtCore import pyqtSlot |
14 from PyQt6.QtCore import pyqtSlot |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import EricMessageBox |
17 from E5Gui.E5Application import e5App |
17 from E5Gui.EricApplication import ericApp |
18 from E5Gui.E5OverrideCursor import E5OverrideCursor |
18 from E5Gui.EricOverrideCursor import EricOverrideCursor |
19 |
19 |
20 from EricNetwork.EricGoogleMailHelpers import getInstallCommand, RequiredPackages |
20 from EricNetwork.EricGoogleMailHelpers import getInstallCommand, RequiredPackages |
21 |
21 |
22 from .ConfigurationPageBase import ConfigurationPageBase |
22 from .ConfigurationPageBase import ConfigurationPageBase |
23 from .Ui_EmailPage import Ui_EmailPage |
23 from .Ui_EmailPage import Ui_EmailPage |
197 def on_testButton_clicked(self): |
197 def on_testButton_clicked(self): |
198 """ |
198 """ |
199 Private slot to test the mail server login data. |
199 Private slot to test the mail server login data. |
200 """ |
200 """ |
201 try: |
201 try: |
202 with E5OverrideCursor(): |
202 with EricOverrideCursor(): |
203 if self.useSslButton.isChecked(): |
203 if self.useSslButton.isChecked(): |
204 server = smtplib.SMTP_SSL(self.mailServerEdit.text(), |
204 server = smtplib.SMTP_SSL(self.mailServerEdit.text(), |
205 self.portSpin.value(), |
205 self.portSpin.value(), |
206 timeout=10) |
206 timeout=10) |
207 else: |
207 else: |
211 if self.useTlsButton.isChecked(): |
211 if self.useTlsButton.isChecked(): |
212 server.starttls() |
212 server.starttls() |
213 server.login(self.mailUserEdit.text(), |
213 server.login(self.mailUserEdit.text(), |
214 self.mailPasswordEdit.text()) |
214 self.mailPasswordEdit.text()) |
215 server.quit() |
215 server.quit() |
216 E5MessageBox.information( |
216 EricMessageBox.information( |
217 self, |
217 self, |
218 self.tr("Login Test"), |
218 self.tr("Login Test"), |
219 self.tr("""The login test succeeded.""")) |
219 self.tr("""The login test succeeded.""")) |
220 except (smtplib.SMTPException, OSError) as e: |
220 except (smtplib.SMTPException, OSError) as e: |
221 if isinstance(e, smtplib.SMTPResponseException): |
221 if isinstance(e, smtplib.SMTPResponseException): |
249 helpStr = self.tr( |
249 helpStr = self.tr( |
250 "<p>The Google Mail Client API is not installed." |
250 "<p>The Google Mail Client API is not installed." |
251 " Use <code>{0}</code> to install it.</p>" |
251 " Use <code>{0}</code> to install it.</p>" |
252 ).format(getInstallCommand()) |
252 ).format(getInstallCommand()) |
253 |
253 |
254 from E5Gui.E5SimpleHelpDialog import E5SimpleHelpDialog |
254 from E5Gui.EricSimpleHelpDialog import EricSimpleHelpDialog |
255 self.__helpDialog = E5SimpleHelpDialog( |
255 self.__helpDialog = EricSimpleHelpDialog( |
256 title=self.tr("Gmail API Help"), |
256 title=self.tr("Gmail API Help"), |
257 helpStr=helpStr, parent=self) |
257 helpStr=helpStr, parent=self) |
258 |
258 |
259 self.__helpDialog.show() |
259 self.__helpDialog.show() |
260 |
260 |
261 @pyqtSlot() |
261 @pyqtSlot() |
262 def on_googleInstallButton_clicked(self): |
262 def on_googleInstallButton_clicked(self): |
263 """ |
263 """ |
264 Private slot to install the required packages for use of Google Mail. |
264 Private slot to install the required packages for use of Google Mail. |
265 """ |
265 """ |
266 pip = e5App().getObject("Pip") |
266 pip = ericApp().getObject("Pip") |
267 pip.installPackages(RequiredPackages, interpreter=sys.executable) |
267 pip.installPackages(RequiredPackages, interpreter=sys.executable) |
268 self.__checkGoogleMail() |
268 self.__checkGoogleMail() |
269 |
269 |
270 @pyqtSlot() |
270 @pyqtSlot() |
271 def on_googleCheckAgainButton_clicked(self): |
271 def on_googleCheckAgainButton_clicked(self): |