Search in sources :

Example 1 with ImapSession

use of com.zimbra.cs.imap.ImapSession in project zm-mailbox by Zimbra.

the class Folder method getImapRECENT.

/** Returns the number of messages in the folder that would be considered
     *  \Recent in an IMAP session.  If there is currently a READ-WRITE IMAP
     *  session open on the folder, by definition all other IMAP connections
     *  will see no \Recent messages.  <i>(Note that as such, this method
     *  should <u>not</u> be called by IMAP sessions that have this folder
     *  selected.)</i>  Otherwise, it is the number of messages/chats/contacts
     *  added to the folder, moved to the folder, or edited in the folder
     *  since the last such IMAP session. */
int getImapRECENT() throws ServiceException {
    // no contents means no \Recent items (duh)
    if (getSize() == 0) {
        return 0;
    }
    // if there's a READ-WRITE IMAP session active on the folder, by definition there are no \Recent messages
    for (Session s : mMailbox.getListeners(Session.Type.IMAP)) {
        ImapSession i4session = (ImapSession) s;
        if (i4session.getFolderId() == mId && i4session.isWritable()) {
            return 0;
        }
    }
    // if no active sessions, use a cached value if possible
    if (imapRECENT >= 0) {
        return imapRECENT;
    }
    // final option is to calculate the number of \Recent messages
    markItemModified(Change.SIZE);
    imapRECENT = DbMailItem.countImapRecent(this, getImapRECENTCutoff());
    return imapRECENT;
}
Also used : ImapSession(com.zimbra.cs.imap.ImapSession) ImapSession(com.zimbra.cs.imap.ImapSession) Session(com.zimbra.cs.session.Session)

Aggregations

ImapSession (com.zimbra.cs.imap.ImapSession)1 Session (com.zimbra.cs.session.Session)1