Commit Graph

102 Commits

Author SHA1 Message Date
Todd Kennedy daf869cf60 Use an Account object to create a mail sender
Instead of boiling the account down to an unusable URI, just pass along
the Account object.

Change-Id: Ida408912de29734c8f4ed9cdf09a4d633dd03002
2011-04-20 11:14:02 -07:00
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
Ben Komalo 2577842269 Misc fixes and dead code removal.
Change-Id: I48b2fa5f7bf619197d882c71e8b174d31d130e26
2011-04-11 14:01:01 -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
Todd Kennedy c17e9ce85f Don't sync messages moved from the sent folder
Modified location of the test to processUploadMessage() method. We do this to
prevent creating multiple EmailContent.Message objects.

bug 4096266

Change-Id: Id83d3703283c0cd89a60c6210976093d39fb6934
2011-03-21 16:13:15 -07:00
Todd Kennedy dece5050c2 Don't sync messages moved from the sent folder
When processing message updates, we handle messages in the "sent" folder
specially. We continue to do that. However, we must also check that the
given message is still in the "sent" folder.

bug 4096266

Change-Id: Iaa47512fad287e63d8216b755a761b52b324cfff
2011-03-17 13:16:36 -07:00
Andy Stadler 3a58509b2a Add parent key to Mailbox schema
Bug: 2028418
Change-Id: I79d48befe7754692a3cab6c8851105bb399431f5
2011-03-01 10:45:50 -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 f92dd2bf3e Don't display toast for background download failures
When downloading attachments in the background, do not display any errors
on the display.

NOTE: This is a partial fix for general background attachment downloading issues

bug 3373982

Change-Id: I874ed902bde293303e10308f38b992b2bb15b6aa
2011-01-21 15:17:29 -08:00
Makoto Onuki aef9515ee7 Controller.Result callbacks should all have accountId
- Added accountId to loadAttachmentCallback/loadMessageForViewCallback

- Cleaned up LegacyListener/MessagingListener.
  Removed the constructors which take messageId and attachmentId, which
  are used to bridge loadAttachmentProgress, which the callsite doesn't know
  these IDs.  The inconsistency (only loadAttachmentProgress() uses the member
  messageId) doesn't look too good, so extracted this into a separate class,
  MessageRetrievalListenerBridge.

Change-Id: I46303e50df2b0e1fe8616e7c9cef632ac14f23aa
2010-12-10 18:11:44 -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 1ed2c7a15d Fix potential NPE
Happened to find this.

Change-Id: I0b71d80a421adad196d8cd113001f2f9fe5a9445
2010-09-14 17:26:13 -07:00
Marc Blank e302d06258 Fix problems with repeating notifications for synced messages
* Existing code reloads long POP/IMAP messages at every sync
* If the server is POP3, or the IMAP message is unread, this
  will lead to redundant notifications of new message arrival
* The fix avoids repeated message reload

Bug: 2892705
Change-Id: I8dc22966282655c8645362d672a083a1c37f554c
2010-09-08 15:43:36 -07:00
Marc Blank 85cf69d371 Fix "move to folder" for both IMAP and EAS
* We were zero'ing the server id BEFORE the move, rather than
  afterward; this is fixed in the current CL

Change-Id: I4a5f2b2de5794a110a8f657c80dfeac4955b5909
2010-08-26 15:42:15 -07:00
Marc Blank b53b150105 IMAP implementation of "move to folder"
* Clean up Controller.deleteMessage to work with new EmailContent
  utility methods, and move out of the UI thread
* Add unit test for Controller.moveMessage

Change-Id: Ic49e2ecc7ef2252dd4d51f4c3b313b936fda78b6
2010-08-26 10:43:28 -07:00
Marc Blank 4dcb1c5fda Fix attachmentExists (recognize mContentBytes)
* Add unit test for attachmentExists

Bug: 2937856
Change-Id: I020f58740618c084676bbf1cdfad3795edb07688
2010-08-25 22:34:22 -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 21efedb67f Rework/cleanup of "refresh".
Added RefreshManager, which is responsible for getting refresh requests
from UI and keeping track of what is being refreshed.

Conceptually it's a part of Controller, but extracted for easier testing.

- Now sendPendingMessagesForAllAccounts() is owned by RefreshManager
  rather than Controller.
- Also updateMailboxRefreshTime/mailboxRequiresRefresh have been moved
  in from the Email class.
- Now MessagingException implements a method to return an error message
  for the UI.

The refresh button on 2-pane doesn't work as intended yet, because the
spec is a bit too complicated (as described in the TODO in
MessageListXLFragmentManager.onRefhres()).

This change touches many file mostly because it cleans up a lot
of code duplication.

Change-Id: I058ab745ccff10f6e574f6ec4569c84ac4a3e10e
2010-08-18 11:06:45 -07:00
Marc Blank 391ae25c43 Handle viewing of attachments that are, themselves, emails
* Add intent filter for application/eml and message/rfc822 mime types,
  launching MessageView with a Uri
* Modify loadMessageTask to handle the Uri by parsing the attachment's
  input stream with Pop3Message.parse(), and then creating an
  EmailProvider message in a special Mailbox created to hold
  "attachment" messages
* Delete all "attachment" messages after the parent message is closed
* Add unit tests

Change-Id: I20276ee006b9f05b889f3c808d3dc407cde26d49
2010-06-22 18:39:18 -07:00
Makoto Onuki 7e1de3c484 Fix NPE in Controller and MessagingController.
Bug 2553401
Bug 2186777
Bug 2721133
Bug 2684365
Bug 2530534

Change-Id: I5185d9196deab5ba3a9866e2de2a9be04a04ca03
2010-06-11 15:54:41 -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 968be441b4 Don't store arbitrary Context in singletons, which causes memory leak.
We have singletons that store a Context passed to getInstance().
The problem is that when we call them, we casually pass any Context at hand.
If it's an activity (which is often the case), it'll never be GCed.

This CL make them store the application context insteaed.

Change-Id: I1abcc2c08d3f8201416d6c14720f041693823b4e
2010-05-20 16:21:06 -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 c563ce1b80 am b8970dab: am e46ac1a6: Cleanup imports. 2010-05-07 15:20:47 -07:00
Makoto Onuki e46ac1a61f Cleanup imports.
(Note it's for froyo-plus-asop)

Change-Id: Ia5b771cd41099ab486ba2e556b441fc7c0affe5f
2010-05-07 14:33:44 -07:00
Makoto Onuki 1f2caa8095 Fix 3 problems that FindBugs found.
Bug 2666278 [findbugs] broken double-lock pettern in Utility.FolderProperties.getInstance()
Bug 2666207 [findbugs] potential NPE in MessagingController.processPendingDeletesSynchronous()
Bug 2666195 [findbugs] Potential NPE in AccountSetupNames.onCreate()

Change-Id: I2ee5bd5b7c80f8bdd32b3c45abb655a3d3fb8c9e
2010-05-07 14:04:50 -07:00
Makoto Onuki cf362a48c1 Collectly preserve the service start-id.
We were passing the wrong arguments, which caused the service left running.

Bug 2646212

Change-Id: Ie5aeaeb80635c8e805fc2e9c6f4aec3b21942740
2010-04-30 14:41:47 -07:00
Andrew Stadler fd249f61dd More work on account migration
* Split account copy loop to do POP3 accounts first, then IMAP
* After upgrading accounts, upgrade folders
* Upgrade messages in those folders
* Preserve attachments on outgoing messages (e.g. drafts)
* Enable composer and start syncing after upgrade
* Fix latent bug in LocalStore (which was not used in Eclair)
* Add tests for upgrade workers in LegacyConversions

Bug: 2065528
2010-03-08 13:53:01 -08:00
Mihai Preda 9ef6f645f5 Controller: modify the test for "attachment already loaded".
Bug 2192510.

update unit test.
2009-10-22 19:27:59 +02: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 f16a3f2f6a Cleanup delete handling issues in POP3
* Removed obsolete "delete after 7 days" option from pop-up prefs
* Mark deleted message sentinels as "read" so they don't contribute
    to unread counts.

Bug # 2157487 and Bug # 2159278

Change-Id: Ic3cbc51d6f5ede2eb923e2d0e5c0dfee377764f5
2009-10-01 01:45:10 -07:00
Andrew Stadler 71754d3f94 Delete attachments when necessary, don't leak disk space
* Add AttachmentProvider.deleteAllMailboxAttachmentFiles
* Call it when server deletes a mailbox
* Confirmed (no change) all message deletes call deleteAllAttachmentFiles
* Unit tests of course :)

Bug # 2069004

Change-Id: I99731e6489fdca4cc9cebdff5fcf9c09d12b7b3a
2009-09-30 23:32:30 -07:00
Andrew Stadler ba64cbcaf8 Watch for null results when updating internaldate.
Fixes bug # 2148971

Note, this condition happens when we APPEND a message to the server
but then we turn around and query for it, and the server reports that
it's not there:

 >>> 7 APPEND "Sent" {490}
 <<< #null# [Ready, for, argument]
 <<< #null# [194, EXISTS]
 <<< #7# [OK, [APPENDUID, 1233339552, 1191], APPEND, completed]
 >>> 8 UID SEARCH (HEADER MESSAGE-ID \
       <pwyc0i5yviwvu5nwio2lwdo5.1254073239445@email.android.com>)
 <<< #null# [SEARCH]
 <<< #8# [OK, UID, SEARCH, completed]
 >>> 9 UID SEARCH UID NULL
 <<< #9# [BAD, UID, SEARCH, error;, bogus, or, incorrect, syntax, \
       of, search, critera]

I don't know why the Yahoo! server did this, but now we'll at least not
crash if they do it again.
2009-09-27 14:36:13 -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 e959645070 Don't drop local mailboxes if we created them.
Reimplement a dropped snippet from the original MessagingController
that preserved locally-created special mailboxes (drafts, sent, etc.)
instead of dropping them when they were not found on the server.

Bug # 2078209
2009-09-25 10:13:12 -07:00
Andrew Stadler fa52e6c956 Clean out old mailbox names logic and fix a couple of bugs.
* Get rid of old Account.getxxxFolderName() calls.
* Clean up any call sites to them
* Properly rename the existing special folder name identifiers
* Use a hash table in MessagingController to improve identification
    of special folders for IMAP accounts
* Fix a bug in Controller, which was creating new server-side folders
    using localized names.
* Fix a bunch of code in Controller that was using mContext, instead of
    using mProviderContext to support testability.
* Fix broken unit tests in ControllerProviderOpsTests

Fixes bug 1904373
2009-09-21 14:44:30 -07:00
Andrew Stadler 9312faea43 Restore lost connection error UI
We lost the reporting of connection errors in the UI.  These were
originally displayed in FolderMessageList, under the name of each folder.

In the new implementation, we borrow the "undo" banner from Gmail and
display it whenever there is a connection error in a mailbox.

* Add banner, and code to animate it on/off the top of the list.
* Toggle banner whenever a connection state change occurs in MessageList
* Toggle banner whenever a connection state change occurs in MailboxList
* Slight change to callback semantics for sendMailCallback
2009-09-18 15:31:37 -07:00
Andrew Stadler 0c4dc85190 Harden against crashes caused by account deletes
The basic failure mode is to delete an account while it is being
synced or some other background activity.  The fixes in this CL will
harden against this, but it will not be a perfect solution; That
will require shutting down all sync, which is difficult in the current
too-many-threads implementation.

Primary bug# 2112564
2009-09-16 10:58:54 -07:00
Andrew Stadler f9ab857a55 Implement delete-from-trash
* Edit Controller.deleteMessage() to handle both cases
* Refactored to start from processPendingActionsSynchronous() and
    dispatch to series of smaller methods to handle deletes vs. updates
    and the details of the various specific operations.
* Added processPendingDeletesSynchronous() which looks for delete-from-
    trash and does the right thing locally and/or remotely.

Fixes bug # 1811026
2009-09-10 16:03:34 -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 242fde1920 Fix NPE in bug #2080357
Change-Id: I07c0b65e16568e9cf182b70302f2a1ce90d2581b
2009-08-27 15:58:44 -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