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"
27 #include "installwindow.h"
28 #include "installtalkwindow.h"
29 #include "createvoicewindow.h"
31 #include "themesinstallwindow.h"
32 #include "uninstallwindow.h"
34 #include "rockboxinfo.h"
39 #include "rbsettings.h"
40 #include "serverinfo.h"
41 #include "systeminfo.h"
43 #include "progressloggerinterface.h"
45 #include "bootloaderinstallbase.h"
46 #include "bootloaderinstallmpio.h"
48 #if defined(Q_OS_LINUX)
51 #if defined(Q_OS_WIN32)
60 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
63 qDebug() << "======================================";
64 qDebug() << "[System] Rockbox Utility " VERSION
;
65 qDebug() << "[System] Qt version:" << qVersion();
66 qDebug() << "======================================";
68 absolutePath
= qApp
->applicationDirPath();
70 HttpGet::setGlobalUserAgent("rbutil/"VERSION
);
71 HttpGet::setGlobalProxy(proxy());
72 // init startup & autodetection
74 #if defined(Q_OS_LINUX)
75 QIcon
windowIcon(":/icons/rockbox-clef.svg");
76 this->setWindowIcon(windowIcon
);
79 #if defined(Q_OS_WIN32)
82 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Wine"),
83 0, KEY_QUERY_VALUE
, &hk
);
84 if(ret
== ERROR_SUCCESS
) {
85 QMessageBox::warning(this, tr("Wine detected!"),
86 tr("It seems you are trying to run this program under Wine. "
87 "Please don't do this, running under Wine will fail. "
88 "Use the native Linux binary instead."),
89 QMessageBox::Ok
, QMessageBox::Ok
);
90 qDebug() << "[RbUtil] WINE DETECTED!";
100 ui
.radioPdf
->setChecked(true);
103 ui
.treeInfo
->setAlternatingRowColors(true);
104 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
105 ui
.treeInfo
->expandAll();
106 ui
.treeInfo
->setColumnCount(2);
107 ui
.treeInfo
->setLayoutDirection(Qt::LeftToRight
);
108 // disable quick install until version info is available
109 ui
.buttonSmall
->setEnabled(false);
110 ui
.buttonComplete
->setEnabled(false);
111 ui
.actionSmall_Installation
->setEnabled(false);
112 ui
.actionComplete_Installation
->setEnabled(false);
114 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
115 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
116 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
117 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
118 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
119 connect(ui
.actionE_xit
, SIGNAL(triggered()), this, SLOT(shutdown()));
120 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
121 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
122 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
123 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
124 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
125 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
126 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
127 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
128 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
129 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
130 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
131 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
132 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
133 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
135 // actions accessible from the menu
136 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
137 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
138 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
139 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
140 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
141 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
142 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
143 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
144 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
145 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
146 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
147 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
148 connect(ui
.action_System_Info
, SIGNAL(triggered()), this, SLOT(sysinfo()));
149 connect(ui
.action_Trace
, SIGNAL(triggered()), this, SLOT(trace()));
152 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
154 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
160 void RbUtilQt::shutdown(void)
162 // restore default message handler to prevent trace accesses during
163 // object destruction -- the trace object could already be destroyed.
164 // Fixes segfaults on exit.
165 qInstallMsgHandler(0);
171 void RbUtilQt::trace(void)
177 void RbUtilQt::sysinfo(void)
183 void RbUtilQt::updateTabs(int count
)
195 void RbUtilQt::downloadInfo()
197 // try to get the current build information
198 daily
= new HttpGet(this);
199 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
200 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
201 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
202 daily
->setCache(true);
204 daily
->setCache(false);
205 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
206 qDebug() << "[RbUtil] downloading build info";
207 daily
->setFile(&buildInfo
);
208 daily
->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl
).toString()));
212 void RbUtilQt::downloadDone(bool error
)
215 qDebug() << "[RbUtil] network error:" << daily
->error();
216 ui
.statusbar
->showMessage(tr("Can't get version information!"));
217 QMessageBox::critical(this, tr("Network error"),
218 tr("Can't get version information.\n"
219 "Network error: %1. Please check your network and proxy settings.")
220 .arg(daily
->errorString()));
223 qDebug() << "[RbUtil] network status:" << daily
->error();
225 // read info into ServerInfo object
227 ServerInfo::readBuildInfo(buildInfo
.fileName());
230 // start bleeding info download
231 bleeding
= new HttpGet(this);
232 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
233 connect(qApp
, SIGNAL(lastWindowClosed()), bleeding
, SLOT(abort()));
234 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
235 bleeding
->setCache(true);
236 bleeding
->setFile(&bleedingInfo
);
237 bleeding
->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo
).toString()));
238 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
243 void RbUtilQt::downloadBleedingDone(bool error
)
246 qDebug() << "[RbUtil] network error:" << bleeding
->error();
247 ui
.statusbar
->showMessage(tr("Can't get version information!"));
248 QMessageBox::critical(this, tr("Network error"),
249 tr("Can't get version information.\n"
250 "Network error: %1. Please check your network and proxy settings.")
251 .arg(bleeding
->errorString()));
256 ServerInfo::readBleedingInfo(bleedingInfo
.fileName());
257 bleedingInfo
.close();
259 ui
.statusbar
->showMessage(tr("Download build information finished."), 5000);
263 //start check for updates
269 void RbUtilQt::about()
271 QDialog
*window
= new QDialog(this);
273 about
.setupUi(window
);
274 window
->setLayoutDirection(Qt::LeftToRight
);
275 window
->setModal(true);
277 QFile
licence(":/docs/gpl-2.0.html");
278 licence
.open(QIODevice::ReadOnly
);
279 QTextStream
c(&licence
);
280 QString cline
= c
.readAll();
281 about
.browserLicense
->insertHtml(cline
);
282 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
283 QFile
credits(":/docs/CREDITS");
284 credits
.open(QIODevice::ReadOnly
);
285 QTextStream
r(&credits
);
286 r
.setCodec(QTextCodec::codecForName("UTF-8"));
288 QString line
= r
.readLine();
289 // filter out header.
290 line
.remove(QRegExp("^[^A-Z]+.*"));
291 line
.remove(QRegExp("^People.*"));
292 about
.browserCredits
->append(line
);
294 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
295 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION
);
296 about
.labelTitle
->setText(title
);
303 void RbUtilQt::help()
305 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
306 QDesktopServices::openUrl(helpurl
);
310 void RbUtilQt::configDialog()
312 Config
*cw
= new Config(this);
313 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
318 void RbUtilQt::updateSettings()
320 qDebug() << "[RbUtil] updating current settings";
323 HttpGet::setGlobalProxy(proxy());
324 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath
).toString());
325 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline
).toBool());
327 if(RbSettings::value(RbSettings::RbutilVersion
) != PUREVERSION
) {
328 QApplication::processEvents();
329 QMessageBox::information(this, tr("New installation"),
330 tr("This is a new installation of Rockbox Utility, or a new version. "
331 "The configuration dialog will now open to allow you to setup the program, "
332 " or review your settings."));
335 else if(chkConfig(false)) {
336 QApplication::processEvents();
337 QMessageBox::critical(this, tr("Configuration error"),
338 tr("Your configuration is invalid. This is most likely due "
339 "to a changed device path. The configuration dialog will "
340 "now open to allow you to correct the problem."));
346 void RbUtilQt::updateDevice()
348 /* TODO: We should check the flags of the bootloaderinstall classes, and not
349 * just check if its != none or != "fwpatcher" */
351 /* Enable bootloader installation, if possible */
352 bool bootloaderInstallable
=
353 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none";
354 ui
.buttonBootloader
->setEnabled(bootloaderInstallable
);
355 ui
.labelBootloader
->setEnabled(bootloaderInstallable
);
356 ui
.actionInstall_Bootloader
->setEnabled(bootloaderInstallable
);
358 /* Enable bootloader uninstallation, if possible */
359 bool bootloaderUninstallable
= bootloaderInstallable
&&
360 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "fwpatcher";
361 ui
.labelRemoveBootloader
->setEnabled(bootloaderUninstallable
);
362 ui
.buttonRemoveBootloader
->setEnabled(bootloaderUninstallable
);
363 ui
.actionRemove_bootloader
->setEnabled(bootloaderUninstallable
);
365 /* Disable the whole tab widget if configuration is invalid */
366 bool configurationValid
= !chkConfig(false);
367 ui
.tabWidget
->setEnabled(configurationValid
);
368 ui
.menuA_ctions
->setEnabled(configurationValid
);
370 // displayed device info
371 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
372 QString brand
= SystemInfo::value(SystemInfo::CurBrand
).toString();
373 QString name
= SystemInfo::value(SystemInfo::CurName
).toString() +
374 " (" + ServerInfo::value(ServerInfo::CurStatus
).toString() + ")";
375 if(name
.isEmpty()) name
= "<none>";
376 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
377 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
378 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
380 // hide quickstart buttons if no release available
381 bool installable
= !ServerInfo::value(ServerInfo::CurReleaseVersion
).toString().isEmpty();
382 ui
.buttonSmall
->setEnabled(installable
);
383 ui
.buttonComplete
->setEnabled(installable
);
384 ui
.actionSmall_Installation
->setEnabled(installable
);
385 ui
.actionComplete_Installation
->setEnabled(installable
);
389 void RbUtilQt::updateManual()
391 if(RbSettings::value(RbSettings::Platform
) != "")
393 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
397 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
399 pdfmanual
= SystemInfo::value(SystemInfo::ManualUrl
).toString()
400 + "/" + manual
+ ".pdf";
402 htmlmanual
= SystemInfo::value(SystemInfo::ManualUrl
).toString()
403 + "/" + manual
+ "/rockbox-build.html";
404 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
406 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
410 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
411 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
412 .arg("http://www.rockbox.org/manual.shtml"));
417 void RbUtilQt::completeInstall()
419 if(chkConfig(true)) return;
420 if(QMessageBox::question(this, tr("Confirm Installation"),
421 tr("Do you really want to perform a complete installation?\n\n"
422 "This will install Rockbox %1. To install the most recent "
423 "development build available press \"Cancel\" and "
424 "use the \"Installation\" tab.")
425 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
426 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
429 logger
= new ProgressLoggerGui(this);
432 if(smallInstallInner())
434 logger
->setRunning();
438 if(!installFontsAuto())
442 // wait for installation finished
444 QApplication::processEvents();
447 logger
->setRunning();
454 if(!installDoomAuto())
458 // wait for installation finished
460 QApplication::processEvents();
467 // it has its own logger window,so close our.
473 void RbUtilQt::smallInstall()
475 if(chkConfig(true)) return;
476 if(QMessageBox::question(this, tr("Confirm Installation"),
477 tr("Do you really want to perform a minimal installation? "
478 "A minimal installation will contain only the absolutely "
479 "necessary parts to run Rockbox.\n\n"
480 "This will install Rockbox %1. To install the most recent "
481 "development build available press \"Cancel\" and "
482 "use the \"Installation\" tab.")
483 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
484 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
488 logger
= new ProgressLoggerGui(this);
494 bool RbUtilQt::smallInstallInner()
496 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
497 // show dialog with error if mount point is wrong
498 if(!QFileInfo(mountpoint
).isDir()) {
499 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
500 logger
->setFinished();
504 if(SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none")
509 if(!installBootloaderAuto()) {
510 logger
->setFinished();
515 // wait for boot loader installation finished
517 QApplication::processEvents();
520 if(m_error
) return true;
521 logger
->setRunning();
531 // wait for installation finished
533 QApplication::processEvents();
536 installBootloaderPost(false);
540 void RbUtilQt::installdone(bool error
)
542 qDebug() << "[RbUtil] install done";
547 void RbUtilQt::installBtn()
549 if(chkConfig(true)) return;
553 bool RbUtilQt::installAuto()
555 QString file
= SystemInfo::value(SystemInfo::ReleaseUrl
).toString();
556 file
.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel
).toString());
557 file
.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
559 // check installed Version and Target
560 QString warning
= Utils::checkEnvironment(false);
561 if(!warning
.isEmpty())
563 if(QMessageBox::warning(this, tr("Really continue?"), warning
,
564 QMessageBox::Ok
| QMessageBox::Abort
, QMessageBox::Abort
)
565 == QMessageBox::Abort
)
567 logger
->addItem(tr("Aborted!"), LOGERROR
);
568 logger
->setFinished();
574 RockboxInfo
rbinfo(RbSettings::value(RbSettings::Mountpoint
).toString());
575 if(rbinfo
.version() != "")
577 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
578 tr("Rockbox installation detected. Do you want to backup first?"),
579 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
581 logger
->addItem(tr("Starting backup..."),LOGINFO
);
582 QString backupName
= RbSettings::value(RbSettings::Mountpoint
).toString()
583 + "/.backup/rockbox-backup-" + rbinfo
.version() + ".zip";
585 //! create dir, if it doesnt exist
586 QFileInfo
backupFile(backupName
);
587 if(!QDir(backupFile
.path()).exists())
590 a
.mkpath(backupFile
.path());
595 connect(&backup
,SIGNAL(zipProgress(int,int)),logger
, SLOT(setProgress(int,int)));
596 if(backup
.createZip(backupName
,
597 RbSettings::value(RbSettings::Mountpoint
).toString() + "/.rockbox") == Zip::Ok
)
599 logger
->addItem(tr("Backup successful"),LOGOK
);
603 logger
->addItem(tr("Backup failed!"),LOGERROR
);
604 logger
->setFinished();
610 //! install current build
611 ZipInstaller
* installer
= new ZipInstaller(this);
612 installer
->setUrl(file
);
613 installer
->setLogSection("Rockbox (Base)");
614 installer
->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
615 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
616 installer
->setCache(true);
617 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
619 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
620 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
621 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
622 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
623 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
624 installer
->install();
629 void RbUtilQt::install()
631 InstallWindow
*installWindow
= new InstallWindow(this);
632 installWindow
->show();
635 bool RbUtilQt::installBootloaderAuto()
641 void RbUtilQt::installBootloaderBtn()
643 if(chkConfig(true)) return;
644 if(QMessageBox::question(this, tr("Confirm Installation"),
645 tr("Do you really want to install the Bootloader?"),
646 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
649 logger
= new ProgressLoggerGui(this);
654 void RbUtilQt::installBootloader()
656 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
657 QString backupDestination
= "";
661 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
662 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
664 logger
->addItem(tr("No install method known."), LOGERROR
);
665 logger
->setFinished();
669 // set bootloader filename. Do this now as installed() needs it.
670 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
671 QStringList blfilepath
;
672 for(int a
= 0; a
< blfile
.size(); a
++) {
673 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
676 bl
->setBlFile(blfilepath
);
677 QUrl
url(SystemInfo::value(SystemInfo::BootloaderUrl
).toString()
678 + SystemInfo::value(SystemInfo::CurBootloaderName
).toString());
680 bl
->setLogfile(RbSettings::value(RbSettings::Mountpoint
).toString()
681 + "/.rockbox/rbutil.log");
683 if(bl
->installed() == BootloaderInstallBase::BootloaderRockbox
) {
684 if(QMessageBox::question(this, tr("Bootloader detected"),
685 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
686 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
) {
688 // keep logger open for auto installs.
689 // don't consider abort as error in auto-mode.
690 logger
->addItem(tr("Bootloader installation skipped"), LOGINFO
);
691 installBootloaderPost(false);
695 installBootloaderPost(true);
701 else if(bl
->installed() == BootloaderInstallBase::BootloaderOther
702 && bl
->capabilities() & BootloaderInstallBase::Backup
)
704 QString targetFolder
= SystemInfo::value(SystemInfo::CurPlatformName
).toString()
705 + " Firmware Backup";
706 // remove invalid character(s)
707 targetFolder
.remove(QRegExp("[:/]"));
708 if(QMessageBox::question(this, tr("Create Bootloader backup"),
709 tr("You can create a backup of the original bootloader "
710 "file. Press \"Yes\" to select an output folder on your "
711 "computer to save the file to. The file will get placed "
712 "in a new folder \"%1\" created below the selected folder.\n"
713 "Press \"No\" to skip this step.").arg(targetFolder
),
714 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
) {
715 backupDestination
= QFileDialog::getExistingDirectory(this,
716 tr("Browse backup folder"), QDir::homePath());
717 if(!backupDestination
.isEmpty())
718 backupDestination
+= "/" + targetFolder
;
720 qDebug() << "[RbUtil] backing up to" << backupDestination
;
721 // backup needs to be done after the logger has been set up.
725 if(bl
->capabilities() & BootloaderInstallBase::NeedsOf
)
728 ret
= QMessageBox::information(this, tr("Prerequisites"),
729 bl
->ofHint(),QMessageBox::Ok
| QMessageBox::Abort
);
730 if(ret
!= QMessageBox::Ok
) {
731 // consider aborting an error to close window / abort automatic
734 logger
->addItem(tr("Bootloader installation aborted"), LOGINFO
);
735 logger
->setFinished();
738 // open dialog to browse to of file
740 offile
= QFileDialog::getOpenFileName(this,
741 tr("Select firmware file"), QDir::homePath());
742 if(!QFileInfo(offile
).isReadable()) {
743 logger
->addItem(tr("Error opening firmware file"), LOGERROR
);
744 logger
->setFinished();
748 bl
->setOfFile(offile
);
751 // the bootloader install class does NOT use any GUI stuff.
752 // All messages are passed via signals.
753 connect(bl
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
754 connect(bl
, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
755 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
756 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
759 if(!backupDestination
.isEmpty()) {
760 if(!bl
->backup(backupDestination
)) {
761 if(QMessageBox::warning(this, tr("Backup error"),
762 tr("Could not create backup file. Continue?"),
763 QMessageBox::No
| QMessageBox::Yes
)
764 == QMessageBox::No
) {
765 logger
->setFinished();
773 void RbUtilQt::installBootloaderPost(bool error
)
775 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error
;
776 // if an error occured don't perform post install steps.
785 // end here if automated install
789 QString msg
= BootloaderInstallBase::postinstallHints(
790 RbSettings::value(RbSettings::Platform
).toString());
792 QMessageBox::information(this, tr("Manual steps required"), msg
);
798 void RbUtilQt::installFontsBtn()
800 if(chkConfig(true)) return;
801 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
802 RockboxInfo
installInfo(mountpoint
);
803 if(installInfo
.revision().isEmpty() && installInfo
.release().isEmpty()) {
804 QMessageBox::critical(this, tr("No Rockbox installation found"),
805 tr("Could not determine the installed Rockbox version. "
806 "Please install a Rockbox build before installing "
810 if(QMessageBox::question(this, tr("Confirm Installation"),
811 tr("Do you really want to install the fonts package?"),
812 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
814 logger
= new ProgressLoggerGui(this);
819 bool RbUtilQt::installFontsAuto()
826 void RbUtilQt::installFonts()
828 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
829 RockboxInfo
installInfo(mountpoint
);
832 QString relversion
= installInfo
.release();
833 if(relversion
.isEmpty()) {
834 // release is empty for non-release versions (i.e. daily / current)
835 fontsurl
= SystemInfo::value(SystemInfo::DailyFontUrl
).toString();
836 logversion
= installInfo
.revision();
839 fontsurl
= SystemInfo::value(SystemInfo::ReleaseFontUrl
).toString();
840 logversion
= installInfo
.release();
842 fontsurl
.replace("%RELEASEVER%", relversion
);
844 // create zip installer
845 installer
= new ZipInstaller(this);
846 installer
->setUrl(fontsurl
);
847 installer
->setLogSection("Fonts");
848 installer
->setLogVersion(logversion
);
849 installer
->setMountPoint(mountpoint
);
850 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
851 installer
->setCache(true);
853 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
854 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
855 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
856 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
857 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
858 installer
->install();
862 void RbUtilQt::installVoice()
864 if(chkConfig(true)) return;
866 if(m_gotInfo
== false)
868 QMessageBox::warning(this, tr("Warning"),
869 tr("The Application is still downloading Information about new Builds."
870 " Please try again shortly."));
874 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
875 RockboxInfo
installInfo(mountpoint
);
879 QString relversion
= installInfo
.release();
880 // if no version is found abort.
881 if(installInfo
.revision().isEmpty() && relversion
.isEmpty()) {
882 QMessageBox::critical(this, tr("No Rockbox installation found"),
883 tr("Could not determine the installed Rockbox version. "
884 "Please install a Rockbox build before installing "
888 if(relversion
.isEmpty()) {
889 // release is empty for non-release versions (i.e. daily / current)
890 voiceurl
= SystemInfo::value(SystemInfo::DailyVoiceUrl
).toString();
891 logversion
= installInfo
.revision();
894 voiceurl
= SystemInfo::value(SystemInfo::ReleaseVoiceUrl
).toString();
895 logversion
= installInfo
.release();
897 if(QMessageBox::question(this, tr("Confirm Installation"),
898 tr("Do you really want to install the voice file?"),
899 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
902 QDate date
= QDate::fromString(
903 ServerInfo::value(ServerInfo::DailyDate
).toString(), Qt::ISODate
);
904 QString model
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
905 // replace placeholder in voice url
906 voiceurl
.replace("%DATE%", date
.toString("yyyyMMdd"));
907 voiceurl
.replace("%MODEL%", model
);
908 voiceurl
.replace("%RELVERSION%", relversion
);
910 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
913 logger
= new ProgressLoggerGui(this);
915 // create zip installer
916 installer
= new ZipInstaller(this);
918 installer
->setUrl(voiceurl
);
919 installer
->setLogSection("Voice");
920 installer
->setLogVersion(logversion
);
921 installer
->setMountPoint(mountpoint
);
922 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
923 installer
->setCache(true);
924 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
925 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
926 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
927 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
928 installer
->install();
932 void RbUtilQt::installDoomBtn()
934 if(chkConfig(true)) return;
936 QMessageBox::critical(this, tr("Error"),
937 tr("Your device doesn't have a doom plugin. Aborting."));
941 if(QMessageBox::question(this, tr("Confirm Installation"),
942 tr("Do you really want to install the game addon files?"),
943 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
945 logger
= new ProgressLoggerGui(this);
950 bool RbUtilQt::installDoomAuto()
956 bool RbUtilQt::hasDoom()
958 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
959 +"/.rockbox/rocks/games/doom.rock");
960 return doomrock
.exists();
963 void RbUtilQt::installDoom()
965 // create zip installer
966 installer
= new ZipInstaller(this);
968 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
969 installer
->setLogSection("Game Addons");
970 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
971 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
972 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
973 installer
->setCache(true);
974 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
975 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
976 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
977 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
978 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
979 installer
->install();
983 void RbUtilQt::installThemes()
985 if(chkConfig(true)) return;
986 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
991 void RbUtilQt::createTalkFiles(void)
993 if(chkConfig(true)) return;
994 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
995 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
996 installWindow
->show();
1000 void RbUtilQt::createVoiceFile(void)
1002 if(chkConfig(true)) return;
1003 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
1005 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1006 installWindow
->show();
1009 void RbUtilQt::uninstall(void)
1011 if(chkConfig(true)) return;
1012 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
1013 uninstallWindow
->show();
1017 void RbUtilQt::uninstallBootloader(void)
1019 if(chkConfig(true)) return;
1020 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
1021 tr("Do you really want to uninstall the Bootloader?"),
1022 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
1024 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1025 logger
->setProgressVisible(false);
1028 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1031 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
1032 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
1035 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
1036 logger
->setFinished();
1039 if( (bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0)
1041 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target."
1042 "Try a normal firmware update to remove the booloader."), LOGERROR
);
1043 logger
->setFinished();
1048 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1049 QStringList blfilepath
;
1050 for(int a
= 0; a
< blfile
.size(); a
++) {
1051 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1054 bl
->setBlFile(blfilepath
);
1056 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1057 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1060 result
= bl
->uninstall();
1062 logger
->setFinished();
1067 void RbUtilQt::downloadManual(void)
1069 if(chkConfig(true)) return;
1070 if(QMessageBox::question(this, tr("Confirm download"),
1071 tr("Do you really want to download the manual? The manual will be saved "
1072 "to the root folder of your player."),
1073 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1076 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
1077 if(manual
.isEmpty())
1079 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
1081 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
1086 if(ui
.radioPdf
->isChecked()) {
1087 target
= "/" + manual
+ ".pdf";
1088 section
= "Manual (PDF)";
1091 target
= "/" + manual
+ "-" + date
.toString("yyyyMMdd") + "-html.zip";
1092 section
= "Manual (HTML)";
1094 manualurl
= SystemInfo::value(SystemInfo::ManualUrl
).toString() + "/" + target
;
1095 qDebug() << "[RbUtil] Manual URL:" << manualurl
;
1097 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1099 installer
= new ZipInstaller(this);
1100 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
1101 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
1102 installer
->setCache(true);
1103 installer
->setLogSection(section
);
1104 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
1105 installer
->setUrl(manualurl
);
1106 installer
->setUnzip(false);
1107 installer
->setTarget(target
);
1108 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1109 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1110 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
1111 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
1112 installer
->install();
1116 void RbUtilQt::installPortable(void)
1118 if(QMessageBox::question(this, tr("Confirm installation"),
1119 tr("Do you really want to install Rockbox Utility to your player? "
1120 "After installation you can run it from the players hard drive."),
1121 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1124 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1125 logger
->setProgressMax(0);
1126 logger
->setProgressValue(0);
1128 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1131 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1132 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1133 logger
->setFinished();
1137 // remove old files first.
1138 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1139 + "/RockboxUtility.exe");
1140 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1141 + "/RockboxUtility.ini");
1142 // copy currently running binary and currently used settings file
1143 if(!QFile::copy(qApp
->applicationFilePath(),
1144 RbSettings::value(RbSettings::Mountpoint
).toString()
1145 + "/RockboxUtility.exe")) {
1146 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1147 logger
->setFinished();
1150 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1151 if(!QFile::copy(RbSettings::userSettingFilename(),
1152 RbSettings::value(RbSettings::Mountpoint
).toString()
1153 + "/RockboxUtility.ini")) {
1154 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1155 logger
->setFinished();
1158 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1159 logger
->setFinished();
1160 logger
->setProgressMax(1);
1161 logger
->setProgressValue(1);
1166 void RbUtilQt::updateInfo()
1168 qDebug() << "[RbUtil] updating server info";
1170 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
1171 QSettings
log(mp
+ "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
1172 QStringList groups
= log
.childGroups();
1173 QList
<QTreeWidgetItem
*> items
;
1174 QTreeWidgetItem
*w
, *w2
;
1178 // remove old list entries (if any)
1179 int l
= ui
.treeInfo
->topLevelItemCount();
1182 m
= ui
.treeInfo
->takeTopLevelItem(l
);
1183 // delete childs (single level deep, no recursion here)
1184 int n
= m
->childCount();
1188 // get and populate new items
1189 for(int a
= 0; a
< groups
.size(); a
++) {
1190 log
.beginGroup(groups
.at(a
));
1191 QStringList keys
= log
.allKeys();
1192 w
= new QTreeWidgetItem
;
1193 w
->setFlags(Qt::ItemIsEnabled
);
1194 w
->setText(0, groups
.at(a
));
1196 // get minimum and maximum version information so we can hilight old files
1197 min
= max
= log
.value(keys
.at(0)).toString();
1198 for(int b
= 0; b
< keys
.size(); b
++) {
1199 if(log
.value(keys
.at(b
)).toString() > max
)
1200 max
= log
.value(keys
.at(b
)).toString();
1201 if(log
.value(keys
.at(b
)).toString() < min
)
1202 min
= log
.value(keys
.at(b
)).toString();
1205 for(int b
= 0; b
< keys
.size(); b
++) {
1207 file
= mp
+ "/" + keys
.at(b
);
1208 if(QFileInfo(file
).isDir())
1210 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
1211 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
1212 if(log
.value(keys
.at(b
)).toString() != max
) {
1213 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
1214 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
1221 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
1223 w
->setData(1, Qt::DisplayRole
, max
);
1225 ui
.treeInfo
->insertTopLevelItems(0, items
);
1226 ui
.treeInfo
->resizeColumnToContents(0);
1230 QUrl
RbUtilQt::proxy()
1232 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1233 return QUrl(RbSettings::value(RbSettings::Proxy
).toString());
1234 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1235 return System::systemProxy();
1240 bool RbUtilQt::chkConfig(bool warn
)
1243 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1244 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1245 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1248 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1249 tr("Your configuration is invalid. Please go to the configuration "
1250 "dialog and make sure the selected values are correct."));
1255 void RbUtilQt::checkUpdate(void)
1257 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1258 #if defined(Q_OS_WIN32)
1260 #elif defined(Q_OS_LINUX)
1262 #elif defined(Q_OS_MACX)
1266 update
= new HttpGet(this);
1267 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1268 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1269 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1270 update
->setCache(true);
1272 ui
.statusbar
->showMessage(tr("Checking for update ..."));
1273 update
->getFile(QUrl(url
));
1276 void RbUtilQt::downloadUpdateDone(bool error
)
1279 qDebug() << "[RbUtil] network error:" << update
->error();
1282 QString
toParse(update
->readAll());
1284 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1285 QStringList rbutilList
;
1287 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1289 rbutilList
<< searchString
.cap(1);
1290 pos
+= searchString
.matchedLength();
1292 qDebug() << "[Checkupdate] " << rbutilList
;
1294 QString newVersion
= "";
1295 //check if there is a binary with higher version in this list
1296 for(int i
=0; i
< rbutilList
.size(); i
++)
1298 #if defined(Q_OS_LINUX)
1299 #if defined(__amd64__)
1300 //skip if it isnt a 64bit build
1301 if( !rbutilList
.at(i
).contains("64bit"))
1304 //skip if it is a 64bit build
1305 if(rbutilList
.at(i
).contains("64bit"))
1309 //check if it is newer, and remember newest
1310 if(Utils::compareVersionStrings(VERSION
, rbutilList
.at(i
)) == 1)
1312 if(Utils::compareVersionStrings(newVersion
, rbutilList
.at(i
)) == 1)
1314 newVersion
= rbutilList
.at(i
);
1319 // if we found something newer, display info
1320 if(newVersion
!= "")
1322 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1323 #if defined(Q_OS_WIN32)
1325 #elif defined(Q_OS_LINUX)
1327 #elif defined(Q_OS_MACX)
1332 QMessageBox::information(this,tr("RockboxUtility Update available"),
1333 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1334 "Download it from here: <a href='%1'>%2</a>").arg(url
).arg(newVersion
) );
1335 ui
.statusbar
->showMessage(tr("New version of Rockbox Utility available."));
1338 ui
.statusbar
->showMessage(tr("Rockbox Utility is up to date."), 5000);