diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-08-10 19:20:53 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-08-10 19:20:53 +0000 |
commit | 84ced00bbd1b86585de508176fa63f09a2faf79b (patch) | |
tree | 4f000e70d6b487b102186be58bb2b0414280adb1 | |
parent | ad7dab615f668274bc35fca5375d1d2facf4f1b8 (diff) | |
download | rockbox-84ced00bbd1b86585de508176fa63f09a2faf79b.tar.gz rockbox-84ced00bbd1b86585de508176fa63f09a2faf79b.zip |
Simplify and cleanup rockbox-info.txt handling.
Simplify RockboxInfo file handling. Remove Detect::installedVersion() and Detect::installedTarget(), as those became wrappers around RockboxInfo without functionality.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22237 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/base/autodetection.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/detect.cpp | 33 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/detect.h | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 19 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/utils.h | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/voicefile.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/install.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 10 |
8 files changed, 23 insertions, 53 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index 386b39057a..5bab1d62d3 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp | |||
@@ -92,7 +92,7 @@ bool Autodetection::detect() | |||
92 | 92 | ||
93 | // check rockbox-info.txt afterwards. | 93 | // check rockbox-info.txt afterwards. |
94 | RockboxInfo info(mounts.at(i)); | 94 | RockboxInfo info(mounts.at(i)); |
95 | if(info.open()) | 95 | if(info.success()) |
96 | { | 96 | { |
97 | if(m_device.isEmpty()) | 97 | if(m_device.isEmpty()) |
98 | { | 98 | { |
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/detect.cpp index 9eaa1c9bb7..3b8547bdaf 100644 --- a/rbutil/rbutilqt/base/detect.cpp +++ b/rbutil/rbutilqt/base/detect.cpp | |||
@@ -396,36 +396,6 @@ QUrl Detect::systemProxy(void) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | /** @brief detects the installed Rockbox version | ||
400 | * @return QString with version. Empty if not aviable | ||
401 | */ | ||
402 | QString Detect::installedVersion(QString mountpoint) | ||
403 | { | ||
404 | RockboxInfo info(mountpoint); | ||
405 | if(!info.open()) | ||
406 | { | ||
407 | return ""; | ||
408 | } | ||
409 | |||
410 | return info.version(); | ||
411 | } | ||
412 | |||
413 | |||
414 | /** @brief detects installed rockbox target string | ||
415 | * @return target name (platform) of installed Rockbox, empty string on error. | ||
416 | */ | ||
417 | QString Detect::installedTarget(QString mountpoint) | ||
418 | { | ||
419 | RockboxInfo info(mountpoint); | ||
420 | if(!info.open()) | ||
421 | { | ||
422 | return ""; | ||
423 | } | ||
424 | |||
425 | return info.target(); | ||
426 | } | ||
427 | |||
428 | |||
429 | /** @brief checks different Enviroment things. Ask if user wants to continue. | 399 | /** @brief checks different Enviroment things. Ask if user wants to continue. |
430 | * @param settings A pointer to rbutils settings class | 400 | * @param settings A pointer to rbutils settings class |
431 | * @param permission if it should check for permission | 401 | * @param permission if it should check for permission |
@@ -449,7 +419,8 @@ QString Detect::check(bool permission) | |||
449 | } | 419 | } |
450 | 420 | ||
451 | // Check TargetId | 421 | // Check TargetId |
452 | QString installed = installedTarget(RbSettings::value(RbSettings::Mountpoint).toString()); | 422 | RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString()); |
423 | QString installed = rbinfo.target(); | ||
453 | if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString()) | 424 | if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString()) |
454 | { | 425 | { |
455 | text += QObject::tr("<li>Target mismatch detected.\n" | 426 | text += QObject::tr("<li>Target mismatch detected.\n" |
diff --git a/rbutil/rbutilqt/base/detect.h b/rbutil/rbutilqt/base/detect.h index 96c0696467..fe4b01f1a1 100644 --- a/rbutil/rbutilqt/base/detect.h +++ b/rbutil/rbutilqt/base/detect.h | |||
@@ -45,8 +45,6 @@ public: | |||
45 | static QMap<uint32_t, QString> listUsbDevices(void); | 45 | static QMap<uint32_t, QString> listUsbDevices(void); |
46 | 46 | ||
47 | static QUrl systemProxy(void); | 47 | static QUrl systemProxy(void); |
48 | static QString installedVersion(QString mountpoint); | ||
49 | static QString installedTarget(QString mountpoint); | ||
50 | 48 | ||
51 | static QString check(bool permission); | 49 | static QString check(bool permission); |
52 | 50 | ||
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 966ce335ea..a1b6e2bd0e 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -161,17 +161,14 @@ QString findExecutable(QString name) | |||
161 | 161 | ||
162 | RockboxInfo::RockboxInfo(QString mountpoint) | 162 | RockboxInfo::RockboxInfo(QString mountpoint) |
163 | { | 163 | { |
164 | m_path = mountpoint +"/.rockbox/rockbox-info.txt"; | 164 | qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint; |
165 | } | 165 | QFile file(mountpoint + "/.rockbox/rockbox-info.txt"); |
166 | 166 | m_success = false; | |
167 | bool RockboxInfo::open() | ||
168 | { | ||
169 | QFile file(m_path); | ||
170 | if(!file.exists()) | 167 | if(!file.exists()) |
171 | return false; | 168 | return; |
172 | 169 | ||
173 | if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) | 170 | if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) |
174 | return false; | 171 | return; |
175 | 172 | ||
176 | // read file contents | 173 | // read file contents |
177 | while (!file.atEnd()) | 174 | while (!file.atEnd()) |
@@ -195,7 +192,9 @@ bool RockboxInfo::open() | |||
195 | m_targetid = line.remove("Target id:").trimmed(); | 192 | m_targetid = line.remove("Target id:").trimmed(); |
196 | } | 193 | } |
197 | } | 194 | } |
198 | 195 | ||
199 | file.close(); | 196 | file.close(); |
200 | return true; | 197 | m_success = true; |
198 | return; | ||
201 | } | 199 | } |
200 | |||
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h index 49fca85df6..9113eba7df 100644 --- a/rbutil/rbutilqt/base/utils.h +++ b/rbutil/rbutilqt/base/utils.h | |||
@@ -35,18 +35,18 @@ class RockboxInfo | |||
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | RockboxInfo(QString mountpoint); | 37 | RockboxInfo(QString mountpoint); |
38 | bool open(); | ||
39 | 38 | ||
40 | QString version() {return m_version;} | 39 | QString version() {return m_version;} |
41 | QString features(){return m_features;} | 40 | QString features(){return m_features;} |
42 | QString targetID() {return m_targetid;} | 41 | QString targetID() {return m_targetid;} |
43 | QString target() {return m_target;} | 42 | QString target() {return m_target;} |
43 | bool success() { return m_success; } | ||
44 | private: | 44 | private: |
45 | QString m_path; | ||
46 | QString m_version; | 45 | QString m_version; |
47 | QString m_features; | 46 | QString m_features; |
48 | QString m_targetid; | 47 | QString m_targetid; |
49 | QString m_target; | 48 | QString m_target; |
49 | bool m_success; | ||
50 | }; | 50 | }; |
51 | 51 | ||
52 | #endif | 52 | #endif |
diff --git a/rbutil/rbutilqt/base/voicefile.cpp b/rbutil/rbutilqt/base/voicefile.cpp index cacd0c437a..6eff308cd1 100644 --- a/rbutil/rbutilqt/base/voicefile.cpp +++ b/rbutil/rbutilqt/base/voicefile.cpp | |||
@@ -47,7 +47,7 @@ bool VoiceFileCreator::createVoiceFile() | |||
47 | 47 | ||
48 | // read rockbox-info.txt | 48 | // read rockbox-info.txt |
49 | RockboxInfo info(m_mountpoint); | 49 | RockboxInfo info(m_mountpoint); |
50 | if(!info.open()) | 50 | if(!info.success()) |
51 | { | 51 | { |
52 | emit logItem(tr("could not find rockbox-info.txt"),LOGERROR); | 52 | emit logItem(tr("could not find rockbox-info.txt"),LOGERROR); |
53 | emit done(true); | 53 | emit done(true); |
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp index e410222636..34a4da17e4 100644 --- a/rbutil/rbutilqt/install.cpp +++ b/rbutil/rbutilqt/install.cpp | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "rbzip.h" | 22 | #include "rbzip.h" |
23 | #include "detect.h" | 23 | #include "detect.h" |
24 | #include "rbsettings.h" | 24 | #include "rbsettings.h" |
25 | #include "utils.h" | ||
25 | 26 | ||
26 | Install::Install(QWidget *parent) : QDialog(parent) | 27 | Install::Install(QWidget *parent) : QDialog(parent) |
27 | { | 28 | { |
@@ -34,7 +35,8 @@ Install::Install(QWidget *parent) : QDialog(parent) | |||
34 | connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int))); | 35 | connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int))); |
35 | 36 | ||
36 | //! check if rockbox is already installed | 37 | //! check if rockbox is already installed |
37 | QString version = Detect::installedVersion(RbSettings::value(RbSettings::Mountpoint).toString()); | 38 | RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString()); |
39 | QString version = rbinfo.version(); | ||
38 | 40 | ||
39 | if(version != "") | 41 | if(version != "") |
40 | { | 42 | { |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 39dd65348c..f7ddb37e4c 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -526,13 +526,12 @@ bool RbUtilQt::installAuto() | |||
526 | buildInfo.close(); | 526 | buildInfo.close(); |
527 | 527 | ||
528 | // check installed Version and Target | 528 | // check installed Version and Target |
529 | QString rbVersion = Detect::installedVersion(RbSettings::value(RbSettings::Mountpoint).toString()); | ||
530 | QString warning = Detect::check(false); | 529 | QString warning = Detect::check(false); |
531 | |||
532 | if(!warning.isEmpty()) | 530 | if(!warning.isEmpty()) |
533 | { | 531 | { |
534 | if(QMessageBox::warning(this, tr("Really continue?"), warning, | 532 | if(QMessageBox::warning(this, tr("Really continue?"), warning, |
535 | QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) == QMessageBox::Abort) | 533 | QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) |
534 | == QMessageBox::Abort) | ||
536 | { | 535 | { |
537 | logger->addItem(tr("Aborted!"), LOGERROR); | 536 | logger->addItem(tr("Aborted!"), LOGERROR); |
538 | logger->setFinished(); | 537 | logger->setFinished(); |
@@ -541,7 +540,8 @@ bool RbUtilQt::installAuto() | |||
541 | } | 540 | } |
542 | 541 | ||
543 | // check version | 542 | // check version |
544 | if(rbVersion != "") | 543 | RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString()); |
544 | if(rbinfo.version() != "") | ||
545 | { | 545 | { |
546 | if(QMessageBox::question(this, tr("Installed Rockbox detected"), | 546 | if(QMessageBox::question(this, tr("Installed Rockbox detected"), |
547 | tr("Rockbox installation detected. Do you want to backup first?"), | 547 | tr("Rockbox installation detected. Do you want to backup first?"), |
@@ -549,7 +549,7 @@ bool RbUtilQt::installAuto() | |||
549 | { | 549 | { |
550 | logger->addItem(tr("Starting backup..."),LOGINFO); | 550 | logger->addItem(tr("Starting backup..."),LOGINFO); |
551 | QString backupName = RbSettings::value(RbSettings::Mountpoint).toString() | 551 | QString backupName = RbSettings::value(RbSettings::Mountpoint).toString() |
552 | + "/.backup/rockbox-backup-" + rbVersion + ".zip"; | 552 | + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip"; |
553 | 553 | ||
554 | //! create dir, if it doesnt exist | 554 | //! create dir, if it doesnt exist |
555 | QFileInfo backupFile(backupName); | 555 | QFileInfo backupFile(backupName); |