diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-16 14:13:59 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-17 23:21:19 +0200 |
commit | 8c55ce62b9e65533619870d1e5b72612a1a16406 (patch) | |
tree | a39beb02600048177920f3b888fed5b5f3fe66be | |
parent | 1af92e5ff84bcb05d264d65d2904c4d9fe8f0d98 (diff) | |
download | rockbox-8c55ce62b9e65533619870d1e5b72612a1a16406.tar.gz rockbox-8c55ce62b9e65533619870d1e5b72612a1a16406.zip |
rbutil: Move bootloader file check to base class.
Avoid constructing the bootloader file path in the caller. Pass filename
list and mountpoint separately so it can directly fall back to the
mountpoint.
Change some functions to use references instead of creating temporary
objects.
Change-Id: I09c9d755553a32de3d02a42a8ce1fcb94f831b2a
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallbase.cpp | 25 | ||||
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallbase.h | 8 | ||||
-rw-r--r-- | utils/rbutilqt/gui/selectiveinstallwidget.cpp | 12 | ||||
-rw-r--r-- | utils/rbutilqt/rbutilqt.cpp | 15 |
4 files changed, 24 insertions, 36 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallbase.cpp b/utils/rbutilqt/base/bootloaderinstallbase.cpp index 36a15c9e1a..b49a9b933b 100644 --- a/utils/rbutilqt/base/bootloaderinstallbase.cpp +++ b/utils/rbutilqt/base/bootloaderinstallbase.cpp | |||
@@ -203,21 +203,28 @@ void BootloaderInstallBase::checkRemount() | |||
203 | 203 | ||
204 | //! @brief set list of possible bootloader files and pick the existing one. | 204 | //! @brief set list of possible bootloader files and pick the existing one. |
205 | //! @param sl list of possible bootloader files. | 205 | //! @param sl list of possible bootloader files. |
206 | void BootloaderInstallBase::setBlFile(QStringList sl) | 206 | void BootloaderInstallBase::setBlFile(const QString& mountpoint, const QStringList& sl) |
207 | { | 207 | { |
208 | // figue which of the possible bootloader filenames is correct. | 208 | if(sl.size() == 0) { |
209 | for(int a = 0; a < sl.size(); a++) { | 209 | m_blfile = mountpoint; |
210 | if(!Utils::resolvePathCase(sl.at(a)).isEmpty()) { | ||
211 | m_blfile = sl.at(a); | ||
212 | } | ||
213 | } | 210 | } |
214 | if(m_blfile.isEmpty() && sl.size() > 0) { | 211 | else { |
215 | m_blfile = sl.at(0); | 212 | for(int a = 0; a < sl.size(); a++) { |
213 | QString filename = mountpoint + sl.at(a); | ||
214 | if(!Utils::resolvePathCase(filename).isEmpty()) { | ||
215 | m_blfile = filename; | ||
216 | break; | ||
217 | } | ||
218 | } | ||
219 | // figue which of the possible bootloader filenames is correct. | ||
220 | if(m_blfile.isEmpty() && sl.size() > 0) { | ||
221 | m_blfile = mountpoint + sl.at(0); | ||
222 | } | ||
216 | } | 223 | } |
217 | } | 224 | } |
218 | 225 | ||
219 | 226 | ||
220 | bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) | 227 | bool BootloaderInstallBase::setOfFile(QString& of, const QStringList& blfile) |
221 | { | 228 | { |
222 | bool found = false; | 229 | bool found = false; |
223 | ArchiveUtil *util = nullptr; | 230 | ArchiveUtil *util = nullptr; |
diff --git a/utils/rbutilqt/base/bootloaderinstallbase.h b/utils/rbutilqt/base/bootloaderinstallbase.h index 567b4e9093..32ca637288 100644 --- a/utils/rbutilqt/base/bootloaderinstallbase.h +++ b/utils/rbutilqt/base/bootloaderinstallbase.h | |||
@@ -55,17 +55,17 @@ class BootloaderInstallBase : public QObject | |||
55 | bool backup(QString to); | 55 | bool backup(QString to); |
56 | 56 | ||
57 | //! set the different filenames and paths | 57 | //! set the different filenames and paths |
58 | void setBlFile(QStringList f); | 58 | void setBlFile(const QString& mountpoint, const QStringList& f); |
59 | void setBlUrl(QUrl u) | 59 | void setBlUrl(QUrl u) |
60 | { m_blurl = u; } | 60 | { m_blurl = u; } |
61 | void setLogfile(QString f) | 61 | void setLogfile(const QString& f) |
62 | { m_logfile = f; } | 62 | { m_logfile = f; } |
63 | bool setOfFile(QString of, QStringList blfile); | 63 | bool setOfFile(QString& of, const QStringList& blfile); |
64 | 64 | ||
65 | //! returns a port Install Hint or empty if there is none | 65 | //! returns a port Install Hint or empty if there is none |
66 | //! static and in the base class, so the installer classes dont need to | 66 | //! static and in the base class, so the installer classes dont need to |
67 | // be modified for new targets | 67 | // be modified for new targets |
68 | static QString postinstallHints(QString model); | 68 | static QString postinstallHints(const QString& model); |
69 | 69 | ||
70 | protected slots: | 70 | protected slots: |
71 | void downloadBlFinish(QNetworkReply::NetworkError error); | 71 | void downloadBlFinish(QNetworkReply::NetworkError error); |
diff --git a/utils/rbutilqt/gui/selectiveinstallwidget.cpp b/utils/rbutilqt/gui/selectiveinstallwidget.cpp index 4417a52a29..7ee7498d64 100644 --- a/utils/rbutilqt/gui/selectiveinstallwidget.cpp +++ b/utils/rbutilqt/gui/selectiveinstallwidget.cpp | |||
@@ -308,17 +308,7 @@ void SelectiveInstallWidget::installBootloader(void) | |||
308 | // set bootloader filename. Do this now as installed() needs it. | 308 | // set bootloader filename. Do this now as installed() needs it. |
309 | QStringList blfile = PlayerBuildInfo::instance()->value( | 309 | QStringList blfile = PlayerBuildInfo::instance()->value( |
310 | PlayerBuildInfo::BootloaderFile).toStringList(); | 310 | PlayerBuildInfo::BootloaderFile).toStringList(); |
311 | QStringList blfilepath; | 311 | bl->setBlFile(RbSettings::value(RbSettings::Mountpoint).toString(), blfile); |
312 | for(int a = 0; a < blfile.size(); a++) { | ||
313 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() | ||
314 | + blfile.at(a)); | ||
315 | } | ||
316 | // on devices without a bootloader file we use the mointpoint. The | ||
317 | // installer will use that to determine the correct device. | ||
318 | if(blfile.isEmpty()) { | ||
319 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()); | ||
320 | } | ||
321 | bl->setBlFile(blfilepath); | ||
322 | QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString() | 312 | QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString() |
323 | + PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString()); | 313 | + PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString()); |
324 | bl->setBlUrl(url); | 314 | bl->setBlUrl(url); |
diff --git a/utils/rbutilqt/rbutilqt.cpp b/utils/rbutilqt/rbutilqt.cpp index f3b12c63af..f5872f268e 100644 --- a/utils/rbutilqt/rbutilqt.cpp +++ b/utils/rbutilqt/rbutilqt.cpp | |||
@@ -507,18 +507,9 @@ void RbUtilQt::uninstallBootloader(void) | |||
507 | logger->setFinished(); | 507 | logger->setFinished(); |
508 | return; | 508 | return; |
509 | } | 509 | } |
510 | QStringList blfile = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFile).toStringList(); | 510 | QStringList blfile = PlayerBuildInfo::instance()->value( |
511 | QStringList blfilepath; | 511 | PlayerBuildInfo::BootloaderFile).toStringList(); |
512 | for(int a = 0; a < blfile.size(); a++) { | 512 | bl->setBlFile(RbSettings::value(RbSettings::Mountpoint).toString(), blfile); |
513 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() | ||
514 | + blfile.at(a)); | ||
515 | } | ||
516 | // on devices without a bootloader file we use the mointpoint. The | ||
517 | // installer will use that to determine the correct device. | ||
518 | if(blfile.isEmpty()) { | ||
519 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()); | ||
520 | } | ||
521 | bl->setBlFile(blfilepath); | ||
522 | bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString() | 513 | bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString() |
523 | + "/.rockbox/rbutil.log"); | 514 | + "/.rockbox/rbutil.log"); |
524 | 515 | ||