summaryrefslogtreecommitdiff
path: root/noncore
authordrw <drw>2003-04-26 22:42:19 (UTC)
committer drw <drw>2003-04-26 22:42:19 (UTC)
commit98a9291263e167b8882ac916330e7215ebd884b4 (patch) (unidiff)
tree882a909e9381ab4cc97e77377fd61361d7f21eab /noncore
parent64c48b637c1bd1bef679bff500f3e0ce5365358d (diff)
downloadopie-98a9291263e167b8882ac916330e7215ebd884b4.zip
opie-98a9291263e167b8882ac916330e7215ebd884b4.tar.gz
opie-98a9291263e167b8882ac916330e7215ebd884b4.tar.bz2
1. Fix for bug #872 - reduce CPU useage while ipkg is doing its thing 2. Re-enable setDocument function for identifying local ipks
Diffstat (limited to 'noncore') (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
@@ -46,13 +46,13 @@
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;
@@ -98,42 +98,41 @@ InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *da
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 );
@@ -265,12 +264,13 @@ void InstallDlgImpl :: installSelected()
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() );
@@ -286,15 +286,20 @@ void InstallDlgImpl :: installSelected()
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() );
@@ -339,24 +344,14 @@ void InstallDlgImpl :: installSelected()
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 );
@@ -397,6 +392,75 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text )
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
@@ -42,25 +42,24 @@ public:
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;
@@ -78,9 +77,10 @@ signals:
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
@@ -52,16 +52,15 @@ Ipkg :: ~Ipkg()
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 {
@@ -134,17 +133,18 @@ bool Ipkg :: runIpkg( )
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 )
@@ -168,13 +168,12 @@ bool Ipkg :: runIpkg( )
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 ) != "/" )
@@ -292,16 +291,12 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
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' )
@@ -351,12 +346,14 @@ void Ipkg::processFinished()
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 )
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
@@ -40,23 +40,25 @@ class OProcess;
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();
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
@@ -294,13 +294,13 @@ void MainWindow :: init()
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
@@ -324,13 +324,13 @@ void MainWindow :: setDocument( const QString &doc )
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 );
@@ -989,20 +989,20 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
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
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
@@ -103,13 +103,13 @@ private:
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();