private void btnSetupPassword_Click(object sender, EventArgs e) { Forms.AssignPasswordForm apForm = new CallButler.Manager.Forms.AssignPasswordForm(); if (apForm.ShowDialog(this) == DialogResult.OK) { string hashedPassword = ""; if (apForm.Password.Length > 0) { hashedPassword = WOSI.Utilities.CryptoUtils.CreateMD5Hash(apForm.Password); } ManagementInterfaceClient.ManagementInterface.SetManagementPassword(ManagementInterfaceClient.AuthInfo, hashedPassword); ManagementInterfaceClient.AuthInfo.Password = hashedPassword; if (apForm.SavePassword) { Properties.Settings.Default.ManagementPassword = hashedPassword; Properties.Settings.Default.Save(); ManagementInterfaceClient.Connect(ManagementInterfaceClient.CurrentServer, Properties.Settings.Default.TcpManagementPort, hashedPassword); } } }
private void SaveSettings() { ManagementInterfaceClient.ManagementInterface.AllowRemoteManagement = cbEnableManagement.Checked; ManagementInterfaceClient.ManagementInterface.SMTPFromEmail = txtFromEmailAddress.Text; ManagementInterfaceClient.ManagementInterface.SMTPServer = txtSMTPServer.Text; ManagementInterfaceClient.ManagementInterface.SMTPPort = (int)numSMTPPort.Value; ManagementInterfaceClient.ManagementInterface.SMTPUseSSL = cbSMTPSSL.Checked; ManagementInterfaceClient.ManagementInterface.SMTPUsername = txtSMTPUsername.Text.Trim(); ManagementInterfaceClient.ManagementInterface.SMTPPassword = WOSI.Utilities.CryptoUtils.Encrypt(txtSMTPPassword.Text.Trim(), WOSI.CallButler.Data.Constants.EncryptionPassword); ManagementInterfaceClient.ManagementInterface.LineCount = (int)numLineCount.Value; ManagementInterfaceClient.ManagementInterface.SetSoundVolume(ManagementInterfaceClient.AuthInfo, (byte)trkSoundVolume.Value); ManagementInterfaceClient.ManagementInterface.SetRecordVolume(ManagementInterfaceClient.AuthInfo, (byte)trkRecordVolume.Value); ManagementInterfaceClient.ManagementInterface.SetSpeechVolume(ManagementInterfaceClient.AuthInfo, (byte)trkSpeechVolume.Value); ManagementInterfaceClient.ManagementInterface.SIPPort = (int)numSIPPort.Value; ManagementInterfaceClient.ManagementInterface.UseInternalAddressForSIP = cbUseInternalIPForSIP.Checked; ManagementInterfaceClient.ManagementInterface.EnableSTUN = cbSTUN.Checked; ManagementInterfaceClient.ManagementInterface.STUNServer = txtSTUNServer.Text; ManagementInterfaceClient.ManagementInterface.SetBusyRedirectServer(ManagementInterfaceClient.AuthInfo, txtBusyRedirectServer.Text); ManagementInterfaceClient.ManagementInterface.LogStorage = (WOSI.CallButler.ManagementInterface.LogStorage)cboLogStorage.SelectedIndex; ManagementInterfaceClient.ManagementInterface.LogLevel = (WOSI.CallButler.ManagementInterface.LogLevel)cboLogLevel.SelectedIndex; ManagementInterfaceClient.ManagementInterface.SetSendLogErrorEmail(ManagementInterfaceClient.AuthInfo, cbSendLogErrorEmail.Checked); ManagementInterfaceClient.ManagementInterface.SetLogErrorEmail(ManagementInterfaceClient.AuthInfo, txtLogErrorEmail.Text); ManagementInterfaceClient.ManagementInterface.SetDefaultVoice(ManagementInterfaceClient.AuthInfo, cboDefaultVoice.Text); ManagementInterfaceClient.ManagementInterface.ReportErrors = chkSendErrorReports.Checked; // Check to make sure our management passwords match if (txtManagementPassword.Text != txtManagementConfirmPassword.Text) { MessageBox.Show(this, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_PasswordsDoNotMatch), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_PasswordMismatch), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtManagementPassword.Text = ""; txtManagementConfirmPassword.Text = ""; wizard.PageIndex = 0; txtManagementPassword.Select(); } else if (txtManagementPassword.Text != blankPassword) { string password = txtManagementPassword.Text; ManagementInterfaceClient.ManagementInterface.SetManagementPassword(ManagementInterfaceClient.AuthInfo, password); ManagementInterfaceClient.Connect(ManagementInterfaceClient.CurrentServer, Properties.Settings.Default.TcpManagementPort, password); } // Save audio codec settings List <WOSI.CallButler.ManagementInterface.AudioCodecInformation> audioCodecs = new List <WOSI.CallButler.ManagementInterface.AudioCodecInformation>(); for (int index = 0; index < lbCodecs.Items.Count; index++) { WOSI.CallButler.ManagementInterface.AudioCodecInformation acInfo = (WOSI.CallButler.ManagementInterface.AudioCodecInformation)lbCodecs.Items[index]; acInfo.Enabled = lbCodecs.GetItemChecked(index); audioCodecs.Add(acInfo); } ManagementInterfaceClient.ManagementInterface.SetAudioCodecs(ManagementInterfaceClient.AuthInfo, audioCodecs.ToArray()); Properties.Settings.Default.UpdateNotification = chkNotifyofProductVersions.Checked; btnApply.Enabled = false; btnCancel.Enabled = false; Properties.Settings.Default.Save(); if (requiresRestart) { if (MessageBox.Show(this, "You have changed a setting that requires a restart of the CallButler Service. Would you like to do this now?", "Restart Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CallButler.Manager.Utils.ServiceUtils.RestartCallButlerService(ManagementInterfaceClient.CurrentServer); } requiresRestart = false; //Note: I really hate this, but the only way i can get the IpcChannel restart to work. Blah! string exmsg = ""; int tries = 0; do { try { ManagementInterfaceClient.Connect(ManagementInterfaceClient.CurrentServer, Properties.Settings.Default.TcpManagementPort, Properties.Settings.Default.ManagementPassword); exmsg = ""; } catch (Exception ex) { tries++; if (ex.Message.Equals("Failed to write to an IPC Port: The pipe is being closed.\r\n")) { exmsg = ex.ToString(); } else { throw ex; } } } while (exmsg.Length > 0 && tries < 5); } }