summaryrefslogtreecommitdiff
authortille <tille>2003-05-30 15:06:17 (UTC)
committer tille <tille>2003-05-30 15:06:17 (UTC)
commit8699d02f6c152afed9490e7e7a4315044261e6e8 (patch) (unidiff)
treed2ee2ba401c7a9db0e33beaf0617a1456fe01d50
parentd8cec07fe5e54a68afe4feca574f9f4d2433e0c1 (diff)
downloadopie-8699d02f6c152afed9490e7e7a4315044261e6e8.zip
opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.gz
opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.bz2
modem and pppdata is now member of interfaceppp
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp70
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h4
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp326
-rw-r--r--noncore/settings/networksettings/ppp/connect.h22
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp245
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.h12
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp123
-rw-r--r--noncore/settings/networksettings/ppp/edit.h20
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp59
-rw-r--r--noncore/settings/networksettings/ppp/general.h10
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp24
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.h25
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp48
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.h30
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp463
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.h11
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp45
-rw-r--r--noncore/settings/networksettings/ppp/modem.h7
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp112
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.h3
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp37
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.h5
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro8
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp29
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h7
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp250
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h62
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp31
30 files changed, 1125 insertions, 981 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 11d4739..3fa2f84 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -41,26 +41,26 @@
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( PPPData *pd, QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name ), _pppdata(pd)
55{ 55{
56 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 56 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
57 accountlist_l = new QListBox(this); 57 accountlist_l = new QListBox(this);
58 58
59 connect(accountlist_l, SIGNAL(highlighted(int)), 59 connect(accountlist_l, SIGNAL(highlighted(int)),
60 this, SLOT(slotListBoxSelect(int))); 60 this, SLOT(slotListBoxSelect(int)));
61 connect(accountlist_l, SIGNAL(selected(int)), 61 connect(accountlist_l, SIGNAL(selected(int)),
62 this, SLOT(editaccount())); 62 this, SLOT(editaccount()));
63 l1->addWidget(accountlist_l, 10); 63 l1->addWidget(accountlist_l, 10);
64 64
65 edit_b = new QPushButton(i18n("&Edit..."), this); 65 edit_b = new QPushButton(i18n("&Edit..."), this);
66 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 66 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
@@ -143,50 +143,50 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
143// reset->setEnabled(FALSE); 143// reset->setEnabled(FALSE);
144// connect(reset, SIGNAL(clicked()), 144// connect(reset, SIGNAL(clicked()),
145 // this, SLOT(resetClicked())); 145 // this, SLOT(resetClicked()));
146// l122->addWidget(reset); 146// l122->addWidget(reset);
147 147
148// log = new QPushButton(i18n("&View Logs"), this); 148// log = new QPushButton(i18n("&View Logs"), this);
149// connect(log, SIGNAL(clicked()), 149// connect(log, SIGNAL(clicked()),
150 // this, SLOT(viewLogClicked())); 150 // this, SLOT(viewLogClicked()));
151// l122->addWidget(log); 151// l122->addWidget(log);
152// l122->addStretch(1); 152// l122->addStretch(1);
153 153
154 //load up account list from gppdata to the list box 154 //load up account list from gppdata to the list box
155 if(PPPData::data()->count() > 0) { 155 if(_pppdata->count() > 0) {
156 for(int i=0; i <= PPPData::data()->count()-1; i++) { 156 for(int i=0; i <= _pppdata->count()-1; i++) {
157 PPPData::data()->setAccountbyIndex(i); 157 _pppdata->setAccountbyIndex(i);
158 accountlist_l->insertItem(PPPData::data()->accname()); 158 accountlist_l->insertItem(_pppdata->accname());
159 } 159 }
160 } 160 }
161 161
162// slotListBoxSelect(accountlist_l->currentItem()); 162// slotListBoxSelect(accountlist_l->currentItem());
163 qDebug("setting listview index to %i",PPPData::data()->currentAccountID() ); 163 qDebug("setting listview index to %i",_pppdata->currentAccountID() );
164 accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() ); 164 accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
165// slotListBoxSelect( PPPData::data()->currentAccountID()); 165// slotListBoxSelect( _pppdata->currentAccountID());
166 166
167 l1->activate(); 167 l1->activate();
168} 168}
169 169
170 170
171 171
172void AccountWidget::slotListBoxSelect(int idx) { 172void AccountWidget::slotListBoxSelect(int idx) {
173 delete_b->setEnabled((bool)(idx != -1)); 173 delete_b->setEnabled((bool)(idx != -1));
174 edit_b->setEnabled((bool)(idx != -1)); 174 edit_b->setEnabled((bool)(idx != -1));
175 copy_b->setEnabled((bool)(idx != -1)); 175 copy_b->setEnabled((bool)(idx != -1));
176 if(idx!=-1) { 176 if(idx!=-1) {
177 qDebug("setting account to %i", idx); 177 qDebug("setting account to %i", idx);
178 QString account = PPPData::data()->accname(); 178 QString account = _pppdata->accname();
179 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem()); 179 _pppdata->setAccountbyIndex(accountlist_l->currentItem());
180 // PPPData::data()->setAccount(account); 180 // _pppdata->setAccount(account);
181 } 181 }
182} 182}
183 183
184 184
185// void AccountWidget::viewLogClicked(){ 185// void AccountWidget::viewLogClicked(){
186 186
187// QApplication::flushX(); 187// QApplication::flushX();
188// if(fork() == 0) { 188// if(fork() == 0) {
189// setgid(getgid()); 189// setgid(getgid());
190// setuid(getuid()); 190// setuid(getuid());
191// system("kppplogview -kppp"); 191// system("kppplogview -kppp");
192// _exit(0); 192// _exit(0);
@@ -205,153 +205,153 @@ void AccountWidget::slotListBoxSelect(int idx) {
205// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); 205// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem()));
206// // costedit->setText("0"); 206// // costedit->setText("0");
207// // } 207// // }
208 208
209// // if(what && QueryReset::VOLUME) { 209// // if(what && QueryReset::VOLUME) {
210// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); 210// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem()));
211// // voledit->setText(prettyPrintVolume(0)); 211// // voledit->setText(prettyPrintVolume(0));
212// // } 212// // }
213// } 213// }
214 214
215 215
216void AccountWidget::editaccount() { 216void AccountWidget::editaccount() {
217 PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem())); 217 _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem()));
218 218
219 int result = doTab(); 219 int result = doTab();
220 220
221 if(result == QDialog::Accepted) { 221 if(result == QDialog::Accepted) {
222 accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem()); 222 accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
223// emit resetaccounts(); 223// emit resetaccounts();
224 PPPData::data()->save(); 224 _pppdata->save();
225 } 225 }
226} 226}
227 227
228 228
229void AccountWidget::newaccount() { 229void AccountWidget::newaccount() {
230 if(accountlist_l->count() == MAX_ACCOUNTS) { 230 if(accountlist_l->count() == MAX_ACCOUNTS) {
231 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 231 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
232 return; 232 return;
233 } 233 }
234 234
235 int result; 235 int result;
236// int query = QMessageBox::information(this, 236// int query = QMessageBox::information(this,
237// i18n("Do you want to use the wizard to create the new account or the " 237// i18n("Do you want to use the wizard to create the new account or the "
238 // "standard, dialog-based setup?\n" 238 // "standard, dialog-based setup?\n"
239 // "The wizard is easier and sufficient in most cases. If you need " 239 // "The wizard is easier and sufficient in most cases. If you need "
240 // "very special settings, you might want to try the standard, " 240 // "very special settings, you might want to try the standard, "
241 // "dialog-based setup."), 241 // "dialog-based setup."),
242 // i18n("Create New Account"), 242 // i18n("Create New Account"),
243 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); 243 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
244 244
245// switch(query) { 245// switch(query) {
246// case QMessageBox::Yes: 246// case QMessageBox::Yes:
247// { 247// {
248// if (PPPData::data()->newaccount() == -1) 248// if (_pppdata->newaccount() == -1)
249 // return; 249 // return;
250// // ProviderDB pdb(this); 250// // ProviderDB pdb(this);
251// // result = pdb.exec(); 251// // result = pdb.exec();
252// break; 252// break;
253// } 253// }
254// case QMessageBox::No: 254// case QMessageBox::No:
255 if (PPPData::data()->newaccount() == -1){ 255 if (_pppdata->newaccount() == -1){
256 qDebug("PPPData::data()->newaccount() == -1"); 256 qDebug("_pppdata->newaccount() == -1");
257 return; 257 return;
258 } 258 }
259 result = doTab(); 259 result = doTab();
260// break; 260// break;
261// default: 261// default:
262// return; 262// return;
263// } 263// }
264 264
265 if(result == QDialog::Accepted) { 265 if(result == QDialog::Accepted) {
266 accountlist_l->insertItem(PPPData::data()->accname()); 266 accountlist_l->insertItem(_pppdata->accname());
267 accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()), 267 accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),
268 true); 268 true);
269// emit resetaccounts(); 269// emit resetaccounts();
270 PPPData::data()->save(); 270 _pppdata->save();
271 } else 271 } else
272 PPPData::data()->deleteAccount(); 272 _pppdata->deleteAccount();
273} 273}
274 274
275 275
276void AccountWidget::copyaccount() { 276void AccountWidget::copyaccount() {
277 if(accountlist_l->count() == MAX_ACCOUNTS) { 277 if(accountlist_l->count() == MAX_ACCOUNTS) {
278 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 278 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
279 return; 279 return;
280 } 280 }
281 281
282 if(accountlist_l->currentItem()<0) { 282 if(accountlist_l->currentItem()<0) {
283 QMessageBox::information(this, "sorry", i18n("No account selected.")); 283 QMessageBox::information(this, "sorry", i18n("No account selected."));
284 return; 284 return;
285 } 285 }
286 286
287 PPPData::data()->copyaccount(accountlist_l->currentItem()); 287 _pppdata->copyaccount(accountlist_l->currentItem());
288 288
289 accountlist_l->insertItem(PPPData::data()->accname()); 289 accountlist_l->insertItem(_pppdata->accname());
290// emit resetaccounts(); 290// emit resetaccounts();
291 PPPData::data()->save(); 291 _pppdata->save();
292} 292}
293 293
294 294
295void AccountWidget::deleteaccount() { 295void AccountWidget::deleteaccount() {
296 296
297 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") 297 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
298 .arg(accountlist_l->text(accountlist_l->currentItem())); 298 .arg(accountlist_l->text(accountlist_l->currentItem()));
299 299
300 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) 300 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
301 return; 301 return;
302 302
303 if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 303 if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
304 accountlist_l->removeItem(accountlist_l->currentItem()); 304 accountlist_l->removeItem(accountlist_l->currentItem());
305 305
306 emit resetaccounts(); 306 emit resetaccounts();
307 PPPData::data()->save(); 307 _pppdata->save();
308 308
309 slotListBoxSelect(accountlist_l->currentItem()); 309 slotListBoxSelect(accountlist_l->currentItem());
310 310
311} 311}
312 312
313 313
314int AccountWidget::doTab(){ 314int AccountWidget::doTab(){
315 QDialog *dlg = new QDialog( this, "newAccount", true ); 315 QDialog *dlg = new QDialog( this, "newAccount", true );
316 QVBoxLayout *layout = new QVBoxLayout( dlg ); 316 QVBoxLayout *layout = new QVBoxLayout( dlg );
317 layout->setSpacing( 0 ); 317 layout->setSpacing( 0 );
318 layout->setMargin( 1 ); 318 layout->setMargin( 1 );
319 319
320 tabWindow = new QTabWidget( dlg, "tabWindow" ); 320 tabWindow = new QTabWidget( dlg, "tabWindow" );
321 layout->addWidget( tabWindow ); 321 layout->addWidget( tabWindow );
322 322
323 bool isnewaccount; 323 bool isnewaccount;
324 324
325 if(PPPData::data()->accname().isEmpty()) { 325 if(_pppdata->accname().isEmpty()) {
326 dlg->setCaption(i18n("New Account")); 326 dlg->setCaption(i18n("New Account"));
327 isnewaccount = true; 327 isnewaccount = true;
328 } else { 328 } else {
329 QString tit = i18n("Edit Account: "); 329 QString tit = i18n("Edit Account: ");
330 tit += PPPData::data()->accname(); 330 tit += _pppdata->accname();
331 dlg->setCaption(tit); 331 dlg->setCaption(tit);
332 isnewaccount = false; 332 isnewaccount = false;
333 } 333 }
334 334
335 dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup"); 335 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
336 tabWindow->addTab( dial_w, i18n("Dial") ); 336 tabWindow->addTab( dial_w, i18n("Dial") );
337 ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup")); 337 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup"));
338 tabWindow->addTab( ip_w, i18n("IP") ); 338 tabWindow->addTab( ip_w, i18n("IP") );
339 gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup")); 339 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup"));
340 tabWindow->addTab( gateway_w, i18n("Gateway") ); 340 tabWindow->addTab( gateway_w, i18n("Gateway") );
341 dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") ); 341 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") );
342 tabWindow->addTab( dns_w, i18n("DNS") ); 342 tabWindow->addTab( dns_w, i18n("DNS") );
343 script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script")); 343 script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script"));
344 tabWindow->addTab( script_w, i18n("Login Script") ); 344 tabWindow->addTab( script_w, i18n("Login Script") );
345 ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs")); 345 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs"));
346 tabWindow->addTab( exec_w, i18n("Execute") ); 346 tabWindow->addTab( exec_w, i18n("Execute") );
347// acct = new AccountingSelector( tabWindow, isnewaccount ); 347// acct = new AccountingSelector( tabWindow, isnewaccount );
348// tabWindow->addTab( acct, i18n("Accounting")); 348// tabWindow->addTab( acct, i18n("Accounting"));
349 349
350 int result = 0; 350 int result = 0;
351 bool ok = false; 351 bool ok = false;
352 qDebug("AccountWidget::doTab dlg->showMinimized"); 352 qDebug("AccountWidget::doTab dlg->showMinimized");
353 dlg->showMinimized(); 353 dlg->showMinimized();
354 while (!ok){ 354 while (!ok){
355 355
356 result = dlg->exec(); 356 result = dlg->exec();
357 ok = true; 357 ok = true;
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
index 751a414..5e8509d 100644
--- a/noncore/settings/networksettings/ppp/accounts.h
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -33,51 +33,53 @@
33#include <qlistbox.h> 33#include <qlistbox.h>
34//#include "acctselect.h" 34//#include "acctselect.h"
35 35
36class QDialog; 36class QDialog;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class QTabWidget; 39class QTabWidget;
40class DialWidget; 40class DialWidget;
41class ScriptWidget; 41class ScriptWidget;
42class IPWidget; 42class IPWidget;
43class DNSWidget; 43class DNSWidget;
44class GatewayWidget; 44class GatewayWidget;
45class PPPData;
45 46
46class AccountWidget : public QWidget { 47class AccountWidget : public QWidget {
47 Q_OBJECT 48 Q_OBJECT
48public: 49public:
49 AccountWidget( QWidget *parent=0, const char *name=0 ); 50 AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 );
50 ~AccountWidget() {} 51 ~AccountWidget() {}
51 52
52private slots: 53private slots:
53 void editaccount(); 54 void editaccount();
54 void copyaccount(); 55 void copyaccount();
55 void newaccount(); 56 void newaccount();
56 void deleteaccount(); 57 void deleteaccount();
57 void slotListBoxSelect(int); 58 void slotListBoxSelect(int);
58// void resetClicked(); 59// void resetClicked();
59// void viewLogClicked(); 60// void viewLogClicked();
60 61
61private: 62private:
62 int doTab(); 63 int doTab();
63 64
64signals: 65signals:
65 void resetaccounts(); 66 void resetaccounts();
66// void resetCosts(const QString &); 67// void resetCosts(const QString &);
67// void resetVolume(const QString &); 68// void resetVolume(const QString &);
68 69
69private: 70private:
70 QString prettyPrintVolume(unsigned int); 71 QString prettyPrintVolume(unsigned int);
71 72
73 PPPData *_pppdata;
72 QTabWidget *tabWindow; 74 QTabWidget *tabWindow;
73 DialWidget *dial_w; 75 DialWidget *dial_w;
74// AccountingSelector *acct; 76// AccountingSelector *acct;
75 IPWidget *ip_w; 77 IPWidget *ip_w;
76 DNSWidget *dns_w; 78 DNSWidget *dns_w;
77 GatewayWidget *gateway_w; 79 GatewayWidget *gateway_w;
78 ScriptWidget *script_w; 80 ScriptWidget *script_w;
79 81
80// QPushButton *reset; 82// QPushButton *reset;
81// QPushButton *log; 83// QPushButton *log;
82// QLabel *costlabel; 84// QLabel *costlabel;
83// QLineEdit *costedit; 85// QLineEdit *costedit;
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index a3eda9d..2615b60 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -56,58 +56,54 @@
56 56
57#ifdef HAVE_SYS_PARAM_H 57#ifdef HAVE_SYS_PARAM_H
58#include <sys/param.h> 58#include <sys/param.h>
59#endif 59#endif
60 60
61#ifdef __linux__ 61#ifdef __linux__
62#include "runtests.h" 62#include "runtests.h"
63#endif 63#endif
64 64
65#include "auth.h" 65#include "auth.h"
66#include "connect.h" 66#include "connect.h"
67//#include "docking.h" 67//#include "docking.h"
68//#include "main.h" 68#include "interfaceppp.h"
69#include "modem.h" 69#include "modem.h"
70#include "kpppconfig.h" 70#include "kpppconfig.h"
71#include "pppdata.h" 71#include "pppdata.h"
72#include "kpppwidget.h" 72#include "kpppwidget.h"
73//#include "requester.h" 73//#include "requester.h"
74//#include "utils.h" 74//#include "utils.h"
75#define execute_command system 75#define execute_command system
76 76
77extern KPPPWidget *p_kppp;
78
79QString old_hostname; 77QString old_hostname;
80bool modified_hostname; 78bool modified_hostname;
81 79
82 80
83ConnectWidget::ConnectWidget(QWidget *parent, const char *name) 81ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
84 : QWidget(parent, name), 82 : QWidget(parent, name),
85 // initialize some important variables
86 myreadbuffer(""), 83 myreadbuffer(""),
87 main_timer_ID(0), 84 main_timer_ID(0),
88 vmain(0), 85 vmain(0),
89 substate(-1), 86 substate(-1),
90 scriptindex(0), 87 scriptindex(0),
91 loopnest(0), 88 loopnest(0),
92 loopend(false), 89 loopend(false),
93 semaphore(false), 90 semaphore(false),
94 expecting(false), 91 expecting(false),
95 readbuffer(""), 92 readbuffer(""),
96 scanvar(""), 93 scanvar(""),
97 scanning(false), 94 scanning(false),
98 pausing(false), 95 pausing(false),
99// termwindow(0), 96 dialnumber(0),
100// stats(st), 97 _ifaceppp(ifp)
101 dialnumber(0)
102{ 98{
103 modified_hostname = false; 99 modified_hostname = false;
104 100
105 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); 101 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
106 QString tit = i18n("Connecting to: "); 102 QString tit = i18n("Connecting to: ");
107 setCaption(tit); 103 setCaption(tit);
108 104
109 QHBoxLayout *l0 = new QHBoxLayout(10); 105 QHBoxLayout *l0 = new QHBoxLayout(10);
110 tl->addLayout(l0); 106 tl->addLayout(l0);
111 l0->addSpacing(10); 107 l0->addSpacing(10);
112 messg = new QLabel(this, "messg"); 108 messg = new QLabel(this, "messg");
113 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
@@ -170,303 +166,303 @@ ConnectWidget::~ConnectWidget() {
170} 166}
171 167
172 168
173void ConnectWidget::preinit() { 169void ConnectWidget::preinit() {
174 // this is all just to keep the GUI nice and snappy .... 170 // this is all just to keep the GUI nice and snappy ....
175 // you have to see to believe ... 171 // you have to see to believe ...
176 messg->setText(i18n("Looking for modem...")); 172 messg->setText(i18n("Looking for modem..."));
177 inittimer->start(100); 173 inittimer->start(100);
178} 174}
179 175
180 176
181void ConnectWidget::init() { 177void ConnectWidget::init() {
182 PPPData::data()->setpppdError(0); 178 _ifaceppp->data()->setpppdError(0);
183 inittimer->stop(); 179 inittimer->stop();
184 vmain = 0; 180 vmain = 0;
185 substate = -1; 181 substate = -1;
186 expecting = false; 182 expecting = false;
187 pausing = false; 183 pausing = false;
188 scriptindex = 0; 184 scriptindex = 0;
189 myreadbuffer = ""; 185 myreadbuffer = "";
190 scanning = false; 186 scanning = false;
191 scanvar = ""; 187 scanvar = "";
192 firstrunID = true; 188 firstrunID = true;
193 firstrunPW = true; 189 firstrunPW = true;
194// stats->totalbytes = 0; 190// stats->totalbytes = 0;
195 dialnumber = 0; 191 dialnumber = 0;
196 192
197 p_kppp->con_speed = ""; 193// p_kppp->con_speed = "";
198 194
199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect()); 195// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
200 196
201 comlist = &PPPData::data()->scriptType(); 197 comlist = &_ifaceppp->data()->scriptType();
202 arglist = &PPPData::data()->script(); 198 arglist = &_ifaceppp->data()->script();
203 199
204 QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); 200 QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname());
205 setCaption(tit); 201 setCaption(tit);
206 202
207 qApp->processEvents(); 203 qApp->processEvents();
208 204
209 // run the "before-connect" command 205 // run the "before-connect" command
210 if (!PPPData::data()->command_before_connect().isEmpty()) { 206 if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
211 messg->setText(i18n("Running pre-startup command...")); 207 messg->setText(i18n("Running pre-startup command..."));
212 emit debugMessage(i18n("Running pre-startup command...")); 208 emit debugMessage(i18n("Running pre-startup command..."));
213 209
214 qApp->processEvents(); 210 qApp->processEvents();
215 QApplication::flushX(); 211 QApplication::flushX();
216 pid_t id = execute_command(PPPData::data()->command_before_connect()); 212 pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
217// int i, status; 213// int i, status;
218 214
219// do { 215// do {
220// qApp->processEvents(); 216// qApp->processEvents();
221// i = waitpid(id, &status, WNOHANG); 217// i = waitpid(id, &status, WNOHANG);
222// usleep(100000); 218// usleep(100000);
223// } while (i == 0 && errno == 0); 219// } while (i == 0 && errno == 0);
224 } 220 }
225 221
226 int lock = Modem::modem->lockdevice(); 222 int lock = _ifaceppp->modem()->lockdevice();
227 223
228 if (lock == 1) { 224 if (lock == 1) {
229 messg->setText(i18n("Modem device is locked.")); 225 messg->setText(i18n("Modem device is locked."));
230 vmain = 20; // wait until cancel is pressed 226 vmain = 20; // wait until cancel is pressed
231 return; 227 return;
232 } 228 }
233 229
234 if (lock == -1) { 230 if (lock == -1) {
235 messg->setText(i18n("Unable to create modem lock file.")); 231 messg->setText(i18n("Unable to create modem lock file."));
236 vmain = 20; // wait until cancel is pressed 232 vmain = 20; // wait until cancel is pressed
237 return; 233 return;
238 } 234 }
239 235
240 if(Modem::modem->opentty()) { 236 if(_ifaceppp->modem()->opentty()) {
241 messg->setText(Modem::modem->modemMessage()); 237 messg->setText(_ifaceppp->modem()->modemMessage());
242 qApp->processEvents(); 238 qApp->processEvents();
243 if(Modem::modem->hangup()) { 239 if(_ifaceppp->modem()->hangup()) {
244 240
245 qApp->processEvents(); 241 qApp->processEvents();
246 242
247 semaphore = false; 243 semaphore = false;
248 244
249 Modem::modem->stop(); 245 _ifaceppp->modem()->stop();
250 Modem::modem->notify(this, SLOT(readChar(unsigned char))); 246 _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char)));
251 247
252 // if we are stuck anywhere we will time out 248 // if we are stuck anywhere we will time out
253 timeout_timer->start(PPPData::data()->modemTimeout()*1000); 249 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
254 250
255 // this timer will run the script etc. 251 // this timer will run the script etc.
256 main_timer_ID = startTimer(10); 252 main_timer_ID = startTimer(10);
257 253
258 return; 254 return;
259 } 255 }
260 } 256 }
261 257
262 // initialization failed 258 // initialization failed
263 messg->setText(Modem::modem->modemMessage()); 259 messg->setText(_ifaceppp->modem()->modemMessage());
264 vmain = 20; // wait until cancel is pressed 260 vmain = 20; // wait until cancel is pressed
265 Modem::modem->unlockdevice(); 261 _ifaceppp->modem()->unlockdevice();
266} 262}
267 263
268 264
269void ConnectWidget::timerEvent(QTimerEvent *) { 265void ConnectWidget::timerEvent(QTimerEvent *) {
270 if (semaphore || pausing) 266 if (semaphore || pausing)
271 return; 267 return;
272 268
273 if(vmain == 0) { 269 if(vmain == 0) {
274#ifdef DEBUG_WO_DIALING 270#ifdef DEBUG_WO_DIALING
275 vmain = 10; 271 vmain = 10;
276 return; 272 return;
277#endif 273#endif
278 274
279 assert(PPPData::NumInitStrings > 0); 275 assert(PPPData::NumInitStrings > 0);
280 // first init string ? 276 // first init string ?
281 if(substate == -1) { 277 if(substate == -1) {
282 messg->setText(i18n("Initializing modem...")); 278 messg->setText(i18n("Initializing modem..."));
283 emit debugMessage(i18n("Initializing modem...")); 279 emit debugMessage(i18n("Initializing modem..."));
284 substate = 0; 280 substate = 0;
285 } 281 }
286 282
287 QString initStr = PPPData::data()->modemInitStr(substate); 283 QString initStr = _ifaceppp->data()->modemInitStr(substate);
288 if (!initStr.isEmpty()) { 284 if (!initStr.isEmpty()) {
289 // send a carriage return and then wait a bit so that the modem will 285 // send a carriage return and then wait a bit so that the modem will
290 // let us issue commands. 286 // let us issue commands.
291 if(PPPData::data()->modemPreInitDelay() > 0) { 287 if(_ifaceppp->data()->modemPreInitDelay() > 0) {
292 usleep(PPPData::data()->modemPreInitDelay() * 5000); 288 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
293 writeline(""); 289 writeline("");
294 usleep(PPPData::data()->modemPreInitDelay() * 5000); 290 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
295 } 291 }
296 setExpect(PPPData::data()->modemInitResp()); 292 setExpect(_ifaceppp->data()->modemInitResp());
297 writeline(initStr); 293 writeline(initStr);
298 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 294 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
299 } 295 }
300 296
301 substate++; 297 substate++;
302 298
303 /* 299 /*
304 * FIXME after 3.0: Make it possible to disable ATS11 since it 300 * FIXME after 3.0: Make it possible to disable ATS11 since it
305 * seems to be incompatible with some ISDN adapters (e.g. DataBox 301 * seems to be incompatible with some ISDN adapters (e.g. DataBox
306 * Speed Dragon). Even better would be to detect this when doing 302 * Speed Dragon). Even better would be to detect this when doing
307 * a "Modem Query" 303 * a "Modem Query"
308 */ 304 */
309 if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration()) 305 if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
310 vmain = 5; 306 vmain = 5;
311 else 307 else
312 vmain = 3; 308 vmain = 3;
313 309
314 return; 310 return;
315 } 311 }
316 312
317 if (vmain == 5) { 313 if (vmain == 5) {
318 if(!expecting) { 314 if(!expecting) {
319 QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration()); 315 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
320 QString msg = i18n("Setting ") + sToneDuration; 316 QString msg = i18n("Setting ") + sToneDuration;
321 messg->setText(msg); 317 messg->setText(msg);
322 emit debugMessage(msg); 318 emit debugMessage(msg);
323 setExpect(PPPData::data()->modemInitResp()); 319 setExpect(_ifaceppp->data()->modemInitResp());
324 writeline(sToneDuration); 320 writeline(sToneDuration);
325 } 321 }
326 vmain = 3; 322 vmain = 3;
327 return; 323 return;
328 } 324 }
329 325
330 if(vmain == 3) { 326 if(vmain == 3) {
331 if(!expecting) { 327 if(!expecting) {
332 // done with all init strings ? 328 // done with all init strings ?
333 if(substate < PPPData::NumInitStrings) { 329 if(substate < PPPData::NumInitStrings) {
334 vmain = 0; 330 vmain = 0;
335 return; 331 return;
336 } 332 }
337 substate = -1; 333 substate = -1;
338 // skip setting the volume if command is empty 334 // skip setting the volume if command is empty
339 if(PPPData::data()->volumeInitString().isEmpty()) { 335 if(_ifaceppp->data()->volumeInitString().isEmpty()) {
340 vmain = 4; 336 vmain = 4;
341 return; 337 return;
342 } 338 }
343 messg->setText(i18n("Setting speaker volume...")); 339 messg->setText(i18n("Setting speaker volume..."));
344 emit debugMessage(i18n("Setting speaker volume...")); 340 emit debugMessage(i18n("Setting speaker volume..."));
345 341
346 setExpect(PPPData::data()->modemInitResp()); 342 setExpect(_ifaceppp->data()->modemInitResp());
347 QString vol("AT"); 343 QString vol("AT");
348 vol += PPPData::data()->volumeInitString(); 344 vol += _ifaceppp->data()->volumeInitString();
349 writeline(vol); 345 writeline(vol);
350 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 346 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
351 vmain = 4; 347 vmain = 4;
352 return; 348 return;
353 } 349 }
354 } 350 }
355 351
356 if(vmain == 4) { 352 if(vmain == 4) {
357 if(!expecting) { 353 if(!expecting) {
358 if(!PPPData::data()->waitForDialTone()) { 354 if(!_ifaceppp->data()->waitForDialTone()) {
359 QString msg = i18n("Turning off dial tone waiting..."); 355 QString msg = i18n("Turning off dial tone waiting...");
360 messg->setText(msg); 356 messg->setText(msg);
361 emit debugMessage(msg); 357 emit debugMessage(msg);
362 setExpect(PPPData::data()->modemInitResp()); 358 setExpect(_ifaceppp->data()->modemInitResp());
363 writeline(PPPData::data()->modemNoDialToneDetectionStr()); 359 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
364 } 360 }
365 vmain = 1; 361 vmain = 1;
366 return; 362 return;
367 } 363 }
368 } 364 }
369 365
370 // dial the number and wait to connect 366 // dial the number and wait to connect
371 if(vmain == 1) { 367 if(vmain == 1) {
372 if(!expecting) { 368 if(!expecting) {
373 369
374 timeout_timer->stop(); 370 timeout_timer->stop();
375 timeout_timer->start(PPPData::data()->modemTimeout()*1000); 371 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
376 372
377 QStringList &plist = PPPData::data()->phonenumbers(); 373 QStringList &plist = _ifaceppp->data()->phonenumbers();
378 QString bmarg= PPPData::data()->dialPrefix(); 374 QString bmarg= _ifaceppp->data()->dialPrefix();
379 bmarg += *plist.at(dialnumber); 375 bmarg += *plist.at(dialnumber);
380 QString bm = i18n("Dialing %1").arg(bmarg); 376 QString bm = i18n("Dialing %1").arg(bmarg);
381 messg->setText(bm); 377 messg->setText(bm);
382 emit debugMessage(bm); 378 emit debugMessage(bm);
383 379
384 QString pn = PPPData::data()->modemDialStr(); 380 QString pn = _ifaceppp->data()->modemDialStr();
385 pn += PPPData::data()->dialPrefix(); 381 pn += _ifaceppp->data()->dialPrefix();
386 pn += *plist.at(dialnumber); 382 pn += *plist.at(dialnumber);
387 if(++dialnumber >= plist.count()) 383 if(++dialnumber >= plist.count())
388 dialnumber = 0; 384 dialnumber = 0;
389 writeline(pn); 385 writeline(pn);
390 386
391 setExpect(PPPData::data()->modemConnectResp()); 387 setExpect(_ifaceppp->data()->modemConnectResp());
392 vmain = 100; 388 vmain = 100;
393 return; 389 return;
394 } 390 }
395 } 391 }
396 392
397 // wait for connect, but redial if BUSY or wait for user cancel 393 // wait for connect, but redial if BUSY or wait for user cancel
398 // if NO CARRIER or NO DIALTONE 394 // if NO CARRIER or NO DIALTONE
399 if(vmain == 100) { 395 if(vmain == 100) {
400 if(!expecting) { 396 if(!expecting) {
401 myreadbuffer = PPPData::data()->modemConnectResp(); 397 myreadbuffer = _ifaceppp->data()->modemConnectResp();
402 setExpect("\n"); 398 setExpect("\n");
403 vmain = 101; 399 vmain = 101;
404 return; 400 return;
405 } 401 }
406 402
407 if(readbuffer.contains(PPPData::data()->modemBusyResp())) { 403 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
408 timeout_timer->stop(); 404 timeout_timer->stop();
409 timeout_timer->start(PPPData::data()->modemTimeout()*1000); 405 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
410 406
411 messg->setText(i18n("Line busy. Hanging up...")); 407 messg->setText(i18n("Line busy. Hanging up..."));
412 emit debugPutChar('\n'); 408 emit debugPutChar('\n');
413 Modem::modem->hangup(); 409 _ifaceppp->modem()->hangup();
414 410
415 if(PPPData::data()->busyWait() > 0) { 411 if(_ifaceppp->data()->busyWait() > 0) {
416 QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait()); 412 QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
417 messg->setText(bm); 413 messg->setText(bm);
418 emit debugMessage(bm); 414 emit debugMessage(bm);
419 415
420 pausing = true; 416 pausing = true;
421 417
422 pausetimer->start(PPPData::data()->busyWait()*1000, true); 418 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
423 timeout_timer->stop(); 419 timeout_timer->stop();
424 } 420 }
425 421
426 Modem::modem->setDataMode(false); 422 _ifaceppp->modem()->setDataMode(false);
427 vmain = 0; 423 vmain = 0;
428 substate = -1; 424 substate = -1;
429 return; 425 return;
430 } 426 }
431 427
432 if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) { 428 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
433 timeout_timer->stop(); 429 timeout_timer->stop();
434 430
435 messg->setText(i18n("No Dialtone")); 431 messg->setText(i18n("No Dialtone"));
436 vmain = 20; 432 vmain = 20;
437 Modem::modem->unlockdevice(); 433 _ifaceppp->modem()->unlockdevice();
438 return; 434 return;
439 } 435 }
440 436
441 if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) { 437 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
442 timeout_timer->stop(); 438 timeout_timer->stop();
443 439
444 messg->setText(i18n("No Carrier")); 440 messg->setText(i18n("No Carrier"));
445 vmain = 20; 441 vmain = 20;
446 Modem::modem->unlockdevice(); 442 _ifaceppp->modem()->unlockdevice();
447 return; 443 return;
448 } 444 }
449 } 445 }
450 446
451 // wait for newline after CONNECT response (so we get the speed) 447 // wait for newline after CONNECT response (so we get the speed)
452 if(vmain == 101) { 448 if(vmain == 101) {
453 if(!expecting) { 449 if(!expecting) {
454 Modem::modem->setDataMode(true); // modem will no longer respond to AT commands 450 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
455 451
456 emit startAccounting(); 452 emit startAccounting();
457// p_kppp->con_win->startClock(); 453// p_kppp->con_win->startClock();
458 454
459 vmain = 2; 455 vmain = 2;
460 scriptTimeout=PPPData::data()->modemTimeout()*1000; 456 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
461 return; 457 return;
462 } 458 }
463 } 459 }
464 460
465 // execute the script 461 // execute the script
466 if(vmain == 2) { 462 if(vmain == 2) {
467 if(!expecting && !pausing && !scanning) { 463 if(!expecting && !pausing && !scanning) {
468 464
469 timeout_timer->stop(); 465 timeout_timer->stop();
470 timeout_timer->start(scriptTimeout); 466 timeout_timer->start(scriptTimeout);
471 467
472 if((unsigned) scriptindex < comlist->count()) { 468 if((unsigned) scriptindex < comlist->count()) {
@@ -485,45 +481,45 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
485 481
486 setScan(scriptArgument); 482 setScan(scriptArgument);
487 scriptindex++; 483 scriptindex++;
488 return; 484 return;
489 } 485 }
490 486
491 if (scriptCommand == "Save") { 487 if (scriptCommand == "Save") {
492 QString bm = i18n("Saving %1").arg(scriptArgument); 488 QString bm = i18n("Saving %1").arg(scriptArgument);
493 messg->setText(bm); 489 messg->setText(bm);
494 emit debugMessage(bm); 490 emit debugMessage(bm);
495 491
496 if (scriptArgument.lower() == "password") { 492 if (scriptArgument.lower() == "password") {
497 PPPData::data()->setPassword(scanvar); 493 _ifaceppp->data()->setPassword(scanvar);
498 p_kppp->setPW_Edit(scanvar); 494 // p_kppp->setPW_Edit(scanvar);
499 if(PPPData::data()->storePassword()) 495 if(_ifaceppp->data()->storePassword())
500 PPPData::data()->setStoredPassword(scanvar); 496 _ifaceppp->data()->setStoredPassword(scanvar);
501 firstrunPW = true; 497 firstrunPW = true;
502 } 498 }
503 499
504 scriptindex++; 500 scriptindex++;
505 return; 501 return;
506 } 502 }
507 503
508 504
509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 505 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
510 QString bm = i18n("Sending %1"); 506 QString bm = i18n("Sending %1");
511 507
512 // replace %USERNAME% and %PASSWORD% 508 // replace %USERNAME% and %PASSWORD%
513 QString arg = scriptArgument; 509 QString arg = scriptArgument;
514 QRegExp re1("%USERNAME%"); 510 QRegExp re1("%USERNAME%");
515 QRegExp re2("%PASSWORD%"); 511 QRegExp re2("%PASSWORD%");
516 arg = arg.replace(re1, PPPData::data()->storedUsername()); 512 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
517 arg = arg.replace(re2, PPPData::data()->storedPassword()); 513 arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
518 514
519 if (scriptCommand == "Send") 515 if (scriptCommand == "Send")
520 bm = bm.arg(scriptArgument); 516 bm = bm.arg(scriptArgument);
521 else { 517 else {
522 for(uint i = 0; i < scriptArgument.length(); i++) 518 for(uint i = 0; i < scriptArgument.length(); i++)
523 bm = bm.arg("*"); 519 bm = bm.arg("*");
524 } 520 }
525 521
526 messg->setText(bm); 522 messg->setText(bm);
527 emit debugMessage(bm); 523 emit debugMessage(bm);
528 524
529 writeline(scriptArgument); 525 writeline(scriptArgument);
@@ -569,49 +565,49 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
569 565
570 scriptTimeout=scriptArgument.toInt()*1000; 566 scriptTimeout=scriptArgument.toInt()*1000;
571 timeout_timer->start(scriptTimeout); 567 timeout_timer->start(scriptTimeout);
572 568
573 scriptindex++; 569 scriptindex++;
574 return; 570 return;
575 } 571 }
576 572
577 if (scriptCommand == "Hangup") { 573 if (scriptCommand == "Hangup") {
578 messg->setText(i18n("Hangup")); 574 messg->setText(i18n("Hangup"));
579 emit debugMessage(i18n("Hangup")); 575 emit debugMessage(i18n("Hangup"));
580 576
581 writeline(PPPData::data()->modemHangupStr()); 577 writeline(_ifaceppp->data()->modemHangupStr());
582 setExpect(PPPData::data()->modemHangupResp()); 578 setExpect(_ifaceppp->data()->modemHangupResp());
583 579
584 scriptindex++; 580 scriptindex++;
585 return; 581 return;
586 } 582 }
587 583
588 if (scriptCommand == "Answer") { 584 if (scriptCommand == "Answer") {
589 585
590 timeout_timer->stop(); 586 timeout_timer->stop();
591 587
592 messg->setText(i18n("Answer")); 588 messg->setText(i18n("Answer"));
593 emit debugMessage(i18n("Answer")); 589 emit debugMessage(i18n("Answer"));
594 590
595 setExpect(PPPData::data()->modemRingResp()); 591 setExpect(_ifaceppp->data()->modemRingResp());
596 vmain = 150; 592 vmain = 150;
597 return; 593 return;
598 } 594 }
599 595
600 if (scriptCommand == "ID") { 596 if (scriptCommand == "ID") {
601 QString bm = i18n("ID %1").arg(scriptArgument); 597 QString bm = i18n("ID %1").arg(scriptArgument);
602 messg->setText(bm); 598 messg->setText(bm);
603 emit debugMessage(bm); 599 emit debugMessage(bm);
604 600
605 QString idstring = PPPData::data()->storedUsername(); 601 QString idstring = _ifaceppp->data()->storedUsername();
606 602
607 if(!idstring.isEmpty() && firstrunID) { 603 if(!idstring.isEmpty() && firstrunID) {
608 // the user entered an Id on the main kppp dialog 604 // the user entered an Id on the main kppp dialog
609 writeline(idstring); 605 writeline(idstring);
610 firstrunID = false; 606 firstrunID = false;
611 scriptindex++; 607 scriptindex++;
612 } 608 }
613 else { 609 else {
614 // the user didn't enter and Id on the main kppp dialog 610 // the user didn't enter and Id on the main kppp dialog
615 // let's query for an ID 611 // let's query for an ID
616 /* if not around yet, then post window... */ 612 /* if not around yet, then post window... */
617 if (prompt->Consumed()) { 613 if (prompt->Consumed()) {
@@ -629,46 +625,46 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
629 return; 625 return;
630 } 626 }
631 /* replace timeout value */ 627 /* replace timeout value */
632 } 628 }
633 } 629 }
634 } 630 }
635 631
636 if (scriptCommand == "Password") { 632 if (scriptCommand == "Password") {
637 QString bm = i18n("Password %1").arg(scriptArgument); 633 QString bm = i18n("Password %1").arg(scriptArgument);
638 messg->setText(bm); 634 messg->setText(bm);
639 emit debugMessage(bm); 635 emit debugMessage(bm);
640 636
641 QString pwstring = PPPData::data()->password(); 637 QString pwstring = _ifaceppp->data()->password();
642 638
643 if(!pwstring.isEmpty() && firstrunPW) { 639 if(!pwstring.isEmpty() && firstrunPW) {
644 // the user entered a password on the main kppp dialog 640 // the user entered a password on the main kppp dialog
645 writeline(pwstring); 641 writeline(pwstring);
646 firstrunPW = false; 642 firstrunPW = false;
647 scriptindex++; 643 scriptindex++;
648 } 644 }
649 else { 645 else {
650 // the user didn't enter a password on the main kppp dialog 646 // the user didn't enter a password on the main kppp dialog
651 // let's query for a password 647 // let's query for a password
652 /* if not around yet, then post window... */ 648 /* if not around yet, then post window... */
653 if (prompt->Consumed()) { 649 if (prompt->Consumed()) {
654 if (!(prompt->isVisible())) { 650 if (!(prompt->isVisible())) {
655 prompt->setPrompt(scriptArgument); 651 prompt->setPrompt(scriptArgument);
656 prompt->setEchoModePassword(); 652 prompt->setEchoModePassword();
657 prompt->show(); 653 prompt->show();
658 } 654 }
659 } else { 655 } else {
660 /* if prompt withdrawn ... then, */ 656 /* if prompt withdrawn ... then, */
661 if(!(prompt->isVisible())) { 657 if(!(prompt->isVisible())) {
662 p_kppp->setPW_Edit(prompt->text()); 658 // p_kppp->setPW_Edit(prompt->text());
663 writeline(prompt->text()); 659 writeline(prompt->text());
664 prompt->setConsumed(); 660 prompt->setConsumed();
665 scriptindex++; 661 scriptindex++;
666 return; 662 return;
667 } 663 }
668 /* replace timeout value */ 664 /* replace timeout value */
669 } 665 }
670 } 666 }
671 } 667 }
672 668
673 if (scriptCommand == "Prompt") { 669 if (scriptCommand == "Prompt") {
674 QString bm = i18n("Prompting %1"); 670 QString bm = i18n("Prompting %1");
@@ -776,26 +772,26 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
776 } 772 }
777 messg->setText(bm); 773 messg->setText(bm);
778 emit debugMessage(bm); 774 emit debugMessage(bm);
779 775
780 } 776 }
781 } 777 }
782 } 778 }
783 779
784 // this is a subroutine for the "Answer" script option 780 // this is a subroutine for the "Answer" script option
785 781
786 if(vmain == 150) { 782 if(vmain == 150) {
787 if(!expecting) { 783 if(!expecting) {
788 writeline(PPPData::data()->modemAnswerStr()); 784 writeline(_ifaceppp->data()->modemAnswerStr());
789 setExpect(PPPData::data()->modemAnswerResp()); 785 setExpect(_ifaceppp->data()->modemAnswerResp());
790 786
791 vmain = 2; 787 vmain = 2;
792 scriptindex++; 788 scriptindex++;
793 return; 789 return;
794 } 790 }
795 } 791 }
796 792
797 if(vmain == 30) { 793 if(vmain == 30) {
798// if (termwindow->isVisible()) 794// if (termwindow->isVisible())
799// return; 795// return;
800// if (termwindow->pressedContinue()) 796// if (termwindow->pressedContinue())
801// vmain = 10; 797// vmain = 10;
@@ -803,103 +799,103 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
803 cancelbutton(); 799 cancelbutton();
804 } 800 }
805 801
806 if(vmain == 10) { 802 if(vmain == 10) {
807 if(!expecting) { 803 if(!expecting) {
808 804
809 int result; 805 int result;
810 806
811 timeout_timer->stop(); 807 timeout_timer->stop();
812 if_timeout_timer->stop(); // better be sure. 808 if_timeout_timer->stop(); // better be sure.
813 809
814 // stop reading of data 810 // stop reading of data
815 Modem::modem->stop(); 811 _ifaceppp->modem()->stop();
816 812
817 if(PPPData::data()->authMethod() == AUTH_TERMINAL) { 813 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
818 // if (termwindow) { 814 // if (termwindow) {
819 // delete termwindow; 815 // delete termwindow;
820 // termwindow = 0L; 816 // termwindow = 0L;
821 // this->show(); 817 // this->show();
822 // } else { 818 // } else {
823 // termwindow = new LoginTerm(0L, 0L); 819 // termwindow = new LoginTerm(0L, 0L);
824 // hide(); 820 // hide();
825 // termwindow->show(); 821 // termwindow->show();
826 // vmain = 30; 822 // vmain = 30;
827 // return; 823 // return;
828 // } 824 // }
829 } 825 }
830 826
831 // Close the tty. This prevents the QTimer::singleShot() in 827 // Close the tty. This prevents the QTimer::singleShot() in
832 // Modem::readtty() from re-enabling the socket notifier. 828 // Modem::readtty() from re-enabling the socket notifier.
833 // The port is still held open by the helper process. 829 // The port is still held open by the helper process.
834 Modem::modem->closetty(); 830 _ifaceppp->modem()->closetty();
835 831
836 killTimer( main_timer_ID ); 832 killTimer( main_timer_ID );
837 833
838 if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000); 834 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
839 qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000); 835 qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000);
840 836
841 // find out PPP interface and notify the stats module 837 // find out PPP interface and notify the stats module
842// stats->setUnit(pppInterfaceNumber()); 838// stats->setUnit(pppInterfaceNumber());
843 839
844 qApp->flushX(); 840 qApp->flushX();
845 semaphore = true; 841 semaphore = true;
846 result = execppp(); 842 result = execppp();
847 843
848 emit debugMessage(i18n("Starting pppd...")); 844 emit debugMessage(i18n("Starting pppd..."));
849 qDebug("execppp() returned with return-code %i", result ); 845 qDebug("execppp() returned with return-code %i", result );
850 846
851 if(result) { 847 if(result) {
852 if(!PPPData::data()->autoDNS()) 848 if(!_ifaceppp->data()->autoDNS())
853 adddns(); 849 adddns( _ifaceppp );
854 850
855 // O.K we are done here, let's change over to the if_waiting loop 851 // O.K we are done here, let's change over to the if_waiting loop
856 // where we wait for the ppp if (interface) to come up. 852 // where we wait for the ppp if (interface) to come up.
857 853
858 emit if_waiting_signal(); 854 emit if_waiting_signal();
859 } else { 855 } else {
860 856
861 // starting pppd wasn't successful. Error messages were 857 // starting pppd wasn't successful. Error messages were
862 // handled by execppp(); 858 // handled by execppp();
863 if_timeout_timer->stop(); 859 if_timeout_timer->stop();
864 this->hide(); 860 this->hide();
865 messg->setText(""); 861 messg->setText("");
866 p_kppp->quit_b->setFocus(); 862 //p_kppp->quit_b->setFocus();
867 p_kppp->show(); 863 //p_kppp->show();
868 qApp->processEvents(); 864 qApp->processEvents();
869 Modem::modem->hangup(); 865 _ifaceppp->modem()->hangup();
870 emit stopAccounting(); 866 emit stopAccounting();
871 //p_kppp->con_win->stopClock(); 867 //p_kppp->con_win->stopClock();
872 Modem::modem->closetty(); 868 _ifaceppp->modem()->closetty();
873 Modem::modem->unlockdevice(); 869 _ifaceppp->modem()->unlockdevice();
874 870
875 } 871 }
876 872
877 return; 873 return;
878 } 874 }
879 } 875 }
880 876
881 // this is a "wait until cancel" entry 877 // this is a "wait until cancel" entry
882 878
883 if(vmain == 20) { 879 if(vmain == 20) {
884 } 880 }
885} 881}
886 882
887 883
888void ConnectWidget::set_con_speed_string() { 884void ConnectWidget::set_con_speed_string() {
889 // Here we are trying to determine the speed at which we are connected. 885 // Here we are trying to determine the speed at which we are connected.
890 // Usually the modem responds after connect with something like 886 // Usually the modem responds after connect with something like
891 // CONNECT 115200, so all we need to do is find the number after CONNECT 887 // CONNECT 115200, so all we need to do is find the number after CONNECT
892 // or whatever the modemConnectResp() is. 888 // or whatever the modemConnectResp() is.
893 p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer); 889// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
894} 890}
895 891
896 892
897 893
898void ConnectWidget::readChar(unsigned char c) { 894void ConnectWidget::readChar(unsigned char c) {
899 if(semaphore) 895 if(semaphore)
900 return; 896 return;
901 897
902 readbuffer += c; 898 readbuffer += c;
903 myreadbuffer += c; 899 myreadbuffer += c;
904 900
905 // While in scanning mode store each char to the scan buffer 901 // While in scanning mode store each char to the scan buffer
@@ -960,56 +956,56 @@ void ConnectWidget::checkBuffers() {
960 } 956 }
961} 957}
962 958
963 959
964 960
965void ConnectWidget::pause() { 961void ConnectWidget::pause() {
966 pausing = false; 962 pausing = false;
967 pausetimer->stop(); 963 pausetimer->stop();
968} 964}
969 965
970 966
971void ConnectWidget::cancelbutton() { 967void ConnectWidget::cancelbutton() {
972 Modem::modem->stop(); 968 _ifaceppp->modem()->stop();
973 killTimer(main_timer_ID); 969 killTimer(main_timer_ID);
974 timeout_timer->stop(); 970 timeout_timer->stop();
975 if_timer->stop(); 971 if_timer->stop();
976 if_timeout_timer->stop(); 972 if_timeout_timer->stop();
977 973
978// if (termwindow) { 974// if (termwindow) {
979// delete termwindow; 975// delete termwindow;
980// termwindow = 0L; 976// termwindow = 0L;
981// this->show(); 977// this->show();
982// } 978// }
983 979
984 messg->setText(i18n("One moment please...")); 980 messg->setText(i18n("One moment please..."));
985 981
986 // just to be sure 982 // just to be sure
987 Modem::modem->removeSecret(AUTH_PAP); 983 _ifaceppp->modem()->removeSecret(AUTH_PAP);
988 Modem::modem->removeSecret(AUTH_CHAP); 984 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
989 removedns(); 985 removedns(_ifaceppp);
990 986
991 qApp->processEvents(); 987 qApp->processEvents();
992 988
993 Modem::modem->killPPPDaemon(); 989 _ifaceppp->modem()->killPPPDaemon();
994 Modem::modem->hangup(); 990 _ifaceppp->modem()->hangup();
995 991
996 this->hide(); 992 this->hide();
997 messg->setText(""); 993 messg->setText("");
998 p_kppp->quit_b->setFocus(); 994// p_kppp->quit_b->setFocus();
999 p_kppp->show(); 995// p_kppp->show();
1000 emit stopAccounting();// just to be sure 996 emit stopAccounting();// just to be sure
1001// p_kppp->con_win->stopClock(); 997// p_kppp->con_win->stopClock();
1002 Modem::modem->closetty(); 998 _ifaceppp->modem()->closetty();
1003 Modem::modem->unlockdevice(); 999 _ifaceppp->modem()->unlockdevice();
1004 1000
1005 //abort prompt window... 1001 //abort prompt window...
1006 if (prompt->isVisible()) { 1002 if (prompt->isVisible()) {
1007 prompt->hide(); 1003 prompt->hide();
1008 } 1004 }
1009 prompt->setConsumed(); 1005 prompt->setConsumed();
1010 1006
1011// if(p_kppp->quitOnDisconnect()) 1007// if(p_kppp->quitOnDisconnect())
1012// qApp->exit(0); 1008// qApp->exit(0);
1013} 1009}
1014 1010
1015 1011
@@ -1017,25 +1013,25 @@ void ConnectWidget::script_timed_out() {
1017 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1013 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1018 timeout_timer->stop(); 1014 timeout_timer->stop();
1019 emit stopAccounting(); 1015 emit stopAccounting();
1020// p_kppp->con_win->stopClock(); 1016// p_kppp->con_win->stopClock();
1021 return; 1017 return;
1022 } 1018 }
1023 1019
1024 if (prompt->isVisible()) 1020 if (prompt->isVisible())
1025 prompt->hide(); 1021 prompt->hide();
1026 1022
1027 prompt->setConsumed(); 1023 prompt->setConsumed();
1028 messg->setText(i18n("Script timed out!")); 1024 messg->setText(i18n("Script timed out!"));
1029 Modem::modem->hangup(); 1025 _ifaceppp->modem()->hangup();
1030 emit stopAccounting(); 1026 emit stopAccounting();
1031// p_kppp->con_win->stopClock(); 1027// p_kppp->con_win->stopClock();
1032 1028
1033 vmain = 0; // let's try again. 1029 vmain = 0; // let's try again.
1034 substate = -1; 1030 substate = -1;
1035} 1031}
1036 1032
1037 1033
1038void ConnectWidget::setScan(const QString &n) { 1034void ConnectWidget::setScan(const QString &n) {
1039 scanning = true; 1035 scanning = true;
1040 scanstr = n; 1036 scanstr = n;
1041 scanbuffer = ""; 1037 scanbuffer = "";
@@ -1054,385 +1050,385 @@ void ConnectWidget::setExpect(const QString &n) {
1054 emit debugMessage(ts); 1050 emit debugMessage(ts);
1055 1051
1056 // check if the expected string is in the read buffer already. 1052 // check if the expected string is in the read buffer already.
1057 checkBuffers(); 1053 checkBuffers();
1058} 1054}
1059 1055
1060 1056
1061void ConnectWidget::if_waiting_timed_out() { 1057void ConnectWidget::if_waiting_timed_out() {
1062 if_timer->stop(); 1058 if_timer->stop();
1063 if_timeout_timer->stop(); 1059 if_timeout_timer->stop();
1064 qDebug("if_waiting_timed_out()"); 1060 qDebug("if_waiting_timed_out()");
1065 1061
1066 PPPData::data()->setpppdError(E_IF_TIMEOUT); 1062 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1067 1063
1068 // let's kill the stuck pppd 1064 // let's kill the stuck pppd
1069 Modem::modem->killPPPDaemon(); 1065 _ifaceppp->modem()->killPPPDaemon();
1070 1066
1071 emit stopAccounting(); 1067 emit stopAccounting();
1072// p_kppp->con_win->stopClock(); 1068// p_kppp->con_win->stopClock();
1073 1069
1074 1070
1075 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1071 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1076 // in main.cpp what happens next will depend on the boolean 1072 // in main.cpp what happens next will depend on the boolean
1077 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1073 // reconnect_on_disconnect which is set in ConnectWidget::init();
1078} 1074}
1079 1075
1080void ConnectWidget::pppdDied() 1076void ConnectWidget::pppdDied()
1081{ 1077{
1082 if_timer->stop(); 1078 if_timer->stop();
1083 if_timeout_timer->stop(); 1079 if_timeout_timer->stop();
1084} 1080}
1085 1081
1086void ConnectWidget::if_waiting_slot() { 1082void ConnectWidget::if_waiting_slot() {
1087 messg->setText(i18n("Logging on to network...")); 1083 messg->setText(i18n("Logging on to network..."));
1088 1084
1089// if(!stats->ifIsUp()) { 1085// if(!stats->ifIsUp()) {
1090 1086
1091// if(PPPData::data()->pppdError() != 0) { 1087// if(_ifaceppp->data()->pppdError() != 0) {
1092// // we are here if pppd died immediately after starting it. 1088// // we are here if pppd died immediately after starting it.
1093// pppdDied(); 1089// pppdDied();
1094// // error message handled in main.cpp: sigPPPDDied() 1090// // error message handled in main.cpp: sigPPPDDied()
1095// return; 1091// return;
1096// } 1092// }
1097 1093
1098// if_timer->start(100, TRUE); // single shot 1094// if_timer->start(100, TRUE); // single shot
1099// return; 1095// return;
1100// } 1096// }
1101 1097
1102 // O.K the ppp interface is up and running 1098 // O.K the ppp interface is up and running
1103 // give it a few time to come up completly (0.2 seconds) 1099 // give it a few time to come up completly (0.2 seconds)
1104 if_timeout_timer->stop(); 1100 if_timeout_timer->stop();
1105 if_timer->stop(); 1101 if_timer->stop();
1106 usleep(200000); 1102 usleep(200000);
1107 1103
1108 if(PPPData::data()->autoDNS()) 1104 if(_ifaceppp->data()->autoDNS())
1109 addpeerdns(); 1105 addpeerdns( _ifaceppp );
1110 1106
1111 // Close the debugging window. If we are connected, we 1107 // Close the debugging window. If we are connected, we
1112 // are not really interested in debug output 1108 // are not really interested in debug output
1113 emit closeDebugWindow(); 1109 emit closeDebugWindow();
1114// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1110// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1115 auto_hostname(); 1111 auto_hostname(_ifaceppp);
1116 1112
1117 if(!PPPData::data()->command_on_connect().isEmpty()) { 1113 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1118 messg->setText(i18n("Running startup command...")); 1114 messg->setText(i18n("Running startup command..."));
1119 1115
1120 // make sure that we don't get any async errors 1116 // make sure that we don't get any async errors
1121 qApp->flushX(); 1117 qApp->flushX();
1122 execute_command(PPPData::data()->command_on_connect()); 1118 execute_command(_ifaceppp->data()->command_on_connect());
1123 messg->setText(i18n("Done")); 1119 messg->setText(i18n("Done"));
1124 } 1120 }
1125 1121
1126 // remove the authentication file 1122 // remove the authentication file
1127 Modem::modem->removeSecret(AUTH_PAP); 1123 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1128 Modem::modem->removeSecret(AUTH_CHAP); 1124 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1129 1125
1130 emit debugMessage(i18n("Done")); 1126 emit debugMessage(i18n("Done"));
1131 set_con_speed_string(); 1127 set_con_speed_string();
1132 1128
1133// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1129// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1134 this->hide(); 1130 this->hide();
1135 messg->setText(""); 1131 messg->setText("");
1136 1132
1137 // prepare the con_win so as to have the right size for 1133 // prepare the con_win so as to have the right size for
1138 // accounting / non-accounting mode 1134 // accounting / non-accounting mode
1139// if(p_kppp->acct != 0) 1135// if(p_kppp->acct != 0)
1140// p_kppp->con_win->accounting(p_kppp->acct->running()); 1136// p_kppp->con_win->accounting(p_kppp->acct->running());
1141// else 1137// else
1142// p_kppp->con_win->accounting(false); 1138// p_kppp->con_win->accounting(false);
1143 1139
1144 if (PPPData::data()->get_dock_into_panel()) { 1140// if (_ifaceppp->data()->get_dock_into_panel()) {
1145// DockWidget::dock_widget->show(); 1141// // DockWidget::dock_widget->show();
1146// DockWidget::dock_widget->take_stats(); 1142// // DockWidget::dock_widget->take_stats();
1147// this->hide(); 1143// // this->hide();
1148 } 1144// }
1149 else { 1145// else {
1150// p_kppp->con_win->show(); 1146// // p_kppp->con_win->show();
1151 1147
1152 if(PPPData::data()->get_iconify_on_connect()) { 1148// if(_ifaceppp->data()->get_iconify_on_connect()) {
1153 // p_kppp->con_win->showMinimized(); 1149// // p_kppp->con_win->showMinimized();
1154 } 1150// }
1155 } 1151// }
1156 1152
1157 Modem::modem->closetty(); 1153 _ifaceppp->modem()->closetty();
1158} 1154}
1159 1155
1160 1156
1161bool ConnectWidget::execppp() { 1157bool ConnectWidget::execppp() {
1162 QString command; 1158 QString command;
1163 1159
1164 command = "pppd"; 1160 command = "pppd";
1165 1161
1166 // as of version 2.3.6 pppd falls back to the real user rights when 1162 // as of version 2.3.6 pppd falls back to the real user rights when
1167 // opening a device given in a command line. To avoid permission conflicts 1163 // opening a device given in a command line. To avoid permission conflicts
1168 // we'll simply leave this argument away. pppd will then use the default tty 1164 // we'll simply leave this argument away. pppd will then use the default tty
1169 // which is the serial port we connected stdin/stdout to in opener.cpp. 1165 // which is the serial port we connected stdin/stdout to in opener.cpp.
1170 // command += " "; 1166 // command += " ";
1171 // command += PPPData::data()->modemDevice(); 1167 // command += _ifaceppp->data()->modemDevice();
1172 1168
1173 command += " " + PPPData::data()->speed(); 1169 command += " " + _ifaceppp->data()->speed();
1174 1170
1175 command += " -detach"; 1171 command += " -detach";
1176 1172
1177 if(PPPData::data()->ipaddr() != "0.0.0.0" || 1173 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1178 PPPData::data()->gateway() != "0.0.0.0") { 1174 _ifaceppp->data()->gateway() != "0.0.0.0") {
1179 if(PPPData::data()->ipaddr() != "0.0.0.0") { 1175 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1180 command += " "; 1176 command += " ";
1181 command += PPPData::data()->ipaddr(); 1177 command += _ifaceppp->data()->ipaddr();
1182 command += ":"; 1178 command += ":";
1183 } 1179 }
1184 else { 1180 else {
1185 command += " "; 1181 command += " ";
1186 command += ":"; 1182 command += ":";
1187 } 1183 }
1188 1184
1189 if(PPPData::data()->gateway() != "0.0.0.0") 1185 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1190 command += PPPData::data()->gateway(); 1186 command += _ifaceppp->data()->gateway();
1191 } 1187 }
1192 1188
1193 if(PPPData::data()->subnetmask() != "0.0.0.0") 1189 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1194 command += " netmask " + PPPData::data()->subnetmask(); 1190 command += " netmask " + _ifaceppp->data()->subnetmask();
1195 1191
1196 if(PPPData::data()->flowcontrol() != "None") { 1192 if(_ifaceppp->data()->flowcontrol() != "None") {
1197 if(PPPData::data()->flowcontrol() == "CRTSCTS") 1193 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
1198 command += " crtscts"; 1194 command += " crtscts";
1199 else 1195 else
1200 command += " xonxoff"; 1196 command += " xonxoff";
1201 } 1197 }
1202 1198
1203 if(PPPData::data()->defaultroute()) 1199 if(_ifaceppp->data()->defaultroute())
1204 command += " defaultroute"; 1200 command += " defaultroute";
1205 1201
1206 if(PPPData::data()->autoDNS()) 1202 if(_ifaceppp->data()->autoDNS())
1207 command += " usepeerdns"; 1203 command += " usepeerdns";
1208 1204
1209 QStringList &arglist = PPPData::data()->pppdArgument(); 1205 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1210 for ( QStringList::Iterator it = arglist.begin(); 1206 for ( QStringList::Iterator it = arglist.begin();
1211 it != arglist.end(); 1207 it != arglist.end();
1212 ++it ) 1208 ++it )
1213 { 1209 {
1214 command += " " + *it; 1210 command += " " + *it;
1215 } 1211 }
1216 1212
1217 // PAP settings 1213 // PAP settings
1218 if(PPPData::data()->authMethod() == AUTH_PAP) { 1214 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1219 command += " -chap user "; 1215 command += " -chap user ";
1220 command = command + "\"" + PPPData::data()->storedUsername() + "\""; 1216 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1221 } 1217 }
1222 1218
1223 // CHAP settings 1219 // CHAP settings
1224 if(PPPData::data()->authMethod() == AUTH_CHAP) { 1220 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1225 command += " -pap user "; 1221 command += " -pap user ";
1226 command = command + "\"" + PPPData::data()->storedUsername() + "\""; 1222 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1227 } 1223 }
1228 1224
1229 // PAP/CHAP settings 1225 // PAP/CHAP settings
1230 if(PPPData::data()->authMethod() == AUTH_PAPCHAP) { 1226 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1231 command += " user "; 1227 command += " user ";
1232 command = command + "\"" + PPPData::data()->storedUsername() + "\""; 1228 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1233 } 1229 }
1234 1230
1235 // check for debug 1231 // check for debug
1236 if(PPPData::data()->getPPPDebug()) 1232 if(_ifaceppp->data()->getPPPDebug())
1237 command += " debug"; 1233 command += " debug";
1238 1234
1239 if (command.length() > MAX_CMDLEN) { 1235 if (command.length() > MAX_CMDLEN) {
1240 QMessageBox::critical(this, "error", i18n( 1236 QMessageBox::critical(this, "error", i18n(
1241 "pppd command + command-line arguments exceed " 1237 "pppd command + command-line arguments exceed "
1242 "2024 characters in length." 1238 "2024 characters in length."
1243 )); 1239 ));
1244 1240
1245 return false; // nonsensically long command which would bust my buffer buf. 1241 return false; // nonsensically long command which would bust my buffer buf.
1246 } 1242 }
1247 1243
1248 qApp->flushX(); 1244 qApp->flushX();
1249 1245
1250 return Modem::modem->execPPPDaemon(command); 1246 return _ifaceppp->modem()->execPPPDaemon(command);
1251} 1247}
1252 1248
1253 1249
1254void ConnectWidget::closeEvent( QCloseEvent *e ) { 1250void ConnectWidget::closeEvent( QCloseEvent *e ) {
1255 e->ignore(); 1251 e->ignore();
1256 emit cancelbutton(); 1252 emit cancelbutton();
1257} 1253}
1258 1254
1259 1255
1260void ConnectWidget::setMsg(const QString &msg) { 1256void ConnectWidget::setMsg(const QString &msg) {
1261 messg->setText(msg); 1257 messg->setText(msg);
1262} 1258}
1263 1259
1264void ConnectWidget::writeline(const QString &s) { 1260void ConnectWidget::writeline(const QString &s) {
1265 Modem::modem->writeLine(s.local8Bit()); 1261 _ifaceppp->modem()->writeLine(s.local8Bit());
1266} 1262}
1267 1263
1268// Set the hostname and domain from DNS Server 1264// Set the hostname and domain from DNS Server
1269void auto_hostname() { 1265void auto_hostname(InterfacePPP *_ifaceppp) {
1270 struct in_addr local_ip; 1266 struct in_addr local_ip;
1271 struct hostent *hostname_entry; 1267 struct hostent *hostname_entry;
1272 QString new_hostname; 1268 QString new_hostname;
1273 int dot; 1269 int dot;
1274 char tmp_str[100]; // buffer overflow safe 1270 char tmp_str[100]; // buffer overflow safe
1275 1271
1276 gethostname(tmp_str, sizeof(tmp_str)); 1272 gethostname(tmp_str, sizeof(tmp_str));
1277 tmp_str[sizeof(tmp_str)-1]=0; // panic 1273 tmp_str[sizeof(tmp_str)-1]=0; // panic
1278 old_hostname=tmp_str; // copy to QString 1274 old_hostname=tmp_str; // copy to QString
1279 1275
1280 // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) { 1276 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
1281 if ( PPPData::data()->autoname()) { 1277 if ( _ifaceppp->data()->autoname()) {
1282// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); 1278// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
1283 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); 1279 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
1284 1280
1285 if (hostname_entry != 0L) { 1281 if (hostname_entry != 0L) {
1286 new_hostname=hostname_entry->h_name; 1282 new_hostname=hostname_entry->h_name;
1287 dot=new_hostname.find('.'); 1283 dot=new_hostname.find('.');
1288 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); 1284 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
1289 Modem::modem->setHostname(new_hostname); 1285 _ifaceppp->modem()->setHostname(new_hostname);
1290 modified_hostname = TRUE; 1286 modified_hostname = TRUE;
1291 1287
1292 new_hostname=hostname_entry->h_name; 1288 new_hostname=hostname_entry->h_name;
1293 new_hostname.remove(0,dot+1); 1289 new_hostname.remove(0,dot+1);
1294 1290
1295 add_domain(new_hostname); 1291 add_domain(new_hostname, _ifaceppp);
1296 } 1292 }
1297 } 1293 }
1298 1294
1299} 1295}
1300 1296
1301// Replace the DNS domain entry in the /etc/resolv.conf file and 1297// Replace the DNS domain entry in the /etc/resolv.conf file and
1302// disable the nameserver entries if option is enabled 1298// disable the nameserver entries if option is enabled
1303void add_domain(const QString &domain) { 1299void add_domain(const QString &domain, InterfacePPP *_ifaceppp) {
1304 1300
1305 int fd; 1301 int fd;
1306 char c; 1302 char c;
1307 QString resolv[MAX_RESOLVCONF_LINES]; 1303 QString resolv[MAX_RESOLVCONF_LINES];
1308 1304
1309 if (domain.isEmpty()) 1305 if (domain.isEmpty())
1310 return; 1306 return;
1311 1307
1312 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { 1308 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1313 1309
1314 int i=0; 1310 int i=0;
1315 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { 1311 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
1316 if(c == '\n') { 1312 if(c == '\n') {
1317 i++; 1313 i++;
1318 } 1314 }
1319 else { 1315 else {
1320 resolv[i] += c; 1316 resolv[i] += c;
1321 } 1317 }
1322 } 1318 }
1323 close(fd); 1319 close(fd);
1324 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; 1320 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
1325 1321
1326 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1322 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1327 QCString tmp = "domain " + domain.local8Bit() + 1323 QCString tmp = "domain " + domain.local8Bit() +
1328 " \t\t#kppp temp entry\n"; 1324 " \t\t#kppp temp entry\n";
1329 write(fd, tmp.data(), tmp.length()); 1325 write(fd, tmp.data(), tmp.length());
1330 1326
1331 for(int j=0; j < i; j++) { 1327 for(int j=0; j < i; j++) {
1332 if((resolv[j].contains("domain") || 1328 if((resolv[j].contains("domain") ||
1333 ( resolv[j].contains("nameserver") 1329 ( resolv[j].contains("nameserver")
1334 && !resolv[j].contains("#kppp temp entry") 1330 && !resolv[j].contains("#kppp temp entry")
1335 && PPPData::data()->exDNSDisabled())) 1331 && _ifaceppp->data()->exDNSDisabled()))
1336 && !resolv[j].contains("#entry disabled by kppp")) { 1332 && !resolv[j].contains("#entry disabled by kppp")) {
1337 QCString tmp = "# " + resolv[j].local8Bit() + 1333 QCString tmp = "# " + resolv[j].local8Bit() +
1338 " \t#entry disabled by kppp\n"; 1334 " \t#entry disabled by kppp\n";
1339 write(fd, tmp, tmp.length()); 1335 write(fd, tmp, tmp.length());
1340 } 1336 }
1341 else { 1337 else {
1342 QCString tmp = resolv[j].local8Bit() + "\n"; 1338 QCString tmp = resolv[j].local8Bit() + "\n";
1343 write(fd, tmp, tmp.length()); 1339 write(fd, tmp, tmp.length());
1344 } 1340 }
1345 } 1341 }
1346 } 1342 }
1347 close(fd); 1343 close(fd);
1348 } 1344 }
1349} 1345}
1350 1346
1351 1347
1352// adds the DNS entries in the /etc/resolv.conf file 1348// adds the DNS entries in the /etc/resolv.conf file
1353void adddns() 1349void adddns( InterfacePPP *_ifaceppp)
1354{ 1350{
1355 int fd; 1351 int fd;
1356 1352
1357 if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1353 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1358 QStringList &dnslist = PPPData::data()->dns(); 1354 QStringList &dnslist = _ifaceppp->data()->dns();
1359 for ( QStringList::Iterator it = dnslist.begin(); 1355 for ( QStringList::Iterator it = dnslist.begin();
1360 it != dnslist.end(); 1356 it != dnslist.end();
1361 ++it ) 1357 ++it )
1362 { 1358 {
1363 QCString dns = "nameserver " + (*it).local8Bit() + 1359 QCString dns = "nameserver " + (*it).local8Bit() +
1364 " \t#kppp temp entry\n"; 1360 " \t#kppp temp entry\n";
1365 write(fd, dns.data(), dns.length()); 1361 write(fd, dns.data(), dns.length());
1366 } 1362 }
1367 close(fd); 1363 close(fd);
1368 } 1364 }
1369 add_domain(PPPData::data()->domain()); 1365 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1370} 1366}
1371 1367
1372void addpeerdns() { 1368void addpeerdns(InterfacePPP *_ifaceppp) {
1373 int fd, fd2; 1369 int fd, fd2;
1374 1370
1375 if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1371 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1376 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { 1372 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
1377 char c; 1373 char c;
1378 int i = 0; 1374 int i = 0;
1379 while(i++ < 100 && read(fd2, &c, 1) == 1) { 1375 while(i++ < 100 && read(fd2, &c, 1) == 1) {
1380 if(c == '\n') 1376 if(c == '\n')
1381 write(fd, "\t#kppp temp entry\n", 18); 1377 write(fd, "\t#kppp temp entry\n", 18);
1382 else 1378 else
1383 write(fd, &c, 1); 1379 write(fd, &c, 1);
1384 } 1380 }
1385 close(fd2); 1381 close(fd2);
1386 } else 1382 } else
1387 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); 1383 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
1388 close(fd); 1384 close(fd);
1389 } 1385 }
1390 add_domain(PPPData::data()->domain()); 1386 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1391} 1387}
1392 1388
1393// remove the dns entries from the /etc/resolv.conf file 1389// remove the dns entries from the /etc/resolv.conf file
1394void removedns() { 1390void removedns(InterfacePPP *_ifaceppp) {
1395 1391
1396 int fd; 1392 int fd;
1397 char c; 1393 char c;
1398 QString resolv[MAX_RESOLVCONF_LINES]; 1394 QString resolv[MAX_RESOLVCONF_LINES];
1399 1395
1400 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { 1396 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1401 1397
1402 int i=0; 1398 int i=0;
1403 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { 1399 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
1404 if(c == '\n') { 1400 if(c == '\n') {
1405 i++; 1401 i++;
1406 } 1402 }
1407 else { 1403 else {
1408 resolv[i] += c; 1404 resolv[i] += c;
1409 } 1405 }
1410 } 1406 }
1411 close(fd); 1407 close(fd);
1412 1408
1413 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1409 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1414 for(int j=0; j < i; j++) { 1410 for(int j=0; j < i; j++) {
1415 if(resolv[j].contains("#kppp temp entry")) continue; 1411 if(resolv[j].contains("#kppp temp entry")) continue;
1416 if(resolv[j].contains("#entry disabled by kppp")) { 1412 if(resolv[j].contains("#entry disabled by kppp")) {
1417 QCString tmp = resolv[j].local8Bit(); 1413 QCString tmp = resolv[j].local8Bit();
1418 write(fd, tmp.data()+2, tmp.length() - 27); 1414 write(fd, tmp.data()+2, tmp.length() - 27);
1419 write(fd, "\n", 1); 1415 write(fd, "\n", 1);
1420 } 1416 }
1421 else { 1417 else {
1422 QCString tmp = resolv[j].local8Bit() + "\n"; 1418 QCString tmp = resolv[j].local8Bit() + "\n";
1423 write(fd, tmp, tmp.length()); 1419 write(fd, tmp, tmp.length());
1424 } 1420 }
1425 } 1421 }
1426 } 1422 }
1427 close(fd); 1423 close(fd);
1428 1424
1429 } 1425 }
1430 1426
1431 if ( modified_hostname ) { 1427 if ( modified_hostname ) {
1432 Modem::modem->setHostname(old_hostname); 1428 _ifaceppp->modem()->setHostname(old_hostname);
1433 modified_hostname = FALSE; 1429 modified_hostname = FALSE;
1434 } 1430 }
1435 1431
1436} 1432}
1437 1433
1438 1434
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h
index 3127236..e7ae5e0 100644
--- a/noncore/settings/networksettings/ppp/connect.h
+++ b/noncore/settings/networksettings/ppp/connect.h
@@ -27,35 +27,35 @@
27 */ 27 */
28 28
29#ifndef _CONNECT_H_ 29#ifndef _CONNECT_H_
30#define _CONNECT_H_ 30#define _CONNECT_H_
31 31
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qevent.h> 35#include <qevent.h>
36 36
37#include "kpppconfig.h" 37#include "kpppconfig.h"
38#include "pwentry.h" 38#include "pwentry.h"
39//#include "docking.h" 39
40//#include "loginterm.h"
41 40
42#define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2) 41#define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2)
43 42
44class PPPStats; 43class InterfacePPP;
44class PPPData;
45 45
46class ConnectWidget : public QWidget { 46class ConnectWidget : public QWidget {
47 Q_OBJECT 47 Q_OBJECT
48public: 48public:
49 ConnectWidget(QWidget *parent, const char *name); 49 ConnectWidget(InterfacePPP*, QWidget *parent, const char *name);
50 ~ConnectWidget(); 50 ~ConnectWidget();
51 51
52public: 52public:
53 void set_con_speed_string(); 53 void set_con_speed_string();
54 void setMsg(const QString &); 54 void setMsg(const QString &);
55 void pppdDied(); 55 void pppdDied();
56 56
57protected: 57protected:
58 void timerEvent(QTimerEvent *); 58 void timerEvent(QTimerEvent *);
59 void closeEvent( QCloseEvent *e ); 59 void closeEvent( QCloseEvent *e );
60 60
61private slots: 61private slots:
@@ -127,26 +127,26 @@ private:
127 QTimer *pausetimer; 127 QTimer *pausetimer;
128 QTimer *if_timer; 128 QTimer *if_timer;
129 QTimer *if_timeout_timer; 129 QTimer *if_timeout_timer;
130 130
131 QLabel *messg; 131 QLabel *messg;
132 QPushButton *cancel; 132 QPushButton *cancel;
133 133
134 bool firstrunID; 134 bool firstrunID;
135 bool firstrunPW; 135 bool firstrunPW;
136 136
137 unsigned int dialnumber; // the current number to dial 137 unsigned int dialnumber; // the current number to dial
138 138
139// PPPStats *stats; 139 InterfacePPP *_ifaceppp;
140}; 140};
141 141
142 142
143// non-member function to kill&wait on the pppd child process 143// non-member function to kill&wait on the pppd child process
144extern void killppp(); 144extern void killppp(PPPData*);
145void adddns(); 145void adddns(InterfacePPP*);
146void addpeerdns(); 146void addpeerdns(InterfacePPP*);
147void removedns(); 147void removedns(InterfacePPP*);
148void add_domain(const QString & newdomain); 148void add_domain(const QString & newdomain, InterfacePPP*);
149void auto_hostname(); 149void auto_hostname(InterfacePPP*);
150 150
151#endif 151#endif
152 152
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index 20d705d..9136ca0 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -22,37 +22,34 @@
22 */ 22 */
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include "conwindow.h" 26#include "conwindow.h"
27//#include "docking.h" 27//#include "docking.h"
28#include "pppdata.h" 28#include "pppdata.h"
29// #include "pppstats.h" 29// #include "pppstats.h"
30// #include <klocale.h> 30// #include <klocale.h>
31#define i18n QObject::tr 31#define i18n QObject::tr
32// #include <kglobal.h> 32// #include <kglobal.h>
33 33
34extern PPPData gpppdata;
35 34
36ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) 35ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name,
37 // PPPStats *st) 36 QDialog *mainwidget )
38 : QWidget(parent, name, 0), 37 : QWidget(parent, name, 0),
39 minutes(0), 38 minutes(0),
40 seconds(0), 39 seconds(0),
41 hours(0), 40 hours(0),
42 days(0), 41 days(0),
43 tl1(0), 42 tl1(0),
44// stats(st), 43 _pppdata(pd)
45 accountingEnabled(false),
46 volumeAccountingEnabled(false)
47{ 44{
48 info1 = new QLabel(i18n("Connected at:"), this); 45 info1 = new QLabel(i18n("Connected at:"), this);
49 info2 = new QLabel("", this); 46 info2 = new QLabel("", this);
50 47
51 timelabel1 = new QLabel(i18n("Time connected:"), this); 48 timelabel1 = new QLabel(i18n("Time connected:"), this);
52 timelabel2 = new QLabel("000:00:00", this); 49 timelabel2 = new QLabel("000:00:00", this);
53 50
54 vollabel = new QLabel(i18n("Volume:"), this); 51 vollabel = new QLabel(i18n("Volume:"), this);
55 volinfo = new QLabel("", this); 52 volinfo = new QLabel("", this);
56 53
57 // now the stuff for accounting 54 // now the stuff for accounting
58 session_bill_l = new QLabel(i18n("Session Bill:"), this); 55 session_bill_l = new QLabel(i18n("Session Bill:"), this);
@@ -106,185 +103,185 @@ QString ConWindow::prettyPrintVolume(unsigned int n) {
106 n /= 1024; 103 n /= 1024;
107 } 104 }
108 105
109 int i = idx; 106 int i = idx;
110 while(i--) 107 while(i--)
111 n1 = n1 / 1024.0; 108 n1 = n1 / 1024.0;
112 109
113 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); 110 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
114 s += " " + quant[idx]; 111 s += " " + quant[idx];
115 return s; 112 return s;
116} 113}
117 114
118void ConWindow::accounting(bool on) { 115// void ConWindow::accounting(bool on) {
119 // cache accounting settings 116// // cache accounting settings
120 accountingEnabled = on; 117// accountingEnabled = on;
121 volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); 118// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
122
123 // delete old layout
124 if(tl1 != 0)
125 delete tl1;
126
127 // add layout now
128 tl1 = new QVBoxLayout(this, 10, 10);
129 tl1->addSpacing(5);
130 QHBoxLayout *tl = new QHBoxLayout;
131 tl1->addLayout(tl);
132 tl->addSpacing(20);
133 QGridLayout *l1;
134
135 int vol_lines = 0;
136 if(PPPData::data()->VolAcctEnabled())
137 vol_lines = 1;
138
139 if(accountingEnabled)
140 l1 = new QGridLayout(4 + vol_lines, 2, 5);
141 else
142 l1 = new QGridLayout(2 + vol_lines, 2, 5);
143 tl->addLayout(l1);
144 l1->setColStretch(0, 0);
145 l1->setColStretch(1, 1);
146
147 info2->setAlignment(AlignRight|AlignVCenter);
148 timelabel2->setAlignment(AlignRight|AlignVCenter);
149 session_bill->setAlignment(AlignRight|AlignVCenter);
150 total_bill->setAlignment(AlignRight|AlignVCenter);
151 volinfo->setAlignment(AlignRight|AlignVCenter);
152 // make sure that there's enough space for the bills
153 QString s1 = session_bill->text();
154 QString s2 = total_bill->text();
155 QString s3 = volinfo->text();
156
157 session_bill->setText("888888.88 XXX");
158 total_bill->setText("888888.88 XXX");
159 volinfo->setText("8888.8 MB");
160 session_bill->setFixedSize(session_bill->sizeHint());
161 total_bill->setFixedSize(total_bill->sizeHint());
162 volinfo->setFixedSize(volinfo->sizeHint());
163 session_bill->setText(s1);
164 total_bill->setText(s2);
165 volinfo->setText(s3);
166
167 l1->addWidget(info1, 0, 0);
168 l1->addWidget(info2, 0, 1);
169 l1->addWidget(timelabel1, 1, 0);
170 l1->addWidget(timelabel2, 1, 1);
171 if(accountingEnabled) {
172 session_bill_l->show();
173 session_bill->show();
174 total_bill_l->show();
175 total_bill->show();
176 l1->addWidget(session_bill_l, 2, 0);
177 l1->addWidget(session_bill, 2, 1);
178 l1->addWidget(total_bill_l, 3, 0);
179 l1->addWidget(total_bill, 3, 1);
180
181 if(volumeAccountingEnabled) {
182 vollabel->show();
183 volinfo->show();
184 l1->addWidget(vollabel, 4, 0);
185 l1->addWidget(volinfo, 4, 1);
186 } else {
187 vollabel->hide();
188 volinfo->hide();
189 }
190
191 } else {
192 session_bill_l->hide();
193 session_bill->hide();
194 total_bill_l->hide();
195 total_bill->hide();
196
197 if(volumeAccountingEnabled) {
198 vollabel->show();
199 volinfo->show();
200 l1->addWidget(vollabel, 2, 0);
201 l1->addWidget(volinfo, 2, 1);
202 } else {
203 vollabel->hide();
204 volinfo->hide();
205 }
206 }
207 119
208 tl->addSpacing(10); 120// // delete old layout
209 QVBoxLayout *l2 = new QVBoxLayout(5); 121// if(tl1 != 0)
210 tl->addLayout(l2); 122// delete tl1;
211 l2->addStretch(1);
212// l2->addWidget(statsbutton);
213 l2->addWidget(cancelbutton);
214 123
215 l2->addStretch(1); 124// // add layout now
125// tl1 = new QVBoxLayout(this, 10, 10);
126// tl1->addSpacing(5);
127// QHBoxLayout *tl = new QHBoxLayout;
128// tl1->addLayout(tl);
129// tl->addSpacing(20);
130// QGridLayout *l1;
216 131
217 tl1->addSpacing(5); 132// int vol_lines = 0;
133// // if(_pppdata->VolAcctEnabled())
134// // vol_lines = 1;
218 135
219 setFixedSize(sizeHint()); 136// if(accountingEnabled)
220/* 137// l1 = new QGridLayout(4 + vol_lines, 2, 5);
221 do not overwrite position read from config 138// else
222 setGeometry((QApplication::desktop()->width() - width()) / 2, 139// l1 = new QGridLayout(2 + vol_lines, 2, 5);
223 (QApplication::desktop()->height() - height())/2, 140// tl->addLayout(l1);
224 width(), 141// l1->setColStretch(0, 0);
225 height()); 142// l1->setColStretch(1, 1);
226*/ 143
227} 144// info2->setAlignment(AlignRight|AlignVCenter);
145// timelabel2->setAlignment(AlignRight|AlignVCenter);
146// session_bill->setAlignment(AlignRight|AlignVCenter);
147// total_bill->setAlignment(AlignRight|AlignVCenter);
148// volinfo->setAlignment(AlignRight|AlignVCenter);
149// // make sure that there's enough space for the bills
150// QString s1 = session_bill->text();
151// QString s2 = total_bill->text();
152// QString s3 = volinfo->text();
153
154// session_bill->setText("888888.88 XXX");
155// total_bill->setText("888888.88 XXX");
156// volinfo->setText("8888.8 MB");
157// session_bill->setFixedSize(session_bill->sizeHint());
158// total_bill->setFixedSize(total_bill->sizeHint());
159// volinfo->setFixedSize(volinfo->sizeHint());
160// session_bill->setText(s1);
161// total_bill->setText(s2);
162// volinfo->setText(s3);
163
164// l1->addWidget(info1, 0, 0);
165// l1->addWidget(info2, 0, 1);
166// l1->addWidget(timelabel1, 1, 0);
167// l1->addWidget(timelabel2, 1, 1);
168// if(accountingEnabled) {
169// session_bill_l->show();
170// session_bill->show();
171// total_bill_l->show();
172// total_bill->show();
173// l1->addWidget(session_bill_l, 2, 0);
174// l1->addWidget(session_bill, 2, 1);
175// l1->addWidget(total_bill_l, 3, 0);
176// l1->addWidget(total_bill, 3, 1);
177
178// if(volumeAccountingEnabled) {
179// vollabel->show();
180// volinfo->show();
181// l1->addWidget(vollabel, 4, 0);
182// l1->addWidget(volinfo, 4, 1);
183// } else {
184// vollabel->hide();
185// volinfo->hide();
186// }
187
188// } else {
189// session_bill_l->hide();
190// session_bill->hide();
191// total_bill_l->hide();
192// total_bill->hide();
193
194// if(volumeAccountingEnabled) {
195// vollabel->show();
196// volinfo->show();
197// l1->addWidget(vollabel, 2, 0);
198// l1->addWidget(volinfo, 2, 1);
199// } else {
200// vollabel->hide();
201// volinfo->hide();
202// }
203// }
228 204
205// tl->addSpacing(10);
206// QVBoxLayout *l2 = new QVBoxLayout(5);
207// tl->addLayout(l2);
208// l2->addStretch(1);
209// // l2->addWidget(statsbutton);
210// l2->addWidget(cancelbutton);
229 211
230void ConWindow::dock() { 212// l2->addStretch(1);
231// DockWidget::dock_widget->show(); 213
232 this->hide(); 214// tl1->addSpacing(5);
233} 215
216// setFixedSize(sizeHint());
217// /*
218// do not overwrite position read from config
219// setGeometry((QApplication::desktop()->width() - width()) / 2,
220 // (QApplication::desktop()->height() - height())/2,
221 // width(),
222 // height());
223// */
224// }
225
226
227// void ConWindow::dock() {
228// // DockWidget::dock_widget->show();
229// this->hide();
230// }
234 231
235 232
236void ConWindow::startClock() { 233void ConWindow::startClock() {
237 minutes = 0; 234 minutes = 0;
238 seconds = 0; 235 seconds = 0;
239 hours = 0; 236 hours = 0;
240 QString title ; 237 QString title ;
241 238
242 title = PPPData::data()->accname(); 239 title = _pppdata->accname();
243 240
244 if(PPPData::data()->get_show_clock_on_caption()){ 241 if(_pppdata->get_show_clock_on_caption()){
245 title += " 00:00" ; 242 title += " 00:00" ;
246 } 243 }
247 this->setCaption(title); 244 this->setCaption(title);
248 245
249 timelabel2->setText("00:00:00"); 246 timelabel2->setText("00:00:00");
250 clocktimer->start(1000); 247 clocktimer->start(1000);
251} 248}
252 249
253 250
254void ConWindow::setConnectionSpeed(const QString &speed) { 251void ConWindow::setConnectionSpeed(const QString &speed) {
255 info2->setText(speed); 252 info2->setText(speed);
256} 253}
257 254
258 255
259void ConWindow::stopClock() { 256void ConWindow::stopClock() {
260 clocktimer->stop(); 257 clocktimer->stop();
261} 258}
262 259
263 260
264void ConWindow::timeclick() { 261void ConWindow::timeclick() {
265// QString tooltip = i18n("Connection: %1\n" 262// QString tooltip = i18n("Connection: %1\n"
266 // "Connected at: %2\n" 263 // "Connected at: %2\n"
267 // "Time connected: %3") 264 // "Time connected: %3")
268 // .arg(PPPData::data()->accname()).arg(info2->text()) 265 // .arg(_pppdata->accname()).arg(info2->text())
269 // .arg(time_string2); 266 // .arg(time_string2);
270 267
271// if(accountingEnabled) 268// if(accountingEnabled)
272// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") 269// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
273 // .arg(session_bill->text()).arg(total_bill->text()); 270 // .arg(session_bill->text()).arg(total_bill->text());
274// // volume accounting 271// // volume accounting
275// if(volumeAccountingEnabled) { 272// if(volumeAccountingEnabled) {
276 273
277// volinfo->setEnabled(TRUE); 274// volinfo->setEnabled(TRUE);
278// int bytes = PPPData::data()->totalBytes(); 275// int bytes = _pppdata->totalBytes();
279// volinfo->setText(prettyPrintVolume(bytes)); 276// volinfo->setText(prettyPrintVolume(bytes));
280// } 277// }
281 278
282// seconds++; 279// seconds++;
283 280
284// if(seconds >= 60 ) { 281// if(seconds >= 60 ) {
285// minutes ++; 282// minutes ++;
286// seconds = 0; 283// seconds = 0;
287// } 284// }
288 285
289// if (minutes >= 60){ 286// if (minutes >= 60){
290// minutes = 0; 287// minutes = 0;
@@ -296,46 +293,46 @@ void ConWindow::timeclick() {
296// hours = 0; 293// hours = 0;
297// } 294// }
298 295
299// time_string.sprintf("%02d:%02d",hours,minutes); 296// time_string.sprintf("%02d:%02d",hours,minutes);
300// time_string2 = ""; 297// time_string2 = "";
301// if (days) 298// if (days)
302// time_string2.sprintf("%d d %02d:%02d:%02d", 299// time_string2.sprintf("%d d %02d:%02d:%02d",
303 // days,hours,minutes,seconds); 300 // days,hours,minutes,seconds);
304 301
305// else 302// else
306// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); 303// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
307 304
308// caption_string = PPPData::data()->accname(); 305// caption_string = _pppdata->accname();
309// caption_string += " "; 306// caption_string += " ";
310// caption_string += time_string; 307// caption_string += time_string;
311 308
312 309
313// timelabel2->setText(time_string2); 310// timelabel2->setText(time_string2);
314 311
315// if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){ 312// if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){
316// // we update the Caption only once per minute not every second 313// // we update the Caption only once per minute not every second
317// // otherwise I get a flickering icon 314// // otherwise I get a flickering icon
318// this->setCaption(caption_string); 315// this->setCaption(caption_string);
319// } 316// }
320 317
321// QToolTip::add(DockWidget::dock_widget, tooltip); 318// QToolTip::add(DockWidget::dock_widget, tooltip);
322} 319}
323 320
324 321
325void ConWindow::closeEvent( QCloseEvent *e ){ 322void ConWindow::closeEvent( QCloseEvent *e ){
326 // we don't want to lose the 323 // we don't want to lose the
327 // conwindow since this is our last connection kppp. 324 // conwindow since this is our last connection kppp.
328 // if we lost it we could only kill the program by hand to get on with life. 325 // if we lost it we could only kill the program by hand to get on with life.
329 e->ignore(); 326 e->ignore();
330 327
331 if(PPPData::data()->get_dock_into_panel()) 328// if(_pppdata->get_dock_into_panel())
332 dock(); 329// dock();
333} 330}
334 331
335 332
336void ConWindow::slotAccounting(QString total, QString session) { 333void ConWindow::slotAccounting(QString total, QString session) {
337 total_bill->setText(total); 334 total_bill->setText(total);
338 session_bill->setText(session); 335 session_bill->setText(session);
339} 336}
340 337
341 338
diff --git a/noncore/settings/networksettings/ppp/conwindow.h b/noncore/settings/networksettings/ppp/conwindow.h
index 20d3579..42c6f35 100644
--- a/noncore/settings/networksettings/ppp/conwindow.h
+++ b/noncore/settings/networksettings/ppp/conwindow.h
@@ -25,46 +25,46 @@
25#ifndef _CONWINDOW_H_ 25#ifndef _CONWINDOW_H_
26#define _CONWINDOW_H_ 26#define _CONWINDOW_H_
27 27
28 28
29#include <qtimer.h> 29#include <qtimer.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qframe.h> 33#include <qframe.h>
34#include <qevent.h> 34#include <qevent.h>
35#include <qlayout.h> 35#include <qlayout.h>
36 36
37//class PPPStats; 37class PPPData;
38 38
39class ConWindow : public QWidget { 39class ConWindow : public QWidget {
40Q_OBJECT 40Q_OBJECT
41 41
42public: 42public:
43 ConWindow(QWidget *parent, const char *name, QDialog* ); 43 ConWindow(PPPData*, QWidget *parent, const char *name, QDialog* );
44 ~ConWindow(); 44 ~ConWindow();
45 45
46protected: 46protected:
47 void closeEvent( QCloseEvent *e ); 47 void closeEvent( QCloseEvent *e );
48 bool event( QEvent *e ); 48 bool event( QEvent *e );
49 49
50private slots: 50private slots:
51 void timeclick(); 51 void timeclick();
52 void dock(); 52// void dock();
53 53
54public: 54public:
55 void setConnectionSpeed(const QString&); 55 void setConnectionSpeed(const QString&);
56 void startClock(); 56 void startClock();
57 void stopClock(); 57 void stopClock();
58 void accounting(bool); // show/ hide accounting info 58// void accounting(bool); // show/ hide accounting info
59 59
60public slots: 60public slots:
61 void slotAccounting(QString, QString); 61 void slotAccounting(QString, QString);
62 62
63private: 63private:
64 QLabel *info1; 64 QLabel *info1;
65 QLabel *info2; 65 QLabel *info2;
66 QPushButton *cancelbutton; 66 QPushButton *cancelbutton;
67 QPushButton *statsbutton; 67 QPushButton *statsbutton;
68 QString prettyPrintVolume(unsigned int); 68 QString prettyPrintVolume(unsigned int);
69 int minutes; 69 int minutes;
70 int seconds; 70 int seconds;
@@ -73,24 +73,22 @@ private:
73 QFrame *fline; 73 QFrame *fline;
74 QLabel *timelabel1; 74 QLabel *timelabel1;
75 QLabel *timelabel2; 75 QLabel *timelabel2;
76 QLabel *total_bill, *total_bill_l; 76 QLabel *total_bill, *total_bill_l;
77 QLabel *session_bill, *session_bill_l; 77 QLabel *session_bill, *session_bill_l;
78 QString caption_string; 78 QString caption_string;
79 QString time_string2; 79 QString time_string2;
80 QString time_string; 80 QString time_string;
81 QTimer *clocktimer; 81 QTimer *clocktimer;
82 QVBoxLayout *tl1; 82 QVBoxLayout *tl1;
83 QLabel *vollabel; 83 QLabel *vollabel;
84 QLabel *volinfo; 84 QLabel *volinfo;
85// PPPStats *stats; 85 PPPData *_pppdata;
86 bool accountingEnabled;
87 bool volumeAccountingEnabled;
88}; 86};
89 87
90 88
91#endif 89#endif
92 90
93 91
94 92
95 93
96 94
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index eee643d..8ae714e 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -36,26 +36,27 @@
36#define i18n QObject::tr 36#define i18n QObject::tr
37#include <qvgroupbox.h> 37#include <qvgroupbox.h>
38#include <qhbox.h> 38#include <qhbox.h>
39#include <qdialog.h> 39#include <qdialog.h>
40//#include <kwin.h> 40//#include <kwin.h>
41 41
42#include "edit.h" 42#include "edit.h"
43#include "pppdata.h" 43#include "pppdata.h"
44//#include "newwidget.h" 44//#include "newwidget.h"
45#include "iplined.h" 45#include "iplined.h"
46#include "auth.h" 46#include "auth.h"
47 47
48DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) 48DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
49 : QWidget(parent, name) 49 , const char *name )
50 : QWidget(parent, name), _pppdata(pd)
50{ 51{
51 const int GRIDROWS = 6; 52 const int GRIDROWS = 6;
52 53
53 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); 54 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
54 55
55 connect_label = new QLabel(i18n("Connection name:"), this); 56 connect_label = new QLabel(i18n("Connection name:"), this);
56 tl->addWidget(connect_label, 0, 0); 57 tl->addWidget(connect_label, 0, 0);
57 58
58 connectname_l = new QLineEdit(this); 59 connectname_l = new QLineEdit(this);
59// connectname_l->setMaxLength(ACCNAME_SIZE); 60// connectname_l->setMaxLength(ACCNAME_SIZE);
60 tl->addWidget(connectname_l, 0, 1); 61 tl->addWidget(connectname_l, 0, 1);
61 QString tmp = i18n("Type in a unique name for this connection"); 62 QString tmp = i18n("Type in a unique name for this connection");
@@ -145,93 +146,93 @@ DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name )
145 "\n" 146 "\n"
146 "<b><font color=\"red\">Warning:</font> your password will be stored as\n" 147 "<b><font color=\"red\">Warning:</font> your password will be stored as\n"
147 "plain text in the config file, which is\n" 148 "plain text in the config file, which is\n"
148 "readable only to you. Make sure nobody\n" 149 "readable only to you. Make sure nobody\n"
149 "gains access to this file!")); 150 "gains access to this file!"));
150 151
151 pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this); 152 pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this);
152 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); 153 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
153 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); 154 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
154 155
155 // Set defaults if editing an existing connection 156 // Set defaults if editing an existing connection
156 if(!isnewaccount) { 157 if(!isnewaccount) {
157 connectname_l->setText(PPPData::data()->accname()); 158 connectname_l->setText(_pppdata->accname());
158 159
159 // insert the phone numbers into the listbox 160 // insert the phone numbers into the listbox
160 QString n = PPPData::data()->phonenumber(); 161 QString n = _pppdata->phonenumber();
161 QString tmp = ""; 162 QString tmp = "";
162 uint idx = 0; 163 uint idx = 0;
163 while(idx != n.length()) { 164 while(idx != n.length()) {
164 if(n[idx] == ':') { 165 if(n[idx] == ':') {
165 if(tmp.length() > 0) 166 if(tmp.length() > 0)
166 numbers->insertItem(tmp); 167 numbers->insertItem(tmp);
167 tmp = ""; 168 tmp = "";
168 } else 169 } else
169 tmp += n[idx]; 170 tmp += n[idx];
170 idx++; 171 idx++;
171 } 172 }
172 if(tmp.length() > 0) 173 if(tmp.length() > 0)
173 numbers->insertItem(tmp); 174 numbers->insertItem(tmp);
174 175
175 auth->setCurrentItem(PPPData::data()->authMethod()); 176 auth->setCurrentItem(_pppdata->authMethod());
176 store_password->setChecked(PPPData::data()->storePassword()); 177 store_password->setChecked(_pppdata->storePassword());
177 } else { 178 } else {
178 // select PAP/CHAP as default 179 // select PAP/CHAP as default
179 auth->setCurrentItem(AUTH_PAPCHAP); 180 auth->setCurrentItem(AUTH_PAPCHAP);
180 } 181 }
181 182
182 numbersChanged(); 183 numbersChanged();
183 tl->activate(); 184 tl->activate();
184} 185}
185 186
186 187
187bool DialWidget::save() { 188bool DialWidget::save() {
188 //first check to make sure that the account name is unique! 189 //first check to make sure that the account name is unique!
189 if(connectname_l->text().isEmpty() || 190 if(connectname_l->text().isEmpty() ||
190 !PPPData::data()->isUniqueAccname(connectname_l->text())) { 191 !_pppdata->isUniqueAccname(connectname_l->text())) {
191 return false; 192 return false;
192 } else { 193 } else {
193 PPPData::data()->setAccname(connectname_l->text()); 194 _pppdata->setAccname(connectname_l->text());
194 195
195 QString number = ""; 196 QString number = "";
196 for(uint i = 0; i < numbers->count(); i++) { 197 for(uint i = 0; i < numbers->count(); i++) {
197 if(i != 0) 198 if(i != 0)
198 number += ":"; 199 number += ":";
199 number += numbers->text(i); 200 number += numbers->text(i);
200 } 201 }
201 202
202 PPPData::data()->setPhonenumber(number); 203 _pppdata->setPhonenumber(number);
203 PPPData::data()->setAuthMethod(auth->currentItem()); 204 _pppdata->setAuthMethod(auth->currentItem());
204 PPPData::data()->setStorePassword(store_password->isChecked()); 205 _pppdata->setStorePassword(store_password->isChecked());
205 return true; 206 return true;
206 } 207 }
207} 208}
208 209
209 210
210void DialWidget::numbersChanged() { 211void DialWidget::numbersChanged() {
211 int sel = numbers->currentItem(); 212 int sel = numbers->currentItem();
212 213
213 del->setEnabled(sel != -1); 214 del->setEnabled(sel != -1);
214 up->setEnabled(sel != -1 && sel != 0); 215 up->setEnabled(sel != -1 && sel != 0);
215 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); 216 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
216} 217}
217 218
218 219
219void DialWidget::selectionChanged(int) { 220void DialWidget::selectionChanged(int) {
220 numbersChanged(); 221 numbersChanged();
221} 222}
222 223
223 224
224void DialWidget::addNumber() { 225void DialWidget::addNumber() {
225 PhoneNumberDialog dlg(this); 226 PhoneNumberDialog dlg(this);
226 if(dlg.exec()) { 227 if(dlg.exec()) {
227 numbers->insertItem(dlg.phoneNumber()); 228 numbers->insertItem(dlg.phoneNumber());
228 numbersChanged(); 229 numbersChanged();
229 } 230 }
230} 231}
231 232
232 233
233void DialWidget::delNumber() { 234void DialWidget::delNumber() {
234 if(numbers->currentItem() != -1) { 235 if(numbers->currentItem() != -1) {
235 numbers->removeItem(numbers->currentItem()); 236 numbers->removeItem(numbers->currentItem());
236 numbersChanged(); 237 numbersChanged();
237 } 238 }
@@ -254,35 +255,35 @@ void DialWidget::downNumber() {
254 int idx = numbers->currentItem(); 255 int idx = numbers->currentItem();
255 if(idx != -1) { 256 if(idx != -1) {
256 QString item = numbers->text(idx); 257 QString item = numbers->text(idx);
257 numbers->removeItem(idx); 258 numbers->removeItem(idx);
258 numbers->insertItem(item, idx+1); 259 numbers->insertItem(item, idx+1);
259 numbers->setCurrentItem(idx+1); 260 numbers->setCurrentItem(idx+1);
260 numbersChanged(); 261 numbersChanged();
261 } 262 }
262} 263}
263 264
264 265
265void DialWidget::pppdargsbutton() { 266void DialWidget::pppdargsbutton() {
266 PPPdArguments pa(this); 267 PPPdArguments pa(_pppdata, this);
267 pa.exec(); 268 pa.exec();
268} 269}
269 270
270 271
271 272
272///////////////////////////////////////////////////////////////////////////// 273/////////////////////////////////////////////////////////////////////////////
273// ExecWidget 274// ExecWidget
274///////////////////////////////////////////////////////////////////////////// 275/////////////////////////////////////////////////////////////////////////////
275ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) : 276ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
276 QWidget(parent, name) 277 QWidget(parent, name), _pppdata(pd)
277{ 278{
278 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 279 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
279 280
280 QLabel *l = new QLabel(\ 281 QLabel *l = new QLabel(\
281i18n("Here you can select commands to run at certain stages of the\n" 282i18n("Here you can select commands to run at certain stages of the\n"
282 "connection. The commands are run with your real user id, so\n" 283 "connection. The commands are run with your real user id, so\n"
283 "you cannot run any commands here requiring root permissions\n" 284 "you cannot run any commands here requiring root permissions\n"
284 "(unless, of course, you are root).\n\n" 285 "(unless, of course, you are root).\n\n"
285 "Be sure to supply the whole path to the program otherwise\n" 286 "Be sure to supply the whole path to the program otherwise\n"
286 "kppp might be unable to find it."), this); 287 "kppp might be unable to find it."), this);
287// l->setMinimumHeight(l->sizeHint().height()); 288// l->setMinimumHeight(l->sizeHint().height());
288 tl->addWidget(l); 289 tl->addWidget(l);
@@ -351,49 +352,49 @@ i18n("Here you can select commands to run at certain stages of the\n"
351 QWhatsThis::add(discommand_label,tmp); 352 QWhatsThis::add(discommand_label,tmp);
352 QWhatsThis::add(discommand,tmp); 353 QWhatsThis::add(discommand,tmp);
353 354
354 // extra space between entries 355 // extra space between entries
355 l1->addRowSpacing(1, 5); 356 l1->addRowSpacing(1, 5);
356 l1->addRowSpacing(3, 5); 357 l1->addRowSpacing(3, 5);
357 358
358 tl->addStretch(1); 359 tl->addStretch(1);
359 tl->activate(); 360 tl->activate();
360 361
361 // Set defaults if editing an existing connection 362 // Set defaults if editing an existing connection
362 if(!isnewaccount) { 363 if(!isnewaccount) {
363 before_connect->setText(PPPData::data()->command_before_connect()); 364 before_connect->setText(_pppdata->command_before_connect());
364 command->setText(PPPData::data()->command_on_connect()); 365 command->setText(_pppdata->command_on_connect());
365 discommand->setText(PPPData::data()->command_on_disconnect()); 366 discommand->setText(_pppdata->command_on_disconnect());
366 predisconnect->setText(PPPData::data()->command_before_disconnect()); 367 predisconnect->setText(_pppdata->command_before_disconnect());
367 } 368 }
368} 369}
369 370
370 371
371bool ExecWidget::save() { 372bool ExecWidget::save() {
372 PPPData::data()->setCommand_before_connect(before_connect->text()); 373 _pppdata->setCommand_before_connect(before_connect->text());
373 PPPData::data()->setCommand_on_connect(command->text()); 374 _pppdata->setCommand_on_connect(command->text());
374 PPPData::data()->setCommand_before_disconnect(predisconnect->text()); 375 _pppdata->setCommand_before_disconnect(predisconnect->text());
375 PPPData::data()->setCommand_on_disconnect(discommand->text()); 376 _pppdata->setCommand_on_disconnect(discommand->text());
376 return true; 377 return true;
377} 378}
378 379
379 380
380 381
381///////////////////////////////////////////////////////////////////////////// 382/////////////////////////////////////////////////////////////////////////////
382// 383//
383// IPWidget 384// IPWidget
384// 385//
385///////////////////////////////////////////////////////////////////////////// 386/////////////////////////////////////////////////////////////////////////////
386IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) 387IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
387 : QWidget(parent, name) 388 : QWidget(parent, name), _pppdata(pd)
388{ 389{
389 QVBoxLayout *topLayout = new QVBoxLayout(this); 390 QVBoxLayout *topLayout = new QVBoxLayout(this);
390 topLayout->setSpacing( 3 );//KDialog::spacingHint()); 391 topLayout->setSpacing( 3 );//KDialog::spacingHint());
391 392
392 box = new QVGroupBox(i18n("Configuration"), this); 393 box = new QVGroupBox(i18n("Configuration"), this);
393// box->setInsideSpacing( 1 );//KDialog::spacingHint()); 394// box->setInsideSpacing( 1 );//KDialog::spacingHint());
394 395
395 rb = new QButtonGroup(this); 396 rb = new QButtonGroup(this);
396 rb->hide(); 397 rb->hide();
397 connect(rb, SIGNAL(clicked(int)), 398 connect(rb, SIGNAL(clicked(int)),
398 SLOT(hitIPSelect(int))); 399 SLOT(hitIPSelect(int)));
399 400
@@ -440,53 +441,53 @@ IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
440 "but your mileage may vary.\n" 441 "but your mileage may vary.\n"
441 "\n" 442 "\n"
442 "If unsure, contact your Internet Service Provider"); 443 "If unsure, contact your Internet Service Provider");
443 ipLayout->addWidget(sub_label, 1, 0); 444 ipLayout->addWidget(sub_label, 1, 0);
444 445
445 subnetmask_l = new IPLineEdit(ipWidget); 446 subnetmask_l = new IPLineEdit(ipWidget);
446 ipLayout->addWidget(subnetmask_l, 1, 1); 447 ipLayout->addWidget(subnetmask_l, 1, 1);
447 448
448 QWhatsThis::add(sub_label,tmp); 449 QWhatsThis::add(sub_label,tmp);
449 QWhatsThis::add(subnetmask_l,tmp); 450 QWhatsThis::add(subnetmask_l,tmp);
450 451
451 autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this); 452 autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this);
452 autoname->setChecked(PPPData::data()->autoname()); 453 autoname->setChecked(_pppdata->autoname());
453 connect(autoname,SIGNAL(toggled(bool)), 454 connect(autoname,SIGNAL(toggled(bool)),
454 this,SLOT(autoname_t(bool))); 455 this,SLOT(autoname_t(bool)));
455 456
456 QWhatsThis::add(autoname, 457 QWhatsThis::add(autoname,
457 i18n("<p>Whenever you connect, this reconfigures\n" 458 i18n("<p>Whenever you connect, this reconfigures\n"
458 "your hostname to match the IP address you\n" 459 "your hostname to match the IP address you\n"
459 "got from the PPP server. This may be useful\n" 460 "got from the PPP server. This may be useful\n"
460 "if you need to use a protocol which depends\n" 461 "if you need to use a protocol which depends\n"
461 "on this information, but it can also cause several\n" 462 "on this information, but it can also cause several\n"
462 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" 463 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
463 "\n" 464 "\n"
464 "Don't enable this unless you really need it.")); 465 "Don't enable this unless you really need it."));
465 466
466 topLayout->addWidget(box); 467 topLayout->addWidget(box);
467 topLayout->addWidget(autoname); 468 topLayout->addWidget(autoname);
468 topLayout->addStretch(); 469 topLayout->addStretch();
469 470
470 //load info from gpppdata 471 //load info from gpppdata
471 if(!isnewaccount) { 472 if(!isnewaccount) {
472 if(PPPData::data()->ipaddr() == "0.0.0.0" && 473 if(_pppdata->ipaddr() == "0.0.0.0" &&
473 PPPData::data()->subnetmask() == "0.0.0.0") { 474 _pppdata->subnetmask() == "0.0.0.0") {
474 dynamicadd_rb->setChecked(true); 475 dynamicadd_rb->setChecked(true);
475 hitIPSelect(0); 476 hitIPSelect(0);
476 autoname->setChecked(PPPData::data()->autoname()); 477 autoname->setChecked(_pppdata->autoname());
477 } 478 }
478 else { 479 else {
479 ipaddress_l->setText(PPPData::data()->ipaddr()); 480 ipaddress_l->setText(_pppdata->ipaddr());
480 subnetmask_l->setText(PPPData::data()->subnetmask()); 481 subnetmask_l->setText(_pppdata->subnetmask());
481 staticadd_rb->setChecked(true); 482 staticadd_rb->setChecked(true);
482 autoname->setChecked(false); 483 autoname->setChecked(false);
483 } 484 }
484 } 485 }
485 else { 486 else {
486 dynamicadd_rb->setChecked(true); 487 dynamicadd_rb->setChecked(true);
487 hitIPSelect(0); 488 hitIPSelect(0);
488 } 489 }
489 490
490} 491}
491 492
492void IPWidget::autoname_t(bool on) { 493void IPWidget::autoname_t(bool on) {
@@ -501,53 +502,53 @@ void IPWidget::autoname_t(bool on) {
501 "you know what you are doing!\n" 502 "you know what you are doing!\n"
502 "For more information take a look at the " 503 "For more information take a look at the "
503 "handbook (or help) in the section \"Frequently " 504 "handbook (or help) in the section \"Frequently "
504 "asked questions\"."), 505 "asked questions\"."),
505 i18n("Warning")); 506 i18n("Warning"));
506 was_warned = true; 507 was_warned = true;
507 } 508 }
508} 509}
509 510
510 511
511void IPWidget::save() { 512void IPWidget::save() {
512 if(dynamicadd_rb->isChecked()) { 513 if(dynamicadd_rb->isChecked()) {
513 PPPData::data()->setIpaddr("0.0.0.0"); 514 _pppdata->setIpaddr("0.0.0.0");
514 PPPData::data()->setSubnetmask("0.0.0.0"); 515 _pppdata->setSubnetmask("0.0.0.0");
515 } else { 516 } else {
516 PPPData::data()->setIpaddr(ipaddress_l->text()); 517 _pppdata->setIpaddr(ipaddress_l->text());
517 PPPData::data()->setSubnetmask(subnetmask_l->text()); 518 _pppdata->setSubnetmask(subnetmask_l->text());
518 } 519 }
519 PPPData::data()->setAutoname(autoname->isChecked()); 520 _pppdata->setAutoname(autoname->isChecked());
520} 521}
521 522
522 523
523void IPWidget::hitIPSelect( int i ) { 524void IPWidget::hitIPSelect( int i ) {
524 if(i == 0) { 525 if(i == 0) {
525 ipaddress_label->setEnabled(false); 526 ipaddress_label->setEnabled(false);
526 sub_label->setEnabled(false); 527 sub_label->setEnabled(false);
527 ipaddress_l->setEnabled(false); 528 ipaddress_l->setEnabled(false);
528 subnetmask_l->setEnabled(false); 529 subnetmask_l->setEnabled(false);
529 } 530 }
530 else { 531 else {
531 ipaddress_label->setEnabled(true); 532 ipaddress_label->setEnabled(true);
532 sub_label->setEnabled(true); 533 sub_label->setEnabled(true);
533 ipaddress_l->setEnabled(true); 534 ipaddress_l->setEnabled(true);
534 subnetmask_l->setEnabled(true); 535 subnetmask_l->setEnabled(true);
535 } 536 }
536} 537}
537 538
538 539
539 540
540DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) 541DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
541 : QWidget(parent, name) 542 : QWidget(parent, name), _pppdata(pd)
542{ 543{
543 // box = new QGroupBox(this); 544 // box = new QGroupBox(this);
544 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint()); 545 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
545 546
546 dnsdomain_label = new QLabel(i18n("Domain name:"), this); 547 dnsdomain_label = new QLabel(i18n("Domain name:"), this);
547 tl->addWidget(dnsdomain_label, 0, 0); 548 tl->addWidget(dnsdomain_label, 0, 0);
548 549
549 dnsdomain = new QLineEdit(this); 550 dnsdomain = new QLineEdit(this);
550// dnsdomain->setMaxLength(DOMAIN_SIZE); 551// dnsdomain->setMaxLength(DOMAIN_SIZE);
551 tl->addWidget(dnsdomain, 0, 1); 552 tl->addWidget(dnsdomain, 0, 1);
552 QString tmp = i18n("If you enter a domain name here, this domain\n" 553 QString tmp = i18n("If you enter a domain name here, this domain\n"
553 "name is used for your computer while you are\n" 554 "name is used for your computer while you are\n"
@@ -563,25 +564,25 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
563 564
564 conf_label = new QLabel(i18n("Configuration:"), this); 565 conf_label = new QLabel(i18n("Configuration:"), this);
565 tl->addWidget(conf_label, 1, 0); 566 tl->addWidget(conf_label, 1, 0);
566 567
567 bg = new QButtonGroup("Group", this); 568 bg = new QButtonGroup("Group", this);
568 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); 569 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
569 bg->hide(); 570 bg->hide();
570 571
571 autodns = new QRadioButton(i18n("Automatic"), this); 572 autodns = new QRadioButton(i18n("Automatic"), this);
572 bg->insert(autodns, 0); 573 bg->insert(autodns, 0);
573 tl->addWidget(autodns, 1, 1); 574 tl->addWidget(autodns, 1, 1);
574 // no automatic DNS detection for pppd < 2.3.7 575 // no automatic DNS detection for pppd < 2.3.7
575 if(!PPPData::data()->pppdVersionMin(2, 3, 7)) 576 if(!_pppdata->pppdVersionMin(2, 3, 7))
576 autodns->setEnabled(false); 577 autodns->setEnabled(false);
577 578
578 mandns = new QRadioButton(i18n("Manual"), this); 579 mandns = new QRadioButton(i18n("Manual"), this);
579 bg->insert(mandns, 1); 580 bg->insert(mandns, 1);
580 tl->addWidget(mandns, 2, 1); 581 tl->addWidget(mandns, 2, 1);
581 582
582 dns_label = new QLabel(i18n("DNS IP address:"), this); 583 dns_label = new QLabel(i18n("DNS IP address:"), this);
583 tl->addWidget(dns_label, 3, 0); 584 tl->addWidget(dns_label, 3, 0);
584 585
585 QHBoxLayout *l2 = new QHBoxLayout; 586 QHBoxLayout *l2 = new QHBoxLayout;
586 tl->addLayout(l2, 3, 1); 587 tl->addLayout(l2, 3, 1);
587 dnsipaddr = new IPLineEdit(this); 588 dnsipaddr = new IPLineEdit(this);
@@ -636,45 +637,45 @@ DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
636 SLOT(DNS_Entry_Selected(int))); 637 SLOT(DNS_Entry_Selected(int)));
637 tl->addWidget(dnsservers, 5, 1); 638 tl->addWidget(dnsservers, 5, 1);
638 tmp = i18n("<p>This shows all defined DNS servers to use\n" 639 tmp = i18n("<p>This shows all defined DNS servers to use\n"
639 "while you are connected. Use the <b>Add</b> and\n" 640 "while you are connected. Use the <b>Add</b> and\n"
640 "<b>Remove</b> buttons to modify the list"); 641 "<b>Remove</b> buttons to modify the list");
641 642
642 QWhatsThis::add(servers_label,tmp); 643 QWhatsThis::add(servers_label,tmp);
643 QWhatsThis::add(dnsservers,tmp); 644 QWhatsThis::add(dnsservers,tmp);
644 645
645 exdnsdisabled_toggle = new QCheckBox(i18n( \ 646 exdnsdisabled_toggle = new QCheckBox(i18n( \
646"Disable existing DNS servers during connection"), 647"Disable existing DNS servers during connection"),
647 this); 648 this);
648 exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled()); 649 exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
649 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); 650 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
650 QWhatsThis::add(exdnsdisabled_toggle, 651 QWhatsThis::add(exdnsdisabled_toggle,
651 i18n("<p>When this option is selected, all DNS\n" 652 i18n("<p>When this option is selected, all DNS\n"
652 "servers specified in <tt>/etc/resolv.conf</tt> are\n" 653 "servers specified in <tt>/etc/resolv.conf</tt> are\n"
653 "temporary disabled while the dialup connection\n" 654 "temporary disabled while the dialup connection\n"
654 "is established. After the connection is\n" 655 "is established. After the connection is\n"
655 "closed, the servers will be re-enabled\n" 656 "closed, the servers will be re-enabled\n"
656 "\n" 657 "\n"
657 "Typically, there is no reason to use this\n" 658 "Typically, there is no reason to use this\n"
658 "option, but it may become useful under \n" 659 "option, but it may become useful under \n"
659 "some circumstances.")); 660 "some circumstances."));
660 661
661 662
662 // restore data if editing 663 // restore data if editing
663 if(!isnewaccount) { 664 if(!isnewaccount) {
664 dnsservers->insertStringList(PPPData::data()->dns()); 665 dnsservers->insertStringList(_pppdata->dns());
665 dnsdomain->setText(PPPData::data()->domain()); 666 dnsdomain->setText(_pppdata->domain());
666 } 667 }
667 668
668 int mode = PPPData::data()->autoDNS() ? 0 : 1; 669 int mode = _pppdata->autoDNS() ? 0 : 1;
669 bg->setButton(mode); 670 bg->setButton(mode);
670 DNS_Mode_Selected(mode); 671 DNS_Mode_Selected(mode);
671 672
672 tl->activate(); 673 tl->activate();
673} 674}
674 675
675void DNSWidget::DNS_Edit_Changed(const QString &text) { 676void DNSWidget::DNS_Edit_Changed(const QString &text) {
676 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); 677 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
677 add->setEnabled(text.find(r) != -1); 678 add->setEnabled(text.find(r) != -1);
678} 679}
679 680
680void DNSWidget::DNS_Entry_Selected(int) { 681void DNSWidget::DNS_Entry_Selected(int) {
@@ -686,63 +687,63 @@ void DNSWidget::DNS_Mode_Selected(int mode) {
686 dns_label->setEnabled(on); 687 dns_label->setEnabled(on);
687 servers_label->setEnabled(on); 688 servers_label->setEnabled(on);
688 dnsipaddr->setText(""); 689 dnsipaddr->setText("");
689 dnsipaddr->setEnabled(on); 690 dnsipaddr->setEnabled(on);
690 add->setEnabled(false); 691 add->setEnabled(false);
691 remove->setEnabled(dnsservers->count()>0 && on); 692 remove->setEnabled(dnsservers->count()>0 && on);
692 dnsservers->clearSelection(); 693 dnsservers->clearSelection();
693 dnsservers->setEnabled(on); 694 dnsservers->setEnabled(on);
694 dnsservers->triggerUpdate(false); 695 dnsservers->triggerUpdate(false);
695} 696}
696 697
697void DNSWidget::save() { 698void DNSWidget::save() {
698 PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0); 699 _pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
699 QStringList serverlist; 700 QStringList serverlist;
700 for(uint i=0; i < dnsservers->count(); i++) 701 for(uint i=0; i < dnsservers->count(); i++)
701 serverlist.append(dnsservers->text(i)); 702 serverlist.append(dnsservers->text(i));
702 PPPData::data()->setDns(serverlist); 703 _pppdata->setDns(serverlist);
703 704
704 // strip leading dot 705 // strip leading dot
705 QString s(dnsdomain->text()); 706 QString s(dnsdomain->text());
706 if(s.left(1) == ".") 707 if(s.left(1) == ".")
707 PPPData::data()->setDomain(s.mid(1)); 708 _pppdata->setDomain(s.mid(1));
708 else 709 else
709 PPPData::data()->setDomain(dnsdomain->text()); 710 _pppdata->setDomain(dnsdomain->text());
710 711
711 PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); 712 _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
712} 713}
713 714
714 715
715void DNSWidget::adddns() { 716void DNSWidget::adddns() {
716 if(dnsservers->count() < MAX_DNS_ENTRIES) { 717 if(dnsservers->count() < MAX_DNS_ENTRIES) {
717 dnsservers->insertItem(dnsipaddr->text()); 718 dnsservers->insertItem(dnsipaddr->text());
718 dnsipaddr->setText(""); 719 dnsipaddr->setText("");
719 } 720 }
720} 721}
721 722
722 723
723void DNSWidget::removedns() { 724void DNSWidget::removedns() {
724 int i; 725 int i;
725 i = dnsservers->currentItem(); 726 i = dnsservers->currentItem();
726 if(i != -1) 727 if(i != -1)
727 dnsservers->removeItem(i); 728 dnsservers->removeItem(i);
728 remove->setEnabled(dnsservers->count()>0); 729 remove->setEnabled(dnsservers->count()>0);
729} 730}
730 731
731 732
732// 733//
733// GatewayWidget 734// GatewayWidget
734// 735//
735GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) 736GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
736 : QWidget(parent, name) 737 : QWidget(parent, name), _pppdata(pd)
737{ 738{
738 QVBoxLayout *topLayout = new QVBoxLayout(this); 739 QVBoxLayout *topLayout = new QVBoxLayout(this);
739 topLayout->setSpacing( 2 );//KDialog::spacingHint()); 740 topLayout->setSpacing( 2 );//KDialog::spacingHint());
740 741
741 box = new QVGroupBox(i18n("Configuration"), this); 742 box = new QVGroupBox(i18n("Configuration"), this);
742// box->setInsideSpacing( 2 );//KDialog::spacingHint()); 743// box->setInsideSpacing( 2 );//KDialog::spacingHint());
743 744
744 rb = new QButtonGroup(this); 745 rb = new QButtonGroup(this);
745 rb->hide(); 746 rb->hide();
746 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); 747 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
747 748
748 defaultgateway = new QRadioButton(box); 749 defaultgateway = new QRadioButton(box);
@@ -776,64 +777,64 @@ GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *na
776 i18n("If this option is enabled, all packets not\n" 777 i18n("If this option is enabled, all packets not\n"
777 "going to the local net are routed through\n" 778 "going to the local net are routed through\n"
778 "the PPP connection.\n" 779 "the PPP connection.\n"
779 "\n" 780 "\n"
780 "Normally, you should turn this on")); 781 "Normally, you should turn this on"));
781 782
782 topLayout->addWidget(box); 783 topLayout->addWidget(box);
783 topLayout->addWidget(defaultroute); 784 topLayout->addWidget(defaultroute);
784 topLayout->addStretch(); 785 topLayout->addStretch();
785 786
786 //load info from gpppdata 787 //load info from gpppdata
787 if(!isnewaccount) { 788 if(!isnewaccount) {
788 if(PPPData::data()->gateway() == "0.0.0.0") { 789 if(_pppdata->gateway() == "0.0.0.0") {
789 defaultgateway->setChecked(true); 790 defaultgateway->setChecked(true);
790 hitGatewaySelect(0); 791 hitGatewaySelect(0);
791 } 792 }
792 else { 793 else {
793 gatewayaddr->setText(PPPData::data()->gateway()); 794 gatewayaddr->setText(_pppdata->gateway());
794 staticgateway->setChecked(true); 795 staticgateway->setChecked(true);
795 } 796 }
796 defaultroute->setChecked(PPPData::data()->defaultroute()); 797 defaultroute->setChecked(_pppdata->defaultroute());
797 } 798 }
798 else { 799 else {
799 defaultgateway->setChecked(true); 800 defaultgateway->setChecked(true);
800 hitGatewaySelect(0); 801 hitGatewaySelect(0);
801 defaultroute->setChecked(true); 802 defaultroute->setChecked(true);
802 } 803 }
803} 804}
804 805
805void GatewayWidget::save() { 806void GatewayWidget::save() {
806 PPPData::data()->setGateway(gatewayaddr->text()); 807 _pppdata->setGateway(gatewayaddr->text());
807 PPPData::data()->setDefaultroute(defaultroute->isChecked()); 808 _pppdata->setDefaultroute(defaultroute->isChecked());
808} 809}
809 810
810 811
811void GatewayWidget::hitGatewaySelect( int i ) { 812void GatewayWidget::hitGatewaySelect( int i ) {
812 if(i == 0) { 813 if(i == 0) {
813 gatewayaddr->setText("0.0.0.0"); 814 gatewayaddr->setText("0.0.0.0");
814 gatewayaddr->setEnabled(false); 815 gatewayaddr->setEnabled(false);
815 gate_label->setEnabled(false); 816 gate_label->setEnabled(false);
816 } 817 }
817 else { 818 else {
818 gatewayaddr->setEnabled(true); 819 gatewayaddr->setEnabled(true);
819 gatewayaddr->setText(""); 820 gatewayaddr->setText("");
820 gate_label->setEnabled(true); 821 gate_label->setEnabled(true);
821 } 822 }
822} 823}
823 824
824 825
825 826
826ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) 827ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
827 : QWidget(parent, name) 828 : QWidget(parent, name),_pppdata(pd)
828{ 829{
829 830
830 QVBoxLayout *tl = new QVBoxLayout(this, 0 ); 831 QVBoxLayout *tl = new QVBoxLayout(this, 0 );
831 se = new ScriptEdit(this); 832 se = new ScriptEdit(this);
832 connect(se, SIGNAL(returnPressed()), SLOT(addButton())); 833 connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
833 tl->addWidget(se); 834 tl->addWidget(se);
834 835
835 // insert equal-sized buttons 836 // insert equal-sized buttons
836 QHBoxLayout *hl = new QHBoxLayout( this ); 837 QHBoxLayout *hl = new QHBoxLayout( this );
837 tl->addLayout( hl ); 838 tl->addLayout( hl );
838 add = new QPushButton( i18n("Add"), this ); 839 add = new QPushButton( i18n("Add"), this );
839 hl->addWidget( add ); 840 hl->addWidget( add );
@@ -858,26 +859,26 @@ ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name
858// sl->setMinimumSize(QSize(150, 140)); 859// sl->setMinimumSize(QSize(150, 140));
859 860
860 slb = new QScrollBar(this); 861 slb = new QScrollBar(this);
861// slb->setFixedWidth(slb->sizeHint().width()); 862// slb->setFixedWidth(slb->sizeHint().width());
862 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); 863 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
863 864
864 l12->addWidget(stl, 1); 865 l12->addWidget(stl, 1);
865 l12->addWidget(sl, 3); 866 l12->addWidget(sl, 3);
866 l12->addWidget(slb, 0); 867 l12->addWidget(slb, 0);
867 868
868 //load data from gpppdata 869 //load data from gpppdata
869 if(!isnewaccount) { 870 if(!isnewaccount) {
870 QStringList &comlist = PPPData::data()->scriptType(); 871 QStringList &comlist = _pppdata->scriptType();
871 QStringList &arglist = PPPData::data()->script(); 872 QStringList &arglist = _pppdata->script();
872 QStringList::Iterator itcom = comlist.begin(); 873 QStringList::Iterator itcom = comlist.begin();
873 QStringList::Iterator itarg = arglist.begin(); 874 QStringList::Iterator itarg = arglist.begin();
874 875
875 for ( ; 876 for ( ;
876 itcom != comlist.end() && itarg != arglist.end(); 877 itcom != comlist.end() && itarg != arglist.end();
877 ++itcom, ++itarg ) 878 ++itcom, ++itarg )
878 { 879 {
879 stl->insertItem(*itcom); 880 stl->insertItem(*itcom);
880 sl->insertItem(*itarg); 881 sl->insertItem(*itarg);
881 } 882 }
882 } 883 }
883 884
@@ -905,26 +906,26 @@ bool ScriptWidget::check() {
905 return ( (errcnt == 0 ) && (lstart == lend) ); 906 return ( (errcnt == 0 ) && (lstart == lend) );
906 } 907 }
907 return true; 908 return true;
908} 909}
909 910
910 911
911void ScriptWidget::save() { 912void ScriptWidget::save() {
912 QStringList typelist, arglist; 913 QStringList typelist, arglist;
913 for(uint i=0; i < sl->count(); i++) { 914 for(uint i=0; i < sl->count(); i++) {
914 typelist.append(stl->text(i)); 915 typelist.append(stl->text(i));
915 arglist.append(sl->text(i)); 916 arglist.append(sl->text(i));
916 } 917 }
917 PPPData::data()->setScriptType(typelist); 918 _pppdata->setScriptType(typelist);
918 PPPData::data()->setScript(arglist); 919 _pppdata->setScript(arglist);
919} 920}
920 921
921 922
922 923
923void ScriptWidget::adjustScrollBar() { 924void ScriptWidget::adjustScrollBar() {
924 if((int)sl->count() <= sl->numItemsVisible()) 925 if((int)sl->count() <= sl->numItemsVisible())
925 slb->setRange(0, 0); 926 slb->setRange(0, 0);
926 else 927 else
927 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); 928 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
928} 929}
929 930
930 931
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h
index cd0161f..2cc0fed 100644
--- a/noncore/settings/networksettings/ppp/edit.h
+++ b/noncore/settings/networksettings/ppp/edit.h
@@ -38,118 +38,122 @@
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qlistbox.h> 39#include <qlistbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qbuttongroup.h> 41#include <qbuttongroup.h>
42#include <qcheckbox.h> 42#include <qcheckbox.h>
43#include <qlabel.h> 43#include <qlabel.h>
44//#include <kdialogbase.h> 44//#include <kdialogbase.h>
45#include "scriptedit.h" 45#include "scriptedit.h"
46#include "kpppconfig.h" 46#include "kpppconfig.h"
47#include "pppdargs.h" 47#include "pppdargs.h"
48 48
49class IPLineEdit; 49class IPLineEdit;
50class PPPData;
50 51
51class DialWidget : public QWidget { 52class DialWidget : public QWidget {
52 Q_OBJECT 53 Q_OBJECT
53public: 54public:
54 DialWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); 55 DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
55 ~DialWidget() {} 56 ~DialWidget() {}
56 57
57public slots: 58public slots:
58 bool save(); 59 bool save();
59 void pppdargsbutton(); 60 void pppdargsbutton();
60 void numbersChanged(); 61 void numbersChanged();
61 void selectionChanged(int); 62 void selectionChanged(int);
62 void addNumber(); 63 void addNumber();
63 void delNumber(); 64 void delNumber();
64 void upNumber(); 65 void upNumber();
65 void downNumber(); 66 void downNumber();
66 67
67private: 68private:
68 QLineEdit *connectname_l; 69 QLineEdit *connectname_l;
69 QLabel *connect_label; 70 QLabel *connect_label;
70 QLabel *number_label; 71 QLabel *number_label;
71 QPushButton *pppdargs; 72 QPushButton *pppdargs;
72 QComboBox *auth; 73 QComboBox *auth;
73 QLabel *auth_l; 74 QLabel *auth_l;
74 QCheckBox *store_password; 75 QCheckBox *store_password;
75 76
76 // for the phonenumber selection 77 // for the phonenumber selection
77 QPushButton *add, *del, *up, *down; 78 QPushButton *add, *del, *up, *down;
78 QListBox *numbers; 79 QListBox *numbers;
80 PPPData *_pppdata;
79}; 81};
80 82
81 83
82///////////////////////////////////////////////////////////////////////////// 84/////////////////////////////////////////////////////////////////////////////
83// 85//
84// tab-window to select what to execute when 86// tab-window to select what to execute when
85// 87//
86///////////////////////////////////////////////////////////////////////////// 88/////////////////////////////////////////////////////////////////////////////
87class ExecWidget : public QWidget { 89class ExecWidget : public QWidget {
88 Q_OBJECT 90 Q_OBJECT
89public: 91public:
90 ExecWidget(QWidget *parent=0, bool isnewaccount=true, const char *name=0); 92 ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0);
91 93
92public slots: 94public slots:
93 bool save(); 95 bool save();
94 96
95private: 97private:
96 QLineEdit *before_connect; 98 QLineEdit *before_connect;
97 QLabel *before_connect_l; 99 QLabel *before_connect_l;
98 100
99 QLineEdit *command; 101 QLineEdit *command;
100 QLabel *command_label; 102 QLabel *command_label;
101 103
102 QLineEdit *predisconnect; 104 QLineEdit *predisconnect;
103 QLabel *predisconnect_label; 105 QLabel *predisconnect_label;
104 106
105 QLineEdit *discommand; 107 QLineEdit *discommand;
106 QLabel *discommand_label; 108 QLabel *discommand_label;
109 PPPData *_pppdata;
107}; 110};
108 111
109 112
110class IPWidget : public QWidget { 113class IPWidget : public QWidget {
111 Q_OBJECT 114 Q_OBJECT
112public: 115public:
113 IPWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); 116 IPWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
114 ~IPWidget() {} 117 ~IPWidget() {}
115 118
116public slots: 119public slots:
117 void save(); 120 void save();
118 121
119protected slots: 122protected slots:
120 void hitIPSelect( int ); 123 void hitIPSelect( int );
121 void autoname_t(bool on); 124 void autoname_t(bool on);
122 125
123private: 126private:
124 QLabel *ipaddress_label; 127 QLabel *ipaddress_label;
125 QLabel *sub_label; 128 QLabel *sub_label;
126 QGroupBox *box1; 129 QGroupBox *box1;
127 QVGroupBox *box; 130 QVGroupBox *box;
128 131
129 QButtonGroup *rb; 132 QButtonGroup *rb;
130 QRadioButton *dynamicadd_rb; 133 QRadioButton *dynamicadd_rb;
131 QRadioButton *staticadd_rb; 134 QRadioButton *staticadd_rb;
132 135
133 IPLineEdit *ipaddress_l; 136 IPLineEdit *ipaddress_l;
134 IPLineEdit *subnetmask_l; 137 IPLineEdit *subnetmask_l;
135 138
136 QCheckBox *autoname; 139 QCheckBox *autoname;
140 PPPData *_pppdata;
137}; 141};
138 142
139 143
140class DNSWidget : public QWidget { 144class DNSWidget : public QWidget {
141 Q_OBJECT 145 Q_OBJECT
142public: 146public:
143 DNSWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); 147 DNSWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
144 ~DNSWidget() {} 148 ~DNSWidget() {}
145 149
146public slots: 150public slots:
147 void save(); 151 void save();
148 152
149protected slots: 153protected slots:
150 void adddns(); 154 void adddns();
151 void removedns(); 155 void removedns();
152 void DNS_Edit_Changed(const QString &); 156 void DNS_Edit_Changed(const QString &);
153 void DNS_Entry_Selected(int); 157 void DNS_Entry_Selected(int);
154 void DNS_Mode_Selected(int); 158 void DNS_Mode_Selected(int);
155 159
@@ -157,55 +161,57 @@ private:
157 QLabel *conf_label; 161 QLabel *conf_label;
158 QButtonGroup *bg; 162 QButtonGroup *bg;
159 QRadioButton *autodns, *mandns; 163 QRadioButton *autodns, *mandns;
160 QLabel *dns_label; 164 QLabel *dns_label;
161 QLabel *servers_label; 165 QLabel *servers_label;
162 IPLineEdit *dnsipaddr; 166 IPLineEdit *dnsipaddr;
163 QPushButton *add; 167 QPushButton *add;
164 QPushButton *remove; 168 QPushButton *remove;
165 QListBox *dnsservers; 169 QListBox *dnsservers;
166 QLineEdit *dnsdomain; 170 QLineEdit *dnsdomain;
167 QLabel *dnsdomain_label; 171 QLabel *dnsdomain_label;
168 QCheckBox *exdnsdisabled_toggle; 172 QCheckBox *exdnsdisabled_toggle;
173 PPPData *_pppdata;
169}; 174};
170 175
171 176
172class GatewayWidget : public QWidget { 177class GatewayWidget : public QWidget {
173 Q_OBJECT 178 Q_OBJECT
174public: 179public:
175 GatewayWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); 180 GatewayWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
176 ~GatewayWidget() {} 181 ~GatewayWidget() {}
177 182
178public slots: 183public slots:
179 void save(); 184 void save();
180 185
181private slots: 186private slots:
182 void hitGatewaySelect( int ); 187 void hitGatewaySelect( int );
183 188
184private: 189private:
185 QGroupBox *box; 190 QGroupBox *box;
186 QLabel *gate_label; 191 QLabel *gate_label;
187 QGroupBox *box1; 192 QGroupBox *box1;
188 QButtonGroup *rb; 193 QButtonGroup *rb;
189 QRadioButton *defaultgateway; 194 QRadioButton *defaultgateway;
190 QRadioButton *staticgateway; 195 QRadioButton *staticgateway;
191 IPLineEdit *gatewayaddr; 196 IPLineEdit *gatewayaddr;
192 QCheckBox *defaultroute; 197 QCheckBox *defaultroute;
198 PPPData *_pppdata;
193}; 199};
194 200
195 201
196class ScriptWidget : public QWidget { 202class ScriptWidget : public QWidget {
197 Q_OBJECT 203 Q_OBJECT
198public: 204public:
199 ScriptWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); 205 ScriptWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
200 ~ScriptWidget() {} 206 ~ScriptWidget() {}
201 207
202public slots: 208public slots:
203 void save(); 209 void save();
204 bool check(); 210 bool check();
205 211
206private slots: 212private slots:
207 void addButton(); 213 void addButton();
208 void insertButton(); 214 void insertButton();
209 void removeButton(); 215 void removeButton();
210 216
211 //signals linked to the scroll bar 217 //signals linked to the scroll bar
@@ -216,36 +222,38 @@ private slots:
216 void stlhighlighted(int); 222 void stlhighlighted(int);
217 223
218private: 224private:
219 void adjustScrollBar(); 225 void adjustScrollBar();
220 226
221 ScriptEdit *se; 227 ScriptEdit *se;
222 QPushButton *add; 228 QPushButton *add;
223 QPushButton *remove; 229 QPushButton *remove;
224 QPushButton *insert; 230 QPushButton *insert;
225 QListBox *sl, *stl; 231 QListBox *sl, *stl;
226 232
227 QScrollBar *slb; 233 QScrollBar *slb;
234 PPPData *_pppdata;
228}; 235};
229 236
230 237
231///////////////////////////////////////////////////////////////////////////// 238/////////////////////////////////////////////////////////////////////////////
232// 239//
233// Used to specify a new phone number 240// Used to specify a new phone number
234// 241//
235///////////////////////////////////////////////////////////////////////////// 242/////////////////////////////////////////////////////////////////////////////
236class PhoneNumberDialog : public QDialog { 243class PhoneNumberDialog : public QDialog {
237 Q_OBJECT 244 Q_OBJECT
238public: 245public:
239 PhoneNumberDialog(QWidget *parent = 0); 246 PhoneNumberDialog(QWidget *parent = 0);
240 247
241 QString phoneNumber(); 248 QString phoneNumber();
242 249
243private slots: 250private slots:
244 void textChanged(const QString &); 251 void textChanged(const QString &);
245 252
246private: 253private:
247 QLineEdit *le; 254 QLineEdit *le;
255
248}; 256};
249 257
250 258
251#endif 259#endif
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 98e035b..f735e49 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -30,37 +30,37 @@
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qwhatsthis.h> 37#include <qwhatsthis.h>
38 38
39// #include <qgroupbox.h> 39// #include <qgroupbox.h>
40 40
41#include "general.h" 41#include "general.h"
42//#include "version.h" 42#include "interfaceppp.h"
43//#include "miniterm.h" 43//#include "miniterm.h"
44#include "modeminfo.h" 44#include "modeminfo.h"
45#include "modemcmds.h" 45#include "modemcmds.h"
46#include "devices.h" 46#include "devices.h"
47#include "pppdata.h" 47#include "pppdata.h"
48//#include <klocale.h> 48//#include <klocale.h>
49#define i18n QObject::tr 49#define i18n QObject::tr
50 50
51 51
52 52
53ModemWidget::ModemWidget( QWidget *parent, const char *name) 53ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name )
54 : QWidget(parent, name) 54 : QWidget(parent, name), _ifaceppp(ifppp)
55{ 55{
56 int k; 56 int k;
57 57
58 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); 58 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
59 59
60 QLabel *label1; 60 QLabel *label1;
61 label1 = new QLabel(i18n("Modem de&vice:"), this); 61 label1 = new QLabel(i18n("Modem de&vice:"), this);
62 tl->addWidget(label1, 0, 0); 62 tl->addWidget(label1, 0, 0);
63 63
64 modemdevice = new QComboBox(false, this); 64 modemdevice = new QComboBox(false, this);
65 label1->setBuddy(modemdevice); 65 label1->setBuddy(modemdevice);
66 66
@@ -163,195 +163,198 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name)
163 163
164 tmp = i18n("Specifies the speed your modem and the serial\n" 164 tmp = i18n("Specifies the speed your modem and the serial\n"
165 "port talk to each other. You should begin with\n" 165 "port talk to each other. You should begin with\n"
166 "the default of 38400 bits/sec. If everything\n" 166 "the default of 38400 bits/sec. If everything\n"
167 "works you can try to increase this value, but to\n" 167 "works you can try to increase this value, but to\n"
168 "no more than 115200 bits/sec (unless you know\n" 168 "no more than 115200 bits/sec (unless you know\n"
169 "that your serial port supports higher speeds)."); 169 "that your serial port supports higher speeds).");
170 170
171 QWhatsThis::add(baud_label,tmp); 171 QWhatsThis::add(baud_label,tmp);
172 QWhatsThis::add(baud_c,tmp); 172 QWhatsThis::add(baud_c,tmp);
173 173
174 for(int i=0; i <= enter->count()-1; i++) { 174 for(int i=0; i <= enter->count()-1; i++) {
175 if(PPPData::data()->enter() == enter->text(i)) 175 if(_ifaceppp->data()->enter() == enter->text(i))
176 enter->setCurrentItem(i); 176 enter->setCurrentItem(i);
177 } 177 }
178 178
179 tl->addRowSpacing(4, 10); 179 tl->addRowSpacing(4, 10);
180 180
181 //Modem Lock File 181 //Modem Lock File
182 modemlockfile = new QCheckBox(i18n("&Use lock file"), this); 182 modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
183 183
184 modemlockfile->setChecked(PPPData::data()->modemLockFile()); 184 modemlockfile->setChecked(_ifaceppp->data()->modemLockFile());
185 connect(modemlockfile, SIGNAL(toggled(bool)), 185 connect(modemlockfile, SIGNAL(toggled(bool)),
186 SLOT(modemlockfilechanged(bool))); 186 SLOT(modemlockfilechanged(bool)));
187 tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); 187 tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
188 // l12->addStretch(1); 188 // l12->addStretch(1);
189 QWhatsThis::add(modemlockfile, 189 QWhatsThis::add(modemlockfile,
190 i18n("<p>To prevent other programs from accessing the\n" 190 i18n("<p>To prevent other programs from accessing the\n"
191 "modem while a connection is established, a\n" 191 "modem while a connection is established, a\n"
192 "file can be created to indicate that the modem\n" 192 "file can be created to indicate that the modem\n"
193 "is in use. On Linux an example file would be\n" 193 "is in use. On Linux an example file would be\n"
194 "<tt>/var/lock/LCK..ttyS1</tt>\n" 194 "<tt>/var/lock/LCK..ttyS1</tt>\n"
195 "Here you can select whether this locking will\n" 195 "Here you can select whether this locking will\n"
196 "be done.\n" 196 "be done.\n"
197 "\n" 197 "\n"
198 "<b>Default</b>: On")); 198 "<b>Default</b>: On"));
199 199
200 // Modem Timeout Line Edit Box 200 // Modem Timeout Line Edit Box
201 QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); 201 QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
202 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); 202 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
203 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); 203 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
204// modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this); 204// modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
205// modemtimeout->setLabel(i18n("Modem &timeout:")); 205// modemtimeout->setLabel(i18n("Modem &timeout:"));
206// modemtimeout->setRange(1, 120, 1); 206// modemtimeout->setRange(1, 120, 1);
207 modemtimeout->setSuffix(i18n(" sec")); 207 modemtimeout->setSuffix(i18n(" sec"));
208 modemtimeout->setValue( _ifaceppp->data()->modemTimeout() );
208 connect(modemtimeout, SIGNAL(valueChanged(int)), 209 connect(modemtimeout, SIGNAL(valueChanged(int)),
209 SLOT(modemtimeoutchanged(int))); 210 SLOT(modemtimeoutchanged(int)));
210 timeoutLayout->addWidget(timeoutlabel); 211 timeoutLayout->addWidget(timeoutlabel);
211 timeoutLayout->addWidget(modemtimeout); 212 timeoutLayout->addWidget(modemtimeout);
212 tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); 213 tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1);
213 214
214 QWhatsThis::add(modemtimeout, 215 QWhatsThis::add(modemtimeout,
215 i18n("This specifies how long <i>kppp</i> waits for a\n" 216 i18n("This specifies how long <i>kppp</i> waits for a\n"
216 "<i>CONNECT</i> response from your modem. The\n" 217 "<i>CONNECT</i> response from your modem. The\n"
217 "recommended value is 30 seconds.")); 218 "recommended value is 30 seconds."));
218 219
219 //set stuff from gpppdata 220 //set stuff from gpppdata
220 for(int i=0; i <= enter->count()-1; i++) { 221 for(int i=0; i <= enter->count()-1; i++) {
221 if(PPPData::data()->enter() == enter->text(i)) 222 if(_ifaceppp->data()->enter() == enter->text(i))
222 enter->setCurrentItem(i); 223 enter->setCurrentItem(i);
223 } 224 }
224 225
225 for(int i=0; i <= modemdevice->count()-1; i++) { 226 for(int i=0; i <= modemdevice->count()-1; i++) {
226 if(PPPData::data()->modemDevice() == modemdevice->text(i)) 227 if(_ifaceppp->data()->modemDevice() == modemdevice->text(i))
227 modemdevice->setCurrentItem(i); 228 modemdevice->setCurrentItem(i);
228 } 229 }
229 230
230 for(int i=0; i <= flowcontrol->count()-1; i++) { 231 for(int i=0; i <= flowcontrol->count()-1; i++) {
231 if(PPPData::data()->flowcontrol() == flowcontrol->text(i)) 232 if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i))
232 flowcontrol->setCurrentItem(i); 233 flowcontrol->setCurrentItem(i);
233 } 234 }
234 235
235 //set the modem speed 236 //set the modem speed
236 for(int i=0; i < baud_c->count(); i++) 237 for(int i=0; i < baud_c->count(); i++)
237 if(baud_c->text(i) == PPPData::data()->speed()) 238 if(baud_c->text(i) == _ifaceppp->data()->speed())
238 baud_c->setCurrentItem(i); 239 baud_c->setCurrentItem(i);
239 240
240 tl->setRowStretch(7, 1); 241 tl->setRowStretch(7, 1);
241} 242}
242 243
243 244
244void ModemWidget::speed_selection(int) { 245void ModemWidget::speed_selection(int) {
245 PPPData::data()->setSpeed(baud_c->text(baud_c->currentItem())); 246 _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem()));
246} 247}
247 248
248 249
249void ModemWidget::setenter(int ) { 250void ModemWidget::setenter(int ) {
250 PPPData::data()->setEnter(enter->text(enter->currentItem())); 251 _ifaceppp->data()->setEnter(enter->text(enter->currentItem()));
251} 252}
252 253
253 254
254void ModemWidget::setmodemdc(int i) { 255void ModemWidget::setmodemdc(int i) {
255 PPPData::data()->setModemDevice(modemdevice->text(i)); 256 _ifaceppp->data()->setModemDevice(modemdevice->text(i));
256} 257}
257 258
258 259
259void ModemWidget::setflowcontrol(int i) { 260void ModemWidget::setflowcontrol(int i) {
260 PPPData::data()->setFlowcontrol(flowcontrol->text(i)); 261 _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i));
261} 262}
262 263
263 264
264void ModemWidget::modemlockfilechanged(bool set) { 265void ModemWidget::modemlockfilechanged(bool set) {
265 PPPData::data()->setModemLockFile(set); 266 _ifaceppp->data()->setModemLockFile(set);
266} 267}
267 268
268 269
269void ModemWidget::modemtimeoutchanged(int n) { 270void ModemWidget::modemtimeoutchanged(int n) {
270 PPPData::data()->setModemTimeout(n); 271 _ifaceppp->data()->setModemTimeout(n);
271} 272}
272 273
273 274
274ModemWidget2::ModemWidget2( QWidget *parent, const char *name) 275ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent,
275 : QWidget(parent, name) 276 const char *name)
277 : QWidget(parent, name), _ifaceppp(ifp)
276{ 278{
277 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 279 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
278 280
279 281
280 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); 282 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
281 waitfordt->setChecked(PPPData::data()->waitForDialTone()); 283 waitfordt->setChecked(_ifaceppp->data()->waitForDialTone());
282 connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); 284 connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
283 l1->addWidget(waitfordt); 285 l1->addWidget(waitfordt);
284 QWhatsThis::add(waitfordt, 286 QWhatsThis::add(waitfordt,
285 i18n("<p>Normally the modem waits for a dial tone\n" 287 i18n("<p>Normally the modem waits for a dial tone\n"
286 "from your phone line, indicating that it can\n" 288 "from your phone line, indicating that it can\n"
287 "start to dial a number. If your modem does not\n" 289 "start to dial a number. If your modem does not\n"
288 "recognize this sound, or your local phone system\n" 290 "recognize this sound, or your local phone system\n"
289 "does not emit such a tone, uncheck this option\n" 291 "does not emit such a tone, uncheck this option\n"
290 "\n" 292 "\n"
291 "<b>Default:</b>: On")); 293 "<b>Default:</b>: On"));
292 294
293 QHBoxLayout *waitLayout = new QHBoxLayout( this ); 295 QHBoxLayout *waitLayout = new QHBoxLayout( this );
294 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); 296 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" );
295 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); 297 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" );
296// busywait = new KIntNumInput(PPPData::data()->busyWait(), this); 298// busywait = new KIntNumInput(_pppdata->busyWait(), this);
297// busywait->setLabel(i18n("B&usy wait:")); 299// busywait->setLabel(i18n("B&usy wait:"));
298// busywait->setRange(0, 300, 5, true); 300// busywait->setRange(0, 300, 5, true);
299 busywait->setSuffix(i18n(" sec")); 301 busywait->setSuffix(i18n(" sec"));
300 connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); 302 connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
301 waitLayout->addWidget(waitLabel); 303 waitLayout->addWidget(waitLabel);
302 waitLayout->addWidget(busywait); 304 waitLayout->addWidget(busywait);
303 l1->addLayout( waitLayout ); 305 l1->addLayout( waitLayout );
304 306
305 QWhatsThis::add(busywait, 307 QWhatsThis::add(busywait,
306 i18n("Specifies the number of seconds to wait before\n" 308 i18n("Specifies the number of seconds to wait before\n"
307 "redial if all dialed numbers are busy. This is\n" 309 "redial if all dialed numbers are busy. This is\n"
308 "necessary because some modems get stuck if the\n" 310 "necessary because some modems get stuck if the\n"
309 "same number is busy too often.\n" 311 "same number is busy too often.\n"
310 "\n" 312 "\n"
311 "The default is 0 seconds, you should not change\n" 313 "The default is 0 seconds, you should not change\n"
312 "this unless you need to.")); 314 "this unless you need to."));
313 315
314 l1->addSpacing(10); 316 l1->addSpacing(10);
315 317
316 QHBoxLayout *hbl = new QHBoxLayout; 318 QHBoxLayout *hbl = new QHBoxLayout;
317 hbl->setSpacing(2);//KDialog::spacingHint()); 319 hbl->setSpacing(2);//KDialog::spacingHint());
318 320
319 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); 321 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
320 hbl->addWidget(volumeLabel); 322 hbl->addWidget(volumeLabel);
321 volume = new QSlider(0, 2, 1, PPPData::data()->volume(), QSlider::Horizontal, this); 323 volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(),
324 QSlider::Horizontal, this);
322 volumeLabel->setBuddy(volume); 325 volumeLabel->setBuddy(volume);
323 volume->setTickmarks(QSlider::Below); 326 volume->setTickmarks(QSlider::Below);
324 hbl->addWidget(volume); 327 hbl->addWidget(volume);
325 328
326 l1->addLayout(hbl); 329 l1->addLayout(hbl);
327 330
328 connect(volume, SIGNAL(valueChanged(int)), 331 connect(volume, SIGNAL(valueChanged(int)),
329 this, SLOT(volumeChanged(int))); 332 this, SLOT(volumeChanged(int)));
330 QString tmp = i18n("Most modems have a speaker which makes\n" 333 QString tmp = i18n("Most modems have a speaker which makes\n"
331 "a lot of noise when dialing. Here you can\n" 334 "a lot of noise when dialing. Here you can\n"
332 "either turn this completely off or select a\n" 335 "either turn this completely off or select a\n"
333 "lower volume.\n" 336 "lower volume.\n"
334 "\n" 337 "\n"
335 "If this does not work for your modem,\n" 338 "If this does not work for your modem,\n"
336 "you must modify the modem volume command."); 339 "you must modify the modem volume command.");
337 340
338 QWhatsThis::add(volumeLabel,tmp); 341 QWhatsThis::add(volumeLabel,tmp);
339 QWhatsThis::add(volume, tmp); 342 QWhatsThis::add(volume, tmp);
340 343
341 l1->addSpacing(20); 344 l1->addSpacing(20);
342 345
343#if 0 346#if 0
344 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); 347 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
345 chkbox1->setChecked(PPPData::data()->UseCDLine()); 348 chkbox1->setChecked(_ifaceppp->data()->UseCDLine());
346 connect(chkbox1,SIGNAL(toggled(bool)), 349 connect(chkbox1,SIGNAL(toggled(bool)),
347 this,SLOT(use_cdline_toggled(bool))); 350 this,SLOT(use_cdline_toggled(bool)));
348 l12->addWidget(chkbox1); 351 l12->addWidget(chkbox1);
349 l12->addStretch(1); 352 l12->addStretch(1);
350 l1->addStretch(1); 353 l1->addStretch(1);
351 QWhatsThis::add(chkbox1, 354 QWhatsThis::add(chkbox1,
352 i18n("This controls how <i>kppp</i> detects that the modem\n" 355 i18n("This controls how <i>kppp</i> detects that the modem\n"
353 "is not responding. Unless you are having\n" 356 "is not responding. Unless you are having\n"
354 "problems with this, do not modify this setting.\n" 357 "problems with this, do not modify this setting.\n"
355 "\n" 358 "\n"
356 "<b>Default</b>: Off")); 359 "<b>Default</b>: Off"));
357#endif 360#endif
@@ -390,49 +393,49 @@ ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
390 l1->addStretch(1); 393 l1->addStretch(1);
391 394
392 connect(modemcmds, SIGNAL(clicked()), 395 connect(modemcmds, SIGNAL(clicked()),
393 SLOT(modemcmdsbutton())); 396 SLOT(modemcmdsbutton()));
394 connect(modeminfo_button, SIGNAL(clicked()), 397 connect(modeminfo_button, SIGNAL(clicked()),
395 SLOT(query_modem())); 398 SLOT(query_modem()));
396// connect(terminal_button, SIGNAL(clicked()), 399// connect(terminal_button, SIGNAL(clicked()),
397 // SLOT(terminal())); 400 // SLOT(terminal()));
398} 401}
399 402
400 403
401void ModemWidget2::modemcmdsbutton() { 404void ModemWidget2::modemcmdsbutton() {
402 ModemCommands mc(this); 405 ModemCommands mc(_ifaceppp->data(), this);
403 mc.showMaximized(); 406 mc.showMaximized();
404 mc.exec(); 407 mc.exec();
405} 408}
406 409
407 410
408void ModemWidget2::query_modem() { 411void ModemWidget2::query_modem() {
409 ModemTransfer mt(this); 412 ModemTransfer mt(_ifaceppp->modem(), this);
410 mt.exec(); 413 mt.exec();
411} 414}
412 415
413 416
414// void ModemWidget2::terminal() { 417// void ModemWidget2::terminal() {
415// MiniTerm terminal(NULL,NULL); 418// MiniTerm terminal(NULL,NULL);
416// terminal.exec(); 419// terminal.exec();
417// } 420// }
418 421
419 422
420#if 0 423#if 0
421void ModemWidget2::use_cdline_toggled(bool on) { 424void ModemWidget2::use_cdline_toggled(bool on) {
422 PPPData::data()->setUseCDLine(on); 425 _ifaceppp->data()->setUseCDLine(on);
423} 426}
424#endif 427#endif
425 428
426void ModemWidget2::waitfordtchanged(bool b) { 429void ModemWidget2::waitfordtchanged(bool b) {
427 PPPData::data()->setWaitForDialTone((int)b); 430 _ifaceppp->data()->setWaitForDialTone((int)b);
428} 431}
429 432
430void ModemWidget2::busywaitchanged(int n) { 433void ModemWidget2::busywaitchanged(int n) {
431 PPPData::data()->setbusyWait(n); 434 _ifaceppp->data()->setbusyWait(n);
432} 435}
433 436
434 437
435void ModemWidget2::volumeChanged(int v) { 438void ModemWidget2::volumeChanged(int v) {
436 PPPData::data()->setVolume(v); 439 _ifaceppp->data()->setVolume(v);
437} 440}
438 441
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
index 4869f6c..3e59b46 100644
--- a/noncore/settings/networksettings/ppp/general.h
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -25,74 +25,76 @@
25 25
26#ifndef _GENERAL_H_ 26#ifndef _GENERAL_H_
27#define _GENERAL_H_ 27#define _GENERAL_H_
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class QSlider; 31class QSlider;
32class QSpinBox; 32class QSpinBox;
33class QCombobox; 33class QCombobox;
34class QLabel; 34class QLabel;
35class QCheckBox; 35class QCheckBox;
36class QComboBox; 36class QComboBox;
37 37class PPPData;
38 38class InterfacePPP;
39 39
40class ModemWidget : public QWidget { 40class ModemWidget : public QWidget {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 ModemWidget( QWidget *parent=0, const char *name=0 ); 43 ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 );
44 44
45private slots: 45private slots:
46 void setmodemdc(int); 46 void setmodemdc(int);
47 void setflowcontrol(int); 47 void setflowcontrol(int);
48 void modemtimeoutchanged(int); 48 void modemtimeoutchanged(int);
49 void modemlockfilechanged(bool); 49 void modemlockfilechanged(bool);
50 void setenter(int); 50 void setenter(int);
51 void speed_selection(int); 51 void speed_selection(int);
52 52
53private: 53private:
54 QComboBox *enter; 54 QComboBox *enter;
55 /* QLabel *label1; */ 55 /* QLabel *label1; */
56 /* QLabel *label2; */ 56 /* QLabel *label2; */
57 /* QLabel *labeltmp; */ 57 /* QLabel *labeltmp; */
58 /* QLabel *labelenter; */ 58 /* QLabel *labelenter; */
59 QComboBox *modemdevice; 59 QComboBox *modemdevice;
60 QComboBox *flowcontrol; 60 QComboBox *flowcontrol;
61 61
62 QComboBox *baud_c; 62 QComboBox *baud_c;
63 QLabel *baud_label; 63 QLabel *baud_label;
64 64
65 QSpinBox *modemtimeout; 65 QSpinBox *modemtimeout;
66 QCheckBox *modemlockfile; 66 QCheckBox *modemlockfile;
67 InterfacePPP *_ifaceppp;
67}; 68};
68 69
69 70
70class ModemWidget2 : public QWidget { 71class ModemWidget2 : public QWidget {
71 Q_OBJECT 72 Q_OBJECT
72public: 73public:
73 ModemWidget2( QWidget *parent=0, const char *name=0 ); 74 ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 );
74 75
75private slots: 76private slots:
76 void waitfordtchanged(bool); 77 void waitfordtchanged(bool);
77 void busywaitchanged(int); 78 void busywaitchanged(int);
78 // void use_cdline_toggled(bool); 79 // void use_cdline_toggled(bool);
79 void modemcmdsbutton(); 80 void modemcmdsbutton();
80 // void terminal(); 81 // void terminal();
81 void query_modem(); 82 void query_modem();
82 void volumeChanged(int); 83 void volumeChanged(int);
83 84
84private: 85private:
85 QLabel *labeltmp; 86 QLabel *labeltmp;
86 QPushButton *modemcmds; 87 QPushButton *modemcmds;
87 QPushButton *modeminfo_button; 88 QPushButton *modeminfo_button;
88 // QPushButton *terminal_button; 89 // QPushButton *terminal_button;
89 // QFrame *fline; 90 // QFrame *fline;
90 QCheckBox *waitfordt; 91 QCheckBox *waitfordt;
91 QSpinBox *busywait; 92 QSpinBox *busywait;
92 QCheckBox *chkbox1; 93 QCheckBox *chkbox1;
93 QSlider *volume; 94 QSlider *volume;
95 InterfacePPP *_ifaceppp;
94}; 96};
95 97
96#endif 98#endif
97 99
98 100
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
new file mode 100644
index 0000000..a58858c
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -0,0 +1,24 @@
1#include "interfaceinformationppp.h"
2
3
4#include <qpushbutton.h>
5#include <qlabel.h>
6//#include <qgroupbox.h>
7#include <qmessagebox.h>
8
9#ifdef QWS
10#else
11 #define showMaximized show
12#endif
13
14/**
15 * Constructor for the InterfaceInformationImp class. This class pretty much
16 * just display's information about the interface that is passed to it.
17 */
18InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f)
19 :InterfaceInformationImp(parent, name, i, f)
20{
21}
22
23
24
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.h b/noncore/settings/networksettings/ppp/interfaceinformationppp.h
new file mode 100644
index 0000000..8c6fc0b
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.h
@@ -0,0 +1,25 @@
1#ifndef INTERFACEINFORMATIONPPP_H
2#define INTERFACEINFORMATIONPPP_H
3
4#include "interfaceinformationimp.h"
5//#include "interface.h"
6
7class QWidget;
8class Interface;
9
10class InterfaceInformationPPP : public InterfaceInformationImp {
11
12Q_OBJECT
13
14public:
15
16 InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
17 ~InterfaceInformationPPP(){};
18
19
20};
21
22#endif
23
24// addserviceimp.h
25
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp
new file mode 100644
index 0000000..d9ee3ff
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp
@@ -0,0 +1,48 @@
1#include "interfaceppp.h"
2#include "modem.h"
3#include "pppdata.h"
4
5InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status)
6 : Interface(parent, name, status),
7 _modem(0),
8 _pppdata(0)
9{
10 qDebug("InterfacePPP::InterfacePPP(");
11}
12
13PPPData* InterfacePPP::data()
14{
15 if (!_pppdata){
16 _pppdata = new PPPData();
17 _pppdata->setModemDevice( getInterfaceName() );
18 _pppdata->setAccount( getHardwareName() );
19 }
20 return _pppdata;
21}
22
23Modem* InterfacePPP::modem()
24{
25 if (!_modem){
26 _modem = new Modem( data() );
27 }
28 return _modem;
29}
30
31bool InterfacePPP::refresh()
32{
33 qDebug("InterfacePPP::refresh()");
34 return false;
35}
36
37void InterfacePPP::start()
38{
39 qDebug("InterfacePPP::start");
40
41}
42
43void InterfacePPP::stop()
44{
45 qDebug("InterfacePPP::stop");
46
47}
48
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h
new file mode 100644
index 0000000..b7477c9
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/interfaceppp.h
@@ -0,0 +1,30 @@
1#ifndef INTERFACEPPP_H
2#define INTERFACEPPP_H
3
4#include "interface.h"
5
6class PPPData;
7class Modem;
8
9class InterfacePPP : public Interface
10{
11 Q_OBJECT
12
13public:
14 InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false);
15
16 PPPData* data();
17 Modem* modem();
18
19public slots:
20 virtual bool refresh();
21 virtual void start();
22 virtual void stop();
23
24 private:
25 Modem *_modem;
26 PPPData *_pppdata;
27};
28
29
30#endif
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index f8a8dc3..289e9f5 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -28,24 +28,25 @@
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qevent.h> 32#include <qevent.h>
33#include <qdialog.h> 33#include <qdialog.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qtabwidget.h> 37#include <qtabwidget.h>
38#include <qdialog.h> 38#include <qdialog.h>
39#include <qwhatsthis.h> 39#include <qwhatsthis.h>
40#include <qcheckbox.h>
40 41
41// #include <kaboutdata.h> 42// #include <kaboutdata.h>
42// #include <kapplication.h> 43// #include <kapplication.h>
43#include <qbuttongroup.h> 44#include <qbuttongroup.h>
44//#include <kcmdlineargs.h> 45//#include <kcmdlineargs.h>
45//#include <kconfig.h> 46//#include <kconfig.h>
46//#include <kdebug.h> 47//#include <kdebug.h>
47#define i18n QObject::tr 48#define i18n QObject::tr
48//#include <kiconloader.h> // For BarIcon 49//#include <kiconloader.h> // For BarIcon
49//#include <klocale.h> 50//#include <klocale.h>
50#include <qmessagebox.h> 51#include <qmessagebox.h>
51// #include <kseparator.h> 52// #include <kseparator.h>
@@ -61,229 +62,237 @@
61 62
62#include "runtests.h" 63#include "runtests.h"
63 64
64//#include "main.h" 65//#include "main.h"
65#include "auth.h" 66#include "auth.h"
66#include "modem.h" 67#include "modem.h"
67//#include "ppplog.h" 68//#include "ppplog.h"
68//#include "opener.h" 69//#include "opener.h"
69//#include "requester.h" 70//#include "requester.h"
70//#include "pppstats.h" 71//#include "pppstats.h"
71#include "pppdata.h" 72#include "pppdata.h"
72#include "general.h" 73#include "general.h"
74#include "interface.h"
73 75
74#define execute_command system 76#define execute_command system
75 77
76KPPPWidget *p_kppp = 0; 78KPPPWidget *p_kppp = 0;
77 79
78KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl ) 80KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl )
79 : QDialog(parent, name, modal, fl) 81 : QDialog(parent, name, modal, fl), _pppdata(pd)
80// , acct(0)
81// , m_bCmdlAccount (false)
82{ 82{
83// tabWindow = 0; 83// tabWindow = 0;
84 p_kppp = this; 84 p_kppp = this;
85 // before doing anything else, run a few tests 85 // before doing anything else, run a few tests
86 if (!_pppdata->setModemDevice( i->getInterfaceName() ))
87 _pppdata->setModemDevice("/dev/modem");
88 qDebug("PPPConfigWidget::PPPConfigWidget");
89 qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1());
90 if (!_pppdata->setAccount( i->getHardwareName() ))
91 _pppdata->setAccount( 0 );
92
93 qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1());
94 qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID());
86 95
87 int result = runTests(); 96 int result = runTests();
88 if(result == TEST_CRITICAL) 97 if(result == TEST_CRITICAL)
89 exit(4); 98 exit(4);
90 99
91// installEventFilter(this); 100// installEventFilter(this);
92 101
93// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 102 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
94 103
95// QGridLayout *l1 = new QGridLayout(3, 4); 104 QGridLayout *l1 = new QGridLayout(3, 4);
96// tl->addLayout(l1); 105 tl->addLayout(l1);
97// l1->addColSpacing(0, 10); 106 l1->addColSpacing(0, 10);
98// l1->addColSpacing(3, 10); 107 l1->addColSpacing(3, 10);
99// l1->setColStretch(1, 3); 108 l1->setColStretch(1, 3);
100// l1->setColStretch(2, 4); 109 l1->setColStretch(2, 4);
101 110
102// label1 = new QLabel(i18n("C&onnect to: "), this); 111 label1 = new QLabel(i18n("C&onnect to: "), this);
103// l1->addWidget(label1, 0, 1); 112 l1->addWidget(label1, 0, 1);
104 113
105// connectto_c = new QComboBox(false, this); 114 connectto_c = new QComboBox(false, this);
106// label1->setBuddy(connectto_c); 115 label1->setBuddy(connectto_c);
107 116
108// connect(connectto_c, SIGNAL(activated(int)), 117 connect(connectto_c, SIGNAL(activated(int)),
109 // SLOT(newdefaultaccount(int))); 118 SLOT(newdefaultaccount(int)));
110// l1->addWidget(connectto_c, 0, 2); 119 l1->addWidget(connectto_c, 0, 2);
111 120
112// ID_Label = new QLabel(i18n("&Login ID:"), this); 121 ID_Label = new QLabel(i18n("&Login ID:"), this);
113// l1->addWidget(ID_Label, 1, 1); 122 l1->addWidget(ID_Label, 1, 1);
114 123
115// // the entry line for usernames 124 // the entry line for usernames
116// ID_Edit = new QLineEdit(this); 125 ID_Edit = new QLineEdit(this);
117// ID_Label->setBuddy(ID_Edit); 126 ID_Label->setBuddy(ID_Edit);
118// l1->addWidget(ID_Edit, 1, 2); 127 l1->addWidget(ID_Edit, 1, 2);
119// connect(ID_Edit, SIGNAL(returnPressed()), 128 connect(ID_Edit, SIGNAL(returnPressed()),
120 // this, SLOT(enterPressedInID())); 129 this, SLOT(enterPressedInID()));
121// QString tmp = i18n("<p>Type in the username that you got from your\n" 130 QString tmp = i18n("<p>Type in the username that you got from your\n"
122 // "ISP. This is especially important for PAP\n" 131 "ISP. This is especially important for PAP\n"
123 // "and CHAP. You may omit this when you use\n" 132 "and CHAP. You may omit this when you use\n"
124 // "terminal-based or script-based authentication.\n" 133 "terminal-based or script-based authentication.\n"
125 // "\n" 134 "\n"
126 // "<b>Important</b>: case is important here:\n" 135 "<b>Important</b>: case is important here:\n"
127 // "<i>myusername</i> is not the same as <i>MyUserName</i>!"); 136 "<i>myusername</i> is not the same as <i>MyUserName</i>!");
128 137
129// QWhatsThis::add(ID_Label,tmp); 138 QWhatsThis::add(ID_Label,tmp);
130// QWhatsThis::add(ID_Edit,tmp); 139 QWhatsThis::add(ID_Edit,tmp);
131 140
132// PW_Label = new QLabel(i18n("&Password:"), this); 141 PW_Label = new QLabel(i18n("&Password:"), this);
133// l1->addWidget(PW_Label, 2, 1); 142 l1->addWidget(PW_Label, 2, 1);
134 143
135// PW_Edit= new QLineEdit(this); 144 PW_Edit= new QLineEdit(this);
136// PW_Label->setBuddy(PW_Edit); 145 PW_Label->setBuddy(PW_Edit);
137// PW_Edit->setEchoMode(QLineEdit::Password); 146 PW_Edit->setEchoMode(QLineEdit::Password);
138// l1->addWidget(PW_Edit, 2, 2); 147 l1->addWidget(PW_Edit, 2, 2);
139// connect(PW_Edit, SIGNAL(returnPressed()), 148 connect(PW_Edit, SIGNAL(returnPressed()),
140 // this, SLOT(enterPressedInPW())); 149 this, SLOT(enterPressedInPW()));
141 150
142// tmp = i18n("<p>Type in the password that you got from your\n" 151 tmp = i18n("<p>Type in the password that you got from your\n"
143 // "ISP. This is especially important for PAP\n" 152 "ISP. This is especially important for PAP\n"
144 // "and CHAP. You may omit this when you use\n" 153 "and CHAP. You may omit this when you use\n"
145 // "terminal-based or script-based authentication.\n" 154 "terminal-based or script-based authentication.\n"
146 // "\n" 155 "\n"
147 // "<b>Important</b>: case is important here:\n" 156 "<b>Important</b>: case is important here:\n"
148 // "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); 157 "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
149 158
150// QWhatsThis::add(PW_Label,tmp); 159 QWhatsThis::add(PW_Label,tmp);
151// QWhatsThis::add(PW_Edit,tmp); 160 QWhatsThis::add(PW_Edit,tmp);
152 161
153// QHBoxLayout *l3 = new QHBoxLayout; 162 QHBoxLayout *l3 = new QHBoxLayout;
154// tl->addSpacing(5); 163 tl->addSpacing(5);
155// tl->addLayout(l3); 164 tl->addLayout(l3);
156// tl->addSpacing(5); 165 tl->addSpacing(5);
157// l3->addSpacing(10); 166 l3->addSpacing(10);
158// log = new QCheckBox(i18n("Show lo&g window"), this); 167 log = new QCheckBox(i18n("Show lo&g window"), this);
159// connect(log, SIGNAL(toggled(bool)), 168 connect(log, SIGNAL(toggled(bool)),
160 // this, SLOT(log_window_toggled(bool))); 169 this, SLOT(log_window_toggled(bool)));
161// log->setChecked(PPPData::data()->get_show_log_window()); 170 log->setChecked(_pppdata->get_show_log_window());
162// l3->addWidget(log); 171 l3->addWidget(log);
163 172
164// QWhatsThis::add(log, 173 QWhatsThis::add(log,
165 // i18n("<p>This controls whether a log window is shown.\n" 174 i18n("<p>This controls whether a log window is shown.\n"
166 // "A log window shows the communication between\n" 175 "A log window shows the communication between\n"
167 // "<i>kppp</i> and your modem. This will help you\n" 176 "<i>kppp</i> and your modem. This will help you\n"
168 // "in tracking down problems.\n" 177 "in tracking down problems.\n"
169 // "\n" 178 "\n"
170 // "Turn it off if <i>kppp</i> routinely connects without\n" 179 "Turn it off if <i>kppp</i> routinely connects without\n"
171 // "problems")); 180 "problems"));
172 181
173// // fline = new QSeparator( KSeparator::HLine, this); 182// fline = new QSeparator( KSeparator::HLine, this);
174// // tl->addWidget(fline); 183// tl->addWidget(fline);
175 184
176// QHBoxLayout *l2 = new QHBoxLayout(this); 185 QHBoxLayout *l2 = new QHBoxLayout(this);
177// tl->addLayout(l2); 186 tl->addLayout(l2);
178 187
179// int minw = 0; 188 int minw = 0;
180// quit_b = new QPushButton(i18n("&Quit"), this); 189 quit_b = new QPushButton(i18n("&Quit"), this);
181// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); 190 // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
182// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); 191 connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
183// if(quit_b->sizeHint().width() > minw) 192 if(quit_b->sizeHint().width() > minw)
184// minw = quit_b->sizeHint().width(); 193 minw = quit_b->sizeHint().width();
185 194
186// setup_b = new QPushButton(i18n("&Setup..."), this); 195 setup_b = new QPushButton(i18n("&Setup..."), this);
187// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); 196// setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
188// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); 197 connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
189// if(setup_b->sizeHint().width() > minw) 198 if(setup_b->sizeHint().width() > minw)
190// minw = setup_b->sizeHint().width(); 199 minw = setup_b->sizeHint().width();
191 200
192 201
193 202
194// if(PPPData::data()->access() != KConfig::ReadWrite) 203// if(_pppdata->access() != KConfig::ReadWrite)
195// setup_b->setEnabled(false); 204 // setup_b->setEnabled(false);
196 205
197// help_b = new QPushButton(i18n("&Help"), this); 206// help_b = new QPushButton(i18n("&Help"), this);
198// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); 207// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
199 208
200// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); 209// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
201// help_b->setPopup((QPopupMenu*)helpMenu->menu()); 210// help_b->setPopup((QPopupMenu*)helpMenu->menu());
202// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); 211// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
203 212
204// if(help_b->sizeHint().width() > minw) 213// if(help_b->sizeHint().width() > minw)
205// minw = help_b->sizeHint().width(); 214// minw = help_b->sizeHint().width();
206 215
207// connect_b = new QPushButton(i18n("&Connect"), this); 216 connect_b = new QPushButton(i18n("&Connect"), this);
208// connect_b->setDefault(true); 217 connect_b->setDefault(true);
209// connect_b->setFocus(); 218 connect_b->setFocus();
210// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); 219 connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
211// if(connect_b->sizeHint().width() > minw) 220 if(connect_b->sizeHint().width() > minw)
212// minw = connect_b->sizeHint().width(); 221 minw = connect_b->sizeHint().width();
213 222
214// quit_b->setFixedWidth(minw); 223 quit_b->setFixedWidth(minw);
215// setup_b->setFixedWidth(minw); 224 setup_b->setFixedWidth(minw);
216// // help_b->setFixedWidth(help_b->sizeHint().width()); 225// help_b->setFixedWidth(help_b->sizeHint().width());
217// connect_b->setFixedWidth(minw); 226 connect_b->setFixedWidth(minw);
218 227
219// l2->addWidget(quit_b); 228 l2->addWidget(quit_b);
220// l2->addWidget(setup_b); 229 l2->addWidget(setup_b);
221// // l2->addWidget(help_b); 230// l2->addWidget(help_b);
222// l2->addSpacing(20); 231 l2->addSpacing(20);
223// l2->addWidget(connect_b); 232 l2->addWidget(connect_b);
224 233
225 setFixedSize(sizeHint()); 234 setFixedSize(sizeHint());
226 235
227 (void)new Modem; 236 (void)new Modem(_pppdata);
228 237
229 // we also connect cmld_start to the beginConnect so that I can run 238 // we also connect cmld_start to the beginConnect so that I can run
230 // the dialer through a command line argument 239 // the dialer through a command line argument
231 connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); 240 connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
232 241
233// stats = new PPPStats; 242// stats = new PPPStats;
234 243
235 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 244 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
236 245
237 // constructor of con_win reads position from config file 246 // constructor of con_win reads position from config file
238// con_win = new ConWindow(0, "conw", this); 247 con_win = new ConWindow(_pppdata, 0, "conw", this);
239 // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); 248 // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
240 249
241// statdlg = new PPPStatsDlg(0, "stats", this, stats); 250// statdlg = new PPPStatsDlg(0, "stats", this, stats);
242// statdlg->hide(); 251// statdlg->hide();
243 252
244 // load up the accounts combo box 253 // load up the accounts combo box
245 254
246// resetaccounts(); 255// resetaccounts();
247// con = new ConnectWidget(0, "con"); 256 con = new ConnectWidget(_pppdata, 0, "con");
248 //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); 257 //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
249// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); 258 connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
250 // Is this the best we can do here? it's not right. 259 // Is this the best we can do here? it's not right.
251// QRect desk = QApplication::desktop()->screenGeometry( 260// QRect desk = QApplication::desktop()->screenGeometry(
252// QApplication::desktop()->screenNumber(topLevelWidget())); 261// QApplication::desktop()->screenNumber(topLevelWidget()));
253// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); 262// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
254 263
255 // connect the ConnectWidgets various signals 264 // connect the ConnectWidgets various signals
256// // connect(con, SIGNAL(startAccounting()), 265 connect(con, SIGNAL(startAccounting()),
257 // // this, SLOT(startAccounting())); 266 this, SLOT(startAccounting()));
258// // connect(con, SIGNAL(stopAccounting()), 267 connect(con, SIGNAL(stopAccounting()),
259 // // this, SLOT(stopAccounting())); 268 this, SLOT(stopAccounting()));
260// connect(qApp, SIGNAL(saveYourself()), 269 connect(qApp, SIGNAL(saveYourself()),
261 // this, SLOT(saveMyself())); 270 this, SLOT(saveMyself()));
262// connect(qApp, SIGNAL(shutDown()), 271 connect(qApp, SIGNAL(shutDown()),
263 // this, SLOT(shutDown())); 272 this, SLOT(shutDown()));
264 273
265 274
266// KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 275// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
267 276
268// m_strCmdlAccount = args->getOption("c"); 277// m_strCmdlAccount = args->getOption("c");
269// m_bQuitOnDisconnect = args->isSet("q"); 278// m_bQuitOnDisconnect = args->isSet("q");
270 279
271// if(!m_strCmdlAccount.isEmpty()) { 280// if(!m_strCmdlAccount.isEmpty()) {
272// m_bCmdlAccount = true; 281// m_bCmdlAccount = true;
273// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; 282// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
274// } 283// }
275 284
276// if(m_bCmdlAccount){ 285// if(m_bCmdlAccount){
277// bool result = PPPData::data()->setAccount(m_strCmdlAccount); 286// bool result = _pppdata->setAccount(m_strCmdlAccount);
278// if (!result){ 287// if (!result){
279// QString string; 288// QString string;
280// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); 289// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
281// KMessageBox::error(this, string); 290// KMessageBox::error(this, string);
282// m_bCmdlAccount = false; 291// m_bCmdlAccount = false;
283// this->show(); 292// this->show();
284// } else { 293// } else {
285// beginConnect(); 294// beginConnect();
286// } 295// }
287// } else 296// } else
288// expandbutton(); 297// expandbutton();
289// show(); 298// show();
@@ -337,454 +346,454 @@ KPPPWidget::~KPPPWidget()
337 346
338void KPPPWidget::enterPressedInID() { 347void KPPPWidget::enterPressedInID() {
339 PW_Edit->setFocus(); 348 PW_Edit->setFocus();
340} 349}
341 350
342 351
343void KPPPWidget::enterPressedInPW() { 352void KPPPWidget::enterPressedInPW() {
344 connect_b->setFocus(); 353 connect_b->setFocus();
345} 354}
346 355
347// triggered by the session manager 356// triggered by the session manager
348void KPPPWidget::saveMyself() { 357void KPPPWidget::saveMyself() {
349 PPPData::data()->save(); 358 _pppdata->save();
350} 359}
351 360
352void KPPPWidget::shutDown() { 361void KPPPWidget::shutDown() {
353 interruptConnection(); 362 interruptConnection();
354 saveMyself(); 363 saveMyself();
355} 364}
356 365
357void KPPPWidget::log_window_toggled(bool on) { 366void KPPPWidget::log_window_toggled(bool on) {
358 PPPData::data()->set_show_log_window(on); 367 _pppdata->set_show_log_window(on);
359} 368}
360 369
361 370
362 371
363 372
364// void KPPPWidget::resetaccounts() { 373// void KPPPWidget::resetaccounts() {
365// connectto_c->clear(); 374// connectto_c->clear();
366 375
367// int count = PPPData::data()->count(); 376// int count = _pppdata->count();
368 377
369// // enable/disable controls 378// // enable/disable controls
370// connectto_c->setEnabled(count > 0); 379// connectto_c->setEnabled(count > 0);
371// connect_b->setEnabled(count > 0); 380// connect_b->setEnabled(count > 0);
372// log->setEnabled(count > 0); 381// log->setEnabled(count > 0);
373// ID_Edit->setEnabled(count > 0); 382// ID_Edit->setEnabled(count > 0);
374// PW_Edit->setEnabled(count > 0); 383// PW_Edit->setEnabled(count > 0);
375 384
376// //load the accounts 385// //load the accounts
377// for(int i=0; i < count; i++) { 386// for(int i=0; i < count; i++) {
378// PPPData::data()->setAccountbyIndex(i); 387// _pppdata->setAccountbyIndex(i);
379// connectto_c->insertItem(PPPData::data()->accname()); 388// connectto_c->insertItem(_pppdata->accname());
380// } 389// }
381 390
382// //set the default account 391// //set the default account
383// if(!PPPData::data()->defaultAccount().isEmpty()) { 392// if(!_pppdata->defaultAccount().isEmpty()) {
384// for(int i=0; i < count; i++) 393// for(int i=0; i < count; i++)
385// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) { 394// if(_pppdata->defaultAccount() == connectto_c->text(i)) {
386 // connectto_c->setCurrentItem(i); 395 // connectto_c->setCurrentItem(i);
387 // PPPData::data()->setAccountbyIndex(i); 396 // _pppdata->setAccountbyIndex(i);
388 397
389 // ID_Edit->setText(PPPData::data()->storedUsername()); 398 // ID_Edit->setText(_pppdata->storedUsername());
390 // PW_Edit->setText(PPPData::data()->storedPassword()); 399 // PW_Edit->setText(_pppdata->storedPassword());
391// } 400// }
392// } 401// }
393// else 402// else
394// if(count > 0) { 403// if(count > 0) {
395// PPPData::data()->setDefaultAccount(connectto_c->text(0)); 404// _pppdata->setDefaultAccount(connectto_c->text(0));
396// PPPData::data()->save(); 405// _pppdata->save();
397 // ID_Edit->setText(PPPData::data()->storedUsername()); 406 // ID_Edit->setText(_pppdata->storedUsername());
398 // PW_Edit->setText(PPPData::data()->storedPassword()); 407 // PW_Edit->setText(_pppdata->storedPassword());
399// } 408// }
400 409
401// connect(ID_Edit, SIGNAL(textChanged(const QString &)), 410// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
402 // this, SLOT(usernameChanged(const QString &))); 411 // this, SLOT(usernameChanged(const QString &)));
403 412
404// connect(PW_Edit, SIGNAL(textChanged(const QString &)), 413// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
405 // this, SLOT(passwordChanged(const QString &))); 414 // this, SLOT(passwordChanged(const QString &)));
406 415
407// if (ID_Edit->text().isEmpty()) 416// if (ID_Edit->text().isEmpty())
408// ID_Edit->setFocus(); 417// ID_Edit->setFocus();
409// else if (PW_Edit->text().isEmpty()) 418// else if (PW_Edit->text().isEmpty())
410// PW_Edit->setFocus(); 419// PW_Edit->setFocus();
411// } 420// }
412 421
413 422
414void KPPPWidget::interruptConnection() { 423void KPPPWidget::interruptConnection() {
415 // interrupt dial up 424 // interrupt dial up
416// if (con->isVisible()) 425//
417// emit con->cancelbutton(); 426
427 if (con->isVisible())
428 emit con->cancelbutton();
418 429
419 // disconnect if online 430 // disconnect if online
420 if (PPPData::data()->pppdRunning()) 431 if (_pppdata->pppdRunning())
421 emit disconnect(); 432 emit disconnect();
422} 433}
423 434
424 435
425void KPPPWidget::sigPPPDDied() { 436void KPPPWidget::sigPPPDDied() {
426 qDebug( "Received a SIGUSR1" ); 437 qDebug( "Received a SIGUSR1" );
427 438
428 // if we are not connected pppdpid is -1 so have have to check for that 439 // if we are not connected pppdpid is -1 so have have to check for that
429 // in the followin line to make sure that we don't raise a false alarm 440 // in the followin line to make sure that we don't raise a false alarm
430 // such as would be the case when the log file viewer exits. 441 // such as would be the case when the log file viewer exits.
431 if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) { 442 if(_pppdata->pppdRunning() || _pppdata->pppdError()) {
432 qDebug( "It was pppd that died" ); 443 qDebug( "It was pppd that died" );
433 444
434 // when we killpppd() on Cancel in ConnectWidget 445 // when we killpppd() on Cancel in ConnectWidget
435 // we set pppid to -1 so we won't 446 // we set pppid to -1 so we won't
436 // enter this block 447 // enter this block
437 448
438 // just to be sure 449 // just to be sure
439 450
440 Modem::modem->removeSecret(AUTH_PAP); 451 Modem::modem->removeSecret(AUTH_PAP);
441 Modem::modem->removeSecret(AUTH_CHAP); 452 Modem::modem->removeSecret(AUTH_CHAP);
442 453
443 PPPData::data()->setpppdRunning(false); 454 _pppdata->setpppdRunning(false);
444 455
445 qDebug( "Executing command on disconnect since pppd has died." ); 456 qDebug( "Executing command on disconnect since pppd has died." );
446 QApplication::flushX(); 457 QApplication::flushX();
447 execute_command(PPPData::data()->command_on_disconnect()); 458 execute_command(_pppdata->command_on_disconnect());
448 459
449// stopAccounting(); 460// stopAccounting();
450 461
451// con_win->stopClock(); 462 con_win->stopClock();
452// DockWidget::dock_widget->stop_stats(); 463// DockWidget::dock_widget->stop_stats();
453// DockWidget::dock_widget->hide(); 464// DockWidget::dock_widget->hide();
454 465
455 if(!PPPData::data()->pppdError()) 466 if(!_pppdata->pppdError())
456 PPPData::data()->setpppdError(E_PPPD_DIED); 467 _pppdata->setpppdError(E_PPPD_DIED);
457 removedns(); 468 removedns();
458 Modem::modem->unlockdevice(); 469 Modem::modem->unlockdevice();
459 // con->pppdDied(); 470 //
471 con->pppdDied();
460 472
461 if(!PPPData::data()->automatic_redial()) { 473 if(!_pppdata->automatic_redial()) {
462 quit_b->setFocus(); 474 quit_b->setFocus();
463 show(); 475 show();
464// con_win->stopClock(); 476 con_win->stopClock();
465 //stopAccounting(); 477 //stopAccounting();
466// con_win->hide(); 478 con_win->hide();
467// con->hide(); 479 con->hide();
468 480
469 PPPData::data()->setpppdRunning(false); 481 _pppdata->setpppdRunning(false);
470 // // not in a signal handler !!! KNotifyClient::beep(); 482 // // not in a signal handler !!! KNotifyClient::beep();
471 QString msg; 483 QString msg;
472 if (PPPData::data()->pppdError() == E_IF_TIMEOUT) 484 if (_pppdata->pppdError() == E_IF_TIMEOUT)
473 msg = i18n("Timeout expired while waiting for the PPP interface " 485 msg = i18n("Timeout expired while waiting for the PPP interface "
474 "to come up!"); 486 "to come up!");
475 else { 487 else {
476 msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); 488 msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
477 Modem::modem->pppdExitStatus(); 489 Modem::modem->pppdExitStatus();
478 if (Modem::modem->lastStatus != 99) {// more recent pppds only 490 if (Modem::modem->lastStatus != 99) {// more recent pppds only
479 msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); 491 msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
480 msg += i18n("</p><p>See 'man pppd' for an explanation of the error " 492 msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
481 "codes or take a look at the kppp FAQ on " 493 "codes or take a look at the kppp FAQ on "
482 " <a href=http://devel-home.kde.org/~kppp/index.html>" 494 " <a href=http://devel-home.kde.org/~kppp/index.html>"
483 "http://devel-home.kde.org/~kppp/index.html</a></p>"); 495 "http://devel-home.kde.org/~kppp/index.html</a></p>");
484 } 496 }
485 } 497 }
486 498
487 // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) 499 // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
488 // // PPPL_ShowLog(); 500 // // PPPL_ShowLog();
489// } else { /* reconnect on disconnect */ 501// } else { /* reconnect on disconnect */
490 if (false){ 502 if (false){
491 qDebug( "Trying to reconnect... " ); 503 qDebug( "Trying to reconnect... " );
492 504
493 if(PPPData::data()->authMethod() == AUTH_PAP || 505 if(_pppdata->authMethod() == AUTH_PAP ||
494 PPPData::data()->authMethod() == AUTH_CHAP || 506 _pppdata->authMethod() == AUTH_CHAP ||
495 PPPData::data()->authMethod() == AUTH_PAPCHAP) 507 _pppdata->authMethod() == AUTH_PAPCHAP)
496 Modem::modem->setSecret(PPPData::data()->authMethod(), 508 Modem::modem->setSecret(_pppdata->authMethod(),
497 encodeWord(PPPData::data()->storedUsername()), 509 encodeWord(_pppdata->storedUsername()),
498 encodeWord(PPPData::data()->password())); 510 encodeWord(_pppdata->password()));
499 511
500// con_win->hide(); 512 con_win->hide();
501 // con_win->stopClock(); 513 con_win->stopClock();
502 //stopAccounting(); 514 //stopAccounting();
503 PPPData::data()->setpppdRunning(false); 515 _pppdata->setpppdRunning(false);
504 // not in a signal handler !!!KNotifyClient::beep(); 516 // not in a signal handler !!!KNotifyClient::beep();
505 emit cmdl_start(); 517 emit cmdl_start();
506 } 518 }
507 } 519 }
508 PPPData::data()->setpppdError(0); 520 _pppdata->setpppdError(0);
509 } 521 }
510} 522}
511 523
512// void KPPPWidget::sigChld() { 524// void KPPPWidget::sigChld() {
513// qDebug( "sigchld()" ); 525// qDebug( "sigchld()" );
514// // pid_t id = wait(0L); 526// // pid_t id = wait(0L);
515// // if(id == helperPid && helperPid != -1) { 527// // if(id == helperPid && helperPid != -1) {
516// // kdDebug(5002) << "It was the setuid child that died" << endl; 528// // kdDebug(5002) << "It was the setuid child that died" << endl;
517// // helperPid = -1; 529// // helperPid = -1;
518// QString msg = i18n("kppp's helper process just died.\n" 530// QString msg = i18n("kppp's helper process just died.\n"
519// "Since a further execution would be pointless, " 531// "Since a further execution would be pointless, "
520// "kppp will shut down now."); 532// "kppp will shut down now.");
521// QMessageBox::warning(0L,"error", msg); 533// QMessageBox::warning(0L,"error", msg);
522// //remove_pidfile(); 534// //remove_pidfile();
523// exit(1); 535// exit(1);
524// // } 536// // }
525// } 537// }
526 538
527 539
528void KPPPWidget::newdefaultaccount(int i) { 540void KPPPWidget::newdefaultaccount(int i) {
529 PPPData::data()->setDefaultAccount(connectto_c->text(i)); 541 _pppdata->setDefaultAccount(connectto_c->text(i));
530 PPPData::data()->save(); 542 _pppdata->save();
531 ID_Edit->setText(PPPData::data()->storedUsername()); 543 ID_Edit->setText(_pppdata->storedUsername());
532 PW_Edit->setText(PPPData::data()->storedPassword()); 544 PW_Edit->setText(_pppdata->storedPassword());
533} 545}
534 546
535 547
536 548
537 549
538void KPPPWidget::beginConnect() { 550void KPPPWidget::beginConnect() {
539 // make sure to connect to the account that is selected in the combo box 551 // make sure to connect to the account that is selected in the combo box
540 // (exeption: an account given by a command line argument) 552 // (exeption: an account given by a command line argument)
541 // if(!m_bCmdlAccount) { 553 // if(!m_bCmdlAccount) {
542// PPPData::data()->setAccount(connectto_c->currentText()); 554// _pppdata->setAccount(connectto_c->currentText());
543// PPPData::data()->setPassword(PW_Edit->text()); 555// _pppdata->setPassword(PW_Edit->text());
544// } else { 556// } else {
545 PPPData::data()->setPassword(PPPData::data()->storedPassword()); 557 _pppdata->setPassword(_pppdata->storedPassword());
546// } 558// }
547 559
548 QFileInfo info(pppdPath()); 560 QFileInfo info(pppdPath());
549 561
550 if(!info.exists()){ 562 if(!info.exists()){
551 QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" 563 QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
552 "Make sure that pppd is installed and " 564 "Make sure that pppd is installed and "
553 "that you have entered the correct path.")); 565 "that you have entered the correct path."));
554 return; 566 return;
555 } 567 }
556#if 0 568#if 0
557 if(!info.isExecutable()){ 569 if(!info.isExecutable()){
558 570
559 QString string; 571 QString string;
560 string = i18n("kppp cannot execute:\n %1\n" 572 string = i18n("kppp cannot execute:\n %1\n"
561 "Please make sure that you have given kppp " 573 "Please make sure that you have given kppp "
562 "setuid permission and that " 574 "setuid permission and that "
563 "pppd is executable.").arg(PPPData::data()->pppdPath()); 575 "pppd is executable.").arg(_pppdata->pppdPath());
564 KMessageBox::error(this, string); 576 KMessageBox::error(this, string);
565 return; 577 return;
566 578
567 } 579 }
568#endif 580#endif
569 581
570 QFileInfo info2(PPPData::data()->modemDevice()); 582 QFileInfo info2(_pppdata->modemDevice());
571 583
572 if(!info2.exists()){ 584 if(!info2.exists()){
573 QString string; 585 QString string;
574 string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " 586 string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
575 "your modem device properly " 587 "your modem device properly "
576 "and/or adjust the location of the modem device on " 588 "and/or adjust the location of the modem device on "
577 "the modem tab of " 589 "the modem tab of "
578 "the setup dialog.").arg(PPPData::data()->modemDevice()); 590 "the setup dialog.").arg(_pppdata->modemDevice());
579 QMessageBox::warning(this, "error", string); 591 QMessageBox::warning(this, "error", string);
580 return; 592 return;
581 } 593 }
582 594
583 // if this is a PAP or CHAP account, ensure that username is 595 // if this is a PAP or CHAP account, ensure that username is
584 // supplied 596 // supplied
585 if(PPPData::data()->authMethod() == AUTH_PAP || 597 if(_pppdata->authMethod() == AUTH_PAP ||
586 PPPData::data()->authMethod() == AUTH_CHAP || 598 _pppdata->authMethod() == AUTH_CHAP ||
587 PPPData::data()->authMethod() == AUTH_PAPCHAP ) { 599 _pppdata->authMethod() == AUTH_PAPCHAP ) {
588 if(ID_Edit->text().isEmpty()) { 600 if(ID_Edit->text().isEmpty()) {
589 QMessageBox::warning(this,"error", 601 QMessageBox::warning(this,"error",
590 i18n( 602 i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!"));
591 "You have selected the authentication " 603// FIXME: return;
592 "method PAP or CHAP. This requires that you "
593 "supply a username and a password!"));
594 return;
595 } else { 604 } else {
596 if(!Modem::modem->setSecret(PPPData::data()->authMethod(), 605 if(!Modem::modem->setSecret(_pppdata->authMethod(),
597 encodeWord(PPPData::data()->storedUsername()), 606 encodeWord(_pppdata->storedUsername()),
598 encodeWord(PPPData::data()->password()))) { 607 encodeWord(_pppdata->password()))) {
599 QString s; 608 QString s;
600 s = i18n("Cannot create PAP/CHAP authentication\n" 609 s = i18n("Cannot create PAP/CHAP authentication\n"
601 "file \"%1\"").arg(PAP_AUTH_FILE); 610 "file \"%1\"").arg(PAP_AUTH_FILE);
602 QMessageBox::warning(this, "error", s); 611 QMessageBox::warning(this, "error", s);
603 return; 612 return;
604 } 613 }
605 } 614 }
606 } 615 }
607 616
608 if (PPPData::data()->phonenumber().isEmpty()) { 617 if (_pppdata->phonenumber().isEmpty()) {
609 QString s = i18n("You must specify a telephone number!"); 618 QString s = i18n("You must specify a telephone number!");
610 QMessageBox::warning(this, "error", s); 619 QMessageBox::warning(this, "error", s);
611 return; 620 return;
612 } 621 }
613 622
614 this->hide(); 623 this->hide();
615 624
616 QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); 625 QString tit = i18n("Connecting to: %1").arg(_pppdata->accname());
617// con->setCaption(tit); 626// con->setCaption(tit);
618 627
619// con->show(); 628// con->show();
620 629
621 630
622 emit begin_connect(); 631 emit begin_connect();
623} 632}
624 633
625 634
626void KPPPWidget::disconnect() { 635void KPPPWidget::disconnect() {
627 if (!PPPData::data()->command_before_disconnect().isEmpty()) { 636 if (!_pppdata->command_before_disconnect().isEmpty()) {
628// con_win->hide(); 637 con_win->hide();
629// con->show(); 638 con->show();
630// con->setCaption(i18n("Disconnecting...")); 639 con->setCaption(i18n("Disconnecting..."));
631// con->setMsg(i18n("Executing command before disconnection.")); 640 con->setMsg(i18n("Executing command before disconnection."));
632 641
633 qApp->processEvents(); 642 qApp->processEvents();
634 QApplication::flushX(); 643 QApplication::flushX();
635// pid_t id = 644// pid_t id =
636 execute_command(PPPData::data()->command_before_disconnect()); 645 execute_command(_pppdata->command_before_disconnect());
637// int i, status; 646// int i, status;
638 647
639// do { 648// do {
640// kapp->processEvents(); 649// kapp->processEvents();
641// i = waitpid(id, &status, WNOHANG); 650// i = waitpid(id, &status, WNOHANG);
642// usleep(500000); 651// usleep(500000);
643// } while (i == 0 && errno == 0); 652// } while (i == 0 && errno == 0);
644 653
645// con->hide(); 654 con->hide();
646 } 655 }
647 656
648 qApp->processEvents(); 657 qApp->processEvents();
649 658
650// statdlg->stop_stats(); 659// statdlg->stop_stats();
651 Modem::modem->killPPPDaemon(); 660 Modem::modem->killPPPDaemon();
652 661
653 QApplication::flushX(); 662 QApplication::flushX();
654 execute_command(PPPData::data()->command_on_disconnect()); 663 execute_command(_pppdata->command_on_disconnect());
655 664
656 Modem::modem->removeSecret(AUTH_PAP); 665 Modem::modem->removeSecret(AUTH_PAP);
657 Modem::modem->removeSecret(AUTH_CHAP); 666 Modem::modem->removeSecret(AUTH_CHAP);
658 667
659 removedns(); 668 removedns();
660 Modem::modem->unlockdevice(); 669 Modem::modem->unlockdevice();
661 670
662// con_win->stopClock(); 671 con_win->stopClock();
663// p_kppp->stopAccounting(); 672// p_kppp->stopAccounting();
664// con_win->hide(); 673 con_win->hide();
665 674
666// DockWidget::dock_widget->stop_stats(); 675// DockWidget::dock_widget->stop_stats();
667// DockWidget::dock_widget->hide(); 676// DockWidget::dock_widget->hide();
668 677
669// if(m_bQuitOnDisconnect) 678// if(m_bQuitOnDisconnect)
670// kapp->exit(0); 679// kapp->exit(0);
671// else { 680// else {
672 this->quit_b->setFocus(); 681 this->quit_b->setFocus();
673 this->show(); 682 this->show();
674// } 683// }
675} 684}
676 685
677 686
678// void KPPPWidget::helpbutton() { 687// void KPPPWidget::helpbutton() {
679// kapp->invokeHelp(); 688// kapp->invokeHelp();
680// } 689// }
681 690
682 691
683void KPPPWidget::quitbutton() { 692void KPPPWidget::quitbutton() {
684 if(PPPData::data()->pppdRunning()) { 693 if(_pppdata->pppdRunning()) {
685 int ok = QMessageBox::warning(this, 694 int ok = QMessageBox::warning(this,
686 i18n("Exiting kPPP will close your PPP Session."), 695 i18n("Exiting kPPP will close your PPP Session."),
687 i18n("Quit kPPP?")); 696 i18n("Quit kPPP?"));
688 if(ok == QMessageBox::Yes) { 697 if(ok == QMessageBox::Yes) {
689 Modem::modem->killPPPDaemon(); 698 Modem::modem->killPPPDaemon();
690 QApplication::flushX(); 699 QApplication::flushX();
691 execute_command(PPPData::data()->command_on_disconnect()); 700 execute_command(_pppdata->command_on_disconnect());
692 removedns(); 701 removedns();
693 Modem::modem->unlockdevice(); 702 Modem::modem->unlockdevice();
694 } 703 }
695 } else { 704 } else {
696 if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword()) 705 if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword())
697 PPPData::data()->setStoredPassword(""); 706 _pppdata->setStoredPassword("");
698 } 707 }
699 PPPData::data()->save(); 708 _pppdata->save();
700 qApp->quit(); 709 qApp->quit();
701} 710}
702 711
703 712
704// void KPPPWidget::rulesetLoadError() { 713// void KPPPWidget::rulesetLoadError() {
705// QMessageBox::warning(this,"error", ruleset_load_errmsg); 714// QMessageBox::warning(this,"error", ruleset_load_errmsg);
706// } 715// }
707 716
708 717
709// void KPPPWidget::startAccounting() { 718// void KPPPWidget::startAccounting() {
710// // volume accounting 719// // volume accounting
711// stats->totalbytes = 0; 720// stats->totalbytes = 0;
712 721
713// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl; 722// kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl;
714 723
715// // load the ruleset 724// // load the ruleset
716// if(!PPPData::data()->AcctEnabled()) 725// if(!_pppdata->AcctEnabled())
717// return; 726// return;
718 727
719// QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile()); 728// QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile());
720// // if(::access(d.data(), X_OK) != 0) 729// // if(::access(d.data(), X_OK) != 0)
721// acct = new Accounting(this, stats); 730// acct = new Accounting(this, stats);
722// // else 731// // else
723// // acct = new ExecutableAccounting(this); 732// // acct = new ExecutableAccounting(this);
724 733
725// // connect to the accounting object 734// // connect to the accounting object
726// connect(acct, SIGNAL(changed(QString, QString)), 735// connect(acct, SIGNAL(changed(QString, QString)),
727 // con_win, SLOT(slotAccounting(QString, QString))); 736 // con_win, SLOT(slotAccounting(QString, QString)));
728 737
729// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) { 738// // if(!acct->loadRuleSet(_pppdata->accountingFile())) {
730// // QString s= i18n("Can not load the accounting " 739// // QString s= i18n("Can not load the accounting "
731 // // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile()); 740 // // "ruleset \"%1\"!").arg(_pppdata->accountingFile());
732 741
733// // starting the messagebox with a timer will prevent us 742// // starting the messagebox with a timer will prevent us
734// // from blocking the calling function ConnectWidget::timerEvent 743// // from blocking the calling function ConnectWidget::timerEvent
735// ruleset_load_errmsg = s; 744// ruleset_load_errmsg = s;
736// QTimer::singleShot(0, this, SLOT(rulesetLoadError())); 745// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
737// return; 746// return;
738// } 747// }
739// //else 748// //else
740// // acct->slotStart(); 749// // acct->slotStart();
741// } 750// }
742 751
743// void KPPPWidget::stopAccounting() { 752// void KPPPWidget::stopAccounting() {
744// // store volume accounting 753// // store volume accounting
745// // if(stats->totalbytes != 0) 754// // if(stats->totalbytes != 0)
746// // PPPData::data()->setTotalBytes(stats->totalbytes); 755// // _pppdata->setTotalBytes(stats->totalbytes);
747 756
748// if(!PPPData::data()->AcctEnabled()) 757// if(!_pppdata->AcctEnabled())
749// return; 758// return;
750 759
751// // if(acct != 0) { 760// // if(acct != 0) {
752// // acct->slotStop(); 761// // acct->slotStop();
753// // delete acct; 762// // delete acct;
754// // acct = 0; 763// // acct = 0;
755// // } 764// // }
756// } 765// }
757 766
758 767
759// void KPPPWidget::showStats() { 768// void KPPPWidget::showStats() {
760// if(statdlg) { 769// if(statdlg) {
761// statdlg->show(); 770// statdlg->show();
762// statdlg->raise(); 771// statdlg->raise();
763// } 772// }
764// } 773// }
765 774
766 775
767void KPPPWidget::usernameChanged(const QString &) { 776void KPPPWidget::usernameChanged(const QString &) {
768 // store username for later use 777 // store username for later use
769 PPPData::data()->setStoredUsername(ID_Edit->text()); 778 _pppdata->setStoredUsername(ID_Edit->text());
770} 779}
771 780
772 781
773void KPPPWidget::passwordChanged(const QString &) { 782void KPPPWidget::passwordChanged(const QString &) {
774 // store the password if so requested 783 // store the password if so requested
775 if(PPPData::data()->storePassword()) 784 if(_pppdata->storePassword())
776 PPPData::data()->setStoredPassword(PW_Edit->text()); 785 _pppdata->setStoredPassword(PW_Edit->text());
777 else 786 else
778 PPPData::data()->setStoredPassword(""); 787 _pppdata->setStoredPassword("");
779} 788}
780 789
781 790
782void KPPPWidget::setPW_Edit(const QString &pw) { 791void KPPPWidget::setPW_Edit(const QString &pw) {
783 PW_Edit->setText(pw); 792 PW_Edit->setText(pw);
784} 793}
785 794
786 795
787// void KPPPWidget::resetCosts(const QString &s) { 796// void KPPPWidget::resetCosts(const QString &s) {
788// AccountingBase::resetCosts(s); 797// AccountingBase::resetCosts(s);
789// } 798// }
790 799
@@ -806,25 +815,25 @@ QString KPPPWidget::encodeWord(const QString &s) {
806 815
807// void KPPPWidget::setQuitOnDisconnect (bool b) 816// void KPPPWidget::setQuitOnDisconnect (bool b)
808// { 817// {
809// m_bQuitOnDisconnect = b; 818// m_bQuitOnDisconnect = b;
810// } 819// }
811 820
812void KPPPWidget::showNews() { 821void KPPPWidget::showNews() {
813#ifdef KPPP_SHOW_NEWS 822#ifdef KPPP_SHOW_NEWS
814 /* 823 /*
815 * Introduce the QuickHelp feature to new users of this version 824 * Introduce the QuickHelp feature to new users of this version
816 */ 825 */
817 #define QUICKHELP_HINT "Hint_QuickHelp" 826 #define QUICKHELP_HINT "Hint_QuickHelp"
818 if(PPPData::data()->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { 827 if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
819 QDialog dlg(0, 0, true); 828 QDialog dlg(0, 0, true);
820 dlg.setCaption(i18n("Recent Changes in KPPP")); 829 dlg.setCaption(i18n("Recent Changes in KPPP"));
821 830
822 QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); 831 QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
823 QHBoxLayout *l1 = new QHBoxLayout(10); 832 QHBoxLayout *l1 = new QHBoxLayout(10);
824 QVBoxLayout *l2 = new QVBoxLayout(10); 833 QVBoxLayout *l2 = new QVBoxLayout(10);
825 tl->addLayout(l1); 834 tl->addLayout(l1);
826 835
827 QLabel *icon = new QLabel(&dlg); 836 QLabel *icon = new QLabel(&dlg);
828 icon->setPixmap(BarIcon("exclamation")); 837 icon->setPixmap(BarIcon("exclamation"));
829 icon->setFixedSize(icon->sizeHint()); 838 icon->setFixedSize(icon->sizeHint());
830 l1->addWidget(icon); 839 l1->addWidget(icon);
@@ -858,22 +867,22 @@ void KPPPWidget::showNews() {
858 l2->addWidget(cb); 867 l2->addWidget(cb);
859 tl->addWidget(bbox); 868 tl->addWidget(bbox);
860 869
861 QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" 870 QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n"
862 "This window will stay open until you\n" 871 "This window will stay open until you\n"
863 "click a mouse button or a press a key.\n"); 872 "click a mouse button or a press a key.\n");
864 873
865 QWhatsThis::add(cb,tmp); 874 QWhatsThis::add(cb,tmp);
866 QWhatsThis::add(l, tmp); 875 QWhatsThis::add(l, tmp);
867 876
868 dlg.exec(); 877 dlg.exec();
869 if(cb->isChecked()) { 878 if(cb->isChecked()) {
870 PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); 879 _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
871 PPPData::data()->save(); 880 _pppdata->save();
872 } 881 }
873 } 882 }
874#endif 883#endif
875} 884}
876 885
877 886
878//#include "kpppwidget.moc" 887//#include "kpppwidget.moc"
879 888
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h
index d7e74af..b958862 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.h
+++ b/noncore/settings/networksettings/ppp/kpppwidget.h
@@ -25,31 +25,32 @@
25 */ 25 */
26 26
27#ifndef __KPPPWIDGET_H__ 27#ifndef __KPPPWIDGET_H__
28#define __KPPPWIDGET_H__ 28#define __KPPPWIDGET_H__
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include "conwindow.h" 32#include "conwindow.h"
33#include "accounts.h" 33#include "accounts.h"
34#include "connect.h" 34#include "connect.h"
35 35
36class QPushButton; 36class QPushButton;
37 37class Interface;
38class PPPData;
38 39
39class KPPPWidget : public QDialog { 40class KPPPWidget : public QDialog {
40 Q_OBJECT 41 Q_OBJECT
41public: 42public:
42 43
43 KPPPWidget( QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 ); 44 KPPPWidget(PPPData*, Interface*, QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 );
44 ~KPPPWidget(); 45 ~KPPPWidget();
45 46
46 void setPW_Edit(const QString &); 47 void setPW_Edit(const QString &);
47 48
48 49
49private slots: 50private slots:
50 void newdefaultaccount(int); 51 void newdefaultaccount(int);
51 void beginConnect(); 52 void beginConnect();
52 void quitbutton(); 53 void quitbutton();
53 void usernameChanged(const QString &); 54 void usernameChanged(const QString &);
54 void passwordChanged(const QString &); 55 void passwordChanged(const QString &);
55 void enterPressedInID(); 56 void enterPressedInID();
@@ -61,41 +62,41 @@ private slots:
61public slots: 62public slots:
62 void disconnect(); 63 void disconnect();
63 void log_window_toggled(bool on); 64 void log_window_toggled(bool on);
64 65
65signals: 66signals:
66 void begin_connect(); 67 void begin_connect();
67 void cmdl_start(); 68 void cmdl_start();
68 69
69public: 70public:
70 QCheckBox *log; 71 QCheckBox *log;
71 bool connected; 72 bool connected;
72 QString con_speed; 73 QString con_speed;
73 // ConnectWidget *con; 74 ConnectWidget *con;
74 // ConWindow *con_win; 75 ConWindow *con_win;
75 // PPPStatsDlg *statdlg; 76 // PPPStatsDlg *statdlg;
76 // AccountingBase *acct; 77 // AccountingBase *acct;
77 QPushButton *quit_b; 78 QPushButton *quit_b;
78 //PPPStats *stats; 79 //PPPStats *stats;
79 80
80private: 81private:
81 // void prepareSetupDialog(); 82 // void prepareSetupDialog();
82 void interruptConnection(); 83 void interruptConnection();
83 void sigChld(); 84 void sigChld();
84 void sigPPPDDied(); 85 void sigPPPDDied();
85 QString encodeWord(const QString &s); 86 QString encodeWord(const QString &s);
86 void showNews (); 87 void showNews ();
87 88
88 QString ruleset_load_errmsg; 89 QString ruleset_load_errmsg;
89 90 PPPData *_pppdata;
90 QPushButton *setup_b; 91 QPushButton *setup_b;
91 QFrame *fline; 92 QFrame *fline;
92 QFrame *fline1; 93 QFrame *fline1;
93 QPushButton *connect_b; 94 QPushButton *connect_b;
94 QComboBox *connectto_c; 95 QComboBox *connectto_c;
95 QLabel *ID_Label; 96 QLabel *ID_Label;
96 QLabel *PW_Label; 97 QLabel *PW_Label;
97 QLineEdit *ID_Edit; 98 QLineEdit *ID_Edit;
98 QLineEdit *PW_Edit; 99 QLineEdit *PW_Edit;
99 QLabel *label1; 100 QLabel *label1;
100 QLabel *label2; 101 QLabel *label2;
101 QLabel *label3; 102 QLabel *label3;
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index 5139482..002c8e7 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -53,25 +53,25 @@
53#define i18n QObject::tr 53#define i18n QObject::tr
54#define qError qDebug 54#define qError qDebug
55//#include <kdebug.h> 55//#include <kdebug.h>
56//#include <config.h> 56//#include <config.h>
57 57
58#define MY_ASSERT(x) if (!(x)) { \ 58#define MY_ASSERT(x) if (!(x)) { \
59 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ 59 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
60 exit(1); } 60 exit(1); }
61 61
62 62
63static sigjmp_buf jmp_buffer; 63static sigjmp_buf jmp_buffer;
64 64
65Modem *Modem::modem = 0; 65//Modem *Modem::modem = 0;
66 66
67 67
68const char* pppdPath() { 68const char* pppdPath() {
69 // wasting a few bytes 69 // wasting a few bytes
70 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; 70 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
71 static char *pppdPath = 0L; 71 static char *pppdPath = 0L;
72 char *p; 72 char *p;
73 73
74 if(pppdPath == 0L) { 74 if(pppdPath == 0L) {
75 const char *c = PPPDSEARCHPATH; 75 const char *c = PPPDSEARCHPATH;
76 while(*c != '\0') { 76 while(*c != '\0') {
77 while(*c == ':') 77 while(*c == ':')
@@ -82,49 +82,48 @@ const char* pppdPath() {
82 *p = '\0'; 82 *p = '\0';
83 strcat(p, "/"); 83 strcat(p, "/");
84 strcat(p, PPPDNAME); 84 strcat(p, PPPDNAME);
85 if(access(buffer, F_OK) == 0) 85 if(access(buffer, F_OK) == 0)
86 return (pppdPath = buffer); 86 return (pppdPath = buffer);
87 } 87 }
88 } 88 }
89 89
90 return pppdPath; 90 return pppdPath;
91} 91}
92 92
93 93
94Modem::Modem() 94Modem::Modem( PPPData* pd )
95{ 95{
96 if (Modem::modem != 0) return; //CORRECT? 96 _pppdata = pd;
97 modemfd = -1; 97 modemfd = -1;
98 _pppdExitStatus = -1; 98 _pppdExitStatus = -1;
99 pppdPid = -1; 99 pppdPid = -1;
100 sn = 0L; 100 sn = 0L;
101 data_mode = false; 101 data_mode = false;
102 modem_is_locked = false; 102 modem_is_locked = false;
103 lockfile[0] = '\0'; 103 lockfile[0] = '\0';
104 device = "/dev/modem"; 104 device = "/dev/modem";
105 modem = this;
106} 105}
107 106
108 107
109Modem::~Modem() { 108Modem::~Modem()
110 modem = 0; 109{
111} 110}
112 111
113 112
114speed_t Modem::modemspeed() { 113speed_t Modem::modemspeed() {
115 // convert the string modem speed int the gpppdata object to a t_speed type 114 // convert the string modem speed int the gpppdata object to a t_speed type
116 // to set the modem. The constants here should all be ifdef'd because 115 // to set the modem. The constants here should all be ifdef'd because
117 // other systems may not have them 116 // other systems may not have them
118 int i = PPPData::data()->speed().toInt()/100; 117 int i = _pppdata->speed().toInt()/100;
119 118
120 switch(i) { 119 switch(i) {
121 case 24: 120 case 24:
122 return B2400; 121 return B2400;
123 break; 122 break;
124 case 96: 123 case 96:
125 return B9600; 124 return B9600;
126 break; 125 break;
127 case 192: 126 case 192:
128 return B19200; 127 return B19200;
129 break; 128 break;
130 case 384: 129 case 384:
@@ -156,35 +155,35 @@ speed_t Modem::modemspeed() {
156 155
157 default: 156 default:
158 return B38400; 157 return B38400;
159 break; 158 break;
160 } 159 }
161} 160}
162 161
163bool Modem::opentty() { 162bool Modem::opentty() {
164 // int flags; 163 // int flags;
165 164
166//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 165//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
167 close(modemfd); 166 close(modemfd);
168 device = PPPData::data()->modemDevice(); 167 device = _pppdata->modemDevice();
169 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { 168 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
170 qDebug("error opening modem device !"); 169 qDebug("error opening modem device !");
171 errmsg = i18n("Unable to open modem."); 170 errmsg = i18n("Unable to open modem.");
172 return false; 171 return false;
173 } 172 }
174//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 173//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
175//} 174//}
176 175
177#if 0 176#if 0
178 if(PPPData::data()->UseCDLine()) { 177 if(_pppdata->UseCDLine()) {
179 if(ioctl(modemfd, TIOCMGET, &flags) == -1) { 178 if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
180 errmsg = i18n("Unable to detect state of CD line."); 179 errmsg = i18n("Unable to detect state of CD line.");
181 ::close(modemfd); 180 ::close(modemfd);
182 modemfd = -1; 181 modemfd = -1;
183 return false; 182 return false;
184 } 183 }
185 if ((flags&TIOCM_CD) == 0) { 184 if ((flags&TIOCM_CD) == 0) {
186 errmsg = i18n("The modem is not ready."); 185 errmsg = i18n("The modem is not ready.");
187 ::close(modemfd); 186 ::close(modemfd);
188 modemfd = -1; 187 modemfd = -1;
189 return false; 188 return false;
190 } 189 }
@@ -214,26 +213,26 @@ bool Modem::opentty() {
214 tty.c_cc[VTIME] = 0; 213 tty.c_cc[VTIME] = 0;
215 tty.c_oflag = 0; 214 tty.c_oflag = 0;
216 tty.c_lflag = 0; 215 tty.c_lflag = 0;
217 216
218 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 217 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
219 tty.c_cflag |= CS8 | CREAD; 218 tty.c_cflag |= CS8 | CREAD;
220 tty.c_cflag |= CLOCAL; // ignore modem status lines 219 tty.c_cflag |= CLOCAL; // ignore modem status lines
221 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; 220 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
222 tty.c_lflag &= ~ICANON; // non-canonical mode 221 tty.c_lflag &= ~ICANON; // non-canonical mode
223 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); 222 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
224 223
225 224
226 if(PPPData::data()->flowcontrol() != "None") { 225 if(_pppdata->flowcontrol() != "None") {
227 if(PPPData::data()->flowcontrol() == "CRTSCTS") { 226 if(_pppdata->flowcontrol() == "CRTSCTS") {
228 tty.c_cflag |= CRTSCTS; 227 tty.c_cflag |= CRTSCTS;
229 } 228 }
230 else { 229 else {
231 tty.c_iflag |= IXON | IXOFF; 230 tty.c_iflag |= IXON | IXOFF;
232 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ 231 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
233 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ 232 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
234 } 233 }
235 } 234 }
236 else { 235 else {
237 tty.c_cflag &= ~CRTSCTS; 236 tty.c_cflag &= ~CRTSCTS;
238 tty.c_iflag &= ~(IXON | IXOFF); 237 tty.c_iflag &= ~(IXON | IXOFF);
239 } 238 }
@@ -344,25 +343,25 @@ bool Modem::writeChar(unsigned char c) {
344 } 343 }
345 } while(s == 0); 344 } while(s == 0);
346 345
347 return true; 346 return true;
348} 347}
349 348
350 349
351bool Modem::writeLine(const char *buf) { 350bool Modem::writeLine(const char *buf) {
352 int len = strlen(buf); 351 int len = strlen(buf);
353 char *b = new char[len+2]; 352 char *b = new char[len+2];
354 memcpy(b, buf, len); 353 memcpy(b, buf, len);
355 // different modems seem to need different line terminations 354 // different modems seem to need different line terminations
356 QString term = PPPData::data()->enter(); 355 QString term = _pppdata->enter();
357 if(term == "LF") 356 if(term == "LF")
358 b[len++]='\n'; 357 b[len++]='\n';
359 else if(term == "CR") 358 else if(term == "CR")
360 b[len++]='\r'; 359 b[len++]='\r';
361 else if(term == "CR/LF") { 360 else if(term == "CR/LF") {
362 b[len++]='\r'; 361 b[len++]='\r';
363 b[len++]='\n'; 362 b[len++]='\n';
364 } 363 }
365 int l = len; 364 int l = len;
366 while(l) { 365 while(l) {
367 int wr = write(modemfd, &b[len-l], l); 366 int wr = write(modemfd, &b[len-l], l);
368 if(wr < 0) { 367 if(wr < 0) {
@@ -384,27 +383,27 @@ bool Modem::hangup() {
384 // this is probably the most imporant snippet of code in the whole of 383 // this is probably the most imporant snippet of code in the whole of
385 // kppp. If people complain about kppp being stuck, this piece of code 384 // kppp. If people complain about kppp being stuck, this piece of code
386 // is most likely the reason. 385 // is most likely the reason.
387 struct termios temptty; 386 struct termios temptty;
388 387
389 if(modemfd >= 0) { 388 if(modemfd >= 0) {
390 389
391 // is this Escape & HangupStr stuff really necessary ? (Harri) 390 // is this Escape & HangupStr stuff really necessary ? (Harri)
392 391
393 if (data_mode) escape_to_command_mode(); 392 if (data_mode) escape_to_command_mode();
394 393
395 // Then hangup command 394 // Then hangup command
396 writeLine(PPPData::data()->modemHangupStr().local8Bit()); 395 writeLine(_pppdata->modemHangupStr().local8Bit());
397 396
398 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 397 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec
399 398
400#ifndef DEBUG_WO_DIALING 399#ifndef DEBUG_WO_DIALING
401 if (sigsetjmp(jmp_buffer, 1) == 0) { 400 if (sigsetjmp(jmp_buffer, 1) == 0) {
402 // set alarm in case tcsendbreak() hangs 401 // set alarm in case tcsendbreak() hangs
403 signal(SIGALRM, alarm_handler); 402 signal(SIGALRM, alarm_handler);
404 alarm(2); 403 alarm(2);
405 404
406 tcsendbreak(modemfd, 0); 405 tcsendbreak(modemfd, 0);
407 406
408 alarm(0); 407 alarm(0);
409 signal(SIGALRM, SIG_IGN); 408 signal(SIGALRM, SIG_IGN);
410 } else { 409 } else {
@@ -422,52 +421,52 @@ bool Modem::hangup() {
422 cfsetispeed(&temptty, B0); 421 cfsetispeed(&temptty, B0);
423 tcsetattr(modemfd, TCSAFLUSH, &temptty); 422 tcsetattr(modemfd, TCSAFLUSH, &temptty);
424#else 423#else
425 int modemstat; 424 int modemstat;
426 ioctl(modemfd, TIOCMGET, &modemstat); 425 ioctl(modemfd, TIOCMGET, &modemstat);
427 modemstat &= ~TIOCM_DTR; 426 modemstat &= ~TIOCM_DTR;
428 ioctl(modemfd, TIOCMSET, &modemstat); 427 ioctl(modemfd, TIOCMSET, &modemstat);
429 ioctl(modemfd, TIOCMGET, &modemstat); 428 ioctl(modemfd, TIOCMGET, &modemstat);
430 modemstat |= TIOCM_DTR; 429 modemstat |= TIOCM_DTR;
431 ioctl(modemfd, TIOCMSET, &modemstat); 430 ioctl(modemfd, TIOCMSET, &modemstat);
432#endif 431#endif
433 432
434 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs 433 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs
435 434
436 cfsetospeed(&temptty, modemspeed()); 435 cfsetospeed(&temptty, modemspeed());
437 cfsetispeed(&temptty, modemspeed()); 436 cfsetispeed(&temptty, modemspeed());
438 tcsetattr(modemfd, TCSAFLUSH, &temptty); 437 tcsetattr(modemfd, TCSAFLUSH, &temptty);
439#endif 438#endif
440 return true; 439 return true;
441 } else 440 } else
442 return false; 441 return false;
443} 442}
444 443
445 444
446void Modem::escape_to_command_mode() { 445void Modem::escape_to_command_mode() {
447 // Send Properly bracketed escape code to put the modem back into command state. 446 // Send Properly bracketed escape code to put the modem back into command state.
448 // A modem will accept AT commands only when it is in command state. 447 // A modem will accept AT commands only when it is in command state.
449 // When a modem sends the host the CONNECT string, that signals 448 // When a modem sends the host the CONNECT string, that signals
450 // that the modem is now in the connect state (no long accepts AT commands.) 449 // that the modem is now in the connect state (no long accepts AT commands.)
451 // Need to send properly timed escape sequence to put modem in command state. 450 // Need to send properly timed escape sequence to put modem in command state.
452 // Escape codes and guard times are controlled by S2 and S12 values. 451 // Escape codes and guard times are controlled by S2 and S12 values.
453 // 452 //
454 tcflush(modemfd, TCIOFLUSH); 453 tcflush(modemfd, TCIOFLUSH);
455 454
456 // +3 because quiet time must be greater than guard time. 455 // +3 because quiet time must be greater than guard time.
457 usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); 456 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
458 QCString tmp = PPPData::data()->modemEscapeStr().local8Bit(); 457 QCString tmp = _pppdata->modemEscapeStr().local8Bit();
459 write(modemfd, tmp.data(), tmp.length()); 458 write(modemfd, tmp.data(), tmp.length());
460 tcflush(modemfd, TCIOFLUSH); 459 tcflush(modemfd, TCIOFLUSH);
461 usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); 460 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
462 461
463 data_mode = false; 462 data_mode = false;
464} 463}
465 464
466 465
467const QString Modem::modemMessage() { 466const QString Modem::modemMessage() {
468 return errmsg; 467 return errmsg;
469} 468}
470 469
471 470
472QString Modem::parseModemSpeed(const QString &s) { 471QString Modem::parseModemSpeed(const QString &s) {
473 // this is a small (and bad) parser for modem speeds 472 // this is a small (and bad) parser for modem speeds
@@ -565,34 +564,34 @@ QString Modem::parseModemSpeed(const QString &s) {
565 qDebug( "The parsed result is: %s", result.latin1()); 564 qDebug( "The parsed result is: %s", result.latin1());
566 565
567 return result; 566 return result;
568} 567}
569 568
570 569
571// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if 570// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
572// a lock file can't be created ( permission problem ) 571// a lock file can't be created ( permission problem )
573int Modem::lockdevice() { 572int Modem::lockdevice() {
574 int fd; 573 int fd;
575 char newlock[80]=""; // safe 574 char newlock[80]=""; // safe
576 575
577 if(!PPPData::data()->modemLockFile()) { 576 if(!_pppdata->modemLockFile()) {
578 qDebug("The user doesn't want a lockfile."); 577 qDebug("The user doesn't want a lockfile.");
579 return 0; 578 return 0;
580 } 579 }
581 580
582 if (modem_is_locked) 581 if (modem_is_locked)
583 return 1; 582 return 1;
584 583
585 QString lockfile = LOCK_DIR"/LCK.."; 584 QString lockfile = LOCK_DIR"/LCK..";
586 lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ 585 lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/
587 586
588 if(access(QFile::encodeName(lockfile), F_OK) == 0) { 587 if(access(QFile::encodeName(lockfile), F_OK) == 0) {
589// if ((fd = Requester::rq-> 588// if ((fd = Requester::rq->
590if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { 589if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
591 // Mario: it's not necessary to read more than lets say 32 bytes. If 590 // Mario: it's not necessary to read more than lets say 32 bytes. If
592 // file has more than 32 bytes, skip the rest 591 // file has more than 32 bytes, skip the rest
593 char oldlock[33]; // safe 592 char oldlock[33]; // safe
594 int sz = read(fd, &oldlock, 32); 593 int sz = read(fd, &oldlock, 32);
595 close (fd); 594 close (fd);
596 if (sz <= 0) 595 if (sz <= 0)
597 return 1; 596 return 1;
598 oldlock[sz] = '\0'; 597 oldlock[sz] = '\0';
@@ -605,25 +604,25 @@ if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
605 // found a pid in lockfile ? 604 // found a pid in lockfile ?
606 if (match < 1 || oldpid <= 0) 605 if (match < 1 || oldpid <= 0)
607 return 1; 606 return 1;
608 607
609 // check if process exists 608 // check if process exists
610 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) 609 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
611 return 1; 610 return 1;
612 611
613 qDebug( "lockfile is stale" ); 612 qDebug( "lockfile is stale" );
614 } 613 }
615 } 614 }
616 615
617 fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); 616 fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
618 if(fd >= 0) { 617 if(fd >= 0) {
619 sprintf(newlock,"%010d\n", getpid()); 618 sprintf(newlock,"%010d\n", getpid());
620 qDebug("Locking Device: %s", newlock); 619 qDebug("Locking Device: %s", newlock);
621 620
622 write(fd, newlock, strlen(newlock)); 621 write(fd, newlock, strlen(newlock));
623 close(fd); 622 close(fd);
624 modem_is_locked=true; 623 modem_is_locked=true;
625 624
626 return 0; 625 return 0;
627 } 626 }
628 627
629 return -1; 628 return -1;
@@ -979,33 +978,33 @@ void Modem::parseargs(char* buf, char** args) {
979 while ((*buf != '\0') && (*buf != quotes)) 978 while ((*buf != '\0') && (*buf != quotes))
980 buf++; 979 buf++;
981 *buf++ = '\0'; 980 *buf++ = '\0';
982 } 981 }
983 } 982 }
984 983
985 *args = 0L; 984 *args = 0L;
986} 985}
987 986
988bool Modem::execPPPDaemon(const QString & arguments) 987bool Modem::execPPPDaemon(const QString & arguments)
989{ 988{
990 if(execpppd(arguments)==0) { 989 if(execpppd(arguments)==0) {
991 PPPData::data()->setpppdRunning(true); 990 _pppdata->setpppdRunning(true);
992 return true; 991 return true;
993 } else 992 } else
994 return false; 993 return false;
995} 994}
996 995
997void Modem::killPPPDaemon() 996void Modem::killPPPDaemon()
998{ 997{
999 PPPData::data()->setpppdRunning(false); 998 _pppdata->setpppdRunning(false);
1000 killpppd(); 999 killpppd();
1001} 1000}
1002 1001
1003int Modem::pppdExitStatus() 1002int Modem::pppdExitStatus()
1004{ 1003{
1005 return _pppdExitStatus; 1004 return _pppdExitStatus;
1006} 1005}
1007 1006
1008int Modem::openResolv(int flags) 1007int Modem::openResolv(int flags)
1009{ 1008{
1010 int fd; 1009 int fd;
1011 if ((fd = open(_PATH_RESCONF, flags)) == -1) { 1010 if ((fd = open(_PATH_RESCONF, flags)) == -1) {
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h
index b494977..103cbeb 100644
--- a/noncore/settings/networksettings/ppp/modem.h
+++ b/noncore/settings/networksettings/ppp/modem.h
@@ -26,33 +26,33 @@
26 26
27#ifndef _MODEM_H_ 27#ifndef _MODEM_H_
28#define _MODEM_H_ 28#define _MODEM_H_
29 29
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33#include <termios.h> 33#include <termios.h>
34#include <unistd.h> 34#include <unistd.h>
35 35
36#include <qsocketnotifier.h> 36#include <qsocketnotifier.h>
37 37
38//#include <config.h> 38class PPPData;
39 39
40void alarm_handler(int); 40void alarm_handler(int);
41const char *pppdPath(); 41const char *pppdPath();
42 42
43class Modem : public QObject { 43class Modem : public QObject {
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 Modem(); 46 Modem(PPPData*);
47 ~Modem(); 47 ~Modem();
48 48
49 const QString getDevice() {return device;}; 49 const QString getDevice() {return device;};
50 void setDevice(const QString dev) {device = dev;}; 50 void setDevice(const QString dev) {device = dev;};
51 51
52 bool opentty(); 52 bool opentty();
53 bool closetty(); 53 bool closetty();
54 bool hangup(); 54 bool hangup();
55 bool writeChar(unsigned char); 55 bool writeChar(unsigned char);
56 bool writeLine(const char *); 56 bool writeLine(const char *);
57 bool dataMode() const { return data_mode; } 57 bool dataMode() const { return data_mode; }
58 void setDataMode(bool set) { data_mode = set; } 58 void setDataMode(bool set) { data_mode = set; }
@@ -67,25 +67,25 @@ public:
67 void unlockdevice(); 67 void unlockdevice();
68 68
69 bool setSecret(int,const char*,const char*); 69 bool setSecret(int,const char*,const char*);
70 bool removeSecret(int); 70 bool removeSecret(int);
71 void killPPPDaemon(); 71 void killPPPDaemon();
72 int pppdExitStatus(); 72 int pppdExitStatus();
73 bool execPPPDaemon(const QString & arguments); 73 bool execPPPDaemon(const QString & arguments);
74 int openResolv(int flags); 74 int openResolv(int flags);
75 bool setHostname(const QString & name); 75 bool setHostname(const QString & name);
76 76
77public: 77public:
78 enum Auth { PAP = 1, CHAP }; 78 enum Auth { PAP = 1, CHAP };
79 static Modem *modem; 79 // static Modem *modem;
80 int lastStatus; 80 int lastStatus;
81 81
82signals: 82signals:
83 void charWaiting(unsigned char); 83 void charWaiting(unsigned char);
84 84
85private slots: 85private slots:
86 void startNotifier(); 86 void startNotifier();
87 void stopNotifier(); 87 void stopNotifier();
88 void readtty(int); 88 void readtty(int);
89 89
90private: 90private:
91 enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; 91 enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
@@ -103,17 +103,18 @@ private:
103private: 103private:
104 QString device; 104 QString device;
105 QString lockfile; 105 QString lockfile;
106 int modemfd; 106 int modemfd;
107 int pppdPid; 107 int pppdPid;
108 int _pppdExitStatus; 108 int _pppdExitStatus;
109 QSocketNotifier *sn; 109 QSocketNotifier *sn;
110 bool data_mode; 110 bool data_mode;
111 QString errmsg; 111 QString errmsg;
112 struct termios initial_tty; 112 struct termios initial_tty;
113 struct termios tty; 113 struct termios tty;
114 bool modem_is_locked; 114 bool modem_is_locked;
115 PPPData *_pppdata;
115}; 116};
116 117
117#endif 118#endif
118 119
119 120
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
index 65032e8..1d9db6e 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.cpp
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -31,26 +31,26 @@
31//#include <kapplication.h> // for getMiniIcon() 31//#include <kapplication.h> // for getMiniIcon()
32//#include <klocale.h> 32//#include <klocale.h>
33#define i18n QObject::tr 33#define i18n QObject::tr
34#include "modemcmds.h" 34#include "modemcmds.h"
35#include "pppdata.h" 35#include "pppdata.h"
36//#include <kwin.h> 36//#include <kwin.h>
37 37
38#define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); 38#define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE);
39 39
40// a little trick to make the label look like a disabled lineedit 40// a little trick to make the label look like a disabled lineedit
41#define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); 41#define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2);
42 42
43ModemCommands::ModemCommands(QWidget *parent, const char *name) 43ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name)
44 : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel) 44 : QDialog(parent, name, true ), _pppdata(pd)
45{ 45{
46 setCaption(i18n("Edit Modem Commands")); 46 setCaption(i18n("Edit Modem Commands"));
47 47
48 const int GRIDROWS = 22; 48 const int GRIDROWS = 22;
49 int row = 0; 49 int row = 0;
50 50
51 // toplevel layout 51 // toplevel layout
52 QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); 52 QVBoxLayout *tl = new QVBoxLayout(this, 10, 4);
53 53
54 // add grid + frame 54 // add grid + frame
55 QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); 55 QGridLayout *l1 = new QGridLayout(GRIDROWS, 4);
56 tl->addLayout(l1); 56 tl->addLayout(l1);
@@ -231,88 +231,88 @@ ModemCommands::ModemCommands(QWidget *parent, const char *name)
231 l6->addWidget(volume_off); 231 l6->addWidget(volume_off);
232 l6->addWidget(volume_medium); 232 l6->addWidget(volume_medium);
233 l6->addWidget(volume_high); 233 l6->addWidget(volume_high);
234 234
235 initstr[0]->setFocus(); 235 initstr[0]->setFocus();
236 236
237 l1->addColSpacing(0, 10); 237 l1->addColSpacing(0, 10);
238 l1->addColSpacing(3, 10); 238 l1->addColSpacing(3, 10);
239 l1->addRowSpacing(0, 5); 239 l1->addRowSpacing(0, 5);
240 l1->addRowSpacing(GRIDROWS, 5); 240 l1->addRowSpacing(GRIDROWS, 5);
241 241
242 //set stuff from gpppdata 242 //set stuff from gpppdata
243 preinitslider->setValue(PPPData::data()->modemPreInitDelay()); 243 preinitslider->setValue(_pppdata->modemPreInitDelay());
244 lpreinitslider->setNum(PPPData::data()->modemPreInitDelay()); 244 lpreinitslider->setNum(_pppdata->modemPreInitDelay());
245 for(int i = 0; i < PPPData::NumInitStrings; i++) 245 for(int i = 0; i < PPPData::NumInitStrings; i++)
246 initstr[i]->setText(PPPData::data()->modemInitStr(i)); 246 initstr[i]->setText(_pppdata->modemInitStr(i));
247 initslider->setValue(PPPData::data()->modemInitDelay()); 247 initslider->setValue(_pppdata->modemInitDelay());
248 linitslider->setNum(PPPData::data()->modemInitDelay()); 248 linitslider->setNum(_pppdata->modemInitDelay());
249 initresp->setText(PPPData::data()->modemInitResp()); 249 initresp->setText(_pppdata->modemInitResp());
250 250
251 durationslider->setValue(PPPData::data()->modemToneDuration()); 251 durationslider->setValue(_pppdata->modemToneDuration());
252 ldurationslider->setNum(PPPData::data()->modemToneDuration()); 252 ldurationslider->setNum(_pppdata->modemToneDuration());
253 253
254 nodetectdialtone->setText(PPPData::data()->modemNoDialToneDetectionStr()); 254 nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr());
255 dialstr->setText(PPPData::data()->modemDialStr()); 255 dialstr->setText(_pppdata->modemDialStr());
256 connectresp->setText(PPPData::data()->modemConnectResp()); 256 connectresp->setText(_pppdata->modemConnectResp());
257 busyresp->setText(PPPData::data()->modemBusyResp()); 257 busyresp->setText(_pppdata->modemBusyResp());
258 nocarrierresp->setText(PPPData::data()->modemNoCarrierResp()); 258 nocarrierresp->setText(_pppdata->modemNoCarrierResp());
259 nodialtoneresp->setText(PPPData::data()->modemNoDialtoneResp()); 259 nodialtoneresp->setText(_pppdata->modemNoDialtoneResp());
260 260
261 escapestr->setText(PPPData::data()->modemEscapeStr()); 261 escapestr->setText(_pppdata->modemEscapeStr());
262 escaperesp->setText(PPPData::data()->modemEscapeResp()); 262 escaperesp->setText(_pppdata->modemEscapeResp());
263 263
264 hangupstr->setText(PPPData::data()->modemHangupStr()); 264 hangupstr->setText(_pppdata->modemHangupStr());
265 hangupresp->setText(PPPData::data()->modemHangupResp()); 265 hangupresp->setText(_pppdata->modemHangupResp());
266 266
267 answerstr->setText(PPPData::data()->modemAnswerStr()); 267 answerstr->setText(_pppdata->modemAnswerStr());
268 ringresp->setText(PPPData::data()->modemRingResp()); 268 ringresp->setText(_pppdata->modemRingResp());
269 answerresp->setText(PPPData::data()->modemAnswerResp()); 269 answerresp->setText(_pppdata->modemAnswerResp());
270 270
271 slider->setValue(PPPData::data()->modemEscapeGuardTime()); 271 slider->setValue(_pppdata->modemEscapeGuardTime());
272 lslider->setNum(PPPData::data()->modemEscapeGuardTime()); 272 lslider->setNum(_pppdata->modemEscapeGuardTime());
273 273
274 volume_off->setText(PPPData::data()->volumeOff()); 274 volume_off->setText(_pppdata->volumeOff());
275 volume_medium->setText(PPPData::data()->volumeMedium()); 275 volume_medium->setText(_pppdata->volumeMedium());
276 volume_high->setText(PPPData::data()->volumeHigh()); 276 volume_high->setText(_pppdata->volumeHigh());
277} 277}
278 278
279 279
280void ModemCommands::slotOk() { 280void ModemCommands::slotOk() {
281 PPPData::data()->setModemPreInitDelay(lpreinitslider->text().toInt()); 281 _pppdata->setModemPreInitDelay(lpreinitslider->text().toInt());
282 for(int i = 0; i < PPPData::NumInitStrings; i++) 282 for(int i = 0; i < PPPData::NumInitStrings; i++)
283 PPPData::data()->setModemInitStr(i, initstr[i]->text()); 283 _pppdata->setModemInitStr(i, initstr[i]->text());
284 PPPData::data()->setModemInitResp(initresp->text()); 284 _pppdata->setModemInitResp(initresp->text());
285 PPPData::data()->setModemInitDelay(linitslider->text().toInt()); 285 _pppdata->setModemInitDelay(linitslider->text().toInt());
286 286
287 PPPData::data()->setModemToneDuration(ldurationslider->text().toInt()); 287 _pppdata->setModemToneDuration(ldurationslider->text().toInt());
288 PPPData::data()->setModemNoDialToneDetectionStr(nodetectdialtone->text()); 288 _pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text());
289 PPPData::data()->setModemDialStr(dialstr->text()); 289 _pppdata->setModemDialStr(dialstr->text());
290 PPPData::data()->setModemConnectResp(connectresp->text()); 290 _pppdata->setModemConnectResp(connectresp->text());
291 PPPData::data()->setModemBusyResp(busyresp->text()); 291 _pppdata->setModemBusyResp(busyresp->text());
292 PPPData::data()->setModemNoCarrierResp(nocarrierresp->text()); 292 _pppdata->setModemNoCarrierResp(nocarrierresp->text());
293 PPPData::data()->setModemNoDialtoneResp(nodialtoneresp->text()); 293 _pppdata->setModemNoDialtoneResp(nodialtoneresp->text());
294 294
295 PPPData::data()->setModemEscapeStr(escapestr->text()); 295 _pppdata->setModemEscapeStr(escapestr->text());
296 PPPData::data()->setModemEscapeResp(escaperesp->text()); 296 _pppdata->setModemEscapeResp(escaperesp->text());
297 PPPData::data()->setModemEscapeGuardTime(lslider->text().toInt()); 297 _pppdata->setModemEscapeGuardTime(lslider->text().toInt());
298 PPPData::data()->setModemHangupStr(hangupstr->text()); 298 _pppdata->setModemHangupStr(hangupstr->text());
299 PPPData::data()->setModemHangupResp(hangupresp->text()); 299 _pppdata->setModemHangupResp(hangupresp->text());
300 300
301 PPPData::data()->setModemAnswerStr(answerstr->text()); 301 _pppdata->setModemAnswerStr(answerstr->text());
302 PPPData::data()->setModemRingResp(ringresp->text()); 302 _pppdata->setModemRingResp(ringresp->text());
303 PPPData::data()->setModemAnswerResp(answerresp->text()); 303 _pppdata->setModemAnswerResp(answerresp->text());
304 304
305 PPPData::data()->setVolumeHigh(volume_high->text()); 305 _pppdata->setVolumeHigh(volume_high->text());
306 PPPData::data()->setVolumeMedium(volume_medium->text()); 306 _pppdata->setVolumeMedium(volume_medium->text());
307 PPPData::data()->setVolumeOff(volume_off->text()); 307 _pppdata->setVolumeOff(volume_off->text());
308 308
309 PPPData::data()->save(); 309 _pppdata->save();
310 accept(); 310 accept();
311} 311}
312 312
313 313
314void ModemCommands::slotCancel() { 314void ModemCommands::slotCancel() {
315 reject(); 315 reject();
316} 316}
317 317
318//#include "modemcmds.moc" 318//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h
index 9d078ec..ef69fec 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.h
+++ b/noncore/settings/networksettings/ppp/modemcmds.h
@@ -35,32 +35,33 @@
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include "pppdata.h" 39#include "pppdata.h"
40 40
41class ModemCommands : public QDialog { 41class ModemCommands : public QDialog {
42 42
43Q_OBJECT 43Q_OBJECT
44 44
45public: 45public:
46 46
47 ModemCommands(QWidget *parent=0, const char *name=0); 47 ModemCommands(PPPData*, QWidget *parent=0, const char *name=0);
48 ~ModemCommands() {} 48 ~ModemCommands() {}
49 49
50private slots: 50private slots:
51 void slotCancel(); 51 void slotCancel();
52 void slotOk(); 52 void slotOk();
53 53
54private: 54private:
55 PPPData *_pppdata;
55 56
56 QGroupBox *box; 57 QGroupBox *box;
57 58
58 QLineEdit *initstr[int(PPPData::NumInitStrings)]; 59 QLineEdit *initstr[int(PPPData::NumInitStrings)];
59 60
60 QLineEdit *initresp; 61 QLineEdit *initresp;
61 QLabel *label2; 62 QLabel *label2;
62 63
63 QLabel *lpreinitslider; 64 QLabel *lpreinitslider;
64 QLabel *lpreinit; 65 QLabel *lpreinit;
65 66
66 QLabel *linitslider; 67 QLabel *linitslider;
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index 4dbbcf5..0bec186 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -28,26 +28,27 @@
28#include <qregexp.h> 28#include <qregexp.h>
29#include <qlayout.h> 29#include <qlayout.h>
30// #include <kwin.h> 30// #include <kwin.h>
31// #include <kmessagebox.h> 31// #include <kmessagebox.h>
32// #include <kapplication.h> 32// #include <kapplication.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include "modeminfo.h" 35#include "modeminfo.h"
36#include "modem.h" 36#include "modem.h"
37//#include <klocale.h> 37//#include <klocale.h>
38#define i18n QObject::tr 38#define i18n QObject::tr
39 39
40ModemTransfer::ModemTransfer(QWidget *parent, const char *name) 40ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
41 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder) 41 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder),
42 _modem(mo)
42{ 43{
43 setCaption(i18n("ATI Query")); 44 setCaption(i18n("ATI Query"));
44// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 45// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
45 46
46 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 47 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
47 48
48 progressBar = new QProgressBar(this, "bar"); 49 progressBar = new QProgressBar(this, "bar");
49 progressBar->setTotalSteps(8); 50 progressBar->setTotalSteps(8);
50 51
51 statusBar = new QLabel(this,"sBar"); 52 statusBar = new QLabel(this,"sBar");
52 statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); 53 statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken);
53 statusBar->setAlignment(AlignCenter); 54 statusBar->setAlignment(AlignCenter);
@@ -88,26 +89,26 @@ ModemTransfer::ModemTransfer(QWidget *parent, const char *name)
88 scripttimer = new QTimer(this); 89 scripttimer = new QTimer(this);
89 connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); 90 connect(scripttimer, SIGNAL(timeout()), SLOT(do_script()));
90 91
91 timeout_timer->start(15000,TRUE); // 15 secs single shot 92 timeout_timer->start(15000,TRUE); // 15 secs single shot
92 QTimer::singleShot(500, this, SLOT(init())); 93 QTimer::singleShot(500, this, SLOT(init()));
93 94
94} 95}
95 96
96 97
97void ModemTransfer::ati_done() { 98void ModemTransfer::ati_done() {
98 scripttimer->stop(); 99 scripttimer->stop();
99 timeout_timer->stop(); 100 timeout_timer->stop();
100 Modem::modem->closetty(); 101 _modem->closetty();
101 Modem::modem->unlockdevice(); 102 _modem->unlockdevice();
102 hide(); 103 hide();
103 104
104 // open the result window 105 // open the result window
105 ModemInfo *mi = new ModemInfo(this); 106 ModemInfo *mi = new ModemInfo(this);
106 for(int i = 0; i < NUM_OF_ATI; i++) 107 for(int i = 0; i < NUM_OF_ATI; i++)
107 mi->setAtiString(i, ati_query_strings[i]); 108 mi->setAtiString(i, ati_query_strings[i]);
108 mi->showMaximized(); 109 mi->showMaximized();
109 mi->exec(); 110 mi->exec();
110 delete mi; 111 delete mi;
111 112
112 accept(); 113 accept();
113} 114}
@@ -117,89 +118,89 @@ void ModemTransfer::time_out_slot() {
117 timeout_timer->stop(); 118 timeout_timer->stop();
118 scripttimer->stop(); 119 scripttimer->stop();
119 120
120 QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); 121 QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out."));
121 reject(); 122 reject();
122} 123}
123 124
124 125
125void ModemTransfer::init() { 126void ModemTransfer::init() {
126 127
127 qApp->processEvents(); 128 qApp->processEvents();
128 129
129 int lock = Modem::modem->lockdevice(); 130 int lock = _modem->lockdevice();
130 if (lock == 1) { 131 if (lock == 1) {
131 132
132 statusBar->setText(i18n("Modem device is locked.")); 133 statusBar->setText(i18n("Modem device is locked."));
133 return; 134 return;
134 } 135 }
135 136
136 if (lock == -1) { 137 if (lock == -1) {
137 138
138 statusBar->setText(i18n("Unable to create modem lock file.")); 139 statusBar->setText(i18n("Unable to create modem lock file."));
139 return; 140 return;
140 } 141 }
141 142
142 143
143 if(Modem::modem->opentty()) { 144 if(_modem->opentty()) {
144 if(Modem::modem->hangup()) { 145 if(_modem->hangup()) {
145 usleep(100000); // wait 0.1 secs 146 usleep(100000); // wait 0.1 secs
146 Modem::modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... 147 _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
147 148
148 statusBar->setText(i18n("Modem Ready")); 149 statusBar->setText(i18n("Modem Ready"));
149 qApp->processEvents(); 150 qApp->processEvents();
150 usleep(100000); // wait 0.1 secs 151 usleep(100000); // wait 0.1 secs
151 qApp->processEvents(); 152 qApp->processEvents();
152 scripttimer->start(1000); // this one does the ati query 153 scripttimer->start(1000); // this one does the ati query
153 154
154 // clear modem buffer 155 // clear modem buffer
155 Modem::modem->flush(); 156 _modem->flush();
156 157
157 Modem::modem->notify(this, SLOT(readChar(unsigned char))); 158 _modem->notify(this, SLOT(readChar(unsigned char)));
158 return; 159 return;
159 } 160 }
160 } 161 }
161 162
162 // opentty() or hangup() failed 163 // opentty() or hangup() failed
163 statusBar->setText(Modem::modem->modemMessage()); 164 statusBar->setText(_modem->modemMessage());
164 step = 99; // wait until cancel is pressed 165 step = 99; // wait until cancel is pressed
165 Modem::modem->unlockdevice(); 166 _modem->unlockdevice();
166} 167}
167 168
168 169
169void ModemTransfer::do_script() { 170void ModemTransfer::do_script() {
170 QString msg; 171 QString msg;
171 QString query; 172 QString query;
172 173
173 switch(step) { 174 switch(step) {
174 case 0: 175 case 0:
175 readtty(); 176 readtty();
176 statusBar->setText("ATI..."); 177 statusBar->setText("ATI...");
177 progressBar->setProgress( progressBar->progress() + 1); 178 progressBar->setProgress( progressBar->progress() + 1);
178 Modem::modem->writeLine("ATI\n"); 179 _modem->writeLine("ATI\n");
179 break; 180 break;
180 181
181 case 1: 182 case 1:
182 case 2: 183 case 2:
183 case 3: 184 case 3:
184 case 4: 185 case 4:
185 case 5: 186 case 5:
186 case 6: 187 case 6:
187 case 7: 188 case 7:
188 readtty(); 189 readtty();
189 msg.sprintf("ATI %d ...", step); 190 msg.sprintf("ATI %d ...", step);
190 query.sprintf("ATI%d\n", step); 191 query.sprintf("ATI%d\n", step);
191 statusBar->setText(msg); 192 statusBar->setText(msg);
192 progressBar->setProgress( progressBar->progress() + 1); 193 progressBar->setProgress( progressBar->progress() + 1);
193 Modem::modem->writeLine(query.local8Bit()); 194 _modem->writeLine(query.local8Bit());
194 break; 195 break;
195 196
196 default: 197 default:
197 readtty(); 198 readtty();
198 ati_done(); 199 ati_done();
199 } 200 }
200 step++; 201 step++;
201} 202}
202 203
203void ModemTransfer::readChar(unsigned char c) { 204void ModemTransfer::readChar(unsigned char c) {
204 if(readbuffer.length() < 255) 205 if(readbuffer.length() < 255)
205 readbuffer += c; 206 readbuffer += c;
@@ -214,34 +215,34 @@ void ModemTransfer::readtty() {
214 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white 215 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white
215 // space 216 // space
216 217
217 if(step <= NUM_OF_ATI) 218 if(step <= NUM_OF_ATI)
218 ati_query_strings[step-1] = readbuffer.copy(); 219 ati_query_strings[step-1] = readbuffer.copy();
219 220
220 readbuffer = ""; 221 readbuffer = "";
221} 222}
222 223
223 224
224void ModemTransfer::cancelbutton() { 225void ModemTransfer::cancelbutton() {
225 scripttimer->stop(); 226 scripttimer->stop();
226 Modem::modem->stop(); 227 _modem->stop();
227 timeout_timer->stop(); 228 timeout_timer->stop();
228 229
229 statusBar->setText(i18n("One moment please...")); 230 statusBar->setText(i18n("One moment please..."));
230 qApp->processEvents(); 231 qApp->processEvents();
231 232
232 Modem::modem->hangup(); 233 _modem->hangup();
233 234
234 Modem::modem->closetty(); 235 _modem->closetty();
235 Modem::modem->unlockdevice(); 236 _modem->unlockdevice();
236 reject(); 237 reject();
237} 238}
238 239
239 240
240void ModemTransfer::closeEvent( QCloseEvent *e ) { 241void ModemTransfer::closeEvent( QCloseEvent *e ) {
241 cancelbutton(); 242 cancelbutton();
242 e->accept(); 243 e->accept();
243} 244}
244 245
245 246
246ModemInfo::ModemInfo(QWidget *parent, const char* name) 247ModemInfo::ModemInfo(QWidget *parent, const char* name)
247 : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) 248 : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder)
diff --git a/noncore/settings/networksettings/ppp/modeminfo.h b/noncore/settings/networksettings/ppp/modeminfo.h
index 7aa2cc0..dfcc841 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.h
+++ b/noncore/settings/networksettings/ppp/modeminfo.h
@@ -28,47 +28,50 @@
28#ifndef _MODEMINFO_H_ 28#ifndef _MODEMINFO_H_
29#define _MODEMINFO_H_ 29#define _MODEMINFO_H_
30 30
31#include <qdialog.h> 31#include <qdialog.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qevent.h> 35#include <qevent.h>
36#include <qtimer.h> 36#include <qtimer.h>
37//#include <kprogress.h> 37//#include <kprogress.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39 39
40class Modem;
41
40const int NUM_OF_ATI = 8; 42const int NUM_OF_ATI = 8;
41 43
42 44
43class ModemTransfer : public QDialog { 45class ModemTransfer : public QDialog {
44 Q_OBJECT 46 Q_OBJECT
45public: 47public:
46 ModemTransfer(QWidget *parent=0, const char *name=0); 48 ModemTransfer(Modem*, QWidget *parent=0, const char *name=0);
47 49
48public slots: 50public slots:
49 void init(); 51 void init();
50 void readtty(); 52 void readtty();
51 void do_script(); 53 void do_script();
52 void time_out_slot(); 54 void time_out_slot();
53 void cancelbutton(); 55 void cancelbutton();
54 void readChar(unsigned char); 56 void readChar(unsigned char);
55 57
56private: 58private:
57 void ati_done(); 59 void ati_done();
58 60
59protected: 61protected:
60 void closeEvent(QCloseEvent *e); 62 void closeEvent(QCloseEvent *e);
61 63
62private: 64private:
65 Modem *_modem;
63 int step; 66 int step;
64 QString readbuffer; 67 QString readbuffer;
65 68
66 QPushButton *cancel; 69 QPushButton *cancel;
67 QProgressBar *progressBar; 70 QProgressBar *progressBar;
68 QLabel *statusBar; 71 QLabel *statusBar;
69 72
70 QTimer *timeout_timer; 73 QTimer *timeout_timer;
71 QTimer *scripttimer; 74 QTimer *scripttimer;
72 QString ati_query_strings[NUM_OF_ATI]; 75 QString ati_query_strings[NUM_OF_ATI];
73}; 76};
74 77
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index ac438dd..483aa58 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,20 +1,20 @@
1#TEMPLATE = app 1#TEMPLATE = app
2# 2#
3TEMPLATE = lib 3TEMPLATE = lib
4#CONFIG += qt warn_on release 4#CONFIG += qt warn_on release
5 CONFIG += qt warn_on debug 5 CONFIG += qt warn_on debug
6DESTDIR = $(OPIEDIR)/plugins/networksettings 6DESTDIR = $(OPIEDIR)/plugins/networksettings
7 HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h 7 HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h
8# 8# kpppwidget.h
9 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp 9 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp
10# 10# kpppwidget.cpp
11 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 11 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
12 DEPENDPATH+= $(OPIEDIR)/include 12 DEPENDPATH+= $(OPIEDIR)/include
13LIBS += -lqpe -L../interfaces/ -linterfaces 13LIBS += -lqpe -L../interfaces/ -linterfaces
14 INTERFACES= 14 INTERFACES=
15 TARGET = pppplugin 15 TARGET = pppplugin
16 VERSION = 1.0.0 16 VERSION = 1.0.0
17 17
18 18
19 19
20include ( $(OPIEDIR)/include.pro ) 20include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index 4c5f7aa..63f9335 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,77 +1,72 @@
1 1
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4#include <qtabwidget.h> 4#include <qtabwidget.h>
5 5
6#include "accounts.h" 6#include "accounts.h"
7#include "general.h" 7#include "general.h"
8#include "interface.h" 8#include "interfaceppp.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( InterfacePPP* 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() ))
28 PPPData::data()->setModemDevice("/dev/modem");
29 qDebug("PPPConfigWidget::PPPConfigWidget"); 27 qDebug("PPPConfigWidget::PPPConfigWidget");
30 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); 28 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
31 if (!PPPData::data()->setAccount( interface->getHardwareName() ))
32 PPPData::data()->setAccount( 0 );
33 29
34 qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); 30 qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
35 qDebug(" PPPData::data()->currentAccountID() >%i<",PPPData::data()->currentAccountID()); 31 qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID());
36 (void)new Modem;
37 32
38 QVBoxLayout *layout = new QVBoxLayout( this ); 33 QVBoxLayout *layout = new QVBoxLayout( this );
39 layout->setSpacing( 0 ); 34 layout->setSpacing( 0 );
40 layout->setMargin( 1 ); 35 layout->setMargin( 1 );
41 tabWindow = new QTabWidget( this, "tabWidget" ); 36 tabWindow = new QTabWidget( this, "tabWidget" );
42 layout->addWidget( tabWindow ); 37 layout->addWidget( tabWindow );
43 38
44 accounts = new AccountWidget( tabWindow, "accounts" ); 39 accounts = new AccountWidget( interface->data(), tabWindow, "accounts" );
45 tabWindow->addTab( accounts, tr("&Accounts") ); 40 tabWindow->addTab( accounts, tr("&Accounts") );
46 modem1 = new ModemWidget( tabWindow, "modem1" ); 41 modem1 = new ModemWidget( interface, tabWindow, "modem1" );
47 tabWindow->addTab( modem1, tr("&Device") ); 42 tabWindow->addTab( modem1, tr("&Device") );
48 modem2 = new ModemWidget2( tabWindow, "modem2" ); 43 modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
49 tabWindow->addTab( modem2, tr("&Modem") ); 44 tabWindow->addTab( modem2, tr("&Modem") );
50// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); 45// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
51// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); 46// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
52 47
53} 48}
54 49
55 50
56PPPConfigWidget::~PPPConfigWidget() 51PPPConfigWidget::~PPPConfigWidget()
57{ 52{
58 53
59} 54}
60 55
61void PPPConfigWidget::accept() 56void PPPConfigWidget::accept()
62{ 57{
63 qDebug("PPPConfigWidget::accept"); 58 qDebug("PPPConfigWidget::accept");
64 qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); 59 qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
65 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); 60 qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
66 interface->setInterfaceName( PPPData::data()->modemDevice() ); 61 interface->setInterfaceName( interface->data()->modemDevice() );
67 interface->setHardwareName( PPPData::data()->accname() ); 62 interface->setHardwareName( interface->data()->accname() );
68 PPPData::data()->save(); 63 interface->data()->save();
69 QDialog::accept(); 64 QDialog::accept();
70} 65}
71 66
72 67
73void PPPConfigWidget::reject() 68void PPPConfigWidget::reject()
74{ 69{
75 PPPData::data()->cancel(); 70 interface->data()->cancel();
76 QDialog::reject(); 71 QDialog::reject();
77} 72}
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
index b324b6d..9bab6fe 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.h
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -1,36 +1,37 @@
1#ifndef _PPPCONFIG_H_ 1#ifndef _PPPCONFIG_H_
2#define _PPPCONFIG_H_ 2#define _PPPCONFIG_H_
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5 5
6class QTabWidget; 6class QTabWidget;
7class Interface; 7//class Interface;
8class InterfacePPP;
8class AccountWidget; 9class AccountWidget;
9class GeneralWidget; 10class GeneralWidget;
10class ModemWidget; 11class ModemWidget;
11class ModemWidget2; 12class ModemWidget2;
12 13
13class PPPConfigWidget : public QDialog { 14class PPPConfigWidget : public QDialog {
14 Q_OBJECT 15 Q_OBJECT
15public: 16public:
16 17
17 PPPConfigWidget( Interface*, QWidget *parent=0, const char *name=0, 18 PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0,
18 bool modal = false, WFlags fl = 0 ); 19 bool modal = false, WFlags fl = 0 );
19 ~PPPConfigWidget(); 20 ~PPPConfigWidget();
20 21
21 22
22protected slots: 23protected slots:
23 virtual void accept(); 24 virtual void accept();
24 virtual void reject(); 25 virtual void reject();
25 26
26 private: 27 private:
27 Interface *interface; 28 InterfacePPP *interface;
28 QTabWidget *tabWindow; 29 QTabWidget *tabWindow;
29 AccountWidget *accounts; 30 AccountWidget *accounts;
30 GeneralWidget *general; 31 GeneralWidget *general;
31 ModemWidget *modem1; 32 ModemWidget *modem1;
32 ModemWidget2 *modem2; 33 ModemWidget2 *modem2;
33}; 34};
34 35
35 36
36#endif 37#endif
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 4039939..d1143cf 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -25,26 +25,26 @@
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#include <qlayout.h> 28#include <qlayout.h>
29#include <qbuttongroup.h> 29#include <qbuttongroup.h>
30//#include <kwin.h> 30//#include <kwin.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include "pppdargs.h" 32#include "pppdargs.h"
33#include "pppdata.h" 33#include "pppdata.h"
34//#include <klocale.h> 34//#include <klocale.h>
35#define i18n QObject::tr 35#define i18n QObject::tr
36 36
37PPPdArguments::PPPdArguments(QWidget *parent, const char *name) 37PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name)
38 : QDialog(parent, name, TRUE) 38 : QDialog(parent, name, TRUE), _pppdata(pd)
39{ 39{
40 setCaption(i18n("Customize pppd Arguments")); 40 setCaption(i18n("Customize pppd Arguments"));
41// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 41// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
42 QVBoxLayout *l = new QVBoxLayout(this, 10, 10); 42 QVBoxLayout *l = new QVBoxLayout(this, 10, 10);
43 QHBoxLayout *tl = new QHBoxLayout(10); 43 QHBoxLayout *tl = new QHBoxLayout(10);
44 l->addLayout(tl); 44 l->addLayout(tl);
45 QVBoxLayout *l1 = new QVBoxLayout(); 45 QVBoxLayout *l1 = new QVBoxLayout();
46 QVBoxLayout *l2 = new QVBoxLayout(); 46 QVBoxLayout *l2 = new QVBoxLayout();
47 tl->addLayout(l1, 1); 47 tl->addLayout(l1, 1);
48 tl->addLayout(l2, 0); 48 tl->addLayout(l2, 0);
49 49
50 QHBoxLayout *l11 = new QHBoxLayout(10); 50 QHBoxLayout *l11 = new QHBoxLayout(10);
@@ -112,50 +112,50 @@ void PPPdArguments::addbutton() {
112} 112}
113 113
114 114
115void PPPdArguments::removebutton() { 115void PPPdArguments::removebutton() {
116 if(arguments->currentItem() >= 0) 116 if(arguments->currentItem() >= 0)
117 arguments->removeItem(arguments->currentItem()); 117 arguments->removeItem(arguments->currentItem());
118} 118}
119 119
120 120
121void PPPdArguments::defaultsbutton() { 121void PPPdArguments::defaultsbutton() {
122 // all of this is a hack 122 // all of this is a hack
123 // save current list 123 // save current list
124 QStringList arglist(PPPData::data()->pppdArgument()); 124 QStringList arglist(_pppdata->pppdArgument());
125 125
126 // get defaults 126 // get defaults
127 PPPData::data()->setpppdArgumentDefaults(); 127 _pppdata->setpppdArgumentDefaults();
128 init(); 128 init();
129 129
130 // restore old list 130 // restore old list
131 PPPData::data()->setpppdArgument(arglist); 131 _pppdata->setpppdArgument(arglist);
132} 132}
133 133
134 134
135void PPPdArguments::closebutton() { 135void PPPdArguments::closebutton() {
136 QStringList arglist; 136 QStringList arglist;
137 for(uint i=0; i < arguments->count(); i++) 137 for(uint i=0; i < arguments->count(); i++)
138 arglist.append(arguments->text(i)); 138 arglist.append(arguments->text(i));
139 PPPData::data()->setpppdArgument(arglist); 139 _pppdata->setpppdArgument(arglist);
140 140
141 done(0); 141 done(0);
142} 142}
143 143
144 144
145void PPPdArguments::init() { 145void PPPdArguments::init() {
146 while(arguments->count()) 146 while(arguments->count())
147 arguments->removeItem(0); 147 arguments->removeItem(0);
148 148
149 QStringList &arglist = PPPData::data()->pppdArgument(); 149 QStringList &arglist = _pppdata->pppdArgument();
150 for ( QStringList::Iterator it = arglist.begin(); 150 for ( QStringList::Iterator it = arglist.begin();
151 it != arglist.end(); 151 it != arglist.end();
152 ++it ) 152 ++it )
153 arguments->insertItem(*it); 153 arguments->insertItem(*it);
154} 154}
155 155
156 156
157void PPPdArguments::textChanged(const QString &s) { 157void PPPdArguments::textChanged(const QString &s) {
158 add->setEnabled(s.length() > 0); 158 add->setEnabled(s.length() > 0);
159} 159}
160 160
161 161
diff --git a/noncore/settings/networksettings/ppp/pppdargs.h b/noncore/settings/networksettings/ppp/pppdargs.h
index c1cd28d..75f0c9d 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.h
+++ b/noncore/settings/networksettings/ppp/pppdargs.h
@@ -24,53 +24,55 @@
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 _PPPDARGS_H_ 28#ifndef _PPPDARGS_H_
29#define _PPPDARGS_H_ 29#define _PPPDARGS_H_
30 30
31#include <qdialog.h> 31#include <qdialog.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qlistbox.h> 34#include <qlistbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36class PPPData;
36 37
37class PPPdArguments : public QDialog { 38class PPPdArguments : public QDialog {
38Q_OBJECT 39Q_OBJECT
39public: 40public:
40 PPPdArguments(QWidget *parent=0, const char *name=0); 41 PPPdArguments(PPPData*,QWidget *parent=0, const char *name=0);
41 ~PPPdArguments() {} 42 ~PPPdArguments() {}
42 43
43private slots: 44private slots:
44 void addbutton(); 45 void addbutton();
45 void removebutton(); 46 void removebutton();
46 void defaultsbutton(); 47 void defaultsbutton();
47 void closebutton(); 48 void closebutton();
48 void textChanged(const QString &); 49 void textChanged(const QString &);
49 void itemSelected(int); 50 void itemSelected(int);
50 51
51private: 52private:
52 void init(); 53 void init();
53 54
54 QLabel *argument_label; 55 QLabel *argument_label;
55 56
56 QLineEdit *argument; 57 QLineEdit *argument;
57 58
58 QPushButton *add; 59 QPushButton *add;
59 QPushButton *remove; 60 QPushButton *remove;
60 QPushButton *defaults; 61 QPushButton *defaults;
61 62
62 QListBox *arguments; 63 QListBox *arguments;
63 64
64 QPushButton *closebtn; 65 QPushButton *closebtn;
66 PPPData *_pppdata;
65}; 67};
66#endif 68#endif
67 69
68 70
69 71
70 72
71 73
72 74
73 75
74 76
75 77
76 78
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 3f1675c..59d68c9 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -29,178 +29,197 @@
29#include "devices.h" 29#include "devices.h"
30//#include <klocale.h> 30//#include <klocale.h>
31#define i18n QObject::tr 31#define i18n QObject::tr
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
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; 41#define SEPARATOR -sseepp-
42Config *PPPData::config = 0; 42#define SEP QString("%1SEPARATOR%1")
43
44PPPData* PPPData::data()
45{
46 if (!_data){
47 qDebug("PPPData::data() creates new Instance");
48 _data = new PPPData();
49 }
50 if (!_data->config){
51 qDebug("PPPData::data() opens conffile");
52 _data->open();
53 }
54 return _data;
55}
56 43
57PPPData::PPPData() 44PPPData::PPPData()
58 : modemDeviceGroup(-1), 45 : modemDeviceGroup(-1),
59 highcount(-1), // start out with no entries 46 highcount(-1), // start out with no entries
60 caccount(-1), // set the current account index also 47 caccount(-1), // set the current account index also
61 suidprocessid(-1), // process ID of setuid child 48 suidprocessid(-1), // process ID of setuid child
62 pppdisrunning(false), 49 pppdisrunning(false),
63 pppderror(0) 50 pppderror(0)
64{ 51{
65}
66
67
68//
69// open configuration file
70//
71bool PPPData::open() {
72 qDebug("opening configfile NetworkSetupPPP");
73 if (config) return true;
74 config = new Config("NetworkSetupPPP");
75
76 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 52 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
77 53
78 if (highcount > MAX_ACCOUNTS) 54 if (highcount > MAX_ACCOUNTS)
79 highcount = MAX_ACCOUNTS; 55 highcount = MAX_ACCOUNTS;
80 56
81 if(highcount >= 0 && defaultAccount().isEmpty()) { 57 if(highcount >= 0 && defaultAccount().isEmpty()) {
82 setAccountbyIndex(0); 58 setAccountbyIndex(0);
83 setDefaultAccount(accname()); 59 setDefaultAccount(accname());
84 } else if(!setAccount(defaultAccount())) 60 } else if(!setAccount(defaultAccount()))
85 setDefaultAccount(accname()); 61 setDefaultAccount(accname());
86 62
87 // start out with internal debugging disabled 63 // start out with internal debugging disabled
88 // the user is still free to specify `debug' on his own 64 // the user is still free to specify `debug' on his own
89 setPPPDebug(false); 65 setPPPDebug(false);
90 66
91 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); 67 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
92 68
93 return true;
94} 69}
95 70
71Config PPPData::config()
72{
73 return Config("NetworkSetupPPP");
74}
96 75
97// 76//
98// save configuration 77// save configuration
99// 78//
100void PPPData::save() { 79void PPPData::save()
101 80{
102 if (config) { 81 qDebug("PPPData saving data");
103 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); 82 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
104 delete config; 83 QString key;
105 config = 0; 84 QStringList keys;
106 qDebug("worte confi NetworkSetupPPP"); 85 Config cfg = config();
107 } 86 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
108 if (_data){ 87 it != stringEntries.end(); ++it ){
109 delete _data; 88 QString val = it.data();
110 _data = 0; 89 key = it.key();
111 } 90// qDebug("saving %s -> %s", key.latin1(), val.latin1() );
112 91 keys = QStringList::split( "SEPARATOR", key );
92 qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
93 cfg.setGroup(keys[0]);
94 cfg.writeEntry(keys[1], val);
95 }
96 for( QMap<QString,int>::Iterator it = intEntries.begin();
97 it != intEntries.end(); ++it ){
98 int val = it.data();
99 key = it.key();
100// qDebug("saving %s -> %i", key.latin1(), val );
101 keys = QStringList::split( "SEPARATOR", key );
102 qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
103 cfg.setGroup(keys[0]);
104 cfg.writeEntry(keys[1], val);
105 }
106 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
107 it != listEntries.end(); ++it ){
108 QStringList val = it.data();
109 key = it.key();
110 QChar sep = sepEntries[key];
111// qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() );
112 keys = QStringList::split( "SEPARATOR", key );
113 qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() );
114 cfg.setGroup(keys[0]);
115 cfg.writeEntry(keys[1], val, sep);
116 }
113} 117}
114 118
115 119
116// 120//
117// cancel changes 121// cancel changes
118// 122//
119void PPPData::cancel() { 123void PPPData::cancel() {
120 124 stringEntries.clear();
121// if (config) { 125 intEntries.clear();
122// config->rollback(); 126 listEntries.clear();
123// config->reparseConfiguration();
124// }
125
126} 127}
127 128
128
129// // currently differentiates between READWRITE and NONE only
130// int PPPData::access() const {
131
132// return 1;//config->getConfigState();
133// }
134
135
136// functions to read/write date to configuration file 129// functions to read/write date to configuration file
137QString PPPData::readConfig(const QString &group, const QString &key, 130QString PPPData::readConfig(const QString &group, const QString &key,
138 const QString &defvalue = "") 131 const QString &defvalue = "")
139{ 132{
140// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); 133// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
141 if (config) { 134 QString idx = SEP.arg(group).arg(key);
142 config->setGroup(group); 135 if (stringEntries.find(idx) != stringEntries.end())
143 return config->readEntry(key, defvalue); 136 return stringEntries[idx];
144 } else 137 Config cfg = config();
145 return defvalue; 138 cfg.setGroup(group);
139 return cfg.readEntry(key, defvalue);
146} 140}
147 141
148 142
149int PPPData::readNumConfig(const QString &group, const QString &key, 143int PPPData::readNumConfig(const QString &group, const QString &key,
150 int defvalue) { 144 int defvalue)
151 if (config) { 145{
152 config->setGroup(group); 146 QString idx = SEP.arg(group).arg(key);
153 return config->readNumEntry(key, defvalue); 147 if (intEntries.find(idx) != intEntries.end())
154 } else 148 return intEntries[idx];
155 return defvalue; 149 Config cfg = config();
150 cfg.setGroup(group);
151 return cfg.readNumEntry(key, defvalue);
152
153// if (config) {
154// config->setGroup(group);
155// return config->readNumEntry(key, defvalue);
156// } else
157// return defvalue;
156 158
157} 159}
158 160
159 161
160bool PPPData::readListConfig(const QString &group, const QString &key, 162bool PPPData::readListConfig(const QString &group, const QString &key,
161 QStringList &list, char sep) { 163 QStringList &list, char sep) {
162 list.clear(); 164 list.clear();
163 if (config) { 165 QString idx = SEP.arg(group).arg(key);
164 config->setGroup(group); 166 if (listEntries.find(idx) != listEntries.end()){
165 list = config->readListEntry(key, sep); 167 list = listEntries[idx];
166 return true; 168 return true;
167 } else 169 }
168 return false; 170 Config cfg = config();
171 cfg.setGroup(group);
172 list = cfg.readListEntry(key, sep);
173 if (list.count() > 0) return true;
174 return false;
175
176// if (config) {
177// config->setGroup(group);
178// list = config->readListEntry(key, sep);
179// return true;
180// } else
181// return false;
169} 182}
170 183
171 184
172void PPPData::writeConfig(const QString &group, const QString &key, 185void PPPData::writeConfig(const QString &group, const QString &key,
173 const QString &value) { 186 const QString &value) {
174 if (config) { 187 stringEntries.insert( SEP.arg(group).arg(key), value );
175 config->setGroup(group); 188// if (config) {
176 config->writeEntry(key, value); 189// config->setGroup(group);
177 } 190// config->writeEntry(key, value);
191// }
178} 192}
179 193
180 194
181void PPPData::writeConfig(const QString &group, const QString &key, int value) { 195void PPPData::writeConfig(const QString &group, const QString &key, int value)
182 if (config) { 196{
183 config->setGroup(group); 197 intEntries.insert( SEP.arg(group).arg(key), value );
184 config->writeEntry(key, value); 198// if (config) {
185 } 199// config->setGroup(group);
200// config->writeEntry(key, value);
201// }
186} 202}
187 203
188 204
189void PPPData::writeListConfig(const QString &group, const QString &key, 205void PPPData::writeListConfig(const QString &group, const QString &key,
190 QStringList &list, char sep) { 206 QStringList &list, char sep)
191 if (config) { 207{
192 config->setGroup(group); 208 listEntries.insert( SEP.arg(group).arg(key), list );
193 config->writeEntry(key, list, sep); 209 sepEntries.insert( SEP.arg(group).arg(key), sep );
194 } 210// if (config) {
211// config->setGroup(group);
212// config->writeEntry(key, list, sep);
213// }
195} 214}
196 215
197 216
198// 217//
199// functions to set/return general information 218// functions to set/return general information
200// 219//
201QString PPPData::password() const { 220QString PPPData::password() const {
202 return passwd; 221 return passwd;
203} 222}
204 223
205 224
206void PPPData::setPassword(const QString &pw) { 225void PPPData::setPassword(const QString &pw) {
@@ -272,42 +291,42 @@ void PPPData::set_show_log_window(bool set) {
272 291
273 292
274bool PPPData::automatic_redial() { 293bool PPPData::automatic_redial() {
275 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); 294 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
276} 295}
277 296
278 297
279void PPPData::set_automatic_redial(bool set) { 298void PPPData::set_automatic_redial(bool set) {
280 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); 299 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
281} 300}
282 301
283 302
284bool PPPData::get_iconify_on_connect() { 303// bool PPPData::get_iconify_on_connect() {
285 return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); 304// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
286} 305// }
287 306
288 307
289void PPPData::set_iconify_on_connect(bool set) { 308// void PPPData::set_iconify_on_connect(bool set) {
290 writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); 309// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
291} 310// }
292 311
293 312
294bool PPPData::get_dock_into_panel() { 313// bool PPPData::get_dock_into_panel() {
295 return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); 314// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
296} 315// }
297 316
298 317
299void PPPData::set_dock_into_panel(bool set) { 318// void PPPData::set_dock_into_panel(bool set) {
300 writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); 319// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
301} 320// }
302 321
303 322
304QString PPPData::pppdVersion() { 323QString PPPData::pppdVersion() {
305 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); 324 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
306} 325}
307 326
308bool PPPData::pppdVersionMin(int ver, int mod, int patch) { 327bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
309 // check if pppd version fulfills minimum requirement 328 // check if pppd version fulfills minimum requirement
310 return (pppdVer > ver 329 return (pppdVer > ver
311 || (pppdVer == ver && pppdMod > mod) 330 || (pppdVer == ver && pppdMod > mod)
312 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); 331 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
313} 332}
@@ -781,25 +800,25 @@ bool PPPData::deleteAccount(const QString &aname) {
781 if(!setAccount(aname)) 800 if(!setAccount(aname))
782 return false; 801 return false;
783 802
784 deleteAccount(); 803 deleteAccount();
785 804
786 return true; 805 return true;
787} 806}
788 807
789 808
790int PPPData::newaccount() { 809int PPPData::newaccount() {
791 810
792 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); 811 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
793 if(!config) open(); 812// if(!config) open();
794 if (highcount >= MAX_ACCOUNTS) return -1; 813 if (highcount >= MAX_ACCOUNTS) return -1;
795 814
796 highcount++; 815 highcount++;
797 setAccountbyIndex(highcount); 816 setAccountbyIndex(highcount);
798 817
799 setpppdArgumentDefaults(); 818 setpppdArgumentDefaults();
800 qDebug("PPPData::newaccount -> %i",caccount); 819 qDebug("PPPData::newaccount -> %i",caccount);
801 return caccount; 820 return caccount;
802} 821}
803 822
804int PPPData::copyaccount(int i) { 823int PPPData::copyaccount(int i) {
805// FIXME 824// FIXME
@@ -981,32 +1000,32 @@ void PPPData::setAutoname(bool set) {
981 1000
982 1001
983bool PPPData::AcctEnabled() { 1002bool PPPData::AcctEnabled() {
984 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); 1003 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
985} 1004}
986 1005
987 1006
988void PPPData::setAcctEnabled(bool set) { 1007void PPPData::setAcctEnabled(bool set) {
989 writeConfig(cgroup, ACCTENABLED_KEY, (int) set); 1008 writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
990} 1009}
991 1010
992 1011
993int PPPData::VolAcctEnabled() { 1012// int PPPData::VolAcctEnabled() {
994 return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); 1013// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
995} 1014// }
996 1015
997 1016
998void PPPData::setVolAcctEnabled(int set) { 1017// void PPPData::setVolAcctEnabled(int set) {
999 writeConfig(cgroup, VOLACCTENABLED_KEY, set); 1018// writeConfig(cgroup, VOLACCTENABLED_KEY, set);
1000} 1019// }
1001 1020
1002 1021
1003const QString PPPData::gateway() { 1022const QString PPPData::gateway() {
1004 return readConfig(cgroup, GATEWAY_KEY); 1023 return readConfig(cgroup, GATEWAY_KEY);
1005} 1024}
1006 1025
1007 1026
1008void PPPData::setGateway(const QString &n ) { 1027void PPPData::setGateway(const QString &n ) {
1009 writeConfig(cgroup, GATEWAY_KEY, n); 1028 writeConfig(cgroup, GATEWAY_KEY, n);
1010} 1029}
1011 1030
1012 1031
@@ -1014,25 +1033,25 @@ bool PPPData::defaultroute() {
1014 // default route is by default 'on'. 1033 // default route is by default 'on'.
1015 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); 1034 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
1016} 1035}
1017 1036
1018 1037
1019void PPPData::setDefaultroute(bool set) { 1038void PPPData::setDefaultroute(bool set) {
1020 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); 1039 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
1021} 1040}
1022 1041
1023 1042
1024bool PPPData::autoDNS() { 1043bool PPPData::autoDNS() {
1025 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); 1044 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
1026 return (set && PPPData::data()->pppdVersionMin(2, 3, 7)); 1045 return (set && pppdVersionMin(2, 3, 7));
1027} 1046}
1028 1047
1029 1048
1030void PPPData::setAutoDNS(bool set) { 1049void PPPData::setAutoDNS(bool set) {
1031 writeConfig(cgroup, AUTODNS_KEY, (int) set); 1050 writeConfig(cgroup, AUTODNS_KEY, (int) set);
1032} 1051}
1033 1052
1034 1053
1035void PPPData::setExDNSDisabled(bool set) { 1054void PPPData::setExDNSDisabled(bool set) {
1036 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); 1055 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
1037} 1056}
1038 1057
@@ -1217,36 +1236,41 @@ void PPPData::setpppdError(int err) {
1217} 1236}
1218 1237
1219QString PPPData::modemGroup() 1238QString PPPData::modemGroup()
1220{ 1239{
1221 if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); 1240 if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup);
1222 return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); 1241 return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup);
1223} 1242}
1224 1243
1225 1244
1226QMap<QString,QString> PPPData::getConfiguredInterfaces() 1245QMap<QString,QString> PPPData::getConfiguredInterfaces()
1227{ 1246{
1228 QMap<QString,QString> ifaces; 1247 QMap<QString,QString> ifaces;
1229 int count = readNumConfig( ACCLIST_GRP, ACCOUNTS_COUNT, -1 ); 1248 Config config = PPPData::config();
1230 QString accGrp; 1249 config.setGroup(ACCLIST_GRP);
1250 int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
1251 QString accGrp, dev, acc;
1231 for (int i = 0; i < count; i++){ 1252 for (int i = 0; i < count; i++){
1232 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); 1253 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
1233 ifaces.insert( readConfig( accGrp, ACOUNTS_DEV, "error" ), 1254 config.setGroup(accGrp);
1234 readConfig( accGrp, ACOUNTS_ACC, "error" ) ); 1255 dev = config.readEntry( ACOUNTS_DEV, "error" );
1256 acc = config.readEntry( ACOUNTS_ACC, "error" );
1257 ifaces.insert( dev, acc );
1235 } 1258 }
1236 1259
1237 return ifaces; 1260 return ifaces;
1238} 1261}
1239 1262
1240void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) 1263void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
1241{ 1264{
1242 QMap<QString,QString>::Iterator it; 1265 QMap<QString,QString>::Iterator it;
1243 QString accGrp;
1244 int i = 0; 1266 int i = 0;
1267 Config cfg = config();
1245 for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ 1268 for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){
1246 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); 1269 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i));
1247 writeConfig( accGrp, ACOUNTS_DEV, it.key() ); 1270 cfg.writeEntry( ACOUNTS_DEV, it.key() );
1248 writeConfig( accGrp, ACOUNTS_ACC, it.data() ); 1271 cfg.writeEntry( ACOUNTS_ACC, it.data() );
1249 } 1272 }
1250 writeConfig( ACCLIST_GRP, ACCOUNTS_COUNT, i ); 1273 cfg.setGroup( ACCLIST_GRP );
1274 cfg.writeEntry( ACCOUNTS_COUNT, i );
1251 1275
1252} 1276}
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index c1c7e69..af960c6 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -146,37 +146,36 @@ class Config;
146#define E_IF_TIMEOUT 1 146#define E_IF_TIMEOUT 1
147#define E_PPPD_DIED 2 147#define E_PPPD_DIED 2
148 148
149// account list 149// account list
150#define ACCOUNTS_COUNT "Accounts_Count" 150#define ACCOUNTS_COUNT "Accounts_Count"
151#define ACOUNTS_DEV "Accounts_Modem" 151#define ACOUNTS_DEV "Accounts_Modem"
152#define ACOUNTS_ACC "Accounts_Account" 152#define ACOUNTS_ACC "Accounts_Account"
153 153
154class PPPData { 154class PPPData {
155public: 155public:
156 PPPData(); 156 PPPData();
157 ~PPPData() {}; 157 ~PPPData() {};
158 static PPPData* data();
159 158
160 enum { NumInitStrings = 2 }; 159 enum { NumInitStrings = 2 };
161 160
162 // general functions 161 // general functions
163 bool open();
164 void save(); 162 void save();
165 void cancel(); 163 void cancel();
166 164
167 QMap<QString,QString> getConfiguredInterfaces(); 165 static QMap<QString,QString> getConfiguredInterfaces();
168 void setConfiguredInterfaces( QMap<QString,QString> ); 166 static void setConfiguredInterfaces( QMap<QString,QString> );
169 167
170 // function to read/write date to configuration file 168 // function to read/write date to configuration file
169 static Config config();
171 QString readConfig(const QString &, const QString &, const QString &); 170 QString readConfig(const QString &, const QString &, const QString &);
172 int readNumConfig(const QString &, const QString &, int); 171 int readNumConfig(const QString &, const QString &, int);
173 bool readListConfig(const QString &, const QString &, 172 bool readListConfig(const QString &, const QString &,
174 QStringList &, char sep = ','); 173 QStringList &, char sep = ',');
175 void writeConfig(const QString &, const QString &, const QString &); 174 void writeConfig(const QString &, const QString &, const QString &);
176 void writeConfig(const QString &, const QString &, int); 175 void writeConfig(const QString &, const QString &, int);
177 void writeListConfig(const QString &, const QString &, 176 void writeListConfig(const QString &, const QString &,
178 QStringList &, char sep = ','); 177 QStringList &, char sep = ',');
179 178
180 // return the current account group 179 // return the current account group
181 QString currentGroup() { return cgroup; } 180 QString currentGroup() { return cgroup; }
182 QString modemGroup(); 181 QString modemGroup();
@@ -198,29 +197,29 @@ public:
198 void set_quit_on_disconnect(bool); 197 void set_quit_on_disconnect(bool);
199 bool quit_on_disconnect(); 198 bool quit_on_disconnect();
200 199
201 void set_show_clock_on_caption(bool set); 200 void set_show_clock_on_caption(bool set);
202 bool get_show_clock_on_caption(); 201 bool get_show_clock_on_caption();
203 202
204 void set_show_log_window(bool set); 203 void set_show_log_window(bool set);
205 bool get_show_log_window(); 204 bool get_show_log_window();
206 205
207 void set_automatic_redial(bool set); 206 void set_automatic_redial(bool set);
208 bool automatic_redial(); 207 bool automatic_redial();
209 208
210 void set_iconify_on_connect(bool set); 209// void set_iconify_on_connect(bool set);
211 bool get_iconify_on_connect(); 210// bool get_iconify_on_connect();
212 211
213 void set_dock_into_panel(bool set); 212// void set_dock_into_panel(bool set);
214 bool get_dock_into_panel(); 213// bool get_dock_into_panel();
215 214
216 const QString enter(); 215 const QString enter();
217 void setEnter(const QString &); 216 void setEnter(const QString &);
218 217
219 QString pppdVersion(); 218 QString pppdVersion();
220 bool pppdVersionMin(int ver, int mod, int patch); 219 bool pppdVersionMin(int ver, int mod, int patch);
221 220
222 int pppdTimeout(); 221 int pppdTimeout();
223 void setpppdTimeout(int); 222 void setpppdTimeout(int);
224 223
225 int busyWait(); 224 int busyWait();
226 void setbusyWait(int); 225 void setbusyWait(int);
@@ -302,29 +301,24 @@ public:
302 const QString modemAnswerResp(); 301 const QString modemAnswerResp();
303 void setModemAnswerResp(const QString &); 302 void setModemAnswerResp(const QString &);
304 303
305 QString volumeOff(); 304 QString volumeOff();
306 void setVolumeOff(const QString &); 305 void setVolumeOff(const QString &);
307 306
308 QString volumeMedium(); 307 QString volumeMedium();
309 void setVolumeMedium(const QString &); 308 void setVolumeMedium(const QString &);
310 309
311 QString volumeHigh(); 310 QString volumeHigh();
312 void setVolumeHigh(const QString &); 311 void setVolumeHigh(const QString &);
313 312
314#if 0
315 void setUseCDLine(const int n);
316 int UseCDLine();
317#endif
318
319 // functions to set/get account information 313 // functions to set/get account information
320 int count() const; 314 int count() const;
321 bool setAccount(const QString &); 315 bool setAccount(const QString &);
322 bool setAccountbyIndex(int); 316 bool setAccountbyIndex(int);
323 317
324 bool isUniqueAccname(const QString &); 318 bool isUniqueAccname(const QString &);
325 319
326 bool deleteAccount(); 320 bool deleteAccount();
327 bool deleteAccount(const QString &); 321 bool deleteAccount(const QString &);
328 int newaccount(); 322 int newaccount();
329 int copyaccount(int i); 323 int copyaccount(int i);
330 324
@@ -365,26 +359,26 @@ public:
365 const QString command_before_disconnect(); 359 const QString command_before_disconnect();
366 void setCommand_before_disconnect(const QString &); 360 void setCommand_before_disconnect(const QString &);
367 361
368 const QString ipaddr(); 362 const QString ipaddr();
369 void setIpaddr(const QString &); 363 void setIpaddr(const QString &);
370 364
371 const QString subnetmask(); 365 const QString subnetmask();
372 void setSubnetmask(const QString &); 366 void setSubnetmask(const QString &);
373 367
374 bool AcctEnabled(); 368 bool AcctEnabled();
375 void setAcctEnabled(bool set); 369 void setAcctEnabled(bool set);
376 370
377 int VolAcctEnabled(); 371// int VolAcctEnabled();
378 void setVolAcctEnabled(int set); 372// void setVolAcctEnabled(int set);
379 373
380 bool autoDNS(); 374 bool autoDNS();
381 void setAutoDNS(bool set); 375 void setAutoDNS(bool set);
382 376
383 bool exDNSDisabled(); 377 bool exDNSDisabled();
384 void setExDNSDisabled(bool set); 378 void setExDNSDisabled(bool set);
385 379
386 bool autoname(); 380 bool autoname();
387 void setAutoname(bool set); 381 void setAutoname(bool set);
388 382
389 const QString gateway(); 383 const QString gateway();
390 void setGateway(const QString &); 384 void setGateway(const QString &);
@@ -406,60 +400,36 @@ public:
406 400
407 QStringList &pppdArgument(); 401 QStringList &pppdArgument();
408 void setpppdArgumentDefaults(); 402 void setpppdArgumentDefaults();
409 void setpppdArgument(QStringList &); 403 void setpppdArgument(QStringList &);
410 404
411 //functions to change/set the child pppd process info 405 //functions to change/set the child pppd process info
412 bool pppdRunning() const; 406 bool pppdRunning() const;
413 void setpppdRunning(bool set); 407 void setpppdRunning(bool set);
414 408
415 int pppdError() const; 409 int pppdError() const;
416 void setpppdError(int err); 410 void setpppdError(int err);
417 411
418 // functions to set/query the accounting info
419// const QString accountingFile();
420// void setAccountingFile(const QString &);
421
422// const QString totalCosts();
423// void setTotalCosts(const QString &);
424
425// int totalBytes();
426// void setTotalBytes(int);
427
428// // graphing widget
429// void setGraphingOptions(bool enabled,
430 // QColor bg,
431 // QColor text,
432 // QColor in,
433 // QColor out);
434// void graphingOptions(bool &enabled,
435 // QColor &bg,
436 // QColor &text,
437 // QColor &in,
438 // QColor &out);
439// bool graphingEnabled();
440
441// // window positions
442// void winPosConWin(int &, int &);
443// void setWinPosConWin(int, int);
444// void winPosStatWin(int &, int &);
445// void setWinPosStatWin(int, int);
446
447private: 412private:
448 413
449 static PPPData *_data; 414 //static PPPData *_data;
450 int modemDeviceGroup; 415 int modemDeviceGroup;
451 QString passwd; 416 QString passwd;
452 static Config* config; // configuration object 417 // static Config* config; // configuration object
453 int highcount; // index of highest account 418 int highcount; // index of highest account
454 int caccount; // index of the current account 419 int caccount; // index of the current account
455 QString cgroup; // name of current config group 420 QString cgroup; // name of current config group
456 pid_t suidprocessid; // process ID of setuid child 421 pid_t suidprocessid; // process ID of setuid child
457 bool pppdisrunning; // pppd process 422 bool pppdisrunning; // pppd process
458 // daemon 423 // daemon
459 int pppderror; // error encounterd running pppd 424 int pppderror; // error encounterd running pppd
460 int pppdVer, pppdMod, pppdPatch; // pppd version 425 int pppdVer, pppdMod, pppdPatch; // pppd version
461 426
462 QStringList phonelist; 427 QStringList phonelist;
428 QMap<QString,QString> stringEntries;
429 QMap<QString,int> intEntries;
430 QMap<QString,QStringList> listEntries;
431 QMap<QString,QChar> sepEntries;
432
463}; 433};
464 434
465#endif 435#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 7cbccc2..95df068 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,48 +1,48 @@
1
1#include "pppconfig.h" 2#include "pppconfig.h"
2#include "pppmodule.h" 3#include "pppmodule.h"
3#include "pppdata.h" 4#include "pppdata.h"
4#include "kpppwidget.h" 5#include "interfaceinformationppp.h"
5#include "interfaceinformationimp.h" 6#include "interfaceppp.h"
6//#include "devices.h" 7
7 8
8/** 9/**
9 * Constructor, find all of the possible interfaces 10 * Constructor, find all of the possible interfaces
10 */ 11 */
11PPPModule::PPPModule() : Module() 12PPPModule::PPPModule() : Module()
12{ 13{
13 QMap<QString,QString> ifaces = PPPData::data()->getConfiguredInterfaces(); 14 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
14 QMap<QString,QString>::Iterator it; 15 QMap<QString,QString>::Iterator it;
15 Interface *iface; 16 InterfacePPP *iface;
16 qDebug("getting interfaces"); 17 qDebug("getting interfaces");
17 for( it = ifaces.begin(); it != ifaces.end(); ++it ){ 18 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
18 qDebug("ifaces %s", it.key().latin1()); 19 qDebug("ifaces %s", it.key().latin1());
19 iface = new Interface( 0, it.key() ); 20 iface = new InterfacePPP( 0, it.key() );
20 iface->setHardwareName( it.data() ); 21 iface->setHardwareName( it.data() );
21 list.append( iface ); 22 list.append( (Interface*)iface );
22 } 23 }
23} 24}
24 25
25/** 26/**
26 * Delete any interfaces that we own. 27 * Delete any interfaces that we own.
27 */ 28 */
28PPPModule::~PPPModule(){ 29PPPModule::~PPPModule(){
29 QMap<QString,QString> ifaces; 30 QMap<QString,QString> ifaces;
30 Interface *i; 31 Interface *i;
31 for ( i=list.first(); i != 0; i=list.next() ){ 32 for ( i=list.first(); i != 0; i=list.next() ){
32 ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); 33 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
33 delete i; 34 delete i;
34 } 35 }
35 PPPData::data()->setConfiguredInterfaces( ifaces ); 36 PPPData::setConfiguredInterfaces( ifaces );
36 PPPData::data()->save();
37} 37}
38 38
39/** 39/**
40 * Change the current profile 40 * Change the current profile
41 */ 41 */
42void PPPModule::setProfile(const QString &newProfile){ 42void PPPModule::setProfile(const QString &newProfile){
43 profile = newProfile; 43 profile = newProfile;
44} 44}
45 45
46/** 46/**
47 * get the icon name for this device. 47 * get the icon name for this device.
48 * @param Interface* can be used in determining the icon. 48 * @param Interface* can be used in determining the icon.
@@ -58,69 +58,72 @@ QString PPPModule::getPixmapName(Interface* ){
58 * @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.
59 */ 59 */
60bool PPPModule::isOwner(Interface *i){ 60bool PPPModule::isOwner(Interface *i){
61 return list.find( i ) != -1; 61 return list.find( i ) != -1;
62} 62}
63 63
64/** 64/**
65 * Create, and return the WLANConfigure Module 65 * Create, and return the WLANConfigure Module
66 * @return QWidget* pointer to this modules configure. 66 * @return QWidget* pointer to this modules configure.
67 */ 67 */
68QWidget *PPPModule::configure(Interface *i){ 68QWidget *PPPModule::configure(Interface *i){
69 qDebug("return ModemWidget"); 69 qDebug("return ModemWidget");
70 PPPConfigWidget *pppconfig = new PPPConfigWidget( i, 0, "PPPConfig", 70 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
71 false, 71 0, "PPPConfig", false,
72 Qt::WDestructiveClose ); 72 Qt::WDestructiveClose );
73 return pppconfig; 73 return pppconfig;
74} 74}
75 75
76/** 76/**
77 * Create, and return the Information Module 77 * Create, and return the Information Module
78 * @return QWidget* pointer to this modules info. 78 * @return QWidget* pointer to this modules info.
79 */ 79 */
80QWidget *PPPModule::information(Interface *i){ 80QWidget *PPPModule::information(Interface *i){
81 // We don't have any advanced pppd information widget yet :-D 81 // We don't have any advanced pppd information widget yet :-D
82 // TODO ^ 82 // TODO ^
83 qDebug("return PPPModule::information"); 83 qDebug("return PPPModule::information");
84 InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i); 84// InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
85 InterfaceInformationPPP *information = new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
85 return information; 86 return information;
86} 87}
87 88
88/** 89/**
89 * Get all active (up or down) interfaces 90 * Get all active (up or down) interfaces
90 * @return QList<Interface> A list of interfaces that exsist that havn't 91 * @return QList<Interface> A list of interfaces that exsist that havn't
91 * been called by isOwner() 92 * been called by isOwner()
92 */ 93 */
93QList<Interface> PPPModule::getInterfaces(){ 94QList<Interface> PPPModule::getInterfaces(){
94 // List all of the files in the peer directory 95 // List all of the files in the peer directory
95 qDebug("PPPModule::getInterfaces"); 96 qDebug("PPPModule::getInterfaces");
96 return list; 97 return list;
97} 98}
98 99
99/** 100/**
100 * Attempt to add a new interface as defined by name 101 * Attempt to add a new interface as defined by name
101 * @param name the name of the type of interface that should be created given 102 * @param name the name of the type of interface that should be created given
102 * by possibleNewInterfaces(); 103 * by possibleNewInterfaces();
103 * @return Interface* NULL if it was unable to be created. 104 * @return Interface* NULL if it was unable to be created.
104 */ 105 */
105Interface *PPPModule::addNewInterface(const QString &newInterface){ 106Interface *PPPModule::addNewInterface(const QString &newInterface){
106 107
107 qDebug("try to add iface %s",newInterface.latin1()); 108 qDebug("try to add iface %s",newInterface.latin1());
108 109
110 InterfacePPP *ifaceppp;
109 Interface *iface; 111 Interface *iface;
110 iface = new Interface(); 112 ifaceppp = new InterfacePPP();
111 PPPConfigWidget imp(iface, 0, "PPPConfigImp", true); 113 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
112 imp.showMaximized(); 114 imp.showMaximized();
113 if(imp.exec() == QDialog::Accepted ){ 115 if(imp.exec() == QDialog::Accepted ){
114 iface->setModuleOwner( this ); 116 iface->setModuleOwner( this );
117 iface = ifaceppp;
115 list.append( iface ); 118 list.append( iface );
116 return iface; 119 return iface;
117 }else { 120 }else {
118 delete iface; 121 delete iface;
119 iface = NULL; 122 iface = NULL;
120 } 123 }
121 return iface; 124 return iface;
122} 125}
123 126
124/** 127/**
125 * Attempts to remove the interface, doesn't delete i 128 * Attempts to remove the interface, doesn't delete i
126 * @return bool true if successfull, false otherwise. 129 * @return bool true if successfull, false otherwise.