author | tille <tille> | 2003-05-25 18:19:04 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-25 18:19:04 (UTC) |
commit | 2ec401058a04c15d2725c94d38226d0ac4505496 (patch) (unidiff) | |
tree | bbe34da6b452cb01f31e5a08acf114c8c9641c32 /noncore/settings/networksettings/ppp/pppdata.cpp | |
parent | 7e1dce1560e45ef7fad91a8da2d0d96c1b166df9 (diff) | |
download | opie-2ec401058a04c15d2725c94d38226d0ac4505496.zip opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.gz opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.bz2 |
saves configured interfaces now
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 109e3b7..3f1675c 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -46,31 +46,30 @@ PPPData* PPPData::data() | |||
46 | if (!_data){ | 46 | if (!_data){ |
47 | qDebug("PPPData::data() creates new Instance"); | 47 | qDebug("PPPData::data() creates new Instance"); |
48 | _data = new PPPData(); | 48 | _data = new PPPData(); |
49 | } | 49 | } |
50 | if (!_data->config){ | 50 | if (!_data->config){ |
51 | qDebug("PPPData::data() opens conffile"); | 51 | qDebug("PPPData::data() opens conffile"); |
52 | _data->open(); | 52 | _data->open(); |
53 | } | 53 | } |
54 | return _data; | 54 | return _data; |
55 | } | 55 | } |
56 | 56 | ||
57 | PPPData::PPPData() | 57 | PPPData::PPPData() |
58 | : //config(0L), | 58 | : modemDeviceGroup(-1), |
59 | highcount(-1), // start out with no entries | 59 | highcount(-1), // start out with no entries |
60 | caccount(-1), // set the current account index also | 60 | caccount(-1), // set the current account index also |
61 | suidprocessid(-1), // process ID of setuid child | 61 | suidprocessid(-1), // process ID of setuid child |
62 | pppdisrunning(false), | 62 | pppdisrunning(false), |
63 | pppderror(0), | 63 | pppderror(0) |
64 | modemDeviceGroup(-1) | ||
65 | { | 64 | { |
66 | } | 65 | } |
67 | 66 | ||
68 | 67 | ||
69 | // | 68 | // |
70 | // open configuration file | 69 | // open configuration file |
71 | // | 70 | // |
72 | bool PPPData::open() { | 71 | bool PPPData::open() { |
73 | qDebug("opening configfile NetworkSetupPPP"); | 72 | qDebug("opening configfile NetworkSetupPPP"); |
74 | if (config) return true; | 73 | if (config) return true; |
75 | config = new Config("NetworkSetupPPP"); | 74 | config = new Config("NetworkSetupPPP"); |
76 | 75 | ||
@@ -320,25 +319,24 @@ int PPPData::pppdTimeout() { | |||
320 | 319 | ||
321 | void PPPData::setpppdTimeout(int n) { | 320 | void PPPData::setpppdTimeout(int n) { |
322 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 321 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
323 | } | 322 | } |
324 | 323 | ||
325 | 324 | ||
326 | const QString PPPData::modemDevice() { | 325 | const QString PPPData::modemDevice() { |
327 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 326 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
328 | } | 327 | } |
329 | 328 | ||
330 | 329 | ||
331 | bool PPPData::setModemDevice(const QString &n) { | 330 | bool PPPData::setModemDevice(const QString &n) { |
332 | //FIXME: change modem group | ||
333 | bool ret = false; | 331 | bool ret = false; |
334 | for (int i = 0; devices[i]; i++) | 332 | for (int i = 0; devices[i]; i++) |
335 | if (devices[i] == n){ | 333 | if (devices[i] == n){ |
336 | modemDeviceGroup = i; | 334 | modemDeviceGroup = i; |
337 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 335 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
338 | ret = true; | 336 | ret = true; |
339 | } | 337 | } |
340 | return ret; | 338 | return ret; |
341 | } | 339 | } |
342 | 340 | ||
343 | 341 | ||
344 | const QString PPPData::flowcontrol() { | 342 | const QString PPPData::flowcontrol() { |
@@ -795,25 +793,25 @@ int PPPData::newaccount() { | |||
795 | if(!config) open(); | 793 | if(!config) open(); |
796 | if (highcount >= MAX_ACCOUNTS) return -1; | 794 | if (highcount >= MAX_ACCOUNTS) return -1; |
797 | 795 | ||
798 | highcount++; | 796 | highcount++; |
799 | setAccountbyIndex(highcount); | 797 | setAccountbyIndex(highcount); |
800 | 798 | ||
801 | setpppdArgumentDefaults(); | 799 | setpppdArgumentDefaults(); |
802 | qDebug("PPPData::newaccount -> %i",caccount); | 800 | qDebug("PPPData::newaccount -> %i",caccount); |
803 | return caccount; | 801 | return caccount; |
804 | } | 802 | } |
805 | 803 | ||
806 | int PPPData::copyaccount(int i) { | 804 | int PPPData::copyaccount(int i) { |
807 | 805 | // FIXME | |
808 | // if(highcount >= MAX_ACCOUNTS) | 806 | // if(highcount >= MAX_ACCOUNTS) |
809 | return -1; | 807 | return -1; |
810 | 808 | ||
811 | // setAccountbyIndex(i); | 809 | // setAccountbyIndex(i); |
812 | 810 | ||
813 | // QMap <QString, QString> map = config->entryMap(cgroup); | 811 | // QMap <QString, QString> map = config->entryMap(cgroup); |
814 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 812 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
815 | 813 | ||
816 | // QString newname = i18n("%1_copy").arg(accname()); | 814 | // QString newname = i18n("%1_copy").arg(accname()); |
817 | 815 | ||
818 | // newaccount(); | 816 | // newaccount(); |
819 | 817 | ||
@@ -1212,37 +1210,43 @@ void PPPData::setpppdRunning(bool set) { | |||
1212 | 1210 | ||
1213 | int PPPData::pppdError() const { | 1211 | int PPPData::pppdError() const { |
1214 | return pppderror; | 1212 | return pppderror; |
1215 | } | 1213 | } |
1216 | 1214 | ||
1217 | void PPPData::setpppdError(int err) { | 1215 | void PPPData::setpppdError(int err) { |
1218 | pppderror = err; | 1216 | pppderror = err; |
1219 | } | 1217 | } |
1220 | 1218 | ||
1221 | QString PPPData::modemGroup() | 1219 | QString PPPData::modemGroup() |
1222 | { | 1220 | { |
1223 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); | 1221 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); |
1224 | return QString("MODEM_GRP_%1").arg(modemDeviceGroup); | 1222 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); |
1225 | } | 1223 | } |
1226 | 1224 | ||
1227 | // // | ||
1228 | // // window position | ||
1229 | // // | ||
1230 | // void PPPData::winPosConWin(int& p_x, int& p_y) { | ||
1231 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); | ||
1232 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); | ||
1233 | // } | ||
1234 | 1225 | ||
1235 | // void PPPData::setWinPosConWin(int p_x, int p_y) { | 1226 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1236 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); | 1227 | { |
1237 | // writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); | 1228 | QMap<QString,QString> ifaces; |
1238 | // } | 1229 | int count = readNumConfig( ACCLIST_GRP, ACCOUNTS_COUNT, -1 ); |
1230 | QString accGrp; | ||
1231 | for (int i = 0; i < count; i++){ | ||
1232 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | ||
1233 | ifaces.insert( readConfig( accGrp, ACOUNTS_DEV, "error" ), | ||
1234 | readConfig( accGrp, ACOUNTS_ACC, "error" ) ); | ||
1235 | } | ||
1239 | 1236 | ||
1240 | // void PPPData::winPosStatWin(int& p_x, int& p_y) { | 1237 | return ifaces; |
1241 | // p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); | 1238 | } |
1242 | // p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); | ||
1243 | // } | ||
1244 | 1239 | ||
1245 | // void PPPData::setWinPosStatWin(int p_x, int p_y) { | 1240 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1246 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); | 1241 | { |
1247 | // writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); | 1242 | QMap<QString,QString>::Iterator it; |
1248 | // } | 1243 | QString accGrp; |
1244 | int i = 0; | ||
1245 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ | ||
1246 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | ||
1247 | writeConfig( accGrp, ACOUNTS_DEV, it.key() ); | ||
1248 | writeConfig( accGrp, ACOUNTS_ACC, it.data() ); | ||
1249 | } | ||
1250 | writeConfig( ACCLIST_GRP, ACCOUNTS_COUNT, i ); | ||
1251 | |||
1252 | } | ||