From a7e015198a8c5ad3b6e144a9032b059086253e00 Mon Sep 17 00:00:00 2001 From: kergoth Date: Sat, 09 Aug 2003 17:14:54 +0000 Subject: Merge from BRANCH_1_0 --- (limited to 'noncore/settings/networksettings/ppp/interfaceppp.cpp') diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index 9ec30bc..f443f3c 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp @@ -1,6 +1,8 @@ #include -#define i18n QObject::tr +#include +#include +#include #include "auth.h" #include "interfaceppp.h" @@ -15,18 +17,18 @@ InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) qDebug("InterfacePPP::InterfacePPP("); } -PPPData* InterfacePPP::data() +PPPData* InterfacePPP::data()const { if (!_dataPtr){ qDebug("creating new Data obj"); _dataPtr = new PPPData(); - _dataPtr->setModemDevice( getInterfaceName() ); + _dataPtr->setDevice( getInterfaceName() ); _dataPtr->setAccount( getHardwareName() ); } return _dataPtr; } -Modem* InterfacePPP::modem() +Modem* InterfacePPP::modem()const { if (!_modemPtr){ qDebug("creating new modem obj"); @@ -38,27 +40,42 @@ Modem* InterfacePPP::modem() bool InterfacePPP::refresh() { qDebug("InterfacePPP::refresh()"); - updateInterface(this); - QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); - return false; + QString old = getInterfaceName(); + setInterfaceName( modem()->pppDevice() ); + + (void)Interface::refresh(); + + setInterfaceName( old ); + emit updateInterface(this); + + return true; } void InterfacePPP::start() { qDebug("InterfacePPP::start"); -// should work... -// if (data()->password().isEmpty() ){ -// //FIXME: ask for password -// qDebug("using dummy password"); -// QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)"); -// } + if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { + + QDialog mb( 0, "Dialog", true ); + mb.setCaption( tr( "No password" ) ); + QVBoxLayout layout( &mb ); + QLabel text ( &mb ); + text.setText( tr("Username defined but no password\n Please enter a password") ); + QLineEdit lineedit( &mb ); + lineedit.setEchoMode( QLineEdit::Password ); + layout.addWidget( &text ); + layout.addWidget( &lineedit ); + if ( mb.exec() == QDialog::Accepted ) { + data()->setPassword( lineedit.text() ); + } + } QFileInfo info(pppdPath()); if(!info.exists()){ QMessageBox::warning(0, tr("Error"), - i18n("Cannot find the PPP daemon!
" + QObject::tr("Cannot find the PPP daemon!
" "Make sure that pppd is installed and " "that you have entered the correct path.
")); return; @@ -67,7 +84,7 @@ void InterfacePPP::start() if(!info.isExecutable()){ QString string; - string = i18n( "Cannot execute:
%1
" + string = QObject::tr( "Cannot execute:
%1
" "Please make sure that you have given " "setuid permission and that " "pppd is executable.
").arg(pppdPath()); @@ -81,7 +98,7 @@ void InterfacePPP::start() if(!info2.exists()){ QString string; - string = i18n( "Cannot find:
%1
" + string = QObject::tr( "Cannot find:
%1
" "Please make sure you have setup " "your modem device properly " "and/or adjust the location of the modem device on " @@ -98,7 +115,7 @@ void InterfacePPP::start() data()->authMethod() == AUTH_PAPCHAP ) { if(false){ //FIXME: ID_Edit->text().isEmpty()) { QMessageBox::warning(0,tr("Error"), - i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); + QObject::tr("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); // FIXME: return; } else { if(!modem()->setSecret(data()->authMethod(), @@ -106,7 +123,7 @@ void InterfacePPP::start() PPPData::encodeWord(data()->password())) ) { QString s; - s = i18n("Cannot create PAP/CHAP authentication
" + s = QObject::tr("Cannot create PAP/CHAP authentication
" "file \"%1\"
").arg(PAP_AUTH_FILE); QMessageBox::warning(0, tr("Error"), s); return; @@ -115,7 +132,7 @@ void InterfacePPP::start() } if (data()->phonenumber().isEmpty()) { - QString s = i18n("You must specify a telephone number!"); + QString s = QObject::tr("You must specify a telephone number!"); QMessageBox::warning(0, tr("Error"), s); return; } @@ -132,6 +149,11 @@ void InterfacePPP::start() void InterfacePPP::stop() { qDebug("InterfacePPP::stop"); + // emit hangup_now(); + status = false; // not connected + setStatus( false ); + emit hangup_now(); + refresh(); } @@ -140,3 +162,13 @@ void InterfacePPP::save() data()->save(); emit updateInterface((Interface*) this); } +QString InterfacePPP::pppDev()const { + return modem()->pppDevice(); +} +pid_t InterfacePPP::pppPID()const{ + return modem()->pppPID(); +} +void InterfacePPP::setPPPDpid( pid_t pid) { + setStatus( true ); + modem()->setPPPDPid( pid ); +} -- cgit v0.9.0.2