"""
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):
"""
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)
"""
@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:
# 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
@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
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}
@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):
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:
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")
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:
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()
item.update(force=True)
except Exception:
_moduleLogger.exception("Update failed for %r" % item)
+ self._timeoutId = None
self._schedule_update()
return False # do not continue
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
import gtk_toolbox
import simple_presence
-import gvoice.state_machine as state_machine
_moduleLogger = logging.getLogger('presence')
"""
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
"""