Diffstat (limited to 'noncore/settings/aqpkg/datamgr.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 139 |
1 files changed, 80 insertions, 59 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index 79f36e1..cd0c78f 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp | |||
@@ -1,22 +1,31 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | datamgr.cpp - description | 2 | This file is part of the OPIE Project |
3 | ------------------- | 3 | |
4 | begin : Thu Aug 29 2002 | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | copyright : (C) 2002 by Andy Qua | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | email : andy.qua@blueyonder.co.uk | 6 | .>+-= |
7 | ***************************************************************************/ | 7 | _;:, .> :=|. This file is free software; you can |
8 | 8 | .> <`_, > . <= redistribute it and/or modify it under | |
9 | /*************************************************************************** | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | * * | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | * it under the terms of the GNU General Public License as published by * | 12 | ._= =} : or (at your option) any later version. |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | .%`+i> _;_. |
14 | * (at your option) any later version. * | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | * * | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | ***************************************************************************/ | 16 | : .. .:, . . . without even the implied warranty of |
17 | #include <fstream> | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | #include <iostream> | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | using namespace std; | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | ||
21 | : = ...= . :.=- You should have received a copy of the GNU | ||
22 | -. .:....=;==+<; General Public License along with this file; | ||
23 | -_. . . )=. = see the file COPYING. If not, write to the | ||
24 | -- :-=` Free Software Foundation, Inc., | ||
25 | 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | |||
28 | */ | ||
20 | 29 | ||
21 | #ifdef QWS | 30 | #ifdef QWS |
22 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
@@ -25,7 +34,8 @@ using namespace std; | |||
25 | #include <qapplication.h> | 34 | #include <qapplication.h> |
26 | #endif | 35 | #endif |
27 | 36 | ||
28 | #include <stdio.h> | 37 | #include <qfile.h> |
38 | #include <qtextstream.h> | ||
29 | 39 | ||
30 | #include "datamgr.h" | 40 | #include "datamgr.h" |
31 | #include "global.h" | 41 | #include "global.h" |
@@ -88,7 +98,6 @@ void DataManager :: loadServers() | |||
88 | QString lineStr; | 98 | QString lineStr; |
89 | if ( fp == NULL ) | 99 | if ( fp == NULL ) |
90 | { | 100 | { |
91 | cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; | ||
92 | return; | 101 | return; |
93 | } | 102 | } |
94 | else | 103 | else |
@@ -198,23 +207,31 @@ void DataManager :: reloadServerData( ) | |||
198 | 207 | ||
199 | void DataManager :: writeOutIpkgConf() | 208 | void DataManager :: writeOutIpkgConf() |
200 | { | 209 | { |
210 | QFile f( IPKG_CONF ); | ||
211 | if ( !f.open( IO_WriteOnly ) ) | ||
212 | { | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | QTextStream t( &f ); | ||
217 | /* | ||
201 | QString ipkg_conf = IPKG_CONF; | 218 | QString ipkg_conf = IPKG_CONF; |
202 | ofstream out( ipkg_conf ); | 219 | ofstream out( ipkg_conf ); |
203 | 220 | */ | |
204 | out << "# Written by AQPkg" << endl; | 221 | t << "# Written by AQPkg\n"; |
205 | out << "# Must have one or more source entries of the form:" << endl; | 222 | t << "# Must have one or more source entries of the form:\n"; |
206 | out << "#" << endl; | 223 | t << "#\n"; |
207 | out << "# src <src-name> <source-url>" << endl; | 224 | t << "# src <src-name> <source-url>\n"; |
208 | out << "#" << endl; | 225 | t << "#\n"; |
209 | out << "# and one or more destination entries of the form:" << endl; | 226 | t << "# and one or more destination entries of the form:\n"; |
210 | out << "#" << endl; | 227 | t << "#\n"; |
211 | out << "# dest <dest-name> <target-path>" << endl; | 228 | t << "# dest <dest-name> <target-path>\n"; |
212 | out << "#" << endl; | 229 | t << "#\n"; |
213 | out << "# where <src-name> and <dest-names> are identifiers that" << endl; | 230 | t << "# where <src-name> and <dest-names> are identifiers that\n"; |
214 | out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; | 231 | t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; |
215 | out << "# URL that points to a directory containing a Familiar" << endl; | 232 | t << "# URL that points to a directory containing a Familiar\n"; |
216 | out << "# Packages file, and <target-path> should be a directory" << endl; | 233 | t << "# Packages file, and <target-path> should be a directory\n"; |
217 | out << "# that exists on the target system." << endl << endl; | 234 | t << "# that exists on the target system.\n\n"; |
218 | 235 | ||
219 | // Write out servers | 236 | // Write out servers |
220 | Server *server; | 237 | Server *server; |
@@ -229,63 +246,67 @@ void DataManager :: writeOutIpkgConf() | |||
229 | QString url = server->getServerUrl();; | 246 | QString url = server->getServerUrl();; |
230 | 247 | ||
231 | if ( !server->isServerActive() ) | 248 | if ( !server->isServerActive() ) |
232 | out << "#"; | 249 | t << "#"; |
233 | out << "src " << alias << " " << url << endl; | 250 | t << "src " << alias << " " << url << endl; |
234 | } | 251 | } |
235 | 252 | ||
236 | ++it; | 253 | ++it; |
237 | } | 254 | } |
238 | 255 | ||
239 | out << endl; | 256 | t << endl; |
240 | 257 | ||
241 | // Write out destinations | 258 | // Write out destinations |
242 | QListIterator<Destination> it2( destList ); | 259 | QListIterator<Destination> it2( destList ); |
243 | while ( it2.current() ) | 260 | while ( it2.current() ) |
244 | { | 261 | { |
245 | out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; | 262 | t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; |
246 | ++it2; | 263 | ++it2; |
247 | } | 264 | } |
248 | 265 | ||
249 | out << endl; | 266 | t << endl; |
250 | out << "# Proxy Support" << endl; | 267 | t << "# Proxy Support\n"; |
251 | 268 | ||
252 | if ( !httpProxyEnabled && httpProxy == "" ) | 269 | if ( !httpProxyEnabled && httpProxy == "" ) |
253 | out << "#option http_proxy http://proxy.tld:3128" << endl; | 270 | t << "#option http_proxy http://proxy.tld:3128\n"; |
254 | else | 271 | else |
255 | { | 272 | { |
256 | if ( !httpProxyEnabled ) | 273 | if ( !httpProxyEnabled ) |
257 | out << "#"; | 274 | t << "#"; |
258 | out << "option http_proxy " << httpProxy << endl; | 275 | t << "option http_proxy " << httpProxy << endl; |
259 | } | 276 | } |
260 | 277 | ||
261 | if ( !ftpProxyEnabled && ftpProxy == "" ) | 278 | if ( !ftpProxyEnabled && ftpProxy == "" ) |
262 | out << "#option ftp_proxy http://proxy.tld:3128" << endl; | 279 | t << "#option ftp_proxy http://proxy.tld:3128\n"; |
263 | else | 280 | else |
264 | { | 281 | { |
265 | if ( !ftpProxyEnabled ) | 282 | if ( !ftpProxyEnabled ) |
266 | out << "#"; | 283 | t << "#"; |
267 | out << "option ftp_proxy " << ftpProxy << endl; | 284 | t << "option ftp_proxy " << ftpProxy << endl; |
268 | } | 285 | } |
269 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 286 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
270 | out << "#option proxy_username <username>" << endl; | 287 | t << "#option proxy_username <username>\n"; |
271 | else | 288 | else |
272 | out << "option proxy_username " << proxyUsername << endl; | 289 | t << "option proxy_username " << proxyUsername << endl; |
273 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 290 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
274 | out << "#option proxy_password <password>" << endl << endl; | 291 | t << "#option proxy_password <password>\n\n"; |
275 | else | 292 | else |
276 | out << "option proxy_password " << proxyPassword << endl<< endl; | 293 | t << "option proxy_password " << proxyPassword << endl<< endl; |
277 | |||
278 | out << "# Offline mode (for use in constructing flash images offline)" << endl; | ||
279 | out << "#option offline_root target" << endl; | ||
280 | 294 | ||
295 | t << "# Offline mode (for use in constructing flash images offline)\n"; | ||
296 | t << "#option offline_root target\n"; | ||
281 | 297 | ||
282 | out.close(); | 298 | f.close(); |
283 | } | 299 | } |
284 | 300 | ||
285 | 301 | ||
286 | void DataManager :: setAvailableCategories( QString section ) | 302 | void DataManager :: setAvailableCategories( QString section ) |
287 | { | 303 | { |
288 | section = section.lower(); | 304 | QString sectstr = "#"; |
289 | if ( availableCategories.find( "#" + section + "#" ) == -1 ) | 305 | sectstr.append( section.lower() ); |
290 | availableCategories += section + "#"; | 306 | sectstr.append( "#" ); |
307 | if ( availableCategories.find( sectstr ) == -1 ) | ||
308 | { | ||
309 | availableCategories.append( section ); | ||
310 | availableCategories.append( "#" ); | ||
311 | } | ||
291 | } | 312 | } |