Diffstat (limited to 'noncore/settings/networksettings2/ppp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/ppp/PPPAuthGUI.ui | 158 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/PPPAuthedit.cpp | 42 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/PPPAuthedit.h | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppp_NN.cpp | 31 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppp_NN.h | 31 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppp_NNI.cpp | 108 | ||||
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppp_NNI.h | 21 |
7 files changed, 263 insertions, 130 deletions
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui index 826843a..0c5f4c8 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui +++ b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui @@ -1,112 +1,112 @@ <!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> + <width>245</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> + <number>3</number> </property> <property stdset="1"> <name>spacing</name> - <number>0</number> + <number>2</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> @@ -146,287 +146,281 @@ <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> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>PapChap_RB</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Pap/Chap/EAP</string> + <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> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Pap_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Pap</string> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Chap_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Chap</string> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>EAP_RB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>EAP</string> + </property> + </widget> + </hbox> </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> + <number>2</number> </property> - <widget row="2" column="0" > + <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>Server</string> </property> </widget> - <widget row="3" column="0" > + <widget row="2" 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> + <widget row="1" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1</cstring> + <cstring>Server_LE</cstring> </property> <property stdset="1"> <name>text</name> - <string>Client</string> + <string>*</string> </property> </widget> - <widget row="0" column="0" > - <class>QLabel</class> + <widget row="2" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_4</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Method</string> + <cstring>Secret_LE</cstring> </property> </widget> - <widget row="1" column="1" rowspan="1" colspan="2" > + <widget row="0" column="1" > <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> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Server_LE</cstring> + <cstring>TextLabel1</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> + <string>Client</string> </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> + <sender>Pap_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> + <connection> + <sender>Chap_RB</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox3</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>EAP_RB</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox3</receiver> + <slot>setEnabled(bool)</slot> + </connection> </connections> </UI> diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp index f305cc4..450d560 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp @@ -1,85 +1,105 @@ #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 ){ } +bool PPPAuthEdit::PAP_Checked( void ) { + return ( Pap_RB->isChecked() || + Chap_RB->isChecked() || + EAP_RB->isChecked() + ); +} + 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() ) { + } else if( PAP_Checked() ) { 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 == 1 && ! PAP_Checked() ) || ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) { // mode modifed SM = 1; D.Auth.Mode = ( Login_RB->isChecked() ) ? 0 : - ( ( PapChap_RB->isChecked() ) ? - 1 : 2 ); + ( PAP_Checked() ) ? 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() ) { + } else if( PAP_Checked() ) { 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 ); + if( Pap_RB->isChecked() ) { + D.Auth.PCEMode = 0; + } else if( Chap_RB->isChecked() ) { + D.Auth.PCEMode = 1; + } else if( EAP_RB->isChecked() ) { + D.Auth.PCEMode = 2; + } } return SM; } void PPPAuthEdit::showData( PPPData_t & D ) { switch( D.Auth.Mode ) { case 0 : - Login_RB->isChecked(); + Login_RB->setChecked( TRUE ); break; case 1 : - PapChap_RB->isChecked(); + switch( D.Auth.PCEMode ) { + case 0 : + Pap_RB->setChecked( TRUE ); + break; + case 1 : + Chap_RB->setChecked( TRUE ); + break; + case 2 : + EAP_RB->setChecked( TRUE ); + break; + } break; case 2 : - Terminal_RB->isChecked(); + Terminal_RB->setChecked( TRUE ); 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 index cbd540e..2392569 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h @@ -1,15 +1,17 @@ #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 ); + bool PAP_Checked( void ); + private : }; diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index b7edf87..ff4465c 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -1,68 +1,85 @@ +#include <qfile.h> +#include <qtextstream.h> #include "ppp_NN.h" #include "ppp_NNI.h" +QStringList * PPPNetNode::ProperFiles = 0; + static const char * PPPNeeds[] = { "line", "modem", 0 }; /** * Constructor, find all of the possible interfaces */ PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { + + // proper files : will leak + ProperFiles =new QStringList; + *ProperFiles << "peers"; + *ProperFiles << "chatscript"; + + // system files + NSResources->addSystemFile( + "pap-secrets", "/tmp/pap-secrets", 0 ); + NSResources->addSystemFile( + "chap-secrets", "/tmp/chap-secrets", 0 ); } /** * 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 0; +QStringList * PPPNetNode::properFiles( void ) { + return ProperFiles; + } -bool PPPNetNode::generateDeviceDataForCommonFile( - SystemFile & , - long ) { - return 0; +// need to generate : +// /etc/ppp/pap-secrets +// /etc/ppp/pap-secrets +bool PPPNetNode::hasDataForFile( const QString & S ) { + return S == "pap-secrets" || + S == "chap-secrets" ; } QString PPPNetNode::genNic( long NicNr ) { QString S; return S.sprintf( "ppp%ld", NicNr ); } void PPPNetNode::setSpecificAttribute( QString & , QString & ) { } void PPPNetNode::saveSpecificAttribute( QTextStream & ) { } 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 index b1483c4..249be5a 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h @@ -1,46 +1,43 @@ #ifndef PPP_NETNODE_H #define PPP_NETNODE_H #include "netnode.h" class APPP; class PPPNetNode : public ANetNode{ - Q_OBJECT + Q_OBJECT public: - PPPNetNode(); - virtual ~PPPNetNode(); + PPPNetNode(); + virtual ~PPPNetNode(); - virtual const QString pixmapName() - { return "Devices/ppp"; } + virtual const QString pixmapName() + { return "Devices/ppp"; } - virtual const QString nodeDescription() ; + virtual bool hasDataForFile( const QString & S ); - virtual ANetNodeInstance * createInstance( void ); + virtual const QString nodeDescription() ; + virtual ANetNodeInstance * createInstance( void ); + virtual const char ** needs( void ); + virtual const char * provides( void ); - virtual const char ** needs( void ); - virtual const char * provides( void ); - - virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); - virtual bool hasDataFor( const QString & ) - { return 0; } - virtual bool generateDeviceDataForCommonFile( - SystemFile & SF, long DevNr ); - - virtual QString genNic( long NicNr ); + virtual QString genNic( long NicNr ); + virtual QStringList * properFiles( void ); private: virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); + + static QStringList * ProperFiles; }; 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 index d0fd31c..ba639de 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp @@ -1,48 +1,50 @@ +#include <qfile.h> +#include <qfileinfo.h> #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" ) { @@ -68,54 +70,152 @@ void APPP::setSpecificAttribute( QString & A, QString & 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 ); } } -bool APPP::generateDataForCommonFile( - SystemFile & , - long) { - return 1; +QFile * APPP::openFile( const QString & ID ) { + QFile * F = 0; + QString S; + + if( ID == "peers" ) { + S = removeSpaces( QString("/tmp/") + connection()->name() ); + + F = new QFile( S ); + + if( ! F->open( IO_WriteOnly ) ) { + Log(("Cannot open file %s\n", S.latin1() )); + return 0; + } + } else if ( ID == "chatscripts" ) { + S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" ); + F = new QFile( S ); + + if( ! F->open( IO_WriteOnly ) ) { + Log(("Cannot open file %s\n", S.latin1() )); + return 0; + } + } + if( F ) { + Log(("Generate proper file %s = %s\n", + ID.latin1(), F->name().latin1())); + } + return F; } +short APPP::generateFile( const QString & ID, + const QString & Path, + QTextStream & TS, + long DevNr ) { + short rvl, rvd; + + rvl = 1; + rvd = 1; + + if( ID == "pap-secrets" ) { + Log(("Generate PPP for %s\n", ID.latin1() )); + if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { + TS << "# secrets for " + << connection()->name().latin1() + << endl; + TS << Data.Auth.Client + << " " + << Data.Auth.Server + << " " + << Data.Auth.Secret + << endl; + rvl = 0; + rvd = connection()->getToplevel()->generateFileEmbedded( + ID, Path, TS, DevNr ); + } + } else if( ID == "chap-secrets" ) { + Log(("Generate PPP for %s\n", ID.latin1() )); + if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { + // used for both EAP and Chap + TS << "# secrets for " + << connection()->name().latin1() + << endl; + TS << Data.Auth.Client + << " " + << Data.Auth.Server + << " " + << Data.Auth.Secret + << endl; + + rvl = 0; + rvd = connection()->getToplevel()->generateFileEmbedded( + ID, Path, TS, DevNr ); + } + } else if ( ID == "peers" ) { + QFileInfo FI(Path); + Log(("Generate PPP for %s\n", ID.latin1() )); + + TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/" + << FI.baseName() + << ".chat\"" + << endl; + + if( Data.IP.GWIsDefault ) { + TS << "defaultroute" + << endl; + } + + TS << "linkname " + << removeSpaces( ID.latin1() ) + << endl; + + // insert other data here + rvl = 0; + rvd = connection()->getToplevel()->generateFileEmbedded( + ID, Path, TS, DevNr ); + } else if ( ID == "chatscripts" ) { + Log(("Generate PPP for %s\n", ID.latin1() )); + rvl = 0; + rvd = connection()->getToplevel()->generateFileEmbedded( + ID, Path, TS, DevNr ); + } + + return (rvd == 2 || rvl == 2 ) ? 2 : + (rvd == 0 || rvl == 0 ) ? 0 : 1; +} diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index 989c2f0..0bf8fa9 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h @@ -1,48 +1,51 @@ #ifndef PPP_H #define PPP_H #include <netnode.h> #include "pppdata.h" #include "ppprun.h" class PPPNetNode; class PPPEdit; +class QTextStream; class APPP : public ANetNodeInstance { public : APPP( PPPNetNode * PNN ); - QWidget * edit( QWidget * parent ); - QString acceptable( void ); - void commit( void ); - RuntimeInfo * runtime( void ) - { if( RT == 0 ) + { if( RT == 0 ) { RT = new PPPRun( this, Data ); + } return RT->runtimeInfo(); } + QWidget * edit( QWidget * parent ); + QString acceptable( void ); + void commit( void ); + virtual void * data( void ) { return (void *)&Data; } - virtual bool hasDataFor( const QString & ) - { return 0; } + virtual QFile * openFile( const QString & ID ); + short generateFile( const QString & ID, + const QString & Path, + QTextStream & TS, + long DevNr ); - virtual bool generateDataForCommonFile( - SystemFile & SF, long DevNr ); protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); private : PPPEdit * GUI; PPPData Data; PPPRun * RT; }; #endif |