Commit 3941ad34 authored by Luci Stanescu's avatar Luci Stanescu

Added account.pstn.idd_prefix setting and made use of it

parent 0ff3e1a9
......@@ -5,16 +5,22 @@
__all__ = ['AccountExtension', 'BonjourAccountExtension']
from sipsimple.account import PSTNSettings
from sipsimple.configuration import Setting, SettingsGroup, SettingsObjectExtension
from blink.configuration.datatypes import CustomSoundFile, DefaultPath
class PSTNSettingsExtension(PSTNSettings):
idd_prefix = Setting(type=unicode, default=None, nillable=True)
class SoundSettings(SettingsGroup):
inbound_ringtone = Setting(type=CustomSoundFile, default=CustomSoundFile(DefaultPath), nillable=True)
class AccountExtension(SettingsObjectExtension):
pstn = PSTNSettingsExtension
sounds = SoundSettings
......
......@@ -1770,6 +1770,8 @@ class SessionManager(object):
@staticmethod
def create_uri(account, address):
address = re.sub(r'\(\s?0\s?\)|[-() ]', '', address)
if isinstance(account, Account) and account.pstn.idd_prefix is not None:
address = re.sub(r'^\+', account.pstn.idd_prefix, address)
if not address.startswith('sip:') and not address.startswith('sips:'):
address = 'sip:' + address
if '@' not in address:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment