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 "installtalkwindow.h"
30 #include "installbootloader.h"
31 #include "installthemes.h"
32 #include "uninstallwindow.h"
39 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
41 absolutePath
= qApp
->applicationDirPath();
42 // use built-in rbutil.ini if no external file in binary folder
43 QString iniFile
= absolutePath
+ "/rbutil.ini";
44 if(QFileInfo(iniFile
).isFile()) {
45 qDebug() << "using external rbutil.ini";
46 devices
= new QSettings(iniFile
, QSettings::IniFormat
, 0);
49 qDebug() << "using built-in rbutil.ini";
50 devices
= new QSettings(":/ini/rbutil.ini", QSettings::IniFormat
, 0);
55 // portable installation:
56 // check for a configuration file in the program folder.
58 config
.setFile(absolutePath
+ "/RockboxUtility.ini");
60 userSettings
= new QSettings(absolutePath
+ "/RockboxUtility.ini",
61 QSettings::IniFormat
, 0);
62 qDebug() << "config: portable";
65 userSettings
= new QSettings(QSettings::IniFormat
,
66 QSettings::UserScope
, "rockbox.org", "RockboxUtility");
67 qDebug() << "config: system";
73 ui
.radioPdf
->setChecked(true);
75 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
76 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
77 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
78 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
79 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(install()));
80 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBl()));
81 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFonts()));
82 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoom()));
83 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
84 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
85 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
86 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
87 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
88 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
89 // disable unimplemented stuff
90 ui
.buttonSmall
->setEnabled(false);
91 ui
.buttonComplete
->setEnabled(false);
93 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
95 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
107 void RbUtilQt::downloadInfo()
109 // try to get the current build information
110 daily
= new HttpGet(this);
111 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
112 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
113 if(userSettings
->value("defaults/proxytype") == "manual")
114 daily
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
116 else if(userSettings
->value("defaults/proxytype") == "system")
117 daily
->setProxy(QUrl(getenv("http_proxy")));
120 qDebug() << "downloading build info";
121 daily
->setFile(&buildInfo
);
122 daily
->getFile(QUrl(devices
->value("server_conf_url").toString()));
126 void RbUtilQt::downloadDone(bool error
)
128 if(error
) qDebug() << "network error:" << daily
->error();
129 qDebug() << "network status:" << daily
->error();
134 void RbUtilQt::downloadDone(int id
, bool error
)
137 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
138 .arg(daily
->errorString());
139 if(error
) QMessageBox::about(this, "Network Error", errorString
);
140 qDebug() << "downloadDone:" << id
<< error
;
144 void RbUtilQt::about()
146 QDialog
*window
= new QDialog(this);
148 about
.setupUi(window
);
149 window
->setModal(true);
151 QFile
licence(":/docs/gpl-2.0.html");
152 licence
.open(QIODevice::ReadOnly
);
153 QTextStream
c(&licence
);
154 QString cline
= c
.readAll();
155 about
.browserLicense
->insertHtml(cline
);
156 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
157 QFile
credits(":/docs/CREDITS");
158 credits
.open(QIODevice::ReadOnly
);
159 QTextStream
r(&credits
);
160 QString rline
= r
.readAll();
161 about
.browserCredits
->insertPlainText(rline
);
162 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
163 QString title
= QString("<b>The Rockbox Utility</b> Version %1").arg(VERSION
);
164 about
.labelTitle
->setText(title
);
165 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
172 void RbUtilQt::configDialog()
174 Config
*cw
= new Config(this);
175 cw
->setUserSettings(userSettings
);
176 cw
->setDevices(devices
);
178 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
179 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
183 void RbUtilQt::updateSettings()
185 qDebug() << "updateSettings()";
191 void RbUtilQt::updateDevice()
193 platform
= userSettings
->value("defaults/platform").toString();
195 devices
->beginGroup(platform
);
196 if(devices
->value("needsbootloader", "") == "no") {
197 ui
.buttonBootloader
->setEnabled(false);
198 ui
.buttonRemoveBootloader
->setEnabled(false);
199 ui
.labelBootloader
->setEnabled(false);
200 ui
.labelRemoveBootloader
->setEnabled(false);
203 ui
.buttonBootloader
->setEnabled(true);
204 ui
.labelBootloader
->setEnabled(true);
205 if(devices
->value("bootloadermethod") == "fwpatcher") {
206 ui
.labelRemoveBootloader
->setEnabled(false);
207 ui
.buttonRemoveBootloader
->setEnabled(false);
210 ui
.labelRemoveBootloader
->setEnabled(true);
211 ui
.buttonRemoveBootloader
->setEnabled(true);
215 // displayed device info
216 platform
= userSettings
->value("defaults/platform").toString();
217 QString mountpoint
= userSettings
->value("defaults/mountpoint").toString();
218 devices
->beginGroup(platform
);
219 QString brand
= devices
->value("brand").toString();
220 QString name
= devices
->value("name").toString();
222 if(name
.isEmpty()) name
= "<none>";
223 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
224 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
225 .arg(brand
, name
, mountpoint
));
229 void RbUtilQt::updateManual()
231 if(userSettings
->value("defaults/platform").toString() != "")
233 devices
->beginGroup(userSettings
->value("defaults/platform").toString());
235 manual
= devices
->value("manualname", "").toString();
238 manual
= "rockbox-" + devices
->value("platform").toString();
241 pdfmanual
= devices
->value("manual_url").toString() + "/" + manual
+ ".pdf";
243 htmlmanual
= devices
->value("manual_url").toString() + "/" + manual
+ "/rockbox-build.html";
244 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
246 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
250 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
251 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
252 .arg("http://www.rockbox.org/manual.shtml"));
258 void RbUtilQt::install()
260 Install
*installWindow
= new Install(this);
261 installWindow
->setUserSettings(userSettings
);
262 installWindow
->setDeviceSettings(devices
);
263 if(userSettings
->value("defaults/proxytype") == "manual")
264 installWindow
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
266 else if(userSettings
->value("defaults/proxytype") == "system")
267 installWindow
->setProxy(QUrl(getenv("http_proxy")));
271 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
273 installWindow
->setArchivedString(info
.value("dailies/date").toString());
275 devices
->beginGroup(platform
);
276 QString released
= devices
->value("released").toString();
278 if(released
== "yes")
279 installWindow
->setReleased(devices
->value("last_release", "").toString());
281 installWindow
->setReleased(0);
283 installWindow
->show();
287 void RbUtilQt::installBl()
289 if(QMessageBox::question(this, tr("Confirm Installation"),
290 tr("Do you really want to install the Bootloader?"),
291 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
294 logger
= new ProgressLoggerGui(this);
297 QString platform
= userSettings
->value("defaults/platform").toString();
299 // if fwpatcher , ask for extra file
301 if(devices
->value(platform
+ "/bootloadermethod").toString() == "fwpatcher")
303 BrowseOF
ofbrowser(this);
304 ofbrowser
.setFile(userSettings
->value("defaults/ofpath").toString());
305 if(ofbrowser
.exec() == QDialog::Accepted
)
307 offirmware
= ofbrowser
.getFile();
308 qDebug() << offirmware
;
309 if(!QFileInfo(offirmware
).exists())
311 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
317 userSettings
->setValue("defaults/ofpath",offirmware
);
318 userSettings
->sync();
323 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
330 blinstaller
= new BootloaderInstaller(this);
332 blinstaller
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
334 if(userSettings
->value("defaults/proxytype") == "manual")
335 blinstaller
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
337 else if(userSettings
->value("defaults/proxytype") == "system")
338 blinstaller
->setProxy(QUrl(getenv("http_proxy")));
341 blinstaller
->setDevice(platform
);
342 blinstaller
->setBootloaderMethod(devices
->value(platform
+ "/bootloadermethod").toString());
343 blinstaller
->setBootloaderName(devices
->value(platform
+ "/bootloadername").toString());
344 blinstaller
->setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
345 blinstaller
->setOrigFirmwarePath(offirmware
);
347 blinstaller
->install(logger
);
349 // connect(blinstaller, SIGNAL(done(bool)), this, SLOT(done(bool)));
353 void RbUtilQt::installFonts()
355 if(QMessageBox::question(this, tr("Confirm Installation"),
356 tr("Do you really want to install the fonts package?"),
357 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
359 logger
= new ProgressLoggerGui(this);
362 // create zip installer
363 installer
= new ZipInstaller(this);
365 installer
->setUrl(devices
->value("font_url").toString());
366 if(userSettings
->value("defaults/proxytype") == "manual")
367 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
369 else if(userSettings
->value("defaults/proxytype") == "system")
370 installer
->setProxy(QUrl(getenv("http_proxy")));
373 installer
->setLogSection("Fonts");
374 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
375 installer
->install(logger
);
377 // connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
381 void RbUtilQt::installVoice()
383 if(QMessageBox::question(this, tr("Confirm Installation"),
384 tr("Do you really want to install the voice file?"),
385 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
387 logger
= new ProgressLoggerGui(this);
390 // create zip installer
391 installer
= new ZipInstaller(this);
392 installer
->setUnzip(false);
394 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
396 QString datestring
= info
.value("dailies/date").toString();
398 QString voiceurl
= devices
->value("voice_url").toString() + "/" +
399 userSettings
->value("defaults/platform").toString() + "-" +
400 datestring
+ "-english.voice";
401 qDebug() << voiceurl
;
402 if(userSettings
->value("defaults/proxytype") == "manual")
403 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
405 else if(userSettings
->value("defaults/proxytype") == "system")
406 installer
->setProxy(QUrl(getenv("http_proxy")));
409 installer
->setUrl(voiceurl
);
410 installer
->setLogSection("Voice");
411 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
412 installer
->setTarget("/.rockbox/langs/english.voice");
413 installer
->install(logger
);
415 //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
419 void RbUtilQt::installDoom()
421 if(QMessageBox::question(this, tr("Confirm Installation"),
422 tr("Do you really want to install the game addon files?"),
423 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
425 logger
= new ProgressLoggerGui(this);
428 // create zip installer
429 installer
= new ZipInstaller(this);
431 installer
->setUrl(devices
->value("doom_url").toString());
432 if(userSettings
->value("defaults/proxytype") == "manual")
433 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
435 else if(userSettings
->value("defaults/proxytype") == "system")
436 installer
->setProxy(QUrl(getenv("http_proxy")));
439 installer
->setLogSection("GameAddons");
440 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
441 installer
->install(logger
);
443 // connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
448 void RbUtilQt::installThemes()
450 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
451 tw
->setDeviceSettings(devices
);
452 tw
->setUserSettings(userSettings
);
453 if(userSettings
->value("defaults/proxytype") == "manual")
454 tw
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
456 else if(userSettings
->value("defaults/proxytype") == "system")
457 tw
->setProxy(QUrl(getenv("http_proxy")));
464 void RbUtilQt::createTalkFiles(void)
466 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
467 installWindow
->setUserSettings(userSettings
);
468 installWindow
->setDeviceSettings(devices
);
469 installWindow
->show();
473 void RbUtilQt::uninstall(void)
475 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
476 uninstallWindow
->setUserSettings(userSettings
);
477 uninstallWindow
->setDeviceSettings(devices
);
478 uninstallWindow
->show();
481 void RbUtilQt::uninstallBootloader(void)
483 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
484 tr("Do you really want to uninstall the Bootloader?"),
485 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
487 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
490 QString plattform
= userSettings
->value("defaults/platform").toString();
491 BootloaderInstaller
blinstaller(this);
492 blinstaller
.setMountPoint(userSettings
->value("defaults/mountpoint").toString());
493 blinstaller
.setDevice(userSettings
->value("defaults/platform").toString());
494 blinstaller
.setBootloaderMethod(devices
->value(plattform
+ "/bootloadermethod").toString());
495 blinstaller
.setBootloaderName(devices
->value(plattform
+ "/bootloadername").toString());
496 blinstaller
.setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
497 blinstaller
.uninstall(logger
);
502 void RbUtilQt::downloadManual(void)
504 if(QMessageBox::question(this, tr("Confirm download"),
505 tr("Do you really want to download the manual? The manual will be saved "
506 "to the root folder of your player."),
507 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
511 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
514 devices
->beginGroup(userSettings
->value("defaults/platform").toString());
516 manual
= devices
->value("manualname", "rockbox-" + devices
->value("platform").toString()).toString();
519 QString date
= (info
.value("dailies/date").toString());
524 if(ui
.radioPdf
->isChecked()) {
525 target
= "/" + manual
+ ".pdf";
526 section
= "Manual (PDF)";
529 target
= "/" + manual
+ "-" + date
+ "-html.zip";
530 section
= "Manual (HTML)";
532 manualurl
= devices
->value("manual_url").toString() + "/" + target
;
533 qDebug() << "manualurl =" << manualurl
;
535 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
537 installer
= new ZipInstaller(this);
538 installer
->setMountPoint(userSettings
->value("defaults/mountpoint").toString());
539 if(userSettings
->value("defaults/proxytype") == "manual")
540 installer
->setProxy(QUrl(userSettings
->value("defaults/proxy").toString()));
542 else if(userSettings
->value("defaults/proxytype") == "system")
543 installer
->setProxy(QUrl(getenv("http_proxy")));
545 installer
->setLogSection(section
);
546 installer
->setUrl(manualurl
);
547 installer
->setUnzip(false);
548 installer
->setTarget(target
);
549 installer
->install(logger
);
553 void RbUtilQt::installPortable(void)
555 if(QMessageBox::question(this, tr("Confirm installation"),
556 tr("Do you really want to install Rockbox Utility to your player? "
557 "After installation you can run it from the players hard drive."),
558 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
561 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
563 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
566 if(!QFileInfo(userSettings
->value("defaults/mountpoint").toString()).isDir()) {
567 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
572 // remove old files first.
573 QFile::remove(userSettings
->value("defaults/mountpoint").toString() + "/RockboxUtility.exe");
574 QFile::remove(userSettings
->value("defaults/mountpoint").toString() + "/RockboxUtility.ini");
575 // copy currently running binary and currently used settings file
576 if(!QFile::copy(qApp
->applicationFilePath(), userSettings
->value("defaults/mountpoint").toString() + "/RockboxUtility.exe")) {
577 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
581 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
582 if(!QFile::copy(userSettings
->fileName(), userSettings
->value("defaults/mountpoint").toString() + "/RockboxUtility.ini")) {
583 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
587 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);