Search in sources :

Example 1 with MessagingException

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

the class MimeMessage method getSentDate.

@Override
public Date getSentDate() throws MessagingException {
    if (mSentDate == null) {
        try {
            DateTimeField field = (DateTimeField) DefaultFieldParser.parse("Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Date")));
            mSentDate = field.getDate();
        // TODO: We should make it more clear what exceptions can be thrown here,
        // and whether they reflect a normal or error condition.
        } catch (Exception e) {
            LogUtils.v(LogUtils.TAG, "Message missing Date header");
        }
    }
    if (mSentDate == null) {
        // If we still don't have a date, fall back to "Delivery-date"
        try {
            DateTimeField field = (DateTimeField) DefaultFieldParser.parse("Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Delivery-date")));
            mSentDate = field.getDate();
        // TODO: We should make it more clear what exceptions can be thrown here,
        // and whether they reflect a normal or error condition.
        } catch (Exception e) {
            LogUtils.v(LogUtils.TAG, "Message also missing Delivery-Date header");
        }
    }
    return mSentDate;
}
Also used : DateTimeField(org.apache.james.mime4j.dom.field.DateTimeField) MimeException(org.apache.james.mime4j.MimeException) IOException(java.io.IOException) MessagingException(com.android.voicemail.impl.mail.MessagingException)

Example 2 with MessagingException

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

the class ImapConnection method open.

public void open() throws IOException, MessagingException {
    if (mTransport != null && mTransport.isOpen()) {
        return;
    }
    try {
        // copy configuration into a clean transport, if necessary
        if (mTransport == null) {
            mTransport = mImapStore.cloneTransport();
        }
        mTransport.open();
        createParser();
        // The server should greet us with something like
        // * OK IMAP4rev1 Server
        // consume the response before doing anything else.
        ImapResponse response = mParser.readResponse(false);
        if (!response.isOk()) {
            mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_INVALID_INITIAL_SERVER_RESPONSE);
            throw new MessagingException(MessagingException.AUTHENTICATION_FAILED_OR_SERVER_ERROR, "Invalid server initial response");
        }
        queryCapability();
        maybeDoStartTls();
        // LOGIN
        doLogin();
    } catch (SSLException e) {
        LogUtils.d(TAG, "SSLException ", e);
        mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_SSL_EXCEPTION);
        throw new CertificateValidationException(e.getMessage(), e);
    } catch (IOException ioe) {
        LogUtils.d(TAG, "IOException", ioe);
        mImapStore.getImapHelper().handleEvent(OmtpEvents.DATA_IOE_ON_OPEN);
        throw ioe;
    } finally {
        destroyResponses();
    }
}
Also used : MessagingException(com.android.voicemail.impl.mail.MessagingException) ImapResponse(com.android.voicemail.impl.mail.store.imap.ImapResponse) CertificateValidationException(com.android.voicemail.impl.mail.CertificateValidationException) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException)

Example 3 with MessagingException

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

the class ImapHelper method openImapFolder.

private ImapFolder openImapFolder(String modeReadWrite) {
    try {
        if (mImapStore == null) {
            return null;
        }
        ImapFolder folder = new ImapFolder(mImapStore, ImapConstants.INBOX);
        folder.open(modeReadWrite);
        return folder;
    } catch (MessagingException e) {
        LogUtils.e(TAG, e, "Messaging Exception");
    }
    return null;
}
Also used : ImapFolder(com.android.voicemail.impl.mail.store.ImapFolder) MessagingException(com.android.voicemail.impl.mail.MessagingException)

Example 4 with MessagingException

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

the class ImapHelper method closeNewUserTutorial.

public void closeNewUserTutorial() throws MessagingException {
    ImapConnection connection = mImapStore.getConnection();
    try {
        String command = getConfig().getProtocol().getCommand(OmtpConstants.IMAP_CLOSE_NUT);
        connection.executeSimpleCommand(command, false);
    } catch (IOException ioe) {
        throw new MessagingException(MessagingException.SERVER_ERROR, ioe.toString());
    } finally {
        connection.destroyResponses();
    }
}
Also used : MessagingException(com.android.voicemail.impl.mail.MessagingException) IOException(java.io.IOException) ImapConnection(com.android.voicemail.impl.mail.store.ImapConnection)

Example 5 with MessagingException

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

the class ImapHelper method fetchVoicemailPayload.

public boolean fetchVoicemailPayload(VoicemailFetchedCallback callback, final String uid) {
    try {
        mFolder = openImapFolder(ImapFolder.MODE_READ_WRITE);
        if (mFolder == null) {
            // This means we were unable to successfully open the folder.
            return false;
        }
        Message message = mFolder.getMessage(uid);
        if (message == null) {
            return false;
        }
        VoicemailPayload voicemailPayload = fetchVoicemailPayload(message);
        callback.setVoicemailContent(voicemailPayload);
        return true;
    } catch (MessagingException e) {
    } finally {
        closeImapFolder();
    }
    return false;
}
Also used : Message(com.android.voicemail.impl.mail.Message) MimeMessage(com.android.voicemail.impl.mail.internet.MimeMessage) 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