Search in sources :

Example 11 with MessagingException

use of com.android.voicemail.impl.mail.MessagingException in project android_packages_apps_Dialer by LineageOS.

the class ImapFolder method doSelect.

/**
 * Selects the folder for use. Before performing any operations on this folder, it must be
 * selected.
 */
private void doSelect() throws IOException, MessagingException {
    final List<ImapResponse> responses = mConnection.executeSimpleCommand(String.format(Locale.US, ImapConstants.SELECT + " \"%s\"", mName));
    // Assume the folder is opened read-write; unless we are notified otherwise
    mMode = MODE_READ_WRITE;
    int messageCount = -1;
    for (ImapResponse response : responses) {
        if (response.isDataResponse(1, ImapConstants.EXISTS)) {
            messageCount = response.getStringOrEmpty(0).getNumberOrZero();
        } else if (response.isOk()) {
            final ImapString responseCode = response.getResponseCodeOrEmpty();
            if (responseCode.is(ImapConstants.READ_ONLY)) {
                mMode = MODE_READ_ONLY;
            } else if (responseCode.is(ImapConstants.READ_WRITE)) {
                mMode = MODE_READ_WRITE;
            }
        } else if (response.isTagged()) {
            // Not OK
            mStore.getImapHelper().handleEvent(OmtpEvents.DATA_MAILBOX_OPEN_FAILED);
            throw new MessagingException("Can't open mailbox: " + response.getStatusResponseTextOrEmpty());
        }
    }
    if (messageCount == -1) {
        throw new MessagingException("Did not find message count during select");
    }
    mMessageCount = messageCount;
    mExists = true;
}
Also used : MessagingException(com.android.voicemail.impl.mail.MessagingException) ImapResponse(com.android.voicemail.impl.mail.store.imap.ImapResponse) ImapString(com.android.voicemail.impl.mail.store.imap.ImapString)

Example 12 with MessagingException

use of com.android.voicemail.impl.mail.MessagingException in project android_packages_apps_Dialer by LineageOS.

the class ImapResponseParser method parseLiteral.

private ImapString parseLiteral() throws IOException, MessagingException {
    expect('{');
    final int size;
    try {
        size = Integer.parseInt(readUntil('}'));
    } catch (NumberFormatException nfe) {
        throw new MessagingException("Invalid length in literal");
    }
    if (size < 0) {
        throw new MessagingException("Invalid negative length in literal");
    }
    expect('\r');
    expect('\n');
    FixedLengthInputStream in = new FixedLengthInputStream(mIn, size);
    if (size > mLiteralKeepInMemoryThreshold) {
        return new ImapTempFileLiteral(in);
    } else {
        return new ImapMemoryLiteral(in);
    }
}
Also used : FixedLengthInputStream(com.android.voicemail.impl.mail.FixedLengthInputStream) MessagingException(com.android.voicemail.impl.mail.MessagingException)

Aggregations

MessagingException (com.android.voicemail.impl.mail.MessagingException)12 IOException (java.io.IOException)5 Message (com.android.voicemail.impl.mail.Message)4 MimeMessage (com.android.voicemail.impl.mail.internet.MimeMessage)3 ImapResponse (com.android.voicemail.impl.mail.store.imap.ImapResponse)3 ImapString (com.android.voicemail.impl.mail.store.imap.ImapString)3 MimeBodyPart (com.android.voicemail.impl.mail.internet.MimeBodyPart)2 ImapMessage (com.android.voicemail.impl.mail.store.ImapStore.ImapMessage)2 ImapList (com.android.voicemail.impl.mail.store.imap.ImapList)2 Network (android.net.Network)1 ArrayMap (android.util.ArrayMap)1 Base64DataException (android.util.Base64DataException)1 Voicemail (com.android.voicemail.impl.Voicemail)1 ImapHelper (com.android.voicemail.impl.imap.ImapHelper)1 InitializingException (com.android.voicemail.impl.imap.ImapHelper.InitializingException)1 AuthenticationFailedException (com.android.voicemail.impl.mail.AuthenticationFailedException)1 CertificateValidationException (com.android.voicemail.impl.mail.CertificateValidationException)1 FetchProfile (com.android.voicemail.impl.mail.FetchProfile)1 FixedLengthInputStream (com.android.voicemail.impl.mail.FixedLengthInputStream)1 Part (com.android.voicemail.impl.mail.Part)1