bool Autodetection::detect() { m_device = ""; m_mountpoint = ""; m_errdev = ""; detectUsb(); // Try detection via rockbox.info / rbutil.log QStringList mounts = mountpoints(); for(int i=0; i< mounts.size();i++) { // do the file checking QDir dir(mounts.at(i)); qDebug() << "[Autodetect] paths to check:" << mounts; if(dir.exists()) { // check logfile first. if(QFile(mounts.at(i) + "/.rockbox/rbutil.log").exists()) { QSettings log(mounts.at(i) + "/.rockbox/rbutil.log", QSettings::IniFormat, this); if(!log.value("platform").toString().isEmpty()) { if(m_device.isEmpty()) m_device = log.value("platform").toString(); m_mountpoint = mounts.at(i); qDebug() << "[Autodetect] rbutil.log detected:" << m_device << m_mountpoint; return true; } } // check rockbox-info.txt afterwards. RockboxInfo info(mounts.at(i)); if(info.success()) { if(m_device.isEmpty()) { m_device = info.target(); // special case for video64mb. This is a workaround, and // should get replaced when autodetection is reworked. if(m_device == "ipodvideo" && info.ram() == 64) { m_device = "ipodvideo64mb"; } } m_mountpoint = mounts.at(i); qDebug() << "[Autodetect] rockbox-info.txt detected:" << m_device << m_mountpoint; return true; } // check for some specific files in root folder QDir root(mounts.at(i)); QStringList rootentries = root.entryList(QDir::Files); if(rootentries.contains("archos.mod", Qt::CaseInsensitive)) { // archos.mod in root folder -> Archos Player m_device = "player"; m_mountpoint = mounts.at(i); return true; } if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive)) { // ONDIOST.BIN in root -> Ondio FM m_device = "ondiofm"; m_mountpoint = mounts.at(i); return true; } if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive)) { // ONDIOSP.BIN in root -> Ondio SP m_device = "ondiosp"; m_mountpoint = mounts.at(i); return true; } if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive)) { qDebug() << "[Autodetect] ajbrec.ajz found. Trying detectAjbrec()"; if(detectAjbrec(mounts.at(i))) { m_mountpoint = mounts.at(i); qDebug() << "[Autodetect]" << m_device; return true; } } // detection based on player specific folders QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); if(rootfolders.contains("GBSYSTEM", Qt::CaseInsensitive)) { // GBSYSTEM folder -> Gigabeat m_device = "gigabeatf"; m_mountpoint = mounts.at(i); return true; } #if defined(Q_OS_WIN32) // on windows, try to detect the drive letter of an Ipod if(rootfolders.contains("iPod_Control", Qt::CaseInsensitive)) { // iPod_Control folder -> Ipod found // detecting of the Ipod type is done below using ipodpatcher m_mountpoint = mounts.at(i); } #endif } } int n; // try ipodpatcher // initialize sector buffer. Needed. ipod_sectorbuf = NULL; ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE); struct ipod_t ipod; n = ipod_scan(&ipod); if(n == 1) { qDebug() << "[Autodetect] Ipod found:" << ipod.modelstr << "at" << ipod.diskname; // if the found ipod is a macpod also notice it as device with problem. if(ipod.macpod) m_errdev = ipod.targetname; m_device = ipod.targetname; // since resolveMountPoint is doing exact matches we need to select // the correct partition. QString mp(ipod.diskname); #ifdef Q_OS_LINUX mp.append("2"); #endif #ifdef Q_OS_MACX mp.append("s2"); #endif m_mountpoint = resolveMountPoint(mp); return true; } else { qDebug() << "[Autodetect] ipodpatcher: no Ipod found." << n; } free(ipod_sectorbuf); ipod_sectorbuf = NULL; // try sansapatcher // initialize sector buffer. Needed. sansa_sectorbuf = NULL; sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE); struct sansa_t sansa; n = sansa_scan(&sansa); if(n == 1) { qDebug() << "[Autodetect] Sansa found:" << sansa.targetname << "at" << sansa.diskname; m_device = QString("sansa%1").arg(sansa.targetname); QString mp(sansa.diskname); #ifdef Q_OS_LINUX mp.append("1"); #endif #ifdef Q_OS_MACX mp.append("s1"); #endif m_mountpoint = resolveMountPoint(mp); return true; } else { qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n; } free(sansa_sectorbuf); sansa_sectorbuf = NULL; if(m_mountpoint.isEmpty() && m_device.isEmpty() && m_errdev.isEmpty() && m_incompat.isEmpty()) return false; return true; }
void Autodetection::mergePatcher(void) { int n; // try ipodpatcher // initialize sector buffer. Needed. struct ipod_t ipod; ipod.sectorbuf = NULL; ipod_alloc_buffer(&ipod, BUFFER_SIZE); n = ipod_scan(&ipod); // FIXME: handle more than one Ipod connected in ipodpatcher. if(n == 1) { LOG_INFO() << "Ipod found:" << ipod.modelstr << "at" << ipod.diskname; // since resolveMountPoint is doing exact matches we need to select // the correct partition. QString mp(ipod.diskname); #ifdef Q_OS_LINUX mp.append("2"); #endif #ifdef Q_OS_MACX mp.append("s2"); #endif struct Detected d; d.device = ipod.targetname; d.mountpoint = Utils::resolveMountPoint(mp); // if the found ipod is a macpod also notice it as device with problem. if(ipod.macpod) d.status = PlayerWrongFilesystem; else d.status = PlayerOk; updateDetectedDevice(d); } else { LOG_INFO() << "ipodpatcher: no Ipod found." << n; } ipod_dealloc_buffer(&ipod); // try sansapatcher // initialize sector buffer. Needed. struct sansa_t sansa; sansa_alloc_buffer(&sansa, BUFFER_SIZE); n = sansa_scan(&sansa); if(n == 1) { LOG_INFO() << "Sansa found:" << sansa.targetname << "at" << sansa.diskname; QString mp(sansa.diskname); #ifdef Q_OS_LINUX mp.append("1"); #endif #ifdef Q_OS_MACX mp.append("s1"); #endif struct Detected d; d.device = QString("sansa%1").arg(sansa.targetname); d.mountpoint = Utils::resolveMountPoint(mp); d.status = PlayerOk; updateDetectedDevice(d); } else { LOG_INFO() << "sansapatcher: no Sansa found." << n; } sansa_dealloc_buffer(&sansa); }