diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-12 18:42:47 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-12 18:42:47 +0000 |
commit | 4d8f5eb37c895d875a7fdcce45f03c406adfa668 (patch) | |
tree | 4d50342ba94930c47875d5febecfb3aea8b0da65 /network/server.c | |
parent | 1cbec5ebe8d67b1b4dcef1768efde2ac1ac51970 (diff) |
network: changed the server D-Bus path and moved storage functions to manager.c
Diffstat (limited to 'network/server.c')
-rw-r--r-- | network/server.c | 73 |
1 files changed, 3 insertions, 70 deletions
diff --git a/network/server.c b/network/server.c index 2a3961ca..e1e27341 100644 --- a/network/server.c +++ b/network/server.c @@ -30,8 +30,6 @@ #include <stdlib.h> #include <errno.h> #include <sys/socket.h> -#include <sys/file.h> -#include <sys/stat.h> #include <bluetooth/bluetooth.h> #include <bluetooth/bnep.h> @@ -51,8 +49,8 @@ #include "bridge.h" #include "common.h" +#include "manager.h" #include "server.h" -#include "textfile.h" /* Pending Authorization */ struct pending_auth { @@ -77,48 +75,6 @@ struct network_server { static char netdev[16] = "bnep%d"; -static inline int create_filename(char *buf, size_t size, - bdaddr_t *bdaddr, const char *name) -{ - char addr[18]; - - ba2str(bdaddr, addr); - - return create_name(buf, size, STORAGEDIR, addr, name); -} - -static int del_stored_server_info(bdaddr_t *src, uint16_t uuid) -{ - char filename[PATH_MAX + 1]; - const char *str; - int err; - - create_filename(filename, PATH_MAX, src, "network"); - - str = bnep_uuid(uuid); - - err = textfile_del(filename, str); - - return err; -} - -static int store_server_info(bdaddr_t *src, uint16_t uuid, gboolean enable) -{ - char filename[PATH_MAX + 1]; - const char *str; - int err; - - create_filename(filename, PATH_MAX, src, "network"); - - str = bnep_uuid(uuid); - - create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - - err = textfile_put(filename, str, enable ? "1" : "0"); - - return err; -} - static void pending_auth_free(struct pending_auth *pauth) { if (!pauth) @@ -753,7 +709,7 @@ static DBusHandlerResult enable(DBusConnection *conn, if (err < 0) return err_failed(conn, msg, strerror(-err)); - store_server_info(&ns->src, ns->id, TRUE); + network_store_info(&ns->src, ns->id, TRUE); return send_message_and_unref(conn, reply); } @@ -781,7 +737,7 @@ static DBusHandlerResult disable(DBusConnection *conn, g_io_channel_unref(ns->io); ns->io = NULL; - store_server_info(&ns->src, ns->id, FALSE); + network_store_info(&ns->src, ns->id, FALSE); return send_message_and_unref(conn, reply); } @@ -1002,8 +958,6 @@ static void server_free(struct network_server *ns) g_io_channel_unref(ns->io); } - del_stored_server_info(&ns->src, ns->id); - g_free(ns); } @@ -1055,29 +1009,8 @@ int server_register(DBusConnection *conn, const char *addr, const char *path, info("Registered server path:%s", ns->path); - store_server_info(&ns->src, ns->id, FALSE); - return 0; fail: server_free(ns); return -1; } - -int read_server_uuid(bdaddr_t *src, uint16_t uuid, gboolean *enable) -{ - char filename[PATH_MAX + 1], *buff; - const char *str; - - create_filename(filename, PATH_MAX, src, "network"); - - str = bnep_uuid(uuid); - buff = textfile_get(filename, str); - if (!buff) - return -ENOENT; - - *enable = (strtol(buff, NULL, 10)) ? TRUE : FALSE; - - g_free(buff); - - return 0; -} |