self.__nextRecievedId += 1
+ def do_quit(self, args):
+ if args:
+ self._report_new_message("No arguments supported")
+ return
+
+ try:
+ self._conn.manager.quit_now()
+ except Exception, e:
+ self._report_new_message(str(e))
+
+ def help_quit(self):
+ self._report_new_message("Shutdown the connection manager immediately, forcing it to be relaunched on reconnect")
+
def do_reset_state_machine(self, args):
try:
args = args.strip().lower()
args = "all"
if args == "all":
for machine in self._conn.session.stateMachine._machines:
- machine.reset_timers()
+ machine.reset_timers(True)
elif args == "contacts":
- self._conn.session.addressbookStateMachine.reset_timers()
+ self._conn.session.addressbookStateMachine.reset_timers(True)
elif args == "voicemail":
- self._conn.session.voicemailsStateMachine.reset_timers()
+ self._conn.session.voicemailsStateMachine.reset_timers(True)
elif args == "texts":
- self._conn.session.textsStateMachine.reset_timers()
+ self._conn.session.textsStateMachine.reset_timers(True)
else:
self._report_new_message('Unknown machine "%s"' % (args, ))
except Exception, e:
"reset_state_machine texts"
""")
+ def do_update_now(self, args):
+ try:
+ args = args.strip().lower()
+ if not args:
+ args = "all"
+ if args == "all":
+ for machine in self._conn.session.stateMachine._machines:
+ machine.update_now()
+ elif args == "contacts":
+ self._conn.session.addressbookStateMachine.update_now()
+ elif args == "voicemail":
+ self._conn.session.voicemailsStateMachine.update_now()
+ elif args == "texts":
+ self._conn.session.textsStateMachine.update_now()
+ else:
+ self._report_new_message('Unknown machine "%s"' % (args, ))
+ except Exception, e:
+ self._report_new_message(str(e))
+
+ def help_update_now(self):
+ self._report_new_message("""Updates all the state machines now skipping there initialization time.
+"update_now" - for all
+"update_now all"
+"update_now contacts"
+"update_now voicemail"
+"update_now texts"
+""")
+
def do_get_state(self, args):
if args:
self._report_new_message("No arguments supported")
# self._protos is from super
self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
self._on_shutdown = shutdown_func
+ self._quitImmediately = False
_moduleLogger.info("Connection manager created")
@misc_utils.log_exception(_moduleLogger)
return result
def disconnect_completed(self):
- gobject_utils.timeout_add_seconds(self.IDLE_TIMEOUT, self._shutdown)
+ if self._quitImmediately:
+ self._shutdown()
+ else:
+ gobject_utils.timeout_add_seconds(self.IDLE_TIMEOUT, self._shutdown)
def quit(self):
"""
conn.Disconnect()
_moduleLogger.info("Connection manager quitting")
+ def quit_now(self):
+ self._quitImmediately = True
+ self.quit()
+
@misc_utils.log_exception(_moduleLogger)
def _shutdown(self):
if (
def state(self):
return self._state
- def reset_timers(self):
- self._reset_timers()
+ def reset_timers(self, initialize=False):
+ self._reset_timers(initialize)
+
+ def update_now(self):
+ if not self._isActive:
+ return # not started yet
+ _moduleLogger.info("%s Forcing immediate update of state machine" % (self._name, ))
+ self._onTimeout.cancel()
+ self._strategy.initialize_state()
+ self._strategy.increment_state()
+ nextTimeout = self._strategy.timeout
+ if nextTimeout != self.INFINITE_PERIOD and nextTimeout < self._maxTime:
+ nextTimeout = 0
+ self._onTimeout.start(seconds=nextTimeout)
+ _moduleLogger.info("%s Marked for update" % (self._name, ))
+ else:
+ _moduleLogger.info("%s Disabled, skipping update (timeout is %s seconds)" % (self._name, nextTimeout, ))
@property
def request_reset_timers(self):