summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/installdlg.cpp
authordrw <drw>2005-01-02 20:26:01 (UTC)
committer drw <drw>2005-01-02 20:26:01 (UTC)
commite763e0cea060ae3a2dfb1c411f56354e27ac12a9 (patch) (unidiff)
tree37896734be7d2679c3f19635fe9fe3b52a549332 /noncore/settings/packagemanager/installdlg.cpp
parent020ea2d54bcd0fc4420cb433b3e657cd13ae07e2 (diff)
downloadopie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.zip
opie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.tar.gz
opie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.tar.bz2
Implement native package linking code (removing need for ipkg-link and its shortcomings), move package linking code to OIpkg (proper place for ipkg specific code), many small code tweaks and bump version up to 0.6.1
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
@@ -21,25 +21,24 @@ _;:, .> :=|. This file is free software; you can
21: = ...= . :.=- You should have received a copy of the GNU 21: = ...= . :.=- You should have received a copy of the GNU
22-. .:....=;==+<; General Public License along with this file; 22-. .:....=;==+<; General Public License along with this file;
23 -_. . . )=. = see the file COPYING. If not, write to the 23 -_. . . )=. = see the file COPYING. If not, write to the
24 -- :-=` Free Software Foundation, Inc., 24 -- :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
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>
40#include <qcombobox.h> 39#include <qcombobox.h>
41#include <qfileinfo.h> 40#include <qfileinfo.h>
42#include <qgroupbox.h> 41#include <qgroupbox.h>
43#include <qlabel.h> 42#include <qlabel.h>
44#include <qlayout.h> 43#include <qlayout.h>
45#include <qmap.h> 44#include <qmap.h>
@@ -238,105 +237,29 @@ void InstallDlg::slotBtnStart()
238 237
239 m_btnOptions->setEnabled( false ); 238 m_btnOptions->setEnabled( false );
240 if ( m_numCommands > 1 ) 239 if ( m_numCommands > 1 )
241 { 240 {
242 m_btnStart->setText( tr( "Abort" ) ); 241 m_btnStart->setText( tr( "Abort" ) );
243 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 242 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
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" ) );
337 260
338 m_btnOptions->setEnabled( true ); 261 m_btnOptions->setEnabled( true );
339 m_btnOptions->setText( tr( "Save output" ) ); 262 m_btnOptions->setText( tr( "Save output" ) );
340 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 263 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
341} 264}
342 265
@@ -363,25 +286,25 @@ void InstallDlg::slotBtnOptions()
363 if( !filename.isEmpty() ) 286 if( !filename.isEmpty() )
364 { 287 {
365 QString currentFileName = QFileInfo( filename ).fileName(); 288 QString currentFileName = QFileInfo( filename ).fileName();
366 DocLnk doc; 289 DocLnk doc;
367 doc.setType( "text/plain" ); 290 doc.setType( "text/plain" );
368 doc.setFile( filename ); 291 doc.setFile( filename );
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' )
382 lineStr.truncate( lineStr.length() - 1 ); 305 lineStr.truncate( lineStr.length() - 1 );
383 m_output->append( lineStr ); 306 m_output->append( lineStr );
384 m_output->setCursorPosition( m_output->numLines(), 0 ); 307 m_output->setCursorPosition( m_output->numLines(), 0 );
385 308
386 // Update available space 309 // Update available space
387 slotDisplayAvailSpace( QString::null ); 310 slotDisplayAvailSpace( QString::null );