author | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
commit | 8f215ba9ceb395f262517855a99d7d2d303ca760 (patch) (unidiff) | |
tree | aa5f9b14c249217b4d3fc30f4771bdaf1c3545d3 /noncore/settings/networksettings2/network | |
parent | ef64880308b5035cc8ca2e4e79325db613af525b (diff) | |
download | opie-8f215ba9ceb395f262517855a99d7d2d303ca760.zip opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.gz opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.bz2 |
MANY changes
- now generates peers/pap-chap secrets files
(no chatscript yet)
(not all usefull ppp options included yet)
- still not ready for prime time yet
Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
4 files changed, 132 insertions, 82 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b4313c4..1feffdb 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,62 +1,82 @@ | |||
1 | #include <asdevice.h> | ||
1 | #include "network_NN.h" | 2 | #include "network_NN.h" |
2 | #include "network_NNI.h" | 3 | #include "network_NNI.h" |
3 | 4 | ||
4 | static const char * NetworkNeeds[] = | 5 | static const char * NetworkNeeds[] = |
5 | { "device", | 6 | { "device", |
6 | 0 | 7 | 0 |
7 | }; | 8 | }; |
8 | 9 | ||
9 | /** | 10 | /** |
10 | * Constructor, find all of the possible interfaces | 11 | * Constructor, find all of the possible interfaces |
11 | */ | 12 | */ |
12 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { | 13 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { |
13 | } | 14 | } |
14 | 15 | ||
15 | /** | 16 | /** |
16 | * Delete any interfaces that we own. | 17 | * Delete any interfaces that we own. |
17 | */ | 18 | */ |
18 | NetworkNetNode::~NetworkNetNode(){ | 19 | NetworkNetNode::~NetworkNetNode(){ |
19 | } | 20 | } |
20 | 21 | ||
21 | const QString NetworkNetNode::nodeDescription(){ | 22 | const QString NetworkNetNode::nodeDescription(){ |
22 | return tr("\ | 23 | return tr("\ |
23 | <p>Sets up TCP/IP options.</p>\ | 24 | <p>Sets up TCP/IP options.</p>\ |
24 | <p>Use this to configure the TCP/IP protocol</p>\ | 25 | <p>Use this to configure the TCP/IP protocol</p>\ |
25 | " | 26 | " |
26 | ); | 27 | ); |
27 | } | 28 | } |
28 | 29 | ||
29 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { | 30 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { |
30 | return new ANetwork( this ); | 31 | return new ANetwork( this ); |
31 | } | 32 | } |
32 | 33 | ||
33 | const char ** NetworkNetNode::needs( void ) { | 34 | bool NetworkNetNode::hasDataForFile( const QString & S ) { |
34 | return NetworkNeeds; | 35 | return S == "interfaces"; |
35 | } | 36 | } |
36 | 37 | ||
37 | const char * NetworkNetNode::provides( void ) { | 38 | short NetworkNetNode::generateFile( const QString & ID, |
38 | return "connection"; | 39 | const QString & , |
40 | QTextStream & TS, | ||
41 | ANetNodeInstance * NNI, | ||
42 | long DevNr ) { | ||
43 | |||
44 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | ||
45 | |||
46 | if( ID == "interfaces" ) { | ||
47 | Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); | ||
48 | // generate mapping stanza for this interface | ||
49 | TS << "# check if " | ||
50 | << NIC | ||
51 | << " can be brought UP" | ||
52 | << endl; | ||
53 | TS << "mapping " | ||
54 | << NIC | ||
55 | << endl; | ||
56 | TS << " script networksettings2-request" | ||
57 | << endl | ||
58 | << endl; | ||
59 | return 0; | ||
60 | } | ||
61 | return 1; | ||
39 | } | 62 | } |
40 | 63 | ||
41 | bool NetworkNetNode::generateProperFilesFor( | 64 | const char ** NetworkNetNode::needs( void ) { |
42 | ANetNodeInstance * ) { | 65 | return NetworkNeeds; |
43 | return 0; | ||
44 | } | 66 | } |
45 | 67 | ||
46 | bool NetworkNetNode::generateDeviceDataForCommonFile( | 68 | const char * NetworkNetNode::provides( void ) { |
47 | SystemFile & , | 69 | return "connection"; |
48 | long ) { | ||
49 | return 0; | ||
50 | } | 70 | } |
51 | 71 | ||
52 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { | 72 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { |
53 | } | 73 | } |
54 | 74 | ||
55 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { | 75 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { |
56 | } | 76 | } |
57 | 77 | ||
58 | extern "C" { | 78 | extern "C" { |
59 | void create_plugin( QList<ANetNode> & PNN ) { | 79 | void create_plugin( QList<ANetNode> & PNN ) { |
60 | PNN.append( new NetworkNetNode() ); | 80 | PNN.append( new NetworkNetNode() ); |
61 | } | 81 | } |
62 | } | 82 | } |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 6548c32..745d1a7 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -1,44 +1,43 @@ | |||
1 | #ifndef NETWORK_NETNODE_H | 1 | #ifndef NETWORK_NETNODE_H |
2 | #define NETWORK_NETNODE_H | 2 | #define NETWORK_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ANetwork; | 6 | 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 bool hasDataForFile( const QString & S ); |
18 | { return "Devices/tcpip"; } | ||
19 | 18 | ||
20 | virtual const QString nodeDescription() ; | 19 | virtual short generateFile( const QString & ID, |
20 | const QString & Path, | ||
21 | QTextStream & TS, | ||
22 | ANetNodeInstance * NNI, | ||
23 | long DevNr ); | ||
24 | virtual const QString pixmapName() | ||
25 | { return "Devices/tcpip"; } | ||
21 | 26 | ||
22 | virtual ANetNodeInstance * createInstance( void ); | 27 | virtual const QString nodeDescription() ; |
23 | 28 | virtual ANetNodeInstance * createInstance( void ); | |
24 | virtual const char ** needs( void ); | 29 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 30 | virtual const char * provides( void ); |
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | 31 | ||
33 | private: | 32 | private: |
34 | 33 | ||
35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
36 | virtual void saveSpecificAttribute( QTextStream & TS ); | 35 | virtual void saveSpecificAttribute( QTextStream & TS ); |
37 | }; | 36 | }; |
38 | 37 | ||
39 | extern "C" | 38 | extern "C" |
40 | { | 39 | { |
41 | void create_plugin( QList<ANetNode> & PNN ); | 40 | void create_plugin( QList<ANetNode> & PNN ); |
42 | }; | 41 | }; |
43 | 42 | ||
44 | #endif | 43 | #endif |
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 3e368a2..324c6e2 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -78,112 +78,142 @@ 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 ) { | 102 | bool ANetwork::hasDataForFile( const QString & S ) { |
103 | return S == "interfaces"; | 103 | return S == "interfaces"; |
104 | } | 104 | } |
105 | 105 | ||
106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | short ANetwork::generateFile( const QString & ID, |
107 | const QString & Path, | ||
108 | QTextStream &TS, | ||
109 | long DevNr | ||
110 | ) { | ||
111 | |||
112 | short rvl, rvd ; | ||
107 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 113 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
108 | 114 | ||
109 | if( S.name() == "interfaces" ) { | 115 | rvl = 1; |
116 | if( ID == "interfaces" ) { | ||
117 | Log(("Generate Network for %s\n", ID.latin1() )); | ||
110 | // we can safely call from here since device item is deeper | 118 | // we can safely call from here since device item is deeper |
111 | if( Data.UseDHCP ) { | 119 | if( Data.UseDHCP ) { |
112 | S << "iface " | 120 | TS << "iface " |
113 | << NIC | 121 | << NIC |
114 | << "-c" | 122 | << "-c" |
115 | << connection()->number() | 123 | << connection()->number() |
116 | << "-allowed inet dhcp" | 124 | << "-allowed inet dhcp" |
117 | << endl; | 125 | << endl; |
118 | S << " up echo \"" | 126 | TS << " up echo \"" |
119 | << NIC | 127 | << NIC |
120 | << "\" > /tmp/profile-" | 128 | << "\" > /tmp/profile-" |
121 | << connection()->number() | 129 | << connection()->number() |
122 | << ".up" | 130 | << ".up" |
123 | << endl; | 131 | << endl; |
124 | if( Data.SendHostname ) { | 132 | if( Data.SendHostname ) { |
125 | S << " hostname " | 133 | TS << " hostname " |
126 | << Data.Hostname | 134 | << Data.Hostname |
127 | << endl; | 135 | << endl; |
128 | } | 136 | } |
129 | 137 | ||
130 | S << " down rm -f /tmp/profile-" | 138 | TS << " down rm -f /tmp/profile-" |
131 | << connection()->number() | 139 | << connection()->number() |
132 | << ".up" | 140 | << ".up" |
133 | << endl; | 141 | << endl; |
134 | } else { | 142 | } else { |
135 | S << "iface " | 143 | TS << "iface " |
136 | << NIC << "-c" | 144 | << NIC << "-c" |
137 | << connection()->number() | 145 | << connection()->number() |
138 | << "-allowed inet static" | 146 | << "-allowed inet static" |
139 | << endl; | 147 | << endl; |
140 | S << " up echo \"" | 148 | TS << " up echo \"" |
141 | << NIC | 149 | << NIC |
142 | << "\" > /tmp/profile-" | 150 | << "\" > /tmp/profile-" |
143 | << connection()->number() | 151 | << connection()->number() |
144 | << ".up" | 152 | << ".up" |
145 | << endl; | 153 | << endl; |
146 | S << " down rm -f /tmp/profile-" | 154 | TS << " down rm -f /tmp/profile-" |
147 | << connection()->number() | 155 | << connection()->number() |
148 | << ".up" | 156 | << ".up" |
149 | << endl; | 157 | << endl; |
150 | S << " address " << Data.IPAddress << endl; | 158 | TS << " address " |
151 | S << " broadcast " << Data.Broadcast << endl; | 159 | << Data.IPAddress |
152 | S << " netmask " << Data.NetMask << endl; | 160 | << endl; |
161 | TS << " broadcast " | ||
162 | << Data.Broadcast | ||
163 | << endl; | ||
164 | TS << " netmask " | ||
165 | << Data.NetMask | ||
166 | << endl; | ||
153 | 167 | ||
154 | // derive network address = IPAddress & netmask | 168 | // derive network address = IPAddress & netmask |
155 | { QString NW; | 169 | { QString NW; |
156 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); | 170 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); |
157 | QStringList nmal = QStringList::split( '.', Data.NetMask ); | 171 | QStringList nmal = QStringList::split( '.', Data.NetMask ); |
158 | 172 | ||
159 | NW = QString( "%1.%2.%3.%4" ). | 173 | NW = QString( "%1.%2.%3.%4" ). |
160 | arg( ipal[0].toShort() & nmal[0].toShort() ). | 174 | arg( ipal[0].toShort() & nmal[0].toShort() ). |
161 | arg( ipal[1].toShort() & nmal[1].toShort() ). | 175 | arg( ipal[1].toShort() & nmal[1].toShort() ). |
162 | arg( ipal[2].toShort() & nmal[2].toShort() ). | 176 | arg( ipal[2].toShort() & nmal[2].toShort() ). |
163 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 177 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
164 | S << " network " << NW << endl; | 178 | TS << " network " |
179 | << NW | ||
180 | << endl; | ||
165 | } | 181 | } |
166 | } | 182 | } |
167 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); | 183 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); |
168 | it != Data.PreUp_SL.end(); | 184 | it != Data.PreUp_SL.end(); |
169 | ++it ) { | 185 | ++it ) { |
170 | S << " pre-up " << (*it) << endl; | 186 | TS << " pre-up " |
187 | << (*it) | ||
188 | << endl; | ||
171 | } | 189 | } |
172 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 190 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
173 | it != Data.PostUp_SL.end(); | 191 | it != Data.PostUp_SL.end(); |
174 | ++it ) { | 192 | ++it ) { |
175 | S << " up " << (*it) << endl; | 193 | TS << " up " |
194 | << (*it) | ||
195 | << endl; | ||
176 | } | 196 | } |
177 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 197 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
178 | it != Data.PreDown_SL.end(); | 198 | it != Data.PreDown_SL.end(); |
179 | ++it ) { | 199 | ++it ) { |
180 | S << " down " << (*it) << endl; | 200 | TS << " down " |
201 | << (*it) | ||
202 | << endl; | ||
181 | } | 203 | } |
182 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 204 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
183 | it != Data.PostDown_SL.end(); | 205 | it != Data.PostDown_SL.end(); |
184 | ++it ) { | 206 | ++it ) { |
185 | S << " post-down " << (*it) << endl; | 207 | TS << " post-down " |
208 | << (*it) | ||
209 | << endl; | ||
186 | } | 210 | } |
211 | rvl = 0; | ||
187 | } | 212 | } |
188 | return 0; | 213 | |
214 | // embed other info in it | ||
215 | rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); | ||
216 | |||
217 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
218 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
189 | } | 219 | } |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 0058793..5e42503 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -1,47 +1,48 @@ | |||
1 | #ifndef NETWORK_H | 1 | #ifndef NETWORK_H |
2 | #define NETWORK_H | 2 | #define NETWORK_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "networkdata.h" | 5 | #include "networkdata.h" |
6 | #include "networkrun.h" | 6 | #include "networkrun.h" |
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 | RuntimeInfo * runtime( void ) | ||
19 | { return | ||
20 | ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) ); | ||
21 | } | ||
22 | |||
18 | QWidget * edit( QWidget * parent ); | 23 | QWidget * edit( QWidget * parent ); |
19 | QString acceptable( void ); | 24 | QString acceptable( void ); |
20 | void commit( void ); | 25 | void commit( void ); |
21 | 26 | ||
22 | RuntimeInfo * runtime( void ) | ||
23 | { if( RT == 0 ) | ||
24 | RT = new NetworkRun( this, Data ); | ||
25 | return RT; | ||
26 | } | ||
27 | |||
28 | virtual void * data( void ) | 27 | virtual void * data( void ) |
29 | { return (void *)&Data; } | 28 | { return (void *)&Data; } |
30 | 29 | ||
31 | virtual bool hasDataFor( const QString & S ); | 30 | virtual bool hasDataForFile( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | 31 | virtual short generateFile( const QString & ID, |
33 | SystemFile & SF, long DevNr ); | 32 | const QString & Path, |
33 | QTextStream &TS, | ||
34 | long DevNr ); | ||
34 | 35 | ||
35 | protected : | 36 | protected : |
36 | 37 | ||
37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
38 | virtual void saveSpecificAttribute( QTextStream & TS ); | 39 | virtual void saveSpecificAttribute( QTextStream & TS ); |
39 | 40 | ||
40 | private : | 41 | private : |
41 | 42 | ||
42 | NetworkEdit * GUI; | 43 | NetworkEdit * GUI; |
43 | NetworkData_t Data; | 44 | NetworkData_t Data; |
44 | NetworkRun * RT; | 45 | NetworkRun * RT; |
45 | }; | 46 | }; |
46 | 47 | ||
47 | #endif | 48 | #endif |