MythTV  master
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MediaMonitorUnix Class Reference

#include <mediamonitor-unix.h>

Inheritance diagram for MediaMonitorUnix:
Inheritance graph
[legend]
Collaboration diagram for MediaMonitorUnix:
Collaboration graph
[legend]

Public Member Functions

 MediaMonitorUnix (QObject *par, unsigned long interval, bool allowEject)
 
void deleteLater (void) override
 
- Public Member Functions inherited from MediaMonitor
bool IsActive (void) const
 
virtual void StartMonitoring (void)
 Start the monitoring thread if needed. More...
 
void StopMonitoring (void)
 Stop the monitoring thread if needed. More...
 
void ChooseAndEjectMedia (void)
 Unmounts and ejects removable media devices. More...
 
void EjectMedia (const QString &path)
 
bool ValidateAndLock (MythMediaDevice *pMedia)
 Validates the MythMediaDevice and increments its reference count. More...
 
void Unlock (MythMediaDevice *pMedia)
 decrements the MythMediaDevices reference count More...
 
QList< MythMediaDevice * > GetRemovable (bool showMounted=false, bool showUsable=false)
 Generate a list of removable drives. More...
 
QList< MythMediaDevice * > GetMedias (unsigned mediatypes)
 Ask for available media. More...
 
MythMediaDeviceGetMedia (const QString &path)
 Get media device by pathname. More...
 
void RegisterMediaHandler (const QString &destination, const QString &description, void(*callback)(MythMediaDevice *), int mediaType, const QString &extensions)
 Register a handler for media related events. More...
 
void JumpToMediaHandler (MythMediaDevice *pMedia)
 Find a relevant jump point for this type of media. More...
 

Protected Member Functions

 ~MediaMonitorUnix () override=default
 
void CheckDeviceNotifications (void) override
 Checks the named pipe, kUDEV_FIFO, for hotplug events from the udev system. More...
 
bool CheckFileSystemTable (void)
 
bool CheckMountable (void)
 Search /sys/block for valid removable media devices. More...
 
bool CheckRemovable (const QString &dev)
 Is /sys/block/dev a removable device? More...
 
bool FindPartitions (const QString &dev, bool checkPartitions)
 Creates MythMedia instances for sysfs removable media devices. More...
 
bool AddDevice (MythMediaDevice *pDevice) override
 Given a media device, add it to our collection. More...
 
bool AddDevice (struct fstab *mep)
 
QString GetDeviceFile (const QString &sysfs)
 Returns the device special file associated with the /sys/block node. More...
 
QStringList GetCDROMBlockDevices (void) override
 
- Protected Member Functions inherited from MediaMonitor
 MediaMonitor (QObject *par, unsigned long interval, bool allowEject)
 Lookup some settings, and do OS-specific stuff in sub-classes. More...
 
 ~MediaMonitor () override=default
 
void CheckDevices (void)
 Poll the devices in our list. More...
 
bool RemoveDevice (const QString &dev)
 Remove a device from the media monitor. More...
 
bool shouldIgnore (const MythMediaDevice *device)
 Check user preferences to see if this device should be monitored. More...
 
bool eventFilter (QObject *obj, QEvent *event) override
 Installed into the main window's event chain, so that the main thread can safely jump to plugin code. More...
 
QString listDevices (void)
 A string summarising the current devices, for debugging. More...
 
MythMediaDeviceselectDrivePopup (const QString &label, bool showMounted=false, bool showUsable=false)
 List removable drives, let the user select one. More...
 

Protected Attributes

int m_fifo {-1}
 
- Protected Attributes inherited from MediaMonitor
QMutex m_DevicesLock
 
QList< MythMediaDevice * > m_Devices
 
QList< MythMediaDevice * > m_RemovedDevices
 
QMap< MythMediaDevice *, int > m_UseCount
 
QStringList m_IgnoreList
 
bool volatile m_Active {false}
 Was MonitorThread started? More...
 
QWaitCondition m_wait
 
MonitorThreadm_Thread {nullptr}
 
unsigned long m_MonitorPollingInterval
 
bool m_AllowEject
 
QMap< QString, MHDatam_handlerMap
 Registered Media Handlers. More...
 

Static Protected Attributes

static const char * kUDEV_FIFO = "/tmp/mythtv_media"
 
- Static Protected Attributes inherited from MediaMonitor
static MediaMonitors_monitor = nullptr
 

Additional Inherited Members

- Public Slots inherited from MediaMonitor
void mediaStatusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia)
 Slot which is called when the device status changes and posts a media event to the mainwindow. More...
 
- Static Public Member Functions inherited from MediaMonitor
static MediaMonitorGetMediaMonitor (void)
 
static QString GetMountPath (const QString &devPath)
 If the device is being monitored, return its mountpoint. More...
 
static void SetCDSpeed (const char *device, int speed)
 
static QString defaultCDdevice ()
 CDDevice, user-selected drive, or /dev/cdrom. More...
 
static QString defaultVCDdevice ()
 VCDDeviceLocation, user-selected drive, or /dev/cdrom. More...
 
static QString defaultDVDdevice ()
 DVDDeviceLocation, user-selected drive, or /dev/dvd. More...
 
static QString defaultCDWriter ()
 CDWriterDeviceLocation, user-selected drive, or /dev/cdrom. More...
 
static QString defaultDVDWriter ()
 MythArchiveDVDLocation, user-selected drive, or /dev/dvd. More...
 
static void ejectOpticalDisc (void)
 Eject a disk, unmount a drive, open a tray. More...
 
- Static Protected Member Functions inherited from MediaMonitor
static void AttemptEject (MythMediaDevice *device)
 
static QString defaultDevice (const QString &setting, const QString &label, const char *hardCodedDefault)
 

Detailed Description

Definition at line 16 of file mediamonitor-unix.h.

Constructor & Destructor Documentation

◆ MediaMonitorUnix()

MediaMonitorUnix::MediaMonitorUnix ( QObject *  par,
unsigned long  interval,
bool  allowEject 
)

Definition at line 117 of file mediamonitor-unix.cpp.

◆ ~MediaMonitorUnix()

MediaMonitorUnix::~MediaMonitorUnix ( )
overrideprotecteddefault

Member Function Documentation

◆ deleteLater()

void MediaMonitorUnix::deleteLater ( void  )
overridevirtual

Reimplemented from MediaMonitor.

Definition at line 129 of file mediamonitor-unix.cpp.

◆ CheckDeviceNotifications()

void MediaMonitorUnix::CheckDeviceNotifications ( void  )
overrideprotectedvirtual

Checks the named pipe, kUDEV_FIFO, for hotplug events from the udev system.

NOTE: Currently only Linux w/udev 0.71+ provides these events.

Reimplemented from MediaMonitor.

Definition at line 842 of file mediamonitor-unix.cpp.

◆ CheckFileSystemTable()

bool MediaMonitorUnix::CheckFileSystemTable ( void  )
protected

Definition at line 143 of file mediamonitor-unix.cpp.

Referenced by MediaMonitorUnix().

◆ CheckMountable()

bool MediaMonitorUnix::CheckMountable ( void  )
protected

Search /sys/block for valid removable media devices.

This function creates MediaDevice instances for valid removable media devices found under the /sys/block filesystem in Linux. CD and DVD devices are created as MythCDROM instances. MythHDD instances will be created for each partition on removable hard disk devices, if they exist. Otherwise a single MythHDD instance will be created for the entire disc.

NOTE: Floppy disks are ignored.

Definition at line 193 of file mediamonitor-unix.cpp.

Referenced by MediaMonitorUnix().

◆ CheckRemovable()

bool MediaMonitorUnix::CheckRemovable ( const QString &  dev)
protected

Is /sys/block/dev a removable device?

Definition at line 300 of file mediamonitor-unix.cpp.

Referenced by CheckDeviceNotifications(), and CheckMountable().

◆ FindPartitions()

bool MediaMonitorUnix::FindPartitions ( const QString &  dev,
bool  checkPartitions 
)
protected

Creates MythMedia instances for sysfs removable media devices.

Block devices are represented as directories in sysfs with directories for each partition underneath the parent device directory.

This function recursively calls itself to find all partitions on a block device and creates a MythHDD instance for each partition found. If no partitions are found and the device is a CD or DVD device a MythCDROM instance is created. Otherwise a MythHDD instance is created for the entire block device.

Parameters
devpath to sysfs block device.
checkPartitionscheck for partitions on block device.
Returns
true if MythMedia instances are created.

Definition at line 774 of file mediamonitor-unix.cpp.

Referenced by CheckDeviceNotifications(), and CheckMountable().

◆ AddDevice() [1/2]

bool MediaMonitorUnix::AddDevice ( MythMediaDevice pDevice)
overrideprotectedvirtual

Given a media device, add it to our collection.

Implements MediaMonitor.

Definition at line 556 of file mediamonitor-unix.cpp.

Referenced by AddDevice(), CheckFileSystemTable(), CheckMountable(), and FindPartitions().

◆ AddDevice() [2/2]

bool MediaMonitorUnix::AddDevice ( struct fstab *  mep)
protected

Definition at line 620 of file mediamonitor-unix.cpp.

◆ GetDeviceFile()

QString MediaMonitorUnix::GetDeviceFile ( const QString &  sysfs)
protected

Returns the device special file associated with the /sys/block node.

Parameters
sysfssystem filesystem path of removable block device.
Returns
path to the device special file

Definition at line 334 of file mediamonitor-unix.cpp.

Referenced by FindPartitions().

◆ GetCDROMBlockDevices()

QStringList MediaMonitorUnix::GetCDROMBlockDevices ( void  )
overrideprotectedvirtual

Implements MediaMonitor.

Definition at line 426 of file mediamonitor-unix.cpp.

Referenced by FindPartitions().

Member Data Documentation

◆ m_fifo

int MediaMonitorUnix::m_fifo {-1}
protected

Definition at line 54 of file mediamonitor-unix.h.

Referenced by CheckDeviceNotifications(), CheckMountable(), and deleteLater().

◆ kUDEV_FIFO

const char * MediaMonitorUnix::kUDEV_FIFO = "/tmp/mythtv_media"
staticprotected

Definition at line 55 of file mediamonitor-unix.h.

Referenced by CheckMountable(), and deleteLater().


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