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,
188 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to %1 %2.")
193 LOG(VB_MEDIA, LOG_INFO,
"Disk inserted on a supermount device");
200 LOG(VB_GENERAL, LOG_INFO,
220 LOG(VB_MEDIA, LOG_NOTICE,
221 QString(
"No files with extensions found in '%1'")
226 QMap<uint, uint> media_cnts;
229 for (
auto it = ext_cnt.cbegin(); it != ext_cnt.cend(); ++it)
231 ext_to_media_t::const_iterator found =
s_ext_to_media.constFind(it.key());
234 LOG(VB_MEDIA, LOG_INFO, QString(
"DetectMediaType %1 (%2)")
236 media_cnts[*found] += *it;
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()));
249 for (
auto cit = media_cnts.cbegin(); cit != media_cnts.cend(); ++cit)
271 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
272 QFileInfoList entries =
d.entryInfoList();
273 for (
const auto& fi : qAsConst(entries))
284 const QString ext = fi.suffix();
286 cnt[ext.toLower()]++;
300 const QString &extensions)
302 QStringList exts = extensions.split(
",");
303 for (
const auto& ext : qAsConst(exts))
370 LOG(VB_MEDIA, LOG_ERR,
"findMountPath() - logic error, no device path");
374 #ifdef USE_MOUNT_COMMAND
378 QFile mountFile(
"/tmp/mounts");
384 if (!mountFile.open(QIODevice::ReadOnly))
388 QTextStream stream(&mountFile);
396 #ifdef USE_MOUNT_COMMAND
400 stream >> deviceName;
401 mountPoint = stream.readLine();
402 mountPoint.remove(
" on ");
403 mountPoint.remove(QRegularExpression(
" type \\w.*"));
404 mountPoint.remove(QRegularExpression(
" \\(\\w.*"));
407 stream >> deviceName >> mountPoint;
411 if (deviceName.isNull())
414 if (deviceName.isEmpty())
417 if (!deviceName.startsWith(
"/dev/"))
420 QStringList deviceNames;
426 deviceNames << deviceName.mid(5);
430 if (mountPoint.contains(
"\\040"))
431 mountPoint.replace(
"\\040",
" ");
443 debug += QString(
" %1 | %2\n")
444 .arg(deviceName, 16).arg(mountPoint);
451 debug =
LOC +
":findMountPath() - mount of '"
453 +
" Device name/type | Current mountpoint\n"
454 +
" -----------------+-------------------\n"
456 +
" =================+===================";
472 if (NewStatus != OldStatus)
474 LOG(VB_MEDIA, LOG_DEBUG,
475 QString(
"MythMediaDevice::setStatus %1 %2->%3")
529 s =
"MEDIATYPE_UNKNOWN";
531 s =
"MEDIATYPE_DATA";
533 s =
"MEDIATYPE_MIXED";
535 s =
"MEDIATYPE_AUDIO";
543 s =
"MEDIATYPE_MMUSIC";
545 s =
"MEDIATYPE_MVIDEO";
547 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