5 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
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.
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.
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
30 static sqlite3 *db = NULL;
32 static int create_tables(void)
39 err = sqlite3_exec(db, "CREATE TABLE properties ("
40 "element TEXT NOT NULL,"
42 "value TEXT NOT NULL,"
43 "PRIMARY KEY(element, name))",
46 if (err != SQLITE_OK) {
47 connman_error("SQL error: %s", msg);
55 int __connman_storage_init(void)
62 if (!sqlite3_threadsafe()) {
63 connman_error("SQLite is missing thread support");
68 err = sqlite3_open(STORAGEDIR "/config.db", &db);
69 if (err != SQLITE_OK) {
70 connman_error("Can't open database: %s", sqlite3_errmsg(db));
80 void __connman_storage_cleanup(void)
87 int __connman_element_load(struct connman_element *element)
92 int __connman_element_store(struct connman_element *element)
98 if (element->priority > 0) {
99 sql = g_strdup_printf("INSERT INTO properties "
100 "VALUES ('%s','%s','%d')",
101 element->path, "Priority",
104 if (sqlite3_exec(db, sql, NULL, NULL, &msg) != SQLITE_OK) {
105 connman_error("SQL error: %s", msg);