c7ef3a47179cce68138c40cb5d04cdc4f5e92ac4
[platform/core/pim/calendar-service.git] / include / calendar_vcalendar.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 #ifndef __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__
20 #define __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__
21
22 #include <calendar_view.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @file calendar_vcalendar.h
30  */
31
32 /**
33  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE
34  * @{
35  */
36
37 /**
38  * @brief Retrieves a vcalendar stream from a calendar list.
39  *
40  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
41  *
42  * @param[in]   calendar_list       The calendar list handle
43  * @param[out]  vcalendar_stream    The vcalendar stream
44  *
45  * @return  @c 0 on success,
46  *          otherwise a negative error value
47  * @retval  #CALENDAR_ERROR_NONE                Successful
48  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
49  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
50  * @retval  #CALENDAR_ERROR_NO_DATA             Requested data does not exist
51  */
52 int calendar_vcalendar_make_from_records(calendar_list_h calendar_list, char **vcalendar_stream);
53
54 /**
55  * @brief Retrieves all calendars from a vcalendar stream.
56  *
57  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
58  *
59  * @param[in]   vcalendar_stream    The vcalendar stream
60  * @param[out]  calendar_list       The calendar list handle
61  *
62  * @return  @c 0 on success,
63  *          otherwise a negative error value
64  * @retval  #CALENDAR_ERROR_NONE                Successful
65  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
66  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
67  * @retval  #CALENDAR_ERROR_NO_DATA             Requested data does not exist
68  *
69  * @pre     calendar_connect() should be called to initialize.
70  *
71  */
72 int calendar_vcalendar_parse_to_calendar(const char* vcalendar_stream, calendar_list_h *calendar_list);
73
74 /**
75  * @brief Called to get a record handle of
76  * \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo.
77  *
78  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
79  *
80  * @param[in]   record     The record handle (\ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo)
81  * @param[in]   user_data  The user data passed from the foreach function
82  *
83  * @return      @c true to continue with the next iteration of the loop,
84  *          otherwise @c false to break out of the loop
85  *
86  * @pre calendar_vcalendar_parse_to_calendar_foreach() will invoke this callback.
87  *
88  * @see calendar_vcalendar_parse_to_calendar_foreach()
89  * @see calendar_record_get_uri_p()
90  */
91 typedef bool (*calendar_vcalendar_parse_cb)(calendar_record_h record, void *user_data);
92
93 /**
94  * @brief Retrieves all events or to-dos
95  * (\ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo) from a vCalendar file.
96  *
97  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
98  *
99  * @param[in]   vcalendar_file_path     The file path of the vCalendar stream file
100  * @param[in]   callback                The callback function to be invoked
101  * @param[in]   user_data               The user data to be passed to the callback function
102  *
103  * @return  @c 0 on success,
104  *          otherwise a negative error value
105  * @retval  #CALENDAR_ERROR_NONE                Successful
106  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
107  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
108  *
109  * @pre  calendar_connect() should be called to initialize.
110  *
111  * @post This function invokes calendar_vcalendar_parse_cb().
112  *
113  * @see  calendar_vcalendar_parse_cb()
114  * @see  calendar_record_get_uri_p()
115  */
116 int calendar_vcalendar_parse_to_calendar_foreach(const char *vcalendar_file_path, calendar_vcalendar_parse_cb callback, void *user_data);
117
118 /**
119  * @}
120  */
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif /* __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__ */
127