summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp87
-rw-r--r--rbutil/rbutilqt/base/autodetection.h1
2 files changed, 23 insertions, 65 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 2d7476502a..4b3d1a1ab1 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -138,18 +138,11 @@ void Autodetection::mergeMounted(void)
QSettings log(mounts.at(i) + "/.rockbox/rbutil.log",
QSettings::IniFormat, this);
if(!log.value("platform").toString().isEmpty()) {
- int index = findDetectedDevice(log.value("platform").toString());
struct Detected d;
d.device = log.value("platform").toString();
d.mountpoint = mounts.at(i);
d.status = PlayerOk;
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
qDebug() << "[Autodetect] rbutil.log detected:"
<< log.value("platform").toString() << mounts.at(i);
}
@@ -159,18 +152,11 @@ void Autodetection::mergeMounted(void)
RockboxInfo info(mounts.at(i));
if(info.success())
{
- int index = findDetectedDevice(info.target());
struct Detected d;
d.device = info.target();
d.mountpoint = mounts.at(i);
d.status = PlayerOk;
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
qDebug() << "[Autodetect] rockbox-info.txt detected:"
<< info.target() << mounts.at(i);
}
@@ -185,7 +171,7 @@ void Autodetection::mergeMounted(void)
d.device = "player";
d.mountpoint = mounts.at(i);
d.status = PlayerOk;
- m_detected.append(d);
+ updateDetectedDevice(d);
}
if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive))
{
@@ -194,14 +180,7 @@ void Autodetection::mergeMounted(void)
d.device = "ondiofm";
d.mountpoint = mounts.at(i);
d.status = PlayerOk;
- int index = findDetectedDevice("ondiofm");
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive))
{
@@ -210,14 +189,7 @@ void Autodetection::mergeMounted(void)
d.device = "ondiosp";
d.mountpoint = mounts.at(i);
d.status = PlayerOk;
- int index = findDetectedDevice("ondiosp");
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive))
{
@@ -228,14 +200,7 @@ void Autodetection::mergeMounted(void)
d.status = PlayerOk;
if(!d.device.isEmpty()) {
qDebug() << "[Autodetect]" << d.device;
- int index = findDetectedDevice("ondiosp");
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
}
// detection based on player specific folders
@@ -247,14 +212,7 @@ void Autodetection::mergeMounted(void)
struct Detected d;
d.device = "gigabeatf";
d.mountpoint = mounts.at(i);
- int index = findDetectedDevice("ondiosp");
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
}
}
@@ -315,14 +273,7 @@ void Autodetection::mergePatcher(void)
d.status = PlayerWrongFilesystem;
else
d.status = PlayerOk;
- int index = findDetectedDevice(ipod.targetname);
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
else {
qDebug() << "[Autodetect] ipodpatcher: no Ipod found." << n;
@@ -348,14 +299,7 @@ void Autodetection::mergePatcher(void)
d.device = QString("sansa%1").arg(sansa.targetname);
d.mountpoint = Utils::resolveMountPoint(mp);
d.status = PlayerOk;
- int index = findDetectedDevice(d.device);
- if(index < 0) {
- m_detected.append(d);
- }
- else {
- m_detected.takeAt(index);
- m_detected.append(d);
- }
+ updateDetectedDevice(d);
}
else {
qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n;
@@ -423,3 +367,16 @@ int Autodetection::findDetectedDevice(QString device)
}
return -1;
}
+
+
+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);
+ }
+}
diff --git a/rbutil/rbutilqt/base/autodetection.h b/rbutil/rbutilqt/base/autodetection.h
index c3c7fc9168..f9adf2aa0c 100644
--- a/rbutil/rbutilqt/base/autodetection.h
+++ b/rbutil/rbutilqt/base/autodetection.h
@@ -61,6 +61,7 @@ private:
void mergePatcher(void);
QString detectAjbrec(QString);
int findDetectedDevice(QString device);
+ void updateDetectedDevice(struct Detected& entry);
QList<struct Detected> m_detected;
QList<int> m_usbconid;