X-Git-Url: http://git.maemo.org/git/?p=theonering;a=blobdiff_plain;f=src%2Fcapabilities.py;h=9657b8b44d831a718cd6c88f87b414303b95d911;hp=6c7ba15e5efe9d6aa264d1f2d866ceb90f6153c5;hb=4a4fcb57119f592b750230807c82ead8a7ab739e;hpb=a840b976430685dbf23bee4e590d1ee23594728c diff --git a/src/capabilities.py b/src/capabilities.py index 6c7ba15..9657b8b 100644 --- a/src/capabilities.py +++ b/src/capabilities.py @@ -1,11 +1,45 @@ import logging +import telepathy + import tp +import util.misc as misc_utils -_moduleLogger = logging.getLogger('capabilities') +_moduleLogger = logging.getLogger(__name__) 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") + + @misc_utils.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