summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/lancard
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/lancard') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/lancard/lancardGUI.ui92
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h8
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp2
-rw-r--r--noncore/settings/networksettings2/lancard/lancardedit.cpp195
-rw-r--r--noncore/settings/networksettings2/lancard/lancardedit.h12
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp34
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h6
8 files changed, 290 insertions, 70 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancardGUI.ui b/noncore/settings/networksettings2/lancard/lancardGUI.ui
index 8d94816..c407175 100644
--- a/noncore/settings/networksettings2/lancard/lancardGUI.ui
+++ b/noncore/settings/networksettings2/lancard/lancardGUI.ui
@@ -10,9 +10,9 @@
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>362</width> 14 <width>354</width>
15 <height>359</height> 15 <height>359</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
@@ -68,9 +68,9 @@
68 </property> 68 </property>
69 <vbox> 69 <vbox>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>margin</name> 71 <name>margin</name>
72 <number>11</number> 72 <number>5</number>
73 </property> 73 </property>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>spacing</name> 75 <name>spacing</name>
76 <number>6</number> 76 <number>6</number>
@@ -79,22 +79,8 @@
79 <class>QListView</class> 79 <class>QListView</class>
80 <column> 80 <column>
81 <property> 81 <property>
82 <name>text</name> 82 <name>text</name>
83 <string>Name</string>
84 </property>
85 <property>
86 <name>clickable</name>
87 <bool>true</bool>
88 </property>
89 <property>
90 <name>resizeable</name>
91 <bool>true</bool>
92 </property>
93 </column>
94 <column>
95 <property>
96 <name>text</name>
97 <string>MACAddress</string> 83 <string>MACAddress</string>
98 </property> 84 </property>
99 <property> 85 <property>
100 <name>clickable</name> 86 <name>clickable</name>
@@ -113,8 +99,68 @@
113 <name>allColumnsShowFocus</name> 99 <name>allColumnsShowFocus</name>
114 <bool>true</bool> 100 <bool>true</bool>
115 </property> 101 </property>
116 </widget> 102 </widget>
103 <widget>
104 <class>QLayoutWidget</class>
105 <property stdset="1">
106 <name>name</name>
107 <cstring>Layout2</cstring>
108 </property>
109 <hbox>
110 <property stdset="1">
111 <name>margin</name>
112 <number>0</number>
113 </property>
114 <property stdset="1">
115 <name>spacing</name>
116 <number>6</number>
117 </property>
118 <widget>
119 <class>QPushButton</class>
120 <property stdset="1">
121 <name>name</name>
122 <cstring>RemoveUnknown_BUT</cstring>
123 </property>
124 <property stdset="1">
125 <name>text</name>
126 <string>Remove Unknown</string>
127 </property>
128 </widget>
129 <spacer>
130 <property>
131 <name>name</name>
132 <cstring>Spacer1</cstring>
133 </property>
134 <property stdset="1">
135 <name>orientation</name>
136 <enum>Horizontal</enum>
137 </property>
138 <property stdset="1">
139 <name>sizeType</name>
140 <enum>Expanding</enum>
141 </property>
142 <property>
143 <name>sizeHint</name>
144 <size>
145 <width>20</width>
146 <height>20</height>
147 </size>
148 </property>
149 </spacer>
150 <widget>
151 <class>QPushButton</class>
152 <property stdset="1">
153 <name>name</name>
154 <cstring>RescanCards_BUT</cstring>
155 </property>
156 <property stdset="1">
157 <name>text</name>
158 <string>Rescan</string>
159 </property>
160 </widget>
161 </hbox>
162 </widget>
117 </vbox> 163 </vbox>
118 </widget> 164 </widget>
119 </vbox> 165 </vbox>
120</widget> 166</widget>
@@ -124,6 +170,20 @@
124 <signal>toggled(bool)</signal> 170 <signal>toggled(bool)</signal>
125 <receiver>GroupBox1</receiver> 171 <receiver>GroupBox1</receiver>
126 <slot>setDisabled(bool)</slot> 172 <slot>setDisabled(bool)</slot>
127 </connection> 173 </connection>
174 <connection>
175 <sender>RescanCards_BUT</sender>
176 <signal>clicked()</signal>
177 <receiver>Lancard_FRM</receiver>
178 <slot>SLOT_ScanCards()</slot>
179 </connection>
180 <connection>
181 <sender>RemoveUnknown_BUT</sender>
182 <signal>clicked()</signal>
183 <receiver>Lancard_FRM</receiver>
184 <slot>SLOT_RemoveUnknown()</slot>
185 </connection>
186 <slot access="public">SLOT_ScanCards()</slot>
187 <slot access="public">SLOT_RemoveUnknown()</slot>
128</connections> 188</connections>
129</UI> 189</UI>
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index ba1c1f8..a4afab1 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -6,9 +6,9 @@ static const char * LanCardNeeds[] =
6 6
7/** 7/**
8 * Constructor, find all of the possible interfaces 8 * Constructor, find all of the possible interfaces
9 */ 9 */
10LanCardNetNode::LanCardNetNode() : ANetNode() { 10LanCardNetNode::LanCardNetNode() : ANetNode(tr("LAN card")), NICMACAddresses() {
11 InstanceCount = 2; 11 InstanceCount = 2;
12} 12}
13 13
14/** 14/**
@@ -68,15 +68,24 @@ QString LanCardNetNode::genNic( long nr ) {
68 68
69void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) { 69void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) {
70 if( A == "interfacecount" ) { 70 if( A == "interfacecount" ) {
71 InstanceCount = V.toLong(); 71 InstanceCount = V.toLong();
72 } else if ( A == "macaddress" ) {
73 NICMACAddresses.append( V );
72 } 74 }
73} 75}
74 76
75void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { 77void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) {
76 TS << "interfacecount=" 78 TS << "interfacecount="
77 << InstanceCount 79 << InstanceCount
78 << endl; 80 << endl;
81 for( QStringList::Iterator it = NICMACAddresses.begin();
82 it != NICMACAddresses.end();
83 ++it ) {
84 TS << "macaddress="
85 << (*it)
86 << endl;
87 }
79} 88}
80 89
81extern "C" { 90extern "C" {
82void create_plugin( QList<ANetNode> & PNN ) { 91void create_plugin( QList<ANetNode> & PNN ) {
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index 5f2b25d..d58823c 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -1,7 +1,8 @@
1#ifndef LANCARD_NETNODE_H 1#ifndef LANCARD_NETNODE_H
2#define LANCARD_NETNODE_H 2#define LANCARD_NETNODE_H
3 3
4#include <qstringlist.h>
4#include "netnode.h" 5#include "netnode.h"
5 6
6class ALanCard; 7class ALanCard;
7 8
@@ -16,11 +17,8 @@ public:
16 17
17 virtual const QString pixmapName() 18 virtual const QString pixmapName()
18 { return "Devices/card"; } 19 { return "Devices/card"; }
19 20
20 virtual const QString nodeName()
21 { return tr("LAN card"); }
22
23 virtual const QString nodeDescription() ; 21 virtual const QString nodeDescription() ;
24 22
25 virtual ANetNodeInstance * createInstance( void ); 23 virtual ANetNodeInstance * createInstance( void );
26 24
@@ -35,8 +33,10 @@ public:
35 virtual long instanceCount( void ) 33 virtual long instanceCount( void )
36 { return InstanceCount; } 34 { return InstanceCount; }
37 35
38 virtual QString genNic( long ); 36 virtual QString genNic( long );
37 virtual QStringList & addressesOfNIC( void )
38 { return NICMACAddresses; }
39 39
40private: 40private:
41 41
42 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 42 virtual void setSpecificAttribute( QString & Attr, QString & Value );
@@ -44,8 +44,10 @@ private:
44 44
45 // number of interfaces for this device 45 // number of interfaces for this device
46 long InstanceCount; 46 long InstanceCount;
47 47
48 QStringList NICMACAddresses;
49
48}; 50};
49 51
50extern "C" 52extern "C"
51{ 53{
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
index 5962d52..99c033e 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -29,9 +29,9 @@ void ALanCard::saveSpecificAttribute( QTextStream & TS) {
29} 29}
30 30
31QWidget * ALanCard::edit( QWidget * parent ) { 31QWidget * ALanCard::edit( QWidget * parent ) {
32 GUI = new LanCardEdit( parent ); 32 GUI = new LanCardEdit( parent );
33 GUI->showData( Data ); 33 GUI->showData( this );
34 return GUI; 34 return GUI;
35} 35}
36 36
37QString ALanCard::acceptable( void ) { 37QString ALanCard::acceptable( void ) {
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp
index fa7f6dc..ffe9bf6 100644
--- a/noncore/settings/networksettings2/lancard/lancardedit.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp
@@ -1,95 +1,208 @@
1#include <GUIUtils.h> 1#include <GUIUtils.h>
2#include <resources.h> 2#include <resources.h>
3#include <qarray.h>
3#include <qlistview.h> 4#include <qlistview.h>
4#include <qcheckbox.h> 5#include <qcheckbox.h>
5#include <qheader.h> 6#include <qheader.h>
6#include <qregexp.h> 7#include <qregexp.h>
8
7#include "lancardedit.h" 9#include "lancardedit.h"
10#include "lancard_NN.h"
11#include "lancard_NNI.h"
8 12
9LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){ 13LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){
10 System & S = NSResources->system();
11 QRegExp R( "eth[0-9]" );
12 QCheckListItem * CLI;
13
14 LanCards_LV->header()->hide(); 14 LanCards_LV->header()->hide();
15 15
16 // populate with all lancards in system
17 for( QDictIterator<InterfaceInfo> It(S.interfaces());
18 It.current();
19 ++It ) {
20 if( R.match( It.current()->Name ) >= 0 &&
21 It.current()->CardType == ARPHRD_ETHER
22 ) {
23 CLI = new QCheckListItem( LanCards_LV, It.current()->Name,
24 QCheckListItem::CheckBox );
25 CLI->setText( 1, It.current()->MACAddress );
26 }
27 }
28} 16}
29 17
30QString LanCardEdit::acceptable( void ) { 18QString LanCardEdit::acceptable( void ) {
31 return QString(); 19 return QString();
32} 20}
33 21
34
35bool LanCardEdit::commit( LanCardData & Data ) { 22bool LanCardEdit::commit( LanCardData & Data ) {
36 bool SM = 0; 23 bool SM = 0;
37 CBM( Data.AnyLanCard, AnyCard_CB, SM ); 24 CBM( Data.AnyLanCard, AnyCard_CB, SM );
38 25
39 if( ! Data.AnyLanCard ) { 26 if( ! Data.AnyLanCard ) {
40 // collect set of lancards that match 27 // take copy for orig list
28 QStringList NewList( Data.HWAddresses );
29
30 // update HWAddresses to new state
31 // remove item also from NewList
41 int idx; 32 int idx;
42 QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); 33 QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
43 while( CLI ) { 34 while( CLI ) {
44 idx = Data.HWAddresses.findIndex(CLI->text(1)); 35 idx = Data.HWAddresses.findIndex(CLI->text(0));
45 if( CLI->isOn() ) { 36 if( CLI->isOn() ) {
46 if( idx < 0 ) { 37 if( idx < 0 ) {
47 // should be in list 38 // should be in list
48 Data.HWAddresses.append( CLI->text(1) ); 39 Data.HWAddresses.append( CLI->text(0) );
49 SM = 1; 40 SM = 1;
50 } 41 }
51 } else { 42 } else {
52 // should not be in list 43 // should not be in list
53 if( idx >= 0 ) { 44 if( idx >= 0 ) {
54 Data.HWAddresses.remove( Data.HWAddresses.at(idx) ); 45 NewList.remove( CLI->text(0) );
46 Data.HWAddresses.remove( CLI->text(0) );
55 SM = 1; 47 SM = 1;
56 } 48 }
57 } 49 }
58 CLI = (QCheckListItem *)CLI->nextSibling(); 50 CLI = (QCheckListItem *)CLI->nextSibling();
59 } 51 }
52
53 // if newlist still contains items. it were items
54 // that were checked but no longer are present in the system
55 SM |= ( NewList.count() > 0 ) ;
60 } 56 }
61 return SM || ContainedObsoleteMAC ; 57 return SM;
62} 58}
63 59
64void LanCardEdit::showData( LanCardData & Data ) { 60void LanCardEdit::showData( ALanCard * LC ) {
61 NNI = LC;
62 LanCardData & Data = *((LanCardData *)LC->data());
63
65 AnyCard_CB->setChecked( Data.AnyLanCard ); 64 AnyCard_CB->setChecked( Data.AnyLanCard );
66 65
66 // load all cards
67 populateList();
68
69 // set checks
67 QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); 70 QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
71 while( CLI ) {
72 CLI->setOn( Data.HWAddresses.findIndex(CLI->text(0)) >= 0 );
73 CLI = (QCheckListItem *)CLI->nextSibling();
74 }
75}
68 76
69 ContainedObsoleteMAC = 0; 77// load all known cards in list
70 // remove obsolete address 78void LanCardEdit::populateList( void ) {
71 for( QStringList::Iterator it=Data.HWAddresses.begin(); 79 LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
72 it != Data.HWAddresses.end(); 80 QCheckListItem * CLI;
73 ) { 81 bool Found;
74 CLI = (QCheckListItem *)LanCards_LV->firstChild(); 82
75 while( CLI ) { 83 LanCards_LV->clear();
76 if( CLI->text(1) == (*it) ) 84
77 // still valid 85 for( QStringList::Iterator it = NN->addressesOfNIC().begin();
86 it != NN->addressesOfNIC().end();
87 ++it ) {
88 CLI = new QCheckListItem( LanCards_LV, (*it), QCheckListItem::CheckBox );
89
90 // check interfaces and see if this card is present
91 Found = 0;
92 for( QDictIterator<InterfaceInfo> NIt(NSResources->system().interfaces());
93 NIt.current();
94 ++NIt ) {
95 if( NIt.current()->MACAddress == (*it) ) {
96 Found = 1;
78 break; 97 break;
79 CLI = (QCheckListItem *)CLI->nextSibling(); 98 }
80 } 99 }
81 if( CLI == 0 ) { 100
82 // address not found -> remove 101 CLI->setPixmap( 0, NSResources->getPixmap(
83 ContainedObsoleteMAC = 1; 102 (Found) ? "add" : "remove" ) );
84 Data.HWAddresses.remove( it ); 103 }
85 } else { 104}
86 ++ it; 105
106// rescan system for new cards
107void LanCardEdit::SLOT_ScanCards( void ) {
108 LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
109
110 // add any NIC that is new and matches our interfacename
111 System & S = NSResources->system();
112 QRegExp R( "eth[0-9]" );
113 // populate with all lancards in system
114 for( QDictIterator<InterfaceInfo> It(S.interfaces());
115 It.current();
116 ++It ) {
117 fprintf( stderr, "TEST %s %s\n",
118 It.current()->Name.latin1(),
119 It.current()->MACAddress.latin1() );
120 if( R.match( It.current()->Name ) >= 0 &&
121 ( It.current()->CardType == ARPHRD_ETHER
122#ifdef ARPHRD_IEEE1394
123 || It.current()->CardType == ARPHRD_IEEE1394
124#endif
125 )
126 ) {
127 // old item ?
128 QCheckListItem * CLI =
129 (QCheckListItem *)LanCards_LV->firstChild();
130 while( CLI ) {
131 if( CLI->text(0) == It.current()->MACAddress ) {
132 break;
133 }
134 CLI = (QCheckListItem *)CLI->nextSibling();
135 }
136
137 if( ! CLI ) {
138 // new item
139 CLI = new QCheckListItem( LanCards_LV,
140 It.current()->MACAddress,
141 QCheckListItem::CheckBox );
142 }
143
144 // mark present
145 CLI->setPixmap( 0, NSResources->getPixmap(
146 "add" ) );
147
148 if( NN->addressesOfNIC().findIndex( It.current()->MACAddress) < 0 ) {
149 // new
150 NN->addressesOfNIC().append( It.current()->MACAddress );
151 }
87 } 152 }
88 } 153 }
89 154
90 // set checks 155}
156
157// remove all cards that are not present -> flagged with 'remove'
158// and unchecked
159void LanCardEdit::SLOT_RemoveUnknown( void ) {
160 QArray<QCheckListItem *> AllItems;
161
162 LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
163
164 QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
91 while( CLI ) { 165 while( CLI ) {
92 CLI->setOn( Data.HWAddresses.findIndex(CLI->text(1)) >= 0 ); 166 AllItems.resize( AllItems.size()+1 );
167 AllItems[ AllItems.size()-1 ] = CLI;
93 CLI = (QCheckListItem *)CLI->nextSibling(); 168 CLI = (QCheckListItem *)CLI->nextSibling();
94 } 169 }
170
171 // force update of system
172 System & S = NSResources->system();
173 S.probeInterfaces();
174
175 // add any NIC that is new and matches our interfacename
176 QRegExp R( "eth[0-9]" );
177
178
179 for( QDictIterator<InterfaceInfo> It(S.interfaces());
180 It.current();
181 ++It ) {
182 if( R.match( It.current()->Name ) >= 0 &&
183 ( It.current()->CardType == ARPHRD_ETHER
184#ifdef ARPHRD_IEEE1394
185 || It.current()->CardType == ARPHRD_IEEE1394
186#endif
187 )
188 ) {
189
190 for ( unsigned i = 0; i< AllItems.size(); i++ ) {
191 if( AllItems[i] &&
192 AllItems[i]->text(0) == It.current()->MACAddress ) {
193 AllItems[i] = 0;
194 break;
195 }
196 }
197 }
198 }
199
200 // AllItems now contains all cards NOT present
201 // remove all items non null and not ON
202 for ( unsigned i = 0; i< AllItems.size(); i++ ) {
203 if( AllItems[i] && ! AllItems[i]->isOn() ) {
204 NN->addressesOfNIC().remove( AllItems[i]->text(0) );
205 delete AllItems[i];
206 }
207 }
95} 208}
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.h b/noncore/settings/networksettings2/lancard/lancardedit.h
index 8def789..282db1f 100644
--- a/noncore/settings/networksettings2/lancard/lancardedit.h
+++ b/noncore/settings/networksettings2/lancard/lancardedit.h
@@ -1,16 +1,24 @@
1#include "lancarddata.h" 1#include "lancarddata.h"
2#include "lancardGUI.h" 2#include "lancardGUI.h"
3 3
4class ALanCard;
5
4class LanCardEdit : public LanCardGUI { 6class LanCardEdit : public LanCardGUI {
5 7
6public : 8public :
7 9
8 LanCardEdit( QWidget * parent ); 10 LanCardEdit( QWidget * parent );
9 QString acceptable( void ); 11 QString acceptable( void );
10 bool commit( LanCardData & Data ); 12 bool commit( LanCardData & Data );
11 void showData( LanCardData & Data ); 13 void showData( ALanCard * NNI );
14
15public slots :
16
17 void SLOT_ScanCards( void );
18 void SLOT_RemoveUnknown( void );
12 19
13private : 20private :
14 21
15 bool ContainedObsoleteMAC; 22 void populateList( void );
23 ALanCard * NNI;
16}; 24};
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 951756d..2e4fc43 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -1,6 +1,7 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qstringlist.h>
3#include <resources.h> 4#include <resources.h>
4#include "lancardrun.h" 5#include "lancardrun.h"
5 6
6void LanCardRun::detectState( NodeCollection * NC ) { 7void LanCardRun::detectState( NodeCollection * NC ) {
@@ -52,10 +53,14 @@ void LanCardRun::detectState( NodeCollection * NC ) {
52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 53 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
53 It.current(); 54 It.current();
54 ++It ) { 55 ++It ) {
55 Run = It.current(); 56 Run = It.current();
56 if( handlesInterface( Run->Name ) && 57 if( handlesInterface( *Run ) &&
57 Run->CardType == ARPHRD_ETHER && 58 ( Run->CardType == ARPHRD_ETHER
59#ifdef ARPHRD_IEEE1394
60 || Run->CardType == ARPHRD_IEEE1394
61#endif
62 ) &&
58 ! Run->IsUp 63 ! Run->IsUp
59 ) { 64 ) {
60 // proper type, and Not UP -> free 65 // proper type, and Not UP -> free
61 NC->setCurrentState( Off ); 66 NC->setCurrentState( Off );
@@ -144,10 +149,14 @@ InterfaceInfo * LanCardRun::getInterface( void ) {
144 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 149 for( QDictIterator<InterfaceInfo> It(S.interfaces());
145 It.current(); 150 It.current();
146 ++It ) { 151 ++It ) {
147 Run = It.current(); 152 Run = It.current();
148 if( handlesInterface( Run->Name ) && 153 if( handlesInterface( *Run ) &&
149 Run->CardType == ARPHRD_ETHER 154 ( Run->CardType == ARPHRD_ETHER
155#ifdef ARPHRD_IEEE1394
156 || Run->CardType == ARPHRD_IEEE1394
157#endif
158 )
150 ) { 159 ) {
151 // this is a LAN card 160 // this is a LAN card
152 if( Run->assignedNode() == netNode() ) { 161 if( Run->assignedNode() == netNode() ) {
153 // assigned to us 162 // assigned to us
@@ -161,6 +170,23 @@ InterfaceInfo * LanCardRun::getInterface( void ) {
161 return best; // can be 0 170 return best; // can be 0
162} 171}
163 172
164bool LanCardRun::handlesInterface( const QString & S ) { 173bool LanCardRun::handlesInterface( const QString & S ) {
174 InterfaceInfo * II;
175 II = NSResources->system().interface( S );
176 if( ( II = NSResources->system().interface( S ) ) ) {
177 return handlesInterface( *II );
178 }
165 return Pat.match( S ) >= 0; 179 return Pat.match( S ) >= 0;
166} 180}
181
182bool LanCardRun::handlesInterface( const InterfaceInfo & II ) {
183 if( Pat.match( II.Name ) < 0 )
184 return 0;
185
186 if( Data->AnyLanCard ) {
187 return 1;
188 }
189
190 // must also match hardware address
191 return ( Data->HWAddresses.findIndex( II.MACAddress ) >= 0 );
192}
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index 499b417..e8a535a 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -9,11 +9,11 @@ class LanCardRun : public AsDevice {
9 9
10public : 10public :
11 11
12 LanCardRun( ANetNodeInstance * NNI, 12 LanCardRun( ANetNodeInstance * NNI,
13 LanCardData & Data ) : AsDevice( NNI ), 13 LanCardData & D ) : AsDevice( NNI ),
14 Pat( "eth[0-9]" ) 14 Pat( "eth[0-9]" )
15 { } 15 { Data = &D; }
16 16
17 virtual AsDevice * device( void ) 17 virtual AsDevice * device( void )
18 { return (AsDevice *)this; } 18 { return (AsDevice *)this; }
19 19
@@ -26,12 +26,14 @@ protected :
26 bool setState( NodeCollection * NC, Action_t A ); 26 bool setState( NodeCollection * NC, Action_t A );
27 bool canSetState( State_t Curr, Action_t A ); 27 bool canSetState( State_t Curr, Action_t A );
28 28
29 bool handlesInterface( const QString & I ); 29 bool handlesInterface( const QString & I );
30 bool handlesInterface( const InterfaceInfo & II );
30 31
31private : 32private :
32 33
33 InterfaceInfo * getInterface( void ); 34 InterfaceInfo * getInterface( void );
34 QRegExp Pat; 35 QRegExp Pat;
36 LanCardData * Data;
35 37
36}; 38};
37#endif 39#endif