MythTV  master
mythmedia.cpp
Go to the documentation of this file.
1 // C header
2 #include <fcntl.h>
3 #include <unistd.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <sys/param.h>
7 
8 // Qt Headers
9 #include <QDir>
10 #include <QFileInfo>
11 #include <QFileInfoList>
12 #include <QTextStream>
13 
14 // MythTV headers
15 #include "mythmedia.h"
16 #include "mythconfig.h"
17 #include "mythlogging.h"
18 #include "mythmiscutil.h"
19 #include "mythsystemlegacy.h"
20 #include "exitcodes.h"
21 
22 using namespace std;
23 
24 #ifdef _WIN32
25 # define O_NONBLOCK 0
26 #endif
27 
28 #define LOC QString("MythMediaDevice:")
29 
30 static const QString PATHTO_PMOUNT("/usr/bin/pmount");
31 static const QString PATHTO_PUMOUNT("/usr/bin/pumount");
32 #if CONFIG_DARWIN
33  static const QString PATHTO_MOUNT("/sbin/mount");
34 #else
35  static const QString PATHTO_MOUNT("/bin/mount");
36 #endif
37 static const QString PATHTO_UNMOUNT("/bin/umount");
38 static const QString PATHTO_MOUNTS("/proc/mounts");
39 
40 #if CONFIG_DARWIN
41 # define USE_MOUNT_COMMAND
42 #endif
43 
44 const std::array<const QString,9> MythMediaDevice::MediaStatusStrings
45 {
46  "MEDIASTAT_ERROR",
47  "MEDIASTAT_UNKNOWN",
48  "MEDIASTAT_UNPLUGGED",
49  "MEDIASTAT_OPEN",
50  "MEDIASTAT_NODISK",
51  "MEDIASTAT_UNFORMATTED",
52  "MEDIASTAT_USEABLE",
53  "MEDIASTAT_NOTMOUNTED",
54  "MEDIASTAT_MOUNTED"
55 };
56 
57 const std::array<const QString,3> MythMediaDevice::MediaErrorStrings
58 {
59  "MEDIAERR_OK",
60  "MEDIAERR_FAILED",
61  "MEDIAERR_UNSUPPORTED"
62 };
63 
64 QEvent::Type MythMediaEvent::kEventType =
65  (QEvent::Type) QEvent::registerEventType();
66 
67 // Force this class to have a vtable so that dynamic_cast works.
68 // NOLINTNEXTLINE(modernize-use-equals-default)
70 {
71 }
72 
74 
75 MythMediaDevice::MythMediaDevice(QObject* par, const char* DevicePath,
76  bool SuperMount, bool AllowEject)
77  : QObject(par), m_DevicePath(DevicePath),
78  m_AllowEject(AllowEject), m_SuperMount(SuperMount)
79 {
81 }
82 
84 {
85  // Sanity check
86  if (isDeviceOpen())
87  return true;
88 
89  QByteArray dev = m_DevicePath.toLocal8Bit();
90  m_DeviceHandle = open(dev.constData(), O_RDONLY | O_NONBLOCK);
91 
92  return isDeviceOpen();
93 }
94 
96 {
97  // Sanity check
98  if (!isDeviceOpen())
99  return true;
100 
101  int ret = close(m_DeviceHandle);
102  m_DeviceHandle = -1;
103 
104  return ret != -1;
105 }
106 
108 {
109  return m_DeviceHandle >= 0;
110 }
111 
113 {
114  if (DoMount && isMounted())
115  {
116 #ifdef Q_OS_MAC
117  // Not an error - DiskArbitration has already mounted the device.
118  // AddDevice calls mount() so onDeviceMounted() can get mediaType.
119  onDeviceMounted();
120 #else
121  LOG(VB_MEDIA, LOG_ERR, "MythMediaDevice::performMountCmd(true)"
122  " - Logic Error? Device already mounted.");
123  return true;
124 #endif
125  }
126 
127  if (isDeviceOpen())
128  closeDevice();
129 
130  if (!m_SuperMount)
131  {
132  QString MountCommand;
133 
134  // Build a command line for mount/unmount and execute it...
135  // Is there a better way to do this?
136  if (QFile(PATHTO_PMOUNT).exists() && QFile(PATHTO_PUMOUNT).exists())
137  {
138  MountCommand = QString("%1 %2")
139  .arg((DoMount) ? PATHTO_PMOUNT : PATHTO_PUMOUNT)
140  .arg(m_DevicePath);
141  }
142  else
143  {
144  MountCommand = QString("%1 %2")
145  .arg((DoMount) ? PATHTO_MOUNT : PATHTO_UNMOUNT)
146  .arg(m_DevicePath);
147  }
148 
149  LOG(VB_MEDIA, LOG_INFO, QString("Executing '%1'").arg(MountCommand));
150  int ret = myth_system(MountCommand, kMSDontBlockInputDevs);
151  if (ret != GENERIC_EXIT_OK)
152  {
153  usleep(300000);
154  LOG(VB_MEDIA, LOG_INFO, QString("Retrying '%1'").arg(MountCommand));
155  ret = myth_system(MountCommand, kMSDontBlockInputDevs);
156  }
157  if (ret == GENERIC_EXIT_OK)
158  {
159  if (DoMount)
160  {
161  // we cannot tell beforehand what the pmount mount point is
162  // so verify the mount status of the device
163  // In the case that m_DevicePath is a symlink to a device
164  // in /etc/fstab then pmount delegates to mount which
165  // performs the mount asynchronously so we must wait a bit
166  usleep(1000000-1);
167  for (int tries = 2; !findMountPath() && tries > 0; --tries)
168  {
169  LOG(VB_MEDIA, LOG_INFO,
170  QString("Repeating '%1'").arg(MountCommand));
171  myth_system(MountCommand, kMSDontBlockInputDevs);
172  usleep(500000);
173  }
174  if (!findMountPath())
175  {
176  LOG(VB_MEDIA, LOG_ERR, "performMountCmd() attempted to"
177  " find mounted media, but failed?");
178  return false;
179  }
180  onDeviceMounted(); // Identify disk type & content
181  LOG(VB_GENERAL, LOG_INFO,
182  QString("Detected MediaType ") + MediaTypeString());
183  }
184  else
186 
187  return true;
188  }
189  LOG(VB_GENERAL, LOG_ERR, QString("Failed to %1 %2.")
190  .arg(DoMount ? "mount" : "unmount").arg(m_DevicePath));
191  }
192  else
193  {
194  LOG(VB_MEDIA, LOG_INFO, "Disk inserted on a supermount device");
195  // If it's a super mount then the OS will handle mounting / unmounting.
196  // We just need to give derived classes a chance to perform their
197  // mount / unmount logic.
198  if (DoMount)
199  {
200  onDeviceMounted();
201  LOG(VB_GENERAL, LOG_INFO,
202  QString("Detected MediaType ") + MediaTypeString());
203  }
204  else
206 
207  return true;
208  }
209  return false;
210 }
211 
216 {
217  ext_cnt_t ext_cnt;
218 
219  if (!ScanMediaType(m_MountPath, ext_cnt))
220  {
221  LOG(VB_MEDIA, LOG_NOTICE,
222  QString("No files with extensions found in '%1'")
223  .arg(m_MountPath));
224  return MEDIATYPE_UNKNOWN;
225  }
226 
227  QMap<uint, uint> media_cnts;
228 
229  // convert raw counts to composite mediatype counts
230  ext_cnt_t::const_iterator it = ext_cnt.begin();
231  for (; it != ext_cnt.end(); ++it)
232  {
233  ext_to_media_t::const_iterator found = s_ext_to_media.find(it.key());
234  if (found != s_ext_to_media.end())
235  {
236  LOG(VB_MEDIA, LOG_INFO, QString("DetectMediaType %1 (%2)")
237  .arg(MediaTypeString(found.value())).arg(it.key()));
238  media_cnts[*found] += *it;
239  }
240  else
241  {
242  LOG(VB_MEDIA, LOG_NOTICE, QString(
243  "DetectMediaType(this=0x%1) unknown file type %1")
244  .arg(quintptr(this),0,16).arg(it.key()));
245  }
246  }
247 
248  // break composite mediatypes into constituent components
249  uint mediatype = 0;
250 
251  QMap<uint, uint>::const_iterator cit = media_cnts.begin();
252  for (; cit != media_cnts.end(); ++cit)
253  {
254  for (uint key = 1; key != MEDIATYPE_END; key <<= 1)
255  {
256  if (key & cit.key())
257  mediatype |= key;
258  }
259  }
260 
262 }
263 
268 bool MythMediaDevice::ScanMediaType(const QString &directory, ext_cnt_t &cnt)
269 {
270  QDir d(directory);
271  if (!d.exists())
272  return false;
273 
274  d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
275  for (const auto& fi : d.entryInfoList())
276  {
277  if (fi.isSymLink())
278  continue;
279 
280  if (fi.isDir())
281  {
282  ScanMediaType(fi.absoluteFilePath(), cnt);
283  continue;
284  }
285 
286  const QString ext = fi.suffix();
287  if (!ext.isEmpty())
288  cnt[ext.toLower()]++;
289  }
290 
291  return !cnt.empty();
292 }
293 
300 // static
302  const QString &extensions)
303 {
304  for (const auto& ext : extensions.split(","))
305  s_ext_to_media[ext] |= mediatype;
306 }
307 
309 {
310  (void) open_close;
311 
312 #if CONFIG_DARWIN
313  QString command = "diskutil eject " + m_DevicePath;
314 
315  myth_system(command, kMSRunBackground);
316  return MEDIAERR_OK;
317 #endif
318 
319  return MEDIAERR_UNSUPPORTED;
320 }
321 
322 bool MythMediaDevice::isSameDevice(const QString &path)
323 {
324 #ifdef Q_OS_MAC
325  // The caller may be using a raw device instead of the BSD 'leaf' name
326  if (path == "/dev/r" + m_DevicePath)
327  return true;
328 #endif
329 
330  return (path == m_DevicePath);
331 }
332 
334 {
335  setDeviceSpeed(m_DevicePath.toLocal8Bit().constData(), speed);
336 }
337 
339 {
340  // We just open the device here, which may or may not do the trick,
341  // derived classes can do more...
342  if (openDevice())
343  {
344  m_Locked = true;
345  return MEDIAERR_OK;
346  }
347  m_Locked = false;
348  return MEDIAERR_FAILED;
349 }
350 
352 {
353  m_Locked = false;
354 
355  return MEDIAERR_OK;
356 }
357 
359 bool MythMediaDevice::isMounted(bool Verify)
360 {
361  if (Verify)
362  return findMountPath();
363  return (m_Status == MEDIASTAT_MOUNTED);
364 }
365 
368 {
369  if (m_DevicePath.isEmpty())
370  {
371  LOG(VB_MEDIA, LOG_ERR, "findMountPath() - logic error, no device path");
372  return false;
373  }
374 
375 #ifdef USE_MOUNT_COMMAND
376  // HACK. TODO: replace with something using popen()?
377  if (myth_system(PATHTO_MOUNT + " > /tmp/mounts") != GENERIC_EXIT_OK)
378  return false;
379  QFile mountFile("/tmp/mounts");
380 #else
381  QFile mountFile(PATHTO_MOUNTS);
382 #endif
383 
384  // Try to open the mounts file so we can search it for our device.
385  if (!mountFile.open(QIODevice::ReadOnly))
386  return false;
387 
388  QString debug;
389  QTextStream stream(&mountFile);
390 
391  for (;;)
392  {
393  QString mountPoint;
394  QString deviceName;
395 
396 
397 #ifdef USE_MOUNT_COMMAND
398  // Extract mount point and device name from something like:
399  // /dev/disk0s3 on / (hfs, local, journaled) - Mac OS X
400  // /dev/hdd on /tmp/AAA BBB type udf (ro) - Linux
401  stream >> deviceName;
402  mountPoint = stream.readLine();
403  mountPoint.remove(" on ");
404  mountPoint.remove(QRegExp(" type \\w.*")); // Linux
405  mountPoint.remove(QRegExp(" \\(\\w.*")); // Mac OS X
406 #else
407  // Extract the mount point and device name.
408  stream >> deviceName >> mountPoint;
409  stream.readLine(); // skip the rest of the line
410 #endif
411 
412  if (deviceName.isNull())
413  break;
414 
415  if (deviceName.isEmpty())
416  continue;
417 
418  if (!deviceName.startsWith("/dev/"))
419  continue;
420 
421  QStringList deviceNames;
422  getSymlinkTarget(deviceName, &deviceNames);
423 
424 #if CONFIG_DARWIN
425  // match short-style BSD node names:
426  if (m_DevicePath.startsWith("disk"))
427  deviceNames << deviceName.mid(5); // remove 5 chars - /dev/
428 #endif
429 
430  // Deal with escaped spaces
431  if (mountPoint.contains("\\040"))
432  mountPoint.replace("\\040", " ");
433 
434 
435  if (deviceNames.contains(m_DevicePath) ||
436  deviceNames.contains(m_RealDevice) )
437  {
438  m_MountPath = mountPoint;
439  mountFile.close();
440  return true;
441  }
442 
443  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
444  debug += QString(" %1 | %2\n")
445  .arg(deviceName, 16).arg(mountPoint);
446  }
447 
448  mountFile.close();
449 
450  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
451  {
452  debug = LOC + ":findMountPath() - mount of '"
453  + m_DevicePath + "' not found.\n"
454  + " Device name/type | Current mountpoint\n"
455  + " -----------------+-------------------\n"
456  + debug
457  + " =================+===================";
458  LOG(VB_MEDIA, LOG_DEBUG, debug);
459  }
460 
461  return false;
462 }
463 
465  bool CloseIt )
466 {
467  MythMediaStatus OldStatus = m_Status;
468 
469  m_Status = NewStatus;
470 
471  // If the status is changed we need to take some actions
472  // depending on the old and new status.
473  if (NewStatus != OldStatus)
474  {
475  LOG(VB_MEDIA, LOG_DEBUG,
476  QString("MythMediaDevice::setStatus %1 %2->%3")
477  .arg(getDevicePath()).arg(MediaStatusStrings[OldStatus])
478  .arg(MediaStatusStrings[NewStatus]));
479  switch (NewStatus)
480  {
481  // the disk is not / should not be mounted.
482  case MEDIASTAT_ERROR:
483  case MEDIASTAT_OPEN:
484  case MEDIASTAT_NODISK:
486  if (isMounted())
487  unmount();
488  break;
489  case MEDIASTAT_UNKNOWN:
490  case MEDIASTAT_USEABLE:
491  case MEDIASTAT_MOUNTED:
492  case MEDIASTAT_UNPLUGGED:
494  // get rid of the compiler warning...
495  break;
496  }
497 
498  // Don't fire off transitions to / from unknown states
499  if (m_Status != MEDIASTAT_UNKNOWN && OldStatus != MEDIASTAT_UNKNOWN)
500  emit statusChanged(OldStatus, this);
501  }
502 
503 
504  if (CloseIt)
505  closeDevice();
506 
507  return m_Status;
508 }
509 
511 {
512  m_VolumeID.clear();
513  m_KeyID.clear();
515 }
516 
518 {
520 }
521 
523 {
524  // MediaType is a bitmask.
525  QString mediatype;
526  for (uint u = MEDIATYPE_UNKNOWN; u != MEDIATYPE_END; u <<= 1)
527  {
528  QString s;
529  if (u & type & MEDIATYPE_UNKNOWN)
530  s = "MEDIATYPE_UNKNOWN";
531  else if (u & type & MEDIATYPE_DATA)
532  s = "MEDIATYPE_DATA";
533  else if (u & type & MEDIATYPE_MIXED)
534  s = "MEDIATYPE_MIXED";
535  else if (u & type & MEDIATYPE_AUDIO)
536  s = "MEDIATYPE_AUDIO";
537  else if (u & type & MEDIATYPE_DVD)
538  s = "MEDIATYPE_DVD";
539  else if (u & type & MEDIATYPE_BD)
540  s = "MEDIATYPE_BD";
541  else if (u & type & MEDIATYPE_VCD)
542  s = "MEDIATYPE_VCD";
543  else if (u & type & MEDIATYPE_MMUSIC)
544  s = "MEDIATYPE_MMUSIC";
545  else if (u & type & MEDIATYPE_MVIDEO)
546  s = "MEDIATYPE_MVIDEO";
547  else if (u & type & MEDIATYPE_MGALLERY)
548  s = "MEDIATYPE_MGALLERY";
549  else
550  continue;
551 
552  if (mediatype.isEmpty())
553  mediatype = s;
554  else
555  mediatype += "|" + s;
556  }
557 
558  return mediatype;
559 }
MEDIATYPE_MIXED
@ MEDIATYPE_MIXED
Definition: mythmedia.h:27
MEDIATYPE_END
@ MEDIATYPE_END
Definition: mythmedia.h:35
PATHTO_UNMOUNT
static const QString PATHTO_UNMOUNT("/bin/umount")
MEDIATYPE_DVD
@ MEDIATYPE_DVD
Definition: mythmedia.h:29
myth_system
uint myth_system(const QString &command, uint flags, uint timeout)
Definition: mythsystemlegacy.cpp:501
GENERIC_EXIT_OK
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
MEDIATYPE_VCD
@ MEDIATYPE_VCD
Definition: mythmedia.h:30
MEDIATYPE_UNKNOWN
@ MEDIATYPE_UNKNOWN
Definition: mythmedia.h:25
MythMediaDevice::m_DeviceHandle
int m_DeviceHandle
A file handle for opening and closing the device, ioctls(), et c.
Definition: mythmedia.h:175
MythMediaDevice::setDeviceSpeed
virtual void setDeviceSpeed(const char *, int)
Definition: mythmedia.h:100
kMSDontBlockInputDevs
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:34
MythMediaDevice::isDeviceOpen
bool isDeviceOpen() const
Definition: mythmedia.cpp:107
mythburn.mediatype
int mediatype
Definition: mythburn.py:208
MythMediaDevice::MythMediaDevice
MythMediaDevice(QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
Definition: mythmedia.cpp:75
MythMediaDevice::m_MountPath
QString m_MountPath
The path to this media's mount point.
Definition: mythmedia.h:153
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
PATHTO_MOUNT
static const QString PATHTO_MOUNT("/bin/mount")
MythMediaDevice::MediaErrorStrings
static const std::array< const QString, 3 > MediaErrorStrings
Definition: mythmedia.h:118
ext_to_media_t
QMap< QString, uint > ext_to_media_t
Definition: mythmedia.h:46
MEDIASTAT_ERROR
@ MEDIASTAT_ERROR
Unable to mount, but could be usable.
Definition: mythmedia.h:13
MythMediaDevice::openDevice
virtual bool openDevice()
Definition: mythmedia.cpp:83
arg
arg(title).arg(filename).arg(doDelete))
MEDIASTAT_USEABLE
@ MEDIASTAT_USEABLE
Definition: mythmedia.h:19
MythMediaDevice::m_SuperMount
bool m_SuperMount
Is this a supermount device?.
Definition: mythmedia.h:168
getSymlinkTarget
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
Definition: mythmiscutil.cpp:496
MythMediaDevice::getDevicePath
const QString & getDevicePath() const
Definition: mythmedia.h:61
MythMediaDevice::m_DevicePath
QString m_DevicePath
The path to this media's device.
Definition: mythmedia.h:149
MEDIATYPE_MMUSIC
@ MEDIATYPE_MMUSIC
Definition: mythmedia.h:31
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythMediaDevice::onDeviceUnmounted
virtual void onDeviceUnmounted()
Override this to perform any post unmount logic.
Definition: mythmedia.h:141
MEDIASTAT_MOUNTED
@ MEDIASTAT_MOUNTED
Definition: mythmedia.h:21
MythMediaDevice::s_ext_to_media
static ext_to_media_t s_ext_to_media
Map of extension to media type.
Definition: mythmedia.h:180
MythMediaDevice::statusChanged
void statusChanged(MythMediaStatus oldStatus, MythMediaDevice *pMedia)
MythMediaEvent::kEventType
static Type kEventType
Definition: mythmedia.h:193
PATHTO_PUMOUNT
static const QString PATHTO_PUMOUNT("/usr/bin/pumount")
MEDIASTAT_UNPLUGGED
@ MEDIASTAT_UNPLUGGED
Definition: mythmedia.h:15
close
#define close
Definition: compat.h:16
mythsystemlegacy.h
MythMediaDevice::m_MediaType
MythMediaType m_MediaType
The type of media. Read only.
Definition: mythmedia.h:162
MythMediaEvent::~MythMediaEvent
~MythMediaEvent() override
Definition: mythmedia.cpp:69
MythMediaDevice::isMounted
bool isMounted(bool bVerify=true)
Tells us if m_DevicePath is a mounted device.
Definition: mythmedia.cpp:359
mythlogging.h
MythMediaDevice::setSpeed
virtual void setSpeed(int speed)
Definition: mythmedia.cpp:333
MythMediaDevice::m_KeyID
QString m_KeyID
KeyID of the media.
Definition: mythmedia.h:151
MythMediaDevice::clearData
void clearData()
Definition: mythmedia.cpp:510
MEDIATYPE_BD
@ MEDIATYPE_BD
Definition: mythmedia.h:34
O_NONBLOCK
#define O_NONBLOCK
Definition: mythmedia.cpp:25
MythMediaDevice::MediaStatusStrings
static const std::array< const QString, 9 > MediaStatusStrings
Definition: mythmedia.h:117
debug
VERBOSE_PREAMBLE Most debug(nodatabase, notimestamp, noextra)") VERBOSE_MAP(VB_GENERAL
MythMediaDevice::unlock
virtual MythMediaError unlock()
Definition: mythmedia.cpp:351
mythmedia.h
MythMediaDevice::unmount
bool unmount()
Definition: mythmedia.h:108
MythMediaDevice::onDeviceMounted
virtual void onDeviceMounted(void)
Override this to perform any post mount logic.
Definition: mythmedia.h:133
MythMediaDevice::m_RealDevice
QString m_RealDevice
If m_DevicePath is a symlink, its target.
Definition: mythmedia.h:155
MEDIATYPE_MVIDEO
@ MEDIATYPE_MVIDEO
Definition: mythmedia.h:32
MEDIATYPE_AUDIO
@ MEDIATYPE_AUDIO
Definition: mythmedia.h:28
MythMediaDevice::setStatus
MythMediaStatus setStatus(MythMediaStatus newStat, bool CloseIt=false)
Definition: mythmedia.cpp:464
uint
unsigned int uint
Definition: compat.h:140
MythMediaDevice::lock
virtual MythMediaError lock()
Definition: mythmedia.cpp:338
MythMediaDevice::isSameDevice
virtual bool isSameDevice(const QString &path)
Definition: mythmedia.cpp:322
LOC
#define LOC
Definition: mythmedia.cpp:28
PATHTO_MOUNTS
static const QString PATHTO_MOUNTS("/proc/mounts")
kMSRunBackground
@ kMSRunBackground
run child in the background
Definition: mythsystem.h:36
MythMediaDevice::eject
virtual MythMediaError eject(bool open_close=true)
Definition: mythmedia.cpp:308
MythMediaDevice::RegisterMediaExtensions
static void RegisterMediaExtensions(uint mediatype, const QString &extensions)
Used to register media types with extensions.
Definition: mythmedia.cpp:301
MythMediaDevice::m_VolumeID
QString m_VolumeID
The volume ID of the media. Read/write.
Definition: mythmedia.h:157
MythMediaType
MythMediaType
Definition: mythmedia.h:24
VERBOSE_LEVEL_CHECK
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:14
mythmiscutil.h
MEDIASTAT_NODISK
@ MEDIASTAT_NODISK
CD/DVD tray closed but empty, device unusable.
Definition: mythmedia.h:17
MEDIATYPE_MGALLERY
@ MEDIATYPE_MGALLERY
Definition: mythmedia.h:33
MythMediaDevice::DetectMediaType
MythMediaType DetectMediaType(void)
Returns guessed media type based on file extensions.
Definition: mythmedia.cpp:215
MythMediaDevice::performMountCmd
virtual bool performMountCmd(bool DoMount)
Definition: mythmedia.cpp:112
MEDIASTAT_OPEN
@ MEDIASTAT_OPEN
CD/DVD tray open (meaningless for non-CDs?)
Definition: mythmedia.h:16
MEDIAERR_FAILED
@ MEDIAERR_FAILED
Definition: mythmedia.h:41
MythMediaError
MythMediaError
Definition: mythmedia.h:39
MEDIASTAT_UNFORMATTED
@ MEDIASTAT_UNFORMATTED
For devices/media a plugin might erase/format.
Definition: mythmedia.h:18
MEDIAERR_OK
@ MEDIAERR_OK
Definition: mythmedia.h:40
exitcodes.h
MEDIASTAT_UNKNOWN
@ MEDIASTAT_UNKNOWN
Definition: mythmedia.h:14
MEDIAERR_UNSUPPORTED
@ MEDIAERR_UNSUPPORTED
Definition: mythmedia.h:42
MythMediaDevice::m_Status
MythMediaStatus m_Status
The status of the media as of the last call to checkMedia.
Definition: mythmedia.h:159
MythMediaDevice::closeDevice
virtual bool closeDevice()
Definition: mythmedia.cpp:95
MythMediaStatus
MythMediaStatus
Definition: mythmedia.h:12
PATHTO_PMOUNT
static const QString PATHTO_PMOUNT("/usr/bin/pmount")
ext_cnt_t
QMap< QString, uint > ext_cnt_t
Definition: mythmedia.h:45
MythMediaDevice::ScanMediaType
bool ScanMediaType(const QString &directory, ext_cnt_t &cnt)
Recursively scan directories and create an associative array with the number of times we've seen each...
Definition: mythmedia.cpp:268
MythMediaDevice::findMountPath
bool findMountPath()
Try to find a mount of m_DevicePath in the mounts file.
Definition: mythmedia.cpp:367
MEDIATYPE_DATA
@ MEDIATYPE_DATA
Definition: mythmedia.h:26
MEDIASTAT_NOTMOUNTED
@ MEDIASTAT_NOTMOUNTED
Definition: mythmedia.h:20
MythMediaDevice::m_Locked
bool m_Locked
Is this media locked?. Read only.
Definition: mythmedia.h:166
MythMediaDevice::MediaTypeString
QString MediaTypeString()
Definition: mythmedia.cpp:517