Discman
Loading...
Searching...
No Matches
BluetoothComponent Class Reference

Handles the interactions with the Bluetooth device selection screen. More...

#include <bluetooth_component.h>

Inheritance diagram for BluetoothComponent:
Collaboration diagram for BluetoothComponent:

Classes

class  DevicesListColumnRecord
 Bluetooth device list columns. More...
 

Public Types

typedef sigc::signal< void()> sig_done
 "Done with screen" signal type.
 
typedef sigc::signal< void()> sig_conn
 "Connected" signal type.
 
typedef sigc::signal< void()> sig_button
 "Button clicked" signal type.
 

Public Member Functions

 BluetoothComponent (Glib::RefPtr< Gtk::Builder > builder)
 BluetoothComponent constructor.
 
 ~BluetoothComponent ()
 BluetoothComponent destructor.
 
void on_show ()
 Called when the Bluetooth device selection screen is navigated to.
 
void on_hide ()
 Called when the Bluetooth device selection screen is navigated from.
 
void on_device_initialization_complete (const bool initialized)
 Called when the Bluetooth device initialization procedure has finished.
 
sig_button signal_button ()
 Getter for _signal_button.
 
sig_done signal_done ()
 Getter for _signal_done.
 
sig_conn signal_connected ()
 Getter for _signal_connected.
 

Private Types

enum  DeviceInitialization { NotInitialized , Initialized , Error }
 Bluetooth device initialization state. More...
 

Private Member Functions

void on_bluetooth_button ()
 Bluetooth button handler.
 
void on_done_button_clicked ()
 Called when the Done button is clicked.
 
void on_device_added (const std::string &address)
 Called when _adapter discovers a new device.
 
void on_device_removed (const std::string &address)
 Called when _adapter reports a removed device.
 
void on_devices_list_selection_changed ()
 Called when a device is clicked in the device list.
 
void on_connect_button_clicked ()
 Called when the Connect/Disconnect button is clicked.
 
void on_device_status_change ()
 Called when the chosen device pairs, connects or disconnects.
 
void build_devices_list ()
 Builds the initial list of preregistered Bluetooth devices.
 
void get_alsa_device_address ()
 Retrieves the device MAC address from the ALSA configuration file.
 
void try_get_alsa_device ()
 Attempts to set _alsa_device based on _alsa_device_address.
 
void set_device_labels ()
 Updates _device_label and _device_status_label based on current state.
 
void update_asoundrc (const std::string &address)
 Update the ALSA configuration file with the newly selected Bluetooth device.
 

Private Attributes

sig_button _signal_button
 Emitted when the Bluetooth button is clicked.
 
sig_conn _signal_connected
 Emitted when the chosen device has been connected to.
 
sig_done _signal_done
 Emitted when the Done button is clicked.
 
Bluez::Adapter _adapter
 Bluetooth adapter used for pairing and connection.
 
std::string _alsa_device_address
 MAC address of the chosen device.
 
Bluez::Device * _alsa_device
 Bluetooth device retrieved from _adapter.
 
Gtk::Button * _bluetooth_button
 Button that switches to the Bluetooth device selection screen.
 
Gtk::Label * _device_label
 Label displaying the chosen device alias.
 
Gtk::Label * _device_status_label
 Label displaying chosen device connection status.
 
Gtk::TreeView * _devices_tree_view
 Device list.
 
Glib::RefPtr< Gtk::ListStore > _devices_list_store
 Device list model.
 
Gtk::Button * _done_button
 Done button.
 
Gtk::Button * _connect_button
 Connect/Disconnect button.
 
DeviceInitialization _alsa_device_init
 Initialization status of the chosen device.
 

Additional Inherited Members

- Protected Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=0
 

Detailed Description

Handles the interactions with the Bluetooth device selection screen.

Definition at line 30 of file bluetooth_component.h.

Member Typedef Documentation

◆ sig_button

typedef sigc::signal<void()> BluetoothComponent::sig_button

"Button clicked" signal type.

Definition at line 40 of file bluetooth_component.h.

◆ sig_conn

typedef sigc::signal<void()> BluetoothComponent::sig_conn

"Connected" signal type.

Definition at line 37 of file bluetooth_component.h.

◆ sig_done

typedef sigc::signal<void()> BluetoothComponent::sig_done

"Done with screen" signal type.

Definition at line 34 of file bluetooth_component.h.

Member Enumeration Documentation

◆ DeviceInitialization

Bluetooth device initialization state.

Enumerator
NotInitialized 
Initialized 
Error 

Definition at line 63 of file bluetooth_component.h.

Constructor & Destructor Documentation

◆ BluetoothComponent()

BluetoothComponent::BluetoothComponent ( Glib::RefPtr< Gtk::Builder > builder)

BluetoothComponent constructor.

Parameters
[in]builderThe builder initialized with the widgets on the Bluetooth device selection screen.

Definition at line 9 of file bluetooth_component.cc.

◆ ~BluetoothComponent()

BluetoothComponent::~BluetoothComponent ( )

BluetoothComponent destructor.

Definition at line 33 of file bluetooth_component.cc.

Member Function Documentation

◆ build_devices_list()

void BluetoothComponent::build_devices_list ( )
private

Builds the initial list of preregistered Bluetooth devices.

Definition at line 174 of file bluetooth_component.cc.

◆ get_alsa_device_address()

void BluetoothComponent::get_alsa_device_address ( )
private

Retrieves the device MAC address from the ALSA configuration file.

Definition at line 188 of file bluetooth_component.cc.

◆ on_bluetooth_button()

void BluetoothComponent::on_bluetooth_button ( )
private

Bluetooth button handler.

Definition at line 243 of file bluetooth_component.cc.

◆ on_connect_button_clicked()

void BluetoothComponent::on_connect_button_clicked ( )
private

Called when the Connect/Disconnect button is clicked.

Definition at line 141 of file bluetooth_component.cc.

◆ on_device_added()

void BluetoothComponent::on_device_added ( const std::string & address)
private

Called when _adapter discovers a new device.

Definition at line 79 of file bluetooth_component.cc.

◆ on_device_initialization_complete()

void BluetoothComponent::on_device_initialization_complete ( const bool initialized)

Called when the Bluetooth device initialization procedure has finished.

Parameters
[in]initializedinitialized (true) or error (false)

Definition at line 58 of file bluetooth_component.cc.

◆ on_device_removed()

void BluetoothComponent::on_device_removed ( const std::string & address)
private

Called when _adapter reports a removed device.

Definition at line 94 of file bluetooth_component.cc.

◆ on_device_status_change()

void BluetoothComponent::on_device_status_change ( )
private

Called when the chosen device pairs, connects or disconnects.

Definition at line 162 of file bluetooth_component.cc.

◆ on_devices_list_selection_changed()

void BluetoothComponent::on_devices_list_selection_changed ( )
private

Called when a device is clicked in the device list.

Definition at line 114 of file bluetooth_component.cc.

◆ on_done_button_clicked()

void BluetoothComponent::on_done_button_clicked ( )
private

Called when the Done button is clicked.

Definition at line 75 of file bluetooth_component.cc.

◆ on_hide()

void BluetoothComponent::on_hide ( )

Called when the Bluetooth device selection screen is navigated from.

Definition at line 54 of file bluetooth_component.cc.

◆ on_show()

void BluetoothComponent::on_show ( )

Called when the Bluetooth device selection screen is navigated to.

Definition at line 44 of file bluetooth_component.cc.

◆ set_device_labels()

void BluetoothComponent::set_device_labels ( )
private

Updates _device_label and _device_status_label based on current state.

Definition at line 220 of file bluetooth_component.cc.

◆ signal_button()

BluetoothComponent::sig_done BluetoothComponent::signal_button ( )

Getter for _signal_button.

Definition at line 63 of file bluetooth_component.cc.

◆ signal_connected()

BluetoothComponent::sig_conn BluetoothComponent::signal_connected ( )

Getter for _signal_connected.

Definition at line 71 of file bluetooth_component.cc.

◆ signal_done()

BluetoothComponent::sig_done BluetoothComponent::signal_done ( )

Getter for _signal_done.

Definition at line 67 of file bluetooth_component.cc.

◆ try_get_alsa_device()

void BluetoothComponent::try_get_alsa_device ( )
private

Attempts to set _alsa_device based on _alsa_device_address.

Definition at line 206 of file bluetooth_component.cc.

◆ update_asoundrc()

void BluetoothComponent::update_asoundrc ( const std::string & address)
private

Update the ALSA configuration file with the newly selected Bluetooth device.

Parameters
[in]addressMAC address of the selected device.

Definition at line 123 of file bluetooth_component.cc.

Member Data Documentation

◆ _adapter

Bluez::Adapter BluetoothComponent::_adapter
private

Bluetooth adapter used for pairing and connection.

Definition at line 85 of file bluetooth_component.h.

◆ _alsa_device

Bluez::Device* BluetoothComponent::_alsa_device
private

Bluetooth device retrieved from _adapter.

Definition at line 87 of file bluetooth_component.h.

◆ _alsa_device_address

std::string BluetoothComponent::_alsa_device_address
private

MAC address of the chosen device.

Definition at line 86 of file bluetooth_component.h.

◆ _alsa_device_init

DeviceInitialization BluetoothComponent::_alsa_device_init
private

Initialization status of the chosen device.

Definition at line 98 of file bluetooth_component.h.

◆ _bluetooth_button

Gtk::Button* BluetoothComponent::_bluetooth_button
private

Button that switches to the Bluetooth device selection screen.

Definition at line 89 of file bluetooth_component.h.

◆ _connect_button

Gtk::Button* BluetoothComponent::_connect_button
private

Connect/Disconnect button.

Definition at line 96 of file bluetooth_component.h.

◆ _device_label

Gtk::Label* BluetoothComponent::_device_label
private

Label displaying the chosen device alias.

Definition at line 91 of file bluetooth_component.h.

◆ _device_status_label

Gtk::Label* BluetoothComponent::_device_status_label
private

Label displaying chosen device connection status.

Definition at line 92 of file bluetooth_component.h.

◆ _devices_list_store

Glib::RefPtr<Gtk::ListStore> BluetoothComponent::_devices_list_store
private

Device list model.

Definition at line 94 of file bluetooth_component.h.

◆ _devices_tree_view

Gtk::TreeView* BluetoothComponent::_devices_tree_view
private

Device list.

Definition at line 93 of file bluetooth_component.h.

◆ _done_button

Gtk::Button* BluetoothComponent::_done_button
private

Done button.

Definition at line 95 of file bluetooth_component.h.

◆ _signal_button

sig_button BluetoothComponent::_signal_button
private

Emitted when the Bluetooth button is clicked.

Definition at line 81 of file bluetooth_component.h.

◆ _signal_connected

sig_conn BluetoothComponent::_signal_connected
private

Emitted when the chosen device has been connected to.

Definition at line 82 of file bluetooth_component.h.

◆ _signal_done

sig_done BluetoothComponent::_signal_done
private

Emitted when the Done button is clicked.

Definition at line 83 of file bluetooth_component.h.


The documentation for this class was generated from the following files: