-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 15 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 0 |
4 files changed, 23 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 3aee7bd..d84fb4b 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -391,173 +391,179 @@ void NetworkPackageManager :: downloadPackage() 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( LOCAL_IPKGS ); 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 ); } } // do the stuff InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); dlg.showDlg(); // Reload data dataMgr->reloadServerData( LOCAL_SERVER ); dataMgr->reloadServerData( serversList->currentText() ); 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 = name; + 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 == "" ) { 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; } } else { // 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; } } 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); } diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index 48b6934..fd75450 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp @@ -1,109 +1,124 @@ /*************************************************************************** package.cpp - description ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "package.h" #include "global.h" Package::Package( QString &name ) { packageName = name; localPackage = 0; installed = false; packageStoredLocally = false; installedToRoot = false; + installed = false; + installedTo = 0; } Package::Package( char *name ) { packageName = name; localPackage = 0; + installed = false; + packageStoredLocally = false; + installedToRoot = false; + installed = false; + installedTo = 0; } Package::~Package() { } QString Package :: toString() { QString ret = "Package - " + getPackageName() + "\n version - " + getVersion(); if ( localPackage ) ret += "\n inst version - " + localPackage->getVersion(); return ret; } void Package :: setStatus( QString &s ) { status = s; if ( status.find( "installed" ) != -1 ) installed = true; } void Package :: setLocalPackage( Package *p ) { localPackage = p; if ( localPackage ) if ( localPackage->getVersion() != getVersion() ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setVersion( QString &v ) { version = v; if ( localPackage ) if ( localPackage->getVersion() != getVersion() ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setPackageName( QString &name ) { packageName = name; } void Package :: setDescription( QString &d ) { description = d; } void Package :: setFilename( QString &f ) { filename = f; } QString Package :: getInstalledVersion() { if ( localPackage ) return localPackage->getVersion(); else return getVersion(); } +QString Package :: getInstalledPackageName() +{ + if ( localPackage ) + return localPackage->getPackageName(); + else + return getPackageName(); +} + bool Package :: isInstalled() { return installed || ( localPackage && localPackage->isInstalled() ); } diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h index 8ba5a6a..2f2a165 100644 --- a/noncore/settings/aqpkg/package.h +++ b/noncore/settings/aqpkg/package.h @@ -1,79 +1,80 @@ /*************************************************************************** package.h - description ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef PACKAGE_H #define PACKAGE_H #include <stdlib.h> /** *@author Andy Qua */ #include <qstring.h> #include "destination.h" class Package { public: Package( QString &name ); Package( char *name ); ~Package(); void setLocalPackage( Package *p ); void setPackageName( QString &name ); void setVersion( QString &v ); void setStatus( QString &s ); void setDescription( QString &d ); void setFilename( QString &f ); void setPackageStoredLocally( bool local ) { packageStoredLocally = local; } void setInstalledToRoot( bool root ) { installedToRoot = root; } void setInstalledTo( Destination *d ) { installedTo = d; } Package *getLocalPackage() { return localPackage; } QString getPackageName() { return packageName; } QString getVersion() { return version; } QString getStatus() { return status; } QString getDescription() { return description; } QString getFilename() { return filename; } bool isInstalled(); bool isPackageStoredLocally() { return packageStoredLocally; } bool isInstalledToRoot() { return installedToRoot; } QString getInstalledVersion(); + QString getInstalledPackageName(); Destination *getInstalledTo() { return installedTo; } QString toString(); private: Package *localPackage; QString packageName; QString version; QString status; QString description; QString filename; bool packageStoredLocally; bool installedToRoot; bool installed; bool differentVersionAvailable; Destination *installedTo; }; #endif diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 7d103a2..8bca892 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp |