blob: 0ba8f5dd0b4a3f5e82b4198b8c42081b2d883fb7 [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 {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080025 // The actual content provider should define its own authority
Mindy Pereirafdd984b2011-12-29 09:43:45 -080026 public static final String AUTHORITY = "com.android.email.providers";
Mindy Pereira6f92de62011-12-19 11:31:48 -080027
28 public static final String ACCOUNT_LIST_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080029 "vnd.android.cursor.dir/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080030 public static final String ACCOUNT_TYPE =
Paul Westbrook82ea6da2011-12-15 11:03:51 -080031 "vnd.android.cursor.item/vnd.com.android.mail.account";
Mindy Pereira6f92de62011-12-19 11:31:48 -080032
33 public static final String[] ACCOUNTS_PROJECTION = {
34 BaseColumns._ID,
35 AccountColumns.NAME,
36 AccountColumns.PROVIDER_VERSION,
37 AccountColumns.URI,
38 AccountColumns.CAPABILITIES,
39 AccountColumns.FOLDER_LIST_URI,
40 AccountColumns.SEARCH_URI,
41 AccountColumns.ACCOUNT_FROM_ADDRESSES_URI,
Paul Westbrook82ea6da2011-12-15 11:03:51 -080042 AccountColumns.SAVE_NEW_DRAFT_URI,
Mindy Pereira3a565bf2011-12-21 11:26:21 -080043 AccountColumns.SEND_MESSAGE_URI
Mindy Pereira6f92de62011-12-19 11:31:48 -080044 };
45
46 public static final class AccountCapabilities {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080047 public static final int SYNCABLE_FOLDERS = 0x0001;
48 public static final int REPORT_SPAM = 0x0002;
49 public static final int ARCHIVE = 0x0004;
50 public static final int MUTE = 0x0008;
51 public static final int SERVER_SEARCH = 0x0010;
52 public static final int FOLDER_SERVER_SEARCH = 0x0020;
53 public static final int SANITIZED_HTML = 0x0040;
54 public static final int DRAFT_SYNCHRONIZATION = 0x0080;
55 public static final int MULTIPLE_FROM_ADDRESSES = 0x0100;
56 public static final int SMART_REPLY = 0x0200;
57 public static final int LOCAL_SEARCH = 0x0400;
58 public static final int THREADED_CONVERSATIONS = 0x0800;
Mindy Pereira6f92de62011-12-19 11:31:48 -080059 }
60
61 public static final class AccountColumns {
Paul Westbrook82ea6da2011-12-15 11:03:51 -080062 /**
63 * This string column contains the human visible name for the account.
64 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080065 public static final String NAME = "name";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080066
67 /**
68 * This integer column returns the version of the UI provider schema from which this
69 * account provider will return results.
70 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080071 public static final String PROVIDER_VERSION = "providerVersion";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080072
73 /**
74 * This string column contains the uri to directly access the information for this account.
75 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080076 public static final String URI = "uri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080077
78 /**
79 * This integer column contains a bit field of the possible cabibilities that this account
80 * supports.
81 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080082 public static final String CAPABILITIES = "capabilities";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080083
84 /**
Mindy Pereira750cc732011-12-21 13:32:29 -080085 * This string column contains the content provider uri to return the
86 * list of top level folders for this account.
Paul Westbrook82ea6da2011-12-15 11:03:51 -080087 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080088 public static final String FOLDER_LIST_URI = "folderListUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080089
90 /**
91 * This string column contains the content provider uri that can be queried for search
92 * results.
93 */
Mindy Pereira6f92de62011-12-19 11:31:48 -080094 public static final String SEARCH_URI = "searchUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -080095
96 /**
97 * This string column contains the content provider uri that can be queried to access the
98 * from addresses for this account.
99 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800100 public static final String ACCOUNT_FROM_ADDRESSES_URI = "accountFromAddressesUri";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800101
102 /**
103 * This string column contains the content provider uri that can be used to save (insert)
104 * new draft messages for this account.
105 */
Mindy Pereira6f92de62011-12-19 11:31:48 -0800106 public static final String SAVE_NEW_DRAFT_URI = "saveNewDraftUri";
107
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800108 /**
109 * This string column contains the content provider uri that can be used to send
110 * a message for this account.
111 * NOTE: This might be better to be an update operation on the messageUri.
112 */
113 public static final String SEND_MESSAGE_URI = "sendMessageUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800114 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800115
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800116 // We define a "folder" as anything that contains a list of conversations.
117 public static final String FOLDER_LIST_TYPE =
118 "vnd.android.cursor.dir/vnd.com.android.mail.folder";
119 public static final String FOLDER_TYPE =
Mindy Pereira750cc732011-12-21 13:32:29 -0800120 "vnd.android.cursor.item/vnd.com.android.mail.folder";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800121
122 public static final String[] FOLDERS_PROJECTION = {
123 BaseColumns._ID,
124 FolderColumns.NAME,
Mindy Pereira750cc732011-12-21 13:32:29 -0800125 FolderColumns.HAS_CHILDREN,
Mindy Pereira0973b202011-12-21 15:48:12 -0800126 FolderColumns.CAPABILITIES,
127 FolderColumns.SYNC_FREQUENCY,
128 FolderColumns.SYNC_WINDOW,
Mindy Pereira750cc732011-12-21 13:32:29 -0800129 FolderColumns.CONVERSATION_LIST_URI,
130 FolderColumns.CHILD_FOLDERS_LIST_URI
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800131 };
132
Mindy Pereira0973b202011-12-21 15:48:12 -0800133 public static final class FolderCapabilities {
134 public static final int SYNCABLE = 0x0001;
135 public static final int PARENT = 0x0002;
136 public static final int CAN_HOLD_MAIL = 0x0004;
137 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
138 }
139
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800140 public static final class FolderColumns {
141 /**
142 * This string column contains the human visible name for the folder.
143 */
144 public static final String NAME = "name";
145 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800146 * This int column represents the capabilities of the folder specified by
147 * FolderCapabilities flags.
148 */
149 public static String CAPABILITIES = "capabilities";
150 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800151 * This boolean column represents whether or not this folder has any
152 * child folders.
153 */
154 public static String HAS_CHILDREN = "hasChildren";
155 /**
Mindy Pereira0973b202011-12-21 15:48:12 -0800156 * This int column represents how often the folder should be synced.
157 */
158 public static String SYNC_FREQUENCY = "syncFrequency";
159 /**
160 * This int column represents how large the sync window is.
161 */
162 public static String SYNC_WINDOW = "syncWindow";
163 /**
Mindy Pereira750cc732011-12-21 13:32:29 -0800164 * This string column contains the content provider uri to return the
165 * list of conversations for this folder.
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800166 */
167 public static final String CONVERSATION_LIST_URI = "conversationListUri";
Mindy Pereira750cc732011-12-21 13:32:29 -0800168 /**
169 * This string column contains the content provider uri to return the
170 * list of child folders of this folder.
171 */
172 public static String CHILD_FOLDERS_LIST_URI = "childFoldersListUri";
Mindy Pereira3a565bf2011-12-21 11:26:21 -0800173
174 public FolderColumns() {};
Mindy Pereira6f92de62011-12-19 11:31:48 -0800175 }
176
Mindy Pereiraa1406072011-12-22 10:54:06 -0800177 // We define a "folder" as anything that contains a list of conversations.
178 public static final String CONVERSATION_LIST_TYPE =
179 "vnd.android.cursor.dir/vnd.com.android.mail.conversation";
180 public static final String CONVERSATION_TYPE =
181 "vnd.android.cursor.item/vnd.com.android.mail.conversation";
182
183 public static final String[] CONVERSATION_PROJECTION = {
184 BaseColumns._ID,
Mindy Pereira3263fa92012-01-04 10:15:32 -0800185 ConversationColumns.CONVERSATION_URI,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800186 ConversationColumns.MESSAGE_LIST_URI,
Mindy Pereiraa1406072011-12-22 10:54:06 -0800187 ConversationColumns.SUBJECT,
Mindy Pereiraf9573c52011-12-22 14:02:49 -0800188 ConversationColumns.SNIPPET,
189 ConversationColumns.SENDER_INFO,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800190 ConversationColumns.DATE_RECEIVED_MS,
191 ConversationColumns.HAS_ATTACHMENTS
Mindy Pereiraa1406072011-12-22 10:54:06 -0800192 };
193
Mindy Pereirafdd984b2011-12-29 09:43:45 -0800194 // These column indexes only work when the caller uses the
195 // default CONVERSATION_PROJECTION defined above.
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800196 public static final int CONVERSATION_ID_COLUMN = 0;
Mindy Pereira3263fa92012-01-04 10:15:32 -0800197 public static final int CONVERSATION_URI_COLUMN = 1;
198 public static final int CONVERSATION_MESSAGE_LIST_URI_COLUMN = 2;
199 public static final int CONVERSATION_SUBJECT_COLUMN = 3;
200 public static final int CONVERSATION_SNIPPET_COLUMN = 4;
201 public static final int CONVERSATION_SENDER_INFO_COLUMN = 5;
202 public static final int CONVERSATION_DATE_RECEIVED_MS_COLUMN = 6;
203 public static final int CONVERSATION_HAS_ATTACHMENTS_COLUMN = 7;
Mindy Pereirafa7ef6e2011-12-29 14:18:15 -0800204
Mindy Pereiraa1406072011-12-22 10:54:06 -0800205 public static final class ConversationColumns {
Mindy Pereira3263fa92012-01-04 10:15:32 -0800206 public static final String CONVERSATION_URI = "conversationUri";
Mindy Pereiraa1406072011-12-22 10:54:06 -0800207 /**
Mindy Pereiraa1406072011-12-22 10:54:06 -0800208 * This string column contains the content provider uri to return the
209 * list of messages for this conversation.
210 */
211 public static final String MESSAGE_LIST_URI = "messageListUri";
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800212 /**
213 * This string column contains the subject string for a conversation.
214 */
215 public static final String SUBJECT = "subject";
216 /**
217 * This string column contains the snippet string for a conversation.
218 */
219 public static final String SNIPPET = "snippet";
220 /**
221 * This string column contains the sender info string for a
222 * conversation.
223 */
224 public static final String SENDER_INFO = "senderInfo";
225 /**
226 * This long column contains the time in ms of the latest update to a
227 * conversation.
228 */
229 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
230
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800231 /**
232 * This boolean column contains whether any messages in this conversation
233 * have attachments.
234 */
235 public static final String HAS_ATTACHMENTS = "hasAttachments";
236
Mindy Pereira27a0cf02011-12-22 13:16:32 -0800237 public ConversationColumns() {
238 };
Mindy Pereiraa1406072011-12-22 10:54:06 -0800239 }
240
Mindy Pereira6f92de62011-12-19 11:31:48 -0800241 /**
242 * Returns a uri that, when queried, will return a cursor with a list of information for the
243 * list of configured accounts.
244 * @return
245 */
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800246 // TODO: create a static registry for the starting point for the UI provider.
247// public static Uri getAccountsUri() {
248// return Uri.parse(BASE_URI_STRING + "/");
249// }
250
251 public static final class DraftType {
252 public static final String COMPOSE = "compose";
253 public static final String REPLY = "reply";
254 public static final String REPLY_ALL = "replyAll";
255 public static final String FORWARD = "forward";
256
257 private DraftType() {}
Mindy Pereira6f92de62011-12-19 11:31:48 -0800258 }
259
Mindy Pereiraa1406072011-12-22 10:54:06 -0800260 public static final String[] MESSAGE_PROJECTION = {
261 BaseColumns._ID,
262 MessageColumns.URI,
263 MessageColumns.MESSAGE_ID,
264 MessageColumns.CONVERSATION_ID,
265 MessageColumns.SUBJECT,
266 MessageColumns.SNIPPET,
267 MessageColumns.FROM,
268 MessageColumns.TO,
269 MessageColumns.CC,
270 MessageColumns.BCC,
271 MessageColumns.REPLY_TO,
272 MessageColumns.DATE_RECEIVED_MS,
273 MessageColumns.BODY_HTML,
274 MessageColumns.BODY_TEXT,
275 MessageColumns.EMBEDS_EXTERNAL_RESOURCES,
276 MessageColumns.REF_MESSAGE_ID,
277 MessageColumns.DRAFT_TYPE,
278 MessageColumns.INCLUDE_QUOTED_TEXT,
279 MessageColumns.QUOTE_START_POS,
280 MessageColumns.CLIENT_CREATED,
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800281 MessageColumns.CUSTOM_FROM_ADDRESS,
282 MessageColumns.HAS_ATTACHMENTS,
283 MessageColumns.ATTACHMENT_LIST_URI
Mindy Pereiraa1406072011-12-22 10:54:06 -0800284 };
285
Mindy Pereiraa1406072011-12-22 10:54:06 -0800286 public static final String MESSAGE_LIST_TYPE =
287 "vnd.android.cursor.dir/vnd.com.android.mail.message";
288 public static final String MESSAGE_TYPE =
289 "vnd.android.cursor.item/vnd.com.android.mail.message";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800290
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800291 public static final class MessageFlags {
292 public static final int SYNCABLE = 0x0001;
293 public static final int PARENT = 0x0002;
294 public static final int CAN_HOLD_MAIL = 0x0004;
295 public static final int CAN_ACCEPT_MOVED_MESSAGES = 0x0008;
296 }
297
Mindy Pereira6f92de62011-12-19 11:31:48 -0800298 public static final class MessageColumns {
Mindy Pereira6f92de62011-12-19 11:31:48 -0800299 public static final String URI = "uri";
300 public static final String MESSAGE_ID = "messageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800301 public static final String CONVERSATION_ID = "conversationId";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800302 public static final String SUBJECT = "subject";
303 public static final String SNIPPET = "snippet";
304 public static final String FROM = "fromAddress";
305 public static final String TO = "toAddresses";
306 public static final String CC = "ccAddresses";
307 public static final String BCC = "bccAddresses";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800308 public static final String REPLY_TO = "replyToAddress";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800309 public static final String DATE_RECEIVED_MS = "dateReceivedMs";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800310 public static final String BODY_HTML = "bodyHtml";
311 public static final String BODY_TEXT = "bodyText";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800312 public static final String EMBEDS_EXTERNAL_RESOURCES = "bodyEmbedsExternalResources";
313 public static final String REF_MESSAGE_ID = "refMessageId";
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800314 public static final String DRAFT_TYPE = "draftType";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800315 public static final String INCLUDE_QUOTED_TEXT = "includeQuotedText";
316 public static final String QUOTE_START_POS = "quoteStartPos";
317 public static final String CLIENT_CREATED = "clientCreated";
318 public static final String CUSTOM_FROM_ADDRESS = "customFromAddress";
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800319 public static final String HAS_ATTACHMENTS = "hasAttachments";
320 public static final String ATTACHMENT_LIST_URI = "attachmentListUri";
321 public static final String MESSAGE_FLAGS = "messagesFlags";
Mindy Pereira6f92de62011-12-19 11:31:48 -0800322 // TODO: Add attachments, flags
323
324 private MessageColumns() {}
325 }
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800326
327 // We define a "folder" as anything that contains a list of conversations.
328 public static final String ATTACHMENT_LIST_TYPE =
329 "vnd.android.cursor.dir/vnd.com.android.mail.attachment";
330 public static final String ATTACHMENT_TYPE =
331 "vnd.android.cursor.item/vnd.com.android.mail.attachment";
332
333 public static final String[] ATTACHMENT_PROJECTION = {
334 BaseColumns._ID,
335 AttachmentColumns.NAME,
336 AttachmentColumns.SIZE,
337 AttachmentColumns.ORIGIN,
338 AttachmentColumns.ORIGIN_EXTRAS,
339 AttachmentColumns.CONTENT_TYPE,
340 AttachmentColumns.SYNCED
341 };
342
Mindy Pereira3263fa92012-01-04 10:15:32 -0800343 public static final int ACCOUNT_NAME_COLUMN = 1;
344
Mindy Pereiraf30cc092011-12-29 14:02:40 -0800345 public static final class AttachmentColumns {
346 public static final String NAME = "name";
347 public static final String SIZE = "size";
348 public static final String ORIGIN = "origin";
349 public static final String ORIGIN_EXTRAS = "originExtras";
350 public static final String CONTENT_TYPE = "contentType";
351 public static final String SYNCED = "synced";
352 }
Paul Westbrook82ea6da2011-12-15 11:03:51 -0800353}