author | wimpie <wimpie> | 2005-01-07 01:19:13 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-07 01:19:13 (UTC) |
commit | 7af7203a51ddcf85f9f60e39157fcad21f7d9e34 (patch) (side-by-side diff) | |
tree | 49829585a0100a5a741d55424f86be39c01d3150 | |
parent | a8e5ecd107a79f940d8a99d4a77071606a3a932f (diff) | |
download | opie-7af7203a51ddcf85f9f60e39157fcad21f7d9e34.zip opie-7af7203a51ddcf85f9f60e39157fcad21f7d9e34.tar.gz opie-7af7203a51ddcf85f9f60e39157fcad21f7d9e34.tar.bz2 |
First implementation of plugins
THIS VERSION DOES NOT COMPILE
45 files changed, 576 insertions, 77 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro index 2e3b5bb..053a6cb 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro +++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = bluetoothBNEP_NN.h \ bluetoothBNEP_NNI.h \ diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp index ee3e92b..5e4d951 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp @@ -2,6 +2,12 @@ #include "bluetoothBNEP_NNI.h" #include "bluetoothRFCOMM_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + // // // BLUETOOTH PAN/NAP node @@ -69,10 +75,20 @@ void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { << 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 + } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp index 9d4ae97..5c937a1 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp @@ -4,6 +4,10 @@ #include <resources.h> #include "bluetoothBNEPrun.h" +using Opietooth2::OTGateway; +using Opietooth2::OTPANConnection; +using Opietooth2::PANConnectionVector; + BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, BluetoothBNEPData & D ) : RuntimeInfo( NNI ), diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index a05a7a2..8551a2e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -2,7 +2,6 @@ #include "bluetoothBNEPdata.h" #include <OTGateway.h> -using namespace Opietooth2; class BluetoothBNEPRun : public RuntimeInfo { @@ -30,6 +29,6 @@ private : bool hasFreePANConnection( bool Grab = 0 ); BluetoothBNEPData & Data; - OTGateway * OT; - QRegExp Pat; + Opietooth2::OTGateway * OT; + QRegExp Pat; }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h index 9ad8f2a..fe474fc 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h @@ -2,7 +2,6 @@ #include "bluetoothRFCOMMGUI.h" #include <Opietooth.h> -using namespace Opietooth2; class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { @@ -15,8 +14,8 @@ public : void showData( BluetoothRFCOMMData & Data ); bool commit( BluetoothRFCOMMData & Data ); - bool Modified; - OTGateway * OT; + bool Modified; + Opietooth2::OTGateway * OT; public slots : diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp index 1e91ed1..ef6878a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp @@ -4,7 +4,9 @@ #include <OTGateway.h> #include "bluetoothRFCOMMrun.h" -using namespace Opietooth2; +using Opietooth2::OTGateway; +using Opietooth2::OTDevice; +using Opietooth2::OTDeviceAddress; BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { if( OT ) { diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index 24e3dae..5a31a94 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -2,7 +2,6 @@ #include "bluetoothRFCOMMdata.h" #include <OTGateway.h> -using namespace Opietooth2; class BluetoothRFCOMMRun : public RuntimeInfo { @@ -27,7 +26,7 @@ private : int deviceNrOfConnection( void ); RFCOMMChannel * getChannel( void ); - BluetoothRFCOMMData * Data; + BluetoothRFCOMMData * Data; Opietooth2::OTGateway * OT; - int DeviceNr; // cached from detection + int DeviceNr; // cached from detection }; diff --git a/noncore/settings/networksettings2/cable/cable.pro b/noncore/settings/networksettings2/cable/cable.pro index 8a046b7..660f95e 100644 --- a/noncore/settings/networksettings2/cable/cable.pro +++ b/noncore/settings/networksettings2/cable/cable.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = cable_NN.h \ cable_NNI.h \ diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index dc4205c..20299e4 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -1,6 +1,12 @@ #include "cable_NN.h" #include "cable_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * CableNeeds[] = { 0 }; @@ -47,8 +53,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/gprs/GPRS.pro b/noncore/settings/networksettings2/gprs/GPRS.pro index 7818415..480c872 100644 --- a/noncore/settings/networksettings2/gprs/GPRS.pro +++ b/noncore/settings/networksettings2/gprs/GPRS.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = GPRS_NN.h \ GPRS_NNI.h \ diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp index 5393324..4415739 100644 --- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp +++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp @@ -4,6 +4,12 @@ #include "GPRS_NN.h" #include "GPRS_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * GPRSNeeds[] = { "GPRS", 0 @@ -73,8 +79,17 @@ QStringList GPRSNetNode::properFiles( void ) { return SL; } +#ifdef MYPLUGIN + extern "C" { void create_plugin( QList<ANetNode> & PNN ) { PNN.append( new GPRSNetNode() ); } + +#else + +OPIE_NS2_PLUGIN( NetNodeInterface<GPRSNetNode> ) + +#endif + } diff --git a/noncore/settings/networksettings2/irda/irda.pro b/noncore/settings/networksettings2/irda/irda.pro index 4613abe..87f7a62 100644 --- a/noncore/settings/networksettings2/irda/irda.pro +++ b/noncore/settings/networksettings2/irda/irda.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = irda_NN.h \ irda_NNI.h \ diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 485cad3..6858157 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp @@ -1,6 +1,12 @@ #include "irda_NN.h" #include "irda_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * IRDANeeds[] = { 0 }; @@ -47,8 +53,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/lancard/lancard.pro b/noncore/settings/networksettings2/lancard/lancard.pro index 6f04e01..05f0fa0 100644 --- a/noncore/settings/networksettings2/lancard/lancard.pro +++ b/noncore/settings/networksettings2/lancard/lancard.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = lancard_NN.h \ lancard_NNI.h \ diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index e36f757..fce3d29 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp @@ -1,6 +1,12 @@ #include "lancard_NN.h" #include "lancard_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * LanCardNeeds[] = { 0 }; @@ -70,8 +76,17 @@ void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { } } +#ifdef MYPLUGIN + extern "C" { void create_plugin( QList<ANetNode> & PNN ) { PNN.append( new LanCardNetNode() ); } + +#else + +OPIE_NS2_PLUGIN( NetNodeInterface<LanCardNetNode> ) + +#endif + } diff --git a/noncore/settings/networksettings2/modem/modem.pro b/noncore/settings/networksettings2/modem/modem.pro index 25e29d4..4511e07 100644 --- a/noncore/settings/networksettings2/modem/modem.pro +++ b/noncore/settings/networksettings2/modem/modem.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = modem_NN.h \ modem_NNI.h \ diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index 06f417c..c7f6e78 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp @@ -1,6 +1,12 @@ #include "modem_NN.h" #include "modem_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * ModemNeeds[] = { "line", 0 @@ -48,8 +54,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/network/network.pro b/noncore/settings/networksettings2/network/network.pro index 05df007..5ca78b9 100644 --- a/noncore/settings/networksettings2/network/network.pro +++ b/noncore/settings/networksettings2/network/network.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = network_NN.h \ network_NNI.h \ diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 23b3d44..82d0c29 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -4,6 +4,12 @@ #include "network_NN.h" #include "network_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * NetworkNeeds[] = { "device", 0 @@ -90,8 +96,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/networksettings2/netnodeinterface.h b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h new file mode 100644 index 0000000..34f3bb5 --- a/dev/null +++ b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h @@ -0,0 +1,139 @@ +/* + This file is part of the Opie Project + + Copyright (C) 2005 Holger Hans Peter Freyther <freyther@handhelds.org> + =. + .=l. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef ANET_NODE_INTERFACE_H +#define ANET_NODE_INTERFACE_H + +#include <opie2/oapplicationfactory.h> +#include <qpe/qcom.h> + +// {A215A785-FB73-4F74-84B0-053BCC77DB87} +#ifndef IID_NetworkSettings2 + +#define IID_NetworkSettings2 QUuid( 0xa215a785, 0xfb73, 0x4f74, 0x84, 0xb0, 0x05, 0x3b, 0xcc, 0x77, 0xdb, 0x87) + +#endif + + + +/** + * Multiple Types + */ +template <class Node > +struct NS2PrivateFactory { + + inline static void createPlugins( QList<ANetNode> & PNN) { + PNN.append( new Node()); + } + +}; + +/* + * Stop recursion here + */ +template <> +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); + } + +}; + +template<class Node> +struct NetNodeInterface : public QUnknownInterface { + + 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 { + + 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 ); + } + + 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 50fb15a..79d41ea 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -4,13 +4,19 @@ #include <pwd.h> #include <qpixmap.h> #include <qdir.h> +#include <qmessagebox.h> + #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> + #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/" @@ -26,6 +32,9 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), detectCurrentUser(); // load available netnodes + +#ifdef MYPLUGIN + findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); // compile provides and needs lists @@ -66,6 +75,52 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), } } +#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 ) { + + if( InnerIt.current() == OuterIt.current() ) + // avoid recursive + continue; + + const char ** Provides = InnerIt.current()->provides(); + NeedsRun = OuterIt.current()->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(); + 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>" ) ); @@ -84,7 +139,15 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), } TheNSResources::~TheNSResources( void ) { + +#ifndef MYPLUGINS + if( Plugins ) { + delete Plugins; + delete PluginManager; + } +#endif delete TheSystem; + } void TheNSResources::addNodeType( const QString & ID, @@ -116,6 +179,7 @@ void TheNSResources::busy( bool ) { */ } +#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 @@ -160,27 +224,6 @@ void TheNSResources::findAvailableNetNodes(const QString &path){ } } -// 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 )); - return trial; - } - } -} - /** * Attempt to load a function and resolve a function. * @param pluginFileName - the name of the file in which to attempt to load @@ -227,6 +270,100 @@ bool TheNSResources::loadNetNode( 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(); + + 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() )); + 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() )); + delete interface; + continue; + } + + // merge this node with global node + for( QListIterator<ANetNode> it(PNN); + it.current(); + ++it ) { + AllNodeTypes.insert( it->current()->name(), it->current() ); + } + } + + // load the translation + QTranslator *trans = new QTranslator(qApp); + QString fn = QPEApplication::qpeDir()+ + "/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 )); + return trial; + } + } +} + QPixmap TheNSResources::getPixmap( const QString & QS ) { QPixmap P; QString S("networksettings2/"); diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 5d90286..421a433 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h @@ -14,13 +14,14 @@ class QPixmap; class ANetNode; class ANetNodeInstance; -typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); +namespace Opie { + namespace Core { + class OPluginLoader; + class OPluginManager; + } +} -typedef struct NetNode_S { - ANetNode * NetNode; - QLibrary * TheLibrary; - long NodeCountInLib; -} NetNode_t; +typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); class CurrentQPEUser { @@ -37,7 +38,21 @@ public : 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; @@ -62,11 +77,16 @@ public : { 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, @@ -81,11 +101,19 @@ public : 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 ) { + return 0; + } + NNI = NNT->createInstance(); +#endif NNI->initialize(); return NNI; } @@ -118,24 +146,35 @@ 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; - Name2Connection_t ConnectionsMap; - System * TheSystem; - Name2SystemFile_t SystemFiles; + Name2Connection_t ConnectionsMap; + System * TheSystem; + Name2SystemFile_t SystemFiles; // all node type classes - Name2NetNode_t AllNodeTypes; + Name2NetNode_t AllNodeTypes; // all nodes - Name2Instance_t AllNodes; + Name2Instance_t AllNodes; + + CurrentQPEUser CurrentUser; + +#ifndef MYPLUGIN + Opie::Core::OPluginLoader * Plugins; + Opie::Core::OPluginManager * PluginManager; +#endif - CurrentQPEUser CurrentUser; }; extern TheNSResources * _NSResources; diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.h b/noncore/settings/networksettings2/opietooth2/OTDevice.h index cf1c4b6..09de7ee 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDevice.h +++ b/noncore/settings/networksettings2/opietooth2/OTDevice.h @@ -16,8 +16,8 @@ class QTimerEvent; namespace Opie { namespace Core { class OProcess; - }; -}; + } +} namespace Opietooth2 { @@ -111,6 +111,6 @@ namespace Opietooth2 { OTGateway * OT; bool NeedsAttach; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h index 50f28fc..8395f37 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h +++ b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h @@ -103,6 +103,6 @@ protected: }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h index f249cf7..b54ffdf 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDriver.h +++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h @@ -228,5 +228,5 @@ private: OTGateway * OT; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.h b/noncore/settings/networksettings2/opietooth2/OTGateway.h index a47cefb..d97ef35 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.h +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.h @@ -195,6 +195,6 @@ private : PeerVector AllPeers; LinkKeyArray AllKeys; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTHCISocket.h b/noncore/settings/networksettings2/opietooth2/OTHCISocket.h index d508078..a004989 100644 --- a/noncore/settings/networksettings2/opietooth2/OTHCISocket.h +++ b/noncore/settings/networksettings2/opietooth2/OTHCISocket.h @@ -111,6 +111,6 @@ private slots: }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTIcons.h b/noncore/settings/networksettings2/opietooth2/OTIcons.h index 966ed24..ee10831 100644 --- a/noncore/settings/networksettings2/opietooth2/OTIcons.h +++ b/noncore/settings/networksettings2/opietooth2/OTIcons.h @@ -49,6 +49,6 @@ private: UUIDVector Networks; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.h b/noncore/settings/networksettings2/opietooth2/OTInquiry.h index 2682499..f7bdeec 100644 --- a/noncore/settings/networksettings2/opietooth2/OTInquiry.h +++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.h @@ -174,5 +174,5 @@ private slots: }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.h b/noncore/settings/networksettings2/opietooth2/OTPeer.h index 9cd0dc7..c09af15 100644 --- a/noncore/settings/networksettings2/opietooth2/OTPeer.h +++ b/noncore/settings/networksettings2/opietooth2/OTPeer.h @@ -130,6 +130,6 @@ private: long ProbeTimeout; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h index 86b5623..e79e33d 100644 --- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h +++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h @@ -135,6 +135,6 @@ private: }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPService.h b/noncore/settings/networksettings2/opietooth2/OTSDPService.h index 21d7344..4831df0 100644 --- a/noncore/settings/networksettings2/opietooth2/OTSDPService.h +++ b/noncore/settings/networksettings2/opietooth2/OTSDPService.h @@ -70,6 +70,6 @@ private: QArray<AttributeEntry> attributeList; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/OTUUID.h b/noncore/settings/networksettings2/opietooth2/OTUUID.h index 97df114..aebd9b9 100644 --- a/noncore/settings/networksettings2/opietooth2/OTUUID.h +++ b/noncore/settings/networksettings2/opietooth2/OTUUID.h @@ -54,5 +54,5 @@ public : uint64_t hi; uint64_t lo; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.h b/noncore/settings/networksettings2/opietooth2/Opietooth.h index e66787f..f077dd7 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.h +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.h @@ -11,9 +11,9 @@ namespace Opie { class OLedBox; - }; + } -}; +} #include <OTSniffGUI.h> namespace Opietooth2 { @@ -51,7 +51,7 @@ private : OTGateway * OT; MyProcess * HciDump; }; -}; +} #include <OTPairingGUI.h> @@ -80,7 +80,7 @@ private : OTIcons * Icons; OTGateway * OT; }; -}; +} #include <OTScanGUI.h> @@ -158,7 +158,7 @@ private : OTPeer * SelectedPeer; int SelectedChannel; }; -}; +} #include <OTManageGUI.h> namespace Opietooth2 { @@ -196,7 +196,7 @@ private : OTGateway * OT; OTInquiry * Scanning; }; -}; +} #include <OTMainGUI.h> @@ -234,5 +234,5 @@ private : OTGateway * OT; QDialog * SnifWindow; }; -}; +} #endif diff --git a/noncore/settings/networksettings2/ppp/ppp.pro b/noncore/settings/networksettings2/ppp/ppp.pro index dd3408c..10d0f1b 100644 --- a/noncore/settings/networksettings2/ppp/ppp.pro +++ b/noncore/settings/networksettings2/ppp/ppp.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = ppp_NN.h \ ppp_NNI.h \ diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index 51ba27d..bd13ab9 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -4,6 +4,12 @@ #include "ppp_NN.h" #include "ppp_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + QStringList * PPPNetNode::ProperFiles = 0; static const char * PPPNeeds[] = @@ -78,8 +84,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/profile/profile.pro b/noncore/settings/networksettings2/profile/profile.pro index f980034..4db7a5d 100644 --- a/noncore/settings/networksettings2/profile/profile.pro +++ b/noncore/settings/networksettings2/profile/profile.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = profile_NN.h \ profile_NNI.h \ diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index b7d8aa0..6028ea5 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp @@ -2,6 +2,12 @@ #include "profile_NN.h" #include "profile_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * ProfileNeeds[] = { "connection", 0 @@ -53,8 +59,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/usb/usb.pro b/noncore/settings/networksettings2/usb/usb.pro index 37c1bde..d9890b6 100644 --- a/noncore/settings/networksettings2/usb/usb.pro +++ b/noncore/settings/networksettings2/usb/usb.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = usb_NN.h \ usb_NNI.h \ diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index bd9ae2b..9c07b82 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp @@ -2,6 +2,12 @@ #include "usb_NN.h" #include "usb_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * USBNeeds[] = { 0 }; @@ -55,8 +61,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index 600b771..424845c 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp @@ -45,7 +45,7 @@ short AUSB::generateFileEmbedded( SystemFile & SF, // generate mapping stanza for this interface SF << " pre-up " << QPEApplication::qpeDir() - << "bin/setmacaddress.sh " + << "bin/NS2SetMac.sh " << NIC << " || true" << endl; diff --git a/noncore/settings/networksettings2/vpn/vpn.pro b/noncore/settings/networksettings2/vpn/vpn.pro index a131a1f..349571e 100644 --- a/noncore/settings/networksettings2/vpn/vpn.pro +++ b/noncore/settings/networksettings2/vpn/vpn.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = vpn_NN.h \ vpn_NNI.h \ diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index 23ec04a..6dd5332 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp @@ -1,6 +1,12 @@ #include "vpn_NN.h" #include "vpn_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * VPNNeeds[] = { 0 }; @@ -47,8 +53,17 @@ 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 + } diff --git a/noncore/settings/networksettings2/wlan/wlan.pro b/noncore/settings/networksettings2/wlan/wlan.pro index f4c55df..a08cbbb 100644 --- a/noncore/settings/networksettings2/wlan/wlan.pro +++ b/noncore/settings/networksettings2/wlan/wlan.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt warn_on release plugin DESTDIR = $(OPIEDIR)/plugins/networksettings2 HEADERS = wlan_NN.h \ wlan_NNI.h \ diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index 36a5c33..c56da06 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp @@ -2,6 +2,12 @@ #include "wlan_NN.h" #include "wlan_NNI.h" +#ifndef MYPLUGIN + +#include "netnodeinterface.h" + +#endif + static const char * WLanNeeds[] = { 0 }; @@ -63,8 +69,17 @@ void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { << endl; } +#ifdef MYPLUGIN + extern "C" { void create_plugin( QList<ANetNode> & PNN ) { PNN.append( new WLanNetNode() ); } + +#else + +OPIE_NS2_PLUGIN( NetNodeInterface<WLanNetNode> ) + +#endif + } |