MythTV  master
Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
MythMediaDevice Class Referenceabstract

#include <mythmedia.h>

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

Signals

void statusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia)
 

Public Member Functions

 MythMediaDevice (QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
 
const QString & getMountPath () const
 
void setMountPath (const char *path)
 
const QString & getDevicePath () const
 
const QString & getRealDevice () const
 
const QString & getDeviceModel () const
 
void setDeviceModel (const char *model)
 
MythMediaStatus getStatus () const
 
const QString & getVolumeID () const
 
void setVolumeID (const char *vol)
 
const QString & getKeyID () const
 
bool getAllowEject () const
 
bool getLocked () const
 
bool isDeviceOpen () const
 
bool isUsable () const
 Is this device "ready", for a plugin to access? More...
 
MythMediaType getMediaType () const
 
bool isSuperMount () const
 
virtual MythMediaError testMedia ()
 
virtual bool openDevice ()
 
virtual bool closeDevice ()
 
virtual bool isSameDevice (const QString &path)
 
virtual void setSpeed (int speed)
 
virtual void setDeviceSpeed (const char *, int)
 
virtual MythMediaStatus checkMedia ()=0
 
virtual MythMediaError eject (bool open_close=true)
 
virtual MythMediaError lock ()
 
virtual MythMediaError unlock ()
 
virtual bool performMountCmd (bool DoMount)
 
bool mount ()
 
bool unmount ()
 
bool isMounted (bool bVerify=true)
 Tells us if m_DevicePath is a mounted device. More...
 
bool findMountPath ()
 Try to find a mount of m_DevicePath in the mounts file. More...
 
void clearData ()
 
QString MediaTypeString ()
 

Static Public Member Functions

static void RegisterMediaExtensions (uint mediatype, const QString &extensions)
 Used to register media types with extensions. More...
 
static QString MediaTypeString (uint type)
 

Static Public Attributes

static const char * MediaStatusStrings []
 
static const char * MediaErrorStrings []
 

Protected Member Functions

virtual ~MythMediaDevice ()
 
virtual void onDeviceMounted (void)
 Override this to perform any post mount logic. More...
 
virtual void onDeviceUnmounted ()
 Override this to perform any post unmount logic. More...
 
MythMediaType DetectMediaType (void)
 Returns guessed media type based on file extensions. More...
 
bool ScanMediaType (const QString &directory, ext_cnt_t &counts)
 Recursively scan directories and create an associative array with the number of times we've seen each extension. More...
 
MythMediaStatus setStatus (MythMediaStatus newStat, bool CloseIt=false)
 

Protected Attributes

QString m_DeviceModel
 The device Manufacturer/Model. Read/write. More...
 
QString m_DevicePath
 The path to this media's device. More...
 
QString m_KeyID
 KeyID of the media. More...
 
QString m_MountPath
 The path to this media's mount point. More...
 
QString m_RealDevice
 If m_DevicePath is a symlink, its target. More...
 
QString m_VolumeID
 The volume ID of the media. Read/write. More...
 
MythMediaStatus m_Status
 The status of the media as of the. More...
 
MythMediaType m_MediaType
 last call to checkMedia. Read only More...
 
bool m_AllowEject
 Allow the user to eject the media?. Read only. More...
 
bool m_Locked
 Is this media locked?. Read only. More...
 
bool m_SuperMount
 Is this a supermount device?. Read only. More...
 
int m_DeviceHandle
 A file handle for opening and closing the device, ioctls(), et c. More...
 

Static Private Attributes

static ext_to_media_t s_ext_to_media
 Map of extension to media type. More...
 

Friends

class MediaMonitorDarwin
 
class MonitorThreadDarwin
 

Detailed Description

Definition at line 48 of file mythmedia.h.

Constructor & Destructor Documentation

◆ MythMediaDevice()

MythMediaDevice::MythMediaDevice ( QObject *  par,
const char *  DevicePath,
bool  SuperMount,
bool  AllowEject 
)

Definition at line 69 of file mythmedia.cpp.

◆ ~MythMediaDevice()

virtual MythMediaDevice::~MythMediaDevice ( )
inlineprotectedvirtual

Definition at line 130 of file mythmedia.h.

Member Function Documentation

◆ getMountPath()

const QString& MythMediaDevice::getMountPath ( ) const
inline

◆ setMountPath()

void MythMediaDevice::setMountPath ( const char *  path)
inline

◆ getDevicePath()

const QString& MythMediaDevice::getDevicePath ( ) const
inline

◆ getRealDevice()

const QString& MythMediaDevice::getRealDevice ( ) const
inline

Definition at line 63 of file mythmedia.h.

Referenced by LookupModel(), and MediaMonitor::shouldIgnore().

◆ getDeviceModel()

const QString& MythMediaDevice::getDeviceModel ( ) const
inline

Definition at line 67 of file mythmedia.h.

Referenced by ImageManagerFe::DetectLocalDevices(), and ImageManagerFe::DeviceEvent().

◆ setDeviceModel()

void MythMediaDevice::setDeviceModel ( const char *  model)
inline

◆ getStatus()

MythMediaStatus MythMediaDevice::getStatus ( ) const
inline

◆ getVolumeID()

const QString& MythMediaDevice::getVolumeID ( ) const
inline

Definition at line 72 of file mythmedia.h.

Referenced by ImageManagerFe::DeviceEvent(), and handleMedia().

◆ setVolumeID()

void MythMediaDevice::setVolumeID ( const char *  vol)
inline

◆ getKeyID()

const QString& MythMediaDevice::getKeyID ( ) const
inline

Definition at line 75 of file mythmedia.h.

◆ getAllowEject()

bool MythMediaDevice::getAllowEject ( ) const
inline

Definition at line 77 of file mythmedia.h.

◆ getLocked()

bool MythMediaDevice::getLocked ( ) const
inline

Definition at line 79 of file mythmedia.h.

◆ isDeviceOpen()

bool MythMediaDevice::isDeviceOpen ( ) const

◆ isUsable()

bool MythMediaDevice::isUsable ( ) const
inline

Is this device "ready", for a plugin to access?

Definition at line 84 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), ImageManagerFe::DetectLocalDevices(), MediaMonitor::eventFilter(), handleCDMedia(), handleDVDMedia(), and handleMedia().

◆ getMediaType()

MythMediaType MythMediaDevice::getMediaType ( ) const
inline

◆ isSuperMount()

bool MythMediaDevice::isSuperMount ( ) const
inline

Definition at line 93 of file mythmedia.h.

◆ testMedia()

virtual MythMediaError MythMediaDevice::testMedia ( void  )
inlinevirtual

Reimplemented in MythCDROMLinux, and MythCDROMFreeBSD.

Definition at line 95 of file mythmedia.h.

Referenced by MediaMonitorUnix::AddDevice().

◆ openDevice()

bool MythMediaDevice::openDevice ( )
virtual

◆ closeDevice()

bool MythMediaDevice::closeDevice ( )
virtual

◆ isSameDevice()

bool MythMediaDevice::isSameDevice ( const QString &  path)
virtual

Reimplemented in MythCDROMLinux.

Definition at line 326 of file mythmedia.cpp.

◆ setSpeed()

void MythMediaDevice::setSpeed ( int  speed)
virtual

Definition at line 337 of file mythmedia.cpp.

Referenced by MediaMonitor::SetCDSpeed().

◆ setDeviceSpeed()

virtual void MythMediaDevice::setDeviceSpeed ( const char *  ,
int   
)
inlinevirtual

Reimplemented in MythCDROMLinux, MythCDROMDarwin, and MythCDROM.

Definition at line 100 of file mythmedia.h.

Referenced by setSpeed().

◆ checkMedia()

virtual MythMediaStatus MythMediaDevice::checkMedia ( )
pure virtual

Implemented in MythCDROMLinux, MythCDROM, and MythHDD.

Referenced by MediaMonitor::CheckDevices().

◆ eject()

MythMediaError MythMediaDevice::eject ( bool  open_close = true)
virtual

Reimplemented in MythCDROMLinux, MythCDROMFreeBSD, and MythHDD.

Definition at line 312 of file mythmedia.cpp.

Referenced by MediaMonitor::AttemptEject(), and Ripper::ejectCD().

◆ lock()

MythMediaError MythMediaDevice::lock ( void  )
virtual

Reimplemented in MythCDROMLinux, and MythCDROMFreeBSD.

Definition at line 342 of file mythmedia.cpp.

Referenced by MythCDROMFreeBSD::lock(), and MythCDROMLinux::lock().

◆ unlock()

MythMediaError MythMediaDevice::unlock ( void  )
virtual

◆ performMountCmd()

bool MythMediaDevice::performMountCmd ( bool  DoMount)
virtual

Definition at line 112 of file mythmedia.cpp.

◆ mount()

bool MythMediaDevice::mount ( )
inline

◆ unmount()

bool MythMediaDevice::unmount ( )
inline

Definition at line 108 of file mythmedia.h.

Referenced by MediaMonitor::AttemptEject(), MythCDROM::onDeviceMounted(), and setStatus().

◆ isMounted()

bool MythMediaDevice::isMounted ( bool  bVerify = true)

◆ findMountPath()

bool MythMediaDevice::findMountPath ( )

Try to find a mount of m_DevicePath in the mounts file.

Definition at line 372 of file mythmedia.cpp.

Referenced by MediaMonitor::GetMountPath(), isMounted(), and performMountCmd().

◆ RegisterMediaExtensions()

void MythMediaDevice::RegisterMediaExtensions ( uint  mediatype,
const QString &  extensions 
)
static

Used to register media types with extensions.

Parameters
mediatypeMythMediaType flag.
extensionsComma separated list of extensions like 'mp3,ogg,flac'.

Definition at line 304 of file mythmedia.cpp.

Referenced by MediaMonitor::RegisterMediaHandler().

◆ clearData()

void MythMediaDevice::clearData ( )

Definition at line 515 of file mythmedia.cpp.

Referenced by MythHDD::checkMedia(), and MediaMonitor::mediaStatusChanged().

◆ MediaTypeString() [1/2]

QString MythMediaDevice::MediaTypeString ( )

◆ MediaTypeString() [2/2]

QString MythMediaDevice::MediaTypeString ( uint  type)
static

Definition at line 527 of file mythmedia.cpp.

◆ statusChanged

void MythMediaDevice::statusChanged ( MythMediaStatus  oldStatus,
MythMediaDevice pMedia 
)
signal

Referenced by setStatus().

◆ onDeviceMounted()

virtual void MythMediaDevice::onDeviceMounted ( void  )
inlineprotectedvirtual

Override this to perform any post mount logic.

Reimplemented in MythCDROM.

Definition at line 133 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), MythCDROM::onDeviceMounted(), and performMountCmd().

◆ onDeviceUnmounted()

virtual void MythMediaDevice::onDeviceUnmounted ( )
inlineprotectedvirtual

Override this to perform any post unmount logic.

Definition at line 141 of file mythmedia.h.

Referenced by performMountCmd().

◆ DetectMediaType()

MythMediaType MythMediaDevice::DetectMediaType ( void  )
protected

Returns guessed media type based on file extensions.

Definition at line 212 of file mythmedia.cpp.

◆ ScanMediaType()

bool MythMediaDevice::ScanMediaType ( const QString &  directory,
ext_cnt_t counts 
)
protected

Recursively scan directories and create an associative array with the number of times we've seen each extension.

Definition at line 265 of file mythmedia.cpp.

Referenced by DetectMediaType().

◆ setStatus()

MythMediaStatus MythMediaDevice::setStatus ( MythMediaStatus  newStat,
bool  CloseIt = false 
)
protected

Friends And Related Function Documentation

◆ MediaMonitorDarwin

friend class MediaMonitorDarwin
friend

Definition at line 51 of file mythmedia.h.

◆ MonitorThreadDarwin

friend class MonitorThreadDarwin
friend

Definition at line 52 of file mythmedia.h.

Member Data Documentation

◆ MediaStatusStrings

const char * MythMediaDevice::MediaStatusStrings
static
Initial value:
=
{
"MEDIASTAT_ERROR",
"MEDIASTAT_UNKNOWN",
"MEDIASTAT_UNPLUGGED",
"MEDIASTAT_OPEN",
"MEDIASTAT_NODISK",
"MEDIASTAT_UNFORMATTED",
"MEDIASTAT_USEABLE",
"MEDIASTAT_NOTMOUNTED",
"MEDIASTAT_MOUNTED"
}

Definition at line 117 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), MediaMonitor::mediaStatusChanged(), and setStatus().

◆ MediaErrorStrings

const char * MythMediaDevice::MediaErrorStrings
static
Initial value:
=
{
"MEDIAERR_OK",
"MEDIAERR_FAILED",
"MEDIAERR_UNSUPPORTED"
}

Definition at line 118 of file mythmedia.h.

◆ m_DeviceModel

QString MythMediaDevice::m_DeviceModel
protected

The device Manufacturer/Model. Read/write.

Definition at line 148 of file mythmedia.h.

◆ m_DevicePath

QString MythMediaDevice::m_DevicePath
protected

◆ m_KeyID

QString MythMediaDevice::m_KeyID
protected

KeyID of the media.

Read only (For ISO9660, volumeid + creation_date)

Definition at line 151 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), and clearData().

◆ m_MountPath

QString MythMediaDevice::m_MountPath
protected

The path to this media's mount point.

(e.g. /mnt/cdrom) Read/write

Definition at line 153 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), DetectMediaType(), findMountPath(), and MythCDROM::onDeviceMounted().

◆ m_RealDevice

QString MythMediaDevice::m_RealDevice
protected

If m_DevicePath is a symlink, its target.

(e.g. /dev/hdc) Read only

Definition at line 155 of file mythmedia.h.

Referenced by findMountPath(), and MythMediaDevice().

◆ m_VolumeID

QString MythMediaDevice::m_VolumeID
protected

The volume ID of the media. Read/write.

Definition at line 157 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), MythCDROMLinux::checkMedia(), and clearData().

◆ m_Status

MythMediaStatus MythMediaDevice::m_Status
protected

◆ m_MediaType

MythMediaType MythMediaDevice::m_MediaType
protected

last call to checkMedia. Read only

The type of media. Read only

Definition at line 161 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), clearData(), MediaTypeString(), MythHDD::MythHDD(), MythMediaDevice(), and MythCDROM::onDeviceMounted().

◆ m_AllowEject

bool MythMediaDevice::m_AllowEject
protected

Allow the user to eject the media?. Read only.

Definition at line 163 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), MythMediaDevice(), and MythCDROM::onDeviceMounted().

◆ m_Locked

bool MythMediaDevice::m_Locked
protected

Is this media locked?. Read only.

Definition at line 164 of file mythmedia.h.

Referenced by lock(), MythMediaDevice(), and unlock().

◆ m_SuperMount

bool MythMediaDevice::m_SuperMount
protected

Is this a supermount device?. Read only.

Definition at line 165 of file mythmedia.h.

Referenced by MythMediaDevice(), and performMountCmd().

◆ m_DeviceHandle

int MythMediaDevice::m_DeviceHandle
protected

◆ s_ext_to_media

ext_to_media_t MythMediaDevice::s_ext_to_media
staticprivate

Map of extension to media type.

Definition at line 172 of file mythmedia.h.

Referenced by DetectMediaType(), and RegisterMediaExtensions().


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