summaryrefslogtreecommitdiff
authortille <tille>2003-05-24 23:34:09 (UTC)
committer tille <tille>2003-05-24 23:34:09 (UTC)
commitd1c32c127b4dabb716064a790da6be7c24975a92 (patch) (side-by-side diff)
treeaa8a7865d4cccbc696c534d8de3ef3b139777c34
parent58947769d80d49faaccac1703da0e66c90158957 (diff)
downloadopie-d1c32c127b4dabb716064a790da6be7c24975a92.zip
opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.gz
opie-d1c32c127b4dabb716064a790da6be7c24975a92.tar.bz2
pppd stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp229
-rw-r--r--noncore/settings/networksettings/ppp/modem.h6
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp134
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h35
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp28
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
@@ -26,6 +26,7 @@
#include <errno.h>
#include <stdlib.h>
+#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
@@ -33,7 +34,18 @@
#include <regex.h>
#include <qregexp.h>
#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"
#include "modem.h"
#include "pppdata.h"
@@ -83,6 +95,8 @@ Modem::Modem()
{
if (Modem::modem != 0) return; //CORRECT?
modemfd = -1;
+ _pppdExitStatus = -1;
+ pppdPid = -1;
sn = 0L;
data_mode = false;
modem_is_locked = false;
@@ -755,6 +769,22 @@ 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)
{
@@ -778,32 +808,215 @@ 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;
}
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;
}
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;
}
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
@@ -93,6 +93,10 @@ private:
const char* authFile(Auth method, int version = Original );
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();
int openLockfile(QString,int);
@@ -100,6 +104,8 @@ private:
QString device;
QString lockfile;
int modemfd;
+ int pppdPid;
+ int _pppdExitStatus;
QSocketNotifier *sn;
bool data_mode;
QString errmsg;
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
@@ -323,27 +323,27 @@ 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]);
}
void PPPData::setModemDevice(const QString &n) {
- writeConfig(MODEM_GRP, MODEMDEV_KEY, n);
+ writeConfig(modemGroup(), MODEMDEV_KEY, n);
}
const QString PPPData::flowcontrol() {
- return readConfig(MODEM_GRP, FLOWCONTROL_KEY, "CRTSCTS");
+ return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
}
void PPPData::setFlowcontrol(const QString &n) {
- writeConfig(MODEM_GRP, FLOWCONTROL_KEY, n);
+ writeConfig(modemGroup(), FLOWCONTROL_KEY, 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=
// entry in kppprc. kppp did set the serial port to 57600 as default but
// pppd wouldn't receive the speed via the command line.
@@ -354,88 +354,88 @@ const QString PPPData::speed() {
void PPPData::setSpeed(const QString &n) {
- writeConfig(MODEM_GRP, SPEED_KEY, n);
+ writeConfig(modemGroup(), SPEED_KEY, n);
}
#if 0
void PPPData::setUseCDLine(const int n) {
- writeConfig(MODEM_GRP,USECDLINE_KEY,n);
+ writeConfig(modemGroup(),USECDLINE_KEY,n);
}
int PPPData::UseCDLine() {
- return readNumConfig(MODEM_GRP,USECDLINE_KEY,0);
+ return readNumConfig(modemGroup(),USECDLINE_KEY,0);
}
#endif
const QString PPPData::modemEscapeStr() {
- return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++");
+ return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
}
void PPPData::setModemEscapeStr(const QString &n) {
- writeConfig(MODEM_GRP,ESCAPESTR_KEY,n);
+ writeConfig(modemGroup(),ESCAPESTR_KEY,n);
}
const QString PPPData::modemEscapeResp() {
- return readConfig(MODEM_GRP,ESCAPERESP_KEY,"OK");
+ return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
}
void PPPData::setModemEscapeResp(const QString &n) {
- writeConfig(MODEM_GRP,ESCAPERESP_KEY,n);
+ writeConfig(modemGroup(),ESCAPERESP_KEY,n);
}
int PPPData::modemEscapeGuardTime() {
- return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50);
+ return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
}
void PPPData::setModemEscapeGuardTime(int n) {
- writeConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,n);
+ writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n);
}
bool PPPData::modemLockFile() {
- return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1);
+ return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
}
void PPPData::setModemLockFile(bool set) {
- writeConfig(MODEM_GRP, LOCKFILE_KEY, set);
+ writeConfig(modemGroup(), LOCKFILE_KEY, set);
}
int PPPData::modemTimeout() {
- return readNumConfig(MODEM_GRP, TIMEOUT_KEY, MODEM_TIMEOUT);
+ return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT);
}
void PPPData::setModemTimeout(int n) {
- writeConfig(MODEM_GRP, TIMEOUT_KEY, n);
+ writeConfig(modemGroup(), TIMEOUT_KEY, n);
}
int PPPData::modemToneDuration() {
- return readNumConfig(MODEM_GRP, TONEDURATION_KEY,MODEM_TONEDURATION);
+ return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION);
}
void PPPData::setModemToneDuration(int n) {
- writeConfig(MODEM_GRP, TONEDURATION_KEY, n);
+ writeConfig(modemGroup(), TONEDURATION_KEY, n);
}
int PPPData::busyWait() {
- return readNumConfig(MODEM_GRP, BUSYWAIT_KEY, BUSY_WAIT);
+ return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT);
}
void PPPData::setbusyWait(int n) {
- writeConfig(MODEM_GRP, BUSYWAIT_KEY, n);
+ writeConfig(modemGroup(), BUSYWAIT_KEY, n);
}
@@ -446,151 +446,151 @@ void PPPData::setbusyWait(int n) {
const QString PPPData::modemInitStr(int i) {
assert(i >= 0 && i < NumInitStrings);
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), "");
}
void PPPData::setModemInitStr(int i, const QString &n) {
assert(i >= 0 && i < NumInitStrings);
QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : "");
- writeConfig(MODEM_GRP, k, n);
+ writeConfig(modemGroup(), k, n);
}
const QString PPPData::modemInitResp() {
- return readConfig(MODEM_GRP, INITRESP_KEY, "OK");
+ return readConfig(modemGroup(), INITRESP_KEY, "OK");
}
void PPPData::setModemInitResp(const QString &n) {
- writeConfig(MODEM_GRP, INITRESP_KEY, n);
+ writeConfig(modemGroup(), INITRESP_KEY, n);
}
int PPPData::modemPreInitDelay() {
- return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50);
+ return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50);
}
void PPPData::setModemPreInitDelay(int n) {
- writeConfig(MODEM_GRP, PREINITDELAY_KEY, n);
+ writeConfig(modemGroup(), PREINITDELAY_KEY, n);
}
int PPPData::modemInitDelay() {
- return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50);
+ return readNumConfig(modemGroup(), INITDELAY_KEY, 50);
}
void PPPData::setModemInitDelay(int n) {
- writeConfig(MODEM_GRP, INITDELAY_KEY, n);
+ writeConfig(modemGroup(), INITDELAY_KEY, n);
}
QString PPPData::modemNoDialToneDetectionStr() {
- return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3");
+ return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3");
}
void PPPData::setModemNoDialToneDetectionStr(const QString &n) {
- writeConfig(MODEM_GRP, NODTDETECT_KEY, n);
+ writeConfig(modemGroup(), NODTDETECT_KEY, n);
}
const QString PPPData::modemDialStr() {
- return readConfig(MODEM_GRP, DIALSTR_KEY, "ATDT");
+ return readConfig(modemGroup(), DIALSTR_KEY, "ATDT");
}
void PPPData::setModemDialStr(const QString &n) {
- writeConfig(MODEM_GRP, DIALSTR_KEY, n);
+ writeConfig(modemGroup(), DIALSTR_KEY, n);
}
const QString PPPData::modemConnectResp() {
- return readConfig(MODEM_GRP, CONNECTRESP_KEY, "CONNECT");
+ return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT");
}
void PPPData::setModemConnectResp(const QString &n) {
- writeConfig(MODEM_GRP, CONNECTRESP_KEY, n);
+ writeConfig(modemGroup(), CONNECTRESP_KEY, n);
}
const QString PPPData::modemBusyResp() {
- return readConfig(MODEM_GRP, BUSYRESP_KEY, "BUSY");
+ return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY");
}
void PPPData::setModemBusyResp(const QString &n) {
- writeConfig(MODEM_GRP, BUSYRESP_KEY, n);
+ writeConfig(modemGroup(), BUSYRESP_KEY, n);
}
const QString PPPData::modemNoCarrierResp() {
- return readConfig(MODEM_GRP, NOCARRIERRESP_KEY, "NO CARRIER");
+ return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER");
}
void PPPData::setModemNoCarrierResp(const QString &n) {
- writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n);
+ writeConfig(modemGroup(), NOCARRIERRESP_KEY, n);
}
const QString PPPData::modemNoDialtoneResp() {
- return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE");
+ return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE");
}
void PPPData::setModemNoDialtoneResp(const QString &n) {
- writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n);
+ writeConfig(modemGroup(), NODIALTONERESP_KEY, n);
}
const QString PPPData::modemHangupStr() {
- return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH");
+ return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH");
}
void PPPData::setModemHangupStr(const QString &n) {
- writeConfig(MODEM_GRP, HANGUPSTR_KEY, n);
+ writeConfig(modemGroup(), HANGUPSTR_KEY, n);
}
const QString PPPData::modemHangupResp() {
- return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK");
+ return readConfig(modemGroup(), HANGUPRESP_KEY, "OK");
}
void PPPData::setModemHangupResp(const QString &n) {
- writeConfig(MODEM_GRP, HANGUPRESP_KEY, n);
+ writeConfig(modemGroup(), HANGUPRESP_KEY, n);
}
const QString PPPData::modemAnswerStr() {
- return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA");
+ return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA");
}
QString PPPData::volumeOff() {
- return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0");
+ return readConfig(modemGroup(), VOLUME_OFF, "M0L0");
}
void PPPData::setVolumeOff(const QString &s) {
- writeConfig(MODEM_GRP, VOLUME_OFF, s);
+ writeConfig(modemGroup(), VOLUME_OFF, s);
}
QString PPPData::volumeMedium() {
- return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1");
+ return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1");
}
void PPPData::setVolumeMedium(const QString &s) {
- writeConfig(MODEM_GRP, VOLUME_MEDIUM, s);
+ writeConfig(modemGroup(), VOLUME_MEDIUM, s);
}
QString PPPData::volumeHigh() {
- QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3");
+ QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3");
if(tmp == "M1L4")
tmp = "M1L3";
return tmp;
@@ -598,7 +598,7 @@ QString PPPData::volumeHigh() {
void PPPData::setVolumeHigh(const QString &s) {
- writeConfig(MODEM_GRP, VOLUME_HIGH, s);
+ writeConfig(modemGroup(), VOLUME_HIGH, s);
}
@@ -624,54 +624,54 @@ QString PPPData::volumeInitString() {
int PPPData::volume() {
- return readNumConfig(MODEM_GRP, VOLUME_KEY, 1);
+ return readNumConfig(modemGroup(), VOLUME_KEY, 1);
}
void PPPData::setVolume(int i) {
- writeConfig(MODEM_GRP, VOLUME_KEY, i);
+ writeConfig(modemGroup(), VOLUME_KEY, i);
}
int PPPData::waitForDialTone() {
- return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1);
+ return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
}
void PPPData::setWaitForDialTone(int i) {
- writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i);
+ writeConfig(modemGroup(), DIALTONEWAIT_KEY, i);
}
void PPPData::setModemAnswerStr(const QString &n) {
- writeConfig(MODEM_GRP, ANSWERSTR_KEY, n);
+ writeConfig(modemGroup(), ANSWERSTR_KEY, n);
}
const QString PPPData::modemRingResp() {
- return readConfig(MODEM_GRP, RINGRESP_KEY, "RING");
+ return readConfig(modemGroup(), RINGRESP_KEY, "RING");
}
void PPPData::setModemRingResp(const QString &n) {
- writeConfig(MODEM_GRP, RINGRESP_KEY, n);
+ writeConfig(modemGroup(), RINGRESP_KEY, n);
}
const QString PPPData::modemAnswerResp() {
- return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT");
+ return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
}
void PPPData::setModemAnswerResp(const QString &n) {
- writeConfig(MODEM_GRP, ANSWERRESP_KEY, n);
+ writeConfig(modemGroup(), ANSWERRESP_KEY, n);
}
const QString PPPData::enter() {
- return readConfig(MODEM_GRP, ENTER_KEY, "CR");
+ return readConfig(modemGroup(), ENTER_KEY, "CR");
}
void PPPData::setEnter(const QString &n) {
- writeConfig(MODEM_GRP, ENTER_KEY, n);
+ writeConfig(modemGroup(), ENTER_KEY, n);
}
@@ -1209,6 +1209,10 @@ void PPPData::setpppdError(int err) {
pppderror = err;
}
+QString PPPData::modemGroup()
+{
+ return MODEM_GRP;
+}
// //
// // window position
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
@@ -159,30 +159,31 @@ class Config;
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();
// functions to set/get general kppp info
QString password() const;
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
@@ -8,7 +8,12 @@
/**
* Constructor, find all of the possible interfaces
*/
-PPPModule::PPPModule() : Module() {
+PPPModule::PPPModule() : Module()
+{
+ Interface *iface;
+ iface = new Interface( 0, "device" );
+ iface->setHardwareName( "account" );
+ list.append( iface );
}
/**
@@ -42,12 +47,7 @@ QString PPPModule::getPixmapName(Interface* ){
* @return bool true if i is owned by this module, false otherwise.
*/
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;
}
/**
@@ -56,8 +56,8 @@ bool PPPModule::isOwner(Interface *i){
*/
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;
}
@@ -97,8 +97,12 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
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;
}
return NULL;
}
@@ -114,8 +118,8 @@ bool PPPModule::remove(Interface*){
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"));
}