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,366 +1,402 @@
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
90 QListIterator<InstallData> it( packageList ); 95 QListIterator<InstallData> it( packageList );
91 // setup package data 96 // setup package data
92 QString remove = tr( "Remove\n" ); 97 QString remove = tr( "Remove\n" );
93 QString install = tr( "Install\n" ); 98 QString install = tr( "Install\n" );
94 QString upgrade = tr( "Upgrade\n" ); 99 QString upgrade = tr( "Upgrade\n" );
95 for ( ; it.current(); ++it ) 100 for ( ; it.current(); ++it )
96 { 101 {
97 InstallData *item = it.current(); 102 InstallData *item = it.current();
98 InstallData *newitem = new InstallData(); 103 InstallData *newitem = new InstallData();
99 104
100 newitem->option = item->option; 105 newitem->option = item->option;
101 newitem->packageName = item->packageName; 106 newitem->packageName = item->packageName;
102 newitem->destination = item->destination; 107 newitem->destination = item->destination;
103 newitem->recreateLinks = item->recreateLinks; 108 newitem->recreateLinks = item->recreateLinks;
104 109
105 if ( item->option == "I" ) 110 if ( item->option == "I" )
106 { 111 {
107 installList.append( newitem ); 112 installList.append( newitem );
108 install.append( QString( " %1\n" ).arg( item->packageName ) ); 113 install.append( QString( " %1\n" ).arg( item->packageName ) );
109 } 114 }
110 else if ( item->option == "D" ) 115 else if ( item->option == "D" )
111 { 116 {
112 removeList.append( newitem ); 117 removeList.append( newitem );
113 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 118 remove.append( QString( " %1\n" ).arg( item->packageName ) );
114 } 119 }
115 else if ( item->option == "U" || item->option == "R" ) 120 else if ( item->option == "U" || item->option == "R" )
116 { 121 {
117 updateList.append( newitem ); 122 updateList.append( newitem );
118 QString type; 123 QString type;
119 if ( item->option == "R" ) 124 if ( item->option == "R" )
120 type = tr( "(ReInstall)" ); 125 type = tr( "(ReInstall)" );
121 else 126 else
122 type = tr( "(Upgrade)" ); 127 type = tr( "(Upgrade)" );
123 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 128 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
124 } 129 }
125 } 130 }
126 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); 131 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
127 132
128 displayAvailableSpace( destination->currentText() ); 133 displayAvailableSpace( destination->currentText() );
129} 134}
130 135
131InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 136InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
132 : QWidget( 0, 0, 0 ) 137 : QWidget( 0, 0, 0 )
133{ 138{
134 setCaption( title ); 139 setCaption( title );
135 init( FALSE ); 140 init( FALSE );
136 pIpkg = ipkg; 141 pIpkg = ipkg;
137 output->setText( initialText ); 142 output->setText( initialText );
138} 143}
139 144
140 145
141InstallDlgImpl::~InstallDlgImpl() 146InstallDlgImpl::~InstallDlgImpl()
142{ 147{
143 if ( pIpkg ) 148 if ( pIpkg )
144 delete pIpkg; 149 delete pIpkg;
145} 150}
146 151
147void InstallDlgImpl :: init( bool displayextrainfo ) 152void InstallDlgImpl :: init( bool displayextrainfo )
148{ 153{
149 QGridLayout *layout = new QGridLayout( this ); 154 QGridLayout *layout = new QGridLayout( this );
150 layout->setSpacing( 4 ); 155 layout->setSpacing( 4 );
151 layout->setMargin( 4 ); 156 layout->setMargin( 4 );
152 157
153 if ( displayextrainfo ) 158 if ( displayextrainfo )
154 { 159 {
155 QLabel *label = new QLabel( tr( "Destination" ), this ); 160 QLabel *label = new QLabel( tr( "Destination" ), this );
156 layout->addWidget( label, 0, 0 ); 161 layout->addWidget( label, 0, 0 );
157 destination = new QComboBox( FALSE, this ); 162 destination = new QComboBox( FALSE, this );
158 layout->addWidget( destination, 0, 1 ); 163 layout->addWidget( destination, 0, 1 );
159 connect( destination, SIGNAL( highlighted( const QString & ) ), 164 connect( destination, SIGNAL( highlighted( const QString & ) ),
160 this, SLOT( displayAvailableSpace( const QString & ) ) ); 165 this, SLOT( displayAvailableSpace( const QString & ) ) );
161 166
162 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 167 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
163 layout->addWidget( label2, 1, 0 ); 168 layout->addWidget( label2, 1, 0 );
164 txtAvailableSpace = new QLabel( "", this ); 169 txtAvailableSpace = new QLabel( "", this );
165 layout->addWidget( txtAvailableSpace, 1, 1 ); 170 layout->addWidget( txtAvailableSpace, 1, 1 );
166 } 171 }
167 else 172 else
168 { 173 {
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
228 btnOptions->setEnabled( false ); 261 btnOptions->setEnabled( false );
229// btnInstall->setEnabled( false ); 262// btnInstall->setEnabled( false );
230 263
231 btnInstall->setText( tr( "Abort" ) ); 264 btnInstall->setText( tr( "Abort" ) );
232 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 265 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
233 266
234 if ( pIpkg ) 267 if ( pIpkg )
235 { 268 {
236 output->setText( "" ); 269 output->setText( "" );
237 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 270 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
238 pIpkg->runIpkg(); 271 pIpkg->runIpkg();
239 } 272 }
240 else 273 else
241 { 274 {
242 output->setText( "" ); 275 output->setText( "" );
243 Destination *d = dataMgr->getDestination( destination->currentText() ); 276 Destination *d = dataMgr->getDestination( destination->currentText() );
244 QString dest = d->getDestinationName(); 277 QString dest = d->getDestinationName();
245 QString destDir = d->getDestinationPath(); 278 QString destDir = d->getDestinationPath();
246 int instFlags = flags; 279 int instFlags = flags;
247 if ( d->linkToRoot() ) 280 if ( d->linkToRoot() )
248 instFlags |= MAKE_LINKS; 281 instFlags |= MAKE_LINKS;
249 282
250#ifdef QWS 283#ifdef QWS
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();
342 378
343 long blockSize = 0; 379 long blockSize = 0;
344 long totalBlocks = 0; 380 long totalBlocks = 0;
345 long availBlocks = 0; 381 long availBlocks = 0;
346 QString space; 382 QString space;
347 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 383 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
348 { 384 {
349 long mult = blockSize / 1024; 385 long mult = blockSize / 1024;
350 long div = 1024 / blockSize; 386 long div = 1024 / blockSize;
351 387
352 if ( !mult ) mult = 1; 388 if ( !mult ) mult = 1;
353 if ( !div ) div = 1; 389 if ( !div ) div = 1;
354// long total = totalBlocks * mult / div; 390// long total = totalBlocks * mult / div;
355 long avail = availBlocks * mult / div; 391 long avail = availBlocks * mult / div;
356// long used = total - avail; 392// long used = total - avail;
357 393
358 space.sprintf( "%ld Kb", avail ); 394 space.sprintf( "%ld Kb", avail );
359 } 395 }
360 else 396 else
361 space = tr( "Unknown" ); 397 space = tr( "Unknown" );
362 398
363 if ( txtAvailableSpace ) 399 if ( txtAvailableSpace )
364 txtAvailableSpace->setText( space ); 400 txtAvailableSpace->setText( space );
365} 401}
366 402
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
@@ -1,85 +1,86 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.h - description 2 installdlgimpl.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 INSTALLDLGIMPL_H 17#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H 18#define INSTALLDLGIMPL_H
19 19
20using namespace std; 20using namespace std;
21 21
22#include <qlist.h> 22#include <qlist.h>
23#include <qstring.h> 23#include <qstring.h>
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( 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
@@ -1,566 +1,566 @@
1/*************************************************************************** 1/***************************************************************************
2 ipkg.cpp - description 2 ipkg.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat Aug 31 2002 4 begin : Sat Aug 31 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 <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20#include <vector> 20#include <vector>
21using namespace std; 21using namespace std;
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <unistd.h> 24#include <unistd.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#else 28#else
29#include <qapplication.h> 29#include <qapplication.h>
30#endif 30#endif
31#include <qdir.h> 31#include <qdir.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33 33
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( ) 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;
114 if ( package != "" ) 114 if ( package != "" )
115 commands << package; 115 commands << package;
116 116
117 117
118 if ( package != "" ) 118 if ( package != "" )
119 emit outputText( QString( "Dealing with package " ) + package ); 119 emit outputText( QString( "Dealing with package " ) + package );
120 120
121 qApp->processEvents(); 121 qApp->processEvents();
122 122
123 // If we are removing, reinstalling or upgrading packages and make links option is selected 123 // If we are removing, reinstalling or upgrading packages and make links option is selected
124 // create the links 124 // create the links
125 if ( option == "remove" || option == "reinstall" || option == "upgrade" ) 125 if ( option == "remove" || option == "reinstall" || option == "upgrade" )
126 { 126 {
127 createLinks = false; 127 createLinks = false;
128 if ( flags & MAKE_LINKS ) 128 if ( flags & MAKE_LINKS )
129 { 129 {
130 emit outputText( QString( "Removing symbolic links...\n" ) ); 130 emit outputText( QString( "Removing symbolic links...\n" ) );
131 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 131 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
132 emit outputText( QString( " " ) ); 132 emit outputText( QString( " " ) );
133 } 133 }
134 } 134 }
135 135
136 // Execute command 136 // Execute command
137 dependantPackages = new QList<QString>; 137 dependantPackages = new QList<QString>;
138 dependantPackages->setAutoDelete( true ); 138 dependantPackages->setAutoDelete( true );
139 139
140 ret = executeIpkgCommand( commands, option ); 140 ret = executeIpkgCommand( commands, option );
141 141
142 if ( aborted ) 142 if ( aborted )
143 return false; 143 return false;
144 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; 174 return ret;
175 175
176} 176}
177 177
178void Ipkg :: removeStatusEntry() 178void Ipkg :: removeStatusEntry()
179{ 179{
180 QString statusFile = destDir; 180 QString statusFile = destDir;
181 if ( statusFile.right( 1 ) != "/" ) 181 if ( statusFile.right( 1 ) != "/" )
182 statusFile += "/"; 182 statusFile += "/";
183 statusFile += "usr/lib/ipkg/status"; 183 statusFile += "usr/lib/ipkg/status";
184 QString outStatusFile = statusFile + ".tmp"; 184 QString outStatusFile = statusFile + ".tmp";
185 185
186 emit outputText( "" ); 186 emit outputText( "" );
187 emit outputText( "Removing status entry..." ); 187 emit outputText( "Removing status entry..." );
188 emit outputText( QString( "status file - " )+ statusFile ); 188 emit outputText( QString( "status file - " )+ statusFile );
189 emit outputText( QString( "package - " )+ package ); 189 emit outputText( QString( "package - " )+ package );
190 190
191 ifstream in( statusFile ); 191 ifstream in( statusFile );
192 ofstream out( outStatusFile ); 192 ofstream out( outStatusFile );
193 if ( !in.is_open() ) 193 if ( !in.is_open() )
194 { 194 {
195 emit outputText( QString( "Couldn't open status file - " )+ statusFile ); 195 emit outputText( QString( "Couldn't open status file - " )+ statusFile );
196 return; 196 return;
197 } 197 }
198 198
199 if ( !out.is_open() ) 199 if ( !out.is_open() )
200 { 200 {
201 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile ); 201 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile );
202 return; 202 return;
203 } 203 }
204 204
205 char line[1001]; 205 char line[1001];
206 char k[21]; 206 char k[21];
207 char v[1001]; 207 char v[1001];
208 QString key; 208 QString key;
209 QString value; 209 QString value;
210 vector<QString> lines; 210 vector<QString> lines;
211 do 211 do
212 { 212 {
213 in.getline( line, 1000 ); 213 in.getline( line, 1000 );
214 if ( in.eof() ) 214 if ( in.eof() )
215 continue; 215 continue;
216 216
217 k[0] = '\0'; 217 k[0] = '\0';
218 v[0] = '\0'; 218 v[0] = '\0';
219 219
220 sscanf( line, "%[^:]: %[^\n]", k, v ); 220 sscanf( line, "%[^:]: %[^\n]", k, v );
221 key = k; 221 key = k;
222 value = v; 222 value = v;
223 key = key.stripWhiteSpace(); 223 key = key.stripWhiteSpace();
224 value = value.stripWhiteSpace(); 224 value = value.stripWhiteSpace();
225 if ( key == "Package" && value == package ) 225 if ( key == "Package" && value == package )
226 { 226 {
227 // Ignore all lines up to next empty 227 // Ignore all lines up to next empty
228 do 228 do
229 { 229 {
230 in.getline( line, 1000 ); 230 in.getline( line, 1000 );
231 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 231 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
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 )
281 { 281 {
282 qDebug( "%s ", (*it).latin1() ); 282 qDebug( "%s ", (*it).latin1() );
283 *proc << (*it).latin1(); 283 *proc << (*it).latin1();
284 } 284 }
285 cout << endl; 285 cout << endl;
286 286
287 // Start the process going 287 // Start the process going
288 finished = false; 288 finished = false;
289 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) 289 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
290 { 290 {
291 emit outputText( QString( "Couldn't start ipkg process" ) ); 291 emit outputText( QString( "Couldn't start ipkg process" ) );
292 qDebug( "Couldn't start ipkg process!" ); 292 qDebug( "Couldn't start ipkg process!" );
293 } 293 }
294 294
295 // Now wait for it to finish 295 // Now wait for it to finish
296 while ( !finished ) 296 while ( !finished )
297 qApp->processEvents(); 297 qApp->processEvents();
298} 298}
299 299
300void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) 300void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
301{ 301{
302 qDebug("received stdout %d bytes", buflen); 302 qDebug("received stdout %d bytes", buflen);
303 303
304 QString lineStr = buffer; 304 QString lineStr = buffer;
305 if ( lineStr[buflen-1] == '\n' ) 305 if ( lineStr[buflen-1] == '\n' )
306 buflen --; 306 buflen --;
307 lineStr = lineStr.left( buflen ); 307 lineStr = lineStr.left( buflen );
308 emit outputText( lineStr ); 308 emit outputText( lineStr );
309 309
310 // check if we are installing dependant packages 310 // check if we are installing dependant packages
311 if ( option == "install" || option == "reinstall" ) 311 if ( option == "install" || option == "reinstall" )
312 { 312 {
313 // Need to keep track of any dependant packages that get installed 313 // Need to keep track of any dependant packages that get installed
314 // so that we can create links to them as necessary 314 // so that we can create links to them as necessary
315 if ( lineStr.startsWith( "Installing " ) ) 315 if ( lineStr.startsWith( "Installing " ) )
316 { 316 {
317 int start = lineStr.find( " " ) + 1; 317 int start = lineStr.find( " " ) + 1;
318 int end = lineStr.find( " ", start ); 318 int end = lineStr.find( " ", start );
319 QString *package = new QString( lineStr.mid( start, end-start ) ); 319 QString *package = new QString( lineStr.mid( start, end-start ) );
320 dependantPackages->append( package ); 320 dependantPackages->append( package );
321 } 321 }
322 } 322 }
323 323
324 qDebug(lineStr); 324 qDebug(lineStr);
325 buffer[0] = '\0'; 325 buffer[0] = '\0';
326} 326}
327 327
328void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) 328void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
329{ 329{
330 qDebug("received stderrt %d bytes", buflen); 330 qDebug("received stderrt %d bytes", buflen);
331 331
332 QString lineStr = buffer; 332 QString lineStr = buffer;
333 if ( lineStr[buflen-1] == '\n' ) 333 if ( lineStr[buflen-1] == '\n' )
334 buflen --; 334 buflen --;
335 lineStr=lineStr.left( buflen ); 335 lineStr=lineStr.left( buflen );
336 emit outputText( lineStr ); 336 emit outputText( lineStr );
337 buffer[0] = '\0'; 337 buffer[0] = '\0';
338 error = true; 338 error = true;
339} 339}
340 340
341void Ipkg::processFinished() 341void Ipkg::processFinished()
342{ 342{
343 // 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
344 // 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
345 if ( !error && option == "remove" ) 345 if ( !error && option == "remove" )
346 removeStatusEntry(); 346 removeStatusEntry();
347 347
348 delete proc; 348 delete proc;
349 proc = 0; 349 proc = 0;
350 finished = true; 350 finished = true;
351} 351}
352 352
353 353
354void Ipkg :: abort() 354void Ipkg :: abort()
355{ 355{
356 if ( proc ) 356 if ( proc )
357 { 357 {
358 proc->kill(); 358 proc->kill();
359 aborted = true; 359 aborted = true;
360 } 360 }
361} 361}
362 362
363/* 363/*
364int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 364int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
365{ 365{
366 FILE *fp = NULL; 366 FILE *fp = NULL;
367 char line[130]; 367 char line[130];
368 QString lineStr, lineStrOld; 368 QString lineStr, lineStrOld;
369 int ret = false; 369 int ret = false;
370 370
371 fp = popen( (const char *) cmd, "r"); 371 fp = popen( (const char *) cmd, "r");
372 if ( fp == NULL ) 372 if ( fp == NULL )
373 { 373 {
374 cout << "Couldn't execute " << cmd << "! err = " << fp << endl; 374 cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
375 QString text; 375 QString text;
376 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 376 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
377 emit outputText( text ); 377 emit outputText( text );
378 } 378 }
379 else 379 else
380 { 380 {
381 while ( fgets( line, sizeof line, fp) != NULL ) 381 while ( fgets( line, sizeof line, fp) != NULL )
382 { 382 {
383 lineStr = line; 383 lineStr = line;
384 lineStr=lineStr.left( lineStr.length()-1 ); 384 lineStr=lineStr.left( lineStr.length()-1 );
385 385
386 if ( lineStr != lineStrOld ) 386 if ( lineStr != lineStrOld )
387 { 387 {
388 //See if we're finished 388 //See if we're finished
389 if ( option == "install" || option == "reinstall" ) 389 if ( option == "install" || option == "reinstall" )
390 { 390 {
391 // Need to keep track of any dependant packages that get installed 391 // Need to keep track of any dependant packages that get installed
392 // so that we can create links to them as necessary 392 // so that we can create links to them as necessary
393 if ( lineStr.startsWith( "Installing " ) ) 393 if ( lineStr.startsWith( "Installing " ) )
394 { 394 {
395 int start = lineStr.find( " " ) + 1; 395 int start = lineStr.find( " " ) + 1;
396 int end = lineStr.find( " ", start ); 396 int end = lineStr.find( " ", start );
397 QString *package = new QString( lineStr.mid( start, end-start ) ); 397 QString *package = new QString( lineStr.mid( start, end-start ) );
398 dependantPackages->append( package ); 398 dependantPackages->append( package );
399 } 399 }
400 } 400 }
401 401
402 if ( option == "update" ) 402 if ( option == "update" )
403 { 403 {
404 if (lineStr.contains("Updated list")) 404 if (lineStr.contains("Updated list"))
405 ret = true; 405 ret = true;
406 } 406 }
407 else if ( option == "download" ) 407 else if ( option == "download" )
408 { 408 {
409 if (lineStr.contains("Downloaded")) 409 if (lineStr.contains("Downloaded"))
410 ret = true; 410 ret = true;
411 } 411 }
412 else 412 else
413 { 413 {
414 if (lineStr.contains("Done")) 414 if (lineStr.contains("Done"))
415 ret = true; 415 ret = true;
416 } 416 }
417 417
418 emit outputText( lineStr ); 418 emit outputText( lineStr );
419 } 419 }
420 lineStrOld = lineStr; 420 lineStrOld = lineStr;
421 qApp->processEvents(); 421 qApp->processEvents();
422 } 422 }
423 pclose(fp); 423 pclose(fp);
424 } 424 }
425 425
426 return ret; 426 return ret;
427} 427}
428*/ 428*/
429 429
430void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 430void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
431{ 431{
432 if ( dest == "root" || dest == "/" ) 432 if ( dest == "root" || dest == "/" )
433 return; 433 return;
434 434
435 qApp->processEvents(); 435 qApp->processEvents();
436 QStringList *fileList = getList( packFileName, destDir ); 436 QStringList *fileList = getList( packFileName, destDir );
437 qApp->processEvents(); 437 qApp->processEvents();
438 processFileList( fileList, destDir ); 438 processFileList( fileList, destDir );
439 delete fileList; 439 delete fileList;
440} 440}
441 441
442QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 442QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
443{ 443{
444 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; 444 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list";
445 QFile f( packageFileDir ); 445 QFile f( packageFileDir );
446 446
447 cout << "Try to open " << packageFileDir << endl; 447 cout << "Try to open " << packageFileDir << endl;
448 if ( !f.open(IO_ReadOnly) ) 448 if ( !f.open(IO_ReadOnly) )
449 { 449 {
450 // Couldn't open from dest, try from / 450 // Couldn't open from dest, try from /
451 cout << "Could not open:" << packageFileDir << endl; 451 cout << "Could not open:" << packageFileDir << endl;
452 f.close(); 452 f.close();
453 453
454 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; 454 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list";
455 f.setName( packageFileDir ); 455 f.setName( packageFileDir );
456 qDebug( "Try to open %s", packageFileDir.latin1() ); 456 qDebug( "Try to open %s", packageFileDir.latin1() );
457 if ( ! f.open(IO_ReadOnly) ) 457 if ( ! f.open(IO_ReadOnly) )
458 { 458 {
459 qDebug( "Could not open: %s", packageFileDir.latin1() ); 459 qDebug( "Could not open: %s", packageFileDir.latin1() );
460 emit outputText( QString( "Could not open :" ) + packageFileDir ); 460 emit outputText( QString( "Could not open :" ) + packageFileDir );
461 return (QStringList*)0; 461 return (QStringList*)0;
462 } 462 }
463 } 463 }
464 QStringList *fileList = new QStringList(); 464 QStringList *fileList = new QStringList();
465 QTextStream t( &f ); 465 QTextStream t( &f );
466 while ( !t.eof() ) 466 while ( !t.eof() )
467 *fileList += t.readLine(); 467 *fileList += t.readLine();
468 468
469 f.close(); 469 f.close();
470 return fileList; 470 return fileList;
471} 471}
472 472
473void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 473void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
474{ 474{
475 if ( !fileList || fileList->isEmpty() ) 475 if ( !fileList || fileList->isEmpty() )
476 return; 476 return;
477 477
478 QString baseDir = ROOT; 478 QString baseDir = ROOT;
479 479
480 if ( createLinks == true ) 480 if ( createLinks == true )
481 { 481 {
482 for ( uint i=0; i < fileList->count(); i++ ) 482 for ( uint i=0; i < fileList->count(); i++ )
483 { 483 {
484 processLinkDir( (*fileList)[i], baseDir, destDir ); 484 processLinkDir( (*fileList)[i], baseDir, destDir );
485 qApp->processEvents(); 485 qApp->processEvents();
486 } 486 }
487 } 487 }
488 else 488 else
489 { 489 {
490 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 490 for ( int i = fileList->count()-1; i >= 0 ; i-- )
491 { 491 {
492 processLinkDir( (*fileList)[i], baseDir, destDir ); 492 processLinkDir( (*fileList)[i], baseDir, destDir );
493 qApp->processEvents(); 493 qApp->processEvents();
494 } 494 }
495 } 495 }
496} 496}
497 497
498void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 498void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
499{ 499{
500 500
501 QString sourceFile = baseDir + file; 501 QString sourceFile = baseDir + file;
502 502
503 QString linkFile = destDir; 503 QString linkFile = destDir;
504 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 504 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
505 { 505 {
506 linkFile += file.mid( 1 ); 506 linkFile += file.mid( 1 );
507 } 507 }
508 else 508 else
509 { 509 {
510 linkFile += file; 510 linkFile += file;
511 } 511 }
512 QString text; 512 QString text;
513 if ( createLinks ) 513 if ( createLinks )
514 { 514 {
515 // If this file is a directory (ends with a /) and it doesn't exist, 515 // If this file is a directory (ends with a /) and it doesn't exist,
516 // we need to create it 516 // we need to create it
517 if ( file.right(1) == "/" ) 517 if ( file.right(1) == "/" )
518 { 518 {
519 QFileInfo f( linkFile ); 519 QFileInfo f( linkFile );
520 if ( !f.exists() ) 520 if ( !f.exists() )
521 { 521 {
522 emit outputText( QString( "Creating directory " ) + linkFile ); 522 emit outputText( QString( "Creating directory " ) + linkFile );
523 QDir d; 523 QDir d;
524 d.mkdir( linkFile, true ); 524 d.mkdir( linkFile, true );
525 } 525 }
526// else 526// else
527// emit outputText( QString( "Directory " ) + linkFile + " already exists" ); 527// emit outputText( QString( "Directory " ) + linkFile + " already exists" );
528 528
529 } 529 }
530 else 530 else
531 { 531 {
532 int rc = symlink( sourceFile, linkFile ); 532 int rc = symlink( sourceFile, linkFile );
533 text = (rc == 0 ? "Linked " : "Failed to link "); 533 text = (rc == 0 ? "Linked " : "Failed to link ");
534 text += sourceFile + " to " + linkFile; 534 text += sourceFile + " to " + linkFile;
535 emit outputText( text ); 535 emit outputText( text );
536 } 536 }
537 } 537 }
538 else 538 else
539 { 539 {
540 QFileInfo f( linkFile ); 540 QFileInfo f( linkFile );
541 if ( f.exists() ) 541 if ( f.exists() )
542 { 542 {
543 if ( f.isFile() ) 543 if ( f.isFile() )
544 { 544 {
545 QFile f( linkFile ); 545 QFile f( linkFile );
546 bool rc = f.remove(); 546 bool rc = f.remove();
547 547
548 text = (rc ? "Removed " : "Failed to remove "); 548 text = (rc ? "Removed " : "Failed to remove ");
549 text += linkFile; 549 text += linkFile;
550 emit outputText( text ); 550 emit outputText( text );
551 } 551 }
552 else if ( f.isDir() ) 552 else if ( f.isDir() )
553 { 553 {
554 QDir d; 554 QDir d;
555 bool rc = d.rmdir( linkFile, true ); 555 bool rc = d.rmdir( linkFile, true );
556 if ( rc ) 556 if ( rc )
557 { 557 {
558 text = (rc ? "Removed " : "Failed to remove "); 558 text = (rc ? "Removed " : "Failed to remove ");
559 text += linkFile; 559 text += linkFile;
560 emit outputText( text ); 560 emit outputText( text );
561 } 561 }
562 } 562 }
563 } 563 }
564 } 564 }
565 565
566} 566}
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
@@ -1,89 +1,90 @@
1/*************************************************************************** 1/***************************************************************************
2 ipkg.h - description 2 ipkg.h - description
3 ------------------- 3 -------------------
4 begin : Sat Aug 31 2002 4 begin : Sat Aug 31 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#ifndef IPKG_H 18#ifndef IPKG_H
19#define IPKG_H 19#define IPKG_H
20 20
21 21
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 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