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.cpp166
1 files changed, 95 insertions, 71 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 2400d7b..e3fab24 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -31,9 +31,8 @@
#include <qapplication.h>
//#include <kdebug.h>
//#include <klocale.h>
-#define i18n QObject::tr
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <unistd.h>
@@ -98,40 +97,40 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam
{
modified_hostname = false;
QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
- QString tit = i18n("Connecting to: ");
+ QString tit = QObject::tr("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->setText(QObject::tr("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);
if (_ifaceppp->getStatus())
- messg->setText(i18n("Online"));
+ messg->setText(QObject::tr("Online"));
else
- messg->setText(i18n("Offline"));
+ messg->setText(QObject::tr("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 = new QPushButton(QObject::tr("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 = new QPushButton(QObject::tr("Cancel"), this);
cancel->setFocus();
connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
// int maxw = QMAX(cancel->sizeHint().width(),
@@ -172,9 +171,9 @@ 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..."));
+ messg->setText(QObject::tr("Looking for modem..."));
inittimer->start(100);
}
@@ -200,17 +199,17 @@ void ConnectWidget::init() {
comlist = &_ifaceppp->data()->scriptType();
arglist = &_ifaceppp->data()->script();
- QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname());
+ QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname());
setCaption(tit);
qApp->processEvents();
// run the "before-connect" command
if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
- messg->setText(i18n("Running pre-startup command..."));
- emit debugMessage(i18n("Running pre-startup command..."));
+ messg->setText(QObject::tr("Running pre-startup command..."));
+ emit debugMessage(QObject::tr("Running pre-startup command..."));
qApp->processEvents();
QApplication::flushX();
pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
@@ -225,15 +224,15 @@ void ConnectWidget::init() {
int lock = _ifaceppp->modem()->lockdevice();
if (lock == 1) {
- messg->setText(i18n("Modem device is locked."));
+ messg->setText(QObject::tr("Modem device is locked."));
vmain = 20; // wait until cancel is pressed
return;
}
if (lock == -1) {
- messg->setText(i18n("Unable to create modem lock file."));
+ messg->setText(QObject::tr("Unable to create modem lock file."));
vmain = 20; // wait until cancel is pressed
return;
}
@@ -278,10 +277,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
assert(PPPData::NumInitStrings > 0);
// first init string ?
if(substate == -1) {
- messg->setText(i18n("Initializing modem..."));
- emit debugMessage(i18n("Initializing modem..."));
+ messg->setText(QObject::tr("Initializing modem..."));
+ emit debugMessage(QObject::tr("Initializing modem..."));
substate = 0;
}
QString initStr = _ifaceppp->data()->modemInitStr(substate);
@@ -316,9 +315,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if (vmain == 5) {
if(!expecting) {
QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
- QString msg = i18n("Setting ") + sToneDuration;
+ QString msg = QObject::tr("Setting ") + sToneDuration;
messg->setText(msg);
emit debugMessage(msg);
setExpect(_ifaceppp->data()->modemInitResp());
writeline(sToneDuration);
@@ -339,10 +338,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(_ifaceppp->data()->volumeInitString().isEmpty()) {
vmain = 4;
return;
}
- messg->setText(i18n("Setting speaker volume..."));
- emit debugMessage(i18n("Setting speaker volume..."));
+ messg->setText(QObject::tr("Setting speaker volume..."));
+ emit debugMessage(QObject::tr("Setting speaker volume..."));
setExpect(_ifaceppp->data()->modemInitResp());
QString vol("AT");
vol += _ifaceppp->data()->volumeInitString();
@@ -355,9 +354,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(vmain == 4) {
if(!expecting) {
if(!_ifaceppp->data()->waitForDialTone()) {
- QString msg = i18n("Turning off dial tone waiting...");
+ QString msg = QObject::tr("Turning off dial tone waiting...");
messg->setText(msg);
emit debugMessage(msg);
setExpect(_ifaceppp->data()->modemInitResp());
writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
@@ -376,9 +375,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
QStringList &plist = _ifaceppp->data()->phonenumbers();
QString bmarg= _ifaceppp->data()->dialPrefix();
bmarg += *plist.at(dialnumber);
- QString bm = i18n("Dialing %1").arg(bmarg);
+ QString bm = QObject::tr("Dialing %1").arg(bmarg);
messg->setText(bm);
emit debugMessage(bm);
QString pn = _ifaceppp->data()->modemDialStr();
@@ -407,14 +406,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
timeout_timer->stop();
timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
- messg->setText(i18n("Line busy. Hanging up..."));
+ messg->setText(QObject::tr("Line busy. Hanging up..."));
emit debugPutChar('\n');
_ifaceppp->modem()->hangup();
if(_ifaceppp->data()->busyWait() > 0) {
- QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
+ QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
messg->setText(bm);
emit debugMessage(bm);
pausing = true;
@@ -431,18 +430,18 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
timeout_timer->stop();
- messg->setText(i18n("No Dialtone"));
+ messg->setText(QObject::tr("No Dialtone"));
vmain = 20;
_ifaceppp->modem()->unlockdevice();
return;
}
if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
timeout_timer->stop();
- messg->setText(i18n("No Carrier"));
+ messg->setText(QObject::tr("No Carrier"));
vmain = 20;
_ifaceppp->modem()->unlockdevice();
return;
}
@@ -478,9 +477,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
return;
}
if (scriptCommand == "Scan") {
- QString bm = i18n("Scanning %1").arg(scriptArgument);
+ QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
setScan(scriptArgument);
@@ -488,9 +487,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
return;
}
if (scriptCommand == "Save") {
- QString bm = i18n("Saving %1").arg(scriptArgument);
+ QString bm = QObject::tr("Saving %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
if (scriptArgument.lower() == "password") {
@@ -506,9 +505,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
- QString bm = i18n("Sending %1");
+ QString bm = QObject::tr("Sending %1");
// replace %USERNAME% and %PASSWORD%
QString arg = scriptArgument;
QRegExp re1("%USERNAME%");
@@ -531,9 +530,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
return;
}
if (scriptCommand == "Expect") {
- QString bm = i18n("Expecting %1").arg(scriptArgument);
+ QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
// The incrementing of the scriptindex MUST be before the
@@ -545,9 +544,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
if (scriptCommand == "Pause") {
- QString bm = i18n("Pause %1 seconds").arg(scriptArgument);
+ QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
pausing = true;
@@ -562,9 +561,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if (scriptCommand == "Timeout") {
timeout_timer->stop();
- QString bm = i18n("Timeout %1 seconds").arg(scriptArgument);
+ QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
scriptTimeout=scriptArgument.toInt()*1000;
@@ -574,10 +573,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
return;
}
if (scriptCommand == "Hangup") {
- messg->setText(i18n("Hangup"));
- emit debugMessage(i18n("Hangup"));
+ messg->setText(QObject::tr("Hangup"));
+ emit debugMessage(QObject::tr("Hangup"));
writeline(_ifaceppp->data()->modemHangupStr());
setExpect(_ifaceppp->data()->modemHangupResp());
@@ -588,18 +587,18 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
if (scriptCommand == "Answer") {
timeout_timer->stop();
- messg->setText(i18n("Answer"));
- emit debugMessage(i18n("Answer"));
+ messg->setText(QObject::tr("Answer"));
+ emit debugMessage(QObject::tr("Answer"));
setExpect(_ifaceppp->data()->modemRingResp());
vmain = 150;
return;
}
if (scriptCommand == "ID") {
- QString bm = i18n("ID %1").arg(scriptArgument);
+ QString bm = QObject::tr("ID %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
QString idstring = _ifaceppp->data()->password();
@@ -633,9 +632,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
}
if (scriptCommand == "Password") {
- QString bm = i18n("Password %1").arg(scriptArgument);
+ QString bm = QObject::tr("Password %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
QString pwstring = _ifaceppp->data()->password();
@@ -670,9 +669,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
}
if (scriptCommand == "Prompt") {
- QString bm = i18n("Prompting %1");
+ QString bm = QObject::tr("Prompting %1");
// if the scriptindex (aka the prompt text) includes a ## marker
// this marker should get substituted with the contents of our stored
// variable (from the subsequent scan).
@@ -707,9 +706,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
}
if (scriptCommand == "PWPrompt") {
- QString bm = i18n("PW Prompt %1").arg(scriptArgument);
+ QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
/* if not around yet, then post window... */
@@ -732,20 +731,20 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
if (scriptCommand == "LoopStart") {
- QString bm = i18n("Loop Start %1").arg(scriptArgument);
+ QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
// The incrementing of the scriptindex MUST be before the
// call to setExpect otherwise the expect will miss a string that is
// already in the buffer.
scriptindex++;
if ( loopnest > (MAXLOOPNEST-2) ) {
- bm += i18n("ERROR: Nested too deep, ignored.");
+ bm += QObject::tr("ERROR: Nested too deep, ignored.");
vmain=20;
cancelbutton();
- QMessageBox::critical(0, "error", i18n("Loops nested too deeply!"));
+ QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
} else {
setExpect(scriptArgument);
loopstartindex[loopnest] = scriptindex;
loopstr[loopnest] = scriptArgument;
@@ -757,11 +756,11 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
if (scriptCommand == "LoopEnd") {
- QString bm = i18n("Loop End %1").arg(scriptArgument);
+ QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
if ( loopnest <= 0 ) {
- bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm);
+ bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
vmain=20;
cancelbutton();
QMessageBox::critical(0, "error", bm);
return;
@@ -847,9 +846,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
qApp->flushX();
semaphore = true;
result = execppp();
- emit debugMessage(i18n("Starting pppd..."));
+ emit debugMessage(QObject::tr("Starting pppd..."));
qDebug("execppp() returned with return-code %i", result );
if(result) {
if(!_ifaceppp->data()->autoDNS())
@@ -929,9 +928,9 @@ void ConnectWidget::checkBuffers() {
scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
scanvar = scanvar.stripWhiteSpace();
// Show the Variabel content in the debug window
- QString sv = i18n("Scan Var: %1").arg(scanvar);
+ QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
emit debugMessage(sv);
}
if(expecting) {
@@ -939,9 +938,9 @@ void ConnectWidget::checkBuffers() {
expecting = false;
// keep everything after the expected string
readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
- QString ts = i18n("Found: %1").arg(expectstr);
+ QString ts = QObject::tr("Found: %1").arg(expectstr);
emit debugMessage(ts);
if (loopend) {
loopend=false;
@@ -950,9 +949,9 @@ void ConnectWidget::checkBuffers() {
if (loopend && readbuffer.contains(loopstr[loopnest])) {
expecting = false;
readbuffer = "";
- QString ts = i18n("Looping: %1").arg(loopstr[loopnest]);
+ QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
emit debugMessage(ts);
scriptindex = loopstartindex[loopnest];
loopend = false;
loopnest++;
@@ -983,9 +982,9 @@ void ConnectWidget::cancelbutton() {
// termwindow = 0L;
// this->show();
// }
- messg->setText(i18n("One moment please..."));
+ messg->setText(QObject::tr("One moment please..."));
// just to be sure
_ifaceppp->modem()->removeSecret(AUTH_PAP);
_ifaceppp->modem()->removeSecret(AUTH_CHAP);
@@ -1005,13 +1004,16 @@ void ConnectWidget::cancelbutton() {
_ifaceppp->modem()->unlockdevice();
//abort prompt window...
if (prompt->isVisible()) {
- prompt->hide();
+ prompt->hide();
}
prompt->setConsumed();
- messg->setText(tr("offline"));
+ _ifaceppp->setStatus( false );
+ _ifaceppp->refresh();
+// messg->setText(tr("offline"));
+ refresh();
}
void ConnectWidget::script_timed_out() {
@@ -1025,9 +1027,9 @@ void ConnectWidget::script_timed_out() {
if (prompt->isVisible())
prompt->hide();
prompt->setConsumed();
- messg->setText(i18n("Script timed out!"));
+ messg->setText(QObject::tr("Script timed out!"));
_ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
@@ -1040,18 +1042,18 @@ void ConnectWidget::setScan(const QString &n) {
scanning = true;
scanstr = n;
scanbuffer = "";
- QString ts = i18n("Scanning: %1").arg(n);
+ QString ts = QObject::tr("Scanning: %1").arg(n);
emit debugMessage(ts);
}
void ConnectWidget::setExpect(const QString &n) {
expecting = true;
expectstr = n;
- QString ts = i18n("Expecting: %1").arg(n);
+ QString ts = QObject::tr("Expecting: %1").arg(n);
ts.replace(QRegExp("\n"), "<LF>");
emit debugMessage(ts);
// check if the expected string is in the read buffer already.
@@ -1084,9 +1086,9 @@ void ConnectWidget::pppdDied()
if_timeout_timer->stop();
}
void ConnectWidget::if_waiting_slot() {
- messg->setText(i18n("Logging on to network..."));
+ messg->setText(QObject::tr("Logging on to network..."));
// if(!stats->ifIsUp()) {
// if(_ifaceppp->data()->pppdError() != 0) {
@@ -1115,28 +1117,33 @@ void ConnectWidget::if_waiting_slot() {
// 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..."));
+ messg->setText(QObject::tr("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"));
+ messg->setText(QObject::tr("Done"));
}
// remove the authentication file
_ifaceppp->modem()->removeSecret(AUTH_PAP);
_ifaceppp->modem()->removeSecret(AUTH_CHAP);
- emit debugMessage(i18n("Done"));
+ emit debugMessage(QObject::tr("Done"));
set_con_speed_string();
// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
- this->hide();
- messg->setText("");
+// this->hide();
+// messg->setText("");
_ifaceppp->setStatus( true );
+
+ m_refreshTimer = new QTimer( this );
+ connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
+ m_refreshTimer->start( 3000 );
+ //_ifaceppp->refresh();
// emit _ifaceppp->updateInterface(_ifaceppp);
// prepare the con_win so as to have the right size for
// accounting / non-accounting mode
@@ -1160,8 +1167,17 @@ void ConnectWidget::if_waiting_slot() {
_ifaceppp->modem()->closetty();
}
+void ConnectWidget::refresh() {
+ _ifaceppp->refresh();
+ if ( _ifaceppp->getStatus() ) {
+ messg->setText(QObject::tr("Online"));
+ } else {
+ messg->setText(QObject::tr("Offline"));
+ }
+}
+
bool ConnectWidget::execppp() {
QString command;
@@ -1209,47 +1225,55 @@ bool ConnectWidget::execppp() {
if(_ifaceppp->data()->autoDNS())
command += " usepeerdns";
- QStringList &arglist = _ifaceppp->data()->pppdArgument();
- for ( QStringList::Iterator it = arglist.begin();
- it != arglist.end();
- ++it )
- {
- command += " " + *it;
- }
// PAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
command += " -chap user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ command = command + _ifaceppp->data()->storedUsername();
}
// CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
command += " -pap user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ command = command + _ifaceppp->data()->storedUsername();
}
// PAP/CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
- command += " user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ QString tmpName = _ifaceppp->data()->storedUsername();
+ if ( !tmpName.isEmpty() ) {
+ command += " user ";
+ command = command + tmpName;
+ }
}
// check for debug
if(_ifaceppp->data()->getPPPDebug())
command += " debug";
+ QStringList &arglist = _ifaceppp->data()->pppdArgument();
+ for ( QStringList::Iterator it = arglist.begin();
+ it != arglist.end();
+ ++it )
+ {
+ command += " " + *it;
+ }
+
+ command += " call opie-kppp logfd 11";
+
if (command.length() > MAX_CMDLEN) {
- QMessageBox::critical(this, "error", i18n(
+ QMessageBox::critical(this, "error", QObject::tr(
"pppd command + command-line arguments exceed "
"2024 characters in length."
));
return false; // nonsensically long command which would bust my buffer buf.
}
+ qWarning("Command IS: %s",command.latin1() );
+
qApp->flushX();
return _ifaceppp->modem()->execPPPDaemon(command);
}