Ejemplo n.º 1
0
  <D> ChannelFuture send(Command command, String args, SettableFuture<D> valueFuture) {
    Long seq = sequence.incrementAndGet();

    String commandString =
        seq + " " + command.toString() + (null == args ? "" : " " + args) + "\r\n";

    // Log the command but clip the \r\n
    log.debug("Sending {} to server...", commandString.substring(0, commandString.length() - 2));
    Boolean toStdOut = logAllMessagesForUsers.get(config.getUsername());
    if (toStdOut != null) {
      if (toStdOut)
        System.out.println(
            "IMAPsnd["
                + config.getUsername()
                + "]: "
                + commandString.substring(0, commandString.length() - 2));
      else
        log.info(
            "IMAPsnd[{}]: {}",
            config.getUsername(),
            commandString.substring(0, commandString.length() - 2));
    }

    // Enqueue command.
    mailClientHandler.enqueue(new CommandCompletion(command, seq, valueFuture, commandString));

    return channel.write(commandString);
  }
Ejemplo n.º 2
0
 public void enableSendLogging(boolean enable) {
   log.info("Logging of sent IMAP commands for user {} = {}", config.getUsername(), enable);
   if (enable) logAllMessagesForUsers.put(config.getUsername(), false);
   else logAllMessagesForUsers.remove(config.getUsername());
 }
Ejemplo n.º 3
0
 // For debugging, use with caution!
 public static void addUserForVerboseOutput(String username, boolean toStdOut) {
   logAllMessagesForUsers.put(username, toStdOut);
 }