summaryrefslogtreecommitdiff
path: root/sunshine/capabilities.py
blob: 4b1e52992e406597f4e2ed6c4e54b87215e1201f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# telepathy-sunshine is the GaduGadu connection manager for Telepathy
#
# Copyright (C) 2009 Collabora Ltd.
# Copyright (C) 2010 Krzysztof Klinikowski <kkszysiu@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import logging
import dbus

import telepathy

from sunshine.handle import SunshineHandleFactory

__all__ = ['SunshineCapabilities']

logger = logging.getLogger('Sunshine.Capabilities')

class SunshineCapabilities(telepathy.server.ConnectionInterfaceCapabilities):

    def __init__(self):
        telepathy.server.ConnectionInterfaceCapabilities.__init__(self)
#        papyon.event.ContactEventInterface.__init__(self, self.msn_client)
        dbus_interface = telepathy.CONNECTION_INTERFACE_CAPABILITIES

    def AdvertiseCapabilities(self, add, remove):
#        for caps, specs in add:
#            if caps == telepathy.CHANNEL_TYPE_STREAMED_MEDIA:
#                if specs & telepathy.CHANNEL_MEDIA_CAPABILITY_VIDEO:
#                    self._self_handle.profile.client_id.has_webcam = True
#                    self._self_handle.profile.client_id.supports_rtc_video = True
#        for caps in remove:
#            if caps == telepathy.CHANNEL_TYPE_STREAMED_MEDIA:
#                self._self_handle.profile.client_id.has_webcam = False

        return telepathy.server.ConnectionInterfaceCapabilities.\
            AdvertiseCapabilities(self, add, remove)

#    # papyon.event.ContactEventInterface
#    def on_contact_client_capabilities_changed(self, contact):
#        self._update_capabilities(contact)
#
#    def _update_capabilities(self, contact):
#        handle = ButterflyHandleFactory(self, 'contact',
#                contact.account, contact.network_id)
#        ctype = telepathy.CHANNEL_TYPE_STREAMED_MEDIA
#
#        new_gen, new_spec = self._get_capabilities(contact)
#        if handle in self._caps:
#            old_gen, old_spec = self._caps[handle][ctype]
#        else:
#            old_gen = 0
#            old_spec = 0
#
#        if old_gen == new_gen and old_spec == new_spec:
#            return
#
#        diff = (int(handle), ctype, old_gen, new_gen, old_spec, new_spec)
#        self.CapabilitiesChanged([diff])
#
    def _get_capabilities(self, contact):
        gen_caps = 0
        spec_caps = 0

        caps = contact.client_capabilities
        #if caps.supports_sip_invite:
        #    gen_caps |= telepathy.CONNECTION_CAPABILITY_FLAG_CREATE
        #    gen_caps |= telepathy.CONNECTION_CAPABILITY_FLAG_INVITE
        #    spec_caps |= telepathy.CHANNEL_MEDIA_CAPABILITY_AUDIO
        #    spec_caps |= telepathy.CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_STUN
        #
        #    if caps.has_webcam:
        #        spec_caps |= telepathy.CHANNEL_MEDIA_CAPABILITY_VIDEO

        return gen_caps, spec_caps