mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
rbutil: split RbSettings. use Stable/unstable status from server.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24331 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7fe60537d4
commit
6128bd14e9
18 changed files with 620 additions and 409 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <QtCore>
|
||||
#include "autodetection.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
|
||||
#include "../ipodpatcher/ipodpatcher.h"
|
||||
#include "../sansapatcher/sansapatcher.h"
|
||||
|
|
@ -384,9 +385,9 @@ bool Autodetection::detectUsb()
|
|||
// usbids holds the mapping in the form
|
||||
// ((VID<<16)|(PID)), targetname
|
||||
// the ini file needs to hold the IDs as hex values.
|
||||
QMap<int, QString> usbids = RbSettings::usbIdMap(RbSettings::MapDevice);
|
||||
QMap<int, QString> usberror = RbSettings::usbIdMap(RbSettings::MapError);
|
||||
QMap<int, QString> usbincompat = RbSettings::usbIdMap(RbSettings::MapIncompatible);
|
||||
QMap<int, QString> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice);
|
||||
QMap<int, QString> usberror = SystemInfo::usbIdMap(SystemInfo::MapError);
|
||||
QMap<int, QString> usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible);
|
||||
|
||||
// usb pid detection
|
||||
QList<uint32_t> attached;
|
||||
|
|
@ -405,7 +406,7 @@ bool Autodetection::detectUsb()
|
|||
return true;
|
||||
}
|
||||
QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
|
||||
if(!RbSettings::platformValue(idstring, RbSettings::CurName).toString().isEmpty()) {
|
||||
if(!SystemInfo::platformValue(idstring, SystemInfo::CurName).toString().isEmpty()) {
|
||||
m_incompat = idstring;
|
||||
qDebug() << "[USB] detected incompatible player" << m_incompat;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -18,46 +18,13 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "rbsettings.h"
|
||||
|
||||
#include "systeminfo.h"
|
||||
#include <QSettings>
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
// device settings
|
||||
const static struct {
|
||||
RbSettings::SystemSettings setting;
|
||||
const char* name;
|
||||
const char* def;
|
||||
} SystemSettingsList[] = {
|
||||
{ RbSettings::ManualUrl, "manual_url", "" },
|
||||
{ RbSettings::BleedingUrl, "bleeding_url", "" },
|
||||
{ RbSettings::BootloaderUrl, "bootloader_url", "" },
|
||||
{ RbSettings::BootloaderInfoUrl, "bootloader_info_url", "" },
|
||||
{ RbSettings::FontUrl, "font_url", "" },
|
||||
{ RbSettings::VoiceUrl, "voice_url", "" },
|
||||
{ RbSettings::DoomUrl, "doom_url", "" },
|
||||
{ RbSettings::ReleaseUrl, "release_url", "" },
|
||||
{ RbSettings::DailyUrl, "daily_url", "" },
|
||||
{ RbSettings::ServerConfUrl, "server_conf_url", "" },
|
||||
{ RbSettings::GenlangUrl, "genlang_url", "" },
|
||||
{ RbSettings::ThemesUrl, "themes_url", "" },
|
||||
{ RbSettings::RbutilUrl, "rbutil_url", "" },
|
||||
{ RbSettings::BleedingInfo, "bleeding_info", "" },
|
||||
{ RbSettings::CurPlatformName, ":platform:/name", "" },
|
||||
{ RbSettings::CurManual, ":platform:/manualname","rockbox-:platform:" },
|
||||
{ RbSettings::CurBootloaderMethod, ":platform:/bootloadermethod", "none" },
|
||||
{ RbSettings::CurBootloaderName, ":platform:/bootloadername", "" },
|
||||
{ RbSettings::CurBootloaderFile, ":platform:/bootloaderfile", "" },
|
||||
{ RbSettings::CurEncoder, ":platform:/encoder", "" },
|
||||
{ RbSettings::CurBrand, ":platform:/brand", "" },
|
||||
{ RbSettings::CurName, ":platform:/name", "" },
|
||||
{ RbSettings::CurBuildserverModel, ":platform:/buildserver_modelname", "" },
|
||||
{ RbSettings::CurConfigureModel, ":platform:/configure_modelname", "" },
|
||||
};
|
||||
|
||||
// user settings
|
||||
const static struct {
|
||||
RbSettings::UserSettings setting;
|
||||
|
|
@ -94,35 +61,11 @@ const static struct {
|
|||
{ RbSettings::EncoderVolume, ":encoder:/volume", "1.0" },
|
||||
};
|
||||
|
||||
// server settings
|
||||
const static struct {
|
||||
RbSettings::ServerSettings setting;
|
||||
const char* name;
|
||||
const char* def;
|
||||
} ServerSettingsList[] = {
|
||||
{ RbSettings::CurReleaseVersion, ":platform:/releaseversion", "" },
|
||||
{ RbSettings::CurStatus, ":platform:/status", "" },
|
||||
{ RbSettings::DailyRevision, "dailyrev", "" },
|
||||
{ RbSettings::DailyDate, "dailydate", "" },
|
||||
{ RbSettings::BleedingRevision, "bleedingrev", "" },
|
||||
{ RbSettings::BleedingDate, "bleedingdate", "" },
|
||||
};
|
||||
|
||||
//! pointer to setting object to NULL
|
||||
QSettings* RbSettings::systemSettings = NULL;
|
||||
QSettings* RbSettings::userSettings = NULL;
|
||||
//! global volatile settings
|
||||
QMap<QString, QVariant> RbSettings::serverSettings;
|
||||
|
||||
void RbSettings::ensureRbSettingsExists()
|
||||
{
|
||||
//check and create settings object
|
||||
if(systemSettings == NULL)
|
||||
{
|
||||
// only use built-in rbutil.ini
|
||||
systemSettings = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
|
||||
}
|
||||
|
||||
if(userSettings == NULL)
|
||||
{
|
||||
// portable installation:
|
||||
|
|
@ -180,22 +123,6 @@ QString RbSettings::userSettingFilename()
|
|||
return userSettings->fileName();
|
||||
}
|
||||
|
||||
QVariant RbSettings::value(enum SystemSettings setting)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(SystemSettingsList[i].setting != setting)
|
||||
i++;
|
||||
|
||||
QString s = constructSettingPath(SystemSettingsList[i].name);
|
||||
QString d = SystemSettingsList[i].def;
|
||||
d.replace(":platform:", userSettings->value("platform").toString());
|
||||
qDebug() << "[Settings] GET S:" << s << systemSettings->value(s, d).toString();
|
||||
return systemSettings->value(s, d);
|
||||
}
|
||||
|
||||
QVariant RbSettings::value(enum UserSettings setting)
|
||||
{
|
||||
QString empty;
|
||||
|
|
@ -216,24 +143,6 @@ QVariant RbSettings::subValue(QString sub, enum UserSettings setting)
|
|||
return userSettings->value(s, UserSettingsList[i].def);
|
||||
}
|
||||
|
||||
QVariant RbSettings::value(enum ServerSettings setting)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(ServerSettingsList[i].setting != setting)
|
||||
i++;
|
||||
|
||||
QString s = constructSettingPath(ServerSettingsList[i].name);
|
||||
qDebug() << "[Settings] GET SERV:" << s
|
||||
<< serverSettings.value(s, ServerSettingsList[i].def).toString();
|
||||
if(serverSettings.contains(s))
|
||||
return serverSettings.value(s);
|
||||
else
|
||||
return ServerSettingsList[i].def;
|
||||
}
|
||||
|
||||
void RbSettings::setValue(enum UserSettings setting , QVariant value)
|
||||
{
|
||||
QString empty;
|
||||
|
|
@ -254,133 +163,6 @@ void RbSettings::setSubValue(QString sub, enum UserSettings setting, QVariant va
|
|||
qDebug() << "[Settings] SET U:" << s << userSettings->value(s).toString();
|
||||
}
|
||||
|
||||
void RbSettings::setValue(enum ServerSettings setting, QVariant value)
|
||||
{
|
||||
QString empty;
|
||||
return setPlatformValue(empty, setting, value);
|
||||
}
|
||||
|
||||
void RbSettings::setPlatformValue(QString platform, enum ServerSettings setting, QVariant value)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(ServerSettingsList[i].setting != setting)
|
||||
i++;
|
||||
|
||||
QString s = ServerSettingsList[i].name;
|
||||
s.replace(":platform:", platform);
|
||||
serverSettings.insert(s, value);
|
||||
qDebug() << "[Settings] SET SERV:" << s << serverSettings.value(s).toString();
|
||||
}
|
||||
|
||||
|
||||
QVariant RbSettings::platformValue(QString platform, enum SystemSettings setting)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(SystemSettingsList[i].setting != setting)
|
||||
i++;
|
||||
|
||||
QString s = SystemSettingsList[i].name;
|
||||
s.replace(":platform:", platform);
|
||||
QString d = SystemSettingsList[i].def;
|
||||
d.replace(":platform:", platform);
|
||||
qDebug() << "[Settings] GET P:" << s << systemSettings->value(s, d).toString();
|
||||
return systemSettings->value(s, d);
|
||||
}
|
||||
|
||||
|
||||
QStringList RbSettings::platforms()
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
QStringList result;
|
||||
systemSettings->beginGroup("platforms");
|
||||
QStringList a = systemSettings->childKeys();
|
||||
systemSettings->endGroup();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
//only add not disabled targets
|
||||
QString target = systemSettings->value("platforms/"+a.at(i), "null").toString();
|
||||
if(systemSettings->value(target+"/status").toString() != "disabled")
|
||||
result.append(target);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList RbSettings::languages()
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
QStringList result;
|
||||
systemSettings->beginGroup("languages");
|
||||
QStringList a = systemSettings->childKeys();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
result.append(systemSettings->value(a.at(i), "null").toString());
|
||||
}
|
||||
systemSettings->endGroup();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString RbSettings::name(QString platform)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
return systemSettings->value(platform + "/name").toString();
|
||||
}
|
||||
|
||||
QString RbSettings::brand(QString platform)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
return systemSettings->value(platform + "/brand").toString();
|
||||
}
|
||||
|
||||
QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
|
||||
{
|
||||
ensureRbSettingsExists();
|
||||
|
||||
QMap<int, QString> map;
|
||||
// get a list of ID -> target name
|
||||
QStringList platforms;
|
||||
systemSettings->beginGroup("platforms");
|
||||
platforms = systemSettings->childKeys();
|
||||
systemSettings->endGroup();
|
||||
|
||||
QString t;
|
||||
switch(type) {
|
||||
case MapDevice:
|
||||
t = "usbid";
|
||||
break;
|
||||
case MapError:
|
||||
t = "usberror";
|
||||
break;
|
||||
case MapIncompatible:
|
||||
t = "usbincompat";
|
||||
break;
|
||||
}
|
||||
|
||||
for(int i = 0; i < platforms.size(); i++)
|
||||
{
|
||||
systemSettings->beginGroup("platforms");
|
||||
QString target = systemSettings->value(platforms.at(i)).toString();
|
||||
systemSettings->endGroup();
|
||||
systemSettings->beginGroup(target);
|
||||
QStringList ids = systemSettings->value(t).toStringList();
|
||||
int j = ids.size();
|
||||
while(j--)
|
||||
map.insert(ids.at(j).toInt(0, 16), target);
|
||||
|
||||
systemSettings->endGroup();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
QString RbSettings::constructSettingPath(QString path, QString substitute)
|
||||
{
|
||||
QString platform = userSettings->value("platform").toString();
|
||||
|
|
@ -390,7 +172,7 @@ QString RbSettings::constructSettingPath(QString path, QString substitute)
|
|||
}
|
||||
else {
|
||||
path.replace(":tts:", userSettings->value("tts").toString());
|
||||
path.replace(":encoder:", systemSettings->value(platform + "/encoder").toString());
|
||||
path.replace(":encoder:", SystemInfo::platformValue(platform,SystemInfo::CurEncoder).toString());
|
||||
}
|
||||
path.replace(":platform:", platform);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,10 @@
|
|||
|
||||
#include <QtCore>
|
||||
|
||||
class QSettings;
|
||||
|
||||
class RbSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! Type of requested usb-id map
|
||||
enum MapType {
|
||||
MapDevice,
|
||||
MapError,
|
||||
MapIncompatible,
|
||||
};
|
||||
|
||||
//! All user settings
|
||||
enum UserSettings {
|
||||
|
|
@ -68,77 +60,19 @@ class RbSettings : public QObject
|
|||
EncoderQuality,
|
||||
EncoderVolume,
|
||||
};
|
||||
|
||||
//! All system settings
|
||||
enum SystemSettings {
|
||||
ManualUrl,
|
||||
BleedingUrl,
|
||||
BootloaderUrl,
|
||||
BootloaderInfoUrl,
|
||||
FontUrl,
|
||||
VoiceUrl,
|
||||
DoomUrl,
|
||||
ReleaseUrl,
|
||||
DailyUrl,
|
||||
ServerConfUrl,
|
||||
GenlangUrl,
|
||||
ThemesUrl,
|
||||
RbutilUrl,
|
||||
BleedingInfo,
|
||||
CurPlatformName,
|
||||
CurManual,
|
||||
CurBootloaderMethod,
|
||||
CurBootloaderName,
|
||||
CurBootloaderFile,
|
||||
CurEncoder,
|
||||
CurBrand,
|
||||
CurName,
|
||||
CurBuildserverModel,
|
||||
CurConfigureModel,
|
||||
};
|
||||
|
||||
//! All Server settings
|
||||
enum ServerSettings {
|
||||
CurReleaseVersion,
|
||||
CurStatus,
|
||||
DailyRevision,
|
||||
DailyDate,
|
||||
BleedingRevision,
|
||||
BleedingDate,
|
||||
};
|
||||
|
||||
|
||||
//! call this to flush the user Settings
|
||||
static void sync();
|
||||
//! returns the filename of the usersettings file
|
||||
static QString userSettingFilename();
|
||||
//! return a list of all platforms (rbutil internal names)
|
||||
static QStringList platforms(void);
|
||||
//! returns a list of all languages
|
||||
static QStringList languages(void);
|
||||
//! maps a platform to its name
|
||||
static QString name(QString plattform);
|
||||
//! maps a platform to its brand
|
||||
static QString brand(QString plattform);
|
||||
//! returns a map of usb-ids and their targets
|
||||
static QMap<int, QString> usbIdMap(enum MapType);
|
||||
//! get a value from system settings
|
||||
static QVariant value(enum SystemSettings setting);
|
||||
//! get a value from user settings
|
||||
static QVariant value(enum UserSettings setting);
|
||||
//! get a value from server settings
|
||||
static QVariant value(enum ServerSettings setting);
|
||||
//! set a user setting value
|
||||
static void setValue(enum UserSettings setting , QVariant value);
|
||||
//! set a server setting value
|
||||
static void setValue(enum ServerSettings setting , QVariant value);
|
||||
//! get a user setting from a subvalue (ie for encoders and tts engines)
|
||||
static QVariant subValue(QString sub, enum UserSettings setting);
|
||||
//! set a user setting from a subvalue (ie for encoders and tts engines)
|
||||
static void setSubValue(QString sub, enum UserSettings setting, QVariant value);
|
||||
//! set a value for a server settings for a named platform.
|
||||
static void setPlatformValue(QString platform, enum ServerSettings setting, QVariant value);
|
||||
//! get a value from system settings for a named platform.
|
||||
static QVariant platformValue(QString platform, enum SystemSettings setting);
|
||||
|
||||
private:
|
||||
//! you shouldnt call this, its a fully static calls
|
||||
|
|
@ -148,11 +82,8 @@ class RbSettings : public QObject
|
|||
//! create a settings path, substitute platform, tts and encoder
|
||||
static QString constructSettingPath(QString path, QString substitute = QString());
|
||||
|
||||
//! pointers to our setting objects
|
||||
static QSettings *systemSettings;
|
||||
//! pointers to our setting object
|
||||
static QSettings *userSettings;
|
||||
//! global volatile settings
|
||||
static QMap<QString, QVariant> serverSettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
149
rbutil/rbutilqt/base/serverinfo.cpp
Normal file
149
rbutil/rbutilqt/base/serverinfo.cpp
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2010 by Dominik Wenger
|
||||
* $Id$
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
// server infos
|
||||
const static struct {
|
||||
ServerInfo::ServerInfos info;
|
||||
const char* name;
|
||||
const char* def;
|
||||
} ServerInfoList[] = {
|
||||
{ ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" },
|
||||
{ ServerInfo::CurStatus, ":platform:/status", "Unknown" },
|
||||
{ ServerInfo::DailyRevision, "dailyrev", "" },
|
||||
{ ServerInfo::DailyDate, "dailydate", "" },
|
||||
{ ServerInfo::BleedingRevision, "bleedingrev", "" },
|
||||
{ ServerInfo::BleedingDate, "bleedingdate", "" },
|
||||
};
|
||||
|
||||
QMap<QString, QVariant> ServerInfo::serverInfos;
|
||||
|
||||
void ServerInfo::readBuildInfo(QString file)
|
||||
{
|
||||
QSettings info(file, QSettings::IniFormat);
|
||||
|
||||
setValue(ServerInfo::DailyRevision,info.value("dailies/rev"));
|
||||
QDate date = QDate::fromString(info.value("dailies/date").toString(), "yyyyMMdd");
|
||||
setValue(ServerInfo::DailyDate,date.toString(Qt::ISODate));
|
||||
|
||||
info.beginGroup("release");
|
||||
QStringList keys = info.allKeys();
|
||||
for(int i=0; i < keys.size(); i++)
|
||||
{
|
||||
setAllConfigPlatformValue(keys[i],ServerInfo::CurReleaseVersion,info.value(keys[i]));
|
||||
}
|
||||
info.endGroup();
|
||||
|
||||
info.beginGroup("status");
|
||||
keys = info.allKeys();
|
||||
for(int i=0; i < keys.size(); i++)
|
||||
{
|
||||
switch(info.value(keys[i]).toInt())
|
||||
{
|
||||
case 1:
|
||||
ServerInfo::setAllConfigPlatformValue(keys[i],ServerInfo::CurStatus,tr("Unusable"));
|
||||
break;
|
||||
case 2:
|
||||
ServerInfo::setAllConfigPlatformValue(keys[i],ServerInfo::CurStatus,tr("Unstable"));
|
||||
break;
|
||||
case 3:
|
||||
ServerInfo::setAllConfigPlatformValue(keys[i],ServerInfo::CurStatus,tr("Stable"));
|
||||
break;
|
||||
default:
|
||||
ServerInfo::setAllConfigPlatformValue(keys[i],ServerInfo::CurStatus,tr("Unknown"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
info.endGroup();
|
||||
}
|
||||
|
||||
void ServerInfo::readBleedingInfo(QString file)
|
||||
{
|
||||
QSettings info(file, QSettings::IniFormat);
|
||||
|
||||
setValue(ServerInfo::BleedingRevision,info.value("bleeding/rev"));
|
||||
QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ");
|
||||
setValue(ServerInfo::BleedingDate,date.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QVariant ServerInfo::value(enum ServerInfos info)
|
||||
{
|
||||
// locate info item
|
||||
int i = 0;
|
||||
while(ServerInfoList[i].info != info)
|
||||
i++;
|
||||
|
||||
QString s = ServerInfoList[i].name;
|
||||
s.replace(":platform:", RbSettings::value(RbSettings::CurrentPlatform).toString());
|
||||
qDebug() << "[ServerIndo] GET:" << s << serverInfos.value(s, ServerInfoList[i].def).toString();
|
||||
return serverInfos.value(s, ServerInfoList[i].def);
|
||||
}
|
||||
|
||||
void ServerInfo::setValue(enum ServerInfos setting, QVariant value)
|
||||
{
|
||||
QString empty;
|
||||
return setPlatformValue(empty, setting, value);
|
||||
}
|
||||
|
||||
void ServerInfo::setPlatformValue(QString platform, enum ServerInfos info, QVariant value)
|
||||
{
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(ServerInfoList[i].info != info)
|
||||
i++;
|
||||
|
||||
QString s = ServerInfoList[i].name;
|
||||
s.replace(":platform:", platform);
|
||||
serverInfos.insert(s, value);
|
||||
qDebug() << "[ServerInfo] SET:" << s << serverInfos.value(s).toString();
|
||||
}
|
||||
|
||||
void ServerInfo::setAllConfigPlatformValue(QString configplatform, ServerInfos info, QVariant value)
|
||||
{
|
||||
// insert intp all platforms where configurename matches
|
||||
QStringList platforms = SystemInfo::platforms();
|
||||
for(int i =0; i < platforms.size(); i++)
|
||||
{
|
||||
if(SystemInfo::platformValue(platforms.at(i),SystemInfo::CurConfigureModel) == configplatform)
|
||||
setPlatformValue(platforms.at(i),info,value);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ServerInfo::platformValue(QString platform, enum ServerInfos info)
|
||||
{
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(ServerInfoList[i].info != info)
|
||||
i++;
|
||||
|
||||
QString s = ServerInfoList[i].name;
|
||||
s.replace(":platform:", platform);
|
||||
QString d = ServerInfoList[i].def;
|
||||
d.replace(":platform:", platform);
|
||||
qDebug() << "[ServerInfo] GET" << s << serverInfos.value(s, d).toString();
|
||||
return serverInfos.value(s, d);
|
||||
}
|
||||
|
||||
67
rbutil/rbutilqt/base/serverinfo.h
Normal file
67
rbutil/rbutilqt/base/serverinfo.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2010 by Dominik Wenger
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SERVERINFO_H
|
||||
#define SERVERINFO_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class ServerInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
//! All Server infos
|
||||
enum ServerInfos {
|
||||
CurReleaseVersion,
|
||||
CurStatus,
|
||||
DailyRevision,
|
||||
DailyDate,
|
||||
BleedingRevision,
|
||||
BleedingDate,
|
||||
};
|
||||
|
||||
//! read in buildinfo file
|
||||
static void readBuildInfo(QString file);
|
||||
//! read in bleeding info file
|
||||
static void readBleedingInfo(QString file);
|
||||
//! get a value from server info
|
||||
static QVariant value(enum ServerInfos setting);
|
||||
//! get a value from server info for a named platform.
|
||||
static QVariant platformValue(QString platform, enum ServerInfos setting);
|
||||
|
||||
private:
|
||||
//! set a server info to all platforms where configurename matches
|
||||
static void setAllConfigPlatformValue(QString configplatform,ServerInfos info, QVariant value);
|
||||
//! set a server info value
|
||||
static void setValue(enum ServerInfos setting , QVariant value);
|
||||
//! set a value for a server info for a named platform.
|
||||
static void setPlatformValue(QString platform, enum ServerInfos setting, QVariant value);
|
||||
//! you shouldnt call this, its a fully static class
|
||||
ServerInfo() {}
|
||||
|
||||
//! map of server infos
|
||||
static QMap<QString, QVariant> serverInfos;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
196
rbutil/rbutilqt/base/systeminfo.cpp
Normal file
196
rbutil/rbutilqt/base/systeminfo.cpp
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2010 by Dominik Wenger
|
||||
* $Id$
|
||||
*
|
||||
* 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 "systeminfo.h"
|
||||
#include "rbsettings.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
// device settings
|
||||
const static struct {
|
||||
SystemInfo::SystemInfos info;
|
||||
const char* name;
|
||||
const char* def;
|
||||
} SystemInfosList[] = {
|
||||
{ SystemInfo::ManualUrl, "manual_url", "" },
|
||||
{ SystemInfo::BleedingUrl, "bleeding_url", "" },
|
||||
{ SystemInfo::BootloaderUrl, "bootloader_url", "" },
|
||||
{ SystemInfo::BootloaderInfoUrl, "bootloader_info_url", "" },
|
||||
{ SystemInfo::FontUrl, "font_url", "" },
|
||||
{ SystemInfo::VoiceUrl, "voice_url", "" },
|
||||
{ SystemInfo::DoomUrl, "doom_url", "" },
|
||||
{ SystemInfo::ReleaseUrl, "release_url", "" },
|
||||
{ SystemInfo::DailyUrl, "daily_url", "" },
|
||||
{ SystemInfo::ServerConfUrl, "server_conf_url", "" },
|
||||
{ SystemInfo::GenlangUrl, "genlang_url", "" },
|
||||
{ SystemInfo::ThemesUrl, "themes_url", "" },
|
||||
{ SystemInfo::RbutilUrl, "rbutil_url", "" },
|
||||
{ SystemInfo::BleedingInfo, "bleeding_info", "" },
|
||||
{ SystemInfo::CurPlatformName, ":platform:/name", "" },
|
||||
{ SystemInfo::CurManual, ":platform:/manualname","rockbox-:platform:" },
|
||||
{ SystemInfo::CurBootloaderMethod, ":platform:/bootloadermethod", "none" },
|
||||
{ SystemInfo::CurBootloaderName, ":platform:/bootloadername", "" },
|
||||
{ SystemInfo::CurBootloaderFile, ":platform:/bootloaderfile", "" },
|
||||
{ SystemInfo::CurEncoder, ":platform:/encoder", "" },
|
||||
{ SystemInfo::CurBrand, ":platform:/brand", "" },
|
||||
{ SystemInfo::CurName, ":platform:/name", "" },
|
||||
{ SystemInfo::CurBuildserverModel, ":platform:/buildserver_modelname", "" },
|
||||
{ SystemInfo::CurConfigureModel, ":platform:/configure_modelname", "" },
|
||||
};
|
||||
|
||||
//! pointer to setting object to NULL
|
||||
QSettings* SystemInfo::systemInfos = NULL;
|
||||
|
||||
void SystemInfo::ensureSystemInfoExists()
|
||||
{
|
||||
//check and create settings object
|
||||
if(systemInfos == NULL)
|
||||
{
|
||||
// only use built-in rbutil.ini
|
||||
systemInfos = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariant SystemInfo::value(enum SystemInfos info)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(SystemInfosList[i].info != info)
|
||||
i++;
|
||||
|
||||
QString s = SystemInfosList[i].name;
|
||||
s.replace(":platform:", RbSettings::value(RbSettings::CurrentPlatform).toString());
|
||||
QString d = SystemInfosList[i].def;
|
||||
d.replace(":platform:", RbSettings::value(RbSettings::CurrentPlatform).toString());
|
||||
qDebug() << "[SystemInfos] GET:" << s << systemInfos->value(s, d).toString();
|
||||
return systemInfos->value(s, d);
|
||||
}
|
||||
|
||||
QVariant SystemInfo::platformValue(QString platform, enum SystemInfos info)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
// locate setting item
|
||||
int i = 0;
|
||||
while(SystemInfosList[i].info != info)
|
||||
i++;
|
||||
|
||||
QString s = SystemInfosList[i].name;
|
||||
s.replace(":platform:", platform);
|
||||
QString d = SystemInfosList[i].def;
|
||||
d.replace(":platform:", platform);
|
||||
qDebug() << "[SystemInfo] GET P:" << s << systemInfos->value(s, d).toString();
|
||||
return systemInfos->value(s, d);
|
||||
}
|
||||
|
||||
QStringList SystemInfo::platforms()
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
QStringList result;
|
||||
systemInfos->beginGroup("platforms");
|
||||
QStringList a = systemInfos->childKeys();
|
||||
systemInfos->endGroup();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
//only add not disabled targets
|
||||
QString target = systemInfos->value("platforms/"+a.at(i), "null").toString();
|
||||
if(systemInfos->value(target+"/status").toString() != "disabled")
|
||||
result.append(target);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList SystemInfo::languages()
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
QStringList result;
|
||||
systemInfos->beginGroup("languages");
|
||||
QStringList a = systemInfos->childKeys();
|
||||
for(int i = 0; i < a.size(); i++)
|
||||
{
|
||||
result.append(systemInfos->value(a.at(i), "null").toString());
|
||||
}
|
||||
systemInfos->endGroup();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString SystemInfo::name(QString platform)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
return systemInfos->value(platform + "/name").toString();
|
||||
}
|
||||
|
||||
QString SystemInfo::brand(QString platform)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
return systemInfos->value(platform + "/brand").toString();
|
||||
}
|
||||
|
||||
QMap<int, QString> SystemInfo::usbIdMap(enum MapType type)
|
||||
{
|
||||
ensureSystemInfoExists();
|
||||
|
||||
QMap<int, QString> map;
|
||||
// get a list of ID -> target name
|
||||
QStringList platforms;
|
||||
systemInfos->beginGroup("platforms");
|
||||
platforms = systemInfos->childKeys();
|
||||
systemInfos->endGroup();
|
||||
|
||||
QString t;
|
||||
switch(type) {
|
||||
case MapDevice:
|
||||
t = "usbid";
|
||||
break;
|
||||
case MapError:
|
||||
t = "usberror";
|
||||
break;
|
||||
case MapIncompatible:
|
||||
t = "usbincompat";
|
||||
break;
|
||||
}
|
||||
|
||||
for(int i = 0; i < platforms.size(); i++)
|
||||
{
|
||||
systemInfos->beginGroup("platforms");
|
||||
QString target = systemInfos->value(platforms.at(i)).toString();
|
||||
systemInfos->endGroup();
|
||||
systemInfos->beginGroup(target);
|
||||
QStringList ids = systemInfos->value(t).toStringList();
|
||||
int j = ids.size();
|
||||
while(j--)
|
||||
map.insert(ids.at(j).toInt(0, 16), target);
|
||||
|
||||
systemInfos->endGroup();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
91
rbutil/rbutilqt/base/systeminfo.h
Normal file
91
rbutil/rbutilqt/base/systeminfo.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2010 by Dominik Wenger
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SYSTEMINFO_H
|
||||
#define SYSTEMINFO_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class SystemInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! Type of requested usb-id map
|
||||
enum MapType {
|
||||
MapDevice,
|
||||
MapError,
|
||||
MapIncompatible,
|
||||
};
|
||||
|
||||
//! All system settings
|
||||
enum SystemInfos {
|
||||
ManualUrl,
|
||||
BleedingUrl,
|
||||
BootloaderUrl,
|
||||
BootloaderInfoUrl,
|
||||
FontUrl,
|
||||
VoiceUrl,
|
||||
DoomUrl,
|
||||
ReleaseUrl,
|
||||
DailyUrl,
|
||||
ServerConfUrl,
|
||||
GenlangUrl,
|
||||
ThemesUrl,
|
||||
RbutilUrl,
|
||||
BleedingInfo,
|
||||
CurPlatformName,
|
||||
CurManual,
|
||||
CurBootloaderMethod,
|
||||
CurBootloaderName,
|
||||
CurBootloaderFile,
|
||||
CurEncoder,
|
||||
CurBrand,
|
||||
CurName,
|
||||
CurBuildserverModel,
|
||||
CurConfigureModel,
|
||||
};
|
||||
|
||||
//! return a list of all platforms (rbutil internal names)
|
||||
static QStringList platforms(void);
|
||||
//! returns a list of all languages
|
||||
static QStringList languages(void);
|
||||
//! maps a platform to its name
|
||||
static QString name(QString plattform);
|
||||
//! maps a platform to its brand
|
||||
static QString brand(QString plattform);
|
||||
//! returns a map of usb-ids and their targets
|
||||
static QMap<int, QString> usbIdMap(enum MapType);
|
||||
//! get a value from system settings
|
||||
static QVariant value(enum SystemInfos info);
|
||||
//! get a value from system settings for a named platform.
|
||||
static QVariant platformValue(QString platform, enum SystemInfos info);
|
||||
|
||||
private:
|
||||
//! you shouldnt call this, its a fully static calls
|
||||
SystemInfo() {}
|
||||
//! create the setting objects if neccessary
|
||||
static void ensureSystemInfoExists();
|
||||
//! pointers to our setting objects
|
||||
static QSettings *systemInfos;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "talkgenerator.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
#include "wavtrim.h"
|
||||
|
||||
TalkGenerator::TalkGenerator(QObject* parent): QObject(parent)
|
||||
|
|
@ -48,7 +49,7 @@ TalkGenerator::Status TalkGenerator::process(QList<TalkEntry>* list,int wavtrimt
|
|||
|
||||
// Encoder
|
||||
emit logItem(tr("Starting Encoder Engine"),LOGINFO);
|
||||
m_enc = EncBase::getEncoder(this,RbSettings::value(RbSettings::CurEncoder).toString());
|
||||
m_enc = EncBase::getEncoder(this,SystemInfo::value(SystemInfo::CurEncoder).toString());
|
||||
if(!m_enc->start())
|
||||
{
|
||||
emit logItem(tr("Init of Encoder engine failed"),LOGERROR);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "ttssapi.h"
|
||||
#include "utils.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
|
||||
TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
|
||||
{
|
||||
|
|
@ -31,7 +32,7 @@ TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
|
|||
void TTSSapi::generateSettings()
|
||||
{
|
||||
// language
|
||||
QStringList languages = RbSettings::languages();
|
||||
QStringList languages = SystemInfo::languages();
|
||||
languages.sort();
|
||||
EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,
|
||||
tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage),languages);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "utils.h"
|
||||
#include "system.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
#define _UNICODE
|
||||
|
|
@ -187,11 +188,11 @@ QString check(bool permission)
|
|||
// Check TargetId
|
||||
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||
QString installed = rbinfo.target();
|
||||
if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
|
||||
if(!installed.isEmpty() && installed != SystemInfo::value(SystemInfo::CurConfigureModel).toString())
|
||||
{
|
||||
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||
"Installed target: %1, selected target: %2.</li>")
|
||||
.arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
|
||||
.arg(installed, SystemInfo::value(SystemInfo::CurPlatformName).toString());
|
||||
// FIXME: replace installed by human-friendly name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "voicefile.h"
|
||||
#include "utils.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
|
||||
VoiceFileCreator::VoiceFileCreator(QObject* parent) :QObject(parent)
|
||||
{
|
||||
|
|
@ -61,7 +62,7 @@ bool VoiceFileCreator::createVoiceFile()
|
|||
version = version.left(version.indexOf("-")).remove("r");
|
||||
|
||||
//prepare download url
|
||||
QUrl genlangUrl = RbSettings::value(RbSettings::GenlangUrl).toString()
|
||||
QUrl genlangUrl = SystemInfo::value(SystemInfo::GenlangUrl).toString()
|
||||
+"?lang=" + m_lang + "&t=" + target + "&rev=" + version + "&f=" + features;
|
||||
|
||||
qDebug() << "downloading " << genlangUrl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue