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 if(QMessageBox::question(this, tr("Confirm Installation"),
802 tr("Do you really want to install the fonts package?"),
803 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
805 logger
= new ProgressLoggerGui(this);
810 bool RbUtilQt::installFontsAuto()
817 void RbUtilQt::installFonts()
819 // create zip installer
820 installer
= new ZipInstaller(this);
822 installer
->setUrl(SystemInfo::value(SystemInfo::FontUrl
).toString());
823 installer
->setLogSection("Fonts");
824 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
825 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
826 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
827 installer
->setCache(true);
829 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
830 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
831 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
832 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
833 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
834 installer
->install();
838 void RbUtilQt::installVoice()
840 if(chkConfig(true)) return;
842 if(m_gotInfo
== false)
844 QMessageBox::warning(this, tr("Warning"),
845 tr("The Application is still downloading Information about new Builds."
846 " Please try again shortly."));
850 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
851 RockboxInfo
installInfo(mountpoint
);
855 QString relversion
= installInfo
.release();
856 // if no version is found abort.
857 if(installInfo
.revision().isEmpty() && relversion
.isEmpty()) {
858 QMessageBox::critical(this, tr("No Rockbox installation found"),
859 tr("Could not determine the installed Rockbox version. "
860 "Please install a Rockbox build before installing "
864 if(relversion
.isEmpty()) {
865 // release is empty for non-release versions (i.e. daily / current)
866 voiceurl
= SystemInfo::value(SystemInfo::DailyVoiceUrl
).toString();
867 logversion
= installInfo
.revision();
870 voiceurl
= SystemInfo::value(SystemInfo::ReleaseVoiceUrl
).toString();
871 logversion
= installInfo
.release();
873 if(QMessageBox::question(this, tr("Confirm Installation"),
874 tr("Do you really want to install the voice file?"),
875 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
878 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
879 QString model
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
880 // replace placeholder in voice url
881 voiceurl
.replace("%DATE%", date
.toString("yyyyMMdd"));
882 voiceurl
.replace("%MODEL%", model
);
883 voiceurl
.replace("%RELVERSION%", relversion
);
885 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
888 logger
= new ProgressLoggerGui(this);
890 // create zip installer
891 installer
= new ZipInstaller(this);
893 installer
->setUrl(voiceurl
);
894 installer
->setLogSection("Voice");
895 installer
->setLogVersion(logversion
);
896 installer
->setMountPoint(mountpoint
);
897 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
898 installer
->setCache(true);
899 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
900 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
901 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
902 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
903 installer
->install();
907 void RbUtilQt::installDoomBtn()
909 if(chkConfig(true)) return;
911 QMessageBox::critical(this, tr("Error"),
912 tr("Your device doesn't have a doom plugin. Aborting."));
916 if(QMessageBox::question(this, tr("Confirm Installation"),
917 tr("Do you really want to install the game addon files?"),
918 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
920 logger
= new ProgressLoggerGui(this);
925 bool RbUtilQt::installDoomAuto()
931 bool RbUtilQt::hasDoom()
933 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
934 +"/.rockbox/rocks/games/doom.rock");
935 return doomrock
.exists();
938 void RbUtilQt::installDoom()
940 // create zip installer
941 installer
= new ZipInstaller(this);
943 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
944 installer
->setLogSection("Game Addons");
945 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
946 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
947 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
948 installer
->setCache(true);
949 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
950 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
951 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
952 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
953 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
954 installer
->install();
958 void RbUtilQt::installThemes()
960 if(chkConfig(true)) return;
961 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
966 void RbUtilQt::createTalkFiles(void)
968 if(chkConfig(true)) return;
969 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
970 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
971 installWindow
->show();
975 void RbUtilQt::createVoiceFile(void)
977 if(chkConfig(true)) return;
978 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
980 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
981 installWindow
->show();
984 void RbUtilQt::uninstall(void)
986 if(chkConfig(true)) return;
987 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
988 uninstallWindow
->show();
992 void RbUtilQt::uninstallBootloader(void)
994 if(chkConfig(true)) return;
995 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
996 tr("Do you really want to uninstall the Bootloader?"),
997 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
999 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1000 logger
->setProgressVisible(false);
1003 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1006 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
1007 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
1010 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
1011 logger
->setFinished();
1014 if( (bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0)
1016 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target."
1017 "Try a normal firmware update to remove the booloader."), LOGERROR
);
1018 logger
->setFinished();
1023 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1024 QStringList blfilepath
;
1025 for(int a
= 0; a
< blfile
.size(); a
++) {
1026 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1029 bl
->setBlFile(blfilepath
);
1031 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1032 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1035 result
= bl
->uninstall();
1037 logger
->setFinished();
1042 void RbUtilQt::downloadManual(void)
1044 if(chkConfig(true)) return;
1045 if(QMessageBox::question(this, tr("Confirm download"),
1046 tr("Do you really want to download the manual? The manual will be saved "
1047 "to the root folder of your player."),
1048 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1051 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
1052 if(manual
.isEmpty())
1054 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
1056 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
1061 if(ui
.radioPdf
->isChecked()) {
1062 target
= "/" + manual
+ ".pdf";
1063 section
= "Manual (PDF)";
1066 target
= "/" + manual
+ "-" + date
.toString("yyyyMMdd") + "-html.zip";
1067 section
= "Manual (HTML)";
1069 manualurl
= SystemInfo::value(SystemInfo::ManualUrl
).toString() + "/" + target
;
1070 qDebug() << "[RbUtil] Manual URL:" << manualurl
;
1072 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1074 installer
= new ZipInstaller(this);
1075 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
1076 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
1077 installer
->setCache(true);
1078 installer
->setLogSection(section
);
1079 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
1080 installer
->setUrl(manualurl
);
1081 installer
->setUnzip(false);
1082 installer
->setTarget(target
);
1083 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1084 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1085 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
1086 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
1087 installer
->install();
1091 void RbUtilQt::installPortable(void)
1093 if(QMessageBox::question(this, tr("Confirm installation"),
1094 tr("Do you really want to install Rockbox Utility to your player? "
1095 "After installation you can run it from the players hard drive."),
1096 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1099 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1100 logger
->setProgressMax(0);
1101 logger
->setProgressValue(0);
1103 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1106 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1107 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1108 logger
->setFinished();
1112 // remove old files first.
1113 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1114 + "/RockboxUtility.exe");
1115 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1116 + "/RockboxUtility.ini");
1117 // copy currently running binary and currently used settings file
1118 if(!QFile::copy(qApp
->applicationFilePath(),
1119 RbSettings::value(RbSettings::Mountpoint
).toString()
1120 + "/RockboxUtility.exe")) {
1121 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1122 logger
->setFinished();
1125 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1126 if(!QFile::copy(RbSettings::userSettingFilename(),
1127 RbSettings::value(RbSettings::Mountpoint
).toString()
1128 + "/RockboxUtility.ini")) {
1129 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1130 logger
->setFinished();
1133 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1134 logger
->setFinished();
1135 logger
->setProgressMax(1);
1136 logger
->setProgressValue(1);
1141 void RbUtilQt::updateInfo()
1143 qDebug() << "[RbUtil] updating server info";
1145 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
1146 QSettings
log(mp
+ "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
1147 QStringList groups
= log
.childGroups();
1148 QList
<QTreeWidgetItem
*> items
;
1149 QTreeWidgetItem
*w
, *w2
;
1153 // remove old list entries (if any)
1154 int l
= ui
.treeInfo
->topLevelItemCount();
1157 m
= ui
.treeInfo
->takeTopLevelItem(l
);
1158 // delete childs (single level deep, no recursion here)
1159 int n
= m
->childCount();
1163 // get and populate new items
1164 for(int a
= 0; a
< groups
.size(); a
++) {
1165 log
.beginGroup(groups
.at(a
));
1166 QStringList keys
= log
.allKeys();
1167 w
= new QTreeWidgetItem
;
1168 w
->setFlags(Qt::ItemIsEnabled
);
1169 w
->setText(0, groups
.at(a
));
1171 // get minimum and maximum version information so we can hilight old files
1172 min
= max
= log
.value(keys
.at(0)).toString();
1173 for(int b
= 0; b
< keys
.size(); b
++) {
1174 if(log
.value(keys
.at(b
)).toString() > max
)
1175 max
= log
.value(keys
.at(b
)).toString();
1176 if(log
.value(keys
.at(b
)).toString() < min
)
1177 min
= log
.value(keys
.at(b
)).toString();
1180 for(int b
= 0; b
< keys
.size(); b
++) {
1182 file
= mp
+ "/" + keys
.at(b
);
1183 if(QFileInfo(file
).isDir())
1185 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
1186 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
1187 if(log
.value(keys
.at(b
)).toString() != max
) {
1188 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
1189 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
1196 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
1198 w
->setData(1, Qt::DisplayRole
, max
);
1200 ui
.treeInfo
->insertTopLevelItems(0, items
);
1201 ui
.treeInfo
->resizeColumnToContents(0);
1205 QUrl
RbUtilQt::proxy()
1207 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1208 return QUrl(RbSettings::value(RbSettings::Proxy
).toString());
1209 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1210 return System::systemProxy();
1215 bool RbUtilQt::chkConfig(bool warn
)
1218 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1219 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1220 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1223 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1224 tr("Your configuration is invalid. Please go to the configuration "
1225 "dialog and make sure the selected values are correct."));
1230 void RbUtilQt::checkUpdate(void)
1232 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1233 #if defined(Q_OS_WIN32)
1235 #elif defined(Q_OS_LINUX)
1237 #elif defined(Q_OS_MACX)
1241 update
= new HttpGet(this);
1242 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1243 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1244 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1245 update
->setCache(true);
1247 update
->getFile(QUrl(url
));
1250 void RbUtilQt::downloadUpdateDone(bool error
)
1253 qDebug() << "[RbUtil] network error:" << update
->error();
1256 QString
toParse(update
->readAll());
1258 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1259 QStringList rbutilList
;
1261 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1263 rbutilList
<< searchString
.cap(1);
1264 pos
+= searchString
.matchedLength();
1266 qDebug() << "[Checkupdate] " << rbutilList
;
1268 QString newVersion
="";
1269 //check if there is a binary with higher version in this list
1270 for(int i
=0; i
< rbutilList
.size(); i
++)
1272 #if defined(Q_OS_LINUX)
1273 #if defined(__amd64__)
1274 //skip if it isnt a 64bit build
1275 if( !rbutilList
.at(i
).contains("64bit"))
1278 //skip if it is a 64bit build
1279 if(rbutilList
.at(i
).contains("64bit"))
1283 //check if it is newer, and remember newest
1284 if(newerVersion(VERSION
,rbutilList
.at(i
)))
1286 if(newVersion
== "" || newerVersion(newVersion
,rbutilList
.at(i
)))
1288 newVersion
= rbutilList
.at(i
);
1293 // if we found something newer, display info
1294 if(newVersion
!= "")
1296 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1297 #if defined(Q_OS_WIN32)
1299 #elif defined(Q_OS_LINUX)
1301 #elif defined(Q_OS_MACX)
1306 QMessageBox::information(this,tr("RockboxUtility Update available"),
1307 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1308 "Download it from here: <a href='%1'>%2</a>").arg(url
).arg(newVersion
) );
1313 bool RbUtilQt::newerVersion(QString versionOld
,QString versionNew
)
1315 QRegExp
chars("\\d*(\\D)");
1317 //strip non-number from beginning
1318 versionOld
= versionOld
.remove(0,versionOld
.indexOf(QRegExp("\\d")));
1319 versionNew
= versionNew
.remove(0,versionNew
.indexOf(QRegExp("\\d")));
1321 // split versions by "."
1322 QStringList versionListOld
= versionOld
.split(".");
1323 QStringList versionListNew
= versionNew
.split(".");
1325 QStringListIterator
iteratorOld(versionListOld
);
1326 QStringListIterator
iteratorNew(versionListNew
);
1328 //check every section
1329 while(iteratorOld
.hasNext() && iteratorNew
.hasNext())
1331 QString newPart
= iteratorNew
.next();
1332 QString oldPart
= iteratorOld
.next();
1333 QString newPartChar
= "", oldPartChar
= "";
1334 int newPartInt
= 0, oldPartInt
=0;
1336 //convert to int, if it contains chars, put into seperated variable
1337 if(newPart
.contains(chars
))
1339 newPartChar
= chars
.cap(1);
1340 newPart
= newPart
.remove(newPartChar
);
1342 newPartInt
= newPart
.toInt();
1343 //convert to int, if it contains chars, put into seperated variable
1344 if(oldPart
.contains(chars
))
1346 oldPartChar
= chars
.cap(1);
1347 oldPart
= oldPart
.remove(oldPartChar
);
1349 oldPartInt
= oldPart
.toInt();
1351 if(newPartInt
> oldPartInt
) // this section int is higher -> true
1353 else if(newPartInt
< oldPartInt
) //this section int is lower -> false
1355 else if(newPartChar
> oldPartChar
) //ints are the same, chars is higher -> true
1357 else if(newPartChar
< oldPartChar
) //ints are the same, chars is lower -> false
1359 //all the same, next section
1361 // all the same -> false