2 // Tizen Web Device API
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.
19 #include "EventRecurrenceRule.h"
20 #include <Commons/Exception.h>
21 #include <dpl/log/log.h>
26 EventRecurrenceRule::EventRecurrenceRule()
28 m_frequency = NO_RECURRENCE;
29 m_interval = DEFAULT_INTERVAL;
30 m_endDate = UNDEFINED_TIME;
31 m_occurrenceCount = -1;
32 StringArrayPtr stringArrayPtr(new StringArray());
33 m_daysOfTheWeek = stringArrayPtr;
34 m_daysOfTheWeekJSRef = NULL;
35 NumberArrayPtr numberArraySetPositionsPtr(new NumberArray());
36 m_setPositions = numberArraySetPositionsPtr;
37 m_setPositionsJSRef = NULL;
38 NumberArrayPtr numberArrayExceptionsPtr(new NumberArray());
39 m_exceptions = numberArrayExceptionsPtr;
40 m_exceptionsJSRef = NULL;
41 m_timeZone = DEFAULT_TIMEZONE;
45 EventRecurrenceRule::~EventRecurrenceRule()
47 if(m_daysOfTheWeekJSRef) {
48 LogDebug("Unprotect JS daysOfTheWeek.");
49 JSValueUnprotect(m_context, m_daysOfTheWeekJSRef);
51 if(m_daysOfTheWeekJSRef) {
52 LogDebug("Unprotect JS setPositions.");
53 JSValueUnprotect(m_context, m_setPositionsJSRef);
55 if(m_exceptionsJSRef) {
56 LogDebug("Unprotect JS exceptions.");
57 JSValueUnprotect(m_context, m_exceptionsJSRef);
61 EventRecurrenceRule::EventRecurrence EventRecurrenceRule::getFrequency() const
66 void EventRecurrenceRule::setFrequency(const EventRecurrenceRule::EventRecurrence &value)
71 int EventRecurrenceRule::getInterval() const
76 void EventRecurrenceRule::setInterval(const int &value)
81 long long int EventRecurrenceRule::getEndDate() const
86 void EventRecurrenceRule::setEndDate(long long int value)
91 long EventRecurrenceRule::getOccurrenceCount() const
93 return m_occurrenceCount;
95 void EventRecurrenceRule::setOccurrenceCount(long value)
97 m_occurrenceCount = value;
100 std::vector<int> EventRecurrenceRule::getDaysOfTheMonth() const
102 return m_daysOfTheMonth;
105 void EventRecurrenceRule::setDaysOfTheMonth(std::vector<int> value)
107 m_daysOfTheMonth = value;
110 StringArrayPtr EventRecurrenceRule::getDaysOfTheWeek() const
112 return m_daysOfTheWeek;
115 void EventRecurrenceRule::setDaysOfTheWeek(StringArrayPtr value)
117 m_daysOfTheWeek = value;
120 JSObjectRef EventRecurrenceRule::getDaysOfTheWeekJSRef() const
122 return m_daysOfTheWeekJSRef;
124 void EventRecurrenceRule::setDaysOfTheWeekJSRef(const JSObjectRef value)
126 m_daysOfTheWeekJSRef = value;
129 std::vector<int> EventRecurrenceRule::getDaysOfTheYear() const
131 return m_daysOfTheYear;
134 void EventRecurrenceRule::setDaysOfTheYear(std::vector<int> value)
136 m_daysOfTheYear = value;
139 std::vector<int> EventRecurrenceRule::getWeeksOfTheYear() const
141 return m_weeksOfTheYear;
144 void EventRecurrenceRule::setWeeksOfTheYear(std::vector<int> value)
146 m_weeksOfTheYear = value;
149 NumberArrayPtr EventRecurrenceRule::getSetPositions() const
151 return m_setPositions;
154 void EventRecurrenceRule::setSetPositions(NumberArrayPtr value)
156 m_setPositions = value;
159 JSObjectRef EventRecurrenceRule::getSetPositionsJSRef() const
161 return m_setPositionsJSRef;
164 void EventRecurrenceRule::setSetPositionsJSRef(const JSObjectRef value)
166 m_setPositionsJSRef = value;
169 NumberArrayPtr EventRecurrenceRule::getExceptions() const
174 void EventRecurrenceRule::setExceptions(NumberArrayPtr value)
176 m_exceptions = value;
179 JSObjectRef EventRecurrenceRule::getExceptionsJSRef() const
181 return m_exceptionsJSRef;
184 void EventRecurrenceRule::setExceptionsJSRef(const JSObjectRef value)
186 m_exceptionsJSRef = value;
189 std::string EventRecurrenceRule::getTimeZone() const
194 void EventRecurrenceRule::setTimeZone(std::string value)
199 JSContextRef EventRecurrenceRule::getContext() const
204 void EventRecurrenceRule::setContext(const JSContextRef contextRef)
206 m_context = contextRef;