author | andyq <andyq> | 2002-11-02 09:09:41 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-02 09:09:41 (UTC) |
commit | f8538844857840a2cdefe8e3b0dfa90a30163ae1 (patch) (unidiff) | |
tree | 57ea5c6cbd9195a3808180f8b999d6cda991df5c | |
parent | bf9388acdebf6e55345dff3bd1cd652b45a2202a (diff) | |
download | opie-f8538844857840a2cdefe8e3b0dfa90a30163ae1.zip opie-f8538844857840a2cdefe8e3b0dfa90a30163ae1.tar.gz opie-f8538844857840a2cdefe8e3b0dfa90a30163ae1.tar.bz2 |
Fixed bug where package should be removed but gets reinstalled
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index b5d7352..3d06aef 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -490,162 +490,163 @@ void NetworkPackageManager :: applyChanges() | |||
490 | // Finally let the main system update itself | 490 | // Finally let the main system update itself |
491 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 491 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
492 | QString lf = QString::null; | 492 | QString lf = QString::null; |
493 | e << lf; | 493 | e << lf; |
494 | #endif | 494 | #endif |
495 | } | 495 | } |
496 | 496 | ||
497 | // decide what to do - either remove, upgrade or install | 497 | // decide what to do - either remove, upgrade or install |
498 | // Current rules: | 498 | // Current rules: |
499 | // If not installed - install | 499 | // If not installed - install |
500 | // If installed and different version available - upgrade | 500 | // If installed and different version available - upgrade |
501 | // If installed and version up to date - remove | 501 | // If installed and version up to date - remove |
502 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 502 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
503 | { | 503 | { |
504 | QString name = item->text(); | 504 | QString name = item->text(); |
505 | int pos = name.find( "*" ); | 505 | int pos = name.find( "*" ); |
506 | name.truncate( pos ); | 506 | name.truncate( pos ); |
507 | 507 | ||
508 | // if (there is a (installed), remove it | 508 | // if (there is a (installed), remove it |
509 | pos = name.find( "(installed)" ); | 509 | pos = name.find( "(installed)" ); |
510 | if ( pos > 0 ) | 510 | if ( pos > 0 ) |
511 | name.truncate( pos - 1 ); | 511 | name.truncate( pos - 1 ); |
512 | 512 | ||
513 | // Get package | 513 | // Get package |
514 | Server *s = dataMgr->getServer( serversList->currentText() ); | 514 | Server *s = dataMgr->getServer( serversList->currentText() ); |
515 | Package *p = s->getPackage( name ); | 515 | Package *p = s->getPackage( name ); |
516 | 516 | ||
517 | // If the package has a filename then it is a local file | 517 | // If the package has a filename then it is a local file |
518 | if ( p->isPackageStoredLocally() ) | 518 | if ( p->isPackageStoredLocally() ) |
519 | name = p->getFilename(); | 519 | name = p->getFilename(); |
520 | QString option; | 520 | QString option; |
521 | QString dest = "root"; | 521 | QString dest = "root"; |
522 | if ( !p->isInstalled() ) | 522 | if ( !p->isInstalled() ) |
523 | { | 523 | { |
524 | InstallData item; | 524 | InstallData item; |
525 | item.option = "I"; | 525 | item.option = "I"; |
526 | item.packageName = name; | 526 | item.packageName = name; |
527 | return item; | 527 | return item; |
528 | } | 528 | } |
529 | else | 529 | else |
530 | { | 530 | { |
531 | InstallData item; | 531 | InstallData item; |
532 | item.option = "D"; | 532 | item.option = "D"; |
533 | item.packageName = p->getInstalledPackageName(); | 533 | item.packageName = p->getInstalledPackageName(); |
534 | if ( p->getInstalledTo() ) | 534 | if ( p->getInstalledTo() ) |
535 | { | 535 | { |
536 | item.destination = p->getInstalledTo(); | 536 | item.destination = p->getInstalledTo(); |
537 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 537 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
538 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 538 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
539 | } | 539 | } |
540 | else | 540 | else |
541 | { | 541 | { |
542 | item.destination = p->getLocalPackage()->getInstalledTo(); | 542 | item.destination = p->getLocalPackage()->getInstalledTo(); |
543 | } | 543 | } |
544 | 544 | ||
545 | // Now see if version is newer or not | 545 | // Now see if version is newer or not |
546 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 546 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
547 | if ( val == -2 ) | 547 | if ( val == -2 ) |
548 | { | 548 | { |
549 | // Error - should handle | 549 | // Error - should handle |
550 | } | 550 | } |
551 | else if ( val == -1 ) | 551 | else if ( val == -1 ) |
552 | { | 552 | { |
553 | // Version available is older - remove only | 553 | // Version available is older - remove only |
554 | item.option = "R"; | 554 | item.option = "D"; |
555 | } | 555 | } |
556 | else | 556 | else |
557 | { | 557 | { |
558 | QString caption; | 558 | QString caption; |
559 | QString text; | 559 | QString text; |
560 | QString secondButton; | 560 | QString secondButton; |
561 | QString secondOption; | 561 | QString secondOption; |
562 | if ( val == 0 ) | 562 | if ( val == 0 ) |
563 | { | 563 | { |
564 | // Version available is the same - option to remove or reinstall | 564 | // Version available is the same - option to remove or reinstall |
565 | caption = "Do you wish to remove or reinstall\n%s?"; | 565 | caption = "Do you wish to remove or reinstall\n%s?"; |
566 | text = "Remove or ReInstall"; | 566 | text = "Remove or ReInstall"; |
567 | secondButton = "ReInstall"; | 567 | secondButton = "ReInstall"; |
568 | secondOption = "R"; | 568 | secondOption = "R"; |
569 | } | 569 | } |
570 | else if ( val == 1 ) | 570 | else if ( val == 1 ) |
571 | { | 571 | { |
572 | // Version available is newer - option to remove or upgrade | 572 | // Version available is newer - option to remove or upgrade |
573 | caption = "Do you wish to remove or upgrade\n%s?"; | 573 | caption = "Do you wish to remove or upgrade\n%s?"; |
574 | text = "Remove or Upgrade"; | 574 | text = "Remove or Upgrade"; |
575 | secondButton = "Upgrade"; | 575 | secondButton = "Upgrade"; |
576 | secondOption = "U"; | 576 | secondOption = "U"; |
577 | } | 577 | } |
578 | 578 | ||
579 | // Sticky option not implemented yet, but will eventually allow | 579 | // Sticky option not implemented yet, but will eventually allow |
580 | // the user to say something like 'remove all' | 580 | // the user to say something like 'remove all' |
581 | if ( stickyOption == "" ) | 581 | if ( stickyOption == "" ) |
582 | { | 582 | { |
583 | QString msgtext; | 583 | QString msgtext; |
584 | msgtext.sprintf( caption, (const char *)name ); | 584 | msgtext.sprintf( caption, (const char *)name ); |
585 | switch( QMessageBox::information( this, text, | 585 | switch( QMessageBox::information( this, text, |
586 | msgtext, "Remove", secondButton ) ) | 586 | msgtext, "Remove", secondButton ) ) |
587 | { | 587 | { |
588 | case 0: // Try again or Enter | 588 | case 0: // Try again or Enter |
589 | // option 0 = Remove | ||
589 | item.option = "D"; | 590 | item.option = "D"; |
590 | break; | 591 | break; |
591 | case 1: // Quit or Escape | 592 | case 1: // Quit or Escape |
592 | item.option = secondOption; | 593 | item.option = secondOption; |
593 | break; | 594 | break; |
594 | } | 595 | } |
595 | } | 596 | } |
596 | else | 597 | else |
597 | { | 598 | { |
598 | // item.option = stickyOption; | 599 | // item.option = stickyOption; |
599 | } | 600 | } |
600 | } | 601 | } |
601 | 602 | ||
602 | 603 | ||
603 | // Check if we are reinstalling the same version | 604 | // Check if we are reinstalling the same version |
604 | if ( item.option != "R" ) | 605 | if ( item.option != "R" ) |
605 | item.recreateLinks = true; | 606 | item.recreateLinks = true; |
606 | else | 607 | else |
607 | item.recreateLinks = false; | 608 | item.recreateLinks = false; |
608 | 609 | ||
609 | // User hit cancel (on dlg - assume remove) | 610 | // User hit cancel (on dlg - assume remove) |
610 | return item; | 611 | return item; |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | void NetworkPackageManager :: displayText( const QString &t ) | 615 | void NetworkPackageManager :: displayText( const QString &t ) |
615 | { | 616 | { |
616 | cout << t << endl; | 617 | cout << t << endl; |
617 | } | 618 | } |
618 | 619 | ||
619 | 620 | ||
620 | void NetworkPackageManager :: letterPushed( QString t ) | 621 | void NetworkPackageManager :: letterPushed( QString t ) |
621 | { | 622 | { |
622 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 623 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
623 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 624 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
624 | if ( packagesList->firstChild() == 0 ) | 625 | if ( packagesList->firstChild() == 0 ) |
625 | return; | 626 | return; |
626 | 627 | ||
627 | QCheckListItem *item; | 628 | QCheckListItem *item; |
628 | if ( start == 0 ) | 629 | if ( start == 0 ) |
629 | { | 630 | { |
630 | item = (QCheckListItem *)packagesList->firstChild(); | 631 | item = (QCheckListItem *)packagesList->firstChild(); |
631 | start = top; | 632 | start = top; |
632 | } | 633 | } |
633 | else | 634 | else |
634 | item = (QCheckListItem *)start->nextSibling(); | 635 | item = (QCheckListItem *)start->nextSibling(); |
635 | 636 | ||
636 | if ( item == 0 ) | 637 | if ( item == 0 ) |
637 | item = (QCheckListItem *)packagesList->firstChild(); | 638 | item = (QCheckListItem *)packagesList->firstChild(); |
638 | do | 639 | do |
639 | { | 640 | { |
640 | if ( item->text().lower().startsWith( t.lower() ) ) | 641 | if ( item->text().lower().startsWith( t.lower() ) ) |
641 | { | 642 | { |
642 | packagesList->setSelected( item, true ); | 643 | packagesList->setSelected( item, true ); |
643 | packagesList->ensureItemVisible( item ); | 644 | packagesList->ensureItemVisible( item ); |
644 | break; | 645 | break; |
645 | } | 646 | } |
646 | 647 | ||
647 | item = (QCheckListItem *)item->nextSibling(); | 648 | item = (QCheckListItem *)item->nextSibling(); |
648 | if ( !item ) | 649 | if ( !item ) |
649 | item = (QCheckListItem *)packagesList->firstChild(); | 650 | item = (QCheckListItem *)packagesList->firstChild(); |
650 | } while ( item != start); | 651 | } while ( item != start); |
651 | } | 652 | } |