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 char *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
89 {
91  return MEDIAERR_UNSUPPORTED;
92 }
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
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.
Definition: mythmedia.h:159
Definition: mythhdd.h:6
Unable to mount, but could be usable.
Definition: mythmedia.h:13
QString m_DevicePath
The path to this media's device.
Definition: mythmedia.h:149
MythMediaError eject(bool) override
Definition: mythhdd.cpp:88
MythMediaStatus setStatus(MythMediaStatus newStat, bool CloseIt=false)
Definition: mythmedia.cpp:469
MythMediaError
Definition: mythmedia.h:39
MythHDD(QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
Creates a new instance of a hard disc device.
Definition: mythhdd.cpp:30
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
virtual void onDeviceMounted(void)
Override this to perform any post mount logic.
Definition: mythmedia.h:133
MythMediaType m_MediaType
last call to checkMedia. Read only
Definition: mythmedia.h:161
bool isMounted(bool bVerify=true)
Tells us if m_DevicePath is a mounted device.
Definition: mythmedia.cpp:363
MythMediaStatus
Definition: mythmedia.h:12
MythMediaStatus checkMedia(void) override
Checks the status of this media device.
Definition: mythhdd.cpp:42
QString m_MountPath
The path to this media's mount point.
Definition: mythmedia.h:153