11 #include <QFileInfoList>
12 #include <QTextStream>
16 #include "mythconfig.h"
28 #define LOC QString("MythMediaDevice:")
41 # define USE_MOUNT_COMMAND
48 "MEDIASTAT_UNPLUGGED",
51 "MEDIASTAT_UNFORMATTED",
53 "MEDIASTAT_NOTMOUNTED",
61 "MEDIAERR_UNSUPPORTED"
65 (QEvent::Type) QEvent::registerEventType();
68 bool SuperMount,
bool AllowEject)
102 return (ret != -1) ?
true :
false;
119 LOG(VB_MEDIA, LOG_ERR,
"MythMediaDevice::performMountCmd(true)"
120 " - Logic Error? Device already mounted.");
130 QString MountCommand;
135 MountCommand = QString(
"%1 %2")
139 MountCommand = QString(
"%1 %2")
143 LOG(VB_MEDIA, LOG_INFO, QString(
"Executing '%1'").arg(MountCommand));
152 LOG(VB_MEDIA, LOG_ERR,
"performMountCmd() attempted to"
153 " find mounted media, but failed?");
158 LOG(VB_GENERAL, LOG_INFO,
167 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to mount %1.")
172 LOG(VB_MEDIA, LOG_INFO,
"Disk inserted on a supermount device");
179 LOG(VB_GENERAL, LOG_INFO,
200 LOG(VB_MEDIA, LOG_NOTICE,
201 QString(
"No files with extensions found in '%1'")
206 QMap<uint, uint> media_cnts, media_cnt;
209 ext_cnt_t::const_iterator it = ext_cnt.begin();
210 for (; it != ext_cnt.end(); ++it)
212 ext_to_media_t::const_iterator found =
m_ext_to_media.find(it.key());
214 media_cnts[*found] += *it;
218 QMap<uint, uint>::const_iterator cit = media_cnts.begin();
219 for (; cit != media_cnts.end(); ++cit)
223 if ((key = 1 << j) & cit.key())
224 media_cnt[key] += *cit;
230 for (cit = media_cnt.begin(); cit != media_cnt.end(); ++cit)
252 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
253 QFileInfoList list = d.entryInfoList();
255 for( QFileInfoList::iterator it = list.begin();
270 const QString ext = fi.suffix();
272 cnt[ext.toLower()]++;
285 const QString &extensions)
287 const QStringList list = extensions.split(
",");
288 for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
361 LOG(VB_MEDIA, LOG_ERR,
"findMountPath() - logic error, no device path");
365 #ifdef USE_MOUNT_COMMAND
369 QFile mountFile(
"/tmp/mounts");
375 if (!mountFile.open(QIODevice::ReadOnly))
379 QTextStream
stream(&mountFile);
387 #ifdef USE_MOUNT_COMMAND
391 stream >> deviceName;
392 mountPoint = stream.readLine();
393 mountPoint.remove(
" on ");
394 mountPoint.remove(QRegExp(
" type \\w.*"));
395 mountPoint.remove(QRegExp(
" \\(\\w.*"));
398 stream >> deviceName >> mountPoint;
402 if (deviceName.isNull())
405 if (deviceName.isEmpty())
408 if (!deviceName.startsWith(
"/dev/"))
411 QStringList deviceNames;
417 deviceNames << deviceName.mid(5);
421 if (mountPoint.contains(
"\\040"))
422 mountPoint.replace(
"\\040",
" ");
433 if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
434 debug += QString(
" %1 | %2\n")
435 .arg(deviceName, 16).arg(mountPoint);
440 if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG))
442 debug =
LOC +
":findMountPath() - mount of '"
444 +
" Device name/type | Current mountpoint\n"
445 +
" -----------------+-------------------\n"
447 +
" =================+===================";
448 LOG(VB_MEDIA, LOG_DEBUG, debug);
463 if (NewStatus != OldStatus)
514 return "MEDIATYPE_UNKNOWN";
516 return "MEDIATYPE_DATA";
518 return "MEDIATYPE_MIXED";
520 return "MEDIATYPE_AUDIO";
522 return "MEDIATYPE_DVD";
524 return "MEDIATYPE_BD";
526 return "MEDIATYPE_VCD";
528 return "MEDIATYPE_MMUSIC";
530 return "MEDIATYPE_MVIDEO";
532 return "MEDIATYPE_MGALLERY";
534 return "MEDIATYPE_UNKNOWN";