Add support for resolver modules
[connman] / src / storage.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #if 0
27 #include <sqlite3.h>
28 #endif
29
30 #include "connman.h"
31
32 #if 0
33 static sqlite3 *db = NULL;
34
35 static int create_tables(void)
36 {
37         char *msg;
38         int err;
39
40         DBG("");
41
42         err = sqlite3_exec(db, "CREATE TABLE properties ("
43                                         "element TEXT NOT NULL,"
44                                         "name TEXT NOT NULL,"
45                                         "value TEXT NOT NULL,"
46                                         "PRIMARY KEY(element, name))",
47                                                         NULL, NULL, &msg);
48
49         if (err != SQLITE_OK) {
50                 connman_error("SQL error: %s", msg);
51                 sqlite3_free(msg);
52                 return -1;
53         }
54
55         return 0;
56 }
57 #endif
58
59 int __connman_storage_init(void)
60 {
61 #if 0
62         int err;
63
64         DBG("");
65
66 #if 0
67         if (!sqlite3_threadsafe()) {
68                 connman_error("SQLite is missing thread support");
69                 return -1;
70         }
71 #endif
72
73         err = sqlite3_open(STORAGEDIR "/config.db", &db);
74         if (err != SQLITE_OK) {
75                 connman_error("Can't open database: %s", sqlite3_errmsg(db));
76                 sqlite3_close(db);
77                 return -1;
78         }
79
80         create_tables();
81 #endif
82
83         return 0;
84 }
85
86 void __connman_storage_cleanup(void)
87 {
88 #if 0
89         DBG("");
90
91         sqlite3_close(db);
92 #endif
93 }
94
95 int __connman_element_load(struct connman_element *element)
96 {
97         return 0;
98 }
99
100 int __connman_element_store(struct connman_element *element)
101 {
102 #if 0
103         char *sql, *msg;
104
105         DBG("");
106
107         if (element->priority > 0) {
108                 sql = g_strdup_printf("INSERT INTO properties "
109                                                 "VALUES ('%s','%s','%d')",
110                                                 element->path, "Priority",
111                                                         element->priority);
112
113                 if (sqlite3_exec(db, sql, NULL, NULL, &msg) != SQLITE_OK) {
114                         connman_error("SQL error: %s", msg);
115                         sqlite3_free(msg);
116                 }
117         }
118 #endif
119
120         return 0;
121 }