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"
38 #include "rbsettings.h"
39 #include "serverinfo.h"
40 #include "systeminfo.h"
42 #include "progressloggerinterface.h"
44 #include "bootloaderinstallbase.h"
45 #include "bootloaderinstallmi4.h"
46 #include "bootloaderinstallhex.h"
47 #include "bootloaderinstallipod.h"
48 #include "bootloaderinstallsansa.h"
49 #include "bootloaderinstallfile.h"
50 #include "bootloaderinstallchinachip.h"
51 #include "bootloaderinstallams.h"
52 #include "bootloaderinstalltcc.h"
55 #if defined(Q_OS_LINUX)
58 #if defined(Q_OS_WIN32)
67 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
70 qDebug() << "======================================";
71 qDebug() << "[System] Rockbox Utility " VERSION
;
72 qDebug() << "[System] Qt version:" << qVersion();
73 qDebug() << "======================================";
75 absolutePath
= qApp
->applicationDirPath();
77 HttpGet::setGlobalUserAgent("rbutil/"VERSION
);
78 // init startup & autodetection
86 ui
.radioPdf
->setChecked(true);
89 ui
.treeInfo
->setAlternatingRowColors(true);
90 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
91 ui
.treeInfo
->expandAll();
92 ui
.treeInfo
->setColumnCount(2);
93 ui
.treeInfo
->setLayoutDirection(Qt::LeftToRight
);
94 // disable quick install until version info is available
95 ui
.buttonSmall
->setEnabled(false);
96 ui
.buttonComplete
->setEnabled(false);
97 ui
.actionSmall_Installation
->setEnabled(false);
98 ui
.actionComplete_Installation
->setEnabled(false);
100 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
101 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
102 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
103 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
104 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
105 connect(ui
.actionE_xit
, SIGNAL(triggered()), this, SLOT(shutdown()));
106 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
107 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
108 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
109 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
110 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
111 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
112 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
113 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
114 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
115 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
116 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
117 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
118 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
119 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
121 // actions accessible from the menu
122 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
123 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
124 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
125 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
126 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
127 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
128 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
129 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
130 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
131 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
132 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
133 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
134 connect(ui
.action_System_Info
, SIGNAL(triggered()), this, SLOT(sysinfo()));
135 connect(ui
.action_Trace
, SIGNAL(triggered()), this, SLOT(trace()));
138 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
140 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
146 void RbUtilQt::shutdown(void)
148 // restore default message handler to prevent trace accesses during
149 // object destruction -- the trace object could already be destroyed.
150 // Fixes segfaults on exit.
151 qInstallMsgHandler(0);
157 void RbUtilQt::trace(void)
163 void RbUtilQt::sysinfo(void)
169 void RbUtilQt::updateTabs(int count
)
181 void RbUtilQt::downloadInfo()
183 // try to get the current build information
184 daily
= new HttpGet(this);
185 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
186 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
187 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
188 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
189 daily
->setCache(true);
191 daily
->setCache(false);
192 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
193 qDebug() << "[RbUtil] downloading build info";
194 daily
->setFile(&buildInfo
);
195 daily
->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl
).toString()));
199 void RbUtilQt::downloadDone(bool error
)
202 qDebug() << "[RbUtil] network error:" << daily
->error();
203 ui
.statusbar
->showMessage(tr("Can't get version information!"));
204 QMessageBox::critical(this, tr("Network error"),
205 tr("Can't get version information."));
208 qDebug() << "[RbUtil] network status:" << daily
->error();
210 // read info into ServerInfo object
212 ServerInfo::readBuildInfo(buildInfo
.fileName());
215 //start bleeding info download
216 bleeding
= new HttpGet(this);
217 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
218 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
219 connect(qApp
, SIGNAL(lastWindowClosed()), bleeding
, SLOT(abort()));
220 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
221 bleeding
->setCache(true);
222 bleeding
->setFile(&bleedingInfo
);
223 bleeding
->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo
).toString()));
224 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
229 void RbUtilQt::downloadBleedingDone(bool error
)
232 qDebug() << "[RbUtil] network error:" << bleeding
->error();
236 ServerInfo::readBleedingInfo(bleedingInfo
.fileName());
237 bleedingInfo
.close();
239 ui
.statusbar
->showMessage(tr("Download build information finished."), 5000);
243 //start check for updates
249 void RbUtilQt::downloadDone(int id
, bool error
)
252 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
253 .arg(daily
->errorString());
255 QMessageBox::about(this, "Network Error", errorString
);
256 m_networkerror
= daily
->errorString();
258 qDebug() << "[RbUtil] downloadDone:" << id
<< "error:" << error
;
262 void RbUtilQt::about()
264 QDialog
*window
= new QDialog(this);
266 about
.setupUi(window
);
267 window
->setLayoutDirection(Qt::LeftToRight
);
268 window
->setModal(true);
270 QFile
licence(":/docs/gpl-2.0.html");
271 licence
.open(QIODevice::ReadOnly
);
272 QTextStream
c(&licence
);
273 QString cline
= c
.readAll();
274 about
.browserLicense
->insertHtml(cline
);
275 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
276 QFile
credits(":/docs/CREDITS");
277 credits
.open(QIODevice::ReadOnly
);
278 QTextStream
r(&credits
);
279 r
.setCodec(QTextCodec::codecForName("UTF-8"));
281 QString line
= r
.readLine();
282 // filter out header.
283 line
.remove(QRegExp("^[^A-Z]+.*"));
284 line
.remove(QRegExp("^People.*"));
285 about
.browserCredits
->append(line
);
287 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
288 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION
);
289 about
.labelTitle
->setText(title
);
296 void RbUtilQt::help()
298 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
299 QDesktopServices::openUrl(helpurl
);
303 void RbUtilQt::configDialog()
305 Config
*cw
= new Config(this);
306 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
311 void RbUtilQt::updateSettings()
313 qDebug() << "[RbUtil] updating current settings";
316 if(RbSettings::value(RbSettings::ProxyType
) == "system") {
317 HttpGet::setGlobalProxy(System::systemProxy());
319 else if(RbSettings::value(RbSettings::ProxyType
) == "manual") {
320 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy
).toString());
323 HttpGet::setGlobalProxy(QUrl(""));
325 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath
).toString());
326 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline
).toBool());
328 if(RbSettings::value(RbSettings::RbutilVersion
) != PUREVERSION
) {
329 QApplication::processEvents();
330 QMessageBox::information(this, tr("New installation"),
331 tr("This is a new installation of Rockbox Utility, or a new version. "
332 "The configuration dialog will now open to allow you to setup the program, "
333 " or review your settings."));
336 else if(chkConfig(false)) {
337 QApplication::processEvents();
338 QMessageBox::critical(this, tr("Configuration error"),
339 tr("Your configuration is invalid. This is most likely due "
340 "to a changed device path. The configuration dialog will "
341 "now open to allow you to correct the problem."));
347 void RbUtilQt::updateDevice()
349 /* TODO: We should check the flags of the bootloaderinstall classes, and not
350 * just check if its != none or != "fwpatcher" */
352 /* Enable bootloader installation, if possible */
353 bool bootloaderInstallable
=
354 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none";
355 ui
.buttonBootloader
->setEnabled(bootloaderInstallable
);
356 ui
.labelBootloader
->setEnabled(bootloaderInstallable
);
357 ui
.actionInstall_Bootloader
->setEnabled(bootloaderInstallable
);
359 /* Enable bootloader uninstallation, if possible */
360 bool bootloaderUninstallable
= bootloaderInstallable
&&
361 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "fwpatcher";
362 ui
.labelRemoveBootloader
->setEnabled(bootloaderUninstallable
);
363 ui
.buttonRemoveBootloader
->setEnabled(bootloaderUninstallable
);
364 ui
.actionRemove_bootloader
->setEnabled(bootloaderUninstallable
);
366 /* Disable the whole tab widget if configuration is invalid */
367 bool configurationValid
= !chkConfig(false);
368 ui
.tabWidget
->setEnabled(configurationValid
);
369 ui
.menuA_ctions
->setEnabled(configurationValid
);
371 // displayed device info
372 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
373 QString brand
= SystemInfo::value(SystemInfo::CurBrand
).toString();
374 QString name
= SystemInfo::value(SystemInfo::CurName
).toString() +
375 " (" + ServerInfo::value(ServerInfo::CurStatus
).toString() + ")";
376 if(name
.isEmpty()) name
= "<none>";
377 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
378 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
379 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
381 // hide quickstart buttons if no release available
382 bool installable
= !ServerInfo::value(ServerInfo::CurReleaseVersion
).toString().isEmpty();
383 ui
.buttonSmall
->setEnabled(installable
);
384 ui
.buttonComplete
->setEnabled(installable
);
385 ui
.actionSmall_Installation
->setEnabled(installable
);
386 ui
.actionComplete_Installation
->setEnabled(installable
);
390 void RbUtilQt::updateManual()
392 if(RbSettings::value(RbSettings::Platform
) != "")
394 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
398 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
400 pdfmanual
= SystemInfo::value(SystemInfo::ManualUrl
).toString()
401 + "/" + manual
+ ".pdf";
403 htmlmanual
= SystemInfo::value(SystemInfo::ManualUrl
).toString()
404 + "/" + manual
+ "/rockbox-build.html";
405 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
407 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
411 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
412 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
413 .arg("http://www.rockbox.org/manual.shtml"));
418 void RbUtilQt::completeInstall()
420 if(chkConfig(true)) return;
421 if(QMessageBox::question(this, tr("Confirm Installation"),
422 tr("Do you really want to perform a complete installation?\n\n"
423 "This will install Rockbox %1. To install the most recent "
424 "development build available press \"Cancel\" and "
425 "use the \"Installation\" tab.")
426 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
427 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
430 logger
= new ProgressLoggerGui(this);
433 if(smallInstallInner())
435 logger
->setRunning();
439 if(!installFontsAuto())
443 // wait for installation finished
445 QApplication::processEvents();
448 logger
->setRunning();
455 if(!installDoomAuto())
459 // wait for installation finished
461 QApplication::processEvents();
468 // it has its own logger window,so close our.
474 void RbUtilQt::smallInstall()
476 if(chkConfig(true)) return;
477 if(QMessageBox::question(this, tr("Confirm Installation"),
478 tr("Do you really want to perform a minimal installation? "
479 "A minimal installation will contain only the absolutely "
480 "necessary parts to run Rockbox.\n\n"
481 "This will install Rockbox %1. To install the most recent "
482 "development build available press \"Cancel\" and "
483 "use the \"Installation\" tab.")
484 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
485 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
489 logger
= new ProgressLoggerGui(this);
495 bool RbUtilQt::smallInstallInner()
497 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
498 // show dialog with error if mount point is wrong
499 if(!QFileInfo(mountpoint
).isDir()) {
500 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
501 logger
->setFinished();
505 if(SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none")
510 if(!installBootloaderAuto()) {
511 logger
->setFinished();
516 // wait for boot loader installation finished
518 QApplication::processEvents();
521 if(m_error
) return true;
522 logger
->setRunning();
532 // wait for installation finished
534 QApplication::processEvents();
537 installBootloaderPost(false);
541 void RbUtilQt::installdone(bool error
)
543 qDebug() << "[RbUtil] install done";
548 void RbUtilQt::installBtn()
550 if(chkConfig(true)) return;
554 bool RbUtilQt::installAuto()
556 QString file
= SystemInfo::value(SystemInfo::ReleaseUrl
).toString();
557 file
.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel
).toString());
558 file
.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
560 // check installed Version and Target
561 QString warning
= check(false);
562 if(!warning
.isEmpty())
564 if(QMessageBox::warning(this, tr("Really continue?"), warning
,
565 QMessageBox::Ok
| QMessageBox::Abort
, QMessageBox::Abort
)
566 == QMessageBox::Abort
)
568 logger
->addItem(tr("Aborted!"), LOGERROR
);
569 logger
->setFinished();
575 RockboxInfo
rbinfo(RbSettings::value(RbSettings::Mountpoint
).toString());
576 if(rbinfo
.version() != "")
578 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
579 tr("Rockbox installation detected. Do you want to backup first?"),
580 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
582 logger
->addItem(tr("Starting backup..."),LOGINFO
);
583 QString backupName
= RbSettings::value(RbSettings::Mountpoint
).toString()
584 + "/.backup/rockbox-backup-" + rbinfo
.version() + ".zip";
586 //! create dir, if it doesnt exist
587 QFileInfo
backupFile(backupName
);
588 if(!QDir(backupFile
.path()).exists())
591 a
.mkpath(backupFile
.path());
596 connect(&backup
,SIGNAL(zipProgress(int,int)),logger
, SLOT(setProgress(int,int)));
597 if(backup
.createZip(backupName
,
598 RbSettings::value(RbSettings::Mountpoint
).toString() + "/.rockbox") == Zip::Ok
)
600 logger
->addItem(tr("Backup successful"),LOGOK
);
604 logger
->addItem(tr("Backup failed!"),LOGERROR
);
605 logger
->setFinished();
611 //! install current build
612 ZipInstaller
* installer
= new ZipInstaller(this);
613 installer
->setUrl(file
);
614 installer
->setLogSection("Rockbox (Base)");
615 installer
->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
616 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
617 installer
->setCache(true);
618 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
620 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
621 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
622 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
623 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
624 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
625 installer
->install();
630 void RbUtilQt::install()
632 InstallWindow
*installWindow
= new InstallWindow(this);
633 installWindow
->show();
636 bool RbUtilQt::installBootloaderAuto()
642 void RbUtilQt::installBootloaderBtn()
644 if(chkConfig(true)) return;
645 if(QMessageBox::question(this, tr("Confirm Installation"),
646 tr("Do you really want to install the Bootloader?"),
647 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
650 logger
= new ProgressLoggerGui(this);
655 void RbUtilQt::installBootloader()
657 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
658 QString backupDestination
= "";
662 BootloaderInstallBase
*bl
;
663 QString type
= SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString();
665 bl
= new BootloaderInstallMi4(this);
667 else if(type
== "hex") {
668 bl
= new BootloaderInstallHex(this);
670 else if(type
== "sansa") {
671 bl
= new BootloaderInstallSansa(this);
673 else if(type
== "ipod") {
674 bl
= new BootloaderInstallIpod(this);
676 else if(type
== "file") {
677 bl
= new BootloaderInstallFile(this);
679 else if(type
== "chinachip") {
680 bl
= new BootloaderInstallChinaChip(this);
682 else if(type
== "ams") {
683 bl
= new BootloaderInstallAms(this);
685 else if(type
== "tcc") {
686 bl
= new BootloaderInstallTcc(this);
689 logger
->addItem(tr("No install method known."), LOGERROR
);
690 logger
->setFinished();
694 // set bootloader filename. Do this now as installed() needs it.
695 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
696 QStringList blfilepath
;
697 for(int a
= 0; a
< blfile
.size(); a
++) {
698 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
701 bl
->setBlFile(blfilepath
);
702 QUrl
url(SystemInfo::value(SystemInfo::BootloaderUrl
).toString()
703 + SystemInfo::value(SystemInfo::CurBootloaderName
).toString());
705 bl
->setLogfile(RbSettings::value(RbSettings::Mountpoint
).toString()
706 + "/.rockbox/rbutil.log");
708 if(bl
->installed() == BootloaderInstallBase::BootloaderRockbox
) {
709 if(QMessageBox::question(this, tr("Bootloader detected"),
710 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
711 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
) {
713 // keep logger open for auto installs.
714 // don't consider abort as error in auto-mode.
715 logger
->addItem(tr("Bootloader installation skipped"), LOGINFO
);
716 installBootloaderPost(false);
720 installBootloaderPost(true);
726 else if(bl
->installed() == BootloaderInstallBase::BootloaderOther
727 && bl
->capabilities() & BootloaderInstallBase::Backup
)
729 QString targetFolder
= SystemInfo::value(SystemInfo::CurPlatformName
).toString()
730 + " Firmware Backup";
731 // remove invalid character(s)
732 targetFolder
.remove(QRegExp("[:/]"));
733 if(QMessageBox::question(this, tr("Create Bootloader backup"),
734 tr("You can create a backup of the original bootloader "
735 "file. Press \"Yes\" to select an output folder on your "
736 "computer to save the file to. The file will get placed "
737 "in a new folder \"%1\" created below the selected folder.\n"
738 "Press \"No\" to skip this step.").arg(targetFolder
),
739 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
) {
740 backupDestination
= QFileDialog::getExistingDirectory(this,
741 tr("Browse backup folder"), QDir::homePath());
742 if(!backupDestination
.isEmpty())
743 backupDestination
+= "/" + targetFolder
;
745 qDebug() << "[RbUtil] backing up to" << backupDestination
;
746 // backup needs to be done after the logger has been set up.
750 if(bl
->capabilities() & BootloaderInstallBase::NeedsOf
)
753 ret
= QMessageBox::information(this, tr("Prerequisites"),
754 bl
->ofHint(),QMessageBox::Ok
| QMessageBox::Abort
);
755 if(ret
!= QMessageBox::Ok
) {
756 // consider aborting an error to close window / abort automatic
759 logger
->addItem(tr("Bootloader installation aborted"), LOGINFO
);
760 logger
->setFinished();
763 // open dialog to browse to of file
765 offile
= QFileDialog::getOpenFileName(this,
766 tr("Select firmware file"), QDir::homePath());
767 if(!QFileInfo(offile
).isReadable()) {
768 logger
->addItem(tr("Error opening firmware file"), LOGERROR
);
769 logger
->setFinished();
773 bl
->setOfFile(offile
);
776 // the bootloader install class does NOT use any GUI stuff.
777 // All messages are passed via signals.
778 connect(bl
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
779 connect(bl
, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
780 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
781 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
784 if(!backupDestination
.isEmpty()) {
785 if(!bl
->backup(backupDestination
)) {
786 if(QMessageBox::warning(this, tr("Backup error"),
787 tr("Could not create backup file. Continue?"),
788 QMessageBox::No
| QMessageBox::Yes
)
789 == QMessageBox::No
) {
790 logger
->setFinished();
798 void RbUtilQt::installBootloaderPost(bool error
)
800 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error
;
801 // if an error occured don't perform post install steps.
810 // end here if automated install
814 QString msg
= BootloaderInstallBase::postinstallHints(
815 RbSettings::value(RbSettings::Platform
).toString());
817 QMessageBox::information(this, tr("Manual steps required"), msg
);
823 void RbUtilQt::installFontsBtn()
825 if(chkConfig(true)) return;
826 if(QMessageBox::question(this, tr("Confirm Installation"),
827 tr("Do you really want to install the fonts package?"),
828 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
830 logger
= new ProgressLoggerGui(this);
835 bool RbUtilQt::installFontsAuto()
842 void RbUtilQt::installFonts()
844 // create zip installer
845 installer
= new ZipInstaller(this);
847 installer
->setUrl(SystemInfo::value(SystemInfo::FontUrl
).toString());
848 installer
->setLogSection("Fonts");
849 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
850 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
851 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
852 installer
->setCache(true);
854 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
855 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
856 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
857 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
858 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
859 installer
->install();
863 void RbUtilQt::installVoice()
865 if(chkConfig(true)) return;
867 if(m_gotInfo
== false)
869 QMessageBox::warning(this, tr("Warning"),
870 tr("The Application is still downloading Information about new Builds."
871 " Please try again shortly."));
875 if(QMessageBox::question(this, tr("Confirm Installation"),
876 tr("Do you really want to install the voice file?"),
877 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
879 logger
= new ProgressLoggerGui(this);
882 // create zip installer
883 installer
= new ZipInstaller(this);
885 QString voiceurl
= SystemInfo::value(SystemInfo::VoiceUrl
).toString();
886 QDate date
= QDate::fromString(ServerInfo::value(ServerInfo::DailyDate
).toString(),Qt::ISODate
);
887 voiceurl
+= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString() + "-" +
888 date
.toString("yyyyMMdd") + "-english.zip";
889 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
891 installer
->setUrl(voiceurl
);
892 installer
->setLogSection("Voice");
893 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
894 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
895 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
896 installer
->setCache(true);
897 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
898 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
899 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
900 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
901 installer
->install();
905 void RbUtilQt::installDoomBtn()
907 if(chkConfig(true)) return;
909 QMessageBox::critical(this, tr("Error"),
910 tr("Your device doesn't have a doom plugin. Aborting."));
914 if(QMessageBox::question(this, tr("Confirm Installation"),
915 tr("Do you really want to install the game addon files?"),
916 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
918 logger
= new ProgressLoggerGui(this);
923 bool RbUtilQt::installDoomAuto()
929 bool RbUtilQt::hasDoom()
931 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
932 +"/.rockbox/rocks/games/doom.rock");
933 return doomrock
.exists();
936 void RbUtilQt::installDoom()
938 // create zip installer
939 installer
= new ZipInstaller(this);
941 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
942 installer
->setLogSection("Game Addons");
943 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
944 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
945 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
946 installer
->setCache(true);
947 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
948 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
949 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
950 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
951 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
952 installer
->install();
956 void RbUtilQt::installThemes()
958 if(chkConfig(true)) return;
959 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
964 void RbUtilQt::createTalkFiles(void)
966 if(chkConfig(true)) return;
967 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
968 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
969 installWindow
->show();
973 void RbUtilQt::createVoiceFile(void)
975 if(chkConfig(true)) return;
976 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
978 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
979 installWindow
->show();
982 void RbUtilQt::uninstall(void)
984 if(chkConfig(true)) return;
985 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
986 uninstallWindow
->show();
990 void RbUtilQt::uninstallBootloader(void)
992 if(chkConfig(true)) return;
993 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
994 tr("Do you really want to uninstall the Bootloader?"),
995 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
997 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
998 logger
->setProgressVisible(false);
1001 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1004 BootloaderInstallBase
*bl
;
1005 QString type
= SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString();
1007 bl
= new BootloaderInstallMi4(this);
1009 else if(type
== "hex") {
1010 bl
= new BootloaderInstallHex(this);
1012 else if(type
== "sansa") {
1013 bl
= new BootloaderInstallSansa(this);
1015 else if(type
== "ipod") {
1016 bl
= new BootloaderInstallIpod(this);
1018 else if(type
== "file") {
1019 bl
= new BootloaderInstallFile(this);
1022 logger
->addItem(tr("No uninstall method known."), LOGERROR
);
1023 logger
->setFinished();
1027 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1028 QStringList blfilepath
;
1029 for(int a
= 0; a
< blfile
.size(); a
++) {
1030 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1033 bl
->setBlFile(blfilepath
);
1035 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1036 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1039 result
= bl
->uninstall();
1041 logger
->setFinished();
1046 void RbUtilQt::downloadManual(void)
1048 if(chkConfig(true)) return;
1049 if(QMessageBox::question(this, tr("Confirm download"),
1050 tr("Do you really want to download the manual? The manual will be saved "
1051 "to the root folder of your player."),
1052 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1055 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
1056 if(manual
.isEmpty())
1058 + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
1060 QString date
= ServerInfo::value(ServerInfo::DailyDate
).toString();
1065 if(ui
.radioPdf
->isChecked()) {
1066 target
= "/" + manual
+ ".pdf";
1067 section
= "Manual (PDF)";
1070 target
= "/" + manual
+ "-" + date
+ "-html.zip";
1071 section
= "Manual (HTML)";
1073 manualurl
= SystemInfo::value(SystemInfo::ManualUrl
).toString() + "/" + target
;
1074 qDebug() << "[RbUtil] Manual URL:" << manualurl
;
1076 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1078 installer
= new ZipInstaller(this);
1079 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
1080 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
1081 installer
->setCache(true);
1082 installer
->setLogSection(section
);
1083 installer
->setLogVersion(date
);
1084 installer
->setUrl(manualurl
);
1085 installer
->setUnzip(false);
1086 installer
->setTarget(target
);
1087 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1088 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1089 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
1090 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
1091 installer
->install();
1095 void RbUtilQt::installPortable(void)
1097 if(QMessageBox::question(this, tr("Confirm installation"),
1098 tr("Do you really want to install Rockbox Utility to your player? "
1099 "After installation you can run it from the players hard drive."),
1100 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1103 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1104 logger
->setProgressMax(0);
1105 logger
->setProgressValue(0);
1107 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1110 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1111 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1112 logger
->setFinished();
1116 // remove old files first.
1117 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1118 + "/RockboxUtility.exe");
1119 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1120 + "/RockboxUtility.ini");
1121 // copy currently running binary and currently used settings file
1122 if(!QFile::copy(qApp
->applicationFilePath(),
1123 RbSettings::value(RbSettings::Mountpoint
).toString()
1124 + "/RockboxUtility.exe")) {
1125 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1126 logger
->setFinished();
1129 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1130 if(!QFile::copy(RbSettings::userSettingFilename(),
1131 RbSettings::value(RbSettings::Mountpoint
).toString()
1132 + "/RockboxUtility.ini")) {
1133 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1134 logger
->setFinished();
1137 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1138 logger
->setFinished();
1139 logger
->setProgressMax(1);
1140 logger
->setProgressValue(1);
1145 void RbUtilQt::updateInfo()
1147 qDebug() << "[RbUtil] updating server info";
1149 QSettings
log(RbSettings::value(RbSettings::Mountpoint
).toString()
1150 + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
1151 QStringList groups
= log
.childGroups();
1152 QList
<QTreeWidgetItem
*> items
;
1153 QTreeWidgetItem
*w
, *w2
;
1157 // remove old list entries (if any)
1158 int l
= ui
.treeInfo
->topLevelItemCount();
1161 m
= ui
.treeInfo
->takeTopLevelItem(l
);
1162 // delete childs (single level deep, no recursion here)
1163 int n
= m
->childCount();
1167 // get and populate new items
1168 for(int a
= 0; a
< groups
.size(); a
++) {
1169 log
.beginGroup(groups
.at(a
));
1170 QStringList keys
= log
.allKeys();
1171 w
= new QTreeWidgetItem
;
1172 w
->setFlags(Qt::ItemIsEnabled
);
1173 w
->setText(0, groups
.at(a
));
1175 // get minimum and maximum version information so we can hilight old files
1176 min
= max
= log
.value(keys
.at(0)).toString();
1177 for(int b
= 0; b
< keys
.size(); b
++) {
1178 if(log
.value(keys
.at(b
)).toString() > max
)
1179 max
= log
.value(keys
.at(b
)).toString();
1180 if(log
.value(keys
.at(b
)).toString() < min
)
1181 min
= log
.value(keys
.at(b
)).toString();
1184 for(int b
= 0; b
< keys
.size(); b
++) {
1186 file
= RbSettings::value(RbSettings::Mountpoint
).toString() + "/" + keys
.at(b
);
1187 if(QFileInfo(file
).isDir())
1189 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
1190 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
1191 if(log
.value(keys
.at(b
)).toString() != max
) {
1192 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
1193 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
1200 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
1202 w
->setData(1, Qt::DisplayRole
, max
);
1204 ui
.treeInfo
->insertTopLevelItems(0, items
);
1205 ui
.treeInfo
->resizeColumnToContents(0);
1209 QUrl
RbUtilQt::proxy()
1211 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1212 return QUrl(RbSettings::value(RbSettings::Proxy
).toString());
1213 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1214 return System::systemProxy();
1219 bool RbUtilQt::chkConfig(bool warn
)
1222 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1223 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1224 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1227 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1228 tr("Your configuration is invalid. Please go to the configuration "
1229 "dialog and make sure the selected values are correct."));
1234 void RbUtilQt::checkUpdate(void)
1236 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1237 #if defined(Q_OS_WIN32)
1239 #elif defined(Q_OS_LINUX)
1241 #elif defined(Q_OS_MACX)
1245 update
= new HttpGet(this);
1246 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1247 connect(update
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
1248 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1249 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1250 update
->setCache(true);
1252 update
->getFile(QUrl(url
));
1255 void RbUtilQt::downloadUpdateDone(bool error
)
1258 qDebug() << "[RbUtil] network error:" << update
->error();
1261 QString
toParse(update
->readAll());
1263 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1264 QStringList rbutilList
;
1266 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1268 rbutilList
<< searchString
.cap(1);
1269 pos
+= searchString
.matchedLength();
1271 qDebug() << "[Checkupdate] " << rbutilList
;
1273 QString newVersion
="";
1274 //check if there is a binary with higher version in this list
1275 for(int i
=0; i
< rbutilList
.size(); i
++)
1277 #if defined(Q_OS_LINUX)
1278 #if defined(__amd64__)
1279 //skip if it isnt a 64bit build
1280 if( !rbutilList
.at(i
).contains("64bit"))
1283 //skip if it is a 64bit build
1284 if(rbutilList
.at(i
).contains("64bit"))
1288 //check if it is newer, and remember newest
1289 if(newerVersion(VERSION
,rbutilList
.at(i
)))
1291 if(newVersion
== "" || newerVersion(newVersion
,rbutilList
.at(i
)))
1293 newVersion
= rbutilList
.at(i
);
1298 // if we found something newer, display info
1299 if(newVersion
!= "")
1301 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1302 #if defined(Q_OS_WIN32)
1304 #elif defined(Q_OS_LINUX)
1306 #elif defined(Q_OS_MACX)
1311 QMessageBox::information(this,tr("RockboxUtility Update available"),
1312 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1313 "Download it from here: <a href='%1'>%2</a>").arg(url
).arg(newVersion
) );
1318 bool RbUtilQt::newerVersion(QString versionOld
,QString versionNew
)
1320 QRegExp
chars("\\d*(\\D)");
1322 //strip non-number from beginning
1323 versionOld
= versionOld
.remove(0,versionOld
.indexOf(QRegExp("\\d")));
1324 versionNew
= versionNew
.remove(0,versionNew
.indexOf(QRegExp("\\d")));
1326 // split versions by "."
1327 QStringList versionListOld
= versionOld
.split(".");
1328 QStringList versionListNew
= versionNew
.split(".");
1330 QStringListIterator
iteratorOld(versionListOld
);
1331 QStringListIterator
iteratorNew(versionListNew
);
1333 //check every section
1334 while(iteratorOld
.hasNext() && iteratorNew
.hasNext())
1336 QString newPart
= iteratorNew
.next();
1337 QString oldPart
= iteratorOld
.next();
1338 QString newPartChar
= "", oldPartChar
= "";
1339 int newPartInt
= 0, oldPartInt
=0;
1341 //convert to int, if it contains chars, put into seperated variable
1342 if(newPart
.contains(chars
))
1344 newPartChar
= chars
.cap(1);
1345 newPart
= newPart
.remove(newPartChar
);
1347 newPartInt
= newPart
.toInt();
1348 //convert to int, if it contains chars, put into seperated variable
1349 if(oldPart
.contains(chars
))
1351 oldPartChar
= chars
.cap(1);
1352 oldPart
= oldPart
.remove(oldPartChar
);
1354 oldPartInt
= oldPart
.toInt();
1356 if(newPartInt
> oldPartInt
) // this section int is higher -> true
1358 else if(newPartInt
< oldPartInt
) //this section int is lower -> false
1360 else if(newPartChar
> oldPartChar
) //ints are the same, chars is higher -> true
1362 else if(newPartChar
< oldPartChar
) //ints are the same, chars is lower -> false
1364 //all the same, next section
1366 // all the same -> false