summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/edit.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp123
1 files changed, 62 insertions, 61 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index eee643d..8ae714e 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -36,26 +36,27 @@
#define i18n QObject::tr
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
//#include <kwin.h>
#include "edit.h"
#include "pppdata.h"
//#include "newwidget.h"
#include "iplined.h"
#include "auth.h"
-DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
+ , const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
const int GRIDROWS = 6;
QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
connect_label = new QLabel(i18n("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
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");
@@ -145,93 +146,93 @@ DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
"\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..."), 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(PPPData::data()->accname());
+ connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
- QString n = PPPData::data()->phonenumber();
+ QString n = _pppdata->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(PPPData::data()->authMethod());
- store_password->setChecked(PPPData::data()->storePassword());
+ auth->setCurrentItem(_pppdata->authMethod());
+ store_password->setChecked(_pppdata->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() ||
- !PPPData::data()->isUniqueAccname(connectname_l->text())) {
+ !_pppdata->isUniqueAccname(connectname_l->text())) {
return false;
} else {
- PPPData::data()->setAccname(connectname_l->text());
+ _pppdata->setAccname(connectname_l->text());
QString number = "";
for(uint i = 0; i < numbers->count(); i++) {
if(i != 0)
number += ":";
number += numbers->text(i);
}
- PPPData::data()->setPhonenumber(number);
- PPPData::data()->setAuthMethod(auth->currentItem());
- PPPData::data()->setStorePassword(store_password->isChecked());
+ _pppdata->setPhonenumber(number);
+ _pppdata->setAuthMethod(auth->currentItem());
+ _pppdata->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);
+ PhoneNumberDialog dlg(this);
if(dlg.exec()) {
numbers->insertItem(dlg.phoneNumber());
numbersChanged();
}
}
void DialWidget::delNumber() {
if(numbers->currentItem() != -1) {
numbers->removeItem(numbers->currentItem());
numbersChanged();
}
@@ -254,35 +255,35 @@ 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);
+ PPPdArguments pa(_pppdata, this);
pa.exec();
}
/////////////////////////////////////////////////////////////////////////////
// ExecWidget
/////////////////////////////////////////////////////////////////////////////
-ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) :
- QWidget(parent, name)
+ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
+ QWidget(parent, name), _pppdata(pd)
{
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."), this);
// l->setMinimumHeight(l->sizeHint().height());
tl->addWidget(l);
@@ -351,49 +352,49 @@ i18n("Here you can select commands to run at certain stages of the\n"
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(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());
+ before_connect->setText(_pppdata->command_before_connect());
+ command->setText(_pppdata->command_on_connect());
+ discommand->setText(_pppdata->command_on_disconnect());
+ predisconnect->setText(_pppdata->command_before_disconnect());
}
}
bool ExecWidget::save() {
- 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());
+ _pppdata->setCommand_before_connect(before_connect->text());
+ _pppdata->setCommand_on_connect(command->text());
+ _pppdata->setCommand_before_disconnect(predisconnect->text());
+ _pppdata->setCommand_on_disconnect(discommand->text());
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// IPWidget
//
/////////////////////////////////////////////////////////////////////////////
-IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 3 );//KDialog::spacingHint());
box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)),
SLOT(hitIPSelect(int)));
@@ -440,53 +441,53 @@ IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
"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"), this);
- autoname->setChecked(PPPData::data()->autoname());
+ autoname->setChecked(_pppdata->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(PPPData::data()->ipaddr() == "0.0.0.0" &&
- PPPData::data()->subnetmask() == "0.0.0.0") {
+ if(_pppdata->ipaddr() == "0.0.0.0" &&
+ _pppdata->subnetmask() == "0.0.0.0") {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
- autoname->setChecked(PPPData::data()->autoname());
+ autoname->setChecked(_pppdata->autoname());
}
else {
- ipaddress_l->setText(PPPData::data()->ipaddr());
- subnetmask_l->setText(PPPData::data()->subnetmask());
+ ipaddress_l->setText(_pppdata->ipaddr());
+ subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
else {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
void IPWidget::autoname_t(bool on) {
@@ -501,53 +502,53 @@ void IPWidget::autoname_t(bool on) {
"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()) {
- PPPData::data()->setIpaddr("0.0.0.0");
- PPPData::data()->setSubnetmask("0.0.0.0");
+ _pppdata->setIpaddr("0.0.0.0");
+ _pppdata->setSubnetmask("0.0.0.0");
} else {
- PPPData::data()->setIpaddr(ipaddress_l->text());
- PPPData::data()->setSubnetmask(subnetmask_l->text());
+ _pppdata->setIpaddr(ipaddress_l->text());
+ _pppdata->setSubnetmask(subnetmask_l->text());
}
- PPPData::data()->setAutoname(autoname->isChecked());
+ _pppdata->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)
+DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
// box = new QGroupBox(this);
QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
dnsdomain_label = new QLabel(i18n("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
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"
@@ -563,25 +564,25 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
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"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
// no automatic DNS detection for pppd < 2.3.7
- if(!PPPData::data()->pppdVersionMin(2, 3, 7))
+ if(!_pppdata->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
mandns = new QRadioButton(i18n("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
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(this);
@@ -636,45 +637,45 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
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"),
this);
- exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled());
+ exdnsdisabled_toggle->setChecked(_pppdata->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(PPPData::data()->dns());
- dnsdomain->setText(PPPData::data()->domain());
+ dnsservers->insertStringList(_pppdata->dns());
+ dnsdomain->setText(_pppdata->domain());
}
- int mode = PPPData::data()->autoDNS() ? 0 : 1;
+ int mode = _pppdata->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) {
@@ -686,63 +687,63 @@ void DNSWidget::DNS_Mode_Selected(int mode) {
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() {
- PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0);
+ _pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
- PPPData::data()->setDns(serverlist);
+ _pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
- PPPData::data()->setDomain(s.mid(1));
+ _pppdata->setDomain(s.mid(1));
else
- PPPData::data()->setDomain(dnsdomain->text());
+ _pppdata->setDomain(dnsdomain->text());
- PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
+ _pppdata->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)
+GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );//KDialog::spacingHint());
box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 2 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
defaultgateway = new QRadioButton(box);
@@ -776,64 +777,64 @@ GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *na
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(PPPData::data()->gateway() == "0.0.0.0") {
+ if(_pppdata->gateway() == "0.0.0.0") {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
}
else {
- gatewayaddr->setText(PPPData::data()->gateway());
+ gatewayaddr->setText(_pppdata->gateway());
staticgateway->setChecked(true);
}
- defaultroute->setChecked(PPPData::data()->defaultroute());
+ defaultroute->setChecked(_pppdata->defaultroute());
}
else {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
defaultroute->setChecked(true);
}
}
void GatewayWidget::save() {
- PPPData::data()->setGateway(gatewayaddr->text());
- PPPData::data()->setDefaultroute(defaultroute->isChecked());
+ _pppdata->setGateway(gatewayaddr->text());
+ _pppdata->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)
+ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name),_pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );
se = new ScriptEdit(this);
connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
tl->addWidget(se);
// insert equal-sized buttons
QHBoxLayout *hl = new QHBoxLayout( this );
tl->addLayout( hl );
add = new QPushButton( i18n("Add"), this );
hl->addWidget( add );
@@ -858,26 +859,26 @@ ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name
// sl->setMinimumSize(QSize(150, 140));
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 = PPPData::data()->scriptType();
- QStringList &arglist = PPPData::data()->script();
+ QStringList &comlist = _pppdata->scriptType();
+ QStringList &arglist = _pppdata->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);
}
}
@@ -905,26 +906,26 @@ bool ScriptWidget::check() {
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));
}
- PPPData::data()->setScriptType(typelist);
- PPPData::data()->setScript(arglist);
+ _pppdata->setScriptType(typelist);
+ _pppdata->setScript(arglist);
}
void ScriptWidget::adjustScrollBar() {
if((int)sl->count() <= sl->numItemsVisible())
slb->setRange(0, 0);
else
slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
}