diff options
Diffstat (limited to 'java/com/android/voicemail/impl/mail/internet')
6 files changed, 142 insertions, 142 deletions
diff --git a/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java b/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java index 753b70f23..d1521bdcb 100644 --- a/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java +++ b/java/com/android/voicemail/impl/mail/internet/BinaryTempFileBody.java @@ -36,7 +36,7 @@ import org.apache.commons.io.IOUtils; * closed the file is deleted and the Body should be considered disposed of. */ public class BinaryTempFileBody implements Body { - private File mFile; + private File file; /** * An alternate way to put data into a BinaryTempFileBody is to simply supply an already- created @@ -45,19 +45,19 @@ public class BinaryTempFileBody implements Body { * @param filePath The file containing the data to be stored on disk temporarily */ public void setFile(String filePath) { - mFile = new File(filePath); + file = new File(filePath); } public OutputStream getOutputStream() throws IOException { - mFile = File.createTempFile("body", null, TempDirectory.getTempDirectory()); - mFile.deleteOnExit(); - return new FileOutputStream(mFile); + file = File.createTempFile("body", null, TempDirectory.getTempDirectory()); + file.deleteOnExit(); + return new FileOutputStream(file); } @Override public InputStream getInputStream() throws MessagingException { try { - return new BinaryTempFileBodyInputStream(new FileInputStream(mFile)); + return new BinaryTempFileBodyInputStream(new FileInputStream(file)); } catch (IOException ioe) { throw new MessagingException("Unable to open body", ioe); } @@ -69,7 +69,7 @@ public class BinaryTempFileBody implements Body { Base64OutputStream base64Out = new Base64OutputStream(out, Base64.CRLF | Base64.NO_CLOSE); IOUtils.copy(in, base64Out); base64Out.close(); - mFile.delete(); + file.delete(); in.close(); } @@ -81,7 +81,7 @@ public class BinaryTempFileBody implements Body { @Override public void close() throws IOException { super.close(); - mFile.delete(); + file.delete(); } } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java b/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java index 2add76c72..12a2b0b7d 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeBodyPart.java @@ -27,10 +27,10 @@ import java.util.regex.Pattern; /** TODO this is a close approximation of Message, need to update along with Message. */ public class MimeBodyPart extends BodyPart { - protected MimeHeader mHeader = new MimeHeader(); - protected MimeHeader mExtendedHeader; - protected Body mBody; - protected int mSize; + protected MimeHeader header = new MimeHeader(); + protected MimeHeader extendedHeader; + protected Body body; + protected int size; // regex that matches content id surrounded by "<>" optionally. private static final Pattern REMOVE_OPTIONAL_BRACKETS = Pattern.compile("^<?([^>]+)>?$"); @@ -53,37 +53,37 @@ public class MimeBodyPart extends BodyPart { } protected String getFirstHeader(String name) throws MessagingException { - return mHeader.getFirstHeader(name); + return header.getFirstHeader(name); } @Override public void addHeader(String name, String value) throws MessagingException { - mHeader.addHeader(name, value); + header.addHeader(name, value); } @Override public void setHeader(String name, String value) throws MessagingException { - mHeader.setHeader(name, value); + header.setHeader(name, value); } @Override public String[] getHeader(String name) throws MessagingException { - return mHeader.getHeader(name); + return header.getHeader(name); } @Override public void removeHeader(String name) throws MessagingException { - mHeader.removeHeader(name); + header.removeHeader(name); } @Override public Body getBody() throws MessagingException { - return mBody; + return body; } @Override public void setBody(Body body) throws MessagingException { - this.mBody = body; + this.body = body; if (body instanceof Multipart) { Multipart multipart = ((Multipart) body); @@ -142,12 +142,12 @@ public class MimeBodyPart extends BodyPart { } public void setSize(int size) { - this.mSize = size; + this.size = size; } @Override public int getSize() throws MessagingException { - return mSize; + return size; } /** @@ -160,15 +160,15 @@ public class MimeBodyPart extends BodyPart { @Override public void setExtendedHeader(String name, String value) throws MessagingException { if (value == null) { - if (mExtendedHeader != null) { - mExtendedHeader.removeHeader(name); + if (extendedHeader != null) { + extendedHeader.removeHeader(name); } return; } - if (mExtendedHeader == null) { - mExtendedHeader = new MimeHeader(); + if (extendedHeader == null) { + extendedHeader = new MimeHeader(); } - mExtendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); + extendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); } /** @@ -180,21 +180,21 @@ public class MimeBodyPart extends BodyPart { */ @Override public String getExtendedHeader(String name) throws MessagingException { - if (mExtendedHeader == null) { + if (extendedHeader == null) { return null; } - return mExtendedHeader.getFirstHeader(name); + return extendedHeader.getFirstHeader(name); } /** Write the MimeMessage out in MIME format. */ @Override public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - mHeader.writeTo(out); + header.writeTo(out); writer.write("\r\n"); writer.flush(); - if (mBody != null) { - mBody.writeTo(out); + if (body != null) { + body.writeTo(out); } } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java index 8f0817650..00a9eccf2 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java @@ -45,10 +45,10 @@ public class MimeHeader { HEADER_ANDROID_ATTACHMENT_STORE_DATA }; - protected final ArrayList<Field> mFields = new ArrayList<Field>(); + protected final ArrayList<Field> fields = new ArrayList<Field>(); public void clear() { - mFields.clear(); + fields.clear(); } public String getFirstHeader(String name) throws MessagingException { @@ -60,7 +60,7 @@ public class MimeHeader { } public void addHeader(String name, String value) throws MessagingException { - mFields.add(new Field(name, value)); + fields.add(new Field(name, value)); } public void setHeader(String name, String value) throws MessagingException { @@ -73,7 +73,7 @@ public class MimeHeader { public String[] getHeader(String name) throws MessagingException { ArrayList<String> values = new ArrayList<String>(); - for (Field field : mFields) { + for (Field field : fields) { if (field.name.equalsIgnoreCase(name)) { values.add(field.value); } @@ -86,12 +86,12 @@ public class MimeHeader { public void removeHeader(String name) throws MessagingException { ArrayList<Field> removeFields = new ArrayList<Field>(); - for (Field field : mFields) { + for (Field field : fields) { if (field.name.equalsIgnoreCase(name)) { removeFields.add(field); } } - mFields.removeAll(removeFields); + fields.removeAll(removeFields); } /** @@ -101,11 +101,11 @@ public class MimeHeader { * empty */ public String writeToString() { - if (mFields.size() == 0) { + if (fields.size() == 0) { return null; } StringBuilder builder = new StringBuilder(); - for (Field field : mFields) { + for (Field field : fields) { if (!arrayContains(WRITE_OMIT_FIELDS, field.name)) { builder.append(field.name + ": " + field.value + "\r\n"); } @@ -115,7 +115,7 @@ public class MimeHeader { public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - for (Field field : mFields) { + for (Field field : fields) { if (!arrayContains(WRITE_OMIT_FIELDS, field.name)) { writer.write(field.name + ": " + field.value + "\r\n"); } @@ -140,7 +140,7 @@ public class MimeHeader { @Override public String toString() { - return (mFields == null) ? null : mFields.toString(); + return (fields == null) ? null : fields.toString(); } public static final boolean arrayContains(Object[] a, Object o) { diff --git a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java index 39378a092..2997ad8c5 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java @@ -53,24 +53,24 @@ import org.apache.james.mime4j.stream.Field; * It would be better to simply do it explicitly on local creation of new outgoing messages. */ public class MimeMessage extends Message { - private MimeHeader mHeader; - private MimeHeader mExtendedHeader; + private MimeHeader header; + private MimeHeader extendedHeader; // NOTE: The fields here are transcribed out of headers, and values stored here will supersede // the values found in the headers. Use caution to prevent any out-of-phase errors. In // particular, any adds/changes/deletes here must be echoed by changes in the parse() function. - private Address[] mFrom; - private Address[] mTo; - private Address[] mCc; - private Address[] mBcc; - private Address[] mReplyTo; - private Date mSentDate; - private Body mBody; - protected int mSize; - private boolean mInhibitLocalMessageId = false; + private Address[] from; + private Address[] to; + private Address[] cc; + private Address[] bcc; + private Address[] replyTo; + private Date sentDate; + private Body body; + protected int size; + private boolean inhibitLocalMessageId = false; // Shared random source for generating local message-id values - private static final java.util.Random sRandom = new java.util.Random(); + private static final java.util.Random random = new java.util.Random(); // In MIME, en_US-like date format should be used. In other words "MMM" should be encoded to // "Jan", not the other localized format like "Ene" (meaning January in locale es). @@ -86,7 +86,7 @@ public class MimeMessage extends Message { private static final Pattern END_OF_LINE = Pattern.compile("\r?\n"); public MimeMessage() { - mHeader = null; + header = null; } /** @@ -100,7 +100,7 @@ public class MimeMessage extends Message { sb.append("<"); for (int i = 0; i < 24; i++) { // We'll use a 5-bit range (0..31) - final int value = sRandom.nextInt() & 31; + final int value = random.nextInt() & 31; final char c = "0123456789abcdefghijklmnopqrstuv".charAt(value); sb.append(c); } @@ -125,14 +125,14 @@ public class MimeMessage extends Message { // Before parsing the input stream, clear all local fields that may be superceded by // the new incoming message. getMimeHeaders().clear(); - mInhibitLocalMessageId = true; - mFrom = null; - mTo = null; - mCc = null; - mBcc = null; - mReplyTo = null; - mSentDate = null; - mBody = null; + inhibitLocalMessageId = true; + from = null; + to = null; + cc = null; + bcc = null; + replyTo = null; + sentDate = null; + body = null; final MimeStreamParser parser = new MimeStreamParser(); parser.setContentHandler(new MimeMessageBuilder()); @@ -149,10 +149,10 @@ public class MimeMessage extends Message { * not creating the headers until needed. */ private MimeHeader getMimeHeaders() { - if (mHeader == null) { - mHeader = new MimeHeader(); + if (header == null) { + header = new MimeHeader(); } - return mHeader; + return header; } @Override @@ -162,40 +162,40 @@ public class MimeMessage extends Message { @Override public Date getSentDate() throws MessagingException { - if (mSentDate == null) { + if (sentDate == null) { try { DateTimeField field = (DateTimeField) DefaultFieldParser.parse( "Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Date"))); - mSentDate = field.getDate(); + sentDate = 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 (sentDate == 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(); + sentDate = 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; + return sentDate; } @Override public void setSentDate(Date sentDate) throws MessagingException { setHeader("Date", DATE_FORMAT.format(sentDate)); - this.mSentDate = sentDate; + this.sentDate = sentDate; } @Override @@ -253,7 +253,7 @@ public class MimeMessage extends Message { @Override public int getSize() throws MessagingException { - return mSize; + return size; } /** @@ -263,20 +263,20 @@ public class MimeMessage extends Message { @Override public Address[] getRecipients(String type) throws MessagingException { if (type == RECIPIENT_TYPE_TO) { - if (mTo == null) { - mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); + if (to == null) { + to = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); } - return mTo; + return to; } else if (type == RECIPIENT_TYPE_CC) { - if (mCc == null) { - mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); + if (cc == null) { + cc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); } - return mCc; + return cc; } else if (type == RECIPIENT_TYPE_BCC) { - if (mBcc == null) { - mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); + if (bcc == null) { + bcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); } - return mBcc; + return bcc; } else { throw new MessagingException("Unrecognized recipient type."); } @@ -290,26 +290,26 @@ public class MimeMessage extends Message { if (type == RECIPIENT_TYPE_TO) { if (addresses == null || addresses.length == 0) { removeHeader("To"); - this.mTo = null; + this.to = null; } else { setHeader("To", MimeUtility.fold(Address.toHeader(addresses), toLength)); - this.mTo = addresses; + this.to = addresses; } } else if (type == RECIPIENT_TYPE_CC) { if (addresses == null || addresses.length == 0) { removeHeader("CC"); - this.mCc = null; + this.cc = null; } else { setHeader("CC", MimeUtility.fold(Address.toHeader(addresses), ccLength)); - this.mCc = addresses; + this.cc = addresses; } } else if (type == RECIPIENT_TYPE_BCC) { if (addresses == null || addresses.length == 0) { removeHeader("BCC"); - this.mBcc = null; + this.bcc = null; } else { setHeader("BCC", MimeUtility.fold(Address.toHeader(addresses), bccLength)); - this.mBcc = addresses; + this.bcc = addresses; } } else { throw new MessagingException("Unrecognized recipient type."); @@ -330,14 +330,14 @@ public class MimeMessage extends Message { @Override public Address[] getFrom() throws MessagingException { - if (mFrom == null) { + if (from == null) { String list = MimeUtility.unfold(getFirstHeader("From")); if (list == null || list.length() == 0) { list = MimeUtility.unfold(getFirstHeader("Sender")); } - mFrom = Address.parse(list); + from = Address.parse(list); } - return mFrom; + return from; } @Override @@ -345,18 +345,18 @@ public class MimeMessage extends Message { final int fromLength = 6; // "From: " if (from != null) { setHeader("From", MimeUtility.fold(from.toHeader(), fromLength)); - this.mFrom = new Address[] {from}; + this.from = new Address[] {from}; } else { - this.mFrom = null; + this.from = null; } } @Override public Address[] getReplyTo() throws MessagingException { - if (mReplyTo == null) { - mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); + if (replyTo == null) { + replyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); } - return mReplyTo; + return replyTo; } @Override @@ -364,10 +364,10 @@ public class MimeMessage extends Message { final int replyToLength = 10; // "Reply-to: " if (replyTo == null || replyTo.length == 0) { removeHeader("Reply-to"); - mReplyTo = null; + this.replyTo = null; } else { setHeader("Reply-to", MimeUtility.fold(Address.toHeader(replyTo), replyToLength)); - mReplyTo = replyTo; + this.replyTo = replyTo; } } @@ -392,7 +392,7 @@ public class MimeMessage extends Message { @Override public String getMessageId() throws MessagingException { String messageId = getFirstHeader("Message-ID"); - if (messageId == null && !mInhibitLocalMessageId) { + if (messageId == null && !inhibitLocalMessageId) { messageId = generateMessageId(); setMessageId(messageId); } @@ -406,12 +406,12 @@ public class MimeMessage extends Message { @Override public Body getBody() throws MessagingException { - return mBody; + return body; } @Override public void setBody(Body body) throws MessagingException { - this.mBody = body; + this.body = body; if (body instanceof Multipart) { final Multipart multipart = ((Multipart) body); multipart.setParent(this); @@ -447,7 +447,7 @@ public class MimeMessage extends Message { public void removeHeader(String name) throws MessagingException { getMimeHeaders().removeHeader(name); if ("Message-ID".equalsIgnoreCase(name)) { - mInhibitLocalMessageId = true; + inhibitLocalMessageId = true; } } @@ -461,15 +461,15 @@ public class MimeMessage extends Message { @Override public void setExtendedHeader(String name, String value) throws MessagingException { if (value == null) { - if (mExtendedHeader != null) { - mExtendedHeader.removeHeader(name); + if (extendedHeader != null) { + extendedHeader.removeHeader(name); } return; } - if (mExtendedHeader == null) { - mExtendedHeader = new MimeHeader(); + if (extendedHeader == null) { + extendedHeader = new MimeHeader(); } - mExtendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); + extendedHeader.setHeader(name, END_OF_LINE.matcher(value).replaceAll("")); } /** @@ -481,10 +481,10 @@ public class MimeMessage extends Message { */ @Override public String getExtendedHeader(String name) throws MessagingException { - if (mExtendedHeader == null) { + if (extendedHeader == null) { return null; } - return mExtendedHeader.getFirstHeader(name); + return extendedHeader.getFirstHeader(name); } /** @@ -496,15 +496,15 @@ public class MimeMessage extends Message { */ public void setExtendedHeaders(String headers) throws MessagingException { if (TextUtils.isEmpty(headers)) { - mExtendedHeader = null; + extendedHeader = null; } else { - mExtendedHeader = new MimeHeader(); + extendedHeader = new MimeHeader(); for (final String header : END_OF_LINE.split(headers)) { final String[] tokens = header.split(":", 2); if (tokens.length != 2) { throw new MessagingException("Illegal extended headers: " + headers); } - mExtendedHeader.setHeader(tokens[0].trim(), tokens[1].trim()); + extendedHeader.setHeader(tokens[0].trim(), tokens[1].trim()); } } } @@ -515,8 +515,8 @@ public class MimeMessage extends Message { * @return "CR-NL-separated extended headers - null if extended header does not exist */ public String getExtendedHeaders() { - if (mExtendedHeader != null) { - return mExtendedHeader.writeToString(); + if (extendedHeader != null) { + return extendedHeader.writeToString(); } return null; } @@ -536,8 +536,8 @@ public class MimeMessage extends Message { // because it is intended to internal use. writer.write("\r\n"); writer.flush(); - if (mBody != null) { - mBody.writeTo(out); + if (body != null) { + body.writeTo(out); } } diff --git a/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java b/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java index 87b88b52a..6cb2c2701 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeMultipart.java @@ -25,25 +25,25 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; public class MimeMultipart extends Multipart { - protected String mPreamble; + protected String preamble; - protected String mContentType; + protected String contentType; - protected String mBoundary; + protected String boundary; - protected String mSubType; + protected String subType; public MimeMultipart() throws MessagingException { - mBoundary = generateBoundary(); + boundary = generateBoundary(); setSubType("mixed"); } public MimeMultipart(String contentType) throws MessagingException { - this.mContentType = contentType; + this.contentType = contentType; try { - mSubType = MimeUtility.getHeaderParameter(contentType, null).split("/")[1]; - mBoundary = MimeUtility.getHeaderParameter(contentType, "boundary"); - if (mBoundary == null) { + subType = MimeUtility.getHeaderParameter(contentType, null).split("/")[1]; + boundary = MimeUtility.getHeaderParameter(contentType, "boundary"); + if (boundary == null) { throw new MessagingException("MultiPart does not contain boundary: " + contentType); } } catch (Exception e) { @@ -65,40 +65,40 @@ public class MimeMultipart extends Multipart { } public String getPreamble() throws MessagingException { - return mPreamble; + return preamble; } public void setPreamble(String preamble) throws MessagingException { - this.mPreamble = preamble; + this.preamble = preamble; } @Override public String getContentType() throws MessagingException { - return mContentType; + return contentType; } public void setSubType(String subType) throws MessagingException { - this.mSubType = subType; - mContentType = String.format("multipart/%s; boundary=\"%s\"", subType, mBoundary); + this.subType = subType; + contentType = String.format("multipart/%s; boundary=\"%s\"", subType, boundary); } @Override public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); - if (mPreamble != null) { - writer.write(mPreamble + "\r\n"); + if (preamble != null) { + writer.write(preamble + "\r\n"); } - for (int i = 0, count = mParts.size(); i < count; i++) { - BodyPart bodyPart = mParts.get(i); - writer.write("--" + mBoundary + "\r\n"); + for (int i = 0, count = parts.size(); i < count; i++) { + BodyPart bodyPart = parts.get(i); + writer.write("--" + boundary + "\r\n"); writer.flush(); bodyPart.writeTo(out); writer.write("\r\n"); } - writer.write("--" + mBoundary + "--\r\n"); + writer.write("--" + boundary + "--\r\n"); writer.flush(); } @@ -108,6 +108,6 @@ public class MimeMultipart extends Multipart { } public String getSubTypeForTest() { - return mSubType; + return subType; } } diff --git a/java/com/android/voicemail/impl/mail/internet/TextBody.java b/java/com/android/voicemail/impl/mail/internet/TextBody.java index dae562508..506e1f52e 100644 --- a/java/com/android/voicemail/impl/mail/internet/TextBody.java +++ b/java/com/android/voicemail/impl/mail/internet/TextBody.java @@ -25,15 +25,15 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; public class TextBody implements Body { - String mBody; + String body; public TextBody(String body) { - this.mBody = body; + this.body = body; } @Override public void writeTo(OutputStream out) throws IOException, MessagingException { - byte[] bytes = mBody.getBytes("UTF-8"); + byte[] bytes = body.getBytes("UTF-8"); out.write(Base64.encode(bytes, Base64.CRLF)); } @@ -43,14 +43,14 @@ public class TextBody implements Body { * @return */ public String getText() { - return mBody; + return body; } /** Returns an InputStream that reads this body's text in UTF-8 format. */ @Override public InputStream getInputStream() throws MessagingException { try { - byte[] b = mBody.getBytes("UTF-8"); + byte[] b = body.getBytes("UTF-8"); return new ByteArrayInputStream(b); } catch (UnsupportedEncodingException usee) { return null; |