亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? imap4.java

?? 手機郵箱撒的方式方式方式的
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:

package mujmail.protocols;

/*
MujMail - Simple mail client for J2ME
Copyright (C) 2006 Nguyen Son Tung <n.sontung@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;

import mujmail.Lang;
import mujmail.MessageHeader;
import mujmail.MujMail;
import mujmail.MyException;
import mujmail.Settings;
import mujmail.account.MailAccount;
import mujmail.connections.ConnectionCompressed;
import mujmail.tasks.BackgroundTask;
import mujmail.tasks.StoppableBackgroundTask;
import mujmail.threading.Algorithm;
import mujmail.ui.AudioAlert;
import mujmail.util.Functions;

/**
 * Implements InProtocol using IMAP4.
 * 
 * The advantages of implementation using IMAP4 compared to POP3:
 * - it can use the command UID_SEARCH_UNSEEN for access to identifiers of 
 * unread mails
 * - easier deleting of mails (without disconnecting from the server)
 * - getting of required bodypart
 * 
 * IMAP supports more parallel connections to one account so identification of
 * the connection must be added before each command
 * 
 */
public class IMAP4 extends InProtocol {
    
    /** The name of this source file */
    private static final String SOURCE_FILE = "IMAP4";

    /** Flag signals if we want to print debug prints */
    private static final boolean DEBUG = false;

    int commandCounter = 0;
    //name of a selected IMAP4 folder followed with it's UIDVALIDITY encapsulated within two slashes //	
    String sld_mailBox_uidval; //so looks like: INBOX/12313/
    String flags;
    int indexOfFlags = -1;
    Vector deleted;
    Timer connectionKeeper;
    boolean pushing = false;

    protected boolean isMujMailServer = false; /// Flag signaling that you are connected to mujMail server
    static final byte GET_URL         = 5;     //re-retrieving mail bodies - redownload uncompleted mails

    /**
     * Resolves myException while running some task.
     * @param ex
     */
    private void resolveMyExceptionRun(MyException ex) {
        ex.printStackTrace();
        if (ex.getErrorCode() == MyException.COM_HALTED) {
            connection.unQuit();
        }
        resolveExceptions(ex.getDetails() + "/ " + account.getEmail(), SOURCE_FILE);
    }
    private class Keeper extends TimerTask {

        public void run() { //sends a command to check and keeps the connection alive to avoid long reconnecting
              if (DEBUG) System.out.println(account.getEmail() + ": keeping connection alive...");
            if (isBusy()) {
                return;
            }
            lock();
            if (!isConnected()) {
                _close(null);
            }
            unlock();
        }
    }

    public IMAP4(MailAccount account) {
        super(account);
        END_OF_MAIL = ")\r\n";
        deleted = new Vector();
    }

    public void addDeleted(MessageHeader header) {
        deleted.addElement(header);
    }

    /**
     * Sends a command to the server.
     * If resultOnly is <code>true</code> it flushes all response lines
     * to the last response line, that begins with the tag and returns the rest
     * of the line (without the tag).
     * 
     * @return tag, when resultOnly is <code>true</code>, rest of the last
     *         response line otherwise
     */ 
    protected String execute(String command, boolean resultOnly) throws MyException {
          if (DEBUG) System.out.println("DEBUG IMAP4.execute(command='" + command + "', resultOnly=" + resultOnly + ")");
        String tag = "A" + commandCounter++ + " ";
          if (DEBUG) System.out.println("DEBUG IMAP4.execute() tag: " + tag);
          if (DEBUG) System.out.println("DEBUG IMAP4.execute() sending CRLF");
        connection.sendCRLF(tag + command);
          if (DEBUG) System.out.println("DEBUG IMAP4.execute() CRLF sent");
        if (resultOnly) {
              if (DEBUG) System.out.println("DEBUG IMAP4.execute() result only, getting line");
            String reply = connection.getLine();
              if (DEBUG) System.out.println("DEBUG IMAP4.execute() line getted");
            while ( !reply.startsWith(tag) ) {
                  if (DEBUG) System.out.println("DEBUG IMAP4.execute() reply: " + reply);
                reply = connection.getLine();
            }

            if (DEBUG) System.out.println("DEBUG IMAP4.execute() reply: " + reply.substring(tag.length()));

            return reply.substring(tag.length());
        }
        return tag;
    }

    /**
     * Sends the command to server and returns the result that is 
     * mostly closed in brackets.
     */ 	
    protected String execute(String command, String arguments) throws MyException {
        String tag = "A" + commandCounter++ + " ";
        connection.sendCRLF(tag + command + (arguments == null ? "" : " " + arguments));       
        String result = "";

        String temp = connection.getLine();
        while (!temp.startsWith(tag)) { //multiline response
            if (temp.indexOf(" " + command + " ") != -1) { //is it the response for the executed command?
                int p = temp.indexOf('(');
                int q = temp.indexOf(')', p + 1);

                if (p != -1 && q > p) {	//a response in the form of "* command (result)"			
                    result = temp.substring(p + 1, q);
                } else //a response in the form of "* command result"
                {
                    result += temp.substring(2 + command.length() + 1);
                } //2 - "* ", 1 - the space after the command
            }
            temp = connection.getLine();
        }

        temp = temp.substring(tag.length());
        if (temp.startsWith("BAD ") || temp.startsWith("NO ")) {
            throw new MyException(MyException.PROTOCOL_COMMAND_NOT_EXECUTED);
        }

        return result;
    }

    public boolean isConnected() {
        try {
              if (DEBUG) System.out.println("DEBUG IMAP4.isConnected() calling connection.isConnected");
            if (connection.isConnected()) {
                  if (DEBUG) System.out.println("DEBUG IMAP4.isConnected() is connected, clearing input");
                connection.clearInput();
                  if (DEBUG) System.out.println("DEBUG IMAP4.isConnected() executing noop");
                if (execute("NOOP", true).startsWith("OK")) {
                      if (DEBUG) System.out.println("DEBUG IMAP4.isConnected() OK");
                    return true;
                }
            }
        } catch (Exception ex) {
            connection.close();
            ex.printStackTrace();
        }
          if (DEBUG) System.out.println("DEBUG IMAP4.isConnected() is not");
        return false;
    }

    public int countNew() throws MyException {
        return searchMailsMatching("UNSEEN").size();
    }

    /**
     * Returns Vector having UID of mails matching the concrete criteria.
     */
    private Vector searchMailsMatching(String criteria) throws MyException {
        Vector mails = new Vector();
        String tag;
        execute("UID SEARCH " + criteria, false);
        String line = connection.getLine();
        line = line.substring(line.indexOf("SEARCH") + 7).trim() + " ";
        int i = 0, j = 0, mailsCount = 0;
        try {
            while (line.length() - 1 > i) {
            	// Break only in case Synchronization
            	// is not running
            	if (!targetBox.isSyncRunning() &&
            		Settings.maxMailsRetrieve > 0 && mailsCount >= Settings.maxMailsRetrieve) //limit exceeded
                {
                    break;
                }
                j = line.indexOf(" ", i);
                tag = line.substring(i, j);

                // In case of synchronization we 
                // want all mails 
                if (targetBox.isSyncRunning()) {
                	mails.addElement(tag);
            	}
                else if (!targetBox.wasOnceDownloaded(account.getEmail(), sld_mailBox_uidval + tag)) {
                    // If the mail with given message ID was 
                    // already downloaded, remove it from 
                    // the list of new mails
                	mails.addElement(tag);
                	mailsCount++;
                }
                i = j + 1;
            }
        } catch (Exception ex) {
              // process chybicky ... proc tu odchytavat
        	  // protoze line.substring() vyhodi Exception
        	  // na konci: tohle by asi melo byt silent
        	  // exception
        	  // TODO (Betlista): tohle je hodně debilní :-/
            ex.printStackTrace();
        }
        return mails;
    }

    private String parseUID(String s) {
        return s.substring(s.lastIndexOf(MessageHeader.MSG_ID_SEPARATOR) + 1);
    }

    // Note task can be null (polling)
    protected boolean open(BackgroundTask task) throws MyException {
        if (DEBUG) System.out.println("DEBUG IMAP4.open() calling isConnected");
        if (isConnected()) {
            if (DEBUG) System.out.println("DEBUG IMAP4.open() is connected");
            return true;
        }
        if (DEBUG) System.out.println("DEBUG IMAP4.open() is not connected");

        _close(task); //we'd better close inactive connections
        try {
            commandCounter = 0;//reset the counter for each connection			
            String reply;

            if (task != null) { task.setTitle(Lang.get(Lang.ALRT_PL_CONNECTING) + " " + account.getEmail()); }
            connection.open(account.getServer() + ":" + account.getPort(),account.isSSL(), account.getSSLType());
            reply = connection.getLine(); // Welcome message from server

            isMujMailServer = reply.indexOf("mujMail") > 0;
            if (reply.length() == 0) {
                if (task != null) { task.setTitle(Lang.get(Lang.ALRT_PL_CONNECTING) + account.getEmail() + Lang.get(Lang.FAILED)); }
                return false;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩久久精品一区| 日本美女一区二区| 亚洲欧美自拍偷拍| 亚洲私人影院在线观看| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 日韩av电影免费观看高清完整版| 亚洲国产精品久久艾草纯爱| 日韩av一区二| 精东粉嫩av免费一区二区三区| 日韩成人dvd| 国产精品18久久久久久久久| 成人av电影在线播放| 色www精品视频在线观看| 欧美日韩成人综合天天影院| 欧美日韩你懂得| 精品免费一区二区三区| 中文字幕精品三区| 一区二区三区成人| 久久国产乱子精品免费女| 韩国毛片一区二区三区| 丰满少妇久久久久久久| 91搞黄在线观看| 国产色综合久久| 亚洲国产精品精华液网站| 免费成人在线影院| 国产91富婆露脸刺激对白| fc2成人免费人成在线观看播放| 色先锋资源久久综合| 欧美一二区视频| 国产精品美女久久久久久久| 午夜精品久久久久久久| 精品亚洲成a人| 99精品视频在线免费观看| 欧美巨大另类极品videosbest | 偷拍日韩校园综合在线| 九九精品视频在线看| 成人国产精品免费观看动漫| 99精品欧美一区二区蜜桃免费 | 日本少妇一区二区| 卡一卡二国产精品| www.亚洲色图| 91精品欧美福利在线观看| 另类综合日韩欧美亚洲| 成人av资源站| 欧美日韩一区二区三区在线| 久久精品一区二区三区不卡牛牛| 夜夜精品视频一区二区| 久久精品免费看| 成人福利电影精品一区二区在线观看| 欧美三级中文字| 欧美国产精品劲爆| 免费日韩伦理电影| 国产成人8x视频一区二区| 欧美性极品少妇| 亚洲精品在线网站| 亚洲3atv精品一区二区三区| 99这里只有精品| 国产欧美一区二区精品性色超碰| 日韩在线一二三区| 99国内精品久久| 久久精品一区八戒影视| 激情久久久久久久久久久久久久久久| 欧洲精品在线观看| 久久久久久久网| 热久久久久久久| 欧美性色综合网| 亚洲欧美电影一区二区| 国产高清不卡二三区| 欧美精品xxxxbbbb| 亚洲国产精品黑人久久久| 国产精品自拍三区| 欧美成人女星排名| 国产精品无码永久免费888| 精品无人码麻豆乱码1区2区 | 国产精品毛片大码女人| 久久99久久99| 在线综合视频播放| 一区二区三区免费看视频| 懂色中文一区二区在线播放| 久久女同精品一区二区| 亚洲激情中文1区| 91年精品国产| 日韩欧美国产成人一区二区| 奇米综合一区二区三区精品视频| 在线免费av一区| 亚洲精品精品亚洲| 97久久超碰国产精品| 中文字幕一区二区在线播放| 国产99久久久久| 亚洲精品一区二区在线观看| 蜜桃视频一区二区| 一本大道久久精品懂色aⅴ| 亚洲美女淫视频| 久久97超碰国产精品超碰| 日韩一区二区免费高清| 亚洲最大色网站| 不卡av电影在线播放| 欧美激情一区在线| 国产69精品久久久久777| 国产日韩av一区二区| 丰满白嫩尤物一区二区| 欧美精品一区二区三区在线播放| 精一区二区三区| 久久久噜噜噜久噜久久综合| 国产福利一区在线| 欧美三级韩国三级日本一级| 国产精品剧情在线亚洲| 精品国产乱码久久久久久图片| 久久91精品久久久久久秒播| 久久亚洲一区二区三区明星换脸 | 日韩欧美国产三级电影视频| 奇米影视7777精品一区二区| 色婷婷激情久久| 日韩综合小视频| 亚洲精品一区二区三区四区高清| 国产综合成人久久大片91| 国产午夜精品一区二区三区四区 | 亚洲一级二级三级| 精品视频在线免费| 午夜亚洲国产au精品一区二区| 日韩一级片在线观看| 亚洲高清中文字幕| 国产午夜精品一区二区三区嫩草 | 亚洲国产成人av好男人在线观看| 91精品国产综合久久小美女 | 日韩欧美国产1| 91亚洲资源网| 视频在线在亚洲| 国产精品你懂的在线欣赏| 色婷婷综合久久久中文字幕| 精品一区二区三区日韩| 国产精品进线69影院| 91精品久久久久久久91蜜桃 | 久久久久国产精品麻豆| 日本乱码高清不卡字幕| 日韩国产欧美在线视频| 欧美国产一区在线| 欧美性欧美巨大黑白大战| 久久99国产精品免费网站| 亚洲综合在线电影| 欧美一级夜夜爽| 91成人网在线| 激情综合网最新| 亚洲午夜电影网| 久久精品欧美一区二区三区不卡| 欧美放荡的少妇| 成人精品免费看| 美女网站视频久久| 成人免费一区二区三区视频| 精品国产91久久久久久久妲己 | 久久久久久久久久久99999| 欧美日韩日日摸| 成人黄色大片在线观看| 蜜臀av一区二区在线免费观看| 中文字幕在线观看不卡视频| 欧美日本在线看| 色94色欧美sute亚洲线路二| 国内精品自线一区二区三区视频| 亚洲一区国产视频| 国产欧美一区视频| 欧美精品一区二区三区很污很色的 | 91麻豆自制传媒国产之光| 国产精品一二三四区| 午夜不卡av免费| 一片黄亚洲嫩模| 国产精品网站一区| 久久久激情视频| 日韩欧美久久久| 91高清在线观看| 91蝌蚪国产九色| 国产成人一区二区精品非洲| 免费久久精品视频| 国产盗摄一区二区三区| 五月天丁香久久| 亚洲女爱视频在线| 久久久久久久久久久久久久久99| 91传媒视频在线播放| 粉嫩一区二区三区性色av| 久久69国产一区二区蜜臀 | 欧美性猛交xxxx黑人交| www.日韩精品| www.亚洲精品| 东方aⅴ免费观看久久av| 国产成人午夜精品影院观看视频 | 欧美色综合网站| 欧洲另类一二三四区| 99久久久国产精品| 99久久婷婷国产精品综合| 国产精品996| 成人黄色网址在线观看| 韩国成人精品a∨在线观看| 精东粉嫩av免费一区二区三区| 蜜桃视频在线观看一区二区| 精品制服美女久久| 日本午夜精品视频在线观看 | 看国产成人h片视频| 美女www一区二区| 日本怡春院一区二区| 久久99精品久久久久久久久久久久| 日本不卡一区二区三区高清视频|