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 FSclRecurrence.h
19 * @brief This is the header file for the %Recurrence class.
21 * This header file contains the declarations of the %Recurrence class.
23 #ifndef _FSCL_RECURRENCE_H_
24 #define _FSCL_RECURRENCE_H_
26 #include <FBaseObject.h>
27 #include <FBaseDataType.h>
28 #include <FBaseColIListT.h>
29 #include <FBaseColArrayListT.h>
30 #include <FBaseDateTime.h>
31 #include <FSclTypes.h>
33 namespace Tizen { namespace Base { namespace Collection
38 namespace Tizen { namespace Social
43 * @brief This class provides methods to access the information of a %Recurrence.
47 * @final This class is not intended for extension.
49 * The %Recurrence class provides methods to access the information of a %Recurrence.
50 * A CalEvent can be made a recurring event using this class. To set or get the information of a recurrence (such as start time and recurrence
51 * pattern) use the methods of this class. The recurrence date is the start date of the CalEvent, if they do not match.
54 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/recurrence_reminder_sensitivity.htm">Recurrence, Reminder, and Sensitivity Properties of Calendar Items</a>.
56 * @see CalEvent::SetRecurrence()
58 * The following examples demonstrate how to use the %Recurrence class.
60 * 1. Repeat daily for 10 occurrences:
65 MyRecurrence::RepeatDayily10(void)
68 Recurrence* pRecurrence = new Recurrence();
69 if (IsFailed(GetLastResult()) || pRecurrence == null)
71 AppLogException("Create instance has failed");
73 pRecurrence->SetFrequency(FREQ_DAILY);
74 r = pRecurrence->SetCounts(10);
77 AppLogException("Set counts has failed");
82 * 2. Repeat weekly until May 4, 2009:
87 MyRecurrence::RepeatDayilyUntil(void)
90 Recurrence* pRecurrence = new Recurrence();
91 if (IsFailed(GetLastResult()) || pRecurrence == null)
93 AppLogException("Create instance has failed");
96 r = until.SetValue(2009, 5, 4);
99 AppLogException("Set date/time has failed");
102 pRecurrence->SetFrequency(FREQ_WEEKLY);
103 r = pRecurrence->SetUntil(&until);
106 AppLogException("Set until has failed");
112 * 3. Repeat bi-weekly on Tuesday and Thursday until May 4, 2009:
116 MyRecurrence::RepeatByWeeklyUntil(void)
119 Recurrence* pRecurrence = new Recurrence();
120 if (IsFailed(GetLastResult()) || pRecurrence == null)
122 AppLogException("Create instance has failed");
126 r = until.SetValue(2009, 5, 4);
129 AppLogException("Set date/time has failed");
132 pRecurrence->SetFrequency(FREQ_WEEKLY);
133 r = pRecurrence->SetInterval(2);
136 AppLogException("Set interval has failed");
139 r = pRecurrence->SetDayOfWeek(CAL_TUESDAY | CAL_THURSDAY);
142 AppLogException("Set day of week has failed");
145 r = pRecurrence->SetUntil(&until);
148 AppLogException("Set until has failed");
153 * 4. Repeat monthly on the first Thursday for 10 occurrences. The week starts on Monday:
157 MyRecurrence::RepeatMonthlyUntil(void)
160 Recurrence* pRecurrence = new Recurrence();
161 if (IsFailed(GetLastResult()) || pRecurrence == null)
163 AppLogException("Create instance has failed");
166 pRecurrence->SetFrequency(FREQ_MONTHLY);
168 r = pRecurrence->SetWeekStart(CAL_MONDAY);
171 AppLogException("Set week start has failed");
174 r = pRecurrence->SetDayOfWeek(CAL_THURSDAY);
177 AppLogException("Set day of the week has failed");
180 r = pRecurrence->SetWeekOfMonth(1);
183 AppLogException("Set week of month has failed");
186 r = pRecurrence->SetCounts(10);
189 AppLogException("Set counts has failed");
196 class _OSP_EXPORT_ Recurrence
197 : public Tizen::Base::Object
201 * This is the default constructor for this class. @n
202 * This constructor sets the default values. The recurrence type is daily and recurrence interval is @c 1. @n
203 * The week start day is #CAL_MONDAY. The recurrence count is @c 1.
210 * Copying of objects using this copy constructor is allowed.
214 * @param[in] rhs An instance of %Recurrence
216 Recurrence(const Recurrence& rhs);
219 * This destructor overrides Tizen::Base::Object::~Object().
223 virtual ~Recurrence(void);
226 * Compares the input Tizen::Base::Object with the calling %Recurrence instance.
230 * @return @c true if the input object equals the calling %Recurrence instance, @n
232 * @param[in] rhs The object instance to compare with the calling object
235 virtual bool Equals(const Tizen::Base::Object& rhs) const;
238 * Gets the hash value of the current instance.
242 * @return The hash value of the current instance
244 virtual int GetHashCode(void) const;
247 * Gets the recurrence frequency type.
251 * @return A reference to one of the @c RecurFrequency enumeration values, @n
252 * else #FREQ_DAILY if this property is not set
254 RecurFrequency GetFrequency(void) const;
257 * Gets the recurrence interval. @n
258 * This represents the number of units between two recurrences. @n
259 * If the frequency is weekly and the recurrence interval is set to @c 2, the event occurs every two weeks.
263 * @return An integer value representing the recurrence interval, @n
264 * else @c 1 if this property is not set
266 int GetInterval(void) const;
269 * Gets the end date and time of recurrence.
273 * @return An instance of Tizen::Base::DateTime representing the end date and time
274 * @remarks If this method returns @c null, get the recurrence counts using the GetCounts() method.
277 const Tizen::Base::DateTime* GetUntil(void) const;
280 * Gets the number of times the event recurs.
284 * @return An integer value representing the number of recurrences
285 * @remarks If this method returns @c 0, get the recurrence end date and time using the GetUntil() method.
288 int GetCounts(void) const;
291 * Gets the first day of the week. @n
292 * The default value is #CAL_MONDAY.
296 * @return An integer value representing the first day of the week
299 CalDayOfWeek GetWeekStart(void) const;
302 * Gets the day of the week when the event should recur. @n
303 * The default value is @c 0.
307 * @return An integer value representing the CalDayofWeek
308 * @remarks The Frequency property must be obtained. If the frequency is #FREQ_WEEKLY, the return value may be a combination of days,
309 * like #CAL_MONDAY| #CAL_THURSDAY.
312 int GetDayOfWeek(void) const;
315 * Gets the day of the month. @n
316 * The default value is @c 0.
320 * @return An integer value between @c 1 ~ @c 31 representing the day of a month
321 * @remarks The Frequency property must be obtained.
323 int GetDayOfMonth(void) const;
326 * Gets the week of the month. @n
327 * The default value is @c 0.
331 * @return An integer value between @c 1 ~ @c 5 representing the week of a month
332 * @remarks The Frequency property must be obtained.
335 int GetWeekOfMonth(void) const;
338 * Gets the month of the year. @n
339 * The default value is @c 0.
343 * @return An integer value between @c 1 ~ @c 12 representing the month of a year
344 * @remarks The Frequency property must be obtained.
347 int GetMonthOfYear(void) const;
350 * Sets a recurring frequency type among specific types (daily, weekly, monthly, and yearly). @n
351 * This property must be set before setting the day of recurrence. After setting the frequency, other properties are reset to default values. @n
352 * For weekly, the day of week must be set. @n
353 * For monthly, the day of the week and the week of the month must be set. @n
354 * For yearly, either the day of the month and the month of the year, or the day of the week, the week of the month, and the month of the year must be set.
358 * @param[in] type The recurrence type
361 void SetFrequency(RecurFrequency type);
364 * Sets the interval of recurrence. @n
365 * If the frequency is weekly and the recurrence interval is set to 2, the event occurs every two weeks.
368 * @brief <i> [Compatibility] </i>
372 * @compatibility This method has compatibility issues with OSP compatible applications. @n
373 * For more information, see @ref CompRecurrenceSetIntervalPage "here".
376 * @return An error code
377 * @param[in] interval The interval of recurrence
378 * @exception E_SUCCESS The method is successful.
379 * @exception E_INVALID_ARG The specified @c interval is less than @c 1.
381 result SetInterval(int interval);
385 * @page CompRecurrenceSetIntervalPage Compatibility for SetInterval()
386 * @section CompRecurrenceSetIntervalPageIssueSection Issues
387 * Implementing this method in OSP compatible applications has the following issues: @n
388 * -# If the value of the interval to be set is greater than 255, E_INVALID_ARG is returned.
390 * @section CompRecurrenceSetIntervalPageSolutionSection Resolutions
391 * This issue has been resolved in Tizen. @n
392 * -# There is no limit for the value of the interval.
397 * Sets the end date of the recurrence. @n
398 * If you want to set the event to have no end date, set the maximum date and time using the Tizen::Base::DateTime::GetMaxValue() method.
402 * @return An error code
403 * @param[in] pUntil The end date and time
404 * @exception E_SUCCESS The method is successful.
405 * @exception E_INVALID_ARG The @c pUntil is not in a valid range. @n
406 * The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
407 * @remarks Either the until or count properties may be set. @n
408 * When the until property is set, the count property becomes @c 0. @n
409 * When the count property is set, the until property becomes @c null.
411 result SetUntil(const Tizen::Base::DateTime* pUntil);
414 * Sets the number of times the event recurs.
418 * @return An error code
419 * @param[in] count The number of times the event recurs
420 * @exception E_SUCCESS The method is successful.
421 * @exception E_INVALID_ARG The specified @c count is less than @c 0.
422 * @remarks Either the until or count properties may be set. @n
423 * When the until property is set, the count property becomes @c 0. @n
424 * When the count property is set, the until property becomes @c null. @n
426 result SetCounts(int count);
429 * Sets the first day of the week. @n
430 * The default value is set to #CAL_MONDAY. The valid values are #CAL_SUNDAY and #CAL_MONDAY. @n
431 * This value is very important when the recurrence type is weekly and the interval is greater than @c 1. @n
432 * The weekly recurrence rule will be calculated based on the week start value.
436 * @return An error code
437 * @param[in] weekStart The day on which the week starts
438 * @exception E_SUCCESS The method is successful.
439 * @exception E_INVALID_ARG The specified @c day is invalid.
441 result SetWeekStart(CalDayOfWeek weekStart);
444 * Sets the day of the week that represents the days when the event should recur. @n
445 * The valid values range between #CAL_SUNDAY and #CAL_SATURDAY. @n
446 * Any values other than #CAL_SUNDAY ~ #CAL_SATURDAY are ignored. @n
447 * The Frequency property must be set before setting this property.
448 * This property is valid for the following #RecurFrequency enumeration types: #FREQ_WEEKLY, #FREQ_MONTHLY, and #FREQ_YEARLY.
449 * If the frequency is #FREQ_WEEKLY, the value of the day may be a combination of days, such as #CAL_MONDAY|#CAL_FRIDAY.
453 * @return An error code
454 * @param[in] day An integer value representing the day of the week
455 * @exception E_SUCCESS The method is successful.
456 * @exception E_INVALID_ARG The specified @c day is invalid.
457 * @exception E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_WEEKLY, #FREQ_MONTHLY, or #FREQ_YEARLY.
458 * @remarks After this property is set, the DayOfMonth property value is reset automatically.
460 result SetDayOfWeek(int day);
463 * Sets the day of the month which indicates when the event recurs. @n
464 * The Frequency property must be set before setting this property. @n
465 * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY. @n
466 * If the day of the month is 31 and the frequency is monthly, the months which have only 30 days are not included in the recurrence instance set. @c
467 * Accordingly, with the recurrence rule, 2/29 yearly, 2/29 every four years will be included in the recurrence set.
471 * @return An error code
472 * @param[in] day An integer value between @c 1 and @c 31 indicating the day of the month
473 * @exception E_SUCCESS The method is successful.
474 * @exception E_INVALID_ARG The specified @c day is less than @c 1 or greater than @c 31.
475 * @exception E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
476 * @remarks After this property is set, the DayOfWeek and WeekOfMonth property value are reset automatically.
478 result SetDayOfMonth(int day);
481 * Sets the week of the month. @n
482 * If the value of the week is @c 5, it is set as the last week of the month. @n
483 * This property is valid for the following #RecurFrequency enumeration types: #FREQ_MONTHLY and #FREQ_YEARLY.
484 * The Frequency property must be set before setting this property. @n
485 * When the week of the month is set, the day of the week must be set accordingly.
489 * @return An error code
490 * @param[in] week An integer value between @c 1 and @c 5 representing the week of the month
491 * @exception E_SUCCESS The method is successful.
492 * @exception E_INVALID_ARG The specified @c week is less than @c 1 or greater than @c 5.
493 * @exception E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_MONTHLY or #FREQ_YEARLY.
494 * @remarks After this property is set, the DayOfMonth property value is reset automatically.
496 result SetWeekOfMonth(int week);
499 * Sets the month of the year. @n
500 * This property is valid for the following #RecurFrequency enumeration type: #FREQ_YEARLY. @n
501 * The Frequency property must be set before setting this property. @n
502 * When the month of the year is set, the day of the month or both the day of the week and the week of the month must be set accordingly.
506 * @return An error code
507 * @param[in] month An integer value between @c 1 and @c 12 representing the month of the year
508 * @exception E_SUCCESS The method is successful.
509 * @exception E_INVALID_ARG The specified @c month is less than @c 1 or greater than @c 12.
510 * @exception E_TYPE_MISMATCH The #RecurFrequency is not #FREQ_YEARLY.
512 result SetMonthOfYear(int month);
515 * Adds an exception date to this event.
516 * The instance that its start date and time matched with the exception date will be exclude from recurrence instances.
517 * If there are any changes in this recurrence, the exception dates would be cleared.
521 * @return An error code
522 * @param[in] exceptionDate The exception date to exclude
523 * @exception E_SUCCESS The method is successful.
524 * @exception E_INVALID_ARG The specified @c exceptionDate is invalid.
525 * @exception E_OBJ_ALREADY_EXIST The specified @c exceptionDate already exists.
527 result AddExceptionDate(const Tizen::Base::DateTime& exceptionDate);
530 * Gets the exception dates.
534 * @return A list containing the exception dates, @n
535 * else an empty list if there are no exception dates, or @c null if an exception occurs @n
536 * The results are listed in the order of date and time.
537 * @exception E_SUCCESS The method is successful.
538 * @exception E_OUT_OF_MEMORY The memory is insufficient.
539 * @remarks The specific error code can be accessed using the GetLastResult() method.
541 Tizen::Base::Collection::IList* GetExceptionDatesN(void) const;
544 * Copying of objects using this copy assignment operator is allowed.
548 * @param[in] rhs An instance of %Recurrence
550 Recurrence& operator =(const Recurrence& rhs);
553 friend class _RecurrenceImpl;
554 class _RecurrenceImpl* __pRecurrenceImpl;
559 #endif // _FSCL_RECURRENCE_H_