summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/pppdata.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp229
1 files changed, 117 insertions, 112 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index f2386fc..646facd 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -40,7 +40,20 @@
40 40
41PPPData gpppdata; 41PPPData *PPPData::_data = 0;
42Config *PPPData::config = 0;
42 43
44PPPData* PPPData::data()
45{
46 if (!_data){
47 qDebug("PPPData::data() creates new Instance");
48 _data = new PPPData();
49 }
50 if (!_data->config){
51 qDebug("PPPData::data() opens conffile");
52 _data->open();
53 }
54 return _data;
55}
43 56
44PPPData::PPPData() 57PPPData::PPPData()
45 : config(0L), 58 : //config(0L),
46 highcount(-1), // start out with no entries 59 highcount(-1), // start out with no entries
@@ -58,21 +71,5 @@ PPPData::PPPData()
58bool PPPData::open() { 71bool PPPData::open() {
59 72 qDebug("opening configfile NetworkSetupPPP");
60 config = new Config("NetworkSetup"); 73 if (config) return true;
61 /* 74 config = new Config("NetworkSetupPPP");
62 config = kapp->config();
63
64 if (config->getConfigState() == KConfig::NoAccess) {
65 KMessageBox::error(0L,
66 i18n("The application-specific config file could not "
67 "be opened in either read-write or read-only mode.\n"
68 "The superuser might have to change its ownership "
69 "by issuing the following command in your home directory:\n"
70 "chown {YourUsername} .kde/share/config/kppprc"),
71 kapp->name());
72 return false;
73 }
74
75 // don't expand shell variables
76 config->setDollarExpansion(false);
77 */
78 75
@@ -106,3 +103,9 @@ void PPPData::save() {
106 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); 103 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
107// config->sync(); 104 delete config;
105 config = 0;
106 qDebug("worte confi NetworkSetupPPP");
107 }
108 if (_data){
109 delete _data;
110 _data = 0;
108 } 111 }
@@ -125,7 +128,7 @@ void PPPData::cancel() {
125 128
126// currently differentiates between READWRITE and NONE only 129// // currently differentiates between READWRITE and NONE only
127int PPPData::access() const { 130// int PPPData::access() const {
128 131
129 return 0;//config->getConfigState(); 132// return 1;//config->getConfigState();
130} 133// }
131 134
@@ -136,2 +139,3 @@ QString PPPData::readConfig(const QString &group, const QString &key,
136{ 139{
140// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
137 if (config) { 141 if (config) {
@@ -720,4 +724,5 @@ bool PPPData::isUniqueAccname(const QString &n) {
720bool PPPData::deleteAccount() { 724bool PPPData::deleteAccount() {
721 if(caccount < 0) 725 //FIXME:
722 return false; 726// if(caccount < 0)
727 return false;
723 728
@@ -726,4 +731,3 @@ bool PPPData::deleteAccount() {
726 731
727 // set all entries of the current account to "" 732// // set all entries of the current account to ""
728// tille: do not handle the accounts here... (?)
729// map = config->entryMap(cgroup); 733// map = config->entryMap(cgroup);
@@ -758,9 +762,9 @@ bool PPPData::deleteAccount() {
758 762
759 highcount--; 763// highcount--;
760 if(caccount > highcount) 764// if(caccount > highcount)
761 caccount = highcount; 765// caccount = highcount;
762 766
763 setAccountbyIndex(caccount); 767// setAccountbyIndex(caccount);
764 768
765 return true; 769// return true;
766} 770}
@@ -780,4 +784,5 @@ int PPPData::newaccount() {
780 784
781 if(!config || highcount >= MAX_ACCOUNTS) 785 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
782 return -1; 786 if(!config) open();
787 if (highcount >= MAX_ACCOUNTS) return -1;
783 788
@@ -787,3 +792,3 @@ int PPPData::newaccount() {
787 setpppdArgumentDefaults(); 792 setpppdArgumentDefaults();
788 793 qDebug("PPPData::newaccount -> %i",caccount);
789 return caccount; 794 return caccount;
@@ -793,22 +798,22 @@ int PPPData::copyaccount(int i) {
793 798
794 if(highcount >= MAX_ACCOUNTS) 799// if(highcount >= MAX_ACCOUNTS)
795 return -1; 800 return -1;
796 801
797 setAccountbyIndex(i); 802// setAccountbyIndex(i);
798 803
799// QMap <QString, QString> map = config->entryMap(cgroup); 804// QMap <QString, QString> map = config->entryMap(cgroup);
800// QMap <QString, QString>::ConstIterator it = map.begin(); 805// QMap <QString, QString>::ConstIterator it = map.begin();
801 806
802 QString newname = i18n("%1_copy").arg(accname()); 807// QString newname = i18n("%1_copy").arg(accname());
803 808
804 newaccount(); 809// newaccount();
805 810
806// while (it != map.end()) { 811// while (it != map.end()) {
807// config->writeEntry(it.key(), *it); 812// config->writeEntry(it.key(), *it);
808// it++; 813// it++;
809// } 814// }
810 815
811 setAccname(newname); 816// setAccname(newname);
812 817
813 return caccount; 818// return caccount;
814} 819}
@@ -831,3 +836,3 @@ void PPPData::setAccname(const QString &n) {
831 836
832#define SEPARATOR_CHAR ':' 837#define SEPARATOR_CHAR '&'
833QStringList &PPPData::phonenumbers() { 838QStringList &PPPData::phonenumbers() {
@@ -1013,3 +1018,3 @@ bool PPPData::autoDNS() {
1013 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); 1018 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
1014 return (set && gpppdata.pppdVersionMin(2, 3, 7)); 1019 return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
1015} 1020}
@@ -1141,45 +1146,45 @@ void PPPData::setpppdArgumentDefaults() {
1141 1146
1142// graphing widget 1147// // graphing widget
1143void PPPData::setGraphingOptions(bool enable, 1148// void PPPData::setGraphingOptions(bool enable,
1144 QColor bg, 1149 // QColor bg,
1145 QColor text, 1150 // QColor text,
1146 QColor in, 1151 // QColor in,
1147 QColor out) 1152 // QColor out)
1148{ 1153// {
1149 if(config) { 1154// if(config) {
1150 config->setGroup(GRAPH_GRP); 1155// config->setGroup(GRAPH_GRP);
1151 config->writeEntry(GENABLED, enable); 1156// config->writeEntry(GENABLED, enable);
1152// config->writeEntry(GCOLOR_BG, bg); 1157// // config->writeEntry(GCOLOR_BG, bg);
1153// config->writeEntry(GCOLOR_TEXT, text); 1158// // config->writeEntry(GCOLOR_TEXT, text);
1154// config->writeEntry(GCOLOR_IN, in); 1159// // config->writeEntry(GCOLOR_IN, in);
1155// config->writeEntry(GCOLOR_OUT, out); 1160// // config->writeEntry(GCOLOR_OUT, out);
1156 } 1161// }
1157} 1162// }
1158 1163
1159void PPPData::graphingOptions(bool &enable, 1164// void PPPData::graphingOptions(bool &enable,
1160 QColor &bg, 1165 // QColor &bg,
1161 QColor &text, 1166 // QColor &text,
1162 QColor &in, 1167 // QColor &in,
1163 QColor &out) 1168 // QColor &out)
1164{ 1169// {
1165 QColor c; 1170// QColor c;
1166 1171
1167 if(config) { 1172// if(config) {
1168 config->setGroup(GRAPH_GRP); 1173// config->setGroup(GRAPH_GRP);
1169 enable = config->readBoolEntry(GENABLED, true); 1174// enable = config->readBoolEntry(GENABLED, true);
1170 bg = Qt::white; 1175// bg = Qt::white;
1171 //bg = config->readColorEntry(GCOLOR_BG, &c); 1176// //bg = config->readColorEntry(GCOLOR_BG, &c);
1172 text = Qt::black; 1177// text = Qt::black;
1173 //text = config->readColorEntry(GCOLOR_TEXT, &c); 1178// //text = config->readColorEntry(GCOLOR_TEXT, &c);
1174 in = Qt::blue; 1179// in = Qt::blue;
1175 //in = config->readColorEntry(GCOLOR_IN, &c); 1180// //in = config->readColorEntry(GCOLOR_IN, &c);
1176 out = Qt::red; 1181// out = Qt::red;
1177 //out = config->readColorEntry(GCOLOR_OUT, &c); 1182// //out = config->readColorEntry(GCOLOR_OUT, &c);
1178 } 1183// }
1179} 1184// }
1180 1185
1181 1186
1182bool PPPData::graphingEnabled() { 1187// bool PPPData::graphingEnabled() {
1183 return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); 1188// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
1184} 1189// }
1185 1190
@@ -1207,23 +1212,23 @@ void PPPData::setpppdError(int err) {
1207 1212
1208// 1213// //
1209// window position 1214// // window position
1210// 1215// //
1211void PPPData::winPosConWin(int& p_x, int& p_y) { 1216// void PPPData::winPosConWin(int& p_x, int& p_y) {
1212 p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); 1217// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
1213 p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); 1218// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
1214} 1219// }
1215 1220
1216void PPPData::setWinPosConWin(int p_x, int p_y) { 1221// void PPPData::setWinPosConWin(int p_x, int p_y) {
1217 writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); 1222// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
1218 writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); 1223// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
1219} 1224// }
1220 1225
1221void PPPData::winPosStatWin(int& p_x, int& p_y) { 1226// void PPPData::winPosStatWin(int& p_x, int& p_y) {
1222 p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); 1227// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
1223 p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); 1228// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
1224} 1229// }
1225 1230
1226void PPPData::setWinPosStatWin(int p_x, int p_y) { 1231// void PPPData::setWinPosStatWin(int p_x, int p_y) {
1227 writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); 1232// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
1228 writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); 1233// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
1229} 1234// }