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))
368 LOG(VB_MEDIA, LOG_ERR,
"findMountPath() - logic error, no device path");
372 #ifdef USE_MOUNT_COMMAND
376 QFile mountFile(
"/tmp/mounts");
382 if (!mountFile.open(QIODevice::ReadOnly))
386 QTextStream stream(&mountFile);
394 #ifdef USE_MOUNT_COMMAND
398 stream >> deviceName;
399 mountPoint = stream.readLine();
400 mountPoint.remove(
" on ");
401 mountPoint.remove(QRegularExpression(
" type \\w.*"));
402 mountPoint.remove(QRegularExpression(
" \\(\\w.*"));
405 stream >> deviceName >> mountPoint;
409 if (deviceName.isNull())
412 if (deviceName.isEmpty())
415 if (!deviceName.startsWith(
"/dev/"))
418 QStringList deviceNames;
424 deviceNames << deviceName.mid(5);
428 if (mountPoint.contains(
"\\040"))
429 mountPoint.replace(
"\\040",
" ");
441 debug += QString(
" %1 | %2\n")
442 .arg(deviceName, 16).arg(mountPoint);
449 debug =
LOC +
":findMountPath() - mount of '"
451 +
" Device name/type | Current mountpoint\n"
452 +
" -----------------+-------------------\n"
454 +
" =================+===================";
470 if (NewStatus != OldStatus)
472 LOG(VB_MEDIA, LOG_DEBUG,
473 QString(
"MythMediaDevice::setStatus %1 %2->%3")
527 s =
"MEDIATYPE_UNKNOWN";
529 s =
"MEDIATYPE_DATA";
531 s =
"MEDIATYPE_MIXED";
533 s =
"MEDIATYPE_AUDIO";
541 s =
"MEDIATYPE_MMUSIC";
543 s =
"MEDIATYPE_MVIDEO";
545 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