當前位置: 首頁>>代碼示例>>Java>>正文


Java Pop3State類代碼示例

本文整理匯總了Java中com.icegreen.greenmail.pop3.Pop3State的典型用法代碼示例。如果您正苦於以下問題:Java Pop3State類的具體用法?Java Pop3State怎麽用?Java Pop3State使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pop3State類屬於com.icegreen.greenmail.pop3包,在下文中一共展示了Pop3State類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state, String cmd) {
    conn.println("+OK");
    try {
        MailFolder inbox = state.getFolder();
        List msgList = inbox.getMessages();
        int count = 0;
        for(int i=0;i<msgList.size();i++) {
            SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(i);
            Flags flags = msg.getFlags();
            if (flags.contains(Flags.Flag.DELETED)) {
                count++;
                flags.remove(Flags.Flag.DELETED);
            }
        }

        conn.println("+OK maildrop has "+count+" messages undeleted.");
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:21,代碼來源:RsetCommand.java

示例2: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    GreenMailUser user = state.getUser();
    if (user == null) {
        conn.println("-ERR USER required");

        return;
    }

    String[] args = cmd.split(" ");
    if (args.length < 2) {
        conn.println("-ERR Required syntax: PASS <username>");

        return;
    }

    try {
        String pass = args[1];
        state.authenticate(pass);
        conn.println("+OK");
    } catch (Exception e) {
        conn.println("-ERR Authentication failed: " + e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:25,代碼來源:PassCommand.java

示例3: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        String[] args = cmd.split(" ");
        if (args.length < 2) {
            conn.println("-ERR Required syntax: USER <username>");

            return;
        }

        String username = args[1];
        state.setUser(state.getUser(username));
        conn.println("+OK");
    } catch (UserException nsue) {
        conn.println("-ERR " + nsue);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:18,代碼來源:UserCommand.java

示例4: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    conn.println("-ERR APOP not supported");

    /*
            try
            {
                String[] arguments = cmd.split(" ");
                String username = arguments[1];
                state.setUser(state.getUser(username));
                conn.println("+OK");
            }
            catch (MailboxException me)
            {
                getLogger().warn("APOP exception", me);
                conn.println("-ERR " + me);
            }
            catch (UserException nsue)
            {
                getLogger().warn("APOP exception", nsue);
                conn.println("-ERR " + nsue);
            }
    */
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:25,代碼來源:ApopCommand.java

示例5: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder inbox = state.getFolder();
        String[] cmdLine = cmd.split(" ");

        String msgNumStr = cmdLine[1];
        List msgList = inbox.getMessages(new MsgRangeFilter(msgNumStr, false));
        if (msgList.size() != 1) {
            conn.println("-ERR no such message");

            return;
        }

        SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(0);
        String email = GreenMailUtil.getWholeMessage(msg.getMimeMessage());
        conn.println("+OK");
        conn.print(new StringReader(email));
        conn.println();
        conn.println(".");
        msg.getFlags().add(Flags.Flag.SEEN);
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:26,代碼來源:RetrCommand.java

示例6: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder folder = state.getFolder();
        if (folder != null) {
            folder.expunge();

        }

        conn.println("+OK bye see you soon");
        conn.quit();
    } catch (FolderException me) {
        conn.println("+OK Signing off, but message deletion failed");
        conn.quit();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:17,代碼來源:QuitCommand.java

示例7: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder inbox = state.getFolder();
        String[] cmdLine = cmd.split(" ");

        String msgNumStr = cmdLine[1];
        List msgList = inbox.getMessages(new MsgRangeFilter(msgNumStr, false));
        if (msgList.size() != 1) {
            conn.println("-ERR no such message");

            return;
        }

        SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(0);
        Flags flags = msg.getFlags();

        if (flags.contains(Flags.Flag.DELETED)) {
            conn.println("-ERR message already deleted");

            return;
        }

        flags.add(Flags.Flag.DELETED);

        conn.println("+OK message scheduled for deletion");
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:31,代碼來源:DeleCommand.java

示例8: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    GreenMailUser user = state.getUser();
    if (user == null) {
        conn.println("-ERR USER required");

        return;
    }

    String[] args = cmd.split(" ");
    if (args.length < 2) {
        conn.println("-ERR Required syntax: PASS <username>");

        return;
    }

    try {
        String pass = args[1];
        state.authenticate(pass);
        conn.println("+OK");
    } catch (Exception e) {
        conn.println("-ERR Authentication failed: " + e);
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:26,代碼來源:PassCommand.java

示例9: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        String[] args = cmd.split(" ");
        if (args.length < 2) {
            conn.println("-ERR Required syntax: USER <username>");

            return;
        }

        String username = args[1];
        state.setUser(state.getUser(username));
        conn.println("+OK");
    } catch (UserException nsue) {
        conn.println("-ERR " + nsue);
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:19,代碼來源:UserCommand.java

示例10: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    conn.println("-ERR APOP not supported");

    /*
            try
            {
                String[] arguments = cmd.split(" ");
                String username = arguments[1];
                state.setUser(state.getUser(username));
                conn.send("+OK");
            }
            catch (MailboxException me)
            {
                getLogger().warn("APOP exception", me);
                conn.send("-ERR " + me);
            }
            catch (UserException nsue)
            {
                getLogger().warn("APOP exception", nsue);
                conn.send("-ERR " + nsue);
            }
    */
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:26,代碼來源:ApopCommand.java

示例11: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder inbox = state.getFolder();
        String[] cmdLine = cmd.split(" ");

        String msgNumStr = cmdLine[1];
        List<StoredMessage> msgList = inbox.getMessages(new MsgRangeFilter(msgNumStr, false));
        if (msgList.size() != 1) {
            conn.println("-ERR no such message");

            return;
        }

        StoredMessage msg = msgList.get(0);
        String email = GreenMailUtil.getWholeMessage(msg.getMimeMessage());
        conn.println("+OK");
        conn.print(new StringReader(email));
        conn.println();
        conn.println(".");
        msg.setFlag(Flags.Flag.SEEN, true);
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:27,代碼來源:RetrCommand.java

示例12: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state, String cmd) {
    conn.println("+OK");
    try {
        MailFolder inbox = state.getFolder();
        List<StoredMessage> msgList = inbox.getMessages();
        int count = 0;
        for (StoredMessage msg : msgList) {
            if (msg.isSet(Flags.Flag.DELETED)) {
                count++;
                msg.setFlag(Flags.Flag.DELETED, false);
            }
        }

        conn.println("+OK maildrop has "+count+" messages undeleted.");
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:20,代碼來源:RsetCommand.java

示例13: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder folder = state.getFolder();
        if (folder != null) {
            folder.expunge();

        }

        conn.println("+OK bye see you soon");
        conn.quit();
    } catch (FolderException me) {
        conn.println("+OK Signing off, but message deletion failed");
        conn.quit();
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:18,代碼來源:QuitCommand.java

示例14: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder inbox = state.getFolder();
        List messages = inbox.getNonDeletedMessages();
        long size = sumMessageSizes(messages);
        conn.println("+OK " + messages.size() + " " + size);
    } catch (Exception me) {
        conn.println("-ERR " + me);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:12,代碼來源:StatCommand.java

示例15: execute

import com.icegreen.greenmail.pop3.Pop3State; //導入依賴的package包/類
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        MailFolder inbox = state.getFolder();
        String[] cmdLine = cmd.split(" ");
        if (cmdLine.length < 3)
            throw new IllegalArgumentException("range and line count required");

        String msgNumStr = cmdLine[1];
        List msgList = inbox.getMessages(new MsgRangeFilter(msgNumStr, false));
        if (msgList.size() != 1) {
            conn.println("-ERR no such message");

            return;
        }

        SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(0);

        int numLines = Integer.parseInt(cmdLine[2]);

        BufferedReader in = new BufferedReader(new StringReader(GreenMailUtil.getWholeMessage(msg.getMimeMessage())));

        conn.println("+OK");

        copyHeaders(in, conn);
        copyLines(in, conn, numLines);
        in.close();
        conn.println(".");
    } catch (Exception e) {
        conn.println("-ERR " + e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:33,代碼來源:TopCommand.java


注:本文中的com.icegreen.greenmail.pop3.Pop3State類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。