summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/usb
Side-by-side diff
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,7 +1,7 @@
-Package: opie-networksettingsplugin2-usb
+Package: opie-networksettings2plugin-usb
Files: plugins/networksettings2/libusb.so*
Priority: optional
Section: opie/settings
Maintainer: Wim Delvaux <wimpie@handhelds.org>
Architecture: arm
Depends: opie-networksettings2, libopiecore2, libopienet2
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,17 +1,25 @@
+#include <resources.h>
#include "usb_NN.h"
#include "usb_NNI.h"
static const char * USBNeeds[] =
{ 0
};
+static const char * USBProvides[] =
+ { "device",
+ 0
+ };
+
/**
* Constructor, find all of the possible interfaces
*/
USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
+ NSResources->addSystemFile(
+ "interfaces", "/etc/network/interfaces", 1 );
}
/**
* Delete any interfaces that we own.
*/
USBNetNode::~USBNetNode(){
@@ -30,14 +38,14 @@ ANetNodeInstance * USBNetNode::createInstance( void ) {
}
const char ** USBNetNode::needs( void ) {
return USBNeeds;
}
-const char * USBNetNode::provides( void ) {
- return "device";
+const char ** USBNetNode::provides( void ) {
+ return USBProvides;
}
QString USBNetNode::genNic( long ) {
return QString( "usbf" );
}
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
@@ -17,13 +17,13 @@ public:
virtual const QString pixmapName()
{ return "Devices/usb"; }
virtual const QString nodeDescription() ;
virtual ANetNodeInstance * createInstance( void );
virtual const char ** needs( void );
- virtual const char * provides( void );
+ virtual const char ** provides( void );
virtual QString genNic( long nr );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -29,33 +29,31 @@ QString AUSB::acceptable( void ) {
void AUSB::commit( void ) {
if( GUI && GUI->commit( Data ) ) {
setModified( 1 );
}
}
-short AUSB::generateFileEmbedded( const QString & ID,
- const QString & Path,
- QTextStream & TS,
+short AUSB::generateFileEmbedded( SystemFile & SF,
long DevNr ) {
QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
short rvl, rvd;
rvl = 1;
- 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()
<< "bin/setmacaddress.sh "
<< NIC
<< " || true"
<< endl;
rvl = 0;
}
- rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
+ rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr );
return (rvd == 2 || rvl == 2 ) ? 2 :
(rvd == 0 || rvl == 0 ) ? 0 : 1;
}
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
@@ -23,15 +23,13 @@ public :
QString acceptable( void );
void commit( void );
virtual void * data( void )
{ return (void *)&Data; }
- virtual short generateFileEmbedded( const QString & ID,
- const QString & Path,
- QTextStream & TS,
+ virtual short generateFileEmbedded( SystemFile & TS,
long DevNr );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
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 @@
#ifndef USB_DATA_H
#define USB_DATA_H
-typedef struct USBData {
+class USBData {
+public :
bool Fake;
-} USBData_t;
+} ;
#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
@@ -6,12 +6,12 @@ USBEdit::USBEdit( QWidget * Parent ) : USBGUI( Parent ){
}
QString USBEdit::acceptable( void ) {
return QString();
}
-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
@@ -4,9 +4,9 @@
class USBEdit : public USBGUI {
public :
USBEdit( QWidget * parent );
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
@@ -1,16 +1,17 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <resources.h>
#include "usbrun.h"
-void USBRun::detectState( NodeCollection * NC ) {
+State_t USBRun::detectState( void ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
+ NodeCollection * NC = nodeCollection();
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
Log(("Detecting for %s\n", NC->name().latin1() ));
@@ -24,33 +25,30 @@ void USBRun::detectState( NodeCollection * NC ) {
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
- Run->assignNode( netNode() );
- assignInterface( Run );
- NC->setCurrentState( IsUp );
- return;
+ NC->assignInterface( Run );
+ return IsUp;
}
}
}
}
- 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 ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
- NC->setCurrentState( Available );
- return;
+ return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
- assignInterface( 0 );
+ NC->assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
@@ -62,90 +60,22 @@ void USBRun::detectState( NodeCollection * NC ) {
! Run->IsUp ));
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER &&
! Run->IsUp
) {
- 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();
}
// get interface that is free or assigned to us
InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
@@ -157,22 +87,26 @@ InterfaceInfo * USBRun::getInterface( void ) {
++It ) {
Run = It.current();
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER
) {
// 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
best = Run;
}
}
}
return best; // can be 0
}
bool USBRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
+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
@@ -1,35 +1,34 @@
#ifndef USBRUN_H
#define USBRUN_H
-#include <asdevice.h>
+#include <netnode.h>
#include <qregexp.h>
#include "usbdata.h"
-class USBRun : public AsDevice {
+class USBRun : public RuntimeInfo {
public :
USBRun( ANetNodeInstance * NNI,
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 );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;