author | tille <tille> | 2003-06-02 11:57:59 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-02 11:57:59 (UTC) |
commit | ec520ccd6a4696663269db36b7df74ffde13c70c (patch) (unidiff) | |
tree | 7c2c27160740eac2f24d8654b25266f8de55663d | |
parent | c002c647b15ea04f5a755b5edba5db0b280b1cbf (diff) | |
download | opie-ec520ccd6a4696663269db36b7df74ffde13c70c.zip opie-ec520ccd6a4696663269db36b7df74ffde13c70c.tar.gz opie-ec520ccd6a4696663269db36b7df74ffde13c70c.tar.bz2 |
basicly working now...
... but it's not yet tested...
... and you cannot input username and pw.
you can write a loginscript.
9 files changed, 160 insertions, 30 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 2410880..1136c2d 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,6 +1,7 @@ | |||
1 | - add possibility to input username and password ;) | ||
1 | - impl. PPPData::copyaccount & PPPData::deleteAccount | 2 | - impl. PPPData::copyaccount & PPPData::deleteAccount |
2 | - update modem attribute inputs when modem has changed | 3 | - update modem attribute inputs when modem has changed |
3 | - fix layout of edit account | 4 | - fix layout of edit account |
4 | - save pppd arguments in edit account | 5 | - save pppd arguments in edit account |
5 | - popup configure modem with the correct account prselected | 6 | - popup configure modem with the correct account prselected |
6 | not quite shure why it does not work... IMHO it should work | 7 | not quite shure why it does not work... IMHO it should work |
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 2615b60..89d9930 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1,333 +1,333 @@ | |||
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 | * | 4 | * |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> | 7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
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 <config.h> | 27 | //#include <config.h> |
28 | 28 | ||
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qregexp.h> | 30 | #include <qregexp.h> |
31 | 31 | ||
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <kdebug.h> | 33 | //#include <kdebug.h> |
34 | //#include <klocale.h> | 34 | //#include <klocale.h> |
35 | #define i18n QObject::tr | 35 | #define i18n QObject::tr |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | 38 | ||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <fcntl.h> | 42 | #include <fcntl.h> |
43 | #include <netdb.h> | 43 | #include <netdb.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 47 | #include <netinet/in.h> |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #ifdef _XPG4_2 | 51 | #ifdef _XPG4_2 |
52 | #define __xnet_connectconnect | 52 | #define __xnet_connectconnect |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #include <errno.h> | 55 | #include <errno.h> |
56 | 56 | ||
57 | #ifdef HAVE_SYS_PARAM_H | 57 | #ifdef HAVE_SYS_PARAM_H |
58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #ifdef __linux__ | 61 | #ifdef __linux__ |
62 | #include "runtests.h" | 62 | #include "runtests.h" |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #include "auth.h" | 65 | #include "auth.h" |
66 | #include "connect.h" | 66 | #include "connect.h" |
67 | //#include "docking.h" | 67 | //#include "docking.h" |
68 | #include "interfaceppp.h" | 68 | #include "interfaceppp.h" |
69 | #include "modem.h" | 69 | #include "modem.h" |
70 | #include "kpppconfig.h" | 70 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 71 | #include "pppdata.h" |
72 | #include "kpppwidget.h" | 72 | #include "kpppwidget.h" |
73 | //#include "requester.h" | 73 | //#include "requester.h" |
74 | //#include "utils.h" | 74 | //#include "utils.h" |
75 | #define execute_command system | 75 | #define execute_command system |
76 | 76 | ||
77 | QString old_hostname; | 77 | QString old_hostname; |
78 | bool modified_hostname; | 78 | bool modified_hostname; |
79 | 79 | ||
80 | 80 | ||
81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) | 81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
82 | : QWidget(parent, name), | 82 | : QWidget(parent, name), |
83 | myreadbuffer(""), | 83 | myreadbuffer(""), |
84 | main_timer_ID(0), | 84 | main_timer_ID(0), |
85 | vmain(0), | 85 | vmain(0), |
86 | substate(-1), | 86 | substate(-1), |
87 | scriptindex(0), | 87 | scriptindex(0), |
88 | loopnest(0), | 88 | loopnest(0), |
89 | loopend(false), | 89 | loopend(false), |
90 | semaphore(false), | 90 | semaphore(false), |
91 | expecting(false), | 91 | expecting(false), |
92 | readbuffer(""), | 92 | readbuffer(""), |
93 | scanvar(""), | 93 | scanvar(""), |
94 | scanning(false), | 94 | scanning(false), |
95 | pausing(false), | 95 | pausing(false), |
96 | dialnumber(0), | 96 | dialnumber(0), |
97 | _ifaceppp(ifp) | 97 | _ifaceppp(ifp) |
98 | { | 98 | { |
99 | modified_hostname = false; | 99 | modified_hostname = false; |
100 | 100 | ||
101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
102 | QString tit = i18n("Connecting to: "); | 102 | QString tit = i18n("Connecting to: "); |
103 | setCaption(tit); | 103 | setCaption(tit); |
104 | 104 | ||
105 | QHBoxLayout *l0 = new QHBoxLayout(10); | 105 | QHBoxLayout *l0 = new QHBoxLayout(10); |
106 | tl->addLayout(l0); | 106 | tl->addLayout(l0); |
107 | l0->addSpacing(10); | 107 | l0->addSpacing(10); |
108 | messg = new QLabel(this, "messg"); | 108 | messg = new QLabel(this, "messg"); |
109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | messg->setAlignment(AlignCenter); | 110 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 111 | messg->setText(i18n("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | int messw = (messg->sizeHint().width() * 12) / 10; | 113 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | messw = QMAX(messw,280); | 114 | // messw = QMAX(messw,280); |
115 | messg->setMinimumWidth(messw); | 115 | // messg->setMinimumWidth(messw); |
116 | messg->setText(i18n("Looking for modem...")); | 116 | messg->setText(i18n("Offline")); |
117 | l0->addSpacing(10); | 117 | l0->addSpacing(10); |
118 | l0->addWidget(messg); | 118 | l0->addWidget(messg); |
119 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
120 | 120 | ||
121 | QHBoxLayout *l1 = new QHBoxLayout(10); | 121 | QHBoxLayout *l1 = new QHBoxLayout(10); |
122 | tl->addLayout(l1); | 122 | tl->addLayout(l1); |
123 | l1->addStretch(1); | 123 | l1->addStretch(1); |
124 | 124 | ||
125 | debug = new QPushButton(i18n("Log"), this); | 125 | debug = new QPushButton(i18n("Log"), this); |
126 | debug->setToggleButton(true); | 126 | debug->setToggleButton(true); |
127 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 127 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
128 | 128 | ||
129 | cancel = new QPushButton(i18n("Cancel"), this); | 129 | cancel = new QPushButton(i18n("Cancel"), this); |
130 | cancel->setFocus(); | 130 | cancel->setFocus(); |
131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
132 | 132 | ||
133 | int maxw = QMAX(cancel->sizeHint().width(), | 133 | // int maxw = QMAX(cancel->sizeHint().width(), |
134 | debug->sizeHint().width()); | 134 | // debug->sizeHint().width()); |
135 | maxw = QMAX(maxw,65); | 135 | // maxw = QMAX(maxw,65); |
136 | debug->setFixedWidth(maxw); | 136 | // debug->setFixedWidth(maxw); |
137 | cancel->setFixedWidth(maxw); | 137 | // cancel->setFixedWidth(maxw); |
138 | l1->addWidget(debug); | 138 | l1->addWidget(debug); |
139 | l1->addWidget(cancel); | 139 | l1->addWidget(cancel); |
140 | 140 | ||
141 | setFixedSize(sizeHint()); | 141 | // setFixedSize(sizeHint()); |
142 | 142 | ||
143 | pausetimer = new QTimer(this); | 143 | pausetimer = new QTimer(this); |
144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
145 | 145 | ||
146 | qApp->processEvents(); | 146 | qApp->processEvents(); |
147 | 147 | ||
148 | timeout_timer = new QTimer(this); | 148 | timeout_timer = new QTimer(this); |
149 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); | 149 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); |
150 | 150 | ||
151 | inittimer = new QTimer(this); | 151 | inittimer = new QTimer(this); |
152 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); | 152 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); |
153 | 153 | ||
154 | if_timeout_timer = new QTimer(this); | 154 | if_timeout_timer = new QTimer(this); |
155 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); | 155 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); |
156 | 156 | ||
157 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); | 157 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); |
158 | 158 | ||
159 | prompt = new PWEntry( this, "pw" ); | 159 | prompt = new PWEntry( this, "pw" ); |
160 | if_timer = new QTimer(this); | 160 | if_timer = new QTimer(this); |
161 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 161 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | ConnectWidget::~ConnectWidget() { | 165 | ConnectWidget::~ConnectWidget() { |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void ConnectWidget::preinit() { | 169 | void ConnectWidget::preinit() { |
170 | // this is all just to keep the GUI nice and snappy .... | 170 | // this is all just to keep the GUI nice and snappy .... |
171 | // you have to see to believe ... | 171 | // you have to see to believe ... |
172 | messg->setText(i18n("Looking for modem...")); | 172 | messg->setText(i18n("Looking for modem...")); |
173 | inittimer->start(100); | 173 | inittimer->start(100); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void ConnectWidget::init() { | 177 | void ConnectWidget::init() { |
178 | _ifaceppp->data()->setpppdError(0); | 178 | _ifaceppp->data()->setpppdError(0); |
179 | inittimer->stop(); | 179 | inittimer->stop(); |
180 | vmain = 0; | 180 | vmain = 0; |
181 | substate = -1; | 181 | substate = -1; |
182 | expecting = false; | 182 | expecting = false; |
183 | pausing = false; | 183 | pausing = false; |
184 | scriptindex = 0; | 184 | scriptindex = 0; |
185 | myreadbuffer = ""; | 185 | myreadbuffer = ""; |
186 | scanning = false; | 186 | scanning = false; |
187 | scanvar = ""; | 187 | scanvar = ""; |
188 | firstrunID = true; | 188 | firstrunID = true; |
189 | firstrunPW = true; | 189 | firstrunPW = true; |
190 | // stats->totalbytes = 0; | 190 | // stats->totalbytes = 0; |
191 | dialnumber = 0; | 191 | dialnumber = 0; |
192 | 192 | ||
193 | // p_kppp->con_speed = ""; | 193 | // p_kppp->con_speed = ""; |
194 | 194 | ||
195 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); | 195 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
196 | 196 | ||
197 | comlist = &_ifaceppp->data()->scriptType(); | 197 | comlist = &_ifaceppp->data()->scriptType(); |
198 | arglist = &_ifaceppp->data()->script(); | 198 | arglist = &_ifaceppp->data()->script(); |
199 | 199 | ||
200 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); | 200 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
201 | setCaption(tit); | 201 | setCaption(tit); |
202 | 202 | ||
203 | qApp->processEvents(); | 203 | qApp->processEvents(); |
204 | 204 | ||
205 | // run the "before-connect" command | 205 | // run the "before-connect" command |
206 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { | 206 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
207 | messg->setText(i18n("Running pre-startup command...")); | 207 | messg->setText(i18n("Running pre-startup command...")); |
208 | emit debugMessage(i18n("Running pre-startup command...")); | 208 | emit debugMessage(i18n("Running pre-startup command...")); |
209 | 209 | ||
210 | qApp->processEvents(); | 210 | qApp->processEvents(); |
211 | QApplication::flushX(); | 211 | QApplication::flushX(); |
212 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); | 212 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
213 | // int i, status; | 213 | // int i, status; |
214 | 214 | ||
215 | // do { | 215 | // do { |
216 | // qApp->processEvents(); | 216 | // qApp->processEvents(); |
217 | // i = waitpid(id, &status, WNOHANG); | 217 | // i = waitpid(id, &status, WNOHANG); |
218 | // usleep(100000); | 218 | // usleep(100000); |
219 | // } while (i == 0 && errno == 0); | 219 | // } while (i == 0 && errno == 0); |
220 | } | 220 | } |
221 | 221 | ||
222 | int lock = _ifaceppp->modem()->lockdevice(); | 222 | int lock = _ifaceppp->modem()->lockdevice(); |
223 | 223 | ||
224 | if (lock == 1) { | 224 | if (lock == 1) { |
225 | messg->setText(i18n("Modem device is locked.")); | 225 | messg->setText(i18n("Modem device is locked.")); |
226 | vmain = 20; // wait until cancel is pressed | 226 | vmain = 20; // wait until cancel is pressed |
227 | return; | 227 | return; |
228 | } | 228 | } |
229 | 229 | ||
230 | if (lock == -1) { | 230 | if (lock == -1) { |
231 | messg->setText(i18n("Unable to create modem lock file.")); | 231 | messg->setText(i18n("Unable to create modem lock file.")); |
232 | vmain = 20; // wait until cancel is pressed | 232 | vmain = 20; // wait until cancel is pressed |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | 235 | ||
236 | if(_ifaceppp->modem()->opentty()) { | 236 | if(_ifaceppp->modem()->opentty()) { |
237 | messg->setText(_ifaceppp->modem()->modemMessage()); | 237 | messg->setText(_ifaceppp->modem()->modemMessage()); |
238 | qApp->processEvents(); | 238 | qApp->processEvents(); |
239 | if(_ifaceppp->modem()->hangup()) { | 239 | if(_ifaceppp->modem()->hangup()) { |
240 | 240 | ||
241 | qApp->processEvents(); | 241 | qApp->processEvents(); |
242 | 242 | ||
243 | semaphore = false; | 243 | semaphore = false; |
244 | 244 | ||
245 | _ifaceppp->modem()->stop(); | 245 | _ifaceppp->modem()->stop(); |
246 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); | 246 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
247 | 247 | ||
248 | // if we are stuck anywhere we will time out | 248 | // if we are stuck anywhere we will time out |
249 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 249 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
250 | 250 | ||
251 | // this timer will run the script etc. | 251 | // this timer will run the script etc. |
252 | main_timer_ID = startTimer(10); | 252 | main_timer_ID = startTimer(10); |
253 | 253 | ||
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | // initialization failed | 258 | // initialization failed |
259 | messg->setText(_ifaceppp->modem()->modemMessage()); | 259 | messg->setText(_ifaceppp->modem()->modemMessage()); |
260 | vmain = 20; // wait until cancel is pressed | 260 | vmain = 20; // wait until cancel is pressed |
261 | _ifaceppp->modem()->unlockdevice(); | 261 | _ifaceppp->modem()->unlockdevice(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | void ConnectWidget::timerEvent(QTimerEvent *) { | 265 | void ConnectWidget::timerEvent(QTimerEvent *) { |
266 | if (semaphore || pausing) | 266 | if (semaphore || pausing) |
267 | return; | 267 | return; |
268 | 268 | ||
269 | if(vmain == 0) { | 269 | if(vmain == 0) { |
270 | #ifdef DEBUG_WO_DIALING | 270 | #ifdef DEBUG_WO_DIALING |
271 | vmain = 10; | 271 | vmain = 10; |
272 | return; | 272 | return; |
273 | #endif | 273 | #endif |
274 | 274 | ||
275 | assert(PPPData::NumInitStrings > 0); | 275 | assert(PPPData::NumInitStrings > 0); |
276 | // first init string ? | 276 | // first init string ? |
277 | if(substate == -1) { | 277 | if(substate == -1) { |
278 | messg->setText(i18n("Initializing modem...")); | 278 | messg->setText(i18n("Initializing modem...")); |
279 | emit debugMessage(i18n("Initializing modem...")); | 279 | emit debugMessage(i18n("Initializing modem...")); |
280 | substate = 0; | 280 | substate = 0; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString initStr = _ifaceppp->data()->modemInitStr(substate); | 283 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
284 | if (!initStr.isEmpty()) { | 284 | if (!initStr.isEmpty()) { |
285 | // send a carriage return and then wait a bit so that the modem will | 285 | // send a carriage return and then wait a bit so that the modem will |
286 | // let us issue commands. | 286 | // let us issue commands. |
287 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { | 287 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
288 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 288 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
289 | writeline(""); | 289 | writeline(""); |
290 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 290 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
291 | } | 291 | } |
292 | setExpect(_ifaceppp->data()->modemInitResp()); | 292 | setExpect(_ifaceppp->data()->modemInitResp()); |
293 | writeline(initStr); | 293 | writeline(initStr); |
294 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 294 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
295 | } | 295 | } |
296 | 296 | ||
297 | substate++; | 297 | substate++; |
298 | 298 | ||
299 | /* | 299 | /* |
300 | * FIXME after 3.0: Make it possible to disable ATS11 since it | 300 | * FIXME after 3.0: Make it possible to disable ATS11 since it |
301 | * seems to be incompatible with some ISDN adapters (e.g. DataBox | 301 | * seems to be incompatible with some ISDN adapters (e.g. DataBox |
302 | * Speed Dragon). Even better would be to detect this when doing | 302 | * Speed Dragon). Even better would be to detect this when doing |
303 | * a "Modem Query" | 303 | * a "Modem Query" |
304 | */ | 304 | */ |
305 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) | 305 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
306 | vmain = 5; | 306 | vmain = 5; |
307 | else | 307 | else |
308 | vmain = 3; | 308 | vmain = 3; |
309 | 309 | ||
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | 312 | ||
313 | if (vmain == 5) { | 313 | if (vmain == 5) { |
314 | if(!expecting) { | 314 | if(!expecting) { |
315 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); | 315 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
316 | QString msg = i18n("Setting ") + sToneDuration; | 316 | QString msg = i18n("Setting ") + sToneDuration; |
317 | messg->setText(msg); | 317 | messg->setText(msg); |
318 | emit debugMessage(msg); | 318 | emit debugMessage(msg); |
319 | setExpect(_ifaceppp->data()->modemInitResp()); | 319 | setExpect(_ifaceppp->data()->modemInitResp()); |
320 | writeline(sToneDuration); | 320 | writeline(sToneDuration); |
321 | } | 321 | } |
322 | vmain = 3; | 322 | vmain = 3; |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | 325 | ||
326 | if(vmain == 3) { | 326 | if(vmain == 3) { |
327 | if(!expecting) { | 327 | if(!expecting) { |
328 | // done with all init strings ? | 328 | // done with all init strings ? |
329 | if(substate < PPPData::NumInitStrings) { | 329 | if(substate < PPPData::NumInitStrings) { |
330 | vmain = 0; | 330 | vmain = 0; |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | substate = -1; | 333 | substate = -1; |
@@ -800,401 +800,399 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
800 | } | 800 | } |
801 | 801 | ||
802 | if(vmain == 10) { | 802 | if(vmain == 10) { |
803 | if(!expecting) { | 803 | if(!expecting) { |
804 | 804 | ||
805 | int result; | 805 | int result; |
806 | 806 | ||
807 | timeout_timer->stop(); | 807 | timeout_timer->stop(); |
808 | if_timeout_timer->stop(); // better be sure. | 808 | if_timeout_timer->stop(); // better be sure. |
809 | 809 | ||
810 | // stop reading of data | 810 | // stop reading of data |
811 | _ifaceppp->modem()->stop(); | 811 | _ifaceppp->modem()->stop(); |
812 | 812 | ||
813 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { | 813 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
814 | // if (termwindow) { | 814 | // if (termwindow) { |
815 | // delete termwindow; | 815 | // delete termwindow; |
816 | // termwindow = 0L; | 816 | // termwindow = 0L; |
817 | // this->show(); | 817 | // this->show(); |
818 | // } else { | 818 | // } else { |
819 | // termwindow = new LoginTerm(0L, 0L); | 819 | // termwindow = new LoginTerm(0L, 0L); |
820 | // hide(); | 820 | // hide(); |
821 | // termwindow->show(); | 821 | // termwindow->show(); |
822 | // vmain = 30; | 822 | // vmain = 30; |
823 | // return; | 823 | // return; |
824 | // } | 824 | // } |
825 | } | 825 | } |
826 | 826 | ||
827 | // Close the tty. This prevents the QTimer::singleShot() in | 827 | // Close the tty. This prevents the QTimer::singleShot() in |
828 | // Modem::readtty() from re-enabling the socket notifier. | 828 | // Modem::readtty() from re-enabling the socket notifier. |
829 | // The port is still held open by the helper process. | 829 | // The port is still held open by the helper process. |
830 | _ifaceppp->modem()->closetty(); | 830 | _ifaceppp->modem()->closetty(); |
831 | 831 | ||
832 | killTimer( main_timer_ID ); | 832 | killTimer( main_timer_ID ); |
833 | 833 | ||
834 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 834 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
835 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 835 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
836 | 836 | ||
837 | // find out PPP interface and notify the stats module | 837 | // find out PPP interface and notify the stats module |
838 | // stats->setUnit(pppInterfaceNumber()); | 838 | // stats->setUnit(pppInterfaceNumber()); |
839 | 839 | ||
840 | qApp->flushX(); | 840 | qApp->flushX(); |
841 | semaphore = true; | 841 | semaphore = true; |
842 | result = execppp(); | 842 | result = execppp(); |
843 | 843 | ||
844 | emit debugMessage(i18n("Starting pppd...")); | 844 | emit debugMessage(i18n("Starting pppd...")); |
845 | qDebug("execppp() returned with return-code %i", result ); | 845 | qDebug("execppp() returned with return-code %i", result ); |
846 | 846 | ||
847 | if(result) { | 847 | if(result) { |
848 | if(!_ifaceppp->data()->autoDNS()) | 848 | if(!_ifaceppp->data()->autoDNS()) |
849 | adddns( _ifaceppp ); | 849 | adddns( _ifaceppp ); |
850 | 850 | ||
851 | // O.K we are done here, let's change over to the if_waiting loop | 851 | // O.K we are done here, let's change over to the if_waiting loop |
852 | // where we wait for the ppp if (interface) to come up. | 852 | // where we wait for the ppp if (interface) to come up. |
853 | 853 | ||
854 | emit if_waiting_signal(); | 854 | emit if_waiting_signal(); |
855 | } else { | 855 | } else { |
856 | 856 | ||
857 | // starting pppd wasn't successful. Error messages were | 857 | // starting pppd wasn't successful. Error messages were |
858 | // handled by execppp(); | 858 | // handled by execppp(); |
859 | if_timeout_timer->stop(); | 859 | if_timeout_timer->stop(); |
860 | this->hide(); | 860 | this->hide(); |
861 | messg->setText(""); | 861 | messg->setText(""); |
862 | //p_kppp->quit_b->setFocus(); | 862 | //p_kppp->quit_b->setFocus(); |
863 | //p_kppp->show(); | 863 | //p_kppp->show(); |
864 | qApp->processEvents(); | 864 | qApp->processEvents(); |
865 | _ifaceppp->modem()->hangup(); | 865 | _ifaceppp->modem()->hangup(); |
866 | emit stopAccounting(); | 866 | emit stopAccounting(); |
867 | //p_kppp->con_win->stopClock(); | 867 | //p_kppp->con_win->stopClock(); |
868 | _ifaceppp->modem()->closetty(); | 868 | _ifaceppp->modem()->closetty(); |
869 | _ifaceppp->modem()->unlockdevice(); | 869 | _ifaceppp->modem()->unlockdevice(); |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | return; | 873 | return; |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | // this is a "wait until cancel" entry | 877 | // this is a "wait until cancel" entry |
878 | 878 | ||
879 | if(vmain == 20) { | 879 | if(vmain == 20) { |
880 | } | 880 | } |
881 | } | 881 | } |
882 | 882 | ||
883 | 883 | ||
884 | void ConnectWidget::set_con_speed_string() { | 884 | void ConnectWidget::set_con_speed_string() { |
885 | // Here we are trying to determine the speed at which we are connected. | 885 | // Here we are trying to determine the speed at which we are connected. |
886 | // Usually the modem responds after connect with something like | 886 | // Usually the modem responds after connect with something like |
887 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 887 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
888 | // or whatever the modemConnectResp() is. | 888 | // or whatever the modemConnectResp() is. |
889 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); | 889 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
890 | } | 890 | } |
891 | 891 | ||
892 | 892 | ||
893 | 893 | ||
894 | void ConnectWidget::readChar(unsigned char c) { | 894 | void ConnectWidget::readChar(unsigned char c) { |
895 | if(semaphore) | 895 | if(semaphore) |
896 | return; | 896 | return; |
897 | 897 | ||
898 | readbuffer += c; | 898 | readbuffer += c; |
899 | myreadbuffer += c; | 899 | myreadbuffer += c; |
900 | 900 | ||
901 | // While in scanning mode store each char to the scan buffer | 901 | // While in scanning mode store each char to the scan buffer |
902 | // for use in the prompt command | 902 | // for use in the prompt command |
903 | if( scanning ) | 903 | if( scanning ) |
904 | scanbuffer += c; | 904 | scanbuffer += c; |
905 | 905 | ||
906 | // add to debug window | 906 | // add to debug window |
907 | emit debugPutChar(c); | 907 | emit debugPutChar(c); |
908 | 908 | ||
909 | checkBuffers(); | 909 | checkBuffers(); |
910 | } | 910 | } |
911 | 911 | ||
912 | 912 | ||
913 | void ConnectWidget::checkBuffers() { | 913 | void ConnectWidget::checkBuffers() { |
914 | // Let's check if we are finished with scanning: | 914 | // Let's check if we are finished with scanning: |
915 | // The scanstring have to be in the buffer and the latest character | 915 | // The scanstring have to be in the buffer and the latest character |
916 | // was a carriage return or an linefeed (depending on modem setup) | 916 | // was a carriage return or an linefeed (depending on modem setup) |
917 | if( scanning && scanbuffer.contains(scanstr) && | 917 | if( scanning && scanbuffer.contains(scanstr) && |
918 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 918 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
919 | scanning = false; | 919 | scanning = false; |
920 | 920 | ||
921 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 921 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
922 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 922 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
923 | scanvar = scanvar.stripWhiteSpace(); | 923 | scanvar = scanvar.stripWhiteSpace(); |
924 | 924 | ||
925 | // Show the Variabel content in the debug window | 925 | // Show the Variabel content in the debug window |
926 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 926 | QString sv = i18n("Scan Var: %1").arg(scanvar); |
927 | emit debugMessage(sv); | 927 | emit debugMessage(sv); |
928 | } | 928 | } |
929 | 929 | ||
930 | if(expecting) { | 930 | if(expecting) { |
931 | if(readbuffer.contains(expectstr)) { | 931 | if(readbuffer.contains(expectstr)) { |
932 | expecting = false; | 932 | expecting = false; |
933 | // keep everything after the expected string | 933 | // keep everything after the expected string |
934 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 934 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
935 | 935 | ||
936 | QString ts = i18n("Found: %1").arg(expectstr); | 936 | QString ts = i18n("Found: %1").arg(expectstr); |
937 | emit debugMessage(ts); | 937 | emit debugMessage(ts); |
938 | 938 | ||
939 | if (loopend) { | 939 | if (loopend) { |
940 | loopend=false; | 940 | loopend=false; |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 944 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
945 | expecting = false; | 945 | expecting = false; |
946 | readbuffer = ""; | 946 | readbuffer = ""; |
947 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 947 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); |
948 | emit debugMessage(ts); | 948 | emit debugMessage(ts); |
949 | scriptindex = loopstartindex[loopnest]; | 949 | scriptindex = loopstartindex[loopnest]; |
950 | loopend = false; | 950 | loopend = false; |
951 | loopnest++; | 951 | loopnest++; |
952 | } | 952 | } |
953 | // notify event loop if expected string was found | 953 | // notify event loop if expected string was found |
954 | if(!expecting) | 954 | if(!expecting) |
955 | timerEvent((QTimerEvent *) 0); | 955 | timerEvent((QTimerEvent *) 0); |
956 | } | 956 | } |
957 | } | 957 | } |
958 | 958 | ||
959 | 959 | ||
960 | 960 | ||
961 | void ConnectWidget::pause() { | 961 | void ConnectWidget::pause() { |
962 | pausing = false; | 962 | pausing = false; |
963 | pausetimer->stop(); | 963 | pausetimer->stop(); |
964 | } | 964 | } |
965 | 965 | ||
966 | 966 | ||
967 | void ConnectWidget::cancelbutton() { | 967 | void ConnectWidget::cancelbutton() { |
968 | _ifaceppp->modem()->stop(); | 968 | _ifaceppp->modem()->stop(); |
969 | killTimer(main_timer_ID); | 969 | killTimer(main_timer_ID); |
970 | timeout_timer->stop(); | 970 | timeout_timer->stop(); |
971 | if_timer->stop(); | 971 | if_timer->stop(); |
972 | if_timeout_timer->stop(); | 972 | if_timeout_timer->stop(); |
973 | 973 | ||
974 | // if (termwindow) { | 974 | // if (termwindow) { |
975 | // delete termwindow; | 975 | // delete termwindow; |
976 | // termwindow = 0L; | 976 | // termwindow = 0L; |
977 | // this->show(); | 977 | // this->show(); |
978 | // } | 978 | // } |
979 | 979 | ||
980 | messg->setText(i18n("One moment please...")); | 980 | messg->setText(i18n("One moment please...")); |
981 | 981 | ||
982 | // just to be sure | 982 | // just to be sure |
983 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 983 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
984 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 984 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
985 | removedns(_ifaceppp); | 985 | removedns(_ifaceppp); |
986 | 986 | ||
987 | qApp->processEvents(); | 987 | qApp->processEvents(); |
988 | 988 | ||
989 | _ifaceppp->modem()->killPPPDaemon(); | 989 | _ifaceppp->modem()->killPPPDaemon(); |
990 | _ifaceppp->modem()->hangup(); | 990 | _ifaceppp->modem()->hangup(); |
991 | 991 | ||
992 | this->hide(); | 992 | |
993 | messg->setText(""); | ||
994 | // p_kppp->quit_b->setFocus(); | 993 | // p_kppp->quit_b->setFocus(); |
995 | // p_kppp->show(); | 994 | // p_kppp->show(); |
996 | emit stopAccounting();// just to be sure | 995 | // emit stopAccounting();// just to be sure |
997 | // p_kppp->con_win->stopClock(); | 996 | // p_kppp->con_win->stopClock(); |
998 | _ifaceppp->modem()->closetty(); | 997 | _ifaceppp->modem()->closetty(); |
999 | _ifaceppp->modem()->unlockdevice(); | 998 | _ifaceppp->modem()->unlockdevice(); |
1000 | 999 | ||
1001 | //abort prompt window... | 1000 | //abort prompt window... |
1002 | if (prompt->isVisible()) { | 1001 | if (prompt->isVisible()) { |
1003 | prompt->hide(); | 1002 | prompt->hide(); |
1004 | } | 1003 | } |
1005 | prompt->setConsumed(); | 1004 | prompt->setConsumed(); |
1006 | 1005 | ||
1007 | // if(p_kppp->quitOnDisconnect()) | 1006 | messg->setText(tr("offline")); |
1008 | // qApp->exit(0); | ||
1009 | } | 1007 | } |
1010 | 1008 | ||
1011 | 1009 | ||
1012 | void ConnectWidget::script_timed_out() { | 1010 | void ConnectWidget::script_timed_out() { |
1013 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1011 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1014 | timeout_timer->stop(); | 1012 | timeout_timer->stop(); |
1015 | emit stopAccounting(); | 1013 | emit stopAccounting(); |
1016 | // p_kppp->con_win->stopClock(); | 1014 | // p_kppp->con_win->stopClock(); |
1017 | return; | 1015 | return; |
1018 | } | 1016 | } |
1019 | 1017 | ||
1020 | if (prompt->isVisible()) | 1018 | if (prompt->isVisible()) |
1021 | prompt->hide(); | 1019 | prompt->hide(); |
1022 | 1020 | ||
1023 | prompt->setConsumed(); | 1021 | prompt->setConsumed(); |
1024 | messg->setText(i18n("Script timed out!")); | 1022 | messg->setText(i18n("Script timed out!")); |
1025 | _ifaceppp->modem()->hangup(); | 1023 | _ifaceppp->modem()->hangup(); |
1026 | emit stopAccounting(); | 1024 | emit stopAccounting(); |
1027 | // p_kppp->con_win->stopClock(); | 1025 | // p_kppp->con_win->stopClock(); |
1028 | 1026 | ||
1029 | vmain = 0; // let's try again. | 1027 | vmain = 0; // let's try again. |
1030 | substate = -1; | 1028 | substate = -1; |
1031 | } | 1029 | } |
1032 | 1030 | ||
1033 | 1031 | ||
1034 | void ConnectWidget::setScan(const QString &n) { | 1032 | void ConnectWidget::setScan(const QString &n) { |
1035 | scanning = true; | 1033 | scanning = true; |
1036 | scanstr = n; | 1034 | scanstr = n; |
1037 | scanbuffer = ""; | 1035 | scanbuffer = ""; |
1038 | 1036 | ||
1039 | QString ts = i18n("Scanning: %1").arg(n); | 1037 | QString ts = i18n("Scanning: %1").arg(n); |
1040 | emit debugMessage(ts); | 1038 | emit debugMessage(ts); |
1041 | } | 1039 | } |
1042 | 1040 | ||
1043 | 1041 | ||
1044 | void ConnectWidget::setExpect(const QString &n) { | 1042 | void ConnectWidget::setExpect(const QString &n) { |
1045 | expecting = true; | 1043 | expecting = true; |
1046 | expectstr = n; | 1044 | expectstr = n; |
1047 | 1045 | ||
1048 | QString ts = i18n("Expecting: %1").arg(n); | 1046 | QString ts = i18n("Expecting: %1").arg(n); |
1049 | ts.replace(QRegExp("\n"), "<LF>"); | 1047 | ts.replace(QRegExp("\n"), "<LF>"); |
1050 | emit debugMessage(ts); | 1048 | emit debugMessage(ts); |
1051 | 1049 | ||
1052 | // check if the expected string is in the read buffer already. | 1050 | // check if the expected string is in the read buffer already. |
1053 | checkBuffers(); | 1051 | checkBuffers(); |
1054 | } | 1052 | } |
1055 | 1053 | ||
1056 | 1054 | ||
1057 | void ConnectWidget::if_waiting_timed_out() { | 1055 | void ConnectWidget::if_waiting_timed_out() { |
1058 | if_timer->stop(); | 1056 | if_timer->stop(); |
1059 | if_timeout_timer->stop(); | 1057 | if_timeout_timer->stop(); |
1060 | qDebug("if_waiting_timed_out()"); | 1058 | qDebug("if_waiting_timed_out()"); |
1061 | 1059 | ||
1062 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); | 1060 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1063 | 1061 | ||
1064 | // let's kill the stuck pppd | 1062 | // let's kill the stuck pppd |
1065 | _ifaceppp->modem()->killPPPDaemon(); | 1063 | _ifaceppp->modem()->killPPPDaemon(); |
1066 | 1064 | ||
1067 | emit stopAccounting(); | 1065 | emit stopAccounting(); |
1068 | // p_kppp->con_win->stopClock(); | 1066 | // p_kppp->con_win->stopClock(); |
1069 | 1067 | ||
1070 | 1068 | ||
1071 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1069 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1072 | // in main.cpp what happens next will depend on the boolean | 1070 | // in main.cpp what happens next will depend on the boolean |
1073 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1071 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1074 | } | 1072 | } |
1075 | 1073 | ||
1076 | void ConnectWidget::pppdDied() | 1074 | void ConnectWidget::pppdDied() |
1077 | { | 1075 | { |
1078 | if_timer->stop(); | 1076 | if_timer->stop(); |
1079 | if_timeout_timer->stop(); | 1077 | if_timeout_timer->stop(); |
1080 | } | 1078 | } |
1081 | 1079 | ||
1082 | void ConnectWidget::if_waiting_slot() { | 1080 | void ConnectWidget::if_waiting_slot() { |
1083 | messg->setText(i18n("Logging on to network...")); | 1081 | messg->setText(i18n("Logging on to network...")); |
1084 | 1082 | ||
1085 | // if(!stats->ifIsUp()) { | 1083 | // if(!stats->ifIsUp()) { |
1086 | 1084 | ||
1087 | // if(_ifaceppp->data()->pppdError() != 0) { | 1085 | // if(_ifaceppp->data()->pppdError() != 0) { |
1088 | // // we are here if pppd died immediately after starting it. | 1086 | // // we are here if pppd died immediately after starting it. |
1089 | // pppdDied(); | 1087 | // pppdDied(); |
1090 | // // error message handled in main.cpp: sigPPPDDied() | 1088 | // // error message handled in main.cpp: sigPPPDDied() |
1091 | // return; | 1089 | // return; |
1092 | // } | 1090 | // } |
1093 | 1091 | ||
1094 | // if_timer->start(100, TRUE); // single shot | 1092 | // if_timer->start(100, TRUE); // single shot |
1095 | // return; | 1093 | // return; |
1096 | // } | 1094 | // } |
1097 | 1095 | ||
1098 | // O.K the ppp interface is up and running | 1096 | // O.K the ppp interface is up and running |
1099 | // give it a few time to come up completly (0.2 seconds) | 1097 | // give it a few time to come up completly (0.2 seconds) |
1100 | if_timeout_timer->stop(); | 1098 | if_timeout_timer->stop(); |
1101 | if_timer->stop(); | 1099 | if_timer->stop(); |
1102 | usleep(200000); | 1100 | usleep(200000); |
1103 | 1101 | ||
1104 | if(_ifaceppp->data()->autoDNS()) | 1102 | if(_ifaceppp->data()->autoDNS()) |
1105 | addpeerdns( _ifaceppp ); | 1103 | addpeerdns( _ifaceppp ); |
1106 | 1104 | ||
1107 | // Close the debugging window. If we are connected, we | 1105 | // Close the debugging window. If we are connected, we |
1108 | // are not really interested in debug output | 1106 | // are not really interested in debug output |
1109 | emit closeDebugWindow(); | 1107 | emit closeDebugWindow(); |
1110 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1108 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1111 | auto_hostname(_ifaceppp); | 1109 | auto_hostname(_ifaceppp); |
1112 | 1110 | ||
1113 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1111 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1114 | messg->setText(i18n("Running startup command...")); | 1112 | messg->setText(i18n("Running startup command...")); |
1115 | 1113 | ||
1116 | // make sure that we don't get any async errors | 1114 | // make sure that we don't get any async errors |
1117 | qApp->flushX(); | 1115 | qApp->flushX(); |
1118 | execute_command(_ifaceppp->data()->command_on_connect()); | 1116 | execute_command(_ifaceppp->data()->command_on_connect()); |
1119 | messg->setText(i18n("Done")); | 1117 | messg->setText(i18n("Done")); |
1120 | } | 1118 | } |
1121 | 1119 | ||
1122 | // remove the authentication file | 1120 | // remove the authentication file |
1123 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1121 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1124 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1122 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1125 | 1123 | ||
1126 | emit debugMessage(i18n("Done")); | 1124 | emit debugMessage(i18n("Done")); |
1127 | set_con_speed_string(); | 1125 | set_con_speed_string(); |
1128 | 1126 | ||
1129 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1127 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1130 | this->hide(); | 1128 | this->hide(); |
1131 | messg->setText(""); | 1129 | messg->setText(""); |
1132 | 1130 | ||
1133 | // prepare the con_win so as to have the right size for | 1131 | // prepare the con_win so as to have the right size for |
1134 | // accounting / non-accounting mode | 1132 | // accounting / non-accounting mode |
1135 | // if(p_kppp->acct != 0) | 1133 | // if(p_kppp->acct != 0) |
1136 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1134 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1137 | // else | 1135 | // else |
1138 | // p_kppp->con_win->accounting(false); | 1136 | // p_kppp->con_win->accounting(false); |
1139 | 1137 | ||
1140 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1138 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1141 | // // DockWidget::dock_widget->show(); | 1139 | // // DockWidget::dock_widget->show(); |
1142 | // // DockWidget::dock_widget->take_stats(); | 1140 | // // DockWidget::dock_widget->take_stats(); |
1143 | // // this->hide(); | 1141 | // // this->hide(); |
1144 | // } | 1142 | // } |
1145 | // else { | 1143 | // else { |
1146 | // // p_kppp->con_win->show(); | 1144 | // // p_kppp->con_win->show(); |
1147 | 1145 | ||
1148 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1146 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1149 | // // p_kppp->con_win->showMinimized(); | 1147 | // // p_kppp->con_win->showMinimized(); |
1150 | // } | 1148 | // } |
1151 | // } | 1149 | // } |
1152 | 1150 | ||
1153 | _ifaceppp->modem()->closetty(); | 1151 | _ifaceppp->modem()->closetty(); |
1154 | } | 1152 | } |
1155 | 1153 | ||
1156 | 1154 | ||
1157 | bool ConnectWidget::execppp() { | 1155 | bool ConnectWidget::execppp() { |
1158 | QString command; | 1156 | QString command; |
1159 | 1157 | ||
1160 | command = "pppd"; | 1158 | command = "pppd"; |
1161 | 1159 | ||
1162 | // as of version 2.3.6 pppd falls back to the real user rights when | 1160 | // as of version 2.3.6 pppd falls back to the real user rights when |
1163 | // opening a device given in a command line. To avoid permission conflicts | 1161 | // opening a device given in a command line. To avoid permission conflicts |
1164 | // we'll simply leave this argument away. pppd will then use the default tty | 1162 | // we'll simply leave this argument away. pppd will then use the default tty |
1165 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1163 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1166 | // command += " "; | 1164 | // command += " "; |
1167 | // command += _ifaceppp->data()->modemDevice(); | 1165 | // command += _ifaceppp->data()->modemDevice(); |
1168 | 1166 | ||
1169 | command += " " + _ifaceppp->data()->speed(); | 1167 | command += " " + _ifaceppp->data()->speed(); |
1170 | 1168 | ||
1171 | command += " -detach"; | 1169 | command += " -detach"; |
1172 | 1170 | ||
1173 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || | 1171 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1174 | _ifaceppp->data()->gateway() != "0.0.0.0") { | 1172 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1175 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { | 1173 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1176 | command += " "; | 1174 | command += " "; |
1177 | command += _ifaceppp->data()->ipaddr(); | 1175 | command += _ifaceppp->data()->ipaddr(); |
1178 | command += ":"; | 1176 | command += ":"; |
1179 | } | 1177 | } |
1180 | else { | 1178 | else { |
1181 | command += " "; | 1179 | command += " "; |
1182 | command += ":"; | 1180 | command += ":"; |
1183 | } | 1181 | } |
1184 | 1182 | ||
1185 | if(_ifaceppp->data()->gateway() != "0.0.0.0") | 1183 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1186 | command += _ifaceppp->data()->gateway(); | 1184 | command += _ifaceppp->data()->gateway(); |
1187 | } | 1185 | } |
1188 | 1186 | ||
1189 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") | 1187 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1190 | command += " netmask " + _ifaceppp->data()->subnetmask(); | 1188 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1191 | 1189 | ||
1192 | if(_ifaceppp->data()->flowcontrol() != "None") { | 1190 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1193 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1191 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1194 | command += " crtscts"; | 1192 | command += " crtscts"; |
1195 | else | 1193 | else |
1196 | command += " xonxoff"; | 1194 | command += " xonxoff"; |
1197 | } | 1195 | } |
1198 | 1196 | ||
1199 | if(_ifaceppp->data()->defaultroute()) | 1197 | if(_ifaceppp->data()->defaultroute()) |
1200 | command += " defaultroute"; | 1198 | command += " defaultroute"; |
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index a58858c..3cf1167 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -1,24 +1,32 @@ | |||
1 | #include "interfaceinformationppp.h" | 1 | #include "interfaceinformationppp.h" |
2 | 2 | ||
3 | 3 | ||
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | //#include <qgroupbox.h> | 6 | //#include <qgroupbox.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | 8 | ||
9 | #include "connect.h" | ||
10 | #include "conwindow.h" | ||
11 | |||
9 | #ifdef QWS | 12 | #ifdef QWS |
10 | #else | 13 | #else |
11 | #define showMaximized show | 14 | #define showMaximized show |
12 | #endif | 15 | #endif |
13 | 16 | ||
14 | /** | 17 | /** |
15 | * Constructor for the InterfaceInformationImp class. This class pretty much | 18 | * Constructor for the InterfaceInformationImp class. This class pretty much |
16 | * just display's information about the interface that is passed to it. | 19 | * just display's information about the interface that is passed to it. |
17 | */ | 20 | */ |
18 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 21 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
19 | :InterfaceInformationImp(parent, name, i, f) | 22 | :InterfaceInformationImp(parent, name, i, f) |
20 | { | 23 | { |
24 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); | ||
25 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | ||
26 | // InterfaceInformationLayout->addMultiCellWidget( con, 7, 7, 0, 1 ); | ||
27 | InterfaceInformationLayout->addWidget( con, 7, 0 ); | ||
28 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | ||
21 | } | 29 | } |
22 | 30 | ||
23 | 31 | ||
24 | 32 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.h b/noncore/settings/networksettings/ppp/interfaceinformationppp.h index 8c6fc0b..68b58ea 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.h +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.h | |||
@@ -1,25 +1,30 @@ | |||
1 | #ifndef INTERFACEINFORMATIONPPP_H | 1 | #ifndef INTERFACEINFORMATIONPPP_H |
2 | #define INTERFACEINFORMATIONPPP_H | 2 | #define INTERFACEINFORMATIONPPP_H |
3 | 3 | ||
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | //#include "interface.h" | 5 | |
6 | 6 | ||
7 | class QWidget; | 7 | class QWidget; |
8 | class Interface; | 8 | class Interface; |
9 | class ConnectWidget; | ||
10 | class ConnectWindow; | ||
9 | 11 | ||
10 | class InterfaceInformationPPP : public InterfaceInformationImp { | 12 | class InterfaceInformationPPP : public InterfaceInformationImp { |
11 | 13 | ||
12 | Q_OBJECT | 14 | Q_OBJECT |
13 | 15 | ||
14 | public: | 16 | public: |
15 | 17 | ||
16 | InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | 18 | InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); |
17 | ~InterfaceInformationPPP(){}; | 19 | ~InterfaceInformationPPP(){}; |
18 | 20 | ||
21 | private: | ||
22 | ConnectWidget *con; | ||
23 | ConnectWindow *con_win; | ||
19 | 24 | ||
20 | }; | 25 | }; |
21 | 26 | ||
22 | #endif | 27 | #endif |
23 | 28 | ||
24 | // addserviceimp.h | 29 | // addserviceimp.h |
25 | 30 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index d9ee3ff..dc24824 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,48 +1,141 @@ | |||
1 | |||
2 | #include <qmessagebox.h> | ||
3 | #define i18n QObject::tr | ||
4 | |||
5 | #include "auth.h" | ||
1 | #include "interfaceppp.h" | 6 | #include "interfaceppp.h" |
2 | #include "modem.h" | 7 | #include "modem.h" |
3 | #include "pppdata.h" | 8 | #include "pppdata.h" |
4 | 9 | ||
5 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
6 | : Interface(parent, name, status), | 11 | : Interface(parent, name, status), |
7 | _modem(0), | 12 | _modemPtr(0), |
8 | _pppdata(0) | 13 | _dataPtr(0) |
9 | { | 14 | { |
10 | qDebug("InterfacePPP::InterfacePPP("); | 15 | qDebug("InterfacePPP::InterfacePPP("); |
11 | } | 16 | } |
12 | 17 | ||
13 | PPPData* InterfacePPP::data() | 18 | PPPData* InterfacePPP::data() |
14 | { | 19 | { |
15 | if (!_pppdata){ | 20 | if (!_dataPtr){ |
16 | _pppdata = new PPPData(); | 21 | qDebug("creating new Data obj"); |
17 | _pppdata->setModemDevice( getInterfaceName() ); | 22 | _dataPtr = new PPPData(); |
18 | _pppdata->setAccount( getHardwareName() ); | 23 | _dataPtr->setModemDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | ||
19 | } | 25 | } |
20 | return _pppdata; | 26 | return _dataPtr; |
21 | } | 27 | } |
22 | 28 | ||
23 | Modem* InterfacePPP::modem() | 29 | Modem* InterfacePPP::modem() |
24 | { | 30 | { |
25 | if (!_modem){ | 31 | if (!_modemPtr){ |
26 | _modem = new Modem( data() ); | 32 | qDebug("creating new modem obj"); |
33 | _modemPtr = new Modem( data() ); | ||
27 | } | 34 | } |
28 | return _modem; | 35 | return _modemPtr; |
29 | } | 36 | } |
30 | 37 | ||
31 | bool InterfacePPP::refresh() | 38 | bool InterfacePPP::refresh() |
32 | { | 39 | { |
33 | qDebug("InterfacePPP::refresh()"); | 40 | qDebug("InterfacePPP::refresh()"); |
41 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | ||
34 | return false; | 42 | return false; |
35 | } | 43 | } |
36 | 44 | ||
37 | void InterfacePPP::start() | 45 | void InterfacePPP::start() |
38 | { | 46 | { |
39 | qDebug("InterfacePPP::start"); | 47 | qDebug("InterfacePPP::start"); |
48 | if (data()->storedPassword() != "" ){ | ||
49 | data()->setPassword(data()->storedPassword()); | ||
50 | }else{ | ||
51 | //FIXME: | ||
52 | qDebug("using dummy password"); | ||
53 | data()->setPassword( "dummy" ); | ||
54 | } | ||
55 | |||
56 | |||
57 | QFileInfo info(pppdPath()); | ||
58 | |||
59 | if(!info.exists()){ | ||
60 | QMessageBox::warning(0, tr("Error"), | ||
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | ||
62 | "Make sure that pppd is installed and " | ||
63 | "that you have entered the correct path.</qt>")); | ||
64 | return; | ||
65 | } | ||
66 | //#if 0 | ||
67 | if(!info.isExecutable()){ | ||
68 | |||
69 | QString string; | ||
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | ||
71 | "Please make sure that you have given " | ||
72 | "setuid permission and that " | ||
73 | "pppd is executable.<br>").arg(pppdPath()); | ||
74 | QMessageBox::warning(0, tr("Error"), string); | ||
75 | return; | ||
76 | |||
77 | } | ||
78 | //#endif | ||
79 | |||
80 | QFileInfo info2(data()->modemDevice()); | ||
81 | |||
82 | if(!info2.exists()){ | ||
83 | QString string; | ||
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | ||
85 | "Please make sure you have setup " | ||
86 | "your modem device properly " | ||
87 | "and/or adjust the location of the modem device on " | ||
88 | "the modem tab of " | ||
89 | "the setup dialog.</qt>").arg(data()->modemDevice()); | ||
90 | QMessageBox::warning(0, tr("Error"), string); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | // if this is a PAP or CHAP account, ensure that username is | ||
95 | // supplied | ||
96 | if(data()->authMethod() == AUTH_PAP || | ||
97 | data()->authMethod() == AUTH_CHAP || | ||
98 | data()->authMethod() == AUTH_PAPCHAP ) { | ||
99 | if(false){ //ID_Edit->text().isEmpty()) { | ||
100 | QMessageBox::warning(0,tr("Error"), | ||
101 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); | ||
102 | // FIXME: return; | ||
103 | } else { | ||
104 | if(!modem()->setSecret(data()->authMethod(), | ||
105 | PPPData::encodeWord(data()->storedUsername()), | ||
106 | PPPData::encodeWord(data()->password())) | ||
107 | ) { | ||
108 | QString s; | ||
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | ||
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | ||
111 | QMessageBox::warning(0, tr("Error"), s); | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (data()->phonenumber().isEmpty()) { | ||
118 | QString s = i18n("You must specify a telephone number!"); | ||
119 | QMessageBox::warning(0, tr("Error"), s); | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | // this->hide(); | ||
124 | |||
125 | QString tit = i18n("Connecting to: %1").arg(data()->accname()); | ||
126 | // con->setCaption(tit); | ||
127 | |||
128 | // con->show(); | ||
129 | |||
130 | |||
131 | emit begin_connect(); | ||
40 | 132 | ||
133 | qDebug("InterfacePPP::start END"); | ||
41 | } | 134 | } |
42 | 135 | ||
43 | void InterfacePPP::stop() | 136 | void InterfacePPP::stop() |
44 | { | 137 | { |
45 | qDebug("InterfacePPP::stop"); | 138 | qDebug("InterfacePPP::stop"); |
46 | 139 | ||
47 | } | 140 | } |
48 | 141 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h index b7477c9..06a4dbf 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.h +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -1,30 +1,33 @@ | |||
1 | #ifndef INTERFACEPPP_H | 1 | #ifndef INTERFACEPPP_H |
2 | #define INTERFACEPPP_H | 2 | #define INTERFACEPPP_H |
3 | 3 | ||
4 | #include "interface.h" | 4 | #include "interface.h" |
5 | 5 | ||
6 | class PPPData; | 6 | class PPPData; |
7 | class Modem; | 7 | class Modem; |
8 | 8 | ||
9 | class InterfacePPP : public Interface | 9 | class InterfacePPP : public Interface |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); | 14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); |
15 | 15 | ||
16 | PPPData* data(); | 16 | PPPData* data(); |
17 | Modem* modem(); | 17 | Modem* modem(); |
18 | 18 | ||
19 | signals: | ||
20 | void begin_connect(); | ||
21 | |||
19 | public slots: | 22 | public slots: |
20 | virtual bool refresh(); | 23 | virtual bool refresh(); |
21 | virtual void start(); | 24 | virtual void start(); |
22 | virtual void stop(); | 25 | virtual void stop(); |
23 | 26 | ||
24 | private: | 27 | private: |
25 | Modem *_modem; | 28 | Modem *_modemPtr; |
26 | PPPData *_pppdata; | 29 | PPPData *_dataPtr; |
27 | }; | 30 | }; |
28 | 31 | ||
29 | 32 | ||
30 | #endif | 33 | #endif |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h index b958862..e0f5237 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.h +++ b/noncore/settings/networksettings/ppp/kpppwidget.h | |||
@@ -1,115 +1,115 @@ | |||
1 | /* | 1 | /* |
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 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> | 10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> |
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 __KPPPWIDGET_H__ | 27 | #ifndef __KPPPWIDGET_H__ |
28 | #define __KPPPWIDGET_H__ | 28 | #define __KPPPWIDGET_H__ |
29 | 29 | ||
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | 31 | ||
32 | #include "conwindow.h" | ||
33 | #include "accounts.h" | 32 | #include "accounts.h" |
34 | #include "connect.h" | 33 | #include "connect.h" |
34 | #include "conwindow.h" | ||
35 | 35 | ||
36 | class QPushButton; | 36 | class QPushButton; |
37 | class Interface; | 37 | class Interface; |
38 | class PPPData; | 38 | class PPPData; |
39 | 39 | ||
40 | class KPPPWidget : public QDialog { | 40 | class KPPPWidget : public QDialog { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | 43 | ||
44 | KPPPWidget(PPPData*, Interface*, QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 ); | 44 | KPPPWidget(PPPData*, Interface*, QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 ); |
45 | ~KPPPWidget(); | 45 | ~KPPPWidget(); |
46 | 46 | ||
47 | void setPW_Edit(const QString &); | 47 | void setPW_Edit(const QString &); |
48 | 48 | ||
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void newdefaultaccount(int); | 51 | void newdefaultaccount(int); |
52 | void beginConnect(); | 52 | void beginConnect(); |
53 | void quitbutton(); | 53 | void quitbutton(); |
54 | void usernameChanged(const QString &); | 54 | void usernameChanged(const QString &); |
55 | void passwordChanged(const QString &); | 55 | void passwordChanged(const QString &); |
56 | void enterPressedInID(); | 56 | void enterPressedInID(); |
57 | void enterPressedInPW(); | 57 | void enterPressedInPW(); |
58 | void saveMyself(); | 58 | void saveMyself(); |
59 | void shutDown(); | 59 | void shutDown(); |
60 | 60 | ||
61 | 61 | ||
62 | public slots: | 62 | public slots: |
63 | void disconnect(); | 63 | void disconnect(); |
64 | void log_window_toggled(bool on); | 64 | void log_window_toggled(bool on); |
65 | 65 | ||
66 | signals: | 66 | signals: |
67 | void begin_connect(); | 67 | void begin_connect(); |
68 | void cmdl_start(); | 68 | void cmdl_start(); |
69 | 69 | ||
70 | public: | 70 | public: |
71 | QCheckBox *log; | 71 | QCheckBox *log; |
72 | bool connected; | 72 | bool connected; |
73 | QString con_speed; | 73 | QString con_speed; |
74 | ConnectWidget *con; | 74 | ConnectWidget *con; |
75 | ConWindow *con_win; | 75 | ConWindow *con_win; |
76 | // PPPStatsDlg *statdlg; | 76 | // PPPStatsDlg *statdlg; |
77 | // AccountingBase *acct; | 77 | // AccountingBase *acct; |
78 | QPushButton *quit_b; | 78 | QPushButton *quit_b; |
79 | //PPPStats *stats; | 79 | //PPPStats *stats; |
80 | 80 | ||
81 | private: | 81 | private: |
82 | // void prepareSetupDialog(); | 82 | // void prepareSetupDialog(); |
83 | void interruptConnection(); | 83 | void interruptConnection(); |
84 | void sigChld(); | 84 | void sigChld(); |
85 | void sigPPPDDied(); | 85 | void sigPPPDDied(); |
86 | QString encodeWord(const QString &s); | 86 | QString encodeWord(const QString &s); |
87 | void showNews (); | 87 | void showNews (); |
88 | 88 | ||
89 | QString ruleset_load_errmsg; | 89 | QString ruleset_load_errmsg; |
90 | PPPData *_pppdata; | 90 | PPPData *_pppdata; |
91 | QPushButton *setup_b; | 91 | QPushButton *setup_b; |
92 | QFrame *fline; | 92 | QFrame *fline; |
93 | QFrame *fline1; | 93 | QFrame *fline1; |
94 | QPushButton *connect_b; | 94 | QPushButton *connect_b; |
95 | QComboBox *connectto_c; | 95 | QComboBox *connectto_c; |
96 | QLabel *ID_Label; | 96 | QLabel *ID_Label; |
97 | QLabel *PW_Label; | 97 | QLabel *PW_Label; |
98 | QLineEdit *ID_Edit; | 98 | QLineEdit *ID_Edit; |
99 | QLineEdit *PW_Edit; | 99 | QLineEdit *PW_Edit; |
100 | QLabel *label1; | 100 | QLabel *label1; |
101 | QLabel *label2; | 101 | QLabel *label2; |
102 | QLabel *label3; | 102 | QLabel *label3; |
103 | QLabel *label4; | 103 | QLabel *label4; |
104 | QLabel *label5; | 104 | QLabel *label5; |
105 | QLabel *label6; | 105 | QLabel *label6; |
106 | QLabel *radio_label; | 106 | QLabel *radio_label; |
107 | 107 | ||
108 | /* QString m_strCmdlAccount; */ | 108 | /* QString m_strCmdlAccount; */ |
109 | /* bool m_bQuitOnDisconnect; */ | 109 | /* bool m_bQuitOnDisconnect; */ |
110 | /* bool m_bCmdlAccount; */ | 110 | /* bool m_bCmdlAccount; */ |
111 | }; | 111 | }; |
112 | 112 | ||
113 | 113 | ||
114 | #endif | 114 | #endif |
115 | 115 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 59d68c9..7a6524f 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -1,1276 +1,1295 @@ | |||
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 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
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 "pppdata.h" | 27 | #include "pppdata.h" |
28 | #include "runtests.h" | 28 | #include "runtests.h" |
29 | #include "devices.h" | 29 | #include "devices.h" |
30 | //#include <klocale.h> | 30 | //#include <klocale.h> |
31 | #define i18n QObject::tr | 31 | #define i18n QObject::tr |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | // #include <klocale.h> | 35 | // #include <klocale.h> |
36 | // #include <kconfig.h> | 36 | // #include <kconfig.h> |
37 | // #include <kmessagebox.h> | 37 | // #include <kmessagebox.h> |
38 | // #include <kapplication.h> | 38 | // #include <kapplication.h> |
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | 40 | ||
41 | #define SEPARATOR -sseepp- | 41 | #define SEPARATOR -sseepp- |
42 | #define SEP QString("%1SEPARATOR%1") | 42 | #define SEP QString("%1SEPARATOR%1") |
43 | 43 | ||
44 | PPPData::PPPData() | 44 | PPPData::PPPData() |
45 | : modemDeviceGroup(-1), | 45 | : modemDeviceGroup(-1), |
46 | highcount(-1), // start out with no entries | 46 | highcount(-1), // start out with no entries |
47 | caccount(-1), // set the current account index also | 47 | caccount(-1), // set the current account index also |
48 | suidprocessid(-1), // process ID of setuid child | 48 | suidprocessid(-1), // process ID of setuid child |
49 | pppdisrunning(false), | 49 | pppdisrunning(false), |
50 | pppderror(0) | 50 | pppderror(0) |
51 | { | 51 | { |
52 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 52 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
53 | 53 | ||
54 | if (highcount > MAX_ACCOUNTS) | 54 | if (highcount > MAX_ACCOUNTS) |
55 | highcount = MAX_ACCOUNTS; | 55 | highcount = MAX_ACCOUNTS; |
56 | 56 | ||
57 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 57 | if(highcount >= 0 && defaultAccount().isEmpty()) { |
58 | setAccountbyIndex(0); | 58 | setAccountbyIndex(0); |
59 | setDefaultAccount(accname()); | 59 | setDefaultAccount(accname()); |
60 | } else if(!setAccount(defaultAccount())) | 60 | } else if(!setAccount(defaultAccount())) |
61 | setDefaultAccount(accname()); | 61 | setDefaultAccount(accname()); |
62 | 62 | ||
63 | // start out with internal debugging disabled | 63 | // start out with internal debugging disabled |
64 | // the user is still free to specify `debug' on his own | 64 | // the user is still free to specify `debug' on his own |
65 | setPPPDebug(false); | 65 | setPPPDebug(false); |
66 | 66 | ||
67 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 67 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
68 | 68 | ||
69 | } | 69 | } |
70 | 70 | ||
71 | Config PPPData::config() | 71 | Config PPPData::config() |
72 | { | 72 | { |
73 | return Config("NetworkSetupPPP"); | 73 | return Config("NetworkSetupPPP"); |
74 | } | 74 | } |
75 | 75 | ||
76 | // | 76 | // |
77 | // save configuration | 77 | // save configuration |
78 | // | 78 | // |
79 | void PPPData::save() | 79 | void PPPData::save() |
80 | { | 80 | { |
81 | qDebug("PPPData saving data"); | 81 | qDebug("PPPData saving data"); |
82 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 82 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
83 | QString key; | 83 | QString key; |
84 | QStringList keys; | 84 | QStringList keys; |
85 | Config cfg = config(); | 85 | Config cfg = config(); |
86 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 86 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
87 | it != stringEntries.end(); ++it ){ | 87 | it != stringEntries.end(); ++it ){ |
88 | QString val = it.data(); | 88 | QString val = it.data(); |
89 | key = it.key(); | 89 | key = it.key(); |
90 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 90 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
91 | keys = QStringList::split( "SEPARATOR", key ); | 91 | keys = QStringList::split( "SEPARATOR", key ); |
92 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 92 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); |
93 | cfg.setGroup(keys[0]); | 93 | cfg.setGroup(keys[0]); |
94 | cfg.writeEntry(keys[1], val); | 94 | cfg.writeEntry(keys[1], val); |
95 | } | 95 | } |
96 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 96 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
97 | it != intEntries.end(); ++it ){ | 97 | it != intEntries.end(); ++it ){ |
98 | int val = it.data(); | 98 | int val = it.data(); |
99 | key = it.key(); | 99 | key = it.key(); |
100 | // qDebug("saving %s -> %i", key.latin1(), val ); | 100 | // qDebug("saving %s -> %i", key.latin1(), val ); |
101 | keys = QStringList::split( "SEPARATOR", key ); | 101 | keys = QStringList::split( "SEPARATOR", key ); |
102 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 102 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); |
103 | cfg.setGroup(keys[0]); | 103 | cfg.setGroup(keys[0]); |
104 | cfg.writeEntry(keys[1], val); | 104 | cfg.writeEntry(keys[1], val); |
105 | } | 105 | } |
106 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 106 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
107 | it != listEntries.end(); ++it ){ | 107 | it != listEntries.end(); ++it ){ |
108 | QStringList val = it.data(); | 108 | QStringList val = it.data(); |
109 | key = it.key(); | 109 | key = it.key(); |
110 | QChar sep = sepEntries[key]; | 110 | QChar sep = sepEntries[key]; |
111 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 111 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); |
112 | keys = QStringList::split( "SEPARATOR", key ); | 112 | keys = QStringList::split( "SEPARATOR", key ); |
113 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | 113 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); |
114 | cfg.setGroup(keys[0]); | 114 | cfg.setGroup(keys[0]); |
115 | cfg.writeEntry(keys[1], val, sep); | 115 | cfg.writeEntry(keys[1], val, sep); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | // | 120 | // |
121 | // cancel changes | 121 | // cancel changes |
122 | // | 122 | // |
123 | void PPPData::cancel() { | 123 | void PPPData::cancel() { |
124 | stringEntries.clear(); | 124 | stringEntries.clear(); |
125 | intEntries.clear(); | 125 | intEntries.clear(); |
126 | listEntries.clear(); | 126 | listEntries.clear(); |
127 | } | 127 | } |
128 | 128 | ||
129 | // functions to read/write date to configuration file | 129 | // functions to read/write date to configuration file |
130 | QString PPPData::readConfig(const QString &group, const QString &key, | 130 | QString PPPData::readConfig(const QString &group, const QString &key, |
131 | const QString &defvalue = "") | 131 | const QString &defvalue = "") |
132 | { | 132 | { |
133 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 133 | qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
134 | QString idx = SEP.arg(group).arg(key); | 134 | QString idx = SEP.arg(group).arg(key); |
135 | if (stringEntries.find(idx) != stringEntries.end()) | 135 | if (stringEntries.find(idx) != stringEntries.end()) |
136 | return stringEntries[idx]; | 136 | return stringEntries[idx]; |
137 | Config cfg = config(); | 137 | Config cfg = config(); |
138 | cfg.setGroup(group); | 138 | cfg.setGroup(group); |
139 | return cfg.readEntry(key, defvalue); | 139 | return cfg.readEntry(key, defvalue); |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | int PPPData::readNumConfig(const QString &group, const QString &key, | 143 | int PPPData::readNumConfig(const QString &group, const QString &key, |
144 | int defvalue) | 144 | int defvalue) |
145 | { | 145 | { |
146 | QString idx = SEP.arg(group).arg(key); | 146 | QString idx = SEP.arg(group).arg(key); |
147 | if (intEntries.find(idx) != intEntries.end()) | 147 | if (intEntries.find(idx) != intEntries.end()) |
148 | return intEntries[idx]; | 148 | return intEntries[idx]; |
149 | Config cfg = config(); | 149 | Config cfg = config(); |
150 | cfg.setGroup(group); | 150 | cfg.setGroup(group); |
151 | return cfg.readNumEntry(key, defvalue); | 151 | return cfg.readNumEntry(key, defvalue); |
152 | 152 | ||
153 | // if (config) { | 153 | // if (config) { |
154 | // config->setGroup(group); | 154 | // config->setGroup(group); |
155 | // return config->readNumEntry(key, defvalue); | 155 | // return config->readNumEntry(key, defvalue); |
156 | // } else | 156 | // } else |
157 | // return defvalue; | 157 | // return defvalue; |
158 | 158 | ||
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | bool PPPData::readListConfig(const QString &group, const QString &key, | 162 | bool PPPData::readListConfig(const QString &group, const QString &key, |
163 | QStringList &list, char sep) { | 163 | QStringList &list, char sep) { |
164 | list.clear(); | 164 | list.clear(); |
165 | QString idx = SEP.arg(group).arg(key); | 165 | QString idx = SEP.arg(group).arg(key); |
166 | if (listEntries.find(idx) != listEntries.end()){ | 166 | if (listEntries.find(idx) != listEntries.end()){ |
167 | list = listEntries[idx]; | 167 | list = listEntries[idx]; |
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | Config cfg = config(); | 170 | Config cfg = config(); |
171 | cfg.setGroup(group); | 171 | cfg.setGroup(group); |
172 | list = cfg.readListEntry(key, sep); | 172 | list = cfg.readListEntry(key, sep); |
173 | if (list.count() > 0) return true; | 173 | if (list.count() > 0) return true; |
174 | return false; | 174 | return false; |
175 | 175 | ||
176 | // if (config) { | 176 | // if (config) { |
177 | // config->setGroup(group); | 177 | // config->setGroup(group); |
178 | // list = config->readListEntry(key, sep); | 178 | // list = config->readListEntry(key, sep); |
179 | // return true; | 179 | // return true; |
180 | // } else | 180 | // } else |
181 | // return false; | 181 | // return false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void PPPData::writeConfig(const QString &group, const QString &key, | 185 | void PPPData::writeConfig(const QString &group, const QString &key, |
186 | const QString &value) { | 186 | const QString &value) { |
187 | stringEntries.insert( SEP.arg(group).arg(key), value ); | 187 | stringEntries.insert( SEP.arg(group).arg(key), value ); |
188 | // if (config) { | 188 | // if (config) { |
189 | // config->setGroup(group); | 189 | // config->setGroup(group); |
190 | // config->writeEntry(key, value); | 190 | // config->writeEntry(key, value); |
191 | // } | 191 | // } |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | void PPPData::writeConfig(const QString &group, const QString &key, int value) | 195 | void PPPData::writeConfig(const QString &group, const QString &key, int value) |
196 | { | 196 | { |
197 | intEntries.insert( SEP.arg(group).arg(key), value ); | 197 | intEntries.insert( SEP.arg(group).arg(key), value ); |
198 | // if (config) { | 198 | // if (config) { |
199 | // config->setGroup(group); | 199 | // config->setGroup(group); |
200 | // config->writeEntry(key, value); | 200 | // config->writeEntry(key, value); |
201 | // } | 201 | // } |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void PPPData::writeListConfig(const QString &group, const QString &key, | 205 | void PPPData::writeListConfig(const QString &group, const QString &key, |
206 | QStringList &list, char sep) | 206 | QStringList &list, char sep) |
207 | { | 207 | { |
208 | listEntries.insert( SEP.arg(group).arg(key), list ); | 208 | listEntries.insert( SEP.arg(group).arg(key), list ); |
209 | sepEntries.insert( SEP.arg(group).arg(key), sep ); | 209 | sepEntries.insert( SEP.arg(group).arg(key), sep ); |
210 | // if (config) { | 210 | // if (config) { |
211 | // config->setGroup(group); | 211 | // config->setGroup(group); |
212 | // config->writeEntry(key, list, sep); | 212 | // config->writeEntry(key, list, sep); |
213 | // } | 213 | // } |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | // | 217 | // |
218 | // functions to set/return general information | 218 | // functions to set/return general information |
219 | // | 219 | // |
220 | QString PPPData::password() const { | 220 | QString PPPData::password() const { |
221 | return passwd; | 221 | return passwd; |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void PPPData::setPassword(const QString &pw) { | 225 | void PPPData::setPassword(const QString &pw) { |
226 | passwd = pw; | 226 | passwd = pw; |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | const QString PPPData::defaultAccount() { | 230 | const QString PPPData::defaultAccount() { |
231 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | 231 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | void PPPData::setDefaultAccount(const QString &n) { | 235 | void PPPData::setDefaultAccount(const QString &n) { |
236 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | 236 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); |
237 | 237 | ||
238 | //now set the current account index to the default account | 238 | //now set the current account index to the default account |
239 | setAccount(defaultAccount()); | 239 | setAccount(defaultAccount()); |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | bool PPPData::get_show_clock_on_caption() { | 243 | bool PPPData::get_show_clock_on_caption() { |
244 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | 244 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PPPData::set_show_clock_on_caption(bool set) { | 248 | void PPPData::set_show_clock_on_caption(bool set) { |
249 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 249 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
250 | } | 250 | } |
251 | 251 | ||
252 | 252 | ||
253 | bool PPPData::get_xserver_exit_disconnect() { | 253 | bool PPPData::get_xserver_exit_disconnect() { |
254 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 254 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void PPPData::setPPPDebug(bool set) { | 258 | void PPPData::setPPPDebug(bool set) { |
259 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 259 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | bool PPPData::getPPPDebug() { | 263 | bool PPPData::getPPPDebug() { |
264 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 264 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | void PPPData::set_xserver_exit_disconnect(bool set) { | 268 | void PPPData::set_xserver_exit_disconnect(bool set) { |
269 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 269 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | bool PPPData::quit_on_disconnect() { | 273 | bool PPPData::quit_on_disconnect() { |
274 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 274 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | void PPPData::set_quit_on_disconnect(bool set) { | 278 | void PPPData::set_quit_on_disconnect(bool set) { |
279 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 279 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | bool PPPData::get_show_log_window() { | 283 | bool PPPData::get_show_log_window() { |
284 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 284 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | void PPPData::set_show_log_window(bool set) { | 288 | void PPPData::set_show_log_window(bool set) { |
289 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 289 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | bool PPPData::automatic_redial() { | 293 | bool PPPData::automatic_redial() { |
294 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 294 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void PPPData::set_automatic_redial(bool set) { | 298 | void PPPData::set_automatic_redial(bool set) { |
299 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 299 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | // bool PPPData::get_iconify_on_connect() { | 303 | // bool PPPData::get_iconify_on_connect() { |
304 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 304 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
305 | // } | 305 | // } |
306 | 306 | ||
307 | 307 | ||
308 | // void PPPData::set_iconify_on_connect(bool set) { | 308 | // void PPPData::set_iconify_on_connect(bool set) { |
309 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 309 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
310 | // } | 310 | // } |
311 | 311 | ||
312 | 312 | ||
313 | // bool PPPData::get_dock_into_panel() { | 313 | // bool PPPData::get_dock_into_panel() { |
314 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 314 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
315 | // } | 315 | // } |
316 | 316 | ||
317 | 317 | ||
318 | // void PPPData::set_dock_into_panel(bool set) { | 318 | // void PPPData::set_dock_into_panel(bool set) { |
319 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 319 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
320 | // } | 320 | // } |
321 | 321 | ||
322 | 322 | ||
323 | QString PPPData::pppdVersion() { | 323 | QString PPPData::pppdVersion() { |
324 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 324 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
325 | } | 325 | } |
326 | 326 | ||
327 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 327 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
328 | // check if pppd version fulfills minimum requirement | 328 | // check if pppd version fulfills minimum requirement |
329 | return (pppdVer > ver | 329 | return (pppdVer > ver |
330 | || (pppdVer == ver && pppdMod > mod) | 330 | || (pppdVer == ver && pppdMod > mod) |
331 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 331 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
332 | } | 332 | } |
333 | 333 | ||
334 | int PPPData::pppdTimeout() { | 334 | int PPPData::pppdTimeout() { |
335 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 335 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | void PPPData::setpppdTimeout(int n) { | 339 | void PPPData::setpppdTimeout(int n) { |
340 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 340 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | const QString PPPData::modemDevice() { | 344 | const QString PPPData::modemDevice() { |
345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | bool PPPData::setModemDevice(const QString &n) { | 349 | bool PPPData::setModemDevice(const QString &n) { |
350 | qDebug("Setting modem dev to >%s<", n.latin1()); | ||
350 | bool ret = false; | 351 | bool ret = false; |
351 | for (int i = 0; devices[i]; i++) | 352 | for (int i = 0; devices[i]; i++) |
352 | if (devices[i] == n){ | 353 | if (devices[i] == n){ |
353 | modemDeviceGroup = i; | 354 | modemDeviceGroup = i; |
354 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 355 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
355 | ret = true; | 356 | ret = true; |
356 | } | 357 | } |
358 | qDebug(ret?"SUCCESS":"FAILURE"); | ||
357 | return ret; | 359 | return ret; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | const QString PPPData::flowcontrol() { | 363 | const QString PPPData::flowcontrol() { |
362 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 364 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
363 | } | 365 | } |
364 | 366 | ||
365 | 367 | ||
366 | void PPPData::setFlowcontrol(const QString &n) { | 368 | void PPPData::setFlowcontrol(const QString &n) { |
367 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 369 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
368 | } | 370 | } |
369 | 371 | ||
370 | 372 | ||
371 | const QString PPPData::speed() { | 373 | const QString PPPData::speed() { |
372 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 374 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
373 | // undo the damage of a bug in former versions. It left an empty Speed= | 375 | // undo the damage of a bug in former versions. It left an empty Speed= |
374 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 376 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
375 | // pppd wouldn't receive the speed via the command line. | 377 | // pppd wouldn't receive the speed via the command line. |
376 | if(s.toUInt() == 0) | 378 | if(s.toUInt() == 0) |
377 | s = "57600"; | 379 | s = "57600"; |
378 | return s; | 380 | return s; |
379 | } | 381 | } |
380 | 382 | ||
381 | 383 | ||
382 | void PPPData::setSpeed(const QString &n) { | 384 | void PPPData::setSpeed(const QString &n) { |
383 | writeConfig(modemGroup(), SPEED_KEY, n); | 385 | writeConfig(modemGroup(), SPEED_KEY, n); |
384 | } | 386 | } |
385 | 387 | ||
386 | 388 | ||
387 | #if 0 | 389 | #if 0 |
388 | void PPPData::setUseCDLine(const int n) { | 390 | void PPPData::setUseCDLine(const int n) { |
389 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 391 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
390 | } | 392 | } |
391 | 393 | ||
392 | 394 | ||
393 | int PPPData::UseCDLine() { | 395 | int PPPData::UseCDLine() { |
394 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 396 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
395 | } | 397 | } |
396 | #endif | 398 | #endif |
397 | 399 | ||
398 | const QString PPPData::modemEscapeStr() { | 400 | const QString PPPData::modemEscapeStr() { |
399 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 401 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
400 | } | 402 | } |
401 | 403 | ||
402 | 404 | ||
403 | void PPPData::setModemEscapeStr(const QString &n) { | 405 | void PPPData::setModemEscapeStr(const QString &n) { |
404 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 406 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
405 | } | 407 | } |
406 | 408 | ||
407 | 409 | ||
408 | const QString PPPData::modemEscapeResp() { | 410 | const QString PPPData::modemEscapeResp() { |
409 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 411 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
410 | } | 412 | } |
411 | 413 | ||
412 | 414 | ||
413 | void PPPData::setModemEscapeResp(const QString &n) { | 415 | void PPPData::setModemEscapeResp(const QString &n) { |
414 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 416 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
415 | } | 417 | } |
416 | 418 | ||
417 | 419 | ||
418 | int PPPData::modemEscapeGuardTime() { | 420 | int PPPData::modemEscapeGuardTime() { |
419 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 421 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
420 | } | 422 | } |
421 | 423 | ||
422 | 424 | ||
423 | void PPPData::setModemEscapeGuardTime(int n) { | 425 | void PPPData::setModemEscapeGuardTime(int n) { |
424 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 426 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
425 | } | 427 | } |
426 | 428 | ||
427 | 429 | ||
428 | bool PPPData::modemLockFile() { | 430 | bool PPPData::modemLockFile() { |
429 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 431 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
430 | } | 432 | } |
431 | 433 | ||
432 | 434 | ||
433 | void PPPData::setModemLockFile(bool set) { | 435 | void PPPData::setModemLockFile(bool set) { |
434 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 436 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
435 | } | 437 | } |
436 | 438 | ||
437 | 439 | ||
438 | int PPPData::modemTimeout() { | 440 | int PPPData::modemTimeout() { |
439 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 441 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
440 | } | 442 | } |
441 | 443 | ||
442 | 444 | ||
443 | void PPPData::setModemTimeout(int n) { | 445 | void PPPData::setModemTimeout(int n) { |
444 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 446 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
445 | } | 447 | } |
446 | 448 | ||
447 | 449 | ||
448 | int PPPData::modemToneDuration() { | 450 | int PPPData::modemToneDuration() { |
449 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 451 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
450 | } | 452 | } |
451 | 453 | ||
452 | 454 | ||
453 | void PPPData::setModemToneDuration(int n) { | 455 | void PPPData::setModemToneDuration(int n) { |
454 | writeConfig(modemGroup(), TONEDURATION_KEY, n); | 456 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
455 | } | 457 | } |
456 | 458 | ||
457 | 459 | ||
458 | int PPPData::busyWait() { | 460 | int PPPData::busyWait() { |
459 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); | 461 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
460 | } | 462 | } |
461 | 463 | ||
462 | 464 | ||
463 | void PPPData::setbusyWait(int n) { | 465 | void PPPData::setbusyWait(int n) { |
464 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); | 466 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); |
465 | } | 467 | } |
466 | 468 | ||
467 | 469 | ||
468 | // | 470 | // |
469 | //Advanced "Modem" dialog | 471 | //Advanced "Modem" dialog |
470 | // | 472 | // |
471 | // defaults: InitString=ATZ, InitString1="" etc. | 473 | // defaults: InitString=ATZ, InitString1="" etc. |
472 | const QString PPPData::modemInitStr(int i) { | 474 | const QString PPPData::modemInitStr(int i) { |
473 | assert(i >= 0 && i < NumInitStrings); | 475 | assert(i >= 0 && i < NumInitStrings); |
474 | if(i == 0) | 476 | if(i == 0) |
475 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); | 477 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); |
476 | else | 478 | else |
477 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); | 479 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); |
478 | } | 480 | } |
479 | 481 | ||
480 | 482 | ||
481 | void PPPData::setModemInitStr(int i, const QString &n) { | 483 | void PPPData::setModemInitStr(int i, const QString &n) { |
482 | assert(i >= 0 && i < NumInitStrings); | 484 | assert(i >= 0 && i < NumInitStrings); |
483 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | 485 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); |
484 | writeConfig(modemGroup(), k, n); | 486 | writeConfig(modemGroup(), k, n); |
485 | } | 487 | } |
486 | 488 | ||
487 | 489 | ||
488 | const QString PPPData::modemInitResp() { | 490 | const QString PPPData::modemInitResp() { |
489 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); | 491 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); |
490 | } | 492 | } |
491 | 493 | ||
492 | 494 | ||
493 | void PPPData::setModemInitResp(const QString &n) { | 495 | void PPPData::setModemInitResp(const QString &n) { |
494 | writeConfig(modemGroup(), INITRESP_KEY, n); | 496 | writeConfig(modemGroup(), INITRESP_KEY, n); |
495 | } | 497 | } |
496 | 498 | ||
497 | 499 | ||
498 | int PPPData::modemPreInitDelay() { | 500 | int PPPData::modemPreInitDelay() { |
499 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); | 501 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); |
500 | } | 502 | } |
501 | 503 | ||
502 | 504 | ||
503 | void PPPData::setModemPreInitDelay(int n) { | 505 | void PPPData::setModemPreInitDelay(int n) { |
504 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); | 506 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); |
505 | } | 507 | } |
506 | 508 | ||
507 | 509 | ||
508 | int PPPData::modemInitDelay() { | 510 | int PPPData::modemInitDelay() { |
509 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); | 511 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); |
510 | } | 512 | } |
511 | 513 | ||
512 | 514 | ||
513 | void PPPData::setModemInitDelay(int n) { | 515 | void PPPData::setModemInitDelay(int n) { |
514 | writeConfig(modemGroup(), INITDELAY_KEY, n); | 516 | writeConfig(modemGroup(), INITDELAY_KEY, n); |
515 | } | 517 | } |
516 | 518 | ||
517 | QString PPPData::modemNoDialToneDetectionStr() { | 519 | QString PPPData::modemNoDialToneDetectionStr() { |
518 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); | 520 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); |
519 | } | 521 | } |
520 | 522 | ||
521 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | 523 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { |
522 | writeConfig(modemGroup(), NODTDETECT_KEY, n); | 524 | writeConfig(modemGroup(), NODTDETECT_KEY, n); |
523 | } | 525 | } |
524 | 526 | ||
525 | const QString PPPData::modemDialStr() { | 527 | const QString PPPData::modemDialStr() { |
526 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); | 528 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); |
527 | } | 529 | } |
528 | 530 | ||
529 | 531 | ||
530 | void PPPData::setModemDialStr(const QString &n) { | 532 | void PPPData::setModemDialStr(const QString &n) { |
531 | writeConfig(modemGroup(), DIALSTR_KEY, n); | 533 | writeConfig(modemGroup(), DIALSTR_KEY, n); |
532 | } | 534 | } |
533 | 535 | ||
534 | 536 | ||
535 | const QString PPPData::modemConnectResp() { | 537 | const QString PPPData::modemConnectResp() { |
536 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); | 538 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); |
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | void PPPData::setModemConnectResp(const QString &n) { | 542 | void PPPData::setModemConnectResp(const QString &n) { |
541 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); | 543 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); |
542 | } | 544 | } |
543 | 545 | ||
544 | 546 | ||
545 | const QString PPPData::modemBusyResp() { | 547 | const QString PPPData::modemBusyResp() { |
546 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); | 548 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); |
547 | } | 549 | } |
548 | 550 | ||
549 | 551 | ||
550 | void PPPData::setModemBusyResp(const QString &n) { | 552 | void PPPData::setModemBusyResp(const QString &n) { |
551 | writeConfig(modemGroup(), BUSYRESP_KEY, n); | 553 | writeConfig(modemGroup(), BUSYRESP_KEY, n); |
552 | } | 554 | } |
553 | 555 | ||
554 | 556 | ||
555 | const QString PPPData::modemNoCarrierResp() { | 557 | const QString PPPData::modemNoCarrierResp() { |
556 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); | 558 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); |
557 | } | 559 | } |
558 | 560 | ||
559 | 561 | ||
560 | void PPPData::setModemNoCarrierResp(const QString &n) { | 562 | void PPPData::setModemNoCarrierResp(const QString &n) { |
561 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); | 563 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); |
562 | } | 564 | } |
563 | 565 | ||
564 | 566 | ||
565 | const QString PPPData::modemNoDialtoneResp() { | 567 | const QString PPPData::modemNoDialtoneResp() { |
566 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); | 568 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); |
567 | } | 569 | } |
568 | 570 | ||
569 | 571 | ||
570 | void PPPData::setModemNoDialtoneResp(const QString &n) { | 572 | void PPPData::setModemNoDialtoneResp(const QString &n) { |
571 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); | 573 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); |
572 | } | 574 | } |
573 | 575 | ||
574 | 576 | ||
575 | const QString PPPData::modemHangupStr() { | 577 | const QString PPPData::modemHangupStr() { |
576 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); | 578 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); |
577 | } | 579 | } |
578 | 580 | ||
579 | void PPPData::setModemHangupStr(const QString &n) { | 581 | void PPPData::setModemHangupStr(const QString &n) { |
580 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); | 582 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); |
581 | } | 583 | } |
582 | 584 | ||
583 | 585 | ||
584 | const QString PPPData::modemHangupResp() { | 586 | const QString PPPData::modemHangupResp() { |
585 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); | 587 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); |
586 | } | 588 | } |
587 | 589 | ||
588 | void PPPData::setModemHangupResp(const QString &n) { | 590 | void PPPData::setModemHangupResp(const QString &n) { |
589 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); | 591 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); |
590 | } | 592 | } |
591 | 593 | ||
592 | 594 | ||
593 | const QString PPPData::modemAnswerStr() { | 595 | const QString PPPData::modemAnswerStr() { |
594 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); | 596 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); |
595 | } | 597 | } |
596 | 598 | ||
597 | 599 | ||
598 | QString PPPData::volumeOff() { | 600 | QString PPPData::volumeOff() { |
599 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); | 601 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
600 | } | 602 | } |
601 | 603 | ||
602 | 604 | ||
603 | void PPPData::setVolumeOff(const QString &s) { | 605 | void PPPData::setVolumeOff(const QString &s) { |
604 | writeConfig(modemGroup(), VOLUME_OFF, s); | 606 | writeConfig(modemGroup(), VOLUME_OFF, s); |
605 | } | 607 | } |
606 | 608 | ||
607 | 609 | ||
608 | QString PPPData::volumeMedium() { | 610 | QString PPPData::volumeMedium() { |
609 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); | 611 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
610 | } | 612 | } |
611 | 613 | ||
612 | 614 | ||
613 | void PPPData::setVolumeMedium(const QString &s) { | 615 | void PPPData::setVolumeMedium(const QString &s) { |
614 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); | 616 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
615 | } | 617 | } |
616 | 618 | ||
617 | 619 | ||
618 | QString PPPData::volumeHigh() { | 620 | QString PPPData::volumeHigh() { |
619 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); | 621 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
620 | if(tmp == "M1L4") | 622 | if(tmp == "M1L4") |
621 | tmp = "M1L3"; | 623 | tmp = "M1L3"; |
622 | return tmp; | 624 | return tmp; |
623 | } | 625 | } |
624 | 626 | ||
625 | 627 | ||
626 | void PPPData::setVolumeHigh(const QString &s) { | 628 | void PPPData::setVolumeHigh(const QString &s) { |
627 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 629 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
628 | } | 630 | } |
629 | 631 | ||
630 | 632 | ||
631 | QString PPPData::volumeInitString() { | 633 | QString PPPData::volumeInitString() { |
632 | QString s; | 634 | QString s; |
633 | 635 | ||
634 | switch(volume()) { | 636 | switch(volume()) { |
635 | case 0: | 637 | case 0: |
636 | s = volumeOff(); | 638 | s = volumeOff(); |
637 | break; | 639 | break; |
638 | case 1: | 640 | case 1: |
639 | s = volumeMedium(); | 641 | s = volumeMedium(); |
640 | break; | 642 | break; |
641 | case 2: | 643 | case 2: |
642 | s = volumeHigh(); | 644 | s = volumeHigh(); |
643 | break; | 645 | break; |
644 | default: | 646 | default: |
645 | s = volumeMedium(); | 647 | s = volumeMedium(); |
646 | } | 648 | } |
647 | 649 | ||
648 | return s; | 650 | return s; |
649 | } | 651 | } |
650 | 652 | ||
651 | 653 | ||
652 | int PPPData::volume() { | 654 | int PPPData::volume() { |
653 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 655 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
654 | } | 656 | } |
655 | 657 | ||
656 | 658 | ||
657 | void PPPData::setVolume(int i) { | 659 | void PPPData::setVolume(int i) { |
658 | writeConfig(modemGroup(), VOLUME_KEY, i); | 660 | writeConfig(modemGroup(), VOLUME_KEY, i); |
659 | } | 661 | } |
660 | 662 | ||
661 | int PPPData::waitForDialTone() { | 663 | int PPPData::waitForDialTone() { |
662 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 664 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
663 | } | 665 | } |
664 | 666 | ||
665 | void PPPData::setWaitForDialTone(int i) { | 667 | void PPPData::setWaitForDialTone(int i) { |
666 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 668 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
667 | } | 669 | } |
668 | 670 | ||
669 | void PPPData::setModemAnswerStr(const QString &n) { | 671 | void PPPData::setModemAnswerStr(const QString &n) { |
670 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 672 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
671 | } | 673 | } |
672 | 674 | ||
673 | 675 | ||
674 | const QString PPPData::modemRingResp() { | 676 | const QString PPPData::modemRingResp() { |
675 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 677 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
676 | } | 678 | } |
677 | 679 | ||
678 | 680 | ||
679 | void PPPData::setModemRingResp(const QString &n) { | 681 | void PPPData::setModemRingResp(const QString &n) { |
680 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 682 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
681 | } | 683 | } |
682 | 684 | ||
683 | 685 | ||
684 | const QString PPPData::modemAnswerResp() { | 686 | const QString PPPData::modemAnswerResp() { |
685 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 687 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
686 | } | 688 | } |
687 | 689 | ||
688 | 690 | ||
689 | void PPPData::setModemAnswerResp(const QString &n) { | 691 | void PPPData::setModemAnswerResp(const QString &n) { |
690 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 692 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
691 | } | 693 | } |
692 | 694 | ||
693 | 695 | ||
694 | const QString PPPData::enter() { | 696 | const QString PPPData::enter() { |
695 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 697 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
696 | } | 698 | } |
697 | 699 | ||
698 | 700 | ||
699 | void PPPData::setEnter(const QString &n) { | 701 | void PPPData::setEnter(const QString &n) { |
700 | writeConfig(modemGroup(), ENTER_KEY, n); | 702 | writeConfig(modemGroup(), ENTER_KEY, n); |
701 | } | 703 | } |
702 | 704 | ||
703 | 705 | ||
704 | // | 706 | // |
705 | // functions to set/return account information | 707 | // functions to set/return account information |
706 | // | 708 | // |
707 | 709 | ||
708 | //returns number of accounts | 710 | //returns number of accounts |
709 | int PPPData::count() const { | 711 | int PPPData::count() const { |
710 | return highcount + 1; | 712 | return highcount + 1; |
711 | } | 713 | } |
712 | 714 | ||
713 | 715 | ||
714 | bool PPPData::setAccount(const QString &aname) { | 716 | bool PPPData::setAccount(const QString &aname) { |
717 | qDebug("setting account to >%s<", aname.latin1()); | ||
715 | for(int i = 0; i <= highcount; i++) { | 718 | for(int i = 0; i <= highcount; i++) { |
716 | setAccountbyIndex(i); | 719 | setAccountbyIndex(i); |
717 | if(accname() == aname) { | 720 | if(accname() == aname) { |
718 | caccount = i; | 721 | caccount = i; |
722 | qDebug("SUCCESS"); | ||
719 | return true; | 723 | return true; |
720 | } | 724 | } |
721 | } | 725 | } |
726 | qDebug("FAILURE"); | ||
722 | return false; | 727 | return false; |
723 | } | 728 | } |
724 | 729 | ||
725 | 730 | ||
726 | bool PPPData::setAccountbyIndex(int i) { | 731 | bool PPPData::setAccountbyIndex(int i) { |
727 | if(i >= 0 && i <= highcount) { | 732 | if(i >= 0 && i <= highcount) { |
728 | caccount = i; | 733 | caccount = i; |
729 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 734 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
730 | return true; | 735 | return true; |
731 | } | 736 | } |
732 | return false; | 737 | return false; |
733 | } | 738 | } |
734 | 739 | ||
735 | 740 | ||
736 | bool PPPData::isUniqueAccname(const QString &n) { | 741 | bool PPPData::isUniqueAccname(const QString &n) { |
737 | int current = caccount; | 742 | int current = caccount; |
738 | for(int i=0; i <= highcount; i++) { | 743 | for(int i=0; i <= highcount; i++) { |
739 | setAccountbyIndex(i); | 744 | setAccountbyIndex(i); |
740 | if(accname() == n && i != current) { | 745 | if(accname() == n && i != current) { |
741 | setAccountbyIndex(current); | 746 | setAccountbyIndex(current); |
742 | return false; | 747 | return false; |
743 | } | 748 | } |
744 | } | 749 | } |
745 | setAccountbyIndex(current); | 750 | setAccountbyIndex(current); |
746 | return true; | 751 | return true; |
747 | } | 752 | } |
748 | 753 | ||
749 | 754 | ||
750 | bool PPPData::deleteAccount() { | 755 | bool PPPData::deleteAccount() { |
751 | //FIXME: | 756 | //FIXME: |
752 | // if(caccount < 0) | 757 | // if(caccount < 0) |
753 | return false; | 758 | return false; |
754 | 759 | ||
755 | // QMap <QString, QString> map; | 760 | // QMap <QString, QString> map; |
756 | // QMap <QString, QString>::Iterator it; | 761 | // QMap <QString, QString>::Iterator it; |
757 | 762 | ||
758 | // // set all entries of the current account to "" | 763 | // // set all entries of the current account to "" |
759 | // map = config->entryMap(cgroup); | 764 | // map = config->entryMap(cgroup); |
760 | // it = map.begin(); | 765 | // it = map.begin(); |
761 | // while (it != map.end()) { | 766 | // while (it != map.end()) { |
762 | // config->writeEntry(it.key(), ""); | 767 | // config->writeEntry(it.key(), ""); |
763 | // it++; | 768 | // it++; |
764 | // } | 769 | // } |
765 | 770 | ||
766 | // // shift the succeeding accounts | 771 | // // shift the succeeding accounts |
767 | // for(int i = caccount+1; i <= highcount; i++) { | 772 | // for(int i = caccount+1; i <= highcount; i++) { |
768 | // setAccountbyIndex(i); | 773 | // setAccountbyIndex(i); |
769 | // map = config->entryMap(cgroup); | 774 | // map = config->entryMap(cgroup); |
770 | // it = map.begin(); | 775 | // it = map.begin(); |
771 | // setAccountbyIndex(i-1); | 776 | // setAccountbyIndex(i-1); |
772 | // config->setGroup(cgroup); | 777 | // config->setGroup(cgroup); |
773 | // while (it != map.end()) { | 778 | // while (it != map.end()) { |
774 | // config->writeEntry(it.key(), *it); | 779 | // config->writeEntry(it.key(), *it); |
775 | // it++; | 780 | // it++; |
776 | // } | 781 | // } |
777 | // } | 782 | // } |
778 | 783 | ||
779 | // // make sure the top account is cleared | 784 | // // make sure the top account is cleared |
780 | // setAccountbyIndex(highcount); | 785 | // setAccountbyIndex(highcount); |
781 | // map = config->entryMap(cgroup); | 786 | // map = config->entryMap(cgroup); |
782 | // it = map.begin(); | 787 | // it = map.begin(); |
783 | // config->setGroup(cgroup); | 788 | // config->setGroup(cgroup); |
784 | // while (it.key() != QString::null) { | 789 | // while (it.key() != QString::null) { |
785 | // config->writeEntry(it.key(), ""); | 790 | // config->writeEntry(it.key(), ""); |
786 | // it++; | 791 | // it++; |
787 | // } | 792 | // } |
788 | 793 | ||
789 | // highcount--; | 794 | // highcount--; |
790 | // if(caccount > highcount) | 795 | // if(caccount > highcount) |
791 | // caccount = highcount; | 796 | // caccount = highcount; |
792 | 797 | ||
793 | // setAccountbyIndex(caccount); | 798 | // setAccountbyIndex(caccount); |
794 | 799 | ||
795 | // return true; | 800 | // return true; |
796 | } | 801 | } |
797 | 802 | ||
798 | 803 | ||
799 | bool PPPData::deleteAccount(const QString &aname) { | 804 | bool PPPData::deleteAccount(const QString &aname) { |
800 | if(!setAccount(aname)) | 805 | if(!setAccount(aname)) |
801 | return false; | 806 | return false; |
802 | 807 | ||
803 | deleteAccount(); | 808 | deleteAccount(); |
804 | 809 | ||
805 | return true; | 810 | return true; |
806 | } | 811 | } |
807 | 812 | ||
808 | 813 | ||
809 | int PPPData::newaccount() { | 814 | int PPPData::newaccount() { |
810 | 815 | ||
811 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 816 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
812 | // if(!config) open(); | 817 | // if(!config) open(); |
813 | if (highcount >= MAX_ACCOUNTS) return -1; | 818 | if (highcount >= MAX_ACCOUNTS) return -1; |
814 | 819 | ||
815 | highcount++; | 820 | highcount++; |
816 | setAccountbyIndex(highcount); | 821 | setAccountbyIndex(highcount); |
817 | 822 | ||
818 | setpppdArgumentDefaults(); | 823 | setpppdArgumentDefaults(); |
819 | qDebug("PPPData::newaccount -> %i",caccount); | 824 | qDebug("PPPData::newaccount -> %i",caccount); |
820 | return caccount; | 825 | return caccount; |
821 | } | 826 | } |
822 | 827 | ||
823 | int PPPData::copyaccount(int i) { | 828 | int PPPData::copyaccount(int i) { |
824 | // FIXME | 829 | // FIXME |
825 | // if(highcount >= MAX_ACCOUNTS) | 830 | // if(highcount >= MAX_ACCOUNTS) |
826 | return -1; | 831 | return -1; |
827 | 832 | ||
828 | // setAccountbyIndex(i); | 833 | // setAccountbyIndex(i); |
829 | 834 | ||
830 | // QMap <QString, QString> map = config->entryMap(cgroup); | 835 | // QMap <QString, QString> map = config->entryMap(cgroup); |
831 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 836 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
832 | 837 | ||
833 | // QString newname = i18n("%1_copy").arg(accname()); | 838 | // QString newname = i18n("%1_copy").arg(accname()); |
834 | 839 | ||
835 | // newaccount(); | 840 | // newaccount(); |
836 | 841 | ||
837 | // while (it != map.end()) { | 842 | // while (it != map.end()) { |
838 | // config->writeEntry(it.key(), *it); | 843 | // config->writeEntry(it.key(), *it); |
839 | // it++; | 844 | // it++; |
840 | // } | 845 | // } |
841 | 846 | ||
842 | // setAccname(newname); | 847 | // setAccname(newname); |
843 | 848 | ||
844 | // return caccount; | 849 | // return caccount; |
845 | } | 850 | } |
846 | 851 | ||
847 | 852 | ||
848 | const QString PPPData::accname() { | 853 | const QString PPPData::accname() { |
849 | return readConfig(cgroup, NAME_KEY); | 854 | return readConfig(cgroup, NAME_KEY); |
850 | } | 855 | } |
851 | 856 | ||
852 | void PPPData::setAccname(const QString &n) { | 857 | void PPPData::setAccname(const QString &n) { |
853 | if(!cgroup.isNull()) { | 858 | if(!cgroup.isNull()) { |
854 | // are we manipulating the default account's name ? then change it, too. | 859 | // are we manipulating the default account's name ? then change it, too. |
855 | bool def = accname() == defaultAccount(); | 860 | bool def = accname() == defaultAccount(); |
856 | writeConfig(cgroup, NAME_KEY, n); | 861 | writeConfig(cgroup, NAME_KEY, n); |
857 | if (def) | 862 | if (def) |
858 | setDefaultAccount(n); | 863 | setDefaultAccount(n); |
859 | } | 864 | } |
860 | } | 865 | } |
861 | 866 | ||
862 | 867 | ||
863 | #define SEPARATOR_CHAR '&' | 868 | #define SEPARATOR_CHAR '&' |
864 | QStringList &PPPData::phonenumbers() { | 869 | QStringList &PPPData::phonenumbers() { |
865 | 870 | ||
866 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 871 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
867 | return phonelist; | 872 | return phonelist; |
868 | 873 | ||
869 | } | 874 | } |
870 | 875 | ||
871 | 876 | ||
872 | const QString PPPData::phonenumber() { | 877 | const QString PPPData::phonenumber() { |
873 | return readConfig(cgroup, PHONENUMBER_KEY); | 878 | return readConfig(cgroup, PHONENUMBER_KEY); |
874 | } | 879 | } |
875 | 880 | ||
876 | 881 | ||
877 | void PPPData::setPhonenumber(const QString &n) { | 882 | void PPPData::setPhonenumber(const QString &n) { |
878 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 883 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
879 | } | 884 | } |
880 | 885 | ||
881 | 886 | ||
882 | const QString PPPData::dialPrefix() { | 887 | const QString PPPData::dialPrefix() { |
883 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 888 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
884 | } | 889 | } |
885 | 890 | ||
886 | 891 | ||
887 | void PPPData::setDialPrefix(const QString &s) { | 892 | void PPPData::setDialPrefix(const QString &s) { |
888 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 893 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
889 | } | 894 | } |
890 | 895 | ||
891 | 896 | ||
892 | int PPPData::authMethod() { | 897 | int PPPData::authMethod() { |
893 | return readNumConfig(cgroup, AUTH_KEY, 0); | 898 | return readNumConfig(cgroup, AUTH_KEY, 0); |
894 | } | 899 | } |
895 | 900 | ||
896 | 901 | ||
897 | void PPPData::setAuthMethod(int value) { | 902 | void PPPData::setAuthMethod(int value) { |
898 | writeConfig(cgroup, AUTH_KEY, value); | 903 | writeConfig(cgroup, AUTH_KEY, value); |
899 | } | 904 | } |
900 | 905 | ||
901 | 906 | ||
902 | const QString PPPData::storedUsername() { | 907 | const QString PPPData::storedUsername() { |
903 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 908 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
904 | } | 909 | } |
905 | 910 | ||
906 | 911 | ||
907 | void PPPData::setStoredUsername(const QString &b) { | 912 | void PPPData::setStoredUsername(const QString &b) { |
908 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 913 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
909 | } | 914 | } |
910 | 915 | ||
911 | 916 | ||
912 | const QString PPPData::storedPassword() { | 917 | const QString PPPData::storedPassword() { |
918 | qDebug("getting stored pw"); | ||
919 | qDebug("g %s", cgroup.latin1() ); | ||
920 | qDebug("k %s", STORED_PASSWORD_KEY); | ||
913 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 921 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
914 | } | 922 | } |
915 | 923 | ||
916 | 924 | ||
917 | void PPPData::setStoredPassword(const QString &b) { | 925 | void PPPData::setStoredPassword(const QString &b) { |
918 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 926 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
919 | } | 927 | } |
920 | 928 | ||
921 | 929 | ||
922 | bool PPPData::storePassword() { | 930 | bool PPPData::storePassword() { |
923 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 931 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
924 | } | 932 | } |
925 | 933 | ||
926 | 934 | ||
927 | const QString PPPData::command_before_connect() { | 935 | const QString PPPData::command_before_connect() { |
928 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 936 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
929 | } | 937 | } |
930 | 938 | ||
931 | 939 | ||
932 | void PPPData::setCommand_before_connect(const QString &n) { | 940 | void PPPData::setCommand_before_connect(const QString &n) { |
933 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 941 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
934 | } | 942 | } |
935 | 943 | ||
936 | 944 | ||
937 | void PPPData::setStorePassword(bool b) { | 945 | void PPPData::setStorePassword(bool b) { |
938 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | 946 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); |
939 | } | 947 | } |
940 | 948 | ||
941 | 949 | ||
942 | const QString PPPData::command_on_connect() { | 950 | const QString PPPData::command_on_connect() { |
943 | return readConfig(cgroup, COMMAND_KEY); | 951 | return readConfig(cgroup, COMMAND_KEY); |
944 | } | 952 | } |
945 | 953 | ||
946 | 954 | ||
947 | void PPPData::setCommand_on_connect(const QString &n) { | 955 | void PPPData::setCommand_on_connect(const QString &n) { |
948 | writeConfig(cgroup, COMMAND_KEY, n); | 956 | writeConfig(cgroup, COMMAND_KEY, n); |
949 | } | 957 | } |
950 | 958 | ||
951 | 959 | ||
952 | const QString PPPData::command_on_disconnect() { | 960 | const QString PPPData::command_on_disconnect() { |
953 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); | 961 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); |
954 | } | 962 | } |
955 | 963 | ||
956 | 964 | ||
957 | void PPPData::setCommand_on_disconnect(const QString &n) { | 965 | void PPPData::setCommand_on_disconnect(const QString &n) { |
958 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); | 966 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); |
959 | } | 967 | } |
960 | 968 | ||
961 | 969 | ||
962 | const QString PPPData::command_before_disconnect() { | 970 | const QString PPPData::command_before_disconnect() { |
963 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); | 971 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); |
964 | } | 972 | } |
965 | 973 | ||
966 | 974 | ||
967 | void PPPData::setCommand_before_disconnect(const QString &n) { | 975 | void PPPData::setCommand_before_disconnect(const QString &n) { |
968 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); | 976 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); |
969 | } | 977 | } |
970 | 978 | ||
971 | 979 | ||
972 | const QString PPPData::ipaddr() { | 980 | const QString PPPData::ipaddr() { |
973 | return readConfig(cgroup, IPADDR_KEY); | 981 | return readConfig(cgroup, IPADDR_KEY); |
974 | } | 982 | } |
975 | 983 | ||
976 | 984 | ||
977 | void PPPData::setIpaddr(const QString &n) { | 985 | void PPPData::setIpaddr(const QString &n) { |
978 | writeConfig(cgroup, IPADDR_KEY, n); | 986 | writeConfig(cgroup, IPADDR_KEY, n); |
979 | } | 987 | } |
980 | 988 | ||
981 | 989 | ||
982 | const QString PPPData::subnetmask() { | 990 | const QString PPPData::subnetmask() { |
983 | return readConfig(cgroup, SUBNETMASK_KEY); | 991 | return readConfig(cgroup, SUBNETMASK_KEY); |
984 | } | 992 | } |
985 | 993 | ||
986 | 994 | ||
987 | void PPPData::setSubnetmask(const QString &n) { | 995 | void PPPData::setSubnetmask(const QString &n) { |
988 | writeConfig(cgroup, SUBNETMASK_KEY, n); | 996 | writeConfig(cgroup, SUBNETMASK_KEY, n); |
989 | } | 997 | } |
990 | 998 | ||
991 | 999 | ||
992 | bool PPPData::autoname() { | 1000 | bool PPPData::autoname() { |
993 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); | 1001 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); |
994 | } | 1002 | } |
995 | 1003 | ||
996 | 1004 | ||
997 | void PPPData::setAutoname(bool set) { | 1005 | void PPPData::setAutoname(bool set) { |
998 | writeConfig(cgroup, AUTONAME_KEY, (int) set); | 1006 | writeConfig(cgroup, AUTONAME_KEY, (int) set); |
999 | } | 1007 | } |
1000 | 1008 | ||
1001 | 1009 | ||
1002 | bool PPPData::AcctEnabled() { | 1010 | bool PPPData::AcctEnabled() { |
1003 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); | 1011 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); |
1004 | } | 1012 | } |
1005 | 1013 | ||
1006 | 1014 | ||
1007 | void PPPData::setAcctEnabled(bool set) { | 1015 | void PPPData::setAcctEnabled(bool set) { |
1008 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); | 1016 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); |
1009 | } | 1017 | } |
1010 | 1018 | ||
1011 | 1019 | ||
1012 | // int PPPData::VolAcctEnabled() { | 1020 | // int PPPData::VolAcctEnabled() { |
1013 | // return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); | 1021 | // return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); |
1014 | // } | 1022 | // } |
1015 | 1023 | ||
1016 | 1024 | ||
1017 | // void PPPData::setVolAcctEnabled(int set) { | 1025 | // void PPPData::setVolAcctEnabled(int set) { |
1018 | // writeConfig(cgroup, VOLACCTENABLED_KEY, set); | 1026 | // writeConfig(cgroup, VOLACCTENABLED_KEY, set); |
1019 | // } | 1027 | // } |
1020 | 1028 | ||
1021 | 1029 | ||
1022 | const QString PPPData::gateway() { | 1030 | const QString PPPData::gateway() { |
1023 | return readConfig(cgroup, GATEWAY_KEY); | 1031 | return readConfig(cgroup, GATEWAY_KEY); |
1024 | } | 1032 | } |
1025 | 1033 | ||
1026 | 1034 | ||
1027 | void PPPData::setGateway(const QString &n ) { | 1035 | void PPPData::setGateway(const QString &n ) { |
1028 | writeConfig(cgroup, GATEWAY_KEY, n); | 1036 | writeConfig(cgroup, GATEWAY_KEY, n); |
1029 | } | 1037 | } |
1030 | 1038 | ||
1031 | 1039 | ||
1032 | bool PPPData::defaultroute() { | 1040 | bool PPPData::defaultroute() { |
1033 | // default route is by default 'on'. | 1041 | // default route is by default 'on'. |
1034 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); | 1042 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); |
1035 | } | 1043 | } |
1036 | 1044 | ||
1037 | 1045 | ||
1038 | void PPPData::setDefaultroute(bool set) { | 1046 | void PPPData::setDefaultroute(bool set) { |
1039 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); | 1047 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); |
1040 | } | 1048 | } |
1041 | 1049 | ||
1042 | 1050 | ||
1043 | bool PPPData::autoDNS() { | 1051 | bool PPPData::autoDNS() { |
1044 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); | 1052 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); |
1045 | return (set && pppdVersionMin(2, 3, 7)); | 1053 | return (set && pppdVersionMin(2, 3, 7)); |
1046 | } | 1054 | } |
1047 | 1055 | ||
1048 | 1056 | ||
1049 | void PPPData::setAutoDNS(bool set) { | 1057 | void PPPData::setAutoDNS(bool set) { |
1050 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | 1058 | writeConfig(cgroup, AUTODNS_KEY, (int) set); |
1051 | } | 1059 | } |
1052 | 1060 | ||
1053 | 1061 | ||
1054 | void PPPData::setExDNSDisabled(bool set) { | 1062 | void PPPData::setExDNSDisabled(bool set) { |
1055 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | 1063 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); |
1056 | } | 1064 | } |
1057 | 1065 | ||
1058 | 1066 | ||
1059 | bool PPPData::exDNSDisabled() { | 1067 | bool PPPData::exDNSDisabled() { |
1060 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | 1068 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); |
1061 | } | 1069 | } |
1062 | 1070 | ||
1063 | 1071 | ||
1064 | QStringList &PPPData::dns() { | 1072 | QStringList &PPPData::dns() { |
1065 | static QStringList dnslist; | 1073 | static QStringList dnslist; |
1066 | 1074 | ||
1067 | readListConfig(cgroup, DNS_KEY, dnslist); | 1075 | readListConfig(cgroup, DNS_KEY, dnslist); |
1068 | while(dnslist.count() > MAX_DNS_ENTRIES) | 1076 | while(dnslist.count() > MAX_DNS_ENTRIES) |
1069 | dnslist.remove(dnslist.last()); | 1077 | dnslist.remove(dnslist.last()); |
1070 | 1078 | ||
1071 | return dnslist; | 1079 | return dnslist; |
1072 | } | 1080 | } |
1073 | 1081 | ||
1074 | 1082 | ||
1075 | void PPPData::setDns(QStringList &list) { | 1083 | void PPPData::setDns(QStringList &list) { |
1076 | writeListConfig(cgroup, DNS_KEY, list); | 1084 | writeListConfig(cgroup, DNS_KEY, list); |
1077 | } | 1085 | } |
1078 | 1086 | ||
1079 | 1087 | ||
1080 | const QString PPPData::domain() { | 1088 | const QString PPPData::domain() { |
1081 | return readConfig(cgroup, DOMAIN_KEY); | 1089 | return readConfig(cgroup, DOMAIN_KEY); |
1082 | } | 1090 | } |
1083 | 1091 | ||
1084 | 1092 | ||
1085 | void PPPData::setDomain(const QString &n ) { | 1093 | void PPPData::setDomain(const QString &n ) { |
1086 | writeConfig(cgroup, DOMAIN_KEY, n); | 1094 | writeConfig(cgroup, DOMAIN_KEY, n); |
1087 | } | 1095 | } |
1088 | 1096 | ||
1089 | 1097 | ||
1090 | QStringList &PPPData::scriptType() { | 1098 | QStringList &PPPData::scriptType() { |
1091 | static QStringList typelist; | 1099 | static QStringList typelist; |
1092 | 1100 | ||
1093 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | 1101 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); |
1094 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | 1102 | while(typelist.count() > MAX_SCRIPT_ENTRIES) |
1095 | typelist.remove(typelist.last()); | 1103 | typelist.remove(typelist.last()); |
1096 | 1104 | ||
1097 | return typelist; | 1105 | return typelist; |
1098 | } | 1106 | } |
1099 | 1107 | ||
1100 | 1108 | ||
1101 | void PPPData::setScriptType(QStringList &list) { | 1109 | void PPPData::setScriptType(QStringList &list) { |
1102 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | 1110 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); |
1103 | } | 1111 | } |
1104 | 1112 | ||
1105 | 1113 | ||
1106 | QStringList &PPPData::script() { | 1114 | QStringList &PPPData::script() { |
1107 | static QStringList scriptlist; | 1115 | static QStringList scriptlist; |
1108 | 1116 | ||
1109 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | 1117 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); |
1110 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | 1118 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) |
1111 | scriptlist.remove(scriptlist.last()); | 1119 | scriptlist.remove(scriptlist.last()); |
1112 | 1120 | ||
1113 | return scriptlist; | 1121 | return scriptlist; |
1114 | } | 1122 | } |
1115 | 1123 | ||
1116 | 1124 | ||
1117 | void PPPData::setScript(QStringList &list) { | 1125 | void PPPData::setScript(QStringList &list) { |
1118 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | 1126 | writeListConfig(cgroup, SCRIPTARG_KEY, list); |
1119 | } | 1127 | } |
1120 | 1128 | ||
1121 | 1129 | ||
1122 | // const QString PPPData::accountingFile() { | 1130 | // const QString PPPData::accountingFile() { |
1123 | // return readConfig(cgroup, ACCTFILE_KEY); | 1131 | // return readConfig(cgroup, ACCTFILE_KEY); |
1124 | // } | 1132 | // } |
1125 | 1133 | ||
1126 | 1134 | ||
1127 | // void PPPData::setAccountingFile(const QString &n) { | 1135 | // void PPPData::setAccountingFile(const QString &n) { |
1128 | // writeConfig(cgroup, ACCTFILE_KEY, n); | 1136 | // writeConfig(cgroup, ACCTFILE_KEY, n); |
1129 | // } | 1137 | // } |
1130 | 1138 | ||
1131 | 1139 | ||
1132 | // const QString PPPData::totalCosts() { | 1140 | // const QString PPPData::totalCosts() { |
1133 | // return readConfig(cgroup, TOTALCOSTS_KEY); | 1141 | // return readConfig(cgroup, TOTALCOSTS_KEY); |
1134 | // } | 1142 | // } |
1135 | 1143 | ||
1136 | 1144 | ||
1137 | // void PPPData::setTotalCosts(const QString &n) { | 1145 | // void PPPData::setTotalCosts(const QString &n) { |
1138 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); | 1146 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); |
1139 | // } | 1147 | // } |
1140 | 1148 | ||
1141 | 1149 | ||
1142 | // int PPPData::totalBytes() { | 1150 | // int PPPData::totalBytes() { |
1143 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | 1151 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); |
1144 | // } | 1152 | // } |
1145 | 1153 | ||
1146 | // void PPPData::setTotalBytes(int n) { | 1154 | // void PPPData::setTotalBytes(int n) { |
1147 | // writeConfig(cgroup, TOTALBYTES_KEY, n); | 1155 | // writeConfig(cgroup, TOTALBYTES_KEY, n); |
1148 | // } | 1156 | // } |
1149 | 1157 | ||
1150 | 1158 | ||
1151 | QStringList &PPPData::pppdArgument() { | 1159 | QStringList &PPPData::pppdArgument() { |
1152 | static QStringList arglist; | 1160 | static QStringList arglist; |
1153 | 1161 | ||
1154 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1162 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1155 | arglist.remove(arglist.last()); | 1163 | arglist.remove(arglist.last()); |
1156 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1164 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1157 | 1165 | ||
1158 | return arglist; | 1166 | return arglist; |
1159 | } | 1167 | } |
1160 | 1168 | ||
1161 | 1169 | ||
1162 | void PPPData::setpppdArgument(QStringList &args) { | 1170 | void PPPData::setpppdArgument(QStringList &args) { |
1163 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1171 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1164 | } | 1172 | } |
1165 | 1173 | ||
1166 | 1174 | ||
1167 | void PPPData::setpppdArgumentDefaults() { | 1175 | void PPPData::setpppdArgumentDefaults() { |
1168 | QStringList arg; | 1176 | QStringList arg; |
1169 | setpppdArgument(arg); | 1177 | setpppdArgument(arg); |
1170 | } | 1178 | } |
1171 | 1179 | ||
1172 | 1180 | ||
1173 | // // graphing widget | 1181 | // // graphing widget |
1174 | // void PPPData::setGraphingOptions(bool enable, | 1182 | // void PPPData::setGraphingOptions(bool enable, |
1175 | // QColor bg, | 1183 | // QColor bg, |
1176 | // QColor text, | 1184 | // QColor text, |
1177 | // QColor in, | 1185 | // QColor in, |
1178 | // QColor out) | 1186 | // QColor out) |
1179 | // { | 1187 | // { |
1180 | // if(config) { | 1188 | // if(config) { |
1181 | // config->setGroup(GRAPH_GRP); | 1189 | // config->setGroup(GRAPH_GRP); |
1182 | // config->writeEntry(GENABLED, enable); | 1190 | // config->writeEntry(GENABLED, enable); |
1183 | // // config->writeEntry(GCOLOR_BG, bg); | 1191 | // // config->writeEntry(GCOLOR_BG, bg); |
1184 | // // config->writeEntry(GCOLOR_TEXT, text); | 1192 | // // config->writeEntry(GCOLOR_TEXT, text); |
1185 | // // config->writeEntry(GCOLOR_IN, in); | 1193 | // // config->writeEntry(GCOLOR_IN, in); |
1186 | // // config->writeEntry(GCOLOR_OUT, out); | 1194 | // // config->writeEntry(GCOLOR_OUT, out); |
1187 | // } | 1195 | // } |
1188 | // } | 1196 | // } |
1189 | 1197 | ||
1190 | // void PPPData::graphingOptions(bool &enable, | 1198 | // void PPPData::graphingOptions(bool &enable, |
1191 | // QColor &bg, | 1199 | // QColor &bg, |
1192 | // QColor &text, | 1200 | // QColor &text, |
1193 | // QColor &in, | 1201 | // QColor &in, |
1194 | // QColor &out) | 1202 | // QColor &out) |
1195 | // { | 1203 | // { |
1196 | // QColor c; | 1204 | // QColor c; |
1197 | 1205 | ||
1198 | // if(config) { | 1206 | // if(config) { |
1199 | // config->setGroup(GRAPH_GRP); | 1207 | // config->setGroup(GRAPH_GRP); |
1200 | // enable = config->readBoolEntry(GENABLED, true); | 1208 | // enable = config->readBoolEntry(GENABLED, true); |
1201 | // bg = Qt::white; | 1209 | // bg = Qt::white; |
1202 | // //bg = config->readColorEntry(GCOLOR_BG, &c); | 1210 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1203 | // text = Qt::black; | 1211 | // text = Qt::black; |
1204 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1212 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1205 | // in = Qt::blue; | 1213 | // in = Qt::blue; |
1206 | // //in = config->readColorEntry(GCOLOR_IN, &c); | 1214 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1207 | // out = Qt::red; | 1215 | // out = Qt::red; |
1208 | // //out = config->readColorEntry(GCOLOR_OUT, &c); | 1216 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1209 | // } | 1217 | // } |
1210 | // } | 1218 | // } |
1211 | 1219 | ||
1212 | 1220 | ||
1213 | // bool PPPData::graphingEnabled() { | 1221 | // bool PPPData::graphingEnabled() { |
1214 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1222 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1215 | // } | 1223 | // } |
1216 | 1224 | ||
1217 | 1225 | ||
1218 | 1226 | ||
1219 | // | 1227 | // |
1220 | //functions to change/set the child pppd process info | 1228 | //functions to change/set the child pppd process info |
1221 | // | 1229 | // |
1222 | bool PPPData::pppdRunning() const { | 1230 | bool PPPData::pppdRunning() const { |
1223 | return pppdisrunning; | 1231 | return pppdisrunning; |
1224 | } | 1232 | } |
1225 | 1233 | ||
1226 | void PPPData::setpppdRunning(bool set) { | 1234 | void PPPData::setpppdRunning(bool set) { |
1227 | pppdisrunning = set; | 1235 | pppdisrunning = set; |
1228 | } | 1236 | } |
1229 | 1237 | ||
1230 | int PPPData::pppdError() const { | 1238 | int PPPData::pppdError() const { |
1231 | return pppderror; | 1239 | return pppderror; |
1232 | } | 1240 | } |
1233 | 1241 | ||
1234 | void PPPData::setpppdError(int err) { | 1242 | void PPPData::setpppdError(int err) { |
1235 | pppderror = err; | 1243 | pppderror = err; |
1236 | } | 1244 | } |
1237 | 1245 | ||
1238 | QString PPPData::modemGroup() | 1246 | QString PPPData::modemGroup() |
1239 | { | 1247 | { |
1240 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); | 1248 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); |
1241 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); | 1249 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); |
1242 | } | 1250 | } |
1243 | 1251 | ||
1244 | 1252 | ||
1245 | QMap<QString,QString> PPPData::getConfiguredInterfaces() | 1253 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1246 | { | 1254 | { |
1247 | QMap<QString,QString> ifaces; | 1255 | QMap<QString,QString> ifaces; |
1248 | Config config = PPPData::config(); | 1256 | Config config = PPPData::config(); |
1249 | config.setGroup(ACCLIST_GRP); | 1257 | config.setGroup(ACCLIST_GRP); |
1250 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | 1258 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); |
1251 | QString accGrp, dev, acc; | 1259 | QString accGrp, dev, acc; |
1252 | for (int i = 0; i < count; i++){ | 1260 | for (int i = 0; i < count; i++){ |
1253 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1261 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
1254 | config.setGroup(accGrp); | 1262 | config.setGroup(accGrp); |
1255 | dev = config.readEntry( ACOUNTS_DEV, "error" ); | 1263 | dev = config.readEntry( ACOUNTS_DEV, "error" ); |
1256 | acc = config.readEntry( ACOUNTS_ACC, "error" ); | 1264 | acc = config.readEntry( ACOUNTS_ACC, "error" ); |
1257 | ifaces.insert( dev, acc ); | 1265 | ifaces.insert( dev, acc ); |
1258 | } | 1266 | } |
1259 | 1267 | ||
1260 | return ifaces; | 1268 | return ifaces; |
1261 | } | 1269 | } |
1262 | 1270 | ||
1263 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1271 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1264 | { | 1272 | { |
1265 | QMap<QString,QString>::Iterator it; | 1273 | QMap<QString,QString>::Iterator it; |
1266 | int i = 0; | 1274 | int i = 0; |
1267 | Config cfg = config(); | 1275 | Config cfg = config(); |
1268 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ | 1276 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ |
1269 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i)); | 1277 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i)); |
1270 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); | 1278 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1271 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1279 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1272 | } | 1280 | } |
1273 | cfg.setGroup( ACCLIST_GRP ); | 1281 | cfg.setGroup( ACCLIST_GRP ); |
1274 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1282 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1275 | 1283 | ||
1276 | } | 1284 | } |
1285 | |||
1286 | /** | ||
1287 | * pppd's getword() function knows about escape characters. | ||
1288 | * If we write the username and password to the secrets file | ||
1289 | * we'll therefore have to escape back slashes. | ||
1290 | */ | ||
1291 | QString PPPData::encodeWord(const QString &s) { | ||
1292 | QString r = s; | ||
1293 | r.replace(QRegExp("\\"), "\\\\"); | ||
1294 | return r; | ||
1295 | } | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index af960c6..c9cd482 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -220,216 +220,219 @@ public: | |||
220 | 220 | ||
221 | int pppdTimeout(); | 221 | int pppdTimeout(); |
222 | void setpppdTimeout(int); | 222 | void setpppdTimeout(int); |
223 | 223 | ||
224 | int busyWait(); | 224 | int busyWait(); |
225 | void setbusyWait(int); | 225 | void setbusyWait(int); |
226 | 226 | ||
227 | bool modemLockFile(); | 227 | bool modemLockFile(); |
228 | void setModemLockFile(bool set); | 228 | void setModemLockFile(bool set); |
229 | 229 | ||
230 | int modemEscapeGuardTime(); | 230 | int modemEscapeGuardTime(); |
231 | void setModemEscapeGuardTime(int i); | 231 | void setModemEscapeGuardTime(int i); |
232 | 232 | ||
233 | void setModemEscapeStr(const QString &); | 233 | void setModemEscapeStr(const QString &); |
234 | const QString modemEscapeStr(); | 234 | const QString modemEscapeStr(); |
235 | 235 | ||
236 | void setModemEscapeResp(const QString &); | 236 | void setModemEscapeResp(const QString &); |
237 | const QString modemEscapeResp(); | 237 | const QString modemEscapeResp(); |
238 | 238 | ||
239 | const QString modemDevice(); | 239 | const QString modemDevice(); |
240 | bool setModemDevice(const QString &); | 240 | bool setModemDevice(const QString &); |
241 | 241 | ||
242 | const QString flowcontrol(); | 242 | const QString flowcontrol(); |
243 | void setFlowcontrol(const QString &); | 243 | void setFlowcontrol(const QString &); |
244 | 244 | ||
245 | int modemTimeout(); | 245 | int modemTimeout(); |
246 | void setModemTimeout(int); | 246 | void setModemTimeout(int); |
247 | 247 | ||
248 | int modemToneDuration(); | 248 | int modemToneDuration(); |
249 | void setModemToneDuration(int); | 249 | void setModemToneDuration(int); |
250 | 250 | ||
251 | QString volumeInitString(); | 251 | QString volumeInitString(); |
252 | int volume(); | 252 | int volume(); |
253 | void setVolume(int); | 253 | void setVolume(int); |
254 | 254 | ||
255 | int waitForDialTone(); | 255 | int waitForDialTone(); |
256 | void setWaitForDialTone(int i); | 256 | void setWaitForDialTone(int i); |
257 | 257 | ||
258 | // modem command strings/responses | 258 | // modem command strings/responses |
259 | const QString modemInitStr(int i); | 259 | const QString modemInitStr(int i); |
260 | void setModemInitStr(int i, const QString &); | 260 | void setModemInitStr(int i, const QString &); |
261 | 261 | ||
262 | const QString modemInitResp(); | 262 | const QString modemInitResp(); |
263 | void setModemInitResp(const QString &); | 263 | void setModemInitResp(const QString &); |
264 | 264 | ||
265 | int modemPreInitDelay(); | 265 | int modemPreInitDelay(); |
266 | void setModemPreInitDelay(int); | 266 | void setModemPreInitDelay(int); |
267 | 267 | ||
268 | int modemInitDelay(); | 268 | int modemInitDelay(); |
269 | void setModemInitDelay(int); | 269 | void setModemInitDelay(int); |
270 | 270 | ||
271 | QString modemNoDialToneDetectionStr(); | 271 | QString modemNoDialToneDetectionStr(); |
272 | void setModemNoDialToneDetectionStr(const QString &); | 272 | void setModemNoDialToneDetectionStr(const QString &); |
273 | 273 | ||
274 | const QString modemDialStr(); | 274 | const QString modemDialStr(); |
275 | void setModemDialStr(const QString &); | 275 | void setModemDialStr(const QString &); |
276 | 276 | ||
277 | const QString modemConnectResp(); | 277 | const QString modemConnectResp(); |
278 | void setModemConnectResp(const QString &); | 278 | void setModemConnectResp(const QString &); |
279 | 279 | ||
280 | const QString modemBusyResp(); | 280 | const QString modemBusyResp(); |
281 | void setModemBusyResp(const QString &); | 281 | void setModemBusyResp(const QString &); |
282 | 282 | ||
283 | const QString modemNoCarrierResp(); | 283 | const QString modemNoCarrierResp(); |
284 | void setModemNoCarrierResp(const QString &); | 284 | void setModemNoCarrierResp(const QString &); |
285 | 285 | ||
286 | const QString modemNoDialtoneResp(); | 286 | const QString modemNoDialtoneResp(); |
287 | void setModemNoDialtoneResp(const QString &); | 287 | void setModemNoDialtoneResp(const QString &); |
288 | 288 | ||
289 | const QString modemHangupStr(); | 289 | const QString modemHangupStr(); |
290 | void setModemHangupStr(const QString &); | 290 | void setModemHangupStr(const QString &); |
291 | 291 | ||
292 | const QString modemHangupResp(); | 292 | const QString modemHangupResp(); |
293 | void setModemHangupResp(const QString &); | 293 | void setModemHangupResp(const QString &); |
294 | 294 | ||
295 | const QString modemAnswerStr(); | 295 | const QString modemAnswerStr(); |
296 | void setModemAnswerStr(const QString &); | 296 | void setModemAnswerStr(const QString &); |
297 | 297 | ||
298 | const QString modemRingResp(); | 298 | const QString modemRingResp(); |
299 | void setModemRingResp(const QString &); | 299 | void setModemRingResp(const QString &); |
300 | 300 | ||
301 | const QString modemAnswerResp(); | 301 | const QString modemAnswerResp(); |
302 | void setModemAnswerResp(const QString &); | 302 | void setModemAnswerResp(const QString &); |
303 | 303 | ||
304 | QString volumeOff(); | 304 | QString volumeOff(); |
305 | void setVolumeOff(const QString &); | 305 | void setVolumeOff(const QString &); |
306 | 306 | ||
307 | QString volumeMedium(); | 307 | QString volumeMedium(); |
308 | void setVolumeMedium(const QString &); | 308 | void setVolumeMedium(const QString &); |
309 | 309 | ||
310 | QString volumeHigh(); | 310 | QString volumeHigh(); |
311 | void setVolumeHigh(const QString &); | 311 | void setVolumeHigh(const QString &); |
312 | 312 | ||
313 | // functions to set/get account information | 313 | // functions to set/get account information |
314 | int count() const; | 314 | int count() const; |
315 | bool setAccount(const QString &); | 315 | bool setAccount(const QString &); |
316 | bool setAccountbyIndex(int); | 316 | bool setAccountbyIndex(int); |
317 | 317 | ||
318 | bool isUniqueAccname(const QString &); | 318 | bool isUniqueAccname(const QString &); |
319 | 319 | ||
320 | bool deleteAccount(); | 320 | bool deleteAccount(); |
321 | bool deleteAccount(const QString &); | 321 | bool deleteAccount(const QString &); |
322 | int newaccount(); | 322 | int newaccount(); |
323 | int copyaccount(int i); | 323 | int copyaccount(int i); |
324 | 324 | ||
325 | const QString accname(); | 325 | const QString accname(); |
326 | void setAccname(const QString &); | 326 | void setAccname(const QString &); |
327 | 327 | ||
328 | QStringList &phonenumbers(); | 328 | QStringList &phonenumbers(); |
329 | const QString phonenumber(); | 329 | const QString phonenumber(); |
330 | void setPhonenumber(const QString &); | 330 | void setPhonenumber(const QString &); |
331 | 331 | ||
332 | const QString dialPrefix(); | 332 | const QString dialPrefix(); |
333 | void setDialPrefix(const QString &); | 333 | void setDialPrefix(const QString &); |
334 | 334 | ||
335 | int authMethod(); | 335 | int authMethod(); |
336 | void setAuthMethod(int); | 336 | void setAuthMethod(int); |
337 | 337 | ||
338 | const QString storedUsername(); | 338 | const QString storedUsername(); |
339 | void setStoredUsername(const QString &); | 339 | void setStoredUsername(const QString &); |
340 | 340 | ||
341 | const QString storedPassword(); | 341 | const QString storedPassword(); |
342 | void setStoredPassword(const QString &); | 342 | void setStoredPassword(const QString &); |
343 | 343 | ||
344 | bool storePassword(); | 344 | bool storePassword(); |
345 | void setStorePassword(bool); | 345 | void setStorePassword(bool); |
346 | 346 | ||
347 | const QString speed(); | 347 | const QString speed(); |
348 | void setSpeed(const QString &); | 348 | void setSpeed(const QString &); |
349 | 349 | ||
350 | const QString command_before_connect(); | 350 | const QString command_before_connect(); |
351 | void setCommand_before_connect(const QString &); | 351 | void setCommand_before_connect(const QString &); |
352 | 352 | ||
353 | const QString command_on_connect(); | 353 | const QString command_on_connect(); |
354 | void setCommand_on_connect(const QString &); | 354 | void setCommand_on_connect(const QString &); |
355 | 355 | ||
356 | const QString command_on_disconnect(); | 356 | const QString command_on_disconnect(); |
357 | void setCommand_on_disconnect(const QString &); | 357 | void setCommand_on_disconnect(const QString &); |
358 | 358 | ||
359 | const QString command_before_disconnect(); | 359 | const QString command_before_disconnect(); |
360 | void setCommand_before_disconnect(const QString &); | 360 | void setCommand_before_disconnect(const QString &); |
361 | 361 | ||
362 | const QString ipaddr(); | 362 | const QString ipaddr(); |
363 | void setIpaddr(const QString &); | 363 | void setIpaddr(const QString &); |
364 | 364 | ||
365 | const QString subnetmask(); | 365 | const QString subnetmask(); |
366 | void setSubnetmask(const QString &); | 366 | void setSubnetmask(const QString &); |
367 | 367 | ||
368 | bool AcctEnabled(); | 368 | bool AcctEnabled(); |
369 | void setAcctEnabled(bool set); | 369 | void setAcctEnabled(bool set); |
370 | 370 | ||
371 | // int VolAcctEnabled(); | 371 | // int VolAcctEnabled(); |
372 | // void setVolAcctEnabled(int set); | 372 | // void setVolAcctEnabled(int set); |
373 | 373 | ||
374 | bool autoDNS(); | 374 | bool autoDNS(); |
375 | void setAutoDNS(bool set); | 375 | void setAutoDNS(bool set); |
376 | 376 | ||
377 | bool exDNSDisabled(); | 377 | bool exDNSDisabled(); |
378 | void setExDNSDisabled(bool set); | 378 | void setExDNSDisabled(bool set); |
379 | 379 | ||
380 | bool autoname(); | 380 | bool autoname(); |
381 | void setAutoname(bool set); | 381 | void setAutoname(bool set); |
382 | 382 | ||
383 | const QString gateway(); | 383 | const QString gateway(); |
384 | void setGateway(const QString &); | 384 | void setGateway(const QString &); |
385 | 385 | ||
386 | bool defaultroute(); | 386 | bool defaultroute(); |
387 | void setDefaultroute(bool set); | 387 | void setDefaultroute(bool set); |
388 | 388 | ||
389 | QStringList &dns(); | 389 | QStringList &dns(); |
390 | void setDns(QStringList &); | 390 | void setDns(QStringList &); |
391 | 391 | ||
392 | const QString domain(); | 392 | const QString domain(); |
393 | void setDomain(const QString &); | 393 | void setDomain(const QString &); |
394 | 394 | ||
395 | QStringList &scriptType(); | 395 | QStringList &scriptType(); |
396 | void setScriptType(QStringList &); | 396 | void setScriptType(QStringList &); |
397 | 397 | ||
398 | QStringList &script(); | 398 | QStringList &script(); |
399 | void setScript(QStringList &); | 399 | void setScript(QStringList &); |
400 | 400 | ||
401 | QStringList &pppdArgument(); | 401 | QStringList &pppdArgument(); |
402 | void setpppdArgumentDefaults(); | 402 | void setpppdArgumentDefaults(); |
403 | void setpppdArgument(QStringList &); | 403 | void setpppdArgument(QStringList &); |
404 | 404 | ||
405 | //functions to change/set the child pppd process info | 405 | //functions to change/set the child pppd process info |
406 | bool pppdRunning() const; | 406 | bool pppdRunning() const; |
407 | void setpppdRunning(bool set); | 407 | void setpppdRunning(bool set); |
408 | 408 | ||
409 | int pppdError() const; | 409 | int pppdError() const; |
410 | void setpppdError(int err); | 410 | void setpppdError(int err); |
411 | 411 | ||
412 | |||
413 | static QString encodeWord(const QString &s); | ||
414 | |||
412 | private: | 415 | private: |
413 | 416 | ||
414 | //static PPPData *_data; | 417 | //static PPPData *_data; |
415 | int modemDeviceGroup; | 418 | int modemDeviceGroup; |
416 | QString passwd; | 419 | QString passwd; |
417 | // static Config* config; // configuration object | 420 | // static Config* config; // configuration object |
418 | int highcount; // index of highest account | 421 | int highcount; // index of highest account |
419 | int caccount; // index of the current account | 422 | int caccount; // index of the current account |
420 | QString cgroup; // name of current config group | 423 | QString cgroup; // name of current config group |
421 | pid_t suidprocessid; // process ID of setuid child | 424 | pid_t suidprocessid; // process ID of setuid child |
422 | bool pppdisrunning; // pppd process | 425 | bool pppdisrunning; // pppd process |
423 | // daemon | 426 | // daemon |
424 | int pppderror; // error encounterd running pppd | 427 | int pppderror; // error encounterd running pppd |
425 | int pppdVer, pppdMod, pppdPatch; // pppd version | 428 | int pppdVer, pppdMod, pppdPatch; // pppd version |
426 | 429 | ||
427 | QStringList phonelist; | 430 | QStringList phonelist; |
428 | QMap<QString,QString> stringEntries; | 431 | QMap<QString,QString> stringEntries; |
429 | QMap<QString,int> intEntries; | 432 | QMap<QString,int> intEntries; |
430 | QMap<QString,QStringList> listEntries; | 433 | QMap<QString,QStringList> listEntries; |
431 | QMap<QString,QChar> sepEntries; | 434 | QMap<QString,QChar> sepEntries; |
432 | 435 | ||
433 | }; | 436 | }; |
434 | 437 | ||
435 | #endif | 438 | #endif |