summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
Unidiff
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,6 +1,8 @@
1#include <qfile.h>
2#include <qfileinfo.h>
1#include "PPPedit.h" 3#include "PPPedit.h"
2#include "ppp_NNI.h" 4#include "ppp_NNI.h"
3#include "ppp_NN.h" 5#include "ppp_NN.h"
4 6
5APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { 7APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
6 Data.DNS.ServerAssigned = 1; 8 Data.DNS.ServerAssigned = 1;
@@ -110,12 +112,110 @@ QString APPP::acceptable( void ) {
110void APPP::commit( void ) { 112void APPP::commit( void ) {
111 if( GUI && GUI->commit( Data ) ) { 113 if( GUI && GUI->commit( Data ) ) {
112 setModified( 1 ); 114 setModified( 1 );
113 } 115 }
114} 116}
115 117
116bool APPP::generateDataForCommonFile( 118QFile * APPP::openFile( const QString & ID ) {
117 SystemFile & , 119 QFile * F = 0;
118 long) { 120 QString S;
119 return 1; 121
122 if( ID == "peers" ) {
123 S = removeSpaces( QString("/tmp/") + connection()->name() );
124
125 F = new QFile( S );
126
127 if( ! F->open( IO_WriteOnly ) ) {
128 Log(("Cannot open file %s\n", S.latin1() ));
129 return 0;
130 }
131 } else if ( ID == "chatscripts" ) {
132 S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
133 F = new QFile( S );
134
135 if( ! F->open( IO_WriteOnly ) ) {
136 Log(("Cannot open file %s\n", S.latin1() ));
137 return 0;
138 }
139 }
140 if( F ) {
141 Log(("Generate proper file %s = %s\n",
142 ID.latin1(), F->name().latin1()));
143 }
144 return F;
120} 145}
121 146
147short APPP::generateFile( const QString & ID,
148 const QString & Path,
149 QTextStream & TS,
150 long DevNr ) {
151 short rvl, rvd;
152
153 rvl = 1;
154 rvd = 1;
155
156 if( ID == "pap-secrets" ) {
157 Log(("Generate PPP for %s\n", ID.latin1() ));
158 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
159 TS << "# secrets for "
160 << connection()->name().latin1()
161 << endl;
162 TS << Data.Auth.Client
163 << " "
164 << Data.Auth.Server
165 << " "
166 << Data.Auth.Secret
167 << endl;
168 rvl = 0;
169 rvd = connection()->getToplevel()->generateFileEmbedded(
170 ID, Path, TS, DevNr );
171 }
172 } else if( ID == "chap-secrets" ) {
173 Log(("Generate PPP for %s\n", ID.latin1() ));
174 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
175 // used for both EAP and Chap
176 TS << "# secrets for "
177 << connection()->name().latin1()
178 << endl;
179 TS << Data.Auth.Client
180 << " "
181 << Data.Auth.Server
182 << " "
183 << Data.Auth.Secret
184 << endl;
185
186 rvl = 0;
187 rvd = connection()->getToplevel()->generateFileEmbedded(
188 ID, Path, TS, DevNr );
189 }
190 } else if ( ID == "peers" ) {
191 QFileInfo FI(Path);
192 Log(("Generate PPP for %s\n", ID.latin1() ));
193
194 TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/"
195 << FI.baseName()
196 << ".chat\""
197 << endl;
198
199 if( Data.IP.GWIsDefault ) {
200 TS << "defaultroute"
201 << endl;
202 }
203
204 TS << "linkname "
205 << removeSpaces( ID.latin1() )
206 << endl;
207
208 // insert other data here
209 rvl = 0;
210 rvd = connection()->getToplevel()->generateFileEmbedded(
211 ID, Path, TS, DevNr );
212 } else if ( ID == "chatscripts" ) {
213 Log(("Generate PPP for %s\n", ID.latin1() ));
214 rvl = 0;
215 rvd = connection()->getToplevel()->generateFileEmbedded(
216 ID, Path, TS, DevNr );
217 }
218
219 return (rvd == 2 || rvl == 2 ) ? 2 :
220 (rvd == 0 || rvl == 0 ) ? 0 : 1;
221}