summaryrefslogtreecommitdiff
authortille <tille>2003-05-30 15:06:17 (UTC)
committer tille <tille>2003-05-30 15:06:17 (UTC)
commit8699d02f6c152afed9490e7e7a4315044261e6e8 (patch) (side-by-side diff)
treed2ee2ba401c7a9db0e33beaf0617a1456fe01d50
parentd8cec07fe5e54a68afe4feca574f9f4d2433e0c1 (diff)
downloadopie-8699d02f6c152afed9490e7e7a4315044261e6e8.zip
opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.gz
opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.bz2
modem and pppdata is now member of interfaceppp
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp70
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h4
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp326
-rw-r--r--noncore/settings/networksettings/ppp/connect.h22
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp245
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.h12
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp123
-rw-r--r--noncore/settings/networksettings/ppp/edit.h20
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp59
-rw-r--r--noncore/settings/networksettings/ppp/general.h10
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp24
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.h25
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp48
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.h30
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp463
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.h11
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp45
-rw-r--r--noncore/settings/networksettings/ppp/modem.h7
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp112
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.h3
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp37
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.h5
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro8
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp29
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h7
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp250
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h62
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp31
30 files changed, 1125 insertions, 981 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 11d4739..3fa2f84 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -41,26 +41,26 @@
//#include <kwin.h>
//#include <kdialogbase.h>
#include <qvgroupbox.h>
#include "pppdata.h"
#include "accounts.h"
//#include "accounting.h"
//#include "providerdb.h"
#include "edit.h"
void parseargs(char* buf, char** args);
-AccountWidget::AccountWidget( QWidget *parent, const char *name )
- : QWidget( parent, name )
+AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
+ : QWidget( parent, name ), _pppdata(pd)
{
QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
accountlist_l = new QListBox(this);
connect(accountlist_l, SIGNAL(highlighted(int)),
this, SLOT(slotListBoxSelect(int)));
connect(accountlist_l, SIGNAL(selected(int)),
this, SLOT(editaccount()));
l1->addWidget(accountlist_l, 10);
edit_b = new QPushButton(i18n("&Edit..."), this);
connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
@@ -143,50 +143,50 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
// reset->setEnabled(FALSE);
// connect(reset, SIGNAL(clicked()),
// this, SLOT(resetClicked()));
// l122->addWidget(reset);
// log = new QPushButton(i18n("&View Logs"), this);
// connect(log, SIGNAL(clicked()),
// this, SLOT(viewLogClicked()));
// l122->addWidget(log);
// l122->addStretch(1);
//load up account list from gppdata to the list box
- if(PPPData::data()->count() > 0) {
- for(int i=0; i <= PPPData::data()->count()-1; i++) {
- PPPData::data()->setAccountbyIndex(i);
- accountlist_l->insertItem(PPPData::data()->accname());
+ if(_pppdata->count() > 0) {
+ for(int i=0; i <= _pppdata->count()-1; i++) {
+ _pppdata->setAccountbyIndex(i);
+ accountlist_l->insertItem(_pppdata->accname());
}
}
// slotListBoxSelect(accountlist_l->currentItem());
- qDebug("setting listview index to %i",PPPData::data()->currentAccountID() );
- accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() );
-// slotListBoxSelect( PPPData::data()->currentAccountID());
+ qDebug("setting listview index to %i",_pppdata->currentAccountID() );
+ accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
+// slotListBoxSelect( _pppdata->currentAccountID());
l1->activate();
}
void AccountWidget::slotListBoxSelect(int idx) {
delete_b->setEnabled((bool)(idx != -1));
edit_b->setEnabled((bool)(idx != -1));
copy_b->setEnabled((bool)(idx != -1));
if(idx!=-1) {
qDebug("setting account to %i", idx);
- QString account = PPPData::data()->accname();
- PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
- // PPPData::data()->setAccount(account);
+ QString account = _pppdata->accname();
+ _pppdata->setAccountbyIndex(accountlist_l->currentItem());
+ // _pppdata->setAccount(account);
}
}
// void AccountWidget::viewLogClicked(){
// QApplication::flushX();
// if(fork() == 0) {
// setgid(getgid());
// setuid(getuid());
// system("kppplogview -kppp");
// _exit(0);
@@ -205,153 +205,153 @@ void AccountWidget::slotListBoxSelect(int idx) {
// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem()));
// // costedit->setText("0");
// // }
// // if(what && QueryReset::VOLUME) {
// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem()));
// // voledit->setText(prettyPrintVolume(0));
// // }
// }
void AccountWidget::editaccount() {
- PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
+ _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
- accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
+ accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
// emit resetaccounts();
- PPPData::data()->save();
+ _pppdata->save();
}
}
void AccountWidget::newaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
return;
}
int result;
// int query = QMessageBox::information(this,
// i18n("Do you want to use the wizard to create the new account or the "
// "standard, dialog-based setup?\n"
// "The wizard is easier and sufficient in most cases. If you need "
// "very special settings, you might want to try the standard, "
// "dialog-based setup."),
// i18n("Create New Account"),
// i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
// switch(query) {
// case QMessageBox::Yes:
// {
-// if (PPPData::data()->newaccount() == -1)
+// if (_pppdata->newaccount() == -1)
// return;
// // ProviderDB pdb(this);
// // result = pdb.exec();
// break;
// }
// case QMessageBox::No:
- if (PPPData::data()->newaccount() == -1){
- qDebug("PPPData::data()->newaccount() == -1");
+ if (_pppdata->newaccount() == -1){
+ qDebug("_pppdata->newaccount() == -1");
return;
}
result = doTab();
// break;
// default:
// return;
// }
if(result == QDialog::Accepted) {
- accountlist_l->insertItem(PPPData::data()->accname());
- accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
+ accountlist_l->insertItem(_pppdata->accname());
+ accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),
true);
// emit resetaccounts();
- PPPData::data()->save();
+ _pppdata->save();
} else
- PPPData::data()->deleteAccount();
+ _pppdata->deleteAccount();
}
void AccountWidget::copyaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
return;
}
if(accountlist_l->currentItem()<0) {
QMessageBox::information(this, "sorry", i18n("No account selected."));
return;
}
- PPPData::data()->copyaccount(accountlist_l->currentItem());
+ _pppdata->copyaccount(accountlist_l->currentItem());
- accountlist_l->insertItem(PPPData::data()->accname());
+ accountlist_l->insertItem(_pppdata->accname());
// emit resetaccounts();
- PPPData::data()->save();
+ _pppdata->save();
}
void AccountWidget::deleteaccount() {
QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
.arg(accountlist_l->text(accountlist_l->currentItem()));
if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
return;
- if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
+ if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
accountlist_l->removeItem(accountlist_l->currentItem());
emit resetaccounts();
- PPPData::data()->save();
+ _pppdata->save();
slotListBoxSelect(accountlist_l->currentItem());
}
int AccountWidget::doTab(){
QDialog *dlg = new QDialog( this, "newAccount", true );
QVBoxLayout *layout = new QVBoxLayout( dlg );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( dlg, "tabWindow" );
layout->addWidget( tabWindow );
bool isnewaccount;
- if(PPPData::data()->accname().isEmpty()) {
+ if(_pppdata->accname().isEmpty()) {
dlg->setCaption(i18n("New Account"));
isnewaccount = true;
} else {
QString tit = i18n("Edit Account: ");
- tit += PPPData::data()->accname();
+ tit += _pppdata->accname();
dlg->setCaption(tit);
isnewaccount = false;
}
- dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
+ dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
tabWindow->addTab( dial_w, i18n("Dial") );
- ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
+ ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup"));
tabWindow->addTab( ip_w, i18n("IP") );
- gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
+ gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup"));
tabWindow->addTab( gateway_w, i18n("Gateway") );
- dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
+ dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") );
tabWindow->addTab( dns_w, i18n("DNS") );
- script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
+ script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script"));
tabWindow->addTab( script_w, i18n("Login Script") );
- ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
+ ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs"));
tabWindow->addTab( exec_w, i18n("Execute") );
// acct = new AccountingSelector( tabWindow, isnewaccount );
// tabWindow->addTab( acct, i18n("Accounting"));
int result = 0;
bool ok = false;
qDebug("AccountWidget::doTab dlg->showMinimized");
dlg->showMinimized();
while (!ok){
result = dlg->exec();
ok = true;
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
index 751a414..5e8509d 100644
--- a/noncore/settings/networksettings/ppp/accounts.h
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -33,51 +33,53 @@
#include <qlistbox.h>
//#include "acctselect.h"
class QDialog;
class QCheckBox;
class QLineEdit;
class QTabWidget;
class DialWidget;
class ScriptWidget;
class IPWidget;
class DNSWidget;
class GatewayWidget;
+class PPPData;
class AccountWidget : public QWidget {
Q_OBJECT
public:
- AccountWidget( QWidget *parent=0, const char *name=0 );
+ AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 );
~AccountWidget() {}
private slots:
void editaccount();
void copyaccount();
void newaccount();
void deleteaccount();
void slotListBoxSelect(int);
// void resetClicked();
// void viewLogClicked();
private:
int doTab();
signals:
void resetaccounts();
// void resetCosts(const QString &);
// void resetVolume(const QString &);
private:
QString prettyPrintVolume(unsigned int);
+ PPPData *_pppdata;
QTabWidget *tabWindow;
DialWidget *dial_w;
// AccountingSelector *acct;
IPWidget *ip_w;
DNSWidget *dns_w;
GatewayWidget *gateway_w;
ScriptWidget *script_w;
// QPushButton *reset;
// QPushButton *log;
// QLabel *costlabel;
// QLineEdit *costedit;
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
@@ -56,58 +56,54 @@
#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 "main.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
-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),
vmain(0),
substate(-1),
scriptindex(0),
loopnest(0),
loopend(false),
semaphore(false),
expecting(false),
readbuffer(""),
scanvar(""),
scanning(false),
pausing(false),
-// termwindow(0),
-// stats(st),
- dialnumber(0)
+ 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);
@@ -170,303 +166,303 @@ 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() {
- PPPData::data()->setpppdError(0);
+ _ifaceppp->data()->setpppdError(0);
inittimer->stop();
vmain = 0;
substate = -1;
expecting = false;
pausing = false;
scriptindex = 0;
myreadbuffer = "";
scanning = false;
scanvar = "";
firstrunID = true;
firstrunPW = true;
// stats->totalbytes = 0;
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);
qApp->processEvents();
// 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..."));
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;
// do {
// qApp->processEvents();
// i = waitpid(id, &status, WNOHANG);
// usleep(100000);
// } while (i == 0 && errno == 0);
}
- int lock = Modem::modem->lockdevice();
+ int lock = _ifaceppp->modem()->lockdevice();
if (lock == 1) {
messg->setText(i18n("Modem device is locked."));
vmain = 20; // wait until cancel is pressed
return;
}
if (lock == -1) {
messg->setText(i18n("Unable to create modem lock file."));
vmain = 20; // wait until cancel is pressed
return;
}
- 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();
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.
main_timer_ID = startTimer(10);
return;
}
}
// 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();
}
void ConnectWidget::timerEvent(QTimerEvent *) {
if (semaphore || pausing)
return;
if(vmain == 0) {
#ifdef DEBUG_WO_DIALING
vmain = 10;
return;
#endif
assert(PPPData::NumInitStrings > 0);
// first init string ?
if(substate == -1) {
messg->setText(i18n("Initializing modem..."));
emit debugMessage(i18n("Initializing modem..."));
substate = 0;
}
- 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
}
substate++;
/*
* FIXME after 3.0: Make it possible to disable ATS11 since it
* seems to be incompatible with some ISDN adapters (e.g. DataBox
* Speed Dragon). Even better would be to detect this when doing
* a "Modem Query"
*/
- if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration())
+ if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
vmain = 5;
else
vmain = 3;
return;
}
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);
}
vmain = 3;
return;
}
if(vmain == 3) {
if(!expecting) {
// done with all init strings ?
if(substate < PPPData::NumInitStrings) {
vmain = 0;
return;
}
substate = -1;
// skip setting the volume if command is empty
- if(PPPData::data()->volumeInitString().isEmpty()) {
+ if(_ifaceppp->data()->volumeInitString().isEmpty()) {
vmain = 4;
return;
}
messg->setText(i18n("Setting speaker volume..."));
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;
}
}
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;
return;
}
}
// dial the number and wait to connect
if(vmain == 1) {
if(!expecting) {
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);
messg->setText(bm);
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())
dialnumber = 0;
writeline(pn);
- setExpect(PPPData::data()->modemConnectResp());
+ setExpect(_ifaceppp->data()->modemConnectResp());
vmain = 100;
return;
}
}
// wait for connect, but redial if BUSY or wait for user cancel
// if NO CARRIER or NO DIALTONE
if(vmain == 100) {
if(!expecting) {
- myreadbuffer = PPPData::data()->modemConnectResp();
+ myreadbuffer = _ifaceppp->data()->modemConnectResp();
setExpect("\n");
vmain = 101;
return;
}
- 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);
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;
return;
}
- 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;
}
}
// wait for newline after CONNECT response (so we get the speed)
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();
// p_kppp->con_win->startClock();
vmain = 2;
- scriptTimeout=PPPData::data()->modemTimeout()*1000;
+ scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
return;
}
}
// execute the script
if(vmain == 2) {
if(!expecting && !pausing && !scanning) {
timeout_timer->stop();
timeout_timer->start(scriptTimeout);
if((unsigned) scriptindex < comlist->count()) {
@@ -485,45 +481,45 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
setScan(scriptArgument);
scriptindex++;
return;
}
if (scriptCommand == "Save") {
QString bm = i18n("Saving %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
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;
}
scriptindex++;
return;
}
if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
QString bm = i18n("Sending %1");
// replace %USERNAME% and %PASSWORD%
QString arg = scriptArgument;
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")
bm = bm.arg(scriptArgument);
else {
for(uint i = 0; i < scriptArgument.length(); i++)
bm = bm.arg("*");
}
messg->setText(bm);
emit debugMessage(bm);
writeline(scriptArgument);
@@ -569,49 +565,49 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
scriptTimeout=scriptArgument.toInt()*1000;
timeout_timer->start(scriptTimeout);
scriptindex++;
return;
}
if (scriptCommand == "Hangup") {
messg->setText(i18n("Hangup"));
emit debugMessage(i18n("Hangup"));
- writeline(PPPData::data()->modemHangupStr());
- setExpect(PPPData::data()->modemHangupResp());
+ writeline(_ifaceppp->data()->modemHangupStr());
+ setExpect(_ifaceppp->data()->modemHangupResp());
scriptindex++;
return;
}
if (scriptCommand == "Answer") {
timeout_timer->stop();
messg->setText(i18n("Answer"));
emit debugMessage(i18n("Answer"));
- setExpect(PPPData::data()->modemRingResp());
+ setExpect(_ifaceppp->data()->modemRingResp());
vmain = 150;
return;
}
if (scriptCommand == "ID") {
QString bm = i18n("ID %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
- QString idstring = PPPData::data()->storedUsername();
+ QString idstring = _ifaceppp->data()->storedUsername();
if(!idstring.isEmpty() && firstrunID) {
// the user entered an Id on the main kppp dialog
writeline(idstring);
firstrunID = false;
scriptindex++;
}
else {
// the user didn't enter and Id on the main kppp dialog
// let's query for an ID
/* if not around yet, then post window... */
if (prompt->Consumed()) {
@@ -629,46 +625,46 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
return;
}
/* replace timeout value */
}
}
}
if (scriptCommand == "Password") {
QString bm = i18n("Password %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
- QString pwstring = PPPData::data()->password();
+ QString pwstring = _ifaceppp->data()->password();
if(!pwstring.isEmpty() && firstrunPW) {
// the user entered a password on the main kppp dialog
writeline(pwstring);
firstrunPW = false;
scriptindex++;
}
else {
// the user didn't enter a password on the main kppp dialog
// let's query for a password
/* if not around yet, then post window... */
if (prompt->Consumed()) {
if (!(prompt->isVisible())) {
prompt->setPrompt(scriptArgument);
prompt->setEchoModePassword();
prompt->show();
}
} else {
/* if prompt withdrawn ... then, */
if(!(prompt->isVisible())) {
- p_kppp->setPW_Edit(prompt->text());
+// p_kppp->setPW_Edit(prompt->text());
writeline(prompt->text());
prompt->setConsumed();
scriptindex++;
return;
}
/* replace timeout value */
}
}
}
if (scriptCommand == "Prompt") {
QString bm = i18n("Prompting %1");
@@ -776,26 +772,26 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
}
messg->setText(bm);
emit debugMessage(bm);
}
}
}
// this is a subroutine for the "Answer" script option
if(vmain == 150) {
if(!expecting) {
- writeline(PPPData::data()->modemAnswerStr());
- setExpect(PPPData::data()->modemAnswerResp());
+ writeline(_ifaceppp->data()->modemAnswerStr());
+ setExpect(_ifaceppp->data()->modemAnswerResp());
vmain = 2;
scriptindex++;
return;
}
}
if(vmain == 30) {
// if (termwindow->isVisible())
// return;
// if (termwindow->pressedContinue())
// vmain = 10;
@@ -803,103 +799,103 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
cancelbutton();
}
if(vmain == 10) {
if(!expecting) {
int result;
timeout_timer->stop();
if_timeout_timer->stop(); // better be sure.
// 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;
// termwindow = 0L;
// this->show();
// } else {
// termwindow = new LoginTerm(0L, 0L);
// hide();
// termwindow->show();
// vmain = 30;
// return;
// }
}
// Close the tty. This prevents the QTimer::singleShot() in
// 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
// stats->setUnit(pppInterfaceNumber());
qApp->flushX();
semaphore = true;
result = execppp();
emit debugMessage(i18n("Starting pppd..."));
qDebug("execppp() returned with return-code %i", result );
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
// where we wait for the ppp if (interface) to come up.
emit if_waiting_signal();
} else {
// starting pppd wasn't successful. Error messages were
// handled by execppp();
if_timeout_timer->stop();
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();
}
return;
}
}
// this is a "wait until cancel" entry
if(vmain == 20) {
}
}
void ConnectWidget::set_con_speed_string() {
// Here we are trying to determine the speed at which we are connected.
// Usually the modem responds after connect with something like
// 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);
}
void ConnectWidget::readChar(unsigned char c) {
if(semaphore)
return;
readbuffer += c;
myreadbuffer += c;
// While in scanning mode store each char to the scan buffer
@@ -960,56 +956,56 @@ void ConnectWidget::checkBuffers() {
}
}
void ConnectWidget::pause() {
pausing = false;
pausetimer->stop();
}
void ConnectWidget::cancelbutton() {
- Modem::modem->stop();
+ _ifaceppp->modem()->stop();
killTimer(main_timer_ID);
timeout_timer->stop();
if_timer->stop();
if_timeout_timer->stop();
// if (termwindow) {
// delete termwindow;
// termwindow = 0L;
// this->show();
// }
messg->setText(i18n("One moment please..."));
// 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...
if (prompt->isVisible()) {
prompt->hide();
}
prompt->setConsumed();
// if(p_kppp->quitOnDisconnect())
// qApp->exit(0);
}
@@ -1017,25 +1013,25 @@ void ConnectWidget::script_timed_out() {
if(vmain == 20) { // we are in the 'wait for the user to cancel' state
timeout_timer->stop();
emit stopAccounting();
// p_kppp->con_win->stopClock();
return;
}
if (prompt->isVisible())
prompt->hide();
prompt->setConsumed();
messg->setText(i18n("Script timed out!"));
- Modem::modem->hangup();
+ _ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
vmain = 0; // let's try again.
substate = -1;
}
void ConnectWidget::setScan(const QString &n) {
scanning = true;
scanstr = n;
scanbuffer = "";
@@ -1054,385 +1050,385 @@ void ConnectWidget::setExpect(const QString &n) {
emit debugMessage(ts);
// check if the expected string is in the read buffer already.
checkBuffers();
}
void ConnectWidget::if_waiting_timed_out() {
if_timer->stop();
if_timeout_timer->stop();
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();
// p_kppp->con_win->stopClock();
// 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(PPPData::data()->pppdError() != 0) {
+// 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(PPPData::data()->autoDNS())
- addpeerdns();
+ 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();
+ 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"));
set_con_speed_string();
// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
this->hide();
messg->setText("");
// 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 (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();
}
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 += 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 += ":";
}
else {
command += " ";
command += ":";
}
- 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
command += " xonxoff";
}
- 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();
++it )
{
command += " " + *it;
}
// 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";
if (command.length() > MAX_CMDLEN) {
QMessageBox::critical(this, "error", i18n(
"pppd command + command-line arguments exceed "
"2024 characters in length."
));
return false; // nonsensically long command which would bust my buffer buf.
}
qApp->flushX();
- return Modem::modem->execPPPDaemon(command);
+ return _ifaceppp->modem()->execPPPDaemon(command);
}
void ConnectWidget::closeEvent( QCloseEvent *e ) {
e->ignore();
emit cancelbutton();
}
void ConnectWidget::setMsg(const QString &msg) {
messg->setText(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;
QString new_hostname;
int dot;
char tmp_str[100]; // buffer overflow safe
gethostname(tmp_str, sizeof(tmp_str));
tmp_str[sizeof(tmp_str)-1]=0; // panic
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);
if (hostname_entry != 0L) {
new_hostname=hostname_entry->h_name;
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;
new_hostname=hostname_entry->h_name;
new_hostname.remove(0,dot+1);
- add_domain(new_hostname);
+ add_domain(new_hostname, _ifaceppp);
}
}
}
// 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;
char c;
QString resolv[MAX_RESOLVCONF_LINES];
if (domain.isEmpty())
return;
- if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
int i=0;
while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
if(c == '\n') {
i++;
}
else {
resolv[i] += c;
}
}
close(fd);
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";
write(fd, tmp.data(), tmp.length());
for(int j=0; j < i; j++) {
if((resolv[j].contains("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() +
" \t#entry disabled by kppp\n";
write(fd, tmp, tmp.length());
}
else {
QCString tmp = resolv[j].local8Bit() + "\n";
write(fd, tmp, tmp.length());
}
}
}
close(fd);
}
}
// 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();
++it )
{
QCString dns = "nameserver " + (*it).local8Bit() +
" \t#kppp temp entry\n";
write(fd, dns.data(), dns.length());
}
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;
int i = 0;
while(i++ < 100 && read(fd2, &c, 1) == 1) {
if(c == '\n')
write(fd, "\t#kppp temp entry\n", 18);
else
write(fd, &c, 1);
}
close(fd2);
} else
fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
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;
char c;
QString resolv[MAX_RESOLVCONF_LINES];
- if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
+ if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
int i=0;
while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
if(c == '\n') {
i++;
}
else {
resolv[i] += c;
}
}
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;
if(resolv[j].contains("#entry disabled by kppp")) {
QCString tmp = resolv[j].local8Bit();
write(fd, tmp.data()+2, tmp.length() - 27);
write(fd, "\n", 1);
}
else {
QCString tmp = resolv[j].local8Bit() + "\n";
write(fd, tmp, tmp.length());
}
}
}
close(fd);
}
if ( modified_hostname ) {
- Modem::modem->setHostname(old_hostname);
+ _ifaceppp->modem()->setHostname(old_hostname);
modified_hostname = FALSE;
}
}
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h
index 3127236..e7ae5e0 100644
--- a/noncore/settings/networksettings/ppp/connect.h
+++ b/noncore/settings/networksettings/ppp/connect.h
@@ -27,35 +27,35 @@
*/
#ifndef _CONNECT_H_
#define _CONNECT_H_
#include <qtimer.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qevent.h>
#include "kpppconfig.h"
#include "pwentry.h"
-//#include "docking.h"
-//#include "loginterm.h"
+
#define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2)
-class PPPStats;
+class InterfacePPP;
+class PPPData;
class ConnectWidget : public QWidget {
Q_OBJECT
public:
- ConnectWidget(QWidget *parent, const char *name);
+ ConnectWidget(InterfacePPP*, QWidget *parent, const char *name);
~ConnectWidget();
public:
void set_con_speed_string();
void setMsg(const QString &);
void pppdDied();
protected:
void timerEvent(QTimerEvent *);
void closeEvent( QCloseEvent *e );
private slots:
@@ -127,26 +127,26 @@ private:
QTimer *pausetimer;
QTimer *if_timer;
QTimer *if_timeout_timer;
QLabel *messg;
QPushButton *cancel;
bool firstrunID;
bool firstrunPW;
unsigned int dialnumber; // the current number to dial
-// PPPStats *stats;
+ InterfacePPP *_ifaceppp;
};
// non-member function to kill&wait on the pppd child process
-extern void killppp();
-void adddns();
-void addpeerdns();
-void removedns();
-void add_domain(const QString & newdomain);
-void auto_hostname();
+extern void killppp(PPPData*);
+void adddns(InterfacePPP*);
+void addpeerdns(InterfacePPP*);
+void removedns(InterfacePPP*);
+void add_domain(const QString & newdomain, InterfacePPP*);
+void auto_hostname(InterfacePPP*);
#endif
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index 20d705d..9136ca0 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -22,37 +22,34 @@
*/
#include <qtooltip.h>
#include <qdialog.h>
#include "conwindow.h"
//#include "docking.h"
#include "pppdata.h"
// #include "pppstats.h"
// #include <klocale.h>
#define i18n QObject::tr
// #include <kglobal.h>
-extern PPPData gpppdata;
-ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget )
-// PPPStats *st)
+ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name,
+ QDialog *mainwidget )
: QWidget(parent, name, 0),
minutes(0),
seconds(0),
hours(0),
days(0),
tl1(0),
-// stats(st),
- accountingEnabled(false),
- volumeAccountingEnabled(false)
+ _pppdata(pd)
{
info1 = new QLabel(i18n("Connected at:"), this);
info2 = new QLabel("", this);
timelabel1 = new QLabel(i18n("Time connected:"), this);
timelabel2 = new QLabel("000:00:00", this);
vollabel = new QLabel(i18n("Volume:"), this);
volinfo = new QLabel("", this);
// now the stuff for accounting
session_bill_l = new QLabel(i18n("Session Bill:"), this);
@@ -106,185 +103,185 @@ QString ConWindow::prettyPrintVolume(unsigned int n) {
n /= 1024;
}
int i = idx;
while(i--)
n1 = n1 / 1024.0;
QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
s += " " + quant[idx];
return s;
}
-void ConWindow::accounting(bool on) {
- // cache accounting settings
- accountingEnabled = on;
- volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
-
- // delete old layout
- if(tl1 != 0)
- delete tl1;
-
- // add layout now
- tl1 = new QVBoxLayout(this, 10, 10);
- tl1->addSpacing(5);
- QHBoxLayout *tl = new QHBoxLayout;
- tl1->addLayout(tl);
- tl->addSpacing(20);
- QGridLayout *l1;
-
- int vol_lines = 0;
- if(PPPData::data()->VolAcctEnabled())
- vol_lines = 1;
-
- if(accountingEnabled)
- l1 = new QGridLayout(4 + vol_lines, 2, 5);
- else
- l1 = new QGridLayout(2 + vol_lines, 2, 5);
- tl->addLayout(l1);
- l1->setColStretch(0, 0);
- l1->setColStretch(1, 1);
-
- info2->setAlignment(AlignRight|AlignVCenter);
- timelabel2->setAlignment(AlignRight|AlignVCenter);
- session_bill->setAlignment(AlignRight|AlignVCenter);
- total_bill->setAlignment(AlignRight|AlignVCenter);
- volinfo->setAlignment(AlignRight|AlignVCenter);
- // make sure that there's enough space for the bills
- QString s1 = session_bill->text();
- QString s2 = total_bill->text();
- QString s3 = volinfo->text();
-
- session_bill->setText("888888.88 XXX");
- total_bill->setText("888888.88 XXX");
- volinfo->setText("8888.8 MB");
- session_bill->setFixedSize(session_bill->sizeHint());
- total_bill->setFixedSize(total_bill->sizeHint());
- volinfo->setFixedSize(volinfo->sizeHint());
- session_bill->setText(s1);
- total_bill->setText(s2);
- volinfo->setText(s3);
-
- l1->addWidget(info1, 0, 0);
- l1->addWidget(info2, 0, 1);
- l1->addWidget(timelabel1, 1, 0);
- l1->addWidget(timelabel2, 1, 1);
- if(accountingEnabled) {
- session_bill_l->show();
- session_bill->show();
- total_bill_l->show();
- total_bill->show();
- l1->addWidget(session_bill_l, 2, 0);
- l1->addWidget(session_bill, 2, 1);
- l1->addWidget(total_bill_l, 3, 0);
- l1->addWidget(total_bill, 3, 1);
-
- if(volumeAccountingEnabled) {
- vollabel->show();
- volinfo->show();
- l1->addWidget(vollabel, 4, 0);
- l1->addWidget(volinfo, 4, 1);
- } else {
- vollabel->hide();
- volinfo->hide();
- }
-
- } else {
- session_bill_l->hide();
- session_bill->hide();
- total_bill_l->hide();
- total_bill->hide();
-
- if(volumeAccountingEnabled) {
- vollabel->show();
- volinfo->show();
- l1->addWidget(vollabel, 2, 0);
- l1->addWidget(volinfo, 2, 1);
- } else {
- vollabel->hide();
- volinfo->hide();
- }
- }
+// void ConWindow::accounting(bool on) {
+// // cache accounting settings
+// accountingEnabled = on;
+// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
- tl->addSpacing(10);
- QVBoxLayout *l2 = new QVBoxLayout(5);
- tl->addLayout(l2);
- l2->addStretch(1);
-// l2->addWidget(statsbutton);
- l2->addWidget(cancelbutton);
+// // delete old layout
+// if(tl1 != 0)
+// delete tl1;
- l2->addStretch(1);
+// // add layout now
+// tl1 = new QVBoxLayout(this, 10, 10);
+// tl1->addSpacing(5);
+// QHBoxLayout *tl = new QHBoxLayout;
+// tl1->addLayout(tl);
+// tl->addSpacing(20);
+// QGridLayout *l1;
- tl1->addSpacing(5);
+// int vol_lines = 0;
+// // if(_pppdata->VolAcctEnabled())
+// // vol_lines = 1;
- setFixedSize(sizeHint());
-/*
- do not overwrite position read from config
- setGeometry((QApplication::desktop()->width() - width()) / 2,
- (QApplication::desktop()->height() - height())/2,
- width(),
- height());
-*/
-}
+// if(accountingEnabled)
+// l1 = new QGridLayout(4 + vol_lines, 2, 5);
+// else
+// l1 = new QGridLayout(2 + vol_lines, 2, 5);
+// tl->addLayout(l1);
+// l1->setColStretch(0, 0);
+// l1->setColStretch(1, 1);
+
+// info2->setAlignment(AlignRight|AlignVCenter);
+// timelabel2->setAlignment(AlignRight|AlignVCenter);
+// session_bill->setAlignment(AlignRight|AlignVCenter);
+// total_bill->setAlignment(AlignRight|AlignVCenter);
+// volinfo->setAlignment(AlignRight|AlignVCenter);
+// // make sure that there's enough space for the bills
+// QString s1 = session_bill->text();
+// QString s2 = total_bill->text();
+// QString s3 = volinfo->text();
+
+// session_bill->setText("888888.88 XXX");
+// total_bill->setText("888888.88 XXX");
+// volinfo->setText("8888.8 MB");
+// session_bill->setFixedSize(session_bill->sizeHint());
+// total_bill->setFixedSize(total_bill->sizeHint());
+// volinfo->setFixedSize(volinfo->sizeHint());
+// session_bill->setText(s1);
+// total_bill->setText(s2);
+// volinfo->setText(s3);
+
+// l1->addWidget(info1, 0, 0);
+// l1->addWidget(info2, 0, 1);
+// l1->addWidget(timelabel1, 1, 0);
+// l1->addWidget(timelabel2, 1, 1);
+// if(accountingEnabled) {
+// session_bill_l->show();
+// session_bill->show();
+// total_bill_l->show();
+// total_bill->show();
+// l1->addWidget(session_bill_l, 2, 0);
+// l1->addWidget(session_bill, 2, 1);
+// l1->addWidget(total_bill_l, 3, 0);
+// l1->addWidget(total_bill, 3, 1);
+
+// if(volumeAccountingEnabled) {
+// vollabel->show();
+// volinfo->show();
+// l1->addWidget(vollabel, 4, 0);
+// l1->addWidget(volinfo, 4, 1);
+// } else {
+// vollabel->hide();
+// volinfo->hide();
+// }
+
+// } else {
+// session_bill_l->hide();
+// session_bill->hide();
+// total_bill_l->hide();
+// total_bill->hide();
+
+// if(volumeAccountingEnabled) {
+// vollabel->show();
+// volinfo->show();
+// l1->addWidget(vollabel, 2, 0);
+// l1->addWidget(volinfo, 2, 1);
+// } else {
+// vollabel->hide();
+// volinfo->hide();
+// }
+// }
+// tl->addSpacing(10);
+// QVBoxLayout *l2 = new QVBoxLayout(5);
+// tl->addLayout(l2);
+// l2->addStretch(1);
+// // l2->addWidget(statsbutton);
+// l2->addWidget(cancelbutton);
-void ConWindow::dock() {
-// DockWidget::dock_widget->show();
- this->hide();
-}
+// l2->addStretch(1);
+
+// tl1->addSpacing(5);
+
+// setFixedSize(sizeHint());
+// /*
+// do not overwrite position read from config
+// setGeometry((QApplication::desktop()->width() - width()) / 2,
+// (QApplication::desktop()->height() - height())/2,
+// width(),
+// height());
+// */
+// }
+
+
+// void ConWindow::dock() {
+// // DockWidget::dock_widget->show();
+// this->hide();
+// }
void ConWindow::startClock() {
minutes = 0;
seconds = 0;
hours = 0;
QString title ;
- title = PPPData::data()->accname();
+ title = _pppdata->accname();
- if(PPPData::data()->get_show_clock_on_caption()){
+ if(_pppdata->get_show_clock_on_caption()){
title += " 00:00" ;
}
this->setCaption(title);
timelabel2->setText("00:00:00");
clocktimer->start(1000);
}
void ConWindow::setConnectionSpeed(const QString &speed) {
info2->setText(speed);
}
void ConWindow::stopClock() {
clocktimer->stop();
}
void ConWindow::timeclick() {
// QString tooltip = i18n("Connection: %1\n"
// "Connected at: %2\n"
// "Time connected: %3")
-// .arg(PPPData::data()->accname()).arg(info2->text())
+// .arg(_pppdata->accname()).arg(info2->text())
// .arg(time_string2);
// if(accountingEnabled)
// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
// .arg(session_bill->text()).arg(total_bill->text());
// // volume accounting
// if(volumeAccountingEnabled) {
// volinfo->setEnabled(TRUE);
-// int bytes = PPPData::data()->totalBytes();
+// int bytes = _pppdata->totalBytes();
// volinfo->setText(prettyPrintVolume(bytes));
// }
// seconds++;
// if(seconds >= 60 ) {
// minutes ++;
// seconds = 0;
// }
// if (minutes >= 60){
// minutes = 0;
@@ -296,46 +293,46 @@ void ConWindow::timeclick() {
// hours = 0;
// }
// time_string.sprintf("%02d:%02d",hours,minutes);
// time_string2 = "";
// if (days)
// time_string2.sprintf("%d d %02d:%02d:%02d",
// days,hours,minutes,seconds);
// else
// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
-// caption_string = PPPData::data()->accname();
+// caption_string = _pppdata->accname();
// caption_string += " ";
// caption_string += time_string;
// timelabel2->setText(time_string2);
-// if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
+// if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){
// // we update the Caption only once per minute not every second
// // otherwise I get a flickering icon
// this->setCaption(caption_string);
// }
// QToolTip::add(DockWidget::dock_widget, tooltip);
}
void ConWindow::closeEvent( QCloseEvent *e ){
// we don't want to lose the
// conwindow since this is our last connection kppp.
// if we lost it we could only kill the program by hand to get on with life.
e->ignore();
- if(PPPData::data()->get_dock_into_panel())
- dock();
+// if(_pppdata->get_dock_into_panel())
+// dock();
}
void ConWindow::slotAccounting(QString total, QString session) {
total_bill->setText(total);
session_bill->setText(session);
}
diff --git a/noncore/settings/networksettings/ppp/conwindow.h b/noncore/settings/networksettings/ppp/conwindow.h
index 20d3579..42c6f35 100644
--- a/noncore/settings/networksettings/ppp/conwindow.h
+++ b/noncore/settings/networksettings/ppp/conwindow.h
@@ -25,46 +25,46 @@
#ifndef _CONWINDOW_H_
#define _CONWINDOW_H_
#include <qtimer.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qdialog.h>
#include <qframe.h>
#include <qevent.h>
#include <qlayout.h>
-//class PPPStats;
+class PPPData;
class ConWindow : public QWidget {
Q_OBJECT
public:
- ConWindow(QWidget *parent, const char *name, QDialog* );
+ ConWindow(PPPData*, QWidget *parent, const char *name, QDialog* );
~ConWindow();
protected:
void closeEvent( QCloseEvent *e );
bool event( QEvent *e );
private slots:
void timeclick();
- void dock();
+// void dock();
public:
void setConnectionSpeed(const QString&);
void startClock();
void stopClock();
- void accounting(bool); // show/ hide accounting info
+// void accounting(bool); // show/ hide accounting info
public slots:
void slotAccounting(QString, QString);
private:
QLabel *info1;
QLabel *info2;
QPushButton *cancelbutton;
QPushButton *statsbutton;
QString prettyPrintVolume(unsigned int);
int minutes;
int seconds;
@@ -73,24 +73,22 @@ private:
QFrame *fline;
QLabel *timelabel1;
QLabel *timelabel2;
QLabel *total_bill, *total_bill_l;
QLabel *session_bill, *session_bill_l;
QString caption_string;
QString time_string2;
QString time_string;
QTimer *clocktimer;
QVBoxLayout *tl1;
QLabel *vollabel;
QLabel *volinfo;
-// PPPStats *stats;
- bool accountingEnabled;
- bool volumeAccountingEnabled;
+ PPPData *_pppdata;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index eee643d..8ae714e 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -36,26 +36,27 @@
#define i18n QObject::tr
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
//#include <kwin.h>
#include "edit.h"
#include "pppdata.h"
//#include "newwidget.h"
#include "iplined.h"
#include "auth.h"
-DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
+ , const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
const int GRIDROWS = 6;
QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
connect_label = new QLabel(i18n("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
connectname_l = new QLineEdit(this);
// connectname_l->setMaxLength(ACCNAME_SIZE);
tl->addWidget(connectname_l, 0, 1);
QString tmp = i18n("Type in a unique name for this connection");
@@ -145,93 +146,93 @@ DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
"\n"
"<b><font color=\"red\">Warning:</font> your password will be stored as\n"
"plain text in the config file, which is\n"
"readable only to you. Make sure nobody\n"
"gains access to this file!"));
pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this);
connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
// Set defaults if editing an existing connection
if(!isnewaccount) {
- connectname_l->setText(PPPData::data()->accname());
+ connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
- QString n = PPPData::data()->phonenumber();
+ QString n = _pppdata->phonenumber();
QString tmp = "";
uint idx = 0;
while(idx != n.length()) {
if(n[idx] == ':') {
if(tmp.length() > 0)
numbers->insertItem(tmp);
tmp = "";
} else
tmp += n[idx];
idx++;
}
if(tmp.length() > 0)
numbers->insertItem(tmp);
- auth->setCurrentItem(PPPData::data()->authMethod());
- store_password->setChecked(PPPData::data()->storePassword());
+ auth->setCurrentItem(_pppdata->authMethod());
+ store_password->setChecked(_pppdata->storePassword());
} else {
// select PAP/CHAP as default
auth->setCurrentItem(AUTH_PAPCHAP);
}
numbersChanged();
tl->activate();
}
bool DialWidget::save() {
//first check to make sure that the account name is unique!
if(connectname_l->text().isEmpty() ||
- !PPPData::data()->isUniqueAccname(connectname_l->text())) {
+ !_pppdata->isUniqueAccname(connectname_l->text())) {
return false;
} else {
- PPPData::data()->setAccname(connectname_l->text());
+ _pppdata->setAccname(connectname_l->text());
QString number = "";
for(uint i = 0; i < numbers->count(); i++) {
if(i != 0)
number += ":";
number += numbers->text(i);
}
- PPPData::data()->setPhonenumber(number);
- PPPData::data()->setAuthMethod(auth->currentItem());
- PPPData::data()->setStorePassword(store_password->isChecked());
+ _pppdata->setPhonenumber(number);
+ _pppdata->setAuthMethod(auth->currentItem());
+ _pppdata->setStorePassword(store_password->isChecked());
return true;
}
}
void DialWidget::numbersChanged() {
int sel = numbers->currentItem();
del->setEnabled(sel != -1);
up->setEnabled(sel != -1 && sel != 0);
down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
}
void DialWidget::selectionChanged(int) {
numbersChanged();
}
void DialWidget::addNumber() {
- PhoneNumberDialog dlg(this);
+ PhoneNumberDialog dlg(this);
if(dlg.exec()) {
numbers->insertItem(dlg.phoneNumber());
numbersChanged();
}
}
void DialWidget::delNumber() {
if(numbers->currentItem() != -1) {
numbers->removeItem(numbers->currentItem());
numbersChanged();
}
@@ -254,35 +255,35 @@ void DialWidget::downNumber() {
int idx = numbers->currentItem();
if(idx != -1) {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx+1);
numbers->setCurrentItem(idx+1);
numbersChanged();
}
}
void DialWidget::pppdargsbutton() {
- PPPdArguments pa(this);
+ PPPdArguments pa(_pppdata, this);
pa.exec();
}
/////////////////////////////////////////////////////////////////////////////
// ExecWidget
/////////////////////////////////////////////////////////////////////////////
-ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) :
- QWidget(parent, name)
+ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
+ QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
QLabel *l = new QLabel(\
i18n("Here you can select commands to run at certain stages of the\n"
"connection. The commands are run with your real user id, so\n"
"you cannot run any commands here requiring root permissions\n"
"(unless, of course, you are root).\n\n"
"Be sure to supply the whole path to the program otherwise\n"
"kppp might be unable to find it."), this);
// l->setMinimumHeight(l->sizeHint().height());
tl->addWidget(l);
@@ -351,49 +352,49 @@ i18n("Here you can select commands to run at certain stages of the\n"
QWhatsThis::add(discommand_label,tmp);
QWhatsThis::add(discommand,tmp);
// extra space between entries
l1->addRowSpacing(1, 5);
l1->addRowSpacing(3, 5);
tl->addStretch(1);
tl->activate();
// Set defaults if editing an existing connection
if(!isnewaccount) {
- before_connect->setText(PPPData::data()->command_before_connect());
- command->setText(PPPData::data()->command_on_connect());
- discommand->setText(PPPData::data()->command_on_disconnect());
- predisconnect->setText(PPPData::data()->command_before_disconnect());
+ before_connect->setText(_pppdata->command_before_connect());
+ command->setText(_pppdata->command_on_connect());
+ discommand->setText(_pppdata->command_on_disconnect());
+ predisconnect->setText(_pppdata->command_before_disconnect());
}
}
bool ExecWidget::save() {
- PPPData::data()->setCommand_before_connect(before_connect->text());
- PPPData::data()->setCommand_on_connect(command->text());
- PPPData::data()->setCommand_before_disconnect(predisconnect->text());
- PPPData::data()->setCommand_on_disconnect(discommand->text());
+ _pppdata->setCommand_before_connect(before_connect->text());
+ _pppdata->setCommand_on_connect(command->text());
+ _pppdata->setCommand_before_disconnect(predisconnect->text());
+ _pppdata->setCommand_on_disconnect(discommand->text());
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// IPWidget
//
/////////////////////////////////////////////////////////////////////////////
-IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 3 );//KDialog::spacingHint());
box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)),
SLOT(hitIPSelect(int)));
@@ -440,53 +441,53 @@ IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
"but your mileage may vary.\n"
"\n"
"If unsure, contact your Internet Service Provider");
ipLayout->addWidget(sub_label, 1, 0);
subnetmask_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(subnetmask_l, 1, 1);
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this);
- autoname->setChecked(PPPData::data()->autoname());
+ autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
i18n("<p>Whenever you connect, this reconfigures\n"
"your hostname to match the IP address you\n"
"got from the PPP server. This may be useful\n"
"if you need to use a protocol which depends\n"
"on this information, but it can also cause several\n"
"<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
"\n"
"Don't enable this unless you really need it."));
topLayout->addWidget(box);
topLayout->addWidget(autoname);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount) {
- if(PPPData::data()->ipaddr() == "0.0.0.0" &&
- PPPData::data()->subnetmask() == "0.0.0.0") {
+ if(_pppdata->ipaddr() == "0.0.0.0" &&
+ _pppdata->subnetmask() == "0.0.0.0") {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
- autoname->setChecked(PPPData::data()->autoname());
+ autoname->setChecked(_pppdata->autoname());
}
else {
- ipaddress_l->setText(PPPData::data()->ipaddr());
- subnetmask_l->setText(PPPData::data()->subnetmask());
+ ipaddress_l->setText(_pppdata->ipaddr());
+ subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
else {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
void IPWidget::autoname_t(bool on) {
@@ -501,53 +502,53 @@ void IPWidget::autoname_t(bool on) {
"you know what you are doing!\n"
"For more information take a look at the "
"handbook (or help) in the section \"Frequently "
"asked questions\"."),
i18n("Warning"));
was_warned = true;
}
}
void IPWidget::save() {
if(dynamicadd_rb->isChecked()) {
- PPPData::data()->setIpaddr("0.0.0.0");
- PPPData::data()->setSubnetmask("0.0.0.0");
+ _pppdata->setIpaddr("0.0.0.0");
+ _pppdata->setSubnetmask("0.0.0.0");
} else {
- PPPData::data()->setIpaddr(ipaddress_l->text());
- PPPData::data()->setSubnetmask(subnetmask_l->text());
+ _pppdata->setIpaddr(ipaddress_l->text());
+ _pppdata->setSubnetmask(subnetmask_l->text());
}
- PPPData::data()->setAutoname(autoname->isChecked());
+ _pppdata->setAutoname(autoname->isChecked());
}
void IPWidget::hitIPSelect( int i ) {
if(i == 0) {
ipaddress_label->setEnabled(false);
sub_label->setEnabled(false);
ipaddress_l->setEnabled(false);
subnetmask_l->setEnabled(false);
}
else {
ipaddress_label->setEnabled(true);
sub_label->setEnabled(true);
ipaddress_l->setEnabled(true);
subnetmask_l->setEnabled(true);
}
}
-DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
// box = new QGroupBox(this);
QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
dnsdomain_label = new QLabel(i18n("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
dnsdomain = new QLineEdit(this);
// dnsdomain->setMaxLength(DOMAIN_SIZE);
tl->addWidget(dnsdomain, 0, 1);
QString tmp = i18n("If you enter a domain name here, this domain\n"
"name is used for your computer while you are\n"
@@ -563,25 +564,25 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
conf_label = new QLabel(i18n("Configuration:"), this);
tl->addWidget(conf_label, 1, 0);
bg = new QButtonGroup("Group", this);
connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
bg->hide();
autodns = new QRadioButton(i18n("Automatic"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
// no automatic DNS detection for pppd < 2.3.7
- if(!PPPData::data()->pppdVersionMin(2, 3, 7))
+ if(!_pppdata->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
mandns = new QRadioButton(i18n("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
dns_label = new QLabel(i18n("DNS IP address:"), this);
tl->addWidget(dns_label, 3, 0);
QHBoxLayout *l2 = new QHBoxLayout;
tl->addLayout(l2, 3, 1);
dnsipaddr = new IPLineEdit(this);
@@ -636,45 +637,45 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
SLOT(DNS_Entry_Selected(int)));
tl->addWidget(dnsservers, 5, 1);
tmp = i18n("<p>This shows all defined DNS servers to use\n"
"while you are connected. Use the <b>Add</b> and\n"
"<b>Remove</b> buttons to modify the list");
QWhatsThis::add(servers_label,tmp);
QWhatsThis::add(dnsservers,tmp);
exdnsdisabled_toggle = new QCheckBox(i18n( \
"Disable existing DNS servers during connection"),
this);
- exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled());
+ exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
QWhatsThis::add(exdnsdisabled_toggle,
i18n("<p>When this option is selected, all DNS\n"
"servers specified in <tt>/etc/resolv.conf</tt> are\n"
"temporary disabled while the dialup connection\n"
"is established. After the connection is\n"
"closed, the servers will be re-enabled\n"
"\n"
"Typically, there is no reason to use this\n"
"option, but it may become useful under \n"
"some circumstances."));
// restore data if editing
if(!isnewaccount) {
- dnsservers->insertStringList(PPPData::data()->dns());
- dnsdomain->setText(PPPData::data()->domain());
+ dnsservers->insertStringList(_pppdata->dns());
+ dnsdomain->setText(_pppdata->domain());
}
- int mode = PPPData::data()->autoDNS() ? 0 : 1;
+ int mode = _pppdata->autoDNS() ? 0 : 1;
bg->setButton(mode);
DNS_Mode_Selected(mode);
tl->activate();
}
void DNSWidget::DNS_Edit_Changed(const QString &text) {
QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
add->setEnabled(text.find(r) != -1);
}
void DNSWidget::DNS_Entry_Selected(int) {
@@ -686,63 +687,63 @@ void DNSWidget::DNS_Mode_Selected(int mode) {
dns_label->setEnabled(on);
servers_label->setEnabled(on);
dnsipaddr->setText("");
dnsipaddr->setEnabled(on);
add->setEnabled(false);
remove->setEnabled(dnsservers->count()>0 && on);
dnsservers->clearSelection();
dnsservers->setEnabled(on);
dnsservers->triggerUpdate(false);
}
void DNSWidget::save() {
- PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0);
+ _pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
- PPPData::data()->setDns(serverlist);
+ _pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
- PPPData::data()->setDomain(s.mid(1));
+ _pppdata->setDomain(s.mid(1));
else
- PPPData::data()->setDomain(dnsdomain->text());
+ _pppdata->setDomain(dnsdomain->text());
- PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
+ _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
}
void DNSWidget::adddns() {
if(dnsservers->count() < MAX_DNS_ENTRIES) {
dnsservers->insertItem(dnsipaddr->text());
dnsipaddr->setText("");
}
}
void DNSWidget::removedns() {
int i;
i = dnsservers->currentItem();
if(i != -1)
dnsservers->removeItem(i);
remove->setEnabled(dnsservers->count()>0);
}
//
// GatewayWidget
//
-GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );//KDialog::spacingHint());
box = new QVGroupBox(i18n("Configuration"), this);
// box->setInsideSpacing( 2 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
defaultgateway = new QRadioButton(box);
@@ -776,64 +777,64 @@ GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *na
i18n("If this option is enabled, all packets not\n"
"going to the local net are routed through\n"
"the PPP connection.\n"
"\n"
"Normally, you should turn this on"));
topLayout->addWidget(box);
topLayout->addWidget(defaultroute);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount) {
- if(PPPData::data()->gateway() == "0.0.0.0") {
+ if(_pppdata->gateway() == "0.0.0.0") {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
}
else {
- gatewayaddr->setText(PPPData::data()->gateway());
+ gatewayaddr->setText(_pppdata->gateway());
staticgateway->setChecked(true);
}
- defaultroute->setChecked(PPPData::data()->defaultroute());
+ defaultroute->setChecked(_pppdata->defaultroute());
}
else {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
defaultroute->setChecked(true);
}
}
void GatewayWidget::save() {
- PPPData::data()->setGateway(gatewayaddr->text());
- PPPData::data()->setDefaultroute(defaultroute->isChecked());
+ _pppdata->setGateway(gatewayaddr->text());
+ _pppdata->setDefaultroute(defaultroute->isChecked());
}
void GatewayWidget::hitGatewaySelect( int i ) {
if(i == 0) {
gatewayaddr->setText("0.0.0.0");
gatewayaddr->setEnabled(false);
gate_label->setEnabled(false);
}
else {
gatewayaddr->setEnabled(true);
gatewayaddr->setText("");
gate_label->setEnabled(true);
}
}
-ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name )
- : QWidget(parent, name)
+ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget(parent, name),_pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );
se = new ScriptEdit(this);
connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
tl->addWidget(se);
// insert equal-sized buttons
QHBoxLayout *hl = new QHBoxLayout( this );
tl->addLayout( hl );
add = new QPushButton( i18n("Add"), this );
hl->addWidget( add );
@@ -858,26 +859,26 @@ ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name
// sl->setMinimumSize(QSize(150, 140));
slb = new QScrollBar(this);
// slb->setFixedWidth(slb->sizeHint().width());
connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
l12->addWidget(stl, 1);
l12->addWidget(sl, 3);
l12->addWidget(slb, 0);
//load data from gpppdata
if(!isnewaccount) {
- QStringList &comlist = PPPData::data()->scriptType();
- QStringList &arglist = PPPData::data()->script();
+ QStringList &comlist = _pppdata->scriptType();
+ QStringList &arglist = _pppdata->script();
QStringList::Iterator itcom = comlist.begin();
QStringList::Iterator itarg = arglist.begin();
for ( ;
itcom != comlist.end() && itarg != arglist.end();
++itcom, ++itarg )
{
stl->insertItem(*itcom);
sl->insertItem(*itarg);
}
}
@@ -905,26 +906,26 @@ bool ScriptWidget::check() {
return ( (errcnt == 0 ) && (lstart == lend) );
}
return true;
}
void ScriptWidget::save() {
QStringList typelist, arglist;
for(uint i=0; i < sl->count(); i++) {
typelist.append(stl->text(i));
arglist.append(sl->text(i));
}
- PPPData::data()->setScriptType(typelist);
- PPPData::data()->setScript(arglist);
+ _pppdata->setScriptType(typelist);
+ _pppdata->setScript(arglist);
}
void ScriptWidget::adjustScrollBar() {
if((int)sl->count() <= sl->numItemsVisible())
slb->setRange(0, 0);
else
slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
}
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h
index cd0161f..2cc0fed 100644
--- a/noncore/settings/networksettings/ppp/edit.h
+++ b/noncore/settings/networksettings/ppp/edit.h
@@ -38,118 +38,122 @@
#include <qlineedit.h>
#include <qlistbox.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qlabel.h>
//#include <kdialogbase.h>
#include "scriptedit.h"
#include "kpppconfig.h"
#include "pppdargs.h"
class IPLineEdit;
+class PPPData;
class DialWidget : public QWidget {
Q_OBJECT
public:
- DialWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~DialWidget() {}
public slots:
bool save();
void pppdargsbutton();
void numbersChanged();
void selectionChanged(int);
void addNumber();
void delNumber();
void upNumber();
void downNumber();
private:
QLineEdit *connectname_l;
QLabel *connect_label;
QLabel *number_label;
QPushButton *pppdargs;
QComboBox *auth;
QLabel *auth_l;
QCheckBox *store_password;
// for the phonenumber selection
QPushButton *add, *del, *up, *down;
QListBox *numbers;
+ PPPData *_pppdata;
};
/////////////////////////////////////////////////////////////////////////////
//
// tab-window to select what to execute when
//
/////////////////////////////////////////////////////////////////////////////
class ExecWidget : public QWidget {
Q_OBJECT
public:
- ExecWidget(QWidget *parent=0, bool isnewaccount=true, const char *name=0);
+ ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0);
public slots:
bool save();
private:
QLineEdit *before_connect;
QLabel *before_connect_l;
QLineEdit *command;
QLabel *command_label;
QLineEdit *predisconnect;
QLabel *predisconnect_label;
QLineEdit *discommand;
QLabel *discommand_label;
+ PPPData *_pppdata;
};
class IPWidget : public QWidget {
Q_OBJECT
public:
- IPWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ IPWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~IPWidget() {}
public slots:
void save();
protected slots:
void hitIPSelect( int );
void autoname_t(bool on);
private:
QLabel *ipaddress_label;
QLabel *sub_label;
QGroupBox *box1;
QVGroupBox *box;
QButtonGroup *rb;
QRadioButton *dynamicadd_rb;
QRadioButton *staticadd_rb;
IPLineEdit *ipaddress_l;
IPLineEdit *subnetmask_l;
QCheckBox *autoname;
+ PPPData *_pppdata;
};
class DNSWidget : public QWidget {
Q_OBJECT
public:
- DNSWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ DNSWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~DNSWidget() {}
public slots:
void save();
protected slots:
void adddns();
void removedns();
void DNS_Edit_Changed(const QString &);
void DNS_Entry_Selected(int);
void DNS_Mode_Selected(int);
@@ -157,55 +161,57 @@ private:
QLabel *conf_label;
QButtonGroup *bg;
QRadioButton *autodns, *mandns;
QLabel *dns_label;
QLabel *servers_label;
IPLineEdit *dnsipaddr;
QPushButton *add;
QPushButton *remove;
QListBox *dnsservers;
QLineEdit *dnsdomain;
QLabel *dnsdomain_label;
QCheckBox *exdnsdisabled_toggle;
+ PPPData *_pppdata;
};
class GatewayWidget : public QWidget {
Q_OBJECT
public:
- GatewayWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ GatewayWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~GatewayWidget() {}
public slots:
void save();
private slots:
void hitGatewaySelect( int );
private:
QGroupBox *box;
QLabel *gate_label;
QGroupBox *box1;
QButtonGroup *rb;
QRadioButton *defaultgateway;
QRadioButton *staticgateway;
IPLineEdit *gatewayaddr;
QCheckBox *defaultroute;
+ PPPData *_pppdata;
};
class ScriptWidget : public QWidget {
Q_OBJECT
public:
- ScriptWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ScriptWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~ScriptWidget() {}
public slots:
void save();
bool check();
private slots:
void addButton();
void insertButton();
void removeButton();
//signals linked to the scroll bar
@@ -216,36 +222,38 @@ private slots:
void stlhighlighted(int);
private:
void adjustScrollBar();
ScriptEdit *se;
QPushButton *add;
QPushButton *remove;
QPushButton *insert;
QListBox *sl, *stl;
QScrollBar *slb;
+ PPPData *_pppdata;
};
/////////////////////////////////////////////////////////////////////////////
//
// Used to specify a new phone number
//
/////////////////////////////////////////////////////////////////////////////
class PhoneNumberDialog : public QDialog {
Q_OBJECT
public:
PhoneNumberDialog(QWidget *parent = 0);
QString phoneNumber();
private slots:
void textChanged(const QString &);
private:
QLineEdit *le;
+
};
#endif
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 98e035b..f735e49 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -30,37 +30,37 @@
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qspinbox.h>
#include <qwhatsthis.h>
// #include <qgroupbox.h>
#include "general.h"
-//#include "version.h"
+#include "interfaceppp.h"
//#include "miniterm.h"
#include "modeminfo.h"
#include "modemcmds.h"
#include "devices.h"
#include "pppdata.h"
//#include <klocale.h>
#define i18n QObject::tr
-ModemWidget::ModemWidget( QWidget *parent, const char *name)
- : QWidget(parent, name)
+ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name )
+ : QWidget(parent, name), _ifaceppp(ifppp)
{
int k;
QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
QLabel *label1;
label1 = new QLabel(i18n("Modem de&vice:"), this);
tl->addWidget(label1, 0, 0);
modemdevice = new QComboBox(false, this);
label1->setBuddy(modemdevice);
@@ -163,195 +163,198 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name)
tmp = i18n("Specifies the speed your modem and the serial\n"
"port talk to each other. You should begin with\n"
"the default of 38400 bits/sec. If everything\n"
"works you can try to increase this value, but to\n"
"no more than 115200 bits/sec (unless you know\n"
"that your serial port supports higher speeds).");
QWhatsThis::add(baud_label,tmp);
QWhatsThis::add(baud_c,tmp);
for(int i=0; i <= enter->count()-1; i++) {
- if(PPPData::data()->enter() == enter->text(i))
+ if(_ifaceppp->data()->enter() == enter->text(i))
enter->setCurrentItem(i);
}
tl->addRowSpacing(4, 10);
//Modem Lock File
modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
- modemlockfile->setChecked(PPPData::data()->modemLockFile());
+ modemlockfile->setChecked(_ifaceppp->data()->modemLockFile());
connect(modemlockfile, SIGNAL(toggled(bool)),
SLOT(modemlockfilechanged(bool)));
tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
// l12->addStretch(1);
QWhatsThis::add(modemlockfile,
i18n("<p>To prevent other programs from accessing the\n"
"modem while a connection is established, a\n"
"file can be created to indicate that the modem\n"
"is in use. On Linux an example file would be\n"
"<tt>/var/lock/LCK..ttyS1</tt>\n"
"Here you can select whether this locking will\n"
"be done.\n"
"\n"
"<b>Default</b>: On"));
// Modem Timeout Line Edit Box
QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
-// modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this);
+// modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
// modemtimeout->setLabel(i18n("Modem &timeout:"));
// modemtimeout->setRange(1, 120, 1);
modemtimeout->setSuffix(i18n(" sec"));
+ modemtimeout->setValue( _ifaceppp->data()->modemTimeout() );
connect(modemtimeout, SIGNAL(valueChanged(int)),
SLOT(modemtimeoutchanged(int)));
timeoutLayout->addWidget(timeoutlabel);
timeoutLayout->addWidget(modemtimeout);
tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1);
QWhatsThis::add(modemtimeout,
i18n("This specifies how long <i>kppp</i> waits for a\n"
"<i>CONNECT</i> response from your modem. The\n"
"recommended value is 30 seconds."));
//set stuff from gpppdata
for(int i=0; i <= enter->count()-1; i++) {
- if(PPPData::data()->enter() == enter->text(i))
+ if(_ifaceppp->data()->enter() == enter->text(i))
enter->setCurrentItem(i);
}
for(int i=0; i <= modemdevice->count()-1; i++) {
- if(PPPData::data()->modemDevice() == modemdevice->text(i))
+ if(_ifaceppp->data()->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
for(int i=0; i <= flowcontrol->count()-1; i++) {
- if(PPPData::data()->flowcontrol() == flowcontrol->text(i))
+ if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i))
flowcontrol->setCurrentItem(i);
}
//set the modem speed
for(int i=0; i < baud_c->count(); i++)
- if(baud_c->text(i) == PPPData::data()->speed())
+ if(baud_c->text(i) == _ifaceppp->data()->speed())
baud_c->setCurrentItem(i);
tl->setRowStretch(7, 1);
}
void ModemWidget::speed_selection(int) {
- PPPData::data()->setSpeed(baud_c->text(baud_c->currentItem()));
+ _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem()));
}
void ModemWidget::setenter(int ) {
- PPPData::data()->setEnter(enter->text(enter->currentItem()));
+ _ifaceppp->data()->setEnter(enter->text(enter->currentItem()));
}
void ModemWidget::setmodemdc(int i) {
- PPPData::data()->setModemDevice(modemdevice->text(i));
+ _ifaceppp->data()->setModemDevice(modemdevice->text(i));
}
void ModemWidget::setflowcontrol(int i) {
- PPPData::data()->setFlowcontrol(flowcontrol->text(i));
+ _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i));
}
void ModemWidget::modemlockfilechanged(bool set) {
- PPPData::data()->setModemLockFile(set);
+ _ifaceppp->data()->setModemLockFile(set);
}
void ModemWidget::modemtimeoutchanged(int n) {
- PPPData::data()->setModemTimeout(n);
+ _ifaceppp->data()->setModemTimeout(n);
}
-ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
- : QWidget(parent, name)
+ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent,
+ const char *name)
+ : QWidget(parent, name), _ifaceppp(ifp)
{
QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
- waitfordt->setChecked(PPPData::data()->waitForDialTone());
+ waitfordt->setChecked(_ifaceppp->data()->waitForDialTone());
connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
l1->addWidget(waitfordt);
QWhatsThis::add(waitfordt,
i18n("<p>Normally the modem waits for a dial tone\n"
"from your phone line, indicating that it can\n"
"start to dial a number. If your modem does not\n"
"recognize this sound, or your local phone system\n"
"does not emit such a tone, uncheck this option\n"
"\n"
"<b>Default:</b>: On"));
QHBoxLayout *waitLayout = new QHBoxLayout( this );
QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" );
busywait = new QSpinBox( 0, 300, 5, this, "busyWait" );
-// busywait = new KIntNumInput(PPPData::data()->busyWait(), this);
+// busywait = new KIntNumInput(_pppdata->busyWait(), this);
// busywait->setLabel(i18n("B&usy wait:"));
// busywait->setRange(0, 300, 5, true);
busywait->setSuffix(i18n(" sec"));
connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
waitLayout->addWidget(waitLabel);
waitLayout->addWidget(busywait);
l1->addLayout( waitLayout );
QWhatsThis::add(busywait,
i18n("Specifies the number of seconds to wait before\n"
"redial if all dialed numbers are busy. This is\n"
"necessary because some modems get stuck if the\n"
"same number is busy too often.\n"
"\n"
"The default is 0 seconds, you should not change\n"
"this unless you need to."));
l1->addSpacing(10);
QHBoxLayout *hbl = new QHBoxLayout;
hbl->setSpacing(2);//KDialog::spacingHint());
QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
hbl->addWidget(volumeLabel);
- volume = new QSlider(0, 2, 1, PPPData::data()->volume(), QSlider::Horizontal, this);
+ volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(),
+ QSlider::Horizontal, this);
volumeLabel->setBuddy(volume);
volume->setTickmarks(QSlider::Below);
hbl->addWidget(volume);
l1->addLayout(hbl);
connect(volume, SIGNAL(valueChanged(int)),
this, SLOT(volumeChanged(int)));
QString tmp = i18n("Most modems have a speaker which makes\n"
"a lot of noise when dialing. Here you can\n"
"either turn this completely off or select a\n"
"lower volume.\n"
"\n"
"If this does not work for your modem,\n"
"you must modify the modem volume command.");
QWhatsThis::add(volumeLabel,tmp);
QWhatsThis::add(volume, tmp);
l1->addSpacing(20);
#if 0
chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
- chkbox1->setChecked(PPPData::data()->UseCDLine());
+ chkbox1->setChecked(_ifaceppp->data()->UseCDLine());
connect(chkbox1,SIGNAL(toggled(bool)),
this,SLOT(use_cdline_toggled(bool)));
l12->addWidget(chkbox1);
l12->addStretch(1);
l1->addStretch(1);
QWhatsThis::add(chkbox1,
i18n("This controls how <i>kppp</i> detects that the modem\n"
"is not responding. Unless you are having\n"
"problems with this, do not modify this setting.\n"
"\n"
"<b>Default</b>: Off"));
#endif
@@ -390,49 +393,49 @@ ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
l1->addStretch(1);
connect(modemcmds, SIGNAL(clicked()),
SLOT(modemcmdsbutton()));
connect(modeminfo_button, SIGNAL(clicked()),
SLOT(query_modem()));
// connect(terminal_button, SIGNAL(clicked()),
// SLOT(terminal()));
}
void ModemWidget2::modemcmdsbutton() {
- ModemCommands mc(this);
+ ModemCommands mc(_ifaceppp->data(), this);
mc.showMaximized();
mc.exec();
}
void ModemWidget2::query_modem() {
- ModemTransfer mt(this);
+ ModemTransfer mt(_ifaceppp->modem(), this);
mt.exec();
}
// void ModemWidget2::terminal() {
// MiniTerm terminal(NULL,NULL);
// terminal.exec();
// }
#if 0
void ModemWidget2::use_cdline_toggled(bool on) {
- PPPData::data()->setUseCDLine(on);
+ _ifaceppp->data()->setUseCDLine(on);
}
#endif
void ModemWidget2::waitfordtchanged(bool b) {
- PPPData::data()->setWaitForDialTone((int)b);
+ _ifaceppp->data()->setWaitForDialTone((int)b);
}
void ModemWidget2::busywaitchanged(int n) {
- PPPData::data()->setbusyWait(n);
+ _ifaceppp->data()->setbusyWait(n);
}
void ModemWidget2::volumeChanged(int v) {
- PPPData::data()->setVolume(v);
+ _ifaceppp->data()->setVolume(v);
}
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
index 4869f6c..3e59b46 100644
--- a/noncore/settings/networksettings/ppp/general.h
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -25,74 +25,76 @@
#ifndef _GENERAL_H_
#define _GENERAL_H_
#include <qwidget.h>
class QSlider;
class QSpinBox;
class QCombobox;
class QLabel;
class QCheckBox;
class QComboBox;
-
-
+class PPPData;
+class InterfacePPP;
class ModemWidget : public QWidget {
Q_OBJECT
public:
- ModemWidget( QWidget *parent=0, const char *name=0 );
+ ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 );
private slots:
void setmodemdc(int);
void setflowcontrol(int);
void modemtimeoutchanged(int);
void modemlockfilechanged(bool);
void setenter(int);
void speed_selection(int);
private:
QComboBox *enter;
/* QLabel *label1; */
/* QLabel *label2; */
/* QLabel *labeltmp; */
/* QLabel *labelenter; */
QComboBox *modemdevice;
QComboBox *flowcontrol;
QComboBox *baud_c;
QLabel *baud_label;
QSpinBox *modemtimeout;
QCheckBox *modemlockfile;
+ InterfacePPP *_ifaceppp;
};
class ModemWidget2 : public QWidget {
Q_OBJECT
public:
- ModemWidget2( QWidget *parent=0, const char *name=0 );
+ ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 );
private slots:
void waitfordtchanged(bool);
void busywaitchanged(int);
// void use_cdline_toggled(bool);
void modemcmdsbutton();
// void terminal();
void query_modem();
void volumeChanged(int);
private:
QLabel *labeltmp;
QPushButton *modemcmds;
QPushButton *modeminfo_button;
// QPushButton *terminal_button;
// QFrame *fline;
QCheckBox *waitfordt;
QSpinBox *busywait;
QCheckBox *chkbox1;
QSlider *volume;
+ InterfacePPP *_ifaceppp;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
new file mode 100644
index 0000000..a58858c
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -0,0 +1,24 @@
+#include "interfaceinformationppp.h"
+
+
+#include <qpushbutton.h>
+#include <qlabel.h>
+//#include <qgroupbox.h>
+#include <qmessagebox.h>
+
+#ifdef QWS
+#else
+ #define showMaximized show
+#endif
+
+/**
+ * Constructor for the InterfaceInformationImp class. This class pretty much
+ * just display's information about the interface that is passed to it.
+ */
+InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f)
+ :InterfaceInformationImp(parent, name, i, f)
+{
+}
+
+
+
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.h b/noncore/settings/networksettings/ppp/interfaceinformationppp.h
new file mode 100644
index 0000000..8c6fc0b
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.h
@@ -0,0 +1,25 @@
+#ifndef INTERFACEINFORMATIONPPP_H
+#define INTERFACEINFORMATIONPPP_H
+
+#include "interfaceinformationimp.h"
+//#include "interface.h"
+
+class QWidget;
+class Interface;
+
+class InterfaceInformationPPP : public InterfaceInformationImp {
+
+Q_OBJECT
+
+public:
+
+ InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
+ ~InterfaceInformationPPP(){};
+
+
+};
+
+#endif
+
+// addserviceimp.h
+
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp
new file mode 100644
index 0000000..d9ee3ff
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp
@@ -0,0 +1,48 @@
+#include "interfaceppp.h"
+#include "modem.h"
+#include "pppdata.h"
+
+InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status)
+ : Interface(parent, name, status),
+ _modem(0),
+ _pppdata(0)
+{
+ qDebug("InterfacePPP::InterfacePPP(");
+}
+
+PPPData* InterfacePPP::data()
+{
+ if (!_pppdata){
+ _pppdata = new PPPData();
+ _pppdata->setModemDevice( getInterfaceName() );
+ _pppdata->setAccount( getHardwareName() );
+ }
+ return _pppdata;
+}
+
+Modem* InterfacePPP::modem()
+{
+ if (!_modem){
+ _modem = new Modem( data() );
+ }
+ return _modem;
+}
+
+bool InterfacePPP::refresh()
+{
+ qDebug("InterfacePPP::refresh()");
+ return false;
+}
+
+void InterfacePPP::start()
+{
+ qDebug("InterfacePPP::start");
+
+}
+
+void InterfacePPP::stop()
+{
+ qDebug("InterfacePPP::stop");
+
+}
+
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h
new file mode 100644
index 0000000..b7477c9
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceppp.h
@@ -0,0 +1,30 @@
+#ifndef INTERFACEPPP_H
+#define INTERFACEPPP_H
+
+#include "interface.h"
+
+class PPPData;
+class Modem;
+
+class InterfacePPP : public Interface
+{
+ Q_OBJECT
+
+public:
+ InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false);
+
+ PPPData* data();
+ Modem* modem();
+
+public slots:
+ virtual bool refresh();
+ virtual void start();
+ virtual void stop();
+
+ private:
+ Modem *_modem;
+ PPPData *_pppdata;
+};
+
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index f8a8dc3..289e9f5 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -28,24 +28,25 @@
#include <qapplication.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qevent.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qregexp.h>
#include <qtabwidget.h>
#include <qdialog.h>
#include <qwhatsthis.h>
+#include <qcheckbox.h>
// #include <kaboutdata.h>
// #include <kapplication.h>
#include <qbuttongroup.h>
//#include <kcmdlineargs.h>
//#include <kconfig.h>
//#include <kdebug.h>
#define i18n QObject::tr
//#include <kiconloader.h> // For BarIcon
//#include <klocale.h>
#include <qmessagebox.h>
// #include <kseparator.h>
@@ -61,229 +62,237 @@
#include "runtests.h"
//#include "main.h"
#include "auth.h"
#include "modem.h"
//#include "ppplog.h"
//#include "opener.h"
//#include "requester.h"
//#include "pppstats.h"
#include "pppdata.h"
#include "general.h"
+#include "interface.h"
#define execute_command system
KPPPWidget *p_kppp = 0;
-KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl )
- : QDialog(parent, name, modal, fl)
-// , acct(0)
-// , m_bCmdlAccount (false)
+KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl )
+ : QDialog(parent, name, modal, fl), _pppdata(pd)
{
// tabWindow = 0;
p_kppp = this;
// before doing anything else, run a few tests
+ if (!_pppdata->setModemDevice( i->getInterfaceName() ))
+ _pppdata->setModemDevice("/dev/modem");
+ qDebug("PPPConfigWidget::PPPConfigWidget");
+ qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1());
+ if (!_pppdata->setAccount( i->getHardwareName() ))
+ _pppdata->setAccount( 0 );
+
+ qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1());
+ qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID());
int result = runTests();
if(result == TEST_CRITICAL)
exit(4);
// installEventFilter(this);
-// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
-
-// QGridLayout *l1 = new QGridLayout(3, 4);
-// tl->addLayout(l1);
-// l1->addColSpacing(0, 10);
-// l1->addColSpacing(3, 10);
-// l1->setColStretch(1, 3);
-// l1->setColStretch(2, 4);
-
-// label1 = new QLabel(i18n("C&onnect to: "), this);
-// l1->addWidget(label1, 0, 1);
-
-// connectto_c = new QComboBox(false, this);
-// label1->setBuddy(connectto_c);
-
-// connect(connectto_c, SIGNAL(activated(int)),
-// SLOT(newdefaultaccount(int)));
-// l1->addWidget(connectto_c, 0, 2);
-
-// ID_Label = new QLabel(i18n("&Login ID:"), this);
-// l1->addWidget(ID_Label, 1, 1);
-
-// // the entry line for usernames
-// ID_Edit = new QLineEdit(this);
-// ID_Label->setBuddy(ID_Edit);
-// l1->addWidget(ID_Edit, 1, 2);
-// connect(ID_Edit, SIGNAL(returnPressed()),
-// this, SLOT(enterPressedInID()));
-// QString tmp = i18n("<p>Type in the username that you got from your\n"
-// "ISP. This is especially important for PAP\n"
-// "and CHAP. You may omit this when you use\n"
-// "terminal-based or script-based authentication.\n"
-// "\n"
-// "<b>Important</b>: case is important here:\n"
-// "<i>myusername</i> is not the same as <i>MyUserName</i>!");
-
-// QWhatsThis::add(ID_Label,tmp);
-// QWhatsThis::add(ID_Edit,tmp);
-
-// PW_Label = new QLabel(i18n("&Password:"), this);
-// l1->addWidget(PW_Label, 2, 1);
-
-// PW_Edit= new QLineEdit(this);
-// PW_Label->setBuddy(PW_Edit);
-// PW_Edit->setEchoMode(QLineEdit::Password);
-// l1->addWidget(PW_Edit, 2, 2);
-// connect(PW_Edit, SIGNAL(returnPressed()),
-// this, SLOT(enterPressedInPW()));
-
-// tmp = i18n("<p>Type in the password that you got from your\n"
-// "ISP. This is especially important for PAP\n"
-// "and CHAP. You may omit this when you use\n"
-// "terminal-based or script-based authentication.\n"
-// "\n"
-// "<b>Important</b>: case is important here:\n"
-// "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
-
-// QWhatsThis::add(PW_Label,tmp);
-// QWhatsThis::add(PW_Edit,tmp);
-
-// QHBoxLayout *l3 = new QHBoxLayout;
-// tl->addSpacing(5);
-// tl->addLayout(l3);
-// tl->addSpacing(5);
-// l3->addSpacing(10);
-// log = new QCheckBox(i18n("Show lo&g window"), this);
-// connect(log, SIGNAL(toggled(bool)),
-// this, SLOT(log_window_toggled(bool)));
-// log->setChecked(PPPData::data()->get_show_log_window());
-// l3->addWidget(log);
-
-// QWhatsThis::add(log,
-// i18n("<p>This controls whether a log window is shown.\n"
-// "A log window shows the communication between\n"
-// "<i>kppp</i> and your modem. This will help you\n"
-// "in tracking down problems.\n"
-// "\n"
-// "Turn it off if <i>kppp</i> routinely connects without\n"
-// "problems"));
-
-// // fline = new QSeparator( KSeparator::HLine, this);
-// // tl->addWidget(fline);
-
-// QHBoxLayout *l2 = new QHBoxLayout(this);
-// tl->addLayout(l2);
-
-// int minw = 0;
-// quit_b = new QPushButton(i18n("&Quit"), this);
-// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
-// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
-// if(quit_b->sizeHint().width() > minw)
-// minw = quit_b->sizeHint().width();
-
-// setup_b = new QPushButton(i18n("&Setup..."), this);
-// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
-// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
-// if(setup_b->sizeHint().width() > minw)
-// minw = setup_b->sizeHint().width();
-
-
-
-// if(PPPData::data()->access() != KConfig::ReadWrite)
-// setup_b->setEnabled(false);
+ QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
+
+ QGridLayout *l1 = new QGridLayout(3, 4);
+ tl->addLayout(l1);
+ l1->addColSpacing(0, 10);
+ l1->addColSpacing(3, 10);
+ l1->setColStretch(1, 3);
+ l1->setColStretch(2, 4);
+
+ label1 = new QLabel(i18n("C&onnect to: "), this);
+ l1->addWidget(label1, 0, 1);
+
+ connectto_c = new QComboBox(false, this);
+ label1->setBuddy(connectto_c);
+
+ connect(connectto_c, SIGNAL(activated(int)),
+ SLOT(newdefaultaccount(int)));
+ l1->addWidget(connectto_c, 0, 2);
+
+ ID_Label = new QLabel(i18n("&Login ID:"), this);
+ l1->addWidget(ID_Label, 1, 1);
+
+ // the entry line for usernames
+ ID_Edit = new QLineEdit(this);
+ ID_Label->setBuddy(ID_Edit);
+ l1->addWidget(ID_Edit, 1, 2);
+ connect(ID_Edit, SIGNAL(returnPressed()),
+ this, SLOT(enterPressedInID()));
+ QString tmp = i18n("<p>Type in the username that you got from your\n"
+ "ISP. This is especially important for PAP\n"
+ "and CHAP. You may omit this when you use\n"
+ "terminal-based or script-based authentication.\n"
+ "\n"
+ "<b>Important</b>: case is important here:\n"
+ "<i>myusername</i> is not the same as <i>MyUserName</i>!");
+
+ QWhatsThis::add(ID_Label,tmp);
+ QWhatsThis::add(ID_Edit,tmp);
+
+ PW_Label = new QLabel(i18n("&Password:"), this);
+ l1->addWidget(PW_Label, 2, 1);
+
+ PW_Edit= new QLineEdit(this);
+ PW_Label->setBuddy(PW_Edit);
+ PW_Edit->setEchoMode(QLineEdit::Password);
+ l1->addWidget(PW_Edit, 2, 2);
+ connect(PW_Edit, SIGNAL(returnPressed()),
+ this, SLOT(enterPressedInPW()));
+
+ tmp = i18n("<p>Type in the password that you got from your\n"
+ "ISP. This is especially important for PAP\n"
+ "and CHAP. You may omit this when you use\n"
+ "terminal-based or script-based authentication.\n"
+ "\n"
+ "<b>Important</b>: case is important here:\n"
+ "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
+
+ QWhatsThis::add(PW_Label,tmp);
+ QWhatsThis::add(PW_Edit,tmp);
+
+ QHBoxLayout *l3 = new QHBoxLayout;
+ tl->addSpacing(5);
+ tl->addLayout(l3);
+ tl->addSpacing(5);
+ l3->addSpacing(10);
+ log = new QCheckBox(i18n("Show lo&g window"), this);
+ connect(log, SIGNAL(toggled(bool)),
+ this, SLOT(log_window_toggled(bool)));
+ log->setChecked(_pppdata->get_show_log_window());
+ l3->addWidget(log);
+
+ QWhatsThis::add(log,
+ i18n("<p>This controls whether a log window is shown.\n"
+ "A log window shows the communication between\n"
+ "<i>kppp</i> and your modem. This will help you\n"
+ "in tracking down problems.\n"
+ "\n"
+ "Turn it off if <i>kppp</i> routinely connects without\n"
+ "problems"));
+
+// fline = new QSeparator( KSeparator::HLine, this);
+// tl->addWidget(fline);
+
+ QHBoxLayout *l2 = new QHBoxLayout(this);
+ tl->addLayout(l2);
+
+ int minw = 0;
+ quit_b = new QPushButton(i18n("&Quit"), this);
+ // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
+ connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
+ if(quit_b->sizeHint().width() > minw)
+ minw = quit_b->sizeHint().width();
+
+ setup_b = new QPushButton(i18n("&Setup..."), this);
+// setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
+ connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
+ if(setup_b->sizeHint().width() > minw)
+ minw = setup_b->sizeHint().width();
+
+
+
+// if(_pppdata->access() != KConfig::ReadWrite)
+ // setup_b->setEnabled(false);
// help_b = new QPushButton(i18n("&Help"), this);
// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
// help_b->setPopup((QPopupMenu*)helpMenu->menu());
// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
// if(help_b->sizeHint().width() > minw)
// minw = help_b->sizeHint().width();
-// connect_b = new QPushButton(i18n("&Connect"), this);
-// connect_b->setDefault(true);
-// connect_b->setFocus();
-// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
-// if(connect_b->sizeHint().width() > minw)
-// minw = connect_b->sizeHint().width();
+ connect_b = new QPushButton(i18n("&Connect"), this);
+ connect_b->setDefault(true);
+ connect_b->setFocus();
+ connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
+ if(connect_b->sizeHint().width() > minw)
+ minw = connect_b->sizeHint().width();
-// quit_b->setFixedWidth(minw);
-// setup_b->setFixedWidth(minw);
-// // help_b->setFixedWidth(help_b->sizeHint().width());
-// connect_b->setFixedWidth(minw);
+ quit_b->setFixedWidth(minw);
+ setup_b->setFixedWidth(minw);
+// help_b->setFixedWidth(help_b->sizeHint().width());
+ connect_b->setFixedWidth(minw);
-// l2->addWidget(quit_b);
-// l2->addWidget(setup_b);
-// // l2->addWidget(help_b);
-// l2->addSpacing(20);
-// l2->addWidget(connect_b);
+ l2->addWidget(quit_b);
+ l2->addWidget(setup_b);
+// l2->addWidget(help_b);
+ l2->addSpacing(20);
+ l2->addWidget(connect_b);
setFixedSize(sizeHint());
- (void)new Modem;
+ (void)new Modem(_pppdata);
// we also connect cmld_start to the beginConnect so that I can run
// the dialer through a command line argument
connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
// stats = new PPPStats;
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
// constructor of con_win reads position from config file
-// con_win = new ConWindow(0, "conw", this);
+ con_win = new ConWindow(_pppdata, 0, "conw", this);
// KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
// statdlg = new PPPStatsDlg(0, "stats", this, stats);
// statdlg->hide();
// load up the accounts combo box
// resetaccounts();
-// con = new ConnectWidget(0, "con");
+ con = new ConnectWidget(_pppdata, 0, "con");
//KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
-// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
+ connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
// Is this the best we can do here? it's not right.
// QRect desk = QApplication::desktop()->screenGeometry(
// QApplication::desktop()->screenNumber(topLevelWidget()));
// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
// connect the ConnectWidgets various signals
-// // connect(con, SIGNAL(startAccounting()),
-// // this, SLOT(startAccounting()));
-// // connect(con, SIGNAL(stopAccounting()),
-// // this, SLOT(stopAccounting()));
-// connect(qApp, SIGNAL(saveYourself()),
-// this, SLOT(saveMyself()));
-// connect(qApp, SIGNAL(shutDown()),
-// this, SLOT(shutDown()));
+ connect(con, SIGNAL(startAccounting()),
+ this, SLOT(startAccounting()));
+ connect(con, SIGNAL(stopAccounting()),
+ this, SLOT(stopAccounting()));
+ connect(qApp, SIGNAL(saveYourself()),
+ this, SLOT(saveMyself()));
+ connect(qApp, SIGNAL(shutDown()),
+ this, SLOT(shutDown()));
// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// m_strCmdlAccount = args->getOption("c");
// m_bQuitOnDisconnect = args->isSet("q");
// if(!m_strCmdlAccount.isEmpty()) {
// m_bCmdlAccount = true;
// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
// }
// if(m_bCmdlAccount){
-// bool result = PPPData::data()->setAccount(m_strCmdlAccount);
+// bool result = _pppdata->setAccount(m_strCmdlAccount);
// if (!result){
// QString string;
// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
// KMessageBox::error(this, string);
// m_bCmdlAccount = false;
// this->show();
// } else {
// beginConnect();
// }
// } else
// expandbutton();
// show();
@@ -337,454 +346,454 @@ KPPPWidget::~KPPPWidget()
void KPPPWidget::enterPressedInID() {
PW_Edit->setFocus();
}
void KPPPWidget::enterPressedInPW() {
connect_b->setFocus();
}
// triggered by the session manager
void KPPPWidget::saveMyself() {
- PPPData::data()->save();
+ _pppdata->save();
}
void KPPPWidget::shutDown() {
interruptConnection();
saveMyself();
}
void KPPPWidget::log_window_toggled(bool on) {
- PPPData::data()->set_show_log_window(on);
+ _pppdata->set_show_log_window(on);
}
// void KPPPWidget::resetaccounts() {
// connectto_c->clear();
-// int count = PPPData::data()->count();
+// int count = _pppdata->count();
// // enable/disable controls
// connectto_c->setEnabled(count > 0);
// connect_b->setEnabled(count > 0);
// log->setEnabled(count > 0);
// ID_Edit->setEnabled(count > 0);
// PW_Edit->setEnabled(count > 0);
// //load the accounts
// for(int i=0; i < count; i++) {
-// PPPData::data()->setAccountbyIndex(i);
-// connectto_c->insertItem(PPPData::data()->accname());
+// _pppdata->setAccountbyIndex(i);
+// connectto_c->insertItem(_pppdata->accname());
// }
// //set the default account
-// if(!PPPData::data()->defaultAccount().isEmpty()) {
+// if(!_pppdata->defaultAccount().isEmpty()) {
// for(int i=0; i < count; i++)
-// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) {
+// if(_pppdata->defaultAccount() == connectto_c->text(i)) {
// connectto_c->setCurrentItem(i);
-// PPPData::data()->setAccountbyIndex(i);
+// _pppdata->setAccountbyIndex(i);
-// ID_Edit->setText(PPPData::data()->storedUsername());
-// PW_Edit->setText(PPPData::data()->storedPassword());
+// ID_Edit->setText(_pppdata->storedUsername());
+// PW_Edit->setText(_pppdata->storedPassword());
// }
// }
// else
// if(count > 0) {
-// PPPData::data()->setDefaultAccount(connectto_c->text(0));
-// PPPData::data()->save();
-// ID_Edit->setText(PPPData::data()->storedUsername());
-// PW_Edit->setText(PPPData::data()->storedPassword());
+// _pppdata->setDefaultAccount(connectto_c->text(0));
+// _pppdata->save();
+// ID_Edit->setText(_pppdata->storedUsername());
+// PW_Edit->setText(_pppdata->storedPassword());
// }
// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
// this, SLOT(usernameChanged(const QString &)));
// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
// this, SLOT(passwordChanged(const QString &)));
// if (ID_Edit->text().isEmpty())
// ID_Edit->setFocus();
// else if (PW_Edit->text().isEmpty())
// PW_Edit->setFocus();
// }
void KPPPWidget::interruptConnection() {
// interrupt dial up
-// if (con->isVisible())
-// emit con->cancelbutton();
+//
+
+ if (con->isVisible())
+ emit con->cancelbutton();
// disconnect if online
- if (PPPData::data()->pppdRunning())
+ if (_pppdata->pppdRunning())
emit disconnect();
}
void KPPPWidget::sigPPPDDied() {
qDebug( "Received a SIGUSR1" );
// if we are not connected pppdpid is -1 so have have to check for that
// in the followin line to make sure that we don't raise a false alarm
// such as would be the case when the log file viewer exits.
- if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) {
+ if(_pppdata->pppdRunning() || _pppdata->pppdError()) {
qDebug( "It was pppd that died" );
// when we killpppd() on Cancel in ConnectWidget
// we set pppid to -1 so we won't
// enter this block
// just to be sure
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
- PPPData::data()->setpppdRunning(false);
+ _pppdata->setpppdRunning(false);
qDebug( "Executing command on disconnect since pppd has died." );
QApplication::flushX();
- execute_command(PPPData::data()->command_on_disconnect());
+ execute_command(_pppdata->command_on_disconnect());
// stopAccounting();
-// con_win->stopClock();
+ con_win->stopClock();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
- if(!PPPData::data()->pppdError())
- PPPData::data()->setpppdError(E_PPPD_DIED);
+ if(!_pppdata->pppdError())
+ _pppdata->setpppdError(E_PPPD_DIED);
removedns();
Modem::modem->unlockdevice();
- // con->pppdDied();
+ //
+ con->pppdDied();
- if(!PPPData::data()->automatic_redial()) {
+ if(!_pppdata->automatic_redial()) {
quit_b->setFocus();
show();
-// con_win->stopClock();
+ con_win->stopClock();
// stopAccounting();
-// con_win->hide();
-// con->hide();
+ con_win->hide();
+ con->hide();
- PPPData::data()->setpppdRunning(false);
+ _pppdata->setpppdRunning(false);
// // not in a signal handler !!! KNotifyClient::beep();
QString msg;
- if (PPPData::data()->pppdError() == E_IF_TIMEOUT)
+ if (_pppdata->pppdError() == E_IF_TIMEOUT)
msg = i18n("Timeout expired while waiting for the PPP interface "
"to come up!");
else {
msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
Modem::modem->pppdExitStatus();
if (Modem::modem->lastStatus != 99) { // more recent pppds only
msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
"codes or take a look at the kppp FAQ on "
" <a href=http://devel-home.kde.org/~kppp/index.html>"
"http://devel-home.kde.org/~kppp/index.html</a></p>");
}
}
// if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
// // PPPL_ShowLog();
// } else { /* reconnect on disconnect */
if (false){
qDebug( "Trying to reconnect... " );
- if(PPPData::data()->authMethod() == AUTH_PAP ||
- PPPData::data()->authMethod() == AUTH_CHAP ||
- PPPData::data()->authMethod() == AUTH_PAPCHAP)
- Modem::modem->setSecret(PPPData::data()->authMethod(),
- encodeWord(PPPData::data()->storedUsername()),
- encodeWord(PPPData::data()->password()));
+ if(_pppdata->authMethod() == AUTH_PAP ||
+ _pppdata->authMethod() == AUTH_CHAP ||
+ _pppdata->authMethod() == AUTH_PAPCHAP)
+ Modem::modem->setSecret(_pppdata->authMethod(),
+ encodeWord(_pppdata->storedUsername()),
+ encodeWord(_pppdata->password()));
-// con_win->hide();
- // con_win->stopClock();
+ con_win->hide();
+ con_win->stopClock();
// stopAccounting();
- PPPData::data()->setpppdRunning(false);
+ _pppdata->setpppdRunning(false);
// not in a signal handler !!! KNotifyClient::beep();
emit cmdl_start();
}
}
- PPPData::data()->setpppdError(0);
+ _pppdata->setpppdError(0);
}
}
// void KPPPWidget::sigChld() {
// qDebug( "sigchld()" );
// // pid_t id = wait(0L);
// // if(id == helperPid && helperPid != -1) {
// // kdDebug(5002) << "It was the setuid child that died" << endl;
// // helperPid = -1;
// QString msg = i18n("kppp's helper process just died.\n"
// "Since a further execution would be pointless, "
// "kppp will shut down now.");
// QMessageBox::warning(0L,"error", msg);
// //remove_pidfile();
// exit(1);
// // }
// }
void KPPPWidget::newdefaultaccount(int i) {
- PPPData::data()->setDefaultAccount(connectto_c->text(i));
- PPPData::data()->save();
- ID_Edit->setText(PPPData::data()->storedUsername());
- PW_Edit->setText(PPPData::data()->storedPassword());
+ _pppdata->setDefaultAccount(connectto_c->text(i));
+ _pppdata->save();
+ ID_Edit->setText(_pppdata->storedUsername());
+ PW_Edit->setText(_pppdata->storedPassword());
}
void KPPPWidget::beginConnect() {
// make sure to connect to the account that is selected in the combo box
// (exeption: an account given by a command line argument)
// if(!m_bCmdlAccount) {
-// PPPData::data()->setAccount(connectto_c->currentText());
-// PPPData::data()->setPassword(PW_Edit->text());
+// _pppdata->setAccount(connectto_c->currentText());
+// _pppdata->setPassword(PW_Edit->text());
// } else {
- PPPData::data()->setPassword(PPPData::data()->storedPassword());
+ _pppdata->setPassword(_pppdata->storedPassword());
// }
QFileInfo info(pppdPath());
if(!info.exists()){
QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
"Make sure that pppd is installed and "
"that you have entered the correct path."));
return;
}
#if 0
if(!info.isExecutable()){
QString string;
string = i18n("kppp cannot execute:\n %1\n"
"Please make sure that you have given kppp "
"setuid permission and that "
- "pppd is executable.").arg(PPPData::data()->pppdPath());
+ "pppd is executable.").arg(_pppdata->pppdPath());
KMessageBox::error(this, string);
return;
}
#endif
- QFileInfo info2(PPPData::data()->modemDevice());
+ QFileInfo info2(_pppdata->modemDevice());
if(!info2.exists()){
QString string;
string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
- "the setup dialog.").arg(PPPData::data()->modemDevice());
+ "the setup dialog.").arg(_pppdata->modemDevice());
QMessageBox::warning(this, "error", string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
- if(PPPData::data()->authMethod() == AUTH_PAP ||
- PPPData::data()->authMethod() == AUTH_CHAP ||
- PPPData::data()->authMethod() == AUTH_PAPCHAP ) {
+ if(_pppdata->authMethod() == AUTH_PAP ||
+ _pppdata->authMethod() == AUTH_CHAP ||
+ _pppdata->authMethod() == AUTH_PAPCHAP ) {
if(ID_Edit->text().isEmpty()) {
QMessageBox::warning(this,"error",
- i18n(
- "You have selected the authentication "
- "method PAP or CHAP. This requires that you "
- "supply a username and a password!"));
- return;
+ i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!"));
+// FIXME: return;
} else {
- if(!Modem::modem->setSecret(PPPData::data()->authMethod(),
- encodeWord(PPPData::data()->storedUsername()),
- encodeWord(PPPData::data()->password()))) {
+ if(!Modem::modem->setSecret(_pppdata->authMethod(),
+ encodeWord(_pppdata->storedUsername()),
+ encodeWord(_pppdata->password()))) {
QString s;
s = i18n("Cannot create PAP/CHAP authentication\n"
"file \"%1\"").arg(PAP_AUTH_FILE);
QMessageBox::warning(this, "error", s);
return;
}
}
}
- if (PPPData::data()->phonenumber().isEmpty()) {
+ if (_pppdata->phonenumber().isEmpty()) {
QString s = i18n("You must specify a telephone number!");
QMessageBox::warning(this, "error", s);
return;
}
this->hide();
- QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
+ QString tit = i18n("Connecting to: %1").arg(_pppdata->accname());
// con->setCaption(tit);
// con->show();
emit begin_connect();
}
void KPPPWidget::disconnect() {
- if (!PPPData::data()->command_before_disconnect().isEmpty()) {
-// con_win->hide();
-// con->show();
-// con->setCaption(i18n("Disconnecting..."));
-// con->setMsg(i18n("Executing command before disconnection."));
+ if (!_pppdata->command_before_disconnect().isEmpty()) {
+ con_win->hide();
+ con->show();
+ con->setCaption(i18n("Disconnecting..."));
+ con->setMsg(i18n("Executing command before disconnection."));
qApp->processEvents();
QApplication::flushX();
// pid_t id =
- execute_command(PPPData::data()->command_before_disconnect());
+ execute_command(_pppdata->command_before_disconnect());
// int i, status;
// do {
// kapp->processEvents();
// i = waitpid(id, &status, WNOHANG);
// usleep(500000);
// } while (i == 0 && errno == 0);
-// con->hide();
+ con->hide();
}
qApp->processEvents();
// statdlg->stop_stats();
Modem::modem->killPPPDaemon();
QApplication::flushX();
- execute_command(PPPData::data()->command_on_disconnect());
+ execute_command(_pppdata->command_on_disconnect());
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
removedns();
Modem::modem->unlockdevice();
-// con_win->stopClock();
+ con_win->stopClock();
// p_kppp->stopAccounting();
-// con_win->hide();
+ con_win->hide();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
// if(m_bQuitOnDisconnect)
// kapp->exit(0);
// else {
this->quit_b->setFocus();
this->show();
// }
}
// void KPPPWidget::helpbutton() {
// kapp->invokeHelp();
// }
void KPPPWidget::quitbutton() {
- if(PPPData::data()->pppdRunning()) {
+ if(_pppdata->pppdRunning()) {
int ok = QMessageBox::warning(this,
i18n("Exiting kPPP will close your PPP Session."),
i18n("Quit kPPP?"));
if(ok == QMessageBox::Yes) {
Modem::modem->killPPPDaemon();
QApplication::flushX();
- execute_command(PPPData::data()->command_on_disconnect());
+ execute_command(_pppdata->command_on_disconnect());
removedns();
Modem::modem->unlockdevice();
}
} else {
- if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword())
- PPPData::data()->setStoredPassword("");
+ if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword())
+ _pppdata->setStoredPassword("");
}
- PPPData::data()->save();
+ _pppdata->save();
qApp->quit();
}
// void KPPPWidget::rulesetLoadError() {
// QMessageBox::warning(this,"error", ruleset_load_errmsg);
// }
// void KPPPWidget::startAccounting() {
// // volume accounting
// stats->totalbytes = 0;
-// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl;
+// kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl;
// // load the ruleset
-// if(!PPPData::data()->AcctEnabled())
+// if(!_pppdata->AcctEnabled())
// return;
-// QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile());
+// QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile());
// // if(::access(d.data(), X_OK) != 0)
// acct = new Accounting(this, stats);
// // else
// // acct = new ExecutableAccounting(this);
// // connect to the accounting object
// connect(acct, SIGNAL(changed(QString, QString)),
// con_win, SLOT(slotAccounting(QString, QString)));
-// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) {
+// // if(!acct->loadRuleSet(_pppdata->accountingFile())) {
// // QString s= i18n("Can not load the accounting "
-// // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile());
+// // "ruleset \"%1\"!").arg(_pppdata->accountingFile());
// // starting the messagebox with a timer will prevent us
// // from blocking the calling function ConnectWidget::timerEvent
// ruleset_load_errmsg = s;
// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
// return;
// }
// //else
// // acct->slotStart();
// }
// void KPPPWidget::stopAccounting() {
// // store volume accounting
// // if(stats->totalbytes != 0)
-// // PPPData::data()->setTotalBytes(stats->totalbytes);
+// // _pppdata->setTotalBytes(stats->totalbytes);
-// if(!PPPData::data()->AcctEnabled())
+// if(!_pppdata->AcctEnabled())
// return;
// // if(acct != 0) {
// // acct->slotStop();
// // delete acct;
// // acct = 0;
// // }
// }
// void KPPPWidget::showStats() {
// if(statdlg) {
// statdlg->show();
// statdlg->raise();
// }
// }
void KPPPWidget::usernameChanged(const QString &) {
// store username for later use
- PPPData::data()->setStoredUsername(ID_Edit->text());
+ _pppdata->setStoredUsername(ID_Edit->text());
}
void KPPPWidget::passwordChanged(const QString &) {
// store the password if so requested
- if(PPPData::data()->storePassword())
- PPPData::data()->setStoredPassword(PW_Edit->text());
+ if(_pppdata->storePassword())
+ _pppdata->setStoredPassword(PW_Edit->text());
else
- PPPData::data()->setStoredPassword("");
+ _pppdata->setStoredPassword("");
}
void KPPPWidget::setPW_Edit(const QString &pw) {
PW_Edit->setText(pw);
}
// void KPPPWidget::resetCosts(const QString &s) {
// AccountingBase::resetCosts(s);
// }
@@ -806,25 +815,25 @@ QString KPPPWidget::encodeWord(const QString &s) {
// void KPPPWidget::setQuitOnDisconnect (bool b)
// {
// m_bQuitOnDisconnect = b;
// }
void KPPPWidget::showNews() {
#ifdef KPPP_SHOW_NEWS
/*
* Introduce the QuickHelp feature to new users of this version
*/
#define QUICKHELP_HINT "Hint_QuickHelp"
- if(PPPData::data()->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
+ if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
QDialog dlg(0, 0, true);
dlg.setCaption(i18n("Recent Changes in KPPP"));
QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
QHBoxLayout *l1 = new QHBoxLayout(10);
QVBoxLayout *l2 = new QVBoxLayout(10);
tl->addLayout(l1);
QLabel *icon = new QLabel(&dlg);
icon->setPixmap(BarIcon("exclamation"));
icon->setFixedSize(icon->sizeHint());
l1->addWidget(icon);
@@ -858,22 +867,22 @@ void KPPPWidget::showNews() {
l2->addWidget(cb);
tl->addWidget(bbox);
QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n"
"This window will stay open until you\n"
"click a mouse button or a press a key.\n");
QWhatsThis::add(cb,tmp);
QWhatsThis::add(l, tmp);
dlg.exec();
if(cb->isChecked()) {
- PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
- PPPData::data()->save();
+ _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
+ _pppdata->save();
}
}
#endif
}
//#include "kpppwidget.moc"
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h
index d7e74af..b958862 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.h
+++ b/noncore/settings/networksettings/ppp/kpppwidget.h
@@ -25,31 +25,32 @@
*/
#ifndef __KPPPWIDGET_H__
#define __KPPPWIDGET_H__
#include <qstring.h>
#include "conwindow.h"
#include "accounts.h"
#include "connect.h"
class QPushButton;
-
+class Interface;
+class PPPData;
class KPPPWidget : public QDialog {
Q_OBJECT
public:
- KPPPWidget( QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 );
+ KPPPWidget(PPPData*, Interface*, QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 );
~KPPPWidget();
void setPW_Edit(const QString &);
private slots:
void newdefaultaccount(int);
void beginConnect();
void quitbutton();
void usernameChanged(const QString &);
void passwordChanged(const QString &);
void enterPressedInID();
@@ -61,41 +62,41 @@ private slots:
public slots:
void disconnect();
void log_window_toggled(bool on);
signals:
void begin_connect();
void cmdl_start();
public:
QCheckBox *log;
bool connected;
QString con_speed;
- // ConnectWidget *con;
- // ConWindow *con_win;
+ ConnectWidget *con;
+ ConWindow *con_win;
// PPPStatsDlg *statdlg;
// AccountingBase *acct;
QPushButton *quit_b;
//PPPStats *stats;
private:
// void prepareSetupDialog();
void interruptConnection();
void sigChld();
void sigPPPDDied();
QString encodeWord(const QString &s);
void showNews ();
QString ruleset_load_errmsg;
-
+ PPPData *_pppdata;
QPushButton *setup_b;
QFrame *fline;
QFrame *fline1;
QPushButton *connect_b;
QComboBox *connectto_c;
QLabel *ID_Label;
QLabel *PW_Label;
QLineEdit *ID_Edit;
QLineEdit *PW_Edit;
QLabel *label1;
QLabel *label2;
QLabel *label3;
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index 5139482..002c8e7 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -53,25 +53,25 @@
#define i18n QObject::tr
#define qError qDebug
//#include <kdebug.h>
//#include <config.h>
#define MY_ASSERT(x) if (!(x)) { \
qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
exit(1); }
static sigjmp_buf jmp_buffer;
-Modem *Modem::modem = 0;
+//Modem *Modem::modem = 0;
const char* pppdPath() {
// wasting a few bytes
static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
static char *pppdPath = 0L;
char *p;
if(pppdPath == 0L) {
const char *c = PPPDSEARCHPATH;
while(*c != '\0') {
while(*c == ':')
@@ -82,49 +82,48 @@ const char* pppdPath() {
*p = '\0';
strcat(p, "/");
strcat(p, PPPDNAME);
if(access(buffer, F_OK) == 0)
return (pppdPath = buffer);
}
}
return pppdPath;
}
-Modem::Modem()
+Modem::Modem( PPPData* pd )
{
- if (Modem::modem != 0) return; //CORRECT?
+ _pppdata = pd;
modemfd = -1;
_pppdExitStatus = -1;
pppdPid = -1;
sn = 0L;
data_mode = false;
modem_is_locked = false;
lockfile[0] = '\0';
device = "/dev/modem";
- modem = this;
}
-Modem::~Modem() {
- modem = 0;
+Modem::~Modem()
+{
}
speed_t Modem::modemspeed() {
// convert the string modem speed int the gpppdata object to a t_speed type
// to set the modem. The constants here should all be ifdef'd because
// other systems may not have them
- int i = PPPData::data()->speed().toInt()/100;
+ int i = _pppdata->speed().toInt()/100;
switch(i) {
case 24:
return B2400;
break;
case 96:
return B9600;
break;
case 192:
return B19200;
break;
case 384:
@@ -156,35 +155,35 @@ speed_t Modem::modemspeed() {
default:
return B38400;
break;
}
}
bool Modem::opentty() {
// int flags;
//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
close(modemfd);
- device = PPPData::data()->modemDevice();
+ device = _pppdata->modemDevice();
if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
qDebug("error opening modem device !");
errmsg = i18n("Unable to open modem.");
return false;
}
//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
//}
#if 0
- if(PPPData::data()->UseCDLine()) {
+ if(_pppdata->UseCDLine()) {
if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
errmsg = i18n("Unable to detect state of CD line.");
::close(modemfd);
modemfd = -1;
return false;
}
if ((flags&TIOCM_CD) == 0) {
errmsg = i18n("The modem is not ready.");
::close(modemfd);
modemfd = -1;
return false;
}
@@ -214,26 +213,26 @@ bool Modem::opentty() {
tty.c_cc[VTIME] = 0;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
tty.c_cflag |= CS8 | CREAD;
tty.c_cflag |= CLOCAL; // ignore modem status lines
tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
tty.c_lflag &= ~ICANON; // non-canonical mode
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
- if(PPPData::data()->flowcontrol() != "None") {
- if(PPPData::data()->flowcontrol() == "CRTSCTS") {
+ if(_pppdata->flowcontrol() != "None") {
+ if(_pppdata->flowcontrol() == "CRTSCTS") {
tty.c_cflag |= CRTSCTS;
}
else {
tty.c_iflag |= IXON | IXOFF;
tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
}
}
else {
tty.c_cflag &= ~CRTSCTS;
tty.c_iflag &= ~(IXON | IXOFF);
}
@@ -344,25 +343,25 @@ bool Modem::writeChar(unsigned char c) {
}
} while(s == 0);
return true;
}
bool Modem::writeLine(const char *buf) {
int len = strlen(buf);
char *b = new char[len+2];
memcpy(b, buf, len);
// different modems seem to need different line terminations
- QString term = PPPData::data()->enter();
+ QString term = _pppdata->enter();
if(term == "LF")
b[len++]='\n';
else if(term == "CR")
b[len++]='\r';
else if(term == "CR/LF") {
b[len++]='\r';
b[len++]='\n';
}
int l = len;
while(l) {
int wr = write(modemfd, &b[len-l], l);
if(wr < 0) {
@@ -384,27 +383,27 @@ bool Modem::hangup() {
// this is probably the most imporant snippet of code in the whole of
// kppp. If people complain about kppp being stuck, this piece of code
// is most likely the reason.
struct termios temptty;
if(modemfd >= 0) {
// is this Escape & HangupStr stuff really necessary ? (Harri)
if (data_mode) escape_to_command_mode();
// Then hangup command
- writeLine(PPPData::data()->modemHangupStr().local8Bit());
+ writeLine(_pppdata->modemHangupStr().local8Bit());
- usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
+ usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec
#ifndef DEBUG_WO_DIALING
if (sigsetjmp(jmp_buffer, 1) == 0) {
// set alarm in case tcsendbreak() hangs
signal(SIGALRM, alarm_handler);
alarm(2);
tcsendbreak(modemfd, 0);
alarm(0);
signal(SIGALRM, SIG_IGN);
} else {
@@ -422,52 +421,52 @@ bool Modem::hangup() {
cfsetispeed(&temptty, B0);
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#else
int modemstat;
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat &= ~TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat |= TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
#endif
- usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs
+ usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs
cfsetospeed(&temptty, modemspeed());
cfsetispeed(&temptty, modemspeed());
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#endif
return true;
} else
return false;
}
void Modem::escape_to_command_mode() {
// Send Properly bracketed escape code to put the modem back into command state.
// A modem will accept AT commands only when it is in command state.
// When a modem sends the host the CONNECT string, that signals
// that the modem is now in the connect state (no long accepts AT commands.)
// Need to send properly timed escape sequence to put modem in command state.
// Escape codes and guard times are controlled by S2 and S12 values.
//
tcflush(modemfd, TCIOFLUSH);
// +3 because quiet time must be greater than guard time.
- usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
- QCString tmp = PPPData::data()->modemEscapeStr().local8Bit();
+ usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
+ QCString tmp = _pppdata->modemEscapeStr().local8Bit();
write(modemfd, tmp.data(), tmp.length());
tcflush(modemfd, TCIOFLUSH);
- usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
+ usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
data_mode = false;
}
const QString Modem::modemMessage() {
return errmsg;
}
QString Modem::parseModemSpeed(const QString &s) {
// this is a small (and bad) parser for modem speeds
@@ -565,34 +564,34 @@ QString Modem::parseModemSpeed(const QString &s) {
qDebug( "The parsed result is: %s", result.latin1());
return result;
}
// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
// a lock file can't be created ( permission problem )
int Modem::lockdevice() {
int fd;
char newlock[80]=""; // safe
- if(!PPPData::data()->modemLockFile()) {
+ if(!_pppdata->modemLockFile()) {
qDebug("The user doesn't want a lockfile.");
return 0;
}
if (modem_is_locked)
return 1;
QString lockfile = LOCK_DIR"/LCK..";
- lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/
+ lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/
if(access(QFile::encodeName(lockfile), F_OK) == 0) {
// if ((fd = Requester::rq->
if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
// Mario: it's not necessary to read more than lets say 32 bytes. If
// file has more than 32 bytes, skip the rest
char oldlock[33]; // safe
int sz = read(fd, &oldlock, 32);
close (fd);
if (sz <= 0)
return 1;
oldlock[sz] = '\0';
@@ -605,25 +604,25 @@ if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
// found a pid in lockfile ?
if (match < 1 || oldpid <= 0)
return 1;
// check if process exists
if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
return 1;
qDebug( "lockfile is stale" );
}
}
- fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
+ fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
if(fd >= 0) {
sprintf(newlock,"%010d\n", getpid());
qDebug("Locking Device: %s", newlock);
write(fd, newlock, strlen(newlock));
close(fd);
modem_is_locked=true;
return 0;
}
return -1;
@@ -979,33 +978,33 @@ void Modem::parseargs(char* buf, char** args) {
while ((*buf != '\0') && (*buf != quotes))
buf++;
*buf++ = '\0';
}
}
*args = 0L;
}
bool Modem::execPPPDaemon(const QString & arguments)
{
if(execpppd(arguments)==0) {
- PPPData::data()->setpppdRunning(true);
+ _pppdata->setpppdRunning(true);
return true;
} else
return false;
}
void Modem::killPPPDaemon()
{
- PPPData::data()->setpppdRunning(false);
+ _pppdata->setpppdRunning(false);
killpppd();
}
int Modem::pppdExitStatus()
{
return _pppdExitStatus;
}
int Modem::openResolv(int flags)
{
int fd;
if ((fd = open(_PATH_RESCONF, flags)) == -1) {
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h
index b494977..103cbeb 100644
--- a/noncore/settings/networksettings/ppp/modem.h
+++ b/noncore/settings/networksettings/ppp/modem.h
@@ -26,33 +26,33 @@
#ifndef _MODEM_H_
#define _MODEM_H_
#include <qdir.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <qsocketnotifier.h>
-//#include <config.h>
+class PPPData;
void alarm_handler(int);
const char *pppdPath();
class Modem : public QObject {
Q_OBJECT
public:
- Modem();
+ Modem(PPPData*);
~Modem();
const QString getDevice() {return device;};
void setDevice(const QString dev) {device = dev;};
bool opentty();
bool closetty();
bool hangup();
bool writeChar(unsigned char);
bool writeLine(const char *);
bool dataMode() const { return data_mode; }
void setDataMode(bool set) { data_mode = set; }
@@ -67,25 +67,25 @@ public:
void unlockdevice();
bool setSecret(int,const char*,const char*);
bool removeSecret(int);
void killPPPDaemon();
int pppdExitStatus();
bool execPPPDaemon(const QString & arguments);
int openResolv(int flags);
bool setHostname(const QString & name);
public:
enum Auth { PAP = 1, CHAP };
- static Modem *modem;
+ // static Modem *modem;
int lastStatus;
signals:
void charWaiting(unsigned char);
private slots:
void startNotifier();
void stopNotifier();
void readtty(int);
private:
enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
@@ -103,17 +103,18 @@ private:
private:
QString device;
QString lockfile;
int modemfd;
int pppdPid;
int _pppdExitStatus;
QSocketNotifier *sn;
bool data_mode;
QString errmsg;
struct termios initial_tty;
struct termios tty;
bool modem_is_locked;
+ PPPData *_pppdata;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
index 65032e8..1d9db6e 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.cpp
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -31,26 +31,26 @@
//#include <kapplication.h> // for getMiniIcon()
//#include <klocale.h>
#define i18n QObject::tr
#include "modemcmds.h"
#include "pppdata.h"
//#include <kwin.h>
#define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE);
// a little trick to make the label look like a disabled lineedit
#define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2);
-ModemCommands::ModemCommands(QWidget *parent, const char *name)
- : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel)
+ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name)
+ : QDialog(parent, name, true ), _pppdata(pd)
{
setCaption(i18n("Edit Modem Commands"));
const int GRIDROWS = 22;
int row = 0;
// toplevel layout
QVBoxLayout *tl = new QVBoxLayout(this, 10, 4);
// add grid + frame
QGridLayout *l1 = new QGridLayout(GRIDROWS, 4);
tl->addLayout(l1);
@@ -231,88 +231,88 @@ ModemCommands::ModemCommands(QWidget *parent, const char *name)
l6->addWidget(volume_off);
l6->addWidget(volume_medium);
l6->addWidget(volume_high);
initstr[0]->setFocus();
l1->addColSpacing(0, 10);
l1->addColSpacing(3, 10);
l1->addRowSpacing(0, 5);
l1->addRowSpacing(GRIDROWS, 5);
//set stuff from gpppdata
- preinitslider->setValue(PPPData::data()->modemPreInitDelay());
- lpreinitslider->setNum(PPPData::data()->modemPreInitDelay());
+ preinitslider->setValue(_pppdata->modemPreInitDelay());
+ lpreinitslider->setNum(_pppdata->modemPreInitDelay());
for(int i = 0; i < PPPData::NumInitStrings; i++)
- initstr[i]->setText(PPPData::data()->modemInitStr(i));
- initslider->setValue(PPPData::data()->modemInitDelay());
- linitslider->setNum(PPPData::data()->modemInitDelay());
- initresp->setText(PPPData::data()->modemInitResp());
+ initstr[i]->setText(_pppdata->modemInitStr(i));
+ initslider->setValue(_pppdata->modemInitDelay());
+ linitslider->setNum(_pppdata->modemInitDelay());
+ initresp->setText(_pppdata->modemInitResp());
- durationslider->setValue(PPPData::data()->modemToneDuration());
- ldurationslider->setNum(PPPData::data()->modemToneDuration());
+ durationslider->setValue(_pppdata->modemToneDuration());
+ ldurationslider->setNum(_pppdata->modemToneDuration());
- nodetectdialtone->setText(PPPData::data()->modemNoDialToneDetectionStr());
- dialstr->setText(PPPData::data()->modemDialStr());
- connectresp->setText(PPPData::data()->modemConnectResp());
- busyresp->setText(PPPData::data()->modemBusyResp());
- nocarrierresp->setText(PPPData::data()->modemNoCarrierResp());
- nodialtoneresp->setText(PPPData::data()->modemNoDialtoneResp());
+ nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr());
+ dialstr->setText(_pppdata->modemDialStr());
+ connectresp->setText(_pppdata->modemConnectResp());
+ busyresp->setText(_pppdata->modemBusyResp());
+ nocarrierresp->setText(_pppdata->modemNoCarrierResp());
+ nodialtoneresp->setText(_pppdata->modemNoDialtoneResp());
- escapestr->setText(PPPData::data()->modemEscapeStr());
- escaperesp->setText(PPPData::data()->modemEscapeResp());
+ escapestr->setText(_pppdata->modemEscapeStr());
+ escaperesp->setText(_pppdata->modemEscapeResp());
- hangupstr->setText(PPPData::data()->modemHangupStr());
- hangupresp->setText(PPPData::data()->modemHangupResp());
+ hangupstr->setText(_pppdata->modemHangupStr());
+ hangupresp->setText(_pppdata->modemHangupResp());
- answerstr->setText(PPPData::data()->modemAnswerStr());
- ringresp->setText(PPPData::data()->modemRingResp());
- answerresp->setText(PPPData::data()->modemAnswerResp());
+ answerstr->setText(_pppdata->modemAnswerStr());
+ ringresp->setText(_pppdata->modemRingResp());
+ answerresp->setText(_pppdata->modemAnswerResp());
- slider->setValue(PPPData::data()->modemEscapeGuardTime());
- lslider->setNum(PPPData::data()->modemEscapeGuardTime());
+ slider->setValue(_pppdata->modemEscapeGuardTime());
+ lslider->setNum(_pppdata->modemEscapeGuardTime());
- volume_off->setText(PPPData::data()->volumeOff());
- volume_medium->setText(PPPData::data()->volumeMedium());
- volume_high->setText(PPPData::data()->volumeHigh());
+ volume_off->setText(_pppdata->volumeOff());
+ volume_medium->setText(_pppdata->volumeMedium());
+ volume_high->setText(_pppdata->volumeHigh());
}
void ModemCommands::slotOk() {
- PPPData::data()->setModemPreInitDelay(lpreinitslider->text().toInt());
+ _pppdata->setModemPreInitDelay(lpreinitslider->text().toInt());
for(int i = 0; i < PPPData::NumInitStrings; i++)
- PPPData::data()->setModemInitStr(i, initstr[i]->text());
- PPPData::data()->setModemInitResp(initresp->text());
- PPPData::data()->setModemInitDelay(linitslider->text().toInt());
-
- PPPData::data()->setModemToneDuration(ldurationslider->text().toInt());
- PPPData::data()->setModemNoDialToneDetectionStr(nodetectdialtone->text());
- PPPData::data()->setModemDialStr(dialstr->text());
- PPPData::data()->setModemConnectResp(connectresp->text());
- PPPData::data()->setModemBusyResp(busyresp->text());
- PPPData::data()->setModemNoCarrierResp(nocarrierresp->text());
- PPPData::data()->setModemNoDialtoneResp(nodialtoneresp->text());
-
- PPPData::data()->setModemEscapeStr(escapestr->text());
- PPPData::data()->setModemEscapeResp(escaperesp->text());
- PPPData::data()->setModemEscapeGuardTime(lslider->text().toInt());
- PPPData::data()->setModemHangupStr(hangupstr->text());
- PPPData::data()->setModemHangupResp(hangupresp->text());
-
- PPPData::data()->setModemAnswerStr(answerstr->text());
- PPPData::data()->setModemRingResp(ringresp->text());
- PPPData::data()->setModemAnswerResp(answerresp->text());
-
- PPPData::data()->setVolumeHigh(volume_high->text());
- PPPData::data()->setVolumeMedium(volume_medium->text());
- PPPData::data()->setVolumeOff(volume_off->text());
-
- PPPData::data()->save();
+ _pppdata->setModemInitStr(i, initstr[i]->text());
+ _pppdata->setModemInitResp(initresp->text());
+ _pppdata->setModemInitDelay(linitslider->text().toInt());
+
+ _pppdata->setModemToneDuration(ldurationslider->text().toInt());
+ _pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text());
+ _pppdata->setModemDialStr(dialstr->text());
+ _pppdata->setModemConnectResp(connectresp->text());
+ _pppdata->setModemBusyResp(busyresp->text());
+ _pppdata->setModemNoCarrierResp(nocarrierresp->text());
+ _pppdata->setModemNoDialtoneResp(nodialtoneresp->text());
+
+ _pppdata->setModemEscapeStr(escapestr->text());
+ _pppdata->setModemEscapeResp(escaperesp->text());
+ _pppdata->setModemEscapeGuardTime(lslider->text().toInt());
+ _pppdata->setModemHangupStr(hangupstr->text());
+ _pppdata->setModemHangupResp(hangupresp->text());
+
+ _pppdata->setModemAnswerStr(answerstr->text());
+ _pppdata->setModemRingResp(ringresp->text());
+ _pppdata->setModemAnswerResp(answerresp->text());
+
+ _pppdata->setVolumeHigh(volume_high->text());
+ _pppdata->setVolumeMedium(volume_medium->text());
+ _pppdata->setVolumeOff(volume_off->text());
+
+ _pppdata->save();
accept();
}
void ModemCommands::slotCancel() {
reject();
}
//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h
index 9d078ec..ef69fec 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.h
+++ b/noncore/settings/networksettings/ppp/modemcmds.h
@@ -35,32 +35,33 @@
#include <qdialog.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include "pppdata.h"
class ModemCommands : public QDialog {
Q_OBJECT
public:
- ModemCommands(QWidget *parent=0, const char *name=0);
+ ModemCommands(PPPData*, QWidget *parent=0, const char *name=0);
~ModemCommands() {}
private slots:
void slotCancel();
void slotOk();
private:
+ PPPData *_pppdata;
QGroupBox *box;
QLineEdit *initstr[int(PPPData::NumInitStrings)];
QLineEdit *initresp;
QLabel *label2;
QLabel *lpreinitslider;
QLabel *lpreinit;
QLabel *linitslider;
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index 4dbbcf5..0bec186 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -28,26 +28,27 @@
#include <qregexp.h>
#include <qlayout.h>
// #include <kwin.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include "modeminfo.h"
#include "modem.h"
//#include <klocale.h>
#define i18n QObject::tr
-ModemTransfer::ModemTransfer(QWidget *parent, const char *name)
- : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder)
+ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
+ : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder),
+ _modem(mo)
{
setCaption(i18n("ATI Query"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
progressBar = new QProgressBar(this, "bar");
progressBar->setTotalSteps(8);
statusBar = new QLabel(this,"sBar");
statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken);
statusBar->setAlignment(AlignCenter);
@@ -88,26 +89,26 @@ ModemTransfer::ModemTransfer(QWidget *parent, const char *name)
scripttimer = new QTimer(this);
connect(scripttimer, SIGNAL(timeout()), SLOT(do_script()));
timeout_timer->start(15000,TRUE); // 15 secs single shot
QTimer::singleShot(500, this, SLOT(init()));
}
void ModemTransfer::ati_done() {
scripttimer->stop();
timeout_timer->stop();
- Modem::modem->closetty();
- Modem::modem->unlockdevice();
+ _modem->closetty();
+ _modem->unlockdevice();
hide();
// open the result window
ModemInfo *mi = new ModemInfo(this);
for(int i = 0; i < NUM_OF_ATI; i++)
mi->setAtiString(i, ati_query_strings[i]);
mi->showMaximized();
mi->exec();
delete mi;
accept();
}
@@ -117,89 +118,89 @@ void ModemTransfer::time_out_slot() {
timeout_timer->stop();
scripttimer->stop();
QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out."));
reject();
}
void ModemTransfer::init() {
qApp->processEvents();
- int lock = Modem::modem->lockdevice();
+ int lock = _modem->lockdevice();
if (lock == 1) {
statusBar->setText(i18n("Modem device is locked."));
return;
}
if (lock == -1) {
statusBar->setText(i18n("Unable to create modem lock file."));
return;
}
- if(Modem::modem->opentty()) {
- if(Modem::modem->hangup()) {
+ if(_modem->opentty()) {
+ if(_modem->hangup()) {
usleep(100000); // wait 0.1 secs
- Modem::modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
+ _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
statusBar->setText(i18n("Modem Ready"));
qApp->processEvents();
usleep(100000); // wait 0.1 secs
qApp->processEvents();
scripttimer->start(1000); // this one does the ati query
// clear modem buffer
- Modem::modem->flush();
+ _modem->flush();
- Modem::modem->notify(this, SLOT(readChar(unsigned char)));
+ _modem->notify(this, SLOT(readChar(unsigned char)));
return;
}
}
// opentty() or hangup() failed
- statusBar->setText(Modem::modem->modemMessage());
+ statusBar->setText(_modem->modemMessage());
step = 99; // wait until cancel is pressed
- Modem::modem->unlockdevice();
+ _modem->unlockdevice();
}
void ModemTransfer::do_script() {
QString msg;
QString query;
switch(step) {
case 0:
readtty();
statusBar->setText("ATI...");
progressBar->setProgress( progressBar->progress() + 1);
- Modem::modem->writeLine("ATI\n");
+ _modem->writeLine("ATI\n");
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
readtty();
msg.sprintf("ATI %d ...", step);
query.sprintf("ATI%d\n", step);
statusBar->setText(msg);
progressBar->setProgress( progressBar->progress() + 1);
- Modem::modem->writeLine(query.local8Bit());
+ _modem->writeLine(query.local8Bit());
break;
default:
readtty();
ati_done();
}
step++;
}
void ModemTransfer::readChar(unsigned char c) {
if(readbuffer.length() < 255)
readbuffer += c;
@@ -214,34 +215,34 @@ void ModemTransfer::readtty() {
readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white
// space
if(step <= NUM_OF_ATI)
ati_query_strings[step-1] = readbuffer.copy();
readbuffer = "";
}
void ModemTransfer::cancelbutton() {
scripttimer->stop();
- Modem::modem->stop();
+ _modem->stop();
timeout_timer->stop();
statusBar->setText(i18n("One moment please..."));
qApp->processEvents();
- Modem::modem->hangup();
+ _modem->hangup();
- Modem::modem->closetty();
- Modem::modem->unlockdevice();
+ _modem->closetty();
+ _modem->unlockdevice();
reject();
}
void ModemTransfer::closeEvent( QCloseEvent *e ) {
cancelbutton();
e->accept();
}
ModemInfo::ModemInfo(QWidget *parent, const char* name)
: QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder)
diff --git a/noncore/settings/networksettings/ppp/modeminfo.h b/noncore/settings/networksettings/ppp/modeminfo.h
index 7aa2cc0..dfcc841 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.h
+++ b/noncore/settings/networksettings/ppp/modeminfo.h
@@ -28,47 +28,50 @@
#ifndef _MODEMINFO_H_
#define _MODEMINFO_H_
#include <qdialog.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qevent.h>
#include <qtimer.h>
//#include <kprogress.h>
#include <qprogressbar.h>
+class Modem;
+
const int NUM_OF_ATI = 8;
class ModemTransfer : public QDialog {
Q_OBJECT
public:
- ModemTransfer(QWidget *parent=0, const char *name=0);
+ ModemTransfer(Modem*, QWidget *parent=0, const char *name=0);
public slots:
void init();
void readtty();
void do_script();
void time_out_slot();
void cancelbutton();
void readChar(unsigned char);
private:
void ati_done();
protected:
void closeEvent(QCloseEvent *e);
private:
+ Modem *_modem;
int step;
QString readbuffer;
QPushButton *cancel;
QProgressBar *progressBar;
QLabel *statusBar;
QTimer *timeout_timer;
QTimer *scripttimer;
QString ati_query_strings[NUM_OF_ATI];
};
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index ac438dd..483aa58 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,20 +1,20 @@
#TEMPLATE = app
#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
-#
-SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp
-#
+HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h
+# kpppwidget.h
+SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp
+# kpppwidget.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
INTERFACES =
TARGET = pppplugin
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index 4c5f7aa..63f9335 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,77 +1,72 @@
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtabwidget.h>
#include "accounts.h"
#include "general.h"
-#include "interface.h"
+#include "interfaceppp.h"
#include "modem.h"
#include "pppconfig.h"
#include "pppdata.h"
#include "runtests.h"
-PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent,
+PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent,
const char *name,
bool modal, WFlags fl )
: QDialog(parent, name, modal, fl)
{
setCaption(tr("Configure Modem"));
int result = runTests();
if(result == TEST_CRITICAL){
QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
return;
}
interface = iface;
- if (!PPPData::data()->setModemDevice( interface->getInterfaceName() ))
- PPPData::data()->setModemDevice("/dev/modem");
qDebug("PPPConfigWidget::PPPConfigWidget");
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
- if (!PPPData::data()->setAccount( interface->getHardwareName() ))
- PPPData::data()->setAccount( 0 );
- qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1());
- qDebug(" PPPData::data()->currentAccountID() >%i<",PPPData::data()->currentAccountID());
- (void)new Modem;
+ qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
+ qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID());
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( this, "tabWidget" );
layout->addWidget( tabWindow );
- accounts = new AccountWidget( tabWindow, "accounts" );
+ accounts = new AccountWidget( interface->data(), tabWindow, "accounts" );
tabWindow->addTab( accounts, tr("&Accounts") );
- modem1 = new ModemWidget( tabWindow, "modem1" );
+ modem1 = new ModemWidget( interface, tabWindow, "modem1" );
tabWindow->addTab( modem1, tr("&Device") );
- modem2 = new ModemWidget2( tabWindow, "modem2" );
+ modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
tabWindow->addTab( modem2, tr("&Modem") );
// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
}
PPPConfigWidget::~PPPConfigWidget()
{
}
void PPPConfigWidget::accept()
{
qDebug("PPPConfigWidget::accept");
- qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1());
+ qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
- interface->setInterfaceName( PPPData::data()->modemDevice() );
- interface->setHardwareName( PPPData::data()->accname() );
- PPPData::data()->save();
+ interface->setInterfaceName( interface->data()->modemDevice() );
+ interface->setHardwareName( interface->data()->accname() );
+ interface->data()->save();
QDialog::accept();
}
void PPPConfigWidget::reject()
{
- PPPData::data()->cancel();
+ interface->data()->cancel();
QDialog::reject();
}
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
index b324b6d..9bab6fe 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.h
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -1,36 +1,37 @@
#ifndef _PPPCONFIG_H_
#define _PPPCONFIG_H_
#include <qdialog.h>
class QTabWidget;
-class Interface;
+//class Interface;
+class InterfacePPP;
class AccountWidget;
class GeneralWidget;
class ModemWidget;
class ModemWidget2;
class PPPConfigWidget : public QDialog {
Q_OBJECT
public:
- PPPConfigWidget( Interface*, QWidget *parent=0, const char *name=0,
+ PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0,
bool modal = false, WFlags fl = 0 );
~PPPConfigWidget();
protected slots:
virtual void accept();
virtual void reject();
private:
- Interface *interface;
+ InterfacePPP *interface;
QTabWidget *tabWindow;
AccountWidget *accounts;
GeneralWidget *general;
ModemWidget *modem1;
ModemWidget2 *modem2;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 4039939..d1143cf 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -25,26 +25,26 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qlayout.h>
#include <qbuttongroup.h>
//#include <kwin.h>
#include <qapplication.h>
#include "pppdargs.h"
#include "pppdata.h"
//#include <klocale.h>
#define i18n QObject::tr
-PPPdArguments::PPPdArguments(QWidget *parent, const char *name)
- : QDialog(parent, name, TRUE)
+PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name)
+ : QDialog(parent, name, TRUE), _pppdata(pd)
{
setCaption(i18n("Customize pppd Arguments"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *l = new QVBoxLayout(this, 10, 10);
QHBoxLayout *tl = new QHBoxLayout(10);
l->addLayout(tl);
QVBoxLayout *l1 = new QVBoxLayout();
QVBoxLayout *l2 = new QVBoxLayout();
tl->addLayout(l1, 1);
tl->addLayout(l2, 0);
QHBoxLayout *l11 = new QHBoxLayout(10);
@@ -112,50 +112,50 @@ void PPPdArguments::addbutton() {
}
void PPPdArguments::removebutton() {
if(arguments->currentItem() >= 0)
arguments->removeItem(arguments->currentItem());
}
void PPPdArguments::defaultsbutton() {
// all of this is a hack
// save current list
- QStringList arglist(PPPData::data()->pppdArgument());
+ QStringList arglist(_pppdata->pppdArgument());
// get defaults
- PPPData::data()->setpppdArgumentDefaults();
+ _pppdata->setpppdArgumentDefaults();
init();
// restore old list
- PPPData::data()->setpppdArgument(arglist);
+ _pppdata->setpppdArgument(arglist);
}
void PPPdArguments::closebutton() {
QStringList arglist;
for(uint i=0; i < arguments->count(); i++)
arglist.append(arguments->text(i));
- PPPData::data()->setpppdArgument(arglist);
+ _pppdata->setpppdArgument(arglist);
done(0);
}
void PPPdArguments::init() {
while(arguments->count())
arguments->removeItem(0);
- QStringList &arglist = PPPData::data()->pppdArgument();
+ QStringList &arglist = _pppdata->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
++it )
arguments->insertItem(*it);
}
void PPPdArguments::textChanged(const QString &s) {
add->setEnabled(s.length() > 0);
}
diff --git a/noncore/settings/networksettings/ppp/pppdargs.h b/noncore/settings/networksettings/ppp/pppdargs.h
index c1cd28d..75f0c9d 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.h
+++ b/noncore/settings/networksettings/ppp/pppdargs.h
@@ -24,53 +24,55 @@
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _PPPDARGS_H_
#define _PPPDARGS_H_
#include <qdialog.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlabel.h>
+class PPPData;
class PPPdArguments : public QDialog {
Q_OBJECT
public:
- PPPdArguments(QWidget *parent=0, const char *name=0);
+ PPPdArguments(PPPData*,QWidget *parent=0, const char *name=0);
~PPPdArguments() {}
private slots:
void addbutton();
void removebutton();
void defaultsbutton();
void closebutton();
void textChanged(const QString &);
void itemSelected(int);
private:
void init();
QLabel *argument_label;
QLineEdit *argument;
QPushButton *add;
QPushButton *remove;
QPushButton *defaults;
QListBox *arguments;
QPushButton *closebtn;
+ PPPData *_pppdata;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 3f1675c..59d68c9 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -29,178 +29,197 @@
#include "devices.h"
//#include <klocale.h>
#define i18n QObject::tr
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qapplication.h>
// #include <klocale.h>
// #include <kconfig.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
-PPPData *PPPData::_data = 0;
-Config *PPPData::config = 0;
-
-PPPData* PPPData::data()
-{
- if (!_data){
- qDebug("PPPData::data() creates new Instance");
- _data = new PPPData();
- }
- if (!_data->config){
- qDebug("PPPData::data() opens conffile");
- _data->open();
- }
- return _data;
-}
+#define SEPARATOR -sseepp-
+#define SEP QString("%1SEPARATOR%1")
PPPData::PPPData()
: modemDeviceGroup(-1),
highcount(-1), // start out with no entries
caccount(-1), // set the current account index also
suidprocessid(-1), // process ID of setuid child
pppdisrunning(false),
pppderror(0)
{
-}
-
-
-//
-// open configuration file
-//
-bool PPPData::open() {
- qDebug("opening configfile NetworkSetupPPP");
- if (config) return true;
- config = new Config("NetworkSetupPPP");
-
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
if (highcount > MAX_ACCOUNTS)
highcount = MAX_ACCOUNTS;
if(highcount >= 0 && defaultAccount().isEmpty()) {
setAccountbyIndex(0);
setDefaultAccount(accname());
} else if(!setAccount(defaultAccount()))
setDefaultAccount(accname());
// start out with internal debugging disabled
// the user is still free to specify `debug' on his own
setPPPDebug(false);
::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
- return true;
}
+Config PPPData::config()
+{
+ return Config("NetworkSetupPPP");
+}
//
// save configuration
//
-void PPPData::save() {
-
- if (config) {
+void PPPData::save()
+{
+ qDebug("PPPData saving data");
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
- delete config;
- config = 0;
- qDebug("worte confi NetworkSetupPPP");
- }
- if (_data){
- delete _data;
- _data = 0;
- }
-
+ QString key;
+ QStringList keys;
+ Config cfg = config();
+ for( QMap<QString,QString>::Iterator it = stringEntries.begin();
+ it != stringEntries.end(); ++it ){
+ QString val = it.data();
+ key = it.key();
+// qDebug("saving %s -> %s", key.latin1(), val.latin1() );
+ keys = QStringList::split( "SEPARATOR", key );
+ qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ cfg.setGroup(keys[0]);
+ cfg.writeEntry(keys[1], val);
+ }
+ for( QMap<QString,int>::Iterator it = intEntries.begin();
+ it != intEntries.end(); ++it ){
+ int val = it.data();
+ key = it.key();
+// qDebug("saving %s -> %i", key.latin1(), val );
+ keys = QStringList::split( "SEPARATOR", key );
+ qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
+ cfg.setGroup(keys[0]);
+ cfg.writeEntry(keys[1], val);
+ }
+ for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
+ it != listEntries.end(); ++it ){
+ QStringList val = it.data();
+ key = it.key();
+ QChar sep = sepEntries[key];
+// qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() );
+ keys = QStringList::split( "SEPARATOR", key );
+ qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() );
+ cfg.setGroup(keys[0]);
+ cfg.writeEntry(keys[1], val, sep);
+ }
}
//
// cancel changes
//
void PPPData::cancel() {
-
-// if (config) {
-// config->rollback();
-// config->reparseConfiguration();
-// }
-
+ stringEntries.clear();
+ intEntries.clear();
+ listEntries.clear();
}
-
-// // currently differentiates between READWRITE and NONE only
-// int PPPData::access() const {
-
-// return 1;//config->getConfigState();
-// }
-
-
// functions to read/write date to configuration file
QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
- if (config) {
- config->setGroup(group);
- return config->readEntry(key, defvalue);
- } else
- return defvalue;
+ QString idx = SEP.arg(group).arg(key);
+ if (stringEntries.find(idx) != stringEntries.end())
+ return stringEntries[idx];
+ Config cfg = config();
+ cfg.setGroup(group);
+ return cfg.readEntry(key, defvalue);
}
int PPPData::readNumConfig(const QString &group, const QString &key,
- int defvalue) {
- if (config) {
- config->setGroup(group);
- return config->readNumEntry(key, defvalue);
- } else
- return defvalue;
+ int defvalue)
+{
+ QString idx = SEP.arg(group).arg(key);
+ if (intEntries.find(idx) != intEntries.end())
+ return intEntries[idx];
+ Config cfg = config();
+ cfg.setGroup(group);
+ return cfg.readNumEntry(key, defvalue);
+
+// if (config) {
+// config->setGroup(group);
+// return config->readNumEntry(key, defvalue);
+// } else
+// return defvalue;
}
bool PPPData::readListConfig(const QString &group, const QString &key,
QStringList &list, char sep) {
list.clear();
- if (config) {
- config->setGroup(group);
- list = config->readListEntry(key, sep);
- return true;
- } else
- return false;
+ QString idx = SEP.arg(group).arg(key);
+ if (listEntries.find(idx) != listEntries.end()){
+ list = listEntries[idx];
+ return true;
+ }
+ Config cfg = config();
+ cfg.setGroup(group);
+ list = cfg.readListEntry(key, sep);
+ if (list.count() > 0) return true;
+ return false;
+
+// if (config) {
+// config->setGroup(group);
+// list = config->readListEntry(key, sep);
+// return true;
+// } else
+// return false;
}
void PPPData::writeConfig(const QString &group, const QString &key,
const QString &value) {
- if (config) {
- config->setGroup(group);
- config->writeEntry(key, value);
- }
+ stringEntries.insert( SEP.arg(group).arg(key), value );
+// if (config) {
+// config->setGroup(group);
+// config->writeEntry(key, value);
+// }
}
-void PPPData::writeConfig(const QString &group, const QString &key, int value) {
- if (config) {
- config->setGroup(group);
- config->writeEntry(key, value);
- }
+void PPPData::writeConfig(const QString &group, const QString &key, int value)
+{
+ intEntries.insert( SEP.arg(group).arg(key), value );
+// if (config) {
+// config->setGroup(group);
+// config->writeEntry(key, value);
+// }
}
void PPPData::writeListConfig(const QString &group, const QString &key,
- QStringList &list, char sep) {
- if (config) {
- config->setGroup(group);
- config->writeEntry(key, list, sep);
- }
+ QStringList &list, char sep)
+{
+ listEntries.insert( SEP.arg(group).arg(key), list );
+ sepEntries.insert( SEP.arg(group).arg(key), sep );
+// if (config) {
+// config->setGroup(group);
+// config->writeEntry(key, list, sep);
+// }
}
//
// functions to set/return general information
//
QString PPPData::password() const {
return passwd;
}
void PPPData::setPassword(const QString &pw) {
@@ -272,42 +291,42 @@ void PPPData::set_show_log_window(bool set) {
bool PPPData::automatic_redial() {
return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
}
void PPPData::set_automatic_redial(bool set) {
writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
}
-bool PPPData::get_iconify_on_connect() {
- return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
-}
+// bool PPPData::get_iconify_on_connect() {
+// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
+// }
-void PPPData::set_iconify_on_connect(bool set) {
- writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
-}
+// void PPPData::set_iconify_on_connect(bool set) {
+// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
+// }
-bool PPPData::get_dock_into_panel() {
- return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
-}
+// bool PPPData::get_dock_into_panel() {
+// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
+// }
-void PPPData::set_dock_into_panel(bool set) {
- writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
-}
+// void PPPData::set_dock_into_panel(bool set) {
+// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
+// }
QString PPPData::pppdVersion() {
return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
}
bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
// check if pppd version fulfills minimum requirement
return (pppdVer > ver
|| (pppdVer == ver && pppdMod > mod)
|| (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
}
@@ -781,25 +800,25 @@ bool PPPData::deleteAccount(const QString &aname) {
if(!setAccount(aname))
return false;
deleteAccount();
return true;
}
int PPPData::newaccount() {
qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
- if(!config) open();
+// if(!config) open();
if (highcount >= MAX_ACCOUNTS) return -1;
highcount++;
setAccountbyIndex(highcount);
setpppdArgumentDefaults();
qDebug("PPPData::newaccount -> %i",caccount);
return caccount;
}
int PPPData::copyaccount(int i) {
// FIXME
@@ -981,32 +1000,32 @@ void PPPData::setAutoname(bool set) {
bool PPPData::AcctEnabled() {
return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
}
void PPPData::setAcctEnabled(bool set) {
writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
}
-int PPPData::VolAcctEnabled() {
- return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
-}
+// int PPPData::VolAcctEnabled() {
+// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
+// }
-void PPPData::setVolAcctEnabled(int set) {
- writeConfig(cgroup, VOLACCTENABLED_KEY, set);
-}
+// void PPPData::setVolAcctEnabled(int set) {
+// writeConfig(cgroup, VOLACCTENABLED_KEY, set);
+// }
const QString PPPData::gateway() {
return readConfig(cgroup, GATEWAY_KEY);
}
void PPPData::setGateway(const QString &n ) {
writeConfig(cgroup, GATEWAY_KEY, n);
}
@@ -1014,25 +1033,25 @@ bool PPPData::defaultroute() {
// default route is by default 'on'.
return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
}
void PPPData::setDefaultroute(bool set) {
writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
}
bool PPPData::autoDNS() {
bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
- return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
+ return (set && pppdVersionMin(2, 3, 7));
}
void PPPData::setAutoDNS(bool set) {
writeConfig(cgroup, AUTODNS_KEY, (int) set);
}
void PPPData::setExDNSDisabled(bool set) {
writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
}
@@ -1217,36 +1236,41 @@ void PPPData::setpppdError(int err) {
}
QString PPPData::modemGroup()
{
if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup);
return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup);
}
QMap<QString,QString> PPPData::getConfiguredInterfaces()
{
QMap<QString,QString> ifaces;
- int count = readNumConfig( ACCLIST_GRP, ACCOUNTS_COUNT, -1 );
- QString accGrp;
+ Config config = PPPData::config();
+ config.setGroup(ACCLIST_GRP);
+ int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
+ QString accGrp, dev, acc;
for (int i = 0; i < count; i++){
accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
- ifaces.insert( readConfig( accGrp, ACOUNTS_DEV, "error" ),
- readConfig( accGrp, ACOUNTS_ACC, "error" ) );
+ config.setGroup(accGrp);
+ dev = config.readEntry( ACOUNTS_DEV, "error" );
+ acc = config.readEntry( ACOUNTS_ACC, "error" );
+ ifaces.insert( dev, acc );
}
return ifaces;
}
void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
{
QMap<QString,QString>::Iterator it;
- QString accGrp;
int i = 0;
+ Config cfg = config();
for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){
- accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
- writeConfig( accGrp, ACOUNTS_DEV, it.key() );
- writeConfig( accGrp, ACOUNTS_ACC, it.data() );
+ cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i));
+ cfg.writeEntry( ACOUNTS_DEV, it.key() );
+ cfg.writeEntry( ACOUNTS_ACC, it.data() );
}
- writeConfig( ACCLIST_GRP, ACCOUNTS_COUNT, i );
+ cfg.setGroup( ACCLIST_GRP );
+ cfg.writeEntry( ACCOUNTS_COUNT, i );
}
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index c1c7e69..af960c6 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -146,37 +146,36 @@ class Config;
#define E_IF_TIMEOUT 1
#define E_PPPD_DIED 2
// account list
#define ACCOUNTS_COUNT "Accounts_Count"
#define ACOUNTS_DEV "Accounts_Modem"
#define ACOUNTS_ACC "Accounts_Account"
class PPPData {
public:
PPPData();
~PPPData() {};
- static PPPData* data();
enum { NumInitStrings = 2 };
// general functions
- bool open();
void save();
void cancel();
- QMap<QString,QString> getConfiguredInterfaces();
- void setConfiguredInterfaces( QMap<QString,QString> );
+ static QMap<QString,QString> getConfiguredInterfaces();
+ static void setConfiguredInterfaces( QMap<QString,QString> );
// function to read/write date to configuration file
+ static Config config();
QString readConfig(const QString &, const QString &, const QString &);
int readNumConfig(const QString &, const QString &, int);
bool readListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
void writeConfig(const QString &, const QString &, const QString &);
void writeConfig(const QString &, const QString &, int);
void writeListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
// return the current account group
QString currentGroup() { return cgroup; }
QString modemGroup();
@@ -198,29 +197,29 @@ public:
void set_quit_on_disconnect(bool);
bool quit_on_disconnect();
void set_show_clock_on_caption(bool set);
bool get_show_clock_on_caption();
void set_show_log_window(bool set);
bool get_show_log_window();
void set_automatic_redial(bool set);
bool automatic_redial();
- void set_iconify_on_connect(bool set);
- bool get_iconify_on_connect();
+// void set_iconify_on_connect(bool set);
+// bool get_iconify_on_connect();
- void set_dock_into_panel(bool set);
- bool get_dock_into_panel();
+// void set_dock_into_panel(bool set);
+// bool get_dock_into_panel();
const QString enter();
void setEnter(const QString &);
QString pppdVersion();
bool pppdVersionMin(int ver, int mod, int patch);
int pppdTimeout();
void setpppdTimeout(int);
int busyWait();
void setbusyWait(int);
@@ -302,29 +301,24 @@ public:
const QString modemAnswerResp();
void setModemAnswerResp(const QString &);
QString volumeOff();
void setVolumeOff(const QString &);
QString volumeMedium();
void setVolumeMedium(const QString &);
QString volumeHigh();
void setVolumeHigh(const QString &);
-#if 0
- void setUseCDLine(const int n);
- int UseCDLine();
-#endif
-
// functions to set/get account information
int count() const;
bool setAccount(const QString &);
bool setAccountbyIndex(int);
bool isUniqueAccname(const QString &);
bool deleteAccount();
bool deleteAccount(const QString &);
int newaccount();
int copyaccount(int i);
@@ -365,26 +359,26 @@ public:
const QString command_before_disconnect();
void setCommand_before_disconnect(const QString &);
const QString ipaddr();
void setIpaddr(const QString &);
const QString subnetmask();
void setSubnetmask(const QString &);
bool AcctEnabled();
void setAcctEnabled(bool set);
- int VolAcctEnabled();
- void setVolAcctEnabled(int set);
+// int VolAcctEnabled();
+// void setVolAcctEnabled(int set);
bool autoDNS();
void setAutoDNS(bool set);
bool exDNSDisabled();
void setExDNSDisabled(bool set);
bool autoname();
void setAutoname(bool set);
const QString gateway();
void setGateway(const QString &);
@@ -406,60 +400,36 @@ public:
QStringList &pppdArgument();
void setpppdArgumentDefaults();
void setpppdArgument(QStringList &);
//functions to change/set the child pppd process info
bool pppdRunning() const;
void setpppdRunning(bool set);
int pppdError() const;
void setpppdError(int err);
- // functions to set/query the accounting info
-// const QString accountingFile();
-// void setAccountingFile(const QString &);
-
-// const QString totalCosts();
-// void setTotalCosts(const QString &);
-
-// int totalBytes();
-// void setTotalBytes(int);
-
-// // graphing widget
-// void setGraphingOptions(bool enabled,
-// QColor bg,
-// QColor text,
-// QColor in,
-// QColor out);
-// void graphingOptions(bool &enabled,
-// QColor &bg,
-// QColor &text,
-// QColor &in,
-// QColor &out);
-// bool graphingEnabled();
-
-// // window positions
-// void winPosConWin(int &, int &);
-// void setWinPosConWin(int, int);
-// void winPosStatWin(int &, int &);
-// void setWinPosStatWin(int, int);
-
private:
- static PPPData *_data;
+ //static PPPData *_data;
int modemDeviceGroup;
QString passwd;
- static Config* config; // configuration object
+ // static Config* config; // configuration object
int highcount; // index of highest account
int caccount; // index of the current account
QString cgroup; // name of current config group
pid_t suidprocessid; // process ID of setuid child
bool pppdisrunning; // pppd process
// daemon
int pppderror; // error encounterd running pppd
int pppdVer, pppdMod, pppdPatch; // pppd version
QStringList phonelist;
+ QMap<QString,QString> stringEntries;
+ QMap<QString,int> intEntries;
+ QMap<QString,QStringList> listEntries;
+ QMap<QString,QChar> sepEntries;
+
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 7cbccc2..95df068 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,48 +1,48 @@
+
#include "pppconfig.h"
#include "pppmodule.h"
#include "pppdata.h"
-#include "kpppwidget.h"
-#include "interfaceinformationimp.h"
-//#include "devices.h"
+#include "interfaceinformationppp.h"
+#include "interfaceppp.h"
+
/**
* Constructor, find all of the possible interfaces
*/
PPPModule::PPPModule() : Module()
{
- QMap<QString,QString> ifaces = PPPData::data()->getConfiguredInterfaces();
+ QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
QMap<QString,QString>::Iterator it;
- Interface *iface;
+ InterfacePPP *iface;
qDebug("getting interfaces");
for( it = ifaces.begin(); it != ifaces.end(); ++it ){
qDebug("ifaces %s", it.key().latin1());
- iface = new Interface( 0, it.key() );
+ iface = new InterfacePPP( 0, it.key() );
iface->setHardwareName( it.data() );
- list.append( iface );
+ list.append( (Interface*)iface );
}
}
/**
* Delete any interfaces that we own.
*/
PPPModule::~PPPModule(){
QMap<QString,QString> ifaces;
Interface *i;
for ( i=list.first(); i != 0; i=list.next() ){
ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
delete i;
}
- PPPData::data()->setConfiguredInterfaces( ifaces );
- PPPData::data()->save();
+ PPPData::setConfiguredInterfaces( ifaces );
}
/**
* Change the current profile
*/
void PPPModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
@@ -58,69 +58,72 @@ QString PPPModule::getPixmapName(Interface* ){
* @return bool true if i is owned by this module, false otherwise.
*/
bool PPPModule::isOwner(Interface *i){
return list.find( i ) != -1;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
qDebug("return ModemWidget");
- PPPConfigWidget *pppconfig = new PPPConfigWidget( i, 0, "PPPConfig",
- false,
+ PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
+ 0, "PPPConfig", false,
Qt::WDestructiveClose );
return pppconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *PPPModule::information(Interface *i){
// We don't have any advanced pppd information widget yet :-D
// TODO ^
qDebug("return PPPModule::information");
- InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
+// InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
+ InterfaceInformationPPP *information = new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
return information;
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> PPPModule::getInterfaces(){
// List all of the files in the peer directory
qDebug("PPPModule::getInterfaces");
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *PPPModule::addNewInterface(const QString &newInterface){
qDebug("try to add iface %s",newInterface.latin1());
+ InterfacePPP *ifaceppp;
Interface *iface;
- iface = new Interface();
- PPPConfigWidget imp(iface, 0, "PPPConfigImp", true);
+ ifaceppp = new InterfacePPP();
+ PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
iface->setModuleOwner( this );
+ iface = ifaceppp;
list.append( iface );
return iface;
}else {
delete iface;
iface = NULL;
}
return iface;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.