summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/pppdata.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp211
1 files changed, 108 insertions, 103 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
@@ -39,9 +39,22 @@
#include <assert.h>
-PPPData gpppdata;
+PPPData *PPPData::_data = 0;
+Config *PPPData::config = 0;
+PPPData* PPPData::data()
+{
+ if (!_data){
+ qDebug("PPPData::data() creates new Instance");
+ _data = new PPPData();
+ }
+ if (!_data->config){
+ qDebug("PPPData::data() opens conffile");
+ _data->open();
+ }
+ return _data;
+}
PPPData::PPPData()
- : config(0L),
+ : //config(0L),
highcount(-1), // start out with no entries
caccount(-1), // set the current account index also
@@ -57,23 +70,7 @@ PPPData::PPPData()
//
bool PPPData::open() {
-
- config = new Config("NetworkSetup");
- /*
- config = kapp->config();
-
- if (config->getConfigState() == KConfig::NoAccess) {
- KMessageBox::error(0L,
- i18n("The application-specific config file could not "
- "be opened in either read-write or read-only mode.\n"
- "The superuser might have to change its ownership "
- "by issuing the following command in your home directory:\n"
- "chown {YourUsername} .kde/share/config/kppprc"),
- kapp->name());
- return false;
- }
-
- // don't expand shell variables
- config->setDollarExpansion(false);
- */
+ qDebug("opening configfile NetworkSetupPPP");
+ if (config) return true;
+ config = new Config("NetworkSetupPPP");
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
@@ -105,5 +102,11 @@ void PPPData::save() {
if (config) {
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
-// config->sync();
+ delete config;
+ config = 0;
+ qDebug("worte confi NetworkSetupPPP");
+ }
+ if (_data){
+ delete _data;
+ _data = 0;
}
@@ -124,9 +127,9 @@ void PPPData::cancel() {
-// currently differentiates between READWRITE and NONE only
-int PPPData::access() const {
+// // currently differentiates between READWRITE and NONE only
+// int PPPData::access() const {
- return 0;//config->getConfigState();
-}
+// return 1;//config->getConfigState();
+// }
@@ -135,4 +138,5 @@ QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
+// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
if (config) {
config->setGroup(group);
@@ -719,5 +723,6 @@ bool PPPData::isUniqueAccname(const QString &n) {
bool PPPData::deleteAccount() {
- if(caccount < 0)
+ //FIXME:
+// if(caccount < 0)
return false;
@@ -725,6 +730,5 @@ bool PPPData::deleteAccount() {
// QMap <QString, QString>::Iterator it;
- // set all entries of the current account to ""
-// tille: do not handle the accounts here... (?)
+// // set all entries of the current account to ""
// map = config->entryMap(cgroup);
// it = map.begin();
@@ -757,11 +761,11 @@ bool PPPData::deleteAccount() {
// }
- highcount--;
- if(caccount > highcount)
- caccount = highcount;
+// highcount--;
+// if(caccount > highcount)
+// caccount = highcount;
- setAccountbyIndex(caccount);
+// setAccountbyIndex(caccount);
- return true;
+// return true;
}
@@ -779,6 +783,7 @@ bool PPPData::deleteAccount(const QString &aname) {
int PPPData::newaccount() {
- if(!config || highcount >= MAX_ACCOUNTS)
- return -1;
+ qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
+ if(!config) open();
+ if (highcount >= MAX_ACCOUNTS) return -1;
highcount++;
@@ -786,5 +791,5 @@ int PPPData::newaccount() {
setpppdArgumentDefaults();
-
+ qDebug("PPPData::newaccount -> %i",caccount);
return caccount;
}
@@ -792,15 +797,15 @@ int PPPData::newaccount() {
int PPPData::copyaccount(int i) {
- if(highcount >= MAX_ACCOUNTS)
+// if(highcount >= MAX_ACCOUNTS)
return -1;
- setAccountbyIndex(i);
+// setAccountbyIndex(i);
// QMap <QString, QString> map = config->entryMap(cgroup);
// QMap <QString, QString>::ConstIterator it = map.begin();
- QString newname = i18n("%1_copy").arg(accname());
+// QString newname = i18n("%1_copy").arg(accname());
- newaccount();
+// newaccount();
// while (it != map.end()) {
@@ -809,7 +814,7 @@ int PPPData::copyaccount(int i) {
// }
- setAccname(newname);
+// setAccname(newname);
- return caccount;
+// return caccount;
}
@@ -830,5 +835,5 @@ void PPPData::setAccname(const QString &n) {
-#define SEPARATOR_CHAR ':'
+#define SEPARATOR_CHAR '&'
QStringList &PPPData::phonenumbers() {
@@ -1012,5 +1017,5 @@ void PPPData::setDefaultroute(bool set) {
bool PPPData::autoDNS() {
bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
- return (set && gpppdata.pppdVersionMin(2, 3, 7));
+ return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
}
@@ -1140,47 +1145,47 @@ void PPPData::setpppdArgumentDefaults() {
-// graphing widget
-void PPPData::setGraphingOptions(bool enable,
- QColor bg,
- QColor text,
- QColor in,
- QColor out)
-{
- if(config) {
- config->setGroup(GRAPH_GRP);
- config->writeEntry(GENABLED, enable);
-// config->writeEntry(GCOLOR_BG, bg);
-// config->writeEntry(GCOLOR_TEXT, text);
-// config->writeEntry(GCOLOR_IN, in);
-// config->writeEntry(GCOLOR_OUT, out);
- }
-}
+// // graphing widget
+// void PPPData::setGraphingOptions(bool enable,
+// QColor bg,
+// QColor text,
+// QColor in,
+// QColor out)
+// {
+// if(config) {
+// config->setGroup(GRAPH_GRP);
+// config->writeEntry(GENABLED, enable);
+// // config->writeEntry(GCOLOR_BG, bg);
+// // config->writeEntry(GCOLOR_TEXT, text);
+// // config->writeEntry(GCOLOR_IN, in);
+// // config->writeEntry(GCOLOR_OUT, out);
+// }
+// }
-void PPPData::graphingOptions(bool &enable,
- QColor &bg,
- QColor &text,
- QColor &in,
- QColor &out)
-{
- QColor c;
+// void PPPData::graphingOptions(bool &enable,
+// QColor &bg,
+// QColor &text,
+// QColor &in,
+// QColor &out)
+// {
+// QColor c;
- if(config) {
- config->setGroup(GRAPH_GRP);
- enable = config->readBoolEntry(GENABLED, true);
- bg = Qt::white;
- //bg = config->readColorEntry(GCOLOR_BG, &c);
- text = Qt::black;
- //text = config->readColorEntry(GCOLOR_TEXT, &c);
- in = Qt::blue;
- //in = config->readColorEntry(GCOLOR_IN, &c);
- out = Qt::red;
- //out = config->readColorEntry(GCOLOR_OUT, &c);
- }
-}
+// if(config) {
+// config->setGroup(GRAPH_GRP);
+// enable = config->readBoolEntry(GENABLED, true);
+// bg = Qt::white;
+// //bg = config->readColorEntry(GCOLOR_BG, &c);
+// text = Qt::black;
+// //text = config->readColorEntry(GCOLOR_TEXT, &c);
+// in = Qt::blue;
+// //in = config->readColorEntry(GCOLOR_IN, &c);
+// out = Qt::red;
+// //out = config->readColorEntry(GCOLOR_OUT, &c);
+// }
+// }
-bool PPPData::graphingEnabled() {
- return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
-}
+// bool PPPData::graphingEnabled() {
+// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
+// }
@@ -1206,24 +1211,24 @@ void PPPData::setpppdError(int err) {
-//
-// window position
-//
-void PPPData::winPosConWin(int& p_x, int& p_y) {
- p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
- p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
-}
+// //
+// // window position
+// //
+// void PPPData::winPosConWin(int& p_x, int& p_y) {
+// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
+// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
+// }
-void PPPData::setWinPosConWin(int p_x, int p_y) {
- writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
- writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
-}
+// void PPPData::setWinPosConWin(int p_x, int p_y) {
+// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
+// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
+// }
-void PPPData::winPosStatWin(int& p_x, int& p_y) {
- p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
- p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
-}
+// void PPPData::winPosStatWin(int& p_x, int& p_y) {
+// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
+// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
+// }
-void PPPData::setWinPosStatWin(int p_x, int p_y) {
- writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
- writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
-}
+// void PPPData::setWinPosStatWin(int p_x, int p_y) {
+// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
+// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
+// }