Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 229 |
1 files changed, 117 insertions, 112 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index f2386fc..646facd 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -17,144 +17,148 @@ | |||
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 "pppdata.h" | 27 | #include "pppdata.h" |
28 | #include "runtests.h" | 28 | #include "runtests.h" |
29 | #include "devices.h" | 29 | #include "devices.h" |
30 | //#include <klocale.h> | 30 | //#include <klocale.h> |
31 | #define i18n QObject::tr | 31 | #define i18n QObject::tr |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | // #include <klocale.h> | 35 | // #include <klocale.h> |
36 | // #include <kconfig.h> | 36 | // #include <kconfig.h> |
37 | // #include <kmessagebox.h> | 37 | // #include <kmessagebox.h> |
38 | // #include <kapplication.h> | 38 | // #include <kapplication.h> |
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | 40 | ||
41 | PPPData gpppdata; | 41 | PPPData *PPPData::_data = 0; |
42 | Config *PPPData::config = 0; | ||
42 | 43 | ||
44 | PPPData* PPPData::data() | ||
45 | { | ||
46 | if (!_data){ | ||
47 | qDebug("PPPData::data() creates new Instance"); | ||
48 | _data = new PPPData(); | ||
49 | } | ||
50 | if (!_data->config){ | ||
51 | qDebug("PPPData::data() opens conffile"); | ||
52 | _data->open(); | ||
53 | } | ||
54 | return _data; | ||
55 | } | ||
43 | 56 | ||
44 | PPPData::PPPData() | 57 | PPPData::PPPData() |
45 | : config(0L), | 58 | : //config(0L), |
46 | highcount(-1), // start out with no entries | 59 | highcount(-1), // start out with no entries |
47 | caccount(-1), // set the current account index also | 60 | caccount(-1), // set the current account index also |
48 | suidprocessid(-1), // process ID of setuid child | 61 | suidprocessid(-1), // process ID of setuid child |
49 | pppdisrunning(false), | 62 | pppdisrunning(false), |
50 | pppderror(0) | 63 | pppderror(0) |
51 | { | 64 | { |
52 | } | 65 | } |
53 | 66 | ||
54 | 67 | ||
55 | // | 68 | // |
56 | // open configuration file | 69 | // open configuration file |
57 | // | 70 | // |
58 | bool PPPData::open() { | 71 | bool PPPData::open() { |
59 | 72 | qDebug("opening configfile NetworkSetupPPP"); | |
60 | config = new Config("NetworkSetup"); | 73 | if (config) return true; |
61 | /* | 74 | config = new Config("NetworkSetupPPP"); |
62 | config = kapp->config(); | ||
63 | |||
64 | if (config->getConfigState() == KConfig::NoAccess) { | ||
65 | KMessageBox::error(0L, | ||
66 | i18n("The application-specific config file could not " | ||
67 | "be opened in either read-write or read-only mode.\n" | ||
68 | "The superuser might have to change its ownership " | ||
69 | "by issuing the following command in your home directory:\n" | ||
70 | "chown {YourUsername} .kde/share/config/kppprc"), | ||
71 | kapp->name()); | ||
72 | return false; | ||
73 | } | ||
74 | |||
75 | // don't expand shell variables | ||
76 | config->setDollarExpansion(false); | ||
77 | */ | ||
78 | 75 | ||
79 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 76 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
80 | 77 | ||
81 | if (highcount > MAX_ACCOUNTS) | 78 | if (highcount > MAX_ACCOUNTS) |
82 | highcount = MAX_ACCOUNTS; | 79 | highcount = MAX_ACCOUNTS; |
83 | 80 | ||
84 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 81 | if(highcount >= 0 && defaultAccount().isEmpty()) { |
85 | setAccountbyIndex(0); | 82 | setAccountbyIndex(0); |
86 | setDefaultAccount(accname()); | 83 | setDefaultAccount(accname()); |
87 | } else if(!setAccount(defaultAccount())) | 84 | } else if(!setAccount(defaultAccount())) |
88 | setDefaultAccount(accname()); | 85 | setDefaultAccount(accname()); |
89 | 86 | ||
90 | // start out with internal debugging disabled | 87 | // start out with internal debugging disabled |
91 | // the user is still free to specify `debug' on his own | 88 | // the user is still free to specify `debug' on his own |
92 | setPPPDebug(false); | 89 | setPPPDebug(false); |
93 | 90 | ||
94 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 91 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
95 | 92 | ||
96 | return true; | 93 | return true; |
97 | } | 94 | } |
98 | 95 | ||
99 | 96 | ||
100 | // | 97 | // |
101 | // save configuration | 98 | // save configuration |
102 | // | 99 | // |
103 | void PPPData::save() { | 100 | void PPPData::save() { |
104 | 101 | ||
105 | if (config) { | 102 | if (config) { |
106 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 103 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
107 | // config->sync(); | 104 | delete config; |
105 | config = 0; | ||
106 | qDebug("worte confi NetworkSetupPPP"); | ||
107 | } | ||
108 | if (_data){ | ||
109 | delete _data; | ||
110 | _data = 0; | ||
108 | } | 111 | } |
109 | 112 | ||
110 | } | 113 | } |
111 | 114 | ||
112 | 115 | ||
113 | // | 116 | // |
114 | // cancel changes | 117 | // cancel changes |
115 | // | 118 | // |
116 | void PPPData::cancel() { | 119 | void PPPData::cancel() { |
117 | 120 | ||
118 | // if (config) { | 121 | // if (config) { |
119 | // config->rollback(); | 122 | // config->rollback(); |
120 | // config->reparseConfiguration(); | 123 | // config->reparseConfiguration(); |
121 | // } | 124 | // } |
122 | 125 | ||
123 | } | 126 | } |
124 | 127 | ||
125 | 128 | ||
126 | // currently differentiates between READWRITE and NONE only | 129 | // // currently differentiates between READWRITE and NONE only |
127 | int PPPData::access() const { | 130 | // int PPPData::access() const { |
128 | 131 | ||
129 | return 0;//config->getConfigState(); | 132 | // return 1;//config->getConfigState(); |
130 | } | 133 | // } |
131 | 134 | ||
132 | 135 | ||
133 | // functions to read/write date to configuration file | 136 | // functions to read/write date to configuration file |
134 | QString PPPData::readConfig(const QString &group, const QString &key, | 137 | QString PPPData::readConfig(const QString &group, const QString &key, |
135 | const QString &defvalue = "") | 138 | const QString &defvalue = "") |
136 | { | 139 | { |
140 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | ||
137 | if (config) { | 141 | if (config) { |
138 | config->setGroup(group); | 142 | config->setGroup(group); |
139 | return config->readEntry(key, defvalue); | 143 | return config->readEntry(key, defvalue); |
140 | } else | 144 | } else |
141 | return defvalue; | 145 | return defvalue; |
142 | } | 146 | } |
143 | 147 | ||
144 | 148 | ||
145 | int PPPData::readNumConfig(const QString &group, const QString &key, | 149 | int PPPData::readNumConfig(const QString &group, const QString &key, |
146 | int defvalue) { | 150 | int defvalue) { |
147 | if (config) { | 151 | if (config) { |
148 | config->setGroup(group); | 152 | config->setGroup(group); |
149 | return config->readNumEntry(key, defvalue); | 153 | return config->readNumEntry(key, defvalue); |
150 | } else | 154 | } else |
151 | return defvalue; | 155 | return defvalue; |
152 | 156 | ||
153 | } | 157 | } |
154 | 158 | ||
155 | 159 | ||
156 | bool PPPData::readListConfig(const QString &group, const QString &key, | 160 | bool PPPData::readListConfig(const QString &group, const QString &key, |
157 | QStringList &list, char sep) { | 161 | QStringList &list, char sep) { |
158 | list.clear(); | 162 | list.clear(); |
159 | if (config) { | 163 | if (config) { |
160 | config->setGroup(group); | 164 | config->setGroup(group); |
@@ -697,160 +701,161 @@ bool PPPData::setAccountbyIndex(int i) { | |||
697 | if(i >= 0 && i <= highcount) { | 701 | if(i >= 0 && i <= highcount) { |
698 | caccount = i; | 702 | caccount = i; |
699 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 703 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
700 | return true; | 704 | return true; |
701 | } | 705 | } |
702 | return false; | 706 | return false; |
703 | } | 707 | } |
704 | 708 | ||
705 | 709 | ||
706 | bool PPPData::isUniqueAccname(const QString &n) { | 710 | bool PPPData::isUniqueAccname(const QString &n) { |
707 | int current = caccount; | 711 | int current = caccount; |
708 | for(int i=0; i <= highcount; i++) { | 712 | for(int i=0; i <= highcount; i++) { |
709 | setAccountbyIndex(i); | 713 | setAccountbyIndex(i); |
710 | if(accname() == n && i != current) { | 714 | if(accname() == n && i != current) { |
711 | setAccountbyIndex(current); | 715 | setAccountbyIndex(current); |
712 | return false; | 716 | return false; |
713 | } | 717 | } |
714 | } | 718 | } |
715 | setAccountbyIndex(current); | 719 | setAccountbyIndex(current); |
716 | return true; | 720 | return true; |
717 | } | 721 | } |
718 | 722 | ||
719 | 723 | ||
720 | bool PPPData::deleteAccount() { | 724 | bool PPPData::deleteAccount() { |
721 | if(caccount < 0) | 725 | //FIXME: |
722 | return false; | 726 | // if(caccount < 0) |
727 | return false; | ||
723 | 728 | ||
724 | // QMap <QString, QString> map; | 729 | // QMap <QString, QString> map; |
725 | // QMap <QString, QString>::Iterator it; | 730 | // QMap <QString, QString>::Iterator it; |
726 | 731 | ||
727 | // set all entries of the current account to "" | 732 | // // set all entries of the current account to "" |
728 | // tille: do not handle the accounts here... (?) | ||
729 | // map = config->entryMap(cgroup); | 733 | // map = config->entryMap(cgroup); |
730 | // it = map.begin(); | 734 | // it = map.begin(); |
731 | // while (it != map.end()) { | 735 | // while (it != map.end()) { |
732 | // config->writeEntry(it.key(), ""); | 736 | // config->writeEntry(it.key(), ""); |
733 | // it++; | 737 | // it++; |
734 | // } | 738 | // } |
735 | 739 | ||
736 | // // shift the succeeding accounts | 740 | // // shift the succeeding accounts |
737 | // for(int i = caccount+1; i <= highcount; i++) { | 741 | // for(int i = caccount+1; i <= highcount; i++) { |
738 | // setAccountbyIndex(i); | 742 | // setAccountbyIndex(i); |
739 | // map = config->entryMap(cgroup); | 743 | // map = config->entryMap(cgroup); |
740 | // it = map.begin(); | 744 | // it = map.begin(); |
741 | // setAccountbyIndex(i-1); | 745 | // setAccountbyIndex(i-1); |
742 | // config->setGroup(cgroup); | 746 | // config->setGroup(cgroup); |
743 | // while (it != map.end()) { | 747 | // while (it != map.end()) { |
744 | // config->writeEntry(it.key(), *it); | 748 | // config->writeEntry(it.key(), *it); |
745 | // it++; | 749 | // it++; |
746 | // } | 750 | // } |
747 | // } | 751 | // } |
748 | 752 | ||
749 | // // make sure the top account is cleared | 753 | // // make sure the top account is cleared |
750 | // setAccountbyIndex(highcount); | 754 | // setAccountbyIndex(highcount); |
751 | // map = config->entryMap(cgroup); | 755 | // map = config->entryMap(cgroup); |
752 | // it = map.begin(); | 756 | // it = map.begin(); |
753 | // config->setGroup(cgroup); | 757 | // config->setGroup(cgroup); |
754 | // while (it.key() != QString::null) { | 758 | // while (it.key() != QString::null) { |
755 | // config->writeEntry(it.key(), ""); | 759 | // config->writeEntry(it.key(), ""); |
756 | // it++; | 760 | // it++; |
757 | // } | 761 | // } |
758 | 762 | ||
759 | highcount--; | 763 | // highcount--; |
760 | if(caccount > highcount) | 764 | // if(caccount > highcount) |
761 | caccount = highcount; | 765 | // caccount = highcount; |
762 | 766 | ||
763 | setAccountbyIndex(caccount); | 767 | // setAccountbyIndex(caccount); |
764 | 768 | ||
765 | return true; | 769 | // return true; |
766 | } | 770 | } |
767 | 771 | ||
768 | 772 | ||
769 | bool PPPData::deleteAccount(const QString &aname) { | 773 | bool PPPData::deleteAccount(const QString &aname) { |
770 | if(!setAccount(aname)) | 774 | if(!setAccount(aname)) |
771 | return false; | 775 | return false; |
772 | 776 | ||
773 | deleteAccount(); | 777 | deleteAccount(); |
774 | 778 | ||
775 | return true; | 779 | return true; |
776 | } | 780 | } |
777 | 781 | ||
778 | 782 | ||
779 | int PPPData::newaccount() { | 783 | int PPPData::newaccount() { |
780 | 784 | ||
781 | if(!config || highcount >= MAX_ACCOUNTS) | 785 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
782 | return -1; | 786 | if(!config) open(); |
787 | if (highcount >= MAX_ACCOUNTS) return -1; | ||
783 | 788 | ||
784 | highcount++; | 789 | highcount++; |
785 | setAccountbyIndex(highcount); | 790 | setAccountbyIndex(highcount); |
786 | 791 | ||
787 | setpppdArgumentDefaults(); | 792 | setpppdArgumentDefaults(); |
788 | 793 | qDebug("PPPData::newaccount -> %i",caccount); | |
789 | return caccount; | 794 | return caccount; |
790 | } | 795 | } |
791 | 796 | ||
792 | int PPPData::copyaccount(int i) { | 797 | int PPPData::copyaccount(int i) { |
793 | 798 | ||
794 | if(highcount >= MAX_ACCOUNTS) | 799 | // if(highcount >= MAX_ACCOUNTS) |
795 | return -1; | 800 | return -1; |
796 | 801 | ||
797 | setAccountbyIndex(i); | 802 | // setAccountbyIndex(i); |
798 | 803 | ||
799 | // QMap <QString, QString> map = config->entryMap(cgroup); | 804 | // QMap <QString, QString> map = config->entryMap(cgroup); |
800 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 805 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
801 | 806 | ||
802 | QString newname = i18n("%1_copy").arg(accname()); | 807 | // QString newname = i18n("%1_copy").arg(accname()); |
803 | 808 | ||
804 | newaccount(); | 809 | // newaccount(); |
805 | 810 | ||
806 | // while (it != map.end()) { | 811 | // while (it != map.end()) { |
807 | // config->writeEntry(it.key(), *it); | 812 | // config->writeEntry(it.key(), *it); |
808 | // it++; | 813 | // it++; |
809 | // } | 814 | // } |
810 | 815 | ||
811 | setAccname(newname); | 816 | // setAccname(newname); |
812 | 817 | ||
813 | return caccount; | 818 | // return caccount; |
814 | } | 819 | } |
815 | 820 | ||
816 | 821 | ||
817 | const QString PPPData::accname() { | 822 | const QString PPPData::accname() { |
818 | return readConfig(cgroup, NAME_KEY); | 823 | return readConfig(cgroup, NAME_KEY); |
819 | } | 824 | } |
820 | 825 | ||
821 | void PPPData::setAccname(const QString &n) { | 826 | void PPPData::setAccname(const QString &n) { |
822 | if(!cgroup.isNull()) { | 827 | if(!cgroup.isNull()) { |
823 | // are we manipulating the default account's name ? then change it, too. | 828 | // are we manipulating the default account's name ? then change it, too. |
824 | bool def = accname() == defaultAccount(); | 829 | bool def = accname() == defaultAccount(); |
825 | writeConfig(cgroup, NAME_KEY, n); | 830 | writeConfig(cgroup, NAME_KEY, n); |
826 | if (def) | 831 | if (def) |
827 | setDefaultAccount(n); | 832 | setDefaultAccount(n); |
828 | } | 833 | } |
829 | } | 834 | } |
830 | 835 | ||
831 | 836 | ||
832 | #define SEPARATOR_CHAR ':' | 837 | #define SEPARATOR_CHAR '&' |
833 | QStringList &PPPData::phonenumbers() { | 838 | QStringList &PPPData::phonenumbers() { |
834 | 839 | ||
835 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 840 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
836 | return phonelist; | 841 | return phonelist; |
837 | 842 | ||
838 | } | 843 | } |
839 | 844 | ||
840 | 845 | ||
841 | const QString PPPData::phonenumber() { | 846 | const QString PPPData::phonenumber() { |
842 | return readConfig(cgroup, PHONENUMBER_KEY); | 847 | return readConfig(cgroup, PHONENUMBER_KEY); |
843 | } | 848 | } |
844 | 849 | ||
845 | 850 | ||
846 | void PPPData::setPhonenumber(const QString &n) { | 851 | void PPPData::setPhonenumber(const QString &n) { |
847 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 852 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
848 | } | 853 | } |
849 | 854 | ||
850 | 855 | ||
851 | const QString PPPData::dialPrefix() { | 856 | const QString PPPData::dialPrefix() { |
852 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 857 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
853 | } | 858 | } |
854 | 859 | ||
855 | 860 | ||
856 | void PPPData::setDialPrefix(const QString &s) { | 861 | void PPPData::setDialPrefix(const QString &s) { |
@@ -990,49 +995,49 @@ void PPPData::setVolAcctEnabled(int set) { | |||
990 | 995 | ||
991 | const QString PPPData::gateway() { | 996 | const QString PPPData::gateway() { |
992 | return readConfig(cgroup, GATEWAY_KEY); | 997 | return readConfig(cgroup, GATEWAY_KEY); |
993 | } | 998 | } |
994 | 999 | ||
995 | 1000 | ||
996 | void PPPData::setGateway(const QString &n ) { | 1001 | void PPPData::setGateway(const QString &n ) { |
997 | writeConfig(cgroup, GATEWAY_KEY, n); | 1002 | writeConfig(cgroup, GATEWAY_KEY, n); |
998 | } | 1003 | } |
999 | 1004 | ||
1000 | 1005 | ||
1001 | bool PPPData::defaultroute() { | 1006 | bool PPPData::defaultroute() { |
1002 | // default route is by default 'on'. | 1007 | // default route is by default 'on'. |
1003 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); | 1008 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); |
1004 | } | 1009 | } |
1005 | 1010 | ||
1006 | 1011 | ||
1007 | void PPPData::setDefaultroute(bool set) { | 1012 | void PPPData::setDefaultroute(bool set) { |
1008 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); | 1013 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); |
1009 | } | 1014 | } |
1010 | 1015 | ||
1011 | 1016 | ||
1012 | bool PPPData::autoDNS() { | 1017 | bool PPPData::autoDNS() { |
1013 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); | 1018 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); |
1014 | return (set && gpppdata.pppdVersionMin(2, 3, 7)); | 1019 | return (set && PPPData::data()->pppdVersionMin(2, 3, 7)); |
1015 | } | 1020 | } |
1016 | 1021 | ||
1017 | 1022 | ||
1018 | void PPPData::setAutoDNS(bool set) { | 1023 | void PPPData::setAutoDNS(bool set) { |
1019 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | 1024 | writeConfig(cgroup, AUTODNS_KEY, (int) set); |
1020 | } | 1025 | } |
1021 | 1026 | ||
1022 | 1027 | ||
1023 | void PPPData::setExDNSDisabled(bool set) { | 1028 | void PPPData::setExDNSDisabled(bool set) { |
1024 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | 1029 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); |
1025 | } | 1030 | } |
1026 | 1031 | ||
1027 | 1032 | ||
1028 | bool PPPData::exDNSDisabled() { | 1033 | bool PPPData::exDNSDisabled() { |
1029 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | 1034 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); |
1030 | } | 1035 | } |
1031 | 1036 | ||
1032 | 1037 | ||
1033 | QStringList &PPPData::dns() { | 1038 | QStringList &PPPData::dns() { |
1034 | static QStringList dnslist; | 1039 | static QStringList dnslist; |
1035 | 1040 | ||
1036 | readListConfig(cgroup, DNS_KEY, dnslist); | 1041 | readListConfig(cgroup, DNS_KEY, dnslist); |
1037 | while(dnslist.count() > MAX_DNS_ENTRIES) | 1042 | while(dnslist.count() > MAX_DNS_ENTRIES) |
1038 | dnslist.remove(dnslist.last()); | 1043 | dnslist.remove(dnslist.last()); |
@@ -1118,112 +1123,112 @@ void PPPData::setTotalBytes(int n) { | |||
1118 | 1123 | ||
1119 | 1124 | ||
1120 | QStringList &PPPData::pppdArgument() { | 1125 | QStringList &PPPData::pppdArgument() { |
1121 | static QStringList arglist; | 1126 | static QStringList arglist; |
1122 | 1127 | ||
1123 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1128 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1124 | arglist.remove(arglist.last()); | 1129 | arglist.remove(arglist.last()); |
1125 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1130 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1126 | 1131 | ||
1127 | return arglist; | 1132 | return arglist; |
1128 | } | 1133 | } |
1129 | 1134 | ||
1130 | 1135 | ||
1131 | void PPPData::setpppdArgument(QStringList &args) { | 1136 | void PPPData::setpppdArgument(QStringList &args) { |
1132 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1137 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1133 | } | 1138 | } |
1134 | 1139 | ||
1135 | 1140 | ||
1136 | void PPPData::setpppdArgumentDefaults() { | 1141 | void PPPData::setpppdArgumentDefaults() { |
1137 | QStringList arg; | 1142 | QStringList arg; |
1138 | setpppdArgument(arg); | 1143 | setpppdArgument(arg); |
1139 | } | 1144 | } |
1140 | 1145 | ||
1141 | 1146 | ||
1142 | // graphing widget | 1147 | // // graphing widget |
1143 | void PPPData::setGraphingOptions(bool enable, | 1148 | // void PPPData::setGraphingOptions(bool enable, |
1144 | QColor bg, | 1149 | // QColor bg, |
1145 | QColor text, | 1150 | // QColor text, |
1146 | QColor in, | 1151 | // QColor in, |
1147 | QColor out) | 1152 | // QColor out) |
1148 | { | 1153 | // { |
1149 | if(config) { | 1154 | // if(config) { |
1150 | config->setGroup(GRAPH_GRP); | 1155 | // config->setGroup(GRAPH_GRP); |
1151 | config->writeEntry(GENABLED, enable); | 1156 | // config->writeEntry(GENABLED, enable); |
1152 | // config->writeEntry(GCOLOR_BG, bg); | 1157 | // // config->writeEntry(GCOLOR_BG, bg); |
1153 | // config->writeEntry(GCOLOR_TEXT, text); | 1158 | // // config->writeEntry(GCOLOR_TEXT, text); |
1154 | // config->writeEntry(GCOLOR_IN, in); | 1159 | // // config->writeEntry(GCOLOR_IN, in); |
1155 | // config->writeEntry(GCOLOR_OUT, out); | 1160 | // // config->writeEntry(GCOLOR_OUT, out); |
1156 | } | 1161 | // } |
1157 | } | 1162 | // } |
1158 | 1163 | ||
1159 | void PPPData::graphingOptions(bool &enable, | 1164 | // void PPPData::graphingOptions(bool &enable, |
1160 | QColor &bg, | 1165 | // QColor &bg, |
1161 | QColor &text, | 1166 | // QColor &text, |
1162 | QColor &in, | 1167 | // QColor &in, |
1163 | QColor &out) | 1168 | // QColor &out) |
1164 | { | 1169 | // { |
1165 | QColor c; | 1170 | // QColor c; |
1166 | 1171 | ||
1167 | if(config) { | 1172 | // if(config) { |
1168 | config->setGroup(GRAPH_GRP); | 1173 | // config->setGroup(GRAPH_GRP); |
1169 | enable = config->readBoolEntry(GENABLED, true); | 1174 | // enable = config->readBoolEntry(GENABLED, true); |
1170 | bg = Qt::white; | 1175 | // bg = Qt::white; |
1171 | //bg = config->readColorEntry(GCOLOR_BG, &c); | 1176 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1172 | text = Qt::black; | 1177 | // text = Qt::black; |
1173 | //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1178 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1174 | in = Qt::blue; | 1179 | // in = Qt::blue; |
1175 | //in = config->readColorEntry(GCOLOR_IN, &c); | 1180 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1176 | out = Qt::red; | 1181 | // out = Qt::red; |
1177 | //out = config->readColorEntry(GCOLOR_OUT, &c); | 1182 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1178 | } | 1183 | // } |
1179 | } | 1184 | // } |
1180 | 1185 | ||
1181 | 1186 | ||
1182 | bool PPPData::graphingEnabled() { | 1187 | // bool PPPData::graphingEnabled() { |
1183 | return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1188 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1184 | } | 1189 | // } |
1185 | 1190 | ||
1186 | 1191 | ||
1187 | 1192 | ||
1188 | // | 1193 | // |
1189 | //functions to change/set the child pppd process info | 1194 | //functions to change/set the child pppd process info |
1190 | // | 1195 | // |
1191 | bool PPPData::pppdRunning() const { | 1196 | bool PPPData::pppdRunning() const { |
1192 | return pppdisrunning; | 1197 | return pppdisrunning; |
1193 | } | 1198 | } |
1194 | 1199 | ||
1195 | void PPPData::setpppdRunning(bool set) { | 1200 | void PPPData::setpppdRunning(bool set) { |
1196 | pppdisrunning = set; | 1201 | pppdisrunning = set; |
1197 | } | 1202 | } |
1198 | 1203 | ||
1199 | int PPPData::pppdError() const { | 1204 | int PPPData::pppdError() const { |
1200 | return pppderror; | 1205 | return pppderror; |
1201 | } | 1206 | } |
1202 | 1207 | ||
1203 | void PPPData::setpppdError(int err) { | 1208 | void PPPData::setpppdError(int err) { |
1204 | pppderror = err; | 1209 | pppderror = err; |
1205 | } | 1210 | } |
1206 | 1211 | ||
1207 | 1212 | ||
1208 | // | 1213 | // // |
1209 | // window position | 1214 | // // window position |
1210 | // | 1215 | // // |
1211 | void PPPData::winPosConWin(int& p_x, int& p_y) { | 1216 | // void PPPData::winPosConWin(int& p_x, int& p_y) { |
1212 | p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); | 1217 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); |
1213 | p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); | 1218 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); |
1214 | } | 1219 | // } |
1215 | 1220 | ||
1216 | void PPPData::setWinPosConWin(int p_x, int p_y) { | 1221 | // void PPPData::setWinPosConWin(int p_x, int p_y) { |
1217 | writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); | 1222 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); |
1218 | writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); | 1223 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); |
1219 | } | 1224 | // } |
1220 | 1225 | ||
1221 | void PPPData::winPosStatWin(int& p_x, int& p_y) { | 1226 | // void PPPData::winPosStatWin(int& p_x, int& p_y) { |
1222 | p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); | 1227 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); |
1223 | p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); | 1228 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); |
1224 | } | 1229 | // } |
1225 | 1230 | ||
1226 | void PPPData::setWinPosStatWin(int p_x, int p_y) { | 1231 | // void PPPData::setWinPosStatWin(int p_x, int p_y) { |
1227 | writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); | 1232 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); |
1228 | writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); | 1233 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); |
1229 | } | 1234 | // } |