sculpt: show wifi button only if wifi card present

This commit is contained in:
Norman Feske 2018-06-01 15:22:17 +02:00 committed by Christian Helmuth
parent fc800ef9e5
commit d4408beeaf
5 changed files with 67 additions and 7 deletions

View File

@ -84,6 +84,31 @@ struct Sculpt::Main : Input_event_handler,
void _handle_nitpicker_hover();
/**********************
** Device discovery **
**********************/
Attached_rom_dataspace _pci_devices { _env, "report -> drivers/pci_devices" };
Signal_handler<Main> _pci_devices_handler {
_env.ep(), *this, &Main::_handle_pci_devices };
Pci_info _pci_info { };
void _handle_pci_devices()
{
_pci_devices.update();
_pci_info.wifi_present = false;
_pci_devices.xml().for_each_sub_node("device", [&] (Xml_node device) {
/* detect Intel Wireless card */
if (device.attribute_value("class_code", 0UL) == 0x28000)
_pci_info.wifi_present = true;
});
}
/***************************
** Configuration loading **
***************************/
@ -115,7 +140,7 @@ struct Sculpt::Main : Input_event_handler,
}
Network _network { _env, _heap, *this, *this, *this };
Network _network { _env, _heap, *this, *this, *this, _pci_info };
/************
@ -323,6 +348,7 @@ struct Sculpt::Main : Input_event_handler,
_update_state_rom.sigh(_update_state_handler);
_nitpicker_hover .sigh(_nitpicker_hover_handler);
_hover_rom .sigh(_hover_handler);
_pci_devices .sigh(_pci_devices_handler);
/*
* Generate initial configurations
@ -334,6 +360,7 @@ struct Sculpt::Main : Input_event_handler,
*/
_storage.handle_storage_devices_update();
_deploy.handle_deploy();
_handle_pci_devices();
generate_runtime_config();
generate_dialog();

View File

@ -0,0 +1,26 @@
/*
* \brief PCI discovery information
* \author Norman Feske
* \date 2018-06-01
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _MODEL__PCI_INFO_H_
#define _MODEL__PCI_INFO_H_
#include "types.h"
namespace Sculpt { struct Pci_info; }
struct Sculpt::Pci_info
{
bool wifi_present = false;
};
#endif /* _MODEL__PCI_INFO_H_ */

View File

@ -40,6 +40,7 @@ struct Sculpt::Network : Network_dialog::Action
Runtime_config_generator &_runtime_config_generator;
Runtime_info const &_runtime_info;
Pci_info const &_pci_info;
Nic_target _nic_target { };
Nic_state _nic_state { };
@ -94,7 +95,8 @@ struct Sculpt::Network : Network_dialog::Action
Network_dialog dialog {
_env, _dialog_generator, _nic_target, _access_points,
_wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy };
_wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy,
_pci_info };
Managed_config<Network> _wlan_config {
_env, "selected_network", "wlan", *this, &Network::_handle_wlan_config };
@ -183,11 +185,11 @@ struct Sculpt::Network : Network_dialog::Action
Network(Env &env, Allocator &alloc, Dialog::Generator &dialog_generator,
Runtime_config_generator &runtime_config_generator,
Runtime_info const &runtime_info)
Runtime_info const &runtime_info, Pci_info const &pci_info)
:
_env(env), _alloc(alloc), _dialog_generator(dialog_generator),
_runtime_config_generator(runtime_config_generator),
_runtime_info(runtime_info)
_runtime_info(runtime_info), _pci_info(pci_info)
{
_generate_nic_router_config();

View File

@ -224,7 +224,8 @@ void Sculpt::Network_dialog::generate(Xml_generator &xml) const
gen_nic_button("wired", Nic_target::WIRED, "Wired");
if (_nic_target.managed() || _nic_target.wifi())
gen_nic_button("wifi", Nic_target::WIFI, "Wifi");
if (_pci_info.wifi_present)
gen_nic_button("wifi", Nic_target::WIFI, "Wifi");
});
if (_nic_target.type == Nic_target::WIFI || _nic_target.type == Nic_target::WIRED) {

View File

@ -19,6 +19,7 @@
#include <model/nic_state.h>
#include <model/wifi_connection.h>
#include <model/wpa_passphrase.h>
#include <model/pci_info.h>
#include <view/dialog.h>
#include <view/selectable_item.h>
@ -39,6 +40,7 @@ struct Sculpt::Network_dialog : Dialog
Nic_state const &_nic_state;
Blind_wpa_passphrase const &_wpa_passphrase;
Wlan_config_policy const &_wlan_config_policy;
Pci_info const &_pci_info;
Hoverable_item _nic_item { };
Selectable_item _ap_item { };
@ -101,12 +103,14 @@ struct Sculpt::Network_dialog : Dialog
Wifi_connection const &wifi_connection,
Nic_state const &nic_state,
Blind_wpa_passphrase const &wpa_passphrase,
Wlan_config_policy const &wlan_config_policy)
Wlan_config_policy const &wlan_config_policy,
Pci_info const &pci_info)
:
_env(env), _dialog_generator(dialog_generator),
_nic_target(nic_target), _access_points(access_points),
_wifi_connection(wifi_connection), _nic_state(nic_state),
_wpa_passphrase(wpa_passphrase), _wlan_config_policy(wlan_config_policy)
_wpa_passphrase(wpa_passphrase), _wlan_config_policy(wlan_config_policy),
_pci_info(pci_info)
{ }
};