4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef __CALENDAR_SVC_STRUCT_H__
20 #define __CALENDAR_SVC_STRUCT_H__
24 * @defgroup CALENDAR_SVC Calendar Service
25 * @section intro 2.0 calendar engine
26 * - this document maded for calendar service
27 * - this document contain api signature & usage
29 * @section CREATEINFO author infomation
30 * - author : heungjae jeong(hj98.jeong@samsung.com)
33 * @section DEPENDENCY DEPENDENCY
36 * @section MODIFYINFO Revision history
37 * - maximus/2010-09-06 : make api signature
38 * - maximus/2010-09-16 : add calendar type & exception date, change api name(remove _event)
39 * - maximus/2010-09-16 : add utility function(for vcalendar)
46 *cal_struct is an opaque type, it must be used via accessor functions.
49 * calendar_svc_struct_new(), calendar_svc_struct_free()
50 * calendar_svc_struct_get_value(), calendar_svc_struct_get_list(),
51 * calendar_svc_struct_store_value(), calendar_svc_struct_store_list()
53 typedef struct _cal_struct cal_struct;
57 * cal_value is an opaque type, it must be
58 * used via accessor functions.
60 * @see calendar_svc_struct_new(), calendar_svc_struct_free()
62 typedef struct _cal_value cal_value;
67 * cal_struct is an opaque type, it must be used via accessor functions.
69 * @see calendar_svc_find_event_list(), calendar_svc_event_get_changes()
70 * calendar_svc_get_event_by_period(), calendar_svc_iter_get_info(),
71 * calendar_svc_iter_next(), calendar_svc_iter_remove()
73 typedef struct _cal_iter cal_iter;
78 * @defgroup example example
79 * @ingroup CALENDAR_SVC
83 void insert_test(void)
85 cal_struct *event=NULL;
86 cal_value *attendee1=NULL,*attendee2=NULL;
87 GList *attendee_list=NULL;
89 calendar_svc_connect();
90 event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
92 calendar_svc_struct_set_str(event, CAL_VALUE_TXT_SUMMARY, "weekly meeting");
93 calendar_svc_struct_set_str(event, CAL_VALUE_TXT_DESCRIPTION, "review : project status");
94 calendar_svc_struct_set_str(event, CAL_VALUE_TXT_LOCATION, "meeting room #1");
96 attendee1 = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
98 calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, "heungjae jeong");
99 calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, "id@domain.com");
100 calendar_svc_value_set_int(attendee1, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, 1);
102 attendee_list = g_list_append(attendee_list, attendee1);
104 attendee2 = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
106 calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, "boncheol gu");
107 calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, "id@domain.com");
108 calendar_svc_value_set_str(attendee2, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, 0);
110 attendee_list = g_list_append(attendee_list, attendee2);
112 calendar_svc_struct_store_list(event, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list);
114 calendar_svc_insert(event);
115 calendar_svc_struct_free(&event);
117 calendar_svc_close();
123 * @addtogroup example
127 void update_test(void)
129 cal_struct *event=NULL;
130 cal_value *attendee1,*attendee2;
131 GList *attendee_list=NULL;
132 char * attendee_name = NULL;
134 calendar_svc_connect();
136 calendar_svc_get(CAL_STRUCT_SCHEDULE,1,&event)
138 calendar_svc_struct_set_str(event, CAL_VALUE_TXT_SUMMARY, "weekly meeting2");
140 attendee_list = calendar_svc_struct_get_list(event,CAL_VALUE_LST_ATTENDEE_LIST);
145 attendee1 = attendee_list->data;
147 attendee_name = calendar_svc_value_get_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
149 if(strcmp(attendee_name,"boncheol gu")==0)
151 calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME,"boncheol gu2");
153 else if(strcmp(attendee_name,"heungjae jeong")==0)
155 calendar_svc_value_set_int(attendee1, CAL_VALUE_INT_DETAIL_DELETE,true); // set delete flag
159 attendee2 = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
161 calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, "jihwa park");
162 calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, "id@domain.com");
164 attendee_list = g_list_append(attendee_list, attendee2);
166 calendar_svc_struct_store_list(event, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list);
168 calendar_svc_update(event);
169 calendar_svc_struct_free(&event);
171 calendar_svc_close();
178 * @addtogroup example
180 * get list/delete example
182 void delete_test(void)
184 cal_struct *event=NULL;
185 cal_value *attendee1=NULL,*attendee2=NULL;
186 GList *attendee_list=NULL;
192 calendar_svc_connect();
194 calendar_svc_event_get_changes(0, version, &iter);
195 ret = calendar_svc_iter_next(iter);
196 while(CAL_SUCCESS == ret)
198 calendar_svc_iter_get_info(iter, &event);
199 index = calendar_svc_struct_get_int(event,CAL_VALUE_INT_INDEX);
201 calendar_svc_delete(CAL_STRUCT_SCHEDULE,index);
203 calendar_svc_struct_free(&event);
204 ret = calendar_svc_iter_next(iter);
207 calendar_svc_iter_remove(&iter);
208 calendar_svc_close();
216 * @addtogroup example
224 cal_struct *event = NULL;
226 GList *get_list, *cursor;
229 ui_event_t appEvent={0,};
231 ret = calendar_svc_get(CAL_STRUCT_SCHEDULE,index,CAL_VALUE_MAIN_FILED, &event);
233 summary = calendar_svc_struct_get_str(event, CAL_VALUE_TXT_SUMMARY);
234 strncpy(appEvent.summay,summary,sizeof(appEvent.summay)-1);
238 calendar_svc_struct_get_list(event, CAL_VALUE_LST_ATTENDEE_LIST, &get_list);
241 for(;cursor;cursor=g_slist_next(cursor))
243 DBG("number Type = %d",
244 calendar_svc_value_get_int((cal_value*)cursor->data, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS));
247 calendar_svc_value_get_str((cal_value*)cursor->data, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME));
250 calendar_svc_struct_free(&event);
257 #endif /* __CALENDAR_SVC_STRUCT_H__ */