Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 59d68c9..7a6524f 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -127,13 +127,13 @@ void PPPData::cancel() { | |||
127 | } | 127 | } |
128 | 128 | ||
129 | // functions to read/write date to configuration file | 129 | // functions to read/write date to configuration file |
130 | QString PPPData::readConfig(const QString &group, const QString &key, | 130 | QString PPPData::readConfig(const QString &group, const QString &key, |
131 | const QString &defvalue = "") | 131 | const QString &defvalue = "") |
132 | { | 132 | { |
133 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 133 | qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
134 | QString idx = SEP.arg(group).arg(key); | 134 | QString idx = SEP.arg(group).arg(key); |
135 | if (stringEntries.find(idx) != stringEntries.end()) | 135 | if (stringEntries.find(idx) != stringEntries.end()) |
136 | return stringEntries[idx]; | 136 | return stringEntries[idx]; |
137 | Config cfg = config(); | 137 | Config cfg = config(); |
138 | cfg.setGroup(group); | 138 | cfg.setGroup(group); |
139 | return cfg.readEntry(key, defvalue); | 139 | return cfg.readEntry(key, defvalue); |
@@ -344,19 +344,21 @@ void PPPData::setpppdTimeout(int n) { | |||
344 | const QString PPPData::modemDevice() { | 344 | const QString PPPData::modemDevice() { |
345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | bool PPPData::setModemDevice(const QString &n) { | 349 | bool PPPData::setModemDevice(const QString &n) { |
350 | qDebug("Setting modem dev to >%s<", n.latin1()); | ||
350 | bool ret = false; | 351 | bool ret = false; |
351 | for (int i = 0; devices[i]; i++) | 352 | for (int i = 0; devices[i]; i++) |
352 | if (devices[i] == n){ | 353 | if (devices[i] == n){ |
353 | modemDeviceGroup = i; | 354 | modemDeviceGroup = i; |
354 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 355 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
355 | ret = true; | 356 | ret = true; |
356 | } | 357 | } |
358 | qDebug(ret?"SUCCESS":"FAILURE"); | ||
357 | return ret; | 359 | return ret; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | const QString PPPData::flowcontrol() { | 363 | const QString PPPData::flowcontrol() { |
362 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 364 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
@@ -709,19 +711,22 @@ void PPPData::setEnter(const QString &n) { | |||
709 | int PPPData::count() const { | 711 | int PPPData::count() const { |
710 | return highcount + 1; | 712 | return highcount + 1; |
711 | } | 713 | } |
712 | 714 | ||
713 | 715 | ||
714 | bool PPPData::setAccount(const QString &aname) { | 716 | bool PPPData::setAccount(const QString &aname) { |
717 | qDebug("setting account to >%s<", aname.latin1()); | ||
715 | for(int i = 0; i <= highcount; i++) { | 718 | for(int i = 0; i <= highcount; i++) { |
716 | setAccountbyIndex(i); | 719 | setAccountbyIndex(i); |
717 | if(accname() == aname) { | 720 | if(accname() == aname) { |
718 | caccount = i; | 721 | caccount = i; |
722 | qDebug("SUCCESS"); | ||
719 | return true; | 723 | return true; |
720 | } | 724 | } |
721 | } | 725 | } |
726 | qDebug("FAILURE"); | ||
722 | return false; | 727 | return false; |
723 | } | 728 | } |
724 | 729 | ||
725 | 730 | ||
726 | bool PPPData::setAccountbyIndex(int i) { | 731 | bool PPPData::setAccountbyIndex(int i) { |
727 | if(i >= 0 && i <= highcount) { | 732 | if(i >= 0 && i <= highcount) { |
@@ -907,12 +912,15 @@ const QString PPPData::storedUsername() { | |||
907 | void PPPData::setStoredUsername(const QString &b) { | 912 | void PPPData::setStoredUsername(const QString &b) { |
908 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 913 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
909 | } | 914 | } |
910 | 915 | ||
911 | 916 | ||
912 | const QString PPPData::storedPassword() { | 917 | const QString PPPData::storedPassword() { |
918 | qDebug("getting stored pw"); | ||
919 | qDebug("g %s", cgroup.latin1() ); | ||
920 | qDebug("k %s", STORED_PASSWORD_KEY); | ||
913 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 921 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
914 | } | 922 | } |
915 | 923 | ||
916 | 924 | ||
917 | void PPPData::setStoredPassword(const QString &b) { | 925 | void PPPData::setStoredPassword(const QString &b) { |
918 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 926 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
@@ -1271,6 +1279,17 @@ void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | |||
1271 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1279 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1272 | } | 1280 | } |
1273 | cfg.setGroup( ACCLIST_GRP ); | 1281 | cfg.setGroup( ACCLIST_GRP ); |
1274 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1282 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1275 | 1283 | ||
1276 | } | 1284 | } |
1285 | |||
1286 | /** | ||
1287 | * pppd's getword() function knows about escape characters. | ||
1288 | * If we write the username and password to the secrets file | ||
1289 | * we'll therefore have to escape back slashes. | ||
1290 | */ | ||
1291 | QString PPPData::encodeWord(const QString &s) { | ||
1292 | QString r = s; | ||
1293 | r.replace(QRegExp("\\"), "\\\\"); | ||
1294 | return r; | ||
1295 | } | ||