summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/datamgr.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/datamgr.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp82
1 files changed, 42 insertions, 40 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
@@ -38,4 +38,7 @@ DataManager::DataManager()
38 activeServer = ""; 38 activeServer = "";
39 availableCategories = "#"; 39 availableCategories = "#";
40
41 serverList.setAutoDelete( TRUE );
42 destList.setAutoDelete( TRUE );
40} 43}
41 44
@@ -44,30 +47,24 @@ DataManager::~DataManager()
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
@@ -76,6 +73,6 @@ void DataManager :: loadServers()
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
@@ -110,11 +107,11 @@ void DataManager :: loadServers()
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 }
@@ -124,5 +121,5 @@ void DataManager :: loadServers()
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
@@ -131,7 +128,7 @@ void DataManager :: loadServers()
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" ) )
@@ -170,13 +167,16 @@ void DataManager :: loadServers()
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 );
@@ -189,9 +189,9 @@ void DataManager :: reloadServerData( )
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}
@@ -218,19 +218,21 @@ void DataManager :: writeOutIpkgConf()
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
@@ -238,9 +240,9 @@ void DataManager :: writeOutIpkgConf()
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