mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
Use target string instead of target id when checking the target selection against an existing Rockbox installation. Removes the need to resolve id -> name.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20325 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5876418343
commit
3822126de8
6 changed files with 21 additions and 47 deletions
|
|
@ -372,29 +372,29 @@ QString Detect::installedVersion(QString mountpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief detects installed rockbox target id
|
/** @brief detects installed rockbox target string
|
||||||
* @return TargetId of installed rockbox, or -1 if not available
|
* @return target name (platform) of installed Rockbox, empty string on error.
|
||||||
*/
|
*/
|
||||||
int Detect::installedTargetId(QString mountpoint)
|
QString Detect::installedTarget(QString mountpoint)
|
||||||
{
|
{
|
||||||
// read rockbox-info.txt
|
// read rockbox-info.txt
|
||||||
QFile info(mountpoint +"/.rockbox/rockbox-info.txt");
|
QFile info(mountpoint +"/.rockbox/rockbox-info.txt");
|
||||||
if(!info.open(QIODevice::ReadOnly))
|
if(!info.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
return -1;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!info.atEnd())
|
while (!info.atEnd())
|
||||||
{
|
{
|
||||||
QString line = info.readLine();
|
QString line = info.readLine();
|
||||||
if(line.contains("Target id:"))
|
if(line.contains("Target:"))
|
||||||
{
|
{
|
||||||
qDebug() << line;
|
qDebug() << line;
|
||||||
return line.remove("Target id:").trimmed().toInt();
|
return line.remove("Target:").trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.close();
|
info.close();
|
||||||
return -1;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -404,7 +404,7 @@ int Detect::installedTargetId(QString mountpoint)
|
||||||
* @param targetId the targetID to check for. if it is -1 no check is done.
|
* @param targetId the targetID to check for. if it is -1 no check is done.
|
||||||
* @return string with error messages if problems occurred, empty strings if none.
|
* @return string with error messages if problems occurred, empty strings if none.
|
||||||
*/
|
*/
|
||||||
QString Detect::check(RbSettings* settings, bool permission, int targetId)
|
QString Detect::check(RbSettings* settings, bool permission)
|
||||||
{
|
{
|
||||||
QString text = "";
|
QString text = "";
|
||||||
|
|
||||||
|
|
@ -421,15 +421,12 @@ QString Detect::check(RbSettings* settings, bool permission, int targetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check TargetId
|
// Check TargetId
|
||||||
if(targetId > 0)
|
QString installed = installedTarget(settings->mountpoint());
|
||||||
|
if(!installed.isEmpty() && installed != settings->curPlatform())
|
||||||
{
|
{
|
||||||
int installedID = Detect::installedTargetId(settings->mountpoint());
|
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||||
if( installedID != -1 && installedID != targetId)
|
"Installed target: %1, selected target: %2.</li>")
|
||||||
{
|
.arg(settings->name(installed), settings->curName());
|
||||||
text += QObject::tr("<li>Target mismatch detected.\n"
|
|
||||||
"Installed target: %1, selected target: %2.</li>")
|
|
||||||
.arg(settings->nameOfTargetId(installedID),settings->curName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!text.isEmpty())
|
if(!text.isEmpty())
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ public:
|
||||||
|
|
||||||
static QUrl systemProxy(void);
|
static QUrl systemProxy(void);
|
||||||
static QString installedVersion(QString mountpoint);
|
static QString installedVersion(QString mountpoint);
|
||||||
static int installedTargetId(QString mountpoint);
|
static QString installedTarget(QString mountpoint);
|
||||||
|
|
||||||
static QString check(RbSettings* settings, bool permission, int targetId);
|
static QString check(RbSettings* settings, bool permission);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ void Install::accept()
|
||||||
}
|
}
|
||||||
settings->sync();
|
settings->sync();
|
||||||
|
|
||||||
QString warning = Detect::check(settings, false, settings->curTargetId());
|
QString warning = Detect::check(settings, false);
|
||||||
if(!warning.isEmpty())
|
if(!warning.isEmpty())
|
||||||
{
|
{
|
||||||
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||||
|
|
|
||||||
|
|
@ -388,30 +388,6 @@ QString RbSettings::brand(QString plattform)
|
||||||
return brand;
|
return brand;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RbSettings::nameOfTargetId(int id)
|
|
||||||
{
|
|
||||||
QString result ="";
|
|
||||||
// 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("targetid").toInt() == id)
|
|
||||||
{
|
|
||||||
result = devices->value("name").toString();
|
|
||||||
}
|
|
||||||
devices->endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<int, QString> RbSettings::usbIdMap()
|
QMap<int, QString> RbSettings::usbIdMap()
|
||||||
{
|
{
|
||||||
QMap<int, QString> map;
|
QMap<int, QString> map;
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,12 @@ class RbSettings : public QObject
|
||||||
double encoderVolume(QString enc);
|
double encoderVolume(QString enc);
|
||||||
bool encoderNarrowband(QString enc);
|
bool encoderNarrowband(QString enc);
|
||||||
|
|
||||||
QStringList allPlatforms();
|
QStringList allPlatforms(void);
|
||||||
|
QStringList allLanguages(void);
|
||||||
|
|
||||||
QString name(QString plattform);
|
QString name(QString plattform);
|
||||||
QString brand(QString plattform);
|
QString brand(QString plattform);
|
||||||
QStringList allLanguages();
|
|
||||||
QString nameOfTargetId(int id);
|
|
||||||
QMap<int, QString> usbIdMap();
|
QMap<int, QString> usbIdMap();
|
||||||
QMap<int, QString> usbIdErrorMap();
|
QMap<int, QString> usbIdErrorMap();
|
||||||
QMap<int, QString> usbIdIncompatMap();
|
QMap<int, QString> usbIdIncompatMap();
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ bool RbUtilQt::installAuto()
|
||||||
|
|
||||||
// check installed Version and Target
|
// check installed Version and Target
|
||||||
QString rbVersion = Detect::installedVersion(settings->mountpoint());
|
QString rbVersion = Detect::installedVersion(settings->mountpoint());
|
||||||
QString warning = Detect::check(settings, false, settings->curTargetId());
|
QString warning = Detect::check(settings, false);
|
||||||
|
|
||||||
if(!warning.isEmpty())
|
if(!warning.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue