public SensipConfigurator() { accList = new List <IAccount>(); for (int i = 0; i < Properties.Settings.Default.cfgSipAccountUsername.Count; i++) { IAccount account = new SensipAccount(i); accList.Add(account); account.HostName = Properties.Settings.Default.cfgSipAccountAddresses[i]; account.ProxyAddress = Properties.Settings.Default.cfgSipAccountProxyAddresses[i]; account.AccountName = Properties.Settings.Default.cfgSipAccountNames[i]; account.DisplayName = Properties.Settings.Default.cfgSipAccountDisplayName[i]; account.Id = Properties.Settings.Default.cfgSipAccountIds[i]; account.UserName = Properties.Settings.Default.cfgSipAccountUsername[i]; account.Password = Properties.Settings.Default.cfgSipAccountPassword[i]; account.DomainName = Properties.Settings.Default.cfgSipAccountDomains[i]; account.TransportMode = 0; account.Picture = Properties.Settings.Default.cfgSipAccountPicture[i]; account.RegState = Int32.Parse(Properties.Settings.Default.cfgSipAccountState[i]); account.Description = Properties.Settings.Default.cfgSipAccountDescription[i]; account.Index = Int32.Parse(Properties.Settings.Default.cfgSipAccountIndex[i]); account.ElemType = Int32.Parse(Properties.Settings.Default.cfgSipAccountElemtype[i]); } }
private bool ApplySettings() { //start verify if ( textBoxRegistrarAddress.Text.Trim() == "" || textBoxUsername.Text.Trim() == "" || textBoxDisplayName.Text.Trim() == "" || textBoxRegistrarAddress.Text.Trim() == "" ) { MessageBox.Show("AccountName, UserName, DisplayName,RegistrarAddress are not allowed to be empty.", "Error"); return(false); } for (int i = 0; i < SensipResources.Configurator.Accounts.Count; i++) { if (i == 0) { continue; } IAccount acc = SensipResources.Configurator.Accounts[i]; if (acc.UserName.Trim() == textBoxUsername.Text.Trim()) { MessageBox.Show("This UserName is already in use.", "Error"); return(false); } if (acc.DisplayName.Trim() == textBoxDisplayName.Text.Trim()) { MessageBox.Show("This DisplayName is already in use.", "Error"); return(false); } } //end verify // IAccount account; if (SensipResources.Configurator.Accounts.Count == 0) { account = new SensipAccount(0); SensipResources.Configurator.Accounts.Add(account); } account = SensipResources.Configurator.Accounts[0]; account.HostName = textBoxRegistrarAddress.Text; account.ProxyAddress = textBoxProxyAddress.Text; account.AccountName = textBoxUsername.Text; account.DisplayName = textBoxDisplayName.Text; account.Id = textBoxUsername.Text; account.UserName = textBoxUsername.Text; account.Password = textBoxPassword.Text; account.DomainName = textBoxDomain.Text; account.TransportMode = (ETransportMode)comboBoxSIPTransport.SelectedIndex; account.Picture = "no picture"; account.RegState = 0; account.Description = "Middleware"; account.Index = 0; account.ElemType = -2; SensipResources.Configurator.DefaultAccountIndex = 0; // Settings SensipResources.Configurator.DNDFlag = checkBoxDND.Checked; SensipResources.Configurator.AAFlag = checkBoxAA.Checked; SensipResources.Configurator.CFUFlag = checkBoxCFU.Checked; SensipResources.Configurator.CFNRFlag = checkBoxCFNR.Checked; SensipResources.Configurator.CFBFlag = checkBoxCFB.Checked; SensipResources.Configurator.CFUNumber = textBoxCFU.Text; SensipResources.Configurator.CFNRNumber = textBoxCFNR.Text; SensipResources.Configurator.CFBNumber = textBoxCFB.Text; // additional settings SensipResources.Configurator.SIPPort = Int16.Parse(textBoxListenPort.Text); SensipResources.Configurator.StunServerAddress = textBoxStunServerAddress.Text; SensipResources.Configurator.PublishEnabled = true; SensipResources.Configurator.Expires = Int32.Parse(textBoxExpires.Text); SensipResources.Configurator.VADEnabled = checkBoxVAD.Checked; SensipResources.Configurator.ECTail = Int32.Parse(textBoxECTail.Text); SensipResources.Configurator.NameServer = textBoxNameServer.Text; ////////////////////////////////////////////////////////////////////////// // skip if stack not initialized if (SensipResources.StackProxy.IsInitialized) { // check if at least 1 codec selected if (listBoxEnCodecs.Items.Count == 0) { (new ErrorDialog("Settings Warning", "No codec selected!")).ShowDialog(); return(false); } // save enabled codec list List <string> cl = new List <string>(); foreach (string item in listBoxEnCodecs.Items) { cl.Add(item); } SensipResources.Configurator.CodecList = cl; } SensipResources.Configurator.Save(); if (SensipResources.StackProxy.IsInitialized) { // set codecs priority... foreach (string item in listBoxDisCodecs.Items) { SensipResources.StackProxy.setCodecPriority(item, 0); } int i = 0; foreach (string item in listBoxEnCodecs.Items) { SensipResources.StackProxy.setCodecPriority(item, 128 - i); i++; } } // reinitialize stack if (RestartRequired) { SensipResources.StackProxy.initialize(); } if (ReregisterRequired) { SensipResources.Registrar.registerAccounts(); } // set device Id SensipResources.StackProxy.setSoundDevice(mMixers.Playback.DeviceDetail.MixerName, mMixers.Recording.DeviceDetail.MixerName); return(true); }