/* * * Copyright 2012 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (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 #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__ */