diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc index c8cfc7242c..bb87a7a164 100644 --- a/repos/gems/src/app/phone_manager/main.cc +++ b/repos/gems/src/app/phone_manager/main.cc @@ -103,6 +103,15 @@ struct Sculpt::Main : Input_event_handler, Registry _child_states { }; + void _with_child(auto const &name, auto const &fn) + { + _child_states.for_each([&] (Child_state &child) { + if (child.name() == name) + fn(child); }); + + _child_states.for_each([&] (Child_state &) { }); /* restore orig. order */ + } + Input::Seq_number _global_input_seq_number { }; Gui::Connection _gui { _env, "input" }; @@ -1397,17 +1406,17 @@ struct Sculpt::Main : Input_event_handler, */ void restart_deployed_component(Start_name const &name) override { - if (name == "nic_drv") { + auto restart = [&] (auto const &name) + { + _with_child(name, [&] (Child_state &child) { + child.trigger_restart(); + generate_runtime_config(); + }); + }; - _network.restart_nic_drv_on_next_runtime_cfg(); - generate_runtime_config(); - - } else if (name == "wifi_drv") { - - _network.restart_wifi_drv_on_next_runtime_cfg(); - generate_runtime_config(); - - } else { + if (name == "nic" || name == "wifi") + restart(name); + else { _runtime_state.restart(name); diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index b7766ecf24..6fc62e8f60 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -88,6 +88,15 @@ struct Sculpt::Main : Input_event_handler, Registry _child_states { }; + void _with_child(auto const &name, auto const &fn) + { + _child_states.for_each([&] (Child_state &child) { + if (child.name() == name) + fn(child); }); + + _child_states.for_each([&] (Child_state &) { }); /* restore orig. order */ + } + Input::Seq_number _global_input_seq_number { }; Gui::Connection _gui { _env, "input" }; @@ -932,17 +941,17 @@ struct Sculpt::Main : Input_event_handler, */ void restart_deployed_component(Start_name const &name) override { - if (name == "nic") { + auto restart = [&] (auto const &name) + { + _with_child(name, [&] (Child_state &child) { + child.trigger_restart(); + generate_runtime_config(); + }); + }; - _network.restart_nic_drv_on_next_runtime_cfg(); - generate_runtime_config(); - - } else if (name == "wifi") { - - _network.restart_wifi_drv_on_next_runtime_cfg(); - generate_runtime_config(); - - } else { + if (name == "nic" || name == "wifi") + restart(name); + else { _runtime_state.restart(name); diff --git a/repos/gems/src/app/sculpt_manager/network.h b/repos/gems/src/app/sculpt_manager/network.h index db6ed466e3..18842ac977 100644 --- a/repos/gems/src/app/sculpt_manager/network.h +++ b/repos/gems/src/app/sculpt_manager/network.h @@ -61,9 +61,6 @@ struct Sculpt::Network : Noncopyable Wpa_passphrase wpa_passphrase { }; - unsigned _nic_drv_version = 0; - unsigned _wifi_drv_version = 0; - Rom_handler _wlan_accesspoints_rom { _env, "report -> runtime/wifi/accesspoints", *this, &Network::_handle_wlan_accesspoints }; @@ -165,9 +162,6 @@ struct Sculpt::Network : Noncopyable }); } - void restart_nic_drv_on_next_runtime_cfg() { _nic_drv_version++; } - void restart_wifi_drv_on_next_runtime_cfg() { _wifi_drv_version++; } - void wifi_disconnect() { /*