Commit Graph

192 Commits

Author SHA1 Message Date
Jan Berkel 40041ac0e0 Move local message code to local package
+ cut some helper dependencies
2014-12-12 15:02:59 +00:00
Jan Berkel 2e98ff56e5 Break dependencies 2014-12-12 13:35:36 +00:00
Jan Berkel 0024f39bc6 Local messages 2014-12-12 13:04:59 +00:00
Jan Berkel 6f4610dd5b Fix visibility 2014-12-12 00:30:41 +00:00
Jan Berkel e59adf46c0 Package visibility 2014-12-12 00:08:25 +00:00
Jan Berkel ca10e4d94a Use TextUtils.isEmpty 2014-12-11 21:56:26 +00:00
cketti 98b5d63909 Merge branch 'open_attachment_improvements'
Conflicts:
	src/com/fsck/k9/helper/Utility.java
2014-11-27 21:03:15 +01:00
cketti d9b6e10cbe Change the way the best view intent is determined
First we try the original MIME type unless it's application/octet-stream.
Then we try the MIME type inferred from the attachment's file extension.
Then we fall back to application/octet-stream.

In all cases we first try the content:// URI, then a file:// URI.
2014-11-18 22:55:51 +01:00
Art O Cathain 668ee71b6c fix tests on JVM 2014-10-11 12:10:07 +01:00
Art O Cathain 203dcfe2c3 use interfaces, not implementions 2014-10-04 12:00:48 +01:00
tobiasbaum dadf5e0865 Merge pull request #7 from artbristol/art/tidying
Art/tidying
2014-09-29 22:15:59 +02:00
Art O Cathain afb65d5ad7 remove some try-catch cruft 2014-09-28 11:39:32 +01:00
Tobias Baum 547eb74774 Changed access to mParts in MimeMultipart so that it can be private too 2014-09-22 21:54:02 +02:00
Tobias Baum b6079d6460 UCDetector warnings: Made things private, deleted unused methods and fields 2014-09-22 21:52:59 +02:00
Tobias Baum 545dd0db06 Added a getBodyparts method to Multipart so that foreach loops can be used. Removed unnecessary mutators from Multipart. 2014-09-14 11:13:34 +02:00
Tobias Baum 5513d5a99b Pulled down getSize from Part to Message which makes ImapBodyPart superfluous 2014-09-14 11:11:48 +02:00
Tobias Baum d467dca32c Added testcases for parsing and removed unused methods for parsing 2014-09-14 11:05:55 +02:00
Mike Perry d67a59b77f Fixes for cketti's code review on pull req #472
Leave the hostname == null checks so we can fall back if a hostname is not
found. Also convert message-id to upper case to match Apple Mail (for
privacy).
2014-06-13 17:49:26 -07:00
Mike Perry 38c90146e1 Issue 6372: Add preference for setting timezone to UTC.
This is a privacy preference to avoid leaking your current location while
replying to email.
2014-05-27 07:53:50 -07:00
Mike Perry 7ac7fe2cfe Issue 3559: Use From or ReplyTo hostname in Message-ID if available.
I wrote this fix to avoid obviously specifying that I am using a mobile device
to reply to an email.

Others want this for ease of filtering messages from their host by Message-ID.
2014-05-27 07:51:23 -07:00
cketti e2cffa074f Update/remove comments 2014-05-03 06:33:33 +02:00
cketti a9cfa9ae68 Code style
No functional changes
2014-05-03 06:13:38 +02:00
Koji Arai 215ada2e77 astyle 2014-05-02 13:21:35 +09:00
Koji Arai 68850b1dc9 Use setter for quoted text like signature 2014-05-02 09:43:14 +09:00
Koji Arai e163fb87e1 set signature parameter when it is only necessary 2014-05-02 09:06:23 +09:00
Koji Arai 421879e9cf Remove unused getter 2014-05-02 08:39:07 +09:00
Koji Arai 56a48476e4 Rename mDraft to mInsertSeparator. 2014-05-02 08:36:46 +09:00
Koji Arai 6155a65f65 Refactoring: extract a class TextBodyBuilder 2014-05-02 01:33:39 +09:00
Miltos Allamanis be2b3b1ec2 Renamed "usee" to "uee".
The naturalize tool detected that using "uee" is more consistent with
the current codebase state:
* "uee" in LocalStore is 28.47% probable ("usee" 5.01%)
* "uee" in TextBody is 45.02% probable ("usee" 9.10%)
2014-02-26 14:23:33 +00:00
András Veres-Szentkirályi cbbd0bc405 use more idiomatic String.isEmpty() instead of comparing length to 0 2014-02-15 23:59:24 +01:00
András Veres-Szentkirályi 8627a3e702 replaced for with for-each loop 2014-02-15 23:59:23 +01:00
Joe Steele 5a46575dc2 Generally replace \n with \r\n when part of a message
This builds upon the efforts started 2 commits back where \r\n is used for
all message text and \n is only used when the text is inside an
EolConvertingEditText widget.
2013-10-11 11:39:46 -04:00
Joe Steele bfb0316583 Fix fatal IndexOutOfBoundsException
The problem:

Configure the account (just an example -- problems can occur in other
configurations as well):
Message Format: HTML
Reply quoting style: Prefix
Quote message when replying: yes
Reply after quoted text: yes

Reply to a message that has a large quantity (20+) of \r\n scattered in
the body of its HTML version (not an unusual scenario).

Add a reply.  Save the message as a draft.  Go back & open the draft
again.  A fatal IndexOutOfBoundsException occurs.

The cause:

When the draft was saved, the X-K9mail-Identity header was computed and
added to the message, then the text of the message was processed with
MimeUtility.fixDraftTextBody, replacing all occurrences of \r\n with \n in
the quoted message before being saved in LocalStore, thus invalidating the
X-K9mail-Identity header.

The fix:

Remove MimeUtility.fixDraftTextBody and implement
MessageCompose$EolConvertingEditText instead.  Any message text placed in
an EolConvertingEditText widget is assured to have \n line endings.  Any
message text extracted from an EolConvertingEditText widget is assured to
have \r\n line endings.  The X-K9mail-Identity header will always be
computed correctly.

Issues thought to be related:  4782, 5010, 5634, 5725

As noted in some of the referenced issues, errors didn't always result in
a fatal exception, but instead with mixed up text.

Ref:  commit f9a35aeaee
2013-10-11 11:39:15 -04:00
Koji Arai 0be299fbd0 Avoid StringIndexOutOfBoundsException when the header is broken like "=?us-ascii?q?abc?= =?" 2013-09-20 13:15:57 +09:00
Joe Steele 1ff128890d Fix MimeMessage(InputStream in, boolean recurse)
No actual impact, because all existing calls were
with recurse = true.
2013-09-07 12:52:14 -04:00
cketti a7c9804995 Make sure the InputStream is always closed
Moving the code to create the OutputStream wrappers into the try-block ensures
that the InputStream is closed in case something goes wrong.
2013-09-06 19:42:10 +02:00
cketti 6cd52c123c Remove unnecessary type cast 2013-09-06 19:38:15 +02:00
Joe Steele 1ca1ef5c84 Content-type case-conversion changes.
Don't convert the content-type to lower case in
MimeMessage.getContentType.  The content-type may have optional parameters
that are case sensitive (boundary, name).

In removing the lower-case conversion from getContentType, a review was
made for inappropriate case-sensitive comparisons which use data obtained
with getContentType.  The only ones found were in isMimeType in both
Message and MimeBodyPart.

Case-sensitive instances of isMimeType were made case-insensitive.  Also,
isMimeType was moved from Message to MimeMessage for symmetry with
MimeBodyPart (MimeMessage & MimeBodyPart are similar and contain a good
bit of duplication such as this).

The unit test required fixing now that the case of the boundary text is
preserved.

References:

Commits 2c5186 and dc4002 added the toLowerCase to getContentType in
MimeMessage & MimeBodyPart (Issue 94).

Later, commit 50cd60 removed the toLowerCase addition from MimeBodyPart
(Issue 1289).
2013-09-03 19:54:18 -04:00
Joe Steele 63f68328ff Standardize line breaks within headers.
Fix the unit test to match.

All line endings in the unit test are now the same.

(Just for consistency.  Not a big deal, since such problems are fixed when
the messages are run through EOLConvertingOutputStream.)
2013-09-03 19:54:17 -04:00
Joe Steele 45e3d8459e Recursively convert attachments of type message/rfc822 to 7bit if necessary.
The preceding commit resulted in attachments of type message/rfc822 being
sent with 8bit encoding even when the SMTP server did not support
8BITMIME.  This commit assures that messages will be converted to 7bit
when necessary.

A new interface CompositeBody was created that extends Body, and classes
Message and Multipart were changed from implementing Body to
CompositeBody.  Additional classes BinaryTempFileMessageBody and
LocalAttachmentMessageBody were created (by extending BinaryTempFileBody
and LocalAttachmentBody, respectively), and they too implement
CompositeBody.

A CompositeBody is a Body containing a composite-type that can contain
subparts that may require recursive processing when converting from 8bit
to 7bit.  The Part to which a CompositeBody belongs is only permitted to
use 8bit or 7bit encoding for the CompositeBody.

Previously, a Message was created so that it was 7bit clean by default
(even though that meant base64 encoding all attachments, including
messages).  Then, if the SMTP server supported 8BITMIME,
Message.setEncoding("8bit") was called so that bodies of type TextBody
would been transmitted using 8bit encoding rather than quoted-printable.

Now, messages are created with 8bit encoding by default.  Then, if the
SMTP server does not support 8BITMIME, Message.setUsing7bitTransport is
called to recursively convert the message and its subparts to 7bit.  The
method setUsing7bitTransport was added to the interfaces Part and
CompositeBody.

setEncoding no longer iterates over parts in Multipart.  That task belongs
to setUsing7bitTransport, which may in turn call setEncoding on the parts.

MimeUtility.getEncodingforType was created as a helper function for
choosing a default encoding that should be used for a given MIME type when
an attachment is added to a message (either while composing or when
retrieving from LocalStore).

setEncoding was implemented in MimeBodyPart to assure that the encoding
set in the Part's headers was the same as set for the Part's Body.  (The
method already existed in MimeMessage, which has similarities with
MimeBodyPart.)

MimeMessage.parse(InputStream in, boolean recurse) was implemented so that
the parser could be told to recursively process nested messages read from
the InputStream, thus giving access to all subparts at any level that may
need to be converted from 8bit to 7bit.
2013-09-03 19:53:13 -04:00
Joe Steele 1d1db50a9f Don't always base64 encode in BinaryTempFileBody.writeTo
Issue 5734 exemplifies the problem:  receive a message with an attachment
of type message/rfc822 that doesn't use base64 encoding for the body of
the attached message.  K-9 Mail incorrectly stores the attached message
locally with its original headers but using base64 encoding for the body.
A discrepancy thus exists between what the headers say about the encoding
of the body versus the actual encoding used.  This is obvious when
attempting to view the attachment (either by using a compatible message
viewer available on the device or by saving the attachment to a file and
viewing the file contents).

The process: When a message with an attached sub-message is received,
Message.parse puts the attachment in a new MimeMessage with the
attachment's body in a BinaryTempFileBody.  LocalFolder.saveAttachment
then calls Message.writeTo (which later calls BinaryTempFileBody.writeTo)
to place the entire attachment (headers and body) in a new file that will
become a LocalAttachmentBody.  Until now,  BinaryTempFileBody.writeTo
could only save the message body using base64 encoding.

This commit implements BinaryTempFileBody.setEncoding and assures that the
body is written out with the same encoding that was found in its  headers.
2013-09-03 19:51:26 -04:00
Joe Steele 769ad843dd Revert "Fix for StrictMode error."
This reverts commit bbdec62e37.

Aside from being the incorrect solution for fixing the problem
described in pull request 211, the patch generates 'Dead code'
warnings inside the if(){} statements on lines 46 and 47.

The correct fix for the problem was already implemented in commit
5678786c97.

Although the logcat in the pull request was generated after the fix,
line numbers in the log indicate that it was based on an outdated
version of MimeUtility.java from before the fix.
2013-06-03 11:59:58 -04:00
cketti 9ea46cf03b Merge branch 'Issue_4019_pinch_zoom'
Conflicts:
	src/com/fsck/k9/view/MessageWebView.java
2013-03-19 21:09:23 +01:00
cketti 0319ee4a5d Move KOI8-U -> KOI8-R fixup to charset fall-back table 2013-03-10 09:55:25 +01:00
cketti 4b42d0e062 Code cleanup 2013-03-10 09:39:03 +01:00
eagan c5802ed8ef Java5 style 'for' 2013-03-10 09:25:28 +01:00
eagan a5f4ddae91 Enhancement for charset fallback.
Fallback rule is defined in CHARSET_FALLBACK_MAP.
Multi-level fallback is supported.
2013-03-10 09:25:13 +01:00
cketti 337487e2ae Merge pull request #211 from colund/master
Close stream in case of an exception
2013-03-10 00:11:53 -08:00
Joe Steele 6a844a2553 Remove unused code in HtmlConverter.
HtmlConverter.getHtmlHeader() and getHtmlFooter() are
no longer used.  Remove them and other related code.
2013-03-01 14:30:42 -05:00
Joe Steele e2c5229e85 Change when <html> tags are applied to messages.
Previously, <html>, <head>, & <body> tags were
attached to messages before they were stored locally.
But now that the <head> element also needs to include
a <meta> element (for proper MessageWebView display),
it seems unecesary to store all these tags with each
message.

Now the tags are no longer stored with the messages.  Instead,
MessageWebView applies the tags before displaying the message.

This also eliminates the need to upgrade an older
message database where all the old messages would have
otherwise needed to be wrapped with the new tags.
2013-03-01 12:59:59 -05:00