示例#1
0
 /// <summary>
 ///     SIP constructor taking an instance of the SipServerParameter class as it's parameter
 /// </summary>
 /// <param name="sipParameters">Instance of the SipServerParameter class</param>
 /// <remarks>
 ///     Use this constructor if you will be regularly accessing and/or changing your SIP server parameters in your application.
 /// </remarks>
 public SipConnection(SipServerParameters sipParameters)
 {
     this.sip.ip           = sipParameters.ip;
     this.sip.port         = sipParameters.port;
     this.sip.username     = sipParameters.username;
     this.sip.password     = sipParameters.password;
     this.sip.extra_number = sipParameters.extra_number;
 }
示例#2
0
 /// <summary>
 ///     Test whether an instance of an unconstructed SIP class is able to communicate with the server.  Use this for on-the-fly tests of SIP parameters.
 /// </summary>
 /// <param name="sipParameters">Instance of the SipServerParameter class</param>
 /// <returns>Returns true if connection is viable.</returns>
 public bool TestConnection(SipServerParameters sipParameters)
 {
     this.sip.ip           = sipParameters.ip;
     this.sip.port         = sipParameters.port;
     this.sip.username     = sipParameters.username;
     this.sip.password     = sipParameters.password;
     this.sip.extra_number = sipParameters.extra_number;
     Open();
     Close();
     return(connected);
 }
示例#3
0
 /// <summary>
 ///     Test whether an instance of an unconstructed SIP class is able to communicate with the server.  Use this for on-the-fly tests of SIP parameters.
 /// </summary>
 /// <param name="sipParameters">Instance of the SipServerParameter class</param>
 /// <returns>Returns true if connection is viable.</returns>
 public bool TestConnection(SipServerParameters sipParameters)
 {
     this.sip.ip = sipParameters.ip;
     this.sip.port = sipParameters.port;
     this.sip.username = sipParameters.username;
     this.sip.password = sipParameters.password;
     this.sip.extra_number = sipParameters.extra_number;
     Open();
     Close();
     return connected;
 }
示例#4
0
 /// <summary>
 ///     SIP constructor taking an instance of the SipServerParameter class as it's parameter
 /// </summary>
 /// <param name="sipParameters">Instance of the SipServerParameter class</param>
 /// <remarks>
 ///     Use this constructor if you will be regularly accessing and/or changing your SIP server parameters in your application.
 /// </remarks>
 public SipConnection(SipServerParameters sipParameters)
 {
     this.sip.ip = sipParameters.ip;
     this.sip.port = sipParameters.port;
     this.sip.username = sipParameters.username;
     this.sip.password = sipParameters.password;
     this.sip.extra_number = sipParameters.extra_number;
 }
        private void btnSubmitSIP_Click(object sender, EventArgs e)
        {
            Button ButtonDown = (Button)sender;
            if (chkSipEnabled.Checked)
            {
                if (AllBoxesFilledIn(ButtonDown.Parent))
                {
                    SipServerParameters SipParams = new SipServerParameters();
                    SipParams.ip = txtSipIP1.Text + "." + txtSipIP2.Text + "." + txtSipIP3.Text + "." + txtSipIP4.Text;
                    SipParams.port = txtSipPort.Text;
                    SipParams.username = txtSipUsername.Text;
                    SipParams.password = txtSipPassword.Text;
                    SipParams.extra_number = txtSipExtraNumber.Text;
                    try
                    {
                        using (SipConnection sip = new SipConnection(SipParams))
                        {
                            try
                            {
                                if (sip.TestConnection())
                                {
                                    ServerData.SipIP = SipParams.ip;
                                    ServerData.SipPort = SipParams.port;
                                    ServerData.SipUsername = SipParams.username;
                                    ServerData.SipPassword = SipParams.password;
                                    ServerData.SipExtraNumber = SipParams.extra_number;
                                    ServerData.SipEnabled = chkSipEnabled.Checked;
                                    HideAndDisplay(ButtonDown);
                                }
                                else
                                {
                                    MessageBox.Show("Could not connect to the SIP server!  If you do not wish to enter your SIP settings now, remove the checkmark for 'enabled'. You can reeanable SIP and add your credentials later through the administration interface.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + ".  If you do not wish to enter your SIP settings now, remove the checkmark for 'enabled'. You can reeanable SIP and add your credentials later through the administration interface.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                         }
                    }
                    catch (Exception) { }
                }
            }
            else
            {
                DialogResult diag = MessageBox.Show("You have chosen to disable SIP.  Are you sure?  SIP can be reenabled later through the administrator interface.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (diag == DialogResult.Yes)
                {
                    ServerData.SipIP = "0.0.0.0";
                    ServerData.SipPort = "6001";
                    ServerData.SipUsername = "******";
                    ServerData.SipPassword = "******";
                    ServerData.SipExtraNumber = "1";
                    ServerData.SipEnabled = chkSipEnabled.Checked;
                    HideAndDisplay(ButtonDown);
                }
            }
        }