summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp7
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstalls5l.cpp6
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.cpp265
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.h106
-rw-r--r--rbutil/rbutilqt/base/rbsettings.cpp5
-rw-r--r--rbutil/rbutilqt/base/serverinfo.cpp157
-rw-r--r--rbutil/rbutilqt/base/serverinfo.h71
-rw-r--r--rbutil/rbutilqt/base/systeminfo.cpp85
-rw-r--r--rbutil/rbutilqt/base/systeminfo.h44
-rw-r--r--rbutil/rbutilqt/base/talkgenerator.cpp9
-rw-r--r--rbutil/rbutilqt/base/utils.cpp8
-rw-r--r--rbutil/rbutilqt/base/voicefile.cpp5
12 files changed, 395 insertions, 373 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 00918bf769..58e844b4c3 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -20,6 +20,7 @@
20#include "autodetection.h" 20#include "autodetection.h"
21#include "rbsettings.h" 21#include "rbsettings.h"
22#include "systeminfo.h" 22#include "systeminfo.h"
23#include "playerbuildinfo.h"
23 24
24#include "../ipodpatcher/ipodpatcher.h" 25#include "../ipodpatcher/ipodpatcher.h"
25#include "../sansapatcher/sansapatcher.h" 26#include "../sansapatcher/sansapatcher.h"
@@ -69,7 +70,8 @@ bool Autodetection::detect(void)
69 } 70 }
70 for(int i = 0; i < m_detected.size(); ++i) { 71 for(int i = 0; i < m_detected.size(); ++i) {
71 LOG_INFO() << "Detected player:" << m_detected.at(i).device 72 LOG_INFO() << "Detected player:" << m_detected.at(i).device
72 << "at" << m_detected.at(i).mountpoint << states[m_detected.at(i).status]; 73 << "at" << m_detected.at(i).mountpoint
74 << states[m_detected.at(i).status];
73 } 75 }
74 76
75 return m_detected.size() > 0; 77 return m_detected.size() > 0;
@@ -108,7 +110,8 @@ void Autodetection::detectUsb()
108 LOG_WARNING() << "[USB] detected problem with player" << d.device; 110 LOG_WARNING() << "[USB] detected problem with player" << d.device;
109 } 111 }
110 QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0')); 112 QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
111 if(!SystemInfo::platformValue(SystemInfo::Name, idstring).toString().isEmpty()) { 113 if(!PlayerBuildInfo::instance()->value(
114 PlayerBuildInfo::DisplayName, idstring).toString().isEmpty()) {
112 struct Detected d; 115 struct Detected d;
113 d.status = PlayerIncompatible; 116 d.status = PlayerIncompatible;
114 d.device = idstring; 117 d.device = idstring;
diff --git a/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp b/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
index e8852d6df5..3621a27e26 100644
--- a/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstalls5l.cpp
@@ -23,7 +23,7 @@
23#include "utils.h" 23#include "utils.h"
24#include "system.h" 24#include "system.h"
25#include "rbsettings.h" 25#include "rbsettings.h"
26#include "systeminfo.h" 26#include "playerbuildinfo.h"
27 27
28#include "../mks5lboot/mks5lboot.h" 28#include "../mks5lboot/mks5lboot.h"
29 29
@@ -408,8 +408,8 @@ BootloaderInstallBase::BootloaderType BootloaderInstallS5l::installed(void)
408 QString logfile = RbSettings::value(RbSettings::Mountpoint).toString() 408 QString logfile = RbSettings::value(RbSettings::Mountpoint).toString()
409 + "/.rockbox/rbutil.log"; 409 + "/.rockbox/rbutil.log";
410 QSettings s(logfile, QSettings::IniFormat, this); 410 QSettings s(logfile, QSettings::IniFormat, this);
411 QString section = SystemInfo::platformValue( 411 QString section = PlayerBuildInfo::instance()->value(
412 SystemInfo::BootloaderName).toString().section('/', -1); 412 PlayerBuildInfo::BootloaderName).toString().section('/', -1);
413 rbblInstalled = s.contains("Bootloader/" + section); 413 rbblInstalled = s.contains("Bootloader/" + section);
414 414
415 if (rbblInstalled) { 415 if (rbblInstalled) {
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.cpp b/rbutil/rbutilqt/base/playerbuildinfo.cpp
new file mode 100644
index 0000000000..fb8b121e8f
--- /dev/null
+++ b/rbutil/rbutilqt/base/playerbuildinfo.cpp
@@ -0,0 +1,265 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2020 by Dominik Riebeling
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#include "playerbuildinfo.h"
20#include "rbsettings.h"
21#include "Logger.h"
22
23PlayerBuildInfo* PlayerBuildInfo::infoInstance = nullptr;
24
25PlayerBuildInfo* PlayerBuildInfo::instance()
26{
27 if (infoInstance == nullptr) {
28 infoInstance = new PlayerBuildInfo();
29 }
30 return infoInstance;
31}
32
33// server infos
34const static struct {
35 PlayerBuildInfo::BuildInfo item;
36 const char* name;
37} ServerInfoList[] = {
38 { PlayerBuildInfo::BuildVoiceLangs, "voices/:version:" },
39 { PlayerBuildInfo::BuildVersion, ":build:/:target:" },
40 { PlayerBuildInfo::BuildUrl, ":build:/build_url" },
41 { PlayerBuildInfo::BuildVoiceUrl, ":build:/voice_url" },
42 { PlayerBuildInfo::BuildManualUrl, ":build:/manual_url" },
43 { PlayerBuildInfo::BuildSourceUrl, ":build:/source_url" },
44 { PlayerBuildInfo::BuildFontUrl, ":build:/font_url" },
45
46 // other URLs -- those are not directly related to the build, but handled here.
47 { PlayerBuildInfo::DoomUrl, "other/doom_url" },
48 { PlayerBuildInfo::Duke3DUrl, "other/duke3d_url" },
49 { PlayerBuildInfo::PuzzFontsUrl, "other/puzzfonts_url" },
50 { PlayerBuildInfo::QuakeUrl, "other/quake_url" },
51 { PlayerBuildInfo::Wolf3DUrl, "other/wolf3d_url" },
52 { PlayerBuildInfo::XWorldUrl, "other/xworld_url" },
53 { PlayerBuildInfo::MidiPatchsetUrl, "other/patcheset_url" },
54};
55
56const static struct {
57 PlayerBuildInfo::DeviceInfo item;
58 const char* name;
59} PlayerInfoList[] = {
60 { PlayerBuildInfo::BuildStatus, "status/:target:" },
61 { PlayerBuildInfo::DisplayName, ":target:/name" },
62 { PlayerBuildInfo::BootloaderMethod, ":target:/bootloadermethod" },
63 { PlayerBuildInfo::BootloaderName, ":target:/bootloadername" },
64 { PlayerBuildInfo::BootloaderFile, ":target:/bootloaderfile" },
65 { PlayerBuildInfo::BootloaderFilter, ":target:/bootloaderfilter" },
66 { PlayerBuildInfo::Encoder, ":target:/encoder" },
67 { PlayerBuildInfo::Brand, ":target:/brand" },
68 { PlayerBuildInfo::PlayerPicture, ":target:/playerpic" },
69};
70
71const static struct {
72 PlayerBuildInfo::SystemUrl item;
73 const char* name;
74} PlayerSystemUrls[] = {
75 { PlayerBuildInfo::BootloaderUrl, "bootloader/download_url" },
76 { PlayerBuildInfo::BuildInfoUrl, "build_info_url" },
77 { PlayerBuildInfo::GenlangUrl, "genlang_url" },
78 { PlayerBuildInfo::ThemesUrl, "themes_url" },
79 { PlayerBuildInfo::ThemesInfoUrl, "themes_info_url" },
80 { PlayerBuildInfo::RbutilUrl, "rbutil_url" },
81};
82
83PlayerBuildInfo::PlayerBuildInfo() :
84 serverInfo(nullptr),
85 playerInfo(":/ini/rbutil.ini", QSettings::IniFormat)
86{
87
88}
89
90void PlayerBuildInfo::setBuildInfo(QString file)
91{
92 if (serverInfo)
93 delete serverInfo;
94 LOG_INFO() << "updated:" << file;
95 serverInfo = new QSettings(file, QSettings::IniFormat);
96}
97
98QVariant PlayerBuildInfo::value(BuildInfo item, BuildType type)
99{
100 // locate setting item in server info file
101 int i = 0;
102 while(ServerInfoList[i].item != item)
103 i++;
104
105 // split of variant for target.
106 // we can have an optional variant part in the target string.
107 // For build info we don't use that.
108 QString target = RbSettings::value(RbSettings::CurrentPlatform).toString().split('.').at(0);
109
110 QString s = ServerInfoList[i].name;
111 s.replace(":target:", target);
112 QString v;
113 switch(type) {
114 case TypeRelease:
115 v = "release";
116 break;
117 case TypeCandidate:
118 v = "release-candidate";
119 break;
120 case TypeDaily:
121 v = "daily";
122 break;
123 case TypeDevel:
124 v = "development";
125 break;
126 }
127
128 QVariant result = QString();
129 if (!serverInfo)
130 return result;
131 QStringList version = serverInfo->value(v + "/" + target, "").toStringList();
132 s.replace(":build:", v);
133 s.replace(":version:", version.at(0));
134
135 // get value from server build-info
136 // we need to get a version string, otherwise the data is invalid.
137 // For invalid data return an empty string.
138 if(version.at(0).isEmpty()) {
139 LOG_INFO() << s << "(version invalid)";
140 return result;
141 }
142 if(!s.isEmpty())
143 result = serverInfo->value(s);
144
145 // depending on the actual value we need more replacements.
146 switch(item) {
147 case BuildVersion:
148 result = result.toStringList().at(0);
149 break;
150
151 case BuildUrl:
152 if(version.size() > 1) {
153 // version info has an URL appended. Takes precendence.
154 result = version.at(1);
155 }
156 break;
157
158 case BuildVoiceLangs:
159 if (type == TypeDaily)
160 s = "voices/daily";
161 result = serverInfo->value(s);
162 break;
163
164 case BuildManualUrl:
165 {
166 // special case: if playerInfo has a non-empty manualname entry for the
167 // target, use that as target for the manual name.
168 QString manualtarget = playerInfo.value(target + "/manualname", "").toString();
169 if(!manualtarget.isEmpty())
170 target = manualtarget;
171 break;
172 }
173
174 default:
175 break;
176 }
177 // if the value is a string we can replace some patterns.
178 // if we cannot convert it (f.e. for a QStringList) we leave as-is, since
179 // the conversion would return an empty type.
180 if (result.canConvert(QMetaType::QString))
181 result = result.toString()
182 .replace("%TARGET%", target)
183 .replace("%VERSION%", version.at(0));
184
185 LOG_INFO() << "B:" << s << result;
186 return result;
187}
188
189QVariant PlayerBuildInfo::value(DeviceInfo item, QString target)
190{
191 // locate setting item in server info file
192 int i = 0;
193 while(PlayerInfoList[i].item != item)
194 i++;
195
196 // split of variant for target.
197 // we can have an optional variant part in the target string.
198 // For device info we use this.
199 if (target.isEmpty())
200 target = RbSettings::value(RbSettings::CurrentPlatform).toString();
201
202 QVariant result = QString();
203
204 QString s = PlayerInfoList[i].name;
205 s.replace(":target:", target);
206
207 switch(item) {
208 case BuildStatus:
209 {
210 // build status is the only value that doesn't depend on the version
211 // but the selected target instead.
212 bool ok = false;
213 if (serverInfo)
214 result = serverInfo->value(s).toInt(&ok);
215 if (!ok)
216 result = -1;
217 break;
218 }
219
220 default:
221 result = playerInfo.value(s);
222 break;
223 }
224
225 LOG_INFO() << "T:" << s << result;
226 return result;
227}
228
229QVariant PlayerBuildInfo::value(SystemUrl item)
230{
231 // locate setting item in server info file
232 int i = 0;
233 while(PlayerSystemUrls[i].item != item)
234 i++;
235
236 QVariant result = playerInfo.value(PlayerSystemUrls[i].name);
237 LOG_INFO() << "U:" << PlayerSystemUrls[i].name << result;
238 return result;
239}
240
241
242QString PlayerBuildInfo::statusAsString(QString platform)
243{
244 QString result;
245 switch(value(BuildStatus, platform).toInt())
246 {
247 case STATUS_RETIRED:
248 result = tr("Stable (Retired)");
249 break;
250 case STATUS_UNUSABLE:
251 result = tr("Unusable");
252 break;
253 case STATUS_UNSTABLE:
254 result = tr("Unstable");
255 break;
256 case STATUS_STABLE:
257 result = tr("Stable");
258 break;
259 default:
260 result = tr("Unknown");
261 break;
262 }
263
264 return result;
265}
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.h b/rbutil/rbutilqt/base/playerbuildinfo.h
new file mode 100644
index 0000000000..81d7d97312
--- /dev/null
+++ b/rbutil/rbutilqt/base/playerbuildinfo.h
@@ -0,0 +1,106 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2020 by Dominik Riebeling
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#ifndef PLAYERBUILDINFO_H
20#define PLAYERBUILDINFO_H
21
22#include <QSettings>
23
24#define STATUS_RETIRED 0
25#define STATUS_UNUSABLE 1
26#define STATUS_UNSTABLE 2
27#define STATUS_STABLE 3
28
29// Provide information about both player and builds.
30// For build info data retrieved from the build server has to be passed.
31class PlayerBuildInfo : public QObject
32{
33public:
34
35 enum BuildType {
36 TypeRelease,
37 TypeCandidate,
38 TypeDaily,
39 TypeDevel,
40 };
41 enum BuildInfo {
42 BuildUrl,
43 BuildVersion,
44 BuildManualUrl,
45 BuildVoiceUrl,
46 BuildVoiceLangs,
47 BuildSourceUrl,
48 BuildFontUrl,
49
50 DoomUrl,
51 Duke3DUrl,
52 PuzzFontsUrl,
53 QuakeUrl,
54 Wolf3DUrl,
55 XWorldUrl,
56 MidiPatchsetUrl,
57 };
58 enum DeviceInfo {
59 BuildStatus,
60
61 DisplayName,
62 BootloaderMethod,
63 BootloaderName,
64 BootloaderFile,
65 BootloaderFilter,
66 Encoder,
67 Brand,
68 PlayerPicture,
69 };
70
71 enum SystemUrl {
72 BootloaderUrl,
73 BuildInfoUrl,
74 GenlangUrl,
75 ThemesUrl,
76 ThemesInfoUrl,
77 RbutilUrl,
78 };
79
80 static PlayerBuildInfo* instance();
81
82 //! Update with build information from server
83 void setBuildInfo(QString file);
84
85 // Get information about a device. This data does not depend on the build type.
86 QVariant value(DeviceInfo item, QString target = "");
87
88 // Get build information for currently selected player.
89 QVariant value(BuildInfo item, BuildType type);
90
91 // Get fixed download URL information
92 QVariant value(SystemUrl item);
93
94 QString statusAsString(QString target = "");
95
96protected:
97 explicit PlayerBuildInfo();
98
99private:
100 static PlayerBuildInfo* infoInstance;
101 QSettings* serverInfo;
102 QSettings playerInfo;
103
104};
105
106#endif
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp
index adb222f80e..47217a15fe 100644
--- a/rbutil/rbutilqt/base/rbsettings.cpp
+++ b/rbutil/rbutilqt/base/rbsettings.cpp
@@ -17,7 +17,7 @@
17 ****************************************************************************/ 17 ****************************************************************************/
18 18
19#include "rbsettings.h" 19#include "rbsettings.h"
20#include "systeminfo.h" 20#include "playerbuildinfo.h"
21#include <QSettings> 21#include <QSettings>
22#include "Logger.h" 22#include "Logger.h"
23 23
@@ -196,7 +196,8 @@ QString RbSettings::constructSettingPath(QString path, QString substitute)
196 } 196 }
197 else { 197 else {
198 path.replace(":tts:", userSettings->value("tts").toString()); 198 path.replace(":tts:", userSettings->value("tts").toString());
199 path.replace(":encoder:", SystemInfo::platformValue(SystemInfo::Encoder, platform).toString()); 199 path.replace(":encoder:", PlayerBuildInfo::instance()->value(
200 PlayerBuildInfo::Encoder, platform).toString());
200 } 201 }
201 path.replace(":platform:", platform); 202 path.replace(":platform:", platform);
202 } 203 }
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp
deleted file mode 100644
index 5fee75f689..0000000000
--- a/rbutil/rbutilqt/base/serverinfo.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2010 by Dominik Wenger
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#include "serverinfo.h"
20#include "rbsettings.h"
21#include "systeminfo.h"
22#include "Logger.h"
23
24ServerInfo* ServerInfo::infoInstance = nullptr;
25
26ServerInfo* ServerInfo::instance()
27{
28 if (infoInstance == nullptr) {
29 infoInstance = new ServerInfo();
30 }
31 return infoInstance;
32}
33
34// server infos
35const static struct {
36 ServerInfo::ServerInfos info;
37 const char* name;
38 const char* def;
39} ServerInfoList[] = {
40 { ServerInfo::CurReleaseVersion, "release/:platform:", "" },
41 { ServerInfo::CurReleaseUrl, "release/:platform:", "" },
42 { ServerInfo::RelCandidateVersion, "release-candidate/:platform:", "" },
43 { ServerInfo::RelCandidateUrl, "release-candidate/:platform:", "" },
44 { ServerInfo::DailyVersion, "daily/:platform:", "" },
45 { ServerInfo::DailyUrl, "daily/:platform:", "" },
46 { ServerInfo::CurStatus, "status/:platform:", "-1" },
47 { ServerInfo::BleedingRevision, "bleeding/rev", "" },
48 { ServerInfo::BleedingDate, "bleeding/timestamp", "" },
49 { ServerInfo::CurDevelUrl, "", "" },
50};
51
52void ServerInfo::readBuildInfo(QString file)
53{
54 if (serverSettings)
55 delete serverSettings;
56 serverSettings = new QSettings(file, QSettings::IniFormat);
57}
58
59
60QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
61{
62 // locate setting item in server info file
63 int i = 0;
64 while(ServerInfoList[i].info != info)
65 i++;
66
67 // replace setting name
68 if(platform.isEmpty())
69 platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
70
71 // split of variant for platform.
72 // we can have an optional variant part in the platform string.
73 // For build info we don't use that.
74 platform = platform.split('.').at(0);
75
76 QString s = ServerInfoList[i].name;
77 s.replace(":platform:", platform);
78
79 // get value
80 QVariant value = QString();
81 if(!s.isEmpty() && serverSettings)
82 value = serverSettings->value(s, ServerInfoList[i].def);
83
84 // depending on the actual value we need more replacements.
85 switch(info) {
86 case CurReleaseVersion:
87 case RelCandidateVersion:
88 case DailyVersion:
89 value = value.toStringList().at(0);
90 break;
91 case CurReleaseUrl:
92 case RelCandidateUrl:
93 case DailyUrl:
94 {
95 QString version = value.toStringList().at(0);
96 if(value.toStringList().size() > 1)
97 value = value.toStringList().at(1);
98 else if(!version.isEmpty() && info == CurReleaseUrl)
99 value = SystemInfo::value(SystemInfo::BuildUrl,
100 SystemInfo::BuildRelease).toString()
101 .replace("%MODEL%", platform)
102 .replace("%RELVERSION%", version);
103 else if(!version.isEmpty() && info == RelCandidateUrl)
104 value = SystemInfo::value(SystemInfo::BuildUrl,
105 SystemInfo::BuildCandidate).toString()
106 .replace("%MODEL%", platform)
107 .replace("%RELVERSION%", version);
108 else if(!version.isEmpty() && info == DailyUrl)
109 value = SystemInfo::value(SystemInfo::BuildUrl,
110 SystemInfo::BuildDaily).toString()
111 .replace("%MODEL%", platform)
112 .replace("%RELVERSION%", version);
113 }
114 break;
115 case CurDevelUrl:
116 value = SystemInfo::value(SystemInfo::BuildUrl,
117 SystemInfo::BuildCurrent).toString()
118 .replace("%MODEL%", platform);
119 break;
120 case BleedingDate:
121 // TODO: get rid of this, it's location specific.
122 value = QDateTime::fromString(value.toString(),
123 "yyyyMMddThhmmssZ").toString(Qt::ISODate);
124 break;
125
126 default:
127 break;
128 }
129
130 LOG_INFO() << "Server:" << value;
131 return value;
132}
133
134QString ServerInfo::statusAsString(QString platform)
135{
136 QString value;
137 switch(platformValue(CurStatus, platform).toInt())
138 {
139 case STATUS_RETIRED:
140 value = tr("Stable (Retired)");
141 break;
142 case STATUS_UNUSABLE:
143 value = tr("Unusable");
144 break;
145 case STATUS_UNSTABLE:
146 value = tr("Unstable");
147 break;
148 case STATUS_STABLE:
149 value = tr("Stable");
150 break;
151 default:
152 value = tr("Unknown");
153 break;
154 }
155
156 return value;
157}
diff --git a/rbutil/rbutilqt/base/serverinfo.h b/rbutil/rbutilqt/base/serverinfo.h
deleted file mode 100644
index 0746ec2c4f..0000000000
--- a/rbutil/rbutilqt/base/serverinfo.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2010 by Dominik Wenger
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21// Parse and provide information from build server via build-info file.
22// This is a singleton.
23
24#ifndef SERVERINFO_H
25#define SERVERINFO_H
26
27#include <QtCore>
28#define STATUS_RETIRED 0
29#define STATUS_UNUSABLE 1
30#define STATUS_UNSTABLE 2
31#define STATUS_STABLE 3
32
33class ServerInfo : public QObject
34{
35 Q_OBJECT
36 public:
37
38 //! All Server infos
39 enum ServerInfos {
40 CurReleaseVersion,
41 CurStatus,
42 CurReleaseUrl,
43 CurDevelUrl,
44 BleedingRevision,
45 BleedingDate,
46 RelCandidateVersion,
47 RelCandidateUrl,
48 DailyVersion,
49 DailyUrl
50 };
51
52 static ServerInfo* instance();
53
54 //! read in buildinfo file
55 void readBuildInfo(QString file);
56 //! get a value from server info for a named platform.
57 QVariant platformValue(enum ServerInfos setting, QString platform = "");
58 //! Get status number as string
59 QString statusAsString(QString platform = "");
60
61 protected:
62 ServerInfo() : serverSettings(nullptr) {}
63
64 private:
65 static ServerInfo* infoInstance;
66 QSettings* serverSettings;
67
68};
69
70#endif
71
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp
index 8868ba937b..aa847540b9 100644
--- a/rbutil/rbutilqt/base/systeminfo.cpp
+++ b/rbutil/rbutilqt/base/systeminfo.cpp
@@ -23,44 +23,6 @@
23#include "Logger.h" 23#include "Logger.h"
24 24
25// device settings 25// device settings
26const static struct {
27 SystemInfo::SystemInfos info;
28 const char* name;
29} SystemInfosList[] = {
30 { SystemInfo::ManualUrl, ":build:/manual_url" },
31 { SystemInfo::BuildUrl, ":build:/build_url" },
32 { SystemInfo::FontUrl, ":build:/font_url" },
33 { SystemInfo::VoiceUrl, ":build:/voice_url" },
34 { SystemInfo::BootloaderUrl, "bootloader/download_url" },
35 { SystemInfo::BootloaderInfoUrl, "bootloader/info_url" },
36 { SystemInfo::DoomUrl, "doom_url" },
37 { SystemInfo::Duke3DUrl, "duke3d_url" },
38 { SystemInfo::PuzzFontsUrl, "puzzfonts_url" },
39 { SystemInfo::QuakeUrl, "quake_url" },
40 { SystemInfo::Wolf3DUrl, "wolf3d_url" },
41 { SystemInfo::XWorldUrl, "xworld_url" },
42 { SystemInfo::BuildInfoUrl, "build_info_url" },
43 { SystemInfo::GenlangUrl, "genlang_url" },
44 { SystemInfo::ThemesUrl, "themes_url" },
45 { SystemInfo::ThemesInfoUrl, "themes_info_url" },
46 { SystemInfo::RbutilUrl, "rbutil_url" },
47};
48
49const static struct {
50 SystemInfo::PlatformInfo info;
51 const char* name;
52 const char* def;
53} PlatformInfosList[] = {
54 { SystemInfo::Manual, ":platform:/manualname", ":platform:" },
55 { SystemInfo::BootloaderMethod, ":platform:/bootloadermethod", "none" },
56 { SystemInfo::BootloaderName, ":platform:/bootloadername", "" },
57 { SystemInfo::BootloaderFile, ":platform:/bootloaderfile", "" },
58 { SystemInfo::BootloaderFilter, ":platform:/bootloaderfilter", "" },
59 { SystemInfo::Encoder, ":platform:/encoder", "" },
60 { SystemInfo::Brand, ":platform:/brand", "" },
61 { SystemInfo::Name, ":platform:/name", "" },
62 { SystemInfo::PlayerPicture, ":platform:/playerpic", "" },
63};
64 26
65//! pointer to setting object to nullptr 27//! pointer to setting object to nullptr
66QSettings* SystemInfo::systemInfos = nullptr; 28QSettings* SystemInfo::systemInfos = nullptr;
@@ -76,53 +38,6 @@ void SystemInfo::ensureSystemInfoExists()
76} 38}
77 39
78 40
79QVariant SystemInfo::value(enum SystemInfos info, BuildType type)
80{
81 ensureSystemInfoExists();
82
83 // locate setting item
84 int i = 0;
85 while(SystemInfosList[i].info != info)
86 i++;
87 QString s = SystemInfosList[i].name;
88 switch(type) {
89 case BuildDaily:
90 s.replace(":build:", "daily");
91 break;
92 case BuildCurrent:
93 s.replace(":build:", "development");
94 break;
95 case BuildCandidate:
96 s.replace(":build:", "release-candidate");
97 break;
98 case BuildRelease:
99 s.replace(":build:", "release");
100 break;
101 }
102 LOG_INFO() << "GET:" << s << systemInfos->value(s).toString();
103 return systemInfos->value(s);
104}
105
106QVariant SystemInfo::platformValue(enum PlatformInfo info, QString platform)
107{
108 ensureSystemInfoExists();
109
110 // locate setting item
111 int i = 0;
112 while(PlatformInfosList[i].info != info)
113 i++;
114
115 if (platform.isEmpty())
116 platform = RbSettings::value(RbSettings::CurrentPlatform).toString();
117
118 QString s = PlatformInfosList[i].name;
119 s.replace(":platform:", platform);
120 QString d = PlatformInfosList[i].def;
121 d.replace(":platform:", platform);
122 LOG_INFO() << "GET P:" << s << systemInfos->value(s, d).toString();
123 return systemInfos->value(s, d);
124}
125
126QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString variant) 41QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString variant)
127{ 42{
128 ensureSystemInfoExists(); 43 ensureSystemInfoExists();
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h
index 67863c2268..7b5b68131b 100644
--- a/rbutil/rbutilqt/base/systeminfo.h
+++ b/rbutil/rbutilqt/base/systeminfo.h
@@ -34,47 +34,6 @@ class SystemInfo : public QObject
34 MapIncompatible, 34 MapIncompatible,
35 }; 35 };
36 36
37 enum BuildType {
38 BuildCurrent,
39 BuildDaily,
40 BuildRelease,
41 BuildCandidate
42 };
43
44 //! All system settings
45 enum SystemInfos {
46 BuildUrl,
47 FontUrl,
48 VoiceUrl,
49 ManualUrl,
50 BootloaderUrl,
51 BootloaderInfoUrl,
52 DoomUrl,
53 Duke3DUrl,
54 QuakeUrl,
55 PuzzFontsUrl,
56 Wolf3DUrl,
57 XWorldUrl,
58 ReleaseUrl,
59 BuildInfoUrl,
60 GenlangUrl,
61 ThemesUrl,
62 ThemesInfoUrl,
63 RbutilUrl,
64 };
65
66 enum PlatformInfo {
67 Manual,
68 BootloaderMethod,
69 BootloaderName,
70 BootloaderFile,
71 BootloaderFilter,
72 Encoder,
73 Brand,
74 Name,
75 PlayerPicture,
76 };
77
78 enum PlatformType { 37 enum PlatformType {
79 PlatformAll, 38 PlatformAll,
80 PlatformAllDisabled, 39 PlatformAllDisabled,
@@ -93,9 +52,6 @@ class SystemInfo : public QObject
93 //! returns a map of usb-ids and their targets 52 //! returns a map of usb-ids and their targets
94 static QMap<int, QStringList> usbIdMap(enum MapType type); 53 static QMap<int, QStringList> usbIdMap(enum MapType type);
95 //! get a value from system settings 54 //! get a value from system settings
96 static QVariant value(enum SystemInfos info, BuildType type = BuildCurrent);
97 //! get a value from system settings for a named platform.
98 static QVariant platformValue(enum PlatformInfo info, QString platform = "");
99 55
100 private: 56 private:
101 //! you shouldnt call this, its a fully static calls 57 //! you shouldnt call this, its a fully static calls
diff --git a/rbutil/rbutilqt/base/talkgenerator.cpp b/rbutil/rbutilqt/base/talkgenerator.cpp
index 951bf0e804..9139ceb274 100644
--- a/rbutil/rbutilqt/base/talkgenerator.cpp
+++ b/rbutil/rbutilqt/base/talkgenerator.cpp
@@ -18,7 +18,7 @@
18 18
19#include "talkgenerator.h" 19#include "talkgenerator.h"
20#include "rbsettings.h" 20#include "rbsettings.h"
21#include "systeminfo.h" 21#include "playerbuildinfo.h"
22#include "wavtrim.h" 22#include "wavtrim.h"
23#include "Logger.h" 23#include "Logger.h"
24 24
@@ -56,8 +56,8 @@ TalkGenerator::Status TalkGenerator::process(QList<TalkEntry>* list,int wavtrimt
56 56
57 // Encoder 57 // Encoder
58 emit logItem(tr("Starting Encoder Engine"),LOGINFO); 58 emit logItem(tr("Starting Encoder Engine"),LOGINFO);
59 m_enc = EncoderBase::getEncoder( 59 m_enc = EncoderBase::getEncoder(this, PlayerBuildInfo::instance()->value(
60 this, SystemInfo::platformValue(SystemInfo::Encoder).toString()); 60 PlayerBuildInfo::Encoder).toString());
61 if(!m_enc->start()) 61 if(!m_enc->start())
62 { 62 {
63 emit logItem(tr("Init of Encoder engine failed"),LOGERROR); 63 emit logItem(tr("Init of Encoder engine failed"),LOGERROR);
@@ -156,7 +156,8 @@ TalkGenerator::Status TalkGenerator::voiceList(QList<TalkEntry>* list,int wavtri
156 QString error; 156 QString error;
157 LOG_INFO() << "voicing: " << list->at(i).toSpeak 157 LOG_INFO() << "voicing: " << list->at(i).toSpeak
158 << "to" << list->at(i).wavfilename; 158 << "to" << list->at(i).wavfilename;
159 TTSStatus status = m_tts->voice(list->at(i).toSpeak,list->at(i).wavfilename, &error); 159 TTSStatus status = m_tts->voice(list->at(i).toSpeak,
160 list->at(i).wavfilename, &error);
160 if(status == Warning) 161 if(status == Warning)
161 { 162 {
162 warnings = true; 163 warnings = true;
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index 2f01f42e2c..3ab8aa6906 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -20,7 +20,7 @@
20#include "rockboxinfo.h" 20#include "rockboxinfo.h"
21#include "system.h" 21#include "system.h"
22#include "rbsettings.h" 22#include "rbsettings.h"
23#include "systeminfo.h" 23#include "playerbuildinfo.h"
24#include "Logger.h" 24#include "Logger.h"
25 25
26#if !defined(_UNICODE) 26#if !defined(_UNICODE)
@@ -385,8 +385,10 @@ QString Utils::checkEnvironment(bool permission)
385 { 385 {
386 text += tr("<li>Target mismatch detected.<br/>" 386 text += tr("<li>Target mismatch detected.<br/>"
387 "Installed target: %1<br/>Selected target: %2.</li>") 387 "Installed target: %1<br/>Selected target: %2.</li>")
388 .arg(SystemInfo::platformValue(SystemInfo::Name, installed).toString(), 388 .arg(PlayerBuildInfo::instance()->value(
389 SystemInfo::platformValue(SystemInfo::Name).toString()); 389 PlayerBuildInfo::DisplayName, installed).toString(),
390 PlayerBuildInfo::instance()->value(
391 PlayerBuildInfo::DisplayName).toString());
390 } 392 }
391 393
392 if(!text.isEmpty()) 394 if(!text.isEmpty())
diff --git a/rbutil/rbutilqt/base/voicefile.cpp b/rbutil/rbutilqt/base/voicefile.cpp
index c4edac64b9..98ab96b8ab 100644
--- a/rbutil/rbutilqt/base/voicefile.cpp
+++ b/rbutil/rbutilqt/base/voicefile.cpp
@@ -21,7 +21,7 @@
21#include "utils.h" 21#include "utils.h"
22#include "rockboxinfo.h" 22#include "rockboxinfo.h"
23#include "rbsettings.h" 23#include "rbsettings.h"
24#include "systeminfo.h" 24#include "playerbuildinfo.h"
25#include "ziputil.h" 25#include "ziputil.h"
26#include "Logger.h" 26#include "Logger.h"
27 27
@@ -148,7 +148,8 @@ bool VoiceFileCreator::createVoiceFile()
148 // genlang output as previously from the webserver. 148 // genlang output as previously from the webserver.
149 149
150 // prepare download url 150 // prepare download url
151 QString genlang = SystemInfo::value(SystemInfo::GenlangUrl).toString(); 151 QString genlang = PlayerBuildInfo::instance()->value(
152 PlayerBuildInfo::GenlangUrl).toString();
152 genlang.replace("%LANG%", m_lang); 153 genlang.replace("%LANG%", m_lang);
153 genlang.replace("%TARGET%", target); 154 genlang.replace("%TARGET%", target);
154 genlang.replace("%REVISION%", version); 155 genlang.replace("%REVISION%", version);