/// <summary>
        /// Convert OutlookConfigurationSettings to GetUserSettings response.
        /// </summary>
        /// <param name="smtpAddress">SMTP address requested.</param>
        /// <param name="requestedSettings">The requested settings.</param>
        /// <returns>GetUserSettingsResponse</returns>
        internal override GetUserSettingsResponse ConvertSettings(string smtpAddress, List <UserSettingName> requestedSettings)
        {
            GetUserSettingsResponse response = new GetUserSettingsResponse();

            response.SmtpAddress = smtpAddress;

            if (this.Error != null)
            {
                response.ErrorCode    = AutodiscoverErrorCode.InternalServerError;
                response.ErrorMessage = this.Error.Message;
            }
            else
            {
                switch (this.ResponseType)
                {
                case AutodiscoverResponseType.Success:
                    response.ErrorCode    = AutodiscoverErrorCode.NoError;
                    response.ErrorMessage = string.Empty;
                    this.user.ConvertToUserSettings(requestedSettings, response);
                    this.account.ConvertToUserSettings(requestedSettings, response);
                    this.ReportUnsupportedSettings(requestedSettings, response);
                    break;

                case AutodiscoverResponseType.Error:
                    response.ErrorCode    = AutodiscoverErrorCode.InternalServerError;
                    response.ErrorMessage = Strings.InvalidAutodiscoverServiceResponse;
                    break;

                case AutodiscoverResponseType.RedirectAddress:
                    response.ErrorCode      = AutodiscoverErrorCode.RedirectAddress;
                    response.ErrorMessage   = string.Empty;
                    response.RedirectTarget = this.RedirectTarget;
                    break;

                case AutodiscoverResponseType.RedirectUrl:
                    response.ErrorCode      = AutodiscoverErrorCode.RedirectUrl;
                    response.ErrorMessage   = string.Empty;
                    response.RedirectTarget = this.RedirectTarget;
                    break;

                default:
                    EwsUtilities.Assert(
                        false,
                        "OutlookConfigurationSettings.ConvertSettings",
                        "An unexpected error has occured. This code path should never be reached.");
                    break;
                }
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convert OutlookUser to GetUserSettings response.
        /// </summary>
        /// <param name="requestedSettings">The requested settings.</param>
        /// <param name="response">The response.</param>
        internal void ConvertToUserSettings(
            List <UserSettingName> requestedSettings,
            GetUserSettingsResponse response)
        {
            // In English: collect converters that are contained in the requested settings.
            var converterQuery = from converter in converterDictionary.Member
                                 where requestedSettings.Contains(converter.Key)
                                 select converter;

            foreach (ConverterPair kv in converterQuery)
            {
                string value = kv.Value(this);
                if (!string.IsNullOrEmpty(value))
                {
                    response.Settings[kv.Key] = value;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Convert OutlookProtocol to GetUserSettings response.
        /// </summary>
        /// <param name="requestedSettings">The requested settings.</param>
        /// <param name="response">The response.</param>
        internal void ConvertToUserSettings(
            List <UserSettingName> requestedSettings,
            GetUserSettingsResponse response)
        {
            if (this.ConverterDictionary != null)
            {
                // In English: collect converters that are contained in the requested settings.
                var converterQuery = from converter in this.ConverterDictionary
                                     where requestedSettings.Contains(converter.Key)
                                     select converter;

                foreach (ConverterPair kv in converterQuery)
                {
                    object value = kv.Value(this);
                    if (value != null)
                    {
                        response.Settings[kv.Key] = value;
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Convert OutlookAccount to GetUserSettings response.
        /// </summary>
        /// <param name="requestedSettings">The requested settings.</param>
        /// <param name="response">GetUserSettings response.</param>
        internal void ConvertToUserSettings(List <UserSettingName> requestedSettings, GetUserSettingsResponse response)
        {
            foreach (OutlookProtocol protocol in this.protocols.Values)
            {
                protocol.ConvertToUserSettings(requestedSettings, response);
            }

            if (requestedSettings.Contains(UserSettingName.AlternateMailboxes))
            {
                response.Settings[UserSettingName.AlternateMailboxes] = this.alternateMailboxes;
            }
        }
        /// <summary>
        /// Reports any requested user settings that aren't supported by the Outlook provider.
        /// </summary>
        /// <param name="requestedSettings">The requested settings.</param>
        /// <param name="response">The response.</param>
        private void ReportUnsupportedSettings(List <UserSettingName> requestedSettings, GetUserSettingsResponse response)
        {
            // In English: find settings listed in requestedSettings that are not supported by the Legacy provider.
            IEnumerable <UserSettingName> invalidSettingQuery = from setting in requestedSettings
                                                                where !OutlookConfigurationSettings.IsAvailableUserSetting(setting)
                                                                select setting;

            // Add any unsupported settings to the UserSettingsError collection.
            foreach (UserSettingName invalidSetting in invalidSettingQuery)
            {
                UserSettingError settingError = new UserSettingError()
                {
                    ErrorCode    = AutodiscoverErrorCode.InvalidSetting,
                    SettingName  = invalidSetting.ToString(),
                    ErrorMessage = string.Format(Strings.AutodiscoverInvalidSettingForOutlookProvider, invalidSetting.ToString())
                };
                response.UserSettingErrors.Add(settingError);
            }
        }