AC_SUBST(HAL_CFLAGS)
AC_SUBST(HAL_LIBS)
+PKG_CHECK_MODULES(SQLITE, sqlite3, dummy=yes,
+ AC_MSG_ERROR(sqlite3 is required))
+AC_SUBST(SQLITE_CFLAGS)
+AC_SUBST(SQLITE_LIBS)
+
AC_OUTPUT(Makefile include/Makefile src/Makefile doc/Makefile
test/Makefile plugins/Makefile scripts/Makefile
scripts/fi.epitest.hostap.WPASupplicant.service
sbin_PROGRAMS = connmand
connmand_SOURCES = main.c connman.h log.c plugin.c element.c \
- manager.c agent.c \
+ storage.c manager.c agent.c \
iface.c iface-storage.c iface-helper.c iface-inet.c \
network.c rtnl.c dhcp.c resolver.c
-connmand_LDADD = @HAL_LIBS@ @GDBUS_LIBS@ @GMODULE_LIBS@ @GTHREAD_LIBS@
+connmand_LDADD = @HAL_LIBS@ @SQLITE_LIBS@ \
+ @GDBUS_LIBS@ @GMODULE_LIBS@ @GTHREAD_LIBS@
statedir = $(localstatedir)/run/connman
plugindir = $(libdir)/connman/plugins
endif
-AM_CFLAGS = @GTHREAD_CFLAGS@ @GMODULE_CFLAGS@ @GDBUS_CFLAGS@ @HAL_CFLAGS@ \
+AM_CFLAGS = @GTHREAD_CFLAGS@ @GMODULE_CFLAGS@ @GDBUS_CFLAGS@ \
+ @SQLITE_CFLAGS@ @HAL_CFLAGS@ \
-DSTATEDIR=\""$(statedir)"\" \
-DSTORAGEDIR=\""$(storagedir)\"" \
-DPLUGINDIR=\""$(plugindir)"\"
#define NM_PATH "/org/freedesktop/NetworkManager"
#define NM_INTERFACE NM_SERVICE
+int __connman_storage_init(void);
+void __connman_storage_cleanup(void);
+
int __connman_manager_init(DBusConnection *conn, gboolean compat);
void __connman_manager_cleanup(void);
const char *__connman_element_type2string(enum connman_element_type type);
const char *__connman_element_subtype2string(enum connman_element_subtype type);
+int __connman_element_load(struct connman_element *element);
+int __connman_element_store(struct connman_element *element);
+
#include <connman/iface.h>
int __connman_iface_init(DBusConnection *conn, const char *interface);
if (connman_element_ref(element) == NULL)
return -1;
+ __connman_element_load(element);
+
g_static_rw_lock_writer_lock(&element_lock);
if (parent) {
g_static_rw_lock_writer_unlock(&element_lock);
+ __connman_element_store(element);
+
g_dbus_register_interface(connection, element->path,
CONNMAN_ELEMENT_INTERFACE,
element_methods, NULL, NULL,
__connman_log_init(option_detach, option_debug);
+ __connman_storage_init();
+
__connman_element_init(conn);
__connman_agent_init(conn);
__connman_element_cleanup();
+ __connman_storage_cleanup();
+
__connman_log_cleanup();
g_dbus_cleanup_connection(conn);
--- /dev/null
+/*
+ *
+ * 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
+
+#include <sqlite3.h>
+
+#include "connman.h"
+
+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;
+}
+
+int __connman_storage_init(void)
+{
+ 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();
+
+ return 0;
+}
+
+void __connman_storage_cleanup(void)
+{
+ DBG("");
+
+ sqlite3_close(db);
+}
+
+int __connman_element_load(struct connman_element *element)
+{
+ return 0;
+}
+
+int __connman_element_store(struct connman_element *element)
+{
+ 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);
+ }
+ }
+
+ return 0;
+}