blob: b59db0e26d9495da122b1420d24087d3b3611d7d [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
Andy Huang30e2c242012-01-06 18:14:30 -080017package com.android.mail.providers;
Mindy Pereira6f92de62011-12-19 11:31:48 -080018
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
Andy Huang30e2c242012-01-06 18:14:30 -080029 public static final String AUTHORITY = "com.android.mail.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,
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800134 FolderColumns.CHILD_FOLDERS_LIST_URI,
135 FolderColumns.UNREAD_COUNT,
136 FolderColumns.TOTAL_COUNT
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800137 };
138
Mindy Pereira0973b202011-12-21 15:48:12 -0800139 public static final class FolderCapabilities {
140 public static final int SYNCABLE = 0x0001;
141 public static final int PARENT = 0x0002;
142 public static final int CAN_HOLD_MAIL = 0x0004;
143 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
144 }
145
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800146 public static final class FolderColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800147 public static String URI = "folderUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800148 /**
149 * This string column contains the human visible name for the folder.
150 */
151 public static final String NAME = "name";
152 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800153 * This int column represents the capabilities of the folder specified by
154 * FolderCapabilities flags.
155 */
156 public static String CAPABILITIES = "capabilities";
157 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800158 * This boolean column represents whether or not this folder has any
159 * child folders.
160 */
161 public static String HAS_CHILDREN = "hasChildren";
162 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800163 * This int column represents how often the folder should be synced.
164 */
165 public static String SYNC_FREQUENCY = "syncFrequency";
166 /**
167 * This int column represents how large the sync window is.
168 */
169 public static String SYNC_WINDOW = "syncWindow";
170 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800171 * This string column contains the content provider uri to return the
172 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800173 */
174 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800175 /**
176 * This string column contains the content provider uri to return the
177 * list of child folders of this folder.
178 */
179 public static String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800180
Mindy Pereirabd8f51c2012-01-06 13:41:48 -0800181 public static String UNREAD_COUNT = "unreadCount";
182
183 public static String TOTAL_COUNT = "totalCount";
184
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800185 public FolderColumns() {};
Mindy Pereira6f92de62011-12-19 11:31:48 -0800186 }
187
Mindy Pereiraa1406072011-12-22 10:54:06 -0800188 // We define a "folder" as anything that contains a list of conversations.
189 public static final String CONVERSATION_LIST_TYPE =
190 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
191 public static final String CONVERSATION_TYPE =
192 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
193
194 public static final String[] CONVERSATION_PROJECTION = {
195 BaseColumns._ID,
Mindy Pereira6349a042012-01-04 11:25:01 -0800196 ConversationColumns.URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800197 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800198 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800199 ConversationColumns.SNIPPET,
200 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800201 ConversationColumns.DATE_RECEIVED_MS,
202 ConversationColumns.HAS_ATTACHMENTS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800203 };
204
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800205 // These column indexes only work when the caller uses the
206 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800207 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800208 public static final int CONVERSATION_URI_COLUMN = 1;
209 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
210 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
211 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
212 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
213 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
214 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800215
Mindy Pereiraa1406072011-12-22 10:54:06 -0800216 public static final class ConversationColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800217 public static final String URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800218 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800219 * This string column contains the content provider uri to return the
220 * list of messages for this conversation.
221 */
222 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800223 /**
224 * This string column contains the subject string for a conversation.
225 */
226 public static final String SUBJECT = "subject";
227 /**
228 * This string column contains the snippet string for a conversation.
229 */
230 public static final String SNIPPET = "snippet";
231 /**
232 * This string column contains the sender info string for a
233 * conversation.
234 */
235 public static final String SENDER_INFO = "senderInfo";
236 /**
237 * This long column contains the time in ms of the latest update to a
238 * conversation.
239 */
240 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
241
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800242 /**
243 * This boolean column contains whether any messages in this conversation
244 * have attachments.
245 */
246 public static final String HAS_ATTACHMENTS = "hasAttachments";
247
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800248 public ConversationColumns() {
249 };
Mindy Pereiraa1406072011-12-22 10:54:06 -0800250 }
251
Mindy Pereira6f92de62011-12-19 11:31:48 -0800252 /**
253 * Returns a uri that, when queried, will return a cursor with a list of information for the
254 * list of configured accounts.
255 * @return
256 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800257 // TODO: create a static registry for the starting point for the UI provider.
258// public static Uri getAccountsUri() {
259// return Uri.parse(BASE_URI_STRING + "/");
260// }
261
262 public static final class DraftType {
263 public static final String COMPOSE = "compose";
264 public static final String REPLY = "reply";
265 public static final String REPLY_ALL = "replyAll";
266 public static final String FORWARD = "forward";
267
268 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800269 }
270
Mindy Pereiraa1406072011-12-22 10:54:06 -0800271 public static final String[] MESSAGE_PROJECTION = {
272 BaseColumns._ID,
Mindy Pereira326c6602012-01-04 15:32:42 -0800273 MessageColumns.SERVER_ID,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800274 MessageColumns.URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800275 MessageColumns.CONVERSATION_ID,
276 MessageColumns.SUBJECT,
277 MessageColumns.SNIPPET,
278 MessageColumns.FROM,
279 MessageColumns.TO,
280 MessageColumns.CC,
281 MessageColumns.BCC,
282 MessageColumns.REPLY_TO,
283 MessageColumns.DATE_RECEIVED_MS,
284 MessageColumns.BODY_HTML,
285 MessageColumns.BODY_TEXT,
286 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
287 MessageColumns.REF_MESSAGE_ID,
288 MessageColumns.DRAFT_TYPE,
289 MessageColumns.INCLUDE_QUOTED_TEXT,
290 MessageColumns.QUOTE_START_POS,
291 MessageColumns.CLIENT_CREATED,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800292 MessageColumns.CUSTOM_FROM_ADDRESS,
293 MessageColumns.HAS_ATTACHMENTS,
Mindy Pereira326c6602012-01-04 15:32:42 -0800294 MessageColumns.ATTACHMENT_LIST_URI,
295 MessageColumns.MESSAGE_FLAGS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800296 };
297
Mindy Pereiraa1406072011-12-22 10:54:06 -0800298 public static final String MESSAGE_LIST_TYPE =
299 "vnd.android.cursor.dir/vnd.com.android.mail.message";
300 public static final String MESSAGE_TYPE =
301 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800302
Mindy Pereira6349a042012-01-04 11:25:01 -0800303 public static final int MESSAGE_ID_COLUMN = 0;
Mindy Pereira326c6602012-01-04 15:32:42 -0800304 public static final int MESSAGE_SERVER_ID_COLUMN = 1;
305 public static final int MESSAGE_URI_COLUMN = 2;
306 public static final int MESSAGE_CONVERSATION_ID_COLUMN = 3;
307 public static final int MESSAGE_SUBJECT_COLUMN = 4;
308 public static final int MESSAGE_SNIPPET_COLUMN = 5;
309 public static final int MESSAGE_FROM_COLUMN = 6;
310 public static final int MESSAGE_TO_COLUMN = 7;
311 public static final int MESSAGE_CC_COLUMN = 8;
312 public static final int MESSAGE_BCC_COLUMN = 9;
313 public static final int MESSAGE_REPLY_TO_COLUMN = 10;
314 public static final int MESSAGE_DATE_RECEIVED_MS_COLUMN = 11;
315 public static final int MESSAGE_BODY_HTML = 12;
316 public static final int MESSAGE_BODY_TEXT = 13;
317 public static final int MESSAGE_EMBEDS_EXTERNAL_RESOURCES_COLUMN = 14;
318 public static final int MESSAGE_REF_MESSAGE_ID_COLUMN = 15;
319 public static final int MESSAGE_DRAFT_TYPE_COLUMN = 16;
320 public static final int MESSAGE_INCLUDE_QUOTED_TEXT_COLUMN = 17;
321 public static final int MESSAGE_QUOTE_START_POS_COLUMN = 18;
322 public static final int MESSAGE_CLIENT_CREATED_COLUMN = 19;
323 public static final int MESSAGE_CUSTOM_FROM_ADDRESS_COLUMN = 20;
324 public static final int MESSAGE_HAS_ATTACHMENTS_COLUMN = 21;
325 public static final int MESSAGE_ATTACHMENT_LIST_URI_COLUMN = 22;
326 public static final int MESSAGE_FLAGS_COLUMN = 23;
Mindy Pereira6349a042012-01-04 11:25:01 -0800327
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800328 public static final class MessageFlags {
329 public static final int SYNCABLE = 0x0001;
330 public static final int PARENT = 0x0002;
331 public static final int CAN_HOLD_MAIL = 0x0004;
332 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
Mindy Pereira326c6602012-01-04 15:32:42 -0800333 public static final int STARRED = 0x0012;
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800334 }
335
Mindy Pereira6f92de62011-12-19 11:31:48 -0800336 public static final class MessageColumns {
Mindy Pereira6349a042012-01-04 11:25:01 -0800337 public static final String URI = "messageUri";
Mindy Pereira326c6602012-01-04 15:32:42 -0800338 public static final String SERVER_ID = "localMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800339 public static final String CONVERSATION_ID = "conversationId";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800340 public static final String SUBJECT = "subject";
341 public static final String SNIPPET = "snippet";
342 public static final String FROM = "fromAddress";
343 public static final String TO = "toAddresses";
344 public static final String CC = "ccAddresses";
345 public static final String BCC = "bccAddresses";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800346 public static final String REPLY_TO = "replyToAddress";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800347 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800348 public static final String BODY_HTML = "bodyHtml";
349 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800350 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
351 public static final String REF_MESSAGE_ID = "refMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800352 public static final String DRAFT_TYPE = "draftType";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800353 public static final String INCLUDE_QUOTED_TEXT = "includeQuotedText";
354 public static final String QUOTE_START_POS = "quoteStartPos";
355 public static final String CLIENT_CREATED = "clientCreated";
356 public static final String CUSTOM_FROM_ADDRESS = "customFromAddress";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800357 public static final String HAS_ATTACHMENTS = "hasAttachments";
358 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
359 public static final String MESSAGE_FLAGS = "messagesFlags";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800360
361 private MessageColumns() {}
362 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800363
364 // We define a "folder" as anything that contains a list of conversations.
365 public static final String ATTACHMENT_LIST_TYPE =
366 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
367 public static final String ATTACHMENT_TYPE =
368 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
369
370 public static final String[] ATTACHMENT_PROJECTION = {
371 BaseColumns._ID,
372 AttachmentColumns.NAME,
373 AttachmentColumns.SIZE,
374 AttachmentColumns.ORIGIN,
375 AttachmentColumns.ORIGIN_EXTRAS,
376 AttachmentColumns.CONTENT_TYPE,
377 AttachmentColumns.SYNCED
378 };
379
Mindy Pereira3263fa92012-01-04 10:15:32 -0800380 public static final int ACCOUNT_NAME_COLUMN = 1;
381
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800382 public static final class AttachmentColumns {
383 public static final String NAME = "name";
384 public static final String SIZE = "size";
385 public static final String ORIGIN = "origin";
386 public static final String ORIGIN_EXTRAS = "originExtras";
387 public static final String CONTENT_TYPE = "contentType";
388 public static final String SYNCED = "synced";
389 }
Mindy Pereira013194c2012-01-06 15:09:33 -0800390
391 public static int getMailMaxAttachmentSize(String account) {
392 // TODO: query the account to see what the max attachment size is?
393 return 5 * 1024 * 1024;
394 }
395
396 public static String getAttachmentTypeSetting() {
397 // TODO: query the account to see what kinds of attachments it supports?
398 return "com.google.android.gm.allowAddAnyAttachment";
399 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800400}