Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 88 |
1 files changed, 61 insertions, 27 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 6f528a1..ed5bf75 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -201,12 +201,30 @@ void NetworkPackageManager :: serverSelected( int ) | |||
201 | // If a different version of package is available, postfix it with an * | 201 | // If a different version of package is available, postfix it with an * |
202 | if ( it->getVersion() != it->getInstalledVersion() ) | 202 | if ( it->getVersion() != it->getInstalledVersion() ) |
203 | text += "*"; | 203 | text += "*"; |
204 | } | 204 | } |
205 | 205 | ||
206 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 206 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
207 | |||
208 | if ( it->isInstalled() ) | ||
209 | { | ||
210 | QString destName = ""; | ||
211 | if ( it->getLocalPackage() ) | ||
212 | { | ||
213 | if ( it->getLocalPackage()->getInstalledTo() ) | ||
214 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | if ( it->getInstalledTo() ) | ||
219 | destName = it->getInstalledTo()->getDestinationName(); | ||
220 | } | ||
221 | if ( destName != "" ) | ||
222 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | ||
223 | } | ||
224 | |||
207 | if ( !it->isPackageStoredLocally() ) | 225 | if ( !it->isPackageStoredLocally() ) |
208 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 226 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
209 | else | 227 | else |
210 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 228 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
211 | 229 | ||
212 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 230 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
@@ -252,26 +270,19 @@ void NetworkPackageManager :: updateServer() | |||
252 | 270 | ||
253 | // Disable buttons to stop silly people clicking lots on them :) | 271 | // Disable buttons to stop silly people clicking lots on them :) |
254 | 272 | ||
255 | // First, write out ipkg_conf file so that ipkg can use it | 273 | // First, write out ipkg_conf file so that ipkg can use it |
256 | dataMgr->writeOutIpkgConf(); | 274 | dataMgr->writeOutIpkgConf(); |
257 | 275 | ||
258 | // if ( serverName == LOCAL_SERVER ) | 276 | QString option = "update"; |
259 | // ; | 277 | QString dummy = ""; |
260 | // else if ( serverName == LOCAL_IPKGS ) | 278 | Ipkg ipkg; |
261 | // ; | 279 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
262 | // else | 280 | ipkg.setOption( option ); |
263 | { | 281 | |
264 | QString option = "update"; | 282 | ipkg.runIpkg( ); |
265 | QString dummy = ""; | ||
266 | Ipkg ipkg; | ||
267 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | ||
268 | ipkg.setOption( option ); | ||
269 | |||
270 | ipkg.runIpkg( ); | ||
271 | } | ||
272 | 283 | ||
273 | // Reload data | 284 | // Reload data |
274 | dataMgr->reloadServerData( serversList->currentText() ); | 285 | dataMgr->reloadServerData( serversList->currentText() ); |
275 | serverSelected(-1); | 286 | serverSelected(-1); |
276 | delete dlg; | 287 | delete dlg; |
277 | } | 288 | } |
@@ -391,29 +402,29 @@ void NetworkPackageManager :: downloadPackage() | |||
391 | serverSelected( -1 ); | 402 | serverSelected( -1 ); |
392 | } | 403 | } |
393 | 404 | ||
394 | 405 | ||
395 | void NetworkPackageManager :: applyChanges() | 406 | void NetworkPackageManager :: applyChanges() |
396 | { | 407 | { |
397 | // Disable buttons to stop silly people clicking lots on them :) | 408 | stickyOption = ""; |
398 | 409 | ||
399 | // First, write out ipkg_conf file so that ipkg can use it | 410 | // First, write out ipkg_conf file so that ipkg can use it |
400 | dataMgr->writeOutIpkgConf(); | 411 | dataMgr->writeOutIpkgConf(); |
401 | 412 | ||
402 | // Now for each selected item | 413 | // Now for each selected item |
403 | // deal with it | 414 | // deal with it |
404 | 415 | ||
405 | vector<QString> workingPackages; | 416 | vector<InstallData> workingPackages; |
406 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 417 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
407 | item != 0 ; | 418 | item != 0 ; |
408 | item = (QCheckListItem *)item->nextSibling() ) | 419 | item = (QCheckListItem *)item->nextSibling() ) |
409 | { | 420 | { |
410 | if ( item->isOn() ) | 421 | if ( item->isOn() ) |
411 | { | 422 | { |
412 | QString p = dealWithItem( item ); | 423 | InstallData data = dealWithItem( item ); |
413 | workingPackages.push_back( p ); | 424 | workingPackages.push_back( data ); |
414 | } | 425 | } |
415 | } | 426 | } |
416 | 427 | ||
417 | // do the stuff | 428 | // do the stuff |
418 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 429 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
419 | dlg.showDlg(); | 430 | dlg.showDlg(); |
@@ -434,13 +445,13 @@ void NetworkPackageManager :: applyChanges() | |||
434 | 445 | ||
435 | // decide what to do - either remove, upgrade or install | 446 | // decide what to do - either remove, upgrade or install |
436 | // Current rules: | 447 | // Current rules: |
437 | // If not installed - install | 448 | // If not installed - install |
438 | // If installed and different version available - upgrade | 449 | // If installed and different version available - upgrade |
439 | // If installed and version up to date - remove | 450 | // If installed and version up to date - remove |
440 | QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 451 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
441 | { | 452 | { |
442 | QString name = item->text(); | 453 | QString name = item->text(); |
443 | int pos = name.find( "*" ); | 454 | int pos = name.find( "*" ); |
444 | name.truncate( pos ); | 455 | name.truncate( pos ); |
445 | 456 | ||
446 | // if (there is a (installed), remove it | 457 | // if (there is a (installed), remove it |
@@ -455,35 +466,58 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | |||
455 | // If the package has a filename then it is a local file | 466 | // If the package has a filename then it is a local file |
456 | if ( p->isPackageStoredLocally() ) | 467 | if ( p->isPackageStoredLocally() ) |
457 | name = p->getFilename(); | 468 | name = p->getFilename(); |
458 | QString option; | 469 | QString option; |
459 | QString dest = "root"; | 470 | QString dest = "root"; |
460 | if ( !p->isInstalled() ) | 471 | if ( !p->isInstalled() ) |
461 | return QString( "I" ) + name; | 472 | { |
473 | InstallData item; | ||
474 | item.option = "I"; | ||
475 | item.packageName = name; | ||
476 | return item; | ||
477 | } | ||
462 | else | 478 | else |
463 | { | 479 | { |
464 | if ( p->getVersion() == p->getInstalledVersion() ) | 480 | InstallData item; |
481 | item.option = "D"; | ||
482 | item.packageName = name; | ||
483 | if ( p->getInstalledTo() ) | ||
484 | item.destination = p->getInstalledTo(); | ||
485 | else | ||
486 | item.destination = p->getLocalPackage()->getInstalledTo(); | ||
487 | |||
488 | // Sticky option not implemented yet, but will eventually allow | ||
489 | // the user to say something like 'remove all' | ||
490 | if ( stickyOption == "" ) | ||
465 | { | 491 | { |
466 | QString msgtext; | 492 | QString msgtext; |
467 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); | 493 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); |
468 | switch( QMessageBox::information( this, "Remove or ReInstall", | 494 | switch( QMessageBox::information( this, "Remove or ReInstall", |
469 | msgtext, "Remove", "ReInstall" ) ) | 495 | msgtext, "Remove", "ReInstall" ) ) |
470 | { | 496 | { |
471 | case 0: // Try again or Enter | 497 | case 0: // Try again or Enter |
472 | return QString( "D" ) + name; | 498 | item.option = "D"; |
473 | break; | 499 | break; |
474 | case 1: // Quit or Escape | 500 | case 1: // Quit or Escape |
475 | return QString( "U" ) + name; | 501 | item.option = "U"; |
476 | break; | 502 | break; |
477 | } | 503 | } |
478 | |||
479 | // User hit cancel (on dlg - assume remove) | ||
480 | return QString( "D" ) + name; | ||
481 | } | 504 | } |
482 | else | 505 | else |
483 | return QString( "U" ) + name; | 506 | { |
507 | // item.option = stickyOption; | ||
508 | } | ||
509 | |||
510 | // Check if we are reinstalling the same version | ||
511 | if ( p->getVersion() != p->getInstalledVersion() ) | ||
512 | item.recreateLinks = true; | ||
513 | else | ||
514 | item.recreateLinks = false; | ||
515 | |||
516 | // User hit cancel (on dlg - assume remove) | ||
517 | return item; | ||
484 | } | 518 | } |
485 | } | 519 | } |
486 | 520 | ||
487 | void NetworkPackageManager :: displayText( const QString &t ) | 521 | void NetworkPackageManager :: displayText( const QString &t ) |
488 | { | 522 | { |
489 | cout << t << endl; | 523 | cout << t << endl; |