27 files changed, 217 insertions, 128 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index 3d1aa69..4579e37 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp @@ -18,2 +18,3 @@ static const char * BluetoothBNEPNeeds[] = BluetoothBNEPNetNode::BluetoothBNEPNetNode() : ANetNode() { + InstanceCount = 7; // default } @@ -66,5 +67,18 @@ QString BluetoothBNEPNetNode::genNic( long nr ) { + +void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { + if( A == "interfacecount" ) { + InstanceCount = V.toLong(); + } +} + +void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { + TS << "interfacecount=" + << InstanceCount + << endl; +} + // // -// BLUETOOTH PAN/NAP node +// BLUETOOTH RFCOMM // @@ -117,2 +131,8 @@ bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile( +void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { +} + +void BluetoothRFCOMMNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index 5cd6c52..882d2e3 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h @@ -35,3 +35,3 @@ public: virtual long instanceCount( void ) - { return 7; } + { return InstanceCount; } virtual QString genNic( long ); @@ -40,2 +40,8 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + + // number of interfaces for this device + long InstanceCount; + }; @@ -71,2 +77,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index a6be4d5..dd41c1f 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -49,2 +49,8 @@ bool CableNetNode::generateDeviceDataForCommonFile( +void CableNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void CableNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index 83b98e0..b37f31a 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 96327a5..49b7707 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp @@ -49,2 +49,8 @@ bool IRDANetNode::generateDeviceDataForCommonFile( +void IRDANetNode::setSpecificAttribute( QString & , QString & ) { +} + +void IRDANetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index a5b6cc5..2dcef74 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 480ddf9..ba1c1f8 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp @@ -10,2 +10,3 @@ static const char * LanCardNeeds[] = LanCardNetNode::LanCardNetNode() : ANetNode() { + InstanceCount = 2; } @@ -67,2 +68,14 @@ QString LanCardNetNode::genNic( long nr ) { +void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) { + if( A == "interfacecount" ) { + InstanceCount = V.toLong(); + } +} + +void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { + TS << "interfacecount=" + << InstanceCount + << endl; +} + extern "C" { diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index dcdd0da..5f2b25d 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h @@ -35,3 +35,3 @@ public: virtual long instanceCount( void ) - { return 2; } + { return InstanceCount; } @@ -41,2 +41,8 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + + // number of interfaces for this device + long InstanceCount; + }; diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index 65b06ee..1cc8524 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp @@ -50,2 +50,8 @@ bool ModemNetNode::generateDeviceDataForCommonFile( +void ModemNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void ModemNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index 49244b2..849f928 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 4a77e6a..d27d54a 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -51,2 +51,8 @@ bool NetworkNetNode::generateDeviceDataForCommonFile( +void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 59f0526..0f87e1b 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index fcc6044..3691e5a 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -47,5 +47,20 @@ QString quote( QString X ) { + +// +// +// ANETNODE +// // + +void ANetNode::saveAttributes( QTextStream & TS ) { + saveSpecificAttribute( TS ); +} + +void ANetNode::setAttribute( QString & Attr, QString & Value ){ + setSpecificAttribute( Attr, Value ); +} + // // +// ANETNODEINSTANCE // @@ -84,3 +99,3 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) { // -// +// NODECOLLECTION // @@ -271,2 +286,8 @@ void NodeCollection::reassign( void ) { +// +// +// RUNTIMEINFO +// +// + InterfaceInfo * RuntimeInfo::assignedInterface( void ) { @@ -278,25 +299 @@ AsDevice * RuntimeInfo::device( void ) { } - -ANetNodeInstance * FakeNetNode::createInstance( void ) { - return new FakeNetNodeInstance( this ); -} - -void FakeNetNodeInstance::setSpecificAttribute( - QString & A, QString & V ) { - ValAttrPairs.insert( A, new QString(V) ); -} - -void FakeNetNodeInstance::saveSpecificAttribute( QTextStream &TS ) { - for( QDictIterator<QString> it( ValAttrPairs ); - it.current(); - ++ it ) { - TS << it.currentKey().latin1() - << "=" - << quote( *(it.current())) - << endl ; - ++it; - } -} - -// collects all info that no plugin acceps -FakeNetNode * FakeNode = 0; diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 9681c6e..6ec9ef6 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h @@ -117,2 +117,6 @@ public: + // set the value of an attribute + void setAttribute( QString & Attr, QString & Value ) ; + void saveAttributes( QTextStream & TS ) ; + // compiled references to 'needed' NetNodes -> needs list @@ -128,2 +132,6 @@ protected : private : + + virtual void setSpecificAttribute( QString & , QString & ) = 0; + virtual void saveSpecificAttribute( QTextStream & ) = 0; + }; @@ -380,86 +388,2 @@ private : -// -// special node that is used to remember entries for plugins -// that seem missing. This way we never loose data -// - -class FakeNetNode : public ANetNode { - -public: - - FakeNetNode( ) { }; - virtual ~FakeNetNode(){}; - - const QString pixmapName() - { return QString(""); } - const QString nodeName() - { return QString("Fake node" ); } - const QString nodeDescription() - { return QString("Fake node" ); } - ANetNodeInstance * createInstance( void ); - const char * provides( void ) - { return ""; } - virtual const char ** needs( void ) - { return 0; } - virtual bool generateProperFilesFor( ANetNodeInstance * ) - { return 0; } - virtual bool hasDataFor( const QString & ) - { return 0; } - virtual bool generateDeviceDataForCommonFile( - SystemFile & , long ) - {return 1; } - -private : - -}; - -class FakeNetNodeInstance : public ANetNodeInstance { - -public: - - FakeNetNodeInstance( ANetNode * NN ) : - ANetNodeInstance( NN ), ValAttrPairs() { } - virtual ~FakeNetNodeInstance( void ) { } - - virtual RuntimeInfo * runtime( void ) - { return 0; } - - // create edit widget under parent - virtual QWidget * edit( QWidget * ) - { return 0; } - // is given data acceptable - virtual QString acceptable( void ) - { return QString(""); } - - // get data from GUI and store in node - virtual void commit( void ) {} - - // get next node - ANetNodeInstance * nextNode() - { return 0; } - // return NetNode this is an instance of - - // intialize am instance of a net node - void initialize( void ){} - - // returns node specific data -> only useful for 'buddy' - virtual void * data( void ) - { return 0; } - - virtual bool hasDataFor( const QString & ) - { return 0; } - - virtual bool generateDataForCommonFile( SystemFile & , long ) - { return 1; } - -protected : - - virtual void setSpecificAttribute( QString & , QString & ); - virtual void saveSpecificAttribute( QTextStream & ); - - QDict<QString> ValAttrPairs; -}; - -extern FakeNetNode * FakeNode; - #endif diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 3048fb3..7050f10 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h @@ -57,2 +57,6 @@ public : { return AllNodeTypes.find(X)!=0; } + ANetNode * findNetNode( const QString & N ) + { NetNode_t * NNT = AllNodeTypes.find(N); + return (NNT) ? NNT->NetNode : 0; + } @@ -66,10 +70,6 @@ public : NetNode_t * NNT = AllNodeTypes[S]; - ANetNode * NN; if( ! NNT ) { - NN = FakeNode = - ( FakeNode ) ? FakeNode : new FakeNetNode(); - } else { - NN = NNT->NetNode; + return 0; } - NNI = NN->createInstance(); + NNI = NNT->NetNode->createInstance(); NNI->initialize(); diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4d9aaa..13979ce 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -33,4 +33,3 @@ NetworkSettingsData::~NetworkSettingsData( void ) { void NetworkSettingsData::loadSettings( void ) { - QString S; - ANetNodeInstance* NNI; + QString Line, S; QString Attr, Value; @@ -59,3 +58,3 @@ void NetworkSettingsData::loadSettings( void ) { while( ! TS.atEnd() ) { - S = TS.readLine(); + S = Line = TS.readLine(); @@ -75,6 +74,12 @@ void NetworkSettingsData::loadSettings( void ) { } else { - // load nodes + ANetNode * NN = 0; + ANetNodeInstance* NNI = 0; + if( S.startsWith( "nodetype " ) ) { + S = S.mid( 9, S.length()-9-1 ); + fprintf( stderr, "Node %s\n", S.latin1() ); + // try to find netnode + NN = NSResources->findNetNode( S ); + } else { + // try to find instance NNI = NSResources->createNodeInstance( S ); - if( ! NNI ) { - printf( "SKIPPING %s\n", S.latin1() ); } @@ -83,2 +88,4 @@ void NetworkSettingsData::loadSettings( void ) { S = TS.readLine(); + + if( NN || NNI ) { if( S.isEmpty() ) { @@ -87,4 +94,2 @@ void NetworkSettingsData::loadSettings( void ) { } - // node found ? - if( NNI ) { idx = S.find( '=' ); @@ -104,2 +109,6 @@ void NetworkSettingsData::loadSettings( void ) { + if( NN ) { + // set the attribute + NNI->setAttribute( Attr, Value ); + } else { // set the attribute @@ -107,3 +116,10 @@ void NetworkSettingsData::loadSettings( void ) { } - + } else { + LeftOvers.append( Line ); + // add empty line too as delimiter + if( S.isEmpty() ) { + // empty line + break; + } + } } while( 1 ); @@ -140,2 +156,21 @@ QString NetworkSettingsData::saveSettings( void ) { QTextStream TS( &F ); + + // save leftovers + for ( QStringList::Iterator it = LeftOvers.begin(); + it != LeftOvers.end(); ++it ) { + TS << (*it) << endl; + } + + // save global configs + for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); + it.current(); + ++it ) { + TS << "[nodetype " + << it.current()->NetNode->name() + << "]" + << endl; + + it.current()->NetNode->saveAttributes( TS ); + } + { Name2Connection_t & M = NSResources->connections(); diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index eb96930..57eb722 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h @@ -40,2 +40,5 @@ private : + // collect strings in config file nobody wants + QStringList LeftOvers; + }; diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index b3f70c5..0bf415b 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -57,2 +57,8 @@ QString PPPNetNode::genNic( long NicNr ) { +void PPPNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void PPPNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index c33f281..fbbbbe1 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h @@ -39,2 +39,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 7609cdc..0f71dc7 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp @@ -51,2 +51,8 @@ bool ProfileNetNode::generateDeviceDataForCommonFile( +void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index f7c2b22..1313ab2 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 30c72db..d5971cf 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp @@ -66,2 +66,8 @@ QString USBNetNode::genNic( long ) { +void USBNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void USBNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index ba22b1c..0b83ea6 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h @@ -38,2 +38,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index d9aa892..307e9dd 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp @@ -51,2 +51,8 @@ bool VPNNetNode::generateDeviceDataForCommonFile( +void VPNNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void VPNNetNode::saveSpecificAttribute( QTextStream & ) { +} + extern "C" { diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index 7ce8e3a..1cd3fcc 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h @@ -37,2 +37,4 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); }; diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index 4e59ac1..e0c4db2 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp @@ -11,2 +11,3 @@ static const char * WLanNeeds[] = WLanNetNode::WLanNetNode() : ANetNode() { + InstanceCount = 2; } @@ -67,2 +68,14 @@ QString WLanNetNode::genNic( long nr ) { +void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { + if( A == "interfacecount" ) { + InstanceCount = V.toLong(); + } +} + +void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { + TS << "interfacecount=" + << InstanceCount + << endl; +} + extern "C" { diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index f27e71c..e93a89a 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h @@ -36,3 +36,3 @@ public: virtual long instanceCount( void ) - { return 2; } + { return InstanceCount; } @@ -42,2 +42,8 @@ private: + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + + // number of interfaces for this device + long InstanceCount; + }; |