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