except Exception:
_moduleLogger.exception("Unknown loading error")
- blobs = "", ""
- isFullscreen = False
- isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical
- tabIndex = 0
- try:
- blobs = [
- config.get(constants.__pretty_app_name__, "bin_blob_%i" % i)
- for i in xrange(len(self._mainWindow.get_default_credentials()))
- ]
- isFullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
- tabIndex = config.getint(constants.__pretty_app_name__, "tab")
- isPortrait = config.getboolean(constants.__pretty_app_name__, "portrait")
- except ConfigParser.NoOptionError, e:
- _moduleLogger.info(
- "Settings file %s is missing option %s" % (
- constants._user_settings_,
- e.option,
- ),
- )
- except ConfigParser.NoSectionError, e:
- _moduleLogger.info(
- "Settings file %s is missing section %s" % (
- constants._user_settings_,
- e.section,
- ),
- )
- except Exception:
- _moduleLogger.exception("Unknown loading error")
-
- try:
- self._alarmHandler.load_settings(config, "alarm")
- self.notifyOnMissed = config.getboolean("2 - Account Info", "notifyOnMissed")
- self.notifyOnVoicemail = config.getboolean("2 - Account Info", "notifyOnVoicemail")
- self.notifyOnSms = config.getboolean("2 - Account Info", "notifyOnSms")
- except ConfigParser.NoOptionError, e:
- _moduleLogger.info(
- "Settings file %s is missing option %s" % (
- constants._user_settings_,
- e.option,
- ),
- )
- except ConfigParser.NoSectionError, e:
- _moduleLogger.info(
- "Settings file %s is missing section %s" % (
- constants._user_settings_,
- e.section,
- ),
- )
- except Exception:
- _moduleLogger.exception("Unknown loading error")
-
- creds = (
- base64.b64decode(blob)
- for blob in blobs
- )
- self._mainWindow.set_default_credentials(*creds)
- self._fullscreenAction.setChecked(isFullscreen)
- self._orientationAction.setChecked(isPortrait)
- self._mainWindow.set_current_tab(tabIndex)
self._mainWindow.load_settings(config)
def save_settings(self):
_moduleLogger.info("Saving settings")
config = ConfigParser.SafeConfigParser()
- config.add_section(constants.__pretty_app_name__)
- config.set(constants.__pretty_app_name__, "tab", str(self._mainWindow.get_current_tab()))
- config.set(constants.__pretty_app_name__, "fullscreen", str(self._fullscreenAction.isChecked()))
- config.set(constants.__pretty_app_name__, "portrait", str(self._orientationAction.isChecked()))
- for i, value in enumerate(self._mainWindow.get_default_credentials()):
- blob = base64.b64encode(value)
- config.set(constants.__pretty_app_name__, "bin_blob_%i" % i, blob)
-
- config.add_section("alarm")
- self._alarmHandler.save_settings(config, "alarm")
- config.add_section("2 - Account Info")
- config.set("2 - Account Info", "notifyOnMissed", repr(self.notifyOnMissed))
- config.set("2 - Account Info", "notifyOnVoicemail", repr(self.notifyOnVoicemail))
- config.set("2 - Account Info", "notifyOnSms", repr(self.notifyOnSms))
-
self._mainWindow.save_settings(config)
with open(constants._user_settings_, "wb") as configFile:
self._session.draft.recipientsChanged.connect(self._on_recipients_changed)
self._session.newMessages.connect(self._on_new_message_alert)
self._app.alarmHandler.applicationNotifySignal.connect(self._on_app_alert)
+ self._voicemailRefreshDelay = QtCore.QTimer()
+ self._voicemailRefreshDelay.setInterval(30 * 1000)
+ self._voicemailRefreshDelay.timeout.connect(self._on_call_missed)
+ self._voicemailRefreshDelay.setSingleShot(True)
+ self._callHandler = None
+ self._updateVoicemailOnMissedCall = False
+
self._defaultCredentials = "", ""
self._curentCredentials = "", ""
self._currentTab = 0
self._tabWidget.setCurrentIndex(tabIndex)
def load_settings(self, config):
+ blobs = "", ""
+ isFullscreen = False
+ isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical
+ tabIndex = 0
+ try:
+ blobs = [
+ config.get(constants.__pretty_app_name__, "bin_blob_%i" % i)
+ for i in xrange(len(self.get_default_credentials()))
+ ]
+ isFullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
+ tabIndex = config.getint(constants.__pretty_app_name__, "tab")
+ isPortrait = config.getboolean(constants.__pretty_app_name__, "portrait")
+ except ConfigParser.NoOptionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing option %s" % (
+ constants._user_settings_,
+ e.option,
+ ),
+ )
+ except ConfigParser.NoSectionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ except Exception:
+ _moduleLogger.exception("Unknown loading error")
+
+ try:
+ self._app.alarmHandler.load_settings(config, "alarm")
+ self._app.notifyOnMissed = config.getboolean("2 - Account Info", "notifyOnMissed")
+ self._app.notifyOnVoicemail = config.getboolean("2 - Account Info", "notifyOnVoicemail")
+ self._app.notifyOnSms = config.getboolean("2 - Account Info", "notifyOnSms")
+ self._updateVoicemailOnMissedCall = config.getboolean("2 - Account Info", "updateVoicemailOnMissedCall")
+ except ConfigParser.NoOptionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing option %s" % (
+ constants._user_settings_,
+ e.option,
+ ),
+ )
+ except ConfigParser.NoSectionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ except Exception:
+ _moduleLogger.exception("Unknown loading error")
+
+ creds = (
+ base64.b64decode(blob)
+ for blob in blobs
+ )
+ self.set_default_credentials(*creds)
+ self._app.fullscreenAction.setChecked(isFullscreen)
+ self._app.orientationAction.setChecked(isPortrait)
+ self.set_current_tab(tabIndex)
+
backendId = 2 # For backwards compatibility
for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
sectionName = "%s - %s" % (backendId, tabTitle)
self._tabsContents[tabIndex].set_settings(settings)
def save_settings(self, config):
+ config.add_section(constants.__pretty_app_name__)
+ config.set(constants.__pretty_app_name__, "tab", str(self.get_current_tab()))
+ config.set(constants.__pretty_app_name__, "fullscreen", str(self._app.fullscreenAction.isChecked()))
+ config.set(constants.__pretty_app_name__, "portrait", str(self._app.orientationAction.isChecked()))
+ for i, value in enumerate(self.get_default_credentials()):
+ blob = base64.b64encode(value)
+ config.set(constants.__pretty_app_name__, "bin_blob_%i" % i, blob)
+
+ config.add_section("alarm")
+ self._app.alarmHandler.save_settings(config, "alarm")
+ config.add_section("2 - Account Info")
+ config.set("2 - Account Info", "notifyOnMissed", repr(self._app.notifyOnMissed))
+ config.set("2 - Account Info", "notifyOnVoicemail", repr(self._app.notifyOnVoicemail))
+ config.set("2 - Account Info", "notifyOnSms", repr(self._app.notifyOnSms))
+ config.set("2 - Account Info", "updateVoicemailOnMissedCall", repr(self._updateVoicemailOnMissedCall))
+
backendId = 2 # For backwards compatibility
for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
sectionName = "%s - %s" % (backendId, tabTitle)
import dialogs
self._accountDialog = dialogs.AccountDialog(self._app)
self._accountDialog.setIfNotificationsSupported(self._app.alarmHandler.backgroundNotificationsSupported)
+
+ if self._callHandler is None or not self._callHandler.isSupported:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_NOT_SUPPORTED
+ elif self._updateVoicemailOnMissedCall:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_ENABLED
+ else:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_DISABLED
self._accountDialog.notifications = self._app.alarmHandler.alarmType
self._accountDialog.notificationTime = self._app.alarmHandler.recurrence
self._accountDialog.notifyOnMissed = self._app.notifyOnMissed
callbackNumber = self._accountDialog.selectedCallback
self._session.set_callback_number(callbackNumber)
+ if self._callHandler is None or self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_DISABLEDD:
+ pass
+ elif self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_ENABLED:
+ self._updateVoicemailOnMissedCall = True
+ self._callHandler.start()
+ else:
+ self._updateVoicemailOnMissedCall = False
+ self._callHandler.stop()
if (
self._accountDialog.notifyOnMissed or
self._accountDialog.notifyOnVoicemail or
else:
self._app.ledHandler.on()
+ @QtCore.pyqtSlot()
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_call_missed(self):
+ with qui_utils.notify_error(self._errorLog):
+ self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force=True)
+
@QtCore.pyqtSlot(str)
@misc_utils.log_exception(_moduleLogger)
def _on_session_error(self, message):
for tab in self._tabsContents:
tab.enable()
self._initialize_tab(self._currentTab)
+ if self._updateVoicemailOnMissedCall:
+ if self._callHandler is None:
+ import call_handler
+ self._callHandler = call_handler.MissedCallWatcher()
+ self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
+ self._callHandler.start()
@QtCore.pyqtSlot()
@misc_utils.log_exception(_moduleLogger)
with qui_utils.notify_error(self._errorLog):
for tab in self._tabsContents:
tab.disable()
+ if self._callHandler is not None:
+ self._callHandler.stop()
@QtCore.pyqtSlot()
@misc_utils.log_exception(_moduleLogger)
if e.errno != 17:
raise
- try:
- import gobject
- gobject.threads_init()
- except ImportError:
- pass
-
logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
logging.basicConfig(level=logging.DEBUG, format=logFormat)
rotating = logging.handlers.RotatingFileHandler(constants._user_logpath_, maxBytes=512*1024, backupCount=1)
_moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:])
_moduleLogger.info("Hostname: %s" % os.uname()[1])
+ try:
+ import gobject
+ gobject.threads_init()
+ except ImportError:
+ _moduleLogger.info("GObject support not available")
+ try:
+ import dbus
+ try:
+ from dbus.mainloop.qt import DBusQtMainLoop
+ DBusQtMainLoop(set_as_default=True)
+ _moduleLogger.info("Using Qt mainloop")
+ except ImportError:
+ try:
+ from dbus.mainloop.glib import DBusGMainLoop
+ DBusGMainLoop(set_as_default=True)
+ _moduleLogger.info("Using GObject mainloop")
+ except ImportError:
+ _moduleLogger.info("Mainloop not available")
+ except ImportError:
+ _moduleLogger.info("DBus support not available")
+
app = QtGui.QApplication([])
handle = Dialcentral(app)
qtpie.init_pies()