summaryrefslogtreecommitdiff
authortille <tille>2003-05-25 18:19:04 (UTC)
committer tille <tille>2003-05-25 18:19:04 (UTC)
commit2ec401058a04c15d2725c94d38226d0ac4505496 (patch) (unidiff)
treebbe34da6b452cb01f31e5a08acf114c8c9641c32
parent7e1dce1560e45ef7fad91a8da2d0d96c1b166df9 (diff)
downloadopie-2ec401058a04c15d2725c94d38226d0ac4505496.zip
opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.gz
opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.bz2
saves configured interfaces now
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/TODO6
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp40
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp8
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp54
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h23
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp17
6 files changed, 74 insertions, 74 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO
new file mode 100644
index 0000000..2410880
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/TODO
@@ -0,0 +1,6 @@
1- impl. PPPData::copyaccount & PPPData::deleteAccount
2- update modem attribute inputs when modem has changed
3- fix layout of edit account
4- save pppd arguments in edit account
5- popup configure modem with the correct account prselected
6 not quite shure why it does not work... IMHO it should work
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 19db9ef..11d4739 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -32,73 +32,60 @@
32#include <qwhatsthis.h> 32#include <qwhatsthis.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34 34
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qbuttongroup.h> 36#include <qbuttongroup.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38//#include <klocale.h> 38//#include <klocale.h>
39#define i18n QObject::tr 39#define i18n QObject::tr
40//#include <kglobal.h> 40//#include <kglobal.h>
41//#include <kwin.h> 41//#include <kwin.h>
42//#include <kdialogbase.h> 42//#include <kdialogbase.h>
43#include <qvgroupbox.h> 43#include <qvgroupbox.h>
44 44
45#include "pppdata.h" 45#include "pppdata.h"
46#include "accounts.h" 46#include "accounts.h"
47//#include "accounting.h" 47//#include "accounting.h"
48//#include "providerdb.h" 48//#include "providerdb.h"
49#include "edit.h" 49#include "edit.h"
50 50
51void parseargs(char* buf, char** args); 51void parseargs(char* buf, char** args);
52 52
53AccountWidget::AccountWidget( QWidget *parent, const char *name ) 53AccountWidget::AccountWidget( QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name )
55{ 55{
56// int min = 0;
57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 56 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
58
59 // add a hbox
60// QHBoxLayout *l11 = new QHBoxLayout;
61// l1->addLayout(l11);
62
63 accountlist_l = new QListBox(this); 57 accountlist_l = new QListBox(this);
64// accountlist_l->setMinimumSize(160, 128); 58
65 connect(accountlist_l, SIGNAL(highlighted(int)), 59 connect(accountlist_l, SIGNAL(highlighted(int)),
66 this, SLOT(slotListBoxSelect(int))); 60 this, SLOT(slotListBoxSelect(int)));
67 connect(accountlist_l, SIGNAL(selected(int)), 61 connect(accountlist_l, SIGNAL(selected(int)),
68 this, SLOT(editaccount())); 62 this, SLOT(editaccount()));
69 l1->addWidget(accountlist_l, 10); 63 l1->addWidget(accountlist_l, 10);
70 64
71// QVBoxLayout *l111 = new QVBoxLayout(this);
72// l11->addLayout(l111, 1);
73 edit_b = new QPushButton(i18n("&Edit..."), this); 65 edit_b = new QPushButton(i18n("&Edit..."), this);
74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 66 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); 67 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
76
77// min = edit_b->sizeHint().width();
78// min = QMAX(70,min);
79// edit_b->setMinimumWidth(min);
80
81 l1->addWidget(edit_b); 68 l1->addWidget(edit_b);
82 69
83 new_b = new QPushButton(i18n("&New..."), this); 70 new_b = new QPushButton(i18n("&New..."), this);
84 connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); 71 connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
85 l1->addWidget(new_b); 72 l1->addWidget(new_b);
86 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" 73 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n"
87 "to the Internet")); 74 "to the Internet"));
88 75
89 copy_b = new QPushButton(i18n("Co&py"), this); 76 copy_b = new QPushButton(i18n("Co&py"), this);
90 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); 77 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
91 l1->addWidget(copy_b); 78 l1->addWidget(copy_b);
92 QWhatsThis::add(copy_b, 79 QWhatsThis::add(copy_b,
93 i18n("Makes a copy of the selected account. All\n" 80 i18n("Makes a copy of the selected account. All\n"
94 "settings of the selected account are copied\n" 81 "settings of the selected account are copied\n"
95 "to a new account, that you can modify to fit your\n" 82 "to a new account, that you can modify to fit your\n"
96 "needs")); 83 "needs"));
97 84
98 delete_b = new QPushButton(i18n("De&lete"), this); 85 delete_b = new QPushButton(i18n("De&lete"), this);
99 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); 86 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
100 l1->addWidget(delete_b); 87 l1->addWidget(delete_b);
101 QWhatsThis::add(delete_b, 88 QWhatsThis::add(delete_b,
102 i18n("<p>Deletes the selected account\n\n" 89 i18n("<p>Deletes the selected account\n\n"
103 "<font color=\"red\"><b>Use with care!</b></font>")); 90 "<font color=\"red\"><b>Use with care!</b></font>"));
104 91
@@ -151,80 +138,67 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
151// l12->addStretch(1); 138// l12->addStretch(1);
152// l12->addLayout(l122); 139// l12->addLayout(l122);
153 140
154// l122->addStretch(1); 141// l122->addStretch(1);
155// reset = new QPushButton(i18n("&Reset..."), parent); 142// reset = new QPushButton(i18n("&Reset..."), parent);
156// reset->setEnabled(FALSE); 143// reset->setEnabled(FALSE);
157// connect(reset, SIGNAL(clicked()), 144// connect(reset, SIGNAL(clicked()),
158 // this, SLOT(resetClicked())); 145 // this, SLOT(resetClicked()));
159// l122->addWidget(reset); 146// l122->addWidget(reset);
160 147
161// log = new QPushButton(i18n("&View Logs"), this); 148// log = new QPushButton(i18n("&View Logs"), this);
162// connect(log, SIGNAL(clicked()), 149// connect(log, SIGNAL(clicked()),
163 // this, SLOT(viewLogClicked())); 150 // this, SLOT(viewLogClicked()));
164// l122->addWidget(log); 151// l122->addWidget(log);
165// l122->addStretch(1); 152// l122->addStretch(1);
166 153
167 //load up account list from gppdata to the list box 154 //load up account list from gppdata to the list box
168 if(PPPData::data()->count() > 0) { 155 if(PPPData::data()->count() > 0) {
169 for(int i=0; i <= PPPData::data()->count()-1; i++) { 156 for(int i=0; i <= PPPData::data()->count()-1; i++) {
170 PPPData::data()->setAccountbyIndex(i); 157 PPPData::data()->setAccountbyIndex(i);
171 accountlist_l->insertItem(PPPData::data()->accname()); 158 accountlist_l->insertItem(PPPData::data()->accname());
172 } 159 }
173 } 160 }
174 161
175 slotListBoxSelect(accountlist_l->currentItem()); 162// slotListBoxSelect(accountlist_l->currentItem());
163 qDebug("setting listview index to %i",PPPData::data()->currentAccountID() );
164 accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() );
165// slotListBoxSelect( PPPData::data()->currentAccountID());
176 166
177 l1->activate(); 167 l1->activate();
178} 168}
179 169
180 170
181 171
182void AccountWidget::slotListBoxSelect(int idx) { 172void AccountWidget::slotListBoxSelect(int idx) {
183 delete_b->setEnabled((bool)(idx != -1)); 173 delete_b->setEnabled((bool)(idx != -1));
184 edit_b->setEnabled((bool)(idx != -1)); 174 edit_b->setEnabled((bool)(idx != -1));
185 copy_b->setEnabled((bool)(idx != -1)); 175 copy_b->setEnabled((bool)(idx != -1));
186 if(idx!=-1) { 176 if(idx!=-1) {
177 qDebug("setting account to %i", idx);
187 QString account = PPPData::data()->accname(); 178 QString account = PPPData::data()->accname();
188 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem()); 179 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
189// reset->setEnabled(TRUE); 180 // PPPData::data()->setAccount(account);
190// costlabel->setEnabled(TRUE);
191// costedit->setEnabled(TRUE);
192// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem())));
193
194// vollabel->setEnabled(TRUE);
195// voledit->setEnabled(TRUE);
196// int bytes = PPPData::data()->totalBytes();
197// voledit->setText(prettyPrintVolume(bytes));
198 PPPData::data()->setAccount(account);
199 } else{
200 // reset->setEnabled(FALSE);
201// costlabel->setEnabled(FALSE);
202// costedit->setText("");
203// costedit->setEnabled(FALSE);
204// vollabel->setEnabled(FALSE);
205// voledit->setText("");
206// voledit->setEnabled(FALSE);
207 } 181 }
208} 182}
209 183
210 184
211// void AccountWidget::viewLogClicked(){ 185// void AccountWidget::viewLogClicked(){
212 186
213// QApplication::flushX(); 187// QApplication::flushX();
214// if(fork() == 0) { 188// if(fork() == 0) {
215// setgid(getgid()); 189// setgid(getgid());
216// setuid(getuid()); 190// setuid(getuid());
217// system("kppplogview -kppp"); 191// system("kppplogview -kppp");
218// _exit(0); 192// _exit(0);
219// } 193// }
220// } 194// }
221 195
222 196
223// void AccountWidget::resetClicked(){ 197// void AccountWidget::resetClicked(){
224// if(accountlist_l->currentItem() == -1) 198// if(accountlist_l->currentItem() == -1)
225// return; 199// return;
226 200
227// // QueryReset dlg(this); 201// // QueryReset dlg(this);
228// // int what = dlg.exec(); 202// // int what = dlg.exec();
229 203
230// // if(what && QueryReset::COSTS) { 204// // if(what && QueryReset::COSTS) {
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index e2521a6..4c5f7aa 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -5,65 +5,73 @@
5 5
6#include "accounts.h" 6#include "accounts.h"
7#include "general.h" 7#include "general.h"
8#include "interface.h" 8#include "interface.h"
9#include "modem.h" 9#include "modem.h"
10#include "pppconfig.h" 10#include "pppconfig.h"
11#include "pppdata.h" 11#include "pppdata.h"
12#include "runtests.h" 12#include "runtests.h"
13 13
14PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent, 14PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent,
15 const char *name, 15 const char *name,
16 bool modal, WFlags fl ) 16 bool modal, WFlags fl )
17 : QDialog(parent, name, modal, fl) 17 : QDialog(parent, name, modal, fl)
18{ 18{
19 setCaption(tr("Configure Modem")); 19 setCaption(tr("Configure Modem"));
20 int result = runTests(); 20 int result = runTests();
21 if(result == TEST_CRITICAL){ 21 if(result == TEST_CRITICAL){
22 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); 22 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
23 return; 23 return;
24 } 24 }
25 25
26 interface = iface; 26 interface = iface;
27 if (!PPPData::data()->setModemDevice( interface->getInterfaceName() )) 27 if (!PPPData::data()->setModemDevice( interface->getInterfaceName() ))
28 PPPData::data()->setModemDevice("/dev/modem"); 28 PPPData::data()->setModemDevice("/dev/modem");
29 qDebug("PPPConfigWidget::PPPConfigWidget");
30 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
29 if (!PPPData::data()->setAccount( interface->getHardwareName() )) 31 if (!PPPData::data()->setAccount( interface->getHardwareName() ))
30 PPPData::data()->setAccount( 0 ); 32 PPPData::data()->setAccount( 0 );
33
34 qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1());
35 qDebug(" PPPData::data()->currentAccountID() >%i<",PPPData::data()->currentAccountID());
31 (void)new Modem; 36 (void)new Modem;
32 37
33 QVBoxLayout *layout = new QVBoxLayout( this ); 38 QVBoxLayout *layout = new QVBoxLayout( this );
34 layout->setSpacing( 0 ); 39 layout->setSpacing( 0 );
35 layout->setMargin( 1 ); 40 layout->setMargin( 1 );
36 tabWindow = new QTabWidget( this, "tabWidget" ); 41 tabWindow = new QTabWidget( this, "tabWidget" );
37 layout->addWidget( tabWindow ); 42 layout->addWidget( tabWindow );
38 43
39 accounts = new AccountWidget( tabWindow, "accounts" ); 44 accounts = new AccountWidget( tabWindow, "accounts" );
40 tabWindow->addTab( accounts, tr("&Accounts") ); 45 tabWindow->addTab( accounts, tr("&Accounts") );
41 modem1 = new ModemWidget( tabWindow, "modem1" ); 46 modem1 = new ModemWidget( tabWindow, "modem1" );
42 tabWindow->addTab( modem1, tr("&Device") ); 47 tabWindow->addTab( modem1, tr("&Device") );
43 modem2 = new ModemWidget2( tabWindow, "modem2" ); 48 modem2 = new ModemWidget2( tabWindow, "modem2" );
44 tabWindow->addTab( modem2, tr("&Modem") ); 49 tabWindow->addTab( modem2, tr("&Modem") );
45// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); 50// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
46// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); 51// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
47 52
48} 53}
49 54
50 55
51PPPConfigWidget::~PPPConfigWidget() 56PPPConfigWidget::~PPPConfigWidget()
52{ 57{
53 58
54} 59}
55 60
56void PPPConfigWidget::accept() 61void PPPConfigWidget::accept()
57{ 62{
63 qDebug("PPPConfigWidget::accept");
64 qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1());
65 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
58 interface->setInterfaceName( PPPData::data()->modemDevice() ); 66 interface->setInterfaceName( PPPData::data()->modemDevice() );
59 interface->setHardwareName( PPPData::data()->accname() ); 67 interface->setHardwareName( PPPData::data()->accname() );
60 PPPData::data()->save(); 68 PPPData::data()->save();
61 QDialog::accept(); 69 QDialog::accept();
62} 70}
63 71
64 72
65void PPPConfigWidget::reject() 73void PPPConfigWidget::reject()
66{ 74{
67 PPPData::data()->cancel(); 75 PPPData::data()->cancel();
68 QDialog::reject(); 76 QDialog::reject();
69} 77}
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
@@ -34,55 +34,54 @@
34#include <qapplication.h> 34#include <qapplication.h>
35// #include <klocale.h> 35// #include <klocale.h>
36// #include <kconfig.h> 36// #include <kconfig.h>
37// #include <kmessagebox.h> 37// #include <kmessagebox.h>
38// #include <kapplication.h> 38// #include <kapplication.h>
39#include <assert.h> 39#include <assert.h>
40 40
41PPPData *PPPData::_data = 0; 41PPPData *PPPData::_data = 0;
42Config *PPPData::config = 0; 42Config *PPPData::config = 0;
43 43
44PPPData* PPPData::data() 44PPPData* PPPData::data()
45{ 45{
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
77 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 76 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
78 77
79 if (highcount > MAX_ACCOUNTS) 78 if (highcount > MAX_ACCOUNTS)
80 highcount = MAX_ACCOUNTS; 79 highcount = MAX_ACCOUNTS;
81 80
82 if(highcount >= 0 && defaultAccount().isEmpty()) { 81 if(highcount >= 0 && defaultAccount().isEmpty()) {
83 setAccountbyIndex(0); 82 setAccountbyIndex(0);
84 setDefaultAccount(accname()); 83 setDefaultAccount(accname());
85 } else if(!setAccount(defaultAccount())) 84 } else if(!setAccount(defaultAccount()))
86 setDefaultAccount(accname()); 85 setDefaultAccount(accname());
87 86
88 // start out with internal debugging disabled 87 // start out with internal debugging disabled
@@ -308,49 +307,48 @@ QString PPPData::pppdVersion() {
308 307
309bool PPPData::pppdVersionMin(int ver, int mod, int patch) { 308bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
310 // check if pppd version fulfills minimum requirement 309 // check if pppd version fulfills minimum requirement
311 return (pppdVer > ver 310 return (pppdVer > ver
312 || (pppdVer == ver && pppdMod > mod) 311 || (pppdVer == ver && pppdMod > mod)
313 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); 312 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
314} 313}
315 314
316int PPPData::pppdTimeout() { 315int PPPData::pppdTimeout() {
317 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); 316 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
318} 317}
319 318
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() {
345 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); 343 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
346} 344}
347 345
348 346
349void PPPData::setFlowcontrol(const QString &n) { 347void PPPData::setFlowcontrol(const QString &n) {
350 writeConfig(modemGroup(), FLOWCONTROL_KEY, n); 348 writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
351} 349}
352 350
353 351
354const QString PPPData::speed() { 352const QString PPPData::speed() {
355 QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); 353 QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
356 // undo the damage of a bug in former versions. It left an empty Speed= 354 // undo the damage of a bug in former versions. It left an empty Speed=
@@ -783,49 +781,49 @@ bool PPPData::deleteAccount(const QString &aname) {
783 if(!setAccount(aname)) 781 if(!setAccount(aname))
784 return false; 782 return false;
785 783
786 deleteAccount(); 784 deleteAccount();
787 785
788 return true; 786 return true;
789} 787}
790 788
791 789
792int PPPData::newaccount() { 790int PPPData::newaccount() {
793 791
794 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); 792 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
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
820// while (it != map.end()) { 818// while (it != map.end()) {
821// config->writeEntry(it.key(), *it); 819// config->writeEntry(it.key(), *it);
822// it++; 820// it++;
823// } 821// }
824 822
825// setAccname(newname); 823// setAccname(newname);
826 824
827// return caccount; 825// return caccount;
828} 826}
829 827
830 828
831const QString PPPData::accname() { 829const QString PPPData::accname() {
@@ -1200,49 +1198,55 @@ void PPPData::setpppdArgumentDefaults() {
1200 1198
1201 1199
1202// 1200//
1203//functions to change/set the child pppd process info 1201//functions to change/set the child pppd process info
1204// 1202//
1205bool PPPData::pppdRunning() const { 1203bool PPPData::pppdRunning() const {
1206 return pppdisrunning; 1204 return pppdisrunning;
1207} 1205}
1208 1206
1209void PPPData::setpppdRunning(bool set) { 1207void PPPData::setpppdRunning(bool set) {
1210 pppdisrunning = set; 1208 pppdisrunning = set;
1211} 1209}
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}
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index 41dfbd8..c1c7e69 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -10,75 +10,77 @@
10 * based on EzPPP: 10 * based on EzPPP:
11 * Copyright (C) 1997 Jay Painter 11 * Copyright (C) 1997 Jay Painter
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 16 * version 2 of the License, or (at your option) any later version.
17 * 17 *
18 * This program is distributed in the hope that it will be useful, 18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details. 21 * Library General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU Library General Public 23 * You should have received a copy of the GNU Library General Public
24 * License along with this program; if not, write to the Free 24 * License along with this program; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#ifndef _PPPDATA_H_ 28#ifndef _PPPDATA_H_
29#define _PPPDATA_H_ 29#define _PPPDATA_H_
30 30
31#include <unistd.h> 31#include <unistd.h>
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#include <qcolor.h>
35#include <qmap.h>
34#include <qstring.h> 36#include <qstring.h>
35#include <qstringlist.h> 37#include <qstringlist.h>
36#include <qcolor.h>
37 38
38#include "kpppconfig.h" 39#include "kpppconfig.h"
39 40
40class Config; 41class Config;
41 42
42// string lengths 43// string lengths
43 44
44#define PATH_SIZE 120 45#define PATH_SIZE 120
45#define MODEMSTR_SIZE 80 46#define MODEMSTR_SIZE 80
46#define ACCNAME_SIZE 50 47#define ACCNAME_SIZE 50
47#define PHONENUMBER_SIZE 60 48#define PHONENUMBER_SIZE 60
48#define COMMAND_SIZE 255 49#define COMMAND_SIZE 255
49#define IPADDR_SIZE 15 50#define IPADDR_SIZE 15
50#define DOMAIN_SIZE 50 51#define DOMAIN_SIZE 50
51#define TIMEOUT_SIZE 60 52#define TIMEOUT_SIZE 60
52 53
53// 54//
54// keys for config file 55// keys for config file
55// 56//
56 57
57// groups 58// groups
58#define GENERAL_GRP "PPP_General" 59#define GENERAL_GRP "PPP_General"
59#define MODEM_GRP "PPP_Modem" 60#define MODEM_GRP "PPP_Modem"
60#define ACCOUNT_GRP "PPP_Account" 61#define ACCOUNT_GRP "PPP_Account"
62#define ACCLIST_GRP "PPP_Accounts_List"
61//#define GRAPH_GRP "Graph" 63//#define GRAPH_GRP "Graph"
62//#define WINPOS_GRP "WindowPosition" 64//#define WINPOS_GRP "WindowPosition"
63 65
64// general 66// general
65#define DEFAULTACCOUNT_KEY "DefaultAccount" 67#define DEFAULTACCOUNT_KEY "DefaultAccount"
66#define PPPDVERSION_KEY "pppdVersion" 68#define PPPDVERSION_KEY "pppdVersion"
67#define PPPDTIMEOUT_KEY "pppdTimeout" 69#define PPPDTIMEOUT_KEY "pppdTimeout"
68#define SHOWCLOCK_KEY "ShowClock" 70#define SHOWCLOCK_KEY "ShowClock"
69#define SHOWLOGWIN_KEY "ShowLogWindow" 71#define SHOWLOGWIN_KEY "ShowLogWindow"
70#define AUTOREDIAL_KEY "AutomaticRedial" 72#define AUTOREDIAL_KEY "AutomaticRedial"
71#define DISCONNECT_KEY "DisconnectOnXServerExit" 73#define DISCONNECT_KEY "DisconnectOnXServerExit"
72#define QUITONDISCONNECT_KEY "QuitOnDisconnect" 74#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
73#define NUMACCOUNTS_KEY "NumberOfAccounts" 75#define NUMACCOUNTS_KEY "NumberOfAccounts"
74 #define ID_KEY "ID" 76 #define ID_KEY "ID"
75 77
76// modem 78// modem
77#define MODEMDEV_KEY "Device" 79#define MODEMDEV_KEY "Device"
78#define LOCKFILE_KEY "UseLockFile" 80#define LOCKFILE_KEY "UseLockFile"
79#define FLOWCONTROL_KEY "FlowControl" 81#define FLOWCONTROL_KEY "FlowControl"
80#define SPEED_KEY "Speed" 82#define SPEED_KEY "Speed"
81#define TIMEOUT_KEY "Timeout" 83#define TIMEOUT_KEY "Timeout"
82#define TONEDURATION_KEY "ToneDuration" 84#define TONEDURATION_KEY "ToneDuration"
83#define BUSYWAIT_KEY "BusyWait" 85#define BUSYWAIT_KEY "BusyWait"
84#define INITSTR_KEY "InitString" 86#define INITSTR_KEY "InitString"
@@ -119,97 +121,92 @@ class Config;
119#define COMMAND_KEY "Command" 121#define COMMAND_KEY "Command"
120#define DISCONNECT_COMMAND_KEY "DisconnectCommand" 122#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
121#define BEFORE_DISCONNECT_KEY "BeforeDisconnect" 123#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
122#define IPADDR_KEY "IPAddr" 124#define IPADDR_KEY "IPAddr"
123#define SUBNETMASK_KEY "SubnetMask" 125#define SUBNETMASK_KEY "SubnetMask"
124#define ACCTENABLED_KEY "AccountingEnabled" 126#define ACCTENABLED_KEY "AccountingEnabled"
125#define VOLACCTENABLED_KEY "VolumeAccountingEnabled" 127#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
126#define ACCTFILE_KEY "AccountingFile" 128#define ACCTFILE_KEY "AccountingFile"
127#define AUTONAME_KEY "AutoName" 129#define AUTONAME_KEY "AutoName"
128#define GATEWAY_KEY "Gateway" 130#define GATEWAY_KEY "Gateway"
129#define DEFAULTROUTE_KEY "DefaultRoute" 131#define DEFAULTROUTE_KEY "DefaultRoute"
130#define DOMAIN_KEY "Domain" 132#define DOMAIN_KEY "Domain"
131#define DNS_KEY "DNS" 133#define DNS_KEY "DNS"
132#define AUTODNS_KEY "AutoDNS" 134#define AUTODNS_KEY "AutoDNS"
133#define EXDNSDISABLED_KEY "ExDNSDisabled" 135#define EXDNSDISABLED_KEY "ExDNSDisabled"
134#define SCRIPTCOM_KEY "ScriptCommands" 136#define SCRIPTCOM_KEY "ScriptCommands"
135#define SCRIPTARG_KEY "ScriptArguments" 137#define SCRIPTARG_KEY "ScriptArguments"
136#define PPPDARG_KEY "pppdArguments" 138#define PPPDARG_KEY "pppdArguments"
137#define PPP_DEBUG_OPTION "PPPDebug" 139#define PPP_DEBUG_OPTION "PPPDebug"
138#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" 140#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
139#define DOCKING_KEY "DockIntoPanel" 141#define DOCKING_KEY "DockIntoPanel"
140#define TOTALCOSTS_KEY "TotalCosts" 142#define TOTALCOSTS_KEY "TotalCosts"
141#define TOTALBYTES_KEY "TotalBytes" 143#define TOTALBYTES_KEY "TotalBytes"
142 144
143// graph colors
144#define GENABLED "Enabled"
145#define GCOLOR_BG "Background"
146#define GCOLOR_TEXT "Text"
147#define GCOLOR_IN "InBytes"
148#define GCOLOR_OUT "OutBytes"
149
150// pppd errors 145// pppd errors
151#define E_IF_TIMEOUT 1 146#define E_IF_TIMEOUT 1
152#define E_PPPD_DIED 2 147#define E_PPPD_DIED 2
153 148
154// window position 149// account list
155#define WINPOS_CONWIN_X "WindowPositionConWinX" 150#define ACCOUNTS_COUNT "Accounts_Count"
156#define WINPOS_CONWIN_Y "WindowPositionConWinY" 151#define ACOUNTS_DEV "Accounts_Modem"
157#define WINPOS_STATWIN_X "WindowPositionStatWinX" 152#define ACOUNTS_ACC "Accounts_Account"
158#define WINPOS_STATWIN_Y "WindowPositionStatWinY"
159 153
160class PPPData { 154class PPPData {
161public: 155public:
162 PPPData(); 156 PPPData();
163 ~PPPData() {}; 157 ~PPPData() {};
164 static PPPData* data(); 158 static PPPData* data();
165 159
166 enum { NumInitStrings = 2 }; 160 enum { NumInitStrings = 2 };
167 161
168 // general functions 162 // general functions
169 bool open(); 163 bool open();
170 void save(); 164 void save();
171 void cancel(); 165 void cancel();
172 166
167 QMap<QString,QString> getConfiguredInterfaces();
168 void setConfiguredInterfaces( QMap<QString,QString> );
173 169
174 // function to read/write date to configuration file 170 // function to read/write date to configuration file
175 QString readConfig(const QString &, const QString &, const QString &); 171 QString readConfig(const QString &, const QString &, const QString &);
176 int readNumConfig(const QString &, const QString &, int); 172 int readNumConfig(const QString &, const QString &, int);
177 bool readListConfig(const QString &, const QString &, 173 bool readListConfig(const QString &, const QString &,
178 QStringList &, char sep = ','); 174 QStringList &, char sep = ',');
179 void writeConfig(const QString &, const QString &, const QString &); 175 void writeConfig(const QString &, const QString &, const QString &);
180 void writeConfig(const QString &, const QString &, int); 176 void writeConfig(const QString &, const QString &, int);
181 void writeListConfig(const QString &, const QString &, 177 void writeListConfig(const QString &, const QString &,
182 QStringList &, char sep = ','); 178 QStringList &, char sep = ',');
183 179
184 // return the current account group 180 // return the current account group
185 QString currentGroup() { return cgroup; } 181 QString currentGroup() { return cgroup; }
186 QString modemGroup(); 182 QString modemGroup();
187 183
188 // functions to set/get general kppp info 184 // functions to set/get general kppp info
189 QString password() const; 185 QString password() const;
190 void setPassword(const QString &); 186 void setPassword(const QString &);
191 187
188 int currentAccountID() { return caccount; };
192 const QString defaultAccount(); 189 const QString defaultAccount();
193 void setDefaultAccount(const QString &); 190 void setDefaultAccount(const QString &);
194 191
195 void set_xserver_exit_disconnect(bool set); 192 void set_xserver_exit_disconnect(bool set);
196 bool get_xserver_exit_disconnect(); 193 bool get_xserver_exit_disconnect();
197 194
198 void setPPPDebug(bool set); 195 void setPPPDebug(bool set);
199 bool getPPPDebug(); 196 bool getPPPDebug();
200 197
201 void set_quit_on_disconnect(bool); 198 void set_quit_on_disconnect(bool);
202 bool quit_on_disconnect(); 199 bool quit_on_disconnect();
203 200
204 void set_show_clock_on_caption(bool set); 201 void set_show_clock_on_caption(bool set);
205 bool get_show_clock_on_caption(); 202 bool get_show_clock_on_caption();
206 203
207 void set_show_log_window(bool set); 204 void set_show_log_window(bool set);
208 bool get_show_log_window(); 205 bool get_show_log_window();
209 206
210 void set_automatic_redial(bool set); 207 void set_automatic_redial(bool set);
211 bool automatic_redial(); 208 bool automatic_redial();
212 209
213 void set_iconify_on_connect(bool set); 210 void set_iconify_on_connect(bool set);
214 bool get_iconify_on_connect(); 211 bool get_iconify_on_connect();
215 212
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 3a97535..7cbccc2 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,50 +1,61 @@
1#include "pppconfig.h" 1#include "pppconfig.h"
2#include "pppmodule.h" 2#include "pppmodule.h"
3#include "pppdata.h" 3#include "pppdata.h"
4#include "kpppwidget.h" 4#include "kpppwidget.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6//#include "devices.h" 6//#include "devices.h"
7 7
8/** 8/**
9 * Constructor, find all of the possible interfaces 9 * Constructor, find all of the possible interfaces
10 */ 10 */
11PPPModule::PPPModule() : Module() 11PPPModule::PPPModule() : Module()
12{ 12{
13 QMap<QString,QString> ifaces = PPPData::data()->getConfiguredInterfaces();
14 QMap<QString,QString>::Iterator it;
13 Interface *iface; 15 Interface *iface;
14 iface = new Interface( 0, "device" ); 16 qDebug("getting interfaces");
15 iface->setHardwareName( "account" ); 17 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
18 qDebug("ifaces %s", it.key().latin1());
19 iface = new Interface( 0, it.key() );
20 iface->setHardwareName( it.data() );
16 list.append( iface ); 21 list.append( iface );
17} 22}
23}
18 24
19/** 25/**
20 * Delete any interfaces that we own. 26 * Delete any interfaces that we own.
21 */ 27 */
22PPPModule::~PPPModule(){ 28PPPModule::~PPPModule(){
29 QMap<QString,QString> ifaces;
23 Interface *i; 30 Interface *i;
24 for ( i=list.first(); i != 0; i=list.next() ) 31 for ( i=list.first(); i != 0; i=list.next() ){
32 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
25 delete i; 33 delete i;
26} 34}
35 PPPData::data()->setConfiguredInterfaces( ifaces );
36 PPPData::data()->save();
37}
27 38
28/** 39/**
29 * Change the current profile 40 * Change the current profile
30 */ 41 */
31void PPPModule::setProfile(const QString &newProfile){ 42void PPPModule::setProfile(const QString &newProfile){
32 profile = newProfile; 43 profile = newProfile;
33} 44}
34 45
35/** 46/**
36 * get the icon name for this device. 47 * get the icon name for this device.
37 * @param Interface* can be used in determining the icon. 48 * @param Interface* can be used in determining the icon.
38 * @return QString the icon name (minus .png, .gif etc) 49 * @return QString the icon name (minus .png, .gif etc)
39 */ 50 */
40QString PPPModule::getPixmapName(Interface* ){ 51QString PPPModule::getPixmapName(Interface* ){
41 return "ppp"; 52 return "ppp";
42} 53}
43 54
44/** 55/**
45 * Check to see if the interface i is owned by this module. 56 * Check to see if the interface i is owned by this module.
46 * @param Interface* interface to check against 57 * @param Interface* interface to check against
47 * @return bool true if i is owned by this module, false otherwise. 58 * @return bool true if i is owned by this module, false otherwise.
48 */ 59 */
49bool PPPModule::isOwner(Interface *i){ 60bool PPPModule::isOwner(Interface *i){
50 return list.find( i ) != -1; 61 return list.find( i ) != -1;