diff options
Diffstat (limited to 'rbutil/rbutilqt/installbootloader.cpp')
-rw-r--r-- | rbutil/rbutilqt/installbootloader.cpp | 190 |
1 files changed, 188 insertions, 2 deletions
diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp index 5c278ee5a7..85dd369693 100644 --- a/rbutil/rbutilqt/installbootloader.cpp +++ b/rbutil/rbutilqt/installbootloader.cpp | |||
@@ -54,6 +54,12 @@ void BootloaderInstaller::install(Ui::InstallProgressFrm* dp) | |||
54 | connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); | 54 | connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); |
55 | connect(this,SIGNAL(finish()),this,SLOT(ipodFinish())); | 55 | connect(this,SIGNAL(finish()),this,SLOT(ipodFinish())); |
56 | } | 56 | } |
57 | else if(m_bootloadermethod == "sansapatcher") | ||
58 | { | ||
59 | // connect internal signal | ||
60 | connect(this,SIGNAL(prepare()),this,SLOT(sansaPrepare())); | ||
61 | connect(this,SIGNAL(finish()),this,SLOT(sansaFinish())); | ||
62 | } | ||
57 | else | 63 | else |
58 | { | 64 | { |
59 | m_dp->listProgress->addItem(tr("unsupported install Method")); | 65 | m_dp->listProgress->addItem(tr("unsupported install Method")); |
@@ -91,6 +97,11 @@ void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp) | |||
91 | // connect internal signal | 97 | // connect internal signal |
92 | connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); | 98 | connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); |
93 | } | 99 | } |
100 | else if(m_bootloadermethod == "sansapatcher") | ||
101 | { | ||
102 | // connect internal signal | ||
103 | connect(this,SIGNAL(prepare()),this,SLOT(sansaPrepare())); | ||
104 | } | ||
94 | else | 105 | else |
95 | { | 106 | { |
96 | m_dp->listProgress->addItem(tr("unsupported install Method")); | 107 | m_dp->listProgress->addItem(tr("unsupported install Method")); |
@@ -596,7 +607,7 @@ void BootloaderInstaller::ipodPrepare() | |||
596 | if (delete_bootloader(&ipod)==0) | 607 | if (delete_bootloader(&ipod)==0) |
597 | { | 608 | { |
598 | m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); | 609 | m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); |
599 | emit done(true); | 610 | emit done(false); |
600 | ipod_close(&ipod); | 611 | ipod_close(&ipod); |
601 | return; | 612 | return; |
602 | } | 613 | } |
@@ -604,6 +615,7 @@ void BootloaderInstaller::ipodPrepare() | |||
604 | { | 615 | { |
605 | m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); | 616 | m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); |
606 | emit done(true); | 617 | emit done(true); |
618 | ipod_close(&ipod); | ||
607 | return; | 619 | return; |
608 | } | 620 | } |
609 | } | 621 | } |
@@ -685,7 +697,7 @@ void BootloaderInstaller::ipodFinish() | |||
685 | if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) | 697 | if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) |
686 | { | 698 | { |
687 | m_dp->listProgress->addItem(tr("Successfully added Bootloader")); | 699 | m_dp->listProgress->addItem(tr("Successfully added Bootloader")); |
688 | emit done(true); | 700 | emit done(false); |
689 | ipod_close(&ipod); | 701 | ipod_close(&ipod); |
690 | return; | 702 | return; |
691 | } | 703 | } |
@@ -695,8 +707,182 @@ void BootloaderInstaller::ipodFinish() | |||
695 | ipod_close(&ipod); | 707 | ipod_close(&ipod); |
696 | emit done(true); | 708 | emit done(true); |
697 | return; | 709 | return; |
710 | } | ||
711 | } | ||
712 | |||
713 | /************************************************** | ||
714 | *** sansa secific code | ||
715 | ***************************************************/ | ||
716 | // reserves memory for sansapatcher | ||
717 | bool initSansaPatcher() | ||
718 | { | ||
719 | if (sansa_alloc_buffer(§orbuf,BUFFER_SIZE) < 0) return true; | ||
720 | else return false; | ||
721 | } | ||
722 | |||
723 | |||
724 | void BootloaderInstaller::sansaPrepare() | ||
725 | { | ||
726 | m_dp->listProgress->addItem(tr("Searching for sansas")); | ||
727 | struct sansa_t sansa; | ||
728 | |||
729 | int n = sansa_scan(&sansa); | ||
730 | if (n == 0) | ||
731 | { | ||
732 | m_dp->listProgress->addItem(tr("No Sansa found")); | ||
733 | emit done(true); | ||
734 | return; | ||
698 | } | 735 | } |
736 | if (n > 1) | ||
737 | { | ||
738 | m_dp->listProgress->addItem(tr("Too many Sansas found")); | ||
739 | emit done(true); | ||
740 | } | ||
741 | |||
742 | if(m_install) // Installation | ||
743 | { | ||
744 | QString url = m_bootloaderUrlBase + "/sandisk-sansa/e200/" + m_bootloadername; | ||
745 | |||
746 | m_dp->listProgress->addItem(tr("Downloading file %1.%2") | ||
747 | .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); | ||
748 | |||
749 | // temporary file needs to be opened to get the filename | ||
750 | downloadFile.open(); | ||
751 | m_tempfilename = downloadFile.fileName(); | ||
752 | downloadFile.close(); | ||
753 | // get the real file. | ||
754 | getter = new HttpGet(this); | ||
755 | getter->setProxy(m_proxy); | ||
756 | getter->setFile(&downloadFile); | ||
757 | getter->getFile(QUrl(url)); | ||
758 | // connect signals from HttpGet | ||
759 | connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); | ||
760 | //connect(getter, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); | ||
761 | connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); | ||
762 | } | ||
763 | else // Uninstallation | ||
764 | { | ||
765 | |||
766 | if (sansa_open(&sansa, 0) < 0) | ||
767 | { | ||
768 | m_dp->listProgress->addItem(tr("could not open Sansa")); | ||
769 | emit done(true); | ||
770 | return; | ||
771 | } | ||
772 | |||
773 | if (sansa_read_partinfo(&sansa,0) < 0) | ||
774 | { | ||
775 | m_dp->listProgress->addItem(tr("could not read partitiontable")); | ||
776 | emit done(true); | ||
777 | return; | ||
778 | } | ||
779 | |||
780 | int i = is_e200(&sansa); | ||
781 | if (i < 0) { | ||
782 | m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); | ||
783 | emit done(true); | ||
784 | return; | ||
785 | } | ||
786 | |||
787 | if (sansa.hasoldbootloader) | ||
788 | { | ||
789 | m_dp->listProgress->addItem(tr("********************************************\n" | ||
790 | "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" | ||
791 | "You must reinstall the original Sansa firmware before running\n" | ||
792 | "sansapatcher for the first time.\n" | ||
793 | "See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n" | ||
794 | "*********************************************\n")); | ||
795 | emit done(true); | ||
796 | return; | ||
797 | } | ||
798 | |||
799 | |||
800 | if (sansa_reopen_rw(&sansa) < 0) | ||
801 | { | ||
802 | m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); | ||
803 | emit done(true); | ||
804 | return; | ||
805 | } | ||
699 | 806 | ||
807 | if (sansa_delete_bootloader(&sansa)==0) | ||
808 | { | ||
809 | m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); | ||
810 | emit done(false); | ||
811 | sansa_close(&sansa); | ||
812 | return; | ||
813 | } | ||
814 | else | ||
815 | { | ||
816 | m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); | ||
817 | emit done(true); | ||
818 | sansa_close(&sansa); | ||
819 | return; | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | |||
824 | void BootloaderInstaller::sansaFinish() | ||
825 | { | ||
826 | struct sansa_t sansa; | ||
827 | sansa_scan(&sansa); | ||
828 | |||
829 | if (sansa_open(&sansa, 0) < 0) | ||
830 | { | ||
831 | m_dp->listProgress->addItem(tr("could not open Sansa")); | ||
832 | emit done(true); | ||
833 | return; | ||
834 | } | ||
835 | |||
836 | if (sansa_read_partinfo(&sansa,0) < 0) | ||
837 | { | ||
838 | m_dp->listProgress->addItem(tr("could not read partitiontable")); | ||
839 | emit done(true); | ||
840 | return; | ||
841 | } | ||
842 | |||
843 | |||
844 | int i = is_e200(&sansa); | ||
845 | if (i < 0) { | ||
846 | |||
847 | m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); | ||
848 | emit done(true); | ||
849 | return; | ||
850 | } | ||
851 | |||
852 | if (sansa.hasoldbootloader) | ||
853 | { | ||
854 | m_dp->listProgress->addItem(tr("********************************************\n" | ||
855 | "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" | ||
856 | "You must reinstall the original Sansa firmware before running\n" | ||
857 | "sansapatcher for the first time.\n" | ||
858 | "See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n" | ||
859 | "*********************************************\n")); | ||
860 | emit done(true); | ||
861 | return; | ||
862 | } | ||
863 | |||
864 | if (sansa_reopen_rw(&sansa) < 0) | ||
865 | { | ||
866 | m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); | ||
867 | emit done(true); | ||
868 | return; | ||
869 | } | ||
870 | |||
871 | if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0) | ||
872 | { | ||
873 | m_dp->listProgress->addItem(tr("Successfully added Bootloader")); | ||
874 | emit done(false); | ||
875 | sansa_close(&sansa); | ||
876 | return; | ||
877 | } | ||
878 | else | ||
879 | { | ||
880 | m_dp->listProgress->addItem(tr("failed to add Bootloader")); | ||
881 | sansa_close(&sansa); | ||
882 | emit done(true); | ||
883 | return; | ||
884 | } | ||
885 | |||
700 | } | 886 | } |
701 | 887 | ||
702 | 888 | ||