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
@@ -1,133 +1,147 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * This file was added by Harri Porten <porten@tu-harburg.de> 9 * This file was added by Harri Porten <porten@tu-harburg.de>
10 * 10 *
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <errno.h> 27#include <errno.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <unistd.h>
29#include <fcntl.h> 30#include <fcntl.h>
30#include <signal.h> 31#include <signal.h>
31#include <sys/ioctl.h> 32#include <sys/ioctl.h>
32#include <setjmp.h> 33#include <setjmp.h>
33#include <regex.h> 34#include <regex.h>
34#include <qregexp.h> 35#include <qregexp.h>
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"
38#include "modem.h" 50#include "modem.h"
39#include "pppdata.h" 51#include "pppdata.h"
40//#include <klocale.h> 52//#include <klocale.h>
41#define i18n QObject::tr 53#define i18n QObject::tr
42#define qError qDebug 54#define qError qDebug
43//#include <kdebug.h> 55//#include <kdebug.h>
44//#include <config.h> 56//#include <config.h>
45 57
46#define MY_ASSERT(x) if (!(x)) { \ 58#define MY_ASSERT(x) if (!(x)) { \
47 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ 59 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
48 exit(1); } 60 exit(1); }
49 61
50 62
51static sigjmp_buf jmp_buffer; 63static sigjmp_buf jmp_buffer;
52 64
53Modem *Modem::modem = 0; 65Modem *Modem::modem = 0;
54 66
55 67
56const char* pppdPath() { 68const char* pppdPath() {
57 // wasting a few bytes 69 // wasting a few bytes
58 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; 70 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
59 static char *pppdPath = 0L; 71 static char *pppdPath = 0L;
60 char *p; 72 char *p;
61 73
62 if(pppdPath == 0L) { 74 if(pppdPath == 0L) {
63 const char *c = PPPDSEARCHPATH; 75 const char *c = PPPDSEARCHPATH;
64 while(*c != '\0') { 76 while(*c != '\0') {
65 while(*c == ':') 77 while(*c == ':')
66 c++; 78 c++;
67 p = buffer; 79 p = buffer;
68 while(*c != '\0' && *c != ':') 80 while(*c != '\0' && *c != ':')
69 *p++ = *c++; 81 *p++ = *c++;
70 *p = '\0'; 82 *p = '\0';
71 strcat(p, "/"); 83 strcat(p, "/");
72 strcat(p, PPPDNAME); 84 strcat(p, PPPDNAME);
73 if(access(buffer, F_OK) == 0) 85 if(access(buffer, F_OK) == 0)
74 return (pppdPath = buffer); 86 return (pppdPath = buffer);
75 } 87 }
76 } 88 }
77 89
78 return pppdPath; 90 return pppdPath;
79} 91}
80 92
81 93
82Modem::Modem() 94Modem::Modem()
83{ 95{
84 if (Modem::modem != 0) return; //CORRECT? 96 if (Modem::modem != 0) return; //CORRECT?
85 modemfd = -1; 97 modemfd = -1;
98 _pppdExitStatus = -1;
99 pppdPid = -1;
86 sn = 0L; 100 sn = 0L;
87 data_mode = false; 101 data_mode = false;
88 modem_is_locked = false; 102 modem_is_locked = false;
89 lockfile[0] = '\0'; 103 lockfile[0] = '\0';
90 device = "/dev/modem"; 104 device = "/dev/modem";
91 modem = this; 105 modem = this;
92} 106}
93 107
94 108
95Modem::~Modem() { 109Modem::~Modem() {
96 modem = 0; 110 modem = 0;
97} 111}
98 112
99 113
100speed_t Modem::modemspeed() { 114speed_t Modem::modemspeed() {
101 // convert the string modem speed int the gpppdata object to a t_speed type 115 // convert the string modem speed int the gpppdata object to a t_speed type
102 // to set the modem. The constants here should all be ifdef'd because 116 // to set the modem. The constants here should all be ifdef'd because
103 // other systems may not have them 117 // other systems may not have them
104 int i = PPPData::data()->speed().toInt()/100; 118 int i = PPPData::data()->speed().toInt()/100;
105 119
106 switch(i) { 120 switch(i) {
107 case 24: 121 case 24:
108 return B2400; 122 return B2400;
109 break; 123 break;
110 case 96: 124 case 96:
111 return B9600; 125 return B9600;
112 break; 126 break;
113 case 192: 127 case 192:
114 return B19200; 128 return B19200;
115 break; 129 break;
116 case 384: 130 case 384:
117 return B38400; 131 return B38400;
118 break; 132 break;
119#ifdef B57600 133#ifdef B57600
120 case 576: 134 case 576:
121 return B57600; 135 return B57600;
122 break; 136 break;
123#endif 137#endif
124 138
125#ifdef B115200 139#ifdef B115200
126 case 1152: 140 case 1152:
127 return B115200; 141 return B115200;
128 break; 142 break;
129#endif 143#endif
130 144
131#ifdef B230400 145#ifdef B230400
132 case 2304: 146 case 2304:
133 return B230400; 147 return B230400;
@@ -710,100 +724,299 @@ bool Modem::createAuthFile(Auth method, const char *username, const char *passwo
710 if(!(newName = authFile(method, New))) 724 if(!(newName = authFile(method, New)))
711 return false; 725 return false;
712 726
713 // look for username, "username" or 'username' 727 // look for username, "username" or 'username'
714 // if you modify this RE you have to adapt regexp's size above 728 // if you modify this RE you have to adapt regexp's size above
715 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", 729 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']",
716 username,username); 730 username,username);
717 MY_ASSERT(regcomp(&preg, regexp, 0) == 0); 731 MY_ASSERT(regcomp(&preg, regexp, 0) == 0);
718 732
719 // copy to new file pap- or chap-secrets 733 // copy to new file pap- or chap-secrets
720 int old_umask = umask(0077); 734 int old_umask = umask(0077);
721 FILE *fout = fopen(newName, "w"); 735 FILE *fout = fopen(newName, "w");
722 if(fout) { 736 if(fout) {
723 // copy old file 737 // copy old file
724 FILE *fin = fopen(authfile, "r"); 738 FILE *fin = fopen(authfile, "r");
725 if(fin) { 739 if(fin) {
726 while(fgets(line, sizeof(line), fin)) { 740 while(fgets(line, sizeof(line), fin)) {
727 if(regexec(&preg, line, 0, 0L, 0) == 0) 741 if(regexec(&preg, line, 0, 0L, 0) == 0)
728 continue; 742 continue;
729 fputs(line, fout); 743 fputs(line, fout);
730 } 744 }
731 fclose(fin); 745 fclose(fin);
732 } 746 }
733 747
734 // append user/pass pair 748 // append user/pass pair
735 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); 749 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password);
736 fclose(fout); 750 fclose(fout);
737 } 751 }
738 752
739 // restore umask 753 // restore umask
740 umask(old_umask); 754 umask(old_umask);
741 755
742 // free memory allocated by regcomp 756 // free memory allocated by regcomp
743 regfree(&preg); 757 regfree(&preg);
744 758
745 if(!(oldName = authFile(method, Old))) 759 if(!(oldName = authFile(method, Old)))
746 return false; 760 return false;
747 761
748 // delete old file if any 762 // delete old file if any
749 unlink(oldName); 763 unlink(oldName);
750 764
751 rename(authfile, oldName); 765 rename(authfile, oldName);
752 rename(newName, authfile); 766 rename(newName, authfile);
753 767
754 return true; 768 return true;
755} 769}
756 770
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)
759{ 789{
760 790
761 Auth auth; 791 Auth auth;
762 if(method == AUTH_PAPCHAP) 792 if(method == AUTH_PAPCHAP)
763 return setSecret(AUTH_PAP, name, password) && 793 return setSecret(AUTH_PAP, name, password) &&
764 setSecret(AUTH_CHAP, name, password); 794 setSecret(AUTH_CHAP, name, password);
765 795
766 switch(method) { 796 switch(method) {
767 case AUTH_PAP: 797 case AUTH_PAP:
768 auth = Modem::PAP; 798 auth = Modem::PAP;
769 break; 799 break;
770 case AUTH_CHAP: 800 case AUTH_CHAP:
771 auth = Modem::CHAP; 801 auth = Modem::CHAP;
772 break; 802 break;
773 default: 803 default:
774 return false; 804 return false;
775 } 805 }
776 806
777 return createAuthFile(auth, name, password); 807 return createAuthFile(auth, name, password);
778 808
779} 809}
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}
794 987
795bool Modem::execPPPDaemon(const QString & arguments) 988bool 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}
799 1007
800int Modem::openResolv(int flags) 1008int 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}
804 1017
805bool Modem::setHostname(const QString & name) 1018bool Modem::setHostname(const QString & name)
806{ 1019{
807 return true; 1020 return sethostname(name, name.length()) == 0;
808} 1021}
809 1022
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
@@ -48,66 +48,72 @@ public:
48 48
49 const QString getDevice() {return device;}; 49 const QString getDevice() {return device;};
50 void setDevice(const QString dev) {device = dev;}; 50 void setDevice(const QString dev) {device = dev;};
51 51
52 bool opentty(); 52 bool opentty();
53 bool closetty(); 53 bool closetty();
54 bool hangup(); 54 bool hangup();
55 bool writeChar(unsigned char); 55 bool writeChar(unsigned char);
56 bool writeLine(const char *); 56 bool writeLine(const char *);
57 bool dataMode() const { return data_mode; } 57 bool dataMode() const { return data_mode; }
58 void setDataMode(bool set) { data_mode = set; } 58 void setDataMode(bool set) { data_mode = set; }
59 const QString modemMessage(); 59 const QString modemMessage();
60 speed_t modemspeed(); 60 speed_t modemspeed();
61 static QString parseModemSpeed(const QString &); 61 static QString parseModemSpeed(const QString &);
62 void notify(const QObject *, const char *); 62 void notify(const QObject *, const char *);
63 void stop(); 63 void stop();
64 void flush(); 64 void flush();
65 65
66 int lockdevice(); 66 int lockdevice();
67 void unlockdevice(); 67 void unlockdevice();
68 68
69 bool setSecret(int,const char*,const char*); 69 bool setSecret(int,const char*,const char*);
70 bool removeSecret(int); 70 bool removeSecret(int);
71 void killPPPDaemon(); 71 void killPPPDaemon();
72 int pppdExitStatus(); 72 int pppdExitStatus();
73 bool execPPPDaemon(const QString & arguments); 73 bool execPPPDaemon(const QString & arguments);
74 int openResolv(int flags); 74 int openResolv(int flags);
75 bool setHostname(const QString & name); 75 bool setHostname(const QString & name);
76 76
77public: 77public:
78 enum Auth { PAP = 1, CHAP }; 78 enum Auth { PAP = 1, CHAP };
79 static Modem *modem; 79 static Modem *modem;
80 int lastStatus; 80 int lastStatus;
81 81
82signals: 82signals:
83 void charWaiting(unsigned char); 83 void charWaiting(unsigned char);
84 84
85private slots: 85private slots:
86 void startNotifier(); 86 void startNotifier();
87 void stopNotifier(); 87 void stopNotifier();
88 void readtty(int); 88 void readtty(int);
89 89
90private: 90private:
91 enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; 91 enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
92 enum { Original=0x100, New=0x200, Old=0x400 } Version; 92 enum { Original=0x100, New=0x200, Old=0x400 } Version;
93 93
94 const char* authFile(Auth method, int version = Original ); 94 const char* authFile(Auth method, int version = Original );
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();
97 int openLockfile(QString,int); 101 int openLockfile(QString,int);
98 102
99private: 103private:
100 QString device; 104 QString device;
101 QString lockfile; 105 QString lockfile;
102 int modemfd; 106 int modemfd;
107 int pppdPid;
108 int _pppdExitStatus;
103 QSocketNotifier *sn; 109 QSocketNotifier *sn;
104 bool data_mode; 110 bool data_mode;
105 QString errmsg; 111 QString errmsg;
106 struct termios initial_tty; 112 struct termios initial_tty;
107 struct termios tty; 113 struct termios tty;
108 bool modem_is_locked; 114 bool modem_is_locked;
109}; 115};
110 116
111#endif 117#endif
112 118
113 119
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
@@ -278,445 +278,445 @@ bool PPPData::automatic_redial() {
278 278
279void PPPData::set_automatic_redial(bool set) { 279void PPPData::set_automatic_redial(bool set) {
280 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); 280 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
281} 281}
282 282
283 283
284bool PPPData::get_iconify_on_connect() { 284bool PPPData::get_iconify_on_connect() {
285 return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); 285 return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
286} 286}
287 287
288 288
289void PPPData::set_iconify_on_connect(bool set) { 289void PPPData::set_iconify_on_connect(bool set) {
290 writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); 290 writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
291} 291}
292 292
293 293
294bool PPPData::get_dock_into_panel() { 294bool PPPData::get_dock_into_panel() {
295 return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); 295 return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
296} 296}
297 297
298 298
299void PPPData::set_dock_into_panel(bool set) { 299void PPPData::set_dock_into_panel(bool set) {
300 writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); 300 writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
301} 301}
302 302
303 303
304QString PPPData::pppdVersion() { 304QString PPPData::pppdVersion() {
305 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); 305 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
306} 306}
307 307
308bool PPPData::pppdVersionMin(int ver, int mod, int patch) { 308bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
309 // check if pppd version fulfills minimum requirement 309 // check if pppd version fulfills minimum requirement
310 return (pppdVer > ver 310 return (pppdVer > ver
311 || (pppdVer == ver && pppdMod > mod) 311 || (pppdVer == ver && pppdMod > mod)
312 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); 312 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
313} 313}
314 314
315int PPPData::pppdTimeout() { 315int PPPData::pppdTimeout() {
316 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); 316 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
317} 317}
318 318
319 319
320void PPPData::setpppdTimeout(int n) { 320void PPPData::setpppdTimeout(int n) {
321 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); 321 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
322} 322}
323 323
324 324
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}
328 328
329 329
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}
333 333
334 334
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}
338 338
339 339
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}
343 343
344 344
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=
348 // entry in kppprc. kppp did set the serial port to 57600 as default but 348 // entry in kppprc. kppp did set the serial port to 57600 as default but
349 // pppd wouldn't receive the speed via the command line. 349 // pppd wouldn't receive the speed via the command line.
350 if(s.toUInt() == 0) 350 if(s.toUInt() == 0)
351 s = "57600"; 351 s = "57600";
352 return s; 352 return s;
353} 353}
354 354
355 355
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}
359 359
360 360
361#if 0 361#if 0
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}
365 365
366 366
367int PPPData::UseCDLine() { 367int PPPData::UseCDLine() {
368 return readNumConfig(MODEM_GRP,USECDLINE_KEY,0); 368 return readNumConfig(modemGroup(),USECDLINE_KEY,0);
369} 369}
370#endif 370#endif
371 371
372const QString PPPData::modemEscapeStr() { 372const QString PPPData::modemEscapeStr() {
373 return readConfig(MODEM_GRP,ESCAPESTR_KEY,"+++"); 373 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
374} 374}
375 375
376 376
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}
380 380
381 381
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}
385 385
386 386
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}
390 390
391 391
392int PPPData::modemEscapeGuardTime() { 392int PPPData::modemEscapeGuardTime() {
393 return readNumConfig(MODEM_GRP,ESCAPEGUARDTIME_KEY,50); 393 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
394} 394}
395 395
396 396
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}
400 400
401 401
402bool PPPData::modemLockFile() { 402bool PPPData::modemLockFile() {
403 return readNumConfig(MODEM_GRP, LOCKFILE_KEY, 1); 403 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
404} 404}
405 405
406 406
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}
410 410
411 411
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}
415 415
416 416
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}
420 420
421 421
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}
425 425
426 426
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}
430 430
431 431
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}
435 435
436 436
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}
440 440
441 441
442// 442//
443//Advanced "Modem" dialog 443//Advanced "Modem" dialog
444// 444//
445// defaults: InitString=ATZ, InitString1="" etc. 445// defaults: InitString=ATZ, InitString1="" etc.
446const QString PPPData::modemInitStr(int i) { 446const QString PPPData::modemInitStr(int i) {
447 assert(i >= 0 && i < NumInitStrings); 447 assert(i >= 0 && i < NumInitStrings);
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}
453 453
454 454
455void PPPData::setModemInitStr(int i, const QString &n) { 455void PPPData::setModemInitStr(int i, const QString &n) {
456 assert(i >= 0 && i < NumInitStrings); 456 assert(i >= 0 && i < NumInitStrings);
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}
460 460
461 461
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}
465 465
466 466
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}
470 470
471 471
472int PPPData::modemPreInitDelay() { 472int PPPData::modemPreInitDelay() {
473 return readNumConfig(MODEM_GRP, PREINITDELAY_KEY, 50); 473 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50);
474} 474}
475 475
476 476
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}
480 480
481 481
482int PPPData::modemInitDelay() { 482int PPPData::modemInitDelay() {
483 return readNumConfig(MODEM_GRP, INITDELAY_KEY, 50); 483 return readNumConfig(modemGroup(), INITDELAY_KEY, 50);
484} 484}
485 485
486 486
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}
490 490
491QString PPPData::modemNoDialToneDetectionStr() { 491QString PPPData::modemNoDialToneDetectionStr() {
492 return readConfig(MODEM_GRP, NODTDETECT_KEY, "ATX3"); 492 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3");
493} 493}
494 494
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}
498 498
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}
502 502
503 503
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}
507 507
508 508
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}
512 512
513 513
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}
517 517
518 518
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}
522 522
523 523
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}
527 527
528 528
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}
532 532
533 533
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}
537 537
538 538
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}
542 542
543 543
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}
547 547
548 548
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}
552 552
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}
556 556
557 557
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}
561 561
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}
565 565
566 566
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}
570 570
571 571
572QString PPPData::volumeOff() { 572QString PPPData::volumeOff() {
573 return readConfig(MODEM_GRP, VOLUME_OFF, "M0L0"); 573 return readConfig(modemGroup(), VOLUME_OFF, "M0L0");
574} 574}
575 575
576 576
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}
580 580
581 581
582QString PPPData::volumeMedium() { 582QString PPPData::volumeMedium() {
583 return readConfig(MODEM_GRP, VOLUME_MEDIUM, "M1L1"); 583 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1");
584} 584}
585 585
586 586
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}
590 590
591 591
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")
595 tmp = "M1L3"; 595 tmp = "M1L3";
596 return tmp; 596 return tmp;
597} 597}
598 598
599 599
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}
603 603
604 604
605QString PPPData::volumeInitString() { 605QString PPPData::volumeInitString() {
606 QString s; 606 QString s;
607 607
608 switch(volume()) { 608 switch(volume()) {
609 case 0: 609 case 0:
610 s = volumeOff(); 610 s = volumeOff();
611 break; 611 break;
612 case 1: 612 case 1:
613 s = volumeMedium(); 613 s = volumeMedium();
614 break; 614 break;
615 case 2: 615 case 2:
616 s = volumeHigh(); 616 s = volumeHigh();
617 break; 617 break;
618 default: 618 default:
619 s = volumeMedium(); 619 s = volumeMedium();
620 } 620 }
621 621
622 return s; 622 return s;
623} 623}
624 624
625 625
626int PPPData::volume() { 626int PPPData::volume() {
627 return readNumConfig(MODEM_GRP, VOLUME_KEY, 1); 627 return readNumConfig(modemGroup(), VOLUME_KEY, 1);
628} 628}
629 629
630 630
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}
634 634
635int PPPData::waitForDialTone() { 635int PPPData::waitForDialTone() {
636 return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); 636 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
637} 637}
638 638
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}
642 642
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}
646 646
647 647
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}
651 651
652 652
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}
656 656
657 657
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}
661 661
662 662
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}
666 666
667 667
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}
671 671
672 672
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}
676 676
677 677
678// 678//
679// functions to set/return account information 679// functions to set/return account information
680// 680//
681 681
682//returns number of accounts 682//returns number of accounts
683int PPPData::count() const { 683int PPPData::count() const {
684 return highcount + 1; 684 return highcount + 1;
685} 685}
686 686
687 687
688bool PPPData::setAccount(const QString &aname) { 688bool PPPData::setAccount(const QString &aname) {
689 for(int i = 0; i <= highcount; i++) { 689 for(int i = 0; i <= highcount; i++) {
690 setAccountbyIndex(i); 690 setAccountbyIndex(i);
691 if(accname() == aname) { 691 if(accname() == aname) {
692 caccount = i; 692 caccount = i;
693 return true; 693 return true;
694 } 694 }
695 } 695 }
696 return false; 696 return false;
697} 697}
698 698
699 699
700bool PPPData::setAccountbyIndex(int i) { 700bool PPPData::setAccountbyIndex(int i) {
701 if(i >= 0 && i <= highcount) { 701 if(i >= 0 && i <= highcount) {
702 caccount = i; 702 caccount = i;
703 cgroup.sprintf("%s%i", ACCOUNT_GRP, i); 703 cgroup.sprintf("%s%i", ACCOUNT_GRP, i);
704 return true; 704 return true;
705 } 705 }
706 return false; 706 return false;
707} 707}
708 708
709 709
710bool PPPData::isUniqueAccname(const QString &n) { 710bool PPPData::isUniqueAccname(const QString &n) {
711 int current = caccount; 711 int current = caccount;
712 for(int i=0; i <= highcount; i++) { 712 for(int i=0; i <= highcount; i++) {
713 setAccountbyIndex(i); 713 setAccountbyIndex(i);
714 if(accname() == n && i != current) { 714 if(accname() == n && i != current) {
715 setAccountbyIndex(current); 715 setAccountbyIndex(current);
716 return false; 716 return false;
717 } 717 }
718 } 718 }
719 setAccountbyIndex(current); 719 setAccountbyIndex(current);
720 return true; 720 return true;
721} 721}
722 722
@@ -1164,71 +1164,75 @@ void PPPData::setpppdArgumentDefaults() {
1164// void PPPData::graphingOptions(bool &enable, 1164// void PPPData::graphingOptions(bool &enable,
1165 // QColor &bg, 1165 // QColor &bg,
1166 // QColor &text, 1166 // QColor &text,
1167 // QColor &in, 1167 // QColor &in,
1168 // QColor &out) 1168 // QColor &out)
1169// { 1169// {
1170// QColor c; 1170// QColor c;
1171 1171
1172// if(config) { 1172// if(config) {
1173// config->setGroup(GRAPH_GRP); 1173// config->setGroup(GRAPH_GRP);
1174// enable = config->readBoolEntry(GENABLED, true); 1174// enable = config->readBoolEntry(GENABLED, true);
1175// bg = Qt::white; 1175// bg = Qt::white;
1176// //bg = config->readColorEntry(GCOLOR_BG, &c); 1176// //bg = config->readColorEntry(GCOLOR_BG, &c);
1177// text = Qt::black; 1177// text = Qt::black;
1178// //text = config->readColorEntry(GCOLOR_TEXT, &c); 1178// //text = config->readColorEntry(GCOLOR_TEXT, &c);
1179// in = Qt::blue; 1179// in = Qt::blue;
1180// //in = config->readColorEntry(GCOLOR_IN, &c); 1180// //in = config->readColorEntry(GCOLOR_IN, &c);
1181// out = Qt::red; 1181// out = Qt::red;
1182// //out = config->readColorEntry(GCOLOR_OUT, &c); 1182// //out = config->readColorEntry(GCOLOR_OUT, &c);
1183// } 1183// }
1184// } 1184// }
1185 1185
1186 1186
1187// bool PPPData::graphingEnabled() { 1187// bool PPPData::graphingEnabled() {
1188// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); 1188// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
1189// } 1189// }
1190 1190
1191 1191
1192 1192
1193// 1193//
1194//functions to change/set the child pppd process info 1194//functions to change/set the child pppd process info
1195// 1195//
1196bool PPPData::pppdRunning() const { 1196bool PPPData::pppdRunning() const {
1197 return pppdisrunning; 1197 return pppdisrunning;
1198} 1198}
1199 1199
1200void PPPData::setpppdRunning(bool set) { 1200void PPPData::setpppdRunning(bool set) {
1201 pppdisrunning = set; 1201 pppdisrunning = set;
1202} 1202}
1203 1203
1204int PPPData::pppdError() const { 1204int PPPData::pppdError() const {
1205 return pppderror; 1205 return pppderror;
1206} 1206}
1207 1207
1208void PPPData::setpppdError(int err) { 1208void PPPData::setpppdError(int err) {
1209 pppderror = err; 1209 pppderror = err;
1210} 1210}
1211 1211
1212QString PPPData::modemGroup()
1213{
1214 return MODEM_GRP;
1215}
1212 1216
1213// // 1217// //
1214// // window position 1218// // window position
1215// // 1219// //
1216// void PPPData::winPosConWin(int& p_x, int& p_y) { 1220// void PPPData::winPosConWin(int& p_x, int& p_y) {
1217// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); 1221// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
1218// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); 1222// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
1219// } 1223// }
1220 1224
1221// void PPPData::setWinPosConWin(int p_x, int p_y) { 1225// void PPPData::setWinPosConWin(int p_x, int p_y) {
1222// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); 1226// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
1223// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); 1227// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
1224// } 1228// }
1225 1229
1226// void PPPData::winPosStatWin(int& p_x, int& p_y) { 1230// void PPPData::winPosStatWin(int& p_x, int& p_y) {
1227// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); 1231// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
1228// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); 1232// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
1229// } 1233// }
1230 1234
1231// void PPPData::setWinPosStatWin(int p_x, int p_y) { 1235// void PPPData::setWinPosStatWin(int p_x, int p_y) {
1232// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); 1236// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
1233// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); 1237// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
1234// } 1238// }
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
@@ -114,120 +114,121 @@ class Config;
114#define AUTH_KEY "Authentication" 114#define AUTH_KEY "Authentication"
115#define STORED_PASSWORD_KEY "Password" 115#define STORED_PASSWORD_KEY "Password"
116#define STORED_USERNAME_KEY "Username" 116#define STORED_USERNAME_KEY "Username"
117#define STORE_PASSWORD_KEY "StorePassword" 117#define STORE_PASSWORD_KEY "StorePassword"
118#define BEFORE_CONNECT_KEY "BeforeConnect" 118#define BEFORE_CONNECT_KEY "BeforeConnect"
119#define COMMAND_KEY "Command" 119#define COMMAND_KEY "Command"
120#define DISCONNECT_COMMAND_KEY "DisconnectCommand" 120#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
121#define BEFORE_DISCONNECT_KEY "BeforeDisconnect" 121#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
122#define IPADDR_KEY "IPAddr" 122#define IPADDR_KEY "IPAddr"
123#define SUBNETMASK_KEY "SubnetMask" 123#define SUBNETMASK_KEY "SubnetMask"
124#define ACCTENABLED_KEY "AccountingEnabled" 124#define ACCTENABLED_KEY "AccountingEnabled"
125#define VOLACCTENABLED_KEY "VolumeAccountingEnabled" 125#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
126#define ACCTFILE_KEY "AccountingFile" 126#define ACCTFILE_KEY "AccountingFile"
127#define AUTONAME_KEY "AutoName" 127#define AUTONAME_KEY "AutoName"
128#define GATEWAY_KEY "Gateway" 128#define GATEWAY_KEY "Gateway"
129#define DEFAULTROUTE_KEY "DefaultRoute" 129#define DEFAULTROUTE_KEY "DefaultRoute"
130#define DOMAIN_KEY "Domain" 130#define DOMAIN_KEY "Domain"
131#define DNS_KEY "DNS" 131#define DNS_KEY "DNS"
132#define AUTODNS_KEY "AutoDNS" 132#define AUTODNS_KEY "AutoDNS"
133#define EXDNSDISABLED_KEY "ExDNSDisabled" 133#define EXDNSDISABLED_KEY "ExDNSDisabled"
134#define SCRIPTCOM_KEY "ScriptCommands" 134#define SCRIPTCOM_KEY "ScriptCommands"
135#define SCRIPTARG_KEY "ScriptArguments" 135#define SCRIPTARG_KEY "ScriptArguments"
136#define PPPDARG_KEY "pppdArguments" 136#define PPPDARG_KEY "pppdArguments"
137#define PPP_DEBUG_OPTION "PPPDebug" 137#define PPP_DEBUG_OPTION "PPPDebug"
138#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" 138#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
139#define DOCKING_KEY "DockIntoPanel" 139#define DOCKING_KEY "DockIntoPanel"
140#define TOTALCOSTS_KEY "TotalCosts" 140#define TOTALCOSTS_KEY "TotalCosts"
141#define TOTALBYTES_KEY "TotalBytes" 141#define TOTALBYTES_KEY "TotalBytes"
142 142
143// graph colors 143// graph colors
144#define GENABLED "Enabled" 144#define GENABLED "Enabled"
145#define GCOLOR_BG "Background" 145#define GCOLOR_BG "Background"
146#define GCOLOR_TEXT "Text" 146#define GCOLOR_TEXT "Text"
147#define GCOLOR_IN "InBytes" 147#define GCOLOR_IN "InBytes"
148#define GCOLOR_OUT "OutBytes" 148#define GCOLOR_OUT "OutBytes"
149 149
150// pppd errors 150// pppd errors
151#define E_IF_TIMEOUT 1 151#define E_IF_TIMEOUT 1
152#define E_PPPD_DIED 2 152#define E_PPPD_DIED 2
153 153
154// window position 154// window position
155#define WINPOS_CONWIN_X "WindowPositionConWinX" 155#define WINPOS_CONWIN_X "WindowPositionConWinX"
156#define WINPOS_CONWIN_Y "WindowPositionConWinY" 156#define WINPOS_CONWIN_Y "WindowPositionConWinY"
157#define WINPOS_STATWIN_X "WindowPositionStatWinX" 157#define WINPOS_STATWIN_X "WindowPositionStatWinX"
158#define WINPOS_STATWIN_Y "WindowPositionStatWinY" 158#define WINPOS_STATWIN_Y "WindowPositionStatWinY"
159 159
160class PPPData { 160class 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
187 // functions to set/get general kppp info 188 // functions to set/get general kppp info
188 QString password() const; 189 QString password() const;
189 void setPassword(const QString &); 190 void setPassword(const QString &);
190 191
191 const QString defaultAccount(); 192 const QString defaultAccount();
192 void setDefaultAccount(const QString &); 193 void setDefaultAccount(const QString &);
193 194
194 void set_xserver_exit_disconnect(bool set); 195 void set_xserver_exit_disconnect(bool set);
195 bool get_xserver_exit_disconnect(); 196 bool get_xserver_exit_disconnect();
196 197
197 void setPPPDebug(bool set); 198 void setPPPDebug(bool set);
198 bool getPPPDebug(); 199 bool getPPPDebug();
199 200
200 void set_quit_on_disconnect(bool); 201 void set_quit_on_disconnect(bool);
201 bool quit_on_disconnect(); 202 bool quit_on_disconnect();
202 203
203 void set_show_clock_on_caption(bool set); 204 void set_show_clock_on_caption(bool set);
204 bool get_show_clock_on_caption(); 205 bool get_show_clock_on_caption();
205 206
206 void set_show_log_window(bool set); 207 void set_show_log_window(bool set);
207 bool get_show_log_window(); 208 bool get_show_log_window();
208 209
209 void set_automatic_redial(bool set); 210 void set_automatic_redial(bool set);
210 bool automatic_redial(); 211 bool automatic_redial();
211 212
212 void set_iconify_on_connect(bool set); 213 void set_iconify_on_connect(bool set);
213 bool get_iconify_on_connect(); 214 bool get_iconify_on_connect();
214 215
215 void set_dock_into_panel(bool set); 216 void set_dock_into_panel(bool set);
216 bool get_dock_into_panel(); 217 bool get_dock_into_panel();
217 218
218 const QString enter(); 219 const QString enter();
219 void setEnter(const QString &); 220 void setEnter(const QString &);
220 221
221 QString pppdVersion(); 222 QString pppdVersion();
222 bool pppdVersionMin(int ver, int mod, int patch); 223 bool pppdVersionMin(int ver, int mod, int patch);
223 224
224 int pppdTimeout(); 225 int pppdTimeout();
225 void setpppdTimeout(int); 226 void setpppdTimeout(int);
226 227
227 int busyWait(); 228 int busyWait();
228 void setbusyWait(int); 229 void setbusyWait(int);
229 230
230 bool modemLockFile(); 231 bool modemLockFile();
231 void setModemLockFile(bool set); 232 void setModemLockFile(bool set);
232 233
233 int modemEscapeGuardTime(); 234 int modemEscapeGuardTime();
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
@@ -1,121 +1,125 @@
1#include "pppconfig.h" 1#include "pppconfig.h"
2#include "pppmodule.h" 2#include "pppmodule.h"
3#include "pppdata.h" 3#include "pppdata.h"
4#include "kpppwidget.h" 4#include "kpppwidget.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6//#include "devices.h" 6//#include "devices.h"
7 7
8/** 8/**
9 * Constructor, find all of the possible interfaces 9 * Constructor, find all of the possible interfaces
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}
13 18
14/** 19/**
15 * Delete any interfaces that we own. 20 * Delete any interfaces that we own.
16 */ 21 */
17PPPModule::~PPPModule(){ 22PPPModule::~PPPModule(){
18 Interface *i; 23 Interface *i;
19 for ( i=list.first(); i != 0; i=list.next() ) 24 for ( i=list.first(); i != 0; i=list.next() )
20 delete i; 25 delete i;
21} 26}
22 27
23/** 28/**
24 * Change the current profile 29 * Change the current profile
25 */ 30 */
26void PPPModule::setProfile(const QString &newProfile){ 31void PPPModule::setProfile(const QString &newProfile){
27 profile = newProfile; 32 profile = newProfile;
28} 33}
29 34
30/** 35/**
31 * get the icon name for this device. 36 * get the icon name for this device.
32 * @param Interface* can be used in determining the icon. 37 * @param Interface* can be used in determining the icon.
33 * @return QString the icon name (minus .png, .gif etc) 38 * @return QString the icon name (minus .png, .gif etc)
34 */ 39 */
35QString PPPModule::getPixmapName(Interface* ){ 40QString PPPModule::getPixmapName(Interface* ){
36 return "ppp"; 41 return "ppp";
37} 42}
38 43
39/** 44/**
40 * Check to see if the interface i is owned by this module. 45 * Check to see if the interface i is owned by this module.
41 * @param Interface* interface to check against 46 * @param Interface* interface to check against
42 * @return bool true if i is owned by this module, false otherwise. 47 * @return bool true if i is owned by this module, false otherwise.
43 */ 48 */
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}
52 52
53/** 53/**
54 * Create, and return the WLANConfigure Module 54 * Create, and return the WLANConfigure Module
55 * @return QWidget* pointer to this modules configure. 55 * @return QWidget* pointer to this modules configure.
56 */ 56 */
57QWidget *PPPModule::configure(Interface *i){ 57QWidget *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;
62} 62}
63 63
64/** 64/**
65 * Create, and return the Information Module 65 * Create, and return the Information Module
66 * @return QWidget* pointer to this modules info. 66 * @return QWidget* pointer to this modules info.
67 */ 67 */
68QWidget *PPPModule::information(Interface *i){ 68QWidget *PPPModule::information(Interface *i){
69 // We don't have any advanced pppd information widget yet :-D 69 // We don't have any advanced pppd information widget yet :-D
70 // TODO ^ 70 // TODO ^
71 qDebug("return PPPModule::information"); 71 qDebug("return PPPModule::information");
72 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); 72 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
73 return information; 73 return information;
74} 74}
75 75
76/** 76/**
77 * Get all active (up or down) interfaces 77 * Get all active (up or down) interfaces
78 * @return QList<Interface> A list of interfaces that exsist that havn't 78 * @return QList<Interface> A list of interfaces that exsist that havn't
79 * been called by isOwner() 79 * been called by isOwner()
80 */ 80 */
81QList<Interface> PPPModule::getInterfaces(){ 81QList<Interface> PPPModule::getInterfaces(){
82 // List all of the files in the peer directory 82 // List all of the files in the peer directory
83 return list; 83 return list;
84} 84}
85 85
86/** 86/**
87 * Attempt to add a new interface as defined by name 87 * Attempt to add a new interface as defined by name
88 * @param name the name of the type of interface that should be created given 88 * @param name the name of the type of interface that should be created given
89 * by possibleNewInterfaces(); 89 * by possibleNewInterfaces();
90 * @return Interface* NULL if it was unable to be created. 90 * @return Interface* NULL if it was unable to be created.
91 */ 91 */
92Interface *PPPModule::addNewInterface(const QString &newInterface){ 92Interface *PPPModule::addNewInterface(const QString &newInterface){
93 93
94 qDebug("try to add iface %s",newInterface.latin1()); 94 qDebug("try to add iface %s",newInterface.latin1());
95 95
96 PPPConfigWidget imp(0, "PPPConfigImp", true); 96 PPPConfigWidget imp(0, "PPPConfigImp", true);
97 imp.showMaximized(); 97 imp.showMaximized();
98 if(imp.exec() == QDialog::Accepted ){ 98 if(imp.exec() == QDialog::Accepted ){
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 }
103 return NULL; 107 return NULL;
104} 108}
105 109
106/** 110/**
107 * Attempts to remove the interface, doesn't delete i 111 * Attempts to remove the interface, doesn't delete i
108 * @return bool true if successfull, false otherwise. 112 * @return bool true if successfull, false otherwise.
109 */ 113 */
110bool PPPModule::remove(Interface*){ 114bool PPPModule::remove(Interface*){
111 // Can't remove a hardware device, you can stop it though. 115 // Can't remove a hardware device, you can stop it though.
112 return false; 116 return false;
113} 117}
114 118
115void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 119void 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}
120 124
121 125