Fixed update instance
[framework/osp/social.git] / src / FSclCalendarbook.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                FSclCalendarbook.cpp
19  * @brief               This is the implementation for Calendarbook class.
20  *
21  * This file contains definitions of @e Calendarbook class.
22  */
23
24 #include <new>
25 #include <FSclCalendarbook.h>
26 #include <FBaseSysLog.h>
27 #include <FSec_AccessController.h>
28 #include "FScl_CalEventImpl.h"
29 #include "FScl_CalTodoImpl.h"
30 #include "FScl_CalendarbookImpl.h"
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Security;
35
36 namespace Tizen { namespace Social
37 {
38
39 Calendarbook::Calendarbook(void)
40         : __pCalendarbookImpl(null)
41 {
42 }
43
44 Calendarbook::~Calendarbook(void)
45 {
46         delete __pCalendarbookImpl;
47 }
48
49 result
50 Calendarbook::Construct(void)
51 {
52         SysAssertf(__pCalendarbookImpl == null,
53                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
54
55         result r = E_SUCCESS;
56         _CalendarbookImpl* pCalendarbookImpl = null;
57
58         pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
59         SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
60
61         r = pCalendarbookImpl->Construct();
62         SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
63
64         __pCalendarbookImpl = pCalendarbookImpl;
65
66         return E_SUCCESS;
67
68 CATCH:
69         delete pCalendarbookImpl;
70
71         return r;
72 }
73
74 result
75 Calendarbook::Construct(IRecordEventListener* pListener)
76 {
77         SysAssertf(__pCalendarbookImpl == null,
78                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
79
80         result r = E_SUCCESS;
81         _CalendarbookImpl* pCalendarbookImpl = null;
82
83         pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
84         SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
85
86         r = pCalendarbookImpl->Construct(pListener);
87         SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
88
89         __pCalendarbookImpl = pCalendarbookImpl;
90
91         return E_SUCCESS;
92
93 CATCH:
94         delete pCalendarbookImpl;
95
96         return r;
97 }
98
99 result
100 Calendarbook::Construct(ICalendarbookEventListener& listener)
101 {
102         SysAssertf(__pCalendarbookImpl == null,
103                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
104
105         result r = E_SUCCESS;
106         _CalendarbookImpl* pCalendarbookImpl = null;
107
108         pCalendarbookImpl = new (std::nothrow) _CalendarbookImpl();
109         SysTryReturnResult(NID_SCL, pCalendarbookImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
110
111         r = pCalendarbookImpl->Construct(listener);
112         SysTryCatch(NID_SCL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
113
114         __pCalendarbookImpl = pCalendarbookImpl;
115
116         return E_SUCCESS;
117
118 CATCH:
119         delete pCalendarbookImpl;
120
121         return r;
122 }
123
124 result
125 Calendarbook::AddEvent(CalEvent& event)
126 {
127         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
128                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
129         SysAssertf(__pCalendarbookImpl != null,
130                         "Not yet constructed. Construct() should be called before use.");
131
132         result r = __pCalendarbookImpl->AddEvent(event);
133         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
134
135         return E_SUCCESS;
136 }
137
138 result
139 Calendarbook::AddEvent(CalEvent& event, RecordId calendarId)
140 {
141         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
142                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
143         SysAssertf(__pCalendarbookImpl != null,
144                         "Not yet constructed. Construct() should be called before use.");
145
146         result r = __pCalendarbookImpl->AddEvent(event, calendarId);
147         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
148
149         return E_SUCCESS;
150 }
151
152 result
153 Calendarbook::AddTodo(CalTodo& todo)
154 {
155         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
156                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
157         SysAssertf(__pCalendarbookImpl != null,
158                         "Not yet constructed. Construct() should be called before use.");
159
160         result r = __pCalendarbookImpl->AddTodo(todo);
161         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
162
163         return E_SUCCESS;
164 }
165
166 result
167 Calendarbook::AddTodo(CalTodo& todo, RecordId calendarId)
168 {
169         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
170                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
171         SysAssertf(__pCalendarbookImpl != null,
172                         "Not yet constructed. Construct() should be called before use.");
173
174         result r = __pCalendarbookImpl->AddTodo(todo, calendarId);
175         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
176
177         return E_SUCCESS;
178 }
179
180 result
181 Calendarbook::RemoveEvent(CalEvent& event)
182 {
183         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
184                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
185         SysAssertf(__pCalendarbookImpl != null,
186                         "Not yet constructed. Construct() should be called before use.");
187
188         result r = __pCalendarbookImpl->RemoveEvent(event);
189         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
190
191         return E_SUCCESS;
192 }
193
194 result
195 Calendarbook::RemoveEvent(RecordId eventId)
196 {
197         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
198                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
199         SysAssertf(__pCalendarbookImpl != null,
200                         "Not yet constructed. Construct() should be called before use.");
201
202         result r = __pCalendarbookImpl->RemoveEvent(eventId);
203         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
204
205         return E_SUCCESS;
206 }
207
208 result
209 Calendarbook::RemoveTodo(CalTodo& todo)
210 {
211         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
212                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
213         SysAssertf(__pCalendarbookImpl != null,
214                         "Not yet constructed. Construct() should be called before use.");
215
216         result r = __pCalendarbookImpl->RemoveTodo(todo);
217         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
218
219         return E_SUCCESS;
220 }
221
222 result
223 Calendarbook::RemoveTodo(RecordId todoId)
224 {
225         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
226                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
227         SysAssertf(__pCalendarbookImpl != null,
228                         "Not yet constructed. Construct() should be called before use.");
229
230         result r = __pCalendarbookImpl->RemoveTodo(todoId);
231         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
232
233         return E_SUCCESS;
234 }
235
236 result
237 Calendarbook::UpdateEvent(const CalEvent& event)
238 {
239         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
240                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
241         SysAssertf(__pCalendarbookImpl != null,
242                         "Not yet constructed. Construct() should be called before use.");
243
244         result r = __pCalendarbookImpl->UpdateEvent(event);
245         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
246
247         return E_SUCCESS;
248 }
249
250 result
251 Calendarbook::UpdateTodo(const CalTodo& todo)
252 {
253         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
254                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
255         SysAssertf(__pCalendarbookImpl != null,
256                         "Not yet constructed. Construct() should be called before use.");
257
258         result r = __pCalendarbookImpl->UpdateTodo(todo);
259         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
260
261         return E_SUCCESS;
262 }
263
264 CalEvent*
265 Calendarbook::GetEventN(RecordId eventId) const
266 {
267         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
268                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
269         SysAssertf(__pCalendarbookImpl != null,
270                         "Not yet constructed. Construct() should be called before use.");
271
272         CalEvent* pEvent = __pCalendarbookImpl->GetEventN(eventId);
273         result r = GetLastResult();
274         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
275
276         return pEvent;
277 }
278
279 CalTodo*
280 Calendarbook::GetTodoN(RecordId todoId) const
281 {
282         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
283                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
284         SysAssertf(__pCalendarbookImpl != null,
285                                 "Not yet constructed. Construct() should be called before use.");
286
287         CalTodo* pTodo = __pCalendarbookImpl->GetTodoN(todoId);
288         result r = GetLastResult();
289         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
290
291         return pTodo;
292 }
293
294 IList*
295 Calendarbook::GetTodosN(const DateTime& start, const DateTime& end, int pageNo, int countPerPage, unsigned long status,
296                                                 unsigned long priority) const
297 {
298         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
299                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
300         SysAssertf(__pCalendarbookImpl != null,
301                         "Not yet constructed. Construct() should be called before use.");
302
303         IList* pList = __pCalendarbookImpl->GetTodosN(start, end, pageNo, countPerPage, status, priority);
304         result r = GetLastResult();
305         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
306
307         return pList;
308 }
309
310 int
311 Calendarbook::GetTodoCount(const DateTime& start, const DateTime& end, unsigned long status, unsigned long priority) const
312 {
313         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, _INVALID_COUNT,
314                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
315         SysAssertf(__pCalendarbookImpl != null,
316                         "Not yet constructed. Construct() should be called before use.");
317
318         int count = __pCalendarbookImpl->GetTodoCount(start, end, status, priority);
319         result r = GetLastResult();
320         SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_COUNT, r, "[%s] Propagating.", GetErrorMessage(r));
321
322         return count;
323 }
324
325 IList*
326 Calendarbook::GetEventInstancesN(const DateTime& start, const DateTime& end,
327                                                                  const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage,
328                                                                  unsigned long category) const
329 {
330         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
331                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
332         SysAssertf(__pCalendarbookImpl != null,
333                         "Not yet constructed. Construct() should be called before use.");
334         IList* pList = __pCalendarbookImpl->GetEventInstancesN(start, end, timeZone, pageNo, countPerPage, category);
335         result r = GetLastResult();
336         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
337
338         return pList;
339 }
340
341 result
342 Calendarbook::GetEventInstances(const DateTime& start, const DateTime& end,
343                                                                 const Tizen::Locales::TimeZone& timeZone, int pageNo, int countPerPage, unsigned long category,
344                                                                 RequestId& reqId,
345                                                                 const IRecordListener& listener) const
346 {
347         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS,
348                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
349         SysAssertf(__pCalendarbookImpl != null,
350                         "Not yet constructed. Construct() should be called before use.");
351
352         result r = __pCalendarbookImpl->GetEventInstances(start, end, timeZone, pageNo, countPerPage, category, reqId, listener);
353         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
354
355         return E_SUCCESS;
356 }
357
358 IList*
359 Calendarbook::GetAllEventsN(void) const
360 {
361         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
362                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
363         SysAssertf(__pCalendarbookImpl != null,
364                         "Not yet constructed. Construct() should be called before use.");
365
366         IList* pList = __pCalendarbookImpl->GetAllEventsN();
367         result r = GetLastResult();
368         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
369
370         return pList;
371 }
372
373 IList*
374 Calendarbook::GetAllTodosN(void) const
375 {
376         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
377                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
378         SysAssertf(__pCalendarbookImpl != null,
379                         "Not yet constructed. Construct() should be called before use.");
380
381         IList* pList = __pCalendarbookImpl->GetAllTodosN();
382         result r = GetLastResult();
383         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
384
385         return pList;
386 }
387
388 IList*
389 Calendarbook::GetAllCalendarsN(void) const
390 {
391         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
392                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
393         SysAssertf(__pCalendarbookImpl != null,
394                         "Not yet constructed. Construct() should be called before use.");
395
396         IList* pList = __pCalendarbookImpl->GetAllCalendarsN();
397         result r = GetLastResult();
398         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
399
400         return pList;
401 }
402
403 IList*
404 Calendarbook::GetChangedEventsAfterN(int version, int& latestVersion) const
405 {
406         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
407                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
408         SysAssertf(__pCalendarbookImpl != null,
409                         "Not yet constructed. Construct() should be called before use.");
410
411         IList* pList = __pCalendarbookImpl->GetChangedEventsAfterN(version, latestVersion);
412         result r = GetLastResult();
413         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
414
415         return pList;
416 }
417
418 IList*
419 Calendarbook::GetChangedTodosAfterN(int version, int& latestVersion) const
420 {
421         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
422                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
423         SysAssertf(__pCalendarbookImpl != null,
424                         "Not yet constructed. Construct() should be called before use.");
425
426         IList* pList = __pCalendarbookImpl->GetChangedTodosAfterN(version, latestVersion);
427         result r = GetLastResult();
428         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
429
430         return pList;
431 }
432
433 result
434 Calendarbook::AddCalendar(Calendar& calendar)
435 {
436         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
437                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
438         SysAssertf(__pCalendarbookImpl != null,
439                         "Not yet constructed. Construct() should be called before use.");
440
441         result r = __pCalendarbookImpl->AddCalendar(calendar);
442         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
443
444         return E_SUCCESS;
445 }
446
447 result
448 Calendarbook::AddCalendar(Calendar& calendar, AccountId accountId)
449 {
450         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
451                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
452         SysAssertf(__pCalendarbookImpl != null,
453                         "Not yet constructed. Construct() should be called before use.");
454
455         result r = __pCalendarbookImpl->AddCalendar(calendar, accountId);
456         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
457
458         return E_SUCCESS;
459 }
460
461 result
462 Calendarbook::RemoveCalendar(RecordId calendarId)
463 {
464         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
465                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
466         SysAssertf(__pCalendarbookImpl != null,
467                         "Not yet constructed. Construct() should be called before use.");
468
469         result r = __pCalendarbookImpl->RemoveCalendar(calendarId);
470         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
471
472         return E_SUCCESS;
473 }
474
475 result
476 Calendarbook::UpdateCalendar(const Calendar& calendar)
477 {
478         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
479                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
480         SysAssertf(__pCalendarbookImpl != null,
481                         "Not yet constructed. Construct() should be called before use.");
482
483         result r = __pCalendarbookImpl->UpdateCalendar(calendar);
484         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
485
486         return E_SUCCESS;
487 }
488
489 Calendar*
490 Calendarbook::GetCalendarN(RecordId calendarId) const
491 {
492         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
493                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
494         SysAssertf(__pCalendarbookImpl != null,
495                         "Not yet constructed. Construct() should be called before use.");
496
497         Calendar* pCalendar = __pCalendarbookImpl->GetCalendarN(calendarId);
498         result r = GetLastResult();
499         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
500
501         return pCalendar;
502 }
503
504 result
505 Calendarbook::RemoveEventInstance(const CalEventInstance& eventInstance)
506 {
507         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
508                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
509         SysAssertf(__pCalendarbookImpl != null,
510                         "Not yet constructed. Construct() should be called before use.");
511
512         result r = __pCalendarbookImpl->RemoveEventInstance(eventInstance);
513         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
514
515         return E_SUCCESS;
516 }
517
518 result
519 Calendarbook::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event)
520 {
521         SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS,
522                         E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
523         SysAssertf(__pCalendarbookImpl != null,
524                         "Not yet constructed. Construct() should be called before use.");
525
526         result r = __pCalendarbookImpl->UpdateEventInstance(eventInstance, event);
527         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
528
529         return E_SUCCESS;
530 }
531
532 int
533 Calendarbook::GetLatestVersion(void) const
534 {
535         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
536                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
537         SysAssertf(__pCalendarbookImpl != null,
538                         "Not yet constructed. Construct() should be called before use.");
539
540         int version = __pCalendarbookImpl->GetLatestVersion();
541         result r = GetLastResult();
542         SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_VERSION, r, "[%s] Propagating.", GetErrorMessage(r));
543
544         return version;
545 }
546
547 IList*
548 Calendarbook::SearchN(const CalendarbookFilter& filter, unsigned long propertySortedBy, SortOrder sortOrder, int offset, int maxCount) const
549 {
550         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
551                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
552         SysAssertf(__pCalendarbookImpl != null,
553                         "Not yet constructed. Construct() should be called before use.");
554
555         IList* pList = __pCalendarbookImpl->SearchN(filter, propertySortedBy, sortOrder, offset, maxCount);
556         result r = GetLastResult();
557         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
558
559         return pList;
560 }
561
562 int
563 Calendarbook::GetMatchedItemCount(const CalendarbookFilter& filter) const
564 {
565         SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_READ) == E_SUCCESS, null,
566                         E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
567         SysAssertf(__pCalendarbookImpl != null,
568                         "Not yet constructed. Construct() should be called before use.");
569
570         int count = __pCalendarbookImpl->GetMatchedItemCount(filter);
571         result r = GetLastResult();
572         SysTryReturn(NID_SCL, r == E_SUCCESS, _INVALID_VERSION, r, "[%s] Propagating.", GetErrorMessage(r));
573
574         return count;
575 }
576
577 IList*
578 Calendarbook::ParseEventsFromVcalendarN(const String& vCalFilePath)
579 {
580         IList* pList = _CalendarbookImpl::ParseEventsFromVcalendarN(vCalFilePath);
581         result r = GetLastResult();
582         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
583
584         return pList;
585 }
586
587 IList*
588 Calendarbook::ParseTodosFromVcalendarN(const String& vCalFilePath)
589 {
590         IList* pList = _CalendarbookImpl::ParseTodosFromVcalendarN(vCalFilePath);
591         result r = GetLastResult();
592         SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
593
594         return pList;
595 }
596
597 result
598 Calendarbook::ExportEventsToVcalendar(const IList& eventList, const String& vCalFilePath)
599 {
600         result r = _CalendarbookImpl::ExportEventsToVcalendar(eventList, vCalFilePath);
601         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
602
603         return E_SUCCESS;
604 }
605
606 result
607 Calendarbook::ExportTodosToVcalendar(const IList& todoList, const String& vCalFilePath)
608 {
609         result r = _CalendarbookImpl::ExportTodosToVcalendar(todoList, vCalFilePath);
610         SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
611
612         return E_SUCCESS;
613 }
614
615 DateTime
616 Calendarbook::GetMaxDateTime(void)
617 {
618         return _CalendarbookImpl::GetMaxDateTime();
619 }
620 DateTime
621 Calendarbook::GetMinDateTime(void)
622 {
623         return _CalendarbookImpl::GetMinDateTime();
624 }
625
626 }}      // Tizen::Social