summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/rbutilqt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/rbutilqt.cpp')
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp279
1 files changed, 202 insertions, 77 deletions
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index ea1ec59de0..4f0e4b5994 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -28,15 +28,22 @@
28#include "installtalkwindow.h" 28#include "installtalkwindow.h"
29#include "createvoicewindow.h" 29#include "createvoicewindow.h"
30#include "httpget.h" 30#include "httpget.h"
31#include "installbootloader.h"
32#include "installthemes.h" 31#include "installthemes.h"
33#include "uninstallwindow.h" 32#include "uninstallwindow.h"
34#include "browseof.h"
35#include "utils.h" 33#include "utils.h"
36#include "rbzip.h" 34#include "rbzip.h"
37#include "sysinfo.h" 35#include "sysinfo.h"
38#include "detect.h" 36#include "detect.h"
39 37
38#include "progressloggerinterface.h"
39
40#include "bootloaderinstallbase.h"
41#include "bootloaderinstallmi4.h"
42#include "bootloaderinstallhex.h"
43#include "bootloaderinstallipod.h"
44#include "bootloaderinstallsansa.h"
45#include "bootloaderinstallfile.h"
46
40#if defined(Q_OS_LINUX) 47#if defined(Q_OS_LINUX)
41#include <stdio.h> 48#include <stdio.h>
42#endif 49#endif
@@ -52,17 +59,19 @@
52RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) 59RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
53{ 60{
54 absolutePath = qApp->applicationDirPath(); 61 absolutePath = qApp->applicationDirPath();
55 62
56 ui.setupUi(this);
57
58 settings = new RbSettings(); 63 settings = new RbSettings();
59 settings->open(); 64 settings->open();
60 HttpGet::setGlobalUserAgent("rbutil/"VERSION); 65 HttpGet::setGlobalUserAgent("rbutil/"VERSION);
66 // init startup & autodetection
67 ui.setupUi(this);
68 updateSettings();
69 downloadInfo();
61 70
62 m_gotInfo = false; 71 m_gotInfo = false;
63 72 m_auto = false;
73
64 // manual tab 74 // manual tab
65 updateSettings();
66 ui.radioPdf->setChecked(true); 75 ui.radioPdf->setChecked(true);
67 76
68 // info tab 77 // info tab
@@ -112,10 +121,6 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
112 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable())); 121 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
113#endif 122#endif
114 123
115 initIpodpatcher();
116 initSansapatcher();
117 downloadInfo();
118
119} 124}
120 125
121 126
@@ -158,6 +163,8 @@ void RbUtilQt::downloadDone(bool error)
158{ 163{
159 if(error) { 164 if(error) {
160 qDebug() << "network error:" << daily->error(); 165 qDebug() << "network error:" << daily->error();
166 QMessageBox::critical(this, tr("Network error"),
167 tr("Can't get version information."));
161 return; 168 return;
162 } 169 }
163 qDebug() << "network status:" << daily->error(); 170 qDebug() << "network status:" << daily->error();
@@ -218,8 +225,9 @@ void RbUtilQt::downloadDone(int id, bool error)
218 .arg(daily->errorString()); 225 .arg(daily->errorString());
219 if(error) { 226 if(error) {
220 QMessageBox::about(this, "Network Error", errorString); 227 QMessageBox::about(this, "Network Error", errorString);
228 m_networkerror = daily->errorString();
221 } 229 }
222 qDebug() << "downloadDone:" << id << error; 230 qDebug() << "downloadDone:" << id << "error:" << error;
223} 231}
224 232
225 233
@@ -428,6 +436,7 @@ bool RbUtilQt::smallInstallInner()
428 { 436 {
429 m_error = false; 437 m_error = false;
430 m_installed = false; 438 m_installed = false;
439 m_auto = true;
431 if(!installBootloaderAuto()) 440 if(!installBootloaderAuto())
432 return true; 441 return true;
433 else 442 else
@@ -436,6 +445,7 @@ bool RbUtilQt::smallInstallInner()
436 while(!m_installed) 445 while(!m_installed)
437 QApplication::processEvents(); 446 QApplication::processEvents();
438 } 447 }
448 m_auto = false;
439 if(m_error) return true; 449 if(m_error) return true;
440 logger->undoAbort(); 450 logger->undoAbort();
441 } 451 }
@@ -452,6 +462,7 @@ bool RbUtilQt::smallInstallInner()
452 QApplication::processEvents(); 462 QApplication::processEvents();
453 } 463 }
454 464
465 installBootloaderPost(false);
455 return false; 466 return false;
456} 467}
457 468
@@ -580,82 +591,167 @@ void RbUtilQt::installBootloaderBtn()
580 591
581 // create logger 592 // create logger
582 logger = new ProgressLoggerGui(this); 593 logger = new ProgressLoggerGui(this);
583 logger->show(); 594
584
585 installBootloader(); 595 installBootloader();
586} 596}
587 597
588void RbUtilQt::installBootloader() 598void RbUtilQt::installBootloader()
589{ 599{
590 QString platform = settings->curPlatform(); 600 QString platform = settings->curPlatform();
601 QString backupDestination = "";
602 m_error = false;
591 603
592 // create installer 604 // create installer
593 blinstaller = new BootloaderInstaller(this); 605 BootloaderInstallBase *bl;
594 606 QString type = settings->curBootloaderMethod();
595 blinstaller->setMountPoint(settings->mountpoint()); 607 if(type == "mi4") {
596 608 bl = new BootloaderInstallMi4(this);
597 blinstaller->setDevice(platform); 609 }
598 blinstaller->setBootloaderMethod(settings->curBootloaderMethod()); 610 else if(type == "hex") {
599 blinstaller->setBootloaderName(settings->curBootloaderName()); 611 bl = new BootloaderInstallHex(this);
600 blinstaller->setBootloaderBaseUrl(settings->bootloaderUrl()); 612 }
601 blinstaller->setBootloaderInfoUrl(settings->bootloaderInfoUrl()); 613 else if(type == "sansa") {
602 if(!blinstaller->downloadInfo()) 614 bl = new BootloaderInstallSansa(this);
603 { 615 }
604 logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR); 616 else if(type == "ipod") {
617 bl = new BootloaderInstallIpod(this);
618 }
619 else if(type == "file") {
620 bl = new BootloaderInstallFile(this);
621 }
622 else {
623 logger->addItem(tr("No install method known."), LOGERROR);
605 logger->abort(); 624 logger->abort();
606 m_error = true;
607 return; 625 return;
608 } 626 }
609 627
610 if(blinstaller->uptodate()) 628 // set bootloader filename. Do this now as installed() needs it.
629 QString blfile;
630 blfile = settings->mountpoint() + settings->curBootloaderFile();
631 // special case for H10 pure: this player can have a different
632 // bootloader file filename. This is handled here to keep the install
633 // class clean, though having it here is also not the nicest solution.
634 if(settings->curPlatformName() == "h10_ums"
635 || settings->curPlatformName() == "h10_mtp") {
636 if(resolvePathCase(blfile).isEmpty())
637 blfile = settings->mountpoint()
638 + settings->curBootloaderName().replace("H10",
639 "H10EMP", Qt::CaseInsensitive);
640 }
641 bl->setBlFile(blfile);
642 QUrl url(settings->bootloaderUrl() + settings->curBootloaderName());
643 bl->setBlUrl(url);
644 bl->setLogfile(settings->mountpoint() + "/.rockbox/rbutil.log");
645
646 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
647 if(QMessageBox::question(this, tr("Bootloader detected"),
648 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
649 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
650 logger->close();
651 m_error = true;
652 return;
653 }
654 }
655 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
656 && bl->capabilities() & BootloaderInstallBase::Backup)
611 { 657 {
612 int ret = QMessageBox::question(this, tr("Bootloader Installation"), 658 QString targetFolder = settings->name(settings->curPlatform())
613 tr("The bootloader is already installed and up to date.\n" 659 + " Firmware Backup";
614 "Do want to replace the current bootloader?"), 660 // remove invalid character(s)
615 QMessageBox::Yes | QMessageBox::No, QMessageBox::No); 661 targetFolder.remove(QRegExp("[:/]"));
616 if(ret == QMessageBox::No) 662 if(QMessageBox::question(this, tr("Create Bootloader backup"),
617 { 663 tr("You can create a backup of the original bootloader "
618 logger->addItem(tr("Bootloader installation skipped!"), LOGINFO); 664 "file. Press \"Yes\" to select an output folder on your "
619 logger->abort(); 665 "computer to save the file to. The file will get placed "
620 m_installed = true; 666 "in a new folder \"%1\" created below the selected folder.\n"
621 return; 667 "Press \"No\" to skip this step.").arg(targetFolder),
668 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
669 BrowseDirtree tree(this, tr("Browse backup folder"));
670 tree.setDir(QDir::home());
671 tree.exec();
672
673 backupDestination = tree.getSelected() + "/" + targetFolder;
674 qDebug() << backupDestination;
675 // backup needs to be done after the logger has been set up.
622 } 676 }
623 } 677 }
624 678
625 // if fwpatcher , ask for extra file 679 if(bl->capabilities() & BootloaderInstallBase::NeedsFlashing)
626 QString offirmware;
627 if(settings->curBootloaderMethod() == "fwpatcher")
628 { 680 {
629 BrowseOF ofbrowser(this); 681 int ret;
630 ofbrowser.setFile(settings->ofPath()); 682 ret = QMessageBox::information(this, tr("Prerequisites"),
631 if(ofbrowser.exec() == QDialog::Accepted) 683 tr("Bootloader installation requires you to provide "
632 { 684 "a firmware file of the original firmware (hex file). "
633 offirmware = ofbrowser.getFile(); 685 "You need to download this file yourself due to legal "
634 qDebug() << offirmware; 686 "reasons. Please refer to the "
635 if(!QFileInfo(offirmware).exists()) 687 "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
636 { 688 "<a href='http://www.rockbox.org/wiki/IriverBoot"
637 logger->addItem(tr("Original Firmware Path is wrong!"),LOGERROR); 689 "#Download_and_extract_a_recent_ve'>IriverBoot</a> wiki page on "
638 logger->abort(); 690 "how to obtain this file.<br/>"
639 m_error = true; 691 "Press Ok to continue and browse your computer for the firmware "
640 return; 692 "file."),
641 } 693 QMessageBox::Ok | QMessageBox::Abort);
642 else 694 if(ret != QMessageBox::Ok) {
643 { 695 m_error = true;
644 settings->setOfPath(offirmware); 696 return;
645 settings->sync();
646 }
647 } 697 }
648 else 698 // open dialog to browse to hex file
649 { 699 QString hexfile;
650 logger->addItem(tr("Original Firmware selection Canceled!"),LOGERROR); 700 hexfile = QFileDialog::getOpenFileName(this,
651 logger->abort(); 701 tr("Select firmware file"), QDir::homePath(), "*.hex");
702 if(!QFileInfo(hexfile).isReadable()) {
703 logger->addItem(tr("Error opening firmware file"), LOGERROR);
652 m_error = true; 704 m_error = true;
653 return; 705 return;
654 } 706 }
707 ((BootloaderInstallHex*)bl)->setHexfile(hexfile);
708 }
709
710 // the bootloader install class does NOT use any GUI stuff.
711 // All messages are passed via signals.
712 connect(bl, SIGNAL(done(bool)), logger, SLOT(abort()));
713 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
714 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
715 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
716
717 // show logger and start install.
718 logger->show();
719 if(!backupDestination.isEmpty()) {
720 if(!bl->backup(backupDestination)) {
721 if(QMessageBox::warning(this, tr("Backup error"),
722 tr("Could not create backup file. Continue?"),
723 QMessageBox::No | QMessageBox::Yes)
724 == QMessageBox::No) {
725 logger->abort();
726 return;
727 }
728 }
655 } 729 }
656 blinstaller->setOrigFirmwarePath(offirmware); 730 bl->install();
657 connect(blinstaller,SIGNAL(done(bool)),this,SLOT(installdone(bool))); 731}
658 blinstaller->install(logger); 732
733void RbUtilQt::installBootloaderPost(bool error)
734{
735 qDebug() << __func__ << error;
736 // if an error occured don't perform post install steps.
737 if(error) {
738 m_error = true;
739 return;
740 }
741 else
742 m_error = false;
743
744 m_installed = true;
745 // end here if automated install
746 if(m_auto)
747 return;
748
749 QString msg = BootloaderInstallBase::postinstallHints(settings->curPlatform());
750 if(!msg.isEmpty()) {
751 QMessageBox::information(this, tr("Manual steps required"), msg);
752 logger->close();
753 }
754
659} 755}
660 756
661void RbUtilQt::installFontsBtn() 757void RbUtilQt::installFontsBtn()
@@ -825,23 +921,52 @@ void RbUtilQt::uninstallBootloader(void)
825 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; 921 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
826 // create logger 922 // create logger
827 ProgressLoggerGui* logger = new ProgressLoggerGui(this); 923 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
924 logger->setProgressVisible(false);
828 logger->show(); 925 logger->show();
829 926
830 BootloaderInstaller blinstaller(this); 927 QString platform = settings->curPlatform();
831 blinstaller.setMountPoint(settings->mountpoint()); 928
832 blinstaller.setDevice(settings->curPlatform()); 929 // create installer
833 blinstaller.setBootloaderMethod(settings->curBootloaderMethod()); 930 BootloaderInstallBase *bl;
834 blinstaller.setBootloaderName(settings->curBootloaderName()); 931 QString type = settings->curBootloaderMethod();
835 blinstaller.setBootloaderBaseUrl(settings->bootloaderUrl()); 932 if(type == "mi4") {
836 blinstaller.setBootloaderInfoUrl(settings->bootloaderInfoUrl()); 933 bl = new BootloaderInstallMi4();
837 if(!blinstaller.downloadInfo()) 934 }
838 { 935 else if(type == "hex") {
839 logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR); 936 bl = new BootloaderInstallHex();
937 }
938 else if(type == "sansa") {
939 bl = new BootloaderInstallSansa();
940 }
941 else if(type == "ipod") {
942 bl = new BootloaderInstallIpod();
943 }
944 else if(type == "file") {
945 bl = new BootloaderInstallFile();
946 }
947 else {
948 logger->addItem(tr("No uninstall method known."), LOGERROR);
840 logger->abort(); 949 logger->abort();
841 return; 950 return;
842 } 951 }
843 952
844 blinstaller.uninstall(logger); 953 QString blfile = settings->mountpoint() + settings->curBootloaderFile();
954 if(settings->curPlatformName() == "h10_ums"
955 || settings->curPlatformName() == "h10_mtp") {
956 if(resolvePathCase(blfile).isEmpty())
957 blfile = settings->mountpoint()
958 + settings->curBootloaderName().replace("H10",
959 "H10EMP", Qt::CaseInsensitive);
960 }
961 bl->setBlFile(blfile);
962
963 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
964 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
965
966 int result;
967 result = bl->uninstall();
968
969 logger->abort();
845 970
846} 971}
847 972