Fix code for TDIS-5396
[framework/osp/social.git] / src / FScl_CalendarbookUtil.h
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                FScl_CalendarbookUtil.h
19  * @brief       This is the header file for the _CalendarbookUtil class.
20  *
21  * This header file contains the declarations of the _CalendarbookUtil class.
22  */
23
24 #ifndef _FSCL_INTERNAL_CALENDARBOOK_UTIL_H_
25 #define _FSCL_INTERNAL_CALENDARBOOK_UTIL_H_
26
27 #include <calendar2.h>
28 #include <FSclTypes.h>
29
30 namespace Tizen { namespace Base
31 {
32 class String;
33 class DateTime;
34 class ByteBuffer;
35 namespace Collection
36 {
37 class ArrayList;
38 }
39 }}
40
41 namespace Tizen { namespace Locales
42 {
43 class TimeZone;
44 }}
45
46 namespace Tizen { namespace Social
47 {
48
49 class _CalendarRecord
50 {
51 public :
52         _CalendarRecord()
53                 : __recordHandle(null)
54         {
55         }
56
57         _CalendarRecord(calendar_record_h recordHandle)
58                 : __recordHandle(recordHandle)
59         {
60         }
61
62         ~_CalendarRecord(void)
63         {
64                 if (__recordHandle)
65                 {
66                         calendar_record_destroy(__recordHandle, true);
67                 }
68         }
69
70         const calendar_record_h GetHandle(void) const
71         {
72                 return __recordHandle;
73         }
74
75         calendar_record_h GetHandle(void)
76         {
77                 return __recordHandle;
78         }
79
80         calendar_record_h ReleaseHandle(void)
81         {
82                 calendar_record_h recordHandle = __recordHandle;
83                 __recordHandle = null;
84                 return recordHandle;
85         }
86
87         void ResetHandle(calendar_record_h recordHandle)
88         {
89                 if (__recordHandle)
90                 {
91                         calendar_record_destroy(__recordHandle, true);
92                 }
93                 __recordHandle = recordHandle;
94         }
95
96 private :
97         calendar_record_h __recordHandle;
98 };
99
100 /**
101  *      @class  _CalendarbookUtil
102  *      @brief  This class represents the calendarbook util.
103  *
104  * The _CalendarbookUtil class support various utilities.
105  */
106 class  _CalendarbookUtil
107 {
108 public:
109         static result ConvertEventAlarmsToReminderList(calendar_record_h calendarRecordHandle, Tizen::Base::Collection::ArrayList& reminderList);
110         static result ConvertTodoAlarmsToReminderList(calendar_record_h calendarRecordHandle, Tizen::Base::Collection::ArrayList& reminderList);
111         static char* ConvertByteBufferToCharArrayN(const Tizen::Base::ByteBuffer& byteBuffer);
112         static Tizen::Base::ByteBuffer* ConvertCharArrayToByteBufferN(const char* pCharArray);
113
114         static long long int ConvertDateTimeToEpochTime(const Tizen::Base::DateTime& dateTime);
115         static Tizen::Base::DateTime ConvertEpochTimeToDateTime(long long int dateTime);
116         static void ConvertDateTimeToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime);
117         static void ConvertDateToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime);
118
119         static Tizen::Base::String ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate);
120         static result ConvertRRuleDateTimeStringToDateTime(const Tizen::Base::String& dateTimeString, Tizen::Base::DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate);
121
122         static calendar_event_status_e ConvertEventStatusToCSEventStatus(int status);
123         static calendar_event_busy_status_e ConvertBusyStatusToCSEventBusyStatus(int busyStatus);
124         static calendar_event_priority_e ConvertEventPriorityToCSEventPriority(int priority);
125         static calendar_sensitivity_e ConvertSensitivityToCSSensitivity(int sensitivity);
126         static calendar_todo_status_e ConvertTodoStatusToCSTodoStatus(int status);
127         static calendar_todo_priority_e ConvertTodoPriorityToCSTodoPriority(int priority);
128         static int ConvertCalendarItemTypeToCSCalendarbookType(int itemType);
129         static EventCategory ConvertCSCategoriesToEventCategory(const char* pCategories);
130
131         static int GetMaxDaysOfMonth(int year, int month);
132         static bool CheckValidDateTime(const Tizen::Base::DateTime& dateTime);
133
134 private:
135
136         /**
137          * This destructor is intentionally declared as private because this class cannot be constructed.
138          */
139         ~_CalendarbookUtil(void);
140 };      // _CalendarbookUtil
141
142 }}      // Tizen::Social
143
144 #endif//_FSCL_INTERNAL_CALENDARBOOK_UTIL_H_