InternalGetSoapUserSettings method

Future<GetUserSettingsResponse> InternalGetSoapUserSettings(
  1. String smtpAddress,
  2. List<UserSettingName> requestedSettings
)
Calls the SOAP Autodiscover service for user settings for a single SMTP address. SMTP address. The requested settings.

Implementation

Future<GetUserSettingsResponse> InternalGetSoapUserSettings(
    String smtpAddress, List<UserSettingName> requestedSettings) async {
  List<String> smtpAddresses = <String>[];
  smtpAddresses.add(smtpAddress);

  List<String> redirectionEmailAddresses = <String>[];
  redirectionEmailAddresses.add(smtpAddress.toLowerCase());

  for (int currentHop = 0;
      currentHop < AutodiscoverService.AutodiscoverMaxRedirections;
      currentHop++) {
    GetUserSettingsResponse response = (await this
        .GetUserSettingsWithSmptAddresses(
            smtpAddresses, requestedSettings))[0];

    switch (response.ErrorCode) {
      case AutodiscoverErrorCode.RedirectAddress:
        this.TraceMessage(enumerations.TraceFlags.AutodiscoverResponse,
            "Autodiscover service returned redirection email address '${response.RedirectTarget}'.");

        smtpAddresses.clear();
        smtpAddresses.add(response.RedirectTarget!.toLowerCase());
        this.Url = null;
        this.Domain = null;

        // If this email address was already tried, we may have a loop
        // in SCP lookups. Disable consideration of SCP records.
        this._DisableScpLookupIfDuplicateRedirection(
            response.RedirectTarget!, redirectionEmailAddresses);
        break;

      case AutodiscoverErrorCode.RedirectUrl:
        this.TraceMessage(enumerations.TraceFlags.AutodiscoverResponse,
            "Autodiscover service returned redirection URL '${response.RedirectTarget}'");

        this.Url =
            this.Credentials!.AdjustUrl(Uri.parse(response.RedirectTarget!));
        break;

      case AutodiscoverErrorCode.NoError:
      default:
        return response;
    }
  }

  throw new AutodiscoverLocalException(
      "Strings.AutodiscoverCouldNotBeLocated");
}