Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
5 files changed, 13 insertions, 23 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index a6b15c6..4a77e6a 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -22,50 +22,35 @@ const QString NetworkNetNode::nodeDescription(){ | |||
22 | return tr("\ | 22 | return tr("\ |
23 | <p>Sets up TCP/IP options.</p>\ | 23 | <p>Sets up TCP/IP options.</p>\ |
24 | <p>Use this to configure the TCP/IP protocol</p>\ | 24 | <p>Use this to configure the TCP/IP protocol</p>\ |
25 | " | 25 | " |
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
29 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { | 29 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { |
30 | return new ANetwork( this ); | 30 | return new ANetwork( this ); |
31 | } | 31 | } |
32 | 32 | ||
33 | const char ** NetworkNetNode::needs( void ) { | 33 | const char ** NetworkNetNode::needs( void ) { |
34 | return NetworkNeeds; | 34 | return NetworkNeeds; |
35 | } | 35 | } |
36 | 36 | ||
37 | const char * NetworkNetNode::provides( void ) { | 37 | const char * NetworkNetNode::provides( void ) { |
38 | return "connection"; | 38 | return "connection"; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool NetworkNetNode::generateProperFilesFor( | 41 | bool NetworkNetNode::generateProperFilesFor( |
42 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
43 | return 1; | 43 | return 1; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool NetworkNetNode::hasDataFor( const QString & S, bool DS ) { | ||
47 | if( ! DS && S == "interfaces" ) { | ||
48 | return 1; | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | bool NetworkNetNode::generateDataForCommonFile( | ||
54 | SystemFile & S, | ||
55 | long DevNr, | ||
56 | ANetNodeInstance * NNI ) { | ||
57 | return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr); | ||
58 | } | ||
59 | |||
60 | bool NetworkNetNode::generateDeviceDataForCommonFile( | 46 | bool NetworkNetNode::generateDeviceDataForCommonFile( |
61 | SystemFile & , | 47 | SystemFile & , |
62 | long , | 48 | long ) { |
63 | ANetNodeInstance * ) { | ||
64 | return 1; | 49 | return 1; |
65 | } | 50 | } |
66 | 51 | ||
67 | extern "C" { | 52 | extern "C" { |
68 | void create_plugin( QList<ANetNode> & PNN ) { | 53 | void create_plugin( QList<ANetNode> & PNN ) { |
69 | PNN.append( new NetworkNetNode() ); | 54 | PNN.append( new NetworkNetNode() ); |
70 | } | 55 | } |
71 | } | 56 | } |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 62a3f10..59f0526 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -7,40 +7,39 @@ class ANetwork; | |||
7 | 7 | ||
8 | class NetworkNetNode : public ANetNode{ | 8 | class NetworkNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | NetworkNetNode(); | 14 | NetworkNetNode(); |
15 | virtual ~NetworkNetNode(); | 15 | virtual ~NetworkNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/tcpip"; } | 18 | { return "Devices/tcpip"; } |
19 | 19 | ||
20 | virtual const QString nodeName() | 20 | virtual const QString nodeName() |
21 | { return tr("IP Configuration"); } | 21 | { return tr("IP Configuration"); } |
22 | 22 | ||
23 | virtual const QString nodeDescription() ; | 23 | virtual const QString nodeDescription() ; |
24 | 24 | ||
25 | virtual ANetNodeInstance * createInstance( void ); | 25 | virtual ANetNodeInstance * createInstance( void ); |
26 | 26 | ||
27 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
28 | virtual const char * provides( void ); | 28 | virtual const char * provides( void ); |
29 | 29 | ||
30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
31 | virtual bool hasDataFor( const QString & S, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index eac2d66..054385a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -78,51 +78,54 @@ void ANetwork::saveSpecificAttribute( QTextStream & TS ) { | |||
78 | TS << "postup=" << quote(*it) << endl; | 78 | TS << "postup=" << quote(*it) << endl; |
79 | } | 79 | } |
80 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 80 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
81 | it != Data.PostDown_SL.end(); | 81 | it != Data.PostDown_SL.end(); |
82 | ++it ) { | 82 | ++it ) { |
83 | TS << "postdown=" << quote(*it) << endl; | 83 | TS << "postdown=" << quote(*it) << endl; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | QWidget * ANetwork::edit( QWidget * parent ) { | 87 | QWidget * ANetwork::edit( QWidget * parent ) { |
88 | GUI = new NetworkEdit( parent ); | 88 | GUI = new NetworkEdit( parent ); |
89 | GUI->showData( Data ); | 89 | GUI->showData( Data ); |
90 | return GUI; | 90 | return GUI; |
91 | } | 91 | } |
92 | 92 | ||
93 | QString ANetwork::acceptable( void ) { | 93 | QString ANetwork::acceptable( void ) { |
94 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 94 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ANetwork::commit( void ) { | 97 | void ANetwork::commit( void ) { |
98 | if( GUI && GUI->commit( Data ) ) | 98 | if( GUI && GUI->commit( Data ) ) |
99 | setModified( 1 ); | 99 | setModified( 1 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | bool ANetwork::hasDataFor( const QString & S ) { | ||
103 | return S == "interfaces"; | ||
104 | } | ||
105 | |||
102 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { |
103 | AsDevice * Dev = runtime()->device(); | 107 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
104 | QString NIC = Dev->genNic( DevNr ); | ||
105 | 108 | ||
106 | if( S.name() == "interfaces" ) { | 109 | if( S.name() == "interfaces" ) { |
107 | // we can safely call from here since device item is deeper | 110 | // we can safely call from here since device item is deeper |
108 | if( Data.UseDHCP ) { | 111 | if( Data.UseDHCP ) { |
109 | S << "iface " << NIC << "-c" << connection()->number() << | 112 | S << "iface " << NIC << "-c" << connection()->number() << |
110 | "-allowed inet dhcp" << endl; | 113 | "-allowed inet dhcp" << endl; |
111 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << | 114 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << |
112 | ".up" << Data.IPAddress << endl; | 115 | ".up" << Data.IPAddress << endl; |
113 | if( Data.SendHostname ) { | 116 | if( Data.SendHostname ) { |
114 | S << " hostname "<< Data.Hostname << endl; | 117 | S << " hostname "<< Data.Hostname << endl; |
115 | } | 118 | } |
116 | 119 | ||
117 | S << " down rm -f /tmp/profile-" << connection()->number() << | 120 | S << " down rm -f /tmp/profile-" << connection()->number() << |
118 | ".up" << Data.IPAddress << endl; | 121 | ".up" << Data.IPAddress << endl; |
119 | } else { | 122 | } else { |
120 | S << "iface " << NIC << "-c" << connection()->number() << | 123 | S << "iface " << NIC << "-c" << connection()->number() << |
121 | "-allowed inet static" << endl; | 124 | "-allowed inet static" << endl; |
122 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << | 125 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << |
123 | ".up" << Data.IPAddress << endl; | 126 | ".up" << Data.IPAddress << endl; |
124 | S << " down rm -f /tmp/profile-" << connection()->number() << | 127 | S << " down rm -f /tmp/profile-" << connection()->number() << |
125 | ".up" << Data.IPAddress << endl; | 128 | ".up" << Data.IPAddress << endl; |
126 | S << " address " << Data.IPAddress << endl; | 129 | S << " address " << Data.IPAddress << endl; |
127 | S << " broadcast " << Data.Broadcast << endl; | 130 | S << " broadcast " << Data.Broadcast << endl; |
128 | S << " netmask " << Data.NetMask << endl; | 131 | S << " netmask " << Data.NetMask << endl; |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index b98ff6e..0058793 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -7,39 +7,41 @@ | |||
7 | 7 | ||
8 | class NetworkNetNode; | 8 | class NetworkNetNode; |
9 | class NetworkEdit; | 9 | class NetworkEdit; |
10 | class SystemFile; | 10 | class SystemFile; |
11 | 11 | ||
12 | class ANetwork : public ANetNodeInstance{ | 12 | class ANetwork : public ANetNodeInstance{ |
13 | 13 | ||
14 | public : | 14 | public : |
15 | 15 | ||
16 | ANetwork( NetworkNetNode * PNN ); | 16 | ANetwork( NetworkNetNode * PNN ); |
17 | 17 | ||
18 | QWidget * edit( QWidget * parent ); | 18 | QWidget * edit( QWidget * parent ); |
19 | QString acceptable( void ); | 19 | QString acceptable( void ); |
20 | void commit( void ); | 20 | void commit( void ); |
21 | 21 | ||
22 | RuntimeInfo * runtime( void ) | 22 | RuntimeInfo * runtime( void ) |
23 | { if( RT == 0 ) | 23 | { if( RT == 0 ) |
24 | RT = new NetworkRun( this, Data ); | 24 | RT = new NetworkRun( this, Data ); |
25 | return RT; | 25 | return RT; |
26 | } | 26 | } |
27 | 27 | ||
28 | virtual void * data( void ) | 28 | virtual void * data( void ) |
29 | { return (void *)&Data; } | 29 | { return (void *)&Data; } |
30 | 30 | ||
31 | bool generateDataForCommonFile( SystemFile & S, long DevNr ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
32 | 34 | ||
33 | protected : | 35 | protected : |
34 | 36 | ||
35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
36 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
37 | 39 | ||
38 | private : | 40 | private : |
39 | 41 | ||
40 | NetworkEdit * GUI; | 42 | NetworkEdit * GUI; |
41 | NetworkData_t Data; | 43 | NetworkData_t Data; |
42 | NetworkRun * RT; | 44 | NetworkRun * RT; |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index f34fdbf..ddb9a5f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -1,36 +1,37 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <asdevice.h> |
3 | #include "networkrun.h" | 3 | #include "networkrun.h" |
4 | 4 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 5 | void NetworkRun::detectState( NodeCollection * NC ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
7 | AsDevice * Next = RI->asDevice(); | 7 | AsDevice * Next = RI->asDevice(); |
8 | InterfaceInfo * II = Next->assignedInterface(); | 8 | InterfaceInfo * II = Next->assignedInterface(); |
9 | 9 | ||
10 | if( II ) { | 10 | if( II ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); |
13 | return; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | // has no interface -> delegate | 16 | // has no interface -> delegate |
16 | RI->detectState( NC ); | 17 | RI->detectState( NC ); |
17 | } | 18 | } |
18 | 19 | ||
19 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | 20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { |
20 | // we handle UP and DOWN | 21 | // we handle UP and DOWN |
21 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
22 | AsDevice * Next = RI->asDevice(); | 23 | AsDevice * Next = RI->asDevice(); |
23 | InterfaceInfo * II = Next->assignedInterface(); | 24 | InterfaceInfo * II = Next->assignedInterface(); |
24 | 25 | ||
25 | if( A == Up ) { | 26 | if( A == Up ) { |
26 | // we can bring UP if lower level is available | 27 | // we can bring UP if lower level is available |
27 | if( NC->currentState() == Available ) { | 28 | if( NC->currentState() == Available ) { |
28 | QString S; | 29 | QString S; |
29 | S.sprintf( "ifup %s=%s-c%d-allowed", | 30 | S.sprintf( "ifup %s=%s-c%d-allowed", |
30 | II->Name.latin1(), II->Name.latin1(), | 31 | II->Name.latin1(), II->Name.latin1(), |
31 | connection()->number() ); | 32 | connection()->number() ); |
32 | NSResources->system().execute( S ); | 33 | NSResources->system().execute( S ); |
33 | } | 34 | } |
34 | return 1; | 35 | return 1; |
35 | } else if( A == Down ) { | 36 | } else if( A == Down ) { |
36 | if( NC->currentState() == IsUp ) { | 37 | if( NC->currentState() == IsUp ) { |