-
Notifications
You must be signed in to change notification settings - Fork 345
/
mythhdd.cpp
79 lines (67 loc) · 2.31 KB
/
mythhdd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "mythhdd.h"
#include "mythlogging.h"
/** \fn MythHDD::Get(QObject*, const char*, bool, bool)
* \brief Helper function used to create a new instance
* of a hard disk device.
* \param devicePath path to the device special file
* representing the device.
* \return new MythHDD instance.
*/
MythHDD *MythHDD::Get(QObject* par, const char* devicePath, bool SuperMount,
bool AllowEject)
{
return new MythHDD(par, devicePath, SuperMount, AllowEject);
}
/** \fn MythHDD::MythHDD(QObject *, const char *, bool, bool)
* \brief Creates a new instance of a hard disc device.
* \param DevicePath path to the device special file representing the device.
* \return new MythHDD instance.
*/
MythHDD::MythHDD(QObject *par, const char *DevicePath,
bool SuperMount, bool AllowEject)
: MythMediaDevice(par, DevicePath, SuperMount, AllowEject)
{
LOG(VB_MEDIA, LOG_INFO, "MythHDD::MythHDD " + m_DevicePath);
m_Status = MEDIASTAT_NOTMOUNTED;
m_MediaType = MEDIATYPE_DATA; // default type is data
}
/** \fn MythHDD::checkMedia(void)
* \brief Checks the status of this media device.
*/
MythMediaStatus MythHDD::checkMedia(void)
{
if (m_Status == MEDIASTAT_ERROR)
return m_Status;
if (isMounted())
{
// A lazy way to present volume name for the user to eject.
// Hotplug devices are usually something like /media/VOLUME
m_VolumeID = m_MountPath;
// device is mounted, trigger event
if (m_Status != MEDIASTAT_MOUNTED)
m_Status = MEDIASTAT_NOTMOUNTED;
return setStatus(MEDIASTAT_MOUNTED);
}
// device is not mounted
switch (m_Status)
{
case MEDIASTAT_NOTMOUNTED:
// a removable device was just plugged in try to mount it.
LOG(VB_MEDIA, LOG_INFO, "MythHDD::checkMedia try mounting " + m_DevicePath);
if (mount())
return setStatus(MEDIASTAT_MOUNTED);
return setStatus(MEDIASTAT_ERROR);
case MEDIASTAT_MOUNTED:
// device was mounted and someone unmounted it.
return setStatus(MEDIASTAT_NOTMOUNTED);
default:
// leave device state as is
return m_Status;
}
}
//virtual
MythMediaError MythHDD::eject(bool)
{
setStatus(MEDIASTAT_UNPLUGGED);
return MEDIAERR_UNSUPPORTED;
}