Commit Graph

79 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 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 0d4fc55861 Email split, part one: EmailService
* Create emailcommon package
* Move EmailService classes to emailcommon package
* Change references to aidl's to emailcommon package
* Add getApiLevel() command to EmailService

Bug: 3442973

Change-Id: Ic7d2115363cdff6ebb86c46650b0a5b2109b1c72
2011-02-10 13:10:38 -08:00
Todd Kennedy 8d8537cd2e Resolve build warnings; part 3
Fixes deprecation warnings

NOTE: This does not resolve hostauth deprecation; that will be fixed
in a separate CL.

Change-Id: I47115516da34effbf885615cb439c9d3e6f95b84
2011-02-03 12:43:12 -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
Andy Stadler 980c2256f1 Catch base64 errors and handle in-place
Bug: 3362752
Change-Id: I63adb8663c90a7710176cc1c481bbfa5b4b859c4
2011-01-24 18:06:53 -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
Marc Blank d3e4f3ca7e Use notifications for login failures
* For now, clicking on the notification takes the user to the
  Welcome activity, as we don't have final flows for the new
  account setup UI
* Need comment on strings; the problem is that notification
  text must be rather short if we're to use the standard
  notification display.  It looks like newer UI will allow
  3 lines instead of 2, however.
* Tested w/ IMAP, POP3, EAS, and SMTP

Bug: 2322253
Change-Id: I7ed6fa5599179870cbcdb14af062e956eff37ec5
2010-10-27 08:56:37 -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 6275e8b144 DO NOT MERGE: Always destroy ImapResponses.
Unfortunately it's hard to write tests for this change, but at least
all tests pass with Idc7b88c4.

Backport of If0335a848dfcc23aecea22c21b2cce73dac7ff6f

Change-Id: I6cb3525bc3c67bbf2fb101488bf95edbead5d299
2010-09-20 16:45:48 -07:00
Makoto Onuki 565f58b9aa DO NOT MERGE: Add TODOs to ImapStore.
Backport of I5a9f246eb81cfca6008f82e8c2ffff8b7f28ba1d

Change-Id: I1422e8ae35e2ba560d1227669b9f720b937033a7
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 80202a9599 DO NOT MERGE: Clean up ImapStore and related classes.
- Introduce Fetchable
- Made static some methods/nested classes in ImapStore
- Removed ImapBodyPart
- Fixed lien breaks

Backport of Iec1aff2771faa28717753d6e2d9db96d940233a9

Change-Id: Ia97257c40a6edbe0abc4937068e9cd20e6c558d8
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 e4cfdfd059 DO NOT MERGE: Simplify MessageRetrievalListener.
Main motivation: not to make the new IMAP parser too complecated.

- Removed messageRetrieved.
Motivation:
- It's not easy to call messageRetrieved() at the proper timing
from the new IMAP parser, and this method wasn't used anyway.

- Renamed messageFinished to messageRetrieved.
And removed the "number" and "ofTotal" arguments.
Motivation:
- They weren't used.  Also there was inconsistency about
what to pass as "numebr".  (i.e. 0-based or 1-based?)  There was
even a bug that caused passing a wrong number.

Backport of If92dbfe681b78a0eea8125188ede63a8f00dcf49

Change-Id: Icdea45e0a9ac567b1cdfb44e975e60bb11815472
2010-09-20 14:07:13 -07:00
Makoto Onuki 550aa6163f DO NOT MERGE: Clean up member variables.
- Fix misnomered fields.  (e.g. static mMember -> static sMember)
- Reduce visibility.  (e.g. mark as private)
- Mark final / static if possible.

Note it's on master.

There's a lot more cleanup oppotunities in the activities, but they're going
to go through a major overhaul, so I didn't bother.

Backport of b3f7dd0169

Change-Id: Ic33f9518f23805716e2aec0ab42edb92107e066c
2010-09-20 14:03:29 -07:00
Marc Blank 7894ee82b3 New attachment download support for Controller (IMAP/POP3)
* Supports download via AttachmentDownloadService

Change-Id: I66143a79b99dcdbd307524ba0b81227f09a00e4a
2010-08-19 15:44:44 -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
Marc Blank d6d874f8c6 Streamline security setup flow
* The setup flow is changed such that the user is asked to activate
  device administration before leaving the setup flow, rather than
  having to wait for the notification to appear, etc.
* Accounts requiring security are created in a security hold state
  to prevent initial sync until device administration is active

Change-Id: I7e33cf98466370ae27414b99018f7aee71e9e237
2010-06-25 09:32:11 -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 977a7d206a Always destroy ImapResponses.
Unfortunately it's hard to write tests for this change, but at least
all tests pass with Idc7b88c4.

Change-Id: If0335a848dfcc23aecea22c21b2cce73dac7ff6f
2010-06-02 09:56:46 -07:00
Makoto Onuki d7470b8687 Add TODOs to ImapStore.
Change-Id: I5a9f246eb81cfca6008f82e8c2ffff8b7f28ba1d
2010-06-01 14:14:21 -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
Makoto Onuki 4f0186c608 Clean up ImapStore and related classes.
- Introduce Fetchable
- Made static some methods/nested classes in ImapStore
- Removed ImapBodyPart
- Fixed lien breaks

Change-Id: Iec1aff2771faa28717753d6e2d9db96d940233a9
2010-05-20 15:12:37 -07:00
Makoto Onuki cbe4ae9291 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.

Change-Id: I48e5b89049338f7d4f1ac77cd7ac7243945a9575
2010-05-19 13:13:18 -07:00
Makoto Onuki 2552b7b705 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.

Change-Id: I04b1de6bc384cffb7a5286bcec0a349a3d62a623
2010-05-18 17:14:30 -07:00
Makoto Onuki dbbd2ba22c Simplify MessageRetrievalListener.
Main motivation: not to make the new IMAP parser too complecated.

- Removed messageRetrieved.
  Motivation:
  - It's not easy to call messageRetrieved() at the proper timing
    from the new IMAP parser, and this method wasn't used anyway.

- Renamed messageFinished to messageRetrieved.
  And removed the "number" and "ofTotal" arguments.
  Motivation:
  - They weren't used.  Also there was inconsistency about
    what to pass as "numebr".  (i.e. 0-based or 1-based?)  There was
    even a bug that caused passing a wrong number.

Change-Id: If92dbfe681b78a0eea8125188ede63a8f00dcf49
2010-05-14 10:44:37 -07:00
Makoto Onuki b3f7dd0169 Clean up member variables.
- Fix misnomered fields.  (e.g. static mMember -> static sMember)
- Reduce visibility.  (e.g. mark as private)
- Mark final / static if possible.

Note it's on master.

There's a lot more cleanup oppotunities in the activities, but they're going
to go through a major overhaul, so I didn't bother.

Change-Id: I3fde73ba5f1f9ff675fff07c510e1e49521dde42
2010-05-11 17:06:37 -07:00
Makoto Onuki 165e8bfe7a Cleanup: Add @Override
(Note it's for froyo-plus-asop)

Change-Id: Ic4211c08586e33c44d5d6267c0c9d37f8c7cdc85
2010-05-07 15:28:26 -07:00
Makoto Onuki af6724527e Added a test for IMAP APPEND
It's a preliminary change for IMAP bug fixes.

Also,
- Fixed a potential bug in ImapFolder.setFlags where it'd throw
  StringIndexOutOfBoundsException if flags is empty.

- Added a generic flag to proguard.flags so that now all methods with
  the "ForTest" sufix are automatically preserved.
  Turned out it wasn't needed for this CL, but it should come in handy
  someday.

Bug 2538076
Change-Id: I49a08afc196c7b7f1f30477dfc38ac5381045d84
2010-04-06 14:33:43 -07:00
Mike LeBeau 38e52ccc72 Fix build breakage caused by mblank in 47050.
Change-Id: Ic67fbc611c707a6ff4de558ca15e848f25b92728
2010-03-30 15:29:51 -07:00
Marc Blank 13e497dd40 Fix NPE in ImapStore.create
Bug: 2557382
Change-Id: Ia2135e332162b0ae9d0ab85fbcc532ead089e815
2010-03-30 12:43:28 -07:00
Doug Zongker 6cec1104fe relocate android.util.base64.* -> android.util.*
b/2553469 - API REVIEW: android.util.base64

Change-Id: I5394427a8e2c94b87ca45a533e417f7088a69f8f
2010-03-29 13:23:39 -07:00
Andrew Stadler c4fcd852ba Eliminate duplication in Yahoo! sent mailbox
* Yahoo! is not supporting search by UID so I can't identify the new
  the UID after I upload.  This inability to correlate the local and
  remote messages means that we wind up syncing the same message back
  down, in a loop, which spawns more messages.
* Yahoo! has partial support for UIDPLUS, and reports the new UID when
  I append (upload) messages.
* Modify IMAP parser to parse response lists
* When APPENDUID is reported, use it (and skip the search)
* Modify the few other existing users of response lists to use the
  parsed versions instead.  Provided a couple of lightweight utilities
  to make it easier to work with ImapList.
* Unit tests for most of it.
* Optimization: share a static date/time parser for all IMAP connections

Bug: 2448220
Change-Id: Ic10fc1a195ccf4671a498188cc8b17848c8d9df7
2010-03-18 10:11:08 -07:00
Makoto Onuki 69ade70f2d Log recent network activities when IMAP parser crashes.
Added DiscourseLogger, which stores last N (currently 64) lines of IMAP
commands sent to the server and responses received from the server.

We dump it to logcat when the IMAP parser crashes, that is, a) getting a
RuntimeException in ImapFolder.fetch() or b) getting a Runtime/IOException
in ImapResponseParser.

Bug 2480227

Change-Id: I6b5a728a7df106627ec29bb3c7c04a97a99b444b
2010-03-10 13:08:09 -08:00
Andrew Stadler 44552da606 Reduce memory overhead in Message and MimeMessage
Message and MimeMessage were creating a lot of unnecessary sub-objects
even when not needed, so do a bunch of lazy initialization.  This should
raise the bar on the size of gigantic inboxes giving us trouble.

* Specific optimizations:
  * Replace date formatter with a shared static
  * lazy create mHeader (ArrayList)
  * lazy create mFlags (HashSet)
  * optimize MimeHeader fields class
  * lazy create local message-ID (expensive-to-make uuid String)
  * make message-id string less expensive to create
* Other cleanups:
  * add some override annotations
  * privatize some members
  * update a fragile test (not a deep fix, it's still fragile)

Side effect, should be faster too.

Bug: 2357564
Bug: 2093422
Change-Id: I8a873879d402e2662339d5398ad0b15da6e580e9
2010-03-09 20:30:47 -08:00