summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/main.cpp26
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp491
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h110
-rw-r--r--noncore/settings/networksettings/ppp/auth.h36
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp1438
-rw-r--r--noncore/settings/networksettings/ppp/connect.h152
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp341
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.h96
-rw-r--r--noncore/settings/networksettings/ppp/debug.cpp141
-rw-r--r--noncore/settings/networksettings/ppp/debug.h70
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp1193
-rw-r--r--noncore/settings/networksettings/ppp/edit.h251
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp421
-rw-r--r--noncore/settings/networksettings/ppp/general.h100
-rw-r--r--noncore/settings/networksettings/ppp/iplined.cpp42
-rw-r--r--noncore/settings/networksettings/ppp/iplined.h40
-rw-r--r--noncore/settings/networksettings/ppp/knuminput.cpp1103
-rw-r--r--noncore/settings/networksettings/ppp/knuminput.h947
-rw-r--r--noncore/settings/networksettings/ppp/knumvalidator.cpp376
-rw-r--r--noncore/settings/networksettings/ppp/knumvalidator.h211
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp905
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.h157
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp192
-rw-r--r--noncore/settings/networksettings/ppp/modem.h15
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp321
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.h119
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp1
-rw-r--r--noncore/settings/networksettings/ppp/newwidget.cpp17
-rw-r--r--noncore/settings/networksettings/ppp/newwidget.h19
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro7
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp62
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h34
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp166
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.h76
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp13
-rw-r--r--noncore/settings/networksettings/ppp/pwentry.cpp116
-rw-r--r--noncore/settings/networksettings/ppp/pwentry.h72
-rw-r--r--noncore/settings/networksettings/ppp/scriptedit.cpp174
-rw-r--r--noncore/settings/networksettings/ppp/scriptedit.h79
39 files changed, 10083 insertions, 47 deletions
diff --git a/noncore/settings/networksettings/main.cpp b/noncore/settings/networksettings/main.cpp
index a9d1a87..1b74d62 100644
--- a/noncore/settings/networksettings/main.cpp
+++ b/noncore/settings/networksettings/main.cpp
@@ -1,13 +1,13 @@
-#include "mainwindowimp.h"
-#include <qpe/qpeapplication.h>
-
-int main(int argc, char **argv)
-{
- QPEApplication app(argc, argv);
- MainWindowImp window;
- app.showMainWidget(&window);
- return app.exec();
-}
-
-// main.cpp
-
+#include "mainwindowimp.h"
+#include <qpe/qpeapplication.h>
+
+int main(int argc, char **argv)
+{
+ QPEApplication app(argc, argv);
+ MainWindowImp window;
+ app.showMainWidget(&window);
+ return app.exec();
+}
+
+// main.cpp
+
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
new file mode 100644
index 0000000..d902517
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -0,0 +1,491 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qdir.h>
+#include <stdlib.h>
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qtabdialog.h>
+#include <qwhatsthis.h>
+#include <qmessagebox.h>
+
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qmessagebox.h>
+//#include <klocale.h>
+#define i18n QObject::tr
+//#include <kglobal.h>
+//#include <kwin.h>
+//#include <kdialogbase.h>
+#include <qvgroupbox.h>
+
+#include "pppdata.h"
+#include "accounts.h"
+//#include "accounting.h"
+//#include "providerdb.h"
+#include "edit.h"
+
+void parseargs(char* buf, char** args);
+
+AccountWidget::AccountWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ int min = 0;
+ QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
+
+ // add a hbox
+// QHBoxLayout *l11 = new QHBoxLayout;
+// l1->addLayout(l11);
+
+ accountlist_l = new QListBox(this);
+ accountlist_l->setMinimumSize(160, 128);
+ connect(accountlist_l, SIGNAL(highlighted(int)),
+ this, SLOT(slotListBoxSelect(int)));
+ connect(accountlist_l, SIGNAL(selected(int)),
+ this, SLOT(editaccount()));
+ l1->addWidget(accountlist_l, 10);
+
+// QVBoxLayout *l111 = new QVBoxLayout(this);
+// l11->addLayout(l111, 1);
+ edit_b = new QPushButton(i18n("&Edit..."), this);
+ connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
+ QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
+
+ min = edit_b->sizeHint().width();
+ min = QMAX(70,min);
+ edit_b->setMinimumWidth(min);
+
+ l1->addWidget(edit_b);
+
+ new_b = new QPushButton(i18n("&New..."), this);
+ connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
+ l1->addWidget(new_b);
+ QWhatsThis::add(new_b, i18n("Create a new dialup connection\n"
+ "to the Internet"));
+
+ copy_b = new QPushButton(i18n("Co&py"), this);
+ connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
+ l1->addWidget(copy_b);
+ QWhatsThis::add(copy_b,
+ i18n("Makes a copy of the selected account. All\n"
+ "settings of the selected account are copied\n"
+ "to a new account, that you can modify to fit your\n"
+ "needs"));
+
+ delete_b = new QPushButton(i18n("De&lete"), this);
+ connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
+ l1->addWidget(delete_b);
+ QWhatsThis::add(delete_b,
+ i18n("<p>Deletes the selected account\n\n"
+ "<font color=\"red\"><b>Use with care!</b></font>"));
+
+ QHBoxLayout *l12 = new QHBoxLayout;
+ l1->addStretch(1);
+ l1->addLayout(l12);
+
+// QVBoxLayout *l121 = new QVBoxLayout;
+// l12->addLayout(l121);
+// l121->addStretch(1);
+ // costlabel = new QLabel(i18n("Phone costs:"), parent);
+// costlabel->setEnabled(FALSE);
+// l121->addWidget(costlabel);
+
+// costedit = new QLineEdit(parent);
+// costedit->setFocusPolicy(QWidget::NoFocus);
+// costedit->setFixedHeight(costedit->sizeHint().height());
+// costedit->setEnabled(FALSE);
+// l121->addWidget(costedit);
+// l121->addStretch(1);
+// QString tmp = i18n("<p>This shows the accumulated phone costs\n"
+// "for the selected account.\n"
+// "\n"
+// "<b>Important</b>: If you have more than one \n"
+// "account - beware, this is <b>NOT</b> the sum \n"
+// "of the phone costs of all your accounts!");
+// QWhatsThis::add(costlabel, tmp);
+// QWhatsThis::add(costedit, tmp);
+
+// vollabel = new QLabel(i18n("Volume:"), parent);
+// vollabel->setEnabled(FALSE);
+// l121->addWidget(vollabel);
+
+// voledit = new QLineEdit(parent,"voledit");
+// voledit->setFocusPolicy(QWidget::NoFocus);
+// voledit->setFixedHeight(voledit->sizeHint().height());
+// voledit->setEnabled(FALSE);
+// l121->addWidget(voledit);
+// tmp = i18n("<p>This shows the number of bytes transferred\n"
+// "for the selected account (not for all of your\n"
+// "accounts. You can select what to display in\n"
+// "the accounting dialog.\n"
+// "\n"
+// "<a href=\"#volaccounting\">More on volume accounting</a>");
+
+// QWhatsThis::add(vollabel,tmp);
+// QWhatsThis::add(voledit, tmp);
+
+// QVBoxLayout *l122 = new QVBoxLayout;
+// l12->addStretch(1);
+// l12->addLayout(l122);
+
+// l122->addStretch(1);
+// reset = new QPushButton(i18n("&Reset..."), parent);
+// reset->setEnabled(FALSE);
+// connect(reset, SIGNAL(clicked()),
+// this, SLOT(resetClicked()));
+// l122->addWidget(reset);
+
+// log = new QPushButton(i18n("&View Logs"), this);
+// connect(log, SIGNAL(clicked()),
+// this, SLOT(viewLogClicked()));
+// l122->addWidget(log);
+// l122->addStretch(1);
+
+ //load up account list from gppdata to the list box
+ if(gpppdata.count() > 0) {
+ for(int i=0; i <= gpppdata.count()-1; i++) {
+ gpppdata.setAccountbyIndex(i);
+ accountlist_l->insertItem(gpppdata.accname());
+ }
+ }
+
+ slotListBoxSelect(accountlist_l->currentItem());
+
+ l1->activate();
+}
+
+
+
+void AccountWidget::slotListBoxSelect(int idx) {
+ delete_b->setEnabled((bool)(idx != -1));
+ edit_b->setEnabled((bool)(idx != -1));
+ copy_b->setEnabled((bool)(idx != -1));
+ if(idx!=-1) {
+ QString account = gpppdata.accname();
+ gpppdata.setAccountbyIndex(accountlist_l->currentItem());
+// reset->setEnabled(TRUE);
+// costlabel->setEnabled(TRUE);
+// costedit->setEnabled(TRUE);
+// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem())));
+
+// vollabel->setEnabled(TRUE);
+// voledit->setEnabled(TRUE);
+ int bytes = gpppdata.totalBytes();
+// voledit->setText(prettyPrintVolume(bytes));
+ gpppdata.setAccount(account);
+ } else{
+ // reset->setEnabled(FALSE);
+// costlabel->setEnabled(FALSE);
+// costedit->setText("");
+// costedit->setEnabled(FALSE);
+// vollabel->setEnabled(FALSE);
+// voledit->setText("");
+// voledit->setEnabled(FALSE);
+ }
+}
+
+
+// void AccountWidget::viewLogClicked(){
+
+// QApplication::flushX();
+// if(fork() == 0) {
+// setgid(getgid());
+// setuid(getuid());
+// system("kppplogview -kppp");
+// _exit(0);
+// }
+// }
+
+
+// void AccountWidget::resetClicked(){
+// if(accountlist_l->currentItem() == -1)
+// return;
+
+// // QueryReset dlg(this);
+// // int what = dlg.exec();
+
+// // if(what && QueryReset::COSTS) {
+// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem()));
+// // costedit->setText("0");
+// // }
+
+// // if(what && QueryReset::VOLUME) {
+// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem()));
+// // voledit->setText(prettyPrintVolume(0));
+// // }
+// }
+
+
+void AccountWidget::editaccount() {
+ gpppdata.setAccount(accountlist_l->text(accountlist_l->currentItem()));
+
+ int result = doTab();
+
+ if(result == QDialog::Accepted) {
+ accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem());
+// emit resetaccounts();
+ gpppdata.save();
+ }
+}
+
+
+void AccountWidget::newaccount() {
+ if(accountlist_l->count() == MAX_ACCOUNTS) {
+ QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
+ return;
+ }
+
+ int result;
+// int query = QMessageBox::information(this,
+// i18n("Do you want to use the wizard to create the new account or the "
+// "standard, dialog-based setup?\n"
+// "The wizard is easier and sufficient in most cases. If you need "
+// "very special settings, you might want to try the standard, "
+// "dialog-based setup."),
+// i18n("Create New Account"),
+// i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
+
+// switch(query) {
+// case QMessageBox::Yes:
+// {
+// if (gpppdata.newaccount() == -1)
+// return;
+// // ProviderDB pdb(this);
+// // result = pdb.exec();
+// break;
+// }
+// case QMessageBox::No:
+ if (gpppdata.newaccount() == -1){
+ qDebug("gpppdata.newaccount() == -1");
+ return;
+ }
+ result = doTab();
+// break;
+// default:
+// return;
+// }
+
+ if(result == QDialog::Accepted) {
+ accountlist_l->insertItem(gpppdata.accname());
+ accountlist_l->setSelected(accountlist_l->findItem(gpppdata.accname()),
+ true);
+// emit resetaccounts();
+ gpppdata.save();
+ } else
+ gpppdata.deleteAccount();
+}
+
+
+void AccountWidget::copyaccount() {
+ if(accountlist_l->count() == MAX_ACCOUNTS) {
+ QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
+ return;
+ }
+
+ if(accountlist_l->currentItem()<0) {
+ QMessageBox::information(this, "sorry", i18n("No account selected."));
+ return;
+ }
+
+ gpppdata.copyaccount(accountlist_l->currentItem());
+
+ accountlist_l->insertItem(gpppdata.accname());
+// emit resetaccounts();
+ gpppdata.save();
+}
+
+
+void AccountWidget::deleteaccount() {
+
+ QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
+ .arg(accountlist_l->text(accountlist_l->currentItem()));
+
+ if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
+ return;
+
+ if(gpppdata.deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
+ accountlist_l->removeItem(accountlist_l->currentItem());
+
+ emit resetaccounts();
+ gpppdata.save();
+
+ slotListBoxSelect(accountlist_l->currentItem());
+
+}
+
+
+int AccountWidget::doTab(){
+ QDialog *dlg = new QDialog( this );
+ tabWindow = new QTabWidget( dlg );
+ // tabWindow = new KDialogBase( KDialogBase::Tabbed, QString::null,
+// KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok,
+// 0, 0, true);
+// KWin::setIcons(tabWindow->winId(), kapp->icon(), kapp->miniIcon());
+ bool isnewaccount;
+
+ if(gpppdata.accname().isEmpty()) {
+ tabWindow->setCaption(i18n("New Account"));
+ isnewaccount = true;
+ } else {
+ QString tit = i18n("Edit Account: ");
+ tit += gpppdata.accname();
+ tabWindow->setCaption(tit);
+ isnewaccount = false;
+ }
+
+ dial_w = new DialWidget( tabWindow );
+ tabWindow->addTab( dial_w, i18n("Dial") );//, i18n("Dial Setup")), isnewaccount);
+ ip_w = new IPWidget( tabWindow );
+ tabWindow->addTab( ip_w, i18n("IP") );//, i18n("IP Setup")), isnewaccount);
+ gateway_w = new GatewayWidget( tabWindow );
+ tabWindow->addTab( gateway_w, i18n("Gateway") );//, i18n("Gateway Setup")), isnewaccount);
+ dns_w = new DNSWidget( tabWindow );
+ tabWindow->addTab( dns_w, i18n("DNS") );//, i18n("DNS Servers")), isnewaccount);
+ script_w = new ScriptWidget( tabWindow );
+ tabWindow->addTab( script_w, i18n("Login Script") ); //, i18n("Edit Login Script")), isnewaccount);
+ ExecWidget *exec_w = new ExecWidget( tabWindow );
+ tabWindow->addTab( exec_w, i18n("Execute") );//, i18n("Execute Programs")), isnewaccount);
+// acct = new AccountingSelector( tabWindow, isnewaccount );
+// tabWindow->addTab( acct, i18n("Accounting"));
+
+ int result = 0;
+ bool ok = false;
+ while (!ok){
+
+ result = dlg->exec();
+ ok = true;
+
+ if(result == QDialog::Accepted) {
+ if (script_w->check()) {
+ if(dial_w->save()) {
+ ip_w->save();
+ dns_w->save();
+ gateway_w->save();
+ script_w->save();
+ exec_w->save();
+// acct->save();
+ } else {
+ QMessageBox::critical(this, "error", i18n( "You must enter a unique\n"
+ "account name"));
+ ok = false;
+ }
+ } else {
+ QMessageBox::critical(this, "error", i18n("Login script has unbalanced "
+ "loop Start/End"));
+ ok = false;
+ }
+ }
+ }
+
+ delete tabWindow;
+ return result;
+}
+
+
+QString AccountWidget::prettyPrintVolume(unsigned int n) {
+ int idx = 0;
+ const QString quant[] = {i18n("Byte"), i18n("KB"),
+ i18n("MB"), i18n("GB"), QString::null};
+
+ float n1 = n;
+ while(n >= 1024 && quant[idx] != QString::null) {
+ idx++;
+ n /= 1024;
+ }
+
+ int i = idx;
+ while(i--)
+ n1 = n1 / 1024.0;
+
+ QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
+ s += " " + quant[idx];
+ return s;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Queries the user what to reset: costs, volume or both
+//
+/////////////////////////////////////////////////////////////////////////////
+QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
+// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+ setCaption(i18n("Reset Accounting"));
+
+ QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
+ QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this);
+
+ QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
+// costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f);
+// costs->setChecked(true);
+// l1->addWidget(costs);
+// QWhatsThis::add(costs, i18n("Check this to set the phone costs\n"
+// "to zero. Typically you'll want to\n"
+// "do this once a month."));
+
+// volume = new QCheckBox(i18n("Reset volume accounting"), f);
+// volume->setChecked(true);
+// l1->addWidget(volume);
+// QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n"
+// "to zero. Typically you'll want to do this\n"
+// "once a month."));
+
+ l1->activate();
+
+ // this activates the f-layout and sets minimumSize()
+ f->show();
+
+ tl->addWidget(f);
+
+ QButtonGroup *bbox = new QButtonGroup(this);
+// bbox->addStretch(1);
+ QPushButton *ok = new QPushButton( bbox, i18n("OK") );
+ bbox->insert(ok);
+ ok->setDefault(true);
+ QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") );
+ bbox->insert(cancel);
+
+ connect(ok, SIGNAL(clicked()),
+ this, SLOT(accepted()));
+ connect(cancel, SIGNAL(clicked()),
+ this, SLOT(reject()));
+
+ bbox->layout();
+ tl->addWidget(bbox);
+
+ // TODO: activate if KGroupBox is fixed
+ // setFixedSize(sizeHint());
+}
+
+
+void QueryReset::accepted() {
+ int result = costs->isChecked() ? COSTS : 0;
+ result += volume->isChecked() ? VOLUME : 0;
+
+ done(result);
+}
+
+
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
new file mode 100644
index 0000000..751a414
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -0,0 +1,110 @@
+/* -*- C++ -*-
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _ACCOUNTS_H_
+#define _ACCOUNTS_H_
+
+#include <qwidget.h>
+#include <qdialog.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+//#include "acctselect.h"
+
+class QDialog;
+class QCheckBox;
+class QLineEdit;
+class QTabWidget;
+class DialWidget;
+class ScriptWidget;
+class IPWidget;
+class DNSWidget;
+class GatewayWidget;
+
+class AccountWidget : public QWidget {
+ Q_OBJECT
+public:
+ AccountWidget( QWidget *parent=0, const char *name=0 );
+ ~AccountWidget() {}
+
+private slots:
+ void editaccount();
+ void copyaccount();
+ void newaccount();
+ void deleteaccount();
+ void slotListBoxSelect(int);
+// void resetClicked();
+// void viewLogClicked();
+
+private:
+ int doTab();
+
+signals:
+ void resetaccounts();
+// void resetCosts(const QString &);
+// void resetVolume(const QString &);
+
+private:
+ QString prettyPrintVolume(unsigned int);
+
+ QTabWidget *tabWindow;
+ DialWidget *dial_w;
+// AccountingSelector *acct;
+ IPWidget *ip_w;
+ DNSWidget *dns_w;
+ GatewayWidget *gateway_w;
+ ScriptWidget *script_w;
+
+// QPushButton *reset;
+// QPushButton *log;
+// QLabel *costlabel;
+// QLineEdit *costedit;
+// QLabel *vollabel;
+// QLineEdit *voledit;
+
+ QListBox *accountlist_l;
+ QPushButton *edit_b;
+ QPushButton *copy_b;
+ QPushButton *new_b;
+ QPushButton *delete_b;
+};
+
+
+class QueryReset : public QDialog {
+ Q_OBJECT
+public:
+ QueryReset(QWidget *parent);
+
+ enum {COSTS=1, VOLUME=2};
+
+private slots:
+ void accepted();
+
+private:
+ QCheckBox *costs, *volume;
+};
+
+#endif
+
diff --git a/noncore/settings/networksettings/ppp/auth.h b/noncore/settings/networksettings/ppp/auth.h
new file mode 100644
index 0000000..d497b10
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/auth.h
@@ -0,0 +1,36 @@
+/*
+ *
+ * kPPP: A pppd Front End for the KDE project
+ *
+ * $Id$
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * This file was contributed by Mario Weilguni <mweilguni@sime.com>
+ * Thanks Mario!
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __AUTH__H__
+#define __AUTH__H__
+
+#define AUTH_SCRIPT 0
+#define AUTH_PAP 1
+#define AUTH_TERMINAL 2
+#define AUTH_CHAP 3
+#define AUTH_PAPCHAP 4
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
new file mode 100644
index 0000000..b7e229e
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -0,0 +1,1438 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ * Copyright (C) 1998-2001 Harri Porten <porten@kde.org>
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+//#include <config.h>
+
+#include <qlayout.h>
+#include <qregexp.h>
+
+#include <qapplication.h>
+//#include <kdebug.h>
+//#include <klocale.h>
+#define i18n QObject::tr
+#include <qmessagebox.h>
+#include <qpushbutton.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+
+#ifdef _XPG4_2
+#define __xnet_connect connect
+#endif
+
+#include <errno.h>
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#ifdef __linux__
+#include "runtests.h"
+#endif
+
+#include "auth.h"
+#include "connect.h"
+//#include "docking.h"
+//#include "main.h"
+#include "modem.h"
+#include "kpppconfig.h"
+#include "pppdata.h"
+#include "kpppwidget.h"
+//#include "requester.h"
+//#include "utils.h"
+#define execute_command system
+
+extern KPPPWidget *p_kppp;
+
+QString old_hostname;
+bool modified_hostname;
+
+
+ConnectWidget::ConnectWidget(QWidget *parent, const char *name)
+ : QWidget(parent, name),
+ // initialize some important variables
+ myreadbuffer(""),
+ main_timer_ID(0),
+ vmain(0),
+ substate(-1),
+ scriptindex(0),
+ loopnest(0),
+ loopend(false),
+ semaphore(false),
+ expecting(false),
+ readbuffer(""),
+ scanvar(""),
+ scanning(false),
+ pausing(false),
+// termwindow(0),
+// stats(st),
+ dialnumber(0)
+{
+ modified_hostname = false;
+
+ QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
+ QString tit = i18n("Connecting to: ");
+ setCaption(tit);
+
+ QHBoxLayout *l0 = new QHBoxLayout(10);
+ tl->addLayout(l0);
+ l0->addSpacing(10);
+ messg = new QLabel(this, "messg");
+ messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
+ messg->setAlignment(AlignCenter);
+ messg->setText(i18n("Unable to create modem lock file."));
+ messg->setMinimumHeight(messg->sizeHint().height() + 5);
+ int messw = (messg->sizeHint().width() * 12) / 10;
+ messw = QMAX(messw,280);
+ messg->setMinimumWidth(messw);
+ messg->setText(i18n("Looking for modem..."));
+ l0->addSpacing(10);
+ l0->addWidget(messg);
+ l0->addSpacing(10);
+
+ QHBoxLayout *l1 = new QHBoxLayout(10);
+ tl->addLayout(l1);
+ l1->addStretch(1);
+
+ debug = new QPushButton(i18n("Log"), this);
+ debug->setToggleButton(true);
+ connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
+
+ cancel = new QPushButton(i18n("Cancel"), this);
+ cancel->setFocus();
+ connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
+
+ int maxw = QMAX(cancel->sizeHint().width(),
+ debug->sizeHint().width());
+ maxw = QMAX(maxw,65);
+ debug->setFixedWidth(maxw);
+ cancel->setFixedWidth(maxw);
+ l1->addWidget(debug);
+ l1->addWidget(cancel);
+
+ setFixedSize(sizeHint());
+
+ pausetimer = new QTimer(this);
+ connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
+
+ qApp->processEvents();
+
+ timeout_timer = new QTimer(this);
+ connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
+
+ inittimer = new QTimer(this);
+ connect(inittimer, SIGNAL(timeout()), SLOT(init()));
+
+ if_timeout_timer = new QTimer(this);
+ connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
+
+ connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
+
+ prompt = new PWEntry( this, "pw" );
+ if_timer = new QTimer(this);
+ connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
+}
+
+
+ConnectWidget::~ConnectWidget() {
+}
+
+
+void ConnectWidget::preinit() {
+ // this is all just to keep the GUI nice and snappy ....
+ // you have to see to believe ...
+ messg->setText(i18n("Looking for modem..."));
+ inittimer->start(100);
+}
+
+
+void ConnectWidget::init() {
+ gpppdata.setpppdError(0);
+ inittimer->stop();
+ vmain = 0;
+ substate = -1;
+ expecting = false;
+ pausing = false;
+ scriptindex = 0;
+ myreadbuffer = "";
+ scanning = false;
+ scanvar = "";
+ firstrunID = true;
+ firstrunPW = true;
+// stats->totalbytes = 0;
+ dialnumber = 0;
+
+ p_kppp->con_speed = "";
+
+// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || gpppdata.quit_on_disconnect());
+
+ comlist = &gpppdata.scriptType();
+ arglist = &gpppdata.script();
+
+ QString tit = i18n("Connecting to: %1").arg(gpppdata.accname());
+ setCaption(tit);
+
+ qApp->processEvents();
+
+ // run the "before-connect" command
+ if (!gpppdata.command_before_connect().isEmpty()) {
+ messg->setText(i18n("Running pre-startup command..."));
+ emit debugMessage(i18n("Running pre-startup command..."));
+
+ qApp->processEvents();
+ QApplication::flushX();
+ pid_t id = execute_command(gpppdata.command_before_connect());
+// int i, status;
+
+// do {
+// qApp->processEvents();
+// i = waitpid(id, &status, WNOHANG);
+// usleep(100000);
+// } while (i == 0 && errno == 0);
+ }
+
+ int lock = Modem::modem->lockdevice();
+
+ if (lock == 1) {
+ messg->setText(i18n("Modem device is locked."));
+ vmain = 20; // wait until cancel is pressed
+ return;
+ }
+
+ if (lock == -1) {
+ messg->setText(i18n("Unable to create modem lock file."));
+ vmain = 20; // wait until cancel is pressed
+ return;
+ }
+
+ if(Modem::modem->opentty()) {
+ messg->setText(Modem::modem->modemMessage());
+ qApp->processEvents();
+ if(Modem::modem->hangup()) {
+
+ qApp->processEvents();
+
+ semaphore = false;
+
+ Modem::modem->stop();
+ Modem::modem->notify(this, SLOT(readChar(unsigned char)));
+
+ // if we are stuck anywhere we will time out
+ timeout_timer->start(gpppdata.modemTimeout()*1000);
+
+ // this timer will run the script etc.
+ main_timer_ID = startTimer(10);
+
+ return;
+ }
+ }
+
+ // initialization failed
+ messg->setText(Modem::modem->modemMessage());
+ vmain = 20; // wait until cancel is pressed
+ Modem::modem->unlockdevice();
+}
+
+
+void ConnectWidget::timerEvent(QTimerEvent *) {
+ if (semaphore || pausing)
+ return;
+
+ if(vmain == 0) {
+#ifdef DEBUG_WO_DIALING
+ vmain = 10;
+ return;
+#endif
+
+ assert(PPPData::NumInitStrings > 0);
+ // first init string ?
+ if(substate == -1) {
+ messg->setText(i18n("Initializing modem..."));
+ emit debugMessage(i18n("Initializing modem..."));
+ substate = 0;
+ }
+
+ QString initStr = gpppdata.modemInitStr(substate);
+ if (!initStr.isEmpty()) {
+ // send a carriage return and then wait a bit so that the modem will
+ // let us issue commands.
+ if(gpppdata.modemPreInitDelay() > 0) {
+ usleep(gpppdata.modemPreInitDelay() * 5000);
+ writeline("");
+ usleep(gpppdata.modemPreInitDelay() * 5000);
+ }
+ setExpect(gpppdata.modemInitResp());
+ writeline(initStr);
+ usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ }
+
+ substate++;
+
+ /*
+ * FIXME after 3.0: Make it possible to disable ATS11 since it
+ * seems to be incompatible with some ISDN adapters (e.g. DataBox
+ * Speed Dragon). Even better would be to detect this when doing
+ * a "Modem Query"
+ */
+ if (MODEM_TONEDURATION != gpppdata.modemToneDuration())
+ vmain = 5;
+ else
+ vmain = 3;
+
+ return;
+ }
+
+ if (vmain == 5) {
+ if(!expecting) {
+ QString sToneDuration = "ATS11=" + QString::number(gpppdata.modemToneDuration());
+ QString msg = i18n("Setting ") + sToneDuration;
+ messg->setText(msg);
+ emit debugMessage(msg);
+ setExpect(gpppdata.modemInitResp());
+ writeline(sToneDuration);
+ }
+ vmain = 3;
+ return;
+ }
+
+ if(vmain == 3) {
+ if(!expecting) {
+ // done with all init strings ?
+ if(substate < PPPData::NumInitStrings) {
+ vmain = 0;
+ return;
+ }
+ substate = -1;
+ // skip setting the volume if command is empty
+ if(gpppdata.volumeInitString().isEmpty()) {
+ vmain = 4;
+ return;
+ }
+ messg->setText(i18n("Setting speaker volume..."));
+ emit debugMessage(i18n("Setting speaker volume..."));
+
+ setExpect(gpppdata.modemInitResp());
+ QString vol("AT");
+ vol += gpppdata.volumeInitString();
+ writeline(vol);
+ usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ vmain = 4;
+ return;
+ }
+ }
+
+ if(vmain == 4) {
+ if(!expecting) {
+ if(!gpppdata.waitForDialTone()) {
+ QString msg = i18n("Turning off dial tone waiting...");
+ messg->setText(msg);
+ emit debugMessage(msg);
+ setExpect(gpppdata.modemInitResp());
+ writeline(gpppdata.modemNoDialToneDetectionStr());
+ }
+ vmain = 1;
+ return;
+ }
+ }
+
+ // dial the number and wait to connect
+ if(vmain == 1) {
+ if(!expecting) {
+
+ timeout_timer->stop();
+ timeout_timer->start(gpppdata.modemTimeout()*1000);
+
+ QStringList &plist = gpppdata.phonenumbers();
+ QString bmarg= gpppdata.dialPrefix();
+ bmarg += *plist.at(dialnumber);
+ QString bm = i18n("Dialing %1").arg(bmarg);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ QString pn = gpppdata.modemDialStr();
+ pn += gpppdata.dialPrefix();
+ pn += *plist.at(dialnumber);
+ if(++dialnumber >= plist.count())
+ dialnumber = 0;
+ writeline(pn);
+
+ setExpect(gpppdata.modemConnectResp());
+ vmain = 100;
+ return;
+ }
+ }
+
+ // wait for connect, but redial if BUSY or wait for user cancel
+ // if NO CARRIER or NO DIALTONE
+ if(vmain == 100) {
+ if(!expecting) {
+ myreadbuffer = gpppdata.modemConnectResp();
+ setExpect("\n");
+ vmain = 101;
+ return;
+ }
+
+ if(readbuffer.contains(gpppdata.modemBusyResp())) {
+ timeout_timer->stop();
+ timeout_timer->start(gpppdata.modemTimeout()*1000);
+
+ messg->setText(i18n("Line busy. Hanging up..."));
+ emit debugPutChar('\n');
+ Modem::modem->hangup();
+
+ if(gpppdata.busyWait() > 0) {
+ QString bm = i18n("Line busy. Waiting: %1 seconds").arg(gpppdata.busyWait());
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ pausing = true;
+
+ pausetimer->start(gpppdata.busyWait()*1000, true);
+ timeout_timer->stop();
+ }
+
+ Modem::modem->setDataMode(false);
+ vmain = 0;
+ substate = -1;
+ return;
+ }
+
+ if(readbuffer.contains(gpppdata.modemNoDialtoneResp())) {
+ timeout_timer->stop();
+
+ messg->setText(i18n("No Dialtone"));
+ vmain = 20;
+ Modem::modem->unlockdevice();
+ return;
+ }
+
+ if(readbuffer.contains(gpppdata.modemNoCarrierResp())) {
+ timeout_timer->stop();
+
+ messg->setText(i18n("No Carrier"));
+ vmain = 20;
+ Modem::modem->unlockdevice();
+ return;
+ }
+ }
+
+ // wait for newline after CONNECT response (so we get the speed)
+ if(vmain == 101) {
+ if(!expecting) {
+ Modem::modem->setDataMode(true); // modem will no longer respond to AT commands
+
+ emit startAccounting();
+// p_kppp->con_win->startClock();
+
+ vmain = 2;
+ scriptTimeout=gpppdata.modemTimeout()*1000;
+ return;
+ }
+ }
+
+ // execute the script
+ if(vmain == 2) {
+ if(!expecting && !pausing && !scanning) {
+
+ timeout_timer->stop();
+ timeout_timer->start(scriptTimeout);
+
+ if((unsigned) scriptindex < comlist->count()) {
+ scriptCommand = *(comlist->at(scriptindex));
+ scriptArgument = *(arglist->at(scriptindex));
+ } else {
+ qDebug( "End of script" );
+ vmain = 10;
+ return;
+ }
+
+ if (scriptCommand == "Scan") {
+ QString bm = i18n("Scanning %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ setScan(scriptArgument);
+ scriptindex++;
+ return;
+ }
+
+ if (scriptCommand == "Save") {
+ QString bm = i18n("Saving %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ if (scriptArgument.lower() == "password") {
+ gpppdata.setPassword(scanvar);
+ p_kppp->setPW_Edit(scanvar);
+ if(gpppdata.storePassword())
+ gpppdata.setStoredPassword(scanvar);
+ firstrunPW = true;
+ }
+
+ scriptindex++;
+ return;
+ }
+
+
+ if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
+ QString bm = i18n("Sending %1");
+
+ // replace %USERNAME% and %PASSWORD%
+ QString arg = scriptArgument;
+ QRegExp re1("%USERNAME%");
+ QRegExp re2("%PASSWORD%");
+ arg = arg.replace(re1, gpppdata.storedUsername());
+ arg = arg.replace(re2, gpppdata.storedPassword());
+
+ if (scriptCommand == "Send")
+ bm = bm.arg(scriptArgument);
+ else {
+ for(uint i = 0; i < scriptArgument.length(); i++)
+ bm = bm.arg("*");
+ }
+
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ writeline(scriptArgument);
+ scriptindex++;
+ return;
+ }
+
+ if (scriptCommand == "Expect") {
+ QString bm = i18n("Expecting %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ // The incrementing of the scriptindex MUST be before the
+ // call to setExpect otherwise the expect will miss a string that is
+ // already in the buffer.
+ scriptindex++;
+ setExpect(scriptArgument);
+ return;
+ }
+
+
+ if (scriptCommand == "Pause") {
+ QString bm = i18n("Pause %1 seconds").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ pausing = true;
+
+ pausetimer->start(scriptArgument.toInt()*1000, true);
+ timeout_timer->stop();
+
+ scriptindex++;
+ return;
+ }
+
+ if (scriptCommand == "Timeout") {
+
+ timeout_timer->stop();
+
+ QString bm = i18n("Timeout %1 seconds").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ scriptTimeout=scriptArgument.toInt()*1000;
+ timeout_timer->start(scriptTimeout);
+
+ scriptindex++;
+ return;
+ }
+
+ if (scriptCommand == "Hangup") {
+ messg->setText(i18n("Hangup"));
+ emit debugMessage(i18n("Hangup"));
+
+ writeline(gpppdata.modemHangupStr());
+ setExpect(gpppdata.modemHangupResp());
+
+ scriptindex++;
+ return;
+ }
+
+ if (scriptCommand == "Answer") {
+
+ timeout_timer->stop();
+
+ messg->setText(i18n("Answer"));
+ emit debugMessage(i18n("Answer"));
+
+ setExpect(gpppdata.modemRingResp());
+ vmain = 150;
+ return;
+ }
+
+ if (scriptCommand == "ID") {
+ QString bm = i18n("ID %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ QString idstring = gpppdata.storedUsername();
+
+ if(!idstring.isEmpty() && firstrunID) {
+ // the user entered an Id on the main kppp dialog
+ writeline(idstring);
+ firstrunID = false;
+ scriptindex++;
+ }
+ else {
+ // the user didn't enter and Id on the main kppp dialog
+ // let's query for an ID
+ /* if not around yet, then post window... */
+ if (prompt->Consumed()) {
+ if (!(prompt->isVisible())) {
+ prompt->setPrompt(scriptArgument);
+ prompt->setEchoModeNormal();
+ prompt->show();
+ }
+ } else {
+ /* if prompt withdrawn ... then, */
+ if(!(prompt->isVisible())) {
+ writeline(prompt->text());
+ prompt->setConsumed();
+ scriptindex++;
+ return;
+ }
+ /* replace timeout value */
+ }
+ }
+ }
+
+ if (scriptCommand == "Password") {
+ QString bm = i18n("Password %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ QString pwstring = gpppdata.password();
+
+ if(!pwstring.isEmpty() && firstrunPW) {
+ // the user entered a password on the main kppp dialog
+ writeline(pwstring);
+ firstrunPW = false;
+ scriptindex++;
+ }
+ else {
+ // the user didn't enter a password on the main kppp dialog
+ // let's query for a password
+ /* if not around yet, then post window... */
+ if (prompt->Consumed()) {
+ if (!(prompt->isVisible())) {
+ prompt->setPrompt(scriptArgument);
+ prompt->setEchoModePassword();
+ prompt->show();
+ }
+ } else {
+ /* if prompt withdrawn ... then, */
+ if(!(prompt->isVisible())) {
+ p_kppp->setPW_Edit(prompt->text());
+ writeline(prompt->text());
+ prompt->setConsumed();
+ scriptindex++;
+ return;
+ }
+ /* replace timeout value */
+ }
+ }
+ }
+
+ if (scriptCommand == "Prompt") {
+ QString bm = i18n("Prompting %1");
+
+ // if the scriptindex (aka the prompt text) includes a ## marker
+ // this marker should get substituted with the contents of our stored
+ // variable (from the subsequent scan).
+
+ QString ts = scriptArgument;
+ int vstart = ts.find( "##" );
+ if( vstart != -1 ) {
+ ts.remove( vstart, 2 );
+ ts.insert( vstart, scanvar );
+ }
+
+ bm = bm.arg(ts);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ /* if not around yet, then post window... */
+ if (prompt->Consumed()) {
+ if (!(prompt->isVisible())) {
+ prompt->setPrompt( ts );
+ prompt->setEchoModeNormal();
+ prompt->show();
+ }
+ } else {
+ /* if prompt withdrawn ... then, */
+ if (!(prompt->isVisible())) {
+ writeline(prompt->text());
+ prompt->setConsumed();
+ scriptindex++;
+ return;
+ }
+ /* replace timeout value */
+ }
+ }
+
+ if (scriptCommand == "PWPrompt") {
+ QString bm = i18n("PW Prompt %1").arg(scriptArgument);
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ /* if not around yet, then post window... */
+ if (prompt->Consumed()) {
+ if (!(prompt->isVisible())) {
+ prompt->setPrompt(scriptArgument);
+ prompt->setEchoModePassword();
+ prompt->show();
+ }
+ } else {
+ /* if prompt withdrawn ... then, */
+ if (!(prompt->isVisible())) {
+ writeline(prompt->text());
+ prompt->setConsumed();
+ scriptindex++;
+ return;
+ }
+ /* replace timeout value */
+ }
+ }
+
+ if (scriptCommand == "LoopStart") {
+
+ QString bm = i18n("Loop Start %1").arg(scriptArgument);
+
+ // The incrementing of the scriptindex MUST be before the
+ // call to setExpect otherwise the expect will miss a string that is
+ // already in the buffer.
+ scriptindex++;
+
+ if ( loopnest > (MAXLOOPNEST-2) ) {
+ bm += i18n("ERROR: Nested too deep, ignored.");
+ vmain=20;
+ cancelbutton();
+ QMessageBox::critical(0, "error", i18n("Loops nested too deeply!"));
+ } else {
+ setExpect(scriptArgument);
+ loopstartindex[loopnest] = scriptindex;
+ loopstr[loopnest] = scriptArgument;
+ loopend = false;
+ loopnest++;
+ }
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ }
+
+ if (scriptCommand == "LoopEnd") {
+ QString bm = i18n("Loop End %1").arg(scriptArgument);
+ if ( loopnest <= 0 ) {
+ bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm);
+ vmain=20;
+ cancelbutton();
+ QMessageBox::critical(0, "error", bm);
+ return;
+ } else {
+ // NB! The incrementing of the scriptindex MUST be before the
+ // call to setExpect otherwise the expect will miss a string
+ // that is already in the buffer.
+ scriptindex++;
+ setExpect(scriptArgument);
+ loopnest--;
+ loopend = true;
+ }
+ messg->setText(bm);
+ emit debugMessage(bm);
+
+ }
+ }
+ }
+
+ // this is a subroutine for the "Answer" script option
+
+ if(vmain == 150) {
+ if(!expecting) {
+ writeline(gpppdata.modemAnswerStr());
+ setExpect(gpppdata.modemAnswerResp());
+
+ vmain = 2;
+ scriptindex++;
+ return;
+ }
+ }
+
+ if(vmain == 30) {
+// if (termwindow->isVisible())
+// return;
+// if (termwindow->pressedContinue())
+// vmain = 10;
+// else
+ cancelbutton();
+ }
+
+ if(vmain == 10) {
+ if(!expecting) {
+
+ int result;
+
+ timeout_timer->stop();
+ if_timeout_timer->stop(); // better be sure.
+
+ // stop reading of data
+ Modem::modem->stop();
+
+ if(gpppdata.authMethod() == AUTH_TERMINAL) {
+ // if (termwindow) {
+// delete termwindow;
+// termwindow = 0L;
+// this->show();
+// } else {
+// termwindow = new LoginTerm(0L, 0L);
+// hide();
+// termwindow->show();
+// vmain = 30;
+// return;
+// }
+ }
+
+ // Close the tty. This prevents the QTimer::singleShot() in
+ // Modem::readtty() from re-enabling the socket notifier.
+ // The port is still held open by the helper process.
+ Modem::modem->closetty();
+
+ killTimer( main_timer_ID );
+
+ if_timeout_timer->start(gpppdata.pppdTimeout()*1000);
+ qDebug( "started if timeout timer with %i", gpppdata.pppdTimeout()*1000);
+
+ // find out PPP interface and notify the stats module
+// stats->setUnit(pppInterfaceNumber());
+
+ qApp->flushX();
+ semaphore = true;
+ result = execppp();
+
+ emit debugMessage(i18n("Starting pppd..."));
+ qDebug("execppp() returned with return-code %i", result );
+
+ if(result) {
+ if(!gpppdata.autoDNS())
+ adddns();
+
+ // O.K we are done here, let's change over to the if_waiting loop
+ // where we wait for the ppp if (interface) to come up.
+
+ emit if_waiting_signal();
+ } else {
+
+ // starting pppd wasn't successful. Error messages were
+ // handled by execppp();
+ if_timeout_timer->stop();
+ this->hide();
+ messg->setText("");
+ p_kppp->quit_b->setFocus();
+ p_kppp->show();
+ qApp->processEvents();
+ Modem::modem->hangup();
+ emit stopAccounting();
+// p_kppp->con_win->stopClock();
+ Modem::modem->closetty();
+ Modem::modem->unlockdevice();
+
+ }
+
+ return;
+ }
+ }
+
+ // this is a "wait until cancel" entry
+
+ if(vmain == 20) {
+ }
+}
+
+
+void ConnectWidget::set_con_speed_string() {
+ // Here we are trying to determine the speed at which we are connected.
+ // Usually the modem responds after connect with something like
+ // CONNECT 115200, so all we need to do is find the number after CONNECT
+ // or whatever the modemConnectResp() is.
+ p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer);
+}
+
+
+
+void ConnectWidget::readChar(unsigned char c) {
+ if(semaphore)
+ return;
+
+ readbuffer += c;
+ myreadbuffer += c;
+
+ // While in scanning mode store each char to the scan buffer
+ // for use in the prompt command
+ if( scanning )
+ scanbuffer += c;
+
+ // add to debug window
+ emit debugPutChar(c);
+
+ checkBuffers();
+}
+
+
+void ConnectWidget::checkBuffers() {
+ // Let's check if we are finished with scanning:
+ // The scanstring have to be in the buffer and the latest character
+ // was a carriage return or an linefeed (depending on modem setup)
+ if( scanning && scanbuffer.contains(scanstr) &&
+ ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
+ scanning = false;
+
+ int vstart = scanbuffer.find( scanstr ) + scanstr.length();
+ scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
+ scanvar = scanvar.stripWhiteSpace();
+
+ // Show the Variabel content in the debug window
+ QString sv = i18n("Scan Var: %1").arg(scanvar);
+ emit debugMessage(sv);
+ }
+
+ if(expecting) {
+ if(readbuffer.contains(expectstr)) {
+ expecting = false;
+ // keep everything after the expected string
+ readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
+
+ QString ts = i18n("Found: %1").arg(expectstr);
+ emit debugMessage(ts);
+
+ if (loopend) {
+ loopend=false;
+ }
+ }
+
+ if (loopend && readbuffer.contains(loopstr[loopnest])) {
+ expecting = false;
+ readbuffer = "";
+ QString ts = i18n("Looping: %1").arg(loopstr[loopnest]);
+ emit debugMessage(ts);
+ scriptindex = loopstartindex[loopnest];
+ loopend = false;
+ loopnest++;
+ }
+ // notify event loop if expected string was found
+ if(!expecting)
+ timerEvent((QTimerEvent *) 0);
+ }
+}
+
+
+
+void ConnectWidget::pause() {
+ pausing = false;
+ pausetimer->stop();
+}
+
+
+void ConnectWidget::cancelbutton() {
+ Modem::modem->stop();
+ killTimer(main_timer_ID);
+ timeout_timer->stop();
+ if_timer->stop();
+ if_timeout_timer->stop();
+
+// if (termwindow) {
+// delete termwindow;
+// termwindow = 0L;
+// this->show();
+// }
+
+ messg->setText(i18n("One moment please..."));
+
+ // just to be sure
+ Modem::modem->removeSecret(AUTH_PAP);
+ Modem::modem->removeSecret(AUTH_CHAP);
+ removedns();
+
+ qApp->processEvents();
+
+ Modem::modem->killPPPDaemon();
+ Modem::modem->hangup();
+
+ this->hide();
+ messg->setText("");
+ p_kppp->quit_b->setFocus();
+ p_kppp->show();
+ emit stopAccounting(); // just to be sure
+// p_kppp->con_win->stopClock();
+ Modem::modem->closetty();
+ Modem::modem->unlockdevice();
+
+ //abort prompt window...
+ if (prompt->isVisible()) {
+ prompt->hide();
+ }
+ prompt->setConsumed();
+
+// if(p_kppp->quitOnDisconnect())
+// qApp->exit(0);
+}
+
+
+void ConnectWidget::script_timed_out() {
+ if(vmain == 20) { // we are in the 'wait for the user to cancel' state
+ timeout_timer->stop();
+ emit stopAccounting();
+// p_kppp->con_win->stopClock();
+ return;
+ }
+
+ if (prompt->isVisible())
+ prompt->hide();
+
+ prompt->setConsumed();
+ messg->setText(i18n("Script timed out!"));
+ Modem::modem->hangup();
+ emit stopAccounting();
+// p_kppp->con_win->stopClock();
+
+ vmain = 0; // let's try again.
+ substate = -1;
+}
+
+
+void ConnectWidget::setScan(const QString &n) {
+ scanning = true;
+ scanstr = n;
+ scanbuffer = "";
+
+ QString ts = i18n("Scanning: %1").arg(n);
+ emit debugMessage(ts);
+}
+
+
+void ConnectWidget::setExpect(const QString &n) {
+ expecting = true;
+ expectstr = n;
+
+ QString ts = i18n("Expecting: %1").arg(n);
+ ts.replace(QRegExp("\n"), "<LF>");
+ emit debugMessage(ts);
+
+ // check if the expected string is in the read buffer already.
+ checkBuffers();
+}
+
+
+void ConnectWidget::if_waiting_timed_out() {
+ if_timer->stop();
+ if_timeout_timer->stop();
+ qDebug("if_waiting_timed_out()");
+
+ gpppdata.setpppdError(E_IF_TIMEOUT);
+
+ // let's kill the stuck pppd
+ Modem::modem->killPPPDaemon();
+
+ emit stopAccounting();
+// p_kppp->con_win->stopClock();
+
+
+ // killing ppp will generate a SIGCHLD which will be caught in pppdie()
+ // in main.cpp what happens next will depend on the boolean
+ // reconnect_on_disconnect which is set in ConnectWidget::init();
+}
+
+void ConnectWidget::pppdDied()
+{
+ if_timer->stop();
+ if_timeout_timer->stop();
+}
+
+void ConnectWidget::if_waiting_slot() {
+ messg->setText(i18n("Logging on to network..."));
+
+// if(!stats->ifIsUp()) {
+
+// if(gpppdata.pppdError() != 0) {
+// // we are here if pppd died immediately after starting it.
+// pppdDied();
+// // error message handled in main.cpp: sigPPPDDied()
+// return;
+// }
+
+// if_timer->start(100, TRUE); // single shot
+// return;
+// }
+
+ // O.K the ppp interface is up and running
+ // give it a few time to come up completly (0.2 seconds)
+ if_timeout_timer->stop();
+ if_timer->stop();
+ usleep(200000);
+
+ if(gpppdata.autoDNS())
+ addpeerdns();
+
+ // Close the debugging window. If we are connected, we
+ // are not really interested in debug output
+ emit closeDebugWindow();
+// p_kppp->statdlg->take_stats(); // start taking ppp statistics
+ auto_hostname();
+
+ if(!gpppdata.command_on_connect().isEmpty()) {
+ messg->setText(i18n("Running startup command..."));
+
+ // make sure that we don't get any async errors
+ qApp->flushX();
+ execute_command(gpppdata.command_on_connect());
+ messg->setText(i18n("Done"));
+ }
+
+ // remove the authentication file
+ Modem::modem->removeSecret(AUTH_PAP);
+ Modem::modem->removeSecret(AUTH_CHAP);
+
+ emit debugMessage(i18n("Done"));
+ set_con_speed_string();
+
+// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
+ this->hide();
+ messg->setText("");
+
+ // prepare the con_win so as to have the right size for
+ // accounting / non-accounting mode
+// if(p_kppp->acct != 0)
+// p_kppp->con_win->accounting(p_kppp->acct->running());
+// else
+// p_kppp->con_win->accounting(false);
+
+ if (gpppdata.get_dock_into_panel()) {
+// DockWidget::dock_widget->show();
+// DockWidget::dock_widget->take_stats();
+// this->hide();
+ }
+ else {
+// p_kppp->con_win->show();
+
+ if(gpppdata.get_iconify_on_connect()) {
+ // p_kppp->con_win->showMinimized();
+ }
+ }
+
+ Modem::modem->closetty();
+}
+
+
+bool ConnectWidget::execppp() {
+ QString command;
+
+ command = "pppd";
+
+ // as of version 2.3.6 pppd falls back to the real user rights when
+ // opening a device given in a command line. To avoid permission conflicts
+ // we'll simply leave this argument away. pppd will then use the default tty
+ // which is the serial port we connected stdin/stdout to in opener.cpp.
+ // command += " ";
+ // command += gpppdata.modemDevice();
+
+ command += " " + gpppdata.speed();
+
+ command += " -detach";
+
+ if(gpppdata.ipaddr() != "0.0.0.0" ||
+ gpppdata.gateway() != "0.0.0.0") {
+ if(gpppdata.ipaddr() != "0.0.0.0") {
+ command += " ";
+ command += gpppdata.ipaddr();
+ command += ":";
+ }
+ else {
+ command += " ";
+ command += ":";
+ }
+
+ if(gpppdata.gateway() != "0.0.0.0")
+ command += gpppdata.gateway();
+ }
+
+ if(gpppdata.subnetmask() != "0.0.0.0")
+ command += " netmask " + gpppdata.subnetmask();
+
+ if(gpppdata.flowcontrol() != "None") {
+ if(gpppdata.flowcontrol() == "CRTSCTS")
+ command += " crtscts";
+ else
+ command += " xonxoff";
+ }
+
+ if(gpppdata.defaultroute())
+ command += " defaultroute";
+
+ if(gpppdata.autoDNS())
+ command += " usepeerdns";
+
+ QStringList &arglist = gpppdata.pppdArgument();
+ for ( QStringList::Iterator it = arglist.begin();
+ it != arglist.end();
+ ++it )
+ {
+ command += " " + *it;
+ }
+
+ // PAP settings
+ if(gpppdata.authMethod() == AUTH_PAP) {
+ command += " -chap user ";
+ command = command + "\"" + gpppdata.storedUsername() + "\"";
+ }
+
+ // CHAP settings
+ if(gpppdata.authMethod() == AUTH_CHAP) {
+ command += " -pap user ";
+ command = command + "\"" + gpppdata.storedUsername() + "\"";
+ }
+
+ // PAP/CHAP settings
+ if(gpppdata.authMethod() == AUTH_PAPCHAP) {
+ command += " user ";
+ command = command + "\"" + gpppdata.storedUsername() + "\"";
+ }
+
+ // check for debug
+ if(gpppdata.getPPPDebug())
+ command += " debug";
+
+ if (command.length() > MAX_CMDLEN) {
+ QMessageBox::critical(this, "error", i18n(
+ "pppd command + command-line arguments exceed "
+ "2024 characters in length."
+ ));
+
+ return false; // nonsensically long command which would bust my buffer buf.
+ }
+
+ qApp->flushX();
+
+ return Modem::modem->execPPPDaemon(command);
+}
+
+
+void ConnectWidget::closeEvent( QCloseEvent *e ) {
+ e->ignore();
+ emit cancelbutton();
+}
+
+
+void ConnectWidget::setMsg(const QString &msg) {
+ messg->setText(msg);
+}
+
+void ConnectWidget::writeline(const QString &s) {
+ Modem::modem->writeLine(s.local8Bit());
+}
+
+// Set the hostname and domain from DNS Server
+void auto_hostname() {
+ struct in_addr local_ip;
+ struct hostent *hostname_entry;
+ QString new_hostname;
+ int dot;
+ char tmp_str[100]; // buffer overflow safe
+
+ gethostname(tmp_str, sizeof(tmp_str));
+ tmp_str[sizeof(tmp_str)-1]=0; // panic
+ old_hostname=tmp_str; // copy to QString
+
+ // if (!p_kppp->stats->local_ip_address.isEmpty() && gpppdata.autoname()) {
+ if ( gpppdata.autoname()) {
+// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
+ hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
+
+ if (hostname_entry != 0L) {
+ new_hostname=hostname_entry->h_name;
+ dot=new_hostname.find('.');
+ new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
+ Modem::modem->setHostname(new_hostname);
+ modified_hostname = TRUE;
+
+ new_hostname=hostname_entry->h_name;
+ new_hostname.remove(0,dot+1);
+
+ add_domain(new_hostname);
+ }
+ }
+
+}
+
+// Replace the DNS domain entry in the /etc/resolv.conf file and
+// disable the nameserver entries if option is enabled
+void add_domain(const QString &domain) {
+
+ int fd;
+ char c;
+ QString resolv[MAX_RESOLVCONF_LINES];
+
+ if (domain.isEmpty())
+ return;
+
+ if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+
+ int i=0;
+ while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
+ if(c == '\n') {
+ i++;
+ }
+ else {
+ resolv[i] += c;
+ }
+ }
+ close(fd);
+ if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
+
+ if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
+ QCString tmp = "domain " + domain.local8Bit() +
+ " \t\t#kppp temp entry\n";
+ write(fd, tmp.data(), tmp.length());
+
+ for(int j=0; j < i; j++) {
+ if((resolv[j].contains("domain") ||
+ ( resolv[j].contains("nameserver")
+ && !resolv[j].contains("#kppp temp entry")
+ && gpppdata.exDNSDisabled()))
+ && !resolv[j].contains("#entry disabled by kppp")) {
+ QCString tmp = "# " + resolv[j].local8Bit() +
+ " \t#entry disabled by kppp\n";
+ write(fd, tmp, tmp.length());
+ }
+ else {
+ QCString tmp = resolv[j].local8Bit() + "\n";
+ write(fd, tmp, tmp.length());
+ }
+ }
+ }
+ close(fd);
+ }
+}
+
+
+// adds the DNS entries in the /etc/resolv.conf file
+void adddns()
+{
+ int fd;
+
+ if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
+ QStringList &dnslist = gpppdata.dns();
+ for ( QStringList::Iterator it = dnslist.begin();
+ it != dnslist.end();
+ ++it )
+ {
+ QCString dns = "nameserver " + (*it).local8Bit() +
+ " \t#kppp temp entry\n";
+ write(fd, dns.data(), dns.length());
+ }
+ close(fd);
+ }
+ add_domain(gpppdata.domain());
+}
+
+void addpeerdns() {
+ int fd, fd2;
+
+ if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
+ if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
+ char c;
+ int i = 0;
+ while(i++ < 100 && read(fd2, &c, 1) == 1) {
+ if(c == '\n')
+ write(fd, "\t#kppp temp entry\n", 18);
+ else
+ write(fd, &c, 1);
+ }
+ close(fd2);
+ } else
+ fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
+ close(fd);
+ }
+ add_domain(gpppdata.domain());
+}
+
+// remove the dns entries from the /etc/resolv.conf file
+void removedns() {
+
+ int fd;
+ char c;
+ QString resolv[MAX_RESOLVCONF_LINES];
+
+ if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+
+ int i=0;
+ while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
+ if(c == '\n') {
+ i++;
+ }
+ else {
+ resolv[i] += c;
+ }
+ }
+ close(fd);
+
+ if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
+ for(int j=0; j < i; j++) {
+ if(resolv[j].contains("#kppp temp entry")) continue;
+ if(resolv[j].contains("#entry disabled by kppp")) {
+ QCString tmp = resolv[j].local8Bit();
+ write(fd, tmp.data()+2, tmp.length() - 27);
+ write(fd, "\n", 1);
+ }
+ else {
+ QCString tmp = resolv[j].local8Bit() + "\n";
+ write(fd, tmp, tmp.length());
+ }
+ }
+ }
+ close(fd);
+
+ }
+
+ if ( modified_hostname ) {
+ Modem::modem->setHostname(old_hostname);
+ modified_hostname = FALSE;
+ }
+
+}
+
+
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h
new file mode 100644
index 0000000..3127236
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/connect.h
@@ -0,0 +1,152 @@
+/* -*- C++ -*-
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _CONNECT_H_
+#define _CONNECT_H_
+
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qevent.h>
+
+#include "kpppconfig.h"
+#include "pwentry.h"
+//#include "docking.h"
+//#include "loginterm.h"
+
+#define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2)
+
+class PPPStats;
+
+class ConnectWidget : public QWidget {
+ Q_OBJECT
+public:
+ ConnectWidget(QWidget *parent, const char *name);
+ ~ConnectWidget();
+
+public:
+ void set_con_speed_string();
+ void setMsg(const QString &);
+ void pppdDied();
+
+protected:
+ void timerEvent(QTimerEvent *);
+ void closeEvent( QCloseEvent *e );
+
+private slots:
+ void readChar(unsigned char);
+ void pause();
+ void if_waiting_slot();
+
+public slots:
+ void init();
+ void preinit();
+ void script_timed_out();
+ void if_waiting_timed_out();
+ void cancelbutton();
+
+signals:
+ void if_waiting_signal();
+ void debugMessage(const QString &);
+ void toggleDebugWindow();
+ void closeDebugWindow();
+ void debugPutChar(unsigned char);
+ void startAccounting();
+ void stopAccounting();
+
+public:
+ QString myreadbuffer; // we want to keep every thing in order to fish for the
+
+ // connection speed later on
+ QPushButton *debug;
+ int main_timer_ID;
+
+private:
+ int vmain;
+ int substate;
+ int scriptindex;
+ QString scriptCommand, scriptArgument;
+ QStringList *comlist, *arglist;
+
+ // static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2);
+ int loopnest;
+ int loopstartindex[MAXLOOPNEST];
+ bool loopend;
+ QString loopstr[MAXLOOPNEST];
+
+ bool semaphore;
+ QTimer *inittimer;
+
+ QTimer *timeout_timer;
+ bool execppp();
+ void writeline(const QString &);
+ void checkBuffers();
+
+ void setExpect(const QString &);
+ bool expecting;
+ QString expectstr;
+
+ QString readbuffer;
+
+ void setScan(const QString &);
+ QString scanvar;
+ QString scanstr;
+ QString scanbuffer;
+ bool scanning;
+
+ bool pausing;
+ PWEntry *prompt;
+// LoginTerm *termwindow;
+
+ int scriptTimeout;
+ QTimer *pausetimer;
+ QTimer *if_timer;
+ QTimer *if_timeout_timer;
+
+ QLabel *messg;
+ QPushButton *cancel;
+
+ bool firstrunID;
+ bool firstrunPW;
+
+ unsigned int dialnumber; // the current number to dial
+
+// PPPStats *stats;
+};
+
+
+// non-member function to kill&wait on the pppd child process
+extern void killppp();
+void adddns();
+void addpeerdns();
+void removedns();
+void add_domain(const QString & newdomain);
+void auto_hostname();
+
+#endif
+
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
new file mode 100644
index 0000000..d6b3fbe
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -0,0 +1,341 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qtooltip.h>
+#include <qdialog.h>
+#include "conwindow.h"
+//#include "docking.h"
+#include "pppdata.h"
+// #include "pppstats.h"
+// #include <klocale.h>
+#define i18n QObject::tr
+// #include <kglobal.h>
+
+extern PPPData gpppdata;
+
+ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget )
+// PPPStats *st)
+ : QWidget(parent, name, 0),
+ minutes(0),
+ seconds(0),
+ hours(0),
+ days(0),
+ tl1(0),
+// stats(st),
+ accountingEnabled(false),
+ volumeAccountingEnabled(false)
+{
+ info1 = new QLabel(i18n("Connected at:"), this);
+ info2 = new QLabel("", this);
+
+ timelabel1 = new QLabel(i18n("Time connected:"), this);
+ timelabel2 = new QLabel("000:00:00", this);
+
+ vollabel = new QLabel(i18n("Volume:"), this);
+ volinfo = new QLabel("", this);
+
+ // now the stuff for accounting
+ session_bill_l = new QLabel(i18n("Session Bill:"), this);
+ session_bill = new QLabel("", this);
+ total_bill_l = new QLabel(i18n("Total Bill:"), this);
+ total_bill = new QLabel("", this);
+
+ this->setCaption("kppp");
+
+ cancelbutton = new QPushButton(this);
+ cancelbutton->setText(i18n("Disconnect"));
+ connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));
+
+ // statsbutton = new QPushButton(this);
+// statsbutton->setText(i18n("Details"));
+// statsbutton->setFocus();
+// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));
+
+ clocktimer = new QTimer(this);
+ connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
+
+ // read window position from config file
+ int p_x, p_y;
+ gpppdata.winPosConWin(p_x, p_y);
+ setGeometry(p_x, p_y, 320, 110);
+}
+
+ConWindow::~ConWindow() {
+ stopClock();
+}
+
+// save window position when window was closed
+bool ConWindow::event(QEvent *e) {
+ if (e->type() == QEvent::Hide)
+ {
+ gpppdata.setWinPosConWin(x(), y());
+ return true;
+ }
+ else
+ return QWidget::event(e);
+}
+
+QString ConWindow::prettyPrintVolume(unsigned int n) {
+ int idx = 0;
+ const QString quant[] = {i18n("Byte"), i18n("KB"),
+ i18n("MB"), i18n("GB"), QString::null};
+
+ float n1 = n;
+ while(n >= 1024 && quant[idx] != QString::null) {
+ idx++;
+ n /= 1024;
+ }
+
+ int i = idx;
+ while(i--)
+ n1 = n1 / 1024.0;
+
+ QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
+ s += " " + quant[idx];
+ return s;
+}
+
+void ConWindow::accounting(bool on) {
+ // cache accounting settings
+ accountingEnabled = on;
+ volumeAccountingEnabled = gpppdata.VolAcctEnabled();
+
+ // delete old layout
+ if(tl1 != 0)
+ delete tl1;
+
+ // add layout now
+ tl1 = new QVBoxLayout(this, 10, 10);
+ tl1->addSpacing(5);
+ QHBoxLayout *tl = new QHBoxLayout;
+ tl1->addLayout(tl);
+ tl->addSpacing(20);
+ QGridLayout *l1;
+
+ int vol_lines = 0;
+ if(gpppdata.VolAcctEnabled())
+ vol_lines = 1;
+
+ if(accountingEnabled)
+ l1 = new QGridLayout(4 + vol_lines, 2, 5);
+ else
+ l1 = new QGridLayout(2 + vol_lines, 2, 5);
+ tl->addLayout(l1);
+ l1->setColStretch(0, 0);
+ l1->setColStretch(1, 1);
+
+ info2->setAlignment(AlignRight|AlignVCenter);
+ timelabel2->setAlignment(AlignRight|AlignVCenter);
+ session_bill->setAlignment(AlignRight|AlignVCenter);
+ total_bill->setAlignment(AlignRight|AlignVCenter);
+ volinfo->setAlignment(AlignRight|AlignVCenter);
+ // make sure that there's enough space for the bills
+ QString s1 = session_bill->text();
+ QString s2 = total_bill->text();
+ QString s3 = volinfo->text();
+
+ session_bill->setText("888888.88 XXX");
+ total_bill->setText("888888.88 XXX");
+ volinfo->setText("8888.8 MB");
+ session_bill->setFixedSize(session_bill->sizeHint());
+ total_bill->setFixedSize(total_bill->sizeHint());
+ volinfo->setFixedSize(volinfo->sizeHint());
+ session_bill->setText(s1);
+ total_bill->setText(s2);
+ volinfo->setText(s3);
+
+ l1->addWidget(info1, 0, 0);
+ l1->addWidget(info2, 0, 1);
+ l1->addWidget(timelabel1, 1, 0);
+ l1->addWidget(timelabel2, 1, 1);
+ if(accountingEnabled) {
+ session_bill_l->show();
+ session_bill->show();
+ total_bill_l->show();
+ total_bill->show();
+ l1->addWidget(session_bill_l, 2, 0);
+ l1->addWidget(session_bill, 2, 1);
+ l1->addWidget(total_bill_l, 3, 0);
+ l1->addWidget(total_bill, 3, 1);
+
+ if(volumeAccountingEnabled) {
+ vollabel->show();
+ volinfo->show();
+ l1->addWidget(vollabel, 4, 0);
+ l1->addWidget(volinfo, 4, 1);
+ } else {
+ vollabel->hide();
+ volinfo->hide();
+ }
+
+ } else {
+ session_bill_l->hide();
+ session_bill->hide();
+ total_bill_l->hide();
+ total_bill->hide();
+
+ if(volumeAccountingEnabled) {
+ vollabel->show();
+ volinfo->show();
+ l1->addWidget(vollabel, 2, 0);
+ l1->addWidget(volinfo, 2, 1);
+ } else {
+ vollabel->hide();
+ volinfo->hide();
+ }
+ }
+
+ tl->addSpacing(10);
+ QVBoxLayout *l2 = new QVBoxLayout(5);
+ tl->addLayout(l2);
+ l2->addStretch(1);
+// l2->addWidget(statsbutton);
+ l2->addWidget(cancelbutton);
+
+ l2->addStretch(1);
+
+ tl1->addSpacing(5);
+
+ setFixedSize(sizeHint());
+/*
+ do not overwrite position read from config
+ setGeometry((QApplication::desktop()->width() - width()) / 2,
+ (QApplication::desktop()->height() - height())/2,
+ width(),
+ height());
+*/
+}
+
+
+void ConWindow::dock() {
+// DockWidget::dock_widget->show();
+ this->hide();
+}
+
+
+void ConWindow::startClock() {
+ minutes = 0;
+ seconds = 0;
+ hours = 0;
+ QString title ;
+
+ title = gpppdata.accname();
+
+ if(gpppdata.get_show_clock_on_caption()){
+ title += " 00:00" ;
+ }
+ this->setCaption(title);
+
+ timelabel2->setText("00:00:00");
+ clocktimer->start(1000);
+}
+
+
+void ConWindow::setConnectionSpeed(const QString &speed) {
+ info2->setText(speed);
+}
+
+
+void ConWindow::stopClock() {
+ clocktimer->stop();
+}
+
+
+void ConWindow::timeclick() {
+ QString tooltip = i18n("Connection: %1\n"
+ "Connected at: %2\n"
+ "Time connected: %3")
+ .arg(gpppdata.accname()).arg(info2->text())
+ .arg(time_string2);
+
+ if(accountingEnabled)
+ tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
+ .arg(session_bill->text()).arg(total_bill->text());
+ // volume accounting
+ if(volumeAccountingEnabled) {
+
+ volinfo->setEnabled(TRUE);
+ int bytes = gpppdata.totalBytes();
+ volinfo->setText(prettyPrintVolume(bytes));
+ }
+
+ seconds++;
+
+ if(seconds >= 60 ) {
+ minutes ++;
+ seconds = 0;
+ }
+
+ if (minutes >= 60){
+ minutes = 0;
+ hours ++;
+ }
+
+ if( hours >= 24){
+ days ++;
+ hours = 0;
+ }
+
+ time_string.sprintf("%02d:%02d",hours,minutes);
+ time_string2 = "";
+ if (days)
+ time_string2.sprintf("%d d %02d:%02d:%02d",
+ days,hours,minutes,seconds);
+
+ else
+ time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
+
+ caption_string = gpppdata.accname();
+ caption_string += " ";
+ caption_string += time_string;
+
+
+ timelabel2->setText(time_string2);
+
+ if(gpppdata.get_show_clock_on_caption() && (seconds == 1)){
+ // we update the Caption only once per minute not every second
+ // otherwise I get a flickering icon
+ this->setCaption(caption_string);
+ }
+
+// QToolTip::add(DockWidget::dock_widget, tooltip);
+}
+
+
+void ConWindow::closeEvent( QCloseEvent *e ){
+ // we don't want to lose the
+ // conwindow since this is our last connection kppp.
+ // if we lost it we could only kill the program by hand to get on with life.
+ e->ignore();
+
+ if(gpppdata.get_dock_into_panel())
+ dock();
+}
+
+
+void ConWindow::slotAccounting(QString total, QString session) {
+ total_bill->setText(total);
+ session_bill->setText(session);
+}
+
+
diff --git a/noncore/settings/networksettings/ppp/conwindow.h b/noncore/settings/networksettings/ppp/conwindow.h
new file mode 100644
index 0000000..20d3579
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/conwindow.h
@@ -0,0 +1,96 @@
+/* -*- C++ -*-
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _CONWINDOW_H_
+#define _CONWINDOW_H_
+
+
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qdialog.h>
+#include <qframe.h>
+#include <qevent.h>
+#include <qlayout.h>
+
+//class PPPStats;
+
+class ConWindow : public QWidget {
+Q_OBJECT
+
+public:
+ ConWindow(QWidget *parent, const char *name, QDialog* );
+ ~ConWindow();
+
+protected:
+ void closeEvent( QCloseEvent *e );
+ bool event( QEvent *e );
+
+private slots:
+ void timeclick();
+ void dock();
+
+public:
+ void setConnectionSpeed(const QString&);
+ void startClock();
+ void stopClock();
+ void accounting(bool); // show/ hide accounting info
+
+public slots:
+ void slotAccounting(QString, QString);
+
+private:
+ QLabel *info1;
+ QLabel *info2;
+ QPushButton *cancelbutton;
+ QPushButton *statsbutton;
+ QString prettyPrintVolume(unsigned int);
+ int minutes;
+ int seconds;
+ int hours;
+ int days;
+ QFrame *fline;
+ QLabel *timelabel1;
+ QLabel *timelabel2;
+ QLabel *total_bill, *total_bill_l;
+ QLabel *session_bill, *session_bill_l;
+ QString caption_string;
+ QString time_string2;
+ QString time_string;
+ QTimer *clocktimer;
+ QVBoxLayout *tl1;
+ QLabel *vollabel;
+ QLabel *volinfo;
+// PPPStats *stats;
+ bool accountingEnabled;
+ bool volumeAccountingEnabled;
+};
+
+
+#endif
+
+
+
+
+
diff --git a/noncore/settings/networksettings/ppp/debug.cpp b/noncore/settings/networksettings/ppp/debug.cpp
new file mode 100644
index 0000000..8652931
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/debug.cpp
@@ -0,0 +1,141 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ * Copyright (C) 1997 Bernd Wuebben
+ * wuebben@math.cornel.edu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "debug.h"
+//#include "main.h"
+#include "pppdata.h"
+//#include <klocale.h>
+#define i18n QObject::tr
+#include "kpppwidget.h"
+#include <assert.h>
+
+extern KPPPWidget *p_kppp;
+
+myMultiEdit::myMultiEdit(QWidget *parent, const char *name)
+ : QMultiLineEdit(parent, name)
+{
+ setReadOnly(true);
+}
+
+void myMultiEdit::insertChar(unsigned char c) {
+ QMultiLineEdit::insert(QChar(c));
+}
+
+
+void myMultiEdit::newLine() {
+ QMultiLineEdit::newLine();
+}
+
+
+DebugWidget::DebugWidget(QWidget *parent, const char *name)
+ : QDialog(parent, name, FALSE)
+{
+ setCaption(i18n("Login Script Debug Window"));
+
+ text_window = new myMultiEdit(this,"debugwindow");
+ text_window->setGeometry(2,5,400, 300);
+ // text_window->setReadOnly(FALSE);
+
+ statuslabel = new QLabel("", this, "statuslabel");
+
+ statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ statuslabel->setAlignment( AlignLeft|AlignVCenter );
+ statuslabel->setGeometry(2, 307, 400, 20);
+ //statusPageLabel->setFont( QFont("helvetica",12,QFont::Normal) );
+
+ dismiss = new QPushButton(this);
+ dismiss->setGeometry(330,340,70,30);
+ dismiss->setText(i18n("Close"));
+ dismiss->setFocus();
+ connect(dismiss, SIGNAL(clicked()), SLOT(hide()));
+
+
+ /* fline = new QFrame(this,"line");
+ fline->setFrameStyle(QFrame::HLine |QFrame::Sunken);
+ fline->setGeometry(2,332,398,5);*/
+ adjustSize();
+ setMinimumSize(width(),height());
+
+}
+
+void DebugWidget::hideEvent(QHideEvent *)
+{
+ assert(p_kppp);
+// p_kppp->con->debug->setOn(false);
+}
+
+void DebugWidget::clear() {
+ text_window->clear();
+}
+
+
+void DebugWidget::addChar(unsigned char c) {
+ QString stuff;
+
+ if(c == '\r' || c == '\n') {
+ if(c == '\n')
+ text_window->newLine();
+ } else
+ text_window->insertChar(c);
+}
+
+
+void DebugWidget::statusLabel(const QString &s) {
+ statuslabel->setText(s);
+}
+
+
+/*
+void DebugWidget::keyPressEvent(QKeyEvent *k) {
+}
+
+*/
+void DebugWidget::resizeEvent(QResizeEvent *e){
+ int w = width() ;
+ int h = height();
+ e = e;
+
+ text_window->setGeometry(2,5,w - 2 ,h - 63);
+ statuslabel->setGeometry(2, h - 56 , w -2 , 20);
+ dismiss->setGeometry(w - 72 , h - 32, 70, 30);
+ // fline->setGeometry(2,h -70 ,w - 4,5);
+}
+
+
+void DebugWidget::enter() {
+ text_window->append("\r\n");
+}
+
+
+void DebugWidget::toggleVisibility() {
+ if(isVisible())
+ hide();
+ else
+ show();
+
+ bool showlog = isVisible();
+ gpppdata.set_show_log_window(showlog);
+}
+
+
+
+
diff --git a/noncore/settings/networksettings/ppp/debug.h b/noncore/settings/networksettings/ppp/debug.h
new file mode 100644
index 0000000..3565cec
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/debug.h
@@ -0,0 +1,70 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ * Copyright (C) 1997 Bernd Wuebben
+ * wuebben@math.cornel.edu
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _DEBUGWIDGET_
+#define _DEBUGWIDGET_
+
+#include <qdialog.h>
+#include <qstring.h>
+#include <qlabel.h>
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+
+
+class myMultiEdit : public QMultiLineEdit {
+public:
+
+ myMultiEdit(QWidget *parent=0, const char *name=0);
+
+ void newLine();
+ void insertChar(unsigned char c);
+};
+
+
+class DebugWidget : public QDialog {
+ Q_OBJECT
+public:
+ DebugWidget(QWidget *parent=0, const char *name=0);
+
+ void clear();
+
+public slots:
+ void statusLabel(const QString &);
+ void toggleVisibility();
+ void addChar(unsigned char);
+
+protected:
+ virtual void hideEvent(QHideEvent *);
+ virtual void resizeEvent(QResizeEvent *e);
+
+private:
+ void enter();
+ QFrame *fline;
+ QPushButton *dismiss;
+ myMultiEdit *text_window;
+
+ QLabel *statuslabel;
+};
+
+#endif
+
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 @@
+/*
+ * kPPP: A pppd Front End for the KDE project
+ *
+ * $Id$
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <string.h>
+#include <termios.h>
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qwhatsthis.h>
+#include <qregexp.h>
+#include <qapplication.h>
+//#include <kiconloader.h>
+#include <qbuttongroup.h>
+//#include <klocale.h>
+#define i18n QObject::tr
+#include <qvgroupbox.h>
+#include <qhbox.h>
+#include <qdialog.h>
+//#include <kwin.h>
+
+#include "edit.h"
+#include "pppdata.h"
+#include "newwidget.h"
+#include "iplined.h"
+#include "auth.h"
+
+DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name)
+{
+ const int GRIDROWS = 6;
+
+ QGridLayout *tl = new QGridLayout(parent, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
+
+ connect_label = new QLabel(i18n("Connection name:"), parent);
+ tl->addWidget(connect_label, 0, 0);
+
+ connectname_l = new QLineEdit(parent);
+ connectname_l->setMaxLength(ACCNAME_SIZE);
+ tl->addWidget(connectname_l, 0, 1);
+ QString tmp = i18n("Type in a unique name for this connection");
+
+ QWhatsThis::add(connect_label,tmp);
+ QWhatsThis::add(connectname_l,tmp);
+
+
+ number_label = new QLabel(i18n("Phone number:"), parent);
+ number_label->setAlignment(AlignTop|AlignLeft);
+ tl->addWidget(number_label, 1, 0);
+
+ QHBoxLayout *lpn = new QHBoxLayout(5);
+ tl->addLayout(lpn, 1, 1);
+ numbers = new QListBox(parent);
+ numbers->setMinimumSize(120, 70);
+ lpn->addWidget(numbers);
+ QVBoxLayout *lpn1 = new QVBoxLayout;
+ lpn->addLayout(lpn1);
+ add = new QPushButton(i18n("&Add..."), parent);
+ del = new QPushButton(i18n("&Remove"), parent);
+
+ up = new QPushButton(parent);
+//FIXME: QPixmap pm = BarIcon("up");
+// up->setPixmap(pm);
+ down = new QPushButton(parent);
+//FIXME: pm = BarIcon("down");
+// down->setPixmap(pm);
+ lpn1->addWidget(add);
+ lpn1->addWidget(del);
+ lpn1->addStretch(1);
+ lpn1->addWidget(up);
+ lpn1->addWidget(down);
+ connect(add, SIGNAL(clicked()),
+ this, SLOT(addNumber()));
+ connect(del, SIGNAL(clicked()),
+ this, SLOT(delNumber()));
+ connect(up, SIGNAL(clicked()),
+ this, SLOT(upNumber()));
+ connect(down, SIGNAL(clicked()),
+ this, SLOT(downNumber()));
+ connect(numbers, SIGNAL(highlighted(int)),
+ this, SLOT(selectionChanged(int)));
+ numbersChanged();
+
+ tmp = i18n("<p>Specifies the phone numbers to dial. You\n"
+ "can supply multiple numbers here, simply\n"
+ "click on \"Add\". You can arrange the\n"
+ "order the numbers are tried by using the\n"
+ "arrow buttons.\n\n"
+ "When a number is busy or fails, <i>kppp</i> will \n"
+ "try the next number and so on");
+
+ QWhatsThis::add(number_label,tmp);
+ QWhatsThis::add(numbers,tmp);
+
+ auth_l = new QLabel(i18n("Authentication:"), parent);
+ tl->addWidget(auth_l, 3, 0);
+
+ auth = new QComboBox(parent);
+ auth->insertItem(i18n("Script-based"));
+ auth->insertItem(i18n("PAP"));
+ auth->insertItem(i18n("Terminal-based"));
+ auth->insertItem(i18n("CHAP"));
+ auth->insertItem(i18n("PAP/CHAP"));
+ tl->addWidget(auth, 3, 1);
+ tmp = i18n("<p>Specifies the method used to identify yourself to\n"
+ "the PPP server. Most universities still use\n"
+ "<b>Terminal</b>- or <b>Script</b>-based authentication,\n"
+ "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n"
+ "unsure, contact your ISP.\n"
+ "\n"
+ "If you can choose between PAP and CHAP,\n"
+ "choose CHAP, because it's much safer. If you don't know\n"
+ "whether PAP or CHAP is right, choose PAP/CHAP.");
+
+ QWhatsThis::add(auth_l,tmp);
+ QWhatsThis::add(auth,tmp);
+
+ store_password = new QCheckBox(i18n("Store password"), parent);
+ store_password->setChecked(true);
+ tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight);
+ QWhatsThis::add(store_password,
+ i18n("<p>When this is turned on, your ISP password\n"
+ "will be saved in <i>kppp</i>'s config file, so\n"
+ "you do not need to type it in every time.\n"
+ "\n"
+ "<b><font color=\"red\">Warning:</font> your password will be stored as\n"
+ "plain text in the config file, which is\n"
+ "readable only to you. Make sure nobody\n"
+ "gains access to this file!"));
+
+ pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), parent);
+ connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
+ tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
+
+ // Set defaults if editing an existing connection
+ if(!isnewaccount) {
+ connectname_l->setText(gpppdata.accname());
+
+ // insert the phone numbers into the listbox
+ QString n = gpppdata.phonenumber();
+ QString tmp = "";
+ uint idx = 0;
+ while(idx != n.length()) {
+ if(n[idx] == ':') {
+ if(tmp.length() > 0)
+ numbers->insertItem(tmp);
+ tmp = "";
+ } else
+ tmp += n[idx];
+ idx++;
+ }
+ if(tmp.length() > 0)
+ numbers->insertItem(tmp);
+
+ auth->setCurrentItem(gpppdata.authMethod());
+ store_password->setChecked(gpppdata.storePassword());
+ } else {
+ // select PAP/CHAP as default
+ auth->setCurrentItem(AUTH_PAPCHAP);
+ }
+
+ numbersChanged();
+ tl->activate();
+}
+
+
+bool DialWidget::save() {
+ //first check to make sure that the account name is unique!
+ if(connectname_l->text().isEmpty() ||
+ !gpppdata.isUniqueAccname(connectname_l->text())) {
+ return false;
+ } else {
+ gpppdata.setAccname(connectname_l->text());
+
+ QString number = "";
+ for(uint i = 0; i < numbers->count(); i++) {
+ if(i != 0)
+ number += ":";
+ number += numbers->text(i);
+ }
+
+ gpppdata.setPhonenumber(number);
+ gpppdata.setAuthMethod(auth->currentItem());
+ gpppdata.setStorePassword(store_password->isChecked());
+ return true;
+ }
+}
+
+
+void DialWidget::numbersChanged() {
+ int sel = numbers->currentItem();
+
+ del->setEnabled(sel != -1);
+ up->setEnabled(sel != -1 && sel != 0);
+ down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
+}
+
+
+void DialWidget::selectionChanged(int) {
+ numbersChanged();
+}
+
+
+void DialWidget::addNumber() {
+ PhoneNumberDialog dlg(this);
+ if(dlg.exec()) {
+ numbers->insertItem(dlg.phoneNumber());
+ numbersChanged();
+ }
+}
+
+
+void DialWidget::delNumber() {
+ if(numbers->currentItem() != -1) {
+ numbers->removeItem(numbers->currentItem());
+ numbersChanged();
+ }
+}
+
+
+void DialWidget::upNumber() {
+ int idx = numbers->currentItem();
+ if(idx != -1) {
+ QString item = numbers->text(idx);
+ numbers->removeItem(idx);
+ numbers->insertItem(item, idx-1);
+ numbers->setCurrentItem(idx-1);
+ numbersChanged();
+ }
+}
+
+
+void DialWidget::downNumber() {
+ int idx = numbers->currentItem();
+ if(idx != -1) {
+ QString item = numbers->text(idx);
+ numbers->removeItem(idx);
+ numbers->insertItem(item, idx+1);
+ numbers->setCurrentItem(idx+1);
+ numbersChanged();
+ }
+}
+
+
+void DialWidget::pppdargsbutton() {
+ PPPdArguments pa(this);
+ pa.exec();
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// ExecWidget
+/////////////////////////////////////////////////////////////////////////////
+ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) :
+ QWidget(parent, name)
+{
+ QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint());
+
+ QLabel *l = new QLabel(\
+i18n("Here you can select commands to run at certain stages of the\n"
+ "connection. The commands are run with your real user id, so\n"
+ "you cannot run any commands here requiring root permissions\n"
+ "(unless, of course, you are root).\n\n"
+ "Be sure to supply the whole path to the program otherwise\n"
+ "kppp might be unable to find it."), parent);
+ l->setMinimumHeight(l->sizeHint().height());
+ tl->addWidget(l);
+ tl->addStretch(1);
+
+ QGridLayout *l1 = new QGridLayout(4, 2, 10);
+ tl->addLayout(l1);
+ l1->setColStretch(0, 0);
+ l1->setColStretch(1, 1);
+
+ before_connect_l = new QLabel(i18n("Before connect:"), parent);
+ before_connect_l->setAlignment(AlignVCenter);
+ l1->addWidget(before_connect_l, 0, 0);
+ before_connect = new QLineEdit(parent);
+ before_connect->setMaxLength(COMMAND_SIZE);
+ l1->addWidget(before_connect, 0, 1);
+ QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
+ "is established. It is called immediately before\n"
+ "dialing has begun.\n\n"
+ "This might be useful, e.g. to stop HylaFAX blocking the\n"
+ "modem.");
+
+ QWhatsThis::add(before_connect_l,tmp);
+ QWhatsThis::add(before_connect,tmp);
+
+ command_label = new QLabel(i18n("Upon connect:"), parent);
+ command_label->setAlignment(AlignVCenter);
+ l1->addWidget(command_label, 1, 0);
+ command = new QLineEdit(parent);
+ command->setMaxLength(COMMAND_SIZE);
+ l1->addWidget(command, 1, 1);
+ tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
+ "is established. When your program is called, all\n"
+ "preparations for an Internet connection are finished.\n"
+ "\n"
+ "Very useful for fetching mail and news");
+
+ QWhatsThis::add(command_label,tmp);
+ QWhatsThis::add(command,tmp);
+
+ predisconnect_label = new QLabel(i18n("Before disconnect:"),
+ parent);
+ predisconnect_label->setAlignment(AlignVCenter);
+ l1->addWidget(predisconnect_label, 2, 0);
+ predisconnect = new QLineEdit(parent);
+ predisconnect->setMaxLength(COMMAND_SIZE);
+ l1->addWidget(predisconnect, 2, 1);
+ tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
+ "is closed. The connection will stay open until\n"
+ "the program exits.");
+
+ QWhatsThis::add(predisconnect_label,tmp);
+ QWhatsThis::add(predisconnect,tmp);
+
+ discommand_label = new QLabel(i18n("Upon disconnect:"),
+ parent);
+ discommand_label->setAlignment(AlignVCenter);
+ l1->addWidget(discommand_label, 3, 0);
+
+ discommand = new QLineEdit(parent);
+ discommand->setMaxLength(COMMAND_SIZE);
+ l1->addWidget(discommand, 3, 1);
+ tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
+ "has been closed.");
+
+ QWhatsThis::add(discommand_label,tmp);
+ QWhatsThis::add(discommand,tmp);
+
+ // extra space between entries
+ l1->addRowSpacing(1, 5);
+ l1->addRowSpacing(3, 5);
+
+ tl->addStretch(1);
+ tl->activate();
+
+ // Set defaults if editing an existing connection
+ if(!isnewaccount) {
+ before_connect->setText(gpppdata.command_before_connect());
+ command->setText(gpppdata.command_on_connect());
+ discommand->setText(gpppdata.command_on_disconnect());
+ predisconnect->setText(gpppdata.command_before_disconnect());
+ }
+}
+
+
+bool ExecWidget::save() {
+ gpppdata.setCommand_before_connect(before_connect->text());
+ gpppdata.setCommand_on_connect(command->text());
+ gpppdata.setCommand_before_disconnect(predisconnect->text());
+ gpppdata.setCommand_on_disconnect(discommand->text());
+ return true;
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// IPWidget
+//
+/////////////////////////////////////////////////////////////////////////////
+IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name)
+{
+ QVBoxLayout *topLayout = new QVBoxLayout(parent);
+ topLayout->setSpacing( 3 );//KDialog::spacingHint());
+
+ box = new QVGroupBox(i18n("Configuration"), parent);
+// box->setInsideSpacing( 1 );//KDialog::spacingHint());
+
+ rb = new QButtonGroup(parent);
+ rb->hide();
+ connect(rb, SIGNAL(clicked(int)),
+ SLOT(hitIPSelect(int)));
+
+ dynamicadd_rb = new QRadioButton(box);
+ dynamicadd_rb->setText(i18n("Dynamic IP address"));
+ QWhatsThis::add(dynamicadd_rb,
+ i18n("Select this option when your computer gets an\n"
+ "internet address (IP) every time a\n"
+ "connection is made.\n"
+ "\n"
+ "Almost every Internet Service Provider uses\n"
+ "this method, so this should be turned on."));
+
+ staticadd_rb = new QRadioButton(box);
+ staticadd_rb->setText(i18n("Static IP address"));
+ rb->insert(dynamicadd_rb, 0);
+ rb->insert(staticadd_rb, 1);
+ QWhatsThis::add(staticadd_rb,
+ i18n("Select this option when your computer has a\n"
+ "fixed internet address (IP). Most computers\n"
+ "don't have this, so you should probably select\n"
+ "dynamic IP addressing unless you know what you\n"
+ "are doing."));
+
+ QWidget *ipWidget = new QWidget(box);
+ QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
+ ipLayout->setSpacing( 2 );//KDialog::spacingHint());
+
+ ipaddress_label = new QLabel(i18n("IP address:"), ipWidget);
+ QString tmp = i18n("If your computer has a permanent internet\n"
+ "address, you must supply your IP address here.");
+ ipLayout->addWidget(ipaddress_label, 0, 0);
+
+ ipaddress_l = new IPLineEdit(ipWidget);
+ ipLayout->addWidget(ipaddress_l, 0, 1);
+
+ QWhatsThis::add(ipaddress_label,tmp);
+ QWhatsThis::add(ipaddress_l,tmp);
+
+ sub_label = new QLabel(i18n("Subnet mask:"), ipWidget);
+ tmp = i18n("<p>If your computer has a static Internet address,\n"
+ "you must supply a network mask here. In almost\n"
+ "all cases this netmask will be <b>255.255.255.0</b>,\n"
+ "but your mileage may vary.\n"
+ "\n"
+ "If unsure, contact your Internet Service Provider");
+ ipLayout->addWidget(sub_label, 1, 0);
+
+ subnetmask_l = new IPLineEdit(ipWidget);
+ ipLayout->addWidget(subnetmask_l, 1, 1);
+
+ QWhatsThis::add(sub_label,tmp);
+ QWhatsThis::add(subnetmask_l,tmp);
+
+ autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), parent);
+ autoname->setChecked(gpppdata.autoname());
+ connect(autoname,SIGNAL(toggled(bool)),
+ this,SLOT(autoname_t(bool)));
+
+ QWhatsThis::add(autoname,
+ i18n("<p>Whenever you connect, this reconfigures\n"
+ "your hostname to match the IP address you\n"
+ "got from the PPP server. This may be useful\n"
+ "if you need to use a protocol which depends\n"
+ "on this information, but it can also cause several\n"
+ "<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
+ "\n"
+ "Don't enable this unless you really need it."));
+
+ topLayout->addWidget(box);
+ topLayout->addWidget(autoname);
+ topLayout->addStretch();
+
+ //load info from gpppdata
+ if(!isnewaccount) {
+ if(gpppdata.ipaddr() == "0.0.0.0" &&
+ gpppdata.subnetmask() == "0.0.0.0") {
+ dynamicadd_rb->setChecked(true);
+ hitIPSelect(0);
+ autoname->setChecked(gpppdata.autoname());
+ }
+ else {
+ ipaddress_l->setText(gpppdata.ipaddr());
+ subnetmask_l->setText(gpppdata.subnetmask());
+ staticadd_rb->setChecked(true);
+ autoname->setChecked(false);
+ }
+ }
+ else {
+ dynamicadd_rb->setChecked(true);
+ hitIPSelect(0);
+ }
+
+}
+
+void IPWidget::autoname_t(bool on) {
+ static bool was_warned = false;
+
+ // big-fat warning when selecting the auto configure hostname option
+ if(on && !was_warned) {
+ QMessageBox::information(this,
+ i18n("Selecting this option might cause some weird "
+ "problems with the X-server and applications "
+ "while kppp is connected. Don't use it until "
+ "you know what you are doing!\n"
+ "For more information take a look at the "
+ "handbook (or help) in the section \"Frequently "
+ "asked questions\"."),
+ i18n("Warning"));
+ was_warned = true;
+ }
+}
+
+
+void IPWidget::save() {
+ if(dynamicadd_rb->isChecked()) {
+ gpppdata.setIpaddr("0.0.0.0");
+ gpppdata.setSubnetmask("0.0.0.0");
+ } else {
+ gpppdata.setIpaddr(ipaddress_l->text());
+ gpppdata.setSubnetmask(subnetmask_l->text());
+ }
+ gpppdata.setAutoname(autoname->isChecked());
+}
+
+
+void IPWidget::hitIPSelect( int i ) {
+ if(i == 0) {
+ ipaddress_label->setEnabled(false);
+ sub_label->setEnabled(false);
+ ipaddress_l->setEnabled(false);
+ subnetmask_l->setEnabled(false);
+ }
+ else {
+ ipaddress_label->setEnabled(true);
+ sub_label->setEnabled(true);
+ ipaddress_l->setEnabled(true);
+ subnetmask_l->setEnabled(true);
+ }
+}
+
+
+
+DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name)
+{
+ // box = new QGroupBox(parent);
+ QGridLayout *tl = new QGridLayout(parent, 7, 2, 0 );//, KDialog::spacingHint());
+
+ dnsdomain_label = new QLabel(i18n("Domain name:"), parent);
+ tl->addWidget(dnsdomain_label, 0, 0);
+
+ dnsdomain = new QLineEdit(parent);
+ dnsdomain->setMaxLength(DOMAIN_SIZE);
+ tl->addWidget(dnsdomain, 0, 1);
+ QString tmp = i18n("If you enter a domain name here, this domain\n"
+ "name is used for your computer while you are\n"
+ "connected. When the connection is closed, the\n"
+ "original domain name of your computer is\n"
+ "restored.\n"
+ "\n"
+ "If you leave this field blank, no changes are\n"
+ "made to the domain name.");
+
+ QWhatsThis::add(dnsdomain_label,tmp);
+ QWhatsThis::add(dnsdomain,tmp);
+
+ conf_label = new QLabel(i18n("Configuration:"), parent);
+ tl->addWidget(conf_label, 1, 0);
+
+ bg = new QButtonGroup("Group", this);
+ connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
+ bg->hide();
+
+ autodns = new QRadioButton(i18n("Automatic"), parent);
+ bg->insert(autodns, 0);
+ tl->addWidget(autodns, 1, 1);
+ // no automatic DNS detection for pppd < 2.3.7
+ if(!gpppdata.pppdVersionMin(2, 3, 7))
+ autodns->setEnabled(false);
+
+ mandns = new QRadioButton(i18n("Manual"), parent);
+ bg->insert(mandns, 1);
+ tl->addWidget(mandns, 2, 1);
+
+ dns_label = new QLabel(i18n("DNS IP address:"), parent);
+ tl->addWidget(dns_label, 3, 0);
+
+ QHBoxLayout *l2 = new QHBoxLayout;
+ tl->addLayout(l2, 3, 1);
+ dnsipaddr = new IPLineEdit(parent);
+ connect(dnsipaddr, SIGNAL(returnPressed()),
+ SLOT(adddns()));
+ connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
+ SLOT(DNS_Edit_Changed(const QString &)));
+ l2->addWidget(dnsipaddr, 1);
+ l2->addStretch(1);
+ tmp = i18n("<p>Allows you to specify a new DNS server to be\n"
+ "used while you are connected. When the\n"
+ "connection is closed, this DNS entry will be\n"
+ "removed again.\n"
+ "\n"
+ "To add a DNS server, type in the IP address of\n"
+ "the DNS server here and click on <b>Add</b>");
+
+ QWhatsThis::add(dns_label, tmp);
+ QWhatsThis::add(dnsipaddr, tmp);
+
+ QHBoxLayout *l1 = new QHBoxLayout;
+ tl->addLayout(l1, 4, 1);
+ add = new QPushButton(i18n("Add"), parent);
+ connect(add, SIGNAL(clicked()), SLOT(adddns()));
+ int width = add->sizeHint().width();
+ width = QMAX(width,60);
+ add->setMinimumWidth(width);
+ l1->addWidget(add);
+ l1->addStretch(1);
+ QWhatsThis::add(add,
+ i18n("Click this button to add the DNS server\n"
+ "specified in the field above. The entry\n"
+ "will then be added to the list below"));
+
+ remove = new QPushButton(i18n("Remove"), parent);
+ connect(remove, SIGNAL(clicked()), SLOT(removedns()));
+ width = remove->sizeHint().width();
+ width = QMAX(width,60);
+ remove->setMinimumWidth(width);
+ l1->addWidget(remove);
+ QWhatsThis::add(remove,
+ i18n("Click this button to remove the selected DNS\n"
+ "server entry from the list below"));
+
+ servers_label = new QLabel(i18n("DNS address list:"), parent);
+ servers_label->setAlignment(AlignTop|AlignLeft);
+ tl->addWidget(servers_label, 5, 0);
+
+ dnsservers = new QListBox(parent);
+ dnsservers->setMinimumSize(150, 80);
+ connect(dnsservers, SIGNAL(highlighted(int)),
+ SLOT(DNS_Entry_Selected(int)));
+ tl->addWidget(dnsservers, 5, 1);
+ tmp = i18n("<p>This shows all defined DNS servers to use\n"
+ "while you are connected. Use the <b>Add</b> and\n"
+ "<b>Remove</b> buttons to modify the list");
+
+ QWhatsThis::add(servers_label,tmp);
+ QWhatsThis::add(dnsservers,tmp);
+
+ exdnsdisabled_toggle = new QCheckBox(i18n( \
+"Disable existing DNS servers during connection"),
+ parent);
+ exdnsdisabled_toggle->setChecked(gpppdata.exDNSDisabled());
+ tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
+ QWhatsThis::add(exdnsdisabled_toggle,
+ i18n("<p>When this option is selected, all DNS\n"
+ "servers specified in <tt>/etc/resolv.conf</tt> are\n"
+ "temporary disabled while the dialup connection\n"
+ "is established. After the connection is\n"
+ "closed, the servers will be re-enabled\n"
+ "\n"
+ "Typically, there is no reason to use this\n"
+ "option, but it may become useful under \n"
+ "some circumstances."));
+
+
+ // restore data if editing
+ if(!isnewaccount) {
+ dnsservers->insertStringList(gpppdata.dns());
+ dnsdomain->setText(gpppdata.domain());
+ }
+
+ int mode = gpppdata.autoDNS() ? 0 : 1;
+ bg->setButton(mode);
+ DNS_Mode_Selected(mode);
+
+ tl->activate();
+}
+
+void DNSWidget::DNS_Edit_Changed(const QString &text) {
+ QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
+ add->setEnabled(text.find(r) != -1);
+}
+
+void DNSWidget::DNS_Entry_Selected(int) {
+ remove->setEnabled(true);
+}
+
+void DNSWidget::DNS_Mode_Selected(int mode) {
+ bool on = (mode == 1);
+ dns_label->setEnabled(on);
+ servers_label->setEnabled(on);
+ dnsipaddr->setText("");
+ dnsipaddr->setEnabled(on);
+ add->setEnabled(false);
+ remove->setEnabled(dnsservers->count()>0 && on);
+ dnsservers->clearSelection();
+ dnsservers->setEnabled(on);
+ dnsservers->triggerUpdate(false);
+}
+
+void DNSWidget::save() {
+ gpppdata.setAutoDNS(bg->id(bg->selected()) == 0);
+ QStringList serverlist;
+ for(uint i=0; i < dnsservers->count(); i++)
+ serverlist.append(dnsservers->text(i));
+ gpppdata.setDns(serverlist);
+
+ // strip leading dot
+ QString s(dnsdomain->text());
+ if(s.left(1) == ".")
+ gpppdata.setDomain(s.mid(1));
+ else
+ gpppdata.setDomain(dnsdomain->text());
+
+ gpppdata.setExDNSDisabled(exdnsdisabled_toggle->isChecked());
+}
+
+
+void DNSWidget::adddns() {
+ if(dnsservers->count() < MAX_DNS_ENTRIES) {
+ dnsservers->insertItem(dnsipaddr->text());
+ dnsipaddr->setText("");
+ }
+}
+
+
+void DNSWidget::removedns() {
+ int i;
+ i = dnsservers->currentItem();
+ if(i != -1)
+ dnsservers->removeItem(i);
+ remove->setEnabled(dnsservers->count()>0);
+}
+
+
+//
+// GatewayWidget
+//
+GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name)
+{
+ QVBoxLayout *topLayout = new QVBoxLayout(parent);
+ topLayout->setSpacing( 2 );//KDialog::spacingHint());
+
+ box = new QVGroupBox(i18n("Configuration"), parent);
+// box->setInsideSpacing( 2 );//KDialog::spacingHint());
+
+ rb = new QButtonGroup(parent);
+ rb->hide();
+ connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
+
+ defaultgateway = new QRadioButton(box);
+ defaultgateway->setText(i18n("Default gateway"));
+ rb->insert(defaultgateway, 0);
+ QWhatsThis::add(defaultgateway,
+ i18n("This makes the PPP peer computer (the computer\n"
+ "you are connected to with your modem) to act as\n"
+ "a gateway. Your computer will send all packets not\n"
+ "going to a computer inside your local net to this\n"
+ "computer, which will route these packets.\n"
+ "\n"
+ "This is the default for most ISPs, so you should\n"
+ "probably leave this option on."));
+
+
+ staticgateway = new QRadioButton(box);
+ staticgateway->setText(i18n("Static gateway"));
+ rb->insert(staticgateway, 1);
+ QWhatsThis::add(staticgateway,
+ i18n("<p>Allows you to specify which computer you want\n"
+ "to use as gateway (see <i>Default Gateway</i> above)"));
+
+ QHBox *gateBox = new QHBox(box);
+ gate_label = new QLabel(i18n("Gateway IP address:"), gateBox);
+ gatewayaddr = new IPLineEdit(gateBox);
+
+ defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"),
+ parent);
+ QWhatsThis::add(defaultroute,
+ i18n("If this option is enabled, all packets not\n"
+ "going to the local net are routed through\n"
+ "the PPP connection.\n"
+ "\n"
+ "Normally, you should turn this on"));
+
+ topLayout->addWidget(box);
+ topLayout->addWidget(defaultroute);
+ topLayout->addStretch();
+
+ //load info from gpppdata
+ if(!isnewaccount) {
+ if(gpppdata.gateway() == "0.0.0.0") {
+ defaultgateway->setChecked(true);
+ hitGatewaySelect(0);
+ }
+ else {
+ gatewayaddr->setText(gpppdata.gateway());
+ staticgateway->setChecked(true);
+ }
+ defaultroute->setChecked(gpppdata.defaultroute());
+ }
+ else {
+ defaultgateway->setChecked(true);
+ hitGatewaySelect(0);
+ defaultroute->setChecked(true);
+ }
+}
+
+void GatewayWidget::save() {
+ gpppdata.setGateway(gatewayaddr->text());
+ gpppdata.setDefaultroute(defaultroute->isChecked());
+}
+
+
+void GatewayWidget::hitGatewaySelect( int i ) {
+ if(i == 0) {
+ gatewayaddr->setText("0.0.0.0");
+ gatewayaddr->setEnabled(false);
+ gate_label->setEnabled(false);
+ }
+ else {
+ gatewayaddr->setEnabled(true);
+ gatewayaddr->setText("");
+ gate_label->setEnabled(true);
+ }
+}
+
+
+
+ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name)
+{
+ QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint());
+ se = new ScriptEdit(parent);
+ connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
+ tl->addWidget(se);
+
+ // insert equal-sized buttons
+ QButtonGroup *bbox = new QButtonGroup(parent);
+ add = new QPushButton( bbox, i18n("Add") );
+ bbox->insert(add);
+ connect(add, SIGNAL(clicked()), SLOT(addButton()));
+// bbox->addStretch(1);
+ insert = new QPushButton( bbox, i18n("Insert") );
+ bbox->insert(insert);
+ connect(insert, SIGNAL(clicked()), SLOT(insertButton()));
+// bbox->addStretch(1);
+ remove = new QPushButton( bbox, i18n("Remove") );
+ bbox->insert(remove);
+ connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
+ bbox->layout();
+ tl->addWidget(bbox);
+
+ QHBoxLayout *l12 = new QHBoxLayout(0);
+ tl->addLayout(l12);
+ stl = new QListBox(parent);
+ stl->setVScrollBarMode( QScrollView::AlwaysOff );
+ connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
+ stl->setMinimumSize(QSize(70, 140));
+
+ sl = new QListBox(parent);
+ sl->setVScrollBarMode( QScrollView::AlwaysOff );
+ connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
+ sl->setMinimumSize(QSize(150, 140));
+
+ slb = new QScrollBar(parent);
+ slb->setFixedWidth(slb->sizeHint().width());
+ connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
+
+ l12->addWidget(stl, 1);
+ l12->addWidget(sl, 3);
+ l12->addWidget(slb, 0);
+
+ //load data from gpppdata
+ if(!isnewaccount) {
+ QStringList &comlist = gpppdata.scriptType();
+ QStringList &arglist = gpppdata.script();
+ QStringList::Iterator itcom = comlist.begin();
+ QStringList::Iterator itarg = arglist.begin();
+
+ for ( ;
+ itcom != comlist.end() && itarg != arglist.end();
+ ++itcom, ++itarg )
+ {
+ stl->insertItem(*itcom);
+ sl->insertItem(*itarg);
+ }
+ }
+
+ insert->setEnabled(false);
+ remove->setEnabled(false);
+ adjustScrollBar();
+ tl->activate();
+}
+
+bool ScriptWidget::check() {
+ uint lstart = 0;
+ uint lend = 0;
+ uint errcnt = 0;
+
+ if(sl->count() > 0) {
+ for( uint i=0; i <= sl->count()-1; i++) {
+ if(stl->text(i) == "LoopStart") {
+ lstart++;
+ }
+ if (stl->text(i) == "LoopEnd") {
+ lend++;
+ }
+ if ( lend > lstart ) errcnt++;
+ }
+ return ( (errcnt == 0 ) && (lstart == lend) );
+ }
+ return true;
+}
+
+
+void ScriptWidget::save() {
+ QStringList typelist, arglist;
+ for(uint i=0; i < sl->count(); i++) {
+ typelist.append(stl->text(i));
+ arglist.append(sl->text(i));
+ }
+ gpppdata.setScriptType(typelist);
+ gpppdata.setScript(arglist);
+}
+
+
+
+void ScriptWidget::adjustScrollBar() {
+ if((int)sl->count() <= sl->numItemsVisible())
+ slb->setRange(0, 0);
+ else
+ slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
+}
+
+
+void ScriptWidget::scrolling(int i) {
+ sl->setTopItem(i);
+ stl->setTopItem(i);
+}
+
+
+void ScriptWidget::slhighlighted(int i) {
+ insert->setEnabled(true);
+ remove->setEnabled(true);
+ stl->setCurrentItem(i);
+}
+
+
+void ScriptWidget::stlhighlighted(int i) {
+ insert->setEnabled(true);
+ remove->setEnabled(true);
+ sl->setCurrentItem(i);
+}
+
+
+void ScriptWidget::addButton() {
+ //don't allow more than the maximum script entries
+ if(sl->count() == MAX_SCRIPT_ENTRIES-1)
+ return;
+
+ switch(se->type()) {
+ case ScriptEdit::Expect:
+ stl->insertItem("Expect");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Send:
+ stl->insertItem("Send");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::SendNoEcho:
+ stl->insertItem("SendNoEcho");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Pause:
+ stl->insertItem("Pause");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Hangup:
+ stl->insertItem("Hangup");
+ sl->insertItem("");
+ break;
+
+ case ScriptEdit::Answer:
+ stl->insertItem("Answer");
+ sl->insertItem("");
+ break;
+
+ case ScriptEdit::Timeout:
+ stl->insertItem("Timeout");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Password:
+ stl->insertItem("Password");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::ID:
+ stl->insertItem("ID");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Prompt:
+ stl->insertItem("Prompt");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::PWPrompt:
+ stl->insertItem("PWPrompt");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::LoopStart:
+ stl->insertItem("LoopStart");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::LoopEnd:
+ stl->insertItem("LoopEnd");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Scan:
+ stl->insertItem("Scan");
+ sl->insertItem(se->text());
+ break;
+
+ case ScriptEdit::Save:
+ stl->insertItem("Save");
+ sl->insertItem(se->text());
+ break;
+
+ default:
+ break;
+ }
+
+ //get the scrollbar adjusted, and scroll the list so we can see what
+ //we're adding to
+ adjustScrollBar();
+ slb->setValue(slb->maxValue());
+
+ //clear the text in the entry box
+ se->setText("");
+}
+
+
+void ScriptWidget::insertButton() {
+ //exit if there is no highlighted item, or we've reached the
+ //maximum entries in the script list
+ if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1))
+ return;
+
+ switch(se->type()) {
+ case ScriptEdit::Expect:
+ stl->insertItem("Expect", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Send:
+ stl->insertItem("Send", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::SendNoEcho:
+ stl->insertItem("SendNoEcho", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Pause:
+ stl->insertItem("Pause", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Hangup:
+ stl->insertItem("Hangup", stl->currentItem());
+ sl->insertItem("", sl->currentItem());
+ break;
+
+ case ScriptEdit::Answer:
+ stl->insertItem("Answer", stl->currentItem());
+ sl->insertItem("", sl->currentItem());
+ break;
+
+ case ScriptEdit::Timeout:
+ stl->insertItem("Timeout", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Password:
+ stl->insertItem("Password", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::ID:
+ stl->insertItem("ID", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Prompt:
+ stl->insertItem("Prompt", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::PWPrompt:
+ stl->insertItem("PWPrompt", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::LoopStart:
+ stl->insertItem("LoopStart", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::LoopEnd:
+ stl->insertItem("LoopEnd", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Scan:
+ stl->insertItem("Scan", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ case ScriptEdit::Save:
+ stl->insertItem("Save", stl->currentItem());
+ sl->insertItem(se->text(), sl->currentItem());
+ break;
+
+ default:
+ break;
+ }
+ adjustScrollBar();
+ se->setText("");
+}
+
+
+void ScriptWidget::removeButton() {
+ if(sl->currentItem() >= 0) {
+ int stlc = stl->currentItem();
+ sl->removeItem(sl->currentItem());
+ stl->removeItem(stlc);
+ adjustScrollBar();
+ insert->setEnabled(sl->currentItem() != -1);
+ remove->setEnabled(sl->currentItem() != -1);
+ }
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Used to specify a new phone number
+//
+/////////////////////////////////////////////////////////////////////////////
+PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
+ : QDialog(parent, 0, true ) {
+ setCaption( i18n("Add Phone Number") );
+// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+
+ QHBox *hbox = new QHBox(this);
+// setMainWidget(hbox);
+
+ hbox->setSpacing( 2 );//KDialog::spacingHint());
+
+ new QLabel(i18n("Enter a phone number:"), hbox);
+
+ le = newLineEdit(14, hbox);
+ le->setMinimumWidth(125);
+
+ connect(le, SIGNAL(textChanged(const QString &)),
+ this, SLOT(textChanged(const QString &)));
+
+ le->setFocus();
+ textChanged("");
+
+// enableButtonSeparator(true);
+}
+
+
+QString PhoneNumberDialog::phoneNumber() {
+ QString s = le->text();
+
+ return s;
+}
+
+
+void PhoneNumberDialog::textChanged(const QString &s) {
+// enableButtonOK(s.length() > 0);
+}
+
+
+//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h
new file mode 100644
index 0000000..cd0161f
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/edit.h
@@ -0,0 +1,251 @@
+/* -*- C++ -*-
+ *
+ * kPPP: A pppd Front End for the KDE project
+ *
+ * $Id$
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef _EDIT_H_
+#define _EDIT_H_
+
+#include <qdialog.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+#include <qvgroupbox.h>
+#include <qscrollbar.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+//#include <kdialogbase.h>
+#include "scriptedit.h"
+#include "kpppconfig.h"
+#include "pppdargs.h"
+
+class IPLineEdit;
+
+class DialWidget : public QWidget {
+ Q_OBJECT
+public:
+ DialWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~DialWidget() {}
+
+public slots:
+ bool save();
+ void pppdargsbutton();
+ void numbersChanged();
+ void selectionChanged(int);
+ void addNumber();
+ void delNumber();
+ void upNumber();
+ void downNumber();
+
+private:
+ QLineEdit *connectname_l;
+ QLabel *connect_label;
+ QLabel *number_label;
+ QPushButton *pppdargs;
+ QComboBox *auth;
+ QLabel *auth_l;
+ QCheckBox *store_password;
+
+ // for the phonenumber selection
+ QPushButton *add, *del, *up, *down;
+ QListBox *numbers;
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// tab-window to select what to execute when
+//
+/////////////////////////////////////////////////////////////////////////////
+class ExecWidget : public QWidget {
+ Q_OBJECT
+public:
+ ExecWidget(QWidget *parent=0, bool isnewaccount=true, const char *name=0);
+
+public slots:
+ bool save();
+
+private:
+ QLineEdit *before_connect;
+ QLabel *before_connect_l;
+
+ QLineEdit *command;
+ QLabel *command_label;
+
+ QLineEdit *predisconnect;
+ QLabel *predisconnect_label;
+
+ QLineEdit *discommand;
+ QLabel *discommand_label;
+};
+
+
+class IPWidget : public QWidget {
+ Q_OBJECT
+public:
+ IPWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~IPWidget() {}
+
+public slots:
+ void save();
+
+protected slots:
+ void hitIPSelect( int );
+ void autoname_t(bool on);
+
+private:
+ QLabel *ipaddress_label;
+ QLabel *sub_label;
+ QGroupBox *box1;
+ QVGroupBox *box;
+
+ QButtonGroup *rb;
+ QRadioButton *dynamicadd_rb;
+ QRadioButton *staticadd_rb;
+
+ IPLineEdit *ipaddress_l;
+ IPLineEdit *subnetmask_l;
+
+ QCheckBox *autoname;
+};
+
+
+class DNSWidget : public QWidget {
+ Q_OBJECT
+public:
+ DNSWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~DNSWidget() {}
+
+public slots:
+ void save();
+
+protected slots:
+ void adddns();
+ void removedns();
+ void DNS_Edit_Changed(const QString &);
+ void DNS_Entry_Selected(int);
+ void DNS_Mode_Selected(int);
+
+private:
+ QLabel *conf_label;
+ QButtonGroup *bg;
+ QRadioButton *autodns, *mandns;
+ QLabel *dns_label;
+ QLabel *servers_label;
+ IPLineEdit *dnsipaddr;
+ QPushButton *add;
+ QPushButton *remove;
+ QListBox *dnsservers;
+ QLineEdit *dnsdomain;
+ QLabel *dnsdomain_label;
+ QCheckBox *exdnsdisabled_toggle;
+};
+
+
+class GatewayWidget : public QWidget {
+ Q_OBJECT
+public:
+ GatewayWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~GatewayWidget() {}
+
+public slots:
+ void save();
+
+private slots:
+ void hitGatewaySelect( int );
+
+private:
+ QGroupBox *box;
+ QLabel *gate_label;
+ QGroupBox *box1;
+ QButtonGroup *rb;
+ QRadioButton *defaultgateway;
+ QRadioButton *staticgateway;
+ IPLineEdit *gatewayaddr;
+ QCheckBox *defaultroute;
+};
+
+
+class ScriptWidget : public QWidget {
+ Q_OBJECT
+public:
+ ScriptWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~ScriptWidget() {}
+
+public slots:
+ void save();
+ bool check();
+
+private slots:
+ void addButton();
+ void insertButton();
+ void removeButton();
+
+ //signals linked to the scroll bar
+ void scrolling(int);
+
+ //signals to keep the two listboxes highlighted in sync
+ void slhighlighted(int);
+ void stlhighlighted(int);
+
+private:
+ void adjustScrollBar();
+
+ ScriptEdit *se;
+ QPushButton *add;
+ QPushButton *remove;
+ QPushButton *insert;
+ QListBox *sl, *stl;
+
+ QScrollBar *slb;
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Used to specify a new phone number
+//
+/////////////////////////////////////////////////////////////////////////////
+class PhoneNumberDialog : public QDialog {
+ Q_OBJECT
+public:
+ PhoneNumberDialog(QWidget *parent = 0);
+
+ QString phoneNumber();
+
+private slots:
+ void textChanged(const QString &);
+
+private:
+ QLineEdit *le;
+};
+
+
+#endif
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 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <termios.h>
+#include <string.h>
+#include <qwhatsthis.h>
+
+#include "knuminput.h"
+#include <qslider.h>
+#include <qlayout.h>
+#include "general.h"
+//#include "version.h"
+//#include "miniterm.h"
+#include "modeminfo.h"
+#include "modemcmds.h"
+#include "devices.h"
+#include "pppdata.h"
+//#include <klocale.h>
+#define i18n QObject::tr
+
+
+
+ModemWidget::ModemWidget( QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ int k;
+
+ QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
+
+ label1 = new QLabel(i18n("Modem de&vice:"), this);
+ tl->addWidget(label1, 0, 0);
+
+ modemdevice = new QComboBox(false, this);
+ label1->setBuddy(modemdevice);
+
+ for(k = 0; devices[k]; k++)
+ modemdevice->insertItem(devices[k]);
+
+ tl->addWidget(modemdevice, 0, 1);
+ connect(modemdevice, SIGNAL(activated(int)),
+ SLOT(setmodemdc(int)));
+ QString tmp = i18n("This specifies the serial port your modem is attached \n"
+ "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
+ "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
+ "\n"
+ "If you have an internal ISDN card with AT command\n"
+ "emulation (most cards under Linux support this), you\n"
+ "should select one of the /dev/ttyIx devices.");
+
+ QWhatsThis::add(label1,tmp);
+ QWhatsThis::add(modemdevice,tmp);
+
+
+ label2 = new QLabel(i18n("&Flow control:"), this);
+ tl->addWidget(label2, 1, 0);
+
+ flowcontrol = new QComboBox(false, this);
+ label2->setBuddy(flowcontrol);
+ flowcontrol->insertItem(i18n("Hardware [CRTSCTS]"));
+ flowcontrol->insertItem(i18n("Software [XON/XOFF]"));
+ flowcontrol->insertItem(i18n("None"));
+ tl->addWidget(flowcontrol, 1, 1);
+ connect(flowcontrol, SIGNAL(activated(int)),
+ SLOT(setflowcontrol(int)));
+
+ tmp = i18n("<p>Specifies how the serial port and modem\n"
+ "communicate. You should not change this unless\n"
+ "you know what you are doing.\n"
+ "\n"
+ "<b>Default</b>: CRTSCTS");
+
+ QWhatsThis::add(label2,tmp);
+ QWhatsThis::add(flowcontrol,tmp);
+
+ labelenter = new QLabel(i18n("&Line termination:"), this);
+ tl->addWidget(labelenter, 2, 0);
+
+ enter = new QComboBox(false, this);
+ labelenter->setBuddy(enter);
+ enter->insertItem("CR");
+ enter->insertItem("LF");
+ enter->insertItem("CR/LF");
+ tl->addWidget(enter, 2, 1);
+ connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
+ tmp = i18n("<p>Specifies how AT commands are sent to your\n"
+ "modem. Most modems will work fine with the\n"
+ "default <i>CR/LF</i>. If your modem does not react\n"
+ "to the init string, you should try different\n"
+ "settings here\n"
+ "\n"
+ "<b>Default</b>: CR/LF");
+
+ QWhatsThis::add(labelenter,tmp);
+ QWhatsThis::add(enter, tmp);
+
+ baud_label = new QLabel(i18n("Co&nnection speed:"), this);
+ tl->addWidget(baud_label, 3, 0);
+ baud_c = new QComboBox(this);
+ baud_label->setBuddy(baud_c);
+
+ static const char *baudrates[] = {
+
+#ifdef B460800
+ "460800",
+#endif
+
+#ifdef B230400
+ "230400",
+#endif
+
+#ifdef B115200
+ "115200",
+#endif
+
+#ifdef B57600
+ "57600",
+#endif
+
+ "38400",
+ "19200",
+ "9600",
+ "2400",
+ 0};
+
+ for(k = 0; baudrates[k]; k++)
+ baud_c->insertItem(baudrates[k]);
+
+ baud_c->setCurrentItem(3);
+ connect(baud_c, SIGNAL(activated(int)),
+ this, SLOT(speed_selection(int)));
+ tl->addWidget(baud_c, 3, 1);
+
+ tmp = i18n("Specifies the speed your modem and the serial\n"
+ "port talk to each other. You should begin with\n"
+ "the default of 38400 bits/sec. If everything\n"
+ "works you can try to increase this value, but to\n"
+ "no more than 115200 bits/sec (unless you know\n"
+ "that your serial port supports higher speeds).");
+
+ QWhatsThis::add(baud_label,tmp);
+ QWhatsThis::add(baud_c,tmp);
+
+ for(int i=0; i <= enter->count()-1; i++) {
+ if(gpppdata.enter() == enter->text(i))
+ enter->setCurrentItem(i);
+ }
+
+ tl->addRowSpacing(4, 10);
+
+ //Modem Lock File
+ modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
+
+ modemlockfile->setChecked(gpppdata.modemLockFile());
+ connect(modemlockfile, SIGNAL(toggled(bool)),
+ SLOT(modemlockfilechanged(bool)));
+ tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
+ // l12->addStretch(1);
+ QWhatsThis::add(modemlockfile,
+ i18n("<p>To prevent other programs from accessing the\n"
+ "modem while a connection is established, a\n"
+ "file can be created to indicate that the modem\n"
+ "is in use. On Linux an example file would be\n"
+ "<tt>/var/lock/LCK..ttyS1</tt>\n"
+ "Here you can select whether this locking will\n"
+ "be done.\n"
+ "\n"
+ "<b>Default</b>: On"));
+
+ // Modem Timeout Line Edit Box
+
+ modemtimeout = new KIntNumInput(gpppdata.modemTimeout(), this);
+ modemtimeout->setLabel(i18n("Modem &timeout:"));
+ modemtimeout->setRange(1, 120, 1);
+ modemtimeout->setSuffix(i18n(" sec"));
+ connect(modemtimeout, SIGNAL(valueChanged(int)),
+ SLOT(modemtimeoutchanged(int)));
+ tl->addMultiCellWidget(modemtimeout, 6, 6, 0, 1);
+
+ QWhatsThis::add(modemtimeout,
+ i18n("This specifies how long <i>kppp</i> waits for a\n"
+ "<i>CONNECT</i> response from your modem. The\n"
+ "recommended value is 30 seconds."));
+
+ //set stuff from gpppdata
+ for(int i=0; i <= enter->count()-1; i++) {
+ if(gpppdata.enter() == enter->text(i))
+ enter->setCurrentItem(i);
+ }
+
+ for(int i=0; i <= modemdevice->count()-1; i++) {
+ if(gpppdata.modemDevice() == modemdevice->text(i))
+ modemdevice->setCurrentItem(i);
+ }
+
+ for(int i=0; i <= flowcontrol->count()-1; i++) {
+ if(gpppdata.flowcontrol() == flowcontrol->text(i))
+ flowcontrol->setCurrentItem(i);
+ }
+
+ //set the modem speed
+ for(int i=0; i < baud_c->count(); i++)
+ if(baud_c->text(i) == gpppdata.speed())
+ baud_c->setCurrentItem(i);
+
+ tl->setRowStretch(7, 1);
+}
+
+
+void ModemWidget::speed_selection(int) {
+ gpppdata.setSpeed(baud_c->text(baud_c->currentItem()));
+}
+
+
+void ModemWidget::setenter(int ) {
+ gpppdata.setEnter(enter->text(enter->currentItem()));
+}
+
+
+void ModemWidget::setmodemdc(int i) {
+ gpppdata.setModemDevice(modemdevice->text(i));
+}
+
+
+void ModemWidget::setflowcontrol(int i) {
+ gpppdata.setFlowcontrol(flowcontrol->text(i));
+}
+
+
+void ModemWidget::modemlockfilechanged(bool set) {
+ gpppdata.setModemLockFile(set);
+}
+
+
+void ModemWidget::modemtimeoutchanged(int n) {
+ gpppdata.setModemTimeout(n);
+}
+
+
+ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
+
+
+ waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
+ waitfordt->setChecked(gpppdata.waitForDialTone());
+ connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
+ l1->addWidget(waitfordt);
+ QWhatsThis::add(waitfordt,
+ i18n("<p>Normally the modem waits for a dial tone\n"
+ "from your phone line, indicating that it can\n"
+ "start to dial a number. If your modem does not\n"
+ "recognize this sound, or your local phone system\n"
+ "does not emit such a tone, uncheck this option\n"
+ "\n"
+ "<b>Default:</b>: On"));
+
+ busywait = new KIntNumInput(gpppdata.busyWait(), this);
+ busywait->setLabel(i18n("B&usy wait:"));
+ busywait->setRange(0, 300, 5, true);
+ busywait->setSuffix(i18n(" sec"));
+ connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
+ l1->addWidget(busywait);
+
+ QWhatsThis::add(busywait,
+ i18n("Specifies the number of seconds to wait before\n"
+ "redial if all dialed numbers are busy. This is\n"
+ "necessary because some modems get stuck if the\n"
+ "same number is busy too often.\n"
+ "\n"
+ "The default is 0 seconds, you should not change\n"
+ "this unless you need to."));
+
+ l1->addSpacing(10);
+
+ QHBoxLayout *hbl = new QHBoxLayout;
+ hbl->setSpacing(2);//KDialog::spacingHint());
+
+ QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
+ hbl->addWidget(volumeLabel);
+ volume = new QSlider(0, 2, 1, gpppdata.volume(), QSlider::Horizontal, this);
+ volumeLabel->setBuddy(volume);
+ volume->setTickmarks(QSlider::Below);
+ hbl->addWidget(volume);
+
+ l1->addLayout(hbl);
+
+ connect(volume, SIGNAL(valueChanged(int)),
+ this, SLOT(volumeChanged(int)));
+ QString tmp = i18n("Most modems have a speaker which makes\n"
+ "a lot of noise when dialing. Here you can\n"
+ "either turn this completely off or select a\n"
+ "lower volume.\n"
+ "\n"
+ "If this does not work for your modem,\n"
+ "you must modify the modem volume command.");
+
+ QWhatsThis::add(volumeLabel,tmp);
+ QWhatsThis::add(volume, tmp);
+
+ l1->addSpacing(20);
+
+#if 0
+ chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
+ chkbox1->setChecked(gpppdata.UseCDLine());
+ connect(chkbox1,SIGNAL(toggled(bool)),
+ this,SLOT(use_cdline_toggled(bool)));
+ l12->addWidget(chkbox1);
+ l12->addStretch(1);
+ l1->addStretch(1);
+ QWhatsThis::add(chkbox1,
+ i18n("This controls how <i>kppp</i> detects that the modem\n"
+ "is not responding. Unless you are having\n"
+ "problems with this, do not modify this setting.\n"
+ "\n"
+ "<b>Default</b>: Off"));
+#endif
+
+ modemcmds = new QPushButton(i18n("Mod&em Commands..."), this);
+ QWhatsThis::add(modemcmds,
+ i18n("Allows you to change the AT command for\n"
+ "your modem."));
+
+ modeminfo_button = new QPushButton(i18n("&Query Modem..."), this);
+ QWhatsThis::add(modeminfo_button,
+ i18n("Most modems support the ATI command set to\n"
+ "find out vendor and revision of your modem.\n"
+ "\n"
+ "Press this button to query your modem for\n"
+ "this information. It can be useful to help\n"
+ "you setup the modem"));
+
+// terminal_button = new QPushButton(i18n("&Terminal..."), this);
+// QWhatsThis::add(terminal_button,
+// i18n("Opens the built-in terminal program. You\n"
+// "can use this if you want to play around\n"
+// "with your modem's AT command set"));
+
+ QHBoxLayout *hbox = new QHBoxLayout();
+ l1->addLayout(hbox);
+ hbox->addStretch(1);
+ QVBoxLayout *vbox = new QVBoxLayout();
+ hbox->addLayout(vbox);
+
+ vbox->addWidget(modemcmds);
+ vbox->addWidget(modeminfo_button);
+// vbox->addWidget(terminal_button);
+
+ hbox->addStretch(1);
+ l1->addStretch(1);
+
+ connect(modemcmds, SIGNAL(clicked()),
+ SLOT(modemcmdsbutton()));
+ connect(modeminfo_button, SIGNAL(clicked()),
+ SLOT(query_modem()));
+// connect(terminal_button, SIGNAL(clicked()),
+// SLOT(terminal()));
+}
+
+
+void ModemWidget2::modemcmdsbutton() {
+ ModemCommands mc(this);
+ mc.showMaximized();
+ mc.exec();
+}
+
+
+void ModemWidget2::query_modem() {
+ ModemTransfer mt(this);
+ mt.exec();
+}
+
+
+// void ModemWidget2::terminal() {
+// MiniTerm terminal(NULL,NULL);
+// terminal.exec();
+// }
+
+
+#if 0
+void ModemWidget2::use_cdline_toggled(bool on) {
+ gpppdata.setUseCDLine(on);
+}
+#endif
+
+void ModemWidget2::waitfordtchanged(bool b) {
+ gpppdata.setWaitForDialTone((int)b);
+}
+
+void ModemWidget2::busywaitchanged(int n) {
+ gpppdata.setbusyWait(n);
+}
+
+
+void ModemWidget2::volumeChanged(int v) {
+ gpppdata.setVolume(v);
+}
+
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
new file mode 100644
index 0000000..66a9eec
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -0,0 +1,100 @@
+/*
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _GENERAL_H_
+#define _GENERAL_H_
+
+#include <qwidget.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qpushbutton.h>
+//#include <kcolorbutton.h>
+
+class QSlider;
+class KIntNumInput;
+
+
+
+class ModemWidget : public QWidget {
+ Q_OBJECT
+public:
+ ModemWidget( QWidget *parent=0, const char *name=0 );
+
+private slots:
+ void setmodemdc(int);
+ void setflowcontrol(int);
+ void modemtimeoutchanged(int);
+ void modemlockfilechanged(bool);
+ void setenter(int);
+ void speed_selection(int);
+
+private:
+ QComboBox *enter;
+ QLabel *label1;
+ QLabel *label2;
+ QLabel *labeltmp;
+ QLabel *labelenter;
+ QComboBox *modemdevice;
+ QComboBox *flowcontrol;
+
+ QComboBox *baud_c;
+ QLabel *baud_label;
+
+ KIntNumInput *modemtimeout;
+ QCheckBox *modemlockfile;
+};
+
+
+class ModemWidget2 : public QWidget {
+ Q_OBJECT
+public:
+ ModemWidget2( QWidget *parent=0, const char *name=0 );
+
+private slots:
+ void waitfordtchanged(bool);
+ void busywaitchanged(int);
+// void use_cdline_toggled(bool);
+ void modemcmdsbutton();
+ // void terminal();
+ void query_modem();
+ void volumeChanged(int);
+
+private:
+ QLabel *labeltmp;
+ QPushButton *modemcmds;
+ QPushButton *modeminfo_button;
+ // QPushButton *terminal_button;
+ QFrame *fline;
+ QCheckBox *waitfordt;
+ KIntNumInput *busywait;
+ QCheckBox *chkbox1;
+ QSlider *volume;
+};
+
+#endif
+
+
diff --git a/noncore/settings/networksettings/ppp/iplined.cpp b/noncore/settings/networksettings/ppp/iplined.cpp
new file mode 100644
index 0000000..f4fc370
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/iplined.cpp
@@ -0,0 +1,42 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "iplined.h"
+
+IPLineEdit::IPLineEdit( QWidget *parent, const char *name )
+ : QLineEdit(parent, name )//, "0123456789.")
+{
+ setMaxLength(3 * 4 + 1 * 3);
+}
+
+QSize IPLineEdit::sizeHint() const {
+ QFontMetrics fm = fontMetrics();
+
+ QSize s;
+ s.setHeight(QLineEdit::sizeHint().height());
+ s.setWidth(fm.boundingRect("888.888.888.888XX").width());
+ return s;
+}
diff --git a/noncore/settings/networksettings/ppp/iplined.h b/noncore/settings/networksettings/ppp/iplined.h
new file mode 100644
index 0000000..825f0ac
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/iplined.h
@@ -0,0 +1,40 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _IPLINED_H_
+#define _IPLINED_H_
+
+#include <qlineedit.h>
+
+class IPLineEdit : public QLineEdit {
+public:
+ IPLineEdit( QWidget *parent=0, const char *name=0 );
+ ~IPLineEdit() {}
+
+ virtual QSize sizeHint() const;
+};
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/knuminput.cpp b/noncore/settings/networksettings/ppp/knuminput.cpp
new file mode 100644
index 0000000..afaa581
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/knuminput.cpp
@@ -0,0 +1,1103 @@
+// -*- c-basic-offset: 4 -*-
+/*
+ * knuminput.cpp
+ *
+ * Initial implementation:
+ * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
+ * Rewritten and maintained by:
+ * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
+ * KDoubleSpinBox:
+ * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+//#include <config.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#include <assert.h>
+#include <math.h>
+#include <algorithm>
+
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qsize.h>
+#include <qslider.h>
+#include <qspinbox.h>
+#include <qstyle.h>
+
+//#include <kglobal.h>
+
+template<class T>
+inline const T& kMin (const T& a, const T& b) { return a < b ? a : b; }
+
+template<class T>
+inline const T& kMax (const T& a, const T& b) { return b < a ? a : b; }
+
+//#include <klocale.h>
+#define i18n QObject::tr
+//#include <kdebug.h>
+
+#include "knumvalidator.h"
+#include "knuminput.h"
+
+static inline int calcDiffByTen( int x, int y ) {
+ // calculate ( x - y ) / 10 without overflowing ints:
+ return ( x / 10 ) - ( y / 10 ) + ( x % 10 - y % 10 ) / 10;
+};
+
+// ----------------------------------------------------------------------------
+
+KNumInput::KNumInput(QWidget* parent, const char* name)
+ : QWidget(parent, name)
+{
+ init();
+}
+
+KNumInput::KNumInput(KNumInput* below, QWidget* parent, const char* name)
+ : QWidget(parent, name)
+{
+ init();
+
+ if(below) {
+ m_next = below->m_next;
+ m_prev = below;
+ below->m_next = this;
+ if(m_next)
+ m_next->m_prev = this;
+ }
+}
+
+void KNumInput::init()
+{
+ m_prev = m_next = 0;
+ m_colw1 = m_colw2 = 0;
+
+ m_label = 0;
+ m_slider = 0;
+ m_alignment = 0;
+}
+
+KNumInput::~KNumInput()
+{
+ if(m_prev)
+ m_prev->m_next = m_next;
+
+ if(m_next)
+ m_next->m_prev = m_prev;
+}
+
+void KNumInput::setLabel(const QString & label, int a)
+{
+ if(label.isEmpty()) {
+ delete m_label;
+ m_label = 0;
+ m_alignment = 0;
+ }
+ else {
+ if (m_label) m_label->setText(label);
+ else m_label = new QLabel(label, this, "KNumInput::QLabel");
+ m_label->setAlignment((a & (~(AlignTop|AlignBottom|AlignVCenter)))
+ | AlignVCenter);
+ // if no vertical alignment set, use Top alignment
+ if(!(a & (AlignTop|AlignBottom|AlignVCenter)))
+ a |= AlignTop;
+ m_alignment = a;
+ }
+
+ layout(true);
+}
+
+QString KNumInput::label() const
+{
+ if (m_label) return m_label->text();
+ return QString::null;
+}
+
+void KNumInput::layout(bool deep)
+{
+ int w1 = m_colw1;
+ int w2 = m_colw2;
+
+ // label sizeHint
+ m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0));
+
+ if(m_label && (m_alignment & AlignVCenter))
+ m_colw1 = m_sizeLabel.width() + 4;
+ else
+ m_colw1 = 0;
+
+ // slider sizeHint
+ m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0));
+
+ doLayout();
+
+ if(!deep) {
+ m_colw1 = w1;
+ m_colw2 = w2;
+ return;
+ }
+
+ KNumInput* p = this;
+ while(p) {
+ p->doLayout();
+ w1 = QMAX(w1, p->m_colw1);
+ w2 = QMAX(w2, p->m_colw2);
+ p = p->m_prev;
+ }
+
+ p = m_next;
+ while(p) {
+ p->doLayout();
+ w1 = QMAX(w1, p->m_colw1);
+ w2 = QMAX(w2, p->m_colw2);
+ p = p->m_next;
+ }
+
+ p = this;
+ while(p) {
+ p->m_colw1 = w1;
+ p->m_colw2 = w2;
+ p = p->m_prev;
+ }
+
+ p = m_next;
+ while(p) {
+ p->m_colw1 = w1;
+ p->m_colw2 = w2;
+ p = p->m_next;
+ }
+
+// kdDebug() << "w1 " << w1 << " w2 " << w2 << endl;
+}
+
+QSizePolicy KNumInput::sizePolicy() const
+{
+ return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
+}
+
+QSize KNumInput::sizeHint() const
+{
+ return minimumSizeHint();
+}
+
+void KNumInput::setSteps(int minor, int major)
+{
+ if(m_slider)
+ m_slider->setSteps( minor, major );
+}
+
+
+// ----------------------------------------------------------------------------
+
+KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name)
+ : QSpinBox(0, 99, 1, parent, name)
+{
+ editor()->setAlignment(AlignRight);
+ val_base = 10;
+ setValue(0);
+}
+
+KIntSpinBox::~KIntSpinBox()
+{
+}
+
+KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base,
+ QWidget* parent, const char* name)
+ : QSpinBox(lower, upper, step, parent, name)
+{
+ editor()->setAlignment(AlignRight);
+ val_base = base;
+ setValue(value);
+}
+
+void KIntSpinBox::setBase(int base)
+{
+ val_base = base;
+}
+
+
+int KIntSpinBox::base() const
+{
+ return val_base;
+}
+
+QString KIntSpinBox::mapValueToText(int v)
+{
+ return QString::number(v, val_base);
+}
+
+int KIntSpinBox::mapTextToValue(bool* ok)
+{
+ return cleanText().toInt(ok, val_base);
+}
+
+void KIntSpinBox::setEditFocus(bool mark)
+{
+ editor()->setFocus();
+ if(mark)
+ editor()->selectAll();
+}
+
+
+// ----------------------------------------------------------------------------
+
+class KIntNumInput::KIntNumInputPrivate {
+public:
+ int referencePoint;
+ short blockRelative;
+ KIntNumInputPrivate( int r )
+ : referencePoint( r ),
+ blockRelative( 0 ) {}
+};
+
+
+KIntNumInput::KIntNumInput(KNumInput* below, int val, QWidget* parent,
+ int _base, const char* name)
+ : KNumInput(below, parent, name)
+{
+ init(val, _base);
+}
+
+KIntNumInput::KIntNumInput(QWidget *parent, const char *name)
+ : KNumInput(parent, name)
+{
+ init(0, 10);
+}
+
+KIntNumInput::KIntNumInput(int val, QWidget *parent, int _base, const char *name)
+ : KNumInput(parent, name)
+{
+ init(val, _base);
+
+}
+
+void KIntNumInput::init(int val, int _base)
+{
+ d = new KIntNumInputPrivate( val );
+ m_spin = new KIntSpinBox(INT_MIN, INT_MAX, 1, val, _base, this, "KIntNumInput::KIntSpinBox");
+ m_spin->setValidator(new KIntValidator(this, _base, "KNumInput::KIntValidtr"));
+ connect(m_spin, SIGNAL(valueChanged(int)), SLOT(spinValueChanged(int)));
+ connect(this, SIGNAL(valueChanged(int)),
+ SLOT(slotEmitRelativeValueChanged(int)));
+
+ setFocusProxy(m_spin);
+ layout(true);
+}
+
+void KIntNumInput::setReferencePoint( int ref ) {
+ // clip to valid range:
+ ref = kMin( maxValue(), kMax( minValue(), ref ) );
+ d->referencePoint = ref;
+}
+
+int KIntNumInput::referencePoint() const {
+ return d->referencePoint;
+}
+
+void KIntNumInput::spinValueChanged(int val)
+{
+ if(m_slider)
+ m_slider->setValue(val);
+
+ emit valueChanged(val);
+}
+
+void KIntNumInput::slotEmitRelativeValueChanged( int value ) {
+ if ( d->blockRelative || !d->referencePoint ) return;
+ emit relativeValueChanged( double( value ) / double( d->referencePoint ) );
+}
+
+void KIntNumInput::setRange(int lower, int upper, int step, bool slider)
+{
+ upper = kMax(upper, lower);
+ lower = kMin(upper, lower);
+ m_spin->setMinValue(lower);
+ m_spin->setMaxValue(upper);
+ m_spin->setLineStep(step);
+
+ step = m_spin->lineStep(); // maybe QRangeControl didn't like out lineStep?
+
+ if(slider) {
+ if (m_slider)
+ m_slider->setRange(lower, upper);
+ else {
+ m_slider = new QSlider(lower, upper, step, m_spin->value(),
+ QSlider::Horizontal, this);
+ m_slider->setTickmarks(QSlider::Below);
+ connect(m_slider, SIGNAL(valueChanged(int)),
+ m_spin, SLOT(setValue(int)));
+ }
+
+ // calculate (upper-lower)/10 without overflowing int's:
+ int major = calcDiffByTen( upper, lower );
+ if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4
+
+ m_slider->setSteps(step, major);
+ m_slider->setTickInterval(major);
+ }
+ else {
+ delete m_slider;
+ m_slider = 0;
+ }
+
+ // check that reference point is still inside valid range:
+ setReferencePoint( referencePoint() );
+
+ layout(true);
+}
+
+void KIntNumInput::setMinValue(int min)
+{
+ setRange(min, m_spin->maxValue(), m_spin->lineStep(), m_slider);
+}
+
+int KIntNumInput::minValue() const
+{
+ return m_spin->minValue();
+}
+
+void KIntNumInput::setMaxValue(int max)
+{
+ setRange(m_spin->minValue(), max, m_spin->lineStep(), m_slider);
+}
+
+int KIntNumInput::maxValue() const
+{
+ return m_spin->maxValue();
+}
+
+void KIntNumInput::setSuffix(const QString &suffix)
+{
+ m_spin->setSuffix(suffix);
+
+ layout(true);
+}
+
+QString KIntNumInput::suffix() const
+{
+ return m_spin->suffix();
+}
+
+void KIntNumInput::setPrefix(const QString &prefix)
+{
+ m_spin->setPrefix(prefix);
+
+ layout(true);
+}
+
+QString KIntNumInput::prefix() const
+{
+ return m_spin->prefix();
+}
+
+void KIntNumInput::setEditFocus(bool mark)
+{
+ m_spin->setEditFocus(mark);
+}
+
+QSize KIntNumInput::minimumSizeHint() const
+{
+ constPolish();
+
+ int w;
+ int h;
+
+ h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height());
+
+ // if in extra row, then count it here
+ if(m_label && (m_alignment & (AlignBottom|AlignTop)))
+ h += 4 + m_sizeLabel.height();
+ else
+ // label is in the same row as the other widgets
+ h = QMAX(h, m_sizeLabel.height() + 2);
+
+ w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
+ w += m_colw1 + m_colw2;
+
+ if(m_alignment & (AlignTop|AlignBottom))
+ w = QMAX(w, m_sizeLabel.width() + 4);
+
+ return QSize(w, h);
+}
+
+void KIntNumInput::doLayout()
+{
+ m_sizeSpin = m_spin->sizeHint();
+ m_colw2 = m_sizeSpin.width();
+
+ if (m_label)
+ m_label->setBuddy(m_spin);
+}
+
+void KIntNumInput::resizeEvent(QResizeEvent* e)
+{
+ int w = m_colw1;
+ int h = 0;
+
+ if(m_label && (m_alignment & AlignTop)) {
+ m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
+ h += m_sizeLabel.height() + 4;
+ }
+
+ if(m_label && (m_alignment & AlignVCenter))
+ m_label->setGeometry(0, 0, w, m_sizeSpin.height());
+
+ m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height());
+ w += m_colw2 + 8;
+
+ if(m_slider)
+ m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height());
+
+ h += m_sizeSpin.height() + 2;
+
+ if(m_label && (m_alignment & AlignBottom))
+ m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
+}
+
+KIntNumInput::~KIntNumInput()
+{
+ delete d;
+}
+
+void KIntNumInput::setValue(int val)
+{
+ m_spin->setValue(val);
+ // slider value is changed by spinValueChanged
+}
+
+void KIntNumInput::setRelativeValue( double r ) {
+ if ( !d->referencePoint ) return;
+ ++d->blockRelative;
+ setValue( int( d->referencePoint * r + 0.5 ) );
+ --d->blockRelative;
+}
+
+double KIntNumInput::relativeValue() const {
+ if ( !d->referencePoint ) return 0;
+ return double( value() ) / double ( d->referencePoint );
+}
+
+int KIntNumInput::value() const
+{
+ return m_spin->value();
+}
+
+void KIntNumInput::setSpecialValueText(const QString& text)
+{
+ m_spin->setSpecialValueText(text);
+ layout(true);
+};
+
+QString KIntNumInput::specialValueText() const
+{
+ return m_spin->specialValueText();
+}
+
+void KIntNumInput::setLabel(const QString & label, int a)
+{
+ KNumInput::setLabel(label, a);
+
+ if(m_label)
+ m_label->setBuddy(m_spin);
+}
+
+// ----------------------------------------------------------------------------
+
+class KDoubleNumInput::KDoubleNumInputPrivate {
+public:
+ KDoubleNumInputPrivate( double r )
+ : spin( 0 ),
+ referencePoint( r ),
+ blockRelative ( 0 ) {}
+ KDoubleSpinBox * spin;
+ double referencePoint;
+ short blockRelative;
+};
+
+KDoubleNumInput::KDoubleNumInput(QWidget *parent, const char *name)
+ : KNumInput(parent, name)
+{
+ init(0.0, 0.0, 9999.0, 0.01, 2);
+}
+
+KDoubleNumInput::KDoubleNumInput(double lower, double upper, double value,
+ double step, int precision, QWidget* parent,
+ const char *name)
+ : KNumInput(parent, name)
+{
+ init(value, lower, upper, step, precision);
+}
+
+KDoubleNumInput::KDoubleNumInput(KNumInput *below,
+ double lower, double upper, double value,
+ double step, int precision, QWidget* parent,
+ const char *name)
+ : KNumInput(below, parent, name)
+{
+ init(value, lower, upper, step, precision);
+}
+
+KDoubleNumInput::KDoubleNumInput(double value, QWidget *parent, const char *name)
+ : KNumInput(parent, name)
+{
+ init(value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
+}
+
+KDoubleNumInput::KDoubleNumInput(KNumInput* below, double value, QWidget* parent,
+ const char* name)
+ : KNumInput(below, parent, name)
+{
+ init( value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
+}
+
+KDoubleNumInput::~KDoubleNumInput()
+{
+ delete d;
+}
+
+// ### remove when BIC changes are allowed again:
+
+bool KDoubleNumInput::eventFilter( QObject * o, QEvent * e ) {
+ return KNumInput::eventFilter( o, e );
+}
+
+void KDoubleNumInput::resetEditBox() {
+
+}
+
+// ### end stuff to remove when BIC changes are allowed again
+
+
+
+void KDoubleNumInput::init(double value, double lower, double upper,
+ double step, int precision )
+{
+ // ### init no longer used members:
+ edit = 0;
+ m_range = true;
+ m_value = 0.0;
+ m_precision = 2;
+ // ### end
+
+ d = new KDoubleNumInputPrivate( value );
+
+ d->spin = new KDoubleSpinBox( lower, upper, step, value, precision,
+ this, "KDoubleNumInput::d->spin" );
+ setFocusProxy(d->spin);
+ connect( d->spin, SIGNAL(valueChanged(double)),
+ this, SIGNAL(valueChanged(double)) );
+ connect( this, SIGNAL(valueChanged(double)),
+ this, SLOT(slotEmitRelativeValueChanged(double)) );
+
+ updateLegacyMembers();
+
+ layout(true);
+}
+
+void KDoubleNumInput::updateLegacyMembers() {
+ // ### update legacy members that are either not private or for
+ // which an inlined getter exists:
+ m_lower = minValue();
+ m_upper = maxValue();
+ m_step = d->spin->lineStep();
+ m_specialvalue = specialValueText();
+}
+
+
+double KDoubleNumInput::mapSliderToSpin( int val ) const
+{
+ // map [slidemin,slidemax] to [spinmin,spinmax]
+ double spinmin = d->spin->minValue();
+ double spinmax = d->spin->maxValue();
+ double slidemin = m_slider->minValue(); // cast int to double to avoid
+ double slidemax = m_slider->maxValue(); // overflow in rel denominator
+ double rel = ( double(val) - slidemin ) / ( slidemax - slidemin );
+ return spinmin + rel * ( spinmax - spinmin );
+}
+
+void KDoubleNumInput::sliderMoved(int val)
+{
+ d->spin->setValue( mapSliderToSpin( val ) );
+}
+
+void KDoubleNumInput::slotEmitRelativeValueChanged( double value )
+{
+ if ( !d->referencePoint ) return;
+ emit relativeValueChanged( value / d->referencePoint );
+}
+
+QSize KDoubleNumInput::minimumSizeHint() const
+{
+ constPolish();
+
+ int w;
+ int h;
+
+ h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height());
+
+ // if in extra row, then count it here
+ if(m_label && (m_alignment & (AlignBottom|AlignTop)))
+ h += 4 + m_sizeLabel.height();
+ else
+ // label is in the same row as the other widgets
+ h = QMAX(h, m_sizeLabel.height() + 2);
+
+ w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
+ w += m_colw1 + m_colw2;
+
+ if(m_alignment & (AlignTop|AlignBottom))
+ w = QMAX(w, m_sizeLabel.width() + 4);
+
+ return QSize(w, h);
+}
+
+void KDoubleNumInput::resizeEvent(QResizeEvent* e)
+{
+ int w = m_colw1;
+ int h = 0;
+
+ if(m_label && (m_alignment & AlignTop)) {
+ m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
+ h += m_sizeLabel.height() + 4;
+ }
+
+ if(m_label && (m_alignment & AlignVCenter))
+ m_label->setGeometry(0, 0, w, m_sizeEdit.height());
+
+ d->spin->setGeometry(w, h, m_slider ? m_colw2
+ : e->size().width() - w, m_sizeEdit.height());
+ w += m_colw2 + 8;
+
+ if(m_slider)
+ m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height());
+
+ h += m_sizeEdit.height() + 2;
+
+ if(m_label && (m_alignment & AlignBottom))
+ m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
+}
+
+void KDoubleNumInput::doLayout()
+{
+ m_sizeEdit = d->spin->sizeHint();
+ m_colw2 = m_sizeEdit.width();
+}
+
+void KDoubleNumInput::setValue(double val)
+{
+ d->spin->setValue( val );
+}
+
+void KDoubleNumInput::setRelativeValue( double r )
+{
+ if ( !d->referencePoint ) return;
+ ++d->blockRelative;
+ setValue( r * d->referencePoint );
+ --d->blockRelative;
+}
+
+void KDoubleNumInput::setReferencePoint( double ref )
+{
+ // clip to valid range:
+ ref = kMin( maxValue(), kMax( minValue(), ref ) );
+ d->referencePoint = ref;
+}
+
+void KDoubleNumInput::setRange(double lower, double upper, double step,
+ bool slider)
+{
+ if( m_slider ) {
+ // don't update the slider to avoid an endless recursion
+ QSpinBox * spin = d->spin;
+ disconnect(spin, SIGNAL(valueChanged(int)),
+ m_slider, SLOT(setValue(int)) );
+ }
+ d->spin->setRange( lower, upper, step, d->spin->precision() );
+
+ if(slider) {
+ // upcast to base type to get the min/maxValue in int form:
+ QSpinBox * spin = d->spin;
+ int slmax = spin->maxValue();
+ int slmin = spin->minValue();
+ int slvalue = spin->value();
+ int slstep = spin->lineStep();
+ if (m_slider) {
+ m_slider->setRange(slmin, slmax);
+ m_slider->setLineStep(slstep);
+ m_slider->setValue(slvalue);
+ } else {
+ m_slider = new QSlider(slmin, slmax, slstep, slvalue,
+ QSlider::Horizontal, this);
+ m_slider->setTickmarks(QSlider::Below);
+ // feedback line: when one moves, the other moves, too:
+ connect(m_slider, SIGNAL(valueChanged(int)),
+ SLOT(sliderMoved(int)) );
+ }
+ connect(spin, SIGNAL(valueChanged(int)),
+ m_slider, SLOT(setValue(int)) );
+ // calculate ( slmax - slmin ) / 10 without overflowing ints:
+ int major = calcDiffByTen( slmax, slmin );
+ if ( !major ) major = slstep; // ### needed?
+ m_slider->setTickInterval(major);
+ } else {
+ delete m_slider;
+ m_slider = 0;
+ }
+
+ setReferencePoint( referencePoint() );
+
+ layout(true);
+ updateLegacyMembers();
+}
+
+void KDoubleNumInput::setMinValue(double min)
+{
+ setRange(min, maxValue(), d->spin->lineStep(), m_slider);
+}
+
+double KDoubleNumInput::minValue() const
+{
+ return d->spin->minValue();
+}
+
+void KDoubleNumInput::setMaxValue(double max)
+{
+ setRange(minValue(), max, d->spin->lineStep(), m_slider);
+}
+
+double KDoubleNumInput::maxValue() const
+{
+ return d->spin->maxValue();
+}
+
+double KDoubleNumInput::value() const
+{
+ return d->spin->value();
+}
+
+double KDoubleNumInput::relativeValue() const
+{
+ if ( !d->referencePoint ) return 0;
+ return value() / d->referencePoint;
+}
+
+double KDoubleNumInput::referencePoint() const
+{
+ return d->referencePoint;
+}
+
+QString KDoubleNumInput::suffix() const
+{
+ return d->spin->suffix();
+}
+
+QString KDoubleNumInput::prefix() const
+{
+ return d->spin->prefix();
+}
+
+void KDoubleNumInput::setSuffix(const QString &suffix)
+{
+ d->spin->setSuffix( suffix );
+
+ layout(true);
+}
+
+void KDoubleNumInput::setPrefix(const QString &prefix)
+{
+ d->spin->setPrefix( prefix );
+
+ layout(true);
+}
+
+void KDoubleNumInput::setPrecision(int precision)
+{
+ d->spin->setPrecision( precision );
+
+ layout(true);
+}
+
+int KDoubleNumInput::precision() const
+{
+ return d->spin->precision();
+}
+
+void KDoubleNumInput::setSpecialValueText(const QString& text)
+{
+ d->spin->setSpecialValueText( text );
+
+ layout(true);
+ updateLegacyMembers();
+};
+
+void KDoubleNumInput::setLabel(const QString & label, int a)
+{
+ KNumInput::setLabel(label, a);
+
+ if(m_label)
+ m_label->setBuddy(d->spin);
+
+}
+
+// ----------------------------------------------------------------------------
+
+
+// We use a kind of fixed-point arithmetic to represent the range of
+// doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the
+// following relations hold:
+//
+// 1. factor = 10^mPrecision
+// 2. basicStep = 1/factor = 10^(-mPrecision);
+// 3. lowerInt = lower * factor;
+// 4. upperInt = upper * factor;
+// 5. lower = lowerInt * basicStep;
+// 6. upper = upperInt * basicStep;
+class KDoubleSpinBox::Private {
+public:
+ Private( int precision=1 )
+ : mPrecision( precision ),
+ mValidator( 0 )
+ {
+ }
+
+ int factor() const {
+ int f = 1;
+ for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10;
+ return f;
+ }
+
+ double basicStep() const {
+ return 1.0/double(factor());
+ }
+
+ int mapToInt( double value, bool * ok ) const {
+ assert( ok );
+ const double f = factor();
+ if ( value > double(INT_MAX) / f ) {
+// kdWarning() << "KDoubleSpinBox: can't represent value " << value
+// << "in terms of fixed-point numbers with precision "
+// << mPrecision << endl;
+ *ok = false;
+ return INT_MAX;
+ } else if ( value < double(INT_MIN) / f ) {
+// kdWarning() << "KDoubleSpinBox: can't represent value " << value
+// << "in terms of fixed-point numbers with precision "
+// << mPrecision << endl;
+ *ok = false;
+ return INT_MIN;
+ } else {
+ *ok = true;
+ return int( value * f + ( value < 0 ? -0.5 : 0.5 ) );
+ }
+ }
+
+ double mapToDouble( int value ) const {
+ return double(value) * basicStep();
+ }
+
+ int mPrecision;
+ KDoubleValidator * mValidator;
+};
+
+KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name )
+ : QSpinBox( parent, name )
+{
+ editor()->setAlignment( Qt::AlignRight );
+ d = new Private();
+ updateValidator();
+}
+
+KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step,
+ double value, int precision,
+ QWidget * parent, const char * name )
+ : QSpinBox( parent, name )
+{
+ editor()->setAlignment( Qt::AlignRight );
+ d = new Private();
+ setRange( lower, upper, step, precision );
+ setValue( value );
+ connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) );
+}
+
+KDoubleSpinBox::~KDoubleSpinBox() {
+ delete d; d = 0;
+}
+
+bool KDoubleSpinBox::acceptLocalizedNumbers() const {
+ if ( !d->mValidator ) return true; // we'll set one that does;
+ // can't do it now, since we're const
+ return d->mValidator->acceptLocalizedNumbers();
+}
+
+void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) {
+ if ( !d->mValidator ) updateValidator();
+ d->mValidator->setAcceptLocalizedNumbers( accept );
+}
+
+void KDoubleSpinBox::setRange( double lower, double upper, double step,
+ int precision ) {
+ lower = kMin(upper, lower);
+ upper = kMax(upper, lower);
+ setPrecision( precision, true ); // disable bounds checking, since
+ setMinValue( lower ); // it's done in set{Min,Max}Value
+ setMaxValue( upper ); // anyway and we want lower, upper
+ setLineStep( step ); // and step to have the right precision
+}
+
+int KDoubleSpinBox::precision() const {
+ return d->mPrecision;
+}
+
+void KDoubleSpinBox::setPrecision( int precision ) {
+ setPrecision( precision, false );
+}
+
+void KDoubleSpinBox::setPrecision( int precision, bool force ) {
+ if ( precision < 1 ) return;
+ if ( !force ) {
+ int maxPrec = maxPrecision();
+ if ( precision > maxPrec )
+ precision = maxPrec;
+ }
+ d->mPrecision = precision;
+ updateValidator();
+}
+
+int KDoubleSpinBox::maxPrecision() const {
+ // INT_MAX must be > maxAbsValue * 10^precision
+ // ==> 10^precision < INT_MAX / maxAbsValue
+ // ==> precision < log10 ( INT_MAX / maxAbsValue )
+ // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) );
+ double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) );
+ if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz...
+
+ return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) );
+}
+
+double KDoubleSpinBox::value() const {
+ return d->mapToDouble( base::value() );
+}
+
+void KDoubleSpinBox::setValue( double value ) {
+ if ( value == this->value() ) return;
+ if ( value < minValue() )
+ base::setValue( base::minValue() );
+ else if ( value > maxValue() )
+ base::setValue( base::maxValue() );
+ else {
+ bool ok = false;
+ base::setValue( d->mapToInt( value, &ok ) );
+ assert( ok );
+ }
+}
+
+double KDoubleSpinBox::minValue() const {
+ return d->mapToDouble( base::minValue() );
+}
+
+void KDoubleSpinBox::setMinValue( double value ) {
+ bool ok = false;
+ int min = d->mapToInt( value, &ok );
+ if ( !ok ) return;
+ base::setMinValue( min );
+ updateValidator();
+}
+
+
+double KDoubleSpinBox::maxValue() const {
+ return d->mapToDouble( base::maxValue() );
+}
+
+void KDoubleSpinBox::setMaxValue( double value ) {
+ bool ok = false;
+ int max = d->mapToInt( value, &ok );
+ if ( !ok ) return;
+ base::setMaxValue( max );
+ updateValidator();
+}
+
+double KDoubleSpinBox::lineStep() const {
+ return d->mapToDouble( base::lineStep() );
+}
+
+void KDoubleSpinBox::setLineStep( double step ) {
+ bool ok = false;
+ if ( step > maxValue() - minValue() )
+ base::setLineStep( 1 );
+ else
+ base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) );
+}
+
+QString KDoubleSpinBox::mapValueToText( int value ) {
+// if ( acceptLocalizedNumbers() )
+// return KGlobal::locale()
+// ->formatNumber( d->mapToDouble( value ), d->mPrecision );
+// else
+ return QString().setNum( d->mapToDouble( value ), 'f', d->mPrecision );
+}
+
+int KDoubleSpinBox::mapTextToValue( bool * ok ) {
+ double value;
+// if ( acceptLocalizedNumbers() )
+// value = KGlobal::locale()->readNumber( cleanText(), ok );
+// else
+ value = cleanText().toDouble( ok );
+ if ( !*ok ) return 0;
+ if ( value > maxValue() )
+ value = maxValue();
+ else if ( value < minValue() )
+ value = minValue();
+ return d->mapToInt( value, ok );
+}
+
+void KDoubleSpinBox::setValidator( const QValidator * ) {
+ // silently discard the new validator. We don't want another one ;-)
+}
+
+void KDoubleSpinBox::slotValueChanged( int value ) {
+ emit valueChanged( d->mapToDouble( value ) );
+}
+
+void KDoubleSpinBox::updateValidator() {
+ if ( !d->mValidator ) {
+ d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(),
+ this, "d->mValidator" );
+ base::setValidator( d->mValidator );
+ } else
+ d->mValidator->setRange( minValue(), maxValue(), precision() );
+}
+
+void KNumInput::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+void KIntNumInput::virtual_hook( int id, void* data )
+{ KNumInput::virtual_hook( id, data ); }
+
+void KDoubleNumInput::virtual_hook( int id, void* data )
+{ KNumInput::virtual_hook( id, data ); }
+
+void KIntSpinBox::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+void KDoubleSpinBox::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+//#include "knuminput.moc"
diff --git a/noncore/settings/networksettings/ppp/knuminput.h b/noncore/settings/networksettings/ppp/knuminput.h
new file mode 100644
index 0000000..67f3b44
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/knuminput.h
@@ -0,0 +1,947 @@
+/*
+ * knuminput.h
+ *
+ * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
+ * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
+ * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef K_NUMINPUT_H
+#define K_NUMINPUT_H
+
+#include <qwidget.h>
+#include <qspinbox.h>
+
+class QLabel;
+class QSlider;
+class QLineEdit;
+class QLayout;
+class QValidator;
+
+class KIntSpinBox;
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * You need to inherit from this class if you want to implement K*NumInput
+ * for a different variable type
+ *
+ */
+class KNumInput : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY( QString label READ label WRITE setLabel )
+public:
+ /**
+ * Default constructor
+ *
+ */
+ KNumInput(QWidget* parent=0, const char* name=0);
+
+ /**
+ * @param below A pointer to another KNumInput.
+ *
+ */
+ KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0);
+ ~KNumInput();
+
+ /**
+ * Sets the text and alignment of the main description label.
+ *
+ * @param label The text of the label.
+ * Use QString::null to remove an existing one.
+ *
+ * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and
+ * @p AlignTop, @p AlignVCenter, @p AlignBottom.
+ * default is @p AlignLeft | @p AlignTop.
+ *
+ * The vertical alignment flags have special meaning with this
+ * widget:
+ *
+ * @li @p AlignTop The label is placed above the edit/slider
+ * @li @p AlignVCenter The label is placed left beside the edit
+ * @li @p AlignBottom The label is placed below the edit/slider
+ *
+ */
+ virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
+
+ /**
+ * @return the text of the label.
+ */
+ QString label() const;
+
+ /**
+ * @return if the num input has a slider.
+ * @since 3.1
+ */
+ bool showSlider() const { return m_slider; }
+
+ /**
+ * Sets the spacing of tickmarks for the slider.
+ *
+ * @param minor Minor tickmark separation.
+ * @param major Major tickmark separation.
+ */
+ void setSteps(int minor, int major);
+
+ /**
+ * Specifies that this widget may stretch horizontally, but is
+ * fixed vertically (like @ref QSpinBox itself).
+ */
+ QSizePolicy sizePolicy() const;
+
+ /**
+ * Returns a size which fits the contents of the control.
+ *
+ * @return the preferred size necessary to show the control
+ */
+ virtual QSize sizeHint() const;
+
+protected:
+ /**
+ * Call this function whenever you change something in the geometry
+ * of your KNumInput child.
+ *
+ */
+ void layout(bool deep);
+
+ /**
+ * You need to overwrite this method and implement your layout
+ * calculations there.
+ *
+ * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation
+ * for details.
+ *
+ */
+ virtual void doLayout() = 0;
+
+ KNumInput* m_prev, *m_next;
+ int m_colw1, m_colw2;
+
+ QLabel* m_label;
+ QSlider* m_slider;
+ QSize m_sizeSlider, m_sizeLabel;
+
+ int m_alignment;
+
+private:
+ void init();
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KNumInputPrivate;
+ KNumInputPrivate *d;
+};
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * KIntNumInput combines a @ref QSpinBox and optionally a @ref QSlider
+ * with a label to make an easy to use control for setting some integer
+ * parameter. This is especially nice for configuration dialogs,
+ * which can have many such combinated controls.
+ *
+ * The slider is created only when the user specifies a range
+ * for the control using the setRange function with the slider
+ * parameter set to "true".
+ *
+ * A special feature of KIntNumInput, designed specifically for
+ * the situation when there are several KIntNumInputs in a column,
+ * is that you can specify what portion of the control is taken by the
+ * QSpinBox (the remaining portion is used by the slider). This makes
+ * it very simple to have all the sliders in a column be the same size.
+ *
+ * It uses @ref KIntValidator validator class. KIntNumInput enforces the
+ * value to be in the given range, and can display it in any base
+ * between 2 and 36.
+ *
+ * @short An input widget for integer numbers, consisting of a spinbox and a slider.
+ * @version $Id$
+ */
+
+class KIntNumInput : public KNumInput
+{
+ Q_OBJECT
+ Q_PROPERTY( int value READ value WRITE setValue )
+ Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
+ Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
+ Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
+ Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
+ Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
+ Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
+
+public:
+ /**
+ * Constructs an input control for integer values
+ * with base 10 and initial value 0.
+ */
+ KIntNumInput(QWidget *parent=0, const char *name=0);
+ /**
+ * Constructor
+ * It constructs a QSpinBox that allows the input of integer numbers
+ * in the range of -INT_MAX to +INT_MAX. To set a descriptive label,
+ * use setLabel(). To enforce the value being in a range and optionally to
+ * attach a slider to it, use setRange().
+ *
+ * @param value initial value for the control
+ * @param base numeric base used for display
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ */
+ KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0);
+
+ /**
+ * Constructor
+ *
+ * the difference to the one above is the "below" parameter. It tells
+ * this instance that it is visually put below some other KNumInput widget.
+ * Note that these two KNumInput's need not to have the same parent widget
+ * or be in the same layout group.
+ * The effect is that it'll adjust it's layout in correspondence
+ * with the layout of the other KNumInput's (you can build an arbitary long
+ * chain).
+ *
+ * @param below append KIntNumInput to the KNumInput chain
+ * @param value initial value for the control
+ * @param base numeric base used for display
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ */
+ KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0);
+
+ /**
+ * Destructor
+ *
+ *
+ */
+ virtual ~KIntNumInput();
+
+ /**
+ * @return the current value.
+ */
+ int value() const;
+
+ /**
+ * @return the curent value in units of the @ref referencePoint.
+ * @since 3.1
+ */
+ double relativeValue() const;
+
+ /**
+ * @return the current reference point
+ * @since 3.1
+ */
+ int referencePoint() const;
+
+ /**
+ * @return the suffix displayed behind the value.
+ * @see #setSuffix()
+ */
+ QString suffix() const;
+ /**
+ * @return the prefix displayed in front of the value.
+ * @see #setPrefix()
+ */
+ QString prefix() const;
+ /**
+ * @return the string displayed for a special value.
+ * @see #setSpecialValueText()
+ */
+ QString specialValueText() const;
+
+ /**
+ * @param min minimum value
+ * @param max maximum value
+ * @param step step size for the QSlider
+ */
+ void setRange(int min, int max, int step=1, bool slider=true);
+ /**
+ * Sets the minimum value.
+ */
+ void setMinValue(int min);
+ /**
+ * @return the minimum value.
+ */
+ int minValue() const;
+ /**
+ * Sets the maximum value.
+ */
+ void setMaxValue(int max);
+ /**
+ * @return the maximum value.
+ */
+ int maxValue() const;
+
+ /**
+ * Sets the special value text. If set, the SpinBox will display
+ * this text instead of the numeric value whenever the current
+ * value is equal to minVal(). Typically this is used for indicating
+ * that the choice has a special (default) meaning.
+ */
+ void setSpecialValueText(const QString& text);
+
+ /**
+ * @reimplemented
+ */
+ virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
+
+ /**
+ * This method returns the minimum size necessary to display the
+ * control. The minimum size is enough to show all the labels
+ * in the current font (font change may invalidate the return value).
+ *
+ * @return the minimum size necessary to show the control
+ */
+ virtual QSize minimumSizeHint() const;
+
+public slots:
+ /**
+ * Sets the value of the control.
+ */
+ void setValue(int);
+
+ /**
+ * Sets the value in units of the @ref referencePoint
+ * @since 3.1
+ */
+ void setRelativeValue(double);
+
+ /**
+ * Sets the reference point for @ref relativeValue.
+ * @since 3.1
+ */
+ void setReferencePoint(int);
+
+ /**
+ * Sets the suffix to @p suffix.
+ * Use QString::null to disable this feature.
+ * Formatting has to be provided (e.g. a space separator between the
+ * prepended @p value and the suffix's text has to be provided
+ * as the first character in the suffix).
+ *
+ * @see QSpinBox::setSuffix(), #setPrefix()
+ */
+ void setSuffix(const QString &suffix);
+
+ /**
+ * Sets the prefix to @p prefix.
+ * Use QString::null to disable this feature.
+ * Formatting has to be provided (see above).
+ *
+ * @see QSpinBox::setPrefix(), #setSuffix()
+ */
+ void setPrefix(const QString &prefix);
+
+ /**
+ * sets focus to the edit widget and marks all text in if mark == true
+ *
+ */
+ void setEditFocus( bool mark = true );
+
+signals:
+ /**
+ * Emitted every time the value changes (by calling @ref setValue() or
+ * by user interaction).
+ */
+ void valueChanged(int);
+
+ /**
+ * Emitted whenever @ref #valueChanged is. Contains the change
+ * relative to the @ref referencePoint.
+ * @since 3.1
+ */
+ void relativeValueChanged(double);
+
+private slots:
+ void spinValueChanged(int);
+ void slotEmitRelativeValueChanged(int);
+
+protected:
+ /**
+ * @reimplemented
+ */
+ virtual void doLayout();
+ /**
+ * @reimplemented
+ */
+ void resizeEvent ( QResizeEvent * );
+
+ KIntSpinBox* m_spin;
+ QSize m_sizeSpin;
+
+private:
+ void init(int value, int _base);
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KIntNumInputPrivate;
+ KIntNumInputPrivate *d;
+};
+
+
+/* ------------------------------------------------------------------------ */
+
+class KDoubleLine;
+
+/**
+ * KDoubleNumInput combines a @ref QSpinBox and optionally a @ref QSlider
+ * with a label to make an easy to use control for setting some float
+ * parameter. This is especially nice for configuration dialogs,
+ * which can have many such combinated controls.
+ *
+ * The slider is created only when the user specifies a range
+ * for the control using the setRange function with the slider
+ * parameter set to "true".
+ *
+ * A special feature of KDoubleNumInput, designed specifically for
+ * the situation when there are several instances in a column,
+ * is that you can specify what portion of the control is taken by the
+ * QSpinBox (the remaining portion is used by the slider). This makes
+ * it very simple to have all the sliders in a column be the same size.
+ *
+ * It uses the @ref KDoubleValidator validator class. KDoubleNumInput
+ * enforces the value to be in the given range, but see the class
+ * documentation of @ref KDoubleSpinBox for the tricky
+ * interrelationship of precision and values. All of what is said
+ * there applies here, too.
+ *
+ * @see KIntNumInput, KDoubleSpinBox
+ * @short An input control for real numbers, consisting of a spinbox and a slider.
+ */
+
+class KDoubleNumInput : public KNumInput
+{
+ Q_OBJECT
+ Q_PROPERTY( double value READ value WRITE setValue )
+ Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
+ Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
+ Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
+ Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
+ Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
+
+public:
+ /**
+ * Constructs an input control for double values
+ * with initial value 0.00.
+ */
+ KDoubleNumInput(QWidget *parent=0, const char *name=0);
+
+ /**
+ * @deprecated (value is rounded to a multiple of 1/100)
+ * Constructor
+ *
+ * @param value initial value for the control
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ */
+ KDoubleNumInput(double value, QWidget *parent=0, const char *name=0);
+
+ /**
+ * Constructor
+ *
+ * @param lower lower boundary value
+ * @param upper upper boundary value
+ * @param value initial value for the control
+ * @param step step size to use for up/down arrow clicks
+ * @param precision number of digits after the decimal point
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ * @since 3.1
+ */
+ KDoubleNumInput(double lower, double upper, double value, double step=0.01,
+ int precision=2, QWidget *parent=0, const char *name=0);
+
+ /**
+ * destructor
+ */
+ virtual ~KDoubleNumInput();
+
+ /**
+ * @deprecated (rounds @p value to a mulitple of 1/100)
+ * Constructor
+ *
+ * puts it below other KNumInput
+ *
+ * @param below
+ * @param value initial value for the control
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ **/
+ KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0);
+
+ /**
+ * Constructor
+ *
+ * puts it below other KNumInput
+ *
+ * @param lower lower boundary value
+ * @param upper upper boundary value
+ * @param value initial value for the control
+ * @param step step size to use for up/down arrow clicks
+ * @param precision number of digits after the decimal point
+ * @param parent parent QWidget
+ * @param name internal name for this widget
+ * @since 3.1
+ */
+ KDoubleNumInput(KNumInput* below,
+ double lower, double upper, double value, double step=0.02,
+ int precision=2, QWidget *parent=0, const char *name=0);
+
+ /**
+ * @return the current value.
+ */
+ double value() const;
+
+ /**
+ * @return the suffix.
+ * @see #setSuffix()
+ */
+ QString suffix() const;
+
+ /**
+ * @return the prefix.
+ * @see #setPrefix()
+ */
+ QString prefix() const;
+
+ /**
+ * @return the precision.
+ * @see #setPrecision()
+ */
+ int precision() const;
+
+ /**
+ * @return the string displayed for a special value.
+ * @see #setSpecialValueText()
+ */
+ QString specialValueText() const { return m_specialvalue; }
+
+ /**
+ * @param min minimum value
+ * @param max maximum value
+ * @param step step size for the QSlider
+ */
+ void setRange(double min, double max, double step=1, bool slider=true);
+ /**
+ * Sets the minimum value.
+ */
+ void setMinValue(double min);
+ /**
+ * @return the minimum value.
+ */
+ double minValue() const;
+ /**
+ * Sets the maximum value.
+ */
+ void setMaxValue(double max);
+ /**
+ * @return the maximum value.
+ */
+ double maxValue() const;
+
+ /**
+ * Specifies the number of digits to use.
+ */
+ void setPrecision(int precision);
+
+ /**
+ * @return the reference point for @ref #relativeValue calculation
+ * @since 3.1
+ */
+ double referencePoint() const;
+
+ /**
+ * @return the current value in units of @ref #referencePoint.
+ * @since 3.1
+ */
+ double relativeValue() const;
+
+ /**
+ * Sets the special value text. If set, the spin box will display
+ * this text instead of the numeric value whenever the current
+ * value is equal to @ref #minVal(). Typically this is used for indicating
+ * that the choice has a special (default) meaning.
+ */
+ void setSpecialValueText(const QString& text);
+
+ /**
+ * @reimplemented
+ */
+ virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
+ /**
+ * @reimplemented
+ */
+ virtual QSize minimumSizeHint() const;
+ /**
+ * @reimplemented
+ */
+ virtual bool eventFilter(QObject*, QEvent*);
+
+public slots:
+ /**
+ * Sets the value of the control.
+ */
+ void setValue(double);
+
+ /**
+ * Sets the value in units of @ref #referencePoint.
+ * @since 3.1
+ */
+ void setRelativeValue(double);
+
+ /**
+ * Sets the reference Point to @p ref. It @p ref == 0, emitting of
+ * @ref #relativeValueChanged is blocked and @ref #relativeValue
+ * just returns 0.
+ * @since 3.1
+ */
+ void setReferencePoint(double ref);
+
+ /**
+ * Sets the suffix to be displayed to @p suffix. Use QString::null to disable
+ * this feature. Note that the suffix is attached to the value without any
+ * spacing. So if you prefer to display a space separator, set suffix
+ * to something like " cm".
+ * @see #setSuffix()
+ */
+ void setSuffix(const QString &suffix);
+
+ /**
+ * Sets the prefix to be displayed to @p prefix. Use QString::null to disable
+ * this feature. Note that the prefix is attached to the value without any
+ * spacing.
+ * @see #setPrefix()
+ */
+ void setPrefix(const QString &prefix);
+
+signals:
+ /**
+ * Emitted every time the value changes (by calling @ref setValue() or
+ * by user interaction).
+ */
+ void valueChanged(double);
+ /**
+ * This is an overloaded member function, provided for
+ * convenience. It essentially behaves like the above function.
+ *
+ * Contains the value in units of @ref #referencePoint.
+ * @since 3.1
+ */
+ void relativeValueChanged(double);
+
+private slots:
+ void sliderMoved(int);
+ void slotEmitRelativeValueChanged(double);
+
+protected:
+
+ /**
+ * @reimplemented
+ */
+ virtual void doLayout();
+ /**
+ * @reimplemented
+ */
+ void resizeEvent ( QResizeEvent * );
+ virtual void resetEditBox();
+
+ // ### no longer used, remove when BIC allowed
+ KDoubleLine* edit;
+
+ bool m_range;
+ double m_lower, m_upper, m_step;
+ // ### end no longer used
+
+ QSize m_sizeEdit;
+
+ friend class KDoubleLine;
+private:
+ void init(double value, double lower, double upper,
+ double step, int precision);
+ double mapSliderToSpin(int) const;
+ void updateLegacyMembers();
+ // ### no longer used, remove when BIC allowed:
+ QString m_specialvalue, m_prefix, m_suffix;
+ double m_value;
+ short m_precision;
+ // ### end remove when BIC allowed
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KDoubleNumInputPrivate;
+ KDoubleNumInputPrivate *d;
+};
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * A @ref QSpinBox with support for arbitrary base numbers
+ * (e.g. hexadecimal).
+ *
+ * The class provides an easy interface to use other
+ * numeric systems then the decimal.
+ *
+ * @short A @ref QSpinBox with support for arbitrary base numbers.
+ */
+class KIntSpinBox : public QSpinBox
+{
+ Q_OBJECT
+ Q_PROPERTY( int base READ base WRITE setBase )
+
+public:
+
+ /**
+ * Constructor.
+ *
+ * Constructs a widget with an integer inputline with a little scrollbar
+ * and a slider, with minimal value 0, maximal value 99, step 1, base 10
+ * and initial value 0.
+ */
+ KIntSpinBox( QWidget *parent=0, const char *name=0);
+
+ /**
+ * Constructor.
+ *
+ * Constructs a widget with an integer inputline with a little scrollbar
+ * and a slider.
+ *
+ * @param lower The lowest valid value.
+ * @param upper The greatest valid value.
+ * @param step The step size of the scrollbar.
+ * @param value The actual value.
+ * @param base The base of the used number system.
+ * @param parent The parent of the widget.
+ * @param name The Name of the widget.
+ */
+ KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
+ QWidget* parent = 0, const char* name = 0);
+
+ /**
+ * Destructor.
+ */
+ virtual ~KIntSpinBox();
+
+ /**
+ * Sets the base in which the numbers in the spin box are represented.
+ */
+ void setBase(int base);
+ /**
+ * @return the base in which numbers in the spin box are represented.
+ */
+ int base() const;
+ /**
+ * sets focus and optionally marks all text
+ *
+ */
+ void setEditFocus(bool mark);
+
+protected:
+
+ /**
+ * Overloaded the method in QSpinBox
+ * to make use of the base given in the constructor.
+ */
+ virtual QString mapValueToText(int);
+
+ /**
+ * Overloaded the method in QSpinBox
+ * to make use of the base given in the constructor.
+ */
+ virtual int mapTextToValue(bool*);
+
+private:
+ int val_base;
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KIntSpinBoxPrivate;
+ KIntSpinBoxPrivate *d;
+};
+
+
+/* --------------------------------------------------------------------------- */
+
+/**
+ This class provides a spin box for fractional numbers.
+
+ @sect Parameters
+
+ There are a number of interdependent parameters whose relation to
+ each other you need to understand in order to make successful use
+ of the spin box.
+
+ @li precision: The number of decimals after the decimal point.
+ @li maxValue/minValue: upper and lower bound of the valid range
+ @li lineStep: the size of the step that is taken when the user hits
+ the up or down buttons
+
+ Since we work with fixed-point numbers internally, the maximum
+ precision is a function of the valid range and vice versa. More
+ precisely, the following relations hold:
+ <pre>
+ max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision
+ maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) )
+ </pre>
+
+ Since the value, bounds and step are rounded to the current
+ precision, you may experience that the order of setting above
+ parameters matters. E.g. the following are @em not equivalent (try
+ it!):
+
+ <pre>
+ // sets precision,
+ // then min/max value (rounded to precison and clipped to obtainable range if needed)
+ // then value and lineStep
+ KDoubleSpinBox * spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this );
+
+ // sets minValue to 0; maxValue to 10.00(!); value to 4.32(!) and only then
+ // increases the precision - too late, since e.g. value has already been rounded...
+ KDpubleSpinBox * spin = new KDoubleSpinBox( this );
+ spin->setMinValue( 0 );
+ spin->setMaxValue( 9.999 );
+ spin->setValue( 4.321 );
+ spin->setPrecision( 3 );
+ </pre>
+
+ @short A spin box for fractional numbers.
+ @author Marc Mutz <mutz@kde.org>
+ @version $Id$
+ @since 3.1
+**/
+
+class KDoubleSpinBox : public QSpinBox {
+ Q_OBJECT
+ Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
+ Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue )
+ Q_OVERRIDE( double minValue READ minValue WRITE setMinValue )
+ Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep )
+ Q_OVERRIDE( double value READ value WRITE setValue )
+ Q_PROPERTY( int precision READ precision WRITE setPrecision )
+
+public:
+ /** Constructs a @ref KDoubleSpinBox with parent @p parent and
+ default values for range and value (whatever @ref QRangeControl
+ uses) and precision (2). */
+ KDoubleSpinBox( QWidget * parent=0, const char * name=0 );
+ /** Constructs a @ref KDoubleSpinBox with parent @p parent, range
+ [@p lower,@p upper], @ref lineStep @p step, @ref precision @p
+ precision and initial value @p value. */
+ KDoubleSpinBox( double lower, double upper, double step, double value,
+ int precision=2, QWidget * parent=0, const char * name=0 );
+
+ virtual ~KDoubleSpinBox();
+
+ /** @return whether the spinbox uses localized numbers */
+ bool acceptLocalizedNumbers() const;
+ /** Sets whether to use and accept localized numbers as returned by
+ @ref KLocale::formatNumber() */
+ virtual void setAcceptLocalizedNumbers( bool accept );
+
+ /** Sets a new range for the spin box values. Note that @p lower, @p
+ upper and @p step are rounded to @p precision decimal points
+ first. */
+ void setRange( double lower, double upper, double step=0.01, int precision=2 );
+
+ /** @return the current number of decimal points displayed. */
+ int precision() const;
+ /** Equivalent to @ref setPrecsion( @p precison, @p false ); Needed
+ since Qt's moc doesn't ignore trailing parameters with default
+ args when searching for a property setter method. */
+ void setPrecision( int precision );
+ /** Sets the number of decimal points to use. Note that there is a
+ tradeoff between the precision used and the available range of
+ values. See the class docs for more.
+ @param precision the new number of decimal points to use
+
+ @param force disables checking of bound violations that can
+ arise if you increase the precision so much that the
+ minimum and maximum values can't be represented
+ anymore. Disabling is useful if you don't want to keep
+ the current min and max values anyway. This is what
+ e.g. @ref setRange() does.
+ **/
+ virtual void setPrecision( int precision, bool force );
+
+ /** @return the current value */
+ double value() const;
+ /** @return the current lower bound */
+ double minValue() const;
+ /** Sets the lower bound of the range to @p value, subject to the
+ contraints that @p value is first rounded to the current
+ precision and then clipped to the maximum representable
+ interval.
+ @see maxValue, minValue, setMaxValue, setRange
+ */
+ void setMinValue( double value );
+ /** @return the current upper bound */
+ double maxValue() const;
+ /** Sets the upper bound of the range to @p value, subject to the
+ contraints that @p value is first rounded to the current
+ precision and then clipped to the maximum representable
+ interval.
+ @see minValue, maxValue, setMinValue, setRange
+ */
+ void setMaxValue( double value );
+
+ /** @return the current step size */
+ double lineStep() const;
+ /** Sets the step size for clicking the up/down buttons to @p step,
+ subject to the constraints that @p step is first rounded to the
+ current precision and then clipped to the meaningful interval
+ [1, @p maxValue - @p minValue]. */
+ void setLineStep( double step );
+
+ /** Overridden to ignore any setValidator() calls. */
+ void setValidator( const QValidator * );
+
+signals:
+ /** Emitted whenever @ref QSpinBox::valueChanged( int ) is emitted. */
+ void valueChanged( double value );
+
+public slots:
+ /** Sets the current value to @p value, cubject to the constraints
+ that @p value is frist rounded to the current precision and then
+ clipped to the interval [@p minvalue(),@p maxValue()]. */
+ virtual void setValue( double value );
+
+protected:
+ virtual QString mapValueToText(int);
+ virtual int mapTextToValue(bool*);
+
+protected slots:
+ void slotValueChanged( int value );
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ typedef QSpinBox base;
+ void updateValidator();
+ int maxPrecision() const;
+
+ class Private;
+ Private * d;
+};
+
+#endif // K_NUMINPUT_H
diff --git a/noncore/settings/networksettings/ppp/knumvalidator.cpp b/noncore/settings/networksettings/ppp/knumvalidator.cpp
new file mode 100644
index 0000000..44f7a60
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/knumvalidator.cpp
@@ -0,0 +1,376 @@
+/**********************************************************************
+**
+** $Id$
+**
+** KIntValidator, KFloatValidator:
+** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com>
+** KDoubleValidator:
+** Copyright (c) 2002 Marc Mutz <mutz@kde.org>
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Library General Public
+** License as published by the Free Software Foundation; either
+** version 2 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Library General Public License for more details.
+**
+** You should have received a copy of the GNU Library General Public
+** License along with this library; if not, write to the Free
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+**
+*****************************************************************************/
+
+#include <qwidget.h>
+#include <qstring.h>
+
+#include "knumvalidator.h"
+//#include <klocale.h>
+#define i18n QObject::tr
+//#include <kglobal.h>
+//#include <kdebug.h>
+
+///////////////////////////////////////////////////////////////
+// Implementation of KIntValidator
+//
+
+KIntValidator::KIntValidator ( QWidget * parent, int base, const char * name )
+ : QValidator(parent, name)
+{
+ _base = base;
+ if (_base < 2) _base = 2;
+ if (_base > 36) _base = 36;
+
+ _min = _max = 0;
+}
+
+KIntValidator::KIntValidator ( int bottom, int top, QWidget * parent, int base, const char * name )
+ : QValidator(parent, name)
+{
+ _base = base;
+ if (_base > 36) _base = 36;
+
+ _min = bottom;
+ _max = top;
+}
+
+KIntValidator::~KIntValidator ()
+{}
+
+QValidator::State KIntValidator::validate ( QString &str, int & ) const
+{
+ bool ok;
+ int val = 0;
+ QString newStr;
+
+ newStr = str.stripWhiteSpace();
+ if (_base > 10)
+ newStr = newStr.upper();
+
+ if (newStr == QString::fromLatin1("-")) // a special case
+ if ((_min || _max) && _min >= 0)
+ ok = false;
+ else
+ return QValidator::Acceptable;
+ else if (newStr.length())
+ val = newStr.toInt(&ok, _base);
+ else {
+ val = 0;
+ ok = true;
+ }
+
+ if (! ok)
+ return QValidator::Invalid;
+
+ if ((! _min && ! _max) || (val >= _min && val <= _max))
+ return QValidator::Acceptable;
+
+ if (_max && _min >= 0 && val < 0)
+ return QValidator::Invalid;
+
+ return QValidator::Valid;
+}
+
+void KIntValidator::fixup ( QString &str ) const
+{
+ int dummy;
+ int val;
+ QValidator::State state;
+
+ state = validate(str, dummy);
+
+ if (state == QValidator::Invalid || state == QValidator::Acceptable)
+ return;
+
+ if (! _min && ! _max)
+ return;
+
+ val = str.toInt(0, _base);
+
+ if (val < _min) val = _min;
+ if (val > _max) val = _max;
+
+ str.setNum(val, _base);
+}
+
+void KIntValidator::setRange ( int bottom, int top )
+{
+ _min = bottom;
+ _max = top;
+
+ if (_max < _min)
+ _max = _min;
+}
+
+void KIntValidator::setBase ( int base )
+{
+ _base = base;
+ if (_base < 2) _base = 2;
+}
+
+int KIntValidator::bottom () const
+{
+ return _min;
+}
+
+int KIntValidator::top () const
+{
+ return _max;
+}
+
+int KIntValidator::base () const
+{
+ return _base;
+}
+
+
+///////////////////////////////////////////////////////////////
+// Implementation of KFloatValidator
+//
+
+class KFloatValidatorPrivate
+{
+public:
+ KFloatValidatorPrivate()
+ {
+ }
+ ~KFloatValidatorPrivate()
+ {
+ }
+ bool acceptLocalizedNumbers;
+};
+
+
+KFloatValidator::KFloatValidator ( QWidget * parent, const char * name )
+ : QValidator(parent, name)
+{
+ d = new KFloatValidatorPrivate;
+ d->acceptLocalizedNumbers=false;
+ _min = _max = 0;
+}
+
+KFloatValidator::KFloatValidator ( double bottom, double top, QWidget * parent, const char * name )
+ : QValidator(parent, name)
+{
+ d = new KFloatValidatorPrivate;
+ d->acceptLocalizedNumbers=false;
+ _min = bottom;
+ _max = top;
+}
+
+KFloatValidator::KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent, const char * name )
+ : QValidator(parent, name)
+{
+ d = new KFloatValidatorPrivate;
+ d->acceptLocalizedNumbers = localeAware;
+ _min = bottom;
+ _max = top;
+}
+
+KFloatValidator::~KFloatValidator ()
+{
+ delete d;
+}
+
+void KFloatValidator::setAcceptLocalizedNumbers(bool _b)
+{
+ d->acceptLocalizedNumbers=_b;
+}
+
+bool KFloatValidator::acceptLocalizedNumbers() const
+{
+ return d->acceptLocalizedNumbers;
+}
+
+//#include <kdebug.h>
+QValidator::State KFloatValidator::validate ( QString &str, int & ) const
+{
+ bool ok;
+ double val = 0;
+ QString newStr;
+ newStr = str.stripWhiteSpace();
+
+ if (newStr == QString::fromLatin1("-")) // a special case
+ if ((_min || _max) && _min >= 0)
+ ok = false;
+ else
+ return QValidator::Acceptable;
+ else if (newStr == QString::fromLatin1(".") ) // FIXME :|| (d->acceptLocalizedNumbers && newStr==KGlobal::locale()->decimalSymbol())) // another special case
+ return QValidator::Acceptable;
+ else if (newStr.length())
+ {
+ val = newStr.toDouble(&ok);
+// if(!ok && d->acceptLocalizedNumbers)
+// val= KGlobal::locale()->readNumber(newStr,&ok);
+ }
+ else {
+ val = 0;
+ ok = true;
+ }
+
+ if (! ok)
+ return QValidator::Invalid;
+
+ if (( !_min && !_max) || (val >= _min && val <= _max))
+ return QValidator::Acceptable;
+
+ if (_max && _min >= 0 && val < 0)
+ return QValidator::Invalid;
+
+ if ( (_min || _max) && (val < _min || val > _max))
+ return QValidator::Invalid;
+
+ return QValidator::Valid;
+}
+
+void KFloatValidator::fixup ( QString &str ) const
+{
+ int dummy;
+ double val;
+ QValidator::State state;
+
+ state = validate(str, dummy);
+
+ if (state == QValidator::Invalid || state == QValidator::Acceptable)
+ return;
+
+ if (! _min && ! _max)
+ return;
+
+ val = str.toDouble();
+
+ if (val < _min) val = _min;
+ if (val > _max) val = _max;
+
+ str.setNum(val);
+}
+
+void KFloatValidator::setRange ( double bottom, double top )
+{
+ _min = bottom;
+ _max = top;
+
+ if (_max < _min)
+ _max = _min;
+}
+
+double KFloatValidator::bottom () const
+{
+ return _min;
+}
+
+double KFloatValidator::top () const
+{
+ return _max;
+}
+
+
+
+
+///////////////////////////////////////////////////////////////
+// Implementation of KDoubleValidator
+//
+
+class KDoubleValidator::Private {
+public:
+ Private( bool accept=false ) : acceptLocalizedNumbers( accept ) {}
+
+ bool acceptLocalizedNumbers;
+};
+
+//KDoubleValidator::KDoubleValidator( QObject * parent, const char * name )
+KDoubleValidator::KDoubleValidator( QWidget * parent, const char * name )
+ : QDoubleValidator( parent, name ), d( 0 )
+{
+ d = new Private();
+}
+
+KDoubleValidator::KDoubleValidator( double bottom, double top, int decimals,
+// QObject * parent, const char * name )
+ QWidget * parent, const char * name )
+ : QDoubleValidator( bottom, top, decimals, parent, name ), d( 0 )
+{
+ d = new Private();
+}
+
+KDoubleValidator::~KDoubleValidator()
+{
+ delete d;
+}
+
+bool KDoubleValidator::acceptLocalizedNumbers() const {
+ return d->acceptLocalizedNumbers;
+}
+
+void KDoubleValidator::setAcceptLocalizedNumbers( bool accept ) {
+ d->acceptLocalizedNumbers = accept;
+}
+
+QValidator::State KDoubleValidator::validate( QString & input, int & p ) const {
+ QString s = input;
+ if ( acceptLocalizedNumbers() ) {
+ // KLocale * l = KGlobal::locale();
+ // ok, we have to re-format the number to have:
+ // 1. decimalSymbol == '.'
+ // 2. negativeSign == '-'
+ // 3. positiveSign == <empty>
+ // 4. thousandsSeparator() == <empty> (we don't check that there
+ // are exactly three decimals between each separator):
+ QString d = ".",//l->decimalSymbol(),
+ n = "-",//l->negativeSign(),
+ p = "", //l->positiveSign(),
+ t = "";//l->thousandsSeparator();
+ // first, delete p's and t's:
+ if ( !p.isEmpty() )
+ for ( int idx = s.find( p ) ; idx >= 0 ; idx = s.find( p, idx ) )
+ s.remove( idx, p.length() );
+
+
+ if ( !t.isEmpty() )
+ for ( int idx = s.find( t ) ; idx >= 0 ; idx = s.find( t, idx ) )
+ s.remove( idx, t.length() );
+
+ // then, replace the d's and n's
+ if ( ( !n.isEmpty() && n.find('.') != -1 ) ||
+ ( !d.isEmpty() && d.find('-') != -1 ) ) {
+ // make sure we don't replace something twice:
+ // kdWarning() << "KDoubleValidator: decimal symbol contains '-' or "
+// "negative sign contains '.' -> improve algorithm" << endl;
+ return Invalid;
+ }
+
+ if ( !d.isEmpty() && d != "." )
+ for ( int idx = s.find( d ) ; idx >= 0 ; idx = s.find( d, idx + 1 ) )
+ s.replace( idx, d.length(), ".");
+
+ if ( !n.isEmpty() && n != "-" )
+ for ( int idx = s.find( n ) ; idx >= 0 ; idx = s.find( n, idx + 1 ) )
+ s.replace( idx, n.length(), "-" );
+ }
+
+ return base::validate( s, p );
+}
+
+//#include "knumvalidator.moc"
diff --git a/noncore/settings/networksettings/ppp/knumvalidator.h b/noncore/settings/networksettings/ppp/knumvalidator.h
new file mode 100644
index 0000000..c95293a
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/knumvalidator.h
@@ -0,0 +1,211 @@
+/**********************************************************************
+**
+** $Id$
+**
+** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com>
+** Copyright (C) 2002 Marc Mutz <mutz@kde.org>
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Library General Public
+** License as published by the Free Software Foundation; either
+** version 2 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Library General Public License for more details.
+**
+** You should have received a copy of the GNU Library General Public
+** License along with this library; if not, write to the Free
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+**
+*****************************************************************************/
+
+#ifndef __KNUMVALIDATOR_H
+#define __KNUMVALIDATOR_H
+
+#include <qvalidator.h>
+
+class QWidget;
+class QString;
+
+/**
+ * @ref QValidator for integers.
+
+ This can be used by @ref QLineEdit or subclass to provide validated
+ text entry. Can be provided with a base value (default is 10), to allow
+ the proper entry of hexadecimal, octal, or any other base numeric data.
+
+ @author Glen Parker <glenebob@nwlink.com>
+ @version 0.0.1
+*/
+class KIntValidator : public QValidator {
+
+ public:
+ /**
+ Constuctor. Also sets the base value.
+ */
+ KIntValidator ( QWidget * parent, int base = 10, const char * name = 0 );
+ /**
+ * Constructor. Also sets the minimum, maximum, and numeric base values.
+ */
+ KIntValidator ( int bottom, int top, QWidget * parent, int base = 10, const char * name = 0 );
+ /**
+ * Destructs the validator.
+ */
+ virtual ~KIntValidator ();
+ /**
+ * Validates the text, and return the result. Does not modify the parameters.
+ */
+ virtual State validate ( QString &, int & ) const;
+ /**
+ * Fixes the text if possible, providing a valid string. The parameter may be modified.
+ */
+ virtual void fixup ( QString & ) const;
+ /**
+ * Sets the minimum and maximum values allowed.
+ */
+ virtual void setRange ( int bottom, int top );
+ /**
+ * Sets the numeric base value.
+ */
+ virtual void setBase ( int base );
+ /**
+ * Returns the current minimum value allowed.
+ */
+ virtual int bottom () const;
+ /**
+ * Returns the current maximum value allowed.
+ */
+ virtual int top () const;
+ /**
+ * Returns the current numeric base.
+ */
+ virtual int base () const;
+
+ private:
+ int _base;
+ int _min;
+ int _max;
+
+};
+
+class KFloatValidatorPrivate;
+
+/**
+ @obsolete Use @ref KDoubleValidator
+
+ @ref QValidator for floating point entry.
+ Extends the QValidator class to properly validate double numeric data.
+ This can be used by @ref QLineEdit or subclass to provide validated
+ text entry.
+
+ @author Glen Parker <glenebob@nwlink.com>
+ @version 0.0.1
+*/
+class KFloatValidator : public QValidator {
+
+ public:
+ /**
+ * Constructor.
+ */
+ KFloatValidator ( QWidget * parent, const char * name = 0 );
+ /**
+ * Constructor. Also sets the minimum and maximum values.
+ */
+ KFloatValidator ( double bottom, double top, QWidget * parent, const char * name = 0 );
+ /**
+ * Constructor. Sets the validator to be locale aware if @p localeAware is true.
+ */
+ KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent, const char * name = 0 );
+ /**
+ * Destructs the validator.
+ */
+ virtual ~KFloatValidator ();
+ /**
+ * Validates the text, and return the result. Does not modify the parameters.
+ */
+ virtual State validate ( QString &, int & ) const;
+ /**
+ * Fixes the text if possible, providing a valid string. The parameter may be modified.
+ */
+ virtual void fixup ( QString & ) const;
+ /**
+ * Sets the minimum and maximum value allowed.
+ */
+ virtual void setRange ( double bottom, double top );
+ /**
+ * Returns the current minimum value allowed.
+ */
+ virtual double bottom () const;
+ /**
+ * Returns the current maximum value allowed.
+ */
+ virtual double top () const;
+ /**
+ * Sets the validator to be locale aware if @p is true. In this case, the
+ * character KLocale::decimalSymbol() from the global locale is recognized
+ * as decimal separator.
+ */
+ void setAcceptLocalizedNumbers(bool b);
+ /**
+ * Returns true if the validator is locale aware.
+ * @see setAcceptLocalizedNumbers().
+ */
+ bool acceptLocalizedNumbers() const;
+
+ private:
+ double _min;
+ double _max;
+
+ KFloatValidatorPrivate *d;
+};
+
+/**
+ KDoubleValidator extends @ref QDoubleValidator to be
+ locale-aware. That means that - subject to not being disabled -
+ @ref KLocale::decimalPoint(), @ref KLocale::thousandsSeparator()
+ and @ref KLocale::positiveSign() and @ref KLocale::negativeSign()
+ are respected.
+
+ @short A locale-aware @ref QDoubleValidator
+ @author Marc Mutz <mutz@kde.org>
+ @version $Id$
+ @see KIntValidator
+ @since 3.1
+**/
+
+class KDoubleValidator : public QDoubleValidator {
+ Q_OBJECT
+ Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
+public:
+ /** Constuct a locale-aware KDoubleValidator with default range
+ (whatever @ref QDoubleValidator uses for that) and parent @p
+ parent */
+ // KDoubleValidator( QObject * parent, const char * name=0 );
+ KDoubleValidator( QWidget * parent, const char * name=0 );
+ /** Constuct a locale-aware KDoubleValidator for range [@p bottom,@p
+ top] and a precision of @p decimals decimals after the decimal
+ point. */
+ KDoubleValidator( double bottom, double top, int decimals,
+ QWidget * parent, const char * name=0 );
+ // QObject * parent, const char * name=0 );
+ /** Destructs the validator.
+ */
+ virtual ~KDoubleValidator();
+
+ /** Overloaded for internal reasons. The API is not affected. */
+ virtual QValidator::State validate( QString & input, int & pos ) const;
+
+ /** @return whether localized numbers are accepted (default: true) */
+ bool acceptLocalizedNumbers() const;
+ /** Sets whether to accept localized numbers (default: true) */
+ void setAcceptLocalizedNumbers( bool accept );
+
+private:
+ typedef QDoubleValidator base;
+ class Private;
+ Private * d;
+};
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
new file mode 100644
index 0000000..2f9feda
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -0,0 +1,905 @@
+/*
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * Copyright (C) 1998-2002 Harri Porten <porten@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "kpppwidget.h"
+
+#include <qapplication.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qevent.h>
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qtabwidget.h>
+#include <qdialog.h>
+#include <qwhatsthis.h>
+
+// #include <kaboutdata.h>
+// #include <kapplication.h>
+#include <qbuttongroup.h>
+//#include <kcmdlineargs.h>
+//#include <kconfig.h>
+//#include <kdebug.h>
+#define i18n QObject::tr
+//#include <kiconloader.h> // For BarIcon
+//#include <klocale.h>
+#include <qmessagebox.h>
+// #include <kseparator.h>
+// #include <kstandarddirs.h>
+// #include <kwin.h>
+// #include <khelpmenu.h>
+#include <qpushbutton.h>
+//#include <kguiitem.h>
+
+#include <stdlib.h>
+#include <errno.h>
+#include <signal.h>
+
+#include "runtests.h"
+
+//#include "main.h"
+#include "auth.h"
+#include "modem.h"
+//#include "ppplog.h"
+//#include "opener.h"
+//#include "requester.h"
+//#include "pppstats.h"
+#include "pppdata.h"
+#include "general.h"
+
+#define execute_command system
+
+KPPPWidget *p_kppp = 0;
+
+KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl )
+ : QDialog(parent, name, modal, fl)
+// , acct(0)
+// , m_bCmdlAccount (false)
+{
+// tabWindow = 0;
+ p_kppp = this;
+ // before doing anything else, run a few tests
+
+ int result = runTests();
+ if(result == TEST_CRITICAL)
+ exit(4);
+
+// installEventFilter(this);
+
+// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
+
+// QGridLayout *l1 = new QGridLayout(3, 4);
+// tl->addLayout(l1);
+// l1->addColSpacing(0, 10);
+// l1->addColSpacing(3, 10);
+// l1->setColStretch(1, 3);
+// l1->setColStretch(2, 4);
+
+// label1 = new QLabel(i18n("C&onnect to: "), this);
+// l1->addWidget(label1, 0, 1);
+
+// connectto_c = new QComboBox(false, this);
+// label1->setBuddy(connectto_c);
+
+// connect(connectto_c, SIGNAL(activated(int)),
+// SLOT(newdefaultaccount(int)));
+// l1->addWidget(connectto_c, 0, 2);
+
+// ID_Label = new QLabel(i18n("&Login ID:"), this);
+// l1->addWidget(ID_Label, 1, 1);
+
+// // the entry line for usernames
+// ID_Edit = new QLineEdit(this);
+// ID_Label->setBuddy(ID_Edit);
+// l1->addWidget(ID_Edit, 1, 2);
+// connect(ID_Edit, SIGNAL(returnPressed()),
+// this, SLOT(enterPressedInID()));
+// QString tmp = i18n("<p>Type in the username that you got from your\n"
+// "ISP. This is especially important for PAP\n"
+// "and CHAP. You may omit this when you use\n"
+// "terminal-based or script-based authentication.\n"
+// "\n"
+// "<b>Important</b>: case is important here:\n"
+// "<i>myusername</i> is not the same as <i>MyUserName</i>!");
+
+// QWhatsThis::add(ID_Label,tmp);
+// QWhatsThis::add(ID_Edit,tmp);
+
+// PW_Label = new QLabel(i18n("&Password:"), this);
+// l1->addWidget(PW_Label, 2, 1);
+
+// PW_Edit= new QLineEdit(this);
+// PW_Label->setBuddy(PW_Edit);
+// PW_Edit->setEchoMode(QLineEdit::Password);
+// l1->addWidget(PW_Edit, 2, 2);
+// connect(PW_Edit, SIGNAL(returnPressed()),
+// this, SLOT(enterPressedInPW()));
+
+// tmp = i18n("<p>Type in the password that you got from your\n"
+// "ISP. This is especially important for PAP\n"
+// "and CHAP. You may omit this when you use\n"
+// "terminal-based or script-based authentication.\n"
+// "\n"
+// "<b>Important</b>: case is important here:\n"
+// "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
+
+// QWhatsThis::add(PW_Label,tmp);
+// QWhatsThis::add(PW_Edit,tmp);
+
+// QHBoxLayout *l3 = new QHBoxLayout;
+// tl->addSpacing(5);
+// tl->addLayout(l3);
+// tl->addSpacing(5);
+// l3->addSpacing(10);
+// log = new QCheckBox(i18n("Show lo&g window"), this);
+// connect(log, SIGNAL(toggled(bool)),
+// this, SLOT(log_window_toggled(bool)));
+// log->setChecked(gpppdata.get_show_log_window());
+// l3->addWidget(log);
+
+// QWhatsThis::add(log,
+// i18n("<p>This controls whether a log window is shown.\n"
+// "A log window shows the communication between\n"
+// "<i>kppp</i> and your modem. This will help you\n"
+// "in tracking down problems.\n"
+// "\n"
+// "Turn it off if <i>kppp</i> routinely connects without\n"
+// "problems"));
+
+// // fline = new QSeparator( KSeparator::HLine, this);
+// // tl->addWidget(fline);
+
+// QHBoxLayout *l2 = new QHBoxLayout(this);
+// tl->addLayout(l2);
+
+// int minw = 0;
+// quit_b = new QPushButton(i18n("&Quit"), this);
+// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
+// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
+// if(quit_b->sizeHint().width() > minw)
+// minw = quit_b->sizeHint().width();
+
+// setup_b = new QPushButton(i18n("&Setup..."), this);
+// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
+// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
+// if(setup_b->sizeHint().width() > minw)
+// minw = setup_b->sizeHint().width();
+
+
+
+// if(gpppdata.access() != KConfig::ReadWrite)
+// setup_b->setEnabled(false);
+
+// help_b = new QPushButton(i18n("&Help"), this);
+// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
+
+// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
+// help_b->setPopup((QPopupMenu*)helpMenu->menu());
+// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
+
+// if(help_b->sizeHint().width() > minw)
+// minw = help_b->sizeHint().width();
+
+// connect_b = new QPushButton(i18n("&Connect"), this);
+// connect_b->setDefault(true);
+// connect_b->setFocus();
+// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
+// if(connect_b->sizeHint().width() > minw)
+// minw = connect_b->sizeHint().width();
+
+// quit_b->setFixedWidth(minw);
+// setup_b->setFixedWidth(minw);
+// // help_b->setFixedWidth(help_b->sizeHint().width());
+// connect_b->setFixedWidth(minw);
+
+// l2->addWidget(quit_b);
+// l2->addWidget(setup_b);
+// // l2->addWidget(help_b);
+// l2->addSpacing(20);
+// l2->addWidget(connect_b);
+
+ setFixedSize(sizeHint());
+
+ (void)new Modem;
+
+ // we also connect cmld_start to the beginConnect so that I can run
+ // the dialer through a command line argument
+ connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
+
+// stats = new PPPStats;
+
+ // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+
+ // constructor of con_win reads position from config file
+// con_win = new ConWindow(0, "conw", this);
+ // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
+
+// statdlg = new PPPStatsDlg(0, "stats", this, stats);
+// statdlg->hide();
+
+ debugwindow = new DebugWidget(0,"debugwindow");
+ // KWin::setIcons(debugwindow->winId(), kapp->icon(), kapp->miniIcon());
+ debugwindow->hide();
+
+ // load up the accounts combo box
+
+// resetaccounts();
+// con = new ConnectWidget(0, "con");
+ //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
+// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
+ // Is this the best we can do here? it's not right.
+// QRect desk = QApplication::desktop()->screenGeometry(
+// QApplication::desktop()->screenNumber(topLevelWidget()));
+// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
+
+ // connect the ConnectWidgets various signals
+// connect(con, SIGNAL(closeDebugWindow()),
+// debugwindow, SLOT(hide()));
+// connect(con, SIGNAL(debugMessage(const QString &)),
+// debugwindow, SLOT(statusLabel(const QString &)));
+// connect(con, SIGNAL(toggleDebugWindow()),
+// debugwindow, SLOT(toggleVisibility()));
+// connect(con, SIGNAL(debugPutChar(unsigned char)),
+// debugwindow, SLOT(addChar(unsigned char)));
+// // connect(con, SIGNAL(startAccounting()),
+// // this, SLOT(startAccounting()));
+// // connect(con, SIGNAL(stopAccounting()),
+// // this, SLOT(stopAccounting()));
+// connect(qApp, SIGNAL(saveYourself()),
+// this, SLOT(saveMyself()));
+// connect(qApp, SIGNAL(shutDown()),
+// this, SLOT(shutDown()));
+
+// debugwindow->setGeometry(desk.center().x()+190, desk.center().y()-55,
+// debugwindow->width(),debugwindow->height());
+
+// move(desk.center().x()-width()/2, desk.center().y()-height()/2);
+
+
+// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+// m_strCmdlAccount = args->getOption("c");
+// m_bQuitOnDisconnect = args->isSet("q");
+
+// if(!m_strCmdlAccount.isEmpty()) {
+// m_bCmdlAccount = true;
+// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
+// }
+
+// if(m_bCmdlAccount){
+// bool result = gpppdata.setAccount(m_strCmdlAccount);
+// if (!result){
+// QString string;
+// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
+// KMessageBox::error(this, string);
+// m_bCmdlAccount = false;
+// this->show();
+// } else {
+// beginConnect();
+// }
+// } else
+// expandbutton();
+// show();
+
+
+//#define KPPP_SHOW_NEWS
+#ifdef KPPP_SHOW_NEWS
+ // keep user informed about recent changes
+ if(!m_bCmdlAccount)
+ showNews();
+#endif
+}
+
+KPPPWidget::~KPPPWidget()
+{
+ p_kppp = 0;
+// delete stats;
+}
+
+// bool KPPPWidget::eventFilter(QObject *o, QEvent *e) {
+// if(e->type() == QEvent::User) {
+// switch(((SignalEvent*)e)->sigType()) {
+// case SIGINT:
+// qDebug( "Received a SIGINT" );
+// interruptConnection();
+// break;
+// case SIGCHLD:
+// sigChld();
+// break;
+// case SIGUSR1:
+// sigPPPDDied();
+// break;
+// }
+// return true;
+// }
+
+// if(o == connect_b) {
+// if(e->type() == QEvent::KeyPress) {
+// if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) {
+// beginConnect();
+// return true;
+// }
+// }
+// }
+
+// return false;
+// }
+
+
+
+
+void KPPPWidget::enterPressedInID() {
+ PW_Edit->setFocus();
+}
+
+
+void KPPPWidget::enterPressedInPW() {
+ connect_b->setFocus();
+}
+
+// triggered by the session manager
+void KPPPWidget::saveMyself() {
+ gpppdata.save();
+}
+
+void KPPPWidget::shutDown() {
+ interruptConnection();
+ saveMyself();
+}
+
+void KPPPWidget::log_window_toggled(bool on) {
+ gpppdata.set_show_log_window(on);
+}
+
+
+
+
+// void KPPPWidget::resetaccounts() {
+// connectto_c->clear();
+
+// int count = gpppdata.count();
+
+// // enable/disable controls
+// connectto_c->setEnabled(count > 0);
+// connect_b->setEnabled(count > 0);
+// log->setEnabled(count > 0);
+// ID_Edit->setEnabled(count > 0);
+// PW_Edit->setEnabled(count > 0);
+
+// //load the accounts
+// for(int i=0; i < count; i++) {
+// gpppdata.setAccountbyIndex(i);
+// connectto_c->insertItem(gpppdata.accname());
+// }
+
+// //set the default account
+// if(!gpppdata.defaultAccount().isEmpty()) {
+// for(int i=0; i < count; i++)
+// if(gpppdata.defaultAccount() == connectto_c->text(i)) {
+// connectto_c->setCurrentItem(i);
+// gpppdata.setAccountbyIndex(i);
+
+// ID_Edit->setText(gpppdata.storedUsername());
+// PW_Edit->setText(gpppdata.storedPassword());
+// }
+// }
+// else
+// if(count > 0) {
+// gpppdata.setDefaultAccount(connectto_c->text(0));
+// gpppdata.save();
+// ID_Edit->setText(gpppdata.storedUsername());
+// PW_Edit->setText(gpppdata.storedPassword());
+// }
+
+// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
+// this, SLOT(usernameChanged(const QString &)));
+
+// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
+// this, SLOT(passwordChanged(const QString &)));
+
+// if (ID_Edit->text().isEmpty())
+// ID_Edit->setFocus();
+// else if (PW_Edit->text().isEmpty())
+// PW_Edit->setFocus();
+// }
+
+
+void KPPPWidget::interruptConnection() {
+ // interrupt dial up
+// if (con->isVisible())
+// emit con->cancelbutton();
+
+ // disconnect if online
+ if (gpppdata.pppdRunning())
+ emit disconnect();
+}
+
+
+void KPPPWidget::sigPPPDDied() {
+ qDebug( "Received a SIGUSR1" );
+
+ // if we are not connected pppdpid is -1 so have have to check for that
+ // in the followin line to make sure that we don't raise a false alarm
+ // such as would be the case when the log file viewer exits.
+ if(gpppdata.pppdRunning() || gpppdata.pppdError()) {
+ qDebug( "It was pppd that died" );
+
+ // when we killpppd() on Cancel in ConnectWidget
+ // we set pppid to -1 so we won't
+ // enter this block
+
+ // just to be sure
+
+ Modem::modem->removeSecret(AUTH_PAP);
+ Modem::modem->removeSecret(AUTH_CHAP);
+
+ gpppdata.setpppdRunning(false);
+
+ qDebug( "Executing command on disconnect since pppd has died." );
+ QApplication::flushX();
+ execute_command(gpppdata.command_on_disconnect());
+
+// stopAccounting();
+
+// con_win->stopClock();
+// DockWidget::dock_widget->stop_stats();
+// DockWidget::dock_widget->hide();
+
+ if(!gpppdata.pppdError())
+ gpppdata.setpppdError(E_PPPD_DIED);
+ removedns();
+ Modem::modem->unlockdevice();
+ // con->pppdDied();
+
+ if(!gpppdata.automatic_redial()) {
+ quit_b->setFocus();
+ show();
+// con_win->stopClock();
+// stopAccounting();
+// con_win->hide();
+// con->hide();
+
+ gpppdata.setpppdRunning(false);
+ // // not in a signal handler !!! KNotifyClient::beep();
+ QString msg;
+ if (gpppdata.pppdError() == E_IF_TIMEOUT)
+ msg = i18n("Timeout expired while waiting for the PPP interface "
+ "to come up!");
+ else {
+ msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
+ Modem::modem->pppdExitStatus();
+ if (Modem::modem->lastStatus != 99) { // more recent pppds only
+ msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
+ msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
+ "codes or take a look at the kppp FAQ on "
+ " <a href=http://devel-home.kde.org/~kppp/index.html>"
+ "http://devel-home.kde.org/~kppp/index.html</a></p>");
+ }
+ }
+
+// if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
+// // PPPL_ShowLog();
+// } else { /* reconnect on disconnect */
+ if (false){
+ qDebug( "Trying to reconnect... " );
+
+ if(gpppdata.authMethod() == AUTH_PAP ||
+ gpppdata.authMethod() == AUTH_CHAP ||
+ gpppdata.authMethod() == AUTH_PAPCHAP)
+ Modem::modem->setSecret(gpppdata.authMethod(),
+ encodeWord(gpppdata.storedUsername()),
+ encodeWord(gpppdata.password()));
+
+// con_win->hide();
+ // con_win->stopClock();
+// stopAccounting();
+ gpppdata.setpppdRunning(false);
+ // not in a signal handler !!! KNotifyClient::beep();
+ emit cmdl_start();
+ }
+ }
+ gpppdata.setpppdError(0);
+ }
+}
+
+// void KPPPWidget::sigChld() {
+// qDebug( "sigchld()" );
+// // pid_t id = wait(0L);
+// // if(id == helperPid && helperPid != -1) {
+// // kdDebug(5002) << "It was the setuid child that died" << endl;
+// // helperPid = -1;
+// QString msg = i18n("kppp's helper process just died.\n"
+// "Since a further execution would be pointless, "
+// "kppp will shut down now.");
+// QMessageBox::warning(0L,"error", msg);
+// //remove_pidfile();
+// exit(1);
+// // }
+// }
+
+
+void KPPPWidget::newdefaultaccount(int i) {
+ gpppdata.setDefaultAccount(connectto_c->text(i));
+ gpppdata.save();
+ ID_Edit->setText(gpppdata.storedUsername());
+ PW_Edit->setText(gpppdata.storedPassword());
+}
+
+
+
+
+void KPPPWidget::beginConnect() {
+ // make sure to connect to the account that is selected in the combo box
+ // (exeption: an account given by a command line argument)
+ // if(!m_bCmdlAccount) {
+// gpppdata.setAccount(connectto_c->currentText());
+// gpppdata.setPassword(PW_Edit->text());
+// } else {
+ gpppdata.setPassword(gpppdata.storedPassword());
+// }
+
+ QFileInfo info(pppdPath());
+
+ if(!info.exists()){
+ QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
+ "Make sure that pppd is installed and "
+ "that you have entered the correct path."));
+ return;
+ }
+#if 0
+ if(!info.isExecutable()){
+
+ QString string;
+ string = i18n("kppp cannot execute:\n %1\n"
+ "Please make sure that you have given kppp "
+ "setuid permission and that "
+ "pppd is executable.").arg(gpppdata.pppdPath());
+ KMessageBox::error(this, string);
+ return;
+
+ }
+#endif
+
+ QFileInfo info2(gpppdata.modemDevice());
+
+ if(!info2.exists()){
+ QString string;
+ string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
+ "your modem device properly "
+ "and/or adjust the location of the modem device on "
+ "the modem tab of "
+ "the setup dialog.").arg(gpppdata.modemDevice());
+ QMessageBox::warning(this, "error", string);
+ return;
+ }
+
+ // if this is a PAP or CHAP account, ensure that username is
+ // supplied
+ if(gpppdata.authMethod() == AUTH_PAP ||
+ gpppdata.authMethod() == AUTH_CHAP ||
+ gpppdata.authMethod() == AUTH_PAPCHAP ) {
+ if(ID_Edit->text().isEmpty()) {
+ QMessageBox::warning(this,"error",
+ i18n(
+ "You have selected the authentication "
+ "method PAP or CHAP. This requires that you "
+ "supply a username and a password!"));
+ return;
+ } else {
+ if(!Modem::modem->setSecret(gpppdata.authMethod(),
+ encodeWord(gpppdata.storedUsername()),
+ encodeWord(gpppdata.password()))) {
+ QString s;
+ s = i18n("Cannot create PAP/CHAP authentication\n"
+ "file \"%1\"").arg(PAP_AUTH_FILE);
+ QMessageBox::warning(this, "error", s);
+ return;
+ }
+ }
+ }
+
+ if (gpppdata.phonenumber().isEmpty()) {
+ QString s = i18n("You must specify a telephone number!");
+ QMessageBox::warning(this, "error", s);
+ return;
+ }
+
+ this->hide();
+
+ QString tit = i18n("Connecting to: %1").arg(gpppdata.accname());
+// con->setCaption(tit);
+
+// con->show();
+
+ bool show_debug = gpppdata.get_show_log_window();
+// con->debug->setOn(show_debug); // toggle button
+ debugwindow->clear();
+ if (!show_debug)
+ debugwindow->hide();
+ else {
+ debugwindow->show();
+// con->raise();
+ }
+
+ emit begin_connect();
+}
+
+
+void KPPPWidget::disconnect() {
+ if (!gpppdata.command_before_disconnect().isEmpty()) {
+// con_win->hide();
+// con->show();
+// con->setCaption(i18n("Disconnecting..."));
+// con->setMsg(i18n("Executing command before disconnection."));
+
+ qApp->processEvents();
+ QApplication::flushX();
+// pid_t id =
+ execute_command(gpppdata.command_before_disconnect());
+// int i, status;
+
+// do {
+// kapp->processEvents();
+// i = waitpid(id, &status, WNOHANG);
+// usleep(500000);
+// } while (i == 0 && errno == 0);
+
+// con->hide();
+ }
+
+ qApp->processEvents();
+
+// statdlg->stop_stats();
+ Modem::modem->killPPPDaemon();
+
+ QApplication::flushX();
+ execute_command(gpppdata.command_on_disconnect());
+
+ Modem::modem->removeSecret(AUTH_PAP);
+ Modem::modem->removeSecret(AUTH_CHAP);
+
+ removedns();
+ Modem::modem->unlockdevice();
+
+// con_win->stopClock();
+// p_kppp->stopAccounting();
+// con_win->hide();
+
+// DockWidget::dock_widget->stop_stats();
+// DockWidget::dock_widget->hide();
+
+// if(m_bQuitOnDisconnect)
+// kapp->exit(0);
+// else {
+ this->quit_b->setFocus();
+ this->show();
+// }
+}
+
+
+// void KPPPWidget::helpbutton() {
+// kapp->invokeHelp();
+// }
+
+
+void KPPPWidget::quitbutton() {
+ if(gpppdata.pppdRunning()) {
+ int ok = QMessageBox::warning(this,
+ i18n("Exiting kPPP will close your PPP Session."),
+ i18n("Quit kPPP?"));
+ if(ok == QMessageBox::Yes) {
+ Modem::modem->killPPPDaemon();
+ QApplication::flushX();
+ execute_command(gpppdata.command_on_disconnect());
+ removedns();
+ Modem::modem->unlockdevice();
+ }
+ } else {
+ if (!gpppdata.accname().isEmpty() && !gpppdata.storePassword())
+ gpppdata.setStoredPassword("");
+ }
+ gpppdata.save();
+ qApp->quit();
+}
+
+
+// void KPPPWidget::rulesetLoadError() {
+// QMessageBox::warning(this,"error", ruleset_load_errmsg);
+// }
+
+
+// void KPPPWidget::startAccounting() {
+// // volume accounting
+// stats->totalbytes = 0;
+
+// kdDebug() << "AcctEnabled: " << gpppdata.AcctEnabled() << endl;
+
+// // load the ruleset
+// if(!gpppdata.AcctEnabled())
+// return;
+
+// QString d = AccountingBase::getAccountingFile(gpppdata.accountingFile());
+// // if(::access(d.data(), X_OK) != 0)
+// acct = new Accounting(this, stats);
+// // else
+// // acct = new ExecutableAccounting(this);
+
+// // connect to the accounting object
+// connect(acct, SIGNAL(changed(QString, QString)),
+// con_win, SLOT(slotAccounting(QString, QString)));
+
+// // if(!acct->loadRuleSet(gpppdata.accountingFile())) {
+// // QString s= i18n("Can not load the accounting "
+// // "ruleset \"%1\"!").arg(gpppdata.accountingFile());
+
+// // starting the messagebox with a timer will prevent us
+// // from blocking the calling function ConnectWidget::timerEvent
+// ruleset_load_errmsg = s;
+// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
+// return;
+// }
+// //else
+// // acct->slotStart();
+// }
+
+// void KPPPWidget::stopAccounting() {
+// // store volume accounting
+// // if(stats->totalbytes != 0)
+// // gpppdata.setTotalBytes(stats->totalbytes);
+
+// if(!gpppdata.AcctEnabled())
+// return;
+
+// // if(acct != 0) {
+// // acct->slotStop();
+// // delete acct;
+// // acct = 0;
+// // }
+// }
+
+
+// void KPPPWidget::showStats() {
+// if(statdlg) {
+// statdlg->show();
+// statdlg->raise();
+// }
+// }
+
+
+void KPPPWidget::usernameChanged(const QString &) {
+ // store username for later use
+ gpppdata.setStoredUsername(ID_Edit->text());
+}
+
+
+void KPPPWidget::passwordChanged(const QString &) {
+ // store the password if so requested
+ if(gpppdata.storePassword())
+ gpppdata.setStoredPassword(PW_Edit->text());
+ else
+ gpppdata.setStoredPassword("");
+}
+
+
+void KPPPWidget::setPW_Edit(const QString &pw) {
+ PW_Edit->setText(pw);
+}
+
+
+// void KPPPWidget::resetCosts(const QString &s) {
+// AccountingBase::resetCosts(s);
+// }
+
+
+// void KPPPWidget::resetVolume(const QString &s) {
+// AccountingBase::resetVolume(s);
+// }
+
+/**
+ * pppd's getword() function knows about escape characters.
+ * If we write the username and password to the secrets file
+ * we'll therefore have to escape back slashes.
+ */
+QString KPPPWidget::encodeWord(const QString &s) {
+ QString r = s;
+ r.replace(QRegExp("\\"), "\\\\");
+ return r;
+}
+
+// void KPPPWidget::setQuitOnDisconnect (bool b)
+// {
+// m_bQuitOnDisconnect = b;
+// }
+
+void KPPPWidget::showNews() {
+#ifdef KPPP_SHOW_NEWS
+ /*
+ * Introduce the QuickHelp feature to new users of this version
+ */
+ #define QUICKHELP_HINT "Hint_QuickHelp"
+ if(gpppdata.readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
+ QDialog dlg(0, 0, true);
+ dlg.setCaption(i18n("Recent Changes in KPPP"));
+
+ QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
+ QHBoxLayout *l1 = new QHBoxLayout(10);
+ QVBoxLayout *l2 = new QVBoxLayout(10);
+ tl->addLayout(l1);
+
+ QLabel *icon = new QLabel(&dlg);
+ icon->setPixmap(BarIcon("exclamation"));
+ icon->setFixedSize(icon->sizeHint());
+ l1->addWidget(icon);
+ l1->addLayout(l2);
+
+ QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n"
+ "called \"Quickhelp\". It's similar to a tooltip,\n"
+ "but you can activate it whenever you want.\n"
+ "\n"
+ "To activate it, simply click on a control like\n"
+ "a button or a label with the right mouse button.\n"
+ "If the item supports Quickhelp, a popup menu\n"
+ "will appear leading to Quickhelp.\n"
+ "\n"
+ "To test it, right-click somewhere in this text."),
+ &dlg);
+
+ QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg);
+ cb->setFixedSize(cb->sizeHint());
+
+ KButtonBox *bbox = new KButtonBox(&dlg);
+ bbox->addStretch(1);
+ QPushButton *ok = bbox->addButton(i18n("OK"));
+ ok->setDefault(true);
+ dlg.connect(ok, SIGNAL(clicked()),
+ &dlg, SLOT(accept()));
+ bbox->addStretch(1);
+ bbox->layout();
+
+ l2->addWidget(l);
+ l2->addWidget(cb);
+ tl->addWidget(bbox);
+
+ QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n"
+ "This window will stay open until you\n"
+ "click a mouse button or a press a key.\n");
+
+ QWhatsThis::add(cb,tmp);
+ QWhatsThis::add(l, tmp);
+
+ dlg.exec();
+ if(cb->isChecked()) {
+ gpppdata.writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
+ gpppdata.save();
+ }
+ }
+#endif
+}
+
+
+//#include "kpppwidget.moc"
+
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h
new file mode 100644
index 0000000..266d829
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/kpppwidget.h
@@ -0,0 +1,157 @@
+/*
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * Copyright (C) 1998-2002 Harri Porten <porten@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __KPPPWIDGET_H__
+#define __KPPPWIDGET_H__
+
+#include <qstring.h>
+
+//#include "accounting.h"
+#include "conwindow.h"
+#include "accounts.h"
+#include "connect.h"
+#include "debug.h"
+//#include "pppstatdlg.h"
+
+//class GraphSetup;
+//class AboutWidget;
+//class PPPStats;
+class QDialog;
+class QPushButton;
+
+/* class SignalEvent : public QEvent { */
+/* public: */
+/* SignalEvent(int s) : QEvent(User), sig(s) { } */
+/* int sigType() const { return sig; } */
+/* private: */
+/* int sig; */
+/* }; */
+
+
+class KPPPWidget : public QDialog {
+ Q_OBJECT
+public:
+
+ KPPPWidget( QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 );
+ ~KPPPWidget();
+
+ void setPW_Edit(const QString &);
+ // virtual bool eventFilter(QObject *, QEvent *);
+
+ void setQuitOnDisconnect (bool b);
+ // bool quitOnDisconnect () {return m_bQuitOnDisconnect;};
+
+private slots:
+ void newdefaultaccount(int);
+// void expandbutton();
+ void beginConnect();
+ void quitbutton();
+ // void helpbutton();
+ // void setup();
+ // void rulesetLoadError();
+ void usernameChanged(const QString &);
+ void passwordChanged(const QString &);
+ void enterPressedInID();
+ void enterPressedInPW();
+ void saveMyself();
+ void shutDown();
+
+/* protected slots: */
+/* virtual void accept(); */
+/* virtual void reject(); */
+
+public slots:
+ // void resetaccounts();
+/* void resetCosts(const QString &); */
+/* void resetVolume(const QString &); */
+ void disconnect();
+ void log_window_toggled(bool on);
+/* void startAccounting(); */
+/* void stopAccounting(); */
+/* void showStats(); */
+
+signals:
+ void begin_connect();
+ void cmdl_start();
+
+public:
+ QCheckBox *log;
+ bool connected;
+ DebugWidget *debugwindow;
+ QString con_speed;
+ // ConnectWidget *con;
+ // ConWindow *con_win;
+ // PPPStatsDlg *statdlg;
+ // AccountingBase *acct;
+ QPushButton *quit_b;
+ //PPPStats *stats;
+
+private:
+ // void prepareSetupDialog();
+ void interruptConnection();
+ void sigChld();
+ void sigPPPDDied();
+ QString encodeWord(const QString &s);
+ void showNews ();
+
+ QString ruleset_load_errmsg;
+
+ // QPushButton *help_b;
+ QPushButton *setup_b;
+ QFrame *fline;
+ QFrame *fline1;
+ QPushButton *connect_b;
+ QComboBox *connectto_c;
+ QLabel *ID_Label;
+ QLabel *PW_Label;
+ QLineEdit *ID_Edit;
+ QLineEdit *PW_Edit;
+ QLabel *label1;
+ QLabel *label2;
+ QLabel *label3;
+ QLabel *label4;
+ QLabel *label5;
+ QLabel *label6;
+ QLabel *radio_label;
+
+
+ // QTabWidget *tabWindow;
+ // AccountWidget *accounts;
+ // GeneralWidget *general;
+ // ModemWidget *modem1;
+ // ModemWidget2 *modem2;
+ // GraphSetup *graph;
+ // AboutWidget *about;
+
+
+/* QString m_strCmdlAccount; */
+/* bool m_bQuitOnDisconnect; */
+/* bool m_bCmdlAccount; */
+};
+
+
+#endif
+
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index e9e3f06..a2f77c5 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -25,47 +25,75 @@
*/
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <setjmp.h>
+#include <regex.h>
#include <qregexp.h>
#include <assert.h>
+#include "auth.h"
#include "modem.h"
#include "pppdata.h"
-//#include "requester.h"
//#include <klocale.h>
#define i18n QObject::tr
#define qError qDebug
//#include <kdebug.h>
//#include <config.h>
#define MY_ASSERT(x) if (!(x)) { \
qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
exit(1); }
static sigjmp_buf jmp_buffer;
Modem *Modem::modem = 0;
-Modem::Modem() :
- modemfd(-1),
- sn(0L),
- data_mode(false),
- modem_is_locked(false)
+
+const char* pppdPath() {
+ // wasting a few bytes
+ static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
+ static char *pppdPath = 0L;
+ char *p;
+
+ if(pppdPath == 0L) {
+ const char *c = PPPDSEARCHPATH;
+ while(*c != '\0') {
+ while(*c == ':')
+ c++;
+ p = buffer;
+ while(*c != '\0' && *c != ':')
+ *p++ = *c++;
+ *p = '\0';
+ strcat(p, "/");
+ strcat(p, PPPDNAME);
+ if(access(buffer, F_OK) == 0)
+ return (pppdPath = buffer);
+ }
+ }
+
+ return pppdPath;
+}
+
+
+Modem::Modem()
{
+ if (Modem::modem != 0) return; //CORRECT?
+ modemfd = -1;
+ sn = 0L;
+ data_mode = false;
+ modem_is_locked = false;
lockfile[0] = '\0';
device = "/dev/modem";
- assert(modem==0);
- modem = this;
+ modem = this;
}
Modem::~Modem() {
modem = 0;
}
@@ -639,33 +667,143 @@ int Modem::openLockfile( QString lockfile, int flags)
void alarm_handler(int) {
// fprintf(stderr, "alarm_handler(): Received SIGALRM\n");
// jump
siglongjmp(jmp_buffer, 1);
}
+const char* Modem::authFile(Auth method, int version) {
+ switch(method|version) {
+ case PAP|Original:
+ return PAP_AUTH_FILE;
+ break;
+ case PAP|New:
+ return PAP_AUTH_FILE".new";
+ break;
+ case PAP|Old:
+ return PAP_AUTH_FILE".old";
+ break;
+ case CHAP|Original:
+ return CHAP_AUTH_FILE;
+ break;
+ case CHAP|New:
+ return CHAP_AUTH_FILE".new";
+ break;
+ case CHAP|Old:
+ return CHAP_AUTH_FILE".old";
+ break;
+ default:
+ return 0L;
+ }
+}
-const char* pppdPath() {
- // wasting a few bytes
- static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
- static char *pppdPath = 0L;
- char *p;
- if(pppdPath == 0L) {
- const char *c = PPPDSEARCHPATH;
- while(*c != '\0') {
- while(*c == ':')
- c++;
- p = buffer;
- while(*c != '\0' && *c != ':')
- *p++ = *c++;
- *p = '\0';
- strcat(p, "/");
- strcat(p, PPPDNAME);
- if(access(buffer, F_OK) == 0)
- return (pppdPath = buffer);
+bool Modem::createAuthFile(Auth method, const char *username, const char *password) {
+ const char *authfile, *oldName, *newName;
+ char line[100];
+ char regexp[2*MaxStrLen+30];
+ regex_t preg;
+
+ if(!(authfile = authFile(method)))
+ return false;
+
+ if(!(newName = authFile(method, New)))
+ return false;
+
+ // look for username, "username" or 'username'
+ // if you modify this RE you have to adapt regexp's size above
+ snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']",
+ username,username);
+ MY_ASSERT(regcomp(&preg, regexp, 0) == 0);
+
+ // copy to new file pap- or chap-secrets
+ int old_umask = umask(0077);
+ FILE *fout = fopen(newName, "w");
+ if(fout) {
+ // copy old file
+ FILE *fin = fopen(authfile, "r");
+ if(fin) {
+ while(fgets(line, sizeof(line), fin)) {
+ if(regexec(&preg, line, 0, 0L, 0) == 0)
+ continue;
+ fputs(line, fout);
+ }
+ fclose(fin);
}
+
+ // append user/pass pair
+ fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password);
+ fclose(fout);
}
- return pppdPath;
+ // restore umask
+ umask(old_umask);
+
+ // free memory allocated by regcomp
+ regfree(&preg);
+
+ if(!(oldName = authFile(method, Old)))
+ return false;
+
+ // delete old file if any
+ unlink(oldName);
+
+ rename(authfile, oldName);
+ rename(newName, authfile);
+
+ return true;
+}
+
+
+bool Modem::setSecret(int method, const char* name, const char* password)
+{
+
+ Auth auth;
+ if(method == AUTH_PAPCHAP)
+ return setSecret(AUTH_PAP, name, password) &&
+ setSecret(AUTH_CHAP, name, password);
+
+ switch(method) {
+ case AUTH_PAP:
+ auth = Modem::PAP;
+ break;
+ case AUTH_CHAP:
+ auth = Modem::CHAP;
+ break;
+ default:
+ return false;
+ }
+
+ return createAuthFile(auth, name, password);
+
+}
+
+bool Modem::removeSecret(int)
+{
+ return true;
+}
+
+void Modem::killPPPDaemon()
+{
+}
+
+int Modem::pppdExitStatus()
+{
+ return -1;
}
+
+bool Modem::execPPPDaemon(const QString & arguments)
+{
+ return true;
+}
+
+int Modem::openResolv(int flags)
+{
+ return -1;
+}
+
+bool Modem::setHostname(const QString & name)
+{
+ return true;
+}
+
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h
index c23524a..052be4a 100644
--- a/noncore/settings/networksettings/ppp/modem.h
+++ b/noncore/settings/networksettings/ppp/modem.h
@@ -61,28 +61,43 @@ public:
static QString parseModemSpeed(const QString &);
void notify(const QObject *, const char *);
void stop();
void flush();
int lockdevice();
void unlockdevice();
+ bool setSecret(int,const char*,const char*);
+ bool removeSecret(int);
+ void killPPPDaemon();
+ int pppdExitStatus();
+ bool execPPPDaemon(const QString & arguments);
+ int openResolv(int flags);
+ bool setHostname(const QString & name);
+
public:
+ enum Auth { PAP = 1, CHAP };
static Modem *modem;
+ int lastStatus;
signals:
void charWaiting(unsigned char);
private slots:
void startNotifier();
void stopNotifier();
void readtty(int);
private:
+ enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
+ enum { Original=0x100, New=0x200, Old=0x400 } Version;
+
+ const char* authFile(Auth method, int version = Original );
+ bool createAuthFile(Auth method,const char *username,const char *password);
void escape_to_command_mode();
int openLockfile(QString,int);
private:
QString device;
QString lockfile;
int modemfd;
QSocketNotifier *sn;
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
new file mode 100644
index 0000000..766ba0f
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -0,0 +1,321 @@
+/*
+ * kPPP: A front end for pppd for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with dummyWidget program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qlayout.h>
+#include <qslider.h>
+#include <qbuttongroup.h>
+#include <stdlib.h>
+//#include <kapplication.h> // for getMiniIcon()
+//#include <klocale.h>
+#define i18n QObject::tr
+#include "modemcmds.h"
+#include "pppdata.h"
+//#include <kwin.h>
+
+#define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE);
+
+// a little trick to make the label look like a disabled lineedit
+#define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2);
+
+ModemCommands::ModemCommands(QWidget *parent, const char *name)
+ : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel)
+{
+ setCaption(i18n("Edit Modem Commands"));
+// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+ QWidget *dummyWidget = new QWidget(this);
+// setMainWidget(dummyWidget);
+
+ const int GRIDROWS = 22;
+ int row = 0;
+
+ // toplevel layout
+ QVBoxLayout *tl = new QVBoxLayout(this, 10, 4);
+
+ // add grid + frame
+ QGridLayout *l1 = new QGridLayout(GRIDROWS, 4);
+ tl->addLayout(l1);
+ box = new QGroupBox(this, "box");
+ l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3);
+
+ // put slider and label into a separate H-Box
+ QHBoxLayout *l2 = new QHBoxLayout;
+ l1->addLayout(l2, row, 2);
+ lpreinitslider = new QLabel("MMMM", this);
+ FORMATSLIDERLABEL(lpreinitslider);
+
+ QSlider *preinitslider = new QSlider(0, 300, 1, 0,
+ QSlider::Horizontal, this);
+// preinitslider->setFixedHeight(preinitslider->sizeHint().height());
+ connect(preinitslider, SIGNAL(valueChanged(int)),
+ lpreinitslider, SLOT(setNum(int)));
+ l2->addWidget(lpreinitslider, 0);
+ l2->addWidget(preinitslider, 1);
+
+ lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this);
+ l1->addWidget(lpreinit, row++, 1);
+
+ for(int i = 0; i < PPPData::NumInitStrings; i++) {
+ initstr[i] = new QLineEdit(this);
+ QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1),
+ this);
+ ADJUSTEDIT(initstr[i]);
+ l1->addWidget(initLabel, row, 1);
+ l1->addWidget(initstr[i], row++, 2);
+ }
+
+ QHBoxLayout *l3 = new QHBoxLayout;
+ l1->addLayout(l3, row, 2);
+ linitslider = new QLabel("MMMM", this);
+ FORMATSLIDERLABEL(linitslider);
+ QSlider *initslider = new QSlider(1, 300, 1, 0,
+ QSlider::Horizontal, this);
+// initslider->setFixedHeight(initslider->sizeHint().height());
+ connect(initslider, SIGNAL(valueChanged(int)),
+ linitslider, SLOT(setNum(int)));
+ l3->addWidget(linitslider, 0);
+ l3->addWidget(initslider, 1);
+
+ label3 = new QLabel(i18n("Post-init delay (sec/100):"), this);
+ l1->addWidget(label3, row++, 1);
+
+ /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */
+ QHBoxLayout *l4 = new QHBoxLayout;
+ l1->addLayout(l4, row, 2);
+ ldurationslider = new QLabel("MMMM", this);
+ FORMATSLIDERLABEL(ldurationslider);
+ QSlider *durationslider = new QSlider(1, 255, 1, 0,
+ QSlider::Horizontal, this);
+// durationslider->setFixedHeight(durationslider->sizeHint().height());
+ connect(durationslider, SIGNAL(valueChanged(int)),
+ ldurationslider, SLOT(setNum(int)));
+ l4->addWidget(ldurationslider, 0);
+ l4->addWidget(durationslider, 1);
+
+ lduration = new QLabel(i18n("Dialing speed (sec/100):"), this);
+ l1->addWidget(lduration, row++, 1);
+
+
+ initresp = new QLineEdit(this);
+ label2 = new QLabel(i18n("Init response:"), this);
+ ADJUSTEDIT(initresp);
+ l1->addWidget(label2, row, 1);
+ l1->addWidget(initresp, row++, 2);
+
+ nodetectdialtone = new QLineEdit(this);
+ lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this);
+ ADJUSTEDIT(nodetectdialtone);
+ l1->addWidget(lnodetectdialtone, row, 1);
+ l1->addWidget(nodetectdialtone, row++, 2);
+
+ dialstr = new QLineEdit(this);
+ label4 = new QLabel(i18n("Dial string:"),this);
+ ADJUSTEDIT(dialstr);
+ l1->addWidget(label4, row, 1);
+ l1->addWidget(dialstr, row++, 2);
+
+ connectresp = new QLineEdit(this);
+ label5 = new QLabel(i18n("Connect response:"), this);
+ ADJUSTEDIT(connectresp);
+ l1->addWidget(label5, row, 1);
+ l1->addWidget(connectresp, row++, 2);
+
+ busyresp = new QLineEdit(this);
+ label6 = new QLabel(i18n("Busy response:"), this);
+ ADJUSTEDIT(busyresp);
+ l1->addWidget(label6, row, 1);
+ l1->addWidget(busyresp, row++, 2);
+
+ nocarrierresp = new QLineEdit(this);
+ label7 = new QLabel(i18n("No carrier response:"), this);
+ ADJUSTEDIT(nocarrierresp);
+ l1->addWidget(label7, row, 1);
+ l1->addWidget(nocarrierresp, row++, 2);
+
+ nodialtoneresp = new QLineEdit(this);
+ label8 = new QLabel(i18n("No dial tone response:"), this);
+ ADJUSTEDIT(nodialtoneresp);
+ l1->addWidget(label8, row, 1);
+ l1->addWidget(nodialtoneresp, row++, 2);
+
+ hangupstr = new QLineEdit(this);
+ label9 = new QLabel(i18n("Hangup string:"), this);
+ ADJUSTEDIT(hangupstr);
+ l1->addWidget(label9, row, 1);
+ l1->addWidget(hangupstr, row++, 2);
+
+ hangupresp = new QLineEdit(this);
+ label10 = new QLabel(i18n("Hangup response:"), this);
+ ADJUSTEDIT(hangupresp);
+ l1->addWidget(label10, row, 1);
+ l1->addWidget(hangupresp, row++, 2);
+
+ answerstr = new QLineEdit(this);
+ label11 = new QLabel(i18n("Answer string:"), this);
+ ADJUSTEDIT(answerstr);
+ l1->addWidget(label11, row, 1);
+ l1->addWidget(answerstr, row++, 2);
+
+ ringresp = new QLineEdit(this);
+ label12 = new QLabel(i18n("Ring response:"), this);
+ ADJUSTEDIT(ringresp);
+ l1->addWidget(label12, row, 1);
+ l1->addWidget(ringresp, row++, 2);
+
+ answerresp = new QLineEdit(this);
+ label13 = new QLabel(i18n("Answer response:"), this);
+ ADJUSTEDIT(answerresp);
+ l1->addWidget(label13, row, 1);
+ l1->addWidget(answerresp, row++, 2);
+
+ escapestr = new QLineEdit(this);
+ label14 = new QLabel(i18n("Escape string:"), this);
+ ADJUSTEDIT(escapestr);
+ l1->addWidget(label14, row, 1);
+ l1->addWidget(escapestr, row++, 2);
+
+ escaperesp = new QLineEdit(this);
+ label15 = new QLabel(i18n("Escape response:"), this);
+ ADJUSTEDIT(escaperesp);
+ l1->addWidget(label15, row, 1);
+ l1->addWidget(escaperesp, row++, 2);
+
+ QHBoxLayout *l5 = new QHBoxLayout;
+ l1->addLayout(l5, row, 2);
+ lslider = new QLabel("MMMM", this);
+ FORMATSLIDERLABEL(lslider);
+
+ QSlider *slider = new QSlider(0, 255, 1, 0,
+ QSlider::Horizontal, this);
+// slider->setFixedHeight(slider->sizeHint().height());
+ connect(slider, SIGNAL(valueChanged(int)),
+ lslider, SLOT(setNum(int)));
+ l5->addWidget(lslider, 0);
+ l5->addWidget(slider, 1);
+
+ label16 = new QLabel(i18n("Guard time (sec/50):"), this);
+ l1->addWidget(label16, row++, 1);
+
+ QLabel *l = new QLabel(i18n("Volume off/low/high:"), this);
+ l1->addWidget(l, row, 1);
+ QHBoxLayout *l6 = new QHBoxLayout;
+ l1->addLayout(l6, row++, 2);
+ volume_off = new QLineEdit(this);
+// volume_off->setFixedHeight(volume_off->sizeHint().height());
+ // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2));
+ volume_medium = new QLineEdit(this);
+// volume_medium->setFixedHeight(volume_medium->sizeHint().height());
+ // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2));
+ volume_high = new QLineEdit(this);
+ // volume_high->setFixedHeight(volume_high->sizeHint().height());
+ // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2));
+ l6->addWidget(volume_off);
+ l6->addWidget(volume_medium);
+ l6->addWidget(volume_high);
+
+ initstr[0]->setFocus();
+
+ l1->addColSpacing(0, 10);
+ l1->addColSpacing(3, 10);
+ l1->addRowSpacing(0, 5);
+ l1->addRowSpacing(GRIDROWS, 5);
+
+ //set stuff from gpppdata
+ preinitslider->setValue(gpppdata.modemPreInitDelay());
+ lpreinitslider->setNum(gpppdata.modemPreInitDelay());
+ for(int i = 0; i < PPPData::NumInitStrings; i++)
+ initstr[i]->setText(gpppdata.modemInitStr(i));
+ initslider->setValue(gpppdata.modemInitDelay());
+ linitslider->setNum(gpppdata.modemInitDelay());
+ initresp->setText(gpppdata.modemInitResp());
+
+ durationslider->setValue(gpppdata.modemToneDuration());
+ ldurationslider->setNum(gpppdata.modemToneDuration());
+
+ nodetectdialtone->setText(gpppdata.modemNoDialToneDetectionStr());
+ dialstr->setText(gpppdata.modemDialStr());
+ connectresp->setText(gpppdata.modemConnectResp());
+ busyresp->setText(gpppdata.modemBusyResp());
+ nocarrierresp->setText(gpppdata.modemNoCarrierResp());
+ nodialtoneresp->setText(gpppdata.modemNoDialtoneResp());
+
+ escapestr->setText(gpppdata.modemEscapeStr());
+ escaperesp->setText(gpppdata.modemEscapeResp());
+
+ hangupstr->setText(gpppdata.modemHangupStr());
+ hangupresp->setText(gpppdata.modemHangupResp());
+
+ answerstr->setText(gpppdata.modemAnswerStr());
+ ringresp->setText(gpppdata.modemRingResp());
+ answerresp->setText(gpppdata.modemAnswerResp());
+
+ slider->setValue(gpppdata.modemEscapeGuardTime());
+ lslider->setNum(gpppdata.modemEscapeGuardTime());
+
+ volume_off->setText(gpppdata.volumeOff());
+ volume_medium->setText(gpppdata.volumeMedium());
+ volume_high->setText(gpppdata.volumeHigh());
+}
+
+
+void ModemCommands::slotOk() {
+ gpppdata.setModemPreInitDelay(lpreinitslider->text().toInt());
+ for(int i = 0; i < PPPData::NumInitStrings; i++)
+ gpppdata.setModemInitStr(i, initstr[i]->text());
+ gpppdata.setModemInitResp(initresp->text());
+ gpppdata.setModemInitDelay(linitslider->text().toInt());
+
+ gpppdata.setModemToneDuration(ldurationslider->text().toInt());
+ gpppdata.setModemNoDialToneDetectionStr(nodetectdialtone->text());
+ gpppdata.setModemDialStr(dialstr->text());
+ gpppdata.setModemConnectResp(connectresp->text());
+ gpppdata.setModemBusyResp(busyresp->text());
+ gpppdata.setModemNoCarrierResp(nocarrierresp->text());
+ gpppdata.setModemNoDialtoneResp(nodialtoneresp->text());
+
+ gpppdata.setModemEscapeStr(escapestr->text());
+ gpppdata.setModemEscapeResp(escaperesp->text());
+ gpppdata.setModemEscapeGuardTime(lslider->text().toInt());
+ gpppdata.setModemHangupStr(hangupstr->text());
+ gpppdata.setModemHangupResp(hangupresp->text());
+
+ gpppdata.setModemAnswerStr(answerstr->text());
+ gpppdata.setModemRingResp(ringresp->text());
+ gpppdata.setModemAnswerResp(answerresp->text());
+
+ gpppdata.setVolumeHigh(volume_high->text());
+ gpppdata.setVolumeMedium(volume_medium->text());
+ gpppdata.setVolumeOff(volume_off->text());
+
+ gpppdata.save();
+ accept();
+}
+
+
+void ModemCommands::slotCancel() {
+ reject();
+}
+
+//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h
new file mode 100644
index 0000000..9d078ec
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/modemcmds.h
@@ -0,0 +1,119 @@
+
+/*
+ *
+ * kPPP: A front end for pppd for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+#ifndef _MODEMCMDS_H_
+#define _MODEMCMDS_H_
+
+#include <qgroupbox.h>
+#include <qdialog.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include "pppdata.h"
+
+class ModemCommands : public QDialog {
+
+Q_OBJECT
+
+public:
+
+ ModemCommands(QWidget *parent=0, const char *name=0);
+ ~ModemCommands() {}
+
+private slots:
+ void slotCancel();
+ void slotOk();
+
+private:
+
+ QGroupBox *box;
+
+ QLineEdit *initstr[int(PPPData::NumInitStrings)];
+
+ QLineEdit *initresp;
+ QLabel *label2;
+
+ QLabel *lpreinitslider;
+ QLabel *lpreinit;
+
+ QLabel *linitslider;
+ QLabel *label3;
+
+ QLabel *ldurationslider;
+ QLabel *lduration;
+
+ QLineEdit *nodetectdialtone;
+ QLabel *lnodetectdialtone;
+
+ QLineEdit *dialstr;
+ QLabel *label4;
+
+ QLineEdit *connectresp;
+ QLabel *label5;
+
+ QLineEdit *busyresp;
+ QLabel *label6;
+
+ QLineEdit *nocarrierresp;
+ QLabel *label7;
+
+ QLineEdit *nodialtoneresp;
+ QLabel *label8;
+
+ QLineEdit *hangupstr;
+ QLabel *label9;
+
+ QLineEdit *hangupresp;
+ QLabel *label10;
+
+ QLineEdit *answerstr;
+ QLabel *label11;
+
+ QLineEdit *ringresp;
+ QLabel *label12;
+
+ QLineEdit *answerresp;
+ QLabel *label13;
+
+ QLineEdit *escapestr;
+ QLabel *label14;
+
+ QLineEdit *escaperesp;
+ QLabel *label15;
+
+ QLabel *lslider;
+ QLabel *label16;
+
+ QLineEdit *volume_off, *volume_medium, *volume_high;
+};
+#endif
+
+
+
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index 8c81e67..4dbbcf5 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -100,16 +100,17 @@ void ModemTransfer::ati_done() {
Modem::modem->closetty();
Modem::modem->unlockdevice();
hide();
// open the result window
ModemInfo *mi = new ModemInfo(this);
for(int i = 0; i < NUM_OF_ATI; i++)
mi->setAtiString(i, ati_query_strings[i]);
+ mi->showMaximized();
mi->exec();
delete mi;
accept();
}
void ModemTransfer::time_out_slot() {
diff --git a/noncore/settings/networksettings/ppp/newwidget.cpp b/noncore/settings/networksettings/ppp/newwidget.cpp
new file mode 100644
index 0000000..d2182fb
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/newwidget.cpp
@@ -0,0 +1,17 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// functions generating layout-aware widgets
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "newwidget.h"
+
+QLineEdit *newLineEdit(int visiblewidth, QWidget *parent) {
+ QLineEdit *l = new QLineEdit(parent);
+ if(visiblewidth == 0)
+ l->setMinimumWidth(l->sizeHint().width());
+ else
+ l->setFixedWidth(l->fontMetrics().width('H') * visiblewidth);
+
+ return l;
+}
diff --git a/noncore/settings/networksettings/ppp/newwidget.h b/noncore/settings/networksettings/ppp/newwidget.h
new file mode 100644
index 0000000..52f2ec7
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/newwidget.h
@@ -0,0 +1,19 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// functions generating layout-aware widgets
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __NEWWIDGET__H__
+#define __NEWWIDGET__H__
+
+#include <qwidget.h>
+#include <qlineedit.h>
+
+#define L_FIXEDW 1
+#define L_FIXEDH 2
+#define L_FIXED (L_FIXEDW | L_FIXEDH)
+
+QLineEdit *newLineEdit(int visiblewidth, QWidget *parent);
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index da32395..a456427 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,17 +1,18 @@
#TEMPLATE = app
+#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-HEADERS = pppimp.h pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h
-SOURCES = pppimp.cpp pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp
+HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h knuminput.h knumvalidator.h kpppwidget.h conwindow.h debug.h accounts.h connect.h edit.h scriptedit.h pppdargs.h newwidget.h iplined.h pwentry.h pppconfig.h
+SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp debug.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp newwidget.cpp iplined.cpp pwentry.cpp pppconfig.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
-INTERFACES = ppp.ui
+INTERFACES =
TARGET = pppplugin
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
new file mode 100644
index 0000000..7b2b21b
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -0,0 +1,62 @@
+
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qtabwidget.h>
+
+#include "accounts.h"
+#include "general.h"
+#include "pppconfig.h"
+#include "pppdata.h"
+#include "runtests.h"
+#include "modem.h"
+
+PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name,
+ bool modal, WFlags fl )
+ : QDialog(parent, name, modal, fl)
+{
+ setCaption(tr("Configure Modem"));
+ int result = runTests();
+ if(result == TEST_CRITICAL){
+ QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
+ return;
+ }
+
+// setFixedSize(sizeHint());
+
+ (void)new Modem;
+
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ layout->setSpacing( 0 );
+ layout->setMargin( 1 );
+ tabWindow = new QTabWidget( this, "tabWidget" );
+ layout->addWidget( tabWindow );
+
+ accounts = new AccountWidget( tabWindow, "accounts" );
+ tabWindow->addTab( accounts, tr("&Accounts") );
+ modem1 = new ModemWidget( tabWindow, "modem1" );
+ tabWindow->addTab( modem1, tr("&Device") );
+ modem2 = new ModemWidget2( tabWindow, "modem2" );
+ tabWindow->addTab( modem2, tr("&Modem") );
+// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
+// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
+
+}
+
+
+PPPConfigWidget::~PPPConfigWidget()
+{
+
+}
+
+void PPPConfigWidget::accept()
+{
+ gpppdata.save();
+ QDialog::accept();
+}
+
+
+void PPPConfigWidget::reject()
+{
+ gpppdata.cancel();
+ QDialog::reject();
+}
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
new file mode 100644
index 0000000..ec64878
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -0,0 +1,34 @@
+#ifndef _PPPCONFIG_H_
+#define _PPPCONFIG_H_
+
+#include <qdialog.h>
+
+class QTabWidget;
+class AccountWidget;
+class GeneralWidget;
+class ModemWidget;
+class ModemWidget2;
+
+class PPPConfigWidget : public QDialog {
+ Q_OBJECT
+public:
+
+ PPPConfigWidget( QWidget *parent=0, const char *name=0,
+ bool modal = false, WFlags fl = 0 );
+ ~PPPConfigWidget();
+
+
+protected slots:
+ virtual void accept();
+ virtual void reject();
+
+ private:
+ QTabWidget *tabWindow;
+ AccountWidget *accounts;
+ GeneralWidget *general;
+ ModemWidget *modem1;
+ ModemWidget2 *modem2;
+};
+
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
new file mode 100644
index 0000000..04d0dd0
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -0,0 +1,166 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qlayout.h>
+#include <qbuttongroup.h>
+//#include <kwin.h>
+#include <qapplication.h>
+#include "pppdargs.h"
+#include "pppdata.h"
+//#include <klocale.h>
+#define i18n QObject::tr
+
+PPPdArguments::PPPdArguments(QWidget *parent, const char *name)
+ : QDialog(parent, name, TRUE)
+{
+ setCaption(i18n("Customize pppd Arguments"));
+// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+ QVBoxLayout *l = new QVBoxLayout(this, 10, 10);
+ QHBoxLayout *tl = new QHBoxLayout(10);
+ l->addLayout(tl);
+ QVBoxLayout *l1 = new QVBoxLayout();
+ QVBoxLayout *l2 = new QVBoxLayout();
+ tl->addLayout(l1, 1);
+ tl->addLayout(l2, 0);
+
+ QHBoxLayout *l11 = new QHBoxLayout(10);
+ l1->addLayout(l11);
+
+ argument_label = new QLabel(i18n("Argument:"), this);
+ l11->addWidget(argument_label);
+
+ argument = new QLineEdit(this);
+ connect(argument, SIGNAL(returnPressed()),
+ SLOT(addbutton()));
+ l11->addWidget(argument);
+ connect(argument, SIGNAL(textChanged(const QString &)),
+ this, SLOT(textChanged(const QString &)));
+
+ arguments = new QListBox(this);
+ arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10);
+ connect(arguments, SIGNAL(highlighted(int)),
+ this, SLOT(itemSelected(int)));
+ l1->addWidget(arguments, 1);
+
+ add = new QPushButton(i18n("Add"), this);
+ connect(add, SIGNAL(clicked()), SLOT(addbutton()));
+ l2->addWidget(add);
+ l2->addStretch(1);
+
+ remove = new QPushButton(i18n("Remove"), this);
+ connect(remove, SIGNAL(clicked()), SLOT(removebutton()));
+ l2->addWidget(remove);
+
+ defaults = new QPushButton(i18n("Defaults"), this);
+ connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton()));
+ l2->addWidget(defaults);
+
+ l->addSpacing(5);
+
+ QButtonGroup *bbox = new QButtonGroup(this);
+// bbox->addStretch(1);
+ closebtn = new QPushButton( bbox, i18n("OK"));
+ bbox->insert(closebtn);
+ connect(closebtn, SIGNAL(clicked()), SLOT(closebutton()));
+ QPushButton *cancel = new QPushButton( bbox, i18n("Cancel"));
+ bbox->insert(cancel);
+ connect(cancel, SIGNAL(clicked()),
+ this, SLOT(reject()));
+ bbox->layout();
+ l->addWidget(bbox);
+
+ setFixedSize(sizeHint());
+
+ //load info from gpppdata
+ init();
+
+ add->setEnabled(false);
+ remove->setEnabled(false);
+ argument->setFocus();
+}
+
+
+void PPPdArguments::addbutton() {
+ if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) {
+ arguments->insertItem(argument->text());
+ argument->setText("");
+ }
+}
+
+
+void PPPdArguments::removebutton() {
+ if(arguments->currentItem() >= 0)
+ arguments->removeItem(arguments->currentItem());
+}
+
+
+void PPPdArguments::defaultsbutton() {
+ // all of this is a hack
+ // save current list
+ QStringList arglist(gpppdata.pppdArgument());
+
+ // get defaults
+ gpppdata.setpppdArgumentDefaults();
+ init();
+
+ // restore old list
+ gpppdata.setpppdArgument(arglist);
+}
+
+
+void PPPdArguments::closebutton() {
+ QStringList arglist;
+ for(uint i=0; i < arguments->count(); i++)
+ arglist.append(arguments->text(i));
+ gpppdata.setpppdArgument(arglist);
+
+ done(0);
+}
+
+
+void PPPdArguments::init() {
+ while(arguments->count())
+ arguments->removeItem(0);
+
+ QStringList &arglist = gpppdata.pppdArgument();
+ for ( QStringList::Iterator it = arglist.begin();
+ it != arglist.end();
+ ++it )
+ arguments->insertItem(*it);
+}
+
+
+void PPPdArguments::textChanged(const QString &s) {
+ add->setEnabled(s.length() > 0);
+}
+
+
+void PPPdArguments::itemSelected(int idx) {
+ remove->setEnabled(idx != -1);
+}
+
+
diff --git a/noncore/settings/networksettings/ppp/pppdargs.h b/noncore/settings/networksettings/ppp/pppdargs.h
new file mode 100644
index 0000000..c1cd28d
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pppdargs.h
@@ -0,0 +1,76 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _PPPDARGS_H_
+#define _PPPDARGS_H_
+
+#include <qdialog.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+#include <qlabel.h>
+
+class PPPdArguments : public QDialog {
+Q_OBJECT
+public:
+ PPPdArguments(QWidget *parent=0, const char *name=0);
+ ~PPPdArguments() {}
+
+private slots:
+ void addbutton();
+ void removebutton();
+ void defaultsbutton();
+ void closebutton();
+ void textChanged(const QString &);
+ void itemSelected(int);
+
+private:
+ void init();
+
+ QLabel *argument_label;
+
+ QLineEdit *argument;
+
+ QPushButton *add;
+ QPushButton *remove;
+ QPushButton *defaults;
+
+ QListBox *arguments;
+
+ QPushButton *closebtn;
+};
+#endif
+
+
+
+
+
+
+
+
+
+
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 40d2455..d6ca88a 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,10 +1,12 @@
+#include "pppconfig.h"
#include "pppmodule.h"
-#include "pppimp.h"
+//#include "pppimp.h"
+#include "kpppwidget.h"
#include "interfaceinformationimp.h"
//#include "devices.h"
/**
* Constructor, find all of the possible interfaces
*/
PPPModule::PPPModule() : Module() {
}
@@ -48,28 +50,30 @@ bool PPPModule::isOwner(Interface *i){
return true;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
- PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", /* i,*/ false, Qt::WDestructiveClose);
+ qDebug("return ModemWidget");
+ PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose );
// pppconfig->setProfile(profile);
return pppconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *PPPModule::information(Interface *i){
// We don't have any advanced pppd information widget yet :-D
// TODO ^
+ qDebug("return PPPModule::information");
InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
return information;
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
@@ -81,19 +85,20 @@ QList<Interface> PPPModule::getInterfaces(){
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *PPPModule::addNewInterface(const QString &newInterface){
- // If the
+
qDebug("try to add iface %s",newInterface.latin1());
- PPPConfigureImp imp(0, "PPPConfigImp");
+
+ PPPConfigWidget imp(0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
qDebug("ACCEPTED");
return new Interface( 0, newInterface );
}
return NULL;
}
diff --git a/noncore/settings/networksettings/ppp/pwentry.cpp b/noncore/settings/networksettings/ppp/pwentry.cpp
new file mode 100644
index 0000000..842dc87
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pwentry.cpp
@@ -0,0 +1,116 @@
+/*
+ *
+ * Kppp: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+
+#include <stdio.h>
+#include <qapplication.h>
+#include "pwentry.h"
+
+PWEntry::PWEntry( QWidget *parent, const char *name )
+ : QWidget(NULL, name) {
+
+ if(parent){
+
+ QPoint point = this->mapToGlobal (QPoint (0,0));
+ QRect pos = this->geometry();
+
+ setGeometry(point.x() + pos.width()/2 - 300/2,
+ point.y() + pos.height()/2 - 90/2,
+ 300,
+ 90);
+ }
+// else{
+// int scnum = QApplication::desktop()->screenNumber(parent);
+// QRect desk = QApplication::desktop()->screenGeometry(scnum);
+// setGeometry( desk.center().x() - 150, desk.center().y() - 50, 300, 90 );
+// }
+
+ frame = new QGroupBox(name, this );
+
+ this->setFocusPolicy( QWidget::StrongFocus );
+
+ pw = new QLineEdit( this, "le" );
+ pw->setEchoMode( QLineEdit::Password );
+ connect( pw, SIGNAL(returnPressed()), this, SLOT(hide()) );
+
+ isconsumed = TRUE;
+}
+
+QString PWEntry::text() { return (pw->text()); }
+
+void PWEntry::focusInEvent( QFocusEvent *){
+
+ pw->setFocus();
+
+}
+
+void PWEntry::setEchoModeNormal() {
+
+ pw->setEchoMode(QLineEdit::Normal);
+
+}
+
+void PWEntry::setEchoModePassword() {
+
+ pw->setEchoMode(QLineEdit::Password);
+
+}
+
+void PWEntry::setPrompt(const QString &p) {
+
+ frame->setTitle(p);
+
+}
+
+void PWEntry::resizeEvent(QResizeEvent* ){
+
+ pw->setGeometry( 15,35, this->width() - 30, 25 );
+ frame->setGeometry(5,5,this->width() - 10, this->height() - 10 );
+
+}
+
+
+void PWEntry::show() {
+
+ pw->setText("");
+ isconsumed = FALSE;
+ QWidget::show();
+}
+
+bool PWEntry::Consumed() {
+ return(isconsumed);
+}
+
+void PWEntry::setConsumed() {
+ isconsumed = TRUE;
+}
+
+void PWEntry::hide() {
+ QWidget::hide();
+ return;
+}
+
+//#include "pwentry.moc"
diff --git a/noncore/settings/networksettings/ppp/pwentry.h b/noncore/settings/networksettings/ppp/pwentry.h
new file mode 100644
index 0000000..4a5e554
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/pwentry.h
@@ -0,0 +1,72 @@
+/*
+ *
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef PWENTRY_H
+#define PWENTRY_H
+
+#include <qwidget.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+
+class PWEntry : public QWidget {
+
+ Q_OBJECT
+
+public:
+
+ PWEntry( QWidget *parent=0, const char *name=0 );
+ bool Consumed();
+ void setConsumed();
+ QString text();
+ void setPrompt(const QString &);
+
+public slots:
+
+ void setEchoModeNormal();
+ void setEchoModePassword();
+ void hide();
+ void show();
+
+signals:
+
+ void returnPressed();
+
+protected:
+
+ void resizeEvent(QResizeEvent* qre);
+ void focusInEvent( QFocusEvent *);
+
+private:
+
+ QGroupBox *frame;
+ QLineEdit *pw;
+ QLabel *pl;
+ bool isconsumed;
+
+};
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/scriptedit.cpp b/noncore/settings/networksettings/ppp/scriptedit.cpp
new file mode 100644
index 0000000..b8afad5
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/scriptedit.cpp
@@ -0,0 +1,174 @@
+
+/*
+ * kPPP: A front end for pppd for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "scriptedit.h"
+#include <qlayout.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+
+ScriptEdit::ScriptEdit( QWidget *parent, const char *name )
+ : QWidget(parent, name)
+{
+ QHBoxLayout *tl = new QHBoxLayout(this, 0, 10);
+
+ st = new QComboBox(this, "st");
+ st->insertItem("Expect");
+ st->insertItem("Send");
+ st->insertItem("Pause (sec)");
+ st->insertItem("Hangup");
+ st->insertItem("Answer");
+ st->insertItem("Timeout (sec)");
+ st->insertItem("Password");
+ st->insertItem("ID");
+ st->insertItem("Prompt");
+ st->insertItem("PWPrompt");
+ st->insertItem("LoopStart");
+ st->insertItem("LoopEnd");
+ st->insertItem("Scan");
+ st->insertItem("Save");
+ st->insertItem("SendNoEcho");
+ connect(st, SIGNAL(activated(int)), SLOT(setType(int)));
+
+ se = new QLineEdit(this, "se");
+ se->setGeometry(120, 5, 140, 25);
+ se->setMaxLength(50);
+ connect(se, SIGNAL(returnPressed()), SLOT(seReturnPressed()));
+
+ tl->addWidget(st, 3);
+ tl->addWidget(se, 7);
+
+ setType(0);
+
+ tl->activate();
+}
+
+
+void ScriptEdit::setEnabled(bool b) {
+ se->setEnabled(b);
+ st->setEnabled(b);
+}
+
+void ScriptEdit::seReturnPressed() {
+ emit returnPressed();
+}
+
+
+QString ScriptEdit::text() {
+ return se->text();
+}
+
+void ScriptEdit::setText(const QString &t) {
+ se->setText(t);
+}
+
+
+int ScriptEdit::type() {
+ return st->currentItem();
+}
+
+void ScriptEdit::setType(int i) {
+ switch(i) {
+ case Expect:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Send:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Pause:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Hangup:
+ se->setText("");
+ se->setEnabled(FALSE);
+ break;
+
+ case Answer:
+ se->setText("");
+ se->setEnabled(FALSE);
+ break;
+
+ case Timeout:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Password:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case ID:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Prompt:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case PWPrompt:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case LoopStart:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case LoopEnd:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Scan:
+ se->setText("");
+ se->setEnabled(TRUE);
+ break;
+
+ case Save:
+ se->setText("password");
+ se->setEnabled(FALSE);
+ break;
+
+ default: break;
+ }
+}
+
+
+
+
+
+
+
diff --git a/noncore/settings/networksettings/ppp/scriptedit.h b/noncore/settings/networksettings/ppp/scriptedit.h
new file mode 100644
index 0000000..47565b8
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/scriptedit.h
@@ -0,0 +1,79 @@
+
+/*
+ * kPPP: A front end for pppd for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _SCRIPTEDIT_H_
+#define _SCRIPTEDIT_H_
+
+#include <qwidget.h>
+
+class QComboBox;
+class QLineEdit;
+
+class ScriptEdit : public QWidget {
+Q_OBJECT
+public:
+ ScriptEdit( QWidget *parent=0, const char *name=0 );
+ ~ScriptEdit() {}
+
+ QString text();
+ void setText(const QString &);
+ int type();
+
+ virtual void setEnabled(bool);
+
+signals:
+ void returnPressed();
+
+private slots:
+ void setType(int);
+ void seReturnPressed();
+
+private:
+ QComboBox *st;
+ QLineEdit *se;
+
+public:
+ enum setypes { Expect = 0,
+ Send = 1,
+ Pause = 2,
+ Hangup = 3,
+ Answer = 4,
+ Timeout = 5,
+ Password = 6,
+ ID = 7,
+ Prompt = 8,
+ PWPrompt = 9,
+ LoopStart = 10,
+ LoopEnd = 11,
+ Scan = 12,
+ Save = 13,
+ SendNoEcho = 14
+ };
+};
+
+#endif
+