author | tille <tille> | 2003-05-24 23:34:09 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-24 23:34:09 (UTC) |
commit | d1c32c127b4dabb716064a790da6be7c24975a92 (patch) (unidiff) | |
tree | aa8a7865d4cccbc696c534d8de3ef3b139777c34 | |
parent | 58947769d80d49faaccac1703da0e66c90158957 (diff) | |
download | opie-d1c32c127b4dabb716064a790da6be7c24975a92.zip opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.gz opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.bz2 |
pppd stuff
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 229 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.h | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 134 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 28 |
5 files changed, 330 insertions, 102 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index cd5d21c..5139482 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -1,277 +1,291 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 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 | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <unistd.h> | ||
29 | #include <fcntl.h> | 30 | #include <fcntl.h> |
30 | #include <signal.h> | 31 | #include <signal.h> |
31 | #include <sys/ioctl.h> | 32 | #include <sys/ioctl.h> |
32 | #include <setjmp.h> | 33 | #include <setjmp.h> |
33 | #include <regex.h> | 34 | #include <regex.h> |
34 | #include <qregexp.h> | 35 | #include <qregexp.h> |
35 | #include <assert.h> | 36 | #include <assert.h> |
37 | #include <string.h> | ||
36 | 38 | ||
39 | #ifdef HAVE_RESOLV_H | ||
40 | # include <arpa/nameser.h> | ||
41 | # include <resolv.h> | ||
42 | #endif | ||
43 | |||
44 | #ifndef _PATH_RESCONF | ||
45 | #define _PATH_RESCONF "/etc/resolv.conf" | ||
46 | #endif | ||
47 | |||
48 | #define strlcpy strcpy | ||
37 | #include "auth.h" | 49 | #include "auth.h" |
38 | #include "modem.h" | 50 | #include "modem.h" |
39 | #include "pppdata.h" | 51 | #include "pppdata.h" |
40 | //#include <klocale.h> | 52 | //#include <klocale.h> |
41 | #define i18n QObject::tr | 53 | #define i18n QObject::tr |
42 | #define qError qDebug | 54 | #define qError qDebug |
43 | //#include <kdebug.h> | 55 | //#include <kdebug.h> |
44 | //#include <config.h> | 56 | //#include <config.h> |
45 | 57 | ||
46 | #define MY_ASSERT(x) if (!(x)) { \ | 58 | #define MY_ASSERT(x) if (!(x)) { \ |
47 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 59 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ |
48 | exit(1); } | 60 | exit(1); } |
49 | 61 | ||
50 | 62 | ||
51 | static sigjmp_buf jmp_buffer; | 63 | static sigjmp_buf jmp_buffer; |
52 | 64 | ||
53 | Modem *Modem::modem = 0; | 65 | Modem *Modem::modem = 0; |
54 | 66 | ||
55 | 67 | ||
56 | const char* pppdPath() { | 68 | const char* pppdPath() { |
57 | // wasting a few bytes | 69 | // wasting a few bytes |
58 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 70 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
59 | static char *pppdPath = 0L; | 71 | static char *pppdPath = 0L; |
60 | char *p; | 72 | char *p; |
61 | 73 | ||
62 | if(pppdPath == 0L) { | 74 | if(pppdPath == 0L) { |
63 | const char *c = PPPDSEARCHPATH; | 75 | const char *c = PPPDSEARCHPATH; |
64 | while(*c != '\0') { | 76 | while(*c != '\0') { |
65 | while(*c == ':') | 77 | while(*c == ':') |
66 | c++; | 78 | c++; |
67 | p = buffer; | 79 | p = buffer; |
68 | while(*c != '\0' && *c != ':') | 80 | while(*c != '\0' && *c != ':') |
69 | *p++ = *c++; | 81 | *p++ = *c++; |
70 | *p = '\0'; | 82 | *p = '\0'; |
71 | strcat(p, "/"); | 83 | strcat(p, "/"); |
72 | strcat(p, PPPDNAME); | 84 | strcat(p, PPPDNAME); |
73 | if(access(buffer, F_OK) == 0) | 85 | if(access(buffer, F_OK) == 0) |
74 | return (pppdPath = buffer); | 86 | return (pppdPath = buffer); |
75 | } | 87 | } |
76 | } | 88 | } |
77 | 89 | ||
78 | return pppdPath; | 90 | return pppdPath; |
79 | } | 91 | } |
80 | 92 | ||
81 | 93 | ||
82 | Modem::Modem() | 94 | Modem::Modem() |
83 | { | 95 | { |
84 | if (Modem::modem != 0) return; //CORRECT? | 96 | if (Modem::modem != 0) return; //CORRECT? |
85 | modemfd = -1; | 97 | modemfd = -1; |
98 | _pppdExitStatus = -1; | ||
99 | pppdPid = -1; | ||
86 | sn = 0L; | 100 | sn = 0L; |
87 | data_mode = false; | 101 | data_mode = false; |
88 | modem_is_locked = false; | 102 | modem_is_locked = false; |
89 | lockfile[0] = '\0'; | 103 | lockfile[0] = '\0'; |
90 | device = "/dev/modem"; | 104 | device = "/dev/modem"; |
91 | modem = this; | 105 | modem = this; |
92 | } | 106 | } |
93 | 107 | ||
94 | 108 | ||
95 | Modem::~Modem() { | 109 | Modem::~Modem() { |
96 | modem = 0; | 110 | modem = 0; |
97 | } | 111 | } |
98 | 112 | ||
99 | 113 | ||
100 | speed_t Modem::modemspeed() { | 114 | speed_t Modem::modemspeed() { |
101 | // convert the string modem speed int the gpppdata object to a t_speed type | 115 | // convert the string modem speed int the gpppdata object to a t_speed type |
102 | // to set the modem. The constants here should all be ifdef'd because | 116 | // to set the modem. The constants here should all be ifdef'd because |
103 | // other systems may not have them | 117 | // other systems may not have them |
104 | int i = PPPData::data()->speed().toInt()/100; | 118 | int i = PPPData::data()->speed().toInt()/100; |
105 | 119 | ||
106 | switch(i) { | 120 | switch(i) { |
107 | case 24: | 121 | case 24: |
108 | return B2400; | 122 | return B2400; |
109 | break; | 123 | break; |
110 | case 96: | 124 | case 96: |
111 | return B9600; | 125 | return B9600; |
112 | break; | 126 | break; |
113 | case 192: | 127 | case 192: |
114 | return B19200; | 128 | return B19200; |
115 | break; | 129 | break; |
116 | case 384: | 130 | case 384: |
117 | return B38400; | 131 | return B38400; |
118 | break; | 132 | break; |
119 | #ifdef B57600 | 133 | #ifdef B57600 |
120 | case 576: | 134 | case 576: |
121 | return B57600; | 135 | return B57600; |
122 | break; | 136 | break; |
123 | #endif | 137 | #endif |
124 | 138 | ||
125 | #ifdef B115200 | 139 | #ifdef B115200 |
126 | case 1152: | 140 | case 1152: |
127 | return B115200; | 141 | return B115200; |
128 | break; | 142 | break; |
129 | #endif | 143 | #endif |
130 | 144 | ||
131 | #ifdef B230400 | 145 | #ifdef B230400 |
132 | case 2304: | 146 | case 2304: |
133 | return B230400; | 147 | return B230400; |
134 | break; | 148 | break; |
135 | #endif | 149 | #endif |
136 | 150 | ||
137 | #ifdef B460800 | 151 | #ifdef B460800 |
138 | case 4608: | 152 | case 4608: |
139 | return B460800; | 153 | return B460800; |
140 | break; | 154 | break; |
141 | #endif | 155 | #endif |
142 | 156 | ||
143 | default: | 157 | default: |
144 | return B38400; | 158 | return B38400; |
145 | break; | 159 | break; |
146 | } | 160 | } |
147 | } | 161 | } |
148 | 162 | ||
149 | bool Modem::opentty() { | 163 | bool Modem::opentty() { |
150 | // int flags; | 164 | // int flags; |
151 | 165 | ||
152 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 166 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
153 | close(modemfd); | 167 | close(modemfd); |
154 | device = PPPData::data()->modemDevice(); | 168 | device = PPPData::data()->modemDevice(); |
155 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 169 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
156 | qDebug("error opening modem device !"); | 170 | qDebug("error opening modem device !"); |
157 | errmsg = i18n("Unable to open modem."); | 171 | errmsg = i18n("Unable to open modem."); |
158 | return false; | 172 | return false; |
159 | } | 173 | } |
160 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 174 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
161 | //} | 175 | //} |
162 | 176 | ||
163 | #if 0 | 177 | #if 0 |
164 | if(PPPData::data()->UseCDLine()) { | 178 | if(PPPData::data()->UseCDLine()) { |
165 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 179 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
166 | errmsg = i18n("Unable to detect state of CD line."); | 180 | errmsg = i18n("Unable to detect state of CD line."); |
167 | ::close(modemfd); | 181 | ::close(modemfd); |
168 | modemfd = -1; | 182 | modemfd = -1; |
169 | return false; | 183 | return false; |
170 | } | 184 | } |
171 | if ((flags&TIOCM_CD) == 0) { | 185 | if ((flags&TIOCM_CD) == 0) { |
172 | errmsg = i18n("The modem is not ready."); | 186 | errmsg = i18n("The modem is not ready."); |
173 | ::close(modemfd); | 187 | ::close(modemfd); |
174 | modemfd = -1; | 188 | modemfd = -1; |
175 | return false; | 189 | return false; |
176 | } | 190 | } |
177 | } | 191 | } |
178 | #endif | 192 | #endif |
179 | 193 | ||
180 | tcdrain (modemfd); | 194 | tcdrain (modemfd); |
181 | tcflush (modemfd, TCIOFLUSH); | 195 | tcflush (modemfd, TCIOFLUSH); |
182 | 196 | ||
183 | if(tcgetattr(modemfd, &tty) < 0){ | 197 | if(tcgetattr(modemfd, &tty) < 0){ |
184 | // this helps in some cases | 198 | // this helps in some cases |
185 | tcsendbreak(modemfd, 0); | 199 | tcsendbreak(modemfd, 0); |
186 | sleep(1); | 200 | sleep(1); |
187 | if(tcgetattr(modemfd, &tty) < 0){ | 201 | if(tcgetattr(modemfd, &tty) < 0){ |
188 | errmsg = i18n("The modem is busy."); | 202 | errmsg = i18n("The modem is busy."); |
189 | ::close(modemfd); | 203 | ::close(modemfd); |
190 | modemfd = -1; | 204 | modemfd = -1; |
191 | return false; | 205 | return false; |
192 | } | 206 | } |
193 | } | 207 | } |
194 | 208 | ||
195 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 209 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
196 | 210 | ||
197 | initial_tty = tty; | 211 | initial_tty = tty; |
198 | 212 | ||
199 | tty.c_cc[VMIN] = 0; // nonblocking | 213 | tty.c_cc[VMIN] = 0; // nonblocking |
200 | tty.c_cc[VTIME] = 0; | 214 | tty.c_cc[VTIME] = 0; |
201 | tty.c_oflag = 0; | 215 | tty.c_oflag = 0; |
202 | tty.c_lflag = 0; | 216 | tty.c_lflag = 0; |
203 | 217 | ||
204 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 218 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
205 | tty.c_cflag |= CS8 | CREAD; | 219 | tty.c_cflag |= CS8 | CREAD; |
206 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 220 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
207 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 221 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
208 | tty.c_lflag &= ~ICANON; // non-canonical mode | 222 | tty.c_lflag &= ~ICANON; // non-canonical mode |
209 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 223 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
210 | 224 | ||
211 | 225 | ||
212 | if(PPPData::data()->flowcontrol() != "None") { | 226 | if(PPPData::data()->flowcontrol() != "None") { |
213 | if(PPPData::data()->flowcontrol() == "CRTSCTS") { | 227 | if(PPPData::data()->flowcontrol() == "CRTSCTS") { |
214 | tty.c_cflag |= CRTSCTS; | 228 | tty.c_cflag |= CRTSCTS; |
215 | } | 229 | } |
216 | else { | 230 | else { |
217 | tty.c_iflag |= IXON | IXOFF; | 231 | tty.c_iflag |= IXON | IXOFF; |
218 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 232 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
219 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 233 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
220 | } | 234 | } |
221 | } | 235 | } |
222 | else { | 236 | else { |
223 | tty.c_cflag &= ~CRTSCTS; | 237 | tty.c_cflag &= ~CRTSCTS; |
224 | tty.c_iflag &= ~(IXON | IXOFF); | 238 | tty.c_iflag &= ~(IXON | IXOFF); |
225 | } | 239 | } |
226 | 240 | ||
227 | cfsetospeed(&tty, modemspeed()); | 241 | cfsetospeed(&tty, modemspeed()); |
228 | cfsetispeed(&tty, modemspeed()); | 242 | cfsetispeed(&tty, modemspeed()); |
229 | 243 | ||
230 | tcdrain(modemfd); | 244 | tcdrain(modemfd); |
231 | 245 | ||
232 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 246 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
233 | errmsg = i18n("The modem is busy."); | 247 | errmsg = i18n("The modem is busy."); |
234 | ::close(modemfd); | 248 | ::close(modemfd); |
235 | modemfd=-1; | 249 | modemfd=-1; |
236 | return false; | 250 | return false; |
237 | } | 251 | } |
238 | 252 | ||
239 | errmsg = i18n("Modem Ready."); | 253 | errmsg = i18n("Modem Ready."); |
240 | return true; | 254 | return true; |
241 | } | 255 | } |
242 | 256 | ||
243 | 257 | ||
244 | bool Modem::closetty() { | 258 | bool Modem::closetty() { |
245 | if(modemfd >=0 ) { | 259 | if(modemfd >=0 ) { |
246 | stop(); | 260 | stop(); |
247 | /* discard data not read or transmitted */ | 261 | /* discard data not read or transmitted */ |
248 | tcflush(modemfd, TCIOFLUSH); | 262 | tcflush(modemfd, TCIOFLUSH); |
249 | 263 | ||
250 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 264 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
251 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); | 265 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); |
252 | ::close(modemfd); | 266 | ::close(modemfd); |
253 | modemfd = -1; | 267 | modemfd = -1; |
254 | return false; | 268 | return false; |
255 | } | 269 | } |
256 | ::close(modemfd); | 270 | ::close(modemfd); |
257 | modemfd = -1; | 271 | modemfd = -1; |
258 | } | 272 | } |
259 | 273 | ||
260 | return true; | 274 | return true; |
261 | } | 275 | } |
262 | 276 | ||
263 | 277 | ||
264 | void Modem::readtty(int) { | 278 | void Modem::readtty(int) { |
265 | char buffer[200]; | 279 | char buffer[200]; |
266 | unsigned char c; | 280 | unsigned char c; |
267 | int len; | 281 | int len; |
268 | 282 | ||
269 | // read data in chunks of up to 200 bytes | 283 | // read data in chunks of up to 200 bytes |
270 | if((len = ::read(modemfd, buffer, 200)) > 0) { | 284 | if((len = ::read(modemfd, buffer, 200)) > 0) { |
271 | // split buffer into single characters for further processing | 285 | // split buffer into single characters for further processing |
272 | for(int i = 0; i < len; i++) { | 286 | for(int i = 0; i < len; i++) { |
273 | c = buffer[i] & 0x7F; | 287 | c = buffer[i] & 0x7F; |
274 | emit charWaiting(c); | 288 | emit charWaiting(c); |
275 | } | 289 | } |
276 | } | 290 | } |
277 | } | 291 | } |
@@ -566,244 +580,443 @@ int Modem::lockdevice() { | |||
566 | } | 580 | } |
567 | 581 | ||
568 | if (modem_is_locked) | 582 | if (modem_is_locked) |
569 | return 1; | 583 | return 1; |
570 | 584 | ||
571 | QString lockfile = LOCK_DIR"/LCK.."; | 585 | QString lockfile = LOCK_DIR"/LCK.."; |
572 | lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ | 586 | lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ |
573 | 587 | ||
574 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 588 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
575 | // if ((fd = Requester::rq-> | 589 | // if ((fd = Requester::rq-> |
576 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 590 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
577 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 591 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
578 | // file has more than 32 bytes, skip the rest | 592 | // file has more than 32 bytes, skip the rest |
579 | char oldlock[33]; // safe | 593 | char oldlock[33]; // safe |
580 | int sz = read(fd, &oldlock, 32); | 594 | int sz = read(fd, &oldlock, 32); |
581 | close (fd); | 595 | close (fd); |
582 | if (sz <= 0) | 596 | if (sz <= 0) |
583 | return 1; | 597 | return 1; |
584 | oldlock[sz] = '\0'; | 598 | oldlock[sz] = '\0'; |
585 | 599 | ||
586 | qDebug( "Device is locked by: %s", oldlock); | 600 | qDebug( "Device is locked by: %s", oldlock); |
587 | 601 | ||
588 | int oldpid; | 602 | int oldpid; |
589 | int match = sscanf(oldlock, "%d", &oldpid); | 603 | int match = sscanf(oldlock, "%d", &oldpid); |
590 | 604 | ||
591 | // found a pid in lockfile ? | 605 | // found a pid in lockfile ? |
592 | if (match < 1 || oldpid <= 0) | 606 | if (match < 1 || oldpid <= 0) |
593 | return 1; | 607 | return 1; |
594 | 608 | ||
595 | // check if process exists | 609 | // check if process exists |
596 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 610 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
597 | return 1; | 611 | return 1; |
598 | 612 | ||
599 | qDebug( "lockfile is stale" ); | 613 | qDebug( "lockfile is stale" ); |
600 | } | 614 | } |
601 | } | 615 | } |
602 | 616 | ||
603 | fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 617 | fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
604 | if(fd >= 0) { | 618 | if(fd >= 0) { |
605 | sprintf(newlock,"%010d\n", getpid()); | 619 | sprintf(newlock,"%010d\n", getpid()); |
606 | qDebug("Locking Device: %s", newlock); | 620 | qDebug("Locking Device: %s", newlock); |
607 | 621 | ||
608 | write(fd, newlock, strlen(newlock)); | 622 | write(fd, newlock, strlen(newlock)); |
609 | close(fd); | 623 | close(fd); |
610 | modem_is_locked=true; | 624 | modem_is_locked=true; |
611 | 625 | ||
612 | return 0; | 626 | return 0; |
613 | } | 627 | } |
614 | 628 | ||
615 | return -1; | 629 | return -1; |
616 | 630 | ||
617 | } | 631 | } |
618 | 632 | ||
619 | 633 | ||
620 | // UnLock modem device | 634 | // UnLock modem device |
621 | void Modem::unlockdevice() { | 635 | void Modem::unlockdevice() { |
622 | if (modem_is_locked) { | 636 | if (modem_is_locked) { |
623 | qDebug( "UnLocking Modem Device" ); | 637 | qDebug( "UnLocking Modem Device" ); |
624 | close(modemfd); | 638 | close(modemfd); |
625 | modemfd = -1; | 639 | modemfd = -1; |
626 | unlink(lockfile); | 640 | unlink(lockfile); |
627 | lockfile[0] = '\0'; | 641 | lockfile[0] = '\0'; |
628 | modem_is_locked=false; | 642 | modem_is_locked=false; |
629 | } | 643 | } |
630 | } | 644 | } |
631 | 645 | ||
632 | int Modem::openLockfile( QString lockfile, int flags) | 646 | int Modem::openLockfile( QString lockfile, int flags) |
633 | { | 647 | { |
634 | int fd; | 648 | int fd; |
635 | int mode; | 649 | int mode; |
636 | flags = O_RDONLY; | 650 | flags = O_RDONLY; |
637 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 651 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
638 | mode = 0644; | 652 | mode = 0644; |
639 | else | 653 | else |
640 | mode = 0; | 654 | mode = 0; |
641 | 655 | ||
642 | lockfile = LOCK_DIR; | 656 | lockfile = LOCK_DIR; |
643 | lockfile += "/LCK.."; | 657 | lockfile += "/LCK.."; |
644 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 658 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
645 | qDebug("lockfile >%s<",lockfile.latin1()); | 659 | qDebug("lockfile >%s<",lockfile.latin1()); |
646 | // TODO: | 660 | // TODO: |
647 | // struct stat st; | 661 | // struct stat st; |
648 | // if(stat(lockfile.data(), &st) == -1) { | 662 | // if(stat(lockfile.data(), &st) == -1) { |
649 | // if(errno == EBADF) | 663 | // if(errno == EBADF) |
650 | // return -1; | 664 | // return -1; |
651 | // } else { | 665 | // } else { |
652 | // // make sure that this is a regular file | 666 | // // make sure that this is a regular file |
653 | // if(!S_ISREG(st.st_mode)) | 667 | // if(!S_ISREG(st.st_mode)) |
654 | // return -1; | 668 | // return -1; |
655 | // } | 669 | // } |
656 | if ((fd = open(lockfile, flags, mode)) == -1) { | 670 | if ((fd = open(lockfile, flags, mode)) == -1) { |
657 | qDebug("error opening lockfile!"); | 671 | qDebug("error opening lockfile!"); |
658 | lockfile = QString::null; | 672 | lockfile = QString::null; |
659 | fd = open(DEVNULL, O_RDONLY); | 673 | fd = open(DEVNULL, O_RDONLY); |
660 | } else | 674 | } else |
661 | fchown(fd, 0, 0); | 675 | fchown(fd, 0, 0); |
662 | return fd; | 676 | return fd; |
663 | } | 677 | } |
664 | 678 | ||
665 | 679 | ||
666 | 680 | ||
667 | void alarm_handler(int) { | 681 | void alarm_handler(int) { |
668 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 682 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
669 | 683 | ||
670 | // jump | 684 | // jump |
671 | siglongjmp(jmp_buffer, 1); | 685 | siglongjmp(jmp_buffer, 1); |
672 | } | 686 | } |
673 | 687 | ||
674 | 688 | ||
675 | const char* Modem::authFile(Auth method, int version) { | 689 | const char* Modem::authFile(Auth method, int version) { |
676 | switch(method|version) { | 690 | switch(method|version) { |
677 | case PAP|Original: | 691 | case PAP|Original: |
678 | return PAP_AUTH_FILE; | 692 | return PAP_AUTH_FILE; |
679 | break; | 693 | break; |
680 | case PAP|New: | 694 | case PAP|New: |
681 | return PAP_AUTH_FILE".new"; | 695 | return PAP_AUTH_FILE".new"; |
682 | break; | 696 | break; |
683 | case PAP|Old: | 697 | case PAP|Old: |
684 | return PAP_AUTH_FILE".old"; | 698 | return PAP_AUTH_FILE".old"; |
685 | break; | 699 | break; |
686 | case CHAP|Original: | 700 | case CHAP|Original: |
687 | return CHAP_AUTH_FILE; | 701 | return CHAP_AUTH_FILE; |
688 | break; | 702 | break; |
689 | case CHAP|New: | 703 | case CHAP|New: |
690 | return CHAP_AUTH_FILE".new"; | 704 | return CHAP_AUTH_FILE".new"; |
691 | break; | 705 | break; |
692 | case CHAP|Old: | 706 | case CHAP|Old: |
693 | return CHAP_AUTH_FILE".old"; | 707 | return CHAP_AUTH_FILE".old"; |
694 | break; | 708 | break; |
695 | default: | 709 | default: |
696 | return 0L; | 710 | return 0L; |
697 | } | 711 | } |
698 | } | 712 | } |
699 | 713 | ||
700 | 714 | ||
701 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { | 715 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { |
702 | const char *authfile, *oldName, *newName; | 716 | const char *authfile, *oldName, *newName; |
703 | char line[100]; | 717 | char line[100]; |
704 | char regexp[2*MaxStrLen+30]; | 718 | char regexp[2*MaxStrLen+30]; |
705 | regex_t preg; | 719 | regex_t preg; |
706 | 720 | ||
707 | if(!(authfile = authFile(method))) | 721 | if(!(authfile = authFile(method))) |
708 | return false; | 722 | return false; |
709 | 723 | ||
710 | if(!(newName = authFile(method, New))) | 724 | if(!(newName = authFile(method, New))) |
711 | return false; | 725 | return false; |
712 | 726 | ||
713 | // look for username, "username" or 'username' | 727 | // look for username, "username" or 'username' |
714 | // if you modify this RE you have to adapt regexp's size above | 728 | // if you modify this RE you have to adapt regexp's size above |
715 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", | 729 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", |
716 | username,username); | 730 | username,username); |
717 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); | 731 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); |
718 | 732 | ||
719 | // copy to new file pap- or chap-secrets | 733 | // copy to new file pap- or chap-secrets |
720 | int old_umask = umask(0077); | 734 | int old_umask = umask(0077); |
721 | FILE *fout = fopen(newName, "w"); | 735 | FILE *fout = fopen(newName, "w"); |
722 | if(fout) { | 736 | if(fout) { |
723 | // copy old file | 737 | // copy old file |
724 | FILE *fin = fopen(authfile, "r"); | 738 | FILE *fin = fopen(authfile, "r"); |
725 | if(fin) { | 739 | if(fin) { |
726 | while(fgets(line, sizeof(line), fin)) { | 740 | while(fgets(line, sizeof(line), fin)) { |
727 | if(regexec(&preg, line, 0, 0L, 0) == 0) | 741 | if(regexec(&preg, line, 0, 0L, 0) == 0) |
728 | continue; | 742 | continue; |
729 | fputs(line, fout); | 743 | fputs(line, fout); |
730 | } | 744 | } |
731 | fclose(fin); | 745 | fclose(fin); |
732 | } | 746 | } |
733 | 747 | ||
734 | // append user/pass pair | 748 | // append user/pass pair |
735 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); | 749 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); |
736 | fclose(fout); | 750 | fclose(fout); |
737 | } | 751 | } |
738 | 752 | ||
739 | // restore umask | 753 | // restore umask |
740 | umask(old_umask); | 754 | umask(old_umask); |
741 | 755 | ||
742 | // free memory allocated by regcomp | 756 | // free memory allocated by regcomp |
743 | regfree(&preg); | 757 | regfree(&preg); |
744 | 758 | ||
745 | if(!(oldName = authFile(method, Old))) | 759 | if(!(oldName = authFile(method, Old))) |
746 | return false; | 760 | return false; |
747 | 761 | ||
748 | // delete old file if any | 762 | // delete old file if any |
749 | unlink(oldName); | 763 | unlink(oldName); |
750 | 764 | ||
751 | rename(authfile, oldName); | 765 | rename(authfile, oldName); |
752 | rename(newName, authfile); | 766 | rename(newName, authfile); |
753 | 767 | ||
754 | return true; | 768 | return true; |
755 | } | 769 | } |
756 | 770 | ||
757 | 771 | ||
772 | bool Modem::removeAuthFile(Auth method) { | ||
773 | const char *authfile, *oldName; | ||
774 | |||
775 | if(!(authfile = authFile(method))) | ||
776 | return false; | ||
777 | if(!(oldName = authFile(method, Old))) | ||
778 | return false; | ||
779 | |||
780 | if(access(oldName, F_OK) == 0) { | ||
781 | unlink(authfile); | ||
782 | return (rename(oldName, authfile) == 0); | ||
783 | } else | ||
784 | return false; | ||
785 | } | ||
786 | |||
787 | |||
758 | bool Modem::setSecret(int method, const char* name, const char* password) | 788 | bool Modem::setSecret(int method, const char* name, const char* password) |
759 | { | 789 | { |
760 | 790 | ||
761 | Auth auth; | 791 | Auth auth; |
762 | if(method == AUTH_PAPCHAP) | 792 | if(method == AUTH_PAPCHAP) |
763 | return setSecret(AUTH_PAP, name, password) && | 793 | return setSecret(AUTH_PAP, name, password) && |
764 | setSecret(AUTH_CHAP, name, password); | 794 | setSecret(AUTH_CHAP, name, password); |
765 | 795 | ||
766 | switch(method) { | 796 | switch(method) { |
767 | case AUTH_PAP: | 797 | case AUTH_PAP: |
768 | auth = Modem::PAP; | 798 | auth = Modem::PAP; |
769 | break; | 799 | break; |
770 | case AUTH_CHAP: | 800 | case AUTH_CHAP: |
771 | auth = Modem::CHAP; | 801 | auth = Modem::CHAP; |
772 | break; | 802 | break; |
773 | default: | 803 | default: |
774 | return false; | 804 | return false; |
775 | } | 805 | } |
776 | 806 | ||
777 | return createAuthFile(auth, name, password); | 807 | return createAuthFile(auth, name, password); |
778 | 808 | ||
779 | } | 809 | } |
780 | 810 | ||
781 | bool Modem::removeSecret(int) | 811 | bool Modem::removeSecret(int method) |
782 | { | 812 | { |
783 | return true; | 813 | Auth auth; |
814 | |||
815 | switch(method) { | ||
816 | case AUTH_PAP: | ||
817 | auth = Modem::PAP; | ||
818 | break; | ||
819 | case AUTH_CHAP: | ||
820 | auth = Modem::CHAP; | ||
821 | break; | ||
822 | default: | ||
823 | return false; | ||
824 | } | ||
825 | return removeAuthFile( auth ); | ||
784 | } | 826 | } |
785 | 827 | ||
786 | void Modem::killPPPDaemon() | 828 | int checkForInterface() |
787 | { | 829 | { |
830 | // I don't know if Linux needs more initialization to get the ioctl to | ||
831 | // work, pppd seems to hint it does. But BSD doesn't, and the following | ||
832 | // code should compile. | ||
833 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) | ||
834 | int s, ok; | ||
835 | struct ifreq ifr; | ||
836 | // extern char *no_ppp_msg; | ||
837 | |||
838 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | ||
839 | return 1; /* can't tell */ | ||
840 | |||
841 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); | ||
842 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; | ||
843 | close(s); | ||
844 | |||
845 | if (ok == -1) { | ||
846 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports | ||
847 | // KLDs, the old LKM interface couldn't handle loading devices | ||
848 | // dynamically, and thus can't load ppp support on the fly | ||
849 | #ifdef __FreeBSD__ | ||
850 | // If we failed to load ppp support and don't have it already. | ||
851 | if (kldload("if_ppp") == -1) { | ||
852 | return -1; | ||
853 | } | ||
854 | return 0; | ||
855 | #else | ||
856 | return -1; | ||
857 | #endif | ||
858 | } | ||
859 | return 0; | ||
860 | #else | ||
861 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp | ||
862 | struct stat buf; | ||
863 | |||
864 | memset(&buf, 0, sizeof(buf)); | ||
865 | return stat("/dev/ppp", &buf); | ||
866 | #endif | ||
788 | } | 867 | } |
789 | 868 | ||
790 | int Modem::pppdExitStatus() | 869 | bool Modem::execpppd(const char *arguments) { |
791 | { | 870 | char buf[MAX_CMDLEN]; |
792 | return -1; | 871 | char *args[MaxArgs]; |
872 | pid_t pgrpid; | ||
873 | |||
874 | if(modemfd<0) | ||
875 | return false; | ||
876 | |||
877 | _pppdExitStatus = -1; | ||
878 | |||
879 | switch(pppdPid = fork()) | ||
880 | { | ||
881 | case -1: | ||
882 | fprintf(stderr,"In parent: fork() failed\n"); | ||
883 | return false; | ||
884 | break; | ||
885 | |||
886 | case 0: | ||
887 | // let's parse the arguments the user supplied into UNIX suitable form | ||
888 | // that is a list of pointers each pointing to exactly one word | ||
889 | strlcpy(buf, arguments); | ||
890 | parseargs(buf, args); | ||
891 | // become a session leader and let /dev/ttySx | ||
892 | // be the controlling terminal. | ||
893 | pgrpid = setsid(); | ||
894 | #ifdef TIOCSCTTY | ||
895 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) | ||
896 | fprintf(stderr, "ioctl() failed.\n"); | ||
897 | #elif defined (TIOCSPGRP) | ||
898 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) | ||
899 | fprintf(stderr, "ioctl() failed.\n"); | ||
900 | #endif | ||
901 | if(tcsetpgrp(modemfd, pgrpid)<0) | ||
902 | fprintf(stderr, "tcsetpgrp() failed.\n"); | ||
903 | |||
904 | dup2(modemfd, 0); | ||
905 | dup2(modemfd, 1); | ||
906 | |||
907 | switch (checkForInterface()) { | ||
908 | case 1: | ||
909 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | ||
910 | break; | ||
911 | case -1: | ||
912 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | ||
913 | break; | ||
914 | case 0: | ||
915 | fprintf(stderr, "Kernel supports ppp alright.\n"); | ||
916 | break; | ||
917 | } | ||
918 | |||
919 | execve(pppdPath(), args, 0L); | ||
920 | _exit(0); | ||
921 | break; | ||
922 | |||
923 | default: | ||
924 | qDebug("In parent: pppd pid %d\n",pppdPid); | ||
925 | close(modemfd); | ||
926 | modemfd = -1; | ||
927 | return true; | ||
928 | break; | ||
929 | } | ||
930 | } | ||
931 | |||
932 | |||
933 | bool Modem::killpppd() { | ||
934 | if(pppdPid > 0) { | ||
935 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | ||
936 | if(kill(pppdPid, SIGTERM) < 0) { | ||
937 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | ||
938 | if(kill(pppdPid, SIGKILL) < 0) { | ||
939 | qDebug("Error killing %d\n", pppdPid); | ||
940 | return false; | ||
941 | } | ||
942 | } | ||
943 | } | ||
944 | return true; | ||
945 | } | ||
946 | |||
947 | |||
948 | void Modem::parseargs(char* buf, char** args) { | ||
949 | int nargs = 0; | ||
950 | int quotes; | ||
951 | |||
952 | while(nargs < MaxArgs-1 && *buf != '\0') { | ||
953 | |||
954 | quotes = 0; | ||
955 | |||
956 | // Strip whitespace. Use nulls, so that the previous argument is | ||
957 | // terminated automatically. | ||
958 | |||
959 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) | ||
960 | *buf++ = '\0'; | ||
961 | |||
962 | // detect begin of quoted argument | ||
963 | if (*buf == '"' || *buf == '\'') { | ||
964 | quotes = *buf; | ||
965 | *buf++ = '\0'; | ||
966 | } | ||
967 | |||
968 | // save the argument | ||
969 | if(*buf != '\0') { | ||
970 | *args++ = buf; | ||
971 | nargs++; | ||
972 | } | ||
973 | |||
974 | if (!quotes) | ||
975 | while ((*buf != '\0') && (*buf != '\n') && | ||
976 | (*buf != '\t') && (*buf != ' ')) | ||
977 | buf++; | ||
978 | else { | ||
979 | while ((*buf != '\0') && (*buf != quotes)) | ||
980 | buf++; | ||
981 | *buf++ = '\0'; | ||
982 | } | ||
983 | } | ||
984 | |||
985 | *args = 0L; | ||
793 | } | 986 | } |
794 | 987 | ||
795 | bool Modem::execPPPDaemon(const QString & arguments) | 988 | bool Modem::execPPPDaemon(const QString & arguments) |
796 | { | 989 | { |
990 | if(execpppd(arguments)==0) { | ||
991 | PPPData::data()->setpppdRunning(true); | ||
797 | return true; | 992 | return true; |
993 | } else | ||
994 | return false; | ||
995 | } | ||
996 | |||
997 | void Modem::killPPPDaemon() | ||
998 | { | ||
999 | PPPData::data()->setpppdRunning(false); | ||
1000 | killpppd(); | ||
1001 | } | ||
1002 | |||
1003 | int Modem::pppdExitStatus() | ||
1004 | { | ||
1005 | return _pppdExitStatus; | ||
798 | } | 1006 | } |
799 | 1007 | ||
800 | int Modem::openResolv(int flags) | 1008 | int Modem::openResolv(int flags) |
801 | { | 1009 | { |
802 | return -1; | 1010 | int fd; |
1011 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | ||
1012 | qDebug("error opening resolv.conf!"); | ||
1013 | fd = open(DEVNULL, O_RDONLY); | ||
1014 | } | ||
1015 | return fd; | ||
803 | } | 1016 | } |
804 | 1017 | ||
805 | bool Modem::setHostname(const QString & name) | 1018 | bool Modem::setHostname(const QString & name) |
806 | { | 1019 | { |
807 | return true; | 1020 | return sethostname(name, name.length()) == 0; |
808 | } | 1021 | } |
809 | 1022 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h index 052be4a..b494977 100644 --- a/noncore/settings/networksettings/ppp/modem.h +++ b/noncore/settings/networksettings/ppp/modem.h | |||
@@ -1,113 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 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 | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _MODEM_H_ | 27 | #ifndef _MODEM_H_ |
28 | #define _MODEM_H_ | 28 | #define _MODEM_H_ |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | 31 | ||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <termios.h> | 33 | #include <termios.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | 35 | ||
36 | #include <qsocketnotifier.h> | 36 | #include <qsocketnotifier.h> |
37 | 37 | ||
38 | //#include <config.h> | 38 | //#include <config.h> |
39 | 39 | ||
40 | void alarm_handler(int); | 40 | void alarm_handler(int); |
41 | const char *pppdPath(); | 41 | const char *pppdPath(); |
42 | 42 | ||
43 | class Modem : public QObject { | 43 | class Modem : public QObject { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | Modem(); | 46 | Modem(); |
47 | ~Modem(); | 47 | ~Modem(); |
48 | 48 | ||
49 | const QString getDevice() {return device;}; | 49 | const QString getDevice() {return device;}; |
50 | void setDevice(const QString dev) {device = dev;}; | 50 | void setDevice(const QString dev) {device = dev;}; |
51 | 51 | ||
52 | bool opentty(); | 52 | bool opentty(); |
53 | bool closetty(); | 53 | bool closetty(); |
54 | bool hangup(); | 54 | bool hangup(); |
55 | bool writeChar(unsigned char); | 55 | bool writeChar(unsigned char); |
56 | bool writeLine(const char *); | 56 | bool writeLine(const char *); |
57 | bool dataMode() const { return data_mode; } | 57 | bool dataMode() const { return data_mode; } |
58 | void setDataMode(bool set) { data_mode = set; } | 58 | void setDataMode(bool set) { data_mode = set; } |
59 | const QString modemMessage(); | 59 | const QString modemMessage(); |
60 | speed_t modemspeed(); | 60 | speed_t modemspeed(); |
61 | static QString parseModemSpeed(const QString &); | 61 | static QString parseModemSpeed(const QString &); |
62 | void notify(const QObject *, const char *); | 62 | void notify(const QObject *, const char *); |
63 | void stop(); | 63 | void stop(); |
64 | void flush(); | 64 | void flush(); |
65 | 65 | ||
66 | int lockdevice(); | 66 | int lockdevice(); |
67 | void unlockdevice(); | 67 | void unlockdevice(); |
68 | 68 | ||
69 | bool setSecret(int,const char*,const char*); | 69 | bool setSecret(int,const char*,const char*); |
70 | bool removeSecret(int); | 70 | bool removeSecret(int); |
71 | void killPPPDaemon(); | 71 | void killPPPDaemon(); |
72 | int pppdExitStatus(); | 72 | int pppdExitStatus(); |
73 | bool execPPPDaemon(const QString & arguments); | 73 | bool execPPPDaemon(const QString & arguments); |
74 | int openResolv(int flags); | 74 | int openResolv(int flags); |
75 | bool setHostname(const QString & name); | 75 | bool setHostname(const QString & name); |
76 | 76 | ||
77 | public: | 77 | public: |
78 | enum Auth { PAP = 1, CHAP }; | 78 | enum Auth { PAP = 1, CHAP }; |
79 | static Modem *modem; | 79 | static Modem *modem; |
80 | int lastStatus; | 80 | int lastStatus; |
81 | 81 | ||
82 | signals: | 82 | signals: |
83 | void charWaiting(unsigned char); | 83 | void charWaiting(unsigned char); |
84 | 84 | ||
85 | private slots: | 85 | private slots: |
86 | void startNotifier(); | 86 | void startNotifier(); |
87 | void stopNotifier(); | 87 | void stopNotifier(); |
88 | void readtty(int); | 88 | void readtty(int); |
89 | 89 | ||
90 | private: | 90 | private: |
91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; | 91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; |
92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; | 92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; |
93 | 93 | ||
94 | const char* authFile(Auth method, int version = Original ); | 94 | const char* authFile(Auth method, int version = Original ); |
95 | bool createAuthFile(Auth method,const char *username,const char *password); | 95 | bool createAuthFile(Auth method,const char *username,const char *password); |
96 | bool removeAuthFile(Auth method); | ||
97 | bool execpppd(const char *arguments); | ||
98 | bool killpppd(); | ||
99 | void parseargs(char* buf, char** args); | ||
96 | void escape_to_command_mode(); | 100 | void escape_to_command_mode(); |
97 | int openLockfile(QString,int); | 101 | int openLockfile(QString,int); |
98 | 102 | ||
99 | private: | 103 | private: |
100 | QString device; | 104 | QString device; |
101 | QString lockfile; | 105 | QString lockfile; |
102 | int modemfd; | 106 | int modemfd; |
107 | int pppdPid; | ||
108 | int _pppdExitStatus; | ||
103 | QSocketNotifier *sn; | 109 | QSocketNotifier *sn; |
104 | bool data_mode; | 110 | bool data_mode; |
105 | QString errmsg; | 111 | QString errmsg; |
106 | struct termios initial_tty; | 112 | struct termios initial_tty; |
107 | struct termios tty; | 113 | struct termios tty; |
108 | bool modem_is_locked; | 114 | bool modem_is_locked; |
109 | }; | 115 | }; |
110 | 116 | ||
111 | #endif | 117 | #endif |
112 | 118 | ||
113 | 119 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 646facd..bb1c8ed 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -134,733 +134,733 @@ void PPPData::cancel() { | |||
134 | 134 | ||
135 | 135 | ||
136 | // functions to read/write date to configuration file | 136 | // functions to read/write date to configuration file |
137 | QString PPPData::readConfig(const QString &group, const QString &key, | 137 | QString PPPData::readConfig(const QString &group, const QString &key, |
138 | const QString &defvalue = "") | 138 | const QString &defvalue = "") |
139 | { | 139 | { |
140 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 140 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
141 | if (config) { | 141 | if (config) { |
142 | config->setGroup(group); | 142 | config->setGroup(group); |
143 | return config->readEntry(key, defvalue); | 143 | return config->readEntry(key, defvalue); |
144 | } else | 144 | } else |
145 | return defvalue; | 145 | return defvalue; |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | int PPPData::readNumConfig(const QString &group, const QString &key, | 149 | int PPPData::readNumConfig(const QString &group, const QString &key, |
150 | int defvalue) { | 150 | int defvalue) { |
151 | if (config) { | 151 | if (config) { |
152 | config->setGroup(group); | 152 | config->setGroup(group); |
153 | return config->readNumEntry(key, defvalue); | 153 | return config->readNumEntry(key, defvalue); |
154 | } else | 154 | } else |
155 | return defvalue; | 155 | return defvalue; |
156 | 156 | ||
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | bool PPPData::readListConfig(const QString &group, const QString &key, | 160 | bool PPPData::readListConfig(const QString &group, const QString &key, |
161 | QStringList &list, char sep) { | 161 | QStringList &list, char sep) { |
162 | list.clear(); | 162 | list.clear(); |
163 | if (config) { | 163 | if (config) { |
164 | config->setGroup(group); | 164 | config->setGroup(group); |
165 | list = config->readListEntry(key, sep); | 165 | list = config->readListEntry(key, sep); |
166 | return true; | 166 | return true; |
167 | } else | 167 | } else |
168 | return false; | 168 | return false; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void PPPData::writeConfig(const QString &group, const QString &key, | 172 | void PPPData::writeConfig(const QString &group, const QString &key, |
173 | const QString &value) { | 173 | const QString &value) { |
174 | if (config) { | 174 | if (config) { |
175 | config->setGroup(group); | 175 | config->setGroup(group); |
176 | config->writeEntry(key, value); | 176 | config->writeEntry(key, value); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | void PPPData::writeConfig(const QString &group, const QString &key, int value) { | 181 | void PPPData::writeConfig(const QString &group, const QString &key, int value) { |
182 | if (config) { | 182 | if (config) { |
183 | config->setGroup(group); | 183 | config->setGroup(group); |
184 | config->writeEntry(key, value); | 184 | config->writeEntry(key, value); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | void PPPData::writeListConfig(const QString &group, const QString &key, | 189 | void PPPData::writeListConfig(const QString &group, const QString &key, |
190 | QStringList &list, char sep) { | 190 | QStringList &list, char sep) { |
191 | if (config) { | 191 | if (config) { |
192 | config->setGroup(group); | 192 | config->setGroup(group); |
193 | config->writeEntry(key, list, sep); | 193 | config->writeEntry(key, list, sep); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | // | 198 | // |
199 | // functions to set/return general information | 199 | // functions to set/return general information |
200 | // | 200 | // |
201 | QString PPPData::password() const { | 201 | QString PPPData::password() const { |
202 | return passwd; | 202 | return passwd; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void PPPData::setPassword(const QString &pw) { | 206 | void PPPData::setPassword(const QString &pw) { |
207 | passwd = pw; | 207 | passwd = pw; |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | const QString PPPData::defaultAccount() { | 211 | const QString PPPData::defaultAccount() { |
212 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | 212 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void PPPData::setDefaultAccount(const QString &n) { | 216 | void PPPData::setDefaultAccount(const QString &n) { |
217 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | 217 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); |
218 | 218 | ||
219 | //now set the current account index to the default account | 219 | //now set the current account index to the default account |
220 | setAccount(defaultAccount()); | 220 | setAccount(defaultAccount()); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | bool PPPData::get_show_clock_on_caption() { | 224 | bool PPPData::get_show_clock_on_caption() { |
225 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | 225 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void PPPData::set_show_clock_on_caption(bool set) { | 229 | void PPPData::set_show_clock_on_caption(bool set) { |
230 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 230 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | bool PPPData::get_xserver_exit_disconnect() { | 234 | bool PPPData::get_xserver_exit_disconnect() { |
235 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 235 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void PPPData::setPPPDebug(bool set) { | 239 | void PPPData::setPPPDebug(bool set) { |
240 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 240 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | bool PPPData::getPPPDebug() { | 244 | bool PPPData::getPPPDebug() { |
245 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 245 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | void PPPData::set_xserver_exit_disconnect(bool set) { | 249 | void PPPData::set_xserver_exit_disconnect(bool set) { |
250 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 250 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | bool PPPData::quit_on_disconnect() { | 254 | bool PPPData::quit_on_disconnect() { |
255 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 255 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void PPPData::set_quit_on_disconnect(bool set) { | 259 | void PPPData::set_quit_on_disconnect(bool set) { |
260 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 260 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | bool PPPData::get_show_log_window() { | 264 | bool PPPData::get_show_log_window() { |
265 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 265 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void PPPData::set_show_log_window(bool set) { | 269 | void PPPData::set_show_log_window(bool set) { |
270 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 270 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | bool PPPData::automatic_redial() { | 274 | bool PPPData::automatic_redial() { |
275 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 275 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | void PPPData::set_automatic_redial(bool set) { | 279 | void PPPData::set_automatic_redial(bool set) { |
280 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 280 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | bool PPPData::get_iconify_on_connect() { | 284 | bool PPPData::get_iconify_on_connect() { |
285 | return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 285 | return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void PPPData::set_iconify_on_connect(bool set) { | 289 | void PPPData::set_iconify_on_connect(bool set) { |
290 | writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 290 | writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | bool PPPData::get_dock_into_panel() { | 294 | bool PPPData::get_dock_into_panel() { |
295 | return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 295 | return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void PPPData::set_dock_into_panel(bool set) { | 299 | void PPPData::set_dock_into_panel(bool set) { |
300 | writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 300 | writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | QString PPPData::pppdVersion() { | 304 | QString PPPData::pppdVersion() { |
305 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 305 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
306 | } | 306 | } |
307 | 307 | ||
308 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 308 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
309 | // check if pppd version fulfills minimum requirement | 309 | // check if pppd version fulfills minimum requirement |
310 | return (pppdVer > ver | 310 | return (pppdVer > ver |
311 | || (pppdVer == ver && pppdMod > mod) | 311 | || (pppdVer == ver && pppdMod > mod) |
312 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 312 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
313 | } | 313 | } |
314 | 314 | ||
315 | int PPPData::pppdTimeout() { | 315 | int PPPData::pppdTimeout() { |
316 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 316 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | void PPPData::setpppdTimeout(int n) { | 320 | void PPPData::setpppdTimeout(int n) { |
321 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 321 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | const QString PPPData::modemDevice() { | 325 | const QString PPPData::modemDevice() { |
326 | return readConfig (MODEM_GRP, MODEMDEV_KEY, devices[DEV_DEFAULT]); | 326 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void PPPData::setModemDevice(const QString &n) { | 330 | void PPPData::setModemDevice(const QString &n) { |
331 | writeConfig(MODEM_GRP, MODEMDEV_KEY, n); | 331 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | const QString PPPData::flowcontrol() { | 335 | const QString PPPData::flowcontrol() { |
336 | return readConfig(MODEM_GRP, FLOWCONTROL_KEY, "CRTSCTS"); | 336 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void PPPData::setFlowcontrol(const QString &n) { | 340 | void PPPData::setFlowcontrol(const QString &n) { |
341 | writeConfig(MODEM_GRP, FLOWCONTROL_KEY, n); | 341 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | const QString PPPData::speed() { | 345 | const QString PPPData::speed() { |
346 | QString s = readConfig(MODEM_GRP, SPEED_KEY, "57600"); | 346 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
347 | // undo the damage of a bug in former versions. It left an empty Speed= | 347 | // undo the damage of a bug in former versions. It left an empty Speed= |
348 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 348 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
349 | // pppd wouldn't receive the speed via the command line. | 349 | // pppd wouldn't receive the speed via the command line. |
350 | if(s.toUInt() == 0) | 350 | if(s.toUInt() == 0) |
351 | s = "57600"; | 351 | s = "57600"; |
352 | return s; | 352 | return s; |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | void PPPData::setSpeed(const QString &n) { | 356 | void PPPData::setSpeed(const QString &n) { |
357 | writeConfig(MODEM_GRP, SPEED_KEY, n); | 357 | writeConfig(modemGroup(), SPEED_KEY, n); |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
361 | #if 0 | 361 | #if 0 |
362 | void PPPData::setUseCDLine(const int n) { | 362 | void PPPData::setUseCDLine(const int n) { |
363 | writeConfig(MODEM_GRP,USECDLINE_KEY,n); | 363 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
364 | } | 364 | } |
365 | 365 | ||
366 | 366 | ||
367 | int PPPData::UseCDLine() { | 367 | int PPPData::UseCDLine() { |
368 | return readNumConfig(MODEM_GRP,USECDLINE_KEY,0); | 368 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
369 | } | 369 | } |
370 | #endif | 370 | #endif |
371 | 371 | ||
372 | const QString PPPData::modemEscapeStr() { | 372 | const QString PPPData::modemEscapeStr() { |
373 | return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++"); | 373 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | void PPPData::setModemEscapeStr(const QString &n) { | 377 | void PPPData::setModemEscapeStr(const QString &n) { |
378 | writeConfig(MODEM_GRP,ESCAPESTR_KEY,n); | 378 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | const QString PPPData::modemEscapeResp() { | 382 | const QString PPPData::modemEscapeResp() { |
383 | return readConfig(MODEM_GRP,ESCAPERESP_KEY,"OK"); | 383 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | void PPPData::setModemEscapeResp(const QString &n) { | 387 | void PPPData::setModemEscapeResp(const QString &n) { |
388 | writeConfig(MODEM_GRP,ESCAPERESP_KEY,n); | 388 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | int PPPData::modemEscapeGuardTime() { | 392 | int PPPData::modemEscapeGuardTime() { |
393 | return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50); | 393 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | void PPPData::setModemEscapeGuardTime(int n) { | 397 | void PPPData::setModemEscapeGuardTime(int n) { |
398 | writeConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,n); | 398 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | bool PPPData::modemLockFile() { | 402 | bool PPPData::modemLockFile() { |
403 | return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1); | 403 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void PPPData::setModemLockFile(bool set) { | 407 | void PPPData::setModemLockFile(bool set) { |
408 | writeConfig(MODEM_GRP, LOCKFILE_KEY, set); | 408 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | int PPPData::modemTimeout() { | 412 | int PPPData::modemTimeout() { |
413 | return readNumConfig(MODEM_GRP, TIMEOUT_KEY, MODEM_TIMEOUT); | 413 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PPPData::setModemTimeout(int n) { | 417 | void PPPData::setModemTimeout(int n) { |
418 | writeConfig(MODEM_GRP, TIMEOUT_KEY, n); | 418 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | int PPPData::modemToneDuration() { | 422 | int PPPData::modemToneDuration() { |
423 | return readNumConfig(MODEM_GRP, TONEDURATION_KEY,MODEM_TONEDURATION); | 423 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | void PPPData::setModemToneDuration(int n) { | 427 | void PPPData::setModemToneDuration(int n) { |
428 | writeConfig(MODEM_GRP, TONEDURATION_KEY, n); | 428 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | int PPPData::busyWait() { | 432 | int PPPData::busyWait() { |
433 | return readNumConfig(MODEM_GRP, BUSYWAIT_KEY, BUSY_WAIT); | 433 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void PPPData::setbusyWait(int n) { | 437 | void PPPData::setbusyWait(int n) { |
438 | writeConfig(MODEM_GRP, BUSYWAIT_KEY, n); | 438 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | // | 442 | // |
443 | //Advanced "Modem" dialog | 443 | //Advanced "Modem" dialog |
444 | // | 444 | // |
445 | // defaults: InitString=ATZ, InitString1="" etc. | 445 | // defaults: InitString=ATZ, InitString1="" etc. |
446 | const QString PPPData::modemInitStr(int i) { | 446 | const QString PPPData::modemInitStr(int i) { |
447 | assert(i >= 0 && i < NumInitStrings); | 447 | assert(i >= 0 && i < NumInitStrings); |
448 | if(i == 0) | 448 | if(i == 0) |
449 | return readConfig(MODEM_GRP, INITSTR_KEY, "ATZ"); | 449 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); |
450 | else | 450 | else |
451 | return readConfig(MODEM_GRP, INITSTR_KEY + QString::number(i), ""); | 451 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PPPData::setModemInitStr(int i, const QString &n) { | 455 | void PPPData::setModemInitStr(int i, const QString &n) { |
456 | assert(i >= 0 && i < NumInitStrings); | 456 | assert(i >= 0 && i < NumInitStrings); |
457 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | 457 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); |
458 | writeConfig(MODEM_GRP, k, n); | 458 | writeConfig(modemGroup(), k, n); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | const QString PPPData::modemInitResp() { | 462 | const QString PPPData::modemInitResp() { |
463 | return readConfig(MODEM_GRP, INITRESP_KEY, "OK"); | 463 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PPPData::setModemInitResp(const QString &n) { | 467 | void PPPData::setModemInitResp(const QString &n) { |
468 | writeConfig(MODEM_GRP, INITRESP_KEY, n); | 468 | writeConfig(modemGroup(), INITRESP_KEY, n); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | int PPPData::modemPreInitDelay() { | 472 | int PPPData::modemPreInitDelay() { |
473 | return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50); | 473 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
477 | void PPPData::setModemPreInitDelay(int n) { | 477 | void PPPData::setModemPreInitDelay(int n) { |
478 | writeConfig(MODEM_GRP, PREINITDELAY_KEY, n); | 478 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | int PPPData::modemInitDelay() { | 482 | int PPPData::modemInitDelay() { |
483 | return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50); | 483 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | void PPPData::setModemInitDelay(int n) { | 487 | void PPPData::setModemInitDelay(int n) { |
488 | writeConfig(MODEM_GRP, INITDELAY_KEY, n); | 488 | writeConfig(modemGroup(), INITDELAY_KEY, n); |
489 | } | 489 | } |
490 | 490 | ||
491 | QString PPPData::modemNoDialToneDetectionStr() { | 491 | QString PPPData::modemNoDialToneDetectionStr() { |
492 | return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3"); | 492 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); |
493 | } | 493 | } |
494 | 494 | ||
495 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | 495 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { |
496 | writeConfig(MODEM_GRP, NODTDETECT_KEY, n); | 496 | writeConfig(modemGroup(), NODTDETECT_KEY, n); |
497 | } | 497 | } |
498 | 498 | ||
499 | const QString PPPData::modemDialStr() { | 499 | const QString PPPData::modemDialStr() { |
500 | return readConfig(MODEM_GRP, DIALSTR_KEY, "ATDT"); | 500 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void PPPData::setModemDialStr(const QString &n) { | 504 | void PPPData::setModemDialStr(const QString &n) { |
505 | writeConfig(MODEM_GRP, DIALSTR_KEY, n); | 505 | writeConfig(modemGroup(), DIALSTR_KEY, n); |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | const QString PPPData::modemConnectResp() { | 509 | const QString PPPData::modemConnectResp() { |
510 | return readConfig(MODEM_GRP, CONNECTRESP_KEY, "CONNECT"); | 510 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); |
511 | } | 511 | } |
512 | 512 | ||
513 | 513 | ||
514 | void PPPData::setModemConnectResp(const QString &n) { | 514 | void PPPData::setModemConnectResp(const QString &n) { |
515 | writeConfig(MODEM_GRP, CONNECTRESP_KEY, n); | 515 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); |
516 | } | 516 | } |
517 | 517 | ||
518 | 518 | ||
519 | const QString PPPData::modemBusyResp() { | 519 | const QString PPPData::modemBusyResp() { |
520 | return readConfig(MODEM_GRP, BUSYRESP_KEY, "BUSY"); | 520 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); |
521 | } | 521 | } |
522 | 522 | ||
523 | 523 | ||
524 | void PPPData::setModemBusyResp(const QString &n) { | 524 | void PPPData::setModemBusyResp(const QString &n) { |
525 | writeConfig(MODEM_GRP, BUSYRESP_KEY, n); | 525 | writeConfig(modemGroup(), BUSYRESP_KEY, n); |
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | const QString PPPData::modemNoCarrierResp() { | 529 | const QString PPPData::modemNoCarrierResp() { |
530 | return readConfig(MODEM_GRP, NOCARRIERRESP_KEY, "NO CARRIER"); | 530 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | void PPPData::setModemNoCarrierResp(const QString &n) { | 534 | void PPPData::setModemNoCarrierResp(const QString &n) { |
535 | writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n); | 535 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | const QString PPPData::modemNoDialtoneResp() { | 539 | const QString PPPData::modemNoDialtoneResp() { |
540 | return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE"); | 540 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); |
541 | } | 541 | } |
542 | 542 | ||
543 | 543 | ||
544 | void PPPData::setModemNoDialtoneResp(const QString &n) { | 544 | void PPPData::setModemNoDialtoneResp(const QString &n) { |
545 | writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n); | 545 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); |
546 | } | 546 | } |
547 | 547 | ||
548 | 548 | ||
549 | const QString PPPData::modemHangupStr() { | 549 | const QString PPPData::modemHangupStr() { |
550 | return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH"); | 550 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); |
551 | } | 551 | } |
552 | 552 | ||
553 | void PPPData::setModemHangupStr(const QString &n) { | 553 | void PPPData::setModemHangupStr(const QString &n) { |
554 | writeConfig(MODEM_GRP, HANGUPSTR_KEY, n); | 554 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | const QString PPPData::modemHangupResp() { | 558 | const QString PPPData::modemHangupResp() { |
559 | return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK"); | 559 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); |
560 | } | 560 | } |
561 | 561 | ||
562 | void PPPData::setModemHangupResp(const QString &n) { | 562 | void PPPData::setModemHangupResp(const QString &n) { |
563 | writeConfig(MODEM_GRP, HANGUPRESP_KEY, n); | 563 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); |
564 | } | 564 | } |
565 | 565 | ||
566 | 566 | ||
567 | const QString PPPData::modemAnswerStr() { | 567 | const QString PPPData::modemAnswerStr() { |
568 | return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA"); | 568 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); |
569 | } | 569 | } |
570 | 570 | ||
571 | 571 | ||
572 | QString PPPData::volumeOff() { | 572 | QString PPPData::volumeOff() { |
573 | return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0"); | 573 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
574 | } | 574 | } |
575 | 575 | ||
576 | 576 | ||
577 | void PPPData::setVolumeOff(const QString &s) { | 577 | void PPPData::setVolumeOff(const QString &s) { |
578 | writeConfig(MODEM_GRP, VOLUME_OFF, s); | 578 | writeConfig(modemGroup(), VOLUME_OFF, s); |
579 | } | 579 | } |
580 | 580 | ||
581 | 581 | ||
582 | QString PPPData::volumeMedium() { | 582 | QString PPPData::volumeMedium() { |
583 | return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1"); | 583 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
584 | } | 584 | } |
585 | 585 | ||
586 | 586 | ||
587 | void PPPData::setVolumeMedium(const QString &s) { | 587 | void PPPData::setVolumeMedium(const QString &s) { |
588 | writeConfig(MODEM_GRP, VOLUME_MEDIUM, s); | 588 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | QString PPPData::volumeHigh() { | 592 | QString PPPData::volumeHigh() { |
593 | QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3"); | 593 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
594 | if(tmp == "M1L4") | 594 | if(tmp == "M1L4") |
595 | tmp = "M1L3"; | 595 | tmp = "M1L3"; |
596 | return tmp; | 596 | return tmp; |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | void PPPData::setVolumeHigh(const QString &s) { | 600 | void PPPData::setVolumeHigh(const QString &s) { |
601 | writeConfig(MODEM_GRP, VOLUME_HIGH, s); | 601 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
602 | } | 602 | } |
603 | 603 | ||
604 | 604 | ||
605 | QString PPPData::volumeInitString() { | 605 | QString PPPData::volumeInitString() { |
606 | QString s; | 606 | QString s; |
607 | 607 | ||
608 | switch(volume()) { | 608 | switch(volume()) { |
609 | case 0: | 609 | case 0: |
610 | s = volumeOff(); | 610 | s = volumeOff(); |
611 | break; | 611 | break; |
612 | case 1: | 612 | case 1: |
613 | s = volumeMedium(); | 613 | s = volumeMedium(); |
614 | break; | 614 | break; |
615 | case 2: | 615 | case 2: |
616 | s = volumeHigh(); | 616 | s = volumeHigh(); |
617 | break; | 617 | break; |
618 | default: | 618 | default: |
619 | s = volumeMedium(); | 619 | s = volumeMedium(); |
620 | } | 620 | } |
621 | 621 | ||
622 | return s; | 622 | return s; |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | int PPPData::volume() { | 626 | int PPPData::volume() { |
627 | return readNumConfig(MODEM_GRP, VOLUME_KEY, 1); | 627 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
631 | void PPPData::setVolume(int i) { | 631 | void PPPData::setVolume(int i) { |
632 | writeConfig(MODEM_GRP, VOLUME_KEY, i); | 632 | writeConfig(modemGroup(), VOLUME_KEY, i); |
633 | } | 633 | } |
634 | 634 | ||
635 | int PPPData::waitForDialTone() { | 635 | int PPPData::waitForDialTone() { |
636 | return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); | 636 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
637 | } | 637 | } |
638 | 638 | ||
639 | void PPPData::setWaitForDialTone(int i) { | 639 | void PPPData::setWaitForDialTone(int i) { |
640 | writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i); | 640 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
641 | } | 641 | } |
642 | 642 | ||
643 | void PPPData::setModemAnswerStr(const QString &n) { | 643 | void PPPData::setModemAnswerStr(const QString &n) { |
644 | writeConfig(MODEM_GRP, ANSWERSTR_KEY, n); | 644 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | const QString PPPData::modemRingResp() { | 648 | const QString PPPData::modemRingResp() { |
649 | return readConfig(MODEM_GRP, RINGRESP_KEY, "RING"); | 649 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void PPPData::setModemRingResp(const QString &n) { | 653 | void PPPData::setModemRingResp(const QString &n) { |
654 | writeConfig(MODEM_GRP, RINGRESP_KEY, n); | 654 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
655 | } | 655 | } |
656 | 656 | ||
657 | 657 | ||
658 | const QString PPPData::modemAnswerResp() { | 658 | const QString PPPData::modemAnswerResp() { |
659 | return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT"); | 659 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
660 | } | 660 | } |
661 | 661 | ||
662 | 662 | ||
663 | void PPPData::setModemAnswerResp(const QString &n) { | 663 | void PPPData::setModemAnswerResp(const QString &n) { |
664 | writeConfig(MODEM_GRP, ANSWERRESP_KEY, n); | 664 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
665 | } | 665 | } |
666 | 666 | ||
667 | 667 | ||
668 | const QString PPPData::enter() { | 668 | const QString PPPData::enter() { |
669 | return readConfig(MODEM_GRP, ENTER_KEY, "CR"); | 669 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
670 | } | 670 | } |
671 | 671 | ||
672 | 672 | ||
673 | void PPPData::setEnter(const QString &n) { | 673 | void PPPData::setEnter(const QString &n) { |
674 | writeConfig(MODEM_GRP, ENTER_KEY, n); | 674 | writeConfig(modemGroup(), ENTER_KEY, n); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | // | 678 | // |
679 | // functions to set/return account information | 679 | // functions to set/return account information |
680 | // | 680 | // |
681 | 681 | ||
682 | //returns number of accounts | 682 | //returns number of accounts |
683 | int PPPData::count() const { | 683 | int PPPData::count() const { |
684 | return highcount + 1; | 684 | return highcount + 1; |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | bool PPPData::setAccount(const QString &aname) { | 688 | bool PPPData::setAccount(const QString &aname) { |
689 | for(int i = 0; i <= highcount; i++) { | 689 | for(int i = 0; i <= highcount; i++) { |
690 | setAccountbyIndex(i); | 690 | setAccountbyIndex(i); |
691 | if(accname() == aname) { | 691 | if(accname() == aname) { |
692 | caccount = i; | 692 | caccount = i; |
693 | return true; | 693 | return true; |
694 | } | 694 | } |
695 | } | 695 | } |
696 | return false; | 696 | return false; |
697 | } | 697 | } |
698 | 698 | ||
699 | 699 | ||
700 | bool PPPData::setAccountbyIndex(int i) { | 700 | bool PPPData::setAccountbyIndex(int i) { |
701 | if(i >= 0 && i <= highcount) { | 701 | if(i >= 0 && i <= highcount) { |
702 | caccount = i; | 702 | caccount = i; |
703 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 703 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
704 | return true; | 704 | return true; |
705 | } | 705 | } |
706 | return false; | 706 | return false; |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | bool PPPData::isUniqueAccname(const QString &n) { | 710 | bool PPPData::isUniqueAccname(const QString &n) { |
711 | int current = caccount; | 711 | int current = caccount; |
712 | for(int i=0; i <= highcount; i++) { | 712 | for(int i=0; i <= highcount; i++) { |
713 | setAccountbyIndex(i); | 713 | setAccountbyIndex(i); |
714 | if(accname() == n && i != current) { | 714 | if(accname() == n && i != current) { |
715 | setAccountbyIndex(current); | 715 | setAccountbyIndex(current); |
716 | return false; | 716 | return false; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | setAccountbyIndex(current); | 719 | setAccountbyIndex(current); |
720 | return true; | 720 | return true; |
721 | } | 721 | } |
722 | 722 | ||
723 | 723 | ||
724 | bool PPPData::deleteAccount() { | 724 | bool PPPData::deleteAccount() { |
725 | //FIXME: | 725 | //FIXME: |
726 | // if(caccount < 0) | 726 | // if(caccount < 0) |
727 | return false; | 727 | return false; |
728 | 728 | ||
729 | // QMap <QString, QString> map; | 729 | // QMap <QString, QString> map; |
730 | // QMap <QString, QString>::Iterator it; | 730 | // QMap <QString, QString>::Iterator it; |
731 | 731 | ||
732 | // // set all entries of the current account to "" | 732 | // // set all entries of the current account to "" |
733 | // map = config->entryMap(cgroup); | 733 | // map = config->entryMap(cgroup); |
734 | // it = map.begin(); | 734 | // it = map.begin(); |
735 | // while (it != map.end()) { | 735 | // while (it != map.end()) { |
736 | // config->writeEntry(it.key(), ""); | 736 | // config->writeEntry(it.key(), ""); |
737 | // it++; | 737 | // it++; |
738 | // } | 738 | // } |
739 | 739 | ||
740 | // // shift the succeeding accounts | 740 | // // shift the succeeding accounts |
741 | // for(int i = caccount+1; i <= highcount; i++) { | 741 | // for(int i = caccount+1; i <= highcount; i++) { |
742 | // setAccountbyIndex(i); | 742 | // setAccountbyIndex(i); |
743 | // map = config->entryMap(cgroup); | 743 | // map = config->entryMap(cgroup); |
744 | // it = map.begin(); | 744 | // it = map.begin(); |
745 | // setAccountbyIndex(i-1); | 745 | // setAccountbyIndex(i-1); |
746 | // config->setGroup(cgroup); | 746 | // config->setGroup(cgroup); |
747 | // while (it != map.end()) { | 747 | // while (it != map.end()) { |
748 | // config->writeEntry(it.key(), *it); | 748 | // config->writeEntry(it.key(), *it); |
749 | // it++; | 749 | // it++; |
750 | // } | 750 | // } |
751 | // } | 751 | // } |
752 | 752 | ||
753 | // // make sure the top account is cleared | 753 | // // make sure the top account is cleared |
754 | // setAccountbyIndex(highcount); | 754 | // setAccountbyIndex(highcount); |
755 | // map = config->entryMap(cgroup); | 755 | // map = config->entryMap(cgroup); |
756 | // it = map.begin(); | 756 | // it = map.begin(); |
757 | // config->setGroup(cgroup); | 757 | // config->setGroup(cgroup); |
758 | // while (it.key() != QString::null) { | 758 | // while (it.key() != QString::null) { |
759 | // config->writeEntry(it.key(), ""); | 759 | // config->writeEntry(it.key(), ""); |
760 | // it++; | 760 | // it++; |
761 | // } | 761 | // } |
762 | 762 | ||
763 | // highcount--; | 763 | // highcount--; |
764 | // if(caccount > highcount) | 764 | // if(caccount > highcount) |
765 | // caccount = highcount; | 765 | // caccount = highcount; |
766 | 766 | ||
767 | // setAccountbyIndex(caccount); | 767 | // setAccountbyIndex(caccount); |
768 | 768 | ||
769 | // return true; | 769 | // return true; |
770 | } | 770 | } |
771 | 771 | ||
772 | 772 | ||
773 | bool PPPData::deleteAccount(const QString &aname) { | 773 | bool PPPData::deleteAccount(const QString &aname) { |
774 | if(!setAccount(aname)) | 774 | if(!setAccount(aname)) |
775 | return false; | 775 | return false; |
776 | 776 | ||
777 | deleteAccount(); | 777 | deleteAccount(); |
778 | 778 | ||
779 | return true; | 779 | return true; |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | int PPPData::newaccount() { | 783 | int PPPData::newaccount() { |
784 | 784 | ||
785 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 785 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
786 | if(!config) open(); | 786 | if(!config) open(); |
787 | if (highcount >= MAX_ACCOUNTS) return -1; | 787 | if (highcount >= MAX_ACCOUNTS) return -1; |
788 | 788 | ||
789 | highcount++; | 789 | highcount++; |
790 | setAccountbyIndex(highcount); | 790 | setAccountbyIndex(highcount); |
791 | 791 | ||
792 | setpppdArgumentDefaults(); | 792 | setpppdArgumentDefaults(); |
793 | qDebug("PPPData::newaccount -> %i",caccount); | 793 | qDebug("PPPData::newaccount -> %i",caccount); |
794 | return caccount; | 794 | return caccount; |
795 | } | 795 | } |
796 | 796 | ||
797 | int PPPData::copyaccount(int i) { | 797 | int PPPData::copyaccount(int i) { |
798 | 798 | ||
799 | // if(highcount >= MAX_ACCOUNTS) | 799 | // if(highcount >= MAX_ACCOUNTS) |
800 | return -1; | 800 | return -1; |
801 | 801 | ||
802 | // setAccountbyIndex(i); | 802 | // setAccountbyIndex(i); |
803 | 803 | ||
804 | // QMap <QString, QString> map = config->entryMap(cgroup); | 804 | // QMap <QString, QString> map = config->entryMap(cgroup); |
805 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 805 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
806 | 806 | ||
807 | // QString newname = i18n("%1_copy").arg(accname()); | 807 | // QString newname = i18n("%1_copy").arg(accname()); |
808 | 808 | ||
809 | // newaccount(); | 809 | // newaccount(); |
810 | 810 | ||
811 | // while (it != map.end()) { | 811 | // while (it != map.end()) { |
812 | // config->writeEntry(it.key(), *it); | 812 | // config->writeEntry(it.key(), *it); |
813 | // it++; | 813 | // it++; |
814 | // } | 814 | // } |
815 | 815 | ||
816 | // setAccname(newname); | 816 | // setAccname(newname); |
817 | 817 | ||
818 | // return caccount; | 818 | // return caccount; |
819 | } | 819 | } |
820 | 820 | ||
821 | 821 | ||
822 | const QString PPPData::accname() { | 822 | const QString PPPData::accname() { |
823 | return readConfig(cgroup, NAME_KEY); | 823 | return readConfig(cgroup, NAME_KEY); |
824 | } | 824 | } |
825 | 825 | ||
826 | void PPPData::setAccname(const QString &n) { | 826 | void PPPData::setAccname(const QString &n) { |
827 | if(!cgroup.isNull()) { | 827 | if(!cgroup.isNull()) { |
828 | // are we manipulating the default account's name ? then change it, too. | 828 | // are we manipulating the default account's name ? then change it, too. |
829 | bool def = accname() == defaultAccount(); | 829 | bool def = accname() == defaultAccount(); |
830 | writeConfig(cgroup, NAME_KEY, n); | 830 | writeConfig(cgroup, NAME_KEY, n); |
831 | if (def) | 831 | if (def) |
832 | setDefaultAccount(n); | 832 | setDefaultAccount(n); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | 835 | ||
836 | 836 | ||
837 | #define SEPARATOR_CHAR '&' | 837 | #define SEPARATOR_CHAR '&' |
838 | QStringList &PPPData::phonenumbers() { | 838 | QStringList &PPPData::phonenumbers() { |
839 | 839 | ||
840 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 840 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
841 | return phonelist; | 841 | return phonelist; |
842 | 842 | ||
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | const QString PPPData::phonenumber() { | 846 | const QString PPPData::phonenumber() { |
847 | return readConfig(cgroup, PHONENUMBER_KEY); | 847 | return readConfig(cgroup, PHONENUMBER_KEY); |
848 | } | 848 | } |
849 | 849 | ||
850 | 850 | ||
851 | void PPPData::setPhonenumber(const QString &n) { | 851 | void PPPData::setPhonenumber(const QString &n) { |
852 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 852 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
853 | } | 853 | } |
854 | 854 | ||
855 | 855 | ||
856 | const QString PPPData::dialPrefix() { | 856 | const QString PPPData::dialPrefix() { |
857 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 857 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
858 | } | 858 | } |
859 | 859 | ||
860 | 860 | ||
861 | void PPPData::setDialPrefix(const QString &s) { | 861 | void PPPData::setDialPrefix(const QString &s) { |
862 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 862 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
863 | } | 863 | } |
864 | 864 | ||
865 | 865 | ||
866 | int PPPData::authMethod() { | 866 | int PPPData::authMethod() { |
@@ -1020,215 +1020,219 @@ bool PPPData::autoDNS() { | |||
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | 1022 | ||
1023 | void PPPData::setAutoDNS(bool set) { | 1023 | void PPPData::setAutoDNS(bool set) { |
1024 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | 1024 | writeConfig(cgroup, AUTODNS_KEY, (int) set); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | void PPPData::setExDNSDisabled(bool set) { | 1028 | void PPPData::setExDNSDisabled(bool set) { |
1029 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | 1029 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | 1032 | ||
1033 | bool PPPData::exDNSDisabled() { | 1033 | bool PPPData::exDNSDisabled() { |
1034 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | 1034 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | 1037 | ||
1038 | QStringList &PPPData::dns() { | 1038 | QStringList &PPPData::dns() { |
1039 | static QStringList dnslist; | 1039 | static QStringList dnslist; |
1040 | 1040 | ||
1041 | readListConfig(cgroup, DNS_KEY, dnslist); | 1041 | readListConfig(cgroup, DNS_KEY, dnslist); |
1042 | while(dnslist.count() > MAX_DNS_ENTRIES) | 1042 | while(dnslist.count() > MAX_DNS_ENTRIES) |
1043 | dnslist.remove(dnslist.last()); | 1043 | dnslist.remove(dnslist.last()); |
1044 | 1044 | ||
1045 | return dnslist; | 1045 | return dnslist; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | 1048 | ||
1049 | void PPPData::setDns(QStringList &list) { | 1049 | void PPPData::setDns(QStringList &list) { |
1050 | writeListConfig(cgroup, DNS_KEY, list); | 1050 | writeListConfig(cgroup, DNS_KEY, list); |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | 1053 | ||
1054 | const QString PPPData::domain() { | 1054 | const QString PPPData::domain() { |
1055 | return readConfig(cgroup, DOMAIN_KEY); | 1055 | return readConfig(cgroup, DOMAIN_KEY); |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | 1058 | ||
1059 | void PPPData::setDomain(const QString &n ) { | 1059 | void PPPData::setDomain(const QString &n ) { |
1060 | writeConfig(cgroup, DOMAIN_KEY, n); | 1060 | writeConfig(cgroup, DOMAIN_KEY, n); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | 1063 | ||
1064 | QStringList &PPPData::scriptType() { | 1064 | QStringList &PPPData::scriptType() { |
1065 | static QStringList typelist; | 1065 | static QStringList typelist; |
1066 | 1066 | ||
1067 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | 1067 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); |
1068 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | 1068 | while(typelist.count() > MAX_SCRIPT_ENTRIES) |
1069 | typelist.remove(typelist.last()); | 1069 | typelist.remove(typelist.last()); |
1070 | 1070 | ||
1071 | return typelist; | 1071 | return typelist; |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | 1074 | ||
1075 | void PPPData::setScriptType(QStringList &list) { | 1075 | void PPPData::setScriptType(QStringList &list) { |
1076 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | 1076 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | 1079 | ||
1080 | QStringList &PPPData::script() { | 1080 | QStringList &PPPData::script() { |
1081 | static QStringList scriptlist; | 1081 | static QStringList scriptlist; |
1082 | 1082 | ||
1083 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | 1083 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); |
1084 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | 1084 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) |
1085 | scriptlist.remove(scriptlist.last()); | 1085 | scriptlist.remove(scriptlist.last()); |
1086 | 1086 | ||
1087 | return scriptlist; | 1087 | return scriptlist; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | 1090 | ||
1091 | void PPPData::setScript(QStringList &list) { | 1091 | void PPPData::setScript(QStringList &list) { |
1092 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | 1092 | writeListConfig(cgroup, SCRIPTARG_KEY, list); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | const QString PPPData::accountingFile() { | 1096 | const QString PPPData::accountingFile() { |
1097 | return readConfig(cgroup, ACCTFILE_KEY); | 1097 | return readConfig(cgroup, ACCTFILE_KEY); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | 1100 | ||
1101 | void PPPData::setAccountingFile(const QString &n) { | 1101 | void PPPData::setAccountingFile(const QString &n) { |
1102 | writeConfig(cgroup, ACCTFILE_KEY, n); | 1102 | writeConfig(cgroup, ACCTFILE_KEY, n); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | const QString PPPData::totalCosts() { | 1106 | const QString PPPData::totalCosts() { |
1107 | return readConfig(cgroup, TOTALCOSTS_KEY); | 1107 | return readConfig(cgroup, TOTALCOSTS_KEY); |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | void PPPData::setTotalCosts(const QString &n) { | 1111 | void PPPData::setTotalCosts(const QString &n) { |
1112 | writeConfig(cgroup, TOTALCOSTS_KEY, n); | 1112 | writeConfig(cgroup, TOTALCOSTS_KEY, n); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | int PPPData::totalBytes() { | 1116 | int PPPData::totalBytes() { |
1117 | return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | 1117 | return readNumConfig(cgroup, TOTALBYTES_KEY, 0); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void PPPData::setTotalBytes(int n) { | 1120 | void PPPData::setTotalBytes(int n) { |
1121 | writeConfig(cgroup, TOTALBYTES_KEY, n); | 1121 | writeConfig(cgroup, TOTALBYTES_KEY, n); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | 1124 | ||
1125 | QStringList &PPPData::pppdArgument() { | 1125 | QStringList &PPPData::pppdArgument() { |
1126 | static QStringList arglist; | 1126 | static QStringList arglist; |
1127 | 1127 | ||
1128 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1128 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1129 | arglist.remove(arglist.last()); | 1129 | arglist.remove(arglist.last()); |
1130 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1130 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1131 | 1131 | ||
1132 | return arglist; | 1132 | return arglist; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | 1135 | ||
1136 | void PPPData::setpppdArgument(QStringList &args) { | 1136 | void PPPData::setpppdArgument(QStringList &args) { |
1137 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1137 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | 1140 | ||
1141 | void PPPData::setpppdArgumentDefaults() { | 1141 | void PPPData::setpppdArgumentDefaults() { |
1142 | QStringList arg; | 1142 | QStringList arg; |
1143 | setpppdArgument(arg); | 1143 | setpppdArgument(arg); |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | 1146 | ||
1147 | // // graphing widget | 1147 | // // graphing widget |
1148 | // void PPPData::setGraphingOptions(bool enable, | 1148 | // void PPPData::setGraphingOptions(bool enable, |
1149 | // QColor bg, | 1149 | // QColor bg, |
1150 | // QColor text, | 1150 | // QColor text, |
1151 | // QColor in, | 1151 | // QColor in, |
1152 | // QColor out) | 1152 | // QColor out) |
1153 | // { | 1153 | // { |
1154 | // if(config) { | 1154 | // if(config) { |
1155 | // config->setGroup(GRAPH_GRP); | 1155 | // config->setGroup(GRAPH_GRP); |
1156 | // config->writeEntry(GENABLED, enable); | 1156 | // config->writeEntry(GENABLED, enable); |
1157 | // // config->writeEntry(GCOLOR_BG, bg); | 1157 | // // config->writeEntry(GCOLOR_BG, bg); |
1158 | // // config->writeEntry(GCOLOR_TEXT, text); | 1158 | // // config->writeEntry(GCOLOR_TEXT, text); |
1159 | // // config->writeEntry(GCOLOR_IN, in); | 1159 | // // config->writeEntry(GCOLOR_IN, in); |
1160 | // // config->writeEntry(GCOLOR_OUT, out); | 1160 | // // config->writeEntry(GCOLOR_OUT, out); |
1161 | // } | 1161 | // } |
1162 | // } | 1162 | // } |
1163 | 1163 | ||
1164 | // void PPPData::graphingOptions(bool &enable, | 1164 | // void PPPData::graphingOptions(bool &enable, |
1165 | // QColor &bg, | 1165 | // QColor &bg, |
1166 | // QColor &text, | 1166 | // QColor &text, |
1167 | // QColor &in, | 1167 | // QColor &in, |
1168 | // QColor &out) | 1168 | // QColor &out) |
1169 | // { | 1169 | // { |
1170 | // QColor c; | 1170 | // QColor c; |
1171 | 1171 | ||
1172 | // if(config) { | 1172 | // if(config) { |
1173 | // config->setGroup(GRAPH_GRP); | 1173 | // config->setGroup(GRAPH_GRP); |
1174 | // enable = config->readBoolEntry(GENABLED, true); | 1174 | // enable = config->readBoolEntry(GENABLED, true); |
1175 | // bg = Qt::white; | 1175 | // bg = Qt::white; |
1176 | // //bg = config->readColorEntry(GCOLOR_BG, &c); | 1176 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1177 | // text = Qt::black; | 1177 | // text = Qt::black; |
1178 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1178 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1179 | // in = Qt::blue; | 1179 | // in = Qt::blue; |
1180 | // //in = config->readColorEntry(GCOLOR_IN, &c); | 1180 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1181 | // out = Qt::red; | 1181 | // out = Qt::red; |
1182 | // //out = config->readColorEntry(GCOLOR_OUT, &c); | 1182 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1183 | // } | 1183 | // } |
1184 | // } | 1184 | // } |
1185 | 1185 | ||
1186 | 1186 | ||
1187 | // bool PPPData::graphingEnabled() { | 1187 | // bool PPPData::graphingEnabled() { |
1188 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1188 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1189 | // } | 1189 | // } |
1190 | 1190 | ||
1191 | 1191 | ||
1192 | 1192 | ||
1193 | // | 1193 | // |
1194 | //functions to change/set the child pppd process info | 1194 | //functions to change/set the child pppd process info |
1195 | // | 1195 | // |
1196 | bool PPPData::pppdRunning() const { | 1196 | bool PPPData::pppdRunning() const { |
1197 | return pppdisrunning; | 1197 | return pppdisrunning; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | void PPPData::setpppdRunning(bool set) { | 1200 | void PPPData::setpppdRunning(bool set) { |
1201 | pppdisrunning = set; | 1201 | pppdisrunning = set; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | int PPPData::pppdError() const { | 1204 | int PPPData::pppdError() const { |
1205 | return pppderror; | 1205 | return pppderror; |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | void PPPData::setpppdError(int err) { | 1208 | void PPPData::setpppdError(int err) { |
1209 | pppderror = err; | 1209 | pppderror = err; |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | QString PPPData::modemGroup() | ||
1213 | { | ||
1214 | return MODEM_GRP; | ||
1215 | } | ||
1212 | 1216 | ||
1213 | // // | 1217 | // // |
1214 | // // window position | 1218 | // // window position |
1215 | // // | 1219 | // // |
1216 | // void PPPData::winPosConWin(int& p_x, int& p_y) { | 1220 | // void PPPData::winPosConWin(int& p_x, int& p_y) { |
1217 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); | 1221 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); |
1218 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); | 1222 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); |
1219 | // } | 1223 | // } |
1220 | 1224 | ||
1221 | // void PPPData::setWinPosConWin(int p_x, int p_y) { | 1225 | // void PPPData::setWinPosConWin(int p_x, int p_y) { |
1222 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); | 1226 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); |
1223 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); | 1227 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); |
1224 | // } | 1228 | // } |
1225 | 1229 | ||
1226 | // void PPPData::winPosStatWin(int& p_x, int& p_y) { | 1230 | // void PPPData::winPosStatWin(int& p_x, int& p_y) { |
1227 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); | 1231 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); |
1228 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); | 1232 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); |
1229 | // } | 1233 | // } |
1230 | 1234 | ||
1231 | // void PPPData::setWinPosStatWin(int p_x, int p_y) { | 1235 | // void PPPData::setWinPosStatWin(int p_x, int p_y) { |
1232 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); | 1236 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); |
1233 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); | 1237 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); |
1234 | // } | 1238 | // } |
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index 57ce2fd..c4d7bc3 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -1,377 +1,378 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * based on EzPPP: | 10 | * based on EzPPP: |
11 | * Copyright (C) 1997 Jay Painter | 11 | * Copyright (C) 1997 Jay Painter |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or | 13 | * This program is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This program is distributed in the hope that it will be useful, | 18 | * This program is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 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 | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef _PPPDATA_H_ | 28 | #ifndef _PPPDATA_H_ |
29 | #define _PPPDATA_H_ | 29 | #define _PPPDATA_H_ |
30 | 30 | ||
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | 33 | ||
34 | #include <qstring.h> | 34 | #include <qstring.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <qcolor.h> | 36 | #include <qcolor.h> |
37 | 37 | ||
38 | #include "kpppconfig.h" | 38 | #include "kpppconfig.h" |
39 | 39 | ||
40 | class Config; | 40 | class Config; |
41 | 41 | ||
42 | // string lengths | 42 | // string lengths |
43 | 43 | ||
44 | #define PATH_SIZE 120 | 44 | #define PATH_SIZE 120 |
45 | #define MODEMSTR_SIZE 80 | 45 | #define MODEMSTR_SIZE 80 |
46 | #define ACCNAME_SIZE 50 | 46 | #define ACCNAME_SIZE 50 |
47 | #define PHONENUMBER_SIZE 60 | 47 | #define PHONENUMBER_SIZE 60 |
48 | #define COMMAND_SIZE 255 | 48 | #define COMMAND_SIZE 255 |
49 | #define IPADDR_SIZE 15 | 49 | #define IPADDR_SIZE 15 |
50 | #define DOMAIN_SIZE 50 | 50 | #define DOMAIN_SIZE 50 |
51 | #define TIMEOUT_SIZE 60 | 51 | #define TIMEOUT_SIZE 60 |
52 | 52 | ||
53 | // | 53 | // |
54 | // keys for config file | 54 | // keys for config file |
55 | // | 55 | // |
56 | 56 | ||
57 | // groups | 57 | // groups |
58 | #define GENERAL_GRP "PPP_General" | 58 | #define GENERAL_GRP "PPP_General" |
59 | #define MODEM_GRP "PPP_Modem" | 59 | #define MODEM_GRP "PPP_Modem" |
60 | #define ACCOUNT_GRP "PPP_Account" | 60 | #define ACCOUNT_GRP "PPP_Account" |
61 | //#define GRAPH_GRP "Graph" | 61 | //#define GRAPH_GRP "Graph" |
62 | //#define WINPOS_GRP "WindowPosition" | 62 | //#define WINPOS_GRP "WindowPosition" |
63 | 63 | ||
64 | // general | 64 | // general |
65 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | 65 | #define DEFAULTACCOUNT_KEY "DefaultAccount" |
66 | #define PPPDVERSION_KEY "pppdVersion" | 66 | #define PPPDVERSION_KEY "pppdVersion" |
67 | #define PPPDTIMEOUT_KEY "pppdTimeout" | 67 | #define PPPDTIMEOUT_KEY "pppdTimeout" |
68 | #define SHOWCLOCK_KEY "ShowClock" | 68 | #define SHOWCLOCK_KEY "ShowClock" |
69 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 69 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
70 | #define AUTOREDIAL_KEY "AutomaticRedial" | 70 | #define AUTOREDIAL_KEY "AutomaticRedial" |
71 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 71 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
72 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 72 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
73 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | 73 | #define NUMACCOUNTS_KEY "NumberOfAccounts" |
74 | #define ID_KEY "ID" | 74 | #define ID_KEY "ID" |
75 | 75 | ||
76 | // modem | 76 | // modem |
77 | #define MODEMDEV_KEY "Device" | 77 | #define MODEMDEV_KEY "Device" |
78 | #define LOCKFILE_KEY "UseLockFile" | 78 | #define LOCKFILE_KEY "UseLockFile" |
79 | #define FLOWCONTROL_KEY "FlowControl" | 79 | #define FLOWCONTROL_KEY "FlowControl" |
80 | #define SPEED_KEY "Speed" | 80 | #define SPEED_KEY "Speed" |
81 | #define TIMEOUT_KEY "Timeout" | 81 | #define TIMEOUT_KEY "Timeout" |
82 | #define TONEDURATION_KEY "ToneDuration" | 82 | #define TONEDURATION_KEY "ToneDuration" |
83 | #define BUSYWAIT_KEY "BusyWait" | 83 | #define BUSYWAIT_KEY "BusyWait" |
84 | #define INITSTR_KEY "InitString" | 84 | #define INITSTR_KEY "InitString" |
85 | #define INITRESP_KEY "InitResponse" | 85 | #define INITRESP_KEY "InitResponse" |
86 | #define PREINITDELAY_KEY "PreInitDelay" | 86 | #define PREINITDELAY_KEY "PreInitDelay" |
87 | #define INITDELAY_KEY "InitDelay" | 87 | #define INITDELAY_KEY "InitDelay" |
88 | #define NODTDETECT_KEY "NoDialToneDetection" | 88 | #define NODTDETECT_KEY "NoDialToneDetection" |
89 | #define DIALTONEWAIT_KEY "WaitForDialTone" | 89 | #define DIALTONEWAIT_KEY "WaitForDialTone" |
90 | #define DIALSTR_KEY "DialString" | 90 | #define DIALSTR_KEY "DialString" |
91 | #define CONNECTRESP_KEY "ConnectResponse" | 91 | #define CONNECTRESP_KEY "ConnectResponse" |
92 | #define BUSYRESP_KEY "BusyResponse" | 92 | #define BUSYRESP_KEY "BusyResponse" |
93 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | 93 | #define NOCARRIERRESP_KEY "NoCarrierResponse" |
94 | #define NODIALTONERESP_KEY "NoDialToneResp" | 94 | #define NODIALTONERESP_KEY "NoDialToneResp" |
95 | #define HANGUPSTR_KEY "HangupString" | 95 | #define HANGUPSTR_KEY "HangupString" |
96 | #define HANGUPRESP_KEY "HangUpResponse" | 96 | #define HANGUPRESP_KEY "HangUpResponse" |
97 | #define ANSWERSTR_KEY "AnswerString" | 97 | #define ANSWERSTR_KEY "AnswerString" |
98 | #define RINGRESP_KEY "RingResponse" | 98 | #define RINGRESP_KEY "RingResponse" |
99 | #define ANSWERRESP_KEY "AnswerResponse" | 99 | #define ANSWERRESP_KEY "AnswerResponse" |
100 | #define ENTER_KEY "Enter" | 100 | #define ENTER_KEY "Enter" |
101 | #define ESCAPESTR_KEY "EscapeString" | 101 | #define ESCAPESTR_KEY "EscapeString" |
102 | #define ESCAPERESP_KEY "EscapeResponse" | 102 | #define ESCAPERESP_KEY "EscapeResponse" |
103 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | 103 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" |
104 | #define USECDLINE_KEY "UseCDLine" | 104 | #define USECDLINE_KEY "UseCDLine" |
105 | #define VOLUME_HIGH "VolumeHigh" | 105 | #define VOLUME_HIGH "VolumeHigh" |
106 | #define VOLUME_MEDIUM "VolumeMedium" | 106 | #define VOLUME_MEDIUM "VolumeMedium" |
107 | #define VOLUME_OFF "VolumeOff" | 107 | #define VOLUME_OFF "VolumeOff" |
108 | #define VOLUME_KEY "Volume" | 108 | #define VOLUME_KEY "Volume" |
109 | 109 | ||
110 | // account | 110 | // account |
111 | #define NAME_KEY "Name" | 111 | #define NAME_KEY "Name" |
112 | #define PHONENUMBER_KEY "Phonenumber" | 112 | #define PHONENUMBER_KEY "Phonenumber" |
113 | #define DIAL_PREFIX_KEY "DialPrefix" | 113 | #define DIAL_PREFIX_KEY "DialPrefix" |
114 | #define AUTH_KEY "Authentication" | 114 | #define AUTH_KEY "Authentication" |
115 | #define STORED_PASSWORD_KEY "Password" | 115 | #define STORED_PASSWORD_KEY "Password" |
116 | #define STORED_USERNAME_KEY "Username" | 116 | #define STORED_USERNAME_KEY "Username" |
117 | #define STORE_PASSWORD_KEY "StorePassword" | 117 | #define STORE_PASSWORD_KEY "StorePassword" |
118 | #define BEFORE_CONNECT_KEY "BeforeConnect" | 118 | #define BEFORE_CONNECT_KEY "BeforeConnect" |
119 | #define COMMAND_KEY "Command" | 119 | #define COMMAND_KEY "Command" |
120 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | 120 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" |
121 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | 121 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" |
122 | #define IPADDR_KEY "IPAddr" | 122 | #define IPADDR_KEY "IPAddr" |
123 | #define SUBNETMASK_KEY "SubnetMask" | 123 | #define SUBNETMASK_KEY "SubnetMask" |
124 | #define ACCTENABLED_KEY "AccountingEnabled" | 124 | #define ACCTENABLED_KEY "AccountingEnabled" |
125 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | 125 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" |
126 | #define ACCTFILE_KEY "AccountingFile" | 126 | #define ACCTFILE_KEY "AccountingFile" |
127 | #define AUTONAME_KEY "AutoName" | 127 | #define AUTONAME_KEY "AutoName" |
128 | #define GATEWAY_KEY "Gateway" | 128 | #define GATEWAY_KEY "Gateway" |
129 | #define DEFAULTROUTE_KEY "DefaultRoute" | 129 | #define DEFAULTROUTE_KEY "DefaultRoute" |
130 | #define DOMAIN_KEY "Domain" | 130 | #define DOMAIN_KEY "Domain" |
131 | #define DNS_KEY "DNS" | 131 | #define DNS_KEY "DNS" |
132 | #define AUTODNS_KEY "AutoDNS" | 132 | #define AUTODNS_KEY "AutoDNS" |
133 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | 133 | #define EXDNSDISABLED_KEY "ExDNSDisabled" |
134 | #define SCRIPTCOM_KEY "ScriptCommands" | 134 | #define SCRIPTCOM_KEY "ScriptCommands" |
135 | #define SCRIPTARG_KEY "ScriptArguments" | 135 | #define SCRIPTARG_KEY "ScriptArguments" |
136 | #define PPPDARG_KEY "pppdArguments" | 136 | #define PPPDARG_KEY "pppdArguments" |
137 | #define PPP_DEBUG_OPTION "PPPDebug" | 137 | #define PPP_DEBUG_OPTION "PPPDebug" |
138 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | 138 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" |
139 | #define DOCKING_KEY "DockIntoPanel" | 139 | #define DOCKING_KEY "DockIntoPanel" |
140 | #define TOTALCOSTS_KEY "TotalCosts" | 140 | #define TOTALCOSTS_KEY "TotalCosts" |
141 | #define TOTALBYTES_KEY "TotalBytes" | 141 | #define TOTALBYTES_KEY "TotalBytes" |
142 | 142 | ||
143 | // graph colors | 143 | // graph colors |
144 | #define GENABLED "Enabled" | 144 | #define GENABLED "Enabled" |
145 | #define GCOLOR_BG "Background" | 145 | #define GCOLOR_BG "Background" |
146 | #define GCOLOR_TEXT "Text" | 146 | #define GCOLOR_TEXT "Text" |
147 | #define GCOLOR_IN "InBytes" | 147 | #define GCOLOR_IN "InBytes" |
148 | #define GCOLOR_OUT "OutBytes" | 148 | #define GCOLOR_OUT "OutBytes" |
149 | 149 | ||
150 | // pppd errors | 150 | // pppd errors |
151 | #define E_IF_TIMEOUT 1 | 151 | #define E_IF_TIMEOUT 1 |
152 | #define E_PPPD_DIED 2 | 152 | #define E_PPPD_DIED 2 |
153 | 153 | ||
154 | // window position | 154 | // window position |
155 | #define WINPOS_CONWIN_X "WindowPositionConWinX" | 155 | #define WINPOS_CONWIN_X "WindowPositionConWinX" |
156 | #define WINPOS_CONWIN_Y "WindowPositionConWinY" | 156 | #define WINPOS_CONWIN_Y "WindowPositionConWinY" |
157 | #define WINPOS_STATWIN_X "WindowPositionStatWinX" | 157 | #define WINPOS_STATWIN_X "WindowPositionStatWinX" |
158 | #define WINPOS_STATWIN_Y "WindowPositionStatWinY" | 158 | #define WINPOS_STATWIN_Y "WindowPositionStatWinY" |
159 | 159 | ||
160 | class PPPData { | 160 | class PPPData { |
161 | public: | 161 | public: |
162 | PPPData(); | 162 | PPPData(); |
163 | ~PPPData() {}; | 163 | ~PPPData() {}; |
164 | static PPPData* data(); | 164 | static PPPData* data(); |
165 | 165 | ||
166 | enum { NumInitStrings = 2 }; | 166 | enum { NumInitStrings = 2 }; |
167 | 167 | ||
168 | // general functions | 168 | // general functions |
169 | bool open(); | 169 | bool open(); |
170 | void save(); | 170 | void save(); |
171 | void cancel(); | 171 | void cancel(); |
172 | // int access() const; // read/write access | ||
173 | 172 | ||
174 | // function to read/write date to configuration file | 173 | |
175 | QString readConfig(const QString &, const QString &, const QString &); | 174 | // function to read/write date to configuration file |
176 | int readNumConfig(const QString &, const QString &, int); | 175 | QString readConfig(const QString &, const QString &, const QString &); |
177 | bool readListConfig(const QString &, const QString &, | 176 | int readNumConfig(const QString &, const QString &, int); |
177 | bool readListConfig(const QString &, const QString &, | ||
178 | QStringList &, char sep = ','); | 178 | QStringList &, char sep = ','); |
179 | void writeConfig(const QString &, const QString &, const QString &); | 179 | void writeConfig(const QString &, const QString &, const QString &); |
180 | void writeConfig(const QString &, const QString &, int); | 180 | void writeConfig(const QString &, const QString &, int); |
181 | void writeListConfig(const QString &, const QString &, | 181 | void writeListConfig(const QString &, const QString &, |
182 | QStringList &, char sep = ','); | 182 | QStringList &, char sep = ','); |
183 | 183 | ||
184 | // return the current account group | 184 | // return the current account group |
185 | QString currentGroup() { return cgroup; } | 185 | QString currentGroup() { return cgroup; } |
186 | QString modemGroup(); | ||
186 | 187 | ||
187 | // functions to set/get general kppp info | 188 | // functions to set/get general kppp info |
188 | QString password() const; | 189 | QString password() const; |
189 | void setPassword(const QString &); | 190 | void setPassword(const QString &); |
190 | 191 | ||
191 | const QString defaultAccount(); | 192 | const QString defaultAccount(); |
192 | void setDefaultAccount(const QString &); | 193 | void setDefaultAccount(const QString &); |
193 | 194 | ||
194 | void set_xserver_exit_disconnect(bool set); | 195 | void set_xserver_exit_disconnect(bool set); |
195 | bool get_xserver_exit_disconnect(); | 196 | bool get_xserver_exit_disconnect(); |
196 | 197 | ||
197 | void setPPPDebug(bool set); | 198 | void setPPPDebug(bool set); |
198 | bool getPPPDebug(); | 199 | bool getPPPDebug(); |
199 | 200 | ||
200 | void set_quit_on_disconnect(bool); | 201 | void set_quit_on_disconnect(bool); |
201 | bool quit_on_disconnect(); | 202 | bool quit_on_disconnect(); |
202 | 203 | ||
203 | void set_show_clock_on_caption(bool set); | 204 | void set_show_clock_on_caption(bool set); |
204 | bool get_show_clock_on_caption(); | 205 | bool get_show_clock_on_caption(); |
205 | 206 | ||
206 | void set_show_log_window(bool set); | 207 | void set_show_log_window(bool set); |
207 | bool get_show_log_window(); | 208 | bool get_show_log_window(); |
208 | 209 | ||
209 | void set_automatic_redial(bool set); | 210 | void set_automatic_redial(bool set); |
210 | bool automatic_redial(); | 211 | bool automatic_redial(); |
211 | 212 | ||
212 | void set_iconify_on_connect(bool set); | 213 | void set_iconify_on_connect(bool set); |
213 | bool get_iconify_on_connect(); | 214 | bool get_iconify_on_connect(); |
214 | 215 | ||
215 | void set_dock_into_panel(bool set); | 216 | void set_dock_into_panel(bool set); |
216 | bool get_dock_into_panel(); | 217 | bool get_dock_into_panel(); |
217 | 218 | ||
218 | const QString enter(); | 219 | const QString enter(); |
219 | void setEnter(const QString &); | 220 | void setEnter(const QString &); |
220 | 221 | ||
221 | QString pppdVersion(); | 222 | QString pppdVersion(); |
222 | bool pppdVersionMin(int ver, int mod, int patch); | 223 | bool pppdVersionMin(int ver, int mod, int patch); |
223 | 224 | ||
224 | int pppdTimeout(); | 225 | int pppdTimeout(); |
225 | void setpppdTimeout(int); | 226 | void setpppdTimeout(int); |
226 | 227 | ||
227 | int busyWait(); | 228 | int busyWait(); |
228 | void setbusyWait(int); | 229 | void setbusyWait(int); |
229 | 230 | ||
230 | bool modemLockFile(); | 231 | bool modemLockFile(); |
231 | void setModemLockFile(bool set); | 232 | void setModemLockFile(bool set); |
232 | 233 | ||
233 | int modemEscapeGuardTime(); | 234 | int modemEscapeGuardTime(); |
234 | void setModemEscapeGuardTime(int i); | 235 | void setModemEscapeGuardTime(int i); |
235 | 236 | ||
236 | void setModemEscapeStr(const QString &); | 237 | void setModemEscapeStr(const QString &); |
237 | const QString modemEscapeStr(); | 238 | const QString modemEscapeStr(); |
238 | 239 | ||
239 | void setModemEscapeResp(const QString &); | 240 | void setModemEscapeResp(const QString &); |
240 | const QString modemEscapeResp(); | 241 | const QString modemEscapeResp(); |
241 | 242 | ||
242 | const QString modemDevice(); | 243 | const QString modemDevice(); |
243 | void setModemDevice(const QString &); | 244 | void setModemDevice(const QString &); |
244 | 245 | ||
245 | const QString flowcontrol(); | 246 | const QString flowcontrol(); |
246 | void setFlowcontrol(const QString &); | 247 | void setFlowcontrol(const QString &); |
247 | 248 | ||
248 | int modemTimeout(); | 249 | int modemTimeout(); |
249 | void setModemTimeout(int); | 250 | void setModemTimeout(int); |
250 | 251 | ||
251 | int modemToneDuration(); | 252 | int modemToneDuration(); |
252 | void setModemToneDuration(int); | 253 | void setModemToneDuration(int); |
253 | 254 | ||
254 | QString volumeInitString(); | 255 | QString volumeInitString(); |
255 | int volume(); | 256 | int volume(); |
256 | void setVolume(int); | 257 | void setVolume(int); |
257 | 258 | ||
258 | int waitForDialTone(); | 259 | int waitForDialTone(); |
259 | void setWaitForDialTone(int i); | 260 | void setWaitForDialTone(int i); |
260 | 261 | ||
261 | // modem command strings/responses | 262 | // modem command strings/responses |
262 | const QString modemInitStr(int i); | 263 | const QString modemInitStr(int i); |
263 | void setModemInitStr(int i, const QString &); | 264 | void setModemInitStr(int i, const QString &); |
264 | 265 | ||
265 | const QString modemInitResp(); | 266 | const QString modemInitResp(); |
266 | void setModemInitResp(const QString &); | 267 | void setModemInitResp(const QString &); |
267 | 268 | ||
268 | int modemPreInitDelay(); | 269 | int modemPreInitDelay(); |
269 | void setModemPreInitDelay(int); | 270 | void setModemPreInitDelay(int); |
270 | 271 | ||
271 | int modemInitDelay(); | 272 | int modemInitDelay(); |
272 | void setModemInitDelay(int); | 273 | void setModemInitDelay(int); |
273 | 274 | ||
274 | QString modemNoDialToneDetectionStr(); | 275 | QString modemNoDialToneDetectionStr(); |
275 | void setModemNoDialToneDetectionStr(const QString &); | 276 | void setModemNoDialToneDetectionStr(const QString &); |
276 | 277 | ||
277 | const QString modemDialStr(); | 278 | const QString modemDialStr(); |
278 | void setModemDialStr(const QString &); | 279 | void setModemDialStr(const QString &); |
279 | 280 | ||
280 | const QString modemConnectResp(); | 281 | const QString modemConnectResp(); |
281 | void setModemConnectResp(const QString &); | 282 | void setModemConnectResp(const QString &); |
282 | 283 | ||
283 | const QString modemBusyResp(); | 284 | const QString modemBusyResp(); |
284 | void setModemBusyResp(const QString &); | 285 | void setModemBusyResp(const QString &); |
285 | 286 | ||
286 | const QString modemNoCarrierResp(); | 287 | const QString modemNoCarrierResp(); |
287 | void setModemNoCarrierResp(const QString &); | 288 | void setModemNoCarrierResp(const QString &); |
288 | 289 | ||
289 | const QString modemNoDialtoneResp(); | 290 | const QString modemNoDialtoneResp(); |
290 | void setModemNoDialtoneResp(const QString &); | 291 | void setModemNoDialtoneResp(const QString &); |
291 | 292 | ||
292 | const QString modemHangupStr(); | 293 | const QString modemHangupStr(); |
293 | void setModemHangupStr(const QString &); | 294 | void setModemHangupStr(const QString &); |
294 | 295 | ||
295 | const QString modemHangupResp(); | 296 | const QString modemHangupResp(); |
296 | void setModemHangupResp(const QString &); | 297 | void setModemHangupResp(const QString &); |
297 | 298 | ||
298 | const QString modemAnswerStr(); | 299 | const QString modemAnswerStr(); |
299 | void setModemAnswerStr(const QString &); | 300 | void setModemAnswerStr(const QString &); |
300 | 301 | ||
301 | const QString modemRingResp(); | 302 | const QString modemRingResp(); |
302 | void setModemRingResp(const QString &); | 303 | void setModemRingResp(const QString &); |
303 | 304 | ||
304 | const QString modemAnswerResp(); | 305 | const QString modemAnswerResp(); |
305 | void setModemAnswerResp(const QString &); | 306 | void setModemAnswerResp(const QString &); |
306 | 307 | ||
307 | QString volumeOff(); | 308 | QString volumeOff(); |
308 | void setVolumeOff(const QString &); | 309 | void setVolumeOff(const QString &); |
309 | 310 | ||
310 | QString volumeMedium(); | 311 | QString volumeMedium(); |
311 | void setVolumeMedium(const QString &); | 312 | void setVolumeMedium(const QString &); |
312 | 313 | ||
313 | QString volumeHigh(); | 314 | QString volumeHigh(); |
314 | void setVolumeHigh(const QString &); | 315 | void setVolumeHigh(const QString &); |
315 | 316 | ||
316 | #if 0 | 317 | #if 0 |
317 | void setUseCDLine(const int n); | 318 | void setUseCDLine(const int n); |
318 | int UseCDLine(); | 319 | int UseCDLine(); |
319 | #endif | 320 | #endif |
320 | 321 | ||
321 | // functions to set/get account information | 322 | // functions to set/get account information |
322 | int count() const; | 323 | int count() const; |
323 | bool setAccount(const QString &); | 324 | bool setAccount(const QString &); |
324 | bool setAccountbyIndex(int); | 325 | bool setAccountbyIndex(int); |
325 | 326 | ||
326 | bool isUniqueAccname(const QString &); | 327 | bool isUniqueAccname(const QString &); |
327 | 328 | ||
328 | bool deleteAccount(); | 329 | bool deleteAccount(); |
329 | bool deleteAccount(const QString &); | 330 | bool deleteAccount(const QString &); |
330 | int newaccount(); | 331 | int newaccount(); |
331 | int copyaccount(int i); | 332 | int copyaccount(int i); |
332 | 333 | ||
333 | const QString accname(); | 334 | const QString accname(); |
334 | void setAccname(const QString &); | 335 | void setAccname(const QString &); |
335 | 336 | ||
336 | QStringList &phonenumbers(); | 337 | QStringList &phonenumbers(); |
337 | const QString phonenumber(); | 338 | const QString phonenumber(); |
338 | void setPhonenumber(const QString &); | 339 | void setPhonenumber(const QString &); |
339 | 340 | ||
340 | const QString dialPrefix(); | 341 | const QString dialPrefix(); |
341 | void setDialPrefix(const QString &); | 342 | void setDialPrefix(const QString &); |
342 | 343 | ||
343 | int authMethod(); | 344 | int authMethod(); |
344 | void setAuthMethod(int); | 345 | void setAuthMethod(int); |
345 | 346 | ||
346 | const QString storedUsername(); | 347 | const QString storedUsername(); |
347 | void setStoredUsername(const QString &); | 348 | void setStoredUsername(const QString &); |
348 | 349 | ||
349 | const QString storedPassword(); | 350 | const QString storedPassword(); |
350 | void setStoredPassword(const QString &); | 351 | void setStoredPassword(const QString &); |
351 | 352 | ||
352 | bool storePassword(); | 353 | bool storePassword(); |
353 | void setStorePassword(bool); | 354 | void setStorePassword(bool); |
354 | 355 | ||
355 | const QString speed(); | 356 | const QString speed(); |
356 | void setSpeed(const QString &); | 357 | void setSpeed(const QString &); |
357 | 358 | ||
358 | const QString command_before_connect(); | 359 | const QString command_before_connect(); |
359 | void setCommand_before_connect(const QString &); | 360 | void setCommand_before_connect(const QString &); |
360 | 361 | ||
361 | const QString command_on_connect(); | 362 | const QString command_on_connect(); |
362 | void setCommand_on_connect(const QString &); | 363 | void setCommand_on_connect(const QString &); |
363 | 364 | ||
364 | const QString command_on_disconnect(); | 365 | const QString command_on_disconnect(); |
365 | void setCommand_on_disconnect(const QString &); | 366 | void setCommand_on_disconnect(const QString &); |
366 | 367 | ||
367 | const QString command_before_disconnect(); | 368 | const QString command_before_disconnect(); |
368 | void setCommand_before_disconnect(const QString &); | 369 | void setCommand_before_disconnect(const QString &); |
369 | 370 | ||
370 | const QString ipaddr(); | 371 | const QString ipaddr(); |
371 | void setIpaddr(const QString &); | 372 | void setIpaddr(const QString &); |
372 | 373 | ||
373 | const QString subnetmask(); | 374 | const QString subnetmask(); |
374 | void setSubnetmask(const QString &); | 375 | void setSubnetmask(const QString &); |
375 | 376 | ||
376 | bool AcctEnabled(); | 377 | bool AcctEnabled(); |
377 | void setAcctEnabled(bool set); | 378 | void setAcctEnabled(bool set); |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index da17e26..e13f8c8 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,121 +1,125 @@ | |||
1 | #include "pppconfig.h" | 1 | #include "pppconfig.h" |
2 | #include "pppmodule.h" | 2 | #include "pppmodule.h" |
3 | #include "pppdata.h" | 3 | #include "pppdata.h" |
4 | #include "kpppwidget.h" | 4 | #include "kpppwidget.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | //#include "devices.h" | 6 | //#include "devices.h" |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | PPPModule::PPPModule() : Module() { | 11 | PPPModule::PPPModule() : Module() |
12 | { | ||
13 | Interface *iface; | ||
14 | iface = new Interface( 0, "device" ); | ||
15 | iface->setHardwareName( "account" ); | ||
16 | list.append( iface ); | ||
12 | } | 17 | } |
13 | 18 | ||
14 | /** | 19 | /** |
15 | * Delete any interfaces that we own. | 20 | * Delete any interfaces that we own. |
16 | */ | 21 | */ |
17 | PPPModule::~PPPModule(){ | 22 | PPPModule::~PPPModule(){ |
18 | Interface *i; | 23 | Interface *i; |
19 | for ( i=list.first(); i != 0; i=list.next() ) | 24 | for ( i=list.first(); i != 0; i=list.next() ) |
20 | delete i; | 25 | delete i; |
21 | } | 26 | } |
22 | 27 | ||
23 | /** | 28 | /** |
24 | * Change the current profile | 29 | * Change the current profile |
25 | */ | 30 | */ |
26 | void PPPModule::setProfile(const QString &newProfile){ | 31 | void PPPModule::setProfile(const QString &newProfile){ |
27 | profile = newProfile; | 32 | profile = newProfile; |
28 | } | 33 | } |
29 | 34 | ||
30 | /** | 35 | /** |
31 | * get the icon name for this device. | 36 | * get the icon name for this device. |
32 | * @param Interface* can be used in determining the icon. | 37 | * @param Interface* can be used in determining the icon. |
33 | * @return QString the icon name (minus .png, .gif etc) | 38 | * @return QString the icon name (minus .png, .gif etc) |
34 | */ | 39 | */ |
35 | QString PPPModule::getPixmapName(Interface* ){ | 40 | QString PPPModule::getPixmapName(Interface* ){ |
36 | return "ppp"; | 41 | return "ppp"; |
37 | } | 42 | } |
38 | 43 | ||
39 | /** | 44 | /** |
40 | * Check to see if the interface i is owned by this module. | 45 | * Check to see if the interface i is owned by this module. |
41 | * @param Interface* interface to check against | 46 | * @param Interface* interface to check against |
42 | * @return bool true if i is owned by this module, false otherwise. | 47 | * @return bool true if i is owned by this module, false otherwise. |
43 | */ | 48 | */ |
44 | bool PPPModule::isOwner(Interface *i){ | 49 | bool PPPModule::isOwner(Interface *i){ |
45 | if(!i->getInterfaceName().upper().contains("PPP")) | 50 | return list.find( i ) != -1; |
46 | return false; | ||
47 | |||
48 | i->setHardwareName("PPP"); | ||
49 | list.append(i); | ||
50 | return true; | ||
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Create, and return the WLANConfigure Module | 54 | * Create, and return the WLANConfigure Module |
55 | * @return QWidget* pointer to this modules configure. | 55 | * @return QWidget* pointer to this modules configure. |
56 | */ | 56 | */ |
57 | QWidget *PPPModule::configure(Interface *i){ | 57 | QWidget *PPPModule::configure(Interface *i){ |
58 | qDebug("return ModemWidget"); | 58 | qDebug("return ModemWidget"); |
59 | PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose ); | 59 | PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, |
60 | // pppconfig->setProfile(profile); | 60 | Qt::WDestructiveClose ); |
61 | return pppconfig; | 61 | return pppconfig; |
62 | } | 62 | } |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Create, and return the Information Module | 65 | * Create, and return the Information Module |
66 | * @return QWidget* pointer to this modules info. | 66 | * @return QWidget* pointer to this modules info. |
67 | */ | 67 | */ |
68 | QWidget *PPPModule::information(Interface *i){ | 68 | QWidget *PPPModule::information(Interface *i){ |
69 | // We don't have any advanced pppd information widget yet :-D | 69 | // We don't have any advanced pppd information widget yet :-D |
70 | // TODO ^ | 70 | // TODO ^ |
71 | qDebug("return PPPModule::information"); | 71 | qDebug("return PPPModule::information"); |
72 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); | 72 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); |
73 | return information; | 73 | return information; |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Get all active (up or down) interfaces | 77 | * Get all active (up or down) interfaces |
78 | * @return QList<Interface> A list of interfaces that exsist that havn't | 78 | * @return QList<Interface> A list of interfaces that exsist that havn't |
79 | * been called by isOwner() | 79 | * been called by isOwner() |
80 | */ | 80 | */ |
81 | QList<Interface> PPPModule::getInterfaces(){ | 81 | QList<Interface> PPPModule::getInterfaces(){ |
82 | // List all of the files in the peer directory | 82 | // List all of the files in the peer directory |
83 | return list; | 83 | return list; |
84 | } | 84 | } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Attempt to add a new interface as defined by name | 87 | * Attempt to add a new interface as defined by name |
88 | * @param name the name of the type of interface that should be created given | 88 | * @param name the name of the type of interface that should be created given |
89 | * by possibleNewInterfaces(); | 89 | * by possibleNewInterfaces(); |
90 | * @return Interface* NULL if it was unable to be created. | 90 | * @return Interface* NULL if it was unable to be created. |
91 | */ | 91 | */ |
92 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 92 | Interface *PPPModule::addNewInterface(const QString &newInterface){ |
93 | 93 | ||
94 | qDebug("try to add iface %s",newInterface.latin1()); | 94 | qDebug("try to add iface %s",newInterface.latin1()); |
95 | 95 | ||
96 | PPPConfigWidget imp(0, "PPPConfigImp", true); | 96 | PPPConfigWidget imp(0, "PPPConfigImp", true); |
97 | imp.showMaximized(); | 97 | imp.showMaximized(); |
98 | if(imp.exec() == QDialog::Accepted ){ | 98 | if(imp.exec() == QDialog::Accepted ){ |
99 | qDebug("ACCEPTED"); | 99 | qDebug("ACCEPTED"); |
100 | return new Interface( 0, newInterface ); | ||
101 | PPPData::data()->save(); | 100 | PPPData::data()->save(); |
101 | Interface *iface; | ||
102 | iface = new Interface( 0, PPPData::data()->modemDevice() ); | ||
103 | iface->setHardwareName( PPPData::data()->accname() ); | ||
104 | list.append( iface ); | ||
105 | return iface; | ||
102 | } | 106 | } |
103 | return NULL; | 107 | return NULL; |
104 | } | 108 | } |
105 | 109 | ||
106 | /** | 110 | /** |
107 | * Attempts to remove the interface, doesn't delete i | 111 | * Attempts to remove the interface, doesn't delete i |
108 | * @return bool true if successfull, false otherwise. | 112 | * @return bool true if successfull, false otherwise. |
109 | */ | 113 | */ |
110 | bool PPPModule::remove(Interface*){ | 114 | bool PPPModule::remove(Interface*){ |
111 | // Can't remove a hardware device, you can stop it though. | 115 | // Can't remove a hardware device, you can stop it though. |
112 | return false; | 116 | return false; |
113 | } | 117 | } |
114 | 118 | ||
115 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 119 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
116 | { | 120 | { |
117 | qDebug("here"); | 121 | newIfaces.insert(QObject::tr("PPP") , |
118 | newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device")); | 122 | QObject::tr("generic ppp device")); |
119 | } | 123 | } |
120 | 124 | ||
121 | 125 | ||