X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fcapabilities.py;h=34872a650c35508880c062c1c44fd42bbdad8246;hp=6c7ba15e5efe9d6aa264d1f2d866ceb90f6153c5;hb=dba615444b6e0d9a1773478a0acc0ce58fc5eeeb;hpb=a840b976430685dbf23bee4e590d1ee23594728c diff --git a/src/capabilities.py b/src/capabilities.py index 6c7ba15..34872a6 100644 --- a/src/capabilities.py +++ b/src/capabilities.py @@ -1,6 +1,9 @@ import logging +import telepathy + import tp +import gtk_toolbox _moduleLogger = logging.getLogger('capabilities') @@ -8,4 +11,35 @@ _moduleLogger = logging.getLogger('capabilities') class CapabilitiesMixin(tp.ConnectionInterfaceCapabilities): - pass + _CAPABILITIES = { + telepathy.CHANNEL_TYPE_TEXT: ( + telepathy.CONNECTION_CAPABILITY_FLAG_CREATE, + 0, + ), + telepathy.CHANNEL_TYPE_STREAMED_MEDIA: ( + telepathy.CONNECTION_CAPABILITY_FLAG_CREATE | + telepathy.CONNECTION_CAPABILITY_FLAG_INVITE, + telepathy.CHANNEL_MEDIA_CAPABILITY_AUDIO, + ), + } + + def __init__(self): + tp.ConnectionInterfaceCapabilities.__init__(self) + + def get_handle_by_id(self, handleType, handleId): + """ + @abstract + """ + raise NotImplementedError("Abstract function called") + + @gtk_toolbox.log_exception(_moduleLogger) + def GetCapabilities(self, handleIds): + ret = [] + for handleId in handleIds: + if handleId != 0 and (telepathy.HANDLE_TYPE_CONTACT, handleId) not in self._handles: + raise telepathy.errors.InvalidHandle + + h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, handleId) + for type, (gen, spec) in self._CAPABILITIES.iteritems(): + ret.append([handleId, type, gen, spec]) + return ret