Repository navigation
Description
Right now the engine is responsible for making UI appear to allow the user to choose an input file:
servo/components/bluetooth/lib.rs
Lines 369 to 397 in f467bdc
| #[cfg(target_os = "linux")] | |
| fn select_device(&mut self, devices: Vec<BluetoothDevice>, adapter: &BluetoothAdapter) -> Option<String> { | |
| if is_mock_adapter(adapter) || opts::get().headless { | |
| for device in devices { | |
| if let Ok(address) = device.get_address() { | |
| return Some(address); | |
| } | |
| } | |
| return None; | |
| } | |
| let mut dialog_rows: Vec<String> = vec!(); | |
| for device in devices { | |
| dialog_rows.extend_from_slice(&[device.get_address().unwrap_or("".to_string()), | |
| device.get_name().unwrap_or("".to_string())]); | |
| } | |
| let dialog_rows: Vec<&str> = dialog_rows.iter() | |
| .map(|s| s.as_ref()) | |
| .collect(); | |
| let dialog_rows: &[&str] = dialog_rows.as_slice(); | |
| if let Some(device) = tinyfiledialogs::list_dialog(DIALOG_TITLE, | |
| &[DIALOG_COLUMN_ID, DIALOG_COLUMN_NAME], | |
| Some(dialog_rows)) { | |
| // The device string format will be "Address|Name". We need the first part of it. | |
| return device.split("|").next().map(|s| s.to_string()); | |
| } | |
| None | |
| } |
Instead, the bluetooth code should send a message to the constellation, which can talk to the embedder and receive the final selection to return to the bluetooth code. This means the bluetooth thread needs to have access to a channel which can communicate with the constellation; this can come from BluetoothManager::new via BluetoothThreadFactory. This is a good model for communicating with the embedder from the constellation.
It's possible to test these changes if you're on linux and you enable the bluetooth preferences and try one of the demo WebBluetooth, but it's also possible to make these changes without testing them.
Activity
kwonoj commentedon Mar 25, 2018
I think this is cruxwise same as #20428, let me try to apply same practices. @highfive assign me
highfive commentedon Mar 25, 2018
Hey @kwonoj! Thanks for your interest in working on this issue. It's now assigned to you!
Auto merge of #20578 - kwonoj:refactor-bluetooth-manager, r=kwonoj
Auto merge of #20578 - kwonoj:refactor-bluetooth-manager, r=kwonoj
Auto merge of #20578 - kwonoj:refactor-bluetooth-manager, r=paulrouget
Auto merge of #20578 - kwonoj:refactor-bluetooth-manager, r=paulrouget