Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (ignore whitespace changes)
12 files changed, 115 insertions, 115 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index b8a1925a..aedc0b9 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -97,49 +97,49 @@ void AccountWidget::edit() | |||
97 | 97 | ||
98 | int result = doTab(); | 98 | int result = doTab(); |
99 | 99 | ||
100 | if(result == QDialog::Accepted) | 100 | if(result == QDialog::Accepted) |
101 | { | 101 | { |
102 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); | 102 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); |
103 | // emit resetaccounts(); | 103 | // emit resetaccounts(); |
104 | _pppdata->save(); | 104 | _pppdata->save(); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void AccountWidget::create() | 109 | void AccountWidget::create() |
110 | { | 110 | { |
111 | 111 | ||
112 | // if(listListbox->count() == MAX_ACCOUNTS) { | 112 | // if(listListbox->count() == MAX_ACCOUNTS) { |
113 | // QMessageBox::information(this, "sorry", | 113 | // QMessageBox::information(this, "sorry", |
114 | // tr("Maximum number of accounts reached.")); | 114 | // tr("Maximum number of accounts reached.")); |
115 | // return; | 115 | // return; |
116 | // } | 116 | // } |
117 | 117 | ||
118 | int result; | 118 | int result; |
119 | if (_pppdata->newaccount() == -1) | 119 | if (_pppdata->newaccount() == -1) |
120 | { | 120 | { |
121 | qDebug("_pppdata->newaccount() == -1"); | 121 | odebug << "_pppdata->newaccount() == -1" << oendl; |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | result = doTab(); | 124 | result = doTab(); |
125 | 125 | ||
126 | if(result == QDialog::Accepted) | 126 | if(result == QDialog::Accepted) |
127 | { | 127 | { |
128 | listListbox->insertItem(_pppdata->accname()); | 128 | listListbox->insertItem(_pppdata->accname()); |
129 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); | 129 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); |
130 | 130 | ||
131 | _pppdata->save(); | 131 | _pppdata->save(); |
132 | } | 132 | } |
133 | else | 133 | else |
134 | _pppdata->deleteAccount(); | 134 | _pppdata->deleteAccount(); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void AccountWidget::copy() | 138 | void AccountWidget::copy() |
139 | { | 139 | { |
140 | // if(listListbox->count() == MAX_ACCOUNTS) { | 140 | // if(listListbox->count() == MAX_ACCOUNTS) { |
141 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 141 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
142 | // return; | 142 | // return; |
143 | // } | 143 | // } |
144 | 144 | ||
145 | if(listListbox->currentItem()<0) | 145 | if(listListbox->currentItem()<0) |
diff --git a/noncore/settings/networksettings/ppp/authwidget.cpp b/noncore/settings/networksettings/ppp/authwidget.cpp index fa2b164..f3d842f 100644 --- a/noncore/settings/networksettings/ppp/authwidget.cpp +++ b/noncore/settings/networksettings/ppp/authwidget.cpp | |||
@@ -121,58 +121,58 @@ AuthWidget::AuthWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch | |||
121 | bool AuthWidget::check() | 121 | bool AuthWidget::check() |
122 | { | 122 | { |
123 | bool ret = true; | 123 | bool ret = true; |
124 | if (scriptWidget){ | 124 | if (scriptWidget){ |
125 | if (!scriptWidget->check()){ | 125 | if (!scriptWidget->check()){ |
126 | QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>")); | 126 | QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>")); |
127 | ret = false; | 127 | ret = false; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | return ret; | 130 | return ret; |
131 | } | 131 | } |
132 | 132 | ||
133 | void AuthWidget::save() | 133 | void AuthWidget::save() |
134 | { | 134 | { |
135 | _pppdata->setAuthMethod(auth->currentItem()); | 135 | _pppdata->setAuthMethod(auth->currentItem()); |
136 | if (scriptWidget) scriptWidget->save(); | 136 | if (scriptWidget) scriptWidget->save(); |
137 | _pppdata->setStoredUsername( userName->text() ); | 137 | _pppdata->setStoredUsername( userName->text() ); |
138 | _pppdata->setStorePassword(store_password->isChecked()); | 138 | _pppdata->setStorePassword(store_password->isChecked()); |
139 | if (store_password->isChecked()) | 139 | if (store_password->isChecked()) |
140 | _pppdata->setStoredPassword( passWord->text() ); | 140 | _pppdata->setStoredPassword( passWord->text() ); |
141 | } | 141 | } |
142 | 142 | ||
143 | void AuthWidget::authChanged( const QString &authStr ) | 143 | void AuthWidget::authChanged( const QString &authStr ) |
144 | { | 144 | { |
145 | qDebug("AuthWidget::authChanged( %s )", authStr.latin1() ); | 145 | odebug << "AuthWidget::authChanged( " << authStr.latin1() << " )" << oendl; |
146 | if ( authStr.contains( tr("Script-based") ) ){ | 146 | if ( authStr.contains( tr("Script-based") ) ){ |
147 | showUsernamePassword( false ); | 147 | showUsernamePassword( false ); |
148 | showScriptWindow( true ); | 148 | showScriptWindow( true ); |
149 | } else if ( authStr.contains( tr("PAP") ) || | 149 | } else if ( authStr.contains( tr("PAP") ) || |
150 | authStr.contains( tr("CHAP") ) ){ | 150 | authStr.contains( tr("CHAP") ) ){ |
151 | showUsernamePassword( true ); | 151 | showUsernamePassword( true ); |
152 | showScriptWindow( false ); | 152 | showScriptWindow( false ); |
153 | } else { | 153 | } else { |
154 | qDebug("do not really know how to handle"); | 154 | odebug << "do not really know how to handle" << oendl; |
155 | showUsernamePassword( false ); | 155 | showUsernamePassword( false ); |
156 | showScriptWindow( false ); | 156 | showScriptWindow( false ); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | void AuthWidget::showUsernamePassword( bool show ) | 161 | void AuthWidget::showUsernamePassword( bool show ) |
162 | { | 162 | { |
163 | if (show){ | 163 | if (show){ |
164 | user_l->show(); | 164 | user_l->show(); |
165 | userName->show(); | 165 | userName->show(); |
166 | pw_l->show(); | 166 | pw_l->show(); |
167 | passWord->show(); | 167 | passWord->show(); |
168 | store_password->show(); | 168 | store_password->show(); |
169 | hidePw->show(); | 169 | hidePw->show(); |
170 | }else{//!show | 170 | }else{//!show |
171 | user_l->hide(); | 171 | user_l->hide(); |
172 | userName->hide(); | 172 | userName->hide(); |
173 | pw_l->hide(); | 173 | pw_l->hide(); |
174 | passWord->hide(); | 174 | passWord->hide(); |
175 | store_password->hide(); | 175 | store_password->hide(); |
176 | hidePw->hide(); | 176 | hidePw->hide(); |
177 | } | 177 | } |
178 | } | 178 | } |
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index e3fab24..b75410c 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -451,49 +451,49 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
451 | if(vmain == 101) { | 451 | if(vmain == 101) { |
452 | if(!expecting) { | 452 | if(!expecting) { |
453 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands | 453 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
454 | 454 | ||
455 | emit startAccounting(); | 455 | emit startAccounting(); |
456 | // p_kppp->con_win->startClock(); | 456 | // p_kppp->con_win->startClock(); |
457 | 457 | ||
458 | vmain = 2; | 458 | vmain = 2; |
459 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; | 459 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
460 | return; | 460 | return; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | // execute the script | 464 | // execute the script |
465 | if(vmain == 2) { | 465 | if(vmain == 2) { |
466 | if(!expecting && !pausing && !scanning) { | 466 | if(!expecting && !pausing && !scanning) { |
467 | 467 | ||
468 | timeout_timer->stop(); | 468 | timeout_timer->stop(); |
469 | timeout_timer->start(scriptTimeout); | 469 | timeout_timer->start(scriptTimeout); |
470 | 470 | ||
471 | if((unsigned) scriptindex < comlist->count()) { | 471 | if((unsigned) scriptindex < comlist->count()) { |
472 | scriptCommand = *(comlist->at(scriptindex)); | 472 | scriptCommand = *(comlist->at(scriptindex)); |
473 | scriptArgument = *(arglist->at(scriptindex)); | 473 | scriptArgument = *(arglist->at(scriptindex)); |
474 | } else { | 474 | } else { |
475 | qDebug( "End of script" ); | 475 | odebug << "End of script" << oendl; |
476 | vmain = 10; | 476 | vmain = 10; |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | 479 | ||
480 | if (scriptCommand == "Scan") { | 480 | if (scriptCommand == "Scan") { |
481 | QString bm = QObject::tr("Scanning %1").arg(scriptArgument); | 481 | QString bm = QObject::tr("Scanning %1").arg(scriptArgument); |
482 | messg->setText(bm); | 482 | messg->setText(bm); |
483 | emit debugMessage(bm); | 483 | emit debugMessage(bm); |
484 | 484 | ||
485 | setScan(scriptArgument); | 485 | setScan(scriptArgument); |
486 | scriptindex++; | 486 | scriptindex++; |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | 489 | ||
490 | if (scriptCommand == "Save") { | 490 | if (scriptCommand == "Save") { |
491 | QString bm = QObject::tr("Saving %1").arg(scriptArgument); | 491 | QString bm = QObject::tr("Saving %1").arg(scriptArgument); |
492 | messg->setText(bm); | 492 | messg->setText(bm); |
493 | emit debugMessage(bm); | 493 | emit debugMessage(bm); |
494 | 494 | ||
495 | if (scriptArgument.lower() == "password") { | 495 | if (scriptArgument.lower() == "password") { |
496 | _ifaceppp->data()->setPassword(scanvar); | 496 | _ifaceppp->data()->setPassword(scanvar); |
497 | // p_kppp->setPW_Edit(scanvar); | 497 | // p_kppp->setPW_Edit(scanvar); |
498 | if(_ifaceppp->data()->storePassword()) | 498 | if(_ifaceppp->data()->storePassword()) |
499 | _ifaceppp->data()->setStoredPassword(scanvar); | 499 | _ifaceppp->data()->setStoredPassword(scanvar); |
@@ -817,59 +817,59 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
817 | // if (termwindow) { | 817 | // if (termwindow) { |
818 | // delete termwindow; | 818 | // delete termwindow; |
819 | // termwindow = 0L; | 819 | // termwindow = 0L; |
820 | // this->show(); | 820 | // this->show(); |
821 | // } else { | 821 | // } else { |
822 | // termwindow = new LoginTerm(0L, 0L); | 822 | // termwindow = new LoginTerm(0L, 0L); |
823 | // hide(); | 823 | // hide(); |
824 | // termwindow->show(); | 824 | // termwindow->show(); |
825 | // vmain = 30; | 825 | // vmain = 30; |
826 | // return; | 826 | // return; |
827 | // } | 827 | // } |
828 | } | 828 | } |
829 | 829 | ||
830 | // Close the tty. This prevents the QTimer::singleShot() in | 830 | // Close the tty. This prevents the QTimer::singleShot() in |
831 | // Modem::readtty() from re-enabling the socket notifier. | 831 | // Modem::readtty() from re-enabling the socket notifier. |
832 | // The port is still held open by the helper process. | 832 | // The port is still held open by the helper process. |
833 | 833 | ||
834 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), | 834 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), |
835 | and closing the thing prevents pppd from using it later. */ | 835 | and closing the thing prevents pppd from using it later. */ |
836 | //_ifaceppp->modem()->closetty(); | 836 | //_ifaceppp->modem()->closetty(); |
837 | 837 | ||
838 | killTimer( main_timer_ID ); | 838 | killTimer( main_timer_ID ); |
839 | 839 | ||
840 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 840 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
841 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 841 | odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; |
842 | 842 | ||
843 | // find out PPP interface and notify the stats module | 843 | // find out PPP interface and notify the stats module |
844 | // stats->setUnit(pppInterfaceNumber()); | 844 | // stats->setUnit(pppInterfaceNumber()); |
845 | 845 | ||
846 | qApp->flushX(); | 846 | qApp->flushX(); |
847 | semaphore = true; | 847 | semaphore = true; |
848 | result = execppp(); | 848 | result = execppp(); |
849 | 849 | ||
850 | emit debugMessage(QObject::tr("Starting pppd...")); | 850 | emit debugMessage(QObject::tr("Starting pppd...")); |
851 | qDebug("execppp() returned with return-code %i", result ); | 851 | odebug << "execppp() returned with return-code " << result << "" << oendl; |
852 | 852 | ||
853 | if(result) { | 853 | if(result) { |
854 | if(!_ifaceppp->data()->autoDNS()) | 854 | if(!_ifaceppp->data()->autoDNS()) |
855 | adddns( _ifaceppp ); | 855 | adddns( _ifaceppp ); |
856 | 856 | ||
857 | // O.K we are done here, let's change over to the if_waiting loop | 857 | // O.K we are done here, let's change over to the if_waiting loop |
858 | // where we wait for the ppp if (interface) to come up. | 858 | // where we wait for the ppp if (interface) to come up. |
859 | 859 | ||
860 | emit if_waiting_signal(); | 860 | emit if_waiting_signal(); |
861 | } else { | 861 | } else { |
862 | 862 | ||
863 | // starting pppd wasn't successful. Error messages were | 863 | // starting pppd wasn't successful. Error messages were |
864 | // handled by execppp(); | 864 | // handled by execppp(); |
865 | if_timeout_timer->stop(); | 865 | if_timeout_timer->stop(); |
866 | this->hide(); | 866 | this->hide(); |
867 | messg->setText(""); | 867 | messg->setText(""); |
868 | //p_kppp->quit_b->setFocus(); | 868 | //p_kppp->quit_b->setFocus(); |
869 | //p_kppp->show(); | 869 | //p_kppp->show(); |
870 | qApp->processEvents(); | 870 | qApp->processEvents(); |
871 | _ifaceppp->modem()->hangup(); | 871 | _ifaceppp->modem()->hangup(); |
872 | emit stopAccounting(); | 872 | emit stopAccounting(); |
873 | //p_kppp->con_win->stopClock(); | 873 | //p_kppp->con_win->stopClock(); |
874 | _ifaceppp->modem()->closetty(); | 874 | _ifaceppp->modem()->closetty(); |
875 | _ifaceppp->modem()->unlockdevice(); | 875 | _ifaceppp->modem()->unlockdevice(); |
@@ -1043,49 +1043,49 @@ void ConnectWidget::setScan(const QString &n) { | |||
1043 | scanstr = n; | 1043 | scanstr = n; |
1044 | scanbuffer = ""; | 1044 | scanbuffer = ""; |
1045 | 1045 | ||
1046 | QString ts = QObject::tr("Scanning: %1").arg(n); | 1046 | QString ts = QObject::tr("Scanning: %1").arg(n); |
1047 | emit debugMessage(ts); | 1047 | emit debugMessage(ts); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | 1050 | ||
1051 | void ConnectWidget::setExpect(const QString &n) { | 1051 | void ConnectWidget::setExpect(const QString &n) { |
1052 | expecting = true; | 1052 | expecting = true; |
1053 | expectstr = n; | 1053 | expectstr = n; |
1054 | 1054 | ||
1055 | QString ts = QObject::tr("Expecting: %1").arg(n); | 1055 | QString ts = QObject::tr("Expecting: %1").arg(n); |
1056 | ts.replace(QRegExp("\n"), "<LF>"); | 1056 | ts.replace(QRegExp("\n"), "<LF>"); |
1057 | emit debugMessage(ts); | 1057 | emit debugMessage(ts); |
1058 | 1058 | ||
1059 | // check if the expected string is in the read buffer already. | 1059 | // check if the expected string is in the read buffer already. |
1060 | checkBuffers(); | 1060 | checkBuffers(); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | 1063 | ||
1064 | void ConnectWidget::if_waiting_timed_out() { | 1064 | void ConnectWidget::if_waiting_timed_out() { |
1065 | if_timer->stop(); | 1065 | if_timer->stop(); |
1066 | if_timeout_timer->stop(); | 1066 | if_timeout_timer->stop(); |
1067 | qDebug("if_waiting_timed_out()"); | 1067 | odebug << "if_waiting_timed_out()" << oendl; |
1068 | 1068 | ||
1069 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); | 1069 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1070 | 1070 | ||
1071 | // let's kill the stuck pppd | 1071 | // let's kill the stuck pppd |
1072 | _ifaceppp->modem()->killPPPDaemon(); | 1072 | _ifaceppp->modem()->killPPPDaemon(); |
1073 | 1073 | ||
1074 | emit stopAccounting(); | 1074 | emit stopAccounting(); |
1075 | // p_kppp->con_win->stopClock(); | 1075 | // p_kppp->con_win->stopClock(); |
1076 | 1076 | ||
1077 | 1077 | ||
1078 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1078 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1079 | // in main.cpp what happens next will depend on the boolean | 1079 | // in main.cpp what happens next will depend on the boolean |
1080 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1080 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | void ConnectWidget::pppdDied() | 1083 | void ConnectWidget::pppdDied() |
1084 | { | 1084 | { |
1085 | if_timer->stop(); | 1085 | if_timer->stop(); |
1086 | if_timeout_timer->stop(); | 1086 | if_timeout_timer->stop(); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | void ConnectWidget::if_waiting_slot() { | 1089 | void ConnectWidget::if_waiting_slot() { |
1090 | messg->setText(QObject::tr("Logging on to network...")); | 1090 | messg->setText(QObject::tr("Logging on to network...")); |
1091 | 1091 | ||
@@ -1250,49 +1250,49 @@ bool ConnectWidget::execppp() { | |||
1250 | 1250 | ||
1251 | // check for debug | 1251 | // check for debug |
1252 | if(_ifaceppp->data()->getPPPDebug()) | 1252 | if(_ifaceppp->data()->getPPPDebug()) |
1253 | command += " debug"; | 1253 | command += " debug"; |
1254 | 1254 | ||
1255 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | 1255 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); |
1256 | for ( QStringList::Iterator it = arglist.begin(); | 1256 | for ( QStringList::Iterator it = arglist.begin(); |
1257 | it != arglist.end(); | 1257 | it != arglist.end(); |
1258 | ++it ) | 1258 | ++it ) |
1259 | { | 1259 | { |
1260 | command += " " + *it; | 1260 | command += " " + *it; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | command += " call opie-kppp logfd 11"; | 1263 | command += " call opie-kppp logfd 11"; |
1264 | 1264 | ||
1265 | if (command.length() > MAX_CMDLEN) { | 1265 | if (command.length() > MAX_CMDLEN) { |
1266 | QMessageBox::critical(this, "error", QObject::tr( | 1266 | QMessageBox::critical(this, "error", QObject::tr( |
1267 | "pppd command + command-line arguments exceed " | 1267 | "pppd command + command-line arguments exceed " |
1268 | "2024 characters in length." | 1268 | "2024 characters in length." |
1269 | )); | 1269 | )); |
1270 | 1270 | ||
1271 | return false; // nonsensically long command which would bust my buffer buf. | 1271 | return false; // nonsensically long command which would bust my buffer buf. |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | qWarning("Command IS: %s",command.latin1() ); | 1274 | owarn << "Command IS: " << command.latin1() << "" << oendl; |
1275 | 1275 | ||
1276 | qApp->flushX(); | 1276 | qApp->flushX(); |
1277 | 1277 | ||
1278 | return _ifaceppp->modem()->execPPPDaemon(command); | 1278 | return _ifaceppp->modem()->execPPPDaemon(command); |
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | 1281 | ||
1282 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1282 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1283 | e->ignore(); | 1283 | e->ignore(); |
1284 | emit cancelbutton(); | 1284 | emit cancelbutton(); |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | 1287 | ||
1288 | void ConnectWidget::setMsg(const QString &msg) { | 1288 | void ConnectWidget::setMsg(const QString &msg) { |
1289 | messg->setText(msg); | 1289 | messg->setText(msg); |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | void ConnectWidget::writeline(const QString &s) { | 1292 | void ConnectWidget::writeline(const QString &s) { |
1293 | _ifaceppp->modem()->writeLine(s.local8Bit()); | 1293 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | // Set the hostname and domain from DNS Server | 1296 | // Set the hostname and domain from DNS Server |
1297 | void auto_hostname(InterfacePPP *_ifaceppp) { | 1297 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1298 | struct in_addr local_ip; | 1298 | struct in_addr local_ip; |
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index 9da090d..350ff32 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp | |||
@@ -51,53 +51,53 @@ | |||
51 | 51 | ||
52 | 52 | ||
53 | void parseargs(char* buf, char** args); | 53 | void parseargs(char* buf, char** args); |
54 | 54 | ||
55 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) | 55 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) |
56 | : ChooserWidget(ip->data(), parent, name, f) | 56 | : ChooserWidget(ip->data(), parent, name, f) |
57 | { | 57 | { |
58 | _ifaceppp = ip; | 58 | _ifaceppp = ip; |
59 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); | 59 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); |
60 | QWhatsThis::add(new_b, tr("Create a new device") ); | 60 | QWhatsThis::add(new_b, tr("Create a new device") ); |
61 | 61 | ||
62 | QWhatsThis::add(copy_b, | 62 | QWhatsThis::add(copy_b, |
63 | tr("Makes a copy of the selected device. All\n" | 63 | tr("Makes a copy of the selected device. All\n" |
64 | "settings of the selected device are copied\n" | 64 | "settings of the selected device are copied\n" |
65 | "to a new device, that you can modify to fit your\n" | 65 | "to a new device, that you can modify to fit your\n" |
66 | "needs")); | 66 | "needs")); |
67 | QWhatsThis::add(delete_b, | 67 | QWhatsThis::add(delete_b, |
68 | tr("<p>Deletes the selected device\n\n" | 68 | tr("<p>Deletes the selected device\n\n" |
69 | "<font color=\"red\"><b>Use with care!</b></font>")); | 69 | "<font color=\"red\"><b>Use with care!</b></font>")); |
70 | 70 | ||
71 | copy_b->setEnabled( false ); //FIXME | 71 | copy_b->setEnabled( false ); //FIXME |
72 | // delete_b->setEnabled( false ); //FIXME | 72 | // delete_b->setEnabled( false ); //FIXME |
73 | 73 | ||
74 | QStringList tmp = _pppdata->getDevicesNamesList(); | 74 | QStringList tmp = _pppdata->getDevicesNamesList(); |
75 | qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1()); | 75 | odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl; |
76 | listListbox->insertStringList(tmp); | 76 | listListbox->insertStringList(tmp); |
77 | 77 | ||
78 | for (uint i = 0; i < listListbox->count(); i++){ | 78 | for (uint i = 0; i < listListbox->count(); i++){ |
79 | qDebug("listListbox->text(i) %s == _pppdata->devname() %s",listListbox->text(i).latin1(), _pppdata->devname().latin1()); | 79 | odebug << "listListbox->text(i) " << listListbox->text(i).latin1() << " == _pppdata->devname() " << _pppdata->devname().latin1() << "" << oendl; |
80 | if ( listListbox->text(i) == _pppdata->devname() ) | 80 | if ( listListbox->text(i) == _pppdata->devname() ) |
81 | listListbox->setCurrentItem( i ); | 81 | listListbox->setCurrentItem( i ); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | void DevicesWidget::slotListBoxSelect(int idx) { | 87 | void DevicesWidget::slotListBoxSelect(int idx) { |
88 | bool ok = _pppdata->setDevice( listListbox->text(idx) ); | 88 | bool ok = _pppdata->setDevice( listListbox->text(idx) ); |
89 | delete_b->setEnabled((bool)(idx != -1)); | 89 | delete_b->setEnabled((bool)(idx != -1)); |
90 | edit_b->setEnabled((bool)(idx != -1)); | 90 | edit_b->setEnabled((bool)(idx != -1)); |
91 | //FIXME copy_b->setEnabled((bool)(idx != -1)); | 91 | //FIXME copy_b->setEnabled((bool)(idx != -1)); |
92 | } | 92 | } |
93 | 93 | ||
94 | void DevicesWidget::edit() { | 94 | void DevicesWidget::edit() { |
95 | _pppdata->setDevice(listListbox->text(listListbox->currentItem())); | 95 | _pppdata->setDevice(listListbox->text(listListbox->currentItem())); |
96 | 96 | ||
97 | int result = doTab(); | 97 | int result = doTab(); |
98 | 98 | ||
99 | if(result == QDialog::Accepted) { | 99 | if(result == QDialog::Accepted) { |
100 | listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); | 100 | listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); |
101 | _pppdata->save(); | 101 | _pppdata->save(); |
102 | } | 102 | } |
103 | } | 103 | } |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 81dab38..69bb682 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -314,49 +314,49 @@ ModemWidget::~ModemWidget() | |||
314 | 314 | ||
315 | // void ModemWidget::setflowcontrol(int i) { | 315 | // void ModemWidget::setflowcontrol(int i) { |
316 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); | 316 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); |
317 | // } | 317 | // } |
318 | 318 | ||
319 | 319 | ||
320 | // void ModemWidget::modemlockfilechanged(bool set) { | 320 | // void ModemWidget::modemlockfilechanged(bool set) { |
321 | // _pppdata->setModemLockFile(set); | 321 | // _pppdata->setModemLockFile(set); |
322 | // } | 322 | // } |
323 | 323 | ||
324 | 324 | ||
325 | // void ModemWidget::modemtimeoutchanged(int n) { | 325 | // void ModemWidget::modemtimeoutchanged(int n) { |
326 | // _pppdata->setModemTimeout(n); | 326 | // _pppdata->setModemTimeout(n); |
327 | // } | 327 | // } |
328 | 328 | ||
329 | 329 | ||
330 | 330 | ||
331 | bool ModemWidget::save() | 331 | bool ModemWidget::save() |
332 | { | 332 | { |
333 | //first check to make sure that the device name is unique! | 333 | //first check to make sure that the device name is unique! |
334 | if(modemname->text().isEmpty() || | 334 | if(modemname->text().isEmpty() || |
335 | !_pppdata->isUniqueDevname(modemname->text())) | 335 | !_pppdata->isUniqueDevname(modemname->text())) |
336 | return false; | 336 | return false; |
337 | 337 | ||
338 | qDebug("ModemWidget::save saving modem1 data"); | 338 | odebug << "ModemWidget::save saving modem1 data" << oendl; |
339 | _pppdata->setDevname( modemname->text() ); | 339 | _pppdata->setDevname( modemname->text() ); |
340 | _pppdata->setModemDevice( modemdevice->currentText() ); | 340 | _pppdata->setModemDevice( modemdevice->currentText() ); |
341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); |
342 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 342 | _pppdata->setFlowcontrol(flowcontrol->currentText()); |
343 | _pppdata->setSpeed(baud_c->currentText()); | 343 | _pppdata->setSpeed(baud_c->currentText()); |
344 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | 344 | _pppdata->setModemLockFile( modemlockfile->isChecked()); |
345 | _pppdata->setModemTimeout( modemtimeout->value() ); | 345 | _pppdata->setModemTimeout( modemtimeout->value() ); |
346 | return true; | 346 | return true; |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | 350 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, |
351 | const char *name) | 351 | const char *name) |
352 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) | 352 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
353 | { | 353 | { |
354 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 354 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
355 | 355 | ||
356 | 356 | ||
357 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); | 357 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
358 | waitfordt->setChecked(_pppdata->waitForDialTone()); | 358 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
359 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 359 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
360 | l1->addWidget(waitfordt); | 360 | l1->addWidget(waitfordt); |
361 | QWhatsThis::add(waitfordt, | 361 | QWhatsThis::add(waitfordt, |
362 | tr("<p>Normally the modem waits for a dial tone\n" | 362 | tr("<p>Normally the modem waits for a dial tone\n" |
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 6b158b9..5a76293 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -1,41 +1,41 @@ | |||
1 | #include "interfaceinformationppp.h" | 1 | #include "interfaceinformationppp.h" |
2 | 2 | ||
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
6 | #include <qabstractlayout.h> | 6 | #include <qabstractlayout.h> |
7 | 7 | ||
8 | #include "connect.h" | 8 | #include "connect.h" |
9 | #include "conwindow.h" | 9 | #include "conwindow.h" |
10 | 10 | ||
11 | #ifdef QWS | 11 | #ifdef QWS |
12 | #else | 12 | #else |
13 | #define showMaximized show | 13 | #define showMaximized show |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor for the InterfaceInformationImp class. This class pretty much | 17 | * Constructor for the InterfaceInformationImp class. This class pretty much |
18 | * just display's information about the interface that is passed to it. | 18 | * just display's information about the interface that is passed to it. |
19 | */ | 19 | */ |
20 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 20 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
21 | :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) | 21 | :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) |
22 | { | 22 | { |
23 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP %s", name); | 23 | odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl; |
24 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | 24 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); |
25 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, | 25 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, |
26 | QSizePolicy::Fixed) ); | 26 | QSizePolicy::Fixed) ); |
27 | 27 | ||
28 | macAddressLabel->hide(); | 28 | macAddressLabel->hide(); |
29 | subnetMaskLabel->hide(); | 29 | subnetMaskLabel->hide(); |
30 | broadcastLabel->hide(); | 30 | broadcastLabel->hide(); |
31 | TextLabel23->hide(); | 31 | TextLabel23->hide(); |
32 | TextLabel21->hide(); | 32 | TextLabel21->hide(); |
33 | TextLabel24->hide(); | 33 | TextLabel24->hide(); |
34 | 34 | ||
35 | InterfaceInformationLayout->addWidget( con, 1, 0 ); | 35 | InterfaceInformationLayout->addWidget( con, 1, 0 ); |
36 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | 36 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); |
37 | connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); | 37 | connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); |
38 | } | 38 | } |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index f443f3c..5cc6f70 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,80 +1,80 @@ | |||
1 | 1 | ||
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | 6 | ||
7 | #include "auth.h" | 7 | #include "auth.h" |
8 | #include "interfaceppp.h" | 8 | #include "interfaceppp.h" |
9 | #include "modem.h" | 9 | #include "modem.h" |
10 | #include "pppdata.h" | 10 | #include "pppdata.h" |
11 | 11 | ||
12 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 12 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
13 | : Interface(parent, name, status), | 13 | : Interface(parent, name, status), |
14 | _modemPtr(0), | 14 | _modemPtr(0), |
15 | _dataPtr(0) | 15 | _dataPtr(0) |
16 | { | 16 | { |
17 | qDebug("InterfacePPP::InterfacePPP("); | 17 | odebug << "InterfacePPP::InterfacePPP(" << oendl; |
18 | } | 18 | } |
19 | 19 | ||
20 | PPPData* InterfacePPP::data()const | 20 | PPPData* InterfacePPP::data()const |
21 | { | 21 | { |
22 | if (!_dataPtr){ | 22 | if (!_dataPtr){ |
23 | qDebug("creating new Data obj"); | 23 | odebug << "creating new Data obj" << oendl; |
24 | _dataPtr = new PPPData(); | 24 | _dataPtr = new PPPData(); |
25 | _dataPtr->setDevice( getInterfaceName() ); | 25 | _dataPtr->setDevice( getInterfaceName() ); |
26 | _dataPtr->setAccount( getHardwareName() ); | 26 | _dataPtr->setAccount( getHardwareName() ); |
27 | } | 27 | } |
28 | return _dataPtr; | 28 | return _dataPtr; |
29 | } | 29 | } |
30 | 30 | ||
31 | Modem* InterfacePPP::modem()const | 31 | Modem* InterfacePPP::modem()const |
32 | { | 32 | { |
33 | if (!_modemPtr){ | 33 | if (!_modemPtr){ |
34 | qDebug("creating new modem obj"); | 34 | odebug << "creating new modem obj" << oendl; |
35 | _modemPtr = new Modem( data() ); | 35 | _modemPtr = new Modem( data() ); |
36 | } | 36 | } |
37 | return _modemPtr; | 37 | return _modemPtr; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool InterfacePPP::refresh() | 40 | bool InterfacePPP::refresh() |
41 | { | 41 | { |
42 | qDebug("InterfacePPP::refresh()"); | 42 | odebug << "InterfacePPP::refresh()" << oendl; |
43 | QString old = getInterfaceName(); | 43 | QString old = getInterfaceName(); |
44 | setInterfaceName( modem()->pppDevice() ); | 44 | setInterfaceName( modem()->pppDevice() ); |
45 | 45 | ||
46 | (void)Interface::refresh(); | 46 | (void)Interface::refresh(); |
47 | 47 | ||
48 | setInterfaceName( old ); | 48 | setInterfaceName( old ); |
49 | emit updateInterface(this); | 49 | emit updateInterface(this); |
50 | 50 | ||
51 | return true; | 51 | return true; |
52 | } | 52 | } |
53 | 53 | ||
54 | void InterfacePPP::start() | 54 | void InterfacePPP::start() |
55 | { | 55 | { |
56 | qDebug("InterfacePPP::start"); | 56 | odebug << "InterfacePPP::start" << oendl; |
57 | 57 | ||
58 | if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { | 58 | if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { |
59 | 59 | ||
60 | QDialog mb( 0, "Dialog", true ); | 60 | QDialog mb( 0, "Dialog", true ); |
61 | mb.setCaption( tr( "No password" ) ); | 61 | mb.setCaption( tr( "No password" ) ); |
62 | QVBoxLayout layout( &mb ); | 62 | QVBoxLayout layout( &mb ); |
63 | QLabel text ( &mb ); | 63 | QLabel text ( &mb ); |
64 | text.setText( tr("Username defined but no password\n Please enter a password") ); | 64 | text.setText( tr("Username defined but no password\n Please enter a password") ); |
65 | QLineEdit lineedit( &mb ); | 65 | QLineEdit lineedit( &mb ); |
66 | lineedit.setEchoMode( QLineEdit::Password ); | 66 | lineedit.setEchoMode( QLineEdit::Password ); |
67 | layout.addWidget( &text ); | 67 | layout.addWidget( &text ); |
68 | layout.addWidget( &lineedit ); | 68 | layout.addWidget( &lineedit ); |
69 | if ( mb.exec() == QDialog::Accepted ) { | 69 | if ( mb.exec() == QDialog::Accepted ) { |
70 | data()->setPassword( lineedit.text() ); | 70 | data()->setPassword( lineedit.text() ); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | QFileInfo info(pppdPath()); | 74 | QFileInfo info(pppdPath()); |
75 | 75 | ||
76 | if(!info.exists()){ | 76 | if(!info.exists()){ |
77 | QMessageBox::warning(0, tr("Error"), | 77 | QMessageBox::warning(0, tr("Error"), |
78 | QObject::tr("<qt>Cannot find the PPP daemon!<br>" | 78 | QObject::tr("<qt>Cannot find the PPP daemon!<br>" |
79 | "Make sure that pppd is installed and " | 79 | "Make sure that pppd is installed and " |
80 | "that you have entered the correct path.</qt>")); | 80 | "that you have entered the correct path.</qt>")); |
@@ -122,53 +122,53 @@ void InterfacePPP::start() | |||
122 | PPPData::encodeWord(data()->storedUsername()), | 122 | PPPData::encodeWord(data()->storedUsername()), |
123 | PPPData::encodeWord(data()->password())) | 123 | PPPData::encodeWord(data()->password())) |
124 | ) { | 124 | ) { |
125 | QString s; | 125 | QString s; |
126 | s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" | 126 | s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" |
127 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | 127 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); |
128 | QMessageBox::warning(0, tr("Error"), s); | 128 | QMessageBox::warning(0, tr("Error"), s); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | if (data()->phonenumber().isEmpty()) { | 134 | if (data()->phonenumber().isEmpty()) { |
135 | QString s = QObject::tr("You must specify a telephone number!"); | 135 | QString s = QObject::tr("You must specify a telephone number!"); |
136 | QMessageBox::warning(0, tr("Error"), s); | 136 | QMessageBox::warning(0, tr("Error"), s); |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | 139 | ||
140 | // SEGFAULTS: | 140 | // SEGFAULTS: |
141 | // setStatus( true ); | 141 | // setStatus( true ); |
142 | // emit updateInterface((Interface*) this); | 142 | // emit updateInterface((Interface*) this); |
143 | 143 | ||
144 | emit begin_connect(); | 144 | emit begin_connect(); |
145 | 145 | ||
146 | qDebug("InterfacePPP::start END"); | 146 | odebug << "InterfacePPP::start END" << oendl; |
147 | } | 147 | } |
148 | 148 | ||
149 | void InterfacePPP::stop() | 149 | void InterfacePPP::stop() |
150 | { | 150 | { |
151 | qDebug("InterfacePPP::stop"); | 151 | odebug << "InterfacePPP::stop" << oendl; |
152 | // emit hangup_now(); | 152 | // emit hangup_now(); |
153 | status = false; // not connected | 153 | status = false; // not connected |
154 | setStatus( false ); | 154 | setStatus( false ); |
155 | emit hangup_now(); | 155 | emit hangup_now(); |
156 | refresh(); | 156 | refresh(); |
157 | 157 | ||
158 | } | 158 | } |
159 | 159 | ||
160 | void InterfacePPP::save() | 160 | void InterfacePPP::save() |
161 | { | 161 | { |
162 | data()->save(); | 162 | data()->save(); |
163 | emit updateInterface((Interface*) this); | 163 | emit updateInterface((Interface*) this); |
164 | } | 164 | } |
165 | QString InterfacePPP::pppDev()const { | 165 | QString InterfacePPP::pppDev()const { |
166 | return modem()->pppDevice(); | 166 | return modem()->pppDevice(); |
167 | } | 167 | } |
168 | pid_t InterfacePPP::pppPID()const{ | 168 | pid_t InterfacePPP::pppPID()const{ |
169 | return modem()->pppPID(); | 169 | return modem()->pppPID(); |
170 | } | 170 | } |
171 | void InterfacePPP::setPPPDpid( pid_t pid) { | 171 | void InterfacePPP::setPPPDpid( pid_t pid) { |
172 | setStatus( true ); | 172 | setStatus( true ); |
173 | modem()->setPPPDPid( pid ); | 173 | modem()->setPPPDPid( pid ); |
174 | } | 174 | } |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index e21bbc7..fd09332 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -53,55 +53,55 @@ | |||
53 | 53 | ||
54 | //#include "main.h" | 54 | //#include "main.h" |
55 | #include "auth.h" | 55 | #include "auth.h" |
56 | #include "modem.h" | 56 | #include "modem.h" |
57 | //#include "ppplog.h" | 57 | //#include "ppplog.h" |
58 | //#include "opener.h" | 58 | //#include "opener.h" |
59 | //#include "requester.h" | 59 | //#include "requester.h" |
60 | //#include "pppstats.h" | 60 | //#include "pppstats.h" |
61 | #include "pppdata.h" | 61 | #include "pppdata.h" |
62 | #include "general.h" | 62 | #include "general.h" |
63 | #include "interface.h" | 63 | #include "interface.h" |
64 | 64 | ||
65 | #define execute_command system | 65 | #define execute_command system |
66 | 66 | ||
67 | KPPPWidget *p_kppp = 0; | 67 | KPPPWidget *p_kppp = 0; |
68 | 68 | ||
69 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) | 69 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) |
70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) | 70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) |
71 | { | 71 | { |
72 | // tabWindow = 0; | 72 | // tabWindow = 0; |
73 | p_kppp = this; | 73 | p_kppp = this; |
74 | // before doing anything else, run a few tests | 74 | // before doing anything else, run a few tests |
75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | 75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) |
76 | _pppdata->setModemDevice("/dev/modem"); | 76 | _pppdata->setModemDevice("/dev/modem"); |
77 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 77 | odebug << "PPPConfigWidget::PPPConfigWidget" << oendl; |
78 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | 78 | odebug << " interface->getHardwareName >" << i->getHardwareName().latin1() << "<" << oendl; |
79 | if (!_pppdata->setAccount( i->getHardwareName() )) | 79 | if (!_pppdata->setAccount( i->getHardwareName() )) |
80 | _pppdata->setAccount( 0 ); | 80 | _pppdata->setAccount( 0 ); |
81 | 81 | ||
82 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | 82 | odebug << " _pppdata->accname >" << _pppdata->accname().latin1() << "<" << oendl; |
83 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); | 83 | odebug << " _pppdata->currentAccountID() >" << _pppdata->currentAccountID() << "<" << oendl; |
84 | 84 | ||
85 | int result = runTests(); | 85 | int result = runTests(); |
86 | if(result == TEST_CRITICAL) | 86 | if(result == TEST_CRITICAL) |
87 | exit(4); | 87 | exit(4); |
88 | 88 | ||
89 | // installEventFilter(this); | 89 | // installEventFilter(this); |
90 | 90 | ||
91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
92 | 92 | ||
93 | QGridLayout *l1 = new QGridLayout(3, 4); | 93 | QGridLayout *l1 = new QGridLayout(3, 4); |
94 | tl->addLayout(l1); | 94 | tl->addLayout(l1); |
95 | l1->addColSpacing(0, 10); | 95 | l1->addColSpacing(0, 10); |
96 | l1->addColSpacing(3, 10); | 96 | l1->addColSpacing(3, 10); |
97 | l1->setColStretch(1, 3); | 97 | l1->setColStretch(1, 3); |
98 | l1->setColStretch(2, 4); | 98 | l1->setColStretch(2, 4); |
99 | 99 | ||
100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); | 100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); |
101 | l1->addWidget(label1, 0, 1); | 101 | l1->addWidget(label1, 0, 1); |
102 | 102 | ||
103 | connectto_c = new QComboBox(false, this); | 103 | connectto_c = new QComboBox(false, this); |
104 | label1->setBuddy(connectto_c); | 104 | label1->setBuddy(connectto_c); |
105 | 105 | ||
106 | connect(connectto_c, SIGNAL(activated(int)), | 106 | connect(connectto_c, SIGNAL(activated(int)), |
107 | SLOT(newdefaultaccount(int))); | 107 | SLOT(newdefaultaccount(int))); |
@@ -284,49 +284,49 @@ KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *na | |||
284 | // } | 284 | // } |
285 | // } else | 285 | // } else |
286 | // expandbutton(); | 286 | // expandbutton(); |
287 | // show(); | 287 | // show(); |
288 | 288 | ||
289 | 289 | ||
290 | //#define KPPP_SHOW_NEWS | 290 | //#define KPPP_SHOW_NEWS |
291 | #ifdef KPPP_SHOW_NEWS | 291 | #ifdef KPPP_SHOW_NEWS |
292 | // keep user informed about recent changes | 292 | // keep user informed about recent changes |
293 | if(!m_bCmdlAccount) | 293 | if(!m_bCmdlAccount) |
294 | showNews(); | 294 | showNews(); |
295 | #endif | 295 | #endif |
296 | } | 296 | } |
297 | 297 | ||
298 | KPPPWidget::~KPPPWidget() | 298 | KPPPWidget::~KPPPWidget() |
299 | { | 299 | { |
300 | p_kppp = 0; | 300 | p_kppp = 0; |
301 | // delete stats; | 301 | // delete stats; |
302 | } | 302 | } |
303 | 303 | ||
304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
305 | // if(e->type() == QEvent::User) { | 305 | // if(e->type() == QEvent::User) { |
306 | // switch(((SignalEvent*)e)->sigType()) { | 306 | // switch(((SignalEvent*)e)->sigType()) { |
307 | // case SIGINT: | 307 | // case SIGINT: |
308 | // qDebug( "Received a SIGINT" ); | 308 | // odebug << "Received a SIGINT" << oendl; |
309 | // interruptConnection(); | 309 | // interruptConnection(); |
310 | // break; | 310 | // break; |
311 | // case SIGCHLD: | 311 | // case SIGCHLD: |
312 | // sigChld(); | 312 | // sigChld(); |
313 | // break; | 313 | // break; |
314 | // case SIGUSR1: | 314 | // case SIGUSR1: |
315 | // sigPPPDDied(); | 315 | // sigPPPDDied(); |
316 | // break; | 316 | // break; |
317 | // } | 317 | // } |
318 | // return true; | 318 | // return true; |
319 | // } | 319 | // } |
320 | 320 | ||
321 | // if(o == connect_b) { | 321 | // if(o == connect_b) { |
322 | // if(e->type() == QEvent::KeyPress) { | 322 | // if(e->type() == QEvent::KeyPress) { |
323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
324 | // beginConnect(); | 324 | // beginConnect(); |
325 | // return true; | 325 | // return true; |
326 | // } | 326 | // } |
327 | // } | 327 | // } |
328 | // } | 328 | // } |
329 | 329 | ||
330 | // return false; | 330 | // return false; |
331 | // } | 331 | // } |
332 | 332 | ||
@@ -402,137 +402,137 @@ void KPPPWidget::log_window_toggled(bool on) { | |||
402 | // connect(PW_Edit, SIGNAL(textChanged(const QString&)), | 402 | // connect(PW_Edit, SIGNAL(textChanged(const QString&)), |
403 | // this, SLOT(passwordChanged(const QString&))); | 403 | // this, SLOT(passwordChanged(const QString&))); |
404 | 404 | ||
405 | // if (ID_Edit->text().isEmpty()) | 405 | // if (ID_Edit->text().isEmpty()) |
406 | // ID_Edit->setFocus(); | 406 | // ID_Edit->setFocus(); |
407 | // else if (PW_Edit->text().isEmpty()) | 407 | // else if (PW_Edit->text().isEmpty()) |
408 | // PW_Edit->setFocus(); | 408 | // PW_Edit->setFocus(); |
409 | // } | 409 | // } |
410 | 410 | ||
411 | 411 | ||
412 | void KPPPWidget::interruptConnection() { | 412 | void KPPPWidget::interruptConnection() { |
413 | // interrupt dial up | 413 | // interrupt dial up |
414 | // | 414 | // |
415 | 415 | ||
416 | if (con->isVisible()) | 416 | if (con->isVisible()) |
417 | emit con->cancelbutton(); | 417 | emit con->cancelbutton(); |
418 | 418 | ||
419 | // disconnect if online | 419 | // disconnect if online |
420 | if (_pppdata->pppdRunning()) | 420 | if (_pppdata->pppdRunning()) |
421 | emit disconnect(); | 421 | emit disconnect(); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void KPPPWidget::sigPPPDDied() { | 425 | void KPPPWidget::sigPPPDDied() { |
426 | qDebug( "Received a SIGUSR1" ); | 426 | odebug << "Received a SIGUSR1" << oendl; |
427 | 427 | ||
428 | // if we are not connected pppdpid is -1 so have have to check for that | 428 | // if we are not connected pppdpid is -1 so have have to check for that |
429 | // in the followin line to make sure that we don't raise a false alarm | 429 | // in the followin line to make sure that we don't raise a false alarm |
430 | // such as would be the case when the log file viewer exits. | 430 | // such as would be the case when the log file viewer exits. |
431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { | 431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
432 | qDebug( "It was pppd that died" ); | 432 | odebug << "It was pppd that died" << oendl; |
433 | 433 | ||
434 | // when we killpppd() on Cancel in ConnectWidget | 434 | // when we killpppd() on Cancel in ConnectWidget |
435 | // we set pppid to -1 so we won't | 435 | // we set pppid to -1 so we won't |
436 | // enter this block | 436 | // enter this block |
437 | 437 | ||
438 | // just to be sure | 438 | // just to be sure |
439 | 439 | ||
440 | Modem::modem->removeSecret(AUTH_PAP); | 440 | Modem::modem->removeSecret(AUTH_PAP); |
441 | Modem::modem->removeSecret(AUTH_CHAP); | 441 | Modem::modem->removeSecret(AUTH_CHAP); |
442 | 442 | ||
443 | _pppdata->setpppdRunning(false); | 443 | _pppdata->setpppdRunning(false); |
444 | 444 | ||
445 | qDebug( "Executing command on disconnect since pppd has died." ); | 445 | odebug << "Executing command on disconnect since pppd has died." << oendl; |
446 | QApplication::flushX(); | 446 | QApplication::flushX(); |
447 | execute_command(_pppdata->command_on_disconnect()); | 447 | execute_command(_pppdata->command_on_disconnect()); |
448 | 448 | ||
449 | // stopAccounting(); | 449 | // stopAccounting(); |
450 | 450 | ||
451 | con_win->stopClock(); | 451 | con_win->stopClock(); |
452 | // DockWidget::dock_widget->stop_stats(); | 452 | // DockWidget::dock_widget->stop_stats(); |
453 | // DockWidget::dock_widget->hide(); | 453 | // DockWidget::dock_widget->hide(); |
454 | 454 | ||
455 | if(!_pppdata->pppdError()) | 455 | if(!_pppdata->pppdError()) |
456 | _pppdata->setpppdError(E_PPPD_DIED); | 456 | _pppdata->setpppdError(E_PPPD_DIED); |
457 | removedns(); | 457 | removedns(); |
458 | Modem::modem->unlockdevice(); | 458 | Modem::modem->unlockdevice(); |
459 | // | 459 | // |
460 | con->pppdDied(); | 460 | con->pppdDied(); |
461 | 461 | ||
462 | if(!_pppdata->automatic_redial()) { | 462 | if(!_pppdata->automatic_redial()) { |
463 | quit_b->setFocus(); | 463 | quit_b->setFocus(); |
464 | show(); | 464 | show(); |
465 | con_win->stopClock(); | 465 | con_win->stopClock(); |
466 | //stopAccounting(); | 466 | //stopAccounting(); |
467 | con_win->hide(); | 467 | con_win->hide(); |
468 | con->hide(); | 468 | con->hide(); |
469 | 469 | ||
470 | _pppdata->setpppdRunning(false); | 470 | _pppdata->setpppdRunning(false); |
471 | // // not in a signal handler !!! KNotifyClient::beep(); | 471 | // // not in a signal handler !!! KNotifyClient::beep(); |
472 | QString msg; | 472 | QString msg; |
473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " | 474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " |
475 | "to come up!"); | 475 | "to come up!"); |
476 | else { | 476 | else { |
477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); | 477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); |
478 | Modem::modem->pppdExitStatus(); | 478 | Modem::modem->pppdExitStatus(); |
479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " | 481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " |
482 | "codes or take a look at the kppp FAQ on " | 482 | "codes or take a look at the kppp FAQ on " |
483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) | 488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) |
489 | // // PPPL_ShowLog(); | 489 | // // PPPL_ShowLog(); |
490 | // } else { /* reconnect on disconnect */ | 490 | // } else { /* reconnect on disconnect */ |
491 | if (false){ | 491 | if (false){ |
492 | qDebug( "Trying to reconnect... " ); | 492 | odebug << "Trying to reconnect... " << oendl; |
493 | 493 | ||
494 | if(_pppdata->authMethod() == AUTH_PAP || | 494 | if(_pppdata->authMethod() == AUTH_PAP || |
495 | _pppdata->authMethod() == AUTH_CHAP || | 495 | _pppdata->authMethod() == AUTH_CHAP || |
496 | _pppdata->authMethod() == AUTH_PAPCHAP) | 496 | _pppdata->authMethod() == AUTH_PAPCHAP) |
497 | Modem::modem->setSecret(_pppdata->authMethod(), | 497 | Modem::modem->setSecret(_pppdata->authMethod(), |
498 | encodeWord(_pppdata->storedUsername()), | 498 | encodeWord(_pppdata->storedUsername()), |
499 | encodeWord(_pppdata->password())); | 499 | encodeWord(_pppdata->password())); |
500 | 500 | ||
501 | con_win->hide(); | 501 | con_win->hide(); |
502 | con_win->stopClock(); | 502 | con_win->stopClock(); |
503 | //stopAccounting(); | 503 | //stopAccounting(); |
504 | _pppdata->setpppdRunning(false); | 504 | _pppdata->setpppdRunning(false); |
505 | // not in a signal handler !!!KNotifyClient::beep(); | 505 | // not in a signal handler !!!KNotifyClient::beep(); |
506 | emit cmdl_start(); | 506 | emit cmdl_start(); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | _pppdata->setpppdError(0); | 509 | _pppdata->setpppdError(0); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | // void KPPPWidget::sigChld() { | 513 | // void KPPPWidget::sigChld() { |
514 | // qDebug( "sigchld()" ); | 514 | // odebug << "sigchld()" << oendl; |
515 | // // pid_t id = wait(0L); | 515 | // // pid_t id = wait(0L); |
516 | // // if(id == helperPid && helperPid != -1) { | 516 | // // if(id == helperPid && helperPid != -1) { |
517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
518 | // // helperPid = -1; | 518 | // // helperPid = -1; |
519 | // QString msg = QObject::tr("kppp's helper process just died.\n" | 519 | // QString msg = QObject::tr("kppp's helper process just died.\n" |
520 | // "Since a further execution would be pointless, " | 520 | // "Since a further execution would be pointless, " |
521 | // "kppp will shut down now."); | 521 | // "kppp will shut down now."); |
522 | // QMessageBox::warning(0L,"error", msg); | 522 | // QMessageBox::warning(0L,"error", msg); |
523 | // //remove_pidfile(); | 523 | // //remove_pidfile(); |
524 | // exit(1); | 524 | // exit(1); |
525 | // // } | 525 | // // } |
526 | // } | 526 | // } |
527 | 527 | ||
528 | 528 | ||
529 | void KPPPWidget::newdefaultaccount(int i) { | 529 | void KPPPWidget::newdefaultaccount(int i) { |
530 | _pppdata->setDefaultAccount(connectto_c->text(i)); | 530 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
531 | _pppdata->save(); | 531 | _pppdata->save(); |
532 | ID_Edit->setText(_pppdata->storedUsername()); | 532 | ID_Edit->setText(_pppdata->storedUsername()); |
533 | PW_Edit->setText(_pppdata->storedPassword()); | 533 | PW_Edit->setText(_pppdata->storedPassword()); |
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | 537 | ||
538 | 538 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 3dbc8c3..f3f2639 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -34,49 +34,49 @@ | |||
34 | #include <sys/stat.h> | 34 | #include <sys/stat.h> |
35 | #include <setjmp.h> | 35 | #include <setjmp.h> |
36 | #include <regex.h> | 36 | #include <regex.h> |
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include <assert.h> | 38 | #include <assert.h> |
39 | #include <string.h> | 39 | #include <string.h> |
40 | 40 | ||
41 | #ifdef HAVE_RESOLV_H | 41 | #ifdef HAVE_RESOLV_H |
42 | # include <arpa/nameser.h> | 42 | # include <arpa/nameser.h> |
43 | # include <resolv.h> | 43 | # include <resolv.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifndef _PATH_RESCONF | 46 | #ifndef _PATH_RESCONF |
47 | #define _PATH_RESCONF "/etc/resolv.conf" | 47 | #define _PATH_RESCONF "/etc/resolv.conf" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #define strlcpy strcpy | 50 | #define strlcpy strcpy |
51 | #include "auth.h" | 51 | #include "auth.h" |
52 | #include "modem.h" | 52 | #include "modem.h" |
53 | #include "pppdata.h" | 53 | #include "pppdata.h" |
54 | #define qError qDebug | 54 | #define qError qDebug |
55 | 55 | ||
56 | 56 | ||
57 | #define MY_ASSERT(x) if (!(x)) { \ | 57 | #define MY_ASSERT(x) if (!(x)) { \ |
58 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 58 | ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ |
59 | exit(1); } | 59 | exit(1); } |
60 | 60 | ||
61 | 61 | ||
62 | static sigjmp_buf jmp_buffer; | 62 | static sigjmp_buf jmp_buffer; |
63 | 63 | ||
64 | //Modem *Modem::modem = 0; | 64 | //Modem *Modem::modem = 0; |
65 | 65 | ||
66 | 66 | ||
67 | const char* pppdPath() { | 67 | const char* pppdPath() { |
68 | // wasting a few bytes | 68 | // wasting a few bytes |
69 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 69 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
70 | static char *pppdPath = 0L; | 70 | static char *pppdPath = 0L; |
71 | char *p; | 71 | char *p; |
72 | 72 | ||
73 | if(pppdPath == 0L) { | 73 | if(pppdPath == 0L) { |
74 | const char *c = PPPDSEARCHPATH; | 74 | const char *c = PPPDSEARCHPATH; |
75 | while(*c != '\0') { | 75 | while(*c != '\0') { |
76 | while(*c == ':') | 76 | while(*c == ':') |
77 | c++; | 77 | c++; |
78 | p = buffer; | 78 | p = buffer; |
79 | while(*c != '\0' && *c != ':') | 79 | while(*c != '\0' && *c != ':') |
80 | *p++ = *c++; | 80 | *p++ = *c++; |
81 | *p = '\0'; | 81 | *p = '\0'; |
82 | strcat(p, "/"); | 82 | strcat(p, "/"); |
@@ -144,49 +144,49 @@ speed_t Modem::modemspeed() { | |||
144 | case 2304: | 144 | case 2304: |
145 | return B230400; | 145 | return B230400; |
146 | break; | 146 | break; |
147 | #endif | 147 | #endif |
148 | 148 | ||
149 | #ifdef B460800 | 149 | #ifdef B460800 |
150 | case 4608: | 150 | case 4608: |
151 | return B460800; | 151 | return B460800; |
152 | break; | 152 | break; |
153 | #endif | 153 | #endif |
154 | 154 | ||
155 | default: | 155 | default: |
156 | return B38400; | 156 | return B38400; |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | bool Modem::opentty() { | 161 | bool Modem::opentty() { |
162 | // int flags; | 162 | // int flags; |
163 | 163 | ||
164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
165 | close(modemfd); | 165 | close(modemfd); |
166 | device = _pppdata->modemDevice(); | 166 | device = _pppdata->modemDevice(); |
167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
168 | qDebug("error opening modem device !"); | 168 | odebug << "error opening modem device !" << oendl; |
169 | errmsg = QObject::tr("Unable to open modem."); | 169 | errmsg = QObject::tr("Unable to open modem."); |
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
173 | //} | 173 | //} |
174 | 174 | ||
175 | #if 0 | 175 | #if 0 |
176 | if(_pppdata->UseCDLine()) { | 176 | if(_pppdata->UseCDLine()) { |
177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
178 | errmsg = QObject::tr("Unable to detect state of CD line."); | 178 | errmsg = QObject::tr("Unable to detect state of CD line."); |
179 | ::close(modemfd); | 179 | ::close(modemfd); |
180 | modemfd = -1; | 180 | modemfd = -1; |
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | if ((flags&TIOCM_CD) == 0) { | 183 | if ((flags&TIOCM_CD) == 0) { |
184 | errmsg = QObject::tr("The modem is not ready."); | 184 | errmsg = QObject::tr("The modem is not ready."); |
185 | ::close(modemfd); | 185 | ::close(modemfd); |
186 | modemfd = -1; | 186 | modemfd = -1; |
187 | return false; | 187 | return false; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | tcdrain (modemfd); | 192 | tcdrain (modemfd); |
@@ -285,108 +285,108 @@ void Modem::readtty(int) { | |||
285 | c = buffer[i] & 0x7F; | 285 | c = buffer[i] & 0x7F; |
286 | emit charWaiting(c); | 286 | emit charWaiting(c); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | 291 | ||
292 | void Modem::notify(const QObject *receiver, const char *member) { | 292 | void Modem::notify(const QObject *receiver, const char *member) { |
293 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | 293 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); |
294 | startNotifier(); | 294 | startNotifier(); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void Modem::stop() { | 298 | void Modem::stop() { |
299 | disconnect(SIGNAL(charWaiting(unsigned char))); | 299 | disconnect(SIGNAL(charWaiting(unsigned char))); |
300 | stopNotifier(); | 300 | stopNotifier(); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void Modem::startNotifier() { | 304 | void Modem::startNotifier() { |
305 | if(modemfd >= 0) { | 305 | if(modemfd >= 0) { |
306 | if(sn == 0) { | 306 | if(sn == 0) { |
307 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 307 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
308 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 308 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
309 | qDebug("QSocketNotifier started!"); | 309 | odebug << "QSocketNotifier started!" << oendl; |
310 | } else { | 310 | } else { |
311 | qDebug("QSocketNotifier re-enabled!"); | 311 | odebug << "QSocketNotifier re-enabled!" << oendl; |
312 | sn->setEnabled(true); | 312 | sn->setEnabled(true); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void Modem::stopNotifier() { | 318 | void Modem::stopNotifier() { |
319 | if(sn != 0) { | 319 | if(sn != 0) { |
320 | sn->setEnabled(false); | 320 | sn->setEnabled(false); |
321 | disconnect(sn); | 321 | disconnect(sn); |
322 | delete sn; | 322 | delete sn; |
323 | sn = 0; | 323 | sn = 0; |
324 | qDebug( "QSocketNotifier stopped!" ); | 324 | odebug << "QSocketNotifier stopped!" << oendl; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void Modem::flush() { | 329 | void Modem::flush() { |
330 | char c; | 330 | char c; |
331 | while(read(modemfd, &c, 1) == 1); | 331 | while(read(modemfd, &c, 1) == 1); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | bool Modem::writeChar(unsigned char c) { | 335 | bool Modem::writeChar(unsigned char c) { |
336 | int s; | 336 | int s; |
337 | do { | 337 | do { |
338 | s = write(modemfd, &c, 1); | 338 | s = write(modemfd, &c, 1); |
339 | if (s < 0) { | 339 | if (s < 0) { |
340 | qError( "write() in Modem::writeChar failed" ); | 340 | oerr << "write() in Modem::writeChar failed" << oendl; |
341 | return false; | 341 | return false; |
342 | } | 342 | } |
343 | } while(s == 0); | 343 | } while(s == 0); |
344 | 344 | ||
345 | return true; | 345 | return true; |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | bool Modem::writeLine(const char *buf) { | 349 | bool Modem::writeLine(const char *buf) { |
350 | int len = strlen(buf); | 350 | int len = strlen(buf); |
351 | char *b = new char[len+2]; | 351 | char *b = new char[len+2]; |
352 | memcpy(b, buf, len); | 352 | memcpy(b, buf, len); |
353 | // different modems seem to need different line terminations | 353 | // different modems seem to need different line terminations |
354 | QString term = _pppdata->enter(); | 354 | QString term = _pppdata->enter(); |
355 | if(term == "LF") | 355 | if(term == "LF") |
356 | b[len++]='\n'; | 356 | b[len++]='\n'; |
357 | else if(term == "CR") | 357 | else if(term == "CR") |
358 | b[len++]='\r'; | 358 | b[len++]='\r'; |
359 | else if(term == "CR/LF") { | 359 | else if(term == "CR/LF") { |
360 | b[len++]='\r'; | 360 | b[len++]='\r'; |
361 | b[len++]='\n'; | 361 | b[len++]='\n'; |
362 | } | 362 | } |
363 | int l = len; | 363 | int l = len; |
364 | while(l) { | 364 | while(l) { |
365 | int wr = write(modemfd, &b[len-l], l); | 365 | int wr = write(modemfd, &b[len-l], l); |
366 | if(wr < 0) { | 366 | if(wr < 0) { |
367 | // TODO do something meaningful with the error code (or ignore it | 367 | // TODO do something meaningful with the error code (or ignore it |
368 | qError( "write() in Modem::writeLine failed" ); | 368 | oerr << "write() in Modem::writeLine failed" << oendl; |
369 | delete[] b; | 369 | delete[] b; |
370 | return false; | 370 | return false; |
371 | } | 371 | } |
372 | l -= wr; | 372 | l -= wr; |
373 | } | 373 | } |
374 | delete[] b; | 374 | delete[] b; |
375 | return true; | 375 | return true; |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | bool Modem::hangup() { | 379 | bool Modem::hangup() { |
380 | // this should really get the modem to hang up and go into command mode | 380 | // this should really get the modem to hang up and go into command mode |
381 | // If anyone sees a fault in the following please let me know, since | 381 | // If anyone sees a fault in the following please let me know, since |
382 | // this is probably the most imporant snippet of code in the whole of | 382 | // this is probably the most imporant snippet of code in the whole of |
383 | // kppp. If people complain about kppp being stuck, this piece of code | 383 | // kppp. If people complain about kppp being stuck, this piece of code |
384 | // is most likely the reason. | 384 | // is most likely the reason. |
385 | struct termios temptty; | 385 | struct termios temptty; |
386 | 386 | ||
387 | if(modemfd >= 0) { | 387 | if(modemfd >= 0) { |
388 | 388 | ||
389 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 389 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
390 | 390 | ||
391 | if (data_mode) escape_to_command_mode(); | 391 | if (data_mode) escape_to_command_mode(); |
392 | 392 | ||
@@ -453,49 +453,49 @@ void Modem::escape_to_command_mode() { | |||
453 | 453 | ||
454 | // +3 because quiet time must be greater than guard time. | 454 | // +3 because quiet time must be greater than guard time. |
455 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 455 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
456 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); | 456 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); |
457 | write(modemfd, tmp.data(), tmp.length()); | 457 | write(modemfd, tmp.data(), tmp.length()); |
458 | tcflush(modemfd, TCIOFLUSH); | 458 | tcflush(modemfd, TCIOFLUSH); |
459 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 459 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
460 | 460 | ||
461 | data_mode = false; | 461 | data_mode = false; |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | const QString Modem::modemMessage() { | 465 | const QString Modem::modemMessage() { |
466 | return errmsg; | 466 | return errmsg; |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | QString Modem::parseModemSpeed(const QString &s) { | 470 | QString Modem::parseModemSpeed(const QString &s) { |
471 | // this is a small (and bad) parser for modem speeds | 471 | // this is a small (and bad) parser for modem speeds |
472 | int rx = -1; | 472 | int rx = -1; |
473 | int tx = -1; | 473 | int tx = -1; |
474 | int i; | 474 | int i; |
475 | QString result; | 475 | QString result; |
476 | 476 | ||
477 | qDebug( "Modem reported result string: %s", s.latin1()); | 477 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; |
478 | 478 | ||
479 | const int RXMAX = 7; | 479 | const int RXMAX = 7; |
480 | const int TXMAX = 2; | 480 | const int TXMAX = 2; |
481 | QRegExp rrx[RXMAX] = { | 481 | QRegExp rrx[RXMAX] = { |
482 | QRegExp("[0-9]+[:/ ]RX", false), | 482 | QRegExp("[0-9]+[:/ ]RX", false), |
483 | QRegExp("[0-9]+RX", false), | 483 | QRegExp("[0-9]+RX", false), |
484 | QRegExp("[/: -][0-9]+[/: ]", false), | 484 | QRegExp("[/: -][0-9]+[/: ]", false), |
485 | QRegExp("[/: -][0-9]+$", false), | 485 | QRegExp("[/: -][0-9]+$", false), |
486 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 486 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
487 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 487 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
488 | QRegExp("[0-9]+") // panic mode | 488 | QRegExp("[0-9]+") // panic mode |
489 | }; | 489 | }; |
490 | 490 | ||
491 | QRegExp trx[TXMAX] = { | 491 | QRegExp trx[TXMAX] = { |
492 | QRegExp("[0-9]+[:/ ]TX", false), | 492 | QRegExp("[0-9]+[:/ ]TX", false), |
493 | QRegExp("[0-9]+TX", false) | 493 | QRegExp("[0-9]+TX", false) |
494 | }; | 494 | }; |
495 | 495 | ||
496 | for(i = 0; i < RXMAX; i++) { | 496 | for(i = 0; i < RXMAX; i++) { |
497 | int len, idx, result; | 497 | int len, idx, result; |
498 | if((idx = rrx[i].match(s,0,&len)) > -1) { | 498 | if((idx = rrx[i].match(s,0,&len)) > -1) { |
499 | // if((idx = rrx[i].search(s)) > -1) { | 499 | // if((idx = rrx[i].search(s)) > -1) { |
500 | // len = rrx[i].matchedLength(); | 500 | // len = rrx[i].matchedLength(); |
501 | 501 | ||
@@ -539,155 +539,155 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
539 | // be converted to an int. | 539 | // be converted to an int. |
540 | // | 540 | // |
541 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { | 541 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { |
542 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { | 542 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { |
543 | // len = rrx[RXMAX-1].matchedLength(); | 543 | // len = rrx[RXMAX-1].matchedLength(); |
544 | sub = sub.mid(idx, len); | 544 | sub = sub.mid(idx, len); |
545 | result = sub.toInt(); | 545 | result = sub.toInt(); |
546 | if(result > 0) { | 546 | if(result > 0) { |
547 | tx = result; | 547 | tx = result; |
548 | break; | 548 | break; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | } | 551 | } |
552 | } | 552 | } |
553 | 553 | ||
554 | if(rx == -1 && tx == -1) | 554 | if(rx == -1 && tx == -1) |
555 | result = QObject::tr("Unknown speed"); | 555 | result = QObject::tr("Unknown speed"); |
556 | else if(tx == -1) | 556 | else if(tx == -1) |
557 | result.setNum(rx); | 557 | result.setNum(rx); |
558 | else if(rx == -1) // should not happen | 558 | else if(rx == -1) // should not happen |
559 | result.setNum(tx); | 559 | result.setNum(tx); |
560 | else | 560 | else |
561 | result.sprintf("%d/%d", rx, tx); | 561 | result.sprintf("%d/%d", rx, tx); |
562 | 562 | ||
563 | qDebug( "The parsed result is: %s", result.latin1()); | 563 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; |
564 | 564 | ||
565 | return result; | 565 | return result; |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 569 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
570 | // a lock file can't be created ( permission problem ) | 570 | // a lock file can't be created ( permission problem ) |
571 | int Modem::lockdevice() { | 571 | int Modem::lockdevice() { |
572 | int fd; | 572 | int fd; |
573 | char newlock[80]=""; // safe | 573 | char newlock[80]=""; // safe |
574 | 574 | ||
575 | if(!_pppdata->modemLockFile()) { | 575 | if(!_pppdata->modemLockFile()) { |
576 | qDebug("The user doesn't want a lockfile."); | 576 | odebug << "The user doesn't want a lockfile." << oendl; |
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | 579 | ||
580 | if (modem_is_locked) | 580 | if (modem_is_locked) |
581 | return 1; | 581 | return 1; |
582 | 582 | ||
583 | QString lockfile = LOCK_DIR"/LCK.."; | 583 | QString lockfile = LOCK_DIR"/LCK.."; |
584 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ | 584 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
585 | 585 | ||
586 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 586 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
587 | // if ((fd = Requester::rq-> | 587 | // if ((fd = Requester::rq-> |
588 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 588 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
589 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 589 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
590 | // file has more than 32 bytes, skip the rest | 590 | // file has more than 32 bytes, skip the rest |
591 | char oldlock[33]; // safe | 591 | char oldlock[33]; // safe |
592 | int sz = read(fd, &oldlock, 32); | 592 | int sz = read(fd, &oldlock, 32); |
593 | close (fd); | 593 | close (fd); |
594 | if (sz <= 0) | 594 | if (sz <= 0) |
595 | return 1; | 595 | return 1; |
596 | oldlock[sz] = '\0'; | 596 | oldlock[sz] = '\0'; |
597 | 597 | ||
598 | qDebug( "Device is locked by: %s", oldlock); | 598 | odebug << "Device is locked by: " << oldlock << "" << oendl; |
599 | 599 | ||
600 | int oldpid; | 600 | int oldpid; |
601 | int match = sscanf(oldlock, "%d", &oldpid); | 601 | int match = sscanf(oldlock, "%d", &oldpid); |
602 | 602 | ||
603 | // found a pid in lockfile ? | 603 | // found a pid in lockfile ? |
604 | if (match < 1 || oldpid <= 0) | 604 | if (match < 1 || oldpid <= 0) |
605 | return 1; | 605 | return 1; |
606 | 606 | ||
607 | // check if process exists | 607 | // check if process exists |
608 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 608 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
609 | return 1; | 609 | return 1; |
610 | 610 | ||
611 | qDebug( "lockfile is stale" ); | 611 | odebug << "lockfile is stale" << oendl; |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 615 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
616 | if(fd >= 0) { | 616 | if(fd >= 0) { |
617 | sprintf(newlock,"%010d\n", getpid()); | 617 | sprintf(newlock,"%010d\n", getpid()); |
618 | qDebug("Locking Device: %s", newlock); | 618 | odebug << "Locking Device: " << newlock << "" << oendl; |
619 | 619 | ||
620 | write(fd, newlock, strlen(newlock)); | 620 | write(fd, newlock, strlen(newlock)); |
621 | close(fd); | 621 | close(fd); |
622 | modem_is_locked=true; | 622 | modem_is_locked=true; |
623 | 623 | ||
624 | return 0; | 624 | return 0; |
625 | } | 625 | } |
626 | 626 | ||
627 | return -1; | 627 | return -1; |
628 | 628 | ||
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | // UnLock modem device | 632 | // UnLock modem device |
633 | void Modem::unlockdevice() { | 633 | void Modem::unlockdevice() { |
634 | if (modem_is_locked) { | 634 | if (modem_is_locked) { |
635 | qDebug( "UnLocking Modem Device" ); | 635 | odebug << "UnLocking Modem Device" << oendl; |
636 | close(modemfd); | 636 | close(modemfd); |
637 | modemfd = -1; | 637 | modemfd = -1; |
638 | unlink(lockfile); | 638 | unlink(lockfile); |
639 | lockfile[0] = '\0'; | 639 | lockfile[0] = '\0'; |
640 | modem_is_locked=false; | 640 | modem_is_locked=false; |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | int Modem::openLockfile( QString lockfile, int flags) | 644 | int Modem::openLockfile( QString lockfile, int flags) |
645 | { | 645 | { |
646 | int fd; | 646 | int fd; |
647 | int mode; | 647 | int mode; |
648 | flags = O_RDONLY; | 648 | flags = O_RDONLY; |
649 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 649 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
650 | mode = 0644; | 650 | mode = 0644; |
651 | else | 651 | else |
652 | mode = 0; | 652 | mode = 0; |
653 | 653 | ||
654 | lockfile = LOCK_DIR; | 654 | lockfile = LOCK_DIR; |
655 | lockfile += "/LCK.."; | 655 | lockfile += "/LCK.."; |
656 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 656 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
657 | qDebug("lockfile >%s<",lockfile.latin1()); | 657 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; |
658 | // TODO: | 658 | // TODO: |
659 | // struct stat st; | 659 | // struct stat st; |
660 | // if(stat(lockfile.data(), &st) == -1) { | 660 | // if(stat(lockfile.data(), &st) == -1) { |
661 | // if(errno == EBADF) | 661 | // if(errno == EBADF) |
662 | // return -1; | 662 | // return -1; |
663 | // } else { | 663 | // } else { |
664 | // // make sure that this is a regular file | 664 | // // make sure that this is a regular file |
665 | // if(!S_ISREG(st.st_mode)) | 665 | // if(!S_ISREG(st.st_mode)) |
666 | // return -1; | 666 | // return -1; |
667 | // } | 667 | // } |
668 | if ((fd = open(lockfile, flags, mode)) == -1) { | 668 | if ((fd = open(lockfile, flags, mode)) == -1) { |
669 | qDebug("error opening lockfile!"); | 669 | odebug << "error opening lockfile!" << oendl; |
670 | lockfile = QString::null; | 670 | lockfile = QString::null; |
671 | fd = open(DEVNULL, O_RDONLY); | 671 | fd = open(DEVNULL, O_RDONLY); |
672 | } else | 672 | } else |
673 | fchown(fd, 0, 0); | 673 | fchown(fd, 0, 0); |
674 | return fd; | 674 | return fd; |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | 678 | ||
679 | void alarm_handler(int) { | 679 | void alarm_handler(int) { |
680 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 680 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
681 | 681 | ||
682 | // jump | 682 | // jump |
683 | siglongjmp(jmp_buffer, 1); | 683 | siglongjmp(jmp_buffer, 1); |
684 | } | 684 | } |
685 | 685 | ||
686 | 686 | ||
687 | const char* Modem::authFile(Auth method, int version) { | 687 | const char* Modem::authFile(Auth method, int version) { |
688 | switch(method|version) { | 688 | switch(method|version) { |
689 | case PAP|Original: | 689 | case PAP|Original: |
690 | return PAP_AUTH_FILE; | 690 | return PAP_AUTH_FILE; |
691 | break; | 691 | break; |
692 | case PAP|New: | 692 | case PAP|New: |
693 | return PAP_AUTH_FILE".new"; | 693 | return PAP_AUTH_FILE".new"; |
@@ -906,84 +906,84 @@ bool Modem::execpppd(const char *arguments) { | |||
906 | ::close( m_pppdLOG[0] ); | 906 | ::close( m_pppdLOG[0] ); |
907 | ::setenv( "LANG", "C", 1 ); // overwrite | 907 | ::setenv( "LANG", "C", 1 ); // overwrite |
908 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 | 908 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 |
909 | dup2(modemfd, 0); | 909 | dup2(modemfd, 0); |
910 | dup2(modemfd, 1); | 910 | dup2(modemfd, 1); |
911 | 911 | ||
912 | 912 | ||
913 | switch (checkForInterface()) { | 913 | switch (checkForInterface()) { |
914 | case 1: | 914 | case 1: |
915 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | 915 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); |
916 | break; | 916 | break; |
917 | case -1: | 917 | case -1: |
918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
919 | break; | 919 | break; |
920 | case 0: | 920 | case 0: |
921 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 921 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
922 | break; | 922 | break; |
923 | } | 923 | } |
924 | 924 | ||
925 | execve(pppdPath(), args, 0L); | 925 | execve(pppdPath(), args, 0L); |
926 | _exit(0); | 926 | _exit(0); |
927 | break; | 927 | break; |
928 | 928 | ||
929 | default: | 929 | default: |
930 | qDebug("In parent: pppd pid %d\n",pppdPid); | 930 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; |
931 | close(modemfd); | 931 | close(modemfd); |
932 | 932 | ||
933 | ::close( m_pppdLOG[1] ); | 933 | ::close( m_pppdLOG[1] ); |
934 | // set it to nonblocking io | 934 | // set it to nonblocking io |
935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | 935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); |
936 | 936 | ||
937 | if ( !(flag & O_NONBLOCK) ) { | 937 | if ( !(flag & O_NONBLOCK) ) { |
938 | qDebug("Setting nonblocking io"); | 938 | odebug << "Setting nonblocking io" << oendl; |
939 | flag |= O_NONBLOCK; | 939 | flag |= O_NONBLOCK; |
940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | 940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); |
941 | } | 941 | } |
942 | 942 | ||
943 | delete m_modemDebug; | 943 | delete m_modemDebug; |
944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | 944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); |
945 | connect(m_modemDebug, SIGNAL(activated(int) ), | 945 | connect(m_modemDebug, SIGNAL(activated(int) ), |
946 | this, SLOT(slotModemDebug(int) ) ); | 946 | this, SLOT(slotModemDebug(int) ) ); |
947 | 947 | ||
948 | modemfd = -1; | 948 | modemfd = -1; |
949 | m_pppdDev = QString::fromLatin1("ppp0"); | 949 | m_pppdDev = QString::fromLatin1("ppp0"); |
950 | return true; | 950 | return true; |
951 | break; | 951 | break; |
952 | } | 952 | } |
953 | } | 953 | } |
954 | 954 | ||
955 | 955 | ||
956 | bool Modem::killpppd() { | 956 | bool Modem::killpppd() { |
957 | qDebug("In killpppd and pid is %d", pppdPid ); | 957 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; |
958 | if(pppdPid > 0) { | 958 | if(pppdPid > 0) { |
959 | delete m_modemDebug; | 959 | delete m_modemDebug; |
960 | m_modemDebug = 0; | 960 | m_modemDebug = 0; |
961 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | 961 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; |
962 | if(kill(pppdPid, SIGTERM) < 0) { | 962 | if(kill(pppdPid, SIGTERM) < 0) { |
963 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | 963 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; |
964 | if(kill(pppdPid, SIGKILL) < 0) { | 964 | if(kill(pppdPid, SIGKILL) < 0) { |
965 | qDebug("Error killing %d\n", pppdPid); | 965 | odebug << "Error killing " << pppdPid << "\n" << oendl; |
966 | return false; | 966 | return false; |
967 | } | 967 | } |
968 | } | 968 | } |
969 | } | 969 | } |
970 | return true; | 970 | return true; |
971 | } | 971 | } |
972 | 972 | ||
973 | 973 | ||
974 | void Modem::parseargs(char* buf, char** args) { | 974 | void Modem::parseargs(char* buf, char** args) { |
975 | int nargs = 0; | 975 | int nargs = 0; |
976 | int quotes; | 976 | int quotes; |
977 | 977 | ||
978 | while(nargs < MaxArgs-1 && *buf != '\0') { | 978 | while(nargs < MaxArgs-1 && *buf != '\0') { |
979 | 979 | ||
980 | quotes = 0; | 980 | quotes = 0; |
981 | 981 | ||
982 | // Strip whitespace. Use nulls, so that the previous argument is | 982 | // Strip whitespace. Use nulls, so that the previous argument is |
983 | // terminated automatically. | 983 | // terminated automatically. |
984 | 984 | ||
985 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) | 985 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) |
986 | *buf++ = '\0'; | 986 | *buf++ = '\0'; |
987 | 987 | ||
988 | // detect begin of quoted argument | 988 | // detect begin of quoted argument |
989 | if (*buf == '"' || *buf == '\'') { | 989 | if (*buf == '"' || *buf == '\'') { |
@@ -1014,67 +1014,67 @@ void Modem::parseargs(char* buf, char** args) { | |||
1014 | bool Modem::execPPPDaemon(const QString & arguments) | 1014 | bool Modem::execPPPDaemon(const QString & arguments) |
1015 | { | 1015 | { |
1016 | if(execpppd(arguments)) { | 1016 | if(execpppd(arguments)) { |
1017 | _pppdata->setpppdRunning(true); | 1017 | _pppdata->setpppdRunning(true); |
1018 | return true; | 1018 | return true; |
1019 | } else | 1019 | } else |
1020 | return false; | 1020 | return false; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void Modem::killPPPDaemon() | 1023 | void Modem::killPPPDaemon() |
1024 | { | 1024 | { |
1025 | _pppdata->setpppdRunning(false); | 1025 | _pppdata->setpppdRunning(false); |
1026 | killpppd(); | 1026 | killpppd(); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | int Modem::pppdExitStatus() | 1029 | int Modem::pppdExitStatus() |
1030 | { | 1030 | { |
1031 | return _pppdExitStatus; | 1031 | return _pppdExitStatus; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | int Modem::openResolv(int flags) | 1034 | int Modem::openResolv(int flags) |
1035 | { | 1035 | { |
1036 | int fd; | 1036 | int fd; |
1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1038 | qDebug("error opening resolv.conf!"); | 1038 | odebug << "error opening resolv.conf!" << oendl; |
1039 | fd = open(DEVNULL, O_RDONLY); | 1039 | fd = open(DEVNULL, O_RDONLY); |
1040 | } | 1040 | } |
1041 | return fd; | 1041 | return fd; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | bool Modem::setHostname(const QString & name) | 1044 | bool Modem::setHostname(const QString & name) |
1045 | { | 1045 | { |
1046 | return sethostname(name, name.length()) == 0; | 1046 | return sethostname(name, name.length()) == 0; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | QString Modem::pppDevice()const { | 1049 | QString Modem::pppDevice()const { |
1050 | return m_pppdDev; | 1050 | return m_pppdDev; |
1051 | } | 1051 | } |
1052 | void Modem::setPPPDevice( const QString& dev ) { | 1052 | void Modem::setPPPDevice( const QString& dev ) { |
1053 | m_pppdDev = dev; | 1053 | m_pppdDev = dev; |
1054 | } | 1054 | } |
1055 | pid_t Modem::pppPID()const { | 1055 | pid_t Modem::pppPID()const { |
1056 | return pppdPid; | 1056 | return pppdPid; |
1057 | } | 1057 | } |
1058 | void Modem::setPPPDPid( pid_t pid ) { | 1058 | void Modem::setPPPDPid( pid_t pid ) { |
1059 | qDebug("Modem setting pid"); | 1059 | odebug << "Modem setting pid" << oendl; |
1060 | _pppdExitStatus = -1; | 1060 | _pppdExitStatus = -1; |
1061 | pppdPid = pid; | 1061 | pppdPid = pid; |
1062 | modemfd = -1; | 1062 | modemfd = -1; |
1063 | } | 1063 | } |
1064 | void Modem::slotModemDebug(int fd) { | 1064 | void Modem::slotModemDebug(int fd) { |
1065 | char buf[2049]; | 1065 | char buf[2049]; |
1066 | int len; | 1066 | int len; |
1067 | 1067 | ||
1068 | // read in pppd data look for Using interface | 1068 | // read in pppd data look for Using interface |
1069 | // then read the interface | 1069 | // then read the interface |
1070 | // we limit to 10 device now 0-9 | 1070 | // we limit to 10 device now 0-9 |
1071 | if((len = ::read(fd, buf, 2048)) > 0) { | 1071 | if((len = ::read(fd, buf, 2048)) > 0) { |
1072 | buf[len+1] = '\0'; | 1072 | buf[len+1] = '\0'; |
1073 | char *found; | 1073 | char *found; |
1074 | if ( (found = ::strstr(buf, "Using interface ") ) ) { | 1074 | if ( (found = ::strstr(buf, "Using interface ") ) ) { |
1075 | found += 16; | 1075 | found += 16; |
1076 | m_pppdDev = QString::fromLatin1(found, 5 ); | 1076 | m_pppdDev = QString::fromLatin1(found, 5 ); |
1077 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); | 1077 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index 97baf31..a8c99fd 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp | |||
@@ -4,72 +4,72 @@ | |||
4 | #include <qtabwidget.h> | 4 | #include <qtabwidget.h> |
5 | 5 | ||
6 | #include "accounts.h" | 6 | #include "accounts.h" |
7 | #include "devices.h" | 7 | #include "devices.h" |
8 | #include "general.h" | 8 | #include "general.h" |
9 | #include "interfaceppp.h" | 9 | #include "interfaceppp.h" |
10 | #include "modem.h" | 10 | #include "modem.h" |
11 | #include "pppconfig.h" | 11 | #include "pppconfig.h" |
12 | #include "pppdata.h" | 12 | #include "pppdata.h" |
13 | #include "runtests.h" | 13 | #include "runtests.h" |
14 | 14 | ||
15 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, | 15 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, |
16 | const char *name, | 16 | const char *name, |
17 | bool modal, WFlags fl ) | 17 | bool modal, WFlags fl ) |
18 | : QDialog(parent, name, modal, fl) | 18 | : QDialog(parent, name, modal, fl) |
19 | { | 19 | { |
20 | setCaption(tr("Configure Modem")); | 20 | setCaption(tr("Configure Modem")); |
21 | int result = runTests(); | 21 | int result = runTests(); |
22 | if(result == TEST_CRITICAL){ | 22 | if(result == TEST_CRITICAL){ |
23 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); | 23 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); |
24 | return; | 24 | return; |
25 | } | 25 | } |
26 | 26 | ||
27 | interface = iface; | 27 | interface = iface; |
28 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 28 | odebug << "PPPConfigWidget::PPPConfigWidget" << oendl; |
29 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 29 | odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; |
30 | 30 | ||
31 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 31 | odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; |
32 | 32 | ||
33 | 33 | ||
34 | QVBoxLayout *layout = new QVBoxLayout( this ); | 34 | QVBoxLayout *layout = new QVBoxLayout( this ); |
35 | layout->setSpacing( 0 ); | 35 | layout->setSpacing( 0 ); |
36 | layout->setMargin( 1 ); | 36 | layout->setMargin( 1 ); |
37 | tabWindow = new QTabWidget( this, "tabWidget" ); | 37 | tabWindow = new QTabWidget( this, "tabWidget" ); |
38 | layout->addWidget( tabWindow ); | 38 | layout->addWidget( tabWindow ); |
39 | 39 | ||
40 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp ); | 40 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp ); |
41 | tabWindow->addTab( accounts, tr("&Accounts") ); | 41 | tabWindow->addTab( accounts, tr("&Accounts") ); |
42 | devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); | 42 | devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); |
43 | tabWindow->addTab( devices, tr("&Devices") ); | 43 | tabWindow->addTab( devices, tr("&Devices") ); |
44 | 44 | ||
45 | //OLD: | 45 | //OLD: |
46 | // modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | 46 | // modem1 = new ModemWidget( interface, tabWindow, "modem1" ); |
47 | // tabWindow->addTab( modem1, tr("&Device") ); | 47 | // tabWindow->addTab( modem1, tr("&Device") ); |
48 | // modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | 48 | // modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); |
49 | // tabWindow->addTab( modem2, tr("&Modem") ); | 49 | // tabWindow->addTab( modem2, tr("&Modem") ); |
50 | 50 | ||
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | PPPConfigWidget::~PPPConfigWidget() | 54 | PPPConfigWidget::~PPPConfigWidget() |
55 | { | 55 | { |
56 | 56 | ||
57 | } | 57 | } |
58 | 58 | ||
59 | void PPPConfigWidget::accept() | 59 | void PPPConfigWidget::accept() |
60 | { | 60 | { |
61 | qDebug("PPPConfigWidget::accept"); | 61 | odebug << "PPPConfigWidget::accept" << oendl; |
62 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 62 | odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; |
63 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 63 | odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; |
64 | interface->setInterfaceName( interface->data()->devname() ); | 64 | interface->setInterfaceName( interface->data()->devname() ); |
65 | interface->setHardwareName( interface->data()->accname() ); | 65 | interface->setHardwareName( interface->data()->accname() ); |
66 | interface->save(); | 66 | interface->save(); |
67 | QDialog::accept(); | 67 | QDialog::accept(); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | void PPPConfigWidget::reject() | 71 | void PPPConfigWidget::reject() |
72 | { | 72 | { |
73 | interface->data()->cancel(); | 73 | interface->data()->cancel(); |
74 | QDialog::reject(); | 74 | QDialog::reject(); |
75 | } | 75 | } |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index f4727c1..567ccf8 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -35,135 +35,135 @@ | |||
35 | // #include <kconfig.h> | 35 | // #include <kconfig.h> |
36 | // #include <kmessagebox.h> | 36 | // #include <kmessagebox.h> |
37 | // #include <kapplication.h> | 37 | // #include <kapplication.h> |
38 | #include <assert.h> | 38 | #include <assert.h> |
39 | 39 | ||
40 | #define SEPARATOR -sseepp- | 40 | #define SEPARATOR -sseepp- |
41 | #define SEP QString("%1SEPARATOR%1") | 41 | #define SEP QString("%1SEPARATOR%1") |
42 | 42 | ||
43 | PPPData::PPPData() | 43 | PPPData::PPPData() |
44 | : passwd(""), | 44 | : passwd(""), |
45 | _modemName(""), | 45 | _modemName(""), |
46 | highcount(-1), // start out with no entries | 46 | highcount(-1), // start out with no entries |
47 | highcountdev(-1), // start out with no entries | 47 | highcountdev(-1), // start out with no entries |
48 | // caccount(-1), // set the current account index also | 48 | // caccount(-1), // set the current account index also |
49 | suidprocessid(-1), // process ID of setuid child | 49 | suidprocessid(-1), // process ID of setuid child |
50 | pppdisrunning(false), | 50 | pppdisrunning(false), |
51 | pppderror(0) | 51 | pppderror(0) |
52 | { | 52 | { |
53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
54 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; | 54 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; |
55 | Config cfg = config(); | 55 | Config cfg = config(); |
56 | cfg.setGroup(GENERAL_GRP); | 56 | cfg.setGroup(GENERAL_GRP); |
57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); | 57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); |
58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); | 58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); |
59 | qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1()); | 59 | odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl; |
60 | qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1()); | 60 | odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl; |
61 | 61 | ||
62 | // if (highcount > MAX_ACCOUNTS) | 62 | // if (highcount > MAX_ACCOUNTS) |
63 | // highcount = MAX_ACCOUNTS; | 63 | // highcount = MAX_ACCOUNTS; |
64 | 64 | ||
65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { | 65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { |
66 | // setAccountbyIndex(0); | 66 | // setAccountbyIndex(0); |
67 | // setDefaultAccount(accname()); | 67 | // setDefaultAccount(accname()); |
68 | // } else if(!setAccount(defaultAccount())) | 68 | // } else if(!setAccount(defaultAccount())) |
69 | setDefaultAccount(accname()); | 69 | setDefaultAccount(accname()); |
70 | 70 | ||
71 | // start out with internal debugging disabled | 71 | // start out with internal debugging disabled |
72 | // the user is still free to specify `debug' on his own | 72 | // the user is still free to specify `debug' on his own |
73 | setPPPDebug(false); | 73 | setPPPDebug(false); |
74 | 74 | ||
75 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 75 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | Config PPPData::config() | 79 | Config PPPData::config() |
80 | { | 80 | { |
81 | return Config("NetworkSetupPPP"); | 81 | return Config("NetworkSetupPPP"); |
82 | } | 82 | } |
83 | 83 | ||
84 | // | 84 | // |
85 | // save configuration | 85 | // save configuration |
86 | // | 86 | // |
87 | void PPPData::save() | 87 | void PPPData::save() |
88 | { | 88 | { |
89 | qDebug("PPPData saving data"); | 89 | odebug << "PPPData saving data" << oendl; |
90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); | 91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); |
92 | QString key; | 92 | QString key; |
93 | QStringList keys; | 93 | QStringList keys; |
94 | Config cfg = config(); | 94 | Config cfg = config(); |
95 | cfg.setGroup(GENERAL_GRP); | 95 | cfg.setGroup(GENERAL_GRP); |
96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); | 96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); |
97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); | 97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); |
98 | 98 | ||
99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
100 | it != stringEntries.end(); ++it ){ | 100 | it != stringEntries.end(); ++it ){ |
101 | QString val = it.data(); | 101 | QString val = it.data(); |
102 | key = it.key(); | 102 | key = it.key(); |
103 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 103 | // odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl; |
104 | keys = QStringList::split( "SEPARATOR", key ); | 104 | keys = QStringList::split( "SEPARATOR", key ); |
105 | //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 105 | //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
106 | cfg.setGroup(keys[0]); | 106 | cfg.setGroup(keys[0]); |
107 | cfg.writeEntry(keys[1], val); | 107 | cfg.writeEntry(keys[1], val); |
108 | } | 108 | } |
109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
110 | it != intEntries.end(); ++it ){ | 110 | it != intEntries.end(); ++it ){ |
111 | int val = it.data(); | 111 | int val = it.data(); |
112 | key = it.key(); | 112 | key = it.key(); |
113 | // qDebug("saving %s -> %i", key.latin1(), val ); | 113 | // odebug << "saving " << key.latin1() << " -> " << val << "" << oendl; |
114 | keys = QStringList::split( "SEPARATOR", key ); | 114 | keys = QStringList::split( "SEPARATOR", key ); |
115 | //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 115 | //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl; |
116 | cfg.setGroup(keys[0]); | 116 | cfg.setGroup(keys[0]); |
117 | cfg.writeEntry(keys[1], val); | 117 | cfg.writeEntry(keys[1], val); |
118 | } | 118 | } |
119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
120 | it != listEntries.end(); ++it ){ | 120 | it != listEntries.end(); ++it ){ |
121 | QStringList val = it.data(); | 121 | QStringList val = it.data(); |
122 | key = it.key(); | 122 | key = it.key(); |
123 | QChar sep = sepEntries[key]; | 123 | QChar sep = sepEntries[key]; |
124 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 124 | // odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl; |
125 | keys = QStringList::split( "SEPARATOR", key ); | 125 | keys = QStringList::split( "SEPARATOR", key ); |
126 | cfg.setGroup(keys[0]); | 126 | cfg.setGroup(keys[0]); |
127 | cfg.writeEntry(keys[1], val, sep); | 127 | cfg.writeEntry(keys[1], val, sep); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | // | 132 | // |
133 | // cancel changes | 133 | // cancel changes |
134 | // | 134 | // |
135 | void PPPData::cancel() { | 135 | void PPPData::cancel() { |
136 | stringEntries.clear(); | 136 | stringEntries.clear(); |
137 | intEntries.clear(); | 137 | intEntries.clear(); |
138 | listEntries.clear(); | 138 | listEntries.clear(); |
139 | } | 139 | } |
140 | 140 | ||
141 | // functions to read/write date to configuration file | 141 | // functions to read/write date to configuration file |
142 | QString PPPData::readConfig(const QString &group, const QString &key, | 142 | QString PPPData::readConfig(const QString &group, const QString &key, |
143 | const QString &defvalue = "") | 143 | const QString &defvalue = "") |
144 | { | 144 | { |
145 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 145 | // odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl; |
146 | QString idx = SEP.arg(group).arg(key); | 146 | QString idx = SEP.arg(group).arg(key); |
147 | if (stringEntries.find(idx) != stringEntries.end()) | 147 | if (stringEntries.find(idx) != stringEntries.end()) |
148 | return stringEntries[idx]; | 148 | return stringEntries[idx]; |
149 | Config cfg = config(); | 149 | Config cfg = config(); |
150 | cfg.setGroup(group); | 150 | cfg.setGroup(group); |
151 | return cfg.readEntry(key, defvalue); | 151 | return cfg.readEntry(key, defvalue); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | int PPPData::readNumConfig(const QString &group, const QString &key, | 155 | int PPPData::readNumConfig(const QString &group, const QString &key, |
156 | int defvalue) | 156 | int defvalue) |
157 | { | 157 | { |
158 | QString idx = SEP.arg(group).arg(key); | 158 | QString idx = SEP.arg(group).arg(key); |
159 | if (intEntries.find(idx) != intEntries.end()) | 159 | if (intEntries.find(idx) != intEntries.end()) |
160 | return intEntries[idx]; | 160 | return intEntries[idx]; |
161 | Config cfg = config(); | 161 | Config cfg = config(); |
162 | cfg.setGroup(group); | 162 | cfg.setGroup(group); |
163 | return cfg.readNumEntry(key, defvalue); | 163 | return cfg.readNumEntry(key, defvalue); |
164 | 164 | ||
165 | // if (config) { | 165 | // if (config) { |
166 | // config->setGroup(group); | 166 | // config->setGroup(group); |
167 | // return config->readNumEntry(key, defvalue); | 167 | // return config->readNumEntry(key, defvalue); |
168 | // } else | 168 | // } else |
169 | // return defvalue; | 169 | // return defvalue; |
@@ -344,63 +344,63 @@ bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | |||
344 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 344 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
345 | } | 345 | } |
346 | 346 | ||
347 | int PPPData::pppdTimeout() { | 347 | int PPPData::pppdTimeout() { |
348 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 348 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void PPPData::setpppdTimeout(int n) { | 352 | void PPPData::setpppdTimeout(int n) { |
353 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 353 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | const QString PPPData::modemDevice() { | 357 | const QString PPPData::modemDevice() { |
358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); | 358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | // const QString PPPData::modemName() | 362 | // const QString PPPData::modemName() |
363 | // { | 363 | // { |
364 | // return readConfig(modemGroup(), MODEMNAME_KEY); | 364 | // return readConfig(modemGroup(), MODEMNAME_KEY); |
365 | // } | 365 | // } |
366 | 366 | ||
367 | // bool PPPData::setModemName(const QString &n) { | 367 | // bool PPPData::setModemName(const QString &n) { |
368 | // qDebug("Setting modem name to >%s<", n.latin1()); | 368 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
369 | // _modemName = n; | 369 | // _modemName = n; |
370 | // writeConfig(cgroup, MODEMNAME_KEY, n); | 370 | // writeConfig(cgroup, MODEMNAME_KEY, n); |
371 | // return true; //FIXME | 371 | // return true; //FIXME |
372 | // } | 372 | // } |
373 | 373 | ||
374 | // bool PPPData::changeModemName(const QString &n) { | 374 | // bool PPPData::changeModemName(const QString &n) { |
375 | // qDebug("Setting modem name to >%s<", n.latin1()); | 375 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
376 | // _modemName = n; | 376 | // _modemName = n; |
377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); | 377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); |
378 | // return true; //FIXME | 378 | // return true; //FIXME |
379 | // } | 379 | // } |
380 | 380 | ||
381 | bool PPPData::setModemDevice(const QString &n) { | 381 | bool PPPData::setModemDevice(const QString &n) { |
382 | qDebug("Setting modem dev to >%s<", n.latin1()); | 382 | odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; |
383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
384 | return true; //FIXME | 384 | return true; //FIXME |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | const QString PPPData::flowcontrol() { | 388 | const QString PPPData::flowcontrol() { |
389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void PPPData::setFlowcontrol(const QString &n) { | 393 | void PPPData::setFlowcontrol(const QString &n) { |
394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | const QString PPPData::speed() { | 398 | const QString PPPData::speed() { |
399 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 399 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
400 | // undo the damage of a bug in former versions. It left an empty Speed= | 400 | // undo the damage of a bug in former versions. It left an empty Speed= |
401 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 401 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
402 | // pppd wouldn't receive the speed via the command line. | 402 | // pppd wouldn't receive the speed via the command line. |
403 | if(s.toUInt() == 0) | 403 | if(s.toUInt() == 0) |
404 | s = "57600"; | 404 | s = "57600"; |
405 | return s; | 405 | return s; |
406 | } | 406 | } |
@@ -718,179 +718,179 @@ void PPPData::setModemAnswerResp(const QString &n) { | |||
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | const QString PPPData::enter() { | 721 | const QString PPPData::enter() { |
722 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 722 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
723 | } | 723 | } |
724 | 724 | ||
725 | 725 | ||
726 | void PPPData::setEnter(const QString &n) { | 726 | void PPPData::setEnter(const QString &n) { |
727 | writeConfig(modemGroup(), ENTER_KEY, n); | 727 | writeConfig(modemGroup(), ENTER_KEY, n); |
728 | } | 728 | } |
729 | 729 | ||
730 | 730 | ||
731 | // | 731 | // |
732 | // functions to set/return account information | 732 | // functions to set/return account information |
733 | // | 733 | // |
734 | 734 | ||
735 | //returns number of accounts | 735 | //returns number of accounts |
736 | int PPPData::count() const { | 736 | int PPPData::count() const { |
737 | return highcount + 1; | 737 | return highcount + 1; |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | bool PPPData::setAccount(const QString &aname) { | 741 | bool PPPData::setAccount(const QString &aname) { |
742 | qDebug("setting account to >%s<", aname.latin1()); | 742 | odebug << "setting account to >" << aname.latin1() << "<" << oendl; |
743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
744 | cgroup = *it; | 744 | cgroup = *it; |
745 | qDebug("PPPData::setAccount %s", cgroup.latin1()); | 745 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
746 | qDebug( "iterator %s", (*it).latin1() ); | 746 | odebug << "iterator " << (*it).latin1() << "" << oendl; |
747 | if(accname() == aname) { | 747 | if(accname() == aname) { |
748 | qDebug("SUCCESS"); | 748 | odebug << "SUCCESS" << oendl; |
749 | return true; | 749 | return true; |
750 | } | 750 | } |
751 | 751 | ||
752 | } | 752 | } |
753 | qDebug("FAILURE"); | 753 | odebug << "FAILURE" << oendl; |
754 | return false; | 754 | return false; |
755 | } | 755 | } |
756 | 756 | ||
757 | /* | 757 | /* |
758 | bool PPPData::setAccountbyIndex(int i) { | 758 | bool PPPData::setAccountbyIndex(int i) { |
759 | if(i >= 0 && i <= highcount) { | 759 | if(i >= 0 && i <= highcount) { |
760 | QString tmp; | 760 | QString tmp; |
761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); | 761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); |
762 | if (_deleted.find(tmp)!=_deleted.end()) return false; | 762 | if (_deleted.find(tmp)!=_deleted.end()) return false; |
763 | caccount = i; | 763 | caccount = i; |
764 | cgroup = tmp; | 764 | cgroup = tmp; |
765 | return true; | 765 | return true; |
766 | } | 766 | } |
767 | return false; | 767 | return false; |
768 | } | 768 | } |
769 | */ | 769 | */ |
770 | 770 | ||
771 | bool PPPData::isUniqueAccname(const QString &n) { | 771 | bool PPPData::isUniqueAccname(const QString &n) { |
772 | QString save_cgroup = cgroup; | 772 | QString save_cgroup = cgroup; |
773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
774 | cgroup = *it; | 774 | cgroup = *it; |
775 | qDebug("PPPData::setAccount %s", cgroup.latin1()); | 775 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
776 | qDebug( "%s \n", (*it).latin1() ); | 776 | odebug << "" << (*it).latin1() << " \n" << oendl; |
777 | if(accname() == n && cgroup != save_cgroup) { | 777 | if(accname() == n && cgroup != save_cgroup) { |
778 | cgroup = save_cgroup; | 778 | cgroup = save_cgroup; |
779 | qDebug("SUCCESS"); | 779 | odebug << "SUCCESS" << oendl; |
780 | return false; | 780 | return false; |
781 | } | 781 | } |
782 | 782 | ||
783 | } | 783 | } |
784 | cgroup = save_cgroup; | 784 | cgroup = save_cgroup; |
785 | return true; | 785 | return true; |
786 | } | 786 | } |
787 | 787 | ||
788 | 788 | ||
789 | bool PPPData::isUniqueDevname(const QString &n) { | 789 | bool PPPData::isUniqueDevname(const QString &n) { |
790 | QString save_mName = _modemName; | 790 | QString save_mName = _modemName; |
791 | qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1()); | 791 | odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; |
792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
793 | _modemName = *it; | 793 | _modemName = *it; |
794 | qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1()); | 794 | odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; |
795 | if(devname() == n && _modemName != save_mName) { | 795 | if(devname() == n && _modemName != save_mName) { |
796 | _modemName = save_mName; | 796 | _modemName = save_mName; |
797 | qDebug("NOT UNIQUE"); | 797 | odebug << "NOT UNIQUE" << oendl; |
798 | return false; | 798 | return false; |
799 | } | 799 | } |
800 | 800 | ||
801 | } | 801 | } |
802 | _modemName = save_mName; | 802 | _modemName = save_mName; |
803 | return true; | 803 | return true; |
804 | } | 804 | } |
805 | 805 | ||
806 | 806 | ||
807 | bool PPPData::deleteAccount() { | 807 | bool PPPData::deleteAccount() { |
808 | // FIXME: check if this account exists in a config... | 808 | // FIXME: check if this account exists in a config... |
809 | Config cfg = PPPData::config(); | 809 | Config cfg = PPPData::config(); |
810 | cfg.setGroup(cgroup); | 810 | cfg.setGroup(cgroup); |
811 | cfg.clearGroup(); | 811 | cfg.clearGroup(); |
812 | accountList.remove(cgroup); | 812 | accountList.remove(cgroup); |
813 | 813 | ||
814 | QString key; | 814 | QString key; |
815 | QStringList keys; | 815 | QStringList keys; |
816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
817 | it != stringEntries.end(); ++it ){ | 817 | it != stringEntries.end(); ++it ){ |
818 | QString val = it.data(); | 818 | QString val = it.data(); |
819 | key = it.key(); | 819 | key = it.key(); |
820 | keys = QStringList::split( "SEPARATOR", key ); | 820 | keys = QStringList::split( "SEPARATOR", key ); |
821 | if(keys[0]==cgroup){ | 821 | if(keys[0]==cgroup){ |
822 | stringEntries.remove( it ); | 822 | stringEntries.remove( it ); |
823 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 823 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
824 | } | 824 | } |
825 | } | 825 | } |
826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
827 | it != intEntries.end(); ++it ){ | 827 | it != intEntries.end(); ++it ){ |
828 | int val = it.data(); | 828 | int val = it.data(); |
829 | key = it.key(); | 829 | key = it.key(); |
830 | keys = QStringList::split( "SEPARATOR", key ); | 830 | keys = QStringList::split( "SEPARATOR", key ); |
831 | if(keys[0]==cgroup){ | 831 | if(keys[0]==cgroup){ |
832 | intEntries.remove( it ); | 832 | intEntries.remove( it ); |
833 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | 833 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; |
834 | } | 834 | } |
835 | } | 835 | } |
836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
837 | it != listEntries.end(); ++it ){ | 837 | it != listEntries.end(); ++it ){ |
838 | QStringList val = it.data(); | 838 | QStringList val = it.data(); |
839 | key = it.key(); | 839 | key = it.key(); |
840 | if(keys[0]==cgroup){ | 840 | if(keys[0]==cgroup){ |
841 | listEntries.remove( it ); | 841 | listEntries.remove( it ); |
842 | sepEntries.remove( key ); | 842 | sepEntries.remove( key ); |
843 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | 843 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; |
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | return true; | 847 | return true; |
848 | } | 848 | } |
849 | 849 | ||
850 | 850 | ||
851 | bool PPPData::deleteAccount(const QString &aname) { | 851 | bool PPPData::deleteAccount(const QString &aname) { |
852 | if(!setAccount(aname)) | 852 | if(!setAccount(aname)) |
853 | return false; | 853 | return false; |
854 | 854 | ||
855 | deleteAccount(); | 855 | deleteAccount(); |
856 | 856 | ||
857 | return true; | 857 | return true; |
858 | } | 858 | } |
859 | 859 | ||
860 | 860 | ||
861 | int PPPData::newaccount() { | 861 | int PPPData::newaccount() { |
862 | 862 | ||
863 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 863 | odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl; |
864 | // if(!config) open(); | 864 | // if(!config) open(); |
865 | // if (highcount >= MAX_ACCOUNTS) return -1; | 865 | // if (highcount >= MAX_ACCOUNTS) return -1; |
866 | 866 | ||
867 | 867 | ||
868 | QString tmp; | 868 | QString tmp; |
869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); | 869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); |
870 | cgroup = QString(tmp); | 870 | cgroup = QString(tmp); |
871 | accountList << tmp; | 871 | accountList << tmp; |
872 | qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1()); | 872 | odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl; |
873 | setpppdArgumentDefaults(); | 873 | setpppdArgumentDefaults(); |
874 | return highcount; | 874 | return highcount; |
875 | } | 875 | } |
876 | 876 | ||
877 | int PPPData::copyaccount(const QString&) { | 877 | int PPPData::copyaccount(const QString&) { |
878 | // FIXME: PPPData::copyaccount | 878 | // FIXME: PPPData::copyaccount |
879 | // if(highcount >= MAX_ACCOUNTS) | 879 | // if(highcount >= MAX_ACCOUNTS) |
880 | return -1; | 880 | return -1; |
881 | 881 | ||
882 | // setAccountbyIndex(i); | 882 | // setAccountbyIndex(i); |
883 | 883 | ||
884 | // QMap <QString, QString> map = config->entryMap(cgroup); | 884 | // QMap <QString, QString> map = config->entryMap(cgroup); |
885 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 885 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
886 | 886 | ||
887 | // QString newname = QObject::tr("%1_copy").arg(accname()); | 887 | // QString newname = QObject::tr("%1_copy").arg(accname()); |
888 | 888 | ||
889 | // newaccount(); | 889 | // newaccount(); |
890 | 890 | ||
891 | // while (it != map.end()) { | 891 | // while (it != map.end()) { |
892 | // config->writeEntry(it.key(), *it); | 892 | // config->writeEntry(it.key(), *it); |
893 | // it++; | 893 | // it++; |
894 | // } | 894 | // } |
895 | 895 | ||
896 | // setAccname(newname); | 896 | // setAccname(newname); |
@@ -944,51 +944,51 @@ void PPPData::setDialPrefix(const QString &s) { | |||
944 | } | 944 | } |
945 | 945 | ||
946 | 946 | ||
947 | int PPPData::authMethod() { | 947 | int PPPData::authMethod() { |
948 | return readNumConfig(cgroup, AUTH_KEY, 0); | 948 | return readNumConfig(cgroup, AUTH_KEY, 0); |
949 | } | 949 | } |
950 | 950 | ||
951 | 951 | ||
952 | void PPPData::setAuthMethod(int value) { | 952 | void PPPData::setAuthMethod(int value) { |
953 | writeConfig(cgroup, AUTH_KEY, value); | 953 | writeConfig(cgroup, AUTH_KEY, value); |
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | const QString PPPData::storedUsername() { | 957 | const QString PPPData::storedUsername() { |
958 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 958 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
959 | } | 959 | } |
960 | 960 | ||
961 | 961 | ||
962 | void PPPData::setStoredUsername(const QString &b) { | 962 | void PPPData::setStoredUsername(const QString &b) { |
963 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 963 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
964 | } | 964 | } |
965 | 965 | ||
966 | 966 | ||
967 | const QString PPPData::storedPassword() { | 967 | const QString PPPData::storedPassword() { |
968 | qDebug("getting stored pw"); | 968 | odebug << "getting stored pw" << oendl; |
969 | qDebug("g %s", cgroup.latin1() ); | 969 | odebug << "g " << cgroup.latin1() << "" << oendl; |
970 | qDebug("k %s", STORED_PASSWORD_KEY); | 970 | odebug << "k " << STORED_PASSWORD_KEY << "" << oendl; |
971 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 971 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
972 | } | 972 | } |
973 | 973 | ||
974 | 974 | ||
975 | void PPPData::setStoredPassword(const QString &b) { | 975 | void PPPData::setStoredPassword(const QString &b) { |
976 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 976 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
977 | } | 977 | } |
978 | 978 | ||
979 | 979 | ||
980 | bool PPPData::storePassword() { | 980 | bool PPPData::storePassword() { |
981 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 981 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
982 | } | 982 | } |
983 | 983 | ||
984 | 984 | ||
985 | const QString PPPData::command_before_connect() { | 985 | const QString PPPData::command_before_connect() { |
986 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 986 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
987 | } | 987 | } |
988 | 988 | ||
989 | 989 | ||
990 | void PPPData::setCommand_before_connect(const QString &n) { | 990 | void PPPData::setCommand_before_connect(const QString &n) { |
991 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 991 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
992 | } | 992 | } |
993 | 993 | ||
994 | 994 | ||
@@ -1308,188 +1308,188 @@ QMap<QString,QString> PPPData::getConfiguredInterfaces() | |||
1308 | Config config = PPPData::config(); | 1308 | Config config = PPPData::config(); |
1309 | config.setGroup(ACCLIST_GRP); | 1309 | config.setGroup(ACCLIST_GRP); |
1310 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | 1310 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); |
1311 | QString accGrp, dev, acc; | 1311 | QString accGrp, dev, acc; |
1312 | for (int i = 0; i < count; i++){ | 1312 | for (int i = 0; i < count; i++){ |
1313 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1313 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
1314 | config.setGroup(accGrp); | 1314 | config.setGroup(accGrp); |
1315 | dev = config.readEntry( ACOUNTS_DEV, "error" ); | 1315 | dev = config.readEntry( ACOUNTS_DEV, "error" ); |
1316 | acc = config.readEntry( ACOUNTS_ACC, "error" ); | 1316 | acc = config.readEntry( ACOUNTS_ACC, "error" ); |
1317 | ifaces.insert( dev, acc ); | 1317 | ifaces.insert( dev, acc ); |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | return ifaces; | 1320 | return ifaces; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1323 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1324 | { | 1324 | { |
1325 | QMap<QString,QString>::Iterator it; | 1325 | QMap<QString,QString>::Iterator it; |
1326 | int i = 0; | 1326 | int i = 0; |
1327 | Config cfg = config(); | 1327 | Config cfg = config(); |
1328 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 1328 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
1329 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); | 1329 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); |
1330 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); | 1330 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1331 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1331 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1332 | qDebug("I %i",i); | 1332 | odebug << "I " << i << "" << oendl; |
1333 | } | 1333 | } |
1334 | cfg.setGroup( ACCLIST_GRP ); | 1334 | cfg.setGroup( ACCLIST_GRP ); |
1335 | qDebug("saved %i account settings", i); | 1335 | odebug << "saved " << i << " account settings" << oendl; |
1336 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1336 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1337 | 1337 | ||
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | /** | 1340 | /** |
1341 | * pppd's getword() function knows about escape characters. | 1341 | * pppd's getword() function knows about escape characters. |
1342 | * If we write the username and password to the secrets file | 1342 | * If we write the username and password to the secrets file |
1343 | * we'll therefore have to escape back slashes. | 1343 | * we'll therefore have to escape back slashes. |
1344 | */ | 1344 | */ |
1345 | QString PPPData::encodeWord(const QString &s) { | 1345 | QString PPPData::encodeWord(const QString &s) { |
1346 | QString r = s; | 1346 | QString r = s; |
1347 | r.replace(QRegExp("\\"), "\\\\"); | 1347 | r.replace(QRegExp("\\"), "\\\\"); |
1348 | return r; | 1348 | return r; |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | QStringList PPPData::getDevicesList() | 1351 | QStringList PPPData::getDevicesList() |
1352 | { | 1352 | { |
1353 | Config cfg("NetworkSetupPPP"); | 1353 | Config cfg("NetworkSetupPPP"); |
1354 | cfg.setGroup("Devices_General"); | 1354 | cfg.setGroup("Devices_General"); |
1355 | return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); | 1355 | return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | QStringList PPPData::getAccountList() | 1358 | QStringList PPPData::getAccountList() |
1359 | { | 1359 | { |
1360 | QStringList list; | 1360 | QStringList list; |
1361 | QString save_cgroup; | 1361 | QString save_cgroup; |
1362 | save_cgroup = cgroup; | 1362 | save_cgroup = cgroup; |
1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
1364 | cgroup = *it; | 1364 | cgroup = *it; |
1365 | list << accname(); | 1365 | list << accname(); |
1366 | } | 1366 | } |
1367 | cgroup = save_cgroup; | 1367 | cgroup = save_cgroup; |
1368 | return list; | 1368 | return list; |
1369 | }; | 1369 | }; |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | const QString PPPData::devname() | 1372 | const QString PPPData::devname() |
1373 | { | 1373 | { |
1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); | 1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); |
1375 | qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1()); | 1375 | odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl; |
1376 | return tmp; | 1376 | return tmp; |
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | void PPPData::setDevname(const QString &n) { | 1379 | void PPPData::setDevname(const QString &n) { |
1380 | // if(!cgroup.isNull()) { | 1380 | // if(!cgroup.isNull()) { |
1381 | // // are we manipulating the default account's name ? then change it, too. | 1381 | // // are we manipulating the default account's name ? then change it, too. |
1382 | // bool def = accname() == defaultAccount(); | 1382 | // bool def = accname() == defaultAccount(); |
1383 | // writeConfig(cgroup, NAME_KEY, n); | 1383 | // writeConfig(cgroup, NAME_KEY, n); |
1384 | // if (def) | 1384 | // if (def) |
1385 | // setDefaultAccount(n); | 1385 | // setDefaultAccount(n); |
1386 | // } | 1386 | // } |
1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); | 1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | 1390 | ||
1391 | bool PPPData::setDevice(const QString &dev ) | 1391 | bool PPPData::setDevice(const QString &dev ) |
1392 | { | 1392 | { |
1393 | qDebug("setting device to >%s<", dev.latin1()); | 1393 | odebug << "setting device to >" << dev.latin1() << "<" << oendl; |
1394 | QString save_mName = _modemName; | 1394 | QString save_mName = _modemName; |
1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
1396 | _modemName = *it; | 1396 | _modemName = *it; |
1397 | qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() ); | 1397 | odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl; |
1398 | qDebug( "iterator %s", (*it).latin1() ); | 1398 | odebug << "iterator " << (*it).latin1() << "" << oendl; |
1399 | if(devname() == dev) { | 1399 | if(devname() == dev) { |
1400 | qDebug("SUCCESS"); | 1400 | odebug << "SUCCESS" << oendl; |
1401 | return true; | 1401 | return true; |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | } | 1404 | } |
1405 | _modemName = save_mName; | 1405 | _modemName = save_mName; |
1406 | qDebug("FAILURE"); | 1406 | odebug << "FAILURE" << oendl; |
1407 | return false; | 1407 | return false; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | bool PPPData::deleteDevice() | 1410 | bool PPPData::deleteDevice() |
1411 | { | 1411 | { |
1412 | // FIXME: check if this account exists in a config... | 1412 | // FIXME: check if this account exists in a config... |
1413 | Config cfg = PPPData::config(); | 1413 | Config cfg = PPPData::config(); |
1414 | cfg.setGroup(modemGroup()); | 1414 | cfg.setGroup(modemGroup()); |
1415 | cfg.clearGroup(); | 1415 | cfg.clearGroup(); |
1416 | deviceList.remove(modemGroup()); | 1416 | deviceList.remove(modemGroup()); |
1417 | 1417 | ||
1418 | QString key; | 1418 | QString key; |
1419 | QStringList keys; | 1419 | QStringList keys; |
1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
1421 | it != stringEntries.end(); ++it ){ | 1421 | it != stringEntries.end(); ++it ){ |
1422 | QString val = it.data(); | 1422 | QString val = it.data(); |
1423 | key = it.key(); | 1423 | key = it.key(); |
1424 | keys = QStringList::split( "SEPARATOR", key ); | 1424 | keys = QStringList::split( "SEPARATOR", key ); |
1425 | if(keys[0]==modemGroup()){ | 1425 | if(keys[0]==modemGroup()){ |
1426 | stringEntries.remove( it ); | 1426 | stringEntries.remove( it ); |
1427 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 1427 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
1431 | it != intEntries.end(); ++it ){ | 1431 | it != intEntries.end(); ++it ){ |
1432 | int val = it.data(); | 1432 | int val = it.data(); |
1433 | key = it.key(); | 1433 | key = it.key(); |
1434 | keys = QStringList::split( "SEPARATOR", key ); | 1434 | keys = QStringList::split( "SEPARATOR", key ); |
1435 | if(keys[0]==modemGroup()){ | 1435 | if(keys[0]==modemGroup()){ |
1436 | intEntries.remove( it ); | 1436 | intEntries.remove( it ); |
1437 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | 1437 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
1441 | it != listEntries.end(); ++it ){ | 1441 | it != listEntries.end(); ++it ){ |
1442 | QStringList val = it.data(); | 1442 | QStringList val = it.data(); |
1443 | key = it.key(); | 1443 | key = it.key(); |
1444 | if(keys[0]==modemGroup()){ | 1444 | if(keys[0]==modemGroup()){ |
1445 | listEntries.remove( it ); | 1445 | listEntries.remove( it ); |
1446 | sepEntries.remove( key ); | 1446 | sepEntries.remove( key ); |
1447 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | 1447 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; |
1448 | } | 1448 | } |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | return true; | 1451 | return true; |
1452 | 1452 | ||
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | bool PPPData::deleteDevice(const QString &dev) | 1455 | bool PPPData::deleteDevice(const QString &dev) |
1456 | { | 1456 | { |
1457 | if(!setDevice(dev)) | 1457 | if(!setDevice(dev)) |
1458 | return false; | 1458 | return false; |
1459 | 1459 | ||
1460 | return deleteDevice(); | 1460 | return deleteDevice(); |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | int PPPData::newdevice() | 1463 | int PPPData::newdevice() |
1464 | { | 1464 | { |
1465 | 1465 | ||
1466 | qDebug("PPPData::newdevice highcount %i",highcountdev); | 1466 | odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl; |
1467 | 1467 | ||
1468 | 1468 | ||
1469 | QString tmp; | 1469 | QString tmp; |
1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); | 1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); |
1471 | _modemName = QString(tmp); | 1471 | _modemName = QString(tmp); |
1472 | deviceList << tmp; | 1472 | deviceList << tmp; |
1473 | qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1()); | 1473 | odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl; |
1474 | return highcountdev; | 1474 | return highcountdev; |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | int PPPData::copydevice(const QString&) | 1477 | int PPPData::copydevice(const QString&) |
1478 | { | 1478 | { |
1479 | return false; | 1479 | return false; |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | 1482 | ||
1483 | QStringList PPPData::getDevicesNamesList() | 1483 | QStringList PPPData::getDevicesNamesList() |
1484 | { | 1484 | { |
1485 | QStringList list; | 1485 | QStringList list; |
1486 | QString save_mName = _modemName; | 1486 | QString save_mName = _modemName; |
1487 | qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1()); | 1487 | odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl; |
1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
1489 | _modemName = *it; | 1489 | _modemName = *it; |
1490 | qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1()); | 1490 | odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl; |
1491 | list << devname(); | 1491 | list << devname(); |
1492 | } | 1492 | } |
1493 | _modemName = save_mName; | 1493 | _modemName = save_mName; |
1494 | return list; | 1494 | return list; |
1495 | }; | 1495 | }; |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index a7caffe..2291e8a 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -39,157 +39,157 @@ namespace | |||
39 | void addInterface( pid_t, const QString& pppDev, const QString& name ); | 39 | void addInterface( pid_t, const QString& pppDev, const QString& name ); |
40 | QMap<QString, Connection> interfaces()const; // will check if still available | 40 | QMap<QString, Connection> interfaces()const; // will check if still available |
41 | private: | 41 | private: |
42 | bool isAvailable( pid_t )const; | 42 | bool isAvailable( pid_t )const; |
43 | QMap<QString, Connection> m_interfaces; | 43 | QMap<QString, Connection> m_interfaces; |
44 | }; | 44 | }; |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Constructor, find all of the possible interfaces | 49 | * Constructor, find all of the possible interfaces |
50 | * We also need to restore the state.. it could be that | 50 | * We also need to restore the state.. it could be that |
51 | * an interface was up while closing the application | 51 | * an interface was up while closing the application |
52 | * we need to be able to shut it down... | 52 | * we need to be able to shut it down... |
53 | */ | 53 | */ |
54 | PPPModule::PPPModule() : Module() | 54 | PPPModule::PPPModule() : Module() |
55 | { | 55 | { |
56 | InterfaceKeeper inFace; | 56 | InterfaceKeeper inFace; |
57 | QMap<QString,Connection> running = inFace.interfaces(); | 57 | QMap<QString,Connection> running = inFace.interfaces(); |
58 | QStringList handledInterfaceNames; | 58 | QStringList handledInterfaceNames; |
59 | 59 | ||
60 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 60 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
61 | QMap<QString,QString>::Iterator it; | 61 | QMap<QString,QString>::Iterator it; |
62 | InterfacePPP *iface; | 62 | InterfacePPP *iface; |
63 | qDebug("getting interfaces"); | 63 | odebug << "getting interfaces" << oendl; |
64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) | 64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) |
65 | { | 65 | { |
66 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); | 66 | odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; |
67 | iface = new InterfacePPP( 0, it.key() ); | 67 | iface = new InterfacePPP( 0, it.key() ); |
68 | iface->setHardwareName( it.data() ); | 68 | iface->setHardwareName( it.data() ); |
69 | list.append( (Interface*)iface ); | 69 | list.append( (Interface*)iface ); |
70 | 70 | ||
71 | // check if (*it) is one of the running ifaces | 71 | // check if (*it) is one of the running ifaces |
72 | if ( running.contains( it.data() ) ) | 72 | if ( running.contains( it.data() ) ) |
73 | { | 73 | { |
74 | qDebug("iface is running %s", it.key().latin1() ); | 74 | odebug << "iface is running " << it.key().latin1() << "" << oendl; |
75 | handledInterfaceNames << running[it.data()].device; | 75 | handledInterfaceNames << running[it.data()].device; |
76 | iface->setStatus( true ); | 76 | iface->setStatus( true ); |
77 | iface->setPPPDpid( running[it.data()].pid ); | 77 | iface->setPPPDpid( running[it.data()].pid ); |
78 | iface->modem()->setPPPDevice( running[it.data()].device ); | 78 | iface->modem()->setPPPDevice( running[it.data()].device ); |
79 | iface->refresh(); | 79 | iface->refresh(); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | setHandledInterfaceNames( handledInterfaceNames ); | 83 | setHandledInterfaceNames( handledInterfaceNames ); |
84 | } | 84 | } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Delete any interfaces that we own. | 87 | * Delete any interfaces that we own. |
88 | */ | 88 | */ |
89 | PPPModule::~PPPModule() | 89 | PPPModule::~PPPModule() |
90 | { | 90 | { |
91 | qDebug("PPPModule::~PPPModule() " ); | 91 | odebug << "PPPModule::~PPPModule() " << oendl; |
92 | QMap<QString,QString> ifaces; | 92 | QMap<QString,QString> ifaces; |
93 | InterfaceKeeper keeper; | 93 | InterfaceKeeper keeper; |
94 | Interface *i; | 94 | Interface *i; |
95 | for ( i=list.first(); i != 0; i=list.next() ) | 95 | for ( i=list.first(); i != 0; i=list.next() ) |
96 | { | 96 | { |
97 | /* if online save the state */ | 97 | /* if online save the state */ |
98 | if ( i->getStatus() ) | 98 | if ( i->getStatus() ) |
99 | { | 99 | { |
100 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | 100 | odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; |
101 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | 101 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); |
102 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | 102 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); |
103 | } | 103 | } |
104 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 104 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
105 | delete i; | 105 | delete i; |
106 | } | 106 | } |
107 | PPPData::setConfiguredInterfaces( ifaces ); | 107 | PPPData::setConfiguredInterfaces( ifaces ); |
108 | } | 108 | } |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * Change the current profile | 111 | * Change the current profile |
112 | */ | 112 | */ |
113 | void PPPModule::setProfile(const QString &newProfile) | 113 | void PPPModule::setProfile(const QString &newProfile) |
114 | { | 114 | { |
115 | profile = newProfile; | 115 | profile = newProfile; |
116 | } | 116 | } |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * get the icon name for this device. | 119 | * get the icon name for this device. |
120 | * @param Interface* can be used in determining the icon. | 120 | * @param Interface* can be used in determining the icon. |
121 | * @return QString the icon name (minus .png, .gif etc) | 121 | * @return QString the icon name (minus .png, .gif etc) |
122 | */ | 122 | */ |
123 | QString PPPModule::getPixmapName(Interface* ) | 123 | QString PPPModule::getPixmapName(Interface* ) |
124 | { | 124 | { |
125 | return "ppp"; | 125 | return "ppp"; |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Check to see if the interface i is owned by this module. | 129 | * Check to see if the interface i is owned by this module. |
130 | * @param Interface* interface to check against | 130 | * @param Interface* interface to check against |
131 | * @return bool true if i is owned by this module, false otherwise. | 131 | * @return bool true if i is owned by this module, false otherwise. |
132 | */ | 132 | */ |
133 | bool PPPModule::isOwner(Interface *i) | 133 | bool PPPModule::isOwner(Interface *i) |
134 | { | 134 | { |
135 | return list.find( i ) != -1; | 135 | return list.find( i ) != -1; |
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Create, and return the WLANConfigure Module | 139 | * Create, and return the WLANConfigure Module |
140 | * @return QWidget* pointer to this modules configure. | 140 | * @return QWidget* pointer to this modules configure. |
141 | */ | 141 | */ |
142 | QWidget *PPPModule::configure(Interface *i) | 142 | QWidget *PPPModule::configure(Interface *i) |
143 | { | 143 | { |
144 | qDebug("return ModemWidget"); | 144 | odebug << "return ModemWidget" << oendl; |
145 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 145 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
146 | 0, "PPPConfig", false, | 146 | 0, "PPPConfig", false, |
147 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); | 147 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); |
148 | return pppconfig; | 148 | return pppconfig; |
149 | } | 149 | } |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Create, and return the Information Module | 152 | * Create, and return the Information Module |
153 | * @return QWidget* pointer to this modules info. | 153 | * @return QWidget* pointer to this modules info. |
154 | */ | 154 | */ |
155 | QWidget *PPPModule::information(Interface *i) | 155 | QWidget *PPPModule::information(Interface *i) |
156 | { | 156 | { |
157 | // We don't have any advanced pppd information widget yet :-D | 157 | // We don't have any advanced pppd information widget yet :-D |
158 | // TODO ^ | 158 | // TODO ^ |
159 | 159 | ||
160 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 160 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Get all active (up or down) interfaces | 164 | * Get all active (up or down) interfaces |
165 | * @return QList<Interface> A list of interfaces that exsist that havn't | 165 | * @return QList<Interface> A list of interfaces that exsist that havn't |
166 | * been called by isOwner() | 166 | * been called by isOwner() |
167 | */ | 167 | */ |
168 | QList<Interface> PPPModule::getInterfaces() | 168 | QList<Interface> PPPModule::getInterfaces() |
169 | { | 169 | { |
170 | // List all of the files in the peer directory | 170 | // List all of the files in the peer directory |
171 | qDebug("PPPModule::getInterfaces"); | 171 | odebug << "PPPModule::getInterfaces" << oendl; |
172 | return list; | 172 | return list; |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Attempt to add a new interface as defined by name | 176 | * Attempt to add a new interface as defined by name |
177 | * @param name the name of the type of interface that should be created given | 177 | * @param name the name of the type of interface that should be created given |
178 | * by possibleNewInterfaces(); | 178 | * by possibleNewInterfaces(); |
179 | * @return Interface* NULL if it was unable to be created. | 179 | * @return Interface* NULL if it was unable to be created. |
180 | */ | 180 | */ |
181 | Interface *PPPModule::addNewInterface(const QString &newInterface) | 181 | Interface *PPPModule::addNewInterface(const QString &newInterface) |
182 | { | 182 | { |
183 | 183 | ||
184 | InterfacePPP *ifaceppp; | 184 | InterfacePPP *ifaceppp; |
185 | Interface *iface; | 185 | Interface *iface; |
186 | ifaceppp = new InterfacePPP(); | 186 | ifaceppp = new InterfacePPP(); |
187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
188 | 188 | ||
189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) | 189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) |
190 | { | 190 | { |
191 | iface = (InterfacePPP*) ifaceppp; | 191 | iface = (InterfacePPP*) ifaceppp; |
192 | iface->setModuleOwner( this ); | 192 | iface->setModuleOwner( this ); |
193 | list.append( iface ); | 193 | list.append( iface ); |
194 | return iface; | 194 | return iface; |
195 | } | 195 | } |
@@ -240,44 +240,44 @@ namespace | |||
240 | cfg.writeEntry( "pid", con.pid ); | 240 | cfg.writeEntry( "pid", con.pid ); |
241 | cfg.writeEntry( "device", con.device ); | 241 | cfg.writeEntry( "device", con.device ); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) | 244 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) |
245 | { | 245 | { |
246 | Connection con; | 246 | Connection con; |
247 | con.pid = pid; | 247 | con.pid = pid; |
248 | con.device = dev; | 248 | con.device = dev; |
249 | con.name = name; | 249 | con.name = name; |
250 | m_interfaces.insert( name, con ); | 250 | m_interfaces.insert( name, con ); |
251 | } | 251 | } |
252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const | 252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const |
253 | { | 253 | { |
254 | Config cfg("ppp_plugin_keeper"); | 254 | Config cfg("ppp_plugin_keeper"); |
255 | QMap<QString, Connection> ifaces; | 255 | QMap<QString, Connection> ifaces; |
256 | QStringList lst = cfg.groupList(); | 256 | QStringList lst = cfg.groupList(); |
257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) | 257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
258 | { | 258 | { |
259 | Connection con; | 259 | Connection con; |
260 | cfg.setGroup( (*it) ); | 260 | cfg.setGroup( (*it) ); |
261 | con.name = (*it); | 261 | con.name = (*it); |
262 | con.pid = cfg.readNumEntry("pid"); | 262 | con.pid = cfg.readNumEntry("pid"); |
263 | con.device = cfg.readEntry("device"); | 263 | con.device = cfg.readEntry("device"); |
264 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); | 264 | odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; |
265 | 265 | ||
266 | if ( con.pid != -1 && isAvailable( con.pid ) ) | 266 | if ( con.pid != -1 && isAvailable( con.pid ) ) |
267 | ifaces.insert( con.name, con ); | 267 | ifaces.insert( con.name, con ); |
268 | } | 268 | } |
269 | return ifaces; | 269 | return ifaces; |
270 | } | 270 | } |
271 | bool InterfaceKeeper::isAvailable( pid_t p)const | 271 | bool InterfaceKeeper::isAvailable( pid_t p)const |
272 | { | 272 | { |
273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) | 273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) |
274 | { | 274 | { |
275 | qDebug("isAvailable %d", p); | 275 | odebug << "isAvailable " << p << "" << oendl; |
276 | return true; | 276 | return true; |
277 | } | 277 | } |
278 | 278 | ||
279 | qDebug("notAvailable %d", p); | 279 | odebug << "notAvailable " << p << "" << oendl; |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | 282 | ||
283 | } | 283 | } |