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:
parent
c2246905a2
commit
94555a0b08
4 changed files with 33 additions and 16 deletions
|
@ -31,20 +31,27 @@ const static struct {
|
|||
const char* def;
|
||||
} ServerInfoList[] = {
|
||||
{ ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" },
|
||||
{ ServerInfo::CurReleaseUrl, ":platform:/releaseurl", "" },
|
||||
{ ServerInfo::CurStatus, ":platform:/status", "Unknown" },
|
||||
{ ServerInfo::BleedingRevision, "bleedingrev", "" },
|
||||
{ ServerInfo::BleedingDate, "bleedingdate", "" },
|
||||
{ ServerInfo::CurDevelUrl, ":platform:/develurl", "" },
|
||||
};
|
||||
|
||||
QMap<QString, QVariant> ServerInfo::serverInfos;
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
setValue(ServerInfo::BleedingDate,date.toString(Qt::ISODate));
|
||||
setValue(ServerInfo::BleedingDate, date.toString(Qt::ISODate));
|
||||
|
||||
info.beginGroup("release");
|
||||
QStringList keys = info.allKeys();
|
||||
|
@ -58,13 +65,18 @@ void ServerInfo::readBuildInfo(QString file)
|
|||
// them the same time.
|
||||
QStringList variants;
|
||||
variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i));
|
||||
QVariant release;
|
||||
QString releaseVersion;
|
||||
QString releaseUrl;
|
||||
info.beginGroup("release");
|
||||
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.beginGroup("status");
|
||||
QString status = tr("Unknown");
|
||||
switch(info.value(platforms.at(i)).toInt())
|
||||
|
@ -82,10 +94,19 @@ void ServerInfo::readBuildInfo(QString file)
|
|||
break;
|
||||
}
|
||||
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)
|
||||
for(int j = 0; j < variants.size(); ++j) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ class ServerInfo : public QObject
|
|||
enum ServerInfos {
|
||||
CurReleaseVersion,
|
||||
CurStatus,
|
||||
CurReleaseUrl,
|
||||
CurDevelUrl,
|
||||
BleedingRevision,
|
||||
BleedingDate,
|
||||
};
|
||||
|
|
|
@ -118,7 +118,7 @@ void InstallWindow::accept()
|
|||
logger = new ProgressLoggerGui(this);
|
||||
logger->show();
|
||||
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
|
||||
if(!QFileInfo(mountPoint).isDir()) {
|
||||
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
|
||||
|
@ -127,14 +127,13 @@ void InstallWindow::accept()
|
|||
}
|
||||
|
||||
QString myversion;
|
||||
QString buildname = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
||||
if(ui.radioStable->isChecked()) {
|
||||
file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
|
||||
file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
|
||||
RbSettings::setValue(RbSettings::Build, "stable");
|
||||
myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString();
|
||||
}
|
||||
else if(ui.radioCurrent->isChecked()) {
|
||||
file = SystemInfo::value(SystemInfo::BleedingUrl).toString();
|
||||
file = ServerInfo::value(ServerInfo::CurDevelUrl).toString();
|
||||
RbSettings::setValue(RbSettings::Build, "current");
|
||||
myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString();
|
||||
}
|
||||
|
@ -142,9 +141,6 @@ void InstallWindow::accept()
|
|||
qDebug() << "[Install] no build selected -- this shouldn't happen";
|
||||
return;
|
||||
}
|
||||
file.replace("%MODEL%", buildname);
|
||||
file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
|
||||
|
||||
RbSettings::sync();
|
||||
|
||||
QString warning = Utils::checkEnvironment(false);
|
||||
|
|
|
@ -529,9 +529,7 @@ void RbUtilQt::installBtn()
|
|||
|
||||
bool RbUtilQt::installAuto()
|
||||
{
|
||||
QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
|
||||
file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
|
||||
file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
|
||||
QString file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
|
||||
|
||||
// check installed Version and Target
|
||||
QString warning = Utils::checkEnvironment(false);
|
||||
|
|
Loading…
Reference in a new issue