summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/usb
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (show 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 @@
-Package: opie-networksettingsplugin2-usb
+Package: opie-networksettings2plugin-usb
Files: 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 @@
+#include <resources.h>
#include "usb_NN.h"
@@ -7,2 +8,7 @@ static const char * USBNeeds[] =
+static const char * USBProvides[] =
+ { "device",
+ 0
+ };
+
/**
@@ -11,2 +17,4 @@ static const char * USBNeeds[] =
USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
+ NSResources->addSystemFile(
+ "interfaces", "/etc/network/interfaces", 1 );
}
@@ -35,4 +43,4 @@ const char ** USBNetNode::needs( void ) {
-const char * USBNetNode::provides( void ) {
- return "device";
+const char ** USBNetNode::provides( void ) {
+ return USBProvides;
}
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:
virtual const char ** needs( void );
- virtual const char * provides( void );
+ virtual const char ** provides( void );
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 ) {
-short AUSB::generateFileEmbedded( const QString & ID,
- const QString & Path,
- QTextStream & TS,
+short AUSB::generateFileEmbedded( SystemFile & SF,
long DevNr ) {
@@ -44,6 +42,6 @@ short AUSB::generateFileEmbedded( const QString & ID,
- if( ID == "interfaces" ) {
- Log(("Generate USB for %s\n", ID.latin1() ));
+ if( SF.name() == "interfaces" ) {
+ Log(("Generate USB for %s\n", SF.name().latin1() ));
// generate mapping stanza for this interface
- TS << " pre-up "
+ SF << " pre-up "
<< QPEApplication::qpeDir()
@@ -55,3 +53,3 @@ short AUSB::generateFileEmbedded( const QString & ID,
}
- rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
+ rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr );
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 :
- virtual short generateFileEmbedded( const QString & ID,
- const QString & Path,
- QTextStream & TS,
+ virtual short generateFileEmbedded( SystemFile & TS,
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 @@
-typedef struct USBData {
+class USBData {
+public :
bool Fake;
-} USBData_t;
+} ;
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 ) {
-void USBEdit::showData( USBData_t & Data ) {
+void USBEdit::showData( USBData & Data ) {
}
-bool USBEdit::commit( USBData_t & Data ) {
+bool USBEdit::commit( USBData & Data ) {
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 :
QString acceptable( void );
- bool commit( USBData_t & Data );
- void showData( USBData_t & Data );
+ bool commit( USBData & Data );
+ void showData( USBData & Data );
};
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 @@
-void USBRun::detectState( NodeCollection * NC ) {
+State_t USBRun::detectState( void ) {
// unavailable : no card found
@@ -10,2 +10,3 @@ void USBRun::detectState( NodeCollection * NC ) {
// up : card found and assigned to us and up
+ NodeCollection * NC = nodeCollection();
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
@@ -29,6 +30,4 @@ void USBRun::detectState( NodeCollection * NC ) {
if( X == Run->Name ) {
- Run->assignNode( netNode() );
- assignInterface( Run );
- NC->setCurrentState( IsUp );
- return;
+ NC->assignInterface( Run );
+ return IsUp;
}
@@ -38,4 +37,4 @@ void USBRun::detectState( NodeCollection * NC ) {
- Log(("Assigned %p\n", assignedInterface() ));
- if( ( Run = assignedInterface() ) ) {
+ Log(("Assigned %p\n", NC->assignedInterface() ));
+ if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
@@ -43,4 +42,3 @@ void USBRun::detectState( NodeCollection * NC ) {
// usb is still free -> keep assignment
- NC->setCurrentState( Available );
- return;
+ return Available;
} // else interface is up but NOT us -> some other profile
@@ -49,3 +47,3 @@ void USBRun::detectState( NodeCollection * NC ) {
// nothing (valid) assigned to us
- assignInterface( 0 );
+ NC->assignInterface( 0 );
@@ -67,80 +65,12 @@ void USBRun::detectState( NodeCollection * NC ) {
) {
- Log(("Released(OFF)\n" ));
// proper type, and Not UP -> free
- NC->setCurrentState( Off );
- return;
+ return Off;
}
}
- // no free found
- Log(("UNA\n" ));
- NC->setCurrentState( Unavailable );
+ return Unavailable;
}
-bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) {
-
- // we only handle activate and deactivate
- switch( A ) {
- case Activate :
- {
- if( NC->currentState() != Off ) {
- return 0;
- }
- InterfaceInfo * N = getInterface();
- if( ! N ) {
- // no interface available
- NC->setCurrentState( Unavailable );
- return 0;
- }
- // because we were OFF the interface
- // we get back is NOT assigned
- N->assignNode( netNode() );
- assignInterface( N );
- Log(("Assing %p\n", N ));
- NC->setCurrentState( Available );
- return 1;
- }
- case Deactivate :
- if( NC->currentState() == IsUp ) {
- // bring down first
- if( ! connection()->setState( Down ) )
- // could not ...
- return 0;
- } else if( NC->currentState() != Available ) {
- return 1;
- }
- assignedInterface()->assignNode( 0 ); // release
- assignInterface( 0 );
- NC->setCurrentState( Off );
- return 1;
- default :
- // FT
- break;
- }
- return 0;
-}
-
-bool USBRun::canSetState( State_t Curr, Action_t A ) {
- // we only handle up down activate and deactivate
- switch( A ) {
- case Activate :
- { // at least available
- if( Curr == Available ) {
- return 1;
- }
- // or we can make one available
- InterfaceInfo * N = getInterface();
- if( ! N || N->assignedNode() != 0 ) {
- // non available or assigned
- return 0;
- }
- return 1;
- }
- case Deactivate :
- return ( Curr >= Available );
- default :
- // FT
- break;
- }
- return 0;
+QString USBRun::setMyState( NodeCollection *, Action_t , bool ) {
+ return QString();
}
@@ -162,6 +92,6 @@ InterfaceInfo * USBRun::getInterface( void ) {
// this is a USB card
- if( Run->assignedNode() == netNode() ) {
+ if( Run->assignedConnection() == netNode()->connection() ) {
// assigned to us
return Run;
- } else if( Run->assignedNode() == 0 ) {
+ } else if( Run->assignedConnection() == 0 ) {
// free
@@ -178 +108,5 @@ bool USBRun::handlesInterface( const QString & S ) {
+bool USBRun::handlesInterface( InterfaceInfo * I ) {
+ return handlesInterface( I->Name );
+}
+
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 @@
-#include <asdevice.h>
+#include <netnode.h>
#include <qregexp.h>
@@ -7,3 +7,3 @@
-class USBRun : public AsDevice {
+class USBRun : public RuntimeInfo {
@@ -13,18 +13,17 @@ public :
USBData & Data ) :
- AsDevice( NNI ),
- Pat( "usb[0-9abcdef]" )
- { }
+ RuntimeInfo( NNI ),
+ Pat( "usb[0-9abcdef]" ) {
+ }
- virtual AsDevice * device( void )
- { return (AsDevice *)this; }
+ virtual RuntimeInfo * device( void )
+ { return this; }
- virtual AsDevice * asDevice( void )
- { return (AsDevice *)this; }
-protected :
+ bool handlesInterface( const QString & I );
+ bool handlesInterface( InterfaceInfo * );
- void detectState( NodeCollection * );
- bool setState( NodeCollection * , Action_t A, bool );
- bool canSetState( State_t , Action_t A );
+ State_t detectState( void );
- bool handlesInterface( const QString & I );
+protected :
+
+ QString setMyState( NodeCollection * , Action_t, bool );