summaryrefslogtreecommitdiffstats
path: root/network/server.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-16 19:32:49 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-16 19:32:49 +0000
commitd2692a02cf86935b4c96198eff694a01c3001890 (patch)
tree4668fe995768aa44dbb98b48d8649d9b0ebf8b3e /network/server.c
parent6745ef8707548a27267184c29dd126945da4b19e (diff)
network: fixed default adapter
Diffstat (limited to 'network/server.c')
-rw-r--r--network/server.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/network/server.c b/network/server.c
index 754a37dc..e47c06ac 100644
--- a/network/server.c
+++ b/network/server.c
@@ -31,9 +31,12 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <net/if.h>
#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
#include <bluetooth/bnep.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/sdp.h>
@@ -723,6 +726,17 @@ static DBusHandlerResult enable(DBusConnection *conn,
if (ns->io)
return err_already_exists(conn, msg, "Server already enabled");
+ if (bacmp(&ns->src, BDADDR_ANY) == 0) {
+ int dev_id;
+
+ dev_id = hci_get_route(NULL);
+ if ((dev_id < 0) || (hci_devba(dev_id, &ns->src) < 0))
+ return err_failed(conn, msg, "Adapter not available");
+
+ /* Store the server info */
+ server_store(conn, ns->path);
+ }
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
@@ -1114,6 +1128,8 @@ int server_store(DBusConnection *conn, const char *path)
else
create_name(filename, PATH_MAX, STORAGEDIR, addr, "gn");
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
textfile_put(filename, "name", ns->name);
if (ns->iface)