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
33 static sqlite3 *db = NULL;
35 static int create_tables(void)
42 err = sqlite3_exec(db, "CREATE TABLE properties ("
43 "element TEXT NOT NULL,"
45 "value TEXT NOT NULL,"
46 "PRIMARY KEY(element, name))",
49 if (err != SQLITE_OK) {
50 connman_error("SQL error: %s", msg);
59 int __connman_storage_init(void)
67 if (!sqlite3_threadsafe()) {
68 connman_error("SQLite is missing thread support");
73 err = sqlite3_open(STORAGEDIR "/config.db", &db);
74 if (err != SQLITE_OK) {
75 connman_error("Can't open database: %s", sqlite3_errmsg(db));
86 void __connman_storage_cleanup(void)
95 int __connman_element_load(struct connman_element *element)
100 int __connman_element_store(struct connman_element *element)
107 if (element->priority > 0) {
108 sql = g_strdup_printf("INSERT INTO properties "
109 "VALUES ('%s','%s','%d')",
110 element->path, "Priority",
113 if (sqlite3_exec(db, sql, NULL, NULL, &msg) != SQLITE_OK) {
114 connman_error("SQL error: %s", msg);