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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? persistentbox.java

?? 手機郵箱撒的方式方式方式的
?? JAVA
字號:
/*
MujMail - Simple mail client for J2ME
Copyright (C) 2006 Nguyen Son Tung <n.sontung@gmail.com>
Copyright (C) 2006 Martin Stefan <martin.stefan@centrum.cz>
Copyright (C) 2008 David Hauzar <david.hauzar.mujmail@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.
 */

package mujmail;

import mujmail.threading.ThreadedEmails;
import mujmail.util.Functions;
import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import mujmail.ordering.Ordering;
import mujmail.ordering.comparator.OriginatorDateTimeComparator;
//#ifdef MUJMAIL_SEARCH
import mujmail.util.SaveableBooleanValue;
import mujmail.util.PersistentValueReminder;
//#endif
/**
 * TheBox thats messages are persistent - stored in RMS.
 * It contains pointer to the database where are stored the headers of mails from
 * this box. So, there is one database for each Box.
 * 
 * Each persistent box is connected to two databases (DBFile, mailDB). The first one 
 * contains the headers of mails from given box, the second one bodyparts of 
 * the mail.
 * 
 * Each mail is stored in one persistent box.
 * 
 * @author David Hauzar
 */
//#ifdef MUJMAIL_SEARCH
public class PersistentBox extends TheBox implements SaveableBooleanValue {
//#else
//# public class PersistentBox extends TheBox {
//#endif   
    /** The name of this source file */
    private static final String SOURCE_FILE = "PersistentBox";
    /** Flag signals if we want to print debug prints */
    private static final boolean DEBUG = false;
    /** Vector of all searchable boxes. */
    private final static Vector persistentBoxes = new Vector();

    //#ifdef MUJMAIL_SEARCH
    private final PersistentValueReminder.PersistentBooleanValueReminder wasSelectedReminder;
    //#endif

    /**
     * The name of database file in which are stored headers of mails from this box
     */
    protected final String DBFile;
    /**
     * Represents database file in which are stored headers of mails from this box
     */
    protected MailDB mailDB;
    
    /**
     * Creates persistent box.
     * 
     * @param DBFile the identifier of RMS database where the mails of this box
     *  will be stored.
     * @param mMail the main object in the application
     * @param name the name of the box
     */
    public PersistentBox(String DBFile, MujMail mMail, String name) {
        super(mMail, name);

        this.DBFile = DBFile;
        
        persistentBoxes.addElement(this);
        mailDB = mujMail.getMailDBManager().getMailDB(this, DBFile);
        
        // mailDB.loadDB(this); // Race condition this have to be called from MujMail class
        //#ifdef MUJMAIL_SEARCH
        wasSelectedReminder = new PersistentValueReminder.PersistentBooleanValueReminder(PersistentValueReminder.DB_PREFIX + DBFile);
        //#endif

    }
    
    /**
     * Gets a copy of all boxes that can be used in the search.
     * @return all boxes that can be used in the search.
     */
    public static Vector getPersistentBoxes() {
        return Functions.copyVector( persistentBoxes );
    }

    /**
     * Do the physical work of deleting marked mails from box and database.
     * Called by deleteMarkedFromBoxAndDB().
     */
    protected void doDeleteMarkedFromBoxAndDB() {
        mailDB.deleteMails(this);
    }

    protected void paintIsBusy() {
        mailDB.getDBLoadingTask().showProgressIfRunning();
    }


    
    /**
     * Indicates whether there proceeds some action beyond the mails in this
     * box.
     * @return true if there proceeds some action beyond the mails int this
     * box
     */
    protected boolean isBusy() {
        return mailDB.isBusy();
    }

    /**
     * Copyes bodyparts of oldHeader to newHeader and stores it.
     * @param oldHeader the header which bodyparts will be copyed
     * @param newHeader the header to that bodyparts will be copyed
     */
    private void copyAndStoreBodyParts(MessageHeader oldHeader, MessageHeader newHeader) {
        for (byte i = 0; i <= oldHeader.getBodyPartCount() - 1; ++i) {
            BodyPart bp = new BodyPart(newHeader, oldHeader.getBodyPart(i), ContentStorage.CopyingModes.DEEP_COPY);
            //make a copy
            bp.setBodyState(oldHeader.getBodyPart(i).getBodyState());
            //maybe it is also partial as it's copy
            //maybe bodypart's content was not saved,
            //at least we'll save the bodypart's header
            newHeader.addBodyPart(bp);
        }
    }

    /**
     * 
     * @param messageHeader
     * @return
     */
    private MessageHeader copyMessageHeader(final MessageHeader messageHeader) {
        final MessageHeader message = new MessageHeader(this, messageHeader);
          // make a copy
        message.DBStatus = MessageHeader.NOT_STORED;
          // because our new header is really not stored in DB yet
        if (message.deleted) {
            message.deleted = false;
        }
          // to prevent being deleted
        if (this != getMujMail().getTrash()) {
            message.setOrgLocation( DBFile.charAt(0) );
        }
          // change the original location of the header to this box DBFile
          if (DEBUG) System.out.println("DEBUG PersistentBox.copyMessageHeader(MessageHeader) - adding message to the storage");
        if ( this instanceof InBox ) { // threading is active only in InBox
            storage.addMessage(message);
        } else {
            if ( storage instanceof ThreadedEmails ) {
                ThreadedEmails te = (ThreadedEmails)storage;
                te.addRoot( message );
            }
        }
          if (DEBUG) System.out.println("DEBUG PersistentBox.copyMessageHeader(MessageHeader) - message added");
        return message;
    }

    /**
     * Stores the copy of given mail with bodyparts mail to the DB of this box 
     * and to the container of this box.
     * 
     * @param header the header of mail to be copied and stored
     * @return the header of the mail that was stored - the copy of the mail
     *  given in parameter
     */
    public MessageHeader storeMail(MessageHeader header) {
        MessageHeader h = null;
        try {
              // TODO (Betlista): why there have to be copy returned ?
              if (DEBUG) System.out.println("DEBUG PersistentBox.storeMail(MessageHeader) - storing mail");
            h = copyMessageHeader(header);
            copyAndStoreBodyParts(header, h);
            h.saveHeader();
              if (DEBUG) System.out.println("DEBUG PersistentBox.storeMail(MessageHeader) - mail stored");
        } catch (MyException ex) {
            //something went wrong, markAsDeleted all saved data
            report(ex.getDetails() + header.getSubject(), SOURCE_FILE);
            for (int i = header.getBodyPartCount() - 1; i >= 0; --i) {
                ((BodyPart) header.getBodyPart(i)).getStorage().deleteContent();
            }
            storage.removeMessage(h);
            //remove the added header by copyMessageHeader()
            return null;
        }
        return h;
    }
    
    /**
     * Delete all mails from database of this persistent box.
     */
    protected void deleteAllMailsFromDB() {
        try {
            mailDB.clearDb(true);
        } catch (MyException ex) {
            if (DEBUG) {
                System.out.println("Clearing DB failed");
                ex.printStackTrace();
            }
        }
    }
    
    /**
     * Deletes oldest mails from this box and from database. Stops deleting if
     * the number of deleted mails is equal to numHeadersToDelete or if it was
     * deleted all mails in this box.
     *
     * @param numHeadersToDelete the number of headers to be deleted.
     * @return the number of headers that were deleted
     */
    public int deleteOldestMails(int numMailsToDelete) {
        if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldest mails - start.");
        synchronized (storage) {
            storage.sort(new OriginatorDateTimeComparator(Ordering.NATURAL));
        }
        
        numMailsToDelete = Math.min(numMailsToDelete, storage.getSize());
        if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldest mails - there should be " + numMailsToDelete + " mails deleted.");
        for (int i = 0; i < numMailsToDelete; i++) {
            if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldest mails - deleting mail.");
            storage.getMessageAt(i).deleteFromDBAndBox(this, Trash.TrashModes.NOT_MOVE_TO_TRASH);
        }
        
        resort();

        return numMailsToDelete;
    }

    /**
     * Deletes bodyparts of oldest mails in this box. Stops deleting if the size
     * of deleted bodyparts is bigger or equal than <code>memoryToBeReleased</code>
     * or if all bodyparts of all mails were deleted.
     *
     * @param memoryToBeReleased the amount of memory to be released in database
     *  by deleting of bodyparts.
     * @param thisMail the mail that's bodyparts should not be deleted.
     * @return the size of all deleted bodyparts.
     */
    public long deleteOldestBodyParts(long memoryToBeReleased, MessageHeader thisMail) {
        synchronized (storage) {
            storage.sort(new OriginatorDateTimeComparator(Ordering.NATURAL));
        }

        if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldestBodyParts - starting to delete bodyparts of max size " + memoryToBeReleased);
        long toDeleteAct = memoryToBeReleased;
        for (int i = 0; i < storage.getSize(); i++) {
            MessageHeader message = storage.getMessageAt(i);
            if (message == thisMail) continue;
            if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldestBodyParts - deleting bodyparts of message " + message);
            toDeleteAct -= deleteBodyPartsOfMessage(message);
            if (toDeleteAct <= 0) break;
        }

        resort();

        long sizeOfAllDeleted = memoryToBeReleased - toDeleteAct;
        if (DEBUG) System.out.println("DEBUG PersistentBox.deleteOldestBodyParts - the size of deleted bodyparts " + sizeOfAllDeleted);
        return sizeOfAllDeleted;
    }
    
    //#ifdef MUJMAIL_SEARCH
    public boolean loadBoolean() {
        return wasSelectedReminder.loadBoolean();
    }
    
    public void saveBoolean(boolean isSelected) {
        wasSelectedReminder.saveBoolean(isSelected);
    }
    //#endif

    public void showBox() {
        // Show us only if paint can show progress with loading DB or inbox content
        if (getMailDB().getDBLoadingTask() != null) {
            super.showBox();
        }
    }
    
    /**
     * Called from MailDB after loading db (loadDB) is done
     * Note: Specialized in childs
     */
    public void loadedDB() {
        resort(); //its needed to resort the box according to the settings
    }

    /**
     * Represents database file in which are stored headers of mails from this box
     */
    public MailDB getMailDB() {
        return MujMail.mujmail.getMailDBManager().getMailDB(this, mailDB.getDBName());
    }
    
    /**
     * @return Name of database where box data are stored
     */
    public String getDBFileName() {
        return DBFile;
    }

    public void commandAction(Command c, Displayable d) {
        super.commandAction(c, d);
    }
    
    /**
     * @return Size of databases that stores data of folder
     */
    public int getOccupiedSpace() {
        return mailDB.getOccupiedSpace();
    }

    /**
     * Deletes body parts of given message.
     *
     * @param message the message that's bodyparts will be deleted.
     * @return the size of bodyparts that were deleted.
     */
    private long deleteBodyPartsOfMessage(MessageHeader message) {
        if (message.getBodyPartCount() > 0) {
            for (int j = 0; j < message.getBodyPartCount(); j++) {
                BodyPart bodyPart = message.getBodyPart(j);
                deleted += bodyPart.getSize();
                bodyPart.getStorage().deleteContent();
            }
            // TODO: this would remove bodyparts only non-persistently!!!
            // message.deleteAllBodyParts();
        }

        return deleted;
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天影视涩香欲综合网| 丝袜亚洲另类丝袜在线| 2021久久国产精品不只是精品| 91美女在线看| 成人福利视频在线| 麻豆精品在线播放| 首页国产丝袜综合| 亚洲自拍偷拍图区| 亚洲精品国产精品乱码不99 | 欧美一区日本一区韩国一区| 99久久精品一区| 99精品一区二区| av影院午夜一区| 一本大道av一区二区在线播放| av不卡免费在线观看| 91丨porny丨首页| 色偷偷成人一区二区三区91| 99久久免费国产| 91免费版pro下载短视频| 91视视频在线观看入口直接观看www | 久久电影国产免费久久电影| 婷婷久久综合九色综合绿巨人 | 久久精品无码一区二区三区| 欧美极品aⅴ影院| 亚洲天堂2016| 日韩黄色在线观看| 激情综合五月天| 99久久精品情趣| 欧美亚一区二区| 日本成人中文字幕| 蜜桃视频第一区免费观看| 国产精品一区二区三区四区| 91麻豆视频网站| 欧美一区二区黄色| 国产免费观看久久| 污片在线观看一区二区| 国产成人精品亚洲午夜麻豆| 色综合激情久久| 国产午夜精品久久久久久免费视| 亚洲一区二区三区美女| 盗摄精品av一区二区三区| 91精品一区二区三区久久久久久| 国产精品乱码人人做人人爱| 日韩**一区毛片| 色久综合一二码| 亚洲欧洲成人自拍| 国产一区二区免费视频| 91精品国产欧美一区二区成人| 国产拍揄自揄精品视频麻豆 | 伊人夜夜躁av伊人久久| 国产成人免费视| 91精品国产色综合久久不卡电影| 国产精品久久久久婷婷| 久久99国产精品免费| 欧美日韩免费高清一区色橹橹 | 国产一区二区三区国产| 91精品国产91久久综合桃花| 亚洲一区二区欧美日韩| 色激情天天射综合网| 亚洲人被黑人高潮完整版| 99精品偷自拍| 18成人在线观看| 成人精品国产一区二区4080| 久久久久久久久久久电影| 另类调教123区 | 久久久99精品久久| 国产一区二区免费在线| 久久亚洲精精品中文字幕早川悠里| 婷婷一区二区三区| 精品国产乱子伦一区| 久久精品二区亚洲w码| 一个色在线综合| 欧美精品xxxxbbbb| 青娱乐精品在线视频| 精品久久久久久亚洲综合网| 久久www免费人成看片高清| 精品捆绑美女sm三区| 粗大黑人巨茎大战欧美成人| 综合电影一区二区三区 | 亚洲高清免费一级二级三级| 91麻豆精品国产综合久久久久久| 日韩二区三区在线观看| 国产欧美一区二区在线观看| 9色porny自拍视频一区二区| 一区二区三区四区蜜桃| 亚洲男人的天堂在线观看| 欧美日韩精品欧美日韩精品一| 丝袜亚洲精品中文字幕一区| 久久久久久一二三区| 欧美日韩视频一区二区| 国产精品主播直播| 亚洲一区二区av电影| 欧美国产综合色视频| 欧美三级在线播放| 成人h精品动漫一区二区三区| 亚洲一区二区三区视频在线| 国产日韩欧美综合在线| 欧美一区二区三区公司| 成年人网站91| 国产一区二区精品久久99 | 日韩av中文在线观看| 17c精品麻豆一区二区免费| 精品免费日韩av| 欧美精品一级二级| 色狠狠桃花综合| 国产一区二区福利视频| 欧美在线观看视频在线| 粉嫩av一区二区三区| 91蜜桃网址入口| 在线综合视频播放| www日韩大片| 日韩亚洲欧美在线观看| 91浏览器在线视频| 99久久国产综合精品麻豆| 极品少妇xxxx偷拍精品少妇| 蜜臀a∨国产成人精品| 亚洲一区二区精品3399| 亚洲美女偷拍久久| 国产精品国产三级国产普通话99 | 国产一区二区导航在线播放| 久久99精品久久久久久国产越南| 久久精品国产精品亚洲精品| 国产乱码精品一区二区三区av| 九九精品视频在线看| 激情文学综合网| 成人午夜在线播放| 色综合久久久久久久| 欧美午夜影院一区| 欧美精品v日韩精品v韩国精品v| 精品卡一卡二卡三卡四在线| 久久久久久久久久久久久女国产乱| 国产日韩v精品一区二区| **欧美大码日韩| 久久精品国产在热久久| 成年人国产精品| 欧美精品一区视频| 色综合天天综合在线视频| youjizz久久| 中文在线免费一区三区高中清不卡 | 国产九九视频一区二区三区| 欧美三片在线视频观看| 久久网这里都是精品| 亚洲成年人影院| 91国偷自产一区二区使用方法| 欧美成人艳星乳罩| 天天色 色综合| 色综合天天性综合| 国产精品入口麻豆九色| 免费观看一级特黄欧美大片| 91色九色蝌蚪| 中文字幕亚洲视频| 极品少妇xxxx精品少妇| 欧美乱熟臀69xxxxxx| 一区二区免费在线| 欧美性做爰猛烈叫床潮| 亚洲综合激情另类小说区| 国产91精品一区二区| 91精品国产麻豆| 婷婷综合在线观看| 日韩视频免费观看高清完整版 | 成人黄色免费短视频| 欧美岛国在线观看| 麻豆精品国产传媒mv男同 | 欧美午夜精品免费| 亚洲精品成人在线| 一本一道波多野结衣一区二区| 国产精品情趣视频| 成人激情小说网站| 亚洲图片另类小说| 一本大道久久a久久综合婷婷| 中文字幕制服丝袜一区二区三区| 99国产精品久久久久久久久久| 亚洲综合免费观看高清在线观看 | 精品国产乱码久久久久久夜甘婷婷 | 欧美日本精品一区二区三区| 国产乱色国产精品免费视频| 亚洲一区二区3| 国产日产欧美精品一区二区三区| 欧洲另类一二三四区| 免费人成黄页网站在线一区二区| 欧美高清视频不卡网| 青娱乐精品视频| 国产精品乱码一区二区三区软件| caoporn国产精品| 五月天亚洲婷婷| 国产欧美日本一区视频| 99久久综合国产精品| 亚洲r级在线视频| 国产网站一区二区三区| 91蝌蚪porny| 天使萌一区二区三区免费观看| 日韩免费视频一区| 99久久婷婷国产综合精品电影 | 日韩欧美高清一区| 韩日av一区二区| 亚洲欧美日韩国产一区二区三区| 欧美二区三区的天堂| 成人亚洲精品久久久久软件| 天堂资源在线中文精品| 国产精品私人自拍|