2 * kPPP: A pppd front end for the KDE project
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
10 * Copyright (C) 1997 Jay Painter
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 #include <QVBoxLayout>
34 #include <QHBoxLayout>
35 #include <QGridLayout>
37 #include <knuminput.h>
42 #include "modeminfo.h"
43 #include "modemcmds.h"
50 /////////////////////////////////////////////////////////////////////////////
52 // Widget containing misc. configuration options
54 /////////////////////////////////////////////////////////////////////////////
55 GeneralWidget::GeneralWidget( QWidget
*parent
, const char *name
)
60 QVBoxLayout
*tl
= new QVBoxLayout(parent
);
61 tl
->setSpacing(KDialog::spacingHint());
64 QHBoxLayout
*hbox
= new QHBoxLayout();
67 label
= new QLabel(i18n("pppd version:"), parent
);
68 hbox
->addWidget(label
);
69 QString version
= gpppdata
.pppdVersion();
70 if(version
== "0.0.0")
72 label
= new QLabel(version
, parent
);
73 label
->setFrameStyle(QFrame::StyledPanel
| QFrame::Sunken
);
74 hbox
->addWidget(label
);
76 KIntNumInput
*pppdTimeout
= new KIntNumInput(gpppdata
.pppdTimeout(), parent
);
77 pppdTimeout
->setLabel(i18n("pppd &timeout:"));
78 pppdTimeout
->setRange(1, TIMEOUT_SIZE
, 5);
79 pppdTimeout
->setSliderEnabled(true);
80 pppdTimeout
->setSuffix(i18n(" sec"));
81 connect(pppdTimeout
, SIGNAL(valueChanged(int)),
82 SLOT(pppdtimeoutchanged(int)));
83 tl
->addWidget(pppdTimeout
);
84 QString tmp
= i18n("<i>kppp</i> will wait this number of seconds\n"
85 "to see if a PPP connection is established.\n"
86 "If no connection is made in this time frame,\n"
87 "<i>kppp</i> will give up and kill pppd.");
88 pppdTimeout
->setWhatsThis(tmp
);
93 chkBox
= new QCheckBox(i18n("Doc&k into panel on connect"), parent
);
95 i18n("<p>After a connection is established, the\n"
96 "window is minimized and a small icon\n"
97 "in the KDE panel represents this window.\n"
99 "Clicking on this icon will restore the\n"
100 "window to its original location and\n"
103 chkBox
->setChecked(gpppdata
.get_dock_into_panel());
104 connect(chkBox
,SIGNAL(toggled(bool)),
105 this, SLOT(docking_toggled(bool)));
106 tl
->addWidget(chkBox
);
108 chkBox
= new QCheckBox(i18n("A&utomatic redial on disconnect"), parent
);
109 chkBox
->setChecked(gpppdata
.automatic_redial());
110 connect(chkBox
,SIGNAL(toggled(bool)),
111 this, SLOT(redial_toggled(bool)));
112 tl
->addWidget(chkBox
);
113 chkBox
->setWhatsThis(
114 i18n("<p>When a connection is established and\n"
115 "it somehow gets disconnected, <i>kppp</i>\n"
116 "will try to reconnect to the same account.\n"
118 "See <a href=\"#redial\">here</a> for more on this topic."));
120 chkBox
= new QCheckBox(i18n("Automatic redial on NO &CARRIER"), parent
);
121 chkBox
->setChecked(gpppdata
.get_redial_on_nocarrier());
122 connect(chkBox
,SIGNAL(toggled(bool)),
123 this, SLOT(nocarrier_toggled(bool)));
124 tl
->addWidget(chkBox
);
125 chkBox
->setWhatsThis(
126 i18n("<p>When dialing if modem returns NO CARRIER\n"
127 "the program will make a new attempt to redial\n"
128 "instead of waiting for user to click <CANCEL>\n"
131 chkBox
= new QCheckBox(i18n("&Show clock on caption"), parent
);
132 chkBox
->setChecked(gpppdata
.get_show_clock_on_caption());
133 connect(chkBox
, SIGNAL(toggled(bool)),
134 this, SLOT(caption_toggled(bool)));
135 tl
->addWidget(chkBox
);
136 chkBox
->setWhatsThis(
137 i18n("When this option is checked, the window\n"
138 "title shows the time since a connection\n"
139 "was established. Very useful, so you \n"
140 "should turn this on"));
142 chkBox
= new QCheckBox(i18n("Disco&nnect on X server shutdown"), parent
);
143 chkBox
->setChecked(gpppdata
.get_xserver_exit_disconnect());
144 connect(chkBox
, SIGNAL(toggled(bool)),
145 this, SLOT(xserver_toggled(bool)));
146 tl
->addWidget(chkBox
);
147 chkBox
->setWhatsThis(
148 i18n("<p>Checking this option will close any\n"
149 "open connection when the X-server is\n"
150 "shut down. You should enable this option\n"
151 "unless you know what you are doing.\n"
153 "See <a href=\"#disxserver\">here</a> for more on this."));
155 chkBox
= new QCheckBox(i18n("&Quit on disconnect"), parent
);
156 chkBox
->setChecked(gpppdata
.quit_on_disconnect());
157 connect(chkBox
, SIGNAL(toggled(bool)),
158 this, SLOT(quit_toggled(bool)));
159 tl
->addWidget(chkBox
);
160 chkBox
->setWhatsThis(
161 i18n("When this option is turned on, <i>kppp</i>\n"
162 "will be closed when you disconnect"));
164 chkBox
= new QCheckBox(i18n("Minimi&ze window on connect"), parent
);
165 chkBox
->setChecked(gpppdata
.get_iconify_on_connect());
166 connect(chkBox
,SIGNAL(toggled(bool)),
167 this,SLOT(iconify_toggled(bool)));
168 tl
->addWidget(chkBox
);
169 chkBox
->setWhatsThis(
170 i18n("Iconifies <i>kppp</i>'s window when a\n"
171 "connection is established"));
178 void GeneralWidget::docking_toggled(bool on
){
179 gpppdata
.set_dock_into_panel(on
);
183 void GeneralWidget::iconify_toggled(bool on
){
184 gpppdata
.set_iconify_on_connect(on
);
188 void GeneralWidget::caption_toggled(bool on
){
189 gpppdata
.set_show_clock_on_caption(on
);
193 void GeneralWidget::redial_toggled(bool on
){
194 gpppdata
.set_automatic_redial(on
);
197 void GeneralWidget::nocarrier_toggled(bool on
){
198 gpppdata
.set_redial_on_nocarrier(on
);
201 void GeneralWidget::xserver_toggled(bool on
){
202 gpppdata
.set_xserver_exit_disconnect(on
);
206 void GeneralWidget::quit_toggled(bool on
){
207 gpppdata
.set_quit_on_disconnect(on
);
211 void GeneralWidget::pppdtimeoutchanged(int n
) {
212 gpppdata
.setpppdTimeout(n
);
217 ModemWidget::ModemWidget(QWidget
*parent
, bool isnewmodem
)
220 QVBoxLayout
*topLayout
= new QVBoxLayout(parent
);
221 topLayout
->setSpacing(KDialog::spacingHint());
222 topLayout
->setMargin(0);
223 topLayout
->addWidget(this);
225 QGridLayout
*tl
= new QGridLayout(this );
226 tl
->setSpacing( KDialog::spacingHint() );
228 connect_label
= new QLabel(i18n("Modem &name:"), this);
229 tl
->addWidget(connect_label
, 0, 0);
231 connectname_l
= new QLineEdit(this);
232 connectname_l
->setMaxLength(ACCNAME_SIZE
);
233 connect_label
->setBuddy(connectname_l
);
235 tl
->addWidget(connectname_l
, 0, 1);
236 QString tmp
= i18n("Type in a unique name for this modem");
238 connect_label
->setWhatsThis(tmp
);
239 connectname_l
->setWhatsThis(tmp
);
241 label1
= new QLabel(i18n("Modem de&vice:"), this);
242 tl
->addWidget(label1
, 1, 0);
244 modemdevice
= new QComboBox(this);
245 modemdevice
->setEditable( false );
246 label1
->setBuddy(modemdevice
);
247 // ### deviceExist mechanism not functional right now
248 bool deviceExist
= false;
249 for(int k
= 0; devices
[k
]; k
++)
251 if ( devices
[k
] == gpppdata
.modemDevice())
253 modemdevice
->addItem(devices
[k
]);
256 modemdevice
->addItem(gpppdata
.modemDevice());
258 tl
->addWidget(modemdevice
, 1, 1);
259 /* connect(modemdevice, SIGNAL(activated(int)),
260 SLOT(setmodemdc(int)));*/
261 tmp
= i18n("This specifies the serial port your modem is attached \n"
262 "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
263 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
265 "If you have an internal ISDN card with AT command\n"
266 "emulation (most cards under Linux support this), you\n"
267 "should select one of the /dev/ttyIx devices.");
269 label1
->setWhatsThis(tmp
);
270 modemdevice
->setWhatsThis(tmp
);
273 label2
= new QLabel(i18n("&Flow control:"), this);
274 tl
->addWidget(label2
, 2, 0);
276 flowcontrol
= new QComboBox(this);
277 flowcontrol
->setEditable( false );
278 label2
->setBuddy(flowcontrol
);
279 flowcontrol
->addItem(i18n("Hardware [CRTSCTS]")); // sync with pppdata.cpp
280 flowcontrol
->addItem(i18n("Software [XON/XOFF]"));
281 flowcontrol
->addItem(i18n("None"));
283 flowListItem
<< "Hardware [CRTSCTS]";
284 flowListItem
<< "Software [XON/XOFF]";
285 flowListItem
<< "None";
287 tl
->addWidget(flowcontrol
, 2, 1);
288 /*connect(flowcontrol, SIGNAL(activated(int)),
289 SLOT(setflowcontrol(int)));*/
291 tmp
= i18n("<p>Specifies how the serial port and modem\n"
292 "communicate. You should not change this unless\n"
293 "you know what you are doing.\n"
295 "<b>Default</b>: CRTSCTS");
297 label2
->setWhatsThis(tmp
);
298 flowcontrol
->setWhatsThis(tmp
);
300 labelenter
= new QLabel(i18n("&Line termination:"), this);
301 tl
->addWidget(labelenter
, 3, 0);
303 enter
= new QComboBox(this);
304 enter
->setEditable( false );
305 labelenter
->setBuddy(enter
);
306 enter
->addItem("CR");
307 enter
->addItem("LF");
308 enter
->addItem("CR/LF");
309 tl
->addWidget(enter
, 3, 1);
310 /* connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));*/
311 tmp
= i18n("<p>Specifies how AT commands are sent to your\n"
312 "modem. Most modems will work fine with the\n"
313 "default <i>CR/LF</i>. If your modem does not react\n"
314 "to the init string, you should try different\n"
317 "<b>Default</b>: CR/LF");
319 labelenter
->setWhatsThis(tmp
);
320 enter
->setWhatsThis( tmp
);
322 baud_label
= new QLabel(i18n("Co&nnection speed:"), this);
323 tl
->addWidget(baud_label
, 4, 0);
324 baud_c
= new QComboBox(this);
325 baud_label
->setBuddy(baud_c
);
327 static const char *baudrates
[] = {
353 for(int k
= 0; baudrates
[k
]; k
++)
354 baud_c
->addItem(baudrates
[k
]);
356 baud_c
->setCurrentIndex(3);
357 /*connect(baud_c, SIGNAL(activated(int)),
358 this, SLOT(speed_selection(int)));*/
359 tl
->addWidget(baud_c
, 4, 1);
361 tmp
= i18n("Specifies the speed your modem and the serial\n"
362 "port talk to each other. You should begin with\n"
363 "at least 115200 bits/sec (or more if you know\n"
364 "that your serial port supports higher speeds).\n"
365 "If you have connection problems, try to reduce\n"
368 baud_label
->setWhatsThis(tmp
);
369 baud_c
->setWhatsThis(tmp
);
371 for(int i
=0; i
<= enter
->count()-1; i
++) {
372 if(gpppdata
.enter() == enter
->itemText(i
))
373 enter
->setCurrentIndex(i
);
376 tl
->addItem(new QSpacerItem(0, 10), 4, 0);
379 modemlockfile
= new QCheckBox(i18n("&Use lock file"), this);
381 modemlockfile
->setChecked(gpppdata
.modemLockFile());
382 /* connect(modemlockfile, SIGNAL(toggled(bool)),
383 SLOT(modemlockfilechanged(bool)));*/
384 tl
->addWidget(modemlockfile
, 5, 0, 1, 2);
385 // l12->addStretch(1);
386 modemlockfile
->setWhatsThis(
387 i18n("<p>To prevent other programs from accessing the\n"
388 "modem while a connection is established, a\n"
389 "file can be created to indicate that the modem\n"
390 "is in use. On Linux an example file would be\n"
391 "<tt>/var/lock/LCK..ttyS1</tt>\n"
392 "Here you can select whether this locking will\n"
395 "<b>Default</b>: On"));
397 // Modem Timeout Line Edit Box
399 modemtimeout
= new KIntNumInput(gpppdata
.modemTimeout(), this);
400 modemtimeout
->setLabel(i18n("Modem &timeout:"));
401 modemtimeout
->setRange(1, 120, 1);
402 modemtimeout
->setSuffix(i18n(" sec"));
403 /* connect(modemtimeout, SIGNAL(valueChanged(int)),
404 SLOT(modemtimeoutchanged(int)));*/
405 tl
->addWidget(modemtimeout
, 6, 0, 1, 2);
407 modemtimeout
->setWhatsThis(
408 i18n("This specifies how long <i>kppp</i> waits for a\n"
409 "<i>CONNECT</i> response from your modem. The\n"
410 "recommended value is 30 seconds."));
412 // Set defaults if editing an existing connection
414 connectname_l
->setText(gpppdata
.modname());
416 //set stuff from gpppdata
417 for(int i
=0; i
<= enter
->count()-1; i
++) {
418 if(gpppdata
.enter() == enter
->itemText(i
))
419 enter
->setCurrentIndex(i
);
422 for(int i
=0; i
<= modemdevice
->count()-1; i
++) {
423 if(gpppdata
.modemDevice() == modemdevice
->itemText(i
))
424 modemdevice
->setCurrentIndex(i
);
427 for(int i
=0; i
<= flowcontrol
->count()-1; i
++)
428 if(gpppdata
.flowcontrol() == flowListItem
[i
])
429 flowcontrol
->setCurrentIndex(i
);
431 //set the modem speed
432 for(int i
=0; i
< baud_c
->count(); i
++)
433 if(baud_c
->itemText(i
) == gpppdata
.speed())
434 baud_c
->setCurrentIndex(i
);
437 //Set the standard Items
438 enter
->setCurrentIndex(0);
439 modemdevice
->setCurrentIndex(0);
440 flowcontrol
->setCurrentIndex(0);
441 baud_c
->setCurrentIndex(0);
444 tl
->setRowStretch(7, 1);
447 bool ModemWidget::save()
449 //first check to make sure that the modem name is unique!
450 if(connectname_l
->text().isEmpty() ||
451 !gpppdata
.isUniqueModname(connectname_l
->text())) {
454 gpppdata
.setModname(connectname_l
->text());
455 gpppdata
.setSpeed(baud_c
->itemText(baud_c
->currentIndex()));
456 gpppdata
.setEnter(enter
->itemText(enter
->currentIndex()));
457 gpppdata
.setModemDevice(modemdevice
->itemText(modemdevice
->currentIndex()));
458 gpppdata
.setFlowcontrol(flowListItem
[flowcontrol
->currentIndex()]);
459 gpppdata
.setModemLockFile(modemlockfile
->isChecked());
460 gpppdata
.setModemTimeout(modemtimeout
->value());
466 ModemWidget2::ModemWidget2(QWidget
*parent
, const char *name
)
471 QVBoxLayout
*topLayout
= new QVBoxLayout(parent
);
472 topLayout
->setSpacing(KDialog::spacingHint());
473 topLayout
->setMargin(0);
474 topLayout
->addWidget(this);
476 QVBoxLayout
*l1
= new QVBoxLayout(this);
477 l1
->setSpacing(KDialog::spacingHint());
481 waitfordt
= new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
482 waitfordt
->setChecked(gpppdata
.waitForDialTone());
483 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
484 l1
->addWidget(waitfordt
);
485 waitfordt
->setWhatsThis(
486 i18n("<p>Normally the modem waits for a dial tone\n"
487 "from your phone line, indicating that it can\n"
488 "start to dial a number. If your modem does not\n"
489 "recognize this sound, or your local phone system\n"
490 "does not emit such a tone, uncheck this option\n"
492 "<b>Default:</b>: On"));
494 busywait
= new KIntNumInput(gpppdata
.busyWait(), this);
495 busywait
->setLabel(i18n("B&usy wait:"));
496 busywait
->setRange(0, 300, 5);
497 busywait
->setSliderEnabled(true);
498 busywait
->setSuffix(i18n(" sec"));
499 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
500 l1
->addWidget(busywait
);
502 busywait
->setWhatsThis(
503 i18n("Specifies the number of seconds to wait before\n"
504 "redial if all dialed numbers are busy. This is\n"
505 "necessary because some modems get stuck if the\n"
506 "same number is busy too often.\n"
508 "The default is 0 seconds, you should not change\n"
509 "this unless you need to."));
513 QHBoxLayout
*hbl
= new QHBoxLayout
;
514 hbl
->setSpacing(KDialog::spacingHint());
516 QLabel
*volumeLabel
= new QLabel(i18n("Modem &volume:"), this);
517 hbl
->addWidget(volumeLabel
);
518 volume
= new QSlider(Qt::Horizontal
, this);
519 volume
->setMinimum(0);
520 volume
->setMaximum(2);
521 volume
->setPageStep(1);
522 volume
->setValue(gpppdata
.volume());
523 volumeLabel
->setBuddy(volume
);
524 volume
->setTickPosition(QSlider::TicksBelow
);
525 hbl
->addWidget(volume
);
529 /* connect(volume, SIGNAL(valueChanged(int)),
530 this, SLOT(volumeChanged(int)));*/
531 QString tmp
= i18n("Most modems have a speaker which makes\n"
532 "a lot of noise when dialing. Here you can\n"
533 "either turn this completely off or select a\n"
536 "If this does not work for your modem,\n"
537 "you must modify the modem volume command.");
539 volumeLabel
->setWhatsThis(tmp
);
540 volume
->setWhatsThis( tmp
);
545 chkbox1
= new QCheckBox(i18n("Modem asserts CD line"), this);
546 chkbox1
->setChecked(gpppdata
.UseCDLine());
547 connect(chkbox1
,SIGNAL(toggled(bool)),
548 this,SLOT(use_cdline_toggled(bool)));
549 l12
->addWidget(chkbox1
);
552 chkbox1
->setWhatsThis(
553 i18n("This controls how <i>kppp</i> detects that the modem\n"
554 "is not responding. Unless you are having\n"
555 "problems with this, do not modify this setting.\n"
557 "<b>Default</b>: Off"));
560 modemcmds
= new QPushButton(i18n("Mod&em Commands..."), this);
561 modemcmds
->setWhatsThis(
562 i18n("Allows you to change the AT command for\n"
565 modeminfo_button
= new QPushButton(i18n("&Query Modem..."), this);
566 modeminfo_button
->setWhatsThis(
567 i18n("Most modems support the ATI command set to\n"
568 "find out vendor and revision of your modem.\n"
570 "Press this button to query your modem for\n"
571 "this information. It can be useful to help\n"
572 "you set up the modem"));
574 terminal_button
= new QPushButton(i18n("&Terminal..."), this);
575 terminal_button
->setWhatsThis(
576 i18n("Opens the built-in terminal program. You\n"
577 "can use this if you want to play around\n"
578 "with your modem's AT command set"));
580 QHBoxLayout
*hbox
= new QHBoxLayout();
583 QVBoxLayout
*vbox
= new QVBoxLayout();
584 hbox
->addLayout(vbox
);
586 vbox
->addWidget(modemcmds
);
587 vbox
->addWidget(modeminfo_button
);
588 vbox
->addWidget(terminal_button
);
593 connect(modemcmds
, SIGNAL(clicked()),
594 SLOT(modemcmdsbutton()));
595 connect(modeminfo_button
, SIGNAL(clicked()),
596 SLOT(query_modem()));
597 connect(terminal_button
, SIGNAL(clicked()),
600 // Create the Modem Command so if the window is not opened they are autosaved anyway
601 mc
= new ModemCommands(this);
605 void ModemWidget2::modemcmdsbutton() {
610 void ModemWidget2::query_modem() {
611 ModemTransfer
mt(this);
616 void ModemWidget2::terminal() {
617 MiniTerm
terminal(NULL
,NULL
);
623 void ModemWidget2::use_cdline_toggled(bool on
) {
624 gpppdata
.setUseCDLine(on
);
628 bool ModemWidget2::save()
630 gpppdata
.setWaitForDialTone(waitfordt
->isChecked());
631 gpppdata
.setbusyWait(busywait
->value());
632 gpppdata
.setVolume(volume
->value());
637 /////////////////////////////////////////////////////////////////////////////
639 // Setup widget for the graph
641 /////////////////////////////////////////////////////////////////////////////
642 GraphSetup::GraphSetup(QWidget
*parent
) :
645 QVBoxLayout
*tl
= new QVBoxLayout(this);
648 QColor bg
, text
, in
, out
;
649 gpppdata
.graphingOptions(enable
, bg
, text
, in
, out
);
651 enable_check
= new QCheckBox(i18n("&Enable throughput graph"), this);
652 tl
->addWidget(enable_check
);
654 grpColor
= new Q3GroupBox(2, Qt::Horizontal
,
655 i18n("Graph Colors"), this);
656 tl
->addWidget(grpColor
);
660 label
= new QLabel(i18n("Bac&kground:"), grpColor
);
661 bg_color
= new KColorButton( bg
, grpColor
);
662 bg_color
->setFixedSize(80, 24);
663 label
->setBuddy(bg_color
);
665 label
= new QLabel(i18n("&Text:"), grpColor
);
666 text_color
= new KColorButton( text
,grpColor
);
667 text_color
->setFixedSize(80, 24);
668 label
->setBuddy(text_color
);
670 label
= new QLabel(i18n("I&nput bytes:"), grpColor
);
671 in_color
= new KColorButton( in
,grpColor
);
672 in_color
->setFixedSize(80, 24);
673 label
->setBuddy(in_color
);
675 label
= new QLabel(i18n("O&utput bytes:"), grpColor
);
676 out_color
= new KColorButton( out
, grpColor
);
677 out_color
->setFixedSize(80, 24);
678 label
->setBuddy(out_color
);
682 connect(enable_check
, SIGNAL(toggled(bool)), this, SLOT(enableToggled(bool)));
683 connect(bg_color
, SIGNAL(changed(const QColor
&)),
684 SLOT(colorChanged(const QColor
&)));
685 connect(text_color
, SIGNAL(changed(const QColor
&)),
686 SLOT(colorChanged(const QColor
&)));
687 connect(in_color
, SIGNAL(changed(const QColor
&)),
688 SLOT(colorChanged(const QColor
&)));
689 connect(out_color
, SIGNAL(changed(const QColor
&)),
690 SLOT(colorChanged(const QColor
&)));
694 enable_check
->setChecked(enable
);
695 enableToggled(enable
);
698 void GraphSetup::enableToggled(bool b
) {
699 grpColor
->setEnabled(b
);
704 void GraphSetup::colorChanged(const QColor
&) {
708 void GraphSetup::save() {
709 gpppdata
.setGraphingOptions(enable_check
->isChecked(),
716 #include "general.moc"