summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
authorwimpie <wimpie>2004-08-12 12:46:55 (UTC)
committer wimpie <wimpie>2004-08-12 12:46:55 (UTC)
commit8f215ba9ceb395f262517855a99d7d2d303ca760 (patch) (side-by-side diff)
treeaa5f9b14c249217b4d3fc30f4771bdaf1c3545d3 /noncore/settings/networksettings2/ppp/ppp_NNI.cpp
parentef64880308b5035cc8ca2e4e79325db613af525b (diff)
downloadopie-8f215ba9ceb395f262517855a99d7d2d303ca760.zip
opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.gz
opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.bz2
MANY changes
- now generates peers/pap-chap secrets files (no chatscript yet) (not all usefull ppp options included yet) - still not ready for prime time yet
Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppp_NNI.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp108
1 files changed, 104 insertions, 4 deletions
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,3 +1,5 @@
+#include <qfile.h>
+#include <qfileinfo.h>
#include "PPPedit.h"
#include "ppp_NNI.h"
#include "ppp_NN.h"
@@ -113,9 +115,107 @@ void APPP::commit( void ) {
}
}
-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;
+}