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 "bootloaderinstallmpio.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::ServerConfUrl
).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 // start bleeding info download
253 bleeding
= new HttpGet(this);
254 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
255 connect(qApp
, SIGNAL(lastWindowClosed()), bleeding
, SLOT(abort()));
256 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
257 bleeding
->setCache(true);
258 bleeding
->setFile(&bleedingInfo
);
259 bleeding
->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo
).toString()));
260 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
265 void RbUtilQt::downloadBleedingDone(bool error
)
268 qDebug() << "[RbUtil] network error:" << bleeding
->error();
269 ui
.statusbar
->showMessage(tr("Can't get version information!"));
270 QMessageBox::critical(this, tr("Network error"),
271 tr("Can't get version information.\n"
272 "Network error: %1. Please check your network and proxy settings.")
273 .arg(bleeding
->errorString()));
278 ServerInfo::readBleedingInfo(bleedingInfo
.fileName());
279 bleedingInfo
.close();
281 ui
.statusbar
->showMessage(tr("Download build information finished."), 5000);
285 //start check for updates
291 void RbUtilQt::about()
293 QDialog
*window
= new QDialog(this);
295 about
.setupUi(window
);
296 window
->setLayoutDirection(Qt::LeftToRight
);
297 window
->setModal(true);
299 QFile
licence(":/docs/gpl-2.0.html");
300 licence
.open(QIODevice::ReadOnly
);
301 QTextStream
c(&licence
);
302 about
.browserLicense
->insertHtml(c
.readAll());
303 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
305 QFile
speexlicense(":/docs/COPYING.SPEEX");
306 speexlicense
.open(QIODevice::ReadOnly
);
307 QTextStream
s(&speexlicense
);
308 about
.browserSpeexLicense
->insertHtml("<pre>" + s
.readAll() + "</pre>");
309 about
.browserSpeexLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
311 QFile
credits(":/docs/CREDITS");
312 credits
.open(QIODevice::ReadOnly
);
313 QTextStream
r(&credits
);
314 r
.setCodec(QTextCodec::codecForName("UTF-8"));
316 QString line
= r
.readLine();
317 // filter out header.
318 line
.remove(QRegExp("^ +.*"));
319 line
.remove(QRegExp("^People.*"));
320 about
.browserCredits
->append(line
);
322 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
323 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION
);
324 about
.labelTitle
->setText(title
);
331 void RbUtilQt::help()
333 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
334 QDesktopServices::openUrl(helpurl
);
338 void RbUtilQt::configDialog()
340 Config
*cw
= new Config(this);
341 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
346 void RbUtilQt::updateSettings()
348 qDebug() << "[RbUtil] updating current settings";
350 manual
->updateManual();
351 HttpGet::setGlobalProxy(proxy());
352 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath
).toString());
353 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline
).toBool());
355 if(RbSettings::value(RbSettings::RbutilVersion
) != PUREVERSION
) {
356 QApplication::processEvents();
357 QMessageBox::information(this, tr("New installation"),
358 tr("This is a new installation of Rockbox Utility, or a new version. "
359 "The configuration dialog will now open to allow you to setup the program, "
360 " or review your settings."));
363 else if(chkConfig(0)) {
364 QApplication::processEvents();
365 QMessageBox::critical(this, tr("Configuration error"),
366 tr("Your configuration is invalid. This is most likely due "
367 "to a changed device path. The configuration dialog will "
368 "now open to allow you to correct the problem."));
374 void RbUtilQt::updateDevice()
376 /* TODO: We should check the flags of the bootloaderinstall classes, and not
377 * just check if its != none or != "fwpatcher" */
379 /* Enable bootloader installation, if possible */
380 bool bootloaderInstallable
=
381 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none";
382 ui
.buttonBootloader
->setEnabled(bootloaderInstallable
);
383 ui
.labelBootloader
->setEnabled(bootloaderInstallable
);
384 ui
.actionInstall_Bootloader
->setEnabled(bootloaderInstallable
);
386 /* Enable bootloader uninstallation, if possible */
387 bool bootloaderUninstallable
= bootloaderInstallable
&&
388 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "fwpatcher";
389 ui
.labelRemoveBootloader
->setEnabled(bootloaderUninstallable
);
390 ui
.buttonRemoveBootloader
->setEnabled(bootloaderUninstallable
);
391 ui
.actionRemove_bootloader
->setEnabled(bootloaderUninstallable
);
393 /* Disable the whole tab widget if configuration is invalid */
394 bool configurationValid
= !chkConfig(0);
395 ui
.tabWidget
->setEnabled(configurationValid
);
396 ui
.menuA_ctions
->setEnabled(configurationValid
);
398 // displayed device info
399 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
400 QString brand
= SystemInfo::value(SystemInfo::CurBrand
).toString();
401 QString name
= SystemInfo::value(SystemInfo::CurName
).toString() +
402 " (" + ServerInfo::value(ServerInfo::CurStatus
).toString() + ")";
403 QString mountdisplay
= QDir::toNativeSeparators(mountpoint
);
404 QString label
= Utils::filesystemName(mountpoint
);
406 mountdisplay
+= " (" + label
+ ")";
408 if(name
.isEmpty()) name
= "<none>";
409 if(mountpoint
.isEmpty())
410 mountpoint
= "<invalid>";
411 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
412 .arg(brand
, name
, mountdisplay
));
414 // hide quickstart buttons if no release available
415 bool installable
= !ServerInfo::value(ServerInfo::CurReleaseVersion
).toString().isEmpty();
416 ui
.buttonSmall
->setEnabled(installable
);
417 ui
.buttonComplete
->setEnabled(installable
);
418 ui
.actionSmall_Installation
->setEnabled(installable
);
419 ui
.actionComplete_Installation
->setEnabled(installable
);
423 void RbUtilQt::completeInstall()
425 if(chkConfig(this)) return;
426 if(QMessageBox::question(this, tr("Confirm Installation"),
427 tr("Do you really want to perform a complete installation?\n\n"
428 "This will install Rockbox %1. To install the most recent "
429 "development build available press \"Cancel\" and "
430 "use the \"Installation\" tab.")
431 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
432 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
435 logger
= new ProgressLoggerGui(this);
438 if(smallInstallInner())
440 logger
->setRunning();
444 if(!installFontsAuto())
448 // wait for installation finished
450 QApplication::processEvents();
453 logger
->setRunning();
460 if(!installDoomAuto())
464 // wait for installation finished
466 QApplication::processEvents();
473 // it has its own logger window,so close our.
479 void RbUtilQt::smallInstall()
481 if(chkConfig(this)) return;
482 if(QMessageBox::question(this, tr("Confirm Installation"),
483 tr("Do you really want to perform a minimal installation? "
484 "A minimal installation will contain only the absolutely "
485 "necessary parts to run Rockbox.\n\n"
486 "This will install Rockbox %1. To install the most recent "
487 "development build available press \"Cancel\" and "
488 "use the \"Installation\" tab.")
489 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
490 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
494 logger
= new ProgressLoggerGui(this);
500 bool RbUtilQt::smallInstallInner()
502 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
503 // show dialog with error if mount point is wrong
504 if(!QFileInfo(mountpoint
).isDir()) {
505 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
506 logger
->setFinished();
510 if(SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none")
515 if(!installBootloaderAuto()) {
516 logger
->setFinished();
521 // wait for boot loader installation finished
523 QApplication::processEvents();
526 if(m_error
) return true;
527 logger
->setRunning();
537 // wait for installation finished
539 QApplication::processEvents();
542 installBootloaderPost(false);
546 void RbUtilQt::installdone(bool error
)
548 qDebug() << "[RbUtil] install done";
553 void RbUtilQt::installBtn()
555 if(chkConfig(this)) return;
559 bool RbUtilQt::installAuto()
561 QString file
= SystemInfo::value(SystemInfo::ReleaseUrl
).toString();
562 file
.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel
).toString());
563 file
.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
565 // check installed Version and Target
566 QString warning
= Utils::checkEnvironment(false);
567 if(!warning
.isEmpty())
569 if(QMessageBox::warning(this, tr("Really continue?"), warning
,
570 QMessageBox::Ok
| QMessageBox::Abort
, QMessageBox::Abort
)
571 == QMessageBox::Abort
)
573 logger
->addItem(tr("Aborted!"), LOGERROR
);
574 logger
->setFinished();
580 RockboxInfo
rbinfo(RbSettings::value(RbSettings::Mountpoint
).toString());
581 if(rbinfo
.version() != "")
583 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
584 tr("Rockbox installation detected. Do you want to backup first?"),
585 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
588 logger
->addItem(tr("Starting backup..."),LOGINFO
);
589 QString backupName
= RbSettings::value(RbSettings::Mountpoint
).toString()
590 + "/.backup/rockbox-backup-" + rbinfo
.version() + ".zip";
592 //! create dir, if it doesnt exist
593 QFileInfo
backupFile(backupName
);
594 if(!QDir(backupFile
.path()).exists())
597 a
.mkpath(backupFile
.path());
600 logger
->addItem(tr("Beginning Backup..."),LOGINFO
);
601 QCoreApplication::processEvents();
605 connect(&zip
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
606 connect(&zip
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
607 zip
.open(backupName
, QuaZip::mdCreate
);
608 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
609 QString folder
= mp
+ "/.rockbox";
610 result
= zip
.appendDirToArchive(folder
, mp
);
614 logger
->addItem(tr("Backup successful"),LOGOK
);
618 logger
->addItem(tr("Backup failed!"),LOGERROR
);
619 logger
->setFinished();
625 //! install current build
626 ZipInstaller
* installer
= new ZipInstaller(this);
627 installer
->setUrl(file
);
628 installer
->setLogSection("Rockbox (Base)");
629 installer
->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
630 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
631 installer
->setCache(true);
632 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
634 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
635 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
636 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
637 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
638 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
639 installer
->install();
644 void RbUtilQt::install()
646 InstallWindow
*installWindow
= new InstallWindow(this);
647 installWindow
->show();
650 bool RbUtilQt::installBootloaderAuto()
656 void RbUtilQt::installBootloaderBtn()
658 if(chkConfig(this)) return;
659 if(QMessageBox::question(this, tr("Confirm Installation"),
660 tr("Do you really want to install the Bootloader?"),
661 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
664 logger
= new ProgressLoggerGui(this);
669 void RbUtilQt::installBootloader()
671 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
672 QString backupDestination
= "";
676 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
677 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
679 logger
->addItem(tr("No install method known."), LOGERROR
);
680 logger
->setFinished();
684 // the bootloader install class does NOT use any GUI stuff.
685 // All messages are passed via signals.
686 connect(bl
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
687 connect(bl
, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
688 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
689 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
691 // set bootloader filename. Do this now as installed() needs it.
692 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
693 QStringList blfilepath
;
694 for(int a
= 0; a
< blfile
.size(); a
++) {
695 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
698 bl
->setBlFile(blfilepath
);
699 QUrl
url(SystemInfo::value(SystemInfo::BootloaderUrl
).toString()
700 + SystemInfo::value(SystemInfo::CurBootloaderName
).toString());
702 bl
->setLogfile(RbSettings::value(RbSettings::Mountpoint
).toString()
703 + "/.rockbox/rbutil.log");
705 if(bl
->installed() == BootloaderInstallBase::BootloaderRockbox
) {
706 if(QMessageBox::question(this, tr("Bootloader detected"),
707 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
708 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
) {
710 // keep logger open for auto installs.
711 // don't consider abort as error in auto-mode.
712 logger
->addItem(tr("Bootloader installation skipped"), LOGINFO
);
713 installBootloaderPost(false);
717 installBootloaderPost(true);
723 else if(bl
->installed() == BootloaderInstallBase::BootloaderOther
724 && bl
->capabilities() & BootloaderInstallBase::Backup
)
726 QString targetFolder
= SystemInfo::value(SystemInfo::CurPlatformName
).toString()
727 + " Firmware Backup";
728 // remove invalid character(s)
729 targetFolder
.remove(QRegExp("[:/]"));
730 if(QMessageBox::question(this, tr("Create Bootloader backup"),
731 tr("You can create a backup of the original bootloader "
732 "file. Press \"Yes\" to select an output folder on your "
733 "computer to save the file to. The file will get placed "
734 "in a new folder \"%1\" created below the selected folder.\n"
735 "Press \"No\" to skip this step.").arg(targetFolder
),
736 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
) {
737 backupDestination
= QFileDialog::getExistingDirectory(this,
738 tr("Browse backup folder"), QDir::homePath());
739 if(!backupDestination
.isEmpty())
740 backupDestination
+= "/" + targetFolder
;
742 qDebug() << "[RbUtil] backing up to" << backupDestination
;
743 // backup needs to be done after the logger has been set up.
747 if(bl
->capabilities() & BootloaderInstallBase::NeedsOf
)
750 ret
= QMessageBox::information(this, tr("Prerequisites"),
751 bl
->ofHint(),QMessageBox::Ok
| QMessageBox::Abort
);
752 if(ret
!= QMessageBox::Ok
) {
753 // consider aborting an error to close window / abort automatic
756 logger
->addItem(tr("Bootloader installation aborted"), LOGINFO
);
757 logger
->setFinished();
760 // open dialog to browse to of file
762 offile
= QFileDialog::getOpenFileName(this,
763 tr("Select firmware file"), QDir::homePath());
764 if(!QFileInfo(offile
).isReadable()) {
765 logger
->addItem(tr("Error opening firmware file"), LOGERROR
);
766 logger
->setFinished();
770 if(!bl
->setOfFile(offile
, blfile
)) {
771 logger
->addItem(tr("Error reading firmware file"), LOGERROR
);
772 logger
->setFinished();
779 if(!backupDestination
.isEmpty()) {
780 if(!bl
->backup(backupDestination
)) {
781 if(QMessageBox::warning(this, tr("Backup error"),
782 tr("Could not create backup file. Continue?"),
783 QMessageBox::No
| QMessageBox::Yes
)
784 == QMessageBox::No
) {
785 logger
->setFinished();
793 void RbUtilQt::installBootloaderPost(bool error
)
795 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error
;
796 // if an error occured don't perform post install steps.
805 // end here if automated install
809 QString msg
= BootloaderInstallBase::postinstallHints(
810 RbSettings::value(RbSettings::Platform
).toString());
812 QMessageBox::information(this, tr("Manual steps required"), msg
);
818 void RbUtilQt::installFontsBtn()
820 if(chkConfig(this)) return;
821 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
822 RockboxInfo
installInfo(mountpoint
);
823 if(installInfo
.revision().isEmpty() && installInfo
.release().isEmpty()) {
824 QMessageBox::critical(this, tr("No Rockbox installation found"),
825 tr("Could not determine the installed Rockbox version. "
826 "Please install a Rockbox build before installing "
830 if(QMessageBox::question(this, tr("Confirm Installation"),
831 tr("Do you really want to install the fonts package?"),
832 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
834 logger
= new ProgressLoggerGui(this);
839 bool RbUtilQt::installFontsAuto()
846 void RbUtilQt::installFonts()
848 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
849 RockboxInfo
installInfo(mountpoint
);
852 QString relversion
= installInfo
.release();
853 if(relversion
.isEmpty()) {
854 // release is empty for non-release versions (i.e. daily / current)
855 fontsurl
= SystemInfo::value(SystemInfo::DailyFontUrl
).toString();
856 logversion
= installInfo
.revision();
859 fontsurl
= SystemInfo::value(SystemInfo::ReleaseFontUrl
).toString();
860 logversion
= installInfo
.release();
862 fontsurl
.replace("%RELEASEVER%", relversion
);
864 // create zip installer
865 installer
= new ZipInstaller(this);
866 installer
->setUrl(fontsurl
);
867 installer
->setLogSection("Fonts");
868 installer
->setLogVersion(logversion
);
869 installer
->setMountPoint(mountpoint
);
870 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
871 installer
->setCache(true);
873 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
874 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
875 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
876 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
877 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
878 installer
->install();
882 void RbUtilQt::installVoice()
884 if(chkConfig(this)) return;
886 if(m_gotInfo
== false)
888 QMessageBox::warning(this, tr("Warning"),
889 tr("The Application is still downloading Information about new Builds."
890 " Please try again shortly."));
894 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
895 RockboxInfo
installInfo(mountpoint
);
899 QString relversion
= installInfo
.release();
900 // if no version is found abort.
901 if(installInfo
.revision().isEmpty() && relversion
.isEmpty()) {
902 QMessageBox::critical(this, tr("No Rockbox installation found"),
903 tr("Could not determine the installed Rockbox version. "
904 "Please install a Rockbox build before installing "
908 if(relversion
.isEmpty()) {
909 // release is empty for non-release versions (i.e. daily / current)
910 voiceurl
= SystemInfo::value(SystemInfo::DailyVoiceUrl
).toString();
911 logversion
= installInfo
.revision();
914 voiceurl
= SystemInfo::value(SystemInfo::ReleaseVoiceUrl
).toString();
915 logversion
= installInfo
.release();
917 if(QMessageBox::question(this, tr("Confirm Installation"),
918 tr("Do you really want to install the voice file?"),
919 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
922 QDate date
= QDate::fromString(
923 ServerInfo::value(ServerInfo::DailyDate
).toString(), Qt::ISODate
);
924 QString model
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
925 // replace placeholder in voice url
926 voiceurl
.replace("%DATE%", date
.toString("yyyyMMdd"));
927 voiceurl
.replace("%MODEL%", model
);
928 voiceurl
.replace("%RELVERSION%", relversion
);
930 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
933 logger
= new ProgressLoggerGui(this);
935 // create zip installer
936 installer
= new ZipInstaller(this);
938 installer
->setUrl(voiceurl
);
939 installer
->setLogSection("Voice");
940 installer
->setLogVersion(logversion
);
941 installer
->setMountPoint(mountpoint
);
942 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
943 installer
->setCache(true);
944 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
945 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
946 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
947 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
948 installer
->install();
952 void RbUtilQt::installDoomBtn()
954 if(chkConfig(this)) return;
956 QMessageBox::critical(this, tr("Error"),
957 tr("Your device doesn't have a doom plugin. Aborting."));
961 if(QMessageBox::question(this, tr("Confirm Installation"),
962 tr("Do you really want to install the game addon files?"),
963 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
965 logger
= new ProgressLoggerGui(this);
970 bool RbUtilQt::installDoomAuto()
976 bool RbUtilQt::hasDoom()
978 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
979 +"/.rockbox/rocks/games/doom.rock");
980 return doomrock
.exists();
983 void RbUtilQt::installDoom()
985 // create zip installer
986 installer
= new ZipInstaller(this);
988 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
989 installer
->setLogSection("Game Addons");
990 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
991 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
992 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
993 installer
->setCache(true);
994 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
995 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
996 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
997 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
998 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
999 installer
->install();
1003 void RbUtilQt::installThemes()
1005 if(chkConfig(this)) return;
1006 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
1011 void RbUtilQt::createTalkFiles(void)
1013 if(chkConfig(this)) return;
1014 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
1015 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1016 installWindow
->show();
1020 void RbUtilQt::createVoiceFile(void)
1022 if(chkConfig(this)) return;
1023 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
1025 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1026 installWindow
->show();
1029 void RbUtilQt::uninstall(void)
1031 if(chkConfig(this)) return;
1032 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
1033 uninstallWindow
->show();
1037 void RbUtilQt::uninstallBootloader(void)
1039 if(chkConfig(this)) return;
1040 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
1041 tr("Do you really want to uninstall the Bootloader?"),
1042 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
1044 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1045 logger
->setProgressVisible(false);
1048 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1051 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
1052 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
1055 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
1056 logger
->setFinished();
1059 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1060 QStringList blfilepath
;
1061 for(int a
= 0; a
< blfile
.size(); a
++) {
1062 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1065 bl
->setBlFile(blfilepath
);
1067 BootloaderInstallBase::BootloaderType currentbl
= bl
->installed();
1068 if((bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0
1069 || currentbl
== BootloaderInstallBase::BootloaderUnknown
1070 || currentbl
== BootloaderInstallBase::BootloaderOther
)
1072 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target. "
1073 "Try a normal firmware update to remove the booloader."), LOGERROR
);
1074 logger
->setFinished();
1079 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1080 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1084 logger
->setFinished();
1089 void RbUtilQt::installPortable(void)
1091 if(QMessageBox::question(this, tr("Confirm installation"),
1092 tr("Do you really want to install Rockbox Utility to your player? "
1093 "After installation you can run it from the players hard drive."),
1094 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1097 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1098 logger
->setProgressMax(0);
1099 logger
->setProgressValue(0);
1101 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1104 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1105 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1106 logger
->setFinished();
1110 // remove old files first.
1111 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1112 + "/RockboxUtility.exe");
1113 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1114 + "/RockboxUtility.ini");
1115 // copy currently running binary and currently used settings file
1116 if(!QFile::copy(qApp
->applicationFilePath(),
1117 RbSettings::value(RbSettings::Mountpoint
).toString()
1118 + "/RockboxUtility.exe")) {
1119 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1120 logger
->setFinished();
1123 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1124 if(!QFile::copy(RbSettings::userSettingFilename(),
1125 RbSettings::value(RbSettings::Mountpoint
).toString()
1126 + "/RockboxUtility.ini")) {
1127 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1128 logger
->setFinished();
1131 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1132 logger
->setFinished();
1133 logger
->setProgressMax(1);
1134 logger
->setProgressValue(1);
1139 QUrl
RbUtilQt::proxy()
1142 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1143 proxy
.setEncodedUrl(RbSettings::value(RbSettings::Proxy
).toByteArray());
1144 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1145 proxy
= System::systemProxy();
1146 qDebug() << proxy
.userName() << proxy
.password() << proxy
.host() << proxy
.port();
1151 bool RbUtilQt::chkConfig(QWidget
*parent
)
1154 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1155 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1156 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1159 if(parent
) QMessageBox::critical(parent
, tr("Configuration error"),
1160 tr("Your configuration is invalid. Please go to the configuration "
1161 "dialog and make sure the selected values are correct."));
1166 void RbUtilQt::checkUpdate(void)
1168 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1169 #if defined(Q_OS_WIN32)
1171 #elif defined(Q_OS_LINUX)
1173 #elif defined(Q_OS_MACX)
1177 update
= new HttpGet(this);
1178 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1179 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1180 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1181 update
->setCache(true);
1183 ui
.statusbar
->showMessage(tr("Checking for update ..."));
1184 update
->getFile(QUrl(url
));
1187 void RbUtilQt::downloadUpdateDone(bool error
)
1190 qDebug() << "[RbUtil] network error:" << update
->error();
1193 QString
toParse(update
->readAll());
1195 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1196 QStringList rbutilList
;
1198 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1200 rbutilList
<< searchString
.cap(1);
1201 pos
+= searchString
.matchedLength();
1203 qDebug() << "[RbUtilQt] Checking for update";
1205 QString newVersion
= "";
1206 QString foundVersion
= "";
1207 // check if there is a binary with higher version in this list
1208 for(int i
=0; i
< rbutilList
.size(); i
++)
1210 QString item
= rbutilList
.at(i
);
1211 #if defined(Q_OS_LINUX)
1212 #if defined(__amd64__)
1213 // skip if it isn't a 64 bit build
1214 if( !item
.contains("64bit"))
1216 // strip the "64bit" suffix for comparison
1217 item
= item
.remove("64bit");
1219 //skip if it is a 64bit build
1220 if(item
.contains("64bit"))
1224 // check if it is newer, and remember newest
1225 if(Utils::compareVersionStrings(VERSION
, item
) == 1)
1227 if(Utils::compareVersionStrings(newVersion
, item
) == 1)
1230 foundVersion
= rbutilList
.at(i
);
1235 // if we found something newer, display info
1236 if(foundVersion
!= "")
1238 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1239 #if defined(Q_OS_WIN32)
1241 #elif defined(Q_OS_LINUX)
1243 #elif defined(Q_OS_MACX)
1246 url
+= foundVersion
;
1248 QMessageBox::information(this,tr("RockboxUtility Update available"),
1249 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1250 "Download it from here: <a href='%1'>%2</a>")
1251 .arg(url
).arg(foundVersion
));
1252 ui
.statusbar
->showMessage(tr("New version of Rockbox Utility available."));
1255 ui
.statusbar
->showMessage(tr("Rockbox Utility is up to date."), 5000);
1261 void RbUtilQt::changeEvent(QEvent
*e
)
1263 if(e
->type() == QEvent::LanguageChange
) {
1264 ui
.retranslateUi(this);
1266 ServerInfo::readBuildInfo(buildInfo
.fileName());
1270 QMainWindow::changeEvent(e
);