1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
Commit Graph

311 Commits

Author SHA1 Message Date
Miltos Allamanis
2df205874e Renamed "s" to "sizeParam".
The naturalize tool detected that using "sizeParam" is more consistent
with the current codebase state:
* "sizeParam" in LocalStore is 22.89% probable ("s" 10.52%)
2014-02-26 14:27:35 +00: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
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
33678ea022 Eliminate unnecessary override in LocalAttachmentBody.
The overriding code is the same as the overridden code.
2013-10-11 11:24:56 -04:00
cketti
2b7f5e7b70 Merge branch 'pick_attachment_fix'
Update LocalStore code to handle the newly introduced temporary files
for attachments

Conflicts:
	res/values/strings.xml
	src/com/fsck/k9/activity/MessageCompose.java
2013-09-25 05:22:00 +02:00
cketti
62aa1b87d0 Fetch attachments while MessageCompose activity is running
Android allows other apps to access protected content of an app without requesting the
necessary permission when the app returns an Intent with FLAG_GRANT_READ_URI_PERMISSION.
This regularly happens as a result of ACTION_GET_CONTENT, i.e. what we use to pick content
to be attached to a message. Accessing that content only works while the receiving activity
is running. Afterwards accessing the content throws a SecurityException because of the
missing permission.
This commit changes K-9 Mail's behavior to copy the content to a temporary file in K-9's
cache directory while the activity is still running.

Fixes issue 4847, 5821

This also fixes bugs related to the fact that K-9 Mail didn't save a copy of attached content
in the message database.

Fixes issue 1187, 3330, 4930
2013-09-25 03:12:34 +02: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
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
77407eb5b7 Don't base64 encode attachments of type message/rfc822.
The problem:  Receive a message with an attachment of type message/rfc822
and forward it.  When the message is sent, K-9 Mail uses base64 encoding
for the attachment.  (Alternatively, you could compose a new message and
add such an attachment from a file using a filing-picking app, but that is
not 100% effective because the app may not choose the correct
message/rfc822 MIME type for the attachment.)

Such encoding is prohibited per RFC 2046 (5.2.1) and RFC 2045 (6.4).  Only
8bit or 7bit encoding is permitted for attachments of type message/rfc822.

Thunderbird refuses to decode such attachments.  All that is shown is the
base64 encoded body.

This commit implements LocalAttachmentBody.setEncoding.  If an attachment
to a newly composed message is itself a message, then setEncoding("8bit")
is called, otherwise setEncoding("base64")  is called for the attachment.
Similar behavior occurs when an attachment is retrieved from LocalStore.

The setEncoding method was added to the Body interface, since all
implementations of Body now declare the method.

The problem here differs from that in the preceding commit:  Here, the
encoding problem occurs on sending, not on receipt.  Here, the entire
message (headers and body) is base64 encoded, not just the body.  Here,
the headers correctly identify the encoding used;  it's just that the RFC
does not permit such encoding of attached messages.  The problem here
could in fact occur in combination with the preceding problem.
2013-09-03 19:52:11 -04:00
Joe Steele
564195bad9 Close stream when done (StrictMode error) 2013-08-09 19:17:07 -04:00
Joe Steele
fcabb7395d bug fix: use "1" not "true" for SQL boolean
Ref:  Pull request #355 from @edemaine
2013-08-02 13:01:22 -04:00
Jesse Vincent
bbad298bf6 Convert OpenMode from an Enum to static ints for perf improvement.
(Based on profiling of long folder list opens)

This should be backported to 4.4
2013-07-30 21:32:35 -04:00
Jesse Vincent
e9a0cbb269 Ask SQLite for a simpler calculation when counting unread messages. The docs imply this is a decent perf win. I'm seeing at least a bit of one 2013-07-30 21:32:35 -04:00
Jesse Vincent
1fa6d5f960 Add an index for a heavy query 2013-07-18 20:09:39 -04:00
cketti
dda8395c7a Make sure we always have the ID of a folder when fetching the unread/flagged count 2013-07-16 16:54:26 +02:00
Jesse Vincent
876d478ad7 Opening a folder (especially in threaded mode) does a very heavy SQL query. This method doesn't use or modify the folder object. Don't cargo-cult the Open here.
(cketti may well tell me I'm wrong about this. Happy to listen & fix)
2013-07-11 18:44:44 -04:00
cketti
5d07b6691b Don't load unread/flagged count when creating LocalFolder instances
This avoids a potentially expensive LEFT JOIN when querying the database.
2013-07-07 03:31:14 +02:00
cketti
422ba279b5 Refactor code to create LocalFolder instances from a database query. 2013-07-07 03:31:14 +02:00
cketti
ed6eb7bade Fix code to reset the database when upgrading fails
Previously the app crashed when upgrading the database failed. Now we
reset the database version and run the upgrade code again (recreating
all tables).
2013-07-03 05:25:39 +02:00
cketti
4890cd9ea0 Better cope with messages having identical message IDs 2013-04-17 02:09:43 +02:00
cketti
658b5dbff6 Fix and vastly simplify the query for the threaded message list
This requires another database schema change. With this change messages
at the root of a thread reference themselves in the 'threads' table,
i.e. 'root' contains the value of 'id' for these messages. It makes
selecting all messages in a thread much simpler.
2013-03-08 01:15:26 +01:00
cketti
50fcff76fd Add a caching layer to EmailProvider
Database updates can be surprisingly slow. This lead to slow updates of
the user interface which in turn made working with K-9 Mail not as fun
as it should be. This commit hopefully changes that.
2013-02-19 04:45:14 +01:00
Danny Baumann
275700e482 Fix a number of build warnings.
This gets rid of about 50 warnings. Deprecation warnings still remain,
though.
2013-02-04 11:18:49 +01:00
cketti
543fefebaa Merge branch 'threading_schema_change' 2013-01-12 23:03:38 +01:00
cketti
65a5a73737 Rewrite/optimize some SQL statements 2013-01-12 04:21:53 +01:00
cketti
0a5a330820 Fix getFoldersAndUids() for threads 2013-01-12 04:02:21 +01:00
cketti
421558c148 Optimize setting flags for whole threads 2013-01-12 02:28:12 +01:00
cketti
1df88ea153 Use separate table to store the thread structure 2013-01-11 03:40:35 +01:00
Danny Baumann
6f7ec3e401 Incorporate review comments. 2013-01-05 13:21:17 +01:00
cketti
7db33ce8c6 Ignore null-rows in results of SQL queries 2012-12-10 17:34:48 +01:00
cketti
8d652b2f61 Fix some compiler warnings 2012-12-07 15:50:55 +01:00
cketti
7b49f67c51 Remove unused methods 2012-12-07 15:47:15 +01:00
cketti
bc4fb530d0 Remove all code using the old unread/flagged count database columns 2012-12-07 15:45:36 +01:00
cketti
04ec2abd2c Use local unread/flagged count in folder list and message list 2012-12-07 15:04:53 +01:00
cketti
d5bb462917 Don't create Message objects when changing flags of selected messages
This changes the interface to MessagingController and the way flags are
updated in the database. Now messages aren't changed one by one but in
batches of 500. This should give better performance, but breaks the
unread and flagged count. I'm not very sad about this, because now we
can move towards only displaying the number of unread/flagged messages
in the local database.
2012-12-06 06:26:38 +01:00
cketti
c0b5255e24 Make most important flags separate database columns
This is the first step to speed up searches and flag updates.
2012-12-04 05:13:58 +01:00
cketti
b2098c8d1c Add activity that is displayed during database upgrades
See UpgradeDatabases.java for a detailed description of the upgrade
process.
2012-12-01 08:02:55 +01:00
cketti
2db8034c31 Use one database transaction when doing bulk flag changes
Previously we used one transaction per message. For 500 messages the
database updates alone took over 30s on my Nexus 7.
2012-11-27 16:46:59 +01:00
cketti
b108e7a539 Don't fetch already downloaded messages found by a server-side search 2012-11-15 21:05:45 +01:00
cketti
e339dd1f10 Delete all messages in a thread when 'delete' is used on the placeholder 2012-11-03 01:52:45 +01:00
cketti
2e1d25118a Fix JOIN-condition when searching for messages 2012-11-01 20:33:13 +01:00
cketti
08b361ed36 Fix search for Unified Inbox
We don't want to list the Inbox contents of all accounts but the
contents of folders whose "Unify" setting is true.
2012-10-31 01:45:44 +01:00
cketti
303c1ee85d Extract generation of SQL queries for searches to SqlQueryBuilder 2012-10-29 02:27:34 +01:00
cketti
d703286833 Make LocalStore.searchForMessages() skip empty messages 2012-10-24 06:01:26 +02:00
cketti
ec76dca57f Remove unused stuff 2012-10-24 01:37:33 +02:00
cketti
1fcce6fb8a Add database indices for thread columns in 'messages' table 2012-10-24 01:03:59 +02:00
cketti
3bef05b55d Removed LocalStore hack introduced in 16d2326 2012-10-24 00:32:29 +02:00
cketti
1b98ce57e1 Notify observers (e.g. CursorAdapter) when the messages table changed 2012-10-24 00:08:44 +02:00
cketti
1d655f5bc2 Added ability to display special folders combining multiple accounts 2012-10-18 05:15:40 +02:00