Search in sources :

Example 1 with MailboxName

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

the class ImapAppender method append.

private long append(MessageInfo mi, Literal data) throws IOException {
    ImapRequest req = connection.newRequest(CAtom.APPEND, new MailboxName(mailbox));
    if (mi.flags != null) {
        req.addParam(mi.flags);
    }
    if (mi.date != null) {
        req.addParam(mi.date);
    }
    req.addParam(data);
    ResponseText rt = req.sendCheckStatus().getResponseText();
    if (rt != null && rt.getCCode() == CAtom.APPENDUID) {
        AppendResult ar = (AppendResult) rt.getData();
        if (ar.getUid() > 0) {
            return ar.getUid();
        }
    }
    throw req.failed("APPENDUID supported but UID missing from result");
}
Also used : MailboxName(com.zimbra.cs.mailclient.imap.MailboxName) ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) ResponseText(com.zimbra.cs.mailclient.imap.ResponseText) AppendResult(com.zimbra.cs.mailclient.imap.AppendResult)

Example 2 with MailboxName

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

the class RemoteFolder method copyMessage.

public CopyResult copyMessage(long uid, String mbox) throws IOException {
    assert isSelected();
    String seq = String.valueOf(uid);
    ImapRequest req = connection.newUidRequest(CAtom.COPY, seq, new MailboxName(mbox));
    ResponseText rt = req.sendCheckStatus().getResponseText();
    if (rt.getCCode() == CAtom.COPYUID) {
        CopyResult cr = (CopyResult) rt.getData();
        // Bug 36373: If COPYUID result 0 then assume that message no longer exists.
        if (cr != null && cr.getToUids()[0] != 0) {
            return cr;
        }
    }
    // Message not found
    return null;
}
Also used : MailboxName(com.zimbra.cs.mailclient.imap.MailboxName) ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) ResponseText(com.zimbra.cs.mailclient.imap.ResponseText) CopyResult(com.zimbra.cs.mailclient.imap.CopyResult)

Example 3 with MailboxName

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

the class TestImap method testOverflowAppend.

@Test
public void testOverflowAppend() throws Exception {
    assertTrue(connection.hasCapability("UIDPLUS"));
    int oldReadTimeout = connection.getConfig().getReadTimeout();
    try {
        connection.setReadTimeout(10);
        Flags flags = Flags.fromSpec("afs");
        Date date = new Date(System.currentTimeMillis());
        ImapRequest req = connection.newRequest(CAtom.APPEND, new MailboxName("INBOX"));
        req.addParam("{" + ((long) (Integer.MAX_VALUE) + 1) + "+}");
        ImapResponse resp = req.send();
        assertTrue(resp.isNO() || resp.isBAD());
        req = connection.newRequest(CAtom.APPEND, new MailboxName("INBOX"));
        req.addParam("{" + ((long) (Integer.MAX_VALUE) + 1) + "}");
        resp = req.send();
        assertTrue(resp.isNO() || resp.isBAD());
    } finally {
        connection.setReadTimeout(oldReadTimeout);
    }
}
Also used : MailboxName(com.zimbra.cs.mailclient.imap.MailboxName) ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) ImapResponse(com.zimbra.cs.mailclient.imap.ImapResponse) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

ImapRequest (com.zimbra.cs.mailclient.imap.ImapRequest)3 MailboxName (com.zimbra.cs.mailclient.imap.MailboxName)3 ResponseText (com.zimbra.cs.mailclient.imap.ResponseText)2 AppendResult (com.zimbra.cs.mailclient.imap.AppendResult)1 CopyResult (com.zimbra.cs.mailclient.imap.CopyResult)1 Flags (com.zimbra.cs.mailclient.imap.Flags)1 ImapResponse (com.zimbra.cs.mailclient.imap.ImapResponse)1 Date (java.sql.Date)1 Test (org.junit.Test)1