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 <QTextStream>
14 
15 // MythTV headers
16 #include "mythmedia.h"
17 #include "mythconfig.h"
18 #include "mythlogging.h"
19 #include "mythmiscutil.h"
20 #include "mythsystemlegacy.h"
21 #include "exitcodes.h"
22 
23 using namespace std;
24 
25 #ifdef _WIN32
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 #if CONFIG_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 #if CONFIG_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 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_MAC
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)
141  .arg(m_devicePath);
142  }
143  else
144  {
145  MountCommand = QString("%1 %2")
146  .arg((DoMount) ? PATHTO_MOUNT : PATHTO_UNMOUNT)
147  .arg(m_devicePath);
148  }
149 
150  LOG(VB_MEDIA, LOG_INFO, QString("Executing '%1'").arg(MountCommand));
151  int ret = myth_system(MountCommand, kMSDontBlockInputDevs);
152  if (ret != GENERIC_EXIT_OK)
153  {
154  usleep(300000);
155  LOG(VB_MEDIA, LOG_INFO, QString("Retrying '%1'").arg(MountCommand));
156  ret = myth_system(MountCommand, kMSDontBlockInputDevs);
157  }
158  if (ret == GENERIC_EXIT_OK)
159  {
160  if (DoMount)
161  {
162  // we cannot tell beforehand what the pmount mount point is
163  // so verify the mount status of the device
164  // In the case that m_devicePath is a symlink to a device
165  // in /etc/fstab then pmount delegates to mount which
166  // performs the mount asynchronously so we must wait a bit
167  usleep(1000000-1);
168  for (int tries = 2; !findMountPath() && tries > 0; --tries)
169  {
170  LOG(VB_MEDIA, LOG_INFO,
171  QString("Repeating '%1'").arg(MountCommand));
172  myth_system(MountCommand, kMSDontBlockInputDevs);
173  usleep(500000);
174  }
175  if (!findMountPath())
176  {
177  LOG(VB_MEDIA, LOG_ERR, "performMountCmd() attempted to"
178  " find mounted media, but failed?");
179  return false;
180  }
181  onDeviceMounted(); // Identify disk type & content
182  LOG(VB_GENERAL, LOG_INFO,
183  QString("Detected MediaType ") + MediaTypeString());
184  }
185  else
187 
188  return true;
189  }
190  LOG(VB_GENERAL, LOG_ERR, QString("Failed to %1 %2.")
191  .arg(DoMount ? "mount" : "unmount").arg(m_devicePath));
192  }
193  else
194  {
195  LOG(VB_MEDIA, LOG_INFO, "Disk inserted on a supermount device");
196  // If it's a super mount then the OS will handle mounting / unmounting.
197  // We just need to give derived classes a chance to perform their
198  // mount / unmount logic.
199  if (DoMount)
200  {
201  onDeviceMounted();
202  LOG(VB_GENERAL, LOG_INFO,
203  QString("Detected MediaType ") + MediaTypeString());
204  }
205  else
207 
208  return true;
209  }
210  return false;
211 }
212 
217 {
218  ext_cnt_t ext_cnt;
219 
220  if (!ScanMediaType(m_mountPath, ext_cnt))
221  {
222  LOG(VB_MEDIA, LOG_NOTICE,
223  QString("No files with extensions found in '%1'")
224  .arg(m_mountPath));
225  return MEDIATYPE_UNKNOWN;
226  }
227 
228  QMap<uint, uint> media_cnts;
229 
230  // convert raw counts to composite mediatype counts
231  for (auto it = ext_cnt.cbegin(); it != ext_cnt.cend(); ++it)
232  {
233  ext_to_media_t::const_iterator found = s_ext_to_media.constFind(it.key());
234  if (found != s_ext_to_media.constEnd())
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  for (auto cit = media_cnts.cbegin(); cit != media_cnts.cend(); ++cit)
252  {
253  for (uint key = 1; key != MEDIATYPE_END; key <<= 1)
254  {
255  if (key & cit.key())
256  mediatype |= key;
257  }
258  }
259 
261 }
262 
267 bool MythMediaDevice::ScanMediaType(const QString &directory, ext_cnt_t &cnt)
268 {
269  QDir d(directory);
270  if (!d.exists())
271  return false;
272 
273  d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
274  QFileInfoList entries = d.entryInfoList();
275  for (const auto& fi : qAsConst(entries))
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  QStringList exts = extensions.split(",");
305  for (const auto& ext : qAsConst(exts))
306  s_ext_to_media[ext] |= mediatype;
307 }
308 
310 {
311  (void) open_close;
312 
313 #if CONFIG_DARWIN
314  QString command = "diskutil eject " + m_devicePath;
315 
316  myth_system(command, kMSRunBackground);
317  return MEDIAERR_OK;
318 #endif
319 
320  return MEDIAERR_UNSUPPORTED;
321 }
322 
323 bool MythMediaDevice::isSameDevice(const QString &path)
324 {
325 #ifdef Q_OS_MAC
326  // The caller may be using a raw device instead of the BSD 'leaf' name
327  if (path == "/dev/r" + m_devicePath)
328  return true;
329 #endif
330 
331  return (path == m_devicePath);
332 }
333 
335 {
336  setDeviceSpeed(m_devicePath.toLocal8Bit().constData(), speed);
337 }
338 
340 {
341  // We just open the device here, which may or may not do the trick,
342  // derived classes can do more...
343  if (openDevice())
344  {
345  m_locked = true;
346  return MEDIAERR_OK;
347  }
348  m_locked = false;
349  return MEDIAERR_FAILED;
350 }
351 
353 {
354  m_locked = false;
355 
356  return MEDIAERR_OK;
357 }
358 
360 bool MythMediaDevice::isMounted(bool Verify)
361 {
362  if (Verify)
363  return findMountPath();
364  return (m_status == MEDIASTAT_MOUNTED);
365 }
366 
369 {
370  if (m_devicePath.isEmpty())
371  {
372  LOG(VB_MEDIA, LOG_ERR, "findMountPath() - logic error, no device path");
373  return false;
374  }
375 
376 #ifdef USE_MOUNT_COMMAND
377  // HACK. TODO: replace with something using popen()?
378  if (myth_system(PATHTO_MOUNT + " > /tmp/mounts") != GENERIC_EXIT_OK)
379  return false;
380  QFile mountFile("/tmp/mounts");
381 #else
382  QFile mountFile(PATHTO_MOUNTS);
383 #endif
384 
385  // Try to open the mounts file so we can search it for our device.
386  if (!mountFile.open(QIODevice::ReadOnly))
387  return false;
388 
389  QString debug;
390  QTextStream stream(&mountFile);
391 
392  for (;;)
393  {
394  QString mountPoint;
395  QString deviceName;
396 
397 
398 #ifdef USE_MOUNT_COMMAND
399  // Extract mount point and device name from something like:
400  // /dev/disk0s3 on / (hfs, local, journaled) - Mac OS X
401  // /dev/hdd on /tmp/AAA BBB type udf (ro) - Linux
402  stream >> deviceName;
403  mountPoint = stream.readLine();
404  mountPoint.remove(" on ");
405  mountPoint.remove(QRegExp(" type \\w.*")); // Linux
406  mountPoint.remove(QRegExp(" \\(\\w.*")); // Mac OS X
407 #else
408  // Extract the mount point and device name.
409  stream >> deviceName >> mountPoint;
410  stream.readLine(); // skip the rest of the line
411 #endif
412 
413  if (deviceName.isNull())
414  break;
415 
416  if (deviceName.isEmpty())
417  continue;
418 
419  if (!deviceName.startsWith("/dev/"))
420  continue;
421 
422  QStringList deviceNames;
423  getSymlinkTarget(deviceName, &deviceNames);
424 
425 #if CONFIG_DARWIN
426  // match short-style BSD node names:
427  if (m_devicePath.startsWith("disk"))
428  deviceNames << deviceName.mid(5); // remove 5 chars - /dev/
429 #endif
430 
431  // Deal with escaped spaces
432  if (mountPoint.contains("\\040"))
433  mountPoint.replace("\\040", " ");
434 
435 
436  if (deviceNames.contains(m_devicePath) ||
437  deviceNames.contains(m_realDevice) )
438  {
439  m_mountPath = mountPoint;
440  mountFile.close();
441  return true;
442  }
443 
444  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
445  debug += QString(" %1 | %2\n")
446  .arg(deviceName, 16).arg(mountPoint);
447  }
448 
449  mountFile.close();
450 
451  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
452  {
453  debug = LOC + ":findMountPath() - mount of '"
454  + m_devicePath + "' not found.\n"
455  + " Device name/type | Current mountpoint\n"
456  + " -----------------+-------------------\n"
457  + debug
458  + " =================+===================";
459  LOG(VB_MEDIA, LOG_DEBUG, debug);
460  }
461 
462  return false;
463 }
464 
466  bool CloseIt )
467 {
468  MythMediaStatus OldStatus = m_status;
469 
470  m_status = NewStatus;
471 
472  // If the status is changed we need to take some actions
473  // depending on the old and new status.
474  if (NewStatus != OldStatus)
475  {
476  LOG(VB_MEDIA, LOG_DEBUG,
477  QString("MythMediaDevice::setStatus %1 %2->%3")
478  .arg(getDevicePath()).arg(kMediaStatusStrings[OldStatus])
479  .arg(kMediaStatusStrings[NewStatus]));
480  switch (NewStatus)
481  {
482  // the disk is not / should not be mounted.
483  case MEDIASTAT_ERROR:
484  case MEDIASTAT_OPEN:
485  case MEDIASTAT_NODISK:
487  if (isMounted())
488  unmount();
489  break;
490  case MEDIASTAT_UNKNOWN:
491  case MEDIASTAT_USEABLE:
492  case MEDIASTAT_MOUNTED:
493  case MEDIASTAT_UNPLUGGED:
495  // get rid of the compiler warning...
496  break;
497  }
498 
499  // Don't fire off transitions to / from unknown states
500  if (m_status != MEDIASTAT_UNKNOWN && OldStatus != MEDIASTAT_UNKNOWN)
501  emit statusChanged(OldStatus, this);
502  }
503 
504 
505  if (CloseIt)
506  closeDevice();
507 
508  return m_status;
509 }
510 
512 {
513  m_volumeID.clear();
514  m_keyID.clear();
516 }
517 
519 {
521 }
522 
524 {
525  // MediaType is a bitmask.
526  QString mediatype;
527  for (uint u = MEDIATYPE_UNKNOWN; u != MEDIATYPE_END; u <<= 1)
528  {
529  QString s;
530  if (u & type & MEDIATYPE_UNKNOWN)
531  s = "MEDIATYPE_UNKNOWN";
532  else if (u & type & MEDIATYPE_DATA)
533  s = "MEDIATYPE_DATA";
534  else if (u & type & MEDIATYPE_MIXED)
535  s = "MEDIATYPE_MIXED";
536  else if (u & type & MEDIATYPE_AUDIO)
537  s = "MEDIATYPE_AUDIO";
538  else if (u & type & MEDIATYPE_DVD)
539  s = "MEDIATYPE_DVD";
540  else if (u & type & MEDIATYPE_BD)
541  s = "MEDIATYPE_BD";
542  else if (u & type & MEDIATYPE_VCD)
543  s = "MEDIATYPE_VCD";
544  else if (u & type & MEDIATYPE_MMUSIC)
545  s = "MEDIATYPE_MMUSIC";
546  else if (u & type & MEDIATYPE_MVIDEO)
547  s = "MEDIATYPE_MVIDEO";
548  else if (u & type & MEDIATYPE_MGALLERY)
549  s = "MEDIATYPE_MGALLERY";
550  else
551  continue;
552 
553  if (mediatype.isEmpty())
554  mediatype = s;
555  else
556  mediatype += "|" + s;
557  }
558 
559  return mediatype;
560 }
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
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
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:34
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
MEDIASTAT_ERROR
@ MEDIASTAT_ERROR
Unable to mount, but could be usable.
Definition: mythmedia.h:13
MythMediaDevice::openDevice
virtual bool openDevice()
Definition: mythmedia.cpp:84
arg
arg(title).arg(filename).arg(doDelete))
MEDIASTAT_USEABLE
@ MEDIASTAT_USEABLE
Definition: mythmedia.h:19
getSymlinkTarget
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
Definition: mythmiscutil.cpp:495
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
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
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:360
mythlogging.h
MythMediaDevice::setSpeed
virtual void setSpeed(int speed)
Definition: mythmedia.cpp:334
MythMediaDevice::clearData
void clearData()
Definition: mythmedia.cpp:511
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:352
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:465
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:339
MythMediaDevice::isSameDevice
virtual bool isSameDevice(const QString &path)
Definition: mythmedia.cpp:323
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:36
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:309
MythMediaDevice::RegisterMediaExtensions
static void RegisterMediaExtensions(uint mediatype, const QString &extensions)
Used to register media types with extensions.
Definition: mythmedia.cpp:301
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::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:216
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:267
MythMediaDevice::findMountPath
bool findMountPath()
Try to find a mount of m_devicePath in the mounts file.
Definition: mythmedia.cpp:368
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:518