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