onContinuationResponse method

Future onContinuationResponse(
  1. ImapResponse imapResponse
)

Handles an continuation response from the server

Implementation

Future onContinuationResponse(ImapResponse imapResponse) async {
  final cmd = _currentCommandTask?.command;
  if (cmd != null) {
    final rawData = cmd.getRawContinuationResponse();
    if (rawData != null) {
      // The literal is still terminated by CRLF, the same as the text path
      // below, just appended to the raw bytes instead of a String so that
      // nothing here re-encodes them.
      await writeData(Uint8List.fromList([...rawData, 13, 10]));

      return;
    }
    final response = cmd.getContinuationResponse(imapResponse);
    if (response != null) {
      await writeText(response);

      return;
    }
  }
  if (_isInIdleMode) {
    // `+ idling` from the server -- IDLE mode is now truly active.
    // Resolve any pending completer from
    // idleStart(waitForContinuation: true).
    final completer = _idleContinuationCompleter;
    if (completer != null && !completer.isCompleted) {
      _idleContinuationCompleter = null;
      completer.complete();
    }
    return;
  }
  logApp('continuation not handled: [$imapResponse], current cmd: $cmd');
}