summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-11-14 16:23:56 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-11-14 16:42:29 +0100
commit2509def164ee7f4aecbe6a786df57140f19e35f2 (patch)
tree63a7396e1b94482f9f05c3f3abf6c7cd77e10d26 /rbutil/rbutilqt/base
parent440083af872da43c116c5374d8e1511cef65abf2 (diff)
downloadrockbox-2509def164ee7f4aecbe6a786df57140f19e35f2.tar.gz
rockbox-2509def164ee7f4aecbe6a786df57140f19e35f2.zip
rbutil: Rework player configuration.
- Split internal configuration into player specific and common parts. Always require passing the player for player specific data instead of implicitly assuming the currently selected one; only use the currently selected one if the player name is explicitly passed as empty. - Similarly adjust handling of server info data; prepare for splitting into build type specific values so the naming becomes cleaner. Change-Id: I894e694f83bd9fe2d22ad46b3f8f7df3e2c68033
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp2
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstalls5l.cpp2
-rw-r--r--rbutil/rbutilqt/base/rbsettings.cpp2
-rw-r--r--rbutil/rbutilqt/base/serverinfo.cpp56
-rw-r--r--rbutil/rbutilqt/base/serverinfo.h6
-rw-r--r--rbutil/rbutilqt/base/systeminfo.cpp21
-rw-r--r--rbutil/rbutilqt/base/systeminfo.h5
-rw-r--r--rbutil/rbutilqt/base/talkgenerator.cpp3
-rw-r--r--rbutil/rbutilqt/base/utils.cpp6
9 files changed, 48 insertions, 55 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 456d803115..7c69b3a59b 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -108,7 +108,7 @@ void Autodetection::detectUsb()
LOG_WARNING() << "[USB] detected problem with player" << d.device;
}
QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
- if(!SystemInfo::platformValue(idstring, SystemInfo::CurName).toString().isEmpty()) {
+ if(!SystemInfo::platformValue(SystemInfo::CurName, idstring).toString().isEmpty()) {
struct Detected d;
d.status = PlayerIncompatible;
d.device = idstring;
diff --git a/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp b/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
index ef1ab1077c..bd7ed6492d 100644
--- a/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
@@ -408,7 +408,7 @@ BootloaderInstallBase::BootloaderType BootloaderInstallS5l::installed(void)
QString logfile = RbSettings::value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log";
QSettings s(logfile, QSettings::IniFormat, this);
- QString section = SystemInfo::value(
+ QString section = SystemInfo::platformValue(
SystemInfo::CurBootloaderName).toString().section('/', -1);
rbblInstalled = s.contains("Bootloader/" + section);
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp
index 854883c4dd..4167a8659c 100644
--- a/rbutil/rbutilqt/base/rbsettings.cpp
+++ b/rbutil/rbutilqt/base/rbsettings.cpp
@@ -194,7 +194,7 @@ QString RbSettings::constructSettingPath(QString path, QString substitute)
}
else {
path.replace(":tts:", userSettings->value("tts").toString());
- path.replace(":encoder:", SystemInfo::platformValue(platform,SystemInfo::CurEncoder).toString());
+ path.replace(":encoder:", SystemInfo::platformValue(SystemInfo::CurEncoder, platform).toString());
}
path.replace(":platform:", platform);
}
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp
index 98a94a5232..505689847d 100644
--- a/rbutil/rbutilqt/base/serverinfo.cpp
+++ b/rbutil/rbutilqt/base/serverinfo.cpp
@@ -51,9 +51,9 @@ void ServerInfo::readBuildInfo(QString file)
QSettings info(file, QSettings::IniFormat);
QString developmentRevision = info.value("bleeding/rev").toString();
- setValue(ServerInfo::BleedingRevision, developmentRevision);
+ setPlatformValue(ServerInfo::BleedingRevision, "", developmentRevision);
QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ");
- setValue(ServerInfo::BleedingDate, date.toString(Qt::ISODate));
+ setPlatformValue(ServerInfo::BleedingDate, "", date.toString(Qt::ISODate));
info.beginGroup("release");
QStringList releasekeys = info.allKeys();
@@ -135,10 +135,10 @@ void ServerInfo::readBuildInfo(QString file)
QString manualHtmlUrl = manualBaseUrl;
QString manualZipUrl = manualBaseUrl;
- QString buildservermodel = SystemInfo::platformValue(platforms.at(i),
- SystemInfo::CurBuildserverModel).toString();
- QString modelman = SystemInfo::platformValue(platforms.at(i),
- SystemInfo::CurManual).toString();
+ QString buildservermodel = SystemInfo::platformValue(
+ SystemInfo::CurBuildserverModel, platforms.at(i)).toString();
+ QString modelman = SystemInfo::platformValue(
+ SystemInfo::CurManual, platforms.at(i)).toString();
QString manualBaseName = "rockbox-";
if(modelman.isEmpty()) manualBaseName += buildservermodel;
@@ -153,45 +153,26 @@ void ServerInfo::readBuildInfo(QString file)
// set variants (if any)
for(int j = 0; j < variants.size(); ++j) {
- setPlatformValue(variants.at(j), ServerInfo::CurStatus, status);
+ setPlatformValue(ServerInfo::CurStatus, variants.at(j), status);
if(!releaseUrl.isEmpty()) {
- setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, releaseVersion);
- setPlatformValue(variants.at(j), ServerInfo::CurReleaseUrl, releaseUrl);
+ setPlatformValue(ServerInfo::CurReleaseVersion, variants.at(j), releaseVersion);
+ setPlatformValue(ServerInfo::CurReleaseUrl, variants.at(j), releaseUrl);
}
if(!relCandidateUrl.isEmpty()) {
- setPlatformValue(variants.at(j), ServerInfo::RelCandidateVersion, relCandidateVersion);
- setPlatformValue(variants.at(j), ServerInfo::RelCandidateUrl, relCandidateUrl);
+ setPlatformValue(ServerInfo::RelCandidateVersion, variants.at(j), relCandidateVersion);
+ setPlatformValue(ServerInfo::RelCandidateUrl, variants.at(j), relCandidateUrl);
}
- setPlatformValue(variants.at(j), ServerInfo::CurDevelUrl, develUrl);
+ setPlatformValue(ServerInfo::CurDevelUrl, variants.at(j), develUrl);
- setPlatformValue(variants.at(j), ServerInfo::ManualPdfUrl, manualPdfUrl);
- setPlatformValue(variants.at(j), ServerInfo::ManualHtmlUrl, manualHtmlUrl);
- setPlatformValue(variants.at(j), ServerInfo::ManualZipUrl, manualZipUrl);
+ setPlatformValue(ServerInfo::ManualPdfUrl, variants.at(j), manualPdfUrl);
+ setPlatformValue(ServerInfo::ManualHtmlUrl, variants.at(j), manualHtmlUrl);
+ setPlatformValue(ServerInfo::ManualZipUrl, variants.at(j), manualZipUrl);
}
}
}
-QVariant ServerInfo::value(enum ServerInfos info)
-{
- // locate info item
- int i = 0;
- while(ServerInfoList[i].info != info)
- i++;
-
- QString s = ServerInfoList[i].name;
- s.replace(":platform:", RbSettings::value(RbSettings::CurrentPlatform).toString());
- LOG_INFO() << "GET:" << s << serverInfos.value(s, ServerInfoList[i].def).toString();
- return serverInfos.value(s, ServerInfoList[i].def);
-}
-
-void ServerInfo::setValue(enum ServerInfos setting, QVariant value)
-{
- QString empty;
- return setPlatformValue(empty, setting, value);
-}
-
-void ServerInfo::setPlatformValue(QString platform, enum ServerInfos info, QVariant value)
+void ServerInfo::setPlatformValue(enum ServerInfos info, QString platform, QVariant value)
{
// locate setting item
int i = 0;
@@ -204,13 +185,16 @@ void ServerInfo::setPlatformValue(QString platform, enum ServerInfos info, QVari
LOG_INFO() << "SET:" << s << serverInfos.value(s).toString();
}
-QVariant ServerInfo::platformValue(QString platform, enum ServerInfos info)
+QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
{
// locate setting item
int i = 0;
while(ServerInfoList[i].info != info)
i++;
+ if(platform.isEmpty())
+ platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
+
QString s = ServerInfoList[i].name;
s.replace(":platform:", platform);
QString d = ServerInfoList[i].def;
diff --git a/rbutil/rbutilqt/base/serverinfo.h b/rbutil/rbutilqt/base/serverinfo.h
index 94b2818f73..b12a437c34 100644
--- a/rbutil/rbutilqt/base/serverinfo.h
+++ b/rbutil/rbutilqt/base/serverinfo.h
@@ -45,16 +45,14 @@ class ServerInfo : public QObject
//! read in buildinfo file
static void readBuildInfo(QString file);
- //! get a value from server info
- static QVariant value(enum ServerInfos setting);
//! get a value from server info for a named platform.
- static QVariant platformValue(QString platform, enum ServerInfos setting);
+ static QVariant platformValue(enum ServerInfos setting, QString platform = "");
private:
//! set a server info value
static void setValue(enum ServerInfos setting, QVariant value);
//! set a value for a server info for a named platform.
- static void setPlatformValue(QString platform, enum ServerInfos setting, QVariant value);
+ static void setPlatformValue(enum ServerInfos setting, QString platform, QVariant value);
//! you shouldnt call this, its a fully static class
ServerInfo() {}
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp
index d57c12a62b..c9e29a8325 100644
--- a/rbutil/rbutilqt/base/systeminfo.cpp
+++ b/rbutil/rbutilqt/base/systeminfo.cpp
@@ -49,6 +49,13 @@ const static struct {
{ SystemInfo::ThemesUrl, "themes_url", "" },
{ SystemInfo::ThemesInfoUrl, "themes_info_url", "" },
{ SystemInfo::RbutilUrl, "rbutil_url", "" },
+};
+
+const static struct {
+ SystemInfo::PlatformInfo info;
+ const char* name;
+ const char* def;
+} PlatformInfosList[] = {
{ SystemInfo::CurPlatformName, ":platform:/name", "" },
{ SystemInfo::CurManual, ":platform:/manualname","rockbox-:platform:" },
{ SystemInfo::CurBootloaderMethod, ":platform:/bootloadermethod", "none" },
@@ -85,27 +92,27 @@ QVariant SystemInfo::value(enum SystemInfos info)
int i = 0;
while(SystemInfosList[i].info != info)
i++;
- QString platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
QString s = SystemInfosList[i].name;
- s.replace(":platform:", platform);
QString d = SystemInfosList[i].def;
- d.replace(":platform:", platform);
LOG_INFO() << "GET:" << s << systemInfos->value(s, d).toString();
return systemInfos->value(s, d);
}
-QVariant SystemInfo::platformValue(QString platform, enum SystemInfos info)
+QVariant SystemInfo::platformValue(enum PlatformInfo info, QString platform)
{
ensureSystemInfoExists();
// locate setting item
int i = 0;
- while(SystemInfosList[i].info != info)
+ while(PlatformInfosList[i].info != info)
i++;
- QString s = SystemInfosList[i].name;
+ if (platform.isEmpty())
+ platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
+
+ QString s = PlatformInfosList[i].name;
s.replace(":platform:", platform);
- QString d = SystemInfosList[i].def;
+ QString d = PlatformInfosList[i].def;
d.replace(":platform:", platform);
LOG_INFO() << "GET P:" << s << systemInfos->value(s, d).toString();
return systemInfos->value(s, d);
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h
index fad2c7e48b..b5380f1af5 100644
--- a/rbutil/rbutilqt/base/systeminfo.h
+++ b/rbutil/rbutilqt/base/systeminfo.h
@@ -57,6 +57,9 @@ class SystemInfo : public QObject
ThemesUrl,
ThemesInfoUrl,
RbutilUrl,
+ };
+
+ enum PlatformInfo {
CurPlatformName,
CurManual,
CurBootloaderMethod,
@@ -90,7 +93,7 @@ class SystemInfo : public QObject
//! get a value from system settings
static QVariant value(enum SystemInfos info);
//! get a value from system settings for a named platform.
- static QVariant platformValue(QString platform, enum SystemInfos info);
+ static QVariant platformValue(enum PlatformInfo info, QString platform = "");
private:
//! you shouldnt call this, its a fully static calls
diff --git a/rbutil/rbutilqt/base/talkgenerator.cpp b/rbutil/rbutilqt/base/talkgenerator.cpp
index 32686c78c2..ee57686037 100644
--- a/rbutil/rbutilqt/base/talkgenerator.cpp
+++ b/rbutil/rbutilqt/base/talkgenerator.cpp
@@ -56,7 +56,8 @@ TalkGenerator::Status TalkGenerator::process(QList<TalkEntry>* list,int wavtrimt
// Encoder
emit logItem(tr("Starting Encoder Engine"),LOGINFO);
- m_enc = EncoderBase::getEncoder(this,SystemInfo::value(SystemInfo::CurEncoder).toString());
+ m_enc = EncoderBase::getEncoder(
+ this, SystemInfo::platformValue(SystemInfo::CurEncoder).toString());
if(!m_enc->start())
{
emit logItem(tr("Init of Encoder engine failed"),LOGERROR);
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index fe35f0c295..a3a3e98fcc 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -381,12 +381,12 @@ QString Utils::checkEnvironment(bool permission)
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
QString installed = rbinfo.target();
if(!installed.isEmpty() && installed !=
- SystemInfo::value(SystemInfo::CurConfigureModel).toString())
+ SystemInfo::platformValue(SystemInfo::CurConfigureModel).toString())
{
text += tr("<li>Target mismatch detected.<br/>"
"Installed target: %1<br/>Selected target: %2.</li>")
- .arg(SystemInfo::platformValue(installed, SystemInfo::CurPlatformName).toString(),
- SystemInfo::value(SystemInfo::CurPlatformName).toString());
+ .arg(SystemInfo::platformValue(SystemInfo::CurPlatformName, installed).toString(),
+ SystemInfo::platformValue(SystemInfo::CurPlatformName).toString());
}
if(!text.isEmpty())