summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-07 15:23:23 (UTC)
committer wimpie <wimpie>2005-01-07 15:23:23 (UTC)
commitb4eced64efad35beeb2004243ca26bf7eb20eaba (patch) (side-by-side diff)
tree14caf32705c787a8bffc917ecdf216ad40cfbdc0
parent7af7203a51ddcf85f9f60e39157fcad21f7d9e34 (diff)
downloadopie-b4eced64efad35beeb2004243ca26bf7eb20eaba.zip
opie-b4eced64efad35beeb2004243ca26bf7eb20eaba.tar.gz
opie-b4eced64efad35beeb2004243ca26bf7eb20eaba.tar.bz2
All NS2 libraries are now properly working plugins
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp21
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp5
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp4
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp37
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h44
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnodeinterface.h18
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp167
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h60
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp88
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp15
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp19
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp19
21 files changed, 186 insertions, 482 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp
index 5e4d951..5c2b8b2 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp
@@ -1,26 +1,22 @@
#include "bluetoothBNEP_NN.h"
#include "bluetoothBNEP_NNI.h"
#include "bluetoothRFCOMM_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
//
//
// BLUETOOTH PAN/NAP node
//
//
static const char * BluetoothBNEPNeeds[] =
{ 0
};
static const char * BluetoothBNEPProvides[] =
{ "device",
0
};
/**
@@ -62,33 +58,18 @@ QString BluetoothBNEPNetNode::genNic( long nr ) {
return S.sprintf( "bnep%ld", nr );
}
void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) {
if( A == "interfacecount" ) {
InstanceCount = V.toLong();
}
}
void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) {
TS << "interfacecount="
<< InstanceCount
<< endl;
}
-#ifndef MYPLUGIN
-
-extern "C" {
-// create plugin registers both BT functions
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new BluetoothBNEPNetNode() );
- PNN.append( new BluetoothRFCOMMNetNode() );
-}
-
-#else
-
typedef Opie::Core::MakeTypelist<BluetoothBNEPNetNode, BluetoothRFCOMMNetNode>::Result BluetoothTypes;
-OPIE_NS2_PLUGIN( NetNodeInterface<BluetoothTypes> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<BluetoothTypes> )
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 20299e4..58237a1 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -1,25 +1,21 @@
#include "cable_NN.h"
#include "cable_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * CableNeeds[] =
{ 0
};
static const char * CableProvides[] =
{ "line",
0
};
/**
* Constructor, find all of the possible interfaces
*/
CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) {
}
/**
@@ -40,30 +36,17 @@ ANetNodeInstance * CableNetNode::createInstance( void ) {
}
const char ** CableNetNode::needs( void ) {
return CableNeeds;
}
const char ** CableNetNode::provides( void ) {
return CableProvides;
}
void CableNetNode::setSpecificAttribute( QString & , QString & ) {
}
void CableNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new CableNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<CableNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> )
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 3f8a53f..0c3ead6 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -308,37 +308,36 @@ NodeCollection * EditConnection::connection( void ) {
// Build device tree -> start
void EditConnection::buildFullTree( void ) {
ANetNode * NN;
// toplevel item
MyQCheckListItem * TheTop = new MyQCheckListItem(
Nodes_LV,
NSResources->netNode2Name("fullsetup"),
QCheckListItem::Controller );
TheTop->setOpen( TRUE );
Description_LBL->setText(
NSResources->netNode2Description( "fullsetup" ) );
Nodes_LV->setSelected( TheTop, TRUE );
// find all Nodes that are toplevel nodes -> ie provide
// TCP/IP Connection
- for( QDictIterator<NetNode_t> Iter(NSResources->netNodes());
+ for( QDictIterator<ANetNode> Iter(NSResources->netNodes());
Iter.current();
++Iter ) {
-
- NN = Iter.current()->NetNode;
+ NN = Iter.current();
if( ! NN->isToplevel() ) {
continue;
}
MyQCheckListItem * it = new MyQCheckListItem( TheTop,
NN->name(),
QCheckListItem::RadioButton );
it->setPixmap( 0,
NSResources->getPixmap( NN->pixmapName() )
);
// remember that this node maps to this listitem
Mapping->insert( it, NN );
buildSubTree( it, NN );
}
}
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
index 4415739..e9553a6 100644
--- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
@@ -1,28 +1,24 @@
#include <resources.h>
#include <qpe/qpeapplication.h>
#include <netnode.h>
#include "GPRS_NN.h"
#include "GPRS_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * GPRSNeeds[] =
{ "GPRS",
0
};
static const char * GPRSProvides[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) {
NSResources->addSystemFile(
"pap-secrets", "/etc/ppp/pap-secrets", 0 );
@@ -66,30 +62,17 @@ const char ** GPRSNetNode::provides( void ) {
void GPRSNetNode::setSpecificAttribute( QString & , QString & ) {
}
void GPRSNetNode::saveSpecificAttribute( QTextStream & ) {
}
QStringList GPRSNetNode::properFiles( void ) {
QStringList SL;
SL << "peers";
SL << "chatscripts";
SL << "extra";
return SL;
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new GPRSNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<GPRSNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> )
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 6858157..a1ed686 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -1,25 +1,21 @@
#include "irda_NN.h"
#include "irda_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * IRDANeeds[] =
{ 0
};
static const char * IRDAProvides[] =
{ "line",
0
};
/**
* Constructor, find all of the possible interfaces
*/
IRDANetNode::IRDANetNode() : ANetNode(tr("Infrared link")) {
}
/**
@@ -40,30 +36,17 @@ ANetNodeInstance * IRDANetNode::createInstance( void ) {
}
const char ** IRDANetNode::needs( void ) {
return IRDANeeds;
}
const char ** IRDANetNode::provides( void ) {
return IRDAProvides;
}
void IRDANetNode::setSpecificAttribute( QString & , QString & ) {
}
void IRDANetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new IRDANetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<IRDANetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<IRDANetNode> )
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index fce3d29..520516c 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -1,25 +1,21 @@
#include "lancard_NN.h"
#include "lancard_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * LanCardNeeds[] =
{ 0
};
static const char * LanCardProvides[] =
{ "device",
0
};
/**
* Constructor, find all of the possible interfaces
*/
LanCardNetNode::LanCardNetNode() : ANetNode(tr("LAN card")), NICMACAddresses() {
InstanceCount = 2;
}
@@ -63,30 +59,17 @@ void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) {
}
}
void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) {
TS << "interfacecount="
<< InstanceCount
<< endl;
for( QStringList::Iterator it = NICMACAddresses.begin();
it != NICMACAddresses.end();
++it ) {
TS << "macaddress="
<< (*it)
<< endl;
}
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new LanCardNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<LanCardNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<LanCardNetNode> )
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index c7f6e78..e91b45a 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -1,25 +1,21 @@
#include "modem_NN.h"
#include "modem_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * ModemNeeds[] =
{ "line",
0
};
static const char * ModemProvides[] =
{ "modem",
0
};
/**
* Constructor, find all of the possible interfaces
*/
ModemNetNode::ModemNetNode() : ANetNode(tr("Dialup modem")) {
}
/**
@@ -41,30 +37,17 @@ ANetNodeInstance * ModemNetNode::createInstance( void ) {
}
const char ** ModemNetNode::needs( void ) {
return ModemNeeds;
}
const char ** ModemNetNode::provides( void ) {
return ModemProvides;
}
void ModemNetNode::setSpecificAttribute( QString & , QString & ) {
}
void ModemNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new ModemNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<ModemNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<ModemNetNode> )
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index 82d0c29..2fa31bd 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,28 +1,24 @@
#include <qpe/qpeapplication.h>
#include <resources.h>
#include <netnode.h>
#include "network_NN.h"
#include "network_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * NetworkNeeds[] =
{ "device",
0
};
static const char * NetworkProvides[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
NSResources->addSystemFile(
@@ -83,30 +79,17 @@ short NetworkNetNode::generateFile( SystemFile & SF,
}
const char ** NetworkNetNode::needs( void ) {
return NetworkNeeds;
}
const char ** NetworkNetNode::provides( void ) {
return NetworkProvides;
}
void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
}
void NetworkNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new NetworkNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<NetworkNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> )
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index dca6631..9680a96 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -224,44 +224,44 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
if( NC->isModified() ) {
if( LBI ) {
if( NC->name() != OldName ) {
// find if new name is free
NodeCollection * LCN = NSResources->findConnection(
NC->name() );
if( LCN ) {
QMessageBox::warning(
0,
tr( "In System Config" ),
tr( "Name %1 already exists" ).arg(NC->name())
);
continue; // restart exec
} // else new name
// new name -> remove item
NSResources->removeConnection( OldName );
- NSResources->addConnection( NC );
+ NSResources->addConnection( NC, 0 );
} // else not changed
// must add it here since change will trigger event
Profiles_LB->changeItem( NC->devicePixmap(),
NC->name(),
Profiles_LB->index( LBI )
);
} else {
// new item
int ci = Profiles_LB->count();
- NSResources->addConnection( NC );
+ NSResources->addConnection( NC, 0 );
NC->setNumber( NSResources->assignConnectionNumber() );
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
Profiles_LB->setSelected( ci, TRUE );
}
updateProfileState( LBI );
}
} else {
// cancelled : reset connection
if( LBI ) {
NodeCollection * NC = NSResources->findConnection( LBI->text() );
NC->reassign();
}
}
break;
}
// reenable
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index f8f2d1e..f00e0b3 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -128,86 +128,91 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
return connection()->findNext( this );
}
//
//
// NODECOLLECTION
//
//
NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
IsModified = 0;
Index = -1;
Name="";
IsNew = 1;
CurrentState = Unchecked;
AssignedInterface = 0;
+ Number = -1;
+ Done = 0;
}
-NodeCollection::NodeCollection( QTextStream & TS ) :
+NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) :
QList<ANetNodeInstance>() {
long idx;
- bool InError = 0;
QString S, A, N;
+
+ Number = -1;
+ Done = 0;
IsModified = 0;
Index = -1;
Name="";
IsNew = 0;
AssignedInterface = 0;
CurrentState = Unchecked;
+ Dangling = 0; // by default node collection is ok
+
do {
S = TS.readLine();
if( S.isEmpty() ) {
- if( InError ) {
- // remove all nodes
- clear();
- }
// empty line
break;
}
idx = S.find('=');
S.stripWhiteSpace();
A = S.left( idx );
A.lower();
N = S.mid( idx+1, S.length() );
N.stripWhiteSpace();
N = deQuote( N );
if( A == "name" ) {
Name = N;
} else if( A == "number" ) {
setNumber( N.toLong() );
} else if( A == "node" ) {
ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
Log(( "Find node %s : %p\n", N.latin1(), NNI ));
- if( NNI && ! InError ) {
+ if( NNI ) {
append( NNI );
} else {
// could not find a node type -> collection invalid
- InError = 1;
+ Log(( "Node %s missing -> connection dangling\n",
+ N.latin1() ));
+ // create placeholder for this dangling NNI
+ NNI = new ErrorNNI( N );
+ Dangling = 1;
}
}
} while( 1 );
Log(( "Profile number %s : %d nodes\n",
Name.latin1(), count() ));
}
-
NodeCollection::~NodeCollection( void ) {
}
const QString & NodeCollection::description( void ) {
ANetNodeInstance * NNI = getToplevel();
return (NNI) ? NNI->runtime()->description() : Name;
}
void NodeCollection::append( ANetNodeInstance * NNI ) {
NNI->setConnection( this );
QList<ANetNodeInstance>::append( NNI );
}
void NodeCollection::save( QTextStream & TS ) {
TS << "name=" << quote( Name ) << endl;
@@ -216,49 +221,51 @@ void NodeCollection::save( QTextStream & TS ) {
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
TS << "node=" << NNI->name() << endl;
}
TS << endl;
IsNew = 0;
}
ANetNodeInstance * NodeCollection::getToplevel( void ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
- if( NNI->nodeClass()->isToplevel() )
- break;
- }
+ if( NNI->nodeClass()->isToplevel() ) {
return NNI;
}
+ }
+ return 0;
+}
ANetNodeInstance * NodeCollection::findByName( const QString & S ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
- if( NNI->name() == S )
- break;
- }
+ if( NNI->name() == S ) {
return NNI;
}
+ }
+ return 0;
+}
ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) {
ANetNodeInstance * NNNI;
if( ! NNI )
getToplevel();
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNNI = it.current();
if( NNNI == NNI ) {
++it;
return it.current();
}
}
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 4626381..151d546 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -306,38 +306,80 @@ public:
// get data from GUI and store in node
virtual void commit( void ) = 0;
// returns node specific data -> only useful for 'buddy'
virtual void * data( void ) = 0;
protected :
virtual void setSpecificAttribute( QString & , QString & ) = 0;
virtual void saveSpecificAttribute( QTextStream & ) = 0;
ANetNode * NodeType;
// connection to which this node belongs to
NodeCollection * Connection;
QString Description;
bool IsModified;
+ // true if this nodeinstance was just created (and not
+ // loaded from file
bool IsNew;
int Done;
static long InstanceCounter;
};
+class ErrorNNI: public ANetNodeInstance {
+
+public:
+
+ ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) {
+ setName( _Name.latin1() );
+ }
+
+ RuntimeInfo * runtime( void ) {
+ return 0;
+ }
+
+ // create edit widget under parent
+ QWidget * edit( QWidget * parent ) {
+ return 0;
+ }
+
+ // is given data acceptable
+ QString acceptable( void ) {
+ return QString();
+ }
+
+ // get data from GUI and store in node
+ void commit( void ) {
+ }
+
+ // returns node specific data -> only useful for 'buddy'
+ void * data( void ) {
+ return 0;
+ }
+
+protected :
+
+ void setSpecificAttribute( QString & , QString & ) {
+ }
+
+ void saveSpecificAttribute( QTextStream & ) {
+ }
+};
+
class RuntimeInfo : public QObject {
Q_OBJECT
public :
RuntimeInfo( ANetNodeInstance * TheNNI )
{ NNI = TheNNI; }
//
//
// methods to be overloaded by connection capable
// runtimes
//
//
@@ -455,33 +497,33 @@ signals :
protected :
// set state of this node (private API)
virtual QString setMyState( NodeCollection * NC,
Action_t A,
bool Force = 0 ) = 0;
// connection this runtime info belongs to
ANetNodeInstance * NNI;
};
class NodeCollection : public QList<ANetNodeInstance> {
public :
NodeCollection( void );
- NodeCollection( QTextStream & TS );
+ NodeCollection( QTextStream & TS, bool & Dangling );
~NodeCollection( void );
inline int done( void )
{ return Done; }
inline void setDone( int D )
{ Done = D; }
inline int number( void )
{ return Number; }
inline void setNumber( int i )
{ Number = i; }
inline bool isNew( void )
{ return IsNew; }
inline void setNew( bool N )
{ IsNew = N ; }
inline bool isModified( void )
diff --git a/noncore/settings/networksettings2/networksettings2/netnodeinterface.h b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h
index 34f3bb5..06d1548 100644
--- a/noncore/settings/networksettings2/networksettings2/netnodeinterface.h
+++ b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h
@@ -65,75 +65,85 @@ struct NS2PrivateFactory<Opie::Core::NullType> {
inline static void createPlugins( QList<ANetNode> &) {
}
};
template <class Node, class Tail>
struct NS2PrivateFactory<Opie::Core::Typelist<Node, Tail> > {
inline static void createPlugins( QList<ANetNode> & PNN ) {
NS2PrivateFactory<Node>::createPlugins(PNN);
NS2PrivateFactory<Tail>::createPlugins(PNN);
}
};
+class NetNodeInterface : public QUnknownInterface {
+
+public :
+
+ virtual QRESULT queryInterface( const QUuid& uuid,
+ QUnknownInterface **iface ) = 0;
+
+ virtual void create_plugin( QList<ANetNode> & PNN ) = 0;
+};
+
template<class Node>
-struct NetNodeInterface : public QUnknownInterface {
+struct NetNodeInterface_T : public NetNodeInterface {
QRESULT queryInterface(const QUuid& uuid, QUnknownInterface **iface) {
*iface = 0;
if( uuid == IID_QUnknown )
*iface = this;
else if( uuid == IID_NetworkSettings2 )
*iface = this;
else
return QS_FALSE;
(*iface)->addRef();
return QS_OK;
}
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new Node());
}
Q_REFCOUNT
};
template<class Node, class Tail>
-struct NetNodeInterface<Opie::Core::Typelist<Node, Tail> >
- : public QUnknownInterface {
+struct NetNodeInterface_T<Opie::Core::Typelist<Node, Tail> >
+ : public NetNodeInterface {
QRESULT queryInterface( const QUuid& uuid,
QUnknownInterface **iface) {
*iface = 0;
if( uuid == IID_QUnknown ) *iface = this;
else if( uuid == IID_NetworkSettings2 ) *iface = this;
else return QS_FALSE;
(*iface)->addRef();
return QS_OK;
}
void create_plugin( QList<ANetNode> & PNN ) {
- NS2PrivateFactory<Opie::Core::Typelist<Node,Tail> >::createPlugin( PNN );
+ NS2PrivateFactory<Opie::Core::Typelist<Node,Tail> >::createPlugins( PNN );
}
Q_REFCOUNT
};
#define OPIE_NS2_PLUGIN( factory ) \
Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory) }
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 79d41ea..3479abb 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -12,84 +12,40 @@
#include <opie2/odebug.h>
#include <opie2/opluginloader.h>
#include <qtopia/resource.h>
#include "netnode.h"
#include "resources.h"
#include "netnodeinterface.h"
#define PLUGINDIR "plugins/networksettings2"
#define ICONDIR "/pics/networksettings2/"
// single resources instance
TheNSResources * _NSResources = 0;
TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
- ConnectionsMap() {
+ ConnectionsMap(), DanglingConnectionsMap() {
_NSResources = this;
detectCurrentUser();
// load available netnodes
-#ifdef MYPLUGIN
-
- findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR );
-
- // compile provides and needs lists
- { const char ** NeedsRun;
- QDictIterator<NetNode_t> OuterIt( AllNodeTypes );
- bool Done;
-
- for ( ; OuterIt.current(); ++OuterIt ) {
- // find needs list
- ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList;
- ANetNode::NetNodeList & NNL = *(NNLP);
-
- // must iterate this way to avoid duplication pointers
- for ( QDictIterator<NetNode_t> InnerIt( AllNodeTypes );
- InnerIt.current(); ++InnerIt ) {
- if( InnerIt.current() == OuterIt.current() )
- // avoid recursive
- continue;
-
- const char ** Provides = InnerIt.current()->NetNode->provides();
- NeedsRun = OuterIt.current()->NetNode->needs();
-
- for( ; *NeedsRun; NeedsRun ++ ) {
- const char ** PRun;
- PRun = Provides;
- for( ; *PRun; PRun ++ ) {
- if( strcmp( *PRun, *NeedsRun ) == 0 ) {
- // inner provides what outer needs
- NNL.resize( NNL.size() + 1 );
- NNL[NNL.size()-1] = InnerIt.current()->NetNode;
- Done = 1; // break from 2 loops
- break;
- }
- }
- }
- }
- OuterIt.current()->NetNode->setAlternatives( NNLP );
- }
- }
-
-#else
-
Plugins = 0;
findAvailableNetNodes();
// compile provides and needs lists
{ const char ** NeedsRun;
QDictIterator<ANetNode> OuterIt( AllNodeTypes );
bool Done;
for ( ; OuterIt.current(); ++OuterIt ) {
// find needs list
ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList;
ANetNode::NetNodeList & NNL = *(NNLP);
// must iterate this way to avoid duplication pointers
for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes );
InnerIt.current(); ++InnerIt ) {
@@ -106,59 +62,55 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
PRun = Provides;
for( ; *PRun; PRun ++ ) {
if( strcmp( *PRun, *NeedsRun ) == 0 ) {
// inner provides what outer needs
NNL.resize( NNL.size() + 1 );
NNL[NNL.size()-1] = InnerIt.current();
Done = 1; // break from 2 loops
break;
}
}
}
}
OuterIt.current()->setAlternatives( NNLP );
}
}
-#endif
-
// define built in Node types to Description map
addNodeType( "device", tr( "Network Device" ),
tr( "<p>Devices that can handle IP packets</p>" ) );
addNodeType( "line", tr( "Character device" ),
tr( "<p>Devices that can handle single bytes</p>" ) );
addNodeType( "connection", tr( "IP Connection" ),
tr( "<p>Nodes that provide working IP connections</p>" ) );
addNodeType( "fullsetup", tr( "Connection Profile" ),
tr( "<p>Fully configured connection profile</p>" ) );
addNodeType( "GPRS", tr( "Connection to GPRS device" ),
tr( "<p>Connection to a GPRS capable device</p>" ) );
// get access to the system
TheSystem = new System();
}
TheNSResources::~TheNSResources( void ) {
-#ifndef MYPLUGINS
if( Plugins ) {
delete Plugins;
delete PluginManager;
}
-#endif
delete TheSystem;
}
void TheNSResources::addNodeType( const QString & ID,
const QString & Name,
const QString & Descr ) {
if( NodeTypeNameMap[ID].isEmpty() ) {
NodeTypeNameMap.insert( ID, Name );
NodeTypeDescriptionMap.insert( ID, Descr );
}
}
void TheNSResources::addSystemFile( const QString & ID,
const QString & P,
bool KDI ) {
@@ -166,196 +118,102 @@ void TheNSResources::addSystemFile( const QString & ID,
// new system file
SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
} // else existed
}
void TheNSResources::busy( bool ) {
/*
if( B ) {
ShowWait->show();
qApp->process
} else {
ShowWait->hide();
}
*/
}
-#ifdef MYPLUGIN
-/**
- * Load all modules that are found in the path
- * @param path a directory that is scaned for any plugins that can be loaded
- * and attempts to load them
- */
-void TheNSResources::findAvailableNetNodes(const QString &path){
-
- Log(("Locate plugins in %s\n", path.latin1() ));
- QDir d(path);
- if(!d.exists())
- return;
-
- QString lang = ::getenv("LANG");
-
- // Don't want sym links
- d.setFilter( QDir::Files | QDir::NoSymLinks );
- const QFileInfoList *list = d.entryInfoList();
- QFileInfoListIterator it( *list );
- QFileInfo *fi;
-
- while ( (fi=it.current()) ) {
-
- if( fi->fileName().contains(".so")){
- /* if loaded install translation */
- if( loadNetNode(path + "/" + fi->fileName()) ) {
- Log(( "Loading plugin %s\n", fi->fileName().latin1()));
- QTranslator *trans = new QTranslator(qApp);
- QString fn = QPEApplication::qpeDir()+
- "/i18n/"+lang+"/"+
- fi->fileName().left( fi->fileName().find(".") )+
- ".qm";
-
- if( trans->load( fn ) )
- qApp->installTranslator( trans );
- else
- delete trans;
- } else {
- Log(( "Error loading plugin %s\n", fi->fileName().latin1()));
- }
- }
- ++it;
- }
-}
-
-/**
- * Attempt to load a function and resolve a function.
- * @param pluginFileName - the name of the file in which to attempt to load
- * @param resolveString - function pointer to resolve
- * @return true of loading is successful
- */
-bool TheNSResources::loadNetNode(
- const QString &pluginFileName, const QString &resolveString){
-
- QLibrary *lib = new QLibrary(pluginFileName);
- void * res = lib->resolve(resolveString);
- if( ! res ){
- delete lib;
- return 0;
- }
-
- GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res;
-
- // Try to get an object.
- QList<ANetNode> PNN;
-
- getNetNodeList( PNN );
- if( PNN.isEmpty() ) {
- delete lib;
- return 0;
- }
-
- ANetNode * NNP;
- for( QListIterator<ANetNode> it(PNN);
- it.current();
- ++it ) {
- NetNode_t * NN;
-
- NNP = it.current();
- NN = new NetNode_t;
- NN->NetNode = NNP;
- NN->TheLibrary = lib;
- NN->NodeCountInLib = PNN.count();
-
- // store mapping
- AllNodeTypes.insert( NN->NetNode->name(), NN );
- }
-
- return 1;
-}
-
-#else
-
void TheNSResources::findAvailableNetNodes( void ){
Plugins = new OPluginLoader( "networksettings2" );
Plugins->setAutoDelete( true );
PluginManager = new OPluginManager( Plugins );
PluginManager->load();
if( Plugins->isInSafeMode() ) {
QMessageBox::information(
0,
tr( "Today Error"),
tr( "<qt>The plugin '%1' caused Today to crash."
" It could be that the plugin is not properly"
" installed.<br>Today tries to continue loading"
" plugins.</qt>" )
.arg( PluginManager->crashedPlugin().name()));
}
// Get All Plugins
OPluginLoader::List allplugins = Plugins->filtered();
+ QString lang = ::getenv("LANG");
for( OPluginLoader::List::Iterator it = allplugins.begin();
it != allplugins.end();
++it ) {
// check if this plugin supports the proper interface
NetNodeInterface * interface =
Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 );
if( ! interface ) {
Log(( "Plugin %s from %s does not support proper interface\n",
- it->name().latin1(), it->path().latin1() ));
+ (*it).name().latin1(), (*it).path().latin1() ));
continue;
}
// add the nodes in this plugin to the dictionary
{ QList<ANetNode> PNN;
interface->create_plugin( PNN );
if( PNN.isEmpty() ) {
Log(( "Plugin %s from %s does offer any nodes\n",
- it->name().latin1(), it->path().latin1() ));
+ (*it).name().latin1(), (*it).path().latin1() ));
delete interface;
continue;
}
// merge this node with global node
for( QListIterator<ANetNode> it(PNN);
it.current();
++it ) {
- AllNodeTypes.insert( it->current()->name(), it->current() );
+ AllNodeTypes.insert( it.current()->name(), it.current() );
}
}
// load the translation
QTranslator *trans = new QTranslator(qApp);
QString fn = QPEApplication::qpeDir()+
- "/i18n/"+lang+"/"+ it->name() + ".qm";
+ "/i18n/"+lang+"/"+ (*it).name() + ".qm";
if( trans->load( fn ) )
qApp->installTranslator( trans );
else
delete trans;
}
}
-#endif
-
// used to find unique connection number
int TheNSResources::assignConnectionNumber( void ) {
bool found = 1;
for( int trial = 0; ; trial ++ ) {
found = 1;
for( QDictIterator<NodeCollection> it(ConnectionsMap);
it.current();
++it ) {
if( it.current()->number() == trial ) {
found = 0;
break;
}
}
if( found ) {
Log(("Assign profile number %d\n", trial ));
@@ -374,60 +232,71 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) {
}
return ( P.isNull() ) ? QPixmap() : P;
}
QString TheNSResources::tr( const char * s ) {
return qApp->translate( "resource", s );
}
const QString & TheNSResources::netNode2Name( const char * s ) {
return NodeTypeNameMap[s];
}
const QString & TheNSResources::netNode2Description( const char * s ) {
return NodeTypeDescriptionMap[s];
}
-void TheNSResources::addConnection( NodeCollection * NC ) {
+void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) {
ANetNodeInstance * NNI;
+ if( Dangling ) {
+ DanglingConnectionsMap.insert( NC->name(), NC );
+ } else {
ConnectionsMap.insert( NC->name(), NC );
+ }
+
// add (new) nodes to NodeList
for( QListIterator<ANetNodeInstance> it(*NC);
it.current();
++it ) {
NNI = it.current();
if( findNodeInstance( NNI->name() ) == 0 ) {
// new item
addNodeInstance( NNI );
}
}
}
void TheNSResources::removeConnection( const QString & N ) {
NodeCollection * NC = findConnection( N );
if( ! NC )
return;
// delete netnodes in this connection
ANetNodeInstance * NNI;
for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) {
removeNodeInstance( NNI->name() );
}
+ if( ConnectionsMap.find( N ) ) {
ConnectionsMap.remove( N );
+ } else {
+ DanglingConnectionsMap.remove( N );
+ }
+
}
+// dangling connections are filtered out
NodeCollection * TheNSResources::findConnection( const QString & S ) {
return ConnectionsMap[ S ];
}
NodeCollection * TheNSResources::getConnection( int nr ) {
for( QDictIterator<NodeCollection> it(ConnectionsMap);
it.current();
++it ) {
if( it.current()->number() == nr ) {
return it.current();
}
}
return 0;
}
/*
void TheNSResources::renumberConnections( void ) {
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 421a433..b27cda1 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -25,159 +25,129 @@ typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN );
class CurrentQPEUser {
public :
CurrentQPEUser() : UserName(), HomeDir(), EnvList() {}
inline bool known( void )
{ return ! HomeDir.isEmpty() && ! UserName.isEmpty(); }
QString UserName;
QString HomeDir;
int Uid;
int Gid;
QArray<char *> EnvList;
};
-#ifdef MYPLUGIN
-
-typedef struct NetNode_S {
- ANetNode * NetNode;
- QLibrary * TheLibrary;
- long NodeCountInLib;
-} NetNode_t;
-typedef QDict<NetNode_t> Name2NetNode_t;
-
-#else
-
typedef QDict<ANetNode> Name2NetNode_t;
-
-#endif
-
typedef QDict<ANetNodeInstance > Name2Instance_t;
typedef QDict<NodeCollection> Name2Connection_t;
typedef QDict<SystemFile> Name2SystemFile_t;
class TheNSResources {
public :
TheNSResources( void );
~TheNSResources( );
// give busy feedback
void busy( bool B );
System & system()
{ return *TheSystem; }
int assignConnectionNumber(void);
QPixmap getPixmap( const QString & Name );
Name2NetNode_t & netNodes( void )
{ return AllNodeTypes; }
bool netNodeExists( const QString & X )
{ return AllNodeTypes.find(X)!=0; }
-#ifdef MYPLUGIN
- ANetNode * findNetNode( const QString & N )
- { NetNode_t * NNT = AllNodeTypes.find(N);
- return (NNT) ? NNT->NetNode : 0;
- }
-#else
ANetNode * findNetNode( const QString & N )
{ return AllNodeTypes.find(N);
}
-#endif
// define new plugin (=node)
void addNodeType( const QString & ID,
const QString & LongName,
const QString & Description );
Name2SystemFile_t & systemFiles( void )
{ return SystemFiles; }
void addSystemFile( const QString & ID,
const QString & P,
bool KDI );
ANetNodeInstance * createNodeInstance( const QString & S )
- { ANetNodeInstance * NNI = 0;
- printf( "Find node type %s\n", S.latin1() );
-#ifdef MYPLUGIN
- NetNode_t * NNT = AllNodeTypes[S];
- if( ! NNT ) {
- return 0;
- }
- NNI = NNT->NetNode->createInstance();
-#else
- ANetNode * NNT = AllNodeTypes[S];
- if( ! NNT ) {
+ { ANetNode * NN = findNetNode( S );
+
+ Log(( "Find node type %s : %p\n", S.latin1(), NN ));
+
+ if( NN == 0 )
+ // type of this instance not found
return 0;
- }
- NNI = NNT->createInstance();
-#endif
+
+ ANetNodeInstance * NNI = NN->createInstance();
NNI->initialize();
return NNI;
}
Name2Instance_t & netNodeInstances( void )
{ return AllNodes; }
void addNodeInstance( ANetNodeInstance * I )
{ AllNodes.insert( I->name(), I ); }
void removeNodeInstance( const QString & N )
{ AllNodes.remove( N );}
ANetNodeInstance * findNodeInstance( const QString & S )
{ return AllNodes[S]; }
const QString & netNode2Name( const char * Type );
const QString & netNode2Description( const char * Type );
- void addConnection( NodeCollection * NC );
+ void addConnection( NodeCollection * NC, bool Dangling );
void removeConnection( const QString & N );
NodeCollection * findConnection( const QString & N );
NodeCollection * getConnection( int nr );
Name2Connection_t & connections( void )
{ return ConnectionsMap; }
+ Name2Connection_t & danglingConnections( void )
+ { return ConnectionsMap; }
inline bool userKnown( void )
{ return CurrentUser.known(); }
CurrentQPEUser & currentUser( void )
{ return CurrentUser; }
private :
void detectCurrentUser( void );
QString tr( const char * path );
-#ifdef MYPLUGIN
- void findAvailableNetNodes( const QString &path );
- bool loadNetNode(
- const QString &pluginFileName,
- const QString &resolveString = "create_plugin");
-#else
void findAvailableNetNodes( void );
-#endif
QMap< QString, QString> NodeTypeNameMap;
QMap< QString, QString> NodeTypeDescriptionMap;
+ // list of connections that are valid
Name2Connection_t ConnectionsMap;
+ // list of connection configurations that are not valid
+ // e.g. because plugins are missing
+ Name2Connection_t DanglingConnectionsMap;
System * TheSystem;
Name2SystemFile_t SystemFiles;
// all node type classes
Name2NetNode_t AllNodeTypes;
// all nodes
Name2Instance_t AllNodes;
CurrentQPEUser CurrentUser;
-#ifndef MYPLUGIN
Opie::Core::OPluginLoader * Plugins;
Opie::Core::OPluginManager * PluginManager;
-#endif
};
extern TheNSResources * _NSResources;
#define NSResources _NSResources
#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 698a941..d76353a 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -103,167 +103,184 @@ void NetworkSettingsData::loadSettings( void ) {
<EMPTYLINE>
*/
while( ! TS.atEnd() ) {
S = Line = TS.readLine();
if ( S.isEmpty() || S[0] != '[' )
continue;
S = S.mid( 1, S.length()-2 );
if( ! NSResources ) {
continue;
}
if( S == "connection" ) {
// load connections -> collections of nodes
- NodeCollection * NC = new NodeCollection( TS );
- NSResources->addConnection( NC );
+ bool Dangling;
+ NodeCollection * NC = new NodeCollection( TS, Dangling );
+ NSResources->addConnection( NC, Dangling );
} else {
ANetNode * NN = 0;
ANetNodeInstance* NNI = 0;
if( S.startsWith( "nodetype " ) ) {
S = S.mid( 9, S.length()-9 );
S = deQuote(S);
// try to find netnode
NN = NSResources->findNetNode( S );
} else {
// try to find instance
NNI = NSResources->createNodeInstance( S );
}
if( NN == 0 && NNI == 0 ) {
LeftOvers.append( Line );
+ do {
+ Line = TS.readLine();
+ // store even delimiter
+ LeftOvers.append( Line );
+ } while ( ! Line.isEmpty() );
+
+ //next section
+ continue;
}
+ // read entries of this section
do {
S = Line = TS.readLine();
- if( NN || NNI ) {
if( S.isEmpty() ) {
// empty line
break;
}
idx = S.find( '=' );
if( idx > 0 ) {
Attr = S.left( idx );
Value = S.mid( idx+1, S.length() );
} else {
Value="";
Attr = S;
}
Value.stripWhiteSpace();
Attr.stripWhiteSpace();
Attr.lower();
// dequote Attr
Value = deQuote(Value);
if( NN ) {
// set the attribute
NN->setAttribute( Attr, Value );
} else {
// set the attribute
NNI->setAttribute( Attr, Value );
}
- } else {
- LeftOvers.append( Line );
- // add empty line too as delimiter
- if( S.isEmpty() ) {
- // empty line
- break;
- }
- }
} while( 1 );
if( NNI ) {
// loading from file -> exists
Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI ));
NNI->setNew( FALSE );
NSResources->addNodeInstance( NNI );
}
+
if( NN ) {
Log( ( "Node %s : %p\n", NN->name(), NN ) );
}
}
}
} while( 0 );
}
QString NetworkSettingsData::saveSettings( void ) {
QString ErrS = "";
if( ! isModified() )
return ErrS;
QString S;
QFile F( CfgFile + ".bup" );
Log( ( "Saving settings to %s\n", CfgFile.latin1() ));
if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
ErrS = qApp->translate( "NetworkSettings",
"<p>Could not save setup to \"%1\" !</p>" ).
arg(CfgFile);
// problem
return ErrS;
}
QTextStream TS( &F );
- // save leftovers
- for ( QStringList::Iterator it = LeftOvers.begin();
- it != LeftOvers.end(); ++it ) {
- TS << (*it) << endl;
- }
-
// save global configs
- for( QDictIterator<NetNode_t> it( NSResources->netNodes() );
+ for( QDictIterator<ANetNode> it( NSResources->netNodes() );
it.current();
++it ) {
TS << "[nodetype "
- << quote( QString( it.current()->NetNode->name() ) )
+ << quote( QString( it.current()->name() ) )
<< "]"
<< endl;
- it.current()->NetNode->saveAttributes( TS );
+ it.current()->saveAttributes( TS );
TS << endl;
}
- { Name2Connection_t & M = NSResources->connections();
- ANetNodeInstance * NNI;
+ // save leftovers
+ for ( QStringList::Iterator it = LeftOvers.begin();
+ it != LeftOvers.end(); ++it ) {
+ TS << (*it) << endl;
+ }
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
- it.current();
- ++it ) {
- // all nodes in those connections
- for( QListIterator<ANetNodeInstance> nit(*(it.current()));
+ // save all netnode instances
+ { ANetNodeInstance * NNI;
+ for( QDictIterator<ANetNodeInstance> nit(
+ NSResources->netNodeInstances());
nit.current();
++nit ) {
// header
NNI = nit.current();
TS << '['
<< QString(NNI->nodeClass()->name())
<< ']'
<< endl;
NNI->saveAttributes( TS );
TS << endl;
}
+ }
+ // good connections
+ { Name2Connection_t & M = NSResources->connections();
+
+ // for all connections
+ for( QDictIterator<NodeCollection> it(M);
+ it.current();
+ ++it ) {
+ TS << "[connection]" << endl;
+ it.current()->save(TS);
+ }
+ }
+
+ // save dangling connections
+ { Name2Connection_t & M = NSResources->danglingConnections();
+
+ // for all connections
+ for( QDictIterator<NodeCollection> it(M);
+ it.current();
+ ++it ) {
TS << "[connection]" << endl;
it.current()->save(TS);
}
}
QDir D(".");
D.rename( CfgFile + ".bup", CfgFile );
//
// proper files AND system files regenerated
//
for( QDictIterator<NodeCollection> it(NSResources->connections());
it.current();
++it ) {
@@ -276,40 +293,41 @@ QString NetworkSettingsData::saveSettings( void ) {
QString NetworkSettingsData::generateSettings( void ) {
QString S = "";
Name2SystemFile_t & SFM = NSResources->systemFiles();
Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
ANetNodeInstance * NNI;
ANetNodeInstance * FirstWithData;
RuntimeInfo * CurDev;
ANetNode * NN, * CurDevNN = 0;
long NoOfDevs;
long DevCtStart;
bool needToGenerate;
// regenerate system files
Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
- for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
+ for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
nnit.current();
++nnit ) {
- { QStringList SL;
bool FirstItem = 1;
bool Generated = 0;
- CurDevNN = nnit.current()->NetNode;
+ CurDevNN = nnit.current();
+
+ { QStringList SL;
SL = CurDevNN->properFiles();
for ( QStringList::Iterator it = SL.begin();
it != SL.end();
++it ) {
Generated = 0;
FirstItem = 1;
// iterate over NNI's of this class
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
if( nniit.current()->nodeClass() != CurDevNN )
// different class
continue;
@@ -382,62 +400,62 @@ QString NetworkSettingsData::generateSettings( void ) {
}
}
}
}
//
// generate all registered files
//
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SystemFile * SF;
SF = sfit.current();
// reset all
- for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
+ for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
nnit.current();
++nnit ) {
- nnit.current()->NetNode->setDone(0);
+ nnit.current()->setDone(0);
}
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
nniit.current()->setDone(0);
}
for( QDictIterator<NodeCollection> ncit(M);
ncit.current();
++ncit ) {
ncit.current()->setDone(0);
}
Log( ( "Generating system file %s\n", SF->name().latin1() ));
needToGenerate = 0;
// are there netnodes that have instances and need
// to write data in this system file ?
- for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
+ for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
! needToGenerate && nnit.current();
++nnit ) {
- NN = nnit.current()->NetNode;
+ NN = nnit.current();
if( NN->hasDataForFile( *SF ) ) {
// netnode can have data
// are there instances of this node ?
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
! needToGenerate && nniit.current();
++nniit ) {
if( nniit.current()->nodeClass() == NN ) {
// yes
Log(("Node %s has data\n",
nniit.current()->name() ));
needToGenerate = 1;
break;
}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index bd13ab9..8c15e9c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,28 +1,24 @@
#include <qfile.h>
#include <resources.h>
#include <qtextstream.h>
#include "ppp_NN.h"
#include "ppp_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
QStringList * PPPNetNode::ProperFiles = 0;
static const char * PPPNeeds[] =
{ "modem",
0
};
static const char * PPPProvides[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
@@ -71,30 +67,17 @@ QStringList PPPNetNode::properFiles( void ) {
bool PPPNetNode::hasDataForFile( SystemFile & S ) {
return S.name() == "pap-secrets" ||
S.name() == "chap-secrets" ;
}
QString PPPNetNode::genNic( long NicNr ) {
QString S;
return S.sprintf( "ppp%ld", NicNr );
}
void PPPNetNode::setSpecificAttribute( QString & , QString & ) {
}
void PPPNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new PPPNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<PPPNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> )
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 6028ea5..1e6912e 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,26 +1,22 @@
#include <resources.h>
#include "profile_NN.h"
#include "profile_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * ProfileNeeds[] =
{ "connection",
0
};
static const char * ProfileProvides[] =
{ "fullsetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
NSResources->addSystemFile(
"interfaces", "/etc/network/interfaces", 1 );
@@ -46,30 +42,17 @@ ANetNodeInstance * ProfileNetNode::createInstance( void ) {
}
const char ** ProfileNetNode::needs( void ) {
return ProfileNeeds;
}
const char ** ProfileNetNode::provides( void ) {
return ProfileProvides;
}
void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
}
void ProfileNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new ProfileNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<ProfileNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> )
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,26 +1,22 @@
#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 );
}
@@ -48,30 +44,17 @@ const char ** USBNetNode::needs( void ) {
}
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,26 +1,28 @@
#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());
@@ -51,52 +53,45 @@ State_t USBRun::detectState( void ) {
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
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 6dd5332..96e9df2 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,25 +1,21 @@
#include "vpn_NN.h"
#include "vpn_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * VPNNeeds[] =
{ 0
};
static const char * VPNProvides[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) {
}
/**
* Delete any interfaces that we own.
@@ -40,30 +36,17 @@ ANetNodeInstance * VPNNetNode::createInstance( void ) {
}
const char ** VPNNetNode::needs( void ) {
return VPNNeeds;
}
const char ** VPNNetNode::provides( void ) {
return VPNProvides;
}
void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
}
void VPNNetNode::saveSpecificAttribute( QTextStream & ) {
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new VPNNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<VPNNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> )
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index c56da06..f7745be 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -1,26 +1,22 @@
#include <resources.h>
#include "wlan_NN.h"
#include "wlan_NNI.h"
-#ifndef MYPLUGIN
-
#include "netnodeinterface.h"
-#endif
-
static const char * WLanNeeds[] =
{ 0
};
static const char * WLanProvides[] =
{ "device",
0
};
/**
* Constructor, find all of the possible interfaces
*/
WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) {
NSResources->addSystemFile(
"interfaces", "/etc/network/interfaces", 1 );
InstanceCount = 2;
@@ -56,30 +52,17 @@ QString WLanNetNode::genNic( long nr ) {
QString S;
return S.sprintf( "wlan%ld", nr );
}
void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) {
if( A == "interfacecount" ) {
InstanceCount = V.toLong();
}
}
void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) {
TS << "interfacecount="
<< InstanceCount
<< endl;
}
-#ifdef MYPLUGIN
-
-extern "C" {
-void create_plugin( QList<ANetNode> & PNN ) {
- PNN.append( new WLanNetNode() );
-}
-
-#else
-
-OPIE_NS2_PLUGIN( NetNodeInterface<WLanNetNode> )
-
-#endif
-
-}
+OPIE_NS2_PLUGIN( NetNodeInterface_T<WLanNetNode> )