From 37dc1dd235e299a7cfb57efc818977b5bdad64a0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 11 Jan 2010 18:46:38 -0600 Subject: [PATCH] Improving state machine timing, logged material, comments, etc --- src/channel/text.py | 4 ++++ src/gvoice/conversations.py | 6 +++++- src/gvoice/session.py | 10 +++++----- src/gvoice/state_machine.py | 4 +++- src/requests.py | 2 ++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/channel/text.py b/src/channel/text.py index 24a0687..bcdacbe 100644 --- a/src/channel/text.py +++ b/src/channel/text.py @@ -86,6 +86,7 @@ class TextChannel(telepathy.server.ChannelTypeText): if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: raise telepathy.errors.NotImplemented("Unhandled message type: %r" % messageType) + _moduleLogger.info("Sending message to %r" % (self.__otherHandle, )) self._conn.session.backend.send_sms(self.__otherHandle.phoneNumber, text) self._conn.session.textsStateMachine.reset_timers() @@ -124,6 +125,9 @@ class TextChannel(telepathy.server.ChannelTypeText): self._report_conversation(mergedConversations) def _report_conversation(self, mergedConversations): + # Can't filter out messages in a texting conversation that came in + # before the last one sent because that creates a race condition of two + # people sending at about the same time, which happens quite a bit newConversations = mergedConversations.conversations newConversations = self._filter_out_reported(newConversations) newConversations = self._filter_out_read(newConversations) diff --git a/src/gvoice/conversations.py b/src/gvoice/conversations.py index d5e060f..c8f623a 100644 --- a/src/gvoice/conversations.py +++ b/src/gvoice/conversations.py @@ -1,5 +1,9 @@ #!/usr/bin/python +# @bug Its inconsistent as to whether messages from contacts come as from the +# contact or just a raw number +# @bug False positives on startup. Luckily the object path for the channel is +# unique, so can use that to cache some of the data out to file import logging @@ -115,7 +119,7 @@ class MergedConversations(object): for newMessage in newConversationMessages if newMessage not in relatedConversation.messages ] - _moduleLogger.info("Found %d new messages in conversation %s (%d/%d)" % ( + _moduleLogger.debug("Found %d new messages in conversation %s (%d/%d)" % ( len(newConversationMessages) - len(newConversation.messages), newConversation.id, len(newConversation.messages), diff --git a/src/gvoice/session.py b/src/gvoice/session.py index 99ef94f..d68f592 100644 --- a/src/gvoice/session.py +++ b/src/gvoice/session.py @@ -31,7 +31,7 @@ class Session(object): ) self._addressbookStateMachine.set_state_strategy( state_machine.StateMachine.STATE_ACTIVE, - state_machine.ConstantStateStrategy(state_machine.to_milliseconds(hours=1)) + state_machine.ConstantStateStrategy(state_machine.to_milliseconds(hours=2)) ) self._voicemails = conversations.Conversations(self._backend.get_voicemails) @@ -42,11 +42,11 @@ class Session(object): ) self._voicemailsStateMachine.set_state_strategy( state_machine.StateMachine.STATE_IDLE, - state_machine.ConstantStateStrategy(state_machine.to_milliseconds(minutes=30)) + state_machine.ConstantStateStrategy(state_machine.to_milliseconds(minutes=60)) ) self._voicemailsStateMachine.set_state_strategy( state_machine.StateMachine.STATE_ACTIVE, - state_machine.ConstantStateStrategy(state_machine.to_milliseconds(minutes=5)) + state_machine.ConstantStateStrategy(state_machine.to_milliseconds(minutes=10)) ) self._voicemails.updateSignalHandler.register_sink( self._voicemailsStateMachine.request_reset_timers @@ -65,8 +65,8 @@ class Session(object): self._textsStateMachine.set_state_strategy( state_machine.StateMachine.STATE_ACTIVE, state_machine.GeometricStateStrategy( - state_machine.to_milliseconds(seconds=10), - state_machine.to_milliseconds(seconds=1), + state_machine.to_milliseconds(seconds=20), + state_machine.to_milliseconds(milliseconds=500), state_machine.to_milliseconds(minutes=10), ) ) diff --git a/src/gvoice/state_machine.py b/src/gvoice/state_machine.py index 1895a5d..21495a7 100644 --- a/src/gvoice/state_machine.py +++ b/src/gvoice/state_machine.py @@ -177,6 +177,7 @@ class UpdateStateMachine(StateMachine): _moduleLogger.info("%s Starting State Machine" % (self._name, )) def stop(self): + _moduleLogger.info("%s Stopping State Machine" % (self._name, )) self._stop_update() def close(self): @@ -197,6 +198,7 @@ class UpdateStateMachine(StateMachine): return self._state def reset_timers(self): + _moduleLogger.info("%s Resetting State Machine" % (self._name, )) self._reset_timers() @property @@ -220,7 +222,7 @@ class UpdateStateMachine(StateMachine): nextTimeout = self._strategy.timeout if nextTimeout != self.INFINITE_PERIOD: self._timeoutId = gobject.timeout_add(nextTimeout, self._on_timeout) - _moduleLogger.debug("%s Next update in %s ms" % (self._name, nextTimeout, )) + _moduleLogger.info("%s Next update in %s ms" % (self._name, nextTimeout, )) def _stop_update(self): if self._timeoutId is None: diff --git a/src/requests.py b/src/requests.py index 26a4d84..0cd8879 100644 --- a/src/requests.py +++ b/src/requests.py @@ -163,6 +163,7 @@ class RequestsMixin( _success(channel._object_path, props) # CreateChannel MUST return *before* NewChannels is emitted. + # @bug On older python-telepathy, it doesn't exist self.signal_new_channels([channel]) @dbus.service.method(telepathy.interfaces.CONNECTION_INTERFACE_REQUESTS, @@ -180,4 +181,5 @@ class RequestsMixin( _success(yours, channel._object_path, props) + # @bug On older python-telepathy, it doesn't exist self.signal_new_channels([channel]) -- 1.7.9.5