-rw-r--r-- | noncore/settings/networksettings/ppp/devices.h | 57 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/kpppconfig.h | 134 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 671 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.h | 98 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modeminfo.cpp | 294 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modeminfo.h | 89 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/ppp.pro | 9 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/ppp.ui | 78 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 1229 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 465 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppimp.cpp | 33 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppimp.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.h | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/runtests.cpp | 279 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/runtests.h | 47 |
16 files changed, 3495 insertions, 46 deletions
diff --git a/noncore/settings/networksettings/ppp/devices.h b/noncore/settings/networksettings/ppp/devices.h new file mode 100644 index 0000000..fb57128 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/devices.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef _DEVICES_H_ | ||
2 | #define _DEVICES_H_ | ||
3 | |||
4 | #include "kpppconfig.h" | ||
5 | |||
6 | static const char *devices[] = { | ||
7 | #ifdef __FreeBSD__ | ||
8 | "/dev/cuaa0", | ||
9 | "/dev/cuaa1", | ||
10 | "/dev/cuaa2", | ||
11 | "/dev/cuaa3", | ||
12 | "/dev/cuaa4", | ||
13 | #elif defined(__NetBSD__) | ||
14 | "/dev/tty00", /* "normal" modem lines */ | ||
15 | "/dev/tty01", | ||
16 | "/dev/tty02", | ||
17 | "/dev/tty03", | ||
18 | "/dev/dty00", /* Dial out devices */ | ||
19 | "/dev/dty01", | ||
20 | "/dev/dty02", | ||
21 | "/dev/dty03", | ||
22 | "/dev/ttyU0", /* USB stuff modems */ | ||
23 | "/dev/ttyU1", | ||
24 | "/dev/ttyU2", | ||
25 | "/dev/ttyU3", | ||
26 | "/dev/dtyU0", /* USB stuff, too (dial out device) */ | ||
27 | "/dev/dtyU1", | ||
28 | "/dev/dtyU2", | ||
29 | "/dev/dtyU3", | ||
30 | #elif defined (__linux__) | ||
31 | "/dev/modem", | ||
32 | "/dev/ttyS0", | ||
33 | "/dev/ttyS1", | ||
34 | "/dev/ttyS2", | ||
35 | "/dev/ttyS3", | ||
36 | #ifdef ISDNSUPPORT | ||
37 | "/dev/ttyI0", | ||
38 | "/dev/ttyI1", | ||
39 | "/dev/ttyI2", | ||
40 | "/dev/ttyI3", | ||
41 | #endif | ||
42 | "/dev/usb/ttyACM0", /* USB stuff modems */ | ||
43 | "/dev/usb/ttyACM1", | ||
44 | "/dev/usb/ttyACM2", | ||
45 | "/dev/usb/ttyACM3", | ||
46 | #elif defined(__svr4__) | ||
47 | "/dev/cua/a", | ||
48 | "/dev/cua/b", | ||
49 | "/dev/ttya", | ||
50 | "/dev/ttyb", | ||
51 | #endif | ||
52 | 0}; | ||
53 | |||
54 | // default device number from the list above | ||
55 | const int DEV_DEFAULT = 0; | ||
56 | |||
57 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/kpppconfig.h b/noncore/settings/networksettings/ppp/kpppconfig.h new file mode 100644 index 0000000..cff2aac --- a/dev/null +++ b/noncore/settings/networksettings/ppp/kpppconfig.h | |||
@@ -0,0 +1,134 @@ | |||
1 | /* -*- C++ -*- | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU Library General Public | ||
12 | * License as published by the Free Software Foundation; either | ||
13 | * version 2 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * Library General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Library General Public | ||
21 | * License along with this program; if not, write to the Free | ||
22 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | |||
26 | #ifndef _KPPPCONFIG_H_ | ||
27 | #define _KPPPCONFIG_H_ | ||
28 | |||
29 | #if defined(__svr4__) | ||
30 | #define STREAMS | ||
31 | #define _XOPEN_SOURCE 1 | ||
32 | #define _XOPEN_SOURCE_EXTENDED 1 | ||
33 | #define __EXTENSIONS__ | ||
34 | #endif | ||
35 | |||
36 | //#include <config.h> | ||
37 | |||
38 | #ifdef HAVE_SYS_PARAM_H | ||
39 | #include <sys/param.h> | ||
40 | #endif | ||
41 | |||
42 | // Warning: If you fiddle with the following directories you have | ||
43 | // to adjust make_directories() in main.cpp() | ||
44 | |||
45 | // file used for PAP authetication purposes | ||
46 | #define PAP_AUTH_FILE "/etc/ppp/pap-secrets" | ||
47 | |||
48 | // file used for CHAP authetication purposes | ||
49 | #define CHAP_AUTH_FILE "/etc/ppp/chap-secrets" | ||
50 | |||
51 | // Define the default modem response timeout | ||
52 | #define MODEM_TIMEOUT 60 | ||
53 | |||
54 | // Define the default modem tone duration (ATS11=) | ||
55 | #define MODEM_TONEDURATION 70 | ||
56 | |||
57 | // Define the default time for pppd to get the interface up | ||
58 | #define PPPD_TIMEOUT 30 | ||
59 | |||
60 | // Define the default time to wait after a busy signal before redialing | ||
61 | #define BUSY_WAIT 0 | ||
62 | |||
63 | |||
64 | |||
65 | // Every PPP_STATS_INTERVAL milli seconds kppp will read | ||
66 | // and display the ppp statistics IF the stats window | ||
67 | // is visible. If the stats window is not visible | ||
68 | // the stats are not taken. | ||
69 | // 200 milli secs is 5 times per second and results in | ||
70 | // 0 load on my machine. Play with this parameter if | ||
71 | // you feel like it. | ||
72 | |||
73 | #define PPP_STATS_INTERVAL 200 | ||
74 | // comment this out to get some more debugging info | ||
75 | /* | ||
76 | #define MY_DEBUG | ||
77 | */ | ||
78 | |||
79 | // Define the maximum number of accounts | ||
80 | #define MAX_ACCOUNTS 100 | ||
81 | |||
82 | // Define the mamimum number of script entries | ||
83 | #define MAX_SCRIPT_ENTRIES 20 | ||
84 | |||
85 | // Define the maximun number of DNS entries | ||
86 | #define MAX_DNS_ENTRIES 5 | ||
87 | |||
88 | // Maximum size of the command executing pppd | ||
89 | const unsigned int MAX_CMDLEN = 2024; | ||
90 | |||
91 | // Define the maximum number of arguments passed to the pppd daemon | ||
92 | #define MAX_PPPD_ARGUMENTS 20 | ||
93 | |||
94 | // Define the maximun number of lines of /etc/resolv.conf | ||
95 | #define MAX_RESOLVCONF_LINES 128 | ||
96 | |||
97 | // Directory for modem lock files (Needed by mgetty users) | ||
98 | #ifdef __linux__ | ||
99 | # define LOCK_DIR "/var/lock" | ||
100 | #else /* linux */ | ||
101 | # ifdef BSD | ||
102 | # defineLOCK_DIR "/var/spool/lock" | ||
103 | # else /* BSD */ | ||
104 | # defineLOCK_DIR "/var/spool/locks" | ||
105 | # endif /* BSD */ | ||
106 | #endif /* linux */ | ||
107 | |||
108 | #define DEVNULL "/dev/null" | ||
109 | |||
110 | // search path for pppd binary | ||
111 | #define PPPDSEARCHPATH "/sbin:/usr/sbin:/usr/local/sbin:/usr/bin:/usr/local/bin" | ||
112 | |||
113 | // name of the pppd binary | ||
114 | #define PPPDNAME "pppd" | ||
115 | |||
116 | // support for internal ISDN cards and modem emulation | ||
117 | #ifdef __linux__ | ||
118 | #define ISDNSUPPORT | ||
119 | #endif | ||
120 | |||
121 | #if defined(__linux__) || defined(BSD) | ||
122 | #define PPP_PID_DIR "/var/run/" | ||
123 | #else | ||
124 | #define PPP_PID_DIR "/etc/ppp/" | ||
125 | #endif | ||
126 | |||
127 | // defined in opener.cpp | ||
128 | extern const char * const kppp_syslog[]; | ||
129 | |||
130 | #ifdef _XPG4_2 | ||
131 | #define __xnet_connect connect | ||
132 | #endif | ||
133 | |||
134 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp new file mode 100644 index 0000000..e9e3f06 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -0,0 +1,671 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd Front End for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | ||
10 | * | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <errno.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <fcntl.h> | ||
30 | #include <signal.h> | ||
31 | #include <sys/ioctl.h> | ||
32 | #include <setjmp.h> | ||
33 | #include <qregexp.h> | ||
34 | #include <assert.h> | ||
35 | |||
36 | #include "modem.h" | ||
37 | #include "pppdata.h" | ||
38 | //#include "requester.h" | ||
39 | //#include <klocale.h> | ||
40 | #define i18n QObject::tr | ||
41 | #define qError qDebug | ||
42 | //#include <kdebug.h> | ||
43 | //#include <config.h> | ||
44 | |||
45 | #define MY_ASSERT(x) if (!(x)) { \ | ||
46 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | ||
47 | exit(1); } | ||
48 | |||
49 | |||
50 | static sigjmp_buf jmp_buffer; | ||
51 | |||
52 | Modem *Modem::modem = 0; | ||
53 | |||
54 | Modem::Modem() : | ||
55 | modemfd(-1), | ||
56 | sn(0L), | ||
57 | data_mode(false), | ||
58 | modem_is_locked(false) | ||
59 | { | ||
60 | lockfile[0] = '\0'; | ||
61 | device = "/dev/modem"; | ||
62 | assert(modem==0); | ||
63 | modem = this; | ||
64 | } | ||
65 | |||
66 | |||
67 | Modem::~Modem() { | ||
68 | modem = 0; | ||
69 | } | ||
70 | |||
71 | |||
72 | speed_t Modem::modemspeed() { | ||
73 | // convert the string modem speed int the gpppdata object to a t_speed type | ||
74 | // to set the modem. The constants here should all be ifdef'd because | ||
75 | // other systems may not have them | ||
76 | int i = gpppdata.speed().toInt()/100; | ||
77 | |||
78 | switch(i) { | ||
79 | case 24: | ||
80 | return B2400; | ||
81 | break; | ||
82 | case 96: | ||
83 | return B9600; | ||
84 | break; | ||
85 | case 192: | ||
86 | return B19200; | ||
87 | break; | ||
88 | case 384: | ||
89 | return B38400; | ||
90 | break; | ||
91 | #ifdef B57600 | ||
92 | case 576: | ||
93 | return B57600; | ||
94 | break; | ||
95 | #endif | ||
96 | |||
97 | #ifdef B115200 | ||
98 | case 1152: | ||
99 | return B115200; | ||
100 | break; | ||
101 | #endif | ||
102 | |||
103 | #ifdef B230400 | ||
104 | case 2304: | ||
105 | return B230400; | ||
106 | break; | ||
107 | #endif | ||
108 | |||
109 | #ifdef B460800 | ||
110 | case 4608: | ||
111 | return B460800; | ||
112 | break; | ||
113 | #endif | ||
114 | |||
115 | default: | ||
116 | return B38400; | ||
117 | break; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | bool Modem::opentty() { | ||
122 | // int flags; | ||
123 | |||
124 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | ||
125 | close(modemfd); | ||
126 | // device = "/dev/modem";//deviceByIndex(request.modem.deviceNum); | ||
127 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | ||
128 | qDebug("error opening modem device !"); | ||
129 | errmsg = i18n("Unable to open modem."); | ||
130 | return false; | ||
131 | } | ||
132 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | ||
133 | //} | ||
134 | |||
135 | #if 0 | ||
136 | if(gpppdata.UseCDLine()) { | ||
137 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | ||
138 | errmsg = i18n("Unable to detect state of CD line."); | ||
139 | ::close(modemfd); | ||
140 | modemfd = -1; | ||
141 | return false; | ||
142 | } | ||
143 | if ((flags&TIOCM_CD) == 0) { | ||
144 | errmsg = i18n("The modem is not ready."); | ||
145 | ::close(modemfd); | ||
146 | modemfd = -1; | ||
147 | return false; | ||
148 | } | ||
149 | } | ||
150 | #endif | ||
151 | |||
152 | tcdrain (modemfd); | ||
153 | tcflush (modemfd, TCIOFLUSH); | ||
154 | |||
155 | if(tcgetattr(modemfd, &tty) < 0){ | ||
156 | // this helps in some cases | ||
157 | tcsendbreak(modemfd, 0); | ||
158 | sleep(1); | ||
159 | if(tcgetattr(modemfd, &tty) < 0){ | ||
160 | errmsg = i18n("The modem is busy."); | ||
161 | ::close(modemfd); | ||
162 | modemfd = -1; | ||
163 | return false; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | memset(&initial_tty,'\0',sizeof(initial_tty)); | ||
168 | |||
169 | initial_tty = tty; | ||
170 | |||
171 | tty.c_cc[VMIN] = 0; // nonblocking | ||
172 | tty.c_cc[VTIME] = 0; | ||
173 | tty.c_oflag = 0; | ||
174 | tty.c_lflag = 0; | ||
175 | |||
176 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | ||
177 | tty.c_cflag |= CS8 | CREAD; | ||
178 | tty.c_cflag |= CLOCAL; // ignore modem status lines | ||
179 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | ||
180 | tty.c_lflag &= ~ICANON; // non-canonical mode | ||
181 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | ||
182 | |||
183 | |||
184 | if(gpppdata.flowcontrol() != "None") { | ||
185 | if(gpppdata.flowcontrol() == "CRTSCTS") { | ||
186 | tty.c_cflag |= CRTSCTS; | ||
187 | } | ||
188 | else { | ||
189 | tty.c_iflag |= IXON | IXOFF; | ||
190 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | ||
191 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | ||
192 | } | ||
193 | } | ||
194 | else { | ||
195 | tty.c_cflag &= ~CRTSCTS; | ||
196 | tty.c_iflag &= ~(IXON | IXOFF); | ||
197 | } | ||
198 | |||
199 | cfsetospeed(&tty, modemspeed()); | ||
200 | cfsetispeed(&tty, modemspeed()); | ||
201 | |||
202 | tcdrain(modemfd); | ||
203 | |||
204 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | ||
205 | errmsg = i18n("The modem is busy."); | ||
206 | ::close(modemfd); | ||
207 | modemfd=-1; | ||
208 | return false; | ||
209 | } | ||
210 | |||
211 | errmsg = i18n("Modem Ready."); | ||
212 | return true; | ||
213 | } | ||
214 | |||
215 | |||
216 | bool Modem::closetty() { | ||
217 | if(modemfd >=0 ) { | ||
218 | stop(); | ||
219 | /* discard data not read or transmitted */ | ||
220 | tcflush(modemfd, TCIOFLUSH); | ||
221 | |||
222 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | ||
223 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); | ||
224 | ::close(modemfd); | ||
225 | modemfd = -1; | ||
226 | return false; | ||
227 | } | ||
228 | ::close(modemfd); | ||
229 | modemfd = -1; | ||
230 | } | ||
231 | |||
232 | return true; | ||
233 | } | ||
234 | |||
235 | |||
236 | void Modem::readtty(int) { | ||
237 | char buffer[200]; | ||
238 | unsigned char c; | ||
239 | int len; | ||
240 | |||
241 | // read data in chunks of up to 200 bytes | ||
242 | if((len = ::read(modemfd, buffer, 200)) > 0) { | ||
243 | // split buffer into single characters for further processing | ||
244 | for(int i = 0; i < len; i++) { | ||
245 | c = buffer[i] & 0x7F; | ||
246 | emit charWaiting(c); | ||
247 | } | ||
248 | } | ||
249 | } | ||
250 | |||
251 | |||
252 | void Modem::notify(const QObject *receiver, const char *member) { | ||
253 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | ||
254 | startNotifier(); | ||
255 | } | ||
256 | |||
257 | |||
258 | void Modem::stop() { | ||
259 | disconnect(SIGNAL(charWaiting(unsigned char))); | ||
260 | stopNotifier(); | ||
261 | } | ||
262 | |||
263 | |||
264 | void Modem::startNotifier() { | ||
265 | if(modemfd >= 0) { | ||
266 | if(sn == 0) { | ||
267 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | ||
268 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | ||
269 | qDebug("QSocketNotifier started!"); | ||
270 | } else { | ||
271 | qDebug("QSocketNotifier re-enabled!"); | ||
272 | sn->setEnabled(true); | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | void Modem::stopNotifier() { | ||
279 | if(sn != 0) { | ||
280 | sn->setEnabled(false); | ||
281 | disconnect(sn); | ||
282 | delete sn; | ||
283 | sn = 0; | ||
284 | qDebug( "QSocketNotifier stopped!" ); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | |||
289 | void Modem::flush() { | ||
290 | char c; | ||
291 | while(read(modemfd, &c, 1) == 1); | ||
292 | } | ||
293 | |||
294 | |||
295 | bool Modem::writeChar(unsigned char c) { | ||
296 | int s; | ||
297 | do { | ||
298 | s = write(modemfd, &c, 1); | ||
299 | if (s < 0) { | ||
300 | qError( "write() in Modem::writeChar failed" ); | ||
301 | return false; | ||
302 | } | ||
303 | } while(s == 0); | ||
304 | |||
305 | return true; | ||
306 | } | ||
307 | |||
308 | |||
309 | bool Modem::writeLine(const char *buf) { | ||
310 | int len = strlen(buf); | ||
311 | char *b = new char[len+2]; | ||
312 | memcpy(b, buf, len); | ||
313 | // different modems seem to need different line terminations | ||
314 | QString term = gpppdata.enter(); | ||
315 | if(term == "LF") | ||
316 | b[len++]='\n'; | ||
317 | else if(term == "CR") | ||
318 | b[len++]='\r'; | ||
319 | else if(term == "CR/LF") { | ||
320 | b[len++]='\r'; | ||
321 | b[len++]='\n'; | ||
322 | } | ||
323 | int l = len; | ||
324 | while(l) { | ||
325 | int wr = write(modemfd, &b[len-l], l); | ||
326 | if(wr < 0) { | ||
327 | // TODO do something meaningful with the error code (or ignore it | ||
328 | qError( "write() in Modem::writeLine failed" ); | ||
329 | delete[] b; | ||
330 | return false; | ||
331 | } | ||
332 | l -= wr; | ||
333 | } | ||
334 | delete[] b; | ||
335 | return true; | ||
336 | } | ||
337 | |||
338 | |||
339 | bool Modem::hangup() { | ||
340 | // this should really get the modem to hang up and go into command mode | ||
341 | // If anyone sees a fault in the following please let me know, since | ||
342 | // this is probably the most imporant snippet of code in the whole of | ||
343 | // kppp. If people complain about kppp being stuck, this piece of code | ||
344 | // is most likely the reason. | ||
345 | struct termios temptty; | ||
346 | |||
347 | if(modemfd >= 0) { | ||
348 | |||
349 | // is this Escape & HangupStr stuff really necessary ? (Harri) | ||
350 | |||
351 | if (data_mode) escape_to_command_mode(); | ||
352 | |||
353 | // Then hangup command | ||
354 | writeLine(gpppdata.modemHangupStr().local8Bit()); | ||
355 | |||
356 | usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec | ||
357 | |||
358 | #ifndef DEBUG_WO_DIALING | ||
359 | if (sigsetjmp(jmp_buffer, 1) == 0) { | ||
360 | // set alarm in case tcsendbreak() hangs | ||
361 | signal(SIGALRM, alarm_handler); | ||
362 | alarm(2); | ||
363 | |||
364 | tcsendbreak(modemfd, 0); | ||
365 | |||
366 | alarm(0); | ||
367 | signal(SIGALRM, SIG_IGN); | ||
368 | } else { | ||
369 | // we reach this point if the alarm handler got called | ||
370 | closetty(); | ||
371 | close(modemfd); | ||
372 | modemfd = -1; | ||
373 | errmsg = i18n("The modem does not respond."); | ||
374 | return false; | ||
375 | } | ||
376 | |||
377 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | ||
378 | tcgetattr(modemfd, &temptty); | ||
379 | cfsetospeed(&temptty, B0); | ||
380 | cfsetispeed(&temptty, B0); | ||
381 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | ||
382 | #else | ||
383 | int modemstat; | ||
384 | ioctl(modemfd, TIOCMGET, &modemstat); | ||
385 | modemstat &= ~TIOCM_DTR; | ||
386 | ioctl(modemfd, TIOCMSET, &modemstat); | ||
387 | ioctl(modemfd, TIOCMGET, &modemstat); | ||
388 | modemstat |= TIOCM_DTR; | ||
389 | ioctl(modemfd, TIOCMSET, &modemstat); | ||
390 | #endif | ||
391 | |||
392 | usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 secs | ||
393 | |||
394 | cfsetospeed(&temptty, modemspeed()); | ||
395 | cfsetispeed(&temptty, modemspeed()); | ||
396 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | ||
397 | #endif | ||
398 | return true; | ||
399 | } else | ||
400 | return false; | ||
401 | } | ||
402 | |||
403 | |||
404 | void Modem::escape_to_command_mode() { | ||
405 | // Send Properly bracketed escape code to put the modem back into command state. | ||
406 | // A modem will accept AT commands only when it is in command state. | ||
407 | // When a modem sends the host the CONNECT string, that signals | ||
408 | // that the modem is now in the connect state (no long accepts AT commands.) | ||
409 | // Need to send properly timed escape sequence to put modem in command state. | ||
410 | // Escape codes and guard times are controlled by S2 and S12 values. | ||
411 | // | ||
412 | tcflush(modemfd, TCIOFLUSH); | ||
413 | |||
414 | // +3 because quiet time must be greater than guard time. | ||
415 | usleep((gpppdata.modemEscapeGuardTime()+3)*20000); | ||
416 | QCString tmp = gpppdata.modemEscapeStr().local8Bit(); | ||
417 | write(modemfd, tmp.data(), tmp.length()); | ||
418 | tcflush(modemfd, TCIOFLUSH); | ||
419 | usleep((gpppdata.modemEscapeGuardTime()+3)*20000); | ||
420 | |||
421 | data_mode = false; | ||
422 | } | ||
423 | |||
424 | |||
425 | const QString Modem::modemMessage() { | ||
426 | return errmsg; | ||
427 | } | ||
428 | |||
429 | |||
430 | QString Modem::parseModemSpeed(const QString &s) { | ||
431 | // this is a small (and bad) parser for modem speeds | ||
432 | int rx = -1; | ||
433 | int tx = -1; | ||
434 | int i; | ||
435 | QString result; | ||
436 | |||
437 | qDebug( "Modem reported result string: %s", s.latin1()); | ||
438 | |||
439 | const int RXMAX = 7; | ||
440 | const int TXMAX = 2; | ||
441 | QRegExp rrx[RXMAX] = { | ||
442 | QRegExp("[0-9]+[:/ ]RX", false), | ||
443 | QRegExp("[0-9]+RX", false), | ||
444 | QRegExp("[/: -][0-9]+[/: ]", false), | ||
445 | QRegExp("[/: -][0-9]+$", false), | ||
446 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | ||
447 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | ||
448 | QRegExp("[0-9]+") // panic mode | ||
449 | }; | ||
450 | |||
451 | QRegExp trx[TXMAX] = { | ||
452 | QRegExp("[0-9]+[:/ ]TX", false), | ||
453 | QRegExp("[0-9]+TX", false) | ||
454 | }; | ||
455 | |||
456 | for(i = 0; i < RXMAX; i++) { | ||
457 | int len, idx, result; | ||
458 | if((idx = rrx[i].match(s,0,&len)) > -1) { | ||
459 | // if((idx = rrx[i].search(s)) > -1) { | ||
460 | // len = rrx[i].matchedLength(); | ||
461 | |||
462 | // | ||
463 | // rrx[i] has been matched, idx contains the start of the match | ||
464 | // and len contains how long the match is. Extract the match. | ||
465 | // | ||
466 | QString sub = s.mid(idx, len); | ||
467 | |||
468 | // | ||
469 | // Now extract the digits only from the match, which will | ||
470 | // then be converted to an int. | ||
471 | // | ||
472 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { | ||
473 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { | ||
474 | // len = rrx[RXMAX-1].matchedLength(); | ||
475 | sub = sub.mid(idx, len); | ||
476 | result = sub.toInt(); | ||
477 | if(result > 0) { | ||
478 | rx = result; | ||
479 | break; | ||
480 | } | ||
481 | } | ||
482 | } | ||
483 | } | ||
484 | |||
485 | for(i = 0; i < TXMAX; i++) { | ||
486 | int len, idx, result; | ||
487 | if((idx = trx[i].match(s,0,&len)) > -1) { | ||
488 | // if((idx = trx[i].search(s)) > -1) { | ||
489 | // len = trx[i].matchedLength(); | ||
490 | |||
491 | // | ||
492 | // trx[i] has been matched, idx contains the start of the match | ||
493 | // and len contains how long the match is. Extract the match. | ||
494 | // | ||
495 | QString sub = s.mid(idx, len); | ||
496 | |||
497 | // | ||
498 | // Now extract the digits only from the match, which will then | ||
499 | // be converted to an int. | ||
500 | // | ||
501 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { | ||
502 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { | ||
503 | // len = rrx[RXMAX-1].matchedLength(); | ||
504 | sub = sub.mid(idx, len); | ||
505 | result = sub.toInt(); | ||
506 | if(result > 0) { | ||
507 | tx = result; | ||
508 | break; | ||
509 | } | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | |||
514 | if(rx == -1 && tx == -1) | ||
515 | result = i18n("Unknown speed"); | ||
516 | else if(tx == -1) | ||
517 | result.setNum(rx); | ||
518 | else if(rx == -1) // should not happen | ||
519 | result.setNum(tx); | ||
520 | else | ||
521 | result.sprintf("%d/%d", rx, tx); | ||
522 | |||
523 | qDebug( "The parsed result is: %s", result.latin1()); | ||
524 | |||
525 | return result; | ||
526 | } | ||
527 | |||
528 | |||
529 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | ||
530 | // a lock file can't be created ( permission problem ) | ||
531 | int Modem::lockdevice() { | ||
532 | int fd; | ||
533 | char newlock[80]=""; // safe | ||
534 | |||
535 | if(!gpppdata.modemLockFile()) { | ||
536 | qDebug("The user doesn't want a lockfile."); | ||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | if (modem_is_locked) | ||
541 | return 1; | ||
542 | |||
543 | QString lockfile = LOCK_DIR"/LCK.."; | ||
544 | lockfile += gpppdata.modemDevice().mid(5); // append everything after /dev/ | ||
545 | |||
546 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | ||
547 | // if ((fd = Requester::rq-> | ||
548 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | ||
549 | // Mario: it's not necessary to read more than lets say 32 bytes. If | ||
550 | // file has more than 32 bytes, skip the rest | ||
551 | char oldlock[33]; // safe | ||
552 | int sz = read(fd, &oldlock, 32); | ||
553 | close (fd); | ||
554 | if (sz <= 0) | ||
555 | return 1; | ||
556 | oldlock[sz] = '\0'; | ||
557 | |||
558 | qDebug( "Device is locked by: %s", oldlock); | ||
559 | |||
560 | int oldpid; | ||
561 | int match = sscanf(oldlock, "%d", &oldpid); | ||
562 | |||
563 | // found a pid in lockfile ? | ||
564 | if (match < 1 || oldpid <= 0) | ||
565 | return 1; | ||
566 | |||
567 | // check if process exists | ||
568 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | ||
569 | return 1; | ||
570 | |||
571 | qDebug( "lockfile is stale" ); | ||
572 | } | ||
573 | } | ||
574 | |||
575 | fd = openLockfile(gpppdata.modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | ||
576 | if(fd >= 0) { | ||
577 | sprintf(newlock,"%010d\n", getpid()); | ||
578 | qDebug("Locking Device: %s", newlock); | ||
579 | |||
580 | write(fd, newlock, strlen(newlock)); | ||
581 | close(fd); | ||
582 | modem_is_locked=true; | ||
583 | |||
584 | return 0; | ||
585 | } | ||
586 | |||
587 | return -1; | ||
588 | |||
589 | } | ||
590 | |||
591 | |||
592 | // UnLock modem device | ||
593 | void Modem::unlockdevice() { | ||
594 | if (modem_is_locked) { | ||
595 | qDebug( "UnLocking Modem Device" ); | ||
596 | close(modemfd); | ||
597 | modemfd = -1; | ||
598 | unlink(lockfile); | ||
599 | lockfile[0] = '\0'; | ||
600 | modem_is_locked=false; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | int Modem::openLockfile( QString lockfile, int flags) | ||
605 | { | ||
606 | int fd; | ||
607 | int mode; | ||
608 | flags = O_RDONLY; | ||
609 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | ||
610 | mode = 0644; | ||
611 | else | ||
612 | mode = 0; | ||
613 | |||
614 | lockfile = LOCK_DIR; | ||
615 | lockfile += "/LCK.."; | ||
616 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | ||
617 | qDebug("lockfile >%s<",lockfile.latin1()); | ||
618 | // TODO: | ||
619 | // struct stat st; | ||
620 | // if(stat(lockfile.data(), &st) == -1) { | ||
621 | // if(errno == EBADF) | ||
622 | // return -1; | ||
623 | // } else { | ||
624 | // // make sure that this is a regular file | ||
625 | // if(!S_ISREG(st.st_mode)) | ||
626 | // return -1; | ||
627 | // } | ||
628 | if ((fd = open(lockfile, flags, mode)) == -1) { | ||
629 | qDebug("error opening lockfile!"); | ||
630 | lockfile = QString::null; | ||
631 | fd = open(DEVNULL, O_RDONLY); | ||
632 | } else | ||
633 | fchown(fd, 0, 0); | ||
634 | return fd; | ||
635 | } | ||
636 | |||
637 | |||
638 | |||
639 | void alarm_handler(int) { | ||
640 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | ||
641 | |||
642 | // jump | ||
643 | siglongjmp(jmp_buffer, 1); | ||
644 | } | ||
645 | |||
646 | |||
647 | |||
648 | const char* pppdPath() { | ||
649 | // wasting a few bytes | ||
650 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | ||
651 | static char *pppdPath = 0L; | ||
652 | char *p; | ||
653 | |||
654 | if(pppdPath == 0L) { | ||
655 | const char *c = PPPDSEARCHPATH; | ||
656 | while(*c != '\0') { | ||
657 | while(*c == ':') | ||
658 | c++; | ||
659 | p = buffer; | ||
660 | while(*c != '\0' && *c != ':') | ||
661 | *p++ = *c++; | ||
662 | *p = '\0'; | ||
663 | strcat(p, "/"); | ||
664 | strcat(p, PPPDNAME); | ||
665 | if(access(buffer, F_OK) == 0) | ||
666 | return (pppdPath = buffer); | ||
667 | } | ||
668 | } | ||
669 | |||
670 | return pppdPath; | ||
671 | } | ||
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h new file mode 100644 index 0000000..c23524a --- a/dev/null +++ b/noncore/settings/networksettings/ppp/modem.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd Front End for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | ||
10 | * | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #ifndef _MODEM_H_ | ||
28 | #define _MODEM_H_ | ||
29 | |||
30 | #include <qdir.h> | ||
31 | |||
32 | #include <sys/types.h> | ||
33 | #include <termios.h> | ||
34 | #include <unistd.h> | ||
35 | |||
36 | #include <qsocketnotifier.h> | ||
37 | |||
38 | //#include <config.h> | ||
39 | |||
40 | void alarm_handler(int); | ||
41 | const char *pppdPath(); | ||
42 | |||
43 | class Modem : public QObject { | ||
44 | Q_OBJECT | ||
45 | public: | ||
46 | Modem(); | ||
47 | ~Modem(); | ||
48 | |||
49 | const QString getDevice() {return device;}; | ||
50 | void setDevice(const QString dev) {device = dev;}; | ||
51 | |||
52 | bool opentty(); | ||
53 | bool closetty(); | ||
54 | bool hangup(); | ||
55 | bool writeChar(unsigned char); | ||
56 | bool writeLine(const char *); | ||
57 | bool dataMode() const { return data_mode; } | ||
58 | void setDataMode(bool set) { data_mode = set; } | ||
59 | const QString modemMessage(); | ||
60 | speed_t modemspeed(); | ||
61 | static QString parseModemSpeed(const QString &); | ||
62 | void notify(const QObject *, const char *); | ||
63 | void stop(); | ||
64 | void flush(); | ||
65 | |||
66 | int lockdevice(); | ||
67 | void unlockdevice(); | ||
68 | |||
69 | public: | ||
70 | static Modem *modem; | ||
71 | |||
72 | signals: | ||
73 | void charWaiting(unsigned char); | ||
74 | |||
75 | private slots: | ||
76 | void startNotifier(); | ||
77 | void stopNotifier(); | ||
78 | void readtty(int); | ||
79 | |||
80 | private: | ||
81 | void escape_to_command_mode(); | ||
82 | int openLockfile(QString,int); | ||
83 | |||
84 | private: | ||
85 | QString device; | ||
86 | QString lockfile; | ||
87 | int modemfd; | ||
88 | QSocketNotifier *sn; | ||
89 | bool data_mode; | ||
90 | QString errmsg; | ||
91 | struct termios initial_tty; | ||
92 | struct termios tty; | ||
93 | bool modem_is_locked; | ||
94 | }; | ||
95 | |||
96 | #endif | ||
97 | |||
98 | |||
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp new file mode 100644 index 0000000..8c81e67 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -0,0 +1,294 @@ | |||
1 | /* | ||
2 | * kPPP: A front end for pppd for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de | ||
10 | * | ||
11 | * | ||
12 | * This library is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This library is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <qregexp.h> | ||
29 | #include <qlayout.h> | ||
30 | // #include <kwin.h> | ||
31 | // #include <kmessagebox.h> | ||
32 | // #include <kapplication.h> | ||
33 | #include <qmessagebox.h> | ||
34 | #include <qapplication.h> | ||
35 | #include "modeminfo.h" | ||
36 | #include "modem.h" | ||
37 | //#include <klocale.h> | ||
38 | #define i18n QObject::tr | ||
39 | |||
40 | ModemTransfer::ModemTransfer(QWidget *parent, const char *name) | ||
41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder) | ||
42 | { | ||
43 | setCaption(i18n("ATI Query")); | ||
44 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | ||
45 | |||
46 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | ||
47 | |||
48 | progressBar = new QProgressBar(this, "bar"); | ||
49 | progressBar->setTotalSteps(8); | ||
50 | |||
51 | statusBar = new QLabel(this,"sBar"); | ||
52 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | ||
53 | statusBar->setAlignment(AlignCenter); | ||
54 | |||
55 | // This is a rather complicated case. Since we do not know which | ||
56 | // message is the widest in the national language, we'd to | ||
57 | // search all these messages. This is a little overkill, so I take | ||
58 | // the longest english message, translate it and give it additional | ||
59 | // 20 percent space. Hope this is enough. | ||
60 | statusBar->setText(i18n("Unable to create modem lock file.")); | ||
61 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | ||
62 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | ||
63 | |||
64 | // set original text | ||
65 | statusBar->setText(i18n("Looking for modem...")); | ||
66 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | ||
67 | tl->addWidget(progressBar); | ||
68 | tl->addWidget(statusBar); | ||
69 | |||
70 | cancel = new QPushButton(i18n("Cancel"), this); | ||
71 | cancel->setFocus(); | ||
72 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | ||
73 | |||
74 | QHBoxLayout *l1 = new QHBoxLayout; | ||
75 | tl->addLayout(l1); | ||
76 | l1->addStretch(1); | ||
77 | l1->addWidget(cancel); | ||
78 | |||
79 | setFixedSize(sizeHint()); | ||
80 | |||
81 | step = 0; | ||
82 | |||
83 | //////////////////////////////////////////////// | ||
84 | |||
85 | timeout_timer = new QTimer(this); | ||
86 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); | ||
87 | |||
88 | scripttimer = new QTimer(this); | ||
89 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); | ||
90 | |||
91 | timeout_timer->start(15000,TRUE); // 15 secs single shot | ||
92 | QTimer::singleShot(500, this, SLOT(init())); | ||
93 | |||
94 | } | ||
95 | |||
96 | |||
97 | void ModemTransfer::ati_done() { | ||
98 | scripttimer->stop(); | ||
99 | timeout_timer->stop(); | ||
100 | Modem::modem->closetty(); | ||
101 | Modem::modem->unlockdevice(); | ||
102 | hide(); | ||
103 | |||
104 | // open the result window | ||
105 | ModemInfo *mi = new ModemInfo(this); | ||
106 | for(int i = 0; i < NUM_OF_ATI; i++) | ||
107 | mi->setAtiString(i, ati_query_strings[i]); | ||
108 | mi->exec(); | ||
109 | delete mi; | ||
110 | |||
111 | accept(); | ||
112 | } | ||
113 | |||
114 | |||
115 | void ModemTransfer::time_out_slot() { | ||
116 | timeout_timer->stop(); | ||
117 | scripttimer->stop(); | ||
118 | |||
119 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); | ||
120 | reject(); | ||
121 | } | ||
122 | |||
123 | |||
124 | void ModemTransfer::init() { | ||
125 | |||
126 | qApp->processEvents(); | ||
127 | |||
128 | int lock = Modem::modem->lockdevice(); | ||
129 | if (lock == 1) { | ||
130 | |||
131 | statusBar->setText(i18n("Modem device is locked.")); | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | if (lock == -1) { | ||
136 | |||
137 | statusBar->setText(i18n("Unable to create modem lock file.")); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | |||
142 | if(Modem::modem->opentty()) { | ||
143 | if(Modem::modem->hangup()) { | ||
144 | usleep(100000); // wait 0.1 secs | ||
145 | Modem::modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | ||
146 | |||
147 | statusBar->setText(i18n("Modem Ready")); | ||
148 | qApp->processEvents(); | ||
149 | usleep(100000); // wait 0.1 secs | ||
150 | qApp->processEvents(); | ||
151 | scripttimer->start(1000); // this one does the ati query | ||
152 | |||
153 | // clear modem buffer | ||
154 | Modem::modem->flush(); | ||
155 | |||
156 | Modem::modem->notify(this, SLOT(readChar(unsigned char))); | ||
157 | return; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | // opentty() or hangup() failed | ||
162 | statusBar->setText(Modem::modem->modemMessage()); | ||
163 | step = 99; // wait until cancel is pressed | ||
164 | Modem::modem->unlockdevice(); | ||
165 | } | ||
166 | |||
167 | |||
168 | void ModemTransfer::do_script() { | ||
169 | QString msg; | ||
170 | QString query; | ||
171 | |||
172 | switch(step) { | ||
173 | case 0: | ||
174 | readtty(); | ||
175 | statusBar->setText("ATI..."); | ||
176 | progressBar->setProgress( progressBar->progress() + 1); | ||
177 | Modem::modem->writeLine("ATI\n"); | ||
178 | break; | ||
179 | |||
180 | case 1: | ||
181 | case 2: | ||
182 | case 3: | ||
183 | case 4: | ||
184 | case 5: | ||
185 | case 6: | ||
186 | case 7: | ||
187 | readtty(); | ||
188 | msg.sprintf("ATI %d ...", step); | ||
189 | query.sprintf("ATI%d\n", step); | ||
190 | statusBar->setText(msg); | ||
191 | progressBar->setProgress( progressBar->progress() + 1); | ||
192 | Modem::modem->writeLine(query.local8Bit()); | ||
193 | break; | ||
194 | |||
195 | default: | ||
196 | readtty(); | ||
197 | ati_done(); | ||
198 | } | ||
199 | step++; | ||
200 | } | ||
201 | |||
202 | void ModemTransfer::readChar(unsigned char c) { | ||
203 | if(readbuffer.length() < 255) | ||
204 | readbuffer += c; | ||
205 | } | ||
206 | |||
207 | void ModemTransfer::readtty() { | ||
208 | |||
209 | if (step == 0) | ||
210 | return; | ||
211 | |||
212 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r | ||
213 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white | ||
214 | // space | ||
215 | |||
216 | if(step <= NUM_OF_ATI) | ||
217 | ati_query_strings[step-1] = readbuffer.copy(); | ||
218 | |||
219 | readbuffer = ""; | ||
220 | } | ||
221 | |||
222 | |||
223 | void ModemTransfer::cancelbutton() { | ||
224 | scripttimer->stop(); | ||
225 | Modem::modem->stop(); | ||
226 | timeout_timer->stop(); | ||
227 | |||
228 | statusBar->setText(i18n("One moment please...")); | ||
229 | qApp->processEvents(); | ||
230 | |||
231 | Modem::modem->hangup(); | ||
232 | |||
233 | Modem::modem->closetty(); | ||
234 | Modem::modem->unlockdevice(); | ||
235 | reject(); | ||
236 | } | ||
237 | |||
238 | |||
239 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | ||
240 | cancelbutton(); | ||
241 | e->accept(); | ||
242 | } | ||
243 | |||
244 | |||
245 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | ||
246 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | ||
247 | { | ||
248 | QString label_text; | ||
249 | |||
250 | setCaption(i18n("Modem Query Results")); | ||
251 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | ||
252 | |||
253 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | ||
254 | |||
255 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | ||
256 | tl->addLayout(l1, 1); | ||
257 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | ||
258 | |||
259 | label_text = ""; | ||
260 | if ( i == 0) | ||
261 | label_text.sprintf("ATI :"); | ||
262 | else | ||
263 | label_text.sprintf("ATI %d:", i ); | ||
264 | |||
265 | ati_label[i] = new QLabel(label_text, this); | ||
266 | l1->addWidget(ati_label[i], i, 0); | ||
267 | |||
268 | ati_label_result[i] = new QLineEdit(this); | ||
269 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | ||
270 | l1->addWidget(ati_label_result[i], i, 1); | ||
271 | } | ||
272 | //tl->addSpacing(1); | ||
273 | |||
274 | QHBoxLayout *l2 = new QHBoxLayout; | ||
275 | QPushButton *ok = new QPushButton(i18n("Close"), this); | ||
276 | ok->setDefault(TRUE); | ||
277 | ok->setFocus(); | ||
278 | |||
279 | tl->addLayout(l2); | ||
280 | l2->addStretch(1); | ||
281 | |||
282 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | ||
283 | l2->addWidget(ok); | ||
284 | |||
285 | setMinimumSize(sizeHint()); | ||
286 | } | ||
287 | |||
288 | |||
289 | void ModemInfo::setAtiString(int i, QString s) { | ||
290 | if(i < NUM_OF_ATI) | ||
291 | ati_label_result[i]->setText(s); | ||
292 | } | ||
293 | |||
294 | //#include "modeminfo.moc" | ||
diff --git a/noncore/settings/networksettings/ppp/modeminfo.h b/noncore/settings/networksettings/ppp/modeminfo.h new file mode 100644 index 0000000..7aa2cc0 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/modeminfo.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | * | ||
3 | * kPPP: A front end for pppd for the KDE project | ||
4 | * | ||
5 | * $Id$ | ||
6 | * | ||
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
8 | * wuebben@math.cornell.edu | ||
9 | * | ||
10 | * | ||
11 | * This library is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU Library General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This library is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * Library General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU Library General Public | ||
22 | * License along with this program; if not, write to the Free | ||
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | |||
28 | #ifndef _MODEMINFO_H_ | ||
29 | #define _MODEMINFO_H_ | ||
30 | |||
31 | #include <qdialog.h> | ||
32 | #include <qlineedit.h> | ||
33 | #include <qpushbutton.h> | ||
34 | #include <qlabel.h> | ||
35 | #include <qevent.h> | ||
36 | #include <qtimer.h> | ||
37 | //#include <kprogress.h> | ||
38 | #include <qprogressbar.h> | ||
39 | |||
40 | const int NUM_OF_ATI = 8; | ||
41 | |||
42 | |||
43 | class ModemTransfer : public QDialog { | ||
44 | Q_OBJECT | ||
45 | public: | ||
46 | ModemTransfer(QWidget *parent=0, const char *name=0); | ||
47 | |||
48 | public slots: | ||
49 | void init(); | ||
50 | void readtty(); | ||
51 | void do_script(); | ||
52 | void time_out_slot(); | ||
53 | void cancelbutton(); | ||
54 | void readChar(unsigned char); | ||
55 | |||
56 | private: | ||
57 | void ati_done(); | ||
58 | |||
59 | protected: | ||
60 | void closeEvent(QCloseEvent *e); | ||
61 | |||
62 | private: | ||
63 | int step; | ||
64 | QString readbuffer; | ||
65 | |||
66 | QPushButton *cancel; | ||
67 | QProgressBar *progressBar; | ||
68 | QLabel *statusBar; | ||
69 | |||
70 | QTimer *timeout_timer; | ||
71 | QTimer *scripttimer; | ||
72 | QString ati_query_strings[NUM_OF_ATI]; | ||
73 | }; | ||
74 | |||
75 | |||
76 | class ModemInfo : public QDialog { | ||
77 | Q_OBJECT | ||
78 | public: | ||
79 | ModemInfo(QWidget *parent=0, const char *name=0); | ||
80 | |||
81 | public: | ||
82 | void setAtiString(int num, QString s); | ||
83 | |||
84 | private: | ||
85 | QLabel *ati_label[NUM_OF_ATI]; | ||
86 | QLineEdit *ati_label_result[NUM_OF_ATI]; | ||
87 | }; | ||
88 | |||
89 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index 0e9e5b8..da32395 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,16 +1,17 @@ | |||
1 | #TEMPLATE = app | ||
1 | TEMPLATE = lib | 2 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 3 | #CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 4 | CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksettings | 5 | DESTDIR = $(OPIEDIR)/plugins/networksettings |
5 | HEADERS = pppimp.h pppmodule.h | 6 | HEADERS = pppimp.h pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h |
6 | SOURCES = pppimp.cpp pppmodule.cpp | 7 | SOURCES = pppimp.cpp pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp |
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 8 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
8 | DEPENDPATH+= $(OPIEDIR)/include | 9 | DEPENDPATH+= $(OPIEDIR)/include |
9 | LIBS += -lqpe -L../interfaces/ -linterfaces | 10 | LIBS += -lqpe -L../interfaces/ -linterfaces |
10 | INTERFACES= ppp.ui | 11 | INTERFACES= ppp.ui |
11 | TARGET = pppplugin | 12 | TARGET = pppplugin |
12 | VERSION = 1.0.0 | 13 | VERSION = 1.0.0 |
13 | 14 | ||
14 | 15 | ||
15 | 16 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/ppp/ppp.ui b/noncore/settings/networksettings/ppp/ppp.ui index 56e1621..2fcb419 100644 --- a/noncore/settings/networksettings/ppp/ppp.ui +++ b/noncore/settings/networksettings/ppp/ppp.ui | |||
@@ -1,519 +1,573 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>PPP</class> | 2 | <class>PPP</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>PPP</cstring> | 7 | <cstring>PPP</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>277</width> | 14 | <width>355</width> |
15 | <height>340</height> | 15 | <height>418</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>sizePolicy</name> | ||
20 | <sizepolicy> | ||
21 | <hsizetype>3</hsizetype> | ||
22 | <vsizetype>3</vsizetype> | ||
23 | </sizepolicy> | ||
24 | </property> | ||
25 | <property stdset="1"> | ||
19 | <name>caption</name> | 26 | <name>caption</name> |
20 | <string>Dial-up </string> | 27 | <string>Dial-up </string> |
21 | </property> | 28 | </property> |
22 | <property> | 29 | <property> |
23 | <name>layoutMargin</name> | 30 | <name>layoutMargin</name> |
24 | </property> | 31 | </property> |
25 | <property> | 32 | <property> |
26 | <name>layoutSpacing</name> | 33 | <name>layoutSpacing</name> |
27 | </property> | 34 | </property> |
28 | <vbox> | 35 | <vbox> |
29 | <property stdset="1"> | 36 | <property stdset="1"> |
30 | <name>margin</name> | 37 | <name>margin</name> |
31 | <number>1</number> | 38 | <number>1</number> |
32 | </property> | 39 | </property> |
33 | <property stdset="1"> | 40 | <property stdset="1"> |
34 | <name>spacing</name> | 41 | <name>spacing</name> |
35 | <number>0</number> | 42 | <number>0</number> |
36 | </property> | 43 | </property> |
37 | <widget> | 44 | <widget> |
38 | <class>QTabWidget</class> | 45 | <class>QTabWidget</class> |
39 | <property stdset="1"> | 46 | <property stdset="1"> |
40 | <name>name</name> | 47 | <name>name</name> |
41 | <cstring>TabWidget2</cstring> | 48 | <cstring>TabWidget2</cstring> |
42 | </property> | 49 | </property> |
43 | <property> | 50 | <property> |
44 | <name>layoutMargin</name> | 51 | <name>layoutMargin</name> |
45 | </property> | 52 | </property> |
46 | <property> | 53 | <property> |
47 | <name>layoutSpacing</name> | 54 | <name>layoutSpacing</name> |
48 | </property> | 55 | </property> |
49 | <widget> | 56 | <widget> |
50 | <class>QWidget</class> | 57 | <class>QWidget</class> |
51 | <property stdset="1"> | 58 | <property stdset="1"> |
52 | <name>name</name> | 59 | <name>name</name> |
53 | <cstring>tab</cstring> | 60 | <cstring>tab</cstring> |
54 | </property> | 61 | </property> |
55 | <attribute> | 62 | <attribute> |
56 | <name>title</name> | 63 | <name>title</name> |
57 | <string>Account</string> | 64 | <string>Account</string> |
58 | </attribute> | 65 | </attribute> |
59 | <grid> | 66 | <grid> |
60 | <property stdset="1"> | 67 | <property stdset="1"> |
61 | <name>margin</name> | 68 | <name>margin</name> |
62 | <number>6</number> | 69 | <number>6</number> |
63 | </property> | 70 | </property> |
64 | <property stdset="1"> | 71 | <property stdset="1"> |
65 | <name>spacing</name> | 72 | <name>spacing</name> |
66 | <number>4</number> | 73 | <number>4</number> |
67 | </property> | 74 | </property> |
68 | <widget row="3" column="1" > | 75 | <widget row="3" column="1" > |
69 | <class>QLineEdit</class> | 76 | <class>QLineEdit</class> |
70 | <property stdset="1"> | 77 | <property stdset="1"> |
71 | <name>name</name> | 78 | <name>name</name> |
72 | <cstring>password</cstring> | 79 | <cstring>password</cstring> |
73 | </property> | 80 | </property> |
74 | <property stdset="1"> | 81 | <property stdset="1"> |
75 | <name>echoMode</name> | 82 | <name>echoMode</name> |
76 | <enum>Password</enum> | 83 | <enum>Password</enum> |
77 | </property> | 84 | </property> |
78 | </widget> | 85 | </widget> |
79 | <widget row="2" column="1" > | 86 | <widget row="2" column="1" > |
80 | <class>QLineEdit</class> | 87 | <class>QLineEdit</class> |
81 | <property stdset="1"> | 88 | <property stdset="1"> |
82 | <name>name</name> | 89 | <name>name</name> |
83 | <cstring>username</cstring> | 90 | <cstring>username</cstring> |
84 | </property> | 91 | </property> |
85 | </widget> | 92 | </widget> |
86 | <widget row="2" column="0" > | 93 | <widget row="2" column="0" > |
87 | <class>QLabel</class> | 94 | <class>QLabel</class> |
88 | <property stdset="1"> | 95 | <property stdset="1"> |
89 | <name>name</name> | 96 | <name>name</name> |
90 | <cstring>TextLabel1</cstring> | 97 | <cstring>TextLabel1</cstring> |
91 | </property> | 98 | </property> |
92 | <property stdset="1"> | 99 | <property stdset="1"> |
93 | <name>text</name> | 100 | <name>text</name> |
94 | <string>Username</string> | 101 | <string>Username</string> |
95 | </property> | 102 | </property> |
96 | </widget> | 103 | </widget> |
97 | <widget row="3" column="0" > | 104 | <widget row="3" column="0" > |
98 | <class>QLabel</class> | 105 | <class>QLabel</class> |
99 | <property stdset="1"> | 106 | <property stdset="1"> |
100 | <name>name</name> | 107 | <name>name</name> |
101 | <cstring>TextLabel2</cstring> | 108 | <cstring>TextLabel2</cstring> |
102 | </property> | 109 | </property> |
103 | <property stdset="1"> | 110 | <property stdset="1"> |
104 | <name>text</name> | 111 | <name>text</name> |
105 | <string>Password</string> | 112 | <string>Password</string> |
106 | </property> | 113 | </property> |
107 | </widget> | 114 | </widget> |
108 | <widget row="5" column="0" > | 115 | <widget row="5" column="0" > |
109 | <class>QLabel</class> | 116 | <class>QLabel</class> |
110 | <property stdset="1"> | 117 | <property stdset="1"> |
111 | <name>name</name> | 118 | <name>name</name> |
112 | <cstring>TextLabel1_2_2</cstring> | 119 | <cstring>TextLabel1_2_2</cstring> |
113 | </property> | 120 | </property> |
114 | <property stdset="1"> | 121 | <property stdset="1"> |
115 | <name>text</name> | 122 | <name>text</name> |
116 | <string>Phone #</string> | 123 | <string>Phone #</string> |
117 | </property> | 124 | </property> |
118 | </widget> | 125 | </widget> |
119 | <widget row="5" column="1" > | 126 | <widget row="5" column="1" > |
120 | <class>QLineEdit</class> | 127 | <class>QLineEdit</class> |
121 | <property stdset="1"> | 128 | <property stdset="1"> |
122 | <name>name</name> | 129 | <name>name</name> |
123 | <cstring>phone</cstring> | 130 | <cstring>phone</cstring> |
124 | </property> | 131 | </property> |
125 | </widget> | 132 | </widget> |
126 | <widget row="4" column="0" rowspan="1" colspan="2" > | 133 | <widget row="4" column="0" rowspan="1" colspan="2" > |
127 | <class>Line</class> | 134 | <class>Line</class> |
128 | <property stdset="1"> | 135 | <property stdset="1"> |
129 | <name>name</name> | 136 | <name>name</name> |
130 | <cstring>Line3</cstring> | 137 | <cstring>Line3</cstring> |
131 | </property> | 138 | </property> |
132 | <property stdset="1"> | 139 | <property stdset="1"> |
133 | <name>orientation</name> | 140 | <name>orientation</name> |
134 | <enum>Horizontal</enum> | 141 | <enum>Horizontal</enum> |
135 | </property> | 142 | </property> |
136 | </widget> | 143 | </widget> |
137 | <widget row="0" column="1" > | 144 | <widget row="0" column="1" > |
138 | <class>QLineEdit</class> | 145 | <class>QLineEdit</class> |
139 | <property stdset="1"> | 146 | <property stdset="1"> |
140 | <name>name</name> | 147 | <name>name</name> |
141 | <cstring>acname</cstring> | 148 | <cstring>acname</cstring> |
142 | </property> | 149 | </property> |
143 | </widget> | 150 | </widget> |
144 | <widget row="0" column="0" > | 151 | <widget row="0" column="0" > |
145 | <class>QLabel</class> | 152 | <class>QLabel</class> |
146 | <property stdset="1"> | 153 | <property stdset="1"> |
147 | <name>name</name> | 154 | <name>name</name> |
148 | <cstring>TextLabel1_2</cstring> | 155 | <cstring>TextLabel1_2</cstring> |
149 | </property> | 156 | </property> |
150 | <property stdset="1"> | 157 | <property stdset="1"> |
151 | <name>text</name> | 158 | <name>text</name> |
152 | <string>Name</string> | 159 | <string>Name</string> |
153 | </property> | 160 | </property> |
154 | </widget> | 161 | </widget> |
155 | <widget row="1" column="0" rowspan="1" colspan="2" > | 162 | <widget row="1" column="0" rowspan="1" colspan="2" > |
156 | <class>Line</class> | 163 | <class>Line</class> |
157 | <property stdset="1"> | 164 | <property stdset="1"> |
158 | <name>name</name> | 165 | <name>name</name> |
159 | <cstring>Line4</cstring> | 166 | <cstring>Line4</cstring> |
160 | </property> | 167 | </property> |
161 | <property stdset="1"> | 168 | <property stdset="1"> |
162 | <name>orientation</name> | 169 | <name>orientation</name> |
163 | <enum>Horizontal</enum> | 170 | <enum>Horizontal</enum> |
164 | </property> | 171 | </property> |
165 | </widget> | 172 | </widget> |
166 | <spacer row="9" column="1" > | 173 | <spacer row="9" column="1" > |
167 | <property> | 174 | <property> |
168 | <name>name</name> | 175 | <name>name</name> |
169 | <cstring>Spacer4</cstring> | 176 | <cstring>Spacer4</cstring> |
170 | </property> | 177 | </property> |
171 | <property stdset="1"> | 178 | <property stdset="1"> |
172 | <name>orientation</name> | 179 | <name>orientation</name> |
173 | <enum>Vertical</enum> | 180 | <enum>Vertical</enum> |
174 | </property> | 181 | </property> |
175 | <property stdset="1"> | 182 | <property stdset="1"> |
176 | <name>sizeType</name> | 183 | <name>sizeType</name> |
177 | <enum>Expanding</enum> | 184 | <enum>Expanding</enum> |
178 | </property> | 185 | </property> |
179 | <property> | 186 | <property> |
180 | <name>sizeHint</name> | 187 | <name>sizeHint</name> |
181 | <size> | 188 | <size> |
182 | <width>20</width> | 189 | <width>20</width> |
183 | <height>20</height> | 190 | <height>20</height> |
184 | </size> | 191 | </size> |
185 | </property> | 192 | </property> |
186 | </spacer> | 193 | </spacer> |
187 | </grid> | 194 | </grid> |
188 | </widget> | 195 | </widget> |
189 | <widget> | 196 | <widget> |
190 | <class>QWidget</class> | 197 | <class>QWidget</class> |
191 | <property stdset="1"> | 198 | <property stdset="1"> |
192 | <name>name</name> | 199 | <name>name</name> |
193 | <cstring>tab</cstring> | 200 | <cstring>tab</cstring> |
194 | </property> | 201 | </property> |
195 | <attribute> | 202 | <attribute> |
196 | <name>title</name> | 203 | <name>title</name> |
197 | <string>Modem</string> | 204 | <string>Modem</string> |
198 | </attribute> | 205 | </attribute> |
199 | <grid> | 206 | <grid> |
200 | <property stdset="1"> | 207 | <property stdset="1"> |
201 | <name>margin</name> | 208 | <name>margin</name> |
202 | <number>6</number> | 209 | <number>11</number> |
203 | </property> | 210 | </property> |
204 | <property stdset="1"> | 211 | <property stdset="1"> |
205 | <name>spacing</name> | 212 | <name>spacing</name> |
206 | <number>4</number> | 213 | <number>6</number> |
207 | </property> | 214 | </property> |
215 | <widget row="4" column="2" rowspan="1" colspan="3" > | ||
216 | <class>QPushButton</class> | ||
217 | <property stdset="1"> | ||
218 | <name>name</name> | ||
219 | <cstring>PushButtonQuery</cstring> | ||
220 | </property> | ||
221 | <property stdset="1"> | ||
222 | <name>sizePolicy</name> | ||
223 | <sizepolicy> | ||
224 | <hsizetype>3</hsizetype> | ||
225 | <vsizetype>0</vsizetype> | ||
226 | </sizepolicy> | ||
227 | </property> | ||
228 | <property stdset="1"> | ||
229 | <name>text</name> | ||
230 | <string>Query Modem</string> | ||
231 | </property> | ||
232 | </widget> | ||
233 | <widget row="4" column="1" > | ||
234 | <class>QComboBox</class> | ||
235 | <property stdset="1"> | ||
236 | <name>name</name> | ||
237 | <cstring>ComboBoxDevice</cstring> | ||
238 | </property> | ||
239 | </widget> | ||
240 | <widget row="4" column="0" > | ||
241 | <class>QLabel</class> | ||
242 | <property stdset="1"> | ||
243 | <name>name</name> | ||
244 | <cstring>TextLabel1_6</cstring> | ||
245 | </property> | ||
246 | <property stdset="1"> | ||
247 | <name>text</name> | ||
248 | <string>Device</string> | ||
249 | </property> | ||
250 | </widget> | ||
208 | <widget row="0" column="0" > | 251 | <widget row="0" column="0" > |
209 | <class>QLabel</class> | 252 | <class>QLabel</class> |
210 | <property stdset="1"> | 253 | <property stdset="1"> |
211 | <name>name</name> | 254 | <name>name</name> |
212 | <cstring>TextLabel3_2_2</cstring> | 255 | <cstring>TextLabel3_2_2</cstring> |
213 | </property> | 256 | </property> |
214 | <property stdset="1"> | 257 | <property stdset="1"> |
215 | <name>text</name> | 258 | <name>text</name> |
216 | <string>AT-dial</string> | 259 | <string>AT-dial</string> |
217 | </property> | 260 | </property> |
218 | </widget> | 261 | </widget> |
219 | <widget row="0" column="1" rowspan="1" colspan="3" > | 262 | <widget row="0" column="1" rowspan="1" colspan="4" > |
220 | <class>QComboBox</class> | 263 | <class>QComboBox</class> |
221 | <item> | 264 | <item> |
222 | <property> | 265 | <property> |
223 | <name>text</name> | 266 | <name>text</name> |
224 | <string>ATDT</string> | 267 | <string>ATDT</string> |
225 | </property> | 268 | </property> |
226 | </item> | 269 | </item> |
227 | <item> | 270 | <item> |
228 | <property> | 271 | <property> |
229 | <name>text</name> | 272 | <name>text</name> |
230 | <string>ATDP</string> | 273 | <string>ATDP</string> |
231 | </property> | 274 | </property> |
232 | </item> | 275 | </item> |
233 | <property stdset="1"> | 276 | <property stdset="1"> |
234 | <name>name</name> | 277 | <name>name</name> |
235 | <cstring>atdial</cstring> | 278 | <cstring>atdial</cstring> |
236 | </property> | 279 | </property> |
237 | <property stdset="1"> | 280 | <property stdset="1"> |
238 | <name>editable</name> | 281 | <name>editable</name> |
239 | <bool>true</bool> | 282 | <bool>true</bool> |
240 | </property> | 283 | </property> |
284 | <property stdset="1"> | ||
285 | <name>currentItem</name> | ||
286 | <number>0</number> | ||
287 | </property> | ||
241 | </widget> | 288 | </widget> |
242 | <widget row="1" column="0" > | 289 | <widget row="1" column="0" > |
243 | <class>QLabel</class> | 290 | <class>QLabel</class> |
244 | <property stdset="1"> | 291 | <property stdset="1"> |
245 | <name>name</name> | 292 | <name>name</name> |
246 | <cstring>TextLabel1_4</cstring> | 293 | <cstring>TextLabel1_4</cstring> |
247 | </property> | 294 | </property> |
248 | <property stdset="1"> | 295 | <property stdset="1"> |
249 | <name>text</name> | 296 | <name>text</name> |
250 | <string>Speed</string> | 297 | <string>Speed</string> |
251 | </property> | 298 | </property> |
252 | </widget> | 299 | </widget> |
253 | <widget row="1" column="1" rowspan="1" colspan="3" > | 300 | <widget row="1" column="1" rowspan="1" colspan="4" > |
254 | <class>QComboBox</class> | 301 | <class>QComboBox</class> |
255 | <item> | 302 | <item> |
256 | <property> | 303 | <property> |
257 | <name>text</name> | 304 | <name>text</name> |
258 | <string>4800</string> | 305 | <string>4800</string> |
259 | </property> | 306 | </property> |
260 | </item> | 307 | </item> |
261 | <item> | 308 | <item> |
262 | <property> | 309 | <property> |
263 | <name>text</name> | 310 | <name>text</name> |
264 | <string>9600</string> | 311 | <string>9600</string> |
265 | </property> | 312 | </property> |
266 | </item> | 313 | </item> |
267 | <item> | 314 | <item> |
268 | <property> | 315 | <property> |
269 | <name>text</name> | 316 | <name>text</name> |
270 | <string>19200</string> | 317 | <string>19200</string> |
271 | </property> | 318 | </property> |
272 | </item> | 319 | </item> |
273 | <item> | 320 | <item> |
274 | <property> | 321 | <property> |
275 | <name>text</name> | 322 | <name>text</name> |
276 | <string>38400</string> | 323 | <string>38400</string> |
277 | </property> | 324 | </property> |
278 | </item> | 325 | </item> |
279 | <item> | 326 | <item> |
280 | <property> | 327 | <property> |
281 | <name>text</name> | 328 | <name>text</name> |
282 | <string>57600</string> | 329 | <string>57600</string> |
283 | </property> | 330 | </property> |
284 | </item> | 331 | </item> |
285 | <item> | 332 | <item> |
286 | <property> | 333 | <property> |
287 | <name>text</name> | 334 | <name>text</name> |
288 | <string>115200</string> | 335 | <string>115200</string> |
289 | </property> | 336 | </property> |
290 | </item> | 337 | </item> |
291 | <property stdset="1"> | 338 | <property stdset="1"> |
292 | <name>name</name> | 339 | <name>name</name> |
293 | <cstring>speed</cstring> | 340 | <cstring>speed</cstring> |
294 | </property> | 341 | </property> |
295 | <property stdset="1"> | 342 | <property stdset="1"> |
296 | <name>currentItem</name> | 343 | <name>currentItem</name> |
297 | <number>5</number> | 344 | <number>5</number> |
298 | </property> | 345 | </property> |
299 | </widget> | 346 | </widget> |
300 | <widget row="3" column="1" > | 347 | <widget row="3" column="1" rowspan="1" colspan="2" > |
301 | <class>QSlider</class> | 348 | <class>QSlider</class> |
302 | <property stdset="1"> | 349 | <property stdset="1"> |
303 | <name>name</name> | 350 | <name>name</name> |
304 | <cstring>connectdelay</cstring> | 351 | <cstring>connectdelay</cstring> |
305 | </property> | 352 | </property> |
306 | <property stdset="1"> | 353 | <property stdset="1"> |
307 | <name>minValue</name> | 354 | <name>minValue</name> |
308 | <number>1</number> | 355 | <number>1</number> |
309 | </property> | 356 | </property> |
310 | <property stdset="1"> | 357 | <property stdset="1"> |
311 | <name>maxValue</name> | 358 | <name>maxValue</name> |
312 | <number>180</number> | 359 | <number>180</number> |
313 | </property> | 360 | </property> |
314 | <property stdset="1"> | 361 | <property stdset="1"> |
315 | <name>value</name> | 362 | <name>value</name> |
316 | <number>6</number> | 363 | <number>6</number> |
317 | </property> | 364 | </property> |
318 | <property stdset="1"> | 365 | <property stdset="1"> |
319 | <name>orientation</name> | 366 | <name>orientation</name> |
320 | <enum>Horizontal</enum> | 367 | <enum>Horizontal</enum> |
321 | </property> | 368 | </property> |
322 | </widget> | 369 | </widget> |
323 | <widget row="3" column="0" > | 370 | <widget row="3" column="0" > |
324 | <class>QLabel</class> | 371 | <class>QLabel</class> |
325 | <property stdset="1"> | 372 | <property stdset="1"> |
326 | <name>name</name> | 373 | <name>name</name> |
327 | <cstring>TextLabel1_3</cstring> | 374 | <cstring>TextLabel1_3</cstring> |
328 | </property> | 375 | </property> |
329 | <property stdset="1"> | 376 | <property stdset="1"> |
330 | <name>text</name> | 377 | <name>text</name> |
331 | <string>Wait time</string> | 378 | <string>Wait time</string> |
332 | </property> | 379 | </property> |
333 | </widget> | 380 | </widget> |
334 | <widget row="3" column="2" > | 381 | <widget row="3" column="3" > |
335 | <class>QLabel</class> | 382 | <class>QLabel</class> |
336 | <property stdset="1"> | 383 | <property stdset="1"> |
337 | <name>name</name> | 384 | <name>name</name> |
338 | <cstring>connectdelay_text</cstring> | 385 | <cstring>connectdelay_text</cstring> |
339 | </property> | 386 | </property> |
340 | <property stdset="1"> | 387 | <property stdset="1"> |
341 | <name>minimumSize</name> | 388 | <name>minimumSize</name> |
342 | <size> | 389 | <size> |
343 | <width>15</width> | 390 | <width>15</width> |
344 | <height>0</height> | 391 | <height>0</height> |
345 | </size> | 392 | </size> |
346 | </property> | 393 | </property> |
347 | <property stdset="1"> | 394 | <property stdset="1"> |
348 | <name>text</name> | 395 | <name>text</name> |
349 | <string>6</string> | 396 | <string>6</string> |
350 | </property> | 397 | </property> |
351 | <property stdset="1"> | 398 | <property stdset="1"> |
352 | <name>alignment</name> | 399 | <name>alignment</name> |
353 | <set>AlignVCenter|AlignRight</set> | 400 | <set>AlignVCenter|AlignRight</set> |
354 | </property> | 401 | </property> |
355 | <property> | 402 | <property> |
356 | <name>hAlign</name> | 403 | <name>hAlign</name> |
357 | </property> | 404 | </property> |
358 | </widget> | 405 | </widget> |
359 | <widget row="3" column="3" > | 406 | <widget row="3" column="4" > |
360 | <class>QLabel</class> | 407 | <class>QLabel</class> |
361 | <property stdset="1"> | 408 | <property stdset="1"> |
362 | <name>name</name> | 409 | <name>name</name> |
363 | <cstring>TextLabel5</cstring> | 410 | <cstring>TextLabel5</cstring> |
364 | </property> | 411 | </property> |
365 | <property stdset="1"> | 412 | <property stdset="1"> |
366 | <name>text</name> | 413 | <name>text</name> |
367 | <string>sec</string> | 414 | <string>sec</string> |
368 | </property> | 415 | </property> |
369 | </widget> | 416 | </widget> |
370 | <widget row="2" column="0" > | 417 | <widget row="2" column="0" > |
371 | <class>QLabel</class> | 418 | <class>QLabel</class> |
372 | <property stdset="1"> | 419 | <property stdset="1"> |
373 | <name>name</name> | 420 | <name>name</name> |
374 | <cstring>TextLabel3</cstring> | 421 | <cstring>TextLabel3</cstring> |
375 | </property> | 422 | </property> |
376 | <property stdset="1"> | 423 | <property stdset="1"> |
377 | <name>text</name> | 424 | <name>text</name> |
378 | <string>Flow control</string> | 425 | <string>Flow control</string> |
379 | </property> | 426 | </property> |
380 | </widget> | 427 | </widget> |
381 | <widget row="2" column="1" rowspan="1" colspan="3" > | 428 | <widget row="2" column="1" rowspan="1" colspan="4" > |
382 | <class>QCheckBox</class> | 429 | <class>QCheckBox</class> |
383 | <property stdset="1"> | 430 | <property stdset="1"> |
384 | <name>name</name> | 431 | <name>name</name> |
385 | <cstring>crtscts</cstring> | 432 | <cstring>crtscts</cstring> |
386 | </property> | 433 | </property> |
387 | <property stdset="1"> | 434 | <property stdset="1"> |
388 | <name>text</name> | 435 | <name>text</name> |
389 | <string>Hardware flow control</string> | 436 | <string>Hardware flow control</string> |
390 | </property> | 437 | </property> |
391 | <property stdset="1"> | 438 | <property stdset="1"> |
392 | <name>checked</name> | 439 | <name>checked</name> |
393 | <bool>true</bool> | 440 | <bool>true</bool> |
394 | </property> | 441 | </property> |
395 | </widget> | 442 | </widget> |
396 | <spacer row="4" column="1" > | 443 | <spacer row="5" column="1" > |
397 | <property> | 444 | <property> |
398 | <name>name</name> | 445 | <name>name</name> |
399 | <cstring>Spacer5</cstring> | 446 | <cstring>Spacer5</cstring> |
400 | </property> | 447 | </property> |
401 | <property stdset="1"> | 448 | <property stdset="1"> |
402 | <name>orientation</name> | 449 | <name>orientation</name> |
403 | <enum>Vertical</enum> | 450 | <enum>Vertical</enum> |
404 | </property> | 451 | </property> |
405 | <property stdset="1"> | 452 | <property stdset="1"> |
406 | <name>sizeType</name> | 453 | <name>sizeType</name> |
407 | <enum>Expanding</enum> | 454 | <enum>Expanding</enum> |
408 | </property> | 455 | </property> |
409 | <property> | 456 | <property> |
410 | <name>sizeHint</name> | 457 | <name>sizeHint</name> |
411 | <size> | 458 | <size> |
412 | <width>20</width> | 459 | <width>20</width> |
413 | <height>20</height> | 460 | <height>20</height> |
414 | </size> | 461 | </size> |
415 | </property> | 462 | </property> |
416 | </spacer> | 463 | </spacer> |
417 | <widget row="5" column="0" rowspan="1" colspan="4" > | 464 | <widget row="6" column="0" rowspan="1" colspan="5" > |
418 | <class>QButtonGroup</class> | 465 | <class>QButtonGroup</class> |
419 | <property stdset="1"> | 466 | <property stdset="1"> |
420 | <name>name</name> | 467 | <name>name</name> |
421 | <cstring>dialmode</cstring> | 468 | <cstring>dialmode</cstring> |
422 | </property> | 469 | </property> |
423 | <property stdset="1"> | 470 | <property stdset="1"> |
471 | <name>sizePolicy</name> | ||
472 | <sizepolicy> | ||
473 | <hsizetype>3</hsizetype> | ||
474 | <vsizetype>5</vsizetype> | ||
475 | </sizepolicy> | ||
476 | </property> | ||
477 | <property stdset="1"> | ||
424 | <name>title</name> | 478 | <name>title</name> |
425 | <string>Demand Dialing</string> | 479 | <string>Demand Dialing</string> |
426 | </property> | 480 | </property> |
427 | <grid> | 481 | <grid> |
428 | <property stdset="1"> | 482 | <property stdset="1"> |
429 | <name>margin</name> | 483 | <name>margin</name> |
430 | <number>11</number> | 484 | <number>11</number> |
431 | </property> | 485 | </property> |
432 | <property stdset="1"> | 486 | <property stdset="1"> |
433 | <name>spacing</name> | 487 | <name>spacing</name> |
434 | <number>6</number> | 488 | <number>6</number> |
435 | </property> | 489 | </property> |
436 | <widget row="0" column="0" rowspan="1" colspan="2" > | 490 | <widget row="0" column="0" rowspan="1" colspan="2" > |
437 | <class>QRadioButton</class> | 491 | <class>QRadioButton</class> |
438 | <property stdset="1"> | 492 | <property stdset="1"> |
439 | <name>name</name> | 493 | <name>name</name> |
440 | <cstring>dial_manual</cstring> | 494 | <cstring>dial_manual</cstring> |
441 | </property> | 495 | </property> |
442 | <property stdset="1"> | 496 | <property stdset="1"> |
443 | <name>text</name> | 497 | <name>text</name> |
444 | <string>Manual connect and disconnect</string> | 498 | <string>Manual connect and disconnect</string> |
445 | </property> | 499 | </property> |
446 | </widget> | 500 | </widget> |
447 | <widget row="3" column="1" > | 501 | <widget row="3" column="1" > |
448 | <class>QSpinBox</class> | 502 | <class>QSpinBox</class> |
449 | <property stdset="1"> | 503 | <property stdset="1"> |
450 | <name>name</name> | 504 | <name>name</name> |
451 | <cstring>idletime</cstring> | 505 | <cstring>idletime</cstring> |
452 | </property> | 506 | </property> |
453 | <property stdset="1"> | 507 | <property stdset="1"> |
454 | <name>suffix</name> | 508 | <name>suffix</name> |
455 | <string> seconds</string> | 509 | <string> seconds</string> |
456 | </property> | 510 | </property> |
457 | <property stdset="1"> | 511 | <property stdset="1"> |
458 | <name>maxValue</name> | 512 | <name>maxValue</name> |
459 | <number>3600</number> | 513 | <number>3600</number> |
460 | </property> | 514 | </property> |
461 | <property stdset="1"> | 515 | <property stdset="1"> |
462 | <name>lineStep</name> | 516 | <name>lineStep</name> |
463 | <number>30</number> | 517 | <number>30</number> |
464 | </property> | 518 | </property> |
465 | <property stdset="1"> | 519 | <property stdset="1"> |
466 | <name>value</name> | 520 | <name>value</name> |
467 | <number>120</number> | 521 | <number>120</number> |
468 | </property> | 522 | </property> |
469 | </widget> | 523 | </widget> |
470 | <widget row="3" column="0" > | 524 | <widget row="3" column="0" > |
471 | <class>QLabel</class> | 525 | <class>QLabel</class> |
472 | <property stdset="1"> | 526 | <property stdset="1"> |
473 | <name>name</name> | 527 | <name>name</name> |
474 | <cstring>TextLabel1_5</cstring> | 528 | <cstring>TextLabel1_5</cstring> |
475 | </property> | 529 | </property> |
476 | <property stdset="1"> | 530 | <property stdset="1"> |
477 | <name>sizePolicy</name> | 531 | <name>sizePolicy</name> |
478 | <sizepolicy> | 532 | <sizepolicy> |
479 | <hsizetype>7</hsizetype> | 533 | <hsizetype>7</hsizetype> |
480 | <vsizetype>1</vsizetype> | 534 | <vsizetype>1</vsizetype> |
481 | </sizepolicy> | 535 | </sizepolicy> |
482 | </property> | 536 | </property> |
483 | <property stdset="1"> | 537 | <property stdset="1"> |
484 | <name>text</name> | 538 | <name>text</name> |
485 | <string>Idle timeout:</string> | 539 | <string>Idle timeout:</string> |
486 | </property> | 540 | </property> |
487 | <property stdset="1"> | 541 | <property stdset="1"> |
488 | <name>alignment</name> | 542 | <name>alignment</name> |
489 | <set>AlignVCenter|AlignRight</set> | 543 | <set>AlignVCenter|AlignRight</set> |
490 | </property> | 544 | </property> |
491 | <property> | 545 | <property> |
492 | <name>hAlign</name> | 546 | <name>hAlign</name> |
493 | </property> | 547 | </property> |
494 | </widget> | 548 | </widget> |
495 | <widget row="2" column="0" rowspan="1" colspan="2" > | 549 | <widget row="2" column="0" rowspan="1" colspan="2" > |
496 | <class>QRadioButton</class> | 550 | <class>QRadioButton</class> |
497 | <property stdset="1"> | 551 | <property stdset="1"> |
498 | <name>name</name> | 552 | <name>name</name> |
499 | <cstring>dial_demand</cstring> | 553 | <cstring>dial_demand</cstring> |
500 | </property> | 554 | </property> |
501 | <property stdset="1"> | 555 | <property stdset="1"> |
502 | <name>text</name> | 556 | <name>text</name> |
503 | <string>Automatic connect and disconnect</string> | 557 | <string>Automatic connect and disconnect</string> |
504 | </property> | 558 | </property> |
505 | <property stdset="1"> | 559 | <property stdset="1"> |
506 | <name>checked</name> | 560 | <name>checked</name> |
507 | <bool>true</bool> | 561 | <bool>true</bool> |
508 | </property> | 562 | </property> |
509 | <property stdset="1"> | 563 | <property stdset="1"> |
510 | <name>buttonGroupId</name> | 564 | <name>buttonGroupId</name> |
511 | <number>2</number> | 565 | <number>2</number> |
512 | </property> | 566 | </property> |
513 | </widget> | 567 | </widget> |
514 | <widget row="1" column="0" rowspan="1" colspan="2" > | 568 | <widget row="1" column="0" rowspan="1" colspan="2" > |
515 | <class>QRadioButton</class> | 569 | <class>QRadioButton</class> |
516 | <property stdset="1"> | 570 | <property stdset="1"> |
517 | <name>name</name> | 571 | <name>name</name> |
518 | <cstring>dial_idle</cstring> | 572 | <cstring>dial_idle</cstring> |
519 | </property> | 573 | </property> |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp new file mode 100644 index 0000000..f2386fc --- a/dev/null +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -0,0 +1,1229 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include "pppdata.h" | ||
28 | #include "runtests.h" | ||
29 | #include "devices.h" | ||
30 | //#include <klocale.h> | ||
31 | #define i18n QObject::tr | ||
32 | #include <qpe/config.h> | ||
33 | #include <qmessagebox.h> | ||
34 | #include <qapplication.h> | ||
35 | // #include <klocale.h> | ||
36 | // #include <kconfig.h> | ||
37 | // #include <kmessagebox.h> | ||
38 | // #include <kapplication.h> | ||
39 | #include <assert.h> | ||
40 | |||
41 | PPPData gpppdata; | ||
42 | |||
43 | |||
44 | PPPData::PPPData() | ||
45 | : config(0L), | ||
46 | highcount(-1), // start out with no entries | ||
47 | caccount(-1), // set the current account index also | ||
48 | suidprocessid(-1), // process ID of setuid child | ||
49 | pppdisrunning(false), | ||
50 | pppderror(0) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | |||
55 | // | ||
56 | // open configuration file | ||
57 | // | ||
58 | bool PPPData::open() { | ||
59 | |||
60 | config = new Config("NetworkSetup"); | ||
61 | /* | ||
62 | config = kapp->config(); | ||
63 | |||
64 | if (config->getConfigState() == KConfig::NoAccess) { | ||
65 | KMessageBox::error(0L, | ||
66 | i18n("The application-specific config file could not " | ||
67 | "be opened in either read-write or read-only mode.\n" | ||
68 | "The superuser might have to change its ownership " | ||
69 | "by issuing the following command in your home directory:\n" | ||
70 | "chown {YourUsername} .kde/share/config/kppprc"), | ||
71 | kapp->name()); | ||
72 | return false; | ||
73 | } | ||
74 | |||
75 | // don't expand shell variables | ||
76 | config->setDollarExpansion(false); | ||
77 | */ | ||
78 | |||
79 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | ||
80 | |||
81 | if (highcount > MAX_ACCOUNTS) | ||
82 | highcount = MAX_ACCOUNTS; | ||
83 | |||
84 | if(highcount >= 0 && defaultAccount().isEmpty()) { | ||
85 | setAccountbyIndex(0); | ||
86 | setDefaultAccount(accname()); | ||
87 | } else if(!setAccount(defaultAccount())) | ||
88 | setDefaultAccount(accname()); | ||
89 | |||
90 | // start out with internal debugging disabled | ||
91 | // the user is still free to specify `debug' on his own | ||
92 | setPPPDebug(false); | ||
93 | |||
94 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | ||
95 | |||
96 | return true; | ||
97 | } | ||
98 | |||
99 | |||
100 | // | ||
101 | // save configuration | ||
102 | // | ||
103 | void PPPData::save() { | ||
104 | |||
105 | if (config) { | ||
106 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | ||
107 | // config->sync(); | ||
108 | } | ||
109 | |||
110 | } | ||
111 | |||
112 | |||
113 | // | ||
114 | // cancel changes | ||
115 | // | ||
116 | void PPPData::cancel() { | ||
117 | |||
118 | // if (config) { | ||
119 | // config->rollback(); | ||
120 | // config->reparseConfiguration(); | ||
121 | // } | ||
122 | |||
123 | } | ||
124 | |||
125 | |||
126 | // currently differentiates between READWRITE and NONE only | ||
127 | int PPPData::access() const { | ||
128 | |||
129 | return 0;//config->getConfigState(); | ||
130 | } | ||
131 | |||
132 | |||
133 | // functions to read/write date to configuration file | ||
134 | QString PPPData::readConfig(const QString &group, const QString &key, | ||
135 | const QString &defvalue = "") | ||
136 | { | ||
137 | if (config) { | ||
138 | config->setGroup(group); | ||
139 | return config->readEntry(key, defvalue); | ||
140 | } else | ||
141 | return defvalue; | ||
142 | } | ||
143 | |||
144 | |||
145 | int PPPData::readNumConfig(const QString &group, const QString &key, | ||
146 | int defvalue) { | ||
147 | if (config) { | ||
148 | config->setGroup(group); | ||
149 | return config->readNumEntry(key, defvalue); | ||
150 | } else | ||
151 | return defvalue; | ||
152 | |||
153 | } | ||
154 | |||
155 | |||
156 | bool PPPData::readListConfig(const QString &group, const QString &key, | ||
157 | QStringList &list, char sep) { | ||
158 | list.clear(); | ||
159 | if (config) { | ||
160 | config->setGroup(group); | ||
161 | list = config->readListEntry(key, sep); | ||
162 | return true; | ||
163 | } else | ||
164 | return false; | ||
165 | } | ||
166 | |||
167 | |||
168 | void PPPData::writeConfig(const QString &group, const QString &key, | ||
169 | const QString &value) { | ||
170 | if (config) { | ||
171 | config->setGroup(group); | ||
172 | config->writeEntry(key, value); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | |||
177 | void PPPData::writeConfig(const QString &group, const QString &key, int value) { | ||
178 | if (config) { | ||
179 | config->setGroup(group); | ||
180 | config->writeEntry(key, value); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | |||
185 | void PPPData::writeListConfig(const QString &group, const QString &key, | ||
186 | QStringList &list, char sep) { | ||
187 | if (config) { | ||
188 | config->setGroup(group); | ||
189 | config->writeEntry(key, list, sep); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | |||
194 | // | ||
195 | // functions to set/return general information | ||
196 | // | ||
197 | QString PPPData::password() const { | ||
198 | return passwd; | ||
199 | } | ||
200 | |||
201 | |||
202 | void PPPData::setPassword(const QString &pw) { | ||
203 | passwd = pw; | ||
204 | } | ||
205 | |||
206 | |||
207 | const QString PPPData::defaultAccount() { | ||
208 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | ||
209 | } | ||
210 | |||
211 | |||
212 | void PPPData::setDefaultAccount(const QString &n) { | ||
213 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | ||
214 | |||
215 | //now set the current account index to the default account | ||
216 | setAccount(defaultAccount()); | ||
217 | } | ||
218 | |||
219 | |||
220 | bool PPPData::get_show_clock_on_caption() { | ||
221 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | ||
222 | } | ||
223 | |||
224 | |||
225 | void PPPData::set_show_clock_on_caption(bool set) { | ||
226 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | ||
227 | } | ||
228 | |||
229 | |||
230 | bool PPPData::get_xserver_exit_disconnect() { | ||
231 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | ||
232 | } | ||
233 | |||
234 | |||
235 | void PPPData::setPPPDebug(bool set) { | ||
236 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | ||
237 | } | ||
238 | |||
239 | |||
240 | bool PPPData::getPPPDebug() { | ||
241 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | ||
242 | } | ||
243 | |||
244 | |||
245 | void PPPData::set_xserver_exit_disconnect(bool set) { | ||
246 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | ||
247 | } | ||
248 | |||
249 | |||
250 | bool PPPData::quit_on_disconnect() { | ||
251 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | ||
252 | } | ||
253 | |||
254 | |||
255 | void PPPData::set_quit_on_disconnect(bool set) { | ||
256 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | ||
257 | } | ||
258 | |||
259 | |||
260 | bool PPPData::get_show_log_window() { | ||
261 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | ||
262 | } | ||
263 | |||
264 | |||
265 | void PPPData::set_show_log_window(bool set) { | ||
266 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | ||
267 | } | ||
268 | |||
269 | |||
270 | bool PPPData::automatic_redial() { | ||
271 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | ||
272 | } | ||
273 | |||
274 | |||
275 | void PPPData::set_automatic_redial(bool set) { | ||
276 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | ||
277 | } | ||
278 | |||
279 | |||
280 | bool PPPData::get_iconify_on_connect() { | ||
281 | return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | ||
282 | } | ||
283 | |||
284 | |||
285 | void PPPData::set_iconify_on_connect(bool set) { | ||
286 | writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | ||
287 | } | ||
288 | |||
289 | |||
290 | bool PPPData::get_dock_into_panel() { | ||
291 | return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | ||
292 | } | ||
293 | |||
294 | |||
295 | void PPPData::set_dock_into_panel(bool set) { | ||
296 | writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | ||
297 | } | ||
298 | |||
299 | |||
300 | QString PPPData::pppdVersion() { | ||
301 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | ||
302 | } | ||
303 | |||
304 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | ||
305 | // check if pppd version fulfills minimum requirement | ||
306 | return (pppdVer > ver | ||
307 | || (pppdVer == ver && pppdMod > mod) | ||
308 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | ||
309 | } | ||
310 | |||
311 | int PPPData::pppdTimeout() { | ||
312 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | ||
313 | } | ||
314 | |||
315 | |||
316 | void PPPData::setpppdTimeout(int n) { | ||
317 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | ||
318 | } | ||
319 | |||
320 | |||
321 | const QString PPPData::modemDevice() { | ||
322 | return readConfig (MODEM_GRP, MODEMDEV_KEY, devices[DEV_DEFAULT]); | ||
323 | } | ||
324 | |||
325 | |||
326 | void PPPData::setModemDevice(const QString &n) { | ||
327 | writeConfig(MODEM_GRP, MODEMDEV_KEY, n); | ||
328 | } | ||
329 | |||
330 | |||
331 | const QString PPPData::flowcontrol() { | ||
332 | return readConfig(MODEM_GRP, FLOWCONTROL_KEY, "CRTSCTS"); | ||
333 | } | ||
334 | |||
335 | |||
336 | void PPPData::setFlowcontrol(const QString &n) { | ||
337 | writeConfig(MODEM_GRP, FLOWCONTROL_KEY, n); | ||
338 | } | ||
339 | |||
340 | |||
341 | const QString PPPData::speed() { | ||
342 | QString s = readConfig(MODEM_GRP, SPEED_KEY, "57600"); | ||
343 | // undo the damage of a bug in former versions. It left an empty Speed= | ||
344 | // entry in kppprc. kppp did set the serial port to 57600 as default but | ||
345 | // pppd wouldn't receive the speed via the command line. | ||
346 | if(s.toUInt() == 0) | ||
347 | s = "57600"; | ||
348 | return s; | ||
349 | } | ||
350 | |||
351 | |||
352 | void PPPData::setSpeed(const QString &n) { | ||
353 | writeConfig(MODEM_GRP, SPEED_KEY, n); | ||
354 | } | ||
355 | |||
356 | |||
357 | #if 0 | ||
358 | void PPPData::setUseCDLine(const int n) { | ||
359 | writeConfig(MODEM_GRP,USECDLINE_KEY,n); | ||
360 | } | ||
361 | |||
362 | |||
363 | int PPPData::UseCDLine() { | ||
364 | return readNumConfig(MODEM_GRP,USECDLINE_KEY,0); | ||
365 | } | ||
366 | #endif | ||
367 | |||
368 | const QString PPPData::modemEscapeStr() { | ||
369 | return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++"); | ||
370 | } | ||
371 | |||
372 | |||
373 | void PPPData::setModemEscapeStr(const QString &n) { | ||
374 | writeConfig(MODEM_GRP,ESCAPESTR_KEY,n); | ||
375 | } | ||
376 | |||
377 | |||
378 | const QString PPPData::modemEscapeResp() { | ||
379 | return readConfig(MODEM_GRP,ESCAPERESP_KEY,"OK"); | ||
380 | } | ||
381 | |||
382 | |||
383 | void PPPData::setModemEscapeResp(const QString &n) { | ||
384 | writeConfig(MODEM_GRP,ESCAPERESP_KEY,n); | ||
385 | } | ||
386 | |||
387 | |||
388 | int PPPData::modemEscapeGuardTime() { | ||
389 | return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50); | ||
390 | } | ||
391 | |||
392 | |||
393 | void PPPData::setModemEscapeGuardTime(int n) { | ||
394 | writeConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,n); | ||
395 | } | ||
396 | |||
397 | |||
398 | bool PPPData::modemLockFile() { | ||
399 | return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1); | ||
400 | } | ||
401 | |||
402 | |||
403 | void PPPData::setModemLockFile(bool set) { | ||
404 | writeConfig(MODEM_GRP, LOCKFILE_KEY, set); | ||
405 | } | ||
406 | |||
407 | |||
408 | int PPPData::modemTimeout() { | ||
409 | return readNumConfig(MODEM_GRP, TIMEOUT_KEY, MODEM_TIMEOUT); | ||
410 | } | ||
411 | |||
412 | |||
413 | void PPPData::setModemTimeout(int n) { | ||
414 | writeConfig(MODEM_GRP, TIMEOUT_KEY, n); | ||
415 | } | ||
416 | |||
417 | |||
418 | int PPPData::modemToneDuration() { | ||
419 | return readNumConfig(MODEM_GRP, TONEDURATION_KEY,MODEM_TONEDURATION); | ||
420 | } | ||
421 | |||
422 | |||
423 | void PPPData::setModemToneDuration(int n) { | ||
424 | writeConfig(MODEM_GRP, TONEDURATION_KEY, n); | ||
425 | } | ||
426 | |||
427 | |||
428 | int PPPData::busyWait() { | ||
429 | return readNumConfig(MODEM_GRP, BUSYWAIT_KEY, BUSY_WAIT); | ||
430 | } | ||
431 | |||
432 | |||
433 | void PPPData::setbusyWait(int n) { | ||
434 | writeConfig(MODEM_GRP, BUSYWAIT_KEY, n); | ||
435 | } | ||
436 | |||
437 | |||
438 | // | ||
439 | //Advanced "Modem" dialog | ||
440 | // | ||
441 | // defaults: InitString=ATZ, InitString1="" etc. | ||
442 | const QString PPPData::modemInitStr(int i) { | ||
443 | assert(i >= 0 && i < NumInitStrings); | ||
444 | if(i == 0) | ||
445 | return readConfig(MODEM_GRP, INITSTR_KEY, "ATZ"); | ||
446 | else | ||
447 | return readConfig(MODEM_GRP, INITSTR_KEY + QString::number(i), ""); | ||
448 | } | ||
449 | |||
450 | |||
451 | void PPPData::setModemInitStr(int i, const QString &n) { | ||
452 | assert(i >= 0 && i < NumInitStrings); | ||
453 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | ||
454 | writeConfig(MODEM_GRP, k, n); | ||
455 | } | ||
456 | |||
457 | |||
458 | const QString PPPData::modemInitResp() { | ||
459 | return readConfig(MODEM_GRP, INITRESP_KEY, "OK"); | ||
460 | } | ||
461 | |||
462 | |||
463 | void PPPData::setModemInitResp(const QString &n) { | ||
464 | writeConfig(MODEM_GRP, INITRESP_KEY, n); | ||
465 | } | ||
466 | |||
467 | |||
468 | int PPPData::modemPreInitDelay() { | ||
469 | return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50); | ||
470 | } | ||
471 | |||
472 | |||
473 | void PPPData::setModemPreInitDelay(int n) { | ||
474 | writeConfig(MODEM_GRP, PREINITDELAY_KEY, n); | ||
475 | } | ||
476 | |||
477 | |||
478 | int PPPData::modemInitDelay() { | ||
479 | return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50); | ||
480 | } | ||
481 | |||
482 | |||
483 | void PPPData::setModemInitDelay(int n) { | ||
484 | writeConfig(MODEM_GRP, INITDELAY_KEY, n); | ||
485 | } | ||
486 | |||
487 | QString PPPData::modemNoDialToneDetectionStr() { | ||
488 | return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3"); | ||
489 | } | ||
490 | |||
491 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | ||
492 | writeConfig(MODEM_GRP, NODTDETECT_KEY, n); | ||
493 | } | ||
494 | |||
495 | const QString PPPData::modemDialStr() { | ||
496 | return readConfig(MODEM_GRP, DIALSTR_KEY, "ATDT"); | ||
497 | } | ||
498 | |||
499 | |||
500 | void PPPData::setModemDialStr(const QString &n) { | ||
501 | writeConfig(MODEM_GRP, DIALSTR_KEY, n); | ||
502 | } | ||
503 | |||
504 | |||
505 | const QString PPPData::modemConnectResp() { | ||
506 | return readConfig(MODEM_GRP, CONNECTRESP_KEY, "CONNECT"); | ||
507 | } | ||
508 | |||
509 | |||
510 | void PPPData::setModemConnectResp(const QString &n) { | ||
511 | writeConfig(MODEM_GRP, CONNECTRESP_KEY, n); | ||
512 | } | ||
513 | |||
514 | |||
515 | const QString PPPData::modemBusyResp() { | ||
516 | return readConfig(MODEM_GRP, BUSYRESP_KEY, "BUSY"); | ||
517 | } | ||
518 | |||
519 | |||
520 | void PPPData::setModemBusyResp(const QString &n) { | ||
521 | writeConfig(MODEM_GRP, BUSYRESP_KEY, n); | ||
522 | } | ||
523 | |||
524 | |||
525 | const QString PPPData::modemNoCarrierResp() { | ||
526 | return readConfig(MODEM_GRP, NOCARRIERRESP_KEY, "NO CARRIER"); | ||
527 | } | ||
528 | |||
529 | |||
530 | void PPPData::setModemNoCarrierResp(const QString &n) { | ||
531 | writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n); | ||
532 | } | ||
533 | |||
534 | |||
535 | const QString PPPData::modemNoDialtoneResp() { | ||
536 | return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE"); | ||
537 | } | ||
538 | |||
539 | |||
540 | void PPPData::setModemNoDialtoneResp(const QString &n) { | ||
541 | writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n); | ||
542 | } | ||
543 | |||
544 | |||
545 | const QString PPPData::modemHangupStr() { | ||
546 | return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH"); | ||
547 | } | ||
548 | |||
549 | void PPPData::setModemHangupStr(const QString &n) { | ||
550 | writeConfig(MODEM_GRP, HANGUPSTR_KEY, n); | ||
551 | } | ||
552 | |||
553 | |||
554 | const QString PPPData::modemHangupResp() { | ||
555 | return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK"); | ||
556 | } | ||
557 | |||
558 | void PPPData::setModemHangupResp(const QString &n) { | ||
559 | writeConfig(MODEM_GRP, HANGUPRESP_KEY, n); | ||
560 | } | ||
561 | |||
562 | |||
563 | const QString PPPData::modemAnswerStr() { | ||
564 | return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA"); | ||
565 | } | ||
566 | |||
567 | |||
568 | QString PPPData::volumeOff() { | ||
569 | return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0"); | ||
570 | } | ||
571 | |||
572 | |||
573 | void PPPData::setVolumeOff(const QString &s) { | ||
574 | writeConfig(MODEM_GRP, VOLUME_OFF, s); | ||
575 | } | ||
576 | |||
577 | |||
578 | QString PPPData::volumeMedium() { | ||
579 | return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1"); | ||
580 | } | ||
581 | |||
582 | |||
583 | void PPPData::setVolumeMedium(const QString &s) { | ||
584 | writeConfig(MODEM_GRP, VOLUME_MEDIUM, s); | ||
585 | } | ||
586 | |||
587 | |||
588 | QString PPPData::volumeHigh() { | ||
589 | QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3"); | ||
590 | if(tmp == "M1L4") | ||
591 | tmp = "M1L3"; | ||
592 | return tmp; | ||
593 | } | ||
594 | |||
595 | |||
596 | void PPPData::setVolumeHigh(const QString &s) { | ||
597 | writeConfig(MODEM_GRP, VOLUME_HIGH, s); | ||
598 | } | ||
599 | |||
600 | |||
601 | QString PPPData::volumeInitString() { | ||
602 | QString s; | ||
603 | |||
604 | switch(volume()) { | ||
605 | case 0: | ||
606 | s = volumeOff(); | ||
607 | break; | ||
608 | case 1: | ||
609 | s = volumeMedium(); | ||
610 | break; | ||
611 | case 2: | ||
612 | s = volumeHigh(); | ||
613 | break; | ||
614 | default: | ||
615 | s = volumeMedium(); | ||
616 | } | ||
617 | |||
618 | return s; | ||
619 | } | ||
620 | |||
621 | |||
622 | int PPPData::volume() { | ||
623 | return readNumConfig(MODEM_GRP, VOLUME_KEY, 1); | ||
624 | } | ||
625 | |||
626 | |||
627 | void PPPData::setVolume(int i) { | ||
628 | writeConfig(MODEM_GRP, VOLUME_KEY, i); | ||
629 | } | ||
630 | |||
631 | int PPPData::waitForDialTone() { | ||
632 | return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); | ||
633 | } | ||
634 | |||
635 | void PPPData::setWaitForDialTone(int i) { | ||
636 | writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i); | ||
637 | } | ||
638 | |||
639 | void PPPData::setModemAnswerStr(const QString &n) { | ||
640 | writeConfig(MODEM_GRP, ANSWERSTR_KEY, n); | ||
641 | } | ||
642 | |||
643 | |||
644 | const QString PPPData::modemRingResp() { | ||
645 | return readConfig(MODEM_GRP, RINGRESP_KEY, "RING"); | ||
646 | } | ||
647 | |||
648 | |||
649 | void PPPData::setModemRingResp(const QString &n) { | ||
650 | writeConfig(MODEM_GRP, RINGRESP_KEY, n); | ||
651 | } | ||
652 | |||
653 | |||
654 | const QString PPPData::modemAnswerResp() { | ||
655 | return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT"); | ||
656 | } | ||
657 | |||
658 | |||
659 | void PPPData::setModemAnswerResp(const QString &n) { | ||
660 | writeConfig(MODEM_GRP, ANSWERRESP_KEY, n); | ||
661 | } | ||
662 | |||
663 | |||
664 | const QString PPPData::enter() { | ||
665 | return readConfig(MODEM_GRP, ENTER_KEY, "CR"); | ||
666 | } | ||
667 | |||
668 | |||
669 | void PPPData::setEnter(const QString &n) { | ||
670 | writeConfig(MODEM_GRP, ENTER_KEY, n); | ||
671 | } | ||
672 | |||
673 | |||
674 | // | ||
675 | // functions to set/return account information | ||
676 | // | ||
677 | |||
678 | //returns number of accounts | ||
679 | int PPPData::count() const { | ||
680 | return highcount + 1; | ||
681 | } | ||
682 | |||
683 | |||
684 | bool PPPData::setAccount(const QString &aname) { | ||
685 | for(int i = 0; i <= highcount; i++) { | ||
686 | setAccountbyIndex(i); | ||
687 | if(accname() == aname) { | ||
688 | caccount = i; | ||
689 | return true; | ||
690 | } | ||
691 | } | ||
692 | return false; | ||
693 | } | ||
694 | |||
695 | |||
696 | bool PPPData::setAccountbyIndex(int i) { | ||
697 | if(i >= 0 && i <= highcount) { | ||
698 | caccount = i; | ||
699 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | ||
700 | return true; | ||
701 | } | ||
702 | return false; | ||
703 | } | ||
704 | |||
705 | |||
706 | bool PPPData::isUniqueAccname(const QString &n) { | ||
707 | int current = caccount; | ||
708 | for(int i=0; i <= highcount; i++) { | ||
709 | setAccountbyIndex(i); | ||
710 | if(accname() == n && i != current) { | ||
711 | setAccountbyIndex(current); | ||
712 | return false; | ||
713 | } | ||
714 | } | ||
715 | setAccountbyIndex(current); | ||
716 | return true; | ||
717 | } | ||
718 | |||
719 | |||
720 | bool PPPData::deleteAccount() { | ||
721 | if(caccount < 0) | ||
722 | return false; | ||
723 | |||
724 | // QMap <QString, QString> map; | ||
725 | // QMap <QString, QString>::Iterator it; | ||
726 | |||
727 | // set all entries of the current account to "" | ||
728 | // tille: do not handle the accounts here... (?) | ||
729 | // map = config->entryMap(cgroup); | ||
730 | // it = map.begin(); | ||
731 | // while (it != map.end()) { | ||
732 | // config->writeEntry(it.key(), ""); | ||
733 | // it++; | ||
734 | // } | ||
735 | |||
736 | // // shift the succeeding accounts | ||
737 | // for(int i = caccount+1; i <= highcount; i++) { | ||
738 | // setAccountbyIndex(i); | ||
739 | // map = config->entryMap(cgroup); | ||
740 | // it = map.begin(); | ||
741 | // setAccountbyIndex(i-1); | ||
742 | // config->setGroup(cgroup); | ||
743 | // while (it != map.end()) { | ||
744 | // config->writeEntry(it.key(), *it); | ||
745 | // it++; | ||
746 | // } | ||
747 | // } | ||
748 | |||
749 | // // make sure the top account is cleared | ||
750 | // setAccountbyIndex(highcount); | ||
751 | // map = config->entryMap(cgroup); | ||
752 | // it = map.begin(); | ||
753 | // config->setGroup(cgroup); | ||
754 | // while (it.key() != QString::null) { | ||
755 | // config->writeEntry(it.key(), ""); | ||
756 | // it++; | ||
757 | // } | ||
758 | |||
759 | highcount--; | ||
760 | if(caccount > highcount) | ||
761 | caccount = highcount; | ||
762 | |||
763 | setAccountbyIndex(caccount); | ||
764 | |||
765 | return true; | ||
766 | } | ||
767 | |||
768 | |||
769 | bool PPPData::deleteAccount(const QString &aname) { | ||
770 | if(!setAccount(aname)) | ||
771 | return false; | ||
772 | |||
773 | deleteAccount(); | ||
774 | |||
775 | return true; | ||
776 | } | ||
777 | |||
778 | |||
779 | int PPPData::newaccount() { | ||
780 | |||
781 | if(!config || highcount >= MAX_ACCOUNTS) | ||
782 | return -1; | ||
783 | |||
784 | highcount++; | ||
785 | setAccountbyIndex(highcount); | ||
786 | |||
787 | setpppdArgumentDefaults(); | ||
788 | |||
789 | return caccount; | ||
790 | } | ||
791 | |||
792 | int PPPData::copyaccount(int i) { | ||
793 | |||
794 | if(highcount >= MAX_ACCOUNTS) | ||
795 | return -1; | ||
796 | |||
797 | setAccountbyIndex(i); | ||
798 | |||
799 | // QMap <QString, QString> map = config->entryMap(cgroup); | ||
800 | // QMap <QString, QString>::ConstIterator it = map.begin(); | ||
801 | |||
802 | QString newname = i18n("%1_copy").arg(accname()); | ||
803 | |||
804 | newaccount(); | ||
805 | |||
806 | // while (it != map.end()) { | ||
807 | // config->writeEntry(it.key(), *it); | ||
808 | // it++; | ||
809 | // } | ||
810 | |||
811 | setAccname(newname); | ||
812 | |||
813 | return caccount; | ||
814 | } | ||
815 | |||
816 | |||
817 | const QString PPPData::accname() { | ||
818 | return readConfig(cgroup, NAME_KEY); | ||
819 | } | ||
820 | |||
821 | void PPPData::setAccname(const QString &n) { | ||
822 | if(!cgroup.isNull()) { | ||
823 | // are we manipulating the default account's name ? then change it, too. | ||
824 | bool def = accname() == defaultAccount(); | ||
825 | writeConfig(cgroup, NAME_KEY, n); | ||
826 | if (def) | ||
827 | setDefaultAccount(n); | ||
828 | } | ||
829 | } | ||
830 | |||
831 | |||
832 | #define SEPARATOR_CHAR ':' | ||
833 | QStringList &PPPData::phonenumbers() { | ||
834 | |||
835 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | ||
836 | return phonelist; | ||
837 | |||
838 | } | ||
839 | |||
840 | |||
841 | const QString PPPData::phonenumber() { | ||
842 | return readConfig(cgroup, PHONENUMBER_KEY); | ||
843 | } | ||
844 | |||
845 | |||
846 | void PPPData::setPhonenumber(const QString &n) { | ||
847 | writeConfig(cgroup, PHONENUMBER_KEY, n); | ||
848 | } | ||
849 | |||
850 | |||
851 | const QString PPPData::dialPrefix() { | ||
852 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | ||
853 | } | ||
854 | |||
855 | |||
856 | void PPPData::setDialPrefix(const QString &s) { | ||
857 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | ||
858 | } | ||
859 | |||
860 | |||
861 | int PPPData::authMethod() { | ||
862 | return readNumConfig(cgroup, AUTH_KEY, 0); | ||
863 | } | ||
864 | |||
865 | |||
866 | void PPPData::setAuthMethod(int value) { | ||
867 | writeConfig(cgroup, AUTH_KEY, value); | ||
868 | } | ||
869 | |||
870 | |||
871 | const QString PPPData::storedUsername() { | ||
872 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | ||
873 | } | ||
874 | |||
875 | |||
876 | void PPPData::setStoredUsername(const QString &b) { | ||
877 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | ||
878 | } | ||
879 | |||
880 | |||
881 | const QString PPPData::storedPassword() { | ||
882 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | ||
883 | } | ||
884 | |||
885 | |||
886 | void PPPData::setStoredPassword(const QString &b) { | ||
887 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | ||
888 | } | ||
889 | |||
890 | |||
891 | bool PPPData::storePassword() { | ||
892 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | ||
893 | } | ||
894 | |||
895 | |||
896 | const QString PPPData::command_before_connect() { | ||
897 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | ||
898 | } | ||
899 | |||
900 | |||
901 | void PPPData::setCommand_before_connect(const QString &n) { | ||
902 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | ||
903 | } | ||
904 | |||
905 | |||
906 | void PPPData::setStorePassword(bool b) { | ||
907 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | ||
908 | } | ||
909 | |||
910 | |||
911 | const QString PPPData::command_on_connect() { | ||
912 | return readConfig(cgroup, COMMAND_KEY); | ||
913 | } | ||
914 | |||
915 | |||
916 | void PPPData::setCommand_on_connect(const QString &n) { | ||
917 | writeConfig(cgroup, COMMAND_KEY, n); | ||
918 | } | ||
919 | |||
920 | |||
921 | const QString PPPData::command_on_disconnect() { | ||
922 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); | ||
923 | } | ||
924 | |||
925 | |||
926 | void PPPData::setCommand_on_disconnect(const QString &n) { | ||
927 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); | ||
928 | } | ||
929 | |||
930 | |||
931 | const QString PPPData::command_before_disconnect() { | ||
932 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); | ||
933 | } | ||
934 | |||
935 | |||
936 | void PPPData::setCommand_before_disconnect(const QString &n) { | ||
937 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); | ||
938 | } | ||
939 | |||
940 | |||
941 | const QString PPPData::ipaddr() { | ||
942 | return readConfig(cgroup, IPADDR_KEY); | ||
943 | } | ||
944 | |||
945 | |||
946 | void PPPData::setIpaddr(const QString &n) { | ||
947 | writeConfig(cgroup, IPADDR_KEY, n); | ||
948 | } | ||
949 | |||
950 | |||
951 | const QString PPPData::subnetmask() { | ||
952 | return readConfig(cgroup, SUBNETMASK_KEY); | ||
953 | } | ||
954 | |||
955 | |||
956 | void PPPData::setSubnetmask(const QString &n) { | ||
957 | writeConfig(cgroup, SUBNETMASK_KEY, n); | ||
958 | } | ||
959 | |||
960 | |||
961 | bool PPPData::autoname() { | ||
962 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); | ||
963 | } | ||
964 | |||
965 | |||
966 | void PPPData::setAutoname(bool set) { | ||
967 | writeConfig(cgroup, AUTONAME_KEY, (int) set); | ||
968 | } | ||
969 | |||
970 | |||
971 | bool PPPData::AcctEnabled() { | ||
972 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); | ||
973 | } | ||
974 | |||
975 | |||
976 | void PPPData::setAcctEnabled(bool set) { | ||
977 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); | ||
978 | } | ||
979 | |||
980 | |||
981 | int PPPData::VolAcctEnabled() { | ||
982 | return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); | ||
983 | } | ||
984 | |||
985 | |||
986 | void PPPData::setVolAcctEnabled(int set) { | ||
987 | writeConfig(cgroup, VOLACCTENABLED_KEY, set); | ||
988 | } | ||
989 | |||
990 | |||
991 | const QString PPPData::gateway() { | ||
992 | return readConfig(cgroup, GATEWAY_KEY); | ||
993 | } | ||
994 | |||
995 | |||
996 | void PPPData::setGateway(const QString &n ) { | ||
997 | writeConfig(cgroup, GATEWAY_KEY, n); | ||
998 | } | ||
999 | |||
1000 | |||
1001 | bool PPPData::defaultroute() { | ||
1002 | // default route is by default 'on'. | ||
1003 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); | ||
1004 | } | ||
1005 | |||
1006 | |||
1007 | void PPPData::setDefaultroute(bool set) { | ||
1008 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); | ||
1009 | } | ||
1010 | |||
1011 | |||
1012 | bool PPPData::autoDNS() { | ||
1013 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); | ||
1014 | return (set && gpppdata.pppdVersionMin(2, 3, 7)); | ||
1015 | } | ||
1016 | |||
1017 | |||
1018 | void PPPData::setAutoDNS(bool set) { | ||
1019 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | ||
1020 | } | ||
1021 | |||
1022 | |||
1023 | void PPPData::setExDNSDisabled(bool set) { | ||
1024 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | ||
1025 | } | ||
1026 | |||
1027 | |||
1028 | bool PPPData::exDNSDisabled() { | ||
1029 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | ||
1030 | } | ||
1031 | |||
1032 | |||
1033 | QStringList &PPPData::dns() { | ||
1034 | static QStringList dnslist; | ||
1035 | |||
1036 | readListConfig(cgroup, DNS_KEY, dnslist); | ||
1037 | while(dnslist.count() > MAX_DNS_ENTRIES) | ||
1038 | dnslist.remove(dnslist.last()); | ||
1039 | |||
1040 | return dnslist; | ||
1041 | } | ||
1042 | |||
1043 | |||
1044 | void PPPData::setDns(QStringList &list) { | ||
1045 | writeListConfig(cgroup, DNS_KEY, list); | ||
1046 | } | ||
1047 | |||
1048 | |||
1049 | const QString PPPData::domain() { | ||
1050 | return readConfig(cgroup, DOMAIN_KEY); | ||
1051 | } | ||
1052 | |||
1053 | |||
1054 | void PPPData::setDomain(const QString &n ) { | ||
1055 | writeConfig(cgroup, DOMAIN_KEY, n); | ||
1056 | } | ||
1057 | |||
1058 | |||
1059 | QStringList &PPPData::scriptType() { | ||
1060 | static QStringList typelist; | ||
1061 | |||
1062 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | ||
1063 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | ||
1064 | typelist.remove(typelist.last()); | ||
1065 | |||
1066 | return typelist; | ||
1067 | } | ||
1068 | |||
1069 | |||
1070 | void PPPData::setScriptType(QStringList &list) { | ||
1071 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | ||
1072 | } | ||
1073 | |||
1074 | |||
1075 | QStringList &PPPData::script() { | ||
1076 | static QStringList scriptlist; | ||
1077 | |||
1078 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | ||
1079 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | ||
1080 | scriptlist.remove(scriptlist.last()); | ||
1081 | |||
1082 | return scriptlist; | ||
1083 | } | ||
1084 | |||
1085 | |||
1086 | void PPPData::setScript(QStringList &list) { | ||
1087 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | ||
1088 | } | ||
1089 | |||
1090 | |||
1091 | const QString PPPData::accountingFile() { | ||
1092 | return readConfig(cgroup, ACCTFILE_KEY); | ||
1093 | } | ||
1094 | |||
1095 | |||
1096 | void PPPData::setAccountingFile(const QString &n) { | ||
1097 | writeConfig(cgroup, ACCTFILE_KEY, n); | ||
1098 | } | ||
1099 | |||
1100 | |||
1101 | const QString PPPData::totalCosts() { | ||
1102 | return readConfig(cgroup, TOTALCOSTS_KEY); | ||
1103 | } | ||
1104 | |||
1105 | |||
1106 | void PPPData::setTotalCosts(const QString &n) { | ||
1107 | writeConfig(cgroup, TOTALCOSTS_KEY, n); | ||
1108 | } | ||
1109 | |||
1110 | |||
1111 | int PPPData::totalBytes() { | ||
1112 | return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | ||
1113 | } | ||
1114 | |||
1115 | void PPPData::setTotalBytes(int n) { | ||
1116 | writeConfig(cgroup, TOTALBYTES_KEY, n); | ||
1117 | } | ||
1118 | |||
1119 | |||
1120 | QStringList &PPPData::pppdArgument() { | ||
1121 | static QStringList arglist; | ||
1122 | |||
1123 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | ||
1124 | arglist.remove(arglist.last()); | ||
1125 | readListConfig(cgroup, PPPDARG_KEY, arglist); | ||
1126 | |||
1127 | return arglist; | ||
1128 | } | ||
1129 | |||
1130 | |||
1131 | void PPPData::setpppdArgument(QStringList &args) { | ||
1132 | writeListConfig(cgroup, PPPDARG_KEY, args); | ||
1133 | } | ||
1134 | |||
1135 | |||
1136 | void PPPData::setpppdArgumentDefaults() { | ||
1137 | QStringList arg; | ||
1138 | setpppdArgument(arg); | ||
1139 | } | ||
1140 | |||
1141 | |||
1142 | // graphing widget | ||
1143 | void PPPData::setGraphingOptions(bool enable, | ||
1144 | QColor bg, | ||
1145 | QColor text, | ||
1146 | QColor in, | ||
1147 | QColor out) | ||
1148 | { | ||
1149 | if(config) { | ||
1150 | config->setGroup(GRAPH_GRP); | ||
1151 | config->writeEntry(GENABLED, enable); | ||
1152 | // config->writeEntry(GCOLOR_BG, bg); | ||
1153 | // config->writeEntry(GCOLOR_TEXT, text); | ||
1154 | // config->writeEntry(GCOLOR_IN, in); | ||
1155 | // config->writeEntry(GCOLOR_OUT, out); | ||
1156 | } | ||
1157 | } | ||
1158 | |||
1159 | void PPPData::graphingOptions(bool &enable, | ||
1160 | QColor &bg, | ||
1161 | QColor &text, | ||
1162 | QColor &in, | ||
1163 | QColor &out) | ||
1164 | { | ||
1165 | QColor c; | ||
1166 | |||
1167 | if(config) { | ||
1168 | config->setGroup(GRAPH_GRP); | ||
1169 | enable = config->readBoolEntry(GENABLED, true); | ||
1170 | bg = Qt::white; | ||
1171 | //bg = config->readColorEntry(GCOLOR_BG, &c); | ||
1172 | text = Qt::black; | ||
1173 | //text = config->readColorEntry(GCOLOR_TEXT, &c); | ||
1174 | in = Qt::blue; | ||
1175 | //in = config->readColorEntry(GCOLOR_IN, &c); | ||
1176 | out = Qt::red; | ||
1177 | //out = config->readColorEntry(GCOLOR_OUT, &c); | ||
1178 | } | ||
1179 | } | ||
1180 | |||
1181 | |||
1182 | bool PPPData::graphingEnabled() { | ||
1183 | return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | ||
1184 | } | ||
1185 | |||
1186 | |||
1187 | |||
1188 | // | ||
1189 | //functions to change/set the child pppd process info | ||
1190 | // | ||
1191 | bool PPPData::pppdRunning() const { | ||
1192 | return pppdisrunning; | ||
1193 | } | ||
1194 | |||
1195 | void PPPData::setpppdRunning(bool set) { | ||
1196 | pppdisrunning = set; | ||
1197 | } | ||
1198 | |||
1199 | int PPPData::pppdError() const { | ||
1200 | return pppderror; | ||
1201 | } | ||
1202 | |||
1203 | void PPPData::setpppdError(int err) { | ||
1204 | pppderror = err; | ||
1205 | } | ||
1206 | |||
1207 | |||
1208 | // | ||
1209 | // window position | ||
1210 | // | ||
1211 | void PPPData::winPosConWin(int& p_x, int& p_y) { | ||
1212 | p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); | ||
1213 | p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); | ||
1214 | } | ||
1215 | |||
1216 | void PPPData::setWinPosConWin(int p_x, int p_y) { | ||
1217 | writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); | ||
1218 | writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); | ||
1219 | } | ||
1220 | |||
1221 | void PPPData::winPosStatWin(int& p_x, int& p_y) { | ||
1222 | p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); | ||
1223 | p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); | ||
1224 | } | ||
1225 | |||
1226 | void PPPData::setWinPosStatWin(int p_x, int p_y) { | ||
1227 | writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); | ||
1228 | writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); | ||
1229 | } | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h new file mode 100644 index 0000000..e286b70 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -0,0 +1,465 @@ | |||
1 | /* -*- C++ -*- | ||
2 | * | ||
3 | * kPPP: A pppd front end for the KDE project | ||
4 | * | ||
5 | * $Id$ | ||
6 | * | ||
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
8 | * wuebben@math.cornell.edu | ||
9 | * | ||
10 | * based on EzPPP: | ||
11 | * Copyright (C) 1997 Jay Painter | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU Library General Public | ||
15 | * License as published by the Free Software Foundation; either | ||
16 | * version 2 of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
21 | * Library General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU Library General Public | ||
24 | * License along with this program; if not, write to the Free | ||
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | */ | ||
27 | |||
28 | #ifndef _PPPDATA_H_ | ||
29 | #define _PPPDATA_H_ | ||
30 | |||
31 | #include <unistd.h> | ||
32 | #include <sys/types.h> | ||
33 | |||
34 | #include <qstring.h> | ||
35 | #include <qstringlist.h> | ||
36 | #include <qcolor.h> | ||
37 | |||
38 | #include "kpppconfig.h" | ||
39 | |||
40 | class Config; | ||
41 | |||
42 | // string lengths | ||
43 | |||
44 | #define PATH_SIZE 120 | ||
45 | #define MODEMSTR_SIZE 80 | ||
46 | #define ACCNAME_SIZE 50 | ||
47 | #define PHONENUMBER_SIZE 60 | ||
48 | #define COMMAND_SIZE 255 | ||
49 | #define IPADDR_SIZE 15 | ||
50 | #define DOMAIN_SIZE 50 | ||
51 | #define TIMEOUT_SIZE 60 | ||
52 | |||
53 | // | ||
54 | // keys for config file | ||
55 | // | ||
56 | |||
57 | // groups | ||
58 | #define GENERAL_GRP "General" | ||
59 | #define MODEM_GRP "Modem" | ||
60 | #define ACCOUNT_GRP "Account" | ||
61 | #define GRAPH_GRP "Graph" | ||
62 | #define WINPOS_GRP "WindowPosition" | ||
63 | |||
64 | // general | ||
65 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | ||
66 | #define PPPDVERSION_KEY "pppdVersion" | ||
67 | #define PPPDTIMEOUT_KEY "pppdTimeout" | ||
68 | #define SHOWCLOCK_KEY "ShowClock" | ||
69 | #define SHOWLOGWIN_KEY "ShowLogWindow" | ||
70 | #define AUTOREDIAL_KEY "AutomaticRedial" | ||
71 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | ||
72 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | ||
73 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | ||
74 | #define ID_KEY "ID" | ||
75 | |||
76 | // modem | ||
77 | #define MODEMDEV_KEY "Device" | ||
78 | #define LOCKFILE_KEY "UseLockFile" | ||
79 | #define FLOWCONTROL_KEY "FlowControl" | ||
80 | #define SPEED_KEY "Speed" | ||
81 | #define TIMEOUT_KEY "Timeout" | ||
82 | #define TONEDURATION_KEY "ToneDuration" | ||
83 | #define BUSYWAIT_KEY "BusyWait" | ||
84 | #define INITSTR_KEY "InitString" | ||
85 | #define INITRESP_KEY "InitResponse" | ||
86 | #define PREINITDELAY_KEY "PreInitDelay" | ||
87 | #define INITDELAY_KEY "InitDelay" | ||
88 | #define NODTDETECT_KEY "NoDialToneDetection" | ||
89 | #define DIALTONEWAIT_KEY "WaitForDialTone" | ||
90 | #define DIALSTR_KEY "DialString" | ||
91 | #define CONNECTRESP_KEY "ConnectResponse" | ||
92 | #define BUSYRESP_KEY "BusyResponse" | ||
93 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | ||
94 | #define NODIALTONERESP_KEY "NoDialToneResp" | ||
95 | #define HANGUPSTR_KEY "HangupString" | ||
96 | #define HANGUPRESP_KEY "HangUpResponse" | ||
97 | #define ANSWERSTR_KEY "AnswerString" | ||
98 | #define RINGRESP_KEY "RingResponse" | ||
99 | #define ANSWERRESP_KEY "AnswerResponse" | ||
100 | #define ENTER_KEY "Enter" | ||
101 | #define ESCAPESTR_KEY "EscapeString" | ||
102 | #define ESCAPERESP_KEY "EscapeResponse" | ||
103 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | ||
104 | #define USECDLINE_KEY "UseCDLine" | ||
105 | #define VOLUME_HIGH "VolumeHigh" | ||
106 | #define VOLUME_MEDIUM "VolumeMedium" | ||
107 | #define VOLUME_OFF "VolumeOff" | ||
108 | #define VOLUME_KEY "Volume" | ||
109 | |||
110 | // account | ||
111 | #define NAME_KEY "Name" | ||
112 | #define PHONENUMBER_KEY "Phonenumber" | ||
113 | #define DIAL_PREFIX_KEY "DialPrefix" | ||
114 | #define AUTH_KEY "Authentication" | ||
115 | #define STORED_PASSWORD_KEY "Password" | ||
116 | #define STORED_USERNAME_KEY "Username" | ||
117 | #define STORE_PASSWORD_KEY "StorePassword" | ||
118 | #define BEFORE_CONNECT_KEY "BeforeConnect" | ||
119 | #define COMMAND_KEY "Command" | ||
120 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | ||
121 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | ||
122 | #define IPADDR_KEY "IPAddr" | ||
123 | #define SUBNETMASK_KEY "SubnetMask" | ||
124 | #define ACCTENABLED_KEY "AccountingEnabled" | ||
125 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | ||
126 | #define ACCTFILE_KEY "AccountingFile" | ||
127 | #define AUTONAME_KEY "AutoName" | ||
128 | #define GATEWAY_KEY "Gateway" | ||
129 | #define DEFAULTROUTE_KEY "DefaultRoute" | ||
130 | #define DOMAIN_KEY "Domain" | ||
131 | #define DNS_KEY "DNS" | ||
132 | #define AUTODNS_KEY "AutoDNS" | ||
133 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | ||
134 | #define SCRIPTCOM_KEY "ScriptCommands" | ||
135 | #define SCRIPTARG_KEY "ScriptArguments" | ||
136 | #define PPPDARG_KEY "pppdArguments" | ||
137 | #define PPP_DEBUG_OPTION "PPPDebug" | ||
138 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | ||
139 | #define DOCKING_KEY "DockIntoPanel" | ||
140 | #define TOTALCOSTS_KEY "TotalCosts" | ||
141 | #define TOTALBYTES_KEY "TotalBytes" | ||
142 | |||
143 | // graph colors | ||
144 | #define GENABLED "Enabled" | ||
145 | #define GCOLOR_BG "Background" | ||
146 | #define GCOLOR_TEXT "Text" | ||
147 | #define GCOLOR_IN "InBytes" | ||
148 | #define GCOLOR_OUT "OutBytes" | ||
149 | |||
150 | // pppd errors | ||
151 | #define E_IF_TIMEOUT 1 | ||
152 | #define E_PPPD_DIED 2 | ||
153 | |||
154 | // window position | ||
155 | #define WINPOS_CONWIN_X "WindowPositionConWinX" | ||
156 | #define WINPOS_CONWIN_Y "WindowPositionConWinY" | ||
157 | #define WINPOS_STATWIN_X "WindowPositionStatWinX" | ||
158 | #define WINPOS_STATWIN_Y "WindowPositionStatWinY" | ||
159 | |||
160 | class PPPData { | ||
161 | public: | ||
162 | PPPData(); | ||
163 | ~PPPData() {}; | ||
164 | |||
165 | enum { NumInitStrings = 2 }; | ||
166 | |||
167 | // general functions | ||
168 | bool open(); | ||
169 | void save(); | ||
170 | void cancel(); | ||
171 | int access() const; // read/write access | ||
172 | |||
173 | // function to read/write date to configuration file | ||
174 | QString readConfig(const QString &, const QString &, const QString &); | ||
175 | int readNumConfig(const QString &, const QString &, int); | ||
176 | bool readListConfig(const QString &, const QString &, | ||
177 | QStringList &, char sep = ','); | ||
178 | void writeConfig(const QString &, const QString &, const QString &); | ||
179 | void writeConfig(const QString &, const QString &, int); | ||
180 | void writeListConfig(const QString &, const QString &, | ||
181 | QStringList &, char sep = ','); | ||
182 | |||
183 | // return the current account group | ||
184 | QString currentGroup() { return cgroup; } | ||
185 | |||
186 | // functions to set/get general kppp info | ||
187 | QString password() const; | ||
188 | void setPassword(const QString &); | ||
189 | |||
190 | const QString defaultAccount(); | ||
191 | void setDefaultAccount(const QString &); | ||
192 | |||
193 | void set_xserver_exit_disconnect(bool set); | ||
194 | bool get_xserver_exit_disconnect(); | ||
195 | |||
196 | void setPPPDebug(bool set); | ||
197 | bool getPPPDebug(); | ||
198 | |||
199 | void set_quit_on_disconnect(bool); | ||
200 | bool quit_on_disconnect(); | ||
201 | |||
202 | void set_show_clock_on_caption(bool set); | ||
203 | bool get_show_clock_on_caption(); | ||
204 | |||
205 | void set_show_log_window(bool set); | ||
206 | bool get_show_log_window(); | ||
207 | |||
208 | void set_automatic_redial(bool set); | ||
209 | bool automatic_redial(); | ||
210 | |||
211 | void set_iconify_on_connect(bool set); | ||
212 | bool get_iconify_on_connect(); | ||
213 | |||
214 | void set_dock_into_panel(bool set); | ||
215 | bool get_dock_into_panel(); | ||
216 | |||
217 | const QString enter(); | ||
218 | void setEnter(const QString &); | ||
219 | |||
220 | QString pppdVersion(); | ||
221 | bool pppdVersionMin(int ver, int mod, int patch); | ||
222 | |||
223 | int pppdTimeout(); | ||
224 | void setpppdTimeout(int); | ||
225 | |||
226 | int busyWait(); | ||
227 | void setbusyWait(int); | ||
228 | |||
229 | bool modemLockFile(); | ||
230 | void setModemLockFile(bool set); | ||
231 | |||
232 | int modemEscapeGuardTime(); | ||
233 | void setModemEscapeGuardTime(int i); | ||
234 | |||
235 | void setModemEscapeStr(const QString &); | ||
236 | const QString modemEscapeStr(); | ||
237 | |||
238 | void setModemEscapeResp(const QString &); | ||
239 | const QString modemEscapeResp(); | ||
240 | |||
241 | const QString modemDevice(); | ||
242 | void setModemDevice(const QString &); | ||
243 | |||
244 | const QString flowcontrol(); | ||
245 | void setFlowcontrol(const QString &); | ||
246 | |||
247 | int modemTimeout(); | ||
248 | void setModemTimeout(int); | ||
249 | |||
250 | int modemToneDuration(); | ||
251 | void setModemToneDuration(int); | ||
252 | |||
253 | QString volumeInitString(); | ||
254 | int volume(); | ||
255 | void setVolume(int); | ||
256 | |||
257 | int waitForDialTone(); | ||
258 | void setWaitForDialTone(int i); | ||
259 | |||
260 | // modem command strings/responses | ||
261 | const QString modemInitStr(int i); | ||
262 | void setModemInitStr(int i, const QString &); | ||
263 | |||
264 | const QString modemInitResp(); | ||
265 | void setModemInitResp(const QString &); | ||
266 | |||
267 | int modemPreInitDelay(); | ||
268 | void setModemPreInitDelay(int); | ||
269 | |||
270 | int modemInitDelay(); | ||
271 | void setModemInitDelay(int); | ||
272 | |||
273 | QString modemNoDialToneDetectionStr(); | ||
274 | void setModemNoDialToneDetectionStr(const QString &); | ||
275 | |||
276 | const QString modemDialStr(); | ||
277 | void setModemDialStr(const QString &); | ||
278 | |||
279 | const QString modemConnectResp(); | ||
280 | void setModemConnectResp(const QString &); | ||
281 | |||
282 | const QString modemBusyResp(); | ||
283 | void setModemBusyResp(const QString &); | ||
284 | |||
285 | const QString modemNoCarrierResp(); | ||
286 | void setModemNoCarrierResp(const QString &); | ||
287 | |||
288 | const QString modemNoDialtoneResp(); | ||
289 | void setModemNoDialtoneResp(const QString &); | ||
290 | |||
291 | const QString modemHangupStr(); | ||
292 | void setModemHangupStr(const QString &); | ||
293 | |||
294 | const QString modemHangupResp(); | ||
295 | void setModemHangupResp(const QString &); | ||
296 | |||
297 | const QString modemAnswerStr(); | ||
298 | void setModemAnswerStr(const QString &); | ||
299 | |||
300 | const QString modemRingResp(); | ||
301 | void setModemRingResp(const QString &); | ||
302 | |||
303 | const QString modemAnswerResp(); | ||
304 | void setModemAnswerResp(const QString &); | ||
305 | |||
306 | QString volumeOff(); | ||
307 | void setVolumeOff(const QString &); | ||
308 | |||
309 | QString volumeMedium(); | ||
310 | void setVolumeMedium(const QString &); | ||
311 | |||
312 | QString volumeHigh(); | ||
313 | void setVolumeHigh(const QString &); | ||
314 | |||
315 | #if 0 | ||
316 | void setUseCDLine(const int n); | ||
317 | int UseCDLine(); | ||
318 | #endif | ||
319 | |||
320 | // functions to set/get account information | ||
321 | int count() const; | ||
322 | bool setAccount(const QString &); | ||
323 | bool setAccountbyIndex(int); | ||
324 | |||
325 | bool isUniqueAccname(const QString &); | ||
326 | |||
327 | bool deleteAccount(); | ||
328 | bool deleteAccount(const QString &); | ||
329 | int newaccount(); | ||
330 | int copyaccount(int i); | ||
331 | |||
332 | const QString accname(); | ||
333 | void setAccname(const QString &); | ||
334 | |||
335 | QStringList &phonenumbers(); | ||
336 | const QString phonenumber(); | ||
337 | void setPhonenumber(const QString &); | ||
338 | |||
339 | const QString dialPrefix(); | ||
340 | void setDialPrefix(const QString &); | ||
341 | |||
342 | int authMethod(); | ||
343 | void setAuthMethod(int); | ||
344 | |||
345 | const QString storedUsername(); | ||
346 | void setStoredUsername(const QString &); | ||
347 | |||
348 | const QString storedPassword(); | ||
349 | void setStoredPassword(const QString &); | ||
350 | |||
351 | bool storePassword(); | ||
352 | void setStorePassword(bool); | ||
353 | |||
354 | const QString speed(); | ||
355 | void setSpeed(const QString &); | ||
356 | |||
357 | const QString command_before_connect(); | ||
358 | void setCommand_before_connect(const QString &); | ||
359 | |||
360 | const QString command_on_connect(); | ||
361 | void setCommand_on_connect(const QString &); | ||
362 | |||
363 | const QString command_on_disconnect(); | ||
364 | void setCommand_on_disconnect(const QString &); | ||
365 | |||
366 | const QString command_before_disconnect(); | ||
367 | void setCommand_before_disconnect(const QString &); | ||
368 | |||
369 | const QString ipaddr(); | ||
370 | void setIpaddr(const QString &); | ||
371 | |||
372 | const QString subnetmask(); | ||
373 | void setSubnetmask(const QString &); | ||
374 | |||
375 | bool AcctEnabled(); | ||
376 | void setAcctEnabled(bool set); | ||
377 | |||
378 | int VolAcctEnabled(); | ||
379 | void setVolAcctEnabled(int set); | ||
380 | |||
381 | bool autoDNS(); | ||
382 | void setAutoDNS(bool set); | ||
383 | |||
384 | bool exDNSDisabled(); | ||
385 | void setExDNSDisabled(bool set); | ||
386 | |||
387 | bool autoname(); | ||
388 | void setAutoname(bool set); | ||
389 | |||
390 | const QString gateway(); | ||
391 | void setGateway(const QString &); | ||
392 | |||
393 | bool defaultroute(); | ||
394 | void setDefaultroute(bool set); | ||
395 | |||
396 | QStringList &dns(); | ||
397 | void setDns(QStringList &); | ||
398 | |||
399 | const QString domain(); | ||
400 | void setDomain(const QString &); | ||
401 | |||
402 | QStringList &scriptType(); | ||
403 | void setScriptType(QStringList &); | ||
404 | |||
405 | QStringList &script(); | ||
406 | void setScript(QStringList &); | ||
407 | |||
408 | QStringList &pppdArgument(); | ||
409 | void setpppdArgumentDefaults(); | ||
410 | void setpppdArgument(QStringList &); | ||
411 | |||
412 | //functions to change/set the child pppd process info | ||
413 | bool pppdRunning() const; | ||
414 | void setpppdRunning(bool set); | ||
415 | |||
416 | int pppdError() const; | ||
417 | void setpppdError(int err); | ||
418 | |||
419 | // functions to set/query the accounting info | ||
420 | const QString accountingFile(); | ||
421 | void setAccountingFile(const QString &); | ||
422 | |||
423 | const QString totalCosts(); | ||
424 | void setTotalCosts(const QString &); | ||
425 | |||
426 | int totalBytes(); | ||
427 | void setTotalBytes(int); | ||
428 | |||
429 | // graphing widget | ||
430 | void setGraphingOptions(bool enabled, | ||
431 | QColor bg, | ||
432 | QColor text, | ||
433 | QColor in, | ||
434 | QColor out); | ||
435 | void graphingOptions(bool &enabled, | ||
436 | QColor &bg, | ||
437 | QColor &text, | ||
438 | QColor &in, | ||
439 | QColor &out); | ||
440 | bool graphingEnabled(); | ||
441 | |||
442 | // window positions | ||
443 | void winPosConWin(int &, int &); | ||
444 | void setWinPosConWin(int, int); | ||
445 | void winPosStatWin(int &, int &); | ||
446 | void setWinPosStatWin(int, int); | ||
447 | |||
448 | private: | ||
449 | QString passwd; | ||
450 | Config* config; // configuration object | ||
451 | int highcount; // index of highest account | ||
452 | int caccount; // index of the current account | ||
453 | QString cgroup; // name of current config group | ||
454 | pid_t suidprocessid; // process ID of setuid child | ||
455 | bool pppdisrunning; // pppd process | ||
456 | // daemon | ||
457 | int pppderror; // error encounterd running pppd | ||
458 | int pppdVer, pppdMod, pppdPatch; // pppd version | ||
459 | |||
460 | QStringList phonelist; | ||
461 | }; | ||
462 | |||
463 | extern PPPData gpppdata; | ||
464 | |||
465 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/pppimp.cpp b/noncore/settings/networksettings/ppp/pppimp.cpp index d3094fc..6588bbc 100644 --- a/noncore/settings/networksettings/ppp/pppimp.cpp +++ b/noncore/settings/networksettings/ppp/pppimp.cpp | |||
@@ -1,39 +1,60 @@ | |||
1 | |||
2 | #include <qcombobox.h> | ||
3 | #include <qpushbutton.h> | ||
4 | |||
1 | #include "pppimp.h" | 5 | #include "pppimp.h" |
6 | #include "devices.h" | ||
7 | #include "modem.h" | ||
8 | #include "modeminfo.h" | ||
9 | //#include "pppdata.h" | ||
10 | |||
2 | 11 | ||
3 | PPPConfigureImp::PPPConfigureImp( QWidget* parent, const char* name, bool modal, WFlags fl) : PPP(parent, name, modal, fl) { | 12 | PPPConfigureImp::PPPConfigureImp( QWidget* parent, const char* name, bool modal, WFlags fl) : PPP(parent, name, modal, fl) { |
4 | 13 | ||
14 | for(int i = 0; devices[i]; i++) | ||
15 | ComboBoxDevice->insertItem(devices[i]); | ||
16 | connect(PushButtonQuery, SIGNAL(clicked()), SLOT(queryModem())); | ||
5 | } | 17 | } |
6 | 18 | ||
7 | /** | 19 | /** |
8 | * Open up the peers file and read any set settings | 20 | * Open up the peers file and read any set settings |
9 | * @param peer the peer file to edit. | 21 | * @param peer the peer file to edit. |
10 | */ | 22 | */ |
11 | void PPPConfigureImp::setPeer(const QString &newPeer){ | 23 | void PPPConfigureImp::setPeer(const QString &newPeer){ |
12 | peer = newPeer; | 24 | peer = newPeer; |
13 | } | 25 | } |
14 | 26 | ||
15 | /** | 27 | /** |
16 | * Save the settings for the current peer. | 28 | * Save the settings for the current peer. |
17 | */ | 29 | */ |
18 | void PPPConfigureImp::accept(){ | 30 | void PPPConfigureImp::accept(){ |
19 | // Check to make sure that all of the inputs are valid. | 31 | // Check to make sure that all of the inputs are valid. |
20 | 32 | ||
21 | // Save settings. | 33 | // Save settings. |
22 | /** | 34 | /** |
23 | /dev/modem or just modem | 35 | /dev/modem or just modem |
24 | <speed> any | 36 | <speed> any |
25 | defaultroute - automaticly add route | 37 | defaultroute - automaticly add route |
26 | noipdefault - get an ip from the server | 38 | noipdefault - get an ip from the server |
27 | usepeerdns - automaticly add dns | 39 | usepeerdns - automaticly add dns |
28 | crtscts - flow control enabled | 40 | crtscts - flow control enabled |
29 | name <name> - user name (and do secret file) | 41 | name <name> - user name (and do secret file) |
30 | */ | 42 | */ |
31 | 43 | ||
32 | // Make sure it is set in interfaces so pon/off can be used. | 44 | // Make sure it is set in interfaces so pon/off can be used. |
33 | 45 | ||
34 | // Close out the dialog | 46 | // Close out the dialog |
35 | QDialog::accept(); | 47 | QDialog::accept(); |
36 | } | 48 | } |
37 | 49 | ||
38 | // pppconfigureimp.h | 50 | void PPPConfigureImp::queryModem() |
51 | { | ||
52 | |||
53 | Modem::modem = new Modem(); | ||
54 | qDebug("setting device"); | ||
55 | // gpppdata.setModemDevice(ComboBoxDevice->currentText()); | ||
56 | qDebug("open dialog"); | ||
57 | ModemTransfer mt(this); | ||
58 | mt.exec(); | ||
59 | } | ||
39 | 60 | ||
diff --git a/noncore/settings/networksettings/ppp/pppimp.h b/noncore/settings/networksettings/ppp/pppimp.h index 1bc1fad..a94139e 100644 --- a/noncore/settings/networksettings/ppp/pppimp.h +++ b/noncore/settings/networksettings/ppp/pppimp.h | |||
@@ -1,25 +1,27 @@ | |||
1 | #ifndef PPPIMP_H | 1 | #ifndef PPPIMP_H |
2 | #define PPPIMP_H | 2 | #define PPPIMP_H |
3 | 3 | ||
4 | #include "ppp.h" | 4 | #include "ppp.h" |
5 | 5 | ||
6 | class PPPConfigureImp : public PPP { | 6 | class PPPConfigureImp : public PPP { |
7 | 7 | ||
8 | Q_OBJECT | 8 | Q_OBJECT |
9 | 9 | ||
10 | public: | 10 | public: |
11 | PPPConfigureImp(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); | 11 | PPPConfigureImp(QWidget* parent = 0, const char* name = 0, bool modal = true, WFlags fl = 0); |
12 | void setPeer(const QString &peer); | 12 | void setPeer(const QString &peer); |
13 | 13 | ||
14 | protected: | 14 | protected: |
15 | void accept(); | 15 | void accept(); |
16 | 16 | ||
17 | protected slots: | ||
18 | void queryModem(); | ||
17 | private: | 19 | private: |
18 | QString peer; | 20 | QString peer; |
19 | 21 | ||
20 | }; | 22 | }; |
21 | 23 | ||
22 | #endif | 24 | #endif |
23 | 25 | ||
24 | // pppconfigureimp.h | 26 | // pppconfigureimp.h |
25 | 27 | ||
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index 72cd45e..40d2455 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,107 +1,115 @@ | |||
1 | #include "pppmodule.h" | 1 | #include "pppmodule.h" |
2 | #include "pppimp.h" | 2 | #include "pppimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | //#include "devices.h" | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * Constructor, find all of the possible interfaces | 7 | * Constructor, find all of the possible interfaces |
7 | */ | 8 | */ |
8 | PPPModule::PPPModule() : Module() { | 9 | PPPModule::PPPModule() : Module() { |
9 | } | 10 | } |
10 | 11 | ||
11 | /** | 12 | /** |
12 | * Delete any interfaces that we own. | 13 | * Delete any interfaces that we own. |
13 | */ | 14 | */ |
14 | PPPModule::~PPPModule(){ | 15 | PPPModule::~PPPModule(){ |
15 | Interface *i; | 16 | Interface *i; |
16 | for ( i=list.first(); i != 0; i=list.next() ) | 17 | for ( i=list.first(); i != 0; i=list.next() ) |
17 | delete i; | 18 | delete i; |
18 | } | 19 | } |
19 | 20 | ||
20 | /** | 21 | /** |
21 | * Change the current profile | 22 | * Change the current profile |
22 | */ | 23 | */ |
23 | void PPPModule::setProfile(const QString &newProfile){ | 24 | void PPPModule::setProfile(const QString &newProfile){ |
24 | profile = newProfile; | 25 | profile = newProfile; |
25 | } | 26 | } |
26 | 27 | ||
27 | /** | 28 | /** |
28 | * get the icon name for this device. | 29 | * get the icon name for this device. |
29 | * @param Interface* can be used in determining the icon. | 30 | * @param Interface* can be used in determining the icon. |
30 | * @return QString the icon name (minus .png, .gif etc) | 31 | * @return QString the icon name (minus .png, .gif etc) |
31 | */ | 32 | */ |
32 | QString PPPModule::getPixmapName(Interface* ){ | 33 | QString PPPModule::getPixmapName(Interface* ){ |
33 | return "ppp"; | 34 | return "ppp"; |
34 | } | 35 | } |
35 | 36 | ||
36 | /** | 37 | /** |
37 | * Check to see if the interface i is owned by this module. | 38 | * Check to see if the interface i is owned by this module. |
38 | * @param Interface* interface to check against | 39 | * @param Interface* interface to check against |
39 | * @return bool true if i is owned by this module, false otherwise. | 40 | * @return bool true if i is owned by this module, false otherwise. |
40 | */ | 41 | */ |
41 | bool PPPModule::isOwner(Interface *i){ | 42 | bool PPPModule::isOwner(Interface *i){ |
42 | if(!i->getInterfaceName().upper().contains("PPP")) | 43 | if(!i->getInterfaceName().upper().contains("PPP")) |
43 | return false; | 44 | return false; |
44 | 45 | ||
45 | i->setHardwareName("PPP"); | 46 | i->setHardwareName("PPP"); |
46 | list.append(i); | 47 | list.append(i); |
47 | return true; | 48 | return true; |
48 | } | 49 | } |
49 | 50 | ||
50 | /** | 51 | /** |
51 | * Create, and return the WLANConfigure Module | 52 | * Create, and return the WLANConfigure Module |
52 | * @return QWidget* pointer to this modules configure. | 53 | * @return QWidget* pointer to this modules configure. |
53 | */ | 54 | */ |
54 | QWidget *PPPModule::configure(Interface *i){ | 55 | QWidget *PPPModule::configure(Interface *i){ |
55 | return NULL; | 56 | PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", /* i,*/ false, Qt::WDestructiveClose); |
56 | //PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", i, false, Qt::WDestructiveClose); | 57 | // pppconfig->setProfile(profile); |
57 | //pppconfig->setProfile(profile); | 58 | return pppconfig; |
58 | //return wlanconfig; | ||
59 | } | 59 | } |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Create, and return the Information Module | 62 | * Create, and return the Information Module |
63 | * @return QWidget* pointer to this modules info. | 63 | * @return QWidget* pointer to this modules info. |
64 | */ | 64 | */ |
65 | QWidget *PPPModule::information(Interface *i){ | 65 | QWidget *PPPModule::information(Interface *i){ |
66 | // We don't have any advanced pppd information widget yet :-D | 66 | // We don't have any advanced pppd information widget yet :-D |
67 | // TODO ^ | 67 | // TODO ^ |
68 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); | 68 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); |
69 | return information; | 69 | return information; |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Get all active (up or down) interfaces | 73 | * Get all active (up or down) interfaces |
74 | * @return QList<Interface> A list of interfaces that exsist that havn't | 74 | * @return QList<Interface> A list of interfaces that exsist that havn't |
75 | * been called by isOwner() | 75 | * been called by isOwner() |
76 | */ | 76 | */ |
77 | QList<Interface> PPPModule::getInterfaces(){ | 77 | QList<Interface> PPPModule::getInterfaces(){ |
78 | // List all of the files in the peer directory | 78 | // List all of the files in the peer directory |
79 | return list; | 79 | return list; |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Attempt to add a new interface as defined by name | 83 | * Attempt to add a new interface as defined by name |
84 | * @param name the name of the type of interface that should be created given | 84 | * @param name the name of the type of interface that should be created given |
85 | * by possibleNewInterfaces(); | 85 | * by possibleNewInterfaces(); |
86 | * @return Interface* NULL if it was unable to be created. | 86 | * @return Interface* NULL if it was unable to be created. |
87 | */ | 87 | */ |
88 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 88 | Interface *PPPModule::addNewInterface(const QString &newInterface){ |
89 | // If the | 89 | // If the |
90 | qDebug("try to add iface %s",newInterface.latin1()); | ||
90 | PPPConfigureImp imp(0, "PPPConfigImp"); | 91 | PPPConfigureImp imp(0, "PPPConfigImp"); |
92 | imp.showMaximized(); | ||
91 | if(imp.exec() == QDialog::Accepted ){ | 93 | if(imp.exec() == QDialog::Accepted ){ |
92 | 94 | qDebug("ACCEPTED"); | |
95 | return new Interface( 0, newInterface ); | ||
93 | } | 96 | } |
94 | return NULL; | 97 | return NULL; |
95 | } | 98 | } |
96 | 99 | ||
97 | /** | 100 | /** |
98 | * Attempts to remove the interface, doesn't delete i | 101 | * Attempts to remove the interface, doesn't delete i |
99 | * @return bool true if successfull, false otherwise. | 102 | * @return bool true if successfull, false otherwise. |
100 | */ | 103 | */ |
101 | bool PPPModule::remove(Interface*){ | 104 | bool PPPModule::remove(Interface*){ |
102 | // Can't remove a hardware device, you can stop it though. | 105 | // Can't remove a hardware device, you can stop it though. |
103 | return false; | 106 | return false; |
107 | } | ||
108 | |||
109 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | ||
110 | { | ||
111 | qDebug("here"); | ||
112 | newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device")); | ||
104 | } | 113 | } |
105 | 114 | ||
106 | // pppmodule.cpp | ||
107 | 115 | ||
diff --git a/noncore/settings/networksettings/ppp/pppmodule.h b/noncore/settings/networksettings/ppp/pppmodule.h index c8e77e2..6464f87 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.h +++ b/noncore/settings/networksettings/ppp/pppmodule.h | |||
@@ -1,41 +1,41 @@ | |||
1 | #ifndef PPP_MODULE_H | 1 | #ifndef PPP_MODULE_H |
2 | #define PPP_MODULE_H | 2 | #define PPP_MODULE_H |
3 | 3 | ||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | class PPPModule : Module { | 6 | class PPPModule : Module { |
7 | 7 | ||
8 | signals: | 8 | signals: |
9 | void updateInterface(Interface *i); | 9 | void updateInterface(Interface *i); |
10 | 10 | ||
11 | public: | 11 | public: |
12 | PPPModule(); | 12 | PPPModule(); |
13 | ~PPPModule(); | 13 | ~PPPModule(); |
14 | 14 | ||
15 | virtual void setProfile(const QString &newProfile); | 15 | virtual void setProfile(const QString &newProfile); |
16 | virtual bool isOwner(Interface *); | 16 | virtual bool isOwner(Interface *); |
17 | virtual QWidget *configure(Interface *i); | 17 | virtual QWidget *configure(Interface *i); |
18 | virtual QWidget *information(Interface *i); | 18 | virtual QWidget *information(Interface *i); |
19 | virtual QList<Interface> getInterfaces(); | 19 | virtual QList<Interface> getInterfaces(); |
20 | virtual void possibleNewInterfaces(QMap<QString, QString> &){}; | 20 | virtual void possibleNewInterfaces(QMap<QString, QString> &); |
21 | virtual Interface *addNewInterface(const QString &name); | 21 | virtual Interface *addNewInterface(const QString &name); |
22 | virtual bool remove(Interface* i); | 22 | virtual bool remove(Interface* i); |
23 | virtual QString getPixmapName(Interface* i); | 23 | virtual QString getPixmapName(Interface* i); |
24 | 24 | ||
25 | private: | 25 | private: |
26 | QList<Interface> list; | 26 | QList<Interface> list; |
27 | QString profile; | 27 | QString profile; |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | extern "C" | 31 | extern "C" |
32 | { | 32 | { |
33 | void* create_plugin() { | 33 | void* create_plugin() { |
34 | return new PPPModule(); | 34 | return new PPPModule(); |
35 | } | 35 | } |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | // pppmodule.h | 40 | // pppmodule.h |
41 | 41 | ||
diff --git a/noncore/settings/networksettings/ppp/runtests.cpp b/noncore/settings/networksettings/ppp/runtests.cpp new file mode 100644 index 0000000..83ef2ea --- a/dev/null +++ b/noncore/settings/networksettings/ppp/runtests.cpp | |||
@@ -0,0 +1,279 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * This file was contributed by Mario Weilguni <mweilguni@sime.com> | ||
10 | * Thanks Mario ! | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qdir.h> | ||
28 | #include "runtests.h" | ||
29 | #include <ctype.h> | ||
30 | #include <unistd.h> | ||
31 | #include <qmessagebox.h> | ||
32 | #include <sys/stat.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <sys/types.h> | ||
35 | #include <pwd.h> | ||
36 | #include <netinet/in.h> | ||
37 | |||
38 | #ifdef HAVE_RESOLV_H | ||
39 | #include <arpa/nameser.h> | ||
40 | #include <resolv.h> | ||
41 | #endif | ||
42 | |||
43 | #ifndef _PATH_RESCONF | ||
44 | #define _PATH_RESCONF "/etc/resolv.conf" | ||
45 | #endif | ||
46 | |||
47 | //#include <klocale.h> | ||
48 | #define i18n QObject::tr | ||
49 | #include "pppdata.h" | ||
50 | |||
51 | // initial effective uid (main.cpp) | ||
52 | extern uid_t euid; | ||
53 | |||
54 | // secure pppd location (opener.cpp) | ||
55 | extern const char* pppdPath(); | ||
56 | |||
57 | // shamelessly stolen from pppd-2.3.5 | ||
58 | /******************************************************************** | ||
59 | * | ||
60 | * Internal routine to decode the version.modification.patch level | ||
61 | */ | ||
62 | |||
63 | static void decode_version (const char *_buf, int *version, | ||
64 | int *modification, int *patch) | ||
65 | { | ||
66 | char *buffer = qstrdup(_buf); | ||
67 | char *buf = buffer; | ||
68 | *version = (int) strtoul (buf, &buf, 10); | ||
69 | *modification = 0; | ||
70 | *patch = 0; | ||
71 | |||
72 | if (*buf == '.') | ||
73 | { | ||
74 | ++buf; | ||
75 | *modification = (int) strtoul (buf, &buf, 10); | ||
76 | if (*buf == '.') | ||
77 | { | ||
78 | ++buf; | ||
79 | *patch = (int) strtoul (buf, &buf, 10); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | if (*buf != '\0') | ||
84 | { | ||
85 | *version = | ||
86 | *modification = | ||
87 | *patch = 0; | ||
88 | } | ||
89 | |||
90 | delete [] buffer; | ||
91 | } | ||
92 | |||
93 | |||
94 | void pppdVersion(int *version, int *modification, int *patch) { | ||
95 | char buffer[30]; | ||
96 | const char *pppd; | ||
97 | char *query; | ||
98 | |||
99 | *version = *modification = *patch = 0; | ||
100 | |||
101 | // locate pppd | ||
102 | if(!(pppd = pppdPath())) | ||
103 | return; | ||
104 | |||
105 | // call pppd with --version option | ||
106 | if(!(query = new char[strlen(pppd)+25])) | ||
107 | return; | ||
108 | strcpy(query, pppd); | ||
109 | // had to add a dummy device to prevent a "no device specified | ||
110 | // and stdin is not a tty" error from newer pppd versions. | ||
111 | strcat(query, " --version /dev/tty 2>&1"); | ||
112 | fflush(0L); | ||
113 | FILE *output = popen(query, "r"); | ||
114 | delete [] query; | ||
115 | if(!output) | ||
116 | return; | ||
117 | |||
118 | // read output | ||
119 | int size = fread(buffer, sizeof(char), 29, output); | ||
120 | |||
121 | if(ferror(output)) { | ||
122 | pclose(output); | ||
123 | return; | ||
124 | } | ||
125 | pclose(output); | ||
126 | buffer[size] = '\0'; | ||
127 | |||
128 | // find position of version number x.y.z | ||
129 | char *p = buffer; | ||
130 | while(*p && !isdigit(*p)) | ||
131 | p++; | ||
132 | if (*p == 0) | ||
133 | return; | ||
134 | char *p2 = p; | ||
135 | while(*p2 == '.' || isdigit(*p2)) | ||
136 | p2++; | ||
137 | *p2 = '\0'; | ||
138 | |||
139 | decode_version(p, version, modification, patch); | ||
140 | } | ||
141 | |||
142 | |||
143 | int uidFromName(const char *uname) { | ||
144 | struct passwd *pw; | ||
145 | |||
146 | setpwent(); | ||
147 | while((pw = getpwent()) != NULL) { | ||
148 | if(strcmp(uname, pw->pw_name) == 0) { | ||
149 | int uid = pw->pw_uid; | ||
150 | endpwent(); | ||
151 | return uid; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | endpwent(); | ||
156 | return -1; | ||
157 | } | ||
158 | |||
159 | |||
160 | const char *homedirFromUid(uid_t uid) { | ||
161 | struct passwd *pw; | ||
162 | char *d = 0; | ||
163 | |||
164 | setpwent(); | ||
165 | while((pw = getpwent()) != NULL) { | ||
166 | if(pw->pw_uid == uid) { | ||
167 | d = strdup(pw->pw_dir); | ||
168 | endpwent(); | ||
169 | return d; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | endpwent(); | ||
174 | return d; | ||
175 | } | ||
176 | |||
177 | |||
178 | const char* getHomeDir() { | ||
179 | static const char *hd = 0; | ||
180 | static bool ranTest = false; | ||
181 | if(!ranTest) { | ||
182 | hd = homedirFromUid(getuid()); | ||
183 | ranTest = true; | ||
184 | } | ||
185 | |||
186 | return hd; | ||
187 | } | ||
188 | |||
189 | |||
190 | int runTests() { | ||
191 | int warning = 0; | ||
192 | |||
193 | // Test pre-1: check if the user is allowed to dial-out | ||
194 | if(access("/etc/kppp.allow", R_OK) == 0 && getuid() != 0) { | ||
195 | bool access = FALSE; | ||
196 | FILE *f; | ||
197 | if((f = fopen("/etc/kppp.allow", "r")) != NULL) { | ||
198 | char buf[2048]; // safe | ||
199 | while(f != NULL && !feof(f)) { | ||
200 | if(fgets(buf, sizeof(buf), f) != NULL) { | ||
201 | QString s(buf); | ||
202 | |||
203 | s = s.stripWhiteSpace(); | ||
204 | if(s[0] == '#' || s.length() == 0) | ||
205 | continue; | ||
206 | |||
207 | if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) { | ||
208 | access = TRUE; | ||
209 | fclose(f); | ||
210 | f = NULL; | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | if(f) | ||
215 | fclose(f); | ||
216 | } | ||
217 | |||
218 | if(!access) { | ||
219 | QMessageBox::warning(0,"error", | ||
220 | i18n("You're not allowed to dial out with " | ||
221 | "kppp.\nContact your system administrator.")); | ||
222 | return TEST_CRITICAL; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | // Test 1: search the pppd binary | ||
227 | const char *f = pppdPath(); | ||
228 | |||
229 | if(!f) { | ||
230 | QMessageBox::warning(0,"error", | ||
231 | i18n("Cannot find the PPP daemon!\n" | ||
232 | "Make sure that pppd is installed.")); | ||
233 | warning++; | ||
234 | } | ||
235 | |||
236 | // Test 2: check access to the pppd binary | ||
237 | if(f) { | ||
238 | #if 0 | ||
239 | if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { | ||
240 | KMessageBox::warning(0, | ||
241 | i18n("You do not have the permission " | ||
242 | "to start pppd!\n" | ||
243 | "Contact your system administrator " | ||
244 | "and ask to get access to pppd.")); | ||
245 | return TEST_CRITICAL; | ||
246 | } | ||
247 | #endif | ||
248 | |||
249 | if(geteuid() != 0) { | ||
250 | struct stat st; | ||
251 | stat(f, &st); | ||
252 | if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { | ||
253 | QMessageBox::warning(0,"error", | ||
254 | i18n("You don't have sufficient permission to run\n" | ||
255 | "%1\n" | ||
256 | "Please make sure that kppp is owned by root " | ||
257 | "and has the SUID bit set.").arg(f)); | ||
258 | warning++; | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | |||
263 | // Test 5: check for existence of /etc/resolv.conf | ||
264 | if (access(_PATH_RESCONF, R_OK) != 0) { | ||
265 | QString file = _PATH_RESCONF" "; | ||
266 | QString msgstr = i18n("%1 is missing or can't be read!\n" | ||
267 | "Ask your system administrator to create " | ||
268 | "this file (can be empty) with appropriate " | ||
269 | "read and write permissions.").arg(file); | ||
270 | QMessageBox::warning(0, "errror", msgstr); | ||
271 | warning ++; | ||
272 | } | ||
273 | |||
274 | if(warning == 0) | ||
275 | return TEST_OK; | ||
276 | else | ||
277 | return TEST_WARNING; | ||
278 | } | ||
279 | |||
diff --git a/noncore/settings/networksettings/ppp/runtests.h b/noncore/settings/networksettings/ppp/runtests.h new file mode 100644 index 0000000..efb1197 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/runtests.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * This file was contributed by Mario Weilguni <mweilguni@sime.com> | ||
10 | * Thanks Mario ! | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with this program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #ifndef __RUNTESTS__H__ | ||
28 | #define __RUNTESTS__H__ | ||
29 | |||
30 | #define SYSOPTIONS "/etc/ppp/options" | ||
31 | |||
32 | const int TEST_OK = 0; | ||
33 | const int TEST_WARNING = 1; | ||
34 | const int TEST_NOCONNECT = 2; | ||
35 | const int TEST_CRITICAL = 3; | ||
36 | |||
37 | // Various tests to be run at starttime | ||
38 | int runTests(); | ||
39 | const char* getHomeDir(); | ||
40 | void pppdVersion(int *version, int *modification, int *patch); | ||
41 | |||
42 | #ifdef __linux__ | ||
43 | bool ppp_available(void); | ||
44 | #endif | ||
45 | |||
46 | #endif | ||
47 | |||