Improving state machine timing, logged material, comments, etc
authorEd Page <eopage@byu.net>
Tue, 12 Jan 2010 00:46:38 +0000 (18:46 -0600)
committerEd Page <eopage@byu.net>
Tue, 12 Jan 2010 00:46:38 +0000 (18:46 -0600)
src/channel/text.py
src/gvoice/conversations.py
src/gvoice/session.py
src/gvoice/state_machine.py
src/requests.py

index 24a0687..bcdacbe 100644 (file)
@@ -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)
index d5e060f..c8f623a 100644 (file)
@@ -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),
index 99ef94f..d68f592 100644 (file)
@@ -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),
                        )
                )
index 1895a5d..21495a7 100644 (file)
@@ -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:
index 26a4d84..0cd8879 100644 (file)
@@ -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])