summaryrefslogtreecommitdiffstats
path: root/lib/mapapi/com/android/bluetooth/mapapi/BluetoothMapEmailContract.java
blob: 61c49e73425aad525075ef556bdc619bbe0173a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/*
 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.bluetooth.mapapi;

import android.content.ContentResolver;
import android.net.Uri;
import com.android.bluetooth.mapapi.BluetoothMapContract.MessageColumns;
import com.android.bluetooth.mapapi.BluetoothMapContract.EmailMessageColumns;
import com.android.bluetooth.mapapi.BluetoothMapContract.FolderColumns;


/**
 * This class defines the minimum sets of data needed for a client to
 * implement to claim support for the Bluetooth Message Access Profile.
 * Access to three data sets are needed:
 * <ul>
 *   <li>Message data set containing lists of messages.</li>
 *   <li>Account data set containing info on the existing accounts, and whether to expose
 *     these accounts. The content of the account data set is often sensitive information,
 *     hence care must be taken, not to reveal any personal information nor passwords.
 *     The accounts in this data base will be exposed in the settings menu, where the user
 *     is able to enable and disable the EXPOSE_FLAG, and thereby provide access to an
 *     account from another device, without any password protection the e-mail client
 *     might provide.</li>
 *   <li>Folder data set with the folder structure for the messages. Each message is linked to an
 *     entry in this data set.</li>
 *   <li>Conversation data set with the thread structure of the messages. Each message is linked
 *     to an entry in this data set.</li>
 * </ul>
 *
 * To enable that the Bluetooth Message Access Server can detect the content provider implementing
 * this interface, the {@code provider} tag for the Bluetooth related content provider must
 * have an intent-filter like the following in the manifest:
 * <pre class="prettyprint">&lt;provider  android:authorities="[PROVIDER AUTHORITY]"
              android:exported="true"
              android:enabled="true"
              android:permission="android.permission.BLUETOOTH_MAP"&gt;
 *   ...
 *      &lt;intent-filter&gt;
           &lt;action android:name="android.content.action.BLEUETOOT_MAP_PROVIDER" /&gt;
        &lt;/intent-filter&gt;
 *   ...
 *   &lt;/provider&gt;
 * [PROVIDER AUTHORITY] shall be the providers authority value which implements this
 * contract. Only a single authority shall be used. The android.permission.BLUETOOTH_MAP
 * permission is needed for the provider.
 */
public final class BluetoothMapEmailContract {
    /**
     * Constructor - should not be used
     */
    private BluetoothMapEmailContract(){
      /* class should not be instantiated */
    }

    public static final String EMAIL_AUTHORITY = "com.android.email.provider";
    public static final String ACTION_CHECK_MAIL =
            "org.codeaurora.email.intent.action.MAIL_SERVICE_WAKEUP";
    public static final String EXTRA_ACCOUNT = "org.codeaurora.email.intent.extra.ACCOUNT";
    public static final String ACTION_DELETE_MESSAGE =
            "org.codeaurora.email.intent.action.MAIL_SERVICE_DELETE_MESSAGE";
    public static final String ACTION_MOVE_MESSAGE =
            "org.codeaurora.email.intent.action.MAIL_SERVICE_MOVE_MESSAGE";
    public static final String ACTION_MESSAGE_READ =
            "org.codeaurora.email.intent.action.MAIL_SERVICE_MESSAGE_READ";
    public static final String ACTION_SEND_PENDING_MAIL =
            "org.codeaurora.email.intent.action.MAIL_SERVICE_SEND_PENDING";
    public static final String EXTRA_MESSAGE_ID = "org.codeaurora.email.intent.extra.MESSAGE_ID";
    public static final String EXTRA_MESSAGE_INFO =
            "org.codeaurora.email.intent.extra.MESSAGE_INFO";

    /**
     * Build URI representing the given Accounts data-set in a
     * Bluetooth provider. When queried, the direct URI for the account
     * with the given accountID is returned.
     */
    public static Uri buildEmailAccountUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority).appendPath(EMAIL_TABLE_ACCOUNT).build();
    }

    /**
     * Build URI representing the given Accounts data-set in a
     * Bluetooth provider. When queried, the direct URI for the account
     * with the given accountID is returned.
     */
    public static Uri buildEmailAccountUriWithId(String authority, String accountId) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority).appendPath(EMAIL_TABLE_ACCOUNT)
                .appendPath(accountId).build();
    }

    /**
     * Build URI representing the entire Message table in a
     * Bluetooth provider.
     */
    public static Uri buildEmailMessageUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .appendPath(EMAIL_TABLE_MESSAGE)
                .build();
    }

    /**
     * Build URI representing the entire Message table in a
     * Bluetooth provider.
     */
    public static Uri buildEmailMessageUri(String authority, String accountId) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .appendPath(accountId)
                .appendPath(EMAIL_TABLE_MESSAGE)
                .build();
    }

    /**
     * Build URI representing the entire email Attachment table in a
     * Bluetooth provider.
     */
    public static Uri buildEmailAttachmentUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .appendPath(EMAIL_TABLE_ATTACHMENT)
                .build();
    }
    /**
     * Build URI representing the entire MessageBody table in a
     * Bluetooth provider.
     */
    public static Uri buildEmailMessageBodyUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .appendPath(EMAIL_TABLE_MSGBODY)
                .build();
    }
    /**
     * Build URI representing the given Message data-set in a
     * Bluetooth provider. When queried, the direct URI for the folder
     * with the given accountID is returned.
     */
    public static Uri buildMailboxUri(String authority) {
        return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
                .authority(authority)
                .appendPath(EMAIL_TABLE_MAILBOX)
                .build();
    }

    /**
     *  @hide
     */
    public static final String EMAIL_TABLE_ACCOUNT  = "account";
    public static final String EMAIL_TABLE_MESSAGE  = "message";
    public static final String EMAIL_TABLE_ATTACHMENT = "attachment";
    public static final String EMAIL_TABLE_MSGBODY = "body";
    public static final String EMAIL_TABLE_MAILBOX  = "mailbox";

    /**
     * Mandatory folders for the Bluetooth message access profile.
     * The email client shall at least implement the following root folders.
     * E.g. as a mapping for them such that the naming will match the underlying
     * matching folder ID's.
     */
    public static final String FOLDER_NAME_INBOX   = "INBOX";
    public static final String FOLDER_NAME_SENT    = "SENT";
    public static final String FOLDER_NAME_OUTBOX  = "OUTBOX";
    public static final String FOLDER_NAME_DRAFT   = "DRAFT";
    public static final String FOLDER_NAME_DRAFTS  = "DRAFTS";
    public static final String FOLDER_NAME_DELETED = "DELETED";
    public static final String FOLDER_NAME_OTHER   = "OTHER";

    /**
     * Folder IDs to be used with Instant Messaging virtual folders
     */
    public static final long FOLDER_ID_OTHER      = 0;
    public static final long FOLDER_ID_INBOX      = 1;
    public static final long FOLDER_ID_SENT       = 2;
    public static final long FOLDER_ID_DRAFT      = 3;
    public static final long FOLDER_ID_OUTBOX     = 4;
    public static final long FOLDER_ID_DELETED    = 5;

    // Types of mailboxes. From EmailContent.java
    // inbox
    public static final int TYPE_INBOX = 0;
    // draft
    public static final int TYPE_DRAFT = 3;
    // outbox
    public static final int TYPE_OUTBOX = 4;
    // sent
    public static final int TYPE_SENT = 5;
    // deleted
    public static final int TYPE_DELETED = 6;
    // Values used in mFlagLoaded
    public static final int FLAG_LOADED_COMPLETE = 1;

    public interface EmailBodyColumns {
        // Foreign key to the message corresponding to this body
        public static final String MESSAGE_KEY = "messageKey";
        // The html content itself, not returned on query
        public static final String HTML_CONTENT = "htmlContent";
        // The html content URI, for ContentResolver#openFileDescriptor()
        public static final String HTML_CONTENT_URI = "htmlContentUri";
        // The plain text content itself, not returned on query
        public static final String TEXT_CONTENT = "textContent";
       // The text content URI, for ContentResolver#openFileDescriptor()
       public static final String TEXT_CONTENT_URI = "textContentUri";
       // Replied-to or forwarded body (in html form)
    }

    public interface ExtEmailMessageColumns extends EmailMessageColumns {
        public static final String RECORD_ID = "_id";
        public static final String DISPLAY_NAME = "displayName";
        public static final String EMAIL_ADDRESS = "emailAddress";
        public static final String ACCOUNT_KEY = "accountKey";
        public static final String IS_DEFAULT = "isDefault";
        public static final String EMAIL_TYPE = "type";
        public static final String MAILBOX_KEY = "mailboxKey";
        // The time (millis) as shown to the user in a message list [INDEX]
        public static final String TIMESTAMP = "timeStamp";
        public static final String EMAIL_SERVICE_NAME = "EMAIL Message Access";
        /**
         * Message Read flag
         * <P>Type: INTEGER (boolean) unread = 0, read = 1</P>
         *  read/write
         */
        public static final String EMAIL_FLAG_READ = "flagRead";
        /** The overall size in bytes of the message including any attachments.
         * This value is informative only and should be the size an email client
         * would display as size for the message.
         * <P>Type: INTEGER </P>
         * read-only
         */
        public static final String EMAIL_ATTACHMENT_SIZE = "size";
        public static final String FLAGS = "flags";
        public static final String FLAG_LOADED = "flagLoaded";
        // Boolean, no attachment = 0, attachment = 1
        public static final String EMAIL_FLAG_ATTACHMENT = "flagAttachment";
        // Saved draft info (reusing the never-used "clientId" column)
        public static final String DRAFT_INFO = "clientId";
       // The message-id in the message's header
       public static final String MESSAGE_ID = "messageId";
       // Address lists, packed with Address.pack()
       public static final String EMAIL_FROM_LIST = "fromList";
       public static final String EMAIL_TO_LIST = "toList";
       public static final String EMAIL_CC_LIST = "ccList";
       public static final String EMAIL_BCC_LIST = "bccList";
       public static final String EMAIL_REPLY_TO_LIST = "replyToList";
       public static final String MEETING_INFO = "meetingInfo";
       public static final String SNIPPET = "snippet";
       public static final String PROTOCOL_SEARCH_INFO = "protocolSearchInfo";
       public static final String THREAD_TOPIC = "threadTopic";
    }

    /**
     * Message folder structure
     * MAP enforces use of a folder structure with mandatory folders:
     *   - inbox, outbox, sent, deleted, draft
     * User defined folders are supported.
     * The folder table must provide filtering (use of WHERE clauses) of the following entries:
     *   - account_id (linking the folder to an e-mail account)
     *   - parent_id (linking the folders individually)
     * The folder table must have a folder name for each entry, and the mandatory folders
     * MUST exist for each account_id. The folders may be empty.
     * Use the FOLDER_NAME_xxx constants for the mandatory folders. Their names must
     * not be translated into other languages, as the folder browsing is string based, and
     * many Bluetooth Message Clients will use these strings to navigate to the folders.
     */
    public interface MailBoxColumns extends FolderColumns {
        public static final String DISPLAY_NAME = "displayName";
        public static final String SERVER_ID = "serverId";
        public static final String PARENT_SERVER_ID = "parentServerId";
        public static final String ACCOUNT_KEY = "accountKey";
    }

    public static final String[] BT_EMAIL_ATTACHMENT_PROJECTION = new String[] {
        ExtEmailMessageColumns.EMAIL_ATTACHMENT_SIZE
    };

    public static final String[] BT_EMAIL_MESSAGE_PROJECTION = new String[] {
        ExtEmailMessageColumns.RECORD_ID,
        ExtEmailMessageColumns.MAILBOX_KEY,
        ExtEmailMessageColumns.ACCOUNT_KEY,
        ExtEmailMessageColumns.DISPLAY_NAME,
        ExtEmailMessageColumns.TIMESTAMP,
        ExtEmailMessageColumns.EMAIL_FLAG_READ,
        MessageColumns.SUBJECT,
        ExtEmailMessageColumns.EMAIL_FLAG_ATTACHMENT,
        ExtEmailMessageColumns.FLAG_LOADED,
        ExtEmailMessageColumns.FLAGS,
        ExtEmailMessageColumns.DRAFT_INFO,
        ExtEmailMessageColumns.MESSAGE_ID,
        ExtEmailMessageColumns.EMAIL_FROM_LIST,
        ExtEmailMessageColumns.EMAIL_TO_LIST,
        ExtEmailMessageColumns.EMAIL_CC_LIST,
        ExtEmailMessageColumns.EMAIL_BCC_LIST,
        ExtEmailMessageColumns.EMAIL_REPLY_TO_LIST,
        ExtEmailMessageColumns.MEETING_INFO,
        ExtEmailMessageColumns.SNIPPET,
        ExtEmailMessageColumns.PROTOCOL_SEARCH_INFO,
        ExtEmailMessageColumns.THREAD_TOPIC
    };

    public static final String[] BT_EMAIL_MSG_PROJECTION_SHORT = new String[] {
        ExtEmailMessageColumns.ACCOUNT_KEY,
        ExtEmailMessageColumns.RECORD_ID,
        ExtEmailMessageColumns.MAILBOX_KEY,
        ExtEmailMessageColumns.EMAIL_FLAG_READ
    };

    public static final String[] BT_EMAIL_MSG_PROJECTION_SHORT_EXT = new String[] {
        ExtEmailMessageColumns.ACCOUNT_KEY,
        ExtEmailMessageColumns.RECORD_ID,
        ExtEmailMessageColumns.MAILBOX_KEY,
        ExtEmailMessageColumns.TIMESTAMP,
        MessageColumns.SUBJECT,
        ExtEmailMessageColumns.EMAIL_FROM_LIST,
        ExtEmailMessageColumns.EMAIL_FLAG_READ
    };

    public static final String[] BT_EMAIL_BODY_CONTENT_PROJECTION = new String[] {
        MessageColumns._ID,
        EmailBodyColumns.MESSAGE_KEY,
        EmailBodyColumns.HTML_CONTENT_URI,
        EmailBodyColumns.TEXT_CONTENT_URI
    };


    public static final String[] BT_EMAIL_ACCOUNT_ID_PROJECTION = new String[] {
        ExtEmailMessageColumns.RECORD_ID,
        ExtEmailMessageColumns.DISPLAY_NAME,
        ExtEmailMessageColumns.EMAIL_ADDRESS,
        ExtEmailMessageColumns.IS_DEFAULT
    };

    /**
     * A projection of all the columns in the Folder table
     */
    public static final String[] BT_FOLDER_PROJECTION = new String[] {
        FolderColumns._ID,
        FolderColumns.NAME,
        FolderColumns.ACCOUNT_ID,
        FolderColumns.PARENT_FOLDER_ID
    };

    /**
     * A projection of all the columns in the Folder table
     */
    public static final String[] BT_EMAIL_MAILBOX_PROJECTION = new String[] {
        FolderColumns._ID,
        MailBoxColumns.DISPLAY_NAME,
        MailBoxColumns.ACCOUNT_KEY,
        MailBoxColumns.SERVER_ID,
        MailBoxColumns.PARENT_SERVER_ID
    };

}