summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/devices.cpp25
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp233
2 files changed, 170 insertions, 88 deletions
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp
index e94904b..9da090d 100644
--- a/noncore/settings/networksettings/ppp/devices.cpp
+++ b/noncore/settings/networksettings/ppp/devices.cpp
@@ -3,67 +3,73 @@
*
* $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 "interfaceppp.h"
+#include "devices.h"
+#include "authwidget.h"
+#include "pppdata.h"
+#include "edit.h"
+#include "general.h"
+
+/* OPIE */
+#include <qpe/qpeapplication.h>
+
+/* QT */
#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 <qvgroupbox.h>
-#include "interfaceppp.h"
-#include "devices.h"
-#include "authwidget.h"
-#include "pppdata.h"
-#include "edit.h"
-#include "general.h"
+/* STD */
+#include <stdlib.h>
+
void parseargs(char* buf, char** args);
DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f )
: ChooserWidget(ip->data(), parent, name, f)
{
_ifaceppp = ip;
QWhatsThis::add(edit_b, tr("Allows you to modify the selected device"));
QWhatsThis::add(new_b, tr("Create a new device") );
QWhatsThis::add(copy_b,
tr("Makes a copy of the selected device. All\n"
"settings of the selected device are copied\n"
"to a new device, that you can modify to fit your\n"
"needs"));
QWhatsThis::add(delete_b,
tr("<p>Deletes the selected device\n\n"
"<font color=\"red\"><b>Use with care!</b></font>"));
copy_b->setEnabled( false ); //FIXME
// delete_b->setEnabled( false ); //FIXME
QStringList tmp = _pppdata->getDevicesNamesList();
qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1());
@@ -170,43 +176,42 @@ int DevicesWidget::doTab(){
QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
layout->addWidget( tabWindow );
bool isnew;
if(_pppdata->devname().isEmpty()) {
dlg->setCaption(tr("New Device"));
isnew = true;
} else {
QString tit = tr("Edit Device: ");
tit += _pppdata->devname();
dlg->setCaption(tit);
isnew = false;
}
modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" );
tabWindow->addTab( modem1, tr("&Device") );
modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" );
tabWindow->addTab( modem2, tr("&Modem") );
int result = 0;
bool ok = false;
while (!ok){
- dlg->showMaximized();
- result = dlg->exec();
+ result = QPEApplication::execDialog( dlg );
ok = true;
if(result == QDialog::Accepted) {
if (!modem1->save()){
QMessageBox::critical(this, "error", tr( "You must enter a unique device name"));
ok = false;
}else{
modem2->save();
}
}
}
delete dlg;
return result;
}
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index ceac90c..7d21605 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -2,65 +2,72 @@
* 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 "edit.h"
+#include "pppdata.h"
+#include "iplined.h"
+#include "auth.h"
+
+/* OPIE */
+#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
+
+/* QT */
#include <qlayout.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <qregexp.h>
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
-#include <qpe/resource.h>
-#include "edit.h"
-#include "pppdata.h"
-#include "iplined.h"
-#include "auth.h"
+/* STD */
+
+#include <string.h>
+#include <termios.h>
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 );
connect_label = new QLabel(tr("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 = tr("Type in a unique name for this connection");
QWhatsThis::add(connect_label,tmp);
QWhatsThis::add(connectname_l,tmp);
number_label = new QLabel(tr("Phone number:"), this);
number_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(number_label, 1, 0);
@@ -91,153 +98,172 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
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 = tr("<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);
pppdargs = new QPushButton(tr("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) {
+ if(!isnewaccount)
+ {
connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
QString n = _pppdata->phonenumber();
QString tmp = "";
uint idx = 0;
- while(idx != n.length()) {
- if(n[idx] == ':') {
+ while(idx != n.length())
+ {
+ if(n[idx] == ':')
+ {
if(tmp.length() > 0)
numbers->insertItem(tmp);
tmp = "";
- } else
+ }
+ else
tmp += n[idx];
idx++;
}
if(tmp.length() > 0)
numbers->insertItem(tmp);
}
numbersChanged();
tl->activate();
}
-bool DialWidget::save() {
+bool DialWidget::save()
+{
//first check to make sure that the account name is unique!
if(connectname_l->text().isEmpty() ||
- !_pppdata->isUniqueAccname(connectname_l->text())) {
+ !_pppdata->isUniqueAccname(connectname_l->text()))
+ {
return false;
- } else {
+ }
+ else
+ {
_pppdata->setAccname(connectname_l->text());
QString number = "";
- for(uint i = 0; i < numbers->count(); i++) {
+ for(uint i = 0; i < numbers->count(); i++)
+ {
if(i != 0)
number += ":";
number += numbers->text(i);
}
_pppdata->setPhonenumber(number);
return true;
}
}
-void DialWidget::numbersChanged() {
+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) {
+void DialWidget::selectionChanged(int)
+{
numbersChanged();
}
-void DialWidget::addNumber() {
+void DialWidget::addNumber()
+{
PhoneNumberDialog dlg(this);
- if(dlg.exec()) {
+ if(dlg.exec())
+ {
numbers->insertItem(dlg.phoneNumber());
numbersChanged();
}
}
-void DialWidget::delNumber() {
- if(numbers->currentItem() != -1) {
+void DialWidget::delNumber()
+{
+ if(numbers->currentItem() != -1)
+ {
numbers->removeItem(numbers->currentItem());
numbersChanged();
}
}
-void DialWidget::upNumber() {
+void DialWidget::upNumber()
+{
int idx = numbers->currentItem();
- if(idx != -1) {
+ if(idx != -1)
+ {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx-1);
numbers->setCurrentItem(idx-1);
numbersChanged();
}
}
-void DialWidget::downNumber() {
+void DialWidget::downNumber()
+{
int idx = numbers->currentItem();
- if(idx != -1) {
+ if(idx != -1)
+ {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx+1);
numbers->setCurrentItem(idx+1);
numbersChanged();
}
}
-void DialWidget::pppdargsbutton() {
+void DialWidget::pppdargsbutton()
+{
PPPdArguments pa(_pppdata, this);
- pa.showMaximized();
- pa.exec();
+ QPEApplication::execDialog( &pa );
}
/////////////////////////////////////////////////////////////////////////////
// ExecWidget
/////////////////////////////////////////////////////////////////////////////
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( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this);
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(tr("Before connect:"), this);
before_connect_l->setAlignment(AlignVCenter);
@@ -284,58 +310,60 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch
QWhatsThis::add(predisconnect,tmp);
discommand_label = new QLabel(tr("Upon disconnect:"),
this);
discommand_label->setAlignment(AlignVCenter);
l1->addWidget(discommand_label, 3, 0);
discommand = new QLineEdit(this);
// discommand->setMaxLength(COMMAND_SIZE);
l1->addWidget(discommand, 3, 1);
tmp = tr("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) {
+ if(!isnewaccount)
+ {
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() {
+bool ExecWidget::save()
+{
_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( 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(tr("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
@@ -393,108 +421,121 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
tr("<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(!isnewaccount)
+ {
if(_pppdata->ipaddr() == "0.0.0.0" &&
- _pppdata->subnetmask() == "0.0.0.0") {
+ _pppdata->subnetmask() == "0.0.0.0")
+ {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
autoname->setChecked(_pppdata->autoname());
}
- else {
+ else
+ {
ipaddress_l->setText(_pppdata->ipaddr());
subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
- else {
+ else
+ {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
-void IPWidget::autoname_t(bool on) {
+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) {
+ if(on && !was_warned)
+ {
QMessageBox::information(this,
tr("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\"."),
tr("Warning"));
was_warned = true;
}
}
-void IPWidget::save() {
- if(dynamicadd_rb->isChecked()) {
+void IPWidget::save()
+{
+ if(dynamicadd_rb->isChecked())
+ {
_pppdata->setIpaddr("0.0.0.0");
_pppdata->setSubnetmask("0.0.0.0");
- } else {
+ }
+ else
+ {
_pppdata->setIpaddr(ipaddress_l->text());
_pppdata->setSubnetmask(subnetmask_l->text());
}
_pppdata->setAutoname(autoname->isChecked());
}
-void IPWidget::hitIPSelect( int i ) {
- if(i == 0) {
+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 {
+ else
+ {
ipaddress_label->setEnabled(true);
sub_label->setEnabled(true);
ipaddress_l->setEnabled(true);
subnetmask_l->setEnabled(true);
}
}
DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
dnsdomain_label = new QLabel(tr("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
dnsdomain = new QLineEdit(this);
tl->addWidget(dnsdomain, 0, 1);
QString tmp = tr("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"
@@ -576,109 +617,117 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha
tmp = tr("<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(tr("Disable DNS servers during connection"), this);
// exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
QWhatsThis::add(exdnsdisabled_toggle,
tr("<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) {
+ if(!isnewaccount)
+ {
dnsservers->insertStringList(_pppdata->dns());
dnsdomain->setText(_pppdata->domain());
}
int mode = _pppdata->autoDNS() ? 0 : 1;
bg->setButton(mode);
DNS_Mode_Selected(mode);
tl->activate();
}
-void DNSWidget::DNS_Edit_Changed(const QString &text) {
+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) {
+void DNSWidget::DNS_Entry_Selected(int)
+{
remove->setEnabled(true);
}
-void DNSWidget::DNS_Mode_Selected(int mode) {
+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() {
+void DNSWidget::save()
+{
_pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
_pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
_pppdata->setDomain(s.mid(1));
else
_pppdata->setDomain(dnsdomain->text());
_pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
}
-void DNSWidget::adddns() {
- if(dnsservers->count() < MAX_DNS_ENTRIES) {
+void DNSWidget::adddns()
+{
+ if(dnsservers->count() < MAX_DNS_ENTRIES)
+ {
dnsservers->insertItem(dnsipaddr->text());
dnsipaddr->setText("");
}
}
-void DNSWidget::removedns() {
+void DNSWidget::removedns()
+{
int i;
i = dnsservers->currentItem();
if(i != -1)
dnsservers->removeItem(i);
remove->setEnabled(dnsservers->count()>0);
}
//
// GatewayWidget
//
GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );
topLayout->setMargin( 0 );
box = new QVGroupBox(tr("Configuration"), this);
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
@@ -700,79 +749,87 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c
staticgateway->setText(tr("Static gateway"));
rb->insert(staticgateway, 1);
QWhatsThis::add(staticgateway,
tr("<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(tr("Gateway IP address:"), gateBox);
gatewayaddr = new IPLineEdit(gateBox);
defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
this);
QWhatsThis::add(defaultroute,
tr("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->gateway() == "0.0.0.0") {
+ if(!isnewaccount)
+ {
+ if(_pppdata->gateway() == "0.0.0.0")
+ {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
}
- else {
+ else
+ {
gatewayaddr->setText(_pppdata->gateway());
staticgateway->setChecked(true);
}
defaultroute->setChecked(_pppdata->defaultroute());
}
- else {
+ else
+ {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
defaultroute->setChecked(true);
}
}
-void GatewayWidget::save() {
+void GatewayWidget::save()
+{
_pppdata->setGateway(gatewayaddr->text());
_pppdata->setDefaultroute(defaultroute->isChecked());
}
-void GatewayWidget::hitGatewaySelect( int i ) {
- if(i == 0) {
+void GatewayWidget::hitGatewaySelect( int i )
+{
+ if(i == 0)
+ {
gatewayaddr->setText("0.0.0.0");
gatewayaddr->setEnabled(false);
gate_label->setEnabled(false);
}
- else {
+ else
+ {
gatewayaddr->setEnabled(true);
gatewayaddr->setText("");
gate_label->setEnabled(true);
}
}
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( tr("Add"), this );
hl->addWidget( add );
connect(add, SIGNAL(clicked()), SLOT(addButton()));
insert = new QPushButton( tr("Insert"), this );
@@ -782,136 +839,150 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con
hl->addWidget( remove );
connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
QHBoxLayout *l12 = new QHBoxLayout(0);
tl->addLayout(l12);
stl = new QListBox(this);
// stl->setVScrollBarMode( QScrollView::AlwaysOff );
connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
// stl->setMinimumSize(QSize(70, 140));
sl = new QListBox(this);
// sl->setVScrollBarMode( QScrollView::AlwaysOff );
connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
// 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) {
+ if(!isnewaccount)
+ {
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);
}
}
insert->setEnabled(false);
remove->setEnabled(false);
adjustScrollBar();
tl->activate();
}
-bool ScriptWidget::check() {
+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") {
+ if(sl->count() > 0)
+ {
+ for( uint i=0; i <= sl->count()-1; i++)
+ {
+ if(stl->text(i) == "LoopStart")
+ {
lstart++;
}
- if (stl->text(i) == "LoopEnd") {
+ if (stl->text(i) == "LoopEnd")
+ {
lend++;
}
if ( lend > lstart ) errcnt++;
}
return ( (errcnt == 0 ) && (lstart == lend) );
}
return true;
}
-void ScriptWidget::save() {
+void ScriptWidget::save()
+{
QStringList typelist, arglist;
- for(uint i=0; i < sl->count(); i++) {
+ for(uint i=0; i < sl->count(); i++)
+ {
typelist.append(stl->text(i));
arglist.append(sl->text(i));
}
_pppdata->setScriptType(typelist);
_pppdata->setScript(arglist);
}
-void ScriptWidget::adjustScrollBar() {
+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) {
+void ScriptWidget::scrolling(int i)
+{
sl->setTopItem(i);
stl->setTopItem(i);
}
-void ScriptWidget::slhighlighted(int i) {
+void ScriptWidget::slhighlighted(int i)
+{
insert->setEnabled(true);
remove->setEnabled(true);
stl->setCurrentItem(i);
}
-void ScriptWidget::stlhighlighted(int i) {
+void ScriptWidget::stlhighlighted(int i)
+{
insert->setEnabled(true);
remove->setEnabled(true);
sl->setCurrentItem(i);
}
-void ScriptWidget::addButton() {
+void ScriptWidget::addButton()
+{
//don't allow more than the maximum script entries
if(sl->count() == MAX_SCRIPT_ENTRIES-1)
return;
- switch(se->type()) {
+ 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;
@@ -959,55 +1030,57 @@ void ScriptWidget::addButton() {
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() {
+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()) {
+ 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;
@@ -1049,86 +1122,90 @@ void ScriptWidget::insertButton() {
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) {
+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,"PhoneNumberDialog",true)
{
setCaption( tr("Add Phone Number") );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 3 );
layout->setMargin( 3 );
// QHBox *hbox = new QHBox(this);
// setMainWidget(hbox);
// hbox->setSpacing( 2 );//KDialog::spacingHint());
QLabel *label = new QLabel(this, tr("Enter a phone number:"));
layout->addWidget( label );
le = new QLineEdit(this, "lineEdit");
layout->addWidget( le );
connect(le, SIGNAL(textChanged(const QString &)),
this, SLOT(textChanged(const QString &)));
le->setFocus();
textChanged("");
}
-QString PhoneNumberDialog::phoneNumber() {
+QString PhoneNumberDialog::phoneNumber()
+{
QString s = le->text();
return s;
}
-void PhoneNumberDialog::textChanged(const QString &s) {
+void PhoneNumberDialog::textChanged(const QString &s)
+{
// enableButtonOK(s.length() > 0);
}
//#include "edit.moc"