Commit Graph

36 Commits

Author SHA1 Message Date
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
Makoto Onuki 726a9fcef3 Ignore FETCH responses that don't have UID.
We've observed that the secure.emailsrvr.com email server returns an excess
FETCH response for a UID FETCH command.  Excess responses don't have the
UID field, even though we request, which led the response parser to crash.

This patch fixes it by making the parser ignore response lines that don't
have UID.

Bug: 2441065
2010-03-01 16:00:05 -08:00
Andrew Stadler cb95fbe135 Send CAPABILITY to all IMAP servers
* Send CAPABILITY to all servers, not just when we check TLS
* Feed capabilities into IMAP ID generation
* Unit tests updated

Bug: 2332183
2010-02-25 22:48:11 -08:00
Makoto Onuki 8068c99945 Don't use hidden APIs
- The entire android.pim package is hidden.
  Use java.text.ParseException instead of android.pim.DateException.

- TelephonyManager.getDefault() is hidden.
  Use Context.getSystemService() instead.

- Use newly added Base64 in the framework.

Bug 2226160
2010-02-22 12:49:52 -08:00
Doug Zongker 33c972e0c6 use the framework Base64 instead of android-common
Change-Id: Ib4f75f66fe8acb1bb5de614bb10e8c938b1d27ef
2010-02-16 09:10:18 -08:00
Doug Zongker f44a40cda1 replace Email's private base64 class with one from android-common
Convert all usages of com.android.email.codec.binary.Base64 to use
com.android.common.Base64 instead, except for Base64OutputStream
(which doesn't exist in android-common yet).

Change-Id: I339a1f451245138187080c7444fcabef8d13f8aa
2010-02-08 20:26:02 -08:00
Andrew Stadler ecb1af8041 Finish up IMAP ID implementation
* scrub all external strings to keep them compliant for IMAP protocol
* move Build.MODEL to x-android-device-model
* send x-android-mobile-net-operator
* send AGUID
* unit tests for above
* retrieve providers from VendorPolicyLoader

Bug: 2332183
2010-02-01 15:53:46 -08:00
Andrew Stadler 468371917e IMAP ID
* Add IMAP ID command to all login sequences
* Send generic information for now
* Explicitly catch & discard parsing errors, since we really don't
  care if the command succeeds or not.
* Unit tests

Bug: 2332183
2010-01-25 18:40:45 -08:00
Andrew Stadler b6756688b1 Handle IMAP empty bodies more safely
Some IMAP servers return NIL if you BODY.PEEK[TEXT] a messsage with
no body, instead of the more canonical {0}CRLF.  Instead of messing with the
parser to deal with that, it makes more sense not to try and fetch empty
bodies.  So there are three changes:

* Don't fetch parts when size = 0
* Don't append "null" when there is null body text
* Slight change to attachment handling so size is reported >0
* Unit tests on some of the related lower-level protocol stuff

Bug http://b/issue?id=2160387

Change-Id: Ifb8fb0ed5ce7297908e1ae8d5a02dda5975c4a3c
2009-10-07 11:42:27 -07:00
Andrew Stadler e4a7cc440f Re-enable modernized version of "optional" SSL/TLS
* Add "Accept all certificates" modes to incoming/outgoing secure choices
* Change URI scheme slightly to make "trust" a flag, not part of the
    protocol.
* Change Stores to know about new URI scheme
* Slightly rework Transport API to make "trust" an independent flag
* Adapt HostAuth to handle new Uri scheme
* Remove the old ambiguous "optional" code, which was allowing
    some unsigned certificates, but was *also* allowing TLS to
    optionally start (though not SSL, despite the UI strings.)
* Add a few unit tests to EmailContent
* Add logging and a bunch of comments to TrustManagerFactory, and a bit
    of simple cleanup to make it more readable.
* Add missing conversion of SSLException->CertificateValidationException
    in TLS so we get the correct certificate errors from TLS too.
* Re-enable TLS for mac.com accounts (which had a certificate problem)

Fixes bug http://b/2119755, http://b/1374780, and probably a raft of
earlier and/or external bugs about certificate problems.

Change-Id: Iaf99a8da3eaadaa4cdeec224737838b5d6813e55
2009-09-29 15:28:43 -07:00
Andrew Stadler 0d4681cd66 Catch possible NPE in IMAP sync.
I don't know the root cause of the null pointer (possibly a broken
connection earlier in the sync) but we shouldn't be crashing here.

Fixes http://b/2135743
2009-09-28 15:56:38 -07:00
Andrew Stadler b422bda4d6 Messages upsynced to "sent" should be marked as "read".
Part of cleanup of bug 2097471 but also addresses old bug 1362964.
2009-09-25 16:42:36 -07:00
Andrew Stadler c41c47fa07 Enable message upload
* Create logic to detect upsyncable messages in Sent
* Note:  Drafts is now local only for IMAP - no sync, either way
* Rewrite MessageController.processPendingAppend for Provider world
* Write provider message -> legacy message converter
* Fixed bug in IMAP APPEND (it was not picking the right UID for the
    uploaded message.)
* Better handling of server internaldate
* Add constants for new X-Android-Body-Quoted-Part header
* Add EmailContent routines to get each of the 5 parts of the body
* Remove "Load more" from unsynced message lists
* Add toString to MimeHeader for debug support

Bug # 2097471

TODO (next CL): Upload attachments records too

Change-Id: I209182f5adc6b6696919f559e3cbbdd58b3eed3a
2009-09-25 14:54:32 -07:00
Andrew Stadler 423206653f Sync "read" and "favorite" back to server.
* Add \FLAGGED support to IMAP (writeback)
* Add code in Controller to kick MessagingController
* Rewrite pending commands system to scan through provider's updated
    messages table and react
* Fix a unit test that I broke
* Cleaned out some of the old PendingCommand support

Addresses the 2nd half (upsync) of bug 1904385

TODO:
Can I add a unit test for IMAP flag writer?

Change-Id: I5a96a695d4f35fca1395506f165b86d9fb19b543
2009-08-26 23:12:02 -07:00
Andrew Stadler 2ac94a9cc2 Update Star and Read/Unread from IMAP server
* Set the star and the read/unread states properly when a
    message is downloaded for the first time.
* Update them on already-downloaded messages.

This is download only - not upload
Bug 1904385

Change-Id: Id03a0957677bb39f4a57ed0542eaa8accc36ab48
2009-08-25 22:45:11 -07:00
Andrew Stadler 0d10783635 Finish loading large IMAP/POP messages
* Handle messages >25k
* When structure is available (e.g. IMAP) pull in the entire body
    and the list of attachments
* When structure is not available (e.g. POP) pull in a large chunk of
    the body to try and capture the message body at least.
* Implement loadAttachment for IMAP/POP to demand download large items
* Tested with IMAP & POP messages

INCOMPLETE (file bugs):
* implement logic for the old loadMessageForView calls that comes from
    MessageView (when you open a message that's partially-loaded)
* Resolve handling of mimetype when attachment info is read (currently
    we're assuming base64 in a couple of places)
* delete account => delete attachments
* delete attachment => delete file
* create account => clear existing attachments for acct id
2009-08-19 16:09:13 -07:00
Mihai Preda f33986d5cc Eliminate Config.LOGV (deprecated, always false).
Add Email.LOGD as a development log guard.
2009-07-16 14:09:15 -07:00
Andy Stadler 80257af81b AI 149020: Manually merge CLs 148814, 148818 which fix IMAP response parsing to be
able to handle a literal string in the middle of the response.
  BUG=1814528

Automated import of CL 149020
2009-05-19 14:54:49 -07:00
Andy Stadler 5551f7feb2 AI 147714: New, lighter-weight version of CL 147620. Still touches as many files,
due to API change, but still has a smaller footprint.  Also fixes the
  bug in the original, which is that we actually needed to udpate the
  local trash folder, not the remote one.
  BUG=1807499

Automated import of CL 147714
2009-04-24 11:54:42 -07:00
Andy Stadler b633efa2b7 AI 147708: Automated g4 rollback of changelist 147620.
*** Reason for rollback ***
  We figured out a simpler solution affecting fewer files - we
  don't actually need the new remotestore API.
  *** Original change description ***
  Some stores require changing the UID of a message when it is
  copied to a new folder (I'm looking at you, EAS).  Add a callback
  to Folder.copyMessages() which allows the store to report back
  such changes.  Then, add a new api to record the new values:
  Folder.updateMessages().
  For now, the two APIs are linked by a common callsite in
  MessagingController, so the existing stores can use a minimal
  implementation - if they don't call the callback, nobody will
  call the update.
  BUG=1807499

Automated import of CL 147708
2009-04-24 11:13:36 -07:00
Andy Stadler 1df530294d AI 147620: Some stores require changing the UID of a message when it is
copied to a new folder (I'm looking at you, EAS).  Add a callback
  to Folder.copyMessages() which allows the store to report back
  such changes.  Then, add a new api to record the new values:
  Folder.updateMessages().
  For now, the two APIs are linked by a common callsite in
  MessagingController, so the existing stores can use a minimal
  implementation - if they don't call the callback, nobody will
  call the update.
  BUG=1807499

Automated import of CL 147620
2009-04-23 23:16:01 -07:00
Andy Stadler c6039f7d17 AI 146134: Add persistence API for remote stores & folders to use while
syncing.  This provides a key-value store, per folder, that
  can be used by network Stores to record persistent data such
  as sync status, server keys, etc.
  Note that, by definition, this only applies to remote folders
  (e.g. IMAP, POP3). You'll see everywhere that LocalFolder is
  passed null, and this is correct - LocalFolder *is* persistent
  storage and does not need external help.
  Note to reviewers:  The core changes are Folder.java,
  LocalStore.java, and LocalStoreUnitTests.java, so please give
  them the bulk of your reviewer attention.  The other files
  are just following along with minor API changes.  Of those,
  the one worth close examination is MessagingController.java,
  which is the only place in the system where remote Folders
  are bonded with Local Folders and thus where this new API
  comes into play.
  Note to jham:  Can you please take a look at
  LocalStore.LocalFolder.setPersistentString() and recommend
  better SQL foo than my primitive test-then-update-or-insert
  logic, which is not transactional or threadsafe.
  BUG=1786939

Automated import of CL 146134
2009-04-14 10:15:07 -07:00
Andy Stadler cd7e5664f9 AI 146061: Add persistent storage that Store classes can access.
The current design for Store classes (e.g. IMAP) did not provide for
  any persistent storage.  This is the beginning of a mechanism to
  provide that.  It's quite simplisitic - each Store can read/write one
  persistent string - but that's enough for the first simple use case
  (saving some sync data for EAS).
  The core changes here - suggest reviewing first - are in Account.java,
  Store.java, and AccountUnitTests.java.  Everything else is just
  following the API change that was necessary.
  Note that, by definition, this only applies to remote stores (e.g.
  IMAP, POP3).  You'll see everywhere that LocalStore is passed null, and
  this is correct - LocalStore *is* persistent storage and does not need
  access (so far, at least).
  BUG=1786939

Automated import of CL 146061
2009-04-13 20:07:56 -07:00
Andy Stadler ae8ca3fbd1 Automated import from //branches/donutburger/...@143018,143018 2009-03-26 17:05:25 -07:00
The Android Open Source Project 3469902379 auto import from //branches/cupcake_rel/...@140373 2009-03-18 17:39:48 -07:00
The Android Open Source Project 3b85e2c2b5 auto import from //branches/cupcake_rel/...@138607 2009-03-13 13:04:24 -07:00
The Android Open Source Project 96c5af40d6 auto import from //depot/cupcake/@135843 2009-03-03 19:32:22 -08:00
The Android Open Source Project 8c2158a5eb auto import from //depot/cupcake/@135843 2009-03-03 18:28:50 -08:00
The Android Open Source Project 687f9962d7 Code drop from //branches/cupcake/...@124589 2008-12-17 18:05:56 -08:00
The Android Open Source Project 8978aac197 Initial Contribution 2008-10-21 07:00:00 -07:00