diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-03-14 23:34:40 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-03-14 23:34:40 +0000 |
commit | 3822126de8e9c66e247b712da16abd8566cbc969 (patch) | |
tree | 0a22b5411c68db39d710833e52725ac71d1dfa74 | |
parent | 58764183439c0a7611aca2fcf344496a1589babf (diff) | |
download | rockbox-3822126de8e9c66e247b712da16abd8566cbc969.tar.gz rockbox-3822126de8e9c66e247b712da16abd8566cbc969.zip |
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
-rw-r--r-- | rbutil/rbutilqt/base/detect.cpp | 29 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/detect.h | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/install.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbsettings.cpp | 24 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbsettings.h | 7 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 2 |
6 files changed, 21 insertions, 47 deletions
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/detect.cpp index d2a65ee72f..1792febc0f 100644 --- a/rbutil/rbutilqt/base/detect.cpp +++ b/rbutil/rbutilqt/base/detect.cpp | |||
@@ -372,29 +372,29 @@ QString Detect::installedVersion(QString mountpoint) | |||
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | /** @brief detects installed rockbox target id | 375 | /** @brief detects installed rockbox target string |
376 | * @return TargetId of installed rockbox, or -1 if not available | 376 | * @return target name (platform) of installed Rockbox, empty string on error. |
377 | */ | 377 | */ |
378 | int Detect::installedTargetId(QString mountpoint) | 378 | QString Detect::installedTarget(QString mountpoint) |
379 | { | 379 | { |
380 | // read rockbox-info.txt | 380 | // read rockbox-info.txt |
381 | QFile info(mountpoint +"/.rockbox/rockbox-info.txt"); | 381 | QFile info(mountpoint +"/.rockbox/rockbox-info.txt"); |
382 | if(!info.open(QIODevice::ReadOnly)) | 382 | if(!info.open(QIODevice::ReadOnly)) |
383 | { | 383 | { |
384 | return -1; | 384 | return ""; |
385 | } | 385 | } |
386 | 386 | ||
387 | while (!info.atEnd()) | 387 | while (!info.atEnd()) |
388 | { | 388 | { |
389 | QString line = info.readLine(); | 389 | QString line = info.readLine(); |
390 | if(line.contains("Target id:")) | 390 | if(line.contains("Target:")) |
391 | { | 391 | { |
392 | qDebug() << line; | 392 | qDebug() << line; |
393 | return line.remove("Target id:").trimmed().toInt(); | 393 | return line.remove("Target:").trimmed(); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | info.close(); | 396 | info.close(); |
397 | return -1; | 397 | return ""; |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
@@ -404,7 +404,7 @@ int Detect::installedTargetId(QString mountpoint) | |||
404 | * @param targetId the targetID to check for. if it is -1 no check is done. | 404 | * @param targetId the targetID to check for. if it is -1 no check is done. |
405 | * @return string with error messages if problems occurred, empty strings if none. | 405 | * @return string with error messages if problems occurred, empty strings if none. |
406 | */ | 406 | */ |
407 | QString Detect::check(RbSettings* settings, bool permission, int targetId) | 407 | QString Detect::check(RbSettings* settings, bool permission) |
408 | { | 408 | { |
409 | QString text = ""; | 409 | QString text = ""; |
410 | 410 | ||
@@ -421,15 +421,12 @@ QString Detect::check(RbSettings* settings, bool permission, int targetId) | |||
421 | } | 421 | } |
422 | 422 | ||
423 | // Check TargetId | 423 | // Check TargetId |
424 | if(targetId > 0) | 424 | QString installed = installedTarget(settings->mountpoint()); |
425 | if(!installed.isEmpty() && installed != settings->curPlatform()) | ||
425 | { | 426 | { |
426 | int installedID = Detect::installedTargetId(settings->mountpoint()); | 427 | text += QObject::tr("<li>Target mismatch detected.\n" |
427 | if( installedID != -1 && installedID != targetId) | 428 | "Installed target: %1, selected target: %2.</li>") |
428 | { | 429 | .arg(settings->name(installed), settings->curName()); |
429 | text += QObject::tr("<li>Target mismatch detected.\n" | ||
430 | "Installed target: %1, selected target: %2.</li>") | ||
431 | .arg(settings->nameOfTargetId(installedID),settings->curName()); | ||
432 | } | ||
433 | } | 430 | } |
434 | 431 | ||
435 | if(!text.isEmpty()) | 432 | if(!text.isEmpty()) |
diff --git a/rbutil/rbutilqt/base/detect.h b/rbutil/rbutilqt/base/detect.h index 00a8daaef7..42de677eac 100644 --- a/rbutil/rbutilqt/base/detect.h +++ b/rbutil/rbutilqt/base/detect.h | |||
@@ -45,9 +45,9 @@ public: | |||
45 | 45 | ||
46 | static QUrl systemProxy(void); | 46 | static QUrl systemProxy(void); |
47 | static QString installedVersion(QString mountpoint); | 47 | static QString installedVersion(QString mountpoint); |
48 | static int installedTargetId(QString mountpoint); | 48 | static QString installedTarget(QString mountpoint); |
49 | 49 | ||
50 | static QString check(RbSettings* settings, bool permission, int targetId); | 50 | static QString check(RbSettings* settings, bool permission); |
51 | 51 | ||
52 | }; | 52 | }; |
53 | #endif | 53 | #endif |
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp index 457ea0d59f..efdc6d0513 100644 --- a/rbutil/rbutilqt/install.cpp +++ b/rbutil/rbutilqt/install.cpp | |||
@@ -133,7 +133,7 @@ void Install::accept() | |||
133 | } | 133 | } |
134 | settings->sync(); | 134 | settings->sync(); |
135 | 135 | ||
136 | QString warning = Detect::check(settings, false, settings->curTargetId()); | 136 | QString warning = Detect::check(settings, false); |
137 | if(!warning.isEmpty()) | 137 | if(!warning.isEmpty()) |
138 | { | 138 | { |
139 | if(QMessageBox::warning(this, tr("Really continue?"), warning, | 139 | if(QMessageBox::warning(this, tr("Really continue?"), warning, |
diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp index b26f86b921..5f8664e7ea 100644 --- a/rbutil/rbutilqt/rbsettings.cpp +++ b/rbutil/rbutilqt/rbsettings.cpp | |||
@@ -388,30 +388,6 @@ QString RbSettings::brand(QString plattform) | |||
388 | return brand; | 388 | return brand; |
389 | } | 389 | } |
390 | 390 | ||
391 | QString RbSettings::nameOfTargetId(int id) | ||
392 | { | ||
393 | QString result =""; | ||
394 | // get a list of ID -> target name | ||
395 | QStringList platforms; | ||
396 | devices->beginGroup("platforms"); | ||
397 | platforms = devices->childKeys(); | ||
398 | devices->endGroup(); | ||
399 | for(int i = 0; i < platforms.size(); i++) | ||
400 | { | ||
401 | devices->beginGroup("platforms"); | ||
402 | QString target = devices->value(platforms.at(i)).toString(); | ||
403 | devices->endGroup(); | ||
404 | devices->beginGroup(target); | ||
405 | if(devices->value("targetid").toInt() == id) | ||
406 | { | ||
407 | result = devices->value("name").toString(); | ||
408 | } | ||
409 | devices->endGroup(); | ||
410 | } | ||
411 | |||
412 | return result; | ||
413 | } | ||
414 | |||
415 | QMap<int, QString> RbSettings::usbIdMap() | 391 | QMap<int, QString> RbSettings::usbIdMap() |
416 | { | 392 | { |
417 | QMap<int, QString> map; | 393 | QMap<int, QString> map; |
diff --git a/rbutil/rbutilqt/rbsettings.h b/rbutil/rbutilqt/rbsettings.h index afa1900e7b..5ee4852065 100644 --- a/rbutil/rbutilqt/rbsettings.h +++ b/rbutil/rbutilqt/rbsettings.h | |||
@@ -80,11 +80,12 @@ class RbSettings : public QObject | |||
80 | double encoderVolume(QString enc); | 80 | double encoderVolume(QString enc); |
81 | bool encoderNarrowband(QString enc); | 81 | bool encoderNarrowband(QString enc); |
82 | 82 | ||
83 | QStringList allPlatforms(); | 83 | QStringList allPlatforms(void); |
84 | QStringList allLanguages(void); | ||
85 | |||
84 | QString name(QString plattform); | 86 | QString name(QString plattform); |
85 | QString brand(QString plattform); | 87 | QString brand(QString plattform); |
86 | QStringList allLanguages(); | 88 | |
87 | QString nameOfTargetId(int id); | ||
88 | QMap<int, QString> usbIdMap(); | 89 | QMap<int, QString> usbIdMap(); |
89 | QMap<int, QString> usbIdErrorMap(); | 90 | QMap<int, QString> usbIdErrorMap(); |
90 | QMap<int, QString> usbIdIncompatMap(); | 91 | QMap<int, QString> usbIdIncompatMap(); |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 77500798b1..9ce8cb58f4 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -518,7 +518,7 @@ bool RbUtilQt::installAuto() | |||
518 | 518 | ||
519 | // check installed Version and Target | 519 | // check installed Version and Target |
520 | QString rbVersion = Detect::installedVersion(settings->mountpoint()); | 520 | QString rbVersion = Detect::installedVersion(settings->mountpoint()); |
521 | QString warning = Detect::check(settings, false, settings->curTargetId()); | 521 | QString warning = Detect::check(settings, false); |
522 | 522 | ||
523 | if(!warning.isEmpty()) | 523 | if(!warning.isEmpty()) |
524 | { | 524 | { |