account.py 3.42 KB
Newer Older
1 2 3 4 5

"""Blink account settings extensions."""

__all__ = ['AccountExtension', 'BonjourAccountExtension']

6
from sipsimple.account import BonjourMSRPSettings, MessageSummarySettings, MSRPSettings, PresenceSettings, RTPSettings, SIPSettings, TLSSettings, XCAPSettings
7
from sipsimple.configuration import Setting, SettingsGroup, SettingsObjectExtension, RuntimeSetting
Dan Pascu's avatar
Dan Pascu committed
8
from sipsimple.configuration.datatypes import AudioCodecList, Hostname, MSRPConnectionModel, MSRPTransport, NonNegativeInteger, SIPTransportList, VideoCodecList
9
from sipsimple.util import user_info
10

11 12
from blink.configuration.datatypes import ApplicationDataPath, HTTPURL, IconDescriptor, SoundFile
from blink.resources import Resources
13 14


Dan Pascu's avatar
Dan Pascu committed
15
class BonjourMSRPSettingsExtension(BonjourMSRPSettings):
16
    transport = Setting(type=MSRPTransport, default='tls')
Dan Pascu's avatar
Dan Pascu committed
17 18 19 20 21 22 23 24 25 26 27 28


class BonjourSIPSettings(SettingsGroup):
    transport_order = Setting(type=SIPTransportList, default=SIPTransportList(['tcp', 'udp', 'tls']))


class MessageSummarySettingsExtension(MessageSummarySettings):
    enabled = Setting(type=bool, default=True)


class MSRPSettingsExtension(MSRPSettings):
    connection_model = Setting(type=MSRPConnectionModel, default='relay')
29
    transport = Setting(type=MSRPTransport, default='tls')
Dan Pascu's avatar
Dan Pascu committed
30 31


32 33 34 35
class PresenceSettingsExtension(PresenceSettings):
    enabled = Setting(type=bool, default=True)


36
class PSTNSettings(SettingsGroup):
37
    idd_prefix = Setting(type=unicode, default=None, nillable=True)
38
    prefix = Setting(type=unicode, default=None, nillable=True)
39 40


41
class RTPSettingsExtension(RTPSettings):
Dan Pascu's avatar
Dan Pascu committed
42
    audio_codec_order = Setting(type=AudioCodecList, default=None, nillable=True)
Dan Pascu's avatar
Dan Pascu committed
43
    video_codec_order = Setting(type=VideoCodecList, default=None, nillable=True)
44
    inband_dtmf = Setting(type=bool, default=True)
Dan Pascu's avatar
Dan Pascu committed
45 46 47 48 49


class SIPSettingsExtension(SIPSettings):
    always_use_my_proxy = Setting(type=bool, default=True)
    register = Setting(type=bool, default=True)
50 51 52
    register_interval = Setting(type=NonNegativeInteger, default=600)
    subscribe_interval = Setting(type=NonNegativeInteger, default=600)
    publish_interval = Setting(type=NonNegativeInteger, default=600)
53 54


55
class ServerSettings(SettingsGroup):
56
    conference_server = Setting(type=Hostname, default=None, nillable=True)
57 58 59
    settings_url = Setting(type=HTTPURL, default=None, nillable=True)


60
class SoundSettings(SettingsGroup):
61
    inbound_ringtone = Setting(type=SoundFile, default=None, nillable=True)
62 63


64
class TLSSettingsExtension(TLSSettings):
65
    certificate = Setting(type=ApplicationDataPath, default=ApplicationDataPath(Resources.get('tls/default.crt')), nillable=True)
66 67


Dan Pascu's avatar
Dan Pascu committed
68 69
class XCAPSettingsExtension(XCAPSettings):
    enabled = Setting(type=bool, default=True)
70
    icon = RuntimeSetting(type=IconDescriptor, nillable=True, default=None)
Dan Pascu's avatar
Dan Pascu committed
71 72


73
class AccountExtension(SettingsObjectExtension):
74
    display_name = Setting(type=unicode, default=user_info.fullname, nillable=True)
Dan Pascu's avatar
Dan Pascu committed
75 76
    message_summary = MessageSummarySettingsExtension
    msrp = MSRPSettingsExtension
Dan Pascu's avatar
Dan Pascu committed
77
    pstn = PSTNSettings
78
    presence = PresenceSettingsExtension
79
    rtp = RTPSettingsExtension
80
    server = ServerSettings
Dan Pascu's avatar
Dan Pascu committed
81
    sip = SIPSettingsExtension
82
    sounds = SoundSettings
83
    tls = TLSSettingsExtension
Dan Pascu's avatar
Dan Pascu committed
84
    xcap = XCAPSettingsExtension
85 86 87


class BonjourAccountExtension(SettingsObjectExtension):
Dan Pascu's avatar
Dan Pascu committed
88
    msrp = BonjourMSRPSettingsExtension
89
    presence = PresenceSettingsExtension
90
    rtp = RTPSettingsExtension
Dan Pascu's avatar
Dan Pascu committed
91 92
    sip = BonjourSIPSettings
    sounds = SoundSettings
93
    tls = TLSSettingsExtension
94

Dan Pascu's avatar
Dan Pascu committed
95