summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-17 10:30:19 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-17 10:30:19 +0200
commit94555a0b08534ba6345d8ba65eef808b6e3d1dca (patch)
tree7184edd46f55edf86bbc5dfb39580fc8dcce0696
parentc2246905a269d1b066b5778610b5705999d9790f (diff)
downloadrockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.tar.gz
rockbox-94555a0b08534ba6345d8ba65eef808b6e3d1dca.zip
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.cpp33
-rw-r--r--rbutil/rbutilqt/base/serverinfo.h2
-rw-r--r--rbutil/rbutilqt/installwindow.cpp10
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp4
4 files changed, 33 insertions, 16 deletions
diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp
index b60245c3d5..4abaeb2aa7 100644
--- a/rbutil/rbutilqt/base/serverinfo.cpp
+++ b/rbutil/rbutilqt/base/serverinfo.cpp
@@ -31,20 +31,27 @@ const static struct {
31 const char* def; 31 const char* def;
32} ServerInfoList[] = { 32} ServerInfoList[] = {
33 { ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" }, 33 { ServerInfo::CurReleaseVersion, ":platform:/releaseversion", "" },
34 { ServerInfo::CurReleaseUrl, ":platform:/releaseurl", "" },
34 { ServerInfo::CurStatus, ":platform:/status", "Unknown" }, 35 { ServerInfo::CurStatus, ":platform:/status", "Unknown" },
35 { ServerInfo::BleedingRevision, "bleedingrev", "" }, 36 { ServerInfo::BleedingRevision, "bleedingrev", "" },
36 { ServerInfo::BleedingDate, "bleedingdate", "" }, 37 { ServerInfo::BleedingDate, "bleedingdate", "" },
38 { ServerInfo::CurDevelUrl, ":platform:/develurl", "" },
37}; 39};
38 40
39QMap<QString, QVariant> ServerInfo::serverInfos; 41QMap<QString, QVariant> ServerInfo::serverInfos;
40 42
41void ServerInfo::readBuildInfo(QString file) 43void ServerInfo::readBuildInfo(QString file)
42{ 44{
45 QString releaseBaseUrl = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
46 QString develBaseUrl = SystemInfo::value(SystemInfo::BleedingUrl).toString();
47 QString manualBaseUrl = SystemInfo::value(SystemInfo::ManualUrl).toString();
48
43 QSettings info(file, QSettings::IniFormat); 49 QSettings info(file, QSettings::IniFormat);
44 50
45 setValue(ServerInfo::BleedingRevision,info.value("bleeding/rev")); 51 QString developmentRevision = info.value("bleeding/rev").toString();
52 setValue(ServerInfo::BleedingRevision, developmentRevision);
46 QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ"); 53 QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ");
47 setValue(ServerInfo::BleedingDate,date.toString(Qt::ISODate)); 54 setValue(ServerInfo::BleedingDate, date.toString(Qt::ISODate));
48 55
49 info.beginGroup("release"); 56 info.beginGroup("release");
50 QStringList keys = info.allKeys(); 57 QStringList keys = info.allKeys();
@@ -58,13 +65,18 @@ void ServerInfo::readBuildInfo(QString file)
58 // them the same time. 65 // them the same time.
59 QStringList variants; 66 QStringList variants;
60 variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i)); 67 variants = SystemInfo::platforms(SystemInfo::PlatformVariantDisabled, platforms.at(i));
61 QVariant release; 68 QString releaseVersion;
69 QString releaseUrl;
62 info.beginGroup("release"); 70 info.beginGroup("release");
63 if(keys.contains(platforms.at(i))) { 71 if(keys.contains(platforms.at(i))) {
64 release = info.value(platforms.at(i)); 72 releaseVersion = info.value(platforms.at(i)).toString();
73 // construct release download URL
74 releaseUrl = releaseBaseUrl;
75 releaseUrl.replace("%MODEL%", platforms.at(i));
76 releaseUrl.replace("%RELVERSION%", releaseVersion);
65 } 77 }
66
67 info.endGroup(); 78 info.endGroup();
79
68 info.beginGroup("status"); 80 info.beginGroup("status");
69 QString status = tr("Unknown"); 81 QString status = tr("Unknown");
70 switch(info.value(platforms.at(i)).toInt()) 82 switch(info.value(platforms.at(i)).toInt())
@@ -82,10 +94,19 @@ void ServerInfo::readBuildInfo(QString file)
82 break; 94 break;
83 } 95 }
84 info.endGroup(); 96 info.endGroup();
97 // release and development URLs are not provided by the server but
98 // constructed.
99 QString develUrl = develBaseUrl;
100 develUrl.replace("%MODEL%", platforms.at(i));
101 develUrl.replace("%RELVERSION%", developmentRevision);
85 // set variants (if any) 102 // set variants (if any)
86 for(int j = 0; j < variants.size(); ++j) { 103 for(int j = 0; j < variants.size(); ++j) {
87 setPlatformValue(variants.at(j), ServerInfo::CurStatus, status); 104 setPlatformValue(variants.at(j), ServerInfo::CurStatus, status);
88 setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, release); 105 if(!releaseUrl.isEmpty()) {
106 setPlatformValue(variants.at(j), ServerInfo::CurReleaseVersion, releaseVersion);
107 setPlatformValue(variants.at(j), ServerInfo::CurReleaseUrl, releaseUrl);
108 }
109 setPlatformValue(variants.at(j), ServerInfo::CurDevelUrl, develUrl);
89 } 110 }
90 } 111 }
91} 112}
diff --git a/rbutil/rbutilqt/base/serverinfo.h b/rbutil/rbutilqt/base/serverinfo.h
index 69aa26f3e6..f541c86540 100644
--- a/rbutil/rbutilqt/base/serverinfo.h
+++ b/rbutil/rbutilqt/base/serverinfo.h
@@ -32,6 +32,8 @@ class ServerInfo : public QObject
32 enum ServerInfos { 32 enum ServerInfos {
33 CurReleaseVersion, 33 CurReleaseVersion,
34 CurStatus, 34 CurStatus,
35 CurReleaseUrl,
36 CurDevelUrl,
35 BleedingRevision, 37 BleedingRevision,
36 BleedingDate, 38 BleedingDate,
37 }; 39 };
diff --git a/rbutil/rbutilqt/installwindow.cpp b/rbutil/rbutilqt/installwindow.cpp
index 7a78154561..1306043027 100644
--- a/rbutil/rbutilqt/installwindow.cpp
+++ b/rbutil/rbutilqt/installwindow.cpp
@@ -118,7 +118,7 @@ void InstallWindow::accept()
118 logger = new ProgressLoggerGui(this); 118 logger = new ProgressLoggerGui(this);
119 logger->show(); 119 logger->show();
120 QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString(); 120 QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString();
121 qDebug() << "[Install] mountpoint:" << RbSettings::value(RbSettings::Mountpoint).toString(); 121 qDebug() << "[Install] mountpoint:" << mountPoint;
122 // show dialog with error if mount point is wrong 122 // show dialog with error if mount point is wrong
123 if(!QFileInfo(mountPoint).isDir()) { 123 if(!QFileInfo(mountPoint).isDir()) {
124 logger->addItem(tr("Mount point is wrong!"),LOGERROR); 124 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
@@ -127,14 +127,13 @@ void InstallWindow::accept()
127 } 127 }
128 128
129 QString myversion; 129 QString myversion;
130 QString buildname = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
131 if(ui.radioStable->isChecked()) { 130 if(ui.radioStable->isChecked()) {
132 file = SystemInfo::value(SystemInfo::ReleaseUrl).toString(); 131 file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
133 RbSettings::setValue(RbSettings::Build, "stable"); 132 RbSettings::setValue(RbSettings::Build, "stable");
134 myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString(); 133 myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString();
135 } 134 }
136 else if(ui.radioCurrent->isChecked()) { 135 else if(ui.radioCurrent->isChecked()) {
137 file = SystemInfo::value(SystemInfo::BleedingUrl).toString(); 136 file = ServerInfo::value(ServerInfo::CurDevelUrl).toString();
138 RbSettings::setValue(RbSettings::Build, "current"); 137 RbSettings::setValue(RbSettings::Build, "current");
139 myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString(); 138 myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString();
140 } 139 }
@@ -142,9 +141,6 @@ void InstallWindow::accept()
142 qDebug() << "[Install] no build selected -- this shouldn't happen"; 141 qDebug() << "[Install] no build selected -- this shouldn't happen";
143 return; 142 return;
144 } 143 }
145 file.replace("%MODEL%", buildname);
146 file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
147
148 RbSettings::sync(); 144 RbSettings::sync();
149 145
150 QString warning = Utils::checkEnvironment(false); 146 QString warning = Utils::checkEnvironment(false);
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 279b73b5be..726c4f4d36 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -529,9 +529,7 @@ void RbUtilQt::installBtn()
529 529
530bool RbUtilQt::installAuto() 530bool RbUtilQt::installAuto()
531{ 531{
532 QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString(); 532 QString file = ServerInfo::value(ServerInfo::CurReleaseUrl).toString();
533 file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
534 file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
535 533
536 // check installed Version and Target 534 // check installed Version and Target
537 QString warning = Utils::checkEnvironment(false); 535 QString warning = Utils::checkEnvironment(false);