Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/usb/usb_NN.cpp | 19 | ||||
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.cpp | 15 |
2 files changed, 6 insertions, 28 deletions
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 9c07b82..6d90ae0 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -1,22 +1,18 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "usb_NN.h" | 2 | #include "usb_NN.h" |
3 | #include "usb_NNI.h" | 3 | #include "usb_NNI.h" |
4 | 4 | ||
5 | #ifndef MYPLUGIN | ||
6 | |||
7 | #include "netnodeinterface.h" | 5 | #include "netnodeinterface.h" |
8 | 6 | ||
9 | #endif | ||
10 | |||
11 | static const char * USBNeeds[] = | 7 | static const char * USBNeeds[] = |
12 | { 0 | 8 | { 0 |
13 | }; | 9 | }; |
14 | 10 | ||
15 | static const char * USBProvides[] = | 11 | static const char * USBProvides[] = |
16 | { "device", | 12 | { "device", |
17 | 0 | 13 | 0 |
18 | }; | 14 | }; |
19 | 15 | ||
20 | /** | 16 | /** |
21 | * Constructor, find all of the possible interfaces | 17 | * Constructor, find all of the possible interfaces |
22 | */ | 18 | */ |
@@ -52,26 +48,13 @@ const char ** USBNetNode::provides( void ) { | |||
52 | } | 48 | } |
53 | 49 | ||
54 | QString USBNetNode::genNic( long ) { | 50 | QString USBNetNode::genNic( long ) { |
55 | return QString( "usbf" ); | 51 | return QString( "usbf" ); |
56 | } | 52 | } |
57 | 53 | ||
58 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { | 54 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { |
59 | } | 55 | } |
60 | 56 | ||
61 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { | 57 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { |
62 | } | 58 | } |
63 | 59 | ||
64 | #ifdef MYPLUGIN | 60 | OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> ) |
65 | |||
66 | extern "C" { | ||
67 | void create_plugin( QList<ANetNode> & PNN ) { | ||
68 | PNN.append( new USBNetNode() ); | ||
69 | } | ||
70 | |||
71 | #else | ||
72 | |||
73 | OPIE_NS2_PLUGIN( NetNodeInterface<USBNetNode> ) | ||
74 | |||
75 | #endif | ||
76 | |||
77 | } | ||
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 0a46642..eb439c1 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -1,22 +1,24 @@ | |||
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 | State_t USBRun::detectState( void ) { | 7 | State_t USBRun::detectState( void ) { |
8 | |||
8 | // unavailable : no card found | 9 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 10 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 11 | // up : card found and assigned to us and up |
12 | |||
11 | NodeCollection * NC = nodeCollection(); | 13 | NodeCollection * NC = nodeCollection(); |
12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 14 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
13 | System & Sys = NSResources->system(); | 15 | System & Sys = NSResources->system(); |
14 | InterfaceInfo * Run; | 16 | InterfaceInfo * Run; |
15 | QFile F( S ); | 17 | QFile F( S ); |
16 | Log(("Detecting for %s\n", NC->name().latin1() )); | 18 | Log(("Detecting for %s\n", NC->name().latin1() )); |
17 | 19 | ||
18 | if( F.open( IO_ReadOnly ) ) { | 20 | if( F.open( IO_ReadOnly ) ) { |
19 | // could open file -> read interface and assign | 21 | // could open file -> read interface and assign |
20 | QString X; | 22 | QString X; |
21 | QTextStream TS(&F); | 23 | QTextStream TS(&F); |
22 | X = TS.readLine(); | 24 | X = TS.readLine(); |
@@ -55,44 +57,37 @@ State_t USBRun::detectState( void ) { | |||
55 | 57 | ||
56 | Log(("%s %d %d=%d %d\n", | 58 | Log(("%s %d %d=%d %d\n", |
57 | Run->Name.latin1(), | 59 | Run->Name.latin1(), |
58 | handlesInterface( Run->Name ), | 60 | handlesInterface( Run->Name ), |
59 | Run->CardType, ARPHRD_ETHER, | 61 | Run->CardType, ARPHRD_ETHER, |
60 | ! Run->IsUp )); | 62 | ! Run->IsUp )); |
61 | 63 | ||
62 | if( handlesInterface( Run->Name ) && | 64 | if( handlesInterface( Run->Name ) && |
63 | Run->CardType == ARPHRD_ETHER && | 65 | Run->CardType == ARPHRD_ETHER && |
64 | ! Run->IsUp | 66 | ! Run->IsUp |
65 | ) { | 67 | ) { |
66 | // proper type, and Not UP -> free | 68 | // proper type, and Not UP -> free |
67 | return Off; | 69 | // usb cables are currently always available when requested |
70 | // until we can detect if we are plugged in | ||
71 | return Available; | ||
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
71 | return Unavailable; | 75 | return Unavailable; |
72 | } | 76 | } |
73 | 77 | ||
74 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | 78 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
75 | 79 | ||
76 | // nothing needs to be done to 'activate' or 'deactivate' | 80 | // nothing needs to be done to 'activate' or 'deactivate' |
77 | // a cable | 81 | // a cable |
78 | |||
79 | // perhaps (later) we can figure out if the device is IN the | ||
80 | // cradle | ||
81 | if( A == Activate ) { | ||
82 | NC->setCurrentState( Available ); | ||
83 | } else if ( A == Deactivate ) { | ||
84 | NC->setCurrentState( Unavailable ); | ||
85 | } | ||
86 | |||
87 | return QString(); | 82 | return QString(); |
88 | } | 83 | } |
89 | 84 | ||
90 | // get interface that is free or assigned to us | 85 | // get interface that is free or assigned to us |
91 | InterfaceInfo * USBRun::getInterface( void ) { | 86 | InterfaceInfo * USBRun::getInterface( void ) { |
92 | 87 | ||
93 | System & S = NSResources->system(); | 88 | System & S = NSResources->system(); |
94 | InterfaceInfo * best = 0, * Run; | 89 | InterfaceInfo * best = 0, * Run; |
95 | QRegExp R( "usb[0-9abcdef]" ); | 90 | QRegExp R( "usb[0-9abcdef]" ); |
96 | 91 | ||
97 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 92 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
98 | It.current(); | 93 | It.current(); |