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 @@ ...@@ -5,16 +5,22 @@
__all__ = ['AccountExtension', 'BonjourAccountExtension'] __all__ = ['AccountExtension', 'BonjourAccountExtension']
from sipsimple.account import PSTNSettings
from sipsimple.configuration import Setting, SettingsGroup, SettingsObjectExtension from sipsimple.configuration import Setting, SettingsGroup, SettingsObjectExtension
from blink.configuration.datatypes import CustomSoundFile, DefaultPath from blink.configuration.datatypes import CustomSoundFile, DefaultPath
class PSTNSettingsExtension(PSTNSettings):
idd_prefix = Setting(type=unicode, default=None, nillable=True)
class SoundSettings(SettingsGroup): class SoundSettings(SettingsGroup):
inbound_ringtone = Setting(type=CustomSoundFile, default=CustomSoundFile(DefaultPath), nillable=True) inbound_ringtone = Setting(type=CustomSoundFile, default=CustomSoundFile(DefaultPath), nillable=True)
class AccountExtension(SettingsObjectExtension): class AccountExtension(SettingsObjectExtension):
pstn = PSTNSettingsExtension
sounds = SoundSettings sounds = SoundSettings
......
...@@ -1770,6 +1770,8 @@ class SessionManager(object): ...@@ -1770,6 +1770,8 @@ class SessionManager(object):
@staticmethod @staticmethod
def create_uri(account, address): def create_uri(account, address):
address = re.sub(r'\(\s?0\s?\)|[-() ]', '', 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:'): if not address.startswith('sip:') and not address.startswith('sips:'):
address = 'sip:' + address address = 'sip:' + address
if '@' not in 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