Go to the documentation of this file.
13 #include <QFileInfoList>
14 #include <QRegularExpression>
15 #include <QTextStream>
29 #define LOC QString("MythMediaDevice:")
42 # define USE_MOUNT_COMMAND
49 "MEDIASTAT_UNPLUGGED",
52 "MEDIASTAT_UNFORMATTED",
54 "MEDIASTAT_NOTMOUNTED",
62 "MEDIAERR_UNSUPPORTED"
66 (QEvent::Type) QEvent::registerEventType();
77 bool SuperMount,
bool AllowEject)
78 : QObject(par), m_devicePath(std::move(DevicePath)),
79 m_allowEject(AllowEject), m_superMount(SuperMount)
122 LOG(VB_MEDIA, LOG_ERR,
"MythMediaDevice::performMountCmd(true)"
123 " - Logic Error? Device already mounted.");
133 QString MountCommand;
139 MountCommand = QString(
"%1 %2")
144 MountCommand = QString(
"%1 %2")
148 LOG(VB_MEDIA, LOG_INFO, QString(
"Executing '%1'").arg(MountCommand));
153 LOG(VB_MEDIA, LOG_INFO, QString(
"Retrying '%1'").arg(MountCommand));
168 LOG(VB_MEDIA, LOG_INFO,
169 QString(
"Repeating '%1'").arg(MountCommand));
175 LOG(VB_MEDIA, LOG_ERR,
"performMountCmd() attempted to"
176 " find mounted media, but failed?");
180 LOG(VB_GENERAL, LOG_INFO,
190 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to %1 %2.")
195 LOG(VB_MEDIA, LOG_INFO,
"Disk inserted on a supermount device");
202 LOG(VB_GENERAL, LOG_INFO,
224 LOG(VB_MEDIA, LOG_NOTICE,
225 QString(
"No files with extensions found in '%1'")
230 QMap<uint, uint> media_cnts;
233 for (
auto it = ext_cnt.cbegin(); it != ext_cnt.cend(); ++it)
235 ext_to_media_t::const_iterator found =
s_ext_to_media.constFind(it.key());
238 LOG(VB_MEDIA, LOG_INFO, QString(
"DetectMediaType %1 (%2)")
240 media_cnts[*found] += *it;
244 LOG(VB_MEDIA, LOG_NOTICE, QString(
245 "DetectMediaType(this=0x%1) unknown file type %1")
246 .arg(quintptr(
this),0,16).arg(it.key()));
253 for (
auto cit = media_cnts.cbegin(); cit != media_cnts.cend(); ++cit)
275 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
276 QFileInfoList entries =
d.entryInfoList();
277 for (
const auto& fi : std::as_const(entries))
288 const QString ext = fi.suffix();
290 cnt[ext.toLower()]++;
304 const QString &extensions)
306 QStringList exts = extensions.split(
",");
307 for (
const auto& ext : std::as_const(exts))
372 LOG(VB_MEDIA, LOG_ERR,
"findMountPath() - logic error, no device path");
376 #ifdef USE_MOUNT_COMMAND
380 QFile mountFile(
"/tmp/mounts");
386 if (!mountFile.open(QIODevice::ReadOnly))
390 QTextStream stream(&mountFile);
398 #ifdef USE_MOUNT_COMMAND
402 stream >> deviceName;
403 mountPoint = stream.readLine();
404 mountPoint.remove(
" on ");
405 mountPoint.remove(QRegularExpression(
" type \\w.*"));
406 mountPoint.remove(QRegularExpression(
" \\(\\w.*"));
409 stream >> deviceName >> mountPoint;
413 if (deviceName.isNull())
416 if (deviceName.isEmpty())
419 if (!deviceName.startsWith(
"/dev/"))
422 QStringList deviceNames;
428 deviceNames << deviceName.mid(5);
432 if (mountPoint.contains(
"\\040"))
433 mountPoint.replace(
"\\040",
" ");
445 debug += QString(
" %1 | %2\n")
446 .arg(deviceName, 16).arg(mountPoint);
453 debug =
LOC +
":findMountPath() - mount of '"
455 +
" Device name/type | Current mountpoint\n"
456 +
" -----------------+-------------------\n"
458 +
" =================+===================";
474 if (NewStatus != OldStatus)
476 LOG(VB_MEDIA, LOG_DEBUG,
477 QString(
"MythMediaDevice::setStatus %1 %2->%3")
531 s =
"MEDIATYPE_UNKNOWN";
533 s =
"MEDIATYPE_DATA";
535 s =
"MEDIATYPE_MIXED";
537 s =
"MEDIATYPE_AUDIO";
545 s =
"MEDIATYPE_MMUSIC";
547 s =
"MEDIATYPE_MVIDEO";
549 s =
"MEDIATYPE_MGALLERY";
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
@ GENERIC_EXIT_OK
Exited with no error.
VERBOSE_PREAMBLE Most debug(nodatabase, notimestamp, noextra)") VERBOSE_MAP(VB_GENERAL
@ kMSRunBackground
run child in the background
static const iso6937table * d