-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/global.h | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/letterpushbutton.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 23 |
10 files changed, 37 insertions, 41 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index e7fb75a..96c28c0 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp @@ -26,60 +26,58 @@ using namespace std; #include "datamgr.h" #include "global.h" QString DataManager::availableCategories = ""; DataManager::DataManager() { activeServer = ""; availableCategories = "#"; } DataManager::~DataManager() { } -Server *DataManager :: getServer( const char *name ) +vector<Server>::iterator DataManager :: getServer( const char *name ) { - Server *s = 0; - vector<Server>::iterator it = serverList.begin(); - while ( it != serverList.end() && s == 0 ) + vector<Server>::iterator it = serverList.begin(); + while ( it != serverList.end() ) { if ( it->getServerName() == name ) - s = &(*it); + return it; ++it; } - return s; + return serverList.end(); } -Destination *DataManager :: getDestination( const char *name ) +vector<Destination>::iterator DataManager :: getDestination( const char *name ) { - Destination *d = 0; vector<Destination>::iterator it = destList.begin(); - while ( it != destList.end() && d == 0 ) + while ( it != destList.end() ) { if ( it->getDestinationName() == name ) - d = &(*it); + return it; ++it; } - return d; + return destList.end(); } void DataManager :: loadServers() { // First add our local server - not really a server but // the local config (which packages are installed) serverList.push_back( Server( LOCAL_SERVER, "" ) ); serverList.push_back( Server( LOCAL_IPKGS, "" ) ); #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "destinations" ); #endif // Read file from /etc/ipkg.conf QString ipkg_conf = IPKG_CONF; @@ -137,56 +135,51 @@ void DataManager :: loadServers() char type[20]; char val[100]; sscanf( lineStr, "%*[^ ] %s %s", type, val ); if ( stricmp( type, "http_proxy" ) == 0 ) httpProxy = val; if ( stricmp( type, "ftp_proxy" ) == 0 ) ftpProxy = val; if ( stricmp( type, "proxy_username" ) == 0 ) proxyUsername = val; if ( stricmp( type, "proxy_password" ) == 0 ) proxyPassword = val; } } } fclose( fp ); - cout << "httpProxy = " << httpProxy << endl; - cout << "ftpProxy = " << ftpProxy << endl; - cout << "proxyUsername = " << proxyUsername << endl; - cout << "proxyPassword = " << proxyPassword << endl; - reloadServerData( ); } void DataManager :: reloadServerData( ) { vector<Server>::iterator it = serverList.begin(); for ( it = serverList.begin() ; it != serverList.end() ; ++it ) { // Now we've read the config file in we need to read the servers // The local server is a special case. This holds the contents of the // status files the number of which depends on how many destinations // we've set up // The other servers files hold the contents of the server package list if ( it->getServerName() == LOCAL_SERVER ) it->readStatusFile( destList ); else if ( it->getServerName() == LOCAL_IPKGS ) - it->readLocalIpks( getServer( LOCAL_SERVER ) ); + it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); else - it->readPackageFile( getServer( LOCAL_SERVER ) ); + it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); } } void DataManager :: writeOutIpkgConf() { QString ipkg_conf = IPKG_CONF; ofstream out( ipkg_conf ); out << "# Written by AQPkg" << endl; out << "# Must have one or more source entries of the form:" << endl; out << "#" << endl; out << "# src <src-name> <source-url>" << endl; out << "#" << endl; out << "# and one or more destination entries of the form:" << endl; out << "#" << endl; out << "# dest <dest-name> <target-path>" << endl; diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 14b0b2f..41833df 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h @@ -25,43 +25,43 @@ using namespace std; #include "server.h" #include "destination.h" #define LOCAL_SERVER "Installed Pkgs" #define LOCAL_IPKGS "local IPKG" /** *@author Andy Qua */ class DataManager { public: DataManager(); - ~DataManager(); + ~DataManager(); void setActiveServer( const QString &act ) { activeServer = act; } QString &getActiveServer( ) { return activeServer; } - Server *getLocalServer() { return getServer( LOCAL_SERVER ); } + Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } vector<Server> &getServerList() { return serverList; } - Server *getServer( const char *name ); + vector<Server>::iterator getServer( const char *name ); vector<Destination> &getDestinationList() { return destList; } - Destination *getDestination( const char *name ); + vector<Destination>::iterator getDestination( const char *name ); void loadServers(); void reloadServerData( ); void writeOutIpkgConf(); static QString getAvailableCategories() { return availableCategories; } static void setAvailableCategories( QString section ); private: static QString availableCategories; QString activeServer; QString httpProxy; QString ftpProxy; QString proxyUsername; QString proxyPassword; diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index fcec643..ddfb3ac 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h @@ -5,33 +5,33 @@ 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 __GLOBAL_H #define __GLOBAL_H -#define VERSION_TEXT "AQPkg Version 1.3" +#define VERSION_TEXT "AQPkg Version 1.4" // Uncomment the below line to run on a Linux box rather than a Zaurus // box this allows you to change where root is, and where to load config files from // #define X86 // Sets up location of ipkg.conf and root directory #ifdef QWS #ifndef X86 // Running QT/Embedded on an arm processor #define IPKG_CONF "/etc/ipkg.conf" #define ROOT "/" #define IPKG_DIR "/usr/lib/ipkg/" #else diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index b297437..db9a259 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -152,33 +152,33 @@ void InstallDlgImpl :: installSelected() done( 1 ); return; } btnInstall->setEnabled( false ); if ( pIpkg ) { output->setText( "" ); connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); pIpkg->runIpkg(); } else { output->setText( "" ); - Destination *d = dataMgr->getDestination( destination->currentText() ); + vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); int instFlags = flags; if ( d->linkToRoot() ) instFlags |= MAKE_LINKS; #ifdef QWS // Save settings Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "dest", dest ); #endif pIpkg = new Ipkg; connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 452eca3..8de3c48 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -3,32 +3,33 @@ ------------------- begin : Sat Aug 31 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 <stdio.h> #include <unistd.h> #ifdef QWS #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <qdir.h> #include <qtextstream.h> #include "utils.h" #include "ipkg.h" #include "global.h" diff --git a/noncore/settings/aqpkg/letterpushbutton.cpp b/noncore/settings/aqpkg/letterpushbutton.cpp index afe25d8..ca96c6c 100644 --- a/noncore/settings/aqpkg/letterpushbutton.cpp +++ b/noncore/settings/aqpkg/letterpushbutton.cpp @@ -4,31 +4,31 @@ begin : Wed Oct 16 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 "letterpushbutton.h" -LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name=0 ) +LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name ) : QPushButton( text, parent, name ) { connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) ); } LetterPushButton :: ~LetterPushButton() { } void LetterPushButton :: released_emmitor() { emit released( text() ); } diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0141359..3ddc582 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -3,32 +3,33 @@ ------------------- 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 <iostream> +using namespace std; #include <qmenubar.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include "mainwin.h" #include "datamgr.h" #include "networkpkgmgr.h" #include "settingsimpl.h" #include "helpwindow.h" #include "utils.h" #include "global.h" MainWindow :: MainWindow( QWidget *p, char *name ) : QMainWindow( p, name ) { @@ -38,33 +39,33 @@ MainWindow :: MainWindow( QWidget *p, char *name ) setCaption( "AQPkg - Package Manager" ); // Create our menu help = new QPopupMenu( this ); help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); settings = new QPopupMenu( this ); settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); edit = new QPopupMenu( this ); edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); filter = new QPopupMenu( this ); - mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); + mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); filter->insertSeparator(); mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); // Create the main menu menu = menuBar(); //new QMenuBar( this ); menu->insertItem( "&Settings", settings ); menu->insertItem( "&Edit", edit ); menu->insertItem( "&Filter", filter ); menu->insertItem( "&Help", help ); mgr = new DataManager(); mgr->loadServers(); @@ -193,17 +194,17 @@ void MainWindow :: setFilterCategory() if ( networkPkgWindow->setFilterCategory( ) ) filter->setItemChecked( mnuFilterByCategory, true ); } void MainWindow :: filterCategory() { if ( filter->isItemChecked( mnuFilterByCategory ) ) { networkPkgWindow->filterByCategory( false ); filter->setItemChecked( mnuFilterByCategory, false ); } else { if ( networkPkgWindow->filterByCategory( true ) ) filter->setItemChecked( mnuFilterByCategory, true ); } -}
\ No newline at end of file +} diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index d9e62b6..79a380e 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -204,33 +204,33 @@ void NetworkPackageManager :: showProgressDialog( char *initialText ) 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<Server>::iterator 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; @@ -599,33 +599,33 @@ void NetworkPackageManager :: applyChanges() // 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() ); + vector<Server>::iterator 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 diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 58407d5..2cb0533 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -67,33 +67,33 @@ void Server :: readStatusFile( vector<Destination> &destList ) 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 ); + 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 diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index a18a178..9dd2206 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp @@ -3,32 +3,33 @@ ------------------- begin : Thu Aug 29 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 <algorithm> using namespace std; #include <qlistbox.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qtabwidget.h> #include <qcheckbox.h> #ifdef QWS #include <qpe/config.h> #endif #include "settingsimpl.h" #include "global.h" @@ -78,64 +79,64 @@ void SettingsImpl :: setupData() destinations->insertItem( it2->getDestinationName() ); #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); #else jumpTo->setChecked( true ); #endif } //------------------ Servers tab ---------------------- void SettingsImpl :: editServer( int sel ) { currentSelectedServer = sel; - Server *s = dataMgr->getServer( servers->currentText() ); + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); serverName = s->getServerName(); servername->setText( s->getServerName() ); serverurl->setText( s->getServerUrl() ); active->setChecked( s->isServerActive() ); } void SettingsImpl :: newServer() { newserver = true; servername->setText( "" ); serverurl->setText( "" ); servername->setFocus(); active->setChecked( true ); } void SettingsImpl :: removeServer() { - changed = true; - Server *s = dataMgr->getServer( servers->currentText() ); - dataMgr->getServerList().erase( s ); - servers->removeItem( currentSelectedServer ); + changed = true; + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); + dataMgr->getServerList().erase( s ); + servers->removeItem( currentSelectedServer ); } void SettingsImpl :: changeServerDetails() { changed = true; QString newName = servername->text(); if ( !newserver ) { - Server *s = dataMgr->getServer( serverName ); + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); // Update url s->setServerUrl( serverurl->text() ); s->setActive( active->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( serverName != newName ) { // Update server name s->setServerName( newName ); // See if this server is the active server // if ( dataMgr->getActiveServer() == serverName ) // dataMgr->setActiveServer( newName ); @@ -146,69 +147,69 @@ void SettingsImpl :: changeServerDetails() else { Server s( newName, serverurl->text() ); dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); dataMgr->getServerList().end()->setActive( active->isChecked() ); servers->insertItem( newName ); servers->setCurrentItem( servers->count() ); newserver = false; } } //------------------ Destinations tab ---------------------- void SettingsImpl :: editDestination( int sel ) { currentSelectedDestination = sel; - Destination *d = dataMgr->getDestination( destinations->currentText() ); + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); destinationName = d->getDestinationName(); destinationname->setText( d->getDestinationName() ); destinationurl->setText( d->getDestinationPath() ); linkToRoot->setChecked( d->linkToRoot() ); } void SettingsImpl :: newDestination() { newdestination = true; destinationname->setText( "" ); destinationurl->setText( "" ); destinationname->setFocus(); linkToRoot->setChecked( true ); } void SettingsImpl :: removeDestination() { - changed = true; - Destination *d = dataMgr->getDestination( destinations->currentText() ); - dataMgr->getDestinationList().erase( d ); + changed = true; + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); + dataMgr->getDestinationList().erase( d ); destinations->removeItem( currentSelectedDestination ); } void SettingsImpl :: changeDestinationDetails() { changed = true; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "destinations" ); #endif QString newName = destinationname->text(); if ( !newdestination ) { - Destination *d = dataMgr->getDestination( destinationName ); + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); // Update url d->setDestinationPath( destinationurl->text() ); d->linkToRoot( linkToRoot->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( destinationName != newName ) { // Update server name d->setDestinationName( newName ); // Update list box destinations->changeItem( newName, currentSelectedDestination ); } #ifdef QWS QString key = newName; |