summaryrefslogtreecommitdiffstats
path: root/network/server.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-13 20:58:03 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-13 20:58:03 +0000
commitaf49fed2e0f5b71203c67fc163d29464ed534399 (patch)
tree02884be8fc136244f5280892352685165eec83cf /network/server.c
parenta4bc8363b53f68c20bed8dcf5bf436c8609be199 (diff)
network: changed server_register signature and code cleanup
Diffstat (limited to 'network/server.c')
-rw-r--r--network/server.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/network/server.c b/network/server.c
index a7dc3f6b..2e6ae84c 100644
--- a/network/server.c
+++ b/network/server.c
@@ -981,8 +981,8 @@ static const DBusObjectPathVTable server_table = {
.unregister_function = server_unregister,
};
-int server_register(DBusConnection *conn, const char *addr, const char *path,
- uint16_t id)
+int server_register(DBusConnection *conn, const char *path,
+ bdaddr_t *src, uint16_t id)
{
struct network_server *ns;
@@ -998,7 +998,8 @@ int server_register(DBusConnection *conn, const char *addr, const char *path,
if (!dbus_connection_register_object_path(conn, path,
&server_table, ns)) {
error("D-Bus failed to register %s path", path);
- goto fail;
+ server_free(ns);
+ return -1;
}
/* Setting a default name */
@@ -1010,14 +1011,11 @@ int server_register(DBusConnection *conn, const char *addr, const char *path,
ns->path = g_strdup(path);
ns->id = id;
ns->conn = dbus_connection_ref(conn);
- str2ba(addr, &ns->src);
+ bacpy(&ns->src, src);
info("Registered server path:%s", path);
return 0;
-fail:
- server_free(ns);
- return -1;
}
int server_register_from_file(DBusConnection *conn, const char *path,
@@ -1028,6 +1026,14 @@ int server_register_from_file(DBusConnection *conn, const char *path,
ns = g_new0(struct network_server, 1);
+ /* Register path */
+ if (!dbus_connection_register_object_path(conn, path,
+ &server_table, ns)) {
+ error("D-Bus failed to register %s path", path);
+ server_free(ns);
+ return -1;
+ }
+
ns->id = id;
ns->name = textfile_get(filename, "name");
if (!ns->name) {
@@ -1047,14 +1053,6 @@ int server_register_from_file(DBusConnection *conn, const char *path,
ns->range = textfile_get(filename, "address_range");
ns->iface = textfile_get(filename, "routing");
- /* Register path */
- if (!dbus_connection_register_object_path(conn, path,
- &server_table, ns)) {
- error("D-Bus failed to register %s path", path);
- server_free(ns);
- return -1;
- }
-
/* FIXME: Missing enabled the server(if applied) */
info("Registered server path:%s", path);