* more of the same

git-svn-id: http://wiiqt.googlecode.com/svn/trunk@90 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
giantpune 2011-05-17 19:02:45 +00:00
parent a747124f2b
commit 573d64a87b
5 changed files with 126 additions and 126 deletions

View File

@ -165,7 +165,7 @@ private:
signals: signals:
void SendError( const QString &message, NusJob job );//send an errer and the title the error is about void SendError( const QString &message, NusJob job );//send an errer and the title the error is about
//send an errer and the title the error is about, no more jobs will be done, and the SendDone signal will not be emited //send an errer and the title the error is about, no more jobs will be done, and the SendDone signal will not be emited
void SendFatalErrorError( const QString &message, NusJob job );//currently not used void SendFatalErrorError( const QString &message, const NusJob &job );//currently not used
void SendDone();//message that all jobs are done void SendDone();//message that all jobs are done
//send progress about the currently downloading job //send progress about the currently downloading job
@ -178,13 +178,13 @@ signals:
void SendTitleProgress( int ); void SendTitleProgress( int );
//sends a completed job to whoever is listening //sends a completed job to whoever is listening
void SendData( NusJob ); void SendData( const NusJob & );
//a file is done downloading //a file is done downloading
void finished(); void finished();
//send pretty text about what is happening //send pretty text about what is happening
void SendText( QString ); void SendText( const QString & );
//maybe this one is redundant //maybe this one is redundant
//void SendJobFinished( downloadJob ); //void SendJobFinished( downloadJob );

View File

@ -8,23 +8,23 @@
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this ) MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this )
{ {
ui->setupUi(this); ui->setupUi(this);
ui->mainToolBar->setVisible( false );//hide toolbar for now ui->mainToolBar->setVisible( false );//hide toolbar for now
//resize buttons to be same size //resize buttons to be same size
QFontMetrics fm( fontMetrics() ); QFontMetrics fm( fontMetrics() );
int max = fm.width( ui->pushButton_CachePathBrowse->text() ); int max = fm.width( ui->pushButton_CachePathBrowse->text() );
max = MAX( max, fm.width( ui->pushButton_decFolder->text() ) ); max = MAX( max, fm.width( ui->pushButton_decFolder->text() ) );
max = MAX( max, fm.width( ui->pushButton_GetTitle->text() ) ); max = MAX( max, fm.width( ui->pushButton_GetTitle->text() ) );
max = MAX( max, fm.width( ui->pushButton_nandPath->text() ) ); max = MAX( max, fm.width( ui->pushButton_nandPath->text() ) );
max = MAX( max, fm.width( ui->pushButton_wad->text() ) ); max = MAX( max, fm.width( ui->pushButton_wad->text() ) );
max += 15; max += 15;
ui->pushButton_CachePathBrowse->setMinimumWidth( max ); ui->pushButton_CachePathBrowse->setMinimumWidth( max );
ui->pushButton_decFolder->setMinimumWidth( max ); ui->pushButton_decFolder->setMinimumWidth( max );
ui->pushButton_GetTitle->setMinimumWidth( max ); ui->pushButton_GetTitle->setMinimumWidth( max );
ui->pushButton_nandPath->setMinimumWidth( max ); ui->pushButton_nandPath->setMinimumWidth( max );
ui->pushButton_wad->setMinimumWidth( max ); ui->pushButton_wad->setMinimumWidth( max );
Wad::SetGlobalCert( QByteArray( (const char*)&certs_dat, CERTS_DAT_SIZE ) ); Wad::SetGlobalCert( QByteArray( (const char*)&certs_dat, CERTS_DAT_SIZE ) );
@ -33,48 +33,48 @@ MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::M
connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) ); connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) );
connect( &nus, SIGNAL( SendError( const QString &, NusJob ) ), this, SLOT( GetError( const QString &, NusJob ) ) ); connect( &nus, SIGNAL( SendError( const QString &, const NusJob & ) ), this, SLOT( GetError( const QString &, const NusJob & ) ) );
connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) ); connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) );
connect( &nus, SIGNAL( SendData( NusJob ) ), this, SLOT( ReceiveTitleFromNus( NusJob) ) ); connect( &nus, SIGNAL( SendData( const NusJob & ) ), this, SLOT( ReceiveTitleFromNus( const NusJob & ) ) );
LoadSettings(); LoadSettings();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
SaveSettings(); SaveSettings();
delete ui; delete ui;
} }
void MainWindow::SaveSettings() void MainWindow::SaveSettings()
{ {
QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this ); QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this );
//settings specific to this program //settings specific to this program
s.beginGroup( "nusDownloader" ); s.beginGroup( "nusDownloader" );
//window geometry //window geometry
s.setValue( "size", size() ); s.setValue( "size", size() );
s.setValue( "pos", pos() ); s.setValue( "pos", pos() );
//which radio button is selected //which radio button is selected
quint8 val = 0; quint8 val = 0;
if( ui->radioButton_folder->isChecked() ) if( ui->radioButton_folder->isChecked() )
val = 1; val = 1;
else if( ui->radioButton_wad->isChecked() ) else if( ui->radioButton_wad->isChecked() )
val = 2; val = 2;
s.setValue( "radio", val ); s.setValue( "radio", val );
s.setValue( "folder", ui->lineEdit_extractPath->text() ); s.setValue( "folder", ui->lineEdit_extractPath->text() );
s.setValue( "nuswads", ui->lineEdit_wad->text() ); s.setValue( "nuswads", ui->lineEdit_wad->text() );
s.endGroup(); s.endGroup();
//settings shared in multiple programs //settings shared in multiple programs
//paths //paths
s.beginGroup( "paths" ); s.beginGroup( "paths" );
s.setValue( "nusCache", ui->lineEdit_cachePath->text() ); s.setValue( "nusCache", ui->lineEdit_cachePath->text() );
s.setValue( "sneek", ui->lineEdit_nandPath->text() ); s.setValue( "sneek", ui->lineEdit_nandPath->text() );
s.endGroup(); s.endGroup();
} }
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -85,42 +85,42 @@ void MainWindow::SaveSettings()
void MainWindow::LoadSettings() void MainWindow::LoadSettings()
{ {
QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this ); QSettings s( QSettings::IniFormat, QSettings::UserScope, "WiiQt", "examples", this );
//settings specific to this program //settings specific to this program
s.beginGroup( "nusDownloader" ); s.beginGroup( "nusDownloader" );
resize( s.value("size", QSize( 585, 457 ) ).toSize() ); resize( s.value("size", QSize( 585, 457 ) ).toSize() );
move( s.value("pos", QPoint( 2, 72 ) ).toPoint() ); move( s.value("pos", QPoint( 2, 72 ) ).toPoint() );
quint8 radio = s.value( "radio", 0 ).toInt(); quint8 radio = s.value( "radio", 0 ).toInt();
if( radio == 1 ) if( radio == 1 )
ui->radioButton_folder->setChecked( true ); ui->radioButton_folder->setChecked( true );
else if( radio == 2 ) else if( radio == 2 )
ui->radioButton_wad->setChecked( true ); ui->radioButton_wad->setChecked( true );
ui->lineEdit_extractPath->setText( s.value( "folder", PATH_PREFIX + "/downloaded" ).toString() ); ui->lineEdit_extractPath->setText( s.value( "folder", PATH_PREFIX + "/downloaded" ).toString() );
ui->lineEdit_wad->setText( s.value( "nuswads", PATH_PREFIX + "/wads" ).toString() ); ui->lineEdit_wad->setText( s.value( "nuswads", PATH_PREFIX + "/wads" ).toString() );
s.endGroup(); s.endGroup();
//settings shared in multiple programs //settings shared in multiple programs
s.beginGroup( "paths" ); s.beginGroup( "paths" );
QString cachePath = s.value( "nusCache", PATH_PREFIX + "/NUS_cache" ).toString(); QString cachePath = s.value( "nusCache", PATH_PREFIX + "/NUS_cache" ).toString();
QString nandPath = s.value( "sneek" ).toString(); QString nandPath = s.value( "sneek" ).toString();
ui->lineEdit_cachePath->setText( cachePath ); ui->lineEdit_cachePath->setText( cachePath );
ui->lineEdit_nandPath->setText( nandPath ); ui->lineEdit_nandPath->setText( nandPath );
if( !nandPath.isEmpty() ) if( !nandPath.isEmpty() )
nand.SetPath( QFileInfo( nandPath ).absoluteFilePath() ); nand.SetPath( QFileInfo( nandPath ).absoluteFilePath() );
if( !cachePath.isEmpty() ) if( !cachePath.isEmpty() )
nus.SetCachePath( QFileInfo( cachePath ).absoluteFilePath() ); nus.SetCachePath( QFileInfo( cachePath ).absoluteFilePath() );
s.endGroup(); s.endGroup();
} }
//some slots to respond to the NUS downloader //some slots to respond to the NUS downloader
void MainWindow::GetError( const QString &message, NusJob job ) void MainWindow::GetError( const QString &message, const NusJob &job )
{ {
QString dataStuff = QString( "%1 items:" ).arg( job.data.size() ); QString dataStuff = QString( "%1 items:" ).arg( job.data.size() );
for( int i = 0; i < job.data.size(); i++ ) for( int i = 0; i < job.data.size(); i++ )
@ -155,14 +155,14 @@ void MainWindow::NusIsDone()
} }
else if( ui->radioButton_nand->isChecked() ) else if( ui->radioButton_nand->isChecked() )
{ {
//check if IOS35 is present in nand dump - needed for sneek //check if IOS35 is present in nand dump - needed for sneek
QByteArray tmdBA = nand.GetFile( "/title/00000001/00000023/content/title.tmd" ); QByteArray tmdBA = nand.GetFile( "/title/00000001/00000023/content/title.tmd" );
if( tmdBA.isEmpty() ) if( tmdBA.isEmpty() )
{ {
ui->plainTextEdit_log->appendHtml( tr( "IOS35 not found on nand. Getting it now...") ); ui->plainTextEdit_log->appendHtml( tr( "IOS35 not found on nand. Getting it now...") );
nus.Get( 0x100000023ull, true ); nus.Get( 0x100000023ull, true );
return; return;
} }
ui->lineEdit_nandPath->setEnabled( true ); ui->lineEdit_nandPath->setEnabled( true );
ui->pushButton_nandPath->setEnabled( true ); ui->pushButton_nandPath->setEnabled( true );
@ -186,13 +186,13 @@ void MainWindow::NusIsDone()
nand.SetSettingTxt( set ); nand.SetSettingTxt( set );
} }
/*QMap< quint64, quint16 > t = nand.GetInstalledTitles(); /*QMap< quint64, quint16 > t = nand.GetInstalledTitles();
QMap< quint64, quint16 >::iterator i = t.begin(); QMap< quint64, quint16 >::iterator i = t.begin();
while( i != t.end() ) while( i != t.end() )
{ {
QString title = QString( "%1v%2" ).arg( i.key(), 16, 16, QChar( '0' ) ).arg( i.value() ); QString title = QString( "%1v%2" ).arg( i.key(), 16, 16, QChar( '0' ) ).arg( i.value() );
qDebug() << "title:" << title; qDebug() << "title:" << title;
i++; i++;
}*/ }*/
} }
else if( ui->radioButton_wad->isChecked() ) else if( ui->radioButton_wad->isChecked() )
{ {
@ -205,7 +205,7 @@ void MainWindow::NusIsDone()
ui->radioButton_wad->setEnabled( true ); ui->radioButton_wad->setEnabled( true );
} }
void MainWindow::ReceiveTitleFromNus( NusJob job ) void MainWindow::ReceiveTitleFromNus( const NusJob &job )
{ {
QString str = tr( "Received a completed download from NUS" ); QString str = tr( "Received a completed download from NUS" );
QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version ); QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version );
@ -223,7 +223,7 @@ void MainWindow::ReceiveTitleFromNus( NusJob job )
if( ok ) if( ok )
ShowMessage( tr( "Installed %1 title to nand" ).arg( title ) ); ShowMessage( tr( "Installed %1 title to nand" ).arg( title ) );
else else
ShowMessage( tr( "<b>Error installing %1 title to nand</b>" ).arg( title ) ); ShowMessage( tr( "<b>Error installing %1 title to nand</b>" ).arg( title ) );
} }
else if( ui->radioButton_wad->isChecked() ) else if( ui->radioButton_wad->isChecked() )
{ {
@ -314,7 +314,7 @@ void MainWindow::on_pushButton_GetTitle_clicked()
//ui->progressBar_dl->setValue( 0 ); //ui->progressBar_dl->setValue( 0 );
//ui->progressBar_title->setValue( 0 ); //ui->progressBar_title->setValue( 0 );
//ui->progressBar_whole->setValue( 0 ); //ui->progressBar_whole->setValue( 0 );
nus.SetCachePath( QFileInfo( ui->lineEdit_cachePath->text() ).absoluteFilePath() ); nus.SetCachePath( QFileInfo( ui->lineEdit_cachePath->text() ).absoluteFilePath() );
if( wholeUpdate ) if( wholeUpdate )
{ {
@ -406,34 +406,34 @@ void MainWindow::on_actionFlush_triggered()
//nand-dump -> ImportWad //nand-dump -> ImportWad
void MainWindow::on_actionImportWad_triggered() void MainWindow::on_actionImportWad_triggered()
{ {
if( nand.GetPath() != ui->lineEdit_nandPath->text() && if( nand.GetPath() != ui->lineEdit_nandPath->text() &&
!nand.SetPath( ui->lineEdit_nandPath->text() ) ) !nand.SetPath( ui->lineEdit_nandPath->text() ) )
{ {
ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" ).arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) ); ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" ).arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) );
return; return;
} }
QString path = ui->lineEdit_wad->text().isEmpty() ? QString path = ui->lineEdit_wad->text().isEmpty() ?
QCoreApplication::applicationDirPath() : ui->lineEdit_wad->text(); QCoreApplication::applicationDirPath() : ui->lineEdit_wad->text();
QString fn = QFileDialog::getOpenFileName( this, QString fn = QFileDialog::getOpenFileName( this,
tr("Wad files(*.wad)"), tr("Wad files(*.wad)"),
path, path,
tr("WadFiles (*.wad)")); tr("WadFiles (*.wad)"));
if(fn == "") return; if(fn == "") return;
QByteArray data = ReadFile( fn ); QByteArray data = ReadFile( fn );
if( data.isEmpty() ) if( data.isEmpty() )
return; return;
Wad wad(data); Wad wad(data);
if( !wad.IsOk() ) { if( !wad.IsOk() ) {
ShowMessage( tr( "Wad data not ok" ) );; ShowMessage( tr( "Wad data not ok" ) );;
return; return;
} }
bool ok = nand.InstallWad( wad ); bool ok = nand.InstallWad( wad );
if( ok ) if( ok )
ShowMessage( tr( "Installed %1 title to nand" ).arg( wad.WadName() ) ); ShowMessage( tr( "Installed %1 title to nand" ).arg( wad.WadName() ) );
else else
ShowMessage( tr( "<b>Error %1 title to nand</b>" ).arg( wad.WadName() ) ); ShowMessage( tr( "<b>Error %1 title to nand</b>" ).arg( wad.WadName() ) );
} }
//save a NUS job to a folder //save a NUS job to a folder
@ -489,14 +489,14 @@ void MainWindow::SaveJobToFolder( NusJob job )
for( quint16 i = 0; i < cnt; i++ )//write all the contents in the new folder. if the job is decrypted, append ".app" to the end of their names for( quint16 i = 0; i < cnt; i++ )//write all the contents in the new folder. if the job is decrypted, append ".app" to the end of their names
{ {
QString appName = t.Cid( i ); QString appName = t.Cid( i );
QByteArray stuff = job.data.takeFirst(); QByteArray stuff = job.data.takeFirst();
if( job.decrypt ) if( job.decrypt )
{ {
appName += ".app"; appName += ".app";
//qDebug() << "resizing from" << hex << stuff.size() << "to" << (quint32)t.Size( i ); //qDebug() << "resizing from" << hex << stuff.size() << "to" << (quint32)t.Size( i );
//stuff.resize( t.Size( i ) ); //stuff.resize( t.Size( i ) );
} }
if( !WriteFile( d.absoluteFilePath( appName ), stuff ) ) if( !WriteFile( d.absoluteFilePath( appName ), stuff ) )
{ {
ShowMessage( "<b>Error writing " + d.absoluteFilePath( appName ) + "!<\b>" ); ShowMessage( "<b>Error writing " + d.absoluteFilePath( appName ) + "!<\b>" );
return; return;

View File

@ -29,24 +29,24 @@ private:
void SaveJobToFolder( NusJob job ); void SaveJobToFolder( NusJob job );
void SaveJobToWad( NusJob job ); void SaveJobToWad( NusJob job );
//settings //settings
void SaveSettings(); void SaveSettings();
void LoadSettings(); void LoadSettings();
public slots: public slots:
//slots for getting info from the NUS downloader //slots for getting info from the NUS downloader
void GetError( const QString &message, NusJob job ); void GetError( const QString &message, const NusJob &job );
void NusIsDone(); void NusIsDone();
void ReceiveTitleFromNus( NusJob job ); void ReceiveTitleFromNus( const NusJob &job );
private slots: private slots:
void on_pushButton_CachePathBrowse_clicked(); void on_pushButton_CachePathBrowse_clicked();
void on_actionFlush_triggered(); void on_actionFlush_triggered();
void on_actionSetting_txt_triggered(); void on_actionSetting_txt_triggered();
void on_actionImportWad_triggered(); void on_actionImportWad_triggered();
void on_pushButton_wad_clicked(); void on_pushButton_wad_clicked();
void on_pushButton_decFolder_clicked(); void on_pushButton_decFolder_clicked();
void on_pushButton_nandPath_clicked(); void on_pushButton_nandPath_clicked();

View File

@ -47,9 +47,9 @@ MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::M
connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) );
connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) ); connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) );
connect( &nus, SIGNAL( SendError( const QString &, NusJob ) ), this, SLOT( GetError( const QString &, NusJob ) ) ); connect( &nus, SIGNAL( SendError( const QString &, const NusJob & ) ), this, SLOT( GetError( const QString &, const NusJob & ) ) );
connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) ); connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) );
connect( &nus, SIGNAL( SendData( NusJob ) ), this, SLOT( ReceiveTitleFromNus( NusJob ) ) ); connect( &nus, SIGNAL( SendData( const NusJob & ) ), this, SLOT( ReceiveTitleFromNus( const NusJob & ) ) );
//connect to the nand.bin to get text and crap from it //connect to the nand.bin to get text and crap from it
connect( &nand, SIGNAL( SendError( const QString & ) ), this, SLOT( GetError( const QString & ) ) ); connect( &nand, SIGNAL( SendError( const QString & ) ), this, SLOT( GetError( const QString & ) ) );
@ -109,7 +109,7 @@ void MainWindow::LoadSettings()
} }
//some slots to respond to the NUS downloader //some slots to respond to the NUS downloader
void MainWindow::GetError( const QString &message, NusJob job ) void MainWindow::GetError( const QString &message, const NusJob &job )
{ {
QString dataStuff = QString( "%1 items:" ).arg( job.data.size() ); QString dataStuff = QString( "%1 items:" ).arg( job.data.size() );
for( int i = 0; i < job.data.size(); i++ ) for( int i = 0; i < job.data.size(); i++ )
@ -190,7 +190,7 @@ void MainWindow::NusIsDone()
} }
} }
void MainWindow::ReceiveTitleFromNus( NusJob job ) void MainWindow::ReceiveTitleFromNus( const NusJob &job )
{ {
QString str = tr( "Received a completed download from NUS" ); QString str = tr( "Received a completed download from NUS" );
//QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version ); //QString title = QString( "%1v%2" ).arg( job.tid, 16, 16, QChar( '0' ) ).arg( job.version );

View File

@ -56,10 +56,10 @@ private:
public slots: public slots:
//slots for getting info from the NUS downloader //slots for getting info from the NUS downloader
void GetError( const QString &message, NusJob job ); void GetError( const QString &message, const NusJob &job );
void GetError( const QString &message ); void GetError( const QString &message );
void NusIsDone(); void NusIsDone();
void ReceiveTitleFromNus( NusJob job ); void ReceiveTitleFromNus( const NusJob &job );
private slots: private slots:
void on_actionFormat_triggered(); void on_actionFormat_triggered();