Initialize Tizen 2.3
[framework/osp/social.git] / src / FSclRecurrence.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
17  * @file                FSclRecurrence.cpp
18  * @brief               This is the implementation for Recurrence class.
19  *
20  * This file contains definitions of @e Recurrence class.
21  */
22
23 #include <new>
24 #include <FBaseColIList.h>
25 #include <FSclRecurrence.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_RecurrenceImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31
32 namespace Tizen { namespace Social
33 {
34
35 Recurrence::Recurrence(void)
36         : __pRecurrenceImpl(null)
37 {
38         __pRecurrenceImpl = new (std::nothrow) _RecurrenceImpl();
39         SysTryReturnVoidResult(NID_SCL, __pRecurrenceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
40 }
41
42 Recurrence::Recurrence(const Recurrence& rhs)
43         : __pRecurrenceImpl(null)
44 {
45         __pRecurrenceImpl = new (std::nothrow) _RecurrenceImpl(*rhs.__pRecurrenceImpl);
46         SysTryReturnVoidResult(NID_SCL, __pRecurrenceImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
47 }
48
49 Recurrence::~Recurrence(void)
50 {
51         delete __pRecurrenceImpl;
52 }
53
54 Recurrence&
55 Recurrence::operator =(const Recurrence& rhs)
56 {
57         if (this == &rhs)
58         {
59                 return *this;
60         }
61
62         *__pRecurrenceImpl = *rhs.__pRecurrenceImpl;
63
64         return *this;
65 }
66
67 bool
68 Recurrence::Equals(const Object& rhs) const
69 {
70         const Recurrence* pRecurrence = dynamic_cast<const Recurrence*>(&rhs);
71         if (pRecurrence == null)
72         {
73                 return false;
74         }
75
76         return __pRecurrenceImpl->Equals(*_RecurrenceImpl::GetInstance(*pRecurrence));
77 }
78
79 int
80 Recurrence::GetHashCode(void) const
81 {
82         return __pRecurrenceImpl->GetHashCode();
83 }
84
85 RecurFrequency
86 Recurrence::GetFrequency(void) const
87 {
88         return __pRecurrenceImpl->GetFrequency();
89 }
90
91 int
92 Recurrence::GetInterval(void) const
93 {
94         return __pRecurrenceImpl->GetInterval();
95 }
96
97 const DateTime*
98 Recurrence::GetUntil(void) const
99 {
100         return __pRecurrenceImpl->GetUntil();
101 }
102
103 int
104 Recurrence::GetCounts(void) const
105 {
106         return __pRecurrenceImpl->GetCounts();
107 }
108
109 CalDayOfWeek
110 Recurrence::GetWeekStart(void) const
111 {
112         return __pRecurrenceImpl->GetWeekStart();
113 }
114
115 int
116 Recurrence::GetDayOfWeek(void) const
117 {
118         return __pRecurrenceImpl->GetDayOfWeek();
119 }
120
121 int
122 Recurrence::GetDayOfMonth(void) const
123 {
124         return __pRecurrenceImpl->GetDayOfMonth();
125 }
126
127 int
128 Recurrence::GetWeekOfMonth(void) const
129 {
130         return __pRecurrenceImpl->GetWeekOfMonth();
131 }
132
133 int
134 Recurrence::GetMonthOfYear(void)const
135 {
136         return __pRecurrenceImpl->GetMonthOfYear();
137 }
138
139 void
140 Recurrence::SetFrequency(RecurFrequency type)
141 {
142         __pRecurrenceImpl->SetFrequency(type);
143 }
144
145 result
146 Recurrence::SetInterval(int interval)
147 {
148         result r = __pRecurrenceImpl->SetInterval(interval);
149         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
150
151         return E_SUCCESS;
152 }
153
154 result
155 Recurrence::SetUntil(const DateTime* pUntil)
156 {
157         result r = __pRecurrenceImpl->SetUntil(pUntil);
158         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
159
160         return E_SUCCESS;
161 }
162
163 result
164 Recurrence::SetCounts(int count)
165 {
166         result r = __pRecurrenceImpl->SetCounts(count);
167         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
168
169         return E_SUCCESS;
170 }
171
172 result
173 Recurrence::SetWeekStart(CalDayOfWeek weekStart)
174 {
175         result r = __pRecurrenceImpl->SetWeekStart(weekStart);
176         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
177
178         return E_SUCCESS;
179 }
180
181 result
182 Recurrence::SetDayOfWeek(int day)
183 {
184         result r = __pRecurrenceImpl->SetDayOfWeek(day);
185         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
186
187         return E_SUCCESS;
188 }
189
190 result
191 Recurrence::SetDayOfMonth(int day)
192 {
193         result r = __pRecurrenceImpl->SetDayOfMonth(day);
194         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
195
196         return E_SUCCESS;
197 }
198
199 result
200 Recurrence::SetWeekOfMonth(int week)
201 {
202         result r = __pRecurrenceImpl->SetWeekOfMonth(week);
203         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
204
205         return E_SUCCESS;
206 }
207
208
209 result
210 Recurrence::SetMonthOfYear(int month)
211 {
212         result r = __pRecurrenceImpl->SetMonthOfYear(month);
213         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
214
215         return E_SUCCESS;
216 }
217
218 result
219 Recurrence::AddExceptionDate(const DateTime& exceptionDate)
220 {
221         result r = __pRecurrenceImpl->AddExceptionDate(exceptionDate);
222         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
223
224         return E_SUCCESS;
225 }
226
227 IList*
228 Recurrence::GetExceptionDatesN(void) const
229 {
230         IList* pList = __pRecurrenceImpl->GetExceptionDatesN();
231         result r = GetLastResult();
232         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
233
234         return pList;
235 }
236
237 }}      // Tizen::Social