Initialize Tizen 2.3
[apps/home/libslp-alarm.git] / include / db.h
1 /*
2 *
3 * Copyright 2012  Samsung Electronics Co., Ltd
4 *
5 * Licensed under the Flora License, Version 1.1 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *    http://floralicense.org/license/
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 #ifndef __ALARM_DB_H__
19 #define __ALARM_DB_H__
20
21 #include <db-util.h>
22 #include "alarm-engine.h"
23
24 /**
25  *  This function opens a connection to database.
26   * @return         This function returns database handler.
27  * @param[in] char*     Path of database file to open.
28  */
29 sqlite3 *db_init(char *);
30
31 /**
32  *  This function closes a connection with database.
33   * @param[in] sqlite3*     Pointer of database handler.
34  */
35 void db_fini(sqlite3 *);
36
37 /**
38  *  This function inserts the alarm data in database.
39  *
40  * @return                      This function returns id of alarm data.
41  * @param[in] sqlite3*              Pointer to database handler.
42  * @param[in] struct alarm_data*        Pointer to structure alarm_data to insert.
43  */
44 int insert_data(sqlite3 *, struct alarm_data *);
45
46 /**
47  *  This function updates the alarm data in database.
48  *
49  * @return                      This function returns id of alarm data.
50  * @param[in] sqlite3*              Pointer to database handler.
51  * @param[in] struct alarm_data*        Pointer to structure alarm_data to update.
52  */
53 int update_data(sqlite3 *, struct alarm_data *);
54
55 /**
56  *  This function removes the alarm data in database.
57  *
58  * @return                      This function returns id of alarm data.
59  * @param[in] sqlite3*              Pointer to database handler.
60  * @param[in] struct alarm_data*        Pointer to structure alarm_data to remove.
61  */
62 int remove_data(sqlite3 *, int id);
63
64 /**
65  *  This function removes all of alarm data in database.
66  *
67  * @return                      This function returns id of alarm data.
68  * @param[in] sqlite3*              Pointer to database handler.
69  */
70 int remove_all_data(sqlite3 *);
71
72 /**
73  *  This function gets the alarm data in database by index of alarm data.
74  *
75  * @return                      This function returns id of alarm data.
76  * @param[in] sqlite3*              Pointer to database handler.
77  * @param[in] int                   Index of alarm data to get.
78  * @param[in] struct alarm_data*        Pointer to structure alarm_data to get.
79  */
80 int get_data(sqlite3 *, int, struct alarm_data *);
81
82 /**
83  *  This function gets the alarm data in database by index & author of alarm data.
84  *
85  * @return                      This function returns id of alarm data.
86  * @param[in] sqlite3*              Pointer to database handler.
87  * @param[in] int                   Index of alarm data to get.
88  * @param[in] struct alarm_data*        Pointer to structure alarm_data to get.
89  * @param[in] char author           Author of alarm data to get.
90  */
91 int get_data_by_author(sqlite3 *, int, struct alarm_data *, char author);
92
93 /**
94  *  This function updates enable flag of  the alarm data in database.
95  *
96  * @return                      This function returns id of alarm data.
97  * @param[in] sqlite3*              Pointer to database handler.
98  * @param[in] int                   Index of alarm data to get.
99  * @param[in] bool                  Bool value where alarm enable.
100  */
101 int update_enable(sqlite3 *, int id, bool enable);
102
103 /**
104  *  This function updates snooze flag of the alarm data in database.
105  *
106  * @return                      This function returns id of alarm data.
107  * @param[in] sqlite3*              Pointer to database handler.
108  * @param[in] int                   Index of alarm data to get.
109  * @param[in] bool                  Bool value where alarm snooze enable.
110  */
111 int update_snooze(sqlite3 *, int id, bool enable);
112
113 /**
114  *  This function gets list has all of the alarm data in database.
115  *
116  * @return                      This function returns pointer of alarm data list.
117  * @param[in] sqlite3*              Pointer to database handler.
118  */
119 struct alarm_data_list *get_data_list_all(sqlite3 *);
120
121 /**
122  *  This function gets list has all of the alarm data in database.
123  *
124  * @return                      This function returns pointer of alarm data list.
125  * @param[in] sqlite3*              Pointer to database handler.
126  * @param[in] char                  Author of alarm data.
127  */
128 struct alarm_data_list *get_data_list_by_author(sqlite3 *, char);
129
130 /**
131  *  This function gets index of last alarm data in database.
132  *
133  * @return                      This function returns index of the last alarm data.
134  * @param[in] sqlite3* db           Pointer to database handler.
135  */
136 int get_last_id(sqlite3 *db);
137
138 /**
139  *  This function gets index of last alarm data in database by author of alarm data.
140  *
141  * @return                      This function returns index of the last alarm data.
142  * @param[in] sqlite3* db           Pointer to database handler.
143  * @param[in] char                  Author of alarm data.
144  */
145 int get_last_id_by_author(sqlite3 *db, char author);
146
147 /**
148  *  This function gets number of alarm data in database by author of alarm data.
149  *
150  * @return                      This function returns number of the alarm data.
151  * @param[in] sqlite3* db           Pointer to database handler.
152  * @param[in] char                  Author of alarm data.
153  */
154 int get_number_of_data_by_author(sqlite3 *db, char author);
155
156 /* int get_poweron_by_author(sqlite3 *db, char author); */
157
158 /**
159  *  This function gets number of enabled alarm  in database by db pointer
160  *
161  * @return                      This function returns number of the enabled alarm
162  * @param[in] sqlite3* db           Pointer to database handler.
163  */
164 int get_num_of_enable(sqlite3 *db);
165
166 /**
167  *  This function gets power_on flag of alarm data in database by author of alarm data.
168  *
169  * @return                      This function returns number of the alarm data.
170  * @param[in] sqlite3* db           Pointer to database handler.
171  * @param[in] char                  Author of alarm data.
172  */
173 int get_power_onoff_by_author(sqlite3 *db, char author);
174
175 #endif                          /* __ALARM_DB_H__ */