summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-10-06 10:44:56 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-10-06 13:53:09 +0200
commitc659f9979a482521950c6db74221330dc1895219 (patch)
tree5a5db5faed2dafd9a66fc31bf8187cea0eb512f3 /rbutil/rbutilqt
parent71f70112b2484e45b332fd7f2da137145aa05e9d (diff)
downloadrockbox-c659f9979a482521950c6db74221330dc1895219.tar.gz
rockbox-c659f9979a482521950c6db74221330dc1895219.zip
Allow USB IDs to be non-unique.
When retrieving USB IDs create a list of players matching to a USB ID instead of assuming only one player. This prevents non-unique IDs overwriting each other and will be used for improved autodetection later. Currently only the first ID is used during detection, and no additional IDs have been added yet. Change-Id: Ieac5594108bae708e364bd2c8df88f61fcdcbdcd
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp12
-rw-r--r--rbutil/rbutilqt/base/systeminfo.cpp19
-rw-r--r--rbutil/rbutilqt/base/systeminfo.h2
3 files changed, 21 insertions, 12 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 6427d929c4..0206502202 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -43,12 +43,12 @@ bool Autodetection::detect()
43 43
44 // Try detection via rockbox.info / rbutil.log 44 // Try detection via rockbox.info / rbutil.log
45 QStringList mounts = Utils::mountpoints(); 45 QStringList mounts = Utils::mountpoints();
46 qDebug() << "[Autodetect] paths to check:" << mounts;
46 47
47 for(int i=0; i< mounts.size();i++) 48 for(int i=0; i< mounts.size();i++)
48 { 49 {
49 // do the file checking 50 // do the file checking
50 QDir dir(mounts.at(i)); 51 QDir dir(mounts.at(i));
51 qDebug() << "[Autodetect] paths to check:" << mounts;
52 if(dir.exists()) 52 if(dir.exists())
53 { 53 {
54 // check logfile first. 54 // check logfile first.
@@ -205,9 +205,9 @@ bool Autodetection::detectUsb()
205 // usbids holds the mapping in the form 205 // usbids holds the mapping in the form
206 // ((VID<<16)|(PID)), targetname 206 // ((VID<<16)|(PID)), targetname
207 // the ini file needs to hold the IDs as hex values. 207 // the ini file needs to hold the IDs as hex values.
208 QMap<int, QString> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice); 208 QMap<int, QStringList> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice);
209 QMap<int, QString> usberror = SystemInfo::usbIdMap(SystemInfo::MapError); 209 QMap<int, QStringList> usberror = SystemInfo::usbIdMap(SystemInfo::MapError);
210 QMap<int, QString> usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible); 210 QMap<int, QStringList> usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible);
211 211
212 // usb pid detection 212 // usb pid detection
213 QList<uint32_t> attached; 213 QList<uint32_t> attached;
@@ -216,12 +216,12 @@ bool Autodetection::detectUsb()
216 int i = attached.size(); 216 int i = attached.size();
217 while(i--) { 217 while(i--) {
218 if(usbids.contains(attached.at(i))) { 218 if(usbids.contains(attached.at(i))) {
219 m_device = usbids.value(attached.at(i)); 219 m_device = usbids.value(attached.at(i)).at(0);
220 qDebug() << "[USB] detected supported player" << m_device; 220 qDebug() << "[USB] detected supported player" << m_device;
221 return true; 221 return true;
222 } 222 }
223 if(usberror.contains(attached.at(i))) { 223 if(usberror.contains(attached.at(i))) {
224 m_errdev = usberror.value(attached.at(i)); 224 m_errdev = usberror.value(attached.at(i)).at(0);
225 qDebug() << "[USB] detected problem with player" << m_errdev; 225 qDebug() << "[USB] detected problem with player" << m_errdev;
226 return true; 226 return true;
227 } 227 }
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp
index fde43d27dd..971a1196ac 100644
--- a/rbutil/rbutilqt/base/systeminfo.cpp
+++ b/rbutil/rbutilqt/base/systeminfo.cpp
@@ -159,11 +159,11 @@ QMap<QString, QStringList> SystemInfo::languages(void)
159} 159}
160 160
161 161
162QMap<int, QString> SystemInfo::usbIdMap(enum MapType type) 162QMap<int, QStringList> SystemInfo::usbIdMap(enum MapType type)
163{ 163{
164 ensureSystemInfoExists(); 164 ensureSystemInfoExists();
165 165
166 QMap<int, QString> map; 166 QMap<int, QStringList> map;
167 // get a list of ID -> target name 167 // get a list of ID -> target name
168 QStringList platforms; 168 QStringList platforms;
169 systemInfos->beginGroup("platforms"); 169 systemInfos->beginGroup("platforms");
@@ -191,9 +191,18 @@ QMap<int, QString> SystemInfo::usbIdMap(enum MapType type)
191 systemInfos->beginGroup(target); 191 systemInfos->beginGroup(target);
192 QStringList ids = systemInfos->value(t).toStringList(); 192 QStringList ids = systemInfos->value(t).toStringList();
193 int j = ids.size(); 193 int j = ids.size();
194 while(j--) 194 while(j--) {
195 map.insert(ids.at(j).toInt(0, 16), target); 195 QStringList l;
196 196 int id = ids.at(j).toInt(0, 16);
197 if(id == 0) {
198 continue;
199 }
200 if(map.keys().contains(id)) {
201 l = map.take(id);
202 }
203 l.append(target);
204 map.insert(id, l);
205 }
197 systemInfos->endGroup(); 206 systemInfos->endGroup();
198 } 207 }
199 return map; 208 return map;
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h
index 0e603f865e..5e75f36a08 100644
--- a/rbutil/rbutilqt/base/systeminfo.h
+++ b/rbutil/rbutilqt/base/systeminfo.h
@@ -81,7 +81,7 @@ class SystemInfo : public QObject
81 //! returns a map of all languages 81 //! returns a map of all languages
82 static QMap<QString, QStringList> languages(void); 82 static QMap<QString, QStringList> languages(void);
83 //! returns a map of usb-ids and their targets 83 //! returns a map of usb-ids and their targets
84 static QMap<int, QString> usbIdMap(enum MapType); 84 static QMap<int, QStringList> usbIdMap(enum MapType type);
85 //! get a value from system settings 85 //! get a value from system settings
86 static QVariant value(enum SystemInfos info); 86 static QVariant value(enum SystemInfos info);
87 //! get a value from system settings for a named platform. 87 //! get a value from system settings for a named platform.