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 ****************************************************************************/
24 #include "ui_rbutilqtfrm.h"
25 #include "ui_aboutbox.h"
26 #include "configure.h"
28 #include "installbootloaderwindow.h"
29 #include "installtalkwindow.h"
31 #include "installbootloader.h"
37 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
39 absolutePath
= qApp
->applicationDirPath();
40 // use built-in rbutil.ini if no external file in binary folder
41 QString iniFile
= absolutePath
+ "/rbutil.ini";
42 if(QFileInfo(iniFile
).isFile()) {
43 qDebug() << "using external rbutil.ini";
44 devices
= new QSettings(iniFile
, QSettings::IniFormat
, 0);
47 qDebug() << "using built-in rbutil.ini";
48 devices
= new QSettings(":/ini/rbutil.ini", QSettings::IniFormat
, 0);
53 // portable installation:
54 // check for a configuration file in the program folder.
56 config
.setFile(absolutePath
+ "/RockboxUtility.ini");
58 userSettings
= new QSettings(absolutePath
+ "/RockboxUtility.ini",
59 QSettings::IniFormat
, 0);
60 qDebug() << "config: portable";
63 userSettings
= new QSettings(QSettings::IniFormat
,
64 QSettings::UserScope
, "rockbox.org", "RockboxUtility");
65 qDebug() << "config: system";
69 ui
.buttonDownloadManual
->setEnabled(false);
73 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
74 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
75 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
76 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
77 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(install()));
78 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBl()));
79 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFonts()));
80 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoom()));
81 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
82 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
85 // disable unimplemented stuff
86 ui
.buttonThemes
->setEnabled(false);
87 ui
.buttonSmall
->setEnabled(false);
88 ui
.buttonRemoveRockbox
->setEnabled(false);
89 ui
.buttonRemoveBootloader
->setEnabled(false);
90 ui
.buttonComplete
->setEnabled(false);
99 void RbUtilQt::downloadInfo()
101 // try to get the current build information
102 daily
= new HttpGet(this);
103 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
104 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
105 if(userSettings
->value("defaults/proxytype") == "manual")
106 daily
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
108 else if(userSettings
->value("defaults/proxytype") == "system")
109 daily
->setProxy(QUrl(getenv("http_proxy")));
112 qDebug() << "downloading build info";
113 daily
->setFile(&buildInfo
);
114 daily
->getFile(QUrl(devices
->value("server_conf_url").toString()));
118 void RbUtilQt::downloadDone(bool error
)
120 if(error
) qDebug() << "network error:" << daily
->error();
121 qDebug() << "network status:" << daily
->error();
126 void RbUtilQt::downloadDone(int id
, bool error
)
129 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
130 .arg(daily
->errorString());
131 if(error
) QMessageBox::about(this, "Network Error", errorString
);
132 qDebug() << "downloadDone:" << id
<< error
;
136 void RbUtilQt::about()
138 QDialog
*window
= new QDialog(this);
140 about
.setupUi(window
);
141 window
->setModal(true);
143 QFile
licence(":/docs/gpl-2.0.html");
144 licence
.open(QIODevice::ReadOnly
);
145 QTextStream
c(&licence
);
146 QString cline
= c
.readAll();
147 about
.browserLicense
->insertHtml(cline
);
148 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
149 QFile
credits(":/docs/CREDITS");
150 credits
.open(QIODevice::ReadOnly
);
151 QTextStream
r(&credits
);
152 QString rline
= r
.readAll();
153 about
.browserCredits
->insertPlainText(rline
);
154 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
155 QString title
= QString("<b>The Rockbox Utility</b> Version %1").arg(VERSION
);
156 about
.labelTitle
->setText(title
);
157 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
164 void RbUtilQt::configDialog()
166 Config
*cw
= new Config(this);
167 cw
->setUserSettings(userSettings
);
168 cw
->setDevices(devices
);
170 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
171 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
175 void RbUtilQt::updateSettings()
177 qDebug() << "updateSettings()";
183 void RbUtilQt::updateDevice()
185 platform
= userSettings
->value("defaults/platform").toString();
187 devices
->beginGroup(platform
);
188 if(devices
->value("needsbootloader", "") == "no") {
189 ui
.buttonBootloader
->setEnabled(false);
190 ui
.buttonRemoveBootloader
->setEnabled(false);
191 ui
.labelBootloader
->setEnabled(false);
192 ui
.labelRemoveBootloader
->setEnabled(false);
195 ui
.buttonBootloader
->setEnabled(true);
196 ui
.labelBootloader
->setEnabled(true);
197 if(devices
->value("bootloadermethod") == "fwpatcher") {
198 ui
.labelRemoveBootloader
->setEnabled(false);
199 ui
.buttonRemoveBootloader
->setEnabled(false);
202 ui
.labelRemoveBootloader
->setEnabled(true);
203 ui
.buttonRemoveBootloader
->setEnabled(true);
207 // displayed device info
208 platform
= userSettings
->value("defaults/platform").toString();
209 QString mountpoint
= userSettings
->value("defaults/mountpoint").toString();
210 devices
->beginGroup(platform
);
211 QString brand
= devices
->value("brand").toString();
212 QString name
= devices
->value("name").toString();
214 if(name
.isEmpty()) name
= "<none>";
215 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
216 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
217 .arg(brand
, name
, mountpoint
));
221 void RbUtilQt::updateManual()
223 if(userSettings
->value("defaults/platform").toString() != "")
225 devices
->beginGroup(userSettings
->value("defaults/platform").toString());
227 manual
= devices
->value("manualname", "").toString();
230 manual
= "rockbox-" + devices
->value("platform").toString();
233 pdfmanual
= devices
->value("manual_url").toString() + "/" + manual
+ ".pdf";
235 htmlmanual
= devices
->value("manual_url").toString() + "/" + manual
+ "/rockbox-build.html";
236 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
238 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
242 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
243 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
244 .arg("http://www.rockbox.org/manual.shtml"));
250 void RbUtilQt::install()
252 Install
*installWindow
= new Install(this);
253 installWindow
->setUserSettings(userSettings
);
254 installWindow
->setDeviceSettings(devices
);
255 if(userSettings
->value("defaults/proxytype") == "manual")
256 installWindow
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
258 else if(userSettings
->value("defaults/proxytype") == "system")
259 installWindow
->setProxy(QUrl(getenv("http_proxy")));
263 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
265 installWindow
->setArchivedString(info
.value("dailies/date").toString());
267 devices
->beginGroup(platform
);
268 QString released
= devices
->value("released").toString();
270 if(released
== "yes")
271 installWindow
->setReleased(devices
->value("last_release", "").toString());
273 installWindow
->setReleased(0);
275 installWindow
->show();
279 void RbUtilQt::installBl()
281 InstallBootloaderWindow
*installWindow
= new InstallBootloaderWindow(this);
282 installWindow
->setUserSettings(userSettings
);
283 installWindow
->setDeviceSettings(devices
);
284 if(userSettings
->value("defaults/proxytype") == "manual")
285 installWindow
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
287 else if(userSettings
->value("defaults/proxytype") == "system")
288 installWindow
->setProxy(QUrl(getenv("http_proxy")));
290 installWindow
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
292 installWindow
->show();
296 void RbUtilQt::installFonts()
298 if(QMessageBox::question(this, tr("Confirm Installation"),
299 tr("Do you really want to install the fonts package?"),
300 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
302 logger
= new ProgressLoggerGui(this);
305 // create zip installer
306 installer
= new ZipInstaller(this);
308 installer
->setUrl(devices
->value("font_url").toString());
309 if(userSettings
->value("defaults/proxytype") == "manual")
310 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
312 else if(userSettings
->value("defaults/proxytype") == "system")
313 installer
->setProxy(QUrl(getenv("http_proxy")));
316 installer
->setLogSection("Fonts");
317 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
318 installer
->install(logger
);
320 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
324 void RbUtilQt::installVoice()
326 if(QMessageBox::question(this, tr("Confirm Installation"),
327 tr("Do you really want to install the voice file?"),
328 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
330 logger
= new ProgressLoggerGui(this);
333 // create zip installer
334 installer
= new ZipInstaller(this);
335 installer
->setUnzip(false);
337 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
339 QString datestring
= info
.value("dailies/date").toString();
341 QString voiceurl
= devices
->value("voice_url").toString() + "/" +
342 userSettings
->value("defaults/platform").toString() + "-" +
343 datestring
+ "-english.voice";
344 qDebug() << voiceurl
;
345 if(userSettings
->value("defaults/proxytype") == "manual")
346 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
348 else if(userSettings
->value("defaults/proxytype") == "system")
349 installer
->setProxy(QUrl(getenv("http_proxy")));
352 installer
->setUrl(voiceurl
);
353 installer
->setLogSection("Voice");
354 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
355 installer
->setTarget("/.rockbox/langs/english.voice");
356 installer
->install(logger
);
358 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
362 void RbUtilQt::installDoom()
364 if(QMessageBox::question(this, tr("Confirm Installation"),
365 tr("Do you really want to install the game addon files?"),
366 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
368 logger
= new ProgressLoggerGui(this);
371 // create zip installer
372 installer
= new ZipInstaller(this);
374 installer
->setUrl(devices
->value("doom_url").toString());
375 if(userSettings
->value("defaults/proxytype") == "manual")
376 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
378 else if(userSettings
->value("defaults/proxytype") == "system")
379 installer
->setProxy(QUrl(getenv("http_proxy")));
382 installer
->setLogSection("Game Addons");
383 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
384 installer
->install(logger
);
386 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
391 void RbUtilQt::createTalkFiles(void)
393 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
394 installWindow
->setUserSettings(userSettings
);
395 installWindow
->setDeviceSettings(devices
);
396 installWindow
->show();