author | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
commit | cd48ed3935f1baa6392afee5764d0927abcf62cc (patch) (side-by-side diff) | |
tree | 54423b7242c59457ded23ce0dd1e89ce05b630b1 | |
parent | 4ce3fb5c10a50aece4ef8a78d07ed116ad754c27 (diff) | |
download | opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.zip opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.gz opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.bz2 |
Changed so that installings/removing and upgrading from/to multiple destinations
works better
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 67 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 17 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 4 |
5 files changed, 136 insertions, 63 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index b92a245..bbb0be75 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -34,3 +34,3 @@ -InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) +InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : InstallDlg( parent, name, modal, fl ) @@ -48,3 +48,4 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM // Grab flags - Turn MAKE_LINKS on by default (if no flags found) - flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); +// flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); + flags = 0; #else @@ -72,3 +73,3 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM - vector<QString>::iterator it; + vector<InstallData>::iterator it; // setup package data @@ -79,17 +80,17 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM { - QString name = *it; - if ( name.startsWith( "I" ) ) + InstallData item = *it; + if ( item.option == "I" ) { - installList.push_back( name.mid(1) ); - install += " " + name.mid(1) + "\n"; + installList.push_back( item ); + install += " " + item.packageName + "\n"; } - else if ( name.startsWith( "D" ) ) + else if ( item.option == "D" ) { - removeList.push_back( name.mid(1) ); - remove += " " + name.mid(1) + "\n"; + removeList.push_back( item ); + remove += " " + item.packageName + "\n"; } - else if ( name.startsWith( "U" ) ) + else if ( item.option == "U" ) { - updateList.push_back( name.mid(1) ); - upgrade += " " + name.mid(1) + "\n"; + updateList.push_back( item ); + upgrade += " " + item.packageName + "\n"; } @@ -138,4 +139,2 @@ void InstallDlgImpl :: optionsSelected() flags |= FORCE_OVERWRITE; - if ( opt.makeLinks->isChecked() ) - flags |= MAKE_LINKS; @@ -173,2 +172,5 @@ void InstallDlgImpl :: installSelected() QString destDir = d->getDestinationPath(); + int instFlags = 0; + if ( d->linkToRoot() ) + instFlags = MAKE_LINKS; @@ -182,10 +184,17 @@ void InstallDlgImpl :: installSelected() // First run through the remove list, then the install list then the upgrade list - vector<QString>::iterator it; + vector<InstallData>::iterator it; ipkg.setOption( "remove" ); - ipkg.setDestination( dest ); - ipkg.setDestinationDir( destDir ); - ipkg.setFlags( flags ); for ( it = removeList.begin() ; it != removeList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setDestination( it->destination->getDestinationName() ); + ipkg.setDestinationDir( it->destination->getDestinationPath() ); + ipkg.setPackage( it->packageName ); + + int tmpFlags = flags; + if ( it->destination->linkToRoot() ) + tmpFlags |= MAKE_LINKS; + else + tmpFlags ^= MAKE_LINKS; + + ipkg.setFlags( tmpFlags ); ipkg.runIpkg(); @@ -194,5 +203,8 @@ void InstallDlgImpl :: installSelected() ipkg.setOption( "install" ); + ipkg.setDestination( dest ); + ipkg.setDestinationDir( destDir ); + ipkg.setFlags( instFlags ); for ( it = installList.begin() ; it != installList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setPackage( it->packageName ); ipkg.runIpkg(); @@ -201,6 +213,15 @@ void InstallDlgImpl :: installSelected() flags |= FORCE_REINSTALL; - ipkg.setFlags( flags ); + ipkg.setOption( "reinstall" ); for ( it = updateList.begin() ; it != updateList.end() ; ++it ) { - ipkg.setPackage( *it ); + ipkg.setDestination( it->destination->getDestinationName() ); + ipkg.setDestinationDir( it->destination->getDestinationPath() ); + ipkg.setPackage( it->packageName ); + + int tmpFlags = flags; + if ( it->destination->linkToRoot() && it->recreateLinks ) + tmpFlags |= MAKE_LINKS; + else + tmpFlags ^= MAKE_LINKS; + ipkg.setFlags( tmpFlags ); ipkg.runIpkg(); diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 8b05c52..3a5d8b8 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -27,2 +27,11 @@ using namespace std; +class InstallData +{ +public: + QString option; // I - install, D - delete, U - upgrade + QString packageName; + Destination *destination; + bool recreateLinks; +}; + class InstallDlgImpl : public InstallDlg @@ -30,3 +39,3 @@ class InstallDlgImpl : public InstallDlg public: - InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); InstallDlgImpl( QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); @@ -41,5 +50,5 @@ private: DataManager *dataMgr; - vector<QString> installList; - vector<QString> removeList; - vector<QString> updateList; + vector<InstallData> installList; + vector<InstallData> removeList; + vector<InstallData> updateList; int flags; diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 6d0edad..02d4258 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -43,3 +43,3 @@ Ipkg :: ~Ipkg() -// Option is what we are going to do - install, upgrade, download +// Option is what we are going to do - install, upgrade, download, reinstall // package is the package name to install - either a fully qualified path and ipk @@ -91,3 +91,2 @@ bool Ipkg :: runIpkg( ) } - } @@ -99,3 +98,7 @@ bool Ipkg :: runIpkg( ) - cmd += " " + option; + + if ( option == "reinstall" ) + cmd += " install"; + else + cmd += " " + option; if ( option != "upgrade" ) @@ -104,2 +107,5 @@ bool Ipkg :: runIpkg( ) + + emit outputText( QString( "Dealing with package " ) + package ); + qApp->processEvents(); @@ -108,3 +114,3 @@ bool Ipkg :: runIpkg( ) // create the links - if ( option == "remove" ) + if ( option == "remove" || option == "reinstall" ) { @@ -127,3 +133,3 @@ bool Ipkg :: runIpkg( ) - if ( option == "install" ) + if ( option == "install" || option == "reinstall" ) { @@ -155,2 +161,3 @@ bool Ipkg :: runIpkg( ) emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") ); + emit outputText( "" ); return ret; @@ -184,3 +191,3 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) //See if we're finished - if ( option == "install" ) + if ( option == "install" || option == "reinstall" ) { @@ -244,3 +251,3 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des - cout << "Try to open " << packageFileDir.latin1() << endl; + cout << "Try to open " << packageFileDir << endl; if ( !f.open(IO_ReadOnly) ) @@ -248,3 +255,3 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des // Couldn't open from dest, try from / -// cout << "Could not open:" << packageFileDir << endl; + cout << "Could not open:" << packageFileDir << endl; f.close(); 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 @@ -206,2 +206,20 @@ void NetworkPackageManager :: serverSelected( int ) 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(); + } + else + { + if ( it->getInstalledTo() ) + destName = it->getInstalledTo()->getDestinationName(); + } + if ( destName != "" ) + new QCheckListItem( item, QString( "Installed To - " ) + destName ); + } + if ( !it->isPackageStoredLocally() ) @@ -257,16 +275,9 @@ void NetworkPackageManager :: updateServer() -// if ( serverName == LOCAL_SERVER ) -// ; -// else if ( serverName == LOCAL_IPKGS ) -// ; -// else - { - QString option = "update"; - QString dummy = ""; - Ipkg ipkg; - connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); - ipkg.setOption( option ); - - ipkg.runIpkg( ); - } + QString option = "update"; + QString dummy = ""; + Ipkg ipkg; + connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); + ipkg.setOption( option ); + + ipkg.runIpkg( ); @@ -396,3 +407,3 @@ void NetworkPackageManager :: applyChanges() { - // Disable buttons to stop silly people clicking lots on them :) + stickyOption = ""; @@ -404,3 +415,3 @@ void NetworkPackageManager :: applyChanges() - vector<QString> workingPackages; + vector<InstallData> workingPackages; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); @@ -411,4 +422,4 @@ void NetworkPackageManager :: applyChanges() { - QString p = dealWithItem( item ); - workingPackages.push_back( p ); + InstallData data = dealWithItem( item ); + workingPackages.push_back( data ); } @@ -439,3 +450,3 @@ void NetworkPackageManager :: applyChanges() // If installed and version up to date - remove -QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) +InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) { @@ -460,6 +471,21 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) if ( !p->isInstalled() ) - return QString( "I" ) + name; + { + InstallData item; + item.option = "I"; + item.packageName = name; + return item; + } else { - if ( p->getVersion() == p->getInstalledVersion() ) + InstallData item; + item.option = "D"; + item.packageName = name; + if ( p->getInstalledTo() ) + item.destination = p->getInstalledTo(); + 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 == "" ) { @@ -471,14 +497,22 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) case 0: // Try again or Enter - return QString( "D" ) + name; + item.option = "D"; break; case 1: // Quit or Escape - return QString( "U" ) + name; + item.option = "U"; break; } - - // User hit cancel (on dlg - assume remove) - return QString( "D" ) + name; } else - return QString( "U" ) + name; + { +// item.option = stickyOption; + } + + // Check if we are reinstalling the same version + if ( p->getVersion() != p->getInstalledVersion() ) + item.recreateLinks = true; + else + item.recreateLinks = false; + + // User hit cancel (on dlg - assume remove) + return item; } diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 0ae64a6..7efa42c 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -28,2 +28,3 @@ #include "progressdlg.h" +class InstallData; @@ -61,3 +62,4 @@ private: void showProgressDialog( char *initialText ); - QString dealWithItem( QCheckListItem *item ); + InstallData dealWithItem( QCheckListItem *item ); + QString stickyOption; |