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.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index e7fb75a..96c28c0 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -30,52 +30,50 @@ using namespace std;
30 30
31QString DataManager::availableCategories = ""; 31QString DataManager::availableCategories = "";
32DataManager::DataManager() 32DataManager::DataManager()
33{ 33{
34 activeServer = ""; 34 activeServer = "";
35 availableCategories = "#"; 35 availableCategories = "#";
36} 36}
37 37
38DataManager::~DataManager() 38DataManager::~DataManager()
39{ 39{
40} 40}
41 41
42Server *DataManager :: getServer( const char *name ) 42vector<Server>::iterator DataManager :: getServer( const char *name )
43{ 43{
44 Server *s = 0; 44 vector<Server>::iterator it = serverList.begin();
45 vector<Server>::iterator it = serverList.begin(); 45 while ( it != serverList.end() )
46 while ( it != serverList.end() && s == 0 )
47 { 46 {
48 if ( it->getServerName() == name ) 47 if ( it->getServerName() == name )
49 s = &(*it); 48 return it;
50 49
51 ++it; 50 ++it;
52 } 51 }
53 52
54 return s; 53 return serverList.end();
55} 54}
56 55
57Destination *DataManager :: getDestination( const char *name ) 56vector<Destination>::iterator DataManager :: getDestination( const char *name )
58{ 57{
59 Destination *d = 0;
60 vector<Destination>::iterator it = destList.begin(); 58 vector<Destination>::iterator it = destList.begin();
61 while ( it != destList.end() && d == 0 ) 59 while ( it != destList.end() )
62 { 60 {
63 if ( it->getDestinationName() == name ) 61 if ( it->getDestinationName() == name )
64 d = &(*it); 62 return it;
65 63
66 ++it; 64 ++it;
67 } 65 }
68 66
69 return d; 67 return destList.end();
70} 68}
71 69
72void DataManager :: loadServers() 70void DataManager :: loadServers()
73{ 71{
74 // First add our local server - not really a server but 72 // First add our local server - not really a server but
75 // the local config (which packages are installed) 73 // the local config (which packages are installed)
76 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 74 serverList.push_back( Server( LOCAL_SERVER, "" ) );
77 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 75 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
78 76
79#ifdef QWS 77#ifdef QWS
80 Config cfg( "aqpkg" ); 78 Config cfg( "aqpkg" );
81 cfg.setGroup( "destinations" ); 79 cfg.setGroup( "destinations" );
@@ -141,48 +139,43 @@ void DataManager :: loadServers()
141 httpProxy = val; 139 httpProxy = val;
142 if ( stricmp( type, "ftp_proxy" ) == 0 ) 140 if ( stricmp( type, "ftp_proxy" ) == 0 )
143 ftpProxy = val; 141 ftpProxy = val;
144 if ( stricmp( type, "proxy_username" ) == 0 ) 142 if ( stricmp( type, "proxy_username" ) == 0 )
145 proxyUsername = val; 143 proxyUsername = val;
146 if ( stricmp( type, "proxy_password" ) == 0 ) 144 if ( stricmp( type, "proxy_password" ) == 0 )
147 proxyPassword = val; 145 proxyPassword = val;
148 } 146 }
149 } 147 }
150 } 148 }
151 fclose( fp ); 149 fclose( fp );
152 150
153 cout << "httpProxy = " << httpProxy << endl;
154 cout << "ftpProxy = " << ftpProxy << endl;
155 cout << "proxyUsername = " << proxyUsername << endl;
156 cout << "proxyPassword = " << proxyPassword << endl;
157
158 reloadServerData( ); 151 reloadServerData( );
159} 152}
160 153
161void DataManager :: reloadServerData( ) 154void DataManager :: reloadServerData( )
162{ 155{
163 vector<Server>::iterator it = serverList.begin(); 156 vector<Server>::iterator it = serverList.begin();
164 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 157 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
165 { 158 {
166 // Now we've read the config file in we need to read the servers 159 // Now we've read the config file in we need to read the servers
167 // The local server is a special case. This holds the contents of the 160 // The local server is a special case. This holds the contents of the
168 // status files the number of which depends on how many destinations 161 // status files the number of which depends on how many destinations
169 // we've set up 162 // we've set up
170 // The other servers files hold the contents of the server package list 163 // The other servers files hold the contents of the server package list
171 if ( it->getServerName() == LOCAL_SERVER ) 164 if ( it->getServerName() == LOCAL_SERVER )
172 it->readStatusFile( destList ); 165 it->readStatusFile( destList );
173 else if ( it->getServerName() == LOCAL_IPKGS ) 166 else if ( it->getServerName() == LOCAL_IPKGS )
174 it->readLocalIpks( getServer( LOCAL_SERVER ) ); 167 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
175 else 168 else
176 it->readPackageFile( getServer( LOCAL_SERVER ) ); 169 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
177 } 170 }
178} 171}
179 172
180void DataManager :: writeOutIpkgConf() 173void DataManager :: writeOutIpkgConf()
181{ 174{
182 QString ipkg_conf = IPKG_CONF; 175 QString ipkg_conf = IPKG_CONF;
183 ofstream out( ipkg_conf ); 176 ofstream out( ipkg_conf );
184 177
185 out << "# Written by AQPkg" << endl; 178 out << "# Written by AQPkg" << endl;
186 out << "# Must have one or more source entries of the form:" << endl; 179 out << "# Must have one or more source entries of the form:" << endl;
187 out << "#" << endl; 180 out << "#" << endl;
188 out << "# src <src-name> <source-url>" << endl; 181 out << "# src <src-name> <source-url>" << endl;