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
This commit is contained in:
Dominik Riebeling 2020-11-28 20:47:28 +01:00
parent 78a01db47c
commit b064a6cbb5
24 changed files with 791 additions and 773 deletions

View File

@ -20,6 +20,7 @@
#include "autodetection.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "../ipodpatcher/ipodpatcher.h"
#include "../sansapatcher/sansapatcher.h"
@ -69,7 +70,8 @@ bool Autodetection::detect(void)
}
for(int i = 0; i < m_detected.size(); ++i) {
LOG_INFO() << "Detected player:" << m_detected.at(i).device
<< "at" << m_detected.at(i).mountpoint << states[m_detected.at(i).status];
<< "at" << m_detected.at(i).mountpoint
<< states[m_detected.at(i).status];
}
return m_detected.size() > 0;
@ -108,7 +110,8 @@ 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(SystemInfo::Name, idstring).toString().isEmpty()) {
if(!PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName, idstring).toString().isEmpty()) {
struct Detected d;
d.status = PlayerIncompatible;
d.device = idstring;

View File

@ -23,7 +23,7 @@
#include "utils.h"
#include "system.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "../mks5lboot/mks5lboot.h"
@ -408,8 +408,8 @@ BootloaderInstallBase::BootloaderType BootloaderInstallS5l::installed(void)
QString logfile = RbSettings::value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log";
QSettings s(logfile, QSettings::IniFormat, this);
QString section = SystemInfo::platformValue(
SystemInfo::BootloaderName).toString().section('/', -1);
QString section = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderName).toString().section('/', -1);
rbblInstalled = s.contains("Bootloader/" + section);
if (rbblInstalled) {

View File

@ -0,0 +1,265 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 by Dominik Riebeling
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "playerbuildinfo.h"
#include "rbsettings.h"
#include "Logger.h"
PlayerBuildInfo* PlayerBuildInfo::infoInstance = nullptr;
PlayerBuildInfo* PlayerBuildInfo::instance()
{
if (infoInstance == nullptr) {
infoInstance = new PlayerBuildInfo();
}
return infoInstance;
}
// server infos
const static struct {
PlayerBuildInfo::BuildInfo item;
const char* name;
} ServerInfoList[] = {
{ PlayerBuildInfo::BuildVoiceLangs, "voices/:version:" },
{ PlayerBuildInfo::BuildVersion, ":build:/:target:" },
{ PlayerBuildInfo::BuildUrl, ":build:/build_url" },
{ PlayerBuildInfo::BuildVoiceUrl, ":build:/voice_url" },
{ PlayerBuildInfo::BuildManualUrl, ":build:/manual_url" },
{ PlayerBuildInfo::BuildSourceUrl, ":build:/source_url" },
{ PlayerBuildInfo::BuildFontUrl, ":build:/font_url" },
// other URLs -- those are not directly related to the build, but handled here.
{ PlayerBuildInfo::DoomUrl, "other/doom_url" },
{ PlayerBuildInfo::Duke3DUrl, "other/duke3d_url" },
{ PlayerBuildInfo::PuzzFontsUrl, "other/puzzfonts_url" },
{ PlayerBuildInfo::QuakeUrl, "other/quake_url" },
{ PlayerBuildInfo::Wolf3DUrl, "other/wolf3d_url" },
{ PlayerBuildInfo::XWorldUrl, "other/xworld_url" },
{ PlayerBuildInfo::MidiPatchsetUrl, "other/patcheset_url" },
};
const static struct {
PlayerBuildInfo::DeviceInfo item;
const char* name;
} PlayerInfoList[] = {
{ PlayerBuildInfo::BuildStatus, "status/:target:" },
{ PlayerBuildInfo::DisplayName, ":target:/name" },
{ PlayerBuildInfo::BootloaderMethod, ":target:/bootloadermethod" },
{ PlayerBuildInfo::BootloaderName, ":target:/bootloadername" },
{ PlayerBuildInfo::BootloaderFile, ":target:/bootloaderfile" },
{ PlayerBuildInfo::BootloaderFilter, ":target:/bootloaderfilter" },
{ PlayerBuildInfo::Encoder, ":target:/encoder" },
{ PlayerBuildInfo::Brand, ":target:/brand" },
{ PlayerBuildInfo::PlayerPicture, ":target:/playerpic" },
};
const static struct {
PlayerBuildInfo::SystemUrl item;
const char* name;
} PlayerSystemUrls[] = {
{ PlayerBuildInfo::BootloaderUrl, "bootloader/download_url" },
{ PlayerBuildInfo::BuildInfoUrl, "build_info_url" },
{ PlayerBuildInfo::GenlangUrl, "genlang_url" },
{ PlayerBuildInfo::ThemesUrl, "themes_url" },
{ PlayerBuildInfo::ThemesInfoUrl, "themes_info_url" },
{ PlayerBuildInfo::RbutilUrl, "rbutil_url" },
};
PlayerBuildInfo::PlayerBuildInfo() :
serverInfo(nullptr),
playerInfo(":/ini/rbutil.ini", QSettings::IniFormat)
{
}
void PlayerBuildInfo::setBuildInfo(QString file)
{
if (serverInfo)
delete serverInfo;
LOG_INFO() << "updated:" << file;
serverInfo = new QSettings(file, QSettings::IniFormat);
}
QVariant PlayerBuildInfo::value(BuildInfo item, BuildType type)
{
// locate setting item in server info file
int i = 0;
while(ServerInfoList[i].item != item)
i++;
// split of variant for target.
// we can have an optional variant part in the target string.
// For build info we don't use that.
QString target = RbSettings::value(RbSettings::CurrentPlatform).toString().split('.').at(0);
QString s = ServerInfoList[i].name;
s.replace(":target:", target);
QString v;
switch(type) {
case TypeRelease:
v = "release";
break;
case TypeCandidate:
v = "release-candidate";
break;
case TypeDaily:
v = "daily";
break;
case TypeDevel:
v = "development";
break;
}
QVariant result = QString();
if (!serverInfo)
return result;
QStringList version = serverInfo->value(v + "/" + target, "").toStringList();
s.replace(":build:", v);
s.replace(":version:", version.at(0));
// get value from server build-info
// we need to get a version string, otherwise the data is invalid.
// For invalid data return an empty string.
if(version.at(0).isEmpty()) {
LOG_INFO() << s << "(version invalid)";
return result;
}
if(!s.isEmpty())
result = serverInfo->value(s);
// depending on the actual value we need more replacements.
switch(item) {
case BuildVersion:
result = result.toStringList().at(0);
break;
case BuildUrl:
if(version.size() > 1) {
// version info has an URL appended. Takes precendence.
result = version.at(1);
}
break;
case BuildVoiceLangs:
if (type == TypeDaily)
s = "voices/daily";
result = serverInfo->value(s);
break;
case BuildManualUrl:
{
// special case: if playerInfo has a non-empty manualname entry for the
// target, use that as target for the manual name.
QString manualtarget = playerInfo.value(target + "/manualname", "").toString();
if(!manualtarget.isEmpty())
target = manualtarget;
break;
}
default:
break;
}
// if the value is a string we can replace some patterns.
// if we cannot convert it (f.e. for a QStringList) we leave as-is, since
// the conversion would return an empty type.
if (result.canConvert(QMetaType::QString))
result = result.toString()
.replace("%TARGET%", target)
.replace("%VERSION%", version.at(0));
LOG_INFO() << "B:" << s << result;
return result;
}
QVariant PlayerBuildInfo::value(DeviceInfo item, QString target)
{
// locate setting item in server info file
int i = 0;
while(PlayerInfoList[i].item != item)
i++;
// split of variant for target.
// we can have an optional variant part in the target string.
// For device info we use this.
if (target.isEmpty())
target = RbSettings::value(RbSettings::CurrentPlatform).toString();
QVariant result = QString();
QString s = PlayerInfoList[i].name;
s.replace(":target:", target);
switch(item) {
case BuildStatus:
{
// build status is the only value that doesn't depend on the version
// but the selected target instead.
bool ok = false;
if (serverInfo)
result = serverInfo->value(s).toInt(&ok);
if (!ok)
result = -1;
break;
}
default:
result = playerInfo.value(s);
break;
}
LOG_INFO() << "T:" << s << result;
return result;
}
QVariant PlayerBuildInfo::value(SystemUrl item)
{
// locate setting item in server info file
int i = 0;
while(PlayerSystemUrls[i].item != item)
i++;
QVariant result = playerInfo.value(PlayerSystemUrls[i].name);
LOG_INFO() << "U:" << PlayerSystemUrls[i].name << result;
return result;
}
QString PlayerBuildInfo::statusAsString(QString platform)
{
QString result;
switch(value(BuildStatus, platform).toInt())
{
case STATUS_RETIRED:
result = tr("Stable (Retired)");
break;
case STATUS_UNUSABLE:
result = tr("Unusable");
break;
case STATUS_UNSTABLE:
result = tr("Unstable");
break;
case STATUS_STABLE:
result = tr("Stable");
break;
default:
result = tr("Unknown");
break;
}
return result;
}

View File

@ -0,0 +1,106 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 by Dominik Riebeling
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef PLAYERBUILDINFO_H
#define PLAYERBUILDINFO_H
#include <QSettings>
#define STATUS_RETIRED 0
#define STATUS_UNUSABLE 1
#define STATUS_UNSTABLE 2
#define STATUS_STABLE 3
// Provide information about both player and builds.
// For build info data retrieved from the build server has to be passed.
class PlayerBuildInfo : public QObject
{
public:
enum BuildType {
TypeRelease,
TypeCandidate,
TypeDaily,
TypeDevel,
};
enum BuildInfo {
BuildUrl,
BuildVersion,
BuildManualUrl,
BuildVoiceUrl,
BuildVoiceLangs,
BuildSourceUrl,
BuildFontUrl,
DoomUrl,
Duke3DUrl,
PuzzFontsUrl,
QuakeUrl,
Wolf3DUrl,
XWorldUrl,
MidiPatchsetUrl,
};
enum DeviceInfo {
BuildStatus,
DisplayName,
BootloaderMethod,
BootloaderName,
BootloaderFile,
BootloaderFilter,
Encoder,
Brand,
PlayerPicture,
};
enum SystemUrl {
BootloaderUrl,
BuildInfoUrl,
GenlangUrl,
ThemesUrl,
ThemesInfoUrl,
RbutilUrl,
};
static PlayerBuildInfo* instance();
//! Update with build information from server
void setBuildInfo(QString file);
// Get information about a device. This data does not depend on the build type.
QVariant value(DeviceInfo item, QString target = "");
// Get build information for currently selected player.
QVariant value(BuildInfo item, BuildType type);
// Get fixed download URL information
QVariant value(SystemUrl item);
QString statusAsString(QString target = "");
protected:
explicit PlayerBuildInfo();
private:
static PlayerBuildInfo* infoInstance;
QSettings* serverInfo;
QSettings playerInfo;
};
#endif

View File

@ -17,7 +17,7 @@
****************************************************************************/
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include <QSettings>
#include "Logger.h"
@ -196,7 +196,8 @@ QString RbSettings::constructSettingPath(QString path, QString substitute)
}
else {
path.replace(":tts:", userSettings->value("tts").toString());
path.replace(":encoder:", SystemInfo::platformValue(SystemInfo::Encoder, platform).toString());
path.replace(":encoder:", PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Encoder, platform).toString());
}
path.replace(":platform:", platform);
}

View File

@ -1,157 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2010 by Dominik Wenger
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "serverinfo.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "Logger.h"
ServerInfo* ServerInfo::infoInstance = nullptr;
ServerInfo* ServerInfo::instance()
{
if (infoInstance == nullptr) {
infoInstance = new ServerInfo();
}
return infoInstance;
}
// server infos
const static struct {
ServerInfo::ServerInfos info;
const char* name;
const char* def;
} ServerInfoList[] = {
{ ServerInfo::CurReleaseVersion, "release/:platform:", "" },
{ ServerInfo::CurReleaseUrl, "release/:platform:", "" },
{ ServerInfo::RelCandidateVersion, "release-candidate/:platform:", "" },
{ ServerInfo::RelCandidateUrl, "release-candidate/:platform:", "" },
{ ServerInfo::DailyVersion, "daily/:platform:", "" },
{ ServerInfo::DailyUrl, "daily/:platform:", "" },
{ ServerInfo::CurStatus, "status/:platform:", "-1" },
{ ServerInfo::BleedingRevision, "bleeding/rev", "" },
{ ServerInfo::BleedingDate, "bleeding/timestamp", "" },
{ ServerInfo::CurDevelUrl, "", "" },
};
void ServerInfo::readBuildInfo(QString file)
{
if (serverSettings)
delete serverSettings;
serverSettings = new QSettings(file, QSettings::IniFormat);
}
QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
{
// locate setting item in server info file
int i = 0;
while(ServerInfoList[i].info != info)
i++;
// replace setting name
if(platform.isEmpty())
platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
// split of variant for platform.
// we can have an optional variant part in the platform string.
// For build info we don't use that.
platform = platform.split('.').at(0);
QString s = ServerInfoList[i].name;
s.replace(":platform:", platform);
// get value
QVariant value = QString();
if(!s.isEmpty() && serverSettings)
value = serverSettings->value(s, ServerInfoList[i].def);
// depending on the actual value we need more replacements.
switch(info) {
case CurReleaseVersion:
case RelCandidateVersion:
case DailyVersion:
value = value.toStringList().at(0);
break;
case CurReleaseUrl:
case RelCandidateUrl:
case DailyUrl:
{
QString version = value.toStringList().at(0);
if(value.toStringList().size() > 1)
value = value.toStringList().at(1);
else if(!version.isEmpty() && info == CurReleaseUrl)
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildRelease).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
else if(!version.isEmpty() && info == RelCandidateUrl)
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCandidate).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
else if(!version.isEmpty() && info == DailyUrl)
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildDaily).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
}
break;
case CurDevelUrl:
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCurrent).toString()
.replace("%MODEL%", platform);
break;
case BleedingDate:
// TODO: get rid of this, it's location specific.
value = QDateTime::fromString(value.toString(),
"yyyyMMddThhmmssZ").toString(Qt::ISODate);
break;
default:
break;
}
LOG_INFO() << "Server:" << value;
return value;
}
QString ServerInfo::statusAsString(QString platform)
{
QString value;
switch(platformValue(CurStatus, platform).toInt())
{
case STATUS_RETIRED:
value = tr("Stable (Retired)");
break;
case STATUS_UNUSABLE:
value = tr("Unusable");
break;
case STATUS_UNSTABLE:
value = tr("Unstable");
break;
case STATUS_STABLE:
value = tr("Stable");
break;
default:
value = tr("Unknown");
break;
}
return value;
}

View File

@ -1,71 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2010 by Dominik Wenger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
// Parse and provide information from build server via build-info file.
// This is a singleton.
#ifndef SERVERINFO_H
#define SERVERINFO_H
#include <QtCore>
#define STATUS_RETIRED 0
#define STATUS_UNUSABLE 1
#define STATUS_UNSTABLE 2
#define STATUS_STABLE 3
class ServerInfo : public QObject
{
Q_OBJECT
public:
//! All Server infos
enum ServerInfos {
CurReleaseVersion,
CurStatus,
CurReleaseUrl,
CurDevelUrl,
BleedingRevision,
BleedingDate,
RelCandidateVersion,
RelCandidateUrl,
DailyVersion,
DailyUrl
};
static ServerInfo* instance();
//! read in buildinfo file
void readBuildInfo(QString file);
//! get a value from server info for a named platform.
QVariant platformValue(enum ServerInfos setting, QString platform = "");
//! Get status number as string
QString statusAsString(QString platform = "");
protected:
ServerInfo() : serverSettings(nullptr) {}
private:
static ServerInfo* infoInstance;
QSettings* serverSettings;
};
#endif

View File

@ -23,44 +23,6 @@
#include "Logger.h"
// device settings
const static struct {
SystemInfo::SystemInfos info;
const char* name;
} SystemInfosList[] = {
{ 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 {
SystemInfo::PlatformInfo info;
const char* name;
const char* def;
} PlatformInfosList[] = {
{ SystemInfo::Manual, ":platform:/manualname", ":platform:" },
{ SystemInfo::BootloaderMethod, ":platform:/bootloadermethod", "none" },
{ SystemInfo::BootloaderName, ":platform:/bootloadername", "" },
{ SystemInfo::BootloaderFile, ":platform:/bootloaderfile", "" },
{ SystemInfo::BootloaderFilter, ":platform:/bootloaderfilter", "" },
{ SystemInfo::Encoder, ":platform:/encoder", "" },
{ SystemInfo::Brand, ":platform:/brand", "" },
{ SystemInfo::Name, ":platform:/name", "" },
{ SystemInfo::PlayerPicture, ":platform:/playerpic", "" },
};
//! pointer to setting object to nullptr
QSettings* SystemInfo::systemInfos = nullptr;
@ -76,53 +38,6 @@ void SystemInfo::ensureSystemInfoExists()
}
QVariant SystemInfo::value(enum SystemInfos info, BuildType type)
{
ensureSystemInfoExists();
// locate setting item
int i = 0;
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);
}
QVariant SystemInfo::platformValue(enum PlatformInfo info, QString platform)
{
ensureSystemInfoExists();
// locate setting item
int i = 0;
while(PlatformInfosList[i].info != info)
i++;
if (platform.isEmpty())
platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
QString s = PlatformInfosList[i].name;
s.replace(":platform:", platform);
QString d = PlatformInfosList[i].def;
d.replace(":platform:", platform);
LOG_INFO() << "GET P:" << s << systemInfos->value(s, d).toString();
return systemInfos->value(s, d);
}
QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString variant)
{
ensureSystemInfoExists();

View File

@ -34,47 +34,6 @@ class SystemInfo : public QObject
MapIncompatible,
};
enum BuildType {
BuildCurrent,
BuildDaily,
BuildRelease,
BuildCandidate
};
//! All system settings
enum SystemInfos {
BuildUrl,
FontUrl,
VoiceUrl,
ManualUrl,
BootloaderUrl,
BootloaderInfoUrl,
DoomUrl,
Duke3DUrl,
QuakeUrl,
PuzzFontsUrl,
Wolf3DUrl,
XWorldUrl,
ReleaseUrl,
BuildInfoUrl,
GenlangUrl,
ThemesUrl,
ThemesInfoUrl,
RbutilUrl,
};
enum PlatformInfo {
Manual,
BootloaderMethod,
BootloaderName,
BootloaderFile,
BootloaderFilter,
Encoder,
Brand,
Name,
PlayerPicture,
};
enum PlatformType {
PlatformAll,
PlatformAllDisabled,
@ -93,9 +52,6 @@ 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, BuildType type = BuildCurrent);
//! get a value from system settings for a named platform.
static QVariant platformValue(enum PlatformInfo info, QString platform = "");
private:
//! you shouldnt call this, its a fully static calls

View File

@ -18,7 +18,7 @@
#include "talkgenerator.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "wavtrim.h"
#include "Logger.h"
@ -56,8 +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::platformValue(SystemInfo::Encoder).toString());
m_enc = EncoderBase::getEncoder(this, PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Encoder).toString());
if(!m_enc->start())
{
emit logItem(tr("Init of Encoder engine failed"),LOGERROR);
@ -156,7 +156,8 @@ TalkGenerator::Status TalkGenerator::voiceList(QList<TalkEntry>* list,int wavtri
QString error;
LOG_INFO() << "voicing: " << list->at(i).toSpeak
<< "to" << list->at(i).wavfilename;
TTSStatus status = m_tts->voice(list->at(i).toSpeak,list->at(i).wavfilename, &error);
TTSStatus status = m_tts->voice(list->at(i).toSpeak,
list->at(i).wavfilename, &error);
if(status == Warning)
{
warnings = true;

View File

@ -20,7 +20,7 @@
#include "rockboxinfo.h"
#include "system.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "Logger.h"
#if !defined(_UNICODE)
@ -385,8 +385,10 @@ QString Utils::checkEnvironment(bool permission)
{
text += tr("<li>Target mismatch detected.<br/>"
"Installed target: %1<br/>Selected target: %2.</li>")
.arg(SystemInfo::platformValue(SystemInfo::Name, installed).toString(),
SystemInfo::platformValue(SystemInfo::Name).toString());
.arg(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName, installed).toString(),
PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName).toString());
}
if(!text.isEmpty())

View File

@ -21,7 +21,7 @@
#include "utils.h"
#include "rockboxinfo.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "ziputil.h"
#include "Logger.h"
@ -148,7 +148,8 @@ bool VoiceFileCreator::createVoiceFile()
// genlang output as previously from the webserver.
// prepare download url
QString genlang = SystemInfo::value(SystemInfo::GenlangUrl).toString();
QString genlang = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::GenlangUrl).toString();
genlang.replace("%LANG%", m_lang);
genlang.replace("%TARGET%", target);
genlang.replace("%REVISION%", version);

View File

@ -33,8 +33,8 @@
#include "system.h"
#include "encttscfggui.h"
#include "rbsettings.h"
#include "serverinfo.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "utils.h"
#include "comboboxviewdelegate.h"
#if defined(Q_OS_WIN32)
@ -355,8 +355,8 @@ void Config::setDevices()
QMultiMap <QString, QString> manuf;
for(int it = 0; it < platformList.size(); it++)
{
QString curbrand = SystemInfo::platformValue(
SystemInfo::Brand, platformList.at(it)).toString();
QString curbrand = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Brand, platformList.at(it)).toString();
manuf.insert(curbrand, platformList.at(it));
}
@ -384,9 +384,10 @@ void Config::setDevices()
if(!manuf.values(brands.at(c)).contains(platformList.at(it)))
continue;
// construct display name
QString curname = SystemInfo::platformValue(
SystemInfo::Name, platformList.at(it)).toString()
+ " (" + ServerInfo::instance()->statusAsString(platformList.at(it)) + ")";
QString curname = QString("%1 (%2)").arg(
PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName,
platformList.at(it)).toString(),
PlayerBuildInfo::instance()->statusAsString(platformList.at(it)));
LOG_INFO() << "add supported device:" << brands.at(c) << curname;
w2 = new QTreeWidgetItem(w, QStringList(curname));
w2->setData(0, Qt::UserRole, platformList.at(it));
@ -470,10 +471,10 @@ void Config::updateEncState()
return;
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
QString encoder = SystemInfo::platformValue(
SystemInfo::Encoder, devname).toString();
ui.encoderName->setText(EncoderBase::getEncoderName(SystemInfo::platformValue(
SystemInfo::Encoder, devname).toString()));
QString encoder = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Encoder, devname).toString();
ui.encoderName->setText(EncoderBase::getEncoderName(
PlayerBuildInfo::instance()->value(PlayerBuildInfo::Encoder, devname).toString()));
EncoderBase* enc = EncoderBase::getEncoder(this,encoder);
@ -741,8 +742,9 @@ void Config::autodetect()
mp = tr("(unknown)");
}
msg += QString("<li>%1</li>").arg(tr("%1 at %2").arg(
SystemInfo::platformValue(
SystemInfo::Name, detected.at(i).device).toString(),
PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName,
detected.at(i).device).toString(),
QDir::toNativeSeparators(mp)));
}
msg += "</ul>";
@ -767,22 +769,25 @@ void Config::autodetect()
case Autodetection::PlayerIncompatible:
msg += tr("Detected an unsupported player:\n%1\n"
"Sorry, Rockbox doesn't run on your player.")
.arg(SystemInfo::platformValue(
SystemInfo::Name, detected.at(0).device).toString());
.arg(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName,
detected.at(0).device).toString());
break;
case Autodetection::PlayerMtpMode:
msg = tr("%1 in MTP mode found!\n"
"You need to change your player to MSC mode for installation. ")
.arg(SystemInfo::platformValue(
SystemInfo::Name, detected.at(0).device).toString());
.arg(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName,
detected.at(0).device).toString());
break;
case Autodetection::PlayerWrongFilesystem:
if(SystemInfo::platformValue(
SystemInfo::BootloaderMethod, detected.at(0).device) == "ipod") {
if(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderMethod, detected.at(0).device) == "ipod") {
msg = tr("%1 \"MacPod\" found!\n"
"Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
"to run. ").arg(SystemInfo::platformValue(
SystemInfo::Name, detected.at(0).device).toString());
"to run. ").arg(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName,
detected.at(0).device).toString());
}
else {
msg = tr("The player contains an incompatible filesystem.\n"
@ -961,10 +966,11 @@ void Config::configEnc()
return;
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
QString encoder = SystemInfo::platformValue(
SystemInfo::Encoder, devname).toString();
ui.encoderName->setText(EncoderBase::getEncoderName(SystemInfo::platformValue(
SystemInfo::Encoder, devname).toString()));
QString encoder = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Encoder, devname).toString();
ui.encoderName->setText(
EncoderBase::getEncoderName(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::Encoder, devname).toString()));
EncoderBase* enc = EncoderBase::getEncoder(this,encoder);

View File

@ -21,7 +21,7 @@
#include <QFileDialog>
#include "selectiveinstallwidget.h"
#include "ui_selectiveinstallwidgetfrm.h"
#include "serverinfo.h"
#include "playerbuildinfo.h"
#include "rbsettings.h"
#include "rockboxinfo.h"
#include "systeminfo.h"
@ -71,26 +71,28 @@ SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent
void SelectiveInstallWidget::selectedVersionChanged(int index)
{
m_buildtype = static_cast<SystemInfo::BuildType>(ui.selectedVersion->itemData(index).toInt());
m_buildtype = static_cast<PlayerBuildInfo::BuildType>(ui.selectedVersion->itemData(index).toInt());
bool voice = true;
switch(m_buildtype) {
case SystemInfo::BuildRelease:
case PlayerBuildInfo::TypeRelease:
ui.selectedDescription->setText(tr("This is the latest stable "
"release available."));
voice = true;
break;
case SystemInfo::BuildCurrent:
case PlayerBuildInfo::TypeDevel:
ui.selectedDescription->setText(tr("The development version is "
"updated on every code change. Last update was on %1").arg(
ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString()));
"updated on every code change. Last update was on %1").arg(
PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildVersion,
PlayerBuildInfo::TypeDevel).toString()));
voice = false;
break;
case SystemInfo::BuildCandidate:
case PlayerBuildInfo::TypeCandidate:
ui.selectedDescription->setText(tr("This will eventually become the "
"next Rockbox version. Install it to help testing."));
voice = false;
break;
case SystemInfo::BuildDaily:
case PlayerBuildInfo::TypeDaily:
ui.selectedDescription->setText(tr("Daily updated development version."));
voice = true;
break;
@ -106,8 +108,8 @@ void SelectiveInstallWidget::updateVersion(void)
// get some configuration values globally
m_mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
m_target = RbSettings::value(RbSettings::CurrentPlatform).toString();
m_blmethod = SystemInfo::platformValue(
SystemInfo::BootloaderMethod, m_target).toString();
m_blmethod = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderMethod, m_target).toString();
if(m_logger != nullptr) {
delete m_logger;
@ -115,46 +117,29 @@ void SelectiveInstallWidget::updateVersion(void)
}
// re-populate all version items
m_versions.clear();
m_versions.insert(SystemInfo::BuildRelease, ServerInfo::instance()->platformValue(
ServerInfo::CurReleaseVersion).toString());
// Don't populate RC or development selections if target has been retired.
if (ServerInfo::instance()->platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) {
m_versions.insert(SystemInfo::BuildCurrent, ServerInfo::instance()->platformValue(
ServerInfo::BleedingRevision).toString());
m_versions.insert(SystemInfo::BuildCandidate, ServerInfo::instance()->platformValue(
ServerInfo::RelCandidateVersion).toString());
m_versions.insert(SystemInfo::BuildDaily, ServerInfo::instance()->platformValue(
ServerInfo::DailyVersion).toString());
QMap<PlayerBuildInfo::BuildType, QString> types;
types[PlayerBuildInfo::TypeRelease] = tr("Stable Release (Version %1)");
if (PlayerBuildInfo::instance()->value(PlayerBuildInfo::BuildStatus).toInt() != STATUS_RETIRED) {
types[PlayerBuildInfo::TypeCandidate] = tr("Release Candidate (Revison %1)");
types[PlayerBuildInfo::TypeDaily] = tr("Daily Build (%1)");
types[PlayerBuildInfo::TypeDevel] = tr("Development Version (Revison %1)");
}
ui.selectedVersion->clear();
if(!m_versions[SystemInfo::BuildRelease].isEmpty()) {
ui.selectedVersion->addItem(tr("Stable Release (Version %1)").arg(
m_versions[SystemInfo::BuildRelease]), SystemInfo::BuildRelease);
}
if(!m_versions[SystemInfo::BuildCurrent].isEmpty()) {
ui.selectedVersion->addItem(tr("Development Version (Revison %1)").arg(
m_versions[SystemInfo::BuildCurrent]), SystemInfo::BuildCurrent);
}
if(!m_versions[SystemInfo::BuildCandidate].isEmpty()) {
ui.selectedVersion->addItem(tr("Release Candidate (Revison %1)").arg(
m_versions[SystemInfo::BuildCandidate]), SystemInfo::BuildCandidate);
}
if(!m_versions[SystemInfo::BuildDaily].isEmpty()) {
ui.selectedVersion->addItem(tr("Daily Build (%1)").arg(
m_versions[SystemInfo::BuildDaily]), SystemInfo::BuildDaily);
for(auto i = types.begin(); i != types.end(); i++) {
QString version = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildVersion, i.key()).toString();
if(!version.isEmpty())
ui.selectedVersion->addItem(i.value().arg(version), i.key());
}
// select previously selected version
int index = ui.selectedVersion->findData(
static_cast<SystemInfo::BuildType>(RbSettings::value(RbSettings::Build).toInt()));
static_cast<PlayerBuildInfo::BuildType>(RbSettings::value(RbSettings::Build).toInt()));
if(index < 0) {
if(!m_versions[SystemInfo::BuildRelease].isEmpty()) {
index = ui.selectedVersion->findData(SystemInfo::BuildRelease);
}
else {
index = ui.selectedVersion->findData(SystemInfo::BuildCurrent);
index = ui.selectedVersion->findData(PlayerBuildInfo::TypeRelease);
if(index < 0) {
index = ui.selectedVersion->findData(PlayerBuildInfo::TypeDevel);
}
}
ui.selectedVersion->setCurrentIndex(index);
@ -295,7 +280,8 @@ void SelectiveInstallWidget::installBootloader(void)
// create installer
BootloaderInstallBase *bl =
BootloaderInstallHelper::createBootloaderInstaller(this,
SystemInfo::platformValue(SystemInfo::BootloaderMethod).toString());
PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderMethod).toString());
if(bl == nullptr) {
m_logger->addItem(tr("No install method known."), LOGERROR);
m_logger->setFinished();
@ -312,15 +298,16 @@ void SelectiveInstallWidget::installBootloader(void)
connect(m_logger, SIGNAL(aborted()), bl, SLOT(progressAborted()));
// set bootloader filename. Do this now as installed() needs it.
QStringList blfile = SystemInfo::platformValue(SystemInfo::BootloaderFile).toStringList();
QStringList blfile = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderFile).toStringList();
QStringList blfilepath;
for(int a = 0; a < blfile.size(); a++) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
+ blfile.at(a));
}
bl->setBlFile(blfilepath);
QUrl url(SystemInfo::value(SystemInfo::BootloaderUrl).toString()
+ SystemInfo::platformValue(SystemInfo::BootloaderName).toString());
QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString()
+ PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString());
bl->setBlUrl(url);
bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log");
@ -340,7 +327,8 @@ void SelectiveInstallWidget::installBootloader(void)
else if(bl->installed() == BootloaderInstallBase::BootloaderOther
&& bl->capabilities() & BootloaderInstallBase::Backup)
{
QString targetFolder = SystemInfo::platformValue(SystemInfo::Name).toString()
QString targetFolder = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::DisplayName).toString()
+ " Firmware Backup";
// remove invalid character(s)
targetFolder.remove(QRegExp("[:/]"));
@ -377,7 +365,7 @@ void SelectiveInstallWidget::installBootloader(void)
// open dialog to browse to of file
QString offile;
QString filter
= SystemInfo::platformValue(SystemInfo::BootloaderFilter).toString();
= PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFilter).toString();
if(!filter.isEmpty()) {
filter = tr("Bootloader files (%1)").arg(filter) + ";;";
}
@ -442,23 +430,8 @@ void SelectiveInstallWidget::installRockbox(void)
RbSettings::setValue(RbSettings::Build, m_buildtype);
RbSettings::sync();
switch(m_buildtype) {
case SystemInfo::BuildRelease:
url = ServerInfo::instance()->platformValue(
ServerInfo::CurReleaseUrl, m_target).toString();
break;
case SystemInfo::BuildCurrent:
url = ServerInfo::instance()->platformValue(
ServerInfo::CurDevelUrl, m_target).toString();
break;
case SystemInfo::BuildCandidate:
url = ServerInfo::instance()->platformValue(
ServerInfo::RelCandidateUrl, m_target).toString();
break;
case SystemInfo::BuildDaily:
url = ServerInfo::instance()->platformValue(
ServerInfo::DailyUrl, m_target).toString();
}
url = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildUrl, m_buildtype).toString();
//! install build
if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater();
m_zipinstaller = new ZipInstaller(this);
@ -466,7 +439,8 @@ void SelectiveInstallWidget::installRockbox(void)
m_zipinstaller->setLogSection("Rockbox (Base)");
if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
m_zipinstaller->setCache(true);
m_zipinstaller->setLogVersion(m_versions[m_buildtype]);
m_zipinstaller->setLogVersion(PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildVersion, m_buildtype).toString());
m_zipinstaller->setMountPoint(m_mountpoint);
connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool)));
@ -497,7 +471,8 @@ void SelectiveInstallWidget::installFonts(void)
// release is empty for non-release versions (i.e. daily / current)
logversion = installInfo.release();
}
fontsurl = SystemInfo::value(SystemInfo::FontUrl, m_buildtype).toString();
fontsurl = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildFontUrl, m_buildtype).toString();
fontsurl.replace("%RELVERSION%", relversion);
// create new zip installer
@ -532,13 +507,12 @@ void SelectiveInstallWidget::installVoicefile(void)
QString voiceurl;
QString logversion;
QString relversion = installInfo.release();
if(m_buildtype != SystemInfo::BuildRelease) {
if(m_buildtype != PlayerBuildInfo::TypeRelease) {
// release is empty for non-release versions (i.e. daily / current)
logversion = installInfo.release();
}
voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, m_buildtype).toString();
voiceurl.replace("%RELVERSION%", m_versions[m_buildtype]);
voiceurl.replace("%MODEL%", m_target);
voiceurl = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildVoiceUrl, m_buildtype).toString();
voiceurl.replace("%LANGUAGE%", lang);
// create new zip installer
@ -573,18 +547,13 @@ void SelectiveInstallWidget::installManual(void)
QString manualurl;
QString logversion;
QString relversion = installInfo.release();
if(m_buildtype != SystemInfo::BuildRelease) {
if(m_buildtype != PlayerBuildInfo::TypeRelease) {
// release is empty for non-release versions (i.e. daily / current)
logversion = installInfo.release();
}
manualurl = SystemInfo::value(SystemInfo::ManualUrl, m_buildtype).toString();
manualurl.replace("%RELVERSION%", m_versions[m_buildtype]);
QString model = SystemInfo::platformValue(SystemInfo::Manual, m_target).toString();
if(model.isEmpty())
model = m_target;
manualurl.replace("%MODEL%", model);
manualurl = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BuildManualUrl, m_buildtype).toString();
if(mantype == "pdf")
manualurl.replace("%FORMAT%", ".pdf");
else
@ -644,15 +613,15 @@ void SelectiveInstallWidget::installThemes(void)
static const struct {
const char *name;
const char *pluginpath;
SystemInfo::SystemInfos zipurl; // add new games to SystemInfo
const char *rockfile;
PlayerBuildInfo::BuildInfo zipurl; // add new games to PlayerBuildInfo
} GamesList[] = {
{ "Doom", "/.rockbox/rocks/games/doom.rock", SystemInfo::DoomUrl },
{ "Duke3D", "/.rockbox/rocks/games/duke3d.rock", SystemInfo::Duke3DUrl },
{ "Quake", "/.rockbox/rocks/games/quake.rock", SystemInfo::QuakeUrl },
{ "Puzzles fonts", "/.rockbox/rocks/games/sgt-blackbox.rock", SystemInfo::PuzzFontsUrl },
{ "Wolf3D", "/.rockbox/rocks/games/wolf3d.rock", SystemInfo::Wolf3DUrl },
{ "XWorld", "/.rockbox/rocks/games/xworld.rock", SystemInfo::XWorldUrl },
{ "Doom", "games/doom.rock", PlayerBuildInfo::DoomUrl },
{ "Duke3D", "games/duke3d.rock", PlayerBuildInfo::Duke3DUrl },
{ "Quake", "games/quake.rock", PlayerBuildInfo::QuakeUrl },
{ "Puzzles fonts", "games/sgt-blackbox.rock", PlayerBuildInfo::PuzzFontsUrl },
{ "Wolf3D", "games/wolf3d.rock", PlayerBuildInfo::Wolf3DUrl },
{ "XWorld", "games/xworld.rock", PlayerBuildInfo::XWorldUrl },
};
void SelectiveInstallWidget::installGamefiles(void)
@ -665,10 +634,13 @@ void SelectiveInstallWidget::installGamefiles(void)
for(unsigned int i = 0; i < sizeof(GamesList) / sizeof(GamesList[0]); i++)
{
// check if installed Rockbox has this plugin.
if(QFileInfo(m_mountpoint + GamesList[i].pluginpath).exists()) {
if(QFileInfo(m_mountpoint + "/.rockbox/rocks/" + GamesList[i].rockfile).exists()) {
gameNames.append(GamesList[i].name);
gameUrls.append(SystemInfo::value(GamesList[i].zipurl).toString());
LOG_INFO() << gameUrls.at(gameUrls.size() - 1);
// game URLs do not depend on the actual build type, but we need
// to pass it (simplifies the API, and will allow to make them
// type specific later if needed)
gameUrls.append(PlayerBuildInfo::instance()->value(
GamesList[i].zipurl, m_buildtype).toString());
}
}

View File

@ -25,6 +25,7 @@
#include "zipinstaller.h"
#include "themesinstallwindow.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
class SelectiveInstallWidget : public QWidget
{
@ -65,9 +66,8 @@ class SelectiveInstallWidget : public QWidget
ProgressLoggerGui *m_logger;
int m_installStage;
ZipInstaller *m_zipinstaller;
QMap<SystemInfo::BuildType, QString> m_versions;
ThemesInstallWindow *m_themesinstaller;
SystemInfo::BuildType m_buildtype;
PlayerBuildInfo::BuildType m_buildtype;
};
#endif

View File

@ -20,32 +20,6 @@ rbutil_url=http://download.rockbox.org/rbutil/
info_url=http://download.rockbox.org/bootloader/bootloaders-info
download_url=http://download.rockbox.org/bootloader
[release]
build_url=https://download.rockbox.org/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-%LANGUAGE%.zip
font_url=https://download.rockbox.org/release/%RELVERSION%/rockbox-fonts-%RELVERSION%.zip
manual_url=https://download.rockbox.org/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%%FORMAT%
[release-candidate]
build_url=https://download.rockbox.org/release-candidate/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
voice_url=https://download.rockbox.org/release-candidate/%RELVERSION%/%MODEL%-%RELVERSION%-%LANGUAGE%.zip
font_url=https://download.rockbox.org/release-candidate/%RELVERSION%/rockbox-fonts-%RELVERSION%.zip
manual_url=https://download.rockbox.org/release-candidate/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%%FORMAT%
[development]
build_url=http://build.rockbox.org/data/rockbox-%MODEL%.zip
; we don't have voices for dev builds.
voice_url=https://download.rockbox.org/daily/voices/%MODEL%-%LANGUAGE%.zip
font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip
; manual is only built daily, use that one instead.
manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT%
[daily]
build_url=https://download.rockbox.org/daily/%MODEL%/rockbox-%MODEL%.zip
voice_url=https://download.rockbox.org/daily/%MODEL%/voice-%MODEL%-%LANGUAGE%.zip
font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip
manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT%
; [platforms] is used to determine the order in the device tree.
; Only devices present in this section will get displayed!
[platforms]

View File

@ -35,7 +35,7 @@
#include "system.h"
#include "systrace.h"
#include "rbsettings.h"
#include "serverinfo.h"
#include "playerbuildinfo.h"
#include "systeminfo.h"
#include "ziputil.h"
#include "infowidget.h"
@ -224,7 +224,7 @@ void RbUtilQt::downloadInfo()
ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
LOG_INFO() << "downloading build info";
daily->setFile(&buildInfo);
daily->getFile(QUrl(SystemInfo::value(SystemInfo::BuildInfoUrl).toString()));
daily->getFile(QUrl(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BuildInfoUrl).toString()));
}
@ -241,9 +241,9 @@ void RbUtilQt::downloadDone(bool error)
}
LOG_INFO() << "network status:" << daily->errorString();
// read info into ServerInfo object
// read info into PlayerBuildInfo object
buildInfo.open();
ServerInfo::instance()->readBuildInfo(buildInfo.fileName());
PlayerBuildInfo::instance()->setBuildInfo(buildInfo.fileName());
buildInfo.close();
ui.statusbar->showMessage(tr("Download build information finished."), 5000);
@ -380,11 +380,11 @@ void RbUtilQt::updateDevice()
/* Enable bootloader installation, if possible */
bool bootloaderInstallable =
SystemInfo::platformValue(SystemInfo::BootloaderMethod) != "none";
PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod).toString() != "none";
/* Enable bootloader uninstallation, if possible */
bool bootloaderUninstallable = bootloaderInstallable &&
SystemInfo::platformValue(SystemInfo::BootloaderMethod) != "fwpatcher";
PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod) != "fwpatcher";
ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable);
ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable);
ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
@ -395,10 +395,11 @@ void RbUtilQt::updateDevice()
ui.menuA_ctions->setEnabled(configurationValid);
// displayed device info
QString brand = SystemInfo::platformValue(SystemInfo::Brand).toString();
QString brand = PlayerBuildInfo::instance()->value(PlayerBuildInfo::Brand).toString();
QString name
= QString("%1 (%2)").arg(SystemInfo::platformValue(SystemInfo::Name).toString(),
ServerInfo::instance()->statusAsString());
= QString("%1 (%2)").arg(
PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName).toString(),
PlayerBuildInfo::instance()->statusAsString());
ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name));
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
@ -413,7 +414,7 @@ void RbUtilQt::updateDevice()
}
QPixmap pm;
QString m = SystemInfo::platformValue(SystemInfo::PlayerPicture).toString();
QString m = PlayerBuildInfo::instance()->value(PlayerBuildInfo::PlayerPicture).toString();
pm.load(":/icons/players/" + m + "-small.png");
pm = pm.scaledToHeight(QFontMetrics(QApplication::font()).height() * 3);
ui.labelPlayerPic->setPixmap(pm);
@ -478,14 +479,14 @@ void RbUtilQt::uninstallBootloader(void)
// create installer
BootloaderInstallBase *bl
= BootloaderInstallHelper::createBootloaderInstaller(this,
SystemInfo::platformValue(SystemInfo::BootloaderMethod).toString());
PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod).toString());
if(bl == nullptr) {
logger->addItem(tr("No uninstall method for this target known."), LOGERROR);
logger->setFinished();
return;
}
QStringList blfile = SystemInfo::platformValue(SystemInfo::BootloaderFile).toStringList();
QStringList blfile = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFile).toStringList();
QStringList blfilepath;
for(int a = 0; a < blfile.size(); a++) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
@ -610,8 +611,8 @@ bool RbUtilQt::chkConfig(QWidget *parent)
void RbUtilQt::checkUpdate(void)
{
QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
#if defined(Q_OS_WIN32)
QString url = PlayerBuildInfo::instance()->value(PlayerBuildInfo::RbutilUrl).toString();
#if defined(Q_OS_WIN32)
url += "win32/";
#elif defined(Q_OS_LINUX)
url += "linux/";
@ -678,8 +679,8 @@ void RbUtilQt::downloadUpdateDone(bool error)
// if we found something newer, display info
if(foundVersion != "")
{
QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
#if defined(Q_OS_WIN32)
QString url = PlayerBuildInfo::instance()->value(PlayerBuildInfo::RbutilUrl).toString();
#if defined(Q_OS_WIN32)
url += "win32/";
#elif defined(Q_OS_LINUX)
url += "linux/";
@ -707,7 +708,7 @@ void RbUtilQt::changeEvent(QEvent *e)
if(e->type() == QEvent::LanguageChange) {
ui.retranslateUi(this);
buildInfo.open();
ServerInfo::instance()->readBuildInfo(buildInfo.fileName());
PlayerBuildInfo::instance()->setBuildInfo(buildInfo.fileName());
buildInfo.close();
updateDevice();
} else {

View File

@ -48,7 +48,6 @@ SOURCES += \
base/voicefile.cpp \
createvoicewindow.cpp \
base/rbsettings.cpp \
base/serverinfo.cpp \
base/systeminfo.cpp \
base/system.cpp \
sysinfo.cpp \
@ -82,6 +81,7 @@ SOURCES += \
mspack/system-mspack.c \
base/mspackutil.cpp \
base/archiveutil.cpp \
base/playerbuildinfo.cpp
HEADERS += \
@ -127,7 +127,6 @@ HEADERS += \
base/voicefile.h \
createvoicewindow.h \
base/rbsettings.h \
base/serverinfo.h \
base/systeminfo.h \
sysinfo.h \
base/system.h \
@ -173,6 +172,7 @@ HEADERS += \
mspack/szdd.h \
base/mspackutil.h \
base/archiveutil.h \
base/playerbuildinfo.h
FORMS += \

View File

@ -0,0 +1,36 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 Dominik Riebeling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
// Stubs for PlayerBuildInfo unit test.
#include "rbsettings.h"
static QMap<RbSettings::UserSettings, QVariant> stubUserSettings;
void RbSettings::setValue(UserSettings setting, QVariant value)
{
stubUserSettings[setting] = value;
}
QVariant RbSettings::value(UserSettings setting)
{
return stubUserSettings[setting];
}

View File

@ -1,105 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 Dominik Riebeling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
// Stubs for ServerInfo unit test.
#include "rbsettings.h"
#include "systeminfo.h"
QVariant SystemInfo::platformValue(SystemInfo::PlatformInfo info, QString platform)
{
switch(info) {
case SystemInfo::Manual:
if (platform == "iriverh120") return "iriverh100";
if (platform == "ipodmini2g") return "ipodmini1g";
break;
case SystemInfo::BuildserverModel:
return platform.split('.').at(0);
default:
return QString();
}
return QString();
}
QVariant SystemInfo::value(SystemInfo::SystemInfos info, SystemInfo::BuildType type)
{
(void)info; // test is currently only using BuildUrl.
switch(type) {
case SystemInfo::BuildCurrent:
return QString("https://unittest/dev/rockbox-%MODEL%.zip");
case SystemInfo::BuildDaily:
return QString("https://unittest/daily/rockbox-%MODEL%-%RELVERSION%.zip");
case SystemInfo::BuildRelease:
return QString("https://unittest/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
case SystemInfo::BuildCandidate:
return QString("https://unittest/rc/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
default:
break;
}
return QString();
}
QStringList SystemInfo::platforms(SystemInfo::PlatformType type, QString variant)
{
// stub implementation: we have a fixed list of players, and only iaudiox5
// has variant iaudiox5.v
QStringList result;
result << "iriverh100" << "iriverh120" << "iriverh300"
<< "ipodmini2g" << "archosrecorder" << "archosfmrecorder"
<< "gigabeatfx" << "iaudiom3" << "sansae200" << "iriverh10";
switch (type)
{
case SystemInfo::PlatformBaseDisabled:
// return base platforms only, i.e. return iaudiox5 for iaudiox5.v
result << "iaudiox5";
break;
case SystemInfo::PlatformVariantDisabled:
// return variants for the passed variant
if (variant == "iaudiox5") {
result.clear();
result << "iaudiox5" << "iaudiox5.v";
}
else {
result.clear();
result << variant;
}
break;
case SystemInfo::PlatformAllDisabled:
// return all, both with and without variant.
result << "iaudiox5" << "iaudiox5.v";
break;
default:
break;
}
return result;
}
QVariant RbSettings::value(UserSettings setting)
{
switch (setting)
{
case RbSettings::CurrentPlatform:
return QString("ipodmini2g");
default:
return QString("");
}
}

View File

@ -0,0 +1,237 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 Dominik Riebeling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <QtTest>
#include <QObject>
#include "playerbuildinfo.h"
#include "rbsettings.h"
class TestPlayerBuildInfo : public QObject
{
Q_OBJECT
private slots:
void testBuildInfo();
void testBuildInfo_data();
void testPlayerInfo();
void testPlayerInfo_data();
};
const char* testinfo =
"[release]\n"
"build_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n"
"voice_url=https://buildurl/release/%VERSION%/voice-%TARGET%-%VERSION%.zip\n"
"manual_url=https://buildurl/release/%VERSION%/manual-%TARGET%-%VERSION%.zip\n"
"source_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-src-%VERSION%.zip\n"
"font_url=https://buildurl/release/%VERSION%/fonts-%VERSION%.zip\n"
"archosfmrecorder=3.11.2\n"
"iaudiom3=3.11.2,http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n"
"sansae200 = 3.15\n"
"iriverh100 = 3.11.2, http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n"
"iriverh120 = 3.3\n"
"iriverh300 = \n"
"[release-candidate]\n"
"build_url=https://buildurl/rc/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n"
"gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n"
"archosfmrecorder=f9dce96\n"
"archosrecorder = f9dce96\n"
"iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n"
"[development]\n"
"build_url=https://buildurl/dev/rockbox-%TARGET%.zip\n"
"iriverh100 = be1be79\n"
"iaudiox5 = be1be76\n"
"[dailies]\n"
"timestamp = 20201113\n"
"rev = 362f7a3\n"
"[daily]\n"
"build_url=https://buildurl/daily/rockbox-%TARGET%-%VERSION%.zip\n"
"iriverh100 = f9dce00\n"
"[bleeding]\n"
"timestamp = 20201114T105723Z\n"
"rev = be1be79\n"
"[status]\n"
"archosfmrecorder=3\n"
"iriverh100=2\n"
"iriverh300=1\n"
"iriverh10=0\n"
"[voices]\n"
"3.15=english,francais\n"
"3.11.2=english\n"
"daily=deutsch,english,francais\n"
;
Q_DECLARE_METATYPE(PlayerBuildInfo::BuildInfo);
Q_DECLARE_METATYPE(PlayerBuildInfo::BuildType);
Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo);
struct {
QString target;
PlayerBuildInfo::BuildInfo item;
PlayerBuildInfo::BuildType type;
QString expected;
} testdataBuild[] =
{
// release builds
{ "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeRelease, "english" },
{ "iriverh300", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" },
{ "iriverh300", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" },
{ "iriverh10", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" },
{ "iriverh10", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" },
{ "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
{ "iaudiom3", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
{ "iaudiom3", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" },
{ "sansae200", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.15" },
{ "sansae200", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.15/rockbox-sansae200-3.15.zip" },
{ "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
{ "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" },
{ "iriverh100", PlayerBuildInfo::BuildVoiceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/voice-iriverh100-3.11.2.zip" },
{ "iriverh100", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/manual-iriverh100-3.11.2.zip" },
{ "iriverh100", PlayerBuildInfo::BuildSourceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/rockbox-iriverh100-src-3.11.2.zip" },
// h120 uses the same manual as h100.
{ "iriverh120", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.3/manual-iriverh100-3.3.zip" },
{ "iriverh100", PlayerBuildInfo::BuildFontUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/fonts-3.11.2.zip" },
// rc builds
{ "gigabeatfx", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
{ "gigabeatfx", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" },
{ "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
{ "archosfmrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" },
{ "archosrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
{ "archosrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" },
{ "iaudiox5", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
{ "iaudiox5", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
{ "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
{ "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
// devel builds
{ "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iriverh100.zip" },
{ "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDevel, "be1be76" },
{ "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iaudiox5.zip" },
// daily builds
{ "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeDaily, "deutsch,english,francais" },
{ "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDaily, "f9dce00" },
{ "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDaily, "https://buildurl/daily/rockbox-iriverh100-f9dce00.zip" },
};
struct {
QString target;
PlayerBuildInfo::DeviceInfo item;
QString expected;
} testdataPlayer[] =
{
{"archosfmrecorder", PlayerBuildInfo::BuildStatus, "3"},
{ "iriverh10", PlayerBuildInfo::BuildStatus, "0" },
{ "iriverh100", PlayerBuildInfo::BuildStatus, "2" },
{ "iriverh300", PlayerBuildInfo::BuildStatus, "1" },
{ "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" },
{"archosfmrecorder", PlayerBuildInfo::DisplayName, "Jukebox Recorder FM"},
{"archosfmrecorder", PlayerBuildInfo::BootloaderMethod, "none"},
{"archosfmrecorder", PlayerBuildInfo::BootloaderName, ""},
{"archosfmrecorder", PlayerBuildInfo::BootloaderFile, ""},
{"archosfmrecorder", PlayerBuildInfo::BootloaderFilter, ""},
{"archosfmrecorder", PlayerBuildInfo::Encoder, "lame"},
{"archosfmrecorder", PlayerBuildInfo::Brand, "Archos"},
{"archosfmrecorder", PlayerBuildInfo::PlayerPicture, "archosfmrecorder"},
{"iriverh100", PlayerBuildInfo::BuildStatus, "2"},
{"iriverh100", PlayerBuildInfo::BootloaderMethod, "hex"},
{"iriverh100", PlayerBuildInfo::BootloaderFilter, "*.hex *.zip"},
{"ipodmini2g", PlayerBuildInfo::Encoder, "rbspeex"},
};
void TestPlayerBuildInfo::testBuildInfo_data()
{
QTest::addColumn<QString>("target");
QTest::addColumn<PlayerBuildInfo::BuildInfo>("item");
QTest::addColumn<PlayerBuildInfo::BuildType>("type");
QTest::addColumn<QString>("expected");
for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++)
QTest::newRow("") << testdataBuild[i].target << testdataBuild[i].item
<< testdataBuild[i].type << testdataBuild[i].expected;
}
void TestPlayerBuildInfo::testBuildInfo()
{
// create a temporary file for test input. Do not use QSettings() to allow
// creating different format variations.
QTemporaryFile tf(this);
tf.open();
QString filename = tf.fileName();
tf.write(testinfo);
tf.close();
PlayerBuildInfo::instance()->setBuildInfo(filename);
QFETCH(QString, target);
QFETCH(PlayerBuildInfo::BuildInfo, item);
QFETCH(PlayerBuildInfo::BuildType, type);
QFETCH(QString, expected);
RbSettings::setValue(RbSettings::CurrentPlatform, target);
QVariant result = PlayerBuildInfo::instance()->value(item, type);
if(result.canConvert(QMetaType::QString))
QCOMPARE(result.toString(), QString(expected));
else
QCOMPARE(result.toStringList().join(","), QString(expected));
}
// NOTE: These tests rely on rbutil.ini
void TestPlayerBuildInfo::testPlayerInfo_data()
{
QTest::addColumn<QString>("target");
QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item");
QTest::addColumn<QString>("expected");
for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++)
QTest::newRow("") << testdataPlayer[i].target << testdataPlayer[i].item
<< testdataPlayer[i].expected;
}
void TestPlayerBuildInfo::testPlayerInfo()
{
// create a temporary file for test input. Do not use QSettings() to allow
// creating different format variations.
QTemporaryFile tf(this);
tf.open();
QString filename = tf.fileName();
tf.write(testinfo);
tf.close();
PlayerBuildInfo::instance()->setBuildInfo(filename);
QFETCH(QString, target);
QFETCH(PlayerBuildInfo::DeviceInfo, item);
QFETCH(QString, expected);
QVariant result = PlayerBuildInfo::instance()->value(item, target);
if(result.canConvert(QMetaType::QString))
QCOMPARE(result.toString(), QString(expected));
else
QCOMPARE(result.toStringList().join(","), QString(expected));
}
QTEST_MAIN(TestPlayerBuildInfo)
// this include is needed because we don't use a separate header file for the
// test class. It also needs to be at the end.
#include "test-playerbuildinfo.moc"

View File

@ -18,19 +18,18 @@
QT += testlib
TEMPLATE = app
TARGET = test-serverinfo
TARGET = test-playerbuildinfo
INCLUDEPATH += . ../base stubs
# Input
SOURCES += \
test-serverinfo.cpp \
stubs/stubs-serverinfo.cpp \
../base/serverinfo.cpp
test-playerbuildinfo.cpp \
stubs/stubs-playerbuildinfo.cpp \
../base/playerbuildinfo.cpp
HEADERS += \
../base/rbsettings.h \
../base/rockboxinfo.h \
../base/systeminfo.h \
../base/serverinfo.h \
RESOURCES += ../rbutilqt.qrc

View File

@ -1,124 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2012 Dominik Riebeling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <QtTest/QtTest>
#include <QObject>
#include "serverinfo.h"
class TestServerInfo : public QObject
{
Q_OBJECT
private slots:
void testMain();
};
const char* testinfo =
"[release]\n"
"archosfmrecorder=3.11.2\n"
"iaudiom3=3.11.2,http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n"
"sansae200 = 3.11.2\n"
"iriverh100 = 3.11.2, http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n"
"iriverh300 = \n"
"[release-candidate]\n"
"gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n"
"archosfmrecorder=f9dce96\n"
"archosrecorder = f9dce96\n"
"iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n"
"[dailies]\n"
"timestamp = 20201113\n"
"rev = 362f7a3\n"
"[bleeding]\n"
"timestamp = 20201114T105723Z\n"
"rev = be1be79\n"
"[status]\n"
"archosfmrecorder=3\n"
"iriverh100=2\n"
"iriverh300=1\n"
"iriverh10=0\n"
;
struct testvector {
const char* target;
ServerInfo::ServerInfos entry;
const char* expected;
};
const struct testvector testdata[] =
{
{ "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" },
{ "archosfmrecorder", ServerInfo::CurStatus, "3" },
{ "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" },
{ "iaudiom3", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" },
{ "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" },
{ "sansae200", ServerInfo::CurReleaseUrl, "https://unittest/release/3.11.2/rockbox-sansae200-3.11.2.zip" },
{ "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" },
{ "iriverh100", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" },
{ "iriverh100", ServerInfo::CurStatus, "2" },
{ "iriverh100", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iriverh100.zip" },
{ "iriverh300", ServerInfo::CurReleaseVersion, "" },
{ "iriverh300", ServerInfo::CurReleaseUrl, "" },
{ "iriverh300", ServerInfo::CurStatus, "1" },
{ "iriverh10", ServerInfo::CurReleaseVersion, "" },
{ "iriverh10", ServerInfo::CurReleaseUrl, "" },
{ "iriverh10", ServerInfo::CurStatus, "0" },
{ "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" },
{ "gigabeatfx", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" },
{ "archosfmrecorder", ServerInfo::RelCandidateVersion, "f9dce96" },
{ "archosfmrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" },
{ "archosrecorder", ServerInfo::RelCandidateVersion, "f9dce96" },
{ "archosrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" },
{ "iaudiox5", ServerInfo::RelCandidateVersion, "f9dce96" },
{ "iaudiox5", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
{ "iaudiox5.v", ServerInfo::RelCandidateVersion, "f9dce96" },
{ "iaudiox5.v", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
{ "iaudiox5.v", ServerInfo::BleedingRevision, "be1be79" },
{ "iaudiox5.v", ServerInfo::BleedingDate, "2020-11-14T10:57:23" },
{ "iaudiox5.v", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iaudiox5.zip" },
};
void TestServerInfo::testMain()
{
// create a temporary file for test input. Do not use QSettings() to allow
// creating different format variations.
QTemporaryFile tf(this);
tf.open();
QString filename = tf.fileName();
tf.write(testinfo);
tf.close();
ServerInfo::instance()->readBuildInfo(filename);
unsigned int i;
for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
QString result = ServerInfo::instance()->platformValue(testdata[i].entry, testdata[i].target).toString();
QCOMPARE(result, QString(testdata[i].expected));
}
}
QTEST_MAIN(TestServerInfo)
// this include is needed because we don't use a separate header file for the
// test class. It also needs to be at the end.
#include "test-serverinfo.moc"

View File

@ -26,7 +26,7 @@
#include "progressloggergui.h"
#include "utils.h"
#include "rbsettings.h"
#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "rockboxinfo.h"
#include "version.h"
#include "Logger.h"
@ -84,7 +84,7 @@ void ThemesInstallWindow::downloadInfo()
LOG_INFO() << "downloading info to" << themesInfo.fileName();
themesInfo.close();
QString infoUrl = SystemInfo::value(SystemInfo::ThemesInfoUrl).toString();
QString infoUrl = PlayerBuildInfo::instance()->value(PlayerBuildInfo::ThemesInfoUrl).toString();
infoUrl.replace("%TARGET%",
RbSettings::value(RbSettings::CurrentPlatform).toString().split(".").at(0));
infoUrl.replace("%REVISION%", installInfo.revision());
@ -218,9 +218,9 @@ void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* p
iniDetails.beginGroup(cur->data(Qt::UserRole).toString());
QUrl img, txt;
txt = QUrl(QString(SystemInfo::value(SystemInfo::ThemesUrl).toString() + "/"
txt = QUrl(QString(PlayerBuildInfo::instance()->value(PlayerBuildInfo::ThemesUrl).toString() + "/"
+ iniDetails.value("descriptionfile").toString()));
img = QUrl(QString(SystemInfo::value(SystemInfo::ThemesUrl).toString() + "/"
img = QUrl(QString(PlayerBuildInfo::instance()->value(PlayerBuildInfo::ThemesUrl).toString() + "/"
+ iniDetails.value("image").toString()));
QString text;
@ -334,7 +334,7 @@ void ThemesInstallWindow::install()
QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this);
for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) {
iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString());
zip = SystemInfo::value(SystemInfo::ThemesUrl).toString()
zip = PlayerBuildInfo::instance()->value(PlayerBuildInfo::ThemesUrl).toString()
+ "/" + iniDetails.value("archive").toString();
themes.append(zip);
names.append("Theme: " +