rbutil: Use pattern replacement for SystemInfo build type.

Use pattern replacement for lookup instead of expanded values. Will
allow simplifying things later for better handling of different build
types.

Change-Id: Iaad67a6c8654d27c3206cf95a379acab169565bc
This commit is contained in:
Dominik Riebeling 2020-11-13 21:53:53 +01:00
parent 6b3b4df6f6
commit ad37655687
8 changed files with 94 additions and 75 deletions

View file

@ -95,17 +95,20 @@ QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
if(value.toStringList().size() > 1)
value = value.toStringList().at(1);
else if(!version.isEmpty() && info == CurReleaseUrl)
value = SystemInfo::value(SystemInfo::ReleaseUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildRelease).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
else if(!version.isEmpty() && info == RelCandidateUrl)
value = SystemInfo::value(SystemInfo::CandidateUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCandidate).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
}
break;
case CurDevelUrl:
value = SystemInfo::value(SystemInfo::BleedingUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCurrent).toString()
.replace("%MODEL%", platform);
break;
case ManualPdfUrl:

View file

@ -27,28 +27,23 @@ const static struct {
SystemInfo::SystemInfos info;
const char* name;
} SystemInfosList[] = {
{ SystemInfo::ManualUrl, "manual_url" },
{ SystemInfo::BleedingUrl, "bleeding_url" },
{ SystemInfo::BootloaderUrl, "bootloader_url" },
{ SystemInfo::BootloaderInfoUrl, "bootloader_info_url" },
{ SystemInfo::ReleaseFontUrl, "release_font_url" },
{ SystemInfo::DailyFontUrl, "daily_font_url" },
{ SystemInfo::DailyVoiceUrl, "daily_voice_url" },
{ SystemInfo::ReleaseVoiceUrl, "release_voice_url" },
{ SystemInfo::DoomUrl, "doom_url" },
{ SystemInfo::Duke3DUrl, "duke3d_url" },
{ SystemInfo::PuzzFontsUrl, "puzzfonts_url" },
{ SystemInfo::QuakeUrl, "quake_url" },
{ SystemInfo::Wolf3DUrl, "wolf3d_url" },
{ SystemInfo::XWorldUrl, "xworld_url" },
{ SystemInfo::ReleaseUrl, "release_url" },
{ SystemInfo::CandidateUrl, "rc_url" },
{ SystemInfo::DailyUrl, "daily_url" },
{ SystemInfo::BuildInfoUrl, "build_info_url" },
{ SystemInfo::GenlangUrl, "genlang_url" },
{ SystemInfo::ThemesUrl, "themes_url" },
{ SystemInfo::ThemesInfoUrl, "themes_info_url" },
{ SystemInfo::RbutilUrl, "rbutil_url" },
{ SystemInfo::ManualUrl, ":build:/manual_url" },
{ SystemInfo::BuildUrl, ":build:/build_url" },
{ SystemInfo::FontUrl, ":build:/font_url" },
{ SystemInfo::VoiceUrl, ":build:/voice_url" },
{ SystemInfo::BootloaderUrl, "bootloader/download_url" },
{ SystemInfo::BootloaderInfoUrl, "bootloader/info_url" },
{ SystemInfo::DoomUrl, "doom_url" },
{ SystemInfo::Duke3DUrl, "duke3d_url" },
{ SystemInfo::PuzzFontsUrl, "puzzfonts_url" },
{ SystemInfo::QuakeUrl, "quake_url" },
{ SystemInfo::Wolf3DUrl, "wolf3d_url" },
{ SystemInfo::XWorldUrl, "xworld_url" },
{ SystemInfo::BuildInfoUrl, "build_info_url" },
{ SystemInfo::GenlangUrl, "genlang_url" },
{ SystemInfo::ThemesUrl, "themes_url" },
{ SystemInfo::ThemesInfoUrl, "themes_info_url" },
{ SystemInfo::RbutilUrl, "rbutil_url" },
};
const static struct {
@ -84,7 +79,7 @@ void SystemInfo::ensureSystemInfoExists()
}
QVariant SystemInfo::value(enum SystemInfos info)
QVariant SystemInfo::value(enum SystemInfos info, BuildType type)
{
ensureSystemInfoExists();
@ -93,6 +88,20 @@ QVariant SystemInfo::value(enum SystemInfos info)
while(SystemInfosList[i].info != info)
i++;
QString s = SystemInfosList[i].name;
switch(type) {
case BuildDaily:
s.replace(":build:", "daily");
break;
case BuildCurrent:
s.replace(":build:", "development");
break;
case BuildCandidate:
s.replace(":build:", "release-candidate");
break;
case BuildRelease:
s.replace(":build:", "release");
break;
}
LOG_INFO() << "GET:" << s << systemInfos->value(s).toString();
return systemInfos->value(s);
}

View file

@ -34,15 +34,21 @@ class SystemInfo : public QObject
MapIncompatible,
};
enum BuildType {
BuildCurrent,
BuildDaily,
BuildRelease,
BuildCandidate
};
//! All system settings
enum SystemInfos {
BuildUrl,
FontUrl,
VoiceUrl,
ManualUrl,
BleedingUrl,
BootloaderUrl,
BootloaderInfoUrl,
DailyUrl,
DailyFontUrl,
DailyVoiceUrl,
DoomUrl,
Duke3DUrl,
QuakeUrl,
@ -50,9 +56,6 @@ class SystemInfo : public QObject
Wolf3DUrl,
XWorldUrl,
ReleaseUrl,
CandidateUrl,
ReleaseVoiceUrl,
ReleaseFontUrl,
BuildInfoUrl,
GenlangUrl,
ThemesUrl,
@ -92,7 +95,7 @@ class SystemInfo : public QObject
//! returns a map of usb-ids and their targets
static QMap<int, QStringList> usbIdMap(enum MapType type);
//! get a value from system settings
static QVariant value(enum SystemInfos info);
static QVariant value(enum SystemInfos info, BuildType type = BuildCurrent);
//! get a value from system settings for a named platform.
static QVariant platformValue(enum PlatformInfo info, QString platform = "");