Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 1193 |
1 files changed, 1193 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp new file mode 100644 index 0000000..961047b --- a/dev/null +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -0,0 +1,1193 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd Front End for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
6 | * wuebben@math.cornell.edu | ||
7 | * | ||
8 | * based on EzPPP: | ||
9 | * Copyright (C) 1997 Jay Painter | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU Library General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * Library General Public License for more details. | ||
20 | * | ||
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 | ||
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | */ | ||
25 | |||
26 | #include <string.h> | ||
27 | #include <termios.h> | ||
28 | #include <qlayout.h> | ||
29 | #include <qmessagebox.h> | ||
30 | #include <qwhatsthis.h> | ||
31 | #include <qregexp.h> | ||
32 | #include <qapplication.h> | ||
33 | //#include <kiconloader.h> | ||
34 | #include <qbuttongroup.h> | ||
35 | //#include <klocale.h> | ||
36 | #define i18n QObject::tr | ||
37 | #include <qvgroupbox.h> | ||
38 | #include <qhbox.h> | ||
39 | #include <qdialog.h> | ||
40 | //#include <kwin.h> | ||
41 | |||
42 | #include "edit.h" | ||
43 | #include "pppdata.h" | ||
44 | #include "newwidget.h" | ||
45 | #include "iplined.h" | ||
46 | #include "auth.h" | ||
47 | |||
48 | DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) | ||
49 | : QWidget(parent, name) | ||
50 | { | ||
51 | const int GRIDROWS = 6; | ||
52 | |||
53 | QGridLayout *tl = new QGridLayout(parent, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | ||
54 | |||
55 | connect_label = new QLabel(i18n("Connection name:"), parent); | ||
56 | tl->addWidget(connect_label, 0, 0); | ||
57 | |||
58 | connectname_l = new QLineEdit(parent); | ||
59 | connectname_l->setMaxLength(ACCNAME_SIZE); | ||
60 | tl->addWidget(connectname_l, 0, 1); | ||
61 | QString tmp = i18n("Type in a unique name for this connection"); | ||
62 | |||
63 | QWhatsThis::add(connect_label,tmp); | ||
64 | QWhatsThis::add(connectname_l,tmp); | ||
65 | |||
66 | |||
67 | number_label = new QLabel(i18n("Phone number:"), parent); | ||
68 | number_label->setAlignment(AlignTop|AlignLeft); | ||
69 | tl->addWidget(number_label, 1, 0); | ||
70 | |||
71 | QHBoxLayout *lpn = new QHBoxLayout(5); | ||
72 | tl->addLayout(lpn, 1, 1); | ||
73 | numbers = new QListBox(parent); | ||
74 | numbers->setMinimumSize(120, 70); | ||
75 | lpn->addWidget(numbers); | ||
76 | QVBoxLayout *lpn1 = new QVBoxLayout; | ||
77 | lpn->addLayout(lpn1); | ||
78 | add = new QPushButton(i18n("&Add..."), parent); | ||
79 | del = new QPushButton(i18n("&Remove"), parent); | ||
80 | |||
81 | up = new QPushButton(parent); | ||
82 | //FIXME: QPixmap pm = BarIcon("up"); | ||
83 | // up->setPixmap(pm); | ||
84 | down = new QPushButton(parent); | ||
85 | //FIXME: pm = BarIcon("down"); | ||
86 | // down->setPixmap(pm); | ||
87 | lpn1->addWidget(add); | ||
88 | lpn1->addWidget(del); | ||
89 | lpn1->addStretch(1); | ||
90 | lpn1->addWidget(up); | ||
91 | lpn1->addWidget(down); | ||
92 | connect(add, SIGNAL(clicked()), | ||
93 | this, SLOT(addNumber())); | ||
94 | connect(del, SIGNAL(clicked()), | ||
95 | this, SLOT(delNumber())); | ||
96 | connect(up, SIGNAL(clicked()), | ||
97 | this, SLOT(upNumber())); | ||
98 | connect(down, SIGNAL(clicked()), | ||
99 | this, SLOT(downNumber())); | ||
100 | connect(numbers, SIGNAL(highlighted(int)), | ||
101 | this, SLOT(selectionChanged(int))); | ||
102 | numbersChanged(); | ||
103 | |||
104 | tmp = i18n("<p>Specifies the phone numbers to dial. You\n" | ||
105 | "can supply multiple numbers here, simply\n" | ||
106 | "click on \"Add\". You can arrange the\n" | ||
107 | "order the numbers are tried by using the\n" | ||
108 | "arrow buttons.\n\n" | ||
109 | "When a number is busy or fails, <i>kppp</i> will \n" | ||
110 | "try the next number and so on"); | ||
111 | |||
112 | QWhatsThis::add(number_label,tmp); | ||
113 | QWhatsThis::add(numbers,tmp); | ||
114 | |||
115 | auth_l = new QLabel(i18n("Authentication:"), parent); | ||
116 | tl->addWidget(auth_l, 3, 0); | ||
117 | |||
118 | auth = new QComboBox(parent); | ||
119 | auth->insertItem(i18n("Script-based")); | ||
120 | auth->insertItem(i18n("PAP")); | ||
121 | auth->insertItem(i18n("Terminal-based")); | ||
122 | auth->insertItem(i18n("CHAP")); | ||
123 | auth->insertItem(i18n("PAP/CHAP")); | ||
124 | tl->addWidget(auth, 3, 1); | ||
125 | tmp = i18n("<p>Specifies the method used to identify yourself to\n" | ||
126 | "the PPP server. Most universities still use\n" | ||
127 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | ||
128 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | ||
129 | "unsure, contact your ISP.\n" | ||
130 | "\n" | ||
131 | "If you can choose between PAP and CHAP,\n" | ||
132 | "choose CHAP, because it's much safer. If you don't know\n" | ||
133 | "whether PAP or CHAP is right, choose PAP/CHAP."); | ||
134 | |||
135 | QWhatsThis::add(auth_l,tmp); | ||
136 | QWhatsThis::add(auth,tmp); | ||
137 | |||
138 | store_password = new QCheckBox(i18n("Store password"), parent); | ||
139 | store_password->setChecked(true); | ||
140 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); | ||
141 | QWhatsThis::add(store_password, | ||
142 | i18n("<p>When this is turned on, your ISP password\n" | ||
143 | "will be saved in <i>kppp</i>'s config file, so\n" | ||
144 | "you do not need to type it in every time.\n" | ||
145 | "\n" | ||
146 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | ||
147 | "plain text in the config file, which is\n" | ||
148 | "readable only to you. Make sure nobody\n" | ||
149 | "gains access to this file!")); | ||
150 | |||
151 | pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), parent); | ||
152 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | ||
153 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | ||
154 | |||
155 | // Set defaults if editing an existing connection | ||
156 | if(!isnewaccount) { | ||
157 | connectname_l->setText(gpppdata.accname()); | ||
158 | |||
159 | // insert the phone numbers into the listbox | ||
160 | QString n = gpppdata.phonenumber(); | ||
161 | QString tmp = ""; | ||
162 | uint idx = 0; | ||
163 | while(idx != n.length()) { | ||
164 | if(n[idx] == ':') { | ||
165 | if(tmp.length() > 0) | ||
166 | numbers->insertItem(tmp); | ||
167 | tmp = ""; | ||
168 | } else | ||
169 | tmp += n[idx]; | ||
170 | idx++; | ||
171 | } | ||
172 | if(tmp.length() > 0) | ||
173 | numbers->insertItem(tmp); | ||
174 | |||
175 | auth->setCurrentItem(gpppdata.authMethod()); | ||
176 | store_password->setChecked(gpppdata.storePassword()); | ||
177 | } else { | ||
178 | // select PAP/CHAP as default | ||
179 | auth->setCurrentItem(AUTH_PAPCHAP); | ||
180 | } | ||
181 | |||
182 | numbersChanged(); | ||
183 | tl->activate(); | ||
184 | } | ||
185 | |||
186 | |||
187 | bool DialWidget::save() { | ||
188 | //first check to make sure that the account name is unique! | ||
189 | if(connectname_l->text().isEmpty() || | ||
190 | !gpppdata.isUniqueAccname(connectname_l->text())) { | ||
191 | return false; | ||
192 | } else { | ||
193 | gpppdata.setAccname(connectname_l->text()); | ||
194 | |||
195 | QString number = ""; | ||
196 | for(uint i = 0; i < numbers->count(); i++) { | ||
197 | if(i != 0) | ||
198 | number += ":"; | ||
199 | number += numbers->text(i); | ||
200 | } | ||
201 | |||
202 | gpppdata.setPhonenumber(number); | ||
203 | gpppdata.setAuthMethod(auth->currentItem()); | ||
204 | gpppdata.setStorePassword(store_password->isChecked()); | ||
205 | return true; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | |||
210 | void DialWidget::numbersChanged() { | ||
211 | int sel = numbers->currentItem(); | ||
212 | |||
213 | del->setEnabled(sel != -1); | ||
214 | up->setEnabled(sel != -1 && sel != 0); | ||
215 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | ||
216 | } | ||
217 | |||
218 | |||
219 | void DialWidget::selectionChanged(int) { | ||
220 | numbersChanged(); | ||
221 | } | ||
222 | |||
223 | |||
224 | void DialWidget::addNumber() { | ||
225 | PhoneNumberDialog dlg(this); | ||
226 | if(dlg.exec()) { | ||
227 | numbers->insertItem(dlg.phoneNumber()); | ||
228 | numbersChanged(); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | |||
233 | void DialWidget::delNumber() { | ||
234 | if(numbers->currentItem() != -1) { | ||
235 | numbers->removeItem(numbers->currentItem()); | ||
236 | numbersChanged(); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | |||
241 | void DialWidget::upNumber() { | ||
242 | int idx = numbers->currentItem(); | ||
243 | if(idx != -1) { | ||
244 | QString item = numbers->text(idx); | ||
245 | numbers->removeItem(idx); | ||
246 | numbers->insertItem(item, idx-1); | ||
247 | numbers->setCurrentItem(idx-1); | ||
248 | numbersChanged(); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | |||
253 | void DialWidget::downNumber() { | ||
254 | int idx = numbers->currentItem(); | ||
255 | if(idx != -1) { | ||
256 | QString item = numbers->text(idx); | ||
257 | numbers->removeItem(idx); | ||
258 | numbers->insertItem(item, idx+1); | ||
259 | numbers->setCurrentItem(idx+1); | ||
260 | numbersChanged(); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | |||
265 | void DialWidget::pppdargsbutton() { | ||
266 | PPPdArguments pa(this); | ||
267 | pa.exec(); | ||
268 | } | ||
269 | |||
270 | |||
271 | |||
272 | ///////////////////////////////////////////////////////////////////////////// | ||
273 | // ExecWidget | ||
274 | ///////////////////////////////////////////////////////////////////////////// | ||
275 | ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) : | ||
276 | QWidget(parent, name) | ||
277 | { | ||
278 | QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint()); | ||
279 | |||
280 | QLabel *l = new QLabel(\ | ||
281 | 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 | "you cannot run any commands here requiring root permissions\n" | ||
284 | "(unless, of course, you are root).\n\n" | ||
285 | "Be sure to supply the whole path to the program otherwise\n" | ||
286 | "kppp might be unable to find it."), parent); | ||
287 | l->setMinimumHeight(l->sizeHint().height()); | ||
288 | tl->addWidget(l); | ||
289 | tl->addStretch(1); | ||
290 | |||
291 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | ||
292 | tl->addLayout(l1); | ||
293 | l1->setColStretch(0, 0); | ||
294 | l1->setColStretch(1, 1); | ||
295 | |||
296 | before_connect_l = new QLabel(i18n("Before connect:"), parent); | ||
297 | before_connect_l->setAlignment(AlignVCenter); | ||
298 | l1->addWidget(before_connect_l, 0, 0); | ||
299 | before_connect = new QLineEdit(parent); | ||
300 | before_connect->setMaxLength(COMMAND_SIZE); | ||
301 | l1->addWidget(before_connect, 0, 1); | ||
302 | QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n" | ||
303 | "is established. It is called immediately before\n" | ||
304 | "dialing has begun.\n\n" | ||
305 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | ||
306 | "modem."); | ||
307 | |||
308 | QWhatsThis::add(before_connect_l,tmp); | ||
309 | QWhatsThis::add(before_connect,tmp); | ||
310 | |||
311 | command_label = new QLabel(i18n("Upon connect:"), parent); | ||
312 | command_label->setAlignment(AlignVCenter); | ||
313 | l1->addWidget(command_label, 1, 0); | ||
314 | command = new QLineEdit(parent); | ||
315 | command->setMaxLength(COMMAND_SIZE); | ||
316 | l1->addWidget(command, 1, 1); | ||
317 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" | ||
318 | "is established. When your program is called, all\n" | ||
319 | "preparations for an Internet connection are finished.\n" | ||
320 | "\n" | ||
321 | "Very useful for fetching mail and news"); | ||
322 | |||
323 | QWhatsThis::add(command_label,tmp); | ||
324 | QWhatsThis::add(command,tmp); | ||
325 | |||
326 | predisconnect_label = new QLabel(i18n("Before disconnect:"), | ||
327 | parent); | ||
328 | predisconnect_label->setAlignment(AlignVCenter); | ||
329 | l1->addWidget(predisconnect_label, 2, 0); | ||
330 | predisconnect = new QLineEdit(parent); | ||
331 | predisconnect->setMaxLength(COMMAND_SIZE); | ||
332 | l1->addWidget(predisconnect, 2, 1); | ||
333 | tmp = i18n("Allows you to run a program <b>before</b> a connection\n" | ||
334 | "is closed. The connection will stay open until\n" | ||
335 | "the program exits."); | ||
336 | |||
337 | QWhatsThis::add(predisconnect_label,tmp); | ||
338 | QWhatsThis::add(predisconnect,tmp); | ||
339 | |||
340 | discommand_label = new QLabel(i18n("Upon disconnect:"), | ||
341 | parent); | ||
342 | discommand_label->setAlignment(AlignVCenter); | ||
343 | l1->addWidget(discommand_label, 3, 0); | ||
344 | |||
345 | discommand = new QLineEdit(parent); | ||
346 | discommand->setMaxLength(COMMAND_SIZE); | ||
347 | l1->addWidget(discommand, 3, 1); | ||
348 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" | ||
349 | "has been closed."); | ||
350 | |||
351 | QWhatsThis::add(discommand_label,tmp); | ||
352 | QWhatsThis::add(discommand,tmp); | ||
353 | |||
354 | // extra space between entries | ||
355 | l1->addRowSpacing(1, 5); | ||
356 | l1->addRowSpacing(3, 5); | ||
357 | |||
358 | tl->addStretch(1); | ||
359 | tl->activate(); | ||
360 | |||
361 | // Set defaults if editing an existing connection | ||
362 | if(!isnewaccount) { | ||
363 | before_connect->setText(gpppdata.command_before_connect()); | ||
364 | command->setText(gpppdata.command_on_connect()); | ||
365 | discommand->setText(gpppdata.command_on_disconnect()); | ||
366 | predisconnect->setText(gpppdata.command_before_disconnect()); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | |||
371 | bool ExecWidget::save() { | ||
372 | gpppdata.setCommand_before_connect(before_connect->text()); | ||
373 | gpppdata.setCommand_on_connect(command->text()); | ||
374 | gpppdata.setCommand_before_disconnect(predisconnect->text()); | ||
375 | gpppdata.setCommand_on_disconnect(discommand->text()); | ||
376 | return true; | ||
377 | } | ||
378 | |||
379 | |||
380 | |||
381 | ///////////////////////////////////////////////////////////////////////////// | ||
382 | // | ||
383 | // IPWidget | ||
384 | // | ||
385 | ///////////////////////////////////////////////////////////////////////////// | ||
386 | IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) | ||
387 | : QWidget(parent, name) | ||
388 | { | ||
389 | QVBoxLayout *topLayout = new QVBoxLayout(parent); | ||
390 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | ||
391 | |||
392 | box = new QVGroupBox(i18n("Configuration"), parent); | ||
393 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | ||
394 | |||
395 | rb = new QButtonGroup(parent); | ||
396 | rb->hide(); | ||
397 | connect(rb, SIGNAL(clicked(int)), | ||
398 | SLOT(hitIPSelect(int))); | ||
399 | |||
400 | dynamicadd_rb = new QRadioButton(box); | ||
401 | dynamicadd_rb->setText(i18n("Dynamic IP address")); | ||
402 | QWhatsThis::add(dynamicadd_rb, | ||
403 | i18n("Select this option when your computer gets an\n" | ||
404 | "internet address (IP) every time a\n" | ||
405 | "connection is made.\n" | ||
406 | "\n" | ||
407 | "Almost every Internet Service Provider uses\n" | ||
408 | "this method, so this should be turned on.")); | ||
409 | |||
410 | staticadd_rb = new QRadioButton(box); | ||
411 | staticadd_rb->setText(i18n("Static IP address")); | ||
412 | rb->insert(dynamicadd_rb, 0); | ||
413 | rb->insert(staticadd_rb, 1); | ||
414 | QWhatsThis::add(staticadd_rb, | ||
415 | i18n("Select this option when your computer has a\n" | ||
416 | "fixed internet address (IP). Most computers\n" | ||
417 | "don't have this, so you should probably select\n" | ||
418 | "dynamic IP addressing unless you know what you\n" | ||
419 | "are doing.")); | ||
420 | |||
421 | QWidget *ipWidget = new QWidget(box); | ||
422 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | ||
423 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | ||
424 | |||
425 | ipaddress_label = new QLabel(i18n("IP address:"), ipWidget); | ||
426 | QString tmp = i18n("If your computer has a permanent internet\n" | ||
427 | "address, you must supply your IP address here."); | ||
428 | ipLayout->addWidget(ipaddress_label, 0, 0); | ||
429 | |||
430 | ipaddress_l = new IPLineEdit(ipWidget); | ||
431 | ipLayout->addWidget(ipaddress_l, 0, 1); | ||
432 | |||
433 | QWhatsThis::add(ipaddress_label,tmp); | ||
434 | QWhatsThis::add(ipaddress_l,tmp); | ||
435 | |||
436 | sub_label = new QLabel(i18n("Subnet mask:"), ipWidget); | ||
437 | tmp = i18n("<p>If your computer has a static Internet address,\n" | ||
438 | "you must supply a network mask here. In almost\n" | ||
439 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | ||
440 | "but your mileage may vary.\n" | ||
441 | "\n" | ||
442 | "If unsure, contact your Internet Service Provider"); | ||
443 | ipLayout->addWidget(sub_label, 1, 0); | ||
444 | |||
445 | subnetmask_l = new IPLineEdit(ipWidget); | ||
446 | ipLayout->addWidget(subnetmask_l, 1, 1); | ||
447 | |||
448 | QWhatsThis::add(sub_label,tmp); | ||
449 | QWhatsThis::add(subnetmask_l,tmp); | ||
450 | |||
451 | autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), parent); | ||
452 | autoname->setChecked(gpppdata.autoname()); | ||
453 | connect(autoname,SIGNAL(toggled(bool)), | ||
454 | this,SLOT(autoname_t(bool))); | ||
455 | |||
456 | QWhatsThis::add(autoname, | ||
457 | i18n("<p>Whenever you connect, this reconfigures\n" | ||
458 | "your hostname to match the IP address you\n" | ||
459 | "got from the PPP server. This may be useful\n" | ||
460 | "if you need to use a protocol which depends\n" | ||
461 | "on this information, but it can also cause several\n" | ||
462 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | ||
463 | "\n" | ||
464 | "Don't enable this unless you really need it.")); | ||
465 | |||
466 | topLayout->addWidget(box); | ||
467 | topLayout->addWidget(autoname); | ||
468 | topLayout->addStretch(); | ||
469 | |||
470 | //load info from gpppdata | ||
471 | if(!isnewaccount) { | ||
472 | if(gpppdata.ipaddr() == "0.0.0.0" && | ||
473 | gpppdata.subnetmask() == "0.0.0.0") { | ||
474 | dynamicadd_rb->setChecked(true); | ||
475 | hitIPSelect(0); | ||
476 | autoname->setChecked(gpppdata.autoname()); | ||
477 | } | ||
478 | else { | ||
479 | ipaddress_l->setText(gpppdata.ipaddr()); | ||
480 | subnetmask_l->setText(gpppdata.subnetmask()); | ||
481 | staticadd_rb->setChecked(true); | ||
482 | autoname->setChecked(false); | ||
483 | } | ||
484 | } | ||
485 | else { | ||
486 | dynamicadd_rb->setChecked(true); | ||
487 | hitIPSelect(0); | ||
488 | } | ||
489 | |||
490 | } | ||
491 | |||
492 | void IPWidget::autoname_t(bool on) { | ||
493 | static bool was_warned = false; | ||
494 | |||
495 | // big-fat warning when selecting the auto configure hostname option | ||
496 | if(on && !was_warned) { | ||
497 | QMessageBox::information(this, | ||
498 | i18n("Selecting this option might cause some weird " | ||
499 | "problems with the X-server and applications " | ||
500 | "while kppp is connected. Don't use it until " | ||
501 | "you know what you are doing!\n" | ||
502 | "For more information take a look at the " | ||
503 | "handbook (or help) in the section \"Frequently " | ||
504 | "asked questions\"."), | ||
505 | i18n("Warning")); | ||
506 | was_warned = true; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | |||
511 | void IPWidget::save() { | ||
512 | if(dynamicadd_rb->isChecked()) { | ||
513 | gpppdata.setIpaddr("0.0.0.0"); | ||
514 | gpppdata.setSubnetmask("0.0.0.0"); | ||
515 | } else { | ||
516 | gpppdata.setIpaddr(ipaddress_l->text()); | ||
517 | gpppdata.setSubnetmask(subnetmask_l->text()); | ||
518 | } | ||
519 | gpppdata.setAutoname(autoname->isChecked()); | ||
520 | } | ||
521 | |||
522 | |||
523 | void IPWidget::hitIPSelect( int i ) { | ||
524 | if(i == 0) { | ||
525 | ipaddress_label->setEnabled(false); | ||
526 | sub_label->setEnabled(false); | ||
527 | ipaddress_l->setEnabled(false); | ||
528 | subnetmask_l->setEnabled(false); | ||
529 | } | ||
530 | else { | ||
531 | ipaddress_label->setEnabled(true); | ||
532 | sub_label->setEnabled(true); | ||
533 | ipaddress_l->setEnabled(true); | ||
534 | subnetmask_l->setEnabled(true); | ||
535 | } | ||
536 | } | ||
537 | |||
538 | |||
539 | |||
540 | DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) | ||
541 | : QWidget(parent, name) | ||
542 | { | ||
543 | // box = new QGroupBox(parent); | ||
544 | QGridLayout *tl = new QGridLayout(parent, 7, 2, 0 );//, KDialog::spacingHint()); | ||
545 | |||
546 | dnsdomain_label = new QLabel(i18n("Domain name:"), parent); | ||
547 | tl->addWidget(dnsdomain_label, 0, 0); | ||
548 | |||
549 | dnsdomain = new QLineEdit(parent); | ||
550 | dnsdomain->setMaxLength(DOMAIN_SIZE); | ||
551 | tl->addWidget(dnsdomain, 0, 1); | ||
552 | 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 | "connected. When the connection is closed, the\n" | ||
555 | "original domain name of your computer is\n" | ||
556 | "restored.\n" | ||
557 | "\n" | ||
558 | "If you leave this field blank, no changes are\n" | ||
559 | "made to the domain name."); | ||
560 | |||
561 | QWhatsThis::add(dnsdomain_label,tmp); | ||
562 | QWhatsThis::add(dnsdomain,tmp); | ||
563 | |||
564 | conf_label = new QLabel(i18n("Configuration:"), parent); | ||
565 | tl->addWidget(conf_label, 1, 0); | ||
566 | |||
567 | bg = new QButtonGroup("Group", this); | ||
568 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | ||
569 | bg->hide(); | ||
570 | |||
571 | autodns = new QRadioButton(i18n("Automatic"), parent); | ||
572 | bg->insert(autodns, 0); | ||
573 | tl->addWidget(autodns, 1, 1); | ||
574 | // no automatic DNS detection for pppd < 2.3.7 | ||
575 | if(!gpppdata.pppdVersionMin(2, 3, 7)) | ||
576 | autodns->setEnabled(false); | ||
577 | |||
578 | mandns = new QRadioButton(i18n("Manual"), parent); | ||
579 | bg->insert(mandns, 1); | ||
580 | tl->addWidget(mandns, 2, 1); | ||
581 | |||
582 | dns_label = new QLabel(i18n("DNS IP address:"), parent); | ||
583 | tl->addWidget(dns_label, 3, 0); | ||
584 | |||
585 | QHBoxLayout *l2 = new QHBoxLayout; | ||
586 | tl->addLayout(l2, 3, 1); | ||
587 | dnsipaddr = new IPLineEdit(parent); | ||
588 | connect(dnsipaddr, SIGNAL(returnPressed()), | ||
589 | SLOT(adddns())); | ||
590 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | ||
591 | SLOT(DNS_Edit_Changed(const QString &))); | ||
592 | l2->addWidget(dnsipaddr, 1); | ||
593 | l2->addStretch(1); | ||
594 | tmp = i18n("<p>Allows you to specify a new DNS server to be\n" | ||
595 | "used while you are connected. When the\n" | ||
596 | "connection is closed, this DNS entry will be\n" | ||
597 | "removed again.\n" | ||
598 | "\n" | ||
599 | "To add a DNS server, type in the IP address of\n" | ||
600 | "the DNS server here and click on <b>Add</b>"); | ||
601 | |||
602 | QWhatsThis::add(dns_label, tmp); | ||
603 | QWhatsThis::add(dnsipaddr, tmp); | ||
604 | |||
605 | QHBoxLayout *l1 = new QHBoxLayout; | ||
606 | tl->addLayout(l1, 4, 1); | ||
607 | add = new QPushButton(i18n("Add"), parent); | ||
608 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | ||
609 | int width = add->sizeHint().width(); | ||
610 | width = QMAX(width,60); | ||
611 | add->setMinimumWidth(width); | ||
612 | l1->addWidget(add); | ||
613 | l1->addStretch(1); | ||
614 | QWhatsThis::add(add, | ||
615 | i18n("Click this button to add the DNS server\n" | ||
616 | "specified in the field above. The entry\n" | ||
617 | "will then be added to the list below")); | ||
618 | |||
619 | remove = new QPushButton(i18n("Remove"), parent); | ||
620 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | ||
621 | width = remove->sizeHint().width(); | ||
622 | width = QMAX(width,60); | ||
623 | remove->setMinimumWidth(width); | ||
624 | l1->addWidget(remove); | ||
625 | QWhatsThis::add(remove, | ||
626 | i18n("Click this button to remove the selected DNS\n" | ||
627 | "server entry from the list below")); | ||
628 | |||
629 | servers_label = new QLabel(i18n("DNS address list:"), parent); | ||
630 | servers_label->setAlignment(AlignTop|AlignLeft); | ||
631 | tl->addWidget(servers_label, 5, 0); | ||
632 | |||
633 | dnsservers = new QListBox(parent); | ||
634 | dnsservers->setMinimumSize(150, 80); | ||
635 | connect(dnsservers, SIGNAL(highlighted(int)), | ||
636 | SLOT(DNS_Entry_Selected(int))); | ||
637 | tl->addWidget(dnsservers, 5, 1); | ||
638 | 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 | "<b>Remove</b> buttons to modify the list"); | ||
641 | |||
642 | QWhatsThis::add(servers_label,tmp); | ||
643 | QWhatsThis::add(dnsservers,tmp); | ||
644 | |||
645 | exdnsdisabled_toggle = new QCheckBox(i18n( \ | ||
646 | "Disable existing DNS servers during connection"), | ||
647 | parent); | ||
648 | exdnsdisabled_toggle->setChecked(gpppdata.exDNSDisabled()); | ||
649 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | ||
650 | QWhatsThis::add(exdnsdisabled_toggle, | ||
651 | i18n("<p>When this option is selected, all DNS\n" | ||
652 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | ||
653 | "temporary disabled while the dialup connection\n" | ||
654 | "is established. After the connection is\n" | ||
655 | "closed, the servers will be re-enabled\n" | ||
656 | "\n" | ||
657 | "Typically, there is no reason to use this\n" | ||
658 | "option, but it may become useful under \n" | ||
659 | "some circumstances.")); | ||
660 | |||
661 | |||
662 | // restore data if editing | ||
663 | if(!isnewaccount) { | ||
664 | dnsservers->insertStringList(gpppdata.dns()); | ||
665 | dnsdomain->setText(gpppdata.domain()); | ||
666 | } | ||
667 | |||
668 | int mode = gpppdata.autoDNS() ? 0 : 1; | ||
669 | bg->setButton(mode); | ||
670 | DNS_Mode_Selected(mode); | ||
671 | |||
672 | tl->activate(); | ||
673 | } | ||
674 | |||
675 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | ||
676 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | ||
677 | add->setEnabled(text.find(r) != -1); | ||
678 | } | ||
679 | |||
680 | void DNSWidget::DNS_Entry_Selected(int) { | ||
681 | remove->setEnabled(true); | ||
682 | } | ||
683 | |||
684 | void DNSWidget::DNS_Mode_Selected(int mode) { | ||
685 | bool on = (mode == 1); | ||
686 | dns_label->setEnabled(on); | ||
687 | servers_label->setEnabled(on); | ||
688 | dnsipaddr->setText(""); | ||
689 | dnsipaddr->setEnabled(on); | ||
690 | add->setEnabled(false); | ||
691 | remove->setEnabled(dnsservers->count()>0 && on); | ||
692 | dnsservers->clearSelection(); | ||
693 | dnsservers->setEnabled(on); | ||
694 | dnsservers->triggerUpdate(false); | ||
695 | } | ||
696 | |||
697 | void DNSWidget::save() { | ||
698 | gpppdata.setAutoDNS(bg->id(bg->selected()) == 0); | ||
699 | QStringList serverlist; | ||
700 | for(uint i=0; i < dnsservers->count(); i++) | ||
701 | serverlist.append(dnsservers->text(i)); | ||
702 | gpppdata.setDns(serverlist); | ||
703 | |||
704 | // strip leading dot | ||
705 | QString s(dnsdomain->text()); | ||
706 | if(s.left(1) == ".") | ||
707 | gpppdata.setDomain(s.mid(1)); | ||
708 | else | ||
709 | gpppdata.setDomain(dnsdomain->text()); | ||
710 | |||
711 | gpppdata.setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | ||
712 | } | ||
713 | |||
714 | |||
715 | void DNSWidget::adddns() { | ||
716 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | ||
717 | dnsservers->insertItem(dnsipaddr->text()); | ||
718 | dnsipaddr->setText(""); | ||
719 | } | ||
720 | } | ||
721 | |||
722 | |||
723 | void DNSWidget::removedns() { | ||
724 | int i; | ||
725 | i = dnsservers->currentItem(); | ||
726 | if(i != -1) | ||
727 | dnsservers->removeItem(i); | ||
728 | remove->setEnabled(dnsservers->count()>0); | ||
729 | } | ||
730 | |||
731 | |||
732 | // | ||
733 | // GatewayWidget | ||
734 | // | ||
735 | GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) | ||
736 | : QWidget(parent, name) | ||
737 | { | ||
738 | QVBoxLayout *topLayout = new QVBoxLayout(parent); | ||
739 | topLayout->setSpacing( 2 );//KDialog::spacingHint()); | ||
740 | |||
741 | box = new QVGroupBox(i18n("Configuration"), parent); | ||
742 | // box->setInsideSpacing( 2 );//KDialog::spacingHint()); | ||
743 | |||
744 | rb = new QButtonGroup(parent); | ||
745 | rb->hide(); | ||
746 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | ||
747 | |||
748 | defaultgateway = new QRadioButton(box); | ||
749 | defaultgateway->setText(i18n("Default gateway")); | ||
750 | rb->insert(defaultgateway, 0); | ||
751 | QWhatsThis::add(defaultgateway, | ||
752 | i18n("This makes the PPP peer computer (the computer\n" | ||
753 | "you are connected to with your modem) to act as\n" | ||
754 | "a gateway. Your computer will send all packets not\n" | ||
755 | "going to a computer inside your local net to this\n" | ||
756 | "computer, which will route these packets.\n" | ||
757 | "\n" | ||
758 | "This is the default for most ISPs, so you should\n" | ||
759 | "probably leave this option on.")); | ||
760 | |||
761 | |||
762 | staticgateway = new QRadioButton(box); | ||
763 | staticgateway->setText(i18n("Static gateway")); | ||
764 | rb->insert(staticgateway, 1); | ||
765 | QWhatsThis::add(staticgateway, | ||
766 | i18n("<p>Allows you to specify which computer you want\n" | ||
767 | "to use as gateway (see <i>Default Gateway</i> above)")); | ||
768 | |||
769 | QHBox *gateBox = new QHBox(box); | ||
770 | gate_label = new QLabel(i18n("Gateway IP address:"), gateBox); | ||
771 | gatewayaddr = new IPLineEdit(gateBox); | ||
772 | |||
773 | defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"), | ||
774 | parent); | ||
775 | QWhatsThis::add(defaultroute, | ||
776 | i18n("If this option is enabled, all packets not\n" | ||
777 | "going to the local net are routed through\n" | ||
778 | "the PPP connection.\n" | ||
779 | "\n" | ||
780 | "Normally, you should turn this on")); | ||
781 | |||
782 | topLayout->addWidget(box); | ||
783 | topLayout->addWidget(defaultroute); | ||
784 | topLayout->addStretch(); | ||
785 | |||
786 | //load info from gpppdata | ||
787 | if(!isnewaccount) { | ||
788 | if(gpppdata.gateway() == "0.0.0.0") { | ||
789 | defaultgateway->setChecked(true); | ||
790 | hitGatewaySelect(0); | ||
791 | } | ||
792 | else { | ||
793 | gatewayaddr->setText(gpppdata.gateway()); | ||
794 | staticgateway->setChecked(true); | ||
795 | } | ||
796 | defaultroute->setChecked(gpppdata.defaultroute()); | ||
797 | } | ||
798 | else { | ||
799 | defaultgateway->setChecked(true); | ||
800 | hitGatewaySelect(0); | ||
801 | defaultroute->setChecked(true); | ||
802 | } | ||
803 | } | ||
804 | |||
805 | void GatewayWidget::save() { | ||
806 | gpppdata.setGateway(gatewayaddr->text()); | ||
807 | gpppdata.setDefaultroute(defaultroute->isChecked()); | ||
808 | } | ||
809 | |||
810 | |||
811 | void GatewayWidget::hitGatewaySelect( int i ) { | ||
812 | if(i == 0) { | ||
813 | gatewayaddr->setText("0.0.0.0"); | ||
814 | gatewayaddr->setEnabled(false); | ||
815 | gate_label->setEnabled(false); | ||
816 | } | ||
817 | else { | ||
818 | gatewayaddr->setEnabled(true); | ||
819 | gatewayaddr->setText(""); | ||
820 | gate_label->setEnabled(true); | ||
821 | } | ||
822 | } | ||
823 | |||
824 | |||
825 | |||
826 | ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) | ||
827 | : QWidget(parent, name) | ||
828 | { | ||
829 | QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint()); | ||
830 | se = new ScriptEdit(parent); | ||
831 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | ||
832 | tl->addWidget(se); | ||
833 | |||
834 | // insert equal-sized buttons | ||
835 | QButtonGroup *bbox = new QButtonGroup(parent); | ||
836 | add = new QPushButton( bbox, i18n("Add") ); | ||
837 | bbox->insert(add); | ||
838 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | ||
839 | // bbox->addStretch(1); | ||
840 | insert = new QPushButton( bbox, i18n("Insert") ); | ||
841 | bbox->insert(insert); | ||
842 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | ||
843 | // bbox->addStretch(1); | ||
844 | remove = new QPushButton( bbox, i18n("Remove") ); | ||
845 | bbox->insert(remove); | ||
846 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | ||
847 | bbox->layout(); | ||
848 | tl->addWidget(bbox); | ||
849 | |||
850 | QHBoxLayout *l12 = new QHBoxLayout(0); | ||
851 | tl->addLayout(l12); | ||
852 | stl = new QListBox(parent); | ||
853 | stl->setVScrollBarMode( QScrollView::AlwaysOff ); | ||
854 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | ||
855 | stl->setMinimumSize(QSize(70, 140)); | ||
856 | |||
857 | sl = new QListBox(parent); | ||
858 | sl->setVScrollBarMode( QScrollView::AlwaysOff ); | ||
859 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | ||
860 | sl->setMinimumSize(QSize(150, 140)); | ||
861 | |||
862 | slb = new QScrollBar(parent); | ||
863 | slb->setFixedWidth(slb->sizeHint().width()); | ||
864 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | ||
865 | |||
866 | l12->addWidget(stl, 1); | ||
867 | l12->addWidget(sl, 3); | ||
868 | l12->addWidget(slb, 0); | ||
869 | |||
870 | //load data from gpppdata | ||
871 | if(!isnewaccount) { | ||
872 | QStringList &comlist = gpppdata.scriptType(); | ||
873 | QStringList &arglist = gpppdata.script(); | ||
874 | QStringList::Iterator itcom = comlist.begin(); | ||
875 | QStringList::Iterator itarg = arglist.begin(); | ||
876 | |||
877 | for ( ; | ||
878 | itcom != comlist.end() && itarg != arglist.end(); | ||
879 | ++itcom, ++itarg ) | ||
880 | { | ||
881 | stl->insertItem(*itcom); | ||
882 | sl->insertItem(*itarg); | ||
883 | } | ||
884 | } | ||
885 | |||
886 | insert->setEnabled(false); | ||
887 | remove->setEnabled(false); | ||
888 | adjustScrollBar(); | ||
889 | tl->activate(); | ||
890 | } | ||
891 | |||
892 | bool ScriptWidget::check() { | ||
893 | uint lstart = 0; | ||
894 | uint lend = 0; | ||
895 | uint errcnt = 0; | ||
896 | |||
897 | if(sl->count() > 0) { | ||
898 | for( uint i=0; i <= sl->count()-1; i++) { | ||
899 | if(stl->text(i) == "LoopStart") { | ||
900 | lstart++; | ||
901 | } | ||
902 | if (stl->text(i) == "LoopEnd") { | ||
903 | lend++; | ||
904 | } | ||
905 | if ( lend > lstart ) errcnt++; | ||
906 | } | ||
907 | return ( (errcnt == 0 ) && (lstart == lend) ); | ||
908 | } | ||
909 | return true; | ||
910 | } | ||
911 | |||
912 | |||
913 | void ScriptWidget::save() { | ||
914 | QStringList typelist, arglist; | ||
915 | for(uint i=0; i < sl->count(); i++) { | ||
916 | typelist.append(stl->text(i)); | ||
917 | arglist.append(sl->text(i)); | ||
918 | } | ||
919 | gpppdata.setScriptType(typelist); | ||
920 | gpppdata.setScript(arglist); | ||
921 | } | ||
922 | |||
923 | |||
924 | |||
925 | void ScriptWidget::adjustScrollBar() { | ||
926 | if((int)sl->count() <= sl->numItemsVisible()) | ||
927 | slb->setRange(0, 0); | ||
928 | else | ||
929 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | ||
930 | } | ||
931 | |||
932 | |||
933 | void ScriptWidget::scrolling(int i) { | ||
934 | sl->setTopItem(i); | ||
935 | stl->setTopItem(i); | ||
936 | } | ||
937 | |||
938 | |||
939 | void ScriptWidget::slhighlighted(int i) { | ||
940 | insert->setEnabled(true); | ||
941 | remove->setEnabled(true); | ||
942 | stl->setCurrentItem(i); | ||
943 | } | ||
944 | |||
945 | |||
946 | void ScriptWidget::stlhighlighted(int i) { | ||
947 | insert->setEnabled(true); | ||
948 | remove->setEnabled(true); | ||
949 | sl->setCurrentItem(i); | ||
950 | } | ||
951 | |||
952 | |||
953 | void ScriptWidget::addButton() { | ||
954 | //don't allow more than the maximum script entries | ||
955 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | ||
956 | return; | ||
957 | |||
958 | switch(se->type()) { | ||
959 | case ScriptEdit::Expect: | ||
960 | stl->insertItem("Expect"); | ||
961 | sl->insertItem(se->text()); | ||
962 | break; | ||
963 | |||
964 | case ScriptEdit::Send: | ||
965 | stl->insertItem("Send"); | ||
966 | sl->insertItem(se->text()); | ||
967 | break; | ||
968 | |||
969 | case ScriptEdit::SendNoEcho: | ||
970 | stl->insertItem("SendNoEcho"); | ||
971 | sl->insertItem(se->text()); | ||
972 | break; | ||
973 | |||
974 | case ScriptEdit::Pause: | ||
975 | stl->insertItem("Pause"); | ||
976 | sl->insertItem(se->text()); | ||
977 | break; | ||
978 | |||
979 | case ScriptEdit::Hangup: | ||
980 | stl->insertItem("Hangup"); | ||
981 | sl->insertItem(""); | ||
982 | break; | ||
983 | |||
984 | case ScriptEdit::Answer: | ||
985 | stl->insertItem("Answer"); | ||
986 | sl->insertItem(""); | ||
987 | break; | ||
988 | |||
989 | case ScriptEdit::Timeout: | ||
990 | stl->insertItem("Timeout"); | ||
991 | sl->insertItem(se->text()); | ||
992 | break; | ||
993 | |||
994 | case ScriptEdit::Password: | ||
995 | stl->insertItem("Password"); | ||
996 | sl->insertItem(se->text()); | ||
997 | break; | ||
998 | |||
999 | case ScriptEdit::ID: | ||
1000 | stl->insertItem("ID"); | ||
1001 | sl->insertItem(se->text()); | ||
1002 | break; | ||
1003 | |||
1004 | case ScriptEdit::Prompt: | ||
1005 | stl->insertItem("Prompt"); | ||
1006 | sl->insertItem(se->text()); | ||
1007 | break; | ||
1008 | |||
1009 | case ScriptEdit::PWPrompt: | ||
1010 | stl->insertItem("PWPrompt"); | ||
1011 | sl->insertItem(se->text()); | ||
1012 | break; | ||
1013 | |||
1014 | case ScriptEdit::LoopStart: | ||
1015 | stl->insertItem("LoopStart"); | ||
1016 | sl->insertItem(se->text()); | ||
1017 | break; | ||
1018 | |||
1019 | case ScriptEdit::LoopEnd: | ||
1020 | stl->insertItem("LoopEnd"); | ||
1021 | sl->insertItem(se->text()); | ||
1022 | break; | ||
1023 | |||
1024 | case ScriptEdit::Scan: | ||
1025 | stl->insertItem("Scan"); | ||
1026 | sl->insertItem(se->text()); | ||
1027 | break; | ||
1028 | |||
1029 | case ScriptEdit::Save: | ||
1030 | stl->insertItem("Save"); | ||
1031 | sl->insertItem(se->text()); | ||
1032 | break; | ||
1033 | |||
1034 | default: | ||
1035 | break; | ||
1036 | } | ||
1037 | |||
1038 | //get the scrollbar adjusted, and scroll the list so we can see what | ||
1039 | //we're adding to | ||
1040 | adjustScrollBar(); | ||
1041 | slb->setValue(slb->maxValue()); | ||
1042 | |||
1043 | //clear the text in the entry box | ||
1044 | se->setText(""); | ||
1045 | } | ||
1046 | |||
1047 | |||
1048 | void ScriptWidget::insertButton() { | ||
1049 | //exit if there is no highlighted item, or we've reached the | ||
1050 | //maximum entries in the script list | ||
1051 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | ||
1052 | return; | ||
1053 | |||
1054 | switch(se->type()) { | ||
1055 | case ScriptEdit::Expect: | ||
1056 | stl->insertItem("Expect", stl->currentItem()); | ||
1057 | sl->insertItem(se->text(), sl->currentItem()); | ||
1058 | break; | ||
1059 | |||
1060 | case ScriptEdit::Send: | ||
1061 | stl->insertItem("Send", stl->currentItem()); | ||
1062 | sl->insertItem(se->text(), sl->currentItem()); | ||
1063 | break; | ||
1064 | |||
1065 | case ScriptEdit::SendNoEcho: | ||
1066 | stl->insertItem("SendNoEcho", stl->currentItem()); | ||
1067 | sl->insertItem(se->text(), sl->currentItem()); | ||
1068 | break; | ||
1069 | |||
1070 | case ScriptEdit::Pause: | ||
1071 | stl->insertItem("Pause", stl->currentItem()); | ||
1072 | sl->insertItem(se->text(), sl->currentItem()); | ||
1073 | break; | ||
1074 | |||
1075 | case ScriptEdit::Hangup: | ||
1076 | stl->insertItem("Hangup", stl->currentItem()); | ||
1077 | sl->insertItem("", sl->currentItem()); | ||
1078 | break; | ||
1079 | |||
1080 | case ScriptEdit::Answer: | ||
1081 | stl->insertItem("Answer", stl->currentItem()); | ||
1082 | sl->insertItem("", sl->currentItem()); | ||
1083 | break; | ||
1084 | |||
1085 | case ScriptEdit::Timeout: | ||
1086 | stl->insertItem("Timeout", stl->currentItem()); | ||
1087 | sl->insertItem(se->text(), sl->currentItem()); | ||
1088 | break; | ||
1089 | |||
1090 | case ScriptEdit::Password: | ||
1091 | stl->insertItem("Password", stl->currentItem()); | ||
1092 | sl->insertItem(se->text(), sl->currentItem()); | ||
1093 | break; | ||
1094 | |||
1095 | case ScriptEdit::ID: | ||
1096 | stl->insertItem("ID", stl->currentItem()); | ||
1097 | sl->insertItem(se->text(), sl->currentItem()); | ||
1098 | break; | ||
1099 | |||
1100 | case ScriptEdit::Prompt: | ||
1101 | stl->insertItem("Prompt", stl->currentItem()); | ||
1102 | sl->insertItem(se->text(), sl->currentItem()); | ||
1103 | break; | ||
1104 | |||
1105 | case ScriptEdit::PWPrompt: | ||
1106 | stl->insertItem("PWPrompt", stl->currentItem()); | ||
1107 | sl->insertItem(se->text(), sl->currentItem()); | ||
1108 | break; | ||
1109 | |||
1110 | case ScriptEdit::LoopStart: | ||
1111 | stl->insertItem("LoopStart", stl->currentItem()); | ||
1112 | sl->insertItem(se->text(), sl->currentItem()); | ||
1113 | break; | ||
1114 | |||
1115 | case ScriptEdit::LoopEnd: | ||
1116 | stl->insertItem("LoopEnd", stl->currentItem()); | ||
1117 | sl->insertItem(se->text(), sl->currentItem()); | ||
1118 | break; | ||
1119 | |||
1120 | case ScriptEdit::Scan: | ||
1121 | stl->insertItem("Scan", stl->currentItem()); | ||
1122 | sl->insertItem(se->text(), sl->currentItem()); | ||
1123 | break; | ||
1124 | |||
1125 | case ScriptEdit::Save: | ||
1126 | stl->insertItem("Save", stl->currentItem()); | ||
1127 | sl->insertItem(se->text(), sl->currentItem()); | ||
1128 | break; | ||
1129 | |||
1130 | default: | ||
1131 | break; | ||
1132 | } | ||
1133 | adjustScrollBar(); | ||
1134 | se->setText(""); | ||
1135 | } | ||
1136 | |||
1137 | |||
1138 | void ScriptWidget::removeButton() { | ||
1139 | if(sl->currentItem() >= 0) { | ||
1140 | int stlc = stl->currentItem(); | ||
1141 | sl->removeItem(sl->currentItem()); | ||
1142 | stl->removeItem(stlc); | ||
1143 | adjustScrollBar(); | ||
1144 | insert->setEnabled(sl->currentItem() != -1); | ||
1145 | remove->setEnabled(sl->currentItem() != -1); | ||
1146 | } | ||
1147 | } | ||
1148 | |||
1149 | |||
1150 | |||
1151 | ///////////////////////////////////////////////////////////////////////////// | ||
1152 | // | ||
1153 | // Used to specify a new phone number | ||
1154 | // | ||
1155 | ///////////////////////////////////////////////////////////////////////////// | ||
1156 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | ||
1157 | : QDialog(parent, 0, true ) { | ||
1158 | setCaption( i18n("Add Phone Number") ); | ||
1159 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | ||
1160 | |||
1161 | QHBox *hbox = new QHBox(this); | ||
1162 | // setMainWidget(hbox); | ||
1163 | |||
1164 | hbox->setSpacing( 2 );//KDialog::spacingHint()); | ||
1165 | |||
1166 | new QLabel(i18n("Enter a phone number:"), hbox); | ||
1167 | |||
1168 | le = newLineEdit(14, hbox); | ||
1169 | le->setMinimumWidth(125); | ||
1170 | |||
1171 | connect(le, SIGNAL(textChanged(const QString &)), | ||
1172 | this, SLOT(textChanged(const QString &))); | ||
1173 | |||
1174 | le->setFocus(); | ||
1175 | textChanged(""); | ||
1176 | |||
1177 | // enableButtonSeparator(true); | ||
1178 | } | ||
1179 | |||
1180 | |||
1181 | QString PhoneNumberDialog::phoneNumber() { | ||
1182 | QString s = le->text(); | ||
1183 | |||
1184 | return s; | ||
1185 | } | ||
1186 | |||
1187 | |||
1188 | void PhoneNumberDialog::textChanged(const QString &s) { | ||
1189 | // enableButtonOK(s.length() > 0); | ||
1190 | } | ||
1191 | |||
1192 | |||
1193 | //#include "edit.moc" | ||