Diffstat (limited to 'noncore/settings/networksettings2/network/network_NN.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/network_NN.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b5c41bf..23b3d44 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,85 +1,97 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <asdevice.h> | 2 | #include <resources.h> |
3 | #include <netnode.h> | ||
3 | #include "network_NN.h" | 4 | #include "network_NN.h" |
4 | #include "network_NNI.h" | 5 | #include "network_NNI.h" |
5 | 6 | ||
6 | static const char * NetworkNeeds[] = | 7 | static const char * NetworkNeeds[] = |
7 | { "device", | 8 | { "device", |
8 | 0 | 9 | 0 |
9 | }; | 10 | }; |
10 | 11 | ||
12 | static const char * NetworkProvides[] = | ||
13 | { "connection", | ||
14 | 0 | ||
15 | }; | ||
16 | |||
11 | /** | 17 | /** |
12 | * Constructor, find all of the possible interfaces | 18 | * Constructor, find all of the possible interfaces |
13 | */ | 19 | */ |
14 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { | 20 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { |
21 | |||
22 | NSResources->addSystemFile( | ||
23 | "interfaces", "/etc/network/interfaces", 1 ); | ||
15 | } | 24 | } |
16 | 25 | ||
17 | /** | 26 | /** |
18 | * Delete any interfaces that we own. | 27 | * Delete any interfaces that we own. |
19 | */ | 28 | */ |
20 | NetworkNetNode::~NetworkNetNode(){ | 29 | NetworkNetNode::~NetworkNetNode(){ |
21 | } | 30 | } |
22 | 31 | ||
23 | const QString NetworkNetNode::nodeDescription(){ | 32 | const QString NetworkNetNode::nodeDescription(){ |
24 | return tr("\ | 33 | return tr("\ |
25 | <p>Sets up TCP/IP options.</p>\ | 34 | <p>Sets up TCP/IP options.</p>\ |
26 | <p>Use this to configure the TCP/IP protocol</p>\ | 35 | <p>Use this to configure the TCP/IP protocol</p>\ |
27 | " | 36 | " |
28 | ); | 37 | ); |
29 | } | 38 | } |
30 | 39 | ||
31 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { | 40 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { |
32 | return new ANetwork( this ); | 41 | return new ANetwork( this ); |
33 | } | 42 | } |
34 | 43 | ||
35 | bool NetworkNetNode::hasDataForFile( const QString & S ) { | 44 | bool NetworkNetNode::hasDataForFile( SystemFile & S ) { |
36 | return S == "interfaces"; | 45 | return S.name() == "interfaces"; |
37 | } | 46 | } |
38 | 47 | ||
39 | short NetworkNetNode::generateFile( const QString & ID, | 48 | short NetworkNetNode::generateFile( SystemFile & SF, |
40 | const QString & , | ||
41 | QTextStream & TS, | ||
42 | ANetNodeInstance * NNI, | 49 | ANetNodeInstance * NNI, |
43 | long DevNr ) { | 50 | long DevNr ) { |
44 | 51 | ||
52 | if( DevNr < 0 ) { | ||
53 | // generate device specific but common part | ||
54 | return 1; | ||
55 | } | ||
56 | |||
45 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 57 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
46 | 58 | ||
47 | if( ID == "interfaces" ) { | 59 | if( SF.name() == "interfaces" ) { |
48 | Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); | 60 | Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); |
49 | // generate mapping stanza for this interface | 61 | // generate mapping stanza for this interface |
50 | TS << "# check if " | 62 | SF << "# check if " |
51 | << NIC | 63 | << NIC |
52 | << " can be brought UP" | 64 | << " can be brought UP" |
53 | << endl; | 65 | << endl; |
54 | TS << "mapping " | 66 | SF << "mapping " |
55 | << NIC | 67 | << NIC |
56 | << endl; | 68 | << endl; |
57 | TS << " script " | 69 | SF << " script " |
58 | << QPEApplication::qpeDir() | 70 | << QPEApplication::qpeDir() |
59 | << "/bin/networksettings2-request" | 71 | << "bin/networksettings2-request" |
60 | << endl | 72 | << endl |
61 | << endl; | 73 | << endl; |
62 | return 0; | 74 | return 0; |
63 | } | 75 | } |
64 | return 1; | 76 | return 1; |
65 | } | 77 | } |
66 | 78 | ||
67 | const char ** NetworkNetNode::needs( void ) { | 79 | const char ** NetworkNetNode::needs( void ) { |
68 | return NetworkNeeds; | 80 | return NetworkNeeds; |
69 | } | 81 | } |
70 | 82 | ||
71 | const char * NetworkNetNode::provides( void ) { | 83 | const char ** NetworkNetNode::provides( void ) { |
72 | return "connection"; | 84 | return NetworkProvides; |
73 | } | 85 | } |
74 | 86 | ||
75 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { | 87 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { |
76 | } | 88 | } |
77 | 89 | ||
78 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { | 90 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { |
79 | } | 91 | } |
80 | 92 | ||
81 | extern "C" { | 93 | extern "C" { |
82 | void create_plugin( QList<ANetNode> & PNN ) { | 94 | void create_plugin( QList<ANetNode> & PNN ) { |
83 | PNN.append( new NetworkNetNode() ); | 95 | PNN.append( new NetworkNetNode() ); |
84 | } | 96 | } |
85 | } | 97 | } |