2010-01-24 21:12:11 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* 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"
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
|
|
|
|
#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", "" },
|
2012-06-17 08:30:19 +00:00
|
|
|
{ ServerInfo::CurReleaseUrl, ":platform:/releaseurl", "" },
|
2012-06-17 09:21:04 +00:00
|
|
|
{ ServerInfo::RelCandidateVersion, ":platform:/rcversion", "" },
|
|
|
|
{ ServerInfo::RelCandidateUrl, ":platform:/rcurl", "" },
|
2010-01-24 21:12:11 +00:00
|
|
|
{ ServerInfo::CurStatus, ":platform:/status", "Unknown" },
|
2012-06-18 21:16:17 +00:00
|
|
|
{ ServerInfo::ManualPdfUrl, ":platform:/manual_pdf", "" },
|
|
|
|
{ ServerInfo::ManualHtmlUrl, ":platform:/manual_html", "" },
|
|
|
|
{ ServerInfo::ManualZipUrl, ":platform:/manual_zip", "" },
|
2010-01-24 21:12:11 +00:00
|
|
|
{ ServerInfo::BleedingRevision, "bleedingrev", "" },
|
|
|
|
{ ServerInfo::BleedingDate, "bleedingdate", "" },
|
2012-06-17 08:30:19 +00:00
|
|
|
{ ServerInfo::CurDevelUrl, ":platform:/develurl", "" },
|
2012-06-02 22:50:01 +00:00
|
|
|
};
|
2010-01-24 21:12:11 +00:00
|
|
|
|
|
|
|
QMap<QString, QVariant> ServerInfo::serverInfos;
|
|
|
|
|
|
|
|
void ServerInfo::readBuildInfo(QString file)
|
|
|
|
{
|
2012-06-17 08:30:19 +00:00
|
|
|
QString releaseBaseUrl = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
|
|
|
|
QString develBaseUrl = SystemInfo::value(SystemInfo::BleedingUrl).toString();
|
|
|
|
QString manualBaseUrl = SystemInfo::value(SystemInfo::ManualUrl).toString();
|
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
QSettings info(file, QSettings::IniFormat);
|
2012-06-02 22:50:01 +00:00
|
|
|
|
2012-06-17 08:30:19 +00:00
|
|
|
QString developmentRevision = info.value("bleeding/rev").toString();
|
|
|
|
setValue(ServerInfo::BleedingRevision, developmentRevision);
|
2012-06-02 22:50:01 +00:00
|
|
|
QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ");
|
2012-06-17 08:30:19 +00:00
|
|
|
setValue(ServerInfo::BleedingDate, date.toString(Qt::ISODate));
|
2012-06-02 22:50:01 +00:00
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
info.beginGroup("release");
|
2012-06-17 11:02:22 +00:00
|
|
|
QStringList releasekeys = info.allKeys();
|
|
|
|
info.endGroup();
|
|
|
|
info.beginGroup("release-candidate");
|
|
|
|
QStringList rckeys = info.allKeys();
|
2010-01-24 21:12:11 +00:00
|
|
|
info.endGroup();
|
|
|
|
|
2010-01-31 21:57:45 +00:00
|
|
|
// get base platforms, handle variants with platforms in the loop
|
2010-02-12 20:38:17 +00:00
|
|
|
QStringList platforms = SystemInfo::platforms(SystemInfo::PlatformBaseDisabled);
|
2010-01-31 21:57:45 +00:00
|
|
|
for(int i = 0; i < platforms.size(); i++)
|
2010-01-24 21:12:11 +00:00
|
|
|
{
|
2010-01-31 21:57:45 +00:00
|
|
|
// check if there are rbutil-variants of the current platform and handle
|
|
|
|
// them the same time.
|
|
|
|
QStringList variants;
|
2010-02-12 20:38:17 +00:00
|
|
|
variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i));
|
2012-06-17 08:30:19 +00:00
|
|
|
QString releaseVersion;
|
|
|
|
QString releaseUrl;
|
2012-06-17 09:21:04 +00:00
|
|
|
QString relCandidateVersion;
|
|
|
|
QString relCandidateUrl;
|
2012-06-17 09:25:11 +00:00
|
|
|
// support two formats for "release" sections:
|
|
|
|
// - <target>=<version>. In this case the URL is constructed.
|
|
|
|
// - <target>=<version>,<url>.
|
2010-01-31 21:57:45 +00:00
|
|
|
info.beginGroup("release");
|
2012-06-17 11:02:22 +00:00
|
|
|
if(releasekeys.contains(platforms.at(i))) {
|
2012-06-17 09:25:11 +00:00
|
|
|
QStringList entry = info.value(platforms.at(i)).toStringList();
|
|
|
|
releaseVersion = entry.at(0);
|
|
|
|
if(entry.size() > 1) {
|
|
|
|
releaseUrl = entry.at(1);
|
|
|
|
}
|
2012-06-17 11:02:22 +00:00
|
|
|
else if(!releaseVersion.isEmpty()) {
|
2012-06-17 09:25:11 +00:00
|
|
|
// construct release download URL
|
|
|
|
releaseUrl = releaseBaseUrl;
|
|
|
|
releaseUrl.replace("%MODEL%", platforms.at(i));
|
|
|
|
releaseUrl.replace("%RELVERSION%", releaseVersion);
|
|
|
|
}
|
2010-01-31 21:57:45 +00:00
|
|
|
}
|
|
|
|
info.endGroup();
|
2012-06-17 09:21:04 +00:00
|
|
|
// "release-candidate" section currently only support the 2nd format.
|
|
|
|
info.beginGroup("release-candidate");
|
2012-06-17 11:02:22 +00:00
|
|
|
if(rckeys.contains(platforms.at(i))) {
|
2012-06-17 09:21:04 +00:00
|
|
|
QStringList entry = info.value(platforms.at(i)).toStringList();
|
|
|
|
if(entry.size() > 1) {
|
2012-06-17 11:02:22 +00:00
|
|
|
relCandidateVersion = entry.at(0);
|
2012-06-17 09:21:04 +00:00
|
|
|
relCandidateUrl = entry.at(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
info.endGroup();
|
|
|
|
|
2012-06-17 09:25:11 +00:00
|
|
|
// "bleeding" section (development) does not provide individual
|
|
|
|
// information but only a global revision value.
|
|
|
|
QString develUrl = develBaseUrl;
|
|
|
|
develUrl.replace("%MODEL%", platforms.at(i));
|
|
|
|
develUrl.replace("%RELVERSION%", developmentRevision);
|
2012-06-17 08:30:19 +00:00
|
|
|
|
2010-01-31 21:57:45 +00:00
|
|
|
info.beginGroup("status");
|
|
|
|
QString status = tr("Unknown");
|
|
|
|
switch(info.value(platforms.at(i)).toInt())
|
2010-01-24 21:12:11 +00:00
|
|
|
{
|
|
|
|
case 1:
|
2010-01-31 21:57:45 +00:00
|
|
|
status = tr("Unusable");
|
2010-01-24 21:12:11 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-01-31 21:57:45 +00:00
|
|
|
status = tr("Unstable");
|
2010-01-24 21:12:11 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-01-31 21:57:45 +00:00
|
|
|
status = tr("Stable");
|
2010-01-24 21:12:11 +00:00
|
|
|
break;
|
2010-01-31 21:57:45 +00:00
|
|
|
default:
|
2010-01-24 21:12:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-01-31 21:57:45 +00:00
|
|
|
info.endGroup();
|
2012-06-18 21:16:17 +00:00
|
|
|
|
|
|
|
// manual URLs
|
|
|
|
QString manualPdfUrl = manualBaseUrl;
|
|
|
|
QString manualHtmlUrl = manualBaseUrl;
|
|
|
|
QString manualZipUrl = manualBaseUrl;
|
|
|
|
|
|
|
|
QString buildservermodel = SystemInfo::platformValue(platforms.at(i),
|
|
|
|
SystemInfo::CurBuildserverModel).toString();
|
|
|
|
QString modelman = SystemInfo::platformValue(platforms.at(i),
|
|
|
|
SystemInfo::CurManual).toString();
|
|
|
|
QString manualBaseName = "rockbox-";
|
|
|
|
|
|
|
|
if(modelman.isEmpty()) manualBaseName += buildservermodel;
|
|
|
|
else manualBaseName += modelman;
|
|
|
|
|
|
|
|
manualPdfUrl.replace("%EXTENSION%", "pdf");
|
|
|
|
manualPdfUrl.replace("%MANUALBASENAME%", manualBaseName);
|
|
|
|
manualHtmlUrl.replace("%EXTENSION%", "html");
|
|
|
|
manualHtmlUrl.replace("%MANUALBASENAME%", manualBaseName + "/rockbox-build");
|
|
|
|
manualZipUrl.replace("%EXTENSION%", "zip");
|
|
|
|
manualZipUrl.replace("%MANUALBASENAME%", manualBaseName + "-html");
|
|
|
|
|
2010-01-31 21:57:45 +00:00
|
|
|
// set variants (if any)
|
|
|
|
for(int j = 0; j < variants.size(); ++j) {
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::CurStatus, status);
|
2012-06-17 08:30:19 +00:00
|
|
|
if(!releaseUrl.isEmpty()) {
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, releaseVersion);
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::CurReleaseUrl, releaseUrl);
|
|
|
|
}
|
2012-06-17 09:21:04 +00:00
|
|
|
if(!relCandidateUrl.isEmpty()) {
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::RelCandidateVersion, relCandidateVersion);
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::RelCandidateUrl, relCandidateUrl);
|
|
|
|
}
|
2012-06-17 08:30:19 +00:00
|
|
|
setPlatformValue(variants.at(j), ServerInfo::CurDevelUrl, develUrl);
|
2012-06-18 21:16:17 +00:00
|
|
|
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::ManualPdfUrl, manualPdfUrl);
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::ManualHtmlUrl, manualHtmlUrl);
|
|
|
|
setPlatformValue(variants.at(j), ServerInfo::ManualZipUrl, manualZipUrl);
|
2010-01-31 21:57:45 +00:00
|
|
|
}
|
2010-01-24 21:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-02 22:50:01 +00:00
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
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());
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "GET:" << s << serverInfos.value(s, ServerInfoList[i].def).toString();
|
2010-01-24 21:12:11 +00:00
|
|
|
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);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "SET:" << s << serverInfos.value(s).toString();
|
2010-01-24 21:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "GET:" << s << serverInfos.value(s, d).toString();
|
2010-01-24 21:12:11 +00:00
|
|
|
return serverInfos.value(s, d);
|
|
|
|
}
|
|
|
|
|