2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FSclCalEvent.h
19 * @brief This is the header file for the %CalEvent class.
21 * This header file contains the declarations of the %CalEvent class.
23 #ifndef _FSCL_CAL_EVENT_H_
24 #define _FSCL_CAL_EVENT_H_
26 #include <FBaseDataType.h>
27 #include <FBaseColIList.h>
28 #include <FBaseString.h>
29 #include <FBaseByteBuffer.h>
30 #include <FBaseDateTime.h>
31 #include <FLclCalendar.h>
32 #include <FSclTypes.h>
33 #include <FSclRecord.h>
34 #include <FSclRecurrence.h>
35 #include <FSclReminder.h>
36 #include <FSclAttendee.h>
38 namespace Tizen { namespace Locales
43 namespace Tizen { namespace Social
48 * @brief This class provides methods to manage the information of a calendar book event.
52 * @final This class is not intended for extension.
54 * The %CalEvent class describes an occasion planned in a particular situation. @n
55 * An event is a subset of vEvent. A %CalEvent instance includes the category, subject, description, start time, end time, location, and sensitivity.
56 * %CalEvent also includes the recurring and reminder data. For more information, see the Recurrence, and Reminder classes.
58 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/calevent.htm">Calendar Events</a>.
60 * The following example demonstrates how to use the %CalEvent class.
67 using namespace Tizen::Base;
68 using namespace Tizen::Social;
69 using namespace Tizen::Locales;
72 CreateCalEventWithTimeZone(void)
74 DateTime startWallTime;
76 DateTime startUtcTime;
79 // Suppose a user set 2010/2/17 12:00:00 ~ 2010/2/17 14:00:00 in wall time for start/end time
80 startWallTime.SetValue(2010, 2, 17, 12, 0, 0);
81 endWallTime.SetValue(2010, 2, 17, 14, 0, 0);
83 // Gets the system time zone
84 LocaleManager localeManager;
85 localeManager.Construct();
87 TimeZone timeZone = localeManager.GetSystemTimeZone();
89 // Converts the wall time to UTC time before set start and end time of the event
90 startUtcTime = timeZone.WallTimeToUtcTime(startWallTime);
91 endUtcTime = timeZone.WallTimeToUtcTime(endWallTime);
97 event.SetTimeZone(timeZone);
98 event.SetStartAndEndTime(startUtcTime, endUtcTime);
104 class _OSP_EXPORT_ CalEvent
110 * This is the default constructor for this class.
117 * Copying of objects using this copy constructor is allowed.
121 * @param[in] rhs An instance of %CalEvent
123 CalEvent(const CalEvent& rhs);
126 * This destructor overrides Tizen::Social::Record::~Record().
130 virtual ~CalEvent(void);
133 * Compares the input Tizen::Base::Object with the calling %CalEvent instance.
137 * @return @c true if the input object equals the calling %CalEvent instance, @n
139 * @param[in] rhs The object instance to compare with the calling object
142 virtual bool Equals(const Tizen::Base::Object& rhs) const;
145 * Gets the hash value of the current instance.
149 * @return The hash value of the current instance
151 virtual int GetHashCode(void) const;
155 * Checks whether this instance is a %CalEvent instance. @n
156 * A one-time calendar event has only one instance and a recurring calendar event has more than one instance. @n
157 * Each instance of %CalEvent has its own recurrence ID.
159 * @brief <i> [Deprecated] </i>
160 * @deprecated This method is deprecated because %CalEvent class is not used for event instance any more. @n
161 * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for event instance.
164 * @return @c true if this instance is a %CalEvent instance, @n
168 bool IsInstance(void) const;
172 * Checks whether the calendar event has a recurring pattern.
174 * @brief <i> [Deprecated] </i>
175 * @deprecated This method is deprecated because %CalEvent class is not used for event instance any more. @n
176 * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for event instance.
179 * @return @c true if the calendar event has a recurring pattern, @n
183 bool IsRecurring(void) const;
187 * Gets the original calendar event ID. @n
188 * The %CalEvent instance has an original @c CalEventId, that is a record ID of its entry.
190 * @brief <i> [Deprecated] </i>
191 * @deprecated This method is deprecated because %CalEvent class is not used for event instance any more. @n
192 * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for event instance.
195 * @return The original calendar event ID, @n
196 * else #INVALID_RECORD_ID if the record ID is invalid
199 RecordId GetOriginalCalEventId(void) const;
202 * Checks whether the calendar event is an all day event.
206 * @return @c true if calendar event is an all day event, @n
209 bool IsAllDayEvent(void) const;
212 * Sets the calendar event as an all day event.
216 * @param[in] isAllDayEvent Set to @c true to make the calendar event an all day event, @n
219 void SetAllDayEvent(bool isAllDayEvent);
223 * Gets the globally unique ID. @n
224 * UID: globally Unique Identifier (vCalendar 1.0)
226 * @brief <i> [Deprecated] </i>
227 * @deprecated This method is deprecated because string value cannot be handled. @n
228 * Instead of using this method, it is recommended to use GetUid().
231 * @return The globally unique ID
232 * @exception E_SUCCESS The method is successful.
233 * @exception E_OUT_OF_MEMORY The memory is insufficient.
234 * @remarks The specific error code can be accessed using the GetLastResult() method.
237 Tizen::Base::ByteBuffer* GetUIDN(void) const;
241 * Sets the globally unique ID. @n
242 * UID: globally Unique Identifier (vCalendar 1.0)
244 * @brief <i> [Deprecated] </i>
245 * @deprecated This method is deprecated because string value cannot be handled. @n
246 * Instead of using this method, it is recommended to use SetUid().
249 * @return An error code
250 * @param[in] pUid The globally unique ID
251 * @exception E_SUCCESS The method is successful.
252 * @exception E_OUT_OF_MEMORY The memory is insufficient.
255 result SetUID(const Tizen::Base::ByteBuffer* pUid);
258 * Gets the globally unique ID. @n
259 * UID: globally Unique Identifier (vCalendar 1.0)
263 * @return The globally unique ID
265 Tizen::Base::String GetUid(void) const;
268 * Sets the globally unique ID. @n
269 * UID: globally Unique Identifier (vCalendar 1.0)
273 * @param[in] uid The globally unique ID
275 void SetUid(const Tizen::Base::String& uid);
278 * Gets the calendar event status. @n
279 * The default status is #EVENT_STATUS_NONE.
283 * @return The calendar event status
286 EventStatus GetStatus(void) const;
289 * Sets the calendar event status.
293 * @param[in] status The status
296 void SetStatus(EventStatus status);
299 * Gets the busy status. @n
300 * The default busy status is #BUSY_STATUS_BUSY.
304 * @return The busy status
307 BusyStatus GetBusyStatus(void) const;
310 * Sets the busy status.
314 * @param[in] busyStatus The busy status
317 void SetBusyStatus(BusyStatus busyStatus);
320 * Gets the priority level of the calendar event. @n
321 * The default priority level is #EVENT_PRIORITY_LOW.
325 * @return The priority level
328 EventPriority GetPriority(void) const;
331 * Sets the priority level of the calendar event.
335 * @param[in] priority The priority level to set
338 void SetPriority(EventPriority priority);
343 * @brief <i> [Compatibility] </i>
345 * @compatibility This method has compatibility issues with Tizen API versions @b prior @b to @b 2.1. @n
346 * For more information, see @ref CompCalEventAddAttendeePage "here".
348 * @return An error code
349 * @param[in] attendee The attendee to add @n
350 * The specified @c attendee must have an email address.
351 * @exception E_SUCCESS The method is successful.
352 * @exception E_INVALID_ARG The specified @c attendee is invalid. @b Since @b 2.1
353 * @exception E_OBJ_ALREADY_EXIST An attendee with the same email address already exists.
355 result AddAttendee(const Attendee& attendee);
358 * @page CompCalEventAddAttendeePage Compatibility for AddAttendee()
359 * @section CompCalEventAddAttendeePageIssueSection Issues
360 * Implementation of this method in Tizen API versions prior to 2.1 has the following issue: @n
361 * -# If the email of @c attendee is empty, the @c E_OBJ_ALREADY_EXIST is returned.
363 * @section CompCalEventAddAttendeePageSolutionSection Resolutions
364 * The issue mentioned above is resolved in Tizen API version 2.1.
365 * -# If the email of @c attendee is empty, the @c E_INVALID_ARG is returned.
369 * Removes an attendee.
373 * @return An error code
374 * @param[in] attendee The attendee to remove @n
375 * The specified @c attendee must have an email address.
376 * @exception E_SUCCESS The method is successful.
377 * @exception E_OBJ_NOT_FOUND An attendee that has the same email address is not found.
379 result RemoveAttendee(const Attendee& attendee);
382 * Gets a list of all the attendees.
386 * @return A list of the attendees
387 * @remarks The specific error code can be accessed using the GetLastResult() method.
390 Tizen::Base::Collection::IList* GetAllAttendeesN(void) const;
393 * Gets the time zone.
397 * @return The time zone
398 * @see Tizen::Locales::TimeZone
400 Tizen::Locales::TimeZone GetTimeZone(void) const;
403 * Sets the time zone. @n
404 * Recurrence is calculated based on the time zone, thus the time zone must be set before setting a recurrence.
405 * If the time zone is not set, it will be considered as Greenwich Mean Time (GMT) 0.
409 * @return An error code
410 * @param[in] timeZone The time zone to set
411 * @exception E_SUCCESS The method is successful.
412 * @exception E_FAILURE The method has failed.
413 * @remarks As anniversaries and all day events are not affected by a time zone, it is recommended not to set the time zone.
414 * @see Tizen::Locales::TimeZone
416 result SetTimeZone(const Tizen::Locales::TimeZone& timeZone);
420 * Gets the recurrence ID. @n
421 * The %GetRecurrenceId() method works only for the %CalEvent instances.
423 * @brief <i> [Deprecated] </i>
424 * @deprecated This method is deprecated because %CalEvent class is not used for event instance any more. @n
425 * Instead of using the %CalEvent class, it is recommended to use the CalEventInstance class for event instance.
428 * @return The recurrence ID
429 * @exception E_SUCCESS The method is successful.
430 * @exception E_INVALID_STATE The instance is a %CalEvent instance that does not have a recurrence ID.
431 * @remarks The specific error code can be accessed using the GetLastResult() method.
434 RecurrenceId GetRecurrenceId(void) const;
437 * Gets the subject of the calendar event.
441 * @return The subject, @n
442 * else @c null if there is no subject value
444 Tizen::Base::String GetSubject(void) const;
447 * Gets the description of the calendar event.
451 * @return The description
453 Tizen::Base::String GetDescription(void) const;
456 * Gets the start date and time of the calendar event.
460 * @return An instance of Tizen::Base::DateTime representing the start date and time
462 Tizen::Base::DateTime GetStartTime(void) const;
465 * Gets the end date and time of the calendar event.
469 * @return An instance of Tizen::Base::DateTime representing the end date and time
471 Tizen::Base::DateTime GetEndTime(void) const;
474 * Gets the location of the calendar event.
478 * @return The location
480 Tizen::Base::String GetLocation(void) const;
484 * Gets the category of the calendar event.
486 * @brief <i> [Deprecated] </i>
487 * @deprecated This method is deprecated because the category of event is not used any more.
490 * @return The category of the calendar event
493 EventCategory GetCategory(void) const;
496 * Gets the sensitivity of the calendar event. @n
497 * The default value is #SENSITIVITY_PUBLIC.
501 * @return The sensitivity of the calendar event
503 RecordSensitivity GetSensitivity(void) const;
508 * Gets the reminder for the calendar event.
510 * @brief <i> [Deprecated] </i>
511 * @deprecated This method is deprecated. Instead of using this method, it is recommended to use GetAllReminders().
514 * @return A pointer to an instance of Reminder, @n
515 * else @c null if the reminder is not set
518 const Reminder* GetReminder(void) const;
521 * Gets the recurrence of the calendar event.
525 * @return A pointer to an instance of Recurrence, @n
526 * else @c null if the event is not a recurring event
528 const Recurrence* GetRecurrence(void) const;
531 * Gets the last updated date and time of the calendar event.
535 * @return The last updated date and time
537 Tizen::Base::DateTime GetLastRevisedTime(void) const;
540 * Sets the subject of the calendar event.
543 * @brief <i> [Compatibility] </i>
547 * @compatibility This method has compatibility issues with OSP compatible applications. @n
548 * For more information, see @ref CompCalEventSetSubjectPage "here".
551 * @return An error code
552 * @param[in] subject The subject of the calendar event
553 * @exception E_SUCCESS The method is successful.
555 result SetSubject(const Tizen::Base::String& subject);
559 * @page CompCalEventSetSubjectPage Compatibility for SetSubject()
560 * @section CompCalEventSetSubjectPageIssueSection Issues
561 * Implementing this method in OSP compatible applications has the following issues: @n
562 * -# If the length of the subject to be set is greater than 100 characters, E_INVALID_ARG is returned.
564 * @section CompCalEventSetSubjectPageSolutionSection Resolutions
565 * This issue has been resolved in Tizen. @n
566 * -# There is no limit for the length of the subject.
571 * Sets the description of the current calendar event.
574 * @brief <i> [Compatibility] </i>
578 * @compatibility This method has compatibility issues with OSP compatible applications. @n
579 * For more information, see @ref CompCalEventSetDescriptionPage "here".
582 * @return An error code
583 * @param[in] description The description of the event
584 * @exception E_SUCCESS The method is successful.
586 result SetDescription(const Tizen::Base::String& description);
590 * @page CompCalEventSetDescriptionPage Compatibility for SetDescription()
591 * @section CompCalEventSetDescriptionPageIssueSection Issues
592 * Implementing this method in OSP compatible applications has the following issues: @n
593 * -# If the length of the description to be set is greater than 1000 characters, E_INVALID_ARG is returned.
595 * @section CompCalEventSetDescriptionPageSolutionSection Resolutions
596 * This issue has been resolved in Tizen. @n
597 * -# There is no limit for the length of the description.
602 * Sets the start and end date and time of the calendar event. @n
603 * If the start date and time is not fixed, the default date and time are set. @n
604 * The default start date and time is the current date and time. @n
605 * The start date and time must be earlier than or equal to the end date and time. @n
606 * If the recurrence date is already set, this method returns an exception.
610 * @return An error code
611 * @param[in] startDateTime The start date and time. @n Any value with a unit that is less than a second is ignored.
612 * @param[in] endDateTime The end date and time. @n Any value with a unit that is less than a second is ignored.
613 * @exception E_SUCCESS The method is successful.
614 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
615 * - The specified @c endDateTime value is earlier than the specified @c startDateTime value.
616 * - The @c startDateTime or @c endDateTime is out of the valid range. @n
617 * The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
618 * @exception E_INVALID_CONDITION The recurrence date is already set.
619 * @remarks The start and end time of all day events created from the base applications is the local time of the location where
621 * All the other events are Coordinated Universal Time (UTC).
622 * In order to integrate it with the base applications, set the start and end time properly according to the above guidelines.
623 * If the seconds value of the start time is set, the alarm will not be fired.
624 * There is no automatic time conversion based on the time zone property of the calendar event.
626 result SetStartAndEndTime(const Tizen::Base::DateTime& startDateTime, const Tizen::Base::DateTime& endDateTime);
629 * Sets the location of the current calendar event.
632 * @brief <i> [Compatibility] </i>
636 * @compatibility This method has compatibility issues with OSP compatible applications. @n
637 * For more information, see @ref CompCalEventSetLocationPage "here".
640 * @return An error code
641 * @param[in] location The location of the event
642 * @exception E_SUCCESS The method is successful.
644 result SetLocation(const Tizen::Base::String& location);
648 * @page CompCalEventSetLocationPage Compatibility for SetLocation()
649 * @section CompCalEventSetLocationPageIssueSection Issues
650 * Implementing this method in OSP compatible applications has the following issues: @n
651 * -# If the length of the location to be set is greater than 100 characters, E_INVALID_ARG is returned.
653 * @section CompCalEventSetLocationPageSolutionSection Resolutions
654 * This issue has been resolved in Tizen. @n
655 * -# There is no limit for the length of the location.
662 * Sets the category of the calendar event. @n
663 * If the category is not set, the default category (#EVENT_CATEGORY_APPOINTMENT) is set.
666 * @brief <i> [Deprecated] [Compatibility] </i>
668 * @deprecated This method is deprecated because the category of event is not used any more.
671 * @compatibility This method has compatibility issues with OSP compatible applications. @n
672 * For more information, see @ref CompCalEventSetCategoryPage "here".
675 * @param[in] category The category of the event
676 * @remarks The start and end time of the anniversary and all day events created from the base applications, is the local time of the location where
678 * All the other events are Coordinated Universal Time (UTC).
679 * In order to integrate it with the base applications, set the start and end time properly according to the above guidelines.
683 void SetCategory(EventCategory category);
687 * @page CompCalEventSetCategoryPage Compatibility for SetCategory()
688 * @section CompCalEventSetCategoryPageIssueSection Issues
689 * Implementing this method in OSP compatible applications has the following issues: @n
691 * -# When the anniversary category is set to the event, it is handled as all day event even though the all day event property is not set.
693 * @section CompCalEventSetCategoryPageSolutionSection Resolutions
695 * This issue has been resolved in Tizen. @n
696 * -# The category property is deprecated and it is not used any more.
697 * In Tizen, the all day event property will be set simultaneously when the anniversary category is set to the event.
698 * If an application tries to change the all day event property of the anniversary event to @c false, it will not be changed.
703 * Sets the sensitivity of the calendar event.
707 * @param[in] sensitivity The sensitivity of the calendar event
709 void SetSensitivity(RecordSensitivity sensitivity);
712 * Sets the coordinates.
716 * @return An error code
717 * @param[in] latitude The latitude in the range @n The valid range is [-90.0, 90.0].
718 * @param[in] longitude The longitude in the range @n The valid range is [-180.0, 180.0].
719 * @exception E_SUCCESS The method is successful.
720 * @exception E_INVALID_ARG The @c latitude or @c longitude is out of the valid range.
722 result SetCoordinates(double latitude, double longitude);
725 * Gets the coordinates.
729 * @return An error code
730 * @param[out] latitude The latitude
731 * @param[out] longitude The longitude
733 void GetCoordinates(double& latitude, double& longitude) const;
737 * Sets the reminder of the calendar event.
739 * @brief <i> [Deprecated] </i>
740 * @deprecated This method is deprecated. Instead of using this method, it is recommended to use AddReminder() and RemoveReminderAt().
743 * @return An error code
744 * @param[in] pReminder The reminder to set, @n
745 * else @c null to remove the previous reminder
746 * @exception E_SUCCESS The method is successful.
747 * @exception E_OUT_OF_MEMORY The memory is insufficient.
750 result SetReminder(const Reminder* pReminder);
753 * Sets the recurrence of the calendar event. @n
754 * The recurrence rule date must be equal to the start date of the event. @n
755 * If the event start date is different than the recurrence rule date, the event start date is set to match the recurrence rule date. @n
756 * For example, if an event start date is 17/02/2010, that is Wednesday and the recurrence rule date is Thursday of every week,
757 * the event start date changes to 18/02/2010, after this method is called. @n
758 * Note that the start/end date and the time zone must be set before setting a recurrence.
761 * @brief <i> [Compatibility] </i>
765 * @compatibility This method has compatibility issues with OSP compatible applications. @n
766 * For more information, see @ref CompCalEventSetRecurrencePage "here".
769 * @return An error code
770 * @param[in] pRecurrence The recurrence to set, @n
771 * else @c null to remove the previous recurrence
772 * @exception E_SUCCESS The method is successful.
773 * @exception E_INVALID_STATE The current event is a %CalEvent instance that has a recurrence ID.
774 * @exception E_INVALID_CONDITION Either of the following conditions has occurred: @n
775 * - The recurrence rule date is earlier than the start date and time of the event. @n
776 * - The recurrence rule is invalid. @n
777 * - The duration of the event is too long. @n
778 * It must be shorter than the (interval x frequency) days set for the recurrence rule.
779 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
780 * - When the frequency is #FREQ_WEEKLY, DayOfWeek is not set. @n
781 * - When the frequency is #FREQ_MONTHLY, neither DayOfMonth nor DayOfWeek and WeekOfMonth are not set. @n
782 * - When the frequency is #FREQ_YEARLY, neither DayOfMonth and MonthOfYear nor DayOfWeek,
783 * WeekOfMonth and MonthOfYear are not set. @n
784 * - When the frequency is #FREQ_YEARLY and MonthOfYear is 2, DayOfMonth is greater than 29 (> 29). @n
785 * - When the frequency is #FREQ_YEARLY and MonthOfYear is 4 or 6 or 9 or 11,
786 * DayOfMonth is greater than 30 (> 30).
787 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
788 * @remarks If the until property of the recurrence is set with too distant future from the event's start date, @n
789 * too many recurring events are generated. It is the same when the value of recurrence count is big. @n
790 * The system limits the count of the recurring events that are generated by recurrence rule of an event. @n
791 * In this case, some recurring events that exceed the system limitation cannot be retrieved.
793 * The following example demonstrates how to use the %SetRecurrence() method.
795 MyClass::SetEventRecurrence(void)
797 result r = E_SUCCESS;
798 Recurrence* pRecurrence = new Recurrence();
800 pRecurrence->SetFrequency(FREQ_WEEKLY);
801 pRecurrence->SetDayOfWeek(CAL_MONDAY);
803 r = __pCalEvent->SetRecurrence(pRecurrence);
809 result SetRecurrence(const Recurrence* pRecurrence);
813 * @page CompCalEventSetRecurrencePage Compatibility for SetRecurrence()
814 * @section CompCalEventSetRecurrencePageIssueSection Issues
815 * Implementing this method in OSP compatible applications has the following issues: @n
816 * - If the category is anniversary and the frequency of recurrence is not yearly, E_TYPE_MISMATCH exception is occurred. @n
817 * Yearly frequency is only accepted for anniversary category.
819 * @section CompCalEventSetRecurrencePageSolutionSection Resolutions
820 * This issue has been resolved in Tizen. @n
821 * -# All recurrence frequency will be accepted because the category of event is not used any more.
830 * @return An error code
831 * @param[in] reminder The reminder to add
832 * @exception E_SUCCESS The method is successful.
833 * @exception E_OUT_OF_MEMORY The memory is insufficient.
835 result AddReminder(const Reminder& reminder);
838 * Removes a reminder at the index.
842 * @return An error code
843 * @param[in] index The index of reminder to remove
844 * @exception E_SUCCESS The method is successful.
845 * @exception E_OUT_OF_RANGE The index is either equal to or greater than the number of reminders or less than @c 0.
847 result RemoveReminderAt(int index);
850 * Gets a list of all the reminders.
854 * @return A list containing the Reminder instances, @n
855 * else an empty list if there are no reminders
857 const Tizen::Base::Collection::IList& GetAllReminders(void) const;
860 * Gets the ID of the calendar to which this event belongs.
864 * @return The calendar Id
866 RecordId GetCalendarId(void) const;
869 * Gets the base event ID.
870 * This method return the ID of the base recurring event for which this event is a recurrence exception.
874 * @return The base event ID, if this event is an exception
875 * else #INVALID_RECORD_ID
877 RecordId GetBaseEventId(void) const;
880 * Copying of objects using this copy assignment operator is allowed.
884 * @param[in] rhs An instance of %CalEvent
886 CalEvent& operator =(const CalEvent& rhs);
889 friend class _CalEventImpl;
890 class _CalEventImpl* __pCalEventImpl;
895 #endif // _FSCL_CAL_EVENT_H_