2007-07-27 22:46:49 +00:00
/***************************************************************************
* __________ __ ___ .
* Open \ ______ \ ____ ____ | | _ \ _ | __ _______ ___
* Source | _ // _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( < _ > ) \ ___ | < | \ _ \ ( < _ > > < <
* Firmware | ____ | _ / \ ____ / \ ___ > __ | _ \ | ___ / \ ____ / __ / \ _ \
* \ / \ / \ / \ / \ /
*
* Copyright ( C ) 2007 by Dominik Wenger
2007-08-23 22:11:50 +00:00
* $ Id $
2007-07-27 22:46:49 +00:00
*
* All files in this archive are subject to the GNU General Public License .
* See the file COPYING in the source tree root for full license agreement .
*
* This software is distributed on an " AS IS " basis , WITHOUT WARRANTY OF ANY
* KIND , either express or implied .
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
# include "installbootloader.h"
2007-07-29 21:59:11 +00:00
# include "irivertools/checksums.h"
2008-04-02 21:17:35 +00:00
# include "utils.h"
2007-07-27 22:46:49 +00:00
2007-09-15 22:57:07 +00:00
BootloaderInstaller : : BootloaderInstaller ( QObject * parent ) : QObject ( parent )
2007-07-27 22:46:49 +00:00
{
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
}
2007-07-29 18:07:31 +00:00
void BootloaderInstaller : : install ( ProgressloggerInterface * dp )
2007-07-27 22:46:49 +00:00
{
m_dp = dp ;
m_install = true ;
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Starting bootloader installation " ) , LOGINFO ) ;
2007-08-01 22:21:57 +00:00
connect ( this , SIGNAL ( done ( bool ) ) , this , SLOT ( installEnded ( bool ) ) ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( m_bootloadermethod = = " gigabeatf " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( gigabeatPrepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( gigabeatFinish ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " iaudio " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( iaudioPrepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( iaudioFinish ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " h10 " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( h10Prepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( h10Finish ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " ipodpatcher " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( ipodPrepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( ipodFinish ( ) ) ) ;
}
2007-07-28 11:32:32 +00:00
else if ( m_bootloadermethod = = " sansapatcher " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( sansaPrepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( sansaFinish ( ) ) ) ;
}
2007-07-28 14:38:25 +00:00
else if ( m_bootloadermethod = = " fwpatcher " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( iriverPrepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( iriverFinish ( ) ) ) ;
}
2008-03-02 12:24:01 +00:00
else if ( m_bootloadermethod = = " mrobe100 " )
{
// connect internal signal
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( mrobe100Prepare ( ) ) ) ;
connect ( this , SIGNAL ( finish ( ) ) , this , SLOT ( mrobe100Finish ( ) ) ) ;
}
2007-07-27 22:46:49 +00:00
else
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " unsupported install Method " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit prepare ( ) ;
}
2007-07-29 18:07:31 +00:00
void BootloaderInstaller : : uninstall ( ProgressloggerInterface * dp )
2007-07-27 22:46:49 +00:00
{
m_dp = dp ;
m_install = false ;
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Starting bootloader uninstallation " ) , LOGINFO ) ;
2007-08-01 22:21:57 +00:00
connect ( this , SIGNAL ( done ( bool ) ) , this , SLOT ( installEnded ( bool ) ) ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( m_bootloadermethod = = " gigabeatf " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( gigabeatPrepare ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " iaudio " )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No uninstallation possible " ) , LOGWARNING ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " iaudio " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( h10Prepare ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
else if ( m_bootloadermethod = = " ipodpatcher " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( ipodPrepare ( ) ) ) ;
2007-07-27 22:46:49 +00:00
}
2007-07-28 11:32:32 +00:00
else if ( m_bootloadermethod = = " sansapatcher " )
{
// connect internal signal
2007-09-15 22:57:07 +00:00
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( sansaPrepare ( ) ) ) ;
2007-07-28 11:32:32 +00:00
}
2008-03-02 12:24:01 +00:00
else if ( m_bootloadermethod = = " h10 " )
{
// connect internal signal
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( h10Prepare ( ) ) ) ;
}
else if ( m_bootloadermethod = = " mrobe100 " )
{
// connect internal signal
connect ( this , SIGNAL ( prepare ( ) ) , this , SLOT ( mrobe100Prepare ( ) ) ) ;
}
2007-07-28 14:38:25 +00:00
else if ( m_bootloadermethod = = " fwpatcher " )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No uninstallation possible " ) , LOGWARNING ) ;
2007-07-28 14:38:25 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-28 14:38:25 +00:00
}
2007-07-27 22:46:49 +00:00
else
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " unsupported install Method " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit prepare ( ) ;
}
void BootloaderInstaller : : downloadRequestFinished ( int id , bool error )
{
qDebug ( ) < < " BootloaderInstall::downloadRequestFinished " < < id < < error ;
qDebug ( ) < < " error: " < < getter - > errorString ( ) ;
downloadDone ( error ) ;
}
void BootloaderInstaller : : downloadDone ( bool error )
{
qDebug ( ) < < " Install::downloadDone, error: " < < error ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
// update progress bar
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
int max = m_dp - > getProgressMax ( ) ;
2007-07-27 22:46:49 +00:00
if ( max = = 0 ) {
max = 100 ;
2007-07-29 18:07:31 +00:00
m_dp - > setProgressMax ( max ) ;
2007-07-27 22:46:49 +00:00
}
2007-07-29 18:07:31 +00:00
m_dp - > setProgressValue ( max ) ;
2007-07-27 22:46:49 +00:00
if ( getter - > httpResponse ( ) ! = 200 ) {
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Download error: received HTTP error %1. " ) . arg ( getter - > httpResponse ( ) ) , LOGERROR ) ;
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( error ) {
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Download error: %1 " ) . arg ( getter - > errorString ( ) ) , LOGERROR ) ;
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-07-31 19:11:44 +00:00
else m_dp - > addItem ( tr ( " Download finished. " ) , LOGOK ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit finish ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
}
2007-08-01 22:21:57 +00:00
void BootloaderInstaller : : installEnded ( bool error )
{
( void ) error ;
m_dp - > abort ( ) ;
}
2007-08-26 16:44:23 +00:00
bool BootloaderInstaller : : downloadInfo ( )
{
// try to get the current build information
infodownloader = new HttpGet ( this ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
connect ( infodownloader , SIGNAL ( done ( bool ) ) , this , SLOT ( infoDownloadDone ( bool ) ) ) ;
connect ( infodownloader , SIGNAL ( requestFinished ( int , bool ) ) , this , SLOT ( infoRequestFinished ( int , bool ) ) ) ;
qDebug ( ) < < " downloading bootloader info " ;
infodownloader - > setFile ( & bootloaderInfo ) ;
infodownloader - > getFile ( QUrl ( m_bootloaderinfoUrl ) ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
// block until its downloaded
qDebug ( ) < < " Waiting for Download finished " ;
infoDownloaded = false ;
infoError = false ;
while ( ! infoDownloaded )
2008-02-10 18:25:49 +00:00
QCoreApplication : : processEvents ( ) ;
2007-08-26 16:44:23 +00:00
return ! infoError ;
}
void BootloaderInstaller : : infoDownloadDone ( bool error )
{
2007-09-15 22:57:07 +00:00
if ( error )
2007-08-26 16:44:23 +00:00
{
qDebug ( ) < < " network error: " < < infodownloader - > error ( ) ;
return ;
}
qDebug ( ) < < " network status: " < < infodownloader - > error ( ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
infoDownloaded = true ;
}
void BootloaderInstaller : : infoRequestFinished ( int id , bool error )
{
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
if ( error )
2007-09-15 22:57:07 +00:00
{
2007-08-26 16:44:23 +00:00
QString errorString ;
errorString = tr ( " Network error: %1. Please check your network and proxy settings. " )
. arg ( infodownloader - > errorString ( ) ) ;
2008-02-10 18:25:49 +00:00
# ifndef CONSOLE
2007-08-26 16:44:23 +00:00
if ( error ) QMessageBox : : about ( NULL , " Network Error " , errorString ) ;
2008-02-10 18:25:49 +00:00
# endif
qDebug ( ) < < " downloadDone: " < < id < < error ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
infoError = true ;
infoDownloaded = true ;
}
qDebug ( ) < < " infoRequestFinished: " < < id < < error ;
}
void BootloaderInstaller : : createInstallLog ( )
{
m_dp - > addItem ( tr ( " Creating installation log " ) , LOGINFO ) ;
QSettings installlog ( m_mountpoint + " /.rockbox/rbutil.log " , QSettings : : IniFormat , 0 ) ;
bootloaderInfo . open ( ) ;
QSettings info ( bootloaderInfo . fileName ( ) , QSettings : : IniFormat , this ) ;
bootloaderInfo . close ( ) ;
info . beginGroup ( m_device ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
installlog . beginGroup ( " Bootloader " ) ;
installlog . setValue ( " md5sum " , info . value ( " md5sum " ) . toString ( ) ) ;
installlog . endGroup ( ) ;
installlog . sync ( ) ;
}
void BootloaderInstaller : : removeInstallLog ( )
{
m_dp - > addItem ( tr ( " Editing installation log " ) , LOGINFO ) ;
QSettings installlog ( m_mountpoint + " /.rockbox/rbutil.log " , QSettings : : IniFormat , 0 ) ;
installlog . beginGroup ( " Bootloader " ) ;
installlog . remove ( " md5sum " ) ;
installlog . endGroup ( ) ;
installlog . sync ( ) ;
}
bool BootloaderInstaller : : uptodate ( )
{
QString installedMd5 ;
QString serverMd5 ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
QSettings installlog ( m_mountpoint + " /.rockbox/rbutil.log " , QSettings : : IniFormat , 0 ) ;
installlog . beginGroup ( " Bootloader " ) ;
installedMd5 = installlog . value ( " md5sum " ) . toString ( ) ;
installlog . endGroup ( ) ;
2007-09-15 22:57:07 +00:00
2008-03-27 22:27:11 +00:00
if ( installedMd5 . isEmpty ( ) )
return false ;
2007-08-26 16:44:23 +00:00
bootloaderInfo . open ( ) ;
QSettings info ( bootloaderInfo . fileName ( ) , QSettings : : IniFormat , this ) ;
bootloaderInfo . close ( ) ;
info . beginGroup ( m_device ) ;
serverMd5 = info . value ( " md5sum " ) . toString ( ) ;
info . endGroup ( ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
if ( installedMd5 ! = serverMd5 )
return false ;
else
return true ;
}
2007-08-01 22:21:57 +00:00
2007-07-27 22:46:49 +00:00
/**************************************************
2007-09-15 22:57:07 +00:00
* * * gigabeat secific code
2007-07-27 22:46:49 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void BootloaderInstaller : : gigabeatPrepare ( )
{
if ( m_install ) // Installation
{
QString url = m_bootloaderUrlBase + " /gigabeat/ " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2008-05-23 19:05:20 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-05-23 19:05:20 +00:00
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2008-05-23 19:05:20 +00:00
}
else //UnInstallation
{
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /GBSYSTEM/FWIMG/FWIMG01.DAT " ) ;
QString firmwareOrig = resolvePathCase ( firmware . append ( " .ORIG " ) ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
// check if original firmware exists
if ( ! firmwareOrigFI . exists ( ) )
{
2008-05-23 19:05:20 +00:00
m_dp - > addItem ( tr ( " Could not find the Original Firmware at: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmwareOrig ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFile firmwareFile ( firmware ) ;
QFile firmwareOrigFile ( firmwareOrig ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
//remove modified firmware
if ( ! firmwareFile . remove ( ) )
{
2008-05-23 19:05:20 +00:00
m_dp - > addItem ( tr ( " Could not remove the Firmware at: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2008-04-02 21:17:35 +00:00
// rename original firmware back
if ( ! firmwareOrigFile . rename ( firmware ) )
2007-07-27 22:46:49 +00:00
{
2008-05-23 19:05:20 +00:00
m_dp - > addItem ( tr ( " Could not copy the Firmware from: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( firmwareOrig , firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
removeInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit done ( false ) ; //success
2008-05-23 19:05:20 +00:00
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
void BootloaderInstaller : : gigabeatFinish ( )
2007-07-27 22:46:49 +00:00
{
// this step is only need for installation, so no code for uninstall here
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Finishing bootloader install " ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /GBSYSTEM/FWIMG/ " + m_bootloadername ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareFI ( firmware ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
// check if firmware exists
if ( ! firmwareFI . exists ( ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not find the Firmware at: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QString firmwareOrig = firmware ;
firmwareOrig . append ( " .ORIG " ) ;
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
2007-09-15 22:57:07 +00:00
2008-02-28 20:18:40 +00:00
// rename and backup the firmware, if there is no original firmware there
2007-07-27 22:46:49 +00:00
if ( ! firmwareOrigFI . exists ( ) )
{
QFile firmwareFile ( firmware ) ;
2008-02-28 20:18:40 +00:00
//backup
QDir : : home ( ) . mkdir ( " Gigabeat Original Firmware Backup " ) ;
firmwareFile . copy ( QDir : : toNativeSeparators ( QDir : : homePath ( ) ) + QDir : : toNativeSeparators ( " /Gigabeat Original Firmware Backup/ " ) + m_bootloadername ) ;
2008-04-02 21:17:35 +00:00
firmwareFile . unsetError ( ) ;
2008-02-28 20:18:40 +00:00
//rename
2007-07-27 22:46:49 +00:00
if ( ! firmwareFile . rename ( firmwareOrig ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not rename: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware , firmwareOrig ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
}
else // or remove the normal firmware, if the original is there
{
QFile firmwareFile ( firmware ) ;
firmwareFile . remove ( ) ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
//copy the firmware
if ( ! downloadFile . copy ( firmware ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not copy: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( m_tempfilename , firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
downloadFile . remove ( ) ;
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Bootloader install finished successfully. " ) , LOGOK ) ;
2007-08-15 14:16:20 +00:00
m_dp - > addItem ( tr ( " To finish the Bootloader installation, follow the steps below. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 1. Eject/Unmount your Device. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 2. Unplug USB and any Power adapters. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 3. Hold POWER to turn the Device off. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 4. Toggle the Battery switch on the Device. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 5. Hold POWER to boot the Rockbox bootloader. " ) , LOGINFO ) ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit done ( false ) ; // success
}
/**************************************************
2007-09-15 22:57:07 +00:00
* * * iaudio secific code
2007-07-27 22:46:49 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void BootloaderInstaller : : iaudioPrepare ( )
{
QString url = m_bootloaderUrlBase + " /iaudio/ " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2007-07-31 19:11:44 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
getter - > getFile ( QUrl ( url ) ) ;
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
}
2007-07-27 22:46:49 +00:00
void BootloaderInstaller : : iaudioFinish ( )
{
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /FIRMWARE/ " ) + " / " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
//copy the firmware
if ( ! downloadFile . copy ( firmware ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not copy: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( m_tempfilename , firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
downloadFile . remove ( ) ;
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-08-03 18:43:45 +00:00
m_dp - > addItem ( tr ( " Bootloader install finished successfully. " ) , LOGOK ) ;
2007-08-15 14:16:20 +00:00
m_dp - > addItem ( tr ( " To finish the Bootloader installation, follow the steps below. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 1. Eject/Unmount your Device. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 2. Turn you Device OFF. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 3. Insert Charger. " ) , LOGINFO ) ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit done ( false ) ; // success
2007-09-15 22:57:07 +00:00
}
2007-07-27 22:46:49 +00:00
/**************************************************
2007-09-15 22:57:07 +00:00
* * * h10 secific code
2007-07-27 22:46:49 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void BootloaderInstaller : : h10Prepare ( )
{
if ( m_install ) // Installation
{
QString url = m_bootloaderUrlBase + " /iriver/ " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2007-07-31 19:11:44 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2007-07-27 22:46:49 +00:00
}
else // Uninstallation
{
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QString firmwarename = m_bootloadername . section ( ' / ' , - 1 ) ;
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM/ " + firmwarename ) ;
QString firmwareOrig = resolvePathCase ( m_mountpoint + " /SYSTEM/OF.mi4 " ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareFI ( firmware ) ;
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
2008-04-02 21:17:35 +00:00
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM/H10EMP.mi4 " ) ;
//attempt other firmwarename
2007-07-27 22:46:49 +00:00
firmwareFI . setFile ( firmware ) ;
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
2007-08-29 12:36:00 +00:00
m_dp - > addItem ( tr ( " Firmware does not exist: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
if ( ! firmwareOrigFI . exists ( ) ) //Original Firmware dosent exists on player
{
2007-08-29 12:36:00 +00:00
m_dp - > addItem ( tr ( " Original Firmware does not exist: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmwareOrig ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFile firmwareFile ( firmware ) ;
QFile firmwareOrigFile ( firmwareOrig ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
//remove modified firmware
if ( ! firmwareFile . remove ( ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not remove the Firmware at: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2008-04-02 21:17:35 +00:00
// rename original firmware back
if ( ! firmwareOrigFile . rename ( firmware ) )
2007-07-27 22:46:49 +00:00
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not copy the Firmware from: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( firmwareOrig , firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
removeInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit done ( false ) ; //success
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
}
}
void BootloaderInstaller : : h10Finish ( )
{
QString firmwarename = m_bootloadername . section ( ' / ' , - 1 ) ;
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM/ " + firmwarename ) ;
QString firmwareOrig = resolvePathCase ( m_mountpoint + " /SYSTEM " ) + " /OF.mi4 " ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareFI ( firmware ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
2008-04-02 21:17:35 +00:00
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM " ) + " /H10EMP.mi4 " ;
//attempt other firmwarename
2007-07-27 22:46:49 +00:00
firmwareFI . setFile ( firmware ) ;
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Firmware does not exist: %1 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
2007-09-15 22:57:07 +00:00
2008-02-28 20:18:40 +00:00
if ( ! firmwareOrigFI . exists ( ) )
2007-07-27 22:46:49 +00:00
{
QFile firmwareFile ( firmware ) ;
2008-02-28 20:18:40 +00:00
//backup
QDir : : home ( ) . mkdir ( " Iriver H10 Original Firmware Backup " ) ;
firmwareFile . copy ( QDir : : toNativeSeparators ( QDir : : homePath ( ) ) + QDir : : toNativeSeparators ( " /Iriver H10 Original Firmware Backup/ " ) + m_bootloadername ) ;
2008-04-02 21:17:35 +00:00
firmwareFile . unsetError ( ) ;
2008-02-28 20:18:40 +00:00
//rename
2007-07-27 22:46:49 +00:00
if ( ! firmwareFile . rename ( firmwareOrig ) ) //rename Firmware to Original
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not rename: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( firmware , firmwareOrig ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
}
2008-02-28 20:18:40 +00:00
else //there is already a original firmware
2007-07-27 22:46:49 +00:00
{
QFile firmwareFile ( firmware ) ;
firmwareFile . remove ( ) ;
}
//copy the firmware
if ( ! downloadFile . copy ( firmware ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not copy: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( m_tempfilename , firmware ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
downloadFile . remove ( ) ;
2007-09-15 22:57:07 +00:00
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Bootloader install finished successfully. " ) , LOGOK ) ;
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
emit done ( false ) ; // success
}
2008-03-02 12:24:01 +00:00
/**************************************************
* * * mrobe100 secific code
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void BootloaderInstaller : : mrobe100Prepare ( )
{
if ( m_install ) // Installation
{
QString url = m_bootloaderUrlBase + " /olympus/mrobe100/ " + m_bootloadername ;
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
2008-04-01 18:02:56 +00:00
2008-03-02 12:24:01 +00:00
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2008-03-02 12:24:01 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2008-03-02 12:24:01 +00:00
}
else // Uninstallation
{
QString firmwarename = m_bootloadername ;
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM/ " + firmwarename ) ;
QString firmwareOrig = resolvePathCase ( m_mountpoint + " /SYSTEM/OF.mi4 " ) ;
2008-03-02 12:24:01 +00:00
QFileInfo firmwareFI ( firmware ) ;
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
m_dp - > addItem ( tr ( " Firmware does not exist: %1 " )
. arg ( firmware ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
if ( ! firmwareOrigFI . exists ( ) ) //Original Firmware dosent exists on player
{
m_dp - > addItem ( tr ( " Original Firmware does not exist: %1 " )
. arg ( firmwareOrig ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
QFile firmwareFile ( firmware ) ;
QFile firmwareOrigFile ( firmwareOrig ) ;
//remove modified firmware
if ( ! firmwareFile . remove ( ) )
{
m_dp - > addItem ( tr ( " Could not remove the Firmware at: %1 " )
. arg ( firmware ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
2008-04-02 21:17:35 +00:00
// move original firmware back
if ( ! firmwareOrigFile . rename ( firmware ) )
2008-03-02 12:24:01 +00:00
{
m_dp - > addItem ( tr ( " Could not copy the Firmware from: %1 to %2 " )
. arg ( firmwareOrig , firmware ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
removeInstallLog ( ) ;
emit done ( false ) ; //success
}
}
void BootloaderInstaller : : mrobe100Finish ( )
{
QString firmwarename = m_bootloadername ;
2008-04-02 21:17:35 +00:00
QString firmware ;
firmware = resolvePathCase ( m_mountpoint + " /SYSTEM/ " + firmwarename ) ;
// NOTE: the filename for the OF may not exist yet, so resolve path only!
QString firmwareOrig = resolvePathCase ( m_mountpoint + " /SYSTEM " ) + " /OF.mi4 " ;
2008-03-02 12:24:01 +00:00
QFileInfo firmwareFI ( firmware ) ;
if ( ! firmwareFI . exists ( ) ) //Firmware dosent exists on player
{
m_dp - > addItem ( tr ( " Firmware does not exist: %1 " )
. arg ( firmware ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
QFileInfo firmwareOrigFI ( firmwareOrig ) ;
if ( ! firmwareOrigFI . exists ( ) )
{
QFile firmwareFile ( firmware ) ;
//backup
QDir : : home ( ) . mkdir ( " Olympus mrobe100 Original Firmware Backup " ) ;
firmwareFile . copy ( QDir : : toNativeSeparators ( QDir : : homePath ( ) ) + QDir : : toNativeSeparators ( " /Olympus mrobe100 Original Firmware Backup/ " ) + m_bootloadername ) ;
2008-04-02 21:17:35 +00:00
firmwareFile . unsetError ( ) ;
//rename
2008-03-02 12:24:01 +00:00
if ( ! firmwareFile . rename ( firmwareOrig ) ) //rename Firmware to Original
{
m_dp - > addItem ( tr ( " Could not rename: %1 to %2 " )
. arg ( firmware , firmwareOrig ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
}
else //there is already a original firmware
{
QFile firmwareFile ( firmware ) ;
firmwareFile . remove ( ) ;
}
//copy the firmware
if ( ! downloadFile . copy ( firmware ) )
{
m_dp - > addItem ( tr ( " Could not copy: %1 to %2 " )
. arg ( m_tempfilename , firmware ) , LOGERROR ) ;
emit done ( true ) ;
return ;
}
downloadFile . remove ( ) ;
createInstallLog ( ) ;
m_dp - > addItem ( tr ( " Bootloader install finished successfully. " ) , LOGOK ) ;
m_dp - > abort ( ) ;
emit done ( false ) ; // success
}
2007-07-27 22:46:49 +00:00
/**************************************************
2007-09-15 22:57:07 +00:00
* * * ipod secific code
2007-07-27 22:46:49 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int verbose = 0 ;
// reserves memory for ipodpatcher
bool initIpodpatcher ( )
{
2008-06-17 17:52:13 +00:00
if ( ipod_alloc_buffer ( & ipod_sectorbuf , BUFFER_SIZE ) < 0 ) return true ;
2007-07-27 22:46:49 +00:00
else return false ;
}
void BootloaderInstaller : : ipodPrepare ( )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Searching for ipods " ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
struct ipod_t ipod ;
int n = ipod_scan ( & ipod ) ;
if ( n = = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No Ipods found " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( n > 1 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Too many Ipods found " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( m_install ) // Installation
{
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
QString url = m_bootloaderUrlBase + " /ipod/bootloader- " + m_bootloadername + " .ipod " ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2007-07-31 19:11:44 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
2008-04-01 18:02:56 +00:00
2007-07-27 22:46:49 +00:00
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2007-07-27 22:46:49 +00:00
}
else // Uninstallation
{
if ( ipod_open ( & ipod , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not open ipod " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( read_partinfo ( & ipod , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not read partitiontable " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( ipod . pinfo [ 0 ] . start = = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No partition 0 on disk " ) , LOGERROR ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
int i ;
double sectors_per_MB = ( 1024.0 * 1024.0 ) / ipod . sector_size ;
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " [INFO] Part Start Sector End Sector Size (MB) Type \n " ) , LOGINFO ) ;
2007-09-15 22:57:07 +00:00
for ( i = 0 ; i < 4 ; i + + )
2007-07-27 22:46:49 +00:00
{
2007-09-15 22:57:07 +00:00
if ( ipod . pinfo [ i ] . start ! = 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " [INFO] %1 %2 %3 %4 %5 (%6) " ) . arg (
2007-07-27 22:46:49 +00:00
i ) . arg (
ipod . pinfo [ i ] . start ) . arg (
ipod . pinfo [ i ] . start + ipod . pinfo [ i ] . size - 1 ) . arg (
ipod . pinfo [ i ] . size / sectors_per_MB ) . arg (
get_parttype ( ipod . pinfo [ i ] . type ) ) . arg (
2007-07-31 19:11:44 +00:00
ipod . pinfo [ i ] . type ) , LOGINFO ) ;
2007-07-27 22:46:49 +00:00
}
}
emit done ( true ) ;
return ;
}
read_directory ( & ipod ) ;
if ( ipod . nimages < = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Failed to read firmware directory " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( getmodel ( & ipod , ( ipod . ipod_directory [ 0 ] . vers > > 8 ) ) < 0 )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Unknown version number in firmware (%1) " ) . arg (
2007-07-31 19:11:44 +00:00
ipod . ipod_directory [ 0 ] . vers ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( ipod . macpod )
{
2007-10-04 22:14:01 +00:00
m_dp - > addItem ( tr ( " Warning this is a MacPod, Rockbox doesnt work on "
" this. Convert it to WinPod \n "
2007-10-04 22:17:45 +00:00
" See http://www.rockbox.org/wiki/IpodConversionToFAT32 " ) ,
2007-10-04 22:14:01 +00:00
LOGWARNING ) ;
emit done ( true ) ;
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
if ( ipod_reopen_rw ( & ipod ) < 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not open Ipod in RW mode " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( ipod . ipod_directory [ 0 ] . entryOffset = = 0 ) {
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No bootloader detected. " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( delete_bootloader ( & ipod ) = = 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Successfully removed Bootloader " ) , LOGOK ) ;
2007-08-26 16:44:23 +00:00
removeInstallLog ( ) ;
2007-07-28 11:32:32 +00:00
emit done ( false ) ;
2007-07-27 22:46:49 +00:00
ipod_close ( & ipod ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
else
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " --delete-bootloader failed. " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
2007-07-28 11:32:32 +00:00
ipod_close ( & ipod ) ;
2007-09-15 22:57:07 +00:00
return ;
}
}
2007-07-27 22:46:49 +00:00
}
void BootloaderInstaller : : ipodFinish ( )
{
struct ipod_t ipod ;
ipod_scan ( & ipod ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
if ( ipod_open ( & ipod , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not open ipod " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( read_partinfo ( & ipod , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not read partitiontable " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( ipod . pinfo [ 0 ] . start = = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No partition 0 on disk " ) , LOGERROR ) ;
2007-09-15 22:57:07 +00:00
2007-07-27 22:46:49 +00:00
int i ;
double sectors_per_MB = ( 1024.0 * 1024.0 ) / ipod . sector_size ;
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " [INFO] Part Start Sector End Sector Size (MB) Type \n " ) , LOGINFO ) ;
2007-09-15 22:57:07 +00:00
for ( i = 0 ; i < 4 ; i + + )
2007-07-27 22:46:49 +00:00
{
2007-09-15 22:57:07 +00:00
if ( ipod . pinfo [ i ] . start ! = 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " [INFO] %1 %2 %3 %4 %5 (%6) " ) . arg (
2007-07-27 22:46:49 +00:00
i ) . arg (
ipod . pinfo [ i ] . start ) . arg (
ipod . pinfo [ i ] . start + ipod . pinfo [ i ] . size - 1 ) . arg (
ipod . pinfo [ i ] . size / sectors_per_MB ) . arg (
get_parttype ( ipod . pinfo [ i ] . type ) ) . arg (
2007-07-31 19:11:44 +00:00
ipod . pinfo [ i ] . type ) , LOGWARNING ) ;
2007-07-27 22:46:49 +00:00
}
}
emit done ( true ) ;
return ;
}
read_directory ( & ipod ) ;
if ( ipod . nimages < = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Failed to read firmware directory " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( getmodel ( & ipod , ( ipod . ipod_directory [ 0 ] . vers > > 8 ) ) < 0 )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Unknown version number in firmware (%1) " ) . arg (
2007-07-31 19:11:44 +00:00
ipod . ipod_directory [ 0 ] . vers ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
if ( ipod . macpod )
{
2007-10-04 22:14:01 +00:00
m_dp - > addItem ( tr ( " Warning this is a MacPod, Rockbox doesnt work on "
" this. Convert it to WinPod \n "
2007-10-04 22:17:45 +00:00
" See http://www.rockbox.org/wiki/IpodConversionToFAT32 " ) ,
2007-10-04 22:14:01 +00:00
LOGWARNING ) ;
emit done ( true ) ;
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
if ( ipod_reopen_rw ( & ipod ) < 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not open Ipod in RW mode " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( add_bootloader ( & ipod , m_tempfilename . toLatin1 ( ) . data ( ) , FILETYPE_DOT_IPOD ) = = 0 )
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Successfully added Bootloader " ) , LOGOK ) ;
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-07-28 11:32:32 +00:00
emit done ( false ) ;
2007-07-27 22:46:49 +00:00
ipod_close ( & ipod ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-27 22:46:49 +00:00
}
2007-09-15 22:57:07 +00:00
else
2007-07-27 22:46:49 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " failed to add Bootloader " ) , LOGERROR ) ;
2007-07-27 22:46:49 +00:00
ipod_close ( & ipod ) ;
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
}
2007-07-28 11:32:32 +00:00
}
/**************************************************
2007-09-15 22:57:07 +00:00
* * * sansa secific code
2007-07-28 11:32:32 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// reserves memory for sansapatcher
2007-08-08 20:16:33 +00:00
bool initSansapatcher ( )
2007-07-28 11:32:32 +00:00
{
2008-06-17 17:52:13 +00:00
if ( sansa_alloc_buffer ( & sansa_sectorbuf , BUFFER_SIZE ) < 0 ) return true ;
2007-07-28 11:32:32 +00:00
else return false ;
}
void BootloaderInstaller : : sansaPrepare ( )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Searching for sansas " ) , LOGINFO ) ;
2007-07-28 11:32:32 +00:00
struct sansa_t sansa ;
int n = sansa_scan ( & sansa ) ;
if ( n = = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " No Sansa found " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
2007-07-27 22:46:49 +00:00
}
2007-07-28 11:32:32 +00:00
if ( n > 1 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Too many Sansas found " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 11:32:32 +00:00
if ( m_install ) // Installation
{
2007-09-19 22:09:02 +00:00
QString url = m_bootloaderUrlBase + " /sandisk-sansa/ "
+ QString ( sansa . targetname ) + " / " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2007-07-31 19:11:44 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-28 11:32:32 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
2008-04-01 18:02:56 +00:00
2007-07-28 11:32:32 +00:00
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2007-07-28 11:32:32 +00:00
}
else // Uninstallation
{
2007-09-15 22:57:07 +00:00
2007-07-28 11:32:32 +00:00
if ( sansa_open ( & sansa , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not open Sansa " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 11:32:32 +00:00
if ( sansa_read_partinfo ( & sansa , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not read partitiontable " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-19 22:02:34 +00:00
int i = is_sansa ( & sansa ) ;
2007-07-28 11:32:32 +00:00
if ( i < 0 ) {
2007-09-19 22:02:34 +00:00
m_dp - > addItem ( tr ( " Disk is not a Sansa (%1), aborting. " ) . arg ( i ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
if ( sansa . hasoldbootloader )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " ******************************************** \n "
2008-04-02 21:17:35 +00:00
" OLD ROCKBOX INSTALLATION DETECTED, ABORTING. \n "
" You must reinstall the original Sansa firmware before running \n "
" sansapatcher for the first time. \n "
" See http://www.rockbox.org/wiki/SansaE200Install \n "
" ********************************************* \n " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( sansa_reopen_rw ( & sansa ) < 0 )
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not open Sansa in RW mode " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( sansa_delete_bootloader ( & sansa ) = = 0 )
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Successfully removed Bootloader " ) , LOGOK ) ;
2007-08-26 16:44:23 +00:00
removeInstallLog ( ) ;
2007-07-28 11:32:32 +00:00
emit done ( false ) ;
sansa_close ( & sansa ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-28 11:32:32 +00:00
}
2007-09-15 22:57:07 +00:00
else
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " --delete-bootloader failed. " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
sansa_close ( & sansa ) ;
2007-09-15 22:57:07 +00:00
return ;
}
}
2007-07-28 11:32:32 +00:00
}
void BootloaderInstaller : : sansaFinish ( )
{
struct sansa_t sansa ;
sansa_scan ( & sansa ) ;
2007-09-15 22:57:07 +00:00
2007-07-28 11:32:32 +00:00
if ( sansa_open ( & sansa , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not open Sansa " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 11:32:32 +00:00
if ( sansa_read_partinfo ( & sansa , 0 ) < 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " could not read partitiontable " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-19 22:02:34 +00:00
int i = is_sansa ( & sansa ) ;
2007-07-28 11:32:32 +00:00
if ( i < 0 ) {
2007-09-15 22:57:07 +00:00
2007-09-19 22:02:34 +00:00
m_dp - > addItem ( tr ( " Disk is not a Sansa (%1), aborting. " ) . arg ( i ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
if ( sansa . hasoldbootloader )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " ******************************************** \n "
2008-04-02 21:17:35 +00:00
" OLD ROCKBOX INSTALLATION DETECTED, ABORTING. \n "
" You must reinstall the original Sansa firmware before running \n "
" sansapatcher for the first time. \n "
" See http://www.rockbox.org/wiki/SansaE200Install \n "
" ********************************************* \n " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( sansa_reopen_rw ( & sansa ) < 0 )
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not open Sansa in RW mode " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
if ( sansa_add_bootloader ( & sansa , m_tempfilename . toLatin1 ( ) . data ( ) , FILETYPE_MI4 ) = = 0 )
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Successfully added Bootloader " ) , LOGOK ) ;
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-07-28 11:32:32 +00:00
emit done ( false ) ;
sansa_close ( & sansa ) ;
2007-09-15 22:57:07 +00:00
return ;
2007-07-28 11:32:32 +00:00
}
2007-09-15 22:57:07 +00:00
else
2007-07-28 11:32:32 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " failed to add Bootloader " ) , LOGERROR ) ;
2007-07-28 11:32:32 +00:00
sansa_close ( & sansa ) ;
emit done ( true ) ;
2007-09-15 22:57:07 +00:00
return ;
}
2007-07-28 11:32:32 +00:00
2007-07-27 22:46:49 +00:00
}
2007-07-28 14:38:25 +00:00
/**************************************************
2007-09-15 22:57:07 +00:00
* * * iriver / fwpatcher secific code
2007-07-28 14:38:25 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void BootloaderInstaller : : iriverPrepare ( )
{
char md5sum_str [ 32 ] ;
if ( ! FileMD5 ( m_origfirmware , md5sum_str ) ) {
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not MD5Sum original firmware " ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
/* Check firmware against md5sums in h120sums and h100sums */
series = 0 ;
table_entry = intable ( md5sum_str , & h120pairs [ 0 ] ,
sizeof ( h120pairs ) / sizeof ( struct sumpairs ) ) ;
if ( table_entry > = 0 ) {
series = 120 ;
}
2007-09-15 22:57:07 +00:00
else
2007-07-28 14:38:25 +00:00
{
table_entry = intable ( md5sum_str , & h100pairs [ 0 ] ,
sizeof ( h100pairs ) / sizeof ( struct sumpairs ) ) ;
2007-09-15 22:57:07 +00:00
if ( table_entry > = 0 )
2007-07-28 14:38:25 +00:00
{
series = 100 ;
}
2007-09-15 22:57:07 +00:00
else
2007-07-28 14:38:25 +00:00
{
table_entry = intable ( md5sum_str , & h300pairs [ 0 ] ,
sizeof ( h300pairs ) / sizeof ( struct sumpairs ) ) ;
if ( table_entry > = 0 )
series = 300 ;
}
}
if ( series = = 0 )
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Could not detect firmware type " ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
QString url = m_bootloaderUrlBase + " /iriver/ " + m_bootloadername ;
2007-09-15 22:57:07 +00:00
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Downloading file %1.%2 " )
2007-07-31 19:11:44 +00:00
. arg ( QFileInfo ( url ) . baseName ( ) , QFileInfo ( url ) . completeSuffix ( ) ) , LOGINFO ) ;
2007-07-28 14:38:25 +00:00
// temporary file needs to be opened to get the filename
downloadFile . open ( ) ;
m_tempfilename = downloadFile . fileName ( ) ;
downloadFile . close ( ) ;
// get the real file.
getter = new HttpGet ( this ) ;
getter - > setFile ( & downloadFile ) ;
2008-04-01 18:02:56 +00:00
2007-07-28 14:38:25 +00:00
// connect signals from HttpGet
connect ( getter , SIGNAL ( done ( bool ) ) , this , SLOT ( downloadDone ( bool ) ) ) ;
2008-06-03 20:08:25 +00:00
connect ( getter , SIGNAL ( dataReadProgress ( int , int ) ) , m_dp , SLOT ( setProgress ( int , int ) ) ) ;
2007-09-15 22:57:07 +00:00
connect ( m_dp , SIGNAL ( aborted ( ) ) , getter , SLOT ( abort ( ) ) ) ;
2008-04-01 18:02:56 +00:00
getter - > getFile ( QUrl ( url ) ) ;
2007-07-28 14:38:25 +00:00
}
void BootloaderInstaller : : iriverFinish ( )
{
// Patch firmware
char md5sum_str [ 32 ] ;
2007-07-29 21:59:11 +00:00
struct sumpairs * sums = 0 ;
int origin = 0 ;
2007-07-28 14:38:25 +00:00
/* get pointer to the correct bootloader.bin */
switch ( series ) {
case 100 :
sums = & h100pairs [ 0 ] ;
origin = 0x1f0000 ;
break ;
case 120 :
sums = & h120pairs [ 0 ] ;
origin = 0x1f0000 ;
break ;
case 300 :
sums = & h300pairs [ 0 ] ;
origin = 0x3f0000 ;
break ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
// temporary files needs to be opened to get the filename
QTemporaryFile firmwareBin , newBin , newHex ;
firmwareBin . open ( ) ;
newBin . open ( ) ;
newHex . open ( ) ;
QString firmwareBinName = firmwareBin . fileName ( ) ;
QString newBinName = newBin . fileName ( ) ;
QString newHexName = newHex . fileName ( ) ;
firmwareBin . close ( ) ;
newBin . close ( ) ;
newHex . close ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
// iriver decode
2008-05-23 19:05:20 +00:00
int result ;
if ( ( result = iriver_decode ( m_origfirmware , firmwareBinName , FALSE , STRIP_NONE ) ) < 0 )
{
QString error ;
switch ( result ) {
case - 1 : error = tr ( " Can't open input file " ) ; break ;
case - 2 : error = tr ( " Can't open output file " ) ; break ;
case - 3 : error = tr ( " invalid file: header length wrong " ) ; break ;
case - 4 : error = tr ( " invalid file: unrecognized header " ) ; break ;
case - 5 : error = tr ( " invalid file: \" length \" field wrong " ) ; break ;
case - 6 : error = tr ( " invalid file: \" length2 \" field wrong " ) ; break ;
case - 7 : error = tr ( " invalid file: internal checksum error " ) ; break ;
case - 8 : error = tr ( " invalid file: \" length3 \" field wrong " ) ; break ;
default : error = tr ( " unknown " ) ; break ;
}
m_dp - > addItem ( tr ( " Error in descramble: %1 " ) . arg ( error ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
firmwareBin . remove ( ) ;
newBin . remove ( ) ;
newHex . remove ( ) ;
emit done ( true ) ;
return ;
}
// mkboot
2008-05-23 19:05:20 +00:00
if ( ( result = mkboot ( firmwareBinName , newBinName , m_tempfilename , origin ) ) < 0 )
{
QString error ;
switch ( result ) {
case - 1 : error = tr ( " could not open input file " ) ; break ;
case - 2 : error = tr ( " reading header failed " ) ; break ;
case - 3 : error = tr ( " reading firmware failed " ) ; break ;
case - 4 : error = tr ( " can't open bootloader file " ) ; break ;
case - 5 : error = tr ( " reading bootloader file failed " ) ; break ;
case - 6 : error = tr ( " can't open output file " ) ; break ;
case - 7 : error = tr ( " writing output file failed " ) ; break ;
}
m_dp - > addItem ( tr ( " Error in patching: %1 " ) . arg ( error ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
firmwareBin . remove ( ) ;
newBin . remove ( ) ;
newHex . remove ( ) ;
emit done ( true ) ;
return ;
}
// iriver_encode
2008-05-23 19:05:20 +00:00
if ( ( result = iriver_encode ( newBinName , newHexName , FALSE ) ) < 0 )
{
QString error ;
switch ( result ) {
case - 1 : error = tr ( " Can't open input file " ) ; break ;
case - 2 : error = tr ( " Can't open output file " ) ; break ;
case - 3 : error = tr ( " invalid file: header length wrong " ) ; break ;
case - 4 : error = tr ( " invalid file: unrecognized header " ) ; break ;
case - 5 : error = tr ( " invalid file: \" length \" field wrong " ) ; break ;
case - 6 : error = tr ( " invalid file: \" length2 \" field wrong " ) ; break ;
case - 7 : error = tr ( " invalid file: internal checksum error " ) ; break ;
case - 8 : error = tr ( " invalid file: \" length3 \" field wrong " ) ; break ;
default : error = tr ( " unknown " ) ; break ;
}
m_dp - > addItem ( tr ( " Error in scramble: %1 " ) . arg ( error ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
firmwareBin . remove ( ) ;
newBin . remove ( ) ;
newHex . remove ( ) ;
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
/* now md5sum it */
2007-09-15 22:57:07 +00:00
if ( ! FileMD5 ( newHexName , md5sum_str ) )
2007-07-28 14:38:25 +00:00
{
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Error in checksumming " ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
firmwareBin . remove ( ) ;
newBin . remove ( ) ;
newHex . remove ( ) ;
emit done ( true ) ;
return ;
}
if ( strncmp ( sums [ table_entry ] . patched , md5sum_str , 32 ) = = 0 ) {
/* delete temp files */
firmwareBin . remove ( ) ;
newBin . remove ( ) ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
// Load patched Firmware to player
QString dest ;
if ( series = = 100 )
dest = m_mountpoint + " /ihp_100.hex " ;
else if ( series = = 120 )
dest = m_mountpoint + " /ihp_120.hex " ;
else if ( series = = 300 )
dest = m_mountpoint + " /H300.hex " ;
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
// copy file
2007-08-26 16:44:23 +00:00
QFile destfile ( dest ) ;
if ( destfile . exists ( ) ) destfile . remove ( ) ;
2007-07-28 14:38:25 +00:00
if ( ! newHex . copy ( dest ) )
{
2007-07-29 18:07:31 +00:00
m_dp - > addItem ( tr ( " Could not copy: %1 to %2 " )
2007-07-31 19:11:44 +00:00
. arg ( newHexName , dest ) , LOGERROR ) ;
2007-07-28 14:38:25 +00:00
emit done ( true ) ;
return ;
}
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
downloadFile . remove ( ) ;
newHex . remove ( ) ;
2007-08-26 16:44:23 +00:00
createInstallLog ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-31 19:11:44 +00:00
m_dp - > addItem ( tr ( " Bootloader install finished successfully. " ) , LOGOK ) ;
2007-08-15 14:16:20 +00:00
m_dp - > addItem ( tr ( " To finish the Bootloader installation, follow the steps below. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 1. Eject/Unmount your Device. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 2. Boot into the original Firmware. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 3. Use the Firmware flash option in the Original Firmware. " ) , LOGINFO ) ;
m_dp - > addItem ( tr ( " 4. Reboot. " ) , LOGINFO ) ;
2007-07-29 18:07:31 +00:00
m_dp - > abort ( ) ;
2007-09-15 22:57:07 +00:00
2007-07-28 14:38:25 +00:00
emit done ( false ) ; // success
}
2008-04-02 21:17:35 +00:00