Diffstat (limited to 'noncore/settings/networksettings2/ppp') (more/less context) (ignore whitespace changes)
20 files changed, 2101 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui new file mode 100644 index 0000000..826843a --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui @@ -0,0 +1,432 @@ +<!DOCTYPE UI><UI> +<class>PPPAuthGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PPPAuthGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>249</width> + <height>209</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>PPPAuth</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>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>0</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Login_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Login</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout3</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>Spacer3</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>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </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>title</name> + <string></string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>1</number> + </property> + <widget row="0" column="0" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>LoginExpect_LE</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ogin:</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>LoginSend_LE</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PasswordExpect_LE</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>assword:</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>PasswordSend_LE</cstring> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>PapChap_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Pap/Chap/EAP</string> + </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> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3_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>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox3</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>title</name> + <string></string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>1</number> + </property> + <widget row="2" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server</string> + </property> + </widget> + <widget row="3" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Secret</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>PAP</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>CHAP</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>EAP</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>AuthMethod_CB</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Client</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Method</string> + </property> + </widget> + <widget row="1" column="1" rowspan="1" colspan="2" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Client_LE</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>*</string> + </property> + </widget> + <widget row="2" column="1" rowspan="1" colspan="2" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Server_LE</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>*</string> + </property> + </widget> + <widget row="3" column="1" rowspan="1" colspan="2" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>Secret_LE</cstring> + </property> + </widget> + <spacer row="0" column="2" > + <property> + <name>name</name> + <cstring>Spacer7</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> + </grid> + </widget> + </hbox> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Terminal_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Terminal</string> + </property> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>PapChap_RB</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox3</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Login_RB</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox1</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +</UI> diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp new file mode 100644 index 0000000..f305cc4 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp @@ -0,0 +1,85 @@ +#include <stdio.h> +#include <qcombobox.h> +#include <qmessagebox.h> +#include <qradiobutton.h> +#include <qlineedit.h> +#include <GUIUtils.h> +#include "PPPAuthedit.h" + +PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){ +} + +QString PPPAuthEdit::acceptable( void ) { + if( Login_RB->isChecked() ) { + if( LoginSend_LE->text().isEmpty() ) + return tr("Login send missing"); + if( LoginExpect_LE->text().isEmpty() ) + return tr("Login expect missing"); + if( PasswordSend_LE->text().isEmpty() ) + return tr("Password send missing"); + if( PasswordExpect_LE->text().isEmpty() ) + return tr("Password expect missing"); + } else if( PapChap_RB->isChecked() ) { + if( Client_LE->text().isEmpty() ) + return tr("Pap/Chap/EAP client id missing"); + if( Server_LE->text().isEmpty() ) + return tr("Pap/Chap/EAP server id missing"); + if( Secret_LE->text().isEmpty() ) + return tr("Pap/Chap/EAP secret id missing"); + } + return QString(); +} + +bool PPPAuthEdit::commit( PPPData_t & D ) { + bool SM = 0; + + if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || + ( D.Auth.Mode == 1 && ! PapChap_RB->isChecked() ) || + ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) { + // mode modifed + SM = 1; + D.Auth.Mode = ( Login_RB->isChecked() ) ? + 0 : + ( ( PapChap_RB->isChecked() ) ? + 1 : 2 ); + } + + if( Login_RB->isChecked() ) { + TXTM( D.Auth.Login.Expect, LoginExpect_LE, SM ); + TXTM( D.Auth.Login.Send, LoginSend_LE, SM ); + TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM ); + TXTM( D.Auth.Password.Send, PasswordSend_LE, SM ); + } else if( PapChap_RB->isChecked() ) { + TXTM( D.Auth.Client, Client_LE, SM ); + TXTM( D.Auth.Server, Server_LE, SM ); + TXTM( D.Auth.Secret, Secret_LE, SM ); + CIM( D.Auth.PCEMode, AuthMethod_CB, SM ); + } + return SM; +} + +void PPPAuthEdit::showData( PPPData_t & D ) { + + switch( D.Auth.Mode ) { + case 0 : + Login_RB->isChecked(); + break; + case 1 : + PapChap_RB->isChecked(); + break; + case 2 : + Terminal_RB->isChecked(); + break; + } + + LoginExpect_LE->setText( D.Auth.Login.Expect ); + PasswordExpect_LE->setText( D.Auth.Password.Expect ); + LoginSend_LE->setText( D.Auth.Login.Send ); + PasswordSend_LE->setText( D.Auth.Password.Send ); + + Client_LE->setText( D.Auth.Client ); + Server_LE->setText( D.Auth.Server ); + Secret_LE->setText( D.Auth.Secret ); + + AuthMethod_CB->setCurrentItem( D.Auth.PCEMode ); +} diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h new file mode 100644 index 0000000..cbd540e --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h @@ -0,0 +1,15 @@ +#include "pppdata.h" +#include "PPPAuthGUI.h" + +class PPPAuthEdit : public PPPAuthGUI { + +public : + + PPPAuthEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( PPPData_t & Data ); + void showData( PPPData_t & Data ); + +private : + +}; diff --git a/noncore/settings/networksettings2/ppp/PPPDNSGUI.ui b/noncore/settings/networksettings2/ppp/PPPDNSGUI.ui new file mode 100644 index 0000000..0ed136f --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDNSGUI.ui @@ -0,0 +1,340 @@ +<!DOCTYPE UI><UI> +<class>PPPDNSGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PPPDNSGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>228</width> + <height>169</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>PPPDNS</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>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup18</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>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>DNSServerAssigned_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server assigned</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>DNSFixed_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Fixed</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout13</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>Spacer29</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>Frame21</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> + <grid> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel5</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>DomainName</string> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel6</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Address</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>DomainName_LE</cstring> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>ServerAddress_LE</cstring> + </property> + </widget> + <widget row="3" column="1" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Servers_LB</cstring> + </property> + </widget> + <widget row="2" column="1" > + <class>QFrame</class> + <property stdset="1"> + <name>name</name> + <cstring>Frame22</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</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> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>0</number> + </property> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Add_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> + </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> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Remove_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> + </property> + </widget> + </hbox> + </widget> + <widget row="3" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel7</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>List</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignTop|AlignLeft</set> + </property> + <property> + <name>vAlign</name> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>DNSFixed_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Frame21</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Add_TB</sender> + <signal>clicked()</signal> + <receiver>PPPDNSGUI</receiver> + <slot>SLOT_AddServer()</slot> + </connection> + <connection> + <sender>Remove_TB</sender> + <signal>clicked()</signal> + <receiver>PPPDNSGUI</receiver> + <slot>SLOT_RemoveServer()</slot> + </connection> + <slot access="public">SLOT_AddServer()</slot> + <slot access="public">SLOT_RemoveServer()</slot> +</connections> +</UI> diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp new file mode 100644 index 0000000..22f8e59 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp @@ -0,0 +1,108 @@ +#include <qtoolbutton.h> +#include <qmessagebox.h> +#include <qlistbox.h> +#include <qlineedit.h> +#include <qradiobutton.h> +#include <resources.h> +#include <GUIUtils.h> +#include "PPPDNSedit.h" + +PPPDNSEdit::PPPDNSEdit( QWidget * Parent ) : PPPDNSGUI( Parent ){ + + Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); + Remove_TB->setPixmap( NSResources->getPixmap( "remove" ) ); +} + +QString PPPDNSEdit::acceptable( void ) { + if( DNSFixed_RB->isChecked() ) { + if( DomainName_LE->text().isEmpty() ) + tr("Domainname needed"); + if( Servers_LB->count() == 0 ) + tr("DNS Servers needed"); + } + return QString(); +} + +bool PPPDNSEdit::commit( PPPData_t & D ) { + bool SM = 0; + + CBM( D.DNS.ServerAssigned, DNSServerAssigned_RB, SM ); + TXTM( D.DNS.DomainName, DomainName_LE, SM ); + + // new items in old ? + for ( unsigned i = 0; i < Servers_LB->count(); i++ ) { + QString S; + bool Found; + Found = 0; + S = Servers_LB->text(i); + for ( unsigned j = 0; j < D.DNS.Servers.size(); j++ ) { + if( *(D.DNS.Servers[i]) == S ) { + // still in list + Found = 1; + break; + } + } + if( ! Found ) { + SM = 1; + D.DNS.Servers.resize( D.DNS.Servers.size()+1 ); + D.DNS.Servers[D.DNS.Servers.size()] = new QString( S ); + } + } + + // old in new ? + for ( unsigned j = 0; j < D.DNS.Servers.size(); j++ ) { + bool Found; + Found = 0; + for ( unsigned i = 0; i < Servers_LB->count(); i++ ) { + if( *(D.DNS.Servers[j]) == Servers_LB->text(i) ) { + // still in list + Found = 1; + break; + } + } + if( ! Found ) { + // old obsolete + SM = 1; + delete D.DNS.Servers[j]; + for( unsigned i = j+1; i < D.DNS.Servers.size(); i ++ ) { + // compress array + D.DNS.Servers[i-1] = D.DNS.Servers[i]; + } + // shrink + D.DNS.Servers.resize( D.DNS.Servers.size()-1 ); + } + } + return SM; +} + +void PPPDNSEdit::showData( PPPData_t & D) { + + DNSServerAssigned_RB->setChecked( D.DNS.ServerAssigned ); + + DomainName_LE->setText( D.DNS.DomainName ); + for( unsigned i = 0; i < D.DNS.Servers.size(); i ++ ) { + Servers_LB->insertItem( *(D.DNS.Servers[i]) ); + } +} + +void PPPDNSEdit::SLOT_AddServer( void ) { + if( ServerAddress_LE->text().isEmpty() ) + return; + + Servers_LB->insertItem( ServerAddress_LE->text() ); + ServerAddress_LE->setText( "" ); +} + +void PPPDNSEdit::SLOT_RemoveServer( void ) { + long i = Servers_LB->currentItem(); + if( i < 0 ) + return; + Servers_LB->removeItem( i ); + if( (unsigned) i >= Servers_LB->count() ) { + i --; + } + if( i >= 0 ) { + Servers_LB->setCurrentItem( i ); + } + +} diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.h b/noncore/settings/networksettings2/ppp/PPPDNSedit.h new file mode 100644 index 0000000..43e0067 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.h @@ -0,0 +1,20 @@ +#include "pppdata.h" +#include "PPPDNSGUI.h" + +class PPPDNSEdit : public PPPDNSGUI { + +public : + + PPPDNSEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( PPPData_t & Data ); + void showData( PPPData_t & Data ); + +public slots : + + void SLOT_AddServer( void ); + void SLOT_RemoveServer( void ); + +private : + +}; diff --git a/noncore/settings/networksettings2/ppp/PPPGUI.ui b/noncore/settings/networksettings2/ppp/PPPGUI.ui new file mode 100644 index 0000000..777e4a9 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPGUI.ui @@ -0,0 +1,103 @@ +<!DOCTYPE UI><UI> +<class>PPPGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PPPGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>124</width> + <height>29</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>PPP</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>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Authentication</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>IP settings</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>DNS Settings</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>PPPOptions_CB</cstring> + </property> + </widget> + <widget> + <class>QWidgetStack</class> + <property stdset="1"> + <name>name</name> + <cstring>Options_WS</cstring> + </property> + </widget> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>QWidgetStack</class> + <header location="global">qwidgetstack.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>7</hordata> + <verdata>7</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + <slot access="public">raiseWidget( int )</slot> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> + </image> +</images> +<connections> + <connection> + <sender>PPPOptions_CB</sender> + <signal>activated(int)</signal> + <receiver>PPPGUI</receiver> + <slot>SLOT_SelectTopic( int )</slot> + </connection> + <slot access="public">SLOT_SelectTopic( int )</slot> +</connections> +</UI> diff --git a/noncore/settings/networksettings2/ppp/PPPIPGUI.ui b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui new file mode 100644 index 0000000..f3d5019 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui @@ -0,0 +1,444 @@ +<!DOCTYPE UI><UI> +<class>PPPIPGUI</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>PPPIPGUI</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>133</width> + <height>235</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>PPPIP</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>2</number> + </property> + <widget> + <class>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup4</cstring> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Box</enum> + </property> + <property stdset="1"> + <name>title</name> + <string>IP</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>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>IPServerAssigned_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server assigned</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>IPFixed_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Fixed</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</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> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + </spacer> + <widget> + <class>QFrame</class> + <property stdset="1"> + <name>name</name> + <cstring>Frame8</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> + <grid> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>IPAddress_LE</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Subnetmask</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>Address</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>IPSubMask_LE</cstring> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget> + <class>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup5</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Gateway</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>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>GWServerAssigned_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server assigned</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>GWFixed_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Fixed</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout12</cstring> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </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>Spacer9</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>Frame9</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> + <grid> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Address</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>GWAddress_LE</cstring> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout3</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>Spacer3</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> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GWIsDefault_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Set as default</string> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>GWFixed_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Frame9</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>IPFixed_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Frame8</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +</UI> diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.cpp b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp new file mode 100644 index 0000000..6965e5a --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp @@ -0,0 +1,57 @@ +#include <qmessagebox.h> +#include <qcheckbox.h> +#include <qradiobutton.h> +#include <qlineedit.h> +#include <GUIUtils.h> +#include "PPPIPedit.h" + +PPPIPEdit::PPPIPEdit( QWidget * Parent ) : PPPIPGUI( Parent ){ +} + +QString PPPIPEdit::acceptable( void ) { + if( IPFixed_RB->isChecked() ) { + if( IPAddress_LE->text().isEmpty() ) + return tr("IPAddress needed" ); + if( ! validIP( IPAddress_LE->text() ) ) + return tr("IPAddress not valid" ); + if( IPSubMask_LE->text().isEmpty() ) + return tr("Subnet mask needed" ); + if( ! validIP( IPSubMask_LE->text() ) ) + return tr("Subnet mask not valid" ); + } else if( GWFixed_RB->isChecked() ) { + if( GWAddress_LE->text().isEmpty() ) + return tr("Gateway address needed" ); + if( ! validIP( GWAddress_LE->text() ) ) + return tr("Gateway address not valid" ); + }; + + return QString(); +} + +bool PPPIPEdit::commit( PPPData_t & D ) { + + bool SM = 0; + + CBM( D.IP.IPAutomatic, IPServerAssigned_RB, SM ); + if( ! D.IP.IPAutomatic ) { + TXTM( D.IP.IPAddress, IPAddress_LE, SM ); + TXTM( D.IP.IPSubMask, IPSubMask_LE, SM ); + } + + CBM( D.IP.GWAutomatic, GWServerAssigned_RB, SM ); + if( ! D.IP.GWAutomatic ) { + TXTM( D.IP.GWAddress, GWAddress_LE, SM ); + } + + CBM( D.IP.GWIsDefault, GWIsDefault_CB, SM ); + return SM; +} + +void PPPIPEdit::showData( PPPData_t & D ) { + IPServerAssigned_RB->setChecked( D.IP.IPAutomatic ); + IPAddress_LE->setText( D.IP.IPAddress ); + IPSubMask_LE->setText( D.IP.IPSubMask ); + GWServerAssigned_RB->setChecked( D.IP.GWAutomatic ); + GWAddress_LE->setText( D.IP.GWAddress ); + GWIsDefault_CB->setChecked( D.IP.GWIsDefault ); +} diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.h b/noncore/settings/networksettings2/ppp/PPPIPedit.h new file mode 100644 index 0000000..153ee68 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPIPedit.h @@ -0,0 +1,15 @@ +#include "pppdata.h" +#include "PPPIPGUI.h" + +class PPPIPEdit : public PPPIPGUI { + +public : + + PPPIPEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( PPPData_t & Data ); + void showData( PPPData_t & Data ); + +private : + +}; diff --git a/noncore/settings/networksettings2/ppp/PPPedit.cpp b/noncore/settings/networksettings2/ppp/PPPedit.cpp new file mode 100644 index 0000000..eb4fdbf --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPedit.cpp @@ -0,0 +1,48 @@ +#include <qwidgetstack.h> + +#include "PPPIPedit.h" +#include "PPPDNSedit.h" +#include "PPPAuthedit.h" +#include "PPPedit.h" + +PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){ + + Auth = new PPPAuthEdit( Options_WS ); + IP = new PPPIPEdit( Options_WS ); + DNS = new PPPDNSEdit( Options_WS ); + Options_WS->addWidget( Auth, 0 ); + Options_WS->addWidget( IP, 1 ); + Options_WS->addWidget( DNS, 2 ); + + Options_WS->raiseWidget( 0 ); +} + +QString PPPEdit::acceptable( void ) { + QString S; + S = Auth->acceptable(); + if( S.isEmpty() ) { + S = IP->acceptable(); + if( S.isEmpty() ) { + S = DNS->acceptable(); + } + } + return S; +} + +bool PPPEdit::commit( PPPData_t & Data ) { + bool SM ; + SM = Auth->commit( Data ); + SM |= IP->commit( Data ); + SM |= DNS->commit( Data ); + return SM; +} + +void PPPEdit::showData( PPPData_t & Data ) { + Auth->showData( Data ) ; + IP->showData( Data ); + DNS->showData( Data ); +} + +void PPPEdit::SLOT_SelectTopic( int v ) { + Options_WS->raiseWidget( v ); +} diff --git a/noncore/settings/networksettings2/ppp/PPPedit.h b/noncore/settings/networksettings2/ppp/PPPedit.h new file mode 100644 index 0000000..57d38ee --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPedit.h @@ -0,0 +1,27 @@ +#include "pppdata.h" +#include "PPPGUI.h" + +class PPPAuthEdit; +class PPPIPEdit; +class PPPDNSEdit; + +class PPPEdit : public PPPGUI { + +public : + + PPPEdit( QWidget * parent ); + QString acceptable( void ); + bool commit( PPPData_t & Data ); + void showData( PPPData_t & Data ); + +public slots : + + void SLOT_SelectTopic( int ); + +private : + + PPPAuthEdit * Auth; + PPPDNSEdit * DNS; + PPPIPEdit * IP; + +}; diff --git a/noncore/settings/networksettings2/ppp/config.in b/noncore/settings/networksettings2/ppp/config.in new file mode 100644 index 0000000..dc3abd0 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/config.in @@ -0,0 +1,4 @@ + config NS2PPP + boolean "opie-networksettings2plugin-ppp (set up PPP)" + default "n" if NS2 + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NS2 && NS2CORE diff --git a/noncore/settings/networksettings2/ppp/ppp.pro b/noncore/settings/networksettings2/ppp/ppp.pro new file mode 100644 index 0000000..f8712cd --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppp.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/plugins/networksettings2 +HEADERS = ppp_NN.h \ + ppp_NNI.h \ + PPPedit.h \ + PPPAuthedit.h \ + PPPDNSedit.h \ + PPPIPedit.h +SOURCES = ppp_NN.cpp \ + ppp_NNI.cpp \ + PPPedit.cpp \ + PPPDNSedit.cpp \ + PPPAuthedit.cpp \ + ppprun.cpp \ + PPPIPedit.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 +LIBS += -lqpe +INTERFACES = PPPGUI.ui PPPAuthGUI.ui PPPIPGUI.ui PPPDNSGUI.ui +TARGET = ppp +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp new file mode 100644 index 0000000..309c9a1 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -0,0 +1,62 @@ +#include "ppp_NN.h" +#include "ppp_NNI.h" + +static const char * PPPNeeds[] = + { "line", + "modem", + 0 + }; + +/** + * Constructor, find all of the possible interfaces + */ +PPPNetNode::PPPNetNode() : ANetNode() { +} + +/** + * Delete any interfaces that we own. + */ +PPPNetNode::~PPPNetNode(){ +} + +const QString PPPNetNode::nodeDescription(){ + return tr("\ +<p>Sets up IP using PPP.</p>\ +<p>Use this for dialup devices or serial setups</p>\ +" +); +} + +ANetNodeInstance * PPPNetNode::createInstance( void ) { + return new APPP( this ); +} + +const char ** PPPNetNode::needs( void ) { + return PPPNeeds; +} + +const char * PPPNetNode::provides( void ) { + return "connection"; +} + +bool PPPNetNode::generateProperFilesFor( + ANetNodeInstance * ) { + return 1; +} + +bool PPPNetNode::hasDataFor( const QString & ) { + return 0; +} + +bool PPPNetNode::generateDataForCommonFile( + SystemFile & , + long, + ANetNodeInstance * ) { + return 1; +} + +extern "C" { +void create_plugin( QList<ANetNode> & PNN ) { + PNN.append( new PPPNetNode() ); +} +} diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h new file mode 100644 index 0000000..a933523 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h @@ -0,0 +1,44 @@ +#ifndef PPP_NETNODE_H +#define PPP_NETNODE_H + +#include "netnode.h" + +class APPP; + +class PPPNetNode : public ANetNode{ + + Q_OBJECT + +public: + + PPPNetNode(); + virtual ~PPPNetNode(); + + virtual const QString pixmapName() + { return "ppp"; } + + virtual const QString nodeName() + { return tr("PPP 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/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp new file mode 100644 index 0000000..d09ecf9 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp @@ -0,0 +1,115 @@ +#include "PPPedit.h" +#include "ppp_NNI.h" +#include "ppp_NN.h" + +APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { + Data.DNS.ServerAssigned = 1; + Data.DNS.DomainName = ""; + + Data.Auth.Mode = 0; + Data.Auth.Login.Expect = "ogin:"; + Data.Auth.Password.Expect = "assword:"; + Data.Auth.PCEMode = 0; + Data.Auth.Client = "*"; + Data.Auth.Server = "*"; + Data.Auth.Secret = ""; + + Data.IP.IPAutomatic = 1; + Data.IP.IPAddress = ""; + Data.IP.IPSubMask = ""; + Data.IP.GWAutomatic = 1; + Data.IP.GWAddress = ""; + Data.IP.GWIsDefault = 1; + GUI = 0; + RT = 0; + +} + +void APPP::setSpecificAttribute( QString & A, QString & V ) { + if( A.startsWith( "dns" ) ) { + if( A == "dnsserverassigned" ) { + Data.DNS.ServerAssigned = (V == "yes"); + } else if( A == "dnsdomainname" ) { + Data.DNS.DomainName = V; + } else if( A == "dnsserver" ) { + Data.DNS.Servers.resize( Data.DNS.Servers.size()+1 ); + Data.DNS.Servers[Data.DNS.Servers.size()-1] = + new QString( V ); + } + } else if( A.startsWith( "auth" ) ) { + if( A == "authmode" ) { + Data.Auth.Mode = V.toShort(); + } else if( A == "authloginexpect" ) { + Data.Auth.Login.Expect = V; + } else if( A == "authloginsend" ) { + Data.Auth.Login.Send = V; + } else if( A == "authpasswordexpect" ) { + Data.Auth.Password.Expect = V; + } else if( A == "authpasswordsend" ) { + Data.Auth.Password.Send = V; + } else if( A == "authpcemode" ) { + Data.Auth.PCEMode = V.toShort(); + } else if( A == "authclient" ) { + Data.Auth.Client = V; + } else if( A == "authserver" ) { + Data.Auth.Server = V; + } else if( A == "authsecret" ) { + Data.Auth.Secret = V; + } + } else if( A.startsWith( "ip" ) ) { + if( A == "ipautomatic" ) { + Data.IP.IPAutomatic = (V == "yes"); + } else if( A == "gwautomatic" ) { + Data.IP.GWAutomatic = (V == "yes"); + } else if( A == "gwisdefault" ) { + Data.IP.GWIsDefault = (V == "yes"); + } else if( A == "ipaddress" ) { + Data.IP.IPAddress = V; + } else if( A == "ipsubmask" ) { + Data.IP.IPSubMask = V; + } else if( A == "gwaddress" ) { + Data.IP.GWAddress = V; + } + } +} + +void APPP::saveSpecificAttribute( QTextStream & TS ) { + TS << "dnsserverassigned=" << + ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; + TS << "dnsdomainname=" << Data.DNS.DomainName << endl; + for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { + TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; + } + TS << "authmode=" << Data.Auth.Mode << endl; + TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; + TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; + TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; + TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; + TS << "authpcemode=" << Data.Auth.PCEMode << endl; + TS << "authclient=" << Data.Auth.Client << endl; + TS << "authserver=" << Data.Auth.Server << endl; + TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; + TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; + TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; + TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; + TS << "ipaddress=" << Data.IP.IPAddress << endl; + TS << "ipsubmask=" << Data.IP.IPSubMask << endl; + TS << "gwaddress=" << Data.IP.GWAddress << endl; +} + +QWidget * APPP::edit( QWidget * parent ) { + GUI = new PPPEdit( parent ); + GUI->showData( Data ); + return GUI; +} + +QString APPP::acceptable( void ) { + return ( GUI ) ? GUI->acceptable( ) : QString(); +} + +void APPP::commit( void ) { + if( GUI && GUI->commit( Data ) ) { + setModified( 1 ); + } +} + diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h new file mode 100644 index 0000000..08dca1d --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h @@ -0,0 +1,43 @@ +#ifndef PPP_H +#define PPP_H + +#include <netnode.h> +#include "pppdata.h" +#include "ppprun.h" + +class PPPNetNode; +class PPPEdit; + +class APPP : public ANetNodeInstance { + +public : + + APPP( PPPNetNode * PNN ); + + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + + RuntimeInfo * runtime( void ) + { if( RT == 0 ) + RT = new PPPRun( 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 : + + PPPEdit * GUI; + PPPData Data; + PPPRun * RT; + +}; + +#endif diff --git a/noncore/settings/networksettings2/ppp/pppdata.h b/noncore/settings/networksettings2/ppp/pppdata.h new file mode 100644 index 0000000..9e8543c --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/pppdata.h @@ -0,0 +1,38 @@ +#ifndef PPP_DATA_H +#define PPP_DATA_H + +#include <qstring.h> +#include <qarray.h> + +typedef struct PPPData { + struct { + bool IPAutomatic; + QString IPAddress; + QString IPSubMask; + bool GWAutomatic; + QString GWAddress; + bool GWIsDefault; + } IP; + struct { + short Mode; // 0 login, 1 chap/pap, 2 Terminal + struct { + QString Expect; + QString Send; + } Login; + struct { + QString Expect; + QString Send; + } Password; + short PCEMode; // 0 pap, 1, chap 2, EAP + QString Server; + QString Client; + QString Secret; + } Auth; + struct { + bool ServerAssigned; + QString DomainName; + QArray<QString *> Servers; + } DNS; +} PPPData_t; + +#endif diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp new file mode 100644 index 0000000..8933f85 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/ppprun.cpp @@ -0,0 +1,77 @@ +#include <resources.h> +#include "ppprun.h" + +void PPPRun::detectState( NodeCollection * NC ) { + if( isMyPPPDRunning( ) ) { + if( isMyPPPUp() ) { + NC->setCurrentState( IsUp ); + } else { + NC->setCurrentState( Available ); + } + } else { + NC->setCurrentState( Off ); // at least this + // but could also be unavailable + netNode()->nextNode()->runtime()->detectState( NC ); + } +} + +bool PPPRun::setState( NodeCollection * NC, Action_t A ) { + switch( A ) { + case Activate : + NC->setCurrentState( Available ); + // no + break; + case Deactivate : + if( NC->currentState() == IsUp ) { + NC->state( Down ); + } + // cannot really disable + NC->setCurrentState( Available ); + break; + case Up : + if( NC->currentState() != IsUp ) { + // start my PPPD + NC->setCurrentState( IsUp ); + } + break; + case Down : + if( NC->currentState() == IsUp ) { + // stop my PPPD + NC->setCurrentState( Available ); + } + break; + default : // FT + break; + } + return 1; +} + +bool PPPRun::isMyPPPDRunning( void ) { + return 0; +} + +bool PPPRun::isMyPPPUp( void ) { + System & S = NSResources->system(); + InterfaceInfo * best = 0, * Run; + QRegExp R( "ppp[0-9]" ); + + for( QDictIterator<InterfaceInfo> It(S.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( R.match( Run->Name ) >= 0 && + Run->IsPointToPoint + ) { + // this is a LAN card + if( Run->assignedNode() == netNode() ) { + // assigned to us + return 1; + } + } + } + return 0; +} + +bool PPPRun::handlesInterface( const QString & S ) { + return Pat.match( S ) >= 0; +} |