-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 2 |
2 files changed, 32 insertions, 16 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 494603b..985e2bd 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp @@ -33,54 +33,54 @@ _;:, .> :=|. This file is free software; you can #include <opie2/oprocess.h> #include <qpe/fileselector.h> #include <qpe/resource.h> #include <qpe/storage.h> #include <qapplication.h> #include <qcombobox.h> #include <qfileinfo.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qmap.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <sys/vfs.h> #include "opackagemanager.h" InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, OPackage::Command command1, const QStringList &packages1, OPackage::Command command2, const QStringList &packages2, OPackage::Command command3, const QStringList &packages3 ) - : QWidget( 0x0 ) + : QWidget( 0l ) , m_packman( pm ) , m_installFound( false ) , m_numCommands( 0 ) , m_currCommand( 0 ) - , m_destItem( 0x0 ) + , m_destItem( 0l ) { // Save command/package list information if ( command1 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command1; m_packages[ m_numCommands ] = packages1; ++m_numCommands; if ( command1 == OPackage::Install ) m_installFound = true; } if ( command2 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command2; m_packages[ m_numCommands ] = packages2; ++m_numCommands; if ( command2 == OPackage::Install ) m_installFound = true; } if ( command3 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command3; m_packages[ m_numCommands ] = packages3; @@ -95,50 +95,50 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap parent->setCaption( caption ); QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); if ( m_installFound ) { QLabel *label = new QLabel( tr( "Destination" ), this ); layout->addWidget( label, 0, 0 ); m_destination = new QComboBox( this ); m_destination->insertStringList( m_packman->destinations() ); layout->addWidget( m_destination, 0, 1 ); connect( m_destination, SIGNAL(highlighted(const QString&)), this, SLOT(slotDisplayAvailSpace(const QString&)) ); label = new QLabel( tr( "Space Avail" ), this ); layout->addWidget( label, 1, 0 ); m_availSpace = new QLabel( this ); layout->addWidget( m_availSpace, 1, 1 ); // TODO - select correct destination slotDisplayAvailSpace( m_destination->currentText() ); } else { - m_destination = 0x0; - m_availSpace = 0x0; + m_destination = 0l; + m_availSpace = 0l; } QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); groupBox->layout()->setSpacing( 0 ); groupBox->layout()->setMargin( 4 ); QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); m_output = new QMultiLineEdit( groupBox ); m_output->setReadOnly( true ); groupBoxLayout->addWidget( m_output ); layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); layout->addWidget( m_btnStart, 3, 0 ); connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); layout->addWidget( m_btnOptions, 3, 1 ); connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); // Display packages being acted upon in output widget for( int i = 0; i < m_numCommands; i++ ) { if ( !m_packages[ i ].isEmpty() ) @@ -233,95 +233,111 @@ void InstallDlg::slotBtnStart() if ( m_installFound ) { dest = m_destination->currentText(); m_destination->setEnabled( false ); } m_btnOptions->setEnabled( false ); if ( m_numCommands > 1 ) { m_btnStart->setText( tr( "Abort" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); } else { m_btnStart->setEnabled( false ); } Opie::Core::OProcess process( this ); for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) { // Execute next command m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 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 ) ) + if ( m_command[ m_currCommand ] == OPackage::Remove ) { - //m_packman->findPackage( m_packages[ m_currCommand ]->destination() != "root"*/ ) + // Unlink application if the package was removed // 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 ); + slotProcessDone( 0l ); m_output->append( tr( "Unable to run ipkg-link." ) ); m_output->setCursorPosition( m_output->numLines(), 0 ); return; } } + } + else if ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) + { + // Link applications in the destination directory + m_output->append( tr( "Running ipkg-link to link packages in '%1'." ).arg( dest ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + + QString destPath; + OConfItem *destItem = m_packman->findConfItem( OConfItem::Destination, dest ); + + // Execute ipkg-link + process.clearArguments(); + process << "ipkg-link" + << "mount" + << destItem->value(); + if ( !process.start( Opie::Core::OProcess::Block, + Opie::Core::OProcess::NoCommunication ) ) + { + slotProcessDone( 0l ); + m_output->append( tr( "Unable to run ipkg-link." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + return; + } } } - slotProcessDone( 0x0 ); + slotProcessDone( 0l ); } void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) { 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 m_btnStart->setEnabled( true ); m_btnStart->setText( tr( "Close" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); m_btnOptions->setEnabled( true ); m_btnOptions->setText( tr( "Save output" ) ); m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); } void InstallDlg::slotBtnOptions() diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index eabb717..7a64fe0 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h @@ -34,49 +34,49 @@ _;:, .> :=|. This file is free software; you can #include "opackage.h" class QComboBox; class QLabel; class QMultiLineEdit; class QPushButton; class OConfItem; class OPackageManager; namespace Opie { namespace Core { class OProcess; } } class InstallDlg : public QWidget { Q_OBJECT public: - InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, + InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, const QString &caption = QString::null, OPackage::Command command1 = OPackage::NotDefined, const QStringList &packages1 = QStringList(), OPackage::Command command2 = OPackage::NotDefined, const QStringList &packages2 = QStringList(), OPackage::Command command3 = OPackage::NotDefined, const QStringList &packages3 = QStringList() ); private: OPackageManager *m_packman; // Pointer to application instance of package manager bool m_installFound; // Indicates if an install is being done, controls display of // destination selection, available space // UI controls QComboBox *m_destination; // Destination selection list QLabel *m_availSpace; // Text label to display available space on selected destination QMultiLineEdit *m_output; // Multi-line edit to display status QPushButton *m_btnStart; // Start/abort/close button QPushButton *m_btnOptions; // Installation options button // Commands and packages to execute int m_numCommands; // Number of commands to be executed int m_currCommand; // Number of currently executing command |