private void AutoConfig_Search_Thread(object obj)
        {
            try
            {
                RequestType requestType = ConfigHelper.ParseEnumString <RequestType>(obj as string);

                MechanismResponse response = IspDbHandler.GetAutoconfig(_emailAddress, requestType);

                if (response.IsGuess)
                {
                    //Excludes servers that fail and determines socket type for Plain/TLS ports
                    EmailProvider provider = response.ClientConfig.EmailProvider;
                    AutoconfigurationHelper.TestAllEmailServers(provider, 5000);

                    if (provider.IncomingServers.Count == 0 ||
                        provider.OutgoingServers.Count == 0)
                    {
                        response = new MechanismResponse()
                        {
                            ResponseType = MechanismResponseType.NotFound
                        };
                    }
                }

                this.Invoke(
                    new CallBackEvent(CallBackMechanismResponse),
                    this,
                    response,
                    new Action <MechanismResponse>(resp =>
                {
                    if (resp != null && resp.IsSuccess)
                    {
                        _mechanismSuccess = resp;
                        contentPage2.Success();
                    }
                    else
                    {
                        contentPage2.Failed();
                    }
                    cmdNext.Enabled = true;
                    cmdNext.Focus();
                }));
            }
            catch
            { }
        }
示例#2
0
        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);
            }
        }
        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 void CallBackMechanismResponse(object sender,
                                        MechanismResponse response,
                                        Action <MechanismResponse> action)
 {
     action(response);
 }