summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/pppdata.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp92
1 files changed, 46 insertions, 46 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index f4727c1..567ccf8 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -35,135 +35,135 @@
// #include <kconfig.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
#define SEPARATOR -sseepp-
#define SEP QString("%1SEPARATOR%1")
PPPData::PPPData()
: passwd(""),
_modemName(""),
highcount(-1), // start out with no entries
highcountdev(-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)
{
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1;
Config cfg = config();
cfg.setGroup(GENERAL_GRP);
accountList = cfg.readListEntry(ACCOUNT_LIST, ',' );
deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' );
- qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1());
- qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1());
+ odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl;
+ odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl;
// 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);
}
Config PPPData::config()
{
return Config("NetworkSetupPPP");
}
//
// save configuration
//
void PPPData::save()
{
- qDebug("PPPData saving data");
+ odebug << "PPPData saving data" << oendl;
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1);
QString key;
QStringList keys;
Config cfg = config();
cfg.setGroup(GENERAL_GRP);
cfg.writeEntry(ACCOUNT_LIST, accountList, ',' );
cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' );
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() );
+// odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl;
keys = QStringList::split( "SEPARATOR", key );
- //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
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 );
+// odebug << "saving " << key.latin1() << " -> " << val << "" << oendl;
keys = QStringList::split( "SEPARATOR", key );
- //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
+ //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl;
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() );
+// odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl;
keys = QStringList::split( "SEPARATOR", key );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val, sep);
}
}
//
// cancel changes
//
void PPPData::cancel() {
stringEntries.clear();
intEntries.clear();
listEntries.clear();
}
// 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());
+// odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl;
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)
{
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;
@@ -344,63 +344,63 @@ bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
|| (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) {
-// qDebug("Setting modem name to >%s<", n.latin1());
+// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
// _modemName = n;
// writeConfig(cgroup, MODEMNAME_KEY, n);
// return true; //FIXME
// }
// bool PPPData::changeModemName(const QString &n) {
-// qDebug("Setting modem name to >%s<", n.latin1());
+// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
// _modemName = n;
// writeConfig(modemGroup(), MODEMNAME_KEY, n);
// return true; //FIXME
// }
bool PPPData::setModemDevice(const QString &n) {
- qDebug("Setting modem dev to >%s<", n.latin1());
+ 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");
}
void PPPData::setFlowcontrol(const QString &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;
}
@@ -718,179 +718,179 @@ void PPPData::setModemAnswerResp(const QString &n) {
}
const QString PPPData::enter() {
return readConfig(modemGroup(), ENTER_KEY, "CR");
}
void PPPData::setEnter(const QString &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) {
- qDebug("setting account to >%s<", aname.latin1());
+ odebug << "setting account to >" << aname.latin1() << "<" << oendl;
for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
cgroup = *it;
- qDebug("PPPData::setAccount %s", cgroup.latin1());
- qDebug( "iterator %s", (*it).latin1() );
+ odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
+ odebug << "iterator " << (*it).latin1() << "" << oendl;
if(accname() == aname) {
- qDebug("SUCCESS");
+ odebug << "SUCCESS" << oendl;
return true;
}
}
- qDebug("FAILURE");
+ 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;
- qDebug("PPPData::setAccount %s", cgroup.latin1());
- qDebug( "%s \n", (*it).latin1() );
+ odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
+ odebug << "" << (*it).latin1() << " \n" << oendl;
if(accname() == n && cgroup != save_cgroup) {
cgroup = save_cgroup;
- qDebug("SUCCESS");
+ odebug << "SUCCESS" << oendl;
return false;
}
}
cgroup = save_cgroup;
return true;
}
bool PPPData::isUniqueDevname(const QString &n) {
QString save_mName = _modemName;
- qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1());
+ odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl;
for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
_modemName = *it;
- qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1());
+ odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl;
if(devname() == n && _modemName != save_mName) {
_modemName = save_mName;
- qDebug("NOT UNIQUE");
+ odebug << "NOT UNIQUE" << oendl;
return false;
}
}
_modemName = save_mName;
return true;
}
bool PPPData::deleteAccount() {
// FIXME: check if this account exists in a config...
Config cfg = PPPData::config();
cfg.setGroup(cgroup);
cfg.clearGroup();
accountList.remove(cgroup);
QString key;
QStringList keys;
for( QMap<QString,QString>::Iterator it = stringEntries.begin();
it != stringEntries.end(); ++it ){
QString val = it.data();
key = it.key();
keys = QStringList::split( "SEPARATOR", key );
if(keys[0]==cgroup){
stringEntries.remove( it );
- qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
}
}
for( QMap<QString,int>::Iterator it = intEntries.begin();
it != intEntries.end(); ++it ){
int val = it.data();
key = it.key();
keys = QStringList::split( "SEPARATOR", key );
if(keys[0]==cgroup){
intEntries.remove( it );
- qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
}
}
for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
it != listEntries.end(); ++it ){
QStringList val = it.data();
key = it.key();
if(keys[0]==cgroup){
listEntries.remove( it );
sepEntries.remove( key );
- qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
}
}
return true;
}
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);
+ odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl;
// if(!config) open();
// if (highcount >= MAX_ACCOUNTS) return -1;
QString tmp;
tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount);
cgroup = QString(tmp);
accountList << tmp;
- qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1());
+ odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl;
setpppdArgumentDefaults();
return highcount;
}
int PPPData::copyaccount(const QString&) {
// FIXME: PPPData::copyaccount
// if(highcount >= MAX_ACCOUNTS)
return -1;
// setAccountbyIndex(i);
// QMap <QString, QString> map = config->entryMap(cgroup);
// QMap <QString, QString>::ConstIterator it = map.begin();
// QString newname = QObject::tr("%1_copy").arg(accname());
// newaccount();
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
// }
// setAccname(newname);
@@ -944,51 +944,51 @@ void PPPData::setDialPrefix(const QString &s) {
}
int PPPData::authMethod() {
return readNumConfig(cgroup, AUTH_KEY, 0);
}
void PPPData::setAuthMethod(int value) {
writeConfig(cgroup, AUTH_KEY, value);
}
const QString PPPData::storedUsername() {
return readConfig(cgroup, STORED_USERNAME_KEY, "");
}
void PPPData::setStoredUsername(const QString &b) {
writeConfig(cgroup, STORED_USERNAME_KEY, b);
}
const QString PPPData::storedPassword() {
- qDebug("getting stored pw");
- qDebug("g %s", cgroup.latin1() );
- qDebug("k %s", STORED_PASSWORD_KEY);
+ odebug << "getting stored pw" << oendl;
+ odebug << "g " << cgroup.latin1() << "" << oendl;
+ odebug << "k " << STORED_PASSWORD_KEY << "" << oendl;
return readConfig(cgroup, STORED_PASSWORD_KEY, "");
}
void PPPData::setStoredPassword(const QString &b) {
writeConfig(cgroup, STORED_PASSWORD_KEY, b);
}
bool PPPData::storePassword() {
return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1);
}
const QString PPPData::command_before_connect() {
return readConfig(cgroup, BEFORE_CONNECT_KEY);
}
void PPPData::setCommand_before_connect(const QString &n) {
writeConfig(cgroup, BEFORE_CONNECT_KEY, n);
}
@@ -1308,188 +1308,188 @@ QMap<QString,QString> PPPData::getConfiguredInterfaces()
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);
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;
int i = 0;
Config cfg = config();
for( it = ifaces.begin(); it != ifaces.end(); ++it ){
cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
cfg.writeEntry( ACOUNTS_DEV, it.key() );
cfg.writeEntry( ACOUNTS_ACC, it.data() );
- qDebug("I %i",i);
+ odebug << "I " << i << "" << oendl;
}
cfg.setGroup( ACCLIST_GRP );
- qDebug("saved %i account settings", i);
+ odebug << "saved " << i << " account settings" << oendl;
cfg.writeEntry( ACCOUNTS_COUNT, i );
}
/**
* pppd's getword() function knows about escape characters.
* If we write the username and password to the secrets file
* we'll therefore have to escape back slashes.
*/
QString PPPData::encodeWord(const QString &s) {
QString r = s;
r.replace(QRegExp("\\"), "\\\\");
return r;
}
QStringList PPPData::getDevicesList()
{
Config cfg("NetworkSetupPPP");
cfg.setGroup("Devices_General");
return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP);
}
QStringList PPPData::getAccountList()
{
QStringList list;
QString save_cgroup;
save_cgroup = cgroup;
for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
cgroup = *it;
list << accname();
}
cgroup = save_cgroup;
return list;
};
const QString PPPData::devname()
{
QString tmp = readConfig(modemGroup(), MODEMNAME_KEY );
- qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1());
+ odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl;
return tmp;
}
void PPPData::setDevname(const QString &n) {
// if(!cgroup.isNull()) {
// // are we manipulating the default account's name ? then change it, too.
// bool def = accname() == defaultAccount();
// writeConfig(cgroup, NAME_KEY, n);
// if (def)
// setDefaultAccount(n);
// }
writeConfig(modemGroup(), MODEMNAME_KEY, n );
}
bool PPPData::setDevice(const QString &dev )
{
- qDebug("setting device to >%s<", dev.latin1());
+ odebug << "setting device to >" << dev.latin1() << "<" << oendl;
QString save_mName = _modemName;
for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
_modemName = *it;
- qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() );
- qDebug( "iterator %s", (*it).latin1() );
+ odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl;
+ odebug << "iterator " << (*it).latin1() << "" << oendl;
if(devname() == dev) {
- qDebug("SUCCESS");
+ odebug << "SUCCESS" << oendl;
return true;
}
}
_modemName = save_mName;
- qDebug("FAILURE");
+ odebug << "FAILURE" << oendl;
return false;
}
bool PPPData::deleteDevice()
{
// FIXME: check if this account exists in a config...
Config cfg = PPPData::config();
cfg.setGroup(modemGroup());
cfg.clearGroup();
deviceList.remove(modemGroup());
QString key;
QStringList keys;
for( QMap<QString,QString>::Iterator it = stringEntries.begin();
it != stringEntries.end(); ++it ){
QString val = it.data();
key = it.key();
keys = QStringList::split( "SEPARATOR", key );
if(keys[0]==modemGroup()){
stringEntries.remove( it );
- qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
}
}
for( QMap<QString,int>::Iterator it = intEntries.begin();
it != intEntries.end(); ++it ){
int val = it.data();
key = it.key();
keys = QStringList::split( "SEPARATOR", key );
if(keys[0]==modemGroup()){
intEntries.remove( it );
- qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
}
}
for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
it != listEntries.end(); ++it ){
QStringList val = it.data();
key = it.key();
if(keys[0]==modemGroup()){
listEntries.remove( it );
sepEntries.remove( key );
- qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() );
+ odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
}
}
return true;
}
bool PPPData::deleteDevice(const QString &dev)
{
if(!setDevice(dev))
return false;
return deleteDevice();
}
int PPPData::newdevice()
{
- qDebug("PPPData::newdevice highcount %i",highcountdev);
+ odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl;
QString tmp;
tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev);
_modemName = QString(tmp);
deviceList << tmp;
- qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1());
+ odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl;
return highcountdev;
}
int PPPData::copydevice(const QString&)
{
return false;
}
QStringList PPPData::getDevicesNamesList()
{
QStringList list;
QString save_mName = _modemName;
- qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1());
+ odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl;
for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
_modemName = *it;
- qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1());
+ odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl;
list << devname();
}
_modemName = save_mName;
return list;
};