summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/installdlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp81
1 files changed, 2 insertions, 79 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 985e2bd..7dea591 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -27,13 +27,12 @@ _;:, .> :=|. This file is free software; you can
27 27
28*/ 28*/
29 29
30#include "installdlg.h" 30#include "installdlg.h"
31 31
32#include <opie2/ofiledialog.h> 32#include <opie2/ofiledialog.h>
33#include <opie2/oprocess.h>
34 33
35#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
36#include <qpe/resource.h> 35#include <qpe/resource.h>
37#include <qpe/storage.h> 36#include <qpe/storage.h>
38 37
39#include <qapplication.h> 38#include <qapplication.h>
@@ -244,93 +243,17 @@ void InstallDlg::slotBtnStart()
244 } 243 }
245 else 244 else
246 { 245 {
247 m_btnStart->setEnabled( false ); 246 m_btnStart->setEnabled( false );
248 } 247 }
249 248
250 Opie::Core::OProcess process( this );
251 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 249 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
252 { 250 {
253 // Execute next command 251 // Execute next command
254 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 252 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
255 this, SLOT(slotOutput(char*)), true ); 253 this, SLOT(slotOutput(const QString &)), true );
256
257 if ( m_command[ m_currCommand ] == OPackage::Remove )
258 {
259 // Unlink application if the package was removed
260
261 // Loop through all package names in the command group
262 for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin();
263 it != m_packages[ m_currCommand ].end();
264 ++it )
265 {
266 OPackage *currPackage = m_packman->findPackage( (*it) );
267
268 // Skip package if it is not found or being removed from 'root'
269 if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove &&
270 currPackage->destination() == "root" ) )
271 continue;
272
273 // Display feedback to user
274 m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." )
275 .arg( currPackage->name() ) ) );
276 m_output->setCursorPosition( m_output->numLines(), 0 );
277
278 // Execute ipkg-link
279 process.clearArguments();
280 process << "ipkg-link"
281 << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" )
282 << currPackage->name();
283 if ( !process.start( Opie::Core::OProcess::Block,
284 Opie::Core::OProcess::NoCommunication ) )
285 {
286 slotProcessDone( 0l );
287 m_output->append( tr( "Unable to run ipkg-link." ) );
288 m_output->setCursorPosition( m_output->numLines(), 0 );
289 return;
290 }
291 }
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 }
316 }
317 }
318
319 slotProcessDone( 0l );
320}
321
322void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc )
323{
324 if ( proc )
325 {
326 // Display message pnly if linking was done
327 m_output->append( tr( "The package linking is done." ) );
328 m_output->setCursorPosition( m_output->numLines(), 0 );
329
330 delete proc;
331 } 254 }
332 255
333 // All commands executed, allow user to close dialog 256 // All commands executed, allow user to close dialog
334 m_btnStart->setEnabled( true ); 257 m_btnStart->setEnabled( true );
335 m_btnStart->setText( tr( "Close" ) ); 258 m_btnStart->setText( tr( "Close" ) );
336 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 259 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
@@ -369,13 +292,13 @@ void InstallDlg::slotBtnOptions()
369 doc.setName( currentFileName ); 292 doc.setName( currentFileName );
370 FileManager fm; 293 FileManager fm;
371 fm.saveFile( doc, m_output->text() ); 294 fm.saveFile( doc, m_output->text() );
372 } 295 }
373} 296}
374 297
375void InstallDlg::slotOutput( char *msg ) 298void InstallDlg::slotOutput( const QString &msg )
376{ 299{
377 // Allow processing of other events 300 // Allow processing of other events
378 qApp->processEvents(); 301 qApp->processEvents();
379 302
380 QString lineStr = msg; 303 QString lineStr = msg;
381 if ( lineStr[lineStr.length()-1] == '\n' ) 304 if ( lineStr[lineStr.length()-1] == '\n' )