blob: de3a86a541d12e374adb8f124a90f51a8cf506aa [file] [log] [blame]
Mindy Pereira6f92de62011-12-19 11:31:48 -08001/**
2 * Copyright (c) 2011, Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.email.providers;
18
Mindy Pereira6f92de62011-12-19 11:31:48 -080019import android.provider.BaseColumns;
20
Paul Westbrook82ea6da2011-12-15 11:03:51 -080021import java.lang.String;
22
Mindy Pereira6f92de62011-12-19 11:31:48 -080023
24public class UIProvider {
Mindy Pereira326c6602012-01-04 15:32:42 -080025 public static final long INVALID_CONVERSATION_ID = -1;
26 public static final long INVALID_MESSAGE_ID = -1;
27
Paul Westbrook82ea6da2011-12-15 11:03:51 -080028 // The actual content provider should define its own authority
Mindy Pereirafdd984b2011-12-29 09:43:45 -080029 public static final String AUTHORITY = "com.android.email.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080030
31 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080032 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080033 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080034 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080035
36 public static final String[] ACCOUNTS_PROJECTION = {
37 BaseColumns._ID,
38 AccountColumns.NAME,
39 AccountColumns.PROVIDER_VERSION,
40 AccountColumns.URI,
41 AccountColumns.CAPABILITIES,
42 AccountColumns.FOLDER_LIST_URI,
43 AccountColumns.SEARCH_URI,
44 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Paul Westbrook82ea6da2011-12-15 11:03:51 -080045 AccountColumns.SAVE_NEW_DRAFT_URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -080046 AccountColumns.SEND_MESSAGE_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -080047 };
48
49 public static final class AccountCapabilities {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080050 public static final int SYNCABLE_FOLDERS = 0x0001;
51 public static final int REPORT_SPAM = 0x0002;
52 public static final int ARCHIVE = 0x0004;
53 public static final int MUTE = 0x0008;
54 public static final int SERVER_SEARCH = 0x0010;
55 public static final int FOLDER_SERVER_SEARCH = 0x0020;
56 public static final int SANITIZED_HTML = 0x0040;
57 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
58 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
59 public static final int SMART_REPLY = 0x0200;
60 public static final int LOCAL_SEARCH = 0x0400;
61 public static final int THREADED_CONVERSATIONS = 0x0800;
Mindy Pereira6f92de62011-12-19 11:31:48 -080062 }
63
64 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080065 /**
66 * This string column contains the human visible name for the account.
67 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080068 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080069
70 /**
71 * This integer column returns the version of the UI provider schema from which this
72 * account provider will return results.
73 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080074 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080075
76 /**
77 * This string column contains the uri to directly access the information for this account.
78 */
Mindy Pereira6349a042012-01-04 11:25:01 -080079 public static final String URI = "accountUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080080
81 /**
82 * This integer column contains a bit field of the possible cabibilities that this account
83 * supports.
84 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080085 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080086
87 /**
Mindy Pereira750cc732011-12-21 13:32:29 -080088 * This string column contains the content provider uri to return the
89 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -080090 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080091 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080092
93 /**
94 * This string column contains the content provider uri that can be queried for search
95 * results.
96 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080097 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080098
99 /**
100 * This string column contains the content provider uri that can be queried to access the
101 * from addresses for this account.
102 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800103 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800104
105 /**
106 * This string column contains the content provider uri that can be used to save (insert)
107 * new draft messages for this account.
108 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800109 public static final String SAVE_NEW_DRAFT_URI = "saveNewDraftUri";
110
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800111 /**
112 * This string column contains the content provider uri that can be used to send
113 * a message for this account.
114 * NOTE: This might be better to be an update operation on the messageUri.
115 */
116 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800117 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800118
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800119 // We define a "folder" as anything that contains a list of conversations.
120 public static final String FOLDER_LIST_TYPE =
121 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
122 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800123 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800124
125 public static final String[] FOLDERS_PROJECTION = {
126 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800127 FolderColumns.URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800128 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800129 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800130 FolderColumns.CAPABILITIES,
131 FolderColumns.SYNC_FREQUENCY,
132 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800133 FolderColumns.CONVERSATION_LIST_URI,
134 FolderColumns.CHILD_FOLDERS_LIST_URI
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800135 };
136
Mindy Pereira0973b202011-12-21 15:48:12 -0800137 public static final class FolderCapabilities {
138 public static final int SYNCABLE = 0x0001;
139 public static final int PARENT = 0x0002;
140 public static final int CAN_HOLD_MAIL = 0x0004;
141 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
142 }
143
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800144 public static final class FolderColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800145 public static String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800146 /**
147 * This string column contains the human visible name for the folder.
148 */
149 public static final String NAME = "name";
150 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800151 * This int column represents the capabilities of the folder specified by
152 * FolderCapabilities flags.
153 */
154 public static String CAPABILITIES = "capabilities";
155 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800156 * This boolean column represents whether or not this folder has any
157 * child folders.
158 */
159 public static String HAS_CHILDREN = "hasChildren";
160 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800161 * This int column represents how often the folder should be synced.
162 */
163 public static String SYNC_FREQUENCY = "syncFrequency";
164 /**
165 * This int column represents how large the sync window is.
166 */
167 public static String SYNC_WINDOW = "syncWindow";
168 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800169 * This string column contains the content provider uri to return the
170 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800171 */
172 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800173 /**
174 * This string column contains the content provider uri to return the
175 * list of child folders of this folder.
176 */
177 public static String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800178
179 public FolderColumns() {};
Mindy Pereira6f92de62011-12-19 11:31:48 -0800180 }
181
Mindy Pereiraa1406072011-12-22 10:54:06 -0800182 // We define a "folder" as anything that contains a list of conversations.
183 public static final String CONVERSATION_LIST_TYPE =
184 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
185 public static final String CONVERSATION_TYPE =
186 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
187
188 public static final String[] CONVERSATION_PROJECTION = {
189 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800190 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800191 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800192 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800193 ConversationColumns.SNIPPET,
194 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800195 ConversationColumns.DATE_RECEIVED_MS,
196 ConversationColumns.HAS_ATTACHMENTS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800197 };
198
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800199 // These column indexes only work when the caller uses the
200 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800201 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800202 public static final int CONVERSATION_URI_COLUMN = 1;
203 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
204 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
205 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
206 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
207 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
208 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800209
Mindy Pereiraa1406072011-12-22 10:54:06 -0800210 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800211 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800212 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800213 * This string column contains the content provider uri to return the
214 * list of messages for this conversation.
215 */
216 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800217 /**
218 * This string column contains the subject string for a conversation.
219 */
220 public static final String SUBJECT = "subject";
221 /**
222 * This string column contains the snippet string for a conversation.
223 */
224 public static final String SNIPPET = "snippet";
225 /**
226 * This string column contains the sender info string for a
227 * conversation.
228 */
229 public static final String SENDER_INFO = "senderInfo";
230 /**
231 * This long column contains the time in ms of the latest update to a
232 * conversation.
233 */
234 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
235
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800236 /**
237 * This boolean column contains whether any messages in this conversation
238 * have attachments.
239 */
240 public static final String HAS_ATTACHMENTS = "hasAttachments";
241
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800242 public ConversationColumns() {
243 };
Mindy Pereiraa1406072011-12-22 10:54:06 -0800244 }
245
Mindy Pereira6f92de62011-12-19 11:31:48 -0800246 /**
247 * Returns a uri that, when queried, will return a cursor with a list of information for the
248 * list of configured accounts.
249 * @return
250 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800251 // TODO: create a static registry for the starting point for the UI provider.
252// public static Uri getAccountsUri() {
253// return Uri.parse(BASE_URI_STRING + "/");
254// }
255
256 public static final class DraftType {
257 public static final String COMPOSE = "compose";
258 public static final String REPLY = "reply";
259 public static final String REPLY_ALL = "replyAll";
260 public static final String FORWARD = "forward";
261
262 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800263 }
264
Mindy Pereiraa1406072011-12-22 10:54:06 -0800265 public static final String[] MESSAGE_PROJECTION = {
266 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800267 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800268 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800269 MessageColumns.CONVERSATION_ID,
270 MessageColumns.SUBJECT,
271 MessageColumns.SNIPPET,
272 MessageColumns.FROM,
273 MessageColumns.TO,
274 MessageColumns.CC,
275 MessageColumns.BCC,
276 MessageColumns.REPLY_TO,
277 MessageColumns.DATE_RECEIVED_MS,
278 MessageColumns.BODY_HTML,
279 MessageColumns.BODY_TEXT,
280 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
281 MessageColumns.REF_MESSAGE_ID,
282 MessageColumns.DRAFT_TYPE,
283 MessageColumns.INCLUDE_QUOTED_TEXT,
284 MessageColumns.QUOTE_START_POS,
285 MessageColumns.CLIENT_CREATED,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800286 MessageColumns.CUSTOM_FROM_ADDRESS,
287 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800288 MessageColumns.ATTACHMENT_LIST_URI,
289 MessageColumns.MESSAGE_FLAGS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800290 };
291
Mindy Pereiraa1406072011-12-22 10:54:06 -0800292 public static final String MESSAGE_LIST_TYPE =
293 "vnd.android.cursor.dir/vnd.com.android.mail.message";
294 public static final String MESSAGE_TYPE =
295 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800296
Mindy Pereira6349a042012-01-04 11:25:01 -0800297 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800298 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
299 public static final int MESSAGE_URI_COLUMN = 2;
300 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
301 public static final int MESSAGE_SUBJECT_COLUMN = 4;
302 public static final int MESSAGE_SNIPPET_COLUMN = 5;
303 public static final int MESSAGE_FROM_COLUMN = 6;
304 public static final int MESSAGE_TO_COLUMN = 7;
305 public static final int MESSAGE_CC_COLUMN = 8;
306 public static final int MESSAGE_BCC_COLUMN = 9;
307 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
308 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
309 public static final int MESSAGE_BODY_HTML = 12;
310 public static final int MESSAGE_BODY_TEXT = 13;
311 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
312 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
313 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
314 public static final int MESSAGE_INCLUDE_QUOTED_TEXT_COLUMN = 17;
315 public static final int MESSAGE_QUOTE_START_POS_COLUMN = 18;
316 public static final int MESSAGE_CLIENT_CREATED_COLUMN = 19;
317 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 20;
318 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 21;
319 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 22;
320 public static final int MESSAGE_FLAGS_COLUMN = 23;
Mindy Pereira6349a042012-01-04 11:25:01 -0800321
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800322 public static final class MessageFlags {
323 public static final int SYNCABLE = 0x0001;
324 public static final int PARENT = 0x0002;
325 public static final int CAN_HOLD_MAIL = 0x0004;
326 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Mindy Pereira326c6602012-01-04 15:32:42 -0800327 public static final int STARRED = 0x0012;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800328 }
329
Mindy Pereira6f92de62011-12-19 11:31:48 -0800330 public static final class MessageColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800331 public static final String URI = "messageUri";
Mindy Pereira326c6602012-01-04 15:32:42 -0800332 public static final String SERVER_ID = "localMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800333 public static final String CONVERSATION_ID = "conversationId";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800334 public static final String SUBJECT = "subject";
335 public static final String SNIPPET = "snippet";
336 public static final String FROM = "fromAddress";
337 public static final String TO = "toAddresses";
338 public static final String CC = "ccAddresses";
339 public static final String BCC = "bccAddresses";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800340 public static final String REPLY_TO = "replyToAddress";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800341 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800342 public static final String BODY_HTML = "bodyHtml";
343 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800344 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
345 public static final String REF_MESSAGE_ID = "refMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800346 public static final String DRAFT_TYPE = "draftType";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800347 public static final String INCLUDE_QUOTED_TEXT = "includeQuotedText";
348 public static final String QUOTE_START_POS = "quoteStartPos";
349 public static final String CLIENT_CREATED = "clientCreated";
350 public static final String CUSTOM_FROM_ADDRESS = "customFromAddress";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800351 public static final String HAS_ATTACHMENTS = "hasAttachments";
352 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
353 public static final String MESSAGE_FLAGS = "messagesFlags";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800354
355 private MessageColumns() {}
356 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800357
358 // We define a "folder" as anything that contains a list of conversations.
359 public static final String ATTACHMENT_LIST_TYPE =
360 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
361 public static final String ATTACHMENT_TYPE =
362 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
363
364 public static final String[] ATTACHMENT_PROJECTION = {
365 BaseColumns._ID,
366 AttachmentColumns.NAME,
367 AttachmentColumns.SIZE,
368 AttachmentColumns.ORIGIN,
369 AttachmentColumns.ORIGIN_EXTRAS,
370 AttachmentColumns.CONTENT_TYPE,
371 AttachmentColumns.SYNCED
372 };
373
Mindy Pereira3263fa92012-01-04 10:15:32 -0800374 public static final int ACCOUNT_NAME_COLUMN = 1;
375
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800376 public static final class AttachmentColumns {
377 public static final String NAME = "name";
378 public static final String SIZE = "size";
379 public static final String ORIGIN = "origin";
380 public static final String ORIGIN_EXTRAS = "originExtras";
381 public static final String CONTENT_TYPE = "contentType";
382 public static final String SYNCED = "synced";
383 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800384}