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/opie-networksettings2plugin-usb.control2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp12
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp12
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h4
-rw-r--r--noncore/settings/networksettings2/usb/usbdata.h5
-rw-r--r--noncore/settings/networksettings2/usb/usbedit.cpp4
-rw-r--r--noncore/settings/networksettings2/usb/usbedit.h4
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp102
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h27
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,2 +1,2 @@
1Package: opie-networksettingsplugin2-usb 1Package: opie-networksettings2plugin-usb
2Files: plugins/networksettings2/libusb.so* 2Files: plugins/networksettings2/libusb.so*
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 +1,2 @@
1#include <resources.h>
1#include "usb_NN.h" 2#include "usb_NN.h"
@@ -7,2 +8,7 @@ static const char * USBNeeds[] =
7 8
9static const char * USBProvides[] =
10 { "device",
11 0
12 };
13
8/** 14/**
@@ -11,2 +17,4 @@ static const char * USBNeeds[] =
11USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { 17USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
18 NSResources->addSystemFile(
19 "interfaces", "/etc/network/interfaces", 1 );
12} 20}
@@ -35,4 +43,4 @@ const char ** USBNetNode::needs( void ) {
35 43
36const char * USBNetNode::provides( void ) { 44const char ** USBNetNode::provides( void ) {
37 return "device"; 45 return USBProvides;
38} 46}
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
@@ -22,3 +22,3 @@ public:
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
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
@@ -34,5 +34,3 @@ void AUSB::commit( void ) {
34 34
35short AUSB::generateFileEmbedded( const QString & ID, 35short AUSB::generateFileEmbedded( SystemFile & SF,
36 const QString & Path,
37 QTextStream & TS,
38 long DevNr ) { 36 long DevNr ) {
@@ -44,6 +42,6 @@ short AUSB::generateFileEmbedded( const QString & ID,
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()
@@ -55,3 +53,3 @@ short AUSB::generateFileEmbedded( const QString & ID,
55 } 53 }
56 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 54 rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr );
57 55
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
@@ -28,5 +28,3 @@ public :
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 );
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
@@ -3,5 +3,6 @@
3 3
4typedef struct USBData { 4class USBData {
5public :
5 bool Fake; 6 bool Fake;
6} USBData_t; 7} ;
7 8
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
@@ -11,6 +11,6 @@ QString USBEdit::acceptable( void ) {
11 11
12void USBEdit::showData( USBData_t & Data ) { 12void USBEdit::showData( USBData & Data ) {
13} 13}
14 14
15bool USBEdit::commit( USBData_t & Data ) { 15bool USBEdit::commit( USBData & Data ) {
16 return 1; 16 return 1;
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
@@ -9,4 +9,4 @@ public :
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
@@ -6,3 +6,3 @@
6 6
7void USBRun::detectState( NodeCollection * NC ) { 7State_t USBRun::detectState( void ) {
8 // unavailable : no card found 8 // unavailable : no card found
@@ -10,2 +10,3 @@ void USBRun::detectState( NodeCollection * NC ) {
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());
@@ -29,6 +30,4 @@ void USBRun::detectState( NodeCollection * NC ) {
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 }
@@ -38,4 +37,4 @@ void USBRun::detectState( NodeCollection * NC ) {
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 ?
@@ -43,4 +42,3 @@ void USBRun::detectState( NodeCollection * NC ) {
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
@@ -49,3 +47,3 @@ void USBRun::detectState( NodeCollection * NC ) {
49 // nothing (valid) assigned to us 47 // nothing (valid) assigned to us
50 assignInterface( 0 ); 48 NC->assignInterface( 0 );
51 49
@@ -67,80 +65,12 @@ void USBRun::detectState( NodeCollection * NC ) {
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
80bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { 74QString 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
123bool 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}
@@ -162,6 +92,6 @@ InterfaceInfo * USBRun::getInterface( void ) {
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
@@ -178 +108,5 @@ bool USBRun::handlesInterface( const QString & S ) {
178 108
109bool 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
@@ -3,3 +3,3 @@
3 3
4#include <asdevice.h> 4#include <netnode.h>
5#include <qregexp.h> 5#include <qregexp.h>
@@ -7,3 +7,3 @@
7 7
8class USBRun : public AsDevice { 8class USBRun : public RuntimeInfo {
9 9
@@ -13,18 +13,17 @@ public :
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 * );
23protected :
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 ); 26protected :
27
28 QString setMyState( NodeCollection * , Action_t, bool );
30 29