MythTV master
mythhdd.cpp
Go to the documentation of this file.
1#include "mythhdd.h"
2#include "mythlogging.h"
3
15MythHDD *MythHDD::Get(QObject* par, const char* devicePath, bool SuperMount,
16 bool AllowEject)
17{
18 return new MythHDD(par, devicePath, SuperMount, AllowEject);
19}
20
30MythHDD::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 " +
70
71 if (mount())
73
75
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
88MythMediaError MythHDD::eject(bool /*open_close*/)
89{
92}
Definition: mythhdd.h:7
MythHDD(QObject *par, const QString &DevicePath, bool SuperMount, bool AllowEject)
Creates a new instance of a hard disc device.
Definition: mythhdd.cpp:30
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
MythMediaStatus checkMedia(void) override
Checks the status of this media device.
Definition: mythhdd.cpp:42
MythMediaError eject(bool) override
Definition: mythhdd.cpp:88
MythMediaStatus setStatus(MythMediaStatus newStat, bool CloseIt=false)
Definition: mythmedia.cpp:465
virtual void onDeviceMounted(void)
Override this to perform any post mount logic.
Definition: mythmedia.h:133
QString m_mountPath
The path to this media's mount point.
Definition: mythmedia.h:153
MythMediaType m_mediaType
The type of media. Read only.
Definition: mythmedia.h:162
QString m_devicePath
The path to this media's device.
Definition: mythmedia.h:149
QString m_volumeID
The volume ID of the media. Read/write.
Definition: mythmedia.h:157
MythMediaStatus m_status
The status of the media as of the last call to checkMedia.
Definition: mythmedia.h:159
bool isMounted(bool bVerify=true)
Tells us if m_devicePath is a mounted device.
Definition: mythmedia.cpp:360
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
@ MEDIATYPE_UNKNOWN
Definition: mythmedia.h:25
MythMediaError
Definition: mythmedia.h:39
@ MEDIAERR_UNSUPPORTED
Definition: mythmedia.h:42
MythMediaStatus
Definition: mythmedia.h:12
@ MEDIASTAT_UNPLUGGED
Definition: mythmedia.h:15
@ MEDIASTAT_NOTMOUNTED
Definition: mythmedia.h:20
@ MEDIASTAT_MOUNTED
Definition: mythmedia.h:21
@ MEDIASTAT_ERROR
Unable to mount, but could be usable.
Definition: mythmedia.h:13