mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
rbutil: Convert ServerInfo to singleton.
Change-Id: I29d94eb6bae084754e5e3f337c41de8354ba123c
This commit is contained in:
parent
f8fb4274ee
commit
f608de723c
7 changed files with 45 additions and 31 deletions
|
|
@ -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)");
|
||||
|
|
|
|||
|
|
@ -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 = "");
|
||||
|
||||
protected:
|
||||
ServerInfo() : serverSettings(nullptr) {}
|
||||
|
||||
private:
|
||||
//! you shouldnt call this, its a fully static class
|
||||
ServerInfo() {}
|
||||
|
||||
static ServerInfo* infoInstance;
|
||||
QSettings* serverSettings;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue