-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 8f066ff..8f45e54 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -1,999 +1,999 @@ | |||
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 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
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 "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 | #define SEPARATOR -sseepp- | 41 | #define SEPARATOR -sseepp- |
42 | #define SEP QString("%1SEPARATOR%1") | 42 | #define SEP QString("%1SEPARATOR%1") |
43 | 43 | ||
44 | PPPData::PPPData() | 44 | PPPData::PPPData() |
45 | : modemDeviceGroup(-1), | 45 | : modemDeviceGroup(-1), |
46 | passwd(""), | 46 | passwd(""), |
47 | highcount(-1), // start out with no entries | 47 | highcount(-1), // start out with no entries |
48 | caccount(-1), // set the current account index also | 48 | caccount(-1), // set the current account index also |
49 | suidprocessid(-1), // process ID of setuid child | 49 | suidprocessid(-1), // process ID of setuid child |
50 | pppdisrunning(false), | 50 | pppdisrunning(false), |
51 | pppderror(0) | 51 | pppderror(0) |
52 | { | 52 | { |
53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
54 | 54 | ||
55 | if (highcount > MAX_ACCOUNTS) | 55 | if (highcount > MAX_ACCOUNTS) |
56 | highcount = MAX_ACCOUNTS; | 56 | highcount = MAX_ACCOUNTS; |
57 | 57 | ||
58 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 58 | if(highcount >= 0 && defaultAccount().isEmpty()) { |
59 | setAccountbyIndex(0); | 59 | setAccountbyIndex(0); |
60 | setDefaultAccount(accname()); | 60 | setDefaultAccount(accname()); |
61 | } else if(!setAccount(defaultAccount())) | 61 | } else if(!setAccount(defaultAccount())) |
62 | setDefaultAccount(accname()); | 62 | setDefaultAccount(accname()); |
63 | 63 | ||
64 | // start out with internal debugging disabled | 64 | // start out with internal debugging disabled |
65 | // the user is still free to specify `debug' on his own | 65 | // the user is still free to specify `debug' on his own |
66 | setPPPDebug(false); | 66 | setPPPDebug(false); |
67 | 67 | ||
68 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 68 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | Config PPPData::config() | 72 | Config PPPData::config() |
73 | { | 73 | { |
74 | return Config("NetworkSetupPPP"); | 74 | return Config("NetworkSetupPPP"); |
75 | } | 75 | } |
76 | 76 | ||
77 | // | 77 | // |
78 | // save configuration | 78 | // save configuration |
79 | // | 79 | // |
80 | void PPPData::save() | 80 | void PPPData::save() |
81 | { | 81 | { |
82 | qDebug("PPPData saving data"); | 82 | qDebug("PPPData saving data"); |
83 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 83 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
84 | QString key; | 84 | QString key; |
85 | QStringList keys; | 85 | QStringList keys; |
86 | Config cfg = config(); | 86 | Config cfg = config(); |
87 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 87 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
88 | it != stringEntries.end(); ++it ){ | 88 | it != stringEntries.end(); ++it ){ |
89 | QString val = it.data(); | 89 | QString val = it.data(); |
90 | key = it.key(); | 90 | key = it.key(); |
91 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 91 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
92 | keys = QStringList::split( "SEPARATOR", key ); | 92 | keys = QStringList::split( "SEPARATOR", key ); |
93 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 93 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); |
94 | cfg.setGroup(keys[0]); | 94 | cfg.setGroup(keys[0]); |
95 | cfg.writeEntry(keys[1], val); | 95 | cfg.writeEntry(keys[1], val); |
96 | } | 96 | } |
97 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 97 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
98 | it != intEntries.end(); ++it ){ | 98 | it != intEntries.end(); ++it ){ |
99 | int val = it.data(); | 99 | int val = it.data(); |
100 | key = it.key(); | 100 | key = it.key(); |
101 | // qDebug("saving %s -> %i", key.latin1(), val ); | 101 | // qDebug("saving %s -> %i", key.latin1(), val ); |
102 | keys = QStringList::split( "SEPARATOR", key ); | 102 | keys = QStringList::split( "SEPARATOR", key ); |
103 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 103 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); |
104 | cfg.setGroup(keys[0]); | 104 | cfg.setGroup(keys[0]); |
105 | cfg.writeEntry(keys[1], val); | 105 | cfg.writeEntry(keys[1], val); |
106 | } | 106 | } |
107 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 107 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
108 | it != listEntries.end(); ++it ){ | 108 | it != listEntries.end(); ++it ){ |
109 | QStringList val = it.data(); | 109 | QStringList val = it.data(); |
110 | key = it.key(); | 110 | key = it.key(); |
111 | QChar sep = sepEntries[key]; | 111 | QChar sep = sepEntries[key]; |
112 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 112 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); |
113 | keys = QStringList::split( "SEPARATOR", key ); | 113 | keys = QStringList::split( "SEPARATOR", key ); |
114 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | 114 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); |
115 | cfg.setGroup(keys[0]); | 115 | cfg.setGroup(keys[0]); |
116 | cfg.writeEntry(keys[1], val, sep); | 116 | cfg.writeEntry(keys[1], val, sep); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | // | 121 | // |
122 | // cancel changes | 122 | // cancel changes |
123 | // | 123 | // |
124 | void PPPData::cancel() { | 124 | void PPPData::cancel() { |
125 | stringEntries.clear(); | 125 | stringEntries.clear(); |
126 | intEntries.clear(); | 126 | intEntries.clear(); |
127 | listEntries.clear(); | 127 | listEntries.clear(); |
128 | } | 128 | } |
129 | 129 | ||
130 | // functions to read/write date to configuration file | 130 | // functions to read/write date to configuration file |
131 | QString PPPData::readConfig(const QString &group, const QString &key, | 131 | QString PPPData::readConfig(const QString &group, const QString &key, |
132 | const QString &defvalue = "") | 132 | const QString &defvalue = "") |
133 | { | 133 | { |
134 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 134 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
135 | QString idx = SEP.arg(group).arg(key); | 135 | QString idx = SEP.arg(group).arg(key); |
136 | if (stringEntries.find(idx) != stringEntries.end()) | 136 | if (stringEntries.find(idx) != stringEntries.end()) |
137 | return stringEntries[idx]; | 137 | return stringEntries[idx]; |
138 | Config cfg = config(); | 138 | Config cfg = config(); |
139 | cfg.setGroup(group); | 139 | cfg.setGroup(group); |
140 | return cfg.readEntry(key, defvalue); | 140 | return cfg.readEntry(key, defvalue); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | int PPPData::readNumConfig(const QString &group, const QString &key, | 144 | int PPPData::readNumConfig(const QString &group, const QString &key, |
145 | int defvalue) | 145 | int defvalue) |
146 | { | 146 | { |
147 | QString idx = SEP.arg(group).arg(key); | 147 | QString idx = SEP.arg(group).arg(key); |
148 | if (intEntries.find(idx) != intEntries.end()) | 148 | if (intEntries.find(idx) != intEntries.end()) |
149 | return intEntries[idx]; | 149 | return intEntries[idx]; |
150 | Config cfg = config(); | 150 | Config cfg = config(); |
151 | cfg.setGroup(group); | 151 | cfg.setGroup(group); |
152 | return cfg.readNumEntry(key, defvalue); | 152 | return cfg.readNumEntry(key, defvalue); |
153 | 153 | ||
154 | // if (config) { | 154 | // if (config) { |
155 | // config->setGroup(group); | 155 | // config->setGroup(group); |
156 | // return config->readNumEntry(key, defvalue); | 156 | // return config->readNumEntry(key, defvalue); |
157 | // } else | 157 | // } else |
158 | // return defvalue; | 158 | // return defvalue; |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | bool PPPData::readListConfig(const QString &group, const QString &key, | 163 | bool PPPData::readListConfig(const QString &group, const QString &key, |
164 | QStringList &list, char sep) { | 164 | QStringList &list, char sep) { |
165 | list.clear(); | 165 | list.clear(); |
166 | QString idx = SEP.arg(group).arg(key); | 166 | QString idx = SEP.arg(group).arg(key); |
167 | if (listEntries.find(idx) != listEntries.end()){ | 167 | if (listEntries.find(idx) != listEntries.end()){ |
168 | list = listEntries[idx]; | 168 | list = listEntries[idx]; |
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | Config cfg = config(); | 171 | Config cfg = config(); |
172 | cfg.setGroup(group); | 172 | cfg.setGroup(group); |
173 | list = cfg.readListEntry(key, sep); | 173 | list = cfg.readListEntry(key, sep); |
174 | if (list.count() > 0) return true; | 174 | if (list.count() > 0) return true; |
175 | return false; | 175 | return false; |
176 | 176 | ||
177 | // if (config) { | 177 | // if (config) { |
178 | // config->setGroup(group); | 178 | // config->setGroup(group); |
179 | // list = config->readListEntry(key, sep); | 179 | // list = config->readListEntry(key, sep); |
180 | // return true; | 180 | // return true; |
181 | // } else | 181 | // } else |
182 | // return false; | 182 | // return false; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | void PPPData::writeConfig(const QString &group, const QString &key, | 186 | void PPPData::writeConfig(const QString &group, const QString &key, |
187 | const QString &value) { | 187 | const QString &value) { |
188 | stringEntries.insert( SEP.arg(group).arg(key), value ); | 188 | stringEntries.insert( SEP.arg(group).arg(key), value ); |
189 | // if (config) { | 189 | // if (config) { |
190 | // config->setGroup(group); | 190 | // config->setGroup(group); |
191 | // config->writeEntry(key, value); | 191 | // config->writeEntry(key, value); |
192 | // } | 192 | // } |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | void PPPData::writeConfig(const QString &group, const QString &key, int value) | 196 | void PPPData::writeConfig(const QString &group, const QString &key, int value) |
197 | { | 197 | { |
198 | intEntries.insert( SEP.arg(group).arg(key), value ); | 198 | intEntries.insert( SEP.arg(group).arg(key), value ); |
199 | // if (config) { | 199 | // if (config) { |
200 | // config->setGroup(group); | 200 | // config->setGroup(group); |
201 | // config->writeEntry(key, value); | 201 | // config->writeEntry(key, value); |
202 | // } | 202 | // } |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void PPPData::writeListConfig(const QString &group, const QString &key, | 206 | void PPPData::writeListConfig(const QString &group, const QString &key, |
207 | QStringList &list, char sep) | 207 | QStringList &list, char sep) |
208 | { | 208 | { |
209 | listEntries.insert( SEP.arg(group).arg(key), list ); | 209 | listEntries.insert( SEP.arg(group).arg(key), list ); |
210 | sepEntries.insert( SEP.arg(group).arg(key), sep ); | 210 | sepEntries.insert( SEP.arg(group).arg(key), sep ); |
211 | // if (config) { | 211 | // if (config) { |
212 | // config->setGroup(group); | 212 | // config->setGroup(group); |
213 | // config->writeEntry(key, list, sep); | 213 | // config->writeEntry(key, list, sep); |
214 | // } | 214 | // } |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | // | 218 | // |
219 | // functions to set/return general information | 219 | // functions to set/return general information |
220 | // | 220 | // |
221 | QString PPPData::password(){ | 221 | QString PPPData::password(){ |
222 | if ( storePassword() ) return storedPassword(); | 222 | if ( storePassword() ) return storedPassword(); |
223 | else return passwd; | 223 | else return passwd; |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void PPPData::setPassword(const QString &pw) { | 227 | void PPPData::setPassword(const QString &pw) { |
228 | passwd = pw; | 228 | passwd = pw; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | const QString PPPData::defaultAccount() { | 232 | const QString PPPData::defaultAccount() { |
233 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | 233 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | void PPPData::setDefaultAccount(const QString &n) { | 237 | void PPPData::setDefaultAccount(const QString &n) { |
238 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | 238 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); |
239 | 239 | ||
240 | //now set the current account index to the default account | 240 | //now set the current account index to the default account |
241 | setAccount(defaultAccount()); | 241 | setAccount(defaultAccount()); |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | bool PPPData::get_show_clock_on_caption() { | 245 | bool PPPData::get_show_clock_on_caption() { |
246 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | 246 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void PPPData::set_show_clock_on_caption(bool set) { | 250 | void PPPData::set_show_clock_on_caption(bool set) { |
251 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 251 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | bool PPPData::get_xserver_exit_disconnect() { | 255 | bool PPPData::get_xserver_exit_disconnect() { |
256 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 256 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void PPPData::setPPPDebug(bool set) { | 260 | void PPPData::setPPPDebug(bool set) { |
261 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 261 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | bool PPPData::getPPPDebug() { | 265 | bool PPPData::getPPPDebug() { |
266 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 266 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | void PPPData::set_xserver_exit_disconnect(bool set) { | 270 | void PPPData::set_xserver_exit_disconnect(bool set) { |
271 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 271 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | bool PPPData::quit_on_disconnect() { | 275 | bool PPPData::quit_on_disconnect() { |
276 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 276 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | void PPPData::set_quit_on_disconnect(bool set) { | 280 | void PPPData::set_quit_on_disconnect(bool set) { |
281 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 281 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | bool PPPData::get_show_log_window() { | 285 | bool PPPData::get_show_log_window() { |
286 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 286 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void PPPData::set_show_log_window(bool set) { | 290 | void PPPData::set_show_log_window(bool set) { |
291 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 291 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | bool PPPData::automatic_redial() { | 295 | bool PPPData::automatic_redial() { |
296 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 296 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void PPPData::set_automatic_redial(bool set) { | 300 | void PPPData::set_automatic_redial(bool set) { |
301 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 301 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | // bool PPPData::get_iconify_on_connect() { | 305 | // bool PPPData::get_iconify_on_connect() { |
306 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 306 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
307 | // } | 307 | // } |
308 | 308 | ||
309 | 309 | ||
310 | // void PPPData::set_iconify_on_connect(bool set) { | 310 | // void PPPData::set_iconify_on_connect(bool set) { |
311 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 311 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
312 | // } | 312 | // } |
313 | 313 | ||
314 | 314 | ||
315 | // bool PPPData::get_dock_into_panel() { | 315 | // bool PPPData::get_dock_into_panel() { |
316 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 316 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
317 | // } | 317 | // } |
318 | 318 | ||
319 | 319 | ||
320 | // void PPPData::set_dock_into_panel(bool set) { | 320 | // void PPPData::set_dock_into_panel(bool set) { |
321 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 321 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
322 | // } | 322 | // } |
323 | 323 | ||
324 | 324 | ||
325 | QString PPPData::pppdVersion() { | 325 | QString PPPData::pppdVersion() { |
326 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 326 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
327 | } | 327 | } |
328 | 328 | ||
329 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 329 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
330 | // check if pppd version fulfills minimum requirement | 330 | // check if pppd version fulfills minimum requirement |
331 | return (pppdVer > ver | 331 | return (pppdVer > ver |
332 | || (pppdVer == ver && pppdMod > mod) | 332 | || (pppdVer == ver && pppdMod > mod) |
333 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 333 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
334 | } | 334 | } |
335 | 335 | ||
336 | int PPPData::pppdTimeout() { | 336 | int PPPData::pppdTimeout() { |
337 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 337 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | void PPPData::setpppdTimeout(int n) { | 341 | void PPPData::setpppdTimeout(int n) { |
342 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 342 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | const QString PPPData::modemDevice() { | 346 | const QString PPPData::modemDevice() { |
347 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 347 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | bool PPPData::setModemDevice(const QString &n) { | 351 | bool PPPData::setModemDevice(const QString &n) { |
352 | qDebug("Setting modem dev to >%s<", n.latin1()); | 352 | qDebug("Setting modem dev to >%s<", n.latin1()); |
353 | bool ret = false; | 353 | bool ret = false; |
354 | for (int i = 0; devices[i]; i++) | 354 | for (int i = 0; devices[i]; i++) |
355 | if (devices[i] == n){ | 355 | if (devices[i] == n){ |
356 | modemDeviceGroup = i; | 356 | modemDeviceGroup = i; |
357 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 357 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
358 | ret = true; | 358 | ret = true; |
359 | } | 359 | } |
360 | qDebug(ret?"SUCCESS":"FAILURE"); | 360 | qDebug(ret?"SUCCESS":"FAILURE"); |
361 | return ret; | 361 | return ret; |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | const QString PPPData::flowcontrol() { | 365 | const QString PPPData::flowcontrol() { |
366 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 366 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void PPPData::setFlowcontrol(const QString &n) { | 370 | void PPPData::setFlowcontrol(const QString &n) { |
371 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 371 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | const QString PPPData::speed() { | 375 | const QString PPPData::speed() { |
376 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 376 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
377 | // undo the damage of a bug in former versions. It left an empty Speed= | 377 | // undo the damage of a bug in former versions. It left an empty Speed= |
378 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 378 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
379 | // pppd wouldn't receive the speed via the command line. | 379 | // pppd wouldn't receive the speed via the command line. |
380 | if(s.toUInt() == 0) | 380 | if(s.toUInt() == 0) |
381 | s = "57600"; | 381 | s = "57600"; |
382 | return s; | 382 | return s; |
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | void PPPData::setSpeed(const QString &n) { | 386 | void PPPData::setSpeed(const QString &n) { |
387 | writeConfig(modemGroup(), SPEED_KEY, n); | 387 | writeConfig(modemGroup(), SPEED_KEY, n); |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | #if 0 | 391 | #if 0 |
392 | void PPPData::setUseCDLine(const int n) { | 392 | void PPPData::setUseCDLine(const int n) { |
393 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 393 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | int PPPData::UseCDLine() { | 397 | int PPPData::UseCDLine() { |
398 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 398 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
399 | } | 399 | } |
400 | #endif | 400 | #endif |
401 | 401 | ||
402 | const QString PPPData::modemEscapeStr() { | 402 | const QString PPPData::modemEscapeStr() { |
403 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 403 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void PPPData::setModemEscapeStr(const QString &n) { | 407 | void PPPData::setModemEscapeStr(const QString &n) { |
408 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 408 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | const QString PPPData::modemEscapeResp() { | 412 | const QString PPPData::modemEscapeResp() { |
413 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 413 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PPPData::setModemEscapeResp(const QString &n) { | 417 | void PPPData::setModemEscapeResp(const QString &n) { |
418 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 418 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | int PPPData::modemEscapeGuardTime() { | 422 | int PPPData::modemEscapeGuardTime() { |
423 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 423 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | void PPPData::setModemEscapeGuardTime(int n) { | 427 | void PPPData::setModemEscapeGuardTime(int n) { |
428 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 428 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | bool PPPData::modemLockFile() { | 432 | bool PPPData::modemLockFile() { |
433 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 433 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void PPPData::setModemLockFile(bool set) { | 437 | void PPPData::setModemLockFile(bool set) { |
438 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 438 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | int PPPData::modemTimeout() { | 442 | int PPPData::modemTimeout() { |
443 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 443 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void PPPData::setModemTimeout(int n) { | 447 | void PPPData::setModemTimeout(int n) { |
448 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 448 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | int PPPData::modemToneDuration() { | 452 | int PPPData::modemToneDuration() { |
453 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 453 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | void PPPData::setModemToneDuration(int n) { | 457 | void PPPData::setModemToneDuration(int n) { |
458 | writeConfig(modemGroup(), TONEDURATION_KEY, n); | 458 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | int PPPData::busyWait() { | 462 | int PPPData::busyWait() { |
463 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); | 463 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PPPData::setbusyWait(int n) { | 467 | void PPPData::setbusyWait(int n) { |
468 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); | 468 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | // | 472 | // |
473 | //Advanced "Modem" dialog | 473 | //Advanced "Modem" dialog |
474 | // | 474 | // |
475 | // defaults: InitString=ATZ, InitString1="" etc. | 475 | // defaults: InitString=ATZ, InitString1="" etc. |
476 | const QString PPPData::modemInitStr(int i) { | 476 | const QString PPPData::modemInitStr(int i) { |
477 | assert(i >= 0 && i < NumInitStrings); | 477 | assert(i >= 0 && i < NumInitStrings); |
478 | if(i == 0) | 478 | if(i == 0) |
479 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); | 479 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); |
480 | else | 480 | else |
481 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); | 481 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | void PPPData::setModemInitStr(int i, const QString &n) { | 485 | void PPPData::setModemInitStr(int i, const QString &n) { |
486 | assert(i >= 0 && i < NumInitStrings); | 486 | assert(i >= 0 && i < NumInitStrings); |
487 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | 487 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : QString("")); |
488 | writeConfig(modemGroup(), k, n); | 488 | writeConfig(modemGroup(), k, n); |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | const QString PPPData::modemInitResp() { | 492 | const QString PPPData::modemInitResp() { |
493 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); | 493 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | void PPPData::setModemInitResp(const QString &n) { | 497 | void PPPData::setModemInitResp(const QString &n) { |
498 | writeConfig(modemGroup(), INITRESP_KEY, n); | 498 | writeConfig(modemGroup(), INITRESP_KEY, n); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | int PPPData::modemPreInitDelay() { | 502 | int PPPData::modemPreInitDelay() { |
503 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); | 503 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void PPPData::setModemPreInitDelay(int n) { | 507 | void PPPData::setModemPreInitDelay(int n) { |
508 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); | 508 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | int PPPData::modemInitDelay() { | 512 | int PPPData::modemInitDelay() { |
513 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); | 513 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | void PPPData::setModemInitDelay(int n) { | 517 | void PPPData::setModemInitDelay(int n) { |
518 | writeConfig(modemGroup(), INITDELAY_KEY, n); | 518 | writeConfig(modemGroup(), INITDELAY_KEY, n); |
519 | } | 519 | } |
520 | 520 | ||
521 | QString PPPData::modemNoDialToneDetectionStr() { | 521 | QString PPPData::modemNoDialToneDetectionStr() { |
522 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); | 522 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); |
523 | } | 523 | } |
524 | 524 | ||
525 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | 525 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { |
526 | writeConfig(modemGroup(), NODTDETECT_KEY, n); | 526 | writeConfig(modemGroup(), NODTDETECT_KEY, n); |
527 | } | 527 | } |
528 | 528 | ||
529 | const QString PPPData::modemDialStr() { | 529 | const QString PPPData::modemDialStr() { |
530 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); | 530 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | void PPPData::setModemDialStr(const QString &n) { | 534 | void PPPData::setModemDialStr(const QString &n) { |
535 | writeConfig(modemGroup(), DIALSTR_KEY, n); | 535 | writeConfig(modemGroup(), DIALSTR_KEY, n); |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | const QString PPPData::modemConnectResp() { | 539 | const QString PPPData::modemConnectResp() { |
540 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); | 540 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); |
541 | } | 541 | } |
542 | 542 | ||
543 | 543 | ||
544 | void PPPData::setModemConnectResp(const QString &n) { | 544 | void PPPData::setModemConnectResp(const QString &n) { |
545 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); | 545 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); |
546 | } | 546 | } |
547 | 547 | ||
548 | 548 | ||
549 | const QString PPPData::modemBusyResp() { | 549 | const QString PPPData::modemBusyResp() { |
550 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); | 550 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | void PPPData::setModemBusyResp(const QString &n) { | 554 | void PPPData::setModemBusyResp(const QString &n) { |
555 | writeConfig(modemGroup(), BUSYRESP_KEY, n); | 555 | writeConfig(modemGroup(), BUSYRESP_KEY, n); |
556 | } | 556 | } |
557 | 557 | ||
558 | 558 | ||
559 | const QString PPPData::modemNoCarrierResp() { | 559 | const QString PPPData::modemNoCarrierResp() { |
560 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); | 560 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); |
561 | } | 561 | } |
562 | 562 | ||
563 | 563 | ||
564 | void PPPData::setModemNoCarrierResp(const QString &n) { | 564 | void PPPData::setModemNoCarrierResp(const QString &n) { |
565 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); | 565 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | const QString PPPData::modemNoDialtoneResp() { | 569 | const QString PPPData::modemNoDialtoneResp() { |
570 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); | 570 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | void PPPData::setModemNoDialtoneResp(const QString &n) { | 574 | void PPPData::setModemNoDialtoneResp(const QString &n) { |
575 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); | 575 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); |
576 | } | 576 | } |
577 | 577 | ||
578 | 578 | ||
579 | const QString PPPData::modemHangupStr() { | 579 | const QString PPPData::modemHangupStr() { |
580 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); | 580 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); |
581 | } | 581 | } |
582 | 582 | ||
583 | void PPPData::setModemHangupStr(const QString &n) { | 583 | void PPPData::setModemHangupStr(const QString &n) { |
584 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); | 584 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); |
585 | } | 585 | } |
586 | 586 | ||
587 | 587 | ||
588 | const QString PPPData::modemHangupResp() { | 588 | const QString PPPData::modemHangupResp() { |
589 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); | 589 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); |
590 | } | 590 | } |
591 | 591 | ||
592 | void PPPData::setModemHangupResp(const QString &n) { | 592 | void PPPData::setModemHangupResp(const QString &n) { |
593 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); | 593 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | const QString PPPData::modemAnswerStr() { | 597 | const QString PPPData::modemAnswerStr() { |
598 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); | 598 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
602 | QString PPPData::volumeOff() { | 602 | QString PPPData::volumeOff() { |
603 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); | 603 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
604 | } | 604 | } |
605 | 605 | ||
606 | 606 | ||
607 | void PPPData::setVolumeOff(const QString &s) { | 607 | void PPPData::setVolumeOff(const QString &s) { |
608 | writeConfig(modemGroup(), VOLUME_OFF, s); | 608 | writeConfig(modemGroup(), VOLUME_OFF, s); |
609 | } | 609 | } |
610 | 610 | ||
611 | 611 | ||
612 | QString PPPData::volumeMedium() { | 612 | QString PPPData::volumeMedium() { |
613 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); | 613 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
614 | } | 614 | } |
615 | 615 | ||
616 | 616 | ||
617 | void PPPData::setVolumeMedium(const QString &s) { | 617 | void PPPData::setVolumeMedium(const QString &s) { |
618 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); | 618 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
619 | } | 619 | } |
620 | 620 | ||
621 | 621 | ||
622 | QString PPPData::volumeHigh() { | 622 | QString PPPData::volumeHigh() { |
623 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); | 623 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
624 | if(tmp == "M1L4") | 624 | if(tmp == "M1L4") |
625 | tmp = "M1L3"; | 625 | tmp = "M1L3"; |
626 | return tmp; | 626 | return tmp; |
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | void PPPData::setVolumeHigh(const QString &s) { | 630 | void PPPData::setVolumeHigh(const QString &s) { |
631 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 631 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
635 | QString PPPData::volumeInitString() { | 635 | QString PPPData::volumeInitString() { |
636 | QString s; | 636 | QString s; |
637 | 637 | ||
638 | switch(volume()) { | 638 | switch(volume()) { |
639 | case 0: | 639 | case 0: |
640 | s = volumeOff(); | 640 | s = volumeOff(); |
641 | break; | 641 | break; |
642 | case 1: | 642 | case 1: |
643 | s = volumeMedium(); | 643 | s = volumeMedium(); |
644 | break; | 644 | break; |
645 | case 2: | 645 | case 2: |
646 | s = volumeHigh(); | 646 | s = volumeHigh(); |
647 | break; | 647 | break; |
648 | default: | 648 | default: |
649 | s = volumeMedium(); | 649 | s = volumeMedium(); |
650 | } | 650 | } |
651 | 651 | ||
652 | return s; | 652 | return s; |
653 | } | 653 | } |
654 | 654 | ||
655 | 655 | ||
656 | int PPPData::volume() { | 656 | int PPPData::volume() { |
657 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 657 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
658 | } | 658 | } |
659 | 659 | ||
660 | 660 | ||
661 | void PPPData::setVolume(int i) { | 661 | void PPPData::setVolume(int i) { |
662 | writeConfig(modemGroup(), VOLUME_KEY, i); | 662 | writeConfig(modemGroup(), VOLUME_KEY, i); |
663 | } | 663 | } |
664 | 664 | ||
665 | int PPPData::waitForDialTone() { | 665 | int PPPData::waitForDialTone() { |
666 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 666 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
667 | } | 667 | } |
668 | 668 | ||
669 | void PPPData::setWaitForDialTone(int i) { | 669 | void PPPData::setWaitForDialTone(int i) { |
670 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 670 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
671 | } | 671 | } |
672 | 672 | ||
673 | void PPPData::setModemAnswerStr(const QString &n) { | 673 | void PPPData::setModemAnswerStr(const QString &n) { |
674 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 674 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | const QString PPPData::modemRingResp() { | 678 | const QString PPPData::modemRingResp() { |
679 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 679 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
683 | void PPPData::setModemRingResp(const QString &n) { | 683 | void PPPData::setModemRingResp(const QString &n) { |
684 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 684 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | const QString PPPData::modemAnswerResp() { | 688 | const QString PPPData::modemAnswerResp() { |
689 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 689 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void PPPData::setModemAnswerResp(const QString &n) { | 693 | void PPPData::setModemAnswerResp(const QString &n) { |
694 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 694 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
695 | } | 695 | } |
696 | 696 | ||
697 | 697 | ||
698 | const QString PPPData::enter() { | 698 | const QString PPPData::enter() { |
699 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 699 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | void PPPData::setEnter(const QString &n) { | 703 | void PPPData::setEnter(const QString &n) { |
704 | writeConfig(modemGroup(), ENTER_KEY, n); | 704 | writeConfig(modemGroup(), ENTER_KEY, n); |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | // | 708 | // |
709 | // functions to set/return account information | 709 | // functions to set/return account information |
710 | // | 710 | // |
711 | 711 | ||
712 | //returns number of accounts | 712 | //returns number of accounts |
713 | int PPPData::count() const { | 713 | int PPPData::count() const { |
714 | return highcount + 1; | 714 | return highcount + 1; |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | bool PPPData::setAccount(const QString &aname) { | 718 | bool PPPData::setAccount(const QString &aname) { |
719 | qDebug("setting account to >%s<", aname.latin1()); | 719 | qDebug("setting account to >%s<", aname.latin1()); |
720 | for(int i = 0; i <= highcount; i++) { | 720 | for(int i = 0; i <= highcount; i++) { |
721 | setAccountbyIndex(i); | 721 | setAccountbyIndex(i); |
722 | if(accname() == aname) { | 722 | if(accname() == aname) { |
723 | caccount = i; | 723 | caccount = i; |
724 | qDebug("SUCCESS"); | 724 | qDebug("SUCCESS"); |
725 | return true; | 725 | return true; |
726 | } | 726 | } |
727 | } | 727 | } |
728 | qDebug("FAILURE"); | 728 | qDebug("FAILURE"); |
729 | return false; | 729 | return false; |
730 | } | 730 | } |
731 | 731 | ||
732 | 732 | ||
733 | bool PPPData::setAccountbyIndex(int i) { | 733 | bool PPPData::setAccountbyIndex(int i) { |
734 | if(i >= 0 && i <= highcount) { | 734 | if(i >= 0 && i <= highcount) { |
735 | caccount = i; | 735 | caccount = i; |
736 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 736 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
737 | return true; | 737 | return true; |
738 | } | 738 | } |
739 | return false; | 739 | return false; |
740 | } | 740 | } |
741 | 741 | ||
742 | 742 | ||
743 | bool PPPData::isUniqueAccname(const QString &n) { | 743 | bool PPPData::isUniqueAccname(const QString &n) { |
744 | int current = caccount; | 744 | int current = caccount; |
745 | for(int i=0; i <= highcount; i++) { | 745 | for(int i=0; i <= highcount; i++) { |
746 | setAccountbyIndex(i); | 746 | setAccountbyIndex(i); |
747 | if(accname() == n && i != current) { | 747 | if(accname() == n && i != current) { |
748 | setAccountbyIndex(current); | 748 | setAccountbyIndex(current); |
749 | return false; | 749 | return false; |
750 | } | 750 | } |
751 | } | 751 | } |
752 | setAccountbyIndex(current); | 752 | setAccountbyIndex(current); |
753 | return true; | 753 | return true; |
754 | } | 754 | } |
755 | 755 | ||
756 | 756 | ||
757 | bool PPPData::deleteAccount() { | 757 | bool PPPData::deleteAccount() { |
758 | //FIXME: PPPData::deleteAccount | 758 | //FIXME: PPPData::deleteAccount |
759 | // if(caccount < 0) | 759 | // if(caccount < 0) |
760 | return false; | 760 | return false; |
761 | 761 | ||
762 | // QMap <QString, QString> map; | 762 | // QMap <QString, QString> map; |
763 | // QMap <QString, QString>::Iterator it; | 763 | // QMap <QString, QString>::Iterator it; |
764 | 764 | ||
765 | // // set all entries of the current account to "" | 765 | // // set all entries of the current account to "" |
766 | // map = config->entryMap(cgroup); | 766 | // map = config->entryMap(cgroup); |
767 | // it = map.begin(); | 767 | // it = map.begin(); |
768 | // while (it != map.end()) { | 768 | // while (it != map.end()) { |
769 | // config->writeEntry(it.key(), ""); | 769 | // config->writeEntry(it.key(), ""); |
770 | // it++; | 770 | // it++; |
771 | // } | 771 | // } |
772 | 772 | ||
773 | // // shift the succeeding accounts | 773 | // // shift the succeeding accounts |
774 | // for(int i = caccount+1; i <= highcount; i++) { | 774 | // for(int i = caccount+1; i <= highcount; i++) { |
775 | // setAccountbyIndex(i); | 775 | // setAccountbyIndex(i); |
776 | // map = config->entryMap(cgroup); | 776 | // map = config->entryMap(cgroup); |
777 | // it = map.begin(); | 777 | // it = map.begin(); |
778 | // setAccountbyIndex(i-1); | 778 | // setAccountbyIndex(i-1); |
779 | // config->setGroup(cgroup); | 779 | // config->setGroup(cgroup); |
780 | // while (it != map.end()) { | 780 | // while (it != map.end()) { |
781 | // config->writeEntry(it.key(), *it); | 781 | // config->writeEntry(it.key(), *it); |
782 | // it++; | 782 | // it++; |
783 | // } | 783 | // } |
784 | // } | 784 | // } |
785 | 785 | ||
786 | // // make sure the top account is cleared | 786 | // // make sure the top account is cleared |
787 | // setAccountbyIndex(highcount); | 787 | // setAccountbyIndex(highcount); |
788 | // map = config->entryMap(cgroup); | 788 | // map = config->entryMap(cgroup); |
789 | // it = map.begin(); | 789 | // it = map.begin(); |
790 | // config->setGroup(cgroup); | 790 | // config->setGroup(cgroup); |
791 | // while (it.key() != QString::null) { | 791 | // while (it.key() != QString::null) { |
792 | // config->writeEntry(it.key(), ""); | 792 | // config->writeEntry(it.key(), ""); |
793 | // it++; | 793 | // it++; |
794 | // } | 794 | // } |
795 | 795 | ||
796 | // highcount--; | 796 | // highcount--; |
797 | // if(caccount > highcount) | 797 | // if(caccount > highcount) |
798 | // caccount = highcount; | 798 | // caccount = highcount; |
799 | 799 | ||
800 | // setAccountbyIndex(caccount); | 800 | // setAccountbyIndex(caccount); |
801 | 801 | ||
802 | // return true; | 802 | // return true; |
803 | } | 803 | } |
804 | 804 | ||
805 | 805 | ||
806 | bool PPPData::deleteAccount(const QString &aname) { | 806 | bool PPPData::deleteAccount(const QString &aname) { |
807 | if(!setAccount(aname)) | 807 | if(!setAccount(aname)) |
808 | return false; | 808 | return false; |
809 | 809 | ||
810 | deleteAccount(); | 810 | deleteAccount(); |
811 | 811 | ||
812 | return true; | 812 | return true; |
813 | } | 813 | } |
814 | 814 | ||
815 | 815 | ||
816 | int PPPData::newaccount() { | 816 | int PPPData::newaccount() { |
817 | 817 | ||
818 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 818 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
819 | // if(!config) open(); | 819 | // if(!config) open(); |
820 | if (highcount >= MAX_ACCOUNTS) return -1; | 820 | if (highcount >= MAX_ACCOUNTS) return -1; |
821 | 821 | ||
822 | highcount++; | 822 | highcount++; |
823 | setAccountbyIndex(highcount); | 823 | setAccountbyIndex(highcount); |
824 | 824 | ||
825 | setpppdArgumentDefaults(); | 825 | setpppdArgumentDefaults(); |
826 | qDebug("PPPData::newaccount -> %i",caccount); | 826 | qDebug("PPPData::newaccount -> %i",caccount); |
827 | return caccount; | 827 | return caccount; |
828 | } | 828 | } |
829 | 829 | ||
830 | int PPPData::copyaccount(int i) { | 830 | int PPPData::copyaccount(int i) { |
831 | // FIXME: PPPData::copyaccount | 831 | // FIXME: PPPData::copyaccount |
832 | // if(highcount >= MAX_ACCOUNTS) | 832 | // if(highcount >= MAX_ACCOUNTS) |
833 | return -1; | 833 | return -1; |
834 | 834 | ||
835 | // setAccountbyIndex(i); | 835 | // setAccountbyIndex(i); |
836 | 836 | ||
837 | // QMap <QString, QString> map = config->entryMap(cgroup); | 837 | // QMap <QString, QString> map = config->entryMap(cgroup); |
838 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 838 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
839 | 839 | ||
840 | // QString newname = i18n("%1_copy").arg(accname()); | 840 | // QString newname = i18n("%1_copy").arg(accname()); |
841 | 841 | ||
842 | // newaccount(); | 842 | // newaccount(); |
843 | 843 | ||
844 | // while (it != map.end()) { | 844 | // while (it != map.end()) { |
845 | // config->writeEntry(it.key(), *it); | 845 | // config->writeEntry(it.key(), *it); |
846 | // it++; | 846 | // it++; |
847 | // } | 847 | // } |
848 | 848 | ||
849 | // setAccname(newname); | 849 | // setAccname(newname); |
850 | 850 | ||
851 | // return caccount; | 851 | // return caccount; |
852 | } | 852 | } |
853 | 853 | ||
854 | 854 | ||
855 | const QString PPPData::accname() { | 855 | const QString PPPData::accname() { |
856 | return readConfig(cgroup, NAME_KEY); | 856 | return readConfig(cgroup, NAME_KEY); |
857 | } | 857 | } |
858 | 858 | ||
859 | void PPPData::setAccname(const QString &n) { | 859 | void PPPData::setAccname(const QString &n) { |
860 | if(!cgroup.isNull()) { | 860 | if(!cgroup.isNull()) { |
861 | // are we manipulating the default account's name ? then change it, too. | 861 | // are we manipulating the default account's name ? then change it, too. |
862 | bool def = accname() == defaultAccount(); | 862 | bool def = accname() == defaultAccount(); |
863 | writeConfig(cgroup, NAME_KEY, n); | 863 | writeConfig(cgroup, NAME_KEY, n); |
864 | if (def) | 864 | if (def) |
865 | setDefaultAccount(n); | 865 | setDefaultAccount(n); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | 868 | ||
869 | 869 | ||
870 | #define SEPARATOR_CHAR '&' | 870 | #define SEPARATOR_CHAR '&' |
871 | QStringList &PPPData::phonenumbers() { | 871 | QStringList &PPPData::phonenumbers() { |
872 | 872 | ||
873 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 873 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
874 | return phonelist; | 874 | return phonelist; |
875 | 875 | ||
876 | } | 876 | } |
877 | 877 | ||
878 | 878 | ||
879 | const QString PPPData::phonenumber() { | 879 | const QString PPPData::phonenumber() { |
880 | return readConfig(cgroup, PHONENUMBER_KEY); | 880 | return readConfig(cgroup, PHONENUMBER_KEY); |
881 | } | 881 | } |
882 | 882 | ||
883 | 883 | ||
884 | void PPPData::setPhonenumber(const QString &n) { | 884 | void PPPData::setPhonenumber(const QString &n) { |
885 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 885 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
886 | } | 886 | } |
887 | 887 | ||
888 | 888 | ||
889 | const QString PPPData::dialPrefix() { | 889 | const QString PPPData::dialPrefix() { |
890 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 890 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
891 | } | 891 | } |
892 | 892 | ||
893 | 893 | ||
894 | void PPPData::setDialPrefix(const QString &s) { | 894 | void PPPData::setDialPrefix(const QString &s) { |
895 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 895 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
896 | } | 896 | } |
897 | 897 | ||
898 | 898 | ||
899 | int PPPData::authMethod() { | 899 | int PPPData::authMethod() { |
900 | return readNumConfig(cgroup, AUTH_KEY, 0); | 900 | return readNumConfig(cgroup, AUTH_KEY, 0); |
901 | } | 901 | } |
902 | 902 | ||
903 | 903 | ||
904 | void PPPData::setAuthMethod(int value) { | 904 | void PPPData::setAuthMethod(int value) { |
905 | writeConfig(cgroup, AUTH_KEY, value); | 905 | writeConfig(cgroup, AUTH_KEY, value); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | const QString PPPData::storedUsername() { | 909 | const QString PPPData::storedUsername() { |
910 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 910 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
911 | } | 911 | } |
912 | 912 | ||
913 | 913 | ||
914 | void PPPData::setStoredUsername(const QString &b) { | 914 | void PPPData::setStoredUsername(const QString &b) { |
915 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 915 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
916 | } | 916 | } |
917 | 917 | ||
918 | 918 | ||
919 | const QString PPPData::storedPassword() { | 919 | const QString PPPData::storedPassword() { |
920 | qDebug("getting stored pw"); | 920 | qDebug("getting stored pw"); |
921 | qDebug("g %s", cgroup.latin1() ); | 921 | qDebug("g %s", cgroup.latin1() ); |
922 | qDebug("k %s", STORED_PASSWORD_KEY); | 922 | qDebug("k %s", STORED_PASSWORD_KEY); |
923 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 923 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
924 | } | 924 | } |
925 | 925 | ||
926 | 926 | ||
927 | void PPPData::setStoredPassword(const QString &b) { | 927 | void PPPData::setStoredPassword(const QString &b) { |
928 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 928 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
929 | } | 929 | } |
930 | 930 | ||
931 | 931 | ||
932 | bool PPPData::storePassword() { | 932 | bool PPPData::storePassword() { |
933 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 933 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
934 | } | 934 | } |
935 | 935 | ||
936 | 936 | ||
937 | const QString PPPData::command_before_connect() { | 937 | const QString PPPData::command_before_connect() { |
938 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 938 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | void PPPData::setCommand_before_connect(const QString &n) { | 942 | void PPPData::setCommand_before_connect(const QString &n) { |
943 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 943 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
944 | } | 944 | } |
945 | 945 | ||
946 | 946 | ||
947 | void PPPData::setStorePassword(bool b) { | 947 | void PPPData::setStorePassword(bool b) { |
948 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | 948 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); |
949 | } | 949 | } |
950 | 950 | ||
951 | 951 | ||
952 | const QString PPPData::command_on_connect() { | 952 | const QString PPPData::command_on_connect() { |
953 | return readConfig(cgroup, COMMAND_KEY); | 953 | return readConfig(cgroup, COMMAND_KEY); |
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | void PPPData::setCommand_on_connect(const QString &n) { | 957 | void PPPData::setCommand_on_connect(const QString &n) { |
958 | writeConfig(cgroup, COMMAND_KEY, n); | 958 | writeConfig(cgroup, COMMAND_KEY, n); |
959 | } | 959 | } |
960 | 960 | ||
961 | 961 | ||
962 | const QString PPPData::command_on_disconnect() { | 962 | const QString PPPData::command_on_disconnect() { |
963 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); | 963 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); |
964 | } | 964 | } |
965 | 965 | ||
966 | 966 | ||
967 | void PPPData::setCommand_on_disconnect(const QString &n) { | 967 | void PPPData::setCommand_on_disconnect(const QString &n) { |
968 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); | 968 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); |
969 | } | 969 | } |
970 | 970 | ||
971 | 971 | ||
972 | const QString PPPData::command_before_disconnect() { | 972 | const QString PPPData::command_before_disconnect() { |
973 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); | 973 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); |
974 | } | 974 | } |
975 | 975 | ||
976 | 976 | ||
977 | void PPPData::setCommand_before_disconnect(const QString &n) { | 977 | void PPPData::setCommand_before_disconnect(const QString &n) { |
978 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); | 978 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); |
979 | } | 979 | } |
980 | 980 | ||
981 | 981 | ||
982 | const QString PPPData::ipaddr() { | 982 | const QString PPPData::ipaddr() { |
983 | return readConfig(cgroup, IPADDR_KEY); | 983 | return readConfig(cgroup, IPADDR_KEY); |
984 | } | 984 | } |
985 | 985 | ||
986 | 986 | ||
987 | void PPPData::setIpaddr(const QString &n) { | 987 | void PPPData::setIpaddr(const QString &n) { |
988 | writeConfig(cgroup, IPADDR_KEY, n); | 988 | writeConfig(cgroup, IPADDR_KEY, n); |
989 | } | 989 | } |
990 | 990 | ||
991 | 991 | ||
992 | const QString PPPData::subnetmask() { | 992 | const QString PPPData::subnetmask() { |
993 | return readConfig(cgroup, SUBNETMASK_KEY); | 993 | return readConfig(cgroup, SUBNETMASK_KEY); |
994 | } | 994 | } |
995 | 995 | ||
996 | 996 | ||
997 | void PPPData::setSubnetmask(const QString &n) { | 997 | void PPPData::setSubnetmask(const QString &n) { |
998 | writeConfig(cgroup, SUBNETMASK_KEY, n); | 998 | writeConfig(cgroup, SUBNETMASK_KEY, n); |
999 | } | 999 | } |