Diffstat (limited to 'noncore/settings/networksettings2/lancard/lancard_NN.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/lancard/lancard_NN.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 7d36918..480ddf9 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -1,67 +1,72 @@ | |||
1 | #include "lancard_NN.h" | 1 | #include "lancard_NN.h" |
2 | #include "lancard_NNI.h" | 2 | #include "lancard_NNI.h" |
3 | 3 | ||
4 | static const char * LanCardNeeds[] = | 4 | static const char * LanCardNeeds[] = |
5 | { 0 }; | 5 | { 0 }; |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * Constructor, find all of the possible interfaces | 8 | * Constructor, find all of the possible interfaces |
9 | */ | 9 | */ |
10 | LanCardNetNode::LanCardNetNode() : ANetNode() { | 10 | LanCardNetNode::LanCardNetNode() : ANetNode() { |
11 | } | 11 | } |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Delete any interfaces that we own. | 14 | * Delete any interfaces that we own. |
15 | */ | 15 | */ |
16 | LanCardNetNode::~LanCardNetNode(){ | 16 | LanCardNetNode::~LanCardNetNode(){ |
17 | } | 17 | } |
18 | 18 | ||
19 | const QString LanCardNetNode::nodeDescription(){ | 19 | const QString LanCardNetNode::nodeDescription(){ |
20 | return tr("\ | 20 | return tr("\ |
21 | <p>Sets up a wired regular LAN card.</p>\ | 21 | <p>Sets up a wired regular LAN card.</p>\ |
22 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ | 22 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ |
23 | " | 23 | " |
24 | ); | 24 | ); |
25 | } | 25 | } |
26 | 26 | ||
27 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { | 27 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { |
28 | return new ALanCard( this ); | 28 | return new ALanCard( this ); |
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | const char ** LanCardNetNode::needs( void ) { | 32 | const char ** LanCardNetNode::needs( void ) { |
33 | return LanCardNeeds; | 33 | return LanCardNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * LanCardNetNode::provides( void ) { | 36 | const char * LanCardNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool LanCardNetNode::generateProperFilesFor( | 40 | bool LanCardNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool LanCardNetNode::hasDataFor( const QString & S, bool DS ) { | 45 | bool LanCardNetNode::hasDataFor( const QString & S ) { |
46 | return DS && S == "interfaces"; | 46 | return S == "interfaces"; |
47 | } | ||
48 | |||
49 | bool LanCardNetNode::generateDataForCommonFile( | ||
50 | SystemFile & , | ||
51 | long , | ||
52 | ANetNodeInstance * ) { | ||
53 | return 1; | ||
54 | } | 47 | } |
55 | 48 | ||
56 | bool LanCardNetNode::generateDeviceDataForCommonFile( | 49 | bool LanCardNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & S , | 50 | SystemFile & S , |
58 | long DevNr , | 51 | long DevNr ) { |
59 | ANetNodeInstance * NNI ) { | 52 | QString NIC = genNic( DevNr ); |
60 | return ((ALanCard *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | 53 | |
54 | if( S.name() == "interfaces" ) { | ||
55 | // generate mapping stanza for this interface | ||
56 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
57 | S << "mapping " << NIC << endl; | ||
58 | S << " script networksettings2-request" << endl << endl; | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | QString LanCardNetNode::genNic( long nr ) { | ||
64 | QString S; | ||
65 | return S.sprintf( "eth%ld", nr ); | ||
61 | } | 66 | } |
62 | 67 | ||
63 | extern "C" { | 68 | extern "C" { |
64 | void create_plugin( QList<ANetNode> & PNN ) { | 69 | void create_plugin( QList<ANetNode> & PNN ) { |
65 | PNN.append( new LanCardNetNode() ); | 70 | PNN.append( new LanCardNetNode() ); |
66 | } | 71 | } |
67 | } | 72 | } |