extend ZipInstaller to support installing of multiple files at once (for use by the...
[Rockbox.git] / rbutil / rbutilqt / install.cpp
blob91a95340611878d4205bdb082ab56c42a711e379
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::setReleased(QString rel)
42 releasever = rel;
43 if(!rel.isEmpty()) {
44 ui.radioStable->setChecked(true);
45 ui.radioStable->setEnabled(true);
46 QFont font;
47 font.setBold(true);
48 ui.radioStable->setFont(font);
50 else {
51 ui.radioCurrent->setChecked(true);
52 ui.radioStable->setEnabled(false);
53 ui.radioStable->setChecked(false);
54 QFont font;
55 font.setBold(true);
56 ui.radioCurrent->setFont(font);
58 qDebug() << "Install::setReleased" << releasever;
63 void Install::setProxy(QUrl proxy_url)
65 proxy = proxy_url;
66 qDebug() << "Install::setProxy" << proxy;
70 void Install::accept()
72 logger = new ProgressLoggerGui(this);
73 logger->show();
74 QString mountPoint = userSettings->value("defaults/mountpoint").toString();
75 qDebug() << "mountpoint:" << userSettings->value("defaults/mountpoint").toString();
76 // show dialog with error if mount point is wrong
77 if(!QFileInfo(mountPoint).isDir()) {
78 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
79 logger->abort();
80 return;
83 if(ui.radioStable->isChecked()) {
84 file = "stable"; // FIXME: this is wrong!
85 fileName = QString("rockbox.zip");
86 userSettings->setValue("defaults/build", "stable");
88 else if(ui.radioArchived->isChecked()) {
89 file = QString("%1%2/rockbox-%3-%4.zip")
90 .arg(devices->value("daily_url").toString(),
91 userSettings->value("defaults/platform").toString(),
92 userSettings->value("defaults/platform").toString(),
93 archived);
94 fileName = QString("rockbox-%1-%2.zip")
95 .arg(userSettings->value("defaults/platform").toString(),
96 archived);
97 userSettings->setValue("defaults/build", "archived");
99 else if(ui.radioCurrent->isChecked()) {
100 file = QString("%1%2/rockbox.zip")
101 .arg(devices->value("bleeding_url").toString(),
102 userSettings->value("defaults/platform").toString());
103 fileName = QString("rockbox.zip");
104 userSettings->setValue("defaults/build", "current");
106 else {
107 qDebug() << "no build selected -- this shouldn't happen";
108 return;
110 userSettings->sync();
112 installer = new ZipInstaller(this);
113 installer->setUrl(file);
114 installer->setProxy(proxy);
115 installer->setLogSection("rockboxbase");
116 installer->setMountPoint(mountPoint);
117 installer->install(logger);
119 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
123 // Zip installer has finished
124 void Install::done(bool error)
126 qDebug() << "Install::done, error:" << error;
128 if(error)
130 logger->abort();
131 return;
134 // no error, close the window, when the logger is closed
135 connect(logger,SIGNAL(closed()),this,SLOT(close()));
140 void Install::setDetailsCurrent(bool show)
142 if(show) {
143 ui.labelDetails->setText(tr("This is the absolute up to the minute "
144 "Rockbox built. A current build will get updated every time "
145 "a change is made."));
146 if(releasever == "")
147 ui.labelNote->setText(tr("<b>Note:</b> This option will always "
148 "download a fresh copy. "
149 "<b>This is the recommended version.</b>"));
150 else
151 ui.labelNote->setText(tr("<b>Note:</b> This option will always "
152 "download a fresh copy."));
157 void Install::setDetailsStable(bool show)
159 if(show) {
160 ui.labelDetails->setText(
161 tr("This is the last released version of Rockbox."));
163 if(releasever != "") ui.labelNote->setText(tr("<b>Note:</b>"
164 "The lastest released version is %1. "
165 "<b>This is the recommended version.</b>").arg(releasever));
166 else ui.labelNote->setText("");
171 void Install::setDetailsArchived(bool show)
173 if(show) {
174 ui.labelDetails->setText(tr("These are automatically built each day "
175 "from the current development source code. This generally has more "
176 "features than the last release but may be much less stable. "
177 "Features may change regularly."));
178 ui.labelNote->setText(tr("<b>Note:</b> archived version is %1.")
179 .arg(archived));
184 void Install::setDeviceSettings(QSettings *dev)
186 devices = dev;
187 qDebug() << "Install::setDeviceSettings:" << devices;
191 void Install::setArchivedString(QString string)
193 archived = string;
194 if(archived.isEmpty()) {
195 ui.radioArchived->setEnabled(false);
196 qDebug() << "no information about archived version available!";
198 qDebug() << "Install::setArchivedString" << archived;
201 void Install::setUserSettings(QSettings *user)
203 userSettings = user;