summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/connect.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp326
1 files changed, 161 insertions, 165 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index a3eda9d..2615b60 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -66,5 +66,5 @@
#include "connect.h"
//#include "docking.h"
-//#include "main.h"
+#include "interfaceppp.h"
#include "modem.h"
#include "kpppconfig.h"
@@ -75,13 +75,10 @@
#define execute_command system
-extern KPPPWidget *p_kppp;
-
QString old_hostname;
bool modified_hostname;
-ConnectWidget::ConnectWidget(QWidget *parent, const char *name)
+ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
: QWidget(parent, name),
- // initialize some important variables
myreadbuffer(""),
main_timer_ID(0),
@@ -97,7 +94,6 @@ ConnectWidget::ConnectWidget(QWidget *parent, const char *name)
scanning(false),
pausing(false),
-// termwindow(0),
-// stats(st),
- dialnumber(0)
+ dialnumber(0),
+ _ifaceppp(ifp)
{
modified_hostname = false;
@@ -180,5 +176,5 @@ void ConnectWidget::preinit() {
void ConnectWidget::init() {
- PPPData::data()->setpppdError(0);
+ _ifaceppp->data()->setpppdError(0);
inittimer->stop();
vmain = 0;
@@ -195,12 +191,12 @@ void ConnectWidget::init() {
dialnumber = 0;
- p_kppp->con_speed = "";
+// p_kppp->con_speed = "";
-// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect());
+// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
- comlist = &PPPData::data()->scriptType();
- arglist = &PPPData::data()->script();
+ comlist = &_ifaceppp->data()->scriptType();
+ arglist = &_ifaceppp->data()->script();
- QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
+ QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname());
setCaption(tit);
@@ -208,5 +204,5 @@ void ConnectWidget::init() {
// run the "before-connect" command
- if (!PPPData::data()->command_before_connect().isEmpty()) {
+ if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
messg->setText(i18n("Running pre-startup command..."));
emit debugMessage(i18n("Running pre-startup command..."));
@@ -214,5 +210,5 @@ void ConnectWidget::init() {
qApp->processEvents();
QApplication::flushX();
- pid_t id = execute_command(PPPData::data()->command_before_connect());
+ pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
// int i, status;
@@ -224,5 +220,5 @@ void ConnectWidget::init() {
}
- int lock = Modem::modem->lockdevice();
+ int lock = _ifaceppp->modem()->lockdevice();
if (lock == 1) {
@@ -238,8 +234,8 @@ void ConnectWidget::init() {
}
- if(Modem::modem->opentty()) {
- messg->setText(Modem::modem->modemMessage());
+ if(_ifaceppp->modem()->opentty()) {
+ messg->setText(_ifaceppp->modem()->modemMessage());
qApp->processEvents();
- if(Modem::modem->hangup()) {
+ if(_ifaceppp->modem()->hangup()) {
qApp->processEvents();
@@ -247,9 +243,9 @@ void ConnectWidget::init() {
semaphore = false;
- Modem::modem->stop();
- Modem::modem->notify(this, SLOT(readChar(unsigned char)));
+ _ifaceppp->modem()->stop();
+ _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char)));
// if we are stuck anywhere we will time out
- timeout_timer->start(PPPData::data()->modemTimeout()*1000);
+ timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
// this timer will run the script etc.
@@ -261,7 +257,7 @@ void ConnectWidget::init() {
// initialization failed
- messg->setText(Modem::modem->modemMessage());
+ messg->setText(_ifaceppp->modem()->modemMessage());
vmain = 20; // wait until cancel is pressed
- Modem::modem->unlockdevice();
+ _ifaceppp->modem()->unlockdevice();
}
@@ -285,16 +281,16 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
- QString initStr = PPPData::data()->modemInitStr(substate);
+ QString initStr = _ifaceppp->data()->modemInitStr(substate);
if (!initStr.isEmpty()) {
// send a carriage return and then wait a bit so that the modem will
// let us issue commands.
- if(PPPData::data()->modemPreInitDelay() > 0) {
- usleep(PPPData::data()->modemPreInitDelay() * 5000);
+ if(_ifaceppp->data()->modemPreInitDelay() > 0) {
+ usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
writeline("");
- usleep(PPPData::data()->modemPreInitDelay() * 5000);
+ usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
}
- setExpect(PPPData::data()->modemInitResp());
+ setExpect(_ifaceppp->data()->modemInitResp());
writeline(initStr);
- usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
}
@@ -307,5 +303,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
* a "Modem Query"
*/
- if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration())
+ if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
vmain = 5;
else
@@ -317,9 +313,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if (vmain == 5) {
if(!expecting) {
- QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration());
+ QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
QString msg = i18n("Setting ") + sToneDuration;
messg->setText(msg);
emit debugMessage(msg);
- setExpect(PPPData::data()->modemInitResp());
+ setExpect(_ifaceppp->data()->modemInitResp());
writeline(sToneDuration);
}
@@ -337,5 +333,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
substate = -1;
// skip setting the volume if command is empty
- if(PPPData::data()->volumeInitString().isEmpty()) {
+ if(_ifaceppp->data()->volumeInitString().isEmpty()) {
vmain = 4;
return;
@@ -344,9 +340,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(i18n("Setting speaker volume..."));
- setExpect(PPPData::data()->modemInitResp());
+ setExpect(_ifaceppp->data()->modemInitResp());
QString vol("AT");
- vol += PPPData::data()->volumeInitString();
+ vol += _ifaceppp->data()->volumeInitString();
writeline(vol);
- usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
vmain = 4;
return;
@@ -356,10 +352,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(vmain == 4) {
if(!expecting) {
- if(!PPPData::data()->waitForDialTone()) {
+ if(!_ifaceppp->data()->waitForDialTone()) {
QString msg = i18n("Turning off dial tone waiting...");
messg->setText(msg);
emit debugMessage(msg);
- setExpect(PPPData::data()->modemInitResp());
- writeline(PPPData::data()->modemNoDialToneDetectionStr());
+ setExpect(_ifaceppp->data()->modemInitResp());
+ writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
}
vmain = 1;
@@ -373,8 +369,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
timeout_timer->stop();
- timeout_timer->start(PPPData::data()->modemTimeout()*1000);
+ timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
- QStringList &plist = PPPData::data()->phonenumbers();
- QString bmarg= PPPData::data()->dialPrefix();
+ QStringList &plist = _ifaceppp->data()->phonenumbers();
+ QString bmarg= _ifaceppp->data()->dialPrefix();
bmarg += *plist.at(dialnumber);
QString bm = i18n("Dialing %1").arg(bmarg);
@@ -382,6 +378,6 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(bm);
- QString pn = PPPData::data()->modemDialStr();
- pn += PPPData::data()->dialPrefix();
+ QString pn = _ifaceppp->data()->modemDialStr();
+ pn += _ifaceppp->data()->dialPrefix();
pn += *plist.at(dialnumber);
if(++dialnumber >= plist.count())
@@ -389,5 +385,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
writeline(pn);
- setExpect(PPPData::data()->modemConnectResp());
+ setExpect(_ifaceppp->data()->modemConnectResp());
vmain = 100;
return;
@@ -399,5 +395,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(vmain == 100) {
if(!expecting) {
- myreadbuffer = PPPData::data()->modemConnectResp();
+ myreadbuffer = _ifaceppp->data()->modemConnectResp();
setExpect("\n");
vmain = 101;
@@ -405,14 +401,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
- if(readbuffer.contains(PPPData::data()->modemBusyResp())) {
+ if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
timeout_timer->stop();
- timeout_timer->start(PPPData::data()->modemTimeout()*1000);
+ timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
messg->setText(i18n("Line busy. Hanging up..."));
emit debugPutChar('\n');
- Modem::modem->hangup();
+ _ifaceppp->modem()->hangup();
- if(PPPData::data()->busyWait() > 0) {
- QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait());
+ if(_ifaceppp->data()->busyWait() > 0) {
+ QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
messg->setText(bm);
emit debugMessage(bm);
@@ -420,9 +416,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
pausing = true;
- pausetimer->start(PPPData::data()->busyWait()*1000, true);
+ pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
timeout_timer->stop();
}
- Modem::modem->setDataMode(false);
+ _ifaceppp->modem()->setDataMode(false);
vmain = 0;
substate = -1;
@@ -430,19 +426,19 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
- if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) {
+ if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
timeout_timer->stop();
messg->setText(i18n("No Dialtone"));
vmain = 20;
- Modem::modem->unlockdevice();
+ _ifaceppp->modem()->unlockdevice();
return;
}
- if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) {
+ if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
timeout_timer->stop();
messg->setText(i18n("No Carrier"));
vmain = 20;
- Modem::modem->unlockdevice();
+ _ifaceppp->modem()->unlockdevice();
return;
}
@@ -452,5 +448,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(vmain == 101) {
if(!expecting) {
- Modem::modem->setDataMode(true); // modem will no longer respond to AT commands
+ _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
emit startAccounting();
@@ -458,5 +454,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
vmain = 2;
- scriptTimeout=PPPData::data()->modemTimeout()*1000;
+ scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
return;
}
@@ -495,8 +491,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if (scriptArgument.lower() == "password") {
- PPPData::data()->setPassword(scanvar);
- p_kppp->setPW_Edit(scanvar);
- if(PPPData::data()->storePassword())
- PPPData::data()->setStoredPassword(scanvar);
+ _ifaceppp->data()->setPassword(scanvar);
+// p_kppp->setPW_Edit(scanvar);
+ if(_ifaceppp->data()->storePassword())
+ _ifaceppp->data()->setStoredPassword(scanvar);
firstrunPW = true;
}
@@ -514,6 +510,6 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
QRegExp re1("%USERNAME%");
QRegExp re2("%PASSWORD%");
- arg = arg.replace(re1, PPPData::data()->storedUsername());
- arg = arg.replace(re2, PPPData::data()->storedPassword());
+ arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
+ arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
if (scriptCommand == "Send")
@@ -579,6 +575,6 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(i18n("Hangup"));
- writeline(PPPData::data()->modemHangupStr());
- setExpect(PPPData::data()->modemHangupResp());
+ writeline(_ifaceppp->data()->modemHangupStr());
+ setExpect(_ifaceppp->data()->modemHangupResp());
scriptindex++;
@@ -593,5 +589,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(i18n("Answer"));
- setExpect(PPPData::data()->modemRingResp());
+ setExpect(_ifaceppp->data()->modemRingResp());
vmain = 150;
return;
@@ -603,5 +599,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(bm);
- QString idstring = PPPData::data()->storedUsername();
+ QString idstring = _ifaceppp->data()->storedUsername();
if(!idstring.isEmpty() && firstrunID) {
@@ -639,5 +635,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
emit debugMessage(bm);
- QString pwstring = PPPData::data()->password();
+ QString pwstring = _ifaceppp->data()->password();
if(!pwstring.isEmpty() && firstrunPW) {
@@ -660,5 +656,5 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
/* if prompt withdrawn ... then, */
if(!(prompt->isVisible())) {
- p_kppp->setPW_Edit(prompt->text());
+// p_kppp->setPW_Edit(prompt->text());
writeline(prompt->text());
prompt->setConsumed();
@@ -786,6 +782,6 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(vmain == 150) {
if(!expecting) {
- writeline(PPPData::data()->modemAnswerStr());
- setExpect(PPPData::data()->modemAnswerResp());
+ writeline(_ifaceppp->data()->modemAnswerStr());
+ setExpect(_ifaceppp->data()->modemAnswerResp());
vmain = 2;
@@ -813,7 +809,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
// stop reading of data
- Modem::modem->stop();
+ _ifaceppp->modem()->stop();
- if(PPPData::data()->authMethod() == AUTH_TERMINAL) {
+ if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
// if (termwindow) {
// delete termwindow;
@@ -832,10 +828,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
// Modem::readtty() from re-enabling the socket notifier.
// The port is still held open by the helper process.
- Modem::modem->closetty();
+ _ifaceppp->modem()->closetty();
killTimer( main_timer_ID );
- if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000);
- qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000);
+ if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
+ qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000);
// find out PPP interface and notify the stats module
@@ -850,6 +846,6 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(result) {
- if(!PPPData::data()->autoDNS())
- adddns();
+ if(!_ifaceppp->data()->autoDNS())
+ adddns( _ifaceppp );
// O.K we are done here, let's change over to the if_waiting loop
@@ -864,12 +860,12 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
this->hide();
messg->setText("");
- p_kppp->quit_b->setFocus();
- p_kppp->show();
+// p_kppp->quit_b->setFocus();
+// p_kppp->show();
qApp->processEvents();
- Modem::modem->hangup();
+ _ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
- Modem::modem->closetty();
- Modem::modem->unlockdevice();
+ _ifaceppp->modem()->closetty();
+ _ifaceppp->modem()->unlockdevice();
}
@@ -891,5 +887,5 @@ void ConnectWidget::set_con_speed_string() {
// CONNECT 115200, so all we need to do is find the number after CONNECT
// or whatever the modemConnectResp() is.
- p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer);
+// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
}
@@ -970,5 +966,5 @@ void ConnectWidget::pause() {
void ConnectWidget::cancelbutton() {
- Modem::modem->stop();
+ _ifaceppp->modem()->stop();
killTimer(main_timer_ID);
timeout_timer->stop();
@@ -985,21 +981,21 @@ void ConnectWidget::cancelbutton() {
// just to be sure
- Modem::modem->removeSecret(AUTH_PAP);
- Modem::modem->removeSecret(AUTH_CHAP);
- removedns();
+ _ifaceppp->modem()->removeSecret(AUTH_PAP);
+ _ifaceppp->modem()->removeSecret(AUTH_CHAP);
+ removedns(_ifaceppp);
qApp->processEvents();
- Modem::modem->killPPPDaemon();
- Modem::modem->hangup();
+ _ifaceppp->modem()->killPPPDaemon();
+ _ifaceppp->modem()->hangup();
this->hide();
messg->setText("");
- p_kppp->quit_b->setFocus();
- p_kppp->show();
+// p_kppp->quit_b->setFocus();
+// p_kppp->show();
emit stopAccounting(); // just to be sure
// p_kppp->con_win->stopClock();
- Modem::modem->closetty();
- Modem::modem->unlockdevice();
+ _ifaceppp->modem()->closetty();
+ _ifaceppp->modem()->unlockdevice();
//abort prompt window...
@@ -1027,5 +1023,5 @@ void ConnectWidget::script_timed_out() {
prompt->setConsumed();
messg->setText(i18n("Script timed out!"));
- Modem::modem->hangup();
+ _ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
@@ -1064,8 +1060,8 @@ void ConnectWidget::if_waiting_timed_out() {
qDebug("if_waiting_timed_out()");
- PPPData::data()->setpppdError(E_IF_TIMEOUT);
+ _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
// let's kill the stuck pppd
- Modem::modem->killPPPDaemon();
+ _ifaceppp->modem()->killPPPDaemon();
emit stopAccounting();
@@ -1089,5 +1085,5 @@ void ConnectWidget::if_waiting_slot() {
// if(!stats->ifIsUp()) {
-// if(PPPData::data()->pppdError() != 0) {
+// if(_ifaceppp->data()->pppdError() != 0) {
// // we are here if pppd died immediately after starting it.
// pppdDied();
@@ -1106,6 +1102,6 @@ void ConnectWidget::if_waiting_slot() {
usleep(200000);
- if(PPPData::data()->autoDNS())
- addpeerdns();
+ if(_ifaceppp->data()->autoDNS())
+ addpeerdns( _ifaceppp );
// Close the debugging window. If we are connected, we
@@ -1113,18 +1109,18 @@ void ConnectWidget::if_waiting_slot() {
emit closeDebugWindow();
// p_kppp->statdlg->take_stats(); // start taking ppp statistics
- auto_hostname();
+ auto_hostname(_ifaceppp);
- if(!PPPData::data()->command_on_connect().isEmpty()) {
+ if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
messg->setText(i18n("Running startup command..."));
// make sure that we don't get any async errors
qApp->flushX();
- execute_command(PPPData::data()->command_on_connect());
+ execute_command(_ifaceppp->data()->command_on_connect());
messg->setText(i18n("Done"));
}
// remove the authentication file
- Modem::modem->removeSecret(AUTH_PAP);
- Modem::modem->removeSecret(AUTH_CHAP);
+ _ifaceppp->modem()->removeSecret(AUTH_PAP);
+ _ifaceppp->modem()->removeSecret(AUTH_CHAP);
emit debugMessage(i18n("Done"));
@@ -1142,18 +1138,18 @@ void ConnectWidget::if_waiting_slot() {
// p_kppp->con_win->accounting(false);
- if (PPPData::data()->get_dock_into_panel()) {
-// DockWidget::dock_widget->show();
-// DockWidget::dock_widget->take_stats();
-// this->hide();
- }
- else {
-// p_kppp->con_win->show();
+// if (_ifaceppp->data()->get_dock_into_panel()) {
+// // DockWidget::dock_widget->show();
+// // DockWidget::dock_widget->take_stats();
+// // this->hide();
+// }
+// else {
+// // p_kppp->con_win->show();
- if(PPPData::data()->get_iconify_on_connect()) {
- // p_kppp->con_win->showMinimized();
- }
- }
+// if(_ifaceppp->data()->get_iconify_on_connect()) {
+// // p_kppp->con_win->showMinimized();
+// }
+// }
- Modem::modem->closetty();
+ _ifaceppp->modem()->closetty();
}
@@ -1169,15 +1165,15 @@ bool ConnectWidget::execppp() {
// which is the serial port we connected stdin/stdout to in opener.cpp.
// command += " ";
- // command += PPPData::data()->modemDevice();
+ // command += _ifaceppp->data()->modemDevice();
- command += " " + PPPData::data()->speed();
+ command += " " + _ifaceppp->data()->speed();
command += " -detach";
- if(PPPData::data()->ipaddr() != "0.0.0.0" ||
- PPPData::data()->gateway() != "0.0.0.0") {
- if(PPPData::data()->ipaddr() != "0.0.0.0") {
+ if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
+ _ifaceppp->data()->gateway() != "0.0.0.0") {
+ if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
command += " ";
- command += PPPData::data()->ipaddr();
+ command += _ifaceppp->data()->ipaddr();
command += ":";
}
@@ -1187,13 +1183,13 @@ bool ConnectWidget::execppp() {
}
- if(PPPData::data()->gateway() != "0.0.0.0")
- command += PPPData::data()->gateway();
+ if(_ifaceppp->data()->gateway() != "0.0.0.0")
+ command += _ifaceppp->data()->gateway();
}
- if(PPPData::data()->subnetmask() != "0.0.0.0")
- command += " netmask " + PPPData::data()->subnetmask();
+ if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
+ command += " netmask " + _ifaceppp->data()->subnetmask();
- if(PPPData::data()->flowcontrol() != "None") {
- if(PPPData::data()->flowcontrol() == "CRTSCTS")
+ if(_ifaceppp->data()->flowcontrol() != "None") {
+ if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
command += " crtscts";
else
@@ -1201,11 +1197,11 @@ bool ConnectWidget::execppp() {
}
- if(PPPData::data()->defaultroute())
+ if(_ifaceppp->data()->defaultroute())
command += " defaultroute";
- if(PPPData::data()->autoDNS())
+ if(_ifaceppp->data()->autoDNS())
command += " usepeerdns";
- QStringList &arglist = PPPData::data()->pppdArgument();
+ QStringList &arglist = _ifaceppp->data()->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
@@ -1216,23 +1212,23 @@ bool ConnectWidget::execppp() {
// PAP settings
- if(PPPData::data()->authMethod() == AUTH_PAP) {
+ if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
command += " -chap user ";
- command = command + "\"" + PPPData::data()->storedUsername() + "\"";
+ command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
}
// CHAP settings
- if(PPPData::data()->authMethod() == AUTH_CHAP) {
+ if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
command += " -pap user ";
- command = command + "\"" + PPPData::data()->storedUsername() + "\"";
+ command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
}
// PAP/CHAP settings
- if(PPPData::data()->authMethod() == AUTH_PAPCHAP) {
+ if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
command += " user ";
- command = command + "\"" + PPPData::data()->storedUsername() + "\"";
+ command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
}
// check for debug
- if(PPPData::data()->getPPPDebug())
+ if(_ifaceppp->data()->getPPPDebug())
command += " debug";
@@ -1248,5 +1244,5 @@ bool ConnectWidget::execppp() {
qApp->flushX();
- return Modem::modem->execPPPDaemon(command);
+ return _ifaceppp->modem()->execPPPDaemon(command);
}
@@ -1263,9 +1259,9 @@ void ConnectWidget::setMsg(const QString &msg) {
void ConnectWidget::writeline(const QString &s) {
- Modem::modem->writeLine(s.local8Bit());
+ _ifaceppp->modem()->writeLine(s.local8Bit());
}
// Set the hostname and domain from DNS Server
-void auto_hostname() {
+void auto_hostname(InterfacePPP *_ifaceppp) {
struct in_addr local_ip;
struct hostent *hostname_entry;
@@ -1278,6 +1274,6 @@ void auto_hostname() {
old_hostname=tmp_str; // copy to QString
- // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) {
- if ( PPPData::data()->autoname()) {
+ // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
+ if ( _ifaceppp->data()->autoname()) {
// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
@@ -1287,5 +1283,5 @@ void auto_hostname() {
dot=new_hostname.find('.');
new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
- Modem::modem->setHostname(new_hostname);
+ _ifaceppp->modem()->setHostname(new_hostname);
modified_hostname = TRUE;
@@ -1293,5 +1289,5 @@ void auto_hostname() {
new_hostname.remove(0,dot+1);
- add_domain(new_hostname);
+ add_domain(new_hostname, _ifaceppp);
}
}
@@ -1301,5 +1297,5 @@ void auto_hostname() {
// Replace the DNS domain entry in the /etc/resolv.conf file and
// disable the nameserver entries if option is enabled
-void add_domain(const QString &domain) {
+void add_domain(const QString &domain, InterfacePPP *_ifaceppp) {
int fd;
@@ -1310,5 +1306,5 @@ void add_domain(const QString &domain) {
return;
- if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
int i=0;
@@ -1324,5 +1320,5 @@ void add_domain(const QString &domain) {
if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
- if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
QCString tmp = "domain " + domain.local8Bit() +
" \t\t#kppp temp entry\n";
@@ -1333,5 +1329,5 @@ void add_domain(const QString &domain) {
( resolv[j].contains("nameserver")
&& !resolv[j].contains("#kppp temp entry")
- && PPPData::data()->exDNSDisabled()))
+ && _ifaceppp->data()->exDNSDisabled()))
&& !resolv[j].contains("#entry disabled by kppp")) {
QCString tmp = "# " + resolv[j].local8Bit() +
@@ -1351,10 +1347,10 @@ void add_domain(const QString &domain) {
// adds the DNS entries in the /etc/resolv.conf file
-void adddns()
+void adddns( InterfacePPP *_ifaceppp)
{
int fd;
- if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
- QStringList &dnslist = PPPData::data()->dns();
+ if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
+ QStringList &dnslist = _ifaceppp->data()->dns();
for ( QStringList::Iterator it = dnslist.begin();
it != dnslist.end();
@@ -1367,11 +1363,11 @@ void adddns()
close(fd);
}
- add_domain(PPPData::data()->domain());
+ add_domain(_ifaceppp->data()->domain(), _ifaceppp);
}
-void addpeerdns() {
+void addpeerdns(InterfacePPP *_ifaceppp) {
int fd, fd2;
- if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
char c;
@@ -1388,9 +1384,9 @@ void addpeerdns() {
close(fd);
}
- add_domain(PPPData::data()->domain());
+ add_domain(_ifaceppp->data()->domain(), _ifaceppp);
}
// remove the dns entries from the /etc/resolv.conf file
-void removedns() {
+void removedns(InterfacePPP *_ifaceppp) {
int fd;
@@ -1398,5 +1394,5 @@ void removedns() {
QString resolv[MAX_RESOLVCONF_LINES];
- if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
int i=0;
@@ -1411,5 +1407,5 @@ void removedns() {
close(fd);
- if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
for(int j=0; j < i; j++) {
if(resolv[j].contains("#kppp temp entry")) continue;
@@ -1430,5 +1426,5 @@ void removedns() {
if ( modified_hostname ) {
- Modem::modem->setHostname(old_hostname);
+ _ifaceppp->modem()->setHostname(old_hostname);
modified_hostname = FALSE;
}