summaryrefslogtreecommitdiff
authortille <tille>2003-05-24 23:34:09 (UTC)
committer tille <tille>2003-05-24 23:34:09 (UTC)
commitd1c32c127b4dabb716064a790da6be7c24975a92 (patch) (unidiff)
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
@@ -28,2 +28,3 @@
28#include <stdlib.h> 28#include <stdlib.h>
29#include <unistd.h>
29#include <fcntl.h> 30#include <fcntl.h>
@@ -35,3 +36,14 @@
35#include <assert.h> 36#include <assert.h>
37#include <string.h>
36 38
39#ifdef HAVE_RESOLV_H
40# include <arpa/nameser.h>
41# include <resolv.h>
42#endif
43
44#ifndef _PATH_RESCONF
45#define _PATH_RESCONF "/etc/resolv.conf"
46#endif
47
48#define strlcpy strcpy
37#include "auth.h" 49#include "auth.h"
@@ -85,2 +97,4 @@ Modem::Modem()
85 modemfd = -1; 97 modemfd = -1;
98 _pppdExitStatus = -1;
99 pppdPid = -1;
86 sn = 0L; 100 sn = 0L;
@@ -757,2 +771,18 @@ bool Modem::createAuthFile(Auth method, const char *username, const char *passwo
757 771
772bool Modem::removeAuthFile(Auth method) {
773 const char *authfile, *oldName;
774
775 if(!(authfile = authFile(method)))
776 return false;
777 if(!(oldName = authFile(method, Old)))
778 return false;
779
780 if(access(oldName, F_OK) == 0) {
781 unlink(authfile);
782 return (rename(oldName, authfile) == 0);
783 } else
784 return false;
785}
786
787
758bool Modem::setSecret(int method, const char* name, const char* password) 788bool 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)
780 810
781bool Modem::removeSecret(int) 811bool Modem::removeSecret(int method)
782{ 812{
783 return true; 813 Auth auth;
814
815 switch(method) {
816 case AUTH_PAP:
817 auth = Modem::PAP;
818 break;
819 case AUTH_CHAP:
820 auth = Modem::CHAP;
821 break;
822 default:
823 return false;
824 }
825 return removeAuthFile( auth );
784} 826}
785 827
786void Modem::killPPPDaemon() 828int checkForInterface()
787{ 829{
830// I don't know if Linux needs more initialization to get the ioctl to
831// work, pppd seems to hint it does. But BSD doesn't, and the following
832// code should compile.
833#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__)
834 int s, ok;
835 struct ifreq ifr;
836 // extern char *no_ppp_msg;
837
838 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
839 return 1; /* can't tell */
840
841 strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
842 ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
843 close(s);
844
845 if (ok == -1) {
846// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports
847// KLDs, the old LKM interface couldn't handle loading devices
848// dynamically, and thus can't load ppp support on the fly
849#ifdef __FreeBSD__
850 // If we failed to load ppp support and don't have it already.
851 if (kldload("if_ppp") == -1) {
852 return -1;
853 }
854 return 0;
855#else
856 return -1;
857#endif
858 }
859 return 0;
860#else
861// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp
862 struct stat buf;
863
864 memset(&buf, 0, sizeof(buf));
865 return stat("/dev/ppp", &buf);
866#endif
788} 867}
789 868
790int Modem::pppdExitStatus() 869bool Modem::execpppd(const char *arguments) {
791{ 870 char buf[MAX_CMDLEN];
792 return -1; 871 char *args[MaxArgs];
872 pid_t pgrpid;
873
874 if(modemfd<0)
875 return false;
876
877 _pppdExitStatus = -1;
878
879 switch(pppdPid = fork())
880 {
881 case -1:
882 fprintf(stderr,"In parent: fork() failed\n");
883 return false;
884 break;
885
886 case 0:
887 // let's parse the arguments the user supplied into UNIX suitable form
888 // that is a list of pointers each pointing to exactly one word
889 strlcpy(buf, arguments);
890 parseargs(buf, args);
891 // become a session leader and let /dev/ttySx
892 // be the controlling terminal.
893 pgrpid = setsid();
894#ifdef TIOCSCTTY
895 if(ioctl(modemfd, TIOCSCTTY, 0)<0)
896 fprintf(stderr, "ioctl() failed.\n");
897#elif defined (TIOCSPGRP)
898 if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0)
899 fprintf(stderr, "ioctl() failed.\n");
900#endif
901 if(tcsetpgrp(modemfd, pgrpid)<0)
902 fprintf(stderr, "tcsetpgrp() failed.\n");
903
904 dup2(modemfd, 0);
905 dup2(modemfd, 1);
906
907 switch (checkForInterface()) {
908 case 1:
909 fprintf(stderr, "Cannot determine if kernel supports ppp.\n");
910 break;
911 case -1:
912 fprintf(stderr, "Kernel does not support ppp, oops.\n");
913 break;
914 case 0:
915 fprintf(stderr, "Kernel supports ppp alright.\n");
916 break;
917 }
918
919 execve(pppdPath(), args, 0L);
920 _exit(0);
921 break;
922
923 default:
924 qDebug("In parent: pppd pid %d\n",pppdPid);
925 close(modemfd);
926 modemfd = -1;
927 return true;
928 break;
929 }
930}
931
932
933bool Modem::killpppd() {
934 if(pppdPid > 0) {
935 qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid);
936 if(kill(pppdPid, SIGTERM) < 0) {
937 qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid);
938 if(kill(pppdPid, SIGKILL) < 0) {
939 qDebug("Error killing %d\n", pppdPid);
940 return false;
941 }
942 }
943 }
944 return true;
945}
946
947
948void Modem::parseargs(char* buf, char** args) {
949 int nargs = 0;
950 int quotes;
951
952 while(nargs < MaxArgs-1 && *buf != '\0') {
953
954 quotes = 0;
955
956 // Strip whitespace. Use nulls, so that the previous argument is
957 // terminated automatically.
958
959 while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) )
960 *buf++ = '\0';
961
962 // detect begin of quoted argument
963 if (*buf == '"' || *buf == '\'') {
964 quotes = *buf;
965 *buf++ = '\0';
966 }
967
968 // save the argument
969 if(*buf != '\0') {
970 *args++ = buf;
971 nargs++;
972 }
973
974 if (!quotes)
975 while ((*buf != '\0') && (*buf != '\n') &&
976 (*buf != '\t') && (*buf != ' '))
977 buf++;
978 else {
979 while ((*buf != '\0') && (*buf != quotes))
980 buf++;
981 *buf++ = '\0';
982 }
983 }
984
985 *args = 0L;
793} 986}
@@ -796,3 +989,18 @@ bool Modem::execPPPDaemon(const QString & arguments)
796{ 989{
990 if(execpppd(arguments)==0) {
991 PPPData::data()->setpppdRunning(true);
797 return true; 992 return true;
993 } else
994 return false;
995}
996
997void Modem::killPPPDaemon()
998{
999 PPPData::data()->setpppdRunning(false);
1000 killpppd();
1001}
1002
1003int Modem::pppdExitStatus()
1004{
1005 return _pppdExitStatus;
798} 1006}
@@ -801,3 +1009,8 @@ int Modem::openResolv(int flags)
801{ 1009{
802 return -1; 1010 int fd;
1011 if ((fd = open(_PATH_RESCONF, flags)) == -1) {
1012 qDebug("error opening resolv.conf!");
1013 fd = open(DEVNULL, O_RDONLY);
1014 }
1015 return fd;
803} 1016}
@@ -806,3 +1019,3 @@ bool Modem::setHostname(const QString & name)
806{ 1019{
807 return true; 1020 return sethostname(name, name.length()) == 0;
808} 1021}
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:
95 bool createAuthFile(Auth method,const char *username,const char *password); 95 bool createAuthFile(Auth method,const char *username,const char *password);
96 bool removeAuthFile(Auth method);
97 bool execpppd(const char *arguments);
98 bool killpppd();
99 void parseargs(char* buf, char** args);
96 void escape_to_command_mode(); 100 void escape_to_command_mode();
@@ -102,2 +106,4 @@ private:
102 int modemfd; 106 int modemfd;
107 int pppdPid;
108 int _pppdExitStatus;
103 QSocketNotifier *sn; 109 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) {
325const QString PPPData::modemDevice() { 325const QString PPPData::modemDevice() {
326 return readConfig (MODEM_GRP, MODEMDEV_KEY, devices[DEV_DEFAULT]); 326 return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]);
327} 327}
@@ -330,3 +330,3 @@ const QString PPPData::modemDevice() {
330void PPPData::setModemDevice(const QString &n) { 330void PPPData::setModemDevice(const QString &n) {
331 writeConfig(MODEM_GRP, MODEMDEV_KEY, n); 331 writeConfig(modemGroup(), MODEMDEV_KEY, n);
332} 332}
@@ -335,3 +335,3 @@ void PPPData::setModemDevice(const QString &n) {
335const QString PPPData::flowcontrol() { 335const QString PPPData::flowcontrol() {
336 return readConfig(MODEM_GRP, FLOWCONTROL_KEY, "CRTSCTS"); 336 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
337} 337}
@@ -340,3 +340,3 @@ const QString PPPData::flowcontrol() {
340void PPPData::setFlowcontrol(const QString &n) { 340void PPPData::setFlowcontrol(const QString &n) {
341 writeConfig(MODEM_GRP, FLOWCONTROL_KEY, n); 341 writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
342} 342}
@@ -345,3 +345,3 @@ void PPPData::setFlowcontrol(const QString &n) {
345const QString PPPData::speed() { 345const QString PPPData::speed() {
346 QString s = readConfig(MODEM_GRP, SPEED_KEY, "57600"); 346 QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
347 // undo the damage of a bug in former versions. It left an empty Speed= 347 // undo the damage of a bug in former versions. It left an empty Speed=
@@ -356,3 +356,3 @@ const QString PPPData::speed() {
356void PPPData::setSpeed(const QString &n) { 356void PPPData::setSpeed(const QString &n) {
357 writeConfig(MODEM_GRP, SPEED_KEY, n); 357 writeConfig(modemGroup(), SPEED_KEY, n);
358} 358}
@@ -362,3 +362,3 @@ void PPPData::setSpeed(const QString &n) {
362void PPPData::setUseCDLine(const int n) { 362void PPPData::setUseCDLine(const int n) {
363 writeConfig(MODEM_GRP,USECDLINE_KEY,n); 363 writeConfig(modemGroup(),USECDLINE_KEY,n);
364} 364}
@@ -367,3 +367,3 @@ void PPPData::setUseCDLine(const int n) {
367int PPPData::UseCDLine() { 367int PPPData::UseCDLine() {
368 return readNumConfig(MODEM_GRP,USECDLINE_KEY,0); 368 return readNumConfig(modemGroup(),USECDLINE_KEY,0);
369} 369}
@@ -372,3 +372,3 @@ int PPPData::UseCDLine() {
372const QString PPPData::modemEscapeStr() { 372const QString PPPData::modemEscapeStr() {
373 return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++"); 373 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
374} 374}
@@ -377,3 +377,3 @@ const QString PPPData::modemEscapeStr() {
377void PPPData::setModemEscapeStr(const QString &n) { 377void PPPData::setModemEscapeStr(const QString &n) {
378 writeConfig(MODEM_GRP,ESCAPESTR_KEY,n); 378 writeConfig(modemGroup(),ESCAPESTR_KEY,n);
379} 379}
@@ -382,3 +382,3 @@ void PPPData::setModemEscapeStr(const QString &n) {
382const QString PPPData::modemEscapeResp() { 382const QString PPPData::modemEscapeResp() {
383 return readConfig(MODEM_GRP,ESCAPERESP_KEY,"OK"); 383 return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
384} 384}
@@ -387,3 +387,3 @@ const QString PPPData::modemEscapeResp() {
387void PPPData::setModemEscapeResp(const QString &n) { 387void PPPData::setModemEscapeResp(const QString &n) {
388 writeConfig(MODEM_GRP,ESCAPERESP_KEY,n); 388 writeConfig(modemGroup(),ESCAPERESP_KEY,n);
389} 389}
@@ -392,3 +392,3 @@ void PPPData::setModemEscapeResp(const QString &n) {
392int PPPData::modemEscapeGuardTime() { 392int PPPData::modemEscapeGuardTime() {
393 return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50); 393 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
394} 394}
@@ -397,3 +397,3 @@ int PPPData::modemEscapeGuardTime() {
397void PPPData::setModemEscapeGuardTime(int n) { 397void PPPData::setModemEscapeGuardTime(int n) {
398 writeConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,n); 398 writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n);
399} 399}
@@ -402,3 +402,3 @@ void PPPData::setModemEscapeGuardTime(int n) {
402bool PPPData::modemLockFile() { 402bool PPPData::modemLockFile() {
403 return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1); 403 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
404} 404}
@@ -407,3 +407,3 @@ bool PPPData::modemLockFile() {
407void PPPData::setModemLockFile(bool set) { 407void PPPData::setModemLockFile(bool set) {
408 writeConfig(MODEM_GRP, LOCKFILE_KEY, set); 408 writeConfig(modemGroup(), LOCKFILE_KEY, set);
409} 409}
@@ -412,3 +412,3 @@ void PPPData::setModemLockFile(bool set) {
412int PPPData::modemTimeout() { 412int PPPData::modemTimeout() {
413 return readNumConfig(MODEM_GRP, TIMEOUT_KEY, MODEM_TIMEOUT); 413 return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT);
414} 414}
@@ -417,3 +417,3 @@ int PPPData::modemTimeout() {
417void PPPData::setModemTimeout(int n) { 417void PPPData::setModemTimeout(int n) {
418 writeConfig(MODEM_GRP, TIMEOUT_KEY, n); 418 writeConfig(modemGroup(), TIMEOUT_KEY, n);
419} 419}
@@ -422,3 +422,3 @@ void PPPData::setModemTimeout(int n) {
422int PPPData::modemToneDuration() { 422int PPPData::modemToneDuration() {
423 return readNumConfig(MODEM_GRP, TONEDURATION_KEY,MODEM_TONEDURATION); 423 return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION);
424} 424}
@@ -427,3 +427,3 @@ int PPPData::modemToneDuration() {
427void PPPData::setModemToneDuration(int n) { 427void PPPData::setModemToneDuration(int n) {
428 writeConfig(MODEM_GRP, TONEDURATION_KEY, n); 428 writeConfig(modemGroup(), TONEDURATION_KEY, n);
429} 429}
@@ -432,3 +432,3 @@ void PPPData::setModemToneDuration(int n) {
432int PPPData::busyWait() { 432int PPPData::busyWait() {
433 return readNumConfig(MODEM_GRP, BUSYWAIT_KEY, BUSY_WAIT); 433 return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT);
434} 434}
@@ -437,3 +437,3 @@ int PPPData::busyWait() {
437void PPPData::setbusyWait(int n) { 437void PPPData::setbusyWait(int n) {
438 writeConfig(MODEM_GRP, BUSYWAIT_KEY, n); 438 writeConfig(modemGroup(), BUSYWAIT_KEY, n);
439} 439}
@@ -448,5 +448,5 @@ const QString PPPData::modemInitStr(int i) {
448 if(i == 0) 448 if(i == 0)
449 return readConfig(MODEM_GRP, INITSTR_KEY, "ATZ"); 449 return readConfig(modemGroup(), INITSTR_KEY, "ATZ");
450 else 450 else
451 return readConfig(MODEM_GRP, INITSTR_KEY + QString::number(i), ""); 451 return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), "");
452} 452}
@@ -457,3 +457,3 @@ void PPPData::setModemInitStr(int i, const QString &n) {
457 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); 457 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : "");
458 writeConfig(MODEM_GRP, k, n); 458 writeConfig(modemGroup(), k, n);
459} 459}
@@ -462,3 +462,3 @@ void PPPData::setModemInitStr(int i, const QString &n) {
462const QString PPPData::modemInitResp() { 462const QString PPPData::modemInitResp() {
463 return readConfig(MODEM_GRP, INITRESP_KEY, "OK"); 463 return readConfig(modemGroup(), INITRESP_KEY, "OK");
464} 464}
@@ -467,3 +467,3 @@ const QString PPPData::modemInitResp() {
467void PPPData::setModemInitResp(const QString &n) { 467void PPPData::setModemInitResp(const QString &n) {
468 writeConfig(MODEM_GRP, INITRESP_KEY, n); 468 writeConfig(modemGroup(), INITRESP_KEY, n);
469} 469}
@@ -472,3 +472,3 @@ void PPPData::setModemInitResp(const QString &n) {
472int PPPData::modemPreInitDelay() { 472int PPPData::modemPreInitDelay() {
473 return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50); 473 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50);
474} 474}
@@ -477,3 +477,3 @@ int PPPData::modemPreInitDelay() {
477void PPPData::setModemPreInitDelay(int n) { 477void PPPData::setModemPreInitDelay(int n) {
478 writeConfig(MODEM_GRP, PREINITDELAY_KEY, n); 478 writeConfig(modemGroup(), PREINITDELAY_KEY, n);
479} 479}
@@ -482,3 +482,3 @@ void PPPData::setModemPreInitDelay(int n) {
482int PPPData::modemInitDelay() { 482int PPPData::modemInitDelay() {
483 return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50); 483 return readNumConfig(modemGroup(), INITDELAY_KEY, 50);
484} 484}
@@ -487,3 +487,3 @@ int PPPData::modemInitDelay() {
487void PPPData::setModemInitDelay(int n) { 487void PPPData::setModemInitDelay(int n) {
488 writeConfig(MODEM_GRP, INITDELAY_KEY, n); 488 writeConfig(modemGroup(), INITDELAY_KEY, n);
489} 489}
@@ -491,3 +491,3 @@ void PPPData::setModemInitDelay(int n) {
491QString PPPData::modemNoDialToneDetectionStr() { 491QString PPPData::modemNoDialToneDetectionStr() {
492 return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3"); 492 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3");
493} 493}
@@ -495,3 +495,3 @@ QString PPPData::modemNoDialToneDetectionStr() {
495void PPPData::setModemNoDialToneDetectionStr(const QString &n) { 495void PPPData::setModemNoDialToneDetectionStr(const QString &n) {
496 writeConfig(MODEM_GRP, NODTDETECT_KEY, n); 496 writeConfig(modemGroup(), NODTDETECT_KEY, n);
497} 497}
@@ -499,3 +499,3 @@ void PPPData::setModemNoDialToneDetectionStr(const QString &n) {
499const QString PPPData::modemDialStr() { 499const QString PPPData::modemDialStr() {
500 return readConfig(MODEM_GRP, DIALSTR_KEY, "ATDT"); 500 return readConfig(modemGroup(), DIALSTR_KEY, "ATDT");
501} 501}
@@ -504,3 +504,3 @@ const QString PPPData::modemDialStr() {
504void PPPData::setModemDialStr(const QString &n) { 504void PPPData::setModemDialStr(const QString &n) {
505 writeConfig(MODEM_GRP, DIALSTR_KEY, n); 505 writeConfig(modemGroup(), DIALSTR_KEY, n);
506} 506}
@@ -509,3 +509,3 @@ void PPPData::setModemDialStr(const QString &n) {
509const QString PPPData::modemConnectResp() { 509const QString PPPData::modemConnectResp() {
510 return readConfig(MODEM_GRP, CONNECTRESP_KEY, "CONNECT"); 510 return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT");
511} 511}
@@ -514,3 +514,3 @@ const QString PPPData::modemConnectResp() {
514void PPPData::setModemConnectResp(const QString &n) { 514void PPPData::setModemConnectResp(const QString &n) {
515 writeConfig(MODEM_GRP, CONNECTRESP_KEY, n); 515 writeConfig(modemGroup(), CONNECTRESP_KEY, n);
516} 516}
@@ -519,3 +519,3 @@ void PPPData::setModemConnectResp(const QString &n) {
519const QString PPPData::modemBusyResp() { 519const QString PPPData::modemBusyResp() {
520 return readConfig(MODEM_GRP, BUSYRESP_KEY, "BUSY"); 520 return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY");
521} 521}
@@ -524,3 +524,3 @@ const QString PPPData::modemBusyResp() {
524void PPPData::setModemBusyResp(const QString &n) { 524void PPPData::setModemBusyResp(const QString &n) {
525 writeConfig(MODEM_GRP, BUSYRESP_KEY, n); 525 writeConfig(modemGroup(), BUSYRESP_KEY, n);
526} 526}
@@ -529,3 +529,3 @@ void PPPData::setModemBusyResp(const QString &n) {
529const QString PPPData::modemNoCarrierResp() { 529const QString PPPData::modemNoCarrierResp() {
530 return readConfig(MODEM_GRP, NOCARRIERRESP_KEY, "NO CARRIER"); 530 return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER");
531} 531}
@@ -534,3 +534,3 @@ const QString PPPData::modemNoCarrierResp() {
534void PPPData::setModemNoCarrierResp(const QString &n) { 534void PPPData::setModemNoCarrierResp(const QString &n) {
535 writeConfig(MODEM_GRP, NOCARRIERRESP_KEY, n); 535 writeConfig(modemGroup(), NOCARRIERRESP_KEY, n);
536} 536}
@@ -539,3 +539,3 @@ void PPPData::setModemNoCarrierResp(const QString &n) {
539const QString PPPData::modemNoDialtoneResp() { 539const QString PPPData::modemNoDialtoneResp() {
540 return readConfig(MODEM_GRP, NODIALTONERESP_KEY, "NO DIALTONE"); 540 return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE");
541} 541}
@@ -544,3 +544,3 @@ const QString PPPData::modemNoDialtoneResp() {
544void PPPData::setModemNoDialtoneResp(const QString &n) { 544void PPPData::setModemNoDialtoneResp(const QString &n) {
545 writeConfig(MODEM_GRP, NODIALTONERESP_KEY, n); 545 writeConfig(modemGroup(), NODIALTONERESP_KEY, n);
546} 546}
@@ -549,3 +549,3 @@ void PPPData::setModemNoDialtoneResp(const QString &n) {
549const QString PPPData::modemHangupStr() { 549const QString PPPData::modemHangupStr() {
550 return readConfig(MODEM_GRP, HANGUPSTR_KEY, "+++ATH"); 550 return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH");
551} 551}
@@ -553,3 +553,3 @@ const QString PPPData::modemHangupStr() {
553void PPPData::setModemHangupStr(const QString &n) { 553void PPPData::setModemHangupStr(const QString &n) {
554 writeConfig(MODEM_GRP, HANGUPSTR_KEY, n); 554 writeConfig(modemGroup(), HANGUPSTR_KEY, n);
555} 555}
@@ -558,3 +558,3 @@ void PPPData::setModemHangupStr(const QString &n) {
558const QString PPPData::modemHangupResp() { 558const QString PPPData::modemHangupResp() {
559 return readConfig(MODEM_GRP, HANGUPRESP_KEY, "OK"); 559 return readConfig(modemGroup(), HANGUPRESP_KEY, "OK");
560} 560}
@@ -562,3 +562,3 @@ const QString PPPData::modemHangupResp() {
562void PPPData::setModemHangupResp(const QString &n) { 562void PPPData::setModemHangupResp(const QString &n) {
563 writeConfig(MODEM_GRP, HANGUPRESP_KEY, n); 563 writeConfig(modemGroup(), HANGUPRESP_KEY, n);
564} 564}
@@ -567,3 +567,3 @@ void PPPData::setModemHangupResp(const QString &n) {
567const QString PPPData::modemAnswerStr() { 567const QString PPPData::modemAnswerStr() {
568 return readConfig(MODEM_GRP, ANSWERSTR_KEY, "ATA"); 568 return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA");
569} 569}
@@ -572,3 +572,3 @@ const QString PPPData::modemAnswerStr() {
572QString PPPData::volumeOff() { 572QString PPPData::volumeOff() {
573 return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0"); 573 return readConfig(modemGroup(), VOLUME_OFF, "M0L0");
574} 574}
@@ -577,3 +577,3 @@ QString PPPData::volumeOff() {
577void PPPData::setVolumeOff(const QString &s) { 577void PPPData::setVolumeOff(const QString &s) {
578 writeConfig(MODEM_GRP, VOLUME_OFF, s); 578 writeConfig(modemGroup(), VOLUME_OFF, s);
579} 579}
@@ -582,3 +582,3 @@ void PPPData::setVolumeOff(const QString &s) {
582QString PPPData::volumeMedium() { 582QString PPPData::volumeMedium() {
583 return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1"); 583 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1");
584} 584}
@@ -587,3 +587,3 @@ QString PPPData::volumeMedium() {
587void PPPData::setVolumeMedium(const QString &s) { 587void PPPData::setVolumeMedium(const QString &s) {
588 writeConfig(MODEM_GRP, VOLUME_MEDIUM, s); 588 writeConfig(modemGroup(), VOLUME_MEDIUM, s);
589} 589}
@@ -592,3 +592,3 @@ void PPPData::setVolumeMedium(const QString &s) {
592QString PPPData::volumeHigh() { 592QString PPPData::volumeHigh() {
593 QString tmp = readConfig(MODEM_GRP, VOLUME_HIGH, "M1L3"); 593 QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3");
594 if(tmp == "M1L4") 594 if(tmp == "M1L4")
@@ -600,3 +600,3 @@ QString PPPData::volumeHigh() {
600void PPPData::setVolumeHigh(const QString &s) { 600void PPPData::setVolumeHigh(const QString &s) {
601 writeConfig(MODEM_GRP, VOLUME_HIGH, s); 601 writeConfig(modemGroup(), VOLUME_HIGH, s);
602} 602}
@@ -626,3 +626,3 @@ QString PPPData::volumeInitString() {
626int PPPData::volume() { 626int PPPData::volume() {
627 return readNumConfig(MODEM_GRP, VOLUME_KEY, 1); 627 return readNumConfig(modemGroup(), VOLUME_KEY, 1);
628} 628}
@@ -631,3 +631,3 @@ int PPPData::volume() {
631void PPPData::setVolume(int i) { 631void PPPData::setVolume(int i) {
632 writeConfig(MODEM_GRP, VOLUME_KEY, i); 632 writeConfig(modemGroup(), VOLUME_KEY, i);
633} 633}
@@ -635,3 +635,3 @@ void PPPData::setVolume(int i) {
635int PPPData::waitForDialTone() { 635int PPPData::waitForDialTone() {
636 return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); 636 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
637} 637}
@@ -639,3 +639,3 @@ int PPPData::waitForDialTone() {
639void PPPData::setWaitForDialTone(int i) { 639void PPPData::setWaitForDialTone(int i) {
640 writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i); 640 writeConfig(modemGroup(), DIALTONEWAIT_KEY, i);
641} 641}
@@ -643,3 +643,3 @@ void PPPData::setWaitForDialTone(int i) {
643void PPPData::setModemAnswerStr(const QString &n) { 643void PPPData::setModemAnswerStr(const QString &n) {
644 writeConfig(MODEM_GRP, ANSWERSTR_KEY, n); 644 writeConfig(modemGroup(), ANSWERSTR_KEY, n);
645} 645}
@@ -648,3 +648,3 @@ void PPPData::setModemAnswerStr(const QString &n) {
648const QString PPPData::modemRingResp() { 648const QString PPPData::modemRingResp() {
649 return readConfig(MODEM_GRP, RINGRESP_KEY, "RING"); 649 return readConfig(modemGroup(), RINGRESP_KEY, "RING");
650} 650}
@@ -653,3 +653,3 @@ const QString PPPData::modemRingResp() {
653void PPPData::setModemRingResp(const QString &n) { 653void PPPData::setModemRingResp(const QString &n) {
654 writeConfig(MODEM_GRP, RINGRESP_KEY, n); 654 writeConfig(modemGroup(), RINGRESP_KEY, n);
655} 655}
@@ -658,3 +658,3 @@ void PPPData::setModemRingResp(const QString &n) {
658const QString PPPData::modemAnswerResp() { 658const QString PPPData::modemAnswerResp() {
659 return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT"); 659 return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
660} 660}
@@ -663,3 +663,3 @@ const QString PPPData::modemAnswerResp() {
663void PPPData::setModemAnswerResp(const QString &n) { 663void PPPData::setModemAnswerResp(const QString &n) {
664 writeConfig(MODEM_GRP, ANSWERRESP_KEY, n); 664 writeConfig(modemGroup(), ANSWERRESP_KEY, n);
665} 665}
@@ -668,3 +668,3 @@ void PPPData::setModemAnswerResp(const QString &n) {
668const QString PPPData::enter() { 668const QString PPPData::enter() {
669 return readConfig(MODEM_GRP, ENTER_KEY, "CR"); 669 return readConfig(modemGroup(), ENTER_KEY, "CR");
670} 670}
@@ -673,3 +673,3 @@ const QString PPPData::enter() {
673void PPPData::setEnter(const QString &n) { 673void PPPData::setEnter(const QString &n) {
674 writeConfig(MODEM_GRP, ENTER_KEY, n); 674 writeConfig(modemGroup(), ENTER_KEY, n);
675} 675}
@@ -1211,2 +1211,6 @@ void PPPData::setpppdError(int err) {
1211 1211
1212QString PPPData::modemGroup()
1213{
1214 return MODEM_GRP;
1215}
1212 1216
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 {
161public: 161public:
162 PPPData(); 162 PPPData();
163 ~PPPData() {}; 163 ~PPPData() {};
164 static PPPData* data(); 164 static PPPData* data();
165 165
166 enum { NumInitStrings = 2 }; 166 enum { NumInitStrings = 2 };
167 167
168 // general functions 168 // general functions
169 bool open(); 169 bool open();
170 void save(); 170 void save();
171 void cancel(); 171 void cancel();
172// int access() const; // read/write access
173 172
174 // function to read/write date to configuration file 173
175 QString readConfig(const QString &, const QString &, const QString &); 174 // function to read/write date to configuration file
176 int readNumConfig(const QString &, const QString &, int); 175 QString readConfig(const QString &, const QString &, const QString &);
177 bool readListConfig(const QString &, const QString &, 176 int readNumConfig(const QString &, const QString &, int);
177 bool readListConfig(const QString &, const QString &,
178 QStringList &, char sep = ','); 178 QStringList &, char sep = ',');
179 void writeConfig(const QString &, const QString &, const QString &); 179 void writeConfig(const QString &, const QString &, const QString &);
180 void writeConfig(const QString &, const QString &, int); 180 void writeConfig(const QString &, const QString &, int);
181 void writeListConfig(const QString &, const QString &, 181 void writeListConfig(const QString &, const QString &,
182 QStringList &, char sep = ','); 182 QStringList &, char sep = ',');
183 183
184 // return the current account group 184 // return the current account group
185 QString currentGroup() { return cgroup; } 185 QString currentGroup() { return cgroup; }
186 QString modemGroup();
186 187
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 @@
10 */ 10 */
11PPPModule::PPPModule() : Module() { 11PPPModule::PPPModule() : Module()
12{
13 Interface *iface;
14 iface = new Interface( 0, "device" );
15 iface->setHardwareName( "account" );
16 list.append( iface );
12} 17}
@@ -44,8 +49,3 @@ QString PPPModule::getPixmapName(Interface* ){
44bool PPPModule::isOwner(Interface *i){ 49bool PPPModule::isOwner(Interface *i){
45 if(!i->getInterfaceName().upper().contains("PPP")) 50 return list.find( i ) != -1;
46 return false;
47
48 i->setHardwareName("PPP");
49 list.append(i);
50 return true;
51} 51}
@@ -58,4 +58,4 @@ QWidget *PPPModule::configure(Interface *i){
58 qDebug("return ModemWidget"); 58 qDebug("return ModemWidget");
59 PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose ); 59 PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false,
60// pppconfig->setProfile(profile); 60 Qt::WDestructiveClose );
61 return pppconfig; 61 return pppconfig;
@@ -99,4 +99,8 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){
99 qDebug("ACCEPTED"); 99 qDebug("ACCEPTED");
100 return new Interface( 0, newInterface );
101 PPPData::data()->save(); 100 PPPData::data()->save();
101 Interface *iface;
102 iface = new Interface( 0, PPPData::data()->modemDevice() );
103 iface->setHardwareName( PPPData::data()->accname() );
104 list.append( iface );
105 return iface;
102 } 106 }
@@ -116,4 +120,4 @@ void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
116{ 120{
117 qDebug("here"); 121 newIfaces.insert(QObject::tr("PPP") ,
118 newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device")); 122 QObject::tr("generic ppp device"));
119} 123}