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)
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)
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()
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
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):
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):
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):
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):
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")
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:
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)