author | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
commit | a7e015198a8c5ad3b6e144a9032b059086253e00 (patch) (unidiff) | |
tree | b712b6f11310d88744fe393a92b3160b741a7efe /noncore/settings/networksettings/ppp/connect.cpp | |
parent | beba0e73306815337bf04dee39502233595e9739 (diff) | |
download | opie-a7e015198a8c5ad3b6e144a9032b059086253e00.zip opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.gz opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.bz2 |
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 166 |
1 files changed, 95 insertions, 71 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 2400d7b..e3fab24 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1,1299 +1,1323 @@ | |||
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 | ||
36 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
38 | 37 | ||
39 | #include <unistd.h> | 38 | #include <unistd.h> |
40 | #include <stdlib.h> | 39 | #include <stdlib.h> |
41 | #include <string.h> | 40 | #include <string.h> |
42 | #include <fcntl.h> | 41 | #include <fcntl.h> |
43 | #include <netdb.h> | 42 | #include <netdb.h> |
44 | #include <sys/types.h> | 43 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 44 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 46 | #include <netinet/in.h> |
48 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
49 | #include <assert.h> | 48 | #include <assert.h> |
50 | 49 | ||
51 | #ifdef _XPG4_2 | 50 | #ifdef _XPG4_2 |
52 | #define __xnet_connectconnect | 51 | #define __xnet_connectconnect |
53 | #endif | 52 | #endif |
54 | 53 | ||
55 | #include <errno.h> | 54 | #include <errno.h> |
56 | 55 | ||
57 | #ifdef HAVE_SYS_PARAM_H | 56 | #ifdef HAVE_SYS_PARAM_H |
58 | #include <sys/param.h> | 57 | #include <sys/param.h> |
59 | #endif | 58 | #endif |
60 | 59 | ||
61 | #ifdef __linux__ | 60 | #ifdef __linux__ |
62 | #include "runtests.h" | 61 | #include "runtests.h" |
63 | #endif | 62 | #endif |
64 | 63 | ||
65 | #include "auth.h" | 64 | #include "auth.h" |
66 | #include "connect.h" | 65 | #include "connect.h" |
67 | //#include "docking.h" | 66 | //#include "docking.h" |
68 | #include "interfaceppp.h" | 67 | #include "interfaceppp.h" |
69 | #include "modem.h" | 68 | #include "modem.h" |
70 | #include "kpppconfig.h" | 69 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 70 | #include "pppdata.h" |
72 | #include "kpppwidget.h" | 71 | #include "kpppwidget.h" |
73 | //#include "requester.h" | 72 | //#include "requester.h" |
74 | //#include "utils.h" | 73 | //#include "utils.h" |
75 | #define execute_command system | 74 | #define execute_command system |
76 | 75 | ||
77 | QString old_hostname; | 76 | QString old_hostname; |
78 | bool modified_hostname; | 77 | bool modified_hostname; |
79 | 78 | ||
80 | 79 | ||
81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) | 80 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
82 | : QWidget(parent, name), | 81 | : QWidget(parent, name), |
83 | myreadbuffer(""), | 82 | myreadbuffer(""), |
84 | main_timer_ID(0), | 83 | main_timer_ID(0), |
85 | vmain(0), | 84 | vmain(0), |
86 | substate(-1), | 85 | substate(-1), |
87 | scriptindex(0), | 86 | scriptindex(0), |
88 | loopnest(0), | 87 | loopnest(0), |
89 | loopend(false), | 88 | loopend(false), |
90 | semaphore(false), | 89 | semaphore(false), |
91 | expecting(false), | 90 | expecting(false), |
92 | readbuffer(""), | 91 | readbuffer(""), |
93 | scanvar(""), | 92 | scanvar(""), |
94 | scanning(false), | 93 | scanning(false), |
95 | pausing(false), | 94 | pausing(false), |
96 | dialnumber(0), | 95 | dialnumber(0), |
97 | _ifaceppp(ifp) | 96 | _ifaceppp(ifp) |
98 | { | 97 | { |
99 | modified_hostname = false; | 98 | modified_hostname = false; |
100 | 99 | ||
101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 100 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
102 | QString tit = i18n("Connecting to: "); | 101 | QString tit = QObject::tr("Connecting to: "); |
103 | setCaption(tit); | 102 | setCaption(tit); |
104 | 103 | ||
105 | QHBoxLayout *l0 = new QHBoxLayout(10); | 104 | QHBoxLayout *l0 = new QHBoxLayout(10); |
106 | tl->addLayout(l0); | 105 | tl->addLayout(l0); |
107 | l0->addSpacing(10); | 106 | l0->addSpacing(10); |
108 | messg = new QLabel(this, "messg"); | 107 | messg = new QLabel(this, "messg"); |
109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 108 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | messg->setAlignment(AlignCenter); | 109 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 110 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 111 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | // int messw = (messg->sizeHint().width() * 12) / 10; | 112 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | // messw = QMAX(messw,280); | 113 | // messw = QMAX(messw,280); |
115 | // messg->setMinimumWidth(messw); | 114 | // messg->setMinimumWidth(messw); |
116 | if (_ifaceppp->getStatus()) | 115 | if (_ifaceppp->getStatus()) |
117 | messg->setText(i18n("Online")); | 116 | messg->setText(QObject::tr("Online")); |
118 | else | 117 | else |
119 | messg->setText(i18n("Offline")); | 118 | messg->setText(QObject::tr("Offline")); |
120 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
121 | l0->addWidget(messg); | 120 | l0->addWidget(messg); |
122 | l0->addSpacing(10); | 121 | l0->addSpacing(10); |
123 | 122 | ||
124 | QHBoxLayout *l1 = new QHBoxLayout(10); | 123 | QHBoxLayout *l1 = new QHBoxLayout(10); |
125 | tl->addLayout(l1); | 124 | tl->addLayout(l1); |
126 | l1->addStretch(1); | 125 | l1->addStretch(1); |
127 | 126 | ||
128 | debug = new QPushButton(i18n("Log"), this); | 127 | debug = new QPushButton(QObject::tr("Log"), this); |
129 | debug->setToggleButton(true); | 128 | debug->setToggleButton(true); |
130 | debug->setEnabled( false ); // FIXME: disable the log button | 129 | debug->setEnabled( false ); // FIXME: disable the log button |
131 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 130 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
132 | 131 | ||
133 | cancel = new QPushButton(i18n("Cancel"), this); | 132 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
134 | cancel->setFocus(); | 133 | cancel->setFocus(); |
135 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 134 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
136 | 135 | ||
137 | // int maxw = QMAX(cancel->sizeHint().width(), | 136 | // int maxw = QMAX(cancel->sizeHint().width(), |
138 | // debug->sizeHint().width()); | 137 | // debug->sizeHint().width()); |
139 | // maxw = QMAX(maxw,65); | 138 | // maxw = QMAX(maxw,65); |
140 | // debug->setFixedWidth(maxw); | 139 | // debug->setFixedWidth(maxw); |
141 | // cancel->setFixedWidth(maxw); | 140 | // cancel->setFixedWidth(maxw); |
142 | l1->addWidget(debug); | 141 | l1->addWidget(debug); |
143 | l1->addWidget(cancel); | 142 | l1->addWidget(cancel); |
144 | 143 | ||
145 | // setFixedSize(sizeHint()); | 144 | // setFixedSize(sizeHint()); |
146 | 145 | ||
147 | pausetimer = new QTimer(this); | 146 | pausetimer = new QTimer(this); |
148 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 147 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
149 | 148 | ||
150 | qApp->processEvents(); | 149 | qApp->processEvents(); |
151 | 150 | ||
152 | timeout_timer = new QTimer(this); | 151 | timeout_timer = new QTimer(this); |
153 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); | 152 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); |
154 | 153 | ||
155 | inittimer = new QTimer(this); | 154 | inittimer = new QTimer(this); |
156 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); | 155 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); |
157 | 156 | ||
158 | if_timeout_timer = new QTimer(this); | 157 | if_timeout_timer = new QTimer(this); |
159 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); | 158 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); |
160 | 159 | ||
161 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); | 160 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); |
162 | 161 | ||
163 | prompt = new PWEntry( this, "pw" ); | 162 | prompt = new PWEntry( this, "pw" ); |
164 | if_timer = new QTimer(this); | 163 | if_timer = new QTimer(this); |
165 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 164 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
166 | } | 165 | } |
167 | 166 | ||
168 | 167 | ||
169 | ConnectWidget::~ConnectWidget() { | 168 | ConnectWidget::~ConnectWidget() { |
170 | } | 169 | } |
171 | 170 | ||
172 | 171 | ||
173 | void ConnectWidget::preinit() { | 172 | void ConnectWidget::preinit() { |
174 | // this is all just to keep the GUI nice and snappy .... | 173 | // this is all just to keep the GUI nice and snappy .... |
175 | // you have to see to believe ... | 174 | // you have to see to believe ... |
176 | messg->setText(i18n("Looking for modem...")); | 175 | messg->setText(QObject::tr("Looking for modem...")); |
177 | inittimer->start(100); | 176 | inittimer->start(100); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | void ConnectWidget::init() { | 180 | void ConnectWidget::init() { |
182 | _ifaceppp->data()->setpppdError(0); | 181 | _ifaceppp->data()->setpppdError(0); |
183 | inittimer->stop(); | 182 | inittimer->stop(); |
184 | vmain = 0; | 183 | vmain = 0; |
185 | substate = -1; | 184 | substate = -1; |
186 | expecting = false; | 185 | expecting = false; |
187 | pausing = false; | 186 | pausing = false; |
188 | scriptindex = 0; | 187 | scriptindex = 0; |
189 | myreadbuffer = ""; | 188 | myreadbuffer = ""; |
190 | scanning = false; | 189 | scanning = false; |
191 | scanvar = ""; | 190 | scanvar = ""; |
192 | firstrunID = true; | 191 | firstrunID = true; |
193 | firstrunPW = true; | 192 | firstrunPW = true; |
194 | // stats->totalbytes = 0; | 193 | // stats->totalbytes = 0; |
195 | dialnumber = 0; | 194 | dialnumber = 0; |
196 | 195 | ||
197 | // p_kppp->con_speed = ""; | 196 | // p_kppp->con_speed = ""; |
198 | 197 | ||
199 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); | 198 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
200 | 199 | ||
201 | comlist = &_ifaceppp->data()->scriptType(); | 200 | comlist = &_ifaceppp->data()->scriptType(); |
202 | arglist = &_ifaceppp->data()->script(); | 201 | arglist = &_ifaceppp->data()->script(); |
203 | 202 | ||
204 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); | 203 | QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
205 | setCaption(tit); | 204 | setCaption(tit); |
206 | 205 | ||
207 | qApp->processEvents(); | 206 | qApp->processEvents(); |
208 | 207 | ||
209 | // run the "before-connect" command | 208 | // run the "before-connect" command |
210 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { | 209 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
211 | messg->setText(i18n("Running pre-startup command...")); | 210 | messg->setText(QObject::tr("Running pre-startup command...")); |
212 | emit debugMessage(i18n("Running pre-startup command...")); | 211 | emit debugMessage(QObject::tr("Running pre-startup command...")); |
213 | 212 | ||
214 | qApp->processEvents(); | 213 | qApp->processEvents(); |
215 | QApplication::flushX(); | 214 | QApplication::flushX(); |
216 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); | 215 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
217 | // int i, status; | 216 | // int i, status; |
218 | 217 | ||
219 | // do { | 218 | // do { |
220 | // qApp->processEvents(); | 219 | // qApp->processEvents(); |
221 | // i = waitpid(id, &status, WNOHANG); | 220 | // i = waitpid(id, &status, WNOHANG); |
222 | // usleep(100000); | 221 | // usleep(100000); |
223 | // } while (i == 0 && errno == 0); | 222 | // } while (i == 0 && errno == 0); |
224 | } | 223 | } |
225 | 224 | ||
226 | int lock = _ifaceppp->modem()->lockdevice(); | 225 | int lock = _ifaceppp->modem()->lockdevice(); |
227 | 226 | ||
228 | if (lock == 1) { | 227 | if (lock == 1) { |
229 | messg->setText(i18n("Modem device is locked.")); | 228 | messg->setText(QObject::tr("Modem device is locked.")); |
230 | vmain = 20; // wait until cancel is pressed | 229 | vmain = 20; // wait until cancel is pressed |
231 | return; | 230 | return; |
232 | } | 231 | } |
233 | 232 | ||
234 | if (lock == -1) { | 233 | if (lock == -1) { |
235 | messg->setText(i18n("Unable to create modem lock file.")); | 234 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
236 | vmain = 20; // wait until cancel is pressed | 235 | vmain = 20; // wait until cancel is pressed |
237 | return; | 236 | return; |
238 | } | 237 | } |
239 | 238 | ||
240 | if(_ifaceppp->modem()->opentty()) { | 239 | if(_ifaceppp->modem()->opentty()) { |
241 | messg->setText(_ifaceppp->modem()->modemMessage()); | 240 | messg->setText(_ifaceppp->modem()->modemMessage()); |
242 | qApp->processEvents(); | 241 | qApp->processEvents(); |
243 | if(_ifaceppp->modem()->hangup()) { | 242 | if(_ifaceppp->modem()->hangup()) { |
244 | 243 | ||
245 | qApp->processEvents(); | 244 | qApp->processEvents(); |
246 | 245 | ||
247 | semaphore = false; | 246 | semaphore = false; |
248 | 247 | ||
249 | _ifaceppp->modem()->stop(); | 248 | _ifaceppp->modem()->stop(); |
250 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); | 249 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
251 | 250 | ||
252 | // if we are stuck anywhere we will time out | 251 | // if we are stuck anywhere we will time out |
253 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 252 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
254 | 253 | ||
255 | // this timer will run the script etc. | 254 | // this timer will run the script etc. |
256 | main_timer_ID = startTimer(10); | 255 | main_timer_ID = startTimer(10); |
257 | 256 | ||
258 | return; | 257 | return; |
259 | } | 258 | } |
260 | } | 259 | } |
261 | 260 | ||
262 | // initialization failed | 261 | // initialization failed |
263 | messg->setText(_ifaceppp->modem()->modemMessage()); | 262 | messg->setText(_ifaceppp->modem()->modemMessage()); |
264 | vmain = 20; // wait until cancel is pressed | 263 | vmain = 20; // wait until cancel is pressed |
265 | _ifaceppp->modem()->unlockdevice(); | 264 | _ifaceppp->modem()->unlockdevice(); |
266 | } | 265 | } |
267 | 266 | ||
268 | 267 | ||
269 | void ConnectWidget::timerEvent(QTimerEvent *) { | 268 | void ConnectWidget::timerEvent(QTimerEvent *) { |
270 | if (semaphore || pausing) | 269 | if (semaphore || pausing) |
271 | return; | 270 | return; |
272 | 271 | ||
273 | if(vmain == 0) { | 272 | if(vmain == 0) { |
274 | #ifdef DEBUG_WO_DIALING | 273 | #ifdef DEBUG_WO_DIALING |
275 | vmain = 10; | 274 | vmain = 10; |
276 | return; | 275 | return; |
277 | #endif | 276 | #endif |
278 | 277 | ||
279 | assert(PPPData::NumInitStrings > 0); | 278 | assert(PPPData::NumInitStrings > 0); |
280 | // first init string ? | 279 | // first init string ? |
281 | if(substate == -1) { | 280 | if(substate == -1) { |
282 | messg->setText(i18n("Initializing modem...")); | 281 | messg->setText(QObject::tr("Initializing modem...")); |
283 | emit debugMessage(i18n("Initializing modem...")); | 282 | emit debugMessage(QObject::tr("Initializing modem...")); |
284 | substate = 0; | 283 | substate = 0; |
285 | } | 284 | } |
286 | 285 | ||
287 | QString initStr = _ifaceppp->data()->modemInitStr(substate); | 286 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
288 | if (!initStr.isEmpty()) { | 287 | if (!initStr.isEmpty()) { |
289 | // send a carriage return and then wait a bit so that the modem will | 288 | // send a carriage return and then wait a bit so that the modem will |
290 | // let us issue commands. | 289 | // let us issue commands. |
291 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { | 290 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
292 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 291 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
293 | writeline(""); | 292 | writeline(""); |
294 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 293 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
295 | } | 294 | } |
296 | setExpect(_ifaceppp->data()->modemInitResp()); | 295 | setExpect(_ifaceppp->data()->modemInitResp()); |
297 | writeline(initStr); | 296 | writeline(initStr); |
298 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 297 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
299 | } | 298 | } |
300 | 299 | ||
301 | substate++; | 300 | substate++; |
302 | 301 | ||
303 | /* | 302 | /* |
304 | * FIXME after 3.0: Make it possible to disable ATS11 since it | 303 | * FIXME after 3.0: Make it possible to disable ATS11 since it |
305 | * seems to be incompatible with some ISDN adapters (e.g. DataBox | 304 | * seems to be incompatible with some ISDN adapters (e.g. DataBox |
306 | * Speed Dragon). Even better would be to detect this when doing | 305 | * Speed Dragon). Even better would be to detect this when doing |
307 | * a "Modem Query" | 306 | * a "Modem Query" |
308 | */ | 307 | */ |
309 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) | 308 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
310 | vmain = 5; | 309 | vmain = 5; |
311 | else | 310 | else |
312 | vmain = 3; | 311 | vmain = 3; |
313 | 312 | ||
314 | return; | 313 | return; |
315 | } | 314 | } |
316 | 315 | ||
317 | if (vmain == 5) { | 316 | if (vmain == 5) { |
318 | if(!expecting) { | 317 | if(!expecting) { |
319 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); | 318 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
320 | QString msg = i18n("Setting ") + sToneDuration; | 319 | QString msg = QObject::tr("Setting ") + sToneDuration; |
321 | messg->setText(msg); | 320 | messg->setText(msg); |
322 | emit debugMessage(msg); | 321 | emit debugMessage(msg); |
323 | setExpect(_ifaceppp->data()->modemInitResp()); | 322 | setExpect(_ifaceppp->data()->modemInitResp()); |
324 | writeline(sToneDuration); | 323 | writeline(sToneDuration); |
325 | } | 324 | } |
326 | vmain = 3; | 325 | vmain = 3; |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | 328 | ||
330 | if(vmain == 3) { | 329 | if(vmain == 3) { |
331 | if(!expecting) { | 330 | if(!expecting) { |
332 | // done with all init strings ? | 331 | // done with all init strings ? |
333 | if(substate < PPPData::NumInitStrings) { | 332 | if(substate < PPPData::NumInitStrings) { |
334 | vmain = 0; | 333 | vmain = 0; |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | substate = -1; | 336 | substate = -1; |
338 | // skip setting the volume if command is empty | 337 | // skip setting the volume if command is empty |
339 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { | 338 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
340 | vmain = 4; | 339 | vmain = 4; |
341 | return; | 340 | return; |
342 | } | 341 | } |
343 | messg->setText(i18n("Setting speaker volume...")); | 342 | messg->setText(QObject::tr("Setting speaker volume...")); |
344 | emit debugMessage(i18n("Setting speaker volume...")); | 343 | emit debugMessage(QObject::tr("Setting speaker volume...")); |
345 | 344 | ||
346 | setExpect(_ifaceppp->data()->modemInitResp()); | 345 | setExpect(_ifaceppp->data()->modemInitResp()); |
347 | QString vol("AT"); | 346 | QString vol("AT"); |
348 | vol += _ifaceppp->data()->volumeInitString(); | 347 | vol += _ifaceppp->data()->volumeInitString(); |
349 | writeline(vol); | 348 | writeline(vol); |
350 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 349 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
351 | vmain = 4; | 350 | vmain = 4; |
352 | return; | 351 | return; |
353 | } | 352 | } |
354 | } | 353 | } |
355 | 354 | ||
356 | if(vmain == 4) { | 355 | if(vmain == 4) { |
357 | if(!expecting) { | 356 | if(!expecting) { |
358 | if(!_ifaceppp->data()->waitForDialTone()) { | 357 | if(!_ifaceppp->data()->waitForDialTone()) { |
359 | QString msg = i18n("Turning off dial tone waiting..."); | 358 | QString msg = QObject::tr("Turning off dial tone waiting..."); |
360 | messg->setText(msg); | 359 | messg->setText(msg); |
361 | emit debugMessage(msg); | 360 | emit debugMessage(msg); |
362 | setExpect(_ifaceppp->data()->modemInitResp()); | 361 | setExpect(_ifaceppp->data()->modemInitResp()); |
363 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); | 362 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
364 | } | 363 | } |
365 | vmain = 1; | 364 | vmain = 1; |
366 | return; | 365 | return; |
367 | } | 366 | } |
368 | } | 367 | } |
369 | 368 | ||
370 | // dial the number and wait to connect | 369 | // dial the number and wait to connect |
371 | if(vmain == 1) { | 370 | if(vmain == 1) { |
372 | if(!expecting) { | 371 | if(!expecting) { |
373 | 372 | ||
374 | timeout_timer->stop(); | 373 | timeout_timer->stop(); |
375 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 374 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
376 | 375 | ||
377 | QStringList &plist = _ifaceppp->data()->phonenumbers(); | 376 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
378 | QString bmarg= _ifaceppp->data()->dialPrefix(); | 377 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
379 | bmarg += *plist.at(dialnumber); | 378 | bmarg += *plist.at(dialnumber); |
380 | QString bm = i18n("Dialing %1").arg(bmarg); | 379 | QString bm = QObject::tr("Dialing %1").arg(bmarg); |
381 | messg->setText(bm); | 380 | messg->setText(bm); |
382 | emit debugMessage(bm); | 381 | emit debugMessage(bm); |
383 | 382 | ||
384 | QString pn = _ifaceppp->data()->modemDialStr(); | 383 | QString pn = _ifaceppp->data()->modemDialStr(); |
385 | pn += _ifaceppp->data()->dialPrefix(); | 384 | pn += _ifaceppp->data()->dialPrefix(); |
386 | pn += *plist.at(dialnumber); | 385 | pn += *plist.at(dialnumber); |
387 | if(++dialnumber >= plist.count()) | 386 | if(++dialnumber >= plist.count()) |
388 | dialnumber = 0; | 387 | dialnumber = 0; |
389 | writeline(pn); | 388 | writeline(pn); |
390 | 389 | ||
391 | setExpect(_ifaceppp->data()->modemConnectResp()); | 390 | setExpect(_ifaceppp->data()->modemConnectResp()); |
392 | vmain = 100; | 391 | vmain = 100; |
393 | return; | 392 | return; |
394 | } | 393 | } |
395 | } | 394 | } |
396 | 395 | ||
397 | // wait for connect, but redial if BUSY or wait for user cancel | 396 | // wait for connect, but redial if BUSY or wait for user cancel |
398 | // if NO CARRIER or NO DIALTONE | 397 | // if NO CARRIER or NO DIALTONE |
399 | if(vmain == 100) { | 398 | if(vmain == 100) { |
400 | if(!expecting) { | 399 | if(!expecting) { |
401 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); | 400 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
402 | setExpect("\n"); | 401 | setExpect("\n"); |
403 | vmain = 101; | 402 | vmain = 101; |
404 | return; | 403 | return; |
405 | } | 404 | } |
406 | 405 | ||
407 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { | 406 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
408 | timeout_timer->stop(); | 407 | timeout_timer->stop(); |
409 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 408 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
410 | 409 | ||
411 | messg->setText(i18n("Line busy. Hanging up...")); | 410 | messg->setText(QObject::tr("Line busy. Hanging up...")); |
412 | emit debugPutChar('\n'); | 411 | emit debugPutChar('\n'); |
413 | _ifaceppp->modem()->hangup(); | 412 | _ifaceppp->modem()->hangup(); |
414 | 413 | ||
415 | if(_ifaceppp->data()->busyWait() > 0) { | 414 | if(_ifaceppp->data()->busyWait() > 0) { |
416 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); | 415 | QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
417 | messg->setText(bm); | 416 | messg->setText(bm); |
418 | emit debugMessage(bm); | 417 | emit debugMessage(bm); |
419 | 418 | ||
420 | pausing = true; | 419 | pausing = true; |
421 | 420 | ||
422 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); | 421 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
423 | timeout_timer->stop(); | 422 | timeout_timer->stop(); |
424 | } | 423 | } |
425 | 424 | ||
426 | _ifaceppp->modem()->setDataMode(false); | 425 | _ifaceppp->modem()->setDataMode(false); |
427 | vmain = 0; | 426 | vmain = 0; |
428 | substate = -1; | 427 | substate = -1; |
429 | return; | 428 | return; |
430 | } | 429 | } |
431 | 430 | ||
432 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { | 431 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
433 | timeout_timer->stop(); | 432 | timeout_timer->stop(); |
434 | 433 | ||
435 | messg->setText(i18n("No Dialtone")); | 434 | messg->setText(QObject::tr("No Dialtone")); |
436 | vmain = 20; | 435 | vmain = 20; |
437 | _ifaceppp->modem()->unlockdevice(); | 436 | _ifaceppp->modem()->unlockdevice(); |
438 | return; | 437 | return; |
439 | } | 438 | } |
440 | 439 | ||
441 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { | 440 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
442 | timeout_timer->stop(); | 441 | timeout_timer->stop(); |
443 | 442 | ||
444 | messg->setText(i18n("No Carrier")); | 443 | messg->setText(QObject::tr("No Carrier")); |
445 | vmain = 20; | 444 | vmain = 20; |
446 | _ifaceppp->modem()->unlockdevice(); | 445 | _ifaceppp->modem()->unlockdevice(); |
447 | return; | 446 | return; |
448 | } | 447 | } |
449 | } | 448 | } |
450 | 449 | ||
451 | // wait for newline after CONNECT response (so we get the speed) | 450 | // wait for newline after CONNECT response (so we get the speed) |
452 | if(vmain == 101) { | 451 | if(vmain == 101) { |
453 | if(!expecting) { | 452 | if(!expecting) { |
454 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands | 453 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
455 | 454 | ||
456 | emit startAccounting(); | 455 | emit startAccounting(); |
457 | // p_kppp->con_win->startClock(); | 456 | // p_kppp->con_win->startClock(); |
458 | 457 | ||
459 | vmain = 2; | 458 | vmain = 2; |
460 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; | 459 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
461 | return; | 460 | return; |
462 | } | 461 | } |
463 | } | 462 | } |
464 | 463 | ||
465 | // execute the script | 464 | // execute the script |
466 | if(vmain == 2) { | 465 | if(vmain == 2) { |
467 | if(!expecting && !pausing && !scanning) { | 466 | if(!expecting && !pausing && !scanning) { |
468 | 467 | ||
469 | timeout_timer->stop(); | 468 | timeout_timer->stop(); |
470 | timeout_timer->start(scriptTimeout); | 469 | timeout_timer->start(scriptTimeout); |
471 | 470 | ||
472 | if((unsigned) scriptindex < comlist->count()) { | 471 | if((unsigned) scriptindex < comlist->count()) { |
473 | scriptCommand = *(comlist->at(scriptindex)); | 472 | scriptCommand = *(comlist->at(scriptindex)); |
474 | scriptArgument = *(arglist->at(scriptindex)); | 473 | scriptArgument = *(arglist->at(scriptindex)); |
475 | } else { | 474 | } else { |
476 | qDebug( "End of script" ); | 475 | qDebug( "End of script" ); |
477 | vmain = 10; | 476 | vmain = 10; |
478 | return; | 477 | return; |
479 | } | 478 | } |
480 | 479 | ||
481 | if (scriptCommand == "Scan") { | 480 | if (scriptCommand == "Scan") { |
482 | QString bm = i18n("Scanning %1").arg(scriptArgument); | 481 | QString bm = QObject::tr("Scanning %1").arg(scriptArgument); |
483 | messg->setText(bm); | 482 | messg->setText(bm); |
484 | emit debugMessage(bm); | 483 | emit debugMessage(bm); |
485 | 484 | ||
486 | setScan(scriptArgument); | 485 | setScan(scriptArgument); |
487 | scriptindex++; | 486 | scriptindex++; |
488 | return; | 487 | return; |
489 | } | 488 | } |
490 | 489 | ||
491 | if (scriptCommand == "Save") { | 490 | if (scriptCommand == "Save") { |
492 | QString bm = i18n("Saving %1").arg(scriptArgument); | 491 | QString bm = QObject::tr("Saving %1").arg(scriptArgument); |
493 | messg->setText(bm); | 492 | messg->setText(bm); |
494 | emit debugMessage(bm); | 493 | emit debugMessage(bm); |
495 | 494 | ||
496 | if (scriptArgument.lower() == "password") { | 495 | if (scriptArgument.lower() == "password") { |
497 | _ifaceppp->data()->setPassword(scanvar); | 496 | _ifaceppp->data()->setPassword(scanvar); |
498 | // p_kppp->setPW_Edit(scanvar); | 497 | // p_kppp->setPW_Edit(scanvar); |
499 | if(_ifaceppp->data()->storePassword()) | 498 | if(_ifaceppp->data()->storePassword()) |
500 | _ifaceppp->data()->setStoredPassword(scanvar); | 499 | _ifaceppp->data()->setStoredPassword(scanvar); |
501 | firstrunPW = true; | 500 | firstrunPW = true; |
502 | } | 501 | } |
503 | 502 | ||
504 | scriptindex++; | 503 | scriptindex++; |
505 | return; | 504 | return; |
506 | } | 505 | } |
507 | 506 | ||
508 | 507 | ||
509 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { | 508 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { |
510 | QString bm = i18n("Sending %1"); | 509 | QString bm = QObject::tr("Sending %1"); |
511 | 510 | ||
512 | // replace %USERNAME% and %PASSWORD% | 511 | // replace %USERNAME% and %PASSWORD% |
513 | QString arg = scriptArgument; | 512 | QString arg = scriptArgument; |
514 | QRegExp re1("%USERNAME%"); | 513 | QRegExp re1("%USERNAME%"); |
515 | QRegExp re2("%PASSWORD%"); | 514 | QRegExp re2("%PASSWORD%"); |
516 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); | 515 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
517 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); | 516 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
518 | 517 | ||
519 | if (scriptCommand == "Send") | 518 | if (scriptCommand == "Send") |
520 | bm = bm.arg(scriptArgument); | 519 | bm = bm.arg(scriptArgument); |
521 | else { | 520 | else { |
522 | for(uint i = 0; i < scriptArgument.length(); i++) | 521 | for(uint i = 0; i < scriptArgument.length(); i++) |
523 | bm = bm.arg("*"); | 522 | bm = bm.arg("*"); |
524 | } | 523 | } |
525 | 524 | ||
526 | messg->setText(bm); | 525 | messg->setText(bm); |
527 | emit debugMessage(bm); | 526 | emit debugMessage(bm); |
528 | 527 | ||
529 | writeline(scriptArgument); | 528 | writeline(scriptArgument); |
530 | scriptindex++; | 529 | scriptindex++; |
531 | return; | 530 | return; |
532 | } | 531 | } |
533 | 532 | ||
534 | if (scriptCommand == "Expect") { | 533 | if (scriptCommand == "Expect") { |
535 | QString bm = i18n("Expecting %1").arg(scriptArgument); | 534 | QString bm = QObject::tr("Expecting %1").arg(scriptArgument); |
536 | messg->setText(bm); | 535 | messg->setText(bm); |
537 | emit debugMessage(bm); | 536 | emit debugMessage(bm); |
538 | 537 | ||
539 | // The incrementing of the scriptindex MUST be before the | 538 | // The incrementing of the scriptindex MUST be before the |
540 | // call to setExpect otherwise the expect will miss a string that is | 539 | // call to setExpect otherwise the expect will miss a string that is |
541 | // already in the buffer. | 540 | // already in the buffer. |
542 | scriptindex++; | 541 | scriptindex++; |
543 | setExpect(scriptArgument); | 542 | setExpect(scriptArgument); |
544 | return; | 543 | return; |
545 | } | 544 | } |
546 | 545 | ||
547 | 546 | ||
548 | if (scriptCommand == "Pause") { | 547 | if (scriptCommand == "Pause") { |
549 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); | 548 | QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); |
550 | messg->setText(bm); | 549 | messg->setText(bm); |
551 | emit debugMessage(bm); | 550 | emit debugMessage(bm); |
552 | 551 | ||
553 | pausing = true; | 552 | pausing = true; |
554 | 553 | ||
555 | pausetimer->start(scriptArgument.toInt()*1000, true); | 554 | pausetimer->start(scriptArgument.toInt()*1000, true); |
556 | timeout_timer->stop(); | 555 | timeout_timer->stop(); |
557 | 556 | ||
558 | scriptindex++; | 557 | scriptindex++; |
559 | return; | 558 | return; |
560 | } | 559 | } |
561 | 560 | ||
562 | if (scriptCommand == "Timeout") { | 561 | if (scriptCommand == "Timeout") { |
563 | 562 | ||
564 | timeout_timer->stop(); | 563 | timeout_timer->stop(); |
565 | 564 | ||
566 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); | 565 | QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); |
567 | messg->setText(bm); | 566 | messg->setText(bm); |
568 | emit debugMessage(bm); | 567 | emit debugMessage(bm); |
569 | 568 | ||
570 | scriptTimeout=scriptArgument.toInt()*1000; | 569 | scriptTimeout=scriptArgument.toInt()*1000; |
571 | timeout_timer->start(scriptTimeout); | 570 | timeout_timer->start(scriptTimeout); |
572 | 571 | ||
573 | scriptindex++; | 572 | scriptindex++; |
574 | return; | 573 | return; |
575 | } | 574 | } |
576 | 575 | ||
577 | if (scriptCommand == "Hangup") { | 576 | if (scriptCommand == "Hangup") { |
578 | messg->setText(i18n("Hangup")); | 577 | messg->setText(QObject::tr("Hangup")); |
579 | emit debugMessage(i18n("Hangup")); | 578 | emit debugMessage(QObject::tr("Hangup")); |
580 | 579 | ||
581 | writeline(_ifaceppp->data()->modemHangupStr()); | 580 | writeline(_ifaceppp->data()->modemHangupStr()); |
582 | setExpect(_ifaceppp->data()->modemHangupResp()); | 581 | setExpect(_ifaceppp->data()->modemHangupResp()); |
583 | 582 | ||
584 | scriptindex++; | 583 | scriptindex++; |
585 | return; | 584 | return; |
586 | } | 585 | } |
587 | 586 | ||
588 | if (scriptCommand == "Answer") { | 587 | if (scriptCommand == "Answer") { |
589 | 588 | ||
590 | timeout_timer->stop(); | 589 | timeout_timer->stop(); |
591 | 590 | ||
592 | messg->setText(i18n("Answer")); | 591 | messg->setText(QObject::tr("Answer")); |
593 | emit debugMessage(i18n("Answer")); | 592 | emit debugMessage(QObject::tr("Answer")); |
594 | 593 | ||
595 | setExpect(_ifaceppp->data()->modemRingResp()); | 594 | setExpect(_ifaceppp->data()->modemRingResp()); |
596 | vmain = 150; | 595 | vmain = 150; |
597 | return; | 596 | return; |
598 | } | 597 | } |
599 | 598 | ||
600 | if (scriptCommand == "ID") { | 599 | if (scriptCommand == "ID") { |
601 | QString bm = i18n("ID %1").arg(scriptArgument); | 600 | QString bm = QObject::tr("ID %1").arg(scriptArgument); |
602 | messg->setText(bm); | 601 | messg->setText(bm); |
603 | emit debugMessage(bm); | 602 | emit debugMessage(bm); |
604 | 603 | ||
605 | QString idstring = _ifaceppp->data()->password(); | 604 | QString idstring = _ifaceppp->data()->password(); |
606 | 605 | ||
607 | if(!idstring.isEmpty() && firstrunID) { | 606 | if(!idstring.isEmpty() && firstrunID) { |
608 | // the user entered an Id on the main kppp dialog | 607 | // the user entered an Id on the main kppp dialog |
609 | writeline(idstring); | 608 | writeline(idstring); |
610 | firstrunID = false; | 609 | firstrunID = false; |
611 | scriptindex++; | 610 | scriptindex++; |
612 | } | 611 | } |
613 | else { | 612 | else { |
614 | // the user didn't enter and Id on the main kppp dialog | 613 | // the user didn't enter and Id on the main kppp dialog |
615 | // let's query for an ID | 614 | // let's query for an ID |
616 | /* if not around yet, then post window... */ | 615 | /* if not around yet, then post window... */ |
617 | if (prompt->Consumed()) { | 616 | if (prompt->Consumed()) { |
618 | if (!(prompt->isVisible())) { | 617 | if (!(prompt->isVisible())) { |
619 | prompt->setPrompt(scriptArgument); | 618 | prompt->setPrompt(scriptArgument); |
620 | prompt->setEchoModeNormal(); | 619 | prompt->setEchoModeNormal(); |
621 | prompt->show(); | 620 | prompt->show(); |
622 | } | 621 | } |
623 | } else { | 622 | } else { |
624 | /* if prompt withdrawn ... then, */ | 623 | /* if prompt withdrawn ... then, */ |
625 | if(!(prompt->isVisible())) { | 624 | if(!(prompt->isVisible())) { |
626 | writeline(prompt->text()); | 625 | writeline(prompt->text()); |
627 | prompt->setConsumed(); | 626 | prompt->setConsumed(); |
628 | scriptindex++; | 627 | scriptindex++; |
629 | return; | 628 | return; |
630 | } | 629 | } |
631 | /* replace timeout value */ | 630 | /* replace timeout value */ |
632 | } | 631 | } |
633 | } | 632 | } |
634 | } | 633 | } |
635 | 634 | ||
636 | if (scriptCommand == "Password") { | 635 | if (scriptCommand == "Password") { |
637 | QString bm = i18n("Password %1").arg(scriptArgument); | 636 | QString bm = QObject::tr("Password %1").arg(scriptArgument); |
638 | messg->setText(bm); | 637 | messg->setText(bm); |
639 | emit debugMessage(bm); | 638 | emit debugMessage(bm); |
640 | 639 | ||
641 | QString pwstring = _ifaceppp->data()->password(); | 640 | QString pwstring = _ifaceppp->data()->password(); |
642 | 641 | ||
643 | if(!pwstring.isEmpty() && firstrunPW) { | 642 | if(!pwstring.isEmpty() && firstrunPW) { |
644 | // the user entered a password on the main kppp dialog | 643 | // the user entered a password on the main kppp dialog |
645 | writeline(pwstring); | 644 | writeline(pwstring); |
646 | firstrunPW = false; | 645 | firstrunPW = false; |
647 | scriptindex++; | 646 | scriptindex++; |
648 | } | 647 | } |
649 | else { | 648 | else { |
650 | // the user didn't enter a password on the main kppp dialog | 649 | // the user didn't enter a password on the main kppp dialog |
651 | // let's query for a password | 650 | // let's query for a password |
652 | /* if not around yet, then post window... */ | 651 | /* if not around yet, then post window... */ |
653 | if (prompt->Consumed()) { | 652 | if (prompt->Consumed()) { |
654 | if (!(prompt->isVisible())) { | 653 | if (!(prompt->isVisible())) { |
655 | prompt->setPrompt(scriptArgument); | 654 | prompt->setPrompt(scriptArgument); |
656 | prompt->setEchoModePassword(); | 655 | prompt->setEchoModePassword(); |
657 | prompt->show(); | 656 | prompt->show(); |
658 | } | 657 | } |
659 | } else { | 658 | } else { |
660 | /* if prompt withdrawn ... then, */ | 659 | /* if prompt withdrawn ... then, */ |
661 | if(!(prompt->isVisible())) { | 660 | if(!(prompt->isVisible())) { |
662 | // p_kppp->setPW_Edit(prompt->text()); | 661 | // p_kppp->setPW_Edit(prompt->text()); |
663 | writeline(prompt->text()); | 662 | writeline(prompt->text()); |
664 | prompt->setConsumed(); | 663 | prompt->setConsumed(); |
665 | scriptindex++; | 664 | scriptindex++; |
666 | return; | 665 | return; |
667 | } | 666 | } |
668 | /* replace timeout value */ | 667 | /* replace timeout value */ |
669 | } | 668 | } |
670 | } | 669 | } |
671 | } | 670 | } |
672 | 671 | ||
673 | if (scriptCommand == "Prompt") { | 672 | if (scriptCommand == "Prompt") { |
674 | QString bm = i18n("Prompting %1"); | 673 | QString bm = QObject::tr("Prompting %1"); |
675 | 674 | ||
676 | // if the scriptindex (aka the prompt text) includes a ## marker | 675 | // if the scriptindex (aka the prompt text) includes a ## marker |
677 | // this marker should get substituted with the contents of our stored | 676 | // this marker should get substituted with the contents of our stored |
678 | // variable (from the subsequent scan). | 677 | // variable (from the subsequent scan). |
679 | 678 | ||
680 | QString ts = scriptArgument; | 679 | QString ts = scriptArgument; |
681 | int vstart = ts.find( "##" ); | 680 | int vstart = ts.find( "##" ); |
682 | if( vstart != -1 ) { | 681 | if( vstart != -1 ) { |
683 | ts.remove( vstart, 2 ); | 682 | ts.remove( vstart, 2 ); |
684 | ts.insert( vstart, scanvar ); | 683 | ts.insert( vstart, scanvar ); |
685 | } | 684 | } |
686 | 685 | ||
687 | bm = bm.arg(ts); | 686 | bm = bm.arg(ts); |
688 | messg->setText(bm); | 687 | messg->setText(bm); |
689 | emit debugMessage(bm); | 688 | emit debugMessage(bm); |
690 | 689 | ||
691 | /* if not around yet, then post window... */ | 690 | /* if not around yet, then post window... */ |
692 | if (prompt->Consumed()) { | 691 | if (prompt->Consumed()) { |
693 | if (!(prompt->isVisible())) { | 692 | if (!(prompt->isVisible())) { |
694 | prompt->setPrompt( ts ); | 693 | prompt->setPrompt( ts ); |
695 | prompt->setEchoModeNormal(); | 694 | prompt->setEchoModeNormal(); |
696 | prompt->show(); | 695 | prompt->show(); |
697 | } | 696 | } |
698 | } else { | 697 | } else { |
699 | /* if prompt withdrawn ... then, */ | 698 | /* if prompt withdrawn ... then, */ |
700 | if (!(prompt->isVisible())) { | 699 | if (!(prompt->isVisible())) { |
701 | writeline(prompt->text()); | 700 | writeline(prompt->text()); |
702 | prompt->setConsumed(); | 701 | prompt->setConsumed(); |
703 | scriptindex++; | 702 | scriptindex++; |
704 | return; | 703 | return; |
705 | } | 704 | } |
706 | /* replace timeout value */ | 705 | /* replace timeout value */ |
707 | } | 706 | } |
708 | } | 707 | } |
709 | 708 | ||
710 | if (scriptCommand == "PWPrompt") { | 709 | if (scriptCommand == "PWPrompt") { |
711 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); | 710 | QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); |
712 | messg->setText(bm); | 711 | messg->setText(bm); |
713 | emit debugMessage(bm); | 712 | emit debugMessage(bm); |
714 | 713 | ||
715 | /* if not around yet, then post window... */ | 714 | /* if not around yet, then post window... */ |
716 | if (prompt->Consumed()) { | 715 | if (prompt->Consumed()) { |
717 | if (!(prompt->isVisible())) { | 716 | if (!(prompt->isVisible())) { |
718 | prompt->setPrompt(scriptArgument); | 717 | prompt->setPrompt(scriptArgument); |
719 | prompt->setEchoModePassword(); | 718 | prompt->setEchoModePassword(); |
720 | prompt->show(); | 719 | prompt->show(); |
721 | } | 720 | } |
722 | } else { | 721 | } else { |
723 | /* if prompt withdrawn ... then, */ | 722 | /* if prompt withdrawn ... then, */ |
724 | if (!(prompt->isVisible())) { | 723 | if (!(prompt->isVisible())) { |
725 | writeline(prompt->text()); | 724 | writeline(prompt->text()); |
726 | prompt->setConsumed(); | 725 | prompt->setConsumed(); |
727 | scriptindex++; | 726 | scriptindex++; |
728 | return; | 727 | return; |
729 | } | 728 | } |
730 | /* replace timeout value */ | 729 | /* replace timeout value */ |
731 | } | 730 | } |
732 | } | 731 | } |
733 | 732 | ||
734 | if (scriptCommand == "LoopStart") { | 733 | if (scriptCommand == "LoopStart") { |
735 | 734 | ||
736 | QString bm = i18n("Loop Start %1").arg(scriptArgument); | 735 | QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); |
737 | 736 | ||
738 | // The incrementing of the scriptindex MUST be before the | 737 | // The incrementing of the scriptindex MUST be before the |
739 | // call to setExpect otherwise the expect will miss a string that is | 738 | // call to setExpect otherwise the expect will miss a string that is |
740 | // already in the buffer. | 739 | // already in the buffer. |
741 | scriptindex++; | 740 | scriptindex++; |
742 | 741 | ||
743 | if ( loopnest > (MAXLOOPNEST-2) ) { | 742 | if ( loopnest > (MAXLOOPNEST-2) ) { |
744 | bm += i18n("ERROR: Nested too deep, ignored."); | 743 | bm += QObject::tr("ERROR: Nested too deep, ignored."); |
745 | vmain=20; | 744 | vmain=20; |
746 | cancelbutton(); | 745 | cancelbutton(); |
747 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); | 746 | QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); |
748 | } else { | 747 | } else { |
749 | setExpect(scriptArgument); | 748 | setExpect(scriptArgument); |
750 | loopstartindex[loopnest] = scriptindex; | 749 | loopstartindex[loopnest] = scriptindex; |
751 | loopstr[loopnest] = scriptArgument; | 750 | loopstr[loopnest] = scriptArgument; |
752 | loopend = false; | 751 | loopend = false; |
753 | loopnest++; | 752 | loopnest++; |
754 | } | 753 | } |
755 | messg->setText(bm); | 754 | messg->setText(bm); |
756 | emit debugMessage(bm); | 755 | emit debugMessage(bm); |
757 | 756 | ||
758 | } | 757 | } |
759 | 758 | ||
760 | if (scriptCommand == "LoopEnd") { | 759 | if (scriptCommand == "LoopEnd") { |
761 | QString bm = i18n("Loop End %1").arg(scriptArgument); | 760 | QString bm = QObject::tr("Loop End %1").arg(scriptArgument); |
762 | if ( loopnest <= 0 ) { | 761 | if ( loopnest <= 0 ) { |
763 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); | 762 | bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); |
764 | vmain=20; | 763 | vmain=20; |
765 | cancelbutton(); | 764 | cancelbutton(); |
766 | QMessageBox::critical(0, "error", bm); | 765 | QMessageBox::critical(0, "error", bm); |
767 | return; | 766 | return; |
768 | } else { | 767 | } else { |
769 | // NB! The incrementing of the scriptindex MUST be before the | 768 | // NB! The incrementing of the scriptindex MUST be before the |
770 | // call to setExpect otherwise the expect will miss a string | 769 | // call to setExpect otherwise the expect will miss a string |
771 | // that is already in the buffer. | 770 | // that is already in the buffer. |
772 | scriptindex++; | 771 | scriptindex++; |
773 | setExpect(scriptArgument); | 772 | setExpect(scriptArgument); |
774 | loopnest--; | 773 | loopnest--; |
775 | loopend = true; | 774 | loopend = true; |
776 | } | 775 | } |
777 | messg->setText(bm); | 776 | messg->setText(bm); |
778 | emit debugMessage(bm); | 777 | emit debugMessage(bm); |
779 | 778 | ||
780 | } | 779 | } |
781 | } | 780 | } |
782 | } | 781 | } |
783 | 782 | ||
784 | // this is a subroutine for the "Answer" script option | 783 | // this is a subroutine for the "Answer" script option |
785 | 784 | ||
786 | if(vmain == 150) { | 785 | if(vmain == 150) { |
787 | if(!expecting) { | 786 | if(!expecting) { |
788 | writeline(_ifaceppp->data()->modemAnswerStr()); | 787 | writeline(_ifaceppp->data()->modemAnswerStr()); |
789 | setExpect(_ifaceppp->data()->modemAnswerResp()); | 788 | setExpect(_ifaceppp->data()->modemAnswerResp()); |
790 | 789 | ||
791 | vmain = 2; | 790 | vmain = 2; |
792 | scriptindex++; | 791 | scriptindex++; |
793 | return; | 792 | return; |
794 | } | 793 | } |
795 | } | 794 | } |
796 | 795 | ||
797 | if(vmain == 30) { | 796 | if(vmain == 30) { |
798 | // if (termwindow->isVisible()) | 797 | // if (termwindow->isVisible()) |
799 | // return; | 798 | // return; |
800 | // if (termwindow->pressedContinue()) | 799 | // if (termwindow->pressedContinue()) |
801 | // vmain = 10; | 800 | // vmain = 10; |
802 | // else | 801 | // else |
803 | cancelbutton(); | 802 | cancelbutton(); |
804 | } | 803 | } |
805 | 804 | ||
806 | if(vmain == 10) { | 805 | if(vmain == 10) { |
807 | if(!expecting) { | 806 | if(!expecting) { |
808 | 807 | ||
809 | int result; | 808 | int result; |
810 | 809 | ||
811 | timeout_timer->stop(); | 810 | timeout_timer->stop(); |
812 | if_timeout_timer->stop(); // better be sure. | 811 | if_timeout_timer->stop(); // better be sure. |
813 | 812 | ||
814 | // stop reading of data | 813 | // stop reading of data |
815 | _ifaceppp->modem()->stop(); | 814 | _ifaceppp->modem()->stop(); |
816 | 815 | ||
817 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { | 816 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
818 | // if (termwindow) { | 817 | // if (termwindow) { |
819 | // delete termwindow; | 818 | // delete termwindow; |
820 | // termwindow = 0L; | 819 | // termwindow = 0L; |
821 | // this->show(); | 820 | // this->show(); |
822 | // } else { | 821 | // } else { |
823 | // termwindow = new LoginTerm(0L, 0L); | 822 | // termwindow = new LoginTerm(0L, 0L); |
824 | // hide(); | 823 | // hide(); |
825 | // termwindow->show(); | 824 | // termwindow->show(); |
826 | // vmain = 30; | 825 | // vmain = 30; |
827 | // return; | 826 | // return; |
828 | // } | 827 | // } |
829 | } | 828 | } |
830 | 829 | ||
831 | // Close the tty. This prevents the QTimer::singleShot() in | 830 | // Close the tty. This prevents the QTimer::singleShot() in |
832 | // Modem::readtty() from re-enabling the socket notifier. | 831 | // Modem::readtty() from re-enabling the socket notifier. |
833 | // The port is still held open by the helper process. | 832 | // The port is still held open by the helper process. |
834 | 833 | ||
835 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), | 834 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), |
836 | and closing the thing prevents pppd from using it later. */ | 835 | and closing the thing prevents pppd from using it later. */ |
837 | //_ifaceppp->modem()->closetty(); | 836 | //_ifaceppp->modem()->closetty(); |
838 | 837 | ||
839 | killTimer( main_timer_ID ); | 838 | killTimer( main_timer_ID ); |
840 | 839 | ||
841 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 840 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
842 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 841 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
843 | 842 | ||
844 | // find out PPP interface and notify the stats module | 843 | // find out PPP interface and notify the stats module |
845 | // stats->setUnit(pppInterfaceNumber()); | 844 | // stats->setUnit(pppInterfaceNumber()); |
846 | 845 | ||
847 | qApp->flushX(); | 846 | qApp->flushX(); |
848 | semaphore = true; | 847 | semaphore = true; |
849 | result = execppp(); | 848 | result = execppp(); |
850 | 849 | ||
851 | emit debugMessage(i18n("Starting pppd...")); | 850 | emit debugMessage(QObject::tr("Starting pppd...")); |
852 | qDebug("execppp() returned with return-code %i", result ); | 851 | qDebug("execppp() returned with return-code %i", result ); |
853 | 852 | ||
854 | if(result) { | 853 | if(result) { |
855 | if(!_ifaceppp->data()->autoDNS()) | 854 | if(!_ifaceppp->data()->autoDNS()) |
856 | adddns( _ifaceppp ); | 855 | adddns( _ifaceppp ); |
857 | 856 | ||
858 | // O.K we are done here, let's change over to the if_waiting loop | 857 | // O.K we are done here, let's change over to the if_waiting loop |
859 | // where we wait for the ppp if (interface) to come up. | 858 | // where we wait for the ppp if (interface) to come up. |
860 | 859 | ||
861 | emit if_waiting_signal(); | 860 | emit if_waiting_signal(); |
862 | } else { | 861 | } else { |
863 | 862 | ||
864 | // starting pppd wasn't successful. Error messages were | 863 | // starting pppd wasn't successful. Error messages were |
865 | // handled by execppp(); | 864 | // handled by execppp(); |
866 | if_timeout_timer->stop(); | 865 | if_timeout_timer->stop(); |
867 | this->hide(); | 866 | this->hide(); |
868 | messg->setText(""); | 867 | messg->setText(""); |
869 | //p_kppp->quit_b->setFocus(); | 868 | //p_kppp->quit_b->setFocus(); |
870 | //p_kppp->show(); | 869 | //p_kppp->show(); |
871 | qApp->processEvents(); | 870 | qApp->processEvents(); |
872 | _ifaceppp->modem()->hangup(); | 871 | _ifaceppp->modem()->hangup(); |
873 | emit stopAccounting(); | 872 | emit stopAccounting(); |
874 | //p_kppp->con_win->stopClock(); | 873 | //p_kppp->con_win->stopClock(); |
875 | _ifaceppp->modem()->closetty(); | 874 | _ifaceppp->modem()->closetty(); |
876 | _ifaceppp->modem()->unlockdevice(); | 875 | _ifaceppp->modem()->unlockdevice(); |
877 | 876 | ||
878 | } | 877 | } |
879 | 878 | ||
880 | return; | 879 | return; |
881 | } | 880 | } |
882 | } | 881 | } |
883 | 882 | ||
884 | // this is a "wait until cancel" entry | 883 | // this is a "wait until cancel" entry |
885 | 884 | ||
886 | if(vmain == 20) { | 885 | if(vmain == 20) { |
887 | } | 886 | } |
888 | } | 887 | } |
889 | 888 | ||
890 | 889 | ||
891 | void ConnectWidget::set_con_speed_string() { | 890 | void ConnectWidget::set_con_speed_string() { |
892 | // Here we are trying to determine the speed at which we are connected. | 891 | // Here we are trying to determine the speed at which we are connected. |
893 | // Usually the modem responds after connect with something like | 892 | // Usually the modem responds after connect with something like |
894 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 893 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
895 | // or whatever the modemConnectResp() is. | 894 | // or whatever the modemConnectResp() is. |
896 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); | 895 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
897 | } | 896 | } |
898 | 897 | ||
899 | 898 | ||
900 | 899 | ||
901 | void ConnectWidget::readChar(unsigned char c) { | 900 | void ConnectWidget::readChar(unsigned char c) { |
902 | if(semaphore) | 901 | if(semaphore) |
903 | return; | 902 | return; |
904 | 903 | ||
905 | readbuffer += c; | 904 | readbuffer += c; |
906 | myreadbuffer += c; | 905 | myreadbuffer += c; |
907 | 906 | ||
908 | // While in scanning mode store each char to the scan buffer | 907 | // While in scanning mode store each char to the scan buffer |
909 | // for use in the prompt command | 908 | // for use in the prompt command |
910 | if( scanning ) | 909 | if( scanning ) |
911 | scanbuffer += c; | 910 | scanbuffer += c; |
912 | 911 | ||
913 | // add to debug window | 912 | // add to debug window |
914 | emit debugPutChar(c); | 913 | emit debugPutChar(c); |
915 | 914 | ||
916 | checkBuffers(); | 915 | checkBuffers(); |
917 | } | 916 | } |
918 | 917 | ||
919 | 918 | ||
920 | void ConnectWidget::checkBuffers() { | 919 | void ConnectWidget::checkBuffers() { |
921 | // Let's check if we are finished with scanning: | 920 | // Let's check if we are finished with scanning: |
922 | // The scanstring have to be in the buffer and the latest character | 921 | // The scanstring have to be in the buffer and the latest character |
923 | // was a carriage return or an linefeed (depending on modem setup) | 922 | // was a carriage return or an linefeed (depending on modem setup) |
924 | if( scanning && scanbuffer.contains(scanstr) && | 923 | if( scanning && scanbuffer.contains(scanstr) && |
925 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 924 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
926 | scanning = false; | 925 | scanning = false; |
927 | 926 | ||
928 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 927 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
929 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 928 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
930 | scanvar = scanvar.stripWhiteSpace(); | 929 | scanvar = scanvar.stripWhiteSpace(); |
931 | 930 | ||
932 | // Show the Variabel content in the debug window | 931 | // Show the Variabel content in the debug window |
933 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 932 | QString sv = QObject::tr("Scan Var: %1").arg(scanvar); |
934 | emit debugMessage(sv); | 933 | emit debugMessage(sv); |
935 | } | 934 | } |
936 | 935 | ||
937 | if(expecting) { | 936 | if(expecting) { |
938 | if(readbuffer.contains(expectstr)) { | 937 | if(readbuffer.contains(expectstr)) { |
939 | expecting = false; | 938 | expecting = false; |
940 | // keep everything after the expected string | 939 | // keep everything after the expected string |
941 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 940 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
942 | 941 | ||
943 | QString ts = i18n("Found: %1").arg(expectstr); | 942 | QString ts = QObject::tr("Found: %1").arg(expectstr); |
944 | emit debugMessage(ts); | 943 | emit debugMessage(ts); |
945 | 944 | ||
946 | if (loopend) { | 945 | if (loopend) { |
947 | loopend=false; | 946 | loopend=false; |
948 | } | 947 | } |
949 | } | 948 | } |
950 | 949 | ||
951 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 950 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
952 | expecting = false; | 951 | expecting = false; |
953 | readbuffer = ""; | 952 | readbuffer = ""; |
954 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 953 | QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); |
955 | emit debugMessage(ts); | 954 | emit debugMessage(ts); |
956 | scriptindex = loopstartindex[loopnest]; | 955 | scriptindex = loopstartindex[loopnest]; |
957 | loopend = false; | 956 | loopend = false; |
958 | loopnest++; | 957 | loopnest++; |
959 | } | 958 | } |
960 | // notify event loop if expected string was found | 959 | // notify event loop if expected string was found |
961 | if(!expecting) | 960 | if(!expecting) |
962 | timerEvent((QTimerEvent *) 0); | 961 | timerEvent((QTimerEvent *) 0); |
963 | } | 962 | } |
964 | } | 963 | } |
965 | 964 | ||
966 | 965 | ||
967 | 966 | ||
968 | void ConnectWidget::pause() { | 967 | void ConnectWidget::pause() { |
969 | pausing = false; | 968 | pausing = false; |
970 | pausetimer->stop(); | 969 | pausetimer->stop(); |
971 | } | 970 | } |
972 | 971 | ||
973 | 972 | ||
974 | void ConnectWidget::cancelbutton() { | 973 | void ConnectWidget::cancelbutton() { |
975 | _ifaceppp->modem()->stop(); | 974 | _ifaceppp->modem()->stop(); |
976 | killTimer(main_timer_ID); | 975 | killTimer(main_timer_ID); |
977 | timeout_timer->stop(); | 976 | timeout_timer->stop(); |
978 | if_timer->stop(); | 977 | if_timer->stop(); |
979 | if_timeout_timer->stop(); | 978 | if_timeout_timer->stop(); |
980 | 979 | ||
981 | // if (termwindow) { | 980 | // if (termwindow) { |
982 | // delete termwindow; | 981 | // delete termwindow; |
983 | // termwindow = 0L; | 982 | // termwindow = 0L; |
984 | // this->show(); | 983 | // this->show(); |
985 | // } | 984 | // } |
986 | 985 | ||
987 | messg->setText(i18n("One moment please...")); | 986 | messg->setText(QObject::tr("One moment please...")); |
988 | 987 | ||
989 | // just to be sure | 988 | // just to be sure |
990 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 989 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
991 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 990 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
992 | removedns(_ifaceppp); | 991 | removedns(_ifaceppp); |
993 | 992 | ||
994 | qApp->processEvents(); | 993 | qApp->processEvents(); |
995 | 994 | ||
996 | _ifaceppp->modem()->killPPPDaemon(); | 995 | _ifaceppp->modem()->killPPPDaemon(); |
997 | _ifaceppp->modem()->hangup(); | 996 | _ifaceppp->modem()->hangup(); |
998 | 997 | ||
999 | 998 | ||
1000 | // p_kppp->quit_b->setFocus(); | 999 | // p_kppp->quit_b->setFocus(); |
1001 | // p_kppp->show(); | 1000 | // p_kppp->show(); |
1002 | // emit stopAccounting();// just to be sure | 1001 | // emit stopAccounting();// just to be sure |
1003 | // p_kppp->con_win->stopClock(); | 1002 | // p_kppp->con_win->stopClock(); |
1004 | _ifaceppp->modem()->closetty(); | 1003 | _ifaceppp->modem()->closetty(); |
1005 | _ifaceppp->modem()->unlockdevice(); | 1004 | _ifaceppp->modem()->unlockdevice(); |
1006 | 1005 | ||
1007 | //abort prompt window... | 1006 | //abort prompt window... |
1008 | if (prompt->isVisible()) { | 1007 | if (prompt->isVisible()) { |
1009 | prompt->hide(); | 1008 | prompt->hide(); |
1010 | } | 1009 | } |
1011 | prompt->setConsumed(); | 1010 | prompt->setConsumed(); |
1012 | 1011 | ||
1013 | messg->setText(tr("offline")); | 1012 | _ifaceppp->setStatus( false ); |
1013 | _ifaceppp->refresh(); | ||
1014 | // messg->setText(tr("offline")); | ||
1015 | refresh(); | ||
1014 | } | 1016 | } |
1015 | 1017 | ||
1016 | 1018 | ||
1017 | void ConnectWidget::script_timed_out() { | 1019 | void ConnectWidget::script_timed_out() { |
1018 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1020 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1019 | timeout_timer->stop(); | 1021 | timeout_timer->stop(); |
1020 | emit stopAccounting(); | 1022 | emit stopAccounting(); |
1021 | // p_kppp->con_win->stopClock(); | 1023 | // p_kppp->con_win->stopClock(); |
1022 | return; | 1024 | return; |
1023 | } | 1025 | } |
1024 | 1026 | ||
1025 | if (prompt->isVisible()) | 1027 | if (prompt->isVisible()) |
1026 | prompt->hide(); | 1028 | prompt->hide(); |
1027 | 1029 | ||
1028 | prompt->setConsumed(); | 1030 | prompt->setConsumed(); |
1029 | messg->setText(i18n("Script timed out!")); | 1031 | messg->setText(QObject::tr("Script timed out!")); |
1030 | _ifaceppp->modem()->hangup(); | 1032 | _ifaceppp->modem()->hangup(); |
1031 | emit stopAccounting(); | 1033 | emit stopAccounting(); |
1032 | // p_kppp->con_win->stopClock(); | 1034 | // p_kppp->con_win->stopClock(); |
1033 | 1035 | ||
1034 | vmain = 0; // let's try again. | 1036 | vmain = 0; // let's try again. |
1035 | substate = -1; | 1037 | substate = -1; |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | 1040 | ||
1039 | void ConnectWidget::setScan(const QString &n) { | 1041 | void ConnectWidget::setScan(const QString &n) { |
1040 | scanning = true; | 1042 | scanning = true; |
1041 | scanstr = n; | 1043 | scanstr = n; |
1042 | scanbuffer = ""; | 1044 | scanbuffer = ""; |
1043 | 1045 | ||
1044 | QString ts = i18n("Scanning: %1").arg(n); | 1046 | QString ts = QObject::tr("Scanning: %1").arg(n); |
1045 | emit debugMessage(ts); | 1047 | emit debugMessage(ts); |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | 1050 | ||
1049 | void ConnectWidget::setExpect(const QString &n) { | 1051 | void ConnectWidget::setExpect(const QString &n) { |
1050 | expecting = true; | 1052 | expecting = true; |
1051 | expectstr = n; | 1053 | expectstr = n; |
1052 | 1054 | ||
1053 | QString ts = i18n("Expecting: %1").arg(n); | 1055 | QString ts = QObject::tr("Expecting: %1").arg(n); |
1054 | ts.replace(QRegExp("\n"), "<LF>"); | 1056 | ts.replace(QRegExp("\n"), "<LF>"); |
1055 | emit debugMessage(ts); | 1057 | emit debugMessage(ts); |
1056 | 1058 | ||
1057 | // check if the expected string is in the read buffer already. | 1059 | // check if the expected string is in the read buffer already. |
1058 | checkBuffers(); | 1060 | checkBuffers(); |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | 1063 | ||
1062 | void ConnectWidget::if_waiting_timed_out() { | 1064 | void ConnectWidget::if_waiting_timed_out() { |
1063 | if_timer->stop(); | 1065 | if_timer->stop(); |
1064 | if_timeout_timer->stop(); | 1066 | if_timeout_timer->stop(); |
1065 | qDebug("if_waiting_timed_out()"); | 1067 | qDebug("if_waiting_timed_out()"); |
1066 | 1068 | ||
1067 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); | 1069 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1068 | 1070 | ||
1069 | // let's kill the stuck pppd | 1071 | // let's kill the stuck pppd |
1070 | _ifaceppp->modem()->killPPPDaemon(); | 1072 | _ifaceppp->modem()->killPPPDaemon(); |
1071 | 1073 | ||
1072 | emit stopAccounting(); | 1074 | emit stopAccounting(); |
1073 | // p_kppp->con_win->stopClock(); | 1075 | // p_kppp->con_win->stopClock(); |
1074 | 1076 | ||
1075 | 1077 | ||
1076 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1078 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1077 | // in main.cpp what happens next will depend on the boolean | 1079 | // in main.cpp what happens next will depend on the boolean |
1078 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1080 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1079 | } | 1081 | } |
1080 | 1082 | ||
1081 | void ConnectWidget::pppdDied() | 1083 | void ConnectWidget::pppdDied() |
1082 | { | 1084 | { |
1083 | if_timer->stop(); | 1085 | if_timer->stop(); |
1084 | if_timeout_timer->stop(); | 1086 | if_timeout_timer->stop(); |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | void ConnectWidget::if_waiting_slot() { | 1089 | void ConnectWidget::if_waiting_slot() { |
1088 | messg->setText(i18n("Logging on to network...")); | 1090 | messg->setText(QObject::tr("Logging on to network...")); |
1089 | 1091 | ||
1090 | // if(!stats->ifIsUp()) { | 1092 | // if(!stats->ifIsUp()) { |
1091 | 1093 | ||
1092 | // if(_ifaceppp->data()->pppdError() != 0) { | 1094 | // if(_ifaceppp->data()->pppdError() != 0) { |
1093 | // // we are here if pppd died immediately after starting it. | 1095 | // // we are here if pppd died immediately after starting it. |
1094 | // pppdDied(); | 1096 | // pppdDied(); |
1095 | // // error message handled in main.cpp: sigPPPDDied() | 1097 | // // error message handled in main.cpp: sigPPPDDied() |
1096 | // return; | 1098 | // return; |
1097 | // } | 1099 | // } |
1098 | 1100 | ||
1099 | // if_timer->start(100, TRUE); // single shot | 1101 | // if_timer->start(100, TRUE); // single shot |
1100 | // return; | 1102 | // return; |
1101 | // } | 1103 | // } |
1102 | 1104 | ||
1103 | // O.K the ppp interface is up and running | 1105 | // O.K the ppp interface is up and running |
1104 | // give it a few time to come up completly (0.2 seconds) | 1106 | // give it a few time to come up completly (0.2 seconds) |
1105 | if_timeout_timer->stop(); | 1107 | if_timeout_timer->stop(); |
1106 | if_timer->stop(); | 1108 | if_timer->stop(); |
1107 | usleep(200000); | 1109 | usleep(200000); |
1108 | 1110 | ||
1109 | if(_ifaceppp->data()->autoDNS()) | 1111 | if(_ifaceppp->data()->autoDNS()) |
1110 | addpeerdns( _ifaceppp ); | 1112 | addpeerdns( _ifaceppp ); |
1111 | 1113 | ||
1112 | // Close the debugging window. If we are connected, we | 1114 | // Close the debugging window. If we are connected, we |
1113 | // are not really interested in debug output | 1115 | // are not really interested in debug output |
1114 | emit closeDebugWindow(); | 1116 | emit closeDebugWindow(); |
1115 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1117 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1116 | auto_hostname(_ifaceppp); | 1118 | auto_hostname(_ifaceppp); |
1117 | 1119 | ||
1118 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1120 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1119 | messg->setText(i18n("Running startup command...")); | 1121 | messg->setText(QObject::tr("Running startup command...")); |
1120 | 1122 | ||
1121 | // make sure that we don't get any async errors | 1123 | // make sure that we don't get any async errors |
1122 | qApp->flushX(); | 1124 | qApp->flushX(); |
1123 | execute_command(_ifaceppp->data()->command_on_connect()); | 1125 | execute_command(_ifaceppp->data()->command_on_connect()); |
1124 | messg->setText(i18n("Done")); | 1126 | messg->setText(QObject::tr("Done")); |
1125 | } | 1127 | } |
1126 | 1128 | ||
1127 | // remove the authentication file | 1129 | // remove the authentication file |
1128 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1130 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1129 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1131 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1130 | 1132 | ||
1131 | emit debugMessage(i18n("Done")); | 1133 | emit debugMessage(QObject::tr("Done")); |
1132 | set_con_speed_string(); | 1134 | set_con_speed_string(); |
1133 | 1135 | ||
1134 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1136 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1135 | this->hide(); | 1137 | // this->hide(); |
1136 | messg->setText(""); | 1138 | // messg->setText(""); |
1137 | 1139 | ||
1138 | _ifaceppp->setStatus( true ); | 1140 | _ifaceppp->setStatus( true ); |
1141 | |||
1142 | m_refreshTimer = new QTimer( this ); | ||
1143 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
1144 | m_refreshTimer->start( 3000 ); | ||
1145 | //_ifaceppp->refresh(); | ||
1139 | // emit _ifaceppp->updateInterface(_ifaceppp); | 1146 | // emit _ifaceppp->updateInterface(_ifaceppp); |
1140 | 1147 | ||
1141 | // prepare the con_win so as to have the right size for | 1148 | // prepare the con_win so as to have the right size for |
1142 | // accounting / non-accounting mode | 1149 | // accounting / non-accounting mode |
1143 | // if(p_kppp->acct != 0) | 1150 | // if(p_kppp->acct != 0) |
1144 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1151 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1145 | // else | 1152 | // else |
1146 | // p_kppp->con_win->accounting(false); | 1153 | // p_kppp->con_win->accounting(false); |
1147 | 1154 | ||
1148 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1155 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1149 | // // DockWidget::dock_widget->show(); | 1156 | // // DockWidget::dock_widget->show(); |
1150 | // // DockWidget::dock_widget->take_stats(); | 1157 | // // DockWidget::dock_widget->take_stats(); |
1151 | // // this->hide(); | 1158 | // // this->hide(); |
1152 | // } | 1159 | // } |
1153 | // else { | 1160 | // else { |
1154 | // // p_kppp->con_win->show(); | 1161 | // // p_kppp->con_win->show(); |
1155 | 1162 | ||
1156 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1163 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1157 | // // p_kppp->con_win->showMinimized(); | 1164 | // // p_kppp->con_win->showMinimized(); |
1158 | // } | 1165 | // } |
1159 | // } | 1166 | // } |
1160 | 1167 | ||
1161 | _ifaceppp->modem()->closetty(); | 1168 | _ifaceppp->modem()->closetty(); |
1162 | } | 1169 | } |
1163 | 1170 | ||
1171 | void ConnectWidget::refresh() { | ||
1172 | _ifaceppp->refresh(); | ||
1173 | if ( _ifaceppp->getStatus() ) { | ||
1174 | messg->setText(QObject::tr("Online")); | ||
1175 | } else { | ||
1176 | messg->setText(QObject::tr("Offline")); | ||
1177 | } | ||
1178 | } | ||
1179 | |||
1164 | 1180 | ||
1165 | bool ConnectWidget::execppp() { | 1181 | bool ConnectWidget::execppp() { |
1166 | QString command; | 1182 | QString command; |
1167 | 1183 | ||
1168 | command = "pppd"; | 1184 | command = "pppd"; |
1169 | 1185 | ||
1170 | // as of version 2.3.6 pppd falls back to the real user rights when | 1186 | // as of version 2.3.6 pppd falls back to the real user rights when |
1171 | // opening a device given in a command line. To avoid permission conflicts | 1187 | // opening a device given in a command line. To avoid permission conflicts |
1172 | // we'll simply leave this argument away. pppd will then use the default tty | 1188 | // we'll simply leave this argument away. pppd will then use the default tty |
1173 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1189 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1174 | // command += " "; | 1190 | // command += " "; |
1175 | // command += _ifaceppp->data()->modemDevice(); | 1191 | // command += _ifaceppp->data()->modemDevice(); |
1176 | 1192 | ||
1177 | command += " " + _ifaceppp->data()->speed(); | 1193 | command += " " + _ifaceppp->data()->speed(); |
1178 | 1194 | ||
1179 | command += " -detach"; | 1195 | command += " -detach"; |
1180 | 1196 | ||
1181 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || | 1197 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1182 | _ifaceppp->data()->gateway() != "0.0.0.0") { | 1198 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1183 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { | 1199 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1184 | command += " "; | 1200 | command += " "; |
1185 | command += _ifaceppp->data()->ipaddr(); | 1201 | command += _ifaceppp->data()->ipaddr(); |
1186 | command += ":"; | 1202 | command += ":"; |
1187 | } | 1203 | } |
1188 | else { | 1204 | else { |
1189 | command += " "; | 1205 | command += " "; |
1190 | command += ":"; | 1206 | command += ":"; |
1191 | } | 1207 | } |
1192 | 1208 | ||
1193 | if(_ifaceppp->data()->gateway() != "0.0.0.0") | 1209 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1194 | command += _ifaceppp->data()->gateway(); | 1210 | command += _ifaceppp->data()->gateway(); |
1195 | } | 1211 | } |
1196 | 1212 | ||
1197 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") | 1213 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1198 | command += " netmask " + _ifaceppp->data()->subnetmask(); | 1214 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1199 | 1215 | ||
1200 | if(_ifaceppp->data()->flowcontrol() != "None") { | 1216 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1201 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1217 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1202 | command += " crtscts"; | 1218 | command += " crtscts"; |
1203 | else | 1219 | else |
1204 | command += " xonxoff"; | 1220 | command += " xonxoff"; |
1205 | } | 1221 | } |
1206 | 1222 | ||
1207 | if(_ifaceppp->data()->defaultroute()) | 1223 | if(_ifaceppp->data()->defaultroute()) |
1208 | command += " defaultroute"; | 1224 | command += " defaultroute"; |
1209 | 1225 | ||
1210 | if(_ifaceppp->data()->autoDNS()) | 1226 | if(_ifaceppp->data()->autoDNS()) |
1211 | command += " usepeerdns"; | 1227 | command += " usepeerdns"; |
1212 | 1228 | ||
1213 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1214 | for ( QStringList::Iterator it = arglist.begin(); | ||
1215 | it != arglist.end(); | ||
1216 | ++it ) | ||
1217 | { | ||
1218 | command += " " + *it; | ||
1219 | } | ||
1220 | 1229 | ||
1221 | // PAP settings | 1230 | // PAP settings |
1222 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { | 1231 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1223 | command += " -chap user "; | 1232 | command += " -chap user "; |
1224 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1233 | command = command + _ifaceppp->data()->storedUsername(); |
1225 | } | 1234 | } |
1226 | 1235 | ||
1227 | // CHAP settings | 1236 | // CHAP settings |
1228 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { | 1237 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1229 | command += " -pap user "; | 1238 | command += " -pap user "; |
1230 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1239 | command = command + _ifaceppp->data()->storedUsername(); |
1231 | } | 1240 | } |
1232 | 1241 | ||
1233 | // PAP/CHAP settings | 1242 | // PAP/CHAP settings |
1234 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { | 1243 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1235 | command += " user "; | 1244 | QString tmpName = _ifaceppp->data()->storedUsername(); |
1236 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1245 | if ( !tmpName.isEmpty() ) { |
1246 | command += " user "; | ||
1247 | command = command + tmpName; | ||
1248 | } | ||
1237 | } | 1249 | } |
1238 | 1250 | ||
1239 | // check for debug | 1251 | // check for debug |
1240 | if(_ifaceppp->data()->getPPPDebug()) | 1252 | if(_ifaceppp->data()->getPPPDebug()) |
1241 | command += " debug"; | 1253 | command += " debug"; |
1242 | 1254 | ||
1255 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1256 | for ( QStringList::Iterator it = arglist.begin(); | ||
1257 | it != arglist.end(); | ||
1258 | ++it ) | ||
1259 | { | ||
1260 | command += " " + *it; | ||
1261 | } | ||
1262 | |||
1263 | command += " call opie-kppp logfd 11"; | ||
1264 | |||
1243 | if (command.length() > MAX_CMDLEN) { | 1265 | if (command.length() > MAX_CMDLEN) { |
1244 | QMessageBox::critical(this, "error", i18n( | 1266 | QMessageBox::critical(this, "error", QObject::tr( |
1245 | "pppd command + command-line arguments exceed " | 1267 | "pppd command + command-line arguments exceed " |
1246 | "2024 characters in length." | 1268 | "2024 characters in length." |
1247 | )); | 1269 | )); |
1248 | 1270 | ||
1249 | return false; // nonsensically long command which would bust my buffer buf. | 1271 | return false; // nonsensically long command which would bust my buffer buf. |
1250 | } | 1272 | } |
1251 | 1273 | ||
1274 | qWarning("Command IS: %s",command.latin1() ); | ||
1275 | |||
1252 | qApp->flushX(); | 1276 | qApp->flushX(); |
1253 | 1277 | ||
1254 | return _ifaceppp->modem()->execPPPDaemon(command); | 1278 | return _ifaceppp->modem()->execPPPDaemon(command); |
1255 | } | 1279 | } |
1256 | 1280 | ||
1257 | 1281 | ||
1258 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1282 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1259 | e->ignore(); | 1283 | e->ignore(); |
1260 | emit cancelbutton(); | 1284 | emit cancelbutton(); |
1261 | } | 1285 | } |
1262 | 1286 | ||
1263 | 1287 | ||
1264 | void ConnectWidget::setMsg(const QString &msg) { | 1288 | void ConnectWidget::setMsg(const QString &msg) { |
1265 | messg->setText(msg); | 1289 | messg->setText(msg); |
1266 | } | 1290 | } |
1267 | 1291 | ||
1268 | void ConnectWidget::writeline(const QString &s) { | 1292 | void ConnectWidget::writeline(const QString &s) { |
1269 | _ifaceppp->modem()->writeLine(s.local8Bit()); | 1293 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1270 | } | 1294 | } |
1271 | 1295 | ||
1272 | // Set the hostname and domain from DNS Server | 1296 | // Set the hostname and domain from DNS Server |
1273 | void auto_hostname(InterfacePPP *_ifaceppp) { | 1297 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1274 | struct in_addr local_ip; | 1298 | struct in_addr local_ip; |
1275 | struct hostent *hostname_entry; | 1299 | struct hostent *hostname_entry; |
1276 | QString new_hostname; | 1300 | QString new_hostname; |
1277 | int dot; | 1301 | int dot; |
1278 | char tmp_str[100]; // buffer overflow safe | 1302 | char tmp_str[100]; // buffer overflow safe |
1279 | 1303 | ||
1280 | gethostname(tmp_str, sizeof(tmp_str)); | 1304 | gethostname(tmp_str, sizeof(tmp_str)); |
1281 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1305 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1282 | old_hostname=tmp_str; // copy to QString | 1306 | old_hostname=tmp_str; // copy to QString |
1283 | 1307 | ||
1284 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { | 1308 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1285 | if ( _ifaceppp->data()->autoname()) { | 1309 | if ( _ifaceppp->data()->autoname()) { |
1286 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); | 1310 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); |
1287 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); | 1311 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); |
1288 | 1312 | ||
1289 | if (hostname_entry != 0L) { | 1313 | if (hostname_entry != 0L) { |
1290 | new_hostname=hostname_entry->h_name; | 1314 | new_hostname=hostname_entry->h_name; |
1291 | dot=new_hostname.find('.'); | 1315 | dot=new_hostname.find('.'); |
1292 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); | 1316 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); |
1293 | _ifaceppp->modem()->setHostname(new_hostname); | 1317 | _ifaceppp->modem()->setHostname(new_hostname); |
1294 | modified_hostname = TRUE; | 1318 | modified_hostname = TRUE; |
1295 | 1319 | ||
1296 | new_hostname=hostname_entry->h_name; | 1320 | new_hostname=hostname_entry->h_name; |
1297 | new_hostname.remove(0,dot+1); | 1321 | new_hostname.remove(0,dot+1); |
1298 | 1322 | ||
1299 | add_domain(new_hostname, _ifaceppp); | 1323 | add_domain(new_hostname, _ifaceppp); |