summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/usb
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp24
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h8
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp25
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h5
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp6
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h4
6 files changed, 31 insertions, 41 deletions
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index be4a2bc..30c72db 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -21,47 +21,51 @@ const QString USBNetNode::nodeDescription(){
21 return tr("\ 21 return tr("\
22<p>Configure Ethernet over USB.</p>\ 22<p>Configure Ethernet over USB.</p>\
23<p>Use this for a computer to computer USB cable connection</p>\ 23<p>Use this for a computer to computer USB cable connection</p>\
24" 24"
25); 25);
26} 26}
27 27
28ANetNodeInstance * USBNetNode::createInstance( void ) { 28ANetNodeInstance * USBNetNode::createInstance( void ) {
29 return new AUSB( this ); 29 return new AUSB( this );
30} 30}
31 31
32const char ** USBNetNode::needs( void ) { 32const char ** USBNetNode::needs( void ) {
33 return USBNeeds; 33 return USBNeeds;
34} 34}
35 35
36const char * USBNetNode::provides( void ) { 36const char * USBNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool USBNetNode::generateProperFilesFor( 40bool USBNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) { 41 ANetNodeInstance * ) {
42 return 1; 42 return 1;
43} 43}
44 44
45bool USBNetNode::hasDataFor( const QString & S, bool ) { 45bool USBNetNode::hasDataFor( const QString & S ) {
46 return (S== "interfaces"); 46 return (S== "interfaces");
47} 47}
48 48
49bool USBNetNode::generateDataForCommonFile( 49bool USBNetNode::generateDeviceDataForCommonFile(
50 SystemFile & S , 50 SystemFile & S ,
51 long DevNr, 51 long DevNr ) {
52 ANetNodeInstance * NNI) { 52 QString NIC = genNic( DevNr );
53 return ((AUSB *)NNI)->generateDataForCommonFile(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;
54} 61}
55 62
56bool USBNetNode::generateDeviceDataForCommonFile( 63QString USBNetNode::genNic( long ) {
57 SystemFile & S , 64 return QString( "usbf" );
58 long DevNr,
59 ANetNodeInstance * NNI) {
60 return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr);
61} 65}
62 66
63extern "C" { 67extern "C" {
64void create_plugin( QList<ANetNode> & PNN ) { 68void create_plugin( QList<ANetNode> & PNN ) {
65 PNN.append( new USBNetNode() ); 69 PNN.append( new USBNetNode() );
66} 70}
67} 71}
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index 8ff5289..ba22b1c 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -7,40 +7,40 @@ class AUSB;
7 7
8class USBNetNode : public ANetNode{ 8class USBNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 USBNetNode(); 14 USBNetNode();
15 virtual ~USBNetNode(); 15 virtual ~USBNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/usb"; } 18 { return "Devices/usb"; }
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("USB Cable Connect"); } 21 { return tr("USB Cable Connect"); }
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 DeviceSpec ); 31 virtual bool hasDataFor( const QString & S);
32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile( 32 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr );
34
35 virtual QString genNic( long nr );
36 36
37private: 37private:
38 38
39}; 39};
40 40
41extern "C" 41extern "C"
42{ 42{
43 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
44}; 44};
45 45
46#endif 46#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index 6fcd6d5..e90204c 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -11,47 +11,42 @@ AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) {
11 11
12void AUSB::setSpecificAttribute( QString & , QString & ) { 12void AUSB::setSpecificAttribute( QString & , QString & ) {
13} 13}
14 14
15void AUSB::saveSpecificAttribute( QTextStream & ) { 15void AUSB::saveSpecificAttribute( QTextStream & ) {
16} 16}
17 17
18 18
19QWidget * AUSB::edit( QWidget * parent ) { 19QWidget * AUSB::edit( QWidget * parent ) {
20 GUI = new USBEdit( parent ); 20 GUI = new USBEdit( parent );
21 GUI->showData( Data ); 21 GUI->showData( Data );
22 return GUI; 22 return GUI;
23} 23}
24 24
25QString AUSB::acceptable( void ) { 25QString AUSB::acceptable( void ) {
26 return ( GUI ) ? GUI->acceptable( ) : QString(); 26 return ( GUI ) ? GUI->acceptable( ) : QString();
27} 27}
28 28
29void AUSB::commit( void ) { 29void AUSB::commit( void ) {
30 if( GUI && GUI->commit( Data ) ) { 30 if( GUI && GUI->commit( Data ) ) {
31 setModified( 1 ); 31 setModified( 1 );
32 } 32 }
33} 33}
34 34
35bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { 35bool AUSB::hasDataFor( const QString & S ) {
36 AsDevice * Dev = runtime()->device(); 36 return (S== "interfaces");
37 QString NIC = Dev->genNic( DevNr );
38
39 if( S.name() == "interfaces" ) {
40 // generate mapping stanza for this interface
41 S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl;
42 }
43 return 0;
44} 37}
45 38
46bool AUSB::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) { 39bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
47 AsDevice * Dev = runtime()->device(); 40 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
48 QString NIC = Dev->genNic( DevNr );
49 41
50 if( S.name() == "interfaces" ) { 42 if( S.name() == "interfaces" ) {
51 // generate mapping stanza for this interface 43 // generate mapping stanza for this interface
52 S << "# check if " << NIC << " can be brought UP" << endl; 44 S << " pre-up "
53 S << "mapping " << NIC << endl; 45 << QPEApplication::qpeDir()
54 S << " script networksettings2-request" << endl << endl; 46 << "bin/setmacaddress.sh "
47 << NIC
48 << " || true"
49 << endl;
55 } 50 }
56 return 0; 51 return 0;
57} 52}
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index 5dead36..d2ee217 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -6,40 +6,41 @@
6#include "usbrun.h" 6#include "usbrun.h"
7 7
8class USBNetNode; 8class USBNetNode;
9class USBEdit; 9class USBEdit;
10 10
11class AUSB : public ANetNodeInstance { 11class AUSB : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AUSB( USBNetNode * PNN ); 15 AUSB( USBNetNode * PNN );
16 16
17 QWidget * edit( QWidget * parent ); 17 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 18 QString acceptable( void );
19 void commit( void ); 19 void commit( void );
20 20
21 RuntimeInfo * runtime( void ) 21 RuntimeInfo * runtime( void )
22 { if( RT == 0 ) 22 { if( RT == 0 )
23 RT = new USBRun( this, Data ); 23 RT = new USBRun( this, Data );
24 return RT; 24 return RT;
25 } 25 }
26 26
27 virtual void * data( void ) 27 virtual void * data( void )
28 { return (void *)&Data; } 28 { return (void *)&Data; }
29 29
30 bool generateDataForCommonFile( SystemFile & S, long DevNr ); 30 virtual bool hasDataFor( const QString & S);
31 bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr ); 31 virtual bool generateDataForCommonFile(
32 SystemFile & SF, long DevNr );
32 33
33protected : 34protected :
34 35
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 36 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 37 virtual void saveSpecificAttribute( QTextStream & TS );
37 38
38private : 39private :
39 40
40 USBEdit * GUI; 41 USBEdit * GUI;
41 USBData Data; 42 USBData Data;
42 USBRun * RT; 43 USBRun * RT;
43}; 44};
44 45
45#endif 46#endif
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index 3007e79..4ce6721 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -153,30 +153,24 @@ InterfaceInfo * USBRun::getInterface( void ) {
153 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 153 for( QDictIterator<InterfaceInfo> It(S.interfaces());
154 It.current(); 154 It.current();
155 ++It ) { 155 ++It ) {
156 Run = It.current(); 156 Run = It.current();
157 if( handlesInterface( Run->Name ) && 157 if( handlesInterface( Run->Name ) &&
158 Run->CardType == ARPHRD_ETHER 158 Run->CardType == ARPHRD_ETHER
159 ) { 159 ) {
160 // this is a USB card 160 // this is a USB card
161 if( Run->assignedNode() == netNode() ) { 161 if( Run->assignedNode() == netNode() ) {
162 // assigned to us 162 // assigned to us
163 return Run; 163 return Run;
164 } else if( Run->assignedNode() == 0 ) { 164 } else if( Run->assignedNode() == 0 ) {
165 // free 165 // free
166 best = Run; 166 best = Run;
167 } 167 }
168 } 168 }
169 } 169 }
170 return best; // can be 0 170 return best; // can be 0
171} 171}
172 172
173bool USBRun::handlesInterface( const QString & S ) { 173bool USBRun::handlesInterface( const QString & S ) {
174 return Pat.match( S ) >= 0; 174 return Pat.match( S ) >= 0;
175} 175}
176 176
177QString USBRun::genNic( long nr ) {
178 QString S;
179 S.sprintf( "usbf" );
180 return S;
181}
182
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index 60f9fe8..6c6e4e4 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -1,41 +1,37 @@
1#ifndef USBRUN_H 1#ifndef USBRUN_H
2#define USBRUN_H 2#define USBRUN_H
3 3
4#include <asdevice.h> 4#include <asdevice.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include "usbdata.h" 6#include "usbdata.h"
7 7
8class USBRun : public AsDevice { 8class USBRun : public AsDevice {
9 9
10public : 10public :
11 11
12 USBRun( ANetNodeInstance * NNI, 12 USBRun( ANetNodeInstance * NNI,
13 USBData & Data ) : 13 USBData & Data ) :
14 AsDevice( NNI ), 14 AsDevice( NNI ),
15 Pat( "usb[0-9abcdef]" ) 15 Pat( "usb[0-9abcdef]" )
16 { } 16 { }
17 17
18 virtual long count( void )
19 { return 1; }
20 virtual QString genNic( long nr );
21
22 virtual AsDevice * device( void ) 18 virtual AsDevice * device( void )
23 { return (AsDevice *)this; } 19 { return (AsDevice *)this; }
24 20
25 virtual AsDevice * asDevice( void ) 21 virtual AsDevice * asDevice( void )
26 { return (AsDevice *)this; } 22 { return (AsDevice *)this; }
27protected : 23protected :
28 24
29 void detectState( NodeCollection * ); 25 void detectState( NodeCollection * );
30 bool setState( NodeCollection * , Action_t A ); 26 bool setState( NodeCollection * , Action_t A );
31 bool canSetState( State_t , Action_t A ); 27 bool canSetState( State_t , Action_t A );
32 28
33 bool handlesInterface( const QString & I ); 29 bool handlesInterface( const QString & I );
34 30
35private : 31private :
36 32
37 InterfaceInfo * getInterface( void ); 33 InterfaceInfo * getInterface( void );
38 QRegExp Pat; 34 QRegExp Pat;
39 35
40}; 36};
41#endif 37#endif