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/usb_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp15
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,34 +1,30 @@
#include <resources.h>
#include "usb_NN.h"
#include "usb_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
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(){
}
const QString USBNetNode::nodeDescription(){
@@ -40,38 +36,25 @@ const QString USBNetNode::nodeDescription(){
}
ANetNodeInstance * USBNetNode::createInstance( void ) {
return new AUSB( this );
}
const char ** USBNetNode::needs( void ) {
return USBNeeds;
}
const char ** USBNetNode::provides( void ) {
return USBProvides;
}
QString USBNetNode::genNic( long ) {
return QString( "usbf" );
}
void USBNetNode::setSpecificAttribute( QString & , QString & ) {
}
void USBNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new USBNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<USBNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> )
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,34 +1,36 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <resources.h>
#include "usbrun.h"
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() ));
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
Log(("%s exists\n", S.latin1() ));
// find interface
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
NC->assignInterface( Run );
return IsUp;
}
}
@@ -43,68 +45,61 @@ State_t USBRun::detectState( void ) {
return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
NC->assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
Log(("%s %d %d=%d %d\n",
Run->Name.latin1(),
handlesInterface( Run->Name ),
Run->CardType, ARPHRD_ETHER,
! Run->IsUp ));
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER &&
! Run->IsUp
) {
// proper type, and Not UP -> free
- return Off;
+ // usb cables are currently always available when requested
+ // until we can detect if we are plugged in
+ return Available;
}
}
return Unavailable;
}
QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
// nothing needs to be done to 'activate' or 'deactivate'
// a cable
-
- // perhaps (later) we can figure out if the device is IN the
- // cradle
- if( A == Activate ) {
- NC->setCurrentState( Available );
- } else if ( A == Deactivate ) {
- NC->setCurrentState( Unavailable );
- }
-
return QString();
}
// get interface that is free or assigned to us
InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
QRegExp R( "usb[0-9abcdef]" );
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER
) {
// this is a USB card
if( Run->assignedConnection() == netNode()->connection() ) {
// assigned to us
return Run;
} else if( Run->assignedConnection() == 0 ) {
// free
best = Run;