Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 781f8f5..494603b 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp @@ -52,3 +52,3 @@ _;:, .> :=|. This file is free software; you can -InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, +InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, OPackage::Command command1, const QStringList &packages1, @@ -58,2 +58,3 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap , m_packman( pm ) + , m_installFound( false ) , m_numCommands( 0 ) @@ -68,2 +69,5 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap ++m_numCommands; + + if ( command1 == OPackage::Install ) + m_installFound = true; } @@ -74,2 +78,5 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap ++m_numCommands; + + if ( command2 == OPackage::Install ) + m_installFound = true; } @@ -80,2 +87,5 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap ++m_numCommands; + + if ( command3 == OPackage::Install ) + m_installFound = true; } @@ -88,3 +98,3 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap - if ( showDestInfo ) + if ( m_installFound ) { @@ -222,3 +232,3 @@ void InstallDlg::slotBtnStart() QString dest; - if ( m_destination ) + if ( m_installFound ) { @@ -239,2 +249,3 @@ void InstallDlg::slotBtnStart() + Opie::Core::OProcess process( this ); for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) @@ -244,29 +255,50 @@ void InstallDlg::slotBtnStart() this, SLOT(slotOutput(char*)), true ); + + // Link/Unlink application if the package was removed from or installed to a destination + // other than root + if ( ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) || + ( m_command[ m_currCommand ] == OPackage::Remove ) ) + { + //m_packman->findPackage( m_packages[ m_currCommand ]->destination() != "root"*/ ) + + // Loop through all package names in the command group + for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); + it != m_packages[ m_currCommand ].end(); + ++it ) + { + OPackage *currPackage = m_packman->findPackage( (*it) ); + + // Skip package if it is not found or being removed from 'root' + if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && + currPackage->destination() == "root" ) ) + continue; + + // Display feedback to user + if ( m_command[ m_currCommand ] == OPackage::Install ) + m_output->append( tr( QString( "Running ipkg-link to link package '%1'." ) + .arg( currPackage->name() ) ) ); + else + m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) + .arg( currPackage->name() ) ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + + // Execute ipkg-link + process.clearArguments(); + process << "ipkg-link" + << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) + << currPackage->name(); + if ( !process.start( Opie::Core::OProcess::Block, + Opie::Core::OProcess::NoCommunication ) ) + { + slotProcessDone( 0x0 ); + m_output->append( tr( "Unable to run ipkg-link." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + return; + } + } + + } } - slotProcessDone(0l); - - // Get destination -/* - if ( dest == "root" ) - { - slotProcessDone(0l); - return; - } - - m_destItem = m_packman->findConfItem( OConfItem::Destination, dest ); - if ( m_destItem ) - { - QString path = m_destItem->value(); - Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" ); - connect( process, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT(slotProcessDone(Opie::Core::OProcess*)) ); - - *process << "ipkg-link" << "mount" << path; - if ( !process->start( Opie::Core::OProcess::NotifyOnExit, - Opie::Core::OProcess::NoCommunication ) ) - slotProcessDone( 0l ); - m_output->append( tr( "Starting ipkg-link to link installed applications." ) ); - m_output->setCursorPosition( m_output->numLines(), 0 ); - } -*/ + + slotProcessDone( 0x0 ); } @@ -275,7 +307,11 @@ void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) { - delete proc; - - m_output->append( tr( "The package linking is done." ) ); - m_output->setCursorPosition( m_output->numLines(), 0 ); - + if ( proc ) + { + // Display message pnly if linking was done + m_output->append( tr( "The package linking is done." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + + delete proc; + } + // All commands executed, allow user to close dialog |