MythTV  master
mythhdd.cpp
Go to the documentation of this file.
1 #include "mythhdd.h"
2 #include "mythlogging.h"
3 
15 MythHDD *MythHDD::Get(QObject* par, const char* devicePath, bool SuperMount,
16  bool AllowEject)
17 {
18  return new MythHDD(par, devicePath, SuperMount, AllowEject);
19 }
20 
30 MythHDD::MythHDD(QObject *par, const QString& DevicePath,
31  bool SuperMount, bool AllowEject)
32  : MythMediaDevice(par, DevicePath, SuperMount, AllowEject)
33 {
34  LOG(VB_MEDIA, LOG_INFO, "MythHDD::MythHDD " + m_devicePath);
37 }
38 
43 {
45  return m_status;
46 
47  if (isMounted())
48  {
49  // A lazy way to present volume name for the user to eject.
50  // Hotplug devices are usually something like /media/VOLUME
52 
53  // device is mounted, trigger event
55  {
58  }
59 
61  }
62 
63  // device is not mounted
64  switch (m_status)
65  {
67  // a removable device was just plugged in try to mount it.
68  LOG(VB_MEDIA, LOG_INFO, "MythHDD::checkMedia try mounting " +
69  m_devicePath);
70 
71  if (mount())
73 
74  return setStatus(MEDIASTAT_ERROR);
75 
76  case MEDIASTAT_MOUNTED:
77  // device was mounted and someone unmounted it.
78  clearData();
80 
81  default:
82  // leave device state as is
83  return m_status;
84  }
85 }
86 
87 //virtual
88 MythMediaError MythHDD::eject(bool /*open_close*/)
89 {
91  return MEDIAERR_UNSUPPORTED;
92 }
MEDIASTAT_ERROR
@ MEDIASTAT_ERROR
Unable to mount, but could be usable.
Definition: mythmedia.h:13
MythMediaDevice::mount
bool mount()
Definition: mythmedia.h:107
MEDIATYPE_UNKNOWN
@ MEDIATYPE_UNKNOWN
Definition: mythmedia.h:25
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythHDD::checkMedia
MythMediaStatus checkMedia(void) override
Checks the status of this media device.
Definition: mythhdd.cpp:42
MEDIASTAT_UNPLUGGED
@ MEDIASTAT_UNPLUGGED
Definition: mythmedia.h:15
MythMediaDevice::isMounted
bool isMounted(bool bVerify=true)
Tells us if m_devicePath is a mounted device.
Definition: mythmedia.cpp:360
mythlogging.h
MEDIAERR_UNSUPPORTED
@ MEDIAERR_UNSUPPORTED
Definition: mythmedia.h:42
MythMediaDevice::clearData
void clearData()
Definition: mythmedia.cpp:511
MythMediaStatus
MythMediaStatus
Definition: mythmedia.h:12
MythMediaDevice::onDeviceMounted
virtual void onDeviceMounted(void)
Override this to perform any post mount logic.
Definition: mythmedia.h:133
MythHDD::Get
static MythHDD * Get(QObject *par, const char *devicePath, bool SuperMount, bool AllowEject)
Helper function used to create a new instance of a hard disk device.
Definition: mythhdd.cpp:15
MEDIASTAT_MOUNTED
@ MEDIASTAT_MOUNTED
Definition: mythmedia.h:21
MythMediaDevice::setStatus
MythMediaStatus setStatus(MythMediaStatus newStat, bool CloseIt=false)
Definition: mythmedia.cpp:465
MythMediaDevice::m_mountPath
QString m_mountPath
The path to this media's mount point.
Definition: mythmedia.h:153
MythMediaDevice::m_devicePath
QString m_devicePath
The path to this media's device.
Definition: mythmedia.h:149
MythHDD::MythHDD
MythHDD(QObject *par, const QString &DevicePath, bool SuperMount, bool AllowEject)
Creates a new instance of a hard disc device.
Definition: mythhdd.cpp:30
MythMediaError
MythMediaError
Definition: mythmedia.h:39
MythMediaDevice
Definition: mythmedia.h:48
MythMediaDevice::m_status
MythMediaStatus m_status
The status of the media as of the last call to checkMedia.
Definition: mythmedia.h:159
MythHDD::eject
MythMediaError eject(bool) override
Definition: mythhdd.cpp:88
MythMediaDevice::m_mediaType
MythMediaType m_mediaType
The type of media. Read only.
Definition: mythmedia.h:162
MythHDD
Definition: mythhdd.h:6
MEDIASTAT_NOTMOUNTED
@ MEDIASTAT_NOTMOUNTED
Definition: mythmedia.h:20
MythMediaDevice::m_volumeID
QString m_volumeID
The volume ID of the media. Read/write.
Definition: mythmedia.h:157
mythhdd.h