[Contact] Refactoring API structures
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Calendar / CalendarQuery.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
18 #ifndef _CALENDAR_QUERY_H_
19 #define _CALENDAR_QUERY_H_
20
21 #include <db-util.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27 #define CALENDAR_DB_PATH "/opt/dbspace/.calendar-svc.db"
28
29 typedef sqlite3_stmt* stmt;
30
31 // Query results struct
32 typedef struct
33 {
34     int         id;         /**< Calendar id in database */
35 } calendar_query_s;
36
37 typedef enum
38 {
39         QUERY_GROUP_CASE = -16,
40         QUERY_NORMALIZATION_ERROR = -15,
41         QUERY_SET_LIMIT = -14,                  /**< For limit operation */
42         QUERY_NO_NEXT_ROW = -13,                        /**< No Row*/
43         QUERY_INSERT_FAIL = -12,
44         QUERY_ORDERING_FAIL = -11,
45         QUERY_STATEMENT_FAIL = -10,
46         QUERY_INVALID_ATTRIBUTE = -9,
47         QUERY_OVER_MAX_COUNT = -8,              /**< memory allocation fail */
48         QUERY_OVER_MAX_PROPERTY_CLASS = -7,                     /**< Invalid property */
49         QUERY_NULL_PARAMETER = -6,              /**< null input data */
50         QUERY_NO_RECORD = -5,                   /**< No Record */
51         QUERY_HANDLE_NONE,                              /**< No handle */
52         QUERY_INVALID_TYPE,                             /**< invalid value type */
53         QUERY_ALLOCATE_MEMORY_FAIL,             /**< memory allocation fail */
54         QUERY_FAIL = -1,                                /**< fail */
55         QUERY_SUCCESS = 0,                              /**< no error */
56 }calendar_query_error;
57
58 calendar_query_error calendar_db_init();
59
60 calendar_query_error calendar_db_finish();
61
62 calendar_query_error calendar_exec_query(char* query);
63
64 int calendar_query_step(stmt pStmt);
65
66 void calendar_query_finalize(stmt pStmt);
67
68 int calendar_query_bind_int(stmt pStmt, int pos, int num);
69
70 int calendar_query_bind_double(stmt pStmt, int pos, double num);
71
72 int calendar_query_bind_text(stmt pStmt, int pos, char* str);
73
74 void calendar_query_stmt_reset(stmt stmt);
75
76 int calendar_query_column_int(stmt pStmt, int pos);
77
78 double calendar_query_column_double(stmt pStmt, int pos);
79
80 char* calendar_query_column_text(stmt pStmt, int pos);
81
82 stmt calendar_query_prepare(char *query);
83
84 #ifdef __cplusplus
85 }
86 #endif /* __cplusplus */
87
88 #endif // _CALENDAR_QUERY_H_
89