UIProvider.java revision 58cad2eea744d41a11c0124e91308e38108d242e
1/*******************************************************************************
2 *      Copyright (C) 2011 Google Inc.
3 *      Licensed to The Android Open Source Project.
4 *
5 *      Licensed under the Apache License, Version 2.0 (the "License");
6 *      you may not use this file except in compliance with the License.
7 *      You may obtain a copy of the License at
8 *
9 *           http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *      Unless required by applicable law or agreed to in writing, software
12 *      distributed under the License is distributed on an "AS IS" BASIS,
13 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *      See the License for the specific language governing permissions and
15 *      limitations under the License.
16 *******************************************************************************/
17
18package com.android.mail.providers;
19
20import android.content.ContentProvider;
21import android.content.ContentValues;
22import android.content.Context;
23import android.content.Intent;
24import android.net.Uri;
25import android.provider.BaseColumns;
26import android.provider.OpenableColumns;
27import android.text.TextUtils;
28
29import com.android.common.contacts.DataUsageStatUpdater;
30
31import java.util.ArrayList;
32
33public class UIProvider {
34    public static final String EMAIL_SEPARATOR = ",";
35    public static final long INVALID_CONVERSATION_ID = -1;
36    public static final long INVALID_MESSAGE_ID = -1;
37
38    /**
39     * Values for the current state of a Folder/Account; note that it's possible that more than one
40     * sync is in progress
41     */
42    public static final class SyncStatus {
43        // No sync in progress
44        public static final int NO_SYNC = 0;
45        // A user-requested sync/refresh is in progress
46        public static final int USER_REFRESH = 1<<0;
47        // A user-requested query is in progress
48        public static final int USER_QUERY = 1<<1;
49        // A user request for additional results is in progress
50        public static final int USER_MORE_RESULTS = 1<<2;
51        // A background sync is in progress
52        public static final int BACKGROUND_SYNC = 1<<3;
53        // An initial sync is needed for this Account/Folder to be used
54        public static final int INITIAL_SYNC_NEEDED = 1<<4;
55        // Manual sync is required
56        public static final int MANUAL_SYNC_REQUIRED = 1<<5;
57
58        public static boolean isSyncInProgress(int syncStatus) {
59            return 0 != (syncStatus & (BACKGROUND_SYNC |
60                    USER_REFRESH |
61                    USER_QUERY |
62                    USER_MORE_RESULTS));
63        }
64    }
65
66    /**
67     * Values for the result of the last attempted sync of a Folder/Account
68     */
69    public static final class LastSyncResult {
70        // The sync completed successfully
71        public static final int SUCCESS = 0;
72        // The sync wasn't completed due to a connection error
73        public static final int CONNECTION_ERROR = 1;
74        // The sync wasn't completed due to an authentication error
75        public static final int AUTH_ERROR = 2;
76        // The sync wasn't completed due to a security error
77        public static final int SECURITY_ERROR = 3;
78        // The sync wasn't completed due to a low memory condition
79        public static final int STORAGE_ERROR = 4;
80        // The sync wasn't completed due to an internal error/exception
81        public static final int INTERNAL_ERROR = 5;
82    }
83
84    // The actual content provider should define its own authority
85    public static final String AUTHORITY = "com.android.mail.providers";
86
87    public static final String ACCOUNT_LIST_TYPE =
88            "vnd.android.cursor.dir/vnd.com.android.mail.account";
89    public static final String ACCOUNT_TYPE =
90            "vnd.android.cursor.item/vnd.com.android.mail.account";
91
92    /**
93     * Query parameter key that can be used to control the behavior of list queries.  The value
94     * must be a serialized {@link ListParams} object.  UIProvider implementations are not
95     * required to respect this query parameter
96     */
97    public static final String LIST_PARAMS_QUERY_PARAMETER = "listParams";
98
99    public static final String[] ACCOUNTS_PROJECTION = {
100            BaseColumns._ID,
101            AccountColumns.NAME,
102            AccountColumns.PROVIDER_VERSION,
103            AccountColumns.URI,
104            AccountColumns.CAPABILITIES,
105            AccountColumns.FOLDER_LIST_URI,
106            AccountColumns.FULL_FOLDER_LIST_URI,
107            AccountColumns.SEARCH_URI,
108            AccountColumns.ACCOUNT_FROM_ADDRESSES,
109            AccountColumns.SAVE_DRAFT_URI,
110            AccountColumns.SEND_MAIL_URI,
111            AccountColumns.EXPUNGE_MESSAGE_URI,
112            AccountColumns.UNDO_URI,
113            AccountColumns.SETTINGS_INTENT_URI,
114            AccountColumns.SYNC_STATUS,
115            AccountColumns.HELP_INTENT_URI,
116            AccountColumns.SEND_FEEDBACK_INTENT_URI,
117            AccountColumns.REAUTHENTICATION_INTENT_URI,
118            AccountColumns.COMPOSE_URI,
119            AccountColumns.MIME_TYPE,
120            AccountColumns.RECENT_FOLDER_LIST_URI,
121            AccountColumns.COLOR,
122            AccountColumns.DEFAULT_RECENT_FOLDER_LIST_URI,
123            AccountColumns.MANUAL_SYNC_URI,
124            AccountColumns.SettingsColumns.SIGNATURE,
125            AccountColumns.SettingsColumns.AUTO_ADVANCE,
126            AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE,
127            AccountColumns.SettingsColumns.SNAP_HEADERS,
128            AccountColumns.SettingsColumns.REPLY_BEHAVIOR,
129            AccountColumns.SettingsColumns.HIDE_CHECKBOXES,
130            AccountColumns.SettingsColumns.CONFIRM_DELETE,
131            AccountColumns.SettingsColumns.CONFIRM_ARCHIVE,
132            AccountColumns.SettingsColumns.CONFIRM_SEND,
133            AccountColumns.SettingsColumns.DEFAULT_INBOX,
134            AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME,
135            AccountColumns.SettingsColumns.FORCE_REPLY_FROM_DEFAULT,
136            AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE,
137            AccountColumns.SettingsColumns.SWIPE,
138            AccountColumns.SettingsColumns.PRIORITY_ARROWS_ENABLED
139    };
140
141    public static final int ACCOUNT_ID_COLUMN = 0;
142    public static final int ACCOUNT_NAME_COLUMN = 1;
143    public static final int ACCOUNT_PROVIDER_VERISON_COLUMN = 2;
144    public static final int ACCOUNT_URI_COLUMN = 3;
145    public static final int ACCOUNT_CAPABILITIES_COLUMN = 4;
146    public static final int ACCOUNT_FOLDER_LIST_URI_COLUMN = 5;
147    public static final int ACCOUNT_FULL_FOLDER_LIST_URI_COLUMN = 6;
148    public static final int ACCOUNT_SEARCH_URI_COLUMN = 7;
149    public static final int ACCOUNT_FROM_ADDRESSES_COLUMN = 8;
150    public static final int ACCOUNT_SAVE_DRAFT_URI_COLUMN = 9;
151    public static final int ACCOUNT_SEND_MESSAGE_URI_COLUMN = 10;
152    public static final int ACCOUNT_EXPUNGE_MESSAGE_URI_COLUMN = 11;
153    public static final int ACCOUNT_UNDO_URI_COLUMN = 12;
154    public static final int ACCOUNT_SETTINGS_INTENT_URI_COLUMN = 13;
155    public static final int ACCOUNT_SYNC_STATUS_COLUMN = 14;
156    public static final int ACCOUNT_HELP_INTENT_URI_COLUMN = 15;
157    public static final int ACCOUNT_SEND_FEEDBACK_INTENT_URI_COLUMN = 16;
158    public static final int ACCOUNT_REAUTHENTICATION_INTENT_URI_COLUMN = 17;
159    public static final int ACCOUNT_COMPOSE_INTENT_URI_COLUMN = 18;
160    public static final int ACCOUNT_MIME_TYPE_COLUMN = 19;
161    public static final int ACCOUNT_RECENT_FOLDER_LIST_URI_COLUMN = 20;
162    public static final int ACCOUNT_COLOR_COLUMN = 21;
163    public static final int ACCOUNT_DEFAULT_RECENT_FOLDER_LIST_URI_COLUMN = 22;
164    public static final int ACCOUNT_MANUAL_SYNC_URI_COLUMN = 23;
165
166    public static final int ACCOUNT_SETTINGS_SIGNATURE_COLUMN = 24;
167    public static final int ACCOUNT_SETTINGS_AUTO_ADVANCE_COLUMN = 25;
168    public static final int ACCOUNT_SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 26;
169    public static final int ACCOUNT_SETTINGS_SNAP_HEADERS_COLUMN = 27;
170    public static final int ACCOUNT_SETTINGS_REPLY_BEHAVIOR_COLUMN = 28;
171    public static final int ACCOUNT_SETTINGS_HIDE_CHECKBOXES_COLUMN = 29;
172    public static final int ACCOUNT_SETTINGS_CONFIRM_DELETE_COLUMN = 30;
173    public static final int ACCOUNT_SETTINGS_CONFIRM_ARCHIVE_COLUMN = 31;
174    public static final int ACCOUNT_SETTINGS_CONFIRM_SEND_COLUMN = 32;
175    public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_COLUMN = 33;
176    public static final int ACCOUNT_SETTINGS_DEFAULT_INBOX_NAME_COLUMN = 34;
177    public static final int ACCOUNT_SETTINGS_FORCE_REPLY_FROM_DEFAULT_COLUMN = 35;
178    public static final int ACCOUNT_SETTINGS_MAX_ATTACHMENT_SIZE_COLUMN = 36;
179    public static final int ACCOUNT_SETTINGS_SWIPE_COLUMN = 37;
180    public static final int ACCOUNT_SETTINGS_PRIORITY_ARROWS_ENABLED_COLUMN = 38;
181
182    public static final class AccountCapabilities {
183        /**
184         * Whether folders can be synchronized back to the server.
185         */
186        public static final int SYNCABLE_FOLDERS = 0x0001;
187        /**
188         * Whether the server allows reporting spam back.
189         */
190        public static final int REPORT_SPAM = 0x0002;
191        /**
192         * Whether the server allows reporting phishing back.
193         */
194        public static final int REPORT_PHISHING = 0x0004;
195        /**
196         * Whether the server supports a concept of Archive: removing mail from the Inbox but
197         * keeping it around.
198         */
199        public static final int ARCHIVE = 0x0008;
200        /**
201         * Whether the server will stop notifying on updates to this thread? This requires
202         * THREADED_CONVERSATIONS to be true, otherwise it should be ignored.
203         */
204        public static final int MUTE = 0x0010;
205        /**
206         * Whether the server supports searching over all messages. This requires SYNCABLE_FOLDERS
207         * to be true, otherwise it should be ignored.
208         */
209        public static final int SERVER_SEARCH = 0x0020;
210        /**
211         * Whether the server supports constraining search to a single folder. Requires
212         * SYNCABLE_FOLDERS, otherwise it should be ignored.
213         */
214        public static final int FOLDER_SERVER_SEARCH = 0x0040;
215        /**
216         * Whether the server sends us sanitized HTML (guaranteed to not contain malicious HTML).
217         */
218        public static final int SANITIZED_HTML = 0x0080;
219        /**
220         * Whether the server allows synchronization of draft messages. This does NOT require
221         * SYNCABLE_FOLDERS to be set.
222         */
223        public static final int DRAFT_SYNCHRONIZATION = 0x0100;
224        /**
225         * Does the server allow the user to compose mails (and reply) using addresses other than
226         * their account name? For instance, GMail allows users to set FROM addresses that are
227         * different from account@gmail.com address. For instance, user@gmail.com could have another
228         * FROM: address like user@android.com. If the user has enabled multiple FROM address, he
229         * can compose (and reply) using either address.
230         */
231        public static final int MULTIPLE_FROM_ADDRESSES = 0x0200;
232        /**
233         * Whether the server allows the original message to be included in the reply by setting a
234         * flag on the reply. If we can avoid including the entire previous message, we save on
235         * bandwidth (replies are shorter).
236         */
237        public static final int SMART_REPLY = 0x0400;
238        /**
239         * Does this account support searching locally, on the device? This requires the backend
240         * storage to support a mechanism for searching.
241         */
242        public static final int LOCAL_SEARCH = 0x0800;
243        /**
244         * Whether the server supports a notion of threaded conversations: where replies to messages
245         * are tagged to keep conversations grouped. This could be full threading (each message
246         * lists its parent) or conversation-level threading (each message lists one conversation
247         * which it belongs to)
248         */
249        public static final int THREADED_CONVERSATIONS = 0x1000;
250        /**
251         * Whether the server supports allowing a conversation to be in multiple folders. (Or allows
252         * multiple folders on a single conversation)
253         */
254        public static final int MULTIPLE_FOLDERS_PER_CONV = 0x2000;
255        /**
256         * Whether the provider supports undoing operations. If it doesn't, never show the undo bar.
257         */
258        public static final int UNDO = 0x4000;
259        /**
260         * Whether the account provides help content.
261         */
262        public static final int HELP_CONTENT = 0x8000;
263        /**
264         * Whether the account provides a way to send feedback content.
265         */
266        public static final int SEND_FEEDBACK = 0x10000;
267        /**
268         * Whether the account provides a mechanism for marking conversations as important.
269         */
270        public static final int MARK_IMPORTANT = 0x20000;
271        /**
272         * Whether initial conversation queries should use a limit parameter
273         */
274        public static final int INITIAL_CONVERSATION_LIMIT = 0x40000;
275        /**
276         * Whether the account cannot be used for sending
277         */
278        public static final int SENDING_UNAVAILABLE = 0x80000;
279        /**
280         * Whether the account supports discarding drafts from a conversation.  This should be
281         * removed when all providers support this capability
282         */
283        public static final int DISCARD_CONVERSATION_DRAFTS = 0x100000;
284    }
285
286    public static final class AccountColumns {
287        /**
288         * This string column contains the human visible name for the account.
289         */
290        public static final String NAME = "name";
291
292        /**
293         * This integer contains the type of the account: Google versus non google. This is not
294         * returned by the UIProvider, rather this is a notion in the system.
295         */
296        public static final String TYPE = "type";
297
298        /**
299         * This integer column returns the version of the UI provider schema from which this
300         * account provider will return results.
301         */
302        public static final String PROVIDER_VERSION = "providerVersion";
303
304        /**
305         * This string column contains the uri to directly access the information for this account.
306         */
307        public static final String URI = "accountUri";
308
309        /**
310         * This integer column contains a bit field of the possible capabilities that this account
311         * supports.
312         */
313        public static final String CAPABILITIES = "capabilities";
314
315        /**
316         * This string column contains the content provider uri to return the
317         * list of top level folders for this account.
318         */
319        public static final String FOLDER_LIST_URI = "folderListUri";
320
321        /**
322         * This string column contains the content provider uri to return the
323         * list of all folders for this account.
324         */
325        public static final String FULL_FOLDER_LIST_URI = "fullFolderListUri";
326
327        /**
328         * This string column contains the content provider uri that can be queried for search
329         * results.
330         * The supported query parameters are limited to those listed
331         * in {@link SearchQueryParameters}
332         * The cursor returned from this query is expected have one row, where the columnm are a
333         * subset of the columns specified in {@link FolderColumns}
334         */
335        public static final String SEARCH_URI = "searchUri";
336
337        /**
338         * This string column contains a json array of json objects representing
339         * custom from addresses for this account or null if there are none.
340         */
341        public static final String ACCOUNT_FROM_ADDRESSES = "accountFromAddresses";
342
343        /**
344         * This string column contains the content provider uri that can be used to save (insert)
345         * new draft messages for this account. NOTE: This might be better to
346         * be an update operation on the messageUri.
347         */
348        public static final String SAVE_DRAFT_URI = "saveDraftUri";
349
350        /**
351         * This string column contains the content provider uri that can be used to send
352         * a message for this account.
353         * NOTE: This might be better to be an update operation on the messageUri.
354         */
355        public static final String SEND_MAIL_URI = "sendMailUri";
356
357        /**
358         * This string column contains the content provider uri that can be used
359         * to expunge a message from this account. NOTE: This might be better to
360         * be an update operation on the messageUri.
361         * When {@link android.content.ContentResolver#update()} is called with this uri, the
362         * {@link ContentValues} object is expected to have {@link BaseColumns._ID} specified with
363         * the local message id of the message.
364         */
365        public static final String EXPUNGE_MESSAGE_URI = "expungeMessageUri";
366
367        /**
368         * This string column contains the content provider uri that can be used
369         * to undo the last committed action.
370         */
371        public static final String UNDO_URI = "undoUri";
372
373        /**
374         * Uri for EDIT intent that will cause the settings screens for this account type to be
375         * shown.
376         * Optionally, extra values from {@link EditSettingsExtras} can be used to indicate
377         * which settings the user wants to edit.
378         * TODO: When we want to support a heterogeneous set of account types, this value may need
379         * to be moved to a global content provider.
380         */
381        public static String SETTINGS_INTENT_URI = "accountSettingsIntentUri";
382
383        /**
384         * Uri for VIEW intent that will cause the help screens for this account type to be
385         * shown.
386         * TODO: When we want to support a heterogeneous set of account types, this value may need
387         * to be moved to a global content provider.
388         */
389        public static String HELP_INTENT_URI = "helpIntentUri";
390
391        /**
392         * Uri for VIEW intent that will cause the send feedback for this account type to be
393         * shown.
394         * TODO: When we want to support a heterogeneous set of account types, this value may need
395         * to be moved to a global content provider.
396         */
397        public static String SEND_FEEDBACK_INTENT_URI = "sendFeedbackIntentUri";
398
399        /**
400         * Uri for VIEW intent that will cause the user to be prompted for authentication for
401         * this account.  startActivityForResult() will be called with this intent. Activities that
402         * handle this intent are expected to return {@link android.app.Activity.RESULT_OK} if the
403         * user successfully authenticated.
404         */
405        public static String REAUTHENTICATION_INTENT_URI = "reauthenticationUri";
406
407        /**
408         * This int column contains the current sync status of the account (the logical AND of the
409         * sync status of folders in this account)
410         */
411        public static final String SYNC_STATUS = "syncStatus";
412        /**
413         * Uri for VIEW intent that will cause the compose screens for this type
414         * of account to be shown.
415         */
416        public static final String COMPOSE_URI = "composeUri";
417        /**
418         * Mime-type defining this account.
419         */
420        public static final String MIME_TYPE = "mimeType";
421        /**
422         * URI for location of recent folders viewed on this account.
423         */
424        public static final String RECENT_FOLDER_LIST_URI = "recentFolderListUri";
425        /**
426         * URI for default recent folders for this account, if any.
427         */
428        public static final String DEFAULT_RECENT_FOLDER_LIST_URI = "defaultRecentFolderListUri";
429        /**
430         * Color used for this account (for Email/Combined view)
431         */
432        public static final String COLOR = "color";
433        /**
434         * URI for forcing a manual sync of this account.
435         */
436        public static final String MANUAL_SYNC_URI = "manualSyncUri";
437
438        public static final class SettingsColumns {
439            /**
440             * String column containing the contents of the signature for this account.  If no
441             * signature has been specified, the value will be null.
442             */
443            public static final String SIGNATURE = "signature";
444
445            /**
446             * Integer column containing the user's specified auto-advance policy.  This value will
447             * be one of the values in {@link UIProvider.AutoAdvance}
448             */
449            public static final String AUTO_ADVANCE = "auto_advance";
450
451            /**
452             * Integer column containing the user's specified message text size preference.  This
453             * value will be one of the values in {@link UIProvider.MessageTextSize}
454             */
455            public static final String MESSAGE_TEXT_SIZE = "message_text_size";
456
457            /**
458             * Integer column contaning the user's specified snap header preference.  This value
459             * will be one of the values in {@link UIProvider.SnapHeaderValue}
460             */
461            public static final String SNAP_HEADERS = "snap_headers";
462
463            /**
464             * Integer column containing the user's specified default reply behavior.  This value
465             * will be one of the values in {@link UIProvider.DefaultReplyBehavior}
466             */
467            public static final String REPLY_BEHAVIOR = "reply_behavior";
468
469            /**
470             * Integer column containing the user's specified checkbox preference. A
471             * non zero value means to hide checkboxes.
472             */
473            public static final String HIDE_CHECKBOXES = "hide_checkboxes";
474
475            /**
476             * Integer column containing the user's specified confirm delete preference value.
477             * A non zero value indicates that the user has indicated that a confirmation should
478             * be shown when a delete action is performed.
479             */
480            public static final String CONFIRM_DELETE = "confirm_delete";
481
482            /**
483             * Integer column containing the user's specified confirm archive preference value.
484             * A non zero value indicates that the user has indicated that a confirmation should
485             * be shown when an archive action is performed.
486             */
487            public static final String CONFIRM_ARCHIVE = "confirm_archive";
488
489            /**
490             * Integer column containing the user's specified confirm send preference value.
491             * A non zero value indicates that the user has indicated that a confirmation should
492             * be shown when a send action is performed.
493             */
494            public static final String CONFIRM_SEND = "confirm_send";
495            /**
496             * String containing the URI for the default inbox for this account.
497             */
498            public static final String DEFAULT_INBOX = "default_inbox";
499            /**
500             * String containing the name of the default Inbox for this account
501             */
502            public static final String DEFAULT_INBOX_NAME = "default_inbox_name";
503            /**
504             * Integer column containing a non zero value if replies should always be sent from
505             * a default address instead of a recipient.
506             */
507            public static final String FORCE_REPLY_FROM_DEFAULT = "force_reply_from_default";
508            /**
509             * Integer column containing the max attachment size in kb.
510             */
511            public static final String MAX_ATTACHMENT_SIZE = "max_attachment_size";
512            /**
513             * Integer column containing a value matching one of the constants from {@link Swipe}
514             */
515            public static final String SWIPE = "swipe";
516            /**
517             * Boolean column containing whether priority inbox arrows are enabled.
518             */
519            public static final String PRIORITY_ARROWS_ENABLED = "priority_inbox_arrows_enabled";
520        }
521    }
522
523    public static final class SearchQueryParameters {
524        /**
525         * Parameter used to specify the search query.
526         */
527        public static final String QUERY = "query";
528
529        /**
530         * If specified, the query results will be limited to this folder.
531         */
532        public static final String FOLDER = "folder";
533
534        private SearchQueryParameters() {}
535    }
536
537    public static final class ConversationListQueryParameters {
538        public static final String DEFAULT_LIMIT = "50";
539        /**
540         * Parameter used to limit the number of rows returned by a conversation list query
541         */
542        public static final String LIMIT = "limit";
543
544        /**
545         * Parameter used to control whether the this query a remote server.
546         */
547        public static final String USE_NETWORK = "use_network";
548
549        /**
550         * Parameter used to allow the caller to indicate desire to receive all notifications.
551         * (Including ones for user initiated actions)
552         */
553        public static final String ALL_NOTIFICATIONS = "all_notifications";
554
555        private ConversationListQueryParameters() {}
556    }
557
558    // We define a "folder" as anything that contains a list of conversations.
559    public static final String FOLDER_LIST_TYPE =
560            "vnd.android.cursor.dir/vnd.com.android.mail.folder";
561    public static final String FOLDER_TYPE =
562            "vnd.android.cursor.item/vnd.com.android.mail.folder";
563
564    public static final String[] FOLDERS_PROJECTION = {
565        BaseColumns._ID,
566        FolderColumns.URI,
567        FolderColumns.NAME,
568        FolderColumns.HAS_CHILDREN,
569        FolderColumns.CAPABILITIES,
570        FolderColumns.SYNC_WINDOW,
571        FolderColumns.CONVERSATION_LIST_URI,
572        FolderColumns.CHILD_FOLDERS_LIST_URI,
573        FolderColumns.UNREAD_COUNT,
574        FolderColumns.TOTAL_COUNT,
575        FolderColumns.REFRESH_URI,
576        FolderColumns.SYNC_STATUS,
577        FolderColumns.LAST_SYNC_RESULT,
578        FolderColumns.TYPE,
579        FolderColumns.ICON_RES_ID,
580        FolderColumns.BG_COLOR,
581        FolderColumns.FG_COLOR,
582        FolderColumns.LOAD_MORE_URI,
583        FolderColumns.HIERARCHICAL_DESC
584    };
585
586    public static final int FOLDER_ID_COLUMN = 0;
587    public static final int FOLDER_URI_COLUMN = 1;
588    public static final int FOLDER_NAME_COLUMN = 2;
589    public static final int FOLDER_HAS_CHILDREN_COLUMN = 3;
590    public static final int FOLDER_CAPABILITIES_COLUMN = 4;
591    public static final int FOLDER_SYNC_WINDOW_COLUMN = 5;
592    public static final int FOLDER_CONVERSATION_LIST_URI_COLUMN = 6;
593    public static final int FOLDER_CHILD_FOLDERS_LIST_COLUMN = 7;
594    public static final int FOLDER_UNREAD_COUNT_COLUMN = 8;
595    public static final int FOLDER_TOTAL_COUNT_COLUMN = 9;
596    public static final int FOLDER_REFRESH_URI_COLUMN = 10;
597    public static final int FOLDER_SYNC_STATUS_COLUMN = 11;
598    public static final int FOLDER_LAST_SYNC_RESULT_COLUMN = 12;
599    public static final int FOLDER_TYPE_COLUMN = 13;
600    public static final int FOLDER_ICON_RES_ID_COLUMN = 14;
601    public static final int FOLDER_BG_COLOR_COLUMN = 15;
602    public static final int FOLDER_FG_COLOR_COLUMN = 16;
603    public static final int FOLDER_LOAD_MORE_URI_COLUMN = 17;
604    public static final int FOLDER_HIERARCHICAL_DESC_COLUMN = 18;
605
606    public static final class FolderType {
607        /** A user defined label. */
608        public static final int DEFAULT = 0;
609        /** A system defined inbox */
610        public static final int INBOX = 1;
611        /** A system defined containing mails to be edited before sending. */
612        public static final int DRAFT = 2;
613        /** A system defined folder containing mails <b>to be</b> sent */
614        public static final int OUTBOX = 3;
615        /** A system defined folder containing sent mails */
616        public static final int SENT = 4;
617        /** A system defined trash folder */
618        public static final int TRASH = 5;
619        /** A system defined spam folder */
620        public static final int SPAM = 6;
621        /** A system defined starred folder */
622        public static final int STARRED = 7;
623        /** Any other system label that we do not have a specific name for. */
624        public static final int OTHER_PROVIDER_FOLDER = 8;
625    }
626
627    public static final class FolderCapabilities {
628        public static final int SYNCABLE = 0x0001;
629        public static final int PARENT = 0x0002;
630        public static final int CAN_HOLD_MAIL = 0x0004;
631        public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
632         /**
633         * For accounts that support archive, this will indicate that this folder supports
634         * the archive functionality.
635         */
636        public static final int ARCHIVE = 0x0010;
637
638        /**
639         * This will indicated that this folder supports the delete functionality.
640         */
641        public static final int DELETE = 0x0020;
642
643        /**
644         * For accounts that support report spam, this will indicate that this folder supports
645         * the report spam functionality.
646         */
647        public static final int REPORT_SPAM = 0x0040;
648
649        /**
650         * For accounts that support report spam, this will indicate that this folder supports
651         * the mark not spam functionality.
652         */
653        public static final int MARK_NOT_SPAM = 0x0080;
654
655        /**
656         * For accounts that support mute, this will indicate if a mute is performed from within
657         * this folder, the action is destructive.
658         */
659        public static final int DESTRUCTIVE_MUTE = 0x0100;
660
661        /**
662         * Indicates that a folder supports settings (sync lookback, etc.)
663         */
664        public static final int SUPPORTS_SETTINGS = 0x0200;
665        /**
666         * All the messages in this folder are important.
667         */
668        public static final int ONLY_IMPORTANT = 0x0400;
669        /**
670         * Deletions in this folder can't be undone (could include archive if desirable)
671         */
672        public static final int DELETE_ACTION_FINAL = 0x0800;
673        /**
674         * This folder is virtual, i.e. contains conversations potentially pulled from other
675         * folders, potentially even from different accounts.  Examples might be a "starred"
676         * folder, or an "unread" folder (per account or provider-wide)
677         */
678        public static final int IS_VIRTUAL = 0x1000;
679
680        /**
681         * For accounts that support report phishing, this will indicate that this folder supports
682         * the report phishing functionality.
683         */
684        public static final int REPORT_PHISHING = 0x2000;
685    }
686
687    public static final class FolderColumns {
688        /**
689         * This string column contains the uri of the folder.
690         */
691        public static final String URI = "folderUri";
692        /**
693         * This string column contains the human visible name for the folder.
694         */
695        public static final String NAME = "name";
696        /**
697         * This int column represents the capabilities of the folder specified by
698         * FolderCapabilities flags.
699         */
700        public static String CAPABILITIES = "capabilities";
701        /**
702         * This int column represents whether or not this folder has any
703         * child folders.
704         */
705        public static String HAS_CHILDREN = "hasChildren";
706        /**
707         * This int column represents how large the sync window is.
708         */
709        public static String SYNC_WINDOW = "syncWindow";
710        /**
711         * This string column contains the content provider uri to return the
712         * list of conversations for this folder.
713         */
714        public static final String CONVERSATION_LIST_URI = "conversationListUri";
715        /**
716         * This string column contains the content provider uri to return the
717         * list of child folders of this folder.
718         */
719        public static final String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
720
721        public static final String UNREAD_COUNT = "unreadCount";
722
723        public static final String TOTAL_COUNT = "totalCount";
724        /**
725         * This string column contains the content provider uri to force a
726         * refresh of this folder.
727         */
728        public static final  String REFRESH_URI = "refreshUri";
729        /**
730         * This int column contains current sync status of the folder; some combination of the
731         * SyncStatus bits defined above
732         */
733        public static final String SYNC_STATUS  = "syncStatus";
734        /**
735         * This int column contains the sync status of the last sync attempt; one of the
736         * LastSyncStatus values defined above
737         */
738        public static final String LAST_SYNC_RESULT  = "lastSyncResult";
739        /**
740         * This long column contains the icon res id for this folder, or 0 if there is none.
741         */
742        public static final String ICON_RES_ID = "iconResId";
743        /**
744         * This int column contains the type of the folder. Zero is default.
745         */
746        public static final String TYPE = "type";
747        /**
748         * String representing the integer background color associated with this
749         * folder, or null.
750         */
751        public static final String BG_COLOR = "bgColor";
752        /**
753         * String representing the integer of the foreground color associated
754         * with this folder, or null.
755         */
756        public static final String FG_COLOR = "fgColor";
757        /**
758         * String with the content provider Uri used to request more items in the folder, or null.
759         */
760        public static final String LOAD_MORE_URI = "loadMoreUri";
761
762        /**
763         * Possibly empty string that describes the full hierarchy of a folder
764         * along with its name.
765         */
766        public static final String HIERARCHICAL_DESC = "hierarchicalDesc";
767
768        public FolderColumns() {}
769    }
770
771    // We define a "folder" as anything that contains a list of conversations.
772    public static final String CONVERSATION_LIST_TYPE =
773            "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
774    public static final String CONVERSATION_TYPE =
775            "vnd.android.cursor.item/vnd.com.android.mail.conversation";
776
777
778    public static final String[] CONVERSATION_PROJECTION = {
779        BaseColumns._ID,
780        ConversationColumns.URI,
781        ConversationColumns.MESSAGE_LIST_URI,
782        ConversationColumns.SUBJECT,
783        ConversationColumns.SNIPPET,
784        ConversationColumns.CONVERSATION_INFO,
785        ConversationColumns.DATE_RECEIVED_MS,
786        ConversationColumns.HAS_ATTACHMENTS,
787        ConversationColumns.NUM_MESSAGES,
788        ConversationColumns.NUM_DRAFTS,
789        ConversationColumns.SENDING_STATE,
790        ConversationColumns.PRIORITY,
791        ConversationColumns.READ,
792        ConversationColumns.STARRED,
793        ConversationColumns.RAW_FOLDERS,
794        ConversationColumns.FLAGS,
795        ConversationColumns.PERSONAL_LEVEL,
796        ConversationColumns.SPAM,
797        ConversationColumns.PHISHING,
798        ConversationColumns.MUTED,
799        ConversationColumns.COLOR,
800        ConversationColumns.ACCOUNT_URI,
801        ConversationColumns.SENDER_INFO,
802        ConversationColumns.CONVERSATION_BASE_URI,
803        ConversationColumns.CONVERSATION_COOKIE,
804        ConversationColumns.REMOTE
805    };
806
807    // These column indexes only work when the caller uses the
808    // default CONVERSATION_PROJECTION defined above.
809    public static final int CONVERSATION_ID_COLUMN = 0;
810    public static final int CONVERSATION_URI_COLUMN = 1;
811    public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
812    public static final int CONVERSATION_SUBJECT_COLUMN = 3;
813    public static final int CONVERSATION_SNIPPET_COLUMN = 4;
814    public static final int CONVERSATION_INFO_COLUMN = 5;
815    public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
816    public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
817    public static final int CONVERSATION_NUM_MESSAGES_COLUMN = 8;
818    public static final int CONVERSATION_NUM_DRAFTS_COLUMN = 9;
819    public static final int CONVERSATION_SENDING_STATE_COLUMN = 10;
820    public static final int CONVERSATION_PRIORITY_COLUMN = 11;
821    public static final int CONVERSATION_READ_COLUMN = 12;
822    public static final int CONVERSATION_STARRED_COLUMN = 13;
823    public static final int CONVERSATION_RAW_FOLDERS_COLUMN = 14;
824    public static final int CONVERSATION_FLAGS_COLUMN = 15;
825    public static final int CONVERSATION_PERSONAL_LEVEL_COLUMN = 16;
826    public static final int CONVERSATION_IS_SPAM_COLUMN = 17;
827    public static final int CONVERSATION_IS_PHISHING_COLUMN = 18;
828    public static final int CONVERSATION_MUTED_COLUMN = 19;
829    public static final int CONVERSATION_COLOR_COLUMN = 20;
830    public static final int CONVERSATION_ACCOUNT_URI_COLUMN = 21;
831    public static final int CONVERSATION_SENDER_INFO_COLUMN = 22;
832    public static final int CONVERSATION_BASE_URI_COLUMN = 23;
833    public static final int CONVERSATION_COOKIE_COLUMN = 24;
834    public static final int CONVERSATION_REMOTE_COLUMN = 25;
835
836    public static final class ConversationSendingState {
837        public static final int OTHER = 0;
838        public static final int QUEUED = 1;
839        public static final int SENDING = 2;
840        public static final int SENT = 3;
841        public static final int SEND_ERROR = -1;
842    }
843
844    public static final class ConversationPriority {
845        public static final int DEFAULT = 0;
846        public static final int IMPORTANT = 1;
847        public static final int LOW = 0;
848        public static final int HIGH = 1;
849    }
850
851    public static final class ConversationPersonalLevel {
852        public static final int NOT_TO_ME = 0;
853        public static final int TO_ME_AND_OTHERS = 1;
854        public static final int ONLY_TO_ME = 2;
855    }
856
857    public static final class ConversationFlags {
858        public static final int REPLIED = 1<<2;
859        public static final int FORWARDED = 1<<3;
860        public static final int CALENDAR_INVITE = 1<<4;
861    }
862
863    public static final class ConversationPhishing {
864        public static final int NOT_PHISHING = 0;
865        public static final int PHISHING = 1;
866    }
867
868    /**
869     * Names of columns representing fields in a Conversation.
870     */
871    public static final class ConversationColumns {
872        public static final String URI = "conversationUri";
873        /**
874         * This string column contains the content provider uri to return the
875         * list of messages for this conversation.
876         * The cursor returned by this query can return a {@link android.os.Bundle}
877         * from a call to {@link android.database.Cursor#getExtras()}.  This Bundle may have
878         * values with keys listed in {@link CursorExtraKeys}
879         */
880        public static final String MESSAGE_LIST_URI = "messageListUri";
881        /**
882         * This string column contains the subject string for a conversation.
883         */
884        public static final String SUBJECT = "subject";
885        /**
886         * This string column contains the snippet string for a conversation.
887         */
888        public static final String SNIPPET = "snippet";
889        /**
890         * @deprecated
891         */
892        public static final String SENDER_INFO = "senderInfo";
893        /**
894         * This string column contains the string representation of the
895         * ConversationInfo JSON object for a conversation.
896         */
897        public static final String CONVERSATION_INFO = "conversationInfo";
898        /**
899         * This long column contains the time in ms of the latest update to a
900         * conversation.
901         */
902        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
903
904        /**
905         * This boolean column contains whether any messages in this conversation
906         * have attachments.
907         */
908        public static final String HAS_ATTACHMENTS = "hasAttachments";
909
910        /**
911         * This int column contains the number of messages in this conversation.
912         * For unthreaded, this will always be 1.
913         */
914        public static String NUM_MESSAGES = "numMessages";
915
916        /**
917         * This int column contains the number of drafts associated with this
918         * conversation.
919         */
920        public static String NUM_DRAFTS = "numDrafts";
921
922        /**
923         * This int column contains the state of drafts and replies associated
924         * with this conversation. Use ConversationSendingState to interpret
925         * this field.
926         */
927        public static String SENDING_STATE = "sendingState";
928
929        /**
930         * This int column contains the priority of this conversation. Use
931         * ConversationPriority to interpret this field.
932         */
933        public static String PRIORITY = "priority";
934
935        /**
936         * This int column indicates whether the conversation has been read
937         */
938        public static String READ = "read";
939        /**
940         * This int column indicates whether the conversation has been starred
941         */
942        public static String STARRED = "starred";
943
944        /**
945         * This string column contains a serialized list of all folders
946         * separated by a Folder.FOLDER_SEPARATOR that are associated with this
947         * conversation. The folders should be only those that the provider
948         * wants to have displayed, so rawFolders will ALWAYS intentionally
949         * exclude the folder currently being viewed. Ideally, only ever use
950         * this for rendering the folder list for a conversation.
951         */
952        public static final String RAW_FOLDERS = "rawFolders";
953        public static final String FLAGS = "conversationFlags";
954        /**
955         * This int column indicates the personal level of a conversation per
956         * {@link ConversationPersonalLevel}.
957         */
958        public static final String PERSONAL_LEVEL = "personalLevel";
959
960        /**
961         * This int column indicates whether the conversation is marked spam.
962         */
963        public static final String SPAM = "spam";
964
965        /**
966         * This int column indicates whether the conversation is marked phishing.
967         */
968        public static final String PHISHING = "phishing";
969
970        /**
971         * This int column indicates whether the conversation was muted.
972         */
973        public static final String MUTED = "muted";
974
975        /**
976         * This int column contains a color for the conversation (used in Email only)
977         */
978        public static final String COLOR = "color";
979
980        /**
981         * This String column contains the Uri for this conversation's account
982         */
983        public static final String ACCOUNT_URI = "accountUri";
984        /**
985         * This int column indicates whether a conversation is remote (non-local), and would require
986         * a network fetch to load.
987         */
988        public static final String REMOTE = "remote";
989        /**
990         * This int column indicates whether the conversation was displayed on the UI and the
991         * user got a chance to read it. The UI does not read this value, it is meant only to
992         * write the status back to the provider. As a result, it is not available in the
993         * {@link Conversation} object.
994         */
995        public static final String VIEWED = "viewed";
996        /**
997         * This String column contains the base uri for this conversation.  This uri can be used
998         * when handling relative urls in the message content
999         */
1000        public static final String CONVERSATION_BASE_URI = "conversationBaseUri";
1001        /**
1002         * This String column contains the cookie needed for accessing inline content.  The cookie
1003         * specified here will be set on the uri specified in the {@link CONVERSATION_BASE_URI}
1004         * column.
1005         */
1006        public static final String CONVERSATION_COOKIE = "conversationCookie";
1007
1008        private ConversationColumns() {
1009        }
1010    }
1011
1012    public static final class ConversationCursorCommand {
1013
1014        public static final String COMMAND_RESPONSE_OK = "ok";
1015        public static final String COMMAND_RESPONSE_FAILED = "failed";
1016
1017        /**
1018         * This bundle key has a boolean value: true to allow cursor network access (whether this
1019         * is true by default is up to the provider), false to temporarily disable network access.
1020         * <p>
1021         * A provider that implements this command should include this key in its response with a
1022         * value of {@link #COMMAND_RESPONSE_OK} or {@link #COMMAND_RESPONSE_FAILED}.
1023         */
1024        public static final String COMMAND_KEY_ALLOW_NETWORK_ACCESS = "allowNetwork";
1025
1026        /**
1027         * This bundle key has a boolean value: true to indicate that this cursor has been shown
1028         * to the user.
1029         */
1030        public static final String COMMAND_KEY_SET_VISIBILITY = "setVisibility";
1031
1032        private ConversationCursorCommand() {}
1033    }
1034
1035    /**
1036     * List of operations that can can be performed on a conversation. These operations are applied
1037     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1038     * where the conversation uri is specified, and the ContentValues specifies the operation to
1039     * be performed.
1040     * <p/>
1041     * The operation to be performed is specified in the ContentValues by
1042     * the {@link ConversationOperations#OPERATION_KEY}
1043     * <p/>
1044     * Note not all UI providers will support these operations.  {@link AccountCapabilities} can
1045     * be used to determine which operations are supported.
1046     */
1047    public static final class ConversationOperations {
1048        /**
1049         * ContentValues key used to specify the operation to be performed
1050         */
1051        public static final String OPERATION_KEY = "operation";
1052
1053        /**
1054         * Archive operation
1055         */
1056        public static final String ARCHIVE = "archive";
1057
1058        /**
1059         * Mute operation
1060         */
1061        public static final String MUTE = "mute";
1062
1063        /**
1064         * Report spam operation
1065         */
1066        public static final String REPORT_SPAM = "report_spam";
1067
1068        /**
1069         * Report not spam operation
1070         */
1071        public static final String REPORT_NOT_SPAM = "report_not_spam";
1072
1073        /**
1074         * Report phishing operation
1075         */
1076        public static final String REPORT_PHISHING = "report_phishing";
1077
1078        /**
1079         * Discard drafts operation
1080         */
1081        public static final String DISCARD_DRAFTS = "discard_drafts";
1082
1083        private ConversationOperations() {
1084        }
1085    }
1086
1087    public static final class DraftType {
1088        public static final int NOT_A_DRAFT = 0;
1089        public static final int COMPOSE = 1;
1090        public static final int REPLY = 2;
1091        public static final int REPLY_ALL = 3;
1092        public static final int FORWARD = 4;
1093
1094        private DraftType() {}
1095    }
1096
1097    /**
1098     * Class for the enum values to determine whether this
1099     * string should be displayed as a high priority warning
1100     * or a low priority warning. The current design has
1101     * high priority warnings in red while low priority warnings
1102     * are grey.
1103     */
1104    public static final class SpamWarningLevel {
1105        public static final int NO_WARNING = 0;
1106        public static final int LOW_WARNING = 1;
1107        public static final int HIGH_WARNING = 2;
1108
1109        private SpamWarningLevel() {}
1110    }
1111
1112    /**
1113     * Class for the enum values to determine which type
1114     * of link to show in the spam warning.
1115     */
1116    public static final class SpamWarningLinkType {
1117        public static final int NO_LINK = 0;
1118        public static final int IGNORE_WARNING = 1;
1119        public static final int REPORT_PHISHING = 2;
1120
1121        private SpamWarningLinkType() {}
1122    }
1123
1124    public static final String[] MESSAGE_PROJECTION = {
1125        BaseColumns._ID,
1126        MessageColumns.SERVER_ID,
1127        MessageColumns.URI,
1128        MessageColumns.CONVERSATION_ID,
1129        MessageColumns.SUBJECT,
1130        MessageColumns.SNIPPET,
1131        MessageColumns.FROM,
1132        MessageColumns.TO,
1133        MessageColumns.CC,
1134        MessageColumns.BCC,
1135        MessageColumns.REPLY_TO,
1136        MessageColumns.DATE_RECEIVED_MS,
1137        MessageColumns.BODY_HTML,
1138        MessageColumns.BODY_TEXT,
1139        MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
1140        MessageColumns.REF_MESSAGE_ID,
1141        MessageColumns.DRAFT_TYPE,
1142        MessageColumns.APPEND_REF_MESSAGE_CONTENT,
1143        MessageColumns.HAS_ATTACHMENTS,
1144        MessageColumns.ATTACHMENT_LIST_URI,
1145        MessageColumns.MESSAGE_FLAGS,
1146        MessageColumns.JOINED_ATTACHMENT_INFOS,
1147        MessageColumns.SAVE_MESSAGE_URI,
1148        MessageColumns.SEND_MESSAGE_URI,
1149        MessageColumns.ALWAYS_SHOW_IMAGES,
1150        MessageColumns.READ,
1151        MessageColumns.STARRED,
1152        MessageColumns.QUOTE_START_POS,
1153        MessageColumns.ATTACHMENTS,
1154        MessageColumns.CUSTOM_FROM_ADDRESS,
1155        MessageColumns.MESSAGE_ACCOUNT_URI,
1156        MessageColumns.EVENT_INTENT_URI,
1157        MessageColumns.SPAM_WARNING_STRING,
1158        MessageColumns.SPAM_WARNING_LEVEL,
1159        MessageColumns.SPAM_WARNING_LINK_TYPE,
1160        MessageColumns.VIA_DOMAIN,
1161        MessageColumns.IS_SENDING
1162    };
1163
1164    /** Separates attachment info parts in strings in a message. */
1165    @Deprecated
1166    public static final String MESSAGE_ATTACHMENT_INFO_SEPARATOR = "\n";
1167    public static final String MESSAGE_LIST_TYPE =
1168            "vnd.android.cursor.dir/vnd.com.android.mail.message";
1169    public static final String MESSAGE_TYPE =
1170            "vnd.android.cursor.item/vnd.com.android.mail.message";
1171
1172    public static final int MESSAGE_ID_COLUMN = 0;
1173    public static final int MESSAGE_SERVER_ID_COLUMN = 1;
1174    public static final int MESSAGE_URI_COLUMN = 2;
1175    public static final int MESSAGE_CONVERSATION_URI_COLUMN = 3;
1176    public static final int MESSAGE_SUBJECT_COLUMN = 4;
1177    public static final int MESSAGE_SNIPPET_COLUMN = 5;
1178    public static final int MESSAGE_FROM_COLUMN = 6;
1179    public static final int MESSAGE_TO_COLUMN = 7;
1180    public static final int MESSAGE_CC_COLUMN = 8;
1181    public static final int MESSAGE_BCC_COLUMN = 9;
1182    public static final int MESSAGE_REPLY_TO_COLUMN = 10;
1183    public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
1184    public static final int MESSAGE_BODY_HTML_COLUMN = 12;
1185    public static final int MESSAGE_BODY_TEXT_COLUMN = 13;
1186    public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
1187    public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
1188    public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
1189    public static final int MESSAGE_APPEND_REF_MESSAGE_CONTENT_COLUMN = 17;
1190    public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 18;
1191    public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 19;
1192    public static final int MESSAGE_FLAGS_COLUMN = 20;
1193    public static final int MESSAGE_JOINED_ATTACHMENT_INFOS_COLUMN = 21;
1194    public static final int MESSAGE_SAVE_URI_COLUMN = 22;
1195    public static final int MESSAGE_SEND_URI_COLUMN = 23;
1196    public static final int MESSAGE_ALWAYS_SHOW_IMAGES_COLUMN = 24;
1197    public static final int MESSAGE_READ_COLUMN = 25;
1198    public static final int MESSAGE_STARRED_COLUMN = 26;
1199    public static final int QUOTED_TEXT_OFFSET_COLUMN = 27;
1200    public static final int MESSAGE_ATTACHMENTS_COLUMN = 28;
1201    public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 29;
1202    public static final int MESSAGE_ACCOUNT_URI_COLUMN = 30;
1203    public static final int MESSAGE_EVENT_INTENT_COLUMN = 31;
1204    public static final int MESSAGE_SPAM_WARNING_STRING_ID_COLUMN = 32;
1205    public static final int MESSAGE_SPAM_WARNING_LEVEL_COLUMN = 33;
1206    public static final int MESSAGE_SPAM_WARNING_LINK_TYPE_COLUMN = 34;
1207    public static final int MESSAGE_VIA_DOMAIN_COLUMN = 35;
1208    public static final int MESSAGE_IS_SENDING_COLUMN = 36;
1209
1210    public static final class CursorStatus {
1211        // The cursor is actively loading more data
1212        public static final int LOADING =      1 << 0;
1213
1214        // The cursor is currently not loading more data, but more data may be available
1215        public static final int LOADED =       1 << 1;
1216
1217        // An error occured while loading data
1218        public static final int ERROR =        1 << 2;
1219
1220        // The cursor is loaded, and there will be no more data
1221        public static final int COMPLETE =     1 << 3;
1222
1223        public static boolean isWaitingForResults(int cursorStatus) {
1224            return 0 != (cursorStatus & LOADING);
1225        }
1226    }
1227
1228
1229    public static final class CursorExtraKeys {
1230        /**
1231         * This integer column contains the staus of the message cursor.  The value will be
1232         * one defined in {@link CursorStatus}.
1233         */
1234        public static final String EXTRA_STATUS = "cursor_status";
1235
1236        /**
1237         * Used for finding the cause of an error.
1238         * TODO: define these values
1239         */
1240        public static final String EXTRA_ERROR = "cursor_error";
1241
1242    }
1243
1244    public static final class AccountCursorExtraKeys {
1245        /**
1246         * This integer column contains the staus of the account cursor.  The value will be
1247         * 1 if all accounts have been fully loaded or 0 if the account list hasn't been fully
1248         * initialized
1249         */
1250        public static final String ACCOUNTS_LOADED = "accounts_loaded";
1251    }
1252
1253
1254    public static final class MessageFlags {
1255        public static final int REPLIED =           1 << 2;
1256        public static final int FORWARDED =         1 << 3;
1257        public static final int CALENDAR_INVITE =   1 << 4;
1258    }
1259
1260    public static final class MessageColumns {
1261        /**
1262         * This string column contains a content provider URI that points to this single message.
1263         */
1264        public static final String URI = "messageUri";
1265        /**
1266         * This string column contains a server-assigned ID for this message.
1267         */
1268        public static final String SERVER_ID = "serverMessageId";
1269        public static final String CONVERSATION_ID = "conversationId";
1270        /**
1271         * This string column contains the subject of a message.
1272         */
1273        public static final String SUBJECT = "subject";
1274        /**
1275         * This string column contains a snippet of the message body.
1276         */
1277        public static final String SNIPPET = "snippet";
1278        /**
1279         * This string column contains the single email address (and optionally name) of the sender.
1280         */
1281        public static final String FROM = "fromAddress";
1282        /**
1283         * This string column contains a comma-delimited list of "To:" recipient email addresses.
1284         */
1285        public static final String TO = "toAddresses";
1286        /**
1287         * This string column contains a comma-delimited list of "CC:" recipient email addresses.
1288         */
1289        public static final String CC = "ccAddresses";
1290        /**
1291         * This string column contains a comma-delimited list of "BCC:" recipient email addresses.
1292         * This value will be null for incoming messages.
1293         */
1294        public static final String BCC = "bccAddresses";
1295        /**
1296         * This string column contains the single email address (and optionally name) of the
1297         * sender's reply-to address.
1298         */
1299        public static final String REPLY_TO = "replyToAddress";
1300        /**
1301         * This long column contains the timestamp (in millis) of receipt of the message.
1302         */
1303        public static final String DATE_RECEIVED_MS = "dateReceivedMs";
1304        /**
1305         * This string column contains the HTML form of the message body, if available. If not,
1306         * a provider must populate BODY_TEXT.
1307         */
1308        public static final String BODY_HTML = "bodyHtml";
1309        /**
1310         * This string column contains the plaintext form of the message body, if HTML is not
1311         * otherwise available. If HTML is available, this value should be left empty (null).
1312         */
1313        public static final String BODY_TEXT = "bodyText";
1314        public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
1315        /**
1316         * This string column contains an opaque string used by the sendMessage api.
1317         */
1318        public static final String REF_MESSAGE_ID = "refMessageId";
1319        /**
1320         * This integer column contains the type of this draft, or zero (0) if this message is not a
1321         * draft. See {@link DraftType} for possible values.
1322         */
1323        public static final String DRAFT_TYPE = "draftType";
1324        /**
1325         * This boolean column indicates whether an outgoing message should trigger special quoted
1326         * text processing upon send. The value should default to zero (0) for protocols that do
1327         * not support or require this flag, and for all incoming messages.
1328         */
1329        public static final String APPEND_REF_MESSAGE_CONTENT = "appendRefMessageContent";
1330        /**
1331         * This boolean column indicates whether a message has attachments. The list of attachments
1332         * can be retrieved using the URI in {@link MessageColumns#ATTACHMENT_LIST_URI}.
1333         */
1334        public static final String HAS_ATTACHMENTS = "hasAttachments";
1335        /**
1336         * This string column contains the content provider URI for the list of
1337         * attachments associated with this message.
1338         */
1339        public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
1340        /**
1341         * This long column is a bit field of flags defined in {@link MessageFlags}.
1342         */
1343        public static final String MESSAGE_FLAGS = "messageFlags";
1344        /**
1345         * This string column contains a specially formatted string representing all
1346         * attachments that we added to a message that is being sent or saved.
1347         *
1348         * TODO: remove this and use {@link #ATTACHMENTS} instead
1349         */
1350        @Deprecated
1351        public static final String JOINED_ATTACHMENT_INFOS = "joinedAttachmentInfos";
1352        /**
1353         * This string column contains the content provider URI for saving this
1354         * message.
1355         */
1356        public static final String SAVE_MESSAGE_URI = "saveMessageUri";
1357        /**
1358         * This string column contains content provider URI for sending this
1359         * message.
1360         */
1361        public static final String SEND_MESSAGE_URI = "sendMessageUri";
1362
1363        /**
1364         * This integer column represents whether the user has specified that images should always
1365         * be shown.  The value of "1" indicates that the user has specified that images should be
1366         * shown, while the value of "0" indicates that the user should be prompted before loading
1367         * any external images.
1368         */
1369        public static final String ALWAYS_SHOW_IMAGES = "alwaysShowImages";
1370
1371        /**
1372         * This boolean column indicates whether the message has been read
1373         */
1374        public static String READ = "read";
1375
1376        /**
1377         * This boolean column indicates whether the message has been starred
1378         */
1379        public static String STARRED = "starred";
1380
1381        /**
1382         * This integer column represents the offset in the message of quoted
1383         * text. If include_quoted_text is zero, the value contained in this
1384         * column is invalid.
1385         */
1386        public static final String QUOTE_START_POS = "quotedTextStartPos";
1387
1388        /**
1389         * This string columns contains a JSON array of serialized {@link Attachment} objects.
1390         */
1391        public static final String ATTACHMENTS = "attachments";
1392        public static final String CUSTOM_FROM_ADDRESS = "customFrom";
1393        /**
1394         * Uri of the account associated with this message. Except in the case
1395         * of showing a combined view, this column is almost always empty.
1396         */
1397        public static final String MESSAGE_ACCOUNT_URI = "messageAccountUri";
1398        /**
1399         * Intent Uri to launch when the user wants to view an event in their calendar, or null.
1400         */
1401        public static final String EVENT_INTENT_URI = "eventIntentUri";
1402        /**
1403         * This string column contains the string for the spam
1404         * warning of this message, or null if there is no spam warning for the message.
1405         */
1406        public static final String SPAM_WARNING_STRING = "spamWarningString";
1407        /**
1408         * This integer column contains the level of spam warning of this message,
1409         * or zero (0) if this message does not have a warning level.
1410         * See {@link SpamWarningLevel} for possible values.
1411         */
1412        public static final String SPAM_WARNING_LEVEL = "spamWarningLevel";
1413        /**
1414         * This integer column contains the type of link for the spam warning
1415         * of this message, or zero (0) if this message does not have a link type.
1416         * See {@link SpamWarningLinkType} for possible values.
1417         */
1418        public static final String SPAM_WARNING_LINK_TYPE = "spamWarningLinkType";
1419        /**
1420         * This string column contains the string for the via domain
1421         * to be included if this message was sent via an alternate
1422         * domain. This column should be null if no via domain exists.
1423         */
1424        public static final String VIA_DOMAIN = "viaDomain";
1425        /**
1426         * This boolean column indicates whether the message is an outgoing message in the process
1427         * of being sent (will be zero for incoming messages and messages that are already sent).
1428         */
1429        public static final String IS_SENDING = "isSending";
1430
1431        private MessageColumns() {}
1432    }
1433
1434    /**
1435     * List of operations that can can be performed on a message. These operations are applied
1436     * with {@link ContentProvider#update(Uri, ContentValues, String, String[])}
1437     * where the message uri is specified, and the ContentValues specifies the operation to
1438     * be performed, e.g. values.put(RESPOND_COLUMN, RESPOND_ACCEPT)
1439     * <p/>
1440     * Note not all UI providers will support these operations.
1441     */
1442    public static final class MessageOperations {
1443        /**
1444         * Respond to a calendar invitation
1445         */
1446        public static final String RESPOND_COLUMN = "respond";
1447
1448        public static final int RESPOND_ACCEPT = 1;
1449        public static final int RESPOND_TENTATIVE = 2;
1450        public static final int RESPOND_DECLINE = 3;
1451
1452        private MessageOperations() {
1453        }
1454    }
1455
1456    public static final String ATTACHMENT_LIST_TYPE =
1457            "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
1458    public static final String ATTACHMENT_TYPE =
1459            "vnd.android.cursor.item/vnd.com.android.mail.attachment";
1460
1461    public static final String[] ATTACHMENT_PROJECTION = {
1462        AttachmentColumns.NAME,
1463        AttachmentColumns.SIZE,
1464        AttachmentColumns.URI,
1465        AttachmentColumns.CONTENT_TYPE,
1466        AttachmentColumns.STATE,
1467        AttachmentColumns.DESTINATION,
1468        AttachmentColumns.DOWNLOADED_SIZE,
1469        AttachmentColumns.CONTENT_URI,
1470        AttachmentColumns.THUMBNAIL_URI,
1471        AttachmentColumns.PREVIEW_INTENT_URI
1472    };
1473    private static final String EMAIL_SEPARATOR_PATTERN = "\n";
1474    public static final int ATTACHMENT_NAME_COLUMN = 0;
1475    public static final int ATTACHMENT_SIZE_COLUMN = 1;
1476    public static final int ATTACHMENT_URI_COLUMN = 2;
1477    public static final int ATTACHMENT_CONTENT_TYPE_COLUMN = 3;
1478    public static final int ATTACHMENT_STATE_COLUMN = 4;
1479    public static final int ATTACHMENT_DESTINATION_COLUMN = 5;
1480    public static final int ATTACHMENT_DOWNLOADED_SIZE_COLUMN = 6;
1481    public static final int ATTACHMENT_CONTENT_URI_COLUMN = 7;
1482    public static final int ATTACHMENT_THUMBNAIL_URI_COLUMN = 8;
1483    public static final int ATTACHMENT_PREVIEW_INTENT_COLUMN = 9;
1484
1485    /**
1486     * Valid states for the {@link AttachmentColumns#STATE} column.
1487     *
1488     */
1489    public static final class AttachmentState {
1490        /**
1491         * The full attachment is not present on device. When used as a command,
1492         * setting this state will tell the provider to cancel a download in
1493         * progress.
1494         * <p>
1495         * Valid next states: {@link #DOWNLOADING}
1496         */
1497        public static final int NOT_SAVED = 0;
1498        /**
1499         * The most recent attachment download attempt failed. The current UI
1500         * design does not require providers to persist this state, but
1501         * providers must return this state at least once after a download
1502         * failure occurs. This state may not be used as a command.
1503         * <p>
1504         * Valid next states: {@link #DOWNLOADING}
1505         */
1506        public static final int FAILED = 1;
1507        /**
1508         * The attachment is currently being downloaded by the provider.
1509         * {@link AttachmentColumns#DOWNLOADED_SIZE} should reflect the current
1510         * download progress while in this state. When used as a command,
1511         * setting this state will tell the provider to initiate a download to
1512         * the accompanying destination in {@link AttachmentColumns#DESTINATION}
1513         * .
1514         * <p>
1515         * Valid next states: {@link #NOT_SAVED}, {@link #FAILED},
1516         * {@link #SAVED}
1517         */
1518        public static final int DOWNLOADING = 2;
1519        /**
1520         * The attachment was successfully downloaded to the destination in
1521         * {@link AttachmentColumns#DESTINATION}. If a provider later detects
1522         * that a download is missing, it should reset the state to
1523         * {@link #NOT_SAVED}. This state may not be used as a command on its
1524         * own. To move a file from cache to external, update
1525         * {@link AttachmentColumns#DESTINATION}.
1526         * <p>
1527         * Valid next states: {@link #NOT_SAVED}
1528         */
1529        public static final int SAVED = 3;
1530
1531        private AttachmentState() {}
1532    }
1533
1534    public static final class AttachmentDestination {
1535
1536        /**
1537         * The attachment will be or is already saved to the app-private cache partition.
1538         */
1539        public static final int CACHE = 0;
1540        /**
1541         * The attachment will be or is already saved to external shared device storage.
1542         */
1543        public static final int EXTERNAL = 1;
1544
1545        private AttachmentDestination() {}
1546    }
1547
1548    public static final class AttachmentColumns {
1549        /**
1550         * This string column is the attachment's file name, intended for display in UI. It is not
1551         * the full path of the file.
1552         */
1553        public static final String NAME = OpenableColumns.DISPLAY_NAME;
1554        /**
1555         * This integer column is the file size of the attachment, in bytes.
1556         */
1557        public static final String SIZE = OpenableColumns.SIZE;
1558        /**
1559         * This column is a {@link Uri} that can be queried to monitor download state and progress
1560         * for this individual attachment (resulting cursor has one single row for this attachment).
1561         */
1562        public static final String URI = "uri";
1563        /**
1564         * This string column is the MIME type of the attachment.
1565         */
1566        public static final String CONTENT_TYPE = "contentType";
1567        /**
1568         * This integer column is the current downloading state of the
1569         * attachment as defined in {@link AttachmentState}.
1570         * <p>
1571         * Providers must accept updates to {@link #URI} with new values of
1572         * this column to initiate or cancel downloads.
1573         */
1574        public static final String STATE = "state";
1575        /**
1576         * This integer column is the file destination for the current download
1577         * in progress (when {@link #STATE} is
1578         * {@link AttachmentState#DOWNLOADING}) or the resulting downloaded file
1579         * ( when {@link #STATE} is {@link AttachmentState#SAVED}), as defined
1580         * in {@link AttachmentDestination}. This value is undefined in any
1581         * other state.
1582         * <p>
1583         * Providers must accept updates to {@link #URI} with new values of
1584         * this column to move an existing downloaded file.
1585         */
1586        public static final String DESTINATION = "destination";
1587        /**
1588         * This integer column is the current number of bytes downloaded when
1589         * {@link #STATE} is {@link AttachmentState#DOWNLOADING}. This value is
1590         * undefined in any other state.
1591         */
1592        public static final String DOWNLOADED_SIZE = "downloadedSize";
1593        /**
1594         * This column is a {@link Uri} that points to the downloaded local file
1595         * when {@link #STATE} is {@link AttachmentState#SAVED}. This value is
1596         * undefined in any other state.
1597         */
1598        public static final String CONTENT_URI = "contentUri";
1599        /**
1600         * This column is a {@link Uri} that points to a local thumbnail file
1601         * for the attachment. Providers that do not support downloading
1602         * attachment thumbnails may leave this null.
1603         */
1604        public static final String THUMBNAIL_URI = "thumbnailUri";
1605        /**
1606         * This column is an {@link Uri} used in an {@link Intent.ACTION_VIEW} Intent to launch a
1607         * preview activity that allows the user to efficiently view an attachment without having to
1608         * first download the entire file. Providers that do not support
1609         * previewing attachments may leave this null.
1610         */
1611        public static final String PREVIEW_INTENT_URI = "previewIntentUri";
1612
1613        private AttachmentColumns() {}
1614    }
1615
1616    public static String getAttachmentTypeSetting() {
1617        // TODO: query the account to see what kinds of attachments it supports?
1618        return "com.google.android.gm.allowAddAnyAttachment";
1619    }
1620
1621    public static void incrementRecipientsTimesContacted(Context context, String addressString) {
1622        DataUsageStatUpdater statsUpdater = new DataUsageStatUpdater(context);
1623        ArrayList<String> recipients = new ArrayList<String>();
1624        String[] addresses = TextUtils.split(addressString, EMAIL_SEPARATOR_PATTERN);
1625        for (String address : addresses) {
1626            recipients.add(address);
1627        }
1628        statsUpdater.updateWithAddress(recipients);
1629    }
1630
1631    public static final String[] UNDO_PROJECTION = {
1632        ConversationColumns.MESSAGE_LIST_URI
1633    };
1634    public static final int UNDO_MESSAGE_LIST_COLUMN = 0;
1635
1636    // Parameter used to indicate the sequence number for an undoable operation
1637    public static final String SEQUENCE_QUERY_PARAMETER = "seq";
1638
1639    /**
1640     * Settings for auto advancing when the current conversation has been destroyed.
1641     */
1642    public static final class AutoAdvance {
1643        /** No setting specified. */
1644        public static final int UNSET = 0;
1645        /** Go to the older message (if available) */
1646        public static final int OLDER = 1;
1647        /** Go to the newer message (if available) */
1648        public static final int NEWER = 2;
1649        /** Go back to conversation list*/
1650        public static final int LIST = 3;
1651    }
1652
1653    /**
1654     * Settings for what swipe should do.
1655     */
1656    public static final class Swipe {
1657        /** Archive or remove label, if available. */
1658        public static final int ARCHIVE = 0;
1659        /** Delete */
1660        public static final int DELETE = 1;
1661        /** No swipe */
1662        public static final int DISABLED = 2;
1663        /** Default is delete */
1664        public static final int DEFAULT = ARCHIVE;
1665    }
1666
1667    public static final class SnapHeaderValue {
1668        public static final int ALWAYS = 0;
1669        public static final int PORTRAIT_ONLY = 1;
1670        public static final int NEVER = 2;
1671    }
1672
1673    public static final class MessageTextSize {
1674        public static final int TINY = -2;
1675        public static final int SMALL = -1;
1676        public static final int NORMAL = 0;
1677        public static final int LARGE = 1;
1678        public static final int HUGE = 2;
1679    }
1680
1681    public static final class DefaultReplyBehavior {
1682        public static final int REPLY = 0;
1683        public static final int REPLY_ALL = 1;
1684    }
1685
1686    /**
1687     * Action for an intent used to update/create new notifications.  The mime type of this
1688     * intent should be set to the mimeType of the account that is generating this notification.
1689     * An intent of this action is required to have the following extras:
1690     * {@link UpdateNotificationExtras#EXTRA_FOLDER} {@link UpdateNotificationExtras#EXTRA_ACCOUNT}
1691     */
1692    public static final String ACTION_UPDATE_NOTIFICATION =
1693            "com.android.mail.action.update_notification";
1694
1695    public static final class UpdateNotificationExtras {
1696        /**
1697         * Parcelable extra containing a {@link Uri} to a {@link Folder}
1698         */
1699        public static final String EXTRA_FOLDER = "notification_extra_folder";
1700
1701        /**
1702         * Parcelable extra containing a {@link Uri} to an {@link Account}
1703         */
1704        public static final String EXTRA_ACCOUNT = "notification_extra_account";
1705
1706        /**
1707         * Integer extra containing the update unread count for the account/folder.
1708         * If this value is 0, the UI will not block the intent to allow code to clear notifications
1709         * to run.
1710         */
1711        public static final String EXTRA_UPDATED_UNREAD_COUNT = "notification_updated_unread_count";
1712    }
1713
1714    public static final class EditSettingsExtras {
1715        /**
1716         * Parcelable extra containing account for which the user wants to
1717         * modify settings
1718         */
1719        public static final String EXTRA_ACCOUNT = "extra_account";
1720
1721        /**
1722         * Parcelable extra containing folder for which the user wants to
1723         * modify settings
1724         */
1725        public static final String EXTRA_FOLDER = "extra_folder";
1726
1727        /**
1728         * Boolean extra which is set true if the user wants to "manage folders"
1729         */
1730        public static final String EXTRA_MANAGE_FOLDERS = "extra_manage_folders";
1731    }
1732
1733    public static final class SendFeedbackExtras {
1734        /**
1735         * Optional boolean extras which indicates that the user is reporting a problem.
1736         */
1737        public static final String EXTRA_REPORTING_PROBLEM = "reporting_problem";
1738    }
1739}
1740