summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp104
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp180
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp26
-rw-r--r--noncore/settings/networksettings/ppp/debug.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp232
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp42
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp150
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp30
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp111
-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.pro4
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp10
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp211
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h56
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp3
17 files changed, 587 insertions, 614 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index d902517..19db9ef 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -1,491 +1,495 @@
/*
* 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;
+// 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);
+// 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);
+// 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());
+ if(PPPData::data()->count() > 0) {
+ for(int i=0; i <= PPPData::data()->count()-1; i++) {
+ PPPData::data()->setAccountbyIndex(i);
+ accountlist_l->insertItem(PPPData::data()->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());
+ QString account = PPPData::data()->accname();
+ PPPData::data()->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();
+// int bytes = PPPData::data()->totalBytes();
// voledit->setText(prettyPrintVolume(bytes));
- gpppdata.setAccount(account);
+ PPPData::data()->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()));
+ PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
- accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem());
+ accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->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)
+// if (PPPData::data()->newaccount() == -1)
// return;
// // ProviderDB pdb(this);
// // result = pdb.exec();
// break;
// }
// case QMessageBox::No:
- if (gpppdata.newaccount() == -1){
- qDebug("gpppdata.newaccount() == -1");
+ if (PPPData::data()->newaccount() == -1){
+ qDebug("PPPData::data()->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()),
+ accountlist_l->insertItem(PPPData::data()->accname());
+ accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
true);
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->save();
} else
- gpppdata.deleteAccount();
+ PPPData::data()->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());
+ PPPData::data()->copyaccount(accountlist_l->currentItem());
- accountlist_l->insertItem(gpppdata.accname());
+ accountlist_l->insertItem(PPPData::data()->accname());
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->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())))
+ if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
accountlist_l->removeItem(accountlist_l->currentItem());
emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->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());
+ QDialog *dlg = new QDialog( this, "newAccount", true );
+ QVBoxLayout *layout = new QVBoxLayout( dlg );
+ layout->setSpacing( 0 );
+ layout->setMargin( 1 );
+
+ tabWindow = new QTabWidget( dlg, "tabWindow" );
+ layout->addWidget( tabWindow );
+
bool isnewaccount;
- if(gpppdata.accname().isEmpty()) {
- tabWindow->setCaption(i18n("New Account"));
+ if(PPPData::data()->accname().isEmpty()) {
+ dlg->setCaption(i18n("New Account"));
isnewaccount = true;
} else {
QString tit = i18n("Edit Account: ");
- tit += gpppdata.accname();
- tabWindow->setCaption(tit);
+ tit += PPPData::data()->accname();
+ dlg->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);
+ dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
+ tabWindow->addTab( dial_w, i18n("Dial") );
+ ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
+ tabWindow->addTab( ip_w, i18n("IP") );
+ gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
+ tabWindow->addTab( gateway_w, i18n("Gateway") );
+ dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
+ tabWindow->addTab( dns_w, i18n("DNS") );
+ script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
+ tabWindow->addTab( script_w, i18n("Login Script") );
+ ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
+ tabWindow->addTab( exec_w, i18n("Execute") );
// acct = new AccountingSelector( tabWindow, isnewaccount );
// tabWindow->addTab( acct, i18n("Accounting"));
int result = 0;
bool ok = false;
+ qDebug("AccountWidget::doTab dlg->showMinimized");
+ dlg->showMinimized();
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/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index b7e229e..a3eda9d 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1,1438 +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);
+ PPPData::data()->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());
+// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect());
- comlist = &gpppdata.scriptType();
- arglist = &gpppdata.script();
+ comlist = &PPPData::data()->scriptType();
+ arglist = &PPPData::data()->script();
- QString tit = i18n("Connecting to: %1").arg(gpppdata.accname());
+ QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
setCaption(tit);
qApp->processEvents();
// run the "before-connect" command
- if (!gpppdata.command_before_connect().isEmpty()) {
+ if (!PPPData::data()->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());
+ pid_t id = execute_command(PPPData::data()->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);
+ timeout_timer->start(PPPData::data()->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);
+ QString initStr = PPPData::data()->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);
+ if(PPPData::data()->modemPreInitDelay() > 0) {
+ usleep(PPPData::data()->modemPreInitDelay() * 5000);
writeline("");
- usleep(gpppdata.modemPreInitDelay() * 5000);
+ usleep(PPPData::data()->modemPreInitDelay() * 5000);
}
- setExpect(gpppdata.modemInitResp());
+ setExpect(PPPData::data()->modemInitResp());
writeline(initStr);
- usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(PPPData::data()->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())
+ if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration())
vmain = 5;
else
vmain = 3;
return;
}
if (vmain == 5) {
if(!expecting) {
- QString sToneDuration = "ATS11=" + QString::number(gpppdata.modemToneDuration());
+ QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration());
QString msg = i18n("Setting ") + sToneDuration;
messg->setText(msg);
emit debugMessage(msg);
- setExpect(gpppdata.modemInitResp());
+ setExpect(PPPData::data()->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()) {
+ if(PPPData::data()->volumeInitString().isEmpty()) {
vmain = 4;
return;
}
messg->setText(i18n("Setting speaker volume..."));
emit debugMessage(i18n("Setting speaker volume..."));
- setExpect(gpppdata.modemInitResp());
+ setExpect(PPPData::data()->modemInitResp());
QString vol("AT");
- vol += gpppdata.volumeInitString();
+ vol += PPPData::data()->volumeInitString();
writeline(vol);
- usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
vmain = 4;
return;
}
}
if(vmain == 4) {
if(!expecting) {
- if(!gpppdata.waitForDialTone()) {
+ if(!PPPData::data()->waitForDialTone()) {
QString msg = i18n("Turning off dial tone waiting...");
messg->setText(msg);
emit debugMessage(msg);
- setExpect(gpppdata.modemInitResp());
- writeline(gpppdata.modemNoDialToneDetectionStr());
+ setExpect(PPPData::data()->modemInitResp());
+ writeline(PPPData::data()->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);
+ timeout_timer->start(PPPData::data()->modemTimeout()*1000);
- QStringList &plist = gpppdata.phonenumbers();
- QString bmarg= gpppdata.dialPrefix();
+ QStringList &plist = PPPData::data()->phonenumbers();
+ QString bmarg= PPPData::data()->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();
+ QString pn = PPPData::data()->modemDialStr();
+ pn += PPPData::data()->dialPrefix();
pn += *plist.at(dialnumber);
if(++dialnumber >= plist.count())
dialnumber = 0;
writeline(pn);
- setExpect(gpppdata.modemConnectResp());
+ setExpect(PPPData::data()->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();
+ myreadbuffer = PPPData::data()->modemConnectResp();
setExpect("\n");
vmain = 101;
return;
}
- if(readbuffer.contains(gpppdata.modemBusyResp())) {
+ if(readbuffer.contains(PPPData::data()->modemBusyResp())) {
timeout_timer->stop();
- timeout_timer->start(gpppdata.modemTimeout()*1000);
+ timeout_timer->start(PPPData::data()->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());
+ if(PPPData::data()->busyWait() > 0) {
+ QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait());
messg->setText(bm);
emit debugMessage(bm);
pausing = true;
- pausetimer->start(gpppdata.busyWait()*1000, true);
+ pausetimer->start(PPPData::data()->busyWait()*1000, true);
timeout_timer->stop();
}
Modem::modem->setDataMode(false);
vmain = 0;
substate = -1;
return;
}
- if(readbuffer.contains(gpppdata.modemNoDialtoneResp())) {
+ if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) {
timeout_timer->stop();
messg->setText(i18n("No Dialtone"));
vmain = 20;
Modem::modem->unlockdevice();
return;
}
- if(readbuffer.contains(gpppdata.modemNoCarrierResp())) {
+ if(readbuffer.contains(PPPData::data()->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;
+ scriptTimeout=PPPData::data()->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);
+ PPPData::data()->setPassword(scanvar);
p_kppp->setPW_Edit(scanvar);
- if(gpppdata.storePassword())
- gpppdata.setStoredPassword(scanvar);
+ if(PPPData::data()->storePassword())
+ PPPData::data()->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());
+ arg = arg.replace(re1, PPPData::data()->storedUsername());
+ arg = arg.replace(re2, PPPData::data()->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());
+ writeline(PPPData::data()->modemHangupStr());
+ setExpect(PPPData::data()->modemHangupResp());
scriptindex++;
return;
}
if (scriptCommand == "Answer") {
timeout_timer->stop();
messg->setText(i18n("Answer"));
emit debugMessage(i18n("Answer"));
- setExpect(gpppdata.modemRingResp());
+ setExpect(PPPData::data()->modemRingResp());
vmain = 150;
return;
}
if (scriptCommand == "ID") {
QString bm = i18n("ID %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
- QString idstring = gpppdata.storedUsername();
+ QString idstring = PPPData::data()->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();
+ QString pwstring = PPPData::data()->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());
+ writeline(PPPData::data()->modemAnswerStr());
+ setExpect(PPPData::data()->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(PPPData::data()->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);
+ if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000);
+ qDebug( "started if timeout timer with %i", PPPData::data()->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())
+ if(!PPPData::data()->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);
+ PPPData::data()->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) {
+// if(PPPData::data()->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())
+ if(PPPData::data()->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()) {
+ if(!PPPData::data()->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());
+ execute_command(PPPData::data()->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()) {
+ if (PPPData::data()->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()) {
+ if(PPPData::data()->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 += PPPData::data()->modemDevice();
- command += " " + gpppdata.speed();
+ command += " " + PPPData::data()->speed();
command += " -detach";
- if(gpppdata.ipaddr() != "0.0.0.0" ||
- gpppdata.gateway() != "0.0.0.0") {
- if(gpppdata.ipaddr() != "0.0.0.0") {
+ if(PPPData::data()->ipaddr() != "0.0.0.0" ||
+ PPPData::data()->gateway() != "0.0.0.0") {
+ if(PPPData::data()->ipaddr() != "0.0.0.0") {
command += " ";
- command += gpppdata.ipaddr();
+ command += PPPData::data()->ipaddr();
command += ":";
}
else {
command += " ";
command += ":";
}
- if(gpppdata.gateway() != "0.0.0.0")
- command += gpppdata.gateway();
+ if(PPPData::data()->gateway() != "0.0.0.0")
+ command += PPPData::data()->gateway();
}
- if(gpppdata.subnetmask() != "0.0.0.0")
- command += " netmask " + gpppdata.subnetmask();
+ if(PPPData::data()->subnetmask() != "0.0.0.0")
+ command += " netmask " + PPPData::data()->subnetmask();
- if(gpppdata.flowcontrol() != "None") {
- if(gpppdata.flowcontrol() == "CRTSCTS")
+ if(PPPData::data()->flowcontrol() != "None") {
+ if(PPPData::data()->flowcontrol() == "CRTSCTS")
command += " crtscts";
else
command += " xonxoff";
}
- if(gpppdata.defaultroute())
+ if(PPPData::data()->defaultroute())
command += " defaultroute";
- if(gpppdata.autoDNS())
+ if(PPPData::data()->autoDNS())
command += " usepeerdns";
- QStringList &arglist = gpppdata.pppdArgument();
+ QStringList &arglist = PPPData::data()->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
++it )
{
command += " " + *it;
}
// PAP settings
- if(gpppdata.authMethod() == AUTH_PAP) {
+ if(PPPData::data()->authMethod() == AUTH_PAP) {
command += " -chap user ";
- command = command + "\"" + gpppdata.storedUsername() + "\"";
+ command = command + "\"" + PPPData::data()->storedUsername() + "\"";
}
// CHAP settings
- if(gpppdata.authMethod() == AUTH_CHAP) {
+ if(PPPData::data()->authMethod() == AUTH_CHAP) {
command += " -pap user ";
- command = command + "\"" + gpppdata.storedUsername() + "\"";
+ command = command + "\"" + PPPData::data()->storedUsername() + "\"";
}
// PAP/CHAP settings
- if(gpppdata.authMethod() == AUTH_PAPCHAP) {
+ if(PPPData::data()->authMethod() == AUTH_PAPCHAP) {
command += " user ";
- command = command + "\"" + gpppdata.storedUsername() + "\"";
+ command = command + "\"" + PPPData::data()->storedUsername() + "\"";
}
// check for debug
- if(gpppdata.getPPPDebug())
+ if(PPPData::data()->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()) {
+ // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) {
+ if ( PPPData::data()->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()))
+ && PPPData::data()->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();
+ QStringList &dnslist = PPPData::data()->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());
+ add_domain(PPPData::data()->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());
+ add_domain(PPPData::data()->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/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index d6b3fbe..ad89005 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -1,341 +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);
+// int p_x, p_y;
+// PPPData::data()->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());
+// PPPData::data()->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();
+ volumeAccountingEnabled = PPPData::data()->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())
+ if(PPPData::data()->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();
+ title = PPPData::data()->accname();
- if(gpppdata.get_show_clock_on_caption()){
+ if(PPPData::data()->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(PPPData::data()->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();
+ int bytes = PPPData::data()->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 = PPPData::data()->accname();
caption_string += " ";
caption_string += time_string;
timelabel2->setText(time_string2);
- if(gpppdata.get_show_clock_on_caption() && (seconds == 1)){
+ if(PPPData::data()->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())
+ if(PPPData::data()->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/debug.cpp b/noncore/settings/networksettings/ppp/debug.cpp
index 8652931..447ccf2 100644
--- a/noncore/settings/networksettings/ppp/debug.cpp
+++ b/noncore/settings/networksettings/ppp/debug.cpp
@@ -1,141 +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);
+ PPPData::data()->set_show_log_window(showlog);
}
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 961047b..6132b80 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -1,1193 +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 "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());
+ QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
- connect_label = new QLabel(i18n("Connection name:"), parent);
+ connect_label = new QLabel(i18n("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
- connectname_l = new QLineEdit(parent);
- connectname_l->setMaxLength(ACCNAME_SIZE);
+ connectname_l = new QLineEdit(this);
+// 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 = new QLabel(i18n("Phone number:"), this);
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 = new QListBox(this);
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);
+ add = new QPushButton(i18n("&Add..."), this);
+ del = new QPushButton(i18n("&Remove"), this);
- up = new QPushButton(parent);
+ up = new QPushButton(this);
//FIXME: QPixmap pm = BarIcon("up");
// up->setPixmap(pm);
- down = new QPushButton(parent);
+ down = new QPushButton(this);
//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);
+ auth_l = new QLabel(i18n("Authentication:"), this);
tl->addWidget(auth_l, 3, 0);
- auth = new QComboBox(parent);
+ auth = new QComboBox(this);
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 = new QCheckBox(i18n("Store password"), this);
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);
+ pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this);
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());
+ connectname_l->setText(PPPData::data()->accname());
// insert the phone numbers into the listbox
- QString n = gpppdata.phonenumber();
+ QString n = PPPData::data()->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());
+ auth->setCurrentItem(PPPData::data()->authMethod());
+ store_password->setChecked(PPPData::data()->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())) {
+ !PPPData::data()->isUniqueAccname(connectname_l->text())) {
return false;
} else {
- gpppdata.setAccname(connectname_l->text());
+ PPPData::data()->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());
+ PPPData::data()->setPhonenumber(number);
+ PPPData::data()->setAuthMethod(auth->currentItem());
+ PPPData::data()->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());
+ QVBoxLayout *tl = new QVBoxLayout(this, 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());
+ "kppp might be unable to find it."), this);
+// 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 = new QLabel(i18n("Before connect:"), this);
before_connect_l->setAlignment(AlignVCenter);
l1->addWidget(before_connect_l, 0, 0);
- before_connect = new QLineEdit(parent);
- before_connect->setMaxLength(COMMAND_SIZE);
+ before_connect = new QLineEdit(this);
+// 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 = new QLabel(i18n("Upon connect:"), this);
command_label->setAlignment(AlignVCenter);
l1->addWidget(command_label, 1, 0);
- command = new QLineEdit(parent);
- command->setMaxLength(COMMAND_SIZE);
+ command = new QLineEdit(this);
+// 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);
+ this);
predisconnect_label->setAlignment(AlignVCenter);
l1->addWidget(predisconnect_label, 2, 0);
- predisconnect = new QLineEdit(parent);
- predisconnect->setMaxLength(COMMAND_SIZE);
+ predisconnect = new QLineEdit(this);
+// 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);
+ this);
discommand_label->setAlignment(AlignVCenter);
l1->addWidget(discommand_label, 3, 0);
- discommand = new QLineEdit(parent);
- discommand->setMaxLength(COMMAND_SIZE);
+ discommand = new QLineEdit(this);
+// 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());
+ before_connect->setText(PPPData::data()->command_before_connect());
+ command->setText(PPPData::data()->command_on_connect());
+ discommand->setText(PPPData::data()->command_on_disconnect());
+ predisconnect->setText(PPPData::data()->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());
+ PPPData::data()->setCommand_before_connect(before_connect->text());
+ PPPData::data()->setCommand_on_connect(command->text());
+ PPPData::data()->setCommand_before_disconnect(predisconnect->text());
+ PPPData::data()->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);
+ QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 3 );//KDialog::spacingHint());
- box = new QVGroupBox(i18n("Configuration"), parent);
+ box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
- rb = new QButtonGroup(parent);
+ rb = new QButtonGroup(this);
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());
+ autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this);
+ autoname->setChecked(PPPData::data()->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") {
+ if(PPPData::data()->ipaddr() == "0.0.0.0" &&
+ PPPData::data()->subnetmask() == "0.0.0.0") {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
- autoname->setChecked(gpppdata.autoname());
+ autoname->setChecked(PPPData::data()->autoname());
}
else {
- ipaddress_l->setText(gpppdata.ipaddr());
- subnetmask_l->setText(gpppdata.subnetmask());
+ ipaddress_l->setText(PPPData::data()->ipaddr());
+ subnetmask_l->setText(PPPData::data()->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");
+ PPPData::data()->setIpaddr("0.0.0.0");
+ PPPData::data()->setSubnetmask("0.0.0.0");
} else {
- gpppdata.setIpaddr(ipaddress_l->text());
- gpppdata.setSubnetmask(subnetmask_l->text());
+ PPPData::data()->setIpaddr(ipaddress_l->text());
+ PPPData::data()->setSubnetmask(subnetmask_l->text());
}
- gpppdata.setAutoname(autoname->isChecked());
+ PPPData::data()->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());
+ // box = new QGroupBox(this);
+ QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
- dnsdomain_label = new QLabel(i18n("Domain name:"), parent);
+ dnsdomain_label = new QLabel(i18n("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
- dnsdomain = new QLineEdit(parent);
- dnsdomain->setMaxLength(DOMAIN_SIZE);
+ dnsdomain = new QLineEdit(this);
+// 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);
+ conf_label = new QLabel(i18n("Configuration:"), this);
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);
+ autodns = new QRadioButton(i18n("Automatic"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
// no automatic DNS detection for pppd < 2.3.7
- if(!gpppdata.pppdVersionMin(2, 3, 7))
+ if(!PPPData::data()->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
- mandns = new QRadioButton(i18n("Manual"), parent);
+ mandns = new QRadioButton(i18n("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
- dns_label = new QLabel(i18n("DNS IP address:"), parent);
+ dns_label = new QLabel(i18n("DNS IP address:"), this);
tl->addWidget(dns_label, 3, 0);
QHBoxLayout *l2 = new QHBoxLayout;
tl->addLayout(l2, 3, 1);
- dnsipaddr = new IPLineEdit(parent);
+ dnsipaddr = new IPLineEdit(this);
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);
+ add = new QPushButton(i18n("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(adddns()));
- int width = add->sizeHint().width();
- width = QMAX(width,60);
- add->setMinimumWidth(width);
+// 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);
+ remove = new QPushButton(i18n("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removedns()));
- width = remove->sizeHint().width();
- width = QMAX(width,60);
- remove->setMinimumWidth(width);
+// 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 = new QLabel(i18n("DNS address list:"), this);
servers_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(servers_label, 5, 0);
- dnsservers = new QListBox(parent);
+ dnsservers = new QListBox(this);
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());
+ this);
+ exdnsdisabled_toggle->setChecked(PPPData::data()->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());
+ dnsservers->insertStringList(PPPData::data()->dns());
+ dnsdomain->setText(PPPData::data()->domain());
}
- int mode = gpppdata.autoDNS() ? 0 : 1;
+ int mode = PPPData::data()->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);
+ PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
- gpppdata.setDns(serverlist);
+ PPPData::data()->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
- gpppdata.setDomain(s.mid(1));
+ PPPData::data()->setDomain(s.mid(1));
else
- gpppdata.setDomain(dnsdomain->text());
+ PPPData::data()->setDomain(dnsdomain->text());
- gpppdata.setExDNSDisabled(exdnsdisabled_toggle->isChecked());
+ PPPData::data()->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);
+ QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );//KDialog::spacingHint());
- box = new QVGroupBox(i18n("Configuration"), parent);
+ box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 2 );//KDialog::spacingHint());
- rb = new QButtonGroup(parent);
+ rb = new QButtonGroup(this);
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);
+ this);
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") {
+ if(PPPData::data()->gateway() == "0.0.0.0") {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
}
else {
- gatewayaddr->setText(gpppdata.gateway());
+ gatewayaddr->setText(PPPData::data()->gateway());
staticgateway->setChecked(true);
}
- defaultroute->setChecked(gpppdata.defaultroute());
+ defaultroute->setChecked(PPPData::data()->defaultroute());
}
else {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
defaultroute->setChecked(true);
}
}
void GatewayWidget::save() {
- gpppdata.setGateway(gatewayaddr->text());
- gpppdata.setDefaultroute(defaultroute->isChecked());
+ PPPData::data()->setGateway(gatewayaddr->text());
+ PPPData::data()->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);
+ QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
+ se = new ScriptEdit(this);
connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
tl->addWidget(se);
// insert equal-sized buttons
- QButtonGroup *bbox = new QButtonGroup(parent);
+ QButtonGroup *bbox = new QButtonGroup(this);
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 = new QListBox(this);
stl->setVScrollBarMode( QScrollView::AlwaysOff );
connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
stl->setMinimumSize(QSize(70, 140));
- sl = new QListBox(parent);
+ sl = new QListBox(this);
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());
+ slb = new QScrollBar(this);
+// 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 &comlist = PPPData::data()->scriptType();
+ QStringList &arglist = PPPData::data()->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);
+ PPPData::data()->setScriptType(typelist);
+ PPPData::data()->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 ) {
+ : QDialog(parent,"PhoneNumberDialog",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);
+ le = new QLineEdit(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/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index f803628..a02ee35 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,421 +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))
+ if(PPPData::data()->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());
+ modemlockfile->setChecked(PPPData::data()->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 = new KIntNumInput(PPPData::data()->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))
+ if(PPPData::data()->enter() == enter->text(i))
enter->setCurrentItem(i);
}
for(int i=0; i <= modemdevice->count()-1; i++) {
- if(gpppdata.modemDevice() == modemdevice->text(i))
+ if(PPPData::data()->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
for(int i=0; i <= flowcontrol->count()-1; i++) {
- if(gpppdata.flowcontrol() == flowcontrol->text(i))
+ if(PPPData::data()->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())
+ if(baud_c->text(i) == PPPData::data()->speed())
baud_c->setCurrentItem(i);
tl->setRowStretch(7, 1);
}
void ModemWidget::speed_selection(int) {
- gpppdata.setSpeed(baud_c->text(baud_c->currentItem()));
+ PPPData::data()->setSpeed(baud_c->text(baud_c->currentItem()));
}
void ModemWidget::setenter(int ) {
- gpppdata.setEnter(enter->text(enter->currentItem()));
+ PPPData::data()->setEnter(enter->text(enter->currentItem()));
}
void ModemWidget::setmodemdc(int i) {
- gpppdata.setModemDevice(modemdevice->text(i));
+ PPPData::data()->setModemDevice(modemdevice->text(i));
}
void ModemWidget::setflowcontrol(int i) {
- gpppdata.setFlowcontrol(flowcontrol->text(i));
+ PPPData::data()->setFlowcontrol(flowcontrol->text(i));
}
void ModemWidget::modemlockfilechanged(bool set) {
- gpppdata.setModemLockFile(set);
+ PPPData::data()->setModemLockFile(set);
}
void ModemWidget::modemtimeoutchanged(int n) {
- gpppdata.setModemTimeout(n);
+ PPPData::data()->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());
+ waitfordt->setChecked(PPPData::data()->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 = new KIntNumInput(PPPData::data()->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);
+ volume = new QSlider(0, 2, 1, PPPData::data()->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());
+ chkbox1->setChecked(PPPData::data()->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);
+ PPPData::data()->setUseCDLine(on);
}
#endif
void ModemWidget2::waitfordtchanged(bool b) {
- gpppdata.setWaitForDialTone((int)b);
+ PPPData::data()->setWaitForDialTone((int)b);
}
void ModemWidget2::busywaitchanged(int n) {
- gpppdata.setbusyWait(n);
+ PPPData::data()->setbusyWait(n);
}
void ModemWidget2::volumeChanged(int v) {
- gpppdata.setVolume(v);
+ PPPData::data()->setVolume(v);
}
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index 2f9feda..8d70cd4 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -1,905 +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());
+// log->setChecked(PPPData::data()->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)
+// if(PPPData::data()->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);
+// bool result = PPPData::data()->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();
+ PPPData::data()->save();
}
void KPPPWidget::shutDown() {
interruptConnection();
saveMyself();
}
void KPPPWidget::log_window_toggled(bool on) {
- gpppdata.set_show_log_window(on);
+ PPPData::data()->set_show_log_window(on);
}
// void KPPPWidget::resetaccounts() {
// connectto_c->clear();
-// int count = gpppdata.count();
+// int count = PPPData::data()->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());
+// PPPData::data()->setAccountbyIndex(i);
+// connectto_c->insertItem(PPPData::data()->accname());
// }
// //set the default account
-// if(!gpppdata.defaultAccount().isEmpty()) {
+// if(!PPPData::data()->defaultAccount().isEmpty()) {
// for(int i=0; i < count; i++)
-// if(gpppdata.defaultAccount() == connectto_c->text(i)) {
+// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) {
// connectto_c->setCurrentItem(i);
-// gpppdata.setAccountbyIndex(i);
+// PPPData::data()->setAccountbyIndex(i);
-// ID_Edit->setText(gpppdata.storedUsername());
-// PW_Edit->setText(gpppdata.storedPassword());
+// ID_Edit->setText(PPPData::data()->storedUsername());
+// PW_Edit->setText(PPPData::data()->storedPassword());
// }
// }
// else
// if(count > 0) {
-// gpppdata.setDefaultAccount(connectto_c->text(0));
-// gpppdata.save();
-// ID_Edit->setText(gpppdata.storedUsername());
-// PW_Edit->setText(gpppdata.storedPassword());
+// PPPData::data()->setDefaultAccount(connectto_c->text(0));
+// PPPData::data()->save();
+// ID_Edit->setText(PPPData::data()->storedUsername());
+// PW_Edit->setText(PPPData::data()->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())
+ if (PPPData::data()->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()) {
+ if(PPPData::data()->pppdRunning() || PPPData::data()->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);
+ PPPData::data()->setpppdRunning(false);
qDebug( "Executing command on disconnect since pppd has died." );
QApplication::flushX();
- execute_command(gpppdata.command_on_disconnect());
+ execute_command(PPPData::data()->command_on_disconnect());
// stopAccounting();
// con_win->stopClock();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
- if(!gpppdata.pppdError())
- gpppdata.setpppdError(E_PPPD_DIED);
+ if(!PPPData::data()->pppdError())
+ PPPData::data()->setpppdError(E_PPPD_DIED);
removedns();
Modem::modem->unlockdevice();
// con->pppdDied();
- if(!gpppdata.automatic_redial()) {
+ if(!PPPData::data()->automatic_redial()) {
quit_b->setFocus();
show();
// con_win->stopClock();
// stopAccounting();
// con_win->hide();
// con->hide();
- gpppdata.setpppdRunning(false);
+ PPPData::data()->setpppdRunning(false);
// // not in a signal handler !!! KNotifyClient::beep();
QString msg;
- if (gpppdata.pppdError() == E_IF_TIMEOUT)
+ if (PPPData::data()->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()));
+ if(PPPData::data()->authMethod() == AUTH_PAP ||
+ PPPData::data()->authMethod() == AUTH_CHAP ||
+ PPPData::data()->authMethod() == AUTH_PAPCHAP)
+ Modem::modem->setSecret(PPPData::data()->authMethod(),
+ encodeWord(PPPData::data()->storedUsername()),
+ encodeWord(PPPData::data()->password()));
// con_win->hide();
// con_win->stopClock();
// stopAccounting();
- gpppdata.setpppdRunning(false);
+ PPPData::data()->setpppdRunning(false);
// not in a signal handler !!! KNotifyClient::beep();
emit cmdl_start();
}
}
- gpppdata.setpppdError(0);
+ PPPData::data()->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());
+ PPPData::data()->setDefaultAccount(connectto_c->text(i));
+ PPPData::data()->save();
+ ID_Edit->setText(PPPData::data()->storedUsername());
+ PW_Edit->setText(PPPData::data()->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());
+// PPPData::data()->setAccount(connectto_c->currentText());
+// PPPData::data()->setPassword(PW_Edit->text());
// } else {
- gpppdata.setPassword(gpppdata.storedPassword());
+ PPPData::data()->setPassword(PPPData::data()->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());
+ "pppd is executable.").arg(PPPData::data()->pppdPath());
KMessageBox::error(this, string);
return;
}
#endif
- QFileInfo info2(gpppdata.modemDevice());
+ QFileInfo info2(PPPData::data()->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());
+ "the setup dialog.").arg(PPPData::data()->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(PPPData::data()->authMethod() == AUTH_PAP ||
+ PPPData::data()->authMethod() == AUTH_CHAP ||
+ PPPData::data()->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()))) {
+ if(!Modem::modem->setSecret(PPPData::data()->authMethod(),
+ encodeWord(PPPData::data()->storedUsername()),
+ encodeWord(PPPData::data()->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()) {
+ if (PPPData::data()->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());
+ QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
// con->setCaption(tit);
// con->show();
- bool show_debug = gpppdata.get_show_log_window();
+ bool show_debug = PPPData::data()->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()) {
+ if (!PPPData::data()->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());
+ execute_command(PPPData::data()->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());
+ execute_command(PPPData::data()->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()) {
+ if(PPPData::data()->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());
+ execute_command(PPPData::data()->command_on_disconnect());
removedns();
Modem::modem->unlockdevice();
}
} else {
- if (!gpppdata.accname().isEmpty() && !gpppdata.storePassword())
- gpppdata.setStoredPassword("");
+ if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword())
+ PPPData::data()->setStoredPassword("");
}
- gpppdata.save();
+ PPPData::data()->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;
+// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl;
// // load the ruleset
-// if(!gpppdata.AcctEnabled())
+// if(!PPPData::data()->AcctEnabled())
// return;
-// QString d = AccountingBase::getAccountingFile(gpppdata.accountingFile());
+// QString d = AccountingBase::getAccountingFile(PPPData::data()->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())) {
+// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) {
// // QString s= i18n("Can not load the accounting "
-// // "ruleset \"%1\"!").arg(gpppdata.accountingFile());
+// // "ruleset \"%1\"!").arg(PPPData::data()->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);
+// // PPPData::data()->setTotalBytes(stats->totalbytes);
-// if(!gpppdata.AcctEnabled())
+// if(!PPPData::data()->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());
+ PPPData::data()->setStoredUsername(ID_Edit->text());
}
void KPPPWidget::passwordChanged(const QString &) {
// store the password if so requested
- if(gpppdata.storePassword())
- gpppdata.setStoredPassword(PW_Edit->text());
+ if(PPPData::data()->storePassword())
+ PPPData::data()->setStoredPassword(PW_Edit->text());
else
- gpppdata.setStoredPassword("");
+ PPPData::data()->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) {
+ if(PPPData::data()->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();
+ PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
+ PPPData::data()->save();
}
}
#endif
}
//#include "kpppwidget.moc"
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index a2f77c5..cd5d21c 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -1,795 +1,795 @@
/*
* kPPP: A pppd Front End for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* This file was added by Harri Porten <porten@tu-harburg.de>
*
*
* 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 <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 <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;
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";
modem = this;
}
Modem::~Modem() {
modem = 0;
}
speed_t Modem::modemspeed() {
// convert the string modem speed int the gpppdata object to a t_speed type
// to set the modem. The constants here should all be ifdef'd because
// other systems may not have them
- int i = gpppdata.speed().toInt()/100;
+ int i = PPPData::data()->speed().toInt()/100;
switch(i) {
case 24:
return B2400;
break;
case 96:
return B9600;
break;
case 192:
return B19200;
break;
case 384:
return B38400;
break;
#ifdef B57600
case 576:
return B57600;
break;
#endif
#ifdef B115200
case 1152:
return B115200;
break;
#endif
#ifdef B230400
case 2304:
return B230400;
break;
#endif
#ifdef B460800
case 4608:
return B460800;
break;
#endif
default:
return B38400;
break;
}
}
bool Modem::opentty() {
// int flags;
//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
close(modemfd);
-// device = "/dev/modem";//deviceByIndex(request.modem.deviceNum);
+ device = PPPData::data()->modemDevice();
if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
qDebug("error opening modem device !");
errmsg = i18n("Unable to open modem.");
return false;
}
//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
//}
#if 0
- if(gpppdata.UseCDLine()) {
+ if(PPPData::data()->UseCDLine()) {
if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
errmsg = i18n("Unable to detect state of CD line.");
::close(modemfd);
modemfd = -1;
return false;
}
if ((flags&TIOCM_CD) == 0) {
errmsg = i18n("The modem is not ready.");
::close(modemfd);
modemfd = -1;
return false;
}
}
#endif
tcdrain (modemfd);
tcflush (modemfd, TCIOFLUSH);
if(tcgetattr(modemfd, &tty) < 0){
// this helps in some cases
tcsendbreak(modemfd, 0);
sleep(1);
if(tcgetattr(modemfd, &tty) < 0){
errmsg = i18n("The modem is busy.");
::close(modemfd);
modemfd = -1;
return false;
}
}
memset(&initial_tty,'\0',sizeof(initial_tty));
initial_tty = tty;
tty.c_cc[VMIN] = 0; // nonblocking
tty.c_cc[VTIME] = 0;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
tty.c_cflag |= CS8 | CREAD;
tty.c_cflag |= CLOCAL; // ignore modem status lines
tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
tty.c_lflag &= ~ICANON; // non-canonical mode
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
- if(gpppdata.flowcontrol() != "None") {
- if(gpppdata.flowcontrol() == "CRTSCTS") {
+ if(PPPData::data()->flowcontrol() != "None") {
+ if(PPPData::data()->flowcontrol() == "CRTSCTS") {
tty.c_cflag |= CRTSCTS;
}
else {
tty.c_iflag |= IXON | IXOFF;
tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
}
}
else {
tty.c_cflag &= ~CRTSCTS;
tty.c_iflag &= ~(IXON | IXOFF);
}
cfsetospeed(&tty, modemspeed());
cfsetispeed(&tty, modemspeed());
tcdrain(modemfd);
if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
errmsg = i18n("The modem is busy.");
::close(modemfd);
modemfd=-1;
return false;
}
errmsg = i18n("Modem Ready.");
return true;
}
bool Modem::closetty() {
if(modemfd >=0 ) {
stop();
/* discard data not read or transmitted */
tcflush(modemfd, TCIOFLUSH);
if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
errmsg = i18n("Can't restore tty settings: tcsetattr()\n");
::close(modemfd);
modemfd = -1;
return false;
}
::close(modemfd);
modemfd = -1;
}
return true;
}
void Modem::readtty(int) {
char buffer[200];
unsigned char c;
int len;
// read data in chunks of up to 200 bytes
if((len = ::read(modemfd, buffer, 200)) > 0) {
// split buffer into single characters for further processing
for(int i = 0; i < len; i++) {
c = buffer[i] & 0x7F;
emit charWaiting(c);
}
}
}
void Modem::notify(const QObject *receiver, const char *member) {
connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member);
startNotifier();
}
void Modem::stop() {
disconnect(SIGNAL(charWaiting(unsigned char)));
stopNotifier();
}
void Modem::startNotifier() {
if(modemfd >= 0) {
if(sn == 0) {
sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
qDebug("QSocketNotifier started!");
} else {
qDebug("QSocketNotifier re-enabled!");
sn->setEnabled(true);
}
}
}
void Modem::stopNotifier() {
if(sn != 0) {
sn->setEnabled(false);
disconnect(sn);
delete sn;
sn = 0;
qDebug( "QSocketNotifier stopped!" );
}
}
void Modem::flush() {
char c;
while(read(modemfd, &c, 1) == 1);
}
bool Modem::writeChar(unsigned char c) {
int s;
do {
s = write(modemfd, &c, 1);
if (s < 0) {
qError( "write() in Modem::writeChar failed" );
return false;
}
} while(s == 0);
return true;
}
bool Modem::writeLine(const char *buf) {
int len = strlen(buf);
char *b = new char[len+2];
memcpy(b, buf, len);
// different modems seem to need different line terminations
- QString term = gpppdata.enter();
+ QString term = PPPData::data()->enter();
if(term == "LF")
b[len++]='\n';
else if(term == "CR")
b[len++]='\r';
else if(term == "CR/LF") {
b[len++]='\r';
b[len++]='\n';
}
int l = len;
while(l) {
int wr = write(modemfd, &b[len-l], l);
if(wr < 0) {
// TODO do something meaningful with the error code (or ignore it
qError( "write() in Modem::writeLine failed" );
delete[] b;
return false;
}
l -= wr;
}
delete[] b;
return true;
}
bool Modem::hangup() {
// this should really get the modem to hang up and go into command mode
// If anyone sees a fault in the following please let me know, since
// this is probably the most imporant snippet of code in the whole of
// kppp. If people complain about kppp being stuck, this piece of code
// is most likely the reason.
struct termios temptty;
if(modemfd >= 0) {
// is this Escape & HangupStr stuff really necessary ? (Harri)
if (data_mode) escape_to_command_mode();
// Then hangup command
- writeLine(gpppdata.modemHangupStr().local8Bit());
+ writeLine(PPPData::data()->modemHangupStr().local8Bit());
- usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
#ifndef DEBUG_WO_DIALING
if (sigsetjmp(jmp_buffer, 1) == 0) {
// set alarm in case tcsendbreak() hangs
signal(SIGALRM, alarm_handler);
alarm(2);
tcsendbreak(modemfd, 0);
alarm(0);
signal(SIGALRM, SIG_IGN);
} else {
// we reach this point if the alarm handler got called
closetty();
close(modemfd);
modemfd = -1;
errmsg = i18n("The modem does not respond.");
return false;
}
#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
tcgetattr(modemfd, &temptty);
cfsetospeed(&temptty, B0);
cfsetispeed(&temptty, B0);
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#else
int modemstat;
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat &= ~TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat |= TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
#endif
- usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 secs
+ usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs
cfsetospeed(&temptty, modemspeed());
cfsetispeed(&temptty, modemspeed());
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#endif
return true;
} else
return false;
}
void Modem::escape_to_command_mode() {
// Send Properly bracketed escape code to put the modem back into command state.
// A modem will accept AT commands only when it is in command state.
// When a modem sends the host the CONNECT string, that signals
// that the modem is now in the connect state (no long accepts AT commands.)
// Need to send properly timed escape sequence to put modem in command state.
// Escape codes and guard times are controlled by S2 and S12 values.
//
tcflush(modemfd, TCIOFLUSH);
// +3 because quiet time must be greater than guard time.
- usleep((gpppdata.modemEscapeGuardTime()+3)*20000);
- QCString tmp = gpppdata.modemEscapeStr().local8Bit();
+ usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
+ QCString tmp = PPPData::data()->modemEscapeStr().local8Bit();
write(modemfd, tmp.data(), tmp.length());
tcflush(modemfd, TCIOFLUSH);
- usleep((gpppdata.modemEscapeGuardTime()+3)*20000);
+ usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
data_mode = false;
}
const QString Modem::modemMessage() {
return errmsg;
}
QString Modem::parseModemSpeed(const QString &s) {
// this is a small (and bad) parser for modem speeds
int rx = -1;
int tx = -1;
int i;
QString result;
qDebug( "Modem reported result string: %s", s.latin1());
const int RXMAX = 7;
const int TXMAX = 2;
QRegExp rrx[RXMAX] = {
QRegExp("[0-9]+[:/ ]RX", false),
QRegExp("[0-9]+RX", false),
QRegExp("[/: -][0-9]+[/: ]", false),
QRegExp("[/: -][0-9]+$", false),
QRegExp("CARRIER [^0-9]*[0-9]+", false),
QRegExp("CONNECT [^0-9]*[0-9]+", false),
QRegExp("[0-9]+") // panic mode
};
QRegExp trx[TXMAX] = {
QRegExp("[0-9]+[:/ ]TX", false),
QRegExp("[0-9]+TX", false)
};
for(i = 0; i < RXMAX; i++) {
int len, idx, result;
if((idx = rrx[i].match(s,0,&len)) > -1) {
// if((idx = rrx[i].search(s)) > -1) {
// len = rrx[i].matchedLength();
//
// rrx[i] has been matched, idx contains the start of the match
// and len contains how long the match is. Extract the match.
//
QString sub = s.mid(idx, len);
//
// Now extract the digits only from the match, which will
// then be converted to an int.
//
if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) {
// if ((idx = rrx[RXMAX-1].search( sub )) > -1) {
// len = rrx[RXMAX-1].matchedLength();
sub = sub.mid(idx, len);
result = sub.toInt();
if(result > 0) {
rx = result;
break;
}
}
}
}
for(i = 0; i < TXMAX; i++) {
int len, idx, result;
if((idx = trx[i].match(s,0,&len)) > -1) {
// if((idx = trx[i].search(s)) > -1) {
// len = trx[i].matchedLength();
//
// trx[i] has been matched, idx contains the start of the match
// and len contains how long the match is. Extract the match.
//
QString sub = s.mid(idx, len);
//
// Now extract the digits only from the match, which will then
// be converted to an int.
//
if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) {
// if((idx = rrx[RXMAX-1].search(sub)) > -1) {
// len = rrx[RXMAX-1].matchedLength();
sub = sub.mid(idx, len);
result = sub.toInt();
if(result > 0) {
tx = result;
break;
}
}
}
}
if(rx == -1 && tx == -1)
result = i18n("Unknown speed");
else if(tx == -1)
result.setNum(rx);
else if(rx == -1) // should not happen
result.setNum(tx);
else
result.sprintf("%d/%d", rx, tx);
qDebug( "The parsed result is: %s", result.latin1());
return result;
}
// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
// a lock file can't be created ( permission problem )
int Modem::lockdevice() {
int fd;
char newlock[80]=""; // safe
- if(!gpppdata.modemLockFile()) {
+ if(!PPPData::data()->modemLockFile()) {
qDebug("The user doesn't want a lockfile.");
return 0;
}
if (modem_is_locked)
return 1;
QString lockfile = LOCK_DIR"/LCK..";
- lockfile += gpppdata.modemDevice().mid(5); // append everything after /dev/
+ lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/
if(access(QFile::encodeName(lockfile), F_OK) == 0) {
// if ((fd = Requester::rq->
if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
// Mario: it's not necessary to read more than lets say 32 bytes. If
// file has more than 32 bytes, skip the rest
char oldlock[33]; // safe
int sz = read(fd, &oldlock, 32);
close (fd);
if (sz <= 0)
return 1;
oldlock[sz] = '\0';
qDebug( "Device is locked by: %s", oldlock);
int oldpid;
int match = sscanf(oldlock, "%d", &oldpid);
// found a pid in lockfile ?
if (match < 1 || oldpid <= 0)
return 1;
// check if process exists
if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
return 1;
qDebug( "lockfile is stale" );
}
}
- fd = openLockfile(gpppdata.modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
+ fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
if(fd >= 0) {
sprintf(newlock,"%010d\n", getpid());
qDebug("Locking Device: %s", newlock);
write(fd, newlock, strlen(newlock));
close(fd);
modem_is_locked=true;
return 0;
}
return -1;
}
// UnLock modem device
void Modem::unlockdevice() {
if (modem_is_locked) {
qDebug( "UnLocking Modem Device" );
close(modemfd);
modemfd = -1;
unlink(lockfile);
lockfile[0] = '\0';
modem_is_locked=false;
}
}
int Modem::openLockfile( QString lockfile, int flags)
{
int fd;
int mode;
flags = O_RDONLY;
if(flags == O_WRONLY|O_TRUNC|O_CREAT)
mode = 0644;
else
mode = 0;
lockfile = LOCK_DIR;
lockfile += "/LCK..";
lockfile += device.right( device.length() - device.findRev("/") -1 );
qDebug("lockfile >%s<",lockfile.latin1());
// TODO:
// struct stat st;
// if(stat(lockfile.data(), &st) == -1) {
// if(errno == EBADF)
// return -1;
// } else {
// // make sure that this is a regular file
// if(!S_ISREG(st.st_mode))
// return -1;
// }
if ((fd = open(lockfile, flags, mode)) == -1) {
qDebug("error opening lockfile!");
lockfile = QString::null;
fd = open(DEVNULL, O_RDONLY);
} else
fchown(fd, 0, 0);
return fd;
}
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;
}
}
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);
}
// 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)
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
index 766ba0f..65032e8 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.cpp
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -1,321 +1,318 @@
/*
* 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());
+ preinitslider->setValue(PPPData::data()->modemPreInitDelay());
+ lpreinitslider->setNum(PPPData::data()->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());
+ initstr[i]->setText(PPPData::data()->modemInitStr(i));
+ initslider->setValue(PPPData::data()->modemInitDelay());
+ linitslider->setNum(PPPData::data()->modemInitDelay());
+ initresp->setText(PPPData::data()->modemInitResp());
- durationslider->setValue(gpppdata.modemToneDuration());
- ldurationslider->setNum(gpppdata.modemToneDuration());
+ durationslider->setValue(PPPData::data()->modemToneDuration());
+ ldurationslider->setNum(PPPData::data()->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());
+ nodetectdialtone->setText(PPPData::data()->modemNoDialToneDetectionStr());
+ dialstr->setText(PPPData::data()->modemDialStr());
+ connectresp->setText(PPPData::data()->modemConnectResp());
+ busyresp->setText(PPPData::data()->modemBusyResp());
+ nocarrierresp->setText(PPPData::data()->modemNoCarrierResp());
+ nodialtoneresp->setText(PPPData::data()->modemNoDialtoneResp());
- escapestr->setText(gpppdata.modemEscapeStr());
- escaperesp->setText(gpppdata.modemEscapeResp());
+ escapestr->setText(PPPData::data()->modemEscapeStr());
+ escaperesp->setText(PPPData::data()->modemEscapeResp());
- hangupstr->setText(gpppdata.modemHangupStr());
- hangupresp->setText(gpppdata.modemHangupResp());
+ hangupstr->setText(PPPData::data()->modemHangupStr());
+ hangupresp->setText(PPPData::data()->modemHangupResp());
- answerstr->setText(gpppdata.modemAnswerStr());
- ringresp->setText(gpppdata.modemRingResp());
- answerresp->setText(gpppdata.modemAnswerResp());
+ answerstr->setText(PPPData::data()->modemAnswerStr());
+ ringresp->setText(PPPData::data()->modemRingResp());
+ answerresp->setText(PPPData::data()->modemAnswerResp());
- slider->setValue(gpppdata.modemEscapeGuardTime());
- lslider->setNum(gpppdata.modemEscapeGuardTime());
+ slider->setValue(PPPData::data()->modemEscapeGuardTime());
+ lslider->setNum(PPPData::data()->modemEscapeGuardTime());
- volume_off->setText(gpppdata.volumeOff());
- volume_medium->setText(gpppdata.volumeMedium());
- volume_high->setText(gpppdata.volumeHigh());
+ volume_off->setText(PPPData::data()->volumeOff());
+ volume_medium->setText(PPPData::data()->volumeMedium());
+ volume_high->setText(PPPData::data()->volumeHigh());
}
void ModemCommands::slotOk() {
- gpppdata.setModemPreInitDelay(lpreinitslider->text().toInt());
+ PPPData::data()->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();
+ PPPData::data()->setModemInitStr(i, initstr[i]->text());
+ PPPData::data()->setModemInitResp(initresp->text());
+ PPPData::data()->setModemInitDelay(linitslider->text().toInt());
+
+ PPPData::data()->setModemToneDuration(ldurationslider->text().toInt());
+ PPPData::data()->setModemNoDialToneDetectionStr(nodetectdialtone->text());
+ PPPData::data()->setModemDialStr(dialstr->text());
+ PPPData::data()->setModemConnectResp(connectresp->text());
+ PPPData::data()->setModemBusyResp(busyresp->text());
+ PPPData::data()->setModemNoCarrierResp(nocarrierresp->text());
+ PPPData::data()->setModemNoDialtoneResp(nodialtoneresp->text());
+
+ PPPData::data()->setModemEscapeStr(escapestr->text());
+ PPPData::data()->setModemEscapeResp(escaperesp->text());
+ PPPData::data()->setModemEscapeGuardTime(lslider->text().toInt());
+ PPPData::data()->setModemHangupStr(hangupstr->text());
+ PPPData::data()->setModemHangupResp(hangupresp->text());
+
+ PPPData::data()->setModemAnswerStr(answerstr->text());
+ PPPData::data()->setModemRingResp(ringresp->text());
+ PPPData::data()->setModemAnswerResp(answerresp->text());
+
+ PPPData::data()->setVolumeHigh(volume_high->text());
+ PPPData::data()->setVolumeMedium(volume_medium->text());
+ PPPData::data()->setVolumeOff(volume_off->text());
+
+ PPPData::data()->save();
accept();
}
void ModemCommands::slotCancel() {
reject();
}
//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/newwidget.cpp b/noncore/settings/networksettings/ppp/newwidget.cpp
deleted file mode 100644
index d2182fb..0000000
--- a/noncore/settings/networksettings/ppp/newwidget.cpp
+++ b/dev/null
@@ -1,17 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-// 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
deleted file mode 100644
index 52f2ec7..0000000
--- a/noncore/settings/networksettings/ppp/newwidget.h
+++ b/dev/null
@@ -1,19 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-// 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 a456427..ebfc713 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,18 +1,18 @@
#TEMPLATE = app
#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-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
+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 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 iplined.cpp pwentry.cpp pppconfig.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
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
index 7b2b21b..c0f1fef 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,62 +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();
+ PPPData::data()->save();
QDialog::accept();
}
void PPPConfigWidget::reject()
{
- gpppdata.cancel();
+ PPPData::data()->cancel();
QDialog::reject();
}
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 04d0dd0..b7fca3f 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -1,166 +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());
+ QStringList arglist(PPPData::data()->pppdArgument());
// get defaults
- gpppdata.setpppdArgumentDefaults();
+ PPPData::data()->setpppdArgumentDefaults();
init();
// restore old list
- gpppdata.setpppdArgument(arglist);
+ PPPData::data()->setpppdArgument(arglist);
}
void PPPdArguments::closebutton() {
QStringList arglist;
for(uint i=0; i < arguments->count(); i++)
arglist.append(arguments->text(i));
- gpppdata.setpppdArgument(arglist);
+ PPPData::data()->setpppdArgument(arglist);
done(0);
}
void PPPdArguments::init() {
while(arguments->count())
arguments->removeItem(0);
- QStringList &arglist = gpppdata.pppdArgument();
+ QStringList &arglist = PPPData::data()->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/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index f2386fc..646facd 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,328 +1,332 @@
/*
* 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 "pppdata.h"
#include "runtests.h"
#include "devices.h"
//#include <klocale.h>
#define i18n QObject::tr
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qapplication.h>
// #include <klocale.h>
// #include <kconfig.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
-PPPData gpppdata;
+PPPData *PPPData::_data = 0;
+Config *PPPData::config = 0;
+PPPData* PPPData::data()
+{
+ if (!_data){
+ qDebug("PPPData::data() creates new Instance");
+ _data = new PPPData();
+ }
+ if (!_data->config){
+ qDebug("PPPData::data() opens conffile");
+ _data->open();
+ }
+ return _data;
+}
PPPData::PPPData()
- : config(0L),
+ : //config(0L),
highcount(-1), // start out with no entries
caccount(-1), // set the current account index also
suidprocessid(-1), // process ID of setuid child
pppdisrunning(false),
pppderror(0)
{
}
//
// open configuration file
//
bool PPPData::open() {
-
- config = new Config("NetworkSetup");
- /*
- config = kapp->config();
-
- if (config->getConfigState() == KConfig::NoAccess) {
- KMessageBox::error(0L,
- i18n("The application-specific config file could not "
- "be opened in either read-write or read-only mode.\n"
- "The superuser might have to change its ownership "
- "by issuing the following command in your home directory:\n"
- "chown {YourUsername} .kde/share/config/kppprc"),
- kapp->name());
- return false;
- }
-
- // don't expand shell variables
- config->setDollarExpansion(false);
- */
+ qDebug("opening configfile NetworkSetupPPP");
+ if (config) return true;
+ config = new Config("NetworkSetupPPP");
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
if (highcount > MAX_ACCOUNTS)
highcount = MAX_ACCOUNTS;
if(highcount >= 0 && defaultAccount().isEmpty()) {
setAccountbyIndex(0);
setDefaultAccount(accname());
} else if(!setAccount(defaultAccount()))
setDefaultAccount(accname());
// start out with internal debugging disabled
// the user is still free to specify `debug' on his own
setPPPDebug(false);
::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
return true;
}
//
// save configuration
//
void PPPData::save() {
if (config) {
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
-// config->sync();
+ delete config;
+ config = 0;
+ qDebug("worte confi NetworkSetupPPP");
+ }
+ if (_data){
+ delete _data;
+ _data = 0;
}
}
//
// cancel changes
//
void PPPData::cancel() {
// if (config) {
// config->rollback();
// config->reparseConfiguration();
// }
}
-// currently differentiates between READWRITE and NONE only
-int PPPData::access() const {
+// // currently differentiates between READWRITE and NONE only
+// int PPPData::access() const {
- return 0;//config->getConfigState();
-}
+// return 1;//config->getConfigState();
+// }
// functions to read/write date to configuration file
QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
+// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
if (config) {
config->setGroup(group);
return config->readEntry(key, defvalue);
} else
return defvalue;
}
int PPPData::readNumConfig(const QString &group, const QString &key,
int defvalue) {
if (config) {
config->setGroup(group);
return config->readNumEntry(key, defvalue);
} else
return defvalue;
}
bool PPPData::readListConfig(const QString &group, const QString &key,
QStringList &list, char sep) {
list.clear();
if (config) {
config->setGroup(group);
list = config->readListEntry(key, sep);
return true;
} else
return false;
}
void PPPData::writeConfig(const QString &group, const QString &key,
const QString &value) {
if (config) {
config->setGroup(group);
config->writeEntry(key, value);
}
}
void PPPData::writeConfig(const QString &group, const QString &key, int value) {
if (config) {
config->setGroup(group);
config->writeEntry(key, value);
}
}
void PPPData::writeListConfig(const QString &group, const QString &key,
QStringList &list, char sep) {
if (config) {
config->setGroup(group);
config->writeEntry(key, list, sep);
}
}
//
// functions to set/return general information
//
QString PPPData::password() const {
return passwd;
}
void PPPData::setPassword(const QString &pw) {
passwd = pw;
}
const QString PPPData::defaultAccount() {
return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
}
void PPPData::setDefaultAccount(const QString &n) {
writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n);
//now set the current account index to the default account
setAccount(defaultAccount());
}
bool PPPData::get_show_clock_on_caption() {
return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true);
}
void PPPData::set_show_clock_on_caption(bool set) {
writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set);
}
bool PPPData::get_xserver_exit_disconnect() {
return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true);
}
void PPPData::setPPPDebug(bool set) {
writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set);
}
bool PPPData::getPPPDebug() {
return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false);
}
void PPPData::set_xserver_exit_disconnect(bool set) {
writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set);
}
bool PPPData::quit_on_disconnect() {
return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false);
}
void PPPData::set_quit_on_disconnect(bool set) {
writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set);
}
bool PPPData::get_show_log_window() {
return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false);
}
void PPPData::set_show_log_window(bool set) {
writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set);
}
bool PPPData::automatic_redial() {
return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
}
void PPPData::set_automatic_redial(bool set) {
writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
}
bool PPPData::get_iconify_on_connect() {
return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
}
void PPPData::set_iconify_on_connect(bool set) {
writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
}
bool PPPData::get_dock_into_panel() {
return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
}
void PPPData::set_dock_into_panel(bool set) {
writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
}
QString PPPData::pppdVersion() {
return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
}
bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
// check if pppd version fulfills minimum requirement
return (pppdVer > ver
|| (pppdVer == ver && pppdMod > mod)
|| (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
}
int PPPData::pppdTimeout() {
return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
}
void PPPData::setpppdTimeout(int n) {
writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
}
const QString PPPData::modemDevice() {
return readConfig (MODEM_GRP, MODEMDEV_KEY, devices[DEV_DEFAULT]);
}
void PPPData::setModemDevice(const QString &n) {
writeConfig(MODEM_GRP, MODEMDEV_KEY, n);
}
@@ -529,701 +533,702 @@ const QString PPPData::modemNoCarrierResp() {
void PPPData::setModemNoCarrierResp(const QString &n) {
writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n);
}
const QString PPPData::modemNoDialtoneResp() {
return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE");
}
void PPPData::setModemNoDialtoneResp(const QString &n) {
writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n);
}
const QString PPPData::modemHangupStr() {
return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH");
}
void PPPData::setModemHangupStr(const QString &n) {
writeConfig(MODEM_GRP, HANGUPSTR_KEY, n);
}
const QString PPPData::modemHangupResp() {
return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK");
}
void PPPData::setModemHangupResp(const QString &n) {
writeConfig(MODEM_GRP, HANGUPRESP_KEY, n);
}
const QString PPPData::modemAnswerStr() {
return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA");
}
QString PPPData::volumeOff() {
return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0");
}
void PPPData::setVolumeOff(const QString &s) {
writeConfig(MODEM_GRP, VOLUME_OFF, s);
}
QString PPPData::volumeMedium() {
return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1");
}
void PPPData::setVolumeMedium(const QString &s) {
writeConfig(MODEM_GRP, VOLUME_MEDIUM, s);
}
QString PPPData::volumeHigh() {
QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3");
if(tmp == "M1L4")
tmp = "M1L3";
return tmp;
}
void PPPData::setVolumeHigh(const QString &s) {
writeConfig(MODEM_GRP, VOLUME_HIGH, s);
}
QString PPPData::volumeInitString() {
QString s;
switch(volume()) {
case 0:
s = volumeOff();
break;
case 1:
s = volumeMedium();
break;
case 2:
s = volumeHigh();
break;
default:
s = volumeMedium();
}
return s;
}
int PPPData::volume() {
return readNumConfig(MODEM_GRP, VOLUME_KEY, 1);
}
void PPPData::setVolume(int i) {
writeConfig(MODEM_GRP, VOLUME_KEY, i);
}
int PPPData::waitForDialTone() {
return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1);
}
void PPPData::setWaitForDialTone(int i) {
writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i);
}
void PPPData::setModemAnswerStr(const QString &n) {
writeConfig(MODEM_GRP, ANSWERSTR_KEY, n);
}
const QString PPPData::modemRingResp() {
return readConfig(MODEM_GRP, RINGRESP_KEY, "RING");
}
void PPPData::setModemRingResp(const QString &n) {
writeConfig(MODEM_GRP, RINGRESP_KEY, n);
}
const QString PPPData::modemAnswerResp() {
return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT");
}
void PPPData::setModemAnswerResp(const QString &n) {
writeConfig(MODEM_GRP, ANSWERRESP_KEY, n);
}
const QString PPPData::enter() {
return readConfig(MODEM_GRP, ENTER_KEY, "CR");
}
void PPPData::setEnter(const QString &n) {
writeConfig(MODEM_GRP, ENTER_KEY, n);
}
//
// functions to set/return account information
//
//returns number of accounts
int PPPData::count() const {
return highcount + 1;
}
bool PPPData::setAccount(const QString &aname) {
for(int i = 0; i <= highcount; i++) {
setAccountbyIndex(i);
if(accname() == aname) {
caccount = i;
return true;
}
}
return false;
}
bool PPPData::setAccountbyIndex(int i) {
if(i >= 0 && i <= highcount) {
caccount = i;
cgroup.sprintf("%s%i", ACCOUNT_GRP, i);
return true;
}
return false;
}
bool PPPData::isUniqueAccname(const QString &n) {
int current = caccount;
for(int i=0; i <= highcount; i++) {
setAccountbyIndex(i);
if(accname() == n && i != current) {
setAccountbyIndex(current);
return false;
}
}
setAccountbyIndex(current);
return true;
}
bool PPPData::deleteAccount() {
- if(caccount < 0)
+ //FIXME:
+// if(caccount < 0)
return false;
// QMap <QString, QString> map;
// QMap <QString, QString>::Iterator it;
- // set all entries of the current account to ""
-// tille: do not handle the accounts here... (?)
+// // set all entries of the current account to ""
// map = config->entryMap(cgroup);
// it = map.begin();
// while (it != map.end()) {
// config->writeEntry(it.key(), "");
// it++;
// }
// // shift the succeeding accounts
// for(int i = caccount+1; i <= highcount; i++) {
// setAccountbyIndex(i);
// map = config->entryMap(cgroup);
// it = map.begin();
// setAccountbyIndex(i-1);
// config->setGroup(cgroup);
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
// }
// }
// // make sure the top account is cleared
// setAccountbyIndex(highcount);
// map = config->entryMap(cgroup);
// it = map.begin();
// config->setGroup(cgroup);
// while (it.key() != QString::null) {
// config->writeEntry(it.key(), "");
// it++;
// }
- highcount--;
- if(caccount > highcount)
- caccount = highcount;
+// highcount--;
+// if(caccount > highcount)
+// caccount = highcount;
- setAccountbyIndex(caccount);
+// setAccountbyIndex(caccount);
- return true;
+// return true;
}
bool PPPData::deleteAccount(const QString &aname) {
if(!setAccount(aname))
return false;
deleteAccount();
return true;
}
int PPPData::newaccount() {
- if(!config || highcount >= MAX_ACCOUNTS)
- return -1;
+ qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
+ if(!config) open();
+ if (highcount >= MAX_ACCOUNTS) return -1;
highcount++;
setAccountbyIndex(highcount);
setpppdArgumentDefaults();
-
+ qDebug("PPPData::newaccount -> %i",caccount);
return caccount;
}
int PPPData::copyaccount(int i) {
- if(highcount >= MAX_ACCOUNTS)
+// if(highcount >= MAX_ACCOUNTS)
return -1;
- setAccountbyIndex(i);
+// setAccountbyIndex(i);
// QMap <QString, QString> map = config->entryMap(cgroup);
// QMap <QString, QString>::ConstIterator it = map.begin();
- QString newname = i18n("%1_copy").arg(accname());
+// QString newname = i18n("%1_copy").arg(accname());
- newaccount();
+// newaccount();
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
// }
- setAccname(newname);
+// setAccname(newname);
- return caccount;
+// return caccount;
}
const QString PPPData::accname() {
return readConfig(cgroup, NAME_KEY);
}
void PPPData::setAccname(const QString &n) {
if(!cgroup.isNull()) {
// are we manipulating the default account's name ? then change it, too.
bool def = accname() == defaultAccount();
writeConfig(cgroup, NAME_KEY, n);
if (def)
setDefaultAccount(n);
}
}
-#define SEPARATOR_CHAR ':'
+#define SEPARATOR_CHAR '&'
QStringList &PPPData::phonenumbers() {
readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR);
return phonelist;
}
const QString PPPData::phonenumber() {
return readConfig(cgroup, PHONENUMBER_KEY);
}
void PPPData::setPhonenumber(const QString &n) {
writeConfig(cgroup, PHONENUMBER_KEY, n);
}
const QString PPPData::dialPrefix() {
return readConfig(cgroup, DIAL_PREFIX_KEY, "");
}
void PPPData::setDialPrefix(const QString &s) {
writeConfig(cgroup, DIAL_PREFIX_KEY, s);
}
int PPPData::authMethod() {
return readNumConfig(cgroup, AUTH_KEY, 0);
}
void PPPData::setAuthMethod(int value) {
writeConfig(cgroup, AUTH_KEY, value);
}
const QString PPPData::storedUsername() {
return readConfig(cgroup, STORED_USERNAME_KEY, "");
}
void PPPData::setStoredUsername(const QString &b) {
writeConfig(cgroup, STORED_USERNAME_KEY, b);
}
const QString PPPData::storedPassword() {
return readConfig(cgroup, STORED_PASSWORD_KEY, "");
}
void PPPData::setStoredPassword(const QString &b) {
writeConfig(cgroup, STORED_PASSWORD_KEY, b);
}
bool PPPData::storePassword() {
return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1);
}
const QString PPPData::command_before_connect() {
return readConfig(cgroup, BEFORE_CONNECT_KEY);
}
void PPPData::setCommand_before_connect(const QString &n) {
writeConfig(cgroup, BEFORE_CONNECT_KEY, n);
}
void PPPData::setStorePassword(bool b) {
writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b);
}
const QString PPPData::command_on_connect() {
return readConfig(cgroup, COMMAND_KEY);
}
void PPPData::setCommand_on_connect(const QString &n) {
writeConfig(cgroup, COMMAND_KEY, n);
}
const QString PPPData::command_on_disconnect() {
return readConfig(cgroup, DISCONNECT_COMMAND_KEY);
}
void PPPData::setCommand_on_disconnect(const QString &n) {
writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n);
}
const QString PPPData::command_before_disconnect() {
return readConfig(cgroup, BEFORE_DISCONNECT_KEY);
}
void PPPData::setCommand_before_disconnect(const QString &n) {
writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n);
}
const QString PPPData::ipaddr() {
return readConfig(cgroup, IPADDR_KEY);
}
void PPPData::setIpaddr(const QString &n) {
writeConfig(cgroup, IPADDR_KEY, n);
}
const QString PPPData::subnetmask() {
return readConfig(cgroup, SUBNETMASK_KEY);
}
void PPPData::setSubnetmask(const QString &n) {
writeConfig(cgroup, SUBNETMASK_KEY, n);
}
bool PPPData::autoname() {
return (bool) readNumConfig(cgroup, AUTONAME_KEY, false);
}
void PPPData::setAutoname(bool set) {
writeConfig(cgroup, AUTONAME_KEY, (int) set);
}
bool PPPData::AcctEnabled() {
return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
}
void PPPData::setAcctEnabled(bool set) {
writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
}
int PPPData::VolAcctEnabled() {
return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
}
void PPPData::setVolAcctEnabled(int set) {
writeConfig(cgroup, VOLACCTENABLED_KEY, set);
}
const QString PPPData::gateway() {
return readConfig(cgroup, GATEWAY_KEY);
}
void PPPData::setGateway(const QString &n ) {
writeConfig(cgroup, GATEWAY_KEY, n);
}
bool PPPData::defaultroute() {
// default route is by default 'on'.
return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
}
void PPPData::setDefaultroute(bool set) {
writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
}
bool PPPData::autoDNS() {
bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
- return (set && gpppdata.pppdVersionMin(2, 3, 7));
+ return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
}
void PPPData::setAutoDNS(bool set) {
writeConfig(cgroup, AUTODNS_KEY, (int) set);
}
void PPPData::setExDNSDisabled(bool set) {
writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
}
bool PPPData::exDNSDisabled() {
return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0);
}
QStringList &PPPData::dns() {
static QStringList dnslist;
readListConfig(cgroup, DNS_KEY, dnslist);
while(dnslist.count() > MAX_DNS_ENTRIES)
dnslist.remove(dnslist.last());
return dnslist;
}
void PPPData::setDns(QStringList &list) {
writeListConfig(cgroup, DNS_KEY, list);
}
const QString PPPData::domain() {
return readConfig(cgroup, DOMAIN_KEY);
}
void PPPData::setDomain(const QString &n ) {
writeConfig(cgroup, DOMAIN_KEY, n);
}
QStringList &PPPData::scriptType() {
static QStringList typelist;
readListConfig(cgroup, SCRIPTCOM_KEY, typelist);
while(typelist.count() > MAX_SCRIPT_ENTRIES)
typelist.remove(typelist.last());
return typelist;
}
void PPPData::setScriptType(QStringList &list) {
writeListConfig(cgroup, SCRIPTCOM_KEY, list);
}
QStringList &PPPData::script() {
static QStringList scriptlist;
readListConfig(cgroup, SCRIPTARG_KEY, scriptlist);
while(scriptlist.count() > MAX_SCRIPT_ENTRIES)
scriptlist.remove(scriptlist.last());
return scriptlist;
}
void PPPData::setScript(QStringList &list) {
writeListConfig(cgroup, SCRIPTARG_KEY, list);
}
const QString PPPData::accountingFile() {
return readConfig(cgroup, ACCTFILE_KEY);
}
void PPPData::setAccountingFile(const QString &n) {
writeConfig(cgroup, ACCTFILE_KEY, n);
}
const QString PPPData::totalCosts() {
return readConfig(cgroup, TOTALCOSTS_KEY);
}
void PPPData::setTotalCosts(const QString &n) {
writeConfig(cgroup, TOTALCOSTS_KEY, n);
}
int PPPData::totalBytes() {
return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
}
void PPPData::setTotalBytes(int n) {
writeConfig(cgroup, TOTALBYTES_KEY, n);
}
QStringList &PPPData::pppdArgument() {
static QStringList arglist;
while(arglist.count() > MAX_PPPD_ARGUMENTS)
arglist.remove(arglist.last());
readListConfig(cgroup, PPPDARG_KEY, arglist);
return arglist;
}
void PPPData::setpppdArgument(QStringList &args) {
writeListConfig(cgroup, PPPDARG_KEY, args);
}
void PPPData::setpppdArgumentDefaults() {
QStringList arg;
setpppdArgument(arg);
}
-// graphing widget
-void PPPData::setGraphingOptions(bool enable,
- QColor bg,
- QColor text,
- QColor in,
- QColor out)
-{
- if(config) {
- config->setGroup(GRAPH_GRP);
- config->writeEntry(GENABLED, enable);
-// config->writeEntry(GCOLOR_BG, bg);
-// config->writeEntry(GCOLOR_TEXT, text);
-// config->writeEntry(GCOLOR_IN, in);
-// config->writeEntry(GCOLOR_OUT, out);
- }
-}
+// // graphing widget
+// void PPPData::setGraphingOptions(bool enable,
+// QColor bg,
+// QColor text,
+// QColor in,
+// QColor out)
+// {
+// if(config) {
+// config->setGroup(GRAPH_GRP);
+// config->writeEntry(GENABLED, enable);
+// // config->writeEntry(GCOLOR_BG, bg);
+// // config->writeEntry(GCOLOR_TEXT, text);
+// // config->writeEntry(GCOLOR_IN, in);
+// // config->writeEntry(GCOLOR_OUT, out);
+// }
+// }
-void PPPData::graphingOptions(bool &enable,
- QColor &bg,
- QColor &text,
- QColor &in,
- QColor &out)
-{
- QColor c;
+// void PPPData::graphingOptions(bool &enable,
+// QColor &bg,
+// QColor &text,
+// QColor &in,
+// QColor &out)
+// {
+// QColor c;
- if(config) {
- config->setGroup(GRAPH_GRP);
- enable = config->readBoolEntry(GENABLED, true);
- bg = Qt::white;
- //bg = config->readColorEntry(GCOLOR_BG, &c);
- text = Qt::black;
- //text = config->readColorEntry(GCOLOR_TEXT, &c);
- in = Qt::blue;
- //in = config->readColorEntry(GCOLOR_IN, &c);
- out = Qt::red;
- //out = config->readColorEntry(GCOLOR_OUT, &c);
- }
-}
+// if(config) {
+// config->setGroup(GRAPH_GRP);
+// enable = config->readBoolEntry(GENABLED, true);
+// bg = Qt::white;
+// //bg = config->readColorEntry(GCOLOR_BG, &c);
+// text = Qt::black;
+// //text = config->readColorEntry(GCOLOR_TEXT, &c);
+// in = Qt::blue;
+// //in = config->readColorEntry(GCOLOR_IN, &c);
+// out = Qt::red;
+// //out = config->readColorEntry(GCOLOR_OUT, &c);
+// }
+// }
-bool PPPData::graphingEnabled() {
- return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
-}
+// bool PPPData::graphingEnabled() {
+// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
+// }
//
//functions to change/set the child pppd process info
//
bool PPPData::pppdRunning() const {
return pppdisrunning;
}
void PPPData::setpppdRunning(bool set) {
pppdisrunning = set;
}
int PPPData::pppdError() const {
return pppderror;
}
void PPPData::setpppdError(int err) {
pppderror = err;
}
-//
-// window position
-//
-void PPPData::winPosConWin(int& p_x, int& p_y) {
- p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
- p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
-}
+// //
+// // window position
+// //
+// void PPPData::winPosConWin(int& p_x, int& p_y) {
+// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
+// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
+// }
-void PPPData::setWinPosConWin(int p_x, int p_y) {
- writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
- writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
-}
+// void PPPData::setWinPosConWin(int p_x, int p_y) {
+// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
+// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
+// }
-void PPPData::winPosStatWin(int& p_x, int& p_y) {
- p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
- p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
-}
+// void PPPData::winPosStatWin(int& p_x, int& p_y) {
+// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
+// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
+// }
-void PPPData::setWinPosStatWin(int p_x, int p_y) {
- writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
- writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
-}
+// void PPPData::setWinPosStatWin(int p_x, int p_y) {
+// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
+// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
+// }
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index e286b70..57ce2fd 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -1,465 +1,467 @@
/* -*- 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 _PPPDATA_H_
#define _PPPDATA_H_
#include <unistd.h>
#include <sys/types.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qcolor.h>
#include "kpppconfig.h"
class Config;
// string lengths
#define PATH_SIZE 120
#define MODEMSTR_SIZE 80
#define ACCNAME_SIZE 50
#define PHONENUMBER_SIZE 60
#define COMMAND_SIZE 255
#define IPADDR_SIZE 15
#define DOMAIN_SIZE 50
#define TIMEOUT_SIZE 60
//
// keys for config file
//
// groups
-#define GENERAL_GRP "General"
-#define MODEM_GRP "Modem"
-#define ACCOUNT_GRP "Account"
-#define GRAPH_GRP "Graph"
-#define WINPOS_GRP "WindowPosition"
+#define GENERAL_GRP "PPP_General"
+#define MODEM_GRP "PPP_Modem"
+#define ACCOUNT_GRP "PPP_Account"
+//#define GRAPH_GRP "Graph"
+//#define WINPOS_GRP "WindowPosition"
// general
#define DEFAULTACCOUNT_KEY "DefaultAccount"
#define PPPDVERSION_KEY "pppdVersion"
#define PPPDTIMEOUT_KEY "pppdTimeout"
#define SHOWCLOCK_KEY "ShowClock"
#define SHOWLOGWIN_KEY "ShowLogWindow"
#define AUTOREDIAL_KEY "AutomaticRedial"
#define DISCONNECT_KEY "DisconnectOnXServerExit"
#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
#define NUMACCOUNTS_KEY "NumberOfAccounts"
#define ID_KEY "ID"
// modem
#define MODEMDEV_KEY "Device"
#define LOCKFILE_KEY "UseLockFile"
#define FLOWCONTROL_KEY "FlowControl"
#define SPEED_KEY "Speed"
#define TIMEOUT_KEY "Timeout"
#define TONEDURATION_KEY "ToneDuration"
#define BUSYWAIT_KEY "BusyWait"
#define INITSTR_KEY "InitString"
#define INITRESP_KEY "InitResponse"
#define PREINITDELAY_KEY "PreInitDelay"
#define INITDELAY_KEY "InitDelay"
#define NODTDETECT_KEY "NoDialToneDetection"
#define DIALTONEWAIT_KEY "WaitForDialTone"
#define DIALSTR_KEY "DialString"
#define CONNECTRESP_KEY "ConnectResponse"
#define BUSYRESP_KEY "BusyResponse"
#define NOCARRIERRESP_KEY "NoCarrierResponse"
#define NODIALTONERESP_KEY "NoDialToneResp"
#define HANGUPSTR_KEY "HangupString"
#define HANGUPRESP_KEY "HangUpResponse"
#define ANSWERSTR_KEY "AnswerString"
#define RINGRESP_KEY "RingResponse"
#define ANSWERRESP_KEY "AnswerResponse"
#define ENTER_KEY "Enter"
#define ESCAPESTR_KEY "EscapeString"
#define ESCAPERESP_KEY "EscapeResponse"
#define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
#define USECDLINE_KEY "UseCDLine"
#define VOLUME_HIGH "VolumeHigh"
#define VOLUME_MEDIUM "VolumeMedium"
#define VOLUME_OFF "VolumeOff"
#define VOLUME_KEY "Volume"
// account
#define NAME_KEY "Name"
#define PHONENUMBER_KEY "Phonenumber"
#define DIAL_PREFIX_KEY "DialPrefix"
#define AUTH_KEY "Authentication"
#define STORED_PASSWORD_KEY "Password"
#define STORED_USERNAME_KEY "Username"
#define STORE_PASSWORD_KEY "StorePassword"
#define BEFORE_CONNECT_KEY "BeforeConnect"
#define COMMAND_KEY "Command"
#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
#define IPADDR_KEY "IPAddr"
#define SUBNETMASK_KEY "SubnetMask"
#define ACCTENABLED_KEY "AccountingEnabled"
#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
#define ACCTFILE_KEY "AccountingFile"
#define AUTONAME_KEY "AutoName"
#define GATEWAY_KEY "Gateway"
#define DEFAULTROUTE_KEY "DefaultRoute"
#define DOMAIN_KEY "Domain"
#define DNS_KEY "DNS"
#define AUTODNS_KEY "AutoDNS"
#define EXDNSDISABLED_KEY "ExDNSDisabled"
#define SCRIPTCOM_KEY "ScriptCommands"
#define SCRIPTARG_KEY "ScriptArguments"
#define PPPDARG_KEY "pppdArguments"
#define PPP_DEBUG_OPTION "PPPDebug"
#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
#define DOCKING_KEY "DockIntoPanel"
#define TOTALCOSTS_KEY "TotalCosts"
#define TOTALBYTES_KEY "TotalBytes"
// graph colors
#define GENABLED "Enabled"
#define GCOLOR_BG "Background"
#define GCOLOR_TEXT "Text"
#define GCOLOR_IN "InBytes"
#define GCOLOR_OUT "OutBytes"
// pppd errors
#define E_IF_TIMEOUT 1
#define E_PPPD_DIED 2
// window position
#define WINPOS_CONWIN_X "WindowPositionConWinX"
#define WINPOS_CONWIN_Y "WindowPositionConWinY"
#define WINPOS_STATWIN_X "WindowPositionStatWinX"
#define WINPOS_STATWIN_Y "WindowPositionStatWinY"
class PPPData {
public:
PPPData();
~PPPData() {};
+ static PPPData* data();
enum { NumInitStrings = 2 };
// general functions
bool open();
void save();
void cancel();
- int access() const; // read/write access
+// int access() const; // read/write access
// function to read/write date to configuration file
QString readConfig(const QString &, const QString &, const QString &);
int readNumConfig(const QString &, const QString &, int);
bool readListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
void writeConfig(const QString &, const QString &, const QString &);
void writeConfig(const QString &, const QString &, int);
void writeListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
// return the current account group
QString currentGroup() { return cgroup; }
// functions to set/get general kppp info
QString password() const;
void setPassword(const QString &);
const QString defaultAccount();
void setDefaultAccount(const QString &);
void set_xserver_exit_disconnect(bool set);
bool get_xserver_exit_disconnect();
void setPPPDebug(bool set);
bool getPPPDebug();
void set_quit_on_disconnect(bool);
bool quit_on_disconnect();
void set_show_clock_on_caption(bool set);
bool get_show_clock_on_caption();
void set_show_log_window(bool set);
bool get_show_log_window();
void set_automatic_redial(bool set);
bool automatic_redial();
void set_iconify_on_connect(bool set);
bool get_iconify_on_connect();
void set_dock_into_panel(bool set);
bool get_dock_into_panel();
const QString enter();
void setEnter(const QString &);
QString pppdVersion();
bool pppdVersionMin(int ver, int mod, int patch);
int pppdTimeout();
void setpppdTimeout(int);
int busyWait();
void setbusyWait(int);
bool modemLockFile();
void setModemLockFile(bool set);
int modemEscapeGuardTime();
void setModemEscapeGuardTime(int i);
void setModemEscapeStr(const QString &);
const QString modemEscapeStr();
void setModemEscapeResp(const QString &);
const QString modemEscapeResp();
const QString modemDevice();
void setModemDevice(const QString &);
const QString flowcontrol();
void setFlowcontrol(const QString &);
int modemTimeout();
void setModemTimeout(int);
int modemToneDuration();
void setModemToneDuration(int);
QString volumeInitString();
int volume();
void setVolume(int);
int waitForDialTone();
void setWaitForDialTone(int i);
// modem command strings/responses
const QString modemInitStr(int i);
void setModemInitStr(int i, const QString &);
const QString modemInitResp();
void setModemInitResp(const QString &);
int modemPreInitDelay();
void setModemPreInitDelay(int);
int modemInitDelay();
void setModemInitDelay(int);
QString modemNoDialToneDetectionStr();
void setModemNoDialToneDetectionStr(const QString &);
const QString modemDialStr();
void setModemDialStr(const QString &);
const QString modemConnectResp();
void setModemConnectResp(const QString &);
const QString modemBusyResp();
void setModemBusyResp(const QString &);
const QString modemNoCarrierResp();
void setModemNoCarrierResp(const QString &);
const QString modemNoDialtoneResp();
void setModemNoDialtoneResp(const QString &);
const QString modemHangupStr();
void setModemHangupStr(const QString &);
const QString modemHangupResp();
void setModemHangupResp(const QString &);
const QString modemAnswerStr();
void setModemAnswerStr(const QString &);
const QString modemRingResp();
void setModemRingResp(const QString &);
const QString modemAnswerResp();
void setModemAnswerResp(const QString &);
QString volumeOff();
void setVolumeOff(const QString &);
QString volumeMedium();
void setVolumeMedium(const QString &);
QString volumeHigh();
void setVolumeHigh(const QString &);
#if 0
void setUseCDLine(const int n);
int UseCDLine();
#endif
// functions to set/get account information
int count() const;
bool setAccount(const QString &);
bool setAccountbyIndex(int);
bool isUniqueAccname(const QString &);
bool deleteAccount();
bool deleteAccount(const QString &);
int newaccount();
int copyaccount(int i);
const QString accname();
void setAccname(const QString &);
QStringList &phonenumbers();
const QString phonenumber();
void setPhonenumber(const QString &);
const QString dialPrefix();
void setDialPrefix(const QString &);
int authMethod();
void setAuthMethod(int);
const QString storedUsername();
void setStoredUsername(const QString &);
const QString storedPassword();
void setStoredPassword(const QString &);
bool storePassword();
void setStorePassword(bool);
const QString speed();
void setSpeed(const QString &);
const QString command_before_connect();
void setCommand_before_connect(const QString &);
const QString command_on_connect();
void setCommand_on_connect(const QString &);
const QString command_on_disconnect();
void setCommand_on_disconnect(const QString &);
const QString command_before_disconnect();
void setCommand_before_disconnect(const QString &);
const QString ipaddr();
void setIpaddr(const QString &);
const QString subnetmask();
void setSubnetmask(const QString &);
bool AcctEnabled();
void setAcctEnabled(bool set);
int VolAcctEnabled();
void setVolAcctEnabled(int set);
bool autoDNS();
void setAutoDNS(bool set);
bool exDNSDisabled();
void setExDNSDisabled(bool set);
bool autoname();
void setAutoname(bool set);
const QString gateway();
void setGateway(const QString &);
bool defaultroute();
void setDefaultroute(bool set);
QStringList &dns();
void setDns(QStringList &);
const QString domain();
void setDomain(const QString &);
QStringList &scriptType();
void setScriptType(QStringList &);
QStringList &script();
void setScript(QStringList &);
QStringList &pppdArgument();
void setpppdArgumentDefaults();
void setpppdArgument(QStringList &);
//functions to change/set the child pppd process info
bool pppdRunning() const;
void setpppdRunning(bool set);
int pppdError() const;
void setpppdError(int err);
// functions to set/query the accounting info
const QString accountingFile();
void setAccountingFile(const QString &);
const QString totalCosts();
void setTotalCosts(const QString &);
int totalBytes();
void setTotalBytes(int);
- // graphing widget
- void setGraphingOptions(bool enabled,
- QColor bg,
- QColor text,
- QColor in,
- QColor out);
- void graphingOptions(bool &enabled,
- QColor &bg,
- QColor &text,
- QColor &in,
- QColor &out);
- bool graphingEnabled();
-
- // window positions
- void winPosConWin(int &, int &);
- void setWinPosConWin(int, int);
- void winPosStatWin(int &, int &);
- void setWinPosStatWin(int, int);
+// // graphing widget
+// void setGraphingOptions(bool enabled,
+// QColor bg,
+// QColor text,
+// QColor in,
+// QColor out);
+// void graphingOptions(bool &enabled,
+// QColor &bg,
+// QColor &text,
+// QColor &in,
+// QColor &out);
+// bool graphingEnabled();
+
+// // window positions
+// void winPosConWin(int &, int &);
+// void setWinPosConWin(int, int);
+// void winPosStatWin(int &, int &);
+// void setWinPosStatWin(int, int);
private:
+
+ static PPPData *_data;
+
QString passwd;
- Config* config; // configuration object
+ static Config* config; // configuration object
int highcount; // index of highest account
int caccount; // index of the current account
QString cgroup; // name of current config group
pid_t suidprocessid; // process ID of setuid child
bool pppdisrunning; // pppd process
// daemon
int pppderror; // error encounterd running pppd
int pppdVer, pppdMod, pppdPatch; // pppd version
QStringList phonelist;
};
-extern PPPData gpppdata;
-
#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index d6ca88a..da17e26 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,120 +1,121 @@
#include "pppconfig.h"
#include "pppmodule.h"
-//#include "pppimp.h"
+#include "pppdata.h"
#include "kpppwidget.h"
#include "interfaceinformationimp.h"
//#include "devices.h"
/**
* Constructor, find all of the possible interfaces
*/
PPPModule::PPPModule() : Module() {
}
/**
* Delete any interfaces that we own.
*/
PPPModule::~PPPModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
void PPPModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString PPPModule::getPixmapName(Interface* ){
return "ppp";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool PPPModule::isOwner(Interface *i){
if(!i->getInterfaceName().upper().contains("PPP"))
return false;
i->setHardwareName("PPP");
list.append(i);
return true;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
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()
*/
QList<Interface> PPPModule::getInterfaces(){
// List all of the files in the peer directory
return list;
}
/**
* 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){
qDebug("try to add iface %s",newInterface.latin1());
PPPConfigWidget imp(0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
qDebug("ACCEPTED");
return new Interface( 0, newInterface );
+ PPPData::data()->save();
}
return NULL;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool PPPModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
{
qDebug("here");
newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device"));
}