blob: 83799c4440c915639bc831832b604e48c4d86455 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
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 android.provider;
18
RoboErikc2d53302011-06-03 09:37:58 -070019
RoboErik36726962011-06-14 14:01:15 -070020import android.annotation.SdkConstant;
21import android.annotation.SdkConstant.SdkConstantType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.app.AlarmManager;
23import android.app.PendingIntent;
Marc Blank64a556d2010-02-25 12:53:16 -080024import android.content.ContentProviderClient;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.content.ContentResolver;
26import android.content.ContentUris;
27import android.content.ContentValues;
28import android.content.Context;
Fred Quintana328c0e72009-12-07 14:52:28 -080029import android.content.CursorEntityIterator;
30import android.content.Entity;
Marc Blank64a556d2010-02-25 12:53:16 -080031import android.content.EntityIterator;
32import android.content.Intent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.database.Cursor;
Fred Quintana328c0e72009-12-07 14:52:28 -080034import android.database.DatabaseUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.net.Uri;
Michael Chancdaeafd2009-10-29 00:11:58 -070036import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037import android.text.format.DateUtils;
38import android.text.format.Time;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040
41/**
RoboErik260598d2011-06-13 17:12:12 -070042 * <p>
43 * The contract between the calendar provider and applications. Contains
44 * definitions for the supported URIs and data columns.
45 * </p>
46 * <h3>Overview</h3>
47 * <p>
48 * CalendarContract defines the data model of calendar and event related
49 * information. This data is stored in a number of tables:
50 * </p>
51 * <ul>
52 * <li>The {@link Calendars} table holds the calendar specific information. Each
53 * row in this table contains the details for a single calendar, such as the
54 * name, color, sync info, etc.</li>
55 * <li>The {@link Events} table holds the event specific information. Each row
56 * in this table has the info for a single event. It contains information such
57 * as event title, location, start time, end time, etc. The event can occur
58 * one-time or can recur multiple times. Attendees, reminders, and extended
59 * properties are stored on separate tables and reference the {@link Events#_ID}
60 * to link them with the event.</li>
61 * <li>The {@link Instances} table holds the start and end time for occurrences
62 * of an event. Each row in this table represents a single occurrence. For
63 * one-time events there will be a 1:1 mapping of instances to events. For
64 * recurring events, multiple rows will automatically be generated which
65 * correspond to multiple occurrences of that event.</li>
66 * <li>The {@link Attendees} table holds the event attendee or guest
67 * information. Each row represents a single guest of an event. It specifies the
68 * type of guest they are and their attendance response for the event.</li>
69 * <li>The {@link Reminders} table holds the alert/notification data. Each row
70 * represents a single alert for an event. An event can have multiple reminders.
71 * The number of reminders per event is specified in
72 * {@link Calendars#MAX_REMINDERS} which is set by the Sync Adapter that owns
73 * the given calendar. Reminders are specified in minutes before the event and
74 * have a type.</li>
Michael Chan73bddfc2011-10-19 18:21:49 -070075 * <li>The {@link ExtendedProperties} table holds opaque data fields used by the
RoboErik260598d2011-06-13 17:12:12 -070076 * sync adapter. The provider takes no action with items in this table except to
77 * delete them when their related events are deleted.</li>
78 * </ul>
79 * <p>
80 * Other tables include:
81 * </p>
82 * <ul>
83 * <li>
84 * {@link SyncState}, which contains free-form data maintained by the sync
85 * adapters</li>
86 * </ul>
RoboErikbec6c362011-06-14 11:06:01 -070087 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 */
RoboErikbec6c362011-06-14 11:06:01 -070089public final class CalendarContract {
RoboErikc2d53302011-06-03 09:37:58 -070090 private static final String TAG = "Calendar";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091
92 /**
RoboErikc2d53302011-06-03 09:37:58 -070093 * Broadcast Action: This is the intent that gets fired when an alarm
94 * notification needs to be posted for a reminder.
RoboErik083cd2d2011-06-30 11:53:05 -070095 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 */
RoboErik36726962011-06-14 14:01:15 -070097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
RoboErike00d5892011-06-23 15:16:55 -070098 public static final String ACTION_EVENT_REMINDER = "android.intent.action.EVENT_REMINDER";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099
100 /**
RoboErikc2d53302011-06-03 09:37:58 -0700101 * Intent Extras key: The start time of an event or an instance of a
102 * recurring event. (milliseconds since epoch)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 */
RoboErike00d5892011-06-23 15:16:55 -0700104 public static final String EXTRA_EVENT_BEGIN_TIME = "beginTime";
RoboErikc2d53302011-06-03 09:37:58 -0700105
106 /**
107 * Intent Extras key: The end time of an event or an instance of a recurring
108 * event. (milliseconds since epoch)
109 */
RoboErike00d5892011-06-23 15:16:55 -0700110 public static final String EXTRA_EVENT_END_TIME = "endTime";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111
Erike9b734d2011-02-14 13:32:19 -0800112 /**
Michael Chan7420f132011-08-25 00:54:25 -0700113 * Intent Extras key: When creating an event, set this to true to create an
114 * all-day event by default
115 */
116 public static final String EXTRA_EVENT_ALL_DAY = "allDay";
117
118 /**
RoboErikc2d53302011-06-03 09:37:58 -0700119 * This authority is used for writing to or querying from the calendar
120 * provider. Note: This is set at first run and cannot be changed without
121 * breaking apps that access the provider.
Erike9b734d2011-02-14 13:32:19 -0800122 */
Ken Shirriff1790c132010-01-22 13:45:31 -0800123 public static final String AUTHORITY = "com.android.calendar";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124
125 /**
126 * The content:// style URL for the top-level calendar authority
127 */
RoboErik083cd2d2011-06-30 11:53:05 -0700128 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129
130 /**
Ken Shirriff5b387e12009-10-23 09:50:41 -0700131 * An optional insert, update or delete URI parameter that allows the caller
RoboErikc2d53302011-06-03 09:37:58 -0700132 * to specify that it is a sync adapter. The default value is false. If set
133 * to true, the modified row is not marked as "dirty" (needs to be synced)
134 * and when the provider calls
135 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}
136 * , the third parameter "syncToNetwork" is set to false. Furthermore, if
137 * set to true, the caller must also include
Andy McFadden6f5b4552011-06-09 15:43:59 -0700138 * {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as
RoboErikc2d53302011-06-03 09:37:58 -0700139 * query parameters.
140 *
Andy McFadden6f5b4552011-06-09 15:43:59 -0700141 * @see Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)
Ken Shirriff5b387e12009-10-23 09:50:41 -0700142 */
143 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
144
RoboErikc2d53302011-06-03 09:37:58 -0700145 /**
146 * A special account type for calendars not associated with any account.
147 * Normally calendars that do not match an account on the device will be
148 * removed. Setting the account_type on a calendar to this will prevent it
149 * from being wiped if it does not match an existing account.
150 *
151 * @see SyncColumns#ACCOUNT_TYPE
152 */
153 public static final String ACCOUNT_TYPE_LOCAL = "LOCAL";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700154
155 /**
RoboErik36726962011-06-14 14:01:15 -0700156 * This utility class cannot be instantiated
157 */
158 private CalendarContract() {}
159
160 /**
RoboErikc2d53302011-06-03 09:37:58 -0700161 * Generic columns for use by sync adapters. The specific functions of these
162 * columns are private to the sync adapter. Other clients of the API should
163 * not attempt to either read or write this column. These columns are
164 * editable as part of the Calendars Uri, but can only be read if accessed
165 * through any other Uri.
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700166 */
RoboErikc2d53302011-06-03 09:37:58 -0700167 protected interface CalendarSyncColumns {
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700168
RoboErik9734df52011-06-09 14:11:25 -0700169
170 /**
171 * Generic column for use by sync adapters. Column name.
172 * <P>Type: TEXT</P>
173 */
RoboErikbe010392011-05-26 12:28:38 -0700174 public static final String CAL_SYNC1 = "cal_sync1";
RoboErik9734df52011-06-09 14:11:25 -0700175
176 /**
177 * Generic column for use by sync adapters. Column name.
178 * <P>Type: TEXT</P>
179 */
RoboErikbe010392011-05-26 12:28:38 -0700180 public static final String CAL_SYNC2 = "cal_sync2";
RoboErik9734df52011-06-09 14:11:25 -0700181
182 /**
183 * Generic column for use by sync adapters. Column name.
184 * <P>Type: TEXT</P>
185 */
RoboErikbe010392011-05-26 12:28:38 -0700186 public static final String CAL_SYNC3 = "cal_sync3";
RoboErik9734df52011-06-09 14:11:25 -0700187
188 /**
189 * Generic column for use by sync adapters. Column name.
190 * <P>Type: TEXT</P>
191 */
RoboErikbe010392011-05-26 12:28:38 -0700192 public static final String CAL_SYNC4 = "cal_sync4";
RoboErik9734df52011-06-09 14:11:25 -0700193
194 /**
195 * Generic column for use by sync adapters. Column name.
196 * <P>Type: TEXT</P>
197 */
RoboErikbe010392011-05-26 12:28:38 -0700198 public static final String CAL_SYNC5 = "cal_sync5";
RoboErik9734df52011-06-09 14:11:25 -0700199
200 /**
201 * Generic column for use by sync adapters. Column name.
202 * <P>Type: TEXT</P>
203 */
RoboErikbe010392011-05-26 12:28:38 -0700204 public static final String CAL_SYNC6 = "cal_sync6";
RoboErik9734df52011-06-09 14:11:25 -0700205
206 /**
207 * Generic column for use by sync adapters. Column name.
208 * <P>Type: TEXT</P>
209 */
210 public static final String CAL_SYNC7 = "cal_sync7";
211
212 /**
213 * Generic column for use by sync adapters. Column name.
214 * <P>Type: TEXT</P>
215 */
216 public static final String CAL_SYNC8 = "cal_sync8";
217
218 /**
219 * Generic column for use by sync adapters. Column name.
220 * <P>Type: TEXT</P>
221 */
222 public static final String CAL_SYNC9 = "cal_sync9";
223
224 /**
225 * Generic column for use by sync adapters. Column name.
226 * <P>Type: TEXT</P>
227 */
228 public static final String CAL_SYNC10 = "cal_sync10";
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700229 }
230
231 /**
RoboErikc2d53302011-06-03 09:37:58 -0700232 * Columns for Sync information used by Calendars and Events tables. These
233 * have specific uses which are expected to be consistent by the app and
234 * sync adapter.
235 *
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700236 */
RoboErik00258602011-06-13 13:47:59 -0700237 protected interface SyncColumns extends CalendarSyncColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700238 /**
RoboErikc2d53302011-06-03 09:37:58 -0700239 * The account that was used to sync the entry to the device. If the
240 * account_type is not {@link #ACCOUNT_TYPE_LOCAL} then the name and
241 * type must match an account on the device or the calendar will be
242 * deleted.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700243 * <P>Type: TEXT</P>
244 */
RoboErik651c02e2011-05-05 15:14:31 -0700245 public static final String ACCOUNT_NAME = "account_name";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700246
247 /**
RoboErikc2d53302011-06-03 09:37:58 -0700248 * The type of the account that was used to sync the entry to the
249 * device. A type of {@link #ACCOUNT_TYPE_LOCAL} will keep this event
250 * form being deleted if there are no matching accounts on the device.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700251 * <P>Type: TEXT</P>
252 */
RoboErik651c02e2011-05-05 15:14:31 -0700253 public static final String ACCOUNT_TYPE = "account_type";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700254
255 /**
RoboErikc2d53302011-06-03 09:37:58 -0700256 * The unique ID for a row assigned by the sync source. NULL if the row
257 * has never been synced. This is used as a reference id for exceptions
258 * along with {@link BaseColumns#_ID}.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700259 * <P>Type: TEXT</P>
260 */
261 public static final String _SYNC_ID = "_sync_id";
262
263 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700264 * Used to indicate that local, unsynced, changes are present.
265 * <P>Type: INTEGER (long)</P>
266 */
RoboErik651c02e2011-05-05 15:14:31 -0700267 public static final String DIRTY = "dirty";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700268
Alon Albert866f40a2011-06-06 14:04:00 -0700269 /**
RoboErik9734df52011-06-09 14:11:25 -0700270 * Whether the row has been deleted but not synced to the server. A
271 * deleted row should be ignored.
272 * <P>
273 * Type: INTEGER (boolean)
274 * </P>
275 */
276 public static final String DELETED = "deleted";
277
278 /**
Alon Albert866f40a2011-06-06 14:04:00 -0700279 * If set to 1 this causes events on this calendar to be duplicated with
RoboErik00258602011-06-13 13:47:59 -0700280 * {@link Events#LAST_SYNCED} set to 1 whenever the event
RoboErik9734df52011-06-09 14:11:25 -0700281 * transitions from non-dirty to dirty. The duplicated event will not be
282 * expanded in the instances table and will only show up in sync adapter
283 * queries of the events table. It will also be deleted when the
Alon Albert866f40a2011-06-06 14:04:00 -0700284 * originating event has its dirty flag cleared by the sync adapter.
285 * <P>Type: INTEGER (boolean)</P>
286 */
287 public static final String CAN_PARTIALLY_UPDATE = "canPartiallyUpdate";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700288 }
289
290 /**
RoboErikc2d53302011-06-03 09:37:58 -0700291 * Columns specific to the Calendars Uri that other Uris can query.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 */
RoboErike00d5892011-06-23 15:16:55 -0700293 protected interface CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 /**
RoboErik4f520612011-09-19 17:47:53 -0700295 * The color of the calendar. This should only be updated by the sync
296 * adapter, not other apps, as changing a calendar's color can adversely
297 * affect its display.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 * <P>Type: INTEGER (color value)</P>
299 */
RoboErik651c02e2011-05-05 15:14:31 -0700300 public static final String CALENDAR_COLOR = "calendar_color";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301
302 /**
RoboErik4172d952011-10-25 13:59:13 -0700303 * A key for looking up a color from the {@link Colors} table. NULL or
304 * an empty string are reserved for indicating that the calendar does
305 * not use a key for looking up the color. The provider will update
306 * {@link #CALENDAR_COLOR} automatically when a valid key is written to
307 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -0700308 * {@link Colors} table. @see Colors
RoboErikf8143c52011-09-28 15:16:00 -0700309 * <P>
310 * Type: TEXT
311 * </P>
RoboErikf8143c52011-09-28 15:16:00 -0700312 */
RoboErik4172d952011-10-25 13:59:13 -0700313 public static final String CALENDAR_COLOR_KEY = "calendar_color_index";
RoboErikf8143c52011-09-28 15:16:00 -0700314
315 /**
RoboErik9734df52011-06-09 14:11:25 -0700316 * The display name of the calendar. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700317 * <P>
318 * Type: TEXT
319 * </P>
RoboErik9734df52011-06-09 14:11:25 -0700320 */
321 public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName";
322
323 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 * The level of access that the user has for the calendar
325 * <P>Type: INTEGER (one of the values below)</P>
326 */
RoboErik9734df52011-06-09 14:11:25 -0700327 public static final String CALENDAR_ACCESS_LEVEL = "calendar_access_level";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328
329 /** Cannot access the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700330 public static final int CAL_ACCESS_NONE = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 /** Can only see free/busy information about the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700332 public static final int CAL_ACCESS_FREEBUSY = 100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800333 /** Can read all event details */
RoboErik9734df52011-06-09 14:11:25 -0700334 public static final int CAL_ACCESS_READ = 200;
RoboErikc2d53302011-06-03 09:37:58 -0700335 /** Can reply yes/no/maybe to an event */
RoboErik9734df52011-06-09 14:11:25 -0700336 public static final int CAL_ACCESS_RESPOND = 300;
RoboErikc2d53302011-06-03 09:37:58 -0700337 /** not used */
RoboErik9734df52011-06-09 14:11:25 -0700338 public static final int CAL_ACCESS_OVERRIDE = 400;
RoboErikc2d53302011-06-03 09:37:58 -0700339 /** Full access to modify the calendar, but not the access control
340 * settings
341 */
RoboErik9734df52011-06-09 14:11:25 -0700342 public static final int CAL_ACCESS_CONTRIBUTOR = 500;
RoboErikc2d53302011-06-03 09:37:58 -0700343 /** Full access to modify the calendar, but not the access control
344 * settings
345 */
RoboErik9734df52011-06-09 14:11:25 -0700346 public static final int CAL_ACCESS_EDITOR = 600;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800347 /** Full access to the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700348 public static final int CAL_ACCESS_OWNER = 700;
Debajit Ghosh2dcaafd2009-09-18 18:29:37 -0700349 /** Domain admin */
RoboErik9734df52011-06-09 14:11:25 -0700350 public static final int CAL_ACCESS_ROOT = 800;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351
352 /**
353 * Is the calendar selected to be displayed?
RoboErikc2d53302011-06-03 09:37:58 -0700354 * 0 - do not show events associated with this calendar.
355 * 1 - show events associated with this calendar
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800356 * <P>Type: INTEGER (boolean)</P>
357 */
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700358 public static final String VISIBLE = "visible";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800359
360 /**
RoboErikc2d53302011-06-03 09:37:58 -0700361 * The time zone the calendar is associated with.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800362 * <P>Type: TEXT</P>
363 */
RoboErik9734df52011-06-09 14:11:25 -0700364 public static final String CALENDAR_TIME_ZONE = "calendar_timezone";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800365
366 /**
RoboErikc2d53302011-06-03 09:37:58 -0700367 * Is this calendar synced and are its events stored on the device?
368 * 0 - Do not sync this calendar or store events for this calendar.
369 * 1 - Sync down events for this calendar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800370 * <p>Type: INTEGER (boolean)</p>
371 */
372 public static final String SYNC_EVENTS = "sync_events";
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700373
374 /**
RoboErik9734df52011-06-09 14:11:25 -0700375 * The owner account for this calendar, based on the calendar feed.
376 * This will be different from the _SYNC_ACCOUNT for delegated calendars.
377 * Column name.
378 * <P>Type: String</P>
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700379 */
RoboErik9734df52011-06-09 14:11:25 -0700380 public static final String OWNER_ACCOUNT = "ownerAccount";
Fred Quintana328c0e72009-12-07 14:52:28 -0800381
382 /**
RoboErik9734df52011-06-09 14:11:25 -0700383 * Can the organizer respond to the event? If no, the status of the
384 * organizer should not be shown by the UI. Defaults to 1. Column name.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700385 * <P>Type: INTEGER (boolean)</P>
Fred Quintana328c0e72009-12-07 14:52:28 -0800386 */
RoboErik9734df52011-06-09 14:11:25 -0700387 public static final String CAN_ORGANIZER_RESPOND = "canOrganizerRespond";
388
389 /**
390 * Can the organizer modify the time zone of the event? Column name.
391 * <P>Type: INTEGER (boolean)</P>
392 */
393 public static final String CAN_MODIFY_TIME_ZONE = "canModifyTimeZone";
394
395 /**
396 * The maximum number of reminders allowed for an event. Column name.
397 * <P>Type: INTEGER</P>
398 */
399 public static final String MAX_REMINDERS = "maxReminders";
400
401 /**
402 * A comma separated list of reminder methods supported for this
403 * calendar in the format "#,#,#". Valid types are
404 * {@link Reminders#METHOD_DEFAULT}, {@link Reminders#METHOD_ALERT},
Alon Albertbd251612012-02-23 10:30:51 -0800405 * {@link Reminders#METHOD_EMAIL}, {@link Reminders#METHOD_SMS},
406 * {@link Reminders#METHOD_ALARM}. Column name.
RoboErik9734df52011-06-09 14:11:25 -0700407 * <P>Type: TEXT</P>
408 */
409 public static final String ALLOWED_REMINDERS = "allowedReminders";
RoboErikf8143c52011-09-28 15:16:00 -0700410
411 /**
412 * A comma separated list of availability types supported for this
413 * calendar in the format "#,#,#". Valid types are
414 * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE},
415 * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only
416 * {@link Events#AVAILABILITY_BUSY} should be used to indicate that
417 * changing the availability is not supported.
418 *
RoboErikf8143c52011-09-28 15:16:00 -0700419 */
420 public static final String ALLOWED_AVAILABILITY = "allowedAvailability";
421
422 /**
423 * A comma separated list of attendee types supported for this calendar
424 * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE},
425 * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED},
426 * {@link Attendees#TYPE_RESOURCE}. Setting this field to only
427 * {@link Attendees#TYPE_NONE} should be used to indicate that changing
428 * the attendee type is not supported.
429 *
RoboErikf8143c52011-09-28 15:16:00 -0700430 */
431 public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 }
433
434 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700435 * Class that represents a Calendar Entity. There is one entry per calendar.
RoboErikc2d53302011-06-03 09:37:58 -0700436 * This is a helper class to make batch operations easier.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700437 */
RoboErik36726962011-06-14 14:01:15 -0700438 public static final class CalendarEntity implements BaseColumns, SyncColumns, CalendarColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700439
RoboErikc2d53302011-06-03 09:37:58 -0700440 /**
441 * The default Uri used when creating a new calendar EntityIterator.
442 */
443 @SuppressWarnings("hiding")
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700444 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
445 "/calendar_entities");
446
RoboErikc2d53302011-06-03 09:37:58 -0700447 /**
RoboErik36726962011-06-14 14:01:15 -0700448 * This utility class cannot be instantiated
449 */
450 private CalendarEntity() {}
451
452 /**
RoboErikc2d53302011-06-03 09:37:58 -0700453 * Creates an entity iterator for the given cursor. It assumes the
454 * cursor contains a calendars query.
455 *
456 * @param cursor query on {@link #CONTENT_URI}
457 * @return an EntityIterator of calendars
458 */
459 public static EntityIterator newEntityIterator(Cursor cursor) {
460 return new EntityIteratorImpl(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700461 }
462
463 private static class EntityIteratorImpl extends CursorEntityIterator {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700464
RoboErikc2d53302011-06-03 09:37:58 -0700465 public EntityIteratorImpl(Cursor cursor) {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700466 super(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700467 }
468
469 @Override
470 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
471 // we expect the cursor is already at the row we need to read from
472 final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
473
474 // Create the content value
475 ContentValues cv = new ContentValues();
476 cv.put(_ID, calendarId);
477
RoboErik651c02e2011-05-05 15:14:31 -0700478 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
479 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700480
481 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -0700482 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700483
RoboErik9734df52011-06-09 14:11:25 -0700484 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
485 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
486 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
487 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
488 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
489 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
490 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
491 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
492 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
493 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700494
495 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME);
496 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
RoboErik9734df52011-06-09 14:11:25 -0700497 Calendars.CALENDAR_DISPLAY_NAME);
Alon Albert866f40a2011-06-06 14:04:00 -0700498 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
499 Calendars.CALENDAR_COLOR);
RoboErik9734df52011-06-09 14:11:25 -0700500 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL);
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700501 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700502 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS);
RoboErik651c02e2011-05-05 15:14:31 -0700503 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
504 Calendars.CALENDAR_LOCATION);
RoboErik9734df52011-06-09 14:11:25 -0700505 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700506 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
507 Calendars.OWNER_ACCOUNT);
508 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700509 Calendars.CAN_ORGANIZER_RESPOND);
510 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
511 Calendars.CAN_MODIFY_TIME_ZONE);
512 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
513 Calendars.MAX_REMINDERS);
Alon Albert866f40a2011-06-06 14:04:00 -0700514 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
515 Calendars.CAN_PARTIALLY_UPDATE);
RoboErik9734df52011-06-09 14:11:25 -0700516 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
517 Calendars.ALLOWED_REMINDERS);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700518
519 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
520
521 // Create the Entity from the ContentValue
522 Entity entity = new Entity(cv);
523
524 // Set cursor to next row
525 cursor.moveToNext();
526
527 // Return the created Entity
528 return entity;
529 }
530 }
531 }
532
533 /**
RoboErikf4010c52011-06-17 11:04:26 -0700534 * Constants and helpers for the Calendars table, which contains details for
535 * individual calendars. <h3>Operations</h3> All operations can be done
536 * either as an app or as a sync adapter. To perform an operation as a sync
537 * adapter {@link #CALLER_IS_SYNCADAPTER} should be set to true and
538 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
539 * parameters. See
540 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
541 * for details on adding parameters. Sync adapters have write access to more
542 * columns but are restricted to a single account at a time. Calendars are
543 * designed to be primarily managed by a sync adapter and inserting new
544 * calendars should be done as a sync adapter. For the most part, apps
545 * should only update calendars (such as changing the color or display
546 * name). If a local calendar is required an app can do so by inserting as a
547 * sync adapter and using an {@link #ACCOUNT_TYPE} of
548 * {@link #ACCOUNT_TYPE_LOCAL} .
549 * <dl>
550 * <dt><b>Insert</b></dt>
551 * <dd>When inserting a new calendar the following fields must be included:
552 * <ul>
553 * <li>{@link #ACCOUNT_NAME}</li>
554 * <li>{@link #ACCOUNT_TYPE}</li>
555 * <li>{@link #NAME}</li>
556 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
557 * <li>{@link #CALENDAR_COLOR}</li>
558 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
559 * <li>{@link #OWNER_ACCOUNT}</li>
560 * </ul>
561 * The following fields are not required when inserting a Calendar but are
562 * generally a good idea to include:
563 * <ul>
564 * <li>{@link #SYNC_EVENTS} set to 1</li>
RoboErikf92ccfb2011-06-17 15:24:02 -0700565 * <li>{@link #CALENDAR_TIME_ZONE}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700566 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700567 * <li>{@link #ALLOWED_AVAILABILITY}</li>
568 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700569 * </ul>
570 * <dt><b>Update</b></dt>
571 * <dd>To perform an update on a calendar the {@link #_ID} of the calendar
572 * should be provided either as an appended id to the Uri (
573 * {@link ContentUris#withAppendedId}) or as the first selection item--the
574 * selection should start with "_id=?" and the first selectionArg should be
575 * the _id of the calendar. Calendars may also be updated using a selection
576 * without the id. In general, the {@link #ACCOUNT_NAME} and
577 * {@link #ACCOUNT_TYPE} should not be changed after a calendar is created
578 * as this can cause issues for sync adapters.
579 * <dt><b>Delete</b></dt>
580 * <dd>Calendars can be deleted either by the {@link #_ID} as an appended id
581 * on the Uri or using any standard selection. Deleting a calendar should
582 * generally be handled by a sync adapter as it will remove the calendar
583 * from the database and all associated data (aka events).</dd>
584 * <dt><b>Query</b></dt>
585 * <dd>Querying the Calendars table will get you all information about a set
586 * of calendars. There will be one row returned for each calendar that
587 * matches the query selection, or at most a single row if the {@link #_ID}
588 * is appended to the Uri.</dd>
589 * </dl>
590 * <h3>Calendar Columns</h3> The following Calendar columns are writable by
591 * both an app and a sync adapter.
592 * <ul>
593 * <li>{@link #NAME}</li>
594 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700595 * <li>{@link #VISIBLE}</li>
596 * <li>{@link #SYNC_EVENTS}</li>
597 * </ul>
598 * The following Calendars columns are writable only by a sync adapter
599 * <ul>
600 * <li>{@link #ACCOUNT_NAME}</li>
601 * <li>{@link #ACCOUNT_TYPE}</li>
RoboErik4f520612011-09-19 17:47:53 -0700602 * <li>{@link #CALENDAR_COLOR}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700603 * <li>{@link #_SYNC_ID}</li>
604 * <li>{@link #DIRTY}</li>
605 * <li>{@link #OWNER_ACCOUNT}</li>
606 * <li>{@link #MAX_REMINDERS}</li>
607 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700608 * <li>{@link #ALLOWED_AVAILABILITY}</li>
609 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700610 * <li>{@link #CAN_MODIFY_TIME_ZONE}</li>
611 * <li>{@link #CAN_ORGANIZER_RESPOND}</li>
612 * <li>{@link #CAN_PARTIALLY_UPDATE}</li>
613 * <li>{@link #CALENDAR_LOCATION}</li>
614 * <li>{@link #CALENDAR_TIME_ZONE}</li>
615 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
616 * <li>{@link #DELETED}</li>
617 * <li>{@link #CAL_SYNC1}</li>
618 * <li>{@link #CAL_SYNC2}</li>
619 * <li>{@link #CAL_SYNC3}</li>
620 * <li>{@link #CAL_SYNC4}</li>
621 * <li>{@link #CAL_SYNC5}</li>
622 * <li>{@link #CAL_SYNC6}</li>
623 * <li>{@link #CAL_SYNC7}</li>
624 * <li>{@link #CAL_SYNC8}</li>
625 * <li>{@link #CAL_SYNC9}</li>
626 * <li>{@link #CAL_SYNC10}</li>
627 * </ul>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800628 */
RoboErik36726962011-06-14 14:01:15 -0700629 public static final class Calendars implements BaseColumns, SyncColumns, CalendarColumns {
630
631 /**
632 * This utility class cannot be instantiated
633 */
634 private Calendars() {}
635
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 /**
RoboErikc2d53302011-06-03 09:37:58 -0700637 * The content:// style URL for accessing Calendars
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800638 */
RoboErikc2d53302011-06-03 09:37:58 -0700639 @SuppressWarnings("hiding")
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800640 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/calendars");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800641
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800642 /**
643 * The default sort order for this table
644 */
Michael Chane5e02502011-09-01 10:46:14 -0700645 public static final String DEFAULT_SORT_ORDER = CALENDAR_DISPLAY_NAME;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800646
647 /**
RoboErikc2d53302011-06-03 09:37:58 -0700648 * The name of the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800649 * <P>Type: TEXT</P>
650 */
651 public static final String NAME = "name";
652
653 /**
RoboErikc2d53302011-06-03 09:37:58 -0700654 * The default location for the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800655 * <P>Type: TEXT</P>
656 */
RoboErik651c02e2011-05-05 15:14:31 -0700657 public static final String CALENDAR_LOCATION = "calendar_location";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800658
659 /**
RoboErik6efb30f2011-05-05 10:11:47 -0700660 * These fields are only writable by a sync adapter. To modify them the
RoboErikc2d53302011-06-03 09:37:58 -0700661 * caller must include {@link #CALLER_IS_SYNCADAPTER},
RoboErik9734df52011-06-09 14:11:25 -0700662 * {@link #ACCOUNT_NAME}, and {@link #ACCOUNT_TYPE} in the Uri's query
RoboErik083cd2d2011-06-30 11:53:05 -0700663 * parameters. TODO move to provider
664 *
665 * @hide
RoboErik6efb30f2011-05-05 10:11:47 -0700666 */
667 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
RoboErik651c02e2011-05-05 15:14:31 -0700668 ACCOUNT_NAME,
669 ACCOUNT_TYPE,
RoboErik6efb30f2011-05-05 10:11:47 -0700670 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -0700671 DIRTY,
RoboErik6efb30f2011-05-05 10:11:47 -0700672 OWNER_ACCOUNT,
673 MAX_REMINDERS,
RoboErikf4010c52011-06-17 11:04:26 -0700674 ALLOWED_REMINDERS,
RoboErik6efb30f2011-05-05 10:11:47 -0700675 CAN_MODIFY_TIME_ZONE,
676 CAN_ORGANIZER_RESPOND,
Alon Albert866f40a2011-06-06 14:04:00 -0700677 CAN_PARTIALLY_UPDATE,
RoboErik651c02e2011-05-05 15:14:31 -0700678 CALENDAR_LOCATION,
RoboErik9734df52011-06-09 14:11:25 -0700679 CALENDAR_TIME_ZONE,
680 CALENDAR_ACCESS_LEVEL,
RoboErik6efb30f2011-05-05 10:11:47 -0700681 DELETED,
RoboErikbe010392011-05-26 12:28:38 -0700682 CAL_SYNC1,
683 CAL_SYNC2,
684 CAL_SYNC3,
685 CAL_SYNC4,
RoboErikc2d53302011-06-03 09:37:58 -0700686 CAL_SYNC5,
687 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -0700688 CAL_SYNC7,
689 CAL_SYNC8,
690 CAL_SYNC9,
691 CAL_SYNC10,
RoboErik6efb30f2011-05-05 10:11:47 -0700692 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800693 }
694
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700695 /**
696 * Columns from the Attendees table that other tables join into themselves.
697 */
RoboErikb2c75602011-06-13 12:53:48 -0700698 protected interface AttendeesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800699
700 /**
RoboErikc2d53302011-06-03 09:37:58 -0700701 * The id of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 * <P>Type: INTEGER</P>
703 */
704 public static final String EVENT_ID = "event_id";
705
706 /**
RoboErikc2d53302011-06-03 09:37:58 -0700707 * The name of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800708 * <P>Type: STRING</P>
709 */
710 public static final String ATTENDEE_NAME = "attendeeName";
711
712 /**
RoboErikc2d53302011-06-03 09:37:58 -0700713 * The email address of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800714 * <P>Type: STRING</P>
715 */
716 public static final String ATTENDEE_EMAIL = "attendeeEmail";
717
718 /**
RoboErikc2d53302011-06-03 09:37:58 -0700719 * The relationship of the attendee to the user. Column name.
720 * <P>Type: INTEGER (one of {@link #RELATIONSHIP_ATTENDEE}, ...}.</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800721 */
722 public static final String ATTENDEE_RELATIONSHIP = "attendeeRelationship";
723
724 public static final int RELATIONSHIP_NONE = 0;
725 public static final int RELATIONSHIP_ATTENDEE = 1;
726 public static final int RELATIONSHIP_ORGANIZER = 2;
727 public static final int RELATIONSHIP_PERFORMER = 3;
728 public static final int RELATIONSHIP_SPEAKER = 4;
729
730 /**
RoboErikc2d53302011-06-03 09:37:58 -0700731 * The type of attendee. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700732 * <P>
RoboErik4172d952011-10-25 13:59:13 -0700733 * Type: Integer (one of {@link #TYPE_NONE}, {@link #TYPE_REQUIRED},
734 * {@link #TYPE_OPTIONAL}, {@link #TYPE_RESOURCE})
RoboErikf8143c52011-09-28 15:16:00 -0700735 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736 */
737 public static final String ATTENDEE_TYPE = "attendeeType";
738
739 public static final int TYPE_NONE = 0;
740 public static final int TYPE_REQUIRED = 1;
741 public static final int TYPE_OPTIONAL = 2;
RoboErikf8143c52011-09-28 15:16:00 -0700742 /**
RoboErik4172d952011-10-25 13:59:13 -0700743 * This specifies that an attendee is a resource, like a room, a
744 * cabbage, or something and not an actual person.
RoboErikf8143c52011-09-28 15:16:00 -0700745 */
746 public static final int TYPE_RESOURCE = 3;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800747
748 /**
RoboErikc2d53302011-06-03 09:37:58 -0700749 * The attendance status of the attendee. Column name.
750 * <P>Type: Integer (one of {@link #ATTENDEE_STATUS_ACCEPTED}, ...).</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751 */
752 public static final String ATTENDEE_STATUS = "attendeeStatus";
753
754 public static final int ATTENDEE_STATUS_NONE = 0;
755 public static final int ATTENDEE_STATUS_ACCEPTED = 1;
756 public static final int ATTENDEE_STATUS_DECLINED = 2;
757 public static final int ATTENDEE_STATUS_INVITED = 3;
758 public static final int ATTENDEE_STATUS_TENTATIVE = 4;
759 }
760
RoboErikc2d53302011-06-03 09:37:58 -0700761 /**
RoboErik3771fcb2011-06-16 15:41:31 -0700762 * Fields and helpers for interacting with Attendees. Each row of this table
763 * represents a single attendee or guest of an event. Calling
RoboErik58644022011-07-08 13:39:05 -0700764 * {@link #query(ContentResolver, long, String[])} will return a list of attendees for
RoboErik3771fcb2011-06-16 15:41:31 -0700765 * the event with the given eventId. Both apps and sync adapters may write
766 * to this table. There are six writable fields and all of them except
767 * {@link #ATTENDEE_NAME} must be included when inserting a new attendee.
768 * They are:
769 * <ul>
770 * <li>{@link #EVENT_ID}</li>
771 * <li>{@link #ATTENDEE_NAME}</li>
772 * <li>{@link #ATTENDEE_EMAIL}</li>
773 * <li>{@link #ATTENDEE_RELATIONSHIP}</li>
774 * <li>{@link #ATTENDEE_TYPE}</li>
775 * <li>{@link #ATTENDEE_STATUS}</li>
776 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -0700777 */
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800778 public static final class Attendees implements BaseColumns, AttendeesColumns, EventsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800779
RoboErikc2d53302011-06-03 09:37:58 -0700780 /**
781 * The content:// style URL for accessing Attendees data
782 */
783 @SuppressWarnings("hiding")
784 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees");
RoboErikc2d53302011-06-03 09:37:58 -0700785 private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?";
786
787 /**
RoboErik36726962011-06-14 14:01:15 -0700788 * This utility class cannot be instantiated
789 */
790 private Attendees() {}
791
792 /**
RoboErikc2d53302011-06-03 09:37:58 -0700793 * Queries all attendees associated with the given event. This is a
794 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -0700795 *
RoboErikc2d53302011-06-03 09:37:58 -0700796 * @param cr The content resolver to use for the query
797 * @param eventId The id of the event to retrieve attendees for
RoboErik58644022011-07-08 13:39:05 -0700798 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -0700799 * @return A Cursor containing all attendees for the event
800 */
RoboErik58644022011-07-08 13:39:05 -0700801 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -0700802 String[] attArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -0700803 return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */,
RoboErikc2d53302011-06-03 09:37:58 -0700804 null /* sort order */);
805 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800806 }
807
808 /**
809 * Columns from the Events table that other tables join into themselves.
810 */
RoboErikb2c75602011-06-13 12:53:48 -0700811 protected interface EventsColumns {
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700812
813 /**
RoboErikc2d53302011-06-03 09:37:58 -0700814 * The {@link Calendars#_ID} of the calendar the event belongs to.
815 * Column name.
816 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800817 */
818 public static final String CALENDAR_ID = "calendar_id";
819
820 /**
RoboErikc2d53302011-06-03 09:37:58 -0700821 * The title of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800822 * <P>Type: TEXT</P>
823 */
824 public static final String TITLE = "title";
825
826 /**
RoboErikc2d53302011-06-03 09:37:58 -0700827 * The description of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800828 * <P>Type: TEXT</P>
829 */
830 public static final String DESCRIPTION = "description";
831
832 /**
RoboErikc2d53302011-06-03 09:37:58 -0700833 * Where the event takes place. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800834 * <P>Type: TEXT</P>
835 */
836 public static final String EVENT_LOCATION = "eventLocation";
837
838 /**
RoboErikf8143c52011-09-28 15:16:00 -0700839 * A secondary color for the individual event. This should only be
840 * updated by the sync adapter for a given account.
RoboErik9734df52011-06-09 14:11:25 -0700841 * <P>Type: INTEGER</P>
842 */
843 public static final String EVENT_COLOR = "eventColor";
844
845 /**
RoboErik4172d952011-10-25 13:59:13 -0700846 * A secondary color key for the individual event. NULL or an empty
847 * string are reserved for indicating that the event does not use a key
848 * for looking up the color. The provider will update
849 * {@link #EVENT_COLOR} automatically when a valid key is written to
850 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -0700851 * {@link Colors} table. @see Colors
852 * <P>
853 * Type: TEXT
854 * </P>
RoboErikf8143c52011-09-28 15:16:00 -0700855 */
RoboErik4172d952011-10-25 13:59:13 -0700856 public static final String EVENT_COLOR_KEY = "eventColor_index";
RoboErikf8143c52011-09-28 15:16:00 -0700857
858 /**
Alon Albertdc927302012-03-01 16:05:55 -0800859 * This will be {@link #EVENT_COLOR} if it is not null; otherwise, this will be
860 * {@link Calendars#CALENDAR_COLOR}.
861 * Read-only value. To modify, write to {@link #EVENT_COLOR} or
862 * {@link Calendars#CALENDAR_COLOR} directly.
863 *<P>
864 * Type: INTEGER
865 *</P>
866 */
867 public static final String DISPLAY_COLOR = "displayColor";
868
869 /**
RoboErikc2d53302011-06-03 09:37:58 -0700870 * The event status. Column name.
871 * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800872 */
873 public static final String STATUS = "eventStatus";
874
875 public static final int STATUS_TENTATIVE = 0;
876 public static final int STATUS_CONFIRMED = 1;
877 public static final int STATUS_CANCELED = 2;
878
879 /**
880 * This is a copy of the attendee status for the owner of this event.
881 * This field is copied here so that we can efficiently filter out
882 * events that are declined without having to look in the Attendees
RoboErikc2d53302011-06-03 09:37:58 -0700883 * table. Column name.
Ken Shirriff5b387e12009-10-23 09:50:41 -0700884 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800885 * <P>Type: INTEGER (int)</P>
886 */
887 public static final String SELF_ATTENDEE_STATUS = "selfAttendeeStatus";
Ken Shirriff5b387e12009-10-23 09:50:41 -0700888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 /**
RoboErikc2d53302011-06-03 09:37:58 -0700890 * This column is available for use by sync adapters. Column name.
Marc Blank64a556d2010-02-25 12:53:16 -0800891 * <P>Type: TEXT</P>
892 */
RoboErik651c02e2011-05-05 15:14:31 -0700893 public static final String SYNC_DATA1 = "sync_data1";
Marc Blank64a556d2010-02-25 12:53:16 -0800894
895 /**
RoboErik9734df52011-06-09 14:11:25 -0700896 * This column is available for use by sync adapters. Column name.
897 * <P>Type: TEXT</P>
898 */
899 public static final String SYNC_DATA2 = "sync_data2";
900
901 /**
902 * This column is available for use by sync adapters. Column name.
903 * <P>Type: TEXT</P>
904 */
905 public static final String SYNC_DATA3 = "sync_data3";
906
907 /**
908 * This column is available for use by sync adapters. Column name.
909 * <P>Type: TEXT</P>
910 */
911 public static final String SYNC_DATA4 = "sync_data4";
912
913 /**
914 * This column is available for use by sync adapters. Column name.
915 * <P>Type: TEXT</P>
916 */
917 public static final String SYNC_DATA5 = "sync_data5";
918
919 /**
920 * This column is available for use by sync adapters. Column name.
921 * <P>Type: TEXT</P>
922 */
923 public static final String SYNC_DATA6 = "sync_data6";
924
925 /**
926 * This column is available for use by sync adapters. Column name.
Alon Albert866f40a2011-06-06 14:04:00 -0700927 * <P>Type: TEXT</P>
928 */
929 public static final String SYNC_DATA7 = "sync_data7";
930
931 /**
RoboErik9734df52011-06-09 14:11:25 -0700932 * This column is available for use by sync adapters. Column name.
933 * <P>Type: TEXT</P>
934 */
935 public static final String SYNC_DATA8 = "sync_data8";
936
937 /**
938 * This column is available for use by sync adapters. Column name.
939 * <P>Type: TEXT</P>
940 */
941 public static final String SYNC_DATA9 = "sync_data9";
942
943 /**
944 * This column is available for use by sync adapters. Column name.
945 * <P>Type: TEXT</P>
946 */
947 public static final String SYNC_DATA10 = "sync_data10";
948
949 /**
Alon Albert866f40a2011-06-06 14:04:00 -0700950 * Used to indicate that a row is not a real event but an original copy of a locally
951 * modified event. A copy is made when an event changes from non-dirty to dirty and the
952 * event is on a calendar with {@link Calendars#CAN_PARTIALLY_UPDATE} set to 1. This copy
953 * does not get expanded in the instances table and is only visible in queries made by a
954 * sync adapter. The copy gets removed when the event is changed back to non-dirty by a
955 * sync adapter.
956 * <P>Type: INTEGER (boolean)</P>
957 */
958 public static final String LAST_SYNCED = "lastSynced";
959
960 /**
RoboErikc2d53302011-06-03 09:37:58 -0700961 * The time the event starts in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 * <P>Type: INTEGER (long; millis since epoch)</P>
963 */
964 public static final String DTSTART = "dtstart";
965
966 /**
RoboErikc2d53302011-06-03 09:37:58 -0700967 * The time the event ends in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800968 * <P>Type: INTEGER (long; millis since epoch)</P>
969 */
970 public static final String DTEND = "dtend";
971
972 /**
RoboErikc2d53302011-06-03 09:37:58 -0700973 * The duration of the event in RFC2445 format. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800974 * <P>Type: TEXT (duration in RFC2445 format)</P>
975 */
976 public static final String DURATION = "duration";
977
978 /**
RoboErikc2d53302011-06-03 09:37:58 -0700979 * The timezone for the event. Column name.
980 * <P>Type: TEXT</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800981 */
982 public static final String EVENT_TIMEZONE = "eventTimezone";
983
984 /**
RoboErikc2d53302011-06-03 09:37:58 -0700985 * The timezone for the end time of the event. Column name.
986 * <P>Type: TEXT</P>
Erikc07b06f2010-05-03 11:37:31 -0700987 */
RoboErik651c02e2011-05-05 15:14:31 -0700988 public static final String EVENT_END_TIMEZONE = "eventEndTimezone";
Erikc07b06f2010-05-03 11:37:31 -0700989
990 /**
RoboErikc2d53302011-06-03 09:37:58 -0700991 * Is the event all day (time zone independent). Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800992 * <P>Type: INTEGER (boolean)</P>
993 */
994 public static final String ALL_DAY = "allDay";
995
996 /**
RoboErik651c02e2011-05-05 15:14:31 -0700997 * Defines how the event shows up for others when the calendar is
RoboErikc2d53302011-06-03 09:37:58 -0700998 * shared. Column name.
999 * <P>Type: INTEGER (One of {@link #ACCESS_DEFAULT}, ...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001000 */
RoboErik651c02e2011-05-05 15:14:31 -07001001 public static final String ACCESS_LEVEL = "accessLevel";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002
1003 /**
RoboErik651c02e2011-05-05 15:14:31 -07001004 * Default access is controlled by the server and will be treated as
1005 * public on the device.
1006 */
1007 public static final int ACCESS_DEFAULT = 0;
1008 /**
1009 * Confidential is not used by the app.
1010 */
1011 public static final int ACCESS_CONFIDENTIAL = 1;
1012 /**
RoboErikc2d53302011-06-03 09:37:58 -07001013 * Private shares the event as a free/busy slot with no details.
RoboErik651c02e2011-05-05 15:14:31 -07001014 */
1015 public static final int ACCESS_PRIVATE = 2;
1016 /**
RoboErikc2d53302011-06-03 09:37:58 -07001017 * Public makes the contents visible to anyone with access to the
RoboErik651c02e2011-05-05 15:14:31 -07001018 * calendar.
1019 */
1020 public static final int ACCESS_PUBLIC = 3;
1021
1022 /**
1023 * If this event counts as busy time or is still free time that can be
RoboErikc2d53302011-06-03 09:37:58 -07001024 * scheduled over. Column name.
RoboErik4172d952011-10-25 13:59:13 -07001025 * <P>
1026 * Type: INTEGER (One of {@link #AVAILABILITY_BUSY},
1027 * {@link #AVAILABILITY_FREE}, {@link #AVAILABILITY_TENTATIVE})
1028 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029 */
RoboErik651c02e2011-05-05 15:14:31 -07001030 public static final String AVAILABILITY = "availability";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001031
RoboErik651c02e2011-05-05 15:14:31 -07001032 /**
1033 * Indicates that this event takes up time and will conflict with other
1034 * events.
1035 */
1036 public static final int AVAILABILITY_BUSY = 0;
1037 /**
1038 * Indicates that this event is free time and will not conflict with
1039 * other events.
1040 */
1041 public static final int AVAILABILITY_FREE = 1;
RoboErikf8143c52011-09-28 15:16:00 -07001042 /**
1043 * Indicates that the owner's availability may change, but should be
1044 * considered busy time that will conflict.
RoboErikf8143c52011-09-28 15:16:00 -07001045 */
1046 public static final int AVAILABILITY_TENTATIVE = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001047
1048 /**
RoboErikc2d53302011-06-03 09:37:58 -07001049 * Whether the event has an alarm or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050 * <P>Type: INTEGER (boolean)</P>
1051 */
1052 public static final String HAS_ALARM = "hasAlarm";
1053
1054 /**
RoboErikc2d53302011-06-03 09:37:58 -07001055 * Whether the event has extended properties or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 * <P>Type: INTEGER (boolean)</P>
1057 */
1058 public static final String HAS_EXTENDED_PROPERTIES = "hasExtendedProperties";
1059
1060 /**
RoboErikc2d53302011-06-03 09:37:58 -07001061 * The recurrence rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001062 * <P>Type: TEXT</P>
1063 */
1064 public static final String RRULE = "rrule";
1065
1066 /**
RoboErikc2d53302011-06-03 09:37:58 -07001067 * The recurrence dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068 * <P>Type: TEXT</P>
1069 */
1070 public static final String RDATE = "rdate";
1071
1072 /**
RoboErikc2d53302011-06-03 09:37:58 -07001073 * The recurrence exception rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001074 * <P>Type: TEXT</P>
1075 */
1076 public static final String EXRULE = "exrule";
1077
1078 /**
RoboErikc2d53302011-06-03 09:37:58 -07001079 * The recurrence exception dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001080 * <P>Type: TEXT</P>
1081 */
1082 public static final String EXDATE = "exdate";
1083
1084 /**
RoboErikc2d53302011-06-03 09:37:58 -07001085 * The {@link Events#_ID} of the original recurring event for which this
1086 * event is an exception. Column name.
RoboErikc0bd9bc2011-05-13 17:54:24 -07001087 * <P>Type: TEXT</P>
1088 */
1089 public static final String ORIGINAL_ID = "original_id";
1090
1091 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001092 * The _sync_id of the original recurring event for which this event is
RoboErikc0bd9bc2011-05-13 17:54:24 -07001093 * an exception. The provider should keep the original_id in sync when
RoboErikc2d53302011-06-03 09:37:58 -07001094 * this is updated. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001095 * <P>Type: TEXT</P>
1096 */
RoboErik651c02e2011-05-05 15:14:31 -07001097 public static final String ORIGINAL_SYNC_ID = "original_sync_id";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001098
1099 /**
1100 * The original instance time of the recurring event for which this
RoboErikc2d53302011-06-03 09:37:58 -07001101 * event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001102 * <P>Type: INTEGER (long; millis since epoch)</P>
1103 */
1104 public static final String ORIGINAL_INSTANCE_TIME = "originalInstanceTime";
1105
1106 /**
1107 * The allDay status (true or false) of the original recurring event
RoboErikc2d53302011-06-03 09:37:58 -07001108 * for which this event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001109 * <P>Type: INTEGER (boolean)</P>
1110 */
1111 public static final String ORIGINAL_ALL_DAY = "originalAllDay";
1112
1113 /**
RoboErikc2d53302011-06-03 09:37:58 -07001114 * The last date this event repeats on, or NULL if it never ends. Column
1115 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001116 * <P>Type: INTEGER (long; millis since epoch)</P>
1117 */
1118 public static final String LAST_DATE = "lastDate";
Ken Shirriff79f0c562009-08-05 13:29:42 -07001119
1120 /**
1121 * Whether the event has attendee information. True if the event
1122 * has full attendee data, false if the event has information about
RoboErikc2d53302011-06-03 09:37:58 -07001123 * self only. Column name.
Ken Shirriff79f0c562009-08-05 13:29:42 -07001124 * <P>Type: INTEGER (boolean)</P>
1125 */
1126 public static final String HAS_ATTENDEE_DATA = "hasAttendeeData";
Ken Shirriff3d037072009-08-17 15:43:21 -07001127
1128 /**
RoboErikc2d53302011-06-03 09:37:58 -07001129 * Whether guests can modify the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001130 * <P>Type: INTEGER (boolean)</P>
1131 */
1132 public static final String GUESTS_CAN_MODIFY = "guestsCanModify";
1133
1134 /**
RoboErikc2d53302011-06-03 09:37:58 -07001135 * Whether guests can invite other guests. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001136 * <P>Type: INTEGER (boolean)</P>
1137 */
1138 public static final String GUESTS_CAN_INVITE_OTHERS = "guestsCanInviteOthers";
1139
1140 /**
RoboErikc2d53302011-06-03 09:37:58 -07001141 * Whether guests can see the list of attendees. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001142 * <P>Type: INTEGER (boolean)</P>
1143 */
1144 public static final String GUESTS_CAN_SEE_GUESTS = "guestsCanSeeGuests";
1145
1146 /**
RoboErikc2d53302011-06-03 09:37:58 -07001147 * Email of the organizer (owner) of the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001148 * <P>Type: STRING</P>
1149 */
1150 public static final String ORGANIZER = "organizer";
1151
1152 /**
RoboErikc2d53302011-06-03 09:37:58 -07001153 * Whether the user can invite others to the event. The
1154 * GUESTS_CAN_INVITE_OTHERS is a setting that applies to an arbitrary
1155 * guest, while CAN_INVITE_OTHERS indicates if the user can invite
1156 * others (either through GUESTS_CAN_INVITE_OTHERS or because the user
1157 * has modify access to the event). Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001158 * <P>Type: INTEGER (boolean, readonly)</P>
1159 */
1160 public static final String CAN_INVITE_OTHERS = "canInviteOthers";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001161 }
1162
1163 /**
RoboErikc2d53302011-06-03 09:37:58 -07001164 * Class that represents an Event Entity. There is one entry per event.
1165 * Recurring events show up as a single entry. This is a helper class to
1166 * make batch operations easier. A {@link ContentResolver} or
1167 * {@link ContentProviderClient} is required as the helper does additional
1168 * queries to add reminders and attendees to each entry.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001169 */
RoboErik651c02e2011-05-05 15:14:31 -07001170 public static final class EventsEntity implements BaseColumns, SyncColumns, EventsColumns {
Fred Quintana328c0e72009-12-07 14:52:28 -08001171 /**
1172 * The content:// style URL for this table
1173 */
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001174 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1175 "/event_entities");
Fred Quintana328c0e72009-12-07 14:52:28 -08001176
RoboErikc2d53302011-06-03 09:37:58 -07001177 /**
RoboErik36726962011-06-14 14:01:15 -07001178 * This utility class cannot be instantiated
1179 */
1180 private EventsEntity() {}
1181
1182 /**
RoboErikc2d53302011-06-03 09:37:58 -07001183 * Creates a new iterator for events
1184 *
1185 * @param cursor An event query
1186 * @param resolver For performing additional queries
1187 * @return an EntityIterator containing one entity per event in the
1188 * cursor
1189 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001190 public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) {
1191 return new EntityIteratorImpl(cursor, resolver);
1192 }
1193
RoboErikc2d53302011-06-03 09:37:58 -07001194 /**
1195 * Creates a new iterator for events
1196 *
1197 * @param cursor An event query
1198 * @param provider For performing additional queries
1199 * @return an EntityIterator containing one entity per event in the
1200 * cursor
1201 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001202 public static EntityIterator newEntityIterator(Cursor cursor,
1203 ContentProviderClient provider) {
1204 return new EntityIteratorImpl(cursor, provider);
1205 }
1206
1207 private static class EntityIteratorImpl extends CursorEntityIterator {
1208 private final ContentResolver mResolver;
1209 private final ContentProviderClient mProvider;
1210
1211 private static final String[] REMINDERS_PROJECTION = new String[] {
1212 Reminders.MINUTES,
1213 Reminders.METHOD,
1214 };
1215 private static final int COLUMN_MINUTES = 0;
1216 private static final int COLUMN_METHOD = 1;
1217
1218 private static final String[] ATTENDEES_PROJECTION = new String[] {
1219 Attendees.ATTENDEE_NAME,
1220 Attendees.ATTENDEE_EMAIL,
1221 Attendees.ATTENDEE_RELATIONSHIP,
1222 Attendees.ATTENDEE_TYPE,
1223 Attendees.ATTENDEE_STATUS,
1224 };
1225 private static final int COLUMN_ATTENDEE_NAME = 0;
1226 private static final int COLUMN_ATTENDEE_EMAIL = 1;
1227 private static final int COLUMN_ATTENDEE_RELATIONSHIP = 2;
1228 private static final int COLUMN_ATTENDEE_TYPE = 3;
1229 private static final int COLUMN_ATTENDEE_STATUS = 4;
1230 private static final String[] EXTENDED_PROJECTION = new String[] {
Marc Blank8f643c12010-04-29 14:16:48 -07001231 ExtendedProperties._ID,
Fred Quintana328c0e72009-12-07 14:52:28 -08001232 ExtendedProperties.NAME,
Marc Blank8f643c12010-04-29 14:16:48 -07001233 ExtendedProperties.VALUE
Fred Quintana328c0e72009-12-07 14:52:28 -08001234 };
Marc Blank8f643c12010-04-29 14:16:48 -07001235 private static final int COLUMN_ID = 0;
1236 private static final int COLUMN_NAME = 1;
1237 private static final int COLUMN_VALUE = 2;
Fred Quintana328c0e72009-12-07 14:52:28 -08001238
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001239 private static final String WHERE_EVENT_ID = "event_id=?";
1240
Fred Quintana328c0e72009-12-07 14:52:28 -08001241 public EntityIteratorImpl(Cursor cursor, ContentResolver resolver) {
1242 super(cursor);
1243 mResolver = resolver;
1244 mProvider = null;
1245 }
1246
1247 public EntityIteratorImpl(Cursor cursor, ContentProviderClient provider) {
1248 super(cursor);
1249 mResolver = null;
1250 mProvider = provider;
1251 }
1252
Marc Blank64a556d2010-02-25 12:53:16 -08001253 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08001254 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
1255 // we expect the cursor is already at the row we need to read from
1256 final long eventId = cursor.getLong(cursor.getColumnIndexOrThrow(Events._ID));
1257 ContentValues cv = new ContentValues();
1258 cv.put(Events._ID, eventId);
1259 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001260 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, TITLE);
1261 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DESCRIPTION);
1262 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_LOCATION);
1263 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, STATUS);
1264 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SELF_ATTENDEE_STATUS);
Fred Quintana328c0e72009-12-07 14:52:28 -08001265 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTSTART);
1266 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTEND);
1267 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DURATION);
1268 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_TIMEZONE);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001269 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_END_TIMEZONE);
Fred Quintana328c0e72009-12-07 14:52:28 -08001270 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ALL_DAY);
RoboErik651c02e2011-05-05 15:14:31 -07001271 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL);
1272 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, AVAILABILITY);
Fred Quintana328c0e72009-12-07 14:52:28 -08001273 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, HAS_ALARM);
1274 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1275 HAS_EXTENDED_PROPERTIES);
1276 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RRULE);
1277 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RDATE);
1278 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXRULE);
1279 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXDATE);
RoboErik651c02e2011-05-05 15:14:31 -07001280 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_SYNC_ID);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001281 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001282 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
1283 ORIGINAL_INSTANCE_TIME);
1284 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ORIGINAL_ALL_DAY);
1285 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_DATE);
1286 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, HAS_ATTENDEE_DATA);
1287 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
1288 GUESTS_CAN_INVITE_OTHERS);
1289 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_MODIFY);
1290 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_SEE_GUESTS);
1291 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORGANIZER);
1292 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -07001293 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Alon Albert866f40a2011-06-06 14:04:00 -07001294 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED);
RoboErikc2d53302011-06-03 09:37:58 -07001295 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
RoboErik9734df52011-06-09 14:11:25 -07001296 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA1);
1297 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA2);
1298 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA3);
1299 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA4);
1300 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA5);
1301 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA6);
1302 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA7);
1303 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA8);
1304 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA9);
1305 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA10);
RoboErikbe010392011-05-26 12:28:38 -07001306 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
1307 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
1308 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
1309 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
1310 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
1311 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
RoboErik9734df52011-06-09 14:11:25 -07001312 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
1313 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
1314 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
1315 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fred Quintana328c0e72009-12-07 14:52:28 -08001316
1317 Entity entity = new Entity(cv);
1318 Cursor subCursor;
1319 if (mResolver != null) {
1320 subCursor = mResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001321 WHERE_EVENT_ID,
1322 new String[] { Long.toString(eventId) } /* selectionArgs */,
1323 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001324 } else {
1325 subCursor = mProvider.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001326 WHERE_EVENT_ID,
1327 new String[] { Long.toString(eventId) } /* selectionArgs */,
1328 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001329 }
1330 try {
1331 while (subCursor.moveToNext()) {
1332 ContentValues reminderValues = new ContentValues();
1333 reminderValues.put(Reminders.MINUTES, subCursor.getInt(COLUMN_MINUTES));
1334 reminderValues.put(Reminders.METHOD, subCursor.getInt(COLUMN_METHOD));
1335 entity.addSubValue(Reminders.CONTENT_URI, reminderValues);
1336 }
1337 } finally {
1338 subCursor.close();
1339 }
1340
1341 if (mResolver != null) {
1342 subCursor = mResolver.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001343 WHERE_EVENT_ID,
1344 new String[] { Long.toString(eventId) } /* selectionArgs */,
1345 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001346 } else {
1347 subCursor = mProvider.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001348 WHERE_EVENT_ID,
1349 new String[] { Long.toString(eventId) } /* selectionArgs */,
1350 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001351 }
1352 try {
1353 while (subCursor.moveToNext()) {
1354 ContentValues attendeeValues = new ContentValues();
1355 attendeeValues.put(Attendees.ATTENDEE_NAME,
1356 subCursor.getString(COLUMN_ATTENDEE_NAME));
1357 attendeeValues.put(Attendees.ATTENDEE_EMAIL,
1358 subCursor.getString(COLUMN_ATTENDEE_EMAIL));
1359 attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP,
1360 subCursor.getInt(COLUMN_ATTENDEE_RELATIONSHIP));
1361 attendeeValues.put(Attendees.ATTENDEE_TYPE,
1362 subCursor.getInt(COLUMN_ATTENDEE_TYPE));
1363 attendeeValues.put(Attendees.ATTENDEE_STATUS,
1364 subCursor.getInt(COLUMN_ATTENDEE_STATUS));
1365 entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);
1366 }
1367 } finally {
1368 subCursor.close();
1369 }
1370
1371 if (mResolver != null) {
1372 subCursor = mResolver.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001373 WHERE_EVENT_ID,
1374 new String[] { Long.toString(eventId) } /* selectionArgs */,
1375 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001376 } else {
1377 subCursor = mProvider.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001378 WHERE_EVENT_ID,
1379 new String[] { Long.toString(eventId) } /* selectionArgs */,
1380 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001381 }
1382 try {
1383 while (subCursor.moveToNext()) {
1384 ContentValues extendedValues = new ContentValues();
Marc Blank8f643c12010-04-29 14:16:48 -07001385 extendedValues.put(ExtendedProperties._ID,
1386 subCursor.getString(COLUMN_ID));
Ken Shirriff3b168922010-01-27 12:27:28 -08001387 extendedValues.put(ExtendedProperties.NAME,
1388 subCursor.getString(COLUMN_NAME));
Fred Quintana328c0e72009-12-07 14:52:28 -08001389 extendedValues.put(ExtendedProperties.VALUE,
Ken Shirriff3b168922010-01-27 12:27:28 -08001390 subCursor.getString(COLUMN_VALUE));
Fred Quintana328c0e72009-12-07 14:52:28 -08001391 entity.addSubValue(ExtendedProperties.CONTENT_URI, extendedValues);
1392 }
1393 } finally {
1394 subCursor.close();
1395 }
1396
1397 cursor.moveToNext();
1398 return entity;
1399 }
1400 }
1401 }
1402
1403 /**
RoboErikf4010c52011-06-17 11:04:26 -07001404 * Constants and helpers for the Events table, which contains details for
1405 * individual events. <h3>Operations</h3> All operations can be done either
1406 * as an app or as a sync adapter. To perform an operation as a sync adapter
1407 * {@link #CALLER_IS_SYNCADAPTER} should be set to true and
1408 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
1409 * parameters. See
1410 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
1411 * for details on adding parameters. Sync adapters have write access to more
1412 * columns but are restricted to a single account at a time.
RoboErikfe37b492011-06-16 12:31:56 -07001413 * <dl>
1414 * <dt><b>Insert</b></dt>
1415 * <dd>When inserting a new event the following fields must be included:
1416 * <ul>
1417 * <li>dtstart</li>
Michael Chane6fbf652011-10-18 14:43:11 -07001418 * <li>dtend if the event is non-recurring</li>
1419 * <li>duration if the event is recurring</li>
1420 * <li>rrule or rdate if the event is recurring</li>
RoboErik4172d952011-10-25 13:59:13 -07001421 * <li>eventTimezone</li>
RoboErikfe37b492011-06-16 12:31:56 -07001422 * <li>a calendar_id</li>
1423 * </ul>
1424 * There are also further requirements when inserting or updating an event.
1425 * See the section on Writing to Events.</dd>
1426 * <dt><b>Update</b></dt>
RoboErikf4010c52011-06-17 11:04:26 -07001427 * <dd>To perform an update of an Event the {@link Events#_ID} of the event
1428 * should be provided either as an appended id to the Uri (
RoboErikfe37b492011-06-16 12:31:56 -07001429 * {@link ContentUris#withAppendedId}) or as the first selection item--the
1430 * selection should start with "_id=?" and the first selectionArg should be
RoboErikf4010c52011-06-17 11:04:26 -07001431 * the _id of the event. Updates may also be done using a selection and no
1432 * id. Updating an event must respect the same rules as inserting and is
1433 * further restricted in the fields that can be written. See the section on
1434 * Writing to Events.</dd>
RoboErikfe37b492011-06-16 12:31:56 -07001435 * <dt><b>Delete</b></dt>
1436 * <dd>Events can be deleted either by the {@link Events#_ID} as an appended
1437 * id on the Uri or using any standard selection. If an appended id is used
1438 * a selection is not allowed. There are two versions of delete: as an app
1439 * and as a sync adapter. An app delete will set the deleted column on an
1440 * event and remove all instances of that event. A sync adapter delete will
1441 * remove the event from the database and all associated data.</dd>
1442 * <dt><b>Query</b></dt>
1443 * <dd>Querying the Events table will get you all information about a set of
1444 * events except their reminders, attendees, and extended properties. There
1445 * will be one row returned for each event that matches the query selection,
1446 * or at most a single row if the {@link Events#_ID} is appended to the Uri.
1447 * Recurring events will only return a single row regardless of the number
1448 * of times that event repeats.</dd>
1449 * </dl>
1450 * <h3>Writing to Events</h3> There are further restrictions on all Updates
1451 * and Inserts in the Events table:
1452 * <ul>
1453 * <li>If allDay is set to 1 eventTimezone must be {@link Time#TIMEZONE_UTC}
1454 * and the time must correspond to a midnight boundary.</li>
1455 * <li>Exceptions are not allowed to recur. If rrule or rdate is not empty,
1456 * original_id and original_sync_id must be empty.</li>
1457 * <li>In general a calendar_id should not be modified after insertion. This
1458 * is not explicitly forbidden but many sync adapters will not behave in an
1459 * expected way if the calendar_id is modified.</li>
1460 * </ul>
1461 * The following Events columns are writable by both an app and a sync
1462 * adapter.
1463 * <ul>
1464 * <li>{@link #CALENDAR_ID}</li>
1465 * <li>{@link #ORGANIZER}</li>
1466 * <li>{@link #TITLE}</li>
1467 * <li>{@link #EVENT_LOCATION}</li>
1468 * <li>{@link #DESCRIPTION}</li>
1469 * <li>{@link #EVENT_COLOR}</li>
1470 * <li>{@link #DTSTART}</li>
1471 * <li>{@link #DTEND}</li>
1472 * <li>{@link #EVENT_TIMEZONE}</li>
1473 * <li>{@link #EVENT_END_TIMEZONE}</li>
1474 * <li>{@link #DURATION}</li>
1475 * <li>{@link #ALL_DAY}</li>
1476 * <li>{@link #RRULE}</li>
1477 * <li>{@link #RDATE}</li>
1478 * <li>{@link #EXRULE}</li>
1479 * <li>{@link #EXDATE}</li>
1480 * <li>{@link #ORIGINAL_ID}</li>
1481 * <li>{@link #ORIGINAL_SYNC_ID}</li>
1482 * <li>{@link #ORIGINAL_INSTANCE_TIME}</li>
1483 * <li>{@link #ORIGINAL_ALL_DAY}</li>
1484 * <li>{@link #ACCESS_LEVEL}</li>
1485 * <li>{@link #AVAILABILITY}</li>
1486 * <li>{@link #GUESTS_CAN_MODIFY}</li>
1487 * <li>{@link #GUESTS_CAN_INVITE_OTHERS}</li>
1488 * <li>{@link #GUESTS_CAN_SEE_GUESTS}</li>
1489 * </ul>
1490 * The following Events columns are writable only by a sync adapter
1491 * <ul>
1492 * <li>{@link #DIRTY}</li>
1493 * <li>{@link #_SYNC_ID}</li>
1494 * <li>{@link #SYNC_DATA1}</li>
1495 * <li>{@link #SYNC_DATA2}</li>
1496 * <li>{@link #SYNC_DATA3}</li>
1497 * <li>{@link #SYNC_DATA4}</li>
1498 * <li>{@link #SYNC_DATA5}</li>
1499 * <li>{@link #SYNC_DATA6}</li>
1500 * <li>{@link #SYNC_DATA7}</li>
1501 * <li>{@link #SYNC_DATA8}</li>
1502 * <li>{@link #SYNC_DATA9}</li>
1503 * <li>{@link #SYNC_DATA10}</li>
1504 * </ul>
1505 * The remaining columns are either updated by the provider only or are
1506 * views into other tables and cannot be changed through the Events table.
Fred Quintana328c0e72009-12-07 14:52:28 -08001507 */
RoboErik9734df52011-06-09 14:11:25 -07001508 public static final class Events implements BaseColumns, SyncColumns, EventsColumns,
RoboErike00d5892011-06-23 15:16:55 -07001509 CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001510
RoboErikc2d53302011-06-03 09:37:58 -07001511 /**
RoboErikc2d53302011-06-03 09:37:58 -07001512 * The content:// style URL for interacting with events. Appending an
1513 * event id using {@link ContentUris#withAppendedId(Uri, long)} will
1514 * specify a single event.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001515 */
RoboErikc2d53302011-06-03 09:37:58 -07001516 @SuppressWarnings("hiding")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001517 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001518 Uri.parse("content://" + AUTHORITY + "/events");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001519
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001520 /**
Andy McFadden4a8c4782011-05-24 13:00:29 -07001521 * The content:// style URI for recurring event exceptions. Insertions require an
1522 * appended event ID. Deletion of exceptions requires both the original event ID and
1523 * the exception event ID (see {@link Uri.Builder#appendPath}).
1524 */
RoboErik083cd2d2011-06-30 11:53:05 -07001525 public static final Uri CONTENT_EXCEPTION_URI =
Andy McFadden4a8c4782011-05-24 13:00:29 -07001526 Uri.parse("content://" + AUTHORITY + "/exception");
1527
1528 /**
RoboErik36726962011-06-14 14:01:15 -07001529 * This utility class cannot be instantiated
1530 */
1531 private Events() {}
1532
1533 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001534 * The default sort order for this table
1535 */
RoboErikc2d53302011-06-03 09:37:58 -07001536 private static final String DEFAULT_SORT_ORDER = "";
RoboErik651c02e2011-05-05 15:14:31 -07001537
1538 /**
1539 * These are columns that should only ever be updated by the provider,
1540 * either because they are views mapped to another table or because they
RoboErik083cd2d2011-06-30 11:53:05 -07001541 * are used for provider only functionality. TODO move to provider
1542 *
1543 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001544 */
1545 public static String[] PROVIDER_WRITABLE_COLUMNS = new String[] {
1546 ACCOUNT_NAME,
RoboErikc2d53302011-06-03 09:37:58 -07001547 ACCOUNT_TYPE,
1548 CAL_SYNC1,
1549 CAL_SYNC2,
1550 CAL_SYNC3,
1551 CAL_SYNC4,
1552 CAL_SYNC5,
Alon Albert866f40a2011-06-06 14:04:00 -07001553 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -07001554 CAL_SYNC7,
1555 CAL_SYNC8,
1556 CAL_SYNC9,
1557 CAL_SYNC10,
1558 ALLOWED_REMINDERS,
RoboErikc7ef9392011-10-27 14:11:44 -07001559 ALLOWED_ATTENDEE_TYPES,
1560 ALLOWED_AVAILABILITY,
RoboErik9734df52011-06-09 14:11:25 -07001561 CALENDAR_ACCESS_LEVEL,
1562 CALENDAR_COLOR,
1563 CALENDAR_TIME_ZONE,
1564 CAN_MODIFY_TIME_ZONE,
1565 CAN_ORGANIZER_RESPOND,
1566 CALENDAR_DISPLAY_NAME,
Alon Albert866f40a2011-06-06 14:04:00 -07001567 CAN_PARTIALLY_UPDATE,
RoboErik9734df52011-06-09 14:11:25 -07001568 SYNC_EVENTS,
1569 VISIBLE,
RoboErik651c02e2011-05-05 15:14:31 -07001570 };
1571
1572 /**
1573 * These fields are only writable by a sync adapter. To modify them the
1574 * caller must include CALLER_IS_SYNCADAPTER, _SYNC_ACCOUNT, and
RoboErik083cd2d2011-06-30 11:53:05 -07001575 * _SYNC_ACCOUNT_TYPE in the query parameters. TODO move to provider.
1576 *
1577 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001578 */
1579 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
1580 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -07001581 DIRTY,
RoboErik9734df52011-06-09 14:11:25 -07001582 SYNC_DATA1,
1583 SYNC_DATA2,
1584 SYNC_DATA3,
1585 SYNC_DATA4,
1586 SYNC_DATA5,
1587 SYNC_DATA6,
1588 SYNC_DATA7,
1589 SYNC_DATA8,
1590 SYNC_DATA9,
1591 SYNC_DATA10,
RoboErik651c02e2011-05-05 15:14:31 -07001592 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001593 }
1594
1595 /**
RoboErikc2d53302011-06-03 09:37:58 -07001596 * Fields and helpers for interacting with Instances. An instance is a
1597 * single occurrence of an event including time zone specific start and end
RoboErik3771fcb2011-06-16 15:41:31 -07001598 * days and minutes. The instances table is not writable and only provides a
1599 * way to query event occurrences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001600 */
RoboErike00d5892011-06-23 15:16:55 -07001601 public static final class Instances implements BaseColumns, EventsColumns, CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001602
RoboErike00d5892011-06-23 15:16:55 -07001603 private static final String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?";
1604 private static final String[] WHERE_CALENDARS_ARGS = {
1605 "1"
1606 };
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001607
RoboErikc2d53302011-06-03 09:37:58 -07001608 /**
RoboErik36726962011-06-14 14:01:15 -07001609 * This utility class cannot be instantiated
1610 */
1611 private Instances() {}
1612
1613 /**
RoboErikc2d53302011-06-03 09:37:58 -07001614 * Performs a query to return all visible instances in the given range.
1615 * This is a blocking function and should not be done on the UI thread.
1616 * This will cause an expansion of recurring events to fill this time
1617 * range if they are not already expanded and will slow down for larger
1618 * time ranges with many recurring events.
1619 *
1620 * @param cr The ContentResolver to use for the query
1621 * @param projection The columns to return
1622 * @param begin The start of the time range to query in UTC millis since
1623 * epoch
1624 * @param end The end of the time range to query in UTC millis since
1625 * epoch
1626 * @return A Cursor containing all instances in the given range
1627 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001628 public static final Cursor query(ContentResolver cr, String[] projection,
1629 long begin, long end) {
1630 Uri.Builder builder = CONTENT_URI.buildUpon();
1631 ContentUris.appendId(builder, begin);
1632 ContentUris.appendId(builder, end);
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001633 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
RoboErike00d5892011-06-23 15:16:55 -07001634 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001635 }
1636
RoboErikc2d53302011-06-03 09:37:58 -07001637 /**
1638 * Performs a query to return all visible instances in the given range
1639 * that match the given query. This is a blocking function and should
1640 * not be done on the UI thread. This will cause an expansion of
1641 * recurring events to fill this time range if they are not already
1642 * expanded and will slow down for larger time ranges with many
1643 * recurring events.
1644 *
1645 * @param cr The ContentResolver to use for the query
1646 * @param projection The columns to return
1647 * @param begin The start of the time range to query in UTC millis since
1648 * epoch
1649 * @param end The end of the time range to query in UTC millis since
1650 * epoch
1651 * @param searchQuery A string of space separated search terms. Segments
1652 * enclosed by double quotes will be treated as a single
1653 * term.
1654 * @return A Cursor of instances matching the search terms in the given
1655 * time range
1656 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001657 public static final Cursor query(ContentResolver cr, String[] projection,
Mason Tang19f84582010-07-08 18:01:41 -07001658 long begin, long end, String searchQuery) {
1659 Uri.Builder builder = CONTENT_SEARCH_URI.buildUpon();
1660 ContentUris.appendId(builder, begin);
1661 ContentUris.appendId(builder, end);
RoboErikc2d53302011-06-03 09:37:58 -07001662 builder = builder.appendPath(searchQuery);
RoboErike00d5892011-06-23 15:16:55 -07001663 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
1664 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
RoboErikc2d53302011-06-03 09:37:58 -07001665 }
1666
1667 /**
1668 * The content:// style URL for querying an instance range. The begin
1669 * and end of the range to query should be added as path segments if
1670 * this is used directly.
1671 */
1672 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001673 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1674 "/instances/when");
RoboErikc2d53302011-06-03 09:37:58 -07001675 /**
1676 * The content:// style URL for querying an instance range by Julian
1677 * Day. The start and end day should be added as path segments if this
1678 * is used directly.
1679 */
Michael Chan2cfb0d12009-06-30 18:11:23 -07001680 public static final Uri CONTENT_BY_DAY_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001681 Uri.parse("content://" + AUTHORITY + "/instances/whenbyday");
RoboErikc2d53302011-06-03 09:37:58 -07001682 /**
1683 * The content:// style URL for querying an instance range with a search
1684 * term. The begin, end, and search string should be appended as path
1685 * segments if this is used directly.
1686 */
Mason Tang19f84582010-07-08 18:01:41 -07001687 public static final Uri CONTENT_SEARCH_URI = Uri.parse("content://" + AUTHORITY +
1688 "/instances/search");
RoboErikc2d53302011-06-03 09:37:58 -07001689 /**
1690 * The content:// style URL for querying an instance range with a search
1691 * term. The start day, end day, and search string should be appended as
1692 * path segments if this is used directly.
1693 */
Mason Tang19f84582010-07-08 18:01:41 -07001694 public static final Uri CONTENT_SEARCH_BY_DAY_URI =
1695 Uri.parse("content://" + AUTHORITY + "/instances/searchbyday");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001696
1697 /**
1698 * The default sort order for this table.
1699 */
RoboErikc2d53302011-06-03 09:37:58 -07001700 private static final String DEFAULT_SORT_ORDER = "begin ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001701
1702 /**
RoboErikc2d53302011-06-03 09:37:58 -07001703 * The beginning time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001704 * <P>Type: INTEGER (long; millis since epoch)</P>
1705 */
1706 public static final String BEGIN = "begin";
1707
1708 /**
RoboErikc2d53302011-06-03 09:37:58 -07001709 * The ending time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001710 * <P>Type: INTEGER (long; millis since epoch)</P>
1711 */
1712 public static final String END = "end";
1713
1714 /**
RoboErikc2d53302011-06-03 09:37:58 -07001715 * The _id of the event for this instance. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001716 * <P>Type: INTEGER (long, foreign key to the Events table)</P>
1717 */
1718 public static final String EVENT_ID = "event_id";
1719
1720 /**
RoboErikc2d53302011-06-03 09:37:58 -07001721 * The Julian start day of the instance, relative to the local time
1722 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001723 * <P>Type: INTEGER (int)</P>
1724 */
1725 public static final String START_DAY = "startDay";
1726
1727 /**
RoboErikc2d53302011-06-03 09:37:58 -07001728 * The Julian end day of the instance, relative to the local time
1729 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001730 * <P>Type: INTEGER (int)</P>
1731 */
1732 public static final String END_DAY = "endDay";
1733
1734 /**
1735 * The start minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07001736 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001737 * <P>Type: INTEGER (int)</P>
1738 */
1739 public static final String START_MINUTE = "startMinute";
1740
1741 /**
1742 * The end minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07001743 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001744 * <P>Type: INTEGER (int)</P>
1745 */
1746 public static final String END_MINUTE = "endMinute";
1747 }
1748
RoboErikb2c75602011-06-13 12:53:48 -07001749 protected interface CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07001750 /**
RoboErikc2d53302011-06-03 09:37:58 -07001751 * The key for the setting. Keys are defined in {@link CalendarCache}.
Erik71ad58c2010-09-13 16:41:35 -07001752 */
1753 public static final String KEY = "key";
1754
1755 /**
1756 * The value of the given setting.
1757 */
1758 public static final String VALUE = "value";
1759 }
1760
RoboErik083cd2d2011-06-30 11:53:05 -07001761 /**
1762 * CalendarCache stores some settings for calendar including the current
1763 * time zone for the instances. These settings are stored using a key/value
1764 * scheme. A {@link #KEY} must be specified when updating these values.
1765 */
RoboErik36726962011-06-14 14:01:15 -07001766 public static final class CalendarCache implements CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07001767 /**
1768 * The URI to use for retrieving the properties from the Calendar db.
1769 */
1770 public static final Uri URI =
1771 Uri.parse("content://" + AUTHORITY + "/properties");
Erik71ad58c2010-09-13 16:41:35 -07001772
1773 /**
RoboErik36726962011-06-14 14:01:15 -07001774 * This utility class cannot be instantiated
1775 */
1776 private CalendarCache() {}
1777
1778 /**
Erik71ad58c2010-09-13 16:41:35 -07001779 * They key for updating the use of auto/home time zones in Calendar.
1780 * Valid values are {@link #TIMEZONE_TYPE_AUTO} or
1781 * {@link #TIMEZONE_TYPE_HOME}.
1782 */
RoboErik083cd2d2011-06-30 11:53:05 -07001783 public static final String KEY_TIMEZONE_TYPE = "timezoneType";
Erik71ad58c2010-09-13 16:41:35 -07001784
1785 /**
1786 * The key for updating the time zone used by the provider when it
1787 * generates the instances table. This should only be written if the
1788 * type is set to {@link #TIMEZONE_TYPE_HOME}. A valid time zone id
1789 * should be written to this field.
1790 */
RoboErik083cd2d2011-06-30 11:53:05 -07001791 public static final String KEY_TIMEZONE_INSTANCES = "timezoneInstances";
Erik71ad58c2010-09-13 16:41:35 -07001792
1793 /**
1794 * The key for reading the last time zone set by the user. This should
1795 * only be read by apps and it will be automatically updated whenever
RoboErik083cd2d2011-06-30 11:53:05 -07001796 * {@link #KEY_TIMEZONE_INSTANCES} is updated with
Erik71ad58c2010-09-13 16:41:35 -07001797 * {@link #TIMEZONE_TYPE_HOME} set.
1798 */
RoboErik083cd2d2011-06-30 11:53:05 -07001799 public static final String KEY_TIMEZONE_INSTANCES_PREVIOUS = "timezoneInstancesPrevious";
Erik71ad58c2010-09-13 16:41:35 -07001800
1801 /**
RoboErik083cd2d2011-06-30 11:53:05 -07001802 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07001803 * should stay in sync with the device's time zone.
1804 */
1805 public static final String TIMEZONE_TYPE_AUTO = "auto";
1806
1807 /**
RoboErik083cd2d2011-06-30 11:53:05 -07001808 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07001809 * should use a fixed time zone set by the user.
1810 */
1811 public static final String TIMEZONE_TYPE_HOME = "home";
1812 }
1813
1814 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001815 * A few Calendar globals are needed in the CalendarProvider for expanding
RoboErik59dab492011-06-17 11:09:36 -07001816 * the Instances table and these are all stored in the first (and only) row
1817 * of the CalendarMetaData table.
1818 *
1819 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001820 */
RoboErikb2c75602011-06-13 12:53:48 -07001821 protected interface CalendarMetaDataColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001822 /**
1823 * The local timezone that was used for precomputing the fields
1824 * in the Instances table.
1825 */
1826 public static final String LOCAL_TIMEZONE = "localTimezone";
1827
1828 /**
1829 * The minimum time used in expanding the Instances table,
1830 * in UTC milliseconds.
1831 * <P>Type: INTEGER</P>
1832 */
1833 public static final String MIN_INSTANCE = "minInstance";
1834
1835 /**
1836 * The maximum time used in expanding the Instances table,
1837 * in UTC milliseconds.
1838 * <P>Type: INTEGER</P>
1839 */
1840 public static final String MAX_INSTANCE = "maxInstance";
1841
1842 /**
Erik37634642009-12-23 15:24:14 -08001843 * The minimum Julian day in the EventDays table.
1844 * <P>Type: INTEGER</P>
1845 */
1846 public static final String MIN_EVENTDAYS = "minEventDays";
1847
1848 /**
1849 * The maximum Julian day in the EventDays table.
1850 * <P>Type: INTEGER</P>
1851 */
1852 public static final String MAX_EVENTDAYS = "maxEventDays";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001853 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07001854
RoboErikc2d53302011-06-03 09:37:58 -07001855 /**
1856 * @hide
1857 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07001858 public static final class CalendarMetaData implements CalendarMetaDataColumns, BaseColumns {
RoboErik36726962011-06-14 14:01:15 -07001859
1860 /**
1861 * This utility class cannot be instantiated
1862 */
1863 private CalendarMetaData() {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001864 }
Erik37634642009-12-23 15:24:14 -08001865
RoboErikb2c75602011-06-13 12:53:48 -07001866 protected interface EventDaysColumns {
Erik37634642009-12-23 15:24:14 -08001867 /**
RoboErikc2d53302011-06-03 09:37:58 -07001868 * The Julian starting day number. Column name.
Erik37634642009-12-23 15:24:14 -08001869 * <P>Type: INTEGER (int)</P>
1870 */
1871 public static final String STARTDAY = "startDay";
RoboErikc2d53302011-06-03 09:37:58 -07001872 /**
1873 * The Julian ending day number. Column name.
1874 * <P>Type: INTEGER (int)</P>
1875 */
Erikbd8e2e22010-01-07 11:56:46 -08001876 public static final String ENDDAY = "endDay";
Erik37634642009-12-23 15:24:14 -08001877
1878 }
1879
RoboErikc2d53302011-06-03 09:37:58 -07001880 /**
1881 * Fields and helpers for querying for a list of days that contain events.
1882 */
Erik37634642009-12-23 15:24:14 -08001883 public static final class EventDays implements EventDaysColumns {
RoboErikb2c75602011-06-13 12:53:48 -07001884 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
RoboErikc2d53302011-06-03 09:37:58 -07001885 + "/instances/groupbyday");
RoboErikc2d53302011-06-03 09:37:58 -07001886 private static final String SELECTION = "selected=1";
1887
1888 /**
RoboErik36726962011-06-14 14:01:15 -07001889 * This utility class cannot be instantiated
1890 */
1891 private EventDays() {}
1892
1893 /**
RoboErikc2d53302011-06-03 09:37:58 -07001894 * Retrieves the days with events for the Julian days starting at
1895 * "startDay" for "numDays". It returns a cursor containing startday and
1896 * endday representing the max range of days for all events beginning on
1897 * each startday.This is a blocking function and should not be done on
1898 * the UI thread.
RoboErik36726962011-06-14 14:01:15 -07001899 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001900 * @param cr the ContentResolver
1901 * @param startDay the first Julian day in the range
1902 * @param numDays the number of days to load (must be at least 1)
RoboErik58644022011-07-08 13:39:05 -07001903 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07001904 * @return a database cursor containing a list of start and end days for
1905 * events
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001906 */
RoboErik58644022011-07-08 13:39:05 -07001907 public static final Cursor query(ContentResolver cr, int startDay, int numDays,
1908 String[] projection) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001909 if (numDays < 1) {
1910 return null;
1911 }
1912 int endDay = startDay + numDays - 1;
1913 Uri.Builder builder = CONTENT_URI.buildUpon();
1914 ContentUris.appendId(builder, startDay);
1915 ContentUris.appendId(builder, endDay);
RoboErik58644022011-07-08 13:39:05 -07001916 return cr.query(builder.build(), projection, SELECTION,
Erik37634642009-12-23 15:24:14 -08001917 null /* selection args */, STARTDAY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001918 }
1919 }
1920
RoboErikb2c75602011-06-13 12:53:48 -07001921 protected interface RemindersColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001922 /**
RoboErikc2d53302011-06-03 09:37:58 -07001923 * The event the reminder belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001924 * <P>Type: INTEGER (foreign key to the Events table)</P>
1925 */
1926 public static final String EVENT_ID = "event_id";
1927
1928 /**
1929 * The minutes prior to the event that the alarm should ring. -1
1930 * specifies that we should use the default value for the system.
RoboErikc2d53302011-06-03 09:37:58 -07001931 * Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001932 * <P>Type: INTEGER</P>
1933 */
1934 public static final String MINUTES = "minutes";
1935
RoboErikc2d53302011-06-03 09:37:58 -07001936 /**
1937 * Passing this as a minutes value will use the default reminder
1938 * minutes.
1939 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001940 public static final int MINUTES_DEFAULT = -1;
1941
1942 /**
RoboErikc2d53302011-06-03 09:37:58 -07001943 * The alarm method, as set on the server. {@link #METHOD_DEFAULT},
Alon Albertbd251612012-02-23 10:30:51 -08001944 * {@link #METHOD_ALERT}, {@link #METHOD_EMAIL}, {@link #METHOD_SMS} and
1945 * {@link #METHOD_ALARM} are possible values; the device will only
1946 * process {@link #METHOD_DEFAULT} and {@link #METHOD_ALERT} reminders
1947 * (the other types are simply stored so we can send the same reminder
1948 * info back to the server when we make changes).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001949 */
1950 public static final String METHOD = "method";
1951
1952 public static final int METHOD_DEFAULT = 0;
1953 public static final int METHOD_ALERT = 1;
1954 public static final int METHOD_EMAIL = 2;
1955 public static final int METHOD_SMS = 3;
Alon Albertbd251612012-02-23 10:30:51 -08001956 public static final int METHOD_ALARM = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001957 }
1958
RoboErikc2d53302011-06-03 09:37:58 -07001959 /**
RoboErik3771fcb2011-06-16 15:41:31 -07001960 * Fields and helpers for accessing reminders for an event. Each row of this
1961 * table represents a single reminder for an event. Calling
RoboErik58644022011-07-08 13:39:05 -07001962 * {@link #query(ContentResolver, long, String[])} will return a list of reminders for
RoboErik3771fcb2011-06-16 15:41:31 -07001963 * the event with the given eventId. Both apps and sync adapters may write
1964 * to this table. There are three writable fields and all of them must be
1965 * included when inserting a new reminder. They are:
1966 * <ul>
1967 * <li>{@link #EVENT_ID}</li>
1968 * <li>{@link #MINUTES}</li>
1969 * <li>{@link #METHOD}</li>
1970 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07001971 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001972 public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns {
RoboErikbec6c362011-06-14 11:06:01 -07001973 private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?";
RoboErikc2d53302011-06-03 09:37:58 -07001974 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001975 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders");
RoboErikc2d53302011-06-03 09:37:58 -07001976
1977 /**
RoboErik36726962011-06-14 14:01:15 -07001978 * This utility class cannot be instantiated
1979 */
1980 private Reminders() {}
1981
1982 /**
RoboErikc2d53302011-06-03 09:37:58 -07001983 * Queries all reminders associated with the given event. This is a
1984 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -07001985 *
RoboErikc2d53302011-06-03 09:37:58 -07001986 * @param cr The content resolver to use for the query
1987 * @param eventId The id of the event to retrieve reminders for
RoboErik58644022011-07-08 13:39:05 -07001988 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07001989 * @return A Cursor containing all reminders for the event
1990 */
RoboErik58644022011-07-08 13:39:05 -07001991 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -07001992 String[] remArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -07001993 return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/,
RoboErikc2d53302011-06-03 09:37:58 -07001994 null /* sort order */);
1995 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001996 }
1997
RoboErikb2c75602011-06-13 12:53:48 -07001998 protected interface CalendarAlertsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001999 /**
RoboErikc2d53302011-06-03 09:37:58 -07002000 * The event that the alert belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002001 * <P>Type: INTEGER (foreign key to the Events table)</P>
2002 */
2003 public static final String EVENT_ID = "event_id";
2004
2005 /**
RoboErikc2d53302011-06-03 09:37:58 -07002006 * The start time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002007 * <P>Type: INTEGER (long; millis since epoch)</P>
2008 */
2009 public static final String BEGIN = "begin";
2010
2011 /**
RoboErikc2d53302011-06-03 09:37:58 -07002012 * The end time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002013 * <P>Type: INTEGER (long; millis since epoch)</P>
2014 */
2015 public static final String END = "end";
2016
2017 /**
RoboErikc2d53302011-06-03 09:37:58 -07002018 * The alarm time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002019 * <P>Type: INTEGER (long; millis since epoch)</P>
2020 */
2021 public static final String ALARM_TIME = "alarmTime";
2022
2023 /**
2024 * The creation time of this database entry, in UTC.
RoboErikc2d53302011-06-03 09:37:58 -07002025 * Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002026 * <P>Type: INTEGER (long; millis since epoch)</P>
2027 */
2028 public static final String CREATION_TIME = "creationTime";
2029
2030 /**
2031 * The time that the alarm broadcast was received by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002032 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002033 * <P>Type: INTEGER (long; millis since epoch)</P>
2034 */
2035 public static final String RECEIVED_TIME = "receivedTime";
2036
2037 /**
2038 * The time that the notification was created by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002039 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002040 * <P>Type: INTEGER (long; millis since epoch)</P>
2041 */
2042 public static final String NOTIFY_TIME = "notifyTime";
2043
2044 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002045 * The state of this alert. It starts out as {@link #STATE_SCHEDULED}, then
2046 * when the alarm goes off, it changes to {@link #STATE_FIRED}, and then when
2047 * the user dismisses the alarm it changes to {@link #STATE_DISMISSED}. Column
RoboErikc2d53302011-06-03 09:37:58 -07002048 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002049 * <P>Type: INTEGER</P>
2050 */
2051 public static final String STATE = "state";
2052
RoboErik083cd2d2011-06-30 11:53:05 -07002053 /**
2054 * An alert begins in this state when it is first created.
2055 */
2056 public static final int STATE_SCHEDULED = 0;
2057 /**
2058 * After a notification for an alert has been created it should be
2059 * updated to fired.
2060 */
2061 public static final int STATE_FIRED = 1;
2062 /**
2063 * Once the user has dismissed the notification the alert's state should
2064 * be set to dismissed so it is not fired again.
2065 */
2066 public static final int STATE_DISMISSED = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002067
2068 /**
RoboErikc2d53302011-06-03 09:37:58 -07002069 * The number of minutes that this alarm precedes the start time. Column
2070 * name.
2071 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002072 */
2073 public static final String MINUTES = "minutes";
2074
2075 /**
RoboErikc2d53302011-06-03 09:37:58 -07002076 * The default sort order for this alerts queries
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002077 */
Michael Chancdaeafd2009-10-29 00:11:58 -07002078 public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002079 }
2080
RoboErikc2d53302011-06-03 09:37:58 -07002081 /**
2082 * Fields and helpers for accessing calendar alerts information. These
RoboErik3771fcb2011-06-16 15:41:31 -07002083 * fields are for tracking which alerts have been fired. Scheduled alarms
RoboErike00d5892011-06-23 15:16:55 -07002084 * will generate an intent using {@link #ACTION_EVENT_REMINDER}. Apps that
RoboErik3771fcb2011-06-16 15:41:31 -07002085 * receive this action may update the {@link #STATE} for the reminder when
2086 * they have finished handling it. Apps that have their notifications
2087 * disabled should not modify the table to ensure that they do not conflict
2088 * with another app that is generating a notification. In general, apps
2089 * should not need to write to this table directly except to update the
2090 * state of a reminder.
RoboErikc2d53302011-06-03 09:37:58 -07002091 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002092 public static final class CalendarAlerts implements BaseColumns,
RoboErike00d5892011-06-23 15:16:55 -07002093 CalendarAlertsColumns, EventsColumns, CalendarColumns {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002094
RoboErikc2d53302011-06-03 09:37:58 -07002095 /**
2096 * @hide
2097 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098 public static final String TABLE_NAME = "CalendarAlerts";
RoboErikc2d53302011-06-03 09:37:58 -07002099 /**
2100 * The Uri for querying calendar alert information
2101 */
2102 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002103 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
2104 "/calendar_alerts");
Ken Shirriff5b387e12009-10-23 09:50:41 -07002105
RoboErik36726962011-06-14 14:01:15 -07002106 /**
2107 * This utility class cannot be instantiated
2108 */
2109 private CalendarAlerts() {}
2110
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002111 private static final String WHERE_ALARM_EXISTS = EVENT_ID + "=?"
2112 + " AND " + BEGIN + "=?"
2113 + " AND " + ALARM_TIME + "=?";
2114
2115 private static final String WHERE_FINDNEXTALARMTIME = ALARM_TIME + ">=?";
2116 private static final String SORT_ORDER_ALARMTIME_ASC = ALARM_TIME + " ASC";
2117
RoboErik083cd2d2011-06-30 11:53:05 -07002118 private static final String WHERE_RESCHEDULE_MISSED_ALARMS = STATE + "=" + STATE_SCHEDULED
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002119 + " AND " + ALARM_TIME + "<?"
2120 + " AND " + ALARM_TIME + ">?"
2121 + " AND " + END + ">=?";
2122
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002123 /**
2124 * This URI is for grouping the query results by event_id and begin
2125 * time. This will return one result per instance of an event. So
2126 * events with multiple alarms will appear just once, but multiple
2127 * instances of a repeating event will show up multiple times.
2128 */
Ken Shirriff5b387e12009-10-23 09:50:41 -07002129 public static final Uri CONTENT_URI_BY_INSTANCE =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002130 Uri.parse("content://" + AUTHORITY + "/calendar_alerts/by_instance");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002131
RoboErik083cd2d2011-06-30 11:53:05 -07002132 private static final boolean DEBUG = false;
Michael Chancdaeafd2009-10-29 00:11:58 -07002133
RoboErikc2d53302011-06-03 09:37:58 -07002134 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002135 * Helper for inserting an alarm time associated with an event TODO move
2136 * to Provider
RoboErikc2d53302011-06-03 09:37:58 -07002137 *
2138 * @hide
2139 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002140 public static final Uri insert(ContentResolver cr, long eventId,
2141 long begin, long end, long alarmTime, int minutes) {
2142 ContentValues values = new ContentValues();
2143 values.put(CalendarAlerts.EVENT_ID, eventId);
2144 values.put(CalendarAlerts.BEGIN, begin);
2145 values.put(CalendarAlerts.END, end);
2146 values.put(CalendarAlerts.ALARM_TIME, alarmTime);
2147 long currentTime = System.currentTimeMillis();
2148 values.put(CalendarAlerts.CREATION_TIME, currentTime);
2149 values.put(CalendarAlerts.RECEIVED_TIME, 0);
2150 values.put(CalendarAlerts.NOTIFY_TIME, 0);
RoboErik083cd2d2011-06-30 11:53:05 -07002151 values.put(CalendarAlerts.STATE, STATE_SCHEDULED);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002152 values.put(CalendarAlerts.MINUTES, minutes);
2153 return cr.insert(CONTENT_URI, values);
2154 }
2155
RoboErikc2d53302011-06-03 09:37:58 -07002156 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002157 * Finds the next alarm after (or equal to) the given time and returns
RoboErikc2d53302011-06-03 09:37:58 -07002158 * the time of that alarm or -1 if no such alarm exists. This is a
RoboErik083cd2d2011-06-30 11:53:05 -07002159 * blocking call and should not be done on the UI thread. TODO move to
2160 * provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002161 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002162 * @param cr the ContentResolver
2163 * @param millis the time in UTC milliseconds
2164 * @return the next alarm time greater than or equal to "millis", or -1
RoboErikc2d53302011-06-03 09:37:58 -07002165 * if no such alarm exists.
RoboErik083cd2d2011-06-30 11:53:05 -07002166 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002167 */
2168 public static final long findNextAlarmTime(ContentResolver cr, long millis) {
2169 String selection = ALARM_TIME + ">=" + millis;
2170 // TODO: construct an explicit SQL query so that we can add
2171 // "LIMIT 1" to the end and get just one result.
2172 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002173 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_FINDNEXTALARMTIME,
2174 (new String[] {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002175 Long.toString(millis)
RoboErik083cd2d2011-06-30 11:53:05 -07002176 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002177 long alarmTime = -1;
2178 try {
2179 if (cursor != null && cursor.moveToFirst()) {
2180 alarmTime = cursor.getLong(0);
2181 }
2182 } finally {
2183 if (cursor != null) {
2184 cursor.close();
2185 }
2186 }
2187 return alarmTime;
2188 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002189
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002190 /**
2191 * Searches the CalendarAlerts table for alarms that should have fired
RoboErik083cd2d2011-06-30 11:53:05 -07002192 * but have not and then reschedules them. This method can be called at
2193 * boot time to restore alarms that may have been lost due to a phone
2194 * reboot. TODO move to provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002195 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002196 * @param cr the ContentResolver
2197 * @param context the Context
2198 * @param manager the AlarmManager
RoboErik083cd2d2011-06-30 11:53:05 -07002199 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002200 */
2201 public static final void rescheduleMissedAlarms(ContentResolver cr,
2202 Context context, AlarmManager manager) {
2203 // Get all the alerts that have been scheduled but have not fired
2204 // and should have fired by now and are not too old.
2205 long now = System.currentTimeMillis();
Michael Chancdaeafd2009-10-29 00:11:58 -07002206 long ancient = now - DateUtils.DAY_IN_MILLIS;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002207 String[] projection = new String[] {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002208 ALARM_TIME,
2209 };
Michael Chancdaeafd2009-10-29 00:11:58 -07002210
2211 // TODO: construct an explicit SQL query so that we can add
2212 // "GROUPBY" instead of doing a sort and de-dup
RoboErik083cd2d2011-06-30 11:53:05 -07002213 Cursor cursor = cr.query(CalendarAlerts.CONTENT_URI, projection,
2214 WHERE_RESCHEDULE_MISSED_ALARMS, (new String[] {
2215 Long.toString(now), Long.toString(ancient), Long.toString(now)
2216 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002217 if (cursor == null) {
2218 return;
2219 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002220
2221 if (DEBUG) {
The Android Open Source Project10592532009-03-18 17:39:46 -07002222 Log.d(TAG, "missed alarms found: " + cursor.getCount());
2223 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002224
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002225 try {
Michael Chancdaeafd2009-10-29 00:11:58 -07002226 long alarmTime = -1;
2227
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002228 while (cursor.moveToNext()) {
Michael Chancdaeafd2009-10-29 00:11:58 -07002229 long newAlarmTime = cursor.getLong(0);
2230 if (alarmTime != newAlarmTime) {
2231 if (DEBUG) {
2232 Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime);
2233 }
2234 scheduleAlarm(context, manager, newAlarmTime);
2235 alarmTime = newAlarmTime;
2236 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002237 }
2238 } finally {
2239 cursor.close();
2240 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002241 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002242
RoboErikc2d53302011-06-03 09:37:58 -07002243 /**
2244 * Schedules an alarm intent with the system AlarmManager that will
RoboErik3771fcb2011-06-16 15:41:31 -07002245 * notify listeners when a reminder should be fired. The provider will
2246 * keep scheduled reminders up to date but apps may use this to
2247 * implement snooze functionality without modifying the reminders table.
2248 * Scheduled alarms will generate an intent using
RoboErik083cd2d2011-06-30 11:53:05 -07002249 * {@link #ACTION_EVENT_REMINDER}. TODO Move to provider
RoboErikc2d53302011-06-03 09:37:58 -07002250 *
2251 * @param context A context for referencing system resources
2252 * @param manager The AlarmManager to use or null
2253 * @param alarmTime The time to fire the intent in UTC millis since
2254 * epoch
RoboErik083cd2d2011-06-30 11:53:05 -07002255 * @hide
RoboErikc2d53302011-06-03 09:37:58 -07002256 */
Michael Chancdaeafd2009-10-29 00:11:58 -07002257 public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) {
2258 if (DEBUG) {
2259 Time time = new Time();
2260 time.set(alarmTime);
2261 String schedTime = time.format(" %a, %b %d, %Y %I:%M%P");
2262 Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime);
2263 }
2264
2265 if (manager == null) {
2266 manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
2267 }
2268
RoboErike00d5892011-06-23 15:16:55 -07002269 Intent intent = new Intent(ACTION_EVENT_REMINDER);
RoboErikbec6c362011-06-14 11:06:01 -07002270 intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime));
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002271 intent.putExtra(ALARM_TIME, alarmTime);
Erik42f19572010-03-17 16:17:22 -07002272 PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
Michael Chancdaeafd2009-10-29 00:11:58 -07002273 manager.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002274 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002275
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002276 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002277 * Searches for an entry in the CalendarAlerts table that matches the
2278 * given event id, begin time and alarm time. If one is found then this
2279 * alarm already exists and this method returns true. TODO Move to
2280 * provider
RoboErik58644022011-07-08 13:39:05 -07002281 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002282 * @param cr the ContentResolver
2283 * @param eventId the event id to match
2284 * @param begin the start time of the event in UTC millis
2285 * @param alarmTime the alarm time of the event in UTC millis
RoboErik083cd2d2011-06-30 11:53:05 -07002286 * @return true if there is already an alarm for the given event with
2287 * the same start time and alarm time.
2288 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002289 */
2290 public static final boolean alarmExists(ContentResolver cr, long eventId,
2291 long begin, long alarmTime) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002292 // TODO: construct an explicit SQL query so that we can add
2293 // "LIMIT 1" to the end and get just one result.
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002294 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002295 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_ALARM_EXISTS,
2296 (new String[] {
2297 Long.toString(eventId), Long.toString(begin), Long.toString(alarmTime)
2298 }), null);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002299 boolean found = false;
2300 try {
2301 if (cursor != null && cursor.getCount() > 0) {
2302 found = true;
2303 }
2304 } finally {
2305 if (cursor != null) {
2306 cursor.close();
2307 }
2308 }
2309 return found;
2310 }
2311 }
2312
RoboErikf8143c52011-09-28 15:16:00 -07002313 protected interface ColorsColumns extends SyncStateContract.Columns {
2314
2315 /**
2316 * The type of color, which describes how it should be used. Valid types
2317 * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name.
2318 * <P>
2319 * Type: INTEGER (NOT NULL)
2320 * </P>
2321 */
2322 public static final String COLOR_TYPE = "color_type";
2323
2324 /**
2325 * This indicateds a color that can be used for calendars.
2326 */
2327 public static final int TYPE_CALENDAR = 0;
2328 /**
2329 * This indicates a color that can be used for events.
2330 */
2331 public static final int TYPE_EVENT = 1;
2332
2333 /**
RoboErik4172d952011-10-25 13:59:13 -07002334 * The key used to reference this color. This can be any non-empty
RoboErikf8143c52011-09-28 15:16:00 -07002335 * string, but must be unique for a given {@link #ACCOUNT_TYPE} and
RoboErik8a8eebc2011-10-20 16:57:18 -07002336 * {@link #ACCOUNT_NAME}. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002337 * <P>
2338 * Type: TEXT
2339 * </P>
2340 */
RoboErik4172d952011-10-25 13:59:13 -07002341 public static final String COLOR_KEY = "color_index";
RoboErikf8143c52011-09-28 15:16:00 -07002342
2343 /**
RoboErik05b36e52011-10-14 15:31:15 -07002344 * The color as an 8-bit ARGB integer value. Colors should specify alpha
2345 * as fully opaque (eg 0xFF993322) as the alpha may be ignored or
2346 * modified for display. It is reccomended that colors be usable with
2347 * light (near white) text. Apps should not depend on that assumption,
2348 * however. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002349 * <P>
2350 * Type: INTEGER (NOT NULL)
2351 * </P>
2352 */
RoboErik05b36e52011-10-14 15:31:15 -07002353 public static final String COLOR = "color";
RoboErikf8143c52011-09-28 15:16:00 -07002354
2355 }
2356
2357 /**
2358 * Fields for accessing colors available for a given account. Colors are
RoboErik4172d952011-10-25 13:59:13 -07002359 * referenced by {@link #COLOR_KEY} which must be unique for a given
RoboErik0c559c62011-10-21 11:20:51 -07002360 * account name/type. These values can only be updated by the sync
RoboErik8a8eebc2011-10-20 16:57:18 -07002361 * adapter. Only {@link #COLOR} may be updated after the initial insert. In
2362 * addition, a row can only be deleted once all references to that color
2363 * have been removed from the {@link Calendars} or {@link Events} tables.
RoboErikf8143c52011-09-28 15:16:00 -07002364 */
2365 public static final class Colors implements ColorsColumns {
2366 /**
2367 * @hide
2368 */
2369 public static final String TABLE_NAME = "Colors";
2370 /**
2371 * The Uri for querying color information
2372 */
2373 @SuppressWarnings("hiding")
2374 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors");
2375
2376 /**
2377 * This utility class cannot be instantiated
2378 */
2379 private Colors() {
2380 }
2381 }
2382
RoboErikb2c75602011-06-13 12:53:48 -07002383 protected interface ExtendedPropertiesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002384 /**
RoboErikc2d53302011-06-03 09:37:58 -07002385 * The event the extended property belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002386 * <P>Type: INTEGER (foreign key to the Events table)</P>
2387 */
2388 public static final String EVENT_ID = "event_id";
2389
2390 /**
2391 * The name of the extended property. This is a uri of the form
RoboErikc2d53302011-06-03 09:37:58 -07002392 * {scheme}#{local-name} convention. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002393 * <P>Type: TEXT</P>
2394 */
2395 public static final String NAME = "name";
2396
2397 /**
RoboErikc2d53302011-06-03 09:37:58 -07002398 * The value of the extended property. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002399 * <P>Type: TEXT</P>
2400 */
2401 public static final String VALUE = "value";
2402 }
2403
RoboErikc2d53302011-06-03 09:37:58 -07002404 /**
2405 * Fields for accessing the Extended Properties. This is a generic set of
Michael Chan73bddfc2011-10-19 18:21:49 -07002406 * name/value pairs for use by sync adapters to add extra
RoboErik3771fcb2011-06-16 15:41:31 -07002407 * information to events. There are three writable columns and all three
2408 * must be present when inserting a new value. They are:
2409 * <ul>
2410 * <li>{@link #EVENT_ID}</li>
2411 * <li>{@link #NAME}</li>
2412 * <li>{@link #VALUE}</li>
2413 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07002414 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002415 public static final class ExtendedProperties implements BaseColumns,
2416 ExtendedPropertiesColumns, EventsColumns {
2417 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002418 Uri.parse("content://" + AUTHORITY + "/extendedproperties");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002419
RoboErik36726962011-06-14 14:01:15 -07002420 /**
2421 * This utility class cannot be instantiated
2422 */
2423 private ExtendedProperties() {}
2424
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002425 // TODO: fill out this class when we actually start utilizing extendedproperties
2426 // in the calendar application.
2427 }
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002428
2429 /**
2430 * A table provided for sync adapters to use for storing private sync state data.
2431 *
2432 * @see SyncStateContract
2433 */
2434 public static final class SyncState implements SyncStateContract.Columns {
2435 /**
2436 * This utility class cannot be instantiated
2437 */
2438 private SyncState() {}
2439
RoboErikc2d53302011-06-03 09:37:58 -07002440 private static final String CONTENT_DIRECTORY =
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002441 SyncStateContract.Constants.CONTENT_DIRECTORY;
2442
2443 /**
2444 * The content:// style URI for this table
2445 */
2446 public static final Uri CONTENT_URI =
RoboErikbec6c362011-06-14 11:06:01 -07002447 Uri.withAppendedPath(CalendarContract.CONTENT_URI, CONTENT_DIRECTORY);
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002448 }
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002449
2450 /**
2451 * Columns from the EventsRawTimes table
RoboErik3771fcb2011-06-16 15:41:31 -07002452 *
2453 * @hide
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002454 */
RoboErikb2c75602011-06-13 12:53:48 -07002455 protected interface EventsRawTimesColumns {
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002456 /**
RoboErikc2d53302011-06-03 09:37:58 -07002457 * The corresponding event id. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002458 * <P>Type: INTEGER (long)</P>
2459 */
2460 public static final String EVENT_ID = "event_id";
2461
2462 /**
RoboErikc2d53302011-06-03 09:37:58 -07002463 * The RFC2445 compliant time the event starts. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002464 * <P>Type: TEXT</P>
2465 */
2466 public static final String DTSTART_2445 = "dtstart2445";
2467
2468 /**
RoboErikc2d53302011-06-03 09:37:58 -07002469 * The RFC2445 compliant time the event ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002470 * <P>Type: TEXT</P>
2471 */
2472 public static final String DTEND_2445 = "dtend2445";
2473
2474 /**
RoboErikc2d53302011-06-03 09:37:58 -07002475 * The RFC2445 compliant original instance time of the recurring event
2476 * for which this event is an exception. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002477 * <P>Type: TEXT</P>
2478 */
2479 public static final String ORIGINAL_INSTANCE_TIME_2445 = "originalInstanceTime2445";
2480
2481 /**
RoboErikc2d53302011-06-03 09:37:58 -07002482 * The RFC2445 compliant last date this event repeats on, or NULL if it
2483 * never ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002484 * <P>Type: TEXT</P>
2485 */
2486 public static final String LAST_DATE_2445 = "lastDate2445";
2487 }
2488
RoboErikc2d53302011-06-03 09:37:58 -07002489 /**
2490 * @hide
2491 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002492 public static final class EventsRawTimes implements BaseColumns, EventsRawTimesColumns {
RoboErik36726962011-06-14 14:01:15 -07002493
2494 /**
2495 * This utility class cannot be instantiated
2496 */
2497 private EventsRawTimes() {}
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002498 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002499}