Commit Graph

79 Commits

Author SHA1 Message Date
Marc Blank 3a5c1fb274 Email split, part neuf: Setup, logging, attachment glue
* Make "Exchange" option in account setup depend upon availability of the
  Exchange EmailService
* Make presence of Exchange logging depend upon availability of the
  Exchange EmailService
* Make AttachmentDownloadService use service rather than ExchangeService
  class
* Move SSLUtils to emailcommon/utility
* Move account manager type defs to emailcommon/AccountManagerTypes
* Update proguard.flags
* This is the penultimate CL for the Email package itself; the next CL
  creates a clean, SDK-compatible Email application

Bug: 3442973
Change-Id: I9162cf5fa6b5a043ded0fdd1e25fd3ce5948ad8f
2011-02-14 16:08:55 -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
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 d306ba3438 Handle query with an id of -1 more gracefully
* In query of an otherwise valid URI with -1 as an id, simply return
  an empty cursor
* Add unit test to verify proper handling of invalid uri's

Bug: 3183245
Bug: 3292080

Change-Id: Ia0c35cbd0f5dd0dc4a8fc794226399644cf1fe13
2010-12-30 15:02:43 -08:00
Marc Blank 1c1bd6a3eb Fix typo in debug code
Change-Id: Iffb3effa3fd659be3df3208bb587fea83bc9116e
2010-12-29 20:51:16 -08:00
Marc Blank e6a22dff39 Throw exception on illegal URI's in EmailProvider operations
Change-Id: I6354c03e7cead81df3764b7d0bd1be0e90271664
2010-12-16 17:12:42 -08:00
Marc Blank 75a873be84 Implement prefetch of IMAP/EAS attachments
* Load attachments in the background for IMAP/EAS messages
* Download an attachment from account X if:
  1) 25% of total storage free
  2) Attachments for X use < 1/N of 25% of total storage, where N is
     the number of AccountManager accounts
* Add accountKey to Attachment table for performance

Change-Id: I913aa710f34f48fcc4210ddf77393ab38323fe59
2010-12-13 15:32:57 -08:00
Makoto Onuki 9d5aaeacd6 Follow-up to Id18fb940. Tests, fix transaction.
Change-Id: If425db7d729e260102a9db82b98e14ff6f6be143
2010-12-03 10:55:27 -08:00
Makoto Onuki edb8af826c Update/invalidate cache properly in update()
This prevented EAS accounts from showing the new message notification,
because Account.newMessageCount in the cache didn't get updated
properly.

Bug 3249319

Change-Id: Id18fb94083e2f441c293414f790a26f82869e3da
2010-12-02 15:39:30 -08:00
Marc Blank 1b9337ea4f Wireframe email widget
* Formatting and assets are preliminary
* Functionality correct
* Needs cleanup, etc.

Change-Id: I75051df93d233ef529a616c7a9efae403d320bd2
2010-12-01 13:37:57 -08:00
Marc Blank fab77f147f EmailProvider content caching
* In this CL, we cache individual rows, based on the CONTENT_PROJECTION
  defined for the most common queries (Account, HostAuth, Mailbox, and
  Message)
* Queries on individual rows (most often Class.restoreClassById()) will
  look to the cache first, rather than querying the database
* Queries on smaller projections will build MatrixCursor's from cached
  data
* Write-through caching updates the cache with changed columns
* Experiments with live data indicate that > 95% of queries that are
  cacheable (single row, no selection) can be retrieved from the cache,
  thereby saving a great deal of disk access.
* Timing experiments show that cache hits are > 40x faster than cache
  misses
* Unit tests for the various classes exist, with more coming

TODO
----
* More unit tests

Change-Id: I386a948a2f4cc02b6548d07d9b2fefd1e018a262
2010-11-16 08:58:05 -08:00
Marc Blank c81bef6720 Drag & Drop "move to folder"
* Drag & Drop "move to folder" preliminary implementation
* Use "drag handle" button to initiate drag
* Use the message list item itself as the drag thumbnail for
  one item; "Move N messages" for multiple (not implemented)
* Disable MailboxList update during drag
* Use ListView itself as drag/drop target

Bug: 3138004
Change-Id: I9243e4f583cf91caa1b9dd04fd64d52e8b28fa30
2010-11-04 08:45:24 -07:00
Marc Blank 07597e547b Use LIMIT parameter in getFirstRowX calls
* Also, rename the LIMIT parameter to be consistent with naming
  conventions

Bug: 3046494

Change-Id: Iafc7f7d76f45bc7988e5d63783359082756b7ffa
2010-09-29 12:27:42 -07:00
Marc Blank 0efe738e05 Add Uri for Message queries that include a LIMIT
* Use a query parameter (e.g. ?limit=2); LIMIT works with any
  query

Change-Id: Idd106ab4b61aec237ac9676a201e797c4f65f15b
2010-09-28 10:58:36 -07:00
Makoto Onuki 261d6c3f0c Notify only account cursors when resetting new msg count
- Resetting the new message count is now correctly done on a BG thread.
- Added special content provider URI to reset the count.
  (/resetNewMessageCount)
- This URI only supports update, which will notify only account
  cursors.
- Fixed a problem that an insert with MAILBOX_ID/MESSAGE_ID/ACCOUNT_ID
  triggers two notifications.

- This CL changes how we use notification URIs, but unfortunately
  no tests for this part.  It turned out MockContentResolver doesn't
  support the notification mechanism, which made it very hard
  to write tests.

Bug 2911646

Change-Id: I35b30a7e6bf2d57510486c7ed19b9f263d8c9b58
2010-09-15 10:53:17 -07:00
Makoto Onuki 7bcf1882bc EmailProvider related clean up
- Removed unused URI definitions.
- Added SuppressWarnings to CONTENT_URI's in EmailContent

Change-Id: Id1e746ef5ab86dd76dc1b7dd38a5a00d052bddab
2010-09-10 15:26:48 -07:00
Makoto Onuki 5b0c2c7f34 Fix tests broken by I2bf5de4e (Clean-ups for EmailProvider)
My previous CL broke some tests.
- make sure to set 0 to unreadCount when adding a new row
- when updating messageCount in the tests, directly manipulate
  the DB.  (the provider no longer allows this)

Change-Id: Ib569349707007badf4f23600fbca37110c78fa6d
2010-09-10 14:37:01 -07:00
Makoto Onuki f678a8e67a Clean-ups for EmailProvider
- Don't allow manual modification of unreadCount/messageCount
  (We used to check only unreadCount in update().)
- Do the integrity check at the very first in update().
  I think the old place was really problematic because we opened
  the database in a few lines above and kept it in a local variable.

Change-Id: I2bf5de4e4e45b40c11b951dd2255f8193c26f1aa
2010-09-10 13:27:12 -07:00
Makoto Onuki d36d911fac Add a flag to check the current thread on db accesses
Added Email.DEBUG_THREAD_CHECK.  If true, EmailProvider warns if certain
methods are called on the UI thread.

Change-Id: I6db9e45f2e449a31850c223fc9eec0fb9a575cb1
2010-09-08 18:19:36 -07:00
Makoto Onuki ddc8dea2bd Fix upgrade problem in I84a2cbe1
I84a2cbe1 didn't upgrade the deleted/updated tables.

Bug 2980891

Change-Id: Ifb0800bab58978352f2239f99186d0503e0dd899
2010-09-07 13:27:49 -07:00
Marc Blank e7b9e4ab94 Add snippets to messages
* Add 'snippet' column in Message table and handle upgrades to the
  new schema
* Generate a snippet from either HTML or plain-text message body,
  removing tags, extraneous whitespace, and other superfluous text
  along the way.  Store the snippet in the Message table
* Clean up MessagesAdapter to use the pre-existing list projection
  and constants
* Write unit tests for snippet creation
* The UI in this CL is always single-line, ellipsized

TODO: Handle two-line subject if portrait and XL

Change-Id: I84a2cbe10957975942edad6eb1255a726924a78a
2010-09-03 23:23:19 -07:00
Makoto Onuki 6c36b4c613 Add shutdown() to providers.
They're needed for unit tests.
I was hoping this would solve some of the unit test issues, but it didn't look
like so.  But still they're nice to have.

Change-Id: Ibf6ae78055560d27aac5934d567a17084de99d84
2010-08-23 12:36:57 -07:00
Marc Blank 09fd4d0a18 New asynchronous attachment loading code
* Create AttachmentDownloadService to manage all attachment downloads
  1) User requested
  2) Required for email forwarding
  3) Opportunistic downloads to enhance offline use
* New attachment related UI (pending UX approval, of course)
  1) MessageView (attachment actions, progress bar, etc.)
  2) MessageCompose (attachments for forwarded messages)
  3) Associated toasts, notifications, etc.

TODO:
* Unit tests
* Cache Management (separate CL)

Change-Id: I7864a5fb1c3f4f2be68d98341a971edc6cbacfe1
2010-08-19 14:01:08 -07:00
Makoto Onuki 574854b528 Add the messageCount column to the mailbox table.
- Use trrigers to keep them up-to-date.
- Batch-update them upon upgrade.

- Motivation:
  On the mailbox list, we show the number of messages in trash/drafts.
  We currently do this with count(*) on the fly, which is okay
  because MailboxList is really shown right now.
  However, on the 2 pane, it's always shown and constantly refreshed,
  so the use of count(*) can be a huge penalty.

  It also make the code significantly simpler.

Change-Id: I26efa238d5183df43420a65925876248ef6c6cb6
2010-07-30 17:37:28 -07:00
Makoto Onuki 20225d5760 Explicitly send ICS files in UTF-8.
- In memory attachments are now stored as byte[], not String.
  We can store any type of contents now.
- Added blob content_bytes to the Attachment table.
  The content field is now deprecated and not used.
- Explicitly convert ICS files to UTF-8.

- Added Utility.to/fromUtf8().

Bug 2509287
Change-Id: I3785a365a9a34039ec12ba82bd857dcdbc4de92d
2010-03-15 10:51:58 -07:00
Andrew Stadler 3aaba9eb87 First part of Exchange meeting request/reply implementation
* Added two columns to Attachment in EmailProvider
  content: content that is written directly as an attachment
  suppressDisposition: to suppress the content-disposition header
  All meeting invitation emails use these two columns; the first
  for ics attachment data (which is quite small, rarely over 1k),
  and the second to indicate NOT sending the content-disposition
  header; without this, Exchange will consider the ics as an
  attachment rather than an iMIP style message (rfc2447)
* Modified tests to include these columns; added upgrade code for
  new database version
* New columns and code are designed to be usable outside Exchange,
  although there are no other clients of the code at this point.
* Modified Rfc822Output to use the content field, if present, in
  lieu of retrieving attachment data via URL; added support for
  suppressing the Content-Disposition header
2010-02-22 12:57:33 -08:00
Marc Blank 4006e5fc22 Add meetingInfo column to Message; use for meeting invites
* Added a meetingInfo column to the Message database
* When a meeting invite is received, the start time is stored here
  in ms from start of epoch.  Note that this field is defined to be
  a String, for extensibility
* Update ProviderTests

Change-Id: If44892d27ccc5ebdc1f8667befafb8b8a27a2cf4
2010-02-16 10:18:33 -08:00
Makoto Onuki 91237e9dcb Adding script for building Email app without exchange.
remove-exchange-support.sh makes it possible to build the email app without
exchange support.

This script:
- removes all packages under com.android.exchange.
- removes all lines surrounded by EXCHANGE-REMOVE-SECTION-START and
  EXCHANGE-REMOVE-SECTION-END

And the resulting source should still build and run fine.

Bug: 2369784
2010-02-03 11:39:46 -08:00
Makoto Onuki faed6178b1 Move Eas.ACCOUNT_MANAGER_TYPE out of the package.
Moved Eas.ACCOUNT_MANAGER_TYPE to Email.EXCHANGE_ACCOUNT_MANAGER_TYPE.

This constant is not related to the exchange protocol, and referred in
a lot of different places.  Moving it out of the package will make it a lot
simpler when removing exchange dependency.
2010-02-01 15:38:15 -08:00
Andrew Stadler 345fb8b737 Add utilities for processing account security policies
* Add security sync key & signature columns
* Add utilities for easy read/write of security columns
* Write aggregator for multiple accounts
* Simple API's for exchange security (very preliminary)
* Unit tests of above

Bug: 2387961
2010-01-26 17:24:15 -08:00
Andrew Stadler fc8d943a82 Add security column to Account
* Upgrade accounts table to add security column
* Read/Write new column
* Backup/Restore new column
* Unit tests for all of the above
* First cut at defining bitfields (non-binding, just putting down ideas)

Bug: 2387961
2010-01-21 11:48:02 -08:00
Marc Blank 0e1595c177 Handle unexpected deletion of EmailProvider database
* Addresses #2226426
* If the user deletes Email data, or if data corruption causes
  EmailProvider.db to be deleted, we will be in an inconsistent
  state with any existing Exchange accounts, since the AccountManager
  will still know about them, contacts (and eventually calendar) items will
  continue to exist, etc.
* Run an integrity check when the provider is created, deleting any
  orphaned EmailProvider.db or EmailProviderBody.db
* Catch SQLiteException's in the Provider and do an integrity check
  if any is caught

Change-Id: I47d523b90a6b8f71ba8e13fba4b04846b3da1b1d
2009-12-07 21:12:57 -08:00
Vasu Nori b720ed3183 revert previously submitted CL 34143.
turns out the change I submitted before is not required at all. I mistakenly
assumed sqlite wouldn't be able to handle it. but tested it with the latest
version of sqlite 3.6.20. the old style triggers work fine.
2009-12-03 18:32:58 -08:00
Vasu Nori 8e09bde568 change BEFORE triggers to AFTER triggers - to make them work with sqlite 3.6.20 and beyond 2009-11-25 15:38:42 -08:00
Marc Blank 367963639d Fix SQL for upgrade from ver 6 to ver 7 of Email database
Fixes #2196917

Change-Id: Ia403e50e9ec4ea553d38ded656bba769a4a4dd18
2009-10-20 10:11:26 -07:00
Marc Blank ef83299b99 Clear out orphaned messages in updates/deletes tables
Case #1:
* Fixes #2184702
* Messages can be in the base Messages table, but also in
  Message_Deletes and Message_Updates; the latter two were not
  being purged of deleted messages.
* This CL deletes from all three tables when a Mailbox is deleted
* Also run a check for orphaned deletes/updates when the email
  provider's db is first opened
* Unit test updated to check for proper deletion
* Unit test for the provider check for orphans

Case #2:
* Fixes #2184708
* Messages in Outbox/Drafts can get modified or deleted, but the
  rows added to the updates/delete tables never get removed because
  the boxes don't sync
* Added code to SyncManager.ping (which gets notifications of these
  changes) to delete these rows

Change-Id: Ib53e441136b0da1e88bc220150d631999058a8f0
2009-10-15 10:58:00 -07:00
Marc Blank 5fc57eccef Fix reply/forward for both SMTP and EAS; fixes #2138725
* Add new introText column in the Body database
* Reply/Forward put the appropriate String into this new column
* Rfc822Output uses this when required when streaming the message

Change-Id: I34602fdb3f91692c46fc8bc31ba0e6f680d445a0
2009-09-23 07:31:01 -07:00
Andrew Stadler 0d00889f83 Cleanup Provider Message in preparation for upload
* Remove mServerIntId and its special logic
* Add mServerTimeStamp
* Add column dynamically so we don't lose accounts

Bug # 2097471
2009-09-22 18:31:10 -07:00
Marc Blank 8587aa6121 Make EmailProvider more threadsafe w/r/t transactions
* Since transactions can be nested, get rid of pointless/dangerous
  flag for indicating we're in a transaction.
* Fixes #2131847

Change-Id: I2955e8a7659533e8ee9e71b949a042570466df45
2009-09-19 22:24:52 -07:00
Marc Blank 657de3bfd6 Revert change to AccountManager naming; use email address again
* Forces wipe of existing accounts

Change-Id: I65d08e07a2d74f94f9142e85791d9bf49c100241
2009-09-18 20:48:43 -07:00
Marc Blank e7e1ca432e Change AccountManager username for Exchange to the user's login credential
* This is not a backward-compatible change (sorry)
* Existing AccountManager EAS accounts and contacts are deleted
* Existing EmailProvider data is deleted
* Change works with new code (stadler) to avoid account duplication

Change-Id: Ife09c51fa714d91054d017b497bce603add5375a
2009-09-17 10:06:27 -07:00
Andrew Stadler 6c21942ec4 Implement move-to-trash for IMAP and POP3.
* Define new message-loaded state "FLAG_LOADED_DELETED" (used only for
   POP3, which needs to write sentinel messages that are not displayed.)
* Also renamed the other flags to make the naming more consistent.
* Tweak MessageList query generation to inhibit display of deleted
    message sentinels, and MessagingController won't try to resync them.
* Clean up implementation of Controller.deleteMessage()
* Add support for move to trash to MessagingController.  This operates
    in three primary modes:
  * POP3 local delete (no server-side interaction)
  * POP3 server delete
  * IMAP server delete (and copy to IMAP trash mailbox)
* Add missing implementation in provider to delete all of the attachments
    for a given message
* Fix progress reporting in activities (the test for error vs. progress
    was inverted, which caused progress indicators to keep spinning
    after errors.)
* Fix broken account settings UI (POP3 delete policy was not persisting)

Addresses bug 2097409

TODO delete from trash / empty trash

Change-Id: I00188e6dc2093823106e009f35b68c760227c9e6
2009-09-10 12:44:05 -07:00
Marc Blank e256983193 Add sourceKey to Body table; add flags for reply/forward in Message
* Set reply/forward flag and sourceKey as appropriate in MessageCompose
* Update provider tests accordingly

Change-Id: I7f49d80a735314a1a38f09fbf1f234257c41af8c
2009-09-08 16:42:53 -07:00
Marc Blank 9be10e62ed Remove the "unique" requirement for serverId; it should never have been there
* People using multiple accounts without this change could end up with missing folders
* Fixes 2099514
* Database version incremented; this change will cause a database wipe

Change-Id: I08d23fa54d8194758e1f7c2ffb528a14bc184f08
2009-09-04 16:36:39 -07:00
Andrew Stadler 936babc145 Bulk change of columns, LAST TIME.
* Add reply columns to Body
* Remove a bunch of unused columns from Message
* Update SQL tables, content read/write, etc.
* Small tweaks to app code that was not-really-using the old columns.
* Update existing unit tests for new/changed columns
* Disable TagsTests to solve a tests failure (prexisting, not caused by
    this CL)

Change-Id: Ief493796dfe219669755170d76786f91570cbb9b
2009-09-01 23:19:12 -07:00
Andrew Stadler 77398c4289 Reenable Load More Messages for IMAP/POP
* Properly reset all mailbox limit values
* When load more messages is clicked, increment limit and resync
* Also fixed a race condition in provider

Resolves bug 2065626

Change-Id:	If50f25a5cb3b549b3acc48406c78533ad86ed4d5
2009-08-23 23:45:54 -07:00
Marc Blank c0c9c33322 Add URI's that atomically add a value to a particular field (Account or Mailbox)
* Message, etc. could be added, if this had a use case
* Unit test added for both Account and Mailbox cases
* Eclipse changed some parens around; it won't happen again
2009-08-20 10:27:10 -07:00
Marc Blank a867ebba62 Have body database attach just once, and never detach
* Much cleaner implementation
* Prevent errors when various threads collide for attach
2009-08-18 14:05:40 -07:00
Andrew Stadler 4a8c70c09b Add "num new messages" field to Account
* Reset DB version to "1"
* Added field and support code (save, restore, & parcel)
* Added forgotten mProtocolVersion to parcelable code
* Added unit test for parceling

Also, fixed race condition in SyncManager that was underlocking the
wake locks during tests.
2009-08-18 12:14:15 -07:00
Mihai Preda 9627d014e1 MessageCompose: update body on save.
- plus unit tests.
- and some attachment refactoring.
- move PROJECTION_ID up to EmailContent.
- add index on messageKey to Attachments and Body tables.
- add missing Columns.ID field in EmailContent.
2009-08-17 13:43:56 +02:00