diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-13 20:58:03 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-13 20:58:03 +0000 |
commit | af49fed2e0f5b71203c67fc163d29464ed534399 (patch) | |
tree | 02884be8fc136244f5280892352685165eec83cf /network | |
parent | a4bc8363b53f68c20bed8dcf5bf436c8609be199 (diff) |
network: changed server_register signature and code cleanup
Diffstat (limited to 'network')
-rw-r--r-- | network/manager.c | 4 | ||||
-rw-r--r-- | network/server.c | 28 | ||||
-rw-r--r-- | network/server.h | 4 |
3 files changed, 17 insertions, 19 deletions
diff --git a/network/manager.c b/network/manager.c index 450fd872..b2ca7fe7 100644 --- a/network/manager.c +++ b/network/manager.c @@ -391,12 +391,12 @@ static void get_address_reply(DBusPendingCall *call, void *data) goto fail; } - if (server_register(pr->conn, address, pr->path, pr->id) < 0) { + str2ba(address, &src); + if (server_register(pr->conn, pr->path, &src, pr->id) < 0) { err_failed(pr->conn, pr->msg, "D-Bus path registration failed"); goto fail; } - str2ba(address, &src); network_store_info(&src, pr->id, FALSE); server_paths = g_slist_append(server_paths, g_strdup(pr->path)); 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); diff --git a/network/server.h b/network/server.h index c4dd51e6..613b628d 100644 --- a/network/server.h +++ b/network/server.h @@ -21,8 +21,8 @@ * */ -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); int server_register_from_file(DBusConnection *conn, const char *path, const bdaddr_t *src, uint16_t id, const char *filename); int read_server_uuid(bdaddr_t *src, uint16_t uuid, gboolean *enable); |