int proxy_register(DBusConnection *conn, struct btd_adapter *btd_adapter) { struct serial_adapter *adapter; const char *path; adapter = find_adapter(adapters, btd_adapter); if (adapter) return -EINVAL; adapter = g_new0(struct serial_adapter, 1); adapter->conn = dbus_connection_ref(conn); adapter->btd_adapter = btd_adapter_ref(btd_adapter); path = adapter_get_path(btd_adapter); if (!g_dbus_register_interface(conn, path, SERIAL_MANAGER_INTERFACE, manager_methods, manager_signals, NULL, adapter, manager_path_unregister)) { error("Failed to register %s interface to %s", SERIAL_MANAGER_INTERFACE, path); return -1; } register_stored(adapter); adapters = g_slist_append(adapters, adapter); debug("Registered interface %s on path %s", SERIAL_MANAGER_INTERFACE, path); return 0; }
int network_manager_init(DBusConnection *conn, struct network_conf *service_conf) { GDBusMethodTable *methods = NULL; GDBusSignalTable *signals = NULL; conf = service_conf; if (conf->server_enabled && conf->connection_enabled) { methods = manager_methods; signals = connection_signals; } else if (conf->connection_enabled) { methods = connection_methods; signals = connection_signals; } else if (conf->server_enabled) methods = server_methods; else { error ("All interfaces were disabled"); return -1; } if (bnep_init(conf->panu_script, conf->gn_script, conf->nap_script)) { error("Can't init bnep module"); return -1; } /* * There is one socket to handle the incomming connections. NAP, * GN and PANU servers share the same PSM. The initial BNEP message * (setup connection request) contains the destination service * field that defines which service the source is connecting to. */ if (conf->server_enabled) { if (bridge_init(conf->gn_iface, conf->nap_iface) < 0) { error("Can't init bridge module"); return -1; } if (server_init(conn, conf->iface_prefix, conf->security) < 0) return -1; } if (conf->connection_enabled) { if (connection_init(conn, conf->iface_prefix) < 0) return -1; } if (g_dbus_register_interface(conn, NETWORK_PATH, NETWORK_MANAGER_INTERFACE, methods, signals, NULL, NULL, manager_unregister) == FALSE) { error("Failed to register %s interface to %s", NETWORK_MANAGER_INTERFACE, NETWORK_PATH); return -1; } connection = dbus_connection_ref(conn); info("Registered manager path:%s", NETWORK_PATH); register_stored(); /* Register PANU, GN and NAP servers if they don't exist */ register_server(BNEP_SVC_PANU); register_server(BNEP_SVC_GN); register_server(BNEP_SVC_NAP); return 0; }