summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/serverinfo.cpp14
-rw-r--r--rbutil/rbutilqt/base/serverinfo.h21
-rw-r--r--rbutil/rbutilqt/configure.cpp5
-rw-r--r--rbutil/rbutilqt/gui/manualwidget.cpp10
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.cpp16
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp6
-rw-r--r--rbutil/rbutilqt/test/test-serverinfo.cpp4
7 files changed, 45 insertions, 31 deletions
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp
index 544348c3b1..08f7f770b7 100644
--- a/rbutil/rbutilqt/base/serverinfo.cpp
+++ b/rbutil/rbutilqt/base/serverinfo.cpp
@@ -21,7 +21,15 @@
#include "systeminfo.h"
#include "Logger.h"
-static QSettings* serverSettings = nullptr;
+ServerInfo* ServerInfo::infoInstance = nullptr;
+
+ServerInfo* ServerInfo::instance()
+{
+ if (infoInstance == nullptr) {
+ infoInstance = new ServerInfo();
+ }
+ return infoInstance;
+}
// server infos
const static struct {
@@ -131,10 +139,10 @@ QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
return value;
}
-QString ServerInfo::statusToString(int status)
+QString ServerInfo::statusAsString(QString platform)
{
QString value;
- switch(status)
+ switch(platformValue(CurStatus, platform).toInt())
{
case STATUS_RETIRED:
value = tr("Stable (Retired)");
diff --git a/rbutil/rbutilqt/base/serverinfo.h b/rbutil/rbutilqt/base/serverinfo.h
index e8d7cd5b74..9affcb6032 100644
--- a/rbutil/rbutilqt/base/serverinfo.h
+++ b/rbutil/rbutilqt/base/serverinfo.h
@@ -18,6 +18,9 @@
*
****************************************************************************/
+// Parse and provide information from build server via build-info file.
+// This is a singleton.
+
#ifndef SERVERINFO_H
#define SERVERINFO_H
@@ -47,17 +50,21 @@ class ServerInfo : public QObject
RelCandidateUrl,
};
+ static ServerInfo* instance();
+
//! read in buildinfo file
- static void readBuildInfo(QString file);
+ void readBuildInfo(QString file);
//! get a value from server info for a named platform.
- static QVariant platformValue(enum ServerInfos setting, QString platform = "");
- //! Convert status number to string
- static QString statusToString(int status);
+ QVariant platformValue(enum ServerInfos setting, QString platform = "");
+ //! Get status number as string
+ QString statusAsString(QString platform = "");
- private:
- //! you shouldnt call this, its a fully static class
- ServerInfo() {}
+ protected:
+ ServerInfo() : serverSettings(nullptr) {}
+ private:
+ static ServerInfo* infoInstance;
+ QSettings* serverSettings;
};
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index d4457a34ed..fc67cb410e 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -385,9 +385,8 @@ void Config::setDevices()
continue;
// construct display name
QString curname = SystemInfo::platformValue(
- SystemInfo::Name, platformList.at(it)).toString() +
- " (" + ServerInfo::statusToString(ServerInfo::platformValue(
- ServerInfo::CurStatus, platformList.at(it)).toInt()) +")";
+ SystemInfo::Name, platformList.at(it)).toString()
+ + " (" + ServerInfo::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));
diff --git a/rbutil/rbutilqt/gui/manualwidget.cpp b/rbutil/rbutilqt/gui/manualwidget.cpp
index ba8f6f6064..c10288df10 100644
--- a/rbutil/rbutilqt/gui/manualwidget.cpp
+++ b/rbutil/rbutilqt/gui/manualwidget.cpp
@@ -42,9 +42,9 @@ void ManualWidget::updateManual()
if(!m_platform.isEmpty())
{
ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
- .arg(ServerInfo::platformValue(ServerInfo::ManualPdfUrl, m_platform).toString()));
+ .arg(ServerInfo::instance()->platformValue(ServerInfo::ManualPdfUrl, m_platform).toString()));
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
- .arg(ServerInfo::platformValue(ServerInfo::ManualHtmlUrl, m_platform).toString()));
+ .arg(ServerInfo::instance()->platformValue(ServerInfo::ManualHtmlUrl, m_platform).toString()));
}
else {
ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
@@ -65,7 +65,7 @@ void ManualWidget::downloadManual(void)
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}
- QString manual = ServerInfo::platformValue(ServerInfo::ManualPdfUrl).toString();
+ QString manual = ServerInfo::instance()->platformValue(ServerInfo::ManualPdfUrl).toString();
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
@@ -75,12 +75,12 @@ void ManualWidget::downloadManual(void)
installer->setCache(true);
if(ui.radioPdf->isChecked()) {
- installer->setUrl(ServerInfo::platformValue(
+ installer->setUrl(ServerInfo::instance()->platformValue(
ServerInfo::ManualPdfUrl, m_platform).toString());
installer->setLogSection("Manual (PDF)");
}
else {
- installer->setUrl(ServerInfo::platformValue(
+ installer->setUrl(ServerInfo::instance()->platformValue(
ServerInfo::ManualZipUrl, m_platform).toString());
installer->setLogSection("Manual (HTML)");
}
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
index f875844c9c..805a432877 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
@@ -69,7 +69,7 @@ void SelectiveInstallWidget::selectedVersionChanged(int index)
if(current == "development")
ui.selectedDescription->setText(tr("The development version is "
"updated on every code change. Last update was on %1").arg(
- ServerInfo::platformValue(ServerInfo::BleedingDate).toString()));
+ ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString()));
if(current == "rc")
ui.selectedDescription->setText(tr("This will eventually become the "
"next Rockbox version. Install it to help testing."));
@@ -91,11 +91,11 @@ void SelectiveInstallWidget::updateVersion(void)
// re-populate all version items
m_versions.clear();
- m_versions.insert("release", ServerInfo::platformValue(ServerInfo::CurReleaseVersion).toString());
+ m_versions.insert("release", ServerInfo::instance()->platformValue(ServerInfo::CurReleaseVersion).toString());
// Don't populate RC or development selections if target has been retired.
- if (ServerInfo::platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) {
- m_versions.insert("development", ServerInfo::platformValue(ServerInfo::BleedingRevision).toString());
- m_versions.insert("rc", ServerInfo::platformValue(ServerInfo::RelCandidateVersion).toString());
+ if (ServerInfo::instance()->platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) {
+ m_versions.insert("development", ServerInfo::instance()->platformValue(ServerInfo::BleedingRevision).toString());
+ m_versions.insert("rc", ServerInfo::instance()->platformValue(ServerInfo::RelCandidateVersion).toString());
}
ui.selectedVersion->clear();
@@ -385,11 +385,11 @@ void SelectiveInstallWidget::installRockbox(void)
RbSettings::setValue(RbSettings::Build, selected);
RbSettings::sync();
- if(selected == "release") url = ServerInfo::platformValue(
+ if(selected == "release") url = ServerInfo::instance()->platformValue(
ServerInfo::CurReleaseUrl, m_target).toString();
- else if(selected == "development") url = ServerInfo::platformValue(
+ else if(selected == "development") url = ServerInfo::instance()->platformValue(
ServerInfo::CurDevelUrl, m_target).toString();
- else if(selected == "rc") url = ServerInfo::platformValue(
+ else if(selected == "rc") url = ServerInfo::instance()->platformValue(
ServerInfo::RelCandidateUrl, m_target).toString();
//! install build
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 0fb2ba562e..cd5bea57b9 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -252,7 +252,7 @@ void RbUtilQt::downloadDone(bool error)
// read info into ServerInfo object
buildInfo.open();
- ServerInfo::readBuildInfo(buildInfo.fileName());
+ ServerInfo::instance()->readBuildInfo(buildInfo.fileName());
buildInfo.close();
ui.statusbar->showMessage(tr("Download build information finished."), 5000);
@@ -408,7 +408,7 @@ void RbUtilQt::updateDevice()
QString brand = SystemInfo::platformValue(SystemInfo::Brand).toString();
QString name
= QString("%1 (%2)").arg(SystemInfo::platformValue(SystemInfo::Name).toString(),
- ServerInfo::statusToString(ServerInfo::platformValue(ServerInfo::CurStatus).toInt()));
+ ServerInfo::instance()->statusAsString());
ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name));
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
@@ -789,7 +789,7 @@ void RbUtilQt::changeEvent(QEvent *e)
if(e->type() == QEvent::LanguageChange) {
ui.retranslateUi(this);
buildInfo.open();
- ServerInfo::readBuildInfo(buildInfo.fileName());
+ ServerInfo::instance()->readBuildInfo(buildInfo.fileName());
buildInfo.close();
updateDevice();
} else {
diff --git a/rbutil/rbutilqt/test/test-serverinfo.cpp b/rbutil/rbutilqt/test/test-serverinfo.cpp
index bda939676c..bc6024e843 100644
--- a/rbutil/rbutilqt/test/test-serverinfo.cpp
+++ b/rbutil/rbutilqt/test/test-serverinfo.cpp
@@ -110,11 +110,11 @@ void TestServerInfo::testMain()
tf.write(testinfo);
tf.close();
- ServerInfo::readBuildInfo(filename);
+ ServerInfo::instance()->readBuildInfo(filename);
unsigned int i;
for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
- QString result = ServerInfo::platformValue(testdata[i].entry, testdata[i].target).toString();
+ QString result = ServerInfo::instance()->platformValue(testdata[i].entry, testdata[i].target).toString();
QCOMPARE(result, QString(testdata[i].expected));
}
}