public static AccountConfigValues MapManualChoice( EmailProvider provider, string emailAddress, string password) { AccountConfigValues mappedAccount; try { mappedAccount = new AccountConfigValues(); if (provider.IncomingServers.Count > 0 && provider.OutgoingServers.Count > 0) { mappedAccount.EmailProvider = provider.ID; mappedAccount.Name = provider.DisplayName; mappedAccount.PollingConfig = MapIncomingServer(provider.IncomingServers[0], emailAddress); mappedAccount.PollingConfig.PasswordTrue = password; mappedAccount.SmtpConfig = MapOutgoingServer(provider.OutgoingServers[0], emailAddress); mappedAccount.SmtpConfig.UsePollingCredentials = mappedAccount.PollingConfig.Username == mappedAccount.SmtpConfig.Username; if (!mappedAccount.SmtpConfig.UsePollingCredentials) { mappedAccount.SmtpConfig.PasswordTrue = password; } } } catch (Exception ex) { mappedAccount = null; } return(mappedAccount); }
private void HandleAutoconfigPage3Select() { switch (contentPage3.Outcome) { case AutoconfigPage3Select.AutoconfigPage3Outcome.WrapperDecides: EmailProvider provider = _mechanismSuccess.ClientConfig.EmailProvider; _chosenTemplate = AutoconfigurationHelper.MapMechanismResponse(_mechanismSuccess, _emailAddress, _password, contentPage3.IncomingPreference); if (ConfigChosen != null) { ConfigChosen(this, new EventArgs()); } break; case AutoconfigPage3Select.AutoconfigPage3Outcome.UserDecides: ServerChoiceForm form = new ServerChoiceForm(); form.EmailProvider = _mechanismSuccess.ClientConfig.EmailProvider; if (form.ShowDialog(this).Equals(DialogResult.OK)) { _chosenTemplate = AutoconfigurationHelper.MapManualChoice(form.EmailProvider, _emailAddress, _password); if (ConfigChosen != null) { ConfigChosen(this, new EventArgs()); } } break; } }
private void Raise_Account_Activated(AccountConfigValues theAccount, bool dirty) { if (Account_Activated != null) { Account_Activated(this, theAccount, dirty); } }
private void HandleAutoconfigPage2Search() { switch (contentPage2.Outcome) { case AutoconfigPage2Search.AutoconfigPage2Outcome.DoMxLookup: cmdNext.Enabled = false; TryAutoConfig(RequestType.MxLookup); break; case AutoconfigPage2Search.AutoconfigPage2Outcome.DoGuess: cmdNext.Enabled = false; TryAutoConfig(RequestType.Guess); break; case AutoconfigPage2Search.AutoconfigPage2Outcome.Manual: _chosenTemplate = CreateOther(_emailAddress, _password); if (ConfigChosen != null) { ConfigChosen(this, new EventArgs()); } break; case AutoconfigPage2Search.AutoconfigPage2Outcome.Success: ShowControl(_stages[_stage + 1]); HideControl(_stages[_stage]); contentPage3.Reset(); _stage++; break; } }
private void Rename() { if (_accountsList != null && _accountsList.Accounts != null) { string beforeName = GetSelectedItem(); string theName = beforeName; AccountConfigValues theAccount = _accountsList.GetAccountByName(theName); if (theAccount != null) { Image accountImage = imageListIcons.Images[0]; string emailProviderType = !string.IsNullOrEmpty(theAccount.EmailProvider) ? theAccount.EmailProvider.ToLower() : string.Empty; if (imageListIcons.Images.IndexOfKey(emailProviderType) >= 0) { accountImage = imageListIcons.Images[emailProviderType]; } DialogResult dialogResult = InputBox.Show(theAccount.Name, Translator.Translate(AccountPromptTextKey), ref theName, accountImage); if (!dialogResult.Equals(DialogResult.Cancel) && !string.IsNullOrEmpty(theName) && !beforeName.Equals(theName)) { if (!_accountsList.CheckAccountExistsByName(theName)) { if (theAccount.Equals(_accountsList.ActiveAccount)) { _accountsList.ActiveAccountName = theName; } if (theAccount.Equals(_accountsList.StartUpAccount)) { _accountsList.StartUpAccountName = theName; } theAccount.Name = theName; Populate(); Raise_Config_Changed(); } else { MessageBox.Show(Translator.Translate(AccountDuplicateTextKey), Translator.Translate(AccountsTextKey), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }
private void SetAsStartUp() { if (_accountsList != null && _accountsList.Accounts != null) { string theName = GetSelectedItem(); AccountConfigValues theAccount = _accountsList.GetAccountByName(theName); if (theAccount != null) { _accountsList.StartUpAccountName = theAccount.Name; Populate(); Raise_Config_Changed(); } } }
public void HandleResponse(MechanismResponse mozillaResponse, string[] args) { if (!_abortRequest) { if (mozillaResponse != null && mozillaResponse.IsSuccess) { EmailProvider provider = mozillaResponse.ClientConfig.EmailProvider; _chosenTemplate = AutoconfigurationHelper.MapMechanismResponse(mozillaResponse, args[0], args[1], ConfigHelper.ParseEnumString <ServerType>(args[2])); } else { _chosenTemplate = null; } this.Invoke(_autoConfigFinishEvent); } }
private void Finish_AutoConfig(object sender, EventArgs e) { EnableForm(true); bool raiseEvent = false; if (_chosenTemplate != null) { if (_chosenTemplate.IsGuess) { DialogResult dialogResult = MessageBox.Show( "Email settings have been guessed, you may need to manually edit the settings before they will work.", this.Parent.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); raiseEvent = dialogResult == DialogResult.OK; } else { raiseEvent = true; } } else { DialogResult dialogResult = MessageBox.Show( Translator.Translate(InputEmailSettingsManual), this.Parent.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (dialogResult == DialogResult.OK) { _chosenTemplate = CreateOther(fbEmailAddress.TextValue, fbPassword.TextValue); raiseEvent = true; } } if (raiseEvent && CreateClicked != null) { CreateClicked(this, new EventArgs()); } _autoConfigThread = null; }
private AccountConfigValues CreateOther(string emailAddress, string password) { AccountConfigValues other = new AccountConfigValues(); other.Name = Translator.Translate(OtherAccountTranslationKey); other.PollingConfig = new PollingConfigValues(); other.PollingConfig.UsePolling = true; other.PollingConfig.Username = emailAddress; other.PollingConfig.PasswordTrue = password; other.PollingConfig.EmailType = EmailType.POP3; other.PollingConfig.Port = 110; other.SmtpConfig = new SmtpConfigValues(); other.SmtpConfig.Authentication = true; other.SmtpConfig.EmailAddress = emailAddress; other.SmtpConfig.Port = 25; other.SmtpConfig.SmtpSSLType = SSLType.None; other.SmtpConfig.UsePollingCredentials = true; return(other); }
public void Add() { AccountConfigValues theNewAccount = null; using (AccountsCreationForm createForm = new AccountsCreationForm()) { createForm.Name = createForm.GetType().Name; if (createForm.ShowDialog(this).Equals(DialogResult.OK)) { theNewAccount = createForm.ChosenTemplate; } } if (theNewAccount != null) { theNewAccount.TemplateDomains = null; //Don't need to save this if (_accountsList.CheckAccountExistsByName(theNewAccount.Name)) { //That name does exist, make a new name int num = 0; bool success = false; string proposedName = null; do { num++; proposedName = string.Format(AccountStatusTemplate, theNewAccount.Name, num); success = !_accountsList.CheckAccountExistsByName(proposedName); } while (!success); theNewAccount.Name = proposedName; } _accountsList.Accounts.Add(theNewAccount); Raise_Account_Activated(theNewAccount, true); } }
public static AccountConfigValues MapMechanismResponse( MechanismResponse response, string emailAddress, string password, ServerType incomingServerPreference) { AccountConfigValues mappedAccount; try { mappedAccount = new AccountConfigValues(); EmailProvider provider = response.ClientConfig.EmailProvider; if (provider.IncomingServers.Count > 0 && provider.OutgoingServers.Count > 0) { mappedAccount.EmailProvider = provider.ID; mappedAccount.Name = provider.DisplayName; mappedAccount.PollingConfig = ChooseIncomingServer(provider, emailAddress, incomingServerPreference); mappedAccount.PollingConfig.PasswordTrue = password; mappedAccount.SmtpConfig = ChooseOutgoingServer(provider, emailAddress); mappedAccount.SmtpConfig.UsePollingCredentials = mappedAccount.PollingConfig.Username == mappedAccount.SmtpConfig.Username; if (!mappedAccount.SmtpConfig.UsePollingCredentials) { mappedAccount.SmtpConfig.PasswordTrue = password; } mappedAccount.IsGuess = response.IsGuess; } } catch (Exception ex) { mappedAccount = null; } return(mappedAccount); }
private ListViewItem CreateListItem(AccountConfigValues account) { ListViewItem item = new ListViewItem(); ListViewItem.ListViewSubItem startUpItem = new ListViewItem.ListViewSubItem(); item.Text = account.Name; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, account.SmtpConfig.EmailAddress)); item.SubItems.Add(startUpItem); startUpItem.Text = account.Equals(_accountsList.StartUpAccount) ? Translator.Translate(AccountStartUpTextKey) : string.Empty; if (account.Equals(_accountsList.ActiveAccount)) { item.Font = ActiveFont; } else { item.ForeColor = Color.Gray; item.Font = NormalFont; } item.Tag = account.Name; int imageIndex = 0; if (account.SmtpConfig != null && !string.IsNullOrEmpty(account.SmtpConfig.EmailAddress)) { string emailProviderType = !string.IsNullOrEmpty(account.EmailProvider) ? account.EmailProvider.ToLower() : string.Empty; if (!string.IsNullOrEmpty(emailProviderType)) { imageIndex = imageListIcons.Images.IndexOfKey(emailProviderType); } } item.ImageIndex = imageIndex >= 0 ? imageIndex : 0; return(item); }
private void Remove() { if (_accountsList != null && _accountsList.Accounts != null) { if (!_accountsList.Accounts.Count.Equals(1)) { string theName = GetSelectedItem(); AccountConfigValues theAccount = _accountsList.GetAccountByName(theName); if (theAccount != null) { if (MessageBox.Show(Translator.Translate(AccountDeletePromptTextKey, theAccount.Name), Translator.Translate(AccountsTextKey), MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes)) { if (theAccount.Equals(_accountsList.StartUpAccount)) { _accountsList.StartUpAccountName = !theAccount.Equals(_accountsList.ActiveAccount) ? _accountsList.ActiveAccount.Name : _accountsList.Accounts[0].Name; } if (theAccount.Equals(_accountsList.ActiveAccount)) { _accountsList.Accounts.Remove(theAccount); Raise_Account_Activated(_accountsList.StartUpAccount); } else { _accountsList.Accounts.Remove(theAccount); } Populate(); Raise_Config_Changed(); } } } } }
private void Raise_Account_Activated(AccountConfigValues theAccount) { Raise_Account_Activated(theAccount, false); }