author | andyq <andyq> | 2002-10-25 18:58:30 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-25 18:58:30 (UTC) |
commit | 835fadbad01b725a46ffd68ca458fd39c7313ea0 (patch) (side-by-side diff) | |
tree | 4fbc213e01292e4e850ad561c387f75098e2b059 /noncore/settings/aqpkg/networkpkgmgr.cpp | |
parent | 1d3135677f1f49b9cc87ebf01f1c4eaab3c450f4 (diff) | |
download | opie-835fadbad01b725a46ffd68ca458fd39c7313ea0.zip opie-835fadbad01b725a46ffd68ca458fd39c7313ea0.tar.gz opie-835fadbad01b725a46ffd68ca458fd39c7313ea0.tar.bz2 |
Added version handling
Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 3971aea..02e4e73 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -34,24 +34,26 @@ using namespace std; #include <qfile.h> #include <qmessagebox.h> #include "datamgr.h" #include "networkpkgmgr.h" #include "installdlgimpl.h" #include "ipkg.h" #include "inputdlg.h" #include "letterpushbutton.h" #include "global.h" +extern int compareVersions( const char *v1, const char *v2 ); + NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) { dataMgr = dataManager; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif @@ -223,25 +225,28 @@ void NetworkPackageManager :: serverSelected( int ) // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !it->isInstalled() ) continue; text += it->getPackageName(); if ( it->isInstalled() ) { text += " (installed)"; // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) - text += "*"; + { + if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) + text += "*"; + } } QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); if ( it->isInstalled() ) { QString destName = ""; if ( it->getLocalPackage() ) { if ( it->getLocalPackage()->getInstalledTo() ) destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); } @@ -524,55 +529,87 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 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(); } - // Sticky option not implemented yet, but will eventually allow - // the user to say something like 'remove all' - if ( stickyOption == "" ) + // Now see if version is newer or not + int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); + if ( val == -2 ) { - QString msgtext; - msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); - switch( QMessageBox::information( this, "Remove or ReInstall", - msgtext, "Remove", "ReInstall" ) ) - { - case 0: // Try again or Enter - item.option = "D"; - break; - case 1: // Quit or Escape - item.option = "U"; - break; - } + // Error - should handle + } + else if ( val == -1 ) + { + // Version available is older - remove only + item.option = "R"; } else { -// item.option = stickyOption; + 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 + 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 ( p->getVersion() != p->getInstalledVersion() ) + if ( item.option != "R" ) item.recreateLinks = true; else - { - if ( item.option == "U" ) - item.option = "R"; item.recreateLinks = false; - } // User hit cancel (on dlg - assume remove) return item; } } void NetworkPackageManager :: displayText( const QString &t ) { cout << t << endl; } |