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,21 +1,30 @@ -/*************************************************************************** - datamgr.cpp - description - ------------------- - begin : Thu Aug 29 2002 - copyright : (C) 2002 by Andy Qua - email : andy.qua@blueyonder.co.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#include <fstream> -#include <iostream> -using namespace std; +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifdef QWS @@ -26,5 +35,6 @@ using namespace std; #endif -#include <stdio.h> +#include <qfile.h> +#include <qtextstream.h> #include "datamgr.h" @@ -89,5 +99,4 @@ void DataManager :: loadServers() if ( fp == NULL ) { - cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; return; } @@ -199,22 +208,30 @@ void DataManager :: reloadServerData( ) void DataManager :: writeOutIpkgConf() { + QFile f( IPKG_CONF ); + if ( !f.open( IO_WriteOnly ) ) + { + return; + } + + QTextStream t( &f ); +/* QString ipkg_conf = IPKG_CONF; ofstream out( ipkg_conf ); +*/ + t << "# Written by AQPkg\n"; + t << "# Must have one or more source entries of the form:\n"; + t << "#\n"; + t << "# src <src-name> <source-url>\n"; + t << "#\n"; + t << "# and one or more destination entries of the form:\n"; + t << "#\n"; + t << "# dest <dest-name> <target-path>\n"; + t << "#\n"; + t << "# where <src-name> and <dest-names> are identifiers that\n"; + t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; + t << "# URL that points to a directory containing a Familiar\n"; + t << "# Packages file, and <target-path> should be a directory\n"; + t << "# that exists on the target system.\n\n"; - out << "# Written by AQPkg" << endl; - out << "# Must have one or more source entries of the form:" << endl; - out << "#" << endl; - out << "# src <src-name> <source-url>" << endl; - out << "#" << endl; - out << "# and one or more destination entries of the form:" << endl; - out << "#" << endl; - out << "# dest <dest-name> <target-path>" << endl; - out << "#" << endl; - out << "# where <src-name> and <dest-names> are identifiers that" << endl; - out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; - out << "# URL that points to a directory containing a Familiar" << endl; - out << "# Packages file, and <target-path> should be a directory" << endl; - out << "# that exists on the target system." << endl << endl; - // Write out servers Server *server; @@ -230,6 +247,6 @@ void DataManager :: writeOutIpkgConf() if ( !server->isServerActive() ) - out << "#"; - out << "src " << alias << " " << url << endl; + t << "#"; + t << "src " << alias << " " << url << endl; } @@ -237,5 +254,5 @@ void DataManager :: writeOutIpkgConf() } - out << endl; + t << endl; // Write out destinations @@ -243,42 +260,41 @@ void DataManager :: writeOutIpkgConf() while ( it2.current() ) { - out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; + t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; ++it2; } - out << endl; - out << "# Proxy Support" << endl; + t << endl; + t << "# Proxy Support\n"; if ( !httpProxyEnabled && httpProxy == "" ) - out << "#option http_proxy http://proxy.tld:3128" << endl; + t << "#option http_proxy http://proxy.tld:3128\n"; else { if ( !httpProxyEnabled ) - out << "#"; - out << "option http_proxy " << httpProxy << endl; + t << "#"; + t << "option http_proxy " << httpProxy << endl; } if ( !ftpProxyEnabled && ftpProxy == "" ) - out << "#option ftp_proxy http://proxy.tld:3128" << endl; + t << "#option ftp_proxy http://proxy.tld:3128\n"; else { if ( !ftpProxyEnabled ) - out << "#"; - out << "option ftp_proxy " << ftpProxy << endl; + t << "#"; + t << "option ftp_proxy " << ftpProxy << endl; } if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) - out << "#option proxy_username <username>" << endl; + t << "#option proxy_username <username>\n"; else - out << "option proxy_username " << proxyUsername << endl; + t << "option proxy_username " << proxyUsername << endl; if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) - out << "#option proxy_password <password>" << endl << endl; + t << "#option proxy_password <password>\n\n"; else - out << "option proxy_password " << proxyPassword << endl<< endl; - - out << "# Offline mode (for use in constructing flash images offline)" << endl; - out << "#option offline_root target" << endl; + t << "option proxy_password " << proxyPassword << endl<< endl; + t << "# Offline mode (for use in constructing flash images offline)\n"; + t << "#option offline_root target\n"; - out.close(); + f.close(); } @@ -286,6 +302,11 @@ void DataManager :: writeOutIpkgConf() void DataManager :: setAvailableCategories( QString section ) { - section = section.lower(); - if ( availableCategories.find( "#" + section + "#" ) == -1 ) - availableCategories += section + "#"; + QString sectstr = "#"; + sectstr.append( section.lower() ); + sectstr.append( "#" ); + if ( availableCategories.find( sectstr ) == -1 ) + { + availableCategories.append( section ); + availableCategories.append( "#" ); + } } |