author | tille <tille> | 2003-05-24 23:34:09 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-24 23:34:09 (UTC) |
commit | d1c32c127b4dabb716064a790da6be7c24975a92 (patch) (side-by-side diff) | |
tree | aa8a7865d4cccbc696c534d8de3ef3b139777c34 /noncore/settings | |
parent | 58947769d80d49faaccac1703da0e66c90158957 (diff) | |
download | opie-d1c32c127b4dabb716064a790da6be7c24975a92.zip opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.gz opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.bz2 |
pppd stuff
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 229 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.h | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 134 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 28 |
5 files changed, 330 insertions, 102 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index cd5d21c..5139482 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp @@ -28,2 +28,3 @@ #include <stdlib.h> +#include <unistd.h> #include <fcntl.h> @@ -35,3 +36,14 @@ #include <assert.h> +#include <string.h> +#ifdef HAVE_RESOLV_H +# include <arpa/nameser.h> +# include <resolv.h> +#endif + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +#define strlcpy strcpy #include "auth.h" @@ -85,2 +97,4 @@ Modem::Modem() modemfd = -1; + _pppdExitStatus = -1; + pppdPid = -1; sn = 0L; @@ -757,2 +771,18 @@ bool Modem::createAuthFile(Auth method, const char *username, const char *passwo +bool Modem::removeAuthFile(Auth method) { + const char *authfile, *oldName; + + if(!(authfile = authFile(method))) + return false; + if(!(oldName = authFile(method, Old))) + return false; + + if(access(oldName, F_OK) == 0) { + unlink(authfile); + return (rename(oldName, authfile) == 0); + } else + return false; +} + + bool Modem::setSecret(int method, const char* name, const char* password) @@ -780,14 +810,177 @@ bool Modem::setSecret(int method, const char* name, const char* password) -bool Modem::removeSecret(int) +bool Modem::removeSecret(int method) { - return true; + Auth auth; + + switch(method) { + case AUTH_PAP: + auth = Modem::PAP; + break; + case AUTH_CHAP: + auth = Modem::CHAP; + break; + default: + return false; + } + return removeAuthFile( auth ); } -void Modem::killPPPDaemon() +int checkForInterface() { +// I don't know if Linux needs more initialization to get the ioctl to +// work, pppd seems to hint it does. But BSD doesn't, and the following +// code should compile. +#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) + int s, ok; + struct ifreq ifr; + // extern char *no_ppp_msg; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + return 1; /* can't tell */ + + strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); + ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; + close(s); + + if (ok == -1) { +// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports +// KLDs, the old LKM interface couldn't handle loading devices +// dynamically, and thus can't load ppp support on the fly +#ifdef __FreeBSD__ + // If we failed to load ppp support and don't have it already. + if (kldload("if_ppp") == -1) { + return -1; + } + return 0; +#else + return -1; +#endif + } + return 0; +#else +// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp + struct stat buf; + + memset(&buf, 0, sizeof(buf)); + return stat("/dev/ppp", &buf); +#endif } -int Modem::pppdExitStatus() -{ - return -1; +bool Modem::execpppd(const char *arguments) { + char buf[MAX_CMDLEN]; + char *args[MaxArgs]; + pid_t pgrpid; + + if(modemfd<0) + return false; + + _pppdExitStatus = -1; + + switch(pppdPid = fork()) + { + case -1: + fprintf(stderr,"In parent: fork() failed\n"); + return false; + break; + + case 0: + // let's parse the arguments the user supplied into UNIX suitable form + // that is a list of pointers each pointing to exactly one word + strlcpy(buf, arguments); + parseargs(buf, args); + // become a session leader and let /dev/ttySx + // be the controlling terminal. + pgrpid = setsid(); +#ifdef TIOCSCTTY + if(ioctl(modemfd, TIOCSCTTY, 0)<0) + fprintf(stderr, "ioctl() failed.\n"); +#elif defined (TIOCSPGRP) + if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) + fprintf(stderr, "ioctl() failed.\n"); +#endif + if(tcsetpgrp(modemfd, pgrpid)<0) + fprintf(stderr, "tcsetpgrp() failed.\n"); + + dup2(modemfd, 0); + dup2(modemfd, 1); + + switch (checkForInterface()) { + case 1: + fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); + break; + case -1: + fprintf(stderr, "Kernel does not support ppp, oops.\n"); + break; + case 0: + fprintf(stderr, "Kernel supports ppp alright.\n"); + break; + } + + execve(pppdPath(), args, 0L); + _exit(0); + break; + + default: + qDebug("In parent: pppd pid %d\n",pppdPid); + close(modemfd); + modemfd = -1; + return true; + break; + } +} + + +bool Modem::killpppd() { + if(pppdPid > 0) { + qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); + if(kill(pppdPid, SIGTERM) < 0) { + qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); + if(kill(pppdPid, SIGKILL) < 0) { + qDebug("Error killing %d\n", pppdPid); + return false; + } + } + } + return true; +} + + +void Modem::parseargs(char* buf, char** args) { + int nargs = 0; + int quotes; + + while(nargs < MaxArgs-1 && *buf != '\0') { + + quotes = 0; + + // Strip whitespace. Use nulls, so that the previous argument is + // terminated automatically. + + while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) + *buf++ = '\0'; + + // detect begin of quoted argument + if (*buf == '"' || *buf == '\'') { + quotes = *buf; + *buf++ = '\0'; + } + + // save the argument + if(*buf != '\0') { + *args++ = buf; + nargs++; + } + + if (!quotes) + while ((*buf != '\0') && (*buf != '\n') && + (*buf != '\t') && (*buf != ' ')) + buf++; + else { + while ((*buf != '\0') && (*buf != quotes)) + buf++; + *buf++ = '\0'; + } + } + + *args = 0L; } @@ -796,3 +989,18 @@ bool Modem::execPPPDaemon(const QString & arguments) { + if(execpppd(arguments)==0) { + PPPData::data()->setpppdRunning(true); return true; + } else + return false; +} + +void Modem::killPPPDaemon() +{ + PPPData::data()->setpppdRunning(false); + killpppd(); +} + +int Modem::pppdExitStatus() +{ + return _pppdExitStatus; } @@ -801,3 +1009,8 @@ int Modem::openResolv(int flags) { - return -1; + int fd; + if ((fd = open(_PATH_RESCONF, flags)) == -1) { + qDebug("error opening resolv.conf!"); + fd = open(DEVNULL, O_RDONLY); + } + return fd; } @@ -806,3 +1019,3 @@ bool Modem::setHostname(const QString & name) { - return true; + return sethostname(name, name.length()) == 0; } diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h index 052be4a..b494977 100644 --- a/noncore/settings/networksettings/ppp/modem.h +++ b/noncore/settings/networksettings/ppp/modem.h @@ -95,2 +95,6 @@ private: bool createAuthFile(Auth method,const char *username,const char *password); + bool removeAuthFile(Auth method); + bool execpppd(const char *arguments); + bool killpppd(); + void parseargs(char* buf, char** args); void escape_to_command_mode(); @@ -102,2 +106,4 @@ private: int modemfd; + int pppdPid; + int _pppdExitStatus; QSocketNotifier *sn; diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 646facd..bb1c8ed 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp @@ -325,3 +325,3 @@ void PPPData::setpppdTimeout(int n) { const QString PPPData::modemDevice() { - return readConfig (MODEM_GRP, MODEMDEV_KEY, devices[DEV_DEFAULT]); + return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); } @@ -330,3 +330,3 @@ const QString PPPData::modemDevice() { void PPPData::setModemDevice(const QString &n) { - writeConfig(MODEM_GRP, MODEMDEV_KEY, n); + writeConfig(modemGroup(), MODEMDEV_KEY, n); } @@ -335,3 +335,3 @@ void PPPData::setModemDevice(const QString &n) { const QString PPPData::flowcontrol() { - return readConfig(MODEM_GRP, FLOWCONTROL_KEY, "CRTSCTS"); + return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); } @@ -340,3 +340,3 @@ const QString PPPData::flowcontrol() { void PPPData::setFlowcontrol(const QString &n) { - writeConfig(MODEM_GRP, FLOWCONTROL_KEY, n); + writeConfig(modemGroup(), FLOWCONTROL_KEY, n); } @@ -345,3 +345,3 @@ void PPPData::setFlowcontrol(const QString &n) { const QString PPPData::speed() { - QString s = readConfig(MODEM_GRP, SPEED_KEY, "57600"); + QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); // undo the damage of a bug in former versions. It left an empty Speed= @@ -356,3 +356,3 @@ const QString PPPData::speed() { void PPPData::setSpeed(const QString &n) { - writeConfig(MODEM_GRP, SPEED_KEY, n); + writeConfig(modemGroup(), SPEED_KEY, n); } @@ -362,3 +362,3 @@ void PPPData::setSpeed(const QString &n) { void PPPData::setUseCDLine(const int n) { - writeConfig(MODEM_GRP,USECDLINE_KEY,n); + writeConfig(modemGroup(),USECDLINE_KEY,n); } @@ -367,3 +367,3 @@ void PPPData::setUseCDLine(const int n) { int PPPData::UseCDLine() { - return readNumConfig(MODEM_GRP,USECDLINE_KEY,0); + return readNumConfig(modemGroup(),USECDLINE_KEY,0); } @@ -372,3 +372,3 @@ int PPPData::UseCDLine() { const QString PPPData::modemEscapeStr() { - return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++"); + return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); } @@ -377,3 +377,3 @@ const QString PPPData::modemEscapeStr() { void PPPData::setModemEscapeStr(const QString &n) { - writeConfig(MODEM_GRP,ESCAPESTR_KEY,n); + writeConfig(modemGroup(),ESCAPESTR_KEY,n); } @@ -382,3 +382,3 @@ void PPPData::setModemEscapeStr(const QString &n) { const QString PPPData::modemEscapeResp() { - return readConfig(MODEM_GRP,ESCAPERESP_KEY,"OK"); + return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); } @@ -387,3 +387,3 @@ const QString PPPData::modemEscapeResp() { void PPPData::setModemEscapeResp(const QString &n) { - writeConfig(MODEM_GRP,ESCAPERESP_KEY,n); + writeConfig(modemGroup(),ESCAPERESP_KEY,n); } @@ -392,3 +392,3 @@ void PPPData::setModemEscapeResp(const QString &n) { int PPPData::modemEscapeGuardTime() { - return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50); + return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); } @@ -397,3 +397,3 @@ int PPPData::modemEscapeGuardTime() { void PPPData::setModemEscapeGuardTime(int n) { - writeConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,n); + writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); } @@ -402,3 +402,3 @@ void PPPData::setModemEscapeGuardTime(int n) { bool PPPData::modemLockFile() { - return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1); + return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); } @@ -407,3 +407,3 @@ bool PPPData::modemLockFile() { void PPPData::setModemLockFile(bool set) { - writeConfig(MODEM_GRP, LOCKFILE_KEY, set); + writeConfig(modemGroup(), LOCKFILE_KEY, set); } @@ -412,3 +412,3 @@ void PPPData::setModemLockFile(bool set) { int PPPData::modemTimeout() { - return readNumConfig(MODEM_GRP, TIMEOUT_KEY, MODEM_TIMEOUT); + return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); } @@ -417,3 +417,3 @@ int PPPData::modemTimeout() { void PPPData::setModemTimeout(int n) { - writeConfig(MODEM_GRP, TIMEOUT_KEY, n); + writeConfig(modemGroup(), TIMEOUT_KEY, n); } @@ -422,3 +422,3 @@ void PPPData::setModemTimeout(int n) { int PPPData::modemToneDuration() { - return readNumConfig(MODEM_GRP, TONEDURATION_KEY,MODEM_TONEDURATION); + return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); } @@ -427,3 +427,3 @@ int PPPData::modemToneDuration() { void PPPData::setModemToneDuration(int n) { - writeConfig(MODEM_GRP, TONEDURATION_KEY, n); + writeConfig(modemGroup(), TONEDURATION_KEY, n); } @@ -432,3 +432,3 @@ void PPPData::setModemToneDuration(int n) { int PPPData::busyWait() { - return readNumConfig(MODEM_GRP, BUSYWAIT_KEY, BUSY_WAIT); + return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); } @@ -437,3 +437,3 @@ int PPPData::busyWait() { void PPPData::setbusyWait(int n) { - writeConfig(MODEM_GRP, BUSYWAIT_KEY, n); + writeConfig(modemGroup(), BUSYWAIT_KEY, n); } @@ -448,5 +448,5 @@ const QString PPPData::modemInitStr(int i) { if(i == 0) - return readConfig(MODEM_GRP, INITSTR_KEY, "ATZ"); + return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); else - return readConfig(MODEM_GRP, INITSTR_KEY + QString::number(i), ""); + return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); } @@ -457,3 +457,3 @@ void PPPData::setModemInitStr(int i, const QString &n) { QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); - writeConfig(MODEM_GRP, k, n); + writeConfig(modemGroup(), k, n); } @@ -462,3 +462,3 @@ void PPPData::setModemInitStr(int i, const QString &n) { const QString PPPData::modemInitResp() { - return readConfig(MODEM_GRP, INITRESP_KEY, "OK"); + return readConfig(modemGroup(), INITRESP_KEY, "OK"); } @@ -467,3 +467,3 @@ const QString PPPData::modemInitResp() { void PPPData::setModemInitResp(const QString &n) { - writeConfig(MODEM_GRP, INITRESP_KEY, n); + writeConfig(modemGroup(), INITRESP_KEY, n); } @@ -472,3 +472,3 @@ void PPPData::setModemInitResp(const QString &n) { int PPPData::modemPreInitDelay() { - return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50); + return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); } @@ -477,3 +477,3 @@ int PPPData::modemPreInitDelay() { void PPPData::setModemPreInitDelay(int n) { - writeConfig(MODEM_GRP, PREINITDELAY_KEY, n); + writeConfig(modemGroup(), PREINITDELAY_KEY, n); } @@ -482,3 +482,3 @@ void PPPData::setModemPreInitDelay(int n) { int PPPData::modemInitDelay() { - return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50); + return readNumConfig(modemGroup(), INITDELAY_KEY, 50); } @@ -487,3 +487,3 @@ int PPPData::modemInitDelay() { void PPPData::setModemInitDelay(int n) { - writeConfig(MODEM_GRP, INITDELAY_KEY, n); + writeConfig(modemGroup(), INITDELAY_KEY, n); } @@ -491,3 +491,3 @@ void PPPData::setModemInitDelay(int n) { QString PPPData::modemNoDialToneDetectionStr() { - return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3"); + return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); } @@ -495,3 +495,3 @@ QString PPPData::modemNoDialToneDetectionStr() { void PPPData::setModemNoDialToneDetectionStr(const QString &n) { - writeConfig(MODEM_GRP, NODTDETECT_KEY, n); + writeConfig(modemGroup(), NODTDETECT_KEY, n); } @@ -499,3 +499,3 @@ void PPPData::setModemNoDialToneDetectionStr(const QString &n) { const QString PPPData::modemDialStr() { - return readConfig(MODEM_GRP, DIALSTR_KEY, "ATDT"); + return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); } @@ -504,3 +504,3 @@ const QString PPPData::modemDialStr() { void PPPData::setModemDialStr(const QString &n) { - writeConfig(MODEM_GRP, DIALSTR_KEY, n); + writeConfig(modemGroup(), DIALSTR_KEY, n); } @@ -509,3 +509,3 @@ void PPPData::setModemDialStr(const QString &n) { const QString PPPData::modemConnectResp() { - return readConfig(MODEM_GRP, CONNECTRESP_KEY, "CONNECT"); + return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); } @@ -514,3 +514,3 @@ const QString PPPData::modemConnectResp() { void PPPData::setModemConnectResp(const QString &n) { - writeConfig(MODEM_GRP, CONNECTRESP_KEY, n); + writeConfig(modemGroup(), CONNECTRESP_KEY, n); } @@ -519,3 +519,3 @@ void PPPData::setModemConnectResp(const QString &n) { const QString PPPData::modemBusyResp() { - return readConfig(MODEM_GRP, BUSYRESP_KEY, "BUSY"); + return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); } @@ -524,3 +524,3 @@ const QString PPPData::modemBusyResp() { void PPPData::setModemBusyResp(const QString &n) { - writeConfig(MODEM_GRP, BUSYRESP_KEY, n); + writeConfig(modemGroup(), BUSYRESP_KEY, n); } @@ -529,3 +529,3 @@ void PPPData::setModemBusyResp(const QString &n) { const QString PPPData::modemNoCarrierResp() { - return readConfig(MODEM_GRP, NOCARRIERRESP_KEY, "NO CARRIER"); + return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); } @@ -534,3 +534,3 @@ const QString PPPData::modemNoCarrierResp() { void PPPData::setModemNoCarrierResp(const QString &n) { - writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n); + writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); } @@ -539,3 +539,3 @@ void PPPData::setModemNoCarrierResp(const QString &n) { const QString PPPData::modemNoDialtoneResp() { - return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE"); + return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); } @@ -544,3 +544,3 @@ const QString PPPData::modemNoDialtoneResp() { void PPPData::setModemNoDialtoneResp(const QString &n) { - writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n); + writeConfig(modemGroup(), NODIALTONERESP_KEY, n); } @@ -549,3 +549,3 @@ void PPPData::setModemNoDialtoneResp(const QString &n) { const QString PPPData::modemHangupStr() { - return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH"); + return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); } @@ -553,3 +553,3 @@ const QString PPPData::modemHangupStr() { void PPPData::setModemHangupStr(const QString &n) { - writeConfig(MODEM_GRP, HANGUPSTR_KEY, n); + writeConfig(modemGroup(), HANGUPSTR_KEY, n); } @@ -558,3 +558,3 @@ void PPPData::setModemHangupStr(const QString &n) { const QString PPPData::modemHangupResp() { - return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK"); + return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); } @@ -562,3 +562,3 @@ const QString PPPData::modemHangupResp() { void PPPData::setModemHangupResp(const QString &n) { - writeConfig(MODEM_GRP, HANGUPRESP_KEY, n); + writeConfig(modemGroup(), HANGUPRESP_KEY, n); } @@ -567,3 +567,3 @@ void PPPData::setModemHangupResp(const QString &n) { const QString PPPData::modemAnswerStr() { - return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA"); + return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); } @@ -572,3 +572,3 @@ const QString PPPData::modemAnswerStr() { QString PPPData::volumeOff() { - return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0"); + return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); } @@ -577,3 +577,3 @@ QString PPPData::volumeOff() { void PPPData::setVolumeOff(const QString &s) { - writeConfig(MODEM_GRP, VOLUME_OFF, s); + writeConfig(modemGroup(), VOLUME_OFF, s); } @@ -582,3 +582,3 @@ void PPPData::setVolumeOff(const QString &s) { QString PPPData::volumeMedium() { - return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1"); + return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); } @@ -587,3 +587,3 @@ QString PPPData::volumeMedium() { void PPPData::setVolumeMedium(const QString &s) { - writeConfig(MODEM_GRP, VOLUME_MEDIUM, s); + writeConfig(modemGroup(), VOLUME_MEDIUM, s); } @@ -592,3 +592,3 @@ void PPPData::setVolumeMedium(const QString &s) { QString PPPData::volumeHigh() { - QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3"); + QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); if(tmp == "M1L4") @@ -600,3 +600,3 @@ QString PPPData::volumeHigh() { void PPPData::setVolumeHigh(const QString &s) { - writeConfig(MODEM_GRP, VOLUME_HIGH, s); + writeConfig(modemGroup(), VOLUME_HIGH, s); } @@ -626,3 +626,3 @@ QString PPPData::volumeInitString() { int PPPData::volume() { - return readNumConfig(MODEM_GRP, VOLUME_KEY, 1); + return readNumConfig(modemGroup(), VOLUME_KEY, 1); } @@ -631,3 +631,3 @@ int PPPData::volume() { void PPPData::setVolume(int i) { - writeConfig(MODEM_GRP, VOLUME_KEY, i); + writeConfig(modemGroup(), VOLUME_KEY, i); } @@ -635,3 +635,3 @@ void PPPData::setVolume(int i) { int PPPData::waitForDialTone() { - return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); + return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); } @@ -639,3 +639,3 @@ int PPPData::waitForDialTone() { void PPPData::setWaitForDialTone(int i) { - writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i); + writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); } @@ -643,3 +643,3 @@ void PPPData::setWaitForDialTone(int i) { void PPPData::setModemAnswerStr(const QString &n) { - writeConfig(MODEM_GRP, ANSWERSTR_KEY, n); + writeConfig(modemGroup(), ANSWERSTR_KEY, n); } @@ -648,3 +648,3 @@ void PPPData::setModemAnswerStr(const QString &n) { const QString PPPData::modemRingResp() { - return readConfig(MODEM_GRP, RINGRESP_KEY, "RING"); + return readConfig(modemGroup(), RINGRESP_KEY, "RING"); } @@ -653,3 +653,3 @@ const QString PPPData::modemRingResp() { void PPPData::setModemRingResp(const QString &n) { - writeConfig(MODEM_GRP, RINGRESP_KEY, n); + writeConfig(modemGroup(), RINGRESP_KEY, n); } @@ -658,3 +658,3 @@ void PPPData::setModemRingResp(const QString &n) { const QString PPPData::modemAnswerResp() { - return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT"); + return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); } @@ -663,3 +663,3 @@ const QString PPPData::modemAnswerResp() { void PPPData::setModemAnswerResp(const QString &n) { - writeConfig(MODEM_GRP, ANSWERRESP_KEY, n); + writeConfig(modemGroup(), ANSWERRESP_KEY, n); } @@ -668,3 +668,3 @@ void PPPData::setModemAnswerResp(const QString &n) { const QString PPPData::enter() { - return readConfig(MODEM_GRP, ENTER_KEY, "CR"); + return readConfig(modemGroup(), ENTER_KEY, "CR"); } @@ -673,3 +673,3 @@ const QString PPPData::enter() { void PPPData::setEnter(const QString &n) { - writeConfig(MODEM_GRP, ENTER_KEY, n); + writeConfig(modemGroup(), ENTER_KEY, n); } @@ -1211,2 +1211,6 @@ void PPPData::setpppdError(int err) { +QString PPPData::modemGroup() +{ + return MODEM_GRP; +} diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index 57ce2fd..c4d7bc3 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h @@ -161,26 +161,27 @@ class PPPData { public: - PPPData(); - ~PPPData() {}; + PPPData(); + ~PPPData() {}; static PPPData* data(); - enum { NumInitStrings = 2 }; + enum { NumInitStrings = 2 }; - // general functions - bool open(); - void save(); - void cancel(); -// int access() const; // read/write access + // general functions + bool open(); + void save(); + void cancel(); - // function to read/write date to configuration file - QString readConfig(const QString &, const QString &, const QString &); - int readNumConfig(const QString &, const QString &, int); - bool readListConfig(const QString &, const QString &, + + // function to read/write date to configuration file + 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 &, + 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; } + // return the current account group + QString currentGroup() { return cgroup; } + QString modemGroup(); diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index da17e26..e13f8c8 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp @@ -10,3 +10,8 @@ */ -PPPModule::PPPModule() : Module() { +PPPModule::PPPModule() : Module() +{ + Interface *iface; + iface = new Interface( 0, "device" ); + iface->setHardwareName( "account" ); + list.append( iface ); } @@ -44,8 +49,3 @@ QString PPPModule::getPixmapName(Interface* ){ bool PPPModule::isOwner(Interface *i){ - if(!i->getInterfaceName().upper().contains("PPP")) - return false; - - i->setHardwareName("PPP"); - list.append(i); - return true; + return list.find( i ) != -1; } @@ -58,4 +58,4 @@ QWidget *PPPModule::configure(Interface *i){ qDebug("return ModemWidget"); - PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose ); -// pppconfig->setProfile(profile); + PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, + Qt::WDestructiveClose ); return pppconfig; @@ -99,4 +99,8 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){ qDebug("ACCEPTED"); - return new Interface( 0, newInterface ); PPPData::data()->save(); + Interface *iface; + iface = new Interface( 0, PPPData::data()->modemDevice() ); + iface->setHardwareName( PPPData::data()->accname() ); + list.append( iface ); + return iface; } @@ -116,4 +120,4 @@ void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) { - qDebug("here"); - newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device")); + newIfaces.insert(QObject::tr("PPP") , + QObject::tr("generic ppp device")); } |