private String getSenderEmailAddress(Message message) { Address[] from = message.getFrom(); if (from == null || from.length == 0) { return null; } return from[0].getAddress(); }
public void delete(List<? extends Message> msgs, String trashFolder) throws MessagingException { for (Message message : msgs) { Message myMessage = getMessage(message.getUid()); myMessage.delete(trashFolder); } }
private void checkConnectionNotNull(ImapConnection conn) throws MessagingException { if (conn == null) { String message = "Could not establish connection for IDLE"; pushReceiver.pushError(message, null); throw new MessagingException(message); } }
@Override public boolean equals(Object o) { if (o == null || !(o instanceof Message)) { return false; } Message other = (Message)o; return (getUid().equals(other.getUid()) && getFolder().getServerId().equals(other.getFolder().getServerId())); }
@Override public void writeTo(OutputStream os) throws IOException { try { Multipart multipartSignedMultipart = (Multipart) signedPart.getBody(); BodyPart signatureBodyPart = multipartSignedMultipart.getBodyPart(0); Timber.d("signed data type: %s", signatureBodyPart.getMimeType()); signatureBodyPart.writeTo(os); } catch (MessagingException e) { Timber.e(e, "Exception while writing message to crypto provider"); } } };
private static String getJisVariantFromFromHeaders(Message message) { Address addresses[] = message.getFrom(); if (addresses == null || addresses.length == 0) { return null; } return getJisVariantFromAddress(addresses[0].getAddress()); }
public static void setEncoding(Part part, String encoding) throws MessagingException { Body body = part.getBody(); if (body != null) { body.setEncoding(encoding); } part.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, encoding); } }
static Part getPart(Part searchRootPart, int... indexes) { Part part = searchRootPart; for (int index : indexes) { part = ((Multipart) part.getBody()).getBodyPart(index); } return part; } }
public Recipient(String name, String email, String addressLabel, long contactId, String lookupKey, int timesContacted, String sortKey) { this.address = new Address(email, name); this.contactId = contactId; this.addressLabel = addressLabel; this.cryptoStatus = RecipientCryptoStatus.UNDEFINED; this.contactLookupKey = lookupKey; this.timesContacted = timesContacted; this.sortKey = sortKey; }
private ServerSettings createServerSettings() { return new ServerSettings( "pop3", "server", 12345, ConnectionSecurity.SSL_TLS_REQUIRED, AuthType.PLAIN, "user", "password", null); } }
private static void closeFolder(Folder f) { if (f != null) { f.close(); } }
public void setRecipient(RecipientType type, Address address) { setRecipients(type, new Address[] { address }); }
/** * This method calls setFlag(Flag, boolean) * @param flags * @param set */ public void setFlags(final Set<Flag> flags, boolean set) throws MessagingException { for (Flag flag : flags) { setFlag(flag, set); } }
private static Message getMessageFromPart(Part part) { while (part != null) { if (part instanceof Message) return (Message)part; if (!(part instanceof BodyPart)) return null; Multipart multipart = ((BodyPart)part).getParent(); if (multipart == null) return null; part = multipart.getParent(); } return null; }
@Override public boolean equals(Object o) { // Equality is entirely up to the address return o instanceof Recipient && address.equals(((Recipient) o).address); }
public static void setDebugSensitive(boolean b) { if (debugStatus instanceof WritableDebugStatus) { ((WritableDebugStatus) debugStatus).setSensitive(b); } }
public static void setDebug(boolean b) { if (debugStatus instanceof WritableDebugStatus) { ((WritableDebugStatus) debugStatus).setEnabled(b); } }
public CertificateValidationException(final String message, Throwable throwable) { super(message, throwable); mReason = Reason.Unknown; scanForCause(); }
private static Address[] stringArrayToAddressArray(String[] emails) { Address addresses[] = new Address[emails.length]; for (int i = 0; i < emails.length; i++) { addresses[i] = new Address(emails[i]); } return addresses; } }
private static void closeFolder(Folder folder) { if (folder != null) { folder.close(); } }