import telepathy
+import gtk_toolbox
+import handle
+
_moduleLogger = logging.getLogger("channel.call")
telepathy.server.ChannelInterfaceGroup.__init__(self)
telepathy.server.ChannelInterfaceChatState.__init__(self)
+ @gtk_toolbox.log_exception(_moduleLogger)
def ListStreams(self):
"""
For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
"""
return ()
+ @gtk_toolbox.log_exception(_moduleLogger)
def RemoveStreams(self, streams):
"""
For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
"""
raise telepathy.NotImplemented("Cannot remove a stream")
+ @gtk_toolbox.log_exception(_moduleLogger)
def RequestStreamDirection(self, stream, streamDirection):
"""
For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
_moduleLogger.info("A request was made to change the stream direction")
raise telepathy.NotImplemented("Cannot change directions")
+ @gtk_toolbox.log_exception(_moduleLogger)
def RequestStreams(self, contact, streamTypes):
"""
For org.freedesktop.Telepathy.Channel.Type.StreamedMedia
if streamType != telepathy.constants.MEDIA_STREAM_TYPE_AUDIO:
raise telepathy.NotImplemented("Audio is the only stream type supported")
- contactId = contact.name
+ contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
- addressbook = self._conn.session.addressbook
- phones = addressbook.get_contact_details(contactId)
- firstNumber = phones.next()
- self._conn.session.backend.dial(firstNumber)
+ self._conn.session.backend.dial(contactNumber)
streamId = 0
streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
+ @gtk_toolbox.log_exception(_moduleLogger)
def GetCallStates(self):
"""
For org.freedesktop.Telepathy.Channel.Interface.CallState
import telepathy
+import gtk_toolbox
import handle
telepathy.server.ChannelTypeText.__init__(self, connection, h)
self._nextRecievedId = 0
- handles = []
- # @todo Populate participants
- self.MembersChanged('', handles, [], [], [],
- 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
+ self._otherHandle = h
+ handles = [h]
+ #self.MembersChanged('', handles, [], [], [],
+ # 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
+ @gtk_toolbox.log_exception(_moduleLogger)
def Send(self, messageType, text):
if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
- raise telepathy.NotImplemented("Unhandled message type")
- # @todo implement sending message
+ raise telepathy.NotImplemented("Unhandled message type: %r" % messageType)
+
+ self._conn.session.backend.send_sms(self._otherHandle.phoneNumber, text)
+
self.Sent(int(time.time()), messageType, text)
+ @gtk_toolbox.log_exception(_moduleLogger)
def Close(self):
telepathy.server.ChannelTypeText.Close(self)
self.remove_from_connection()
raise telepathy.NotImplemented("Only Contacts are allowed")
_moduleLogger.debug("Requesting new text channel")
- chan = channel.text.TextChannel(self._connRef(), None)
+ chan = channel.text.TextChannel(self._connRef(), handle)
self._textChannels[handle] = chan
self._connRef().add_channel(chan, handle, suppress_handler)
return chan
raise telepathy.NotImplemented("Using deprecated means to create a call")
_moduleLogger.debug("Requesting new call channel")
- chan = channel.call.CallChannel(self._connRef())
+ chan = channel.call.CallChannel(self._connRef(), handle)
self._callChannels[handle] = chan
self._connRef().add_channel(chan, handle, suppress_handler)
return chan
import telepathy
import constants
+import gtk_toolbox
import gvoice
import handle
import channel_manager
self.check_handle(handleType, handleId)
return self._handles[handleType, handleId]
+ @gtk_toolbox.log_exception(_moduleLogger)
def Connect(self):
"""
For org.freedesktop.telepathy.Connection
telepathy.CONNECTION_STATUS_REASON_REQUESTED
)
+ @gtk_toolbox.log_exception(_moduleLogger)
def Disconnect(self):
"""
For org.freedesktop.telepathy.Connection
telepathy.CONNECTION_STATUS_REASON_REQUESTED
)
+ @gtk_toolbox.log_exception(_moduleLogger)
def RequestChannel(self, type, handleType, handleId, suppressHandler):
"""
For org.freedesktop.telepathy.Connection
channel = channelManager.channel_for_list(handle, suppressHandler)
elif type == telepathy.CHANNEL_TYPE_TEXT:
_moduleLogger.info("RequestChannel Text")
- channel = channelManager.channel_for_text(handle, None, suppressHandler)
+ channel = channelManager.channel_for_text(handle, suppressHandler)
elif type == telepathy.CHANNEL_TYPE_STREAMED_MEDIA:
_moduleLogger.info("RequestChannel Media")
- channel = channelManager.channel_for_text(handle, None, suppressHandler)
+ channel = channelManager.channel_for_call(handle, suppressHandler)
else:
raise telepathy.NotImplemented("unknown channel type %s" % type)
_moduleLogger.info("RequestChannel Object Path: %s" % channel._object_path)
return channel._object_path
+ @gtk_toolbox.log_exception(_moduleLogger)
def RequestHandles(self, handleType, names, sender):
"""
For org.freedesktop.telepathy.Connection
"""
@todo Determine if nay of this is really needed
"""
- requestedContactId, requestedContactName = handle.ContactHandle.from_handle_name(
+ requestedContactId, requestedContactNumber = handle.ContactHandle.from_handle_name(
requestedHandleName
)
- h = handle.create_handle(self, 'contact', requestedContactId, requestedHandleName)
+ h = handle.create_handle(self, 'contact', requestedContactId, requestedContactNumber)
return h
def _on_invite_text(self, contactId):
import telepathy
import constants
+import gtk_toolbox
import connection
self._on_shutdown = shutdown_func
_moduleLogger.info("Connection manager created")
+ @gtk_toolbox.log_exception(_moduleLogger)
def GetParameters(self, proto):
"""
For org.freedesktop.telepathy.ConnectionManager
return func(*args, **kwds)
except Exception:
logger.exception(func.__name__)
+ raise
return wrapper
- return log_exception_decorator
\ No newline at end of file
+ return log_exception_decorator
@staticmethod
def from_handle_name(handleName):
- parts = handleName.split("#")
- assert len(parts) == 2
- contactId, contactNumber = parts[0:2]
+ parts = handleName.split("#", 1)
+ if len(parts) == 2:
+ contactId, contactNumber = parts[0:2]
+ elif len(parts) == 1:
+ contactId, contactNumber = "", handleName
+ else:
+ raise RuntimeError("Invalid handle: %s" % handleName)
+
+ contactNumber = strip_number(contactNumber)
return contactId, contactNumber
@staticmethod
return self._contactId
@property
+ def phoneNumber(self):
+ return self._phoneNumber
+
+ @property
def contactDetails(self):
return self._conn.addressbook.get_contact_details(self._id)
import telepathy
+import gtk_toolbox
+
_moduleLogger = logging.getLogger("simple_presence")
"""
raise NotImplementedError()
+ @gtk_toolbox.log_exception(_moduleLogger)
def GetPresences(self, contacts):
"""
@todo Figure out how to know when its self and get whether busy or not
presences[handle] = (presenceType, presence, personalMessage)
return presences
+ @gtk_toolbox.log_exception(_moduleLogger)
def SetPresence(self, status, message):
if message:
raise telepathy.errors.InvalidArgument