diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-12 12:19:39 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-12 12:19:39 +0000 |
commit | 9743174631a196c41c50d30af936d62488e9b843 (patch) | |
tree | a391402b8a5d7db33dd5e0bd5f6d80073a389afb | |
parent | e5aff3f6f7c43f4ddf8d83358d6a49ad2f81e750 (diff) |
network: code cleanup
-rw-r--r-- | network/manager.c | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/network/manager.c b/network/manager.c index 408e0ab3..0195c960 100644 --- a/network/manager.c +++ b/network/manager.c @@ -53,13 +53,13 @@ struct manager { }; struct pending_reply { - DBusConnection *conn; - DBusMessage *msg; - struct manager *mgr; - uint16_t id; - char *addr; - char *path; - char *adapter_path; + DBusConnection *conn; + DBusMessage *msg; + struct manager *mgr; + char *addr; + char *path; + char *adapter_path; + uint16_t id; }; static DBusConnection *connection = NULL; @@ -648,37 +648,9 @@ static const DBusObjectPathVTable manager_table = { .unregister_function = manager_unregister, }; -int network_dbus_init(void) -{ - struct manager *mgr; - - mgr = g_new0(struct manager, 1); - - /* Fallback to catch invalid network path */ - if (dbus_connection_register_fallback(connection, NETWORK_PATH, - &manager_table, mgr) == FALSE) { - error("D-Bus failed to register %s path", NETWORK_PATH); - goto fail; - } - - info("Registered manager path:%s", NETWORK_PATH); - - return 0; - -fail: - manager_free(mgr); - - return -1; -} - -void network_dbus_exit(void) -{ - dbus_connection_unregister_object_path(connection, NETWORK_PATH); -} - int network_init(DBusConnection *conn) { - int err; + struct manager *mgr; if (bridge_init() < 0) { error("Can't init bridge module"); @@ -697,16 +669,27 @@ int network_init(DBusConnection *conn) connection = dbus_connection_ref(conn); - err = network_dbus_init(); - if (err < 0) + /* FIXME: make manager global */ + mgr = g_new0(struct manager, 1); + + /* Fallback to catch invalid network path */ + if (dbus_connection_register_fallback(connection, NETWORK_PATH, + &manager_table, mgr) == FALSE) { + error("D-Bus failed to register %s path", NETWORK_PATH); + manager_free(mgr); dbus_connection_unref(connection); - return err; + return -1; + } + + info("Registered manager path:%s", NETWORK_PATH); + + return 0; } void network_exit(void) { - network_dbus_exit(); + dbus_connection_unregister_object_path(connection, NETWORK_PATH); dbus_connection_unref(connection); |