summaryrefslogtreecommitdiff
authordrw <drw>2003-02-06 01:19:25 (UTC)
committer drw <drw>2003-02-06 01:19:25 (UTC)
commit79588befde53765db0a92977c6890a4d226096e7 (patch) (side-by-side diff)
tree83b6dd14c49733b9759fad04147bf0bee50793fe
parentbbb3690f12191763a407e6a0edd521113b3c25ac (diff)
downloadopie-79588befde53765db0a92977c6890a4d226096e7.zip
opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz
opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp82
-rw-r--r--noncore/settings/aqpkg/datamgr.h15
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp82
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h12
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp143
-rw-r--r--noncore/settings/aqpkg/mainwin.h2
-rw-r--r--noncore/settings/aqpkg/server.cpp69
-rw-r--r--noncore/settings/aqpkg/server.h8
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp38
9 files changed, 241 insertions, 210 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 2c83e28..79f36e1 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,289 +1,291 @@
/***************************************************************************
datamgr.cpp - description
-------------------
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 <iostream>
using namespace std;
#ifdef QWS
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
#endif
#include <stdio.h>
#include "datamgr.h"
#include "global.h"
QString DataManager::availableCategories = "";
DataManager::DataManager()
: QObject( 0x0, 0x0 )
{
activeServer = "";
availableCategories = "#";
+
+ serverList.setAutoDelete( TRUE );
+ destList.setAutoDelete( TRUE );
}
DataManager::~DataManager()
{
}
-vector<Server>::iterator DataManager :: getServer( const char *name )
+Server *DataManager :: getServer( const char *name )
{
- vector<Server>::iterator it = serverList.begin();
- while ( it != serverList.end() )
+ QListIterator<Server> it( serverList );
+ while ( it.current() && it.current()->getServerName() != name )
{
- if ( it->getServerName() == name )
- return it;
-
++it;
}
- return serverList.end();
+ return it.current();
}
-vector<Destination>::iterator DataManager :: getDestination( const char *name )
+Destination *DataManager :: getDestination( const char *name )
{
- vector<Destination>::iterator it = destList.begin();
- while ( it != destList.end() )
+ QListIterator<Destination> it( destList );
+ while ( it.current() && it.current()->getDestinationName() != name )
{
- if ( it->getDestinationName() == name )
- return it;
-
++it;
}
- return destList.end();
+ return it.current();
}
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, "" ) );
+ serverList.append( new Server( LOCAL_SERVER, "" ) );
+ serverList.append( new Server( LOCAL_IPKGS, "" ) );
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "destinations" );
#endif
// Read file from /etc/ipkg.conf
QString ipkg_conf = IPKG_CONF;
FILE *fp;
fp = fopen( ipkg_conf, "r" );
char line[130];
QString lineStr;
if ( fp == NULL )
{
cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
return;
}
else
{
while ( fgets( line, sizeof line, fp) != NULL )
{
lineStr = line;
if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
{
char alias[20];
char url[100];
// Looks a little wierd but read up to the r of src (throwing it away),
// then read up to the next space and throw that away, the alias
// is next.
// Should Handle #src, # src, src, and combinations of
sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
- Server s( alias, url );
+ Server *s = new Server( alias, url );
if ( lineStr.startsWith( "src" ) )
- s.setActive( true );
+ s->setActive( true );
else
- s.setActive( false );
+ s->setActive( false );
- serverList.push_back( s );
+ serverList.append( s );
}
else if ( lineStr.startsWith( "dest" ) )
{
char alias[20];
char path[50];
sscanf( lineStr, "%*[^ ] %s %s", alias, path );
- Destination d( alias, path );
+ Destination *d = new Destination( alias, path );
bool linkToRoot = true;
#ifdef QWS
QString key = alias;
key += "_linkToRoot";
linkToRoot = cfg.readBoolEntry( key, true );
#endif
- d.linkToRoot( linkToRoot );
+ d->linkToRoot( linkToRoot );
- destList.push_back( d );
+ destList.append( d );
}
else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
{
char type[20];
char val[100];
sscanf( lineStr, "%*[^ ] %s %s", type, val );
if ( stricmp( type, "http_proxy" ) == 0 )
{
httpProxy = val;
if ( lineStr.startsWith( "#" ) )
httpProxyEnabled = false;
else
httpProxyEnabled = true;
}
if ( stricmp( type, "ftp_proxy" ) == 0 )
{
ftpProxy = val;
if ( lineStr.startsWith( "#" ) )
ftpProxyEnabled = false;
else
ftpProxyEnabled = true;
}
if ( stricmp( type, "proxy_username" ) == 0 )
proxyUsername = val;
if ( stricmp( type, "proxy_password" ) == 0 )
proxyPassword = val;
}
}
}
fclose( fp );
reloadServerData( );
}
void DataManager :: reloadServerData( )
{
- emit progressSetSteps( serverList.size() );
+ emit progressSetSteps( serverList.count() );
emit progressSetMessage( tr( "Reading configuration..." ) );
- vector<Server>::iterator it = serverList.begin();
QString serverName;
int i = 0;
- for ( it = serverList.begin() ; it != serverList.end() ; ++it )
+
+ Server *server;
+ QListIterator<Server> it( serverList );
+ for ( ; it.current(); ++it )
{
- serverName = it->getServerName();
+ server = it.current();
+ serverName = server->getServerName();
i++;
emit progressUpdate( i );
qApp->processEvents();
// 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 ( serverName == LOCAL_SERVER )
- it->readStatusFile( destList );
+ server->readStatusFile( destList );
else if ( serverName == LOCAL_IPKGS )
- it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
+ server->readLocalIpks( getServer( LOCAL_SERVER ) );
else
- it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
+ server->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;
out << "#" << endl;
out << "# where <src-name> and <dest-names> are identifiers that" << endl;
out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
out << "# URL that points to a directory containing a Familiar" << endl;
out << "# Packages file, and <target-path> should be a directory" << endl;
out << "# that exists on the target system." << endl << endl;
// Write out servers
- vector<Server>::iterator it = serverList.begin();
- while ( it != serverList.end() )
+ Server *server;
+ QListIterator<Server> it( serverList );
+ while ( it.current() )
{
- QString alias = it->getServerName();
+ server = it.current();
+ QString alias = server->getServerName();
// Don't write out local as its a dummy
if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
{
- QString url = it->getServerUrl();;
+ QString url = server->getServerUrl();;
- if ( !it->isServerActive() )
+ if ( !server->isServerActive() )
out << "#";
out << "src " << alias << " " << url << endl;
}
- it++;
+ ++it;
}
out << endl;
// Write out destinations
- vector<Destination>::iterator it2 = destList.begin();
- while ( it2 != destList.end() )
+ QListIterator<Destination> it2( destList );
+ while ( it2.current() )
{
- out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
- it2++;
+ out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl;
+ ++it2;
}
out << endl;
out << "# Proxy Support" << endl;
if ( !httpProxyEnabled && httpProxy == "" )
out << "#option http_proxy http://proxy.tld:3128" << endl;
else
{
if ( !httpProxyEnabled )
out << "#";
out << "option http_proxy " << httpProxy << endl;
}
if ( !ftpProxyEnabled && ftpProxy == "" )
out << "#option ftp_proxy http://proxy.tld:3128" << endl;
else
{
if ( !ftpProxyEnabled )
out << "#";
out << "option ftp_proxy " << ftpProxy << endl;
}
if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
out << "#option proxy_username <username>" << endl;
else
out << "option proxy_username " << proxyUsername << endl;
if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
out << "#option proxy_password <password>" << endl << endl;
else
out << "option proxy_password " << proxyPassword << endl<< endl;
out << "# Offline mode (for use in constructing flash images offline)" << endl;
out << "#option offline_root target" << endl;
out.close();
}
void DataManager :: setAvailableCategories( QString section )
{
section = section.lower();
if ( availableCategories.find( "#" + section + "#" ) == -1 )
availableCategories += section + "#";
}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 90328ab..7fa42c1 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -1,98 +1,99 @@
/***************************************************************************
datamgr.h - description
-------------------
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. *
* *
***************************************************************************/
#ifndef DATAMGR_H
#define DATAMGR_H
#include <map>
using namespace std;
+#include <qlist.h>
#include <qobject.h>
#include <qstring.h>
#include "server.h"
#include "destination.h"
#define LOCAL_SERVER "Installed Pkgs"
#define LOCAL_IPKGS "local IPKG"
/**
*@author Andy Qua
*/
class DataManager : public QObject
{
Q_OBJECT
public:
DataManager();
~DataManager();
void setActiveServer( const QString &act ) { activeServer = act; }
QString &getActiveServer( ) { return activeServer; }
- Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); }
- vector<Server> &getServerList() { return serverList; }
- vector<Server>::iterator getServer( const char *name );
+ Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); }
+ QList<Server> &getServerList() { return serverList; }
+ Server *getServer( const char *name );
- vector<Destination> &getDestinationList() { return destList; }
- vector<Destination>::iterator getDestination( const char *name );
+ QList<Destination> &getDestinationList() { return destList; }
+ Destination *getDestination( const char *name );
void loadServers();
void reloadServerData( );
void writeOutIpkgConf();
static QString getAvailableCategories() { return availableCategories; }
static void setAvailableCategories( QString section );
QString getHttpProxy() { return httpProxy; }
QString getFtpProxy() { return ftpProxy; }
QString getProxyUsername() { return proxyUsername; }
QString getProxyPassword() { return proxyPassword; }
bool getHttpProxyEnabled() { return httpProxyEnabled; }
bool getFtpProxyEnabled() { return ftpProxyEnabled; }
void setHttpProxy( QString proxy ) { httpProxy = proxy; }
void setFtpProxy( QString proxy ) { ftpProxy = proxy; }
void setProxyUsername( QString name ) { proxyUsername = name; }
void setProxyPassword( QString pword ) { proxyPassword = pword; }
void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; }
void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; }
private:
static QString availableCategories;
QString activeServer;
QString httpProxy;
QString ftpProxy;
QString proxyUsername;
QString proxyPassword;
bool httpProxyEnabled;
bool ftpProxyEnabled;
- vector<Server> serverList;
- vector<Destination> destList;
+ QList<Server> serverList;
+ QList<Destination> destList;
signals:
void progressSetSteps( int );
void progressSetMessage( const QString & );
void progressUpdate( int );
};
#endif
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 19fe46a..9339086 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,345 +1,355 @@
/***************************************************************************
installdlgimpl.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 <stdio.h>
#ifdef QWS
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
#endif
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialog.h>
#include <qgroupbox.h>
#include <qmultilineedit.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include "datamgr.h"
#include "destination.h"
#include "instoptionsimpl.h"
#include "installdlgimpl.h"
#include "ipkg.h"
#include "utils.h"
#include "global.h"
-InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title )
+InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( TRUE );
pIpkg = 0;
upgradePackages = false;
dataMgr = dataManager;
- vector<Destination>::iterator dit;
QString defaultDest = "root";
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
defaultDest = cfg.readEntry( "dest", "root" );
// Grab flags - Turn MAKE_LINKS on by default (if no flags found)
flags = cfg.readNumEntry( "installFlags", 0 );
#else
flags = 0;
#endif
// Output text is read only
output->setReadOnly( true );
// QFont f( "helvetica" );
// f.setPointSize( 10 );
// output->setFont( f );
// setup destination data
int defIndex = 0;
int i;
- for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
+ QListIterator<Destination> dit( dataMgr->getDestinationList() );
+ for ( i = 0; dit.current(); ++dit, ++i )
{
- destination->insertItem( dit->getDestinationName() );
- if ( dit->getDestinationName() == defaultDest )
+ destination->insertItem( dit.current()->getDestinationName() );
+ if ( dit.current()->getDestinationName() == defaultDest )
defIndex = i;
}
destination->setCurrentItem( defIndex );
- vector<InstallData>::iterator it;
+ QListIterator<InstallData> it( packageList );
// setup package data
QString remove = tr( "Remove\n" );
QString install = tr( "Install\n" );
QString upgrade = tr( "Upgrade\n" );
- for ( it = packageList.begin() ; it != packageList.end() ; ++it )
+ for ( ; it.current(); ++it )
{
- InstallData item = *it;
- if ( item.option == "I" )
+ InstallData *item = it.current();
+ InstallData *newitem = new InstallData();
+
+ newitem->option = item->option;
+ newitem->packageName = item->packageName;
+ newitem->destination = item->destination;
+ newitem->recreateLinks = item->recreateLinks;
+
+ if ( item->option == "I" )
{
- installList.push_back( item );
- install.append( QString( " %1\n" ).arg( item.packageName ) );
+ installList.append( newitem );
+ install.append( QString( " %1\n" ).arg( item->packageName ) );
}
- else if ( item.option == "D" )
+ else if ( item->option == "D" )
{
- removeList.push_back( item );
- remove.append( QString( " %1\n" ).arg( item.packageName ) );
+ removeList.append( newitem );
+ remove.append( QString( " %1\n" ).arg( item->packageName ) );
}
- else if ( item.option == "U" || item.option == "R" )
+ else if ( item->option == "U" || item->option == "R" )
{
- updateList.push_back( item );
+ updateList.append( newitem );
QString type;
- if ( item.option == "R" )
+ if ( item->option == "R" )
type = tr( "(ReInstall)" );
else
type = tr( "(Upgrade)" );
- upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) );
+ upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
}
}
-
output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
displayAvailableSpace( destination->currentText() );
}
InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( FALSE );
pIpkg = ipkg;
output->setText( initialText );
}
InstallDlgImpl::~InstallDlgImpl()
{
if ( pIpkg )
delete pIpkg;
}
void InstallDlgImpl :: init( bool displayextrainfo )
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
if ( displayextrainfo )
{
QLabel *label = new QLabel( tr( "Destination" ), this );
layout->addWidget( label, 0, 0 );
destination = new QComboBox( FALSE, this );
layout->addWidget( destination, 0, 1 );
connect( destination, SIGNAL( highlighted( const QString & ) ),
this, SLOT( displayAvailableSpace( const QString & ) ) );
QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
layout->addWidget( label2, 1, 0 );
txtAvailableSpace = new QLabel( "", this );
layout->addWidget( txtAvailableSpace, 1, 1 );
}
else
{
destination = 0x0;
txtAvailableSpace = 0x0;
}
QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
GroupBox2->layout()->setSpacing( 0 );
GroupBox2->layout()->setMargin( 4 );
QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
output = new QMultiLineEdit( GroupBox2 );
GroupBox2Layout->addWidget( output );
layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
layout->addWidget( btnInstall, 3, 0 );
connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this );
layout->addWidget( btnOptions, 3, 1 );
connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
}
void InstallDlgImpl :: optionsSelected()
{
InstallOptionsDlgImpl opt( flags, this, "Option", true );
opt.exec();
// set options selected from dialog
flags = opt.getFlags();
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "installFlags", flags );
#endif
}
void InstallDlgImpl :: installSelected()
{
if ( btnInstall->text() == tr( "Abort" ) )
{
if ( pIpkg )
{
displayText( tr( "\n**** User Clicked ABORT ***" ) );
pIpkg->abort();
displayText( tr( "**** Process Aborted ****" ) );
}
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
return;
}
else if ( btnInstall->text() == tr( "Close" ) )
{
emit reloadData( this );
return;
}
// Disable buttons
btnOptions->setEnabled( false );
// btnInstall->setEnabled( false );
btnInstall->setText( tr( "Abort" ) );
btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
if ( pIpkg )
{
output->setText( "" );
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
pIpkg->runIpkg();
}
else
{
output->setText( "" );
- vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
+ Destination *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 &)));
// First run through the remove list, then the install list then the upgrade list
- vector<InstallData>::iterator it;
pIpkg->setOption( "remove" );
- for ( it = removeList.begin() ; it != removeList.end() ; ++it )
+ QListIterator<InstallData> it( removeList );
+ InstallData *idata;
+ for ( ; it.current(); ++it )
{
- pIpkg->setDestination( it->destination->getDestinationName() );
- pIpkg->setDestinationDir( it->destination->getDestinationPath() );
- pIpkg->setPackage( it->packageName );
+ idata = it.current();
+ pIpkg->setDestination( idata->destination->getDestinationName() );
+ pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
+ pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
- if ( it->destination->linkToRoot() )
+ if ( idata->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags );
pIpkg->runIpkg();
}
pIpkg->setOption( "install" );
pIpkg->setDestination( dest );
pIpkg->setDestinationDir( destDir );
pIpkg->setFlags( instFlags );
- for ( it = installList.begin() ; it != installList.end() ; ++it )
+ QListIterator<InstallData> it2( installList );
+ for ( ; it2.current(); ++it2 )
{
- pIpkg->setPackage( it->packageName );
+ pIpkg->setPackage( it2.current()->packageName );
pIpkg->runIpkg();
}
flags |= FORCE_REINSTALL;
- for ( it = updateList.begin() ; it != updateList.end() ; ++it )
+ QListIterator<InstallData> it3( updateList );
+ for ( ; it3.current() ; ++it3 )
{
- if ( it->option == "R" )
+ idata = it3.current();
+ if ( idata->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
- pIpkg->setDestination( it->destination->getDestinationName() );
- pIpkg->setDestinationDir( it->destination->getDestinationPath() );
- pIpkg->setPackage( it->packageName );
+ pIpkg->setDestination( idata->destination->getDestinationName() );
+ pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
+ pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
- if ( it->destination->linkToRoot() && it->recreateLinks )
+ if ( idata->destination->linkToRoot() && idata->recreateLinks )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags );
pIpkg->runIpkg();
}
delete pIpkg;
pIpkg = 0;
}
btnOptions->setEnabled( true );
// btnInstall->setEnabled( true );
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
displayAvailableSpace( destination->currentText() );
}
void InstallDlgImpl :: displayText(const QString &text )
{
- //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) );
QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
output->setText( newtext );
output->setCursorPosition( output->numLines(), 0 );
}
void InstallDlgImpl :: displayAvailableSpace( const QString &text )
{
- vector<Destination>::iterator d = dataMgr->getDestination( text );
+ Destination *d = dataMgr->getDestination( text );
QString destDir = d->getDestinationPath();
long blockSize = 0;
long totalBlocks = 0;
long availBlocks = 0;
QString space;
if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
{
long mult = blockSize / 1024;
long div = 1024 / blockSize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
// long total = totalBlocks * mult / div;
long avail = availBlocks * mult / div;
// long used = total - avail;
space.sprintf( "%ld Kb", avail );
}
else
space = tr( "Unknown" );
if ( txtAvailableSpace )
txtAvailableSpace->setText( space );
}
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 4c9f087..d7509bb 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -1,85 +1,85 @@
/***************************************************************************
installdlgimpl.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 INSTALLDLGIMPL_H
#define INSTALLDLGIMPL_H
-#include <vector>
using namespace std;
-#include <qwidget.h>
+#include <qlist.h>
#include <qstring.h>
+#include <qwidget.h>
class QComboBox;
class QLabel;
class QMultiLineEdit;
class QPushButton;
class DataManager;
class Destination;
class Ipkg;
class InstallData
{
public:
QString option; // I - install, D - delete, R- reinstall U - upgrade
QString packageName;
Destination *destination;
bool recreateLinks;
};
class InstallDlgImpl : public QWidget
{
Q_OBJECT
public:
- InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
+ InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
~InstallDlgImpl();
bool upgradeServer( QString &server );
protected:
private:
DataManager *dataMgr;
- vector<InstallData> installList;
- vector<InstallData> removeList;
- vector<InstallData> updateList;
+ QList<InstallData> installList;
+ QList<InstallData> removeList;
+ QList<InstallData> updateList;
int flags;
Ipkg *pIpkg;
bool upgradePackages;
QComboBox *destination;
QPushButton *btnInstall;
QPushButton *btnOptions;
QMultiLineEdit *output;
QLabel *txtAvailableSpace;
void init( bool );
bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
signals:
void reloadData( InstallDlgImpl * );
public slots:
void optionsSelected();
void installSelected();
void displayText(const QString &text );
void displayAvailableSpace( const QString &text);
};
#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 361946c..8ae5815 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -34,1153 +34,1162 @@
#include <qlistview.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include <qwidgetstack.h>
#include "categoryfilterimpl.h"
#include "datamgr.h"
#include "global.h"
#include "helpwindow.h"
#include "inputdlg.h"
#include "ipkg.h"
#include "installdlgimpl.h"
#include "letterpushbutton.h"
#include "mainwin.h"
#include "settingsimpl.h"
#include "utils.h"
extern int compareVersions( const char *v1, const char *v2 );
MainWindow :: MainWindow()
: QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
{
setCaption( tr( "AQPkg - Package Manager" ) );
// Create UI widgets
initMainWidget();
initProgressWidget();
// Build menu and tool bars
setToolBarsMovable( FALSE );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mb = new QPEMenuBar( bar );
mb->setMargin( 0 );
bar = new QPEToolBar( this );
// Find toolbar
findBar = new QPEToolBar( this );
addToolBar( findBar, QMainWindow::Top, true );
findBar->setHorizontalStretchable( true );
findEdit = new QLineEdit( findBar );
QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
findBar->setStretchableWidget( findEdit );
connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
// Quick jump toolbar
jumpBar = new QPEToolBar( this );
addToolBar( jumpBar, QMainWindow::Top, true );
jumpBar->setHorizontalStretchable( true );
QWidget *w = new QWidget( jumpBar );
jumpBar->setStretchableWidget( w );
QGridLayout *layout = new QGridLayout( w );
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, w );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
layout->addWidget( b, i / 13, i % 13);
}
QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
a->addTo( jumpBar );
jumpBar->hide();
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
a->addTo( popup );
a->addTo( bar );
actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( bar );
iconDownload = Resource::loadPixmap( "aqpkg/download" );
iconRemove = Resource::loadPixmap( "aqpkg/remove" );
actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
actionDownload->addTo( popup );
actionDownload->addTo( bar );
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
a->addTo( popup );
a->addTo( bar );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
actionUninstalled->setToggleAction( TRUE );
actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
actionUninstalled->addTo( popup );
actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
actionInstalled->setToggleAction( TRUE );
actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
actionInstalled->addTo( popup );
actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
actionUpdated->setToggleAction( TRUE );
actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
actionUpdated->addTo( popup );
popup->insertSeparator();
actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
actionFilter->setToggleAction( TRUE );
actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
actionFilter->addTo( popup );
a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
a->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to search for text in package names." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
a->addTo( popup );
actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
actionFindNext->setEnabled( FALSE );
actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
actionFindNext->addTo( popup );
actionFindNext->addTo( findBar );
popup->insertSeparator();
a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
a->addTo( popup );
mb->insertItem( tr( "View" ), popup );
// Options menu
popup = new QPopupMenu( this );
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
a->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here for help." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) );
a->addTo( popup );
a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here for software version information." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) );
a->addTo( popup );
mb->insertItem( tr( "Options" ), popup );
// Finish find toolbar creation
a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
a->addTo( findBar );
findBar->hide();
// Create widget stack and add UI widgets
stack = new QWidgetStack( this );
stack->addWidget( progressWindow, 2 );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
stack->raiseWidget( progressWindow );
// Delayed call to finish initialization
QTimer::singleShot( 100, this, SLOT( init() ) );
}
MainWindow :: ~MainWindow()
{
delete mgr;
}
void MainWindow :: initMainWidget()
{
networkPkgWindow = new QWidget( this );
QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
serversList = new QComboBox( networkPkgWindow );
connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) );
QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
installedIcon = Resource::loadPixmap( "aqpkg/installed" );
updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
packagesList = new QListView( networkPkgWindow );
packagesList->addColumn( tr( "Packages" ), 225 );
QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
hbox1->addWidget( l );
hbox1->addWidget( serversList );
vbox->addWidget( packagesList );
downloadEnabled = TRUE;
}
void MainWindow :: initProgressWidget()
{
progressWindow = new QWidget( this );
QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
m_status = new QLabel( progressWindow );
m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout->addWidget( m_status );
m_progress = new QProgressBar( progressWindow );
layout->addWidget( m_progress );
}
void MainWindow :: init()
{
#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
stack->raiseWidget( progressWindow );
mgr = new DataManager();
connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
this, SLOT( setProgressMessage( const QString & ) ) );
connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
mgr->loadServers();
showUninstalledPkgs = false;
showInstalledPkgs = false;
showUpgradedPkgs = false;
categoryFilterEnabled = false;
updateData();
stack->raiseWidget( networkPkgWindow );
}
/*
void MainWindow :: setDocument( const QString &doc )
{
// Remove path from package
QString package = Utils::getPackageNameFromIpkFilename( doc );
// std::cout << "Selecting package " << package << std::endl;
// 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( package ) )
{
item->setOn( true );
break;
}
}
}
*/
void MainWindow :: displaySettings()
{
SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
if ( dlg->showDlg() )
{
stack->raiseWidget( progressWindow );
updateData();
stack->raiseWidget( networkPkgWindow );
}
delete dlg;
}
void MainWindow :: displayHelp()
{
HelpWindow *dlg = new HelpWindow( this );
dlg->exec();
delete dlg;
}
void MainWindow :: displayFindBar()
{
findBar->show();
findEdit->setFocus();
}
void MainWindow :: displayJumpBar()
{
jumpBar->show();
}
void MainWindow :: repeatFind()
{
searchForPackage( findEdit->text() );
}
void MainWindow :: findPackage( const QString &text )
{
actionFindNext->setEnabled( !text.isEmpty() );
searchForPackage( text );
}
void MainWindow :: hideFindBar()
{
findBar->hide();
}
void MainWindow :: hideJumpBar()
{
jumpBar->hide();
}
void MainWindow :: displayAbout()
{
QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) );
}
void MainWindow :: filterUninstalledPackages()
{
showUninstalledPkgs = actionUninstalled->isOn();
if ( showUninstalledPkgs )
{
showInstalledPkgs = FALSE;
showUpgradedPkgs = FALSE;
}
serverSelected( -1 );
actionInstalled->setOn( FALSE );
actionUpdated->setOn( FALSE );
}
void MainWindow :: filterInstalledPackages()
{
showInstalledPkgs = actionInstalled->isOn();
if ( showInstalledPkgs )
{
showUninstalledPkgs = FALSE;
showUpgradedPkgs = FALSE;
}
serverSelected( -1 );
actionUninstalled->setOn( FALSE );
actionUpdated->setOn( FALSE );
}
void MainWindow :: filterUpgradedPackages()
{
showUpgradedPkgs = actionUpdated->isOn();
if ( showUpgradedPkgs )
{
showUninstalledPkgs = FALSE;
showInstalledPkgs = FALSE;
}
serverSelected( -1 );
actionUninstalled->setOn( FALSE );
actionInstalled->setOn( FALSE );
}
bool MainWindow :: setFilterCategory()
{
// Get categories;
CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
if ( dlg.exec() == QDialog::Accepted )
{
categoryFilter = dlg.getSelectedFilter();
if ( categoryFilter == "" )
return false;
categoryFilterEnabled = true;
serverSelected( -1 );
actionFilter->setOn( TRUE );
return true;
}
return false;
}
void MainWindow :: filterCategory()
{
if ( !actionFilter->isOn() )
{
filterByCategory( FALSE );
}
else
{
actionFilter->setOn( filterByCategory( TRUE ) );
}
}
bool MainWindow :: filterByCategory( bool val )
{
if ( val )
{
if ( categoryFilter == "" )
{
if ( !setFilterCategory() )
return false;
}
categoryFilterEnabled = true;
serverSelected( -1 );
return true;
}
else
{
// Turn off filter
categoryFilterEnabled = false;
serverSelected( -1 );
return false;
}
}
void MainWindow :: raiseMainWidget()
{
stack->raiseWidget( networkPkgWindow );
}
void MainWindow :: raiseProgressWidget()
{
stack->raiseWidget( progressWindow );
}
void MainWindow :: enableUpgrade( bool enabled )
{
actionUpgrade->setEnabled( enabled );
}
void MainWindow :: enableDownload( bool enabled )
{
if ( enabled )
{
actionDownload->setIconSet( iconDownload );
actionDownload->setText( tr( "Download" ) );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
}
else
{
actionDownload->setIconSet( iconRemove );
actionDownload->setText( tr( "Remove" ) );
actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
}
}
void MainWindow :: setProgressSteps( int numsteps )
{
m_progress->setTotalSteps( numsteps );
}
void MainWindow :: setProgressMessage( const QString &msg )
{
m_status->setText( msg );
}
void MainWindow :: updateProgress( int progress )
{
m_progress->setProgress( progress );
}
void MainWindow :: updateData()
{
- m_progress->setTotalSteps( mgr->getServerList().size() );
+ m_progress->setTotalSteps( mgr->getServerList().count() );
serversList->clear();
packagesList->clear();
- vector<Server>::iterator it;
int activeItem = -1;
- int i;
+ int i = 0;
QString serverName;
- for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i )
+
+ QListIterator<Server> it( mgr->getServerList() );
+ Server *server;
+
+ for ( ; it.current(); ++it, ++i )
{
- serverName = it->getServerName();
+ server = it.current();
+ serverName = server->getServerName();
m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
m_progress->setProgress( i );
qApp->processEvents();
// cout << "Adding " << it->getServerName() << " to combobox" << endl;
- if ( !it->isServerActive() )
+ if ( !server->isServerActive() )
{
// cout << serverName << " is not active" << endl;
i--;
continue;
}
serversList->insertItem( serverName );
if ( serverName == currentlySelectedServer )
activeItem = i;
}
// set selected server to be active server
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
serverSelected( 0, FALSE );
}
void MainWindow :: serverSelected( int index )
{
serverSelected( index, TRUE );
}
void MainWindow :: serverSelected( int, bool raiseProgress )
{
QPixmap nullIcon( installedIcon.size() );
nullIcon.fill( colorGroup().base() );
// display packages
QString serverName = serversList->currentText();
currentlySelectedServer = serverName;
- vector<Server>::iterator s = mgr->getServer( serverName );
+ Server *s = mgr->getServer( serverName );
- vector<Package> &list = s->getPackageList();
- vector<Package>::iterator it;
+ QList<Package> &list = s->getPackageList();
+ QListIterator<Package> it( list );
// Display progress widget while loading list
- bool doProgress = ( list.size() > 200 );
+ bool doProgress = ( list.count() > 200 );
if ( doProgress )
{
if ( raiseProgress )
{
stack->raiseWidget( progressWindow );
}
- m_progress->setTotalSteps( list.size() );
+ m_progress->setTotalSteps( list.count() );
m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
}
packagesList->clear();
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "selectedServer", currentlySelectedServer );
#endif
int i = 0;
- for ( it = list.begin() ; it != list.end() ; ++it )
+ Package *package;
+ for ( ; it.current(); ++it )
{
// Update progress after every 100th package (arbitrary value, seems to give good balance)
i++;
if ( ( i % 100 ) == 0 )
{
if ( doProgress )
{
m_progress->setProgress( i );
}
qApp->processEvents();
}
QString text = "";
+ package = it.current();
+
// Apply show only uninstalled packages filter
- if ( showUninstalledPkgs && it->isInstalled() )
+ if ( showUninstalledPkgs && package->isInstalled() )
continue;
// Apply show only installed packages filter
- if ( showInstalledPkgs && !it->isInstalled() )
+ if ( showInstalledPkgs && !package->isInstalled() )
continue;
// Apply show only new installed packages filter
if ( showUpgradedPkgs )
{
- if ( !it->isInstalled() ||
- compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
+ if ( !package->isInstalled() ||
+ compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 )
continue;
}
// Apply the section filter
if ( categoryFilterEnabled && categoryFilter != "" )
{
- if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
+ if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
continue;
}
// If the local server, only display installed packages
- if ( serverName == LOCAL_SERVER && !it->isInstalled() )
+ if ( serverName == LOCAL_SERVER && !package->isInstalled() )
continue;
- QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox );
+ QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
+ QCheckListItem::CheckBox );
- if ( it->isInstalled() )
+ if ( package->isInstalled() )
{
// If a different version of package is available, show update available icon
// Otherwise, show installed icon
- if ( it->getVersion() != it->getInstalledVersion() &&
- compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1)
+ if ( package->getVersion() != package->getInstalledVersion() &&
+ compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1)
{
item->setPixmap( 0, updatedIcon );
}
else
{
item->setPixmap( 0, installedIcon );
}
QString destName = "";
- if ( it->getLocalPackage() )
+ if ( package->getLocalPackage() )
{
- if ( it->getLocalPackage()->getInstalledTo() )
- destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
+ if ( package->getLocalPackage()->getInstalledTo() )
+ destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
}
else
{
- if ( it->getInstalledTo() )
- destName = it->getInstalledTo()->getDestinationName();
+ if ( package->getInstalledTo() )
+ destName = package->getInstalledTo()->getDestinationName();
}
if ( destName != "" )
new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
}
else
{
item->setPixmap( 0, nullIcon );
}
- if ( !it->isPackageStoredLocally() )
+ if ( !package->isPackageStoredLocally() )
{
- new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) );
- new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) );
- new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) );
+ new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) );
+ new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) );
+ new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) );
}
else
- new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) );
+ new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) );
if ( serverName == LOCAL_SERVER )
{
- new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
+ new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) );
}
else
{
- new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
- if ( it->getLocalPackage() )
+ new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) );
+ if ( package->getLocalPackage() )
{
- if ( it->isInstalled() )
- new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
+ if ( package->isInstalled() )
+ new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) );
}
}
packagesList->insertItem( item );
}
// If the local server or the local ipkgs server disable the download button
if ( serverName == LOCAL_SERVER )
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( FALSE );
}
else if ( serverName == LOCAL_IPKGS )
{
downloadEnabled = FALSE;
actionUpgrade->setEnabled( FALSE );
}
else
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( TRUE );
}
enableDownload( downloadEnabled );
// Display this widget once everything is done
if ( doProgress && raiseProgress )
{
stack->raiseWidget( networkPkgWindow );
}
}
void MainWindow :: searchForPackage( const QString &text )
{
if ( !text.isEmpty() )
{
// cout << "searching for " << text << endl;
// look through package list for text startng at current position
- vector<InstallData> workingPackages;
+// vector<InstallData> workingPackages;
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
// if ( start != 0 )
// start = (QCheckListItem *)start->nextSibling();
if ( start == 0 )
start = (QCheckListItem *)packagesList->firstChild();
for ( QCheckListItem *item = start; item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
// cout << "checking " << item->text().lower() << endl;
if ( item->text().lower().find( text ) != -1 )
{
// cout << "matched " << item->text() << endl;
packagesList->ensureItemVisible( item );
packagesList->setCurrentItem( item );
break;
}
}
}
}
void MainWindow :: updateServer()
{
QString serverName = serversList->currentText();
// Update the current server
// Display dialog
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
Ipkg *ipkg = new Ipkg;
ipkg->setOption( "update" );
InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
tr( "Update lists" ) );
connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
dlg->showMaximized();
// delete progDlg;
}
void MainWindow :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
// TODO - ODevice????
QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now run upgrade
Ipkg *ipkg = new Ipkg;
ipkg->setOption( "upgrade" );
InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
tr ( "Upgrade" ) );
connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
dlg->showMaximized();
}
}
void MainWindow :: downloadPackage()
{
bool doUpdate = true;
if ( downloadEnabled )
{
// See if any packages are selected
bool found = false;
if ( serversList->currentText() != LOCAL_SERVER )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 && !found;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
found = true;
}
}
// If user selected some packages then download the and store the locally
// otherwise, display dialog asking user what package to download from an http server
// and whether to install it
if ( found )
downloadSelectedPackages();
else
downloadRemotePackage();
}
else
{
doUpdate = false;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
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 );
Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
QString msgtext;
msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
if ( QMessageBox::information( this, tr( "Are you sure?" ),
msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
{
doUpdate = true;
QFile f( p->getFilename() );
f.remove();
}
}
}
}
if ( doUpdate )
{
reloadData( 0x0 );
}
}
void MainWindow :: downloadSelectedPackages()
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
#ifdef QWS
// Store download directory in config file
cfg.writeEntry( "downloadDir", dir );
#endif
// Get starting directory
char initDir[PATH_MAX];
getcwd( initDir, PATH_MAX );
// Download each package
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
ipkg.setPackage( item->text() );
ipkg.runIpkg( );
}
}
}
void MainWindow :: downloadRemotePackage()
{
// Display dialog
bool ok;
QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
if ( !ok || package.isEmpty() )
return;
// DownloadRemoteDlgImpl dlg( this, "Install", true );
// if ( dlg.exec() == QDialog::Rejected )
// return;
// grab details from dialog
// QString package = dlg.getPackageLocation();
- InstallData item;
- item.option = "I";
- item.packageName = package;
- vector<InstallData> workingPackages;
- workingPackages.push_back( item );
+ InstallData *item = new InstallData();
+ item->option = "I";
+ item->packageName = package;
+ QList<InstallData> workingPackages;
+ workingPackages.setAutoDelete( TRUE );
+ workingPackages.append( item );
InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
dlg->showMaximized();
}
void MainWindow :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
- vector<InstallData> workingPackages;
+ QList<InstallData> workingPackages;
+ workingPackages.setAutoDelete( TRUE );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
- InstallData data = dealWithItem( item );
- workingPackages.push_back( data );
+ workingPackages.append( dealWithItem( item ) );
}
}
- if ( workingPackages.size() == 0 )
+ if ( workingPackages.count() == 0 )
{
// Nothing to do
QMessageBox::information( this, tr( "Nothing to do" ),
tr( "No packages selected" ), tr( "OK" ) );
return;
}
// do the stuff
InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
dlg->showMaximized();
}
// 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 MainWindow :: dealWithItem( QCheckListItem *item )
+InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
// Get package
- vector<Server>::iterator s = mgr->getServer( serversList->currentText() );
+ Server *s = mgr->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;
+ InstallData *newitem = new InstallData();;
+ newitem->option = "I";
+ newitem->packageName = name;
+ return newitem;
}
else
{
- InstallData item;
- item.option = "D";
+ InstallData *newitem = new InstallData();;
+ newitem->option = "D";
if ( !p->isPackageStoredLocally() )
- item.packageName = p->getInstalledPackageName();
+ newitem->packageName = p->getInstalledPackageName();
else
- item.packageName = name;
+ newitem->packageName = name;
if ( p->getInstalledTo() )
{
- item.destination = p->getInstalledTo();
+ newitem->destination = p->getInstalledTo();
// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
}
else
{
- item.destination = p->getLocalPackage()->getInstalledTo();
+ newitem->destination = p->getLocalPackage()->getInstalledTo();
}
// Now see if version is newer or not
int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
// If the version requested is older and user selected a local ipk file, then reinstall the file
if ( p->isPackageStoredLocally() && val == -1 )
val = 0;
if ( val == -2 )
{
// Error - should handle
}
else if ( val == -1 )
{
// Version available is older - remove only
- item.option = "D";
+ newitem->option = "D";
}
else
{
QString caption;
QString text;
QString secondButton;
QString secondOption;
if ( val == 0 )
{
// Version available is the same - option to remove or reinstall
caption = tr( "Do you wish to remove or reinstall\n%1?" );
text = tr( "Remove or ReInstall" );
secondButton = tr( "ReInstall" );
secondOption = tr( "R" );
}
else if ( val == 1 )
{
// Version available is newer - option to remove or upgrade
caption = tr( "Do you wish to remove or upgrade\n%1?" );
text = tr( "Remove or Upgrade" );
secondButton = tr( "Upgrade" );
secondOption = tr( "U" );
}
// Sticky option not implemented yet, but will eventually allow
// the user to say something like 'remove all'
if ( stickyOption == "" )
{
QString msgtext;
msgtext = caption.arg( ( const char * )name );
switch( QMessageBox::information( this, text,
msgtext, tr( "Remove" ), secondButton ) )
{
case 0: // Try again or Enter
// option 0 = Remove
- item.option = "D";
+ newitem->option = "D";
break;
case 1: // Quit or Escape
- item.option = secondOption;
+ newitem->option = secondOption;
break;
}
}
else
{
-// item.option = stickyOption;
+// newitem->option = stickyOption;
}
}
// Check if we are reinstalling the same version
- if ( item.option != "R" )
- item.recreateLinks = true;
+ if ( newitem->option != "R" )
+ newitem->recreateLinks = true;
else
- item.recreateLinks = false;
+ newitem->recreateLinks = false;
// User hit cancel (on dlg - assume remove)
- return item;
+ return newitem;
}
}
void MainWindow :: reloadData( InstallDlgImpl *dlg )
{
stack->raiseWidget( progressWindow );
if ( dlg )
{
dlg->close();
delete dlg;
}
mgr->reloadServerData();
serverSelected( -1, FALSE );
#ifdef QWS
m_status->setText( tr( "Updating Launcher..." ) );
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#endif
stack->raiseWidget( networkPkgWindow );
}
void MainWindow :: 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/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index d0777fb..db06e16 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,138 +1,138 @@
/***************************************************************************
mainwin.h - 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. *
* *
***************************************************************************/
#ifndef MAINWIN_H
#define MAINWIN_H
#include <qmainwindow.h>
#include <qpixmap.h>
class DataManager;
class InstallData;
class InstallDlgImpl;
class QAction;
class QCheckListItem;
class QComboBox;
class QLabel;
class QLineEdit;
class QListView;
class QPEToolBar;
class QProgressBar;
class QWidgetStack;
class MainWindow :public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
private:
DataManager *mgr;
QWidgetStack *stack;
QPEToolBar *findBar;
QPEToolBar *jumpBar;
QLineEdit *findEdit;
QAction *actionFindNext;
QAction *actionFilter;
QAction *actionUpgrade;
QAction *actionDownload;
QAction *actionUninstalled;
QAction *actionInstalled;
QAction *actionUpdated;
QPixmap iconDownload;
QPixmap iconRemove;
int mnuShowUninstalledPkgsId;
int mnuShowInstalledPkgsId;
int mnuShowUpgradedPkgsId;
int mnuFilterByCategory;
int mnuSetFilterCategory;
// Main package list widget
QWidget *networkPkgWindow;
QComboBox *serversList;
QListView *packagesList;
QPixmap installedIcon;
QPixmap updatedIcon;
QString currentlySelectedServer;
QString categoryFilter;
QString stickyOption;
bool categoryFilterEnabled;
bool showJumpTo;
bool showUninstalledPkgs;
bool showInstalledPkgs;
bool showUpgradedPkgs;
bool downloadEnabled;
void initMainWidget();
void updateData();
void serverSelected( int index, bool showProgress );
void searchForPackage( const QString & );
bool filterByCategory( bool val );
void downloadSelectedPackages();
void downloadRemotePackage();
- InstallData dealWithItem( QCheckListItem *item );
+ InstallData *dealWithItem( QCheckListItem *item );
// Progress widget
QWidget *progressWindow;
QLabel *m_status;
QProgressBar *m_progress;
void initProgressWidget();
public slots:
// void setDocument( const QString &doc );
void displayHelp();
void displayFindBar();
void displayJumpBar();
void repeatFind();
void findPackage( const QString & );
void hideFindBar();
void hideJumpBar();
void displayAbout();
void displaySettings();
void filterUninstalledPackages();
void filterInstalledPackages();
void filterUpgradedPackages();
void filterCategory();
bool setFilterCategory();
void raiseMainWidget();
void raiseProgressWidget();
void enableUpgrade( bool );
void enableDownload( bool );
void reloadData( InstallDlgImpl * );
private slots:
void init();
void setProgressSteps( int );
void setProgressMessage( const QString & );
void updateProgress( int );
void serverSelected( int index );
void updateServer();
void upgradePackages();
void downloadPackage();
void applyChanges();
void letterPushed( QString t );
};
#endif
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
@@ -1,307 +1,314 @@
/***************************************************************************
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 )
+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
// 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 );
-
+ 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
// 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());
+ 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" )
{
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 )
{
- 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";
+ QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl );
- for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
- ret += "\n " + packageList[i].toString();
+ 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;
}
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h
index f585b8f..02746e0 100644
--- a/noncore/settings/aqpkg/server.h
+++ b/noncore/settings/aqpkg/server.h
@@ -1,66 +1,66 @@
/***************************************************************************
server.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 SERVER_H
#define SERVER_H
+#include <qlist.h>
#include <qstring.h>
-#include <vector>
using namespace std;
#include "package.h"
#include "destination.h"
class Server
{
public:
Server() {}
Server( const char *name, const char *url );
Server( const char *name, const char *url, const char *file );
~Server();
void cleanUp();
- void readStatusFile( vector<Destination> &v );
+ void readStatusFile( QList<Destination> &v );
void readLocalIpks( Server *local );
void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 );
void buildLocalPackages( Server *local );
Package *getPackage( const char *name );
Package *getPackage( QString &name );
QString toString();
- vector<Package> &getPackageList();
+ QList<Package> &getPackageList();
bool isServerActive() { return active; }
void setServerName( const QString &name ) { serverName = name; }
void setServerUrl( const QString &url ) { serverUrl = url; }
void setActive( bool val ) { active = val; }
QString &getServerName() { return serverName; }
QString &getServerUrl() { return serverUrl; }
protected:
private:
QString serverName;
QString serverUrl;
QString packageFile;
bool active;
- vector<Package> packageList;
+ QList<Package> packageList;
};
#endif
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index c5a55d2..7541f0b 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -1,438 +1,440 @@
/***************************************************************************
settingsimpl.cpp - description
-------------------
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 <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qpushbutton.h>
#include <opie/otabwidget.h>
#ifdef QWS
#include <qpe/config.h>
#include <qpe/resource.h>
#endif
#include "settingsimpl.h"
#include "global.h"
SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
setCaption( tr( "Configuration" ) );
// Setup layout to make everything pretty
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Setup tabs for all info
OTabWidget *tabwidget = new OTabWidget( this );
layout->addWidget( tabwidget );
tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) );
tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) );
tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) );
tabwidget->setCurrentTab( tr( "Servers" ) );
dataMgr = dataManager;
setupData();
changed = false;
newserver = false;
newdestination = false;
}
SettingsImpl :: ~SettingsImpl()
{
}
bool SettingsImpl :: showDlg()
{
showMaximized();
exec();
if ( changed )
dataMgr->writeOutIpkgConf();
return changed;
}
QWidget *SettingsImpl :: initServerTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
servers = new QListBox( container );
servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) );
layout->addMultiCellWidget( servers, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) );
layout->addWidget( btn, 1, 0 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) );
layout->addWidget( btn, 1, 1 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
QLabel *label = new QLabel( tr( "Name:" ), grpbox );
grplayout->addWidget( label, 0, 0 );
servername = new QLineEdit( grpbox );
grplayout->addWidget( servername, 0, 1 );
label = new QLabel( tr( "Address:" ), grpbox );
grplayout->addWidget( label, 1, 0 );
serverurl = new QLineEdit( grpbox );
grplayout->addWidget( serverurl, 1, 1 );
active = new QCheckBox( tr( "Active Server" ), grpbox );
grplayout->addMultiCellWidget( active, 2, 2, 0, 1 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) );
grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
return control;
}
QWidget *SettingsImpl :: initDestinationTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
destinations = new QListBox( container );
destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) );
layout->addMultiCellWidget( destinations, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) );
layout->addWidget( btn, 1, 0 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) );
layout->addWidget( btn, 1, 1 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
QLabel *label = new QLabel( tr( "Name:" ), grpbox );
grplayout->addWidget( label, 0, 0 );
destinationname = new QLineEdit( grpbox );
grplayout->addWidget( destinationname, 0, 1 );
label = new QLabel( tr( "Location:" ), grpbox );
grplayout->addWidget( label, 1, 0 );
destinationurl = new QLineEdit( grpbox );
grplayout->addWidget( destinationurl, 1, 1 );
linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox );
grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) );
grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
return control;
}
QWidget *SettingsImpl :: initProxyTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
txtHttpProxy = new QLineEdit( grpbox );
grplayout->addWidget( txtHttpProxy );
chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
grplayout->addWidget( chkHttpProxyEnabled );
grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
grplayout = new QVBoxLayout( grpbox->layout() );
txtFtpProxy = new QLineEdit( grpbox );
grplayout->addWidget( txtFtpProxy );
chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
grplayout->addWidget( chkFtpProxyEnabled );
QLabel *label = new QLabel( tr( "Username:" ), container );
layout->addWidget( label, 2, 0 );
txtUsername = new QLineEdit( container );
layout->addWidget( txtUsername, 2, 1 );
label = new QLabel( tr( "Password:" ), container );
layout->addWidget( label, 3, 0 );
txtPassword = new QLineEdit( container );
layout->addWidget( txtPassword, 3, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
return control;
}
void SettingsImpl :: setupData()
{
// add servers
- vector<Server>::iterator it;
- for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it )
+ QString serverName;
+ QListIterator<Server> it( dataMgr->getServerList() );
+ for ( ; it.current(); ++it )
{
- if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS )
+ serverName = it.current()->getServerName();
+ if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
continue;
- servers->insertItem( it->getServerName() );
+ servers->insertItem( serverName );
}
// add destinations
- vector<Destination>::iterator it2;
- for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 )
- destinations->insertItem( it2->getDestinationName() );
+ QListIterator<Destination> it2( dataMgr->getDestinationList() );
+ for ( ; it2.current(); ++it2 )
+ destinations->insertItem( it2.current()->getDestinationName() );
// setup proxy tab
txtHttpProxy->setText( dataMgr->getHttpProxy() );
txtFtpProxy->setText( dataMgr->getFtpProxy() );
txtUsername->setText( dataMgr->getProxyUsername() );
txtPassword->setText( dataMgr->getProxyPassword() );
chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
}
//------------------ Servers tab ----------------------
void SettingsImpl :: editServer( int sel )
{
currentSelectedServer = sel;
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
+ Server *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;
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
- dataMgr->getServerList().erase( s );
+ Server *s = dataMgr->getServer( servers->currentText() );
+ dataMgr->getServerList().removeRef( s );
servers->removeItem( currentSelectedServer );
}
void SettingsImpl :: changeServerDetails()
{
changed = true;
QString newName = servername->text();
if ( !newserver )
{
- vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
+ Server *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 );
// Update list box
servers->changeItem( newName, currentSelectedServer );
}
}
else
{
Server s( newName, serverurl->text() );
- dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) );
- dataMgr->getServerList().end()->setActive( active->isChecked() );
+ dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
+ dataMgr->getServerList().last()->setActive( active->isChecked() );
servers->insertItem( newName );
servers->setCurrentItem( servers->count() );
newserver = false;
}
}
//------------------ Destinations tab ----------------------
void SettingsImpl :: editDestination( int sel )
{
currentSelectedDestination = sel;
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
+ Destination *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;
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
- dataMgr->getDestinationList().erase( d );
+ Destination *d = dataMgr->getDestination( destinations->currentText() );
+ dataMgr->getDestinationList().removeRef( d );
destinations->removeItem( currentSelectedDestination );
}
void SettingsImpl :: changeDestinationDetails()
{
changed = true;
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "destinations" );
#endif
QString newName = destinationname->text();
if ( !newdestination )
{
- vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
+ Destination *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;
key += "_linkToRoot";
int val = d->linkToRoot();
cfg.writeEntry( key, val );
#endif
}
else
{
- dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) );
+ dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) );
destinations->insertItem( newName );
destinations->setCurrentItem( destinations->count() );
newdestination = false;
#ifdef QWS
QString key = newName;
key += "_linkToRoot";
cfg.writeEntry( key, true );
#endif
}
}
//------------------ Proxy tab ----------------------
void SettingsImpl :: proxyApplyChanges()
{
changed = true;
dataMgr->setHttpProxy( txtHttpProxy->text() );
dataMgr->setFtpProxy( txtFtpProxy->text() );
dataMgr->setProxyUsername( txtUsername->text() );
dataMgr->setProxyPassword( txtPassword->text() );
dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() );
dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() );
}