Skip to content

Remove use of tinyfiledialogs from bluetooth code #20429

Closed

Description

@jdm

Right now the engine is responsible for making UI appear to allow the user to choose an input file:

#[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

  1. added
    I-refactor
    E-more-complex
    on Mar 25, 2018
  2. kwonoj commented on Mar 25, 2018

    @kwonoj
    Contributor

    I think this is cruxwise same as #20428, let me try to apply same practices. @highfive assign me

  3. highfive commented on Mar 25, 2018

    @highfive

    Hey @kwonoj! Thanks for your interest in working on this issue. It's now assigned to you!

  4. added
    C-assigned
    on Mar 25, 2018
  5. added 4 commits that reference this issue on Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/bluetoothA-embeddingC-assignedE-more-complexI-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions