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 #ifdef _WIN32
24 # define O_NONBLOCK 0
25 #endif
26 
27 #define LOC QString("MythMediaDevice:")
28 
29 static const QString PATHTO_PMOUNT("/usr/bin/pmount");
30 static const QString PATHTO_PUMOUNT("/usr/bin/pumount");
31 #if CONFIG_DARWIN
32  static const QString PATHTO_MOUNT("/sbin/mount");
33 #else
34  static const QString PATHTO_MOUNT("/bin/mount");
35 #endif
36 static const QString PATHTO_UNMOUNT("/bin/umount");
37 static const QString PATHTO_MOUNTS("/proc/mounts");
38 
39 #if CONFIG_DARWIN
40 # define USE_MOUNT_COMMAND
41 #endif
42 
43 const std::array<const QString,9> MythMediaDevice::kMediaStatusStrings
44 {
45  "MEDIASTAT_ERROR",
46  "MEDIASTAT_UNKNOWN",
47  "MEDIASTAT_UNPLUGGED",
48  "MEDIASTAT_OPEN",
49  "MEDIASTAT_NODISK",
50  "MEDIASTAT_UNFORMATTED",
51  "MEDIASTAT_USEABLE",
52  "MEDIASTAT_NOTMOUNTED",
53  "MEDIASTAT_MOUNTED"
54 };
55 
56 const std::array<const QString,3> MythMediaDevice::kMediaErrorStrings
57 {
58  "MEDIAERR_OK",
59  "MEDIAERR_FAILED",
60  "MEDIAERR_UNSUPPORTED"
61 };
62 
63 QEvent::Type MythMediaEvent::kEventType =
64  (QEvent::Type) QEvent::registerEventType();
65 
66 // Force this class to have a vtable so that dynamic_cast works.
67 // NOLINTNEXTLINE(modernize-use-equals-default)
69 {
70 }
71 
73 
74 MythMediaDevice::MythMediaDevice(QObject* par, QString DevicePath,
75  bool SuperMount, bool AllowEject)
76  : QObject(par), m_devicePath(std::move(DevicePath)),
77  m_allowEject(AllowEject), m_superMount(SuperMount)
78 {
80 }
81 
83 {
84  // Sanity check
85  if (isDeviceOpen())
86  return true;
87 
88  QByteArray dev = m_devicePath.toLocal8Bit();
89  m_deviceHandle = open(dev.constData(), O_RDONLY | O_NONBLOCK);
90 
91  return isDeviceOpen();
92 }
93 
95 {
96  // Sanity check
97  if (!isDeviceOpen())
98  return true;
99 
100  int ret = close(m_deviceHandle);
101  m_deviceHandle = -1;
102 
103  return ret != -1;
104 }
105 
107 {
108  return m_deviceHandle >= 0;
109 }
110 
112 {
113  if (DoMount && isMounted())
114  {
115 #ifdef Q_OS_MAC
116  // Not an error - DiskArbitration has already mounted the device.
117  // AddDevice calls mount() so onDeviceMounted() can get mediaType.
118  onDeviceMounted();
119 #else
120  LOG(VB_MEDIA, LOG_ERR, "MythMediaDevice::performMountCmd(true)"
121  " - Logic Error? Device already mounted.");
122  return true;
123 #endif
124  }
125 
126  if (isDeviceOpen())
127  closeDevice();
128 
129  if (!m_superMount)
130  {
131  QString MountCommand;
132 
133  // Build a command line for mount/unmount and execute it...
134  // Is there a better way to do this?
135  if (QFile(PATHTO_PMOUNT).exists() && QFile(PATHTO_PUMOUNT).exists())
136  {
137  MountCommand = QString("%1 %2")
138  .arg((DoMount) ? PATHTO_PMOUNT : PATHTO_PUMOUNT)
139  .arg(m_devicePath);
140  }
141  else
142  {
143  MountCommand = QString("%1 %2")
144  .arg((DoMount) ? PATHTO_MOUNT : PATHTO_UNMOUNT)
145  .arg(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").arg(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())).arg(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 : qAsConst(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 : qAsConst(exts))
304  s_ext_to_media[ext] |= mediatype;
305 }
306 
308 {
309  (void) open_close;
310 
311 #if CONFIG_DARWIN
312  QString command = "diskutil eject " + m_devicePath;
313 
314  myth_system(command, kMSRunBackground);
315  return MEDIAERR_OK;
316 #endif
317 
318  return MEDIAERR_UNSUPPORTED;
319 }
320 
321 bool MythMediaDevice::isSameDevice(const QString &path)
322 {
323 #ifdef Q_OS_MAC
324  // The caller may be using a raw device instead of the BSD 'leaf' name
325  if (path == "/dev/r" + m_devicePath)
326  return true;
327 #endif
328 
329  return (path == m_devicePath);
330 }
331 
333 {
334  setDeviceSpeed(m_devicePath.toLocal8Bit().constData(), speed);
335 }
336 
338 {
339  // We just open the device here, which may or may not do the trick,
340  // derived classes can do more...
341  if (openDevice())
342  {
343  m_locked = true;
344  return MEDIAERR_OK;
345  }
346  m_locked = false;
347  return MEDIAERR_FAILED;
348 }
349 
351 {
352  m_locked = false;
353 
354  return MEDIAERR_OK;
355 }
356 
358 bool MythMediaDevice::isMounted(bool Verify)
359 {
360  if (Verify)
361  return findMountPath();
362  return (m_status == MEDIASTAT_MOUNTED);
363 }
364 
367 {
368  if (m_devicePath.isEmpty())
369  {
370  LOG(VB_MEDIA, LOG_ERR, "findMountPath() - logic error, no device path");
371  return false;
372  }
373 
374 #ifdef USE_MOUNT_COMMAND
375  // HACK. TODO: replace with something using popen()?
376  if (myth_system(PATHTO_MOUNT + " > /tmp/mounts") != GENERIC_EXIT_OK)
377  return false;
378  QFile mountFile("/tmp/mounts");
379 #else
380  QFile mountFile(PATHTO_MOUNTS);
381 #endif
382 
383  // Try to open the mounts file so we can search it for our device.
384  if (!mountFile.open(QIODevice::ReadOnly))
385  return false;
386 
387  QString debug;
388  QTextStream stream(&mountFile);
389 
390  for (;;)
391  {
392  QString mountPoint;
393  QString deviceName;
394 
395 
396 #ifdef USE_MOUNT_COMMAND
397  // Extract mount point and device name from something like:
398  // /dev/disk0s3 on / (hfs, local, journaled) - Mac OS X
399  // /dev/hdd on /tmp/AAA BBB type udf (ro) - Linux
400  stream >> deviceName;
401  mountPoint = stream.readLine();
402  mountPoint.remove(" on ");
403  mountPoint.remove(QRegExp(" type \\w.*")); // Linux
404  mountPoint.remove(QRegExp(" \\(\\w.*")); // Mac OS X
405 #else
406  // Extract the mount point and device name.
407  stream >> deviceName >> mountPoint;
408  stream.readLine(); // skip the rest of the line
409 #endif
410 
411  if (deviceName.isNull())
412  break;
413 
414  if (deviceName.isEmpty())
415  continue;
416 
417  if (!deviceName.startsWith("/dev/"))
418  continue;
419 
420  QStringList deviceNames;
421  getSymlinkTarget(deviceName, &deviceNames);
422 
423 #if CONFIG_DARWIN
424  // match short-style BSD node names:
425  if (m_devicePath.startsWith("disk"))
426  deviceNames << deviceName.mid(5); // remove 5 chars - /dev/
427 #endif
428 
429  // Deal with escaped spaces
430  if (mountPoint.contains("\\040"))
431  mountPoint.replace("\\040", " ");
432 
433 
434  if (deviceNames.contains(m_devicePath) ||
435  deviceNames.contains(m_realDevice) )
436  {
437  m_mountPath = mountPoint;
438  mountFile.close();
439  return true;
440  }
441 
442  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
443  debug += QString(" %1 | %2\n")
444  .arg(deviceName, 16).arg(mountPoint);
445  }
446 
447  mountFile.close();
448 
449  if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
450  {
451  debug = LOC + ":findMountPath() - mount of '"
452  + m_devicePath + "' not found.\n"
453  + " Device name/type | Current mountpoint\n"
454  + " -----------------+-------------------\n"
455  + debug
456  + " =================+===================";
457  LOG(VB_MEDIA, LOG_DEBUG, debug);
458  }
459 
460  return false;
461 }
462 
464  bool CloseIt )
465 {
466  MythMediaStatus OldStatus = m_status;
467 
468  m_status = NewStatus;
469 
470  // If the status is changed we need to take some actions
471  // depending on the old and new status.
472  if (NewStatus != OldStatus)
473  {
474  LOG(VB_MEDIA, LOG_DEBUG,
475  QString("MythMediaDevice::setStatus %1 %2->%3")
476  .arg(getDevicePath()).arg(kMediaStatusStrings[OldStatus])
477  .arg(kMediaStatusStrings[NewStatus]));
478  switch (NewStatus)
479  {
480  // the disk is not / should not be mounted.
481  case MEDIASTAT_ERROR:
482  case MEDIASTAT_OPEN:
483  case MEDIASTAT_NODISK:
485  if (isMounted())
486  unmount();
487  break;
488  case MEDIASTAT_UNKNOWN:
489  case MEDIASTAT_USEABLE:
490  case MEDIASTAT_MOUNTED:
491  case MEDIASTAT_UNPLUGGED:
493  // get rid of the compiler warning...
494  break;
495  }
496 
497  // Don't fire off transitions to / from unknown states
498  if (m_status != MEDIASTAT_UNKNOWN && OldStatus != MEDIASTAT_UNKNOWN)
499  emit statusChanged(OldStatus, this);
500  }
501 
502 
503  if (CloseIt)
504  closeDevice();
505 
506  return m_status;
507 }
508 
510 {
511  m_volumeID.clear();
512  m_keyID.clear();
514 }
515 
517 {
519 }
520 
522 {
523  // MediaType is a bitmask.
524  QString mediatype;
525  for (uint u = MEDIATYPE_UNKNOWN; u != MEDIATYPE_END; u <<= 1)
526  {
527  QString s;
528  if (u & type & MEDIATYPE_UNKNOWN)
529  s = "MEDIATYPE_UNKNOWN";
530  else if (u & type & MEDIATYPE_DATA)
531  s = "MEDIATYPE_DATA";
532  else if (u & type & MEDIATYPE_MIXED)
533  s = "MEDIATYPE_MIXED";
534  else if (u & type & MEDIATYPE_AUDIO)
535  s = "MEDIATYPE_AUDIO";
536  else if (u & type & MEDIATYPE_DVD)
537  s = "MEDIATYPE_DVD";
538  else if (u & type & MEDIATYPE_BD)
539  s = "MEDIATYPE_BD";
540  else if (u & type & MEDIATYPE_VCD)
541  s = "MEDIATYPE_VCD";
542  else if (u & type & MEDIATYPE_MMUSIC)
543  s = "MEDIATYPE_MMUSIC";
544  else if (u & type & MEDIATYPE_MVIDEO)
545  s = "MEDIATYPE_MVIDEO";
546  else if (u & type & MEDIATYPE_MGALLERY)
547  s = "MEDIATYPE_MGALLERY";
548  else
549  continue;
550 
551  if (mediatype.isEmpty())
552  mediatype = s;
553  else
554  mediatype += "|" + s;
555  }
556 
557  return mediatype;
558 }
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:106
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:82
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:497
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:17
mythsystemlegacy.h
MythMediaEvent::~MythMediaEvent
~MythMediaEvent() override
Definition: mythmedia.cpp:68
MythMediaDevice::isMounted
bool isMounted(bool bVerify=true)
Tells us if m_devicePath is a mounted device.
Definition: mythmedia.cpp:358
mythlogging.h
MythMediaDevice::setSpeed
virtual void setSpeed(int speed)
Definition: mythmedia.cpp:332
MythMediaDevice::clearData
void clearData()
Definition: mythmedia.cpp:509
MEDIATYPE_BD
@ MEDIATYPE_BD
Definition: mythmedia.h:34
O_NONBLOCK
#define O_NONBLOCK
Definition: mythmedia.cpp:24
debug
VERBOSE_PREAMBLE Most debug(nodatabase, notimestamp, noextra)") VERBOSE_MAP(VB_GENERAL
MythMediaDevice::unlock
virtual MythMediaError unlock()
Definition: mythmedia.cpp:350
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:463
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:141
MythMediaDevice::lock
virtual MythMediaError lock()
Definition: mythmedia.cpp:337
MythMediaDevice::isSameDevice
virtual bool isSameDevice(const QString &path)
Definition: mythmedia.cpp:321
LOC
#define LOC
Definition: mythmedia.cpp:27
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: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
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:214
MythMediaDevice::performMountCmd
virtual bool performMountCmd(bool DoMount)
Definition: mythmedia.cpp:111
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:94
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:366
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:74
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:516