64 files changed, 3150 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro new file mode 100644 index 0000000..180bda9 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = bluetooth_NN.h \ + bluetoothBNEP_NNI.h \ + bluetoothRFCOMM_NNI.h \ + bluetoothBNEPedit.h \ + bluetoothRFCOMMedit.h +SOURCES = bluetooth_NN.cpp \ + bluetoothBNEP_NNI.cpp \ + bluetoothRFCOMM_NNI.cpp \ + bluetoothBNEPedit.cpp \ + bluetoothRFCOMMedit.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui +TARGET = bluetooth +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPGUI.ui b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPGUI.ui new file mode 100644 index 0000000..ddb5ddd --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPGUI.ui @@ -0,0 +1,131 @@ +<!DOCTYPE UI><UI> +<class>BluetoothBNEPGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>BluetoothBNEP_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>283</width> + <height>199</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Bluetooth-bnep</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Name</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Name_LE</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Description</string> + </property> + </widget> + <widget> + <class>QMultiLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Description_LE</cstring> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Automatic_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Start automatically</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Confirm_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Confirm before start</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +</UI> diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp new file mode 100644 index 0000000..1743c1d --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp @@ -0,0 +1,29 @@ +#include "bluetoothBNEPedit.h" +#include "bluetoothBNEP_NNI.h" +#include "bluetooth_NN.h" + +ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : ANetNodeInstance( PNN ) { + GUI = 0; + RT = 0; +} + +void ABluetoothBNEP::setSpecificAttribute( QString & , QString & ) { +} + +void ABluetoothBNEP::saveSpecificAttribute( QTextStream & ) { +} + +QWidget * ABluetoothBNEP::edit( QWidget * parent ) { + GUI = new BluetoothBNEPEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString ABluetoothBNEP::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void ABluetoothBNEP::commit( void ) { + if( GUI && GUI->commit( Data ) ) + setModified( 1 ); +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h new file mode 100644 index 0000000..a21f574 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h @@ -0,0 +1,43 @@ +#ifndef BLUETOOTHBNEP_H +#define BLUETOOTHBNEP_H + +#include <netnode.h> +#include "bluetoothBNEPdata.h" +#include "bluetoothBNEPrun.h" + +class BluetoothBNEPNetNode; +class BluetoothBNEPEdit; + +class ABluetoothBNEP : public ANetNodeInstance { + +public : + + ABluetoothBNEP( BluetoothBNEPNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new BluetoothBNEPRun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + BluetoothBNEPEdit * GUI; + BluetoothBNEPData Data; + BluetoothBNEPRun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h new file mode 100644 index 0000000..037b7b1 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h @@ -0,0 +1,8 @@ +#ifndef BLUETOOTHBNEP_DATA_H +#define BLUETOOTHBNEP_DATA_H + +typedef struct BluetoothBNEPData { + long x; +} BluetoothBNEPData_t; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp new file mode 100644 index 0000000..a27f1a7 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp @@ -0,0 +1,18 @@ +#include <GUIUtils.h> +#include "bluetoothBNEPedit.h" + + +BluetoothBNEPEdit::BluetoothBNEPEdit( QWidget * Parent ) : BluetoothBNEPGUI( Parent ){ + +} + +QString BluetoothBNEPEdit::acceptable( void ) { + return QString(); +} + +bool BluetoothBNEPEdit::commit( BluetoothBNEPData & Data ) { + return 0; +} + +void BluetoothBNEPEdit::showData( BluetoothBNEPData & Data ) { +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.h new file mode 100644 index 0000000..d546f1e --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.h @@ -0,0 +1,13 @@ +#include "bluetoothBNEPdata.h" +#include "bluetoothBNEPGUI.h" + +class BluetoothBNEPEdit : public BluetoothBNEPGUI { + +public : + + BluetoothBNEPEdit( QWidget * parent ); + + QString acceptable( void ); + bool commit( BluetoothBNEPData & Data ); + void showData( BluetoothBNEPData & Data ); +}; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h new file mode 100644 index 0000000..e65b378 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -0,0 +1,32 @@ +#include <asdevice.h> +#include "bluetoothBNEPdata.h" + +class BluetoothBNEPRun : public AsDevice { + +public : + + BluetoothBNEPRun( ANetNodeInstance * NNI, + BluetoothBNEPData & Data ) : AsDevice( NNI ) + { } + + virtual long count( void ) + { return 3; } + virtual QString genNic( long nr ) + { QString S; return S.sprintf( "bnep%ld", nr ); } + virtual AsDevice * device( void ) + { return asDevice(); } + +protected : + + void detectState( NodeCollection * ) + { } + + bool setState( NodeCollection * , Action_t ) + { return 0; } + + bool canSetState( State_t , Action_t ) + { return 0; } + + bool handlesInterface( const QString & ) + { return 0; } +}; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui new file mode 100644 index 0000000..2754a70 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui @@ -0,0 +1,131 @@ +<!DOCTYPE UI><UI> +<class>BluetoothRFCOMMGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>BluetoothRFCOMM_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>283</width> + <height>199</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Bluetooth-rfcomm</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Name</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Name_LE</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Description</string> + </property> + </widget> + <widget> + <class>QMultiLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Description_LE</cstring> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Automatic_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Start automatically</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Confirm_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Confirm before start</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +</UI> diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp new file mode 100644 index 0000000..7ec8288 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp @@ -0,0 +1,30 @@ +#include "bluetoothRFCOMMedit.h" +#include "bluetoothRFCOMM_NNI.h" +#include "bluetooth_NN.h" + +ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : ANetNodeInstance( PNN ) { + GUI = 0; + RT = 0; +} + +void ABluetoothRFCOMM::setSpecificAttribute( QString & , QString & ) { +} + +void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & ) { +} + + +QWidget * ABluetoothRFCOMM::edit( QWidget * parent ) { + GUI = new BluetoothRFCOMMEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString ABluetoothRFCOMM::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void ABluetoothRFCOMM::commit( void ) { + if( GUI->commit( Data ) ) + setModified( 1 ); +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h new file mode 100644 index 0000000..4dd508d --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h @@ -0,0 +1,42 @@ +#ifndef BLUETOOTHRFCOMM_H +#define BLUETOOTHRFCOMM_H + +#include <netnode.h> +#include "bluetoothRFCOMMdata.h" +#include "bluetoothRFCOMMrun.h" + +class BluetoothRFCOMMNetNode; +class BluetoothRFCOMMEdit; + +class ABluetoothRFCOMM : public ANetNodeInstance { + +public : + + ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT ) + RT = new BluetoothRFCOMMRun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + BluetoothRFCOMMEdit * GUI; + BluetoothRFCOMMData Data; + BluetoothRFCOMMRun * RT; +}; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h new file mode 100644 index 0000000..18f0d38 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h @@ -0,0 +1,18 @@ +#ifndef BLUETOOTHRFCOMM_DATA_H +#define BLUETOOTHRFCOMM_DATA_H + +#include <qstring.h> + +typedef struct BluetoothRFCOMMData { + QString Device; + QString LockFile; + long Speed; + short Parity; + short DataBits; + short StopBits; + bool HardwareControl; + bool SoftwareControl; + +} BluetoothRFCOMMData_t; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp new file mode 100644 index 0000000..d3ddab4 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp @@ -0,0 +1,18 @@ +#include <GUIUtils.h> +#include "bluetoothRFCOMMedit.h" + +BluetoothRFCOMMEdit::BluetoothRFCOMMEdit( QWidget * Parent ) : + BluetoothRFCOMMGUI( Parent ){ + +} + +QString BluetoothRFCOMMEdit::acceptable( void ) { + return QString(); +} + +void BluetoothRFCOMMEdit::showData( BluetoothRFCOMMData & Data ) { +} + +bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { + return 0; +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h new file mode 100644 index 0000000..14a6d64 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h @@ -0,0 +1,13 @@ +#include "bluetoothRFCOMMdata.h" +#include "bluetoothRFCOMMGUI.h" + +class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { + +public : + + BluetoothRFCOMMEdit( QWidget * parent ); + + QString acceptable( void ); + void showData( BluetoothRFCOMMData & Data ); + bool commit( BluetoothRFCOMMData & Data ); +}; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h new file mode 100644 index 0000000..87116e2 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -0,0 +1,22 @@ +#include <asline.h> +#include "bluetoothRFCOMMdata.h" + +class BluetoothRFCOMMRun : public AsLine { + +public : + + BluetoothRFCOMMRun( ANetNodeInstance * NNI, + BluetoothRFCOMMData & Data ) : AsLine( NNI ) + { } + +protected : + + void detectState( NodeCollection * ) + { } + + bool setState( NodeCollection * , Action_t ) + { return 0; } + + bool canSetState( State_t , Action_t ) + { return 0; } +}; diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp new file mode 100644 index 0000000..91be153 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp @@ -0,0 +1,120 @@ +#include "bluetooth_NN.h" +#include "bluetoothBNEP_NNI.h" +#include "bluetoothRFCOMM_NNI.h" + +// +// +// BLUETOOTH PAN/NAP node +// +// + +static const char * BluetoothBNEPNeeds[] = + { 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +BluetoothBNEPNetNode::BluetoothBNEPNetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){ +} + +const QString BluetoothBNEPNetNode::nodeDescription(){ + return tr("\ +<p>Sets up a bluetooth link using the bluetooth Network profile.</p>\ +<p>Use this to connect two computing devices.</p>\ +" +); +} + +ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { + return new ABluetoothBNEP( this ); +} + +const char ** BluetoothBNEPNetNode::needs( void ) { + return BluetoothBNEPNeeds; +} + +const char * BluetoothBNEPNetNode::provides( void ) { + return "device"; +} + +bool BluetoothBNEPNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool BluetoothBNEPNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool BluetoothBNEPNetNode::generateDataForCommonFile( + SystemFile & , + long , + ANetNodeInstance * ) { + return 1; +} + +// +// +// BLUETOOTH PAN/NAP node +// +// + +static const char * BluetoothRFCOMMNeeds[] = + { 0 + }; + +BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { +} + +BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ +} + +const QString BluetoothRFCOMMNetNode::nodeDescription(){ + return tr("\ +<p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ +<p>Use this to connect to a GSM.</p>\ +" +); +} + +ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { + return new ABluetoothRFCOMM( this ); +} + +const char ** BluetoothRFCOMMNetNode::needs( void ) { + return BluetoothRFCOMMNeeds; +} + +const char * BluetoothRFCOMMNetNode::provides( void ) { + return "line"; +} + +bool BluetoothRFCOMMNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 0; +} + +bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool BluetoothRFCOMMNetNode::generateDataForCommonFile( + SystemFile & , + long, + ANetNodeInstance * ) { + return 0; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new BluetoothBNEPNetNode() ); + PNN.append( new BluetoothRFCOMMNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h new file mode 100644 index 0000000..ee346f0 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h @@ -0,0 +1,75 @@ +#ifndef BLUETOOTH_NETNODE_H +#define BLUETOOTH_NETNODE_H + +#include "netnode.h" + +class ABluetoothBNEP; + +class BluetoothBNEPNetNode : public ANetNode { + + Q_OBJECT + +public: + + BluetoothBNEPNetNode(); + virtual ~BluetoothBNEPNetNode(); + + virtual const QString pixmapName() + { return "bluetooth"; } + + virtual const QString nodeName() + { return tr("Bluetooth PAN/NAP"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); + +private: + +}; + +class BluetoothRFCOMMNetNode : public ANetNode { + + Q_OBJECT + +public: + + BluetoothRFCOMMNetNode(); + virtual ~BluetoothRFCOMMNetNode(); + + virtual const QString pixmapName() + { return "bluetooth"; } + + virtual const QString nodeName() + { return tr("Bluetooth serial link"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long, ANetNodeInstance * NNI ); + +private: + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in new file mode 100644 index 0000000..2b527cc --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/config.in @@ -0,0 +1,4 @@ + config NS2BT + boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/cable/cable.pro b/noncore/settings/networksettings2/cable/cable.pro new file mode 100644 index 0000000..d902360 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cable.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = cable_NN.h \ + cable_NNI.h \ + cableedit.h +SOURCES = cable_NN.cpp \ + cable_NNI.cpp \ + cableedit.cpp \ + cablerun.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = cableGUI.ui +TARGET = cable +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/cable/cableGUI.ui b/noncore/settings/networksettings2/cable/cableGUI.ui new file mode 100644 index 0000000..2431861 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cableGUI.ui @@ -0,0 +1,545 @@ +<!DOCTYPE UI><UI> +<class>CableGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Cable_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>235</width> + <height>194</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Cable</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout3</cstring> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Lock file</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Device</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>LockFile_LE</cstring> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>DeviceFile_LE</cstring> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Serial settings</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout13</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget row="0" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>2400</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>9600</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>19200</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>38400</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>57600</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>115200</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>230400</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>460800</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>500000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>921600</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>1000000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>1152000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>1500000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>2000000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>2500000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>3000000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>3500000</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>4000000</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>Speed_CB</cstring> + </property> + <property stdset="1"> + <name>currentItem</name> + <number>5</number> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Parity</string> + </property> + </widget> + <widget row="0" column="2" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2_3</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Data bits</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Speed</string> + </property> + </widget> + <widget row="1" column="2" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2_3_2</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Stop bits</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>No</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Even</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Odd</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Mark</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Space</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>Parity_CB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>currentItem</name> + <number>0</number> + </property> + </widget> + <widget row="0" column="3" > + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>DataBits_SB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>8</number> + </property> + <property stdset="1"> + <name>minValue</name> + <number>5</number> + </property> + <property stdset="1"> + <name>value</name> + <number>8</number> + </property> + </widget> + <widget row="1" column="3" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>1</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>2</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>StopBits_CB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout17</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Flow control :</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignTop|AlignLeft</set> + </property> + <property> + <name>vAlign</name> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout16</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>HardwareFC_CB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Hardware</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>SoftwareFC_CB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Software</string> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer6</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +</UI> diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp new file mode 100644 index 0000000..756903e --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -0,0 +1,59 @@ +#include "cable_NN.h" +#include "cable_NNI.h" + +static const char * CableNeeds[] = + { 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +CableNetNode::CableNetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +CableNetNode::~CableNetNode(){ +} + +const QString CableNetNode::nodeDescription(){ + return tr("\ +<p>Sets up a wired serial or parallel.</p>\ +" +); +} + +ANetNodeInstance * CableNetNode::createInstance( void ) { + return new ACable( this ); +} + +const char ** CableNetNode::needs( void ) { + return CableNeeds; +} + +const char * CableNetNode::provides( void ) { + return "line"; +} + +bool CableNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool CableNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool CableNetNode::generateDataForCommonFile( + SystemFile & , + long , + ANetNodeInstance * ) { + return 1; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new CableNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h new file mode 100644 index 0000000..401317b --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cable_NN.h @@ -0,0 +1,44 @@ +#ifndef CABLE_NETNODE_H +#define CABLE_NETNODE_H + +#include "netnode.h" + +class ACable; + +class CableNetNode : public ANetNode { + + Q_OBJECT + +public: + + CableNetNode(); + virtual ~CableNetNode(); + + virtual const QString pixmapName() + { return "cable"; } + + virtual const QString nodeName() + { return tr("Cable Connection"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); + +private: + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp new file mode 100644 index 0000000..d26afd1 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp @@ -0,0 +1,66 @@ +#include "cableedit.h" +#include "cable_NNI.h" +#include "cable_NN.h" + +ACable::ACable( CableNetNode * PNN ) : ANetNodeInstance( PNN ) { + // default values + Data.Device = "/dev/ttyS0"; + Data.LockFile = "/var/Lock"; + Data.Speed = 115200; + Data.DataBits = 8; + Data.Parity = 0; + Data.StopBits = 1; + Data.HardwareControl = 0; + Data.SoftwareControl = 0; + GUI = 0; + RT = 0; +} + +void ACable::setSpecificAttribute( QString & A, QString & V) { + if( A == "device" ) { + Data.Device = V; + } else if ( A == "lockfile" ) { + Data.LockFile = V; + } else if ( A == "speed" ) { + Data.Speed = V.toLong(); + } else if ( A == "parity" ) { + Data.Parity = V.toShort(); + } else if ( A == "databits" ) { + Data.DataBits = V.toShort(); + } else if ( A == "stopbits" ) { + Data.StopBits = V.toShort(); + } else if ( A == "hardwarecontrol" ) { + Data.HardwareControl = ( V == "yes" ); + } else if ( A == "softwarecontrol" ) { + Data.SoftwareControl = ( V == "yes" ); + } +} + +void ACable::saveSpecificAttribute( QTextStream & TS ) { + TS << "device=" << quote( Data.Device ) << endl; + TS << "lockfile=" << quote( Data.LockFile ) << endl; + TS << "speed=" << Data.Speed << endl; + TS << "parity=" << Data.Parity << endl; + TS << "databits=" << Data.DataBits << endl; + TS << "stopbits=" << Data.StopBits << endl; + TS << "hardwarecontrol=" << + ((Data.HardwareControl) ? "yes" : "no") << endl; + TS << "softwarecontrol=" << + ((Data.SoftwareControl) ? "yes" : "no") << endl; +} + +QWidget * ACable::edit( QWidget * parent ) { + GUI = new CableEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString ACable::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void ACable::commit( void ) { + if( GUI && GUI->commit( Data ) ) { + setModified( 1 ); + } +} diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h new file mode 100644 index 0000000..0654a5d --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cable_NNI.h @@ -0,0 +1,43 @@ +#ifndef CABLE_H +#define CABLE_H + +#include <netnode.h> +#include "cabledata.h" +#include "cablerun.h" + +class CableNetNode; +class CableEdit; + +class ACable : public ANetNodeInstance { + +public : + + ACable( CableNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new CableRun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + CableEdit * GUI; + CableData_t Data; + CableRun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/cable/cabledata.h b/noncore/settings/networksettings2/cable/cabledata.h new file mode 100644 index 0000000..c449d96 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cabledata.h @@ -0,0 +1,18 @@ +#ifndef CABLE_DATA_H +#define CABLE_DATA_H + +#include <qstring.h> + +typedef struct CableData { + QString Device; + QString LockFile; + long Speed; + short Parity; + short DataBits; + short StopBits; + bool HardwareControl; + bool SoftwareControl; + +} CableData_t; + +#endif diff --git a/noncore/settings/networksettings2/cable/cableedit.cpp b/noncore/settings/networksettings2/cable/cableedit.cpp new file mode 100644 index 0000000..6e1a13b --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cableedit.cpp @@ -0,0 +1,68 @@ +#include <GUIUtils.h> +#include <stdio.h> +#include <qlineedit.h> +#include <qcombobox.h> +#include <qspinbox.h> +#include <qcheckbox.h> +#include "cabledata.h" +#include "cableedit.h" + +static long SpeedTable[] = { + 2400, 9600, 19200, 38400, 57600, 115200, + 230400, 460800, 500000, 921600, 1000000, + 1152000, 1500000, 2000000, 2500000, 3000000, + 3500000, 4000000, -1 +}; + +CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) { +} + +void CableEdit::showData( CableData_t & D ) { + DeviceFile_LE->setText( D.Device ); + LockFile_LE->setText( D.LockFile ); + for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { + if( *Run == D.Speed ) { + Speed_CB->setCurrentItem( + ((long)(Run)-(long)(SpeedTable))/sizeof(long) ); + break; + } + } + Parity_CB->setCurrentItem( D.Parity ); + DataBits_SB->setValue( D.DataBits ); + StopBits_CB->setCurrentItem( D.StopBits ); + HardwareFC_CB->setChecked( D.HardwareControl ); + SoftwareFC_CB->setChecked( D.SoftwareControl ); +} + +QString CableEdit::acceptable( void ) { + if( DeviceFile_LE->text().isEmpty() ) + return tr("Device filename needed"); + return QString(); +} + +bool CableEdit::commit( CableData_t & D ) { + bool SM = 0; + + TXTM( D.Device, DeviceFile_LE, SM ); + TXTM( D.LockFile, LockFile_LE, SM ); + + for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { + if( *Run == D.Speed ) { + if( D.Speed != Speed_CB->currentText().toLong() ) { + SM = 1; + D.Speed = Speed_CB->currentText().toLong(); + } + break; + } + } + + CIM(D.Parity, Parity_CB, SM ); + + SBM(D.DataBits, DataBits_SB, SM ); + CIM(D.StopBits, StopBits_CB, SM ); + + CBM( D.HardwareControl, HardwareFC_CB, SM ); + CBM( D.SoftwareControl, SoftwareFC_CB, SM ); + + return SM; +} diff --git a/noncore/settings/networksettings2/cable/cableedit.h b/noncore/settings/networksettings2/cable/cableedit.h new file mode 100644 index 0000000..ffacc61 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cableedit.h @@ -0,0 +1,12 @@ +#include "cabledata.h" +#include "cableGUI.h" + +class CableEdit : public CableGUI { + +public : + + CableEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( CableData_t & D ); + void showData( CableData_t & D ); +}; diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp new file mode 100644 index 0000000..edb4b01 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cablerun.cpp @@ -0,0 +1,26 @@ +#include <fcntl.h> +#include <unistd.h> +#include "cablerun.h" + +void CableRun::detectState( NodeCollection * NC ) { + + int fd = open( D->Device.latin1(), O_RDWR ); + + if( fd < 0 ) { + NC->setCurrentState( Unavailable ); + } + close( fd ); + NC->setCurrentState( Available ); +} + +bool CableRun::setState( NodeCollection * NC, Action_t A ) { + if( A == Activate ) { + detectState(NC); + return (NC->currentState() == Available); + } + return 1; +} + +bool CableRun::canSetState( State_t , Action_t ) { + return 1; +} diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h new file mode 100644 index 0000000..36ee640 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/cablerun.h @@ -0,0 +1,21 @@ +#include <asline.h> +#include "cabledata.h" + +class CableRun : public AsLine { + +public : + + CableRun( ANetNodeInstance * NNI, + CableData & Data ) : AsLine( NNI ) + { D = &Data; } + +protected : + + void detectState( NodeCollection * NC ); + bool setState( NodeCollection * NC, Action_t A ); + bool canSetState( State_t Curr, Action_t A ); + +private : + + CableData_t * D; +}; diff --git a/noncore/settings/networksettings2/cable/config.in b/noncore/settings/networksettings2/cable/config.in new file mode 100644 index 0000000..4453107 --- a/dev/null +++ b/noncore/settings/networksettings2/cable/config.in @@ -0,0 +1,4 @@ + config NS2CABLE + boolean "opie-networksettings2plugin-cable (set up Cable)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/irda/config.in b/noncore/settings/networksettings2/irda/config.in new file mode 100644 index 0000000..997cf55 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/config.in @@ -0,0 +1,4 @@ + config NS2IRDA + boolean "opie-networksettings2plugin-irda (set up IRDA)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/irda/irda.pro b/noncore/settings/networksettings2/irda/irda.pro new file mode 100644 index 0000000..a7573b8 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irda.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = irda_NN.h \ + irda_NNI.h \ + irdaedit.h +SOURCES = irda_NN.cpp \ + irda_NNI.cpp \ + irdaedit.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = irdaGUI.ui +TARGET = irda +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/irda/irdaGUI.ui b/noncore/settings/networksettings2/irda/irdaGUI.ui new file mode 100644 index 0000000..f8a7020 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irdaGUI.ui @@ -0,0 +1,131 @@ +<!DOCTYPE UI><UI> +<class>IRDAGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>IRDA_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>283</width> + <height>199</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>IRDA</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Name</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Name_LE</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Description</string> + </property> + </widget> + <widget> + <class>QMultiLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Description_LE</cstring> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Automatic_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Start automatically</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Confirm_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Confirm before start</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +</UI> diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp new file mode 100644 index 0000000..3b9c938 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp @@ -0,0 +1,59 @@ +#include "irda_NN.h" +#include "irda_NNI.h" + +static const char * IRDANeeds[] = + { 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +IRDANetNode::IRDANetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +IRDANetNode::~IRDANetNode(){ +} + +const QString IRDANetNode::nodeDescription(){ + return tr("\ +<p>Sets up a infra red serial link.</p>\ +" +); +} + +ANetNodeInstance * IRDANetNode::createInstance( void ) { + return new AIRDA( this ); +} + +const char ** IRDANetNode::needs( void ) { + return IRDANeeds; +} + +const char * IRDANetNode::provides( void ) { + return "line"; +} + +bool IRDANetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool IRDANetNode::hasDataFor( const QString & ) { + return 0; +} + +bool IRDANetNode::generateDataForCommonFile( + SystemFile & , + long , + ANetNodeInstance * ) { + return 1; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new IRDANetNode() ); +} +} diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h new file mode 100644 index 0000000..82811a4 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irda_NN.h @@ -0,0 +1,44 @@ +#ifndef IRDA_NETNODE_H +#define IRDA_NETNODE_H + +#include "netnode.h" + +class AIRDA; + +class IRDANetNode : public ANetNode { + + Q_OBJECT + +public: + + IRDANetNode(); + virtual ~IRDANetNode(); + + virtual const QString pixmapName() + { return "irda"; } + + virtual const QString nodeName() + { return tr("Infrared link"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); + +private: + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp new file mode 100644 index 0000000..78d6ff9 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp @@ -0,0 +1,30 @@ +#include "irdaedit.h" +#include "irda_NNI.h" +#include "irda_NN.h" + +AIRDA::AIRDA( IRDANetNode * PNN ) : ANetNodeInstance( PNN ) { + + GUI = 0; + RT = 0; +} + +void AIRDA::setSpecificAttribute( QString & , QString & ) { +} + +void AIRDA::saveSpecificAttribute( QTextStream & ) { +} + +QWidget * AIRDA::edit( QWidget * parent ) { + GUI = new IRDAEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString AIRDA::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void AIRDA::commit( void ) { + if( GUI && GUI->commit( Data ) ) + setModified( 1 ); +} diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h new file mode 100644 index 0000000..c2d6875 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irda_NNI.h @@ -0,0 +1,43 @@ +#ifndef IRDA_H +#define IRDA_H + +#include <netnode.h> +#include "irdadata.h" +#include "irdarun.h" + +class IRDANetNode; +class IRDAEdit; + +class AIRDA : public ANetNodeInstance { + +public : + + AIRDA( IRDANetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new IRDARun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + IRDAEdit * GUI; + IRDAData Data; + IRDARun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/irda/irdadata.h b/noncore/settings/networksettings2/irda/irdadata.h new file mode 100644 index 0000000..c3c683e --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irdadata.h @@ -0,0 +1,18 @@ +#ifndef IRDA_DATA_H +#define IRDA_DATA_H + +#include <qstring.h> + +typedef struct IRDAData { + QString Device; + QString LockFile; + long Speed; + short Parity; + short DataBits; + short StopBits; + bool HardwareControl; + bool SoftwareControl; + +} IRDAData_t; + +#endif diff --git a/noncore/settings/networksettings2/irda/irdaedit.cpp b/noncore/settings/networksettings2/irda/irdaedit.cpp new file mode 100644 index 0000000..2dfdce5 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irdaedit.cpp @@ -0,0 +1,17 @@ +#include <GUIUtils.h> +#include "irdaedit.h" + +IRDAEdit::IRDAEdit( QWidget * Parent ) : IRDAGUI( Parent ){ + +} + +QString IRDAEdit::acceptable( void ) { + return QString(); +} + +bool IRDAEdit::commit( IRDAData & Data ) { + return 0; +} + +void IRDAEdit::showData( IRDAData & Data ) { +} diff --git a/noncore/settings/networksettings2/irda/irdaedit.h b/noncore/settings/networksettings2/irda/irdaedit.h new file mode 100644 index 0000000..5131126 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irdaedit.h @@ -0,0 +1,12 @@ +#include "irdadata.h" +#include "irdaGUI.h" + +class IRDAEdit : public IRDAGUI { + +public : + + IRDAEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( IRDAData & Data ); + void showData( IRDAData & Data ); +}; diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h new file mode 100644 index 0000000..adc9c24 --- a/dev/null +++ b/noncore/settings/networksettings2/irda/irdarun.h @@ -0,0 +1,22 @@ +#include <asline.h> +#include "irdadata.h" + +class IRDARun : public AsLine { + +public : + + IRDARun( ANetNodeInstance * NNI, + IRDAData & Data ) : AsLine( NNI ) + { } + +protected : + + void detectState( NodeCollection * ) + { } + + bool setState( NodeCollection * , Action_t ) + { return 0; } + + bool canSetState( State_t , Action_t ) + { return 0; } +}; diff --git a/noncore/settings/networksettings2/lancard/config.in b/noncore/settings/networksettings2/lancard/config.in new file mode 100644 index 0000000..d190f6e --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/config.in @@ -0,0 +1,4 @@ + config NS2LANCARD + boolean "opie-networksettings2plugin-lancard (regular wired lan card)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/lancard/lancard.pro b/noncore/settings/networksettings2/lancard/lancard.pro new file mode 100644 index 0000000..f188d2b --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancard.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = lancard_NN.h \ + lancard_NNI.h \ + lancardedit.h +SOURCES = lancard_NN.cpp \ + lancard_NNI.cpp \ + lancardedit.cpp \ + lancardrun.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = lancardGUI.ui +TARGET = lancard +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/lancard/lancardGUI.ui b/noncore/settings/networksettings2/lancard/lancardGUI.ui new file mode 100644 index 0000000..8d94816 --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardGUI.ui @@ -0,0 +1,129 @@ +<!DOCTYPE UI><UI> +<class>LanCardGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Lancard_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>362</width> + <height>359</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>LAN card</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>AnyCard_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Any available LAN card</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>title</name> + <string>Select Card</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Name</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>MACAddress</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>LanCards_LV</cstring> + </property> + <property stdset="1"> + <name>allColumnsShowFocus</name> + <bool>true</bool> + </property> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>AnyCard_CB</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox1</receiver> + <slot>setDisabled(bool)</slot> + </connection> +</connections> +</UI> diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp new file mode 100644 index 0000000..a45496d --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp @@ -0,0 +1,60 @@ +#include "lancard_NN.h" +#include "lancard_NNI.h" + +static const char * LanCardNeeds[] = + { 0 }; + +/** + * Constructor, find all of the possible interfaces + */ +LanCardNetNode::LanCardNetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +LanCardNetNode::~LanCardNetNode(){ +} + +const QString LanCardNetNode::nodeDescription(){ + return tr("\ +<p>Sets up a wired regular LAN card.</p>\ +<p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ +" +); +} + +ANetNodeInstance * LanCardNetNode::createInstance( void ) { + return new ALanCard( this ); +} + + +const char ** LanCardNetNode::needs( void ) { + return LanCardNeeds; +} + +const char * LanCardNetNode::provides( void ) { + return "device"; +} + +bool LanCardNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool LanCardNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool LanCardNetNode::generateDataForCommonFile( + SystemFile & , + long , + ANetNodeInstance * ) { + return 1; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new LanCardNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h new file mode 100644 index 0000000..576a6e0 --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h @@ -0,0 +1,44 @@ +#ifndef LANCARD_NETNODE_H +#define LANCARD_NETNODE_H + +#include "netnode.h" + +class ALanCard; + +class LanCardNetNode : public ANetNode{ + + Q_OBJECT + +public: + + LanCardNetNode(); + virtual ~LanCardNetNode(); + + virtual const QString pixmapName() + { return "card"; } + + virtual const QString nodeName() + { return tr("LAN card"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); + +private: + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp new file mode 100644 index 0000000..9595e2e --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp @@ -0,0 +1,44 @@ +#include "lancardedit.h" +#include "lancard_NNI.h" +#include "lancard_NN.h" + +ALanCard::ALanCard( LanCardNetNode * PNN ) : ANetNodeInstance( PNN ) { + + Data.AnyLanCard = 1; + Data.HWAddresses.clear(); + + GUI = 0; + RT = 0; +} + +void ALanCard::setSpecificAttribute( QString & A, QString & V ) { + if( A == "matchanycard" ) { + Data.AnyLanCard = (V == "yes" ); + } else if( A == "match" ) { + Data.HWAddresses.append( V ); + } +} + +void ALanCard::saveSpecificAttribute( QTextStream & TS) { + TS << "matchanycard=" << + ((Data.AnyLanCard) ? "yes" : "no") << endl; + for( QStringList::Iterator it = Data.HWAddresses.begin(); + it != Data.HWAddresses.end(); ++it ) { + TS << "match=" << quote( *it ) << endl; + } +} + +QWidget * ALanCard::edit( QWidget * parent ) { + GUI = new LanCardEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString ALanCard::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void ALanCard::commit( void ) { + if( GUI && GUI->commit( Data ) ) + setModified( 1 ); +} diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h new file mode 100644 index 0000000..8fc8868 --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h @@ -0,0 +1,43 @@ +#ifndef LANCARD_H +#define LANCARD_H + +#include <netnode.h> +#include "lancarddata.h" +#include "lancardrun.h" + +class LanCardNetNode; +class LanCardEdit; + +class ALanCard : public ANetNodeInstance { + +public : + + ALanCard( LanCardNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new LanCardRun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + LanCardEdit * GUI; + LanCardData Data; + LanCardRun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/lancard/lancarddata.h b/noncore/settings/networksettings2/lancard/lancarddata.h new file mode 100644 index 0000000..c76767f --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancarddata.h @@ -0,0 +1,13 @@ +#ifndef LANCARD_DATA_H +#define LANCARD_DATA_H + +#include <qstringlist.h> +#include <qstring.h> + +typedef struct LanCardData { + bool AnyLanCard; + QStringList HWAddresses; + +} LanCardData_t; + +#endif diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp new file mode 100644 index 0000000..fa7f6dc --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp @@ -0,0 +1,95 @@ +#include <GUIUtils.h> +#include <resources.h> +#include <qlistview.h> +#include <qcheckbox.h> +#include <qheader.h> +#include <qregexp.h> +#include "lancardedit.h" + +LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){ + System & S = NSResources->system(); + QRegExp R( "eth[0-9]" ); + QCheckListItem * CLI; + + LanCards_LV->header()->hide(); + + // populate with all lancards in system + for( QDictIterator<InterfaceInfo> It(S.interfaces()); + It.current(); + ++It ) { + if( R.match( It.current()->Name ) >= 0 && + It.current()->CardType == ARPHRD_ETHER + ) { + CLI = new QCheckListItem( LanCards_LV, It.current()->Name, + QCheckListItem::CheckBox ); + CLI->setText( 1, It.current()->MACAddress ); + } + } +} + +QString LanCardEdit::acceptable( void ) { + return QString(); +} + + +bool LanCardEdit::commit( LanCardData & Data ) { + bool SM = 0; + CBM( Data.AnyLanCard, AnyCard_CB, SM ); + + if( ! Data.AnyLanCard ) { + // collect set of lancards that match + int idx; + QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); + while( CLI ) { + idx = Data.HWAddresses.findIndex(CLI->text(1)); + if( CLI->isOn() ) { + if( idx < 0 ) { + // should be in list + Data.HWAddresses.append( CLI->text(1) ); + SM = 1; + } + } else { + // should not be in list + if( idx >= 0 ) { + Data.HWAddresses.remove( Data.HWAddresses.at(idx) ); + SM = 1; + } + } + CLI = (QCheckListItem *)CLI->nextSibling(); + } + } + return SM || ContainedObsoleteMAC ; +} + +void LanCardEdit::showData( LanCardData & Data ) { + AnyCard_CB->setChecked( Data.AnyLanCard ); + + QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); + + ContainedObsoleteMAC = 0; + // remove obsolete address + for( QStringList::Iterator it=Data.HWAddresses.begin(); + it != Data.HWAddresses.end(); + ) { + CLI = (QCheckListItem *)LanCards_LV->firstChild(); + while( CLI ) { + if( CLI->text(1) == (*it) ) + // still valid + break; + CLI = (QCheckListItem *)CLI->nextSibling(); + } + if( CLI == 0 ) { + // address not found -> remove + ContainedObsoleteMAC = 1; + Data.HWAddresses.remove( it ); + } else { + ++ it; + } + } + + // set checks + while( CLI ) { + CLI->setOn( Data.HWAddresses.findIndex(CLI->text(1)) >= 0 ); + CLI = (QCheckListItem *)CLI->nextSibling(); + } +} diff --git a/noncore/settings/networksettings2/lancard/lancardedit.h b/noncore/settings/networksettings2/lancard/lancardedit.h new file mode 100644 index 0000000..8def789 --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardedit.h @@ -0,0 +1,16 @@ +#include "lancarddata.h" +#include "lancardGUI.h" + +class LanCardEdit : public LanCardGUI { + +public : + + LanCardEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( LanCardData & Data ); + void showData( LanCardData & Data ); + +private : + + bool ContainedObsoleteMAC; +}; diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp new file mode 100644 index 0000000..b3b592b --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp @@ -0,0 +1,158 @@ +#include <qfile.h> +#include <qtextstream.h> +#include <resources.h> +#include "lancardrun.h" + +void LanCardRun::detectState( NodeCollection * NC ) { + + // unavailable : no card found + // available : card found and assigned to us or free + // up : card found and assigned to us and up + + QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); + System & Sys = NSResources->system(); + InterfaceInfo * Run; + + QFile F( S ); + + if( F.open( IO_ReadOnly ) ) { + // could open file -> read interface and assign + QString X; + QTextStream TS(&F); + X = TS.readLine(); + // find interface + if( handlesInterface( X ) ) { + for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( X == Run->Name ) { + Run->assignNode( netNode() ); + assignInterface( Run ); + NC->setCurrentState( IsUp ); + return; + } + } + } + } + + // we are certainly not UP + assignInterface( 0 ); + + // find possible interface + for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( handlesInterface( Run->Name ) && + Run->CardType == ARPHRD_ETHER && + ! Run->IsUp + ) { + // proper type, and Not UP -> free + NC->setCurrentState( Off ); + return; + } + } + // no free found + + NC->setCurrentState( Unavailable ); + +} + +bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { + + // we only handle activate and deactivate + switch( A ) { + case Activate : + { + if( NC->currentState() != Off ) { + return 0; + } + InterfaceInfo * N = getInterface(); + if( ! N ) { + // no interface available + NC->setCurrentState( Unavailable ); + return 0; + } + // because we were OFF the interface + // we get back is NOT assigned + N->assignNode( netNode() ); + assignInterface( N ); + NC->setCurrentState( Available ); + return 1; + } + case Deactivate : + if( NC->currentState() == IsUp ) { + // bring down first + if( ! connection()->setState( Down ) ) + // could not ... + return 0; + } + if( NC->currentState() != Available ) { + return 1; + } + assignedInterface()->assignNode( 0 ); // release + assignInterface( 0 ); + NC->setCurrentState( Off ); + return 1; + default : + // FT + break; + } + return 0; +} + +bool LanCardRun::canSetState( State_t Curr, Action_t A ) { + // we only handle up down activate and deactivate + switch( A ) { + case Activate : + { // at least available + if( Curr == Available ) { + return 1; + } + // or we can make one available + InterfaceInfo * N = getInterface(); + if( ! N || N->assignedNode() != 0 ) { + // non available or assigned + return 0; + } + return 1; + } + case Deactivate : + return ( Curr >= Available ); + default : + // FT + break; + } + return 0; +} + +// get interface that is free or assigned to us +InterfaceInfo * LanCardRun::getInterface( void ) { + + System & S = NSResources->system(); + InterfaceInfo * best = 0, * Run; + + for( QDictIterator<InterfaceInfo> It(S.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( handlesInterface( Run->Name ) && + Run->CardType == ARPHRD_ETHER + ) { + // this is a LAN card + if( Run->assignedNode() == netNode() ) { + // assigned to us + return Run; + } else if( Run->assignedNode() == 0 ) { + // free + best = Run; + } + } + } + return best; // can be 0 +} + +bool LanCardRun::handlesInterface( const QString & S ) { + return Pat.match( S ) >= 0; +} diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h new file mode 100644 index 0000000..5f004e0 --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardrun.h @@ -0,0 +1,38 @@ +#ifndef LANCARDRUN_H +#define LANCARDRUN_H + +#include <asdevice.h> +#include <qregexp.h> +#include "lancarddata.h" + +class LanCardRun : public AsDevice { + +public : + + LanCardRun( ANetNodeInstance * NNI, + LanCardData & Data ) : AsDevice( NNI ), + Pat( "eth[0-9]" ) + { } + + virtual long count( void ) + { return 2; } + virtual QString genNic( long nr ) + { QString S; return S.sprintf( "eth%ld", nr ); } + virtual AsDevice * device( void ) + { return asDevice(); } + +protected : + + void detectState( NodeCollection * NC ); + bool setState( NodeCollection * NC, Action_t A ); + bool canSetState( State_t Curr, Action_t A ); + + bool handlesInterface( const QString & I ); + +private : + + InterfaceInfo * getInterface( void ); + QRegExp Pat; + +}; +#endif diff --git a/noncore/settings/networksettings2/modem/config.in b/noncore/settings/networksettings2/modem/config.in new file mode 100644 index 0000000..77a1c77 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/config.in @@ -0,0 +1,4 @@ + config NS2MODEM + boolean "opie-networksettings2plugin-modem (set up DIALUP)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/modem/modem.pro b/noncore/settings/networksettings2/modem/modem.pro new file mode 100644 index 0000000..945486b --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modem.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = modem_NN.h \ + modem_NNI.h \ + modemedit.h +SOURCES = modem_NN.cpp \ + modem_NNI.cpp \ + modemedit.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = modemGUI.ui +TARGET = modem +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/modem/modemGUI.ui b/noncore/settings/networksettings2/modem/modemGUI.ui new file mode 100644 index 0000000..328f95c --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modemGUI.ui @@ -0,0 +1,131 @@ +<!DOCTYPE UI><UI> +<class>ModemGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Modem_FRM</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>283</width> + <height>199</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Modem</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Name</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Name_LE</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Description</string> + </property> + </widget> + <widget> + <class>QMultiLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Description_LE</cstring> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Automatic_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Start automatically</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Confirm_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Confirm before start</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +</UI> diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp new file mode 100644 index 0000000..48e1ad8 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp @@ -0,0 +1,60 @@ +#include "modem_NN.h" +#include "modem_NNI.h" + +static const char * ModemNeeds[] = + { "line" + }; + +/** + * Constructor, find all of the possible interfaces + */ +ModemNetNode::ModemNetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +ModemNetNode::~ModemNetNode(){ +} + +const QString ModemNetNode::nodeDescription(){ + return tr("\ +<p>Sets up a dialing procedures.</p>\ +<p>Use this to dial up over modems, ISDN, GSM, ...</p>\ +" +); +} + +ANetNodeInstance * ModemNetNode::createInstance( void ) { + return new AModem( this ); +} + +const char ** ModemNetNode::needs( void ) { + return ModemNeeds; +} + +const char * ModemNetNode::provides( void ) { + return "line"; +} + +bool ModemNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool ModemNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool ModemNetNode::generateDataForCommonFile( + SystemFile & , + long , + ANetNodeInstance * ) { + return 1; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new ModemNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h new file mode 100644 index 0000000..0f4c124 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modem_NN.h @@ -0,0 +1,44 @@ +#ifndef MODEM_NETNODE_H +#define MODEM_NETNODE_H + +#include "netnode.h" + +class AModem; + +class ModemNetNode : public ANetNode{ + + Q_OBJECT + +public: + + ModemNetNode(); + virtual ~ModemNetNode(); + + virtual const QString pixmapName() + { return "modem"; } + + virtual const QString nodeName() + { return tr("Dialup modem"); } + + virtual const QString nodeDescription() ; + + virtual ANetNodeInstance * createInstance( void ); + + virtual const char ** needs( void ); + virtual const char * provides( void ); + + virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); + virtual bool hasDataFor( const QString & S ); + virtual bool generateDataForCommonFile( + SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); + +private: + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp new file mode 100644 index 0000000..91df22b --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp @@ -0,0 +1,31 @@ +#include "modemedit.h" +#include "modem_NNI.h" +#include "modem_NN.h" + +AModem::AModem( ModemNetNode * PNN ) : ANetNodeInstance( PNN ) { + + GUI = 0; + RT = 0; +} + +void AModem::setSpecificAttribute( QString & , QString & ) { +} + +void AModem::saveSpecificAttribute( QTextStream & ) { +} + +QWidget * AModem::edit( QWidget * parent ) { + GUI = new ModemEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString AModem::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void AModem::commit( void ) { + if( GUI && GUI->commit( Data ) ) + setModified( 1 ); +} + diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h new file mode 100644 index 0000000..7543e7d --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modem_NNI.h @@ -0,0 +1,43 @@ +#ifndef Modem_H +#define Modem_H + +#include <netnode.h> +#include "modemdata.h" +#include "modemrun.h" + +class ModemNetNode; +class ModemEdit; + +class AModem : public ANetNodeInstance { + +public : + + AModem( ModemNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new ModemRun( this, Data ); + return RT; + } + + virtual void * data( void ) + { return (void *)&Data; } + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + ModemEdit * GUI; + ModemData Data; + ModemRun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/modem/modemdata.h b/noncore/settings/networksettings2/modem/modemdata.h new file mode 100644 index 0000000..773cb77 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modemdata.h @@ -0,0 +1,17 @@ +#ifndef MODEM_DATA_H +#define MODEM_DATA_H + +#include <qstring.h> +typedef struct ModemData { + QString Device; + QString LockFile; + long Speed; + short Parity; + short DataBits; + short StopBits; + bool HardwareControl; + bool SoftwareControl; + +} ModemData_t; + +#endif diff --git a/noncore/settings/networksettings2/modem/modemedit.cpp b/noncore/settings/networksettings2/modem/modemedit.cpp new file mode 100644 index 0000000..fd3d694 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modemedit.cpp @@ -0,0 +1,18 @@ +#include <GUIUtils.h> +#include "modemedit.h" + +ModemEdit::ModemEdit( QWidget * Parent ) : ModemGUI( Parent ){ + +} + +QString ModemEdit::acceptable( void ) { + return QString(); +} + +bool ModemEdit::commit( ModemData_t & Data ) { + return 0; +} + +void ModemEdit::showData( ModemData_t & Data ) { +} + diff --git a/noncore/settings/networksettings2/modem/modemedit.h b/noncore/settings/networksettings2/modem/modemedit.h new file mode 100644 index 0000000..56e2a82 --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modemedit.h @@ -0,0 +1,12 @@ +#include "modemdata.h" +#include "modemGUI.h" + +class ModemEdit : public ModemGUI { + +public : + + ModemEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( ModemData_t & Data ); + void showData( ModemData_t & Data ); +}; diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h new file mode 100644 index 0000000..719ab2f --- a/dev/null +++ b/noncore/settings/networksettings2/modem/modemrun.h @@ -0,0 +1,22 @@ +#include <asline.h> +#include "modemdata.h" + +class ModemRun : public AsLine { + +public : + + ModemRun( ANetNodeInstance * NNI, + ModemData & Data ) : AsLine ( NNI ) + { } + +protected : + + void detectState( NodeCollection * ) + { } + + bool setState( NodeCollection *, Action_t ) + { return 0; } + + bool canSetState( State_t, Action_t ) + { return 0; } +}; |