summaryrefslogtreecommitdiff
path: root/src/storage.c
blob: d67d0d2c17d8abe3bc9ff6fe25ab671321f5b0c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 *
 *  Connection Manager
 *
 *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#if 0
#include <sqlite3.h>
#endif

#include "connman.h"

#if 0
static sqlite3 *db = NULL;

static int create_tables(void)
{
	char *msg;
	int err;

	DBG("");

	err = sqlite3_exec(db, "CREATE TABLE properties ("
					"element TEXT NOT NULL,"
					"name TEXT NOT NULL,"
					"value TEXT NOT NULL,"
					"PRIMARY KEY(element, name))",
							NULL, NULL, &msg);

	if (err != SQLITE_OK) {
		connman_error("SQL error: %s", msg);
		sqlite3_free(msg);
		return -1;
	}

	return 0;
}
#endif

int __connman_storage_init(void)
{
#if 0
	int err;

	DBG("");

#if 0
	if (!sqlite3_threadsafe()) {
		connman_error("SQLite is missing thread support");
		return -1;
	}
#endif

	err = sqlite3_open(STORAGEDIR "/config.db", &db);
	if (err != SQLITE_OK) {
		connman_error("Can't open database: %s", sqlite3_errmsg(db));
		sqlite3_close(db);
		return -1;
	}

	create_tables();
#endif

	return 0;
}

void __connman_storage_cleanup(void)
{
#if 0
	DBG("");

	sqlite3_close(db);
#endif
}

int __connman_element_load(struct connman_element *element)
{
	return 0;
}

int __connman_element_store(struct connman_element *element)
{
#if 0
	char *sql, *msg;

	DBG("");

	if (element->priority > 0) {
		sql = g_strdup_printf("INSERT INTO properties "
						"VALUES ('%s','%s','%d')",
						element->path, "Priority",
							element->priority);

		if (sqlite3_exec(db, sql, NULL, NULL, &msg) != SQLITE_OK) {
			connman_error("SQL error: %s", msg);
			sqlite3_free(msg);
		}
	}
#endif

	return 0;
}