-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 52 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 2 |
2 files changed, 35 insertions, 19 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 | |||
@@ -45,30 +45,30 @@ _;:, .> :=|. This file is free software; you can | |||
45 | #include <qmap.h> | 45 | #include <qmap.h> |
46 | #include <qmultilineedit.h> | 46 | #include <qmultilineedit.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | 48 | ||
49 | #include <sys/vfs.h> | 49 | #include <sys/vfs.h> |
50 | 50 | ||
51 | #include "opackagemanager.h" | 51 | #include "opackagemanager.h" |
52 | 52 | ||
53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, | 53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, |
54 | OPackage::Command command1, const QStringList &packages1, | 54 | OPackage::Command command1, const QStringList &packages1, |
55 | OPackage::Command command2, const QStringList &packages2, | 55 | OPackage::Command command2, const QStringList &packages2, |
56 | OPackage::Command command3, const QStringList &packages3 ) | 56 | OPackage::Command command3, const QStringList &packages3 ) |
57 | : QWidget( 0x0 ) | 57 | : QWidget( 0l ) |
58 | , m_packman( pm ) | 58 | , m_packman( pm ) |
59 | , m_installFound( false ) | 59 | , m_installFound( false ) |
60 | , m_numCommands( 0 ) | 60 | , m_numCommands( 0 ) |
61 | , m_currCommand( 0 ) | 61 | , m_currCommand( 0 ) |
62 | , m_destItem( 0x0 ) | 62 | , m_destItem( 0l ) |
63 | { | 63 | { |
64 | // Save command/package list information | 64 | // Save command/package list information |
65 | if ( command1 != OPackage::NotDefined ) | 65 | if ( command1 != OPackage::NotDefined ) |
66 | { | 66 | { |
67 | m_command[ m_numCommands ] = command1; | 67 | m_command[ m_numCommands ] = command1; |
68 | m_packages[ m_numCommands ] = packages1; | 68 | m_packages[ m_numCommands ] = packages1; |
69 | ++m_numCommands; | 69 | ++m_numCommands; |
70 | 70 | ||
71 | if ( command1 == OPackage::Install ) | 71 | if ( command1 == OPackage::Install ) |
72 | m_installFound = true; | 72 | m_installFound = true; |
73 | } | 73 | } |
74 | if ( command2 != OPackage::NotDefined ) | 74 | if ( command2 != OPackage::NotDefined ) |
@@ -107,26 +107,26 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
107 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 107 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
108 | 108 | ||
109 | label = new QLabel( tr( "Space Avail" ), this ); | 109 | label = new QLabel( tr( "Space Avail" ), this ); |
110 | layout->addWidget( label, 1, 0 ); | 110 | layout->addWidget( label, 1, 0 ); |
111 | m_availSpace = new QLabel( this ); | 111 | m_availSpace = new QLabel( this ); |
112 | layout->addWidget( m_availSpace, 1, 1 ); | 112 | layout->addWidget( m_availSpace, 1, 1 ); |
113 | 113 | ||
114 | // TODO - select correct destination | 114 | // TODO - select correct destination |
115 | slotDisplayAvailSpace( m_destination->currentText() ); | 115 | slotDisplayAvailSpace( m_destination->currentText() ); |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
119 | m_destination = 0x0; | 119 | m_destination = 0l; |
120 | m_availSpace = 0x0; | 120 | m_availSpace = 0l; |
121 | } | 121 | } |
122 | 122 | ||
123 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 123 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
124 | groupBox->layout()->setSpacing( 0 ); | 124 | groupBox->layout()->setSpacing( 0 ); |
125 | groupBox->layout()->setMargin( 4 ); | 125 | groupBox->layout()->setMargin( 4 ); |
126 | 126 | ||
127 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 127 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
128 | m_output = new QMultiLineEdit( groupBox ); | 128 | m_output = new QMultiLineEdit( groupBox ); |
129 | m_output->setReadOnly( true ); | 129 | m_output->setReadOnly( true ); |
130 | groupBoxLayout->addWidget( m_output ); | 130 | groupBoxLayout->addWidget( m_output ); |
131 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 131 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
132 | 132 | ||
@@ -245,71 +245,87 @@ void InstallDlg::slotBtnStart() | |||
245 | else | 245 | else |
246 | { | 246 | { |
247 | m_btnStart->setEnabled( false ); | 247 | m_btnStart->setEnabled( false ); |
248 | } | 248 | } |
249 | 249 | ||
250 | Opie::Core::OProcess process( this ); | 250 | Opie::Core::OProcess process( this ); |
251 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 251 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
252 | { | 252 | { |
253 | // Execute next command | 253 | // Execute next command |
254 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 254 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
255 | this, SLOT(slotOutput(char*)), true ); | 255 | this, SLOT(slotOutput(char*)), true ); |
256 | 256 | ||
257 | // Link/Unlink application if the package was removed from or installed to a destination | 257 | if ( m_command[ m_currCommand ] == OPackage::Remove ) |
258 | // other than root | ||
259 | if ( ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) || | ||
260 | ( m_command[ m_currCommand ] == OPackage::Remove ) ) | ||
261 | { | 258 | { |
262 | //m_packman->findPackage( m_packages[ m_currCommand ]->destination() != "root"*/ ) | 259 | // Unlink application if the package was removed |
263 | 260 | ||
264 | // Loop through all package names in the command group | 261 | // Loop through all package names in the command group |
265 | for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); | 262 | for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); |
266 | it != m_packages[ m_currCommand ].end(); | 263 | it != m_packages[ m_currCommand ].end(); |
267 | ++it ) | 264 | ++it ) |
268 | { | 265 | { |
269 | OPackage *currPackage = m_packman->findPackage( (*it) ); | 266 | OPackage *currPackage = m_packman->findPackage( (*it) ); |
270 | 267 | ||
271 | // Skip package if it is not found or being removed from 'root' | 268 | // Skip package if it is not found or being removed from 'root' |
272 | if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && | 269 | if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && |
273 | currPackage->destination() == "root" ) ) | 270 | currPackage->destination() == "root" ) ) |
274 | continue; | 271 | continue; |
275 | 272 | ||
276 | // Display feedback to user | 273 | // Display feedback to user |
277 | if ( m_command[ m_currCommand ] == OPackage::Install ) | 274 | m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) |
278 | m_output->append( tr( QString( "Running ipkg-link to link package '%1'." ) | 275 | .arg( currPackage->name() ) ) ); |
279 | .arg( currPackage->name() ) ) ); | ||
280 | else | ||
281 | m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) | ||
282 | .arg( currPackage->name() ) ) ); | ||
283 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 276 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
284 | 277 | ||
285 | // Execute ipkg-link | 278 | // Execute ipkg-link |
286 | process.clearArguments(); | 279 | process.clearArguments(); |
287 | process << "ipkg-link" | 280 | process << "ipkg-link" |
288 | << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) | 281 | << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) |
289 | << currPackage->name(); | 282 | << currPackage->name(); |
290 | if ( !process.start( Opie::Core::OProcess::Block, | 283 | if ( !process.start( Opie::Core::OProcess::Block, |
291 | Opie::Core::OProcess::NoCommunication ) ) | 284 | Opie::Core::OProcess::NoCommunication ) ) |
292 | { | 285 | { |
293 | slotProcessDone( 0x0 ); | 286 | slotProcessDone( 0l ); |
294 | m_output->append( tr( "Unable to run ipkg-link." ) ); | 287 | m_output->append( tr( "Unable to run ipkg-link." ) ); |
295 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 288 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
296 | return; | 289 | return; |
297 | } | 290 | } |
298 | } | 291 | } |
299 | 292 | } | |
293 | else if ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) | ||
294 | { | ||
295 | // Link applications in the destination directory | ||
296 | |||
297 | m_output->append( tr( "Running ipkg-link to link packages in '%1'." ).arg( dest ) ); | ||
298 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
299 | |||
300 | QString destPath; | ||
301 | OConfItem *destItem = m_packman->findConfItem( OConfItem::Destination, dest ); | ||
302 | |||
303 | // Execute ipkg-link | ||
304 | process.clearArguments(); | ||
305 | process << "ipkg-link" | ||
306 | << "mount" | ||
307 | << destItem->value(); | ||
308 | if ( !process.start( Opie::Core::OProcess::Block, | ||
309 | Opie::Core::OProcess::NoCommunication ) ) | ||
310 | { | ||
311 | slotProcessDone( 0l ); | ||
312 | m_output->append( tr( "Unable to run ipkg-link." ) ); | ||
313 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
314 | return; | ||
315 | } | ||
300 | } | 316 | } |
301 | } | 317 | } |
302 | 318 | ||
303 | slotProcessDone( 0x0 ); | 319 | slotProcessDone( 0l ); |
304 | } | 320 | } |
305 | 321 | ||
306 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) | 322 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) |
307 | { | 323 | { |
308 | if ( proc ) | 324 | if ( proc ) |
309 | { | 325 | { |
310 | // Display message pnly if linking was done | 326 | // Display message pnly if linking was done |
311 | m_output->append( tr( "The package linking is done." ) ); | 327 | m_output->append( tr( "The package linking is done." ) ); |
312 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 328 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
313 | 329 | ||
314 | delete proc; | 330 | delete proc; |
315 | } | 331 | } |
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 | |||
@@ -46,25 +46,25 @@ namespace Opie | |||
46 | { | 46 | { |
47 | namespace Core | 47 | namespace Core |
48 | { | 48 | { |
49 | class OProcess; | 49 | class OProcess; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | class InstallDlg : public QWidget | 53 | class InstallDlg : public QWidget |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | 56 | ||
57 | public: | 57 | public: |
58 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, | 58 | InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, |
59 | const QString &caption = QString::null, | 59 | const QString &caption = QString::null, |
60 | OPackage::Command command1 = OPackage::NotDefined, | 60 | OPackage::Command command1 = OPackage::NotDefined, |
61 | const QStringList &packages1 = QStringList(), | 61 | const QStringList &packages1 = QStringList(), |
62 | OPackage::Command command2 = OPackage::NotDefined, | 62 | OPackage::Command command2 = OPackage::NotDefined, |
63 | const QStringList &packages2 = QStringList(), | 63 | const QStringList &packages2 = QStringList(), |
64 | OPackage::Command command3 = OPackage::NotDefined, | 64 | OPackage::Command command3 = OPackage::NotDefined, |
65 | const QStringList &packages3 = QStringList() ); | 65 | const QStringList &packages3 = QStringList() ); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | OPackageManager *m_packman; // Pointer to application instance of package manager | 68 | OPackageManager *m_packman; // Pointer to application instance of package manager |
69 | 69 | ||
70 | bool m_installFound; // Indicates if an install is being done, controls display of | 70 | bool m_installFound; // Indicates if an install is being done, controls display of |