MythTV  master
mythmedia.cpp
Go to the documentation of this file.
1 // C header
2 #include <fcntl.h>
3 #include <unistd.h>
4 #include <utility>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <sys/param.h>
8 
9 // Qt Headers
10 #include <QDir>
11 #include <QFileInfo>
12 #include <QFileInfoList>
13 #include <QRegularExpression>
14 #include <QTextStream>
15 
16 // MythTV headers
17 #include "mythmedia.h"
18 #include "mythconfig.h"
19 #include "mythlogging.h"
20 #include "mythmiscutil.h"
21 #include "mythsystemlegacy.h"
22 #include "exitcodes.h"
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::kMediaStatusStrings
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::kMediaErrorStrings
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, QString DevicePath,
76  bool SuperMount, bool AllowEject)
77  : QObject(par), m_devicePath(std::move(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, m_devicePath);
140  }
141  else
142  {
143  MountCommand = QString("%1 %2")
144  .arg((DoMount) ? PATHTO_MOUNT : PATHTO_UNMOUNT, m_devicePath);
145  }
146 
147  LOG(VB_MEDIA, LOG_INFO, QString("Executing '%1'").arg(MountCommand));
148  int ret = myth_system(MountCommand, kMSDontBlockInputDevs);
149  if (ret != GENERIC_EXIT_OK)
150  {
151  usleep(300000);
152  LOG(VB_MEDIA, LOG_INFO, QString("Retrying '%1'").arg(MountCommand));
153  ret = myth_system(MountCommand, kMSDontBlockInputDevs);
154  }
155  if (ret == GENERIC_EXIT_OK)
156  {
157  if (DoMount)
158  {
159  // we cannot tell beforehand what the pmount mount point is
160  // so verify the mount status of the device
161  // In the case that m_devicePath is a symlink to a device
162  // in /etc/fstab then pmount delegates to mount which
163  // performs the mount asynchronously so we must wait a bit
164  usleep(1000000-1);
165  for (int tries = 2; !findMountPath() && tries > 0; --tries)
166  {
167  LOG(VB_MEDIA, LOG_INFO,
168  QString("Repeating '%1'").arg(MountCommand));
169  myth_system(MountCommand, kMSDontBlockInputDevs);
170  usleep(500000);
171  }
172  if (!findMountPath())
173  {
174  LOG(VB_MEDIA, LOG_ERR, "performMountCmd() attempted to"
175  " find mounted media, but failed?");
176  return false;
177  }
178  onDeviceMounted(); // Identify disk type & content
179  LOG(VB_GENERAL, LOG_INFO,
180  QString("Detected MediaType ") + MediaTypeString());
181  }
182  else
184 
185  return true;
186  }
187  LOG(VB_GENERAL, LOG_ERR, QString("Failed to %1 %2.")
188  .arg(DoMount ? "mount" : "unmount", m_devicePath));
189  }
190  else
191  {
192  LOG(VB_MEDIA, LOG_INFO, "Disk inserted on a supermount device");
193  // If it's a super mount then the OS will handle mounting / unmounting.
194  // We just need to give derived classes a chance to perform their
195  // mount / unmount logic.
196  if (DoMount)
197  {
198  onDeviceMounted();
199  LOG(VB_GENERAL, LOG_INFO,
200  QString("Detected MediaType ") + MediaTypeString());
201  }
202  else
204 
205  return true;
206  }
207  return false;
208 }
209 
214 {
215  ext_cnt_t ext_cnt;
216 
217  if (!ScanMediaType(m_mountPath, ext_cnt))
218  {
219  LOG(VB_MEDIA, LOG_NOTICE,
220  QString("No files with extensions found in '%1'")
221  .arg(m_mountPath));
222  return MEDIATYPE_UNKNOWN;
223  }
224 
225  QMap<uint, uint> media_cnts;
226 
227  // convert raw counts to composite mediatype counts
228  for (auto it = ext_cnt.cbegin(); it != ext_cnt.cend(); ++it)
229  {
230  ext_to_media_t::const_iterator found = s_ext_to_media.constFind(it.key());
231  if (found != s_ext_to_media.constEnd())
232  {
233  LOG(VB_MEDIA, LOG_INFO, QString("DetectMediaType %1 (%2)")
234  .arg(MediaTypeString(found.value()), it.key()));
235  media_cnts[*found] += *it;
236  }
237  else
238  {
239  LOG(VB_MEDIA, LOG_NOTICE, QString(
240  "DetectMediaType(this=0x%1) unknown file type %1")
241  .arg(quintptr(this),0,16).arg(it.key()));
242  }
243  }
244 
245  // break composite mediatypes into constituent components
246  uint mediatype = 0;
247 
248  for (auto cit = media_cnts.cbegin(); cit != media_cnts.cend(); ++cit)
249  {
250  for (uint key = 1; key != MEDIATYPE_END; key <<= 1)
251  {
252  if (key & cit.key())
253  mediatype |= key;
254  }
255  }
256 
258 }
259 
264 bool MythMediaDevice::ScanMediaType(const QString &directory, ext_cnt_t &cnt)
265 {
266  QDir d(directory);
267  if (!d.exists())
268  return false;
269 
270  d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
271  QFileInfoList entries = d.entryInfoList();
272  for (const auto& fi : qAsConst(entries))
273  {
274  if (fi.isSymLink())
275  continue;
276 
277  if (fi.isDir())
278  {
279  ScanMediaType(fi.absoluteFilePath(), cnt);
280  continue;
281  }
282 
283  const QString ext = fi.suffix();
284  if (!ext.isEmpty())
285  cnt[ext.toLower()]++;
286  }
287 
288  return !cnt.empty();
289 }
290 
297 // static
299  const QString &extensions)
300 {
301  QStringList exts = extensions.split(",");
302  for (const auto& ext : qAsConst(exts))
303  s_ext_to_media[ext] |= mediatype;
304 }
305 
307 {
308  (void) open_close;
309 
310 #if CONFIG_DARWIN
311  QString command = "diskutil eject " + m_devicePath;
312 
313  myth_system(command, kMSRunBackground);
314  return MEDIAERR_OK;
315 #endif
316 
317  return MEDIAERR_UNSUPPORTED;
318 }
319 
320 bool MythMediaDevice::isSameDevice(const QString &path)
321 {
322 #ifdef Q_OS_MAC
323  // The caller may be using a raw device instead of the BSD 'leaf' name
324  if (path == "/dev/r" + m_devicePath)
325  return true;
326 #endif
327 
328  return (path == m_devicePath);
329 }
330 
332 {
333  setDeviceSpeed(m_devicePath.toLocal8Bit().constData(), speed);
334 }
335 
337 {
338  // We just open the device here, which may or may not do the trick,
339  // derived classes can do more...
340  if (openDevice())
341  {
342  m_locked = true;
343  return MEDIAERR_OK;
344  }
345  m_locked = false;
346  return MEDIAERR_FAILED;
347 }
348 
350 {
351  m_locked = false;
352 
353  return MEDIAERR_OK;
354 }
355 
357 bool MythMediaDevice::isMounted(bool Verify)
358 {
359  if (Verify)
360  return findMountPath();
361  return (m_status == MEDIASTAT_MOUNTED);
362 }
363 
366 {
367  if (m_devicePath.isEmpty())
368  {
369  LOG(VB_MEDIA, LOG_ERR, "findMountPath() - logic error, no device path");
370  return false;
371  }
372 
373 #ifdef USE_MOUNT_COMMAND
374  // HACK. TODO: replace with something using popen()?
375  if (myth_system(PATHTO_MOUNT + " > /tmp/mounts") != GENERIC_EXIT_OK)
376  return false;
377  QFile mountFile("/tmp/mounts");
378 #else
379  QFile mountFile(PATHTO_MOUNTS);
380 #endif
381 
382  // Try to open the mounts file so we can search it for our device.
383  if (!mountFile.open(QIODevice::ReadOnly))
384  return false;
385 
386  QString debug;
387  QTextStream stream(&mountFile);
388 
389  for (;;)
390  {
391  QString mountPoint;
392  QString deviceName;
393 
394 
395 #ifdef USE_MOUNT_COMMAND
396  // Extract mount point and device name from something like:
397  // /dev/disk0s3 on / (hfs, local, journaled) - Mac OS X
398  // /dev/hdd on /tmp/AAA BBB type udf (ro) - Linux
399  stream >> deviceName;
400  mountPoint = stream.readLine();
401  mountPoint.remove(" on ");
402  mountPoint.remove(QRegularExpression(" type \\w.*")); // Linux
403  mountPoint.remove(QRegularExpression(" \\(\\w.*")); // Mac OS X
404 #else
405  // Extract the mount point and device name.
406  stream >> deviceName >> mountPoint;
407  stream.readLine(); // skip the rest of the line
408 #endif
409 
410  if (deviceName.isNull())
411  break;
412 
413  if (deviceName.isEmpty())
414  continue;
415 
416  if (!deviceName.startsWith("/dev/"))
417  continue;
418 
419  QStringList deviceNames;
420  getSymlinkTarget(deviceName, &deviceNames);
421 
422 #if CONFIG_DARWIN
423  // match short-style BSD node names:
424  if (m_devicePath.startsWith("disk"))
425  deviceNames << deviceName.mid(5); // remove 5 chars - /dev/
426 #endif
427 
428  // Deal with escaped spaces
429  if (mountPoint.contains("\\040"))
430  mountPoint.replace("\\040", " ");
431 
432 
433  if (deviceNames.contains(m_devicePath) ||
434  deviceNames.contains(m_realDevice) )
435  {
436  m_mountPath = mountPoint;
437  mountFile.close();
438  return true;
439  }
440 
441  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
442  debug += QString(" %1 | %2\n")
443  .arg(deviceName, 16).arg(mountPoint);
444  }
445 
446  mountFile.close();
447 
448  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
449  {
450  debug = LOC + ":findMountPath() - mount of '"
451  + m_devicePath + "' not found.\n"
452  + " Device name/type | Current mountpoint\n"
453  + " -----------------+-------------------\n"
454  + debug
455  + " =================+===================";
456  LOG(VB_MEDIA, LOG_DEBUG, debug);
457  }
458 
459  return false;
460 }
461 
463  bool CloseIt )
464 {
465  MythMediaStatus OldStatus = m_status;
466 
467  m_status = NewStatus;
468 
469  // If the status is changed we need to take some actions
470  // depending on the old and new status.
471  if (NewStatus != OldStatus)
472  {
473  LOG(VB_MEDIA, LOG_DEBUG,
474  QString("MythMediaDevice::setStatus %1 %2->%3")
475  .arg(getDevicePath(), kMediaStatusStrings[OldStatus],
476  kMediaStatusStrings[NewStatus]));
477  switch (NewStatus)
478  {
479  // the disk is not / should not be mounted.
480  case MEDIASTAT_ERROR:
481  case MEDIASTAT_OPEN:
482  case MEDIASTAT_NODISK:
484  if (isMounted())
485  unmount();
486  break;
487  case MEDIASTAT_UNKNOWN:
488  case MEDIASTAT_USEABLE:
489  case MEDIASTAT_MOUNTED:
490  case MEDIASTAT_UNPLUGGED:
492  // get rid of the compiler warning...
493  break;
494  }
495 
496  // Don't fire off transitions to / from unknown states
497  if (m_status != MEDIASTAT_UNKNOWN && OldStatus != MEDIASTAT_UNKNOWN)
498  emit statusChanged(OldStatus, this);
499  }
500 
501 
502  if (CloseIt)
503  closeDevice();
504 
505  return m_status;
506 }
507 
509 {
510  m_volumeID.clear();
511  m_keyID.clear();
513 }
514 
516 {
518 }
519 
521 {
522  // MediaType is a bitmask.
523  QString mediatype;
524  for (uint u = MEDIATYPE_UNKNOWN; u != MEDIATYPE_END; u <<= 1)
525  {
526  QString s;
527  if (u & type & MEDIATYPE_UNKNOWN)
528  s = "MEDIATYPE_UNKNOWN";
529  else if (u & type & MEDIATYPE_DATA)
530  s = "MEDIATYPE_DATA";
531  else if (u & type & MEDIATYPE_MIXED)
532  s = "MEDIATYPE_MIXED";
533  else if (u & type & MEDIATYPE_AUDIO)
534  s = "MEDIATYPE_AUDIO";
535  else if (u & type & MEDIATYPE_DVD)
536  s = "MEDIATYPE_DVD";
537  else if (u & type & MEDIATYPE_BD)
538  s = "MEDIATYPE_BD";
539  else if (u & type & MEDIATYPE_VCD)
540  s = "MEDIATYPE_VCD";
541  else if (u & type & MEDIATYPE_MMUSIC)
542  s = "MEDIATYPE_MMUSIC";
543  else if (u & type & MEDIATYPE_MVIDEO)
544  s = "MEDIATYPE_MVIDEO";
545  else if (u & type & MEDIATYPE_MGALLERY)
546  s = "MEDIATYPE_MGALLERY";
547  else
548  continue;
549 
550  if (mediatype.isEmpty())
551  mediatype = s;
552  else
553  mediatype += "|" + s;
554  }
555 
556  return mediatype;
557 }
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")
MythMediaDevice::m_superMount
bool m_superMount
Is this a supermount device?.
Definition: mythmedia.h:168
MEDIATYPE_DVD
@ MEDIATYPE_DVD
Definition: mythmedia.h:29
GENERIC_EXIT_OK
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
MythMediaDevice::m_deviceHandle
int m_deviceHandle
A file handle for opening and closing the device, ioctls(), et c.
Definition: mythmedia.h:175
MEDIATYPE_VCD
@ MEDIATYPE_VCD
Definition: mythmedia.h:30
MEDIATYPE_UNKNOWN
@ MEDIATYPE_UNKNOWN
Definition: mythmedia.h:25
MythMediaDevice::setDeviceSpeed
virtual void setDeviceSpeed(const char *, int)
Definition: mythmedia.h:100
kMSDontBlockInputDevs
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:36
MythMediaDevice::isDeviceOpen
bool isDeviceOpen() const
Definition: mythmedia.cpp:107
mythburn.mediatype
int mediatype
Definition: mythburn.py:208
MythMediaDevice::m_keyID
QString m_keyID
KeyID of the media.
Definition: mythmedia.h:151
MythMediaDevice::m_realDevice
QString m_realDevice
If m_devicePath is a symlink, its target.
Definition: mythmedia.h:155
PATHTO_MOUNT
static const QString PATHTO_MOUNT("/bin/mount")
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
MEDIASTAT_USEABLE
@ MEDIASTAT_USEABLE
Definition: mythmedia.h:19
getSymlinkTarget
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
Definition: mythmiscutil.cpp:499
MythMediaDevice::getDevicePath
const QString & getDevicePath() const
Definition: mythmedia.h:61
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
myth_system
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
Definition: mythsystemlegacy.cpp:502
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:17
mythsystemlegacy.h
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:357
mythlogging.h
MythMediaDevice::setSpeed
virtual void setSpeed(int speed)
Definition: mythmedia.cpp:331
MythMediaDevice::clearData
void clearData()
Definition: mythmedia.cpp:508
MEDIATYPE_BD
@ MEDIATYPE_BD
Definition: mythmedia.h:34
O_NONBLOCK
#define O_NONBLOCK
Definition: mythmedia.cpp:25
debug
VERBOSE_PREAMBLE Most debug(nodatabase, notimestamp, noextra)") VERBOSE_MAP(VB_GENERAL
MythMediaDevice::unlock
virtual MythMediaError unlock()
Definition: mythmedia.cpp:349
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
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:462
MythMediaDevice::m_mountPath
QString m_mountPath
The path to this media's mount point.
Definition: mythmedia.h:153
MythMediaDevice::kMediaErrorStrings
static const std::array< const QString, 3 > kMediaErrorStrings
Definition: mythmedia.h:118
uint
unsigned int uint
Definition: compat.h:140
MythMediaDevice::lock
virtual MythMediaError lock()
Definition: mythmedia.cpp:336
MythMediaDevice::isSameDevice
virtual bool isSameDevice(const QString &path)
Definition: mythmedia.cpp:320
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:38
MythMediaDevice::m_locked
bool m_locked
Is this media locked?. Read only.
Definition: mythmedia.h:166
MythMediaDevice::eject
virtual MythMediaError eject(bool open_close=true)
Definition: mythmedia.cpp:306
MythMediaDevice::RegisterMediaExtensions
static void RegisterMediaExtensions(uint mediatype, const QString &extensions)
Used to register media types with extensions.
Definition: mythmedia.cpp:298
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
std
Definition: mythchrono.h:23
MythMediaDevice::m_devicePath
QString m_devicePath
The path to this media's device.
Definition: mythmedia.h:149
MythMediaDevice::kMediaStatusStrings
static const std::array< const QString, 9 > kMediaStatusStrings
Definition: mythmedia.h:117
MythMediaDevice::DetectMediaType
MythMediaType DetectMediaType(void)
Returns guessed media type based on file extensions.
Definition: mythmedia.cpp:213
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
MythMediaDevice::m_status
MythMediaStatus m_status
The status of the media as of the last call to checkMedia.
Definition: mythmedia.h:159
MEDIASTAT_UNFORMATTED
@ MEDIASTAT_UNFORMATTED
For devices/media a plugin might erase/format.
Definition: mythmedia.h:18
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
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::closeDevice
virtual bool closeDevice()
Definition: mythmedia.cpp:95
MythMediaStatus
MythMediaStatus
Definition: mythmedia.h:12
MythMediaDevice::m_mediaType
MythMediaType m_mediaType
The type of media. Read only.
Definition: mythmedia.h:162
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:264
MythMediaDevice::findMountPath
bool findMountPath()
Try to find a mount of m_devicePath in the mounts file.
Definition: mythmedia.cpp:365
MEDIATYPE_DATA
@ MEDIATYPE_DATA
Definition: mythmedia.h:26
MEDIASTAT_NOTMOUNTED
@ MEDIASTAT_NOTMOUNTED
Definition: mythmedia.h:20
MythMediaDevice::MythMediaDevice
MythMediaDevice(QObject *par, QString DevicePath, bool SuperMount, bool AllowEject)
Definition: mythmedia.cpp:75
MythMediaDevice::m_volumeID
QString m_volumeID
The volume ID of the media. Read/write.
Definition: mythmedia.h:157
MythMediaDevice::MediaTypeString
QString MediaTypeString()
Definition: mythmedia.cpp:515