Search in sources :

Example 1 with ImapException

use of com.android.voicemail.impl.mail.store.ImapStore.ImapException in project android_packages_apps_Dialer by LineageOS.

the class ImapConnection method getCommandResponses.

/**
 * Read and return all of the responses from the most recent command sent to the server
 *
 * @return a list of ImapResponses
 * @throws IOException
 * @throws MessagingException
 */
List<ImapResponse> getCommandResponses() throws IOException, MessagingException {
    final List<ImapResponse> responses = new ArrayList<ImapResponse>();
    ImapResponse response;
    do {
        response = parser.readResponse(false);
        responses.add(response);
    } while (!(response.isTagged() || response.isContinuationRequest()));
    if (!(response.isOk() || response.isContinuationRequest())) {
        final String toString = response.toString();
        final String status = response.getStatusOrEmpty().getString();
        final String statusMessage = response.getStatusResponseTextOrEmpty().getString();
        final String alert = response.getAlertTextOrEmpty().getString();
        final String responseCode = response.getResponseCodeOrEmpty().getString();
        destroyResponses();
        throw new ImapException(toString, status, statusMessage, alert, responseCode);
    }
    return responses;
}
Also used : ImapException(com.android.voicemail.impl.mail.store.ImapStore.ImapException) ArrayList(java.util.ArrayList) ImapResponse(com.android.voicemail.impl.mail.store.imap.ImapResponse)

Example 2 with ImapException

use of com.android.voicemail.impl.mail.store.ImapStore.ImapException in project android_packages_apps_Dialer by MoKee.

the class ImapFolder method searchForUids.

@VisibleForTesting
String[] searchForUids(String searchCriteria) throws MessagingException {
    checkOpen();
    try {
        try {
            final String command = ImapConstants.UID_SEARCH + " " + searchCriteria;
            final String[] result = getSearchUids(connection.executeSimpleCommand(command));
            VvmLog.d(TAG, "searchForUids '" + searchCriteria + "' results: " + result.length);
            return result;
        } catch (ImapException me) {
            VvmLog.d(TAG, "ImapException in search: " + searchCriteria, me);
            // Not found
            return Utility.EMPTY_STRINGS;
        } catch (IOException ioe) {
            VvmLog.d(TAG, "IOException in search: " + searchCriteria, ioe);
            store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE);
            throw ioExceptionHandler(connection, ioe);
        }
    } finally {
        destroyResponses();
    }
}
Also used : ImapException(com.android.voicemail.impl.mail.store.ImapStore.ImapException) ImapString(com.android.voicemail.impl.mail.store.imap.ImapString) IOException(java.io.IOException) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 3 with ImapException

use of com.android.voicemail.impl.mail.store.ImapStore.ImapException in project android_packages_apps_Dialer by LineageOS.

the class ImapFolder method searchForUids.

@VisibleForTesting
String[] searchForUids(String searchCriteria) throws MessagingException {
    checkOpen();
    try {
        try {
            final String command = ImapConstants.UID_SEARCH + " " + searchCriteria;
            final String[] result = getSearchUids(connection.executeSimpleCommand(command));
            VvmLog.d(TAG, "searchForUids '" + searchCriteria + "' results: " + result.length);
            return result;
        } catch (ImapException me) {
            VvmLog.d(TAG, "ImapException in search: " + searchCriteria, me);
            // Not found
            return Utility.EMPTY_STRINGS;
        } catch (IOException ioe) {
            VvmLog.d(TAG, "IOException in search: " + searchCriteria, ioe);
            store.getImapHelper().handleEvent(OmtpEvents.DATA_GENERIC_IMAP_IOE);
            throw ioExceptionHandler(connection, ioe);
        }
    } finally {
        destroyResponses();
    }
}
Also used : ImapException(com.android.voicemail.impl.mail.store.ImapStore.ImapException) ImapString(com.android.voicemail.impl.mail.store.imap.ImapString) IOException(java.io.IOException) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 4 with ImapException

use of com.android.voicemail.impl.mail.store.ImapStore.ImapException in project android_packages_apps_Dialer by MoKee.

the class ImapConnection method getCommandResponses.

/**
 * Read and return all of the responses from the most recent command sent to the server
 *
 * @return a list of ImapResponses
 * @throws IOException
 * @throws MessagingException
 */
List<ImapResponse> getCommandResponses() throws IOException, MessagingException {
    final List<ImapResponse> responses = new ArrayList<ImapResponse>();
    ImapResponse response;
    do {
        response = parser.readResponse(false);
        responses.add(response);
    } while (!(response.isTagged() || response.isContinuationRequest()));
    if (!(response.isOk() || response.isContinuationRequest())) {
        final String toString = response.toString();
        final String status = response.getStatusOrEmpty().getString();
        final String statusMessage = response.getStatusResponseTextOrEmpty().getString();
        final String alert = response.getAlertTextOrEmpty().getString();
        final String responseCode = response.getResponseCodeOrEmpty().getString();
        destroyResponses();
        throw new ImapException(toString, status, statusMessage, alert, responseCode);
    }
    return responses;
}
Also used : ImapException(com.android.voicemail.impl.mail.store.ImapStore.ImapException) ArrayList(java.util.ArrayList) ImapResponse(com.android.voicemail.impl.mail.store.imap.ImapResponse)

Aggregations

ImapException (com.android.voicemail.impl.mail.store.ImapStore.ImapException)4 VisibleForTesting (android.support.annotation.VisibleForTesting)2 ImapResponse (com.android.voicemail.impl.mail.store.imap.ImapResponse)2 ImapString (com.android.voicemail.impl.mail.store.imap.ImapString)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2