Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 233 |
1 files changed, 155 insertions, 78 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index ceac90c..7d21605 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -14,41 +14,48 @@ | |||
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <string.h> | 26 | #include "edit.h" |
27 | #include <termios.h> | 27 | #include "pppdata.h" |
28 | #include "iplined.h" | ||
29 | #include "auth.h" | ||
30 | |||
31 | /* OPIE */ | ||
32 | #include <qpe/resource.h> | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | |||
35 | /* QT */ | ||
28 | #include <qlayout.h> | 36 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 39 | #include <qregexp.h> |
32 | #include <qapplication.h> | 40 | #include <qapplication.h> |
33 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 42 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 43 | #include <qhbox.h> |
36 | #include <qdialog.h> | 44 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | ||
38 | 45 | ||
39 | #include "edit.h" | 46 | /* STD */ |
40 | #include "pppdata.h" | 47 | |
41 | #include "iplined.h" | 48 | #include <string.h> |
42 | #include "auth.h" | 49 | #include <termios.h> |
43 | 50 | ||
44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 51 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
45 | , const char *name ) | 52 | , const char *name ) |
46 | : QWidget(parent, name), _pppdata(pd) | 53 | : QWidget(parent, name), _pppdata(pd) |
47 | { | 54 | { |
48 | const int GRIDROWS = 6; | 55 | const int GRIDROWS = 6; |
49 | 56 | ||
50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); | 57 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
51 | 58 | ||
52 | connect_label = new QLabel(tr("Connection name:"), this); | 59 | connect_label = new QLabel(tr("Connection name:"), this); |
53 | tl->addWidget(connect_label, 0, 0); | 60 | tl->addWidget(connect_label, 0, 0); |
54 | 61 | ||
@@ -103,129 +110,148 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
103 | "arrow buttons.\n\n" | 110 | "arrow buttons.\n\n" |
104 | "When a number is busy or fails, <i>kppp</i> will \n" | 111 | "When a number is busy or fails, <i>kppp</i> will \n" |
105 | "try the next number and so on"); | 112 | "try the next number and so on"); |
106 | 113 | ||
107 | QWhatsThis::add(number_label,tmp); | 114 | QWhatsThis::add(number_label,tmp); |
108 | QWhatsThis::add(numbers,tmp); | 115 | QWhatsThis::add(numbers,tmp); |
109 | 116 | ||
110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 117 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 118 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 119 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
113 | 120 | ||
114 | // Set defaults if editing an existing connection | 121 | // Set defaults if editing an existing connection |
115 | if(!isnewaccount) { | 122 | if(!isnewaccount) |
123 | { | ||
116 | connectname_l->setText(_pppdata->accname()); | 124 | connectname_l->setText(_pppdata->accname()); |
117 | 125 | ||
118 | // insert the phone numbers into the listbox | 126 | // insert the phone numbers into the listbox |
119 | QString n = _pppdata->phonenumber(); | 127 | QString n = _pppdata->phonenumber(); |
120 | QString tmp = ""; | 128 | QString tmp = ""; |
121 | uint idx = 0; | 129 | uint idx = 0; |
122 | while(idx != n.length()) { | 130 | while(idx != n.length()) |
123 | if(n[idx] == ':') { | 131 | { |
132 | if(n[idx] == ':') | ||
133 | { | ||
124 | if(tmp.length() > 0) | 134 | if(tmp.length() > 0) |
125 | numbers->insertItem(tmp); | 135 | numbers->insertItem(tmp); |
126 | tmp = ""; | 136 | tmp = ""; |
127 | } else | 137 | } |
138 | else | ||
128 | tmp += n[idx]; | 139 | tmp += n[idx]; |
129 | idx++; | 140 | idx++; |
130 | } | 141 | } |
131 | if(tmp.length() > 0) | 142 | if(tmp.length() > 0) |
132 | numbers->insertItem(tmp); | 143 | numbers->insertItem(tmp); |
133 | 144 | ||
134 | } | 145 | } |
135 | 146 | ||
136 | numbersChanged(); | 147 | numbersChanged(); |
137 | tl->activate(); | 148 | tl->activate(); |
138 | } | 149 | } |
139 | 150 | ||
140 | bool DialWidget::save() { | 151 | bool DialWidget::save() |
152 | { | ||
141 | //first check to make sure that the account name is unique! | 153 | //first check to make sure that the account name is unique! |
142 | if(connectname_l->text().isEmpty() || | 154 | if(connectname_l->text().isEmpty() || |
143 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 155 | !_pppdata->isUniqueAccname(connectname_l->text())) |
156 | { | ||
144 | return false; | 157 | return false; |
145 | } else { | 158 | } |
159 | else | ||
160 | { | ||
146 | _pppdata->setAccname(connectname_l->text()); | 161 | _pppdata->setAccname(connectname_l->text()); |
147 | 162 | ||
148 | QString number = ""; | 163 | QString number = ""; |
149 | for(uint i = 0; i < numbers->count(); i++) { | 164 | for(uint i = 0; i < numbers->count(); i++) |
165 | { | ||
150 | if(i != 0) | 166 | if(i != 0) |
151 | number += ":"; | 167 | number += ":"; |
152 | number += numbers->text(i); | 168 | number += numbers->text(i); |
153 | } | 169 | } |
154 | 170 | ||
155 | _pppdata->setPhonenumber(number); | 171 | _pppdata->setPhonenumber(number); |
156 | return true; | 172 | return true; |
157 | } | 173 | } |
158 | } | 174 | } |
159 | 175 | ||
160 | 176 | ||
161 | void DialWidget::numbersChanged() { | 177 | void DialWidget::numbersChanged() |
178 | { | ||
162 | int sel = numbers->currentItem(); | 179 | int sel = numbers->currentItem(); |
163 | 180 | ||
164 | del->setEnabled(sel != -1); | 181 | del->setEnabled(sel != -1); |
165 | up->setEnabled(sel != -1 && sel != 0); | 182 | up->setEnabled(sel != -1 && sel != 0); |
166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 183 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
167 | } | 184 | } |
168 | 185 | ||
169 | 186 | ||
170 | void DialWidget::selectionChanged(int) { | 187 | void DialWidget::selectionChanged(int) |
188 | { | ||
171 | numbersChanged(); | 189 | numbersChanged(); |
172 | } | 190 | } |
173 | 191 | ||
174 | 192 | ||
175 | void DialWidget::addNumber() { | 193 | void DialWidget::addNumber() |
194 | { | ||
176 | PhoneNumberDialog dlg(this); | 195 | PhoneNumberDialog dlg(this); |
177 | if(dlg.exec()) { | 196 | if(dlg.exec()) |
197 | { | ||
178 | numbers->insertItem(dlg.phoneNumber()); | 198 | numbers->insertItem(dlg.phoneNumber()); |
179 | numbersChanged(); | 199 | numbersChanged(); |
180 | } | 200 | } |
181 | } | 201 | } |
182 | 202 | ||
183 | 203 | ||
184 | void DialWidget::delNumber() { | 204 | void DialWidget::delNumber() |
185 | if(numbers->currentItem() != -1) { | 205 | { |
206 | if(numbers->currentItem() != -1) | ||
207 | { | ||
186 | numbers->removeItem(numbers->currentItem()); | 208 | numbers->removeItem(numbers->currentItem()); |
187 | numbersChanged(); | 209 | numbersChanged(); |
188 | } | 210 | } |
189 | } | 211 | } |
190 | 212 | ||
191 | 213 | ||
192 | void DialWidget::upNumber() { | 214 | void DialWidget::upNumber() |
215 | { | ||
193 | int idx = numbers->currentItem(); | 216 | int idx = numbers->currentItem(); |
194 | if(idx != -1) { | 217 | if(idx != -1) |
218 | { | ||
195 | QString item = numbers->text(idx); | 219 | QString item = numbers->text(idx); |
196 | numbers->removeItem(idx); | 220 | numbers->removeItem(idx); |
197 | numbers->insertItem(item, idx-1); | 221 | numbers->insertItem(item, idx-1); |
198 | numbers->setCurrentItem(idx-1); | 222 | numbers->setCurrentItem(idx-1); |
199 | numbersChanged(); | 223 | numbersChanged(); |
200 | } | 224 | } |
201 | } | 225 | } |
202 | 226 | ||
203 | 227 | ||
204 | void DialWidget::downNumber() { | 228 | void DialWidget::downNumber() |
229 | { | ||
205 | int idx = numbers->currentItem(); | 230 | int idx = numbers->currentItem(); |
206 | if(idx != -1) { | 231 | if(idx != -1) |
232 | { | ||
207 | QString item = numbers->text(idx); | 233 | QString item = numbers->text(idx); |
208 | numbers->removeItem(idx); | 234 | numbers->removeItem(idx); |
209 | numbers->insertItem(item, idx+1); | 235 | numbers->insertItem(item, idx+1); |
210 | numbers->setCurrentItem(idx+1); | 236 | numbers->setCurrentItem(idx+1); |
211 | numbersChanged(); | 237 | numbersChanged(); |
212 | } | 238 | } |
213 | } | 239 | } |
214 | 240 | ||
215 | 241 | ||
216 | void DialWidget::pppdargsbutton() { | 242 | void DialWidget::pppdargsbutton() |
243 | { | ||
217 | PPPdArguments pa(_pppdata, this); | 244 | PPPdArguments pa(_pppdata, this); |
218 | pa.showMaximized(); | 245 | QPEApplication::execDialog( &pa ); |
219 | pa.exec(); | ||
220 | } | 246 | } |
221 | 247 | ||
222 | 248 | ||
223 | 249 | ||
224 | ///////////////////////////////////////////////////////////////////////////// | 250 | ///////////////////////////////////////////////////////////////////////////// |
225 | // ExecWidget | 251 | // ExecWidget |
226 | ///////////////////////////////////////////////////////////////////////////// | 252 | ///////////////////////////////////////////////////////////////////////////// |
227 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 253 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
228 | QWidget(parent, name), _pppdata(pd) | 254 | QWidget(parent, name), _pppdata(pd) |
229 | { | 255 | { |
230 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 256 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
231 | 257 | ||
@@ -296,34 +322,36 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch | |||
296 | 322 | ||
297 | QWhatsThis::add(discommand_label,tmp); | 323 | QWhatsThis::add(discommand_label,tmp); |
298 | QWhatsThis::add(discommand,tmp); | 324 | QWhatsThis::add(discommand,tmp); |
299 | 325 | ||
300 | // extra space between entries | 326 | // extra space between entries |
301 | l1->addRowSpacing(1, 5); | 327 | l1->addRowSpacing(1, 5); |
302 | l1->addRowSpacing(3, 5); | 328 | l1->addRowSpacing(3, 5); |
303 | 329 | ||
304 | tl->addStretch(1); | 330 | tl->addStretch(1); |
305 | tl->activate(); | 331 | tl->activate(); |
306 | 332 | ||
307 | // Set defaults if editing an existing connection | 333 | // Set defaults if editing an existing connection |
308 | if(!isnewaccount) { | 334 | if(!isnewaccount) |
335 | { | ||
309 | before_connect->setText(_pppdata->command_before_connect()); | 336 | before_connect->setText(_pppdata->command_before_connect()); |
310 | command->setText(_pppdata->command_on_connect()); | 337 | command->setText(_pppdata->command_on_connect()); |
311 | discommand->setText(_pppdata->command_on_disconnect()); | 338 | discommand->setText(_pppdata->command_on_disconnect()); |
312 | predisconnect->setText(_pppdata->command_before_disconnect()); | 339 | predisconnect->setText(_pppdata->command_before_disconnect()); |
313 | } | 340 | } |
314 | } | 341 | } |
315 | 342 | ||
316 | 343 | ||
317 | bool ExecWidget::save() { | 344 | bool ExecWidget::save() |
345 | { | ||
318 | _pppdata->setCommand_before_connect(before_connect->text()); | 346 | _pppdata->setCommand_before_connect(before_connect->text()); |
319 | _pppdata->setCommand_on_connect(command->text()); | 347 | _pppdata->setCommand_on_connect(command->text()); |
320 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 348 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
321 | _pppdata->setCommand_on_disconnect(discommand->text()); | 349 | _pppdata->setCommand_on_disconnect(discommand->text()); |
322 | return true; | 350 | return true; |
323 | } | 351 | } |
324 | 352 | ||
325 | 353 | ||
326 | 354 | ||
327 | ///////////////////////////////////////////////////////////////////////////// | 355 | ///////////////////////////////////////////////////////////////////////////// |
328 | // | 356 | // |
329 | // IPWidget | 357 | // IPWidget |
@@ -405,84 +433,97 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char | |||
405 | "got from the PPP server. This may be useful\n" | 433 | "got from the PPP server. This may be useful\n" |
406 | "if you need to use a protocol which depends\n" | 434 | "if you need to use a protocol which depends\n" |
407 | "on this information, but it can also cause several\n" | 435 | "on this information, but it can also cause several\n" |
408 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 436 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
409 | "\n" | 437 | "\n" |
410 | "Don't enable this unless you really need it.")); | 438 | "Don't enable this unless you really need it.")); |
411 | 439 | ||
412 | topLayout->addWidget(box); | 440 | topLayout->addWidget(box); |
413 | topLayout->addWidget(autoname); | 441 | topLayout->addWidget(autoname); |
414 | topLayout->addStretch(); | 442 | topLayout->addStretch(); |
415 | 443 | ||
416 | //load info from gpppdata | 444 | //load info from gpppdata |
417 | if(!isnewaccount) { | 445 | if(!isnewaccount) |
446 | { | ||
418 | if(_pppdata->ipaddr() == "0.0.0.0" && | 447 | if(_pppdata->ipaddr() == "0.0.0.0" && |
419 | _pppdata->subnetmask() == "0.0.0.0") { | 448 | _pppdata->subnetmask() == "0.0.0.0") |
449 | { | ||
420 | dynamicadd_rb->setChecked(true); | 450 | dynamicadd_rb->setChecked(true); |
421 | hitIPSelect(0); | 451 | hitIPSelect(0); |
422 | autoname->setChecked(_pppdata->autoname()); | 452 | autoname->setChecked(_pppdata->autoname()); |
423 | } | 453 | } |
424 | else { | 454 | else |
455 | { | ||
425 | ipaddress_l->setText(_pppdata->ipaddr()); | 456 | ipaddress_l->setText(_pppdata->ipaddr()); |
426 | subnetmask_l->setText(_pppdata->subnetmask()); | 457 | subnetmask_l->setText(_pppdata->subnetmask()); |
427 | staticadd_rb->setChecked(true); | 458 | staticadd_rb->setChecked(true); |
428 | autoname->setChecked(false); | 459 | autoname->setChecked(false); |
429 | } | 460 | } |
430 | } | 461 | } |
431 | else { | 462 | else |
463 | { | ||
432 | dynamicadd_rb->setChecked(true); | 464 | dynamicadd_rb->setChecked(true); |
433 | hitIPSelect(0); | 465 | hitIPSelect(0); |
434 | } | 466 | } |
435 | 467 | ||
436 | } | 468 | } |
437 | 469 | ||
438 | void IPWidget::autoname_t(bool on) { | 470 | void IPWidget::autoname_t(bool on) |
471 | { | ||
439 | static bool was_warned = false; | 472 | static bool was_warned = false; |
440 | 473 | ||
441 | // big-fat warning when selecting the auto configure hostname option | 474 | // big-fat warning when selecting the auto configure hostname option |
442 | if(on && !was_warned) { | 475 | if(on && !was_warned) |
476 | { | ||
443 | QMessageBox::information(this, | 477 | QMessageBox::information(this, |
444 | tr("Selecting this option might cause some weird " | 478 | tr("Selecting this option might cause some weird " |
445 | "problems with the X-server and applications " | 479 | "problems with the X-server and applications " |
446 | "while kppp is connected. Don't use it until " | 480 | "while kppp is connected. Don't use it until " |
447 | "you know what you are doing!\n" | 481 | "you know what you are doing!\n" |
448 | "For more information take a look at the " | 482 | "For more information take a look at the " |
449 | "handbook (or help) in the section \"Frequently " | 483 | "handbook (or help) in the section \"Frequently " |
450 | "asked questions\"."), | 484 | "asked questions\"."), |
451 | tr("Warning")); | 485 | tr("Warning")); |
452 | was_warned = true; | 486 | was_warned = true; |
453 | } | 487 | } |
454 | } | 488 | } |
455 | 489 | ||
456 | 490 | ||
457 | void IPWidget::save() { | 491 | void IPWidget::save() |
458 | if(dynamicadd_rb->isChecked()) { | 492 | { |
493 | if(dynamicadd_rb->isChecked()) | ||
494 | { | ||
459 | _pppdata->setIpaddr("0.0.0.0"); | 495 | _pppdata->setIpaddr("0.0.0.0"); |
460 | _pppdata->setSubnetmask("0.0.0.0"); | 496 | _pppdata->setSubnetmask("0.0.0.0"); |
461 | } else { | 497 | } |
498 | else | ||
499 | { | ||
462 | _pppdata->setIpaddr(ipaddress_l->text()); | 500 | _pppdata->setIpaddr(ipaddress_l->text()); |
463 | _pppdata->setSubnetmask(subnetmask_l->text()); | 501 | _pppdata->setSubnetmask(subnetmask_l->text()); |
464 | } | 502 | } |
465 | _pppdata->setAutoname(autoname->isChecked()); | 503 | _pppdata->setAutoname(autoname->isChecked()); |
466 | } | 504 | } |
467 | 505 | ||
468 | 506 | ||
469 | void IPWidget::hitIPSelect( int i ) { | 507 | void IPWidget::hitIPSelect( int i ) |
470 | if(i == 0) { | 508 | { |
509 | if(i == 0) | ||
510 | { | ||
471 | ipaddress_label->setEnabled(false); | 511 | ipaddress_label->setEnabled(false); |
472 | sub_label->setEnabled(false); | 512 | sub_label->setEnabled(false); |
473 | ipaddress_l->setEnabled(false); | 513 | ipaddress_l->setEnabled(false); |
474 | subnetmask_l->setEnabled(false); | 514 | subnetmask_l->setEnabled(false); |
475 | } | 515 | } |
476 | else { | 516 | else |
517 | { | ||
477 | ipaddress_label->setEnabled(true); | 518 | ipaddress_label->setEnabled(true); |
478 | sub_label->setEnabled(true); | 519 | sub_label->setEnabled(true); |
479 | ipaddress_l->setEnabled(true); | 520 | ipaddress_l->setEnabled(true); |
480 | subnetmask_l->setEnabled(true); | 521 | subnetmask_l->setEnabled(true); |
481 | } | 522 | } |
482 | } | 523 | } |
483 | 524 | ||
484 | 525 | ||
485 | 526 | ||
486 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
487 | : QWidget(parent, name), _pppdata(pd) | 528 | : QWidget(parent, name), _pppdata(pd) |
488 | { | 529 | { |
@@ -588,85 +629,93 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha | |||
588 | tr("<p>When this option is selected, all DNS\n" | 629 | tr("<p>When this option is selected, all DNS\n" |
589 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
590 | "temporary disabled while the dialup connection\n" | 631 | "temporary disabled while the dialup connection\n" |
591 | "is established. After the connection is\n" | 632 | "is established. After the connection is\n" |
592 | "closed, the servers will be re-enabled\n" | 633 | "closed, the servers will be re-enabled\n" |
593 | "\n" | 634 | "\n" |
594 | "Typically, there is no reason to use this\n" | 635 | "Typically, there is no reason to use this\n" |
595 | "option, but it may become useful under \n" | 636 | "option, but it may become useful under \n" |
596 | "some circumstances.")); | 637 | "some circumstances.")); |
597 | 638 | ||
598 | 639 | ||
599 | // restore data if editing | 640 | // restore data if editing |
600 | if(!isnewaccount) { | 641 | if(!isnewaccount) |
642 | { | ||
601 | dnsservers->insertStringList(_pppdata->dns()); | 643 | dnsservers->insertStringList(_pppdata->dns()); |
602 | dnsdomain->setText(_pppdata->domain()); | 644 | dnsdomain->setText(_pppdata->domain()); |
603 | } | 645 | } |
604 | 646 | ||
605 | int mode = _pppdata->autoDNS() ? 0 : 1; | 647 | int mode = _pppdata->autoDNS() ? 0 : 1; |
606 | bg->setButton(mode); | 648 | bg->setButton(mode); |
607 | DNS_Mode_Selected(mode); | 649 | DNS_Mode_Selected(mode); |
608 | 650 | ||
609 | tl->activate(); | 651 | tl->activate(); |
610 | } | 652 | } |
611 | 653 | ||
612 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 654 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
655 | { | ||
613 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
614 | add->setEnabled(text.find(r) != -1); | 657 | add->setEnabled(text.find(r) != -1); |
615 | } | 658 | } |
616 | 659 | ||
617 | void DNSWidget::DNS_Entry_Selected(int) { | 660 | void DNSWidget::DNS_Entry_Selected(int) |
661 | { | ||
618 | remove->setEnabled(true); | 662 | remove->setEnabled(true); |
619 | } | 663 | } |
620 | 664 | ||
621 | void DNSWidget::DNS_Mode_Selected(int mode) { | 665 | void DNSWidget::DNS_Mode_Selected(int mode) |
666 | { | ||
622 | bool on = (mode == 1); | 667 | bool on = (mode == 1); |
623 | dns_label->setEnabled(on); | 668 | dns_label->setEnabled(on); |
624 | servers_label->setEnabled(on); | 669 | servers_label->setEnabled(on); |
625 | dnsipaddr->setText(""); | 670 | dnsipaddr->setText(""); |
626 | dnsipaddr->setEnabled(on); | 671 | dnsipaddr->setEnabled(on); |
627 | add->setEnabled(false); | 672 | add->setEnabled(false); |
628 | remove->setEnabled(dnsservers->count()>0 && on); | 673 | remove->setEnabled(dnsservers->count()>0 && on); |
629 | dnsservers->clearSelection(); | 674 | dnsservers->clearSelection(); |
630 | dnsservers->setEnabled(on); | 675 | dnsservers->setEnabled(on); |
631 | dnsservers->triggerUpdate(false); | 676 | dnsservers->triggerUpdate(false); |
632 | } | 677 | } |
633 | 678 | ||
634 | void DNSWidget::save() { | 679 | void DNSWidget::save() |
680 | { | ||
635 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
636 | QStringList serverlist; | 682 | QStringList serverlist; |
637 | for(uint i=0; i < dnsservers->count(); i++) | 683 | for(uint i=0; i < dnsservers->count(); i++) |
638 | serverlist.append(dnsservers->text(i)); | 684 | serverlist.append(dnsservers->text(i)); |
639 | _pppdata->setDns(serverlist); | 685 | _pppdata->setDns(serverlist); |
640 | 686 | ||
641 | // strip leading dot | 687 | // strip leading dot |
642 | QString s(dnsdomain->text()); | 688 | QString s(dnsdomain->text()); |
643 | if(s.left(1) == ".") | 689 | if(s.left(1) == ".") |
644 | _pppdata->setDomain(s.mid(1)); | 690 | _pppdata->setDomain(s.mid(1)); |
645 | else | 691 | else |
646 | _pppdata->setDomain(dnsdomain->text()); | 692 | _pppdata->setDomain(dnsdomain->text()); |
647 | 693 | ||
648 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 694 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
649 | } | 695 | } |
650 | 696 | ||
651 | 697 | ||
652 | void DNSWidget::adddns() { | 698 | void DNSWidget::adddns() |
653 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 699 | { |
700 | if(dnsservers->count() < MAX_DNS_ENTRIES) | ||
701 | { | ||
654 | dnsservers->insertItem(dnsipaddr->text()); | 702 | dnsservers->insertItem(dnsipaddr->text()); |
655 | dnsipaddr->setText(""); | 703 | dnsipaddr->setText(""); |
656 | } | 704 | } |
657 | } | 705 | } |
658 | 706 | ||
659 | 707 | ||
660 | void DNSWidget::removedns() { | 708 | void DNSWidget::removedns() |
709 | { | ||
661 | int i; | 710 | int i; |
662 | i = dnsservers->currentItem(); | 711 | i = dnsservers->currentItem(); |
663 | if(i != -1) | 712 | if(i != -1) |
664 | dnsservers->removeItem(i); | 713 | dnsservers->removeItem(i); |
665 | remove->setEnabled(dnsservers->count()>0); | 714 | remove->setEnabled(dnsservers->count()>0); |
666 | } | 715 | } |
667 | 716 | ||
668 | 717 | ||
669 | // | 718 | // |
670 | // GatewayWidget | 719 | // GatewayWidget |
671 | // | 720 | // |
672 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 721 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
@@ -712,55 +761,63 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c | |||
712 | QWhatsThis::add(defaultroute, | 761 | QWhatsThis::add(defaultroute, |
713 | tr("If this option is enabled, all packets not\n" | 762 | tr("If this option is enabled, all packets not\n" |
714 | "going to the local net are routed through\n" | 763 | "going to the local net are routed through\n" |
715 | "the PPP connection.\n" | 764 | "the PPP connection.\n" |
716 | "\n" | 765 | "\n" |
717 | "Normally, you should turn this on")); | 766 | "Normally, you should turn this on")); |
718 | 767 | ||
719 | topLayout->addWidget(box); | 768 | topLayout->addWidget(box); |
720 | topLayout->addWidget(defaultroute); | 769 | topLayout->addWidget(defaultroute); |
721 | topLayout->addStretch(); | 770 | topLayout->addStretch(); |
722 | 771 | ||
723 | //load info from gpppdata | 772 | //load info from gpppdata |
724 | if(!isnewaccount) { | 773 | if(!isnewaccount) |
725 | if(_pppdata->gateway() == "0.0.0.0") { | 774 | { |
775 | if(_pppdata->gateway() == "0.0.0.0") | ||
776 | { | ||
726 | defaultgateway->setChecked(true); | 777 | defaultgateway->setChecked(true); |
727 | hitGatewaySelect(0); | 778 | hitGatewaySelect(0); |
728 | } | 779 | } |
729 | else { | 780 | else |
781 | { | ||
730 | gatewayaddr->setText(_pppdata->gateway()); | 782 | gatewayaddr->setText(_pppdata->gateway()); |
731 | staticgateway->setChecked(true); | 783 | staticgateway->setChecked(true); |
732 | } | 784 | } |
733 | defaultroute->setChecked(_pppdata->defaultroute()); | 785 | defaultroute->setChecked(_pppdata->defaultroute()); |
734 | } | 786 | } |
735 | else { | 787 | else |
788 | { | ||
736 | defaultgateway->setChecked(true); | 789 | defaultgateway->setChecked(true); |
737 | hitGatewaySelect(0); | 790 | hitGatewaySelect(0); |
738 | defaultroute->setChecked(true); | 791 | defaultroute->setChecked(true); |
739 | } | 792 | } |
740 | } | 793 | } |
741 | 794 | ||
742 | void GatewayWidget::save() { | 795 | void GatewayWidget::save() |
796 | { | ||
743 | _pppdata->setGateway(gatewayaddr->text()); | 797 | _pppdata->setGateway(gatewayaddr->text()); |
744 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 798 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
745 | } | 799 | } |
746 | 800 | ||
747 | 801 | ||
748 | void GatewayWidget::hitGatewaySelect( int i ) { | 802 | void GatewayWidget::hitGatewaySelect( int i ) |
749 | if(i == 0) { | 803 | { |
804 | if(i == 0) | ||
805 | { | ||
750 | gatewayaddr->setText("0.0.0.0"); | 806 | gatewayaddr->setText("0.0.0.0"); |
751 | gatewayaddr->setEnabled(false); | 807 | gatewayaddr->setEnabled(false); |
752 | gate_label->setEnabled(false); | 808 | gate_label->setEnabled(false); |
753 | } | 809 | } |
754 | else { | 810 | else |
811 | { | ||
755 | gatewayaddr->setEnabled(true); | 812 | gatewayaddr->setEnabled(true); |
756 | gatewayaddr->setText(""); | 813 | gatewayaddr->setText(""); |
757 | gate_label->setEnabled(true); | 814 | gate_label->setEnabled(true); |
758 | } | 815 | } |
759 | } | 816 | } |
760 | 817 | ||
761 | 818 | ||
762 | 819 | ||
763 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 820 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
764 | : QWidget(parent, name),_pppdata(pd) | 821 | : QWidget(parent, name),_pppdata(pd) |
765 | { | 822 | { |
766 | 823 | ||
@@ -794,112 +851,126 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con | |||
794 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 851 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
795 | // sl->setMinimumSize(QSize(150, 140)); | 852 | // sl->setMinimumSize(QSize(150, 140)); |
796 | 853 | ||
797 | slb = new QScrollBar(this); | 854 | slb = new QScrollBar(this); |
798 | // slb->setFixedWidth(slb->sizeHint().width()); | 855 | // slb->setFixedWidth(slb->sizeHint().width()); |
799 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 856 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
800 | 857 | ||
801 | l12->addWidget(stl, 1); | 858 | l12->addWidget(stl, 1); |
802 | l12->addWidget(sl, 3); | 859 | l12->addWidget(sl, 3); |
803 | l12->addWidget(slb, 0); | 860 | l12->addWidget(slb, 0); |
804 | 861 | ||
805 | //load data from gpppdata | 862 | //load data from gpppdata |
806 | if(!isnewaccount) { | 863 | if(!isnewaccount) |
864 | { | ||
807 | QStringList &comlist = _pppdata->scriptType(); | 865 | QStringList &comlist = _pppdata->scriptType(); |
808 | QStringList &arglist = _pppdata->script(); | 866 | QStringList &arglist = _pppdata->script(); |
809 | QStringList::Iterator itcom = comlist.begin(); | 867 | QStringList::Iterator itcom = comlist.begin(); |
810 | QStringList::Iterator itarg = arglist.begin(); | 868 | QStringList::Iterator itarg = arglist.begin(); |
811 | 869 | ||
812 | for ( ; | 870 | for ( ; |
813 | itcom != comlist.end() && itarg != arglist.end(); | 871 | itcom != comlist.end() && itarg != arglist.end(); |
814 | ++itcom, ++itarg ) | 872 | ++itcom, ++itarg ) |
815 | { | 873 | { |
816 | stl->insertItem(*itcom); | 874 | stl->insertItem(*itcom); |
817 | sl->insertItem(*itarg); | 875 | sl->insertItem(*itarg); |
818 | } | 876 | } |
819 | } | 877 | } |
820 | 878 | ||
821 | insert->setEnabled(false); | 879 | insert->setEnabled(false); |
822 | remove->setEnabled(false); | 880 | remove->setEnabled(false); |
823 | adjustScrollBar(); | 881 | adjustScrollBar(); |
824 | tl->activate(); | 882 | tl->activate(); |
825 | } | 883 | } |
826 | 884 | ||
827 | bool ScriptWidget::check() { | 885 | bool ScriptWidget::check() |
886 | { | ||
828 | uint lstart = 0; | 887 | uint lstart = 0; |
829 | uint lend = 0; | 888 | uint lend = 0; |
830 | uint errcnt = 0; | 889 | uint errcnt = 0; |
831 | 890 | ||
832 | if(sl->count() > 0) { | 891 | if(sl->count() > 0) |
833 | for( uint i=0; i <= sl->count()-1; i++) { | 892 | { |
834 | if(stl->text(i) == "LoopStart") { | 893 | for( uint i=0; i <= sl->count()-1; i++) |
894 | { | ||
895 | if(stl->text(i) == "LoopStart") | ||
896 | { | ||
835 | lstart++; | 897 | lstart++; |
836 | } | 898 | } |
837 | if (stl->text(i) == "LoopEnd") { | 899 | if (stl->text(i) == "LoopEnd") |
900 | { | ||
838 | lend++; | 901 | lend++; |
839 | } | 902 | } |
840 | if ( lend > lstart ) errcnt++; | 903 | if ( lend > lstart ) errcnt++; |
841 | } | 904 | } |
842 | return ( (errcnt == 0 ) && (lstart == lend) ); | 905 | return ( (errcnt == 0 ) && (lstart == lend) ); |
843 | } | 906 | } |
844 | return true; | 907 | return true; |
845 | } | 908 | } |
846 | 909 | ||
847 | 910 | ||
848 | void ScriptWidget::save() { | 911 | void ScriptWidget::save() |
912 | { | ||
849 | QStringList typelist, arglist; | 913 | QStringList typelist, arglist; |
850 | for(uint i=0; i < sl->count(); i++) { | 914 | for(uint i=0; i < sl->count(); i++) |
915 | { | ||
851 | typelist.append(stl->text(i)); | 916 | typelist.append(stl->text(i)); |
852 | arglist.append(sl->text(i)); | 917 | arglist.append(sl->text(i)); |
853 | } | 918 | } |
854 | _pppdata->setScriptType(typelist); | 919 | _pppdata->setScriptType(typelist); |
855 | _pppdata->setScript(arglist); | 920 | _pppdata->setScript(arglist); |
856 | } | 921 | } |
857 | 922 | ||
858 | 923 | ||
859 | 924 | ||
860 | void ScriptWidget::adjustScrollBar() { | 925 | void ScriptWidget::adjustScrollBar() |
926 | { | ||
861 | if((int)sl->count() <= sl->numItemsVisible()) | 927 | if((int)sl->count() <= sl->numItemsVisible()) |
862 | slb->setRange(0, 0); | 928 | slb->setRange(0, 0); |
863 | else | 929 | else |
864 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 930 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
865 | } | 931 | } |
866 | 932 | ||
867 | 933 | ||
868 | void ScriptWidget::scrolling(int i) { | 934 | void ScriptWidget::scrolling(int i) |
935 | { | ||
869 | sl->setTopItem(i); | 936 | sl->setTopItem(i); |
870 | stl->setTopItem(i); | 937 | stl->setTopItem(i); |
871 | } | 938 | } |
872 | 939 | ||
873 | 940 | ||
874 | void ScriptWidget::slhighlighted(int i) { | 941 | void ScriptWidget::slhighlighted(int i) |
942 | { | ||
875 | insert->setEnabled(true); | 943 | insert->setEnabled(true); |
876 | remove->setEnabled(true); | 944 | remove->setEnabled(true); |
877 | stl->setCurrentItem(i); | 945 | stl->setCurrentItem(i); |
878 | } | 946 | } |
879 | 947 | ||
880 | 948 | ||
881 | void ScriptWidget::stlhighlighted(int i) { | 949 | void ScriptWidget::stlhighlighted(int i) |
950 | { | ||
882 | insert->setEnabled(true); | 951 | insert->setEnabled(true); |
883 | remove->setEnabled(true); | 952 | remove->setEnabled(true); |
884 | sl->setCurrentItem(i); | 953 | sl->setCurrentItem(i); |
885 | } | 954 | } |
886 | 955 | ||
887 | 956 | ||
888 | void ScriptWidget::addButton() { | 957 | void ScriptWidget::addButton() |
958 | { | ||
889 | //don't allow more than the maximum script entries | 959 | //don't allow more than the maximum script entries |
890 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 960 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
891 | return; | 961 | return; |
892 | 962 | ||
893 | switch(se->type()) { | 963 | switch(se->type()) |
964 | { | ||
894 | case ScriptEdit::Expect: | 965 | case ScriptEdit::Expect: |
895 | stl->insertItem("Expect"); | 966 | stl->insertItem("Expect"); |
896 | sl->insertItem(se->text()); | 967 | sl->insertItem(se->text()); |
897 | break; | 968 | break; |
898 | 969 | ||
899 | case ScriptEdit::Send: | 970 | case ScriptEdit::Send: |
900 | stl->insertItem("Send"); | 971 | stl->insertItem("Send"); |
901 | sl->insertItem(se->text()); | 972 | sl->insertItem(se->text()); |
902 | break; | 973 | break; |
903 | 974 | ||
904 | case ScriptEdit::SendNoEcho: | 975 | case ScriptEdit::SendNoEcho: |
905 | stl->insertItem("SendNoEcho"); | 976 | stl->insertItem("SendNoEcho"); |
@@ -971,31 +1042,33 @@ void ScriptWidget::addButton() { | |||
971 | } | 1042 | } |
972 | 1043 | ||
973 | //get the scrollbar adjusted, and scroll the list so we can see what | 1044 | //get the scrollbar adjusted, and scroll the list so we can see what |
974 | //we're adding to | 1045 | //we're adding to |
975 | adjustScrollBar(); | 1046 | adjustScrollBar(); |
976 | slb->setValue(slb->maxValue()); | 1047 | slb->setValue(slb->maxValue()); |
977 | 1048 | ||
978 | //clear the text in the entry box | 1049 | //clear the text in the entry box |
979 | se->setText(""); | 1050 | se->setText(""); |
980 | } | 1051 | } |
981 | 1052 | ||
982 | 1053 | ||
983 | void ScriptWidget::insertButton() { | 1054 | void ScriptWidget::insertButton() |
1055 | { | ||
984 | //exit if there is no highlighted item, or we've reached the | 1056 | //exit if there is no highlighted item, or we've reached the |
985 | //maximum entries in the script list | 1057 | //maximum entries in the script list |
986 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1058 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
987 | return; | 1059 | return; |
988 | 1060 | ||
989 | switch(se->type()) { | 1061 | switch(se->type()) |
1062 | { | ||
990 | case ScriptEdit::Expect: | 1063 | case ScriptEdit::Expect: |
991 | stl->insertItem("Expect", stl->currentItem()); | 1064 | stl->insertItem("Expect", stl->currentItem()); |
992 | sl->insertItem(se->text(), sl->currentItem()); | 1065 | sl->insertItem(se->text(), sl->currentItem()); |
993 | break; | 1066 | break; |
994 | 1067 | ||
995 | case ScriptEdit::Send: | 1068 | case ScriptEdit::Send: |
996 | stl->insertItem("Send", stl->currentItem()); | 1069 | stl->insertItem("Send", stl->currentItem()); |
997 | sl->insertItem(se->text(), sl->currentItem()); | 1070 | sl->insertItem(se->text(), sl->currentItem()); |
998 | break; | 1071 | break; |
999 | 1072 | ||
1000 | case ScriptEdit::SendNoEcho: | 1073 | case ScriptEdit::SendNoEcho: |
1001 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1074 | stl->insertItem("SendNoEcho", stl->currentItem()); |
@@ -1061,26 +1134,28 @@ void ScriptWidget::insertButton() { | |||
1061 | stl->insertItem("Save", stl->currentItem()); | 1134 | stl->insertItem("Save", stl->currentItem()); |
1062 | sl->insertItem(se->text(), sl->currentItem()); | 1135 | sl->insertItem(se->text(), sl->currentItem()); |
1063 | break; | 1136 | break; |
1064 | 1137 | ||
1065 | default: | 1138 | default: |
1066 | break; | 1139 | break; |
1067 | } | 1140 | } |
1068 | adjustScrollBar(); | 1141 | adjustScrollBar(); |
1069 | se->setText(""); | 1142 | se->setText(""); |
1070 | } | 1143 | } |
1071 | 1144 | ||
1072 | 1145 | ||
1073 | void ScriptWidget::removeButton() { | 1146 | void ScriptWidget::removeButton() |
1074 | if(sl->currentItem() >= 0) { | 1147 | { |
1148 | if(sl->currentItem() >= 0) | ||
1149 | { | ||
1075 | int stlc = stl->currentItem(); | 1150 | int stlc = stl->currentItem(); |
1076 | sl->removeItem(sl->currentItem()); | 1151 | sl->removeItem(sl->currentItem()); |
1077 | stl->removeItem(stlc); | 1152 | stl->removeItem(stlc); |
1078 | adjustScrollBar(); | 1153 | adjustScrollBar(); |
1079 | insert->setEnabled(sl->currentItem() != -1); | 1154 | insert->setEnabled(sl->currentItem() != -1); |
1080 | remove->setEnabled(sl->currentItem() != -1); | 1155 | remove->setEnabled(sl->currentItem() != -1); |
1081 | } | 1156 | } |
1082 | } | 1157 | } |
1083 | 1158 | ||
1084 | 1159 | ||
1085 | 1160 | ||
1086 | ///////////////////////////////////////////////////////////////////////////// | 1161 | ///////////////////////////////////////////////////////////////////////////// |
@@ -1110,25 +1185,27 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | |||
1110 | layout->addWidget( le ); | 1185 | layout->addWidget( le ); |
1111 | 1186 | ||
1112 | connect(le, SIGNAL(textChanged(const QString &)), | 1187 | connect(le, SIGNAL(textChanged(const QString &)), |
1113 | this, SLOT(textChanged(const QString &))); | 1188 | this, SLOT(textChanged(const QString &))); |
1114 | 1189 | ||
1115 | le->setFocus(); | 1190 | le->setFocus(); |
1116 | textChanged(""); | 1191 | textChanged(""); |
1117 | 1192 | ||
1118 | 1193 | ||
1119 | } | 1194 | } |
1120 | 1195 | ||
1121 | 1196 | ||
1122 | QString PhoneNumberDialog::phoneNumber() { | 1197 | QString PhoneNumberDialog::phoneNumber() |
1198 | { | ||
1123 | QString s = le->text(); | 1199 | QString s = le->text(); |
1124 | 1200 | ||
1125 | return s; | 1201 | return s; |
1126 | } | 1202 | } |
1127 | 1203 | ||
1128 | 1204 | ||
1129 | void PhoneNumberDialog::textChanged(const QString &s) { | 1205 | void PhoneNumberDialog::textChanged(const QString &s) |
1206 | { | ||
1130 | // enableButtonOK(s.length() > 0); | 1207 | // enableButtonOK(s.length() > 0); |
1131 | } | 1208 | } |
1132 | 1209 | ||
1133 | 1210 | ||
1134 | //#include "edit.moc" | 1211 | //#include "edit.moc" |