Diffstat (limited to 'noncore/settings/networksettings/ppp/edit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 233 |
1 files changed, 155 insertions, 78 deletions
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 @@ -24,6 +24,14 @@ */ -#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> @@ -35,10 +43,9 @@ #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 @@ -113,5 +120,6 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount // Set defaults if editing an existing connection - if(!isnewaccount) { + if(!isnewaccount) + { connectname_l->setText(_pppdata->accname()); @@ -120,10 +128,13 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 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++; @@ -138,14 +149,19 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount } -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 += ":"; @@ -159,5 +175,6 @@ bool DialWidget::save() { -void DialWidget::numbersChanged() { +void DialWidget::numbersChanged() +{ int sel = numbers->currentItem(); @@ -168,12 +185,15 @@ void DialWidget::numbersChanged() { -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(); @@ -182,6 +202,8 @@ void DialWidget::addNumber() { -void DialWidget::delNumber() { - if(numbers->currentItem() != -1) { +void DialWidget::delNumber() +{ + if(numbers->currentItem() != -1) + { numbers->removeItem(numbers->currentItem()); numbersChanged(); @@ -190,7 +212,9 @@ void DialWidget::delNumber() { -void DialWidget::upNumber() { +void DialWidget::upNumber() +{ int idx = numbers->currentItem(); - if(idx != -1) { + if(idx != -1) + { QString item = numbers->text(idx); numbers->removeItem(idx); @@ -202,7 +226,9 @@ void DialWidget::upNumber() { -void DialWidget::downNumber() { +void DialWidget::downNumber() +{ int idx = numbers->currentItem(); - if(idx != -1) { + if(idx != -1) + { QString item = numbers->text(idx); numbers->removeItem(idx); @@ -214,8 +240,8 @@ void DialWidget::downNumber() { -void DialWidget::pppdargsbutton() { +void DialWidget::pppdargsbutton() +{ PPPdArguments pa(_pppdata, this); - pa.showMaximized(); - pa.exec(); + QPEApplication::execDialog( &pa ); } @@ -306,5 +332,6 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch // Set defaults if editing an existing connection - if(!isnewaccount) { + if(!isnewaccount) + { before_connect->setText(_pppdata->command_before_connect()); command->setText(_pppdata->command_on_connect()); @@ -315,5 +342,6 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch -bool ExecWidget::save() { +bool ExecWidget::save() +{ _pppdata->setCommand_before_connect(before_connect->text()); _pppdata->setCommand_on_connect(command->text()); @@ -415,12 +443,15 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char //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()); @@ -429,5 +460,6 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char } } - else { + else + { dynamicadd_rb->setChecked(true); hitIPSelect(0); @@ -436,9 +468,11 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char } -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 " @@ -455,9 +489,13 @@ void IPWidget::autoname_t(bool on) { -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()); @@ -467,6 +505,8 @@ void IPWidget::save() { -void IPWidget::hitIPSelect( int i ) { - if(i == 0) { +void IPWidget::hitIPSelect( int i ) +{ + if(i == 0) + { ipaddress_label->setEnabled(false); sub_label->setEnabled(false); @@ -474,5 +514,6 @@ void IPWidget::hitIPSelect( int i ) { subnetmask_l->setEnabled(false); } - else { + else + { ipaddress_label->setEnabled(true); sub_label->setEnabled(true); @@ -598,5 +639,6 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha // restore data if editing - if(!isnewaccount) { + if(!isnewaccount) + { dnsservers->insertStringList(_pppdata->dns()); dnsdomain->setText(_pppdata->domain()); @@ -610,14 +652,17 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha } -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); @@ -632,5 +677,6 @@ void DNSWidget::DNS_Mode_Selected(int mode) { } -void DNSWidget::save() { +void DNSWidget::save() +{ _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); QStringList serverlist; @@ -650,6 +696,8 @@ void DNSWidget::save() { -void DNSWidget::adddns() { - if(dnsservers->count() < MAX_DNS_ENTRIES) { +void DNSWidget::adddns() +{ + if(dnsservers->count() < MAX_DNS_ENTRIES) + { dnsservers->insertItem(dnsipaddr->text()); dnsipaddr->setText(""); @@ -658,5 +706,6 @@ void DNSWidget::adddns() { -void DNSWidget::removedns() { +void DNSWidget::removedns() +{ int i; i = dnsservers->currentItem(); @@ -722,10 +771,13 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c //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); @@ -733,5 +785,6 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c defaultroute->setChecked(_pppdata->defaultroute()); } - else { + else + { defaultgateway->setChecked(true); hitGatewaySelect(0); @@ -740,5 +793,6 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c } -void GatewayWidget::save() { +void GatewayWidget::save() +{ _pppdata->setGateway(gatewayaddr->text()); _pppdata->setDefaultroute(defaultroute->isChecked()); @@ -746,11 +800,14 @@ void GatewayWidget::save() { -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(""); @@ -804,5 +861,6 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con //load data from gpppdata - if(!isnewaccount) { + if(!isnewaccount) + { QStringList &comlist = _pppdata->scriptType(); QStringList &arglist = _pppdata->script(); @@ -825,15 +883,20 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con } -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++; } @@ -846,7 +909,9 @@ bool ScriptWidget::check() { -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)); @@ -858,5 +923,6 @@ void ScriptWidget::save() { -void ScriptWidget::adjustScrollBar() { +void ScriptWidget::adjustScrollBar() +{ if((int)sl->count() <= sl->numItemsVisible()) slb->setRange(0, 0); @@ -866,5 +932,6 @@ void ScriptWidget::adjustScrollBar() { -void ScriptWidget::scrolling(int i) { +void ScriptWidget::scrolling(int i) +{ sl->setTopItem(i); stl->setTopItem(i); @@ -872,5 +939,6 @@ void ScriptWidget::scrolling(int i) { -void ScriptWidget::slhighlighted(int i) { +void ScriptWidget::slhighlighted(int i) +{ insert->setEnabled(true); remove->setEnabled(true); @@ -879,5 +947,6 @@ void ScriptWidget::slhighlighted(int i) { -void ScriptWidget::stlhighlighted(int i) { +void ScriptWidget::stlhighlighted(int i) +{ insert->setEnabled(true); remove->setEnabled(true); @@ -886,10 +955,12 @@ void ScriptWidget::stlhighlighted(int 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"); @@ -981,5 +1052,6 @@ void ScriptWidget::addButton() { -void ScriptWidget::insertButton() { +void ScriptWidget::insertButton() +{ //exit if there is no highlighted item, or we've reached the //maximum entries in the script list @@ -987,5 +1059,6 @@ void ScriptWidget::insertButton() { return; - switch(se->type()) { + switch(se->type()) + { case ScriptEdit::Expect: stl->insertItem("Expect", stl->currentItem()); @@ -1071,6 +1144,8 @@ void ScriptWidget::insertButton() { -void ScriptWidget::removeButton() { - if(sl->currentItem() >= 0) { +void ScriptWidget::removeButton() +{ + if(sl->currentItem() >= 0) + { int stlc = stl->currentItem(); sl->removeItem(sl->currentItem()); @@ -1120,5 +1195,6 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) -QString PhoneNumberDialog::phoneNumber() { +QString PhoneNumberDialog::phoneNumber() +{ QString s = le->text(); @@ -1127,5 +1203,6 @@ QString PhoneNumberDialog::phoneNumber() { -void PhoneNumberDialog::textChanged(const QString &s) { +void PhoneNumberDialog::textChanged(const QString &s) +{ // enableButtonOK(s.length() > 0); } |