3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (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
9 * http://floralicense.org/license/
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.
18 #ifndef __ALARM_DB_H__
19 #define __ALARM_DB_H__
22 #include "alarm-engine.h"
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.
29 sqlite3 *db_init(char *);
32 * This function closes a connection with database.
33 * @param[in] sqlite3* Pointer of database handler.
35 void db_fini(sqlite3 *);
38 * This function inserts the alarm data in database.
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.
44 int insert_data(sqlite3 *, struct alarm_data *);
47 * This function updates the alarm data in database.
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.
53 int update_data(sqlite3 *, struct alarm_data *);
56 * This function removes the alarm data in database.
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.
62 int remove_data(sqlite3 *, int id);
65 * This function removes all of alarm data in database.
67 * @return This function returns id of alarm data.
68 * @param[in] sqlite3* Pointer to database handler.
70 int remove_all_data(sqlite3 *);
73 * This function gets the alarm data in database by index of alarm data.
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.
80 int get_data(sqlite3 *, int, struct alarm_data *);
83 * This function gets the alarm data in database by index & author of alarm data.
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.
91 int get_data_by_author(sqlite3 *, int, struct alarm_data *, char author);
94 * This function updates enable flag of the alarm data in database.
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.
101 int update_enable(sqlite3 *, int id, bool enable);
104 * This function updates snooze flag of the alarm data in database.
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.
111 int update_snooze(sqlite3 *, int id, bool enable);
114 * This function gets list has all of the alarm data in database.
116 * @return This function returns pointer of alarm data list.
117 * @param[in] sqlite3* Pointer to database handler.
119 struct alarm_data_list *get_data_list_all(sqlite3 *);
122 * This function gets list has all of the alarm data in database.
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.
128 struct alarm_data_list *get_data_list_by_author(sqlite3 *, char);
131 * This function gets index of last alarm data in database.
133 * @return This function returns index of the last alarm data.
134 * @param[in] sqlite3* db Pointer to database handler.
136 int get_last_id(sqlite3 *db);
139 * This function gets index of last alarm data in database by author of alarm data.
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.
145 int get_last_id_by_author(sqlite3 *db, char author);
148 * This function gets number of alarm data in database by author of alarm data.
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.
154 int get_number_of_data_by_author(sqlite3 *db, char author);
156 /* int get_poweron_by_author(sqlite3 *db, char author); */
159 * This function gets number of enabled alarm in database by db pointer
161 * @return This function returns number of the enabled alarm
162 * @param[in] sqlite3* db Pointer to database handler.
164 int get_num_of_enable(sqlite3 *db);
167 * This function gets power_on flag of alarm data in database by author of alarm data.
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.
173 int get_power_onoff_by_author(sqlite3 *db, char author);
175 #endif /* __ALARM_DB_H__ */