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