summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-11-28 20:47:28 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-03 22:25:12 +0100
commitb064a6cbb58a0db1a70fbac2e82242ce0c7509b1 (patch)
treec9090d367d237cbd408afbd24d5809e55a1a2653 /rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
parent78a01db47cac5fa67aeee6f1c5134f89c3e4944a (diff)
downloadrockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.tar.gz
rockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.zip
rbutil: Rework and merge player and build server info handling.
Handling the data for players from rbutil.ini and the build-info data from the server is closely related. Splitting things up into different classes only creates tightly coupling, which is unnecessary, and the need to differentiate between them in the application. Merge both classes into a single one and rework handling so the application doesn't have to deal with two separate classes anymore. Furthermore, change URL templates to use new values from build-info instead of hard coding them. Change-Id: Ica550973ce23d1559110782add52bc214eba552d
Diffstat (limited to 'rbutil/rbutilqt/gui/selectiveinstallwidget.cpp')
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.cpp152
1 files changed, 62 insertions, 90 deletions
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
index 3ac24666df..190bdb28f4 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
@@ -21,7 +21,7 @@
21#include <QFileDialog> 21#include <QFileDialog>
22#include "selectiveinstallwidget.h" 22#include "selectiveinstallwidget.h"
23#include "ui_selectiveinstallwidgetfrm.h" 23#include "ui_selectiveinstallwidgetfrm.h"
24#include "serverinfo.h" 24#include "playerbuildinfo.h"
25#include "rbsettings.h" 25#include "rbsettings.h"
26#include "rockboxinfo.h" 26#include "rockboxinfo.h"
27#include "systeminfo.h" 27#include "systeminfo.h"
@@ -71,26 +71,28 @@ SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent
71 71
72void SelectiveInstallWidget::selectedVersionChanged(int index) 72void SelectiveInstallWidget::selectedVersionChanged(int index)
73{ 73{
74 m_buildtype = static_cast<SystemInfo::BuildType>(ui.selectedVersion->itemData(index).toInt()); 74 m_buildtype = static_cast<PlayerBuildInfo::BuildType>(ui.selectedVersion->itemData(index).toInt());
75 bool voice = true; 75 bool voice = true;
76 switch(m_buildtype) { 76 switch(m_buildtype) {
77 case SystemInfo::BuildRelease: 77 case PlayerBuildInfo::TypeRelease:
78 ui.selectedDescription->setText(tr("This is the latest stable " 78 ui.selectedDescription->setText(tr("This is the latest stable "
79 "release available.")); 79 "release available."));
80 voice = true; 80 voice = true;
81 break; 81 break;
82 case SystemInfo::BuildCurrent: 82 case PlayerBuildInfo::TypeDevel:
83 ui.selectedDescription->setText(tr("The development version is " 83 ui.selectedDescription->setText(tr("The development version is "
84 "updated on every code change. Last update was on %1").arg( 84 "updated on every code change. Last update was on %1").arg(
85 ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString())); 85 PlayerBuildInfo::instance()->value(
86 PlayerBuildInfo::BuildVersion,
87 PlayerBuildInfo::TypeDevel).toString()));
86 voice = false; 88 voice = false;
87 break; 89 break;
88 case SystemInfo::BuildCandidate: 90 case PlayerBuildInfo::TypeCandidate:
89 ui.selectedDescription->setText(tr("This will eventually become the " 91 ui.selectedDescription->setText(tr("This will eventually become the "
90 "next Rockbox version. Install it to help testing.")); 92 "next Rockbox version. Install it to help testing."));
91 voice = false; 93 voice = false;
92 break; 94 break;
93 case SystemInfo::BuildDaily: 95 case PlayerBuildInfo::TypeDaily:
94 ui.selectedDescription->setText(tr("Daily updated development version.")); 96 ui.selectedDescription->setText(tr("Daily updated development version."));
95 voice = true; 97 voice = true;
96 break; 98 break;
@@ -106,8 +108,8 @@ void SelectiveInstallWidget::updateVersion(void)
106 // get some configuration values globally 108 // get some configuration values globally
107 m_mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); 109 m_mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
108 m_target = RbSettings::value(RbSettings::CurrentPlatform).toString(); 110 m_target = RbSettings::value(RbSettings::CurrentPlatform).toString();
109 m_blmethod = SystemInfo::platformValue( 111 m_blmethod = PlayerBuildInfo::instance()->value(
110 SystemInfo::BootloaderMethod, m_target).toString(); 112 PlayerBuildInfo::BootloaderMethod, m_target).toString();
111 113
112 if(m_logger != nullptr) { 114 if(m_logger != nullptr) {
113 delete m_logger; 115 delete m_logger;
@@ -115,46 +117,29 @@ void SelectiveInstallWidget::updateVersion(void)
115 } 117 }
116 118
117 // re-populate all version items 119 // re-populate all version items
118 m_versions.clear(); 120 QMap<PlayerBuildInfo::BuildType, QString> types;
119 m_versions.insert(SystemInfo::BuildRelease, ServerInfo::instance()->platformValue( 121 types[PlayerBuildInfo::TypeRelease] = tr("Stable Release (Version %1)");
120 ServerInfo::CurReleaseVersion).toString()); 122 if (PlayerBuildInfo::instance()->value(PlayerBuildInfo::BuildStatus).toInt() != STATUS_RETIRED) {
121 // Don't populate RC or development selections if target has been retired. 123 types[PlayerBuildInfo::TypeCandidate] = tr("Release Candidate (Revison %1)");
122 if (ServerInfo::instance()->platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) { 124 types[PlayerBuildInfo::TypeDaily] = tr("Daily Build (%1)");
123 m_versions.insert(SystemInfo::BuildCurrent, ServerInfo::instance()->platformValue( 125 types[PlayerBuildInfo::TypeDevel] = tr("Development Version (Revison %1)");
124 ServerInfo::BleedingRevision).toString());
125 m_versions.insert(SystemInfo::BuildCandidate, ServerInfo::instance()->platformValue(
126 ServerInfo::RelCandidateVersion).toString());
127 m_versions.insert(SystemInfo::BuildDaily, ServerInfo::instance()->platformValue(
128 ServerInfo::DailyVersion).toString());
129 } 126 }
130 127
131 ui.selectedVersion->clear(); 128 ui.selectedVersion->clear();
132 if(!m_versions[SystemInfo::BuildRelease].isEmpty()) { 129 for(auto i = types.begin(); i != types.end(); i++) {
133 ui.selectedVersion->addItem(tr("Stable Release (Version %1)").arg( 130 QString version = PlayerBuildInfo::instance()->value(
134 m_versions[SystemInfo::BuildRelease]), SystemInfo::BuildRelease); 131 PlayerBuildInfo::BuildVersion, i.key()).toString();
135 } 132 if(!version.isEmpty())
136 if(!m_versions[SystemInfo::BuildCurrent].isEmpty()) { 133 ui.selectedVersion->addItem(i.value().arg(version), i.key());
137 ui.selectedVersion->addItem(tr("Development Version (Revison %1)").arg(
138 m_versions[SystemInfo::BuildCurrent]), SystemInfo::BuildCurrent);
139 }
140 if(!m_versions[SystemInfo::BuildCandidate].isEmpty()) {
141 ui.selectedVersion->addItem(tr("Release Candidate (Revison %1)").arg(
142 m_versions[SystemInfo::BuildCandidate]), SystemInfo::BuildCandidate);
143 }
144 if(!m_versions[SystemInfo::BuildDaily].isEmpty()) {
145 ui.selectedVersion->addItem(tr("Daily Build (%1)").arg(
146 m_versions[SystemInfo::BuildDaily]), SystemInfo::BuildDaily);
147 } 134 }
148 135
149 // select previously selected version 136 // select previously selected version
150 int index = ui.selectedVersion->findData( 137 int index = ui.selectedVersion->findData(
151 static_cast<SystemInfo::BuildType>(RbSettings::value(RbSettings::Build).toInt())); 138 static_cast<PlayerBuildInfo::BuildType>(RbSettings::value(RbSettings::Build).toInt()));
152 if(index < 0) { 139 if(index < 0) {
153 if(!m_versions[SystemInfo::BuildRelease].isEmpty()) { 140 index = ui.selectedVersion->findData(PlayerBuildInfo::TypeRelease);
154 index = ui.selectedVersion->findData(SystemInfo::BuildRelease); 141 if(index < 0) {
155 } 142 index = ui.selectedVersion->findData(PlayerBuildInfo::TypeDevel);
156 else {
157 index = ui.selectedVersion->findData(SystemInfo::BuildCurrent);
158 } 143 }
159 } 144 }
160 ui.selectedVersion->setCurrentIndex(index); 145 ui.selectedVersion->setCurrentIndex(index);
@@ -295,7 +280,8 @@ void SelectiveInstallWidget::installBootloader(void)
295 // create installer 280 // create installer
296 BootloaderInstallBase *bl = 281 BootloaderInstallBase *bl =
297 BootloaderInstallHelper::createBootloaderInstaller(this, 282 BootloaderInstallHelper::createBootloaderInstaller(this,
298 SystemInfo::platformValue(SystemInfo::BootloaderMethod).toString()); 283 PlayerBuildInfo::instance()->value(
284 PlayerBuildInfo::BootloaderMethod).toString());
299 if(bl == nullptr) { 285 if(bl == nullptr) {
300 m_logger->addItem(tr("No install method known."), LOGERROR); 286 m_logger->addItem(tr("No install method known."), LOGERROR);
301 m_logger->setFinished(); 287 m_logger->setFinished();
@@ -312,15 +298,16 @@ void SelectiveInstallWidget::installBootloader(void)
312 connect(m_logger, SIGNAL(aborted()), bl, SLOT(progressAborted())); 298 connect(m_logger, SIGNAL(aborted()), bl, SLOT(progressAborted()));
313 299
314 // set bootloader filename. Do this now as installed() needs it. 300 // set bootloader filename. Do this now as installed() needs it.
315 QStringList blfile = SystemInfo::platformValue(SystemInfo::BootloaderFile).toStringList(); 301 QStringList blfile = PlayerBuildInfo::instance()->value(
302 PlayerBuildInfo::BootloaderFile).toStringList();
316 QStringList blfilepath; 303 QStringList blfilepath;
317 for(int a = 0; a < blfile.size(); a++) { 304 for(int a = 0; a < blfile.size(); a++) {
318 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() 305 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
319 + blfile.at(a)); 306 + blfile.at(a));
320 } 307 }
321 bl->setBlFile(blfilepath); 308 bl->setBlFile(blfilepath);
322 QUrl url(SystemInfo::value(SystemInfo::BootloaderUrl).toString() 309 QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString()
323 + SystemInfo::platformValue(SystemInfo::BootloaderName).toString()); 310 + PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString());
324 bl->setBlUrl(url); 311 bl->setBlUrl(url);
325 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString() 312 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
326 + "/.rockbox/rbutil.log"); 313 + "/.rockbox/rbutil.log");
@@ -340,7 +327,8 @@ void SelectiveInstallWidget::installBootloader(void)
340 else if(bl->installed() == BootloaderInstallBase::BootloaderOther 327 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
341 && bl->capabilities() & BootloaderInstallBase::Backup) 328 && bl->capabilities() & BootloaderInstallBase::Backup)
342 { 329 {
343 QString targetFolder = SystemInfo::platformValue(SystemInfo::Name).toString() 330 QString targetFolder = PlayerBuildInfo::instance()->value(
331 PlayerBuildInfo::DisplayName).toString()
344 + " Firmware Backup"; 332 + " Firmware Backup";
345 // remove invalid character(s) 333 // remove invalid character(s)
346 targetFolder.remove(QRegExp("[:/]")); 334 targetFolder.remove(QRegExp("[:/]"));
@@ -377,7 +365,7 @@ void SelectiveInstallWidget::installBootloader(void)
377 // open dialog to browse to of file 365 // open dialog to browse to of file
378 QString offile; 366 QString offile;
379 QString filter 367 QString filter
380 = SystemInfo::platformValue(SystemInfo::BootloaderFilter).toString(); 368 = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFilter).toString();
381 if(!filter.isEmpty()) { 369 if(!filter.isEmpty()) {
382 filter = tr("Bootloader files (%1)").arg(filter) + ";;"; 370 filter = tr("Bootloader files (%1)").arg(filter) + ";;";
383 } 371 }
@@ -442,23 +430,8 @@ void SelectiveInstallWidget::installRockbox(void)
442 RbSettings::setValue(RbSettings::Build, m_buildtype); 430 RbSettings::setValue(RbSettings::Build, m_buildtype);
443 RbSettings::sync(); 431 RbSettings::sync();
444 432
445 switch(m_buildtype) { 433 url = PlayerBuildInfo::instance()->value(
446 case SystemInfo::BuildRelease: 434 PlayerBuildInfo::BuildUrl, m_buildtype).toString();
447 url = ServerInfo::instance()->platformValue(
448 ServerInfo::CurReleaseUrl, m_target).toString();
449 break;
450 case SystemInfo::BuildCurrent:
451 url = ServerInfo::instance()->platformValue(
452 ServerInfo::CurDevelUrl, m_target).toString();
453 break;
454 case SystemInfo::BuildCandidate:
455 url = ServerInfo::instance()->platformValue(
456 ServerInfo::RelCandidateUrl, m_target).toString();
457 break;
458 case SystemInfo::BuildDaily:
459 url = ServerInfo::instance()->platformValue(
460 ServerInfo::DailyUrl, m_target).toString();
461 }
462 //! install build 435 //! install build
463 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); 436 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater();
464 m_zipinstaller = new ZipInstaller(this); 437 m_zipinstaller = new ZipInstaller(this);
@@ -466,7 +439,8 @@ void SelectiveInstallWidget::installRockbox(void)
466 m_zipinstaller->setLogSection("Rockbox (Base)"); 439 m_zipinstaller->setLogSection("Rockbox (Base)");
467 if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) 440 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
468 m_zipinstaller->setCache(true); 441 m_zipinstaller->setCache(true);
469 m_zipinstaller->setLogVersion(m_versions[m_buildtype]); 442 m_zipinstaller->setLogVersion(PlayerBuildInfo::instance()->value(
443 PlayerBuildInfo::BuildVersion, m_buildtype).toString());
470 m_zipinstaller->setMountPoint(m_mountpoint); 444 m_zipinstaller->setMountPoint(m_mountpoint);
471 445
472 connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); 446 connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool)));
@@ -497,7 +471,8 @@ void SelectiveInstallWidget::installFonts(void)
497 // release is empty for non-release versions (i.e. daily / current) 471 // release is empty for non-release versions (i.e. daily / current)
498 logversion = installInfo.release(); 472 logversion = installInfo.release();
499 } 473 }
500 fontsurl = SystemInfo::value(SystemInfo::FontUrl, m_buildtype).toString(); 474 fontsurl = PlayerBuildInfo::instance()->value(
475 PlayerBuildInfo::BuildFontUrl, m_buildtype).toString();
501 fontsurl.replace("%RELVERSION%", relversion); 476 fontsurl.replace("%RELVERSION%", relversion);
502 477
503 // create new zip installer 478 // create new zip installer
@@ -532,13 +507,12 @@ void SelectiveInstallWidget::installVoicefile(void)
532 QString voiceurl; 507 QString voiceurl;
533 QString logversion; 508 QString logversion;
534 QString relversion = installInfo.release(); 509 QString relversion = installInfo.release();
535 if(m_buildtype != SystemInfo::BuildRelease) { 510 if(m_buildtype != PlayerBuildInfo::TypeRelease) {
536 // release is empty for non-release versions (i.e. daily / current) 511 // release is empty for non-release versions (i.e. daily / current)
537 logversion = installInfo.release(); 512 logversion = installInfo.release();
538 } 513 }
539 voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, m_buildtype).toString(); 514 voiceurl = PlayerBuildInfo::instance()->value(
540 voiceurl.replace("%RELVERSION%", m_versions[m_buildtype]); 515 PlayerBuildInfo::BuildVoiceUrl, m_buildtype).toString();
541 voiceurl.replace("%MODEL%", m_target);
542 voiceurl.replace("%LANGUAGE%", lang); 516 voiceurl.replace("%LANGUAGE%", lang);
543 517
544 // create new zip installer 518 // create new zip installer
@@ -573,18 +547,13 @@ void SelectiveInstallWidget::installManual(void)
573 QString manualurl; 547 QString manualurl;
574 QString logversion; 548 QString logversion;
575 QString relversion = installInfo.release(); 549 QString relversion = installInfo.release();
576 if(m_buildtype != SystemInfo::BuildRelease) { 550 if(m_buildtype != PlayerBuildInfo::TypeRelease) {
577 // release is empty for non-release versions (i.e. daily / current) 551 // release is empty for non-release versions (i.e. daily / current)
578 logversion = installInfo.release(); 552 logversion = installInfo.release();
579 } 553 }
580 554
581 manualurl = SystemInfo::value(SystemInfo::ManualUrl, m_buildtype).toString(); 555 manualurl = PlayerBuildInfo::instance()->value(
582 manualurl.replace("%RELVERSION%", m_versions[m_buildtype]); 556 PlayerBuildInfo::BuildManualUrl, m_buildtype).toString();
583 QString model = SystemInfo::platformValue(SystemInfo::Manual, m_target).toString();
584 if(model.isEmpty())
585 model = m_target;
586 manualurl.replace("%MODEL%", model);
587
588 if(mantype == "pdf") 557 if(mantype == "pdf")
589 manualurl.replace("%FORMAT%", ".pdf"); 558 manualurl.replace("%FORMAT%", ".pdf");
590 else 559 else
@@ -644,15 +613,15 @@ void SelectiveInstallWidget::installThemes(void)
644 613
645static const struct { 614static const struct {
646 const char *name; 615 const char *name;
647 const char *pluginpath; 616 const char *rockfile;
648 SystemInfo::SystemInfos zipurl; // add new games to SystemInfo 617 PlayerBuildInfo::BuildInfo zipurl; // add new games to PlayerBuildInfo
649} GamesList[] = { 618} GamesList[] = {
650 { "Doom", "/.rockbox/rocks/games/doom.rock", SystemInfo::DoomUrl }, 619 { "Doom", "games/doom.rock", PlayerBuildInfo::DoomUrl },
651 { "Duke3D", "/.rockbox/rocks/games/duke3d.rock", SystemInfo::Duke3DUrl }, 620 { "Duke3D", "games/duke3d.rock", PlayerBuildInfo::Duke3DUrl },
652 { "Quake", "/.rockbox/rocks/games/quake.rock", SystemInfo::QuakeUrl }, 621 { "Quake", "games/quake.rock", PlayerBuildInfo::QuakeUrl },
653 { "Puzzles fonts", "/.rockbox/rocks/games/sgt-blackbox.rock", SystemInfo::PuzzFontsUrl }, 622 { "Puzzles fonts", "games/sgt-blackbox.rock", PlayerBuildInfo::PuzzFontsUrl },
654 { "Wolf3D", "/.rockbox/rocks/games/wolf3d.rock", SystemInfo::Wolf3DUrl }, 623 { "Wolf3D", "games/wolf3d.rock", PlayerBuildInfo::Wolf3DUrl },
655 { "XWorld", "/.rockbox/rocks/games/xworld.rock", SystemInfo::XWorldUrl }, 624 { "XWorld", "games/xworld.rock", PlayerBuildInfo::XWorldUrl },
656}; 625};
657 626
658void SelectiveInstallWidget::installGamefiles(void) 627void SelectiveInstallWidget::installGamefiles(void)
@@ -665,10 +634,13 @@ void SelectiveInstallWidget::installGamefiles(void)
665 for(unsigned int i = 0; i < sizeof(GamesList) / sizeof(GamesList[0]); i++) 634 for(unsigned int i = 0; i < sizeof(GamesList) / sizeof(GamesList[0]); i++)
666 { 635 {
667 // check if installed Rockbox has this plugin. 636 // check if installed Rockbox has this plugin.
668 if(QFileInfo(m_mountpoint + GamesList[i].pluginpath).exists()) { 637 if(QFileInfo(m_mountpoint + "/.rockbox/rocks/" + GamesList[i].rockfile).exists()) {
669 gameNames.append(GamesList[i].name); 638 gameNames.append(GamesList[i].name);
670 gameUrls.append(SystemInfo::value(GamesList[i].zipurl).toString()); 639 // game URLs do not depend on the actual build type, but we need
671 LOG_INFO() << gameUrls.at(gameUrls.size() - 1); 640 // to pass it (simplifies the API, and will allow to make them
641 // type specific later if needed)
642 gameUrls.append(PlayerBuildInfo::instance()->value(
643 GamesList[i].zipurl, m_buildtype).toString());
672 } 644 }
673 } 645 }
674 646