-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.h | 3 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 12 |
4 files changed, 31 insertions, 9 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 @@ -439,101 +439,107 @@ void NetworkPackageManager :: applyChanges() 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; 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; + 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 @@ -10,70 +10,71 @@ * * * 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 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 @@ -61,106 +61,106 @@ void Server :: readStatusFile( vector<Destination> &destList ) { cleanUp(); vector<Destination>::iterator dit; bool rootRead = false; for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) { bool installingToRoot = false; QString path = dit->getDestinationPath(); if ( path.right( 1 ) != "/" ) path += "/"; if ( path == "/" ) { rootRead = true; installingToRoot = true; } packageFile = path + "usr/lib/ipkg/status"; readPackageFile( 0, false, installingToRoot, dit ); } // Ensure that the root status file is read if ( !rootRead ) { cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; packageFile = "/usr/lib/ipkg/status"; readPackageFile( 0, false, true ); } } void Server :: readLocalIpks( Server *local ) { cleanUp(); #ifdef QWS // First, get any local IPKGs in the documents area // Only applicable to Qtopie/Opie DocLnkSet files; Global::findDocuments( &files, "application/ipkg" ); // Now add the items to the list QListIterator<DocLnk> it( files.children() ); for ( ; it.current() ; ++it ) { - // OK, we have a local IPK file, I think the standard naming conventions - // for these are packagename_version_arm.ipk - QString file = (*it)->file(); + // OK, we have a local IPK file, I think the standard naming conventions + // for these are packagename_version_arm.ipk + QString file = (*it)->file(); QString packageName = Utils::getPackageNameFromIpkFilename( file ); QString ver = Utils::getPackageVersionFromIpkFilename( file ); packageList.push_back( Package( packageName ) ); - packageList.back().setVersion( ver ); - packageList.back().setFilename( file ); - packageList.back().setPackageStoredLocally( true ); + packageList.back().setVersion( ver ); + packageList.back().setFilename( file ); + packageList.back().setPackageStoredLocally( true ); } #else QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; for ( int i = 0 ; i < 4 ; ++i ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = names[i]; int p = file.find( "_" ); QString tmp = file.mid( 0, p ); packageList.push_back( Package( tmp ) ); int p2 = file.find( "_", p+1 ); tmp = file.mid( p+1, p2-(p+1) ); packageList.back().setVersion( tmp ); packageList.back().setPackageStoredLocally( true ); } #endif // build local packages buildLocalPackages( local ); } void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) { ifstream in( packageFile ); if ( !in.is_open() ) return; char line[1001]; char k[21]; char v[1001]; QString key; QString value; if ( clearAll ) cleanUp(); Package *currPackage = 0; bool newPackage = true; do { in.getline( line, 1000 ); if ( in.eof() ) continue; k[0] = '\0'; v[0] = '\0'; |