summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/connect.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp166
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
@@ -23,25 +23,24 @@
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>
@@ -90,56 +89,56 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam
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());
@@ -164,25 +163,25 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam
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
169ConnectWidget::~ConnectWidget() { 168ConnectWidget::~ConnectWidget() {
170} 169}
171 170
172 171
173void ConnectWidget::preinit() { 172void 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
181void ConnectWidget::init() { 180void 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;
@@ -192,56 +191,56 @@ void ConnectWidget::init() {
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;
@@ -270,26 +269,26 @@ 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 }
@@ -308,85 +307,85 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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;
@@ -399,58 +398,58 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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();
@@ -470,144 +469,144 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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 {
@@ -625,25 +624,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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 {
@@ -662,25 +661,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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
@@ -699,77 +698,77 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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;
@@ -839,25 +838,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
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
@@ -921,46 +920,46 @@ 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
@@ -975,91 +974,94 @@ 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
1017void ConnectWidget::script_timed_out() { 1019void 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
1039void ConnectWidget::setScan(const QString &n) { 1041void 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
1049void ConnectWidget::setExpect(const QString &n) { 1051void 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
1062void ConnectWidget::if_waiting_timed_out() { 1064void 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()");
@@ -1076,25 +1078,25 @@ void ConnectWidget::if_waiting_timed_out() {
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
1081void ConnectWidget::pppdDied() 1083void 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
1087void ConnectWidget::if_waiting_slot() { 1089void 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;
@@ -1107,44 +1109,49 @@ void ConnectWidget::if_waiting_slot() {
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();
@@ -1152,24 +1159,33 @@ void ConnectWidget::if_waiting_slot() {
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
1171void 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
1165bool ConnectWidget::execppp() { 1181bool 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();
@@ -1201,63 +1217,71 @@ bool ConnectWidget::execppp() {
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
1258void ConnectWidget::closeEvent( QCloseEvent *e ) { 1282void ConnectWidget::closeEvent( QCloseEvent *e ) {
1259 e->ignore(); 1283 e->ignore();
1260 emit cancelbutton(); 1284 emit cancelbutton();
1261} 1285}
1262 1286
1263 1287