Search in sources :

Example 1 with BaseFolderInfo

use of com.zimbra.common.mailbox.BaseFolderInfo in project zm-mailbox by Zimbra.

the class ImapListener method handleModify.

protected void handleModify(int changeId, Change chg, AddedItems added) {
    if (chg.what instanceof ZimbraTag && (chg.why & Change.NAME) != 0) {
        mFolder.handleTagRename(changeId, (ZimbraTag) chg.what, chg);
    } else {
        boolean isFolder = (chg.what instanceof BaseItemInfo && ((BaseItemInfo) chg.what).getMailItemType() == MailItemType.FOLDER);
        boolean isMsgOrContact = false;
        BaseItemInfo item = null;
        if (chg.what instanceof BaseItemInfo) {
            item = (BaseItemInfo) chg.what;
            isMsgOrContact = (item.getMailItemType() == MailItemType.MESSAGE || item.getMailItemType() == MailItemType.CONTACT);
        }
        try {
            if (isFolder && ((BaseFolderInfo) chg.what).getFolderIdInOwnerMailbox() == folderId.id) {
                FolderStore folder = (FolderStore) chg.what;
                // here we assume that the FolderStore object also implements BaseItemInfo
                if ((chg.why & Change.FLAGS) != 0 && (((BaseItemInfo) folder).getFlagBitmask() & Flag.BITMASK_DELETED) != 0) {
                    // mailbox accessed by sending a untagged BYE response."
                    if (handler != null) {
                        handler.close();
                    }
                } else if ((chg.why & (Change.FOLDER | Change.NAME)) != 0) {
                    mFolder.handleFolderRename(changeId, folder, chg);
                }
            } else if (isMsgOrContact) {
                boolean inFolder = mIsVirtual || item.getFolderIdInMailbox() == folderId.id;
                if (!inFolder && (chg.why & Change.FOLDER) == 0) {
                    return;
                }
                mFolder.handleItemUpdate(changeId, chg, added);
            }
        } catch (ServiceException e) {
            ZimbraLog.imap.warn("error handling modified items for changeId %s", changeId, e);
            return;
        }
    }
}
Also used : BaseFolderInfo(com.zimbra.common.mailbox.BaseFolderInfo) BaseItemInfo(com.zimbra.common.mailbox.BaseItemInfo) ServiceException(com.zimbra.common.service.ServiceException) ZimbraTag(com.zimbra.common.mailbox.ZimbraTag) FolderStore(com.zimbra.common.mailbox.FolderStore)

Aggregations

BaseFolderInfo (com.zimbra.common.mailbox.BaseFolderInfo)1 BaseItemInfo (com.zimbra.common.mailbox.BaseItemInfo)1 FolderStore (com.zimbra.common.mailbox.FolderStore)1 ZimbraTag (com.zimbra.common.mailbox.ZimbraTag)1 ServiceException (com.zimbra.common.service.ServiceException)1