Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/usb/usb_NN.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usb_NN.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usb_NNI.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usb_NNI.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.h | 5 |
6 files changed, 47 insertions, 12 deletions
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index c65771d..be4a2bc 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -33,28 +33,35 @@ const char ** USBNetNode::needs( void ) { | |||
33 | return USBNeeds; | 33 | return USBNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * USBNetNode::provides( void ) { | 36 | const char * USBNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool USBNetNode::generateProperFilesFor( | 40 | bool USBNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool USBNetNode::hasDataFor( const QString & S ) { | 45 | bool USBNetNode::hasDataFor( const QString & S, bool ) { |
46 | return (S== "interfaces"); | 46 | return (S== "interfaces"); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool USBNetNode::generateDataForCommonFile( | 49 | bool USBNetNode::generateDataForCommonFile( |
50 | SystemFile & S , | 50 | SystemFile & S , |
51 | long DevNr, | 51 | long DevNr, |
52 | ANetNodeInstance * NNI) { | 52 | ANetNodeInstance * NNI) { |
53 | return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); | 53 | return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool USBNetNode::generateDeviceDataForCommonFile( | ||
57 | SystemFile & S , | ||
58 | long DevNr, | ||
59 | ANetNodeInstance * NNI) { | ||
60 | return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | ||
61 | } | ||
62 | |||
56 | extern "C" { | 63 | extern "C" { |
57 | void create_plugin( QList<ANetNode> & PNN ) { | 64 | void create_plugin( QList<ANetNode> & PNN ) { |
58 | PNN.append( new USBNetNode() ); | 65 | PNN.append( new USBNetNode() ); |
59 | } | 66 | } |
60 | } | 67 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index 8b97452..8ff5289 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h | |||
@@ -19,26 +19,28 @@ public: | |||
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 ); | 31 | virtual bool hasDataFor( const QString & S, bool DeviceSpec ); |
32 | virtual bool generateDataForCommonFile( | 32 | virtual bool generateDataForCommonFile( |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); |
34 | virtual bool generateDeviceDataForCommonFile( | ||
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | 36 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "C" |
40 | { | 42 | { |
41 | void create_plugin( QList<ANetNode> & PNN ); | 43 | void create_plugin( QList<ANetNode> & PNN ); |
42 | }; | 44 | }; |
43 | 45 | ||
44 | #endif | 46 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index 4729416..6fcd6d5 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp | |||
@@ -34,13 +34,24 @@ void AUSB::commit( void ) { | |||
34 | 34 | ||
35 | bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 35 | bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { |
36 | AsDevice * Dev = runtime()->device(); | 36 | AsDevice * Dev = runtime()->device(); |
37 | QString NIC = Dev->genNic( DevNr ); | 37 | QString NIC = Dev->genNic( DevNr ); |
38 | 38 | ||
39 | if( S.name() == "interfaces" ) { | 39 | if( S.name() == "interfaces" ) { |
40 | // generate mapping stanza for this interface | 40 | // generate mapping stanza for this interface |
41 | S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl; | 41 | S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl; |
42 | } | 42 | } |
43 | return 0; | 43 | return 0; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool AUSB::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) { | ||
47 | AsDevice * Dev = runtime()->device(); | ||
48 | QString NIC = Dev->genNic( DevNr ); | ||
46 | 49 | ||
50 | if( S.name() == "interfaces" ) { | ||
51 | // generate mapping stanza for this interface | ||
52 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
53 | S << "mapping " << NIC << endl; | ||
54 | S << " script networksettings2-request" << endl << endl; | ||
55 | } | ||
56 | return 0; | ||
57 | } | ||
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h index b09f17a..5dead36 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.h +++ b/noncore/settings/networksettings2/usb/usb_NNI.h | |||
@@ -19,24 +19,25 @@ public : | |||
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 | bool generateDataForCommonFile( SystemFile & S, long DevNr ); |
31 | bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr ); | ||
31 | 32 | ||
32 | protected : | 33 | protected : |
33 | 34 | ||
34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
35 | virtual void saveSpecificAttribute( QTextStream & TS ); | 36 | virtual void saveSpecificAttribute( QTextStream & TS ); |
36 | 37 | ||
37 | private : | 38 | private : |
38 | 39 | ||
39 | USBEdit * GUI; | 40 | USBEdit * GUI; |
40 | USBData Data; | 41 | USBData Data; |
41 | USBRun * RT; | 42 | USBRun * RT; |
42 | }; | 43 | }; |
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 49b5a77..3007e79 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -25,43 +25,54 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
25 | ++It ) { | 25 | ++It ) { |
26 | Run = It.current(); | 26 | Run = It.current(); |
27 | if( X == Run->Name ) { | 27 | if( X == Run->Name ) { |
28 | Run->assignNode( netNode() ); | 28 | Run->assignNode( netNode() ); |
29 | assignInterface( Run ); | 29 | assignInterface( Run ); |
30 | NC->setCurrentState( IsUp ); | 30 | NC->setCurrentState( IsUp ); |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | fprintf( stderr, "NUP\n" ); | 37 | fprintf( stderr, "Assigned %p\n", assignedInterface() ); |
38 | // definitively not up | 38 | if( ( Run = assignedInterface() ) ) { |
39 | // we already have an interface assigned -> still present ? | ||
40 | if( ! Run->IsUp ) { | ||
41 | // usb is still free -> keep assignment | ||
42 | NC->setCurrentState( Available ); | ||
43 | return; | ||
44 | } // else interface is up but NOT us -> some other profile | ||
45 | } | ||
46 | |||
47 | // nothing (valid) assigned to us | ||
39 | assignInterface( 0 ); | 48 | assignInterface( 0 ); |
40 | 49 | ||
41 | // find possible interface | 50 | // find possible interface |
42 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 51 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
43 | It.current(); | 52 | It.current(); |
44 | ++It ) { | 53 | ++It ) { |
45 | Run = It.current(); | 54 | Run = It.current(); |
55 | |||
46 | fprintf( stderr, "%s %d %d=%d %d\n", | 56 | fprintf( stderr, "%s %d %d=%d %d\n", |
47 | Run->Name.latin1(), | 57 | Run->Name.latin1(), |
48 | handlesInterface( Run->Name ), | 58 | handlesInterface( Run->Name ), |
49 | Run->CardType, ARPHRD_ETHER, | 59 | Run->CardType, ARPHRD_ETHER, |
50 | ! Run->IsUp ); | 60 | ! Run->IsUp ); |
61 | |||
51 | if( handlesInterface( Run->Name ) && | 62 | if( handlesInterface( Run->Name ) && |
52 | Run->CardType == ARPHRD_ETHER && | 63 | Run->CardType == ARPHRD_ETHER && |
53 | ! Run->IsUp | 64 | ! Run->IsUp |
54 | ) { | 65 | ) { |
55 | fprintf( stderr, "OFF\n" ); | 66 | fprintf( stderr, "Released(OFF)\n" ); |
56 | // proper type, and Not UP -> free | 67 | // proper type, and Not UP -> free |
57 | NC->setCurrentState( Off ); | 68 | NC->setCurrentState( Off ); |
58 | return; | 69 | return; |
59 | } | 70 | } |
60 | } | 71 | } |
61 | // no free found | 72 | // no free found |
62 | fprintf( stderr, "UNA\n" ); | 73 | fprintf( stderr, "UNA\n" ); |
63 | 74 | ||
64 | NC->setCurrentState( Unavailable ); | 75 | NC->setCurrentState( Unavailable ); |
65 | } | 76 | } |
66 | 77 | ||
67 | bool USBRun::setState( NodeCollection * NC, Action_t A ) { | 78 | bool USBRun::setState( NodeCollection * NC, Action_t A ) { |
@@ -74,35 +85,35 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { | |||
74 | return 0; | 85 | return 0; |
75 | } | 86 | } |
76 | InterfaceInfo * N = getInterface(); | 87 | InterfaceInfo * N = getInterface(); |
77 | if( ! N ) { | 88 | if( ! N ) { |
78 | // no interface available | 89 | // no interface available |
79 | NC->setCurrentState( Unavailable ); | 90 | NC->setCurrentState( Unavailable ); |
80 | return 0; | 91 | return 0; |
81 | } | 92 | } |
82 | // because we were OFF the interface | 93 | // because we were OFF the interface |
83 | // we get back is NOT assigned | 94 | // we get back is NOT assigned |
84 | N->assignNode( netNode() ); | 95 | N->assignNode( netNode() ); |
85 | assignInterface( N ); | 96 | assignInterface( N ); |
97 | fprintf( stderr, "Assing %p\n", N ); | ||
86 | NC->setCurrentState( Available ); | 98 | NC->setCurrentState( Available ); |
87 | return 1; | 99 | return 1; |
88 | } | 100 | } |
89 | case Deactivate : | 101 | case Deactivate : |
90 | if( NC->currentState() == IsUp ) { | 102 | if( NC->currentState() == IsUp ) { |
91 | // bring down first | 103 | // bring down first |
92 | if( ! connection()->setState( Down ) ) | 104 | if( ! connection()->setState( Down ) ) |
93 | // could not ... | 105 | // could not ... |
94 | return 0; | 106 | return 0; |
95 | } | 107 | } else if( NC->currentState() != Available ) { |
96 | if( NC->currentState() != Available ) { | ||
97 | return 1; | 108 | return 1; |
98 | } | 109 | } |
99 | assignedInterface()->assignNode( 0 ); // release | 110 | assignedInterface()->assignNode( 0 ); // release |
100 | assignInterface( 0 ); | 111 | assignInterface( 0 ); |
101 | NC->setCurrentState( Off ); | 112 | NC->setCurrentState( Off ); |
102 | return 1; | 113 | return 1; |
103 | default : | 114 | default : |
104 | // FT | 115 | // FT |
105 | break; | 116 | break; |
106 | } | 117 | } |
107 | return 0; | 118 | return 0; |
108 | } | 119 | } |
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h index c9c9121..60f9fe8 100644 --- a/noncore/settings/networksettings2/usb/usbrun.h +++ b/noncore/settings/networksettings2/usb/usbrun.h | |||
@@ -9,27 +9,30 @@ class USBRun : public AsDevice { | |||
9 | 9 | ||
10 | public : | 10 | public : |
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 ) | 18 | virtual long count( void ) |
19 | { return 1; } | 19 | { return 1; } |
20 | virtual QString genNic( long nr ); | 20 | virtual QString genNic( long nr ); |
21 | |||
21 | virtual AsDevice * device( void ) | 22 | virtual AsDevice * device( void ) |
22 | { return asDevice(); } | 23 | { return (AsDevice *)this; } |
23 | 24 | ||
25 | virtual AsDevice * asDevice( void ) | ||
26 | { return (AsDevice *)this; } | ||
24 | protected : | 27 | protected : |
25 | 28 | ||
26 | void detectState( NodeCollection * ); | 29 | void detectState( NodeCollection * ); |
27 | bool setState( NodeCollection * , Action_t A ); | 30 | bool setState( NodeCollection * , Action_t A ); |
28 | bool canSetState( State_t , Action_t A ); | 31 | bool canSetState( State_t , Action_t A ); |
29 | 32 | ||
30 | bool handlesInterface( const QString & I ); | 33 | bool handlesInterface( const QString & I ); |
31 | 34 | ||
32 | private : | 35 | private : |
33 | 36 | ||
34 | InterfaceInfo * getInterface( void ); | 37 | InterfaceInfo * getInterface( void ); |
35 | QRegExp Pat; | 38 | QRegExp Pat; |