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 | |||
@@ -25,4 +25,12 @@ | |||
25 | 25 | ||
26 | #include <string.h> | 26 | #include "edit.h" |
27 | #include <termios.h> | 27 | #include "pppdata.h" |
28 | #include "iplined.h" | ||
29 | #include "auth.h" | ||
30 | |||
31 | /* OPIE */ | ||
32 | #include <qpe/resource.h> | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | |||
35 | /* QT */ | ||
28 | #include <qlayout.h> | 36 | #include <qlayout.h> |
@@ -36,8 +44,7 @@ | |||
36 | #include <qdialog.h> | 44 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | ||
38 | 45 | ||
39 | #include "edit.h" | 46 | /* STD */ |
40 | #include "pppdata.h" | 47 | |
41 | #include "iplined.h" | 48 | #include <string.h> |
42 | #include "auth.h" | 49 | #include <termios.h> |
43 | 50 | ||
@@ -114,3 +121,4 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
114 | // Set defaults if editing an existing connection | 121 | // Set defaults if editing an existing connection |
115 | if(!isnewaccount) { | 122 | if(!isnewaccount) |
123 | { | ||
116 | connectname_l->setText(_pppdata->accname()); | 124 | connectname_l->setText(_pppdata->accname()); |
@@ -121,4 +129,6 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
121 | uint idx = 0; | 129 | uint idx = 0; |
122 | while(idx != n.length()) { | 130 | while(idx != n.length()) |
123 | if(n[idx] == ':') { | 131 | { |
132 | if(n[idx] == ':') | ||
133 | { | ||
124 | if(tmp.length() > 0) | 134 | if(tmp.length() > 0) |
@@ -126,3 +136,4 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
126 | tmp = ""; | 136 | tmp = ""; |
127 | } else | 137 | } |
138 | else | ||
128 | tmp += n[idx]; | 139 | tmp += n[idx]; |
@@ -139,8 +150,12 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
139 | 150 | ||
140 | bool DialWidget::save() { | 151 | bool DialWidget::save() |
152 | { | ||
141 | //first check to make sure that the account name is unique! | 153 | //first check to make sure that the account name is unique! |
142 | if(connectname_l->text().isEmpty() || | 154 | if(connectname_l->text().isEmpty() || |
143 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 155 | !_pppdata->isUniqueAccname(connectname_l->text())) |
156 | { | ||
144 | return false; | 157 | return false; |
145 | } else { | 158 | } |
159 | else | ||
160 | { | ||
146 | _pppdata->setAccname(connectname_l->text()); | 161 | _pppdata->setAccname(connectname_l->text()); |
@@ -148,3 +163,4 @@ bool DialWidget::save() { | |||
148 | QString number = ""; | 163 | QString number = ""; |
149 | for(uint i = 0; i < numbers->count(); i++) { | 164 | for(uint i = 0; i < numbers->count(); i++) |
165 | { | ||
150 | if(i != 0) | 166 | if(i != 0) |
@@ -160,3 +176,4 @@ bool DialWidget::save() { | |||
160 | 176 | ||
161 | void DialWidget::numbersChanged() { | 177 | void DialWidget::numbersChanged() |
178 | { | ||
162 | int sel = numbers->currentItem(); | 179 | int sel = numbers->currentItem(); |
@@ -169,3 +186,4 @@ void DialWidget::numbersChanged() { | |||
169 | 186 | ||
170 | void DialWidget::selectionChanged(int) { | 187 | void DialWidget::selectionChanged(int) |
188 | { | ||
171 | numbersChanged(); | 189 | numbersChanged(); |
@@ -174,5 +192,7 @@ void DialWidget::selectionChanged(int) { | |||
174 | 192 | ||
175 | void DialWidget::addNumber() { | 193 | void DialWidget::addNumber() |
194 | { | ||
176 | PhoneNumberDialog dlg(this); | 195 | PhoneNumberDialog dlg(this); |
177 | if(dlg.exec()) { | 196 | if(dlg.exec()) |
197 | { | ||
178 | numbers->insertItem(dlg.phoneNumber()); | 198 | numbers->insertItem(dlg.phoneNumber()); |
@@ -183,4 +203,6 @@ void DialWidget::addNumber() { | |||
183 | 203 | ||
184 | void DialWidget::delNumber() { | 204 | void DialWidget::delNumber() |
185 | if(numbers->currentItem() != -1) { | 205 | { |
206 | if(numbers->currentItem() != -1) | ||
207 | { | ||
186 | numbers->removeItem(numbers->currentItem()); | 208 | numbers->removeItem(numbers->currentItem()); |
@@ -191,5 +213,7 @@ void DialWidget::delNumber() { | |||
191 | 213 | ||
192 | void DialWidget::upNumber() { | 214 | void DialWidget::upNumber() |
215 | { | ||
193 | int idx = numbers->currentItem(); | 216 | int idx = numbers->currentItem(); |
194 | if(idx != -1) { | 217 | if(idx != -1) |
218 | { | ||
195 | QString item = numbers->text(idx); | 219 | QString item = numbers->text(idx); |
@@ -203,5 +227,7 @@ void DialWidget::upNumber() { | |||
203 | 227 | ||
204 | void DialWidget::downNumber() { | 228 | void DialWidget::downNumber() |
229 | { | ||
205 | int idx = numbers->currentItem(); | 230 | int idx = numbers->currentItem(); |
206 | if(idx != -1) { | 231 | if(idx != -1) |
232 | { | ||
207 | QString item = numbers->text(idx); | 233 | QString item = numbers->text(idx); |
@@ -215,6 +241,6 @@ void DialWidget::downNumber() { | |||
215 | 241 | ||
216 | void DialWidget::pppdargsbutton() { | 242 | void DialWidget::pppdargsbutton() |
243 | { | ||
217 | PPPdArguments pa(_pppdata, this); | 244 | PPPdArguments pa(_pppdata, this); |
218 | pa.showMaximized(); | 245 | QPEApplication::execDialog( &pa ); |
219 | pa.exec(); | ||
220 | } | 246 | } |
@@ -307,3 +333,4 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch | |||
307 | // Set defaults if editing an existing connection | 333 | // Set defaults if editing an existing connection |
308 | if(!isnewaccount) { | 334 | if(!isnewaccount) |
335 | { | ||
309 | before_connect->setText(_pppdata->command_before_connect()); | 336 | before_connect->setText(_pppdata->command_before_connect()); |
@@ -316,3 +343,4 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch | |||
316 | 343 | ||
317 | bool ExecWidget::save() { | 344 | bool ExecWidget::save() |
345 | { | ||
318 | _pppdata->setCommand_before_connect(before_connect->text()); | 346 | _pppdata->setCommand_before_connect(before_connect->text()); |
@@ -416,5 +444,7 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char | |||
416 | //load info from gpppdata | 444 | //load info from gpppdata |
417 | if(!isnewaccount) { | 445 | if(!isnewaccount) |
446 | { | ||
418 | if(_pppdata->ipaddr() == "0.0.0.0" && | 447 | if(_pppdata->ipaddr() == "0.0.0.0" && |
419 | _pppdata->subnetmask() == "0.0.0.0") { | 448 | _pppdata->subnetmask() == "0.0.0.0") |
449 | { | ||
420 | dynamicadd_rb->setChecked(true); | 450 | dynamicadd_rb->setChecked(true); |
@@ -423,3 +453,4 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char | |||
423 | } | 453 | } |
424 | else { | 454 | else |
455 | { | ||
425 | ipaddress_l->setText(_pppdata->ipaddr()); | 456 | ipaddress_l->setText(_pppdata->ipaddr()); |
@@ -430,3 +461,4 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char | |||
430 | } | 461 | } |
431 | else { | 462 | else |
463 | { | ||
432 | dynamicadd_rb->setChecked(true); | 464 | dynamicadd_rb->setChecked(true); |
@@ -437,3 +469,4 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char | |||
437 | 469 | ||
438 | void IPWidget::autoname_t(bool on) { | 470 | void IPWidget::autoname_t(bool on) |
471 | { | ||
439 | static bool was_warned = false; | 472 | static bool was_warned = false; |
@@ -441,3 +474,4 @@ void IPWidget::autoname_t(bool on) { | |||
441 | // big-fat warning when selecting the auto configure hostname option | 474 | // big-fat warning when selecting the auto configure hostname option |
442 | if(on && !was_warned) { | 475 | if(on && !was_warned) |
476 | { | ||
443 | QMessageBox::information(this, | 477 | QMessageBox::information(this, |
@@ -456,7 +490,11 @@ void IPWidget::autoname_t(bool on) { | |||
456 | 490 | ||
457 | void IPWidget::save() { | 491 | void IPWidget::save() |
458 | if(dynamicadd_rb->isChecked()) { | 492 | { |
493 | if(dynamicadd_rb->isChecked()) | ||
494 | { | ||
459 | _pppdata->setIpaddr("0.0.0.0"); | 495 | _pppdata->setIpaddr("0.0.0.0"); |
460 | _pppdata->setSubnetmask("0.0.0.0"); | 496 | _pppdata->setSubnetmask("0.0.0.0"); |
461 | } else { | 497 | } |
498 | else | ||
499 | { | ||
462 | _pppdata->setIpaddr(ipaddress_l->text()); | 500 | _pppdata->setIpaddr(ipaddress_l->text()); |
@@ -468,4 +506,6 @@ void IPWidget::save() { | |||
468 | 506 | ||
469 | void IPWidget::hitIPSelect( int i ) { | 507 | void IPWidget::hitIPSelect( int i ) |
470 | if(i == 0) { | 508 | { |
509 | if(i == 0) | ||
510 | { | ||
471 | ipaddress_label->setEnabled(false); | 511 | ipaddress_label->setEnabled(false); |
@@ -475,3 +515,4 @@ void IPWidget::hitIPSelect( int i ) { | |||
475 | } | 515 | } |
476 | else { | 516 | else |
517 | { | ||
477 | ipaddress_label->setEnabled(true); | 518 | ipaddress_label->setEnabled(true); |
@@ -599,3 +640,4 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha | |||
599 | // restore data if editing | 640 | // restore data if editing |
600 | if(!isnewaccount) { | 641 | if(!isnewaccount) |
642 | { | ||
601 | dnsservers->insertStringList(_pppdata->dns()); | 643 | dnsservers->insertStringList(_pppdata->dns()); |
@@ -611,3 +653,4 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha | |||
611 | 653 | ||
612 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 654 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
655 | { | ||
613 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
@@ -616,3 +659,4 @@ void DNSWidget::DNS_Edit_Changed(const QString &text) { | |||
616 | 659 | ||
617 | void DNSWidget::DNS_Entry_Selected(int) { | 660 | void DNSWidget::DNS_Entry_Selected(int) |
661 | { | ||
618 | remove->setEnabled(true); | 662 | remove->setEnabled(true); |
@@ -620,3 +664,4 @@ void DNSWidget::DNS_Entry_Selected(int) { | |||
620 | 664 | ||
621 | void DNSWidget::DNS_Mode_Selected(int mode) { | 665 | void DNSWidget::DNS_Mode_Selected(int mode) |
666 | { | ||
622 | bool on = (mode == 1); | 667 | bool on = (mode == 1); |
@@ -633,3 +678,4 @@ void DNSWidget::DNS_Mode_Selected(int mode) { | |||
633 | 678 | ||
634 | void DNSWidget::save() { | 679 | void DNSWidget::save() |
680 | { | ||
635 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
@@ -651,4 +697,6 @@ void DNSWidget::save() { | |||
651 | 697 | ||
652 | void DNSWidget::adddns() { | 698 | void DNSWidget::adddns() |
653 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 699 | { |
700 | if(dnsservers->count() < MAX_DNS_ENTRIES) | ||
701 | { | ||
654 | dnsservers->insertItem(dnsipaddr->text()); | 702 | dnsservers->insertItem(dnsipaddr->text()); |
@@ -659,3 +707,4 @@ void DNSWidget::adddns() { | |||
659 | 707 | ||
660 | void DNSWidget::removedns() { | 708 | void DNSWidget::removedns() |
709 | { | ||
661 | int i; | 710 | int i; |
@@ -723,4 +772,6 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c | |||
723 | //load info from gpppdata | 772 | //load info from gpppdata |
724 | if(!isnewaccount) { | 773 | if(!isnewaccount) |
725 | if(_pppdata->gateway() == "0.0.0.0") { | 774 | { |
775 | if(_pppdata->gateway() == "0.0.0.0") | ||
776 | { | ||
726 | defaultgateway->setChecked(true); | 777 | defaultgateway->setChecked(true); |
@@ -728,3 +779,4 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c | |||
728 | } | 779 | } |
729 | else { | 780 | else |
781 | { | ||
730 | gatewayaddr->setText(_pppdata->gateway()); | 782 | gatewayaddr->setText(_pppdata->gateway()); |
@@ -734,3 +786,4 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c | |||
734 | } | 786 | } |
735 | else { | 787 | else |
788 | { | ||
736 | defaultgateway->setChecked(true); | 789 | defaultgateway->setChecked(true); |
@@ -741,3 +794,4 @@ GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, c | |||
741 | 794 | ||
742 | void GatewayWidget::save() { | 795 | void GatewayWidget::save() |
796 | { | ||
743 | _pppdata->setGateway(gatewayaddr->text()); | 797 | _pppdata->setGateway(gatewayaddr->text()); |
@@ -747,4 +801,6 @@ void GatewayWidget::save() { | |||
747 | 801 | ||
748 | void GatewayWidget::hitGatewaySelect( int i ) { | 802 | void GatewayWidget::hitGatewaySelect( int i ) |
749 | if(i == 0) { | 803 | { |
804 | if(i == 0) | ||
805 | { | ||
750 | gatewayaddr->setText("0.0.0.0"); | 806 | gatewayaddr->setText("0.0.0.0"); |
@@ -753,3 +809,4 @@ void GatewayWidget::hitGatewaySelect( int i ) { | |||
753 | } | 809 | } |
754 | else { | 810 | else |
811 | { | ||
755 | gatewayaddr->setEnabled(true); | 812 | gatewayaddr->setEnabled(true); |
@@ -805,3 +862,4 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con | |||
805 | //load data from gpppdata | 862 | //load data from gpppdata |
806 | if(!isnewaccount) { | 863 | if(!isnewaccount) |
864 | { | ||
807 | QStringList &comlist = _pppdata->scriptType(); | 865 | QStringList &comlist = _pppdata->scriptType(); |
@@ -826,3 +884,4 @@ ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, con | |||
826 | 884 | ||
827 | bool ScriptWidget::check() { | 885 | bool ScriptWidget::check() |
886 | { | ||
828 | uint lstart = 0; | 887 | uint lstart = 0; |
@@ -831,8 +890,12 @@ bool ScriptWidget::check() { | |||
831 | 890 | ||
832 | if(sl->count() > 0) { | 891 | if(sl->count() > 0) |
833 | for( uint i=0; i <= sl->count()-1; i++) { | 892 | { |
834 | if(stl->text(i) == "LoopStart") { | 893 | for( uint i=0; i <= sl->count()-1; i++) |
894 | { | ||
895 | if(stl->text(i) == "LoopStart") | ||
896 | { | ||
835 | lstart++; | 897 | lstart++; |
836 | } | 898 | } |
837 | if (stl->text(i) == "LoopEnd") { | 899 | if (stl->text(i) == "LoopEnd") |
900 | { | ||
838 | lend++; | 901 | lend++; |
@@ -847,5 +910,7 @@ bool ScriptWidget::check() { | |||
847 | 910 | ||
848 | void ScriptWidget::save() { | 911 | void ScriptWidget::save() |
912 | { | ||
849 | QStringList typelist, arglist; | 913 | QStringList typelist, arglist; |
850 | for(uint i=0; i < sl->count(); i++) { | 914 | for(uint i=0; i < sl->count(); i++) |
915 | { | ||
851 | typelist.append(stl->text(i)); | 916 | typelist.append(stl->text(i)); |
@@ -859,3 +924,4 @@ void ScriptWidget::save() { | |||
859 | 924 | ||
860 | void ScriptWidget::adjustScrollBar() { | 925 | void ScriptWidget::adjustScrollBar() |
926 | { | ||
861 | if((int)sl->count() <= sl->numItemsVisible()) | 927 | if((int)sl->count() <= sl->numItemsVisible()) |
@@ -867,3 +933,4 @@ void ScriptWidget::adjustScrollBar() { | |||
867 | 933 | ||
868 | void ScriptWidget::scrolling(int i) { | 934 | void ScriptWidget::scrolling(int i) |
935 | { | ||
869 | sl->setTopItem(i); | 936 | sl->setTopItem(i); |
@@ -873,3 +940,4 @@ void ScriptWidget::scrolling(int i) { | |||
873 | 940 | ||
874 | void ScriptWidget::slhighlighted(int i) { | 941 | void ScriptWidget::slhighlighted(int i) |
942 | { | ||
875 | insert->setEnabled(true); | 943 | insert->setEnabled(true); |
@@ -880,3 +948,4 @@ void ScriptWidget::slhighlighted(int i) { | |||
880 | 948 | ||
881 | void ScriptWidget::stlhighlighted(int i) { | 949 | void ScriptWidget::stlhighlighted(int i) |
950 | { | ||
882 | insert->setEnabled(true); | 951 | insert->setEnabled(true); |
@@ -887,3 +956,4 @@ void ScriptWidget::stlhighlighted(int i) { | |||
887 | 956 | ||
888 | void ScriptWidget::addButton() { | 957 | void ScriptWidget::addButton() |
958 | { | ||
889 | //don't allow more than the maximum script entries | 959 | //don't allow more than the maximum script entries |
@@ -892,3 +962,4 @@ void ScriptWidget::addButton() { | |||
892 | 962 | ||
893 | switch(se->type()) { | 963 | switch(se->type()) |
964 | { | ||
894 | case ScriptEdit::Expect: | 965 | case ScriptEdit::Expect: |
@@ -982,3 +1053,4 @@ void ScriptWidget::addButton() { | |||
982 | 1053 | ||
983 | void ScriptWidget::insertButton() { | 1054 | void ScriptWidget::insertButton() |
1055 | { | ||
984 | //exit if there is no highlighted item, or we've reached the | 1056 | //exit if there is no highlighted item, or we've reached the |
@@ -988,3 +1060,4 @@ void ScriptWidget::insertButton() { | |||
988 | 1060 | ||
989 | switch(se->type()) { | 1061 | switch(se->type()) |
1062 | { | ||
990 | case ScriptEdit::Expect: | 1063 | case ScriptEdit::Expect: |
@@ -1072,4 +1145,6 @@ void ScriptWidget::insertButton() { | |||
1072 | 1145 | ||
1073 | void ScriptWidget::removeButton() { | 1146 | void ScriptWidget::removeButton() |
1074 | if(sl->currentItem() >= 0) { | 1147 | { |
1148 | if(sl->currentItem() >= 0) | ||
1149 | { | ||
1075 | int stlc = stl->currentItem(); | 1150 | int stlc = stl->currentItem(); |
@@ -1121,3 +1196,4 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | |||
1121 | 1196 | ||
1122 | QString PhoneNumberDialog::phoneNumber() { | 1197 | QString PhoneNumberDialog::phoneNumber() |
1198 | { | ||
1123 | QString s = le->text(); | 1199 | QString s = le->text(); |
@@ -1128,3 +1204,4 @@ QString PhoneNumberDialog::phoneNumber() { | |||
1128 | 1204 | ||
1129 | void PhoneNumberDialog::textChanged(const QString &s) { | 1205 | void PhoneNumberDialog::textChanged(const QString &s) |
1206 | { | ||
1130 | // enableButtonOK(s.length() > 0); | 1207 | // enableButtonOK(s.length() > 0); |