Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index f4727c1..567ccf8 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -47,26 +47,26 @@ PPPData::PPPData() | |||
47 | highcountdev(-1), // start out with no entries | 47 | highcountdev(-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 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; | 54 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; |
55 | Config cfg = config(); | 55 | Config cfg = config(); |
56 | cfg.setGroup(GENERAL_GRP); | 56 | cfg.setGroup(GENERAL_GRP); |
57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); | 57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); |
58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); | 58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); |
59 | qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1()); | 59 | odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl; |
60 | qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1()); | 60 | odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl; |
61 | 61 | ||
62 | // if (highcount > MAX_ACCOUNTS) | 62 | // if (highcount > MAX_ACCOUNTS) |
63 | // highcount = MAX_ACCOUNTS; | 63 | // highcount = MAX_ACCOUNTS; |
64 | 64 | ||
65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { | 65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { |
66 | // setAccountbyIndex(0); | 66 | // setAccountbyIndex(0); |
67 | // setDefaultAccount(accname()); | 67 | // setDefaultAccount(accname()); |
68 | // } else if(!setAccount(defaultAccount())) | 68 | // } else if(!setAccount(defaultAccount())) |
69 | setDefaultAccount(accname()); | 69 | setDefaultAccount(accname()); |
70 | 70 | ||
71 | // start out with internal debugging disabled | 71 | // start out with internal debugging disabled |
72 | // the user is still free to specify `debug' on his own | 72 | // the user is still free to specify `debug' on his own |
@@ -77,81 +77,81 @@ PPPData::PPPData() | |||
77 | } | 77 | } |
78 | 78 | ||
79 | Config PPPData::config() | 79 | Config PPPData::config() |
80 | { | 80 | { |
81 | return Config("NetworkSetupPPP"); | 81 | return Config("NetworkSetupPPP"); |
82 | } | 82 | } |
83 | 83 | ||
84 | // | 84 | // |
85 | // save configuration | 85 | // save configuration |
86 | // | 86 | // |
87 | void PPPData::save() | 87 | void PPPData::save() |
88 | { | 88 | { |
89 | qDebug("PPPData saving data"); | 89 | odebug << "PPPData saving data" << oendl; |
90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); | 91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); |
92 | QString key; | 92 | QString key; |
93 | QStringList keys; | 93 | QStringList keys; |
94 | Config cfg = config(); | 94 | Config cfg = config(); |
95 | cfg.setGroup(GENERAL_GRP); | 95 | cfg.setGroup(GENERAL_GRP); |
96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); | 96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); |
97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); | 97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); |
98 | 98 | ||
99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
100 | it != stringEntries.end(); ++it ){ | 100 | it != stringEntries.end(); ++it ){ |
101 | QString val = it.data(); | 101 | QString val = it.data(); |
102 | key = it.key(); | 102 | key = it.key(); |
103 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 103 | // odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl; |
104 | keys = QStringList::split( "SEPARATOR", key ); | 104 | keys = QStringList::split( "SEPARATOR", key ); |
105 | //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 105 | //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
106 | cfg.setGroup(keys[0]); | 106 | cfg.setGroup(keys[0]); |
107 | cfg.writeEntry(keys[1], val); | 107 | cfg.writeEntry(keys[1], val); |
108 | } | 108 | } |
109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
110 | it != intEntries.end(); ++it ){ | 110 | it != intEntries.end(); ++it ){ |
111 | int val = it.data(); | 111 | int val = it.data(); |
112 | key = it.key(); | 112 | key = it.key(); |
113 | // qDebug("saving %s -> %i", key.latin1(), val ); | 113 | // odebug << "saving " << key.latin1() << " -> " << val << "" << oendl; |
114 | keys = QStringList::split( "SEPARATOR", key ); | 114 | keys = QStringList::split( "SEPARATOR", key ); |
115 | //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 115 | //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl; |
116 | cfg.setGroup(keys[0]); | 116 | cfg.setGroup(keys[0]); |
117 | cfg.writeEntry(keys[1], val); | 117 | cfg.writeEntry(keys[1], val); |
118 | } | 118 | } |
119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
120 | it != listEntries.end(); ++it ){ | 120 | it != listEntries.end(); ++it ){ |
121 | QStringList val = it.data(); | 121 | QStringList val = it.data(); |
122 | key = it.key(); | 122 | key = it.key(); |
123 | QChar sep = sepEntries[key]; | 123 | QChar sep = sepEntries[key]; |
124 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 124 | // odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl; |
125 | keys = QStringList::split( "SEPARATOR", key ); | 125 | keys = QStringList::split( "SEPARATOR", key ); |
126 | cfg.setGroup(keys[0]); | 126 | cfg.setGroup(keys[0]); |
127 | cfg.writeEntry(keys[1], val, sep); | 127 | cfg.writeEntry(keys[1], val, sep); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | // | 132 | // |
133 | // cancel changes | 133 | // cancel changes |
134 | // | 134 | // |
135 | void PPPData::cancel() { | 135 | void PPPData::cancel() { |
136 | stringEntries.clear(); | 136 | stringEntries.clear(); |
137 | intEntries.clear(); | 137 | intEntries.clear(); |
138 | listEntries.clear(); | 138 | listEntries.clear(); |
139 | } | 139 | } |
140 | 140 | ||
141 | // functions to read/write date to configuration file | 141 | // functions to read/write date to configuration file |
142 | QString PPPData::readConfig(const QString &group, const QString &key, | 142 | QString PPPData::readConfig(const QString &group, const QString &key, |
143 | const QString &defvalue = "") | 143 | const QString &defvalue = "") |
144 | { | 144 | { |
145 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 145 | // odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl; |
146 | QString idx = SEP.arg(group).arg(key); | 146 | QString idx = SEP.arg(group).arg(key); |
147 | if (stringEntries.find(idx) != stringEntries.end()) | 147 | if (stringEntries.find(idx) != stringEntries.end()) |
148 | return stringEntries[idx]; | 148 | return stringEntries[idx]; |
149 | Config cfg = config(); | 149 | Config cfg = config(); |
150 | cfg.setGroup(group); | 150 | cfg.setGroup(group); |
151 | return cfg.readEntry(key, defvalue); | 151 | return cfg.readEntry(key, defvalue); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | int PPPData::readNumConfig(const QString &group, const QString &key, | 155 | int PPPData::readNumConfig(const QString &group, const QString &key, |
156 | int defvalue) | 156 | int defvalue) |
157 | { | 157 | { |
@@ -356,39 +356,39 @@ void PPPData::setpppdTimeout(int n) { | |||
356 | 356 | ||
357 | const QString PPPData::modemDevice() { | 357 | const QString PPPData::modemDevice() { |
358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); | 358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | // const QString PPPData::modemName() | 362 | // const QString PPPData::modemName() |
363 | // { | 363 | // { |
364 | // return readConfig(modemGroup(), MODEMNAME_KEY); | 364 | // return readConfig(modemGroup(), MODEMNAME_KEY); |
365 | // } | 365 | // } |
366 | 366 | ||
367 | // bool PPPData::setModemName(const QString &n) { | 367 | // bool PPPData::setModemName(const QString &n) { |
368 | // qDebug("Setting modem name to >%s<", n.latin1()); | 368 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
369 | // _modemName = n; | 369 | // _modemName = n; |
370 | // writeConfig(cgroup, MODEMNAME_KEY, n); | 370 | // writeConfig(cgroup, MODEMNAME_KEY, n); |
371 | // return true; //FIXME | 371 | // return true; //FIXME |
372 | // } | 372 | // } |
373 | 373 | ||
374 | // bool PPPData::changeModemName(const QString &n) { | 374 | // bool PPPData::changeModemName(const QString &n) { |
375 | // qDebug("Setting modem name to >%s<", n.latin1()); | 375 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
376 | // _modemName = n; | 376 | // _modemName = n; |
377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); | 377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); |
378 | // return true; //FIXME | 378 | // return true; //FIXME |
379 | // } | 379 | // } |
380 | 380 | ||
381 | bool PPPData::setModemDevice(const QString &n) { | 381 | bool PPPData::setModemDevice(const QString &n) { |
382 | qDebug("Setting modem dev to >%s<", n.latin1()); | 382 | odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; |
383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
384 | return true; //FIXME | 384 | return true; //FIXME |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | const QString PPPData::flowcontrol() { | 388 | const QString PPPData::flowcontrol() { |
389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void PPPData::setFlowcontrol(const QString &n) { | 393 | void PPPData::setFlowcontrol(const QString &n) { |
394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
@@ -730,80 +730,80 @@ void PPPData::setEnter(const QString &n) { | |||
730 | 730 | ||
731 | // | 731 | // |
732 | // functions to set/return account information | 732 | // functions to set/return account information |
733 | // | 733 | // |
734 | 734 | ||
735 | //returns number of accounts | 735 | //returns number of accounts |
736 | int PPPData::count() const { | 736 | int PPPData::count() const { |
737 | return highcount + 1; | 737 | return highcount + 1; |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | bool PPPData::setAccount(const QString &aname) { | 741 | bool PPPData::setAccount(const QString &aname) { |
742 | qDebug("setting account to >%s<", aname.latin1()); | 742 | odebug << "setting account to >" << aname.latin1() << "<" << oendl; |
743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
744 | cgroup = *it; | 744 | cgroup = *it; |
745 | qDebug("PPPData::setAccount %s", cgroup.latin1()); | 745 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
746 | qDebug( "iterator %s", (*it).latin1() ); | 746 | odebug << "iterator " << (*it).latin1() << "" << oendl; |
747 | if(accname() == aname) { | 747 | if(accname() == aname) { |
748 | qDebug("SUCCESS"); | 748 | odebug << "SUCCESS" << oendl; |
749 | return true; | 749 | return true; |
750 | } | 750 | } |
751 | 751 | ||
752 | } | 752 | } |
753 | qDebug("FAILURE"); | 753 | odebug << "FAILURE" << oendl; |
754 | return false; | 754 | return false; |
755 | } | 755 | } |
756 | 756 | ||
757 | /* | 757 | /* |
758 | bool PPPData::setAccountbyIndex(int i) { | 758 | bool PPPData::setAccountbyIndex(int i) { |
759 | if(i >= 0 && i <= highcount) { | 759 | if(i >= 0 && i <= highcount) { |
760 | QString tmp; | 760 | QString tmp; |
761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); | 761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); |
762 | if (_deleted.find(tmp)!=_deleted.end()) return false; | 762 | if (_deleted.find(tmp)!=_deleted.end()) return false; |
763 | caccount = i; | 763 | caccount = i; |
764 | cgroup = tmp; | 764 | cgroup = tmp; |
765 | return true; | 765 | return true; |
766 | } | 766 | } |
767 | return false; | 767 | return false; |
768 | } | 768 | } |
769 | */ | 769 | */ |
770 | 770 | ||
771 | bool PPPData::isUniqueAccname(const QString &n) { | 771 | bool PPPData::isUniqueAccname(const QString &n) { |
772 | QString save_cgroup = cgroup; | 772 | QString save_cgroup = cgroup; |
773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
774 | cgroup = *it; | 774 | cgroup = *it; |
775 | qDebug("PPPData::setAccount %s", cgroup.latin1()); | 775 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
776 | qDebug( "%s \n", (*it).latin1() ); | 776 | odebug << "" << (*it).latin1() << " \n" << oendl; |
777 | if(accname() == n && cgroup != save_cgroup) { | 777 | if(accname() == n && cgroup != save_cgroup) { |
778 | cgroup = save_cgroup; | 778 | cgroup = save_cgroup; |
779 | qDebug("SUCCESS"); | 779 | odebug << "SUCCESS" << oendl; |
780 | return false; | 780 | return false; |
781 | } | 781 | } |
782 | 782 | ||
783 | } | 783 | } |
784 | cgroup = save_cgroup; | 784 | cgroup = save_cgroup; |
785 | return true; | 785 | return true; |
786 | } | 786 | } |
787 | 787 | ||
788 | 788 | ||
789 | bool PPPData::isUniqueDevname(const QString &n) { | 789 | bool PPPData::isUniqueDevname(const QString &n) { |
790 | QString save_mName = _modemName; | 790 | QString save_mName = _modemName; |
791 | qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1()); | 791 | odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; |
792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
793 | _modemName = *it; | 793 | _modemName = *it; |
794 | qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1()); | 794 | odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; |
795 | if(devname() == n && _modemName != save_mName) { | 795 | if(devname() == n && _modemName != save_mName) { |
796 | _modemName = save_mName; | 796 | _modemName = save_mName; |
797 | qDebug("NOT UNIQUE"); | 797 | odebug << "NOT UNIQUE" << oendl; |
798 | return false; | 798 | return false; |
799 | } | 799 | } |
800 | 800 | ||
801 | } | 801 | } |
802 | _modemName = save_mName; | 802 | _modemName = save_mName; |
803 | return true; | 803 | return true; |
804 | } | 804 | } |
805 | 805 | ||
806 | 806 | ||
807 | bool PPPData::deleteAccount() { | 807 | bool PPPData::deleteAccount() { |
808 | // FIXME: check if this account exists in a config... | 808 | // FIXME: check if this account exists in a config... |
809 | Config cfg = PPPData::config(); | 809 | Config cfg = PPPData::config(); |
@@ -811,74 +811,74 @@ bool PPPData::deleteAccount() { | |||
811 | cfg.clearGroup(); | 811 | cfg.clearGroup(); |
812 | accountList.remove(cgroup); | 812 | accountList.remove(cgroup); |
813 | 813 | ||
814 | QString key; | 814 | QString key; |
815 | QStringList keys; | 815 | QStringList keys; |
816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
817 | it != stringEntries.end(); ++it ){ | 817 | it != stringEntries.end(); ++it ){ |
818 | QString val = it.data(); | 818 | QString val = it.data(); |
819 | key = it.key(); | 819 | key = it.key(); |
820 | keys = QStringList::split( "SEPARATOR", key ); | 820 | keys = QStringList::split( "SEPARATOR", key ); |
821 | if(keys[0]==cgroup){ | 821 | if(keys[0]==cgroup){ |
822 | stringEntries.remove( it ); | 822 | stringEntries.remove( it ); |
823 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 823 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
824 | } | 824 | } |
825 | } | 825 | } |
826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
827 | it != intEntries.end(); ++it ){ | 827 | it != intEntries.end(); ++it ){ |
828 | int val = it.data(); | 828 | int val = it.data(); |
829 | key = it.key(); | 829 | key = it.key(); |
830 | keys = QStringList::split( "SEPARATOR", key ); | 830 | keys = QStringList::split( "SEPARATOR", key ); |
831 | if(keys[0]==cgroup){ | 831 | if(keys[0]==cgroup){ |
832 | intEntries.remove( it ); | 832 | intEntries.remove( it ); |
833 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | 833 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; |
834 | } | 834 | } |
835 | } | 835 | } |
836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
837 | it != listEntries.end(); ++it ){ | 837 | it != listEntries.end(); ++it ){ |
838 | QStringList val = it.data(); | 838 | QStringList val = it.data(); |
839 | key = it.key(); | 839 | key = it.key(); |
840 | if(keys[0]==cgroup){ | 840 | if(keys[0]==cgroup){ |
841 | listEntries.remove( it ); | 841 | listEntries.remove( it ); |
842 | sepEntries.remove( key ); | 842 | sepEntries.remove( key ); |
843 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | 843 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; |
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | return true; | 847 | return true; |
848 | } | 848 | } |
849 | 849 | ||
850 | 850 | ||
851 | bool PPPData::deleteAccount(const QString &aname) { | 851 | bool PPPData::deleteAccount(const QString &aname) { |
852 | if(!setAccount(aname)) | 852 | if(!setAccount(aname)) |
853 | return false; | 853 | return false; |
854 | 854 | ||
855 | deleteAccount(); | 855 | deleteAccount(); |
856 | 856 | ||
857 | return true; | 857 | return true; |
858 | } | 858 | } |
859 | 859 | ||
860 | 860 | ||
861 | int PPPData::newaccount() { | 861 | int PPPData::newaccount() { |
862 | 862 | ||
863 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 863 | odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl; |
864 | // if(!config) open(); | 864 | // if(!config) open(); |
865 | // if (highcount >= MAX_ACCOUNTS) return -1; | 865 | // if (highcount >= MAX_ACCOUNTS) return -1; |
866 | 866 | ||
867 | 867 | ||
868 | QString tmp; | 868 | QString tmp; |
869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); | 869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); |
870 | cgroup = QString(tmp); | 870 | cgroup = QString(tmp); |
871 | accountList << tmp; | 871 | accountList << tmp; |
872 | qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1()); | 872 | odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl; |
873 | setpppdArgumentDefaults(); | 873 | setpppdArgumentDefaults(); |
874 | return highcount; | 874 | return highcount; |
875 | } | 875 | } |
876 | 876 | ||
877 | int PPPData::copyaccount(const QString&) { | 877 | int PPPData::copyaccount(const QString&) { |
878 | // FIXME: PPPData::copyaccount | 878 | // FIXME: PPPData::copyaccount |
879 | // if(highcount >= MAX_ACCOUNTS) | 879 | // if(highcount >= MAX_ACCOUNTS) |
880 | return -1; | 880 | return -1; |
881 | 881 | ||
882 | // setAccountbyIndex(i); | 882 | // setAccountbyIndex(i); |
883 | 883 | ||
884 | // QMap <QString, QString> map = config->entryMap(cgroup); | 884 | // QMap <QString, QString> map = config->entryMap(cgroup); |
@@ -956,27 +956,27 @@ void PPPData::setAuthMethod(int value) { | |||
956 | 956 | ||
957 | const QString PPPData::storedUsername() { | 957 | const QString PPPData::storedUsername() { |
958 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 958 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
959 | } | 959 | } |
960 | 960 | ||
961 | 961 | ||
962 | void PPPData::setStoredUsername(const QString &b) { | 962 | void PPPData::setStoredUsername(const QString &b) { |
963 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 963 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
964 | } | 964 | } |
965 | 965 | ||
966 | 966 | ||
967 | const QString PPPData::storedPassword() { | 967 | const QString PPPData::storedPassword() { |
968 | qDebug("getting stored pw"); | 968 | odebug << "getting stored pw" << oendl; |
969 | qDebug("g %s", cgroup.latin1() ); | 969 | odebug << "g " << cgroup.latin1() << "" << oendl; |
970 | qDebug("k %s", STORED_PASSWORD_KEY); | 970 | odebug << "k " << STORED_PASSWORD_KEY << "" << oendl; |
971 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 971 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
972 | } | 972 | } |
973 | 973 | ||
974 | 974 | ||
975 | void PPPData::setStoredPassword(const QString &b) { | 975 | void PPPData::setStoredPassword(const QString &b) { |
976 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 976 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
977 | } | 977 | } |
978 | 978 | ||
979 | 979 | ||
980 | bool PPPData::storePassword() { | 980 | bool PPPData::storePassword() { |
981 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 981 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
982 | } | 982 | } |
@@ -1320,28 +1320,28 @@ QMap<QString,QString> PPPData::getConfiguredInterfaces() | |||
1320 | return ifaces; | 1320 | return ifaces; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1323 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1324 | { | 1324 | { |
1325 | QMap<QString,QString>::Iterator it; | 1325 | QMap<QString,QString>::Iterator it; |
1326 | int i = 0; | 1326 | int i = 0; |
1327 | Config cfg = config(); | 1327 | Config cfg = config(); |
1328 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 1328 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
1329 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); | 1329 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); |
1330 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); | 1330 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1331 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1331 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1332 | qDebug("I %i",i); | 1332 | odebug << "I " << i << "" << oendl; |
1333 | } | 1333 | } |
1334 | cfg.setGroup( ACCLIST_GRP ); | 1334 | cfg.setGroup( ACCLIST_GRP ); |
1335 | qDebug("saved %i account settings", i); | 1335 | odebug << "saved " << i << " account settings" << oendl; |
1336 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1336 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1337 | 1337 | ||
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | /** | 1340 | /** |
1341 | * pppd's getword() function knows about escape characters. | 1341 | * pppd's getword() function knows about escape characters. |
1342 | * If we write the username and password to the secrets file | 1342 | * If we write the username and password to the secrets file |
1343 | * we'll therefore have to escape back slashes. | 1343 | * we'll therefore have to escape back slashes. |
1344 | */ | 1344 | */ |
1345 | QString PPPData::encodeWord(const QString &s) { | 1345 | QString PPPData::encodeWord(const QString &s) { |
1346 | QString r = s; | 1346 | QString r = s; |
1347 | r.replace(QRegExp("\\"), "\\\\"); | 1347 | r.replace(QRegExp("\\"), "\\\\"); |
@@ -1363,133 +1363,133 @@ QStringList PPPData::getAccountList() | |||
1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
1364 | cgroup = *it; | 1364 | cgroup = *it; |
1365 | list << accname(); | 1365 | list << accname(); |
1366 | } | 1366 | } |
1367 | cgroup = save_cgroup; | 1367 | cgroup = save_cgroup; |
1368 | return list; | 1368 | return list; |
1369 | }; | 1369 | }; |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | const QString PPPData::devname() | 1372 | const QString PPPData::devname() |
1373 | { | 1373 | { |
1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); | 1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); |
1375 | qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1()); | 1375 | odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl; |
1376 | return tmp; | 1376 | return tmp; |
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | void PPPData::setDevname(const QString &n) { | 1379 | void PPPData::setDevname(const QString &n) { |
1380 | // if(!cgroup.isNull()) { | 1380 | // if(!cgroup.isNull()) { |
1381 | // // are we manipulating the default account's name ? then change it, too. | 1381 | // // are we manipulating the default account's name ? then change it, too. |
1382 | // bool def = accname() == defaultAccount(); | 1382 | // bool def = accname() == defaultAccount(); |
1383 | // writeConfig(cgroup, NAME_KEY, n); | 1383 | // writeConfig(cgroup, NAME_KEY, n); |
1384 | // if (def) | 1384 | // if (def) |
1385 | // setDefaultAccount(n); | 1385 | // setDefaultAccount(n); |
1386 | // } | 1386 | // } |
1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); | 1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | 1390 | ||
1391 | bool PPPData::setDevice(const QString &dev ) | 1391 | bool PPPData::setDevice(const QString &dev ) |
1392 | { | 1392 | { |
1393 | qDebug("setting device to >%s<", dev.latin1()); | 1393 | odebug << "setting device to >" << dev.latin1() << "<" << oendl; |
1394 | QString save_mName = _modemName; | 1394 | QString save_mName = _modemName; |
1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
1396 | _modemName = *it; | 1396 | _modemName = *it; |
1397 | qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() ); | 1397 | odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl; |
1398 | qDebug( "iterator %s", (*it).latin1() ); | 1398 | odebug << "iterator " << (*it).latin1() << "" << oendl; |
1399 | if(devname() == dev) { | 1399 | if(devname() == dev) { |
1400 | qDebug("SUCCESS"); | 1400 | odebug << "SUCCESS" << oendl; |
1401 | return true; | 1401 | return true; |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | } | 1404 | } |
1405 | _modemName = save_mName; | 1405 | _modemName = save_mName; |
1406 | qDebug("FAILURE"); | 1406 | odebug << "FAILURE" << oendl; |
1407 | return false; | 1407 | return false; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | bool PPPData::deleteDevice() | 1410 | bool PPPData::deleteDevice() |
1411 | { | 1411 | { |
1412 | // FIXME: check if this account exists in a config... | 1412 | // FIXME: check if this account exists in a config... |
1413 | Config cfg = PPPData::config(); | 1413 | Config cfg = PPPData::config(); |
1414 | cfg.setGroup(modemGroup()); | 1414 | cfg.setGroup(modemGroup()); |
1415 | cfg.clearGroup(); | 1415 | cfg.clearGroup(); |
1416 | deviceList.remove(modemGroup()); | 1416 | deviceList.remove(modemGroup()); |
1417 | 1417 | ||
1418 | QString key; | 1418 | QString key; |
1419 | QStringList keys; | 1419 | QStringList keys; |
1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
1421 | it != stringEntries.end(); ++it ){ | 1421 | it != stringEntries.end(); ++it ){ |
1422 | QString val = it.data(); | 1422 | QString val = it.data(); |
1423 | key = it.key(); | 1423 | key = it.key(); |
1424 | keys = QStringList::split( "SEPARATOR", key ); | 1424 | keys = QStringList::split( "SEPARATOR", key ); |
1425 | if(keys[0]==modemGroup()){ | 1425 | if(keys[0]==modemGroup()){ |
1426 | stringEntries.remove( it ); | 1426 | stringEntries.remove( it ); |
1427 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 1427 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
1431 | it != intEntries.end(); ++it ){ | 1431 | it != intEntries.end(); ++it ){ |
1432 | int val = it.data(); | 1432 | int val = it.data(); |
1433 | key = it.key(); | 1433 | key = it.key(); |
1434 | keys = QStringList::split( "SEPARATOR", key ); | 1434 | keys = QStringList::split( "SEPARATOR", key ); |
1435 | if(keys[0]==modemGroup()){ | 1435 | if(keys[0]==modemGroup()){ |
1436 | intEntries.remove( it ); | 1436 | intEntries.remove( it ); |
1437 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | 1437 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
1441 | it != listEntries.end(); ++it ){ | 1441 | it != listEntries.end(); ++it ){ |
1442 | QStringList val = it.data(); | 1442 | QStringList val = it.data(); |
1443 | key = it.key(); | 1443 | key = it.key(); |
1444 | if(keys[0]==modemGroup()){ | 1444 | if(keys[0]==modemGroup()){ |
1445 | listEntries.remove( it ); | 1445 | listEntries.remove( it ); |
1446 | sepEntries.remove( key ); | 1446 | sepEntries.remove( key ); |
1447 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | 1447 | odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; |
1448 | } | 1448 | } |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | return true; | 1451 | return true; |
1452 | 1452 | ||
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | bool PPPData::deleteDevice(const QString &dev) | 1455 | bool PPPData::deleteDevice(const QString &dev) |
1456 | { | 1456 | { |
1457 | if(!setDevice(dev)) | 1457 | if(!setDevice(dev)) |
1458 | return false; | 1458 | return false; |
1459 | 1459 | ||
1460 | return deleteDevice(); | 1460 | return deleteDevice(); |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | int PPPData::newdevice() | 1463 | int PPPData::newdevice() |
1464 | { | 1464 | { |
1465 | 1465 | ||
1466 | qDebug("PPPData::newdevice highcount %i",highcountdev); | 1466 | odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl; |
1467 | 1467 | ||
1468 | 1468 | ||
1469 | QString tmp; | 1469 | QString tmp; |
1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); | 1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); |
1471 | _modemName = QString(tmp); | 1471 | _modemName = QString(tmp); |
1472 | deviceList << tmp; | 1472 | deviceList << tmp; |
1473 | qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1()); | 1473 | odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl; |
1474 | return highcountdev; | 1474 | return highcountdev; |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | int PPPData::copydevice(const QString&) | 1477 | int PPPData::copydevice(const QString&) |
1478 | { | 1478 | { |
1479 | return false; | 1479 | return false; |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | 1482 | ||
1483 | QStringList PPPData::getDevicesNamesList() | 1483 | QStringList PPPData::getDevicesNamesList() |
1484 | { | 1484 | { |
1485 | QStringList list; | 1485 | QStringList list; |
1486 | QString save_mName = _modemName; | 1486 | QString save_mName = _modemName; |
1487 | qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1()); | 1487 | odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl; |
1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
1489 | _modemName = *it; | 1489 | _modemName = *it; |
1490 | qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1()); | 1490 | odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl; |
1491 | list << devname(); | 1491 | list << devname(); |
1492 | } | 1492 | } |
1493 | _modemName = save_mName; | 1493 | _modemName = save_mName; |
1494 | return list; | 1494 | return list; |
1495 | }; | 1495 | }; |