summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-17 22:58:36 (UTC)
committer andyq <andyq>2002-10-17 22:58:36 (UTC)
commitcd48ed3935f1baa6392afee5764d0927abcf62cc (patch) (side-by-side diff)
tree54423b7242c59457ded23ce0dd1e89ce05b630b1
parent4ce3fb5c10a50aece4ef8a78d07ed116ad754c27 (diff)
downloadopie-cd48ed3935f1baa6392afee5764d0927abcf62cc.zip
opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.gz
opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.bz2
Changed so that installings/removing and upgrading from/to multiple destinations
works better
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp67
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h17
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp21
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp74
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h4
5 files changed, 128 insertions, 55 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
@@ -33,5 +33,5 @@
#include "global.h"
-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 )
{
@@ -47,5 +47,6 @@ 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
flags = 0;
@@ -71,5 +72,5 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM
destination->setCurrentItem( defIndex );
- vector<QString>::iterator it;
+ vector<InstallData>::iterator it;
// setup package data
QString remove = "Remove\n";
@@ -78,19 +79,19 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM
for ( it = packageList.begin() ; it != packageList.end() ; ++it )
{
- 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";
}
}
@@ -137,6 +138,4 @@ void InstallDlgImpl :: optionsSelected()
if ( opt.forceOverwrite->isChecked() )
flags |= FORCE_OVERWRITE;
- if ( opt.makeLinks->isChecked() )
- flags |= MAKE_LINKS;
#ifdef QWS
@@ -172,4 +171,7 @@ void InstallDlgImpl :: installSelected()
QString dest = d->getDestinationName();
QString destDir = d->getDestinationPath();
+ int instFlags = 0;
+ if ( d->linkToRoot() )
+ instFlags = MAKE_LINKS;
#ifdef QWS
@@ -181,27 +183,46 @@ 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();
}
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();
}
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
@@ -26,8 +26,17 @@ using namespace std;
#include "install.h"
+class InstallData
+{
+public:
+ QString option; // I - install, D - delete, U - upgrade
+ QString packageName;
+ Destination *destination;
+ bool recreateLinks;
+};
+
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 );
~InstallDlgImpl();
@@ -40,7 +49,7 @@ protected:
private:
DataManager *dataMgr;
- vector<QString> installList;
- vector<QString> removeList;
- vector<QString> updateList;
+ vector<InstallData> installList;
+ vector<InstallData> removeList;
+ vector<InstallData> updateList;
int flags;
Ipkg ipkg;
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
@@ -42,5 +42,5 @@ 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
// file (if stored locally) or just the name of the package (for a network package)
@@ -90,5 +90,4 @@ bool Ipkg :: runIpkg( )
flags ^= MAKE_LINKS;
}
-
}
@@ -98,4 +97,8 @@ bool Ipkg :: runIpkg( )
#endif
+
+ if ( option == "reinstall" )
+ cmd += " install";
+ else
cmd += " " + option;
if ( option != "upgrade" )
@@ -103,9 +106,12 @@ bool Ipkg :: runIpkg( )
cmd += " 2>&1";
+
+ emit outputText( QString( "Dealing with package " ) + package );
+
qApp->processEvents();
// If we are removing packages and make links option is selected
// create the links
- if ( option == "remove" )
+ if ( option == "remove" || option == "reinstall" )
{
createLinks = false;
@@ -126,5 +132,5 @@ bool Ipkg :: runIpkg( )
ret = executeIpkgCommand( cmd, option );
- if ( option == "install" )
+ if ( option == "install" || option == "reinstall" )
{
// If we are not removing packages and make links option is selected
@@ -154,4 +160,5 @@ bool Ipkg :: runIpkg( )
emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
+ emit outputText( "" );
return ret;
}
@@ -183,5 +190,5 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
{
//See if we're finished
- if ( option == "install" )
+ if ( option == "install" || option == "reinstall" )
{
// Need to keep track of any dependant packages that get installed
@@ -243,9 +250,9 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des
QFile f( packageFileDir );
- cout << "Try to open " << packageFileDir.latin1() << endl;
+ cout << "Try to open " << packageFileDir << endl;
if ( !f.open(IO_ReadOnly) )
{
// 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
@@ -205,4 +205,22 @@ 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() )
new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
@@ -256,10 +274,4 @@ void NetworkPackageManager :: updateServer()
dataMgr->writeOutIpkgConf();
-// if ( serverName == LOCAL_SERVER )
-// ;
-// else if ( serverName == LOCAL_IPKGS )
-// ;
-// else
- {
QString option = "update";
QString dummy = "";
@@ -269,5 +281,4 @@ void NetworkPackageManager :: updateServer()
ipkg.runIpkg( );
- }
// Reload data
@@ -395,5 +406,5 @@ void NetworkPackageManager :: downloadPackage()
void NetworkPackageManager :: applyChanges()
{
- // Disable buttons to stop silly people clicking lots on them :)
+ stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
@@ -403,5 +414,5 @@ void NetworkPackageManager :: applyChanges()
// deal with it
- vector<QString> workingPackages;
+ vector<InstallData> workingPackages;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
@@ -410,6 +421,6 @@ void NetworkPackageManager :: applyChanges()
if ( item->isOn() )
{
- QString p = dealWithItem( item );
- workingPackages.push_back( p );
+ InstallData data = dealWithItem( item );
+ workingPackages.push_back( data );
}
}
@@ -438,5 +449,5 @@ void NetworkPackageManager :: applyChanges()
// If installed and different version available - upgrade
// If installed and version up to date - remove
-QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
+InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
@@ -459,8 +470,23 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
QString dest = "root";
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 == "" )
{
QString msgtext;
@@ -470,16 +496,24 @@ 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
@@ -27,4 +27,5 @@
#include "datamgr.h"
#include "progressdlg.h"
+class InstallData;
/** NetworkPackageManager is the base class of the project */
@@ -60,5 +61,6 @@ private:
void setupConnections();
void showProgressDialog( char *initialText );
- QString dealWithItem( QCheckListItem *item );
+ InstallData dealWithItem( QCheckListItem *item );
+ QString stickyOption;
public slots: