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 "installbl.h"
29 #include "installtalkwindow.h"
31 #include "installbootloader.h"
37 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
39 QString programPath
= qApp
->arguments().at(0);
40 absolutePath
= QFileInfo(programPath
).absolutePath() + "/";
41 // use built-in rbutil.ini if no external file in binary folder
42 QString iniFile
= absolutePath
+ "rbutil.ini";
43 if(QFileInfo(iniFile
).isFile()) {
44 qDebug() << "using external rbutil.ini";
45 devices
= new QSettings(iniFile
, QSettings::IniFormat
, 0);
48 qDebug() << "using built-in rbutil.ini";
49 devices
= new QSettings(":/ini/rbutil.ini", QSettings::IniFormat
, 0);
54 // portable installation:
55 // check for a configuration file in the program folder.
57 config
.setFile(absolutePath
+ "RockboxUtility.ini");
59 userSettings
= new QSettings(absolutePath
+ "RockboxUtility.ini",
60 QSettings::IniFormat
, 0);
61 qDebug() << "config: portable";
64 userSettings
= new QSettings(QSettings::IniFormat
,
65 QSettings::UserScope
, "rockbox.org", "RockboxUtility");
66 qDebug() << "config: system";
70 ui
.buttonDownloadManual
->setEnabled(false);
74 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
75 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
76 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
77 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
78 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(install()));
79 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBl()));
80 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFonts()));
81 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoom()));
82 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
83 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
86 // disable unimplemented stuff
87 ui
.buttonThemes
->setEnabled(false);
88 ui
.buttonSmall
->setEnabled(false);
89 ui
.buttonRemoveRockbox
->setEnabled(false);
90 ui
.buttonRemoveBootloader
->setEnabled(false);
91 ui
.buttonComplete
->setEnabled(false);
100 void RbUtilQt::downloadInfo()
102 // try to get the current build information
103 daily
= new HttpGet(this);
104 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
105 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
106 if(userSettings
->value("defaults/proxytype") == "manual")
107 daily
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
109 else if(userSettings
->value("defaults/proxytype") == "system")
110 daily
->setProxy(QUrl(getenv("http_proxy")));
113 qDebug() << "downloading build info";
114 daily
->setFile(&buildInfo
);
115 daily
->getFile(QUrl(devices
->value("server_conf_url").toString()));
119 void RbUtilQt::downloadDone(bool error
)
121 if(error
) qDebug() << "network error:" << daily
->error();
122 qDebug() << "network status:" << daily
->error();
127 void RbUtilQt::downloadDone(int id
, bool error
)
130 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
131 .arg(daily
->errorString());
132 if(error
) QMessageBox::about(this, "Network Error", errorString
);
133 qDebug() << "downloadDone:" << id
<< error
;
137 void RbUtilQt::about()
139 QDialog
*window
= new QDialog(this);
141 about
.setupUi(window
);
142 window
->setModal(true);
144 QFile
licence(":/docs/gpl-2.0.html");
145 licence
.open(QIODevice::ReadOnly
);
146 QTextStream
c(&licence
);
147 QString cline
= c
.readAll();
148 about
.browserLicense
->insertHtml(cline
);
149 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
150 QFile
credits(":/docs/CREDITS");
151 credits
.open(QIODevice::ReadOnly
);
152 QTextStream
r(&credits
);
153 QString rline
= r
.readAll();
154 about
.browserCredits
->insertPlainText(rline
);
155 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
156 QString title
= QString("<b>The Rockbox Utility</b> Version %1").arg(VERSION
);
157 about
.labelTitle
->setText(title
);
158 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
165 void RbUtilQt::configDialog()
167 Config
*cw
= new Config(this);
168 cw
->setUserSettings(userSettings
);
169 cw
->setDevices(devices
);
171 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
172 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
176 void RbUtilQt::updateSettings()
178 qDebug() << "updateSettings()";
184 void RbUtilQt::updateDevice()
186 platform
= userSettings
->value("defaults/platform").toString();
188 devices
->beginGroup(platform
);
189 if(devices
->value("needsbootloader", "") == "no") {
190 ui
.buttonBootloader
->setEnabled(false);
191 ui
.buttonRemoveBootloader
->setEnabled(false);
192 ui
.labelBootloader
->setEnabled(false);
193 ui
.labelRemoveBootloader
->setEnabled(false);
196 ui
.buttonBootloader
->setEnabled(true);
197 ui
.labelBootloader
->setEnabled(true);
198 if(devices
->value("bootloadermethod") == "fwpatcher") {
199 ui
.labelRemoveBootloader
->setEnabled(false);
200 ui
.buttonRemoveBootloader
->setEnabled(false);
203 ui
.labelRemoveBootloader
->setEnabled(true);
204 ui
.buttonRemoveBootloader
->setEnabled(true);
208 // displayed device info
209 platform
= userSettings
->value("defaults/platform").toString();
210 QString mountpoint
= userSettings
->value("defaults/mountpoint").toString();
211 devices
->beginGroup(platform
);
212 QString brand
= devices
->value("brand").toString();
213 QString name
= devices
->value("name").toString();
215 if(name
.isEmpty()) name
= "<none>";
216 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
217 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
218 .arg(brand
, name
, mountpoint
));
222 void RbUtilQt::updateManual()
224 if(userSettings
->value("defaults/platform").toString() != "")
226 devices
->beginGroup(userSettings
->value("defaults/platform").toString());
228 manual
= devices
->value("manualname", "").toString();
231 manual
= "rockbox-" + devices
->value("platform").toString();
234 pdfmanual
= devices
->value("manual_url").toString() + "/" + manual
+ ".pdf";
236 htmlmanual
= devices
->value("manual_url").toString() + "/" + manual
+ "/rockbox-build.html";
237 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
239 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
243 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
244 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
245 .arg("http://www.rockbox.org/manual.shtml"));
251 void RbUtilQt::install()
253 Install
*installWindow
= new Install(this);
254 installWindow
->setUserSettings(userSettings
);
255 installWindow
->setDeviceSettings(devices
);
256 if(userSettings
->value("defaults/proxytype") == "manual")
257 installWindow
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
259 else if(userSettings
->value("defaults/proxytype") == "system")
260 installWindow
->setProxy(QUrl(getenv("http_proxy")));
264 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
266 installWindow
->setArchivedString(info
.value("dailies/date").toString());
268 devices
->beginGroup(platform
);
269 QString released
= devices
->value("released").toString();
271 if(released
== "yes")
272 installWindow
->setReleased(devices
->value("last_release", "").toString());
274 installWindow
->setReleased(0);
276 installWindow
->show();
280 void RbUtilQt::installBl()
282 InstallBl
*installWindow
= new InstallBl(this);
283 installWindow
->setUserSettings(userSettings
);
284 installWindow
->setDeviceSettings(devices
);
285 if(userSettings
->value("defaults/proxytype") == "manual")
286 installWindow
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
288 else if(userSettings
->value("defaults/proxytype") == "system")
289 installWindow
->setProxy(QUrl(getenv("http_proxy")));
291 installWindow
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
293 installWindow
->show();
297 void RbUtilQt::installFonts()
299 if(QMessageBox::question(this, tr("Confirm Installation"),
300 tr("Do you really want to install the fonts package?"),
301 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
303 logger
= new ProgressLoggerGui(this);
306 // create zip installer
307 installer
= new ZipInstaller(this);
309 installer
->setUrl(devices
->value("font_url").toString());
310 if(userSettings
->value("defaults/proxytype") == "manual")
311 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
313 else if(userSettings
->value("defaults/proxytype") == "system")
314 installer
->setProxy(QUrl(getenv("http_proxy")));
317 installer
->setLogSection("Fonts");
318 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
319 installer
->install(logger
);
321 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
325 void RbUtilQt::installVoice()
327 if(QMessageBox::question(this, tr("Confirm Installation"),
328 tr("Do you really want to install the voice file?"),
329 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
331 logger
= new ProgressLoggerGui(this);
334 // create zip installer
335 installer
= new ZipInstaller(this);
336 installer
->setUnzip(false);
338 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
340 QString datestring
= info
.value("dailies/date").toString();
342 QString voiceurl
= devices
->value("voice_url").toString() + "/" +
343 userSettings
->value("defaults/platform").toString() + "-" +
344 datestring
+ "-english.voice";
345 qDebug() << voiceurl
;
346 if(userSettings
->value("defaults/proxytype") == "manual")
347 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
349 else if(userSettings
->value("defaults/proxytype") == "system")
350 installer
->setProxy(QUrl(getenv("http_proxy")));
353 installer
->setUrl(voiceurl
);
354 installer
->setLogSection("Voice");
355 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
356 installer
->setTarget("/.rockbox/langs/english.voice");
357 installer
->install(logger
);
359 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
363 void RbUtilQt::installDoom()
365 if(QMessageBox::question(this, tr("Confirm Installation"),
366 tr("Do you really want to install the game addon files?"),
367 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
369 logger
= new ProgressLoggerGui(this);
372 // create zip installer
373 installer
= new ZipInstaller(this);
375 installer
->setUrl(devices
->value("doom_url").toString());
376 if(userSettings
->value("defaults/proxytype") == "manual")
377 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
379 else if(userSettings
->value("defaults/proxytype") == "system")
380 installer
->setProxy(QUrl(getenv("http_proxy")));
383 installer
->setLogSection("Game Addons");
384 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
385 installer
->install(logger
);
387 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
392 void RbUtilQt::createTalkFiles(void)
394 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
395 installWindow
->setUserSettings(userSettings
);
396 installWindow
->setDeviceSettings(devices
);
397 installWindow
->show();