summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 6905d79..2400d7b 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -52,129 +52,132 @@
#define __xnet_connect connect
#endif
#include <errno.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef __linux__
#include "runtests.h"
#endif
#include "auth.h"
#include "connect.h"
//#include "docking.h"
#include "interfaceppp.h"
#include "modem.h"
#include "kpppconfig.h"
#include "pppdata.h"
#include "kpppwidget.h"
//#include "requester.h"
//#include "utils.h"
#define execute_command system
QString old_hostname;
bool modified_hostname;
ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
: QWidget(parent, name),
myreadbuffer(""),
main_timer_ID(0),
vmain(0),
substate(-1),
scriptindex(0),
loopnest(0),
loopend(false),
semaphore(false),
expecting(false),
readbuffer(""),
scanvar(""),
scanning(false),
pausing(false),
dialnumber(0),
_ifaceppp(ifp)
{
modified_hostname = false;
QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
QString tit = i18n("Connecting to: ");
setCaption(tit);
QHBoxLayout *l0 = new QHBoxLayout(10);
tl->addLayout(l0);
l0->addSpacing(10);
messg = new QLabel(this, "messg");
messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
messg->setAlignment(AlignCenter);
messg->setText(i18n("Unable to create modem lock file."));
messg->setMinimumHeight(messg->sizeHint().height() + 5);
// int messw = (messg->sizeHint().width() * 12) / 10;
// messw = QMAX(messw,280);
// messg->setMinimumWidth(messw);
- messg->setText(i18n("Offline"));
+ if (_ifaceppp->getStatus())
+ messg->setText(i18n("Online"));
+ else
+ messg->setText(i18n("Offline"));
l0->addSpacing(10);
l0->addWidget(messg);
l0->addSpacing(10);
QHBoxLayout *l1 = new QHBoxLayout(10);
tl->addLayout(l1);
l1->addStretch(1);
debug = new QPushButton(i18n("Log"), this);
debug->setToggleButton(true);
debug->setEnabled( false ); // FIXME: disable the log button
connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
cancel = new QPushButton(i18n("Cancel"), this);
cancel->setFocus();
connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
// int maxw = QMAX(cancel->sizeHint().width(),
// debug->sizeHint().width());
// maxw = QMAX(maxw,65);
// debug->setFixedWidth(maxw);
// cancel->setFixedWidth(maxw);
l1->addWidget(debug);
l1->addWidget(cancel);
// setFixedSize(sizeHint());
pausetimer = new QTimer(this);
connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
qApp->processEvents();
timeout_timer = new QTimer(this);
connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
inittimer = new QTimer(this);
connect(inittimer, SIGNAL(timeout()), SLOT(init()));
if_timeout_timer = new QTimer(this);
connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
prompt = new PWEntry( this, "pw" );
if_timer = new QTimer(this);
connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
}
ConnectWidget::~ConnectWidget() {
}
void ConnectWidget::preinit() {
// this is all just to keep the GUI nice and snappy ....
// you have to see to believe ...
messg->setText(i18n("Looking for modem..."));
inittimer->start(100);
}
void ConnectWidget::init() {
_ifaceppp->data()->setpppdError(0);
inittimer->stop();
@@ -1071,128 +1074,131 @@ void ConnectWidget::if_waiting_timed_out() {
// killing ppp will generate a SIGCHLD which will be caught in pppdie()
// in main.cpp what happens next will depend on the boolean
// reconnect_on_disconnect which is set in ConnectWidget::init();
}
void ConnectWidget::pppdDied()
{
if_timer->stop();
if_timeout_timer->stop();
}
void ConnectWidget::if_waiting_slot() {
messg->setText(i18n("Logging on to network..."));
// if(!stats->ifIsUp()) {
// if(_ifaceppp->data()->pppdError() != 0) {
// // we are here if pppd died immediately after starting it.
// pppdDied();
// // error message handled in main.cpp: sigPPPDDied()
// return;
// }
// if_timer->start(100, TRUE); // single shot
// return;
// }
// O.K the ppp interface is up and running
// give it a few time to come up completly (0.2 seconds)
if_timeout_timer->stop();
if_timer->stop();
usleep(200000);
if(_ifaceppp->data()->autoDNS())
addpeerdns( _ifaceppp );
// Close the debugging window. If we are connected, we
// are not really interested in debug output
emit closeDebugWindow();
// p_kppp->statdlg->take_stats(); // start taking ppp statistics
auto_hostname(_ifaceppp);
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(_ifaceppp->data()->command_on_connect());
messg->setText(i18n("Done"));
}
// remove the authentication file
_ifaceppp->modem()->removeSecret(AUTH_PAP);
_ifaceppp->modem()->removeSecret(AUTH_CHAP);
emit debugMessage(i18n("Done"));
set_con_speed_string();
// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
this->hide();
messg->setText("");
+ _ifaceppp->setStatus( true );
+ // emit _ifaceppp->updateInterface(_ifaceppp);
+
// prepare the con_win so as to have the right size for
// accounting / non-accounting mode
// if(p_kppp->acct != 0)
// p_kppp->con_win->accounting(p_kppp->acct->running());
// else
// p_kppp->con_win->accounting(false);
// 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(_ifaceppp->data()->get_iconify_on_connect()) {
// // p_kppp->con_win->showMinimized();
// }
// }
_ifaceppp->modem()->closetty();
}
bool ConnectWidget::execppp() {
QString command;
command = "pppd";
// as of version 2.3.6 pppd falls back to the real user rights when
// opening a device given in a command line. To avoid permission conflicts
// we'll simply leave this argument away. pppd will then use the default tty
// which is the serial port we connected stdin/stdout to in opener.cpp.
// command += " ";
// command += _ifaceppp->data()->modemDevice();
command += " " + _ifaceppp->data()->speed();
command += " -detach";
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 += _ifaceppp->data()->ipaddr();
command += ":";
}
else {
command += " ";
command += ":";
}
if(_ifaceppp->data()->gateway() != "0.0.0.0")
command += _ifaceppp->data()->gateway();
}
if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
command += " netmask " + _ifaceppp->data()->subnetmask();
if(_ifaceppp->data()->flowcontrol() != "None") {
if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
command += " crtscts";
else
command += " xonxoff";