CalendarContract.java revision 8a8eebcbe8e3aded682c9c4937e155218ddf7ff4
1/* 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 19 20import android.annotation.SdkConstant; 21import android.annotation.SdkConstant.SdkConstantType; 22import android.app.AlarmManager; 23import android.app.PendingIntent; 24import android.content.ContentProviderClient; 25import android.content.ContentResolver; 26import android.content.ContentUris; 27import android.content.ContentValues; 28import android.content.Context; 29import android.content.CursorEntityIterator; 30import android.content.Entity; 31import android.content.EntityIterator; 32import android.content.Intent; 33import android.database.Cursor; 34import android.database.DatabaseUtils; 35import android.net.Uri; 36import android.os.RemoteException; 37import android.text.format.DateUtils; 38import android.text.format.Time; 39import android.util.Log; 40 41/** 42 * <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> 75 * <li>The {@link ExtendedProperties} table holds opaque data fields used by the 76 * 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> 87 * 88 */ 89public final class CalendarContract { 90 private static final String TAG = "Calendar"; 91 92 /** 93 * Broadcast Action: This is the intent that gets fired when an alarm 94 * notification needs to be posted for a reminder. 95 * 96 */ 97 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 98 public static final String ACTION_EVENT_REMINDER = "android.intent.action.EVENT_REMINDER"; 99 100 /** 101 * Intent Extras key: The start time of an event or an instance of a 102 * recurring event. (milliseconds since epoch) 103 */ 104 public static final String EXTRA_EVENT_BEGIN_TIME = "beginTime"; 105 106 /** 107 * Intent Extras key: The end time of an event or an instance of a recurring 108 * event. (milliseconds since epoch) 109 */ 110 public static final String EXTRA_EVENT_END_TIME = "endTime"; 111 112 /** 113 * 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 /** 119 * 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. 122 */ 123 public static final String AUTHORITY = "com.android.calendar"; 124 125 /** 126 * The content:// style URL for the top-level calendar authority 127 */ 128 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY); 129 130 /** 131 * An optional insert, update or delete URI parameter that allows the caller 132 * 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 138 * {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as 139 * query parameters. 140 * 141 * @see Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String) 142 */ 143 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; 144 145 /** 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"; 154 155 /** 156 * This utility class cannot be instantiated 157 */ 158 private CalendarContract() {} 159 160 /** 161 * 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. 166 */ 167 protected interface CalendarSyncColumns { 168 169 170 /** 171 * Generic column for use by sync adapters. Column name. 172 * <P>Type: TEXT</P> 173 */ 174 public static final String CAL_SYNC1 = "cal_sync1"; 175 176 /** 177 * Generic column for use by sync adapters. Column name. 178 * <P>Type: TEXT</P> 179 */ 180 public static final String CAL_SYNC2 = "cal_sync2"; 181 182 /** 183 * Generic column for use by sync adapters. Column name. 184 * <P>Type: TEXT</P> 185 */ 186 public static final String CAL_SYNC3 = "cal_sync3"; 187 188 /** 189 * Generic column for use by sync adapters. Column name. 190 * <P>Type: TEXT</P> 191 */ 192 public static final String CAL_SYNC4 = "cal_sync4"; 193 194 /** 195 * Generic column for use by sync adapters. Column name. 196 * <P>Type: TEXT</P> 197 */ 198 public static final String CAL_SYNC5 = "cal_sync5"; 199 200 /** 201 * Generic column for use by sync adapters. Column name. 202 * <P>Type: TEXT</P> 203 */ 204 public static final String CAL_SYNC6 = "cal_sync6"; 205 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"; 229 } 230 231 /** 232 * 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 * 236 */ 237 protected interface SyncColumns extends CalendarSyncColumns { 238 /** 239 * 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. 243 * <P>Type: TEXT</P> 244 */ 245 public static final String ACCOUNT_NAME = "account_name"; 246 247 /** 248 * 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. 251 * <P>Type: TEXT</P> 252 */ 253 public static final String ACCOUNT_TYPE = "account_type"; 254 255 /** 256 * 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}. 259 * <P>Type: TEXT</P> 260 */ 261 public static final String _SYNC_ID = "_sync_id"; 262 263 /** 264 * Used to indicate that local, unsynced, changes are present. 265 * <P>Type: INTEGER (long)</P> 266 */ 267 public static final String DIRTY = "dirty"; 268 269 /** 270 * 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 /** 279 * If set to 1 this causes events on this calendar to be duplicated with 280 * {@link Events#LAST_SYNCED} set to 1 whenever the event 281 * 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 284 * 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"; 288 } 289 290 /** 291 * Columns specific to the Calendars Uri that other Uris can query. 292 */ 293 protected interface CalendarColumns { 294 /** 295 * 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. 298 * <P>Type: INTEGER (color value)</P> 299 */ 300 public static final String CALENDAR_COLOR = "calendar_color"; 301 302 /** 303 * An index for looking up a color from the {@link Colors} table. NULL 304 * or an empty string are reserved for indicating that the calendar does 305 * not use an index for looking up the color. The provider will update 306 * {@link #CALENDAR_COLOR} automatically when a valid index is written 307 * to this column. The index must reference an existing row of the 308 * {@link Colors} table. @see Colors 309 * <P> 310 * Type: TEXT 311 * </P> 312 * TODO UNHIDE 313 * 314 * @hide 315 */ 316 public static final String CALENDAR_COLOR_INDEX = "calendar_color_index"; 317 318 /** 319 * The display name of the calendar. Column name. 320 * <P> 321 * Type: TEXT 322 * </P> 323 */ 324 public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName"; 325 326 /** 327 * The level of access that the user has for the calendar 328 * <P>Type: INTEGER (one of the values below)</P> 329 */ 330 public static final String CALENDAR_ACCESS_LEVEL = "calendar_access_level"; 331 332 /** Cannot access the calendar */ 333 public static final int CAL_ACCESS_NONE = 0; 334 /** Can only see free/busy information about the calendar */ 335 public static final int CAL_ACCESS_FREEBUSY = 100; 336 /** Can read all event details */ 337 public static final int CAL_ACCESS_READ = 200; 338 /** Can reply yes/no/maybe to an event */ 339 public static final int CAL_ACCESS_RESPOND = 300; 340 /** not used */ 341 public static final int CAL_ACCESS_OVERRIDE = 400; 342 /** Full access to modify the calendar, but not the access control 343 * settings 344 */ 345 public static final int CAL_ACCESS_CONTRIBUTOR = 500; 346 /** Full access to modify the calendar, but not the access control 347 * settings 348 */ 349 public static final int CAL_ACCESS_EDITOR = 600; 350 /** Full access to the calendar */ 351 public static final int CAL_ACCESS_OWNER = 700; 352 /** Domain admin */ 353 public static final int CAL_ACCESS_ROOT = 800; 354 355 /** 356 * Is the calendar selected to be displayed? 357 * 0 - do not show events associated with this calendar. 358 * 1 - show events associated with this calendar 359 * <P>Type: INTEGER (boolean)</P> 360 */ 361 public static final String VISIBLE = "visible"; 362 363 /** 364 * The time zone the calendar is associated with. 365 * <P>Type: TEXT</P> 366 */ 367 public static final String CALENDAR_TIME_ZONE = "calendar_timezone"; 368 369 /** 370 * Is this calendar synced and are its events stored on the device? 371 * 0 - Do not sync this calendar or store events for this calendar. 372 * 1 - Sync down events for this calendar. 373 * <p>Type: INTEGER (boolean)</p> 374 */ 375 public static final String SYNC_EVENTS = "sync_events"; 376 377 /** 378 * The owner account for this calendar, based on the calendar feed. 379 * This will be different from the _SYNC_ACCOUNT for delegated calendars. 380 * Column name. 381 * <P>Type: String</P> 382 */ 383 public static final String OWNER_ACCOUNT = "ownerAccount"; 384 385 /** 386 * Can the organizer respond to the event? If no, the status of the 387 * organizer should not be shown by the UI. Defaults to 1. Column name. 388 * <P>Type: INTEGER (boolean)</P> 389 */ 390 public static final String CAN_ORGANIZER_RESPOND = "canOrganizerRespond"; 391 392 /** 393 * Can the organizer modify the time zone of the event? Column name. 394 * <P>Type: INTEGER (boolean)</P> 395 */ 396 public static final String CAN_MODIFY_TIME_ZONE = "canModifyTimeZone"; 397 398 /** 399 * The maximum number of reminders allowed for an event. Column name. 400 * <P>Type: INTEGER</P> 401 */ 402 public static final String MAX_REMINDERS = "maxReminders"; 403 404 /** 405 * A comma separated list of reminder methods supported for this 406 * calendar in the format "#,#,#". Valid types are 407 * {@link Reminders#METHOD_DEFAULT}, {@link Reminders#METHOD_ALERT}, 408 * {@link Reminders#METHOD_EMAIL}, {@link Reminders#METHOD_SMS}. Column 409 * name. 410 * <P>Type: TEXT</P> 411 */ 412 public static final String ALLOWED_REMINDERS = "allowedReminders"; 413 414 /** 415 * A comma separated list of availability types supported for this 416 * calendar in the format "#,#,#". Valid types are 417 * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE}, 418 * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only 419 * {@link Events#AVAILABILITY_BUSY} should be used to indicate that 420 * changing the availability is not supported. 421 * 422 * TODO UNHIDE, Update Calendars doc 423 * 424 * @hide 425 */ 426 public static final String ALLOWED_AVAILABILITY = "allowedAvailability"; 427 428 /** 429 * A comma separated list of attendee types supported for this calendar 430 * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE}, 431 * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED}, 432 * {@link Attendees#TYPE_RESOURCE}. Setting this field to only 433 * {@link Attendees#TYPE_NONE} should be used to indicate that changing 434 * the attendee type is not supported. 435 * 436 * TODO UNHIDE, Update Calendars doc 437 * 438 * @hide 439 */ 440 public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes"; 441 } 442 443 /** 444 * Class that represents a Calendar Entity. There is one entry per calendar. 445 * This is a helper class to make batch operations easier. 446 */ 447 public static final class CalendarEntity implements BaseColumns, SyncColumns, CalendarColumns { 448 449 /** 450 * The default Uri used when creating a new calendar EntityIterator. 451 */ 452 @SuppressWarnings("hiding") 453 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + 454 "/calendar_entities"); 455 456 /** 457 * This utility class cannot be instantiated 458 */ 459 private CalendarEntity() {} 460 461 /** 462 * Creates an entity iterator for the given cursor. It assumes the 463 * cursor contains a calendars query. 464 * 465 * @param cursor query on {@link #CONTENT_URI} 466 * @return an EntityIterator of calendars 467 */ 468 public static EntityIterator newEntityIterator(Cursor cursor) { 469 return new EntityIteratorImpl(cursor); 470 } 471 472 private static class EntityIteratorImpl extends CursorEntityIterator { 473 474 public EntityIteratorImpl(Cursor cursor) { 475 super(cursor); 476 } 477 478 @Override 479 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { 480 // we expect the cursor is already at the row we need to read from 481 final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID)); 482 483 // Create the content value 484 ContentValues cv = new ContentValues(); 485 cv.put(_ID, calendarId); 486 487 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); 488 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); 489 490 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID); 491 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); 492 493 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1); 494 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2); 495 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3); 496 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4); 497 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5); 498 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6); 499 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7); 500 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8); 501 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9); 502 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10); 503 504 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME); 505 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 506 Calendars.CALENDAR_DISPLAY_NAME); 507 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, 508 Calendars.CALENDAR_COLOR); 509 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL); 510 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE); 511 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS); 512 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 513 Calendars.CALENDAR_LOCATION); 514 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE); 515 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 516 Calendars.OWNER_ACCOUNT); 517 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, 518 Calendars.CAN_ORGANIZER_RESPOND); 519 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, 520 Calendars.CAN_MODIFY_TIME_ZONE); 521 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, 522 Calendars.MAX_REMINDERS); 523 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, 524 Calendars.CAN_PARTIALLY_UPDATE); 525 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, 526 Calendars.ALLOWED_REMINDERS); 527 528 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); 529 530 // Create the Entity from the ContentValue 531 Entity entity = new Entity(cv); 532 533 // Set cursor to next row 534 cursor.moveToNext(); 535 536 // Return the created Entity 537 return entity; 538 } 539 } 540 } 541 542 /** 543 * Constants and helpers for the Calendars table, which contains details for 544 * individual calendars. <h3>Operations</h3> All operations can be done 545 * either as an app or as a sync adapter. To perform an operation as a sync 546 * adapter {@link #CALLER_IS_SYNCADAPTER} should be set to true and 547 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri 548 * parameters. See 549 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)} 550 * for details on adding parameters. Sync adapters have write access to more 551 * columns but are restricted to a single account at a time. Calendars are 552 * designed to be primarily managed by a sync adapter and inserting new 553 * calendars should be done as a sync adapter. For the most part, apps 554 * should only update calendars (such as changing the color or display 555 * name). If a local calendar is required an app can do so by inserting as a 556 * sync adapter and using an {@link #ACCOUNT_TYPE} of 557 * {@link #ACCOUNT_TYPE_LOCAL} . 558 * <dl> 559 * <dt><b>Insert</b></dt> 560 * <dd>When inserting a new calendar the following fields must be included: 561 * <ul> 562 * <li>{@link #ACCOUNT_NAME}</li> 563 * <li>{@link #ACCOUNT_TYPE}</li> 564 * <li>{@link #NAME}</li> 565 * <li>{@link #CALENDAR_DISPLAY_NAME}</li> 566 * <li>{@link #CALENDAR_COLOR}</li> 567 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li> 568 * <li>{@link #OWNER_ACCOUNT}</li> 569 * </ul> 570 * The following fields are not required when inserting a Calendar but are 571 * generally a good idea to include: 572 * <ul> 573 * <li>{@link #SYNC_EVENTS} set to 1</li> 574 * <li>{@link #CALENDAR_TIME_ZONE}</li> 575 * <li>{@link #ALLOWED_REMINDERS}</li> 576 * </ul> 577 * <dt><b>Update</b></dt> 578 * <dd>To perform an update on a calendar the {@link #_ID} of the calendar 579 * should be provided either as an appended id to the Uri ( 580 * {@link ContentUris#withAppendedId}) or as the first selection item--the 581 * selection should start with "_id=?" and the first selectionArg should be 582 * the _id of the calendar. Calendars may also be updated using a selection 583 * without the id. In general, the {@link #ACCOUNT_NAME} and 584 * {@link #ACCOUNT_TYPE} should not be changed after a calendar is created 585 * as this can cause issues for sync adapters. 586 * <dt><b>Delete</b></dt> 587 * <dd>Calendars can be deleted either by the {@link #_ID} as an appended id 588 * on the Uri or using any standard selection. Deleting a calendar should 589 * generally be handled by a sync adapter as it will remove the calendar 590 * from the database and all associated data (aka events).</dd> 591 * <dt><b>Query</b></dt> 592 * <dd>Querying the Calendars table will get you all information about a set 593 * of calendars. There will be one row returned for each calendar that 594 * matches the query selection, or at most a single row if the {@link #_ID} 595 * is appended to the Uri.</dd> 596 * </dl> 597 * <h3>Calendar Columns</h3> The following Calendar columns are writable by 598 * both an app and a sync adapter. 599 * <ul> 600 * <li>{@link #NAME}</li> 601 * <li>{@link #CALENDAR_DISPLAY_NAME}</li> 602 * <li>{@link #VISIBLE}</li> 603 * <li>{@link #SYNC_EVENTS}</li> 604 * </ul> 605 * The following Calendars columns are writable only by a sync adapter 606 * <ul> 607 * <li>{@link #ACCOUNT_NAME}</li> 608 * <li>{@link #ACCOUNT_TYPE}</li> 609 * <li>{@link #CALENDAR_COLOR}</li> 610 * <li>{@link #_SYNC_ID}</li> 611 * <li>{@link #DIRTY}</li> 612 * <li>{@link #OWNER_ACCOUNT}</li> 613 * <li>{@link #MAX_REMINDERS}</li> 614 * <li>{@link #ALLOWED_REMINDERS}</li> 615 * <li>{@link #CAN_MODIFY_TIME_ZONE}</li> 616 * <li>{@link #CAN_ORGANIZER_RESPOND}</li> 617 * <li>{@link #CAN_PARTIALLY_UPDATE}</li> 618 * <li>{@link #CALENDAR_LOCATION}</li> 619 * <li>{@link #CALENDAR_TIME_ZONE}</li> 620 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li> 621 * <li>{@link #DELETED}</li> 622 * <li>{@link #CAL_SYNC1}</li> 623 * <li>{@link #CAL_SYNC2}</li> 624 * <li>{@link #CAL_SYNC3}</li> 625 * <li>{@link #CAL_SYNC4}</li> 626 * <li>{@link #CAL_SYNC5}</li> 627 * <li>{@link #CAL_SYNC6}</li> 628 * <li>{@link #CAL_SYNC7}</li> 629 * <li>{@link #CAL_SYNC8}</li> 630 * <li>{@link #CAL_SYNC9}</li> 631 * <li>{@link #CAL_SYNC10}</li> 632 * </ul> 633 */ 634 public static final class Calendars implements BaseColumns, SyncColumns, CalendarColumns { 635 636 /** 637 * This utility class cannot be instantiated 638 */ 639 private Calendars() {} 640 641 /** 642 * The content:// style URL for accessing Calendars 643 */ 644 @SuppressWarnings("hiding") 645 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/calendars"); 646 647 /** 648 * The default sort order for this table 649 */ 650 public static final String DEFAULT_SORT_ORDER = CALENDAR_DISPLAY_NAME; 651 652 /** 653 * The name of the calendar. Column name. 654 * <P>Type: TEXT</P> 655 */ 656 public static final String NAME = "name"; 657 658 /** 659 * The default location for the calendar. Column name. 660 * <P>Type: TEXT</P> 661 */ 662 public static final String CALENDAR_LOCATION = "calendar_location"; 663 664 /** 665 * These fields are only writable by a sync adapter. To modify them the 666 * caller must include {@link #CALLER_IS_SYNCADAPTER}, 667 * {@link #ACCOUNT_NAME}, and {@link #ACCOUNT_TYPE} in the Uri's query 668 * parameters. TODO move to provider 669 * 670 * @hide 671 */ 672 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] { 673 ACCOUNT_NAME, 674 ACCOUNT_TYPE, 675 _SYNC_ID, 676 DIRTY, 677 OWNER_ACCOUNT, 678 MAX_REMINDERS, 679 ALLOWED_REMINDERS, 680 CAN_MODIFY_TIME_ZONE, 681 CAN_ORGANIZER_RESPOND, 682 CAN_PARTIALLY_UPDATE, 683 CALENDAR_LOCATION, 684 CALENDAR_TIME_ZONE, 685 CALENDAR_ACCESS_LEVEL, 686 DELETED, 687 CAL_SYNC1, 688 CAL_SYNC2, 689 CAL_SYNC3, 690 CAL_SYNC4, 691 CAL_SYNC5, 692 CAL_SYNC6, 693 CAL_SYNC7, 694 CAL_SYNC8, 695 CAL_SYNC9, 696 CAL_SYNC10, 697 }; 698 } 699 700 /** 701 * Columns from the Attendees table that other tables join into themselves. 702 */ 703 protected interface AttendeesColumns { 704 705 /** 706 * The id of the event. Column name. 707 * <P>Type: INTEGER</P> 708 */ 709 public static final String EVENT_ID = "event_id"; 710 711 /** 712 * The name of the attendee. Column name. 713 * <P>Type: STRING</P> 714 */ 715 public static final String ATTENDEE_NAME = "attendeeName"; 716 717 /** 718 * The email address of the attendee. Column name. 719 * <P>Type: STRING</P> 720 */ 721 public static final String ATTENDEE_EMAIL = "attendeeEmail"; 722 723 /** 724 * The relationship of the attendee to the user. Column name. 725 * <P>Type: INTEGER (one of {@link #RELATIONSHIP_ATTENDEE}, ...}.</P> 726 */ 727 public static final String ATTENDEE_RELATIONSHIP = "attendeeRelationship"; 728 729 public static final int RELATIONSHIP_NONE = 0; 730 public static final int RELATIONSHIP_ATTENDEE = 1; 731 public static final int RELATIONSHIP_ORGANIZER = 2; 732 public static final int RELATIONSHIP_PERFORMER = 3; 733 public static final int RELATIONSHIP_SPEAKER = 4; 734 735 /** 736 * The type of attendee. Column name. 737 * <P> 738 * Type: Integer (one of {@link #TYPE_REQUIRED}, {@link #TYPE_OPTIONAL} 739 * </P> 740 */ 741 public static final String ATTENDEE_TYPE = "attendeeType"; 742 743 public static final int TYPE_NONE = 0; 744 public static final int TYPE_REQUIRED = 1; 745 public static final int TYPE_OPTIONAL = 2; 746 /** 747 * This specifies that an attendee is a resource, such as a room, and 748 * not an actual person. TODO UNHIDE and add to ATTENDEE_TYPE comment 749 * 750 * @hide 751 */ 752 public static final int TYPE_RESOURCE = 3; 753 754 /** 755 * The attendance status of the attendee. Column name. 756 * <P>Type: Integer (one of {@link #ATTENDEE_STATUS_ACCEPTED}, ...).</P> 757 */ 758 public static final String ATTENDEE_STATUS = "attendeeStatus"; 759 760 public static final int ATTENDEE_STATUS_NONE = 0; 761 public static final int ATTENDEE_STATUS_ACCEPTED = 1; 762 public static final int ATTENDEE_STATUS_DECLINED = 2; 763 public static final int ATTENDEE_STATUS_INVITED = 3; 764 public static final int ATTENDEE_STATUS_TENTATIVE = 4; 765 } 766 767 /** 768 * Fields and helpers for interacting with Attendees. Each row of this table 769 * represents a single attendee or guest of an event. Calling 770 * {@link #query(ContentResolver, long, String[])} will return a list of attendees for 771 * the event with the given eventId. Both apps and sync adapters may write 772 * to this table. There are six writable fields and all of them except 773 * {@link #ATTENDEE_NAME} must be included when inserting a new attendee. 774 * They are: 775 * <ul> 776 * <li>{@link #EVENT_ID}</li> 777 * <li>{@link #ATTENDEE_NAME}</li> 778 * <li>{@link #ATTENDEE_EMAIL}</li> 779 * <li>{@link #ATTENDEE_RELATIONSHIP}</li> 780 * <li>{@link #ATTENDEE_TYPE}</li> 781 * <li>{@link #ATTENDEE_STATUS}</li> 782 * </ul> 783 */ 784 public static final class Attendees implements BaseColumns, AttendeesColumns, EventsColumns { 785 786 /** 787 * The content:// style URL for accessing Attendees data 788 */ 789 @SuppressWarnings("hiding") 790 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees"); 791 private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?"; 792 793 /** 794 * This utility class cannot be instantiated 795 */ 796 private Attendees() {} 797 798 /** 799 * Queries all attendees associated with the given event. This is a 800 * blocking call and should not be done on the UI thread. 801 * 802 * @param cr The content resolver to use for the query 803 * @param eventId The id of the event to retrieve attendees for 804 * @param projection the columns to return in the cursor 805 * @return A Cursor containing all attendees for the event 806 */ 807 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) { 808 String[] attArgs = {Long.toString(eventId)}; 809 return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */, 810 null /* sort order */); 811 } 812 } 813 814 /** 815 * Columns from the Events table that other tables join into themselves. 816 */ 817 protected interface EventsColumns { 818 819 /** 820 * The {@link Calendars#_ID} of the calendar the event belongs to. 821 * Column name. 822 * <P>Type: INTEGER</P> 823 */ 824 public static final String CALENDAR_ID = "calendar_id"; 825 826 /** 827 * The title of the event. Column name. 828 * <P>Type: TEXT</P> 829 */ 830 public static final String TITLE = "title"; 831 832 /** 833 * The description of the event. Column name. 834 * <P>Type: TEXT</P> 835 */ 836 public static final String DESCRIPTION = "description"; 837 838 /** 839 * Where the event takes place. Column name. 840 * <P>Type: TEXT</P> 841 */ 842 public static final String EVENT_LOCATION = "eventLocation"; 843 844 /** 845 * A secondary color for the individual event. This should only be 846 * updated by the sync adapter for a given account. 847 * <P>Type: INTEGER</P> 848 */ 849 public static final String EVENT_COLOR = "eventColor"; 850 851 /** 852 * A secondary color index for the individual event. NULL or an empty 853 * string are reserved for indicating that the event does not use an 854 * index for looking up the color. The provider will update 855 * {@link #EVENT_COLOR} automatically when a valid index is written to 856 * this column. The index must reference an existing row of the 857 * {@link Colors} table. @see Colors 858 * <P> 859 * Type: TEXT 860 * </P> 861 * TODO UNHIDE 862 * 863 * @hide 864 */ 865 public static final String EVENT_COLOR_INDEX = "eventColor_index"; 866 867 /** 868 * The event status. Column name. 869 * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P> 870 */ 871 public static final String STATUS = "eventStatus"; 872 873 public static final int STATUS_TENTATIVE = 0; 874 public static final int STATUS_CONFIRMED = 1; 875 public static final int STATUS_CANCELED = 2; 876 877 /** 878 * This is a copy of the attendee status for the owner of this event. 879 * This field is copied here so that we can efficiently filter out 880 * events that are declined without having to look in the Attendees 881 * table. Column name. 882 * 883 * <P>Type: INTEGER (int)</P> 884 */ 885 public static final String SELF_ATTENDEE_STATUS = "selfAttendeeStatus"; 886 887 /** 888 * This column is available for use by sync adapters. Column name. 889 * <P>Type: TEXT</P> 890 */ 891 public static final String SYNC_DATA1 = "sync_data1"; 892 893 /** 894 * This column is available for use by sync adapters. Column name. 895 * <P>Type: TEXT</P> 896 */ 897 public static final String SYNC_DATA2 = "sync_data2"; 898 899 /** 900 * This column is available for use by sync adapters. Column name. 901 * <P>Type: TEXT</P> 902 */ 903 public static final String SYNC_DATA3 = "sync_data3"; 904 905 /** 906 * This column is available for use by sync adapters. Column name. 907 * <P>Type: TEXT</P> 908 */ 909 public static final String SYNC_DATA4 = "sync_data4"; 910 911 /** 912 * This column is available for use by sync adapters. Column name. 913 * <P>Type: TEXT</P> 914 */ 915 public static final String SYNC_DATA5 = "sync_data5"; 916 917 /** 918 * This column is available for use by sync adapters. Column name. 919 * <P>Type: TEXT</P> 920 */ 921 public static final String SYNC_DATA6 = "sync_data6"; 922 923 /** 924 * This column is available for use by sync adapters. Column name. 925 * <P>Type: TEXT</P> 926 */ 927 public static final String SYNC_DATA7 = "sync_data7"; 928 929 /** 930 * This column is available for use by sync adapters. Column name. 931 * <P>Type: TEXT</P> 932 */ 933 public static final String SYNC_DATA8 = "sync_data8"; 934 935 /** 936 * This column is available for use by sync adapters. Column name. 937 * <P>Type: TEXT</P> 938 */ 939 public static final String SYNC_DATA9 = "sync_data9"; 940 941 /** 942 * This column is available for use by sync adapters. Column name. 943 * <P>Type: TEXT</P> 944 */ 945 public static final String SYNC_DATA10 = "sync_data10"; 946 947 /** 948 * Used to indicate that a row is not a real event but an original copy of a locally 949 * modified event. A copy is made when an event changes from non-dirty to dirty and the 950 * event is on a calendar with {@link Calendars#CAN_PARTIALLY_UPDATE} set to 1. This copy 951 * does not get expanded in the instances table and is only visible in queries made by a 952 * sync adapter. The copy gets removed when the event is changed back to non-dirty by a 953 * sync adapter. 954 * <P>Type: INTEGER (boolean)</P> 955 */ 956 public static final String LAST_SYNCED = "lastSynced"; 957 958 /** 959 * The time the event starts in UTC millis since epoch. Column name. 960 * <P>Type: INTEGER (long; millis since epoch)</P> 961 */ 962 public static final String DTSTART = "dtstart"; 963 964 /** 965 * The time the event ends in UTC millis since epoch. Column name. 966 * <P>Type: INTEGER (long; millis since epoch)</P> 967 */ 968 public static final String DTEND = "dtend"; 969 970 /** 971 * The duration of the event in RFC2445 format. Column name. 972 * <P>Type: TEXT (duration in RFC2445 format)</P> 973 */ 974 public static final String DURATION = "duration"; 975 976 /** 977 * The timezone for the event. Column name. 978 * <P>Type: TEXT</P> 979 */ 980 public static final String EVENT_TIMEZONE = "eventTimezone"; 981 982 /** 983 * The timezone for the end time of the event. Column name. 984 * <P>Type: TEXT</P> 985 */ 986 public static final String EVENT_END_TIMEZONE = "eventEndTimezone"; 987 988 /** 989 * Is the event all day (time zone independent). Column name. 990 * <P>Type: INTEGER (boolean)</P> 991 */ 992 public static final String ALL_DAY = "allDay"; 993 994 /** 995 * Defines how the event shows up for others when the calendar is 996 * shared. Column name. 997 * <P>Type: INTEGER (One of {@link #ACCESS_DEFAULT}, ...)</P> 998 */ 999 public static final String ACCESS_LEVEL = "accessLevel"; 1000 1001 /** 1002 * Default access is controlled by the server and will be treated as 1003 * public on the device. 1004 */ 1005 public static final int ACCESS_DEFAULT = 0; 1006 /** 1007 * Confidential is not used by the app. 1008 */ 1009 public static final int ACCESS_CONFIDENTIAL = 1; 1010 /** 1011 * Private shares the event as a free/busy slot with no details. 1012 */ 1013 public static final int ACCESS_PRIVATE = 2; 1014 /** 1015 * Public makes the contents visible to anyone with access to the 1016 * calendar. 1017 */ 1018 public static final int ACCESS_PUBLIC = 3; 1019 1020 /** 1021 * If this event counts as busy time or is still free time that can be 1022 * scheduled over. Column name. 1023 * <P>Type: INTEGER (One of {@link #AVAILABILITY_BUSY}, 1024 * {@link #AVAILABILITY_FREE})</P> 1025 */ 1026 public static final String AVAILABILITY = "availability"; 1027 1028 /** 1029 * Indicates that this event takes up time and will conflict with other 1030 * events. 1031 */ 1032 public static final int AVAILABILITY_BUSY = 0; 1033 /** 1034 * Indicates that this event is free time and will not conflict with 1035 * other events. 1036 */ 1037 public static final int AVAILABILITY_FREE = 1; 1038 /** 1039 * Indicates that the owner's availability may change, but should be 1040 * considered busy time that will conflict. 1041 * 1042 * TODO UNHIDE 1043 * 1044 * @hide 1045 */ 1046 public static final int AVAILABILITY_TENTATIVE = 2; 1047 1048 /** 1049 * Whether the event has an alarm or not. Column name. 1050 * <P>Type: INTEGER (boolean)</P> 1051 */ 1052 public static final String HAS_ALARM = "hasAlarm"; 1053 1054 /** 1055 * Whether the event has extended properties or not. Column name. 1056 * <P>Type: INTEGER (boolean)</P> 1057 */ 1058 public static final String HAS_EXTENDED_PROPERTIES = "hasExtendedProperties"; 1059 1060 /** 1061 * The recurrence rule for the event. Column name. 1062 * <P>Type: TEXT</P> 1063 */ 1064 public static final String RRULE = "rrule"; 1065 1066 /** 1067 * The recurrence dates for the event. Column name. 1068 * <P>Type: TEXT</P> 1069 */ 1070 public static final String RDATE = "rdate"; 1071 1072 /** 1073 * The recurrence exception rule for the event. Column name. 1074 * <P>Type: TEXT</P> 1075 */ 1076 public static final String EXRULE = "exrule"; 1077 1078 /** 1079 * The recurrence exception dates for the event. Column name. 1080 * <P>Type: TEXT</P> 1081 */ 1082 public static final String EXDATE = "exdate"; 1083 1084 /** 1085 * The {@link Events#_ID} of the original recurring event for which this 1086 * event is an exception. Column name. 1087 * <P>Type: TEXT</P> 1088 */ 1089 public static final String ORIGINAL_ID = "original_id"; 1090 1091 /** 1092 * The _sync_id of the original recurring event for which this event is 1093 * an exception. The provider should keep the original_id in sync when 1094 * this is updated. Column name. 1095 * <P>Type: TEXT</P> 1096 */ 1097 public static final String ORIGINAL_SYNC_ID = "original_sync_id"; 1098 1099 /** 1100 * The original instance time of the recurring event for which this 1101 * event is an exception. Column name. 1102 * <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 1108 * for which this event is an exception. Column name. 1109 * <P>Type: INTEGER (boolean)</P> 1110 */ 1111 public static final String ORIGINAL_ALL_DAY = "originalAllDay"; 1112 1113 /** 1114 * The last date this event repeats on, or NULL if it never ends. Column 1115 * name. 1116 * <P>Type: INTEGER (long; millis since epoch)</P> 1117 */ 1118 public static final String LAST_DATE = "lastDate"; 1119 1120 /** 1121 * Whether the event has attendee information. True if the event 1122 * has full attendee data, false if the event has information about 1123 * self only. Column name. 1124 * <P>Type: INTEGER (boolean)</P> 1125 */ 1126 public static final String HAS_ATTENDEE_DATA = "hasAttendeeData"; 1127 1128 /** 1129 * Whether guests can modify the event. Column name. 1130 * <P>Type: INTEGER (boolean)</P> 1131 */ 1132 public static final String GUESTS_CAN_MODIFY = "guestsCanModify"; 1133 1134 /** 1135 * Whether guests can invite other guests. Column name. 1136 * <P>Type: INTEGER (boolean)</P> 1137 */ 1138 public static final String GUESTS_CAN_INVITE_OTHERS = "guestsCanInviteOthers"; 1139 1140 /** 1141 * Whether guests can see the list of attendees. Column name. 1142 * <P>Type: INTEGER (boolean)</P> 1143 */ 1144 public static final String GUESTS_CAN_SEE_GUESTS = "guestsCanSeeGuests"; 1145 1146 /** 1147 * Email of the organizer (owner) of the event. Column name. 1148 * <P>Type: STRING</P> 1149 */ 1150 public static final String ORGANIZER = "organizer"; 1151 1152 /** 1153 * 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. 1158 * <P>Type: INTEGER (boolean, readonly)</P> 1159 */ 1160 public static final String CAN_INVITE_OTHERS = "canInviteOthers"; 1161 } 1162 1163 /** 1164 * 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. 1169 */ 1170 public static final class EventsEntity implements BaseColumns, SyncColumns, EventsColumns { 1171 /** 1172 * The content:// style URL for this table 1173 */ 1174 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + 1175 "/event_entities"); 1176 1177 /** 1178 * This utility class cannot be instantiated 1179 */ 1180 private EventsEntity() {} 1181 1182 /** 1183 * 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 */ 1190 public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) { 1191 return new EntityIteratorImpl(cursor, resolver); 1192 } 1193 1194 /** 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 */ 1202 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[] { 1231 ExtendedProperties._ID, 1232 ExtendedProperties.NAME, 1233 ExtendedProperties.VALUE 1234 }; 1235 private static final int COLUMN_ID = 0; 1236 private static final int COLUMN_NAME = 1; 1237 private static final int COLUMN_VALUE = 2; 1238 1239 private static final String WHERE_EVENT_ID = "event_id=?"; 1240 1241 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 1253 @Override 1254 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); 1260 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); 1265 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTSTART); 1266 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTEND); 1267 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DURATION); 1268 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_TIMEZONE); 1269 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_END_TIMEZONE); 1270 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ALL_DAY); 1271 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL); 1272 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, AVAILABILITY); 1273 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); 1280 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_SYNC_ID); 1281 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_ID); 1282 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); 1293 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); 1294 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED); 1295 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); 1296 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); 1306 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); 1312 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); 1316 1317 Entity entity = new Entity(cv); 1318 Cursor subCursor; 1319 if (mResolver != null) { 1320 subCursor = mResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION, 1321 WHERE_EVENT_ID, 1322 new String[] { Long.toString(eventId) } /* selectionArgs */, 1323 null /* sortOrder */); 1324 } else { 1325 subCursor = mProvider.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION, 1326 WHERE_EVENT_ID, 1327 new String[] { Long.toString(eventId) } /* selectionArgs */, 1328 null /* sortOrder */); 1329 } 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, 1343 WHERE_EVENT_ID, 1344 new String[] { Long.toString(eventId) } /* selectionArgs */, 1345 null /* sortOrder */); 1346 } else { 1347 subCursor = mProvider.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION, 1348 WHERE_EVENT_ID, 1349 new String[] { Long.toString(eventId) } /* selectionArgs */, 1350 null /* sortOrder */); 1351 } 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, 1373 WHERE_EVENT_ID, 1374 new String[] { Long.toString(eventId) } /* selectionArgs */, 1375 null /* sortOrder */); 1376 } else { 1377 subCursor = mProvider.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION, 1378 WHERE_EVENT_ID, 1379 new String[] { Long.toString(eventId) } /* selectionArgs */, 1380 null /* sortOrder */); 1381 } 1382 try { 1383 while (subCursor.moveToNext()) { 1384 ContentValues extendedValues = new ContentValues(); 1385 extendedValues.put(ExtendedProperties._ID, 1386 subCursor.getString(COLUMN_ID)); 1387 extendedValues.put(ExtendedProperties.NAME, 1388 subCursor.getString(COLUMN_NAME)); 1389 extendedValues.put(ExtendedProperties.VALUE, 1390 subCursor.getString(COLUMN_VALUE)); 1391 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 /** 1404 * 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. 1413 * <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> 1418 * <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> 1421 * <li>a calendar_id</li> 1422 * </ul> 1423 * There are also further requirements when inserting or updating an event. 1424 * See the section on Writing to Events.</dd> 1425 * <dt><b>Update</b></dt> 1426 * <dd>To perform an update of an Event the {@link Events#_ID} of the event 1427 * should be provided either as an appended id to the Uri ( 1428 * {@link ContentUris#withAppendedId}) or as the first selection item--the 1429 * selection should start with "_id=?" and the first selectionArg should be 1430 * the _id of the event. Updates may also be done using a selection and no 1431 * id. Updating an event must respect the same rules as inserting and is 1432 * further restricted in the fields that can be written. See the section on 1433 * Writing to Events.</dd> 1434 * <dt><b>Delete</b></dt> 1435 * <dd>Events can be deleted either by the {@link Events#_ID} as an appended 1436 * id on the Uri or using any standard selection. If an appended id is used 1437 * a selection is not allowed. There are two versions of delete: as an app 1438 * and as a sync adapter. An app delete will set the deleted column on an 1439 * event and remove all instances of that event. A sync adapter delete will 1440 * remove the event from the database and all associated data.</dd> 1441 * <dt><b>Query</b></dt> 1442 * <dd>Querying the Events table will get you all information about a set of 1443 * events except their reminders, attendees, and extended properties. There 1444 * will be one row returned for each event that matches the query selection, 1445 * or at most a single row if the {@link Events#_ID} is appended to the Uri. 1446 * Recurring events will only return a single row regardless of the number 1447 * of times that event repeats.</dd> 1448 * </dl> 1449 * <h3>Writing to Events</h3> There are further restrictions on all Updates 1450 * and Inserts in the Events table: 1451 * <ul> 1452 * <li>If allDay is set to 1 eventTimezone must be {@link Time#TIMEZONE_UTC} 1453 * and the time must correspond to a midnight boundary.</li> 1454 * <li>Exceptions are not allowed to recur. If rrule or rdate is not empty, 1455 * original_id and original_sync_id must be empty.</li> 1456 * <li>In general a calendar_id should not be modified after insertion. This 1457 * is not explicitly forbidden but many sync adapters will not behave in an 1458 * expected way if the calendar_id is modified.</li> 1459 * </ul> 1460 * The following Events columns are writable by both an app and a sync 1461 * adapter. 1462 * <ul> 1463 * <li>{@link #CALENDAR_ID}</li> 1464 * <li>{@link #ORGANIZER}</li> 1465 * <li>{@link #TITLE}</li> 1466 * <li>{@link #EVENT_LOCATION}</li> 1467 * <li>{@link #DESCRIPTION}</li> 1468 * <li>{@link #EVENT_COLOR}</li> 1469 * <li>{@link #DTSTART}</li> 1470 * <li>{@link #DTEND}</li> 1471 * <li>{@link #EVENT_TIMEZONE}</li> 1472 * <li>{@link #EVENT_END_TIMEZONE}</li> 1473 * <li>{@link #DURATION}</li> 1474 * <li>{@link #ALL_DAY}</li> 1475 * <li>{@link #RRULE}</li> 1476 * <li>{@link #RDATE}</li> 1477 * <li>{@link #EXRULE}</li> 1478 * <li>{@link #EXDATE}</li> 1479 * <li>{@link #ORIGINAL_ID}</li> 1480 * <li>{@link #ORIGINAL_SYNC_ID}</li> 1481 * <li>{@link #ORIGINAL_INSTANCE_TIME}</li> 1482 * <li>{@link #ORIGINAL_ALL_DAY}</li> 1483 * <li>{@link #ACCESS_LEVEL}</li> 1484 * <li>{@link #AVAILABILITY}</li> 1485 * <li>{@link #GUESTS_CAN_MODIFY}</li> 1486 * <li>{@link #GUESTS_CAN_INVITE_OTHERS}</li> 1487 * <li>{@link #GUESTS_CAN_SEE_GUESTS}</li> 1488 * </ul> 1489 * The following Events columns are writable only by a sync adapter 1490 * <ul> 1491 * <li>{@link #DIRTY}</li> 1492 * <li>{@link #_SYNC_ID}</li> 1493 * <li>{@link #SYNC_DATA1}</li> 1494 * <li>{@link #SYNC_DATA2}</li> 1495 * <li>{@link #SYNC_DATA3}</li> 1496 * <li>{@link #SYNC_DATA4}</li> 1497 * <li>{@link #SYNC_DATA5}</li> 1498 * <li>{@link #SYNC_DATA6}</li> 1499 * <li>{@link #SYNC_DATA7}</li> 1500 * <li>{@link #SYNC_DATA8}</li> 1501 * <li>{@link #SYNC_DATA9}</li> 1502 * <li>{@link #SYNC_DATA10}</li> 1503 * </ul> 1504 * The remaining columns are either updated by the provider only or are 1505 * views into other tables and cannot be changed through the Events table. 1506 */ 1507 public static final class Events implements BaseColumns, SyncColumns, EventsColumns, 1508 CalendarColumns { 1509 1510 /** 1511 * The content:// style URL for interacting with events. Appending an 1512 * event id using {@link ContentUris#withAppendedId(Uri, long)} will 1513 * specify a single event. 1514 */ 1515 @SuppressWarnings("hiding") 1516 public static final Uri CONTENT_URI = 1517 Uri.parse("content://" + AUTHORITY + "/events"); 1518 1519 /** 1520 * The content:// style URI for recurring event exceptions. Insertions require an 1521 * appended event ID. Deletion of exceptions requires both the original event ID and 1522 * the exception event ID (see {@link Uri.Builder#appendPath}). 1523 */ 1524 public static final Uri CONTENT_EXCEPTION_URI = 1525 Uri.parse("content://" + AUTHORITY + "/exception"); 1526 1527 /** 1528 * This utility class cannot be instantiated 1529 */ 1530 private Events() {} 1531 1532 /** 1533 * The default sort order for this table 1534 */ 1535 private static final String DEFAULT_SORT_ORDER = ""; 1536 1537 /** 1538 * These are columns that should only ever be updated by the provider, 1539 * either because they are views mapped to another table or because they 1540 * are used for provider only functionality. TODO move to provider 1541 * 1542 * @hide 1543 */ 1544 public static String[] PROVIDER_WRITABLE_COLUMNS = new String[] { 1545 ACCOUNT_NAME, 1546 ACCOUNT_TYPE, 1547 CAL_SYNC1, 1548 CAL_SYNC2, 1549 CAL_SYNC3, 1550 CAL_SYNC4, 1551 CAL_SYNC5, 1552 CAL_SYNC6, 1553 CAL_SYNC7, 1554 CAL_SYNC8, 1555 CAL_SYNC9, 1556 CAL_SYNC10, 1557 ALLOWED_REMINDERS, 1558 CALENDAR_ACCESS_LEVEL, 1559 CALENDAR_COLOR, 1560 CALENDAR_TIME_ZONE, 1561 CAN_MODIFY_TIME_ZONE, 1562 CAN_ORGANIZER_RESPOND, 1563 CALENDAR_DISPLAY_NAME, 1564 CAN_PARTIALLY_UPDATE, 1565 SYNC_EVENTS, 1566 VISIBLE, 1567 }; 1568 1569 /** 1570 * These fields are only writable by a sync adapter. To modify them the 1571 * caller must include CALLER_IS_SYNCADAPTER, _SYNC_ACCOUNT, and 1572 * _SYNC_ACCOUNT_TYPE in the query parameters. TODO move to provider. 1573 * 1574 * @hide 1575 */ 1576 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] { 1577 _SYNC_ID, 1578 DIRTY, 1579 SYNC_DATA1, 1580 SYNC_DATA2, 1581 SYNC_DATA3, 1582 SYNC_DATA4, 1583 SYNC_DATA5, 1584 SYNC_DATA6, 1585 SYNC_DATA7, 1586 SYNC_DATA8, 1587 SYNC_DATA9, 1588 SYNC_DATA10, 1589 }; 1590 } 1591 1592 /** 1593 * Fields and helpers for interacting with Instances. An instance is a 1594 * single occurrence of an event including time zone specific start and end 1595 * days and minutes. The instances table is not writable and only provides a 1596 * way to query event occurrences. 1597 */ 1598 public static final class Instances implements BaseColumns, EventsColumns, CalendarColumns { 1599 1600 private static final String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?"; 1601 private static final String[] WHERE_CALENDARS_ARGS = { 1602 "1" 1603 }; 1604 1605 /** 1606 * This utility class cannot be instantiated 1607 */ 1608 private Instances() {} 1609 1610 /** 1611 * Performs a query to return all visible instances in the given range. 1612 * This is a blocking function and should not be done on the UI thread. 1613 * This will cause an expansion of recurring events to fill this time 1614 * range if they are not already expanded and will slow down for larger 1615 * time ranges with many recurring events. 1616 * 1617 * @param cr The ContentResolver to use for the query 1618 * @param projection The columns to return 1619 * @param begin The start of the time range to query in UTC millis since 1620 * epoch 1621 * @param end The end of the time range to query in UTC millis since 1622 * epoch 1623 * @return A Cursor containing all instances in the given range 1624 */ 1625 public static final Cursor query(ContentResolver cr, String[] projection, 1626 long begin, long end) { 1627 Uri.Builder builder = CONTENT_URI.buildUpon(); 1628 ContentUris.appendId(builder, begin); 1629 ContentUris.appendId(builder, end); 1630 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED, 1631 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER); 1632 } 1633 1634 /** 1635 * Performs a query to return all visible instances in the given range 1636 * that match the given query. This is a blocking function and should 1637 * not be done on the UI thread. This will cause an expansion of 1638 * recurring events to fill this time range if they are not already 1639 * expanded and will slow down for larger time ranges with many 1640 * recurring events. 1641 * 1642 * @param cr The ContentResolver to use for the query 1643 * @param projection The columns to return 1644 * @param begin The start of the time range to query in UTC millis since 1645 * epoch 1646 * @param end The end of the time range to query in UTC millis since 1647 * epoch 1648 * @param searchQuery A string of space separated search terms. Segments 1649 * enclosed by double quotes will be treated as a single 1650 * term. 1651 * @return A Cursor of instances matching the search terms in the given 1652 * time range 1653 */ 1654 public static final Cursor query(ContentResolver cr, String[] projection, 1655 long begin, long end, String searchQuery) { 1656 Uri.Builder builder = CONTENT_SEARCH_URI.buildUpon(); 1657 ContentUris.appendId(builder, begin); 1658 ContentUris.appendId(builder, end); 1659 builder = builder.appendPath(searchQuery); 1660 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED, 1661 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER); 1662 } 1663 1664 /** 1665 * The content:// style URL for querying an instance range. The begin 1666 * and end of the range to query should be added as path segments if 1667 * this is used directly. 1668 */ 1669 @SuppressWarnings("hiding") 1670 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + 1671 "/instances/when"); 1672 /** 1673 * The content:// style URL for querying an instance range by Julian 1674 * Day. The start and end day should be added as path segments if this 1675 * is used directly. 1676 */ 1677 public static final Uri CONTENT_BY_DAY_URI = 1678 Uri.parse("content://" + AUTHORITY + "/instances/whenbyday"); 1679 /** 1680 * The content:// style URL for querying an instance range with a search 1681 * term. The begin, end, and search string should be appended as path 1682 * segments if this is used directly. 1683 */ 1684 public static final Uri CONTENT_SEARCH_URI = Uri.parse("content://" + AUTHORITY + 1685 "/instances/search"); 1686 /** 1687 * The content:// style URL for querying an instance range with a search 1688 * term. The start day, end day, and search string should be appended as 1689 * path segments if this is used directly. 1690 */ 1691 public static final Uri CONTENT_SEARCH_BY_DAY_URI = 1692 Uri.parse("content://" + AUTHORITY + "/instances/searchbyday"); 1693 1694 /** 1695 * The default sort order for this table. 1696 */ 1697 private static final String DEFAULT_SORT_ORDER = "begin ASC"; 1698 1699 /** 1700 * The beginning time of the instance, in UTC milliseconds. Column name. 1701 * <P>Type: INTEGER (long; millis since epoch)</P> 1702 */ 1703 public static final String BEGIN = "begin"; 1704 1705 /** 1706 * The ending time of the instance, in UTC milliseconds. Column name. 1707 * <P>Type: INTEGER (long; millis since epoch)</P> 1708 */ 1709 public static final String END = "end"; 1710 1711 /** 1712 * The _id of the event for this instance. Column name. 1713 * <P>Type: INTEGER (long, foreign key to the Events table)</P> 1714 */ 1715 public static final String EVENT_ID = "event_id"; 1716 1717 /** 1718 * The Julian start day of the instance, relative to the local time 1719 * zone. Column name. 1720 * <P>Type: INTEGER (int)</P> 1721 */ 1722 public static final String START_DAY = "startDay"; 1723 1724 /** 1725 * The Julian end day of the instance, relative to the local time 1726 * zone. Column name. 1727 * <P>Type: INTEGER (int)</P> 1728 */ 1729 public static final String END_DAY = "endDay"; 1730 1731 /** 1732 * The start minute of the instance measured from midnight in the 1733 * local time zone. Column name. 1734 * <P>Type: INTEGER (int)</P> 1735 */ 1736 public static final String START_MINUTE = "startMinute"; 1737 1738 /** 1739 * The end minute of the instance measured from midnight in the 1740 * local time zone. Column name. 1741 * <P>Type: INTEGER (int)</P> 1742 */ 1743 public static final String END_MINUTE = "endMinute"; 1744 } 1745 1746 protected interface CalendarCacheColumns { 1747 /** 1748 * The key for the setting. Keys are defined in {@link CalendarCache}. 1749 */ 1750 public static final String KEY = "key"; 1751 1752 /** 1753 * The value of the given setting. 1754 */ 1755 public static final String VALUE = "value"; 1756 } 1757 1758 /** 1759 * CalendarCache stores some settings for calendar including the current 1760 * time zone for the instances. These settings are stored using a key/value 1761 * scheme. A {@link #KEY} must be specified when updating these values. 1762 */ 1763 public static final class CalendarCache implements CalendarCacheColumns { 1764 /** 1765 * The URI to use for retrieving the properties from the Calendar db. 1766 */ 1767 public static final Uri URI = 1768 Uri.parse("content://" + AUTHORITY + "/properties"); 1769 1770 /** 1771 * This utility class cannot be instantiated 1772 */ 1773 private CalendarCache() {} 1774 1775 /** 1776 * They key for updating the use of auto/home time zones in Calendar. 1777 * Valid values are {@link #TIMEZONE_TYPE_AUTO} or 1778 * {@link #TIMEZONE_TYPE_HOME}. 1779 */ 1780 public static final String KEY_TIMEZONE_TYPE = "timezoneType"; 1781 1782 /** 1783 * The key for updating the time zone used by the provider when it 1784 * generates the instances table. This should only be written if the 1785 * type is set to {@link #TIMEZONE_TYPE_HOME}. A valid time zone id 1786 * should be written to this field. 1787 */ 1788 public static final String KEY_TIMEZONE_INSTANCES = "timezoneInstances"; 1789 1790 /** 1791 * The key for reading the last time zone set by the user. This should 1792 * only be read by apps and it will be automatically updated whenever 1793 * {@link #KEY_TIMEZONE_INSTANCES} is updated with 1794 * {@link #TIMEZONE_TYPE_HOME} set. 1795 */ 1796 public static final String KEY_TIMEZONE_INSTANCES_PREVIOUS = "timezoneInstancesPrevious"; 1797 1798 /** 1799 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider 1800 * should stay in sync with the device's time zone. 1801 */ 1802 public static final String TIMEZONE_TYPE_AUTO = "auto"; 1803 1804 /** 1805 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider 1806 * should use a fixed time zone set by the user. 1807 */ 1808 public static final String TIMEZONE_TYPE_HOME = "home"; 1809 } 1810 1811 /** 1812 * A few Calendar globals are needed in the CalendarProvider for expanding 1813 * the Instances table and these are all stored in the first (and only) row 1814 * of the CalendarMetaData table. 1815 * 1816 * @hide 1817 */ 1818 protected interface CalendarMetaDataColumns { 1819 /** 1820 * The local timezone that was used for precomputing the fields 1821 * in the Instances table. 1822 */ 1823 public static final String LOCAL_TIMEZONE = "localTimezone"; 1824 1825 /** 1826 * The minimum time used in expanding the Instances table, 1827 * in UTC milliseconds. 1828 * <P>Type: INTEGER</P> 1829 */ 1830 public static final String MIN_INSTANCE = "minInstance"; 1831 1832 /** 1833 * The maximum time used in expanding the Instances table, 1834 * in UTC milliseconds. 1835 * <P>Type: INTEGER</P> 1836 */ 1837 public static final String MAX_INSTANCE = "maxInstance"; 1838 1839 /** 1840 * The minimum Julian day in the EventDays table. 1841 * <P>Type: INTEGER</P> 1842 */ 1843 public static final String MIN_EVENTDAYS = "minEventDays"; 1844 1845 /** 1846 * The maximum Julian day in the EventDays table. 1847 * <P>Type: INTEGER</P> 1848 */ 1849 public static final String MAX_EVENTDAYS = "maxEventDays"; 1850 } 1851 1852 /** 1853 * @hide 1854 */ 1855 public static final class CalendarMetaData implements CalendarMetaDataColumns, BaseColumns { 1856 1857 /** 1858 * This utility class cannot be instantiated 1859 */ 1860 private CalendarMetaData() {} 1861 } 1862 1863 protected interface EventDaysColumns { 1864 /** 1865 * The Julian starting day number. Column name. 1866 * <P>Type: INTEGER (int)</P> 1867 */ 1868 public static final String STARTDAY = "startDay"; 1869 /** 1870 * The Julian ending day number. Column name. 1871 * <P>Type: INTEGER (int)</P> 1872 */ 1873 public static final String ENDDAY = "endDay"; 1874 1875 } 1876 1877 /** 1878 * Fields and helpers for querying for a list of days that contain events. 1879 */ 1880 public static final class EventDays implements EventDaysColumns { 1881 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY 1882 + "/instances/groupbyday"); 1883 private static final String SELECTION = "selected=1"; 1884 1885 /** 1886 * This utility class cannot be instantiated 1887 */ 1888 private EventDays() {} 1889 1890 /** 1891 * Retrieves the days with events for the Julian days starting at 1892 * "startDay" for "numDays". It returns a cursor containing startday and 1893 * endday representing the max range of days for all events beginning on 1894 * each startday.This is a blocking function and should not be done on 1895 * the UI thread. 1896 * 1897 * @param cr the ContentResolver 1898 * @param startDay the first Julian day in the range 1899 * @param numDays the number of days to load (must be at least 1) 1900 * @param projection the columns to return in the cursor 1901 * @return a database cursor containing a list of start and end days for 1902 * events 1903 */ 1904 public static final Cursor query(ContentResolver cr, int startDay, int numDays, 1905 String[] projection) { 1906 if (numDays < 1) { 1907 return null; 1908 } 1909 int endDay = startDay + numDays - 1; 1910 Uri.Builder builder = CONTENT_URI.buildUpon(); 1911 ContentUris.appendId(builder, startDay); 1912 ContentUris.appendId(builder, endDay); 1913 return cr.query(builder.build(), projection, SELECTION, 1914 null /* selection args */, STARTDAY); 1915 } 1916 } 1917 1918 protected interface RemindersColumns { 1919 /** 1920 * The event the reminder belongs to. Column name. 1921 * <P>Type: INTEGER (foreign key to the Events table)</P> 1922 */ 1923 public static final String EVENT_ID = "event_id"; 1924 1925 /** 1926 * The minutes prior to the event that the alarm should ring. -1 1927 * specifies that we should use the default value for the system. 1928 * Column name. 1929 * <P>Type: INTEGER</P> 1930 */ 1931 public static final String MINUTES = "minutes"; 1932 1933 /** 1934 * Passing this as a minutes value will use the default reminder 1935 * minutes. 1936 */ 1937 public static final int MINUTES_DEFAULT = -1; 1938 1939 /** 1940 * The alarm method, as set on the server. {@link #METHOD_DEFAULT}, 1941 * {@link #METHOD_ALERT}, {@link #METHOD_EMAIL}, and {@link #METHOD_SMS} 1942 * are possible values; the device will only process 1943 * {@link #METHOD_DEFAULT} and {@link #METHOD_ALERT} reminders (the 1944 * other types are simply stored so we can send the same reminder info 1945 * back to the server when we make changes). 1946 */ 1947 public static final String METHOD = "method"; 1948 1949 public static final int METHOD_DEFAULT = 0; 1950 public static final int METHOD_ALERT = 1; 1951 public static final int METHOD_EMAIL = 2; 1952 public static final int METHOD_SMS = 3; 1953 } 1954 1955 /** 1956 * Fields and helpers for accessing reminders for an event. Each row of this 1957 * table represents a single reminder for an event. Calling 1958 * {@link #query(ContentResolver, long, String[])} will return a list of reminders for 1959 * the event with the given eventId. Both apps and sync adapters may write 1960 * to this table. There are three writable fields and all of them must be 1961 * included when inserting a new reminder. They are: 1962 * <ul> 1963 * <li>{@link #EVENT_ID}</li> 1964 * <li>{@link #MINUTES}</li> 1965 * <li>{@link #METHOD}</li> 1966 * </ul> 1967 */ 1968 public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns { 1969 private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?"; 1970 @SuppressWarnings("hiding") 1971 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders"); 1972 1973 /** 1974 * This utility class cannot be instantiated 1975 */ 1976 private Reminders() {} 1977 1978 /** 1979 * Queries all reminders associated with the given event. This is a 1980 * blocking call and should not be done on the UI thread. 1981 * 1982 * @param cr The content resolver to use for the query 1983 * @param eventId The id of the event to retrieve reminders for 1984 * @param projection the columns to return in the cursor 1985 * @return A Cursor containing all reminders for the event 1986 */ 1987 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) { 1988 String[] remArgs = {Long.toString(eventId)}; 1989 return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/, 1990 null /* sort order */); 1991 } 1992 } 1993 1994 protected interface CalendarAlertsColumns { 1995 /** 1996 * The event that the alert belongs to. Column name. 1997 * <P>Type: INTEGER (foreign key to the Events table)</P> 1998 */ 1999 public static final String EVENT_ID = "event_id"; 2000 2001 /** 2002 * The start time of the event, in UTC. Column name. 2003 * <P>Type: INTEGER (long; millis since epoch)</P> 2004 */ 2005 public static final String BEGIN = "begin"; 2006 2007 /** 2008 * The end time of the event, in UTC. Column name. 2009 * <P>Type: INTEGER (long; millis since epoch)</P> 2010 */ 2011 public static final String END = "end"; 2012 2013 /** 2014 * The alarm time of the event, in UTC. Column name. 2015 * <P>Type: INTEGER (long; millis since epoch)</P> 2016 */ 2017 public static final String ALARM_TIME = "alarmTime"; 2018 2019 /** 2020 * The creation time of this database entry, in UTC. 2021 * Useful for debugging missed reminders. Column name. 2022 * <P>Type: INTEGER (long; millis since epoch)</P> 2023 */ 2024 public static final String CREATION_TIME = "creationTime"; 2025 2026 /** 2027 * The time that the alarm broadcast was received by the Calendar app, 2028 * in UTC. Useful for debugging missed reminders. Column name. 2029 * <P>Type: INTEGER (long; millis since epoch)</P> 2030 */ 2031 public static final String RECEIVED_TIME = "receivedTime"; 2032 2033 /** 2034 * The time that the notification was created by the Calendar app, 2035 * in UTC. Useful for debugging missed reminders. Column name. 2036 * <P>Type: INTEGER (long; millis since epoch)</P> 2037 */ 2038 public static final String NOTIFY_TIME = "notifyTime"; 2039 2040 /** 2041 * The state of this alert. It starts out as {@link #STATE_SCHEDULED}, then 2042 * when the alarm goes off, it changes to {@link #STATE_FIRED}, and then when 2043 * the user dismisses the alarm it changes to {@link #STATE_DISMISSED}. Column 2044 * name. 2045 * <P>Type: INTEGER</P> 2046 */ 2047 public static final String STATE = "state"; 2048 2049 /** 2050 * An alert begins in this state when it is first created. 2051 */ 2052 public static final int STATE_SCHEDULED = 0; 2053 /** 2054 * After a notification for an alert has been created it should be 2055 * updated to fired. 2056 */ 2057 public static final int STATE_FIRED = 1; 2058 /** 2059 * Once the user has dismissed the notification the alert's state should 2060 * be set to dismissed so it is not fired again. 2061 */ 2062 public static final int STATE_DISMISSED = 2; 2063 2064 /** 2065 * The number of minutes that this alarm precedes the start time. Column 2066 * name. 2067 * <P>Type: INTEGER</P> 2068 */ 2069 public static final String MINUTES = "minutes"; 2070 2071 /** 2072 * The default sort order for this alerts queries 2073 */ 2074 public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC"; 2075 } 2076 2077 /** 2078 * Fields and helpers for accessing calendar alerts information. These 2079 * fields are for tracking which alerts have been fired. Scheduled alarms 2080 * will generate an intent using {@link #ACTION_EVENT_REMINDER}. Apps that 2081 * receive this action may update the {@link #STATE} for the reminder when 2082 * they have finished handling it. Apps that have their notifications 2083 * disabled should not modify the table to ensure that they do not conflict 2084 * with another app that is generating a notification. In general, apps 2085 * should not need to write to this table directly except to update the 2086 * state of a reminder. 2087 */ 2088 public static final class CalendarAlerts implements BaseColumns, 2089 CalendarAlertsColumns, EventsColumns, CalendarColumns { 2090 2091 /** 2092 * @hide 2093 */ 2094 public static final String TABLE_NAME = "CalendarAlerts"; 2095 /** 2096 * The Uri for querying calendar alert information 2097 */ 2098 @SuppressWarnings("hiding") 2099 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + 2100 "/calendar_alerts"); 2101 2102 /** 2103 * This utility class cannot be instantiated 2104 */ 2105 private CalendarAlerts() {} 2106 2107 private static final String WHERE_ALARM_EXISTS = EVENT_ID + "=?" 2108 + " AND " + BEGIN + "=?" 2109 + " AND " + ALARM_TIME + "=?"; 2110 2111 private static final String WHERE_FINDNEXTALARMTIME = ALARM_TIME + ">=?"; 2112 private static final String SORT_ORDER_ALARMTIME_ASC = ALARM_TIME + " ASC"; 2113 2114 private static final String WHERE_RESCHEDULE_MISSED_ALARMS = STATE + "=" + STATE_SCHEDULED 2115 + " AND " + ALARM_TIME + "<?" 2116 + " AND " + ALARM_TIME + ">?" 2117 + " AND " + END + ">=?"; 2118 2119 /** 2120 * This URI is for grouping the query results by event_id and begin 2121 * time. This will return one result per instance of an event. So 2122 * events with multiple alarms will appear just once, but multiple 2123 * instances of a repeating event will show up multiple times. 2124 */ 2125 public static final Uri CONTENT_URI_BY_INSTANCE = 2126 Uri.parse("content://" + AUTHORITY + "/calendar_alerts/by_instance"); 2127 2128 private static final boolean DEBUG = false; 2129 2130 /** 2131 * Helper for inserting an alarm time associated with an event TODO move 2132 * to Provider 2133 * 2134 * @hide 2135 */ 2136 public static final Uri insert(ContentResolver cr, long eventId, 2137 long begin, long end, long alarmTime, int minutes) { 2138 ContentValues values = new ContentValues(); 2139 values.put(CalendarAlerts.EVENT_ID, eventId); 2140 values.put(CalendarAlerts.BEGIN, begin); 2141 values.put(CalendarAlerts.END, end); 2142 values.put(CalendarAlerts.ALARM_TIME, alarmTime); 2143 long currentTime = System.currentTimeMillis(); 2144 values.put(CalendarAlerts.CREATION_TIME, currentTime); 2145 values.put(CalendarAlerts.RECEIVED_TIME, 0); 2146 values.put(CalendarAlerts.NOTIFY_TIME, 0); 2147 values.put(CalendarAlerts.STATE, STATE_SCHEDULED); 2148 values.put(CalendarAlerts.MINUTES, minutes); 2149 return cr.insert(CONTENT_URI, values); 2150 } 2151 2152 /** 2153 * Finds the next alarm after (or equal to) the given time and returns 2154 * the time of that alarm or -1 if no such alarm exists. This is a 2155 * blocking call and should not be done on the UI thread. TODO move to 2156 * provider 2157 * 2158 * @param cr the ContentResolver 2159 * @param millis the time in UTC milliseconds 2160 * @return the next alarm time greater than or equal to "millis", or -1 2161 * if no such alarm exists. 2162 * @hide 2163 */ 2164 public static final long findNextAlarmTime(ContentResolver cr, long millis) { 2165 String selection = ALARM_TIME + ">=" + millis; 2166 // TODO: construct an explicit SQL query so that we can add 2167 // "LIMIT 1" to the end and get just one result. 2168 String[] projection = new String[] { ALARM_TIME }; 2169 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_FINDNEXTALARMTIME, 2170 (new String[] { 2171 Long.toString(millis) 2172 }), SORT_ORDER_ALARMTIME_ASC); 2173 long alarmTime = -1; 2174 try { 2175 if (cursor != null && cursor.moveToFirst()) { 2176 alarmTime = cursor.getLong(0); 2177 } 2178 } finally { 2179 if (cursor != null) { 2180 cursor.close(); 2181 } 2182 } 2183 return alarmTime; 2184 } 2185 2186 /** 2187 * Searches the CalendarAlerts table for alarms that should have fired 2188 * but have not and then reschedules them. This method can be called at 2189 * boot time to restore alarms that may have been lost due to a phone 2190 * reboot. TODO move to provider 2191 * 2192 * @param cr the ContentResolver 2193 * @param context the Context 2194 * @param manager the AlarmManager 2195 * @hide 2196 */ 2197 public static final void rescheduleMissedAlarms(ContentResolver cr, 2198 Context context, AlarmManager manager) { 2199 // Get all the alerts that have been scheduled but have not fired 2200 // and should have fired by now and are not too old. 2201 long now = System.currentTimeMillis(); 2202 long ancient = now - DateUtils.DAY_IN_MILLIS; 2203 String[] projection = new String[] { 2204 ALARM_TIME, 2205 }; 2206 2207 // TODO: construct an explicit SQL query so that we can add 2208 // "GROUPBY" instead of doing a sort and de-dup 2209 Cursor cursor = cr.query(CalendarAlerts.CONTENT_URI, projection, 2210 WHERE_RESCHEDULE_MISSED_ALARMS, (new String[] { 2211 Long.toString(now), Long.toString(ancient), Long.toString(now) 2212 }), SORT_ORDER_ALARMTIME_ASC); 2213 if (cursor == null) { 2214 return; 2215 } 2216 2217 if (DEBUG) { 2218 Log.d(TAG, "missed alarms found: " + cursor.getCount()); 2219 } 2220 2221 try { 2222 long alarmTime = -1; 2223 2224 while (cursor.moveToNext()) { 2225 long newAlarmTime = cursor.getLong(0); 2226 if (alarmTime != newAlarmTime) { 2227 if (DEBUG) { 2228 Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime); 2229 } 2230 scheduleAlarm(context, manager, newAlarmTime); 2231 alarmTime = newAlarmTime; 2232 } 2233 } 2234 } finally { 2235 cursor.close(); 2236 } 2237 } 2238 2239 /** 2240 * Schedules an alarm intent with the system AlarmManager that will 2241 * notify listeners when a reminder should be fired. The provider will 2242 * keep scheduled reminders up to date but apps may use this to 2243 * implement snooze functionality without modifying the reminders table. 2244 * Scheduled alarms will generate an intent using 2245 * {@link #ACTION_EVENT_REMINDER}. TODO Move to provider 2246 * 2247 * @param context A context for referencing system resources 2248 * @param manager The AlarmManager to use or null 2249 * @param alarmTime The time to fire the intent in UTC millis since 2250 * epoch 2251 * @hide 2252 */ 2253 public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) { 2254 if (DEBUG) { 2255 Time time = new Time(); 2256 time.set(alarmTime); 2257 String schedTime = time.format(" %a, %b %d, %Y %I:%M%P"); 2258 Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime); 2259 } 2260 2261 if (manager == null) { 2262 manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 2263 } 2264 2265 Intent intent = new Intent(ACTION_EVENT_REMINDER); 2266 intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime)); 2267 intent.putExtra(ALARM_TIME, alarmTime); 2268 PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); 2269 manager.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); 2270 } 2271 2272 /** 2273 * Searches for an entry in the CalendarAlerts table that matches the 2274 * given event id, begin time and alarm time. If one is found then this 2275 * alarm already exists and this method returns true. TODO Move to 2276 * provider 2277 * 2278 * @param cr the ContentResolver 2279 * @param eventId the event id to match 2280 * @param begin the start time of the event in UTC millis 2281 * @param alarmTime the alarm time of the event in UTC millis 2282 * @return true if there is already an alarm for the given event with 2283 * the same start time and alarm time. 2284 * @hide 2285 */ 2286 public static final boolean alarmExists(ContentResolver cr, long eventId, 2287 long begin, long alarmTime) { 2288 // TODO: construct an explicit SQL query so that we can add 2289 // "LIMIT 1" to the end and get just one result. 2290 String[] projection = new String[] { ALARM_TIME }; 2291 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_ALARM_EXISTS, 2292 (new String[] { 2293 Long.toString(eventId), Long.toString(begin), Long.toString(alarmTime) 2294 }), null); 2295 boolean found = false; 2296 try { 2297 if (cursor != null && cursor.getCount() > 0) { 2298 found = true; 2299 } 2300 } finally { 2301 if (cursor != null) { 2302 cursor.close(); 2303 } 2304 } 2305 return found; 2306 } 2307 } 2308 2309 /** 2310 * @hide 2311 * TODO UNHIDE 2312 */ 2313 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 /** 2334 * The index used to reference this color. This can be any non-empty 2335 * string, but must be unique for a given {@link #ACCOUNT_TYPE} and 2336 * {@link #ACCOUNT_NAME}. Column name. 2337 * <P> 2338 * Type: TEXT 2339 * </P> 2340 */ 2341 public static final String COLOR_INDEX = "color_index"; 2342 2343 /** 2344 * 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. 2349 * <P> 2350 * Type: INTEGER (NOT NULL) 2351 * </P> 2352 */ 2353 public static final String COLOR = "color"; 2354 2355 } 2356 2357 /** 2358 * Fields for accessing colors available for a given account. Colors are 2359 * referenced by {@link #COLOR_INDEX} which must be unique for a given 2360 * account name/type. These values should only be updated by the sync 2361 * 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. 2364 * TODO UNHIDE 2365 * 2366 * @hide 2367 */ 2368 public static final class Colors implements ColorsColumns { 2369 /** 2370 * @hide 2371 */ 2372 public static final String TABLE_NAME = "Colors"; 2373 /** 2374 * The Uri for querying color information 2375 */ 2376 @SuppressWarnings("hiding") 2377 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors"); 2378 2379 /** 2380 * This utility class cannot be instantiated 2381 */ 2382 private Colors() { 2383 } 2384 } 2385 2386 protected interface ExtendedPropertiesColumns { 2387 /** 2388 * The event the extended property belongs to. Column name. 2389 * <P>Type: INTEGER (foreign key to the Events table)</P> 2390 */ 2391 public static final String EVENT_ID = "event_id"; 2392 2393 /** 2394 * The name of the extended property. This is a uri of the form 2395 * {scheme}#{local-name} convention. Column name. 2396 * <P>Type: TEXT</P> 2397 */ 2398 public static final String NAME = "name"; 2399 2400 /** 2401 * The value of the extended property. Column name. 2402 * <P>Type: TEXT</P> 2403 */ 2404 public static final String VALUE = "value"; 2405 } 2406 2407 /** 2408 * Fields for accessing the Extended Properties. This is a generic set of 2409 * name/value pairs for use by sync adapters to add extra 2410 * information to events. There are three writable columns and all three 2411 * must be present when inserting a new value. They are: 2412 * <ul> 2413 * <li>{@link #EVENT_ID}</li> 2414 * <li>{@link #NAME}</li> 2415 * <li>{@link #VALUE}</li> 2416 * </ul> 2417 */ 2418 public static final class ExtendedProperties implements BaseColumns, 2419 ExtendedPropertiesColumns, EventsColumns { 2420 public static final Uri CONTENT_URI = 2421 Uri.parse("content://" + AUTHORITY + "/extendedproperties"); 2422 2423 /** 2424 * This utility class cannot be instantiated 2425 */ 2426 private ExtendedProperties() {} 2427 2428 // TODO: fill out this class when we actually start utilizing extendedproperties 2429 // in the calendar application. 2430 } 2431 2432 /** 2433 * A table provided for sync adapters to use for storing private sync state data. 2434 * 2435 * @see SyncStateContract 2436 */ 2437 public static final class SyncState implements SyncStateContract.Columns { 2438 /** 2439 * This utility class cannot be instantiated 2440 */ 2441 private SyncState() {} 2442 2443 private static final String CONTENT_DIRECTORY = 2444 SyncStateContract.Constants.CONTENT_DIRECTORY; 2445 2446 /** 2447 * The content:// style URI for this table 2448 */ 2449 public static final Uri CONTENT_URI = 2450 Uri.withAppendedPath(CalendarContract.CONTENT_URI, CONTENT_DIRECTORY); 2451 } 2452 2453 /** 2454 * Columns from the EventsRawTimes table 2455 * 2456 * @hide 2457 */ 2458 protected interface EventsRawTimesColumns { 2459 /** 2460 * The corresponding event id. Column name. 2461 * <P>Type: INTEGER (long)</P> 2462 */ 2463 public static final String EVENT_ID = "event_id"; 2464 2465 /** 2466 * The RFC2445 compliant time the event starts. Column name. 2467 * <P>Type: TEXT</P> 2468 */ 2469 public static final String DTSTART_2445 = "dtstart2445"; 2470 2471 /** 2472 * The RFC2445 compliant time the event ends. Column name. 2473 * <P>Type: TEXT</P> 2474 */ 2475 public static final String DTEND_2445 = "dtend2445"; 2476 2477 /** 2478 * The RFC2445 compliant original instance time of the recurring event 2479 * for which this event is an exception. Column name. 2480 * <P>Type: TEXT</P> 2481 */ 2482 public static final String ORIGINAL_INSTANCE_TIME_2445 = "originalInstanceTime2445"; 2483 2484 /** 2485 * The RFC2445 compliant last date this event repeats on, or NULL if it 2486 * never ends. Column name. 2487 * <P>Type: TEXT</P> 2488 */ 2489 public static final String LAST_DATE_2445 = "lastDate2445"; 2490 } 2491 2492 /** 2493 * @hide 2494 */ 2495 public static final class EventsRawTimes implements BaseColumns, EventsRawTimesColumns { 2496 2497 /** 2498 * This utility class cannot be instantiated 2499 */ 2500 private EventsRawTimes() {} 2501 } 2502} 2503