rbutil:let autodetection::detectUsb also use the rbsettings object.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16952 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Wenger 2008-04-03 20:05:13 +00:00
parent 8143f49876
commit 1363881148
5 changed files with 61 additions and 25 deletions

View file

@ -256,32 +256,11 @@ QString Autodetection::resolveMountPoint(QString device)
*/
bool Autodetection::detectUsb()
{
// autodetection uses the buildin device settings only
QSettings dev(":/ini/rbutil.ini", QSettings::IniFormat, this);
// get a list of ID -> target name
QStringList platforms;
dev.beginGroup("platforms");
platforms = dev.childKeys();
dev.endGroup();
// usbids holds the mapping in the form
// ((VID<<16)|(PID)), targetname
// the ini file needs to hold the IDs as hex values.
QMap<int, QString> usbids;
QMap<int, QString> usberror;
for(int i = 0; i < platforms.size(); i++) {
dev.beginGroup("platforms");
QString target = dev.value(platforms.at(i)).toString();
dev.endGroup();
dev.beginGroup(target);
if(!dev.value("usbid").toString().isEmpty())
usbids.insert(dev.value("usbid").toString().toInt(0, 16), target);
if(!dev.value("usberror").toString().isEmpty())
usberror.insert(dev.value("usberror").toString().toInt(0, 16), target);
dev.endGroup();
}
QMap<int, QString> usbids = settings->usbIdMap();
QMap<int, QString> usberror = settings->usbIdErrorMap();
// usb pid detection
#if defined(Q_OS_LINUX) | defined(Q_OS_MACX)

View file

@ -22,6 +22,7 @@
#define AUTODETECTION_H_
#include <QtCore>
#include "rbsettings.h"
extern "C" {
// Ipodpatcher
@ -36,6 +37,8 @@ class Autodetection :public QObject
public:
Autodetection(QObject* parent=0);
void setSettings(RbSettings* sett) {settings = sett;}
bool detect();
QString getDevice() {return m_device;}
@ -52,6 +55,7 @@ private:
QString m_mountpoint;
QString m_errdev;
QList<int> m_usbconid;
RbSettings* settings;
};

View file

@ -489,6 +489,7 @@ void Config::setCache(QString c)
void Config::autodetect()
{
Autodetection detector(this);
detector.setSettings(settings);
if(detector.detect()) //let it detect
{

View file

@ -410,6 +410,55 @@ QString RbSettings::brand(QString plattform)
return brand;
}
QMap<int, QString> RbSettings::usbIdMap()
{
QMap<int, QString> map;
// get a list of ID -> target name
QStringList platforms;
devices->beginGroup("platforms");
platforms = devices->childKeys();
devices->endGroup();
for(int i = 0; i < platforms.size(); i++)
{
devices->beginGroup("platforms");
QString target = devices->value(platforms.at(i)).toString();
devices->endGroup();
devices->beginGroup(target);
if(!devices->value("usbid").toString().isEmpty())
map.insert(devices->value("usbid").toString().toInt(0, 16), target);
devices->endGroup();
}
return map;
}
QMap<int, QString> RbSettings::usbIdErrorMap()
{
QMap<int, QString> map;
// get a list of ID -> target name
QStringList platforms;
devices->beginGroup("platforms");
platforms = devices->childKeys();
devices->endGroup();
for(int i = 0; i < platforms.size(); i++)
{
devices->beginGroup("platforms");
QString target = devices->value(platforms.at(i)).toString();
devices->endGroup();
devices->beginGroup(target);
if(!devices->value("usberror").toString().isEmpty())
map.insert(devices->value("usberror").toString().toInt(0, 16), target);
devices->endGroup();
}
return map;
}
QString RbSettings::curResolution()
{
QString platform = userSettings->value("platform").toString();

View file

@ -81,6 +81,9 @@ class RbSettings : public QObject
QString name(QString plattform);
QString brand(QString plattform);
QStringList allLanguages();
QMap<int, QString> usbIdMap();
QMap<int, QString> usbIdErrorMap();
bool curNeedsBootloader();
QString curBrand();