From e096c9d1f2be1ec74ede583fc4221871a56ef508 Mon Sep 17 00:00:00 2001 From: drw Date: Tue, 29 Apr 2003 02:28:16 +0000 Subject: Give aqpkg standard source headers and some minor code clean-up. --- (limited to 'noncore/settings/aqpkg/datamgr.cpp') 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 @@ -/*************************************************************************** - 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 -#include -using namespace std; +/* +                This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua +             .=l. Dan Williams +           .>+-= + _;:,     .>    :=|. 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_,=:_.      -`: 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 #include @@ -25,7 +34,8 @@ using namespace std; #include #endif -#include +#include +#include #include "datamgr.h" #include "global.h" @@ -88,7 +98,6 @@ void DataManager :: loadServers() QString lineStr; if ( fp == NULL ) { - cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; return; } else @@ -198,24 +207,32 @@ 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 \n"; + t << "#\n"; + t << "# and one or more destination entries of the form:\n"; + t << "#\n"; + t << "# dest \n"; + t << "#\n"; + t << "# where and are identifiers that\n"; + t << "# should match [a-zA-Z0-9._-]+, should be a\n"; + t << "# URL that points to a directory containing a Familiar\n"; + t << "# Packages file, and 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 " << endl; - out << "#" << endl; - out << "# and one or more destination entries of the form:" << endl; - out << "#" << endl; - out << "# dest " << endl; - out << "#" << endl; - out << "# where and are identifiers that" << endl; - out << "# should match [a-zA-Z0-9._-]+, should be a" << endl; - out << "# URL that points to a directory containing a Familiar" << endl; - out << "# Packages file, and should be a directory" << endl; - out << "# that exists on the target system." << endl << endl; - // Write out servers Server *server; QListIterator it( serverList ); @@ -229,63 +246,67 @@ void DataManager :: writeOutIpkgConf() QString url = server->getServerUrl();; if ( !server->isServerActive() ) - out << "#"; - out << "src " << alias << " " << url << endl; + t << "#"; + t << "src " << alias << " " << url << endl; } ++it; } - out << endl; + t << endl; // Write out destinations QListIterator it2( destList ); 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 " << endl; + t << "#option proxy_username \n"; else - out << "option proxy_username " << proxyUsername << endl; + t << "option proxy_username " << proxyUsername << endl; if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) - out << "#option proxy_password " << endl << endl; + t << "#option proxy_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(); } 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( "#" ); + } } -- cgit v0.9.0.2