Diffstat (limited to 'noncore/settings/aqpkg/datamgr.cpp') (more/less context) (ignore 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,20 +1,29 @@ | |||
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 | ||
@@ -27,3 +36,4 @@ using namespace std; | |||
27 | 36 | ||
28 | #include <stdio.h> | 37 | #include <qfile.h> |
38 | #include <qtextstream.h> | ||
29 | 39 | ||
@@ -90,3 +100,2 @@ void DataManager :: loadServers() | |||
90 | { | 100 | { |
91 | cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; | ||
92 | return; | 101 | return; |
@@ -200,20 +209,28 @@ 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 ); |
220 | */ | ||
221 | t << "# Written by AQPkg\n"; | ||
222 | t << "# Must have one or more source entries of the form:\n"; | ||
223 | t << "#\n"; | ||
224 | t << "# src <src-name> <source-url>\n"; | ||
225 | t << "#\n"; | ||
226 | t << "# and one or more destination entries of the form:\n"; | ||
227 | t << "#\n"; | ||
228 | t << "# dest <dest-name> <target-path>\n"; | ||
229 | t << "#\n"; | ||
230 | t << "# where <src-name> and <dest-names> are identifiers that\n"; | ||
231 | t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; | ||
232 | t << "# URL that points to a directory containing a Familiar\n"; | ||
233 | t << "# Packages file, and <target-path> should be a directory\n"; | ||
234 | t << "# that exists on the target system.\n\n"; | ||
203 | 235 | ||
204 | out << "# Written by AQPkg" << endl; | ||
205 | out << "# Must have one or more source entries of the form:" << endl; | ||
206 | out << "#" << endl; | ||
207 | out << "# src <src-name> <source-url>" << endl; | ||
208 | out << "#" << endl; | ||
209 | out << "# and one or more destination entries of the form:" << endl; | ||
210 | out << "#" << endl; | ||
211 | out << "# dest <dest-name> <target-path>" << endl; | ||
212 | out << "#" << 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; | ||
215 | out << "# URL that points to a directory containing a Familiar" << endl; | ||
216 | out << "# Packages file, and <target-path> should be a directory" << endl; | ||
217 | out << "# that exists on the target system." << endl << endl; | ||
218 | |||
219 | // Write out servers | 236 | // Write out servers |
@@ -231,4 +248,4 @@ void DataManager :: writeOutIpkgConf() | |||
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 | } |
@@ -238,3 +255,3 @@ void DataManager :: writeOutIpkgConf() | |||
238 | 255 | ||
239 | out << endl; | 256 | t << endl; |
240 | 257 | ||
@@ -244,3 +261,3 @@ void DataManager :: writeOutIpkgConf() | |||
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; |
@@ -248,7 +265,7 @@ void DataManager :: writeOutIpkgConf() | |||
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 |
@@ -256,4 +273,4 @@ void DataManager :: writeOutIpkgConf() | |||
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 | } |
@@ -261,3 +278,3 @@ void DataManager :: writeOutIpkgConf() | |||
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 |
@@ -265,19 +282,18 @@ void DataManager :: writeOutIpkgConf() | |||
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 | } |
@@ -287,5 +303,10 @@ 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 | } |