author | wimpie <wimpie> | 2005-01-11 22:10:59 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-11 22:10:59 (UTC) |
commit | b0afa096730ac7893fcd25873f6fd09fcef32a95 (patch) (side-by-side diff) | |
tree | fc462fb9413e104b777f9f6d1439f4147e6c1350 | |
parent | 96678694f8952f60d0a895cede2b621404b4bfb8 (diff) | |
download | opie-b0afa096730ac7893fcd25873f6fd09fcef32a95.zip opie-b0afa096730ac7893fcd25873f6fd09fcef32a95.tar.gz opie-b0afa096730ac7893fcd25873f6fd09fcef32a95.tar.bz2 |
Changes now ok
this works again
8 files changed, 19 insertions, 17 deletions
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index 3f34bb2..4085b22 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -1,52 +1,52 @@ #include "cable_NN.h" #include "cable_NNI.h" #include "netnodeinterface.h" static const char * CableNeeds[] = { 0 }; static const char * CableProvides[] = { "line", 0 }; /** * Constructor, find all of the possible interfaces */ -CableNetNode::CableNetNode() : ANetNode(tr("Cable NetworkSetup")) { +CableNetNode::CableNetNode() : ANetNode(tr("Cable connection")) { } /** * Delete any interfaces that we own. */ CableNetNode::~CableNetNode(){ } const QString CableNetNode::nodeDescription(){ return tr("\ <p>Sets up a wired serial or parallel.</p>\ " ); } ANetNodeInstance * CableNetNode::createInstance( void ) { return new ACable( this ); } const char ** CableNetNode::needs( void ) { return CableNeeds; } const char ** CableNetNode::provides( void ) { return CableProvides; } void CableNetNode::setSpecificAttribute( QString & , QString & ) { } void CableNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> ) diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp index 374cf5a..e9553a6 100644 --- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp +++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp @@ -1,78 +1,78 @@ #include <resources.h> #include <qpe/qpeapplication.h> #include <netnode.h> #include "GPRS_NN.h" #include "GPRS_NNI.h" #include "netnodeinterface.h" static const char * GPRSNeeds[] = { "GPRS", 0 }; static const char * GPRSProvides[] = - { "NetworkSetup", + { "connection", 0 }; /** * Constructor, find all of the possible interfaces */ GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) { NSResources->addSystemFile( "pap-secrets", "/etc/ppp/pap-secrets", 0 ); } /** * Delete any interfaces that we own. */ GPRSNetNode::~GPRSNetNode(){ } const QString GPRSNetNode::nodeDescription(){ return tr("\ <p>provides access to a GPRS capable device.</p>\ " ); } ANetNodeInstance * GPRSNetNode::createInstance( void ) { return new AGPRSDevice( this ); } bool GPRSNetNode::hasDataForFile( SystemFile & S ) { return S.name() == "pap-secrets"; } short GPRSNetNode::generateFile( SystemFile & , ANetNodeInstance * , long ) { return 0; } const char ** GPRSNetNode::needs( void ) { return GPRSNeeds; } const char ** GPRSNetNode::provides( void ) { return GPRSProvides; } void GPRSNetNode::setSpecificAttribute( QString & , QString & ) { } void GPRSNetNode::saveSpecificAttribute( QTextStream & ) { } QStringList GPRSNetNode::properFiles( void ) { QStringList SL; SL << "peers"; SL << "chatscripts"; SL << "extra"; return SL; } OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> ) diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 80a7fac..2fa31bd 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -1,95 +1,95 @@ #include <qpe/qpeapplication.h> #include <resources.h> #include <netnode.h> #include "network_NN.h" #include "network_NNI.h" #include "netnodeinterface.h" static const char * NetworkNeeds[] = { "device", 0 }; static const char * NetworkProvides[] = - { "NetworkSetup", + { "connection", 0 }; /** * Constructor, find all of the possible interfaces */ NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { NSResources->addSystemFile( "interfaces", "/etc/network/interfaces", 1 ); } /** * Delete any interfaces that we own. */ NetworkNetNode::~NetworkNetNode(){ } const QString NetworkNetNode::nodeDescription(){ return tr("\ <p>Sets up TCP/IP options.</p>\ <p>Use this to configure the TCP/IP protocol</p>\ " ); } ANetNodeInstance * NetworkNetNode::createInstance( void ) { return new ANetwork( this ); } bool NetworkNetNode::hasDataForFile( SystemFile & S ) { return S.name() == "interfaces"; } short NetworkNetNode::generateFile( SystemFile & SF, ANetNodeInstance * NNI, long DevNr ) { if( DevNr < 0 ) { // generate device specific but common part return 1; } QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); if( SF.name() == "interfaces" ) { Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); // generate mapping stanza for this interface SF << "# check if " << NIC << " can be brought UP" << endl; SF << "mapping " << NIC << endl; SF << " script " << QPEApplication::qpeDir() << "bin/networksettings2-request" << endl << endl; return 0; } return 1; } const char ** NetworkNetNode::needs( void ) { return NetworkNeeds; } const char ** NetworkNetNode::provides( void ) { return NetworkProvides; } void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { } void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> ) diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 0e72c25..2dd91f8 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -1,379 +1,381 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <pwd.h> #include <qpixmap.h> #include <qdir.h> #include <qmessagebox.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <opie2/odebug.h> #include <opie2/opluginloader.h> #include <qtopia/resource.h> #include "netnode.h" #include "resources.h" #include "netnodeinterface.h" #define PLUGINDIR "plugins/networksettings2" #define ICONDIR "/pics/networksettings2/" // single resources instance TheNSResources * _NSResources = 0; TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), NetworkSetupsMap(), DanglingNetworkSetupsMap() { _NSResources = this; detectCurrentUser(); // load available netnodes Plugins = 0; findAvailableNetNodes(); // compile provides and needs lists { const char ** NeedsRun; QDictIterator<ANetNode> OuterIt( AllNodeTypes ); bool Done; for ( ; OuterIt.current(); ++OuterIt ) { // find needs list ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; ANetNode::NetNodeList & NNL = *(NNLP); // must iterate this way to avoid duplication pointers for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes ); InnerIt.current(); ++InnerIt ) { if( InnerIt.current() == OuterIt.current() ) // avoid recursive continue; const char ** Provides = InnerIt.current()->provides(); NeedsRun = OuterIt.current()->needs(); for( ; *NeedsRun; NeedsRun ++ ) { const char ** PRun; PRun = Provides; for( ; *PRun; PRun ++ ) { if( strcmp( *PRun, *NeedsRun ) == 0 ) { // inner provides what outer needs NNL.resize( NNL.size() + 1 ); NNL[NNL.size()-1] = InnerIt.current(); Done = 1; // break from 2 loops break; } } } } OuterIt.current()->setAlternatives( NNLP ); } } // define built in Node types to Description map addNodeType( "device", tr( "Network Device" ), tr( "<p>Devices that can handle IP packets</p>" ) ); addNodeType( "line", tr( "Character device" ), tr( "<p>Devices that can handle single bytes</p>" ) ); addNodeType( "NetworkSetup", tr( "IP NetworkSetup" ), tr( "<p>Nodes that provide working IP NetworkSetups</p>" ) ); addNodeType( "fullsetup", tr( "NetworkSetup Profile" ), tr( "<p>Fully configured NetworkSetup profile</p>" ) ); addNodeType( "GPRS", tr( "NetworkSetup to GPRS device" ), tr( "<p>NetworkSetup to a GPRS capable device</p>" ) ); // get access to the system TheSystem = new System(); } TheNSResources::~TheNSResources( void ) { if( Plugins ) { delete Plugins; delete PluginManager; } delete TheSystem; } void TheNSResources::addNodeType( const QString & ID, const QString & Name, const QString & Descr ) { if( NodeTypeNameMap[ID].isEmpty() ) { NodeTypeNameMap.insert( ID, Name ); NodeTypeDescriptionMap.insert( ID, Descr ); } } void TheNSResources::addSystemFile( const QString & ID, const QString & P, bool KDI ) { if( ! SystemFiles.find( ID ) ) { // new system file SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) ); } // else existed } void TheNSResources::busy( bool ) { /* if( B ) { ShowWait->show(); qApp->process } else { ShowWait->hide(); } */ } void TheNSResources::findAvailableNetNodes( void ){ Plugins = new OPluginLoader( "networksettings2" ); Plugins->setAutoDelete( true ); PluginManager = new OPluginManager( Plugins ); PluginManager->load(); if( Plugins->isInSafeMode() ) { QMessageBox::information( 0, tr( "Today Error"), tr( "<qt>The plugin '%1' caused Today to crash." " It could be that the plugin is not properly" " installed.<br>Today tries to continue loading" " plugins.</qt>" ) .arg( PluginManager->crashedPlugin().name())); } // Get All Plugins OPluginLoader::List allplugins = Plugins->filtered(); QString lang = ::getenv("LANG"); for( OPluginLoader::List::Iterator it = allplugins.begin(); it != allplugins.end(); ++it ) { // check if this plugin supports the proper interface NetNodeInterface * interface = Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 ); if( ! interface ) { Log(( "Plugin %s from %s does not support proper interface\n", (*it).name().latin1(), (*it).path().latin1() )); continue; } // add the nodes in this plugin to the dictionary { QList<ANetNode> PNN; interface->create_plugin( PNN ); if( PNN.isEmpty() ) { Log(( "Plugin %s from %s does offer any nodes\n", (*it).name().latin1(), (*it).path().latin1() )); delete interface; continue; } // merge this node with global node - for( QListIterator<ANetNode> it(PNN); - it.current(); - ++it ) { - AllNodeTypes.insert( it.current()->name(), it.current() ); + for( QListIterator<ANetNode> nnit(PNN); + nnit.current(); + ++nnit ) { + Log(( "Found node type %s in plugin %s\n", + nnit.current()->name(), (*it).name().latin1() )); + AllNodeTypes.insert( nnit.current()->name(), nnit.current() ); } } // load the translation QTranslator *trans = new QTranslator(qApp); QString fn = QPEApplication::qpeDir()+ "/i18n/"+lang+"/"+ (*it).name() + ".qm"; if( trans->load( fn ) ) qApp->installTranslator( trans ); else delete trans; } } // used to find unique NetworkSetup number int TheNSResources::assignNetworkSetupNumber( void ) { bool found = 1; for( int trial = 0; ; trial ++ ) { found = 1; for( QDictIterator<NetworkSetup> it(NetworkSetupsMap); it.current(); ++it ) { if( it.current()->number() == trial ) { found = 0; break; } } if( found ) { Log(("Assign profile number %d\n", trial )); return trial; } } } QPixmap TheNSResources::getPixmap( const QString & QS ) { QPixmap P; QString S("networksettings2/"); S += QS; P = Resource::loadPixmap( S ); if( P.isNull() ) { Log(( "Cannot load %s\n", S.latin1() )); } return ( P.isNull() ) ? QPixmap() : P; } QString TheNSResources::tr( const char * s ) { return qApp->translate( "resource", s ); } const QString & TheNSResources::netNode2Name( const char * s ) { return NodeTypeNameMap[s]; } const QString & TheNSResources::netNode2Description( const char * s ) { return NodeTypeDescriptionMap[s]; } void TheNSResources::addNetworkSetup( NetworkSetup * NC, bool Dangling ) { ANetNodeInstance * NNI; Log(( "Add NetworkSetup %s, Dangling %d\n", NC->name().latin1(), Dangling )); if( Dangling ) { DanglingNetworkSetupsMap.insert( NC->name(), NC ); } else { NetworkSetupsMap.insert( NC->name(), NC ); } // add (new) nodes to NodeList for( QListIterator<ANetNodeInstance> it(*NC); it.current(); ++it ) { NNI = it.current(); if( findNodeInstance( NNI->name() ) == 0 ) { // new item addNodeInstance( NNI ); } } } void TheNSResources::removeNetworkSetup( const QString & N ) { NetworkSetup * NC = findNetworkSetup( N ); if( ! NC ) return; // delete netnodes in this NetworkSetup ANetNodeInstance * NNI; for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { removeNodeInstance( NNI->name() ); } if( NetworkSetupsMap.find( N ) ) { NetworkSetupsMap.remove( N ); } else { DanglingNetworkSetupsMap.remove( N ); } } // dangling NetworkSetups are filtered out NetworkSetup * TheNSResources::findNetworkSetup( const QString & S ) { return NetworkSetupsMap[ S ]; } NetworkSetup * TheNSResources::getNetworkSetup( int nr ) { for( QDictIterator<NetworkSetup> it(NetworkSetupsMap); it.current(); ++it ) { if( it.current()->number() == nr ) { return it.current(); } } return 0; } /* void TheNSResources::renumberNetworkSetups( void ) { Name2NetworkSetup_t & M = NSResources->NetworkSetups(); NetworkSetup * NC; // for all NetworkSetups NetworkSetup::resetMaxNr(); for( QDictIterator<NetworkSetup> it(M); it.current(); ++it ) { NC = it.current(); NC->setNumber( NC->maxNetworkSetupNumber()+1 ); NC->setModified( 1 ); } } */ typedef struct EnvVars { char * Name; int Len; } EnvVar_t; #define AnEV(x) x, sizeof(x)-1 static EnvVar_t EV[] = { AnEV( "HOME" ), AnEV( "LOGNAME" ), AnEV( "USER" ), AnEV( "LD_LIBRARY_PATH" ), AnEV( "PATH" ), AnEV( "QTDIR" ), AnEV( "OPIEDIR" ), AnEV( "SHELL" ), { NULL, 0 } }; void TheNSResources::detectCurrentUser( void ) { // find current running qpe QString QPEEnvFile = ""; CurrentUser.UserName = ""; CurrentUser.HomeDir = ""; if( getenv( "OPIEDIR" ) == 0 ) { // nothing known { // open proc dir and find all dirs in it QRegExp R("[0-9]+"); QDir ProcDir( "/proc" ); QFileInfo FI; QStringList EL = ProcDir.entryList( QDir::Dirs ); // print it out for ( QStringList::Iterator it = EL.begin(); it != EL.end(); ++it ) { if( R.match( (*it) ) >= 0 ) { QString S = ProcDir.path()+"/"+ (*it); S.append( "/exe" ); FI.setFile( S ); // get the link S = FI.readLink(); if( S.right( 8 ) == "/bin/qpe" ) { // found running qpe QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" ); break; } } } } if( QPEEnvFile.isEmpty() ) { // could not find qpe Log(("Could not find qpe\n" )); return; } // FI now contains path ProcDir to the cmd dir diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index 884168c..6c1387d 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -1,83 +1,83 @@ #include <qfile.h> #include <resources.h> #include <qtextstream.h> #include "ppp_NN.h" #include "ppp_NNI.h" #include "netnodeinterface.h" QStringList * PPPNetNode::ProperFiles = 0; static const char * PPPNeeds[] = { "modem", 0 }; static const char * PPPProvides[] = - { "NetworkSetup", + { "connection", 0 }; /** * Constructor, find all of the possible interfaces */ -PPPNetNode::PPPNetNode() : ANetNode(tr("PPP NetworkSetup")) { +PPPNetNode::PPPNetNode() : ANetNode(tr("PPP connection")) { NSResources->addSystemFile( "pap-secrets", "/etc/ppp/pap-secrets", 0 ); NSResources->addSystemFile( "chap-secrets", "/etc/ppp/chap-secrets", 0 ); } /** * Delete any interfaces that we own. */ PPPNetNode::~PPPNetNode(){ } const QString PPPNetNode::nodeDescription(){ return tr("\ <p>Sets up IP using PPP.</p>\ <p>Use this for dialup devices or serial setups</p>\ " ); } ANetNodeInstance * PPPNetNode::createInstance( void ) { return new APPP( this ); } const char ** PPPNetNode::needs( void ) { return PPPNeeds; } const char ** PPPNetNode::provides( void ) { return PPPProvides; } QStringList PPPNetNode::properFiles( void ) { QStringList SL; SL << "peers" << "chatscripts"; return SL; } // need to generate : // /etc/ppp/pap-secrets // /etc/ppp/pap-secrets bool PPPNetNode::hasDataForFile( SystemFile & S ) { return S.name() == "pap-secrets" || S.name() == "chap-secrets" ; } QString PPPNetNode::genNic( long NicNr ) { QString S; return S.sprintf( "ppp%ld", NicNr ); } void PPPNetNode::setSpecificAttribute( QString & , QString & ) { } void PPPNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> ) diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 007f4a5..1e6912e 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp @@ -1,58 +1,58 @@ #include <resources.h> #include "profile_NN.h" #include "profile_NNI.h" #include "netnodeinterface.h" static const char * ProfileNeeds[] = - { "NetworkSetup", + { "connection", 0 }; static const char * ProfileProvides[] = { "fullsetup", 0 }; /** * Constructor, find all of the possible interfaces */ -ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular NetworkSetup profile")) { +ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { NSResources->addSystemFile( "interfaces", "/etc/network/interfaces", 1 ); } /** * Delete any interfaces that we own. */ ProfileNetNode::~ProfileNetNode(){ } const QString ProfileNetNode::nodeDescription(){ return tr("\ -<p>Define use of an IP NetworkSetup.</p>\ -<p>Configure if and when this NetworkSetup needs to be established</p>\ +<p>Define use of an IP connection.</p>\ +<p>Configure if and when this connection needs to be established</p>\ " ); } ANetNodeInstance * ProfileNetNode::createInstance( void ) { return new AProfile( this ); } const char ** ProfileNetNode::needs( void ) { return ProfileNeeds; } const char ** ProfileNetNode::provides( void ) { return ProfileProvides; } void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { } void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> ) diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 6e2597c..6d90ae0 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp @@ -1,60 +1,60 @@ #include <resources.h> #include "usb_NN.h" #include "usb_NNI.h" #include "netnodeinterface.h" static const char * USBNeeds[] = { 0 }; static const char * USBProvides[] = { "device", 0 }; /** * Constructor, find all of the possible interfaces */ USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { NSResources->addSystemFile( "interfaces", "/etc/network/interfaces", 1 ); } /** * Delete any interfaces that we own. */ USBNetNode::~USBNetNode(){ } const QString USBNetNode::nodeDescription(){ return tr("\ <p>Configure Ethernet over USB.</p>\ -<p>Use this for a computer to computer USB cable NetworkSetup</p>\ +<p>Use this for a computer to computer USB cable connection</p>\ " ); } ANetNodeInstance * USBNetNode::createInstance( void ) { return new AUSB( this ); } const char ** USBNetNode::needs( void ) { return USBNeeds; } const char ** USBNetNode::provides( void ) { return USBProvides; } QString USBNetNode::genNic( long ) { return QString( "usbf" ); } void USBNetNode::setSpecificAttribute( QString & , QString & ) { } void USBNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> ) diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index 7c2e77b..beb9215 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp @@ -1,52 +1,52 @@ #include "vpn_NN.h" #include "vpn_NNI.h" #include "netnodeinterface.h" static const char * VPNNeeds[] = { 0 }; static const char * VPNProvides[] = - { "NetworkSetup", + { "connection", 0 }; /** * Constructor, find all of the possible interfaces */ -VPNNetNode::VPNNetNode() : ANetNode(tr("VPN NetworkSetup")) { +VPNNetNode::VPNNetNode() : ANetNode(tr("VPN connection")) { } /** * Delete any interfaces that we own. */ VPNNetNode::~VPNNetNode(){ } const QString VPNNetNode::nodeDescription(){ return tr("\ -<p>Configure private IP NetworkSetup.</p>\ +<p>Configure private IP connection.</p>\ <p>Defines Secure tunnels over non secure IP sessions</p>\ " ); } ANetNodeInstance * VPNNetNode::createInstance( void ) { return new AVPN( this ); } const char ** VPNNetNode::needs( void ) { return VPNNeeds; } const char ** VPNNetNode::provides( void ) { return VPNProvides; } void VPNNetNode::setSpecificAttribute( QString & , QString & ) { } void VPNNetNode::saveSpecificAttribute( QTextStream & ) { } OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> ) |