+ self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
+
+ def _initialize_tab(self, index):
+ assert index < self.MAX_TABS, "Invalid tab"
+ if not self._tabsContents[index].has_child():
+ tab = self._TAB_CLASS[index](self._app, self._session, self._errorLog)
+ self._tabsContents[index].set_child(tab)
+ self._tabsContents[index].refresh(force=False)
+
+ def _prompt_for_login(self):
+ if self._credentialsDialog is None:
+ import dialogs
+ self._credentialsDialog = dialogs.CredentialsDialog(self._app)
+ credentials = self._credentialsDialog.run(
+ self._defaultCredentials[0], self._defaultCredentials[1], self.window
+ )
+ if credentials is None:
+ return
+ username, password = credentials
+ self._curentCredentials = username, password
+ self._session.login(username, password)
+
+ def _show_account_dialog(self):
+ if self._accountDialog is None:
+ import dialogs
+ self._accountDialog = dialogs.AccountDialog(self._app)
+ self._accountDialog.setIfNotificationsSupported(self._app.alarmHandler.backgroundNotificationsSupported)
+ self._accountDialog.notifications = self._app.alarmHandler.alarmType
+ self._accountDialog.notificationTime = self._app.alarmHandler.recurrence
+ self._accountDialog.notifyOnMissed = self._app.notifyOnMissed
+ self._accountDialog.notifyOnVoicemail = self._app.notifyOnVoicemail
+ self._accountDialog.notifyOnSms = self._app.notifyOnSms
+ self._accountDialog.set_callbacks(
+ self._session.get_callback_numbers(), self._session.get_callback_number()
+ )
+ accountNumberToDisplay = self._session.get_account_number()
+ if not accountNumberToDisplay:
+ accountNumberToDisplay = "Not Available (%s)" % self._session.state
+ self._accountDialog.set_account_number(accountNumberToDisplay)
+ response = self._accountDialog.run(self.window)
+ if response == QtGui.QDialog.Accepted:
+ if self._accountDialog.doClear:
+ self._session.logout_and_clear()
+ self._defaultCredentials = "", ""
+ self._curentCredentials = "", ""
+ for tab in self._tabsContents:
+ tab.disable()
+ else:
+ callbackNumber = self._accountDialog.selectedCallback
+ self._session.set_callback_number(callbackNumber)
+
+ if (
+ self._accountDialog.notifyOnMissed or
+ self._accountDialog.notifyOnVoicemail or
+ self._accountDialog.notifyOnSms
+ ):
+ notifications = self._accountDialog.notifications
+ else:
+ notifications = self._accountDialog.ALARM_NONE
+ self._app.alarmHandler.apply_settings(notifications, self._accountDialog.notificationTime)
+
+ self._app.notifyOnMissed = self._accountDialog.notifyOnMissed
+ self._app.notifyOnVoicemail = self._accountDialog.notifyOnVoicemail
+ self._app.notifyOnSms = self._accountDialog.notifyOnSms
+ self._app.save_settings()
+ elif response == QtGui.QDialog.Rejected:
+ _moduleLogger.info("Cancelled")
+ else:
+ _moduleLogger.info("Unknown response")