diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-11-15 21:55:34 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-11-15 21:55:34 +0100 |
commit | dec5421ca2cb5ac9e77ce96507d0285a6b0fcfee (patch) | |
tree | d8a93441f1ed6f4c21f5e483fa42d5fe7f97b1eb | |
parent | af766ae10eb10685bfd81124738b167294b7a8f2 (diff) | |
download | rockbox-dec5421ca2cb5ac9e77ce96507d0285a6b0fcfee.tar.gz rockbox-dec5421ca2cb5ac9e77ce96507d0285a6b0fcfee.zip |
rbutil: Rework server info data handling.
Return status as int, not as string, and provide a separate function for
converting to string. This allows to filter based on the actual status,
not a (localized) status string, which is more robust.
Fix a regression that made players with missing status value show up as
retired.
Change-Id: I15f83ae0df484199b1b3b5b95069db8b4d425987
-rw-r--r-- | rbutil/rbutilqt/base/serverinfo.cpp | 28 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/gui/selectiveinstallwidget.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/test/test-serverinfo.cpp | 8 |
5 files changed, 21 insertions, 23 deletions
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp index 84aa89039d..88c8d955fe 100644 --- a/rbutil/rbutilqt/base/serverinfo.cpp +++ b/rbutil/rbutilqt/base/serverinfo.cpp | |||
@@ -27,18 +27,19 @@ static QSettings* serverSettings = nullptr; | |||
27 | const static struct { | 27 | const static struct { |
28 | ServerInfo::ServerInfos info; | 28 | ServerInfo::ServerInfos info; |
29 | const char* name; | 29 | const char* name; |
30 | const char* def; | ||
30 | } ServerInfoList[] = { | 31 | } ServerInfoList[] = { |
31 | { ServerInfo::CurReleaseVersion, "release/:platform:" }, | 32 | { ServerInfo::CurReleaseVersion, "release/:platform:", "" }, |
32 | { ServerInfo::CurReleaseUrl, "release/:platform:" }, | 33 | { ServerInfo::CurReleaseUrl, "release/:platform:", "" }, |
33 | { ServerInfo::RelCandidateVersion, "release-candidate/:platform:" }, | 34 | { ServerInfo::RelCandidateVersion, "release-candidate/:platform:", "" }, |
34 | { ServerInfo::RelCandidateUrl, "release-candidate/:platform:" }, | 35 | { ServerInfo::RelCandidateUrl, "release-candidate/:platform:", "" }, |
35 | { ServerInfo::CurStatus, "status/:platform:" }, | 36 | { ServerInfo::CurStatus, "status/:platform:", "-1" }, |
36 | { ServerInfo::ManualPdfUrl, "" }, | 37 | { ServerInfo::ManualPdfUrl, "", "" }, |
37 | { ServerInfo::ManualHtmlUrl, "" }, | 38 | { ServerInfo::ManualHtmlUrl, "", "" }, |
38 | { ServerInfo::ManualZipUrl, "" }, | 39 | { ServerInfo::ManualZipUrl, "", "" }, |
39 | { ServerInfo::BleedingRevision, "bleeding/rev" }, | 40 | { ServerInfo::BleedingRevision, "bleeding/rev", "" }, |
40 | { ServerInfo::BleedingDate, "bleeding/timestamp" }, | 41 | { ServerInfo::BleedingDate, "bleeding/timestamp", "" }, |
41 | { ServerInfo::CurDevelUrl, "" }, | 42 | { ServerInfo::CurDevelUrl, "", "" }, |
42 | }; | 43 | }; |
43 | 44 | ||
44 | QMap<QString, QVariant> ServerInfo::serverInfos; | 45 | QMap<QString, QVariant> ServerInfo::serverInfos; |
@@ -73,13 +74,10 @@ QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform) | |||
73 | // get value | 74 | // get value |
74 | QVariant value = QString(); | 75 | QVariant value = QString(); |
75 | if(!s.isEmpty() && serverSettings) | 76 | if(!s.isEmpty() && serverSettings) |
76 | value = serverSettings->value(s, ""); | 77 | value = serverSettings->value(s, ServerInfoList[i].def); |
77 | 78 | ||
78 | // depending on the actual value we need more replacements. | 79 | // depending on the actual value we need more replacements. |
79 | switch(info) { | 80 | switch(info) { |
80 | case ServerInfo::CurStatus: | ||
81 | value = ServerInfo::statusToString(value.toInt()); | ||
82 | break; | ||
83 | case CurReleaseVersion: | 81 | case CurReleaseVersion: |
84 | case RelCandidateVersion: | 82 | case RelCandidateVersion: |
85 | value = value.toStringList().at(0); | 83 | value = value.toStringList().at(0); |
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index d18f438801..d4457a34ed 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -386,8 +386,8 @@ void Config::setDevices() | |||
386 | // construct display name | 386 | // construct display name |
387 | QString curname = SystemInfo::platformValue( | 387 | QString curname = SystemInfo::platformValue( |
388 | SystemInfo::Name, platformList.at(it)).toString() + | 388 | SystemInfo::Name, platformList.at(it)).toString() + |
389 | " (" +ServerInfo::platformValue( | 389 | " (" + ServerInfo::statusToString(ServerInfo::platformValue( |
390 | ServerInfo::CurStatus, platformList.at(it)).toString() +")"; | 390 | ServerInfo::CurStatus, platformList.at(it)).toInt()) +")"; |
391 | LOG_INFO() << "add supported device:" << brands.at(c) << curname; | 391 | LOG_INFO() << "add supported device:" << brands.at(c) << curname; |
392 | w2 = new QTreeWidgetItem(w, QStringList(curname)); | 392 | w2 = new QTreeWidgetItem(w, QStringList(curname)); |
393 | w2->setData(0, Qt::UserRole, platformList.at(it)); | 393 | w2->setData(0, Qt::UserRole, platformList.at(it)); |
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp index 065a139436..f875844c9c 100644 --- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp +++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp | |||
@@ -93,7 +93,7 @@ void SelectiveInstallWidget::updateVersion(void) | |||
93 | m_versions.clear(); | 93 | m_versions.clear(); |
94 | m_versions.insert("release", ServerInfo::platformValue(ServerInfo::CurReleaseVersion).toString()); | 94 | m_versions.insert("release", ServerInfo::platformValue(ServerInfo::CurReleaseVersion).toString()); |
95 | // Don't populate RC or development selections if target has been retired. | 95 | // Don't populate RC or development selections if target has been retired. |
96 | if (ServerInfo::platformValue(ServerInfo::CurStatus) != tr("Stable (Retired)")) { | 96 | if (ServerInfo::platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) { |
97 | m_versions.insert("development", ServerInfo::platformValue(ServerInfo::BleedingRevision).toString()); | 97 | m_versions.insert("development", ServerInfo::platformValue(ServerInfo::BleedingRevision).toString()); |
98 | m_versions.insert("rc", ServerInfo::platformValue(ServerInfo::RelCandidateVersion).toString()); | 98 | m_versions.insert("rc", ServerInfo::platformValue(ServerInfo::RelCandidateVersion).toString()); |
99 | } | 99 | } |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index ae28ee4e70..0fb2ba562e 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -408,7 +408,7 @@ void RbUtilQt::updateDevice() | |||
408 | QString brand = SystemInfo::platformValue(SystemInfo::Brand).toString(); | 408 | QString brand = SystemInfo::platformValue(SystemInfo::Brand).toString(); |
409 | QString name | 409 | QString name |
410 | = QString("%1 (%2)").arg(SystemInfo::platformValue(SystemInfo::Name).toString(), | 410 | = QString("%1 (%2)").arg(SystemInfo::platformValue(SystemInfo::Name).toString(), |
411 | ServerInfo::platformValue(ServerInfo::CurStatus).toString()); | 411 | ServerInfo::statusToString(ServerInfo::platformValue(ServerInfo::CurStatus).toInt())); |
412 | ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name)); | 412 | ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name)); |
413 | 413 | ||
414 | QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); | 414 | QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); |
diff --git a/rbutil/rbutilqt/test/test-serverinfo.cpp b/rbutil/rbutilqt/test/test-serverinfo.cpp index 9aa8306e50..bda939676c 100644 --- a/rbutil/rbutilqt/test/test-serverinfo.cpp +++ b/rbutil/rbutilqt/test/test-serverinfo.cpp | |||
@@ -65,21 +65,21 @@ struct testvector { | |||
65 | const struct testvector testdata[] = | 65 | const struct testvector testdata[] = |
66 | { | 66 | { |
67 | { "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" }, | 67 | { "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" }, |
68 | { "archosfmrecorder", ServerInfo::CurStatus, "Stable" }, | 68 | { "archosfmrecorder", ServerInfo::CurStatus, "3" }, |
69 | { "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" }, | 69 | { "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" }, |
70 | { "iaudiom3", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" }, | 70 | { "iaudiom3", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" }, |
71 | { "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" }, | 71 | { "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" }, |
72 | { "sansae200", ServerInfo::CurReleaseUrl, "https://unittest/release/3.11.2/rockbox-sansae200-3.11.2.zip" }, | 72 | { "sansae200", ServerInfo::CurReleaseUrl, "https://unittest/release/3.11.2/rockbox-sansae200-3.11.2.zip" }, |
73 | { "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" }, | 73 | { "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" }, |
74 | { "iriverh100", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" }, | 74 | { "iriverh100", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" }, |
75 | { "iriverh100", ServerInfo::CurStatus, "Unstable" }, | 75 | { "iriverh100", ServerInfo::CurStatus, "2" }, |
76 | { "iriverh100", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iriverh100.zip" }, | 76 | { "iriverh100", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iriverh100.zip" }, |
77 | { "iriverh300", ServerInfo::CurReleaseVersion, "" }, | 77 | { "iriverh300", ServerInfo::CurReleaseVersion, "" }, |
78 | { "iriverh300", ServerInfo::CurReleaseUrl, "" }, | 78 | { "iriverh300", ServerInfo::CurReleaseUrl, "" }, |
79 | { "iriverh300", ServerInfo::CurStatus, "Unusable" }, | 79 | { "iriverh300", ServerInfo::CurStatus, "1" }, |
80 | { "iriverh10", ServerInfo::CurReleaseVersion, "" }, | 80 | { "iriverh10", ServerInfo::CurReleaseVersion, "" }, |
81 | { "iriverh10", ServerInfo::CurReleaseUrl, "" }, | 81 | { "iriverh10", ServerInfo::CurReleaseUrl, "" }, |
82 | { "iriverh10", ServerInfo::CurStatus, "Stable (Retired)" }, | 82 | { "iriverh10", ServerInfo::CurStatus, "0" }, |
83 | { "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" }, | 83 | { "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" }, |
84 | { "gigabeatfx", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" }, | 84 | { "gigabeatfx", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" }, |
85 | { "archosfmrecorder", ServerInfo::RelCandidateVersion, "f9dce96" }, | 85 | { "archosfmrecorder", ServerInfo::RelCandidateVersion, "f9dce96" }, |