Commit Graph

971 Commits

Author SHA1 Message Date
András Veres-Szentkirályi 8627a3e702 replaced for with for-each loop 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi ac1e68af78 use built-in TextUtils.join instead of StringBuilder 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi 0c7740ce86 removed unread field mAccount 2014-02-15 21:30:44 +01:00
cketti 3527930f89 Fix 'endless' loop in ImapFolderPusher
Under certain circumstances it's possible that the 'push state' isn't
updated to contain the most recent 'UIDNEXT' value. In that case
ImapFolderPusher.start() would execute the same code path through its
main loop over and over again, preventing the device from going to
sleep.
Rather than changing the code to update the 'push state' in the corner
case that triggers the behavior described above, this commit introduces
another mechanism to track the 'UIDNEXT' value. This should also catch
as of yet unknown cases where the 'push state' isn't properly updated.

At some point in the future I hope we get to a point where we only
persist the 'push state' when we manually stop/restart the service.
During normal operation there's no need to read from/write to storage
all the time.

Fixes issue 4907
2014-02-11 20:17:47 +01:00
Joe Steele 03925fb409 Fix POP3 STLS command
The server response needed to be retrieved.

Thanks to Paul Durrant:
https://groups.google.com/d/msg/k-9-mail/0XHNNMR1TQ4/yExsr7nvJQwJ
2013-12-29 18:47:02 -05:00
cketti 79a5bc9c7e Revert "Make IMAP autoconfig recognize "Draft" as drafts folder"
This reverts commit 453f10128c.
See https://github.com/k9mail/k-9/pull/429
2013-12-17 18:45:57 +01:00
erlendorf 453f10128c Make IMAP autoconfig recognize "Draft" as drafts folder
Yahoo names it "Draft" instead of the more common "Drafts".
2013-12-16 17:14:56 +01:00
Joe Steele 40404c3700 Move some classes out of com.fsck.k9.mail.store
The classes are just as much related to com.fsck.k9.mail.transport
as com.fsck.k9.mail.store, so having them in
com.fsck.k9.mail.store doesn't seem appropriate.

Move LocalKeyStore to com.fsck.k9.security

Move TrustManagerFactory and TrustedSocketFactory to com.fsck.k9.net.ssl
2013-12-02 14:07:57 -05:00
Joe Steele 76605f7d86 Extract code into new LocalKeyStore class
Also, implement the ability to configure an alternate key store
file location. This permits the running of unit tests without
clobbering the live key store file.

Also, add a test to confirm that the key store file is being written
out and reread correctly.
2013-12-02 14:04:40 -05:00
cketti 4b57d79acf Only check against the certificate stored for a server, not all of them 2013-11-29 14:06:02 +01:00
cketti c5c195d243 Add unit tests for TrustManagerFactory 2013-11-29 10:49:52 +01:00
Joe Steele a4440b4042 Fix inadequate certificate validation
Proper host name validation was not being performed for certificates
kept in the local keystore.  If an attacker could convince a user to
accept and store an attacker's certificate, then that certificate
could be used for MITM attacks, giving the attacker access to all
connections to all servers in all accounts in K-9.

This commit changes how the certificates are stored.  Previously, an
entire certificate chain was stored for a server (and any of those
certificates in the chain were available for validating signatures on
certificates received when connecting).  Now just the single
certificate for the server is stored.

This commit changes how locally stored certificates are retrieved.
They can only be retrieved using the host:port that the user
configured for the server.

This also fixes issue 1326.  Users can now use different certificates
for different servers on the same host (listening to different ports).

The above changes mean that users might have to re-accept certificates
that they had previously accepted and are still using (but only if the
certificate's Subject doesn't match the host that they are connecting
to).

This commit modifies AccountSetupBasics so that it now calls
AccountSetupCheckSettings twice -- once for checking the incoming
settings and once for the outgoing settings.  Otherwise, an exception
could occur while checking incoming settings, the user could say
continue (or the user could accept a certificate key), and the
outgoing settings would not be checked.  This also helps with
determining if a certificate exception was for the incoming or
outgoing server, which is needed if the user decides to add the
certificate to the keystore.
2013-11-23 13:26:57 -05:00
brian m. carlson 1bfb78ee51 Use TrustedSocketFactory for STARTTLS.
The TrustedSocketFactory, which provides goodies like better cipher suites and
TLSv1.2, was only being used for tunnelled connections.  Use it for STARTTLS
connections as well.
2013-11-10 00:27:01 +00:00
cketti a036e4d2f9 Merge branch 'tls-hardening' 2013-10-29 04:40:06 +01:00
cketti a97705ffa9 Refactor TrustedSocketFactory 2013-10-29 04:37:52 +01:00
cketti 8f45d76b5c Extract WebDavSocketFactory 2013-10-29 03:42:37 +01:00
András Veres-Szentkirályi 105d3b3c4e filter TLS protocol versions by support as well 2013-10-20 10:42:39 +02:00
András Veres-Szentkirályi 77d43fb7bd extracted method filterBySupport 2013-10-20 10:30:33 +02:00
András Veres-Szentkirályi dbc47c7297 filter enabled cipher suites by availability 2013-10-20 10:22:53 +02:00
András Veres-Szentkirályi d84ce6ddb9 Hardened TLS cipher suites and versions
As Georg Lukas wrote in his blog post about how Android handles TLS
handshake (http://op-co.de/blog/posts/android_ssl_downgrade/), an
explicit order of cipher suites and TLS versions must be supplied to
avoid having the weak (presumably broken) RC4 cipher at the top of the
preference list.

This commit adds the list included in the blog post to every TLS socket
creation, including IMAP, POP3 and SMTP, see Wireshark screenshots done
during testing at http://vsza.hu/k9mail-tls-hardening/
2013-10-15 10:16:42 +02: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
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
Joe Steele 1afff1e38f Delete related files when deleting a database.
The journal file was not being deleted when an account was deleted.
Over time, one can end up with a collection of dead journal files.
2013-10-11 11:24:51 -04:00
Danny Baumann 8777441d92 Use address object as contact picture instead of email address only.
Fixes assignment problems for emails sent by some issue tracking
systems, which send out mails with a fixed mail address on behalf of
different people.
2013-09-27 08:53:14 +02: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
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 aaa0de4dbc Don't append "null" to the "MAIL FROM" line in case the server doesn't support 8BITMIME 2013-09-06 20:28:46 +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 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 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 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 de23a0e3e1 SMTP 8BITMIME compliance
Currently, K-9 Mail detects if an SMTP server supports 8BITMIME (RFC
6152), and if so, TextBody parts are sent with content-transfer-ecoding =
8bit.  Otherwise, they are sent using quoted-printable.

This adds the required "BODY=8BITMIME" parameter to the MAIL command when
sending messages to servers that support 8BITMIME.
2013-09-03 16:47:57 -04:00
cketti 8fb2c5a490 Merge branch 'pr/349'
Remove remote/local store references when deleting accounts
2013-08-30 03:03:30 +02:00
cketti 9b370d0620 Add code to remove references to LocalStore when deleting accounts 2013-08-30 03:02:50 +02:00
cketti 01336944ec Refactor code to remove remote store references when deleting accounts 2013-08-30 02:28:57 +02:00
Joe Steele ac42bce799 Clean-up related to certificate chains
Per comments in pull request #365
2013-08-27 18:48:07 -04:00
Joe Steele 604aa87ccf Fix erroneous SSL certificate warnings
If you attempted to use SSL to connect to a server that speaks
STARTTLS, you should get an SSL protocol error.  Instead, you
were likely to get an "Unrecognized Certificate" error that shows
you an unrelated certificate chain and asks you to accept it or
reject it.  Neither action would work because the actual problem
had nothing to do with certificates.  The unrelated certificate
chain that popped up had been statically stored when validating
a prior connection to a different server.

With this patch, certificate chains are no longer stored statically
when validating server connections.

Issue 5886 is an example of a user experiencing this problem.
2013-08-25 15:43:36 -04:00
Jesse Vincent 7aeaa46fe6 Koji Arai pointed out that I screwed up the constants for folder open modes 2013-08-25 11:36:25 -04:00
cketti ce56475a4f Avoid race condition that can lead to a NullPointerException 2013-08-21 12:33:27 +02:00
cketti f11f0fcc9b Skip incorrectly formatted/parsed LSUB/LIST replies
Example: * LIST (\HasChildren) "." [Folder]
"[Folder]" will be parsed as list containing the element "Folder".
2013-08-20 18:39:20 +02:00
Joe Steele b7c67019af SMTP dot stuffing should be done *after* line wrapping. 2013-08-13 19:27:40 -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
Wang Li 50a8d89468 remoteStore assocciated with account indirectly should also be reseted when acccount was removed. Otherwise, there might be residual data that will affec account being added later. 2013-07-23 14:09:53 +08: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 306b258f25 Merge pull request #323 from jca02266/adapt_broken_server
Adapt broken pop3 server
2013-07-07 19:43:55 -07: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
Koji Arai b88fbb7fd8 adapt to a corner case for broken server. 2013-06-29 22:28:27 +09:00
Koji Arai 35c79a5656 adapt broken pop3 server 2013-06-26 23:57:55 +09: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 46ed21d9f5 Merge branch 'smtp_port_fix' 2013-04-26 02:30:27 +02:00
cketti b91b86c657 Change SMTP default port to 587 2013-04-26 02:29:36 +02:00
dzan 6c1b3cbc68 Change smtp+tls default port to 587. 2013-04-20 18:02:30 +02:00
cketti 4890cd9ea0 Better cope with messages having identical message IDs 2013-04-17 02:09:43 +02: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 a619a9df93 Hide delete policy "Mark as read on server" for POP3 accounts 2013-03-13 06:34:14 +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
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
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
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
Danny Baumann 5d1e42c453 Improve certificate failure notifications.
The commit that introduced those notifications also introduced a rather
... interesting design pattern: The CertificateValidationException
notified the user of its pure existance - it's no longer a 'message'
only, but defines policy. As this is more than unusual, replace this
pattern by the MessagingController treating
CertificateValidationException specially when accessing remote folders.

Also make clear which account failed when constructing the notification.
2013-02-02 13:04:41 +01:00
Jesse Vincent ae6c7e37ca Merge remote-tracking branch 'zjw/issue_2389_cert_error_notice2'
* zjw/issue_2389_cert_error_notice2:
  Fix Issue 2389:  Self signed certificate expiry causes silent send/receive failure.
2013-01-15 14:44:21 -05: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
Joe Steele 29f15d715d Fix Issue 2389: Self signed certificate expiry causes silent send/receive failure.
With this fix, a CertPathValidatorException or CertificateException will
create a "Certificate error:  Check your server settings" notification
in the status bar.  When the user clicks on the notification, they are
taken to the appropriate server settings screen where they can review their
settings and can accept a different server certificate.
2013-01-10 16:49:55 -05:00
Andrew Chen 5ac3d1d5c2 Use existing LocalMessage for the JB notifications.
LocalMessage already has a content preview in it; reuse that.
Remove unneeded MimeMessage#getPreview() method now that we don't need
to generate a preview anymore.
2013-01-07 23:20:35 -08:00
Andrew Chen 068f87380c More javadoc 2013-01-07 22:15:49 -08:00
Andrew Chen d4eae05630 Javadoc 2013-01-07 22:11:04 -08:00
Danny Baumann 45328189f3 Strip off signatures from preview. 2013-01-07 10:39:08 +01:00
Danny Baumann 6f7ec3e401 Incorporate review comments. 2013-01-05 13:21:17 +01:00
cketti bcd52a6707 Fetch in-reply-to header when downloading envelope on IMAP accounts 2012-12-13 17:03:35 +01:00
cketti 44348e08a4 Create non-existent IMAP folders when copying/moving messages 2012-12-10 21:42:57 +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
luyang bbdec62e37 Fix for StrictMode error.
When the device lost connectivity, a StrictMode error could be thrown since
the stream was never closed.
2012-11-28 19:55:42 +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
cketti 20ed1ebe61 Code style cleanup 2012-10-17 20:52:03 +02:00
cketti f1e433e6df Whitespace cleanup 2012-10-16 22:42:51 +02:00
cketti 83d5102f3d Merge branch 'new_search_framework' into content_provider
Conflicts:
	src/com/fsck/k9/fragment/MessageListFragment.java
2012-10-16 20:57:47 +02:00
cketti cc74a2ad2e Switched to ContentProvider and CursorLoader to display the message list 2012-10-16 15:46:40 +02:00
Sander Bogaert d27f909600 Add new search logic to the MessagingController and LocalStore classes. 2012-10-13 08:53:00 -04:00
cketti 16d2326033 Nasty hack to retain threads in MessageListFragment when polling 2012-10-10 03:02:36 +02:00
cketti 63b6b497a0 Early version of message threading
Missing:
- UI support for threading when polling
- code to upgrade existing installations
- UI elements to switch from/to threaded display mode
- threading of messages with same subject
2012-10-08 22:51:29 +02:00
Jesse Vincent 0c34a21ff0 Add a fromMe method on messages 2012-10-03 21:56:28 -04:00
Andrew Chen 39e2a973a1 Merge branch 'imapsearch'
* imapsearch:
  Change settings version to 18 to match what's currrently on master.
  Handle aborted imap searches by nuking in-progress connections.
  Move IMAP search into the Folder level.
  Remove duplicate notification on remote search start.
  Rename variables
  changed PREFERENCE_CLOUD_SEARCH_ENABLED from "cloud_search_enabled" to "remote_search_enabled" in activity/setup/AccountSettings.java to resolve FC.
  Add cloud search icon to local search result screen. Implement pull-to-remote-search.
  Log remote search exceptions in addition to toasting them.
  Add settings export for remote search settings.
  Whitespace; no functional changes.
  Handle implicit vs. explicit searches in ActionBar home button behavior.
  Whitespace fix; no functional changes.
  Add remote search actionbar icons.
  IMAP Search: log exceptions on remote search, properly dispatch MessageList changes.
  modified loadMessageForView() to dowload message if neither X_DOWNLOADED_FULL nor X_DOWNLOADED_PARTIAL.
  Add remote IMAP search support.

Conflicts:
	res/menu/message_list_option.xml
	res/values/attrs.xml
	res/values/themes.xml
	src/com/fsck/k9/activity/MessageList.java
	src/com/fsck/k9/preferences/Settings.java
2012-09-25 16:01:52 -07:00
Andrew Chen 2541753aff Handle aborted imap searches by nuking in-progress connections. 2012-09-25 15:46:30 -07:00
Andrew Chen 9f96cd36a7 Move IMAP search into the Folder level.
Should also consider moving the LocalStore search into the folder level and have the store call the folder level searches.
2012-09-25 14:34:59 -07:00
Andrew Chen 7631af1572 Log remote search exceptions in addition to toasting them. 2012-09-22 09:37:50 -07:00
cketti 2ee3378eef Use executeSimpleCommand() for UID COPY so the response type is checked
The previous code never failed e.g. on a "NO" response. That lead to
messages being deleted for a move action.
2012-09-14 02:08:39 +02:00
Rob Bayer fdb1267cb1 Add remote IMAP search support.
* rbayer/IMAPsearch: (21 commits)
  More cleanup
  Code Cleanup getRemoteSearchFullText -> isRemoteSearchFullText line wraps for preference items
  Refactor to allow fetching of extra search results beyond original request.  Most code moved out of ImapStore and ImapFolder and into MessagingController.searchRemoteMessagesSynchronous.  Should make it easier to add remoteSearch for other server types.
  Prevent delete of search results while search results open
  remove duplicated code block
  Don't hide Crypto when IMAPsearch disabled
  Code Style Cleanup: Tabs -> 4 spaces Remove trailing whitespace from blank lines
  tabs -> spaces (my bad...)
  Fix opening of folders to be Read-Write when necessary, even if they were previously opened Read-Only.
  add missing file
  Working IMAP search, with passable UI.
  UI improvements
  Simple help info when enabling Remote Search
  Dependency for preferences
  Basic IMAP search working
2012-09-13 09:10:37 -07:00
Jesse Vincent 3799ecfb21 Check message uids first when comparing messages. message uids are less likely to be the same than folders, so it's a slight optimization 2012-09-12 21:56:17 -05:00
Jesse Vincent d5f739030a Always save all headers. Not doing so is kind of a crazy space microoptimization and can get a little messy 2012-09-10 12:07:35 -04:00
Bernhard Redl e5d56a4eac Fixes 4517: Junk special folder not autoconfigured (rfc6154 implementation was incomplete) 2012-09-09 19:12:37 -05:00
cketti 3253466f14 More magic to work around BinaryTempFileBodyInputStream 2012-09-09 01:15:26 +02:00
cketti 5678786c97 Properly closing InputStreams to avoid StrictMode warnings 2012-09-05 05:57:52 +02:00
Bernhard Redl 474f32ad02 changed parseFlags to directly manimpulate member 2012-08-30 18:15:19 +02:00
Bernhard Redl 56105bcfe3 + add support for $Forwarded IMAP flag 2012-08-29 02:26:38 +02:00
Bernhard Redl 89f6c2f6d0 upgraded Mime4J 0.7-SNAPSHOT -> 0.7.2 (fixes MimeMultipart parser bug) 2012-08-15 01:47:57 +02:00
cketti 83e57064ff Check database version after ending the transaction 2012-07-07 17:15:14 +02:00
cketti d08169b004 Corrected indentation 2012-07-07 17:14:03 +02:00
cketti 400487b8aa Merge branch 'pullreq150' 2012-07-07 17:04:17 +02:00
cketti e1d9a4779d Changed the rest of ImapStore to use longs for storing UIDs 2012-07-07 16:46:07 +02:00
cketti 2ad748fad7 Change ImapUtility to use 'long' for the values of sequence sets 2012-07-07 16:21:07 +02:00
cketti a37c95b456 Move auto-unboxing out of if-clause 2012-07-07 15:41:55 +02:00
cketti c359eb3cb7 Use auto-unboxing when iterating over a List<Long> 2012-07-07 15:36:43 +02:00
cketti 08c6c63b31 Merge branch 'pullreq153' 2012-07-07 15:06:41 +02:00
cketti 8493847895 Removed unused class 2012-07-07 14:29:40 +02:00
András Veres-Szentkirályi d0c08fb705 removed unread private field mSecure 2012-07-06 15:04:46 +02:00
András Veres-Szentkirályi 9413cf5c9d Removed override merely calling super() 2012-07-06 14:35:01 +02:00
András Veres-Szentkirályi bff1602da1 combined nested if statements in LocalStore 2012-07-06 14:35:01 +02:00
András Veres-Szentkirályi 961872edf0 combined nested if statements in ImapStore 2012-07-06 14:35:01 +02:00
András Veres-Szentkirályi 57f364ca69 combined nested if statements in MimeHeader.hasToBeEncoded 2012-07-06 14:35:01 +02:00
Joe Steele 102c6153a1 Issue 4359: IMAP message UIDs are 32 bit unsigned values and cannot be
stored in int, so we now parse them as long.
2012-07-05 18:00:49 -04:00
cketti 602ce7be99 Trim the first value in getHeaderParameters()
Previously a value like 'text/html ; charset="windows-1251"' for the
Content-Type header would not be decoded correctly.

Fixes issue 4348
2012-06-18 04:46:46 +02:00
cketti 67caa357fd Fixed loading messages from the database when message format is AUTO 2012-06-01 20:03:03 +02:00
cketti 116e9598da Create an HTML version of text/plain-only drafts in the database
Without this, text/plain-only messages with K-9 Mail's "identity header"
are displayed as "No text" (when moved out of the Drafts folder).
2012-06-01 16:15:07 +02:00
Romain Vimont (®om) fb36389d20 Create database in a transaction (for performance)
On my emulator, it takes 70ms instead of 250ms.
On a very specific hardware, it takes 0,5s instead of 4,1s.

I willingly did not indent the code between my try/catch (for the patch to be readable).
2012-05-30 12:57:05 +02:00
ashley willis 7e5717ed81 use the new way on internal storage, or the original way otherwise 2012-05-09 21:09:10 -05:00
ashley willis b1b6d5fce4 Yahoo! IMAP seems to no longer require 'ID ("GUID" "1")' over non-3G.
see http://mobile.yahoo.com/mail for IMAP setup instructions.
2012-05-09 13:48:36 -05:00
ashley willis ca6d697eed fixed commit ed4c74983e due to crashing on 2.1 devices 2012-05-07 09:24:13 -05:00
ashley willis 9e1fa63139 fixed MimeHeader.hasToBeEncoded() to include TAB.
bug encounted when replying to a message such as:
From: "bar,	foo" <foobar@example.com>
the field was originally folded on the tab, but the CRLF was already stripped before this error.
2012-04-30 13:58:02 -05:00
ashley willis ed4c74983e fixed security issue -- account databases previously world-readable and accessible to any app if UUID is known. 2012-04-26 08:03:06 -05:00
Andrew Chen 7e26b62227 Remove horizontal rules in message previews. 2012-04-08 16:52:55 -07:00
Jesse Vincent 85da3d8667 workaround to detect the charset from HTML mail without charset parameter on the header.
Conflicts:

	src/com/fsck/k9/mail/internet/MimeUtility.java
2012-04-08 12:38:45 -04:00
Jesse Vincent 4723ea0ae5 Possible to select email addresses from the ContactPicker
Conflicts:

	src/com/fsck/k9/activity/MessageCompose.java
	src/com/fsck/k9/helper/ContactsSdk3_4.java
2012-04-08 12:29:08 -04:00
cketti 0caac114a6 Added some error checks when processing IMAP FETCH responses 2012-04-03 07:55:52 +02:00
Koji Arai 10c37942a6 Added two domains handle docomo emoji 2012-03-17 23:24:12 +09:00
Koji Arai f9fb74241a avoid NPE. address may be null when the parser is failed. 2012-03-17 23:23:27 +09:00
cketti f9a35aeaee Replace CRLF with LF when loading drafts
This is necessary because we save the offset and length of the user-
supplied text in the identity header. These values are then later used
to split the draft in user text and quoted message.
When calculating these values we operate on a string with LF line
endings. Ideally we want to do the reverse operation on the same
string, but when saving the message to the server LF is converted to
CRLF to create RFC-conforming messages.

This is only a hack and will probably be the cause of more trouble in
the future. A better solution would be to make the identity header more
robust or get rid of it entirely.
2012-03-17 04:15:30 +01:00
cketti 3fa8081e88 Fixed MimeUtility.extractTextual() when loading messages from the server 2012-03-17 03:19:09 +01:00
cketti dbf38dae65 Fixed the change of the previous commit 2012-03-17 00:30:40 +01:00
cketti a48adafbbc Don't use null for 'text' and 'html' in ViewableContainer 2012-03-16 22:56:09 +01:00
cketti f181e923ca Don't modify draft messages when storing them in the database 2012-03-15 21:21:00 +01:00
cketti aeb0220e56 Fixed MimeUtility.getHeaderParameter() to not crash on unexpected input 2012-03-12 17:45:34 +01:00
cketti 0cb4207ef7 IMAP: don't create the destination folder when copying messages 2012-03-09 21:51:48 +01:00
cketti 7163d39091 Change ImapException to always be a permanent error
This way IMAP commands that get anything but an "OK" response are never
tried again (pending actions).
2012-03-09 21:50:26 +01:00
cketti 5591865f17 Merge branch 'uidplus' 2012-02-29 14:09:41 +01:00
cketti e72afc1641 Set content type of attachment even when no file name was found 2012-02-27 23:20:30 +01:00
cketti 2cb31a2fac Added button to show unnamed and inline attachments 2012-02-27 21:45:46 +01:00
cketti fbc187a3e2 IMAP: Send the Message-ID as quoted string in getUidFromMessageId() 2012-02-19 19:51:06 +01:00
cketti 4adfc51339 Use HtmlConverter.convertEmoji2Img() in LocalFolder.updateMessage() 2012-02-18 00:44:24 +01:00
cketti b9803ece19 Fixed divider before text part with filename 2012-02-18 00:05:56 +01:00
cketti 8ce78408c2 Fixed HTML generation in MimeUtility.extractTextAndAttachments() 2012-02-17 19:42:35 +01:00
cketti 5083b8f1e8 Use newly imported AOSP code instead of ImapStore.parseSequenceSet() 2012-02-17 15:01:30 +01:00
cketti deb01bcd16 Imported ImapUtility.java from AOSP Email
Modified it to fit our needs.
2012-02-17 14:59:50 +01:00
cketti c3885bc475 Cleaned up LocalFolder.appendMessages() a bit 2012-02-16 23:52:44 +01:00
cketti 023c60513e Fixed UID mapping return value of LocalStore.moveMessages() 2012-02-16 23:37:44 +01:00
cketti 3e4e6c72fd Cleaned up ImapStore.ImapFolder.copyMessages() 2012-02-16 22:12:44 +01:00
cketti 396005974a Cleaned up ImapStore.ImapFolder.appendMessages() 2012-02-16 21:33:53 +01:00
cketti 8e1627e1b9 Merge branch 'master' into uidplus
Conflicts:
	src/com/fsck/k9/controller/MessagingController.java
	src/com/fsck/k9/mail/store/WebDavStore.java
2012-02-16 19:57:24 +01:00
cketti cf9631d481 Changed the way we decide what message parts to display 2012-02-13 23:11:59 +01:00
cketti 7a252bf002 Changed method to update the unread widget 2012-02-13 12:16:20 +01:00
cketti 29e1a68288 Added widget to display the unread count for an account 2012-02-13 12:16:18 +01:00
cketti e8eae37389 Reset unread/flagged count on "empty trash" 2012-01-27 00:51:18 +01:00
cketti 4e5d116713 Delete attachment metadata and thumbnails when deleting attachments 2012-01-24 16:15:45 +01:00
cketti bddacf6b64 Use database ID to keep track of the current draft
By using the database ID we avoid having to deal with the problem of
changing UIDs. First the message has a local UID, then, when the upload
to the server is completed, it gets a remote UID.
2012-01-22 05:20:41 +01:00
cketti 96f827d291 Modified LocalStore to use UPDATE when replacing existing messages
This way we can later use the database ID to keep track of drafts.
2012-01-22 05:20:41 +01:00
cketti 32a29f131b Make sure an IOException is always passed through as MessagingException
This is important for the code handling pending actions in
MessagingController. If a non-permantent MessagingException is
encountered, the pending action is retried later.

Fixes issue 3696
2012-01-20 19:50:07 +01:00
cketti 258b0039d5 IMAP: also get the Message-ID when fetching the message "envelope"
This should fix issue 3994
2012-01-14 06:30:22 +01:00
cketti 66b7805a57 Fixed a bug in the IMAP response parser
Also got rid of ImapResponse.more() which isn't necessary anymore.
2012-01-12 07:56:52 +01:00
cketti d848b434f5 Fall back to HELO command if the server doesn't know EHLO (SMTP)
Fixes issue 2704
2012-01-05 03:53:23 +01:00
cketti 71174417ce Clone Message object to avoid ConcurrentModificationExceptions
Fixes issue 3953
2012-01-04 03:57:53 +01:00