1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
23 #include "ui_rbutilqtfrm.h"
24 #include "ui_aboutbox.h"
25 #include "configure.h"
26 #include "installwindow.h"
27 #include "installtalkwindow.h"
28 #include "createvoicewindow.h"
30 #include "themesinstallwindow.h"
31 #include "uninstallwindow.h"
33 #include "rockboxinfo.h"
37 #include "rbsettings.h"
38 #include "serverinfo.h"
39 #include "systeminfo.h"
41 #include "manualwidget.h"
42 #include "infowidget.h"
44 #include "progressloggerinterface.h"
46 #include "bootloaderinstallbase.h"
47 #include "bootloaderinstallhelper.h"
49 #if defined(Q_OS_LINUX)
52 #if defined(Q_OS_WIN32)
61 QList
<QTranslator
*> RbUtilQt::translators
;
63 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
66 qDebug() << "======================================";
67 qDebug() << "[System] Rockbox Utility " VERSION
;
68 qDebug() << "[System] Qt version:" << qVersion();
69 qDebug() << "======================================";
71 absolutePath
= qApp
->applicationDirPath();
73 HttpGet::setGlobalUserAgent("rbutil/"VERSION
);
74 HttpGet::setGlobalProxy(proxy());
75 // init startup & autodetection
77 #if defined(Q_OS_LINUX)
78 QIcon
windowIcon(":/icons/rockbox-clef.svg");
79 this->setWindowIcon(windowIcon
);
81 #if defined(Q_OS_WIN32)
82 QIcon windowIcon
= QIcon();
83 windowIcon
.addFile(":/icons/rockbox-16.png");
84 windowIcon
.addFile(":/icons/rockbox-32.png");
85 windowIcon
.addFile(":/icons/rockbox-48.png");
86 windowIcon
.addFile(":/icons/rockbox-64.png");
87 windowIcon
.addFile(":/icons/rockbox-128.png");
88 windowIcon
.addFile(":/icons/rockbox-256.png");
89 this->setWindowIcon(windowIcon
);
91 #if defined(Q_OS_MACX)
92 // don't translate menu entries that are handled specially on OS X
93 // (Configure, Quit). Qt handles them for us if they use english string.
94 ui
.action_Configure
->setText("Configure");
95 ui
.actionE_xit
->setText("Quit");
97 #if defined(Q_OS_WIN32)
100 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Wine"),
101 0, KEY_QUERY_VALUE
, &hk
);
102 if(ret
== ERROR_SUCCESS
) {
103 QMessageBox::warning(this, tr("Wine detected!"),
104 tr("It seems you are trying to run this program under Wine. "
105 "Please don't do this, running under Wine will fail. "
106 "Use the native Linux binary instead."),
107 QMessageBox::Ok
, QMessageBox::Ok
);
108 qDebug() << "[RbUtil] WINE DETECTED!";
118 // insert ManualWidget() widget in manual tab
119 QGridLayout
*mantablayout
= new QGridLayout(this);
120 ui
.manual
->setLayout(mantablayout
);
121 manual
= new ManualWidget(this);
122 mantablayout
->addWidget(manual
);
125 QGridLayout
*infotablayout
= new QGridLayout(this);
126 ui
.info
->setLayout(infotablayout
);
127 info
= new InfoWidget(this);
128 infotablayout
->addWidget(info
);
130 // disable quick install until version info is available
131 ui
.buttonSmall
->setEnabled(false);
132 ui
.buttonComplete
->setEnabled(false);
133 ui
.actionSmall_Installation
->setEnabled(false);
134 ui
.actionComplete_Installation
->setEnabled(false);
136 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
137 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
138 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
139 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
140 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
141 connect(ui
.actionE_xit
, SIGNAL(triggered()), this, SLOT(shutdown()));
142 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
143 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
144 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
145 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
146 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
147 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
148 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
149 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
150 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
151 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
152 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
153 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
154 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
156 // actions accessible from the menu
157 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
158 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
159 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
160 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
161 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
162 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
163 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
164 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
165 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
166 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
167 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
168 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
169 connect(ui
.action_System_Info
, SIGNAL(triggered()), this, SLOT(sysinfo()));
170 connect(ui
.action_Trace
, SIGNAL(triggered()), this, SLOT(trace()));
173 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
175 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
177 Utils::findRunningProcess(QStringList("iTunes"));
182 void RbUtilQt::shutdown(void)
184 // restore default message handler to prevent trace accesses during
185 // object destruction -- the trace object could already be destroyed.
186 // Fixes segfaults on exit.
187 qInstallMsgHandler(0);
193 void RbUtilQt::trace(void)
199 void RbUtilQt::sysinfo(void)
205 void RbUtilQt::updateTabs(int count
)
217 void RbUtilQt::downloadInfo()
219 // try to get the current build information
220 daily
= new HttpGet(this);
221 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
222 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
223 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
224 daily
->setCache(true);
226 daily
->setCache(false);
227 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
228 qDebug() << "[RbUtil] downloading build info";
229 daily
->setFile(&buildInfo
);
230 daily
->getFile(QUrl(SystemInfo::value(SystemInfo::BuildInfoUrl
).toString()));
234 void RbUtilQt::downloadDone(bool error
)
237 qDebug() << "[RbUtil] network error:" << daily
->error();
238 ui
.statusbar
->showMessage(tr("Can't get version information!"));
239 QMessageBox::critical(this, tr("Network error"),
240 tr("Can't get version information.\n"
241 "Network error: %1. Please check your network and proxy settings.")
242 .arg(daily
->errorString()));
245 qDebug() << "[RbUtil] network status:" << daily
->error();
247 // read info into ServerInfo object
249 ServerInfo::readBuildInfo(buildInfo
.fileName());
252 ui
.statusbar
->showMessage(tr("Download build information finished."), 5000);
256 //start check for updates
262 void RbUtilQt::about()
264 QDialog
*window
= new QDialog(this);
266 about
.setupUi(window
);
267 window
->setLayoutDirection(Qt::LeftToRight
);
268 window
->setModal(true);
270 QFile
licence(":/docs/gpl-2.0.html");
271 licence
.open(QIODevice::ReadOnly
);
272 QTextStream
c(&licence
);
273 about
.browserLicense
->insertHtml(c
.readAll());
274 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
276 QFile
speexlicense(":/docs/COPYING.SPEEX");
277 speexlicense
.open(QIODevice::ReadOnly
);
278 QTextStream
s(&speexlicense
);
279 about
.browserSpeexLicense
->insertHtml("<pre>" + s
.readAll() + "</pre>");
280 about
.browserSpeexLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
282 QFile
credits(":/docs/CREDITS");
283 credits
.open(QIODevice::ReadOnly
);
284 QTextStream
r(&credits
);
285 r
.setCodec(QTextCodec::codecForName("UTF-8"));
287 QString line
= r
.readLine();
288 // filter out header.
289 line
.remove(QRegExp("^ +.*"));
290 line
.remove(QRegExp("^People.*"));
291 about
.browserCredits
->append(line
);
293 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
294 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION
);
295 about
.labelTitle
->setText(title
);
302 void RbUtilQt::help()
304 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
305 QDesktopServices::openUrl(helpurl
);
309 void RbUtilQt::configDialog()
311 Config
*cw
= new Config(this);
312 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
317 void RbUtilQt::updateSettings()
319 qDebug() << "[RbUtil] updating current settings";
321 manual
->updateManual();
322 HttpGet::setGlobalProxy(proxy());
323 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath
).toString());
324 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline
).toBool());
326 if(RbSettings::value(RbSettings::RbutilVersion
) != PUREVERSION
) {
327 QApplication::processEvents();
328 QMessageBox::information(this, tr("New installation"),
329 tr("This is a new installation of Rockbox Utility, or a new version. "
330 "The configuration dialog will now open to allow you to setup the program, "
331 " or review your settings."));
334 else if(chkConfig(0)) {
335 QApplication::processEvents();
336 QMessageBox::critical(this, tr("Configuration error"),
337 tr("Your configuration is invalid. This is most likely due "
338 "to a changed device path. The configuration dialog will "
339 "now open to allow you to correct the problem."));
345 void RbUtilQt::updateDevice()
347 /* TODO: We should check the flags of the bootloaderinstall classes, and not
348 * just check if its != none or != "fwpatcher" */
350 /* Enable bootloader installation, if possible */
351 bool bootloaderInstallable
=
352 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none";
353 ui
.buttonBootloader
->setEnabled(bootloaderInstallable
);
354 ui
.labelBootloader
->setEnabled(bootloaderInstallable
);
355 ui
.actionInstall_Bootloader
->setEnabled(bootloaderInstallable
);
357 /* Enable bootloader uninstallation, if possible */
358 bool bootloaderUninstallable
= bootloaderInstallable
&&
359 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "fwpatcher";
360 ui
.labelRemoveBootloader
->setEnabled(bootloaderUninstallable
);
361 ui
.buttonRemoveBootloader
->setEnabled(bootloaderUninstallable
);
362 ui
.actionRemove_bootloader
->setEnabled(bootloaderUninstallable
);
364 /* Disable the whole tab widget if configuration is invalid */
365 bool configurationValid
= !chkConfig(0);
366 ui
.tabWidget
->setEnabled(configurationValid
);
367 ui
.menuA_ctions
->setEnabled(configurationValid
);
369 // displayed device info
370 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
371 QString brand
= SystemInfo::value(SystemInfo::CurBrand
).toString();
372 QString name
= SystemInfo::value(SystemInfo::CurName
).toString() +
373 " (" + ServerInfo::value(ServerInfo::CurStatus
).toString() + ")";
374 QString mountdisplay
= QDir::toNativeSeparators(mountpoint
);
375 QString label
= Utils::filesystemName(mountpoint
);
377 mountdisplay
+= " (" + label
+ ")";
379 if(name
.isEmpty()) name
= "<none>";
380 if(mountpoint
.isEmpty())
381 mountpoint
= "<invalid>";
382 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
383 .arg(brand
, name
, mountdisplay
));
385 // hide quickstart buttons if no release available
386 bool installable
= !ServerInfo::value(ServerInfo::CurReleaseVersion
).toString().isEmpty();
387 ui
.buttonSmall
->setEnabled(installable
);
388 ui
.buttonComplete
->setEnabled(installable
);
389 ui
.actionSmall_Installation
->setEnabled(installable
);
390 ui
.actionComplete_Installation
->setEnabled(installable
);
394 void RbUtilQt::completeInstall()
396 if(chkConfig(this)) return;
397 if(QMessageBox::question(this, tr("Confirm Installation"),
398 tr("Do you really want to perform a complete installation?\n\n"
399 "This will install Rockbox %1. To install the most recent "
400 "development build available press \"Cancel\" and "
401 "use the \"Installation\" tab.")
402 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
403 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
406 logger
= new ProgressLoggerGui(this);
409 if(smallInstallInner())
411 logger
->setRunning();
415 if(!installFontsAuto())
419 // wait for installation finished
421 QApplication::processEvents();
424 logger
->setRunning();
431 if(!installDoomAuto())
435 // wait for installation finished
437 QApplication::processEvents();
444 // it has its own logger window,so close our.
450 void RbUtilQt::smallInstall()
452 if(chkConfig(this)) return;
453 if(QMessageBox::question(this, tr("Confirm Installation"),
454 tr("Do you really want to perform a minimal installation? "
455 "A minimal installation will contain only the absolutely "
456 "necessary parts to run Rockbox.\n\n"
457 "This will install Rockbox %1. To install the most recent "
458 "development build available press \"Cancel\" and "
459 "use the \"Installation\" tab.")
460 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
461 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
465 logger
= new ProgressLoggerGui(this);
471 bool RbUtilQt::smallInstallInner()
473 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
474 // show dialog with error if mount point is wrong
475 if(!QFileInfo(mountpoint
).isDir()) {
476 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
477 logger
->setFinished();
481 if(SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none")
486 if(!installBootloaderAuto()) {
487 logger
->setFinished();
492 // wait for boot loader installation finished
494 QApplication::processEvents();
497 if(m_error
) return true;
498 logger
->setRunning();
508 // wait for installation finished
510 QApplication::processEvents();
513 installBootloaderPost(false);
517 void RbUtilQt::installdone(bool error
)
519 qDebug() << "[RbUtil] install done";
524 void RbUtilQt::installBtn()
526 if(chkConfig(this)) return;
530 bool RbUtilQt::installAuto()
532 QString file
= SystemInfo::value(SystemInfo::ReleaseUrl
).toString();
533 file
.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel
).toString());
534 file
.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
536 // check installed Version and Target
537 QString warning
= Utils::checkEnvironment(false);
538 if(!warning
.isEmpty())
540 if(QMessageBox::warning(this, tr("Really continue?"), warning
,
541 QMessageBox::Ok
| QMessageBox::Abort
, QMessageBox::Abort
)
542 == QMessageBox::Abort
)
544 logger
->addItem(tr("Aborted!"), LOGERROR
);
545 logger
->setFinished();
551 RockboxInfo
rbinfo(RbSettings::value(RbSettings::Mountpoint
).toString());
552 if(rbinfo
.version() != "")
554 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
555 tr("Rockbox installation detected. Do you want to backup first?"),
556 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
559 logger
->addItem(tr("Starting backup..."),LOGINFO
);
560 QString backupName
= RbSettings::value(RbSettings::Mountpoint
).toString()
561 + "/.backup/rockbox-backup-" + rbinfo
.version() + ".zip";
563 //! create dir, if it doesnt exist
564 QFileInfo
backupFile(backupName
);
565 if(!QDir(backupFile
.path()).exists())
568 a
.mkpath(backupFile
.path());
571 logger
->addItem(tr("Beginning Backup..."),LOGINFO
);
572 QCoreApplication::processEvents();
576 connect(&zip
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
577 connect(&zip
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
578 zip
.open(backupName
, QuaZip::mdCreate
);
579 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
580 QString folder
= mp
+ "/.rockbox";
581 result
= zip
.appendDirToArchive(folder
, mp
);
585 logger
->addItem(tr("Backup successful"),LOGOK
);
589 logger
->addItem(tr("Backup failed!"),LOGERROR
);
590 logger
->setFinished();
596 //! install current build
597 ZipInstaller
* installer
= new ZipInstaller(this);
598 installer
->setUrl(file
);
599 installer
->setLogSection("Rockbox (Base)");
600 installer
->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
601 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
602 installer
->setCache(true);
603 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
605 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
606 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
607 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
608 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
609 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
610 installer
->install();
615 void RbUtilQt::install()
617 InstallWindow
*installWindow
= new InstallWindow(this);
618 installWindow
->show();
621 bool RbUtilQt::installBootloaderAuto()
627 void RbUtilQt::installBootloaderBtn()
629 if(chkConfig(this)) return;
630 if(QMessageBox::question(this, tr("Confirm Installation"),
631 tr("Do you really want to install the Bootloader?"),
632 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
635 logger
= new ProgressLoggerGui(this);
640 void RbUtilQt::installBootloader()
642 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
643 QString backupDestination
= "";
647 BootloaderInstallBase
*bl
=
648 BootloaderInstallHelper::createBootloaderInstaller(this,
649 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
651 logger
->addItem(tr("No install method known."), LOGERROR
);
652 logger
->setFinished();
656 // the bootloader install class does NOT use any GUI stuff.
657 // All messages are passed via signals.
658 connect(bl
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
659 connect(bl
, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
660 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
661 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
663 // set bootloader filename. Do this now as installed() needs it.
664 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
665 QStringList blfilepath
;
666 for(int a
= 0; a
< blfile
.size(); a
++) {
667 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
670 bl
->setBlFile(blfilepath
);
671 QUrl
url(SystemInfo::value(SystemInfo::BootloaderUrl
).toString()
672 + SystemInfo::value(SystemInfo::CurBootloaderName
).toString());
674 bl
->setLogfile(RbSettings::value(RbSettings::Mountpoint
).toString()
675 + "/.rockbox/rbutil.log");
677 if(bl
->installed() == BootloaderInstallBase::BootloaderRockbox
) {
678 if(QMessageBox::question(this, tr("Bootloader detected"),
679 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
680 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
) {
682 // keep logger open for auto installs.
683 // don't consider abort as error in auto-mode.
684 logger
->addItem(tr("Bootloader installation skipped"), LOGINFO
);
685 installBootloaderPost(false);
689 installBootloaderPost(true);
695 else if(bl
->installed() == BootloaderInstallBase::BootloaderOther
696 && bl
->capabilities() & BootloaderInstallBase::Backup
)
698 QString targetFolder
= SystemInfo::value(SystemInfo::CurPlatformName
).toString()
699 + " Firmware Backup";
700 // remove invalid character(s)
701 targetFolder
.remove(QRegExp("[:/]"));
702 if(QMessageBox::question(this, tr("Create Bootloader backup"),
703 tr("You can create a backup of the original bootloader "
704 "file. Press \"Yes\" to select an output folder on your "
705 "computer to save the file to. The file will get placed "
706 "in a new folder \"%1\" created below the selected folder.\n"
707 "Press \"No\" to skip this step.").arg(targetFolder
),
708 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
) {
709 backupDestination
= QFileDialog::getExistingDirectory(this,
710 tr("Browse backup folder"), QDir::homePath());
711 if(!backupDestination
.isEmpty())
712 backupDestination
+= "/" + targetFolder
;
714 qDebug() << "[RbUtil] backing up to" << backupDestination
;
715 // backup needs to be done after the logger has been set up.
719 if(bl
->capabilities() & BootloaderInstallBase::NeedsOf
)
722 ret
= QMessageBox::information(this, tr("Prerequisites"),
723 bl
->ofHint(),QMessageBox::Ok
| QMessageBox::Abort
);
724 if(ret
!= QMessageBox::Ok
) {
725 // consider aborting an error to close window / abort automatic
728 logger
->addItem(tr("Bootloader installation aborted"), LOGINFO
);
729 logger
->setFinished();
732 // open dialog to browse to of file
735 = SystemInfo::value(SystemInfo::CurBootloaderFilter
).toString();
736 if(!filter
.isEmpty()) {
737 filter
= tr("Bootloader files (%1)").arg(filter
) + ";;";
739 filter
+= tr("All files (*)");
740 offile
= QFileDialog::getOpenFileName(this,
741 tr("Select firmware file"), QDir::homePath(), filter
);
742 if(!QFileInfo(offile
).isReadable()) {
743 logger
->addItem(tr("Error opening firmware file"), LOGERROR
);
744 logger
->setFinished();
748 if(!bl
->setOfFile(offile
, blfile
)) {
749 logger
->addItem(tr("Error reading firmware file"), LOGERROR
);
750 logger
->setFinished();
757 if(!backupDestination
.isEmpty()) {
758 if(!bl
->backup(backupDestination
)) {
759 if(QMessageBox::warning(this, tr("Backup error"),
760 tr("Could not create backup file. Continue?"),
761 QMessageBox::No
| QMessageBox::Yes
)
762 == QMessageBox::No
) {
763 logger
->setFinished();
771 void RbUtilQt::installBootloaderPost(bool error
)
773 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error
;
774 // if an error occured don't perform post install steps.
783 // end here if automated install
787 QString msg
= BootloaderInstallHelper::postinstallHints(
788 RbSettings::value(RbSettings::Platform
).toString());
790 QMessageBox::information(this, tr("Manual steps required"), msg
);
796 void RbUtilQt::installFontsBtn()
798 if(chkConfig(this)) return;
799 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
800 RockboxInfo
installInfo(mountpoint
);
801 if(installInfo
.revision().isEmpty() && installInfo
.release().isEmpty()) {
802 QMessageBox::critical(this, tr("No Rockbox installation found"),
803 tr("Could not determine the installed Rockbox version. "
804 "Please install a Rockbox build before installing "
808 if(QMessageBox::question(this, tr("Confirm Installation"),
809 tr("Do you really want to install the fonts package?"),
810 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
812 logger
= new ProgressLoggerGui(this);
817 bool RbUtilQt::installFontsAuto()
824 void RbUtilQt::installFonts()
826 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
827 RockboxInfo
installInfo(mountpoint
);
830 QString relversion
= installInfo
.release();
831 if(relversion
.isEmpty()) {
832 // release is empty for non-release versions (i.e. daily / current)
833 fontsurl
= SystemInfo::value(SystemInfo::DailyFontUrl
).toString();
836 fontsurl
= SystemInfo::value(SystemInfo::ReleaseFontUrl
).toString();
837 logversion
= installInfo
.release();
839 fontsurl
.replace("%RELEASEVER%", relversion
);
841 // create zip installer
842 installer
= new ZipInstaller(this);
843 installer
->setUrl(fontsurl
);
844 installer
->setLogSection("Fonts");
845 installer
->setLogVersion(logversion
);
846 installer
->setMountPoint(mountpoint
);
847 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
848 installer
->setCache(true);
850 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
851 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
852 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
853 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
854 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
855 installer
->install();
859 void RbUtilQt::installVoice()
861 if(chkConfig(this)) return;
863 if(m_gotInfo
== false)
865 QMessageBox::warning(this, tr("Warning"),
866 tr("The Application is still downloading Information about new Builds."
867 " Please try again shortly."));
871 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
872 RockboxInfo
installInfo(mountpoint
);
876 QString relversion
= installInfo
.release();
877 // if no version is found abort.
878 if(installInfo
.revision().isEmpty() && relversion
.isEmpty()) {
879 QMessageBox::critical(this, tr("No Rockbox installation found"),
880 tr("Could not determine the installed Rockbox version. "
881 "Please install a Rockbox build before installing "
885 if(relversion
.isEmpty()) {
886 // release is empty for development builds.
887 // No voice files are available for development builds.
888 QMessageBox::critical(this, tr("No voice file available"),
889 tr("The installed version of Rockbox is a development version. "
890 "Pre-built voices are only available for release versions "
891 "of Rockbox. Please generate a voice yourself using the "
892 "\"Create voice file\" functionality."));
896 voiceurl
= SystemInfo::value(SystemInfo::ReleaseVoiceUrl
).toString();
897 logversion
= installInfo
.release();
899 if(QMessageBox::question(this, tr("Confirm Installation"),
900 tr("Do you really want to install the voice file?"),
901 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
904 QString model
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
905 // replace placeholder in voice url
906 voiceurl
.replace("%MODEL%", model
);
907 voiceurl
.replace("%RELVERSION%", relversion
);
909 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
912 logger
= new ProgressLoggerGui(this);
914 // create zip installer
915 installer
= new ZipInstaller(this);
917 installer
->setUrl(voiceurl
);
918 installer
->setLogSection("Voice");
919 installer
->setLogVersion(logversion
);
920 installer
->setMountPoint(mountpoint
);
921 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
922 installer
->setCache(true);
923 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
924 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
925 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
926 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
927 installer
->install();
931 void RbUtilQt::installDoomBtn()
933 if(chkConfig(this)) return;
935 QMessageBox::critical(this, tr("Error"),
936 tr("Your device doesn't have a doom plugin. Aborting."));
940 if(QMessageBox::question(this, tr("Confirm Installation"),
941 tr("Do you really want to install the game addon files?"),
942 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
944 logger
= new ProgressLoggerGui(this);
949 bool RbUtilQt::installDoomAuto()
955 bool RbUtilQt::hasDoom()
957 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
958 +"/.rockbox/rocks/games/doom.rock");
959 return doomrock
.exists();
962 void RbUtilQt::installDoom()
964 // create zip installer
965 installer
= new ZipInstaller(this);
967 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
968 installer
->setLogSection("Game Addons");
969 installer
->setLogVersion();
970 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
971 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
972 installer
->setCache(true);
973 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
974 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
975 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
976 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
977 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
978 installer
->install();
982 void RbUtilQt::installThemes()
984 if(chkConfig(this)) return;
985 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
990 void RbUtilQt::createTalkFiles(void)
992 if(chkConfig(this)) return;
993 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
994 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
995 installWindow
->show();
999 void RbUtilQt::createVoiceFile(void)
1001 if(chkConfig(this)) return;
1002 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
1004 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1005 installWindow
->show();
1008 void RbUtilQt::uninstall(void)
1010 if(chkConfig(this)) return;
1011 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
1012 uninstallWindow
->show();
1016 void RbUtilQt::uninstallBootloader(void)
1018 if(chkConfig(this)) return;
1019 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
1020 tr("Do you really want to uninstall the Bootloader?"),
1021 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
1023 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1024 logger
->setProgressVisible(false);
1027 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1030 BootloaderInstallBase
*bl
1031 = BootloaderInstallHelper::createBootloaderInstaller(this,
1032 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
1035 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
1036 logger
->setFinished();
1039 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1040 QStringList blfilepath
;
1041 for(int a
= 0; a
< blfile
.size(); a
++) {
1042 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1045 bl
->setBlFile(blfilepath
);
1047 BootloaderInstallBase::BootloaderType currentbl
= bl
->installed();
1048 if((bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0
1049 || currentbl
== BootloaderInstallBase::BootloaderUnknown
1050 || currentbl
== BootloaderInstallBase::BootloaderOther
)
1052 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target. "
1053 "Try a normal firmware update to remove the booloader."), LOGERROR
);
1054 logger
->setFinished();
1059 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1060 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1064 logger
->setFinished();
1069 void RbUtilQt::installPortable(void)
1071 if(QMessageBox::question(this, tr("Confirm installation"),
1072 tr("Do you really want to install Rockbox Utility to your player? "
1073 "After installation you can run it from the players hard drive."),
1074 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1077 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1078 logger
->setProgressMax(0);
1079 logger
->setProgressValue(0);
1081 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1084 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1085 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1086 logger
->setFinished();
1090 // remove old files first.
1091 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1092 + "/RockboxUtility.exe");
1093 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1094 + "/RockboxUtility.ini");
1095 // copy currently running binary and currently used settings file
1096 if(!QFile::copy(qApp
->applicationFilePath(),
1097 RbSettings::value(RbSettings::Mountpoint
).toString()
1098 + "/RockboxUtility.exe")) {
1099 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1100 logger
->setFinished();
1103 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1104 if(!QFile::copy(RbSettings::userSettingFilename(),
1105 RbSettings::value(RbSettings::Mountpoint
).toString()
1106 + "/RockboxUtility.ini")) {
1107 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1108 logger
->setFinished();
1111 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1112 logger
->setFinished();
1113 logger
->setProgressMax(1);
1114 logger
->setProgressValue(1);
1119 QUrl
RbUtilQt::proxy()
1122 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1123 proxy
.setEncodedUrl(RbSettings::value(RbSettings::Proxy
).toByteArray());
1124 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1125 proxy
= System::systemProxy();
1126 qDebug() << proxy
.userName() << proxy
.password() << proxy
.host() << proxy
.port();
1131 bool RbUtilQt::chkConfig(QWidget
*parent
)
1134 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1135 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1136 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1139 if(parent
) QMessageBox::critical(parent
, tr("Configuration error"),
1140 tr("Your configuration is invalid. Please go to the configuration "
1141 "dialog and make sure the selected values are correct."));
1146 void RbUtilQt::checkUpdate(void)
1148 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1149 #if defined(Q_OS_WIN32)
1151 #elif defined(Q_OS_LINUX)
1153 #elif defined(Q_OS_MACX)
1157 update
= new HttpGet(this);
1158 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1159 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1160 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1161 update
->setCache(true);
1163 ui
.statusbar
->showMessage(tr("Checking for update ..."));
1164 update
->getFile(QUrl(url
));
1167 void RbUtilQt::downloadUpdateDone(bool error
)
1170 qDebug() << "[RbUtil] network error:" << update
->error();
1173 QString
toParse(update
->readAll());
1175 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1176 QStringList rbutilList
;
1178 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1180 rbutilList
<< searchString
.cap(1);
1181 pos
+= searchString
.matchedLength();
1183 qDebug() << "[RbUtilQt] Checking for update";
1185 QString newVersion
= "";
1186 QString foundVersion
= "";
1187 // check if there is a binary with higher version in this list
1188 for(int i
=0; i
< rbutilList
.size(); i
++)
1190 QString item
= rbutilList
.at(i
);
1191 #if defined(Q_OS_LINUX)
1192 #if defined(__amd64__)
1193 // skip if it isn't a 64 bit build
1194 if( !item
.contains("64bit"))
1196 // strip the "64bit" suffix for comparison
1197 item
= item
.remove("64bit");
1199 //skip if it is a 64bit build
1200 if(item
.contains("64bit"))
1204 // check if it is newer, and remember newest
1205 if(Utils::compareVersionStrings(VERSION
, item
) == 1)
1207 if(Utils::compareVersionStrings(newVersion
, item
) == 1)
1210 foundVersion
= rbutilList
.at(i
);
1215 // if we found something newer, display info
1216 if(foundVersion
!= "")
1218 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1219 #if defined(Q_OS_WIN32)
1221 #elif defined(Q_OS_LINUX)
1223 #elif defined(Q_OS_MACX)
1226 url
+= foundVersion
;
1228 QMessageBox::information(this,tr("RockboxUtility Update available"),
1229 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1230 "Download it from here: <a href='%1'>%2</a>")
1231 .arg(url
).arg(foundVersion
));
1232 ui
.statusbar
->showMessage(tr("New version of Rockbox Utility available."));
1235 ui
.statusbar
->showMessage(tr("Rockbox Utility is up to date."), 5000);
1241 void RbUtilQt::changeEvent(QEvent
*e
)
1243 if(e
->type() == QEvent::LanguageChange
) {
1244 ui
.retranslateUi(this);
1246 ServerInfo::readBuildInfo(buildInfo
.fileName());
1250 QMainWindow::changeEvent(e
);