1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #include "ui_installfrm.h"
23 Install::Install(QWidget
*parent
) : QDialog(parent
)
27 connect(ui
.radioCurrent
, SIGNAL(toggled(bool)), this, SLOT(setCached(bool)));
28 connect(ui
.radioStable
, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool)));
29 connect(ui
.radioCurrent
, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool)));
30 connect(ui
.radioArchived
, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool)));
34 void Install::setCached(bool cache
)
36 ui
.checkBoxCache
->setEnabled(!cache
);
40 void Install::setProxy(QUrl proxy_url
)
43 qDebug() << "Install::setProxy" << proxy
;
47 void Install::accept()
49 logger
= new ProgressLoggerGui(this);
51 QString mountPoint
= userSettings
->value("mountpoint").toString();
52 qDebug() << "mountpoint:" << userSettings
->value("mountpoint").toString();
53 // show dialog with error if mount point is wrong
54 if(!QFileInfo(mountPoint
).isDir()) {
55 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
62 devices
->beginGroup(userSettings
->value("platform").toString());
63 buildname
= devices
->value("platform").toString();
65 if(ui
.radioStable
->isChecked()) {
66 file
= QString("%1/rockbox-%2-%3.zip")
67 .arg(devices
->value("download_url").toString(),
68 devices
->value("last_release").toString(), buildname
);
69 fileName
= QString("rockbox-%1-%2.zip")
70 .arg(devices
->value("last_release").toString(), buildname
);
71 userSettings
->setValue("build", "stable");
72 myversion
= version
.value("rel_rev");
74 else if(ui
.radioArchived
->isChecked()) {
75 file
= QString("%1%2/rockbox-%3-%4.zip")
76 .arg(devices
->value("daily_url").toString(),
77 buildname
, buildname
, version
.value("arch_date"));
78 fileName
= QString("rockbox-%1-%2.zip")
79 .arg(buildname
, version
.value("arch_date"));
80 userSettings
->setValue("build", "archived");
81 myversion
= "r" + version
.value("arch_rev") + "-" + version
.value("arch_date");
83 else if(ui
.radioCurrent
->isChecked()) {
84 file
= QString("%1%2/rockbox.zip")
85 .arg(devices
->value("bleeding_url").toString(), buildname
);
86 fileName
= QString("rockbox.zip");
87 userSettings
->setValue("build", "current");
88 myversion
= "r" + version
.value("bleed_rev");
91 qDebug() << "no build selected -- this shouldn't happen";
96 installer
= new ZipInstaller(this);
97 installer
->setUrl(file
);
98 installer
->setProxy(proxy
);
99 installer
->setLogSection("Rockbox (Base)");
100 if(!userSettings
->value("cachedisable").toBool()
101 && !ui
.radioCurrent
->isChecked()
102 && !ui
.checkBoxCache
->isChecked())
103 installer
->setCache(userSettings
->value("cachepath",
104 QDir::tempPath()).toString());
106 installer
->setLogVersion(myversion
);
107 installer
->setMountPoint(mountPoint
);
108 installer
->install(logger
);
110 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
114 // Zip installer has finished
115 void Install::done(bool error
)
117 qDebug() << "Install::done, error:" << error
;
125 // no error, close the window, when the logger is closed
126 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
127 // add platform info to log file for later detection
128 QSettings
installlog(userSettings
->value("mountpoint").toString()
129 + "/.rockbox/rbutil.log", QSettings::IniFormat
, 0);
130 installlog
.setValue("platform", userSettings
->value("platform").toString());
135 void Install::setDetailsCurrent(bool show
)
138 ui
.labelDetails
->setText(tr("This is the absolute up to the minute "
139 "Rockbox built. A current build will get updated every time "
140 "a change is made. Latest version is r%1 (%2).")
141 .arg(version
.value("bleed_rev"), version
.value("bleed_date")));
142 if(version
.value("rel_rev").isEmpty())
143 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
144 "download a fresh copy. "
145 "<b>This is the recommended version.</b>"));
147 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
148 "download a fresh copy."));
153 void Install::setDetailsStable(bool show
)
156 ui
.labelDetails
->setText(
157 tr("This is the last released version of Rockbox."));
159 if(!version
.value("rel_rev").isEmpty())
160 ui
.labelNote
->setText(tr("<b>Note:</b>"
161 "The lastest released version is %1. "
162 "<b>This is the recommended version.</b>")
163 .arg(version
.value("rel_rev")));
164 else ui
.labelNote
->setText("");
169 void Install::setDetailsArchived(bool show
)
172 ui
.labelDetails
->setText(tr("These are automatically built each day "
173 "from the current development source code. This generally has more "
174 "features than the last release but may be much less stable. "
175 "Features may change regularly."));
176 ui
.labelNote
->setText(tr("<b>Note:</b> archived version is r%1 (%2).")
177 .arg(version
.value("arch_rev"), version
.value("arch_date")));
182 void Install::setDeviceSettings(QSettings
*dev
)
185 qDebug() << "Install::setDeviceSettings:" << devices
;
189 void Install::setVersionStrings(QMap
<QString
, QString
> ver
)
192 // version strings map is as following:
193 // rel_rev release version revision id
194 // rel_date release version release date
195 // same for arch_* and bleed_*
197 if(version
.value("arch_rev").isEmpty()) {
198 ui
.radioArchived
->setEnabled(false);
199 qDebug() << "no information about archived version available!";
202 if(!version
.value("rel_rev").isEmpty()) {
203 ui
.radioStable
->setChecked(true);
204 ui
.radioStable
->setEnabled(true);
207 ui
.radioStable
->setFont(font
);
210 ui
.radioCurrent
->setChecked(true);
211 ui
.radioStable
->setEnabled(false);
212 ui
.radioStable
->setChecked(false);
215 ui
.radioCurrent
->setFont(font
);
217 qDebug() << "Install::setVersionStrings" << version
;
220 void Install::setUserSettings(QSettings
*user
)