<commit_before>package com.google.sitebricks.mail;

import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.sitebricks.mail.imap.*;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * An IMAP mail client based on JBoss Netty and Event-driven IO.
 *
 * @author <EMAIL> (<NAME>)
 */
public interface MailClient {
  /**
   * Connects to the IMAP server logs in with the given credentials. Waits until the
   * connection is established before returning. Returns true if the connection auth
   * was successful. If not, the login error message can be obtained by calling
   * {@link #lastError()}
   */
  boolean connect();

  /**
   * Identical to {@link #connect()}.
   *
   * @param listener A listener to be notified when this client is disconnected due
   *   to any IO error or closed normally. Can be null.
   */
  boolean connect(DisconnectListener listener);

  /**
   * Logs out of the current IMAP session and releases all resources, including
   * executor services.
   */
  void disconnect();

  /**
   * Returns true if the underlying channels are connected to the remote server, logged in and
   * open for business.
   */
  boolean isConnected();

  List<String> capabilities();

  ListenableFuture<List<String>> listFolders();

  ListenableFuture<FolderStatus> statusOf(String folder);

  /**
   * Opens a logical 'session' to the given folder name. This method must be called
   * prior to using many of the in-folder methods on this API. Opens folder in
   * READ-ONLY mode.
   * <p>
   * Equivalent of calling {@link #open(String, boolean)} with readWrite as false.
   */
  ListenableFuture<Folder> open(String folder);

  /**
   * Opens a logical 'session' to the given folder name. This method must be called<commit_msg>Support asynchronous disconnection of mail client<commit_after>package com.google.sitebricks.mail;

import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.sitebricks.mail.imap.*;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * An IMAP mail client based on JBoss Netty and Event-driven IO.
 *
 * @author <EMAIL> (<NAME>)
 */
public interface MailClient {
  /**
   * Connects to the IMAP server logs in with the given credentials. Waits until the
   * connection is established before returning. Returns true if the connection auth
   * was successful. If not, the login error message can be obtained by calling
   * {@link #lastError()}
   */
  boolean connect();

  /**
   * Identical to {@link #connect()}.
   *
   * @param listener A listener to be notified when this client is disconnected due
   *   to any IO error or closed normally. Can be null.
   */
  boolean connect(DisconnectListener listener);

  /**
   * Logs out of the current IMAP session and releases all resources, including
   * executor services.
   */
  void disconnect();

  /**
   * Same as {@link #disconnect()} but does so on a separate worker thread, the caller
   * returns immediately.
   */
  void disconnectAsync();

  /**
   * Returns true if the underlying channels are connected to the remote server, logged in and
   * open for business.
   */
  boolean isConnected();

  List<String> capabilities();

  ListenableFuture<List<String>> listFolders();

  ListenableFuture<FolderStatus> statusOf(String folder);

  /**
   * Opens a logical 'session' to the given folder name. This method must be called
   * prior to using many of the in-folder methods on this API. Opens folder in
   * READ-ONLY mode.
   * <p>
   * Equivalent of calling {@link #open(String, boolean)} with readWrite as false.
   */
  ListenableFuture<Folder> open(String folder);

  /**
   * Opens a logical 'session' to the given folder name. This method must be called
{'fraction_non_alphanumeric': 0.09631147540983606, 'fraction_numerical': 0.0, 'mean_word_length': 3.5249130938586326, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '831169', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1075, 'n_words': 434}