2007-08-05 19:48:04 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Wenger
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2008-10-12 19:21:58 +00:00
|
|
|
#include <QtCore>
|
2007-08-05 19:48:04 +00:00
|
|
|
#include "autodetection.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2020-11-28 19:47:28 +00:00
|
|
|
#include "playerbuildinfo.h"
|
2007-08-05 19:48:04 +00:00
|
|
|
|
2008-10-15 18:37:26 +00:00
|
|
|
#include "../ipodpatcher/ipodpatcher.h"
|
|
|
|
#include "../sansapatcher/sansapatcher.h"
|
|
|
|
|
2008-12-13 10:09:13 +00:00
|
|
|
|
2009-08-10 19:46:51 +00:00
|
|
|
#include "system.h"
|
2008-06-29 09:50:20 +00:00
|
|
|
#include "utils.h"
|
2010-04-02 21:24:19 +00:00
|
|
|
#include "rockboxinfo.h"
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
2007-09-02 08:49:08 +00:00
|
|
|
|
2007-08-05 19:48:04 +00:00
|
|
|
Autodetection::Autodetection(QObject* parent): QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
|
|
|
|
bool Autodetection::detect(void)
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2013-09-18 20:06:41 +00:00
|
|
|
QMap<PlayerStatus, QString> states;
|
|
|
|
states[PlayerOk] = "Ok";
|
|
|
|
states[PlayerAmbiguous] = "Ambiguous";
|
|
|
|
states[PlayerError] = "Error";
|
|
|
|
states[PlayerIncompatible] = "Incompatible";
|
|
|
|
states[PlayerMtpMode] = "MtpMode";
|
|
|
|
|
|
|
|
// clear detection state
|
|
|
|
m_detected.clear();
|
2007-09-14 20:52:38 +00:00
|
|
|
|
|
|
|
detectUsb();
|
2013-09-18 20:06:41 +00:00
|
|
|
mergeMounted();
|
|
|
|
mergePatcher();
|
|
|
|
// if any entry with usbdevices containing a value is left that entry
|
|
|
|
// hasn't been merged later. This indicates a problem during detection
|
|
|
|
// (ambiguous player but refining it failed). In this case create an entry
|
|
|
|
// for eacho of those so the user can select.
|
2020-12-05 18:01:03 +00:00
|
|
|
QList<struct Detected> detected;
|
2013-09-18 20:06:41 +00:00
|
|
|
for(int i = 0; i < m_detected.size(); ++i) {
|
|
|
|
int j = m_detected.at(i).usbdevices.size();
|
|
|
|
if(j > 0) {
|
2020-12-05 18:01:03 +00:00
|
|
|
struct Detected entry = m_detected.at(i);
|
2013-09-18 20:06:41 +00:00
|
|
|
while(j--) {
|
|
|
|
struct Detected d;
|
|
|
|
d.device = entry.usbdevices.at(j);
|
|
|
|
d.mountpoint = entry.mountpoint;
|
|
|
|
d.status = PlayerAmbiguous;
|
2020-12-05 18:01:03 +00:00
|
|
|
detected.append(d);
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-05 18:01:03 +00:00
|
|
|
else {
|
|
|
|
detected.append(m_detected.at(i));
|
|
|
|
}
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
2020-12-05 18:01:03 +00:00
|
|
|
m_detected = detected;
|
2013-09-18 20:06:41 +00:00
|
|
|
for(int i = 0; i < m_detected.size(); ++i) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Detected player:" << m_detected.at(i).device
|
2020-11-28 19:47:28 +00:00
|
|
|
<< "at" << m_detected.at(i).mountpoint
|
|
|
|
<< states[m_detected.at(i).status];
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_detected.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief detect devices based on usb pid / vid.
|
|
|
|
*/
|
|
|
|
void Autodetection::detectUsb()
|
|
|
|
{
|
|
|
|
// usb pid detection
|
|
|
|
QList<uint32_t> attached;
|
|
|
|
attached = System::listUsbIds();
|
2007-08-30 19:08:25 +00:00
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
int i = attached.size();
|
|
|
|
while(i--) {
|
2020-12-05 16:37:20 +00:00
|
|
|
QStringList a = PlayerBuildInfo::instance()->value(PlayerBuildInfo::UsbIdTargetList, attached.at(i)).toStringList();
|
|
|
|
if(a.size() > 0) {
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.status = PlayerOk;
|
2020-12-05 16:37:20 +00:00
|
|
|
d.usbdevices = a;
|
2013-09-18 20:06:41 +00:00
|
|
|
m_detected.append(d);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "[USB] detected supported player" << d.usbdevices;
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
2020-12-05 16:37:20 +00:00
|
|
|
QStringList b = PlayerBuildInfo::instance()->value(PlayerBuildInfo::UsbIdErrorList, attached.at(i)).toStringList();
|
|
|
|
if(b.size() > 0) {
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.status = PlayerMtpMode;
|
2020-12-05 16:37:20 +00:00
|
|
|
d.usbdevices = b;
|
2013-09-18 20:06:41 +00:00
|
|
|
m_detected.append(d);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_WARNING() << "[USB] detected problem with player" << d.device;
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
|
2020-11-28 19:47:28 +00:00
|
|
|
if(!PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::DisplayName, idstring).toString().isEmpty()) {
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.status = PlayerIncompatible;
|
|
|
|
d.device = idstring;
|
|
|
|
m_detected.append(d);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_WARNING() << "[USB] detected incompatible player" << d.device;
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Merge players detected by checking mounted filesystems for known files:
|
|
|
|
// - rockbox-info.txt / rbutil.log
|
|
|
|
// - player specific files
|
|
|
|
void Autodetection::mergeMounted(void)
|
|
|
|
{
|
2013-04-01 18:37:13 +00:00
|
|
|
QStringList mounts = Utils::mountpoints(Utils::MountpointsSupported);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "paths to check:" << mounts;
|
2007-08-23 15:24:28 +00:00
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
for(int i = 0; i < mounts.size(); i++)
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2007-08-30 19:08:25 +00:00
|
|
|
// do the file checking
|
2008-12-13 19:45:11 +00:00
|
|
|
QDir dir(mounts.at(i));
|
2007-08-05 19:48:04 +00:00
|
|
|
if(dir.exists())
|
|
|
|
{
|
2007-08-30 19:08:25 +00:00
|
|
|
// check logfile first.
|
2008-12-13 19:45:11 +00:00
|
|
|
if(QFile(mounts.at(i) + "/.rockbox/rbutil.log").exists()) {
|
|
|
|
QSettings log(mounts.at(i) + "/.rockbox/rbutil.log",
|
2007-08-30 19:08:25 +00:00
|
|
|
QSettings::IniFormat, this);
|
|
|
|
if(!log.value("platform").toString().isEmpty()) {
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = log.value("platform").toString();
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "rbutil.log detected:"
|
|
|
|
<< log.value("platform").toString() << mounts.at(i);
|
2007-08-30 19:08:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check rockbox-info.txt afterwards.
|
2009-03-21 16:30:40 +00:00
|
|
|
RockboxInfo info(mounts.at(i));
|
2009-08-10 19:20:53 +00:00
|
|
|
if(info.success())
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = info.target();
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "rockbox-info.txt detected:"
|
|
|
|
<< info.target() << mounts.at(i);
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2007-09-02 10:50:13 +00:00
|
|
|
// check for some specific files in root folder
|
2008-12-13 19:45:11 +00:00
|
|
|
QDir root(mounts.at(i));
|
2007-09-02 10:50:13 +00:00
|
|
|
QStringList rootentries = root.entryList(QDir::Files);
|
2007-09-02 12:20:44 +00:00
|
|
|
if(rootentries.contains("archos.mod", Qt::CaseInsensitive))
|
2007-09-02 10:50:13 +00:00
|
|
|
{
|
|
|
|
// archos.mod in root folder -> Archos Player
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = "player";
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-09-02 10:50:13 +00:00
|
|
|
}
|
2007-09-27 08:50:47 +00:00
|
|
|
if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive))
|
2007-09-02 10:50:13 +00:00
|
|
|
{
|
|
|
|
// ONDIOST.BIN in root -> Ondio FM
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = "ondiofm";
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-09-02 10:50:13 +00:00
|
|
|
}
|
2007-09-27 08:50:47 +00:00
|
|
|
if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive))
|
2007-09-02 10:50:13 +00:00
|
|
|
{
|
|
|
|
// ONDIOSP.BIN in root -> Ondio SP
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = "ondiosp";
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-09-02 10:50:13 +00:00
|
|
|
}
|
2007-09-27 08:50:47 +00:00
|
|
|
if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive))
|
2007-09-02 10:50:13 +00:00
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "ajbrec.ajz found. Trying detectAjbrec()";
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = detectAjbrec(mounts.at(i));
|
|
|
|
d.mountpoint = mounts.at(i);
|
|
|
|
d.status = PlayerOk;
|
|
|
|
if(!d.device.isEmpty()) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << d.device;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-09-27 08:50:47 +00:00
|
|
|
}
|
2007-09-02 10:50:13 +00:00
|
|
|
}
|
|
|
|
// detection based on player specific folders
|
2008-04-05 18:59:54 +00:00
|
|
|
QStringList rootfolders = root.entryList(QDir::Dirs
|
|
|
|
| QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
|
|
|
if(rootfolders.contains("GBSYSTEM", Qt::CaseInsensitive))
|
2007-09-02 10:50:13 +00:00
|
|
|
{
|
|
|
|
// GBSYSTEM folder -> Gigabeat
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = "gigabeatf";
|
|
|
|
d.mountpoint = mounts.at(i);
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-09-02 10:50:13 +00:00
|
|
|
}
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
// Ipods have a folder "iPod_Control" in the root.
|
|
|
|
for(int i = 0; i < m_detected.size(); ++i) {
|
|
|
|
struct Detected entry = m_detected.at(i);
|
|
|
|
for(int j = 0; j < entry.usbdevices.size(); ++j) {
|
|
|
|
// limit this to Ipods only.
|
|
|
|
if(!entry.usbdevices.at(j).startsWith("ipod")
|
|
|
|
&& !entry.device.startsWith("ipod")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// look for iPod_Control on all supported volumes.
|
|
|
|
for(int k = 0; k < mounts.size(); k++) {
|
|
|
|
QDir root(mounts.at(k));
|
|
|
|
QStringList rootfolders = root.entryList(QDir::Dirs
|
|
|
|
| QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
|
|
|
if(rootfolders.contains("iPod_Control", Qt::CaseInsensitive)) {
|
|
|
|
entry.mountpoint = mounts.at(k);
|
|
|
|
m_detected.takeAt(i);
|
|
|
|
m_detected.append(entry);
|
|
|
|
}
|
2008-03-20 20:29:17 +00:00
|
|
|
}
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-18 20:06:41 +00:00
|
|
|
#endif
|
2007-09-02 12:20:44 +00:00
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Autodetection::mergePatcher(void)
|
|
|
|
{
|
2007-09-02 10:50:13 +00:00
|
|
|
int n;
|
2008-09-28 17:02:36 +00:00
|
|
|
// try ipodpatcher
|
|
|
|
// initialize sector buffer. Needed.
|
2007-08-23 15:24:28 +00:00
|
|
|
struct ipod_t ipod;
|
2020-11-19 19:36:57 +00:00
|
|
|
ipod.sectorbuf = nullptr;
|
2012-12-23 22:30:57 +00:00
|
|
|
ipod_alloc_buffer(&ipod, BUFFER_SIZE);
|
2007-08-23 22:07:21 +00:00
|
|
|
n = ipod_scan(&ipod);
|
2013-09-18 20:06:41 +00:00
|
|
|
// FIXME: handle more than one Ipod connected in ipodpatcher.
|
2007-08-23 15:24:28 +00:00
|
|
|
if(n == 1) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Ipod found:" << ipod.modelstr << "at" << ipod.diskname;
|
2010-02-27 11:27:13 +00:00
|
|
|
// 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
|
2013-09-18 20:06:41 +00:00
|
|
|
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;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-08-23 15:24:28 +00:00
|
|
|
}
|
2008-06-29 09:50:20 +00:00
|
|
|
else {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "ipodpatcher: no Ipod found." << n;
|
2008-06-29 09:50:20 +00:00
|
|
|
}
|
2013-01-01 10:04:21 +00:00
|
|
|
ipod_dealloc_buffer(&ipod);
|
2007-09-02 10:50:13 +00:00
|
|
|
|
2008-09-28 17:02:36 +00:00
|
|
|
// try sansapatcher
|
|
|
|
// initialize sector buffer. Needed.
|
2007-08-23 22:07:21 +00:00
|
|
|
struct sansa_t sansa;
|
2012-12-23 22:36:00 +00:00
|
|
|
sansa_alloc_buffer(&sansa, BUFFER_SIZE);
|
2007-08-23 22:07:21 +00:00
|
|
|
n = sansa_scan(&sansa);
|
|
|
|
if(n == 1) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Sansa found:"
|
|
|
|
<< sansa.targetname << "at" << sansa.diskname;
|
2010-02-27 11:27:13 +00:00
|
|
|
QString mp(sansa.diskname);
|
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
mp.append("1");
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MACX
|
|
|
|
mp.append("s1");
|
|
|
|
#endif
|
2013-09-18 20:06:41 +00:00
|
|
|
struct Detected d;
|
|
|
|
d.device = QString("sansa%1").arg(sansa.targetname);
|
|
|
|
d.mountpoint = Utils::resolveMountPoint(mp);
|
|
|
|
d.status = PlayerOk;
|
2013-09-20 19:03:51 +00:00
|
|
|
updateDetectedDevice(d);
|
2007-08-23 22:07:21 +00:00
|
|
|
}
|
2008-06-29 09:50:20 +00:00
|
|
|
else {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "sansapatcher: no Sansa found." << n;
|
2008-06-29 09:50:20 +00:00
|
|
|
}
|
2013-01-01 12:23:47 +00:00
|
|
|
sansa_dealloc_buffer(&sansa);
|
2007-09-14 20:52:38 +00:00
|
|
|
}
|
2007-09-27 08:50:47 +00:00
|
|
|
|
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
QString Autodetection::detectAjbrec(QString root)
|
2007-09-27 08:50:47 +00:00
|
|
|
{
|
|
|
|
QFile f(root + "/ajbrec.ajz");
|
|
|
|
char header[24];
|
|
|
|
f.open(QIODevice::ReadOnly);
|
2013-09-18 20:06:41 +00:00
|
|
|
if(!f.read(header, 24)) return QString();
|
|
|
|
f.close();
|
2007-09-27 08:50:47 +00:00
|
|
|
|
|
|
|
// check the header of the file.
|
|
|
|
// recorder v1 had a 6 bytes sized header
|
|
|
|
// recorder v2, FM, Ondio SP and FM have a 24 bytes header.
|
|
|
|
|
|
|
|
// recorder v1 has the binary length in the first 4 bytes, so check
|
|
|
|
// for them first.
|
|
|
|
int len = (header[0]<<24) | (header[1]<<16) | (header[2]<<8) | header[3];
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "abjrec.ajz possible bin length:" << len
|
|
|
|
<< "file len:" << f.size();
|
2007-09-27 08:50:47 +00:00
|
|
|
if((f.size() - 6) == len)
|
2013-09-18 20:06:41 +00:00
|
|
|
return "recorder";
|
2008-10-15 18:37:26 +00:00
|
|
|
|
2007-09-27 08:50:47 +00:00
|
|
|
// size didn't match, now we need to assume we have a headerlength of 24.
|
|
|
|
switch(header[11]) {
|
|
|
|
case 2:
|
2013-09-18 20:06:41 +00:00
|
|
|
return "recorderv2";
|
2007-09-27 08:50:47 +00:00
|
|
|
case 4:
|
2013-09-18 20:06:41 +00:00
|
|
|
return "fmrecorder";
|
2007-09-27 08:50:47 +00:00
|
|
|
case 8:
|
2013-09-18 20:06:41 +00:00
|
|
|
return "ondiofm";
|
2007-09-27 08:50:47 +00:00
|
|
|
case 16:
|
2013-09-18 20:06:41 +00:00
|
|
|
return "ondiosp";
|
2007-09-27 08:50:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-09-18 20:06:41 +00:00
|
|
|
return QString();
|
2007-09-27 08:50:47 +00:00
|
|
|
}
|
2008-10-15 18:37:26 +00:00
|
|
|
|
2013-09-18 20:06:41 +00:00
|
|
|
|
|
|
|
int Autodetection::findDetectedDevice(QString device)
|
|
|
|
{
|
|
|
|
int i = m_detected.size();
|
|
|
|
while(i--) {
|
|
|
|
if(m_detected.at(i).usbdevices.contains(device))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
i = m_detected.size();
|
|
|
|
while(i--) {
|
|
|
|
if(m_detected.at(i).device == device)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2013-09-20 19:03:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
void Autodetection::updateDetectedDevice(Detected& entry)
|
|
|
|
{
|
|
|
|
int index = findDetectedDevice(entry.device);
|
|
|
|
if(index < 0) {
|
|
|
|
m_detected.append(entry);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_detected.takeAt(index);
|
|
|
|
m_detected.append(entry);
|
|
|
|
}
|
|
|
|
}
|