summaryrefslogtreecommitdiff
authordrw <drw>2003-04-26 22:42:19 (UTC)
committer drw <drw>2003-04-26 22:42:19 (UTC)
commit98a9291263e167b8882ac916330e7215ebd884b4 (patch) (unidiff)
tree882a909e9381ab4cc97e77377fd61361d7f21eab
parent64c48b637c1bd1bef679bff500f3e0ce5365358d (diff)
downloadopie-98a9291263e167b8882ac916330e7215ebd884b4.zip
opie-98a9291263e167b8882ac916330e7215ebd884b4.tar.gz
opie-98a9291263e167b8882ac916330e7215ebd884b4.tar.bz2
1. Fix for bug #872 - reduce CPU useage while ipkg is doing its thing 2. Re-enable setDocument function for identifying local ipks
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp130
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h8
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp17
-rw-r--r--noncore/settings/aqpkg/ipkg.h4
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp8
-rw-r--r--noncore/settings/aqpkg/mainwin.h2
6 files changed, 116 insertions, 53 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 76d0a80..896e370 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,402 +1,466 @@
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 19
20#include <opie/ofiledialog.h> 20#include <opie/ofiledialog.h>
21 21
22#ifdef QWS 22#ifdef QWS
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/fileselector.h> 24#include <qpe/fileselector.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/storage.h> 27#include <qpe/storage.h>
28#endif 28#endif
29 29
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qmultilineedit.h> 35#include <qmultilineedit.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39 39
40#include "datamgr.h" 40#include "datamgr.h"
41#include "destination.h" 41#include "destination.h"
42#include "instoptionsimpl.h" 42#include "instoptionsimpl.h"
43#include "installdlgimpl.h" 43#include "installdlgimpl.h"
44#include "ipkg.h" 44#include "ipkg.h"
45#include "utils.h" 45#include "utils.h"
46#include "global.h" 46#include "global.h"
47 47
48enum { 48enum {
49 MAXLINES = 100, 49 MAXLINES = 100,
50}; 50};
51 51
52InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 52InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title )
53 : QWidget( 0, 0, 0 ) 53 : QWidget( 0, 0, 0 )
54{ 54{
55 setCaption( title ); 55 setCaption( title );
56 init( TRUE ); 56 init( TRUE );
57 57
58 pIpkg = 0; 58 pIpkg = 0;
59 upgradePackages = false; 59 upgradePackages = false;
60 dataMgr = dataManager; 60 dataMgr = dataManager;
61 61
62 QString defaultDest = "root"; 62 QString defaultDest = "root";
63#ifdef QWS 63#ifdef QWS
64 Config cfg( "aqpkg" ); 64 Config cfg( "aqpkg" );
65 cfg.setGroup( "settings" ); 65 cfg.setGroup( "settings" );
66 defaultDest = cfg.readEntry( "dest", "root" ); 66 defaultDest = cfg.readEntry( "dest", "root" );
67 67
68 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 68 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
69 flags = cfg.readNumEntry( "installFlags", 0 ); 69 flags = cfg.readNumEntry( "installFlags", 0 );
70 infoLevel = cfg.readNumEntry( "infoLevel", 1 ); 70 infoLevel = cfg.readNumEntry( "infoLevel", 1 );
71#else 71#else
72 flags = 0; 72 flags = 0;
73#endif 73#endif
74 74
75 // Output text is read only 75 // Output text is read only
76 output->setReadOnly( true ); 76 output->setReadOnly( true );
77 //QFont f( "helvetica" ); 77 //QFont f( "helvetica" );
78 //f.setPointSize( 10 ); 78 //f.setPointSize( 10 );
79 //output->setFont( f ); 79 //output->setFont( f );
80 80
81 81
82 // setup destination data 82 // setup destination data
83 int defIndex = 0; 83 int defIndex = 0;
84 int i; 84 int i;
85 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 85 QListIterator<Destination> dit( dataMgr->getDestinationList() );
86 for ( i = 0; dit.current(); ++dit, ++i ) 86 for ( i = 0; dit.current(); ++dit, ++i )
87 { 87 {
88 destination->insertItem( dit.current()->getDestinationName() ); 88 destination->insertItem( dit.current()->getDestinationName() );
89 if ( dit.current()->getDestinationName() == defaultDest ) 89 if ( dit.current()->getDestinationName() == defaultDest )
90 defIndex = i; 90 defIndex = i;
91 } 91 }
92 92
93 destination->setCurrentItem( defIndex ); 93 destination->setCurrentItem( defIndex );
94 94
95 QListIterator<InstallData> it( packageList ); 95 QListIterator<InstallData> it( packageList );
96 // setup package data 96 // setup package data
97 QString remove = tr( "Remove\n" ); 97 QString remove = tr( "Remove\n" );
98 QString install = tr( "Install\n" ); 98 QString install = tr( "Install\n" );
99 QString upgrade = tr( "Upgrade\n" ); 99 QString upgrade = tr( "Upgrade\n" );
100 for ( ; it.current(); ++it ) 100 for ( ; it.current(); ++it )
101 { 101 {
102 InstallData *item = it.current(); 102 InstallData *item = it.current();
103 InstallData *newitem = new InstallData(); 103 InstallData *newitem = new InstallData();
104 104
105 newitem->option = item->option; 105 newitem->option = item->option;
106 newitem->packageName = item->packageName; 106 newitem->packageName = item->packageName;
107 newitem->destination = item->destination; 107 newitem->destination = item->destination;
108 newitem->recreateLinks = item->recreateLinks; 108 newitem->recreateLinks = item->recreateLinks;
109 109 packages.append( newitem );
110 if ( item->option == "I" ) 110
111 if ( item->option == "I" )
111 { 112 {
112 installList.append( newitem );
113 install.append( QString( " %1\n" ).arg( item->packageName ) ); 113 install.append( QString( " %1\n" ).arg( item->packageName ) );
114 } 114 }
115 else if ( item->option == "D" ) 115 else if ( item->option == "D" )
116 { 116 {
117 removeList.append( newitem );
118 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 117 remove.append( QString( " %1\n" ).arg( item->packageName ) );
119 } 118 }
120 else if ( item->option == "U" || item->option == "R" ) 119 else if ( item->option == "U" || item->option == "R" )
121 { 120 {
122 updateList.append( newitem ); 121 QString type;
123 QString type; 122 if ( item->option == "R" )
124 if ( item->option == "R" ) 123 type = tr( "(ReInstall)" );
125 type = tr( "(ReInstall)" ); 124 else
126 else 125 type = tr( "(Upgrade)" );
127 type = tr( "(Upgrade)" ); 126 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
128 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 127 }
129 } 128 }
130 }
131 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
132 129
133 displayAvailableSpace( destination->currentText() ); 130 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
131
132 displayAvailableSpace( destination->currentText() );
134} 133}
135 134
136InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 135InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
137 : QWidget( 0, 0, 0 ) 136 : QWidget( 0, 0, 0 )
138{ 137{
139 setCaption( title ); 138 setCaption( title );
140 init( FALSE ); 139 init( FALSE );
141 pIpkg = ipkg; 140 pIpkg = ipkg;
142 output->setText( initialText ); 141 output->setText( initialText );
143} 142}
144 143
145 144
146InstallDlgImpl::~InstallDlgImpl() 145InstallDlgImpl::~InstallDlgImpl()
147{ 146{
148 if ( pIpkg ) 147 if ( pIpkg )
149 delete pIpkg; 148 delete pIpkg;
150} 149}
151 150
152void InstallDlgImpl :: init( bool displayextrainfo ) 151void InstallDlgImpl :: init( bool displayextrainfo )
153{ 152{
154 QGridLayout *layout = new QGridLayout( this ); 153 QGridLayout *layout = new QGridLayout( this );
155 layout->setSpacing( 4 ); 154 layout->setSpacing( 4 );
156 layout->setMargin( 4 ); 155 layout->setMargin( 4 );
157 156
158 if ( displayextrainfo ) 157 if ( displayextrainfo )
159 { 158 {
160 QLabel *label = new QLabel( tr( "Destination" ), this ); 159 QLabel *label = new QLabel( tr( "Destination" ), this );
161 layout->addWidget( label, 0, 0 ); 160 layout->addWidget( label, 0, 0 );
162 destination = new QComboBox( FALSE, this ); 161 destination = new QComboBox( FALSE, this );
163 layout->addWidget( destination, 0, 1 ); 162 layout->addWidget( destination, 0, 1 );
164 connect( destination, SIGNAL( highlighted( const QString & ) ), 163 connect( destination, SIGNAL( highlighted( const QString & ) ),
165 this, SLOT( displayAvailableSpace( const QString & ) ) ); 164 this, SLOT( displayAvailableSpace( const QString & ) ) );
166 165
167 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 166 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
168 layout->addWidget( label2, 1, 0 ); 167 layout->addWidget( label2, 1, 0 );
169 txtAvailableSpace = new QLabel( "", this ); 168 txtAvailableSpace = new QLabel( "", this );
170 layout->addWidget( txtAvailableSpace, 1, 1 ); 169 layout->addWidget( txtAvailableSpace, 1, 1 );
171 } 170 }
172 else 171 else
173 { 172 {
174 destination = 0x0; 173 destination = 0x0;
175 txtAvailableSpace = 0x0; 174 txtAvailableSpace = 0x0;
176 } 175 }
177 176
178 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 177 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
179 GroupBox2->layout()->setSpacing( 0 ); 178 GroupBox2->layout()->setSpacing( 0 );
180 GroupBox2->layout()->setMargin( 4 ); 179 GroupBox2->layout()->setMargin( 4 );
181 180
182 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 181 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
183 output = new QMultiLineEdit( GroupBox2 ); 182 output = new QMultiLineEdit( GroupBox2 );
184 GroupBox2Layout->addWidget( output ); 183 GroupBox2Layout->addWidget( output );
185 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 184 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
186 185
187 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 186 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
188 layout->addWidget( btnInstall, 3, 0 ); 187 layout->addWidget( btnInstall, 3, 0 );
189 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 188 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
190 189
191 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 190 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
192 layout->addWidget( btnOptions, 3, 1 ); 191 layout->addWidget( btnOptions, 3, 1 );
193 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 192 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
194} 193}
195 194
196void InstallDlgImpl :: optionsSelected() 195void InstallDlgImpl :: optionsSelected()
197{ 196{
198 if ( btnOptions->text() == tr( "Options" ) ) 197 if ( btnOptions->text() == tr( "Options" ) )
199 { 198 {
200 InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); 199 InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true );
201 if ( opt.exec() == QDialog::Accepted ) 200 if ( opt.exec() == QDialog::Accepted )
202 { 201 {
203 // set options selected from dialog 202 // set options selected from dialog
204 flags = opt.getFlags(); 203 flags = opt.getFlags();
205 infoLevel = opt.getInfoLevel(); 204 infoLevel = opt.getInfoLevel();
206 205
207#ifdef QWS 206#ifdef QWS
208 Config cfg( "aqpkg" ); 207 Config cfg( "aqpkg" );
209 cfg.setGroup( "settings" ); 208 cfg.setGroup( "settings" );
210 cfg.writeEntry( "installFlags", flags ); 209 cfg.writeEntry( "installFlags", flags );
211 cfg.writeEntry( "infoLevel", infoLevel ); 210 cfg.writeEntry( "infoLevel", infoLevel );
212#endif 211#endif
213 } 212 }
214 } 213 }
215 else // Save output 214 else // Save output
216 { 215 {
217 QMap<QString, QStringList> map; 216 QMap<QString, QStringList> map;
218 map.insert( tr( "All" ), QStringList() ); 217 map.insert( tr( "All" ), QStringList() );
219 QStringList text; 218 QStringList text;
220 text << "text/*"; 219 text << "text/*";
221 map.insert(tr( "Text" ), text ); 220 map.insert(tr( "Text" ), text );
222 text << "*"; 221 text << "*";
223 map.insert( tr( "All" ), text ); 222 map.insert( tr( "All" ), text );
224 223
225 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 224 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
226 if( !filename.isEmpty() ) 225 if( !filename.isEmpty() )
227 { 226 {
228 QString currentFileName = QFileInfo( filename ).fileName(); 227 QString currentFileName = QFileInfo( filename ).fileName();
229 DocLnk doc; 228 DocLnk doc;
230 doc.setType( "text/plain" ); 229 doc.setType( "text/plain" );
231 doc.setFile( filename ); 230 doc.setFile( filename );
232 doc.setName( currentFileName ); 231 doc.setName( currentFileName );
233 FileManager fm; 232 FileManager fm;
234 fm.saveFile( doc, output->text() ); 233 fm.saveFile( doc, output->text() );
235 } 234 }
236 } 235 }
237} 236}
238 237
239void InstallDlgImpl :: installSelected() 238void InstallDlgImpl :: installSelected()
240{ 239{
241 if ( btnInstall->text() == tr( "Abort" ) ) 240 if ( btnInstall->text() == tr( "Abort" ) )
242 { 241 {
243 if ( pIpkg ) 242 if ( pIpkg )
244 { 243 {
245 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 244 displayText( tr( "\n**** User Clicked ABORT ***" ) );
246 pIpkg->abort(); 245 pIpkg->abort();
247 displayText( tr( "**** Process Aborted ****" ) ); 246 displayText( tr( "**** Process Aborted ****" ) );
248 } 247 }
249 248
250 btnInstall->setText( tr( "Close" ) ); 249 btnInstall->setText( tr( "Close" ) );
251 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 250 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
252 return; 251 return;
253 } 252 }
254 else if ( btnInstall->text() == tr( "Close" ) ) 253 else if ( btnInstall->text() == tr( "Close" ) )
255 { 254 {
256 emit reloadData( this ); 255 emit reloadData( this );
257 return; 256 return;
258 } 257 }
259 258
260 // Disable buttons 259 // Disable buttons
261 btnOptions->setEnabled( false ); 260 btnOptions->setEnabled( false );
262// btnInstall->setEnabled( false ); 261// btnInstall->setEnabled( false );
263 262
264 btnInstall->setText( tr( "Abort" ) ); 263 btnInstall->setText( tr( "Abort" ) );
265 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 264 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
266 265
267 if ( pIpkg ) 266 if ( pIpkg )
268 { 267 {
269 output->setText( "" ); 268 output->setText( "" );
270 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 269 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
270 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
271 pIpkg->runIpkg(); 271 pIpkg->runIpkg();
272 } 272 }
273 else 273 else
274 { 274 {
275 output->setText( "" ); 275 output->setText( "" );
276 Destination *d = dataMgr->getDestination( destination->currentText() ); 276 Destination *d = dataMgr->getDestination( destination->currentText() );
277 QString dest = d->getDestinationName(); 277 QString dest = d->getDestinationName();
278 QString destDir = d->getDestinationPath(); 278 QString destDir = d->getDestinationPath();
279 int instFlags = flags; 279 int instFlags = flags;
280 if ( d->linkToRoot() ) 280 if ( d->linkToRoot() )
281 instFlags |= MAKE_LINKS; 281 instFlags |= MAKE_LINKS;
282 282
283#ifdef QWS 283#ifdef QWS
284 // Save settings 284 // Save settings
285 Config cfg( "aqpkg" ); 285 Config cfg( "aqpkg" );
286 cfg.setGroup( "settings" ); 286 cfg.setGroup( "settings" );
287 cfg.writeEntry( "dest", dest ); 287 cfg.writeEntry( "dest", dest );
288#endif 288#endif
289 289
290 pIpkg = new Ipkg; 290 pIpkg = new Ipkg;
291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
292 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
293
294 firstPackage = TRUE;
295 ipkgFinished();
292 296
293 // First run through the remove list, then the install list then the upgrade list 297 // First run through the remove list, then the install list then the upgrade list
294 pIpkg->setOption( "remove" ); 298/*
299 pIpkg->setOption( "remove" );
295 QListIterator<InstallData> it( removeList ); 300 QListIterator<InstallData> it( removeList );
296 InstallData *idata; 301 InstallData *idata;
297 for ( ; it.current(); ++it ) 302 for ( ; it.current(); ++it )
298 { 303 {
299 idata = it.current(); 304 idata = it.current();
300 pIpkg->setDestination( idata->destination->getDestinationName() ); 305 pIpkg->setDestination( idata->destination->getDestinationName() );
301 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 306 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
302 pIpkg->setPackage( idata->packageName ); 307 pIpkg->setPackage( idata->packageName );
303 308
304 int tmpFlags = flags; 309 int tmpFlags = flags;
305 if ( idata->destination->linkToRoot() ) 310 if ( idata->destination->linkToRoot() )
306 tmpFlags |= MAKE_LINKS; 311 tmpFlags |= MAKE_LINKS;
307 312
308 pIpkg->setFlags( tmpFlags, infoLevel ); 313 pIpkg->setFlags( tmpFlags, infoLevel );
309 pIpkg->runIpkg(); 314 pIpkg->runIpkg();
310 } 315 }
311 316
312 pIpkg->setOption( "install" ); 317 pIpkg->setOption( "install" );
313 pIpkg->setDestination( dest ); 318 pIpkg->setDestination( dest );
314 pIpkg->setDestinationDir( destDir ); 319 pIpkg->setDestinationDir( destDir );
315 pIpkg->setFlags( instFlags, infoLevel ); 320 pIpkg->setFlags( instFlags, infoLevel );
316 QListIterator<InstallData> it2( installList ); 321 QListIterator<InstallData> it2( installList );
317 for ( ; it2.current(); ++it2 ) 322 for ( ; it2.current(); ++it2 )
318 { 323 {
319 pIpkg->setPackage( it2.current()->packageName ); 324 pIpkg->setPackage( it2.current()->packageName );
320 pIpkg->runIpkg(); 325 pIpkg->runIpkg();
321 } 326 }
322 327
323 flags |= FORCE_REINSTALL; 328 flags |= FORCE_REINSTALL;
324 QListIterator<InstallData> it3( updateList ); 329 QListIterator<InstallData> it3( updateList );
325 for ( ; it3.current() ; ++it3 ) 330 for ( ; it3.current() ; ++it3 )
326 { 331 {
327 idata = it3.current(); 332 idata = it3.current();
328 if ( idata->option == "R" ) 333 if ( idata->option == "R" )
329 pIpkg->setOption( "reinstall" ); 334 pIpkg->setOption( "reinstall" );
330 else 335 else
331 pIpkg->setOption( "upgrade" ); 336 pIpkg->setOption( "upgrade" );
332 pIpkg->setDestination( idata->destination->getDestinationName() ); 337 pIpkg->setDestination( idata->destination->getDestinationName() );
333 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 338 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
334 pIpkg->setPackage( idata->packageName ); 339 pIpkg->setPackage( idata->packageName );
335 340
336 int tmpFlags = flags; 341 int tmpFlags = flags;
337 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 342 if ( idata->destination->linkToRoot() && idata->recreateLinks )
338 tmpFlags |= MAKE_LINKS; 343 tmpFlags |= MAKE_LINKS;
339 pIpkg->setFlags( tmpFlags, infoLevel ); 344 pIpkg->setFlags( tmpFlags, infoLevel );
340 pIpkg->runIpkg(); 345 pIpkg->runIpkg();
341 } 346 }
342 347
343 delete pIpkg; 348 delete pIpkg;
344 pIpkg = 0; 349 pIpkg = 0;
350*/
345 } 351 }
346
347 btnOptions->setEnabled( true );
348// btnInstall->setEnabled( true );
349 btnInstall->setText( tr( "Close" ) );
350 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
351
352 btnOptions->setText( tr( "Save output" ) );
353 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
354
355 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
356 displayAvailableSpace( destination->currentText() );
357} 352}
358 353
359 354
360void InstallDlgImpl :: displayText(const QString &text ) 355void InstallDlgImpl :: displayText(const QString &text )
361{ 356{
362 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 357 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
363 358
364 /* Set a max line count for the QMultiLineEdit, as users have reported 359 /* Set a max line count for the QMultiLineEdit, as users have reported
365 * performance issues when line count gets extreme. 360 * performance issues when line count gets extreme.
366 */ 361 */
367 if(output->numLines() >= MAXLINES) 362 if(output->numLines() >= MAXLINES)
368 output->removeLine(0); 363 output->removeLine(0);
369 output->setText( newtext ); 364 output->setText( newtext );
370 output->setCursorPosition( output->numLines(), 0 ); 365 output->setCursorPosition( output->numLines(), 0 );
371} 366}
372 367
373 368
374void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 369void InstallDlgImpl :: displayAvailableSpace( const QString &text )
375{ 370{
376 Destination *d = dataMgr->getDestination( text ); 371 Destination *d = dataMgr->getDestination( text );
377 QString destDir = d->getDestinationPath(); 372 QString destDir = d->getDestinationPath();
378 373
379 long blockSize = 0; 374 long blockSize = 0;
380 long totalBlocks = 0; 375 long totalBlocks = 0;
381 long availBlocks = 0; 376 long availBlocks = 0;
382 QString space; 377 QString space;
383 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 378 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
384 { 379 {
385 long mult = blockSize / 1024; 380 long mult = blockSize / 1024;
386 long div = 1024 / blockSize; 381 long div = 1024 / blockSize;
387 382
388 if ( !mult ) mult = 1; 383 if ( !mult ) mult = 1;
389 if ( !div ) div = 1; 384 if ( !div ) div = 1;
390// long total = totalBlocks * mult / div; 385// long total = totalBlocks * mult / div;
391 long avail = availBlocks * mult / div; 386 long avail = availBlocks * mult / div;
392// long used = total - avail; 387// long used = total - avail;
393 388
394 space.sprintf( "%ld Kb", avail ); 389 space.sprintf( "%ld Kb", avail );
395 } 390 }
396 else 391 else
397 space = tr( "Unknown" ); 392 space = tr( "Unknown" );
398 393
399 if ( txtAvailableSpace ) 394 if ( txtAvailableSpace )
400 txtAvailableSpace->setText( space ); 395 txtAvailableSpace->setText( space );
401} 396}
402 397
398void InstallDlgImpl :: ipkgFinished()
399{
400 InstallData *item;
401 if ( firstPackage )
402 item = packages.first();
403 else
404 {
405 // Create symlinks if necessary before moving on to next package
406 pIpkg->createSymLinks();
407
408 item = packages.next();
409 }
410
411 firstPackage = FALSE;
412 if ( item )
413 {
414 pIpkg->setPackage( item->packageName );
415 int tmpFlags = flags;
416
417 if ( item->option == "I" )
418 {
419 pIpkg->setOption( "install" );
420 Destination *d = dataMgr->getDestination( destination->currentText() );
421 pIpkg->setDestination( d->getDestinationName() );
422 pIpkg->setDestinationDir( d->getDestinationPath() );
423
424 if ( d->linkToRoot() )
425 tmpFlags |= MAKE_LINKS;
426 }
427 else if ( item->option == "D" )
428 {
429 pIpkg->setOption( "remove" );
430 pIpkg->setDestination( item->destination->getDestinationName() );
431 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
432
433 if ( item->destination->linkToRoot() )
434 tmpFlags |= MAKE_LINKS;
435 }
436 else
437 {
438 if ( item->option == "R" )
439 pIpkg->setOption( "reinstall" );
440 else
441 pIpkg->setOption( "upgrade" );
442
443 pIpkg->setDestination( item->destination->getDestinationName() );
444 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
445 pIpkg->setPackage( item->packageName );
446
447 tmpFlags |= FORCE_REINSTALL;
448 if ( item->destination->linkToRoot() && item->recreateLinks )
449 tmpFlags |= MAKE_LINKS;
450 }
451 pIpkg->setFlags( tmpFlags, infoLevel );
452 pIpkg->runIpkg();
453 }
454 else
455 {
456 btnOptions->setEnabled( true );
457 btnInstall->setText( tr( "Close" ) );
458 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
459
460 btnOptions->setText( tr( "Save output" ) );
461 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
462
463 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
464 displayAvailableSpace( destination->currentText() );
465 }
466} \ No newline at end of file
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 15cf427..9a7dbff 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -1,86 +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( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); 49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
50 ~InstallDlgImpl(); 50 ~InstallDlgImpl();
51 51
52 bool upgradeServer( QString &server ); 52 bool upgradeServer( QString &server );
53 53
54protected: 54protected:
55 55
56private: 56private:
57 DataManager *dataMgr; 57 DataManager *dataMgr;
58 QList<InstallData> installList; 58 QList<InstallData> packages;
59 QList<InstallData> removeList; 59 bool firstPackage;
60 QList<InstallData> updateList;
61 int flags; 60 int flags;
62 int infoLevel; 61 int infoLevel;
63 Ipkg *pIpkg; 62 Ipkg *pIpkg;
64 bool upgradePackages; 63 bool upgradePackages;
65 64
66 QComboBox *destination; 65 QComboBox *destination;
67 QPushButton *btnInstall; 66 QPushButton *btnInstall;
68 QPushButton *btnOptions; 67 QPushButton *btnOptions;
69 QMultiLineEdit *output; 68 QMultiLineEdit *output;
70 QLabel *txtAvailableSpace; 69 QLabel *txtAvailableSpace;
71 70
72 void init( bool ); 71 void init( bool );
73 72
74 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
75 74
76signals: 75signals:
77 void reloadData( InstallDlgImpl * ); 76 void reloadData( InstallDlgImpl * );
78 77
79public slots: 78public slots:
80 void optionsSelected(); 79 void optionsSelected();
81 void installSelected(); 80 void installSelected();
82 void displayText(const QString &text ); 81 void displayText(const QString &text );
83 void displayAvailableSpace( const QString &text); 82 void displayAvailableSpace( const QString &text);
83 void ipkgFinished();
84}; 84};
85 85
86#endif 86#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index e906653..34999ad 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -1,578 +1,575 @@
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( ) 58void Ipkg :: runIpkg()
59{ 59{
60 error = false; 60 error = false;
61 bool ret = false;
62 QStringList commands; 61 QStringList commands;
63 62
64 QDir::setCurrent( "/tmp" ); 63 QDir::setCurrent( "/tmp" );
65 64
66 if ( runtimeDir != "" ) 65 if ( runtimeDir != "" )
67 { 66 {
68 commands << "cd "; 67 commands << "cd ";
69 commands << runtimeDir; 68 commands << runtimeDir;
70 commands << ";"; 69 commands << ";";
71 } 70 }
72 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; 71 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults";
73 72
74 // only set the destination for an install operation 73 // only set the destination for an install operation
75 if ( option == "install" ) 74 if ( option == "install" )
76 commands << "-dest" << destination; 75 commands << "-dest" << destination;
77 76
78 77
79 if ( option != "update" && option != "download" ) 78 if ( option != "update" && option != "download" )
80 { 79 {
81 if ( flags & FORCE_DEPENDS ) 80 if ( flags & FORCE_DEPENDS )
82 commands << "-force-depends"; 81 commands << "-force-depends";
83 if ( flags & FORCE_REINSTALL ) 82 if ( flags & FORCE_REINSTALL )
84 commands << "-force-reinstall"; 83 commands << "-force-reinstall";
85 if ( flags & FORCE_REMOVE ) 84 if ( flags & FORCE_REMOVE )
86 commands << "-force-removal-of-essential-packages"; 85 commands << "-force-removal-of-essential-packages";
87 if ( flags & FORCE_OVERWRITE ) 86 if ( flags & FORCE_OVERWRITE )
88 commands << "-force-overwrite"; 87 commands << "-force-overwrite";
89 if ( infoLevel == 3 ) 88 if ( infoLevel == 3 )
90 commands << "-verbose_wget"; 89 commands << "-verbose_wget";
91 90
92 // Handle make links 91 // Handle make links
93 // Rules - If make links is switched on, create links to root 92 // Rules - If make links is switched on, create links to root
94 // if destDir is NOT / 93 // if destDir is NOT /
95 if ( flags & MAKE_LINKS ) 94 if ( flags & MAKE_LINKS )
96 { 95 {
97 // If destDir == / turn off make links as package is being insalled 96 // If destDir == / turn off make links as package is being insalled
98 // to root already. 97 // to root already.
99 if ( destDir == "/" ) 98 if ( destDir == "/" )
100 flags ^= MAKE_LINKS; 99 flags ^= MAKE_LINKS;
101 } 100 }
102 } 101 }
103 102
104#ifdef X86 103#ifdef X86
105 commands << "-f"; 104 commands << "-f";
106 commands << IPKG_CONF; 105 commands << IPKG_CONF;
107#endif 106#endif
108 107
109 108
110 if ( option == "reinstall" ) 109 if ( option == "reinstall" )
111 commands << "install"; 110 commands << "install";
112 else 111 else
113 commands << option; 112 commands << option;
114 if ( package != "" ) 113 if ( package != "" )
115 commands << package; 114 commands << package;
116 115
117 116
118 if ( package != "" ) 117 if ( package != "" )
119 emit outputText( QString( "Dealing with package " ) + package ); 118 emit outputText( QString( "Dealing with package " ) + package );
120 119
121 qApp->processEvents(); 120 qApp->processEvents();
122 121
123 // If we are removing, reinstalling or upgrading packages and make links option is selected 122 // If we are removing, reinstalling or upgrading packages and make links option is selected
124 // create the links 123 // create the links
125 if ( option == "remove" || option == "reinstall" || option == "upgrade" ) 124 if ( option == "remove" || option == "reinstall" || option == "upgrade" )
126 { 125 {
127 createLinks = false; 126 createLinks = false;
128 if ( flags & MAKE_LINKS ) 127 if ( flags & MAKE_LINKS )
129 { 128 {
130 emit outputText( QString( "Removing symbolic links...\n" ) ); 129 emit outputText( QString( "Removing symbolic links...\n" ) );
131 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 130 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
132 emit outputText( QString( " " ) ); 131 emit outputText( QString( " " ) );
133 } 132 }
134 } 133 }
135 134
136 // Execute command 135 // Execute command
137 dependantPackages = new QList<QString>; 136 dependantPackages = new QList<QString>;
138 dependantPackages->setAutoDelete( true ); 137 dependantPackages->setAutoDelete( true );
139 138
140 ret = executeIpkgCommand( commands, option ); 139 executeIpkgCommand( commands, option );
141 140
142 if ( aborted ) 141}
143 return false;
144 142
143void Ipkg :: createSymLinks()
144{
145 if ( option == "install" || option == "reinstall" || option == "upgrade" ) 145 if ( option == "install" || option == "reinstall" || option == "upgrade" )
146 { 146 {
147 // If we are not removing packages and make links option is selected 147 // If we are not removing packages and make links option is selected
148 // create the links 148 // create the links
149 createLinks = true; 149 createLinks = true;
150 if ( flags & MAKE_LINKS ) 150 if ( flags & MAKE_LINKS )
151 { 151 {
152 emit outputText( " " ); 152 emit outputText( " " );
153 emit outputText( QString( "Creating symbolic links for " )+ package ); 153 emit outputText( QString( "Creating symbolic links for " )+ package );
154 154
155 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 155 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
156 156
157 // link dependant packages that were installed with this release 157 // link dependant packages that were installed with this release
158 QString *pkg; 158 QString *pkg;
159 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) 159 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
160 { 160 {
161 if ( *pkg == package ) 161 if ( *pkg == package )
162 continue; 162 continue;
163 emit outputText( " " ); 163 emit outputText( " " );
164 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); 164 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
165 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); 165 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 delete dependantPackages; 170 delete dependantPackages;
171 171
172 emit outputText( "Finished" ); 172 emit outputText( "Finished" );
173 emit outputText( "" ); 173 emit outputText( "" );
174 return ret;
175} 174}
176 175
177void Ipkg :: removeStatusEntry() 176void Ipkg :: removeStatusEntry()
178{ 177{
179 QString statusFile = destDir; 178 QString statusFile = destDir;
180 if ( statusFile.right( 1 ) != "/" ) 179 if ( statusFile.right( 1 ) != "/" )
181 statusFile.append( "/" ); 180 statusFile.append( "/" );
182 statusFile.append( "usr/lib/ipkg/status" ); 181 statusFile.append( "usr/lib/ipkg/status" );
183 QString outStatusFile = statusFile; 182 QString outStatusFile = statusFile;
184 outStatusFile.append( ".tmp" ); 183 outStatusFile.append( ".tmp" );
185 184
186 emit outputText( "" ); 185 emit outputText( "" );
187 emit outputText( "Removing status entry..." ); 186 emit outputText( "Removing status entry..." );
188 QString tempstr = "status file - "; 187 QString tempstr = "status file - ";
189 tempstr.append( statusFile ); 188 tempstr.append( statusFile );
190 emit outputText( tempstr ); 189 emit outputText( tempstr );
191 tempstr = "package - "; 190 tempstr = "package - ";
192 tempstr.append( package ); 191 tempstr.append( package );
193 emit outputText( tempstr ); 192 emit outputText( tempstr );
194 193
195 ifstream in( statusFile ); 194 ifstream in( statusFile );
196 ofstream out( outStatusFile ); 195 ofstream out( outStatusFile );
197 if ( !in.is_open() ) 196 if ( !in.is_open() )
198 { 197 {
199 tempstr = "Couldn't open status file - "; 198 tempstr = "Couldn't open status file - ";
200 tempstr.append( statusFile ); 199 tempstr.append( statusFile );
201 emit outputText( tempstr ); 200 emit outputText( tempstr );
202 return; 201 return;
203 } 202 }
204 203
205 if ( !out.is_open() ) 204 if ( !out.is_open() )
206 { 205 {
207 tempstr = "Couldn't create tempory status file - "; 206 tempstr = "Couldn't create tempory status file - ";
208 tempstr.append( outStatusFile ); 207 tempstr.append( outStatusFile );
209 emit outputText( tempstr ); 208 emit outputText( tempstr );
210 return; 209 return;
211 } 210 }
212 211
213 char line[1001]; 212 char line[1001];
214 char k[21]; 213 char k[21];
215 char v[1001]; 214 char v[1001];
216 QString key; 215 QString key;
217 QString value; 216 QString value;
218 vector<QString> lines; 217 vector<QString> lines;
219 do 218 do
220 { 219 {
221 in.getline( line, 1000 ); 220 in.getline( line, 1000 );
222 if ( in.eof() ) 221 if ( in.eof() )
223 continue; 222 continue;
224 223
225 k[0] = '\0'; 224 k[0] = '\0';
226 v[0] = '\0'; 225 v[0] = '\0';
227 226
228 sscanf( line, "%[^:]: %[^\n]", k, v ); 227 sscanf( line, "%[^:]: %[^\n]", k, v );
229 key = k; 228 key = k;
230 value = v; 229 value = v;
231 key = key.stripWhiteSpace(); 230 key = key.stripWhiteSpace();
232 value = value.stripWhiteSpace(); 231 value = value.stripWhiteSpace();
233 if ( key == "Package" && value == package ) 232 if ( key == "Package" && value == package )
234 { 233 {
235 // Ignore all lines up to next empty 234 // Ignore all lines up to next empty
236 do 235 do
237 { 236 {
238 in.getline( line, 1000 ); 237 in.getline( line, 1000 );
239 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 238 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
240 continue; 239 continue;
241 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 240 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
242 } 241 }
243 242
244 lines.push_back( QString( line ) ); 243 lines.push_back( QString( line ) );
245 out << line << endl; 244 out << line << endl;
246 } while ( !in.eof() ); 245 } while ( !in.eof() );
247 246
248 // Write lines out 247 // Write lines out
249 vector<QString>::iterator it; 248 vector<QString>::iterator it;
250 for ( it = lines.begin() ; it != lines.end() ; ++it ) 249 for ( it = lines.begin() ; it != lines.end() ; ++it )
251 { 250 {
252 out << (const char *)(*it) << endl; 251 out << (const char *)(*it) << endl;
253 } 252 }
254 253
255 in.close(); 254 in.close();
256 out.close(); 255 out.close();
257 256
258 // Remove old status file and put tmp stats file in its place 257 // Remove old status file and put tmp stats file in its place
259 remove( statusFile ); 258 remove( statusFile );
260 rename( outStatusFile, statusFile ); 259 rename( outStatusFile, statusFile );
261} 260}
262 261
263int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) 262int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
264{ 263{
265 // If one is already running - should never be but just to be safe 264 // If one is already running - should never be but just to be safe
266 if ( proc ) 265 if ( proc )
267 { 266 {
268 delete proc; 267 delete proc;
269 proc = 0; 268 proc = 0;
270 } 269 }
271 270
272 // OK we're gonna use OProcess to run this thing 271 // OK we're gonna use OProcess to run this thing
273 proc = new OProcess(); 272 proc = new OProcess();
274 aborted = false; 273 aborted = false;
275 274
276 275
277 // Connect up our slots 276 // Connect up our slots
278 connect(proc, SIGNAL(processExited(OProcess *)), 277 connect(proc, SIGNAL(processExited(OProcess *)),
279 this, SLOT( processFinished())); 278 this, SLOT( processFinished()));
280 279
281 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 280 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
282 this, SLOT(commandStdout(OProcess *, char *, int))); 281 this, SLOT(commandStdout(OProcess *, char *, int)));
283 282
284 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 283 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
285 this, SLOT(commandStderr(OProcess *, char *, int))); 284 this, SLOT(commandStderr(OProcess *, char *, int)));
286 285
287 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) 286 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
288 { 287 {
289 *proc << (*it).latin1(); 288 *proc << (*it).latin1();
290 } 289 }
291 290
292 // Start the process going 291 // Start the process going
293 finished = false; 292 finished = false;
294 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) 293 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
295 { 294 {
296 emit outputText( QString( "Couldn't start ipkg process" ) ); 295 emit outputText( QString( "Couldn't start ipkg process" ) );
297 } 296 }
298
299 // Now wait for it to finish
300 while ( !finished )
301 qApp->processEvents();
302} 297}
303 298
304void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) 299void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
305{ 300{
306 QString lineStr = buffer; 301 QString lineStr = buffer;
307 if ( lineStr[buflen-1] == '\n' ) 302 if ( lineStr[buflen-1] == '\n' )
308 buflen --; 303 buflen --;
309 lineStr = lineStr.left( buflen ); 304 lineStr = lineStr.left( buflen );
310 emit outputText( lineStr ); 305 emit outputText( lineStr );
311 306
312 // check if we are installing dependant packages 307 // check if we are installing dependant packages
313 if ( option == "install" || option == "reinstall" ) 308 if ( option == "install" || option == "reinstall" )
314 { 309 {
315 // Need to keep track of any dependant packages that get installed 310 // Need to keep track of any dependant packages that get installed
316 // so that we can create links to them as necessary 311 // so that we can create links to them as necessary
317 if ( lineStr.startsWith( "Installing " ) ) 312 if ( lineStr.startsWith( "Installing " ) )
318 { 313 {
319 int start = lineStr.find( " " ) + 1; 314 int start = lineStr.find( " " ) + 1;
320 int end = lineStr.find( " ", start ); 315 int end = lineStr.find( " ", start );
321 QString *package = new QString( lineStr.mid( start, end-start ) ); 316 QString *package = new QString( lineStr.mid( start, end-start ) );
322 dependantPackages->append( package ); 317 dependantPackages->append( package );
323 } 318 }
324 } 319 }
325 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && 320 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) &&
326 lineStr.find( "is depended upon by packages:" ) != -1 ) 321 lineStr.find( "is depended upon by packages:" ) != -1 )
327 { 322 {
328 // Ipkg should send this to STDERR, but doesn't - so trap here 323 // Ipkg should send this to STDERR, but doesn't - so trap here
329 error = true; 324 error = true;
330 } 325 }
331 326
332 buffer[0] = '\0'; 327 buffer[0] = '\0';
333} 328}
334 329
335void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) 330void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
336{ 331{
337 QString lineStr = buffer; 332 QString lineStr = buffer;
338 if ( lineStr[buflen-1] == '\n' ) 333 if ( lineStr[buflen-1] == '\n' )
339 buflen --; 334 buflen --;
340 lineStr=lineStr.left( buflen ); 335 lineStr=lineStr.left( buflen );
341 emit outputText( lineStr ); 336 emit outputText( lineStr );
342 buffer[0] = '\0'; 337 buffer[0] = '\0';
343 error = true; 338 error = true;
344} 339}
345 340
346void Ipkg::processFinished() 341void Ipkg::processFinished()
347{ 342{
348 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file 343 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
349 // to workaround an ipkg bug which stops reinstall to a different location 344 // to workaround an ipkg bug which stops reinstall to a different location
350 345
351 if ( !error && option == "remove" ) 346 if ( !error && option == "remove" )
352 removeStatusEntry(); 347 removeStatusEntry();
353 348
354 delete proc; 349 delete proc;
355 proc = 0; 350 proc = 0;
356 finished = true; 351 finished = true;
352
353 emit ipkgFinished();
357} 354}
358 355
359 356
360void Ipkg :: abort() 357void Ipkg :: abort()
361{ 358{
362 if ( proc ) 359 if ( proc )
363 { 360 {
364 proc->kill(); 361 proc->kill();
365 aborted = true; 362 aborted = true;
366 } 363 }
367} 364}
368 365
369/* 366/*
370int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 367int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
371{ 368{
372 FILE *fp = NULL; 369 FILE *fp = NULL;
373 char line[130]; 370 char line[130];
374 QString lineStr, lineStrOld; 371 QString lineStr, lineStrOld;
375 int ret = false; 372 int ret = false;
376 373
377 fp = popen( (const char *) cmd, "r"); 374 fp = popen( (const char *) cmd, "r");
378 if ( fp == NULL ) 375 if ( fp == NULL )
379 { 376 {
380 QString text; 377 QString text;
381 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 378 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
382 emit outputText( text ); 379 emit outputText( text );
383 } 380 }
384 else 381 else
385 { 382 {
386 while ( fgets( line, sizeof line, fp) != NULL ) 383 while ( fgets( line, sizeof line, fp) != NULL )
387 { 384 {
388 lineStr = line; 385 lineStr = line;
389 lineStr=lineStr.left( lineStr.length()-1 ); 386 lineStr=lineStr.left( lineStr.length()-1 );
390 387
391 if ( lineStr != lineStrOld ) 388 if ( lineStr != lineStrOld )
392 { 389 {
393 //See if we're finished 390 //See if we're finished
394 if ( option == "install" || option == "reinstall" ) 391 if ( option == "install" || option == "reinstall" )
395 { 392 {
396 // Need to keep track of any dependant packages that get installed 393 // Need to keep track of any dependant packages that get installed
397 // so that we can create links to them as necessary 394 // so that we can create links to them as necessary
398 if ( lineStr.startsWith( "Installing " ) ) 395 if ( lineStr.startsWith( "Installing " ) )
399 { 396 {
400 int start = lineStr.find( " " ) + 1; 397 int start = lineStr.find( " " ) + 1;
401 int end = lineStr.find( " ", start ); 398 int end = lineStr.find( " ", start );
402 QString *package = new QString( lineStr.mid( start, end-start ) ); 399 QString *package = new QString( lineStr.mid( start, end-start ) );
403 dependantPackages->append( package ); 400 dependantPackages->append( package );
404 } 401 }
405 } 402 }
406 403
407 if ( option == "update" ) 404 if ( option == "update" )
408 { 405 {
409 if (lineStr.contains("Updated list")) 406 if (lineStr.contains("Updated list"))
410 ret = true; 407 ret = true;
411 } 408 }
412 else if ( option == "download" ) 409 else if ( option == "download" )
413 { 410 {
414 if (lineStr.contains("Downloaded")) 411 if (lineStr.contains("Downloaded"))
415 ret = true; 412 ret = true;
416 } 413 }
417 else 414 else
418 { 415 {
419 if (lineStr.contains("Done")) 416 if (lineStr.contains("Done"))
420 ret = true; 417 ret = true;
421 } 418 }
422 419
423 emit outputText( lineStr ); 420 emit outputText( lineStr );
424 } 421 }
425 lineStrOld = lineStr; 422 lineStrOld = lineStr;
426 qApp->processEvents(); 423 qApp->processEvents();
427 } 424 }
428 pclose(fp); 425 pclose(fp);
429 } 426 }
430 427
431 return ret; 428 return ret;
432} 429}
433*/ 430*/
434 431
435void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 432void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
436{ 433{
437 if ( dest == "root" || dest == "/" ) 434 if ( dest == "root" || dest == "/" )
438 return; 435 return;
439 436
440 qApp->processEvents(); 437 qApp->processEvents();
441 QStringList *fileList = getList( packFileName, destDir ); 438 QStringList *fileList = getList( packFileName, destDir );
442 qApp->processEvents(); 439 qApp->processEvents();
443 processFileList( fileList, destDir ); 440 processFileList( fileList, destDir );
444 delete fileList; 441 delete fileList;
445} 442}
446 443
447QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 444QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
448{ 445{
449 QString packageFileDir = destDir; 446 QString packageFileDir = destDir;
450 packageFileDir.append( "/usr/lib/ipkg/info/" ); 447 packageFileDir.append( "/usr/lib/ipkg/info/" );
451 packageFileDir.append( packageFilename ); 448 packageFileDir.append( packageFilename );
452 packageFileDir.append( ".list" ); 449 packageFileDir.append( ".list" );
453 QFile f( packageFileDir ); 450 QFile f( packageFileDir );
454 451
455 if ( !f.open(IO_ReadOnly) ) 452 if ( !f.open(IO_ReadOnly) )
456 { 453 {
457 // Couldn't open from dest, try from / 454 // Couldn't open from dest, try from /
458 f.close(); 455 f.close();
459 456
460 packageFileDir = "/usr/lib/ipkg/info/"; 457 packageFileDir = "/usr/lib/ipkg/info/";
461 packageFileDir.append( packageFilename ); 458 packageFileDir.append( packageFilename );
462 packageFileDir.append( ".list" ); 459 packageFileDir.append( ".list" );
463 f.setName( packageFileDir ); 460 f.setName( packageFileDir );
464 if ( ! f.open(IO_ReadOnly) ) 461 if ( ! f.open(IO_ReadOnly) )
465 { 462 {
466 QString tempstr = "Could not open :"; 463 QString tempstr = "Could not open :";
467 tempstr.append( packageFileDir ); 464 tempstr.append( packageFileDir );
468 emit outputText( tempstr ); 465 emit outputText( tempstr );
469 return (QStringList*)0; 466 return (QStringList*)0;
470 } 467 }
471 } 468 }
472 QStringList *fileList = new QStringList(); 469 QStringList *fileList = new QStringList();
473 QTextStream t( &f ); 470 QTextStream t( &f );
474 while ( !t.eof() ) 471 while ( !t.eof() )
475 *fileList += t.readLine(); 472 *fileList += t.readLine();
476 473
477 f.close(); 474 f.close();
478 return fileList; 475 return fileList;
479} 476}
480 477
481void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 478void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
482{ 479{
483 if ( !fileList || fileList->isEmpty() ) 480 if ( !fileList || fileList->isEmpty() )
484 return; 481 return;
485 482
486 QString baseDir = ROOT; 483 QString baseDir = ROOT;
487 484
488 if ( createLinks == true ) 485 if ( createLinks == true )
489 { 486 {
490 for ( uint i=0; i < fileList->count(); i++ ) 487 for ( uint i=0; i < fileList->count(); i++ )
491 { 488 {
492 processLinkDir( (*fileList)[i], baseDir, destDir ); 489 processLinkDir( (*fileList)[i], baseDir, destDir );
493 qApp->processEvents(); 490 qApp->processEvents();
494 } 491 }
495 } 492 }
496 else 493 else
497 { 494 {
498 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 495 for ( int i = fileList->count()-1; i >= 0 ; i-- )
499 { 496 {
500 processLinkDir( (*fileList)[i], baseDir, destDir ); 497 processLinkDir( (*fileList)[i], baseDir, destDir );
501 qApp->processEvents(); 498 qApp->processEvents();
502 } 499 }
503 } 500 }
504} 501}
505 502
506void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 503void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
507{ 504{
508 505
509 QString sourceFile = baseDir; 506 QString sourceFile = baseDir;
510 sourceFile.append( file ); 507 sourceFile.append( file );
511 508
512 QString linkFile = destDir; 509 QString linkFile = destDir;
513 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 510 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
514 { 511 {
515 linkFile.append( file.mid( 1 ) ); 512 linkFile.append( file.mid( 1 ) );
516 } 513 }
517 else 514 else
518 { 515 {
519 linkFile.append( file ); 516 linkFile.append( file );
520 } 517 }
521 QString text; 518 QString text;
522 if ( createLinks ) 519 if ( createLinks )
523 { 520 {
524 // If this file is a directory (ends with a /) and it doesn't exist, 521 // If this file is a directory (ends with a /) and it doesn't exist,
525 // we need to create it 522 // we need to create it
526 if ( file.right(1) == "/" ) 523 if ( file.right(1) == "/" )
527 { 524 {
528 QFileInfo f( linkFile ); 525 QFileInfo f( linkFile );
529 if ( !f.exists() ) 526 if ( !f.exists() )
530 { 527 {
531 QString tempstr = "Creating directory "; 528 QString tempstr = "Creating directory ";
532 tempstr.append( linkFile ); 529 tempstr.append( linkFile );
533 emit outputText( tempstr ); 530 emit outputText( tempstr );
534 QDir d; 531 QDir d;
535 d.mkdir( linkFile, true ); 532 d.mkdir( linkFile, true );
536 } 533 }
537// else 534// else
538// emit outputText( QString( "Directory " ) + linkFile + " already exists" ); 535// emit outputText( QString( "Directory " ) + linkFile + " already exists" );
539 536
540 } 537 }
541 else 538 else
542 { 539 {
543 int rc = symlink( sourceFile, linkFile ); 540 int rc = symlink( sourceFile, linkFile );
544 text = (rc == 0 ? "Linked " : "Failed to link "); 541 text = (rc == 0 ? "Linked " : "Failed to link ");
545 text.append( sourceFile ); 542 text.append( sourceFile );
546 text.append( " to " ); 543 text.append( " to " );
547 text.append( linkFile ); 544 text.append( linkFile );
548 emit outputText( text ); 545 emit outputText( text );
549 } 546 }
550 } 547 }
551 else 548 else
552 { 549 {
553 QFileInfo f( linkFile ); 550 QFileInfo f( linkFile );
554 if ( f.exists() ) 551 if ( f.exists() )
555 { 552 {
556 if ( f.isFile() ) 553 if ( f.isFile() )
557 { 554 {
558 QFile f( linkFile ); 555 QFile f( linkFile );
559 bool rc = f.remove(); 556 bool rc = f.remove();
560 557
561 text = (rc ? "Removed " : "Failed to remove "); 558 text = (rc ? "Removed " : "Failed to remove ");
562 text.append( linkFile ); 559 text.append( linkFile );
563 emit outputText( text ); 560 emit outputText( text );
564 } 561 }
565 else if ( f.isDir() ) 562 else if ( f.isDir() )
566 { 563 {
567 QDir d; 564 QDir d;
568 bool rc = d.rmdir( linkFile, true ); 565 bool rc = d.rmdir( linkFile, true );
569 if ( rc ) 566 if ( rc )
570 { 567 {
571 text = (rc ? "Removed " : "Failed to remove "); 568 text = (rc ? "Removed " : "Failed to remove ");
572 text.append( linkFile ); 569 text.append( linkFile );
573 emit outputText( text ); 570 emit outputText( text );
574 } 571 }
575 } 572 }
576 } 573 }
577 } 574 }
578} 575}
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 531bfc0..a0d38e3 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -1,90 +1,92 @@
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 void runIpkg();
47 void createSymLinks();
47 48
48 void setOption( const char *opt ) { option = opt; } 49 void setOption( const char *opt ) { option = opt; }
49 void setPackage( const char *pkg ) { package = pkg; } 50 void setPackage( const char *pkg ) { package = pkg; }
50 void setDestination( const char *dest ) { destination = dest; } 51 void setDestination( const char *dest ) { destination = dest; }
51 void setDestinationDir( const char *dir ) { destDir = dir; } 52 void setDestinationDir( const char *dir ) { destDir = dir; }
52 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } 53 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; }
53 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } 54 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
54 55
55signals: 56signals:
56 void outputText( const QString &text ); 57 void outputText( const QString &text );
58 void ipkgFinished();
57 59
58public slots: 60public slots:
59 void commandStdout(OProcess*, char *buffer, int buflen); 61 void commandStdout(OProcess*, char *buffer, int buflen);
60 void commandStderr(OProcess*, char *buffer, int buflen); 62 void commandStderr(OProcess*, char *buffer, int buflen);
61 void processFinished(); 63 void processFinished();
62 void abort(); 64 void abort();
63 65
64 66
65private: 67private:
66 bool createLinks; 68 bool createLinks;
67 bool aborted; 69 bool aborted;
68 bool error; 70 bool error;
69 QString option; 71 QString option;
70 QString package; 72 QString package;
71 QString destination; 73 QString destination;
72 QString destDir; 74 QString destDir;
73 QString runtimeDir; 75 QString runtimeDir;
74 OProcess *proc; 76 OProcess *proc;
75 int flags; 77 int flags;
76 int infoLevel; 78 int infoLevel;
77 bool finished; 79 bool finished;
78 80
79 QList<QString> *dependantPackages; 81 QList<QString> *dependantPackages;
80 82
81 int executeIpkgCommand( QStringList &cmd, const QString option ); 83 int executeIpkgCommand( QStringList &cmd, const QString option );
82 void removeStatusEntry(); 84 void removeStatusEntry();
83 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); 85 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir );
84 QStringList* getList( const QString &packageFilename, const QString &destDir ); 86 QStringList* getList( const QString &packageFilename, const QString &destDir );
85 void processFileList( const QStringList *fileList, const QString &destDir ); 87 void processFileList( const QStringList *fileList, const QString &destDir );
86 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); 88 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir );
87 89
88}; 90};
89 91
90#endif 92#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 1aec6a8..58f6feb 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,1158 +1,1158 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 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 <linux/limits.h> 18#include <linux/limits.h>
19#include <unistd.h> 19#include <unistd.h>
20 20
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qmenubar.h> 22#include <qmenubar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qtoolbar.h> 24#include <qtoolbar.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qaction.h> 28#include <qaction.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qtimer.h> 39#include <qtimer.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41#include <qwidgetstack.h> 41#include <qwidgetstack.h>
42 42
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44#include "datamgr.h" 44#include "datamgr.h"
45#include "global.h" 45#include "global.h"
46#include "inputdlg.h" 46#include "inputdlg.h"
47#include "ipkg.h" 47#include "ipkg.h"
48#include "installdlgimpl.h" 48#include "installdlgimpl.h"
49#include "letterpushbutton.h" 49#include "letterpushbutton.h"
50#include "mainwin.h" 50#include "mainwin.h"
51#include "packagewin.h" 51#include "packagewin.h"
52#include "settingsimpl.h" 52#include "settingsimpl.h"
53#include "utils.h" 53#include "utils.h"
54 54
55extern int compareVersions( const char *v1, const char *v2 ); 55extern int compareVersions( const char *v1, const char *v2 );
56 56
57MainWindow :: MainWindow() 57MainWindow :: MainWindow()
58 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 58 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
59{ 59{
60 setCaption( tr( "AQPkg - Package Manager" ) ); 60 setCaption( tr( "AQPkg - Package Manager" ) );
61 61
62 // Create UI widgets 62 // Create UI widgets
63 initMainWidget(); 63 initMainWidget();
64 initProgressWidget(); 64 initProgressWidget();
65 65
66 // Build menu and tool bars 66 // Build menu and tool bars
67 setToolBarsMovable( FALSE ); 67 setToolBarsMovable( FALSE );
68 68
69 QToolBar *bar = new QToolBar( this ); 69 QToolBar *bar = new QToolBar( this );
70 bar->setHorizontalStretchable( TRUE ); 70 bar->setHorizontalStretchable( TRUE );
71 QMenuBar *mb = new QMenuBar( bar ); 71 QMenuBar *mb = new QMenuBar( bar );
72 mb->setMargin( 0 ); 72 mb->setMargin( 0 );
73 bar = new QToolBar( this ); 73 bar = new QToolBar( this );
74 74
75 // Find toolbar 75 // Find toolbar
76 findBar = new QToolBar( this ); 76 findBar = new QToolBar( this );
77 addToolBar( findBar, QMainWindow::Top, true ); 77 addToolBar( findBar, QMainWindow::Top, true );
78 findBar->setHorizontalStretchable( true ); 78 findBar->setHorizontalStretchable( true );
79 findEdit = new QLineEdit( findBar ); 79 findEdit = new QLineEdit( findBar );
80 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 80 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
81 findBar->setStretchableWidget( findEdit ); 81 findBar->setStretchableWidget( findEdit );
82 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 82 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
83 83
84 // Quick jump toolbar 84 // Quick jump toolbar
85 jumpBar = new QToolBar( this ); 85 jumpBar = new QToolBar( this );
86 addToolBar( jumpBar, QMainWindow::Top, true ); 86 addToolBar( jumpBar, QMainWindow::Top, true );
87 jumpBar->setHorizontalStretchable( true ); 87 jumpBar->setHorizontalStretchable( true );
88 QWidget *w = new QWidget( jumpBar ); 88 QWidget *w = new QWidget( jumpBar );
89 jumpBar->setStretchableWidget( w ); 89 jumpBar->setStretchableWidget( w );
90 90
91 QGridLayout *layout = new QGridLayout( w ); 91 QGridLayout *layout = new QGridLayout( w );
92 92
93 char text[2]; 93 char text[2];
94 text[1] = '\0'; 94 text[1] = '\0';
95 for ( int i = 0 ; i < 26 ; ++i ) 95 for ( int i = 0 ; i < 26 ; ++i )
96 { 96 {
97 text[0] = 'A' + i; 97 text[0] = 'A' + i;
98 LetterPushButton *b = new LetterPushButton( text, w ); 98 LetterPushButton *b = new LetterPushButton( text, w );
99 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 99 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
100 layout->addWidget( b, i / 13, i % 13); 100 layout->addWidget( b, i / 13, i % 13);
101 } 101 }
102 102
103 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 103 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
104 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 104 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
105 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 105 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
106 a->addTo( jumpBar ); 106 a->addTo( jumpBar );
107 jumpBar->hide(); 107 jumpBar->hide();
108 108
109 // Packages menu 109 // Packages menu
110 QPopupMenu *popup = new QPopupMenu( this ); 110 QPopupMenu *popup = new QPopupMenu( this );
111 111
112 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 112 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
113 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 113 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
114 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 114 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
115 a->addTo( popup ); 115 a->addTo( popup );
116 a->addTo( bar ); 116 a->addTo( bar );
117 117
118 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 118 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
119 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 119 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
120 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 120 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
121 actionUpgrade->addTo( popup ); 121 actionUpgrade->addTo( popup );
122 actionUpgrade->addTo( bar ); 122 actionUpgrade->addTo( bar );
123 123
124 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 124 iconDownload = Resource::loadPixmap( "aqpkg/download" );
125 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 125 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
126 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 126 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
127 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 127 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
128 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 128 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
129 actionDownload->addTo( popup ); 129 actionDownload->addTo( popup );
130 actionDownload->addTo( bar ); 130 actionDownload->addTo( bar );
131 131
132 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 132 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
133 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 133 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
134 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 134 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
135 a->addTo( popup ); 135 a->addTo( popup );
136 a->addTo( bar ); 136 a->addTo( bar );
137 137
138 popup->insertSeparator(); 138 popup->insertSeparator();
139 139
140 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 140 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
141 a->setWhatsThis( tr( "Click here to configure this application." ) ); 141 a->setWhatsThis( tr( "Click here to configure this application." ) );
142 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 142 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
143 a->addTo( popup ); 143 a->addTo( popup );
144 mb->insertItem( tr( "Actions" ), popup ); 144 mb->insertItem( tr( "Actions" ), popup );
145 145
146 // View menu 146 // View menu
147 popup = new QPopupMenu( this ); 147 popup = new QPopupMenu( this );
148 148
149 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 149 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
150 actionUninstalled->setToggleAction( TRUE ); 150 actionUninstalled->setToggleAction( TRUE );
151 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 151 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
152 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 152 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
153 actionUninstalled->addTo( popup ); 153 actionUninstalled->addTo( popup );
154 154
155 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 155 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
156 actionInstalled->setToggleAction( TRUE ); 156 actionInstalled->setToggleAction( TRUE );
157 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 157 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
158 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 158 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
159 actionInstalled->addTo( popup ); 159 actionInstalled->addTo( popup );
160 160
161 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 161 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
162 actionUpdated->setToggleAction( TRUE ); 162 actionUpdated->setToggleAction( TRUE );
163 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 163 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
164 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 164 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
165 actionUpdated->addTo( popup ); 165 actionUpdated->addTo( popup );
166 166
167 popup->insertSeparator(); 167 popup->insertSeparator();
168 168
169 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 169 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
170 actionFilter->setToggleAction( TRUE ); 170 actionFilter->setToggleAction( TRUE );
171 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 171 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
172 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 172 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
173 actionFilter->addTo( popup ); 173 actionFilter->addTo( popup );
174 174
175 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 175 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 176 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 177 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
178 a->addTo( popup ); 178 a->addTo( popup );
179 179
180 popup->insertSeparator(); 180 popup->insertSeparator();
181 181
182 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 182 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
183 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 183 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
184 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 184 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
185 a->addTo( popup ); 185 a->addTo( popup );
186 186
187 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 187 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
188 actionFindNext->setEnabled( FALSE ); 188 actionFindNext->setEnabled( FALSE );
189 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 189 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
190 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 190 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
191 actionFindNext->addTo( popup ); 191 actionFindNext->addTo( popup );
192 actionFindNext->addTo( findBar ); 192 actionFindNext->addTo( findBar );
193 193
194 194
195 popup->insertSeparator(); 195 popup->insertSeparator();
196 196
197 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 197 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
198 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 198 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
199 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
200 a->addTo( popup ); 200 a->addTo( popup );
201 201
202 mb->insertItem( tr( "View" ), popup ); 202 mb->insertItem( tr( "View" ), popup );
203 203
204 // Finish find toolbar creation 204 // Finish find toolbar creation
205 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 205 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
206 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 206 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
207 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 207 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
208 a->addTo( findBar ); 208 a->addTo( findBar );
209 findBar->hide(); 209 findBar->hide();
210 210
211 // Create widget stack and add UI widgets 211 // Create widget stack and add UI widgets
212 stack = new QWidgetStack( this ); 212 stack = new QWidgetStack( this );
213 stack->addWidget( progressWindow, 2 ); 213 stack->addWidget( progressWindow, 2 );
214 stack->addWidget( networkPkgWindow, 1 ); 214 stack->addWidget( networkPkgWindow, 1 );
215 setCentralWidget( stack ); 215 setCentralWidget( stack );
216 stack->raiseWidget( progressWindow ); 216 stack->raiseWidget( progressWindow );
217 217
218 // Delayed call to finish initialization 218 // Delayed call to finish initialization
219 QTimer::singleShot( 100, this, SLOT( init() ) ); 219 QTimer::singleShot( 100, this, SLOT( init() ) );
220} 220}
221 221
222MainWindow :: ~MainWindow() 222MainWindow :: ~MainWindow()
223{ 223{
224 delete mgr; 224 delete mgr;
225} 225}
226 226
227void MainWindow :: initMainWidget() 227void MainWindow :: initMainWidget()
228{ 228{
229 networkPkgWindow = new QWidget( this ); 229 networkPkgWindow = new QWidget( this );
230 230
231 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 231 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
232 232
233 serversList = new QComboBox( networkPkgWindow ); 233 serversList = new QComboBox( networkPkgWindow );
234 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); 234 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) );
235 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 235 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
236 236
237 installedIcon = Resource::loadPixmap( "installed" ); 237 installedIcon = Resource::loadPixmap( "installed" );
238 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 238 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
239 239
240 packagesList = new QListView( networkPkgWindow ); 240 packagesList = new QListView( networkPkgWindow );
241 packagesList->addColumn( tr( "Packages" ), 225 ); 241 packagesList->addColumn( tr( "Packages" ), 225 );
242 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); 242 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
243 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); 243 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold );
244 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), 244 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),
245 this, SLOT(slotDisplayPackage(QListViewItem *)) ); 245 this, SLOT(slotDisplayPackage(QListViewItem *)) );
246 246
247 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 247 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
248 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 248 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
249 hbox1->addWidget( l ); 249 hbox1->addWidget( l );
250 hbox1->addWidget( serversList ); 250 hbox1->addWidget( serversList );
251 251
252 vbox->addWidget( packagesList ); 252 vbox->addWidget( packagesList );
253 253
254 downloadEnabled = TRUE; 254 downloadEnabled = TRUE;
255} 255}
256 256
257void MainWindow :: initProgressWidget() 257void MainWindow :: initProgressWidget()
258{ 258{
259 progressWindow = new QWidget( this ); 259 progressWindow = new QWidget( this );
260 260
261 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 261 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
262 262
263 m_status = new QLabel( progressWindow ); 263 m_status = new QLabel( progressWindow );
264 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 264 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
265 layout->addWidget( m_status ); 265 layout->addWidget( m_status );
266 266
267 m_progress = new QProgressBar( progressWindow ); 267 m_progress = new QProgressBar( progressWindow );
268 layout->addWidget( m_progress ); 268 layout->addWidget( m_progress );
269} 269}
270 270
271void MainWindow :: init() 271void MainWindow :: init()
272{ 272{
273#ifdef QWS 273#ifdef QWS
274 // read download directory from config file 274 // read download directory from config file
275 Config cfg( "aqpkg" ); 275 Config cfg( "aqpkg" );
276 cfg.setGroup( "settings" ); 276 cfg.setGroup( "settings" );
277 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 277 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
278// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 278// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
279 279
280#endif 280#endif
281 281
282 stack->raiseWidget( progressWindow ); 282 stack->raiseWidget( progressWindow );
283 283
284 mgr = new DataManager(); 284 mgr = new DataManager();
285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
287 this, SLOT( setProgressMessage( const QString & ) ) ); 287 this, SLOT( setProgressMessage( const QString & ) ) );
288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
289 mgr->loadServers(); 289 mgr->loadServers();
290 290
291 showUninstalledPkgs = false; 291 showUninstalledPkgs = false;
292 showInstalledPkgs = false; 292 showInstalledPkgs = false;
293 showUpgradedPkgs = false; 293 showUpgradedPkgs = false;
294 categoryFilterEnabled = false; 294 categoryFilterEnabled = false;
295 295
296 updateData(); 296 updateData();
297 297
298 stack->raiseWidget( networkPkgWindow ); 298 stack->raiseWidget( networkPkgWindow );
299} 299}
300/* 300
301void MainWindow :: setDocument( const QString &doc ) 301void MainWindow :: setDocument( const QString &doc )
302{ 302{
303 // Remove path from package 303 // Remove path from package
304 QString package = Utils::getPackageNameFromIpkFilename( doc ); 304 QString package = Utils::getPackageNameFromIpkFilename( doc );
305// std::cout << "Selecting package " << package << std::endl; 305// std::cout << "Selecting package " << package << std::endl;
306 306
307 // First select local server 307 // First select local server
308 for ( int i = 0 ; i < serversList->count() ; ++i ) 308 for ( int i = 0 ; i < serversList->count() ; ++i )
309 { 309 {
310 if ( serversList->text( i ) == LOCAL_IPKGS ) 310 if ( serversList->text( i ) == LOCAL_IPKGS )
311 { 311 {
312 serversList->setCurrentItem( i ); 312 serversList->setCurrentItem( i );
313 break; 313 break;
314 } 314 }
315 } 315 }
316 serverSelected( 0 ); 316 serverSelected( 0 );
317 317
318 // Now set the check box of the selected package 318 // Now set the check box of the selected package
319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
320 item != 0 ; 320 item != 0 ;
321 item = (QCheckListItem *)item->nextSibling() ) 321 item = (QCheckListItem *)item->nextSibling() )
322 { 322 {
323 if ( item->text().startsWith( package ) ) 323 if ( item->text().startsWith( package ) )
324 { 324 {
325 item->setOn( true ); 325 item->setOn( true );
326 break; 326 break;
327 } 327 }
328 } 328 }
329} 329}
330*/ 330
331void MainWindow :: displaySettings() 331void MainWindow :: displaySettings()
332{ 332{
333 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 333 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
334 if ( dlg->showDlg() ) 334 if ( dlg->showDlg() )
335 { 335 {
336 stack->raiseWidget( progressWindow ); 336 stack->raiseWidget( progressWindow );
337 updateData(); 337 updateData();
338 stack->raiseWidget( networkPkgWindow ); 338 stack->raiseWidget( networkPkgWindow );
339 } 339 }
340 delete dlg; 340 delete dlg;
341} 341}
342 342
343void MainWindow :: closeEvent( QCloseEvent *e ) 343void MainWindow :: closeEvent( QCloseEvent *e )
344{ 344{
345 // If install dialog is visible, return to main view, otherwise close app 345 // If install dialog is visible, return to main view, otherwise close app
346 QWidget *widget = stack->visibleWidget(); 346 QWidget *widget = stack->visibleWidget();
347 347
348 if ( widget != networkPkgWindow && widget != progressWindow ) 348 if ( widget != networkPkgWindow && widget != progressWindow )
349 { 349 {
350 if ( widget ) delete widget; 350 if ( widget ) delete widget;
351 stack->raiseWidget( networkPkgWindow ); 351 stack->raiseWidget( networkPkgWindow );
352 e->ignore(); 352 e->ignore();
353 } 353 }
354 else 354 else
355 { 355 {
356 e->accept(); 356 e->accept();
357 } 357 }
358} 358}
359 359
360void MainWindow :: displayFindBar() 360void MainWindow :: displayFindBar()
361{ 361{
362 findBar->show(); 362 findBar->show();
363 findEdit->setFocus(); 363 findEdit->setFocus();
364} 364}
365 365
366void MainWindow :: displayJumpBar() 366void MainWindow :: displayJumpBar()
367{ 367{
368 jumpBar->show(); 368 jumpBar->show();
369} 369}
370 370
371void MainWindow :: repeatFind() 371void MainWindow :: repeatFind()
372{ 372{
373 searchForPackage( findEdit->text() ); 373 searchForPackage( findEdit->text() );
374} 374}
375 375
376void MainWindow :: findPackage( const QString &text ) 376void MainWindow :: findPackage( const QString &text )
377{ 377{
378 actionFindNext->setEnabled( !text.isEmpty() ); 378 actionFindNext->setEnabled( !text.isEmpty() );
379 searchForPackage( text ); 379 searchForPackage( text );
380} 380}
381 381
382void MainWindow :: hideFindBar() 382void MainWindow :: hideFindBar()
383{ 383{
384 findBar->hide(); 384 findBar->hide();
385} 385}
386 386
387void MainWindow :: hideJumpBar() 387void MainWindow :: hideJumpBar()
388{ 388{
389 jumpBar->hide(); 389 jumpBar->hide();
390} 390}
391 391
392void MainWindow :: filterUninstalledPackages() 392void MainWindow :: filterUninstalledPackages()
393{ 393{
394 showUninstalledPkgs = actionUninstalled->isOn(); 394 showUninstalledPkgs = actionUninstalled->isOn();
395 if ( showUninstalledPkgs ) 395 if ( showUninstalledPkgs )
396 { 396 {
397 showInstalledPkgs = FALSE; 397 showInstalledPkgs = FALSE;
398 showUpgradedPkgs = FALSE; 398 showUpgradedPkgs = FALSE;
399 } 399 }
400 serverSelected( -1 ); 400 serverSelected( -1 );
401 401
402 actionInstalled->setOn( FALSE ); 402 actionInstalled->setOn( FALSE );
403 actionUpdated->setOn( FALSE ); 403 actionUpdated->setOn( FALSE );
404} 404}
405 405
406void MainWindow :: filterInstalledPackages() 406void MainWindow :: filterInstalledPackages()
407{ 407{
408 showInstalledPkgs = actionInstalled->isOn(); 408 showInstalledPkgs = actionInstalled->isOn();
409 if ( showInstalledPkgs ) 409 if ( showInstalledPkgs )
410 { 410 {
411 showUninstalledPkgs = FALSE; 411 showUninstalledPkgs = FALSE;
412 showUpgradedPkgs = FALSE; 412 showUpgradedPkgs = FALSE;
413 } 413 }
414 serverSelected( -1 ); 414 serverSelected( -1 );
415 415
416 actionUninstalled->setOn( FALSE ); 416 actionUninstalled->setOn( FALSE );
417 actionUpdated->setOn( FALSE ); 417 actionUpdated->setOn( FALSE );
418} 418}
419 419
420void MainWindow :: filterUpgradedPackages() 420void MainWindow :: filterUpgradedPackages()
421{ 421{
422 showUpgradedPkgs = actionUpdated->isOn(); 422 showUpgradedPkgs = actionUpdated->isOn();
423 if ( showUpgradedPkgs ) 423 if ( showUpgradedPkgs )
424 { 424 {
425 showUninstalledPkgs = FALSE; 425 showUninstalledPkgs = FALSE;
426 showInstalledPkgs = FALSE; 426 showInstalledPkgs = FALSE;
427 } 427 }
428 serverSelected( -1 ); 428 serverSelected( -1 );
429 429
430 actionUninstalled->setOn( FALSE ); 430 actionUninstalled->setOn( FALSE );
431 actionInstalled->setOn( FALSE ); 431 actionInstalled->setOn( FALSE );
432} 432}
433 433
434bool MainWindow :: setFilterCategory() 434bool MainWindow :: setFilterCategory()
435{ 435{
436 // Get categories; 436 // Get categories;
437 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 437 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
438 if ( dlg.exec() == QDialog::Accepted ) 438 if ( dlg.exec() == QDialog::Accepted )
439 { 439 {
440 categoryFilter = dlg.getSelectedFilter(); 440 categoryFilter = dlg.getSelectedFilter();
441 441
442 if ( categoryFilter == "" ) 442 if ( categoryFilter == "" )
443 return false; 443 return false;
444 444
445 categoryFilterEnabled = true; 445 categoryFilterEnabled = true;
446 serverSelected( -1 ); 446 serverSelected( -1 );
447 actionFilter->setOn( TRUE ); 447 actionFilter->setOn( TRUE );
448 return true; 448 return true;
449 } 449 }
450 450
451 return false; 451 return false;
452} 452}
453 453
454void MainWindow :: filterCategory() 454void MainWindow :: filterCategory()
455{ 455{
456 if ( !actionFilter->isOn() ) 456 if ( !actionFilter->isOn() )
457 { 457 {
458 filterByCategory( FALSE ); 458 filterByCategory( FALSE );
459 } 459 }
460 else 460 else
461 { 461 {
462 actionFilter->setOn( filterByCategory( TRUE ) ); 462 actionFilter->setOn( filterByCategory( TRUE ) );
463 } 463 }
464} 464}
465 465
466bool MainWindow :: filterByCategory( bool val ) 466bool MainWindow :: filterByCategory( bool val )
467{ 467{
468 if ( val ) 468 if ( val )
469 { 469 {
470 if ( categoryFilter == "" ) 470 if ( categoryFilter == "" )
471 { 471 {
472 if ( !setFilterCategory() ) 472 if ( !setFilterCategory() )
473 return false; 473 return false;
474 } 474 }
475 475
476 categoryFilterEnabled = true; 476 categoryFilterEnabled = true;
477 serverSelected( -1 ); 477 serverSelected( -1 );
478 return true; 478 return true;
479 } 479 }
480 else 480 else
481 { 481 {
482 // Turn off filter 482 // Turn off filter
483 categoryFilterEnabled = false; 483 categoryFilterEnabled = false;
484 serverSelected( -1 ); 484 serverSelected( -1 );
485 return false; 485 return false;
486 } 486 }
487} 487}
488 488
489void MainWindow :: raiseMainWidget() 489void MainWindow :: raiseMainWidget()
490{ 490{
491 stack->raiseWidget( networkPkgWindow ); 491 stack->raiseWidget( networkPkgWindow );
492} 492}
493 493
494void MainWindow :: raiseProgressWidget() 494void MainWindow :: raiseProgressWidget()
495{ 495{
496 stack->raiseWidget( progressWindow ); 496 stack->raiseWidget( progressWindow );
497} 497}
498 498
499void MainWindow :: enableUpgrade( bool enabled ) 499void MainWindow :: enableUpgrade( bool enabled )
500{ 500{
501 actionUpgrade->setEnabled( enabled ); 501 actionUpgrade->setEnabled( enabled );
502} 502}
503 503
504void MainWindow :: enableDownload( bool enabled ) 504void MainWindow :: enableDownload( bool enabled )
505{ 505{
506 if ( enabled ) 506 if ( enabled )
507 { 507 {
508 actionDownload->setIconSet( iconDownload ); 508 actionDownload->setIconSet( iconDownload );
509 actionDownload->setText( tr( "Download" ) ); 509 actionDownload->setText( tr( "Download" ) );
510 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 510 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
511 } 511 }
512 else 512 else
513 { 513 {
514 actionDownload->setIconSet( iconRemove ); 514 actionDownload->setIconSet( iconRemove );
515 actionDownload->setText( tr( "Remove" ) ); 515 actionDownload->setText( tr( "Remove" ) );
516 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 516 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
517 } 517 }
518} 518}
519 519
520void MainWindow :: setProgressSteps( int numsteps ) 520void MainWindow :: setProgressSteps( int numsteps )
521{ 521{
522 m_progress->setTotalSteps( numsteps ); 522 m_progress->setTotalSteps( numsteps );
523} 523}
524 524
525void MainWindow :: setProgressMessage( const QString &msg ) 525void MainWindow :: setProgressMessage( const QString &msg )
526{ 526{
527 m_status->setText( msg ); 527 m_status->setText( msg );
528} 528}
529 529
530void MainWindow :: updateProgress( int progress ) 530void MainWindow :: updateProgress( int progress )
531{ 531{
532 m_progress->setProgress( progress ); 532 m_progress->setProgress( progress );
533} 533}
534 534
535void MainWindow :: updateData() 535void MainWindow :: updateData()
536{ 536{
537 m_progress->setTotalSteps( mgr->getServerList().count() ); 537 m_progress->setTotalSteps( mgr->getServerList().count() );
538 538
539 serversList->clear(); 539 serversList->clear();
540 packagesList->clear(); 540 packagesList->clear();
541 541
542 int activeItem = -1; 542 int activeItem = -1;
543 int i = 0; 543 int i = 0;
544 QString serverName; 544 QString serverName;
545 545
546 QListIterator<Server> it( mgr->getServerList() ); 546 QListIterator<Server> it( mgr->getServerList() );
547 Server *server; 547 Server *server;
548 548
549 for ( ; it.current(); ++it, ++i ) 549 for ( ; it.current(); ++it, ++i )
550 { 550 {
551 server = it.current(); 551 server = it.current();
552 serverName = server->getServerName(); 552 serverName = server->getServerName();
553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
554 m_progress->setProgress( i ); 554 m_progress->setProgress( i );
555 qApp->processEvents(); 555 qApp->processEvents();
556 556
557// cout << "Adding " << it->getServerName() << " to combobox" << endl; 557// cout << "Adding " << it->getServerName() << " to combobox" << endl;
558 if ( !server->isServerActive() ) 558 if ( !server->isServerActive() )
559 { 559 {
560// cout << serverName << " is not active" << endl; 560// cout << serverName << " is not active" << endl;
561 i--; 561 i--;
562 continue; 562 continue;
563 } 563 }
564 564
565 serversList->insertItem( serverName ); 565 serversList->insertItem( serverName );
566 if ( serverName == currentlySelectedServer ) 566 if ( serverName == currentlySelectedServer )
567 activeItem = i; 567 activeItem = i;
568 } 568 }
569 569
570 // set selected server to be active server 570 // set selected server to be active server
571 if ( activeItem != -1 ) 571 if ( activeItem != -1 )
572 serversList->setCurrentItem( activeItem ); 572 serversList->setCurrentItem( activeItem );
573 serverSelected( 0, FALSE ); 573 serverSelected( 0, FALSE );
574} 574}
575 575
576void MainWindow :: serverSelected( int index ) 576void MainWindow :: serverSelected( int index )
577{ 577{
578 serverSelected( index, TRUE ); 578 serverSelected( index, TRUE );
579} 579}
580 580
581void MainWindow :: serverSelected( int, bool raiseProgress ) 581void MainWindow :: serverSelected( int, bool raiseProgress )
582{ 582{
583 QPixmap nullIcon( installedIcon.size() ); 583 QPixmap nullIcon( installedIcon.size() );
584 nullIcon.fill( colorGroup().base() ); 584 nullIcon.fill( colorGroup().base() );
585 585
586 // display packages 586 // display packages
587 QString serverName = serversList->currentText(); 587 QString serverName = serversList->currentText();
588 currentlySelectedServer = serverName; 588 currentlySelectedServer = serverName;
589 589
590 Server *s = mgr->getServer( serverName ); 590 Server *s = mgr->getServer( serverName );
591 591
592 QList<Package> &list = s->getPackageList(); 592 QList<Package> &list = s->getPackageList();
593 QListIterator<Package> it( list ); 593 QListIterator<Package> it( list );
594 594
595 // Display progress widget while loading list 595 // Display progress widget while loading list
596 bool doProgress = ( list.count() > 200 ); 596 bool doProgress = ( list.count() > 200 );
597 if ( doProgress ) 597 if ( doProgress )
598 { 598 {
599 if ( raiseProgress ) 599 if ( raiseProgress )
600 { 600 {
601 stack->raiseWidget( progressWindow ); 601 stack->raiseWidget( progressWindow );
602 } 602 }
603 m_progress->setTotalSteps( list.count() ); 603 m_progress->setTotalSteps( list.count() );
604 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 604 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
605 } 605 }
606 606
607 packagesList->clear(); 607 packagesList->clear();
608 608
609#ifdef QWS 609#ifdef QWS
610 // read download directory from config file 610 // read download directory from config file
611 Config cfg( "aqpkg" ); 611 Config cfg( "aqpkg" );
612 cfg.setGroup( "settings" ); 612 cfg.setGroup( "settings" );
613 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 613 cfg.writeEntry( "selectedServer", currentlySelectedServer );
614#endif 614#endif
615 615
616 int i = 0; 616 int i = 0;
617 Package *package; 617 Package *package;
618 for ( ; it.current(); ++it ) 618 for ( ; it.current(); ++it )
619 { 619 {
620 // Update progress after every 100th package (arbitrary value, seems to give good balance) 620 // Update progress after every 100th package (arbitrary value, seems to give good balance)
621 i++; 621 i++;
622 if ( ( i % 100 ) == 0 ) 622 if ( ( i % 100 ) == 0 )
623 { 623 {
624 if ( doProgress ) 624 if ( doProgress )
625 { 625 {
626 m_progress->setProgress( i ); 626 m_progress->setProgress( i );
627 } 627 }
628 qApp->processEvents(); 628 qApp->processEvents();
629 } 629 }
630 630
631 QString text = ""; 631 QString text = "";
632 632
633 package = it.current(); 633 package = it.current();
634 634
635 // Apply show only uninstalled packages filter 635 // Apply show only uninstalled packages filter
636 if ( showUninstalledPkgs && package->isInstalled() ) 636 if ( showUninstalledPkgs && package->isInstalled() )
637 continue; 637 continue;
638 638
639 // Apply show only installed packages filter 639 // Apply show only installed packages filter
640 if ( showInstalledPkgs && !package->isInstalled() ) 640 if ( showInstalledPkgs && !package->isInstalled() )
641 continue; 641 continue;
642 642
643 // Apply show only new installed packages filter 643 // Apply show only new installed packages filter
644 if ( showUpgradedPkgs ) 644 if ( showUpgradedPkgs )
645 { 645 {
646 if ( !package->isInstalled() || !package->getNewVersionAvailable() ) 646 if ( !package->isInstalled() || !package->getNewVersionAvailable() )
647 continue; 647 continue;
648 } 648 }
649 649
650 // Apply the section filter 650 // Apply the section filter
651 if ( categoryFilterEnabled && categoryFilter != "" ) 651 if ( categoryFilterEnabled && categoryFilter != "" )
652 { 652 {
653 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 653 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
654 continue; 654 continue;
655 } 655 }
656 656
657 // If the local server, only display installed packages 657 // If the local server, only display installed packages
658 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 658 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
659 continue; 659 continue;
660 660
661 661
662 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 662 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
663 QCheckListItem::CheckBox ); 663 QCheckListItem::CheckBox );
664 664
665 if ( package->isInstalled() ) 665 if ( package->isInstalled() )
666 { 666 {
667 // If a different version of package is available, show update available icon 667 // If a different version of package is available, show update available icon
668 // Otherwise, show installed icon 668 // Otherwise, show installed icon
669 if ( package->getNewVersionAvailable()) 669 if ( package->getNewVersionAvailable())
670 { 670 {
671 671
672 item->setPixmap( 0, updatedIcon ); 672 item->setPixmap( 0, updatedIcon );
673 } 673 }
674 else 674 else
675 { 675 {
676 item->setPixmap( 0, installedIcon ); 676 item->setPixmap( 0, installedIcon );
677 } 677 }
678 } 678 }
679 else 679 else
680 { 680 {
681 item->setPixmap( 0, nullIcon ); 681 item->setPixmap( 0, nullIcon );
682 } 682 }
683 683
684 packagesList->insertItem( item ); 684 packagesList->insertItem( item );
685 } 685 }
686 686
687 // If the local server or the local ipkgs server disable the download button 687 // If the local server or the local ipkgs server disable the download button
688 if ( serverName == LOCAL_SERVER ) 688 if ( serverName == LOCAL_SERVER )
689 { 689 {
690 downloadEnabled = TRUE; 690 downloadEnabled = TRUE;
691 actionUpgrade->setEnabled( FALSE ); 691 actionUpgrade->setEnabled( FALSE );
692 } 692 }
693 else if ( serverName == LOCAL_IPKGS ) 693 else if ( serverName == LOCAL_IPKGS )
694 { 694 {
695 downloadEnabled = FALSE; 695 downloadEnabled = FALSE;
696 actionUpgrade->setEnabled( FALSE ); 696 actionUpgrade->setEnabled( FALSE );
697 } 697 }
698 else 698 else
699 { 699 {
700 downloadEnabled = TRUE; 700 downloadEnabled = TRUE;
701 actionUpgrade->setEnabled( TRUE ); 701 actionUpgrade->setEnabled( TRUE );
702 } 702 }
703 enableDownload( downloadEnabled ); 703 enableDownload( downloadEnabled );
704 704
705 // Display this widget once everything is done 705 // Display this widget once everything is done
706 if ( doProgress && raiseProgress ) 706 if ( doProgress && raiseProgress )
707 { 707 {
708 stack->raiseWidget( networkPkgWindow ); 708 stack->raiseWidget( networkPkgWindow );
709 } 709 }
710} 710}
711 711
712void MainWindow :: searchForPackage( const QString &text ) 712void MainWindow :: searchForPackage( const QString &text )
713{ 713{
714 if ( !text.isEmpty() ) 714 if ( !text.isEmpty() )
715 { 715 {
716// cout << "searching for " << text << endl; 716// cout << "searching for " << text << endl;
717 // look through package list for text startng at current position 717 // look through package list for text startng at current position
718// vector<InstallData> workingPackages; 718// vector<InstallData> workingPackages;
719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
720// if ( start != 0 ) 720// if ( start != 0 )
721// start = (QCheckListItem *)start->nextSibling(); 721// start = (QCheckListItem *)start->nextSibling();
722 722
723 if ( start == 0 ) 723 if ( start == 0 )
724 start = (QCheckListItem *)packagesList->firstChild(); 724 start = (QCheckListItem *)packagesList->firstChild();
725 725
726 for ( QCheckListItem *item = start; item != 0 ; 726 for ( QCheckListItem *item = start; item != 0 ;
727 item = (QCheckListItem *)item->nextSibling() ) 727 item = (QCheckListItem *)item->nextSibling() )
728 { 728 {
729// cout << "checking " << item->text().lower() << endl; 729// cout << "checking " << item->text().lower() << endl;
730 if ( item->text().lower().find( text ) != -1 ) 730 if ( item->text().lower().find( text ) != -1 )
731 { 731 {
732// cout << "matched " << item->text() << endl; 732// cout << "matched " << item->text() << endl;
733 packagesList->ensureItemVisible( item ); 733 packagesList->ensureItemVisible( item );
734 packagesList->setCurrentItem( item ); 734 packagesList->setCurrentItem( item );
735 break; 735 break;
736 } 736 }
737 } 737 }
738 } 738 }
739} 739}
740 740
741void MainWindow :: updateServer() 741void MainWindow :: updateServer()
742{ 742{
743 QString serverName = serversList->currentText(); 743 QString serverName = serversList->currentText();
744 744
745 // Update the current server 745 // Update the current server
746 // Display dialog 746 // Display dialog
747 747
748 // Disable buttons to stop silly people clicking lots on them :) 748 // Disable buttons to stop silly people clicking lots on them :)
749 749
750 // First, write out ipkg_conf file so that ipkg can use it 750 // First, write out ipkg_conf file so that ipkg can use it
751 mgr->writeOutIpkgConf(); 751 mgr->writeOutIpkgConf();
752 752
753 Ipkg *ipkg = new Ipkg; 753 Ipkg *ipkg = new Ipkg;
754 ipkg->setOption( "update" ); 754 ipkg->setOption( "update" );
755 755
756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
757 tr( "Update lists" ) ); 757 tr( "Update lists" ) );
758 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 758 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
759 stack->addWidget( dlg, 3 ); 759 stack->addWidget( dlg, 3 );
760 stack->raiseWidget( dlg ); 760 stack->raiseWidget( dlg );
761 761
762// delete progDlg; 762// delete progDlg;
763} 763}
764 764
765void MainWindow :: upgradePackages() 765void MainWindow :: upgradePackages()
766{ 766{
767 // We're gonna do an upgrade of all packages 767 // We're gonna do an upgrade of all packages
768 // First warn user that this isn't recommended 768 // First warn user that this isn't recommended
769 // TODO - ODevice???? 769 // TODO - ODevice????
770 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 770 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
771 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 771 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
772 QMessageBox::Yes, 772 QMessageBox::Yes,
773 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 773 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
774 0, this ); 774 0, this );
775 warn.adjustSize(); 775 warn.adjustSize();
776 776
777 if ( warn.exec() == QMessageBox::Yes ) 777 if ( warn.exec() == QMessageBox::Yes )
778 { 778 {
779 // First, write out ipkg_conf file so that ipkg can use it 779 // First, write out ipkg_conf file so that ipkg can use it
780 mgr->writeOutIpkgConf(); 780 mgr->writeOutIpkgConf();
781 781
782 // Now run upgrade 782 // Now run upgrade
783 Ipkg *ipkg = new Ipkg; 783 Ipkg *ipkg = new Ipkg;
784 ipkg->setOption( "upgrade" ); 784 ipkg->setOption( "upgrade" );
785 785
786 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 786 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
787 tr ( "Upgrade" ) ); 787 tr ( "Upgrade" ) );
788 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 788 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
789 stack->addWidget( dlg, 3 ); 789 stack->addWidget( dlg, 3 );
790 stack->raiseWidget( dlg ); 790 stack->raiseWidget( dlg );
791 } 791 }
792} 792}
793 793
794void MainWindow :: downloadPackage() 794void MainWindow :: downloadPackage()
795{ 795{
796 bool doUpdate = true; 796 bool doUpdate = true;
797 if ( downloadEnabled ) 797 if ( downloadEnabled )
798 { 798 {
799 // See if any packages are selected 799 // See if any packages are selected
800 bool found = false; 800 bool found = false;
801 if ( serversList->currentText() != LOCAL_SERVER ) 801 if ( serversList->currentText() != LOCAL_SERVER )
802 { 802 {
803 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 803 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
804 item != 0 && !found; 804 item != 0 && !found;
805 item = (QCheckListItem *)item->nextSibling() ) 805 item = (QCheckListItem *)item->nextSibling() )
806 { 806 {
807 if ( item->isOn() ) 807 if ( item->isOn() )
808 found = true; 808 found = true;
809 } 809 }
810 } 810 }
811 811
812 // If user selected some packages then download the and store the locally 812 // If user selected some packages then download the and store the locally
813 // otherwise, display dialog asking user what package to download from an http server 813 // otherwise, display dialog asking user what package to download from an http server
814 // and whether to install it 814 // and whether to install it
815 if ( found ) 815 if ( found )
816 downloadSelectedPackages(); 816 downloadSelectedPackages();
817 else 817 else
818 downloadRemotePackage(); 818 downloadRemotePackage();
819 819
820 } 820 }
821 else 821 else
822 { 822 {
823 doUpdate = false; 823 doUpdate = false;
824 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 824 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
825 item != 0 ; 825 item != 0 ;
826 item = (QCheckListItem *)item->nextSibling() ) 826 item = (QCheckListItem *)item->nextSibling() )
827 { 827 {
828 if ( item->isOn() ) 828 if ( item->isOn() )
829 { 829 {
830 QString name = item->text(); 830 QString name = item->text();
831 int pos = name.find( "*" ); 831 int pos = name.find( "*" );
832 name.truncate( pos ); 832 name.truncate( pos );
833 833
834 // if (there is a (installed), remove it 834 // if (there is a (installed), remove it
835 pos = name.find( "(installed)" ); 835 pos = name.find( "(installed)" );
836 if ( pos > 0 ) 836 if ( pos > 0 )
837 name.truncate( pos - 1 ); 837 name.truncate( pos - 1 );
838 838
839 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 839 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
840 840
841 QString msgtext; 841 QString msgtext;
842 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 842 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
843 if ( QMessageBox::information( this, tr( "Are you sure?" ), 843 if ( QMessageBox::information( this, tr( "Are you sure?" ),
844 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 844 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
845 { 845 {
846 doUpdate = true; 846 doUpdate = true;
847 QFile f( p->getFilename() ); 847 QFile f( p->getFilename() );
848 f.remove(); 848 f.remove();
849 } 849 }
850 } 850 }
851 } 851 }
852 } 852 }
853 853
854 if ( doUpdate ) 854 if ( doUpdate )
855 { 855 {
856 reloadData( 0x0 ); 856 reloadData( 0x0 );
857 } 857 }
858} 858}
859 859
860void MainWindow :: downloadSelectedPackages() 860void MainWindow :: downloadSelectedPackages()
861{ 861{
862 // First, write out ipkg_conf file so that ipkg can use it 862 // First, write out ipkg_conf file so that ipkg can use it
863 mgr->writeOutIpkgConf(); 863 mgr->writeOutIpkgConf();
864 864
865 // Display dialog to user asking where to download the files to 865 // Display dialog to user asking where to download the files to
866 bool ok = FALSE; 866 bool ok = FALSE;
867 QString dir = ""; 867 QString dir = "";
868#ifdef QWS 868#ifdef QWS
869 // read download directory from config file 869 // read download directory from config file
870 Config cfg( "aqpkg" ); 870 Config cfg( "aqpkg" );
871 cfg.setGroup( "settings" ); 871 cfg.setGroup( "settings" );
872 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 872 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
873#endif 873#endif
874 874
875 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 875 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
876 if ( ok && !text.isEmpty() ) 876 if ( ok && !text.isEmpty() )
877 dir = text; // user entered something and pressed ok 877 dir = text; // user entered something and pressed ok
878 else 878 else
879 return; // user entered nothing or pressed cancel 879 return; // user entered nothing or pressed cancel
880 880
881#ifdef QWS 881#ifdef QWS
882 // Store download directory in config file 882 // Store download directory in config file
883 cfg.writeEntry( "downloadDir", dir ); 883 cfg.writeEntry( "downloadDir", dir );
884#endif 884#endif
885 885
886 // Get starting directory 886 // Get starting directory
887 char initDir[PATH_MAX]; 887 char initDir[PATH_MAX];
888 getcwd( initDir, PATH_MAX ); 888 getcwd( initDir, PATH_MAX );
889 889
890 // Download each package 890 // Download each package
891 Ipkg ipkg; 891 Ipkg ipkg;
892 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 892 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
893 893
894 ipkg.setOption( "download" ); 894 ipkg.setOption( "download" );
895 ipkg.setRuntimeDirectory( dir ); 895 ipkg.setRuntimeDirectory( dir );
896 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 896 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
897 item != 0 ; 897 item != 0 ;
898 item = (QCheckListItem *)item->nextSibling() ) 898 item = (QCheckListItem *)item->nextSibling() )
899 { 899 {
900 if ( item->isOn() ) 900 if ( item->isOn() )
901 { 901 {
902 ipkg.setPackage( item->text() ); 902 ipkg.setPackage( item->text() );
903 ipkg.runIpkg( ); 903 ipkg.runIpkg( );
904 } 904 }
905 } 905 }
906} 906}
907 907
908void MainWindow :: downloadRemotePackage() 908void MainWindow :: downloadRemotePackage()
909{ 909{
910 // Display dialog 910 // Display dialog
911 bool ok; 911 bool ok;
912 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 912 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
913 if ( !ok || package.isEmpty() ) 913 if ( !ok || package.isEmpty() )
914 return; 914 return;
915// DownloadRemoteDlgImpl dlg( this, "Install", true ); 915// DownloadRemoteDlgImpl dlg( this, "Install", true );
916// if ( dlg.exec() == QDialog::Rejected ) 916// if ( dlg.exec() == QDialog::Rejected )
917// return; 917// return;
918 918
919 // grab details from dialog 919 // grab details from dialog
920// QString package = dlg.getPackageLocation(); 920// QString package = dlg.getPackageLocation();
921 921
922 InstallData *item = new InstallData(); 922 InstallData *item = new InstallData();
923 item->option = "I"; 923 item->option = "I";
924 item->packageName = package; 924 item->packageName = package;
925 QList<InstallData> workingPackages; 925 QList<InstallData> workingPackages;
926 workingPackages.setAutoDelete( TRUE ); 926 workingPackages.setAutoDelete( TRUE );
927 workingPackages.append( item ); 927 workingPackages.append( item );
928 928
929 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 929 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
930 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 930 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
931 stack->addWidget( dlg, 3 ); 931 stack->addWidget( dlg, 3 );
932 stack->raiseWidget( dlg ); 932 stack->raiseWidget( dlg );
933} 933}
934 934
935 935
936void MainWindow :: applyChanges() 936void MainWindow :: applyChanges()
937{ 937{
938 stickyOption = ""; 938 stickyOption = "";
939 939
940 // First, write out ipkg_conf file so that ipkg can use it 940 // First, write out ipkg_conf file so that ipkg can use it
941 mgr->writeOutIpkgConf(); 941 mgr->writeOutIpkgConf();
942 942
943 // Now for each selected item 943 // Now for each selected item
944 // deal with it 944 // deal with it
945 945
946 QList<InstallData> workingPackages; 946 QList<InstallData> workingPackages;
947 workingPackages.setAutoDelete( TRUE ); 947 workingPackages.setAutoDelete( TRUE );
948 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 948 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
949 item != 0 ; 949 item != 0 ;
950 item = (QCheckListItem *)item->nextSibling() ) 950 item = (QCheckListItem *)item->nextSibling() )
951 { 951 {
952 if ( item->isOn() ) 952 if ( item->isOn() )
953 { 953 {
954 workingPackages.append( dealWithItem( item ) ); 954 workingPackages.append( dealWithItem( item ) );
955 } 955 }
956 } 956 }
957 957
958 if ( workingPackages.count() == 0 ) 958 if ( workingPackages.count() == 0 )
959 { 959 {
960 // Nothing to do 960 // Nothing to do
961 QMessageBox::information( this, tr( "Nothing to do" ), 961 QMessageBox::information( this, tr( "Nothing to do" ),
962 tr( "No packages selected" ), tr( "OK" ) ); 962 tr( "No packages selected" ), tr( "OK" ) );
963 963
964 return; 964 return;
965 } 965 }
966 966
967 // do the stuff 967 // do the stuff
968 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 968 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
969 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 969 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
970 stack->addWidget( dlg, 3 ); 970 stack->addWidget( dlg, 3 );
971 stack->raiseWidget( dlg ); 971 stack->raiseWidget( dlg );
972} 972}
973 973
974// decide what to do - either remove, upgrade or install 974// decide what to do - either remove, upgrade or install
975// Current rules: 975// Current rules:
976// If not installed - install 976// If not installed - install
977// If installed and different version available - upgrade 977// If installed and different version available - upgrade
978// If installed and version up to date - remove 978// If installed and version up to date - remove
979InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 979InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
980{ 980{
981 QString name = item->text(); 981 QString name = item->text();
982 982
983 // Get package 983 // Get package
984 Server *s = mgr->getServer( serversList->currentText() ); 984 Server *s = mgr->getServer( serversList->currentText() );
985 Package *p = s->getPackage( name ); 985 Package *p = s->getPackage( name );
986 986
987 // If the package has a filename then it is a local file 987 // If the package has a filename then it is a local file
988 if ( p->isPackageStoredLocally() ) 988 if ( p->isPackageStoredLocally() )
989 name = p->getFilename(); 989 name = p->getFilename();
990 990
991 QString option; 991 QString option;
992 QString dest = "root"; 992 QString dest = "root";
993 if ( !p->isInstalled() ) 993 if ( !p->isInstalled() )
994 { 994 {
995 InstallData *newitem = new InstallData();; 995 InstallData *newitem = new InstallData();
996 newitem->option = "I"; 996 newitem->option = "I";
997 newitem->packageName = name; 997 newitem->packageName = name;
998 return newitem; 998 return newitem;
999 } 999 }
1000 else 1000 else
1001 { 1001 {
1002 InstallData *newitem = new InstallData();; 1002 InstallData *newitem = new InstallData();
1003 newitem->option = "D"; 1003 newitem->option = "D";
1004 if ( !p->isPackageStoredLocally() ) 1004 if ( !p->isPackageStoredLocally() )
1005 newitem->packageName = p->getInstalledPackageName(); 1005 newitem->packageName = p->getInstalledPackageName();
1006 else 1006 else
1007 newitem->packageName = name; 1007 newitem->packageName = name;
1008 1008
1009 if ( p->getInstalledTo() ) 1009 if ( p->getInstalledTo() )
1010 { 1010 {
1011 newitem->destination = p->getInstalledTo(); 1011 newitem->destination = p->getInstalledTo();
1012// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1012// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1013// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1013// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1014 } 1014 }
1015 else 1015 else
1016 { 1016 {
1017 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1017 newitem->destination = p->getLocalPackage()->getInstalledTo();
1018 } 1018 }
1019 1019
1020 // Now see if version is newer or not 1020 // Now see if version is newer or not
1021 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1021 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1022 1022
1023 // If the version requested is older and user selected a local ipk file, then reinstall the file 1023 // If the version requested is older and user selected a local ipk file, then reinstall the file
1024 if ( p->isPackageStoredLocally() && val == -1 ) 1024 if ( p->isPackageStoredLocally() && val == -1 )
1025 val = 0; 1025 val = 0;
1026 1026
1027 if ( val == -2 ) 1027 if ( val == -2 )
1028 { 1028 {
1029 // Error - should handle 1029 // Error - should handle
1030 } 1030 }
1031 else if ( val == -1 ) 1031 else if ( val == -1 )
1032 { 1032 {
1033 // Version available is older - remove only 1033 // Version available is older - remove only
1034 newitem->option = "D"; 1034 newitem->option = "D";
1035 } 1035 }
1036 else 1036 else
1037 { 1037 {
1038 QString caption; 1038 QString caption;
1039 QString text; 1039 QString text;
1040 QString secondButton; 1040 QString secondButton;
1041 QString secondOption; 1041 QString secondOption;
1042 if ( val == 0 ) 1042 if ( val == 0 )
1043 { 1043 {
1044 // Version available is the same - option to remove or reinstall 1044 // Version available is the same - option to remove or reinstall
1045 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1045 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1046 text = tr( "Remove or ReInstall" ); 1046 text = tr( "Remove or ReInstall" );
1047 secondButton = tr( "ReInstall" ); 1047 secondButton = tr( "ReInstall" );
1048 secondOption = tr( "R" ); 1048 secondOption = tr( "R" );
1049 } 1049 }
1050 else if ( val == 1 ) 1050 else if ( val == 1 )
1051 { 1051 {
1052 // Version available is newer - option to remove or upgrade 1052 // Version available is newer - option to remove or upgrade
1053 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1053 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1054 text = tr( "Remove or Upgrade" ); 1054 text = tr( "Remove or Upgrade" );
1055 secondButton = tr( "Upgrade" ); 1055 secondButton = tr( "Upgrade" );
1056 secondOption = tr( "U" ); 1056 secondOption = tr( "U" );
1057 } 1057 }
1058 1058
1059 // Sticky option not implemented yet, but will eventually allow 1059 // Sticky option not implemented yet, but will eventually allow
1060 // the user to say something like 'remove all' 1060 // the user to say something like 'remove all'
1061 if ( stickyOption == "" ) 1061 if ( stickyOption == "" )
1062 { 1062 {
1063 QString msgtext; 1063 QString msgtext;
1064 msgtext = caption.arg( ( const char * )name ); 1064 msgtext = caption.arg( ( const char * )name );
1065 switch( QMessageBox::information( this, text, 1065 switch( QMessageBox::information( this, text,
1066 msgtext, tr( "Remove" ), secondButton ) ) 1066 msgtext, tr( "Remove" ), secondButton ) )
1067 { 1067 {
1068 case 0: // Try again or Enter 1068 case 0: // Try again or Enter
1069 // option 0 = Remove 1069 // option 0 = Remove
1070 newitem->option = "D"; 1070 newitem->option = "D";
1071 break; 1071 break;
1072 case 1: // Quit or Escape 1072 case 1: // Quit or Escape
1073 newitem->option = secondOption; 1073 newitem->option = secondOption;
1074 break; 1074 break;
1075 } 1075 }
1076 } 1076 }
1077 else 1077 else
1078 { 1078 {
1079// newitem->option = stickyOption; 1079// newitem->option = stickyOption;
1080 } 1080 }
1081 } 1081 }
1082 1082
1083 1083
1084 // Check if we are reinstalling the same version 1084 // Check if we are reinstalling the same version
1085 if ( newitem->option != "R" ) 1085 if ( newitem->option != "R" )
1086 newitem->recreateLinks = true; 1086 newitem->recreateLinks = true;
1087 else 1087 else
1088 newitem->recreateLinks = false; 1088 newitem->recreateLinks = false;
1089 1089
1090 // User hit cancel (on dlg - assume remove) 1090 // User hit cancel (on dlg - assume remove)
1091 return newitem; 1091 return newitem;
1092 } 1092 }
1093} 1093}
1094 1094
1095void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1095void MainWindow :: reloadData( InstallDlgImpl *dlg )
1096{ 1096{
1097 stack->raiseWidget( progressWindow ); 1097 stack->raiseWidget( progressWindow );
1098 1098
1099 if ( dlg ) 1099 if ( dlg )
1100 { 1100 {
1101 dlg->close(); 1101 dlg->close();
1102 delete dlg; 1102 delete dlg;
1103 } 1103 }
1104 1104
1105 mgr->reloadServerData(); 1105 mgr->reloadServerData();
1106 serverSelected( -1, FALSE ); 1106 serverSelected( -1, FALSE );
1107 1107
1108#ifdef QWS 1108#ifdef QWS
1109 m_status->setText( tr( "Updating Launcher..." ) ); 1109 m_status->setText( tr( "Updating Launcher..." ) );
1110 1110
1111 // Finally let the main system update itself 1111 // Finally let the main system update itself
1112 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1112 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1113 QString lf = QString::null; 1113 QString lf = QString::null;
1114 e << lf; 1114 e << lf;
1115#endif 1115#endif
1116 1116
1117 stack->raiseWidget( networkPkgWindow ); 1117 stack->raiseWidget( networkPkgWindow );
1118} 1118}
1119 1119
1120void MainWindow :: letterPushed( QString t ) 1120void MainWindow :: letterPushed( QString t )
1121{ 1121{
1122 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1122 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1123 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1123 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1124 if ( packagesList->firstChild() == 0 ) 1124 if ( packagesList->firstChild() == 0 )
1125 return; 1125 return;
1126 1126
1127 QCheckListItem *item; 1127 QCheckListItem *item;
1128 if ( start == 0 ) 1128 if ( start == 0 )
1129 { 1129 {
1130 item = (QCheckListItem *)packagesList->firstChild(); 1130 item = (QCheckListItem *)packagesList->firstChild();
1131 start = top; 1131 start = top;
1132 } 1132 }
1133 else 1133 else
1134 item = (QCheckListItem *)start->nextSibling(); 1134 item = (QCheckListItem *)start->nextSibling();
1135 1135
1136 if ( item == 0 ) 1136 if ( item == 0 )
1137 item = (QCheckListItem *)packagesList->firstChild(); 1137 item = (QCheckListItem *)packagesList->firstChild();
1138 do 1138 do
1139 { 1139 {
1140 if ( item->text().lower().startsWith( t.lower() ) ) 1140 if ( item->text().lower().startsWith( t.lower() ) )
1141 { 1141 {
1142 packagesList->setSelected( item, true ); 1142 packagesList->setSelected( item, true );
1143 packagesList->ensureItemVisible( item ); 1143 packagesList->ensureItemVisible( item );
1144 break; 1144 break;
1145 } 1145 }
1146 1146
1147 item = (QCheckListItem *)item->nextSibling(); 1147 item = (QCheckListItem *)item->nextSibling();
1148 if ( !item ) 1148 if ( !item )
1149 item = (QCheckListItem *)packagesList->firstChild(); 1149 item = (QCheckListItem *)packagesList->firstChild();
1150 } while ( item != start); 1150 } while ( item != start);
1151} 1151}
1152 1152
1153void MainWindow :: slotDisplayPackage( QListViewItem *item ) 1153void MainWindow :: slotDisplayPackage( QListViewItem *item )
1154{ 1154{
1155 QString itemstr( ((QCheckListItem*)item)->text() ); 1155 QString itemstr( ((QCheckListItem*)item)->text() );
1156 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); 1156 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) );
1157 p->showMaximized(); 1157 p->showMaximized();
1158} 1158}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 0295519..c4548b1 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,141 +1,141 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 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 MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23 23
24class DataManager; 24class DataManager;
25class InstallData; 25class InstallData;
26class InstallDlgImpl; 26class InstallDlgImpl;
27 27
28class QAction; 28class QAction;
29class QCheckListItem; 29class QCheckListItem;
30class QComboBox; 30class QComboBox;
31class QLabel; 31class QLabel;
32class QLineEdit; 32class QLineEdit;
33class QListView; 33class QListView;
34class QListViewItem; 34class QListViewItem;
35class QToolBar; 35class QToolBar;
36class QProgressBar; 36class QProgressBar;
37class QWidgetStack; 37class QWidgetStack;
38 38
39class MainWindow :public QMainWindow 39class MainWindow :public QMainWindow
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 43
44 MainWindow(); 44 MainWindow();
45 ~MainWindow(); 45 ~MainWindow();
46 46
47protected: 47protected:
48 void closeEvent( QCloseEvent* e ); 48 void closeEvent( QCloseEvent* e );
49 49
50private: 50private:
51 DataManager *mgr; 51 DataManager *mgr;
52 52
53 QWidgetStack *stack; 53 QWidgetStack *stack;
54 54
55 QToolBar *findBar; 55 QToolBar *findBar;
56 QToolBar *jumpBar; 56 QToolBar *jumpBar;
57 QLineEdit *findEdit; 57 QLineEdit *findEdit;
58 QAction *actionFindNext; 58 QAction *actionFindNext;
59 QAction *actionFilter; 59 QAction *actionFilter;
60 QAction *actionUpgrade; 60 QAction *actionUpgrade;
61 QAction *actionDownload; 61 QAction *actionDownload;
62 QAction *actionUninstalled; 62 QAction *actionUninstalled;
63 QAction *actionInstalled; 63 QAction *actionInstalled;
64 QAction *actionUpdated; 64 QAction *actionUpdated;
65 65
66 QPixmap iconDownload; 66 QPixmap iconDownload;
67 QPixmap iconRemove; 67 QPixmap iconRemove;
68 68
69 int mnuShowUninstalledPkgsId; 69 int mnuShowUninstalledPkgsId;
70 int mnuShowInstalledPkgsId; 70 int mnuShowInstalledPkgsId;
71 int mnuShowUpgradedPkgsId; 71 int mnuShowUpgradedPkgsId;
72 int mnuFilterByCategory; 72 int mnuFilterByCategory;
73 int mnuSetFilterCategory; 73 int mnuSetFilterCategory;
74 74
75 // Main package list widget 75 // Main package list widget
76 QWidget *networkPkgWindow; 76 QWidget *networkPkgWindow;
77 QComboBox *serversList; 77 QComboBox *serversList;
78 QListView *packagesList; 78 QListView *packagesList;
79 QPixmap installedIcon; 79 QPixmap installedIcon;
80 QPixmap updatedIcon; 80 QPixmap updatedIcon;
81 QString currentlySelectedServer; 81 QString currentlySelectedServer;
82 QString categoryFilter; 82 QString categoryFilter;
83 QString stickyOption; 83 QString stickyOption;
84 84
85 bool categoryFilterEnabled; 85 bool categoryFilterEnabled;
86 bool showJumpTo; 86 bool showJumpTo;
87 bool showUninstalledPkgs; 87 bool showUninstalledPkgs;
88 bool showInstalledPkgs; 88 bool showInstalledPkgs;
89 bool showUpgradedPkgs; 89 bool showUpgradedPkgs;
90 bool downloadEnabled; 90 bool downloadEnabled;
91 91
92 void initMainWidget(); 92 void initMainWidget();
93 void updateData(); 93 void updateData();
94 void serverSelected( int index, bool showProgress ); 94 void serverSelected( int index, bool showProgress );
95 void searchForPackage( const QString & ); 95 void searchForPackage( const QString & );
96 bool filterByCategory( bool val ); 96 bool filterByCategory( bool val );
97 void downloadSelectedPackages(); 97 void downloadSelectedPackages();
98 void downloadRemotePackage(); 98 void downloadRemotePackage();
99 InstallData *dealWithItem( QCheckListItem *item ); 99 InstallData *dealWithItem( QCheckListItem *item );
100 100
101 // Progress widget 101 // Progress widget
102 QWidget *progressWindow; 102 QWidget *progressWindow;
103 QLabel *m_status; 103 QLabel *m_status;
104 QProgressBar *m_progress; 104 QProgressBar *m_progress;
105 105
106 void initProgressWidget(); 106 void initProgressWidget();
107 107
108public slots: 108public slots:
109// void setDocument( const QString &doc ); 109 void setDocument( const QString &doc );
110 void displayFindBar(); 110 void displayFindBar();
111 void displayJumpBar(); 111 void displayJumpBar();
112 void repeatFind(); 112 void repeatFind();
113 void findPackage( const QString & ); 113 void findPackage( const QString & );
114 void hideFindBar(); 114 void hideFindBar();
115 void hideJumpBar(); 115 void hideJumpBar();
116 void displaySettings(); 116 void displaySettings();
117 void filterUninstalledPackages(); 117 void filterUninstalledPackages();
118 void filterInstalledPackages(); 118 void filterInstalledPackages();
119 void filterUpgradedPackages(); 119 void filterUpgradedPackages();
120 void filterCategory(); 120 void filterCategory();
121 bool setFilterCategory(); 121 bool setFilterCategory();
122 void raiseMainWidget(); 122 void raiseMainWidget();
123 void raiseProgressWidget(); 123 void raiseProgressWidget();
124 void enableUpgrade( bool ); 124 void enableUpgrade( bool );
125 void enableDownload( bool ); 125 void enableDownload( bool );
126 void reloadData( InstallDlgImpl * ); 126 void reloadData( InstallDlgImpl * );
127 127
128private slots: 128private slots:
129 void init(); 129 void init();
130 void setProgressSteps( int ); 130 void setProgressSteps( int );
131 void setProgressMessage( const QString & ); 131 void setProgressMessage( const QString & );
132 void updateProgress( int ); 132 void updateProgress( int );
133 void serverSelected( int index ); 133 void serverSelected( int index );
134 void updateServer(); 134 void updateServer();
135 void upgradePackages(); 135 void upgradePackages();
136 void downloadPackage(); 136 void downloadPackage();
137 void applyChanges(); 137 void applyChanges();
138 void letterPushed( QString t ); 138 void letterPushed( QString t );
139 void slotDisplayPackage( QListViewItem * ); 139 void slotDisplayPackage( QListViewItem * );
140}; 140};
141#endif 141#endif