summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/pppdata.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 23db409..8f066ff 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -34,24 +34,25 @@
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
44PPPData::PPPData() 44PPPData::PPPData()
45 : modemDeviceGroup(-1), 45 : modemDeviceGroup(-1),
46 passwd(""),
46 highcount(-1), // start out with no entries 47 highcount(-1), // start out with no entries
47 caccount(-1), // set the current account index also 48 caccount(-1), // set the current account index also
48 suidprocessid(-1), // process ID of setuid child 49 suidprocessid(-1), // process ID of setuid child
49 pppdisrunning(false), 50 pppdisrunning(false),
50 pppderror(0) 51 pppderror(0)
51{ 52{
52 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 53 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
53 54
54 if (highcount > MAX_ACCOUNTS) 55 if (highcount > MAX_ACCOUNTS)
55 highcount = MAX_ACCOUNTS; 56 highcount = MAX_ACCOUNTS;
56 57
57 if(highcount >= 0 && defaultAccount().isEmpty()) { 58 if(highcount >= 0 && defaultAccount().isEmpty()) {
@@ -208,26 +209,27 @@ void PPPData::writeListConfig(const QString &group, const QString &key,
208 listEntries.insert( SEP.arg(group).arg(key), list ); 209 listEntries.insert( SEP.arg(group).arg(key), list );
209 sepEntries.insert( SEP.arg(group).arg(key), sep ); 210 sepEntries.insert( SEP.arg(group).arg(key), sep );
210// if (config) { 211// if (config) {
211// config->setGroup(group); 212// config->setGroup(group);
212// config->writeEntry(key, list, sep); 213// config->writeEntry(key, list, sep);
213// } 214// }
214} 215}
215 216
216 217
217// 218//
218// functions to set/return general information 219// functions to set/return general information
219// 220//
220QString PPPData::password() const { 221QString PPPData::password(){
221 return passwd; 222 if ( storePassword() ) return storedPassword();
223 else return passwd;
222} 224}
223 225
224 226
225void PPPData::setPassword(const QString &pw) { 227void PPPData::setPassword(const QString &pw) {
226 passwd = pw; 228 passwd = pw;
227} 229}
228 230
229 231
230const QString PPPData::defaultAccount() { 232const QString PPPData::defaultAccount() {
231 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); 233 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
232} 234}
233 235
@@ -744,25 +746,25 @@ bool PPPData::isUniqueAccname(const QString &n) {
744 setAccountbyIndex(i); 746 setAccountbyIndex(i);
745 if(accname() == n && i != current) { 747 if(accname() == n && i != current) {
746 setAccountbyIndex(current); 748 setAccountbyIndex(current);
747 return false; 749 return false;
748 } 750 }
749 } 751 }
750 setAccountbyIndex(current); 752 setAccountbyIndex(current);
751 return true; 753 return true;
752} 754}
753 755
754 756
755bool PPPData::deleteAccount() { 757bool PPPData::deleteAccount() {
756 //FIXME: 758 //FIXME: PPPData::deleteAccount
757// if(caccount < 0) 759// if(caccount < 0)
758 return false; 760 return false;
759 761
760// QMap <QString, QString> map; 762// QMap <QString, QString> map;
761// QMap <QString, QString>::Iterator it; 763// QMap <QString, QString>::Iterator it;
762 764
763// // set all entries of the current account to "" 765// // set all entries of the current account to ""
764// map = config->entryMap(cgroup); 766// map = config->entryMap(cgroup);
765// it = map.begin(); 767// it = map.begin();
766// while (it != map.end()) { 768// while (it != map.end()) {
767// config->writeEntry(it.key(), ""); 769// config->writeEntry(it.key(), "");
768// it++; 770// it++;
@@ -817,25 +819,25 @@ int PPPData::newaccount() {
817// if(!config) open(); 819// if(!config) open();
818 if (highcount >= MAX_ACCOUNTS) return -1; 820 if (highcount >= MAX_ACCOUNTS) return -1;
819 821
820 highcount++; 822 highcount++;
821 setAccountbyIndex(highcount); 823 setAccountbyIndex(highcount);
822 824
823 setpppdArgumentDefaults(); 825 setpppdArgumentDefaults();
824 qDebug("PPPData::newaccount -> %i",caccount); 826 qDebug("PPPData::newaccount -> %i",caccount);
825 return caccount; 827 return caccount;
826} 828}
827 829
828int PPPData::copyaccount(int i) { 830int PPPData::copyaccount(int i) {
829// FIXME 831// FIXME: PPPData::copyaccount
830// if(highcount >= MAX_ACCOUNTS) 832// if(highcount >= MAX_ACCOUNTS)
831 return -1; 833 return -1;
832 834
833// setAccountbyIndex(i); 835// setAccountbyIndex(i);
834 836
835// QMap <QString, QString> map = config->entryMap(cgroup); 837// QMap <QString, QString> map = config->entryMap(cgroup);
836// QMap <QString, QString>::ConstIterator it = map.begin(); 838// QMap <QString, QString>::ConstIterator it = map.begin();
837 839
838// QString newname = i18n("%1_copy").arg(accname()); 840// QString newname = i18n("%1_copy").arg(accname());
839 841
840// newaccount(); 842// newaccount();
841 843
@@ -1267,30 +1269,32 @@ QMap<QString,QString> PPPData::getConfiguredInterfaces()
1267 acc = config.readEntry( ACOUNTS_ACC, "error" ); 1269 acc = config.readEntry( ACOUNTS_ACC, "error" );
1268 ifaces.insert( dev, acc ); 1270 ifaces.insert( dev, acc );
1269 } 1271 }
1270 1272
1271 return ifaces; 1273 return ifaces;
1272} 1274}
1273 1275
1274void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) 1276void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
1275{ 1277{
1276 QMap<QString,QString>::Iterator it; 1278 QMap<QString,QString>::Iterator it;
1277 int i = 0; 1279 int i = 0;
1278 Config cfg = config(); 1280 Config cfg = config();
1279 for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ 1281 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
1280 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i)); 1282 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
1281 cfg.writeEntry( ACOUNTS_DEV, it.key() ); 1283 cfg.writeEntry( ACOUNTS_DEV, it.key() );
1282 cfg.writeEntry( ACOUNTS_ACC, it.data() ); 1284 cfg.writeEntry( ACOUNTS_ACC, it.data() );
1285 qDebug("I %i",i);
1283 } 1286 }
1284 cfg.setGroup( ACCLIST_GRP ); 1287 cfg.setGroup( ACCLIST_GRP );
1288 qDebug("saved %i account settings", i);
1285 cfg.writeEntry( ACCOUNTS_COUNT, i ); 1289 cfg.writeEntry( ACCOUNTS_COUNT, i );
1286 1290
1287} 1291}
1288 1292
1289/** 1293/**
1290 * pppd's getword() function knows about escape characters. 1294 * pppd's getword() function knows about escape characters.
1291 * If we write the username and password to the secrets file 1295 * If we write the username and password to the secrets file
1292 * we'll therefore have to escape back slashes. 1296 * we'll therefore have to escape back slashes.
1293 */ 1297 */
1294QString PPPData::encodeWord(const QString &s) { 1298QString PPPData::encodeWord(const QString &s) {
1295 QString r = s; 1299 QString r = s;
1296 r.replace(QRegExp("\\"), "\\\\"); 1300 r.replace(QRegExp("\\"), "\\\\");