/// <summary> /// Initializes a new instance of the <see cref="Deflect"/> class. /// </summary> /// <param name="id">Channel id</param> /// <param name="address">Sip address to deflect to</param> public Deflect(UniqueId id, SipAddress address) { if (id == null) throw new ArgumentNullException("id"); if (address == null) throw new ArgumentNullException("address"); _id = id; _address = address; }
/// <summary> /// Initializes a new instance of the <see cref="Deflect"/> class. /// </summary> /// <param name="id">Channel id</param> /// <param name="address">Sip address to deflect to</param> public Deflect(UniqueId id, SipAddress address) { if (id == null) { throw new ArgumentNullException("id"); } if (address == null) { throw new ArgumentNullException("address"); } _id = id; _address = address; }
protected SipRequest CreateRequest(string method) { /*create the 'INVITE' message*/ SipAddressFactory addressFactory = _stack.CreateAddressFactory(); SipHeaderFactory headerFactory = _stack.CreateHeaderFactory(); SipMessageFactory messageFactory = _stack.CreateMessageFactory(); SipUri senderSipUri = addressFactory.CreateUri(string.Empty, new IPEndPoint(_ipAddress, 12345).ToString()); SipAddress senderSipAddress = addressFactory.CreateAddress(string.Empty, senderSipUri); SipUri receiverSipUri = addressFactory.CreateUri(string.Empty, new IPEndPoint(_ipAddress, 23456).ToString()); SipAddress receiverSipAddress = addressFactory.CreateAddress(string.Empty, senderSipUri); SipToHeader toHeader = headerFactory.CreateToHeader(receiverSipAddress); SipFromHeader fromHeader = headerFactory.CreateFromHeader(senderSipAddress, SipUtil.CreateTag()); SipCSeqHeader cseqHeader = headerFactory.CreateSCeqHeader(method, 1); SipCallIdHeader callIdheader = headerFactory.CreateCallIdHeader(SipUtil.CreateCallId()); SipViaHeader viaHeader = headerFactory.CreateViaHeader(_ipAddress, 12345, SipConstants.Udp, SipUtil.CreateBranch()); SipMaxForwardsHeader maxForwardsHeader = headerFactory.CreateMaxForwardsHeader(); SipRequest request = messageFactory.CreateRequest( receiverSipUri, method, callIdheader, cseqHeader, fromHeader, toHeader, viaHeader, maxForwardsHeader); if (method == SipMethods.Invite) { SipContactHeader contactHeader = headerFactory.CreateContactHeader(senderSipUri); request.Contacts.Add(contactHeader); } return(request); }
/// <summary> /// Initializes a new instance of the <see cref="SofiaSipAddress"/> class. /// </summary> /// <param name="address">Another address.</param> public SofiaSipAddress(SipAddress address) { _profileName = address.Domain; Extension = address.Extension; }
private void UpdateUserButton_Click(object sender, RoutedEventArgs e) { bool IsSipAddressChanged = false, // IsRegistrarPoolChanged = false, IsLineURIChanged = false, IsEnterpriseVoiceEnabledChanged = false, IsHostedVoicemailChanged = false, IsConferencingPolicyChanged = false, IsVoicePolicyChanged = false, IsExternalAccessPolicyChanged = false, IsHostedVoicemailPolicyChanged = false, IsMobilityPolicyChanged = false; string ChangedAttr = ""; //check which attributes have been changed if (SipAddressTextBox.Text != (String.IsNullOrEmpty(SipAddress) ? SipAddress : SipAddress.Remove(0, 4))) { ChangedAttr += "\nSip address from " + SipAddress + " to sip:" + SipAddressTextBox.Text + "\n"; IsSipAddressChanged = true; } //if (RegistrarPoolTextBlock.Text == RegistrarPool); if (LineURITextBox.Text != (String.IsNullOrEmpty(LineURI) ? LineURI : LineURI.Remove(0, 4))) { ChangedAttr += "\nLine URI from " + LineURI + " to tel:" + LineURITextBox.Text + "\n"; IsLineURIChanged = true; } if (EnterpriseVoiceEnabledCheckBox.IsChecked != EnterpriseVoiceEnabled) { ChangedAttr += "\nEV Enabled from " + EnterpriseVoiceEnabled.ToString() + " to " + EnterpriseVoiceEnabledCheckBox.IsChecked.ToString() + "\n"; IsEnterpriseVoiceEnabledChanged = true; } if (HostedVoicemailCheckBox.IsChecked != HostedVoicemail) { ChangedAttr += "\nHosted VM enabled from " + HostedVoicemail.ToString() + " to " + HostedVoicemailCheckBox.IsChecked.ToString() + "\n"; IsHostedVoicemailChanged = true; } //check conf pol if (ConferencingPolicyComboBox.SelectedValue != UserPolicies["ConferencingPolicy"]) { ChangedAttr += "\nConf policy from " + UserPolicies["ConferencingPolicy"] + " to " + ConferencingPolicyComboBox.SelectedValue + "\n"; IsConferencingPolicyChanged = true; } //voice pol if (VoicePolicyComboBox.SelectedValue != UserPolicies["VoicePolicy"]) { ChangedAttr += "\nVoice policy from " + UserPolicies["VoicePolicy"] + " to " + VoicePolicyComboBox.SelectedValue + "\n"; IsVoicePolicyChanged = true; } //ExternalAccess if (ExternalAccessPolicyComboBox.SelectedValue != UserPolicies["ExternalAccessPolicy"]) { ChangedAttr += "\nExternal Access policy from " + UserPolicies["ExternalAccessPolicy"] + " to " + ExternalAccessPolicyComboBox.SelectedValue + "\n"; IsExternalAccessPolicyChanged = true; } //HostedVM if (HostedVoicemailPolicyComboBox.SelectedValue != UserPolicies["HostedVoicemailPolicy"]) { ChangedAttr += "\nHosted VM policy from " + UserPolicies["HostedVoicemailPolicy"] + " to " + HostedVoicemailPolicyComboBox.SelectedValue + "\n"; IsHostedVoicemailPolicyChanged = true; } //mobility pol if (MobilityPolicyComboBox.SelectedValue != UserPolicies["MobilityPolicy"]) { ChangedAttr += "\nMobility policy from " + UserPolicies["MobilityPolicy"] + " to " + MobilityPolicyComboBox.SelectedValue + "\n"; IsMobilityPolicyChanged = true; } //start dialog if any of attributes were changed if (IsSipAddressChanged || IsLineURIChanged || IsEnterpriseVoiceEnabledChanged || IsHostedVoicemailChanged || IsConferencingPolicyChanged || IsVoicePolicyChanged || IsExternalAccessPolicyChanged || IsHostedVoicemailPolicyChanged || IsMobilityPolicyChanged) { //if confirmed, run set-csuser and\ or grant policies if (MessageBox.Show("Do you really want to change following attributes for the " + SipAddress + " user? (if Global or Site: policies are chosen, the user " + "will be granted with automatic policy)\n" + ChangedAttr, "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.No) == MessageBoxResult.Yes) { if (IsSipAddressChanged) { Collection <PSObject> result = new Collection <PSObject>(); result = PSExecute("Set-CsUser -Identity '" + Identity + "'" + " -SipAddress 'sip:" + SipAddressTextBox.Text + "'"); if (result != null) { AppendMainText("\nsip address changed\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsLineURIChanged) { string NewLineURI; //if lineuri string is empty, set argument as $null if (String.IsNullOrEmpty(LineURITextBox.Text)) { NewLineURI = "$null"; } else { NewLineURI = "'tel:" + LineURITextBox.Text + "'"; } Collection <PSObject> result = new Collection <PSObject>(); result = PSExecute("Set-CsUser -Identity '" + Identity + "'" + "-LineURI " + NewLineURI); if (result != null) { AppendMainText("\nLineURI changed\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsEnterpriseVoiceEnabledChanged) { Collection <PSObject> result = new Collection <PSObject>(); result = PSExecute("Set-CsUser -Identity '" + Identity + "'" + " -EnterpriseVoiceEnabled $" + (!EnterpriseVoiceEnabled).ToString()); if (result != null) { AppendMainText("\nEV changed\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsHostedVoicemailChanged) { Collection <PSObject> result = new Collection <PSObject>(); result = PSExecute("Set-CsUser -Identity '" + Identity + "'" + " -HostedVoicemail $" + (!HostedVoicemail).ToString()); if (result != null) { AppendMainText("\nHosted VM enabled changed\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsConferencingPolicyChanged) { Collection <PSObject> result = new Collection <PSObject>(); //for Global and Site policies use $null for automatical assigment if (ConferencingPolicyComboBox.SelectedValue.ToString() != "Global" && !(ConferencingPolicyComboBox.SelectedValue.ToString().StartsWith("Site:"))) { result = PSExecute("Grant-CsConferencingPolicy -Identity '" + Identity + "'" + " -PolicyName '" + ConferencingPolicyComboBox.SelectedValue + "'"); } else { result = PSExecute("Grant-CsConferencingPolicy -Identity '" + Identity + "'" + " -PolicyName $null"); } if (result != null) { AppendMainText("\nNew Conferencing Policy granted\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsVoicePolicyChanged) { Collection <PSObject> result = new Collection <PSObject>(); //for Global and Site policies use $null for automatical assigment if (VoicePolicyComboBox.SelectedValue.ToString() != "Global" && !(VoicePolicyComboBox.SelectedValue.ToString().StartsWith("Site:"))) { result = PSExecute("Grant-CsVoicePolicy -Identity '" + Identity + "'" + " -PolicyName '" + VoicePolicyComboBox.SelectedValue + "'"); } else { result = PSExecute("Grant-CsVoicePolicy -Identity '" + Identity + "'" + " -PolicyName $null"); } if (result != null) { AppendMainText("\nNew Voice Policy granted\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsExternalAccessPolicyChanged) { Collection <PSObject> result = new Collection <PSObject>(); //for Global and Site policies use $null for automatical assigment if (ExternalAccessPolicyComboBox.SelectedValue.ToString() != "Global" && !(ExternalAccessPolicyComboBox.SelectedValue.ToString().StartsWith("Site:"))) { result = PSExecute("Grant-CsExternalAccessPolicy -Identity '" + Identity + "'" + " -PolicyName '" + ExternalAccessPolicyComboBox.SelectedValue + "'"); } else { result = PSExecute("Grant-CsExternalAccessPolicy -Identity '" + Identity + "'" + " -PolicyName $null"); } if (result != null) { AppendMainText("\nNew External Access Policy granted\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsHostedVoicemailPolicyChanged) { Collection <PSObject> result = new Collection <PSObject>(); //for Global and Site policies use $null for automatical assigment if (HostedVoicemailPolicyComboBox.SelectedValue.ToString() != "Global" && !(HostedVoicemailPolicyComboBox.SelectedValue.ToString().StartsWith("Site:"))) { result = PSExecute("Grant-CsHostedVoicemailPolicy -Identity '" + Identity + "'" + " -PolicyName '" + HostedVoicemailPolicyComboBox.SelectedValue + "'"); } else { result = PSExecute("Grant-CsHostedVoicemailPolicy -Identity '" + Identity + "'" + " -PolicyName $null"); } if (result != null) { AppendMainText("\nNew Hosted Voicemail Policy granted\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } if (IsMobilityPolicyChanged) { Collection <PSObject> result = new Collection <PSObject>(); //for Global and Site policies use $null for automatical assigment if (MobilityPolicyComboBox.SelectedValue.ToString() != "Global" && !(MobilityPolicyComboBox.SelectedValue.ToString().StartsWith("Site:"))) { result = PSExecute("Grant-CsMobilityPolicy -Identity '" + Identity + "'" + " -PolicyName '" + MobilityPolicyComboBox.SelectedValue + "'"); } else { result = PSExecute("Grant-CsMobilityPolicy -Identity '" + Identity + "'" + " -PolicyName $null"); } if (result != null) { AppendMainText("\nNew Mobility Policy granted\n"); } else { AppendMainText("\nThe error occured, please find the error details above, try again\n"); } } } //disable Update Button until next user will be found UpdateButton("UpdateUserButton", false, "Search again"); } else { MessageBox.Show("None of attributes were changed", "Nothing to change", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); } }
private void UpdateUIwithUserAttributes() { //remove "sip:" prefix if the string isnt empty SipAddressTextBox.Text = String.IsNullOrEmpty(SipAddress) ? SipAddress : SipAddress.Remove(0, 4); RegistrarPoolTextBlock.Text = RegistrarPool; //remove "tel:" prefix if the string isnt empty LineURITextBox.Text = String.IsNullOrEmpty(LineURI) ? LineURI : LineURI.Remove(0, 4); EnterpriseVoiceEnabledCheckBox.IsChecked = EnterpriseVoiceEnabled; HostedVoicemailCheckBox.IsChecked = HostedVoicemail; if (UserPolicies != null) { //select effective policies for current user in the comboboxes ConferencingPolicyComboBox.SelectedValue = UserPolicies["ConferencingPolicy"]; VoicePolicyComboBox.SelectedValue = UserPolicies["VoicePolicy"]; ExternalAccessPolicyComboBox.SelectedValue = UserPolicies["ExternalAccessPolicy"]; HostedVoicemailPolicyComboBox.SelectedValue = UserPolicies["HostedVoicemailPolicy"]; MobilityPolicyComboBox.SelectedValue = UserPolicies["MobilityPolicy"]; } //select first value in comboboxes if the user policies are empty else { ConferencingPolicyComboBox.SelectedIndex = 0; VoicePolicyComboBox.SelectedIndex = 0; ExternalAccessPolicyComboBox.SelectedIndex = 0; HostedVoicemailPolicyComboBox.SelectedIndex = 0; MobilityPolicyComboBox.SelectedIndex = 0; } }