summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp130
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h8
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp17
-rw-r--r--noncore/settings/aqpkg/ipkg.h4
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp8
-rw-r--r--noncore/settings/aqpkg/mainwin.h2
6 files changed, 116 insertions, 53 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 76d0a80..896e370 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -28,49 +28,49 @@
28#endif 28#endif
29 29
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qmultilineedit.h> 35#include <qmultilineedit.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39 39
40#include "datamgr.h" 40#include "datamgr.h"
41#include "destination.h" 41#include "destination.h"
42#include "instoptionsimpl.h" 42#include "instoptionsimpl.h"
43#include "installdlgimpl.h" 43#include "installdlgimpl.h"
44#include "ipkg.h" 44#include "ipkg.h"
45#include "utils.h" 45#include "utils.h"
46#include "global.h" 46#include "global.h"
47 47
48enum { 48enum {
49 MAXLINES = 100, 49 MAXLINES = 100,
50}; 50};
51 51
52InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 52InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title )
53 : QWidget( 0, 0, 0 ) 53 : QWidget( 0, 0, 0 )
54{ 54{
55 setCaption( title ); 55 setCaption( title );
56 init( TRUE ); 56 init( TRUE );
57 57
58 pIpkg = 0; 58 pIpkg = 0;
59 upgradePackages = false; 59 upgradePackages = false;
60 dataMgr = dataManager; 60 dataMgr = dataManager;
61 61
62 QString defaultDest = "root"; 62 QString defaultDest = "root";
63#ifdef QWS 63#ifdef QWS
64 Config cfg( "aqpkg" ); 64 Config cfg( "aqpkg" );
65 cfg.setGroup( "settings" ); 65 cfg.setGroup( "settings" );
66 defaultDest = cfg.readEntry( "dest", "root" ); 66 defaultDest = cfg.readEntry( "dest", "root" );
67 67
68 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 68 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
69 flags = cfg.readNumEntry( "installFlags", 0 ); 69 flags = cfg.readNumEntry( "installFlags", 0 );
70 infoLevel = cfg.readNumEntry( "infoLevel", 1 ); 70 infoLevel = cfg.readNumEntry( "infoLevel", 1 );
71#else 71#else
72 flags = 0; 72 flags = 0;
73#endif 73#endif
74 74
75 // Output text is read only 75 // Output text is read only
76 output->setReadOnly( true ); 76 output->setReadOnly( true );
@@ -80,78 +80,77 @@ InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *da
80 80
81 81
82 // setup destination data 82 // setup destination data
83 int defIndex = 0; 83 int defIndex = 0;
84 int i; 84 int i;
85 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 85 QListIterator<Destination> dit( dataMgr->getDestinationList() );
86 for ( i = 0; dit.current(); ++dit, ++i ) 86 for ( i = 0; dit.current(); ++dit, ++i )
87 { 87 {
88 destination->insertItem( dit.current()->getDestinationName() ); 88 destination->insertItem( dit.current()->getDestinationName() );
89 if ( dit.current()->getDestinationName() == defaultDest ) 89 if ( dit.current()->getDestinationName() == defaultDest )
90 defIndex = i; 90 defIndex = i;
91 } 91 }
92 92
93 destination->setCurrentItem( defIndex ); 93 destination->setCurrentItem( defIndex );
94 94
95 QListIterator<InstallData> it( packageList ); 95 QListIterator<InstallData> it( packageList );
96 // setup package data 96 // setup package data
97 QString remove = tr( "Remove\n" ); 97 QString remove = tr( "Remove\n" );
98 QString install = tr( "Install\n" ); 98 QString install = tr( "Install\n" );
99 QString upgrade = tr( "Upgrade\n" ); 99 QString upgrade = tr( "Upgrade\n" );
100 for ( ; it.current(); ++it ) 100 for ( ; it.current(); ++it )
101 { 101 {
102 InstallData *item = it.current(); 102 InstallData *item = it.current();
103 InstallData *newitem = new InstallData(); 103 InstallData *newitem = new InstallData();
104 104
105 newitem->option = item->option; 105 newitem->option = item->option;
106 newitem->packageName = item->packageName; 106 newitem->packageName = item->packageName;
107 newitem->destination = item->destination; 107 newitem->destination = item->destination;
108 newitem->recreateLinks = item->recreateLinks; 108 newitem->recreateLinks = item->recreateLinks;
109 109 packages.append( newitem );
110 if ( item->option == "I" ) 110
111 if ( item->option == "I" )
111 { 112 {
112 installList.append( newitem );
113 install.append( QString( " %1\n" ).arg( item->packageName ) ); 113 install.append( QString( " %1\n" ).arg( item->packageName ) );
114 } 114 }
115 else if ( item->option == "D" ) 115 else if ( item->option == "D" )
116 { 116 {
117 removeList.append( newitem );
118 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 117 remove.append( QString( " %1\n" ).arg( item->packageName ) );
119 } 118 }
120 else if ( item->option == "U" || item->option == "R" ) 119 else if ( item->option == "U" || item->option == "R" )
121 { 120 {
122 updateList.append( newitem ); 121 QString type;
123 QString type; 122 if ( item->option == "R" )
124 if ( item->option == "R" ) 123 type = tr( "(ReInstall)" );
125 type = tr( "(ReInstall)" ); 124 else
126 else 125 type = tr( "(Upgrade)" );
127 type = tr( "(Upgrade)" ); 126 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
128 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 127 }
129 } 128 }
130 }
131 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
132 129
133 displayAvailableSpace( destination->currentText() ); 130 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
131
132 displayAvailableSpace( destination->currentText() );
134} 133}
135 134
136InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 135InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
137 : QWidget( 0, 0, 0 ) 136 : QWidget( 0, 0, 0 )
138{ 137{
139 setCaption( title ); 138 setCaption( title );
140 init( FALSE ); 139 init( FALSE );
141 pIpkg = ipkg; 140 pIpkg = ipkg;
142 output->setText( initialText ); 141 output->setText( initialText );
143} 142}
144 143
145 144
146InstallDlgImpl::~InstallDlgImpl() 145InstallDlgImpl::~InstallDlgImpl()
147{ 146{
148 if ( pIpkg ) 147 if ( pIpkg )
149 delete pIpkg; 148 delete pIpkg;
150} 149}
151 150
152void InstallDlgImpl :: init( bool displayextrainfo ) 151void InstallDlgImpl :: init( bool displayextrainfo )
153{ 152{
154 QGridLayout *layout = new QGridLayout( this ); 153 QGridLayout *layout = new QGridLayout( this );
155 layout->setSpacing( 4 ); 154 layout->setSpacing( 4 );
156 layout->setMargin( 4 ); 155 layout->setMargin( 4 );
157 156
@@ -247,72 +246,78 @@ void InstallDlgImpl :: installSelected()
247 displayText( tr( "**** Process Aborted ****" ) ); 246 displayText( tr( "**** Process Aborted ****" ) );
248 } 247 }
249 248
250 btnInstall->setText( tr( "Close" ) ); 249 btnInstall->setText( tr( "Close" ) );
251 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 250 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
252 return; 251 return;
253 } 252 }
254 else if ( btnInstall->text() == tr( "Close" ) ) 253 else if ( btnInstall->text() == tr( "Close" ) )
255 { 254 {
256 emit reloadData( this ); 255 emit reloadData( this );
257 return; 256 return;
258 } 257 }
259 258
260 // Disable buttons 259 // Disable buttons
261 btnOptions->setEnabled( false ); 260 btnOptions->setEnabled( false );
262// btnInstall->setEnabled( false ); 261// btnInstall->setEnabled( false );
263 262
264 btnInstall->setText( tr( "Abort" ) ); 263 btnInstall->setText( tr( "Abort" ) );
265 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 264 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
266 265
267 if ( pIpkg ) 266 if ( pIpkg )
268 { 267 {
269 output->setText( "" ); 268 output->setText( "" );
270 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 269 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
270 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
271 pIpkg->runIpkg(); 271 pIpkg->runIpkg();
272 } 272 }
273 else 273 else
274 { 274 {
275 output->setText( "" ); 275 output->setText( "" );
276 Destination *d = dataMgr->getDestination( destination->currentText() ); 276 Destination *d = dataMgr->getDestination( destination->currentText() );
277 QString dest = d->getDestinationName(); 277 QString dest = d->getDestinationName();
278 QString destDir = d->getDestinationPath(); 278 QString destDir = d->getDestinationPath();
279 int instFlags = flags; 279 int instFlags = flags;
280 if ( d->linkToRoot() ) 280 if ( d->linkToRoot() )
281 instFlags |= MAKE_LINKS; 281 instFlags |= MAKE_LINKS;
282 282
283#ifdef QWS 283#ifdef QWS
284 // Save settings 284 // Save settings
285 Config cfg( "aqpkg" ); 285 Config cfg( "aqpkg" );
286 cfg.setGroup( "settings" ); 286 cfg.setGroup( "settings" );
287 cfg.writeEntry( "dest", dest ); 287 cfg.writeEntry( "dest", dest );
288#endif 288#endif
289 289
290 pIpkg = new Ipkg; 290 pIpkg = new Ipkg;
291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
292 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
293
294 firstPackage = TRUE;
295 ipkgFinished();
292 296
293 // First run through the remove list, then the install list then the upgrade list 297 // First run through the remove list, then the install list then the upgrade list
294 pIpkg->setOption( "remove" ); 298/*
299 pIpkg->setOption( "remove" );
295 QListIterator<InstallData> it( removeList ); 300 QListIterator<InstallData> it( removeList );
296 InstallData *idata; 301 InstallData *idata;
297 for ( ; it.current(); ++it ) 302 for ( ; it.current(); ++it )
298 { 303 {
299 idata = it.current(); 304 idata = it.current();
300 pIpkg->setDestination( idata->destination->getDestinationName() ); 305 pIpkg->setDestination( idata->destination->getDestinationName() );
301 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 306 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
302 pIpkg->setPackage( idata->packageName ); 307 pIpkg->setPackage( idata->packageName );
303 308
304 int tmpFlags = flags; 309 int tmpFlags = flags;
305 if ( idata->destination->linkToRoot() ) 310 if ( idata->destination->linkToRoot() )
306 tmpFlags |= MAKE_LINKS; 311 tmpFlags |= MAKE_LINKS;
307 312
308 pIpkg->setFlags( tmpFlags, infoLevel ); 313 pIpkg->setFlags( tmpFlags, infoLevel );
309 pIpkg->runIpkg(); 314 pIpkg->runIpkg();
310 } 315 }
311 316
312 pIpkg->setOption( "install" ); 317 pIpkg->setOption( "install" );
313 pIpkg->setDestination( dest ); 318 pIpkg->setDestination( dest );
314 pIpkg->setDestinationDir( destDir ); 319 pIpkg->setDestinationDir( destDir );
315 pIpkg->setFlags( instFlags, infoLevel ); 320 pIpkg->setFlags( instFlags, infoLevel );
316 QListIterator<InstallData> it2( installList ); 321 QListIterator<InstallData> it2( installList );
317 for ( ; it2.current(); ++it2 ) 322 for ( ; it2.current(); ++it2 )
318 { 323 {
@@ -321,82 +326,141 @@ void InstallDlgImpl :: installSelected()
321 } 326 }
322 327
323 flags |= FORCE_REINSTALL; 328 flags |= FORCE_REINSTALL;
324 QListIterator<InstallData> it3( updateList ); 329 QListIterator<InstallData> it3( updateList );
325 for ( ; it3.current() ; ++it3 ) 330 for ( ; it3.current() ; ++it3 )
326 { 331 {
327 idata = it3.current(); 332 idata = it3.current();
328 if ( idata->option == "R" ) 333 if ( idata->option == "R" )
329 pIpkg->setOption( "reinstall" ); 334 pIpkg->setOption( "reinstall" );
330 else 335 else
331 pIpkg->setOption( "upgrade" ); 336 pIpkg->setOption( "upgrade" );
332 pIpkg->setDestination( idata->destination->getDestinationName() ); 337 pIpkg->setDestination( idata->destination->getDestinationName() );
333 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 338 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
334 pIpkg->setPackage( idata->packageName ); 339 pIpkg->setPackage( idata->packageName );
335 340
336 int tmpFlags = flags; 341 int tmpFlags = flags;
337 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 342 if ( idata->destination->linkToRoot() && idata->recreateLinks )
338 tmpFlags |= MAKE_LINKS; 343 tmpFlags |= MAKE_LINKS;
339 pIpkg->setFlags( tmpFlags, infoLevel ); 344 pIpkg->setFlags( tmpFlags, infoLevel );
340 pIpkg->runIpkg(); 345 pIpkg->runIpkg();
341 } 346 }
342 347
343 delete pIpkg; 348 delete pIpkg;
344 pIpkg = 0; 349 pIpkg = 0;
350*/
345 } 351 }
346
347 btnOptions->setEnabled( true );
348// btnInstall->setEnabled( true );
349 btnInstall->setText( tr( "Close" ) );
350 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
351
352 btnOptions->setText( tr( "Save output" ) );
353 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
354
355 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
356 displayAvailableSpace( destination->currentText() );
357} 352}
358 353
359 354
360void InstallDlgImpl :: displayText(const QString &text ) 355void InstallDlgImpl :: displayText(const QString &text )
361{ 356{
362 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 357 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
363 358
364 /* Set a max line count for the QMultiLineEdit, as users have reported 359 /* Set a max line count for the QMultiLineEdit, as users have reported
365 * performance issues when line count gets extreme. 360 * performance issues when line count gets extreme.
366 */ 361 */
367 if(output->numLines() >= MAXLINES) 362 if(output->numLines() >= MAXLINES)
368 output->removeLine(0); 363 output->removeLine(0);
369 output->setText( newtext ); 364 output->setText( newtext );
370 output->setCursorPosition( output->numLines(), 0 ); 365 output->setCursorPosition( output->numLines(), 0 );
371} 366}
372 367
373 368
374void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 369void InstallDlgImpl :: displayAvailableSpace( const QString &text )
375{ 370{
376 Destination *d = dataMgr->getDestination( text ); 371 Destination *d = dataMgr->getDestination( text );
377 QString destDir = d->getDestinationPath(); 372 QString destDir = d->getDestinationPath();
378 373
379 long blockSize = 0; 374 long blockSize = 0;
380 long totalBlocks = 0; 375 long totalBlocks = 0;
381 long availBlocks = 0; 376 long availBlocks = 0;
382 QString space; 377 QString space;
383 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 378 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
384 { 379 {
385 long mult = blockSize / 1024; 380 long mult = blockSize / 1024;
386 long div = 1024 / blockSize; 381 long div = 1024 / blockSize;
387 382
388 if ( !mult ) mult = 1; 383 if ( !mult ) mult = 1;
389 if ( !div ) div = 1; 384 if ( !div ) div = 1;
390// long total = totalBlocks * mult / div; 385// long total = totalBlocks * mult / div;
391 long avail = availBlocks * mult / div; 386 long avail = availBlocks * mult / div;
392// long used = total - avail; 387// long used = total - avail;
393 388
394 space.sprintf( "%ld Kb", avail ); 389 space.sprintf( "%ld Kb", avail );
395 } 390 }
396 else 391 else
397 space = tr( "Unknown" ); 392 space = tr( "Unknown" );
398 393
399 if ( txtAvailableSpace ) 394 if ( txtAvailableSpace )
400 txtAvailableSpace->setText( space ); 395 txtAvailableSpace->setText( space );
401} 396}
402 397
398void InstallDlgImpl :: ipkgFinished()
399{
400 InstallData *item;
401 if ( firstPackage )
402 item = packages.first();
403 else
404 {
405 // Create symlinks if necessary before moving on to next package
406 pIpkg->createSymLinks();
407
408 item = packages.next();
409 }
410
411 firstPackage = FALSE;
412 if ( item )
413 {
414 pIpkg->setPackage( item->packageName );
415 int tmpFlags = flags;
416
417 if ( item->option == "I" )
418 {
419 pIpkg->setOption( "install" );
420 Destination *d = dataMgr->getDestination( destination->currentText() );
421 pIpkg->setDestination( d->getDestinationName() );
422 pIpkg->setDestinationDir( d->getDestinationPath() );
423
424 if ( d->linkToRoot() )
425 tmpFlags |= MAKE_LINKS;
426 }
427 else if ( item->option == "D" )
428 {
429 pIpkg->setOption( "remove" );
430 pIpkg->setDestination( item->destination->getDestinationName() );
431 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
432
433 if ( item->destination->linkToRoot() )
434 tmpFlags |= MAKE_LINKS;
435 }
436 else
437 {
438 if ( item->option == "R" )
439 pIpkg->setOption( "reinstall" );
440 else
441 pIpkg->setOption( "upgrade" );
442
443 pIpkg->setDestination( item->destination->getDestinationName() );
444 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
445 pIpkg->setPackage( item->packageName );
446
447 tmpFlags |= FORCE_REINSTALL;
448 if ( item->destination->linkToRoot() && item->recreateLinks )
449 tmpFlags |= MAKE_LINKS;
450 }
451 pIpkg->setFlags( tmpFlags, infoLevel );
452 pIpkg->runIpkg();
453 }
454 else
455 {
456 btnOptions->setEnabled( true );
457 btnInstall->setText( tr( "Close" ) );
458 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
459
460 btnOptions->setText( tr( "Save output" ) );
461 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
462
463 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
464 displayAvailableSpace( destination->currentText() );
465 }
466} \ No newline at end of file
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 15cf427..9a7dbff 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -24,63 +24,63 @@ using namespace std;
24#include <qwidget.h> 24#include <qwidget.h>
25 25
26class QComboBox; 26class QComboBox;
27class QLabel; 27class QLabel;
28class QMultiLineEdit; 28class QMultiLineEdit;
29class QPushButton; 29class QPushButton;
30 30
31class DataManager; 31class DataManager;
32class Destination; 32class Destination;
33class Ipkg; 33class Ipkg;
34 34
35class InstallData 35class InstallData
36{ 36{
37public: 37public:
38 QString option; // I - install, D - delete, R- reinstall U - upgrade 38 QString option; // I - install, D - delete, R- reinstall U - upgrade
39 QString packageName; 39 QString packageName;
40 Destination *destination; 40 Destination *destination;
41 bool recreateLinks; 41 bool recreateLinks;
42}; 42};
43 43
44class InstallDlgImpl : public QWidget 44class InstallDlgImpl : public QWidget
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47public: 47public:
48 InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); 48 InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); 49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
50 ~InstallDlgImpl(); 50 ~InstallDlgImpl();
51 51
52 bool upgradeServer( QString &server ); 52 bool upgradeServer( QString &server );
53 53
54protected: 54protected:
55 55
56private: 56private:
57 DataManager *dataMgr; 57 DataManager *dataMgr;
58 QList<InstallData> installList; 58 QList<InstallData> packages;
59 QList<InstallData> removeList; 59 bool firstPackage;
60 QList<InstallData> updateList;
61 int flags; 60 int flags;
62 int infoLevel; 61 int infoLevel;
63 Ipkg *pIpkg; 62 Ipkg *pIpkg;
64 bool upgradePackages; 63 bool upgradePackages;
65 64
66 QComboBox *destination; 65 QComboBox *destination;
67 QPushButton *btnInstall; 66 QPushButton *btnInstall;
68 QPushButton *btnOptions; 67 QPushButton *btnOptions;
69 QMultiLineEdit *output; 68 QMultiLineEdit *output;
70 QLabel *txtAvailableSpace; 69 QLabel *txtAvailableSpace;
71 70
72 void init( bool ); 71 void init( bool );
73 72
74 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
75 74
76signals: 75signals:
77 void reloadData( InstallDlgImpl * ); 76 void reloadData( InstallDlgImpl * );
78 77
79public slots: 78public slots:
80 void optionsSelected(); 79 void optionsSelected();
81 void installSelected(); 80 void installSelected();
82 void displayText(const QString &text ); 81 void displayText(const QString &text );
83 void displayAvailableSpace( const QString &text); 82 void displayAvailableSpace( const QString &text);
83 void ipkgFinished();
84}; 84};
85 85
86#endif 86#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index e906653..34999ad 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -34,52 +34,51 @@ using namespace std;
34#include <opie/oprocess.h> 34#include <opie/oprocess.h>
35 35
36#include "utils.h" 36#include "utils.h"
37#include "ipkg.h" 37#include "ipkg.h"
38#include "global.h" 38#include "global.h"
39 39
40Ipkg :: Ipkg() 40Ipkg :: Ipkg()
41{ 41{
42 proc = 0; 42 proc = 0;
43} 43}
44 44
45Ipkg :: ~Ipkg() 45Ipkg :: ~Ipkg()
46{ 46{
47} 47}
48 48
49// Option is what we are going to do - install, upgrade, download, reinstall 49// Option is what we are going to do - install, upgrade, download, reinstall
50// package is the package name to install - either a fully qualified path and ipk 50// package is the package name to install - either a fully qualified path and ipk
51// file (if stored locally) or just the name of the package (for a network package) 51// file (if stored locally) or just the name of the package (for a network package)
52// packageName is the package name - (for a network package this will be the same as 52// packageName is the package name - (for a network package this will be the same as
53// package parameter) 53// package parameter)
54// dest is the destination alias (from ipk.conf) 54// dest is the destination alias (from ipk.conf)
55// destDir is the dir that the destination alias points to (used to link to root) 55// destDir is the dir that the destination alias points to (used to link to root)
56// flags is the ipkg options flags 56// flags is the ipkg options flags
57// dir is the directory to run ipkg in (defaults to "") 57// dir is the directory to run ipkg in (defaults to "")
58bool Ipkg :: runIpkg( ) 58void Ipkg :: runIpkg()
59{ 59{
60 error = false; 60 error = false;
61 bool ret = false;
62 QStringList commands; 61 QStringList commands;
63 62
64 QDir::setCurrent( "/tmp" ); 63 QDir::setCurrent( "/tmp" );
65 64
66 if ( runtimeDir != "" ) 65 if ( runtimeDir != "" )
67 { 66 {
68 commands << "cd "; 67 commands << "cd ";
69 commands << runtimeDir; 68 commands << runtimeDir;
70 commands << ";"; 69 commands << ";";
71 } 70 }
72 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; 71 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults";
73 72
74 // only set the destination for an install operation 73 // only set the destination for an install operation
75 if ( option == "install" ) 74 if ( option == "install" )
76 commands << "-dest" << destination; 75 commands << "-dest" << destination;
77 76
78 77
79 if ( option != "update" && option != "download" ) 78 if ( option != "update" && option != "download" )
80 { 79 {
81 if ( flags & FORCE_DEPENDS ) 80 if ( flags & FORCE_DEPENDS )
82 commands << "-force-depends"; 81 commands << "-force-depends";
83 if ( flags & FORCE_REINSTALL ) 82 if ( flags & FORCE_REINSTALL )
84 commands << "-force-reinstall"; 83 commands << "-force-reinstall";
85 if ( flags & FORCE_REMOVE ) 84 if ( flags & FORCE_REMOVE )
@@ -116,83 +115,83 @@ bool Ipkg :: runIpkg( )
116 115
117 116
118 if ( package != "" ) 117 if ( package != "" )
119 emit outputText( QString( "Dealing with package " ) + package ); 118 emit outputText( QString( "Dealing with package " ) + package );
120 119
121 qApp->processEvents(); 120 qApp->processEvents();
122 121
123 // If we are removing, reinstalling or upgrading packages and make links option is selected 122 // If we are removing, reinstalling or upgrading packages and make links option is selected
124 // create the links 123 // create the links
125 if ( option == "remove" || option == "reinstall" || option == "upgrade" ) 124 if ( option == "remove" || option == "reinstall" || option == "upgrade" )
126 { 125 {
127 createLinks = false; 126 createLinks = false;
128 if ( flags & MAKE_LINKS ) 127 if ( flags & MAKE_LINKS )
129 { 128 {
130 emit outputText( QString( "Removing symbolic links...\n" ) ); 129 emit outputText( QString( "Removing symbolic links...\n" ) );
131 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 130 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
132 emit outputText( QString( " " ) ); 131 emit outputText( QString( " " ) );
133 } 132 }
134 } 133 }
135 134
136 // Execute command 135 // Execute command
137 dependantPackages = new QList<QString>; 136 dependantPackages = new QList<QString>;
138 dependantPackages->setAutoDelete( true ); 137 dependantPackages->setAutoDelete( true );
139 138
140 ret = executeIpkgCommand( commands, option ); 139 executeIpkgCommand( commands, option );
141 140
142 if ( aborted ) 141}
143 return false;
144 142
143void Ipkg :: createSymLinks()
144{
145 if ( option == "install" || option == "reinstall" || option == "upgrade" ) 145 if ( option == "install" || option == "reinstall" || option == "upgrade" )
146 { 146 {
147 // If we are not removing packages and make links option is selected 147 // If we are not removing packages and make links option is selected
148 // create the links 148 // create the links
149 createLinks = true; 149 createLinks = true;
150 if ( flags & MAKE_LINKS ) 150 if ( flags & MAKE_LINKS )
151 { 151 {
152 emit outputText( " " ); 152 emit outputText( " " );
153 emit outputText( QString( "Creating symbolic links for " )+ package ); 153 emit outputText( QString( "Creating symbolic links for " )+ package );
154 154
155 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 155 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
156 156
157 // link dependant packages that were installed with this release 157 // link dependant packages that were installed with this release
158 QString *pkg; 158 QString *pkg;
159 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) 159 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
160 { 160 {
161 if ( *pkg == package ) 161 if ( *pkg == package )
162 continue; 162 continue;
163 emit outputText( " " ); 163 emit outputText( " " );
164 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); 164 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
165 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); 165 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 delete dependantPackages; 170 delete dependantPackages;
171 171
172 emit outputText( "Finished" ); 172 emit outputText( "Finished" );
173 emit outputText( "" ); 173 emit outputText( "" );
174 return ret;
175} 174}
176 175
177void Ipkg :: removeStatusEntry() 176void Ipkg :: removeStatusEntry()
178{ 177{
179 QString statusFile = destDir; 178 QString statusFile = destDir;
180 if ( statusFile.right( 1 ) != "/" ) 179 if ( statusFile.right( 1 ) != "/" )
181 statusFile.append( "/" ); 180 statusFile.append( "/" );
182 statusFile.append( "usr/lib/ipkg/status" ); 181 statusFile.append( "usr/lib/ipkg/status" );
183 QString outStatusFile = statusFile; 182 QString outStatusFile = statusFile;
184 outStatusFile.append( ".tmp" ); 183 outStatusFile.append( ".tmp" );
185 184
186 emit outputText( "" ); 185 emit outputText( "" );
187 emit outputText( "Removing status entry..." ); 186 emit outputText( "Removing status entry..." );
188 QString tempstr = "status file - "; 187 QString tempstr = "status file - ";
189 tempstr.append( statusFile ); 188 tempstr.append( statusFile );
190 emit outputText( tempstr ); 189 emit outputText( tempstr );
191 tempstr = "package - "; 190 tempstr = "package - ";
192 tempstr.append( package ); 191 tempstr.append( package );
193 emit outputText( tempstr ); 192 emit outputText( tempstr );
194 193
195 ifstream in( statusFile ); 194 ifstream in( statusFile );
196 ofstream out( outStatusFile ); 195 ofstream out( outStatusFile );
197 if ( !in.is_open() ) 196 if ( !in.is_open() )
198 { 197 {
@@ -274,52 +273,48 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
274 aborted = false; 273 aborted = false;
275 274
276 275
277 // Connect up our slots 276 // Connect up our slots
278 connect(proc, SIGNAL(processExited(OProcess *)), 277 connect(proc, SIGNAL(processExited(OProcess *)),
279 this, SLOT( processFinished())); 278 this, SLOT( processFinished()));
280 279
281 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 280 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
282 this, SLOT(commandStdout(OProcess *, char *, int))); 281 this, SLOT(commandStdout(OProcess *, char *, int)));
283 282
284 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 283 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
285 this, SLOT(commandStderr(OProcess *, char *, int))); 284 this, SLOT(commandStderr(OProcess *, char *, int)));
286 285
287 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) 286 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
288 { 287 {
289 *proc << (*it).latin1(); 288 *proc << (*it).latin1();
290 } 289 }
291 290
292 // Start the process going 291 // Start the process going
293 finished = false; 292 finished = false;
294 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) 293 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
295 { 294 {
296 emit outputText( QString( "Couldn't start ipkg process" ) ); 295 emit outputText( QString( "Couldn't start ipkg process" ) );
297 } 296 }
298
299 // Now wait for it to finish
300 while ( !finished )
301 qApp->processEvents();
302} 297}
303 298
304void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) 299void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
305{ 300{
306 QString lineStr = buffer; 301 QString lineStr = buffer;
307 if ( lineStr[buflen-1] == '\n' ) 302 if ( lineStr[buflen-1] == '\n' )
308 buflen --; 303 buflen --;
309 lineStr = lineStr.left( buflen ); 304 lineStr = lineStr.left( buflen );
310 emit outputText( lineStr ); 305 emit outputText( lineStr );
311 306
312 // check if we are installing dependant packages 307 // check if we are installing dependant packages
313 if ( option == "install" || option == "reinstall" ) 308 if ( option == "install" || option == "reinstall" )
314 { 309 {
315 // Need to keep track of any dependant packages that get installed 310 // Need to keep track of any dependant packages that get installed
316 // so that we can create links to them as necessary 311 // so that we can create links to them as necessary
317 if ( lineStr.startsWith( "Installing " ) ) 312 if ( lineStr.startsWith( "Installing " ) )
318 { 313 {
319 int start = lineStr.find( " " ) + 1; 314 int start = lineStr.find( " " ) + 1;
320 int end = lineStr.find( " ", start ); 315 int end = lineStr.find( " ", start );
321 QString *package = new QString( lineStr.mid( start, end-start ) ); 316 QString *package = new QString( lineStr.mid( start, end-start ) );
322 dependantPackages->append( package ); 317 dependantPackages->append( package );
323 } 318 }
324 } 319 }
325 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && 320 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) &&
@@ -333,48 +328,50 @@ void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
333} 328}
334 329
335void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) 330void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
336{ 331{
337 QString lineStr = buffer; 332 QString lineStr = buffer;
338 if ( lineStr[buflen-1] == '\n' ) 333 if ( lineStr[buflen-1] == '\n' )
339 buflen --; 334 buflen --;
340 lineStr=lineStr.left( buflen ); 335 lineStr=lineStr.left( buflen );
341 emit outputText( lineStr ); 336 emit outputText( lineStr );
342 buffer[0] = '\0'; 337 buffer[0] = '\0';
343 error = true; 338 error = true;
344} 339}
345 340
346void Ipkg::processFinished() 341void Ipkg::processFinished()
347{ 342{
348 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file 343 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
349 // to workaround an ipkg bug which stops reinstall to a different location 344 // to workaround an ipkg bug which stops reinstall to a different location
350 345
351 if ( !error && option == "remove" ) 346 if ( !error && option == "remove" )
352 removeStatusEntry(); 347 removeStatusEntry();
353 348
354 delete proc; 349 delete proc;
355 proc = 0; 350 proc = 0;
356 finished = true; 351 finished = true;
352
353 emit ipkgFinished();
357} 354}
358 355
359 356
360void Ipkg :: abort() 357void Ipkg :: abort()
361{ 358{
362 if ( proc ) 359 if ( proc )
363 { 360 {
364 proc->kill(); 361 proc->kill();
365 aborted = true; 362 aborted = true;
366 } 363 }
367} 364}
368 365
369/* 366/*
370int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 367int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
371{ 368{
372 FILE *fp = NULL; 369 FILE *fp = NULL;
373 char line[130]; 370 char line[130];
374 QString lineStr, lineStrOld; 371 QString lineStr, lineStrOld;
375 int ret = false; 372 int ret = false;
376 373
377 fp = popen( (const char *) cmd, "r"); 374 fp = popen( (const char *) cmd, "r");
378 if ( fp == NULL ) 375 if ( fp == NULL )
379 { 376 {
380 QString text; 377 QString text;
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 531bfc0..a0d38e3 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -22,59 +22,61 @@
22/** 22/**
23 *@author Andy Qua 23 *@author Andy Qua
24 */ 24 */
25 25
26#include <qobject.h> 26#include <qobject.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlist.h> 29#include <qlist.h>
30 30
31#define FORCE_DEPENDS 0x0001 31#define FORCE_DEPENDS 0x0001
32#define FORCE_REMOVE 0x0002 32#define FORCE_REMOVE 0x0002
33#define FORCE_REINSTALL 0x0004 33#define FORCE_REINSTALL 0x0004
34#define FORCE_OVERWRITE 0x0008 34#define FORCE_OVERWRITE 0x0008
35#define MAKE_LINKS 0x0010 35#define MAKE_LINKS 0x0010
36#define VERBOSE_WGET 0x0020 36#define VERBOSE_WGET 0x0020
37 37
38class OProcess; 38class OProcess;
39 39
40class Ipkg : public QObject 40class Ipkg : public QObject
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 Ipkg(); 44 Ipkg();
45 ~Ipkg(); 45 ~Ipkg();
46 bool runIpkg( ); 46 void runIpkg();
47 void createSymLinks();
47 48
48 void setOption( const char *opt ) { option = opt; } 49 void setOption( const char *opt ) { option = opt; }
49 void setPackage( const char *pkg ) { package = pkg; } 50 void setPackage( const char *pkg ) { package = pkg; }
50 void setDestination( const char *dest ) { destination = dest; } 51 void setDestination( const char *dest ) { destination = dest; }
51 void setDestinationDir( const char *dir ) { destDir = dir; } 52 void setDestinationDir( const char *dir ) { destDir = dir; }
52 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } 53 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; }
53 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } 54 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
54 55
55signals: 56signals:
56 void outputText( const QString &text ); 57 void outputText( const QString &text );
58 void ipkgFinished();
57 59
58public slots: 60public slots:
59 void commandStdout(OProcess*, char *buffer, int buflen); 61 void commandStdout(OProcess*, char *buffer, int buflen);
60 void commandStderr(OProcess*, char *buffer, int buflen); 62 void commandStderr(OProcess*, char *buffer, int buflen);
61 void processFinished(); 63 void processFinished();
62 void abort(); 64 void abort();
63 65
64 66
65private: 67private:
66 bool createLinks; 68 bool createLinks;
67 bool aborted; 69 bool aborted;
68 bool error; 70 bool error;
69 QString option; 71 QString option;
70 QString package; 72 QString package;
71 QString destination; 73 QString destination;
72 QString destDir; 74 QString destDir;
73 QString runtimeDir; 75 QString runtimeDir;
74 OProcess *proc; 76 OProcess *proc;
75 int flags; 77 int flags;
76 int infoLevel; 78 int infoLevel;
77 bool finished; 79 bool finished;
78 80
79 QList<QString> *dependantPackages; 81 QList<QString> *dependantPackages;
80 82
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 1aec6a8..58f6feb 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -276,79 +276,79 @@ void MainWindow :: init()
276 cfg.setGroup( "settings" ); 276 cfg.setGroup( "settings" );
277 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 277 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
278// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 278// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
279 279
280#endif 280#endif
281 281
282 stack->raiseWidget( progressWindow ); 282 stack->raiseWidget( progressWindow );
283 283
284 mgr = new DataManager(); 284 mgr = new DataManager();
285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
287 this, SLOT( setProgressMessage( const QString & ) ) ); 287 this, SLOT( setProgressMessage( const QString & ) ) );
288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
289 mgr->loadServers(); 289 mgr->loadServers();
290 290
291 showUninstalledPkgs = false; 291 showUninstalledPkgs = false;
292 showInstalledPkgs = false; 292 showInstalledPkgs = false;
293 showUpgradedPkgs = false; 293 showUpgradedPkgs = false;
294 categoryFilterEnabled = false; 294 categoryFilterEnabled = false;
295 295
296 updateData(); 296 updateData();
297 297
298 stack->raiseWidget( networkPkgWindow ); 298 stack->raiseWidget( networkPkgWindow );
299} 299}
300/* 300
301void MainWindow :: setDocument( const QString &doc ) 301void MainWindow :: setDocument( const QString &doc )
302{ 302{
303 // Remove path from package 303 // Remove path from package
304 QString package = Utils::getPackageNameFromIpkFilename( doc ); 304 QString package = Utils::getPackageNameFromIpkFilename( doc );
305// std::cout << "Selecting package " << package << std::endl; 305// std::cout << "Selecting package " << package << std::endl;
306 306
307 // First select local server 307 // First select local server
308 for ( int i = 0 ; i < serversList->count() ; ++i ) 308 for ( int i = 0 ; i < serversList->count() ; ++i )
309 { 309 {
310 if ( serversList->text( i ) == LOCAL_IPKGS ) 310 if ( serversList->text( i ) == LOCAL_IPKGS )
311 { 311 {
312 serversList->setCurrentItem( i ); 312 serversList->setCurrentItem( i );
313 break; 313 break;
314 } 314 }
315 } 315 }
316 serverSelected( 0 ); 316 serverSelected( 0 );
317 317
318 // Now set the check box of the selected package 318 // Now set the check box of the selected package
319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
320 item != 0 ; 320 item != 0 ;
321 item = (QCheckListItem *)item->nextSibling() ) 321 item = (QCheckListItem *)item->nextSibling() )
322 { 322 {
323 if ( item->text().startsWith( package ) ) 323 if ( item->text().startsWith( package ) )
324 { 324 {
325 item->setOn( true ); 325 item->setOn( true );
326 break; 326 break;
327 } 327 }
328 } 328 }
329} 329}
330*/ 330
331void MainWindow :: displaySettings() 331void MainWindow :: displaySettings()
332{ 332{
333 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 333 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
334 if ( dlg->showDlg() ) 334 if ( dlg->showDlg() )
335 { 335 {
336 stack->raiseWidget( progressWindow ); 336 stack->raiseWidget( progressWindow );
337 updateData(); 337 updateData();
338 stack->raiseWidget( networkPkgWindow ); 338 stack->raiseWidget( networkPkgWindow );
339 } 339 }
340 delete dlg; 340 delete dlg;
341} 341}
342 342
343void MainWindow :: closeEvent( QCloseEvent *e ) 343void MainWindow :: closeEvent( QCloseEvent *e )
344{ 344{
345 // If install dialog is visible, return to main view, otherwise close app 345 // If install dialog is visible, return to main view, otherwise close app
346 QWidget *widget = stack->visibleWidget(); 346 QWidget *widget = stack->visibleWidget();
347 347
348 if ( widget != networkPkgWindow && widget != progressWindow ) 348 if ( widget != networkPkgWindow && widget != progressWindow )
349 { 349 {
350 if ( widget ) delete widget; 350 if ( widget ) delete widget;
351 stack->raiseWidget( networkPkgWindow ); 351 stack->raiseWidget( networkPkgWindow );
352 e->ignore(); 352 e->ignore();
353 } 353 }
354 else 354 else
@@ -971,56 +971,56 @@ void MainWindow :: applyChanges()
971 stack->raiseWidget( dlg ); 971 stack->raiseWidget( dlg );
972} 972}
973 973
974// decide what to do - either remove, upgrade or install 974// decide what to do - either remove, upgrade or install
975// Current rules: 975// Current rules:
976// If not installed - install 976// If not installed - install
977// If installed and different version available - upgrade 977// If installed and different version available - upgrade
978// If installed and version up to date - remove 978// If installed and version up to date - remove
979InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 979InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
980{ 980{
981 QString name = item->text(); 981 QString name = item->text();
982 982
983 // Get package 983 // Get package
984 Server *s = mgr->getServer( serversList->currentText() ); 984 Server *s = mgr->getServer( serversList->currentText() );
985 Package *p = s->getPackage( name ); 985 Package *p = s->getPackage( name );
986 986
987 // If the package has a filename then it is a local file 987 // If the package has a filename then it is a local file
988 if ( p->isPackageStoredLocally() ) 988 if ( p->isPackageStoredLocally() )
989 name = p->getFilename(); 989 name = p->getFilename();
990 990
991 QString option; 991 QString option;
992 QString dest = "root"; 992 QString dest = "root";
993 if ( !p->isInstalled() ) 993 if ( !p->isInstalled() )
994 { 994 {
995 InstallData *newitem = new InstallData();; 995 InstallData *newitem = new InstallData();
996 newitem->option = "I"; 996 newitem->option = "I";
997 newitem->packageName = name; 997 newitem->packageName = name;
998 return newitem; 998 return newitem;
999 } 999 }
1000 else 1000 else
1001 { 1001 {
1002 InstallData *newitem = new InstallData();; 1002 InstallData *newitem = new InstallData();
1003 newitem->option = "D"; 1003 newitem->option = "D";
1004 if ( !p->isPackageStoredLocally() ) 1004 if ( !p->isPackageStoredLocally() )
1005 newitem->packageName = p->getInstalledPackageName(); 1005 newitem->packageName = p->getInstalledPackageName();
1006 else 1006 else
1007 newitem->packageName = name; 1007 newitem->packageName = name;
1008 1008
1009 if ( p->getInstalledTo() ) 1009 if ( p->getInstalledTo() )
1010 { 1010 {
1011 newitem->destination = p->getInstalledTo(); 1011 newitem->destination = p->getInstalledTo();
1012// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1012// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1013// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1013// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1014 } 1014 }
1015 else 1015 else
1016 { 1016 {
1017 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1017 newitem->destination = p->getLocalPackage()->getInstalledTo();
1018 } 1018 }
1019 1019
1020 // Now see if version is newer or not 1020 // Now see if version is newer or not
1021 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1021 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1022 1022
1023 // If the version requested is older and user selected a local ipk file, then reinstall the file 1023 // If the version requested is older and user selected a local ipk file, then reinstall the file
1024 if ( p->isPackageStoredLocally() && val == -1 ) 1024 if ( p->isPackageStoredLocally() && val == -1 )
1025 val = 0; 1025 val = 0;
1026 1026
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 0295519..c4548b1 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -85,49 +85,49 @@ private:
85 bool categoryFilterEnabled; 85 bool categoryFilterEnabled;
86 bool showJumpTo; 86 bool showJumpTo;
87 bool showUninstalledPkgs; 87 bool showUninstalledPkgs;
88 bool showInstalledPkgs; 88 bool showInstalledPkgs;
89 bool showUpgradedPkgs; 89 bool showUpgradedPkgs;
90 bool downloadEnabled; 90 bool downloadEnabled;
91 91
92 void initMainWidget(); 92 void initMainWidget();
93 void updateData(); 93 void updateData();
94 void serverSelected( int index, bool showProgress ); 94 void serverSelected( int index, bool showProgress );
95 void searchForPackage( const QString & ); 95 void searchForPackage( const QString & );
96 bool filterByCategory( bool val ); 96 bool filterByCategory( bool val );
97 void downloadSelectedPackages(); 97 void downloadSelectedPackages();
98 void downloadRemotePackage(); 98 void downloadRemotePackage();
99 InstallData *dealWithItem( QCheckListItem *item ); 99 InstallData *dealWithItem( QCheckListItem *item );
100 100
101 // Progress widget 101 // Progress widget
102 QWidget *progressWindow; 102 QWidget *progressWindow;
103 QLabel *m_status; 103 QLabel *m_status;
104 QProgressBar *m_progress; 104 QProgressBar *m_progress;
105 105
106 void initProgressWidget(); 106 void initProgressWidget();
107 107
108public slots: 108public slots:
109// void setDocument( const QString &doc ); 109 void setDocument( const QString &doc );
110 void displayFindBar(); 110 void displayFindBar();
111 void displayJumpBar(); 111 void displayJumpBar();
112 void repeatFind(); 112 void repeatFind();
113 void findPackage( const QString & ); 113 void findPackage( const QString & );
114 void hideFindBar(); 114 void hideFindBar();
115 void hideJumpBar(); 115 void hideJumpBar();
116 void displaySettings(); 116 void displaySettings();
117 void filterUninstalledPackages(); 117 void filterUninstalledPackages();
118 void filterInstalledPackages(); 118 void filterInstalledPackages();
119 void filterUpgradedPackages(); 119 void filterUpgradedPackages();
120 void filterCategory(); 120 void filterCategory();
121 bool setFilterCategory(); 121 bool setFilterCategory();
122 void raiseMainWidget(); 122 void raiseMainWidget();
123 void raiseProgressWidget(); 123 void raiseProgressWidget();
124 void enableUpgrade( bool ); 124 void enableUpgrade( bool );
125 void enableDownload( bool ); 125 void enableDownload( bool );
126 void reloadData( InstallDlgImpl * ); 126 void reloadData( InstallDlgImpl * );
127 127
128private slots: 128private slots:
129 void init(); 129 void init();
130 void setProgressSteps( int ); 130 void setProgressSteps( int );
131 void setProgressMessage( const QString & ); 131 void setProgressMessage( const QString & );
132 void updateProgress( int ); 132 void updateProgress( int );
133 void serverSelected( int index ); 133 void serverSelected( int index );