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"
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 if(QMessageBox::question(this, tr("Confirm Installation"),
851 tr("Do you really want to install the voice file?"),
852 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
854 logger
= new ProgressLoggerGui(this);
857 // create zip installer
858 installer
= new ZipInstaller(this);
860 QString voiceurl
= SystemInfo::value(SystemInfo::VoiceUrl
).toString();
861 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
862 voiceurl
+= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString() + "-" +
863 date
.toString("yyyyMMdd") + "-english.zip";
864 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
866 installer
->setUrl(voiceurl
);
867 installer
->setLogSection("Voice");
868 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
869 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
870 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
871 installer
->setCache(true);
872 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
873 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
874 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
875 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
876 installer
->install();
880 void RbUtilQt::installDoomBtn()
882 if(chkConfig(true)) return;
884 QMessageBox::critical(this, tr("Error"),
885 tr("Your device doesn't have a doom plugin. Aborting."));
889 if(QMessageBox::question(this, tr("Confirm Installation"),
890 tr("Do you really want to install the game addon files?"),
891 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
893 logger
= new ProgressLoggerGui(this);
898 bool RbUtilQt::installDoomAuto()
904 bool RbUtilQt::hasDoom()
906 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
907 +"/.rockbox/rocks/games/doom.rock");
908 return doomrock
.exists();
911 void RbUtilQt::installDoom()
913 // create zip installer
914 installer
= new ZipInstaller(this);
916 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
917 installer
->setLogSection("Game Addons");
918 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
919 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
920 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
921 installer
->setCache(true);
922 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
923 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
924 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
925 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
926 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
927 installer
->install();
931 void RbUtilQt::installThemes()
933 if(chkConfig(true)) return;
934 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
939 void RbUtilQt::createTalkFiles(void)
941 if(chkConfig(true)) return;
942 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
943 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
944 installWindow
->show();
948 void RbUtilQt::createVoiceFile(void)
950 if(chkConfig(true)) return;
951 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
953 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
954 installWindow
->show();
957 void RbUtilQt::uninstall(void)
959 if(chkConfig(true)) return;
960 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
961 uninstallWindow
->show();
965 void RbUtilQt::uninstallBootloader(void)
967 if(chkConfig(true)) return;
968 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
969 tr("Do you really want to uninstall the Bootloader?"),
970 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
972 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
973 logger
->setProgressVisible(false);
976 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
979 BootloaderInstallBase
*bl
= BootloaderInstallBase::createBootloaderInstaller(this,
980 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
983 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
984 logger
->setFinished();
987 if( (bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0)
989 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target."
990 "Try a normal firmware update to remove the booloader."), LOGERROR
);
991 logger
->setFinished();
996 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
997 QStringList blfilepath
;
998 for(int a
= 0; a
< blfile
.size(); a
++) {
999 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1002 bl
->setBlFile(blfilepath
);
1004 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1005 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1008 result
= bl
->uninstall();
1010 logger
->setFinished();
1015 void RbUtilQt::downloadManual(void)
1017 if(chkConfig(true)) return;
1018 if(QMessageBox::question(this, tr("Confirm download"),
1019 tr("Do you really want to download the manual? The manual will be saved "
1020 "to the root folder of your player."),
1021 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1024 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
1025 if(manual
.isEmpty())
1027 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
1029 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
1034 if(ui
.radioPdf
->isChecked()) {
1035 target
= "/" + manual
+ ".pdf";
1036 section
= "Manual (PDF)";
1039 target
= "/" + manual
+ "-" + date
.toString("yyyyMMdd") + "-html.zip";
1040 section
= "Manual (HTML)";
1042 manualurl
= SystemInfo::value(SystemInfo::ManualUrl
).toString() + "/" + target
;
1043 qDebug() << "[RbUtil] Manual URL:" << manualurl
;
1045 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1047 installer
= new ZipInstaller(this);
1048 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
1049 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
1050 installer
->setCache(true);
1051 installer
->setLogSection(section
);
1052 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
1053 installer
->setUrl(manualurl
);
1054 installer
->setUnzip(false);
1055 installer
->setTarget(target
);
1056 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1057 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1058 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
1059 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
1060 installer
->install();
1064 void RbUtilQt::installPortable(void)
1066 if(QMessageBox::question(this, tr("Confirm installation"),
1067 tr("Do you really want to install Rockbox Utility to your player? "
1068 "After installation you can run it from the players hard drive."),
1069 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1072 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1073 logger
->setProgressMax(0);
1074 logger
->setProgressValue(0);
1076 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1079 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1080 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1081 logger
->setFinished();
1085 // remove old files first.
1086 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1087 + "/RockboxUtility.exe");
1088 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1089 + "/RockboxUtility.ini");
1090 // copy currently running binary and currently used settings file
1091 if(!QFile::copy(qApp
->applicationFilePath(),
1092 RbSettings::value(RbSettings::Mountpoint
).toString()
1093 + "/RockboxUtility.exe")) {
1094 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1095 logger
->setFinished();
1098 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1099 if(!QFile::copy(RbSettings::userSettingFilename(),
1100 RbSettings::value(RbSettings::Mountpoint
).toString()
1101 + "/RockboxUtility.ini")) {
1102 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1103 logger
->setFinished();
1106 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1107 logger
->setFinished();
1108 logger
->setProgressMax(1);
1109 logger
->setProgressValue(1);
1114 void RbUtilQt::updateInfo()
1116 qDebug() << "[RbUtil] updating server info";
1118 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
1119 QSettings
log(mp
+ "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
1120 QStringList groups
= log
.childGroups();
1121 QList
<QTreeWidgetItem
*> items
;
1122 QTreeWidgetItem
*w
, *w2
;
1126 // remove old list entries (if any)
1127 int l
= ui
.treeInfo
->topLevelItemCount();
1130 m
= ui
.treeInfo
->takeTopLevelItem(l
);
1131 // delete childs (single level deep, no recursion here)
1132 int n
= m
->childCount();
1136 // get and populate new items
1137 for(int a
= 0; a
< groups
.size(); a
++) {
1138 log
.beginGroup(groups
.at(a
));
1139 QStringList keys
= log
.allKeys();
1140 w
= new QTreeWidgetItem
;
1141 w
->setFlags(Qt::ItemIsEnabled
);
1142 w
->setText(0, groups
.at(a
));
1144 // get minimum and maximum version information so we can hilight old files
1145 min
= max
= log
.value(keys
.at(0)).toString();
1146 for(int b
= 0; b
< keys
.size(); b
++) {
1147 if(log
.value(keys
.at(b
)).toString() > max
)
1148 max
= log
.value(keys
.at(b
)).toString();
1149 if(log
.value(keys
.at(b
)).toString() < min
)
1150 min
= log
.value(keys
.at(b
)).toString();
1153 for(int b
= 0; b
< keys
.size(); b
++) {
1155 file
= mp
+ "/" + keys
.at(b
);
1156 if(QFileInfo(file
).isDir())
1158 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
1159 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
1160 if(log
.value(keys
.at(b
)).toString() != max
) {
1161 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
1162 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
1169 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
1171 w
->setData(1, Qt::DisplayRole
, max
);
1173 ui
.treeInfo
->insertTopLevelItems(0, items
);
1174 ui
.treeInfo
->resizeColumnToContents(0);
1178 QUrl
RbUtilQt::proxy()
1180 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1181 return QUrl(RbSettings::value(RbSettings::Proxy
).toString());
1182 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1183 return System::systemProxy();
1188 bool RbUtilQt::chkConfig(bool warn
)
1191 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1192 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1193 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1196 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1197 tr("Your configuration is invalid. Please go to the configuration "
1198 "dialog and make sure the selected values are correct."));
1203 void RbUtilQt::checkUpdate(void)
1205 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1206 #if defined(Q_OS_WIN32)
1208 #elif defined(Q_OS_LINUX)
1210 #elif defined(Q_OS_MACX)
1214 update
= new HttpGet(this);
1215 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1216 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1217 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1218 update
->setCache(true);
1220 update
->getFile(QUrl(url
));
1223 void RbUtilQt::downloadUpdateDone(bool error
)
1226 qDebug() << "[RbUtil] network error:" << update
->error();
1229 QString
toParse(update
->readAll());
1231 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1232 QStringList rbutilList
;
1234 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1236 rbutilList
<< searchString
.cap(1);
1237 pos
+= searchString
.matchedLength();
1239 qDebug() << "[Checkupdate] " << rbutilList
;
1241 QString newVersion
="";
1242 //check if there is a binary with higher version in this list
1243 for(int i
=0; i
< rbutilList
.size(); i
++)
1245 #if defined(Q_OS_LINUX)
1246 #if defined(__amd64__)
1247 //skip if it isnt a 64bit build
1248 if( !rbutilList
.at(i
).contains("64bit"))
1251 //skip if it is a 64bit build
1252 if(rbutilList
.at(i
).contains("64bit"))
1256 //check if it is newer, and remember newest
1257 if(newerVersion(VERSION
,rbutilList
.at(i
)))
1259 if(newVersion
== "" || newerVersion(newVersion
,rbutilList
.at(i
)))
1261 newVersion
= rbutilList
.at(i
);
1266 // if we found something newer, display info
1267 if(newVersion
!= "")
1269 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1270 #if defined(Q_OS_WIN32)
1272 #elif defined(Q_OS_LINUX)
1274 #elif defined(Q_OS_MACX)
1279 QMessageBox::information(this,tr("RockboxUtility Update available"),
1280 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1281 "Download it from here: <a href='%1'>%2</a>").arg(url
).arg(newVersion
) );
1286 bool RbUtilQt::newerVersion(QString versionOld
,QString versionNew
)
1288 QRegExp
chars("\\d*(\\D)");
1290 //strip non-number from beginning
1291 versionOld
= versionOld
.remove(0,versionOld
.indexOf(QRegExp("\\d")));
1292 versionNew
= versionNew
.remove(0,versionNew
.indexOf(QRegExp("\\d")));
1294 // split versions by "."
1295 QStringList versionListOld
= versionOld
.split(".");
1296 QStringList versionListNew
= versionNew
.split(".");
1298 QStringListIterator
iteratorOld(versionListOld
);
1299 QStringListIterator
iteratorNew(versionListNew
);
1301 //check every section
1302 while(iteratorOld
.hasNext() && iteratorNew
.hasNext())
1304 QString newPart
= iteratorNew
.next();
1305 QString oldPart
= iteratorOld
.next();
1306 QString newPartChar
= "", oldPartChar
= "";
1307 int newPartInt
= 0, oldPartInt
=0;
1309 //convert to int, if it contains chars, put into seperated variable
1310 if(newPart
.contains(chars
))
1312 newPartChar
= chars
.cap(1);
1313 newPart
= newPart
.remove(newPartChar
);
1315 newPartInt
= newPart
.toInt();
1316 //convert to int, if it contains chars, put into seperated variable
1317 if(oldPart
.contains(chars
))
1319 oldPartChar
= chars
.cap(1);
1320 oldPart
= oldPart
.remove(oldPartChar
);
1322 oldPartInt
= oldPart
.toInt();
1324 if(newPartInt
> oldPartInt
) // this section int is higher -> true
1326 else if(newPartInt
< oldPartInt
) //this section int is lower -> false
1328 else if(newPartChar
> oldPartChar
) //ints are the same, chars is higher -> true
1330 else if(newPartChar
< oldPartChar
) //ints are the same, chars is lower -> false
1332 //all the same, next section
1334 // all the same -> false