public static String getAlertText(ImapResponse response) { if (response.size() < 3 || !response.isList(1)) { return null; } ImapList responseTextCode = response.getList(1); if (responseTextCode.size() != 1 || !equalsIgnoreCase(responseTextCode.get(0), ALERT_RESPONSE_CODE)) { return null; } return response.getString(2); } }
private void readContinuationRequest(ImapResponseCallback callback) throws IOException { parseCommandContinuationRequest(); response = ImapResponse.newContinuationRequest(callback); skipIfSpace(); String rest = readStringUntilEndOfLine(); response.add(rest); }
private void upgradeToTlsIfNecessary() throws IOException, MessagingException, GeneralSecurityException { if (settings.getConnectionSecurity() == STARTTLS_REQUIRED) { upgradeToTls(); } }
protected List<ImapMessage> getMessages(final Set<Long> mesgSeqs, final boolean includeDeleted, final MessageRetrievalListener<ImapMessage> listener) throws MessagingException { checkOpen(); try { String commandSuffix = includeDeleted ? "" : " NOT DELETED"; List<ImapResponse> imapResponses = connection.executeCommandWithIdSet(Commands.UID_SEARCH, commandSuffix, mesgSeqs); SearchResponse searchResponse = SearchResponse.parse(imapResponses); return getMessages(searchResponse, listener); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } }
public boolean wasByeResponseReceived() { for (ImapResponse response : responses) { if (response.getTag() == null && response.size() >= 1 && equalsIgnoreCase(response.get(0), Responses.BYE)) { return true; } } return false; }
private void parseListResponse(ImapResponse response) throws IOException { expect(' '); parseList(response, '(', ')'); expect(' '); String delimiter = parseQuotedOrNil(); response.add(delimiter); expect(' '); String name = parseString(); response.add(name); expect('\r'); expect('\n'); }
public Object getKeyedValue(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return get(i + 1); } } return null; }
private boolean isListResponse(ImapResponse response) { boolean responseTooShort = response.size() < 4; if (responseTooShort) { return false; } boolean isListResponse = equalsIgnoreCase(response.get(0), Responses.LIST); boolean hierarchyDelimiterValid = response.get(2) instanceof String; return isListResponse && hierarchyDelimiterValid; }
protected long getHighestUid() throws MessagingException { try { List<ImapResponse> responses = executeSimpleCommand("UID SEARCH *:*"); SearchResponse searchResponse = SearchResponse.parse(responses); return extractHighestUid(searchResponse); } catch (NegativeImapResponseException e) { return -1L; } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } }
public String getAlertText() { if (alertText == null) { ImapResponse lastResponse = getLastResponse(); alertText = AlertResponse.getAlertText(lastResponse); } return alertText; }
private ImapConnection simpleOpenWithCapabilities(MockImapServer server, String postAuthCapabilities) throws Exception { simpleOpenDialog(server, postAuthCapabilities); ImapConnection imapConnection = startServerAndCreateImapConnection(server); imapConnection.open(); return imapConnection; }
private boolean openConnectionIfNecessary() throws MessagingException { ImapConnection oldConnection = connection; internalOpen(OPEN_MODE_RO); ImapConnection conn = connection; checkConnectionNotNull(conn); checkConnectionIdleCapable(conn); return conn != oldConnection; }
private void readUntaggedResponse(ImapResponseCallback callback) throws IOException { parseUntaggedResponse(); response = ImapResponse.newUntaggedResponse(callback); readTokens(response); }
private void readTaggedResponse(ImapResponseCallback callback) throws IOException { String tag = parseTaggedResponse(); response = ImapResponse.newTaggedResponse(callback, tag); readTokens(response); }
ImapConnection createImapConnection() { return new ImapConnection( new StoreImapSettings(), mTrustedSocketFactory, connectivityManager, oauthTokenProvider); }
public List<ImapResponse> readStatusResponse(String tag, String commandToLog, UntaggedHandler untaggedHandler) throws IOException, NegativeImapResponseException { return responseParser.readStatusResponse(tag, commandToLog, getLogId(), untaggedHandler); }
private NamespaceResponse parse(String response) throws IOException { ImapResponse imapResponse = createImapResponse(response); return NamespaceResponse.parse(imapResponse); } }
private void retrievePathDelimiterIfNecessary() throws IOException, MessagingException { if (settings.getPathDelimiter() == null) { retrievePathDelimiter(); } }
public boolean containsKey(String key) { if (key == null) { return false; } for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return true; } } return false; }