Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/devices.cpp | 25 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 233 |
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 @@ -24,25 +24,31 @@ * 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); @@ -191,8 +197,7 @@ int DevicesWidget::doTab(){ bool ok = false; while (!ok){ - dlg->showMaximized(); - result = dlg->exec(); + result = QPEApplication::execDialog( dlg ); ok = true; if(result == QDialog::Accepted) { 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 @@ -23,8 +23,16 @@ * 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> @@ -34,12 +42,11 @@ #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 ) @@ -112,19 +119,23 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 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++; } @@ -137,16 +148,21 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 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); @@ -158,7 +174,8 @@ bool DialWidget::save() { } -void DialWidget::numbersChanged() { +void DialWidget::numbersChanged() +{ int sel = numbers->currentItem(); del->setEnabled(sel != -1); @@ -167,31 +184,38 @@ 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(); } } -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); @@ -201,9 +225,11 @@ 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); numbers->insertItem(item, idx+1); @@ -213,10 +239,10 @@ void DialWidget::downNumber() { } -void DialWidget::pppdargsbutton() { +void DialWidget::pppdargsbutton() +{ PPPdArguments pa(_pppdata, this); - pa.showMaximized(); - pa.exec(); + QPEApplication::execDialog( &pa ); } @@ -305,7 +331,8 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch 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()); @@ -314,7 +341,8 @@ 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()); _pppdata->setCommand_before_disconnect(predisconnect->text()); @@ -414,32 +442,38 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char 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 " @@ -454,11 +488,15 @@ 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()); } @@ -466,14 +504,17 @@ 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); ipaddress_l->setEnabled(false); subnetmask_l->setEnabled(false); } - else { + else + { ipaddress_label->setEnabled(true); sub_label->setEnabled(true); ipaddress_l->setEnabled(true); @@ -597,7 +638,8 @@ 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()); } @@ -609,16 +651,19 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha 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); @@ -631,7 +676,8 @@ void DNSWidget::DNS_Mode_Selected(int mode) { 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++) @@ -649,15 +695,18 @@ 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(""); } } -void DNSWidget::removedns() { +void DNSWidget::removedns() +{ int i; i = dnsservers->currentItem(); if(i != -1) @@ -721,37 +770,45 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c 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); @@ -803,7 +860,8 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con 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(); @@ -824,17 +882,22 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con 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++; @@ -845,9 +908,11 @@ 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)); } @@ -857,7 +922,8 @@ void ScriptWidget::save() { -void ScriptWidget::adjustScrollBar() { +void ScriptWidget::adjustScrollBar() +{ if((int)sl->count() <= sl->numItemsVisible()) slb->setRange(0, 0); else @@ -865,32 +931,37 @@ void ScriptWidget::adjustScrollBar() { } -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()); @@ -980,13 +1051,15 @@ 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 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()); @@ -1070,8 +1143,10 @@ 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()); stl->removeItem(stlc); @@ -1119,14 +1194,16 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) } -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); } |