merge with master
[framework/pim/calendar-service.git] / include / calendar_types2.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_SOCIAL_CALENDAR_TYPES_H__
18 #define __TIZEN_SOCIAL_CALENDAR_TYPES_H__
19
20 #include <stdint.h>
21 #include <tizen.h>
22 #include <calendar_errors.h>
23 #include <bundle.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #ifndef API
30 #define API __attribute__ ((visibility("default")))
31 #endif
32
33 #define _CALENDAR_HANDLE(A) typedef struct __##A* A;
34
35 #define _CALENDAR_BEGIN_VIEW() \
36                 typedef struct{ \
37                         const char* _uri;
38 #define _CALENDAR_PROPERTY_INT(property_id_name)        unsigned int property_id_name;
39 #define _CALENDAR_PROPERTY_STR(property_id_name)        unsigned int property_id_name;
40 #define _CALENDAR_PROPERTY_DOUBLE(property_id_name)     unsigned int property_id_name;
41 #define _CALENDAR_PROPERTY_LLI(property_id_name)        unsigned int property_id_name;
42 #define _CALENDAR_PROPERTY_CALTIME(property_id_name)    unsigned int property_id_name;
43 #define _CALENDAR_PROPERTY_CHILD_MULTIPLE(property_id_name) unsigned int property_id_name;
44 #define _CALENDAR_END_VIEW(name) } name##_property_ids; \
45     extern API const name##_property_ids name;
46
47 #define _CALENDAR_BEGIN_READ_ONLY_VIEW() \
48         typedef struct{ \
49             const char* _uri;
50 #define _CALENDAR_PROPERTY_PROJECTION_INT(property_id_name)        unsigned int property_id_name;
51 #define _CALENDAR_PROPERTY_PROJECTION_STR(property_id_name)        unsigned int property_id_name;
52 #define _CALENDAR_PROPERTY_PROJECTION_DOUBLE(property_id_name)     unsigned int property_id_name;
53 #define _CALENDAR_PROPERTY_PROJECTION_LLI(property_id_name)        unsigned int property_id_name;
54 #define _CALENDAR_PROPERTY_PROJECTION_CALTIME(property_id_name)    unsigned int property_id_name;
55 #define _CALENDAR_PROPERTY_FILTER_INT(property_id_name)        unsigned int property_id_name;
56 #define _CALENDAR_PROPERTY_FILTER_STR(property_id_name)        unsigned int property_id_name;
57 #define _CALENDAR_PROPERTY_FILTER_DOUBLE(property_id_name)     unsigned int property_id_name;
58 #define _CALENDAR_PROPERTY_FILTER_LLI(property_id_name)        unsigned int property_id_name;
59 #define _CALENDAR_PROPERTY_FILTER_CALTIME(property_id_name)    unsigned int property_id_name;
60 #define _CALENDAR_END_READ_ONLY_VIEW(name) } name##_property_ids; \
61     extern API const name##_property_ids name;
62
63 _CALENDAR_HANDLE( calendar_record_h )
64 _CALENDAR_HANDLE( calendar_filter_h )
65 _CALENDAR_HANDLE( calendar_list_h )
66 _CALENDAR_HANDLE( calendar_query_h )
67
68 /**
69  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
70  * @{
71  */
72
73 /**
74  * @brief The callback function to get the result of batch operation.
75  *
76  * @param[in]   error                   Error code for batch operation
77  * @param[in]   user_data               The user data passed from the batch operation
78  *
79  * @return  @c true to continue with the next iteration of the loop or @c false to break out of the loop.
80  *
81  * @pre calendar_db_update_records() will invoke this callback.
82  *
83  * @see calendar_db_update_records()
84  */
85 typedef void (*calendar_db_result_cb)( int error, void *user_data);
86
87 /**
88  * @brief The callback function to get the result of batch operation.
89  *
90  * @param[in]   error           Error code for batch operation
91  * @param[in]   record_id_array The record IDs for batch operation
92  * @param[in]   count           The number of record ID array
93  * @param[in]   user_data       The user data passed from the batch operation
94  *
95  * @return  @c true to continue with the next iteration of the loop or @c false to break out of the loop.
96  *
97  * @pre calendar_db_insert_records() will invoke this callback.
98  *
99  * @see calendar_db_insert_records()
100  */
101 typedef void (*calendar_db_insert_result_cb)( int error, int* record_id_array, int count, void *user_data);
102
103 /**
104  * @brief       Called when designated view changes.
105  *
106  * @param[in]   view_uri        The view uri
107  * @param[in]   user_data       The user data passed from the callback registration function
108  *
109  * @see calendar_db_add_changed_cb()
110  */
111 typedef void (*calendar_db_changed_cb)(const char* view_uri, void* user_data);
112
113 /**
114  * @brief       Called when alarm is alerted.
115  *
116  * @param[in]   b                       bundle
117  * @param[in]   user_data       The user data passed from the callback registration function
118  *
119  * @see calendar_db_add_changed_cb()
120  */
121 typedef void (*calendar_reminder_cb)(bundle *b, void* user_data);
122
123 /**
124  * @brief Definition for calendar connect flag
125  */
126 #define CALENDAR_CONNECT_FLAG_NONE         0x00000000
127 #define CALENDAR_CONNECT_FLAG_RETRY        0x00000001
128
129 /**
130  * @brief Definition for default event calendar book database ID
131  */
132 #define DEFAULT_EVENT_CALENDAR_BOOK_ID           1
133
134 /**
135  * @brief Definition for default to-do calendar book database ID
136  */
137 #define DEFAULT_TODO_CALENDAR_BOOK_ID            2
138
139 /**
140  * @brief Definition for default birthday calendar book database ID
141  */
142 #define DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID        3
143
144 /**
145  * @brief Definition for no due date of a to-do
146  */
147 #define CALENDAR_TODO_NO_DUE_DATE   INT64_MAX
148
149 /**
150  * @brief Definition for no start date of a to-do
151  */
152 #define CALENDAR_TODO_NO_START_DATE (-INT64_MAX)
153
154 /**
155  * @brief Definition for no until of a record
156  */
157 #define CALENDAR_RECORD_NO_UNTIL    INT64_MAX
158
159 /**
160  * @brief Definition for no coordinate(latitude/longitude) of a record
161  */
162 #define CALENDAR_RECORD_NO_COORDINATE 1000
163
164 /**
165  * @}
166  */
167
168 /**
169  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE
170  * @{
171  */
172
173 /**
174  * @brief Definition for all calendar book
175  */
176 #define CALENDAR_BOOK_FILTER_ALL                    -1
177
178 /**
179  * @brief Enumerations of filter match type for string
180  */
181 typedef enum
182 {
183         CALENDAR_MATCH_EXACTLY,                 /**< . */
184         CALENDAR_MATCH_FULLSTRING,              /**< . */
185         CALENDAR_MATCH_CONTAINS,                /**< . */
186         CALENDAR_MATCH_STARTSWITH,              /**< . */
187         CALENDAR_MATCH_ENDSWITH,                /**< . */
188         CALENDAR_MATCH_EXISTS           /**< . */
189 } calendar_match_str_flag_e;
190
191 /**
192  * @brief Enumerations of filter match type for integer
193  */
194 typedef enum
195 {
196         CALENDAR_MATCH_EQUAL,                                   /**< . */
197         CALENDAR_MATCH_GREATER_THAN,                    /**< . */
198         CALENDAR_MATCH_GREATER_THAN_OR_EQUAL,   /**< . */
199         CALENDAR_MATCH_LESS_THAN,                               /**< . */
200         CALENDAR_MATCH_LESS_THAN_OR_EQUAL,              /**< . */
201         CALENDAR_MATCH_NOT_EQUAL,               /**< this flag can yield poor performance */
202         CALENDAR_MATCH_NONE                                             /**< . */
203 } calendar_match_int_flag_e;
204
205 /**
206  * @brief Enumerations of filter combine type
207  */
208 typedef enum {
209         CALENDAR_FILTER_OPERATOR_AND,   /**< . */
210         CALENDAR_FILTER_OPERATOR_OR             /**< . */
211 } calendar_filter_operator_e;
212
213 /**
214  * @}
215  */
216
217 /**
218  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE
219  * @{
220  */
221
222 /**
223  * @brief Enumerations for calendar book type. "OR"ing supported.
224  */
225 typedef enum
226 {
227     CALENDAR_BOOK_TYPE_NONE          = 0,       /**< Calendar book type default */
228     CALENDAR_BOOK_TYPE_EVENT         = 1<<0,        /**< Event calendar book type */
229     CALENDAR_BOOK_TYPE_TODO          = 1<<1     /**< To-do Calendar book type */
230 } calendar_book_type_e;
231
232 /**
233  * @brief Enumerations for calendar sensitivity type.
234  */
235 typedef enum
236 {
237     CALENDAR_SENSITIVITY_PUBLIC          = 0,   /**< Public Sensitivity */
238     CALENDAR_SENSITIVITY_PRIVATE,                               /**< Private Sensitivity */
239     CALENDAR_SENSITIVITY_CONFIDENTIAL                   /**< Confidential Sensitivity */
240 } calendar_sensitivity_e;
241
242 /**
243  * @brief Enumerations of attendee status.
244  */
245 typedef enum
246 {
247         CALENDAR_ATTENDEE_STATUS_PENDING        = 0,    /**< Pending status */
248         CALENDAR_ATTENDEE_STATUS_ACCEPTED,                      /**< Accepted status */
249         CALENDAR_ATTENDEE_STATUS_DECLINED,                      /**< Decliend status */
250         CALENDAR_ATTENDEE_STATUS_TENTATIVE,                     /**< Tentative status */
251         CALENDAR_ATTENDEE_STATUS_DELEGATED,                     /**< Delegated status */
252         CALENDAR_ATTENDEE_STATUS_COMPLETED,                     /**< Completed status */
253         CALENDAR_ATTENDEE_STATUS_IN_PROCESS,                    /**< In process status */
254         CALENDAR_ATTENDEE_STATUS_MAX,
255 }calendar_attendee_status_e;
256
257 /**
258  * @brief Enumerations of attendee role.
259  */
260 typedef enum
261 {
262         CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT  = 0,    /**< Participation is required */
263         CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT,                 /**< Accepted status */
264         CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT,                 /**< Non-Participant */
265         CALENDAR_ATTENDEE_ROLE_CHAIR,                                   /**< Chairperson */
266         CALENDAR_ATTENDEE_ROLE_MAX,
267 }calendar_attendee_role_e;
268
269 /**
270  * @brief  Alarm time unit type of event such as minutes, hours, days, or etc.
271  */
272 typedef enum
273 {
274     CALENDAR_ALARM_NONE = -1,                  /**< No reminder set */
275     CALENDAR_ALARM_TIME_UNIT_SPECIFIC = 1,     /**< specific in sec */
276     CALENDAR_ALARM_TIME_UNIT_MINUTE = 60,      /**< Alarm time unit in minutes */
277     CALENDAR_ALARM_TIME_UNIT_HOUR = 3600,      /**< Alarm time unit in hours */
278     CALENDAR_ALARM_TIME_UNIT_DAY = 86400,      /**< Alarm time unit in days */
279     CALENDAR_ALARM_TIME_UNIT_WEEK = 604800,    /**< Alarm time unit in weeks */
280     CALENDAR_ALARM_TIME_UNIT_MONTH = 18144000, /**< Alarm time unit in months */
281 } calendar_alarm_time_unit_type_e;
282
283 /**
284  * @brief Enumerations of the frequency of event recurrence.
285  */
286 typedef enum
287 {
288     CALENDAR_RECURRENCE_NONE,           /**< No recurrence event */
289     CALENDAR_RECURRENCE_DAILY,          /**< A Event occurs every day */
290     CALENDAR_RECURRENCE_WEEKLY,         /**< A Event occurs on the same day of every week \n According to week flag, the event will recurrence every days of week */
291     CALENDAR_RECURRENCE_MONTHLY,        /**< A Event occurs on the same day of every month */
292     CALENDAR_RECURRENCE_YEARLY         /**< A Event occurs on the same day of every year */
293 } calendar_recurrence_frequency_e;
294
295 /**
296  * @brief Enumerations of status for event.
297  */
298 typedef enum
299 {
300     CALENDAR_EVENT_STATUS_NONE          = 0x01,         /**< None */
301     CALENDAR_EVENT_STATUS_TENTATIVE     = 0x02,         /**< The event is tentative */
302     CALENDAR_EVENT_STATUS_CONFIRMED     = 0x04,         /**< The event is confirmed */
303     CALENDAR_EVENT_STATUS_CANCELLED     = 0x08          /**< The event is cancelled */
304 }calendar_event_status_e;
305
306 /**
307  * @brief Enumerations of busy status for event.
308  */
309 typedef enum
310 {
311     CALENDAR_EVENT_BUSY_STATUS_FREE = 0,                /**< The free status */
312     CALENDAR_EVENT_BUSY_STATUS_BUSY,                    /**< The busy status */
313     CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE,             /**< The unavailable status */
314     CALENDAR_EVENT_BUSY_STATUS_TENTATIVE                /**< The tentative status */
315 }calendar_event_busy_status_e;
316 /**
317  * @brief Calendar event item priority
318  */
319 typedef enum
320 {
321     CALENDAR_EVENT_PRIORITY_LOW          = 0,   /**< Low priority */
322     CALENDAR_EVENT_PRIORITY_NORMAL,                             /**< Normal priority */
323     CALENDAR_EVENT_PRIORITY_HIGH                                /**< High priority */
324 } calendar_event_priority_e;
325
326 /**
327  * @brief Calendar to-do item priority
328  */
329 typedef enum
330 {
331         CALENDAR_TODO_PRIORITY_NONE                     = 0x01, /**< Priority none */
332     CALENDAR_TODO_PRIORITY_LOW          = 0x08, /**< Low priority */
333     CALENDAR_TODO_PRIORITY_NORMAL               = 0x04, /**< Normal priority */
334     CALENDAR_TODO_PRIORITY_HIGH                 = 0x02, /**< High priority */
335 } calendar_todo_priority_e;
336
337 /**
338  * @brief Enumerations of status for to-do.
339  */
340 typedef enum
341 {
342     CALENDAR_TODO_STATUS_NONE                   = 0x0100,       /**< None */
343     CALENDAR_TODO_STATUS_NEEDS_ACTION   = 0x0200,       /**< Needs action status */
344     CALENDAR_TODO_STATUS_COMPLETED              = 0x0400,       /**< Completed status */
345     CALENDAR_TODO_STATUS_IN_PROCESS             = 0x0800,       /**< Work in process status */
346     CALENDAR_TODO_STATUS_CANCELED               = 0x1000        /**< Canceled status */
347 } calendar_todo_status_e;
348
349 typedef enum
350 {
351         CALENDAR_TIME_UTIME = 0,                        /**< . */
352         CALENDAR_TIME_LOCALTIME,                        /**< . */
353 } calendar_time_type_e;
354
355 typedef enum
356 {
357         CALENDAR_RANGE_UNTIL,           /**< . */
358         CALENDAR_RANGE_COUNT,           /**< . */
359         CALENDAR_RANGE_NONE,            /**< . */
360 } calendar_range_type_e;
361
362 typedef enum
363 {
364     CALENDAR_SYSTEM_NONE,                                       /**< . */
365     CALENDAR_SYSTEM_GREGORIAN,                          /**< . */
366     CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR,       /**< . */
367 } calendar_system_type_e;
368
369 typedef enum
370 {
371     CALENDAR_MEETING_STATUS_NOTMEETING = 0,     /**< . */
372     CALENDAR_MEETING_STATUS_MEETING,            /**< . */
373     CALENDAR_MEETING_STATUS_RECEIVED,           /**< . */
374     CALENDAR_MEETING_STATUS_CANCELED,           /**< . */
375 } calendar_meeting_status_e;
376
377 /**
378  * @brief Enumerations of weekday of month(Same value as UCalendarDaysOfWeek in ICU).
379  */
380 typedef enum
381 {
382         CALENDAR_SUNDAY = 1,
383         CALENDAR_MONDAY,
384         CALENDAR_TUESDAY,
385         CALENDAR_WEDNESDAY,
386         CALENDAR_THURSDAY,
387         CALENDAR_FRIDAY,
388         CALENDAR_SATURDAY,
389 }calendar_days_of_week_e;
390
391 // deprecated
392 #define CALENDAR_EVENT_MODIFIED_STATUS_INSERTED 0
393 #define CALENDAR_EVENT_MODIFIED_STATUS_UPDATED  1
394 #define CALENDAR_EVENT_MODIFIED_STATUS_DELETED  2
395 /**
396  * @brief Enumerations of modified status for record.
397  */
398 typedef enum
399 {
400     CALENDAR_RECORD_MODIFIED_STATUS_INSERTED = 0,    /**< The record is inserted */
401     CALENDAR_RECORD_MODIFIED_STATUS_UPDATED,            /**< The record is updated */
402     CALENDAR_RECORD_MODIFIED_STATUS_DELETED          /**< The record is deleted */
403 }calendar_record_modified_status_e;
404
405 /**
406  * @brief The structure of time
407  */
408 typedef struct
409 {
410     calendar_time_type_e type;
411     union {
412         long long int utime;
413         struct {
414             int year;
415             int month;
416             int mday;
417         }date;
418     }time;
419 }calendar_time_s;
420
421 /**
422  * @brief Enumerations of type for record.
423  */
424 typedef enum
425 {
426     CALENDAR_RECORD_TYPE_NONE = 0,          /**< . */
427     CALENDAR_RECORD_TYPE_CALENDAR_BOOK,     /**< . */
428     CALENDAR_RECORD_TYPE_EVENT,             /**< . */
429     CALENDAR_RECORD_TYPE_TODO,              /**< . */
430 }calendar_record_type_e;
431
432 /**
433  * @}
434  */
435
436 #ifdef __cplusplus
437 }
438 #endif
439
440 #endif //__TIZEN_SOCIAL_CALENDAR_TYPES_H__