author | andyq <andyq> | 2002-11-21 18:11:40 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-21 18:11:40 (UTC) |
commit | 5e806f161bc0bde64d5058dab4850c45aeba2cdf (patch) (side-by-side diff) | |
tree | e93f10fe052da154b1cfe42bdbf5f29ef8749bc4 | |
parent | 5b0e9483f45967da95dc05d770197c631b959070 (diff) | |
download | opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.zip opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.tar.gz opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.tar.bz2 |
Fixed bug where installed and local ipkg servers weren't shown (hopefully)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 0814121..cf94628 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -1,288 +1,289 @@ /*************************************************************************** networkpkgmgr.cpp - description ------------------- begin : Mon Aug 26 13:32:30 BST 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 <fstream> #include <iostream> using namespace std; #include <unistd.h> #include <stdlib.h> #include <linux/limits.h> #ifdef QWS #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #else #include <qapplication.h> #endif #include <qlabel.h> #include <qfile.h> #include <qmessagebox.h> #include "datamgr.h" #include "networkpkgmgr.h" #include "installdlgimpl.h" #include "ipkg.h" #include "inputdlg.h" #include "letterpushbutton.h" #include "categoryfilterimpl.h" #include "global.h" extern int compareVersions( const char *v1, const char *v2 ); NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) { dataMgr = dataManager; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif showUninstalledPkgs = false; showInstalledPkgs = false; showUpgradedPkgs = false; categoryFilterEnabled = false; initGui(); setupConnections(); updateData(); } NetworkPackageManager::~NetworkPackageManager() { } void NetworkPackageManager :: timerEvent ( QTimerEvent * ) { killTimer( timerId ); // Add server names to listbox updateData(); } void NetworkPackageManager :: updateData() { serversList->clear(); packagesList->clear(); vector<Server>::iterator it; int activeItem = -1; int i; for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) { + cout << "Adding " << it->getServerName() << " to combobox" << endl; if ( !it->isServerActive() ) { i--; continue; } serversList->insertItem( it->getServerName() ); if ( it->getServerName() == currentlySelectedServer ) activeItem = i; } // set selected server to be active server if ( activeItem != -1 ) serversList->setCurrentItem( activeItem ); serverSelected( 0 ); } void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) { // First select local server for ( int i = 0 ; i < serversList->count() ; ++i ) { if ( serversList->text( i ) == LOCAL_IPKGS ) { serversList->setCurrentItem( i ); break; } } serverSelected( 0 ); // Now set the check box of the selected package for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().startsWith( pkg ) ) { item->setOn( true ); break; } } } void NetworkPackageManager :: initGui() { QLabel *l = new QLabel( "Servers", this ); serversList = new QComboBox( this ); packagesList = new QListView( this ); update = new QPushButton( "Refresh Lists", this ); download = new QPushButton( "Download", this ); upgrade = new QPushButton( "Upgrade", this ); apply = new QPushButton( "Apply", this ); QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); if ( showJumpTo ) { char text[2]; text[1] = '\0'; for ( int i = 0 ; i < 26 ; ++i ) { text[0] = 'A' + i; LetterPushButton *b = new LetterPushButton( text, this ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); if ( i < 13 ) hbox3->addWidget( b ); else hbox4->addWidget( b ); } } vbox->addWidget( packagesList ); packagesList->addColumn( "Packages" ); QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); hbox2->addWidget( update ); hbox2->addWidget( download ); hbox2->addWidget( upgrade ); hbox2->addWidget( apply ); } void NetworkPackageManager :: setupConnections() { connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); } void NetworkPackageManager :: showProgressDialog( char *initialText ) { if ( !progressDlg ) progressDlg = new ProgressDlg( this, "Progress", false ); progressDlg->setText( initialText ); progressDlg->show(); } void NetworkPackageManager :: serverSelected( int ) { packagesList->clear(); // display packages QString serverName = serversList->currentText(); currentlySelectedServer = serverName; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif Server *s = dataMgr->getServer( serverName ); vector<Package> &list = s->getPackageList(); vector<Package>::iterator it; for ( it = list.begin() ; it != list.end() ; ++it ) { QString text = ""; // Apply show only uninstalled packages filter if ( showUninstalledPkgs && it->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !it->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !it->isInstalled() || compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) continue; } // Apply the section filter if ( categoryFilterEnabled && categoryFilter != "" ) { if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) continue; } // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !it->isInstalled() ) continue; text += it->getPackageName(); if ( it->isInstalled() ) { text += " (installed)"; // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) { if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) text += "*"; } } 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() ) diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 726cf00..58407d5 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -1,239 +1,240 @@ /*************************************************************************** server.cpp - description ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk description : This class holds details about a server : e.g. all the packages that contained on the server : the installation status ***************************************************************************/ /*************************************************************************** * * * 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 <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <fstream> using namespace std; #include "server.h" #include "datamgr.h" #ifdef QWS #include <qpe/global.h> #include <qpe/applnk.h> #include <qlist.h> #endif #include "utils.h" #include "global.h" Server :: Server( const char *name, const char *url ) { serverName = name; serverUrl = url; packageFile = IPKG_DIR; + active = true; packageFile += "lists/" + serverName; } Server :: ~Server() { cleanUp(); } void Server :: cleanUp() { packageList.clear(); } 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(); // 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 ); } #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'; 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()); 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" ) { if ( currPackage ) currPackage->setStatus( value ); } else if ( key == "Description" ) { if ( currPackage ) currPackage->setDescription( value ); } else if ( key == "Filename" ) { if ( currPackage ) currPackage->setFilename( value ); } else if ( key == "Size" ) { if ( currPackage ) currPackage->setPackageSize( value ); } else if ( key == "Section" ) { if ( currPackage ) currPackage->setSection( value ); DataManager::setAvailableCategories( value ); } else if ( key == "" ) { newPackage = true; } } while ( !in.eof() ); in.close(); // build local packages buildLocalPackages( local ); } void Server :: buildLocalPackages( Server *local ) |