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

Manages the state of the disc drive and any removable (iPod) drive. More...

#include <drive_manager.h>

Collaboration diagram for DriveManager:

Classes

struct  NoDriveException
 Thrown when the assumption of the presence of a drive is false. More...
 
class  Poller
 The Poller uses a separate thread to poll the host for the presence of an audio CD. More...
 

Public Types

enum  Drive { Disc , Removable }
 The two drives supported. More...
 
typedef sigc::signal< void(Drive)> sig_drive
 "Inserted" and "Ejected" shared signal type.
 

Public Member Functions

 DriveManager ()
 DriveManager constructor.
 
 ~DriveManager ()
 DriveManager destructor.
 
sig_drive signal_inserted ()
 Getter for ::_signal_inserted.
 
sig_drive signal_ejected ()
 Getter for ::_signal_ejected.
 
void eject (const Drive drive)
 Eject one of the drives.
 
bool is_disc_present () const
 Returns the (cached) property of disc presence.
 
bool is_removable_present () const
 Returns the (cached) property of iPod presence.
 
UDisks2::Filesystem & removable ()
 Returns the UDisks2::Filesystem cassociated with the iPod.
 
CDDrivedisc_drive ()
 Returns the CDDrive associated with the disc drive.
 

Private Member Functions

void on_udisks2_init ()
 Called when UDisks2 initializes the list of preregisterd drives and filesystems.
 
void on_notification_from_poller ()
 Called when _dispatcher is notified.
 
void on_cddrive_eject ()
 Called when the disc drive successfully ejects.
 
void on_removable_added (const std::string &path)
 Called when a new filesystem appears.
 
void on_removable_removed (const std::string &path)
 Called when a filesystem is removed.
 
void on_removable_mounted (const std::string &)
 Called when the removable drive is mounted.
 
void on_removable_unmounted ()
 Called when the removable drive is unmounted.
 

Private Attributes

sig_drive _sig_inserted
 Emitted when a drive is inserted.
 
sig_drive _sig_ejected
 Emitted when a drive is removed.
 
CDDrive _drive
 The disc drive.
 
UDisks2::Manager _udisks2
 UDisks2 provides access to removable disks.
 
UDisks2::Filesystem * _removable_fs
 The filesystem associated with the iPod.
 
Poller_poller
 When running, checks for the presence of a disc in _drive.
 
Glib::Dispatcher _dispatcher
 Used to samely emit _sig_inserted for the disc drive.
 
std::regex _acceptable_fs_pat
 Filters the filesystems reported by UDisks2 to acceptable ones.
 

Detailed Description

Manages the state of the disc drive and any removable (iPod) drive.

Definition at line 22 of file drive_manager.h.

Member Typedef Documentation

◆ sig_drive

typedef sigc::signal<void(Drive)> DriveManager::sig_drive

"Inserted" and "Ejected" shared signal type.

Definition at line 38 of file drive_manager.h.

Member Enumeration Documentation

◆ Drive

The two drives supported.

Enumerator
Disc 
Removable 

Definition at line 26 of file drive_manager.h.

Constructor & Destructor Documentation

◆ DriveManager()

DriveManager::DriveManager ( )

DriveManager constructor.

Definition at line 9 of file drive_manager.cc.

◆ ~DriveManager()

DriveManager::~DriveManager ( )

DriveManager destructor.

Definition at line 20 of file drive_manager.cc.

Member Function Documentation

◆ disc_drive()

CDDrive & DriveManager::disc_drive ( )

Returns the CDDrive associated with the disc drive.

Definition at line 150 of file drive_manager.cc.

◆ eject()

void DriveManager::eject ( const Drive drive)

Eject one of the drives.

Parameters
[in]driveDrive::Disc or Drive::Removable.

Definition at line 52 of file drive_manager.cc.

◆ is_disc_present()

bool DriveManager::is_disc_present ( ) const

Returns the (cached) property of disc presence.

Definition at line 134 of file drive_manager.cc.

◆ is_removable_present()

bool DriveManager::is_removable_present ( ) const

Returns the (cached) property of iPod presence.

Definition at line 138 of file drive_manager.cc.

◆ on_cddrive_eject()

void DriveManager::on_cddrive_eject ( )
private

Called when the disc drive successfully ejects.

Definition at line 65 of file drive_manager.cc.

◆ on_notification_from_poller()

void DriveManager::on_notification_from_poller ( )
private

Called when _dispatcher is notified.

Definition at line 94 of file drive_manager.cc.

◆ on_removable_added()

void DriveManager::on_removable_added ( const std::string & path)
private

Called when a new filesystem appears.

Parameters
[in]pathThe D-Bus path to the filesystem.

Definition at line 101 of file drive_manager.cc.

◆ on_removable_mounted()

void DriveManager::on_removable_mounted ( const std::string & )
private

Called when the removable drive is mounted.

Definition at line 126 of file drive_manager.cc.

◆ on_removable_removed()

void DriveManager::on_removable_removed ( const std::string & path)
private

Called when a filesystem is removed.

Parameters
[in]pathThe D-Bus path to the filesystem.

Definition at line 114 of file drive_manager.cc.

◆ on_removable_unmounted()

void DriveManager::on_removable_unmounted ( )
private

Called when the removable drive is unmounted.

Definition at line 130 of file drive_manager.cc.

◆ on_udisks2_init()

void DriveManager::on_udisks2_init ( )
private

Called when UDisks2 initializes the list of preregisterd drives and filesystems.

Definition at line 80 of file drive_manager.cc.

◆ removable()

UDisks2::Filesystem & DriveManager::removable ( )

Returns the UDisks2::Filesystem cassociated with the iPod.

Definition at line 142 of file drive_manager.cc.

◆ signal_ejected()

DriveManager::sig_drive DriveManager::signal_ejected ( )

Getter for ::_signal_ejected.

Definition at line 76 of file drive_manager.cc.

◆ signal_inserted()

DriveManager::sig_drive DriveManager::signal_inserted ( )

Getter for ::_signal_inserted.

Definition at line 72 of file drive_manager.cc.

Member Data Documentation

◆ _acceptable_fs_pat

std::regex DriveManager::_acceptable_fs_pat
private

Filters the filesystems reported by UDisks2 to acceptable ones.

Definition at line 75 of file drive_manager.h.

◆ _dispatcher

Glib::Dispatcher DriveManager::_dispatcher
private

Used to samely emit _sig_inserted for the disc drive.

Definition at line 73 of file drive_manager.h.

◆ _drive

CDDrive DriveManager::_drive
private

The disc drive.

Definition at line 66 of file drive_manager.h.

◆ _poller

Poller* DriveManager::_poller
private

When running, checks for the presence of a disc in _drive.

Definition at line 71 of file drive_manager.h.

◆ _removable_fs

UDisks2::Filesystem* DriveManager::_removable_fs
private

The filesystem associated with the iPod.

Definition at line 69 of file drive_manager.h.

◆ _sig_ejected

sig_drive DriveManager::_sig_ejected
private

Emitted when a drive is removed.

Definition at line 64 of file drive_manager.h.

◆ _sig_inserted

sig_drive DriveManager::_sig_inserted
private

Emitted when a drive is inserted.

Definition at line 63 of file drive_manager.h.

◆ _udisks2

UDisks2::Manager DriveManager::_udisks2
private

UDisks2 provides access to removable disks.

Definition at line 68 of file drive_manager.h.


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