Commit Graph

162 Commits

Author SHA1 Message Date
Todd Kennedy a50fc99b0c Use Account instead of URI to create transports
There's no need to create a URI just to rip in appart again. Additionally, to
support additional changes (i.e. to use Mailbox instead of Folder in the
MessageController), we need to store the actual Account.

NOTE -- This change only affects IMAP and POP3. SMTP will come in a follow-on CL

Change-Id: I400036a17271c99272fd9c603547dcd713b50b9d
2011-04-20 08:31:24 -07:00
Todd Kennedy ba7652cda0 Make ImapFolder a top-level class
No code changes; just moving the class

Change-Id: I4e4544d99d52dde85b96c99ef45da3a96e7d3d48
2011-04-19 09:31:43 -07:00
Todd Kennedy d31238ca88 Add support to query for message IDs
If an IMAP server supports the UIDPLUS capability, it can return the new UID
as part of the response to the "UID COPY" command. However, if the server does
not support UIDPLUS, we perform a SEARCH to try to determine the new message
UID.

This is the second of a couple modifications.

bug 4092301

Change-Id: I1f548b63becfec8733cb8ba9a3fe6ff4be6fdd83
2011-03-24 10:56:42 -07:00
Todd Kennedy 284d8d7db5 Add support for UIDPLUS capability
When copying messages between mailboxes using standard IMAP, we must perform
a QUERY or FETCH in order to determine the new message UID. However, if the
server supports the UIDPLUS capability, the server will return the new UID
as part of the response to the "UID COPY" command.

This is the first of a couple modifications. We still need to fallback to a
less efficient QUERY/FETCH if the server does not support UIDPLUS.

bug 4092301

Change-Id: I9279f7fd70daf85adba3b3e202c12d67ddf91f22
2011-03-23 15:15:45 -07:00
Andy Stadler 45d50a1ccf Don't send ID command to *.secureserver.net
Fixes connection failures with GoDaddy IMAP.

Bug: 3497713
Change-Id: I327d9b24598d7dead2d1b74f4e37d1e5885822a6
2011-03-02 16:13:23 -08:00
Marc Blank 31d9acbf06 Email split, part huit: Refactor constants, clean emailcommon
* There are three pieces to this CL (sorry):
  1) Move and/or rename some constants into emailcommon
  2) Move Utility to emailcommon, moving the few UI
     related utilities back into Email (FolderProperties
     and UiUtilities)
  3) Remove all references to resources from emailcommon
* The three pieces relate in that, between them, they allow
  the emailcommon static library to compile cleanly

Bug: 3442973

Change-Id: Ic5e3abaa2a1b36999e0b6653c6c2134ea1bd544f
2011-02-14 12:18:10 -08:00
Todd Kennedy 32311cce01 Implement IMAP prefix support
We support two different ways for an IMAP prefix to be specified:
  1. A text field on the IMAP configuration page. This is the most obvious to
     the end user. It is also an explicit, manual configuration.
  2. RFC2342 defines a NAMESPACE IMAP command to be able to query the prefix
     from the IMAP server. This is an automatic configuration without any
     user involvement (i.e. the UI will NOT change if a prefix is loaded in
     this way)

If the user goes to the trouble of specifying a prefix, we will always honour
it instead of the namespace returned by the IMAP server -- even if the user's
configuration is wrong.

bug 1592696

Change-Id: I6b94c7aaac538f6cd9dc4694b0f1634e8c956bc1
2011-02-11 14:17:48 -08:00
Marc Blank a7bc0319a7 Email split, part six: EmailContent
* Moved EmailContent to emailcommon

Change-Id: Ib3db1bfcfe74554c0e5afd3cfce6d72f26e9aeb9
2011-02-10 19:44:29 -08:00
Marc Blank 2193962ca2 Email split, part quatre: Move along, nothing to see here
* No code was harmed, er, changed in the making of this CL
* All that's happened is that code that is needed by both Email and
  Exchange have been moved into emailcommon
* This required import changes to many files, which explains the
  length of the CL

Change-Id: I4e12455ba057a4a8054fdbd0b578c73afa411c8a
2011-02-10 16:28:37 -08:00
Marc Blank 8a57469460 Email split, part trois: AccountService
* Create AccountService.aidl and AccountServiceProxy in emailcommon
* Implement AccountService in email
* Use AccountServiceProxy in Exchange for account reconciliation,
  notifications, etc.
* Move sync window constants into emailcommon
* Split attachment provider utilities and constants into emailcommon

Bug: 3442973
Change-Id: I89dce28b799b193243c07774dab65d830ae62775
2011-02-10 14:32:01 -08:00
Andy Stadler 7d51b7a05b Remove all compatibility with pre-2.0 data
* Remove LocalStore (pre-2.0 mail database) and its unit test
* Remove UpgradeAccounts (converted pre-2.0 accounts to Provider)
* Remove FolderMessageList (receiver for pre-1.6 desktop shortcuts)
* Remove "upgrading" paths through LegacyConversions
* Clip out dangling references to everything above

Bug: 3292310
Change-Id: I5654d55a0879b00b05b63055b94651855a8ee3ef
2011-02-06 00:54:39 -08:00
Todd Kennedy 8546e21e1e Resolve build warnings; part 2
Change-Id: I76c1a5a4f759071f92eef0574abb20a99bfb32b7
2011-02-03 11:46:40 -08:00
Makoto Onuki f33420e68f Message details: Show only one address per line
Also removed unused field from MessageViewMessageDetailsDialog

Bug 3372971

Change-Id: I8a6d87d006793c0099b380634217624bf9002ead
2011-01-31 16:12:53 -08:00
Andy Stadler 11070a5397 am 275b89d9: am 927dbc7c: Don\'t send IMAP ID unless server supports it
* commit '275b89d96949de6544c7bca999e241f659cf18b3':
  Don't send IMAP ID unless server supports it
2011-01-31 15:20:01 -08:00
Andy Stadler 927dbc7c20 Don't send IMAP ID unless server supports it
Only send IMAP ID to servers that include ID in the CAPABILITY response.
Always sending IMAP ID was found to cause problems with some servers.

Better compliance with RFC 2971.
Thanks to Samsung for debugging & reporting this.

Change-Id: I495f80949f9f811470853a1f2f8e506d8236d8cf
2011-01-31 15:10:49 -08:00
Makoto Onuki 36f2088408 Fix LocalStoreUnitTests
The problem was that we tried to upgrade the db by re-creating a LocalStore,
without closing the existing connection.  The db was still upgraded on the
filesystem, but the old connection kept looking at the old table definition
for whatever reason.

Also cleaned up checkAllTablesFound().  It now shows what columns are
missing when failed.

Bug 3349973

Change-Id: I80f4c67f1bd61cd5e1f12a632978b36a6e0a3b19
2011-01-14 14:36:01 -08:00
Makoto Onuki a826d3fb03 Pixel perfect: Message view
Still waiting for a few missing assets, but it's done other than that.

The divider change is already merged; new layouts all use the framework style.

It's basically all layout changes, except for:
- Now the recepient address line has "Show details", which shows a dialog with
  all to/cc/bcc addresses with the timestamp.
- Now invite response buttons are checkboxes.
  (But the basic behavior doesn't change -- once you check a response,
  the message will be gone, so you can't change the response later.)

Copied message_header_bg from gmail manuall.  It'll look silly without it.

Bug 3138021
Bug 3307021

Change-Id: I6f7eb91d6104c3143a5c58b0c4c6c19929cea477
2011-01-10 15:51:32 -08:00
Andy Stadler f252d5d95e am 42749c91: am 1a791e67: Fix NPE when switching IMAP into TLS
* commit '42749c9105c663e035a0863d7a6bda111b5c7112':
  Fix NPE when switching IMAP into TLS
2011-01-05 08:10:26 -08:00
Andy Stadler 1a791e675b Fix NPE when switching IMAP into TLS
* Update MockTransport to allow TLS connections
* Test TLS connection in ImapStore unit tests
* The bugfix: Re-query capabilities after closing/reopening parser for TLS

(Note: Actually, this is required by the IMAP RFC 3501, 6.2.1)

Bug: 3315939
Change-Id: I51f838043e87750b5712a1bd2e4f9c821b58c808
2011-01-04 20:21:15 -08:00
Makoto Onuki c849936a36 Fix unit tests
- Now ProviderContextSetupHelper.getProviderContext() invalidates DB cache

* MailboxAccountLoaderTestCase
- Save hostauth properly
- (ProviderContextSetupHelper invalidates cache before each test)

Bug 3280911

* SmtpSenderUnitTests
- Use ProviderContextSetupHelper to create isolated context,
  which now also invalidates DB cache

Bug 3280913

* MailboxFinderTest
- When kicking Controller.Result methods directly from tests,
  call the raw callback, rather than the one wrapped with
  ControllerResultUiThreadWrapper, to make it synchronous.

Bug 3280898

* MessageViewTest
- Disable testOpenMessage()
  This test doesn't work because it sets up test data in an isolated
  context but the activity/fragment don't see them because they
  use the real context.
  I have no idea why it worked before... Maybe because there were
  accounts/mailbox/message with the same ID in the DB by chance.

Bug 3280905

Change-Id: I6beb08c58fff102e90bebd2c35f70820268b9e62
2010-12-13 16:29:57 -08:00
Andy Stadler 54ab7a27a3 Fix NPE in pop3 checkcapabilities
* This happens if an open fails immediately (error message in the
  initial banner) followed by a checkSettings.
* The fix is to harden checkSettings to force a clean connection
  every time.

Bug: 2170147
Change-Id: If7403bf517477d2b03b21d71caab511fe45e234c
2010-11-04 23:34:26 -07:00
Andy Stadler ac916da48e Improve handling of content-disposition DO NOT MERGE
* Check array returned by split("=")
* Add unit tests for this case
* Also add unit tests for quoting removal

Bug: 3040796
Backport from: I170f3cd483fe35186194edeb0c3142fb0e2e9b75

Change-Id: I32ccbdbc7264a95a9cd279218cae390e65e82eeb
2010-09-27 15:16:24 -07:00
Andrew Stadler 87fcd03a1b Improve handling of content-disposition
* Check array returned by split("=")
* Add unit tests for this case
* Also add unit tests for quoting removal

Bug: 3040796
Change-Id: I170f3cd483fe35186194edeb0c3142fb0e2e9b75
2010-09-27 15:09:35 -07:00
Makoto Onuki 0be6c7c5cf Merge "DO NOT MERGE: Fix handling IOException in ImapStore" into gingerbread 2010-09-21 10:24:48 -07:00
Makoto Onuki 32517753ea Merge "DO NOT MERGE: Handle multiple IMAP SEARCH results." into gingerbread 2010-09-21 10:24:44 -07:00
Makoto Onuki 75c6a611aa Merge "DO NOT MERGE: Test for interaction between ImapStore and vendor policy." into gingerbread 2010-09-21 10:24:40 -07:00
Makoto Onuki 415b27fbd3 Merge "DO NOT MERGE: Follow-up to the new IMAP parser." into gingerbread 2010-09-21 10:24:18 -07:00
Marc Blank 9afbf947de DO NOT MERGE: Send intro text with SmartForward
* We need to include the intro text (--Original Message--, etc.) to
  SmartForwards, and somehow this got in a past updat
* Add unit test for forwarding
* Fix unit test for reply so that it works localized

Backport of I8d92f00d37a434840ec3eb237f3901cd5dc7ad09

Bug: 2477988
Bug: 2685784
Change-Id: I2b6654413a8eb5ca900f958f49ec9eee5161a365
2010-09-20 18:51:32 -07:00
Makoto Onuki f255081a85 DO NOT MERGE: Fix handling IOException in ImapStore
- mConnection.destroyResponses() should be protected with
if (mConnection != null).
When we get an IOException, we close the connection and null it out in
ioExceptionHandler().  So mConnection can be null at any point after
where ioExceptionHandler() first appears.

- ioExceptionHandler should close its parent ImapFolder only if the argument
connection is mConnection.
Methods like exists() may pass an ImapConnection which is not mConnection
to ioExceptionHandler.  In which case we don't have to close the ImapFolder.

Bug 2898211

Backport of I8f9f45d91f596bb8da1a1575593e652d66deb643

Change-Id: I070458b5535540aba69ad7eee88bd2af8ad5f7b1
2010-09-20 16:45:48 -07:00
Makoto Onuki 29f0638f4d DO NOT MERGE: Handle multiple IMAP SEARCH results.
Apparently IMAP servers may return multiple SEARCH responses for a
single SEARCH command, and we need to handle all of them.

Before the IMAP rework there was 3 methods that issued the SEARCH command.
Two of them ware doing it right, but the other wasn't, which was what
I copied from, unfortunately!

In case you're wondering, originally the test for this method was done through
upper methods, e.g. getMessage().

Bug 2911647

Backport of Ia50072944d5b01c1e59541c3a966067b13910cc4

Change-Id: Iab5d3fa21e403f2e1043990112154fbb72322b02
2010-09-20 16:45:48 -07:00
Makoto Onuki 8aa79ba695 DO NOT MERGE: Test for interaction between ImapStore and vendor policy.
Backport of I092b3a0f2f40d9aa19f2f61066362099c8b3f50b

Change-Id: I492f975e66d67aae62024804a294e796f23d2aad
2010-09-20 16:45:48 -07:00
Makoto Onuki 57ab324a11 DO NOT MERGE: Follow-up to the new IMAP parser.
- Replace string literals in ImapStore with constants.
- Simplifies ImapStore.en/decodeFolderName
- Mix cases in the test data to test for case-insensitivity

Backport of I88424357227bcf78528df5e6a1c4ba45d54cc65b

Change-Id: I254fe82324f6ff530e40ca0cff7073f670cf9aa3
2010-09-20 16:45:48 -07:00
Makoto Onuki ff0712cb1e DO NOT MERGE: New IMAP parser to fix long-lasting problems.
- Almost completely re-wrote ImapResponseParser layer
- We no longer use simple ArrayList and String to represent
imap response.  We have classes for that.  (Type safe!)
These classes are also NPE-free.
(which isn't necessarily a good thing, though)
- A lot of clean-ups and fixes in ImapStore.
- More tests for ImapStore.

Now ImapResponseParser moved to com.android.email.mail.store.imap.parser,
but inside, it's 99% new code.

This CL introduces many new classes, but most of them are small classes
to represent the IMAP response.

Problems that this CL fixes includes:
- Special characters in OK response
- Handling BYE response
- Case sensitivity
- ClassCast/ArrayIndexOutOfBound/NumberFormatException
- Handling NIL/literals at any position

Bug 2480227
Bug 2244049
Bug 2138981
Bug 1351896
Bug 2591435
Bug 2173061
Bug 2370627
Bug 2524881
Bug 2525902
Bug 2538076

Backport of I7116f57fba079b8a5ef8d5439a9b3d9a9af8e6ed

Change-Id: I38b6da7b82110181dc78a2c63c6837c57afa81ae
2010-09-20 16:45:48 -07:00
Makoto Onuki 9d1b9fc784 DO NOT MERGE: Two new tests for the bottom half of ImapFolder.append().
They cover the cases:
- when OK response doesn't have APPENDUID.
- when APPEND fails.

Backport of I13a0fb8aaf2e1cbb5a1f055c9ce56e2891373ea0

Change-Id: Ifb5f8c07a8d956b0f4cc019eac7712ef22b0fa73
2010-09-20 16:45:47 -07:00
Makoto Onuki 286eafcf5f DO NOT MERGE: More tests for IMAP, clean up, and a few bug fixes.
- A few new tests in ImapStoreUnitTests.
- Added TODOs to ImapStoreUnitTests (for mainly NO response handling)
- Renamed ImapStore.releaseConnection to poolConnection.
- Fixed a bug in getConnection where it'd return a closed connection.
- Now getConnection() hanles BYE response for NOOP correctly and treat the
connection as closed.

Backport of I48e5b89049338f7d4f1ac77cd7ac7243945a9575

Change-Id: I529c6667a1e60c67285b7050b2b1e4b67eccc104
2010-09-20 16:45:47 -07:00
Makoto Onuki cd0b60e97a DO NOT MERGE: More test for ImapStore/ImapFolder.
- Also, fixed a potential crash in getMessages().
It could happen when a client is gettign a message list while
another client is removing messages.

Backport of I04b1de6bc384cffb7a5286bcec0a349a3d62a623

Change-Id: I227ecbf5bd68c999ba0ab8cd50ef798ef4ef35e4
2010-09-20 16:45:47 -07:00
Makoto Onuki a599ee773d DO NOT MERGE: Tests for IMAP FETCH
Adding regression test for the new IMAP parser.

Backport of Iac7f5c022e44ca5f06f735e145af15cc459eb61f

Change-Id: Ic84172b6793a9837c2fc4a894fee141da3d19f1d
2010-09-20 16:45:47 -07:00
Makoto Onuki 18d331898f Merge "DO NOT MERGE: Relax MIME date parser." into gingerbread 2010-09-20 16:44:06 -07:00
Makoto Onuki 090489b395 Merge "DO NOT MERGE: Fix flaky tests" into gingerbread 2010-09-20 16:43:48 -07:00
Andy Stadler be2ef97220 DO NOT MERGE Send local IP address with EHLO instead of "localhost".
Bug 1515345

Backport of: I181c9f0d79fbdf62f7df77f72a1ec9653797b6dd

Change-Id: If9da2d9f717814bff6a3aa7e6f1a0a44a49f34d6
2010-09-20 16:21:32 -07:00
Makoto Onuki a780e12db2 DO NOT MERGE: Relax MIME date parser.
Make the date parser accept invalid dates like
"Thu, 10 Dec 09 15:08:08 GMT-0700" which was observed in an email from eBay.

Per RFC, timezone must be either obs-zone (e.g. "GMT") or +/- with 4 digits.
The GMT+/-digits format is not permitted.

Bug 2367124

Backport of I59968274160aeadea70223208b463ee692660056

Change-Id: I3c80eee28d1dcf4c0c211f773a50de0f0839e4ad
2010-09-20 15:50:52 -07:00
Makoto Onuki a8a68b827d DO NOT MERGE: Fix flaky tests
Follow up to I3bf7d340.  Make sure temp directory is set before running tests.

Turned out Application.onCreate doesn't seem to be guaranteed to be run
before unit tests.

Without this, some tests may fail saying: "TempDirectory not set.
Application hasn't started??", if onCreate runs too late.

Backport of Ic5aee939a2c21f9579a643d0729dd0e9ba81022e

Change-Id: I7526e3205fc78a5eb79f0786b831c4f642cbda70
2010-09-20 15:50:49 -07:00
Makoto Onuki 7040017624 DO NOT MERGE: Add static method to get temp dir in Email.
I need to be able to get the temp dir from anywhere without Context
for the new IMAP parser.

Backport of I3bf7d34059399a8253c0760ebc392804ea434412

Change-Id: Idf7f8dffe9d6dd040d1b2311d053d4fc292ba18e
2010-09-20 14:06:50 -07:00
Makoto Onuki 367ebd7fa5 Handle multiple IMAP SEARCH results.
Apparently IMAP servers may return multiple SEARCH responses for a
single SEARCH command, and we need to handle all of them.

Before the IMAP rework there was 3 methods that issued the SEARCH command.
Two of them ware doing it right, but the other wasn't, which was what
I copied from, unfortunately!

In case you're wondering, originally the test for this method was done through
upper methods, e.g. getMessage().

Bug 2911647

Change-Id: Ia50072944d5b01c1e59541c3a966067b13910cc4
2010-08-12 11:10:00 -07:00
Makoto Onuki c14ff6ea45 Fix handling IOException in ImapStore
- mConnection.destroyResponses() should be protected with
  if (mConnection != null).
  When we get an IOException, we close the connection and null it out in
  ioExceptionHandler().  So mConnection can be null at any point after
  where ioExceptionHandler() first appears.

- ioExceptionHandler should close its parent ImapFolder only if the argument
  connection is mConnection.
  Methods like exists() may pass an ImapConnection which is not mConnection
  to ioExceptionHandler.  In which case we don't have to close the ImapFolder.

Bug 2898211

Change-Id: I8f9f45d91f596bb8da1a1575593e652d66deb643
2010-08-11 14:44:09 -07:00
Makoto Onuki ae8fc30b41 Fix "disk I/O error" in LocalStoreUnitTests
The problem was that we didn't close the LocalStores created in these
testDbUpgradeXxx tests.

Also,
- Make sure to close databases.
- Make sure to close cursors.
- Cleard up warnings (unnecessary casts, etc.)

Bug 2859264

Change-Id: Ifaddbb6cf07794a7b5978564ea8fbb3cbf75b978
2010-07-28 13:07:33 -07:00
Marc Blank 80ee607a7c Send intro text with SmartForward
* We need to include the intro text (--Original Message--, etc.) to
  SmartForwards, and somehow this got in a past updat
* Add unit test for forwarding
* Fix unit test for reply so that it works localized

Bug: 2477988
Bug: 2685784
Change-Id: I8d92f00d37a434840ec3eb237f3901cd5dc7ad09
2010-07-09 09:39:58 -07:00
Makoto Onuki 34f29c8a74 Test for interaction between ImapStore and vendor policy.
Change-Id: I092b3a0f2f40d9aa19f2f61066362099c8b3f50b
2010-06-15 13:44:31 -07:00
Makoto Onuki bf58053406 Follow-up to the new IMAP parser.
- Replace string literals in ImapStore with constants.
- Simplifies ImapStore.en/decodeFolderName
- Mix cases in the test data to test for case-insensitivity

Change-Id: I88424357227bcf78528df5e6a1c4ba45d54cc65b
2010-06-01 10:50:15 -07:00
Makoto Onuki 7e5ba0e1ea New IMAP parser to fix long-lasting problems.
- Almost completely re-wrote ImapResponseParser layer
- We no longer use simple ArrayList and String to represent
  imap response.  We have classes for that.  (Type safe!)
  These classes are also NPE-free.
  (which isn't necessarily a good thing, though)
- A lot of clean-ups and fixes in ImapStore.
- More tests for ImapStore.

Now ImapResponseParser moved to com.android.email.mail.store.imap.parser,
but inside, it's 99% new code.

This CL introduces many new classes, but most of them are small classes
to represent the IMAP response.

Problems that this CL fixes includes:
- Special characters in OK response
- Handling BYE response
- Case sensitivity
- ClassCast/ArrayIndexOutOfBound/NumberFormatException
- Handling NIL/literals at any position

Bug 2480227
Bug 2244049
Bug 2138981
Bug 1351896
Bug 2591435
Bug 2173061
Bug 2370627
Bug 2524881
Bug 2525902
Bug 2538076

Change-Id: I7116f57fba079b8a5ef8d5439a9b3d9a9af8e6ed
2010-05-28 15:59:09 -07:00