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