From: Ed Page Date: Thu, 24 Dec 2009 15:36:32 +0000 (-0600) Subject: Call-centric work X-Git-Url: http://git.maemo.org/git/?p=theonering;a=commitdiff_plain;h=1bd375495719117939fa0ac384835001485eeef7 Call-centric work * Cleanup * Putting a hack in for capabilities * Call state stuff --- diff --git a/src/aliasing.py b/src/aliasing.py index ed79708..bf73e06 100644 --- a/src/aliasing.py +++ b/src/aliasing.py @@ -77,12 +77,11 @@ class AliasingMixin(telepathy.server.ConnectionInterfaceAliasing): """ raise NotImplementedError("Abstract property called") - @property - def handle(self): + def handle(self, handleType, handleId): """ @abstract """ - raise NotImplementedError("Abstract property called") + raise NotImplementedError("Abstract function called") @gtk_toolbox.log_exception(_moduleLogger) def GetAliasFlags(self): diff --git a/src/capabilities.py b/src/capabilities.py index 31227d4..c4a94cb 100644 --- a/src/capabilities.py +++ b/src/capabilities.py @@ -24,27 +24,39 @@ class CapabilitiesMixin(telepathy.server.ConnectionInterfaceCapabilities): """ raise NotImplementedError("Abstract property called") - @property - def handle(self): + def handle(self, handleType, handleId): """ @abstract """ - raise NotImplementedError("Abstract property called") + raise NotImplementedError("Abstract function called") + + def GetSelfHandle(self): + """ + @abstract + """ + raise NotImplementedError("Abstract function called") @gtk_toolbox.log_exception(_moduleLogger) - def GetCapabilities(self, handles): + def GetCapabilities(self, handleIds): """ @todo HACK Remove this once we are building against a fixed version of python-telepathy """ ret = [] - for handle in handles: - if handle != 0 and (telepathy.HANDLE_TYPE_CONTACT, handle) not in self._handles: + for handleId in handleIds: + h = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId) + if handleId != 0 and (telepathy.HANDLE_TYPE_CONTACT, handleId) not in self._handles: raise telepathy.errors.InvalidHandle - elif handle in self._caps: - theirs = self._caps[handle] - for type in theirs: - ret.append([handle, type, theirs[0], theirs[1]]) - _moduleLogger.info("GetCaps %r" % ret) + elif h in self._caps: + types = self._caps[h] + for type in types: + for ctype, specs in types.iteritems(): + ret.append([handleId, type, specs[0], specs[1]]) + else: + # No caps, so just default to the connection's caps + types = self._caps[self.GetSelfHandle()] + for type in types: + for ctype, specs in types.iteritems(): + ret.append([handleId, type, specs[0], specs[1]]) return ret @gtk_toolbox.log_exception(_moduleLogger) @@ -52,7 +64,7 @@ class CapabilitiesMixin(telepathy.server.ConnectionInterfaceCapabilities): """ @todo HACK Remove this once we are building against a fixed version of python-telepathy """ - my_caps = self._caps.setdefault(self._self_handle, {}) + my_caps = self._caps.setdefault(self.GetSelfHandle(), {}) changed = {} for ctype, spec_caps in add: @@ -70,13 +82,12 @@ class CapabilitiesMixin(telepathy.server.ConnectionInterfaceCapabilities): # channel type supports new capabilities gen_new, spec_new = gen_old, spec_old | spec_caps if spec_old != spec_new or gen_old != gen_new: - caps.append((self._self_handle, ctype, gen_old, gen_new, + caps.append((self.GetSelfHandle(), ctype, gen_old, gen_new, spec_old, spec_new)) - _moduleLogger.info("CapsChanged %r" % caps) self.CapabilitiesChanged(caps) + _moduleLogger.info("CapsChanged %r" % self._caps) # return all my capabilities ret = [(ctype, caps[1]) for ctype, caps in my_caps.iteritems()] - _moduleLogger.info("Adv %r" % ret) return ret diff --git a/src/channel/call.py b/src/channel/call.py index 9de629e..24ec99f 100644 --- a/src/channel/call.py +++ b/src/channel/call.py @@ -60,15 +60,13 @@ class CallChannel( @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)] """ - for streamType in streamTypes: - if streamType != telepathy.constants.MEDIA_STREAM_TYPE_AUDIO: - raise telepathy.errors.NotImplemented("Audio is the only stream type supported") - contact = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, contactId) assert self._contactHandle == contact, "%r != %r" % (self._contactHandle, contact) contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name) + self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING) self._conn.session.backend.call(contactNumber) + self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED) streamId = 0 streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED @@ -84,4 +82,4 @@ class CallChannel( Get the current call states for all contacts involved in this call. @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*} """ - return {} + return {self._contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED} diff --git a/src/gvoice/backend.py b/src/gvoice/backend.py index 251cfa5..a02ed76 100755 --- a/src/gvoice/backend.py +++ b/src/gvoice/backend.py @@ -437,6 +437,7 @@ class GVoiceBackend(object): @param callbacknumber should be a proper 10 digit number """ self._callbackNumber = callbacknumber + _moduleLogger.info("Callback number changed: %r" % self._callbackNumber) return True def get_callback_number(self): diff --git a/src/gvoice/conversations.py b/src/gvoice/conversations.py index 4541608..7435da8 100644 --- a/src/gvoice/conversations.py +++ b/src/gvoice/conversations.py @@ -38,7 +38,8 @@ class Conversations(object): mergedConversations.append_conversation(conversation) isConversationUpdated = True except RuntimeError, e: - _moduleLogger.info("Skipping conversation for %r because '%s'" % (key, e)) + if False: + _moduleLogger.info("Skipping conversation for %r because '%s'" % (key, e)) isConversationUpdated = False if isConversationUpdated: diff --git a/src/gvoice/state_machine.py b/src/gvoice/state_machine.py index 6b0a58d..6080abd 100644 --- a/src/gvoice/state_machine.py +++ b/src/gvoice/state_machine.py @@ -72,6 +72,7 @@ class StateMachine(object): except Exception: _moduleLogger.exception("Initial update failed for %r" % item) self._schedule_update() + return False # do not continue def stop(self): _moduleLogger.info("Stopping an already stopped state machine") @@ -103,6 +104,7 @@ class StateMachine(object): self._currentPeriod = self._INITIAL_ACTIVE_PERIOD / 2 # We will double it later def _schedule_update(self): + assert self._timeoutId is None nextTimeout = self._calculate_step(self._state, self._currentPeriod) nextTimeout = int(nextTimeout) if nextTimeout != self._INFINITE_PERIOD: @@ -117,6 +119,8 @@ class StateMachine(object): self._timeoutId = None def _reset_timers(self): + if self._timeoutId is None: + return # not started yet self._stop_update() self._set_initial_period() self._schedule_update() @@ -128,6 +132,7 @@ class StateMachine(object): item.update(force=True) except Exception: _moduleLogger.exception("Update failed for %r" % item) + self._timeoutId = None self._schedule_update() return False # do not continue diff --git a/src/handle.py b/src/handle.py index 55f36fb..33d5660 100644 --- a/src/handle.py +++ b/src/handle.py @@ -121,8 +121,9 @@ def create_handle_factory(): cache[key] = handle isNewHandle = True connection._handles[handle.get_type(), handle.get_id()] = handle - handleStatus = "Is New!" if isNewHandle else "From Cache" - _moduleLogger.info("Created Handle: %r (%s)" % (handle, handleStatus)) + if False: + handleStatus = "Is New!" if isNewHandle else "From Cache" + _moduleLogger.info("Created Handle: %r (%s)" % (handle, handleStatus)) return handle return create_handle diff --git a/src/presence.py b/src/presence.py index f078e27..8c38252 100644 --- a/src/presence.py +++ b/src/presence.py @@ -4,7 +4,6 @@ import telepathy import gtk_toolbox import simple_presence -import gvoice.state_machine as state_machine _moduleLogger = logging.getLogger('presence') diff --git a/src/simple_presence.py b/src/simple_presence.py index e5d5973..49941f8 100644 --- a/src/simple_presence.py +++ b/src/simple_presence.py @@ -32,14 +32,13 @@ class TheOneRingPresence(object): """ raise NotImplementedError() - @property - def handle(self): + def Disconnect(self): """ @abstract """ - raise NotImplementedError("Abstract property called") + raise NotImplementedError("Abstract function called") - def Disconnect(self): + def handle(self, handleType, handleId): """ @abstract """