From: Ed Page Date: Sun, 27 Feb 2011 00:20:36 +0000 (-0600) Subject: Exposing to the user the ability to do partial refreshes X-Git-Url: http://git.maemo.org/git/?p=gc-dialer;a=commitdiff_plain;h=35398cbc6f8edecb35115faf0f496617f963676e Exposing to the user the ability to do partial refreshes --- diff --git a/src/dialcentral_qt.py b/src/dialcentral_qt.py index 0d7b50a..7ba1e7e 100755 --- a/src/dialcentral_qt.py +++ b/src/dialcentral_qt.py @@ -595,7 +595,12 @@ class MainWindow(qwrappers.WindowWrapper): def _on_app_alert(self): with qui_utils.notify_error(self._errorLog): if self._session.state == self._session.LOGGEDIN_STATE: - self._session.update_messages(force=True) + messageType = { + (True, True): self._session.MESSAGE_ALL, + (True, False): self._session.MESSAGE_TEXTS, + (False, True): self._session.MESSAGE_VOICEMAILS, + }[(self._app.notifyOnSms, self._app.notifyOnVoicemail)] + self._session.update_messages(messageType, force=True) @QtCore.pyqtSlot() @misc_utils.log_exception(_moduleLogger) diff --git a/src/dialogs.py b/src/dialogs.py index 4cbcd84..be4a177 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -350,15 +350,13 @@ class AccountDialog(object): self._notificationTimeSelector.setEnabled(True) self._missedCallsNotificationButton.setEnabled(False) - self._voicemailNotificationButton.setEnabled(False) - self._smsNotificationButton.setEnabled(False) + self._voicemailNotificationButton.setEnabled(True) + self._smsNotificationButton.setEnabled(True) self._missedCallsNotificationButton.setChecked(False) - self._voicemailNotificationButton.setChecked(True) - self._smsNotificationButton.setChecked(True) else: - self._notificationTimeSelector.setEnabled(False) + self._missedCallsNotificationButton.setEnabled(False) self._voicemailNotificationButton.setEnabled(False) self._smsNotificationButton.setEnabled(False) diff --git a/src/gv_views.py b/src/gv_views.py index 6745812..08de9b7 100644 --- a/src/gv_views.py +++ b/src/gv_views.py @@ -553,7 +553,18 @@ class Messages(object): def refresh(self, force=True): self._itemView.setFocus(QtCore.Qt.OtherFocusReason) - self._session.update_messages(force) + + if self._selectedTypeFilter == self.NO_MESSAGES: + pass + elif self._selectedTypeFilter == self.TEXT_MESSAGES: + self._session.update_messages(self._session.MESSAGE_TEXTS, force) + elif self._selectedTypeFilter == self.VOICEMAIL_MESSAGES: + self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force) + elif self._selectedTypeFilter == self.ALL_TYPES: + self._session.update_messages(self._session.MESSAGE_ALL, force) + else: + assert False, "How did we get here?" + if self._app.notifyOnSms or self._app.notifyOnVoicemail and self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_BACKGROUND: self._app.ledHandler.off() diff --git a/src/session.py b/src/session.py index bc682f7..6c2029c 100644 --- a/src/session.py +++ b/src/session.py @@ -211,6 +211,10 @@ class Session(QtCore.QObject): LOGGINGIN_STATE = "logging in" LOGGEDIN_STATE = "logged in" + MESSAGE_TEXTS = "Text" + MESSAGE_VOICEMAILS = "Voicemail" + MESSAGE_ALL = "All" + _OLDEST_COMPATIBLE_FORMAT_VERSION = misc_utils.parse_version("1.3.0") _LOGGEDOUT_TIME = -1 @@ -294,7 +298,7 @@ class Session(QtCore.QObject): def update_account(self, force = True): if not force and self._contacts: return - le = concurrent.AsyncLinearExecution(self._pool, self._update_account) + le = concurrent.AsyncLinearExecution(self._pool, self._update_account), (), {} self._perform_op_while_loggedin(le) def get_contacts(self): @@ -303,10 +307,10 @@ class Session(QtCore.QObject): def get_when_contacts_updated(self): return self._accountUpdateTime - def update_messages(self, force = True): + def update_messages(self, messageType, force = True): if not force and self._messages: return - le = concurrent.AsyncLinearExecution(self._pool, self._update_messages) + le = concurrent.AsyncLinearExecution(self._pool, self._update_messages), (messageType, ), {} self._perform_op_while_loggedin(le) def get_messages(self): @@ -318,7 +322,7 @@ class Session(QtCore.QObject): def update_history(self, force = True): if not force and self._history: return - le = concurrent.AsyncLinearExecution(self._pool, self._update_history) + le = concurrent.AsyncLinearExecution(self._pool, self._update_history), (), {} self._perform_op_while_loggedin(le) def get_history(self): @@ -328,7 +332,7 @@ class Session(QtCore.QObject): return self._historyUpdateTime def update_dnd(self): - le = concurrent.AsyncLinearExecution(self._pool, self._update_dnd) + le = concurrent.AsyncLinearExecution(self._pool, self._update_dnd), (), {} self._perform_op_while_loggedin(le) def set_dnd(self, dnd): @@ -442,8 +446,8 @@ class Session(QtCore.QObject): else: loginOps = [] del self._loginOps[:] - for asyncOp in loginOps: - asyncOp.start() + for asyncOp, args, kwds in loginOps: + asyncOp.start(*args, **kwds) else: self._loggedInTime = self._LOGGEDOUT_TIME self.error.emit("Error logging in") @@ -603,13 +607,13 @@ class Session(QtCore.QObject): return self._process_account_data(accountData) - def _update_messages(self): + def _update_messages(self, messageType): try: assert self.state == self.LOGGEDIN_STATE, "Messages requires being logged in (currently %s" % self.state - with qui_utils.notify_busy(self._errorLog, "Updating Messages"): + with qui_utils.notify_busy(self._errorLog, "Updating %s Messages" % messageType): self._messages = yield ( self._backend[0].get_messages, - (self._backend[0].MESSAGE_ALL, ), + (messageType, ), {}, ) except Exception, e: @@ -654,7 +658,8 @@ class Session(QtCore.QObject): def _perform_op_while_loggedin(self, op): if self.state == self.LOGGEDIN_STATE: - op.start() + op, args, kwds = op + op.start(*args, **kwds) else: self._push_login_op(op)