25 files changed, 2363 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp new file mode 100644 index 0000000..ee3e92b --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp @@ -0,0 +1,78 @@ +#include "bluetoothBNEP_NN.h" +#include "bluetoothBNEP_NNI.h" +#include "bluetoothRFCOMM_NNI.h" + +// +// +// BLUETOOTH PAN/NAP node +// +// + +static const char * BluetoothBNEPNeeds[] = + { 0 + }; + +static const char * BluetoothBNEPProvides[] = + { "device", + 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +BluetoothBNEPNetNode::BluetoothBNEPNetNode() : + ANetNode(tr("Bluetooth PAN/NAP")) { + InstanceCount = 7; // default +} + +/** + * 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 BluetoothBNEPProvides; +} + +QString BluetoothBNEPNetNode::genNic( long nr ) { + QString S; + return S.sprintf( "bnep%ld", nr ); +} + + +void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { + if( A == "interfacecount" ) { + InstanceCount = V.toLong(); + } +} + +void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { + TS << "interfacecount=" + << InstanceCount + << endl; +} + +extern "C" { +// create plugin registers both BT functions +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new BluetoothBNEPNetNode() ); + PNN.append( new BluetoothRFCOMMNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.h new file mode 100644 index 0000000..5057e6d --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.h @@ -0,0 +1,44 @@ +#ifndef BLUETOOTHBNEP_NETNODE_H +#define BLUETOOTHBNEP_NETNODE_H + +#include "netnode.h" +#include "bluetoothRFCOMM_NN.h" + +class ABluetoothBNEP; + +class BluetoothBNEPNetNode : public ANetNode { + + Q_OBJECT + +public: + + BluetoothBNEPNetNode(); + virtual ~BluetoothBNEPNetNode(); + + virtual QString genNic( long ); + virtual long instanceCount( void ) + { return InstanceCount; } + virtual const QString pixmapName() + { return "Devices/bluetooth"; } + + virtual const QString nodeDescription() ; + virtual ANetNodeInstance * createInstance( void ); + virtual const char ** provides( void ); + virtual const char ** needs( void ); + +private: + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + + // number of interfaces for this device + long InstanceCount; + +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.cpp new file mode 100644 index 0000000..2b17ab5 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.cpp @@ -0,0 +1,46 @@ +#include "bluetoothRFCOMM_NN.h" +#include "bluetoothRFCOMM_NNI.h" + +static const char * BluetoothRFCOMMNeeds[] = + { 0 + }; + +static const char * BluetoothRFCOMMProvides[] = + { "line", + "GPRS" + }; + +BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : + ANetNode( tr("Bluetooth serial link") ) { +} + +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 BluetoothRFCOMMProvides; +} + +void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { +} + +void BluetoothRFCOMMNetNode::saveSpecificAttribute( QTextStream & ) { +} + +// create plugin -> see BNEP diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.h new file mode 100644 index 0000000..cc7037a --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NN.h @@ -0,0 +1,29 @@ +#ifndef BLUETOOTHRFCOMM_NETNODE_H +#define BLUETOOTHRFCOMM_NETNODE_H + +#include "netnode.h" + +class BluetoothRFCOMMNetNode : public ANetNode { + + Q_OBJECT + +public: + + BluetoothRFCOMMNetNode(); + virtual ~BluetoothRFCOMMNetNode(); + + virtual const QString pixmapName() + { return "Devices/bluetooth"; } + + virtual const QString nodeDescription() ; + virtual ANetNodeInstance * createInstance( void ); + virtual const char ** needs( void ); + virtual const char ** provides( void ); + +private: + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); +}; + +#endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp new file mode 100644 index 0000000..1e91ed1 --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp @@ -0,0 +1,162 @@ +#include <qapplication.h> +#include <resources.h> +#include <OTDevice.h> +#include <OTGateway.h> +#include "bluetoothRFCOMMrun.h" + +using namespace Opietooth2; + +BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { + if( OT ) { + OTGateway::releaseOTGateway(); + } +} + +State_t BluetoothRFCOMMRun::detectState( void ) { + + if( ! OT ) { + OT = OTGateway::getOTGateway(); + } + + if( deviceNrOfConnection() >= 0 ) { + return Available; + } + + owarn << "Bluetooth " + << OT->isEnabled() + << oendl; + + return ( OT->isEnabled() ) ? Off : Unavailable; +} + +QString BluetoothRFCOMMRun::setMyState( NodeCollection *, + Action_t A, + bool ) { + + if( OT ) { + OTGateway::getOTGateway(); + } + + if( A == Activate ) { + // from OFF to Available + RFCOMMChannel * Ch = getChannel( ); + System & Sys = NSResources->system(); + + if( Ch ) { + // connect to this peer + DeviceNr = OT->getFreeRFCommDevice(); + QStringList S; + + S << "rfcomm" + << "bind" + << QString().setNum( DeviceNr ) + << Ch->BDAddress + << QString().setNum( Ch->Channel ); + + if( Sys.runAsRoot( S ) ) { + return QString( "Error starting %1").arg(S.join(" ")); + } + + // here rfcomm should be running -> we will detect state later + return QString(); + } else { + Log(( "No channel selected -> cancel\n" )); + return QString( "No channel selected. Operation cancelled" ); + } + } + + if( A == Deactivate ) { + if( DeviceNr >= 0 ) { + if( OT->releaseRFCommDevice( DeviceNr ) ) { + return QString( "Cannot release RFCOMM connection" ); + } + DeviceNr = -1; + } + } + return QString(); +} + +#include <qlistbox.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qdialog.h> + +RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { + + if( Data->Devices.count() == 1 ) { + // only one device -> return channel + return Data->Devices[0]; + } + + RFCOMMChannel * Ch = 0; + QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); + QVBoxLayout * V = new QVBoxLayout( Dlg ); + + QLabel * L = new QLabel( + qApp->translate( "BluetoothRFCOMMRun", + "Select device to connect to"), + Dlg ); + QListBox * LB = new QListBox( Dlg ); + + for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { + LB->insertItem( QString( "%1 (%2 Chnl %3)" ). + arg( Data->Devices[i]->Name ). + arg( Data->Devices[i]->BDAddress ). + arg( Data->Devices[i]->Channel ) ); + } + + V->addWidget( L ); + V->addWidget( LB ); + + Dlg->resize( 100, 100 ); + Dlg->move( 20, + (qApp->desktop()->height()-100)/2 ); + + if( Dlg->exec() == QDialog::Accepted ) { + unsigned int i = 0; + for( i = 0; i < Data->Devices.count(); i ++ ) { + if( LB->isSelected(i) ) { + owarn << "Selected " << Data->Devices[i]->Name << oendl; + Ch = Data->Devices[i]; + break; + } + } + } + + delete Dlg; + return Ch; +} + +QString BluetoothRFCOMMRun::deviceFile( void ) { + if( deviceNrOfConnection() >= 0 ) { + OTDevice * OTD = OT->getOTDevice(); + // there is a connection + return OTD->getRFCommDevicePattern().arg(DeviceNr); + } + return QString(); +} + +int BluetoothRFCOMMRun::deviceNrOfConnection( void ) { + + if( ! OT ) { + OT = OTGateway::getOTGateway(); + } + + DeviceNr = -1; + for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { + owarn << "Check for rfcomm on " + << Data->Devices[i]->BDAddress + << " " + << Data->Devices[i]->Channel + << oendl; + if( ( DeviceNr = OT->connectedToRFCommChannel( + OTDeviceAddress( Data->Devices[i]->BDAddress ), + Data->Devices[i]->Channel ) ) >= 0 ) { + owarn << "Up " + << oendl; + break; + } + } + return DeviceNr; +} diff --git a/noncore/settings/networksettings2/gprs/GPRS.pro b/noncore/settings/networksettings2/gprs/GPRS.pro new file mode 100644 index 0000000..7818415 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRS.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = GPRS_NN.h \ + GPRS_NNI.h \ + GPRSedit.h +SOURCES = GPRS_NN.cpp \ + GPRS_NNI.cpp \ + GPRSedit.cpp \ + GPRSrun.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = GPRSGUI.ui +TARGET = GPRS +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/gprs/GPRSGUI.ui b/noncore/settings/networksettings2/gprs/GPRSGUI.ui new file mode 100644 index 0000000..1ba5971 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSGUI.ui @@ -0,0 +1,910 @@ +<!DOCTYPE UI><UI> +<class>GPRSGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>GPRSGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>326</width> + <height>418</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>GPRS Configuration</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>0</number> + </property> + <widget> + <class>QTabWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>TabWidget2</cstring> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Login</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</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="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>User_LE</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_3_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>User</string> + </property> + </widget> + <widget row="2" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Password_LE</cstring> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>APN</string> + </property> + </widget> + <widget row="2" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_3_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Password</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>wordwrap</name> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>APN_LE</cstring> + </property> + </widget> + </grid> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer9</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> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>DNS</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>AssignedByServer_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>As assigned by server</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</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>0</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer14</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QFrame</class> + <property stdset="1"> + <name>name</name> + <cstring>Frame5</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>NoFrame</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Raised</enum> + </property> + <property> + <name>layoutMargin</name> + </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="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>DNS2_LE</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + </widget> + <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>DNS2</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>DNS1</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>DNS1_LE</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + </widget> + </grid> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer13</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</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> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer15</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> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Routing</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>0</number> + </property> + <widget> + <class>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup1</cstring> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>NoFrame</enum> + </property> + <property stdset="1"> + <name>title</name> + <string></string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>-3</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>DefaultGateway_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Set as default gateway</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout13</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>0</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer8</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>SetIfSet_CB</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Set even if Set</string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer17</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</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> + </hbox> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>FixedGateway_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Fixed Routing</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout11</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer8_2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QFrame</class> + <property stdset="1"> + <name>name</name> + <cstring>Frame3</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>NoFrame</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Raised</enum> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</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>3</number> + </property> + <widget row="0" column="1" rowspan="1" colspan="3" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Net_LE</cstring> + </property> + </widget> + <widget row="1" column="1" > + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Mask_SB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>32</number> + </property> + <property stdset="1"> + <name>minValue</name> + <number>1</number> + </property> + <property stdset="1"> + <name>value</name> + <number>24</number> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_6</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Mask</string> + </property> + </widget> + <widget row="1" column="3" > + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Delete_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_5_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Net</string> + </property> + </widget> + <widget row="1" column="2" > + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Add_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Network</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>Mask</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>Routing_LV</cstring> + </property> + <property stdset="1"> + <name>selectionMode</name> + <enum>Extended</enum> + </property> + <property stdset="1"> + <name>allColumnsShowFocus</name> + <bool>true</bool> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </vbox> + </widget> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Misc</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</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>TextLabel1_4</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Debug</string> + </property> + </widget> + <widget> + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Debug_SB</cstring> + </property> + <property stdset="1"> + <name>maxValue</name> + <number>3</number> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</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> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3</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> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>AssignedByServer_CB</sender> + <signal>toggled(bool)</signal> + <receiver>Frame5</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>FixedGateway_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Frame3</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>DefaultGateway_RB</sender> + <signal>toggled(bool)</signal> + <receiver>SetIfSet_CB</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Add_TB</sender> + <signal>clicked()</signal> + <receiver>GPRSGUI</receiver> + <slot>SLOT_AddRoute()</slot> + </connection> + <connection> + <sender>Delete_TB</sender> + <signal>clicked()</signal> + <receiver>GPRSGUI</receiver> + <slot>SLOT_DeleteRoute()</slot> + </connection> + <slot access="public">SLOT_AddRoute()</slot> + <slot access="public">SLOT_AddServer()</slot> + <slot access="public">SLOT_RemoveServer()</slot> + <slot access="public">SLOT_DeleteRoute()</slot> +</connections> +<tabstops> + <tabstop>APN_LE</tabstop> + <tabstop>User_LE</tabstop> + <tabstop>Password_LE</tabstop> + <tabstop>DNS1_LE</tabstop> + <tabstop>DNS2_LE</tabstop> +</tabstops> +</UI> diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp new file mode 100644 index 0000000..5393324 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp @@ -0,0 +1,80 @@ +#include <resources.h> +#include <qpe/qpeapplication.h> +#include <netnode.h> +#include "GPRS_NN.h" +#include "GPRS_NNI.h" + +static const char * GPRSNeeds[] = + { "GPRS", + 0 + }; + +static const char * GPRSProvides[] = + { "connection", + 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) { + NSResources->addSystemFile( + "pap-secrets", "/etc/ppp/pap-secrets", 0 ); +} + +/** + * Delete any interfaces that we own. + */ +GPRSNetNode::~GPRSNetNode(){ +} + +const QString GPRSNetNode::nodeDescription(){ + return tr("\ +<p>provides access to a GPRS capable device.</p>\ +" +); +} + +ANetNodeInstance * GPRSNetNode::createInstance( void ) { + return new AGPRSDevice( this ); +} + +bool GPRSNetNode::hasDataForFile( SystemFile & S ) { + return S.name() == "pap-secrets"; +} + +short GPRSNetNode::generateFile( SystemFile & , + ANetNodeInstance * , + long ) { + + return 0; +} + +const char ** GPRSNetNode::needs( void ) { + return GPRSNeeds; +} + +const char ** GPRSNetNode::provides( void ) { + return GPRSProvides; +} + +void GPRSNetNode::setSpecificAttribute( QString & , QString & ) { +} + +void GPRSNetNode::saveSpecificAttribute( QTextStream & ) { +} + +QStringList GPRSNetNode::properFiles( void ) { + QStringList SL; + + SL << "peers"; + SL << "chatscripts"; + SL << "extra"; + return SL; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new GPRSNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.h b/noncore/settings/networksettings2/gprs/GPRS_NN.h new file mode 100644 index 0000000..6a036e1 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRS_NN.h @@ -0,0 +1,43 @@ +#ifndef GPRS_NETNODE_H +#define GPRS_NETNODE_H + +#include "netnode.h" + +class ANetwork; + +class GPRSNetNode : public ANetNode{ + + Q_OBJECT + +public: + + GPRSNetNode(); + virtual ~GPRSNetNode(); + + virtual bool hasDataForFile( SystemFile & S ); + + virtual short generateFile( SystemFile & Sf, + ANetNodeInstance * NNI, + long DevNr ); + virtual const QString pixmapName() + { return "Devices/gprs"; } + + virtual QStringList properFiles( void ); + + virtual const QString nodeDescription() ; + virtual ANetNodeInstance * createInstance( void ); + virtual const char ** needs( void ); + virtual const char ** provides( void ); + +private: + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); +}; + +extern "C" +{ + void create_plugin( QList<ANetNode> & PNN ); +}; + +#endif diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp new file mode 100644 index 0000000..2f61cba --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp @@ -0,0 +1,231 @@ +#include <system.h> +#include <netnode.h> +#include "GPRSedit.h" +#include "GPRS_NNI.h" +#include "GPRS_NN.h" + +AGPRSDevice::AGPRSDevice( GPRSNetNode * PNN ) : ANetNodeInstance( PNN ) { + Data.APN = ""; + Data.User = ""; + Data.Password = ""; + Data.DefaultGateway = 1; + Data.SetIfSet = 0; + Data.Debug = 0; + Data.Routing.setAutoDelete( TRUE ); + GUI = 0; + RT = 0; +} + +void AGPRSDevice::setSpecificAttribute( QString & A, QString & V ) { + if( A == "apn" ) { + Data.APN = V; + } else if( A == "user" ) { + Data.User = V; + } else if( A == "password" ) { + Data.Password = V; + } else if( A == "dns2" ) { + Data.DNS2 = V; + } else if( A == "dns1" ) { + Data.DNS1 = V; + } else if( A == "defaultgateway" ) { + Data.DefaultGateway = (V=="yes"); + } else if( A == "setifset" ) { + Data.SetIfSet = (V == "yes"); + } else if( A == "routes" ) { + Data.Routing.resize( V.toULong() ); + } else if( A.startsWith( "route" ) ) { + QStringList SL = QStringList::split( "/", V ); + GPRSRoutingEntry * E = new GPRSRoutingEntry; + + E->Address = SL[0]; + E->Mask = SL[1].toULong(); + + Data.Routing.insert( A.mid(5).toULong(), E ); + } else if( A == "debug" ) { + Data.Debug = V.toShort(); + } +} + +void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) { + TS << "apn=" << Data.APN << endl; + TS << "user=" << Data.User << endl; + TS << "password=" << Data.Password << endl; + TS << "dns1=" << Data.DNS1 << endl; + TS << "dns2=" << Data.DNS2 << endl; + TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl; + TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl; + TS << "debug=" << Data.Debug << endl; + + TS << "routes=" << Data.Routing.count() << oendl; + for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) { + TS << "route" << i << "=" + << Data.Routing[i]->Address + << "/" + << Data.Routing[i]->Mask + << oendl; + } +} + +QWidget * AGPRSDevice::edit( QWidget * parent ) { + GUI = new GPRSEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString AGPRSDevice::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void AGPRSDevice::commit( void ) { + if( GUI && GUI->commit( Data ) ) + setModified( 1 ); +} + +bool AGPRSDevice::hasDataForFile( SystemFile & S ) { + return S.name() == "pap-secrets" || + S.name() == "peers" || + S.name() == "extra" || + S.name() == "chatscripts" ; +} + +short AGPRSDevice::generateFile( SystemFile & SF, + long + ) { + + if( SF.name() == "pap-secrets" ) { + SF << Data.User + << " * " + << Data.Password + << " *" + << endl; + return 0; + } else if( SF.name() == "chatscripts" ) { + SF << "SAY \"Starting\\n\"" << oendl; + SF << "ECHO OFF" << oendl; + SF << "ABORT BUSY" << oendl; + SF << "ABORT ERROR" << oendl; + SF << "ABORT VOICE" << oendl; + SF << "ABORT \"NO CARRIER\"" << oendl; + SF << "ABORT \"NO DIALTONE\"" << oendl; + SF << "\"\" AT" << oendl; + SF << "OK AT+CGATT=1" << oendl; + SF << "OK AT+CGDCONT=1,\"IP\",\"" + << Data.APN + << "\"" + << oendl; + SF << "OK ATD*99***1#\\n" << oendl; + SF << "TIMEOUT 10" << oendl; + SF << "CONNECT \"\"" << oendl; + SF << "SAY \"READY\\n\"" << oendl; + return 0; + } else if( SF.name() == "peers" ) { + SF << "noauth" << oendl; + SF << "user " << Data.User << oendl; + SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/" + << removeSpaces( connection()->name() ) + << "\"" + << oendl; + SF << "ipcp-accept-local" << oendl; + SF << "ipcp-accept-remote" << oendl; + if( Data.DefaultGateway ) { + SF << "defaultroute" << oendl; + if( Data.SetIfSet ) { + SF << "replacedefaultroute" << oendl; + } + } + if( Data.Debug ) { + SF << "logfile /tmp/" + << removeSpaces( connection()->name() ) + << oendl; + for( int i = 0; i < Data.Debug; i ++ ) { + SF << "debug" << oendl; + } + } + SF << "nocrtscts" << oendl; + SF << "local" << oendl; + SF << "lcp-echo-interval 0" << oendl; + SF << "lcp-echo-failure 0" << oendl; + SF << "usepeerdns" << oendl; + SF << "linkname " << removeSpaces( connection()->name() ) << oendl; + SF << "nopersist" << oendl; + SF << "ipparam " << removeSpaces( connection()->name() ) <<oendl; + SF << "maxfail 1" << oendl; + return 0; + } else if( SF.name() == "extra" ) { + unsigned long Bits; + // generate 'fixed' settings + for( unsigned int i = 0 ; + i < Data.Routing.count(); + i ++ ) { + if( Data.Routing[i]->Mask == 32 ) { + Bits = 0xffffffff; + } else { + Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1); + } + SF << "route add -net " + << Data.Routing[i]->Address + << " netmask " + << ((Bits&0xff000000)>>24) + << "." + << ((Bits&0x00ff0000)>>16) + << "." + << ((Bits&0x0000ff00)>>8) + << "." + << ((Bits&0x000000ff)) + << " gw $PPP_REMOTE" + << oendl; + SF << "route del -net " + << Data.Routing[i]->Address + << " netmask " + << ((Bits&0xff000000)>>24) + << "." + << ((Bits&0x00ff0000)>>16) + << "." + << ((Bits&0x0000ff00)>>8) + << "." + << ((Bits&0x000000ff)) + << " gw $PPP_REMOTE" + << oendl; + } + + if( ! Data.DNS1.isEmpty() ) { + SF << "nameserver " + << Data.DNS1 + << " # profile " + << removeSpaces( connection()->name() ) + <<oendl; + } + + if( ! Data.DNS2.isEmpty() ) { + SF << "nameserver " + << Data.DNS2 + << " # profile " + << removeSpaces( connection()->name() ) + <<oendl; + } + } + return 1; +} + +bool AGPRSDevice::openFile( SystemFile & SF ) { + if( SF.name() == "peers" ) { + SF.setPath( + QString( "/etc/ppp/peers/" ) + + removeSpaces( connection()->name() ) + ); + return 1; + } else if ( SF.name() == "chatscripts" ) { + SF.setPath( + QString( "/etc/chatscripts/" ) + + removeSpaces( connection()->name() ) + ); + return 1; + } else if ( SF.name() == "extra" ) { + SF.setPath( + QString( "/etc/ppp/" ) + + removeSpaces( connection()->name() ) + ".fixed" + ); + return 1; + } + return 0; +} diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.h b/noncore/settings/networksettings2/gprs/GPRS_NNI.h new file mode 100644 index 0000000..1060a6e --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.h @@ -0,0 +1,48 @@ +#ifndef GPRS_H +#define GPRS_H + +#include <netnode.h> +#include "GPRSdata.h" +#include "GPRSrun.h" + +class GPRSNetNode; +class GPRSEdit; +class SystemFile; + +class AGPRSDevice : public ANetNodeInstance{ + +public : + + AGPRSDevice( GPRSNetNode * PNN ); + + RuntimeInfo * runtime( void ) + { return + ( RT ) ? RT : ( RT = new GPRSRun( this, Data ) ); + } + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + virtual bool openFile( SystemFile & SF ); + + virtual void * data( void ) + { return (void *)&Data; } + + virtual bool hasDataForFile( SystemFile & S ); + virtual short generateFile( SystemFile & SF, + long DevNr ); + +protected : + + virtual void setSpecificAttribute( QString & Attr, QString & Value ); + virtual void saveSpecificAttribute( QTextStream & TS ); + +private : + + GPRSEdit * GUI; + GPRSData Data; + GPRSRun * RT; +}; + +#endif diff --git a/noncore/settings/networksettings2/gprs/GPRSdata.h b/noncore/settings/networksettings2/gprs/GPRSdata.h new file mode 100644 index 0000000..d68c3f2 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSdata.h @@ -0,0 +1,24 @@ +#ifndef GPRS_DATA_H +#define GPRS_DATA_H + +#include <qvector.h> +class GPRSRoutingEntry { +public : + QString Address; + short Mask; +}; + +class GPRSData { +public : + QString APN; + QString User; + QString Password; + QString DNS1; + QString DNS2; + bool SetIfSet; + bool DefaultGateway; + short Debug; + QVector<GPRSRoutingEntry> Routing; +} ; + +#endif diff --git a/noncore/settings/networksettings2/gprs/GPRSedit.cpp b/noncore/settings/networksettings2/gprs/GPRSedit.cpp new file mode 100644 index 0000000..d72b9a2 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSedit.cpp @@ -0,0 +1,164 @@ +#include <qtoolbutton.h> +#include <qlistview.h> +#include <qheader.h> +#include <qspinbox.h> +#include <qradiobutton.h> +#include <qcheckbox.h> +#include <qtabwidget.h> +#include <qlineedit.h> +#include <qlistbox.h> +#include <GUIUtils.h> +#include <resources.h> +#include "GPRSedit.h" + +GPRSEdit::GPRSEdit( QWidget * Parent ) : GPRSGUI( Parent ){ + Routing_LV->header()->hide(); + Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); + Delete_TB->setPixmap( NSResources->getPixmap( "delete" ) ); + Routing_LV->setColumnAlignment( 1, Qt::AlignRight ); +} + +QString GPRSEdit::acceptable( void ) { + if( APN_LE->text().isEmpty() ) { + return tr("APN is required"); + } + + return QString(); +} + +bool GPRSEdit::commit( GPRSData & Data ) { + bool SM = 0; + bool RM; + + TXTM( Data.APN, APN_LE, SM ); + TXTM( Data.User, User_LE, SM ); + TXTM( Data.Password, Password_LE, SM ); + + if( AssignedByServer_CB->isChecked() ) { + if( ! Data.DNS1.isEmpty() ) { + SM = 1; + Data.DNS1 = ""; + } + if( ! Data.DNS2.isEmpty() ) { + SM = 1; + Data.DNS2 = ""; + } + } else { + TXTM( Data.DNS1, DNS1_LE, SM ); + TXTM( Data.DNS2, DNS2_LE, SM ); + } + + CBM( Data.DefaultGateway, DefaultGateway_RB, SM ); + CBM( Data.SetIfSet, SetIfSet_CB, SM ); + + // find new routes + unsigned int i; + + RM = 0; // routing modified + QListViewItem * it = Routing_LV->firstChild(); + while( ! RM && it ) { + for( i = 0; i < Data.Routing.count(); i ++ ) { + if( it->text(0) == Data.Routing[i]->Address ) { + // still exists + break; + } + } + if( i == Data.Routing.count() ) { + // modified + RM = 1; + } + it = it->nextSibling(); + } + + // find obsoleted + for( i = 0; ! RM && i < Data.Routing.count(); i ++ ) { + it = Routing_LV->firstChild(); + while( it ) { + if( it->text(0) == Data.Routing[i]->Address ) { + // still exists + break; + } + it = it->nextSibling(); + } + + if( it == 0 ) { + RM = 1; + } + } + + if( RM ) { + unsigned int i = 0; + GPRSRoutingEntry * E; + // update routing table + Data.Routing.resize(0); + Data.Routing.resize( Routing_LV->childCount() ); + + it = Routing_LV->firstChild(); + while( it ) { + E = new GPRSRoutingEntry; + E->Address = it->text(0); + E->Mask = it->text(1).toShort(); + Data.Routing.insert( i, E ); + i ++; + it = it->nextSibling(); + } + } + + SBM( Data.Debug, Debug_SB, SM ); + return SM; +} + +void GPRSEdit::showData( GPRSData & Data ) { + STXT( Data.APN, APN_LE ); + STXT( Data.User, User_LE ); + STXT( Data.Password, Password_LE ); + + SCB( ( Data.DNS1.isEmpty() && Data.DNS2.isEmpty() ), + AssignedByServer_CB ); + STXT( Data.DNS1, DNS1_LE ); + STXT( Data.DNS2, DNS2_LE ); + + SCB( Data.DefaultGateway, DefaultGateway_RB ); + SCB( (! Data.DefaultGateway), FixedGateway_RB ); + SCB( Data.SetIfSet, SetIfSet_CB ); + + for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) { + QListViewItem * it; + it = new QListViewItem( Routing_LV ); + + it->setText( 0, Data.Routing[i]->Address ); + it->setText( 1, QString().setNum( Data.Routing[i]->Mask ) ); + } + + SSB( Data.Debug, Debug_SB ); +} + +void GPRSEdit::SLOT_AddRoute( void ) { + QListViewItem * it, *last; + QListViewItem * after = Routing_LV->firstChild(); + last = 0; + while( after ) { + if( after->isSelected() ) { + break; + } + last = after; + after = after->nextSibling(); + } + + it = new QListViewItem( Routing_LV, (after) ? after : last ); + + it->setText( 0, Net_LE->text() ); + it->setText( 1, QString().setNum( Mask_SB->value() ) ); +} + +void GPRSEdit::SLOT_DeleteRoute( void ) { + QListViewItem * nit; + QListViewItem * it = Routing_LV->firstChild(); + while( it ) { + nit = it->nextSibling(); + if( it->isSelected() ) { + delete it; + } + it = nit; + } +} diff --git a/noncore/settings/networksettings2/gprs/GPRSedit.h b/noncore/settings/networksettings2/gprs/GPRSedit.h new file mode 100644 index 0000000..35e8ee6 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSedit.h @@ -0,0 +1,20 @@ +#include "GPRSdata.h" +#include "GPRSGUI.h" + +class GPRSEdit : public GPRSGUI { + +public : + + GPRSEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( GPRSData & Data ); + void showData( GPRSData & Data ); + +public slots : + + void SLOT_AddRoute(); + void SLOT_DeleteRoute(); + +private : + +}; diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.cpp b/noncore/settings/networksettings2/gprs/GPRSrun.cpp new file mode 100644 index 0000000..e842b99 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSrun.cpp @@ -0,0 +1,105 @@ +#include <sys/types.h> +#include <signal.h> +#include <errno.h> +#include <qdir.h> +#include <system.h> +#include <resources.h> +#include <netnode.h> +#include "GPRSrun.h" + +State_t GPRSRun::detectState( void ) { + + // is pppd still running ? + // is rfcomm still active + NodeCollection * NC = nodeCollection(); + InterfaceInfo * I = NC->assignedInterface(); + + QDir D("/var/run"); + + if( I ) { + // has some pppx attached + return ( I->IsUp ) ? IsUp : Available; + } + + // check ppp itself and figure out interface + + owarn << "Check for ppp " << NC->name() << oendl; + if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) { + // get pid and check if pppd is still running + QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid"); + + owarn << "PPP PID " << F.name() << oendl; + if( F.open( IO_ReadOnly ) ) { + QTextStream TS(&F); + QString X = TS.readLine(); + PPPPid = X.toULong(); + int rv; + + rv = ::kill( PPPPid, 0 ); + if( rv == 0 || + ( rv < 0 && errno == EPERM ) + ) { + // pppd is still up + X = TS.readLine(); + I = NSResources->system().findInterface(X); + + owarn << "ppp running : IFace " << X << " = " << (long)I << oendl; + + if( I ) { + NC->assignInterface( I ); + return (I->IsUp) ? IsUp : Available; + } + + return Available; + + } else { + // pppd is down + PPPPid = 0; + } + } // else pppd is down + } + NC->assignInterface( 0 ); + return Unknown; +} + +QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) { + + if( A == Up ) { + // start ppp on deviceFile + QStringList SL; + SL << "pon" + << removeSpaces( NC->name() ) + << NC->device()->deviceFile(); + + if( ! NSResources->system().execAsUser( SL ) ) { + return QString("Cannot start pppd for %1").arg(NC->name()); + } + } else if ( A == Down ) { + if( PPPPid == 0 ) { + detectState(); + } + if( PPPPid ) { + QStringList SL; + + SL << "poff" + << removeSpaces( NC->name() ); + + if( ! NSResources->system().execAsUser( SL ) ) { + return QString("Cannot terminate pppd for %1").arg(NC->name()); + } + NC->assignInterface( 0 ); + owarn << "ppp stopped " << oendl; + PPPPid = 0; + } + } + + return QString(); +} + +bool GPRSRun::handlesInterface( const QString & S ) { + return Pat.match( S ) >= 0; +} + +bool GPRSRun::handlesInterface( InterfaceInfo * I ) { + return handlesInterface( I->Name ); +} diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.h b/noncore/settings/networksettings2/gprs/GPRSrun.h new file mode 100644 index 0000000..817f8a9 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/GPRSrun.h @@ -0,0 +1,34 @@ +#include <netnode.h> +#include <qregexp.h> +#include "GPRSdata.h" + +class GPRSRun : public RuntimeInfo { + +public : + + GPRSRun( ANetNodeInstance * NNI, + GPRSData & D ) : RuntimeInfo( NNI ), + Pat( "ppp[0-9]" ) { + PPPPid = 0; + } + + bool handlesInterface( const QString & I ); + bool handlesInterface( InterfaceInfo * ); + + virtual RuntimeInfo * device( void ) + { return this; } + virtual RuntimeInfo * connection( void ) + { return this; } + + State_t detectState( void ); + +protected : + + QString setMyState( NodeCollection * , Action_t, bool ); + +private : + + QRegExp Pat; + size_t PPPPid; + +}; diff --git a/noncore/settings/networksettings2/gprs/config.in b/noncore/settings/networksettings2/gprs/config.in new file mode 100644 index 0000000..ec29264 --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/config.in @@ -0,0 +1,4 @@ + config NS2GPRS + boolean "opie-networksettings2plugin-gprs (set up GPRS)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE diff --git a/noncore/settings/networksettings2/gprs/opie-networksettings2plugin-network.control b/noncore/settings/networksettings2/gprs/opie-networksettings2plugin-network.control new file mode 100644 index 0000000..902ebff --- a/dev/null +++ b/noncore/settings/networksettings2/gprs/opie-networksettings2plugin-network.control @@ -0,0 +1,9 @@ +Package: opie-networksettings2plugin-GPRS +Files: plugins/networksettings2/libGPRS.so* +Priority: optional +Section: opie/settings +Maintainer: Wim Delvaux <wimpie@handhelds.org> +Architecture: arm +Depends: opie-networksettings2, libopiecore2, libopienet2 +Description: Setup GPRS network +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/networksettings2/opie-networksettings2.control b/noncore/settings/networksettings2/opie-networksettings2.control new file mode 100644 index 0000000..e4bd29c --- a/dev/null +++ b/noncore/settings/networksettings2/opie-networksettings2.control @@ -0,0 +1,10 @@ +Package: opie-networksettings2 +Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png +Priority: optional +Section: opie/settings +Maintainer: wim delvaux <wimpie@handhelds.org> +Architecture: arm +Depends: task-opie-minimal, libopietooth2 +Description: Network settings. +Replaces: opie-networksetup +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/networksettings2/opie-networksettings2.postinst b/noncore/settings/networksettings2/opie-networksettings2.postinst new file mode 100755 index 0000000..ce43274 --- a/dev/null +++ b/noncore/settings/networksettings2/opie-networksettings2.postinst @@ -0,0 +1,9 @@ +#!/bin/sh + +QTPB=/opt/QtPalmtop/bin + +[ ! -L ${QTPB}/networksettings2-request ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-request + +qcop QPE/TaskBar "reloadApps()" + +exit 0 diff --git a/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp new file mode 100644 index 0000000..9264ceb --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <qcombobox.h> +#include <qmessagebox.h> +#include <qradiobutton.h> +#include <qlineedit.h> +#include <GUIUtils.h> +#include "PPPDialingedit.h" + +PPPDialingEdit::PPPDialingEdit( QWidget * Parent ) : + PPPDialingGUI( Parent ){ + + // populate widget stack +} + +QString PPPDialingEdit::acceptable( void ) { + return QString(); +} + +bool PPPDialingEdit::commit( PPPData & D ) { + bool SM; + return SM; +} + +void PPPDialingEdit::showData( PPPData & D ) { +} diff --git a/noncore/settings/networksettings2/ppp/PPPDialingedit.h b/noncore/settings/networksettings2/ppp/PPPDialingedit.h new file mode 100644 index 0000000..016bb3b --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDialingedit.h @@ -0,0 +1,16 @@ +#include "pppdata.h" +#include "PPPDialingGUI.h" + +class PPPDialingEdit : public PPPDialingGUI { + +public : + + PPPDialingEdit( QWidget * parent ); + + QString acceptable( void ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); + +private : + +}; diff --git a/noncore/settings/networksettings2/ppp/PPPRunGUI.ui b/noncore/settings/networksettings2/ppp/PPPRunGUI.ui new file mode 100644 index 0000000..4532065 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPRunGUI.ui @@ -0,0 +1,207 @@ +<!DOCTYPE UI><UI> +<class>PPPRunGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PPPRunGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>210</width> + <height>272</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>PPPRun</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Upon connect</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PreConnect_LE</cstring> + </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>Before</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PostConnect_LE</cstring> + </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>text</name> + <string>After</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1_2</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Upon disconnect</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PreDisconnect_LE</cstring> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Before</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PostDisconnect_LE</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>After</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string><UL> +<LI>Commands run under your <b>real</b> user id (<b>not</b> as root)</LI> +<LI>Supply the whole path</LI> +</UL></string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property> + <name>wordwrap</name> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer1</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/ppp/PPPRunedit.cpp b/noncore/settings/networksettings2/ppp/PPPRunedit.cpp new file mode 100644 index 0000000..23fcd3c --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPRunedit.cpp @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <qcombobox.h> +#include <qmessagebox.h> +#include <qradiobutton.h> +#include <qlineedit.h> +#include <GUIUtils.h> +#include "PPPRunedit.h" + +PPPRunEdit::PPPRunEdit( QWidget * Parent ) : PPPRunGUI( Parent ){ +} + +QString PPPRunEdit::acceptable( void ) { + return QString(); +} + +bool PPPRunEdit::commit( PPPData & D ) { + bool SM = 0; + + TXTM( D.Run.PreConnect, PreConnect_LE, SM ); + TXTM( D.Run.PostConnect, PostConnect_LE, SM ); + TXTM( D.Run.PreDisconnect, PreDisconnect_LE, SM ); + TXTM( D.Run.PostDisconnect, PostDisconnect_LE, SM ); + return SM; +} + +void PPPRunEdit::showData( PPPData & D ) { + STXT( D.Run.PreConnect, PreConnect_LE); + STXT( D.Run.PostConnect, PostConnect_LE); + STXT( D.Run.PreDisconnect, PreDisconnect_LE ); + STXT( D.Run.PostDisconnect, PostDisconnect_LE); +} diff --git a/noncore/settings/networksettings2/ppp/PPPRunedit.h b/noncore/settings/networksettings2/ppp/PPPRunedit.h new file mode 100644 index 0000000..4205512 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPRunedit.h @@ -0,0 +1,16 @@ +#include "pppdata.h" +#include "PPPRunGUI.h" + +class PPPRunEdit : public PPPRunGUI { + +public : + + PPPRunEdit( QWidget * parent ); + + QString acceptable( void ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); + +private : + +}; |