author | drw <drw> | 2003-02-06 01:19:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-02-06 01:19:25 (UTC) |
commit | 79588befde53765db0a92977c6890a4d226096e7 (patch) (side-by-side diff) | |
tree | 83b6dd14c49733b9759fad04147bf0bee50793fe /noncore/settings/aqpkg/server.cpp | |
parent | bbb3690f12191763a407e6a0edd521113b3c25ac (diff) | |
download | opie-79588befde53765db0a92977c6890a4d226096e7.zip opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2 |
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
Diffstat (limited to 'noncore/settings/aqpkg/server.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index fc5ed12..04f5ab7 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -46,54 +46,56 @@ Server :: Server( const char *name, const char *url ) serverUrl = url; packageFile = IPKG_DIR; active = true; packageFile += "lists/" + serverName; } Server :: ~Server() { cleanUp(); } void Server :: cleanUp() { packageList.clear(); } -void Server :: readStatusFile( vector<Destination> &destList ) +void Server :: readStatusFile( QList<Destination> &destList ) { cleanUp(); - vector<Destination>::iterator dit; + Destination *dest; + QListIterator<Destination> dit( destList ); bool rootRead = false; - for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) + for ( ; dit.current(); ++dit ) { + dest = dit.current(); bool installingToRoot = false; - QString path = dit->getDestinationPath(); + QString path = dest->getDestinationPath(); if ( path.right( 1 ) != "/" ) path += "/"; if ( path == "/" ) { rootRead = true; installingToRoot = true; } packageFile = path + "usr/lib/ipkg/status"; - readPackageFile( 0, false, installingToRoot, &( *dit ) ); + readPackageFile( 0, false, installingToRoot, &( *dest ) ); } // 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 @@ -102,38 +104,38 @@ void Server :: readLocalIpks( Server *local ) 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(); // Changed to display the filename (excluding the path) QString packageName = Utils::getFilenameFromIpkFilename( file ); QString ver = Utils::getPackageVersionFromIpkFilename( file ); - packageList.push_back( Package( packageName ) ); - packageList.back().setVersion( ver ); - packageList.back().setFilename( file ); - packageList.back().setPackageStoredLocally( true ); - - } + Package *package = new Package( packageName ); + package->setVersion( ver ); + package->setFilename( file ); + package->setPackageStoredLocally( true ); + packageList.append( package ); + } #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 @@ -167,36 +169,36 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR k[0] = '\0'; v[0] = '\0'; sscanf( line, "%[^:]: %[^\n]", k, v ); key = k; value = v; key = key.stripWhiteSpace(); value = value.stripWhiteSpace(); if ( key == "Package" && newPackage ) { newPackage = false; currPackage = getPackage( value ); if ( !currPackage ) { - packageList.push_back( Package( value ) ); - currPackage = &(packageList.back()); + Package *package = new Package( value ); + packageList.append( package ); + currPackage = package; currPackage->setInstalledTo( dest ); - if ( installingToRoot ) currPackage->setInstalledToRoot( true ); } else { if (currPackage->getStatus().find( "deinstall" ) != -1 ) currPackage->setInstalledTo( dest ); } } else if ( key == "Version" ) { if ( currPackage ) currPackage->setVersion( value ); } else if ( key == "Status" ) { @@ -226,82 +228,87 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR DataManager::setAvailableCategories( value ); } else if ( key == "" ) { newPackage = true; } } while ( !in.eof() ); in.close(); // build local packages buildLocalPackages( local ); } void Server :: buildLocalPackages( Server *local ) { - for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) + Package *curr; + QListIterator<Package> it( packageList ); + for ( ; it.current(); ++it ) { - QString name = packageList[i].getPackageName(); + curr = it.current(); + QString name = curr->getPackageName(); // If the package name is an ipk name, then convert the filename to a package name if ( name.find( ".ipk" ) != -1 ) - name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); + name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); if ( local ) { Package *p = local->getPackage( name ); - packageList[i].setLocalPackage( p ); + curr->setLocalPackage( p ); if ( p ) { // Set some default stuff like size and things - if ( p->getInstalledVersion() == packageList[i].getVersion() ) + if ( p->getInstalledVersion() == curr->getVersion() ) { - p->setPackageSize( packageList[i].getPackageSize() ); - p->setSection( packageList[i].getSection() ); - p->setDescription( packageList[i].getDescription() ); + p->setPackageSize( curr->getPackageSize() ); + p->setSection( curr->getSection() ); + p->setDescription( curr->getDescription() ); } } } else - packageList[i].setLocalPackage( 0 ); + curr->setLocalPackage( 0 ); } } Package *Server :: getPackage( QString &name ) { return getPackage( (const char *)name ); } Package *Server :: getPackage( const char *name ) { Package *ret = 0; - for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) + QListIterator<Package> it( packageList ); + for ( ; it.current(); ++it ) { - if ( packageList[i].getPackageName() == name ) - ret = &packageList[i]; - } + if ( it.current()->getPackageName() == name ) + ret = it.current(); + } return ret; } QString Server :: toString() { - QString ret = "Server\n name - " + serverName + - "\n url - " + serverUrl + - "\n"; - - for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) - ret += "\n " + packageList[i].toString(); + QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); + + QListIterator<Package> it( packageList ); + for ( ; it.current(); ++it ) + { + ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); + } return ret; } -vector<Package> &Server::getPackageList() +QList<Package> &Server::getPackageList() { return packageList; } |