Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 121 |
1 files changed, 61 insertions, 60 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index eee643d..8ae714e 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -36,26 +36,27 @@ | |||
36 | #define i18n QObject::tr | 36 | #define i18n QObject::tr |
37 | #include <qvgroupbox.h> | 37 | #include <qvgroupbox.h> |
38 | #include <qhbox.h> | 38 | #include <qhbox.h> |
39 | #include <qdialog.h> | 39 | #include <qdialog.h> |
40 | //#include <kwin.h> | 40 | //#include <kwin.h> |
41 | 41 | ||
42 | #include "edit.h" | 42 | #include "edit.h" |
43 | #include "pppdata.h" | 43 | #include "pppdata.h" |
44 | //#include "newwidget.h" | 44 | //#include "newwidget.h" |
45 | #include "iplined.h" | 45 | #include "iplined.h" |
46 | #include "auth.h" | 46 | #include "auth.h" |
47 | 47 | ||
48 | DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) | 48 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
49 | : QWidget(parent, name) | 49 | , const char *name ) |
50 | : QWidget(parent, name), _pppdata(pd) | ||
50 | { | 51 | { |
51 | const int GRIDROWS = 6; | 52 | const int GRIDROWS = 6; |
52 | 53 | ||
53 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | 54 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); |
54 | 55 | ||
55 | connect_label = new QLabel(i18n("Connection name:"), this); | 56 | connect_label = new QLabel(i18n("Connection name:"), this); |
56 | tl->addWidget(connect_label, 0, 0); | 57 | tl->addWidget(connect_label, 0, 0); |
57 | 58 | ||
58 | connectname_l = new QLineEdit(this); | 59 | connectname_l = new QLineEdit(this); |
59 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 60 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
60 | tl->addWidget(connectname_l, 0, 1); | 61 | tl->addWidget(connectname_l, 0, 1); |
61 | QString tmp = i18n("Type in a unique name for this connection"); | 62 | QString tmp = i18n("Type in a unique name for this connection"); |
@@ -145,72 +146,72 @@ DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) | |||
145 | "\n" | 146 | "\n" |
146 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | 147 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" |
147 | "plain text in the config file, which is\n" | 148 | "plain text in the config file, which is\n" |
148 | "readable only to you. Make sure nobody\n" | 149 | "readable only to you. Make sure nobody\n" |
149 | "gains access to this file!")); | 150 | "gains access to this file!")); |
150 | 151 | ||
151 | pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this); | 152 | pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this); |
152 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 153 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
153 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 154 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
154 | 155 | ||
155 | // Set defaults if editing an existing connection | 156 | // Set defaults if editing an existing connection |
156 | if(!isnewaccount) { | 157 | if(!isnewaccount) { |
157 | connectname_l->setText(PPPData::data()->accname()); | 158 | connectname_l->setText(_pppdata->accname()); |
158 | 159 | ||
159 | // insert the phone numbers into the listbox | 160 | // insert the phone numbers into the listbox |
160 | QString n = PPPData::data()->phonenumber(); | 161 | QString n = _pppdata->phonenumber(); |
161 | QString tmp = ""; | 162 | QString tmp = ""; |
162 | uint idx = 0; | 163 | uint idx = 0; |
163 | while(idx != n.length()) { | 164 | while(idx != n.length()) { |
164 | if(n[idx] == ':') { | 165 | if(n[idx] == ':') { |
165 | if(tmp.length() > 0) | 166 | if(tmp.length() > 0) |
166 | numbers->insertItem(tmp); | 167 | numbers->insertItem(tmp); |
167 | tmp = ""; | 168 | tmp = ""; |
168 | } else | 169 | } else |
169 | tmp += n[idx]; | 170 | tmp += n[idx]; |
170 | idx++; | 171 | idx++; |
171 | } | 172 | } |
172 | if(tmp.length() > 0) | 173 | if(tmp.length() > 0) |
173 | numbers->insertItem(tmp); | 174 | numbers->insertItem(tmp); |
174 | 175 | ||
175 | auth->setCurrentItem(PPPData::data()->authMethod()); | 176 | auth->setCurrentItem(_pppdata->authMethod()); |
176 | store_password->setChecked(PPPData::data()->storePassword()); | 177 | store_password->setChecked(_pppdata->storePassword()); |
177 | } else { | 178 | } else { |
178 | // select PAP/CHAP as default | 179 | // select PAP/CHAP as default |
179 | auth->setCurrentItem(AUTH_PAPCHAP); | 180 | auth->setCurrentItem(AUTH_PAPCHAP); |
180 | } | 181 | } |
181 | 182 | ||
182 | numbersChanged(); | 183 | numbersChanged(); |
183 | tl->activate(); | 184 | tl->activate(); |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | bool DialWidget::save() { | 188 | bool DialWidget::save() { |
188 | //first check to make sure that the account name is unique! | 189 | //first check to make sure that the account name is unique! |
189 | if(connectname_l->text().isEmpty() || | 190 | if(connectname_l->text().isEmpty() || |
190 | !PPPData::data()->isUniqueAccname(connectname_l->text())) { | 191 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
191 | return false; | 192 | return false; |
192 | } else { | 193 | } else { |
193 | PPPData::data()->setAccname(connectname_l->text()); | 194 | _pppdata->setAccname(connectname_l->text()); |
194 | 195 | ||
195 | QString number = ""; | 196 | QString number = ""; |
196 | for(uint i = 0; i < numbers->count(); i++) { | 197 | for(uint i = 0; i < numbers->count(); i++) { |
197 | if(i != 0) | 198 | if(i != 0) |
198 | number += ":"; | 199 | number += ":"; |
199 | number += numbers->text(i); | 200 | number += numbers->text(i); |
200 | } | 201 | } |
201 | 202 | ||
202 | PPPData::data()->setPhonenumber(number); | 203 | _pppdata->setPhonenumber(number); |
203 | PPPData::data()->setAuthMethod(auth->currentItem()); | 204 | _pppdata->setAuthMethod(auth->currentItem()); |
204 | PPPData::data()->setStorePassword(store_password->isChecked()); | 205 | _pppdata->setStorePassword(store_password->isChecked()); |
205 | return true; | 206 | return true; |
206 | } | 207 | } |
207 | } | 208 | } |
208 | 209 | ||
209 | 210 | ||
210 | void DialWidget::numbersChanged() { | 211 | void DialWidget::numbersChanged() { |
211 | int sel = numbers->currentItem(); | 212 | int sel = numbers->currentItem(); |
212 | 213 | ||
213 | del->setEnabled(sel != -1); | 214 | del->setEnabled(sel != -1); |
214 | up->setEnabled(sel != -1 && sel != 0); | 215 | up->setEnabled(sel != -1 && sel != 0); |
215 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 216 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
216 | } | 217 | } |
@@ -254,35 +255,35 @@ void DialWidget::downNumber() { | |||
254 | int idx = numbers->currentItem(); | 255 | int idx = numbers->currentItem(); |
255 | if(idx != -1) { | 256 | if(idx != -1) { |
256 | QString item = numbers->text(idx); | 257 | QString item = numbers->text(idx); |
257 | numbers->removeItem(idx); | 258 | numbers->removeItem(idx); |
258 | numbers->insertItem(item, idx+1); | 259 | numbers->insertItem(item, idx+1); |
259 | numbers->setCurrentItem(idx+1); | 260 | numbers->setCurrentItem(idx+1); |
260 | numbersChanged(); | 261 | numbersChanged(); |
261 | } | 262 | } |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void DialWidget::pppdargsbutton() { | 266 | void DialWidget::pppdargsbutton() { |
266 | PPPdArguments pa(this); | 267 | PPPdArguments pa(_pppdata, this); |
267 | pa.exec(); | 268 | pa.exec(); |
268 | } | 269 | } |
269 | 270 | ||
270 | 271 | ||
271 | 272 | ||
272 | ///////////////////////////////////////////////////////////////////////////// | 273 | ///////////////////////////////////////////////////////////////////////////// |
273 | // ExecWidget | 274 | // ExecWidget |
274 | ///////////////////////////////////////////////////////////////////////////// | 275 | ///////////////////////////////////////////////////////////////////////////// |
275 | ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) : | 276 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
276 | QWidget(parent, name) | 277 | QWidget(parent, name), _pppdata(pd) |
277 | { | 278 | { |
278 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 279 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
279 | 280 | ||
280 | QLabel *l = new QLabel(\ | 281 | QLabel *l = new QLabel(\ |
281 | i18n("Here you can select commands to run at certain stages of the\n" | 282 | i18n("Here you can select commands to run at certain stages of the\n" |
282 | "connection. The commands are run with your real user id, so\n" | 283 | "connection. The commands are run with your real user id, so\n" |
283 | "you cannot run any commands here requiring root permissions\n" | 284 | "you cannot run any commands here requiring root permissions\n" |
284 | "(unless, of course, you are root).\n\n" | 285 | "(unless, of course, you are root).\n\n" |
285 | "Be sure to supply the whole path to the program otherwise\n" | 286 | "Be sure to supply the whole path to the program otherwise\n" |
286 | "kppp might be unable to find it."), this); | 287 | "kppp might be unable to find it."), this); |
287 | // l->setMinimumHeight(l->sizeHint().height()); | 288 | // l->setMinimumHeight(l->sizeHint().height()); |
288 | tl->addWidget(l); | 289 | tl->addWidget(l); |
@@ -351,49 +352,49 @@ i18n("Here you can select commands to run at certain stages of the\n" | |||
351 | QWhatsThis::add(discommand_label,tmp); | 352 | QWhatsThis::add(discommand_label,tmp); |
352 | QWhatsThis::add(discommand,tmp); | 353 | QWhatsThis::add(discommand,tmp); |
353 | 354 | ||
354 | // extra space between entries | 355 | // extra space between entries |
355 | l1->addRowSpacing(1, 5); | 356 | l1->addRowSpacing(1, 5); |
356 | l1->addRowSpacing(3, 5); | 357 | l1->addRowSpacing(3, 5); |
357 | 358 | ||
358 | tl->addStretch(1); | 359 | tl->addStretch(1); |
359 | tl->activate(); | 360 | tl->activate(); |
360 | 361 | ||
361 | // Set defaults if editing an existing connection | 362 | // Set defaults if editing an existing connection |
362 | if(!isnewaccount) { | 363 | if(!isnewaccount) { |
363 | before_connect->setText(PPPData::data()->command_before_connect()); | 364 | before_connect->setText(_pppdata->command_before_connect()); |
364 | command->setText(PPPData::data()->command_on_connect()); | 365 | command->setText(_pppdata->command_on_connect()); |
365 | discommand->setText(PPPData::data()->command_on_disconnect()); | 366 | discommand->setText(_pppdata->command_on_disconnect()); |
366 | predisconnect->setText(PPPData::data()->command_before_disconnect()); | 367 | predisconnect->setText(_pppdata->command_before_disconnect()); |
367 | } | 368 | } |
368 | } | 369 | } |
369 | 370 | ||
370 | 371 | ||
371 | bool ExecWidget::save() { | 372 | bool ExecWidget::save() { |
372 | PPPData::data()->setCommand_before_connect(before_connect->text()); | 373 | _pppdata->setCommand_before_connect(before_connect->text()); |
373 | PPPData::data()->setCommand_on_connect(command->text()); | 374 | _pppdata->setCommand_on_connect(command->text()); |
374 | PPPData::data()->setCommand_before_disconnect(predisconnect->text()); | 375 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
375 | PPPData::data()->setCommand_on_disconnect(discommand->text()); | 376 | _pppdata->setCommand_on_disconnect(discommand->text()); |
376 | return true; | 377 | return true; |
377 | } | 378 | } |
378 | 379 | ||
379 | 380 | ||
380 | 381 | ||
381 | ///////////////////////////////////////////////////////////////////////////// | 382 | ///////////////////////////////////////////////////////////////////////////// |
382 | // | 383 | // |
383 | // IPWidget | 384 | // IPWidget |
384 | // | 385 | // |
385 | ///////////////////////////////////////////////////////////////////////////// | 386 | ///////////////////////////////////////////////////////////////////////////// |
386 | IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) | 387 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
387 | : QWidget(parent, name) | 388 | : QWidget(parent, name), _pppdata(pd) |
388 | { | 389 | { |
389 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 390 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
390 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 391 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
391 | 392 | ||
392 | box = new QVGroupBox(i18n("Configuration"), this); | 393 | box = new QVGroupBox(i18n("Configuration"), this); |
393 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 394 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
394 | 395 | ||
395 | rb = new QButtonGroup(this); | 396 | rb = new QButtonGroup(this); |
396 | rb->hide(); | 397 | rb->hide(); |
397 | connect(rb, SIGNAL(clicked(int)), | 398 | connect(rb, SIGNAL(clicked(int)), |
398 | SLOT(hitIPSelect(int))); | 399 | SLOT(hitIPSelect(int))); |
399 | 400 | ||
@@ -440,53 +441,53 @@ IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) | |||
440 | "but your mileage may vary.\n" | 441 | "but your mileage may vary.\n" |
441 | "\n" | 442 | "\n" |
442 | "If unsure, contact your Internet Service Provider"); | 443 | "If unsure, contact your Internet Service Provider"); |
443 | ipLayout->addWidget(sub_label, 1, 0); | 444 | ipLayout->addWidget(sub_label, 1, 0); |
444 | 445 | ||
445 | subnetmask_l = new IPLineEdit(ipWidget); | 446 | subnetmask_l = new IPLineEdit(ipWidget); |
446 | ipLayout->addWidget(subnetmask_l, 1, 1); | 447 | ipLayout->addWidget(subnetmask_l, 1, 1); |
447 | 448 | ||
448 | QWhatsThis::add(sub_label,tmp); | 449 | QWhatsThis::add(sub_label,tmp); |
449 | QWhatsThis::add(subnetmask_l,tmp); | 450 | QWhatsThis::add(subnetmask_l,tmp); |
450 | 451 | ||
451 | autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this); | 452 | autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this); |
452 | autoname->setChecked(PPPData::data()->autoname()); | 453 | autoname->setChecked(_pppdata->autoname()); |
453 | connect(autoname,SIGNAL(toggled(bool)), | 454 | connect(autoname,SIGNAL(toggled(bool)), |
454 | this,SLOT(autoname_t(bool))); | 455 | this,SLOT(autoname_t(bool))); |
455 | 456 | ||
456 | QWhatsThis::add(autoname, | 457 | QWhatsThis::add(autoname, |
457 | i18n("<p>Whenever you connect, this reconfigures\n" | 458 | i18n("<p>Whenever you connect, this reconfigures\n" |
458 | "your hostname to match the IP address you\n" | 459 | "your hostname to match the IP address you\n" |
459 | "got from the PPP server. This may be useful\n" | 460 | "got from the PPP server. This may be useful\n" |
460 | "if you need to use a protocol which depends\n" | 461 | "if you need to use a protocol which depends\n" |
461 | "on this information, but it can also cause several\n" | 462 | "on this information, but it can also cause several\n" |
462 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 463 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
463 | "\n" | 464 | "\n" |
464 | "Don't enable this unless you really need it.")); | 465 | "Don't enable this unless you really need it.")); |
465 | 466 | ||
466 | topLayout->addWidget(box); | 467 | topLayout->addWidget(box); |
467 | topLayout->addWidget(autoname); | 468 | topLayout->addWidget(autoname); |
468 | topLayout->addStretch(); | 469 | topLayout->addStretch(); |
469 | 470 | ||
470 | //load info from gpppdata | 471 | //load info from gpppdata |
471 | if(!isnewaccount) { | 472 | if(!isnewaccount) { |
472 | if(PPPData::data()->ipaddr() == "0.0.0.0" && | 473 | if(_pppdata->ipaddr() == "0.0.0.0" && |
473 | PPPData::data()->subnetmask() == "0.0.0.0") { | 474 | _pppdata->subnetmask() == "0.0.0.0") { |
474 | dynamicadd_rb->setChecked(true); | 475 | dynamicadd_rb->setChecked(true); |
475 | hitIPSelect(0); | 476 | hitIPSelect(0); |
476 | autoname->setChecked(PPPData::data()->autoname()); | 477 | autoname->setChecked(_pppdata->autoname()); |
477 | } | 478 | } |
478 | else { | 479 | else { |
479 | ipaddress_l->setText(PPPData::data()->ipaddr()); | 480 | ipaddress_l->setText(_pppdata->ipaddr()); |
480 | subnetmask_l->setText(PPPData::data()->subnetmask()); | 481 | subnetmask_l->setText(_pppdata->subnetmask()); |
481 | staticadd_rb->setChecked(true); | 482 | staticadd_rb->setChecked(true); |
482 | autoname->setChecked(false); | 483 | autoname->setChecked(false); |
483 | } | 484 | } |
484 | } | 485 | } |
485 | else { | 486 | else { |
486 | dynamicadd_rb->setChecked(true); | 487 | dynamicadd_rb->setChecked(true); |
487 | hitIPSelect(0); | 488 | hitIPSelect(0); |
488 | } | 489 | } |
489 | 490 | ||
490 | } | 491 | } |
491 | 492 | ||
492 | void IPWidget::autoname_t(bool on) { | 493 | void IPWidget::autoname_t(bool on) { |
@@ -501,53 +502,53 @@ void IPWidget::autoname_t(bool on) { | |||
501 | "you know what you are doing!\n" | 502 | "you know what you are doing!\n" |
502 | "For more information take a look at the " | 503 | "For more information take a look at the " |
503 | "handbook (or help) in the section \"Frequently " | 504 | "handbook (or help) in the section \"Frequently " |
504 | "asked questions\"."), | 505 | "asked questions\"."), |
505 | i18n("Warning")); | 506 | i18n("Warning")); |
506 | was_warned = true; | 507 | was_warned = true; |
507 | } | 508 | } |
508 | } | 509 | } |
509 | 510 | ||
510 | 511 | ||
511 | void IPWidget::save() { | 512 | void IPWidget::save() { |
512 | if(dynamicadd_rb->isChecked()) { | 513 | if(dynamicadd_rb->isChecked()) { |
513 | PPPData::data()->setIpaddr("0.0.0.0"); | 514 | _pppdata->setIpaddr("0.0.0.0"); |
514 | PPPData::data()->setSubnetmask("0.0.0.0"); | 515 | _pppdata->setSubnetmask("0.0.0.0"); |
515 | } else { | 516 | } else { |
516 | PPPData::data()->setIpaddr(ipaddress_l->text()); | 517 | _pppdata->setIpaddr(ipaddress_l->text()); |
517 | PPPData::data()->setSubnetmask(subnetmask_l->text()); | 518 | _pppdata->setSubnetmask(subnetmask_l->text()); |
518 | } | 519 | } |
519 | PPPData::data()->setAutoname(autoname->isChecked()); | 520 | _pppdata->setAutoname(autoname->isChecked()); |
520 | } | 521 | } |
521 | 522 | ||
522 | 523 | ||
523 | void IPWidget::hitIPSelect( int i ) { | 524 | void IPWidget::hitIPSelect( int i ) { |
524 | if(i == 0) { | 525 | if(i == 0) { |
525 | ipaddress_label->setEnabled(false); | 526 | ipaddress_label->setEnabled(false); |
526 | sub_label->setEnabled(false); | 527 | sub_label->setEnabled(false); |
527 | ipaddress_l->setEnabled(false); | 528 | ipaddress_l->setEnabled(false); |
528 | subnetmask_l->setEnabled(false); | 529 | subnetmask_l->setEnabled(false); |
529 | } | 530 | } |
530 | else { | 531 | else { |
531 | ipaddress_label->setEnabled(true); | 532 | ipaddress_label->setEnabled(true); |
532 | sub_label->setEnabled(true); | 533 | sub_label->setEnabled(true); |
533 | ipaddress_l->setEnabled(true); | 534 | ipaddress_l->setEnabled(true); |
534 | subnetmask_l->setEnabled(true); | 535 | subnetmask_l->setEnabled(true); |
535 | } | 536 | } |
536 | } | 537 | } |
537 | 538 | ||
538 | 539 | ||
539 | 540 | ||
540 | DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) | 541 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
541 | : QWidget(parent, name) | 542 | : QWidget(parent, name), _pppdata(pd) |
542 | { | 543 | { |
543 | // box = new QGroupBox(this); | 544 | // box = new QGroupBox(this); |
544 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint()); | 545 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint()); |
545 | 546 | ||
546 | dnsdomain_label = new QLabel(i18n("Domain name:"), this); | 547 | dnsdomain_label = new QLabel(i18n("Domain name:"), this); |
547 | tl->addWidget(dnsdomain_label, 0, 0); | 548 | tl->addWidget(dnsdomain_label, 0, 0); |
548 | 549 | ||
549 | dnsdomain = new QLineEdit(this); | 550 | dnsdomain = new QLineEdit(this); |
550 | // dnsdomain->setMaxLength(DOMAIN_SIZE); | 551 | // dnsdomain->setMaxLength(DOMAIN_SIZE); |
551 | tl->addWidget(dnsdomain, 0, 1); | 552 | tl->addWidget(dnsdomain, 0, 1); |
552 | QString tmp = i18n("If you enter a domain name here, this domain\n" | 553 | QString tmp = i18n("If you enter a domain name here, this domain\n" |
553 | "name is used for your computer while you are\n" | 554 | "name is used for your computer while you are\n" |
@@ -563,25 +564,25 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) | |||
563 | 564 | ||
564 | conf_label = new QLabel(i18n("Configuration:"), this); | 565 | conf_label = new QLabel(i18n("Configuration:"), this); |
565 | tl->addWidget(conf_label, 1, 0); | 566 | tl->addWidget(conf_label, 1, 0); |
566 | 567 | ||
567 | bg = new QButtonGroup("Group", this); | 568 | bg = new QButtonGroup("Group", this); |
568 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 569 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
569 | bg->hide(); | 570 | bg->hide(); |
570 | 571 | ||
571 | autodns = new QRadioButton(i18n("Automatic"), this); | 572 | autodns = new QRadioButton(i18n("Automatic"), this); |
572 | bg->insert(autodns, 0); | 573 | bg->insert(autodns, 0); |
573 | tl->addWidget(autodns, 1, 1); | 574 | tl->addWidget(autodns, 1, 1); |
574 | // no automatic DNS detection for pppd < 2.3.7 | 575 | // no automatic DNS detection for pppd < 2.3.7 |
575 | if(!PPPData::data()->pppdVersionMin(2, 3, 7)) | 576 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
576 | autodns->setEnabled(false); | 577 | autodns->setEnabled(false); |
577 | 578 | ||
578 | mandns = new QRadioButton(i18n("Manual"), this); | 579 | mandns = new QRadioButton(i18n("Manual"), this); |
579 | bg->insert(mandns, 1); | 580 | bg->insert(mandns, 1); |
580 | tl->addWidget(mandns, 2, 1); | 581 | tl->addWidget(mandns, 2, 1); |
581 | 582 | ||
582 | dns_label = new QLabel(i18n("DNS IP address:"), this); | 583 | dns_label = new QLabel(i18n("DNS IP address:"), this); |
583 | tl->addWidget(dns_label, 3, 0); | 584 | tl->addWidget(dns_label, 3, 0); |
584 | 585 | ||
585 | QHBoxLayout *l2 = new QHBoxLayout; | 586 | QHBoxLayout *l2 = new QHBoxLayout; |
586 | tl->addLayout(l2, 3, 1); | 587 | tl->addLayout(l2, 3, 1); |
587 | dnsipaddr = new IPLineEdit(this); | 588 | dnsipaddr = new IPLineEdit(this); |
@@ -636,45 +637,45 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) | |||
636 | SLOT(DNS_Entry_Selected(int))); | 637 | SLOT(DNS_Entry_Selected(int))); |
637 | tl->addWidget(dnsservers, 5, 1); | 638 | tl->addWidget(dnsservers, 5, 1); |
638 | tmp = i18n("<p>This shows all defined DNS servers to use\n" | 639 | tmp = i18n("<p>This shows all defined DNS servers to use\n" |
639 | "while you are connected. Use the <b>Add</b> and\n" | 640 | "while you are connected. Use the <b>Add</b> and\n" |
640 | "<b>Remove</b> buttons to modify the list"); | 641 | "<b>Remove</b> buttons to modify the list"); |
641 | 642 | ||
642 | QWhatsThis::add(servers_label,tmp); | 643 | QWhatsThis::add(servers_label,tmp); |
643 | QWhatsThis::add(dnsservers,tmp); | 644 | QWhatsThis::add(dnsservers,tmp); |
644 | 645 | ||
645 | exdnsdisabled_toggle = new QCheckBox(i18n( \ | 646 | exdnsdisabled_toggle = new QCheckBox(i18n( \ |
646 | "Disable existing DNS servers during connection"), | 647 | "Disable existing DNS servers during connection"), |
647 | this); | 648 | this); |
648 | exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled()); | 649 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
649 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 650 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
650 | QWhatsThis::add(exdnsdisabled_toggle, | 651 | QWhatsThis::add(exdnsdisabled_toggle, |
651 | i18n("<p>When this option is selected, all DNS\n" | 652 | i18n("<p>When this option is selected, all DNS\n" |
652 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 653 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
653 | "temporary disabled while the dialup connection\n" | 654 | "temporary disabled while the dialup connection\n" |
654 | "is established. After the connection is\n" | 655 | "is established. After the connection is\n" |
655 | "closed, the servers will be re-enabled\n" | 656 | "closed, the servers will be re-enabled\n" |
656 | "\n" | 657 | "\n" |
657 | "Typically, there is no reason to use this\n" | 658 | "Typically, there is no reason to use this\n" |
658 | "option, but it may become useful under \n" | 659 | "option, but it may become useful under \n" |
659 | "some circumstances.")); | 660 | "some circumstances.")); |
660 | 661 | ||
661 | 662 | ||
662 | // restore data if editing | 663 | // restore data if editing |
663 | if(!isnewaccount) { | 664 | if(!isnewaccount) { |
664 | dnsservers->insertStringList(PPPData::data()->dns()); | 665 | dnsservers->insertStringList(_pppdata->dns()); |
665 | dnsdomain->setText(PPPData::data()->domain()); | 666 | dnsdomain->setText(_pppdata->domain()); |
666 | } | 667 | } |
667 | 668 | ||
668 | int mode = PPPData::data()->autoDNS() ? 0 : 1; | 669 | int mode = _pppdata->autoDNS() ? 0 : 1; |
669 | bg->setButton(mode); | 670 | bg->setButton(mode); |
670 | DNS_Mode_Selected(mode); | 671 | DNS_Mode_Selected(mode); |
671 | 672 | ||
672 | tl->activate(); | 673 | tl->activate(); |
673 | } | 674 | } |
674 | 675 | ||
675 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 676 | void DNSWidget::DNS_Edit_Changed(const QString &text) { |
676 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 677 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
677 | add->setEnabled(text.find(r) != -1); | 678 | add->setEnabled(text.find(r) != -1); |
678 | } | 679 | } |
679 | 680 | ||
680 | void DNSWidget::DNS_Entry_Selected(int) { | 681 | void DNSWidget::DNS_Entry_Selected(int) { |
@@ -686,63 +687,63 @@ void DNSWidget::DNS_Mode_Selected(int mode) { | |||
686 | dns_label->setEnabled(on); | 687 | dns_label->setEnabled(on); |
687 | servers_label->setEnabled(on); | 688 | servers_label->setEnabled(on); |
688 | dnsipaddr->setText(""); | 689 | dnsipaddr->setText(""); |
689 | dnsipaddr->setEnabled(on); | 690 | dnsipaddr->setEnabled(on); |
690 | add->setEnabled(false); | 691 | add->setEnabled(false); |
691 | remove->setEnabled(dnsservers->count()>0 && on); | 692 | remove->setEnabled(dnsservers->count()>0 && on); |
692 | dnsservers->clearSelection(); | 693 | dnsservers->clearSelection(); |
693 | dnsservers->setEnabled(on); | 694 | dnsservers->setEnabled(on); |
694 | dnsservers->triggerUpdate(false); | 695 | dnsservers->triggerUpdate(false); |
695 | } | 696 | } |
696 | 697 | ||
697 | void DNSWidget::save() { | 698 | void DNSWidget::save() { |
698 | PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0); | 699 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
699 | QStringList serverlist; | 700 | QStringList serverlist; |
700 | for(uint i=0; i < dnsservers->count(); i++) | 701 | for(uint i=0; i < dnsservers->count(); i++) |
701 | serverlist.append(dnsservers->text(i)); | 702 | serverlist.append(dnsservers->text(i)); |
702 | PPPData::data()->setDns(serverlist); | 703 | _pppdata->setDns(serverlist); |
703 | 704 | ||
704 | // strip leading dot | 705 | // strip leading dot |
705 | QString s(dnsdomain->text()); | 706 | QString s(dnsdomain->text()); |
706 | if(s.left(1) == ".") | 707 | if(s.left(1) == ".") |
707 | PPPData::data()->setDomain(s.mid(1)); | 708 | _pppdata->setDomain(s.mid(1)); |
708 | else | 709 | else |
709 | PPPData::data()->setDomain(dnsdomain->text()); | 710 | _pppdata->setDomain(dnsdomain->text()); |
710 | 711 | ||
711 | PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 712 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
712 | } | 713 | } |
713 | 714 | ||
714 | 715 | ||
715 | void DNSWidget::adddns() { | 716 | void DNSWidget::adddns() { |
716 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 717 | if(dnsservers->count() < MAX_DNS_ENTRIES) { |
717 | dnsservers->insertItem(dnsipaddr->text()); | 718 | dnsservers->insertItem(dnsipaddr->text()); |
718 | dnsipaddr->setText(""); | 719 | dnsipaddr->setText(""); |
719 | } | 720 | } |
720 | } | 721 | } |
721 | 722 | ||
722 | 723 | ||
723 | void DNSWidget::removedns() { | 724 | void DNSWidget::removedns() { |
724 | int i; | 725 | int i; |
725 | i = dnsservers->currentItem(); | 726 | i = dnsservers->currentItem(); |
726 | if(i != -1) | 727 | if(i != -1) |
727 | dnsservers->removeItem(i); | 728 | dnsservers->removeItem(i); |
728 | remove->setEnabled(dnsservers->count()>0); | 729 | remove->setEnabled(dnsservers->count()>0); |
729 | } | 730 | } |
730 | 731 | ||
731 | 732 | ||
732 | // | 733 | // |
733 | // GatewayWidget | 734 | // GatewayWidget |
734 | // | 735 | // |
735 | GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) | 736 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
736 | : QWidget(parent, name) | 737 | : QWidget(parent, name), _pppdata(pd) |
737 | { | 738 | { |
738 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 739 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
739 | topLayout->setSpacing( 2 );//KDialog::spacingHint()); | 740 | topLayout->setSpacing( 2 );//KDialog::spacingHint()); |
740 | 741 | ||
741 | box = new QVGroupBox(i18n("Configuration"), this); | 742 | box = new QVGroupBox(i18n("Configuration"), this); |
742 | // box->setInsideSpacing( 2 );//KDialog::spacingHint()); | 743 | // box->setInsideSpacing( 2 );//KDialog::spacingHint()); |
743 | 744 | ||
744 | rb = new QButtonGroup(this); | 745 | rb = new QButtonGroup(this); |
745 | rb->hide(); | 746 | rb->hide(); |
746 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 747 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
747 | 748 | ||
748 | defaultgateway = new QRadioButton(box); | 749 | defaultgateway = new QRadioButton(box); |
@@ -776,64 +777,64 @@ GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *na | |||
776 | i18n("If this option is enabled, all packets not\n" | 777 | i18n("If this option is enabled, all packets not\n" |
777 | "going to the local net are routed through\n" | 778 | "going to the local net are routed through\n" |
778 | "the PPP connection.\n" | 779 | "the PPP connection.\n" |
779 | "\n" | 780 | "\n" |
780 | "Normally, you should turn this on")); | 781 | "Normally, you should turn this on")); |
781 | 782 | ||
782 | topLayout->addWidget(box); | 783 | topLayout->addWidget(box); |
783 | topLayout->addWidget(defaultroute); | 784 | topLayout->addWidget(defaultroute); |
784 | topLayout->addStretch(); | 785 | topLayout->addStretch(); |
785 | 786 | ||
786 | //load info from gpppdata | 787 | //load info from gpppdata |
787 | if(!isnewaccount) { | 788 | if(!isnewaccount) { |
788 | if(PPPData::data()->gateway() == "0.0.0.0") { | 789 | if(_pppdata->gateway() == "0.0.0.0") { |
789 | defaultgateway->setChecked(true); | 790 | defaultgateway->setChecked(true); |
790 | hitGatewaySelect(0); | 791 | hitGatewaySelect(0); |
791 | } | 792 | } |
792 | else { | 793 | else { |
793 | gatewayaddr->setText(PPPData::data()->gateway()); | 794 | gatewayaddr->setText(_pppdata->gateway()); |
794 | staticgateway->setChecked(true); | 795 | staticgateway->setChecked(true); |
795 | } | 796 | } |
796 | defaultroute->setChecked(PPPData::data()->defaultroute()); | 797 | defaultroute->setChecked(_pppdata->defaultroute()); |
797 | } | 798 | } |
798 | else { | 799 | else { |
799 | defaultgateway->setChecked(true); | 800 | defaultgateway->setChecked(true); |
800 | hitGatewaySelect(0); | 801 | hitGatewaySelect(0); |
801 | defaultroute->setChecked(true); | 802 | defaultroute->setChecked(true); |
802 | } | 803 | } |
803 | } | 804 | } |
804 | 805 | ||
805 | void GatewayWidget::save() { | 806 | void GatewayWidget::save() { |
806 | PPPData::data()->setGateway(gatewayaddr->text()); | 807 | _pppdata->setGateway(gatewayaddr->text()); |
807 | PPPData::data()->setDefaultroute(defaultroute->isChecked()); | 808 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
808 | } | 809 | } |
809 | 810 | ||
810 | 811 | ||
811 | void GatewayWidget::hitGatewaySelect( int i ) { | 812 | void GatewayWidget::hitGatewaySelect( int i ) { |
812 | if(i == 0) { | 813 | if(i == 0) { |
813 | gatewayaddr->setText("0.0.0.0"); | 814 | gatewayaddr->setText("0.0.0.0"); |
814 | gatewayaddr->setEnabled(false); | 815 | gatewayaddr->setEnabled(false); |
815 | gate_label->setEnabled(false); | 816 | gate_label->setEnabled(false); |
816 | } | 817 | } |
817 | else { | 818 | else { |
818 | gatewayaddr->setEnabled(true); | 819 | gatewayaddr->setEnabled(true); |
819 | gatewayaddr->setText(""); | 820 | gatewayaddr->setText(""); |
820 | gate_label->setEnabled(true); | 821 | gate_label->setEnabled(true); |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | 825 | ||
825 | 826 | ||
826 | ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) | 827 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
827 | : QWidget(parent, name) | 828 | : QWidget(parent, name),_pppdata(pd) |
828 | { | 829 | { |
829 | 830 | ||
830 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 831 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
831 | se = new ScriptEdit(this); | 832 | se = new ScriptEdit(this); |
832 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 833 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
833 | tl->addWidget(se); | 834 | tl->addWidget(se); |
834 | 835 | ||
835 | // insert equal-sized buttons | 836 | // insert equal-sized buttons |
836 | QHBoxLayout *hl = new QHBoxLayout( this ); | 837 | QHBoxLayout *hl = new QHBoxLayout( this ); |
837 | tl->addLayout( hl ); | 838 | tl->addLayout( hl ); |
838 | add = new QPushButton( i18n("Add"), this ); | 839 | add = new QPushButton( i18n("Add"), this ); |
839 | hl->addWidget( add ); | 840 | hl->addWidget( add ); |
@@ -858,26 +859,26 @@ ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name | |||
858 | // sl->setMinimumSize(QSize(150, 140)); | 859 | // sl->setMinimumSize(QSize(150, 140)); |
859 | 860 | ||
860 | slb = new QScrollBar(this); | 861 | slb = new QScrollBar(this); |
861 | // slb->setFixedWidth(slb->sizeHint().width()); | 862 | // slb->setFixedWidth(slb->sizeHint().width()); |
862 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 863 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
863 | 864 | ||
864 | l12->addWidget(stl, 1); | 865 | l12->addWidget(stl, 1); |
865 | l12->addWidget(sl, 3); | 866 | l12->addWidget(sl, 3); |
866 | l12->addWidget(slb, 0); | 867 | l12->addWidget(slb, 0); |
867 | 868 | ||
868 | //load data from gpppdata | 869 | //load data from gpppdata |
869 | if(!isnewaccount) { | 870 | if(!isnewaccount) { |
870 | QStringList &comlist = PPPData::data()->scriptType(); | 871 | QStringList &comlist = _pppdata->scriptType(); |
871 | QStringList &arglist = PPPData::data()->script(); | 872 | QStringList &arglist = _pppdata->script(); |
872 | QStringList::Iterator itcom = comlist.begin(); | 873 | QStringList::Iterator itcom = comlist.begin(); |
873 | QStringList::Iterator itarg = arglist.begin(); | 874 | QStringList::Iterator itarg = arglist.begin(); |
874 | 875 | ||
875 | for ( ; | 876 | for ( ; |
876 | itcom != comlist.end() && itarg != arglist.end(); | 877 | itcom != comlist.end() && itarg != arglist.end(); |
877 | ++itcom, ++itarg ) | 878 | ++itcom, ++itarg ) |
878 | { | 879 | { |
879 | stl->insertItem(*itcom); | 880 | stl->insertItem(*itcom); |
880 | sl->insertItem(*itarg); | 881 | sl->insertItem(*itarg); |
881 | } | 882 | } |
882 | } | 883 | } |
883 | 884 | ||
@@ -905,26 +906,26 @@ bool ScriptWidget::check() { | |||
905 | return ( (errcnt == 0 ) && (lstart == lend) ); | 906 | return ( (errcnt == 0 ) && (lstart == lend) ); |
906 | } | 907 | } |
907 | return true; | 908 | return true; |
908 | } | 909 | } |
909 | 910 | ||
910 | 911 | ||
911 | void ScriptWidget::save() { | 912 | void ScriptWidget::save() { |
912 | QStringList typelist, arglist; | 913 | QStringList typelist, arglist; |
913 | for(uint i=0; i < sl->count(); i++) { | 914 | for(uint i=0; i < sl->count(); i++) { |
914 | typelist.append(stl->text(i)); | 915 | typelist.append(stl->text(i)); |
915 | arglist.append(sl->text(i)); | 916 | arglist.append(sl->text(i)); |
916 | } | 917 | } |
917 | PPPData::data()->setScriptType(typelist); | 918 | _pppdata->setScriptType(typelist); |
918 | PPPData::data()->setScript(arglist); | 919 | _pppdata->setScript(arglist); |
919 | } | 920 | } |
920 | 921 | ||
921 | 922 | ||
922 | 923 | ||
923 | void ScriptWidget::adjustScrollBar() { | 924 | void ScriptWidget::adjustScrollBar() { |
924 | if((int)sl->count() <= sl->numItemsVisible()) | 925 | if((int)sl->count() <= sl->numItemsVisible()) |
925 | slb->setRange(0, 0); | 926 | slb->setRange(0, 0); |
926 | else | 927 | else |
927 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 928 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
928 | } | 929 | } |
929 | 930 | ||
930 | 931 | ||