summaryrefslogtreecommitdiff
authordrw <drw>2003-04-17 20:19:52 (UTC)
committer drw <drw>2003-04-17 20:19:52 (UTC)
commitfabadbc7caba39006fcdda5167c29fa287e23cc3 (patch) (unidiff)
treebcd0fe44cd443001514ff4f9e50af5e9da093fcc
parent187e3c56ab0bb2f562c9d6347a99edb440c18d6c (diff)
downloadopie-fabadbc7caba39006fcdda5167c29fa287e23cc3.zip
opie-fabadbc7caba39006fcdda5167c29fa287e23cc3.tar.gz
opie-fabadbc7caba39006fcdda5167c29fa287e23cc3.tar.bz2
Added better verbosity options and option to save ipkg output to a file (per 'bugs' #856 & #857). Also fixed Ok/Cancel behavior on install options dialog.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp58
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h1
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.cpp27
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.h5
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp6
-rw-r--r--noncore/settings/aqpkg/ipkg.h3
6 files changed, 79 insertions, 21 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 2bb8b4d..76d0a80 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,89 +1,94 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.cpp - description 2 installdlgimpl.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <stdio.h> 18#include <stdio.h>
19
20#include <opie/ofiledialog.h>
19 21
20#ifdef QWS 22#ifdef QWS
21#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/fileselector.h>
22#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 26#include <qpe/resource.h>
24#include <qpe/storage.h> 27#include <qpe/storage.h>
25#endif 28#endif
26 29
27#include <qcheckbox.h> 30#include <qcheckbox.h>
28#include <qcombobox.h> 31#include <qcombobox.h>
29#include <qdialog.h> 32#include <qdialog.h>
33#include <qfileinfo.h>
30#include <qgroupbox.h> 34#include <qgroupbox.h>
31#include <qmultilineedit.h> 35#include <qmultilineedit.h>
32#include <qlabel.h> 36#include <qlabel.h>
33#include <qlayout.h> 37#include <qlayout.h>
34#include <qpushbutton.h> 38#include <qpushbutton.h>
35 39
36#include "datamgr.h" 40#include "datamgr.h"
37#include "destination.h" 41#include "destination.h"
38#include "instoptionsimpl.h" 42#include "instoptionsimpl.h"
39#include "installdlgimpl.h" 43#include "installdlgimpl.h"
40#include "ipkg.h" 44#include "ipkg.h"
41#include "utils.h" 45#include "utils.h"
42#include "global.h" 46#include "global.h"
43 47
44enum { 48enum {
45 MAXLINES = 100, 49 MAXLINES = 100,
46}; 50};
47 51
48InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 52InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
49 : QWidget( 0, 0, 0 ) 53 : QWidget( 0, 0, 0 )
50{ 54{
51 setCaption( title ); 55 setCaption( title );
52 init( TRUE ); 56 init( TRUE );
53 57
54 pIpkg = 0; 58 pIpkg = 0;
55 upgradePackages = false; 59 upgradePackages = false;
56 dataMgr = dataManager; 60 dataMgr = dataManager;
57 61
58 QString defaultDest = "root"; 62 QString defaultDest = "root";
59#ifdef QWS 63#ifdef QWS
60 Config cfg( "aqpkg" ); 64 Config cfg( "aqpkg" );
61 cfg.setGroup( "settings" ); 65 cfg.setGroup( "settings" );
62 defaultDest = cfg.readEntry( "dest", "root" ); 66 defaultDest = cfg.readEntry( "dest", "root" );
63 67
64 // 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)
65 flags = cfg.readNumEntry( "installFlags", 0 ); 69 flags = cfg.readNumEntry( "installFlags", 0 );
70 infoLevel = cfg.readNumEntry( "infoLevel", 1 );
66#else 71#else
67 flags = 0; 72 flags = 0;
68#endif 73#endif
69 74
70 // Output text is read only 75 // Output text is read only
71 output->setReadOnly( true ); 76 output->setReadOnly( true );
72 //QFont f( "helvetica" ); 77 //QFont f( "helvetica" );
73 //f.setPointSize( 10 ); 78 //f.setPointSize( 10 );
74 //output->setFont( f ); 79 //output->setFont( f );
75 80
76 81
77 // setup destination data 82 // setup destination data
78 int defIndex = 0; 83 int defIndex = 0;
79 int i; 84 int i;
80 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 85 QListIterator<Destination> dit( dataMgr->getDestinationList() );
81 for ( i = 0; dit.current(); ++dit, ++i ) 86 for ( i = 0; dit.current(); ++dit, ++i )
82 { 87 {
83 destination->insertItem( dit.current()->getDestinationName() ); 88 destination->insertItem( dit.current()->getDestinationName() );
84 if ( dit.current()->getDestinationName() == defaultDest ) 89 if ( dit.current()->getDestinationName() == defaultDest )
85 defIndex = i; 90 defIndex = i;
86 } 91 }
87 92
88 destination->setCurrentItem( defIndex ); 93 destination->setCurrentItem( defIndex );
89 94
@@ -169,59 +174,87 @@ void InstallDlgImpl :: init( bool displayextrainfo )
169 destination = 0x0; 174 destination = 0x0;
170 txtAvailableSpace = 0x0; 175 txtAvailableSpace = 0x0;
171 } 176 }
172 177
173 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 178 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
174 GroupBox2->layout()->setSpacing( 0 ); 179 GroupBox2->layout()->setSpacing( 0 );
175 GroupBox2->layout()->setMargin( 4 ); 180 GroupBox2->layout()->setMargin( 4 );
176 181
177 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 182 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
178 output = new QMultiLineEdit( GroupBox2 ); 183 output = new QMultiLineEdit( GroupBox2 );
179 GroupBox2Layout->addWidget( output ); 184 GroupBox2Layout->addWidget( output );
180 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 185 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
181 186
182 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 187 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
183 layout->addWidget( btnInstall, 3, 0 ); 188 layout->addWidget( btnInstall, 3, 0 );
184 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 189 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
185 190
186 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 191 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
187 layout->addWidget( btnOptions, 3, 1 ); 192 layout->addWidget( btnOptions, 3, 1 );
188 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 193 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
189} 194}
190 195
191void InstallDlgImpl :: optionsSelected() 196void InstallDlgImpl :: optionsSelected()
192{ 197{
193 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 198 if ( btnOptions->text() == tr( "Options" ) )
194 opt.exec(); 199 {
195 200 InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true );
196 // set options selected from dialog 201 if ( opt.exec() == QDialog::Accepted )
197 flags = opt.getFlags(); 202 {
203 // set options selected from dialog
204 flags = opt.getFlags();
205 infoLevel = opt.getInfoLevel();
198 206
199#ifdef QWS 207#ifdef QWS
200 Config cfg( "aqpkg" ); 208 Config cfg( "aqpkg" );
201 cfg.setGroup( "settings" ); 209 cfg.setGroup( "settings" );
202 cfg.writeEntry( "installFlags", flags ); 210 cfg.writeEntry( "installFlags", flags );
211 cfg.writeEntry( "infoLevel", infoLevel );
203#endif 212#endif
213 }
214 }
215 else // Save output
216 {
217 QMap<QString, QStringList> map;
218 map.insert( tr( "All" ), QStringList() );
219 QStringList text;
220 text << "text/*";
221 map.insert(tr( "Text" ), text );
222 text << "*";
223 map.insert( tr( "All" ), text );
224
225 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
226 if( !filename.isEmpty() )
227 {
228 QString currentFileName = QFileInfo( filename ).fileName();
229 DocLnk doc;
230 doc.setType( "text/plain" );
231 doc.setFile( filename );
232 doc.setName( currentFileName );
233 FileManager fm;
234 fm.saveFile( doc, output->text() );
235 }
236 }
204} 237}
205 238
206void InstallDlgImpl :: installSelected() 239void InstallDlgImpl :: installSelected()
207{ 240{
208 if ( btnInstall->text() == tr( "Abort" ) ) 241 if ( btnInstall->text() == tr( "Abort" ) )
209 { 242 {
210 if ( pIpkg ) 243 if ( pIpkg )
211 { 244 {
212 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 245 displayText( tr( "\n**** User Clicked ABORT ***" ) );
213 pIpkg->abort(); 246 pIpkg->abort();
214 displayText( tr( "**** Process Aborted ****" ) ); 247 displayText( tr( "**** Process Aborted ****" ) );
215 } 248 }
216 249
217 btnInstall->setText( tr( "Close" ) ); 250 btnInstall->setText( tr( "Close" ) );
218 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 251 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
219 return; 252 return;
220 } 253 }
221 else if ( btnInstall->text() == tr( "Close" ) ) 254 else if ( btnInstall->text() == tr( "Close" ) )
222 { 255 {
223 emit reloadData( this ); 256 emit reloadData( this );
224 return; 257 return;
225 } 258 }
226 259
227 // Disable buttons 260 // Disable buttons
@@ -251,91 +284,94 @@ void InstallDlgImpl :: installSelected()
251 // Save settings 284 // Save settings
252 Config cfg( "aqpkg" ); 285 Config cfg( "aqpkg" );
253 cfg.setGroup( "settings" ); 286 cfg.setGroup( "settings" );
254 cfg.writeEntry( "dest", dest ); 287 cfg.writeEntry( "dest", dest );
255#endif 288#endif
256 289
257 pIpkg = new Ipkg; 290 pIpkg = new Ipkg;
258 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
259 292
260 // First run through the remove list, then the install list then the upgrade list 293 // First run through the remove list, then the install list then the upgrade list
261 pIpkg->setOption( "remove" ); 294 pIpkg->setOption( "remove" );
262 QListIterator<InstallData> it( removeList ); 295 QListIterator<InstallData> it( removeList );
263 InstallData *idata; 296 InstallData *idata;
264 for ( ; it.current(); ++it ) 297 for ( ; it.current(); ++it )
265 { 298 {
266 idata = it.current(); 299 idata = it.current();
267 pIpkg->setDestination( idata->destination->getDestinationName() ); 300 pIpkg->setDestination( idata->destination->getDestinationName() );
268 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 301 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
269 pIpkg->setPackage( idata->packageName ); 302 pIpkg->setPackage( idata->packageName );
270 303
271 int tmpFlags = flags; 304 int tmpFlags = flags;
272 if ( idata->destination->linkToRoot() ) 305 if ( idata->destination->linkToRoot() )
273 tmpFlags |= MAKE_LINKS; 306 tmpFlags |= MAKE_LINKS;
274 307
275 pIpkg->setFlags( tmpFlags ); 308 pIpkg->setFlags( tmpFlags, infoLevel );
276 pIpkg->runIpkg(); 309 pIpkg->runIpkg();
277 } 310 }
278 311
279 pIpkg->setOption( "install" ); 312 pIpkg->setOption( "install" );
280 pIpkg->setDestination( dest ); 313 pIpkg->setDestination( dest );
281 pIpkg->setDestinationDir( destDir ); 314 pIpkg->setDestinationDir( destDir );
282 pIpkg->setFlags( instFlags ); 315 pIpkg->setFlags( instFlags, infoLevel );
283 QListIterator<InstallData> it2( installList ); 316 QListIterator<InstallData> it2( installList );
284 for ( ; it2.current(); ++it2 ) 317 for ( ; it2.current(); ++it2 )
285 { 318 {
286 pIpkg->setPackage( it2.current()->packageName ); 319 pIpkg->setPackage( it2.current()->packageName );
287 pIpkg->runIpkg(); 320 pIpkg->runIpkg();
288 } 321 }
289 322
290 flags |= FORCE_REINSTALL; 323 flags |= FORCE_REINSTALL;
291 QListIterator<InstallData> it3( updateList ); 324 QListIterator<InstallData> it3( updateList );
292 for ( ; it3.current() ; ++it3 ) 325 for ( ; it3.current() ; ++it3 )
293 { 326 {
294 idata = it3.current(); 327 idata = it3.current();
295 if ( idata->option == "R" ) 328 if ( idata->option == "R" )
296 pIpkg->setOption( "reinstall" ); 329 pIpkg->setOption( "reinstall" );
297 else 330 else
298 pIpkg->setOption( "upgrade" ); 331 pIpkg->setOption( "upgrade" );
299 pIpkg->setDestination( idata->destination->getDestinationName() ); 332 pIpkg->setDestination( idata->destination->getDestinationName() );
300 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 333 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
301 pIpkg->setPackage( idata->packageName ); 334 pIpkg->setPackage( idata->packageName );
302 335
303 int tmpFlags = flags; 336 int tmpFlags = flags;
304 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 337 if ( idata->destination->linkToRoot() && idata->recreateLinks )
305 tmpFlags |= MAKE_LINKS; 338 tmpFlags |= MAKE_LINKS;
306 pIpkg->setFlags( tmpFlags ); 339 pIpkg->setFlags( tmpFlags, infoLevel );
307 pIpkg->runIpkg(); 340 pIpkg->runIpkg();
308 } 341 }
309 342
310 delete pIpkg; 343 delete pIpkg;
311 pIpkg = 0; 344 pIpkg = 0;
312 } 345 }
313 346
314 btnOptions->setEnabled( true ); 347 btnOptions->setEnabled( true );
315// btnInstall->setEnabled( true ); 348// btnInstall->setEnabled( true );
316 btnInstall->setText( tr( "Close" ) ); 349 btnInstall->setText( tr( "Close" ) );
317 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 350 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
351
352 btnOptions->setText( tr( "Save output" ) );
353 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
318 354
319 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 355 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
320 displayAvailableSpace( destination->currentText() ); 356 displayAvailableSpace( destination->currentText() );
321} 357}
322 358
323 359
324void InstallDlgImpl :: displayText(const QString &text ) 360void InstallDlgImpl :: displayText(const QString &text )
325{ 361{
326 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 362 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
327 363
328 /* Set a max line count for the QMultiLineEdit, as users have reported 364 /* Set a max line count for the QMultiLineEdit, as users have reported
329 * performance issues when line count gets extreme. 365 * performance issues when line count gets extreme.
330 */ 366 */
331 if(output->numLines() >= MAXLINES) 367 if(output->numLines() >= MAXLINES)
332 output->removeLine(0); 368 output->removeLine(0);
333 output->setText( newtext ); 369 output->setText( newtext );
334 output->setCursorPosition( output->numLines(), 0 ); 370 output->setCursorPosition( output->numLines(), 0 );
335} 371}
336 372
337 373
338void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 374void InstallDlgImpl :: displayAvailableSpace( const QString &text )
339{ 375{
340 Destination *d = dataMgr->getDestination( text ); 376 Destination *d = dataMgr->getDestination( text );
341 QString destDir = d->getDestinationPath(); 377 QString destDir = d->getDestinationPath();
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index c30963e..15cf427 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -38,48 +38,49 @@ public:
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( 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> installList;
59 QList<InstallData> removeList; 59 QList<InstallData> removeList;
60 QList<InstallData> updateList; 60 QList<InstallData> updateList;
61 int flags; 61 int flags;
62 int infoLevel;
62 Ipkg *pIpkg; 63 Ipkg *pIpkg;
63 bool upgradePackages; 64 bool upgradePackages;
64 65
65 QComboBox *destination; 66 QComboBox *destination;
66 QPushButton *btnInstall; 67 QPushButton *btnInstall;
67 QPushButton *btnOptions; 68 QPushButton *btnOptions;
68 QMultiLineEdit *output; 69 QMultiLineEdit *output;
69 QLabel *txtAvailableSpace; 70 QLabel *txtAvailableSpace;
70 71
71 void init( bool ); 72 void init( bool );
72 73
73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 74 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
74 75
75signals: 76signals:
76 void reloadData( InstallDlgImpl * ); 77 void reloadData( InstallDlgImpl * );
77 78
78public slots: 79public slots:
79 void optionsSelected(); 80 void optionsSelected();
80 void installSelected(); 81 void installSelected();
81 void displayText(const QString &text ); 82 void displayText(const QString &text );
82 void displayAvailableSpace( const QString &text); 83 void displayAvailableSpace( const QString &text);
83}; 84};
84 85
85#endif 86#endif
diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp
index 47b250d..72d794f 100644
--- a/noncore/settings/aqpkg/instoptionsimpl.cpp
+++ b/noncore/settings/aqpkg/instoptionsimpl.cpp
@@ -1,99 +1,116 @@
1/*************************************************************************** 1/***************************************************************************
2 instoptionsimpl.cpp - description 2 instoptionsimpl.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifdef QWS 18#ifdef QWS
19#include <qpe/config.h> 19#include <qpe/config.h>
20#endif 20#endif
21 21
22#include <qcheckbox.h> 22#include <qcheckbox.h>
23#include <qcombobox.h>
23#include <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h>
24#include <qlayout.h> 26#include <qlayout.h>
25 27
26#include "global.h" 28#include "global.h"
27#include "instoptionsimpl.h" 29#include "instoptionsimpl.h"
28#include "ipkg.h" 30#include "ipkg.h"
29 31
30InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, QWidget * parent, const char* name, bool modal, WFlags fl ) 32InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl )
31 : QDialog( parent, name, modal, fl ) 33 : QDialog( parent, name, modal, fl )
32{ 34{
33 setCaption( tr( "Options" ) ); 35 setCaption( tr( "Options" ) );
34 36
35 QVBoxLayout *layout = new QVBoxLayout( this ); 37 QVBoxLayout *layout = new QVBoxLayout( this );
36 layout->setMargin( 2 ); 38 layout->setMargin( 2 );
37 layout->setSpacing( 4 ); 39 layout->setSpacing( 4 );
38 40
39 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); 41 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this );
40 grpbox->layout()->setSpacing( 2 ); 42 grpbox->layout()->setSpacing( 2 );
41 grpbox->layout()->setMargin( 4 ); 43 grpbox->layout()->setMargin( 4 );
42 layout->addWidget( grpbox ); 44 layout->addWidget( grpbox );
43 45
44 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 46 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
45 47
46 forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); 48 forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox );
47 grplayout->addWidget( forceDepends ); 49 grplayout->addWidget( forceDepends );
48 50
49 forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); 51 forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox );
50 grplayout->addWidget( forceReinstall ); 52 grplayout->addWidget( forceReinstall );
51 53
52 forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); 54 forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox );
53 grplayout->addWidget( forceRemove ); 55 grplayout->addWidget( forceRemove );
54 56
55 forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); 57 forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox );
56 grplayout->addWidget( forceOverwrite ); 58 grplayout->addWidget( forceOverwrite );
57 59
58 verboseWget = new QCheckBox( tr( "Verbose WGet" ), grpbox ); 60 QLabel *l = new QLabel( tr( "Information Level" ), grpbox );
59 grplayout->addWidget( verboseWget ); 61 grplayout->addWidget( l );
62
63 verboseIpkg = new QComboBox( grpbox );
64 verboseIpkg->insertItem( tr( "Errors only" ) );
65 verboseIpkg->insertItem( tr( "Normal messages" ) );
66 verboseIpkg->insertItem( tr( "Informative messages" ) );
67 verboseIpkg->insertItem( tr( "Troubleshooting output" ) );
68 verboseIpkg->setCurrentItem( verb );
69 grplayout->addWidget( verboseIpkg );
70
71 grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
60 72
61 if ( flags & FORCE_DEPENDS ) 73 if ( flags & FORCE_DEPENDS )
62 forceDepends->setChecked( true ); 74 forceDepends->setChecked( true );
63 if ( flags & FORCE_REINSTALL ) 75 if ( flags & FORCE_REINSTALL )
64 forceReinstall->setChecked( true ); 76 forceReinstall->setChecked( true );
65 if ( flags & FORCE_REMOVE ) 77 if ( flags & FORCE_REMOVE )
66 forceRemove->setChecked( true ); 78 forceRemove->setChecked( true );
67 if ( flags & FORCE_OVERWRITE ) 79 if ( flags & FORCE_OVERWRITE )
68 forceOverwrite->setChecked( true ); 80 forceOverwrite->setChecked( true );
69 if ( flags & VERBOSE_WGET ) 81// if ( flags & VERBOSE_WGET )
70 verboseWget->setChecked( true ); 82 // verboseWget->setChecked( true );
71// if ( flags & MAKE_LINKS ) 83// if ( flags & MAKE_LINKS )
72 // makeLinks->setChecked( true ); 84 // makeLinks->setChecked( true );
73 85
74 showMaximized(); 86 showMaximized();
75 87
76} 88}
77 89
78InstallOptionsDlgImpl::~InstallOptionsDlgImpl() 90InstallOptionsDlgImpl::~InstallOptionsDlgImpl()
79{ 91{
80} 92}
81 93
82 94
83int InstallOptionsDlgImpl :: getFlags() 95int InstallOptionsDlgImpl :: getFlags()
84{ 96{
85 int flags = 0; 97 int flags = 0;
86 98
87 if ( forceDepends->isChecked() ) 99 if ( forceDepends->isChecked() )
88 flags |= FORCE_DEPENDS; 100 flags |= FORCE_DEPENDS;
89 if ( forceReinstall->isChecked() ) 101 if ( forceReinstall->isChecked() )
90 flags |= FORCE_REINSTALL; 102 flags |= FORCE_REINSTALL;
91 if ( forceRemove->isChecked() ) 103 if ( forceRemove->isChecked() )
92 flags |= FORCE_REMOVE; 104 flags |= FORCE_REMOVE;
93 if ( forceOverwrite->isChecked() ) 105 if ( forceOverwrite->isChecked() )
94 flags |= FORCE_OVERWRITE; 106 flags |= FORCE_OVERWRITE;
95 if ( verboseWget->isChecked() ) 107 if ( verboseWget->isChecked() )
96 flags |= VERBOSE_WGET; 108 flags |= VERBOSE_WGET;
97 109
98 return flags; 110 return flags;
99} 111}
112
113int InstallOptionsDlgImpl :: getInfoLevel()
114{
115 return verboseIpkg->currentItem();
116}
diff --git a/noncore/settings/aqpkg/instoptionsimpl.h b/noncore/settings/aqpkg/instoptionsimpl.h
index f4724a0..1312afd 100644
--- a/noncore/settings/aqpkg/instoptionsimpl.h
+++ b/noncore/settings/aqpkg/instoptionsimpl.h
@@ -1,40 +1,43 @@
1/*************************************************************************** 1/***************************************************************************
2 installoptionsimpl.h - description 2 installoptionsimpl.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#ifndef INSTALLOPTIONSIMPL_H 17#ifndef INSTALLOPTIONSIMPL_H
18#define INSTALLOPTIONSIMPL_H 18#define INSTALLOPTIONSIMPL_H
19 19
20#include <qdialog.h> 20#include <qdialog.h>
21 21
22class QCheckBox; 22class QCheckBox;
23class QComboBox;
23 24
24class InstallOptionsDlgImpl : public QDialog 25class InstallOptionsDlgImpl : public QDialog
25{ 26{
26 Q_OBJECT 27 Q_OBJECT
27public: 28public:
28 InstallOptionsDlgImpl( int flags, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); 29 InstallOptionsDlgImpl( int, int, QWidget * = 0, const char * = 0, bool = false, WFlags = 0 );
29 ~InstallOptionsDlgImpl(); 30 ~InstallOptionsDlgImpl();
30 int getFlags(); 31 int getFlags();
32 int getInfoLevel();
31 33
32private: 34private:
33 QCheckBox* forceDepends; 35 QCheckBox* forceDepends;
34 QCheckBox* forceReinstall; 36 QCheckBox* forceReinstall;
35 QCheckBox* forceRemove; 37 QCheckBox* forceRemove;
36 QCheckBox* forceOverwrite; 38 QCheckBox* forceOverwrite;
37 QCheckBox* verboseWget; 39 QCheckBox* verboseWget;
40 QComboBox* verboseIpkg;
38}; 41};
39 42
40#endif 43#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index e66c02d..7df643e 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -48,66 +48,66 @@ Ipkg :: ~Ipkg()
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( ) 58bool Ipkg :: runIpkg( )
59{ 59{
60 error = false; 60 error = false;
61 bool ret = false; 61 bool ret = false;
62 QStringList commands; 62 QStringList commands;
63 63
64 QDir::setCurrent( "/tmp" ); 64 QDir::setCurrent( "/tmp" );
65 65
66 if ( runtimeDir != "" ) 66 if ( runtimeDir != "" )
67 { 67 {
68 commands << "cd "; 68 commands << "cd ";
69 commands << runtimeDir; 69 commands << runtimeDir;
70 commands << ";"; 70 commands << ";";
71 } 71 }
72 commands << "ipkg" << "-force-defaults"; 72 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults";
73 73
74 // only set the destination for an install operation 74 // only set the destination for an install operation
75 if ( option == "install" ) 75 if ( option == "install" )
76 commands << "-dest" << destination; 76 commands << "-dest" << destination;
77 77
78 78
79 if ( option != "update" && option != "download" ) 79 if ( option != "update" && option != "download" )
80 { 80 {
81 if ( flags & FORCE_DEPENDS ) 81 if ( flags & FORCE_DEPENDS )
82 commands << "-force-depends"; 82 commands << "-force-depends";
83 if ( flags & FORCE_REINSTALL ) 83 if ( flags & FORCE_REINSTALL )
84 commands << "-force-reinstall"; 84 commands << "-force-reinstall";
85 if ( flags & FORCE_REMOVE ) 85 if ( flags & FORCE_REMOVE )
86 commands << "-force-removal-of-essential-packages"; 86 commands << "-force-removal-of-essential-packages";
87 if ( flags & FORCE_OVERWRITE ) 87 if ( flags & FORCE_OVERWRITE )
88 commands << "-force-overwrite"; 88 commands << "-force-overwrite";
89 if ( flags & VERBOSE_WGET ) 89 if ( infoLevel == 3 )
90 commands << "-verbose_wget"; 90 commands << "-verbose_wget";
91 91
92 // Handle make links 92 // Handle make links
93 // Rules - If make links is switched on, create links to root 93 // Rules - If make links is switched on, create links to root
94 // if destDir is NOT / 94 // if destDir is NOT /
95 if ( flags & MAKE_LINKS ) 95 if ( flags & MAKE_LINKS )
96 { 96 {
97 // If destDir == / turn off make links as package is being insalled 97 // If destDir == / turn off make links as package is being insalled
98 // to root already. 98 // to root already.
99 if ( destDir == "/" ) 99 if ( destDir == "/" )
100 flags ^= MAKE_LINKS; 100 flags ^= MAKE_LINKS;
101 } 101 }
102 } 102 }
103 103
104#ifdef X86 104#ifdef X86
105 commands << "-f"; 105 commands << "-f";
106 commands << IPKG_CONF; 106 commands << IPKG_CONF;
107#endif 107#endif
108 108
109 109
110 if ( option == "reinstall" ) 110 if ( option == "reinstall" )
111 commands << "install"; 111 commands << "install";
112 else 112 else
113 commands << option; 113 commands << option;
@@ -232,49 +232,49 @@ void Ipkg :: removeStatusEntry()
232 continue; 232 continue;
233 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 233 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
234 } 234 }
235 235
236 lines.push_back( QString( line ) ); 236 lines.push_back( QString( line ) );
237// out << line << endl; 237// out << line << endl;
238 } while ( !in.eof() ); 238 } while ( !in.eof() );
239 239
240 // Write lines out 240 // Write lines out
241 vector<QString>::iterator it; 241 vector<QString>::iterator it;
242 for ( it = lines.begin() ; it != lines.end() ; ++it ) 242 for ( it = lines.begin() ; it != lines.end() ; ++it )
243 { 243 {
244 cout << "Writing " << (const char *)(*it) << endl; 244 cout << "Writing " << (const char *)(*it) << endl;
245 out << (const char *)(*it) << endl; 245 out << (const char *)(*it) << endl;
246 } 246 }
247 247
248 in.close(); 248 in.close();
249 out.close(); 249 out.close();
250 250
251 // Remove old status file and put tmp stats file in its place 251 // Remove old status file and put tmp stats file in its place
252 remove( statusFile ); 252 remove( statusFile );
253 rename( outStatusFile, statusFile ); 253 rename( outStatusFile, statusFile );
254} 254}
255 255
256int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option ) 256int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
257{ 257{
258 // If one is already running - should never be but just to be safe 258 // If one is already running - should never be but just to be safe
259 if ( proc ) 259 if ( proc )
260 { 260 {
261 delete proc; 261 delete proc;
262 proc = 0; 262 proc = 0;
263 } 263 }
264 264
265 // OK we're gonna use OProcess to run this thing 265 // OK we're gonna use OProcess to run this thing
266 proc = new OProcess(); 266 proc = new OProcess();
267 aborted = false; 267 aborted = false;
268 268
269 269
270 // Connect up our slots 270 // Connect up our slots
271 connect(proc, SIGNAL(processExited(OProcess *)), 271 connect(proc, SIGNAL(processExited(OProcess *)),
272 this, SLOT( processFinished())); 272 this, SLOT( processFinished()));
273 273
274 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 274 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
275 this, SLOT(commandStdout(OProcess *, char *, int))); 275 this, SLOT(commandStdout(OProcess *, char *, int)));
276 276
277 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 277 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
278 this, SLOT(commandStderr(OProcess *, char *, int))); 278 this, SLOT(commandStderr(OProcess *, char *, int)));
279 279
280 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) 280 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index d49bb04..531bfc0 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -28,62 +28,63 @@
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 bool runIpkg( );
47 47
48 void setOption( const char *opt ) { option = opt; } 48 void setOption( const char *opt ) { option = opt; }
49 void setPackage( const char *pkg ) { package = pkg; } 49 void setPackage( const char *pkg ) { package = pkg; }
50 void setDestination( const char *dest ) { destination = dest; } 50 void setDestination( const char *dest ) { destination = dest; }
51 void setDestinationDir( const char *dir ) { destDir = dir; } 51 void setDestinationDir( const char *dir ) { destDir = dir; }
52 void setFlags( int fl ) { flags = fl; } 52 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; }
53 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } 53 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
54 54
55signals: 55signals:
56 void outputText( const QString &text ); 56 void outputText( const QString &text );
57 57
58public slots: 58public slots:
59 void commandStdout(OProcess*, char *buffer, int buflen); 59 void commandStdout(OProcess*, char *buffer, int buflen);
60 void commandStderr(OProcess*, char *buffer, int buflen); 60 void commandStderr(OProcess*, char *buffer, int buflen);
61 void processFinished(); 61 void processFinished();
62 void abort(); 62 void abort();
63 63
64 64
65private: 65private:
66 bool createLinks; 66 bool createLinks;
67 bool aborted; 67 bool aborted;
68 bool error; 68 bool error;
69 QString option; 69 QString option;
70 QString package; 70 QString package;
71 QString destination; 71 QString destination;
72 QString destDir; 72 QString destDir;
73 QString runtimeDir; 73 QString runtimeDir;
74 OProcess *proc; 74 OProcess *proc;
75 int flags; 75 int flags;
76 int infoLevel;
76 bool finished; 77 bool finished;
77 78
78 QList<QString> *dependantPackages; 79 QList<QString> *dependantPackages;
79 80
80 int executeIpkgCommand( QStringList &cmd, const QString option ); 81 int executeIpkgCommand( QStringList &cmd, const QString option );
81 void removeStatusEntry(); 82 void removeStatusEntry();
82 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); 83 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir );
83 QStringList* getList( const QString &packageFilename, const QString &destDir ); 84 QStringList* getList( const QString &packageFilename, const QString &destDir );
84 void processFileList( const QStringList *fileList, const QString &destDir ); 85 void processFileList( const QStringList *fileList, const QString &destDir );
85 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); 86 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir );
86 87
87}; 88};
88 89
89#endif 90#endif