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.cpp54
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
57PPPData::PPPData() 57PPPData::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//
72bool PPPData::open() { 71bool 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
321void PPPData::setpppdTimeout(int n) { 320void PPPData::setpppdTimeout(int n) {
322 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); 321 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
323} 322}
324 323
325 324
326const QString PPPData::modemDevice() { 325const 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
331bool PPPData::setModemDevice(const QString &n) { 330bool 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
344const QString PPPData::flowcontrol() { 342const 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
806int PPPData::copyaccount(int i) { 804int 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
1213int PPPData::pppdError() const { 1211int PPPData::pppdError() const {
1214 return pppderror; 1212 return pppderror;
1215} 1213}
1216 1214
1217void PPPData::setpppdError(int err) { 1215void PPPData::setpppdError(int err) {
1218 pppderror = err; 1216 pppderror = err;
1219} 1217}
1220 1218
1221QString PPPData::modemGroup() 1219QString 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) { 1226QMap<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) { 1240void 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}