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
@@ -24,128 +24,125 @@ using namespace std;
24#else 24#else
25#include <qapplication.h> 25#include <qapplication.h>
26#endif 26#endif
27 27
28#include <stdio.h> 28#include <stdio.h>
29 29
30#include "datamgr.h" 30#include "datamgr.h"
31#include "global.h" 31#include "global.h"
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;
88 FILE *fp; 85 FILE *fp;
89 fp = fopen( ipkg_conf, "r" ); 86 fp = fopen( ipkg_conf, "r" );
90 char line[130]; 87 char line[130];
91 QString lineStr; 88 QString lineStr;
92 if ( fp == NULL ) 89 if ( fp == NULL )
93 { 90 {
94 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 91 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
95 return; 92 return;
96 } 93 }
97 else 94 else
98 { 95 {
99 while ( fgets( line, sizeof line, fp) != NULL ) 96 while ( fgets( line, sizeof line, fp) != NULL )
100 { 97 {
101 lineStr = line; 98 lineStr = line;
102 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 99 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
103 { 100 {
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 {
144 httpProxy = val; 141 httpProxy = val;
145 if ( lineStr.startsWith( "#" ) ) 142 if ( lineStr.startsWith( "#" ) )
146 httpProxyEnabled = false; 143 httpProxyEnabled = false;
147 else 144 else
148 httpProxyEnabled = true; 145 httpProxyEnabled = true;
149 } 146 }
150 if ( stricmp( type, "ftp_proxy" ) == 0 ) 147 if ( stricmp( type, "ftp_proxy" ) == 0 )
151 { 148 {
@@ -156,105 +153,110 @@ void DataManager :: loadServers()
156 ftpProxyEnabled = true; 153 ftpProxyEnabled = true;
157 } 154 }
158 if ( stricmp( type, "proxy_username" ) == 0 ) 155 if ( stricmp( type, "proxy_username" ) == 0 )
159 proxyUsername = val; 156 proxyUsername = val;
160 if ( stricmp( type, "proxy_password" ) == 0 ) 157 if ( stricmp( type, "proxy_password" ) == 0 )
161 proxyPassword = val; 158 proxyPassword = val;
162 } 159 }
163 } 160 }
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
204 out << "# Written by AQPkg" << endl; 204 out << "# Written by AQPkg" << endl;
205 out << "# Must have one or more source entries of the form:" << endl; 205 out << "# Must have one or more source entries of the form:" << endl;
206 out << "#" << endl; 206 out << "#" << endl;
207 out << "# src <src-name> <source-url>" << endl; 207 out << "# src <src-name> <source-url>" << endl;
208 out << "#" << endl; 208 out << "#" << endl;
209 out << "# and one or more destination entries of the form:" << endl; 209 out << "# and one or more destination entries of the form:" << endl;
210 out << "#" << endl; 210 out << "#" << endl;
211 out << "# dest <dest-name> <target-path>" << endl; 211 out << "# dest <dest-name> <target-path>" << endl;
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
253 { 255 {
254 if ( !httpProxyEnabled ) 256 if ( !httpProxyEnabled )
255 out << "#"; 257 out << "#";
256 out << "option http_proxy " << httpProxy << endl; 258 out << "option http_proxy " << httpProxy << endl;
257 } 259 }
258 260
259 if ( !ftpProxyEnabled && ftpProxy == "" ) 261 if ( !ftpProxyEnabled && ftpProxy == "" )
260 out << "#option ftp_proxy http://proxy.tld:3128" << endl; 262 out << "#option ftp_proxy http://proxy.tld:3128" << endl;
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
@@ -8,62 +8,63 @@
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
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 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"
32 33
33/** 34/**
34 *@author Andy Qua 35 *@author Andy Qua
35 */ 36 */
36 37
37 38
38class DataManager : public QObject 39class DataManager : public QObject
39{ 40{
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 );
62 63
63 QString getHttpProxy() { return httpProxy; } 64 QString getHttpProxy() { return httpProxy; }
64 QString getFtpProxy() { return ftpProxy; } 65 QString getFtpProxy() { return ftpProxy; }
65 QString getProxyUsername() { return proxyUsername; } 66 QString getProxyUsername() { return proxyUsername; }
66 QString getProxyPassword() { return proxyPassword; } 67 QString getProxyPassword() { return proxyPassword; }
67 68
68 bool getHttpProxyEnabled() { return httpProxyEnabled; } 69 bool getHttpProxyEnabled() { return httpProxyEnabled; }
69 bool getFtpProxyEnabled() { return ftpProxyEnabled; } 70 bool getFtpProxyEnabled() { return ftpProxyEnabled; }
@@ -73,26 +74,26 @@ public:
73 void setProxyUsername( QString name ) { proxyUsername = name; } 74 void setProxyUsername( QString name ) { proxyUsername = name; }
74 void setProxyPassword( QString pword ) { proxyPassword = pword; } 75 void setProxyPassword( QString pword ) { proxyPassword = pword; }
75 76
76 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } 77 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; }
77 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } 78 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; }
78private: 79private:
79 static QString availableCategories; 80 static QString availableCategories;
80 QString activeServer; 81 QString activeServer;
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
@@ -28,104 +28,110 @@
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qdialog.h> 29#include <qdialog.h>
30#include <qgroupbox.h> 30#include <qgroupbox.h>
31#include <qmultilineedit.h> 31#include <qmultilineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35 35
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)
62 flags = cfg.readNumEntry( "installFlags", 0 ); 61 flags = cfg.readNumEntry( "installFlags", 0 );
63#else 62#else
64 flags = 0; 63 flags = 0;
65#endif 64#endif
66 65
67 // Output text is read only 66 // Output text is read only
68 output->setReadOnly( true ); 67 output->setReadOnly( true );
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{
124 setCaption( title ); 130 setCaption( title );
125 init( FALSE ); 131 init( FALSE );
126 pIpkg = ipkg; 132 pIpkg = ipkg;
127 output->setText( initialText ); 133 output->setText( initialText );
128} 134}
129 135
130 136
131InstallDlgImpl::~InstallDlgImpl() 137InstallDlgImpl::~InstallDlgImpl()
@@ -200,136 +206,140 @@ void InstallDlgImpl :: installSelected()
200 if ( pIpkg ) 206 if ( pIpkg )
201 { 207 {
202 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 208 displayText( tr( "\n**** User Clicked ABORT ***" ) );
203 pIpkg->abort(); 209 pIpkg->abort();
204 displayText( tr( "**** Process Aborted ****" ) ); 210 displayText( tr( "**** Process Aborted ****" ) );
205 } 211 }
206 212
207 btnInstall->setText( tr( "Close" ) ); 213 btnInstall->setText( tr( "Close" ) );
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
241 Config cfg( "aqpkg" ); 247 Config cfg( "aqpkg" );
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 }
297 308
298 btnOptions->setEnabled( true ); 309 btnOptions->setEnabled( true );
299// btnInstall->setEnabled( true ); 310// btnInstall->setEnabled( true );
300 btnInstall->setText( tr( "Close" ) ); 311 btnInstall->setText( tr( "Close" ) );
301 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 312 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
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 {
328 long mult = blockSize / 1024; 338 long mult = blockSize / 1024;
329 long div = 1024 / blockSize; 339 long div = 1024 / blockSize;
330 340
331 if ( !mult ) mult = 1; 341 if ( !mult ) mult = 1;
332 if ( !div ) div = 1; 342 if ( !div ) div = 1;
333// long total = totalBlocks * mult / div; 343// long total = totalBlocks * mult / div;
334 long avail = availBlocks * mult / div; 344 long avail = availBlocks * mult / div;
335// long used = total - avail; 345// long used = total - avail;
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
@@ -4,73 +4,73 @@
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
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;
33class Ipkg; 33class Ipkg;
34 34
35class InstallData 35class InstallData
36{ 36{
37public: 37public:
38 QString option; // I - install, D - delete, R- reinstall U - upgrade 38 QString option; // I - install, D - delete, R- reinstall U - upgrade
39 QString packageName; 39 QString packageName;
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;
69 QLabel *txtAvailableSpace; 69 QLabel *txtAvailableSpace;
70 70
71 void init( bool ); 71 void init( bool );
72 72
73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
74 74
75signals: 75signals:
76 void reloadData( InstallDlgImpl * ); 76 void reloadData( InstallDlgImpl * );
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
@@ -530,207 +530,215 @@ void MainWindow :: setProgressSteps( int numsteps )
530{ 530{
531 m_progress->setTotalSteps( numsteps ); 531 m_progress->setTotalSteps( numsteps );
532} 532}
533 533
534void MainWindow :: setProgressMessage( const QString &msg ) 534void MainWindow :: setProgressMessage( const QString &msg )
535{ 535{
536 m_status->setText( msg ); 536 m_status->setText( msg );
537} 537}
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 )
572 activeItem = i; 576 activeItem = i;
573 } 577 }
574 578
575 // set selected server to be active server 579 // set selected server to be active server
576 if ( activeItem != -1 ) 580 if ( activeItem != -1 )
577 serversList->setCurrentItem( activeItem ); 581 serversList->setCurrentItem( activeItem );
578 serverSelected( 0, FALSE ); 582 serverSelected( 0, FALSE );
579} 583}
580 584
581void MainWindow :: serverSelected( int index ) 585void MainWindow :: serverSelected( int index )
582{ 586{
583 serverSelected( index, TRUE ); 587 serverSelected( index, TRUE );
584} 588}
585 589
586void MainWindow :: serverSelected( int, bool raiseProgress ) 590void 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 )
729 { 737 {
730 downloadEnabled = TRUE; 738 downloadEnabled = TRUE;
731 actionUpgrade->setEnabled( FALSE ); 739 actionUpgrade->setEnabled( FALSE );
732 } 740 }
733 else if ( serverName == LOCAL_IPKGS ) 741 else if ( serverName == LOCAL_IPKGS )
734 { 742 {
735 downloadEnabled = FALSE; 743 downloadEnabled = FALSE;
736 actionUpgrade->setEnabled( FALSE ); 744 actionUpgrade->setEnabled( FALSE );
@@ -742,33 +750,33 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
742 } 750 }
743 enableDownload( downloadEnabled ); 751 enableDownload( downloadEnabled );
744 752
745 // Display this widget once everything is done 753 // Display this widget once everything is done
746 if ( doProgress && raiseProgress ) 754 if ( doProgress && raiseProgress )
747 { 755 {
748 stack->raiseWidget( networkPkgWindow ); 756 stack->raiseWidget( networkPkgWindow );
749 } 757 }
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 ;
767 item = (QCheckListItem *)item->nextSibling() ) 775 item = (QCheckListItem *)item->nextSibling() )
768 { 776 {
769// cout << "checking " << item->text().lower() << endl; 777// cout << "checking " << item->text().lower() << endl;
770 if ( item->text().lower().find( text ) != -1 ) 778 if ( item->text().lower().find( text ) != -1 )
771 { 779 {
772// cout << "matched " << item->text() << endl; 780// cout << "matched " << item->text() << endl;
773 packagesList->ensureItemVisible( item ); 781 packagesList->ensureItemVisible( item );
774 packagesList->setCurrentItem( item ); 782 packagesList->setCurrentItem( item );
@@ -944,142 +952,143 @@ void MainWindow :: downloadSelectedPackages()
944} 952}
945 953
946void MainWindow :: downloadRemotePackage() 954void MainWindow :: downloadRemotePackage()
947{ 955{
948 // Display dialog 956 // Display dialog
949 bool ok; 957 bool ok;
950 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 958 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
951 if ( !ok || package.isEmpty() ) 959 if ( !ok || package.isEmpty() )
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()
973{ 982{
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
1003 // do the stuff 1012 // do the stuff
1004 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 1013 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
1005 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 1014 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
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 )
1078 { 1087 {
1079 // Version available is the same - option to remove or reinstall 1088 // Version available is the same - option to remove or reinstall
1080 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1089 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1081 text = tr( "Remove or ReInstall" ); 1090 text = tr( "Remove or ReInstall" );
1082 secondButton = tr( "ReInstall" ); 1091 secondButton = tr( "ReInstall" );
1083 secondOption = tr( "R" ); 1092 secondOption = tr( "R" );
1084 } 1093 }
1085 else if ( val == 1 ) 1094 else if ( val == 1 )
@@ -1089,54 +1098,54 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
1089 text = tr( "Remove or Upgrade" ); 1098 text = tr( "Remove or Upgrade" );
1090 secondButton = tr( "Upgrade" ); 1099 secondButton = tr( "Upgrade" );
1091 secondOption = tr( "U" ); 1100 secondOption = tr( "U" );
1092 } 1101 }
1093 1102
1094 // Sticky option not implemented yet, but will eventually allow 1103 // Sticky option not implemented yet, but will eventually allow
1095 // the user to say something like 'remove all' 1104 // the user to say something like 'remove all'
1096 if ( stickyOption == "" ) 1105 if ( stickyOption == "" )
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 )
1135 { 1144 {
1136 dlg->close(); 1145 dlg->close();
1137 delete dlg; 1146 delete dlg;
1138 } 1147 }
1139 1148
1140 mgr->reloadServerData(); 1149 mgr->reloadServerData();
1141 serverSelected( -1, FALSE ); 1150 serverSelected( -1, FALSE );
1142 1151
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
@@ -79,33 +79,33 @@ private:
79 QString stickyOption; 79 QString stickyOption;
80 80
81 bool categoryFilterEnabled; 81 bool categoryFilterEnabled;
82 bool showJumpTo; 82 bool showJumpTo;
83 bool showUninstalledPkgs; 83 bool showUninstalledPkgs;
84 bool showInstalledPkgs; 84 bool showInstalledPkgs;
85 bool showUpgradedPkgs; 85 bool showUpgradedPkgs;
86 bool downloadEnabled; 86 bool downloadEnabled;
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
104public slots: 104public slots:
105// void setDocument( const QString &doc ); 105// void setDocument( const QString &doc );
106 void displayHelp(); 106 void displayHelp();
107 void displayFindBar(); 107 void displayFindBar();
108 void displayJumpBar(); 108 void displayJumpBar();
109 void repeatFind(); 109 void repeatFind();
110 void findPackage( const QString & ); 110 void findPackage( const QString & );
111 void hideFindBar(); 111 void hideFindBar();
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index fc5ed12..04f5ab7 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -46,54 +46,56 @@ Server :: Server( const char *name, const char *url )
46 serverUrl = url; 46 serverUrl = url;
47 packageFile = IPKG_DIR; 47 packageFile = IPKG_DIR;
48 active = true; 48 active = true;
49 packageFile += "lists/" + serverName; 49 packageFile += "lists/" + serverName;
50} 50}
51 51
52Server :: ~Server() 52Server :: ~Server()
53{ 53{
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 );
92 } 94 }
93} 95}
94 96
95void Server :: readLocalIpks( Server *local ) 97void Server :: readLocalIpks( Server *local )
96{ 98{
97 cleanUp(); 99 cleanUp();
98 100
99#ifdef QWS 101#ifdef QWS
@@ -102,38 +104,38 @@ void Server :: readLocalIpks( Server *local )
102 104
103 DocLnkSet files; 105 DocLnkSet files;
104 Global::findDocuments( &files, "application/ipkg" ); 106 Global::findDocuments( &files, "application/ipkg" );
105 107
106 // Now add the items to the list 108 // Now add the items to the list
107 QListIterator<DocLnk> it( files.children() ); 109 QListIterator<DocLnk> it( files.children() );
108 110
109 for ( ; it.current() ; ++it ) 111 for ( ; it.current() ; ++it )
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( "_" );
132 QString tmp = file.mid( 0, p ); 134 QString tmp = file.mid( 0, p );
133 packageList.push_back( Package( tmp ) ); 135 packageList.push_back( Package( tmp ) );
134 int p2 = file.find( "_", p+1 ); 136 int p2 = file.find( "_", p+1 );
135 tmp = file.mid( p+1, p2-(p+1) ); 137 tmp = file.mid( p+1, p2-(p+1) );
136 packageList.back().setVersion( tmp ); 138 packageList.back().setVersion( tmp );
137 packageList.back().setPackageStoredLocally( true ); 139 packageList.back().setPackageStoredLocally( true );
138 } 140 }
139#endif 141#endif
@@ -167,36 +169,36 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
167 169
168 k[0] = '\0'; 170 k[0] = '\0';
169 v[0] = '\0'; 171 v[0] = '\0';
170 172
171 sscanf( line, "%[^:]: %[^\n]", k, v ); 173 sscanf( line, "%[^:]: %[^\n]", k, v );
172 key = k; 174 key = k;
173 value = v; 175 value = v;
174 key = key.stripWhiteSpace(); 176 key = key.stripWhiteSpace();
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 }
195 } 197 }
196 else if ( key == "Version" ) 198 else if ( key == "Version" )
197 { 199 {
198 if ( currPackage ) 200 if ( currPackage )
199 currPackage->setVersion( value ); 201 currPackage->setVersion( value );
200 } 202 }
201 else if ( key == "Status" ) 203 else if ( key == "Status" )
202 { 204 {
@@ -226,82 +228,87 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
226 DataManager::setAvailableCategories( value ); 228 DataManager::setAvailableCategories( value );
227 } 229 }
228 else if ( key == "" ) 230 else if ( key == "" )
229 { 231 {
230 newPackage = true; 232 newPackage = true;
231 } 233 }
232 } while ( !in.eof() ); 234 } while ( !in.eof() );
233 235
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
@@ -4,63 +4,63 @@
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
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
54protected: 54protected:
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
@@ -241,190 +241,192 @@ QWidget *SettingsImpl :: initProxyTab()
241 241
242 label = new QLabel( tr( "Password:" ), container ); 242 label = new QLabel( tr( "Password:" ), container );
243 layout->addWidget( label, 3, 0 ); 243 layout->addWidget( label, 3, 0 );
244 txtPassword = new QLineEdit( container ); 244 txtPassword = new QLineEdit( container );
245 layout->addWidget( txtPassword, 3, 1 ); 245 layout->addWidget( txtPassword, 3, 1 );
246 246
247 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); 247 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container );
248 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); 248 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
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{
295 newserver = true; 297 newserver = true;
296 servername->setText( "" ); 298 servername->setText( "" );
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 )
326 { 328 {
327 // Update server name 329 // Update server name
328 s->setServerName( newName ); 330 s->setServerName( newName );
329 331
330 // See if this server is the active server 332 // See if this server is the active server
331 // if ( dataMgr->getActiveServer() == serverName ) 333 // if ( dataMgr->getActiveServer() == serverName )
332 // dataMgr->setActiveServer( newName ); 334 // dataMgr->setActiveServer( newName );
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{
363 newdestination = true; 365 newdestination = true;
364 destinationname->setText( "" ); 366 destinationname->setText( "" );
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 {
399 // Update server name 401 // Update server name
400 d->setDestinationName( newName ); 402 d->setDestinationName( newName );
401 403
402 // Update list box 404 // Update list box
403 destinations->changeItem( newName, currentSelectedDestination ); 405 destinations->changeItem( newName, currentSelectedDestination );
404 } 406 }
405#ifdef QWS 407#ifdef QWS
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 );
423#endif 425#endif
424 } 426 }
425} 427}
426 428
427//------------------ Proxy tab ---------------------- 429//------------------ Proxy tab ----------------------
428void SettingsImpl :: proxyApplyChanges() 430void SettingsImpl :: proxyApplyChanges()
429{ 431{
430 changed = true; 432 changed = true;