summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/general.cpp
authortille <tille>2003-05-23 19:43:46 (UTC)
committer tille <tille>2003-05-23 19:43:46 (UTC)
commit9b6b21112f38181f49b07e973bfe00c0d83a6900 (patch) (unidiff)
treec2fa45a93ac5c26fe98558f28bb0a166b14ad065 /noncore/settings/networksettings/ppp/general.cpp
parent34b9974063032242e5de65fa56d4c2cb5e1ce565 (diff)
downloadopie-9b6b21112f38181f49b07e973bfe00c0d83a6900.zip
opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.gz
opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.bz2
configure dialog basicly working
more kppp stuff... ;)
Diffstat (limited to 'noncore/settings/networksettings/ppp/general.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp421
1 files changed, 421 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
new file mode 100644
index 0000000..f803628
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -0,0 +1,421 @@
1/*
2 * kPPP: A pppd front end for the KDE project
3 *
4 * $Id$
5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
8 *
9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter
11 *
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.
16 *
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.
21 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#include <termios.h>
28#include <string.h>
29#include <qwhatsthis.h>
30
31#include "knuminput.h"
32#include <qslider.h>
33#include <qlayout.h>
34#include "general.h"
35//#include "version.h"
36//#include "miniterm.h"
37#include "modeminfo.h"
38#include "modemcmds.h"
39#include "devices.h"
40#include "pppdata.h"
41//#include <klocale.h>
42#define i18n QObject::tr
43
44
45
46ModemWidget::ModemWidget( QWidget *parent, const char *name)
47 : QWidget(parent, name)
48{
49 int k;
50
51 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
52
53 label1 = new QLabel(i18n("Modem de&vice:"), this);
54 tl->addWidget(label1, 0, 0);
55
56 modemdevice = new QComboBox(false, this);
57 label1->setBuddy(modemdevice);
58
59 for(k = 0; devices[k]; k++)
60 modemdevice->insertItem(devices[k]);
61
62 tl->addWidget(modemdevice, 0, 1);
63 connect(modemdevice, SIGNAL(activated(int)),
64 SLOT(setmodemdc(int)));
65 QString tmp = i18n("This specifies the serial port your modem is attached \n"
66 "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
67 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
68 "\n"
69 "If you have an internal ISDN card with AT command\n"
70 "emulation (most cards under Linux support this), you\n"
71 "should select one of the /dev/ttyIx devices.");
72
73 QWhatsThis::add(label1,tmp);
74 QWhatsThis::add(modemdevice,tmp);
75
76
77 label2 = new QLabel(i18n("&Flow control:"), this);
78 tl->addWidget(label2, 1, 0);
79
80 flowcontrol = new QComboBox(false, this);
81 label2->setBuddy(flowcontrol);
82 flowcontrol->insertItem(i18n("Hardware [CRTSCTS]"));
83 flowcontrol->insertItem(i18n("Software [XON/XOFF]"));
84 flowcontrol->insertItem(i18n("None"));
85 tl->addWidget(flowcontrol, 1, 1);
86 connect(flowcontrol, SIGNAL(activated(int)),
87 SLOT(setflowcontrol(int)));
88
89 tmp = i18n("<p>Specifies how the serial port and modem\n"
90 "communicate. You should not change this unless\n"
91 "you know what you are doing.\n"
92 "\n"
93 "<b>Default</b>: CRTSCTS");
94
95 QWhatsThis::add(label2,tmp);
96 QWhatsThis::add(flowcontrol,tmp);
97
98 labelenter = new QLabel(i18n("&Line termination:"), this);
99 tl->addWidget(labelenter, 2, 0);
100
101 enter = new QComboBox(false, this);
102 labelenter->setBuddy(enter);
103 enter->insertItem("CR");
104 enter->insertItem("LF");
105 enter->insertItem("CR/LF");
106 tl->addWidget(enter, 2, 1);
107 connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
108 tmp = i18n("<p>Specifies how AT commands are sent to your\n"
109 "modem. Most modems will work fine with the\n"
110 "default <i>CR/LF</i>. If your modem does not react\n"
111 "to the init string, you should try different\n"
112 "settings here\n"
113 "\n"
114 "<b>Default</b>: CR/LF");
115
116 QWhatsThis::add(labelenter,tmp);
117 QWhatsThis::add(enter, tmp);
118
119 baud_label = new QLabel(i18n("Co&nnection speed:"), this);
120 tl->addWidget(baud_label, 3, 0);
121 baud_c = new QComboBox(this);
122 baud_label->setBuddy(baud_c);
123
124 static const char *baudrates[] = {
125
126#ifdef B460800
127 "460800",
128#endif
129
130#ifdef B230400
131 "230400",
132#endif
133
134#ifdef B115200
135 "115200",
136#endif
137
138#ifdef B57600
139 "57600",
140#endif
141
142 "38400",
143 "19200",
144 "9600",
145 "2400",
146 0};
147
148 for(k = 0; baudrates[k]; k++)
149 baud_c->insertItem(baudrates[k]);
150
151 baud_c->setCurrentItem(3);
152 connect(baud_c, SIGNAL(activated(int)),
153 this, SLOT(speed_selection(int)));
154 tl->addWidget(baud_c, 3, 1);
155
156 tmp = i18n("Specifies the speed your modem and the serial\n"
157 "port talk to each other. You should begin with\n"
158 "the default of 38400 bits/sec. If everything\n"
159 "works you can try to increase this value, but to\n"
160 "no more than 115200 bits/sec (unless you know\n"
161 "that your serial port supports higher speeds).");
162
163 QWhatsThis::add(baud_label,tmp);
164 QWhatsThis::add(baud_c,tmp);
165
166 for(int i=0; i <= enter->count()-1; i++) {
167 if(gpppdata.enter() == enter->text(i))
168 enter->setCurrentItem(i);
169 }
170
171 tl->addRowSpacing(4, 10);
172
173 //Modem Lock File
174 modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
175
176 modemlockfile->setChecked(gpppdata.modemLockFile());
177 connect(modemlockfile, SIGNAL(toggled(bool)),
178 SLOT(modemlockfilechanged(bool)));
179 tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
180 // l12->addStretch(1);
181 QWhatsThis::add(modemlockfile,
182 i18n("<p>To prevent other programs from accessing the\n"
183 "modem while a connection is established, a\n"
184 "file can be created to indicate that the modem\n"
185 "is in use. On Linux an example file would be\n"
186 "<tt>/var/lock/LCK..ttyS1</tt>\n"
187 "Here you can select whether this locking will\n"
188 "be done.\n"
189 "\n"
190 "<b>Default</b>: On"));
191
192 // Modem Timeout Line Edit Box
193
194 modemtimeout = new KIntNumInput(gpppdata.modemTimeout(), this);
195 modemtimeout->setLabel(i18n("Modem &timeout:"));
196 modemtimeout->setRange(1, 120, 1);
197 modemtimeout->setSuffix(i18n(" sec"));
198 connect(modemtimeout, SIGNAL(valueChanged(int)),
199 SLOT(modemtimeoutchanged(int)));
200 tl->addMultiCellWidget(modemtimeout, 6, 6, 0, 1);
201
202 QWhatsThis::add(modemtimeout,
203 i18n("This specifies how long <i>kppp</i> waits for a\n"
204 "<i>CONNECT</i> response from your modem. The\n"
205 "recommended value is 30 seconds."));
206
207 //set stuff from gpppdata
208 for(int i=0; i <= enter->count()-1; i++) {
209 if(gpppdata.enter() == enter->text(i))
210 enter->setCurrentItem(i);
211 }
212
213 for(int i=0; i <= modemdevice->count()-1; i++) {
214 if(gpppdata.modemDevice() == modemdevice->text(i))
215 modemdevice->setCurrentItem(i);
216 }
217
218 for(int i=0; i <= flowcontrol->count()-1; i++) {
219 if(gpppdata.flowcontrol() == flowcontrol->text(i))
220 flowcontrol->setCurrentItem(i);
221 }
222
223 //set the modem speed
224 for(int i=0; i < baud_c->count(); i++)
225 if(baud_c->text(i) == gpppdata.speed())
226 baud_c->setCurrentItem(i);
227
228 tl->setRowStretch(7, 1);
229}
230
231
232void ModemWidget::speed_selection(int) {
233 gpppdata.setSpeed(baud_c->text(baud_c->currentItem()));
234}
235
236
237void ModemWidget::setenter(int ) {
238 gpppdata.setEnter(enter->text(enter->currentItem()));
239}
240
241
242void ModemWidget::setmodemdc(int i) {
243 gpppdata.setModemDevice(modemdevice->text(i));
244}
245
246
247void ModemWidget::setflowcontrol(int i) {
248 gpppdata.setFlowcontrol(flowcontrol->text(i));
249}
250
251
252void ModemWidget::modemlockfilechanged(bool set) {
253 gpppdata.setModemLockFile(set);
254}
255
256
257void ModemWidget::modemtimeoutchanged(int n) {
258 gpppdata.setModemTimeout(n);
259}
260
261
262ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
263 : QWidget(parent, name)
264{
265 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
266
267
268 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
269 waitfordt->setChecked(gpppdata.waitForDialTone());
270 connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
271 l1->addWidget(waitfordt);
272 QWhatsThis::add(waitfordt,
273 i18n("<p>Normally the modem waits for a dial tone\n"
274 "from your phone line, indicating that it can\n"
275 "start to dial a number. If your modem does not\n"
276 "recognize this sound, or your local phone system\n"
277 "does not emit such a tone, uncheck this option\n"
278 "\n"
279 "<b>Default:</b>: On"));
280
281 busywait = new KIntNumInput(gpppdata.busyWait(), this);
282 busywait->setLabel(i18n("B&usy wait:"));
283 busywait->setRange(0, 300, 5, true);
284 busywait->setSuffix(i18n(" sec"));
285 connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
286 l1->addWidget(busywait);
287
288 QWhatsThis::add(busywait,
289 i18n("Specifies the number of seconds to wait before\n"
290 "redial if all dialed numbers are busy. This is\n"
291 "necessary because some modems get stuck if the\n"
292 "same number is busy too often.\n"
293 "\n"
294 "The default is 0 seconds, you should not change\n"
295 "this unless you need to."));
296
297 l1->addSpacing(10);
298
299 QHBoxLayout *hbl = new QHBoxLayout;
300 hbl->setSpacing(2);//KDialog::spacingHint());
301
302 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
303 hbl->addWidget(volumeLabel);
304 volume = new QSlider(0, 2, 1, gpppdata.volume(), QSlider::Horizontal, this);
305 volumeLabel->setBuddy(volume);
306 volume->setTickmarks(QSlider::Below);
307 hbl->addWidget(volume);
308
309 l1->addLayout(hbl);
310
311 connect(volume, SIGNAL(valueChanged(int)),
312 this, SLOT(volumeChanged(int)));
313 QString tmp = i18n("Most modems have a speaker which makes\n"
314 "a lot of noise when dialing. Here you can\n"
315 "either turn this completely off or select a\n"
316 "lower volume.\n"
317 "\n"
318 "If this does not work for your modem,\n"
319 "you must modify the modem volume command.");
320
321 QWhatsThis::add(volumeLabel,tmp);
322 QWhatsThis::add(volume, tmp);
323
324 l1->addSpacing(20);
325
326#if 0
327 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
328 chkbox1->setChecked(gpppdata.UseCDLine());
329 connect(chkbox1,SIGNAL(toggled(bool)),
330 this,SLOT(use_cdline_toggled(bool)));
331 l12->addWidget(chkbox1);
332 l12->addStretch(1);
333 l1->addStretch(1);
334 QWhatsThis::add(chkbox1,
335 i18n("This controls how <i>kppp</i> detects that the modem\n"
336 "is not responding. Unless you are having\n"
337 "problems with this, do not modify this setting.\n"
338 "\n"
339 "<b>Default</b>: Off"));
340#endif
341
342 modemcmds = new QPushButton(i18n("Mod&em Commands..."), this);
343 QWhatsThis::add(modemcmds,
344 i18n("Allows you to change the AT command for\n"
345 "your modem."));
346
347 modeminfo_button = new QPushButton(i18n("&Query Modem..."), this);
348 QWhatsThis::add(modeminfo_button,
349 i18n("Most modems support the ATI command set to\n"
350 "find out vendor and revision of your modem.\n"
351 "\n"
352 "Press this button to query your modem for\n"
353 "this information. It can be useful to help\n"
354 "you setup the modem"));
355
356// terminal_button = new QPushButton(i18n("&Terminal..."), this);
357// QWhatsThis::add(terminal_button,
358 // i18n("Opens the built-in terminal program. You\n"
359 // "can use this if you want to play around\n"
360 // "with your modem's AT command set"));
361
362 QHBoxLayout *hbox = new QHBoxLayout();
363 l1->addLayout(hbox);
364 hbox->addStretch(1);
365 QVBoxLayout *vbox = new QVBoxLayout();
366 hbox->addLayout(vbox);
367
368 vbox->addWidget(modemcmds);
369 vbox->addWidget(modeminfo_button);
370// vbox->addWidget(terminal_button);
371
372 hbox->addStretch(1);
373 l1->addStretch(1);
374
375 connect(modemcmds, SIGNAL(clicked()),
376 SLOT(modemcmdsbutton()));
377 connect(modeminfo_button, SIGNAL(clicked()),
378 SLOT(query_modem()));
379// connect(terminal_button, SIGNAL(clicked()),
380 // SLOT(terminal()));
381}
382
383
384void ModemWidget2::modemcmdsbutton() {
385 ModemCommands mc(this);
386 mc.showMaximized();
387 mc.exec();
388}
389
390
391void ModemWidget2::query_modem() {
392 ModemTransfer mt(this);
393 mt.exec();
394}
395
396
397// void ModemWidget2::terminal() {
398// MiniTerm terminal(NULL,NULL);
399// terminal.exec();
400// }
401
402
403#if 0
404void ModemWidget2::use_cdline_toggled(bool on) {
405 gpppdata.setUseCDLine(on);
406}
407#endif
408
409void ModemWidget2::waitfordtchanged(bool b) {
410 gpppdata.setWaitForDialTone((int)b);
411}
412
413void ModemWidget2::busywaitchanged(int n) {
414 gpppdata.setbusyWait(n);
415}
416
417
418void ModemWidget2::volumeChanged(int v) {
419 gpppdata.setVolume(v);
420}
421