public TracingWakeLock(int flags, String ntag) { tag = ntag; wakeLock = pm.newWakeLock(flags, tag); id = wakeLockId.getAndIncrement(); if (K9MailLib.isDebug()) { Timber.v("TracingWakeLock for tag %s / id %d: Create", tag, id); } }
private void parseOptionalSizeValue(Map<String, String> extensions) { if (extensions.containsKey("SIZE")) { String optionalsizeValue = extensions.get("SIZE"); if (optionalsizeValue != null && !"".equals(optionalsizeValue)) { try { largestAcceptableMessage = Integer.parseInt(optionalsizeValue); } catch (NumberFormatException e) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) { Timber.d(e, "Tried to parse %s and get an int", optionalsizeValue); } } } } }
public void sendContinuation(String continuation) throws IOException { outputStream.write(continuation.getBytes()); outputStream.write('\r'); outputStream.write('\n'); outputStream.flush(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { Timber.v("%s>>> %s", getLogId(), continuation); } }
protected boolean isIdleCapable() { if (K9MailLib.isDebug()) { Timber.v("Connection %s has %d capabilities", getLogId(), capabilities.size()); } return capabilities.contains(Capabilities.IDLE); }
public static synchronized TracingPowerManager getPowerManager(Context context) { Context appContext = context.getApplicationContext(); if (tracingPowerManager == null) { if (K9MailLib.isDebug()) { Timber.v("Creating TracingPowerManager"); } tracingPowerManager = new TracingPowerManager(appContext); } return tracingPowerManager; }
private String readLine() throws IOException { StringBuilder sb = new StringBuilder(); int d; while ((d = inputStream.read()) != -1) { char c = (char) d; if (c == '\n') { break; } else if (c != '\r') { sb.append(c); } } String ret = sb.toString(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) Timber.d("SMTP <<< %s", ret); return ret; }
@Override public void acquire(long timeout) { synchronized (wakeLock) { wakeLock.acquire(timeout); } if (K9MailLib.isDebug()) { Timber.v("TracingWakeLock for tag %s / id %d for %d ms: acquired", tag, id, timeout); } raiseNotification(); if (startTime == null) { startTime = SystemClock.elapsedRealtime(); } this.timeout = timeout; }
@Override public void acquire() { synchronized (wakeLock) { wakeLock.acquire(); } raiseNotification(); if (K9MailLib.isDebug()) { Timber.w("TracingWakeLock for tag %s / id %d: acquired with no timeout. K-9 Mail should not do this", tag, id); } if (startTime == null) { startTime = SystemClock.elapsedRealtime(); } timeout = null; }
@Override public void open() throws MessagingException { if (K9MailLib.isDebug()) Timber.d( ">>> open called on WebDavTransport "); store.getHttpClient(); }
public WebDavTransport(TrustManagerFactory trustManagerFactory, WebDavStoreSettings serverSettings, StoreConfig storeConfig) { store = new WebDavStore(trustManagerFactory, serverSettings, storeConfig); if (K9MailLib.isDebug()) Timber.d(">>> New WebDavTransport creation complete"); }
private void indexMessage(int msgNum, Pop3Message message) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { Timber.d("Adding index for UID %s to msgNum %d", message.getUid(), msgNum); } msgNumToMsgMap.put(msgNum, message); uidToMsgMap.put(message.getUid(), message); uidToMsgNumMap.put(message.getUid(), msgNum); }
private void notifyMessagesArrived(long startUid, long uidNext) { if (K9MailLib.isDebug()) { Timber.i("Needs sync from uid %d to %d for %s", startUid, uidNext, getLogId()); } int count = (int) (uidNext - startUid); List<Message> messages = new ArrayList<>(count); for (long uid = startUid; uid < uidNext; uid++) { ImapMessage message = new ImapMessage(Long.toString(uid), ImapFolderPusher.this); messages.add(message); } pushReceiver.messagesArrived(ImapFolderPusher.this, messages); }
private void requestCapabilitiesIfNecessary() throws IOException, MessagingException { if (!capabilities.isEmpty()) { return; } if (K9MailLib.isDebug()) { Timber.i("Did not get capabilities in banner, requesting CAPABILITY for %s", getLogId()); } requestCapabilities(); }
private void processStoredUntaggedResponses() throws MessagingException { while (true) { List<ImapResponse> untaggedResponses = getAndClearStoredUntaggedResponses(); if (untaggedResponses.isEmpty()) { break; } if (K9MailLib.isDebug()) { Timber.i("Processing %d untagged responses from previous commands for %s", untaggedResponses.size(), getLogId()); } processUntaggedResponses(untaggedResponses); } }
private void readInitialResponse() throws IOException { ImapResponse initialResponse = responseParser.readResponse(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { Timber.v("%s <<< %s", getLogId(), initialResponse); } extractCapabilities(Collections.singletonList(initialResponse)); }
private List<ImapResponse> extractCapabilities(List<ImapResponse> responses) { CapabilityResponse capabilityResponse = CapabilityResponse.parse(responses); if (capabilityResponse != null) { Set<String> receivedCapabilities = capabilityResponse.getCapabilities(); if (K9MailLib.isDebug()) { Timber.d("Saving %s capabilities for %s", receivedCapabilities, getLogId()); } capabilities = receivedCapabilities; } return responses; }
public ImapResponse readResponse(ImapResponseCallback callback) throws IOException { try { ImapResponse response = responseParser.readResponse(callback); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { Timber.v("%s<<<%s", getLogId(), response); } return response; } catch (IOException e) { close(); throw e; } }
private long getOldUidNext() { long oldUidNext = -1L; try { String serializedPushState = pushReceiver.getPushState(getServerId()); ImapPushState pushState = ImapPushState.parse(serializedPushState); oldUidNext = pushState.uidNext; if (K9MailLib.isDebug()) { Timber.i("Got oldUidNext %d for %s", oldUidNext, getLogId()); } } catch (Exception e) { Timber.e(e, "Unable to get oldUidNext for %s", getLogId()); } return oldUidNext; } }
private void handleNamespace() throws IOException, MessagingException { List<ImapResponse> responses = executeSimpleCommand(Commands.NAMESPACE); NamespaceResponse namespaceResponse = NamespaceResponse.parse(responses); if (namespaceResponse != null) { String prefix = namespaceResponse.getPrefix(); String hierarchyDelimiter = namespaceResponse.getHierarchyDelimiter(); settings.setPathPrefix(prefix); settings.setPathDelimiter(hierarchyDelimiter); settings.setCombinedPrefix(null); if (K9MailLib.isDebug()) { Timber.d("Got path '%s' and separator '%s'", prefix, hierarchyDelimiter); } } }
private void startTLS() throws IOException, MessagingException, GeneralSecurityException { executeSimpleCommand(Commands.STARTTLS); String host = settings.getHost(); int port = settings.getPort(); String clientCertificateAlias = settings.getClientCertificateAlias(); socket = socketFactory.createSocket(socket, host, port, clientCertificateAlias); configureSocket(); setUpStreamsAndParserFromSocket(); // Per RFC 2595 (3.1): Once TLS has been started, reissue CAPABILITY command if (K9MailLib.isDebug()) { Timber.i("Updating capabilities after STARTTLS for %s", getLogId()); } requestCapabilities(); }