diff options
| author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-06-17 10:30:19 +0200 |
|---|---|---|
| committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-06-17 10:30:19 +0200 |
| commit | 94555a0b08534ba6345d8ba65eef808b6e3d1dca (patch) | |
| tree | 7184edd46f55edf86bbc5dfb39580fc8dcce0696 | |
| parent | c2246905a269d1b066b5778610b5705999d9790f (diff) | |
| download | rockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.zip rockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.tar.gz rockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.tar.bz2 rockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.tar.xz | |
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
| -rw-r--r-- | rbutil/rbutilqt/base/serverinfo.cpp | 33 | ||||
| -rw-r--r-- | rbutil/rbutilqt/base/serverinfo.h | 2 | ||||
| -rw-r--r-- | rbutil/rbutilqt/installwindow.cpp | 10 | ||||
| -rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 4 |
4 files changed, 33 insertions, 16 deletions
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp index b60245c..4abaeb2 100644 --- a/rbutil/rbutilqt/base/serverinfo.cpp +++ b/rbutil/rbutilqt/base/serverinfo.cpp @@ -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); } } } diff --git a/rbutil/rbutilqt/base/serverinfo.h b/rbutil/rbutilqt/base/serverinfo.h index 69aa26f..f541c86 100644 --- a/rbutil/rbutilqt/base/serverinfo.h +++ b/rbutil/rbutilqt/base/serverinfo.h @@ -32,6 +32,8 @@ class ServerInfo : public QObject enum ServerInfos { CurReleaseVersion, CurStatus, + CurReleaseUrl, + CurDevelUrl, BleedingRevision, BleedingDate, }; diff --git a/rbutil/rbutilqt/installwindow.cpp b/rbutil/rbutilqt/installwindow.cpp index 7a78154..1306043 100644 --- a/rbutil/rbutilqt/installwindow.cpp +++ b/rbutil/rbutilqt/installwindow.cpp @@ -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); diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 279b73b..726c4f4 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -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); |