author | andyq <andyq> | 2002-11-02 09:09:41 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-02 09:09:41 (UTC) |
commit | f8538844857840a2cdefe8e3b0dfa90a30163ae1 (patch) (side-by-side diff) | |
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 @@ -426,226 +426,227 @@ void NetworkPackageManager :: downloadPackage() { if ( item->isOn() ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); // if (there is a (installed), remove it pos = name.find( "(installed)" ); if ( pos > 0 ) name.truncate( pos - 1 ); Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); QFile f( p->getFilename() ); f.remove(); } } } dataMgr->reloadServerData(); serverSelected( -1 ); } void NetworkPackageManager :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); // Now for each selected item // deal with it vector<InstallData> workingPackages; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { InstallData data = dealWithItem( item ); workingPackages.push_back( data ); } } if ( workingPackages.size() == 0 ) { // Nothing to do QMessageBox::information( this, "Nothing to do", "No packages selected", "OK" ); return; } // do the stuff InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); dlg.showDlg(); // Reload data dataMgr->reloadServerData(); serverSelected(-1); #ifdef QWS // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; #endif } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); // if (there is a (installed), remove it pos = name.find( "(installed)" ); if ( pos > 0 ) name.truncate( pos - 1 ); // Get package Server *s = dataMgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData item; item.option = "I"; item.packageName = name; return item; } else { InstallData item; item.option = "D"; item.packageName = p->getInstalledPackageName(); if ( p->getInstalledTo() ) { item.destination = p->getInstalledTo(); cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; } else { item.destination = p->getLocalPackage()->getInstalledTo(); } // Now see if version is newer or not int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); if ( val == -2 ) { // Error - should handle } else if ( val == -1 ) { // Version available is older - remove only - item.option = "R"; + item.option = "D"; } else { QString caption; QString text; QString secondButton; QString secondOption; if ( val == 0 ) { // Version available is the same - option to remove or reinstall caption = "Do you wish to remove or reinstall\n%s?"; text = "Remove or ReInstall"; secondButton = "ReInstall"; secondOption = "R"; } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = "Do you wish to remove or upgrade\n%s?"; text = "Remove or Upgrade"; secondButton = "Upgrade"; secondOption = "U"; } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext.sprintf( caption, (const char *)name ); switch( QMessageBox::information( this, text, msgtext, "Remove", secondButton ) ) { case 0: // Try again or Enter + // option 0 = Remove item.option = "D"; break; case 1: // Quit or Escape item.option = secondOption; break; } } else { // item.option = stickyOption; } } // Check if we are reinstalling the same version if ( item.option != "R" ) item.recreateLinks = true; else item.recreateLinks = false; // User hit cancel (on dlg - assume remove) return item; } } void NetworkPackageManager :: displayText( const QString &t ) { cout << t << endl; } void NetworkPackageManager :: letterPushed( QString t ) { QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( packagesList->firstChild() == 0 ) return; QCheckListItem *item; if ( start == 0 ) { item = (QCheckListItem *)packagesList->firstChild(); start = top; } else item = (QCheckListItem *)start->nextSibling(); if ( item == 0 ) item = (QCheckListItem *)packagesList->firstChild(); do { if ( item->text().lower().startsWith( t.lower() ) ) { packagesList->setSelected( item, true ); packagesList->ensureItemVisible( item ); break; } item = (QCheckListItem *)item->nextSibling(); if ( !item ) item = (QCheckListItem *)packagesList->firstChild(); } while ( item != start); } |