summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp34
-rw-r--r--noncore/settings/aqpkg/datamgr.h2
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp32
3 files changed, 36 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 089c3e3..f342aff 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -122,52 +122,52 @@ void DataManager :: loadServers()
122 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 122 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
123 Destination d( alias, path ); 123 Destination d( alias, path );
124 bool linkToRoot = true; 124 bool linkToRoot = true;
125#ifdef QWS 125#ifdef QWS
126 QString key = alias; 126 QString key = alias;
127 key += "_linkToRoot"; 127 key += "_linkToRoot";
128 linkToRoot = cfg.readBoolEntry( key, true ); 128 linkToRoot = cfg.readBoolEntry( key, true );
129#endif 129#endif
130 d.linkToRoot( linkToRoot ); 130 d.linkToRoot( linkToRoot );
131 131
132 destList.push_back( d ); 132 destList.push_back( d );
133 } 133 }
134 } 134 }
135 } 135 }
136 fclose( fp ); 136 fclose( fp );
137 137
138 vector<Server>::iterator it; 138 reloadServerData( );
139 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
140 reloadServerData( it->getServerName() );
141} 139}
142 140
143void DataManager :: reloadServerData( const char *serverName ) 141void DataManager :: reloadServerData( )
144{ 142{
145 Server *s = getServer( serverName ); 143 vector<Server>::iterator it = serverList.begin();
146 // Now we've read the config file in we need to read the servers 144 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
147 // The local server is a special case. This holds the contents of the 145 {
148 // status files the number of which depends on how many destinations 146 // Now we've read the config file in we need to read the servers
149 // we've set up 147 // The local server is a special case. This holds the contents of the
150 // The other servers files hold the contents of the server package list 148 // status files the number of which depends on how many destinations
151 if ( s->getServerName() == LOCAL_SERVER ) 149 // we've set up
152 s->readStatusFile( destList ); 150 // The other servers files hold the contents of the server package list
153 else if ( s->getServerName() == LOCAL_IPKGS ) 151 if ( it->getServerName() == LOCAL_SERVER )
154 s->readLocalIpks( getServer( LOCAL_SERVER ) ); 152 it->readStatusFile( destList );
155 else 153 else if ( it->getServerName() == LOCAL_IPKGS )
156 s->readPackageFile( getServer( LOCAL_SERVER ) ); 154 it->readLocalIpks( getServer( LOCAL_SERVER ) );
157 155 else
156 it->readPackageFile( getServer( LOCAL_SERVER ) );
157 }
158} 158}
159 159
160void DataManager :: writeOutIpkgConf() 160void DataManager :: writeOutIpkgConf()
161{ 161{
162 QString ipkg_conf = IPKG_CONF; 162 QString ipkg_conf = IPKG_CONF;
163 ofstream out( ipkg_conf ); 163 ofstream out( ipkg_conf );
164 164
165 out << "# Written by AQPkg" << endl; 165 out << "# Written by AQPkg" << endl;
166 out << "# Must have one or more source entries of the form:" << endl; 166 out << "# Must have one or more source entries of the form:" << endl;
167 out << "#" << endl; 167 out << "#" << endl;
168 out << "# src <src-name> <source-url>" << endl; 168 out << "# src <src-name> <source-url>" << endl;
169 out << "#" << endl; 169 out << "#" << endl;
170 out << "# and one or more destination entries of the form:" << endl; 170 out << "# and one or more destination entries of the form:" << endl;
171 out << "#" << endl; 171 out << "#" << endl;
172 out << "# dest <dest-name> <target-path>" << endl; 172 out << "# dest <dest-name> <target-path>" << endl;
173 out << "#" << endl; 173 out << "#" << endl;
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index eb802b5..8c6fb0d 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -36,29 +36,29 @@ class DataManager
36{ 36{
37public: 37public:
38 DataManager(); 38 DataManager();
39 ~DataManager(); 39 ~DataManager();
40 40
41 void setActiveServer( const QString &act ) { activeServer = act; } 41 void setActiveServer( const QString &act ) { activeServer = act; }
42 QString &getActiveServer( ) { return activeServer; } 42 QString &getActiveServer( ) { return activeServer; }
43 43
44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); } 44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); }
45 vector<Server> &getServerList() { return serverList; } 45 vector<Server> &getServerList() { return serverList; }
46 Server *getServer( const char *name ); 46 Server *getServer( const char *name );
47 47
48 vector<Destination> &getDestinationList() { return destList; } 48 vector<Destination> &getDestinationList() { return destList; }
49 Destination *getDestination( const char *name ); 49 Destination *getDestination( const char *name );
50 50
51 void loadServers(); 51 void loadServers();
52 void reloadServerData( const char *sn ); 52 void reloadServerData( );
53 53
54 void writeOutIpkgConf(); 54 void writeOutIpkgConf();
55 55
56 56
57private: 57private:
58 QString activeServer; 58 QString activeServer;
59 59
60 vector<Server> serverList; 60 vector<Server> serverList;
61 vector<Destination> destList; 61 vector<Destination> destList;
62}; 62};
63 63
64#endif 64#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 02e4e73..b5d7352 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -202,86 +202,94 @@ void NetworkPackageManager :: showProgressDialog( char *initialText )
202void NetworkPackageManager :: serverSelected( int ) 202void NetworkPackageManager :: serverSelected( int )
203{ 203{
204 packagesList->clear(); 204 packagesList->clear();
205 205
206 // display packages 206 // display packages
207 QString serverName = serversList->currentText(); 207 QString serverName = serversList->currentText();
208 currentlySelectedServer = serverName; 208 currentlySelectedServer = serverName;
209 209
210#ifdef QWS 210#ifdef QWS
211 // read download directory from config file 211 // read download directory from config file
212 Config cfg( "aqpkg" ); 212 Config cfg( "aqpkg" );
213 cfg.setGroup( "settings" ); 213 cfg.setGroup( "settings" );
214 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 214 cfg.writeEntry( "selectedServer", currentlySelectedServer );
215#endif 215#endif
216 216
217 Server *s = dataMgr->getServer( serverName ); 217 Server *s = dataMgr->getServer( serverName );
218// dataMgr->setActiveServer( serverName );
219 218
220 vector<Package> &list = s->getPackageList(); 219 vector<Package> &list = s->getPackageList();
221 vector<Package>::iterator it; 220 vector<Package>::iterator it;
222 for ( it = list.begin() ; it != list.end() ; ++it ) 221 for ( it = list.begin() ; it != list.end() ; ++it )
223 { 222 {
223
224 QString text = ""; 224 QString text = "";
225 225
226 // If the local server, only display installed packages 226 // If the local server, only display installed packages
227 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 227 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
228 continue; 228 continue;
229 229
230 text += it->getPackageName(); 230 text += it->getPackageName();
231 if ( it->isInstalled() ) 231 if ( it->isInstalled() )
232 { 232 {
233 text += " (installed)"; 233 text += " (installed)";
234 234
235 // If a different version of package is available, postfix it with an * 235 // If a different version of package is available, postfix it with an *
236 if ( it->getVersion() != it->getInstalledVersion() ) 236 if ( it->getVersion() != it->getInstalledVersion() )
237 { 237 {
238
238 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 239 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
239 text += "*"; 240 text += "*";
240 } 241 }
241 } 242 }
242 243
243 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 244 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
244 245
245 if ( it->isInstalled() ) 246 if ( it->isInstalled() )
246 { 247 {
247 QString destName = ""; 248 QString destName = "";
248 if ( it->getLocalPackage() ) 249 if ( it->getLocalPackage() )
249 { 250 {
250 if ( it->getLocalPackage()->getInstalledTo() ) 251 if ( it->getLocalPackage()->getInstalledTo() )
251 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 252 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
252 } 253 }
253 else 254 else
254 { 255 {
255 if ( it->getInstalledTo() ) 256 if ( it->getInstalledTo() )
256 destName = it->getInstalledTo()->getDestinationName(); 257 destName = it->getInstalledTo()->getDestinationName();
257 } 258 }
258 if ( destName != "" ) 259 if ( destName != "" )
259 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 260 new QCheckListItem( item, QString( "Installed To - " ) + destName );
260 } 261 }
261 262
262 if ( !it->isPackageStoredLocally() ) 263 if ( !it->isPackageStoredLocally() )
263 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 264 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
264 else 265 else
265 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 266 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
266 267
267 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 268 if ( serverName == LOCAL_SERVER )
268 if ( it->getLocalPackage() ) 269 {
269 { 270 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
270 if ( it->isInstalled() ) 271 }
271 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 272 else
273 {
274 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
275 if ( it->getLocalPackage() )
276 {
277 if ( it->isInstalled() )
278 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
279 }
272 } 280 }
273 packagesList->insertItem( item ); 281 packagesList->insertItem( item );
274 } 282 }
275 283
276 // If the local server or the local ipkgs server disable the download button 284 // If the local server or the local ipkgs server disable the download button
277 if ( serverName == LOCAL_SERVER ) 285 if ( serverName == LOCAL_SERVER )
278 { 286 {
279 upgrade->setEnabled( false ); 287 upgrade->setEnabled( false );
280 download->setText( "Download" ); 288 download->setText( "Download" );
281 download->setEnabled( false ); 289 download->setEnabled( false );
282 } 290 }
283 else if ( serverName == LOCAL_IPKGS ) 291 else if ( serverName == LOCAL_IPKGS )
284 { 292 {
285 upgrade->setEnabled( false ); 293 upgrade->setEnabled( false );
286 download->setEnabled( true ); 294 download->setEnabled( true );
287 download->setText( "Remove" ); 295 download->setText( "Remove" );
@@ -304,64 +312,62 @@ void NetworkPackageManager :: updateServer()
304// QString status = "Updating package lists..."; 312// QString status = "Updating package lists...";
305// progDlg->show(); 313// progDlg->show();
306// progDlg->setText( status ); 314// progDlg->setText( status );
307 315
308 // Disable buttons to stop silly people clicking lots on them :) 316 // Disable buttons to stop silly people clicking lots on them :)
309 317
310 // First, write out ipkg_conf file so that ipkg can use it 318 // First, write out ipkg_conf file so that ipkg can use it
311 dataMgr->writeOutIpkgConf(); 319 dataMgr->writeOutIpkgConf();
312 320
313 Ipkg ipkg; 321 Ipkg ipkg;
314 ipkg.setOption( "update" ); 322 ipkg.setOption( "update" );
315 323
316 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 324 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
317 dlg.showDlg(); 325 dlg.showDlg();
318 326
319 // Reload data 327 // Reload data
320 dataMgr->reloadServerData( serversList->currentText() ); 328 dataMgr->reloadServerData();
321 serverSelected(-1); 329 serverSelected(-1);
322// delete progDlg; 330// delete progDlg;
323} 331}
324 332
325void NetworkPackageManager :: upgradePackages() 333void NetworkPackageManager :: upgradePackages()
326{ 334{
327 // We're gonna do an upgrade of all packages 335 // We're gonna do an upgrade of all packages
328 // First warn user that this isn't recommended 336 // First warn user that this isn't recommended
329 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 337 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
330 QMessageBox warn("Warning", text, QMessageBox::Warning, 338 QMessageBox warn("Warning", text, QMessageBox::Warning,
331 QMessageBox::Yes, 339 QMessageBox::Yes,
332 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 340 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
333 0, this ); 341 0, this );
334 warn.adjustSize(); 342 warn.adjustSize();
335 343
336 if ( warn.exec() == QMessageBox::Yes ) 344 if ( warn.exec() == QMessageBox::Yes )
337 { 345 {
338 // First, write out ipkg_conf file so that ipkg can use it 346 // First, write out ipkg_conf file so that ipkg can use it
339 dataMgr->writeOutIpkgConf(); 347 dataMgr->writeOutIpkgConf();
340 348
341 // Now run upgrade 349 // Now run upgrade
342 Ipkg ipkg; 350 Ipkg ipkg;
343 ipkg.setOption( "upgrade" ); 351 ipkg.setOption( "upgrade" );
344 352
345 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 353 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
346 dlg.showDlg(); 354 dlg.showDlg();
347 355
348 // Reload data 356 // Reload data
349 dataMgr->reloadServerData( LOCAL_SERVER ); 357 dataMgr->reloadServerData();
350
351 dataMgr->reloadServerData( serversList->currentText() );
352 serverSelected(-1); 358 serverSelected(-1);
353 } 359 }
354} 360}
355 361
356 362
357void NetworkPackageManager :: downloadPackage() 363void NetworkPackageManager :: downloadPackage()
358{ 364{
359 if ( download->text() == "Download" ) 365 if ( download->text() == "Download" )
360 { 366 {
361 // First, write out ipkg_conf file so that ipkg can use it 367 // First, write out ipkg_conf file so that ipkg can use it
362 dataMgr->writeOutIpkgConf(); 368 dataMgr->writeOutIpkgConf();
363 369
364 // Display dialog to user asking where to download the files to 370 // Display dialog to user asking where to download the files to
365 bool ok = FALSE; 371 bool ok = FALSE;
366 QString dir = ""; 372 QString dir = "";
367#ifdef QWS 373#ifdef QWS
@@ -423,33 +429,33 @@ void NetworkPackageManager :: downloadPackage()
423 QString name = item->text(); 429 QString name = item->text();
424 int pos = name.find( "*" ); 430 int pos = name.find( "*" );
425 name.truncate( pos ); 431 name.truncate( pos );
426 432
427 // if (there is a (installed), remove it 433 // if (there is a (installed), remove it
428 pos = name.find( "(installed)" ); 434 pos = name.find( "(installed)" );
429 if ( pos > 0 ) 435 if ( pos > 0 )
430 name.truncate( pos - 1 ); 436 name.truncate( pos - 1 );
431 437
432 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 438 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
433 QFile f( p->getFilename() ); 439 QFile f( p->getFilename() );
434 f.remove(); 440 f.remove();
435 } 441 }
436 } 442 }
437 } 443 }
438 444
439 dataMgr->reloadServerData( LOCAL_IPKGS ); 445 dataMgr->reloadServerData();
440 serverSelected( -1 ); 446 serverSelected( -1 );
441} 447}
442 448
443 449
444void NetworkPackageManager :: applyChanges() 450void NetworkPackageManager :: applyChanges()
445{ 451{
446 stickyOption = ""; 452 stickyOption = "";
447 453
448 // First, write out ipkg_conf file so that ipkg can use it 454 // First, write out ipkg_conf file so that ipkg can use it
449 dataMgr->writeOutIpkgConf(); 455 dataMgr->writeOutIpkgConf();
450 456
451 // Now for each selected item 457 // Now for each selected item
452 // deal with it 458 // deal with it
453 459
454 vector<InstallData> workingPackages; 460 vector<InstallData> workingPackages;
455 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 461 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
@@ -464,35 +470,33 @@ void NetworkPackageManager :: applyChanges()
464 } 470 }
465 471
466 if ( workingPackages.size() == 0 ) 472 if ( workingPackages.size() == 0 )
467 { 473 {
468 // Nothing to do 474 // Nothing to do
469 QMessageBox::information( this, "Nothing to do", 475 QMessageBox::information( this, "Nothing to do",
470 "No packages selected", "OK" ); 476 "No packages selected", "OK" );
471 477
472 return; 478 return;
473 } 479 }
474 480
475 // do the stuff 481 // do the stuff
476 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 482 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
477 dlg.showDlg(); 483 dlg.showDlg();
478 484
479 // Reload data 485 // Reload data
480 dataMgr->reloadServerData( LOCAL_SERVER ); 486 dataMgr->reloadServerData();
481
482 dataMgr->reloadServerData( serversList->currentText() );
483 serverSelected(-1); 487 serverSelected(-1);
484 488
485#ifdef QWS 489#ifdef QWS
486 // Finally let the main system update itself 490 // Finally let the main system update itself
487 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 491 QCopEnvelope e("QPE/System", "linkChanged(QString)");
488 QString lf = QString::null; 492 QString lf = QString::null;
489 e << lf; 493 e << lf;
490#endif 494#endif
491} 495}
492 496
493// decide what to do - either remove, upgrade or install 497// decide what to do - either remove, upgrade or install
494// Current rules: 498// Current rules:
495// If not installed - install 499// If not installed - install
496// If installed and different version available - upgrade 500// If installed and different version available - upgrade
497// If installed and version up to date - remove 501// If installed and version up to date - remove
498InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 502InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )