- check for specific files / folders case-insensitive
[Rockbox.git] / rbutil / rbutilqt / install.cpp
blob5edef5b6eeacecd574e21db075ec71a59100f24a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
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 ****************************************************************************/
20 #include "install.h"
21 #include "ui_installfrm.h"
23 Install::Install(QWidget *parent) : QDialog(parent)
25 ui.setupUi(this);
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)
42 proxy = proxy_url;
43 qDebug() << "Install::setProxy" << proxy;
47 void Install::accept()
49 logger = new ProgressLoggerGui(this);
50 logger->show();
51 QString mountPoint = userSettings->value("defaults/mountpoint").toString();
52 qDebug() << "mountpoint:" << userSettings->value("defaults/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);
56 logger->abort();
57 return;
60 QString myversion;
61 QString buildname;
62 devices->beginGroup(userSettings->value("defaults/platform").toString());
63 buildname = devices->value("platform").toString();
64 devices->endGroup();
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("defaults/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("defaults/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("defaults/build", "current");
88 myversion = "r" + version.value("bleed_rev");
90 else {
91 qDebug() << "no build selected -- this shouldn't happen";
92 return;
94 userSettings->sync();
96 installer = new ZipInstaller(this);
97 installer->setUrl(file);
98 installer->setProxy(proxy);
99 installer->setLogSection("Rockbox (Base)");
100 if(!userSettings->value("defaults/cachedisable").toBool()
101 && !ui.radioCurrent->isChecked()
102 && !ui.checkBoxCache->isChecked())
103 installer->setCache(userSettings->value("defaults/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;
119 if(error)
121 logger->abort();
122 return;
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("defaults/mountpoint").toString()
129 + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
130 installlog.setValue("platform", userSettings->value("defaults/platform").toString());
131 installlog.sync();
135 void Install::setDetailsCurrent(bool show)
137 if(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>"));
146 else
147 ui.labelNote->setText(tr("<b>Note:</b> This option will always "
148 "download a fresh copy."));
153 void Install::setDetailsStable(bool show)
155 if(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)
171 if(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)
184 devices = dev;
185 qDebug() << "Install::setDeviceSettings:" << devices;
189 void Install::setVersionStrings(QMap<QString, QString> ver)
191 version = 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);
205 QFont font;
206 font.setBold(true);
207 ui.radioStable->setFont(font);
209 else {
210 ui.radioCurrent->setChecked(true);
211 ui.radioStable->setEnabled(false);
212 ui.radioStable->setChecked(false);
213 QFont font;
214 font.setBold(true);
215 ui.radioCurrent->setFont(font);
217 qDebug() << "Install::setVersionStrings" << version;
220 void Install::setUserSettings(QSettings *user)
222 userSettings = user;