summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/autodetection.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-04-06 21:15:05 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-04-09 22:39:13 +0200
commite30b3d84e8d744098df13617fceed562bcdb8462 (patch)
tree707d86f86098b287de15e586dc4fb6d11f27127a /rbutil/rbutilqt/base/autodetection.cpp
parente6c0bd035046e6b97f408fcff14879a2fba6c9e6 (diff)
downloadrockbox-e30b3d84e8d744098df13617fceed562bcdb8462.tar.gz
rockbox-e30b3d84e8d744098df13617fceed562bcdb8462.tar.bz2
rockbox-e30b3d84e8d744098df13617fceed562bcdb8462.zip
Change autodetection result to a list.
Both autodetection functionality and the configuration dialog assumed detection to only return one found device. This isn't necessarily true, especially since some players can be detected but detecting their mountpoint might be ambiguous (only if no previous Rockbox installation is present). Instead of returning individual results (found "ok" player, found "error" player etc.) return a list containing an entry for each player. Current autodetection code will never return more than one entry since it doesn't handle multiple devices yet, and the configuration dialog will show an error if multiple devices are found. Thus there is no user visible change yet. Both autodetection and configuration dialog can now get extended to handle multiple devices. Change-Id: I79b763dbd6e7111783194bcc22ab7cc06a4061c1
Diffstat (limited to 'rbutil/rbutilqt/base/autodetection.cpp')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index fa2fe63cb8..de3765ffb1 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -38,6 +38,7 @@ bool Autodetection::detect()
m_device = "";
m_mountpoint = "";
m_errdev = "";
+ m_usberr = "";
detectUsb();
@@ -146,7 +147,8 @@ bool Autodetection::detect()
// 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;
+ else
+ m_device = ipod.targetname;
// since resolveMountPoint is doing exact matches we need to select
// the correct partition.
QString mp(ipod.diskname);
@@ -218,8 +220,8 @@ bool Autodetection::detectUsb()
return true;
}
if(usberror.contains(attached.at(i))) {
- m_errdev = usberror.value(attached.at(i)).at(0);
- qDebug() << "[USB] detected problem with player" << m_errdev;
+ m_usberr = usberror.value(attached.at(i)).at(0);
+ qDebug() << "[USB] detected problem with player" << m_usberr;
return true;
}
QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
@@ -233,6 +235,37 @@ bool Autodetection::detectUsb()
}
+QList<struct Autodetection::Detected> Autodetection::detected(void)
+{
+ struct Detected d;
+
+ m_detected.clear();
+ if(!m_device.isEmpty()) {
+ d.device = m_device;
+ d.mountpoint = m_mountpoint;
+ d.status = PlayerOk;
+ m_detected.append(d);
+ }
+ else if(!m_errdev.isEmpty()) {
+ d.device = m_errdev;
+ d.status = PlayerWrongFilesystem;
+ m_detected.append(d);
+ }
+ else if(!m_usberr.isEmpty()) {
+ d.device = m_usberr;
+ d.status = PlayerMtpMode;
+ m_detected.append(d);
+ }
+ else if(!m_incompat.isEmpty()) {
+ d.device = m_incompat;
+ d.status = PlayerIncompatible;
+ m_detected.append(d);
+ }
+
+ return m_detected;
+}
+
+
bool Autodetection::detectAjbrec(QString root)
{
QFile f(root + "/ajbrec.ajz");