summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-16 13:49:13 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-16 13:49:13 +0000
commit8c599674509651cc8e68d12ba21423dbf13305d9 (patch)
treed15c6cb6374f599a94ad68a95c4ea77d27627ba1 /network
parent3723149c0baab5f94d57221fa693e4d0ec19df6b (diff)
network: added function to store/update server property
Diffstat (limited to 'network')
-rw-r--r--network/manager.c30
-rw-r--r--network/server.c19
2 files changed, 17 insertions, 32 deletions
diff --git a/network/manager.c b/network/manager.c
index 78d69150..16123002 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -889,33 +889,3 @@ static inline int create_filename(char *buf, size_t size,
return create_name(buf, size, STORAGEDIR, addr, name);
}
-
-int network_del_stored_info(bdaddr_t *src, uint16_t uuid)
-{
- char filename[PATH_MAX + 1];
- const char *str;
-
- create_filename(filename, PATH_MAX, src, "network");
-
- /* FIXME: Wrong format */
-
- str = bnep_uuid(uuid);
-
- return textfile_del(filename, str);
-}
-
-int network_store_info(bdaddr_t *src, uint16_t uuid, gboolean enable)
-{
- char filename[PATH_MAX + 1];
- const char *str;
-
- create_filename(filename, PATH_MAX, src, "network");
-
- /* FIXME: Wrong format */
-
- str = bnep_uuid(uuid);
-
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- return textfile_put(filename, str, enable ? "1" : "0");
-}
diff --git a/network/server.c b/network/server.c
index 160f8910..f5a4b7c3 100644
--- a/network/server.c
+++ b/network/server.c
@@ -79,6 +79,21 @@ struct network_server {
static char netdev[16] = "bnep%d";
+static int store_property(bdaddr_t *src, uint16_t id,
+ const char *key, const char *value)
+{
+ char filename[PATH_MAX + 1];
+ char addr[18];
+
+ ba2str(src, addr);
+ if (id == BNEP_SVC_NAP)
+ create_name(filename, PATH_MAX, STORAGEDIR, addr, "nap");
+ else
+ create_name(filename, PATH_MAX, STORAGEDIR, addr, "gn");
+
+ return textfile_put(filename, key, value);
+}
+
static void pending_auth_free(struct pending_auth *pauth)
{
if (!pauth)
@@ -723,7 +738,7 @@ static DBusHandlerResult enable(DBusConnection *conn,
if (err < 0)
return err_failed(conn, msg, strerror(-err));
- network_store_info(&ns->src, ns->id, TRUE);
+ store_property(&ns->src, ns->id, "enabled", "1");
return send_message_and_unref(conn, reply);
}
@@ -751,7 +766,7 @@ static DBusHandlerResult disable(DBusConnection *conn,
g_io_channel_unref(ns->io);
ns->io = NULL;
- network_store_info(&ns->src, ns->id, FALSE);
+ store_property(&ns->src, ns->id, "enabled", "0");
return send_message_and_unref(conn, reply);
}