1
0
Fork 0
forked from len0rd/rockbox

Move download URL construction to ServerInfo.

Centralize creating the URLs so it's not duplicated in two places. This also
allows to change the representation on the server more easily, since it only
requires changes in one place.

Currently only changes URLs for Rockbox builds.

Change-Id: I87277cd61f8b164bdbcd914c9873d674661a786c
This commit is contained in:
Dominik Riebeling 2012-06-17 10:30:19 +02:00
parent c2246905a2
commit 94555a0b08
4 changed files with 33 additions and 16 deletions

View file

@ -31,20 +31,27 @@ const static struct {
const char* def; const char* def;
} ServerInfoList[] = { } ServerInfoList[] = {
{ ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" }, { ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" },
{ ServerInfo::CurReleaseUrl, ":platform:/releaseurl", "" },
{ ServerInfo::CurStatus, ":platform:/status", "Unknown" }, { ServerInfo::CurStatus, ":platform:/status", "Unknown" },
{ ServerInfo::BleedingRevision, "bleedingrev", "" }, { ServerInfo::BleedingRevision, "bleedingrev", "" },
{ ServerInfo::BleedingDate, "bleedingdate", "" }, { ServerInfo::BleedingDate, "bleedingdate", "" },
{ ServerInfo::CurDevelUrl, ":platform:/develurl", "" },
}; };
QMap<QString, QVariant> ServerInfo::serverInfos; QMap<QString, QVariant> ServerInfo::serverInfos;
void ServerInfo::readBuildInfo(QString file) void ServerInfo::readBuildInfo(QString file)
{ {
QString releaseBaseUrl = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
QString develBaseUrl = SystemInfo::value(SystemInfo::BleedingUrl).toString();
QString manualBaseUrl = SystemInfo::value(SystemInfo::ManualUrl).toString();
QSettings info(file, QSettings::IniFormat); QSettings info(file, QSettings::IniFormat);
setValue(ServerInfo::BleedingRevision,info.value("bleeding/rev")); QString developmentRevision = info.value("bleeding/rev").toString();
setValue(ServerInfo::BleedingRevision, developmentRevision);
QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ"); QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ");
setValue(ServerInfo::BleedingDate,date.toString(Qt::ISODate)); setValue(ServerInfo::BleedingDate, date.toString(Qt::ISODate));
info.beginGroup("release"); info.beginGroup("release");
QStringList keys = info.allKeys(); QStringList keys = info.allKeys();
@ -58,13 +65,18 @@ void ServerInfo::readBuildInfo(QString file)
// them the same time. // them the same time.
QStringList variants; QStringList variants;
variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i)); variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i));
QVariant release; QString releaseVersion;
QString releaseUrl;
info.beginGroup("release"); info.beginGroup("release");
if(keys.contains(platforms.at(i))) { if(keys.contains(platforms.at(i))) {
release = info.value(platforms.at(i)); releaseVersion = info.value(platforms.at(i)).toString();
// construct release download URL
releaseUrl = releaseBaseUrl;
releaseUrl.replace("%MODEL%", platforms.at(i));
releaseUrl.replace("%RELVERSION%", releaseVersion);
} }
info.endGroup(); info.endGroup();
info.beginGroup("status"); info.beginGroup("status");
QString status = tr("Unknown"); QString status = tr("Unknown");
switch(info.value(platforms.at(i)).toInt()) switch(info.value(platforms.at(i)).toInt())
@ -82,10 +94,19 @@ void ServerInfo::readBuildInfo(QString file)
break; break;
} }
info.endGroup(); info.endGroup();
// release and development URLs are not provided by the server but
// constructed.
QString develUrl = develBaseUrl;
develUrl.replace("%MODEL%", platforms.at(i));
develUrl.replace("%RELVERSION%", developmentRevision);
// set variants (if any) // set variants (if any)
for(int j = 0; j < variants.size(); ++j) { for(int j = 0; j < variants.size(); ++j) {
setPlatformValue(variants.at(j), ServerInfo::CurStatus, status); setPlatformValue(variants.at(j), ServerInfo::CurStatus, status);
setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, release); if(!releaseUrl.isEmpty()) {
setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, releaseVersion);
setPlatformValue(variants.at(j), ServerInfo::CurReleaseUrl, releaseUrl);
}
setPlatformValue(variants.at(j), ServerInfo::CurDevelUrl, develUrl);
} }
} }
} }

View file

@ -32,6 +32,8 @@ class ServerInfo : public QObject
enum ServerInfos { enum ServerInfos {
CurReleaseVersion, CurReleaseVersion,
CurStatus, CurStatus,
CurReleaseUrl,
CurDevelUrl,
BleedingRevision, BleedingRevision,
BleedingDate, BleedingDate,
}; };

View file

@ -118,7 +118,7 @@ void InstallWindow::accept()
logger = new ProgressLoggerGui(this); logger = new ProgressLoggerGui(this);
logger->show(); logger->show();
QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString(); QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString();
qDebug() << "[Install] mountpoint:" << RbSettings::value(RbSettings::Mountpoint).toString(); qDebug() << "[Install] mountpoint:" << mountPoint;
// show dialog with error if mount point is wrong // show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) { if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR); logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@ -127,14 +127,13 @@ void InstallWindow::accept()
} }
QString myversion; QString myversion;
QString buildname = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
if(ui.radioStable->isChecked()) { if(ui.radioStable->isChecked()) {
file = SystemInfo::value(SystemInfo::ReleaseUrl).toString(); file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
RbSettings::setValue(RbSettings::Build, "stable"); RbSettings::setValue(RbSettings::Build, "stable");
myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString(); myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString();
} }
else if(ui.radioCurrent->isChecked()) { else if(ui.radioCurrent->isChecked()) {
file = SystemInfo::value(SystemInfo::BleedingUrl).toString(); file = ServerInfo::value(ServerInfo::CurDevelUrl).toString();
RbSettings::setValue(RbSettings::Build, "current"); RbSettings::setValue(RbSettings::Build, "current");
myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString(); myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString();
} }
@ -142,9 +141,6 @@ void InstallWindow::accept()
qDebug() << "[Install] no build selected -- this shouldn't happen"; qDebug() << "[Install] no build selected -- this shouldn't happen";
return; return;
} }
file.replace("%MODEL%", buildname);
file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
RbSettings::sync(); RbSettings::sync();
QString warning = Utils::checkEnvironment(false); QString warning = Utils::checkEnvironment(false);

View file

@ -529,9 +529,7 @@ void RbUtilQt::installBtn()
bool RbUtilQt::installAuto() bool RbUtilQt::installAuto()
{ {
QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString(); QString file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
// check installed Version and Target // check installed Version and Target
QString warning = Utils::checkEnvironment(false); QString warning = Utils::checkEnvironment(false);