summaryrefslogtreecommitdiff
authorzecke <zecke>2004-10-14 01:44:27 (UTC)
committer zecke <zecke>2004-10-14 01:44:27 (UTC)
commit474150327729d63706b89a54414ead68acd83fc9 (patch) (side-by-side diff)
tree633f60754361699393e484c4ef774947f46aafa8
parenta1aed5edd5ccef77d79ccdd2d74f5c029d037617 (diff)
downloadopie-474150327729d63706b89a54414ead68acd83fc9.zip
opie-474150327729d63706b89a54414ead68acd83fc9.tar.gz
opie-474150327729d63706b89a54414ead68acd83fc9.tar.bz2
-FlowControl and LineTermination are saved and activated by numerical
value now. This makes it work across different translations -Switch code to use new PPPData::enter() and PPPData::flowcontrol()
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp34
-rw-r--r--noncore/settings/networksettings/ppp/general.h4
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp16
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp12
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h19
6 files changed, 45 insertions, 44 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 128877a..8981e01 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1170,98 +1170,98 @@ void ConnectWidget::if_waiting_slot() {
_ifaceppp->modem()->closetty();
}
void ConnectWidget::refresh() {
_ifaceppp->refresh();
if ( _ifaceppp->getStatus() ) {
messg->setText(QObject::tr("Online"));
} else {
messg->setText(QObject::tr("Offline"));
}
}
bool ConnectWidget::execppp() {
QString command;
command = "pppd";
// as of version 2.3.6 pppd falls back to the real user rights when
// opening a device given in a command line. To avoid permission conflicts
// we'll simply leave this argument away. pppd will then use the default tty
// which is the serial port we connected stdin/stdout to in opener.cpp.
// command += " ";
// command += _ifaceppp->data()->modemDevice();
command += " " + _ifaceppp->data()->speed();
command += " -detach";
if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
_ifaceppp->data()->gateway() != "0.0.0.0") {
if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
command += " ";
command += _ifaceppp->data()->ipaddr();
command += ":";
}
else {
command += " ";
command += ":";
}
if(_ifaceppp->data()->gateway() != "0.0.0.0")
command += _ifaceppp->data()->gateway();
}
if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
command += " netmask " + _ifaceppp->data()->subnetmask();
- if(_ifaceppp->data()->flowcontrol() != "None") {
- if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
+ if(_ifaceppp->data()->flowcontrol() != PPPData::FlowNone) {
+ if(_ifaceppp->data()->flowcontrol() == PPPData::FlowHardware)
command += " crtscts";
else
command += " xonxoff";
}
if(_ifaceppp->data()->defaultroute())
command += " defaultroute";
if(_ifaceppp->data()->autoDNS())
command += " usepeerdns";
// PAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
command += " -chap user ";
command = command + _ifaceppp->data()->storedUsername();
}
// CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
command += " -pap user ";
command = command + _ifaceppp->data()->storedUsername();
}
// PAP/CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
QString tmpName = _ifaceppp->data()->storedUsername();
if ( !tmpName.isEmpty() ) {
command += " user ";
command = command + tmpName;
}
}
// check for debug
if(_ifaceppp->data()->getPPPDebug())
command += " debug";
QStringList &arglist = _ifaceppp->data()->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
++it )
{
command += " " + *it;
}
command += " call opie-kppp logfd 11";
if (command.length() > MAX_CMDLEN) {
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 5e2a04f..9457173 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -147,273 +147,259 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
tl->addWidget(baud_label, 4, 0);
baud_c = new QComboBox(this);
baud_label->setBuddy(baud_c);
static const char *baudrates[] =
{
#ifdef B460800
"460800",
#endif
#ifdef B230400
"230400",
#endif
#ifdef B115200
"115200",
#endif
#ifdef B57600
"57600",
#endif
"38400",
"19200",
"9600",
"2400",
0
};
for(k = 0; baudrates[k]; k++)
baud_c->insertItem(baudrates[k]);
baud_c->setCurrentItem(3);
// connect(baud_c, SIGNAL(activated(int)),
// this, SLOT(speed_selection(int)));
tl->addWidget(baud_c, 4, 1);
tmp = tr("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->enter() == enter->text(i))
- enter->setCurrentItem(i);
- }
-
tl->addRowSpacing(5, 10);
//Modem Lock File
modemlockfile = new QCheckBox(tr("&Use lock file"), this);
-
modemlockfile->setChecked(_pppdata->modemLockFile());
// connect(modemlockfile, SIGNAL(toggled(bool)),
// SLOT(modemlockfilechanged(bool)));
tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1);
// l12->addStretch(1);
QWhatsThis::add(modemlockfile,
tr("<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->modemTimeout(), this);
// modemtimeout->setLabel(tr("Modem &timeout:"));
// modemtimeout->setRange(1, 120, 1);
modemtimeout->setSuffix(tr(" sec"));
modemtimeout->setValue( _pppdata->modemTimeout() );
// connect(modemtimeout, SIGNAL(valueChanged(int)),
// SLOT(modemtimeoutchanged(int)));
timeoutLayout->addWidget(timeoutlabel);
timeoutLayout->addWidget(modemtimeout);
tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
QWhatsThis::add(modemtimeout,
tr("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->enter() == enter->text(i))
- enter->setCurrentItem(i);
- }
+ enter->setCurrentItem( static_cast<int>(_pppdata->enter()) );
+ flowcontrol->setCurrentItem( static_cast<int>( _pppdata->flowcontrol() ) );
for(int i=0; i <= modemdevice->count()-1; i++)
{
if(_pppdata->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
- for(int i=0; i <= flowcontrol->count()-1; i++)
- {
- if(_pppdata->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->speed())
baud_c->setCurrentItem(i);
tl->setRowStretch(1, 1);
}
ModemWidget::~ModemWidget()
{
QStringList devs;
for (int i=0;i<modemdevice->count();i++)
{
QString s = modemdevice->text(i);
s.simplifyWhiteSpace();
if (! s.isEmpty() ) devs << s;
}
QString edited = modemdevice->currentText();
if ( !( edited ).isEmpty() )
{
edited.simplifyWhiteSpace();
if ( devs.contains( edited ) == 0 )
{
devs << edited;
}
}
Config cfg("NetworkSetupPPP");
cfg.setGroup("Devices_General");
cfg.writeEntry("devices",devs,',');
}
// void ModemWidget::speed_selection(int) {
// _pppdata->setSpeed(baud_c->text(baud_c->currentItem()));
// }
// void ModemWidget::setenter(int ) {
// _pppdata->setEnter(enter->text(enter->currentItem()));
// }
// void ModemWidget::setmodemdc(int i) {
// _pppdata->setModemDevice(modemdevice->text(i));
// }
// void ModemWidget::setmodemdc( const QString &string ) {
// _pppdata->setModemDevice( string );
// }
// void ModemWidget::setflowcontrol(int i) {
// _pppdata->setFlowcontrol(flowcontrol->text(i));
// }
// void ModemWidget::modemlockfilechanged(bool set) {
// _pppdata->setModemLockFile(set);
// }
// void ModemWidget::modemtimeoutchanged(int n) {
// _pppdata->setModemTimeout(n);
// }
bool ModemWidget::save()
{
//first check to make sure that the device name is unique!
if(modemname->text().isEmpty() ||
!_pppdata->isUniqueDevname(modemname->text()))
return false;
_pppdata->setDevname( modemname->text() );
_pppdata->setModemDevice( modemdevice->currentText() );
- _pppdata->setFlowcontrol(flowcontrol->currentText());
- _pppdata->setFlowcontrol(flowcontrol->currentText());
+ _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
+ _pppdata->setEnter( static_cast<PPPData::LineTermination>(enter->currentItem()));
_pppdata->setSpeed(baud_c->currentText());
_pppdata->setModemLockFile( modemlockfile->isChecked());
_pppdata->setModemTimeout( modemtimeout->value() );
return true;
}
void ModemWidget::slotBeforeModemQuery()
{
m_oldModemDev = _pppdata->modemDevice();
- m_oldFlowControl = _pppdata->flowcontrol();
+ m_oldFlowControl = static_cast<int>( _pppdata->flowcontrol() );
m_oldSpeed = _pppdata->speed();
m_oldModemLock = _pppdata->modemLockFile();
m_oldModemTimeout = _pppdata->modemTimeout();
+ m_oldLineEnd = static_cast<int>( _pppdata->enter() );
_pppdata->setModemDevice( modemdevice->currentText() );
- _pppdata->setFlowcontrol(flowcontrol->currentText());
- _pppdata->setFlowcontrol(flowcontrol->currentText());
+ _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
+ _pppdata->setEnter(static_cast<PPPData::LineTermination>(enter->currentItem()));
_pppdata->setSpeed(baud_c->currentText());
_pppdata->setModemLockFile( modemlockfile->isChecked());
_pppdata->setModemTimeout( modemtimeout->value() );
}
void ModemWidget::slotAfterModemQuery()
{
_pppdata->setModemDevice( m_oldModemDev );
- _pppdata->setFlowcontrol( m_oldFlowControl );
+ _pppdata->setFlowcontrol( static_cast<PPPData::FlowControl>(m_oldFlowControl) );
+ _pppdata->setEnter( static_cast<PPPData::LineTermination>(m_oldLineEnd) );
_pppdata->setSpeed( m_oldSpeed );
_pppdata->setModemLockFile( m_oldModemLock );
_pppdata->setModemTimeout( m_oldModemTimeout );
}
ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent,
const char *name)
: QWidget(parent, name), _pppdata(pd), _ifaceppp(ip)
{
QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this);
waitfordt->setChecked(_pppdata->waitForDialTone());
// connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
l1->addWidget(waitfordt);
QWhatsThis::add(waitfordt,
tr("<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->busyWait(), this);
// busywait->setLabel(tr("B&usy wait:"));
// busywait->setRange(0, 300, 5, true);
busywait->setSuffix(tr(" sec"));
// connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
waitLayout->addWidget(waitLabel);
waitLayout->addWidget(busywait);
l1->addLayout( waitLayout );
QWhatsThis::add(busywait,
tr("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);
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
index a4dece4..0bb3136 100644
--- a/noncore/settings/networksettings/ppp/general.h
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -36,90 +36,90 @@ class QCheckBox;
class QComboBox;
class PPPData;
class InterfacePPP;
class QLineEdit;
class ModemWidget : public QWidget {
Q_OBJECT
public:
ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 );
~ModemWidget();
bool save();
private slots:
/*
* temporarily commit configuration so queryModem
* will use 'current' settings
*/
void slotBeforeModemQuery();
void slotAfterModemQuery();
/* private slots: */
/* void setmodemdc(int); */
/* void setmodemdc(const QString &); */
/* 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; */
QLineEdit *modemname;
QComboBox *modemdevice;
QComboBox *flowcontrol;
QComboBox *baud_c;
QLabel *baud_label;
QSpinBox *modemtimeout;
QCheckBox *modemlockfile;
PPPData *_pppdata;
private:
- QString m_oldModemDev, m_oldFlowControl, m_oldSpeed;
+ QString m_oldModemDev, m_oldSpeed;
bool m_oldModemLock;
- int m_oldModemTimeout;
+ int m_oldModemTimeout, m_oldFlowControl, m_oldLineEnd;
};
class ModemWidget2 : public QWidget {
Q_OBJECT
public:
ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 );
bool save();
signals:
void sig_beforeQueryModem();
void sig_afterQueryModem();
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;
PPPData *_pppdata;
InterfacePPP *_ifaceppp;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index 79f015b..7b2e2a3 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -180,98 +180,98 @@ bool Modem::opentty() {
if(_pppdata->UseCDLine()) {
if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
errmsg = QObject::tr("Unable to detect state of CD line.");
::close(modemfd);
modemfd = -1;
return false;
}
if ((flags&TIOCM_CD) == 0) {
errmsg = QObject::tr("The modem is not ready.");
::close(modemfd);
modemfd = -1;
return false;
}
}
#endif
tcdrain (modemfd);
tcflush (modemfd, TCIOFLUSH);
if(tcgetattr(modemfd, &tty) < 0){
// this helps in some cases
tcsendbreak(modemfd, 0);
sleep(1);
if(tcgetattr(modemfd, &tty) < 0){
errmsg = QObject::tr("The modem is busy.");
::close(modemfd);
modemfd = -1;
return false;
}
}
memset(&initial_tty,'\0',sizeof(initial_tty));
initial_tty = tty;
tty.c_cc[VMIN] = 0; // nonblocking
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->flowcontrol() != "None") {
- if(_pppdata->flowcontrol() == "CRTSCTS") {
+ if(_pppdata->flowcontrol() != PPPData::FlowNone) {
+ if(_pppdata->flowcontrol() == PPPData::FlowHardware) {
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);
}
cfsetospeed(&tty, modemspeed());
cfsetispeed(&tty, modemspeed());
tcdrain(modemfd);
if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
errmsg = QObject::tr("The modem is busy.");
::close(modemfd);
modemfd=-1;
return false;
}
errmsg = QObject::tr("Modem Ready.");
return true;
}
bool Modem::closetty() {
if(modemfd >=0 ) {
stop();
/* discard data not read or transmitted */
tcflush(modemfd, TCIOFLUSH);
if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n");
::close(modemfd);
modemfd = -1;
return false;
}
::close(modemfd);
modemfd = -1;
}
return true;
}
@@ -310,105 +310,109 @@ void Modem::startNotifier() {
if(sn == 0) {
sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
odebug << "QSocketNotifier started!" << oendl;
} else {
odebug << "QSocketNotifier re-enabled!" << oendl;
sn->setEnabled(true);
}
}
}
void Modem::stopNotifier() {
if(sn != 0) {
sn->setEnabled(false);
disconnect(sn);
delete sn;
sn = 0;
odebug << "QSocketNotifier stopped!" << oendl;
}
}
void Modem::flush() {
char c;
while(read(modemfd, &c, 1) == 1);
}
bool Modem::writeChar(unsigned char c) {
int s;
do {
s = write(modemfd, &c, 1);
if (s < 0) {
oerr << "write() in Modem::writeChar failed" << oendl;
return false;
}
} 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->enter();
- if(term == "LF")
+ switch( _pppdata->enter() ) {
+ case PPPData::EndLF:
b[len++]='\n';
- else if(term == "CR")
+ break;
+ case PPPData::EndCR:
b[len++]='\r';
- else if(term == "CR/LF") {
+ break;
+ case PPPData::EndCRLF:
b[len++]='\r';
b[len++]='\n';
+ break;
}
+
int l = len;
while(l) {
int wr = write(modemfd, &b[len-l], l);
if(wr < 0) {
// TODO do something meaningful with the error code (or ignore it
oerr << "write() in Modem::writeLine failed" << oendl;
delete[] b;
return false;
}
l -= wr;
}
delete[] b;
return true;
}
bool Modem::hangup() {
// this should really get the modem to hang up and go into command mode
// If anyone sees a fault in the following please let me know, since
// 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->modemHangupStr().local8Bit());
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 {
// we reach this point if the alarm handler got called
closetty();
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index eb03ef4..1491ea2 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -342,102 +342,102 @@ QString PPPData::pppdVersion() {
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));
}
int PPPData::pppdTimeout() {
return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
}
void PPPData::setpppdTimeout(int n) {
writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
}
const QString PPPData::modemDevice() {
return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" );
}
// const QString PPPData::modemName()
// {
// return readConfig(modemGroup(), MODEMNAME_KEY);
// }
// bool PPPData::setModemName(const QString &n) {
// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
// _modemName = n;
// writeConfig(cgroup, MODEMNAME_KEY, n);
// return true; //FIXME
// }
// bool PPPData::changeModemName(const QString &n) {
// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
// _modemName = n;
// writeConfig(modemGroup(), MODEMNAME_KEY, n);
// return true; //FIXME
// }
bool PPPData::setModemDevice(const QString &n) {
odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl;
writeConfig(modemGroup(), MODEMDEV_KEY, n);
return true; //FIXME
}
-const QString PPPData::flowcontrol() {
- return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
+enum PPPData::FlowControl PPPData::flowcontrol() {
+ return static_cast<FlowControl>(readNumConfig(modemGroup(), FLOWCONTROL_KEY, FlowHardware));
}
-void PPPData::setFlowcontrol(const QString &n) {
+void PPPData::setFlowcontrol(enum FlowControl n) {
writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
}
const QString PPPData::speed() {
QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
// undo the damage of a bug in former versions. It left an empty Speed=
// entry in kppprc. kppp did set the serial port to 57600 as default but
// pppd wouldn't receive the speed via the command line.
if(s.toUInt() == 0)
s = "57600";
return s;
}
void PPPData::setSpeed(const QString &n) {
writeConfig(modemGroup(), SPEED_KEY, n);
}
#if 0
void PPPData::setUseCDLine(const int n) {
writeConfig(modemGroup(),USECDLINE_KEY,n);
}
int PPPData::UseCDLine() {
return readNumConfig(modemGroup(),USECDLINE_KEY,0);
}
#endif
const QString PPPData::modemEscapeStr() {
return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
}
void PPPData::setModemEscapeStr(const QString &n) {
writeConfig(modemGroup(),ESCAPESTR_KEY,n);
}
const QString PPPData::modemEscapeResp() {
return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
}
void PPPData::setModemEscapeResp(const QString &n) {
writeConfig(modemGroup(),ESCAPERESP_KEY,n);
@@ -675,102 +675,102 @@ QString PPPData::volumeInitString() {
}
return s;
}
int PPPData::volume() {
return readNumConfig(modemGroup(), VOLUME_KEY, 1);
}
void PPPData::setVolume(int i) {
writeConfig(modemGroup(), VOLUME_KEY, i);
}
int PPPData::waitForDialTone() {
return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
}
void PPPData::setWaitForDialTone(int i) {
writeConfig(modemGroup(), DIALTONEWAIT_KEY, i);
}
void PPPData::setModemAnswerStr(const QString &n) {
writeConfig(modemGroup(), ANSWERSTR_KEY, n);
}
const QString PPPData::modemRingResp() {
return readConfig(modemGroup(), RINGRESP_KEY, "RING");
}
void PPPData::setModemRingResp(const QString &n) {
writeConfig(modemGroup(), RINGRESP_KEY, n);
}
const QString PPPData::modemAnswerResp() {
return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
}
void PPPData::setModemAnswerResp(const QString &n) {
writeConfig(modemGroup(), ANSWERRESP_KEY, n);
}
-const QString PPPData::enter() {
- return readConfig(modemGroup(), ENTER_KEY, "CR");
+enum PPPData::LineTermination PPPData::enter(){
+ return static_cast<PPPData::LineTermination>(readNumConfig(modemGroup(), ENTER_KEY, EndCR));
}
-void PPPData::setEnter(const QString &n) {
+void PPPData::setEnter(enum PPPData::LineTermination n) {
writeConfig(modemGroup(), ENTER_KEY, n);
}
//
// functions to set/return account information
//
//returns number of accounts
int PPPData::count() const {
return highcount + 1;
}
bool PPPData::setAccount(const QString &aname) {
odebug << "setting account to >" << aname.latin1() << "<" << oendl;
for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
cgroup = *it;
odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
odebug << "iterator " << (*it).latin1() << "" << oendl;
if(accname() == aname) {
odebug << "SUCCESS" << oendl;
return true;
}
}
odebug << "FAILURE" << oendl;
return false;
}
/*
bool PPPData::setAccountbyIndex(int i) {
if(i >= 0 && i <= highcount) {
QString tmp;
tmp.sprintf("%s%i", ACCOUNT_GRP, i);
if (_deleted.find(tmp)!=_deleted.end()) return false;
caccount = i;
cgroup = tmp;
return true;
}
return false;
}
*/
bool PPPData::isUniqueAccname(const QString &n) {
QString save_cgroup = cgroup;
for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
cgroup = *it;
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index d1cbeb5..d731b62 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -120,186 +120,197 @@ class Config;
#define AUTH_KEY "Authentication"
#define STORED_PASSWORD_KEY "Password"
#define STORED_USERNAME_KEY "Username"
#define STORE_PASSWORD_KEY "StorePassword"
#define BEFORE_CONNECT_KEY "BeforeConnect"
#define COMMAND_KEY "Command"
#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
#define IPADDR_KEY "IPAddr"
#define SUBNETMASK_KEY "SubnetMask"
#define ACCTENABLED_KEY "AccountingEnabled"
#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
#define ACCTFILE_KEY "AccountingFile"
#define AUTONAME_KEY "AutoName"
#define GATEWAY_KEY "Gateway"
#define DEFAULTROUTE_KEY "DefaultRoute"
#define DOMAIN_KEY "Domain"
#define DNS_KEY "DNS"
#define AUTODNS_KEY "AutoDNS"
#define EXDNSDISABLED_KEY "ExDNSDisabled"
#define SCRIPTCOM_KEY "ScriptCommands"
#define SCRIPTARG_KEY "ScriptArguments"
#define PPPDARG_KEY "pppdArguments"
#define PPP_DEBUG_OPTION "PPPDebug"
#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
#define DOCKING_KEY "DockIntoPanel"
#define TOTALCOSTS_KEY "TotalCosts"
#define TOTALBYTES_KEY "TotalBytes"
// pppd errors
#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"
#define DEVICESNAMES_LIST "DevicesNames_List"
#define DEVICES_LIST "Devices_List"
#define DEVICES_LIST_SEP ','
class PPPData {
public:
PPPData();
~PPPData() {};
enum { NumInitStrings = 2 };
+ enum LineTermination {
+ EndCR,
+ EndLF,
+ EndCRLF
+ };
+
+ enum FlowControl {
+ FlowHardware,
+ FlowSoftware,
+ FlowNone
+ };
// general functions
void save();
void cancel();
QStringList getAccountList();
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();
// functions to set/get general kppp info
QString password();
void setPassword(const QString &);
// int currentAccountID() { return caccount; };
const QString defaultAccount();
void setDefaultAccount(const QString &);
void set_xserver_exit_disconnect(bool set);
bool get_xserver_exit_disconnect();
void setPPPDebug(bool set);
bool getPPPDebug();
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_dock_into_panel(bool set);
// bool get_dock_into_panel();
- const QString enter();
- void setEnter(const QString &);
+ enum LineTermination enter();
+ void setEnter(enum LineTermination);
QString pppdVersion();
bool pppdVersionMin(int ver, int mod, int patch);
int pppdTimeout();
void setpppdTimeout(int);
int busyWait();
void setbusyWait(int);
bool modemLockFile();
void setModemLockFile(bool set);
int modemEscapeGuardTime();
void setModemEscapeGuardTime(int i);
void setModemEscapeStr(const QString &);
const QString modemEscapeStr();
void setModemEscapeResp(const QString &);
const QString modemEscapeResp();
// const QString modemName();
// bool setModemName(const QString &);
// bool changeModemName(const QString &);
const QString modemDevice();
bool setModemDevice(const QString &);
- const QString flowcontrol();
- void setFlowcontrol(const QString &);
+ enum FlowControl flowcontrol();
+ void setFlowcontrol(enum FlowControl);
int modemTimeout();
void setModemTimeout(int);
int modemToneDuration();
void setModemToneDuration(int);
QString volumeInitString();
int volume();
void setVolume(int);
int waitForDialTone();
void setWaitForDialTone(int i);
// modem command strings/responses
const QString modemInitStr(int i);
void setModemInitStr(int i, const QString &);
const QString modemInitResp();
void setModemInitResp(const QString &);
int modemPreInitDelay();
void setModemPreInitDelay(int);
int modemInitDelay();
void setModemInitDelay(int);
QString modemNoDialToneDetectionStr();
void setModemNoDialToneDetectionStr(const QString &);
const QString modemDialStr();
void setModemDialStr(const QString &);
const QString modemConnectResp();
void setModemConnectResp(const QString &);
const QString modemBusyResp();
void setModemBusyResp(const QString &);
const QString modemNoCarrierResp();
void setModemNoCarrierResp(const QString &);
const QString modemNoDialtoneResp();
void setModemNoDialtoneResp(const QString &);
const QString modemHangupStr();
void setModemHangupStr(const QString &);