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
@@ -1206,26 +1206,26 @@ bool ConnectWidget::execppp() {
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";
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
@@ -183,35 +183,28 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
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"
@@ -231,42 +224,33 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
// 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;
@@ -329,55 +313,57 @@ ModemWidget::~ModemWidget()
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());
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
@@ -72,27 +72,27 @@ private:
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();
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
@@ -216,26 +216,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->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);
}
@@ -346,33 +346,37 @@ 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->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;
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
@@ -378,30 +378,30 @@ const QString PPPData::modemDevice() {
// _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;
@@ -711,30 +711,30 @@ void PPPData::setModemRingResp(const QString &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;
}
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
@@ -156,24 +156,35 @@ class Config;
#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();
@@ -213,26 +224,26 @@ public:
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);
@@ -244,26 +255,26 @@ public:
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();