author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/usb | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (ignore whitespace changes)
10 files changed, 56 insertions, 118 deletions
diff --git a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control index 8b8508c..ffb3012 100644 --- a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control +++ b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-networksettingsplugin2-usb | 1 | Package: opie-networksettings2plugin-usb |
2 | Files: plugins/networksettings2/libusb.so* | 2 | Files: plugins/networksettings2/libusb.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/settings | 4 | Section: opie/settings |
5 | Maintainer: Wim Delvaux <wimpie@handhelds.org> | 5 | Maintainer: Wim Delvaux <wimpie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: opie-networksettings2, libopiecore2, libopienet2 | 7 | Depends: opie-networksettings2, libopiecore2, libopienet2 |
8 | Description: Network settings usb plugin. | 8 | Description: Network settings usb plugin. |
9 | Version: $QPE_VERSION$EXTRAVERSION | 9 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 14c479a..bd9ae2b 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -1,54 +1,62 @@ | |||
1 | #include <resources.h> | ||
1 | #include "usb_NN.h" | 2 | #include "usb_NN.h" |
2 | #include "usb_NNI.h" | 3 | #include "usb_NNI.h" |
3 | 4 | ||
4 | static const char * USBNeeds[] = | 5 | static const char * USBNeeds[] = |
5 | { 0 | 6 | { 0 |
6 | }; | 7 | }; |
7 | 8 | ||
9 | static const char * USBProvides[] = | ||
10 | { "device", | ||
11 | 0 | ||
12 | }; | ||
13 | |||
8 | /** | 14 | /** |
9 | * Constructor, find all of the possible interfaces | 15 | * Constructor, find all of the possible interfaces |
10 | */ | 16 | */ |
11 | USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { | 17 | USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { |
18 | NSResources->addSystemFile( | ||
19 | "interfaces", "/etc/network/interfaces", 1 ); | ||
12 | } | 20 | } |
13 | 21 | ||
14 | /** | 22 | /** |
15 | * Delete any interfaces that we own. | 23 | * Delete any interfaces that we own. |
16 | */ | 24 | */ |
17 | USBNetNode::~USBNetNode(){ | 25 | USBNetNode::~USBNetNode(){ |
18 | } | 26 | } |
19 | 27 | ||
20 | const QString USBNetNode::nodeDescription(){ | 28 | const QString USBNetNode::nodeDescription(){ |
21 | return tr("\ | 29 | return tr("\ |
22 | <p>Configure Ethernet over USB.</p>\ | 30 | <p>Configure Ethernet over USB.</p>\ |
23 | <p>Use this for a computer to computer USB cable connection</p>\ | 31 | <p>Use this for a computer to computer USB cable connection</p>\ |
24 | " | 32 | " |
25 | ); | 33 | ); |
26 | } | 34 | } |
27 | 35 | ||
28 | ANetNodeInstance * USBNetNode::createInstance( void ) { | 36 | ANetNodeInstance * USBNetNode::createInstance( void ) { |
29 | return new AUSB( this ); | 37 | return new AUSB( this ); |
30 | } | 38 | } |
31 | 39 | ||
32 | const char ** USBNetNode::needs( void ) { | 40 | const char ** USBNetNode::needs( void ) { |
33 | return USBNeeds; | 41 | return USBNeeds; |
34 | } | 42 | } |
35 | 43 | ||
36 | const char * USBNetNode::provides( void ) { | 44 | const char ** USBNetNode::provides( void ) { |
37 | return "device"; | 45 | return USBProvides; |
38 | } | 46 | } |
39 | 47 | ||
40 | QString USBNetNode::genNic( long ) { | 48 | QString USBNetNode::genNic( long ) { |
41 | return QString( "usbf" ); | 49 | return QString( "usbf" ); |
42 | } | 50 | } |
43 | 51 | ||
44 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { | 52 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { |
45 | } | 53 | } |
46 | 54 | ||
47 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { | 55 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { |
48 | } | 56 | } |
49 | 57 | ||
50 | extern "C" { | 58 | extern "C" { |
51 | void create_plugin( QList<ANetNode> & PNN ) { | 59 | void create_plugin( QList<ANetNode> & PNN ) { |
52 | PNN.append( new USBNetNode() ); | 60 | PNN.append( new USBNetNode() ); |
53 | } | 61 | } |
54 | } | 62 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index 73da15a..b825cec 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h | |||
@@ -1,38 +1,38 @@ | |||
1 | #ifndef USB_NETNODE_H | 1 | #ifndef USB_NETNODE_H |
2 | #define USB_NETNODE_H | 2 | #define USB_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AUSB; | 6 | class AUSB; |
7 | 7 | ||
8 | class USBNetNode : public ANetNode{ | 8 | class USBNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
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 nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
22 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
23 | virtual const char * provides( void ); | 23 | virtual const char ** provides( void ); |
24 | 24 | ||
25 | virtual QString genNic( long nr ); | 25 | virtual QString genNic( long nr ); |
26 | 26 | ||
27 | private: | 27 | private: |
28 | 28 | ||
29 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 29 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
30 | virtual void saveSpecificAttribute( QTextStream & TS ); | 30 | virtual void saveSpecificAttribute( QTextStream & TS ); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | extern "C" | 33 | extern "C" |
34 | { | 34 | { |
35 | void create_plugin( QList<ANetNode> & PNN ); | 35 | void create_plugin( QList<ANetNode> & PNN ); |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #endif | 38 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index 50c6e8d..600b771 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp | |||
@@ -1,61 +1,59 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include "usbedit.h" | 2 | #include "usbedit.h" |
3 | #include "usb_NNI.h" | 3 | #include "usb_NNI.h" |
4 | #include "usb_NN.h" | 4 | #include "usb_NN.h" |
5 | 5 | ||
6 | AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) { | 6 | AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) { |
7 | 7 | ||
8 | GUI = 0; | 8 | GUI = 0; |
9 | RT = 0; | 9 | RT = 0; |
10 | } | 10 | } |
11 | 11 | ||
12 | void AUSB::setSpecificAttribute( QString & , QString & ) { | 12 | void AUSB::setSpecificAttribute( QString & , QString & ) { |
13 | } | 13 | } |
14 | 14 | ||
15 | void AUSB::saveSpecificAttribute( QTextStream & ) { | 15 | void AUSB::saveSpecificAttribute( QTextStream & ) { |
16 | } | 16 | } |
17 | 17 | ||
18 | 18 | ||
19 | QWidget * AUSB::edit( QWidget * parent ) { | 19 | QWidget * 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 | ||
25 | QString AUSB::acceptable( void ) { | 25 | QString AUSB::acceptable( void ) { |
26 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 26 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
27 | } | 27 | } |
28 | 28 | ||
29 | void AUSB::commit( void ) { | 29 | void 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 | ||
35 | short AUSB::generateFileEmbedded( const QString & ID, | 35 | short AUSB::generateFileEmbedded( SystemFile & SF, |
36 | const QString & Path, | ||
37 | QTextStream & TS, | ||
38 | long DevNr ) { | 36 | long DevNr ) { |
39 | 37 | ||
40 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 38 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
41 | short rvl, rvd; | 39 | short rvl, rvd; |
42 | 40 | ||
43 | rvl = 1; | 41 | rvl = 1; |
44 | 42 | ||
45 | if( ID == "interfaces" ) { | 43 | if( SF.name() == "interfaces" ) { |
46 | Log(("Generate USB for %s\n", ID.latin1() )); | 44 | Log(("Generate USB for %s\n", SF.name().latin1() )); |
47 | // generate mapping stanza for this interface | 45 | // generate mapping stanza for this interface |
48 | TS << " pre-up " | 46 | SF << " pre-up " |
49 | << QPEApplication::qpeDir() | 47 | << QPEApplication::qpeDir() |
50 | << "bin/setmacaddress.sh " | 48 | << "bin/setmacaddress.sh " |
51 | << NIC | 49 | << NIC |
52 | << " || true" | 50 | << " || true" |
53 | << endl; | 51 | << endl; |
54 | rvl = 0; | 52 | rvl = 0; |
55 | } | 53 | } |
56 | rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); | 54 | rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr ); |
57 | 55 | ||
58 | return (rvd == 2 || rvl == 2 ) ? 2 : | 56 | return (rvd == 2 || rvl == 2 ) ? 2 : |
59 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | 57 | (rvd == 0 || rvl == 0 ) ? 0 : 1; |
60 | 58 | ||
61 | } | 59 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h index fcdfd91..27e71ee 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.h +++ b/noncore/settings/networksettings2/usb/usb_NNI.h | |||
@@ -1,46 +1,44 @@ | |||
1 | #ifndef USB_H | 1 | #ifndef USB_H |
2 | #define USB_H | 2 | #define USB_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "usbdata.h" | 5 | #include "usbdata.h" |
6 | #include "usbrun.h" | 6 | #include "usbrun.h" |
7 | 7 | ||
8 | class USBNetNode; | 8 | class USBNetNode; |
9 | class USBEdit; | 9 | class USBEdit; |
10 | 10 | ||
11 | class AUSB : public ANetNodeInstance { | 11 | class AUSB : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AUSB( USBNetNode * PNN ); | 15 | AUSB( USBNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | 17 | RuntimeInfo * runtime( void ) |
18 | { return | 18 | { return |
19 | ( RT ) ? RT : ( RT = new USBRun( this, Data ) ); | 19 | ( RT ) ? RT : ( RT = new USBRun( this, Data ) ); |
20 | } | 20 | } |
21 | 21 | ||
22 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
23 | QString acceptable( void ); | 23 | QString acceptable( void ); |
24 | void commit( void ); | 24 | void commit( void ); |
25 | 25 | ||
26 | virtual void * data( void ) | 26 | virtual void * data( void ) |
27 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
28 | 28 | ||
29 | virtual short generateFileEmbedded( const QString & ID, | 29 | virtual short generateFileEmbedded( SystemFile & TS, |
30 | const QString & Path, | ||
31 | QTextStream & TS, | ||
32 | long DevNr ); | 30 | long DevNr ); |
33 | 31 | ||
34 | protected : | 32 | protected : |
35 | 33 | ||
36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
37 | virtual void saveSpecificAttribute( QTextStream & TS ); | 35 | virtual void saveSpecificAttribute( QTextStream & TS ); |
38 | 36 | ||
39 | private : | 37 | private : |
40 | 38 | ||
41 | USBEdit * GUI; | 39 | USBEdit * GUI; |
42 | USBData Data; | 40 | USBData Data; |
43 | USBRun * RT; | 41 | USBRun * RT; |
44 | }; | 42 | }; |
45 | 43 | ||
46 | #endif | 44 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usbdata.h b/noncore/settings/networksettings2/usb/usbdata.h index c59f508..fa357b5 100644 --- a/noncore/settings/networksettings2/usb/usbdata.h +++ b/noncore/settings/networksettings2/usb/usbdata.h | |||
@@ -1,8 +1,9 @@ | |||
1 | #ifndef USB_DATA_H | 1 | #ifndef USB_DATA_H |
2 | #define USB_DATA_H | 2 | #define USB_DATA_H |
3 | 3 | ||
4 | typedef struct USBData { | 4 | class USBData { |
5 | public : | ||
5 | bool Fake; | 6 | bool Fake; |
6 | } USBData_t; | 7 | } ; |
7 | 8 | ||
8 | #endif | 9 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usbedit.cpp b/noncore/settings/networksettings2/usb/usbedit.cpp index 153c497..cc96b96 100644 --- a/noncore/settings/networksettings2/usb/usbedit.cpp +++ b/noncore/settings/networksettings2/usb/usbedit.cpp | |||
@@ -1,17 +1,17 @@ | |||
1 | #include <GUIUtils.h> | 1 | #include <GUIUtils.h> |
2 | #include "usbedit.h" | 2 | #include "usbedit.h" |
3 | 3 | ||
4 | USBEdit::USBEdit( QWidget * Parent ) : USBGUI( Parent ){ | 4 | USBEdit::USBEdit( QWidget * Parent ) : USBGUI( Parent ){ |
5 | 5 | ||
6 | } | 6 | } |
7 | 7 | ||
8 | QString USBEdit::acceptable( void ) { | 8 | QString USBEdit::acceptable( void ) { |
9 | return QString(); | 9 | return QString(); |
10 | } | 10 | } |
11 | 11 | ||
12 | void USBEdit::showData( USBData_t & Data ) { | 12 | void USBEdit::showData( USBData & Data ) { |
13 | } | 13 | } |
14 | 14 | ||
15 | bool USBEdit::commit( USBData_t & Data ) { | 15 | bool USBEdit::commit( USBData & Data ) { |
16 | return 1; | 16 | return 1; |
17 | } | 17 | } |
diff --git a/noncore/settings/networksettings2/usb/usbedit.h b/noncore/settings/networksettings2/usb/usbedit.h index 441f2f0..4179898 100644 --- a/noncore/settings/networksettings2/usb/usbedit.h +++ b/noncore/settings/networksettings2/usb/usbedit.h | |||
@@ -1,12 +1,12 @@ | |||
1 | #include "usbdata.h" | 1 | #include "usbdata.h" |
2 | #include "usbGUI.h" | 2 | #include "usbGUI.h" |
3 | 3 | ||
4 | class USBEdit : public USBGUI { | 4 | class USBEdit : public USBGUI { |
5 | 5 | ||
6 | public : | 6 | public : |
7 | 7 | ||
8 | USBEdit( QWidget * parent ); | 8 | USBEdit( QWidget * parent ); |
9 | QString acceptable( void ); | 9 | QString acceptable( void ); |
10 | bool commit( USBData_t & Data ); | 10 | bool commit( USBData & Data ); |
11 | void showData( USBData_t & Data ); | 11 | void showData( USBData & Data ); |
12 | }; | 12 | }; |
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index b8ac8a8..f8824e0 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -1,178 +1,112 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <resources.h> | 4 | #include <resources.h> |
5 | #include "usbrun.h" | 5 | #include "usbrun.h" |
6 | 6 | ||
7 | void USBRun::detectState( NodeCollection * NC ) { | 7 | State_t USBRun::detectState( void ) { |
8 | // unavailable : no card found | 8 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 9 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 10 | // up : card found and assigned to us and up |
11 | NodeCollection * NC = nodeCollection(); | ||
11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
12 | System & Sys = NSResources->system(); | 13 | System & Sys = NSResources->system(); |
13 | InterfaceInfo * Run; | 14 | InterfaceInfo * Run; |
14 | QFile F( S ); | 15 | QFile F( S ); |
15 | Log(("Detecting for %s\n", NC->name().latin1() )); | 16 | Log(("Detecting for %s\n", NC->name().latin1() )); |
16 | 17 | ||
17 | if( F.open( IO_ReadOnly ) ) { | 18 | if( F.open( IO_ReadOnly ) ) { |
18 | // could open file -> read interface and assign | 19 | // could open file -> read interface and assign |
19 | QString X; | 20 | QString X; |
20 | QTextStream TS(&F); | 21 | QTextStream TS(&F); |
21 | X = TS.readLine(); | 22 | X = TS.readLine(); |
22 | Log(("%s exists\n", S.latin1() )); | 23 | Log(("%s exists\n", S.latin1() )); |
23 | // find interface | 24 | // find interface |
24 | if( handlesInterface( X ) ) { | 25 | if( handlesInterface( X ) ) { |
25 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 26 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
26 | It.current(); | 27 | It.current(); |
27 | ++It ) { | 28 | ++It ) { |
28 | Run = It.current(); | 29 | Run = It.current(); |
29 | if( X == Run->Name ) { | 30 | if( X == Run->Name ) { |
30 | Run->assignNode( netNode() ); | 31 | NC->assignInterface( Run ); |
31 | assignInterface( Run ); | 32 | return IsUp; |
32 | NC->setCurrentState( IsUp ); | ||
33 | return; | ||
34 | } | 33 | } |
35 | } | 34 | } |
36 | } | 35 | } |
37 | } | 36 | } |
38 | 37 | ||
39 | Log(("Assigned %p\n", assignedInterface() )); | 38 | Log(("Assigned %p\n", NC->assignedInterface() )); |
40 | if( ( Run = assignedInterface() ) ) { | 39 | if( ( Run = NC->assignedInterface() ) ) { |
41 | // we already have an interface assigned -> still present ? | 40 | // we already have an interface assigned -> still present ? |
42 | if( ! Run->IsUp ) { | 41 | if( ! Run->IsUp ) { |
43 | // usb is still free -> keep assignment | 42 | // usb is still free -> keep assignment |
44 | NC->setCurrentState( Available ); | 43 | return Available; |
45 | return; | ||
46 | } // else interface is up but NOT us -> some other profile | 44 | } // else interface is up but NOT us -> some other profile |
47 | } | 45 | } |
48 | 46 | ||
49 | // nothing (valid) assigned to us | 47 | // nothing (valid) assigned to us |
50 | assignInterface( 0 ); | 48 | NC->assignInterface( 0 ); |
51 | 49 | ||
52 | // find possible interface | 50 | // find possible interface |
53 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 51 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
54 | It.current(); | 52 | It.current(); |
55 | ++It ) { | 53 | ++It ) { |
56 | Run = It.current(); | 54 | Run = It.current(); |
57 | 55 | ||
58 | Log(("%s %d %d=%d %d\n", | 56 | Log(("%s %d %d=%d %d\n", |
59 | Run->Name.latin1(), | 57 | Run->Name.latin1(), |
60 | handlesInterface( Run->Name ), | 58 | handlesInterface( Run->Name ), |
61 | Run->CardType, ARPHRD_ETHER, | 59 | Run->CardType, ARPHRD_ETHER, |
62 | ! Run->IsUp )); | 60 | ! Run->IsUp )); |
63 | 61 | ||
64 | if( handlesInterface( Run->Name ) && | 62 | if( handlesInterface( Run->Name ) && |
65 | Run->CardType == ARPHRD_ETHER && | 63 | Run->CardType == ARPHRD_ETHER && |
66 | ! Run->IsUp | 64 | ! Run->IsUp |
67 | ) { | 65 | ) { |
68 | Log(("Released(OFF)\n" )); | ||
69 | // proper type, and Not UP -> free | 66 | // proper type, and Not UP -> free |
70 | NC->setCurrentState( Off ); | 67 | return Off; |
71 | return; | ||
72 | } | 68 | } |
73 | } | 69 | } |
74 | // no free found | ||
75 | Log(("UNA\n" )); | ||
76 | 70 | ||
77 | NC->setCurrentState( Unavailable ); | 71 | return Unavailable; |
78 | } | 72 | } |
79 | 73 | ||
80 | bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { | 74 | QString USBRun::setMyState( NodeCollection *, Action_t , bool ) { |
81 | 75 | return QString(); | |
82 | // we only handle activate and deactivate | ||
83 | switch( A ) { | ||
84 | case Activate : | ||
85 | { | ||
86 | if( NC->currentState() != Off ) { | ||
87 | return 0; | ||
88 | } | ||
89 | InterfaceInfo * N = getInterface(); | ||
90 | if( ! N ) { | ||
91 | // no interface available | ||
92 | NC->setCurrentState( Unavailable ); | ||
93 | return 0; | ||
94 | } | ||
95 | // because we were OFF the interface | ||
96 | // we get back is NOT assigned | ||
97 | N->assignNode( netNode() ); | ||
98 | assignInterface( N ); | ||
99 | Log(("Assing %p\n", N )); | ||
100 | NC->setCurrentState( Available ); | ||
101 | return 1; | ||
102 | } | ||
103 | case Deactivate : | ||
104 | if( NC->currentState() == IsUp ) { | ||
105 | // bring down first | ||
106 | if( ! connection()->setState( Down ) ) | ||
107 | // could not ... | ||
108 | return 0; | ||
109 | } else if( NC->currentState() != Available ) { | ||
110 | return 1; | ||
111 | } | ||
112 | assignedInterface()->assignNode( 0 ); // release | ||
113 | assignInterface( 0 ); | ||
114 | NC->setCurrentState( Off ); | ||
115 | return 1; | ||
116 | default : | ||
117 | // FT | ||
118 | break; | ||
119 | } | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | bool USBRun::canSetState( State_t Curr, Action_t A ) { | ||
124 | // we only handle up down activate and deactivate | ||
125 | switch( A ) { | ||
126 | case Activate : | ||
127 | { // at least available | ||
128 | if( Curr == Available ) { | ||
129 | return 1; | ||
130 | } | ||
131 | // or we can make one available | ||
132 | InterfaceInfo * N = getInterface(); | ||
133 | if( ! N || N->assignedNode() != 0 ) { | ||
134 | // non available or assigned | ||
135 | return 0; | ||
136 | } | ||
137 | return 1; | ||
138 | } | ||
139 | case Deactivate : | ||
140 | return ( Curr >= Available ); | ||
141 | default : | ||
142 | // FT | ||
143 | break; | ||
144 | } | ||
145 | return 0; | ||
146 | } | 76 | } |
147 | 77 | ||
148 | // get interface that is free or assigned to us | 78 | // get interface that is free or assigned to us |
149 | InterfaceInfo * USBRun::getInterface( void ) { | 79 | InterfaceInfo * USBRun::getInterface( void ) { |
150 | 80 | ||
151 | System & S = NSResources->system(); | 81 | System & S = NSResources->system(); |
152 | InterfaceInfo * best = 0, * Run; | 82 | InterfaceInfo * best = 0, * Run; |
153 | QRegExp R( "usb[0-9abcdef]" ); | 83 | QRegExp R( "usb[0-9abcdef]" ); |
154 | 84 | ||
155 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 85 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
156 | It.current(); | 86 | It.current(); |
157 | ++It ) { | 87 | ++It ) { |
158 | Run = It.current(); | 88 | Run = It.current(); |
159 | if( handlesInterface( Run->Name ) && | 89 | if( handlesInterface( Run->Name ) && |
160 | Run->CardType == ARPHRD_ETHER | 90 | Run->CardType == ARPHRD_ETHER |
161 | ) { | 91 | ) { |
162 | // this is a USB card | 92 | // this is a USB card |
163 | if( Run->assignedNode() == netNode() ) { | 93 | if( Run->assignedConnection() == netNode()->connection() ) { |
164 | // assigned to us | 94 | // assigned to us |
165 | return Run; | 95 | return Run; |
166 | } else if( Run->assignedNode() == 0 ) { | 96 | } else if( Run->assignedConnection() == 0 ) { |
167 | // free | 97 | // free |
168 | best = Run; | 98 | best = Run; |
169 | } | 99 | } |
170 | } | 100 | } |
171 | } | 101 | } |
172 | return best; // can be 0 | 102 | return best; // can be 0 |
173 | } | 103 | } |
174 | 104 | ||
175 | bool USBRun::handlesInterface( const QString & S ) { | 105 | bool USBRun::handlesInterface( const QString & S ) { |
176 | return Pat.match( S ) >= 0; | 106 | return Pat.match( S ) >= 0; |
177 | } | 107 | } |
178 | 108 | ||
109 | bool USBRun::handlesInterface( InterfaceInfo * I ) { | ||
110 | return handlesInterface( I->Name ); | ||
111 | } | ||
112 | |||
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h index 03e21ab..6ce4fa2 100644 --- a/noncore/settings/networksettings2/usb/usbrun.h +++ b/noncore/settings/networksettings2/usb/usbrun.h | |||
@@ -1,37 +1,36 @@ | |||
1 | #ifndef USBRUN_H | 1 | #ifndef USBRUN_H |
2 | #define USBRUN_H | 2 | #define USBRUN_H |
3 | 3 | ||
4 | #include <asdevice.h> | 4 | #include <netnode.h> |
5 | #include <qregexp.h> | 5 | #include <qregexp.h> |
6 | #include "usbdata.h" | 6 | #include "usbdata.h" |
7 | 7 | ||
8 | class USBRun : public AsDevice { | 8 | class USBRun : public RuntimeInfo { |
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 | RuntimeInfo( NNI ), |
15 | Pat( "usb[0-9abcdef]" ) | 15 | Pat( "usb[0-9abcdef]" ) { |
16 | { } | 16 | } |
17 | 17 | ||
18 | virtual AsDevice * device( void ) | 18 | virtual RuntimeInfo * device( void ) |
19 | { return (AsDevice *)this; } | 19 | { return this; } |
20 | 20 | ||
21 | virtual AsDevice * asDevice( void ) | 21 | bool handlesInterface( const QString & I ); |
22 | { return (AsDevice *)this; } | 22 | bool handlesInterface( InterfaceInfo * ); |
23 | protected : | ||
24 | 23 | ||
25 | void detectState( NodeCollection * ); | 24 | State_t detectState( void ); |
26 | bool setState( NodeCollection * , Action_t A, bool ); | ||
27 | bool canSetState( State_t , Action_t A ); | ||
28 | 25 | ||
29 | bool handlesInterface( const QString & I ); | 26 | protected : |
27 | |||
28 | QString setMyState( NodeCollection * , Action_t, bool ); | ||
30 | 29 | ||
31 | private : | 30 | private : |
32 | 31 | ||
33 | InterfaceInfo * getInterface( void ); | 32 | InterfaceInfo * getInterface( void ); |
34 | QRegExp Pat; | 33 | QRegExp Pat; |
35 | 34 | ||
36 | }; | 35 | }; |
37 | #endif | 36 | #endif |