summaryrefslogtreecommitdiff
authordrw <drw>2003-02-06 01:19:25 (UTC)
committer drw <drw>2003-02-06 01:19:25 (UTC)
commit79588befde53765db0a92977c6890a4d226096e7 (patch) (unidiff)
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) (ignore 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.cpp84
-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.cpp75
-rw-r--r--noncore/settings/aqpkg/server.h8
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp38
9 files changed, 245 insertions, 214 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
@@ -32,56 +32,53 @@ using namespace std;
32 32
33 33
34QString DataManager::availableCategories = ""; 34QString DataManager::availableCategories = "";
35DataManager::DataManager() 35DataManager::DataManager()
36 : QObject( 0x0, 0x0 ) 36 : QObject( 0x0, 0x0 )
37{ 37{
38 activeServer = ""; 38 activeServer = "";
39 availableCategories = "#"; 39 availableCategories = "#";
40
41 serverList.setAutoDelete( TRUE );
42 destList.setAutoDelete( TRUE );
40} 43}
41 44
42DataManager::~DataManager() 45DataManager::~DataManager()
43{ 46{
44} 47}
45 48
46vector<Server>::iterator DataManager :: getServer( const char *name ) 49Server *DataManager :: getServer( const char *name )
47{ 50{
48 vector<Server>::iterator it = serverList.begin(); 51 QListIterator<Server> it( serverList );
49 while ( it != serverList.end() ) 52 while ( it.current() && it.current()->getServerName() != name )
50 { 53 {
51 if ( it->getServerName() == name )
52 return it;
53
54 ++it; 54 ++it;
55 } 55 }
56 56
57 return serverList.end(); 57 return it.current();
58} 58}
59 59
60vector<Destination>::iterator DataManager :: getDestination( const char *name ) 60Destination *DataManager :: getDestination( const char *name )
61{ 61{
62 vector<Destination>::iterator it = destList.begin(); 62 QListIterator<Destination> it( destList );
63 while ( it != destList.end() ) 63 while ( it.current() && it.current()->getDestinationName() != name )
64 { 64 {
65 if ( it->getDestinationName() == name )
66 return it;
67
68 ++it; 65 ++it;
69 } 66 }
70 67
71 return destList.end(); 68 return it.current();
72} 69}
73 70
74void DataManager :: loadServers() 71void DataManager :: loadServers()
75{ 72{
76 // First add our local server - not really a server but 73 // First add our local server - not really a server but
77 // the local config (which packages are installed) 74 // the local config (which packages are installed)
78 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 75 serverList.append( new Server( LOCAL_SERVER, "" ) );
79 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 76 serverList.append( new Server( LOCAL_IPKGS, "" ) );
80 77
81#ifdef QWS 78#ifdef QWS
82 Config cfg( "aqpkg" ); 79 Config cfg( "aqpkg" );
83 cfg.setGroup( "destinations" ); 80 cfg.setGroup( "destinations" );
84#endif 81#endif
85 82
86 // Read file from /etc/ipkg.conf 83 // Read file from /etc/ipkg.conf
87 QString ipkg_conf = IPKG_CONF; 84 QString ipkg_conf = IPKG_CONF;
@@ -104,40 +101,40 @@ void DataManager :: loadServers()
104 char alias[20]; 101 char alias[20];
105 char url[100]; 102 char url[100];
106 103
107 // Looks a little wierd but read up to the r of src (throwing it away), 104 // Looks a little wierd but read up to the r of src (throwing it away),
108 // then read up to the next space and throw that away, the alias 105 // then read up to the next space and throw that away, the alias
109 // is next. 106 // is next.
110 // Should Handle #src, # src, src, and combinations of 107 // Should Handle #src, # src, src, and combinations of
111 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
112 Server s( alias, url ); 109 Server *s = new Server( alias, url );
113 if ( lineStr.startsWith( "src" ) ) 110 if ( lineStr.startsWith( "src" ) )
114 s.setActive( true ); 111 s->setActive( true );
115 else 112 else
116 s.setActive( false ); 113 s->setActive( false );
117 114
118 serverList.push_back( s ); 115 serverList.append( s );
119 116
120 } 117 }
121 else if ( lineStr.startsWith( "dest" ) ) 118 else if ( lineStr.startsWith( "dest" ) )
122 { 119 {
123 char alias[20]; 120 char alias[20];
124 char path[50]; 121 char path[50];
125 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 122 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
126 Destination d( alias, path ); 123 Destination *d = new Destination( alias, path );
127 bool linkToRoot = true; 124 bool linkToRoot = true;
128#ifdef QWS 125#ifdef QWS
129 QString key = alias; 126 QString key = alias;
130 key += "_linkToRoot"; 127 key += "_linkToRoot";
131 linkToRoot = cfg.readBoolEntry( key, true ); 128 linkToRoot = cfg.readBoolEntry( key, true );
132#endif 129#endif
133 d.linkToRoot( linkToRoot ); 130 d->linkToRoot( linkToRoot );
134 131
135 destList.push_back( d ); 132 destList.append( d );
136 } 133 }
137 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) 134 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
138 { 135 {
139 char type[20]; 136 char type[20];
140 char val[100]; 137 char val[100];
141 sscanf( lineStr, "%*[^ ] %s %s", type, val ); 138 sscanf( lineStr, "%*[^ ] %s %s", type, val );
142 if ( stricmp( type, "http_proxy" ) == 0 ) 139 if ( stricmp( type, "http_proxy" ) == 0 )
143 { 140 {
@@ -164,40 +161,43 @@ void DataManager :: loadServers()
164 } 161 }
165 fclose( fp ); 162 fclose( fp );
166 163
167 reloadServerData( ); 164 reloadServerData( );
168} 165}
169 166
170void DataManager :: reloadServerData( ) 167void DataManager :: reloadServerData( )
171{ 168{
172 emit progressSetSteps( serverList.size() ); 169 emit progressSetSteps( serverList.count() );
173 emit progressSetMessage( tr( "Reading configuration..." ) ); 170 emit progressSetMessage( tr( "Reading configuration..." ) );
174 171
175 vector<Server>::iterator it = serverList.begin();
176 QString serverName; 172 QString serverName;
177 int i = 0; 173 int i = 0;
178 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 174
175 Server *server;
176 QListIterator<Server> it( serverList );
177 for ( ; it.current(); ++it )
179 { 178 {
180 serverName = it->getServerName(); 179 server = it.current();
180 serverName = server->getServerName();
181 i++; 181 i++;
182 emit progressUpdate( i ); 182 emit progressUpdate( i );
183 qApp->processEvents(); 183 qApp->processEvents();
184 184
185 // Now we've read the config file in we need to read the servers 185 // Now we've read the config file in we need to read the servers
186 // The local server is a special case. This holds the contents of the 186 // The local server is a special case. This holds the contents of the
187 // status files the number of which depends on how many destinations 187 // status files the number of which depends on how many destinations
188 // we've set up 188 // we've set up
189 // The other servers files hold the contents of the server package list 189 // The other servers files hold the contents of the server package list
190 if ( serverName == LOCAL_SERVER ) 190 if ( serverName == LOCAL_SERVER )
191 it->readStatusFile( destList ); 191 server->readStatusFile( destList );
192 else if ( serverName == LOCAL_IPKGS ) 192 else if ( serverName == LOCAL_IPKGS )
193 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); 193 server->readLocalIpks( getServer( LOCAL_SERVER ) );
194 else 194 else
195 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); 195 server->readPackageFile( getServer( LOCAL_SERVER ) );
196 } 196 }
197} 197}
198 198
199void DataManager :: writeOutIpkgConf() 199void DataManager :: writeOutIpkgConf()
200{ 200{
201 QString ipkg_conf = IPKG_CONF; 201 QString ipkg_conf = IPKG_CONF;
202 ofstream out( ipkg_conf ); 202 ofstream out( ipkg_conf );
203 203
@@ -212,41 +212,43 @@ void DataManager :: writeOutIpkgConf()
212 out << "#" << endl; 212 out << "#" << endl;
213 out << "# where <src-name> and <dest-names> are identifiers that" << endl; 213 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
214 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; 214 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
215 out << "# URL that points to a directory containing a Familiar" << endl; 215 out << "# URL that points to a directory containing a Familiar" << endl;
216 out << "# Packages file, and <target-path> should be a directory" << endl; 216 out << "# Packages file, and <target-path> should be a directory" << endl;
217 out << "# that exists on the target system." << endl << endl; 217 out << "# that exists on the target system." << endl << endl;
218 218
219 // Write out servers 219 // Write out servers
220 vector<Server>::iterator it = serverList.begin(); 220 Server *server;
221 while ( it != serverList.end() ) 221 QListIterator<Server> it( serverList );
222 while ( it.current() )
222 { 223 {
223 QString alias = it->getServerName(); 224 server = it.current();
225 QString alias = server->getServerName();
224 // Don't write out local as its a dummy 226 // Don't write out local as its a dummy
225 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 227 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
226 { 228 {
227 QString url = it->getServerUrl();; 229 QString url = server->getServerUrl();;
228 230
229 if ( !it->isServerActive() ) 231 if ( !server->isServerActive() )
230 out << "#"; 232 out << "#";
231 out << "src " << alias << " " << url << endl; 233 out << "src " << alias << " " << url << endl;
232 } 234 }
233 235
234 it++; 236 ++it;
235 } 237 }
236 238
237 out << endl; 239 out << endl;
238 240
239 // Write out destinations 241 // Write out destinations
240 vector<Destination>::iterator it2 = destList.begin(); 242 QListIterator<Destination> it2( destList );
241 while ( it2 != destList.end() ) 243 while ( it2.current() )
242 { 244 {
243 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 245 out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl;
244 it2++; 246 ++it2;
245 } 247 }
246 248
247 out << endl; 249 out << endl;
248 out << "# Proxy Support" << endl; 250 out << "# Proxy Support" << endl;
249 251
250 if ( !httpProxyEnabled && httpProxy == "" ) 252 if ( !httpProxyEnabled && httpProxy == "" )
251 out << "#option http_proxy http://proxy.tld:3128" << endl; 253 out << "#option http_proxy http://proxy.tld:3128" << endl;
252 else 254 else
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
@@ -16,16 +16,17 @@
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef DATAMGR_H 18#ifndef DATAMGR_H
19#define DATAMGR_H 19#define DATAMGR_H
20 20
21#include <map> 21#include <map>
22using namespace std; 22using namespace std;
23 23
24#include <qlist.h>
24#include <qobject.h> 25#include <qobject.h>
25#include <qstring.h> 26#include <qstring.h>
26 27
27#include "server.h" 28#include "server.h"
28#include "destination.h" 29#include "destination.h"
29 30
30 #define LOCAL_SERVER "Installed Pkgs" 31 #define LOCAL_SERVER "Installed Pkgs"
31 #define LOCAL_IPKGS "local IPKG" 32 #define LOCAL_IPKGS "local IPKG"
@@ -40,22 +41,22 @@ class DataManager : public QObject
40 Q_OBJECT 41 Q_OBJECT
41public: 42public:
42 DataManager(); 43 DataManager();
43 ~DataManager(); 44 ~DataManager();
44 45
45 void setActiveServer( const QString &act ) { activeServer = act; } 46 void setActiveServer( const QString &act ) { activeServer = act; }
46 QString &getActiveServer( ) { return activeServer; } 47 QString &getActiveServer( ) { return activeServer; }
47 48
48 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } 49 Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); }
49 vector<Server> &getServerList() { return serverList; } 50 QList<Server> &getServerList() { return serverList; }
50 vector<Server>::iterator getServer( const char *name ); 51 Server *getServer( const char *name );
51 52
52 vector<Destination> &getDestinationList() { return destList; } 53 QList<Destination> &getDestinationList() { return destList; }
53 vector<Destination>::iterator getDestination( const char *name ); 54 Destination *getDestination( const char *name );
54 55
55 void loadServers(); 56 void loadServers();
56 void reloadServerData( ); 57 void reloadServerData( );
57 58
58 void writeOutIpkgConf(); 59 void writeOutIpkgConf();
59 60
60 static QString getAvailableCategories() { return availableCategories; } 61 static QString getAvailableCategories() { return availableCategories; }
61 static void setAvailableCategories( QString section ); 62 static void setAvailableCategories( QString section );
@@ -81,18 +82,18 @@ private:
81 QString httpProxy; 82 QString httpProxy;
82 QString ftpProxy; 83 QString ftpProxy;
83 QString proxyUsername; 84 QString proxyUsername;
84 QString proxyPassword; 85 QString proxyPassword;
85 86
86 bool httpProxyEnabled; 87 bool httpProxyEnabled;
87 bool ftpProxyEnabled; 88 bool ftpProxyEnabled;
88 89
89 vector<Server> serverList; 90 QList<Server> serverList;
90 vector<Destination> destList; 91 QList<Destination> destList;
91 92
92signals: 93signals:
93 void progressSetSteps( int ); 94 void progressSetSteps( int );
94 void progressSetMessage( const QString & ); 95 void progressSetMessage( const QString & );
95 void progressUpdate( int ); 96 void progressUpdate( int );
96}; 97};
97 98
98#endif 99#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
@@ -36,26 +36,25 @@
36#include "datamgr.h" 36#include "datamgr.h"
37#include "destination.h" 37#include "destination.h"
38#include "instoptionsimpl.h" 38#include "instoptionsimpl.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "utils.h" 41#include "utils.h"
42#include "global.h" 42#include "global.h"
43 43
44InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title ) 44InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
45 : QWidget( 0, 0, 0 ) 45 : QWidget( 0, 0, 0 )
46{ 46{
47 setCaption( title ); 47 setCaption( title );
48 init( TRUE ); 48 init( TRUE );
49 49
50 pIpkg = 0; 50 pIpkg = 0;
51 upgradePackages = false; 51 upgradePackages = false;
52 dataMgr = dataManager; 52 dataMgr = dataManager;
53 vector<Destination>::iterator dit;
54 53
55 QString defaultDest = "root"; 54 QString defaultDest = "root";
56#ifdef QWS 55#ifdef QWS
57 Config cfg( "aqpkg" ); 56 Config cfg( "aqpkg" );
58 cfg.setGroup( "settings" ); 57 cfg.setGroup( "settings" );
59 defaultDest = cfg.readEntry( "dest", "root" ); 58 defaultDest = cfg.readEntry( "dest", "root" );
60 59
61 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 60 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
@@ -69,55 +68,62 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
69 //QFont f( "helvetica" ); 68 //QFont f( "helvetica" );
70 //f.setPointSize( 10 ); 69 //f.setPointSize( 10 );
71 //output->setFont( f ); 70 //output->setFont( f );
72 71
73 72
74 // setup destination data 73 // setup destination data
75 int defIndex = 0; 74 int defIndex = 0;
76 int i; 75 int i;
77 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) 76 QListIterator<Destination> dit( dataMgr->getDestinationList() );
77 for ( i = 0; dit.current(); ++dit, ++i )
78 { 78 {
79 destination->insertItem( dit->getDestinationName() ); 79 destination->insertItem( dit.current()->getDestinationName() );
80 if ( dit->getDestinationName() == defaultDest ) 80 if ( dit.current()->getDestinationName() == defaultDest )
81 defIndex = i; 81 defIndex = i;
82 } 82 }
83 83
84 destination->setCurrentItem( defIndex ); 84 destination->setCurrentItem( defIndex );
85 85
86 vector<InstallData>::iterator it; 86 QListIterator<InstallData> it( packageList );
87 // setup package data 87 // setup package data
88 QString remove = tr( "Remove\n" ); 88 QString remove = tr( "Remove\n" );
89 QString install = tr( "Install\n" ); 89 QString install = tr( "Install\n" );
90 QString upgrade = tr( "Upgrade\n" ); 90 QString upgrade = tr( "Upgrade\n" );
91 for ( it = packageList.begin() ; it != packageList.end() ; ++it ) 91 for ( ; it.current(); ++it )
92 { 92 {
93 InstallData item = *it; 93 InstallData *item = it.current();
94 if ( item.option == "I" ) 94 InstallData *newitem = new InstallData();
95
96 newitem->option = item->option;
97 newitem->packageName = item->packageName;
98 newitem->destination = item->destination;
99 newitem->recreateLinks = item->recreateLinks;
100
101 if ( item->option == "I" )
95 { 102 {
96 installList.push_back( item ); 103 installList.append( newitem );
97 install.append( QString( " %1\n" ).arg( item.packageName ) ); 104 install.append( QString( " %1\n" ).arg( item->packageName ) );
98 } 105 }
99 else if ( item.option == "D" ) 106 else if ( item->option == "D" )
100 { 107 {
101 removeList.push_back( item ); 108 removeList.append( newitem );
102 remove.append( QString( " %1\n" ).arg( item.packageName ) ); 109 remove.append( QString( " %1\n" ).arg( item->packageName ) );
103 } 110 }
104 else if ( item.option == "U" || item.option == "R" ) 111 else if ( item->option == "U" || item->option == "R" )
105 { 112 {
106 updateList.push_back( item ); 113 updateList.append( newitem );
107 QString type; 114 QString type;
108 if ( item.option == "R" ) 115 if ( item->option == "R" )
109 type = tr( "(ReInstall)" ); 116 type = tr( "(ReInstall)" );
110 else 117 else
111 type = tr( "(Upgrade)" ); 118 type = tr( "(Upgrade)" );
112 upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); 119 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
113 } 120 }
114 } 121 }
115
116 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); 122 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
117 123
118 displayAvailableSpace( destination->currentText() ); 124 displayAvailableSpace( destination->currentText() );
119} 125}
120 126
121InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 127InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
122 : QWidget( 0, 0, 0 ) 128 : QWidget( 0, 0, 0 )
123{ 129{
@@ -208,33 +214,33 @@ void InstallDlgImpl :: installSelected()
208 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 214 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
209 return; 215 return;
210 } 216 }
211 else if ( btnInstall->text() == tr( "Close" ) ) 217 else if ( btnInstall->text() == tr( "Close" ) )
212 { 218 {
213 emit reloadData( this ); 219 emit reloadData( this );
214 return; 220 return;
215 } 221 }
216 222
217 // Disable buttons 223 // Disable buttons
218 btnOptions->setEnabled( false ); 224 btnOptions->setEnabled( false );
219// btnInstall->setEnabled( false ); 225// btnInstall->setEnabled( false );
220 226
221 btnInstall->setText( tr( "Abort" ) ); 227 btnInstall->setText( tr( "Abort" ) );
222 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 228 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
223 if ( pIpkg ) 229 if ( pIpkg )
224 { 230 {
225 output->setText( "" ); 231 output->setText( "" );
226 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 232 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
227 pIpkg->runIpkg(); 233 pIpkg->runIpkg();
228 } 234 }
229 else 235 else
230 { 236 {
231 output->setText( "" ); 237 output->setText( "" );
232 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); 238 Destination *d = dataMgr->getDestination( destination->currentText() );
233 QString dest = d->getDestinationName(); 239 QString dest = d->getDestinationName();
234 QString destDir = d->getDestinationPath(); 240 QString destDir = d->getDestinationPath();
235 int instFlags = flags; 241 int instFlags = flags;
236 if ( d->linkToRoot() ) 242 if ( d->linkToRoot() )
237 instFlags |= MAKE_LINKS; 243 instFlags |= MAKE_LINKS;
238 244
239#ifdef QWS 245#ifdef QWS
240 // Save settings 246 // Save settings
@@ -242,55 +248,60 @@ void InstallDlgImpl :: installSelected()
242 cfg.setGroup( "settings" ); 248 cfg.setGroup( "settings" );
243 cfg.writeEntry( "dest", dest ); 249 cfg.writeEntry( "dest", dest );
244#endif 250#endif
245 251
246 pIpkg = new Ipkg; 252 pIpkg = new Ipkg;
247 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 253 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
248 254
249 // First run through the remove list, then the install list then the upgrade list 255 // First run through the remove list, then the install list then the upgrade list
250 vector<InstallData>::iterator it;
251 pIpkg->setOption( "remove" ); 256 pIpkg->setOption( "remove" );
252 for ( it = removeList.begin() ; it != removeList.end() ; ++it ) 257 QListIterator<InstallData> it( removeList );
258 InstallData *idata;
259 for ( ; it.current(); ++it )
253 { 260 {
254 pIpkg->setDestination( it->destination->getDestinationName() ); 261 idata = it.current();
255 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 262 pIpkg->setDestination( idata->destination->getDestinationName() );
256 pIpkg->setPackage( it->packageName ); 263 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
264 pIpkg->setPackage( idata->packageName );
257 265
258 int tmpFlags = flags; 266 int tmpFlags = flags;
259 if ( it->destination->linkToRoot() ) 267 if ( idata->destination->linkToRoot() )
260 tmpFlags |= MAKE_LINKS; 268 tmpFlags |= MAKE_LINKS;
261 269
262 pIpkg->setFlags( tmpFlags ); 270 pIpkg->setFlags( tmpFlags );
263 pIpkg->runIpkg(); 271 pIpkg->runIpkg();
264 } 272 }
265 273
266 pIpkg->setOption( "install" ); 274 pIpkg->setOption( "install" );
267 pIpkg->setDestination( dest ); 275 pIpkg->setDestination( dest );
268 pIpkg->setDestinationDir( destDir ); 276 pIpkg->setDestinationDir( destDir );
269 pIpkg->setFlags( instFlags ); 277 pIpkg->setFlags( instFlags );
270 for ( it = installList.begin() ; it != installList.end() ; ++it ) 278 QListIterator<InstallData> it2( installList );
279 for ( ; it2.current(); ++it2 )
271 { 280 {
272 pIpkg->setPackage( it->packageName ); 281 pIpkg->setPackage( it2.current()->packageName );
273 pIpkg->runIpkg(); 282 pIpkg->runIpkg();
274 } 283 }
275 284
276 flags |= FORCE_REINSTALL; 285 flags |= FORCE_REINSTALL;
277 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 286 QListIterator<InstallData> it3( updateList );
287 for ( ; it3.current() ; ++it3 )
278 { 288 {
279 if ( it->option == "R" ) 289 idata = it3.current();
290 if ( idata->option == "R" )
280 pIpkg->setOption( "reinstall" ); 291 pIpkg->setOption( "reinstall" );
281 else 292 else
282 pIpkg->setOption( "upgrade" ); 293 pIpkg->setOption( "upgrade" );
283 pIpkg->setDestination( it->destination->getDestinationName() ); 294 pIpkg->setDestination( idata->destination->getDestinationName() );
284 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 295 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
285 pIpkg->setPackage( it->packageName ); 296 pIpkg->setPackage( idata->packageName );
286 297
287 int tmpFlags = flags; 298 int tmpFlags = flags;
288 if ( it->destination->linkToRoot() && it->recreateLinks ) 299 if ( idata->destination->linkToRoot() && idata->recreateLinks )
289 tmpFlags |= MAKE_LINKS; 300 tmpFlags |= MAKE_LINKS;
290 pIpkg->setFlags( tmpFlags ); 301 pIpkg->setFlags( tmpFlags );
291 pIpkg->runIpkg(); 302 pIpkg->runIpkg();
292 } 303 }
293 304
294 delete pIpkg; 305 delete pIpkg;
295 pIpkg = 0; 306 pIpkg = 0;
296 } 307 }
@@ -302,26 +313,25 @@ void InstallDlgImpl :: installSelected()
302 313
303 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 314 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
304 displayAvailableSpace( destination->currentText() ); 315 displayAvailableSpace( destination->currentText() );
305} 316}
306 317
307 318
308void InstallDlgImpl :: displayText(const QString &text ) 319void InstallDlgImpl :: displayText(const QString &text )
309{ 320{
310 //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) );
311 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 321 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
312 output->setText( newtext ); 322 output->setText( newtext );
313 output->setCursorPosition( output->numLines(), 0 ); 323 output->setCursorPosition( output->numLines(), 0 );
314} 324}
315 325
316 326
317void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 327void InstallDlgImpl :: displayAvailableSpace( const QString &text )
318{ 328{
319 vector<Destination>::iterator d = dataMgr->getDestination( text ); 329 Destination *d = dataMgr->getDestination( text );
320 QString destDir = d->getDestinationPath(); 330 QString destDir = d->getDestinationPath();
321 331
322 long blockSize = 0; 332 long blockSize = 0;
323 long totalBlocks = 0; 333 long totalBlocks = 0;
324 long availBlocks = 0; 334 long availBlocks = 0;
325 QString space; 335 QString space;
326 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 336 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
327 { 337 {
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
@@ -12,21 +12,21 @@
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#ifndef INSTALLDLGIMPL_H 17#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H 18#define INSTALLDLGIMPL_H
19 19
20#include <vector>
21using namespace std; 20using namespace std;
22 21
23#include <qwidget.h> 22#include <qlist.h>
24#include <qstring.h> 23#include <qstring.h>
24#include <qwidget.h>
25 25
26class QComboBox; 26class QComboBox;
27class QLabel; 27class QLabel;
28class QMultiLineEdit; 28class QMultiLineEdit;
29class QPushButton; 29class QPushButton;
30 30
31class DataManager; 31class DataManager;
32class Destination; 32class Destination;
@@ -40,29 +40,29 @@ public:
40 Destination *destination; 40 Destination *destination;
41 bool recreateLinks; 41 bool recreateLinks;
42}; 42};
43 43
44class InstallDlgImpl : public QWidget 44class InstallDlgImpl : public QWidget
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47public: 47public:
48 InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); 48 InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); 49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
50 ~InstallDlgImpl(); 50 ~InstallDlgImpl();
51 51
52 bool upgradeServer( QString &server ); 52 bool upgradeServer( QString &server );
53 53
54protected: 54protected:
55 55
56private: 56private:
57 DataManager *dataMgr; 57 DataManager *dataMgr;
58 vector<InstallData> installList; 58 QList<InstallData> installList;
59 vector<InstallData> removeList; 59 QList<InstallData> removeList;
60 vector<InstallData> updateList; 60 QList<InstallData> updateList;
61 int flags; 61 int flags;
62 Ipkg *pIpkg; 62 Ipkg *pIpkg;
63 bool upgradePackages; 63 bool upgradePackages;
64 64
65 QComboBox *destination; 65 QComboBox *destination;
66 QPushButton *btnInstall; 66 QPushButton *btnInstall;
67 QPushButton *btnOptions; 67 QPushButton *btnOptions;
68 QMultiLineEdit *output; 68 QMultiLineEdit *output;
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
@@ -538,34 +538,38 @@ void MainWindow :: setProgressMessage( const QString &msg )
538 538
539void MainWindow :: updateProgress( int progress ) 539void MainWindow :: updateProgress( int progress )
540{ 540{
541 m_progress->setProgress( progress ); 541 m_progress->setProgress( progress );
542} 542}
543 543
544void MainWindow :: updateData() 544void MainWindow :: updateData()
545{ 545{
546 m_progress->setTotalSteps( mgr->getServerList().size() ); 546 m_progress->setTotalSteps( mgr->getServerList().count() );
547 547
548 serversList->clear(); 548 serversList->clear();
549 packagesList->clear(); 549 packagesList->clear();
550 550
551 vector<Server>::iterator it;
552 int activeItem = -1; 551 int activeItem = -1;
553 int i; 552 int i = 0;
554 QString serverName; 553 QString serverName;
555 for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) 554
555 QListIterator<Server> it( mgr->getServerList() );
556 Server *server;
557
558 for ( ; it.current(); ++it, ++i )
556 { 559 {
557 serverName = it->getServerName(); 560 server = it.current();
561 serverName = server->getServerName();
558 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 562 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
559 m_progress->setProgress( i ); 563 m_progress->setProgress( i );
560 qApp->processEvents(); 564 qApp->processEvents();
561 565
562// cout << "Adding " << it->getServerName() << " to combobox" << endl; 566// cout << "Adding " << it->getServerName() << " to combobox" << endl;
563 if ( !it->isServerActive() ) 567 if ( !server->isServerActive() )
564 { 568 {
565// cout << serverName << " is not active" << endl; 569// cout << serverName << " is not active" << endl;
566 i--; 570 i--;
567 continue; 571 continue;
568 } 572 }
569 573
570 serversList->insertItem( serverName ); 574 serversList->insertItem( serverName );
571 if ( serverName == currentlySelectedServer ) 575 if ( serverName == currentlySelectedServer )
@@ -587,142 +591,146 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
587{ 591{
588 QPixmap nullIcon( installedIcon.size() ); 592 QPixmap nullIcon( installedIcon.size() );
589 nullIcon.fill( colorGroup().base() ); 593 nullIcon.fill( colorGroup().base() );
590 594
591 // display packages 595 // display packages
592 QString serverName = serversList->currentText(); 596 QString serverName = serversList->currentText();
593 currentlySelectedServer = serverName; 597 currentlySelectedServer = serverName;
594 598
595 vector<Server>::iterator s = mgr->getServer( serverName ); 599 Server *s = mgr->getServer( serverName );
596 600
597 vector<Package> &list = s->getPackageList(); 601 QList<Package> &list = s->getPackageList();
598 vector<Package>::iterator it; 602 QListIterator<Package> it( list );
599 603
600 // Display progress widget while loading list 604 // Display progress widget while loading list
601 bool doProgress = ( list.size() > 200 ); 605 bool doProgress = ( list.count() > 200 );
602 if ( doProgress ) 606 if ( doProgress )
603 { 607 {
604 if ( raiseProgress ) 608 if ( raiseProgress )
605 { 609 {
606 stack->raiseWidget( progressWindow ); 610 stack->raiseWidget( progressWindow );
607 } 611 }
608 m_progress->setTotalSteps( list.size() ); 612 m_progress->setTotalSteps( list.count() );
609 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 613 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
610 } 614 }
611 615
612 packagesList->clear(); 616 packagesList->clear();
613 617
614#ifdef QWS 618#ifdef QWS
615 // read download directory from config file 619 // read download directory from config file
616 Config cfg( "aqpkg" ); 620 Config cfg( "aqpkg" );
617 cfg.setGroup( "settings" ); 621 cfg.setGroup( "settings" );
618 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 622 cfg.writeEntry( "selectedServer", currentlySelectedServer );
619#endif 623#endif
620 624
621 int i = 0; 625 int i = 0;
622 for ( it = list.begin() ; it != list.end() ; ++it ) 626 Package *package;
627 for ( ; it.current(); ++it )
623 { 628 {
624 // Update progress after every 100th package (arbitrary value, seems to give good balance) 629 // Update progress after every 100th package (arbitrary value, seems to give good balance)
625 i++; 630 i++;
626 if ( ( i % 100 ) == 0 ) 631 if ( ( i % 100 ) == 0 )
627 { 632 {
628 if ( doProgress ) 633 if ( doProgress )
629 { 634 {
630 m_progress->setProgress( i ); 635 m_progress->setProgress( i );
631 } 636 }
632 qApp->processEvents(); 637 qApp->processEvents();
633 } 638 }
634 639
635 QString text = ""; 640 QString text = "";
641
642 package = it.current();
636 643
637 // Apply show only uninstalled packages filter 644 // Apply show only uninstalled packages filter
638 if ( showUninstalledPkgs && it->isInstalled() ) 645 if ( showUninstalledPkgs && package->isInstalled() )
639 continue; 646 continue;
640 647
641 // Apply show only installed packages filter 648 // Apply show only installed packages filter
642 if ( showInstalledPkgs && !it->isInstalled() ) 649 if ( showInstalledPkgs && !package->isInstalled() )
643 continue; 650 continue;
644 651
645 // Apply show only new installed packages filter 652 // Apply show only new installed packages filter
646 if ( showUpgradedPkgs ) 653 if ( showUpgradedPkgs )
647 { 654 {
648 if ( !it->isInstalled() || 655 if ( !package->isInstalled() ||
649 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 656 compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 )
650 continue; 657 continue;
651 } 658 }
652 659
653 // Apply the section filter 660 // Apply the section filter
654 if ( categoryFilterEnabled && categoryFilter != "" ) 661 if ( categoryFilterEnabled && categoryFilter != "" )
655 { 662 {
656 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) 663 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
657 continue; 664 continue;
658 } 665 }
659 666
660 // If the local server, only display installed packages 667 // If the local server, only display installed packages
661 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 668 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
662 continue; 669 continue;
663 670
664 671
665 QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); 672 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
673 QCheckListItem::CheckBox );
666 674
667 if ( it->isInstalled() ) 675 if ( package->isInstalled() )
668 { 676 {
669 // If a different version of package is available, show update available icon 677 // If a different version of package is available, show update available icon
670 // Otherwise, show installed icon 678 // Otherwise, show installed icon
671 if ( it->getVersion() != it->getInstalledVersion() && 679 if ( package->getVersion() != package->getInstalledVersion() &&
672 compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) 680 compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1)
673 { 681 {
674 682
675 item->setPixmap( 0, updatedIcon ); 683 item->setPixmap( 0, updatedIcon );
676 } 684 }
677 else 685 else
678 { 686 {
679 item->setPixmap( 0, installedIcon ); 687 item->setPixmap( 0, installedIcon );
680 } 688 }
681 689
682 QString destName = ""; 690 QString destName = "";
683 if ( it->getLocalPackage() ) 691 if ( package->getLocalPackage() )
684 { 692 {
685 if ( it->getLocalPackage()->getInstalledTo() ) 693 if ( package->getLocalPackage()->getInstalledTo() )
686 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 694 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
687 } 695 }
688 else 696 else
689 { 697 {
690 if ( it->getInstalledTo() ) 698 if ( package->getInstalledTo() )
691 destName = it->getInstalledTo()->getDestinationName(); 699 destName = package->getInstalledTo()->getDestinationName();
692 } 700 }
693 if ( destName != "" ) 701 if ( destName != "" )
694 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); 702 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
695 } 703 }
696 else 704 else
697 { 705 {
698 item->setPixmap( 0, nullIcon ); 706 item->setPixmap( 0, nullIcon );
699 } 707 }
700 708
701 if ( !it->isPackageStoredLocally() ) 709 if ( !package->isPackageStoredLocally() )
702 { 710 {
703 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); 711 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) );
704 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); 712 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) );
705 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); 713 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) );
706 } 714 }
707 else 715 else
708 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); 716 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) );
709 717
710 if ( serverName == LOCAL_SERVER ) 718 if ( serverName == LOCAL_SERVER )
711 { 719 {
712 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); 720 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) );
713 } 721 }
714 else 722 else
715 { 723 {
716 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); 724 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) );
717 if ( it->getLocalPackage() ) 725 if ( package->getLocalPackage() )
718 { 726 {
719 if ( it->isInstalled() ) 727 if ( package->isInstalled() )
720 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); 728 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) );
721 } 729 }
722 } 730 }
723 731
724 packagesList->insertItem( item ); 732 packagesList->insertItem( item );
725 } 733 }
726 734
727 // If the local server or the local ipkgs server disable the download button 735 // If the local server or the local ipkgs server disable the download button
728 if ( serverName == LOCAL_SERVER ) 736 if ( serverName == LOCAL_SERVER )
@@ -750,17 +758,17 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
750} 758}
751 759
752void MainWindow :: searchForPackage( const QString &text ) 760void MainWindow :: searchForPackage( const QString &text )
753{ 761{
754 if ( !text.isEmpty() ) 762 if ( !text.isEmpty() )
755 { 763 {
756// cout << "searching for " << text << endl; 764// cout << "searching for " << text << endl;
757 // look through package list for text startng at current position 765 // look through package list for text startng at current position
758 vector<InstallData> workingPackages; 766// vector<InstallData> workingPackages;
759 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 767 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
760// if ( start != 0 ) 768// if ( start != 0 )
761// start = (QCheckListItem *)start->nextSibling(); 769// start = (QCheckListItem *)start->nextSibling();
762 770
763 if ( start == 0 ) 771 if ( start == 0 )
764 start = (QCheckListItem *)packagesList->firstChild(); 772 start = (QCheckListItem *)packagesList->firstChild();
765 773
766 for ( QCheckListItem *item = start; item != 0 ; 774 for ( QCheckListItem *item = start; item != 0 ;
@@ -952,21 +960,22 @@ void MainWindow :: downloadRemotePackage()
952 return; 960 return;
953// DownloadRemoteDlgImpl dlg( this, "Install", true ); 961// DownloadRemoteDlgImpl dlg( this, "Install", true );
954// if ( dlg.exec() == QDialog::Rejected ) 962// if ( dlg.exec() == QDialog::Rejected )
955// return; 963// return;
956 964
957 // grab details from dialog 965 // grab details from dialog
958// QString package = dlg.getPackageLocation(); 966// QString package = dlg.getPackageLocation();
959 967
960 InstallData item; 968 InstallData *item = new InstallData();
961 item.option = "I"; 969 item->option = "I";
962 item.packageName = package; 970 item->packageName = package;
963 vector<InstallData> workingPackages; 971 QList<InstallData> workingPackages;
964 workingPackages.push_back( item ); 972 workingPackages.setAutoDelete( TRUE );
973 workingPackages.append( item );
965 974
966 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 975 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
967 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 976 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
968 dlg->showMaximized(); 977 dlg->showMaximized();
969} 978}
970 979
971 980
972void MainWindow :: applyChanges() 981void MainWindow :: applyChanges()
@@ -974,29 +983,29 @@ void MainWindow :: applyChanges()
974 stickyOption = ""; 983 stickyOption = "";
975 984
976 // First, write out ipkg_conf file so that ipkg can use it 985 // First, write out ipkg_conf file so that ipkg can use it
977 mgr->writeOutIpkgConf(); 986 mgr->writeOutIpkgConf();
978 987
979 // Now for each selected item 988 // Now for each selected item
980 // deal with it 989 // deal with it
981 990
982 vector<InstallData> workingPackages; 991 QList<InstallData> workingPackages;
992 workingPackages.setAutoDelete( TRUE );
983 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 993 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
984 item != 0 ; 994 item != 0 ;
985 item = (QCheckListItem *)item->nextSibling() ) 995 item = (QCheckListItem *)item->nextSibling() )
986 { 996 {
987 if ( item->isOn() ) 997 if ( item->isOn() )
988 { 998 {
989 InstallData data = dealWithItem( item ); 999 workingPackages.append( dealWithItem( item ) );
990 workingPackages.push_back( data );
991 } 1000 }
992 } 1001 }
993 1002
994 if ( workingPackages.size() == 0 ) 1003 if ( workingPackages.count() == 0 )
995 { 1004 {
996 // Nothing to do 1005 // Nothing to do
997 QMessageBox::information( this, tr( "Nothing to do" ), 1006 QMessageBox::information( this, tr( "Nothing to do" ),
998 tr( "No packages selected" ), tr( "OK" ) ); 1007 tr( "No packages selected" ), tr( "OK" ) );
999 1008
1000 return; 1009 return;
1001 } 1010 }
1002 1011
@@ -1006,72 +1015,72 @@ void MainWindow :: applyChanges()
1006 dlg->showMaximized(); 1015 dlg->showMaximized();
1007} 1016}
1008 1017
1009// decide what to do - either remove, upgrade or install 1018// decide what to do - either remove, upgrade or install
1010// Current rules: 1019// Current rules:
1011// If not installed - install 1020// If not installed - install
1012// If installed and different version available - upgrade 1021// If installed and different version available - upgrade
1013// If installed and version up to date - remove 1022// If installed and version up to date - remove
1014InstallData MainWindow :: dealWithItem( QCheckListItem *item ) 1023InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1015{ 1024{
1016 QString name = item->text(); 1025 QString name = item->text();
1017 1026
1018 // Get package 1027 // Get package
1019 vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); 1028 Server *s = mgr->getServer( serversList->currentText() );
1020 Package *p = s->getPackage( name ); 1029 Package *p = s->getPackage( name );
1021 1030
1022 // If the package has a filename then it is a local file 1031 // If the package has a filename then it is a local file
1023 if ( p->isPackageStoredLocally() ) 1032 if ( p->isPackageStoredLocally() )
1024 name = p->getFilename(); 1033 name = p->getFilename();
1025 1034
1026 QString option; 1035 QString option;
1027 QString dest = "root"; 1036 QString dest = "root";
1028 if ( !p->isInstalled() ) 1037 if ( !p->isInstalled() )
1029 { 1038 {
1030 InstallData item; 1039 InstallData *newitem = new InstallData();;
1031 item.option = "I"; 1040 newitem->option = "I";
1032 item.packageName = name; 1041 newitem->packageName = name;
1033 return item; 1042 return newitem;
1034 } 1043 }
1035 else 1044 else
1036 { 1045 {
1037 InstallData item; 1046 InstallData *newitem = new InstallData();;
1038 item.option = "D"; 1047 newitem->option = "D";
1039 if ( !p->isPackageStoredLocally() ) 1048 if ( !p->isPackageStoredLocally() )
1040 item.packageName = p->getInstalledPackageName(); 1049 newitem->packageName = p->getInstalledPackageName();
1041 else 1050 else
1042 item.packageName = name; 1051 newitem->packageName = name;
1043 1052
1044 if ( p->getInstalledTo() ) 1053 if ( p->getInstalledTo() )
1045 { 1054 {
1046 item.destination = p->getInstalledTo(); 1055 newitem->destination = p->getInstalledTo();
1047// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1056// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1048// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1057// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1049 } 1058 }
1050 else 1059 else
1051 { 1060 {
1052 item.destination = p->getLocalPackage()->getInstalledTo(); 1061 newitem->destination = p->getLocalPackage()->getInstalledTo();
1053 } 1062 }
1054 1063
1055 // Now see if version is newer or not 1064 // Now see if version is newer or not
1056 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1065 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1057 1066
1058 // If the version requested is older and user selected a local ipk file, then reinstall the file 1067 // If the version requested is older and user selected a local ipk file, then reinstall the file
1059 if ( p->isPackageStoredLocally() && val == -1 ) 1068 if ( p->isPackageStoredLocally() && val == -1 )
1060 val = 0; 1069 val = 0;
1061 1070
1062 if ( val == -2 ) 1071 if ( val == -2 )
1063 { 1072 {
1064 // Error - should handle 1073 // Error - should handle
1065 } 1074 }
1066 else if ( val == -1 ) 1075 else if ( val == -1 )
1067 { 1076 {
1068 // Version available is older - remove only 1077 // Version available is older - remove only
1069 item.option = "D"; 1078 newitem->option = "D";
1070 } 1079 }
1071 else 1080 else
1072 { 1081 {
1073 QString caption; 1082 QString caption;
1074 QString text; 1083 QString text;
1075 QString secondButton; 1084 QString secondButton;
1076 QString secondOption; 1085 QString secondOption;
1077 if ( val == 0 ) 1086 if ( val == 0 )
@@ -1097,38 +1106,38 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
1097 { 1106 {
1098 QString msgtext; 1107 QString msgtext;
1099 msgtext = caption.arg( ( const char * )name ); 1108 msgtext = caption.arg( ( const char * )name );
1100 switch( QMessageBox::information( this, text, 1109 switch( QMessageBox::information( this, text,
1101 msgtext, tr( "Remove" ), secondButton ) ) 1110 msgtext, tr( "Remove" ), secondButton ) )
1102 { 1111 {
1103 case 0: // Try again or Enter 1112 case 0: // Try again or Enter
1104 // option 0 = Remove 1113 // option 0 = Remove
1105 item.option = "D"; 1114 newitem->option = "D";
1106 break; 1115 break;
1107 case 1: // Quit or Escape 1116 case 1: // Quit or Escape
1108 item.option = secondOption; 1117 newitem->option = secondOption;
1109 break; 1118 break;
1110 } 1119 }
1111 } 1120 }
1112 else 1121 else
1113 { 1122 {
1114// item.option = stickyOption; 1123// newitem->option = stickyOption;
1115 } 1124 }
1116 } 1125 }
1117 1126
1118 1127
1119 // Check if we are reinstalling the same version 1128 // Check if we are reinstalling the same version
1120 if ( item.option != "R" ) 1129 if ( newitem->option != "R" )
1121 item.recreateLinks = true; 1130 newitem->recreateLinks = true;
1122 else 1131 else
1123 item.recreateLinks = false; 1132 newitem->recreateLinks = false;
1124 1133
1125 // User hit cancel (on dlg - assume remove) 1134 // User hit cancel (on dlg - assume remove)
1126 return item; 1135 return newitem;
1127 } 1136 }
1128} 1137}
1129 1138
1130void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1139void MainWindow :: reloadData( InstallDlgImpl *dlg )
1131{ 1140{
1132 stack->raiseWidget( progressWindow ); 1141 stack->raiseWidget( progressWindow );
1133 1142
1134 if ( dlg ) 1143 if ( dlg )
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
@@ -87,17 +87,17 @@ private:
87 87
88 void initMainWidget(); 88 void initMainWidget();
89 void updateData(); 89 void updateData();
90 void serverSelected( int index, bool showProgress ); 90 void serverSelected( int index, bool showProgress );
91 void searchForPackage( const QString & ); 91 void searchForPackage( const QString & );
92 bool filterByCategory( bool val ); 92 bool filterByCategory( bool val );
93 void downloadSelectedPackages(); 93 void downloadSelectedPackages();
94 void downloadRemotePackage(); 94 void downloadRemotePackage();
95 InstallData dealWithItem( QCheckListItem *item ); 95 InstallData *dealWithItem( QCheckListItem *item );
96 96
97 // Progress widget 97 // Progress widget
98 QWidget *progressWindow; 98 QWidget *progressWindow;
99 QLabel *m_status; 99 QLabel *m_status;
100 QProgressBar *m_progress; 100 QProgressBar *m_progress;
101 101
102 void initProgressWidget(); 102 void initProgressWidget();
103 103
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
@@ -54,38 +54,40 @@ Server :: ~Server()
54 cleanUp(); 54 cleanUp();
55} 55}
56 56
57void Server :: cleanUp() 57void Server :: cleanUp()
58{ 58{
59 packageList.clear(); 59 packageList.clear();
60} 60}
61 61
62void Server :: readStatusFile( vector<Destination> &destList ) 62void Server :: readStatusFile( QList<Destination> &destList )
63{ 63{
64 cleanUp(); 64 cleanUp();
65 65
66 vector<Destination>::iterator dit; 66 Destination *dest;
67 QListIterator<Destination> dit( destList );
67 bool rootRead = false; 68 bool rootRead = false;
68 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 69 for ( ; dit.current(); ++dit )
69 { 70 {
71 dest = dit.current();
70 bool installingToRoot = false; 72 bool installingToRoot = false;
71 73
72 QString path = dit->getDestinationPath(); 74 QString path = dest->getDestinationPath();
73 if ( path.right( 1 ) != "/" ) 75 if ( path.right( 1 ) != "/" )
74 path += "/"; 76 path += "/";
75 77
76 if ( path == "/" ) 78 if ( path == "/" )
77 { 79 {
78 rootRead = true; 80 rootRead = true;
79 installingToRoot = true; 81 installingToRoot = true;
80 } 82 }
81 83
82 packageFile = path + "usr/lib/ipkg/status"; 84 packageFile = path + "usr/lib/ipkg/status";
83 readPackageFile( 0, false, installingToRoot, &( *dit ) ); 85 readPackageFile( 0, false, installingToRoot, &( *dest ) );
84 } 86 }
85 87
86 // Ensure that the root status file is read 88 // Ensure that the root status file is read
87 if ( !rootRead ) 89 if ( !rootRead )
88 { 90 {
89 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 91 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
90 packageFile = "/usr/lib/ipkg/status"; 92 packageFile = "/usr/lib/ipkg/status";
91 readPackageFile( 0, false, true ); 93 readPackageFile( 0, false, true );
@@ -110,22 +112,22 @@ void Server :: readLocalIpks( Server *local )
110 { 112 {
111 // OK, we have a local IPK file, I think the standard naming conventions 113 // OK, we have a local IPK file, I think the standard naming conventions
112 // for these are packagename_version_arm.ipk 114 // for these are packagename_version_arm.ipk
113 QString file = (*it)->file(); 115 QString file = (*it)->file();
114 116
115 // Changed to display the filename (excluding the path) 117 // Changed to display the filename (excluding the path)
116 QString packageName = Utils::getFilenameFromIpkFilename( file ); 118 QString packageName = Utils::getFilenameFromIpkFilename( file );
117 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 119 QString ver = Utils::getPackageVersionFromIpkFilename( file );
118 packageList.push_back( Package( packageName ) ); 120 Package *package = new Package( packageName );
119 packageList.back().setVersion( ver ); 121 package->setVersion( ver );
120 packageList.back().setFilename( file ); 122 package->setFilename( file );
121 packageList.back().setPackageStoredLocally( true ); 123 package->setPackageStoredLocally( true );
122 124 packageList.append( package );
123 } 125 }
124#else 126#else
125 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" }; 127 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" };
126 for ( int i = 0 ; i < 4 ; ++i ) 128 for ( int i = 0 ; i < 4 ; ++i )
127 { 129 {
128 // OK, we have a local IPK file, I think the standard naming conventions 130 // OK, we have a local IPK file, I think the standard naming conventions
129 // for these are packagename_version_arm.ipk 131 // for these are packagename_version_arm.ipk
130 QString file = names[i]; 132 QString file = names[i];
131 int p = file.find( "_" ); 133 int p = file.find( "_" );
@@ -175,20 +177,20 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
175 value = value.stripWhiteSpace(); 177 value = value.stripWhiteSpace();
176 if ( key == "Package" && newPackage ) 178 if ( key == "Package" && newPackage )
177 { 179 {
178 newPackage = false; 180 newPackage = false;
179 181
180 currPackage = getPackage( value ); 182 currPackage = getPackage( value );
181 if ( !currPackage ) 183 if ( !currPackage )
182 { 184 {
183 packageList.push_back( Package( value ) ); 185 Package *package = new Package( value );
184 currPackage = &(packageList.back()); 186 packageList.append( package );
187 currPackage = package;
185 currPackage->setInstalledTo( dest ); 188 currPackage->setInstalledTo( dest );
186
187 if ( installingToRoot ) 189 if ( installingToRoot )
188 currPackage->setInstalledToRoot( true ); 190 currPackage->setInstalledToRoot( true );
189 } 191 }
190 else 192 else
191 { 193 {
192 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 194 if (currPackage->getStatus().find( "deinstall" ) != -1 )
193 currPackage->setInstalledTo( dest ); 195 currPackage->setInstalledTo( dest );
194 } 196 }
@@ -234,74 +236,79 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
234 in.close(); 236 in.close();
235 237
236 // build local packages 238 // build local packages
237 buildLocalPackages( local ); 239 buildLocalPackages( local );
238} 240}
239 241
240void Server :: buildLocalPackages( Server *local ) 242void Server :: buildLocalPackages( Server *local )
241{ 243{
242 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 244 Package *curr;
245 QListIterator<Package> it( packageList );
246 for ( ; it.current(); ++it )
243 { 247 {
244 QString name = packageList[i].getPackageName(); 248 curr = it.current();
249 QString name = curr->getPackageName();
245 250
246 // If the package name is an ipk name, then convert the filename to a package name 251 // If the package name is an ipk name, then convert the filename to a package name
247 if ( name.find( ".ipk" ) != -1 ) 252 if ( name.find( ".ipk" ) != -1 )
248 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); 253 name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );
249 254
250 if ( local ) 255 if ( local )
251 { 256 {
252 Package *p = local->getPackage( name ); 257 Package *p = local->getPackage( name );
253 packageList[i].setLocalPackage( p ); 258 curr->setLocalPackage( p );
254 if ( p ) 259 if ( p )
255 { 260 {
256 // Set some default stuff like size and things 261 // Set some default stuff like size and things
257 if ( p->getInstalledVersion() == packageList[i].getVersion() ) 262 if ( p->getInstalledVersion() == curr->getVersion() )
258 { 263 {
259 p->setPackageSize( packageList[i].getPackageSize() ); 264 p->setPackageSize( curr->getPackageSize() );
260 p->setSection( packageList[i].getSection() ); 265 p->setSection( curr->getSection() );
261 p->setDescription( packageList[i].getDescription() ); 266 p->setDescription( curr->getDescription() );
262 } 267 }
263 } 268 }
264 269
265 } 270 }
266 else 271 else
267 packageList[i].setLocalPackage( 0 ); 272 curr->setLocalPackage( 0 );
268 } 273 }
269 274
270} 275}
271 276
272Package *Server :: getPackage( QString &name ) 277Package *Server :: getPackage( QString &name )
273{ 278{
274 return getPackage( (const char *)name ); 279 return getPackage( (const char *)name );
275} 280}
276 281
277Package *Server :: getPackage( const char *name ) 282Package *Server :: getPackage( const char *name )
278{ 283{
279 Package *ret = 0; 284 Package *ret = 0;
280 285
281 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) 286 QListIterator<Package> it( packageList );
287 for ( ; it.current(); ++it )
282 { 288 {
283 if ( packageList[i].getPackageName() == name ) 289 if ( it.current()->getPackageName() == name )
284 ret = &packageList[i]; 290 ret = it.current();
285 } 291 }
286 292
287 return ret; 293 return ret;
288} 294}
289 295
290QString Server :: toString() 296QString Server :: toString()
291{ 297{
292 QString ret = "Server\n name - " + serverName + 298 QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl );
293 "\n url - " + serverUrl + 299
294 "\n"; 300 QListIterator<Package> it( packageList );
295 301 for ( ; it.current(); ++it )
296 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 302 {
297 ret += "\n " + packageList[i].toString(); 303 ret.append( QString( "\n %1" ).arg( it.current()->toString() ) );
304 }
298 305
299 306
300 return ret; 307 return ret;
301} 308}
302 309
303vector<Package> &Server::getPackageList() 310QList<Package> &Server::getPackageList()
304{ 311{
305 return packageList; 312 return packageList;
306} 313}
307 314
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
@@ -12,42 +12,42 @@
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#ifndef SERVER_H 17#ifndef SERVER_H
18#define SERVER_H 18#define SERVER_H
19 19
20#include <qlist.h>
20#include <qstring.h> 21#include <qstring.h>
21 22
22#include <vector>
23using namespace std; 23using namespace std;
24 24
25#include "package.h" 25#include "package.h"
26#include "destination.h" 26#include "destination.h"
27 27
28class Server 28class Server
29{ 29{
30public: 30public:
31 Server() {} 31 Server() {}
32 Server( const char *name, const char *url ); 32 Server( const char *name, const char *url );
33 Server( const char *name, const char *url, const char *file ); 33 Server( const char *name, const char *url, const char *file );
34 ~Server(); 34 ~Server();
35 35
36 void cleanUp(); 36 void cleanUp();
37 37
38 void readStatusFile( vector<Destination> &v ); 38 void readStatusFile( QList<Destination> &v );
39 void readLocalIpks( Server *local ); 39 void readLocalIpks( Server *local );
40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); 40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 );
41 void buildLocalPackages( Server *local ); 41 void buildLocalPackages( Server *local );
42 Package *getPackage( const char *name ); 42 Package *getPackage( const char *name );
43 Package *getPackage( QString &name ); 43 Package *getPackage( QString &name );
44 QString toString(); 44 QString toString();
45 vector<Package> &getPackageList(); 45 QList<Package> &getPackageList();
46 bool isServerActive() { return active; } 46 bool isServerActive() { return active; }
47 47
48 void setServerName( const QString &name ) { serverName = name; } 48 void setServerName( const QString &name ) { serverName = name; }
49 void setServerUrl( const QString &url ) { serverUrl = url; } 49 void setServerUrl( const QString &url ) { serverUrl = url; }
50 void setActive( bool val ) { active = val; } 50 void setActive( bool val ) { active = val; }
51 QString &getServerName() { return serverName; } 51 QString &getServerName() { return serverName; }
52 QString &getServerUrl() { return serverUrl; } 52 QString &getServerUrl() { return serverUrl; }
53 53
@@ -55,12 +55,12 @@ protected:
55 55
56private: 56private:
57 QString serverName; 57 QString serverName;
58 QString serverUrl; 58 QString serverUrl;
59 QString packageFile; 59 QString packageFile;
60 bool active; 60 bool active;
61 61
62 62
63 vector<Package> packageList; 63 QList<Package> packageList;
64}; 64};
65 65
66#endif 66#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
@@ -249,46 +249,48 @@ QWidget *SettingsImpl :: initProxyTab()
249 layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); 249 layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
250 250
251 return control; 251 return control;
252} 252}
253 253
254void SettingsImpl :: setupData() 254void SettingsImpl :: setupData()
255{ 255{
256 // add servers 256 // add servers
257 vector<Server>::iterator it; 257 QString serverName;
258 for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) 258 QListIterator<Server> it( dataMgr->getServerList() );
259 for ( ; it.current(); ++it )
259 { 260 {
260 if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) 261 serverName = it.current()->getServerName();
262 if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
261 continue; 263 continue;
262 264
263 servers->insertItem( it->getServerName() ); 265 servers->insertItem( serverName );
264 } 266 }
265 267
266 268
267 // add destinations 269 // add destinations
268 vector<Destination>::iterator it2; 270 QListIterator<Destination> it2( dataMgr->getDestinationList() );
269 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) 271 for ( ; it2.current(); ++it2 )
270 destinations->insertItem( it2->getDestinationName() ); 272 destinations->insertItem( it2.current()->getDestinationName() );
271 273
272 // setup proxy tab 274 // setup proxy tab
273 txtHttpProxy->setText( dataMgr->getHttpProxy() ); 275 txtHttpProxy->setText( dataMgr->getHttpProxy() );
274 txtFtpProxy->setText( dataMgr->getFtpProxy() ); 276 txtFtpProxy->setText( dataMgr->getFtpProxy() );
275 txtUsername->setText( dataMgr->getProxyUsername() ); 277 txtUsername->setText( dataMgr->getProxyUsername() );
276 txtPassword->setText( dataMgr->getProxyPassword() ); 278 txtPassword->setText( dataMgr->getProxyPassword() );
277 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); 279 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
278 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); 280 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
279} 281}
280 282
281//------------------ Servers tab ---------------------- 283//------------------ Servers tab ----------------------
282 284
283void SettingsImpl :: editServer( int sel ) 285void SettingsImpl :: editServer( int sel )
284{ 286{
285 currentSelectedServer = sel; 287 currentSelectedServer = sel;
286 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); 288 Server *s = dataMgr->getServer( servers->currentText() );
287 serverName = s->getServerName(); 289 serverName = s->getServerName();
288 servername->setText( s->getServerName() ); 290 servername->setText( s->getServerName() );
289 serverurl->setText( s->getServerUrl() ); 291 serverurl->setText( s->getServerUrl() );
290 active->setChecked( s->isServerActive() ); 292 active->setChecked( s->isServerActive() );
291} 293}
292 294
293void SettingsImpl :: newServer() 295void SettingsImpl :: newServer()
294{ 296{
@@ -297,29 +299,29 @@ void SettingsImpl :: newServer()
297 serverurl->setText( "" ); 299 serverurl->setText( "" );
298 servername->setFocus(); 300 servername->setFocus();
299 active->setChecked( true ); 301 active->setChecked( true );
300} 302}
301 303
302void SettingsImpl :: removeServer() 304void SettingsImpl :: removeServer()
303{ 305{
304 changed = true; 306 changed = true;
305 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); 307 Server *s = dataMgr->getServer( servers->currentText() );
306 dataMgr->getServerList().erase( s ); 308 dataMgr->getServerList().removeRef( s );
307 servers->removeItem( currentSelectedServer ); 309 servers->removeItem( currentSelectedServer );
308} 310}
309 311
310void SettingsImpl :: changeServerDetails() 312void SettingsImpl :: changeServerDetails()
311{ 313{
312 changed = true; 314 changed = true;
313 315
314 QString newName = servername->text(); 316 QString newName = servername->text();
315 if ( !newserver ) 317 if ( !newserver )
316 { 318 {
317 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); 319 Server *s = dataMgr->getServer( servers->currentText() );
318 320
319 // Update url 321 // Update url
320 s->setServerUrl( serverurl->text() ); 322 s->setServerUrl( serverurl->text() );
321 s->setActive( active->isChecked() ); 323 s->setActive( active->isChecked() );
322 324
323 325
324 // Check if server name has changed, if it has then we need to replace the key in the map 326 // Check if server name has changed, if it has then we need to replace the key in the map
325 if ( serverName != newName ) 327 if ( serverName != newName )
@@ -333,30 +335,30 @@ void SettingsImpl :: changeServerDetails()
333 335
334 // Update list box 336 // Update list box
335 servers->changeItem( newName, currentSelectedServer ); 337 servers->changeItem( newName, currentSelectedServer );
336 } 338 }
337 } 339 }
338 else 340 else
339 { 341 {
340 Server s( newName, serverurl->text() ); 342 Server s( newName, serverurl->text() );
341 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); 343 dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
342 dataMgr->getServerList().end()->setActive( active->isChecked() ); 344 dataMgr->getServerList().last()->setActive( active->isChecked() );
343 servers->insertItem( newName ); 345 servers->insertItem( newName );
344 servers->setCurrentItem( servers->count() ); 346 servers->setCurrentItem( servers->count() );
345 newserver = false; 347 newserver = false;
346 } 348 }
347} 349}
348 350
349//------------------ Destinations tab ---------------------- 351//------------------ Destinations tab ----------------------
350 352
351void SettingsImpl :: editDestination( int sel ) 353void SettingsImpl :: editDestination( int sel )
352{ 354{
353 currentSelectedDestination = sel; 355 currentSelectedDestination = sel;
354 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); 356 Destination *d = dataMgr->getDestination( destinations->currentText() );
355 destinationName = d->getDestinationName(); 357 destinationName = d->getDestinationName();
356 destinationname->setText( d->getDestinationName() ); 358 destinationname->setText( d->getDestinationName() );
357 destinationurl->setText( d->getDestinationPath() ); 359 destinationurl->setText( d->getDestinationPath() );
358 linkToRoot->setChecked( d->linkToRoot() ); 360 linkToRoot->setChecked( d->linkToRoot() );
359} 361}
360 362
361void SettingsImpl :: newDestination() 363void SettingsImpl :: newDestination()
362{ 364{
@@ -365,34 +367,34 @@ void SettingsImpl :: newDestination()
365 destinationurl->setText( "" ); 367 destinationurl->setText( "" );
366 destinationname->setFocus(); 368 destinationname->setFocus();
367 linkToRoot->setChecked( true ); 369 linkToRoot->setChecked( true );
368} 370}
369 371
370void SettingsImpl :: removeDestination() 372void SettingsImpl :: removeDestination()
371{ 373{
372 changed = true; 374 changed = true;
373 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); 375 Destination *d = dataMgr->getDestination( destinations->currentText() );
374 dataMgr->getDestinationList().erase( d ); 376 dataMgr->getDestinationList().removeRef( d );
375 destinations->removeItem( currentSelectedDestination ); 377 destinations->removeItem( currentSelectedDestination );
376} 378}
377 379
378void SettingsImpl :: changeDestinationDetails() 380void SettingsImpl :: changeDestinationDetails()
379{ 381{
380 changed = true; 382 changed = true;
381 383
382#ifdef QWS 384#ifdef QWS
383 Config cfg( "aqpkg" ); 385 Config cfg( "aqpkg" );
384 cfg.setGroup( "destinations" ); 386 cfg.setGroup( "destinations" );
385#endif 387#endif
386 388
387 QString newName = destinationname->text(); 389 QString newName = destinationname->text();
388 if ( !newdestination ) 390 if ( !newdestination )
389 { 391 {
390 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); 392 Destination *d = dataMgr->getDestination( destinations->currentText() );
391 393
392 // Update url 394 // Update url
393 d->setDestinationPath( destinationurl->text() ); 395 d->setDestinationPath( destinationurl->text() );
394 d->linkToRoot( linkToRoot->isChecked() ); 396 d->linkToRoot( linkToRoot->isChecked() );
395 397
396 // Check if server name has changed, if it has then we need to replace the key in the map 398 // Check if server name has changed, if it has then we need to replace the key in the map
397 if ( destinationName != newName ) 399 if ( destinationName != newName )
398 { 400 {
@@ -406,17 +408,17 @@ void SettingsImpl :: changeDestinationDetails()
406 QString key = newName; 408 QString key = newName;
407 key += "_linkToRoot"; 409 key += "_linkToRoot";
408 int val = d->linkToRoot(); 410 int val = d->linkToRoot();
409 cfg.writeEntry( key, val ); 411 cfg.writeEntry( key, val );
410#endif 412#endif
411 } 413 }
412 else 414 else
413 { 415 {
414 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); 416 dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) );
415 destinations->insertItem( newName ); 417 destinations->insertItem( newName );
416 destinations->setCurrentItem( destinations->count() ); 418 destinations->setCurrentItem( destinations->count() );
417 newdestination = false; 419 newdestination = false;
418 420
419#ifdef QWS 421#ifdef QWS
420 QString key = newName; 422 QString key = newName;
421 key += "_linkToRoot"; 423 key += "_linkToRoot";
422 cfg.writeEntry( key, true ); 424 cfg.writeEntry( key, true );