add telegram account, fix db insert error.
[apps/native/telegram-tizen.git] / TelegramTizen / db_manager / tg_db_manager.h
1 /*
2     This file is part of Telegram application for tizen
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Lesser General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef TG_DB_MANAGER_H_
20 #define TG_DB_MANAGER_H_
21
22 #include "tg_common.h"
23 #include <sqlite3.h>
24
25 #define TG_DBMGR_NOLIMITED 0
26 #define TG_DBMGR_LIMITED 30
27
28 extern sqlite3* create_database();
29 extern Eina_Bool close_database(sqlite3* db);
30 extern Eina_Bool create_table(const char* table_name, Eina_List *column_names, Eina_List *column_types);
31 extern Eina_Bool insert_table(const char* table_name, Eina_List *column_names, Eina_List *column_types, Eina_List *column_values);
32 extern Eina_Bool update_table(const char* table_name, Eina_List *column_names, Eina_List *column_types, Eina_List *column_values, const char* where_clause);
33 extern Eina_Bool create_index(const char* table_name, const char* column_name);
34 extern Eina_Bool get_values_from_table(const char* table_name, Eina_List *column_names, int (*callback)(void*,int,char**,char**), const char* where_clause, void* data_to_callback);
35 extern Eina_List *get_values_from_table_sync(const char* table_name, Eina_List *column_names, Eina_List *column_types, const char* where_clause, unsigned int limit, unsigned int offset);
36 extern Eina_List *get_values_from_table_sync_order_by(const char* table_name, Eina_List *column_names, Eina_List *column_types, const char* order_column, Eina_Bool is_asc, const char* where_clause, unsigned int limit, unsigned int offset);
37 extern int get_number_of_rows(const char* table_name, char* where_clause);
38 extern Eina_List *tg_db_get_user_info(tgl_peer_id_t *user_id);
39 extern Eina_List *tg_db_get_chat_info(const char *table_name);
40 extern tg_peer_info_s *tg_db_get_peer_info(const char *table, int peer_id);
41 extern Eina_List *tg_db_get_messages(const char *table_name);
42 extern Eina_Bool delete_all_records(char *tablename);
43
44 extern int tg_db_init(void);
45 extern int tg_db_fini(void);
46
47 #endif /* TG_DB_MANAGER_H_ */