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) (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 @@
-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
@@ -58,21 +71,5 @@ 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");
@@ -106,3 +103,9 @@ void PPPData::save() {
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
-// config->sync();
+ delete config;
+ config = 0;
+ qDebug("worte confi NetworkSetupPPP");
+ }
+ if (_data){
+ delete _data;
+ _data = 0;
}
@@ -125,7 +128,7 @@ 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();
+// }
@@ -136,2 +139,3 @@ QString PPPData::readConfig(const QString &group, const QString &key,
{
+// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
if (config) {
@@ -720,4 +724,5 @@ bool PPPData::isUniqueAccname(const QString &n) {
bool PPPData::deleteAccount() {
- if(caccount < 0)
- return false;
+ //FIXME:
+// if(caccount < 0)
+ return false;
@@ -726,4 +731,3 @@ bool PPPData::deleteAccount() {
- // 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);
@@ -758,9 +762,9 @@ bool PPPData::deleteAccount() {
- highcount--;
- if(caccount > highcount)
- caccount = highcount;
+// highcount--;
+// if(caccount > highcount)
+// caccount = highcount;
- setAccountbyIndex(caccount);
+// setAccountbyIndex(caccount);
- return true;
+// return true;
}
@@ -780,4 +784,5 @@ 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;
@@ -787,3 +792,3 @@ int PPPData::newaccount() {
setpppdArgumentDefaults();
-
+ qDebug("PPPData::newaccount -> %i",caccount);
return caccount;
@@ -793,22 +798,22 @@ 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();
+// 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()) {
-// config->writeEntry(it.key(), *it);
-// it++;
-// }
+// while (it != map.end()) {
+// config->writeEntry(it.key(), *it);
+// it++;
+// }
- setAccname(newname);
+// setAccname(newname);
- return caccount;
+// return caccount;
}
@@ -831,3 +836,3 @@ void PPPData::setAccname(const QString &n) {
-#define SEPARATOR_CHAR ':'
+#define SEPARATOR_CHAR '&'
QStringList &PPPData::phonenumbers() {
@@ -1013,3 +1018,3 @@ 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));
}
@@ -1141,45 +1146,45 @@ 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);
- }
-}
-
-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);
- }
-}
+// // 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;
+
+// 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);
+// }
@@ -1207,23 +1212,23 @@ 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);
+// }