summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-03-19 13:24:41 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-03-19 13:24:41 +0000
commit851ad267e554850ae2cbfd486922cbcfb897f8b5 (patch)
tree9a393fb7e36f3782cf54caac05592e9c41be5918 /network
parentad868bd4137e86fbf141175f411898796287ff2a (diff)
- Fix standalone init when there is no bluetooth adapter.
Diffstat (limited to 'network')
-rw-r--r--network/connection.c26
-rw-r--r--network/connection.h1
-rw-r--r--network/main.c6
-rw-r--r--network/manager.c6
4 files changed, 33 insertions, 6 deletions
diff --git a/network/connection.c b/network/connection.c
index cdcdcbb1..4966a7e1 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -33,6 +33,7 @@
#include "dbus.h"
#define NETWORK_CONNECTION_INTERFACE "org.bluez.network.Manager"
+#define NETWORK_CONNECTION_PATH "/org/bluez/network/connection"
#define NETWORK_ERROR_INTERFACE "org.bluez.Error"
#include "connection.h"
@@ -153,3 +154,28 @@ static const DBusObjectPathVTable connection_table = {
.unregister_function = connection_unregister,
};
+int connection_register(DBusConnection *conn, const char *path)
+{
+ struct network_conn *nc;
+ static int nc_uid = 0;
+
+ if (!conn)
+ return -1;
+
+ nc = g_new0(struct network_conn, 1);
+
+ /* register path */
+ if (!dbus_connection_register_object_path(conn, path,
+ &connection_table, nc)) {
+ error("D-Bus failed to register %s path", path);
+ goto fail;
+ }
+
+ nc->path = g_strdup(path);
+ info("Registered connection path:%s", path);
+
+ return 0;
+fail:
+ connection_free(nc);
+ return -1;
+}
diff --git a/network/connection.h b/network/connection.h
index e87dd676..b2dc2ab3 100644
--- a/network/connection.h
+++ b/network/connection.h
@@ -20,3 +20,4 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+int connection_register(DBusConnection *conn, const char *path);
diff --git a/network/main.c b/network/main.c
index 5e8f2739..d0daf429 100644
--- a/network/main.c
+++ b/network/main.c
@@ -66,15 +66,17 @@ int main(int argc, char *argv[])
/* Create event loop */
main_loop = g_main_loop_new(NULL, FALSE);
+ if (network_init() == -1)
+ goto fail;
+
if (argc > 1 && !strcmp(argv[1], "-s"))
internal_service("network");
- network_init();
-
g_main_loop_run(main_loop);
network_exit();
+fail:
g_main_loop_unref(main_loop);
info("Exit");
diff --git a/network/manager.c b/network/manager.c
index 26ebf57b..e0265af7 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -191,7 +191,7 @@ int network_dbus_init(void)
mgr = g_new0(struct manager, 1);
- /* Fallback to catch invalid device path */
+ /* Fallback to catch invalid network path */
if (!dbus_connection_register_fallback(connection, NETWORK_PATH,
&manager_table, mgr)) {
error("D-Bus failed to register %s path", NETWORK_PATH);
@@ -262,8 +262,6 @@ void internal_service(const char *identifier)
int network_init(void)
{
- network_dbus_init();
-
if (bridge_init() < 0) {
error("Can't init bridge module");
return -1;
@@ -274,7 +272,7 @@ int network_init(void)
return -1;
}
- return 0;
+ return network_dbus_init();
}
void network_exit(void)