summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/datamgr.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/datamgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index cd0c78f..67f90a3 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,15 +1,15 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5             .=l. Dan Williams <drw@handhelds.org> 5             .=l. Dan Williams <drw@handhelds.org>
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
@@ -31,32 +31,35 @@
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#else 33#else
34#include <qapplication.h> 34#include <qapplication.h>
35#endif 35#endif
36 36
37#include <qfile.h> 37#include <qfile.h>
38#include <qtextstream.h> 38#include <qtextstream.h>
39 39
40#include "datamgr.h" 40#include "datamgr.h"
41#include "global.h" 41#include "global.h"
42 42
43QString LOCAL_SERVER;
44QString LOCAL_IPKGS;
45
43 46
44QString DataManager::availableCategories = ""; 47QString DataManager::availableCategories = "";
45DataManager::DataManager() 48DataManager::DataManager()
46 : QObject( 0x0, 0x0 ) 49 : QObject( 0x0, 0x0 )
47{ 50{
48 activeServer = ""; 51 activeServer = "";
49 availableCategories = "#"; 52 availableCategories = "#";
50 53
51 serverList.setAutoDelete( TRUE ); 54 serverList.setAutoDelete( TRUE );
52 destList.setAutoDelete( TRUE ); 55 destList.setAutoDelete( TRUE );
53} 56}
54 57
55DataManager::~DataManager() 58DataManager::~DataManager()
56{ 59{
57} 60}
58 61
59Server *DataManager :: getServer( const char *name ) 62Server *DataManager :: getServer( const char *name )
60{ 63{
61 QListIterator<Server> it( serverList ); 64 QListIterator<Server> it( serverList );
62 while ( it.current() && it.current()->getServerName() != name ) 65 while ( it.current() && it.current()->getServerName() != name )
@@ -128,25 +131,25 @@ void DataManager :: loadServers()
128 { 131 {
129 char alias[20]; 132 char alias[20];
130 char path[50]; 133 char path[50];
131 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 134 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
132 Destination *d = new Destination( alias, path ); 135 Destination *d = new Destination( alias, path );
133 bool linkToRoot = true; 136 bool linkToRoot = true;
134#ifdef QWS 137#ifdef QWS
135 QString key = alias; 138 QString key = alias;
136 key += "_linkToRoot"; 139 key += "_linkToRoot";
137 linkToRoot = cfg.readBoolEntry( key, true ); 140 linkToRoot = cfg.readBoolEntry( key, true );
138#endif 141#endif
139 d->linkToRoot( linkToRoot ); 142 d->linkToRoot( linkToRoot );
140 143
141 destList.append( d ); 144 destList.append( d );
142 } 145 }
143 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) 146 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
144 { 147 {
145 char type[20]; 148 char type[20];
146 char val[100]; 149 char val[100];
147 sscanf( lineStr, "%*[^ ] %s %s", type, val ); 150 sscanf( lineStr, "%*[^ ] %s %s", type, val );
148 if ( stricmp( type, "http_proxy" ) == 0 ) 151 if ( stricmp( type, "http_proxy" ) == 0 )
149 { 152 {
150 httpProxy = val; 153 httpProxy = val;
151 if ( lineStr.startsWith( "#" ) ) 154 if ( lineStr.startsWith( "#" ) )
152 httpProxyEnabled = false; 155 httpProxyEnabled = false;
@@ -171,57 +174,57 @@ void DataManager :: loadServers()
171 fclose( fp ); 174 fclose( fp );
172 175
173 reloadServerData( ); 176 reloadServerData( );
174} 177}
175 178
176void DataManager :: reloadServerData( ) 179void DataManager :: reloadServerData( )
177{ 180{
178 emit progressSetSteps( serverList.count() ); 181 emit progressSetSteps( serverList.count() );
179 emit progressSetMessage( tr( "Reading configuration..." ) ); 182 emit progressSetMessage( tr( "Reading configuration..." ) );
180 183
181 QString serverName; 184 QString serverName;
182 int i = 0; 185 int i = 0;
183 186
184 Server *server; 187 Server *server;
185 QListIterator<Server> it( serverList ); 188 QListIterator<Server> it( serverList );
186 for ( ; it.current(); ++it ) 189 for ( ; it.current(); ++it )
187 { 190 {
188 server = it.current(); 191 server = it.current();
189 serverName = server->getServerName(); 192 serverName = server->getServerName();
190 i++; 193 i++;
191 emit progressUpdate( i ); 194 emit progressUpdate( i );
192 qApp->processEvents(); 195 qApp->processEvents();
193 196
194 // Now we've read the config file in we need to read the servers 197 // Now we've read the config file in we need to read the servers
195 // The local server is a special case. This holds the contents of the 198 // The local server is a special case. This holds the contents of the
196 // status files the number of which depends on how many destinations 199 // status files the number of which depends on how many destinations
197 // we've set up 200 // we've set up
198 // The other servers files hold the contents of the server package list 201 // The other servers files hold the contents of the server package list
199 if ( serverName == LOCAL_SERVER ) 202 if ( serverName == LOCAL_SERVER )
200 server->readStatusFile( destList ); 203 server->readStatusFile( destList );
201 else if ( serverName == LOCAL_IPKGS ) 204 else if ( serverName == LOCAL_IPKGS )
202 server->readLocalIpks( getServer( LOCAL_SERVER ) ); 205 server->readLocalIpks( getServer( LOCAL_SERVER ) );
203 else 206 else
204 server->readPackageFile( getServer( LOCAL_SERVER ) ); 207 server->readPackageFile( getServer( LOCAL_SERVER ) );
205 } 208 }
206} 209}
207 210
208void DataManager :: writeOutIpkgConf() 211void DataManager :: writeOutIpkgConf()
209{ 212{
210 QFile f( IPKG_CONF ); 213 QFile f( IPKG_CONF );
211 if ( !f.open( IO_WriteOnly ) ) 214 if ( !f.open( IO_WriteOnly ) )
212 { 215 {
213 return; 216 return;
214 } 217 }
215 218
216 QTextStream t( &f ); 219 QTextStream t( &f );
217/* 220/*
218 QString ipkg_conf = IPKG_CONF; 221 QString ipkg_conf = IPKG_CONF;
219 ofstream out( ipkg_conf ); 222 ofstream out( ipkg_conf );
220*/ 223*/
221 t << "# Written by AQPkg\n"; 224 t << "# Written by AQPkg\n";
222 t << "# Must have one or more source entries of the form:\n"; 225 t << "# Must have one or more source entries of the form:\n";
223 t << "#\n"; 226 t << "#\n";
224 t << "# src <src-name> <source-url>\n"; 227 t << "# src <src-name> <source-url>\n";
225 t << "#\n"; 228 t << "#\n";
226 t << "# and one or more destination entries of the form:\n"; 229 t << "# and one or more destination entries of the form:\n";
227 t << "#\n"; 230 t << "#\n";
@@ -285,25 +288,25 @@ void DataManager :: writeOutIpkgConf()
285 } 288 }
286 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 289 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
287 t << "#option proxy_username <username>\n"; 290 t << "#option proxy_username <username>\n";
288 else 291 else
289 t << "option proxy_username " << proxyUsername << endl; 292 t << "option proxy_username " << proxyUsername << endl;
290 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 293 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
291 t << "#option proxy_password <password>\n\n"; 294 t << "#option proxy_password <password>\n\n";
292 else 295 else
293 t << "option proxy_password " << proxyPassword << endl<< endl; 296 t << "option proxy_password " << proxyPassword << endl<< endl;
294 297
295 t << "# Offline mode (for use in constructing flash images offline)\n"; 298 t << "# Offline mode (for use in constructing flash images offline)\n";
296 t << "#option offline_root target\n"; 299 t << "#option offline_root target\n";
297 300
298 f.close(); 301 f.close();
299} 302}
300 303
301 304
302void DataManager :: setAvailableCategories( QString section ) 305void DataManager :: setAvailableCategories( QString section )
303{ 306{
304 QString sectstr = "#"; 307 QString sectstr = "#";
305 sectstr.append( section.lower() ); 308 sectstr.append( section.lower() );
306 sectstr.append( "#" ); 309 sectstr.append( "#" );
307 if ( availableCategories.find( sectstr ) == -1 ) 310 if ( availableCategories.find( sectstr ) == -1 )
308 { 311 {
309 availableCategories.append( section ); 312 availableCategories.append( section );