summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp110
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp180
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp26
-rw-r--r--noncore/settings/networksettings/ppp/debug.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp242
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp42
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp150
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp30
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp111
-rw-r--r--noncore/settings/networksettings/ppp/newwidget.cpp17
-rw-r--r--noncore/settings/networksettings/ppp/newwidget.h19
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro4
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp10
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp229
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h78
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp3
17 files changed, 615 insertions, 642 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index d902517..19db9ef 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -1,471 +1,475 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <qdir.h> 27#include <qdir.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qtabdialog.h> 31#include <qtabdialog.h>
32#include <qwhatsthis.h> 32#include <qwhatsthis.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34 34
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qbuttongroup.h> 36#include <qbuttongroup.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38//#include <klocale.h> 38//#include <klocale.h>
39#define i18n QObject::tr 39#define i18n QObject::tr
40//#include <kglobal.h> 40//#include <kglobal.h>
41//#include <kwin.h> 41//#include <kwin.h>
42//#include <kdialogbase.h> 42//#include <kdialogbase.h>
43#include <qvgroupbox.h> 43#include <qvgroupbox.h>
44 44
45#include "pppdata.h" 45#include "pppdata.h"
46#include "accounts.h" 46#include "accounts.h"
47//#include "accounting.h" 47//#include "accounting.h"
48//#include "providerdb.h" 48//#include "providerdb.h"
49#include "edit.h" 49#include "edit.h"
50 50
51void parseargs(char* buf, char** args); 51void parseargs(char* buf, char** args);
52 52
53AccountWidget::AccountWidget( QWidget *parent, const char *name ) 53AccountWidget::AccountWidget( QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name )
55{ 55{
56 int min = 0; 56// int min = 0;
57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
58 58
59 // add a hbox 59 // add a hbox
60// QHBoxLayout *l11 = new QHBoxLayout; 60// QHBoxLayout *l11 = new QHBoxLayout;
61// l1->addLayout(l11); 61// l1->addLayout(l11);
62 62
63 accountlist_l = new QListBox(this); 63 accountlist_l = new QListBox(this);
64 accountlist_l->setMinimumSize(160, 128); 64// accountlist_l->setMinimumSize(160, 128);
65 connect(accountlist_l, SIGNAL(highlighted(int)), 65 connect(accountlist_l, SIGNAL(highlighted(int)),
66 this, SLOT(slotListBoxSelect(int))); 66 this, SLOT(slotListBoxSelect(int)));
67 connect(accountlist_l, SIGNAL(selected(int)), 67 connect(accountlist_l, SIGNAL(selected(int)),
68 this, SLOT(editaccount())); 68 this, SLOT(editaccount()));
69 l1->addWidget(accountlist_l, 10); 69 l1->addWidget(accountlist_l, 10);
70 70
71// QVBoxLayout *l111 = new QVBoxLayout(this); 71// QVBoxLayout *l111 = new QVBoxLayout(this);
72// l11->addLayout(l111, 1); 72// l11->addLayout(l111, 1);
73 edit_b = new QPushButton(i18n("&Edit..."), this); 73 edit_b = new QPushButton(i18n("&Edit..."), this);
74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); 75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
76 76
77 min = edit_b->sizeHint().width(); 77// min = edit_b->sizeHint().width();
78 min = QMAX(70,min); 78// min = QMAX(70,min);
79 edit_b->setMinimumWidth(min); 79// edit_b->setMinimumWidth(min);
80 80
81 l1->addWidget(edit_b); 81 l1->addWidget(edit_b);
82 82
83 new_b = new QPushButton(i18n("&New..."), this); 83 new_b = new QPushButton(i18n("&New..."), this);
84 connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); 84 connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
85 l1->addWidget(new_b); 85 l1->addWidget(new_b);
86 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" 86 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n"
87 "to the Internet")); 87 "to the Internet"));
88 88
89 copy_b = new QPushButton(i18n("Co&py"), this); 89 copy_b = new QPushButton(i18n("Co&py"), this);
90 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); 90 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
91 l1->addWidget(copy_b); 91 l1->addWidget(copy_b);
92 QWhatsThis::add(copy_b, 92 QWhatsThis::add(copy_b,
93 i18n("Makes a copy of the selected account. All\n" 93 i18n("Makes a copy of the selected account. All\n"
94 "settings of the selected account are copied\n" 94 "settings of the selected account are copied\n"
95 "to a new account, that you can modify to fit your\n" 95 "to a new account, that you can modify to fit your\n"
96 "needs")); 96 "needs"));
97 97
98 delete_b = new QPushButton(i18n("De&lete"), this); 98 delete_b = new QPushButton(i18n("De&lete"), this);
99 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); 99 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
100 l1->addWidget(delete_b); 100 l1->addWidget(delete_b);
101 QWhatsThis::add(delete_b, 101 QWhatsThis::add(delete_b,
102 i18n("<p>Deletes the selected account\n\n" 102 i18n("<p>Deletes the selected account\n\n"
103 "<font color=\"red\"><b>Use with care!</b></font>")); 103 "<font color=\"red\"><b>Use with care!</b></font>"));
104 104
105 QHBoxLayout *l12 = new QHBoxLayout; 105 QHBoxLayout *l12 = new QHBoxLayout;
106 l1->addStretch(1); 106 l1->addStretch(1);
107 l1->addLayout(l12); 107 l1->addLayout(l12);
108 108
109// QVBoxLayout *l121 = new QVBoxLayout; 109// QVBoxLayout *l121 = new QVBoxLayout;
110// l12->addLayout(l121); 110// l12->addLayout(l121);
111// l121->addStretch(1); 111// l121->addStretch(1);
112 // costlabel = new QLabel(i18n("Phone costs:"), parent); 112 // costlabel = new QLabel(i18n("Phone costs:"), parent);
113// costlabel->setEnabled(FALSE); 113// costlabel->setEnabled(FALSE);
114// l121->addWidget(costlabel); 114// l121->addWidget(costlabel);
115 115
116// costedit = new QLineEdit(parent); 116// costedit = new QLineEdit(parent);
117// costedit->setFocusPolicy(QWidget::NoFocus); 117// costedit->setFocusPolicy(QWidget::NoFocus);
118// costedit->setFixedHeight(costedit->sizeHint().height()); 118// costedit->setFixedHeight(costedit->sizeHint().height());
119// costedit->setEnabled(FALSE); 119// costedit->setEnabled(FALSE);
120// l121->addWidget(costedit); 120// l121->addWidget(costedit);
121// l121->addStretch(1); 121// l121->addStretch(1);
122// QString tmp = i18n("<p>This shows the accumulated phone costs\n" 122// QString tmp = i18n("<p>This shows the accumulated phone costs\n"
123 // "for the selected account.\n" 123 // "for the selected account.\n"
124 // "\n" 124 // "\n"
125 // "<b>Important</b>: If you have more than one \n" 125 // "<b>Important</b>: If you have more than one \n"
126 // "account - beware, this is <b>NOT</b> the sum \n" 126 // "account - beware, this is <b>NOT</b> the sum \n"
127 // "of the phone costs of all your accounts!"); 127 // "of the phone costs of all your accounts!");
128// QWhatsThis::add(costlabel, tmp); 128// QWhatsThis::add(costlabel, tmp);
129// QWhatsThis::add(costedit, tmp); 129// QWhatsThis::add(costedit, tmp);
130 130
131// vollabel = new QLabel(i18n("Volume:"), parent); 131// vollabel = new QLabel(i18n("Volume:"), parent);
132// vollabel->setEnabled(FALSE); 132// vollabel->setEnabled(FALSE);
133// l121->addWidget(vollabel); 133// l121->addWidget(vollabel);
134 134
135// voledit = new QLineEdit(parent,"voledit"); 135// voledit = new QLineEdit(parent,"voledit");
136// voledit->setFocusPolicy(QWidget::NoFocus); 136// voledit->setFocusPolicy(QWidget::NoFocus);
137// voledit->setFixedHeight(voledit->sizeHint().height()); 137// voledit->setFixedHeight(voledit->sizeHint().height());
138// voledit->setEnabled(FALSE); 138// voledit->setEnabled(FALSE);
139// l121->addWidget(voledit); 139// l121->addWidget(voledit);
140// tmp = i18n("<p>This shows the number of bytes transferred\n" 140// tmp = i18n("<p>This shows the number of bytes transferred\n"
141 // "for the selected account (not for all of your\n" 141 // "for the selected account (not for all of your\n"
142 // "accounts. You can select what to display in\n" 142 // "accounts. You can select what to display in\n"
143 // "the accounting dialog.\n" 143 // "the accounting dialog.\n"
144 // "\n" 144 // "\n"
145 // "<a href=\"#volaccounting\">More on volume accounting</a>"); 145 // "<a href=\"#volaccounting\">More on volume accounting</a>");
146 146
147// QWhatsThis::add(vollabel,tmp); 147// QWhatsThis::add(vollabel,tmp);
148// QWhatsThis::add(voledit, tmp); 148// QWhatsThis::add(voledit, tmp);
149 149
150// QVBoxLayout *l122 = new QVBoxLayout; 150// QVBoxLayout *l122 = new QVBoxLayout;
151// l12->addStretch(1); 151// l12->addStretch(1);
152// l12->addLayout(l122); 152// l12->addLayout(l122);
153 153
154// l122->addStretch(1); 154// l122->addStretch(1);
155// reset = new QPushButton(i18n("&Reset..."), parent); 155// reset = new QPushButton(i18n("&Reset..."), parent);
156// reset->setEnabled(FALSE); 156// reset->setEnabled(FALSE);
157// connect(reset, SIGNAL(clicked()), 157// connect(reset, SIGNAL(clicked()),
158 // this, SLOT(resetClicked())); 158 // this, SLOT(resetClicked()));
159// l122->addWidget(reset); 159// l122->addWidget(reset);
160 160
161// log = new QPushButton(i18n("&View Logs"), this); 161// log = new QPushButton(i18n("&View Logs"), this);
162// connect(log, SIGNAL(clicked()), 162// connect(log, SIGNAL(clicked()),
163 // this, SLOT(viewLogClicked())); 163 // this, SLOT(viewLogClicked()));
164// l122->addWidget(log); 164// l122->addWidget(log);
165// l122->addStretch(1); 165// l122->addStretch(1);
166 166
167 //load up account list from gppdata to the list box 167 //load up account list from gppdata to the list box
168 if(gpppdata.count() > 0) { 168 if(PPPData::data()->count() > 0) {
169 for(int i=0; i <= gpppdata.count()-1; i++) { 169 for(int i=0; i <= PPPData::data()->count()-1; i++) {
170 gpppdata.setAccountbyIndex(i); 170 PPPData::data()->setAccountbyIndex(i);
171 accountlist_l->insertItem(gpppdata.accname()); 171 accountlist_l->insertItem(PPPData::data()->accname());
172 } 172 }
173 } 173 }
174 174
175 slotListBoxSelect(accountlist_l->currentItem()); 175 slotListBoxSelect(accountlist_l->currentItem());
176 176
177 l1->activate(); 177 l1->activate();
178} 178}
179 179
180 180
181 181
182void AccountWidget::slotListBoxSelect(int idx) { 182void AccountWidget::slotListBoxSelect(int idx) {
183 delete_b->setEnabled((bool)(idx != -1)); 183 delete_b->setEnabled((bool)(idx != -1));
184 edit_b->setEnabled((bool)(idx != -1)); 184 edit_b->setEnabled((bool)(idx != -1));
185 copy_b->setEnabled((bool)(idx != -1)); 185 copy_b->setEnabled((bool)(idx != -1));
186 if(idx!=-1) { 186 if(idx!=-1) {
187 QString account = gpppdata.accname(); 187 QString account = PPPData::data()->accname();
188 gpppdata.setAccountbyIndex(accountlist_l->currentItem()); 188 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
189// reset->setEnabled(TRUE); 189// reset->setEnabled(TRUE);
190// costlabel->setEnabled(TRUE); 190// costlabel->setEnabled(TRUE);
191// costedit->setEnabled(TRUE); 191// costedit->setEnabled(TRUE);
192// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem()))); 192// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem())));
193 193
194// vollabel->setEnabled(TRUE); 194// vollabel->setEnabled(TRUE);
195// voledit->setEnabled(TRUE); 195// voledit->setEnabled(TRUE);
196 int bytes = gpppdata.totalBytes(); 196// int bytes = PPPData::data()->totalBytes();
197// voledit->setText(prettyPrintVolume(bytes)); 197// voledit->setText(prettyPrintVolume(bytes));
198 gpppdata.setAccount(account); 198 PPPData::data()->setAccount(account);
199 } else{ 199 } else{
200 // reset->setEnabled(FALSE); 200 // reset->setEnabled(FALSE);
201// costlabel->setEnabled(FALSE); 201// costlabel->setEnabled(FALSE);
202// costedit->setText(""); 202// costedit->setText("");
203// costedit->setEnabled(FALSE); 203// costedit->setEnabled(FALSE);
204// vollabel->setEnabled(FALSE); 204// vollabel->setEnabled(FALSE);
205// voledit->setText(""); 205// voledit->setText("");
206// voledit->setEnabled(FALSE); 206// voledit->setEnabled(FALSE);
207 } 207 }
208} 208}
209 209
210 210
211// void AccountWidget::viewLogClicked(){ 211// void AccountWidget::viewLogClicked(){
212 212
213// QApplication::flushX(); 213// QApplication::flushX();
214// if(fork() == 0) { 214// if(fork() == 0) {
215// setgid(getgid()); 215// setgid(getgid());
216// setuid(getuid()); 216// setuid(getuid());
217// system("kppplogview -kppp"); 217// system("kppplogview -kppp");
218// _exit(0); 218// _exit(0);
219// } 219// }
220// } 220// }
221 221
222 222
223// void AccountWidget::resetClicked(){ 223// void AccountWidget::resetClicked(){
224// if(accountlist_l->currentItem() == -1) 224// if(accountlist_l->currentItem() == -1)
225// return; 225// return;
226 226
227// // QueryReset dlg(this); 227// // QueryReset dlg(this);
228// // int what = dlg.exec(); 228// // int what = dlg.exec();
229 229
230// // if(what && QueryReset::COSTS) { 230// // if(what && QueryReset::COSTS) {
231// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); 231// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem()));
232// // costedit->setText("0"); 232// // costedit->setText("0");
233// // } 233// // }
234 234
235// // if(what && QueryReset::VOLUME) { 235// // if(what && QueryReset::VOLUME) {
236// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); 236// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem()));
237// // voledit->setText(prettyPrintVolume(0)); 237// // voledit->setText(prettyPrintVolume(0));
238// // } 238// // }
239// } 239// }
240 240
241 241
242void AccountWidget::editaccount() { 242void AccountWidget::editaccount() {
243 gpppdata.setAccount(accountlist_l->text(accountlist_l->currentItem())); 243 PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
244 244
245 int result = doTab(); 245 int result = doTab();
246 246
247 if(result == QDialog::Accepted) { 247 if(result == QDialog::Accepted) {
248 accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem()); 248 accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
249// emit resetaccounts(); 249// emit resetaccounts();
250 gpppdata.save(); 250 PPPData::data()->save();
251 } 251 }
252} 252}
253 253
254 254
255void AccountWidget::newaccount() { 255void AccountWidget::newaccount() {
256 if(accountlist_l->count() == MAX_ACCOUNTS) { 256 if(accountlist_l->count() == MAX_ACCOUNTS) {
257 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 257 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
258 return; 258 return;
259 } 259 }
260 260
261 int result; 261 int result;
262// int query = QMessageBox::information(this, 262// int query = QMessageBox::information(this,
263// i18n("Do you want to use the wizard to create the new account or the " 263// i18n("Do you want to use the wizard to create the new account or the "
264 // "standard, dialog-based setup?\n" 264 // "standard, dialog-based setup?\n"
265 // "The wizard is easier and sufficient in most cases. If you need " 265 // "The wizard is easier and sufficient in most cases. If you need "
266 // "very special settings, you might want to try the standard, " 266 // "very special settings, you might want to try the standard, "
267 // "dialog-based setup."), 267 // "dialog-based setup."),
268 // i18n("Create New Account"), 268 // i18n("Create New Account"),
269 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); 269 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
270 270
271// switch(query) { 271// switch(query) {
272// case QMessageBox::Yes: 272// case QMessageBox::Yes:
273// { 273// {
274// if (gpppdata.newaccount() == -1) 274// if (PPPData::data()->newaccount() == -1)
275 // return; 275 // return;
276// // ProviderDB pdb(this); 276// // ProviderDB pdb(this);
277// // result = pdb.exec(); 277// // result = pdb.exec();
278// break; 278// break;
279// } 279// }
280// case QMessageBox::No: 280// case QMessageBox::No:
281 if (gpppdata.newaccount() == -1){ 281 if (PPPData::data()->newaccount() == -1){
282 qDebug("gpppdata.newaccount() == -1"); 282 qDebug("PPPData::data()->newaccount() == -1");
283 return; 283 return;
284 } 284 }
285 result = doTab(); 285 result = doTab();
286// break; 286// break;
287// default: 287// default:
288// return; 288// return;
289// } 289// }
290 290
291 if(result == QDialog::Accepted) { 291 if(result == QDialog::Accepted) {
292 accountlist_l->insertItem(gpppdata.accname()); 292 accountlist_l->insertItem(PPPData::data()->accname());
293 accountlist_l->setSelected(accountlist_l->findItem(gpppdata.accname()), 293 accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
294 true); 294 true);
295// emit resetaccounts(); 295// emit resetaccounts();
296 gpppdata.save(); 296 PPPData::data()->save();
297 } else 297 } else
298 gpppdata.deleteAccount(); 298 PPPData::data()->deleteAccount();
299} 299}
300 300
301 301
302void AccountWidget::copyaccount() { 302void AccountWidget::copyaccount() {
303 if(accountlist_l->count() == MAX_ACCOUNTS) { 303 if(accountlist_l->count() == MAX_ACCOUNTS) {
304 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 304 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
305 return; 305 return;
306 } 306 }
307 307
308 if(accountlist_l->currentItem()<0) { 308 if(accountlist_l->currentItem()<0) {
309 QMessageBox::information(this, "sorry", i18n("No account selected.")); 309 QMessageBox::information(this, "sorry", i18n("No account selected."));
310 return; 310 return;
311 } 311 }
312 312
313 gpppdata.copyaccount(accountlist_l->currentItem()); 313 PPPData::data()->copyaccount(accountlist_l->currentItem());
314 314
315 accountlist_l->insertItem(gpppdata.accname()); 315 accountlist_l->insertItem(PPPData::data()->accname());
316// emit resetaccounts(); 316// emit resetaccounts();
317 gpppdata.save(); 317 PPPData::data()->save();
318} 318}
319 319
320 320
321void AccountWidget::deleteaccount() { 321void AccountWidget::deleteaccount() {
322 322
323 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") 323 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
324 .arg(accountlist_l->text(accountlist_l->currentItem())); 324 .arg(accountlist_l->text(accountlist_l->currentItem()));
325 325
326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) 326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
327 return; 327 return;
328 328
329 if(gpppdata.deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 329 if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
330 accountlist_l->removeItem(accountlist_l->currentItem()); 330 accountlist_l->removeItem(accountlist_l->currentItem());
331 331
332 emit resetaccounts(); 332 emit resetaccounts();
333 gpppdata.save(); 333 PPPData::data()->save();
334 334
335 slotListBoxSelect(accountlist_l->currentItem()); 335 slotListBoxSelect(accountlist_l->currentItem());
336 336
337} 337}
338 338
339 339
340int AccountWidget::doTab(){ 340int AccountWidget::doTab(){
341 QDialog *dlg = new QDialog( this ); 341 QDialog *dlg = new QDialog( this, "newAccount", true );
342 tabWindow = new QTabWidget( dlg ); 342 QVBoxLayout *layout = new QVBoxLayout( dlg );
343 // tabWindow = new KDialogBase( KDialogBase::Tabbed, QString::null, 343 layout->setSpacing( 0 );
344// KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, 344 layout->setMargin( 1 );
345// 0, 0, true); 345
346// KWin::setIcons(tabWindow->winId(), kapp->icon(), kapp->miniIcon()); 346 tabWindow = new QTabWidget( dlg, "tabWindow" );
347 layout->addWidget( tabWindow );
348
347 bool isnewaccount; 349 bool isnewaccount;
348 350
349 if(gpppdata.accname().isEmpty()) { 351 if(PPPData::data()->accname().isEmpty()) {
350 tabWindow->setCaption(i18n("New Account")); 352 dlg->setCaption(i18n("New Account"));
351 isnewaccount = true; 353 isnewaccount = true;
352 } else { 354 } else {
353 QString tit = i18n("Edit Account: "); 355 QString tit = i18n("Edit Account: ");
354 tit += gpppdata.accname(); 356 tit += PPPData::data()->accname();
355 tabWindow->setCaption(tit); 357 dlg->setCaption(tit);
356 isnewaccount = false; 358 isnewaccount = false;
357 } 359 }
358 360
359 dial_w = new DialWidget( tabWindow ); 361 dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
360 tabWindow->addTab( dial_w, i18n("Dial") );//, i18n("Dial Setup")), isnewaccount); 362 tabWindow->addTab( dial_w, i18n("Dial") );
361 ip_w = new IPWidget( tabWindow ); 363 ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
362 tabWindow->addTab( ip_w, i18n("IP") );//, i18n("IP Setup")), isnewaccount); 364 tabWindow->addTab( ip_w, i18n("IP") );
363 gateway_w = new GatewayWidget( tabWindow ); 365 gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
364 tabWindow->addTab( gateway_w, i18n("Gateway") );//, i18n("Gateway Setup")), isnewaccount); 366 tabWindow->addTab( gateway_w, i18n("Gateway") );
365 dns_w = new DNSWidget( tabWindow ); 367 dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
366 tabWindow->addTab( dns_w, i18n("DNS") );//, i18n("DNS Servers")), isnewaccount); 368 tabWindow->addTab( dns_w, i18n("DNS") );
367 script_w = new ScriptWidget( tabWindow ); 369 script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
368 tabWindow->addTab( script_w, i18n("Login Script") ); //, i18n("Edit Login Script")), isnewaccount); 370 tabWindow->addTab( script_w, i18n("Login Script") );
369 ExecWidget *exec_w = new ExecWidget( tabWindow ); 371 ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
370 tabWindow->addTab( exec_w, i18n("Execute") );//, i18n("Execute Programs")), isnewaccount); 372 tabWindow->addTab( exec_w, i18n("Execute") );
371// acct = new AccountingSelector( tabWindow, isnewaccount ); 373// acct = new AccountingSelector( tabWindow, isnewaccount );
372// tabWindow->addTab( acct, i18n("Accounting")); 374// tabWindow->addTab( acct, i18n("Accounting"));
373 375
374 int result = 0; 376 int result = 0;
375 bool ok = false; 377 bool ok = false;
378 qDebug("AccountWidget::doTab dlg->showMinimized");
379 dlg->showMinimized();
376 while (!ok){ 380 while (!ok){
377 381
378 result = dlg->exec(); 382 result = dlg->exec();
379 ok = true; 383 ok = true;
380 384
381 if(result == QDialog::Accepted) { 385 if(result == QDialog::Accepted) {
382 if (script_w->check()) { 386 if (script_w->check()) {
383 if(dial_w->save()) { 387 if(dial_w->save()) {
384 ip_w->save(); 388 ip_w->save();
385 dns_w->save(); 389 dns_w->save();
386 gateway_w->save(); 390 gateway_w->save();
387 script_w->save(); 391 script_w->save();
388 exec_w->save(); 392 exec_w->save();
389 // acct->save(); 393 // acct->save();
390 } else { 394 } else {
391 QMessageBox::critical(this, "error", i18n( "You must enter a unique\n" 395 QMessageBox::critical(this, "error", i18n( "You must enter a unique\n"
392 "account name")); 396 "account name"));
393 ok = false; 397 ok = false;
394 } 398 }
395 } else { 399 } else {
396 QMessageBox::critical(this, "error", i18n("Login script has unbalanced " 400 QMessageBox::critical(this, "error", i18n("Login script has unbalanced "
397 "loop Start/End")); 401 "loop Start/End"));
398 ok = false; 402 ok = false;
399 } 403 }
400 } 404 }
401 } 405 }
402 406
403 delete tabWindow; 407 delete tabWindow;
404 return result; 408 return result;
405} 409}
406 410
407 411
408QString AccountWidget::prettyPrintVolume(unsigned int n) { 412QString AccountWidget::prettyPrintVolume(unsigned int n) {
409 int idx = 0; 413 int idx = 0;
410 const QString quant[] = {i18n("Byte"), i18n("KB"), 414 const QString quant[] = {i18n("Byte"), i18n("KB"),
411 i18n("MB"), i18n("GB"), QString::null}; 415 i18n("MB"), i18n("GB"), QString::null};
412 416
413 float n1 = n; 417 float n1 = n;
414 while(n >= 1024 && quant[idx] != QString::null) { 418 while(n >= 1024 && quant[idx] != QString::null) {
415 idx++; 419 idx++;
416 n /= 1024; 420 n /= 1024;
417 } 421 }
418 422
419 int i = idx; 423 int i = idx;
420 while(i--) 424 while(i--)
421 n1 = n1 / 1024.0; 425 n1 = n1 / 1024.0;
422 426
423 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); 427 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
424 s += " " + quant[idx]; 428 s += " " + quant[idx];
425 return s; 429 return s;
426} 430}
427 431
428 432
429///////////////////////////////////////////////////////////////////////////// 433/////////////////////////////////////////////////////////////////////////////
430// 434//
431// Queries the user what to reset: costs, volume or both 435// Queries the user what to reset: costs, volume or both
432// 436//
433///////////////////////////////////////////////////////////////////////////// 437/////////////////////////////////////////////////////////////////////////////
434QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { 438QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
435// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 439// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
436 setCaption(i18n("Reset Accounting")); 440 setCaption(i18n("Reset Accounting"));
437 441
438 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 442 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
439 QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this); 443 QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this);
440 444
441 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 445 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
442// costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f); 446// costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f);
443// costs->setChecked(true); 447// costs->setChecked(true);
444// l1->addWidget(costs); 448// l1->addWidget(costs);
445// QWhatsThis::add(costs, i18n("Check this to set the phone costs\n" 449// QWhatsThis::add(costs, i18n("Check this to set the phone costs\n"
446 // "to zero. Typically you'll want to\n" 450 // "to zero. Typically you'll want to\n"
447 // "do this once a month.")); 451 // "do this once a month."));
448 452
449// volume = new QCheckBox(i18n("Reset volume accounting"), f); 453// volume = new QCheckBox(i18n("Reset volume accounting"), f);
450// volume->setChecked(true); 454// volume->setChecked(true);
451// l1->addWidget(volume); 455// l1->addWidget(volume);
452// QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n" 456// QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n"
453 // "to zero. Typically you'll want to do this\n" 457 // "to zero. Typically you'll want to do this\n"
454 // "once a month.")); 458 // "once a month."));
455 459
456 l1->activate(); 460 l1->activate();
457 461
458 // this activates the f-layout and sets minimumSize() 462 // this activates the f-layout and sets minimumSize()
459 f->show(); 463 f->show();
460 464
461 tl->addWidget(f); 465 tl->addWidget(f);
462 466
463 QButtonGroup *bbox = new QButtonGroup(this); 467 QButtonGroup *bbox = new QButtonGroup(this);
464// bbox->addStretch(1); 468// bbox->addStretch(1);
465 QPushButton *ok = new QPushButton( bbox, i18n("OK") ); 469 QPushButton *ok = new QPushButton( bbox, i18n("OK") );
466 bbox->insert(ok); 470 bbox->insert(ok);
467 ok->setDefault(true); 471 ok->setDefault(true);
468 QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") ); 472 QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") );
469 bbox->insert(cancel); 473 bbox->insert(cancel);
470 474
471 connect(ok, SIGNAL(clicked()), 475 connect(ok, SIGNAL(clicked()),
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index b7e229e..a3eda9d 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -86,863 +86,863 @@ ConnectWidget::ConnectWidget(QWidget *parent, const char *name)
86 myreadbuffer(""), 86 myreadbuffer(""),
87 main_timer_ID(0), 87 main_timer_ID(0),
88 vmain(0), 88 vmain(0),
89 substate(-1), 89 substate(-1),
90 scriptindex(0), 90 scriptindex(0),
91 loopnest(0), 91 loopnest(0),
92 loopend(false), 92 loopend(false),
93 semaphore(false), 93 semaphore(false),
94 expecting(false), 94 expecting(false),
95 readbuffer(""), 95 readbuffer(""),
96 scanvar(""), 96 scanvar(""),
97 scanning(false), 97 scanning(false),
98 pausing(false), 98 pausing(false),
99// termwindow(0), 99// termwindow(0),
100// stats(st), 100// stats(st),
101 dialnumber(0) 101 dialnumber(0)
102{ 102{
103 modified_hostname = false; 103 modified_hostname = false;
104 104
105 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); 105 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
106 QString tit = i18n("Connecting to: "); 106 QString tit = i18n("Connecting to: ");
107 setCaption(tit); 107 setCaption(tit);
108 108
109 QHBoxLayout *l0 = new QHBoxLayout(10); 109 QHBoxLayout *l0 = new QHBoxLayout(10);
110 tl->addLayout(l0); 110 tl->addLayout(l0);
111 l0->addSpacing(10); 111 l0->addSpacing(10);
112 messg = new QLabel(this, "messg"); 112 messg = new QLabel(this, "messg");
113 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 113 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
114 messg->setAlignment(AlignCenter); 114 messg->setAlignment(AlignCenter);
115 messg->setText(i18n("Unable to create modem lock file.")); 115 messg->setText(i18n("Unable to create modem lock file."));
116 messg->setMinimumHeight(messg->sizeHint().height() + 5); 116 messg->setMinimumHeight(messg->sizeHint().height() + 5);
117 int messw = (messg->sizeHint().width() * 12) / 10; 117 int messw = (messg->sizeHint().width() * 12) / 10;
118 messw = QMAX(messw,280); 118 messw = QMAX(messw,280);
119 messg->setMinimumWidth(messw); 119 messg->setMinimumWidth(messw);
120 messg->setText(i18n("Looking for modem...")); 120 messg->setText(i18n("Looking for modem..."));
121 l0->addSpacing(10); 121 l0->addSpacing(10);
122 l0->addWidget(messg); 122 l0->addWidget(messg);
123 l0->addSpacing(10); 123 l0->addSpacing(10);
124 124
125 QHBoxLayout *l1 = new QHBoxLayout(10); 125 QHBoxLayout *l1 = new QHBoxLayout(10);
126 tl->addLayout(l1); 126 tl->addLayout(l1);
127 l1->addStretch(1); 127 l1->addStretch(1);
128 128
129 debug = new QPushButton(i18n("Log"), this); 129 debug = new QPushButton(i18n("Log"), this);
130 debug->setToggleButton(true); 130 debug->setToggleButton(true);
131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); 131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
132 132
133 cancel = new QPushButton(i18n("Cancel"), this); 133 cancel = new QPushButton(i18n("Cancel"), this);
134 cancel->setFocus(); 134 cancel->setFocus();
135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); 135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
136 136
137 int maxw = QMAX(cancel->sizeHint().width(), 137 int maxw = QMAX(cancel->sizeHint().width(),
138 debug->sizeHint().width()); 138 debug->sizeHint().width());
139 maxw = QMAX(maxw,65); 139 maxw = QMAX(maxw,65);
140 debug->setFixedWidth(maxw); 140 debug->setFixedWidth(maxw);
141 cancel->setFixedWidth(maxw); 141 cancel->setFixedWidth(maxw);
142 l1->addWidget(debug); 142 l1->addWidget(debug);
143 l1->addWidget(cancel); 143 l1->addWidget(cancel);
144 144
145 setFixedSize(sizeHint()); 145 setFixedSize(sizeHint());
146 146
147 pausetimer = new QTimer(this); 147 pausetimer = new QTimer(this);
148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); 148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
149 149
150 qApp->processEvents(); 150 qApp->processEvents();
151 151
152 timeout_timer = new QTimer(this); 152 timeout_timer = new QTimer(this);
153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); 153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
154 154
155 inittimer = new QTimer(this); 155 inittimer = new QTimer(this);
156 connect(inittimer, SIGNAL(timeout()), SLOT(init())); 156 connect(inittimer, SIGNAL(timeout()), SLOT(init()));
157 157
158 if_timeout_timer = new QTimer(this); 158 if_timeout_timer = new QTimer(this);
159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); 159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
160 160
161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); 161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
162 162
163 prompt = new PWEntry( this, "pw" ); 163 prompt = new PWEntry( this, "pw" );
164 if_timer = new QTimer(this); 164 if_timer = new QTimer(this);
165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); 165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
166} 166}
167 167
168 168
169ConnectWidget::~ConnectWidget() { 169ConnectWidget::~ConnectWidget() {
170} 170}
171 171
172 172
173void ConnectWidget::preinit() { 173void ConnectWidget::preinit() {
174 // this is all just to keep the GUI nice and snappy .... 174 // this is all just to keep the GUI nice and snappy ....
175 // you have to see to believe ... 175 // you have to see to believe ...
176 messg->setText(i18n("Looking for modem...")); 176 messg->setText(i18n("Looking for modem..."));
177 inittimer->start(100); 177 inittimer->start(100);
178} 178}
179 179
180 180
181void ConnectWidget::init() { 181void ConnectWidget::init() {
182 gpppdata.setpppdError(0); 182 PPPData::data()->setpppdError(0);
183 inittimer->stop(); 183 inittimer->stop();
184 vmain = 0; 184 vmain = 0;
185 substate = -1; 185 substate = -1;
186 expecting = false; 186 expecting = false;
187 pausing = false; 187 pausing = false;
188 scriptindex = 0; 188 scriptindex = 0;
189 myreadbuffer = ""; 189 myreadbuffer = "";
190 scanning = false; 190 scanning = false;
191 scanvar = ""; 191 scanvar = "";
192 firstrunID = true; 192 firstrunID = true;
193 firstrunPW = true; 193 firstrunPW = true;
194// stats->totalbytes = 0; 194// stats->totalbytes = 0;
195 dialnumber = 0; 195 dialnumber = 0;
196 196
197 p_kppp->con_speed = ""; 197 p_kppp->con_speed = "";
198 198
199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || gpppdata.quit_on_disconnect()); 199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect());
200 200
201 comlist = &gpppdata.scriptType(); 201 comlist = &PPPData::data()->scriptType();
202 arglist = &gpppdata.script(); 202 arglist = &PPPData::data()->script();
203 203
204 QString tit = i18n("Connecting to: %1").arg(gpppdata.accname()); 204 QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
205 setCaption(tit); 205 setCaption(tit);
206 206
207 qApp->processEvents(); 207 qApp->processEvents();
208 208
209 // run the "before-connect" command 209 // run the "before-connect" command
210 if (!gpppdata.command_before_connect().isEmpty()) { 210 if (!PPPData::data()->command_before_connect().isEmpty()) {
211 messg->setText(i18n("Running pre-startup command...")); 211 messg->setText(i18n("Running pre-startup command..."));
212 emit debugMessage(i18n("Running pre-startup command...")); 212 emit debugMessage(i18n("Running pre-startup command..."));
213 213
214 qApp->processEvents(); 214 qApp->processEvents();
215 QApplication::flushX(); 215 QApplication::flushX();
216 pid_t id = execute_command(gpppdata.command_before_connect()); 216 pid_t id = execute_command(PPPData::data()->command_before_connect());
217// int i, status; 217// int i, status;
218 218
219// do { 219// do {
220// qApp->processEvents(); 220// qApp->processEvents();
221// i = waitpid(id, &status, WNOHANG); 221// i = waitpid(id, &status, WNOHANG);
222// usleep(100000); 222// usleep(100000);
223// } while (i == 0 && errno == 0); 223// } while (i == 0 && errno == 0);
224 } 224 }
225 225
226 int lock = Modem::modem->lockdevice(); 226 int lock = Modem::modem->lockdevice();
227 227
228 if (lock == 1) { 228 if (lock == 1) {
229 messg->setText(i18n("Modem device is locked.")); 229 messg->setText(i18n("Modem device is locked."));
230 vmain = 20; // wait until cancel is pressed 230 vmain = 20; // wait until cancel is pressed
231 return; 231 return;
232 } 232 }
233 233
234 if (lock == -1) { 234 if (lock == -1) {
235 messg->setText(i18n("Unable to create modem lock file.")); 235 messg->setText(i18n("Unable to create modem lock file."));
236 vmain = 20; // wait until cancel is pressed 236 vmain = 20; // wait until cancel is pressed
237 return; 237 return;
238 } 238 }
239 239
240 if(Modem::modem->opentty()) { 240 if(Modem::modem->opentty()) {
241 messg->setText(Modem::modem->modemMessage()); 241 messg->setText(Modem::modem->modemMessage());
242 qApp->processEvents(); 242 qApp->processEvents();
243 if(Modem::modem->hangup()) { 243 if(Modem::modem->hangup()) {
244 244
245 qApp->processEvents(); 245 qApp->processEvents();
246 246
247 semaphore = false; 247 semaphore = false;
248 248
249 Modem::modem->stop(); 249 Modem::modem->stop();
250 Modem::modem->notify(this, SLOT(readChar(unsigned char))); 250 Modem::modem->notify(this, SLOT(readChar(unsigned char)));
251 251
252 // if we are stuck anywhere we will time out 252 // if we are stuck anywhere we will time out
253 timeout_timer->start(gpppdata.modemTimeout()*1000); 253 timeout_timer->start(PPPData::data()->modemTimeout()*1000);
254 254
255 // this timer will run the script etc. 255 // this timer will run the script etc.
256 main_timer_ID = startTimer(10); 256 main_timer_ID = startTimer(10);
257 257
258 return; 258 return;
259 } 259 }
260 } 260 }
261 261
262 // initialization failed 262 // initialization failed
263 messg->setText(Modem::modem->modemMessage()); 263 messg->setText(Modem::modem->modemMessage());
264 vmain = 20; // wait until cancel is pressed 264 vmain = 20; // wait until cancel is pressed
265 Modem::modem->unlockdevice(); 265 Modem::modem->unlockdevice();
266} 266}
267 267
268 268
269void ConnectWidget::timerEvent(QTimerEvent *) { 269void ConnectWidget::timerEvent(QTimerEvent *) {
270 if (semaphore || pausing) 270 if (semaphore || pausing)
271 return; 271 return;
272 272
273 if(vmain == 0) { 273 if(vmain == 0) {
274#ifdef DEBUG_WO_DIALING 274#ifdef DEBUG_WO_DIALING
275 vmain = 10; 275 vmain = 10;
276 return; 276 return;
277#endif 277#endif
278 278
279 assert(PPPData::NumInitStrings > 0); 279 assert(PPPData::NumInitStrings > 0);
280 // first init string ? 280 // first init string ?
281 if(substate == -1) { 281 if(substate == -1) {
282 messg->setText(i18n("Initializing modem...")); 282 messg->setText(i18n("Initializing modem..."));
283 emit debugMessage(i18n("Initializing modem...")); 283 emit debugMessage(i18n("Initializing modem..."));
284 substate = 0; 284 substate = 0;
285 } 285 }
286 286
287 QString initStr = gpppdata.modemInitStr(substate); 287 QString initStr = PPPData::data()->modemInitStr(substate);
288 if (!initStr.isEmpty()) { 288 if (!initStr.isEmpty()) {
289 // send a carriage return and then wait a bit so that the modem will 289 // send a carriage return and then wait a bit so that the modem will
290 // let us issue commands. 290 // let us issue commands.
291 if(gpppdata.modemPreInitDelay() > 0) { 291 if(PPPData::data()->modemPreInitDelay() > 0) {
292 usleep(gpppdata.modemPreInitDelay() * 5000); 292 usleep(PPPData::data()->modemPreInitDelay() * 5000);
293 writeline(""); 293 writeline("");
294 usleep(gpppdata.modemPreInitDelay() * 5000); 294 usleep(PPPData::data()->modemPreInitDelay() * 5000);
295 } 295 }
296 setExpect(gpppdata.modemInitResp()); 296 setExpect(PPPData::data()->modemInitResp());
297 writeline(initStr); 297 writeline(initStr);
298 usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec 298 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
299 } 299 }
300 300
301 substate++; 301 substate++;
302 302
303 /* 303 /*
304 * FIXME after 3.0: Make it possible to disable ATS11 since it 304 * FIXME after 3.0: Make it possible to disable ATS11 since it
305 * seems to be incompatible with some ISDN adapters (e.g. DataBox 305 * seems to be incompatible with some ISDN adapters (e.g. DataBox
306 * Speed Dragon). Even better would be to detect this when doing 306 * Speed Dragon). Even better would be to detect this when doing
307 * a "Modem Query" 307 * a "Modem Query"
308 */ 308 */
309 if (MODEM_TONEDURATION != gpppdata.modemToneDuration()) 309 if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration())
310 vmain = 5; 310 vmain = 5;
311 else 311 else
312 vmain = 3; 312 vmain = 3;
313 313
314 return; 314 return;
315 } 315 }
316 316
317 if (vmain == 5) { 317 if (vmain == 5) {
318 if(!expecting) { 318 if(!expecting) {
319 QString sToneDuration = "ATS11=" + QString::number(gpppdata.modemToneDuration()); 319 QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration());
320 QString msg = i18n("Setting ") + sToneDuration; 320 QString msg = i18n("Setting ") + sToneDuration;
321 messg->setText(msg); 321 messg->setText(msg);
322 emit debugMessage(msg); 322 emit debugMessage(msg);
323 setExpect(gpppdata.modemInitResp()); 323 setExpect(PPPData::data()->modemInitResp());
324 writeline(sToneDuration); 324 writeline(sToneDuration);
325 } 325 }
326 vmain = 3; 326 vmain = 3;
327 return; 327 return;
328 } 328 }
329 329
330 if(vmain == 3) { 330 if(vmain == 3) {
331 if(!expecting) { 331 if(!expecting) {
332 // done with all init strings ? 332 // done with all init strings ?
333 if(substate < PPPData::NumInitStrings) { 333 if(substate < PPPData::NumInitStrings) {
334 vmain = 0; 334 vmain = 0;
335 return; 335 return;
336 } 336 }
337 substate = -1; 337 substate = -1;
338 // skip setting the volume if command is empty 338 // skip setting the volume if command is empty
339 if(gpppdata.volumeInitString().isEmpty()) { 339 if(PPPData::data()->volumeInitString().isEmpty()) {
340 vmain = 4; 340 vmain = 4;
341 return; 341 return;
342 } 342 }
343 messg->setText(i18n("Setting speaker volume...")); 343 messg->setText(i18n("Setting speaker volume..."));
344 emit debugMessage(i18n("Setting speaker volume...")); 344 emit debugMessage(i18n("Setting speaker volume..."));
345 345
346 setExpect(gpppdata.modemInitResp()); 346 setExpect(PPPData::data()->modemInitResp());
347 QString vol("AT"); 347 QString vol("AT");
348 vol += gpppdata.volumeInitString(); 348 vol += PPPData::data()->volumeInitString();
349 writeline(vol); 349 writeline(vol);
350 usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec 350 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
351 vmain = 4; 351 vmain = 4;
352 return; 352 return;
353 } 353 }
354 } 354 }
355 355
356 if(vmain == 4) { 356 if(vmain == 4) {
357 if(!expecting) { 357 if(!expecting) {
358 if(!gpppdata.waitForDialTone()) { 358 if(!PPPData::data()->waitForDialTone()) {
359 QString msg = i18n("Turning off dial tone waiting..."); 359 QString msg = i18n("Turning off dial tone waiting...");
360 messg->setText(msg); 360 messg->setText(msg);
361 emit debugMessage(msg); 361 emit debugMessage(msg);
362 setExpect(gpppdata.modemInitResp()); 362 setExpect(PPPData::data()->modemInitResp());
363 writeline(gpppdata.modemNoDialToneDetectionStr()); 363 writeline(PPPData::data()->modemNoDialToneDetectionStr());
364 } 364 }
365 vmain = 1; 365 vmain = 1;
366 return; 366 return;
367 } 367 }
368 } 368 }
369 369
370 // dial the number and wait to connect 370 // dial the number and wait to connect
371 if(vmain == 1) { 371 if(vmain == 1) {
372 if(!expecting) { 372 if(!expecting) {
373 373
374 timeout_timer->stop(); 374 timeout_timer->stop();
375 timeout_timer->start(gpppdata.modemTimeout()*1000); 375 timeout_timer->start(PPPData::data()->modemTimeout()*1000);
376 376
377 QStringList &plist = gpppdata.phonenumbers(); 377 QStringList &plist = PPPData::data()->phonenumbers();
378 QString bmarg= gpppdata.dialPrefix(); 378 QString bmarg= PPPData::data()->dialPrefix();
379 bmarg += *plist.at(dialnumber); 379 bmarg += *plist.at(dialnumber);
380 QString bm = i18n("Dialing %1").arg(bmarg); 380 QString bm = i18n("Dialing %1").arg(bmarg);
381 messg->setText(bm); 381 messg->setText(bm);
382 emit debugMessage(bm); 382 emit debugMessage(bm);
383 383
384 QString pn = gpppdata.modemDialStr(); 384 QString pn = PPPData::data()->modemDialStr();
385 pn += gpppdata.dialPrefix(); 385 pn += PPPData::data()->dialPrefix();
386 pn += *plist.at(dialnumber); 386 pn += *plist.at(dialnumber);
387 if(++dialnumber >= plist.count()) 387 if(++dialnumber >= plist.count())
388 dialnumber = 0; 388 dialnumber = 0;
389 writeline(pn); 389 writeline(pn);
390 390
391 setExpect(gpppdata.modemConnectResp()); 391 setExpect(PPPData::data()->modemConnectResp());
392 vmain = 100; 392 vmain = 100;
393 return; 393 return;
394 } 394 }
395 } 395 }
396 396
397 // wait for connect, but redial if BUSY or wait for user cancel 397 // wait for connect, but redial if BUSY or wait for user cancel
398 // if NO CARRIER or NO DIALTONE 398 // if NO CARRIER or NO DIALTONE
399 if(vmain == 100) { 399 if(vmain == 100) {
400 if(!expecting) { 400 if(!expecting) {
401 myreadbuffer = gpppdata.modemConnectResp(); 401 myreadbuffer = PPPData::data()->modemConnectResp();
402 setExpect("\n"); 402 setExpect("\n");
403 vmain = 101; 403 vmain = 101;
404 return; 404 return;
405 } 405 }
406 406
407 if(readbuffer.contains(gpppdata.modemBusyResp())) { 407 if(readbuffer.contains(PPPData::data()->modemBusyResp())) {
408 timeout_timer->stop(); 408 timeout_timer->stop();
409 timeout_timer->start(gpppdata.modemTimeout()*1000); 409 timeout_timer->start(PPPData::data()->modemTimeout()*1000);
410 410
411 messg->setText(i18n("Line busy. Hanging up...")); 411 messg->setText(i18n("Line busy. Hanging up..."));
412 emit debugPutChar('\n'); 412 emit debugPutChar('\n');
413 Modem::modem->hangup(); 413 Modem::modem->hangup();
414 414
415 if(gpppdata.busyWait() > 0) { 415 if(PPPData::data()->busyWait() > 0) {
416 QString bm = i18n("Line busy. Waiting: %1 seconds").arg(gpppdata.busyWait()); 416 QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait());
417 messg->setText(bm); 417 messg->setText(bm);
418 emit debugMessage(bm); 418 emit debugMessage(bm);
419 419
420 pausing = true; 420 pausing = true;
421 421
422 pausetimer->start(gpppdata.busyWait()*1000, true); 422 pausetimer->start(PPPData::data()->busyWait()*1000, true);
423 timeout_timer->stop(); 423 timeout_timer->stop();
424 } 424 }
425 425
426 Modem::modem->setDataMode(false); 426 Modem::modem->setDataMode(false);
427 vmain = 0; 427 vmain = 0;
428 substate = -1; 428 substate = -1;
429 return; 429 return;
430 } 430 }
431 431
432 if(readbuffer.contains(gpppdata.modemNoDialtoneResp())) { 432 if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) {
433 timeout_timer->stop(); 433 timeout_timer->stop();
434 434
435 messg->setText(i18n("No Dialtone")); 435 messg->setText(i18n("No Dialtone"));
436 vmain = 20; 436 vmain = 20;
437 Modem::modem->unlockdevice(); 437 Modem::modem->unlockdevice();
438 return; 438 return;
439 } 439 }
440 440
441 if(readbuffer.contains(gpppdata.modemNoCarrierResp())) { 441 if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) {
442 timeout_timer->stop(); 442 timeout_timer->stop();
443 443
444 messg->setText(i18n("No Carrier")); 444 messg->setText(i18n("No Carrier"));
445 vmain = 20; 445 vmain = 20;
446 Modem::modem->unlockdevice(); 446 Modem::modem->unlockdevice();
447 return; 447 return;
448 } 448 }
449 } 449 }
450 450
451 // wait for newline after CONNECT response (so we get the speed) 451 // wait for newline after CONNECT response (so we get the speed)
452 if(vmain == 101) { 452 if(vmain == 101) {
453 if(!expecting) { 453 if(!expecting) {
454 Modem::modem->setDataMode(true); // modem will no longer respond to AT commands 454 Modem::modem->setDataMode(true); // modem will no longer respond to AT commands
455 455
456 emit startAccounting(); 456 emit startAccounting();
457// p_kppp->con_win->startClock(); 457// p_kppp->con_win->startClock();
458 458
459 vmain = 2; 459 vmain = 2;
460 scriptTimeout=gpppdata.modemTimeout()*1000; 460 scriptTimeout=PPPData::data()->modemTimeout()*1000;
461 return; 461 return;
462 } 462 }
463 } 463 }
464 464
465 // execute the script 465 // execute the script
466 if(vmain == 2) { 466 if(vmain == 2) {
467 if(!expecting && !pausing && !scanning) { 467 if(!expecting && !pausing && !scanning) {
468 468
469 timeout_timer->stop(); 469 timeout_timer->stop();
470 timeout_timer->start(scriptTimeout); 470 timeout_timer->start(scriptTimeout);
471 471
472 if((unsigned) scriptindex < comlist->count()) { 472 if((unsigned) scriptindex < comlist->count()) {
473 scriptCommand = *(comlist->at(scriptindex)); 473 scriptCommand = *(comlist->at(scriptindex));
474 scriptArgument = *(arglist->at(scriptindex)); 474 scriptArgument = *(arglist->at(scriptindex));
475 } else { 475 } else {
476 qDebug( "End of script" ); 476 qDebug( "End of script" );
477 vmain = 10; 477 vmain = 10;
478 return; 478 return;
479 } 479 }
480 480
481 if (scriptCommand == "Scan") { 481 if (scriptCommand == "Scan") {
482 QString bm = i18n("Scanning %1").arg(scriptArgument); 482 QString bm = i18n("Scanning %1").arg(scriptArgument);
483 messg->setText(bm); 483 messg->setText(bm);
484 emit debugMessage(bm); 484 emit debugMessage(bm);
485 485
486 setScan(scriptArgument); 486 setScan(scriptArgument);
487 scriptindex++; 487 scriptindex++;
488 return; 488 return;
489 } 489 }
490 490
491 if (scriptCommand == "Save") { 491 if (scriptCommand == "Save") {
492 QString bm = i18n("Saving %1").arg(scriptArgument); 492 QString bm = i18n("Saving %1").arg(scriptArgument);
493 messg->setText(bm); 493 messg->setText(bm);
494 emit debugMessage(bm); 494 emit debugMessage(bm);
495 495
496 if (scriptArgument.lower() == "password") { 496 if (scriptArgument.lower() == "password") {
497 gpppdata.setPassword(scanvar); 497 PPPData::data()->setPassword(scanvar);
498 p_kppp->setPW_Edit(scanvar); 498 p_kppp->setPW_Edit(scanvar);
499 if(gpppdata.storePassword()) 499 if(PPPData::data()->storePassword())
500 gpppdata.setStoredPassword(scanvar); 500 PPPData::data()->setStoredPassword(scanvar);
501 firstrunPW = true; 501 firstrunPW = true;
502 } 502 }
503 503
504 scriptindex++; 504 scriptindex++;
505 return; 505 return;
506 } 506 }
507 507
508 508
509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
510 QString bm = i18n("Sending %1"); 510 QString bm = i18n("Sending %1");
511 511
512 // replace %USERNAME% and %PASSWORD% 512 // replace %USERNAME% and %PASSWORD%
513 QString arg = scriptArgument; 513 QString arg = scriptArgument;
514 QRegExp re1("%USERNAME%"); 514 QRegExp re1("%USERNAME%");
515 QRegExp re2("%PASSWORD%"); 515 QRegExp re2("%PASSWORD%");
516 arg = arg.replace(re1, gpppdata.storedUsername()); 516 arg = arg.replace(re1, PPPData::data()->storedUsername());
517 arg = arg.replace(re2, gpppdata.storedPassword()); 517 arg = arg.replace(re2, PPPData::data()->storedPassword());
518 518
519 if (scriptCommand == "Send") 519 if (scriptCommand == "Send")
520 bm = bm.arg(scriptArgument); 520 bm = bm.arg(scriptArgument);
521 else { 521 else {
522 for(uint i = 0; i < scriptArgument.length(); i++) 522 for(uint i = 0; i < scriptArgument.length(); i++)
523 bm = bm.arg("*"); 523 bm = bm.arg("*");
524 } 524 }
525 525
526 messg->setText(bm); 526 messg->setText(bm);
527 emit debugMessage(bm); 527 emit debugMessage(bm);
528 528
529 writeline(scriptArgument); 529 writeline(scriptArgument);
530 scriptindex++; 530 scriptindex++;
531 return; 531 return;
532 } 532 }
533 533
534 if (scriptCommand == "Expect") { 534 if (scriptCommand == "Expect") {
535 QString bm = i18n("Expecting %1").arg(scriptArgument); 535 QString bm = i18n("Expecting %1").arg(scriptArgument);
536 messg->setText(bm); 536 messg->setText(bm);
537 emit debugMessage(bm); 537 emit debugMessage(bm);
538 538
539 // The incrementing of the scriptindex MUST be before the 539 // The incrementing of the scriptindex MUST be before the
540 // call to setExpect otherwise the expect will miss a string that is 540 // call to setExpect otherwise the expect will miss a string that is
541 // already in the buffer. 541 // already in the buffer.
542 scriptindex++; 542 scriptindex++;
543 setExpect(scriptArgument); 543 setExpect(scriptArgument);
544 return; 544 return;
545 } 545 }
546 546
547 547
548 if (scriptCommand == "Pause") { 548 if (scriptCommand == "Pause") {
549 QString bm = i18n("Pause %1 seconds").arg(scriptArgument); 549 QString bm = i18n("Pause %1 seconds").arg(scriptArgument);
550 messg->setText(bm); 550 messg->setText(bm);
551 emit debugMessage(bm); 551 emit debugMessage(bm);
552 552
553 pausing = true; 553 pausing = true;
554 554
555 pausetimer->start(scriptArgument.toInt()*1000, true); 555 pausetimer->start(scriptArgument.toInt()*1000, true);
556 timeout_timer->stop(); 556 timeout_timer->stop();
557 557
558 scriptindex++; 558 scriptindex++;
559 return; 559 return;
560 } 560 }
561 561
562 if (scriptCommand == "Timeout") { 562 if (scriptCommand == "Timeout") {
563 563
564 timeout_timer->stop(); 564 timeout_timer->stop();
565 565
566 QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); 566 QString bm = i18n("Timeout %1 seconds").arg(scriptArgument);
567 messg->setText(bm); 567 messg->setText(bm);
568 emit debugMessage(bm); 568 emit debugMessage(bm);
569 569
570 scriptTimeout=scriptArgument.toInt()*1000; 570 scriptTimeout=scriptArgument.toInt()*1000;
571 timeout_timer->start(scriptTimeout); 571 timeout_timer->start(scriptTimeout);
572 572
573 scriptindex++; 573 scriptindex++;
574 return; 574 return;
575 } 575 }
576 576
577 if (scriptCommand == "Hangup") { 577 if (scriptCommand == "Hangup") {
578 messg->setText(i18n("Hangup")); 578 messg->setText(i18n("Hangup"));
579 emit debugMessage(i18n("Hangup")); 579 emit debugMessage(i18n("Hangup"));
580 580
581 writeline(gpppdata.modemHangupStr()); 581 writeline(PPPData::data()->modemHangupStr());
582 setExpect(gpppdata.modemHangupResp()); 582 setExpect(PPPData::data()->modemHangupResp());
583 583
584 scriptindex++; 584 scriptindex++;
585 return; 585 return;
586 } 586 }
587 587
588 if (scriptCommand == "Answer") { 588 if (scriptCommand == "Answer") {
589 589
590 timeout_timer->stop(); 590 timeout_timer->stop();
591 591
592 messg->setText(i18n("Answer")); 592 messg->setText(i18n("Answer"));
593 emit debugMessage(i18n("Answer")); 593 emit debugMessage(i18n("Answer"));
594 594
595 setExpect(gpppdata.modemRingResp()); 595 setExpect(PPPData::data()->modemRingResp());
596 vmain = 150; 596 vmain = 150;
597 return; 597 return;
598 } 598 }
599 599
600 if (scriptCommand == "ID") { 600 if (scriptCommand == "ID") {
601 QString bm = i18n("ID %1").arg(scriptArgument); 601 QString bm = i18n("ID %1").arg(scriptArgument);
602 messg->setText(bm); 602 messg->setText(bm);
603 emit debugMessage(bm); 603 emit debugMessage(bm);
604 604
605 QString idstring = gpppdata.storedUsername(); 605 QString idstring = PPPData::data()->storedUsername();
606 606
607 if(!idstring.isEmpty() && firstrunID) { 607 if(!idstring.isEmpty() && firstrunID) {
608 // the user entered an Id on the main kppp dialog 608 // the user entered an Id on the main kppp dialog
609 writeline(idstring); 609 writeline(idstring);
610 firstrunID = false; 610 firstrunID = false;
611 scriptindex++; 611 scriptindex++;
612 } 612 }
613 else { 613 else {
614 // the user didn't enter and Id on the main kppp dialog 614 // the user didn't enter and Id on the main kppp dialog
615 // let's query for an ID 615 // let's query for an ID
616 /* if not around yet, then post window... */ 616 /* if not around yet, then post window... */
617 if (prompt->Consumed()) { 617 if (prompt->Consumed()) {
618 if (!(prompt->isVisible())) { 618 if (!(prompt->isVisible())) {
619 prompt->setPrompt(scriptArgument); 619 prompt->setPrompt(scriptArgument);
620 prompt->setEchoModeNormal(); 620 prompt->setEchoModeNormal();
621 prompt->show(); 621 prompt->show();
622 } 622 }
623 } else { 623 } else {
624 /* if prompt withdrawn ... then, */ 624 /* if prompt withdrawn ... then, */
625 if(!(prompt->isVisible())) { 625 if(!(prompt->isVisible())) {
626 writeline(prompt->text()); 626 writeline(prompt->text());
627 prompt->setConsumed(); 627 prompt->setConsumed();
628 scriptindex++; 628 scriptindex++;
629 return; 629 return;
630 } 630 }
631 /* replace timeout value */ 631 /* replace timeout value */
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 if (scriptCommand == "Password") { 636 if (scriptCommand == "Password") {
637 QString bm = i18n("Password %1").arg(scriptArgument); 637 QString bm = i18n("Password %1").arg(scriptArgument);
638 messg->setText(bm); 638 messg->setText(bm);
639 emit debugMessage(bm); 639 emit debugMessage(bm);
640 640
641 QString pwstring = gpppdata.password(); 641 QString pwstring = PPPData::data()->password();
642 642
643 if(!pwstring.isEmpty() && firstrunPW) { 643 if(!pwstring.isEmpty() && firstrunPW) {
644 // the user entered a password on the main kppp dialog 644 // the user entered a password on the main kppp dialog
645 writeline(pwstring); 645 writeline(pwstring);
646 firstrunPW = false; 646 firstrunPW = false;
647 scriptindex++; 647 scriptindex++;
648 } 648 }
649 else { 649 else {
650 // the user didn't enter a password on the main kppp dialog 650 // the user didn't enter a password on the main kppp dialog
651 // let's query for a password 651 // let's query for a password
652 /* if not around yet, then post window... */ 652 /* if not around yet, then post window... */
653 if (prompt->Consumed()) { 653 if (prompt->Consumed()) {
654 if (!(prompt->isVisible())) { 654 if (!(prompt->isVisible())) {
655 prompt->setPrompt(scriptArgument); 655 prompt->setPrompt(scriptArgument);
656 prompt->setEchoModePassword(); 656 prompt->setEchoModePassword();
657 prompt->show(); 657 prompt->show();
658 } 658 }
659 } else { 659 } else {
660 /* if prompt withdrawn ... then, */ 660 /* if prompt withdrawn ... then, */
661 if(!(prompt->isVisible())) { 661 if(!(prompt->isVisible())) {
662 p_kppp->setPW_Edit(prompt->text()); 662 p_kppp->setPW_Edit(prompt->text());
663 writeline(prompt->text()); 663 writeline(prompt->text());
664 prompt->setConsumed(); 664 prompt->setConsumed();
665 scriptindex++; 665 scriptindex++;
666 return; 666 return;
667 } 667 }
668 /* replace timeout value */ 668 /* replace timeout value */
669 } 669 }
670 } 670 }
671 } 671 }
672 672
673 if (scriptCommand == "Prompt") { 673 if (scriptCommand == "Prompt") {
674 QString bm = i18n("Prompting %1"); 674 QString bm = i18n("Prompting %1");
675 675
676 // if the scriptindex (aka the prompt text) includes a ## marker 676 // if the scriptindex (aka the prompt text) includes a ## marker
677 // this marker should get substituted with the contents of our stored 677 // this marker should get substituted with the contents of our stored
678 // variable (from the subsequent scan). 678 // variable (from the subsequent scan).
679 679
680 QString ts = scriptArgument; 680 QString ts = scriptArgument;
681 int vstart = ts.find( "##" ); 681 int vstart = ts.find( "##" );
682 if( vstart != -1 ) { 682 if( vstart != -1 ) {
683 ts.remove( vstart, 2 ); 683 ts.remove( vstart, 2 );
684 ts.insert( vstart, scanvar ); 684 ts.insert( vstart, scanvar );
685 } 685 }
686 686
687 bm = bm.arg(ts); 687 bm = bm.arg(ts);
688 messg->setText(bm); 688 messg->setText(bm);
689 emit debugMessage(bm); 689 emit debugMessage(bm);
690 690
691 /* if not around yet, then post window... */ 691 /* if not around yet, then post window... */
692 if (prompt->Consumed()) { 692 if (prompt->Consumed()) {
693 if (!(prompt->isVisible())) { 693 if (!(prompt->isVisible())) {
694 prompt->setPrompt( ts ); 694 prompt->setPrompt( ts );
695 prompt->setEchoModeNormal(); 695 prompt->setEchoModeNormal();
696 prompt->show(); 696 prompt->show();
697 } 697 }
698 } else { 698 } else {
699 /* if prompt withdrawn ... then, */ 699 /* if prompt withdrawn ... then, */
700 if (!(prompt->isVisible())) { 700 if (!(prompt->isVisible())) {
701 writeline(prompt->text()); 701 writeline(prompt->text());
702 prompt->setConsumed(); 702 prompt->setConsumed();
703 scriptindex++; 703 scriptindex++;
704 return; 704 return;
705 } 705 }
706 /* replace timeout value */ 706 /* replace timeout value */
707 } 707 }
708 } 708 }
709 709
710 if (scriptCommand == "PWPrompt") { 710 if (scriptCommand == "PWPrompt") {
711 QString bm = i18n("PW Prompt %1").arg(scriptArgument); 711 QString bm = i18n("PW Prompt %1").arg(scriptArgument);
712 messg->setText(bm); 712 messg->setText(bm);
713 emit debugMessage(bm); 713 emit debugMessage(bm);
714 714
715 /* if not around yet, then post window... */ 715 /* if not around yet, then post window... */
716 if (prompt->Consumed()) { 716 if (prompt->Consumed()) {
717 if (!(prompt->isVisible())) { 717 if (!(prompt->isVisible())) {
718 prompt->setPrompt(scriptArgument); 718 prompt->setPrompt(scriptArgument);
719 prompt->setEchoModePassword(); 719 prompt->setEchoModePassword();
720 prompt->show(); 720 prompt->show();
721 } 721 }
722 } else { 722 } else {
723 /* if prompt withdrawn ... then, */ 723 /* if prompt withdrawn ... then, */
724 if (!(prompt->isVisible())) { 724 if (!(prompt->isVisible())) {
725 writeline(prompt->text()); 725 writeline(prompt->text());
726 prompt->setConsumed(); 726 prompt->setConsumed();
727 scriptindex++; 727 scriptindex++;
728 return; 728 return;
729 } 729 }
730 /* replace timeout value */ 730 /* replace timeout value */
731 } 731 }
732 } 732 }
733 733
734 if (scriptCommand == "LoopStart") { 734 if (scriptCommand == "LoopStart") {
735 735
736 QString bm = i18n("Loop Start %1").arg(scriptArgument); 736 QString bm = i18n("Loop Start %1").arg(scriptArgument);
737 737
738 // The incrementing of the scriptindex MUST be before the 738 // The incrementing of the scriptindex MUST be before the
739 // call to setExpect otherwise the expect will miss a string that is 739 // call to setExpect otherwise the expect will miss a string that is
740 // already in the buffer. 740 // already in the buffer.
741 scriptindex++; 741 scriptindex++;
742 742
743 if ( loopnest > (MAXLOOPNEST-2) ) { 743 if ( loopnest > (MAXLOOPNEST-2) ) {
744 bm += i18n("ERROR: Nested too deep, ignored."); 744 bm += i18n("ERROR: Nested too deep, ignored.");
745 vmain=20; 745 vmain=20;
746 cancelbutton(); 746 cancelbutton();
747 QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); 747 QMessageBox::critical(0, "error", i18n("Loops nested too deeply!"));
748 } else { 748 } else {
749 setExpect(scriptArgument); 749 setExpect(scriptArgument);
750 loopstartindex[loopnest] = scriptindex; 750 loopstartindex[loopnest] = scriptindex;
751 loopstr[loopnest] = scriptArgument; 751 loopstr[loopnest] = scriptArgument;
752 loopend = false; 752 loopend = false;
753 loopnest++; 753 loopnest++;
754 } 754 }
755 messg->setText(bm); 755 messg->setText(bm);
756 emit debugMessage(bm); 756 emit debugMessage(bm);
757 757
758 } 758 }
759 759
760 if (scriptCommand == "LoopEnd") { 760 if (scriptCommand == "LoopEnd") {
761 QString bm = i18n("Loop End %1").arg(scriptArgument); 761 QString bm = i18n("Loop End %1").arg(scriptArgument);
762 if ( loopnest <= 0 ) { 762 if ( loopnest <= 0 ) {
763 bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); 763 bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm);
764 vmain=20; 764 vmain=20;
765 cancelbutton(); 765 cancelbutton();
766 QMessageBox::critical(0, "error", bm); 766 QMessageBox::critical(0, "error", bm);
767 return; 767 return;
768 } else { 768 } else {
769 // NB! The incrementing of the scriptindex MUST be before the 769 // NB! The incrementing of the scriptindex MUST be before the
770 // call to setExpect otherwise the expect will miss a string 770 // call to setExpect otherwise the expect will miss a string
771 // that is already in the buffer. 771 // that is already in the buffer.
772 scriptindex++; 772 scriptindex++;
773 setExpect(scriptArgument); 773 setExpect(scriptArgument);
774 loopnest--; 774 loopnest--;
775 loopend = true; 775 loopend = true;
776 } 776 }
777 messg->setText(bm); 777 messg->setText(bm);
778 emit debugMessage(bm); 778 emit debugMessage(bm);
779 779
780 } 780 }
781 } 781 }
782 } 782 }
783 783
784 // this is a subroutine for the "Answer" script option 784 // this is a subroutine for the "Answer" script option
785 785
786 if(vmain == 150) { 786 if(vmain == 150) {
787 if(!expecting) { 787 if(!expecting) {
788 writeline(gpppdata.modemAnswerStr()); 788 writeline(PPPData::data()->modemAnswerStr());
789 setExpect(gpppdata.modemAnswerResp()); 789 setExpect(PPPData::data()->modemAnswerResp());
790 790
791 vmain = 2; 791 vmain = 2;
792 scriptindex++; 792 scriptindex++;
793 return; 793 return;
794 } 794 }
795 } 795 }
796 796
797 if(vmain == 30) { 797 if(vmain == 30) {
798// if (termwindow->isVisible()) 798// if (termwindow->isVisible())
799// return; 799// return;
800// if (termwindow->pressedContinue()) 800// if (termwindow->pressedContinue())
801// vmain = 10; 801// vmain = 10;
802// else 802// else
803 cancelbutton(); 803 cancelbutton();
804 } 804 }
805 805
806 if(vmain == 10) { 806 if(vmain == 10) {
807 if(!expecting) { 807 if(!expecting) {
808 808
809 int result; 809 int result;
810 810
811 timeout_timer->stop(); 811 timeout_timer->stop();
812 if_timeout_timer->stop(); // better be sure. 812 if_timeout_timer->stop(); // better be sure.
813 813
814 // stop reading of data 814 // stop reading of data
815 Modem::modem->stop(); 815 Modem::modem->stop();
816 816
817 if(gpppdata.authMethod() == AUTH_TERMINAL) { 817 if(PPPData::data()->authMethod() == AUTH_TERMINAL) {
818 // if (termwindow) { 818 // if (termwindow) {
819 // delete termwindow; 819 // delete termwindow;
820 // termwindow = 0L; 820 // termwindow = 0L;
821 // this->show(); 821 // this->show();
822 // } else { 822 // } else {
823 // termwindow = new LoginTerm(0L, 0L); 823 // termwindow = new LoginTerm(0L, 0L);
824 // hide(); 824 // hide();
825 // termwindow->show(); 825 // termwindow->show();
826 // vmain = 30; 826 // vmain = 30;
827 // return; 827 // return;
828 // } 828 // }
829 } 829 }
830 830
831 // Close the tty. This prevents the QTimer::singleShot() in 831 // Close the tty. This prevents the QTimer::singleShot() in
832 // Modem::readtty() from re-enabling the socket notifier. 832 // Modem::readtty() from re-enabling the socket notifier.
833 // The port is still held open by the helper process. 833 // The port is still held open by the helper process.
834 Modem::modem->closetty(); 834 Modem::modem->closetty();
835 835
836 killTimer( main_timer_ID ); 836 killTimer( main_timer_ID );
837 837
838 if_timeout_timer->start(gpppdata.pppdTimeout()*1000); 838 if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000);
839 qDebug( "started if timeout timer with %i", gpppdata.pppdTimeout()*1000); 839 qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000);
840 840
841 // find out PPP interface and notify the stats module 841 // find out PPP interface and notify the stats module
842// stats->setUnit(pppInterfaceNumber()); 842// stats->setUnit(pppInterfaceNumber());
843 843
844 qApp->flushX(); 844 qApp->flushX();
845 semaphore = true; 845 semaphore = true;
846 result = execppp(); 846 result = execppp();
847 847
848 emit debugMessage(i18n("Starting pppd...")); 848 emit debugMessage(i18n("Starting pppd..."));
849 qDebug("execppp() returned with return-code %i", result ); 849 qDebug("execppp() returned with return-code %i", result );
850 850
851 if(result) { 851 if(result) {
852 if(!gpppdata.autoDNS()) 852 if(!PPPData::data()->autoDNS())
853 adddns(); 853 adddns();
854 854
855 // O.K we are done here, let's change over to the if_waiting loop 855 // 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. 856 // where we wait for the ppp if (interface) to come up.
857 857
858 emit if_waiting_signal(); 858 emit if_waiting_signal();
859 } else { 859 } else {
860 860
861 // starting pppd wasn't successful. Error messages were 861 // starting pppd wasn't successful. Error messages were
862 // handled by execppp(); 862 // handled by execppp();
863 if_timeout_timer->stop(); 863 if_timeout_timer->stop();
864 this->hide(); 864 this->hide();
865 messg->setText(""); 865 messg->setText("");
866 p_kppp->quit_b->setFocus(); 866 p_kppp->quit_b->setFocus();
867 p_kppp->show(); 867 p_kppp->show();
868 qApp->processEvents(); 868 qApp->processEvents();
869 Modem::modem->hangup(); 869 Modem::modem->hangup();
870 emit stopAccounting(); 870 emit stopAccounting();
871 //p_kppp->con_win->stopClock(); 871 //p_kppp->con_win->stopClock();
872 Modem::modem->closetty(); 872 Modem::modem->closetty();
873 Modem::modem->unlockdevice(); 873 Modem::modem->unlockdevice();
874 874
875 } 875 }
876 876
877 return; 877 return;
878 } 878 }
879 } 879 }
880 880
881 // this is a "wait until cancel" entry 881 // this is a "wait until cancel" entry
882 882
883 if(vmain == 20) { 883 if(vmain == 20) {
884 } 884 }
885} 885}
886 886
887 887
888void ConnectWidget::set_con_speed_string() { 888void ConnectWidget::set_con_speed_string() {
889 // Here we are trying to determine the speed at which we are connected. 889 // Here we are trying to determine the speed at which we are connected.
890 // Usually the modem responds after connect with something like 890 // Usually the modem responds after connect with something like
891 // CONNECT 115200, so all we need to do is find the number after CONNECT 891 // CONNECT 115200, so all we need to do is find the number after CONNECT
892 // or whatever the modemConnectResp() is. 892 // or whatever the modemConnectResp() is.
893 p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer); 893 p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer);
894} 894}
895 895
896 896
897 897
898void ConnectWidget::readChar(unsigned char c) { 898void ConnectWidget::readChar(unsigned char c) {
899 if(semaphore) 899 if(semaphore)
900 return; 900 return;
901 901
902 readbuffer += c; 902 readbuffer += c;
903 myreadbuffer += c; 903 myreadbuffer += c;
904 904
905 // While in scanning mode store each char to the scan buffer 905 // While in scanning mode store each char to the scan buffer
906 // for use in the prompt command 906 // for use in the prompt command
907 if( scanning ) 907 if( scanning )
908 scanbuffer += c; 908 scanbuffer += c;
909 909
910 // add to debug window 910 // add to debug window
911 emit debugPutChar(c); 911 emit debugPutChar(c);
912 912
913 checkBuffers(); 913 checkBuffers();
914} 914}
915 915
916 916
917void ConnectWidget::checkBuffers() { 917void ConnectWidget::checkBuffers() {
918 // Let's check if we are finished with scanning: 918 // Let's check if we are finished with scanning:
919 // The scanstring have to be in the buffer and the latest character 919 // The scanstring have to be in the buffer and the latest character
920 // was a carriage return or an linefeed (depending on modem setup) 920 // was a carriage return or an linefeed (depending on modem setup)
921 if( scanning && scanbuffer.contains(scanstr) && 921 if( scanning && scanbuffer.contains(scanstr) &&
922 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { 922 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
923 scanning = false; 923 scanning = false;
924 924
925 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 925 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
926 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 926 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
927 scanvar = scanvar.stripWhiteSpace(); 927 scanvar = scanvar.stripWhiteSpace();
928 928
929 // Show the Variabel content in the debug window 929 // Show the Variabel content in the debug window
930 QString sv = i18n("Scan Var: %1").arg(scanvar); 930 QString sv = i18n("Scan Var: %1").arg(scanvar);
931 emit debugMessage(sv); 931 emit debugMessage(sv);
932 } 932 }
933 933
934 if(expecting) { 934 if(expecting) {
935 if(readbuffer.contains(expectstr)) { 935 if(readbuffer.contains(expectstr)) {
936 expecting = false; 936 expecting = false;
937 // keep everything after the expected string 937 // keep everything after the expected string
938 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 938 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
939 939
940 QString ts = i18n("Found: %1").arg(expectstr); 940 QString ts = i18n("Found: %1").arg(expectstr);
941 emit debugMessage(ts); 941 emit debugMessage(ts);
942 942
943 if (loopend) { 943 if (loopend) {
944 loopend=false; 944 loopend=false;
945 } 945 }
946 } 946 }
947 947
948 if (loopend && readbuffer.contains(loopstr[loopnest])) { 948 if (loopend && readbuffer.contains(loopstr[loopnest])) {
@@ -970,469 +970,469 @@ void ConnectWidget::pause() {
970 970
971void ConnectWidget::cancelbutton() { 971void ConnectWidget::cancelbutton() {
972 Modem::modem->stop(); 972 Modem::modem->stop();
973 killTimer(main_timer_ID); 973 killTimer(main_timer_ID);
974 timeout_timer->stop(); 974 timeout_timer->stop();
975 if_timer->stop(); 975 if_timer->stop();
976 if_timeout_timer->stop(); 976 if_timeout_timer->stop();
977 977
978// if (termwindow) { 978// if (termwindow) {
979// delete termwindow; 979// delete termwindow;
980// termwindow = 0L; 980// termwindow = 0L;
981// this->show(); 981// this->show();
982// } 982// }
983 983
984 messg->setText(i18n("One moment please...")); 984 messg->setText(i18n("One moment please..."));
985 985
986 // just to be sure 986 // just to be sure
987 Modem::modem->removeSecret(AUTH_PAP); 987 Modem::modem->removeSecret(AUTH_PAP);
988 Modem::modem->removeSecret(AUTH_CHAP); 988 Modem::modem->removeSecret(AUTH_CHAP);
989 removedns(); 989 removedns();
990 990
991 qApp->processEvents(); 991 qApp->processEvents();
992 992
993 Modem::modem->killPPPDaemon(); 993 Modem::modem->killPPPDaemon();
994 Modem::modem->hangup(); 994 Modem::modem->hangup();
995 995
996 this->hide(); 996 this->hide();
997 messg->setText(""); 997 messg->setText("");
998 p_kppp->quit_b->setFocus(); 998 p_kppp->quit_b->setFocus();
999 p_kppp->show(); 999 p_kppp->show();
1000 emit stopAccounting();// just to be sure 1000 emit stopAccounting();// just to be sure
1001// p_kppp->con_win->stopClock(); 1001// p_kppp->con_win->stopClock();
1002 Modem::modem->closetty(); 1002 Modem::modem->closetty();
1003 Modem::modem->unlockdevice(); 1003 Modem::modem->unlockdevice();
1004 1004
1005 //abort prompt window... 1005 //abort prompt window...
1006 if (prompt->isVisible()) { 1006 if (prompt->isVisible()) {
1007 prompt->hide(); 1007 prompt->hide();
1008 } 1008 }
1009 prompt->setConsumed(); 1009 prompt->setConsumed();
1010 1010
1011// if(p_kppp->quitOnDisconnect()) 1011// if(p_kppp->quitOnDisconnect())
1012// qApp->exit(0); 1012// qApp->exit(0);
1013} 1013}
1014 1014
1015 1015
1016void ConnectWidget::script_timed_out() { 1016void ConnectWidget::script_timed_out() {
1017 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1017 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1018 timeout_timer->stop(); 1018 timeout_timer->stop();
1019 emit stopAccounting(); 1019 emit stopAccounting();
1020// p_kppp->con_win->stopClock(); 1020// p_kppp->con_win->stopClock();
1021 return; 1021 return;
1022 } 1022 }
1023 1023
1024 if (prompt->isVisible()) 1024 if (prompt->isVisible())
1025 prompt->hide(); 1025 prompt->hide();
1026 1026
1027 prompt->setConsumed(); 1027 prompt->setConsumed();
1028 messg->setText(i18n("Script timed out!")); 1028 messg->setText(i18n("Script timed out!"));
1029 Modem::modem->hangup(); 1029 Modem::modem->hangup();
1030 emit stopAccounting(); 1030 emit stopAccounting();
1031// p_kppp->con_win->stopClock(); 1031// p_kppp->con_win->stopClock();
1032 1032
1033 vmain = 0; // let's try again. 1033 vmain = 0; // let's try again.
1034 substate = -1; 1034 substate = -1;
1035} 1035}
1036 1036
1037 1037
1038void ConnectWidget::setScan(const QString &n) { 1038void ConnectWidget::setScan(const QString &n) {
1039 scanning = true; 1039 scanning = true;
1040 scanstr = n; 1040 scanstr = n;
1041 scanbuffer = ""; 1041 scanbuffer = "";
1042 1042
1043 QString ts = i18n("Scanning: %1").arg(n); 1043 QString ts = i18n("Scanning: %1").arg(n);
1044 emit debugMessage(ts); 1044 emit debugMessage(ts);
1045} 1045}
1046 1046
1047 1047
1048void ConnectWidget::setExpect(const QString &n) { 1048void ConnectWidget::setExpect(const QString &n) {
1049 expecting = true; 1049 expecting = true;
1050 expectstr = n; 1050 expectstr = n;
1051 1051
1052 QString ts = i18n("Expecting: %1").arg(n); 1052 QString ts = i18n("Expecting: %1").arg(n);
1053 ts.replace(QRegExp("\n"), "<LF>"); 1053 ts.replace(QRegExp("\n"), "<LF>");
1054 emit debugMessage(ts); 1054 emit debugMessage(ts);
1055 1055
1056 // check if the expected string is in the read buffer already. 1056 // check if the expected string is in the read buffer already.
1057 checkBuffers(); 1057 checkBuffers();
1058} 1058}
1059 1059
1060 1060
1061void ConnectWidget::if_waiting_timed_out() { 1061void ConnectWidget::if_waiting_timed_out() {
1062 if_timer->stop(); 1062 if_timer->stop();
1063 if_timeout_timer->stop(); 1063 if_timeout_timer->stop();
1064 qDebug("if_waiting_timed_out()"); 1064 qDebug("if_waiting_timed_out()");
1065 1065
1066 gpppdata.setpppdError(E_IF_TIMEOUT); 1066 PPPData::data()->setpppdError(E_IF_TIMEOUT);
1067 1067
1068 // let's kill the stuck pppd 1068 // let's kill the stuck pppd
1069 Modem::modem->killPPPDaemon(); 1069 Modem::modem->killPPPDaemon();
1070 1070
1071 emit stopAccounting(); 1071 emit stopAccounting();
1072// p_kppp->con_win->stopClock(); 1072// p_kppp->con_win->stopClock();
1073 1073
1074 1074
1075 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1075 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1076 // in main.cpp what happens next will depend on the boolean 1076 // in main.cpp what happens next will depend on the boolean
1077 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1077 // reconnect_on_disconnect which is set in ConnectWidget::init();
1078} 1078}
1079 1079
1080void ConnectWidget::pppdDied() 1080void ConnectWidget::pppdDied()
1081{ 1081{
1082 if_timer->stop(); 1082 if_timer->stop();
1083 if_timeout_timer->stop(); 1083 if_timeout_timer->stop();
1084} 1084}
1085 1085
1086void ConnectWidget::if_waiting_slot() { 1086void ConnectWidget::if_waiting_slot() {
1087 messg->setText(i18n("Logging on to network...")); 1087 messg->setText(i18n("Logging on to network..."));
1088 1088
1089// if(!stats->ifIsUp()) { 1089// if(!stats->ifIsUp()) {
1090 1090
1091// if(gpppdata.pppdError() != 0) { 1091// if(PPPData::data()->pppdError() != 0) {
1092// // we are here if pppd died immediately after starting it. 1092// // we are here if pppd died immediately after starting it.
1093// pppdDied(); 1093// pppdDied();
1094// // error message handled in main.cpp: sigPPPDDied() 1094// // error message handled in main.cpp: sigPPPDDied()
1095// return; 1095// return;
1096// } 1096// }
1097 1097
1098// if_timer->start(100, TRUE); // single shot 1098// if_timer->start(100, TRUE); // single shot
1099// return; 1099// return;
1100// } 1100// }
1101 1101
1102 // O.K the ppp interface is up and running 1102 // O.K the ppp interface is up and running
1103 // give it a few time to come up completly (0.2 seconds) 1103 // give it a few time to come up completly (0.2 seconds)
1104 if_timeout_timer->stop(); 1104 if_timeout_timer->stop();
1105 if_timer->stop(); 1105 if_timer->stop();
1106 usleep(200000); 1106 usleep(200000);
1107 1107
1108 if(gpppdata.autoDNS()) 1108 if(PPPData::data()->autoDNS())
1109 addpeerdns(); 1109 addpeerdns();
1110 1110
1111 // Close the debugging window. If we are connected, we 1111 // Close the debugging window. If we are connected, we
1112 // are not really interested in debug output 1112 // are not really interested in debug output
1113 emit closeDebugWindow(); 1113 emit closeDebugWindow();
1114// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1114// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1115 auto_hostname(); 1115 auto_hostname();
1116 1116
1117 if(!gpppdata.command_on_connect().isEmpty()) { 1117 if(!PPPData::data()->command_on_connect().isEmpty()) {
1118 messg->setText(i18n("Running startup command...")); 1118 messg->setText(i18n("Running startup command..."));
1119 1119
1120 // make sure that we don't get any async errors 1120 // make sure that we don't get any async errors
1121 qApp->flushX(); 1121 qApp->flushX();
1122 execute_command(gpppdata.command_on_connect()); 1122 execute_command(PPPData::data()->command_on_connect());
1123 messg->setText(i18n("Done")); 1123 messg->setText(i18n("Done"));
1124 } 1124 }
1125 1125
1126 // remove the authentication file 1126 // remove the authentication file
1127 Modem::modem->removeSecret(AUTH_PAP); 1127 Modem::modem->removeSecret(AUTH_PAP);
1128 Modem::modem->removeSecret(AUTH_CHAP); 1128 Modem::modem->removeSecret(AUTH_CHAP);
1129 1129
1130 emit debugMessage(i18n("Done")); 1130 emit debugMessage(i18n("Done"));
1131 set_con_speed_string(); 1131 set_con_speed_string();
1132 1132
1133// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1133// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1134 this->hide(); 1134 this->hide();
1135 messg->setText(""); 1135 messg->setText("");
1136 1136
1137 // prepare the con_win so as to have the right size for 1137 // prepare the con_win so as to have the right size for
1138 // accounting / non-accounting mode 1138 // accounting / non-accounting mode
1139// if(p_kppp->acct != 0) 1139// if(p_kppp->acct != 0)
1140// p_kppp->con_win->accounting(p_kppp->acct->running()); 1140// p_kppp->con_win->accounting(p_kppp->acct->running());
1141// else 1141// else
1142// p_kppp->con_win->accounting(false); 1142// p_kppp->con_win->accounting(false);
1143 1143
1144 if (gpppdata.get_dock_into_panel()) { 1144 if (PPPData::data()->get_dock_into_panel()) {
1145// DockWidget::dock_widget->show(); 1145// DockWidget::dock_widget->show();
1146// DockWidget::dock_widget->take_stats(); 1146// DockWidget::dock_widget->take_stats();
1147// this->hide(); 1147// this->hide();
1148 } 1148 }
1149 else { 1149 else {
1150// p_kppp->con_win->show(); 1150// p_kppp->con_win->show();
1151 1151
1152 if(gpppdata.get_iconify_on_connect()) { 1152 if(PPPData::data()->get_iconify_on_connect()) {
1153 // p_kppp->con_win->showMinimized(); 1153 // p_kppp->con_win->showMinimized();
1154 } 1154 }
1155 } 1155 }
1156 1156
1157 Modem::modem->closetty(); 1157 Modem::modem->closetty();
1158} 1158}
1159 1159
1160 1160
1161bool ConnectWidget::execppp() { 1161bool ConnectWidget::execppp() {
1162 QString command; 1162 QString command;
1163 1163
1164 command = "pppd"; 1164 command = "pppd";
1165 1165
1166 // as of version 2.3.6 pppd falls back to the real user rights when 1166 // 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 1167 // 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 1168 // 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. 1169 // which is the serial port we connected stdin/stdout to in opener.cpp.
1170 // command += " "; 1170 // command += " ";
1171 // command += gpppdata.modemDevice(); 1171 // command += PPPData::data()->modemDevice();
1172 1172
1173 command += " " + gpppdata.speed(); 1173 command += " " + PPPData::data()->speed();
1174 1174
1175 command += " -detach"; 1175 command += " -detach";
1176 1176
1177 if(gpppdata.ipaddr() != "0.0.0.0" || 1177 if(PPPData::data()->ipaddr() != "0.0.0.0" ||
1178 gpppdata.gateway() != "0.0.0.0") { 1178 PPPData::data()->gateway() != "0.0.0.0") {
1179 if(gpppdata.ipaddr() != "0.0.0.0") { 1179 if(PPPData::data()->ipaddr() != "0.0.0.0") {
1180 command += " "; 1180 command += " ";
1181 command += gpppdata.ipaddr(); 1181 command += PPPData::data()->ipaddr();
1182 command += ":"; 1182 command += ":";
1183 } 1183 }
1184 else { 1184 else {
1185 command += " "; 1185 command += " ";
1186 command += ":"; 1186 command += ":";
1187 } 1187 }
1188 1188
1189 if(gpppdata.gateway() != "0.0.0.0") 1189 if(PPPData::data()->gateway() != "0.0.0.0")
1190 command += gpppdata.gateway(); 1190 command += PPPData::data()->gateway();
1191 } 1191 }
1192 1192
1193 if(gpppdata.subnetmask() != "0.0.0.0") 1193 if(PPPData::data()->subnetmask() != "0.0.0.0")
1194 command += " netmask " + gpppdata.subnetmask(); 1194 command += " netmask " + PPPData::data()->subnetmask();
1195 1195
1196 if(gpppdata.flowcontrol() != "None") { 1196 if(PPPData::data()->flowcontrol() != "None") {
1197 if(gpppdata.flowcontrol() == "CRTSCTS") 1197 if(PPPData::data()->flowcontrol() == "CRTSCTS")
1198 command += " crtscts"; 1198 command += " crtscts";
1199 else 1199 else
1200 command += " xonxoff"; 1200 command += " xonxoff";
1201 } 1201 }
1202 1202
1203 if(gpppdata.defaultroute()) 1203 if(PPPData::data()->defaultroute())
1204 command += " defaultroute"; 1204 command += " defaultroute";
1205 1205
1206 if(gpppdata.autoDNS()) 1206 if(PPPData::data()->autoDNS())
1207 command += " usepeerdns"; 1207 command += " usepeerdns";
1208 1208
1209 QStringList &arglist = gpppdata.pppdArgument(); 1209 QStringList &arglist = PPPData::data()->pppdArgument();
1210 for ( QStringList::Iterator it = arglist.begin(); 1210 for ( QStringList::Iterator it = arglist.begin();
1211 it != arglist.end(); 1211 it != arglist.end();
1212 ++it ) 1212 ++it )
1213 { 1213 {
1214 command += " " + *it; 1214 command += " " + *it;
1215 } 1215 }
1216 1216
1217 // PAP settings 1217 // PAP settings
1218 if(gpppdata.authMethod() == AUTH_PAP) { 1218 if(PPPData::data()->authMethod() == AUTH_PAP) {
1219 command += " -chap user "; 1219 command += " -chap user ";
1220 command = command + "\"" + gpppdata.storedUsername() + "\""; 1220 command = command + "\"" + PPPData::data()->storedUsername() + "\"";
1221 } 1221 }
1222 1222
1223 // CHAP settings 1223 // CHAP settings
1224 if(gpppdata.authMethod() == AUTH_CHAP) { 1224 if(PPPData::data()->authMethod() == AUTH_CHAP) {
1225 command += " -pap user "; 1225 command += " -pap user ";
1226 command = command + "\"" + gpppdata.storedUsername() + "\""; 1226 command = command + "\"" + PPPData::data()->storedUsername() + "\"";
1227 } 1227 }
1228 1228
1229 // PAP/CHAP settings 1229 // PAP/CHAP settings
1230 if(gpppdata.authMethod() == AUTH_PAPCHAP) { 1230 if(PPPData::data()->authMethod() == AUTH_PAPCHAP) {
1231 command += " user "; 1231 command += " user ";
1232 command = command + "\"" + gpppdata.storedUsername() + "\""; 1232 command = command + "\"" + PPPData::data()->storedUsername() + "\"";
1233 } 1233 }
1234 1234
1235 // check for debug 1235 // check for debug
1236 if(gpppdata.getPPPDebug()) 1236 if(PPPData::data()->getPPPDebug())
1237 command += " debug"; 1237 command += " debug";
1238 1238
1239 if (command.length() > MAX_CMDLEN) { 1239 if (command.length() > MAX_CMDLEN) {
1240 QMessageBox::critical(this, "error", i18n( 1240 QMessageBox::critical(this, "error", i18n(
1241 "pppd command + command-line arguments exceed " 1241 "pppd command + command-line arguments exceed "
1242 "2024 characters in length." 1242 "2024 characters in length."
1243 )); 1243 ));
1244 1244
1245 return false; // nonsensically long command which would bust my buffer buf. 1245 return false; // nonsensically long command which would bust my buffer buf.
1246 } 1246 }
1247 1247
1248 qApp->flushX(); 1248 qApp->flushX();
1249 1249
1250 return Modem::modem->execPPPDaemon(command); 1250 return Modem::modem->execPPPDaemon(command);
1251} 1251}
1252 1252
1253 1253
1254void ConnectWidget::closeEvent( QCloseEvent *e ) { 1254void ConnectWidget::closeEvent( QCloseEvent *e ) {
1255 e->ignore(); 1255 e->ignore();
1256 emit cancelbutton(); 1256 emit cancelbutton();
1257} 1257}
1258 1258
1259 1259
1260void ConnectWidget::setMsg(const QString &msg) { 1260void ConnectWidget::setMsg(const QString &msg) {
1261 messg->setText(msg); 1261 messg->setText(msg);
1262} 1262}
1263 1263
1264void ConnectWidget::writeline(const QString &s) { 1264void ConnectWidget::writeline(const QString &s) {
1265 Modem::modem->writeLine(s.local8Bit()); 1265 Modem::modem->writeLine(s.local8Bit());
1266} 1266}
1267 1267
1268// Set the hostname and domain from DNS Server 1268// Set the hostname and domain from DNS Server
1269void auto_hostname() { 1269void auto_hostname() {
1270 struct in_addr local_ip; 1270 struct in_addr local_ip;
1271 struct hostent *hostname_entry; 1271 struct hostent *hostname_entry;
1272 QString new_hostname; 1272 QString new_hostname;
1273 int dot; 1273 int dot;
1274 char tmp_str[100]; // buffer overflow safe 1274 char tmp_str[100]; // buffer overflow safe
1275 1275
1276 gethostname(tmp_str, sizeof(tmp_str)); 1276 gethostname(tmp_str, sizeof(tmp_str));
1277 tmp_str[sizeof(tmp_str)-1]=0; // panic 1277 tmp_str[sizeof(tmp_str)-1]=0; // panic
1278 old_hostname=tmp_str; // copy to QString 1278 old_hostname=tmp_str; // copy to QString
1279 1279
1280 // if (!p_kppp->stats->local_ip_address.isEmpty() && gpppdata.autoname()) { 1280 // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) {
1281 if ( gpppdata.autoname()) { 1281 if ( PPPData::data()->autoname()) {
1282// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); 1282// 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); 1283 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
1284 1284
1285 if (hostname_entry != 0L) { 1285 if (hostname_entry != 0L) {
1286 new_hostname=hostname_entry->h_name; 1286 new_hostname=hostname_entry->h_name;
1287 dot=new_hostname.find('.'); 1287 dot=new_hostname.find('.');
1288 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); 1288 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
1289 Modem::modem->setHostname(new_hostname); 1289 Modem::modem->setHostname(new_hostname);
1290 modified_hostname = TRUE; 1290 modified_hostname = TRUE;
1291 1291
1292 new_hostname=hostname_entry->h_name; 1292 new_hostname=hostname_entry->h_name;
1293 new_hostname.remove(0,dot+1); 1293 new_hostname.remove(0,dot+1);
1294 1294
1295 add_domain(new_hostname); 1295 add_domain(new_hostname);
1296 } 1296 }
1297 } 1297 }
1298 1298
1299} 1299}
1300 1300
1301// Replace the DNS domain entry in the /etc/resolv.conf file and 1301// Replace the DNS domain entry in the /etc/resolv.conf file and
1302// disable the nameserver entries if option is enabled 1302// disable the nameserver entries if option is enabled
1303void add_domain(const QString &domain) { 1303void add_domain(const QString &domain) {
1304 1304
1305 int fd; 1305 int fd;
1306 char c; 1306 char c;
1307 QString resolv[MAX_RESOLVCONF_LINES]; 1307 QString resolv[MAX_RESOLVCONF_LINES];
1308 1308
1309 if (domain.isEmpty()) 1309 if (domain.isEmpty())
1310 return; 1310 return;
1311 1311
1312 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { 1312 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
1313 1313
1314 int i=0; 1314 int i=0;
1315 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { 1315 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
1316 if(c == '\n') { 1316 if(c == '\n') {
1317 i++; 1317 i++;
1318 } 1318 }
1319 else { 1319 else {
1320 resolv[i] += c; 1320 resolv[i] += c;
1321 } 1321 }
1322 } 1322 }
1323 close(fd); 1323 close(fd);
1324 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; 1324 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
1325 1325
1326 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1326 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1327 QCString tmp = "domain " + domain.local8Bit() + 1327 QCString tmp = "domain " + domain.local8Bit() +
1328 " \t\t#kppp temp entry\n"; 1328 " \t\t#kppp temp entry\n";
1329 write(fd, tmp.data(), tmp.length()); 1329 write(fd, tmp.data(), tmp.length());
1330 1330
1331 for(int j=0; j < i; j++) { 1331 for(int j=0; j < i; j++) {
1332 if((resolv[j].contains("domain") || 1332 if((resolv[j].contains("domain") ||
1333 ( resolv[j].contains("nameserver") 1333 ( resolv[j].contains("nameserver")
1334 && !resolv[j].contains("#kppp temp entry") 1334 && !resolv[j].contains("#kppp temp entry")
1335 && gpppdata.exDNSDisabled())) 1335 && PPPData::data()->exDNSDisabled()))
1336 && !resolv[j].contains("#entry disabled by kppp")) { 1336 && !resolv[j].contains("#entry disabled by kppp")) {
1337 QCString tmp = "# " + resolv[j].local8Bit() + 1337 QCString tmp = "# " + resolv[j].local8Bit() +
1338 " \t#entry disabled by kppp\n"; 1338 " \t#entry disabled by kppp\n";
1339 write(fd, tmp, tmp.length()); 1339 write(fd, tmp, tmp.length());
1340 } 1340 }
1341 else { 1341 else {
1342 QCString tmp = resolv[j].local8Bit() + "\n"; 1342 QCString tmp = resolv[j].local8Bit() + "\n";
1343 write(fd, tmp, tmp.length()); 1343 write(fd, tmp, tmp.length());
1344 } 1344 }
1345 } 1345 }
1346 } 1346 }
1347 close(fd); 1347 close(fd);
1348 } 1348 }
1349} 1349}
1350 1350
1351 1351
1352// adds the DNS entries in the /etc/resolv.conf file 1352// adds the DNS entries in the /etc/resolv.conf file
1353void adddns() 1353void adddns()
1354{ 1354{
1355 int fd; 1355 int fd;
1356 1356
1357 if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1357 if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1358 QStringList &dnslist = gpppdata.dns(); 1358 QStringList &dnslist = PPPData::data()->dns();
1359 for ( QStringList::Iterator it = dnslist.begin(); 1359 for ( QStringList::Iterator it = dnslist.begin();
1360 it != dnslist.end(); 1360 it != dnslist.end();
1361 ++it ) 1361 ++it )
1362 { 1362 {
1363 QCString dns = "nameserver " + (*it).local8Bit() + 1363 QCString dns = "nameserver " + (*it).local8Bit() +
1364 " \t#kppp temp entry\n"; 1364 " \t#kppp temp entry\n";
1365 write(fd, dns.data(), dns.length()); 1365 write(fd, dns.data(), dns.length());
1366 } 1366 }
1367 close(fd); 1367 close(fd);
1368 } 1368 }
1369 add_domain(gpppdata.domain()); 1369 add_domain(PPPData::data()->domain());
1370} 1370}
1371 1371
1372void addpeerdns() { 1372void addpeerdns() {
1373 int fd, fd2; 1373 int fd, fd2;
1374 1374
1375 if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1375 if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1376 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { 1376 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
1377 char c; 1377 char c;
1378 int i = 0; 1378 int i = 0;
1379 while(i++ < 100 && read(fd2, &c, 1) == 1) { 1379 while(i++ < 100 && read(fd2, &c, 1) == 1) {
1380 if(c == '\n') 1380 if(c == '\n')
1381 write(fd, "\t#kppp temp entry\n", 18); 1381 write(fd, "\t#kppp temp entry\n", 18);
1382 else 1382 else
1383 write(fd, &c, 1); 1383 write(fd, &c, 1);
1384 } 1384 }
1385 close(fd2); 1385 close(fd2);
1386 } else 1386 } else
1387 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); 1387 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
1388 close(fd); 1388 close(fd);
1389 } 1389 }
1390 add_domain(gpppdata.domain()); 1390 add_domain(PPPData::data()->domain());
1391} 1391}
1392 1392
1393// remove the dns entries from the /etc/resolv.conf file 1393// remove the dns entries from the /etc/resolv.conf file
1394void removedns() { 1394void removedns() {
1395 1395
1396 int fd; 1396 int fd;
1397 char c; 1397 char c;
1398 QString resolv[MAX_RESOLVCONF_LINES]; 1398 QString resolv[MAX_RESOLVCONF_LINES];
1399 1399
1400 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { 1400 if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) {
1401 1401
1402 int i=0; 1402 int i=0;
1403 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { 1403 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
1404 if(c == '\n') { 1404 if(c == '\n') {
1405 i++; 1405 i++;
1406 } 1406 }
1407 else { 1407 else {
1408 resolv[i] += c; 1408 resolv[i] += c;
1409 } 1409 }
1410 } 1410 }
1411 close(fd); 1411 close(fd);
1412 1412
1413 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1413 if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1414 for(int j=0; j < i; j++) { 1414 for(int j=0; j < i; j++) {
1415 if(resolv[j].contains("#kppp temp entry")) continue; 1415 if(resolv[j].contains("#kppp temp entry")) continue;
1416 if(resolv[j].contains("#entry disabled by kppp")) { 1416 if(resolv[j].contains("#entry disabled by kppp")) {
1417 QCString tmp = resolv[j].local8Bit(); 1417 QCString tmp = resolv[j].local8Bit();
1418 write(fd, tmp.data()+2, tmp.length() - 27); 1418 write(fd, tmp.data()+2, tmp.length() - 27);
1419 write(fd, "\n", 1); 1419 write(fd, "\n", 1);
1420 } 1420 }
1421 else { 1421 else {
1422 QCString tmp = resolv[j].local8Bit() + "\n"; 1422 QCString tmp = resolv[j].local8Bit() + "\n";
1423 write(fd, tmp, tmp.length()); 1423 write(fd, tmp, tmp.length());
1424 } 1424 }
1425 } 1425 }
1426 } 1426 }
1427 close(fd); 1427 close(fd);
1428 1428
1429 } 1429 }
1430 1430
1431 if ( modified_hostname ) { 1431 if ( modified_hostname ) {
1432 Modem::modem->setHostname(old_hostname); 1432 Modem::modem->setHostname(old_hostname);
1433 modified_hostname = FALSE; 1433 modified_hostname = FALSE;
1434 } 1434 }
1435 1435
1436} 1436}
1437 1437
1438 1438
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index d6b3fbe..ad89005 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -1,341 +1,341 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public 19 * You should have received a copy of the GNU Library General Public
20 * License along with this program; if not, write to the Free 20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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; 34extern PPPData gpppdata;
35 35
36ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) 36ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget )
37 // PPPStats *st) 37 // PPPStats *st)
38 : QWidget(parent, name, 0), 38 : QWidget(parent, name, 0),
39 minutes(0), 39 minutes(0),
40 seconds(0), 40 seconds(0),
41 hours(0), 41 hours(0),
42 days(0), 42 days(0),
43 tl1(0), 43 tl1(0),
44// stats(st), 44// stats(st),
45 accountingEnabled(false), 45 accountingEnabled(false),
46 volumeAccountingEnabled(false) 46 volumeAccountingEnabled(false)
47{ 47{
48 info1 = new QLabel(i18n("Connected at:"), this); 48 info1 = new QLabel(i18n("Connected at:"), this);
49 info2 = new QLabel("", this); 49 info2 = new QLabel("", this);
50 50
51 timelabel1 = new QLabel(i18n("Time connected:"), this); 51 timelabel1 = new QLabel(i18n("Time connected:"), this);
52 timelabel2 = new QLabel("000:00:00", this); 52 timelabel2 = new QLabel("000:00:00", this);
53 53
54 vollabel = new QLabel(i18n("Volume:"), this); 54 vollabel = new QLabel(i18n("Volume:"), this);
55 volinfo = new QLabel("", this); 55 volinfo = new QLabel("", this);
56 56
57 // now the stuff for accounting 57 // now the stuff for accounting
58 session_bill_l = new QLabel(i18n("Session Bill:"), this); 58 session_bill_l = new QLabel(i18n("Session Bill:"), this);
59 session_bill = new QLabel("", this); 59 session_bill = new QLabel("", this);
60 total_bill_l = new QLabel(i18n("Total Bill:"), this); 60 total_bill_l = new QLabel(i18n("Total Bill:"), this);
61 total_bill = new QLabel("", this); 61 total_bill = new QLabel("", this);
62 62
63 this->setCaption("kppp"); 63 this->setCaption("kppp");
64 64
65 cancelbutton = new QPushButton(this); 65 cancelbutton = new QPushButton(this);
66 cancelbutton->setText(i18n("Disconnect")); 66 cancelbutton->setText(i18n("Disconnect"));
67 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); 67 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));
68 68
69 // statsbutton = new QPushButton(this); 69 // statsbutton = new QPushButton(this);
70// statsbutton->setText(i18n("Details")); 70// statsbutton->setText(i18n("Details"));
71// statsbutton->setFocus(); 71// statsbutton->setFocus();
72// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); 72// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));
73 73
74 clocktimer = new QTimer(this); 74 clocktimer = new QTimer(this);
75 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); 75 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
76 76
77 // read window position from config file 77 // read window position from config file
78 int p_x, p_y; 78// int p_x, p_y;
79 gpppdata.winPosConWin(p_x, p_y); 79// PPPData::data()->winPosConWin(p_x, p_y);
80 setGeometry(p_x, p_y, 320, 110); 80// setGeometry(p_x, p_y, 320, 110);
81} 81}
82 82
83ConWindow::~ConWindow() { 83ConWindow::~ConWindow() {
84 stopClock(); 84 stopClock();
85} 85}
86 86
87// save window position when window was closed 87// save window position when window was closed
88bool ConWindow::event(QEvent *e) { 88bool ConWindow::event(QEvent *e) {
89 if (e->type() == QEvent::Hide) 89 if (e->type() == QEvent::Hide)
90 { 90 {
91 gpppdata.setWinPosConWin(x(), y()); 91// PPPData::data()->setWinPosConWin(x(), y());
92 return true; 92 return true;
93 } 93 }
94 else 94 else
95 return QWidget::event(e); 95 return QWidget::event(e);
96} 96}
97 97
98QString ConWindow::prettyPrintVolume(unsigned int n) { 98QString ConWindow::prettyPrintVolume(unsigned int n) {
99 int idx = 0; 99 int idx = 0;
100 const QString quant[] = {i18n("Byte"), i18n("KB"), 100 const QString quant[] = {i18n("Byte"), i18n("KB"),
101 i18n("MB"), i18n("GB"), QString::null}; 101 i18n("MB"), i18n("GB"), QString::null};
102 102
103 float n1 = n; 103 float n1 = n;
104 while(n >= 1024 && quant[idx] != QString::null) { 104 while(n >= 1024 && quant[idx] != QString::null) {
105 idx++; 105 idx++;
106 n /= 1024; 106 n /= 1024;
107 } 107 }
108 108
109 int i = idx; 109 int i = idx;
110 while(i--) 110 while(i--)
111 n1 = n1 / 1024.0; 111 n1 = n1 / 1024.0;
112 112
113 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); 113 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
114 s += " " + quant[idx]; 114 s += " " + quant[idx];
115 return s; 115 return s;
116} 116}
117 117
118void ConWindow::accounting(bool on) { 118void ConWindow::accounting(bool on) {
119 // cache accounting settings 119 // cache accounting settings
120 accountingEnabled = on; 120 accountingEnabled = on;
121 volumeAccountingEnabled = gpppdata.VolAcctEnabled(); 121 volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
122 122
123 // delete old layout 123 // delete old layout
124 if(tl1 != 0) 124 if(tl1 != 0)
125 delete tl1; 125 delete tl1;
126 126
127 // add layout now 127 // add layout now
128 tl1 = new QVBoxLayout(this, 10, 10); 128 tl1 = new QVBoxLayout(this, 10, 10);
129 tl1->addSpacing(5); 129 tl1->addSpacing(5);
130 QHBoxLayout *tl = new QHBoxLayout; 130 QHBoxLayout *tl = new QHBoxLayout;
131 tl1->addLayout(tl); 131 tl1->addLayout(tl);
132 tl->addSpacing(20); 132 tl->addSpacing(20);
133 QGridLayout *l1; 133 QGridLayout *l1;
134 134
135 int vol_lines = 0; 135 int vol_lines = 0;
136 if(gpppdata.VolAcctEnabled()) 136 if(PPPData::data()->VolAcctEnabled())
137 vol_lines = 1; 137 vol_lines = 1;
138 138
139 if(accountingEnabled) 139 if(accountingEnabled)
140 l1 = new QGridLayout(4 + vol_lines, 2, 5); 140 l1 = new QGridLayout(4 + vol_lines, 2, 5);
141 else 141 else
142 l1 = new QGridLayout(2 + vol_lines, 2, 5); 142 l1 = new QGridLayout(2 + vol_lines, 2, 5);
143 tl->addLayout(l1); 143 tl->addLayout(l1);
144 l1->setColStretch(0, 0); 144 l1->setColStretch(0, 0);
145 l1->setColStretch(1, 1); 145 l1->setColStretch(1, 1);
146 146
147 info2->setAlignment(AlignRight|AlignVCenter); 147 info2->setAlignment(AlignRight|AlignVCenter);
148 timelabel2->setAlignment(AlignRight|AlignVCenter); 148 timelabel2->setAlignment(AlignRight|AlignVCenter);
149 session_bill->setAlignment(AlignRight|AlignVCenter); 149 session_bill->setAlignment(AlignRight|AlignVCenter);
150 total_bill->setAlignment(AlignRight|AlignVCenter); 150 total_bill->setAlignment(AlignRight|AlignVCenter);
151 volinfo->setAlignment(AlignRight|AlignVCenter); 151 volinfo->setAlignment(AlignRight|AlignVCenter);
152 // make sure that there's enough space for the bills 152 // make sure that there's enough space for the bills
153 QString s1 = session_bill->text(); 153 QString s1 = session_bill->text();
154 QString s2 = total_bill->text(); 154 QString s2 = total_bill->text();
155 QString s3 = volinfo->text(); 155 QString s3 = volinfo->text();
156 156
157 session_bill->setText("888888.88 XXX"); 157 session_bill->setText("888888.88 XXX");
158 total_bill->setText("888888.88 XXX"); 158 total_bill->setText("888888.88 XXX");
159 volinfo->setText("8888.8 MB"); 159 volinfo->setText("8888.8 MB");
160 session_bill->setFixedSize(session_bill->sizeHint()); 160 session_bill->setFixedSize(session_bill->sizeHint());
161 total_bill->setFixedSize(total_bill->sizeHint()); 161 total_bill->setFixedSize(total_bill->sizeHint());
162 volinfo->setFixedSize(volinfo->sizeHint()); 162 volinfo->setFixedSize(volinfo->sizeHint());
163 session_bill->setText(s1); 163 session_bill->setText(s1);
164 total_bill->setText(s2); 164 total_bill->setText(s2);
165 volinfo->setText(s3); 165 volinfo->setText(s3);
166 166
167 l1->addWidget(info1, 0, 0); 167 l1->addWidget(info1, 0, 0);
168 l1->addWidget(info2, 0, 1); 168 l1->addWidget(info2, 0, 1);
169 l1->addWidget(timelabel1, 1, 0); 169 l1->addWidget(timelabel1, 1, 0);
170 l1->addWidget(timelabel2, 1, 1); 170 l1->addWidget(timelabel2, 1, 1);
171 if(accountingEnabled) { 171 if(accountingEnabled) {
172 session_bill_l->show(); 172 session_bill_l->show();
173 session_bill->show(); 173 session_bill->show();
174 total_bill_l->show(); 174 total_bill_l->show();
175 total_bill->show(); 175 total_bill->show();
176 l1->addWidget(session_bill_l, 2, 0); 176 l1->addWidget(session_bill_l, 2, 0);
177 l1->addWidget(session_bill, 2, 1); 177 l1->addWidget(session_bill, 2, 1);
178 l1->addWidget(total_bill_l, 3, 0); 178 l1->addWidget(total_bill_l, 3, 0);
179 l1->addWidget(total_bill, 3, 1); 179 l1->addWidget(total_bill, 3, 1);
180 180
181 if(volumeAccountingEnabled) { 181 if(volumeAccountingEnabled) {
182 vollabel->show(); 182 vollabel->show();
183 volinfo->show(); 183 volinfo->show();
184 l1->addWidget(vollabel, 4, 0); 184 l1->addWidget(vollabel, 4, 0);
185 l1->addWidget(volinfo, 4, 1); 185 l1->addWidget(volinfo, 4, 1);
186 } else { 186 } else {
187 vollabel->hide(); 187 vollabel->hide();
188 volinfo->hide(); 188 volinfo->hide();
189 } 189 }
190 190
191 } else { 191 } else {
192 session_bill_l->hide(); 192 session_bill_l->hide();
193 session_bill->hide(); 193 session_bill->hide();
194 total_bill_l->hide(); 194 total_bill_l->hide();
195 total_bill->hide(); 195 total_bill->hide();
196 196
197 if(volumeAccountingEnabled) { 197 if(volumeAccountingEnabled) {
198 vollabel->show(); 198 vollabel->show();
199 volinfo->show(); 199 volinfo->show();
200 l1->addWidget(vollabel, 2, 0); 200 l1->addWidget(vollabel, 2, 0);
201 l1->addWidget(volinfo, 2, 1); 201 l1->addWidget(volinfo, 2, 1);
202 } else { 202 } else {
203 vollabel->hide(); 203 vollabel->hide();
204 volinfo->hide(); 204 volinfo->hide();
205 } 205 }
206 } 206 }
207 207
208 tl->addSpacing(10); 208 tl->addSpacing(10);
209 QVBoxLayout *l2 = new QVBoxLayout(5); 209 QVBoxLayout *l2 = new QVBoxLayout(5);
210 tl->addLayout(l2); 210 tl->addLayout(l2);
211 l2->addStretch(1); 211 l2->addStretch(1);
212// l2->addWidget(statsbutton); 212// l2->addWidget(statsbutton);
213 l2->addWidget(cancelbutton); 213 l2->addWidget(cancelbutton);
214 214
215 l2->addStretch(1); 215 l2->addStretch(1);
216 216
217 tl1->addSpacing(5); 217 tl1->addSpacing(5);
218 218
219 setFixedSize(sizeHint()); 219 setFixedSize(sizeHint());
220/* 220/*
221 do not overwrite position read from config 221 do not overwrite position read from config
222 setGeometry((QApplication::desktop()->width() - width()) / 2, 222 setGeometry((QApplication::desktop()->width() - width()) / 2,
223 (QApplication::desktop()->height() - height())/2, 223 (QApplication::desktop()->height() - height())/2,
224 width(), 224 width(),
225 height()); 225 height());
226*/ 226*/
227} 227}
228 228
229 229
230void ConWindow::dock() { 230void ConWindow::dock() {
231// DockWidget::dock_widget->show(); 231// DockWidget::dock_widget->show();
232 this->hide(); 232 this->hide();
233} 233}
234 234
235 235
236void ConWindow::startClock() { 236void ConWindow::startClock() {
237 minutes = 0; 237 minutes = 0;
238 seconds = 0; 238 seconds = 0;
239 hours = 0; 239 hours = 0;
240 QString title ; 240 QString title ;
241 241
242 title = gpppdata.accname(); 242 title = PPPData::data()->accname();
243 243
244 if(gpppdata.get_show_clock_on_caption()){ 244 if(PPPData::data()->get_show_clock_on_caption()){
245 title += " 00:00" ; 245 title += " 00:00" ;
246 } 246 }
247 this->setCaption(title); 247 this->setCaption(title);
248 248
249 timelabel2->setText("00:00:00"); 249 timelabel2->setText("00:00:00");
250 clocktimer->start(1000); 250 clocktimer->start(1000);
251} 251}
252 252
253 253
254void ConWindow::setConnectionSpeed(const QString &speed) { 254void ConWindow::setConnectionSpeed(const QString &speed) {
255 info2->setText(speed); 255 info2->setText(speed);
256} 256}
257 257
258 258
259void ConWindow::stopClock() { 259void ConWindow::stopClock() {
260 clocktimer->stop(); 260 clocktimer->stop();
261} 261}
262 262
263 263
264void ConWindow::timeclick() { 264void ConWindow::timeclick() {
265 QString tooltip = i18n("Connection: %1\n" 265 QString tooltip = i18n("Connection: %1\n"
266 "Connected at: %2\n" 266 "Connected at: %2\n"
267 "Time connected: %3") 267 "Time connected: %3")
268 .arg(gpppdata.accname()).arg(info2->text()) 268 .arg(PPPData::data()->accname()).arg(info2->text())
269 .arg(time_string2); 269 .arg(time_string2);
270 270
271 if(accountingEnabled) 271 if(accountingEnabled)
272 tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") 272 tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
273 .arg(session_bill->text()).arg(total_bill->text()); 273 .arg(session_bill->text()).arg(total_bill->text());
274 // volume accounting 274 // volume accounting
275 if(volumeAccountingEnabled) { 275 if(volumeAccountingEnabled) {
276 276
277 volinfo->setEnabled(TRUE); 277 volinfo->setEnabled(TRUE);
278 int bytes = gpppdata.totalBytes(); 278 int bytes = PPPData::data()->totalBytes();
279 volinfo->setText(prettyPrintVolume(bytes)); 279 volinfo->setText(prettyPrintVolume(bytes));
280 } 280 }
281 281
282 seconds++; 282 seconds++;
283 283
284 if(seconds >= 60 ) { 284 if(seconds >= 60 ) {
285 minutes ++; 285 minutes ++;
286 seconds = 0; 286 seconds = 0;
287 } 287 }
288 288
289 if (minutes >= 60){ 289 if (minutes >= 60){
290 minutes = 0; 290 minutes = 0;
291 hours ++; 291 hours ++;
292 } 292 }
293 293
294 if( hours >= 24){ 294 if( hours >= 24){
295 days ++; 295 days ++;
296 hours = 0; 296 hours = 0;
297 } 297 }
298 298
299 time_string.sprintf("%02d:%02d",hours,minutes); 299 time_string.sprintf("%02d:%02d",hours,minutes);
300 time_string2 = ""; 300 time_string2 = "";
301 if (days) 301 if (days)
302 time_string2.sprintf("%d d %02d:%02d:%02d", 302 time_string2.sprintf("%d d %02d:%02d:%02d",
303 days,hours,minutes,seconds); 303 days,hours,minutes,seconds);
304 304
305 else 305 else
306 time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); 306 time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
307 307
308 caption_string = gpppdata.accname(); 308 caption_string = PPPData::data()->accname();
309 caption_string += " "; 309 caption_string += " ";
310 caption_string += time_string; 310 caption_string += time_string;
311 311
312 312
313 timelabel2->setText(time_string2); 313 timelabel2->setText(time_string2);
314 314
315 if(gpppdata.get_show_clock_on_caption() && (seconds == 1)){ 315 if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
316 // we update the Caption only once per minute not every second 316 // we update the Caption only once per minute not every second
317 // otherwise I get a flickering icon 317 // otherwise I get a flickering icon
318 this->setCaption(caption_string); 318 this->setCaption(caption_string);
319 } 319 }
320 320
321// QToolTip::add(DockWidget::dock_widget, tooltip); 321// QToolTip::add(DockWidget::dock_widget, tooltip);
322} 322}
323 323
324 324
325void ConWindow::closeEvent( QCloseEvent *e ){ 325void ConWindow::closeEvent( QCloseEvent *e ){
326 // we don't want to lose the 326 // we don't want to lose the
327 // conwindow since this is our last connection kppp. 327 // 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. 328 // if we lost it we could only kill the program by hand to get on with life.
329 e->ignore(); 329 e->ignore();
330 330
331 if(gpppdata.get_dock_into_panel()) 331 if(PPPData::data()->get_dock_into_panel())
332 dock(); 332 dock();
333} 333}
334 334
335 335
336void ConWindow::slotAccounting(QString total, QString session) { 336void ConWindow::slotAccounting(QString total, QString session) {
337 total_bill->setText(total); 337 total_bill->setText(total);
338 session_bill->setText(session); 338 session_bill->setText(session);
339} 339}
340 340
341 341
diff --git a/noncore/settings/networksettings/ppp/debug.cpp b/noncore/settings/networksettings/ppp/debug.cpp
index 8652931..447ccf2 100644
--- a/noncore/settings/networksettings/ppp/debug.cpp
+++ b/noncore/settings/networksettings/ppp/debug.cpp
@@ -40,102 +40,102 @@ void myMultiEdit::insertChar(unsigned char c) {
40 QMultiLineEdit::insert(QChar(c)); 40 QMultiLineEdit::insert(QChar(c));
41} 41}
42 42
43 43
44void myMultiEdit::newLine() { 44void myMultiEdit::newLine() {
45 QMultiLineEdit::newLine(); 45 QMultiLineEdit::newLine();
46} 46}
47 47
48 48
49DebugWidget::DebugWidget(QWidget *parent, const char *name) 49DebugWidget::DebugWidget(QWidget *parent, const char *name)
50 : QDialog(parent, name, FALSE) 50 : QDialog(parent, name, FALSE)
51{ 51{
52 setCaption(i18n("Login Script Debug Window")); 52 setCaption(i18n("Login Script Debug Window"));
53 53
54 text_window = new myMultiEdit(this,"debugwindow"); 54 text_window = new myMultiEdit(this,"debugwindow");
55 text_window->setGeometry(2,5,400, 300); 55 text_window->setGeometry(2,5,400, 300);
56 // text_window->setReadOnly(FALSE); 56 // text_window->setReadOnly(FALSE);
57 57
58 statuslabel = new QLabel("", this, "statuslabel"); 58 statuslabel = new QLabel("", this, "statuslabel");
59 59
60 statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 60 statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
61 statuslabel->setAlignment( AlignLeft|AlignVCenter ); 61 statuslabel->setAlignment( AlignLeft|AlignVCenter );
62 statuslabel->setGeometry(2, 307, 400, 20); 62 statuslabel->setGeometry(2, 307, 400, 20);
63 //statusPageLabel->setFont( QFont("helvetica",12,QFont::Normal) ); 63 //statusPageLabel->setFont( QFont("helvetica",12,QFont::Normal) );
64 64
65 dismiss = new QPushButton(this); 65 dismiss = new QPushButton(this);
66 dismiss->setGeometry(330,340,70,30); 66 dismiss->setGeometry(330,340,70,30);
67 dismiss->setText(i18n("Close")); 67 dismiss->setText(i18n("Close"));
68 dismiss->setFocus(); 68 dismiss->setFocus();
69 connect(dismiss, SIGNAL(clicked()), SLOT(hide())); 69 connect(dismiss, SIGNAL(clicked()), SLOT(hide()));
70 70
71 71
72 /* fline = new QFrame(this,"line"); 72 /* fline = new QFrame(this,"line");
73 fline->setFrameStyle(QFrame::HLine |QFrame::Sunken); 73 fline->setFrameStyle(QFrame::HLine |QFrame::Sunken);
74 fline->setGeometry(2,332,398,5);*/ 74 fline->setGeometry(2,332,398,5);*/
75 adjustSize(); 75 adjustSize();
76 setMinimumSize(width(),height()); 76 setMinimumSize(width(),height());
77 77
78} 78}
79 79
80void DebugWidget::hideEvent(QHideEvent *) 80void DebugWidget::hideEvent(QHideEvent *)
81{ 81{
82 assert(p_kppp); 82 assert(p_kppp);
83// p_kppp->con->debug->setOn(false); 83// p_kppp->con->debug->setOn(false);
84} 84}
85 85
86void DebugWidget::clear() { 86void DebugWidget::clear() {
87 text_window->clear(); 87 text_window->clear();
88} 88}
89 89
90 90
91void DebugWidget::addChar(unsigned char c) { 91void DebugWidget::addChar(unsigned char c) {
92 QString stuff; 92 QString stuff;
93 93
94 if(c == '\r' || c == '\n') { 94 if(c == '\r' || c == '\n') {
95 if(c == '\n') 95 if(c == '\n')
96 text_window->newLine(); 96 text_window->newLine();
97 } else 97 } else
98 text_window->insertChar(c); 98 text_window->insertChar(c);
99} 99}
100 100
101 101
102void DebugWidget::statusLabel(const QString &s) { 102void DebugWidget::statusLabel(const QString &s) {
103 statuslabel->setText(s); 103 statuslabel->setText(s);
104} 104}
105 105
106 106
107/* 107/*
108void DebugWidget::keyPressEvent(QKeyEvent *k) { 108void DebugWidget::keyPressEvent(QKeyEvent *k) {
109} 109}
110 110
111*/ 111*/
112void DebugWidget::resizeEvent(QResizeEvent *e){ 112void DebugWidget::resizeEvent(QResizeEvent *e){
113 int w = width() ; 113 int w = width() ;
114 int h = height(); 114 int h = height();
115 e = e; 115 e = e;
116 116
117 text_window->setGeometry(2,5,w - 2 ,h - 63); 117 text_window->setGeometry(2,5,w - 2 ,h - 63);
118 statuslabel->setGeometry(2, h - 56 , w -2 , 20); 118 statuslabel->setGeometry(2, h - 56 , w -2 , 20);
119 dismiss->setGeometry(w - 72 , h - 32, 70, 30); 119 dismiss->setGeometry(w - 72 , h - 32, 70, 30);
120 // fline->setGeometry(2,h -70 ,w - 4,5); 120 // fline->setGeometry(2,h -70 ,w - 4,5);
121} 121}
122 122
123 123
124void DebugWidget::enter() { 124void DebugWidget::enter() {
125 text_window->append("\r\n"); 125 text_window->append("\r\n");
126} 126}
127 127
128 128
129void DebugWidget::toggleVisibility() { 129void DebugWidget::toggleVisibility() {
130 if(isVisible()) 130 if(isVisible())
131 hide(); 131 hide();
132 else 132 else
133 show(); 133 show();
134 134
135 bool showlog = isVisible(); 135 bool showlog = isVisible();
136 gpppdata.set_show_log_window(showlog); 136 PPPData::data()->set_show_log_window(showlog);
137} 137}
138 138
139 139
140 140
141 141
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 961047b..6132b80 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -1,1016 +1,1016 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * 7 *
8 * based on EzPPP: 8 * based on EzPPP:
9 * Copyright (C) 1997 Jay Painter 9 * Copyright (C) 1997 Jay Painter
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public 21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free 22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#include <string.h> 26#include <string.h>
27#include <termios.h> 27#include <termios.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <kiconloader.h> 33//#include <kiconloader.h>
34#include <qbuttongroup.h> 34#include <qbuttongroup.h>
35//#include <klocale.h> 35//#include <klocale.h>
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( QWidget *parent, bool isnewaccount, const char *name )
49 : QWidget(parent, name) 49 : QWidget(parent, name)
50{ 50{
51 const int GRIDROWS = 6; 51 const int GRIDROWS = 6;
52 52
53 QGridLayout *tl = new QGridLayout(parent, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); 53 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
54 54
55 connect_label = new QLabel(i18n("Connection name:"), parent); 55 connect_label = new QLabel(i18n("Connection name:"), this);
56 tl->addWidget(connect_label, 0, 0); 56 tl->addWidget(connect_label, 0, 0);
57 57
58 connectname_l = new QLineEdit(parent); 58 connectname_l = new QLineEdit(this);
59 connectname_l->setMaxLength(ACCNAME_SIZE); 59// connectname_l->setMaxLength(ACCNAME_SIZE);
60 tl->addWidget(connectname_l, 0, 1); 60 tl->addWidget(connectname_l, 0, 1);
61 QString tmp = i18n("Type in a unique name for this connection"); 61 QString tmp = i18n("Type in a unique name for this connection");
62 62
63 QWhatsThis::add(connect_label,tmp); 63 QWhatsThis::add(connect_label,tmp);
64 QWhatsThis::add(connectname_l,tmp); 64 QWhatsThis::add(connectname_l,tmp);
65 65
66 66
67 number_label = new QLabel(i18n("Phone number:"), parent); 67 number_label = new QLabel(i18n("Phone number:"), this);
68 number_label->setAlignment(AlignTop|AlignLeft); 68 number_label->setAlignment(AlignTop|AlignLeft);
69 tl->addWidget(number_label, 1, 0); 69 tl->addWidget(number_label, 1, 0);
70 70
71 QHBoxLayout *lpn = new QHBoxLayout(5); 71 QHBoxLayout *lpn = new QHBoxLayout(5);
72 tl->addLayout(lpn, 1, 1); 72 tl->addLayout(lpn, 1, 1);
73 numbers = new QListBox(parent); 73 numbers = new QListBox(this);
74 numbers->setMinimumSize(120, 70); 74 numbers->setMinimumSize(120, 70);
75 lpn->addWidget(numbers); 75 lpn->addWidget(numbers);
76 QVBoxLayout *lpn1 = new QVBoxLayout; 76 QVBoxLayout *lpn1 = new QVBoxLayout;
77 lpn->addLayout(lpn1); 77 lpn->addLayout(lpn1);
78 add = new QPushButton(i18n("&Add..."), parent); 78 add = new QPushButton(i18n("&Add..."), this);
79 del = new QPushButton(i18n("&Remove"), parent); 79 del = new QPushButton(i18n("&Remove"), this);
80 80
81 up = new QPushButton(parent); 81 up = new QPushButton(this);
82//FIXME: QPixmap pm = BarIcon("up"); 82//FIXME: QPixmap pm = BarIcon("up");
83// up->setPixmap(pm); 83// up->setPixmap(pm);
84 down = new QPushButton(parent); 84 down = new QPushButton(this);
85//FIXME: pm = BarIcon("down"); 85//FIXME: pm = BarIcon("down");
86// down->setPixmap(pm); 86// down->setPixmap(pm);
87 lpn1->addWidget(add); 87 lpn1->addWidget(add);
88 lpn1->addWidget(del); 88 lpn1->addWidget(del);
89 lpn1->addStretch(1); 89 lpn1->addStretch(1);
90 lpn1->addWidget(up); 90 lpn1->addWidget(up);
91 lpn1->addWidget(down); 91 lpn1->addWidget(down);
92 connect(add, SIGNAL(clicked()), 92 connect(add, SIGNAL(clicked()),
93 this, SLOT(addNumber())); 93 this, SLOT(addNumber()));
94 connect(del, SIGNAL(clicked()), 94 connect(del, SIGNAL(clicked()),
95 this, SLOT(delNumber())); 95 this, SLOT(delNumber()));
96 connect(up, SIGNAL(clicked()), 96 connect(up, SIGNAL(clicked()),
97 this, SLOT(upNumber())); 97 this, SLOT(upNumber()));
98 connect(down, SIGNAL(clicked()), 98 connect(down, SIGNAL(clicked()),
99 this, SLOT(downNumber())); 99 this, SLOT(downNumber()));
100 connect(numbers, SIGNAL(highlighted(int)), 100 connect(numbers, SIGNAL(highlighted(int)),
101 this, SLOT(selectionChanged(int))); 101 this, SLOT(selectionChanged(int)));
102 numbersChanged(); 102 numbersChanged();
103 103
104 tmp = i18n("<p>Specifies the phone numbers to dial. You\n" 104 tmp = i18n("<p>Specifies the phone numbers to dial. You\n"
105 "can supply multiple numbers here, simply\n" 105 "can supply multiple numbers here, simply\n"
106 "click on \"Add\". You can arrange the\n" 106 "click on \"Add\". You can arrange the\n"
107 "order the numbers are tried by using the\n" 107 "order the numbers are tried by using the\n"
108 "arrow buttons.\n\n" 108 "arrow buttons.\n\n"
109 "When a number is busy or fails, <i>kppp</i> will \n" 109 "When a number is busy or fails, <i>kppp</i> will \n"
110 "try the next number and so on"); 110 "try the next number and so on");
111 111
112 QWhatsThis::add(number_label,tmp); 112 QWhatsThis::add(number_label,tmp);
113 QWhatsThis::add(numbers,tmp); 113 QWhatsThis::add(numbers,tmp);
114 114
115 auth_l = new QLabel(i18n("Authentication:"), parent); 115 auth_l = new QLabel(i18n("Authentication:"), this);
116 tl->addWidget(auth_l, 3, 0); 116 tl->addWidget(auth_l, 3, 0);
117 117
118 auth = new QComboBox(parent); 118 auth = new QComboBox(this);
119 auth->insertItem(i18n("Script-based")); 119 auth->insertItem(i18n("Script-based"));
120 auth->insertItem(i18n("PAP")); 120 auth->insertItem(i18n("PAP"));
121 auth->insertItem(i18n("Terminal-based")); 121 auth->insertItem(i18n("Terminal-based"));
122 auth->insertItem(i18n("CHAP")); 122 auth->insertItem(i18n("CHAP"));
123 auth->insertItem(i18n("PAP/CHAP")); 123 auth->insertItem(i18n("PAP/CHAP"));
124 tl->addWidget(auth, 3, 1); 124 tl->addWidget(auth, 3, 1);
125 tmp = i18n("<p>Specifies the method used to identify yourself to\n" 125 tmp = i18n("<p>Specifies the method used to identify yourself to\n"
126 "the PPP server. Most universities still use\n" 126 "the PPP server. Most universities still use\n"
127 "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" 127 "<b>Terminal</b>- or <b>Script</b>-based authentication,\n"
128 "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" 128 "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n"
129 "unsure, contact your ISP.\n" 129 "unsure, contact your ISP.\n"
130 "\n" 130 "\n"
131 "If you can choose between PAP and CHAP,\n" 131 "If you can choose between PAP and CHAP,\n"
132 "choose CHAP, because it's much safer. If you don't know\n" 132 "choose CHAP, because it's much safer. If you don't know\n"
133 "whether PAP or CHAP is right, choose PAP/CHAP."); 133 "whether PAP or CHAP is right, choose PAP/CHAP.");
134 134
135 QWhatsThis::add(auth_l,tmp); 135 QWhatsThis::add(auth_l,tmp);
136 QWhatsThis::add(auth,tmp); 136 QWhatsThis::add(auth,tmp);
137 137
138 store_password = new QCheckBox(i18n("Store password"), parent); 138 store_password = new QCheckBox(i18n("Store password"), this);
139 store_password->setChecked(true); 139 store_password->setChecked(true);
140 tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); 140 tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight);
141 QWhatsThis::add(store_password, 141 QWhatsThis::add(store_password,
142 i18n("<p>When this is turned on, your ISP password\n" 142 i18n("<p>When this is turned on, your ISP password\n"
143 "will be saved in <i>kppp</i>'s config file, so\n" 143 "will be saved in <i>kppp</i>'s config file, so\n"
144 "you do not need to type it in every time.\n" 144 "you do not need to type it in every time.\n"
145 "\n" 145 "\n"
146 "<b><font color=\"red\">Warning:</font> your password will be stored as\n" 146 "<b><font color=\"red\">Warning:</font> your password will be stored as\n"
147 "plain text in the config file, which is\n" 147 "plain text in the config file, which is\n"
148 "readable only to you. Make sure nobody\n" 148 "readable only to you. Make sure nobody\n"
149 "gains access to this file!")); 149 "gains access to this file!"));
150 150
151 pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), parent); 151 pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this);
152 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); 152 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
153 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); 153 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
154 154
155 // Set defaults if editing an existing connection 155 // Set defaults if editing an existing connection
156 if(!isnewaccount) { 156 if(!isnewaccount) {
157 connectname_l->setText(gpppdata.accname()); 157 connectname_l->setText(PPPData::data()->accname());
158 158
159 // insert the phone numbers into the listbox 159 // insert the phone numbers into the listbox
160 QString n = gpppdata.phonenumber(); 160 QString n = PPPData::data()->phonenumber();
161 QString tmp = ""; 161 QString tmp = "";
162 uint idx = 0; 162 uint idx = 0;
163 while(idx != n.length()) { 163 while(idx != n.length()) {
164 if(n[idx] == ':') { 164 if(n[idx] == ':') {
165 if(tmp.length() > 0) 165 if(tmp.length() > 0)
166 numbers->insertItem(tmp); 166 numbers->insertItem(tmp);
167 tmp = ""; 167 tmp = "";
168 } else 168 } else
169 tmp += n[idx]; 169 tmp += n[idx];
170 idx++; 170 idx++;
171 } 171 }
172 if(tmp.length() > 0) 172 if(tmp.length() > 0)
173 numbers->insertItem(tmp); 173 numbers->insertItem(tmp);
174 174
175 auth->setCurrentItem(gpppdata.authMethod()); 175 auth->setCurrentItem(PPPData::data()->authMethod());
176 store_password->setChecked(gpppdata.storePassword()); 176 store_password->setChecked(PPPData::data()->storePassword());
177 } else { 177 } else {
178 // select PAP/CHAP as default 178 // select PAP/CHAP as default
179 auth->setCurrentItem(AUTH_PAPCHAP); 179 auth->setCurrentItem(AUTH_PAPCHAP);
180 } 180 }
181 181
182 numbersChanged(); 182 numbersChanged();
183 tl->activate(); 183 tl->activate();
184} 184}
185 185
186 186
187bool DialWidget::save() { 187bool DialWidget::save() {
188 //first check to make sure that the account name is unique! 188 //first check to make sure that the account name is unique!
189 if(connectname_l->text().isEmpty() || 189 if(connectname_l->text().isEmpty() ||
190 !gpppdata.isUniqueAccname(connectname_l->text())) { 190 !PPPData::data()->isUniqueAccname(connectname_l->text())) {
191 return false; 191 return false;
192 } else { 192 } else {
193 gpppdata.setAccname(connectname_l->text()); 193 PPPData::data()->setAccname(connectname_l->text());
194 194
195 QString number = ""; 195 QString number = "";
196 for(uint i = 0; i < numbers->count(); i++) { 196 for(uint i = 0; i < numbers->count(); i++) {
197 if(i != 0) 197 if(i != 0)
198 number += ":"; 198 number += ":";
199 number += numbers->text(i); 199 number += numbers->text(i);
200 } 200 }
201 201
202 gpppdata.setPhonenumber(number); 202 PPPData::data()->setPhonenumber(number);
203 gpppdata.setAuthMethod(auth->currentItem()); 203 PPPData::data()->setAuthMethod(auth->currentItem());
204 gpppdata.setStorePassword(store_password->isChecked()); 204 PPPData::data()->setStorePassword(store_password->isChecked());
205 return true; 205 return true;
206 } 206 }
207} 207}
208 208
209 209
210void DialWidget::numbersChanged() { 210void DialWidget::numbersChanged() {
211 int sel = numbers->currentItem(); 211 int sel = numbers->currentItem();
212 212
213 del->setEnabled(sel != -1); 213 del->setEnabled(sel != -1);
214 up->setEnabled(sel != -1 && sel != 0); 214 up->setEnabled(sel != -1 && sel != 0);
215 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); 215 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
216} 216}
217 217
218 218
219void DialWidget::selectionChanged(int) { 219void DialWidget::selectionChanged(int) {
220 numbersChanged(); 220 numbersChanged();
221} 221}
222 222
223 223
224void DialWidget::addNumber() { 224void DialWidget::addNumber() {
225 PhoneNumberDialog dlg(this); 225 PhoneNumberDialog dlg(this);
226 if(dlg.exec()) { 226 if(dlg.exec()) {
227 numbers->insertItem(dlg.phoneNumber()); 227 numbers->insertItem(dlg.phoneNumber());
228 numbersChanged(); 228 numbersChanged();
229 } 229 }
230} 230}
231 231
232 232
233void DialWidget::delNumber() { 233void DialWidget::delNumber() {
234 if(numbers->currentItem() != -1) { 234 if(numbers->currentItem() != -1) {
235 numbers->removeItem(numbers->currentItem()); 235 numbers->removeItem(numbers->currentItem());
236 numbersChanged(); 236 numbersChanged();
237 } 237 }
238} 238}
239 239
240 240
241void DialWidget::upNumber() { 241void DialWidget::upNumber() {
242 int idx = numbers->currentItem(); 242 int idx = numbers->currentItem();
243 if(idx != -1) { 243 if(idx != -1) {
244 QString item = numbers->text(idx); 244 QString item = numbers->text(idx);
245 numbers->removeItem(idx); 245 numbers->removeItem(idx);
246 numbers->insertItem(item, idx-1); 246 numbers->insertItem(item, idx-1);
247 numbers->setCurrentItem(idx-1); 247 numbers->setCurrentItem(idx-1);
248 numbersChanged(); 248 numbersChanged();
249 } 249 }
250} 250}
251 251
252 252
253void DialWidget::downNumber() { 253void DialWidget::downNumber() {
254 int idx = numbers->currentItem(); 254 int idx = numbers->currentItem();
255 if(idx != -1) { 255 if(idx != -1) {
256 QString item = numbers->text(idx); 256 QString item = numbers->text(idx);
257 numbers->removeItem(idx); 257 numbers->removeItem(idx);
258 numbers->insertItem(item, idx+1); 258 numbers->insertItem(item, idx+1);
259 numbers->setCurrentItem(idx+1); 259 numbers->setCurrentItem(idx+1);
260 numbersChanged(); 260 numbersChanged();
261 } 261 }
262} 262}
263 263
264 264
265void DialWidget::pppdargsbutton() { 265void DialWidget::pppdargsbutton() {
266 PPPdArguments pa(this); 266 PPPdArguments pa(this);
267 pa.exec(); 267 pa.exec();
268} 268}
269 269
270 270
271 271
272///////////////////////////////////////////////////////////////////////////// 272/////////////////////////////////////////////////////////////////////////////
273// ExecWidget 273// ExecWidget
274///////////////////////////////////////////////////////////////////////////// 274/////////////////////////////////////////////////////////////////////////////
275ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) : 275ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) :
276 QWidget(parent, name) 276 QWidget(parent, name)
277{ 277{
278 QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint()); 278 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
279 279
280 QLabel *l = new QLabel(\ 280 QLabel *l = new QLabel(\
281i18n("Here you can select commands to run at certain stages of the\n" 281i18n("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" 282 "connection. The commands are run with your real user id, so\n"
283 "you cannot run any commands here requiring root permissions\n" 283 "you cannot run any commands here requiring root permissions\n"
284 "(unless, of course, you are root).\n\n" 284 "(unless, of course, you are root).\n\n"
285 "Be sure to supply the whole path to the program otherwise\n" 285 "Be sure to supply the whole path to the program otherwise\n"
286 "kppp might be unable to find it."), parent); 286 "kppp might be unable to find it."), this);
287 l->setMinimumHeight(l->sizeHint().height()); 287// l->setMinimumHeight(l->sizeHint().height());
288 tl->addWidget(l); 288 tl->addWidget(l);
289 tl->addStretch(1); 289 tl->addStretch(1);
290 290
291 QGridLayout *l1 = new QGridLayout(4, 2, 10); 291 QGridLayout *l1 = new QGridLayout(4, 2, 10);
292 tl->addLayout(l1); 292 tl->addLayout(l1);
293 l1->setColStretch(0, 0); 293 l1->setColStretch(0, 0);
294 l1->setColStretch(1, 1); 294 l1->setColStretch(1, 1);
295 295
296 before_connect_l = new QLabel(i18n("Before connect:"), parent); 296 before_connect_l = new QLabel(i18n("Before connect:"), this);
297 before_connect_l->setAlignment(AlignVCenter); 297 before_connect_l->setAlignment(AlignVCenter);
298 l1->addWidget(before_connect_l, 0, 0); 298 l1->addWidget(before_connect_l, 0, 0);
299 before_connect = new QLineEdit(parent); 299 before_connect = new QLineEdit(this);
300 before_connect->setMaxLength(COMMAND_SIZE); 300// before_connect->setMaxLength(COMMAND_SIZE);
301 l1->addWidget(before_connect, 0, 1); 301 l1->addWidget(before_connect, 0, 1);
302 QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n" 302 QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
303 "is established. It is called immediately before\n" 303 "is established. It is called immediately before\n"
304 "dialing has begun.\n\n" 304 "dialing has begun.\n\n"
305 "This might be useful, e.g. to stop HylaFAX blocking the\n" 305 "This might be useful, e.g. to stop HylaFAX blocking the\n"
306 "modem."); 306 "modem.");
307 307
308 QWhatsThis::add(before_connect_l,tmp); 308 QWhatsThis::add(before_connect_l,tmp);
309 QWhatsThis::add(before_connect,tmp); 309 QWhatsThis::add(before_connect,tmp);
310 310
311 command_label = new QLabel(i18n("Upon connect:"), parent); 311 command_label = new QLabel(i18n("Upon connect:"), this);
312 command_label->setAlignment(AlignVCenter); 312 command_label->setAlignment(AlignVCenter);
313 l1->addWidget(command_label, 1, 0); 313 l1->addWidget(command_label, 1, 0);
314 command = new QLineEdit(parent); 314 command = new QLineEdit(this);
315 command->setMaxLength(COMMAND_SIZE); 315// command->setMaxLength(COMMAND_SIZE);
316 l1->addWidget(command, 1, 1); 316 l1->addWidget(command, 1, 1);
317 tmp = i18n("Allows you to run a program <b>after</b> a connection\n" 317 tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
318 "is established. When your program is called, all\n" 318 "is established. When your program is called, all\n"
319 "preparations for an Internet connection are finished.\n" 319 "preparations for an Internet connection are finished.\n"
320 "\n" 320 "\n"
321 "Very useful for fetching mail and news"); 321 "Very useful for fetching mail and news");
322 322
323 QWhatsThis::add(command_label,tmp); 323 QWhatsThis::add(command_label,tmp);
324 QWhatsThis::add(command,tmp); 324 QWhatsThis::add(command,tmp);
325 325
326 predisconnect_label = new QLabel(i18n("Before disconnect:"), 326 predisconnect_label = new QLabel(i18n("Before disconnect:"),
327 parent); 327 this);
328 predisconnect_label->setAlignment(AlignVCenter); 328 predisconnect_label->setAlignment(AlignVCenter);
329 l1->addWidget(predisconnect_label, 2, 0); 329 l1->addWidget(predisconnect_label, 2, 0);
330 predisconnect = new QLineEdit(parent); 330 predisconnect = new QLineEdit(this);
331 predisconnect->setMaxLength(COMMAND_SIZE); 331// predisconnect->setMaxLength(COMMAND_SIZE);
332 l1->addWidget(predisconnect, 2, 1); 332 l1->addWidget(predisconnect, 2, 1);
333 tmp = i18n("Allows you to run a program <b>before</b> a connection\n" 333 tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
334 "is closed. The connection will stay open until\n" 334 "is closed. The connection will stay open until\n"
335 "the program exits."); 335 "the program exits.");
336 336
337 QWhatsThis::add(predisconnect_label,tmp); 337 QWhatsThis::add(predisconnect_label,tmp);
338 QWhatsThis::add(predisconnect,tmp); 338 QWhatsThis::add(predisconnect,tmp);
339 339
340 discommand_label = new QLabel(i18n("Upon disconnect:"), 340 discommand_label = new QLabel(i18n("Upon disconnect:"),
341 parent); 341 this);
342 discommand_label->setAlignment(AlignVCenter); 342 discommand_label->setAlignment(AlignVCenter);
343 l1->addWidget(discommand_label, 3, 0); 343 l1->addWidget(discommand_label, 3, 0);
344 344
345 discommand = new QLineEdit(parent); 345 discommand = new QLineEdit(this);
346 discommand->setMaxLength(COMMAND_SIZE); 346// discommand->setMaxLength(COMMAND_SIZE);
347 l1->addWidget(discommand, 3, 1); 347 l1->addWidget(discommand, 3, 1);
348 tmp = i18n("Allows you to run a program <b>after</b> a connection\n" 348 tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
349 "has been closed."); 349 "has been closed.");
350 350
351 QWhatsThis::add(discommand_label,tmp); 351 QWhatsThis::add(discommand_label,tmp);
352 QWhatsThis::add(discommand,tmp); 352 QWhatsThis::add(discommand,tmp);
353 353
354 // extra space between entries 354 // extra space between entries
355 l1->addRowSpacing(1, 5); 355 l1->addRowSpacing(1, 5);
356 l1->addRowSpacing(3, 5); 356 l1->addRowSpacing(3, 5);
357 357
358 tl->addStretch(1); 358 tl->addStretch(1);
359 tl->activate(); 359 tl->activate();
360 360
361 // Set defaults if editing an existing connection 361 // Set defaults if editing an existing connection
362 if(!isnewaccount) { 362 if(!isnewaccount) {
363 before_connect->setText(gpppdata.command_before_connect()); 363 before_connect->setText(PPPData::data()->command_before_connect());
364 command->setText(gpppdata.command_on_connect()); 364 command->setText(PPPData::data()->command_on_connect());
365 discommand->setText(gpppdata.command_on_disconnect()); 365 discommand->setText(PPPData::data()->command_on_disconnect());
366 predisconnect->setText(gpppdata.command_before_disconnect()); 366 predisconnect->setText(PPPData::data()->command_before_disconnect());
367 } 367 }
368} 368}
369 369
370 370
371bool ExecWidget::save() { 371bool ExecWidget::save() {
372 gpppdata.setCommand_before_connect(before_connect->text()); 372 PPPData::data()->setCommand_before_connect(before_connect->text());
373 gpppdata.setCommand_on_connect(command->text()); 373 PPPData::data()->setCommand_on_connect(command->text());
374 gpppdata.setCommand_before_disconnect(predisconnect->text()); 374 PPPData::data()->setCommand_before_disconnect(predisconnect->text());
375 gpppdata.setCommand_on_disconnect(discommand->text()); 375 PPPData::data()->setCommand_on_disconnect(discommand->text());
376 return true; 376 return true;
377} 377}
378 378
379 379
380 380
381///////////////////////////////////////////////////////////////////////////// 381/////////////////////////////////////////////////////////////////////////////
382// 382//
383// IPWidget 383// IPWidget
384// 384//
385///////////////////////////////////////////////////////////////////////////// 385/////////////////////////////////////////////////////////////////////////////
386IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) 386IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name )
387 : QWidget(parent, name) 387 : QWidget(parent, name)
388{ 388{
389 QVBoxLayout *topLayout = new QVBoxLayout(parent); 389 QVBoxLayout *topLayout = new QVBoxLayout(this);
390 topLayout->setSpacing( 3 );//KDialog::spacingHint()); 390 topLayout->setSpacing( 3 );//KDialog::spacingHint());
391 391
392 box = new QVGroupBox(i18n("Configuration"), parent); 392 box = new QVGroupBox(i18n("Configuration"), this);
393// box->setInsideSpacing( 1 );//KDialog::spacingHint()); 393// box->setInsideSpacing( 1 );//KDialog::spacingHint());
394 394
395 rb = new QButtonGroup(parent); 395 rb = new QButtonGroup(this);
396 rb->hide(); 396 rb->hide();
397 connect(rb, SIGNAL(clicked(int)), 397 connect(rb, SIGNAL(clicked(int)),
398 SLOT(hitIPSelect(int))); 398 SLOT(hitIPSelect(int)));
399 399
400 dynamicadd_rb = new QRadioButton(box); 400 dynamicadd_rb = new QRadioButton(box);
401 dynamicadd_rb->setText(i18n("Dynamic IP address")); 401 dynamicadd_rb->setText(i18n("Dynamic IP address"));
402 QWhatsThis::add(dynamicadd_rb, 402 QWhatsThis::add(dynamicadd_rb,
403 i18n("Select this option when your computer gets an\n" 403 i18n("Select this option when your computer gets an\n"
404 "internet address (IP) every time a\n" 404 "internet address (IP) every time a\n"
405 "connection is made.\n" 405 "connection is made.\n"
406 "\n" 406 "\n"
407 "Almost every Internet Service Provider uses\n" 407 "Almost every Internet Service Provider uses\n"
408 "this method, so this should be turned on.")); 408 "this method, so this should be turned on."));
409 409
410 staticadd_rb = new QRadioButton(box); 410 staticadd_rb = new QRadioButton(box);
411 staticadd_rb->setText(i18n("Static IP address")); 411 staticadd_rb->setText(i18n("Static IP address"));
412 rb->insert(dynamicadd_rb, 0); 412 rb->insert(dynamicadd_rb, 0);
413 rb->insert(staticadd_rb, 1); 413 rb->insert(staticadd_rb, 1);
414 QWhatsThis::add(staticadd_rb, 414 QWhatsThis::add(staticadd_rb,
415 i18n("Select this option when your computer has a\n" 415 i18n("Select this option when your computer has a\n"
416 "fixed internet address (IP). Most computers\n" 416 "fixed internet address (IP). Most computers\n"
417 "don't have this, so you should probably select\n" 417 "don't have this, so you should probably select\n"
418 "dynamic IP addressing unless you know what you\n" 418 "dynamic IP addressing unless you know what you\n"
419 "are doing.")); 419 "are doing."));
420 420
421 QWidget *ipWidget = new QWidget(box); 421 QWidget *ipWidget = new QWidget(box);
422 QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); 422 QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
423 ipLayout->setSpacing( 2 );//KDialog::spacingHint()); 423 ipLayout->setSpacing( 2 );//KDialog::spacingHint());
424 424
425 ipaddress_label = new QLabel(i18n("IP address:"), ipWidget); 425 ipaddress_label = new QLabel(i18n("IP address:"), ipWidget);
426 QString tmp = i18n("If your computer has a permanent internet\n" 426 QString tmp = i18n("If your computer has a permanent internet\n"
427 "address, you must supply your IP address here."); 427 "address, you must supply your IP address here.");
428 ipLayout->addWidget(ipaddress_label, 0, 0); 428 ipLayout->addWidget(ipaddress_label, 0, 0);
429 429
430 ipaddress_l = new IPLineEdit(ipWidget); 430 ipaddress_l = new IPLineEdit(ipWidget);
431 ipLayout->addWidget(ipaddress_l, 0, 1); 431 ipLayout->addWidget(ipaddress_l, 0, 1);
432 432
433 QWhatsThis::add(ipaddress_label,tmp); 433 QWhatsThis::add(ipaddress_label,tmp);
434 QWhatsThis::add(ipaddress_l,tmp); 434 QWhatsThis::add(ipaddress_l,tmp);
435 435
436 sub_label = new QLabel(i18n("Subnet mask:"), ipWidget); 436 sub_label = new QLabel(i18n("Subnet mask:"), ipWidget);
437 tmp = i18n("<p>If your computer has a static Internet address,\n" 437 tmp = i18n("<p>If your computer has a static Internet address,\n"
438 "you must supply a network mask here. In almost\n" 438 "you must supply a network mask here. In almost\n"
439 "all cases this netmask will be <b>255.255.255.0</b>,\n" 439 "all cases this netmask will be <b>255.255.255.0</b>,\n"
440 "but your mileage may vary.\n" 440 "but your mileage may vary.\n"
441 "\n" 441 "\n"
442 "If unsure, contact your Internet Service Provider"); 442 "If unsure, contact your Internet Service Provider");
443 ipLayout->addWidget(sub_label, 1, 0); 443 ipLayout->addWidget(sub_label, 1, 0);
444 444
445 subnetmask_l = new IPLineEdit(ipWidget); 445 subnetmask_l = new IPLineEdit(ipWidget);
446 ipLayout->addWidget(subnetmask_l, 1, 1); 446 ipLayout->addWidget(subnetmask_l, 1, 1);
447 447
448 QWhatsThis::add(sub_label,tmp); 448 QWhatsThis::add(sub_label,tmp);
449 QWhatsThis::add(subnetmask_l,tmp); 449 QWhatsThis::add(subnetmask_l,tmp);
450 450
451 autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), parent); 451 autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this);
452 autoname->setChecked(gpppdata.autoname()); 452 autoname->setChecked(PPPData::data()->autoname());
453 connect(autoname,SIGNAL(toggled(bool)), 453 connect(autoname,SIGNAL(toggled(bool)),
454 this,SLOT(autoname_t(bool))); 454 this,SLOT(autoname_t(bool)));
455 455
456 QWhatsThis::add(autoname, 456 QWhatsThis::add(autoname,
457 i18n("<p>Whenever you connect, this reconfigures\n" 457 i18n("<p>Whenever you connect, this reconfigures\n"
458 "your hostname to match the IP address you\n" 458 "your hostname to match the IP address you\n"
459 "got from the PPP server. This may be useful\n" 459 "got from the PPP server. This may be useful\n"
460 "if you need to use a protocol which depends\n" 460 "if you need to use a protocol which depends\n"
461 "on this information, but it can also cause several\n" 461 "on this information, but it can also cause several\n"
462 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" 462 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
463 "\n" 463 "\n"
464 "Don't enable this unless you really need it.")); 464 "Don't enable this unless you really need it."));
465 465
466 topLayout->addWidget(box); 466 topLayout->addWidget(box);
467 topLayout->addWidget(autoname); 467 topLayout->addWidget(autoname);
468 topLayout->addStretch(); 468 topLayout->addStretch();
469 469
470 //load info from gpppdata 470 //load info from gpppdata
471 if(!isnewaccount) { 471 if(!isnewaccount) {
472 if(gpppdata.ipaddr() == "0.0.0.0" && 472 if(PPPData::data()->ipaddr() == "0.0.0.0" &&
473 gpppdata.subnetmask() == "0.0.0.0") { 473 PPPData::data()->subnetmask() == "0.0.0.0") {
474 dynamicadd_rb->setChecked(true); 474 dynamicadd_rb->setChecked(true);
475 hitIPSelect(0); 475 hitIPSelect(0);
476 autoname->setChecked(gpppdata.autoname()); 476 autoname->setChecked(PPPData::data()->autoname());
477 } 477 }
478 else { 478 else {
479 ipaddress_l->setText(gpppdata.ipaddr()); 479 ipaddress_l->setText(PPPData::data()->ipaddr());
480 subnetmask_l->setText(gpppdata.subnetmask()); 480 subnetmask_l->setText(PPPData::data()->subnetmask());
481 staticadd_rb->setChecked(true); 481 staticadd_rb->setChecked(true);
482 autoname->setChecked(false); 482 autoname->setChecked(false);
483 } 483 }
484 } 484 }
485 else { 485 else {
486 dynamicadd_rb->setChecked(true); 486 dynamicadd_rb->setChecked(true);
487 hitIPSelect(0); 487 hitIPSelect(0);
488 } 488 }
489 489
490} 490}
491 491
492void IPWidget::autoname_t(bool on) { 492void IPWidget::autoname_t(bool on) {
493 static bool was_warned = false; 493 static bool was_warned = false;
494 494
495 // big-fat warning when selecting the auto configure hostname option 495 // big-fat warning when selecting the auto configure hostname option
496 if(on && !was_warned) { 496 if(on && !was_warned) {
497 QMessageBox::information(this, 497 QMessageBox::information(this,
498 i18n("Selecting this option might cause some weird " 498 i18n("Selecting this option might cause some weird "
499 "problems with the X-server and applications " 499 "problems with the X-server and applications "
500 "while kppp is connected. Don't use it until " 500 "while kppp is connected. Don't use it until "
501 "you know what you are doing!\n" 501 "you know what you are doing!\n"
502 "For more information take a look at the " 502 "For more information take a look at the "
503 "handbook (or help) in the section \"Frequently " 503 "handbook (or help) in the section \"Frequently "
504 "asked questions\"."), 504 "asked questions\"."),
505 i18n("Warning")); 505 i18n("Warning"));
506 was_warned = true; 506 was_warned = true;
507 } 507 }
508} 508}
509 509
510 510
511void IPWidget::save() { 511void IPWidget::save() {
512 if(dynamicadd_rb->isChecked()) { 512 if(dynamicadd_rb->isChecked()) {
513 gpppdata.setIpaddr("0.0.0.0"); 513 PPPData::data()->setIpaddr("0.0.0.0");
514 gpppdata.setSubnetmask("0.0.0.0"); 514 PPPData::data()->setSubnetmask("0.0.0.0");
515 } else { 515 } else {
516 gpppdata.setIpaddr(ipaddress_l->text()); 516 PPPData::data()->setIpaddr(ipaddress_l->text());
517 gpppdata.setSubnetmask(subnetmask_l->text()); 517 PPPData::data()->setSubnetmask(subnetmask_l->text());
518 } 518 }
519 gpppdata.setAutoname(autoname->isChecked()); 519 PPPData::data()->setAutoname(autoname->isChecked());
520} 520}
521 521
522 522
523void IPWidget::hitIPSelect( int i ) { 523void IPWidget::hitIPSelect( int i ) {
524 if(i == 0) { 524 if(i == 0) {
525 ipaddress_label->setEnabled(false); 525 ipaddress_label->setEnabled(false);
526 sub_label->setEnabled(false); 526 sub_label->setEnabled(false);
527 ipaddress_l->setEnabled(false); 527 ipaddress_l->setEnabled(false);
528 subnetmask_l->setEnabled(false); 528 subnetmask_l->setEnabled(false);
529 } 529 }
530 else { 530 else {
531 ipaddress_label->setEnabled(true); 531 ipaddress_label->setEnabled(true);
532 sub_label->setEnabled(true); 532 sub_label->setEnabled(true);
533 ipaddress_l->setEnabled(true); 533 ipaddress_l->setEnabled(true);
534 subnetmask_l->setEnabled(true); 534 subnetmask_l->setEnabled(true);
535 } 535 }
536} 536}
537 537
538 538
539 539
540DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) 540DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name )
541 : QWidget(parent, name) 541 : QWidget(parent, name)
542{ 542{
543 // box = new QGroupBox(parent); 543 // box = new QGroupBox(this);
544 QGridLayout *tl = new QGridLayout(parent, 7, 2, 0 );//, KDialog::spacingHint()); 544 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
545 545
546 dnsdomain_label = new QLabel(i18n("Domain name:"), parent); 546 dnsdomain_label = new QLabel(i18n("Domain name:"), this);
547 tl->addWidget(dnsdomain_label, 0, 0); 547 tl->addWidget(dnsdomain_label, 0, 0);
548 548
549 dnsdomain = new QLineEdit(parent); 549 dnsdomain = new QLineEdit(this);
550 dnsdomain->setMaxLength(DOMAIN_SIZE); 550// dnsdomain->setMaxLength(DOMAIN_SIZE);
551 tl->addWidget(dnsdomain, 0, 1); 551 tl->addWidget(dnsdomain, 0, 1);
552 QString tmp = i18n("If you enter a domain name here, this domain\n" 552 QString tmp = i18n("If you enter a domain name here, this domain\n"
553 "name is used for your computer while you are\n" 553 "name is used for your computer while you are\n"
554 "connected. When the connection is closed, the\n" 554 "connected. When the connection is closed, the\n"
555 "original domain name of your computer is\n" 555 "original domain name of your computer is\n"
556 "restored.\n" 556 "restored.\n"
557 "\n" 557 "\n"
558 "If you leave this field blank, no changes are\n" 558 "If you leave this field blank, no changes are\n"
559 "made to the domain name."); 559 "made to the domain name.");
560 560
561 QWhatsThis::add(dnsdomain_label,tmp); 561 QWhatsThis::add(dnsdomain_label,tmp);
562 QWhatsThis::add(dnsdomain,tmp); 562 QWhatsThis::add(dnsdomain,tmp);
563 563
564 conf_label = new QLabel(i18n("Configuration:"), parent); 564 conf_label = new QLabel(i18n("Configuration:"), this);
565 tl->addWidget(conf_label, 1, 0); 565 tl->addWidget(conf_label, 1, 0);
566 566
567 bg = new QButtonGroup("Group", this); 567 bg = new QButtonGroup("Group", this);
568 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); 568 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
569 bg->hide(); 569 bg->hide();
570 570
571 autodns = new QRadioButton(i18n("Automatic"), parent); 571 autodns = new QRadioButton(i18n("Automatic"), this);
572 bg->insert(autodns, 0); 572 bg->insert(autodns, 0);
573 tl->addWidget(autodns, 1, 1); 573 tl->addWidget(autodns, 1, 1);
574 // no automatic DNS detection for pppd < 2.3.7 574 // no automatic DNS detection for pppd < 2.3.7
575 if(!gpppdata.pppdVersionMin(2, 3, 7)) 575 if(!PPPData::data()->pppdVersionMin(2, 3, 7))
576 autodns->setEnabled(false); 576 autodns->setEnabled(false);
577 577
578 mandns = new QRadioButton(i18n("Manual"), parent); 578 mandns = new QRadioButton(i18n("Manual"), this);
579 bg->insert(mandns, 1); 579 bg->insert(mandns, 1);
580 tl->addWidget(mandns, 2, 1); 580 tl->addWidget(mandns, 2, 1);
581 581
582 dns_label = new QLabel(i18n("DNS IP address:"), parent); 582 dns_label = new QLabel(i18n("DNS IP address:"), this);
583 tl->addWidget(dns_label, 3, 0); 583 tl->addWidget(dns_label, 3, 0);
584 584
585 QHBoxLayout *l2 = new QHBoxLayout; 585 QHBoxLayout *l2 = new QHBoxLayout;
586 tl->addLayout(l2, 3, 1); 586 tl->addLayout(l2, 3, 1);
587 dnsipaddr = new IPLineEdit(parent); 587 dnsipaddr = new IPLineEdit(this);
588 connect(dnsipaddr, SIGNAL(returnPressed()), 588 connect(dnsipaddr, SIGNAL(returnPressed()),
589 SLOT(adddns())); 589 SLOT(adddns()));
590 connect(dnsipaddr, SIGNAL(textChanged(const QString &)), 590 connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
591 SLOT(DNS_Edit_Changed(const QString &))); 591 SLOT(DNS_Edit_Changed(const QString &)));
592 l2->addWidget(dnsipaddr, 1); 592 l2->addWidget(dnsipaddr, 1);
593 l2->addStretch(1); 593 l2->addStretch(1);
594 tmp = i18n("<p>Allows you to specify a new DNS server to be\n" 594 tmp = i18n("<p>Allows you to specify a new DNS server to be\n"
595 "used while you are connected. When the\n" 595 "used while you are connected. When the\n"
596 "connection is closed, this DNS entry will be\n" 596 "connection is closed, this DNS entry will be\n"
597 "removed again.\n" 597 "removed again.\n"
598 "\n" 598 "\n"
599 "To add a DNS server, type in the IP address of\n" 599 "To add a DNS server, type in the IP address of\n"
600 "the DNS server here and click on <b>Add</b>"); 600 "the DNS server here and click on <b>Add</b>");
601 601
602 QWhatsThis::add(dns_label, tmp); 602 QWhatsThis::add(dns_label, tmp);
603 QWhatsThis::add(dnsipaddr, tmp); 603 QWhatsThis::add(dnsipaddr, tmp);
604 604
605 QHBoxLayout *l1 = new QHBoxLayout; 605 QHBoxLayout *l1 = new QHBoxLayout;
606 tl->addLayout(l1, 4, 1); 606 tl->addLayout(l1, 4, 1);
607 add = new QPushButton(i18n("Add"), parent); 607 add = new QPushButton(i18n("Add"), this);
608 connect(add, SIGNAL(clicked()), SLOT(adddns())); 608 connect(add, SIGNAL(clicked()), SLOT(adddns()));
609 int width = add->sizeHint().width(); 609// int width = add->sizeHint().width();
610 width = QMAX(width,60); 610// width = QMAX(width,60);
611 add->setMinimumWidth(width); 611// add->setMinimumWidth(width);
612 l1->addWidget(add); 612 l1->addWidget(add);
613 l1->addStretch(1); 613 l1->addStretch(1);
614 QWhatsThis::add(add, 614 QWhatsThis::add(add,
615 i18n("Click this button to add the DNS server\n" 615 i18n("Click this button to add the DNS server\n"
616 "specified in the field above. The entry\n" 616 "specified in the field above. The entry\n"
617 "will then be added to the list below")); 617 "will then be added to the list below"));
618 618
619 remove = new QPushButton(i18n("Remove"), parent); 619 remove = new QPushButton(i18n("Remove"), this);
620 connect(remove, SIGNAL(clicked()), SLOT(removedns())); 620 connect(remove, SIGNAL(clicked()), SLOT(removedns()));
621 width = remove->sizeHint().width(); 621// width = remove->sizeHint().width();
622 width = QMAX(width,60); 622// width = QMAX(width,60);
623 remove->setMinimumWidth(width); 623// remove->setMinimumWidth(width);
624 l1->addWidget(remove); 624 l1->addWidget(remove);
625 QWhatsThis::add(remove, 625 QWhatsThis::add(remove,
626 i18n("Click this button to remove the selected DNS\n" 626 i18n("Click this button to remove the selected DNS\n"
627 "server entry from the list below")); 627 "server entry from the list below"));
628 628
629 servers_label = new QLabel(i18n("DNS address list:"), parent); 629 servers_label = new QLabel(i18n("DNS address list:"), this);
630 servers_label->setAlignment(AlignTop|AlignLeft); 630 servers_label->setAlignment(AlignTop|AlignLeft);
631 tl->addWidget(servers_label, 5, 0); 631 tl->addWidget(servers_label, 5, 0);
632 632
633 dnsservers = new QListBox(parent); 633 dnsservers = new QListBox(this);
634 dnsservers->setMinimumSize(150, 80); 634 dnsservers->setMinimumSize(150, 80);
635 connect(dnsservers, SIGNAL(highlighted(int)), 635 connect(dnsservers, SIGNAL(highlighted(int)),
636 SLOT(DNS_Entry_Selected(int))); 636 SLOT(DNS_Entry_Selected(int)));
637 tl->addWidget(dnsservers, 5, 1); 637 tl->addWidget(dnsservers, 5, 1);
638 tmp = i18n("<p>This shows all defined DNS servers to use\n" 638 tmp = i18n("<p>This shows all defined DNS servers to use\n"
639 "while you are connected. Use the <b>Add</b> and\n" 639 "while you are connected. Use the <b>Add</b> and\n"
640 "<b>Remove</b> buttons to modify the list"); 640 "<b>Remove</b> buttons to modify the list");
641 641
642 QWhatsThis::add(servers_label,tmp); 642 QWhatsThis::add(servers_label,tmp);
643 QWhatsThis::add(dnsservers,tmp); 643 QWhatsThis::add(dnsservers,tmp);
644 644
645 exdnsdisabled_toggle = new QCheckBox(i18n( \ 645 exdnsdisabled_toggle = new QCheckBox(i18n( \
646"Disable existing DNS servers during connection"), 646"Disable existing DNS servers during connection"),
647 parent); 647 this);
648 exdnsdisabled_toggle->setChecked(gpppdata.exDNSDisabled()); 648 exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled());
649 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); 649 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
650 QWhatsThis::add(exdnsdisabled_toggle, 650 QWhatsThis::add(exdnsdisabled_toggle,
651 i18n("<p>When this option is selected, all DNS\n" 651 i18n("<p>When this option is selected, all DNS\n"
652 "servers specified in <tt>/etc/resolv.conf</tt> are\n" 652 "servers specified in <tt>/etc/resolv.conf</tt> are\n"
653 "temporary disabled while the dialup connection\n" 653 "temporary disabled while the dialup connection\n"
654 "is established. After the connection is\n" 654 "is established. After the connection is\n"
655 "closed, the servers will be re-enabled\n" 655 "closed, the servers will be re-enabled\n"
656 "\n" 656 "\n"
657 "Typically, there is no reason to use this\n" 657 "Typically, there is no reason to use this\n"
658 "option, but it may become useful under \n" 658 "option, but it may become useful under \n"
659 "some circumstances.")); 659 "some circumstances."));
660 660
661 661
662 // restore data if editing 662 // restore data if editing
663 if(!isnewaccount) { 663 if(!isnewaccount) {
664 dnsservers->insertStringList(gpppdata.dns()); 664 dnsservers->insertStringList(PPPData::data()->dns());
665 dnsdomain->setText(gpppdata.domain()); 665 dnsdomain->setText(PPPData::data()->domain());
666 } 666 }
667 667
668 int mode = gpppdata.autoDNS() ? 0 : 1; 668 int mode = PPPData::data()->autoDNS() ? 0 : 1;
669 bg->setButton(mode); 669 bg->setButton(mode);
670 DNS_Mode_Selected(mode); 670 DNS_Mode_Selected(mode);
671 671
672 tl->activate(); 672 tl->activate();
673} 673}
674 674
675void DNSWidget::DNS_Edit_Changed(const QString &text) { 675void DNSWidget::DNS_Edit_Changed(const QString &text) {
676 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); 676 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
677 add->setEnabled(text.find(r) != -1); 677 add->setEnabled(text.find(r) != -1);
678} 678}
679 679
680void DNSWidget::DNS_Entry_Selected(int) { 680void DNSWidget::DNS_Entry_Selected(int) {
681 remove->setEnabled(true); 681 remove->setEnabled(true);
682} 682}
683 683
684void DNSWidget::DNS_Mode_Selected(int mode) { 684void DNSWidget::DNS_Mode_Selected(int mode) {
685 bool on = (mode == 1); 685 bool on = (mode == 1);
686 dns_label->setEnabled(on); 686 dns_label->setEnabled(on);
687 servers_label->setEnabled(on); 687 servers_label->setEnabled(on);
688 dnsipaddr->setText(""); 688 dnsipaddr->setText("");
689 dnsipaddr->setEnabled(on); 689 dnsipaddr->setEnabled(on);
690 add->setEnabled(false); 690 add->setEnabled(false);
691 remove->setEnabled(dnsservers->count()>0 && on); 691 remove->setEnabled(dnsservers->count()>0 && on);
692 dnsservers->clearSelection(); 692 dnsservers->clearSelection();
693 dnsservers->setEnabled(on); 693 dnsservers->setEnabled(on);
694 dnsservers->triggerUpdate(false); 694 dnsservers->triggerUpdate(false);
695} 695}
696 696
697void DNSWidget::save() { 697void DNSWidget::save() {
698 gpppdata.setAutoDNS(bg->id(bg->selected()) == 0); 698 PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0);
699 QStringList serverlist; 699 QStringList serverlist;
700 for(uint i=0; i < dnsservers->count(); i++) 700 for(uint i=0; i < dnsservers->count(); i++)
701 serverlist.append(dnsservers->text(i)); 701 serverlist.append(dnsservers->text(i));
702 gpppdata.setDns(serverlist); 702 PPPData::data()->setDns(serverlist);
703 703
704 // strip leading dot 704 // strip leading dot
705 QString s(dnsdomain->text()); 705 QString s(dnsdomain->text());
706 if(s.left(1) == ".") 706 if(s.left(1) == ".")
707 gpppdata.setDomain(s.mid(1)); 707 PPPData::data()->setDomain(s.mid(1));
708 else 708 else
709 gpppdata.setDomain(dnsdomain->text()); 709 PPPData::data()->setDomain(dnsdomain->text());
710 710
711 gpppdata.setExDNSDisabled(exdnsdisabled_toggle->isChecked()); 711 PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
712} 712}
713 713
714 714
715void DNSWidget::adddns() { 715void DNSWidget::adddns() {
716 if(dnsservers->count() < MAX_DNS_ENTRIES) { 716 if(dnsservers->count() < MAX_DNS_ENTRIES) {
717 dnsservers->insertItem(dnsipaddr->text()); 717 dnsservers->insertItem(dnsipaddr->text());
718 dnsipaddr->setText(""); 718 dnsipaddr->setText("");
719 } 719 }
720} 720}
721 721
722 722
723void DNSWidget::removedns() { 723void DNSWidget::removedns() {
724 int i; 724 int i;
725 i = dnsservers->currentItem(); 725 i = dnsservers->currentItem();
726 if(i != -1) 726 if(i != -1)
727 dnsservers->removeItem(i); 727 dnsservers->removeItem(i);
728 remove->setEnabled(dnsservers->count()>0); 728 remove->setEnabled(dnsservers->count()>0);
729} 729}
730 730
731 731
732// 732//
733// GatewayWidget 733// GatewayWidget
734// 734//
735GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) 735GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name )
736 : QWidget(parent, name) 736 : QWidget(parent, name)
737{ 737{
738 QVBoxLayout *topLayout = new QVBoxLayout(parent); 738 QVBoxLayout *topLayout = new QVBoxLayout(this);
739 topLayout->setSpacing( 2 );//KDialog::spacingHint()); 739 topLayout->setSpacing( 2 );//KDialog::spacingHint());
740 740
741 box = new QVGroupBox(i18n("Configuration"), parent); 741 box = new QVGroupBox(i18n("Configuration"), this);
742// box->setInsideSpacing( 2 );//KDialog::spacingHint()); 742// box->setInsideSpacing( 2 );//KDialog::spacingHint());
743 743
744 rb = new QButtonGroup(parent); 744 rb = new QButtonGroup(this);
745 rb->hide(); 745 rb->hide();
746 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); 746 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
747 747
748 defaultgateway = new QRadioButton(box); 748 defaultgateway = new QRadioButton(box);
749 defaultgateway->setText(i18n("Default gateway")); 749 defaultgateway->setText(i18n("Default gateway"));
750 rb->insert(defaultgateway, 0); 750 rb->insert(defaultgateway, 0);
751 QWhatsThis::add(defaultgateway, 751 QWhatsThis::add(defaultgateway,
752 i18n("This makes the PPP peer computer (the computer\n" 752 i18n("This makes the PPP peer computer (the computer\n"
753 "you are connected to with your modem) to act as\n" 753 "you are connected to with your modem) to act as\n"
754 "a gateway. Your computer will send all packets not\n" 754 "a gateway. Your computer will send all packets not\n"
755 "going to a computer inside your local net to this\n" 755 "going to a computer inside your local net to this\n"
756 "computer, which will route these packets.\n" 756 "computer, which will route these packets.\n"
757 "\n" 757 "\n"
758 "This is the default for most ISPs, so you should\n" 758 "This is the default for most ISPs, so you should\n"
759 "probably leave this option on.")); 759 "probably leave this option on."));
760 760
761 761
762 staticgateway = new QRadioButton(box); 762 staticgateway = new QRadioButton(box);
763 staticgateway->setText(i18n("Static gateway")); 763 staticgateway->setText(i18n("Static gateway"));
764 rb->insert(staticgateway, 1); 764 rb->insert(staticgateway, 1);
765 QWhatsThis::add(staticgateway, 765 QWhatsThis::add(staticgateway,
766 i18n("<p>Allows you to specify which computer you want\n" 766 i18n("<p>Allows you to specify which computer you want\n"
767 "to use as gateway (see <i>Default Gateway</i> above)")); 767 "to use as gateway (see <i>Default Gateway</i> above)"));
768 768
769 QHBox *gateBox = new QHBox(box); 769 QHBox *gateBox = new QHBox(box);
770 gate_label = new QLabel(i18n("Gateway IP address:"), gateBox); 770 gate_label = new QLabel(i18n("Gateway IP address:"), gateBox);
771 gatewayaddr = new IPLineEdit(gateBox); 771 gatewayaddr = new IPLineEdit(gateBox);
772 772
773 defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"), 773 defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"),
774 parent); 774 this);
775 QWhatsThis::add(defaultroute, 775 QWhatsThis::add(defaultroute,
776 i18n("If this option is enabled, all packets not\n" 776 i18n("If this option is enabled, all packets not\n"
777 "going to the local net are routed through\n" 777 "going to the local net are routed through\n"
778 "the PPP connection.\n" 778 "the PPP connection.\n"
779 "\n" 779 "\n"
780 "Normally, you should turn this on")); 780 "Normally, you should turn this on"));
781 781
782 topLayout->addWidget(box); 782 topLayout->addWidget(box);
783 topLayout->addWidget(defaultroute); 783 topLayout->addWidget(defaultroute);
784 topLayout->addStretch(); 784 topLayout->addStretch();
785 785
786 //load info from gpppdata 786 //load info from gpppdata
787 if(!isnewaccount) { 787 if(!isnewaccount) {
788 if(gpppdata.gateway() == "0.0.0.0") { 788 if(PPPData::data()->gateway() == "0.0.0.0") {
789 defaultgateway->setChecked(true); 789 defaultgateway->setChecked(true);
790 hitGatewaySelect(0); 790 hitGatewaySelect(0);
791 } 791 }
792 else { 792 else {
793 gatewayaddr->setText(gpppdata.gateway()); 793 gatewayaddr->setText(PPPData::data()->gateway());
794 staticgateway->setChecked(true); 794 staticgateway->setChecked(true);
795 } 795 }
796 defaultroute->setChecked(gpppdata.defaultroute()); 796 defaultroute->setChecked(PPPData::data()->defaultroute());
797 } 797 }
798 else { 798 else {
799 defaultgateway->setChecked(true); 799 defaultgateway->setChecked(true);
800 hitGatewaySelect(0); 800 hitGatewaySelect(0);
801 defaultroute->setChecked(true); 801 defaultroute->setChecked(true);
802 } 802 }
803} 803}
804 804
805void GatewayWidget::save() { 805void GatewayWidget::save() {
806 gpppdata.setGateway(gatewayaddr->text()); 806 PPPData::data()->setGateway(gatewayaddr->text());
807 gpppdata.setDefaultroute(defaultroute->isChecked()); 807 PPPData::data()->setDefaultroute(defaultroute->isChecked());
808} 808}
809 809
810 810
811void GatewayWidget::hitGatewaySelect( int i ) { 811void GatewayWidget::hitGatewaySelect( int i ) {
812 if(i == 0) { 812 if(i == 0) {
813 gatewayaddr->setText("0.0.0.0"); 813 gatewayaddr->setText("0.0.0.0");
814 gatewayaddr->setEnabled(false); 814 gatewayaddr->setEnabled(false);
815 gate_label->setEnabled(false); 815 gate_label->setEnabled(false);
816 } 816 }
817 else { 817 else {
818 gatewayaddr->setEnabled(true); 818 gatewayaddr->setEnabled(true);
819 gatewayaddr->setText(""); 819 gatewayaddr->setText("");
820 gate_label->setEnabled(true); 820 gate_label->setEnabled(true);
821 } 821 }
822} 822}
823 823
824 824
825 825
826ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) 826ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name )
827 : QWidget(parent, name) 827 : QWidget(parent, name)
828{ 828{
829 QVBoxLayout *tl = new QVBoxLayout(parent, 0 );//, KDialog::spacingHint()); 829 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
830 se = new ScriptEdit(parent); 830 se = new ScriptEdit(this);
831 connect(se, SIGNAL(returnPressed()), SLOT(addButton())); 831 connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
832 tl->addWidget(se); 832 tl->addWidget(se);
833 833
834 // insert equal-sized buttons 834 // insert equal-sized buttons
835 QButtonGroup *bbox = new QButtonGroup(parent); 835 QButtonGroup *bbox = new QButtonGroup(this);
836 add = new QPushButton( bbox, i18n("Add") ); 836 add = new QPushButton( bbox, i18n("Add") );
837 bbox->insert(add); 837 bbox->insert(add);
838 connect(add, SIGNAL(clicked()), SLOT(addButton())); 838 connect(add, SIGNAL(clicked()), SLOT(addButton()));
839// bbox->addStretch(1); 839// bbox->addStretch(1);
840 insert = new QPushButton( bbox, i18n("Insert") ); 840 insert = new QPushButton( bbox, i18n("Insert") );
841 bbox->insert(insert); 841 bbox->insert(insert);
842 connect(insert, SIGNAL(clicked()), SLOT(insertButton())); 842 connect(insert, SIGNAL(clicked()), SLOT(insertButton()));
843// bbox->addStretch(1); 843// bbox->addStretch(1);
844 remove = new QPushButton( bbox, i18n("Remove") ); 844 remove = new QPushButton( bbox, i18n("Remove") );
845 bbox->insert(remove); 845 bbox->insert(remove);
846 connect(remove, SIGNAL(clicked()), SLOT(removeButton())); 846 connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
847 bbox->layout(); 847 bbox->layout();
848 tl->addWidget(bbox); 848 tl->addWidget(bbox);
849 849
850 QHBoxLayout *l12 = new QHBoxLayout(0); 850 QHBoxLayout *l12 = new QHBoxLayout(0);
851 tl->addLayout(l12); 851 tl->addLayout(l12);
852 stl = new QListBox(parent); 852 stl = new QListBox(this);
853 stl->setVScrollBarMode( QScrollView::AlwaysOff ); 853 stl->setVScrollBarMode( QScrollView::AlwaysOff );
854 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); 854 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
855 stl->setMinimumSize(QSize(70, 140)); 855 stl->setMinimumSize(QSize(70, 140));
856 856
857 sl = new QListBox(parent); 857 sl = new QListBox(this);
858 sl->setVScrollBarMode( QScrollView::AlwaysOff ); 858 sl->setVScrollBarMode( QScrollView::AlwaysOff );
859 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); 859 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
860 sl->setMinimumSize(QSize(150, 140)); 860 sl->setMinimumSize(QSize(150, 140));
861 861
862 slb = new QScrollBar(parent); 862 slb = new QScrollBar(this);
863 slb->setFixedWidth(slb->sizeHint().width()); 863// slb->setFixedWidth(slb->sizeHint().width());
864 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); 864 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
865 865
866 l12->addWidget(stl, 1); 866 l12->addWidget(stl, 1);
867 l12->addWidget(sl, 3); 867 l12->addWidget(sl, 3);
868 l12->addWidget(slb, 0); 868 l12->addWidget(slb, 0);
869 869
870 //load data from gpppdata 870 //load data from gpppdata
871 if(!isnewaccount) { 871 if(!isnewaccount) {
872 QStringList &comlist = gpppdata.scriptType(); 872 QStringList &comlist = PPPData::data()->scriptType();
873 QStringList &arglist = gpppdata.script(); 873 QStringList &arglist = PPPData::data()->script();
874 QStringList::Iterator itcom = comlist.begin(); 874 QStringList::Iterator itcom = comlist.begin();
875 QStringList::Iterator itarg = arglist.begin(); 875 QStringList::Iterator itarg = arglist.begin();
876 876
877 for ( ; 877 for ( ;
878 itcom != comlist.end() && itarg != arglist.end(); 878 itcom != comlist.end() && itarg != arglist.end();
879 ++itcom, ++itarg ) 879 ++itcom, ++itarg )
880 { 880 {
881 stl->insertItem(*itcom); 881 stl->insertItem(*itcom);
882 sl->insertItem(*itarg); 882 sl->insertItem(*itarg);
883 } 883 }
884 } 884 }
885 885
886 insert->setEnabled(false); 886 insert->setEnabled(false);
887 remove->setEnabled(false); 887 remove->setEnabled(false);
888 adjustScrollBar(); 888 adjustScrollBar();
889 tl->activate(); 889 tl->activate();
890} 890}
891 891
892bool ScriptWidget::check() { 892bool ScriptWidget::check() {
893 uint lstart = 0; 893 uint lstart = 0;
894 uint lend = 0; 894 uint lend = 0;
895 uint errcnt = 0; 895 uint errcnt = 0;
896 896
897 if(sl->count() > 0) { 897 if(sl->count() > 0) {
898 for( uint i=0; i <= sl->count()-1; i++) { 898 for( uint i=0; i <= sl->count()-1; i++) {
899 if(stl->text(i) == "LoopStart") { 899 if(stl->text(i) == "LoopStart") {
900 lstart++; 900 lstart++;
901 } 901 }
902 if (stl->text(i) == "LoopEnd") { 902 if (stl->text(i) == "LoopEnd") {
903 lend++; 903 lend++;
904 } 904 }
905 if ( lend > lstart ) errcnt++; 905 if ( lend > lstart ) errcnt++;
906 } 906 }
907 return ( (errcnt == 0 ) && (lstart == lend) ); 907 return ( (errcnt == 0 ) && (lstart == lend) );
908 } 908 }
909 return true; 909 return true;
910} 910}
911 911
912 912
913void ScriptWidget::save() { 913void ScriptWidget::save() {
914 QStringList typelist, arglist; 914 QStringList typelist, arglist;
915 for(uint i=0; i < sl->count(); i++) { 915 for(uint i=0; i < sl->count(); i++) {
916 typelist.append(stl->text(i)); 916 typelist.append(stl->text(i));
917 arglist.append(sl->text(i)); 917 arglist.append(sl->text(i));
918 } 918 }
919 gpppdata.setScriptType(typelist); 919 PPPData::data()->setScriptType(typelist);
920 gpppdata.setScript(arglist); 920 PPPData::data()->setScript(arglist);
921} 921}
922 922
923 923
924 924
925void ScriptWidget::adjustScrollBar() { 925void ScriptWidget::adjustScrollBar() {
926 if((int)sl->count() <= sl->numItemsVisible()) 926 if((int)sl->count() <= sl->numItemsVisible())
927 slb->setRange(0, 0); 927 slb->setRange(0, 0);
928 else 928 else
929 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); 929 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
930} 930}
931 931
932 932
933void ScriptWidget::scrolling(int i) { 933void ScriptWidget::scrolling(int i) {
934 sl->setTopItem(i); 934 sl->setTopItem(i);
935 stl->setTopItem(i); 935 stl->setTopItem(i);
936} 936}
937 937
938 938
939void ScriptWidget::slhighlighted(int i) { 939void ScriptWidget::slhighlighted(int i) {
940 insert->setEnabled(true); 940 insert->setEnabled(true);
941 remove->setEnabled(true); 941 remove->setEnabled(true);
942 stl->setCurrentItem(i); 942 stl->setCurrentItem(i);
943} 943}
944 944
945 945
946void ScriptWidget::stlhighlighted(int i) { 946void ScriptWidget::stlhighlighted(int i) {
947 insert->setEnabled(true); 947 insert->setEnabled(true);
948 remove->setEnabled(true); 948 remove->setEnabled(true);
949 sl->setCurrentItem(i); 949 sl->setCurrentItem(i);
950} 950}
951 951
952 952
953void ScriptWidget::addButton() { 953void ScriptWidget::addButton() {
954 //don't allow more than the maximum script entries 954 //don't allow more than the maximum script entries
955 if(sl->count() == MAX_SCRIPT_ENTRIES-1) 955 if(sl->count() == MAX_SCRIPT_ENTRIES-1)
956 return; 956 return;
957 957
958 switch(se->type()) { 958 switch(se->type()) {
959 case ScriptEdit::Expect: 959 case ScriptEdit::Expect:
960 stl->insertItem("Expect"); 960 stl->insertItem("Expect");
961 sl->insertItem(se->text()); 961 sl->insertItem(se->text());
962 break; 962 break;
963 963
964 case ScriptEdit::Send: 964 case ScriptEdit::Send:
965 stl->insertItem("Send"); 965 stl->insertItem("Send");
966 sl->insertItem(se->text()); 966 sl->insertItem(se->text());
967 break; 967 break;
968 968
969 case ScriptEdit::SendNoEcho: 969 case ScriptEdit::SendNoEcho:
970 stl->insertItem("SendNoEcho"); 970 stl->insertItem("SendNoEcho");
971 sl->insertItem(se->text()); 971 sl->insertItem(se->text());
972 break; 972 break;
973 973
974 case ScriptEdit::Pause: 974 case ScriptEdit::Pause:
975 stl->insertItem("Pause"); 975 stl->insertItem("Pause");
976 sl->insertItem(se->text()); 976 sl->insertItem(se->text());
977 break; 977 break;
978 978
979 case ScriptEdit::Hangup: 979 case ScriptEdit::Hangup:
980 stl->insertItem("Hangup"); 980 stl->insertItem("Hangup");
981 sl->insertItem(""); 981 sl->insertItem("");
982 break; 982 break;
983 983
984 case ScriptEdit::Answer: 984 case ScriptEdit::Answer:
985 stl->insertItem("Answer"); 985 stl->insertItem("Answer");
986 sl->insertItem(""); 986 sl->insertItem("");
987 break; 987 break;
988 988
989 case ScriptEdit::Timeout: 989 case ScriptEdit::Timeout:
990 stl->insertItem("Timeout"); 990 stl->insertItem("Timeout");
991 sl->insertItem(se->text()); 991 sl->insertItem(se->text());
992 break; 992 break;
993 993
994 case ScriptEdit::Password: 994 case ScriptEdit::Password:
995 stl->insertItem("Password"); 995 stl->insertItem("Password");
996 sl->insertItem(se->text()); 996 sl->insertItem(se->text());
997 break; 997 break;
998 998
999 case ScriptEdit::ID: 999 case ScriptEdit::ID:
1000 stl->insertItem("ID"); 1000 stl->insertItem("ID");
1001 sl->insertItem(se->text()); 1001 sl->insertItem(se->text());
1002 break; 1002 break;
1003 1003
1004 case ScriptEdit::Prompt: 1004 case ScriptEdit::Prompt:
1005 stl->insertItem("Prompt"); 1005 stl->insertItem("Prompt");
1006 sl->insertItem(se->text()); 1006 sl->insertItem(se->text());
1007 break; 1007 break;
1008 1008
1009 case ScriptEdit::PWPrompt: 1009 case ScriptEdit::PWPrompt:
1010 stl->insertItem("PWPrompt"); 1010 stl->insertItem("PWPrompt");
1011 sl->insertItem(se->text()); 1011 sl->insertItem(se->text());
1012 break; 1012 break;
1013 1013
1014 case ScriptEdit::LoopStart: 1014 case ScriptEdit::LoopStart:
1015 stl->insertItem("LoopStart"); 1015 stl->insertItem("LoopStart");
1016 sl->insertItem(se->text()); 1016 sl->insertItem(se->text());
@@ -1061,133 +1061,133 @@ void ScriptWidget::insertButton() {
1061 stl->insertItem("Send", stl->currentItem()); 1061 stl->insertItem("Send", stl->currentItem());
1062 sl->insertItem(se->text(), sl->currentItem()); 1062 sl->insertItem(se->text(), sl->currentItem());
1063 break; 1063 break;
1064 1064
1065 case ScriptEdit::SendNoEcho: 1065 case ScriptEdit::SendNoEcho:
1066 stl->insertItem("SendNoEcho", stl->currentItem()); 1066 stl->insertItem("SendNoEcho", stl->currentItem());
1067 sl->insertItem(se->text(), sl->currentItem()); 1067 sl->insertItem(se->text(), sl->currentItem());
1068 break; 1068 break;
1069 1069
1070 case ScriptEdit::Pause: 1070 case ScriptEdit::Pause:
1071 stl->insertItem("Pause", stl->currentItem()); 1071 stl->insertItem("Pause", stl->currentItem());
1072 sl->insertItem(se->text(), sl->currentItem()); 1072 sl->insertItem(se->text(), sl->currentItem());
1073 break; 1073 break;
1074 1074
1075 case ScriptEdit::Hangup: 1075 case ScriptEdit::Hangup:
1076 stl->insertItem("Hangup", stl->currentItem()); 1076 stl->insertItem("Hangup", stl->currentItem());
1077 sl->insertItem("", sl->currentItem()); 1077 sl->insertItem("", sl->currentItem());
1078 break; 1078 break;
1079 1079
1080 case ScriptEdit::Answer: 1080 case ScriptEdit::Answer:
1081 stl->insertItem("Answer", stl->currentItem()); 1081 stl->insertItem("Answer", stl->currentItem());
1082 sl->insertItem("", sl->currentItem()); 1082 sl->insertItem("", sl->currentItem());
1083 break; 1083 break;
1084 1084
1085 case ScriptEdit::Timeout: 1085 case ScriptEdit::Timeout:
1086 stl->insertItem("Timeout", stl->currentItem()); 1086 stl->insertItem("Timeout", stl->currentItem());
1087 sl->insertItem(se->text(), sl->currentItem()); 1087 sl->insertItem(se->text(), sl->currentItem());
1088 break; 1088 break;
1089 1089
1090 case ScriptEdit::Password: 1090 case ScriptEdit::Password:
1091 stl->insertItem("Password", stl->currentItem()); 1091 stl->insertItem("Password", stl->currentItem());
1092 sl->insertItem(se->text(), sl->currentItem()); 1092 sl->insertItem(se->text(), sl->currentItem());
1093 break; 1093 break;
1094 1094
1095 case ScriptEdit::ID: 1095 case ScriptEdit::ID:
1096 stl->insertItem("ID", stl->currentItem()); 1096 stl->insertItem("ID", stl->currentItem());
1097 sl->insertItem(se->text(), sl->currentItem()); 1097 sl->insertItem(se->text(), sl->currentItem());
1098 break; 1098 break;
1099 1099
1100 case ScriptEdit::Prompt: 1100 case ScriptEdit::Prompt:
1101 stl->insertItem("Prompt", stl->currentItem()); 1101 stl->insertItem("Prompt", stl->currentItem());
1102 sl->insertItem(se->text(), sl->currentItem()); 1102 sl->insertItem(se->text(), sl->currentItem());
1103 break; 1103 break;
1104 1104
1105 case ScriptEdit::PWPrompt: 1105 case ScriptEdit::PWPrompt:
1106 stl->insertItem("PWPrompt", stl->currentItem()); 1106 stl->insertItem("PWPrompt", stl->currentItem());
1107 sl->insertItem(se->text(), sl->currentItem()); 1107 sl->insertItem(se->text(), sl->currentItem());
1108 break; 1108 break;
1109 1109
1110 case ScriptEdit::LoopStart: 1110 case ScriptEdit::LoopStart:
1111 stl->insertItem("LoopStart", stl->currentItem()); 1111 stl->insertItem("LoopStart", stl->currentItem());
1112 sl->insertItem(se->text(), sl->currentItem()); 1112 sl->insertItem(se->text(), sl->currentItem());
1113 break; 1113 break;
1114 1114
1115 case ScriptEdit::LoopEnd: 1115 case ScriptEdit::LoopEnd:
1116 stl->insertItem("LoopEnd", stl->currentItem()); 1116 stl->insertItem("LoopEnd", stl->currentItem());
1117 sl->insertItem(se->text(), sl->currentItem()); 1117 sl->insertItem(se->text(), sl->currentItem());
1118 break; 1118 break;
1119 1119
1120 case ScriptEdit::Scan: 1120 case ScriptEdit::Scan:
1121 stl->insertItem("Scan", stl->currentItem()); 1121 stl->insertItem("Scan", stl->currentItem());
1122 sl->insertItem(se->text(), sl->currentItem()); 1122 sl->insertItem(se->text(), sl->currentItem());
1123 break; 1123 break;
1124 1124
1125 case ScriptEdit::Save: 1125 case ScriptEdit::Save:
1126 stl->insertItem("Save", stl->currentItem()); 1126 stl->insertItem("Save", stl->currentItem());
1127 sl->insertItem(se->text(), sl->currentItem()); 1127 sl->insertItem(se->text(), sl->currentItem());
1128 break; 1128 break;
1129 1129
1130 default: 1130 default:
1131 break; 1131 break;
1132 } 1132 }
1133 adjustScrollBar(); 1133 adjustScrollBar();
1134 se->setText(""); 1134 se->setText("");
1135} 1135}
1136 1136
1137 1137
1138void ScriptWidget::removeButton() { 1138void ScriptWidget::removeButton() {
1139 if(sl->currentItem() >= 0) { 1139 if(sl->currentItem() >= 0) {
1140 int stlc = stl->currentItem(); 1140 int stlc = stl->currentItem();
1141 sl->removeItem(sl->currentItem()); 1141 sl->removeItem(sl->currentItem());
1142 stl->removeItem(stlc); 1142 stl->removeItem(stlc);
1143 adjustScrollBar(); 1143 adjustScrollBar();
1144 insert->setEnabled(sl->currentItem() != -1); 1144 insert->setEnabled(sl->currentItem() != -1);
1145 remove->setEnabled(sl->currentItem() != -1); 1145 remove->setEnabled(sl->currentItem() != -1);
1146 } 1146 }
1147} 1147}
1148 1148
1149 1149
1150 1150
1151///////////////////////////////////////////////////////////////////////////// 1151/////////////////////////////////////////////////////////////////////////////
1152// 1152//
1153// Used to specify a new phone number 1153// Used to specify a new phone number
1154// 1154//
1155///////////////////////////////////////////////////////////////////////////// 1155/////////////////////////////////////////////////////////////////////////////
1156PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) 1156PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
1157 : QDialog(parent, 0, true ) { 1157 : QDialog(parent,"PhoneNumberDialog",true) {
1158 setCaption( i18n("Add Phone Number") ); 1158 setCaption( i18n("Add Phone Number") );
1159// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 1159// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
1160 1160
1161 QHBox *hbox = new QHBox(this); 1161 QHBox *hbox = new QHBox(this);
1162// setMainWidget(hbox); 1162// setMainWidget(hbox);
1163 1163
1164 hbox->setSpacing( 2 );//KDialog::spacingHint()); 1164 hbox->setSpacing( 2 );//KDialog::spacingHint());
1165 1165
1166 new QLabel(i18n("Enter a phone number:"), hbox); 1166 new QLabel(i18n("Enter a phone number:"), hbox);
1167 1167
1168 le = newLineEdit(14, hbox); 1168 le = new QLineEdit(hbox);
1169 le->setMinimumWidth(125); 1169// le->setMinimumWidth(125);
1170 1170
1171 connect(le, SIGNAL(textChanged(const QString &)), 1171 connect(le, SIGNAL(textChanged(const QString &)),
1172 this, SLOT(textChanged(const QString &))); 1172 this, SLOT(textChanged(const QString &)));
1173 1173
1174 le->setFocus(); 1174 le->setFocus();
1175 textChanged(""); 1175 textChanged("");
1176 1176
1177// enableButtonSeparator(true); 1177// enableButtonSeparator(true);
1178} 1178}
1179 1179
1180 1180
1181QString PhoneNumberDialog::phoneNumber() { 1181QString PhoneNumberDialog::phoneNumber() {
1182 QString s = le->text(); 1182 QString s = le->text();
1183 1183
1184 return s; 1184 return s;
1185} 1185}
1186 1186
1187 1187
1188void PhoneNumberDialog::textChanged(const QString &s) { 1188void PhoneNumberDialog::textChanged(const QString &s) {
1189// enableButtonOK(s.length() > 0); 1189// enableButtonOK(s.length() > 0);
1190} 1190}
1191 1191
1192 1192
1193//#include "edit.moc" 1193//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index f803628..a02ee35 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -71,351 +71,351 @@ ModemWidget::ModemWidget( QWidget *parent, const char *name)
71 "should select one of the /dev/ttyIx devices."); 71 "should select one of the /dev/ttyIx devices.");
72 72
73 QWhatsThis::add(label1,tmp); 73 QWhatsThis::add(label1,tmp);
74 QWhatsThis::add(modemdevice,tmp); 74 QWhatsThis::add(modemdevice,tmp);
75 75
76 76
77 label2 = new QLabel(i18n("&Flow control:"), this); 77 label2 = new QLabel(i18n("&Flow control:"), this);
78 tl->addWidget(label2, 1, 0); 78 tl->addWidget(label2, 1, 0);
79 79
80 flowcontrol = new QComboBox(false, this); 80 flowcontrol = new QComboBox(false, this);
81 label2->setBuddy(flowcontrol); 81 label2->setBuddy(flowcontrol);
82 flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); 82 flowcontrol->insertItem(i18n("Hardware [CRTSCTS]"));
83 flowcontrol->insertItem(i18n("Software [XON/XOFF]")); 83 flowcontrol->insertItem(i18n("Software [XON/XOFF]"));
84 flowcontrol->insertItem(i18n("None")); 84 flowcontrol->insertItem(i18n("None"));
85 tl->addWidget(flowcontrol, 1, 1); 85 tl->addWidget(flowcontrol, 1, 1);
86 connect(flowcontrol, SIGNAL(activated(int)), 86 connect(flowcontrol, SIGNAL(activated(int)),
87 SLOT(setflowcontrol(int))); 87 SLOT(setflowcontrol(int)));
88 88
89 tmp = i18n("<p>Specifies how the serial port and modem\n" 89 tmp = i18n("<p>Specifies how the serial port and modem\n"
90 "communicate. You should not change this unless\n" 90 "communicate. You should not change this unless\n"
91 "you know what you are doing.\n" 91 "you know what you are doing.\n"
92 "\n" 92 "\n"
93 "<b>Default</b>: CRTSCTS"); 93 "<b>Default</b>: CRTSCTS");
94 94
95 QWhatsThis::add(label2,tmp); 95 QWhatsThis::add(label2,tmp);
96 QWhatsThis::add(flowcontrol,tmp); 96 QWhatsThis::add(flowcontrol,tmp);
97 97
98 labelenter = new QLabel(i18n("&Line termination:"), this); 98 labelenter = new QLabel(i18n("&Line termination:"), this);
99 tl->addWidget(labelenter, 2, 0); 99 tl->addWidget(labelenter, 2, 0);
100 100
101 enter = new QComboBox(false, this); 101 enter = new QComboBox(false, this);
102 labelenter->setBuddy(enter); 102 labelenter->setBuddy(enter);
103 enter->insertItem("CR"); 103 enter->insertItem("CR");
104 enter->insertItem("LF"); 104 enter->insertItem("LF");
105 enter->insertItem("CR/LF"); 105 enter->insertItem("CR/LF");
106 tl->addWidget(enter, 2, 1); 106 tl->addWidget(enter, 2, 1);
107 connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); 107 connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
108 tmp = i18n("<p>Specifies how AT commands are sent to your\n" 108 tmp = i18n("<p>Specifies how AT commands are sent to your\n"
109 "modem. Most modems will work fine with the\n" 109 "modem. Most modems will work fine with the\n"
110 "default <i>CR/LF</i>. If your modem does not react\n" 110 "default <i>CR/LF</i>. If your modem does not react\n"
111 "to the init string, you should try different\n" 111 "to the init string, you should try different\n"
112 "settings here\n" 112 "settings here\n"
113 "\n" 113 "\n"
114 "<b>Default</b>: CR/LF"); 114 "<b>Default</b>: CR/LF");
115 115
116 QWhatsThis::add(labelenter,tmp); 116 QWhatsThis::add(labelenter,tmp);
117 QWhatsThis::add(enter, tmp); 117 QWhatsThis::add(enter, tmp);
118 118
119 baud_label = new QLabel(i18n("Co&nnection speed:"), this); 119 baud_label = new QLabel(i18n("Co&nnection speed:"), this);
120 tl->addWidget(baud_label, 3, 0); 120 tl->addWidget(baud_label, 3, 0);
121 baud_c = new QComboBox(this); 121 baud_c = new QComboBox(this);
122 baud_label->setBuddy(baud_c); 122 baud_label->setBuddy(baud_c);
123 123
124 static const char *baudrates[] = { 124 static const char *baudrates[] = {
125 125
126#ifdef B460800 126#ifdef B460800
127 "460800", 127 "460800",
128#endif 128#endif
129 129
130#ifdef B230400 130#ifdef B230400
131 "230400", 131 "230400",
132#endif 132#endif
133 133
134#ifdef B115200 134#ifdef B115200
135 "115200", 135 "115200",
136#endif 136#endif
137 137
138#ifdef B57600 138#ifdef B57600
139 "57600", 139 "57600",
140#endif 140#endif
141 141
142 "38400", 142 "38400",
143 "19200", 143 "19200",
144 "9600", 144 "9600",
145 "2400", 145 "2400",
146 0}; 146 0};
147 147
148 for(k = 0; baudrates[k]; k++) 148 for(k = 0; baudrates[k]; k++)
149 baud_c->insertItem(baudrates[k]); 149 baud_c->insertItem(baudrates[k]);
150 150
151 baud_c->setCurrentItem(3); 151 baud_c->setCurrentItem(3);
152 connect(baud_c, SIGNAL(activated(int)), 152 connect(baud_c, SIGNAL(activated(int)),
153 this, SLOT(speed_selection(int))); 153 this, SLOT(speed_selection(int)));
154 tl->addWidget(baud_c, 3, 1); 154 tl->addWidget(baud_c, 3, 1);
155 155
156 tmp = i18n("Specifies the speed your modem and the serial\n" 156 tmp = i18n("Specifies the speed your modem and the serial\n"
157 "port talk to each other. You should begin with\n" 157 "port talk to each other. You should begin with\n"
158 "the default of 38400 bits/sec. If everything\n" 158 "the default of 38400 bits/sec. If everything\n"
159 "works you can try to increase this value, but to\n" 159 "works you can try to increase this value, but to\n"
160 "no more than 115200 bits/sec (unless you know\n" 160 "no more than 115200 bits/sec (unless you know\n"
161 "that your serial port supports higher speeds)."); 161 "that your serial port supports higher speeds).");
162 162
163 QWhatsThis::add(baud_label,tmp); 163 QWhatsThis::add(baud_label,tmp);
164 QWhatsThis::add(baud_c,tmp); 164 QWhatsThis::add(baud_c,tmp);
165 165
166 for(int i=0; i <= enter->count()-1; i++) { 166 for(int i=0; i <= enter->count()-1; i++) {
167 if(gpppdata.enter() == enter->text(i)) 167 if(PPPData::data()->enter() == enter->text(i))
168 enter->setCurrentItem(i); 168 enter->setCurrentItem(i);
169 } 169 }
170 170
171 tl->addRowSpacing(4, 10); 171 tl->addRowSpacing(4, 10);
172 172
173 //Modem Lock File 173 //Modem Lock File
174 modemlockfile = new QCheckBox(i18n("&Use lock file"), this); 174 modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
175 175
176 modemlockfile->setChecked(gpppdata.modemLockFile()); 176 modemlockfile->setChecked(PPPData::data()->modemLockFile());
177 connect(modemlockfile, SIGNAL(toggled(bool)), 177 connect(modemlockfile, SIGNAL(toggled(bool)),
178 SLOT(modemlockfilechanged(bool))); 178 SLOT(modemlockfilechanged(bool)));
179 tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); 179 tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
180 // l12->addStretch(1); 180 // l12->addStretch(1);
181 QWhatsThis::add(modemlockfile, 181 QWhatsThis::add(modemlockfile,
182 i18n("<p>To prevent other programs from accessing the\n" 182 i18n("<p>To prevent other programs from accessing the\n"
183 "modem while a connection is established, a\n" 183 "modem while a connection is established, a\n"
184 "file can be created to indicate that the modem\n" 184 "file can be created to indicate that the modem\n"
185 "is in use. On Linux an example file would be\n" 185 "is in use. On Linux an example file would be\n"
186 "<tt>/var/lock/LCK..ttyS1</tt>\n" 186 "<tt>/var/lock/LCK..ttyS1</tt>\n"
187 "Here you can select whether this locking will\n" 187 "Here you can select whether this locking will\n"
188 "be done.\n" 188 "be done.\n"
189 "\n" 189 "\n"
190 "<b>Default</b>: On")); 190 "<b>Default</b>: On"));
191 191
192 // Modem Timeout Line Edit Box 192 // Modem Timeout Line Edit Box
193 193
194 modemtimeout = new KIntNumInput(gpppdata.modemTimeout(), this); 194 modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this);
195 modemtimeout->setLabel(i18n("Modem &timeout:")); 195 modemtimeout->setLabel(i18n("Modem &timeout:"));
196 modemtimeout->setRange(1, 120, 1); 196 modemtimeout->setRange(1, 120, 1);
197 modemtimeout->setSuffix(i18n(" sec")); 197 modemtimeout->setSuffix(i18n(" sec"));
198 connect(modemtimeout, SIGNAL(valueChanged(int)), 198 connect(modemtimeout, SIGNAL(valueChanged(int)),
199 SLOT(modemtimeoutchanged(int))); 199 SLOT(modemtimeoutchanged(int)));
200 tl->addMultiCellWidget(modemtimeout, 6, 6, 0, 1); 200 tl->addMultiCellWidget(modemtimeout, 6, 6, 0, 1);
201 201
202 QWhatsThis::add(modemtimeout, 202 QWhatsThis::add(modemtimeout,
203 i18n("This specifies how long <i>kppp</i> waits for a\n" 203 i18n("This specifies how long <i>kppp</i> waits for a\n"
204 "<i>CONNECT</i> response from your modem. The\n" 204 "<i>CONNECT</i> response from your modem. The\n"
205 "recommended value is 30 seconds.")); 205 "recommended value is 30 seconds."));
206 206
207 //set stuff from gpppdata 207 //set stuff from gpppdata
208 for(int i=0; i <= enter->count()-1; i++) { 208 for(int i=0; i <= enter->count()-1; i++) {
209 if(gpppdata.enter() == enter->text(i)) 209 if(PPPData::data()->enter() == enter->text(i))
210 enter->setCurrentItem(i); 210 enter->setCurrentItem(i);
211 } 211 }
212 212
213 for(int i=0; i <= modemdevice->count()-1; i++) { 213 for(int i=0; i <= modemdevice->count()-1; i++) {
214 if(gpppdata.modemDevice() == modemdevice->text(i)) 214 if(PPPData::data()->modemDevice() == modemdevice->text(i))
215 modemdevice->setCurrentItem(i); 215 modemdevice->setCurrentItem(i);
216 } 216 }
217 217
218 for(int i=0; i <= flowcontrol->count()-1; i++) { 218 for(int i=0; i <= flowcontrol->count()-1; i++) {
219 if(gpppdata.flowcontrol() == flowcontrol->text(i)) 219 if(PPPData::data()->flowcontrol() == flowcontrol->text(i))
220 flowcontrol->setCurrentItem(i); 220 flowcontrol->setCurrentItem(i);
221 } 221 }
222 222
223 //set the modem speed 223 //set the modem speed
224 for(int i=0; i < baud_c->count(); i++) 224 for(int i=0; i < baud_c->count(); i++)
225 if(baud_c->text(i) == gpppdata.speed()) 225 if(baud_c->text(i) == PPPData::data()->speed())
226 baud_c->setCurrentItem(i); 226 baud_c->setCurrentItem(i);
227 227
228 tl->setRowStretch(7, 1); 228 tl->setRowStretch(7, 1);
229} 229}
230 230
231 231
232void ModemWidget::speed_selection(int) { 232void ModemWidget::speed_selection(int) {
233 gpppdata.setSpeed(baud_c->text(baud_c->currentItem())); 233 PPPData::data()->setSpeed(baud_c->text(baud_c->currentItem()));
234} 234}
235 235
236 236
237void ModemWidget::setenter(int ) { 237void ModemWidget::setenter(int ) {
238 gpppdata.setEnter(enter->text(enter->currentItem())); 238 PPPData::data()->setEnter(enter->text(enter->currentItem()));
239} 239}
240 240
241 241
242void ModemWidget::setmodemdc(int i) { 242void ModemWidget::setmodemdc(int i) {
243 gpppdata.setModemDevice(modemdevice->text(i)); 243 PPPData::data()->setModemDevice(modemdevice->text(i));
244} 244}
245 245
246 246
247void ModemWidget::setflowcontrol(int i) { 247void ModemWidget::setflowcontrol(int i) {
248 gpppdata.setFlowcontrol(flowcontrol->text(i)); 248 PPPData::data()->setFlowcontrol(flowcontrol->text(i));
249} 249}
250 250
251 251
252void ModemWidget::modemlockfilechanged(bool set) { 252void ModemWidget::modemlockfilechanged(bool set) {
253 gpppdata.setModemLockFile(set); 253 PPPData::data()->setModemLockFile(set);
254} 254}
255 255
256 256
257void ModemWidget::modemtimeoutchanged(int n) { 257void ModemWidget::modemtimeoutchanged(int n) {
258 gpppdata.setModemTimeout(n); 258 PPPData::data()->setModemTimeout(n);
259} 259}
260 260
261 261
262ModemWidget2::ModemWidget2( QWidget *parent, const char *name) 262ModemWidget2::ModemWidget2( QWidget *parent, const char *name)
263 : QWidget(parent, name) 263 : QWidget(parent, name)
264{ 264{
265 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 265 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
266 266
267 267
268 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); 268 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
269 waitfordt->setChecked(gpppdata.waitForDialTone()); 269 waitfordt->setChecked(PPPData::data()->waitForDialTone());
270 connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); 270 connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
271 l1->addWidget(waitfordt); 271 l1->addWidget(waitfordt);
272 QWhatsThis::add(waitfordt, 272 QWhatsThis::add(waitfordt,
273 i18n("<p>Normally the modem waits for a dial tone\n" 273 i18n("<p>Normally the modem waits for a dial tone\n"
274 "from your phone line, indicating that it can\n" 274 "from your phone line, indicating that it can\n"
275 "start to dial a number. If your modem does not\n" 275 "start to dial a number. If your modem does not\n"
276 "recognize this sound, or your local phone system\n" 276 "recognize this sound, or your local phone system\n"
277 "does not emit such a tone, uncheck this option\n" 277 "does not emit such a tone, uncheck this option\n"
278 "\n" 278 "\n"
279 "<b>Default:</b>: On")); 279 "<b>Default:</b>: On"));
280 280
281 busywait = new KIntNumInput(gpppdata.busyWait(), this); 281 busywait = new KIntNumInput(PPPData::data()->busyWait(), this);
282 busywait->setLabel(i18n("B&usy wait:")); 282 busywait->setLabel(i18n("B&usy wait:"));
283 busywait->setRange(0, 300, 5, true); 283 busywait->setRange(0, 300, 5, true);
284 busywait->setSuffix(i18n(" sec")); 284 busywait->setSuffix(i18n(" sec"));
285 connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); 285 connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
286 l1->addWidget(busywait); 286 l1->addWidget(busywait);
287 287
288 QWhatsThis::add(busywait, 288 QWhatsThis::add(busywait,
289 i18n("Specifies the number of seconds to wait before\n" 289 i18n("Specifies the number of seconds to wait before\n"
290 "redial if all dialed numbers are busy. This is\n" 290 "redial if all dialed numbers are busy. This is\n"
291 "necessary because some modems get stuck if the\n" 291 "necessary because some modems get stuck if the\n"
292 "same number is busy too often.\n" 292 "same number is busy too often.\n"
293 "\n" 293 "\n"
294 "The default is 0 seconds, you should not change\n" 294 "The default is 0 seconds, you should not change\n"
295 "this unless you need to.")); 295 "this unless you need to."));
296 296
297 l1->addSpacing(10); 297 l1->addSpacing(10);
298 298
299 QHBoxLayout *hbl = new QHBoxLayout; 299 QHBoxLayout *hbl = new QHBoxLayout;
300 hbl->setSpacing(2);//KDialog::spacingHint()); 300 hbl->setSpacing(2);//KDialog::spacingHint());
301 301
302 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); 302 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
303 hbl->addWidget(volumeLabel); 303 hbl->addWidget(volumeLabel);
304 volume = new QSlider(0, 2, 1, gpppdata.volume(), QSlider::Horizontal, this); 304 volume = new QSlider(0, 2, 1, PPPData::data()->volume(), QSlider::Horizontal, this);
305 volumeLabel->setBuddy(volume); 305 volumeLabel->setBuddy(volume);
306 volume->setTickmarks(QSlider::Below); 306 volume->setTickmarks(QSlider::Below);
307 hbl->addWidget(volume); 307 hbl->addWidget(volume);
308 308
309 l1->addLayout(hbl); 309 l1->addLayout(hbl);
310 310
311 connect(volume, SIGNAL(valueChanged(int)), 311 connect(volume, SIGNAL(valueChanged(int)),
312 this, SLOT(volumeChanged(int))); 312 this, SLOT(volumeChanged(int)));
313 QString tmp = i18n("Most modems have a speaker which makes\n" 313 QString tmp = i18n("Most modems have a speaker which makes\n"
314 "a lot of noise when dialing. Here you can\n" 314 "a lot of noise when dialing. Here you can\n"
315 "either turn this completely off or select a\n" 315 "either turn this completely off or select a\n"
316 "lower volume.\n" 316 "lower volume.\n"
317 "\n" 317 "\n"
318 "If this does not work for your modem,\n" 318 "If this does not work for your modem,\n"
319 "you must modify the modem volume command."); 319 "you must modify the modem volume command.");
320 320
321 QWhatsThis::add(volumeLabel,tmp); 321 QWhatsThis::add(volumeLabel,tmp);
322 QWhatsThis::add(volume, tmp); 322 QWhatsThis::add(volume, tmp);
323 323
324 l1->addSpacing(20); 324 l1->addSpacing(20);
325 325
326#if 0 326#if 0
327 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); 327 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
328 chkbox1->setChecked(gpppdata.UseCDLine()); 328 chkbox1->setChecked(PPPData::data()->UseCDLine());
329 connect(chkbox1,SIGNAL(toggled(bool)), 329 connect(chkbox1,SIGNAL(toggled(bool)),
330 this,SLOT(use_cdline_toggled(bool))); 330 this,SLOT(use_cdline_toggled(bool)));
331 l12->addWidget(chkbox1); 331 l12->addWidget(chkbox1);
332 l12->addStretch(1); 332 l12->addStretch(1);
333 l1->addStretch(1); 333 l1->addStretch(1);
334 QWhatsThis::add(chkbox1, 334 QWhatsThis::add(chkbox1,
335 i18n("This controls how <i>kppp</i> detects that the modem\n" 335 i18n("This controls how <i>kppp</i> detects that the modem\n"
336 "is not responding. Unless you are having\n" 336 "is not responding. Unless you are having\n"
337 "problems with this, do not modify this setting.\n" 337 "problems with this, do not modify this setting.\n"
338 "\n" 338 "\n"
339 "<b>Default</b>: Off")); 339 "<b>Default</b>: Off"));
340#endif 340#endif
341 341
342 modemcmds = new QPushButton(i18n("Mod&em Commands..."), this); 342 modemcmds = new QPushButton(i18n("Mod&em Commands..."), this);
343 QWhatsThis::add(modemcmds, 343 QWhatsThis::add(modemcmds,
344 i18n("Allows you to change the AT command for\n" 344 i18n("Allows you to change the AT command for\n"
345 "your modem.")); 345 "your modem."));
346 346
347 modeminfo_button = new QPushButton(i18n("&Query Modem..."), this); 347 modeminfo_button = new QPushButton(i18n("&Query Modem..."), this);
348 QWhatsThis::add(modeminfo_button, 348 QWhatsThis::add(modeminfo_button,
349 i18n("Most modems support the ATI command set to\n" 349 i18n("Most modems support the ATI command set to\n"
350 "find out vendor and revision of your modem.\n" 350 "find out vendor and revision of your modem.\n"
351 "\n" 351 "\n"
352 "Press this button to query your modem for\n" 352 "Press this button to query your modem for\n"
353 "this information. It can be useful to help\n" 353 "this information. It can be useful to help\n"
354 "you setup the modem")); 354 "you setup the modem"));
355 355
356// terminal_button = new QPushButton(i18n("&Terminal..."), this); 356// terminal_button = new QPushButton(i18n("&Terminal..."), this);
357// QWhatsThis::add(terminal_button, 357// QWhatsThis::add(terminal_button,
358 // i18n("Opens the built-in terminal program. You\n" 358 // i18n("Opens the built-in terminal program. You\n"
359 // "can use this if you want to play around\n" 359 // "can use this if you want to play around\n"
360 // "with your modem's AT command set")); 360 // "with your modem's AT command set"));
361 361
362 QHBoxLayout *hbox = new QHBoxLayout(); 362 QHBoxLayout *hbox = new QHBoxLayout();
363 l1->addLayout(hbox); 363 l1->addLayout(hbox);
364 hbox->addStretch(1); 364 hbox->addStretch(1);
365 QVBoxLayout *vbox = new QVBoxLayout(); 365 QVBoxLayout *vbox = new QVBoxLayout();
366 hbox->addLayout(vbox); 366 hbox->addLayout(vbox);
367 367
368 vbox->addWidget(modemcmds); 368 vbox->addWidget(modemcmds);
369 vbox->addWidget(modeminfo_button); 369 vbox->addWidget(modeminfo_button);
370// vbox->addWidget(terminal_button); 370// vbox->addWidget(terminal_button);
371 371
372 hbox->addStretch(1); 372 hbox->addStretch(1);
373 l1->addStretch(1); 373 l1->addStretch(1);
374 374
375 connect(modemcmds, SIGNAL(clicked()), 375 connect(modemcmds, SIGNAL(clicked()),
376 SLOT(modemcmdsbutton())); 376 SLOT(modemcmdsbutton()));
377 connect(modeminfo_button, SIGNAL(clicked()), 377 connect(modeminfo_button, SIGNAL(clicked()),
378 SLOT(query_modem())); 378 SLOT(query_modem()));
379// connect(terminal_button, SIGNAL(clicked()), 379// connect(terminal_button, SIGNAL(clicked()),
380 // SLOT(terminal())); 380 // SLOT(terminal()));
381} 381}
382 382
383 383
384void ModemWidget2::modemcmdsbutton() { 384void ModemWidget2::modemcmdsbutton() {
385 ModemCommands mc(this); 385 ModemCommands mc(this);
386 mc.showMaximized(); 386 mc.showMaximized();
387 mc.exec(); 387 mc.exec();
388} 388}
389 389
390 390
391void ModemWidget2::query_modem() { 391void ModemWidget2::query_modem() {
392 ModemTransfer mt(this); 392 ModemTransfer mt(this);
393 mt.exec(); 393 mt.exec();
394} 394}
395 395
396 396
397// void ModemWidget2::terminal() { 397// void ModemWidget2::terminal() {
398// MiniTerm terminal(NULL,NULL); 398// MiniTerm terminal(NULL,NULL);
399// terminal.exec(); 399// terminal.exec();
400// } 400// }
401 401
402 402
403#if 0 403#if 0
404void ModemWidget2::use_cdline_toggled(bool on) { 404void ModemWidget2::use_cdline_toggled(bool on) {
405 gpppdata.setUseCDLine(on); 405 PPPData::data()->setUseCDLine(on);
406} 406}
407#endif 407#endif
408 408
409void ModemWidget2::waitfordtchanged(bool b) { 409void ModemWidget2::waitfordtchanged(bool b) {
410 gpppdata.setWaitForDialTone((int)b); 410 PPPData::data()->setWaitForDialTone((int)b);
411} 411}
412 412
413void ModemWidget2::busywaitchanged(int n) { 413void ModemWidget2::busywaitchanged(int n) {
414 gpppdata.setbusyWait(n); 414 PPPData::data()->setbusyWait(n);
415} 415}
416 416
417 417
418void ModemWidget2::volumeChanged(int v) { 418void ModemWidget2::volumeChanged(int v) {
419 gpppdata.setVolume(v); 419 PPPData::data()->setVolume(v);
420} 420}
421 421
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index 2f9feda..8d70cd4 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -65,841 +65,841 @@
65#include "auth.h" 65#include "auth.h"
66#include "modem.h" 66#include "modem.h"
67//#include "ppplog.h" 67//#include "ppplog.h"
68//#include "opener.h" 68//#include "opener.h"
69//#include "requester.h" 69//#include "requester.h"
70//#include "pppstats.h" 70//#include "pppstats.h"
71#include "pppdata.h" 71#include "pppdata.h"
72#include "general.h" 72#include "general.h"
73 73
74#define execute_command system 74#define execute_command system
75 75
76KPPPWidget *p_kppp = 0; 76KPPPWidget *p_kppp = 0;
77 77
78KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl ) 78KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl )
79 : QDialog(parent, name, modal, fl) 79 : QDialog(parent, name, modal, fl)
80// , acct(0) 80// , acct(0)
81// , m_bCmdlAccount (false) 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 86
87 int result = runTests(); 87 int result = runTests();
88 if(result == TEST_CRITICAL) 88 if(result == TEST_CRITICAL)
89 exit(4); 89 exit(4);
90 90
91// installEventFilter(this); 91// installEventFilter(this);
92 92
93// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 93// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
94 94
95// QGridLayout *l1 = new QGridLayout(3, 4); 95// QGridLayout *l1 = new QGridLayout(3, 4);
96// tl->addLayout(l1); 96// tl->addLayout(l1);
97// l1->addColSpacing(0, 10); 97// l1->addColSpacing(0, 10);
98// l1->addColSpacing(3, 10); 98// l1->addColSpacing(3, 10);
99// l1->setColStretch(1, 3); 99// l1->setColStretch(1, 3);
100// l1->setColStretch(2, 4); 100// l1->setColStretch(2, 4);
101 101
102// label1 = new QLabel(i18n("C&onnect to: "), this); 102// label1 = new QLabel(i18n("C&onnect to: "), this);
103// l1->addWidget(label1, 0, 1); 103// l1->addWidget(label1, 0, 1);
104 104
105// connectto_c = new QComboBox(false, this); 105// connectto_c = new QComboBox(false, this);
106// label1->setBuddy(connectto_c); 106// label1->setBuddy(connectto_c);
107 107
108// connect(connectto_c, SIGNAL(activated(int)), 108// connect(connectto_c, SIGNAL(activated(int)),
109 // SLOT(newdefaultaccount(int))); 109 // SLOT(newdefaultaccount(int)));
110// l1->addWidget(connectto_c, 0, 2); 110// l1->addWidget(connectto_c, 0, 2);
111 111
112// ID_Label = new QLabel(i18n("&Login ID:"), this); 112// ID_Label = new QLabel(i18n("&Login ID:"), this);
113// l1->addWidget(ID_Label, 1, 1); 113// l1->addWidget(ID_Label, 1, 1);
114 114
115// // the entry line for usernames 115// // the entry line for usernames
116// ID_Edit = new QLineEdit(this); 116// ID_Edit = new QLineEdit(this);
117// ID_Label->setBuddy(ID_Edit); 117// ID_Label->setBuddy(ID_Edit);
118// l1->addWidget(ID_Edit, 1, 2); 118// l1->addWidget(ID_Edit, 1, 2);
119// connect(ID_Edit, SIGNAL(returnPressed()), 119// connect(ID_Edit, SIGNAL(returnPressed()),
120 // this, SLOT(enterPressedInID())); 120 // this, SLOT(enterPressedInID()));
121// QString tmp = i18n("<p>Type in the username that you got from your\n" 121// QString tmp = i18n("<p>Type in the username that you got from your\n"
122 // "ISP. This is especially important for PAP\n" 122 // "ISP. This is especially important for PAP\n"
123 // "and CHAP. You may omit this when you use\n" 123 // "and CHAP. You may omit this when you use\n"
124 // "terminal-based or script-based authentication.\n" 124 // "terminal-based or script-based authentication.\n"
125 // "\n" 125 // "\n"
126 // "<b>Important</b>: case is important here:\n" 126 // "<b>Important</b>: case is important here:\n"
127 // "<i>myusername</i> is not the same as <i>MyUserName</i>!"); 127 // "<i>myusername</i> is not the same as <i>MyUserName</i>!");
128 128
129// QWhatsThis::add(ID_Label,tmp); 129// QWhatsThis::add(ID_Label,tmp);
130// QWhatsThis::add(ID_Edit,tmp); 130// QWhatsThis::add(ID_Edit,tmp);
131 131
132// PW_Label = new QLabel(i18n("&Password:"), this); 132// PW_Label = new QLabel(i18n("&Password:"), this);
133// l1->addWidget(PW_Label, 2, 1); 133// l1->addWidget(PW_Label, 2, 1);
134 134
135// PW_Edit= new QLineEdit(this); 135// PW_Edit= new QLineEdit(this);
136// PW_Label->setBuddy(PW_Edit); 136// PW_Label->setBuddy(PW_Edit);
137// PW_Edit->setEchoMode(QLineEdit::Password); 137// PW_Edit->setEchoMode(QLineEdit::Password);
138// l1->addWidget(PW_Edit, 2, 2); 138// l1->addWidget(PW_Edit, 2, 2);
139// connect(PW_Edit, SIGNAL(returnPressed()), 139// connect(PW_Edit, SIGNAL(returnPressed()),
140 // this, SLOT(enterPressedInPW())); 140 // this, SLOT(enterPressedInPW()));
141 141
142// tmp = i18n("<p>Type in the password that you got from your\n" 142// tmp = i18n("<p>Type in the password that you got from your\n"
143 // "ISP. This is especially important for PAP\n" 143 // "ISP. This is especially important for PAP\n"
144 // "and CHAP. You may omit this when you use\n" 144 // "and CHAP. You may omit this when you use\n"
145 // "terminal-based or script-based authentication.\n" 145 // "terminal-based or script-based authentication.\n"
146 // "\n" 146 // "\n"
147 // "<b>Important</b>: case is important here:\n" 147 // "<b>Important</b>: case is important here:\n"
148 // "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); 148 // "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
149 149
150// QWhatsThis::add(PW_Label,tmp); 150// QWhatsThis::add(PW_Label,tmp);
151// QWhatsThis::add(PW_Edit,tmp); 151// QWhatsThis::add(PW_Edit,tmp);
152 152
153// QHBoxLayout *l3 = new QHBoxLayout; 153// QHBoxLayout *l3 = new QHBoxLayout;
154// tl->addSpacing(5); 154// tl->addSpacing(5);
155// tl->addLayout(l3); 155// tl->addLayout(l3);
156// tl->addSpacing(5); 156// tl->addSpacing(5);
157// l3->addSpacing(10); 157// l3->addSpacing(10);
158// log = new QCheckBox(i18n("Show lo&g window"), this); 158// log = new QCheckBox(i18n("Show lo&g window"), this);
159// connect(log, SIGNAL(toggled(bool)), 159// connect(log, SIGNAL(toggled(bool)),
160 // this, SLOT(log_window_toggled(bool))); 160 // this, SLOT(log_window_toggled(bool)));
161// log->setChecked(gpppdata.get_show_log_window()); 161// log->setChecked(PPPData::data()->get_show_log_window());
162// l3->addWidget(log); 162// l3->addWidget(log);
163 163
164// QWhatsThis::add(log, 164// QWhatsThis::add(log,
165 // i18n("<p>This controls whether a log window is shown.\n" 165 // i18n("<p>This controls whether a log window is shown.\n"
166 // "A log window shows the communication between\n" 166 // "A log window shows the communication between\n"
167 // "<i>kppp</i> and your modem. This will help you\n" 167 // "<i>kppp</i> and your modem. This will help you\n"
168 // "in tracking down problems.\n" 168 // "in tracking down problems.\n"
169 // "\n" 169 // "\n"
170 // "Turn it off if <i>kppp</i> routinely connects without\n" 170 // "Turn it off if <i>kppp</i> routinely connects without\n"
171 // "problems")); 171 // "problems"));
172 172
173// // fline = new QSeparator( KSeparator::HLine, this); 173// // fline = new QSeparator( KSeparator::HLine, this);
174// // tl->addWidget(fline); 174// // tl->addWidget(fline);
175 175
176// QHBoxLayout *l2 = new QHBoxLayout(this); 176// QHBoxLayout *l2 = new QHBoxLayout(this);
177// tl->addLayout(l2); 177// tl->addLayout(l2);
178 178
179// int minw = 0; 179// int minw = 0;
180// quit_b = new QPushButton(i18n("&Quit"), this); 180// quit_b = new QPushButton(i18n("&Quit"), this);
181// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); 181// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
182// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); 182// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
183// if(quit_b->sizeHint().width() > minw) 183// if(quit_b->sizeHint().width() > minw)
184// minw = quit_b->sizeHint().width(); 184// minw = quit_b->sizeHint().width();
185 185
186// setup_b = new QPushButton(i18n("&Setup..."), this); 186// setup_b = new QPushButton(i18n("&Setup..."), this);
187// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); 187// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
188// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); 188// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
189// if(setup_b->sizeHint().width() > minw) 189// if(setup_b->sizeHint().width() > minw)
190// minw = setup_b->sizeHint().width(); 190// minw = setup_b->sizeHint().width();
191 191
192 192
193 193
194// if(gpppdata.access() != KConfig::ReadWrite) 194// if(PPPData::data()->access() != KConfig::ReadWrite)
195// setup_b->setEnabled(false); 195// setup_b->setEnabled(false);
196 196
197// help_b = new QPushButton(i18n("&Help"), this); 197// help_b = new QPushButton(i18n("&Help"), this);
198// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); 198// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
199 199
200// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); 200// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
201// help_b->setPopup((QPopupMenu*)helpMenu->menu()); 201// help_b->setPopup((QPopupMenu*)helpMenu->menu());
202// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); 202// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
203 203
204// if(help_b->sizeHint().width() > minw) 204// if(help_b->sizeHint().width() > minw)
205// minw = help_b->sizeHint().width(); 205// minw = help_b->sizeHint().width();
206 206
207// connect_b = new QPushButton(i18n("&Connect"), this); 207// connect_b = new QPushButton(i18n("&Connect"), this);
208// connect_b->setDefault(true); 208// connect_b->setDefault(true);
209// connect_b->setFocus(); 209// connect_b->setFocus();
210// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); 210// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
211// if(connect_b->sizeHint().width() > minw) 211// if(connect_b->sizeHint().width() > minw)
212// minw = connect_b->sizeHint().width(); 212// minw = connect_b->sizeHint().width();
213 213
214// quit_b->setFixedWidth(minw); 214// quit_b->setFixedWidth(minw);
215// setup_b->setFixedWidth(minw); 215// setup_b->setFixedWidth(minw);
216// // help_b->setFixedWidth(help_b->sizeHint().width()); 216// // help_b->setFixedWidth(help_b->sizeHint().width());
217// connect_b->setFixedWidth(minw); 217// connect_b->setFixedWidth(minw);
218 218
219// l2->addWidget(quit_b); 219// l2->addWidget(quit_b);
220// l2->addWidget(setup_b); 220// l2->addWidget(setup_b);
221// // l2->addWidget(help_b); 221// // l2->addWidget(help_b);
222// l2->addSpacing(20); 222// l2->addSpacing(20);
223// l2->addWidget(connect_b); 223// l2->addWidget(connect_b);
224 224
225 setFixedSize(sizeHint()); 225 setFixedSize(sizeHint());
226 226
227 (void)new Modem; 227 (void)new Modem;
228 228
229 // we also connect cmld_start to the beginConnect so that I can run 229 // we also connect cmld_start to the beginConnect so that I can run
230 // the dialer through a command line argument 230 // the dialer through a command line argument
231 connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); 231 connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
232 232
233// stats = new PPPStats; 233// stats = new PPPStats;
234 234
235 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 235 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
236 236
237 // constructor of con_win reads position from config file 237 // constructor of con_win reads position from config file
238// con_win = new ConWindow(0, "conw", this); 238// con_win = new ConWindow(0, "conw", this);
239 // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); 239 // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
240 240
241// statdlg = new PPPStatsDlg(0, "stats", this, stats); 241// statdlg = new PPPStatsDlg(0, "stats", this, stats);
242// statdlg->hide(); 242// statdlg->hide();
243 243
244 debugwindow = new DebugWidget(0,"debugwindow"); 244 debugwindow = new DebugWidget(0,"debugwindow");
245 // KWin::setIcons(debugwindow->winId(), kapp->icon(), kapp->miniIcon()); 245 // KWin::setIcons(debugwindow->winId(), kapp->icon(), kapp->miniIcon());
246 debugwindow->hide(); 246 debugwindow->hide();
247 247
248 // load up the accounts combo box 248 // load up the accounts combo box
249 249
250// resetaccounts(); 250// resetaccounts();
251// con = new ConnectWidget(0, "con"); 251// con = new ConnectWidget(0, "con");
252 //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); 252 //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
253// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); 253// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
254 // Is this the best we can do here? it's not right. 254 // Is this the best we can do here? it's not right.
255// QRect desk = QApplication::desktop()->screenGeometry( 255// QRect desk = QApplication::desktop()->screenGeometry(
256// QApplication::desktop()->screenNumber(topLevelWidget())); 256// QApplication::desktop()->screenNumber(topLevelWidget()));
257// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); 257// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
258 258
259 // connect the ConnectWidgets various signals 259 // connect the ConnectWidgets various signals
260// connect(con, SIGNAL(closeDebugWindow()), 260// connect(con, SIGNAL(closeDebugWindow()),
261 // debugwindow, SLOT(hide())); 261 // debugwindow, SLOT(hide()));
262// connect(con, SIGNAL(debugMessage(const QString &)), 262// connect(con, SIGNAL(debugMessage(const QString &)),
263 // debugwindow, SLOT(statusLabel(const QString &))); 263 // debugwindow, SLOT(statusLabel(const QString &)));
264// connect(con, SIGNAL(toggleDebugWindow()), 264// connect(con, SIGNAL(toggleDebugWindow()),
265 // debugwindow, SLOT(toggleVisibility())); 265 // debugwindow, SLOT(toggleVisibility()));
266// connect(con, SIGNAL(debugPutChar(unsigned char)), 266// connect(con, SIGNAL(debugPutChar(unsigned char)),
267 // debugwindow, SLOT(addChar(unsigned char))); 267 // debugwindow, SLOT(addChar(unsigned char)));
268// // connect(con, SIGNAL(startAccounting()), 268// // connect(con, SIGNAL(startAccounting()),
269 // // this, SLOT(startAccounting())); 269 // // this, SLOT(startAccounting()));
270// // connect(con, SIGNAL(stopAccounting()), 270// // connect(con, SIGNAL(stopAccounting()),
271 // // this, SLOT(stopAccounting())); 271 // // this, SLOT(stopAccounting()));
272// connect(qApp, SIGNAL(saveYourself()), 272// connect(qApp, SIGNAL(saveYourself()),
273 // this, SLOT(saveMyself())); 273 // this, SLOT(saveMyself()));
274// connect(qApp, SIGNAL(shutDown()), 274// connect(qApp, SIGNAL(shutDown()),
275 // this, SLOT(shutDown())); 275 // this, SLOT(shutDown()));
276 276
277// debugwindow->setGeometry(desk.center().x()+190, desk.center().y()-55, 277// debugwindow->setGeometry(desk.center().x()+190, desk.center().y()-55,
278 // debugwindow->width(),debugwindow->height()); 278 // debugwindow->width(),debugwindow->height());
279 279
280// move(desk.center().x()-width()/2, desk.center().y()-height()/2); 280// move(desk.center().x()-width()/2, desk.center().y()-height()/2);
281 281
282 282
283// KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 283// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
284 284
285// m_strCmdlAccount = args->getOption("c"); 285// m_strCmdlAccount = args->getOption("c");
286// m_bQuitOnDisconnect = args->isSet("q"); 286// m_bQuitOnDisconnect = args->isSet("q");
287 287
288// if(!m_strCmdlAccount.isEmpty()) { 288// if(!m_strCmdlAccount.isEmpty()) {
289// m_bCmdlAccount = true; 289// m_bCmdlAccount = true;
290// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; 290// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
291// } 291// }
292 292
293// if(m_bCmdlAccount){ 293// if(m_bCmdlAccount){
294// bool result = gpppdata.setAccount(m_strCmdlAccount); 294// bool result = PPPData::data()->setAccount(m_strCmdlAccount);
295// if (!result){ 295// if (!result){
296// QString string; 296// QString string;
297// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); 297// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
298// KMessageBox::error(this, string); 298// KMessageBox::error(this, string);
299// m_bCmdlAccount = false; 299// m_bCmdlAccount = false;
300// this->show(); 300// this->show();
301// } else { 301// } else {
302// beginConnect(); 302// beginConnect();
303// } 303// }
304// } else 304// } else
305// expandbutton(); 305// expandbutton();
306// show(); 306// show();
307 307
308 308
309//#define KPPP_SHOW_NEWS 309//#define KPPP_SHOW_NEWS
310#ifdef KPPP_SHOW_NEWS 310#ifdef KPPP_SHOW_NEWS
311 // keep user informed about recent changes 311 // keep user informed about recent changes
312 if(!m_bCmdlAccount) 312 if(!m_bCmdlAccount)
313 showNews(); 313 showNews();
314#endif 314#endif
315} 315}
316 316
317KPPPWidget::~KPPPWidget() 317KPPPWidget::~KPPPWidget()
318{ 318{
319 p_kppp = 0; 319 p_kppp = 0;
320// delete stats; 320// delete stats;
321} 321}
322 322
323// bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { 323// bool KPPPWidget::eventFilter(QObject *o, QEvent *e) {
324// if(e->type() == QEvent::User) { 324// if(e->type() == QEvent::User) {
325// switch(((SignalEvent*)e)->sigType()) { 325// switch(((SignalEvent*)e)->sigType()) {
326// case SIGINT: 326// case SIGINT:
327// qDebug( "Received a SIGINT" ); 327// qDebug( "Received a SIGINT" );
328// interruptConnection(); 328// interruptConnection();
329// break; 329// break;
330// case SIGCHLD: 330// case SIGCHLD:
331// sigChld(); 331// sigChld();
332// break; 332// break;
333// case SIGUSR1: 333// case SIGUSR1:
334// sigPPPDDied(); 334// sigPPPDDied();
335// break; 335// break;
336// } 336// }
337// return true; 337// return true;
338// } 338// }
339 339
340// if(o == connect_b) { 340// if(o == connect_b) {
341// if(e->type() == QEvent::KeyPress) { 341// if(e->type() == QEvent::KeyPress) {
342// if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { 342// if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) {
343// beginConnect(); 343// beginConnect();
344// return true; 344// return true;
345// } 345// }
346// } 346// }
347// } 347// }
348 348
349// return false; 349// return false;
350// } 350// }
351 351
352 352
353 353
354 354
355void KPPPWidget::enterPressedInID() { 355void KPPPWidget::enterPressedInID() {
356 PW_Edit->setFocus(); 356 PW_Edit->setFocus();
357} 357}
358 358
359 359
360void KPPPWidget::enterPressedInPW() { 360void KPPPWidget::enterPressedInPW() {
361 connect_b->setFocus(); 361 connect_b->setFocus();
362} 362}
363 363
364// triggered by the session manager 364// triggered by the session manager
365void KPPPWidget::saveMyself() { 365void KPPPWidget::saveMyself() {
366 gpppdata.save(); 366 PPPData::data()->save();
367} 367}
368 368
369void KPPPWidget::shutDown() { 369void KPPPWidget::shutDown() {
370 interruptConnection(); 370 interruptConnection();
371 saveMyself(); 371 saveMyself();
372} 372}
373 373
374void KPPPWidget::log_window_toggled(bool on) { 374void KPPPWidget::log_window_toggled(bool on) {
375 gpppdata.set_show_log_window(on); 375 PPPData::data()->set_show_log_window(on);
376} 376}
377 377
378 378
379 379
380 380
381// void KPPPWidget::resetaccounts() { 381// void KPPPWidget::resetaccounts() {
382// connectto_c->clear(); 382// connectto_c->clear();
383 383
384// int count = gpppdata.count(); 384// int count = PPPData::data()->count();
385 385
386// // enable/disable controls 386// // enable/disable controls
387// connectto_c->setEnabled(count > 0); 387// connectto_c->setEnabled(count > 0);
388// connect_b->setEnabled(count > 0); 388// connect_b->setEnabled(count > 0);
389// log->setEnabled(count > 0); 389// log->setEnabled(count > 0);
390// ID_Edit->setEnabled(count > 0); 390// ID_Edit->setEnabled(count > 0);
391// PW_Edit->setEnabled(count > 0); 391// PW_Edit->setEnabled(count > 0);
392 392
393// //load the accounts 393// //load the accounts
394// for(int i=0; i < count; i++) { 394// for(int i=0; i < count; i++) {
395// gpppdata.setAccountbyIndex(i); 395// PPPData::data()->setAccountbyIndex(i);
396// connectto_c->insertItem(gpppdata.accname()); 396// connectto_c->insertItem(PPPData::data()->accname());
397// } 397// }
398 398
399// //set the default account 399// //set the default account
400// if(!gpppdata.defaultAccount().isEmpty()) { 400// if(!PPPData::data()->defaultAccount().isEmpty()) {
401// for(int i=0; i < count; i++) 401// for(int i=0; i < count; i++)
402// if(gpppdata.defaultAccount() == connectto_c->text(i)) { 402// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) {
403 // connectto_c->setCurrentItem(i); 403 // connectto_c->setCurrentItem(i);
404 // gpppdata.setAccountbyIndex(i); 404 // PPPData::data()->setAccountbyIndex(i);
405 405
406 // ID_Edit->setText(gpppdata.storedUsername()); 406 // ID_Edit->setText(PPPData::data()->storedUsername());
407 // PW_Edit->setText(gpppdata.storedPassword()); 407 // PW_Edit->setText(PPPData::data()->storedPassword());
408// } 408// }
409// } 409// }
410// else 410// else
411// if(count > 0) { 411// if(count > 0) {
412// gpppdata.setDefaultAccount(connectto_c->text(0)); 412// PPPData::data()->setDefaultAccount(connectto_c->text(0));
413// gpppdata.save(); 413// PPPData::data()->save();
414 // ID_Edit->setText(gpppdata.storedUsername()); 414 // ID_Edit->setText(PPPData::data()->storedUsername());
415 // PW_Edit->setText(gpppdata.storedPassword()); 415 // PW_Edit->setText(PPPData::data()->storedPassword());
416// } 416// }
417 417
418// connect(ID_Edit, SIGNAL(textChanged(const QString &)), 418// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
419 // this, SLOT(usernameChanged(const QString &))); 419 // this, SLOT(usernameChanged(const QString &)));
420 420
421// connect(PW_Edit, SIGNAL(textChanged(const QString &)), 421// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
422 // this, SLOT(passwordChanged(const QString &))); 422 // this, SLOT(passwordChanged(const QString &)));
423 423
424// if (ID_Edit->text().isEmpty()) 424// if (ID_Edit->text().isEmpty())
425// ID_Edit->setFocus(); 425// ID_Edit->setFocus();
426// else if (PW_Edit->text().isEmpty()) 426// else if (PW_Edit->text().isEmpty())
427// PW_Edit->setFocus(); 427// PW_Edit->setFocus();
428// } 428// }
429 429
430 430
431void KPPPWidget::interruptConnection() { 431void KPPPWidget::interruptConnection() {
432 // interrupt dial up 432 // interrupt dial up
433// if (con->isVisible()) 433// if (con->isVisible())
434// emit con->cancelbutton(); 434// emit con->cancelbutton();
435 435
436 // disconnect if online 436 // disconnect if online
437 if (gpppdata.pppdRunning()) 437 if (PPPData::data()->pppdRunning())
438 emit disconnect(); 438 emit disconnect();
439} 439}
440 440
441 441
442void KPPPWidget::sigPPPDDied() { 442void KPPPWidget::sigPPPDDied() {
443 qDebug( "Received a SIGUSR1" ); 443 qDebug( "Received a SIGUSR1" );
444 444
445 // if we are not connected pppdpid is -1 so have have to check for that 445 // if we are not connected pppdpid is -1 so have have to check for that
446 // in the followin line to make sure that we don't raise a false alarm 446 // in the followin line to make sure that we don't raise a false alarm
447 // such as would be the case when the log file viewer exits. 447 // such as would be the case when the log file viewer exits.
448 if(gpppdata.pppdRunning() || gpppdata.pppdError()) { 448 if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) {
449 qDebug( "It was pppd that died" ); 449 qDebug( "It was pppd that died" );
450 450
451 // when we killpppd() on Cancel in ConnectWidget 451 // when we killpppd() on Cancel in ConnectWidget
452 // we set pppid to -1 so we won't 452 // we set pppid to -1 so we won't
453 // enter this block 453 // enter this block
454 454
455 // just to be sure 455 // just to be sure
456 456
457 Modem::modem->removeSecret(AUTH_PAP); 457 Modem::modem->removeSecret(AUTH_PAP);
458 Modem::modem->removeSecret(AUTH_CHAP); 458 Modem::modem->removeSecret(AUTH_CHAP);
459 459
460 gpppdata.setpppdRunning(false); 460 PPPData::data()->setpppdRunning(false);
461 461
462 qDebug( "Executing command on disconnect since pppd has died." ); 462 qDebug( "Executing command on disconnect since pppd has died." );
463 QApplication::flushX(); 463 QApplication::flushX();
464 execute_command(gpppdata.command_on_disconnect()); 464 execute_command(PPPData::data()->command_on_disconnect());
465 465
466// stopAccounting(); 466// stopAccounting();
467 467
468// con_win->stopClock(); 468// con_win->stopClock();
469// DockWidget::dock_widget->stop_stats(); 469// DockWidget::dock_widget->stop_stats();
470// DockWidget::dock_widget->hide(); 470// DockWidget::dock_widget->hide();
471 471
472 if(!gpppdata.pppdError()) 472 if(!PPPData::data()->pppdError())
473 gpppdata.setpppdError(E_PPPD_DIED); 473 PPPData::data()->setpppdError(E_PPPD_DIED);
474 removedns(); 474 removedns();
475 Modem::modem->unlockdevice(); 475 Modem::modem->unlockdevice();
476 // con->pppdDied(); 476 // con->pppdDied();
477 477
478 if(!gpppdata.automatic_redial()) { 478 if(!PPPData::data()->automatic_redial()) {
479 quit_b->setFocus(); 479 quit_b->setFocus();
480 show(); 480 show();
481// con_win->stopClock(); 481// con_win->stopClock();
482 //stopAccounting(); 482 //stopAccounting();
483// con_win->hide(); 483// con_win->hide();
484// con->hide(); 484// con->hide();
485 485
486 gpppdata.setpppdRunning(false); 486 PPPData::data()->setpppdRunning(false);
487 // // not in a signal handler !!! KNotifyClient::beep(); 487 // // not in a signal handler !!! KNotifyClient::beep();
488 QString msg; 488 QString msg;
489 if (gpppdata.pppdError() == E_IF_TIMEOUT) 489 if (PPPData::data()->pppdError() == E_IF_TIMEOUT)
490 msg = i18n("Timeout expired while waiting for the PPP interface " 490 msg = i18n("Timeout expired while waiting for the PPP interface "
491 "to come up!"); 491 "to come up!");
492 else { 492 else {
493 msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); 493 msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
494 Modem::modem->pppdExitStatus(); 494 Modem::modem->pppdExitStatus();
495 if (Modem::modem->lastStatus != 99) {// more recent pppds only 495 if (Modem::modem->lastStatus != 99) {// more recent pppds only
496 msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); 496 msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
497 msg += i18n("</p><p>See 'man pppd' for an explanation of the error " 497 msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
498 "codes or take a look at the kppp FAQ on " 498 "codes or take a look at the kppp FAQ on "
499 " <a href=http://devel-home.kde.org/~kppp/index.html>" 499 " <a href=http://devel-home.kde.org/~kppp/index.html>"
500 "http://devel-home.kde.org/~kppp/index.html</a></p>"); 500 "http://devel-home.kde.org/~kppp/index.html</a></p>");
501 } 501 }
502 } 502 }
503 503
504 // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) 504 // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
505 // // PPPL_ShowLog(); 505 // // PPPL_ShowLog();
506// } else { /* reconnect on disconnect */ 506// } else { /* reconnect on disconnect */
507 if (false){ 507 if (false){
508 qDebug( "Trying to reconnect... " ); 508 qDebug( "Trying to reconnect... " );
509 509
510 if(gpppdata.authMethod() == AUTH_PAP || 510 if(PPPData::data()->authMethod() == AUTH_PAP ||
511 gpppdata.authMethod() == AUTH_CHAP || 511 PPPData::data()->authMethod() == AUTH_CHAP ||
512 gpppdata.authMethod() == AUTH_PAPCHAP) 512 PPPData::data()->authMethod() == AUTH_PAPCHAP)
513 Modem::modem->setSecret(gpppdata.authMethod(), 513 Modem::modem->setSecret(PPPData::data()->authMethod(),
514 encodeWord(gpppdata.storedUsername()), 514 encodeWord(PPPData::data()->storedUsername()),
515 encodeWord(gpppdata.password())); 515 encodeWord(PPPData::data()->password()));
516 516
517// con_win->hide(); 517// con_win->hide();
518 // con_win->stopClock(); 518 // con_win->stopClock();
519 //stopAccounting(); 519 //stopAccounting();
520 gpppdata.setpppdRunning(false); 520 PPPData::data()->setpppdRunning(false);
521 // not in a signal handler !!!KNotifyClient::beep(); 521 // not in a signal handler !!!KNotifyClient::beep();
522 emit cmdl_start(); 522 emit cmdl_start();
523 } 523 }
524 } 524 }
525 gpppdata.setpppdError(0); 525 PPPData::data()->setpppdError(0);
526 } 526 }
527} 527}
528 528
529// void KPPPWidget::sigChld() { 529// void KPPPWidget::sigChld() {
530// qDebug( "sigchld()" ); 530// qDebug( "sigchld()" );
531// // pid_t id = wait(0L); 531// // pid_t id = wait(0L);
532// // if(id == helperPid && helperPid != -1) { 532// // if(id == helperPid && helperPid != -1) {
533// // kdDebug(5002) << "It was the setuid child that died" << endl; 533// // kdDebug(5002) << "It was the setuid child that died" << endl;
534// // helperPid = -1; 534// // helperPid = -1;
535// QString msg = i18n("kppp's helper process just died.\n" 535// QString msg = i18n("kppp's helper process just died.\n"
536// "Since a further execution would be pointless, " 536// "Since a further execution would be pointless, "
537// "kppp will shut down now."); 537// "kppp will shut down now.");
538// QMessageBox::warning(0L,"error", msg); 538// QMessageBox::warning(0L,"error", msg);
539// //remove_pidfile(); 539// //remove_pidfile();
540// exit(1); 540// exit(1);
541// // } 541// // }
542// } 542// }
543 543
544 544
545void KPPPWidget::newdefaultaccount(int i) { 545void KPPPWidget::newdefaultaccount(int i) {
546 gpppdata.setDefaultAccount(connectto_c->text(i)); 546 PPPData::data()->setDefaultAccount(connectto_c->text(i));
547 gpppdata.save(); 547 PPPData::data()->save();
548 ID_Edit->setText(gpppdata.storedUsername()); 548 ID_Edit->setText(PPPData::data()->storedUsername());
549 PW_Edit->setText(gpppdata.storedPassword()); 549 PW_Edit->setText(PPPData::data()->storedPassword());
550} 550}
551 551
552 552
553 553
554 554
555void KPPPWidget::beginConnect() { 555void KPPPWidget::beginConnect() {
556 // make sure to connect to the account that is selected in the combo box 556 // make sure to connect to the account that is selected in the combo box
557 // (exeption: an account given by a command line argument) 557 // (exeption: an account given by a command line argument)
558 // if(!m_bCmdlAccount) { 558 // if(!m_bCmdlAccount) {
559// gpppdata.setAccount(connectto_c->currentText()); 559// PPPData::data()->setAccount(connectto_c->currentText());
560// gpppdata.setPassword(PW_Edit->text()); 560// PPPData::data()->setPassword(PW_Edit->text());
561// } else { 561// } else {
562 gpppdata.setPassword(gpppdata.storedPassword()); 562 PPPData::data()->setPassword(PPPData::data()->storedPassword());
563// } 563// }
564 564
565 QFileInfo info(pppdPath()); 565 QFileInfo info(pppdPath());
566 566
567 if(!info.exists()){ 567 if(!info.exists()){
568 QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" 568 QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
569 "Make sure that pppd is installed and " 569 "Make sure that pppd is installed and "
570 "that you have entered the correct path.")); 570 "that you have entered the correct path."));
571 return; 571 return;
572 } 572 }
573#if 0 573#if 0
574 if(!info.isExecutable()){ 574 if(!info.isExecutable()){
575 575
576 QString string; 576 QString string;
577 string = i18n("kppp cannot execute:\n %1\n" 577 string = i18n("kppp cannot execute:\n %1\n"
578 "Please make sure that you have given kppp " 578 "Please make sure that you have given kppp "
579 "setuid permission and that " 579 "setuid permission and that "
580 "pppd is executable.").arg(gpppdata.pppdPath()); 580 "pppd is executable.").arg(PPPData::data()->pppdPath());
581 KMessageBox::error(this, string); 581 KMessageBox::error(this, string);
582 return; 582 return;
583 583
584 } 584 }
585#endif 585#endif
586 586
587 QFileInfo info2(gpppdata.modemDevice()); 587 QFileInfo info2(PPPData::data()->modemDevice());
588 588
589 if(!info2.exists()){ 589 if(!info2.exists()){
590 QString string; 590 QString string;
591 string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " 591 string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
592 "your modem device properly " 592 "your modem device properly "
593 "and/or adjust the location of the modem device on " 593 "and/or adjust the location of the modem device on "
594 "the modem tab of " 594 "the modem tab of "
595 "the setup dialog.").arg(gpppdata.modemDevice()); 595 "the setup dialog.").arg(PPPData::data()->modemDevice());
596 QMessageBox::warning(this, "error", string); 596 QMessageBox::warning(this, "error", string);
597 return; 597 return;
598 } 598 }
599 599
600 // if this is a PAP or CHAP account, ensure that username is 600 // if this is a PAP or CHAP account, ensure that username is
601 // supplied 601 // supplied
602 if(gpppdata.authMethod() == AUTH_PAP || 602 if(PPPData::data()->authMethod() == AUTH_PAP ||
603 gpppdata.authMethod() == AUTH_CHAP || 603 PPPData::data()->authMethod() == AUTH_CHAP ||
604 gpppdata.authMethod() == AUTH_PAPCHAP ) { 604 PPPData::data()->authMethod() == AUTH_PAPCHAP ) {
605 if(ID_Edit->text().isEmpty()) { 605 if(ID_Edit->text().isEmpty()) {
606 QMessageBox::warning(this,"error", 606 QMessageBox::warning(this,"error",
607 i18n( 607 i18n(
608 "You have selected the authentication " 608 "You have selected the authentication "
609 "method PAP or CHAP. This requires that you " 609 "method PAP or CHAP. This requires that you "
610 "supply a username and a password!")); 610 "supply a username and a password!"));
611 return; 611 return;
612 } else { 612 } else {
613 if(!Modem::modem->setSecret(gpppdata.authMethod(), 613 if(!Modem::modem->setSecret(PPPData::data()->authMethod(),
614 encodeWord(gpppdata.storedUsername()), 614 encodeWord(PPPData::data()->storedUsername()),
615 encodeWord(gpppdata.password()))) { 615 encodeWord(PPPData::data()->password()))) {
616 QString s; 616 QString s;
617 s = i18n("Cannot create PAP/CHAP authentication\n" 617 s = i18n("Cannot create PAP/CHAP authentication\n"
618 "file \"%1\"").arg(PAP_AUTH_FILE); 618 "file \"%1\"").arg(PAP_AUTH_FILE);
619 QMessageBox::warning(this, "error", s); 619 QMessageBox::warning(this, "error", s);
620 return; 620 return;
621 } 621 }
622 } 622 }
623 } 623 }
624 624
625 if (gpppdata.phonenumber().isEmpty()) { 625 if (PPPData::data()->phonenumber().isEmpty()) {
626 QString s = i18n("You must specify a telephone number!"); 626 QString s = i18n("You must specify a telephone number!");
627 QMessageBox::warning(this, "error", s); 627 QMessageBox::warning(this, "error", s);
628 return; 628 return;
629 } 629 }
630 630
631 this->hide(); 631 this->hide();
632 632
633 QString tit = i18n("Connecting to: %1").arg(gpppdata.accname()); 633 QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname());
634// con->setCaption(tit); 634// con->setCaption(tit);
635 635
636// con->show(); 636// con->show();
637 637
638 bool show_debug = gpppdata.get_show_log_window(); 638 bool show_debug = PPPData::data()->get_show_log_window();
639 // con->debug->setOn(show_debug);// toggle button 639 // con->debug->setOn(show_debug);// toggle button
640 debugwindow->clear(); 640 debugwindow->clear();
641 if (!show_debug) 641 if (!show_debug)
642 debugwindow->hide(); 642 debugwindow->hide();
643 else { 643 else {
644 debugwindow->show(); 644 debugwindow->show();
645// con->raise(); 645// con->raise();
646 } 646 }
647 647
648 emit begin_connect(); 648 emit begin_connect();
649} 649}
650 650
651 651
652void KPPPWidget::disconnect() { 652void KPPPWidget::disconnect() {
653 if (!gpppdata.command_before_disconnect().isEmpty()) { 653 if (!PPPData::data()->command_before_disconnect().isEmpty()) {
654// con_win->hide(); 654// con_win->hide();
655// con->show(); 655// con->show();
656// con->setCaption(i18n("Disconnecting...")); 656// con->setCaption(i18n("Disconnecting..."));
657// con->setMsg(i18n("Executing command before disconnection.")); 657// con->setMsg(i18n("Executing command before disconnection."));
658 658
659 qApp->processEvents(); 659 qApp->processEvents();
660 QApplication::flushX(); 660 QApplication::flushX();
661// pid_t id = 661// pid_t id =
662 execute_command(gpppdata.command_before_disconnect()); 662 execute_command(PPPData::data()->command_before_disconnect());
663// int i, status; 663// int i, status;
664 664
665// do { 665// do {
666// kapp->processEvents(); 666// kapp->processEvents();
667// i = waitpid(id, &status, WNOHANG); 667// i = waitpid(id, &status, WNOHANG);
668// usleep(500000); 668// usleep(500000);
669// } while (i == 0 && errno == 0); 669// } while (i == 0 && errno == 0);
670 670
671// con->hide(); 671// con->hide();
672 } 672 }
673 673
674 qApp->processEvents(); 674 qApp->processEvents();
675 675
676// statdlg->stop_stats(); 676// statdlg->stop_stats();
677 Modem::modem->killPPPDaemon(); 677 Modem::modem->killPPPDaemon();
678 678
679 QApplication::flushX(); 679 QApplication::flushX();
680 execute_command(gpppdata.command_on_disconnect()); 680 execute_command(PPPData::data()->command_on_disconnect());
681 681
682 Modem::modem->removeSecret(AUTH_PAP); 682 Modem::modem->removeSecret(AUTH_PAP);
683 Modem::modem->removeSecret(AUTH_CHAP); 683 Modem::modem->removeSecret(AUTH_CHAP);
684 684
685 removedns(); 685 removedns();
686 Modem::modem->unlockdevice(); 686 Modem::modem->unlockdevice();
687 687
688// con_win->stopClock(); 688// con_win->stopClock();
689// p_kppp->stopAccounting(); 689// p_kppp->stopAccounting();
690// con_win->hide(); 690// con_win->hide();
691 691
692// DockWidget::dock_widget->stop_stats(); 692// DockWidget::dock_widget->stop_stats();
693// DockWidget::dock_widget->hide(); 693// DockWidget::dock_widget->hide();
694 694
695// if(m_bQuitOnDisconnect) 695// if(m_bQuitOnDisconnect)
696// kapp->exit(0); 696// kapp->exit(0);
697// else { 697// else {
698 this->quit_b->setFocus(); 698 this->quit_b->setFocus();
699 this->show(); 699 this->show();
700// } 700// }
701} 701}
702 702
703 703
704// void KPPPWidget::helpbutton() { 704// void KPPPWidget::helpbutton() {
705// kapp->invokeHelp(); 705// kapp->invokeHelp();
706// } 706// }
707 707
708 708
709void KPPPWidget::quitbutton() { 709void KPPPWidget::quitbutton() {
710 if(gpppdata.pppdRunning()) { 710 if(PPPData::data()->pppdRunning()) {
711 int ok = QMessageBox::warning(this, 711 int ok = QMessageBox::warning(this,
712 i18n("Exiting kPPP will close your PPP Session."), 712 i18n("Exiting kPPP will close your PPP Session."),
713 i18n("Quit kPPP?")); 713 i18n("Quit kPPP?"));
714 if(ok == QMessageBox::Yes) { 714 if(ok == QMessageBox::Yes) {
715 Modem::modem->killPPPDaemon(); 715 Modem::modem->killPPPDaemon();
716 QApplication::flushX(); 716 QApplication::flushX();
717 execute_command(gpppdata.command_on_disconnect()); 717 execute_command(PPPData::data()->command_on_disconnect());
718 removedns(); 718 removedns();
719 Modem::modem->unlockdevice(); 719 Modem::modem->unlockdevice();
720 } 720 }
721 } else { 721 } else {
722 if (!gpppdata.accname().isEmpty() && !gpppdata.storePassword()) 722 if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword())
723 gpppdata.setStoredPassword(""); 723 PPPData::data()->setStoredPassword("");
724 } 724 }
725 gpppdata.save(); 725 PPPData::data()->save();
726 qApp->quit(); 726 qApp->quit();
727} 727}
728 728
729 729
730// void KPPPWidget::rulesetLoadError() { 730// void KPPPWidget::rulesetLoadError() {
731// QMessageBox::warning(this,"error", ruleset_load_errmsg); 731// QMessageBox::warning(this,"error", ruleset_load_errmsg);
732// } 732// }
733 733
734 734
735// void KPPPWidget::startAccounting() { 735// void KPPPWidget::startAccounting() {
736// // volume accounting 736// // volume accounting
737// stats->totalbytes = 0; 737// stats->totalbytes = 0;
738 738
739// kdDebug() << "AcctEnabled: " << gpppdata.AcctEnabled() << endl; 739// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl;
740 740
741// // load the ruleset 741// // load the ruleset
742// if(!gpppdata.AcctEnabled()) 742// if(!PPPData::data()->AcctEnabled())
743// return; 743// return;
744 744
745// QString d = AccountingBase::getAccountingFile(gpppdata.accountingFile()); 745// QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile());
746// // if(::access(d.data(), X_OK) != 0) 746// // if(::access(d.data(), X_OK) != 0)
747// acct = new Accounting(this, stats); 747// acct = new Accounting(this, stats);
748// // else 748// // else
749// // acct = new ExecutableAccounting(this); 749// // acct = new ExecutableAccounting(this);
750 750
751// // connect to the accounting object 751// // connect to the accounting object
752// connect(acct, SIGNAL(changed(QString, QString)), 752// connect(acct, SIGNAL(changed(QString, QString)),
753 // con_win, SLOT(slotAccounting(QString, QString))); 753 // con_win, SLOT(slotAccounting(QString, QString)));
754 754
755// // if(!acct->loadRuleSet(gpppdata.accountingFile())) { 755// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) {
756// // QString s= i18n("Can not load the accounting " 756// // QString s= i18n("Can not load the accounting "
757 // // "ruleset \"%1\"!").arg(gpppdata.accountingFile()); 757 // // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile());
758 758
759// // starting the messagebox with a timer will prevent us 759// // starting the messagebox with a timer will prevent us
760// // from blocking the calling function ConnectWidget::timerEvent 760// // from blocking the calling function ConnectWidget::timerEvent
761// ruleset_load_errmsg = s; 761// ruleset_load_errmsg = s;
762// QTimer::singleShot(0, this, SLOT(rulesetLoadError())); 762// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
763// return; 763// return;
764// } 764// }
765// //else 765// //else
766// // acct->slotStart(); 766// // acct->slotStart();
767// } 767// }
768 768
769// void KPPPWidget::stopAccounting() { 769// void KPPPWidget::stopAccounting() {
770// // store volume accounting 770// // store volume accounting
771// // if(stats->totalbytes != 0) 771// // if(stats->totalbytes != 0)
772// // gpppdata.setTotalBytes(stats->totalbytes); 772// // PPPData::data()->setTotalBytes(stats->totalbytes);
773 773
774// if(!gpppdata.AcctEnabled()) 774// if(!PPPData::data()->AcctEnabled())
775// return; 775// return;
776 776
777// // if(acct != 0) { 777// // if(acct != 0) {
778// // acct->slotStop(); 778// // acct->slotStop();
779// // delete acct; 779// // delete acct;
780// // acct = 0; 780// // acct = 0;
781// // } 781// // }
782// } 782// }
783 783
784 784
785// void KPPPWidget::showStats() { 785// void KPPPWidget::showStats() {
786// if(statdlg) { 786// if(statdlg) {
787// statdlg->show(); 787// statdlg->show();
788// statdlg->raise(); 788// statdlg->raise();
789// } 789// }
790// } 790// }
791 791
792 792
793void KPPPWidget::usernameChanged(const QString &) { 793void KPPPWidget::usernameChanged(const QString &) {
794 // store username for later use 794 // store username for later use
795 gpppdata.setStoredUsername(ID_Edit->text()); 795 PPPData::data()->setStoredUsername(ID_Edit->text());
796} 796}
797 797
798 798
799void KPPPWidget::passwordChanged(const QString &) { 799void KPPPWidget::passwordChanged(const QString &) {
800 // store the password if so requested 800 // store the password if so requested
801 if(gpppdata.storePassword()) 801 if(PPPData::data()->storePassword())
802 gpppdata.setStoredPassword(PW_Edit->text()); 802 PPPData::data()->setStoredPassword(PW_Edit->text());
803 else 803 else
804 gpppdata.setStoredPassword(""); 804 PPPData::data()->setStoredPassword("");
805} 805}
806 806
807 807
808void KPPPWidget::setPW_Edit(const QString &pw) { 808void KPPPWidget::setPW_Edit(const QString &pw) {
809 PW_Edit->setText(pw); 809 PW_Edit->setText(pw);
810} 810}
811 811
812 812
813// void KPPPWidget::resetCosts(const QString &s) { 813// void KPPPWidget::resetCosts(const QString &s) {
814// AccountingBase::resetCosts(s); 814// AccountingBase::resetCosts(s);
815// } 815// }
816 816
817 817
818// void KPPPWidget::resetVolume(const QString &s) { 818// void KPPPWidget::resetVolume(const QString &s) {
819// AccountingBase::resetVolume(s); 819// AccountingBase::resetVolume(s);
820// } 820// }
821 821
822/** 822/**
823 * pppd's getword() function knows about escape characters. 823 * pppd's getword() function knows about escape characters.
824 * If we write the username and password to the secrets file 824 * If we write the username and password to the secrets file
825 * we'll therefore have to escape back slashes. 825 * we'll therefore have to escape back slashes.
826 */ 826 */
827QString KPPPWidget::encodeWord(const QString &s) { 827QString KPPPWidget::encodeWord(const QString &s) {
828 QString r = s; 828 QString r = s;
829 r.replace(QRegExp("\\"), "\\\\"); 829 r.replace(QRegExp("\\"), "\\\\");
830 return r; 830 return r;
831} 831}
832 832
833// void KPPPWidget::setQuitOnDisconnect (bool b) 833// void KPPPWidget::setQuitOnDisconnect (bool b)
834// { 834// {
835// m_bQuitOnDisconnect = b; 835// m_bQuitOnDisconnect = b;
836// } 836// }
837 837
838void KPPPWidget::showNews() { 838void KPPPWidget::showNews() {
839#ifdef KPPP_SHOW_NEWS 839#ifdef KPPP_SHOW_NEWS
840 /* 840 /*
841 * Introduce the QuickHelp feature to new users of this version 841 * Introduce the QuickHelp feature to new users of this version
842 */ 842 */
843 #define QUICKHELP_HINT "Hint_QuickHelp" 843 #define QUICKHELP_HINT "Hint_QuickHelp"
844 if(gpppdata.readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { 844 if(PPPData::data()->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
845 QDialog dlg(0, 0, true); 845 QDialog dlg(0, 0, true);
846 dlg.setCaption(i18n("Recent Changes in KPPP")); 846 dlg.setCaption(i18n("Recent Changes in KPPP"));
847 847
848 QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); 848 QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
849 QHBoxLayout *l1 = new QHBoxLayout(10); 849 QHBoxLayout *l1 = new QHBoxLayout(10);
850 QVBoxLayout *l2 = new QVBoxLayout(10); 850 QVBoxLayout *l2 = new QVBoxLayout(10);
851 tl->addLayout(l1); 851 tl->addLayout(l1);
852 852
853 QLabel *icon = new QLabel(&dlg); 853 QLabel *icon = new QLabel(&dlg);
854 icon->setPixmap(BarIcon("exclamation")); 854 icon->setPixmap(BarIcon("exclamation"));
855 icon->setFixedSize(icon->sizeHint()); 855 icon->setFixedSize(icon->sizeHint());
856 l1->addWidget(icon); 856 l1->addWidget(icon);
857 l1->addLayout(l2); 857 l1->addLayout(l2);
858 858
859 QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" 859 QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n"
860 "called \"Quickhelp\". It's similar to a tooltip,\n" 860 "called \"Quickhelp\". It's similar to a tooltip,\n"
861 "but you can activate it whenever you want.\n" 861 "but you can activate it whenever you want.\n"
862 "\n" 862 "\n"
863 "To activate it, simply click on a control like\n" 863 "To activate it, simply click on a control like\n"
864 "a button or a label with the right mouse button.\n" 864 "a button or a label with the right mouse button.\n"
865 "If the item supports Quickhelp, a popup menu\n" 865 "If the item supports Quickhelp, a popup menu\n"
866 "will appear leading to Quickhelp.\n" 866 "will appear leading to Quickhelp.\n"
867 "\n" 867 "\n"
868 "To test it, right-click somewhere in this text."), 868 "To test it, right-click somewhere in this text."),
869 &dlg); 869 &dlg);
870 870
871 QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); 871 QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg);
872 cb->setFixedSize(cb->sizeHint()); 872 cb->setFixedSize(cb->sizeHint());
873 873
874 KButtonBox *bbox = new KButtonBox(&dlg); 874 KButtonBox *bbox = new KButtonBox(&dlg);
875 bbox->addStretch(1); 875 bbox->addStretch(1);
876 QPushButton *ok = bbox->addButton(i18n("OK")); 876 QPushButton *ok = bbox->addButton(i18n("OK"));
877 ok->setDefault(true); 877 ok->setDefault(true);
878 dlg.connect(ok, SIGNAL(clicked()), 878 dlg.connect(ok, SIGNAL(clicked()),
879 &dlg, SLOT(accept())); 879 &dlg, SLOT(accept()));
880 bbox->addStretch(1); 880 bbox->addStretch(1);
881 bbox->layout(); 881 bbox->layout();
882 882
883 l2->addWidget(l); 883 l2->addWidget(l);
884 l2->addWidget(cb); 884 l2->addWidget(cb);
885 tl->addWidget(bbox); 885 tl->addWidget(bbox);
886 886
887 QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" 887 QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n"
888 "This window will stay open until you\n" 888 "This window will stay open until you\n"
889 "click a mouse button or a press a key.\n"); 889 "click a mouse button or a press a key.\n");
890 890
891 QWhatsThis::add(cb,tmp); 891 QWhatsThis::add(cb,tmp);
892 QWhatsThis::add(l, tmp); 892 QWhatsThis::add(l, tmp);
893 893
894 dlg.exec(); 894 dlg.exec();
895 if(cb->isChecked()) { 895 if(cb->isChecked()) {
896 gpppdata.writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); 896 PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
897 gpppdata.save(); 897 PPPData::data()->save();
898 } 898 }
899 } 899 }
900#endif 900#endif
901} 901}
902 902
903 903
904//#include "kpppwidget.moc" 904//#include "kpppwidget.moc"
905 905
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index a2f77c5..cd5d21c 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -8,692 +8,692 @@
8 * 8 *
9 * This file was added by Harri Porten <porten@tu-harburg.de> 9 * This file was added by Harri Porten <porten@tu-harburg.de>
10 * 10 *
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <errno.h> 27#include <errno.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <fcntl.h> 29#include <fcntl.h>
30#include <signal.h> 30#include <signal.h>
31#include <sys/ioctl.h> 31#include <sys/ioctl.h>
32#include <setjmp.h> 32#include <setjmp.h>
33#include <regex.h> 33#include <regex.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <assert.h> 35#include <assert.h>
36 36
37#include "auth.h" 37#include "auth.h"
38#include "modem.h" 38#include "modem.h"
39#include "pppdata.h" 39#include "pppdata.h"
40//#include <klocale.h> 40//#include <klocale.h>
41#define i18n QObject::tr 41#define i18n QObject::tr
42#define qError qDebug 42#define qError qDebug
43//#include <kdebug.h> 43//#include <kdebug.h>
44//#include <config.h> 44//#include <config.h>
45 45
46#define MY_ASSERT(x) if (!(x)) { \ 46#define MY_ASSERT(x) if (!(x)) { \
47 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ 47 qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
48 exit(1); } 48 exit(1); }
49 49
50 50
51static sigjmp_buf jmp_buffer; 51static sigjmp_buf jmp_buffer;
52 52
53Modem *Modem::modem = 0; 53Modem *Modem::modem = 0;
54 54
55 55
56const char* pppdPath() { 56const char* pppdPath() {
57 // wasting a few bytes 57 // wasting a few bytes
58 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; 58 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
59 static char *pppdPath = 0L; 59 static char *pppdPath = 0L;
60 char *p; 60 char *p;
61 61
62 if(pppdPath == 0L) { 62 if(pppdPath == 0L) {
63 const char *c = PPPDSEARCHPATH; 63 const char *c = PPPDSEARCHPATH;
64 while(*c != '\0') { 64 while(*c != '\0') {
65 while(*c == ':') 65 while(*c == ':')
66 c++; 66 c++;
67 p = buffer; 67 p = buffer;
68 while(*c != '\0' && *c != ':') 68 while(*c != '\0' && *c != ':')
69 *p++ = *c++; 69 *p++ = *c++;
70 *p = '\0'; 70 *p = '\0';
71 strcat(p, "/"); 71 strcat(p, "/");
72 strcat(p, PPPDNAME); 72 strcat(p, PPPDNAME);
73 if(access(buffer, F_OK) == 0) 73 if(access(buffer, F_OK) == 0)
74 return (pppdPath = buffer); 74 return (pppdPath = buffer);
75 } 75 }
76 } 76 }
77 77
78 return pppdPath; 78 return pppdPath;
79} 79}
80 80
81 81
82Modem::Modem() 82Modem::Modem()
83{ 83{
84 if (Modem::modem != 0) return; //CORRECT? 84 if (Modem::modem != 0) return; //CORRECT?
85 modemfd = -1; 85 modemfd = -1;
86 sn = 0L; 86 sn = 0L;
87 data_mode = false; 87 data_mode = false;
88 modem_is_locked = false; 88 modem_is_locked = false;
89 lockfile[0] = '\0'; 89 lockfile[0] = '\0';
90 device = "/dev/modem"; 90 device = "/dev/modem";
91 modem = this; 91 modem = this;
92} 92}
93 93
94 94
95Modem::~Modem() { 95Modem::~Modem() {
96 modem = 0; 96 modem = 0;
97} 97}
98 98
99 99
100speed_t Modem::modemspeed() { 100speed_t Modem::modemspeed() {
101 // convert the string modem speed int the gpppdata object to a t_speed type 101 // convert the string modem speed int the gpppdata object to a t_speed type
102 // to set the modem. The constants here should all be ifdef'd because 102 // to set the modem. The constants here should all be ifdef'd because
103 // other systems may not have them 103 // other systems may not have them
104 int i = gpppdata.speed().toInt()/100; 104 int i = PPPData::data()->speed().toInt()/100;
105 105
106 switch(i) { 106 switch(i) {
107 case 24: 107 case 24:
108 return B2400; 108 return B2400;
109 break; 109 break;
110 case 96: 110 case 96:
111 return B9600; 111 return B9600;
112 break; 112 break;
113 case 192: 113 case 192:
114 return B19200; 114 return B19200;
115 break; 115 break;
116 case 384: 116 case 384:
117 return B38400; 117 return B38400;
118 break; 118 break;
119#ifdef B57600 119#ifdef B57600
120 case 576: 120 case 576:
121 return B57600; 121 return B57600;
122 break; 122 break;
123#endif 123#endif
124 124
125#ifdef B115200 125#ifdef B115200
126 case 1152: 126 case 1152:
127 return B115200; 127 return B115200;
128 break; 128 break;
129#endif 129#endif
130 130
131#ifdef B230400 131#ifdef B230400
132 case 2304: 132 case 2304:
133 return B230400; 133 return B230400;
134 break; 134 break;
135#endif 135#endif
136 136
137#ifdef B460800 137#ifdef B460800
138 case 4608: 138 case 4608:
139 return B460800; 139 return B460800;
140 break; 140 break;
141#endif 141#endif
142 142
143 default: 143 default:
144 return B38400; 144 return B38400;
145 break; 145 break;
146 } 146 }
147} 147}
148 148
149bool Modem::opentty() { 149bool Modem::opentty() {
150 // int flags; 150 // int flags;
151 151
152//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 152//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
153 close(modemfd); 153 close(modemfd);
154// device = "/dev/modem";//deviceByIndex(request.modem.deviceNum); 154 device = PPPData::data()->modemDevice();
155 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { 155 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
156 qDebug("error opening modem device !"); 156 qDebug("error opening modem device !");
157 errmsg = i18n("Unable to open modem."); 157 errmsg = i18n("Unable to open modem.");
158 return false; 158 return false;
159 } 159 }
160//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 160//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
161//} 161//}
162 162
163#if 0 163#if 0
164 if(gpppdata.UseCDLine()) { 164 if(PPPData::data()->UseCDLine()) {
165 if(ioctl(modemfd, TIOCMGET, &flags) == -1) { 165 if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
166 errmsg = i18n("Unable to detect state of CD line."); 166 errmsg = i18n("Unable to detect state of CD line.");
167 ::close(modemfd); 167 ::close(modemfd);
168 modemfd = -1; 168 modemfd = -1;
169 return false; 169 return false;
170 } 170 }
171 if ((flags&TIOCM_CD) == 0) { 171 if ((flags&TIOCM_CD) == 0) {
172 errmsg = i18n("The modem is not ready."); 172 errmsg = i18n("The modem is not ready.");
173 ::close(modemfd); 173 ::close(modemfd);
174 modemfd = -1; 174 modemfd = -1;
175 return false; 175 return false;
176 } 176 }
177 } 177 }
178#endif 178#endif
179 179
180 tcdrain (modemfd); 180 tcdrain (modemfd);
181 tcflush (modemfd, TCIOFLUSH); 181 tcflush (modemfd, TCIOFLUSH);
182 182
183 if(tcgetattr(modemfd, &tty) < 0){ 183 if(tcgetattr(modemfd, &tty) < 0){
184 // this helps in some cases 184 // this helps in some cases
185 tcsendbreak(modemfd, 0); 185 tcsendbreak(modemfd, 0);
186 sleep(1); 186 sleep(1);
187 if(tcgetattr(modemfd, &tty) < 0){ 187 if(tcgetattr(modemfd, &tty) < 0){
188 errmsg = i18n("The modem is busy."); 188 errmsg = i18n("The modem is busy.");
189 ::close(modemfd); 189 ::close(modemfd);
190 modemfd = -1; 190 modemfd = -1;
191 return false; 191 return false;
192 } 192 }
193 } 193 }
194 194
195 memset(&initial_tty,'\0',sizeof(initial_tty)); 195 memset(&initial_tty,'\0',sizeof(initial_tty));
196 196
197 initial_tty = tty; 197 initial_tty = tty;
198 198
199 tty.c_cc[VMIN] = 0; // nonblocking 199 tty.c_cc[VMIN] = 0; // nonblocking
200 tty.c_cc[VTIME] = 0; 200 tty.c_cc[VTIME] = 0;
201 tty.c_oflag = 0; 201 tty.c_oflag = 0;
202 tty.c_lflag = 0; 202 tty.c_lflag = 0;
203 203
204 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 204 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
205 tty.c_cflag |= CS8 | CREAD; 205 tty.c_cflag |= CS8 | CREAD;
206 tty.c_cflag |= CLOCAL; // ignore modem status lines 206 tty.c_cflag |= CLOCAL; // ignore modem status lines
207 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; 207 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
208 tty.c_lflag &= ~ICANON; // non-canonical mode 208 tty.c_lflag &= ~ICANON; // non-canonical mode
209 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); 209 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
210 210
211 211
212 if(gpppdata.flowcontrol() != "None") { 212 if(PPPData::data()->flowcontrol() != "None") {
213 if(gpppdata.flowcontrol() == "CRTSCTS") { 213 if(PPPData::data()->flowcontrol() == "CRTSCTS") {
214 tty.c_cflag |= CRTSCTS; 214 tty.c_cflag |= CRTSCTS;
215 } 215 }
216 else { 216 else {
217 tty.c_iflag |= IXON | IXOFF; 217 tty.c_iflag |= IXON | IXOFF;
218 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ 218 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
219 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ 219 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
220 } 220 }
221 } 221 }
222 else { 222 else {
223 tty.c_cflag &= ~CRTSCTS; 223 tty.c_cflag &= ~CRTSCTS;
224 tty.c_iflag &= ~(IXON | IXOFF); 224 tty.c_iflag &= ~(IXON | IXOFF);
225 } 225 }
226 226
227 cfsetospeed(&tty, modemspeed()); 227 cfsetospeed(&tty, modemspeed());
228 cfsetispeed(&tty, modemspeed()); 228 cfsetispeed(&tty, modemspeed());
229 229
230 tcdrain(modemfd); 230 tcdrain(modemfd);
231 231
232 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ 232 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
233 errmsg = i18n("The modem is busy."); 233 errmsg = i18n("The modem is busy.");
234 ::close(modemfd); 234 ::close(modemfd);
235 modemfd=-1; 235 modemfd=-1;
236 return false; 236 return false;
237 } 237 }
238 238
239 errmsg = i18n("Modem Ready."); 239 errmsg = i18n("Modem Ready.");
240 return true; 240 return true;
241} 241}
242 242
243 243
244bool Modem::closetty() { 244bool Modem::closetty() {
245 if(modemfd >=0 ) { 245 if(modemfd >=0 ) {
246 stop(); 246 stop();
247 /* discard data not read or transmitted */ 247 /* discard data not read or transmitted */
248 tcflush(modemfd, TCIOFLUSH); 248 tcflush(modemfd, TCIOFLUSH);
249 249
250 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ 250 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
251 errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); 251 errmsg = i18n("Can't restore tty settings: tcsetattr()\n");
252 ::close(modemfd); 252 ::close(modemfd);
253 modemfd = -1; 253 modemfd = -1;
254 return false; 254 return false;
255 } 255 }
256 ::close(modemfd); 256 ::close(modemfd);
257 modemfd = -1; 257 modemfd = -1;
258 } 258 }
259 259
260 return true; 260 return true;
261} 261}
262 262
263 263
264void Modem::readtty(int) { 264void Modem::readtty(int) {
265 char buffer[200]; 265 char buffer[200];
266 unsigned char c; 266 unsigned char c;
267 int len; 267 int len;
268 268
269 // read data in chunks of up to 200 bytes 269 // read data in chunks of up to 200 bytes
270 if((len = ::read(modemfd, buffer, 200)) > 0) { 270 if((len = ::read(modemfd, buffer, 200)) > 0) {
271 // split buffer into single characters for further processing 271 // split buffer into single characters for further processing
272 for(int i = 0; i < len; i++) { 272 for(int i = 0; i < len; i++) {
273 c = buffer[i] & 0x7F; 273 c = buffer[i] & 0x7F;
274 emit charWaiting(c); 274 emit charWaiting(c);
275 } 275 }
276 } 276 }
277} 277}
278 278
279 279
280void Modem::notify(const QObject *receiver, const char *member) { 280void Modem::notify(const QObject *receiver, const char *member) {
281 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); 281 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member);
282 startNotifier(); 282 startNotifier();
283} 283}
284 284
285 285
286void Modem::stop() { 286void Modem::stop() {
287 disconnect(SIGNAL(charWaiting(unsigned char))); 287 disconnect(SIGNAL(charWaiting(unsigned char)));
288 stopNotifier(); 288 stopNotifier();
289} 289}
290 290
291 291
292void Modem::startNotifier() { 292void Modem::startNotifier() {
293 if(modemfd >= 0) { 293 if(modemfd >= 0) {
294 if(sn == 0) { 294 if(sn == 0) {
295 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); 295 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
296 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); 296 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
297 qDebug("QSocketNotifier started!"); 297 qDebug("QSocketNotifier started!");
298 } else { 298 } else {
299 qDebug("QSocketNotifier re-enabled!"); 299 qDebug("QSocketNotifier re-enabled!");
300 sn->setEnabled(true); 300 sn->setEnabled(true);
301 } 301 }
302 } 302 }
303} 303}
304 304
305 305
306void Modem::stopNotifier() { 306void Modem::stopNotifier() {
307 if(sn != 0) { 307 if(sn != 0) {
308 sn->setEnabled(false); 308 sn->setEnabled(false);
309 disconnect(sn); 309 disconnect(sn);
310 delete sn; 310 delete sn;
311 sn = 0; 311 sn = 0;
312 qDebug( "QSocketNotifier stopped!" ); 312 qDebug( "QSocketNotifier stopped!" );
313 } 313 }
314} 314}
315 315
316 316
317void Modem::flush() { 317void Modem::flush() {
318 char c; 318 char c;
319 while(read(modemfd, &c, 1) == 1); 319 while(read(modemfd, &c, 1) == 1);
320} 320}
321 321
322 322
323bool Modem::writeChar(unsigned char c) { 323bool Modem::writeChar(unsigned char c) {
324 int s; 324 int s;
325 do { 325 do {
326 s = write(modemfd, &c, 1); 326 s = write(modemfd, &c, 1);
327 if (s < 0) { 327 if (s < 0) {
328 qError( "write() in Modem::writeChar failed" ); 328 qError( "write() in Modem::writeChar failed" );
329 return false; 329 return false;
330 } 330 }
331 } while(s == 0); 331 } while(s == 0);
332 332
333 return true; 333 return true;
334} 334}
335 335
336 336
337bool Modem::writeLine(const char *buf) { 337bool Modem::writeLine(const char *buf) {
338 int len = strlen(buf); 338 int len = strlen(buf);
339 char *b = new char[len+2]; 339 char *b = new char[len+2];
340 memcpy(b, buf, len); 340 memcpy(b, buf, len);
341 // different modems seem to need different line terminations 341 // different modems seem to need different line terminations
342 QString term = gpppdata.enter(); 342 QString term = PPPData::data()->enter();
343 if(term == "LF") 343 if(term == "LF")
344 b[len++]='\n'; 344 b[len++]='\n';
345 else if(term == "CR") 345 else if(term == "CR")
346 b[len++]='\r'; 346 b[len++]='\r';
347 else if(term == "CR/LF") { 347 else if(term == "CR/LF") {
348 b[len++]='\r'; 348 b[len++]='\r';
349 b[len++]='\n'; 349 b[len++]='\n';
350 } 350 }
351 int l = len; 351 int l = len;
352 while(l) { 352 while(l) {
353 int wr = write(modemfd, &b[len-l], l); 353 int wr = write(modemfd, &b[len-l], l);
354 if(wr < 0) { 354 if(wr < 0) {
355 // TODO do something meaningful with the error code (or ignore it 355 // TODO do something meaningful with the error code (or ignore it
356 qError( "write() in Modem::writeLine failed" ); 356 qError( "write() in Modem::writeLine failed" );
357 delete[] b; 357 delete[] b;
358 return false; 358 return false;
359 } 359 }
360 l -= wr; 360 l -= wr;
361 } 361 }
362 delete[] b; 362 delete[] b;
363 return true; 363 return true;
364} 364}
365 365
366 366
367bool Modem::hangup() { 367bool Modem::hangup() {
368 // this should really get the modem to hang up and go into command mode 368 // this should really get the modem to hang up and go into command mode
369 // If anyone sees a fault in the following please let me know, since 369 // If anyone sees a fault in the following please let me know, since
370 // this is probably the most imporant snippet of code in the whole of 370 // this is probably the most imporant snippet of code in the whole of
371 // kppp. If people complain about kppp being stuck, this piece of code 371 // kppp. If people complain about kppp being stuck, this piece of code
372 // is most likely the reason. 372 // is most likely the reason.
373 struct termios temptty; 373 struct termios temptty;
374 374
375 if(modemfd >= 0) { 375 if(modemfd >= 0) {
376 376
377 // is this Escape & HangupStr stuff really necessary ? (Harri) 377 // is this Escape & HangupStr stuff really necessary ? (Harri)
378 378
379 if (data_mode) escape_to_command_mode(); 379 if (data_mode) escape_to_command_mode();
380 380
381 // Then hangup command 381 // Then hangup command
382 writeLine(gpppdata.modemHangupStr().local8Bit()); 382 writeLine(PPPData::data()->modemHangupStr().local8Bit());
383 383
384 usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec 384 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
385 385
386#ifndef DEBUG_WO_DIALING 386#ifndef DEBUG_WO_DIALING
387 if (sigsetjmp(jmp_buffer, 1) == 0) { 387 if (sigsetjmp(jmp_buffer, 1) == 0) {
388 // set alarm in case tcsendbreak() hangs 388 // set alarm in case tcsendbreak() hangs
389 signal(SIGALRM, alarm_handler); 389 signal(SIGALRM, alarm_handler);
390 alarm(2); 390 alarm(2);
391 391
392 tcsendbreak(modemfd, 0); 392 tcsendbreak(modemfd, 0);
393 393
394 alarm(0); 394 alarm(0);
395 signal(SIGALRM, SIG_IGN); 395 signal(SIGALRM, SIG_IGN);
396 } else { 396 } else {
397 // we reach this point if the alarm handler got called 397 // we reach this point if the alarm handler got called
398 closetty(); 398 closetty();
399 close(modemfd); 399 close(modemfd);
400 modemfd = -1; 400 modemfd = -1;
401 errmsg = i18n("The modem does not respond."); 401 errmsg = i18n("The modem does not respond.");
402 return false; 402 return false;
403 } 403 }
404 404
405#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. 405#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
406 tcgetattr(modemfd, &temptty); 406 tcgetattr(modemfd, &temptty);
407 cfsetospeed(&temptty, B0); 407 cfsetospeed(&temptty, B0);
408 cfsetispeed(&temptty, B0); 408 cfsetispeed(&temptty, B0);
409 tcsetattr(modemfd, TCSAFLUSH, &temptty); 409 tcsetattr(modemfd, TCSAFLUSH, &temptty);
410#else 410#else
411 int modemstat; 411 int modemstat;
412 ioctl(modemfd, TIOCMGET, &modemstat); 412 ioctl(modemfd, TIOCMGET, &modemstat);
413 modemstat &= ~TIOCM_DTR; 413 modemstat &= ~TIOCM_DTR;
414 ioctl(modemfd, TIOCMSET, &modemstat); 414 ioctl(modemfd, TIOCMSET, &modemstat);
415 ioctl(modemfd, TIOCMGET, &modemstat); 415 ioctl(modemfd, TIOCMGET, &modemstat);
416 modemstat |= TIOCM_DTR; 416 modemstat |= TIOCM_DTR;
417 ioctl(modemfd, TIOCMSET, &modemstat); 417 ioctl(modemfd, TIOCMSET, &modemstat);
418#endif 418#endif
419 419
420 usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 secs 420 usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs
421 421
422 cfsetospeed(&temptty, modemspeed()); 422 cfsetospeed(&temptty, modemspeed());
423 cfsetispeed(&temptty, modemspeed()); 423 cfsetispeed(&temptty, modemspeed());
424 tcsetattr(modemfd, TCSAFLUSH, &temptty); 424 tcsetattr(modemfd, TCSAFLUSH, &temptty);
425#endif 425#endif
426 return true; 426 return true;
427 } else 427 } else
428 return false; 428 return false;
429} 429}
430 430
431 431
432void Modem::escape_to_command_mode() { 432void Modem::escape_to_command_mode() {
433 // Send Properly bracketed escape code to put the modem back into command state. 433 // Send Properly bracketed escape code to put the modem back into command state.
434 // A modem will accept AT commands only when it is in command state. 434 // A modem will accept AT commands only when it is in command state.
435 // When a modem sends the host the CONNECT string, that signals 435 // When a modem sends the host the CONNECT string, that signals
436 // that the modem is now in the connect state (no long accepts AT commands.) 436 // that the modem is now in the connect state (no long accepts AT commands.)
437 // Need to send properly timed escape sequence to put modem in command state. 437 // Need to send properly timed escape sequence to put modem in command state.
438 // Escape codes and guard times are controlled by S2 and S12 values. 438 // Escape codes and guard times are controlled by S2 and S12 values.
439 // 439 //
440 tcflush(modemfd, TCIOFLUSH); 440 tcflush(modemfd, TCIOFLUSH);
441 441
442 // +3 because quiet time must be greater than guard time. 442 // +3 because quiet time must be greater than guard time.
443 usleep((gpppdata.modemEscapeGuardTime()+3)*20000); 443 usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
444 QCString tmp = gpppdata.modemEscapeStr().local8Bit(); 444 QCString tmp = PPPData::data()->modemEscapeStr().local8Bit();
445 write(modemfd, tmp.data(), tmp.length()); 445 write(modemfd, tmp.data(), tmp.length());
446 tcflush(modemfd, TCIOFLUSH); 446 tcflush(modemfd, TCIOFLUSH);
447 usleep((gpppdata.modemEscapeGuardTime()+3)*20000); 447 usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000);
448 448
449 data_mode = false; 449 data_mode = false;
450} 450}
451 451
452 452
453const QString Modem::modemMessage() { 453const QString Modem::modemMessage() {
454 return errmsg; 454 return errmsg;
455} 455}
456 456
457 457
458QString Modem::parseModemSpeed(const QString &s) { 458QString Modem::parseModemSpeed(const QString &s) {
459 // this is a small (and bad) parser for modem speeds 459 // this is a small (and bad) parser for modem speeds
460 int rx = -1; 460 int rx = -1;
461 int tx = -1; 461 int tx = -1;
462 int i; 462 int i;
463 QString result; 463 QString result;
464 464
465 qDebug( "Modem reported result string: %s", s.latin1()); 465 qDebug( "Modem reported result string: %s", s.latin1());
466 466
467 const int RXMAX = 7; 467 const int RXMAX = 7;
468 const int TXMAX = 2; 468 const int TXMAX = 2;
469 QRegExp rrx[RXMAX] = { 469 QRegExp rrx[RXMAX] = {
470 QRegExp("[0-9]+[:/ ]RX", false), 470 QRegExp("[0-9]+[:/ ]RX", false),
471 QRegExp("[0-9]+RX", false), 471 QRegExp("[0-9]+RX", false),
472 QRegExp("[/: -][0-9]+[/: ]", false), 472 QRegExp("[/: -][0-9]+[/: ]", false),
473 QRegExp("[/: -][0-9]+$", false), 473 QRegExp("[/: -][0-9]+$", false),
474 QRegExp("CARRIER [^0-9]*[0-9]+", false), 474 QRegExp("CARRIER [^0-9]*[0-9]+", false),
475 QRegExp("CONNECT [^0-9]*[0-9]+", false), 475 QRegExp("CONNECT [^0-9]*[0-9]+", false),
476 QRegExp("[0-9]+") // panic mode 476 QRegExp("[0-9]+") // panic mode
477 }; 477 };
478 478
479 QRegExp trx[TXMAX] = { 479 QRegExp trx[TXMAX] = {
480 QRegExp("[0-9]+[:/ ]TX", false), 480 QRegExp("[0-9]+[:/ ]TX", false),
481 QRegExp("[0-9]+TX", false) 481 QRegExp("[0-9]+TX", false)
482 }; 482 };
483 483
484 for(i = 0; i < RXMAX; i++) { 484 for(i = 0; i < RXMAX; i++) {
485 int len, idx, result; 485 int len, idx, result;
486 if((idx = rrx[i].match(s,0,&len)) > -1) { 486 if((idx = rrx[i].match(s,0,&len)) > -1) {
487// if((idx = rrx[i].search(s)) > -1) { 487// if((idx = rrx[i].search(s)) > -1) {
488 // len = rrx[i].matchedLength(); 488 // len = rrx[i].matchedLength();
489 489
490 // 490 //
491 // rrx[i] has been matched, idx contains the start of the match 491 // rrx[i] has been matched, idx contains the start of the match
492 // and len contains how long the match is. Extract the match. 492 // and len contains how long the match is. Extract the match.
493 // 493 //
494 QString sub = s.mid(idx, len); 494 QString sub = s.mid(idx, len);
495 495
496 // 496 //
497 // Now extract the digits only from the match, which will 497 // Now extract the digits only from the match, which will
498 // then be converted to an int. 498 // then be converted to an int.
499 // 499 //
500 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { 500 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) {
501// if ((idx = rrx[RXMAX-1].search( sub )) > -1) { 501// if ((idx = rrx[RXMAX-1].search( sub )) > -1) {
502// len = rrx[RXMAX-1].matchedLength(); 502// len = rrx[RXMAX-1].matchedLength();
503 sub = sub.mid(idx, len); 503 sub = sub.mid(idx, len);
504 result = sub.toInt(); 504 result = sub.toInt();
505 if(result > 0) { 505 if(result > 0) {
506 rx = result; 506 rx = result;
507 break; 507 break;
508 } 508 }
509 } 509 }
510 } 510 }
511 } 511 }
512 512
513 for(i = 0; i < TXMAX; i++) { 513 for(i = 0; i < TXMAX; i++) {
514 int len, idx, result; 514 int len, idx, result;
515 if((idx = trx[i].match(s,0,&len)) > -1) { 515 if((idx = trx[i].match(s,0,&len)) > -1) {
516// if((idx = trx[i].search(s)) > -1) { 516// if((idx = trx[i].search(s)) > -1) {
517// len = trx[i].matchedLength(); 517// len = trx[i].matchedLength();
518 518
519 // 519 //
520 // trx[i] has been matched, idx contains the start of the match 520 // trx[i] has been matched, idx contains the start of the match
521 // and len contains how long the match is. Extract the match. 521 // and len contains how long the match is. Extract the match.
522 // 522 //
523 QString sub = s.mid(idx, len); 523 QString sub = s.mid(idx, len);
524 524
525 // 525 //
526 // Now extract the digits only from the match, which will then 526 // Now extract the digits only from the match, which will then
527 // be converted to an int. 527 // be converted to an int.
528 // 528 //
529 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { 529 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) {
530// if((idx = rrx[RXMAX-1].search(sub)) > -1) { 530// if((idx = rrx[RXMAX-1].search(sub)) > -1) {
531// len = rrx[RXMAX-1].matchedLength(); 531// len = rrx[RXMAX-1].matchedLength();
532 sub = sub.mid(idx, len); 532 sub = sub.mid(idx, len);
533 result = sub.toInt(); 533 result = sub.toInt();
534 if(result > 0) { 534 if(result > 0) {
535 tx = result; 535 tx = result;
536 break; 536 break;
537 } 537 }
538 } 538 }
539 } 539 }
540 } 540 }
541 541
542 if(rx == -1 && tx == -1) 542 if(rx == -1 && tx == -1)
543 result = i18n("Unknown speed"); 543 result = i18n("Unknown speed");
544 else if(tx == -1) 544 else if(tx == -1)
545 result.setNum(rx); 545 result.setNum(rx);
546 else if(rx == -1) // should not happen 546 else if(rx == -1) // should not happen
547 result.setNum(tx); 547 result.setNum(tx);
548 else 548 else
549 result.sprintf("%d/%d", rx, tx); 549 result.sprintf("%d/%d", rx, tx);
550 550
551 qDebug( "The parsed result is: %s", result.latin1()); 551 qDebug( "The parsed result is: %s", result.latin1());
552 552
553 return result; 553 return result;
554} 554}
555 555
556 556
557// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if 557// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
558// a lock file can't be created ( permission problem ) 558// a lock file can't be created ( permission problem )
559int Modem::lockdevice() { 559int Modem::lockdevice() {
560 int fd; 560 int fd;
561 char newlock[80]=""; // safe 561 char newlock[80]=""; // safe
562 562
563 if(!gpppdata.modemLockFile()) { 563 if(!PPPData::data()->modemLockFile()) {
564 qDebug("The user doesn't want a lockfile."); 564 qDebug("The user doesn't want a lockfile.");
565 return 0; 565 return 0;
566 } 566 }
567 567
568 if (modem_is_locked) 568 if (modem_is_locked)
569 return 1; 569 return 1;
570 570
571 QString lockfile = LOCK_DIR"/LCK.."; 571 QString lockfile = LOCK_DIR"/LCK..";
572 lockfile += gpppdata.modemDevice().mid(5); // append everything after /dev/ 572 lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/
573 573
574 if(access(QFile::encodeName(lockfile), F_OK) == 0) { 574 if(access(QFile::encodeName(lockfile), F_OK) == 0) {
575// if ((fd = Requester::rq-> 575// if ((fd = Requester::rq->
576if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { 576if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
577 // Mario: it's not necessary to read more than lets say 32 bytes. If 577 // Mario: it's not necessary to read more than lets say 32 bytes. If
578 // file has more than 32 bytes, skip the rest 578 // file has more than 32 bytes, skip the rest
579 char oldlock[33]; // safe 579 char oldlock[33]; // safe
580 int sz = read(fd, &oldlock, 32); 580 int sz = read(fd, &oldlock, 32);
581 close (fd); 581 close (fd);
582 if (sz <= 0) 582 if (sz <= 0)
583 return 1; 583 return 1;
584 oldlock[sz] = '\0'; 584 oldlock[sz] = '\0';
585 585
586 qDebug( "Device is locked by: %s", oldlock); 586 qDebug( "Device is locked by: %s", oldlock);
587 587
588 int oldpid; 588 int oldpid;
589 int match = sscanf(oldlock, "%d", &oldpid); 589 int match = sscanf(oldlock, "%d", &oldpid);
590 590
591 // found a pid in lockfile ? 591 // found a pid in lockfile ?
592 if (match < 1 || oldpid <= 0) 592 if (match < 1 || oldpid <= 0)
593 return 1; 593 return 1;
594 594
595 // check if process exists 595 // check if process exists
596 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) 596 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
597 return 1; 597 return 1;
598 598
599 qDebug( "lockfile is stale" ); 599 qDebug( "lockfile is stale" );
600 } 600 }
601 } 601 }
602 602
603 fd = openLockfile(gpppdata.modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); 603 fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
604 if(fd >= 0) { 604 if(fd >= 0) {
605 sprintf(newlock,"%010d\n", getpid()); 605 sprintf(newlock,"%010d\n", getpid());
606 qDebug("Locking Device: %s", newlock); 606 qDebug("Locking Device: %s", newlock);
607 607
608 write(fd, newlock, strlen(newlock)); 608 write(fd, newlock, strlen(newlock));
609 close(fd); 609 close(fd);
610 modem_is_locked=true; 610 modem_is_locked=true;
611 611
612 return 0; 612 return 0;
613 } 613 }
614 614
615 return -1; 615 return -1;
616 616
617} 617}
618 618
619 619
620// UnLock modem device 620// UnLock modem device
621void Modem::unlockdevice() { 621void Modem::unlockdevice() {
622 if (modem_is_locked) { 622 if (modem_is_locked) {
623 qDebug( "UnLocking Modem Device" ); 623 qDebug( "UnLocking Modem Device" );
624 close(modemfd); 624 close(modemfd);
625 modemfd = -1; 625 modemfd = -1;
626 unlink(lockfile); 626 unlink(lockfile);
627 lockfile[0] = '\0'; 627 lockfile[0] = '\0';
628 modem_is_locked=false; 628 modem_is_locked=false;
629 } 629 }
630} 630}
631 631
632int Modem::openLockfile( QString lockfile, int flags) 632int Modem::openLockfile( QString lockfile, int flags)
633{ 633{
634 int fd; 634 int fd;
635 int mode; 635 int mode;
636 flags = O_RDONLY; 636 flags = O_RDONLY;
637 if(flags == O_WRONLY|O_TRUNC|O_CREAT) 637 if(flags == O_WRONLY|O_TRUNC|O_CREAT)
638 mode = 0644; 638 mode = 0644;
639 else 639 else
640 mode = 0; 640 mode = 0;
641 641
642 lockfile = LOCK_DIR; 642 lockfile = LOCK_DIR;
643 lockfile += "/LCK.."; 643 lockfile += "/LCK..";
644 lockfile += device.right( device.length() - device.findRev("/") -1 ); 644 lockfile += device.right( device.length() - device.findRev("/") -1 );
645 qDebug("lockfile >%s<",lockfile.latin1()); 645 qDebug("lockfile >%s<",lockfile.latin1());
646 // TODO: 646 // TODO:
647 // struct stat st; 647 // struct stat st;
648 // if(stat(lockfile.data(), &st) == -1) { 648 // if(stat(lockfile.data(), &st) == -1) {
649 // if(errno == EBADF) 649 // if(errno == EBADF)
650 // return -1; 650 // return -1;
651 // } else { 651 // } else {
652 // // make sure that this is a regular file 652 // // make sure that this is a regular file
653 // if(!S_ISREG(st.st_mode)) 653 // if(!S_ISREG(st.st_mode))
654 // return -1; 654 // return -1;
655 // } 655 // }
656 if ((fd = open(lockfile, flags, mode)) == -1) { 656 if ((fd = open(lockfile, flags, mode)) == -1) {
657 qDebug("error opening lockfile!"); 657 qDebug("error opening lockfile!");
658 lockfile = QString::null; 658 lockfile = QString::null;
659 fd = open(DEVNULL, O_RDONLY); 659 fd = open(DEVNULL, O_RDONLY);
660 } else 660 } else
661 fchown(fd, 0, 0); 661 fchown(fd, 0, 0);
662 return fd; 662 return fd;
663} 663}
664 664
665 665
666 666
667void alarm_handler(int) { 667void alarm_handler(int) {
668 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); 668 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n");
669 669
670 // jump 670 // jump
671 siglongjmp(jmp_buffer, 1); 671 siglongjmp(jmp_buffer, 1);
672} 672}
673 673
674 674
675const char* Modem::authFile(Auth method, int version) { 675const char* Modem::authFile(Auth method, int version) {
676 switch(method|version) { 676 switch(method|version) {
677 case PAP|Original: 677 case PAP|Original:
678 return PAP_AUTH_FILE; 678 return PAP_AUTH_FILE;
679 break; 679 break;
680 case PAP|New: 680 case PAP|New:
681 return PAP_AUTH_FILE".new"; 681 return PAP_AUTH_FILE".new";
682 break; 682 break;
683 case PAP|Old: 683 case PAP|Old:
684 return PAP_AUTH_FILE".old"; 684 return PAP_AUTH_FILE".old";
685 break; 685 break;
686 case CHAP|Original: 686 case CHAP|Original:
687 return CHAP_AUTH_FILE; 687 return CHAP_AUTH_FILE;
688 break; 688 break;
689 case CHAP|New: 689 case CHAP|New:
690 return CHAP_AUTH_FILE".new"; 690 return CHAP_AUTH_FILE".new";
691 break; 691 break;
692 case CHAP|Old: 692 case CHAP|Old:
693 return CHAP_AUTH_FILE".old"; 693 return CHAP_AUTH_FILE".old";
694 break; 694 break;
695 default: 695 default:
696 return 0L; 696 return 0L;
697 } 697 }
698} 698}
699 699
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
index 766ba0f..65032e8 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.cpp
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -1,145 +1,142 @@
1/* 1/*
2 * kPPP: A front end for pppd for the KDE project 2 * kPPP: A front end for pppd for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This library is free software; you can redistribute it and/or 12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This library is distributed in the hope that it will be useful, 17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with dummyWidget program; if not, write to the Free 23 * License along with dummyWidget program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qslider.h> 28#include <qslider.h>
29#include <qbuttongroup.h> 29#include <qbuttongroup.h>
30#include <stdlib.h> 30#include <stdlib.h>
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(QWidget *parent, const char *name)
44 : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel) 44 : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel)
45{ 45{
46 setCaption(i18n("Edit Modem Commands")); 46 setCaption(i18n("Edit Modem Commands"));
47// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
48 QWidget *dummyWidget = new QWidget(this);
49// setMainWidget(dummyWidget);
50 47
51 const int GRIDROWS = 22; 48 const int GRIDROWS = 22;
52 int row = 0; 49 int row = 0;
53 50
54 // toplevel layout 51 // toplevel layout
55 QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); 52 QVBoxLayout *tl = new QVBoxLayout(this, 10, 4);
56 53
57 // add grid + frame 54 // add grid + frame
58 QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); 55 QGridLayout *l1 = new QGridLayout(GRIDROWS, 4);
59 tl->addLayout(l1); 56 tl->addLayout(l1);
60 box = new QGroupBox(this, "box"); 57 box = new QGroupBox(this, "box");
61 l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); 58 l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3);
62 59
63 // put slider and label into a separate H-Box 60 // put slider and label into a separate H-Box
64 QHBoxLayout *l2 = new QHBoxLayout; 61 QHBoxLayout *l2 = new QHBoxLayout;
65 l1->addLayout(l2, row, 2); 62 l1->addLayout(l2, row, 2);
66 lpreinitslider = new QLabel("MMMM", this); 63 lpreinitslider = new QLabel("MMMM", this);
67 FORMATSLIDERLABEL(lpreinitslider); 64 FORMATSLIDERLABEL(lpreinitslider);
68 65
69 QSlider *preinitslider = new QSlider(0, 300, 1, 0, 66 QSlider *preinitslider = new QSlider(0, 300, 1, 0,
70 QSlider::Horizontal, this); 67 QSlider::Horizontal, this);
71// preinitslider->setFixedHeight(preinitslider->sizeHint().height()); 68// preinitslider->setFixedHeight(preinitslider->sizeHint().height());
72 connect(preinitslider, SIGNAL(valueChanged(int)), 69 connect(preinitslider, SIGNAL(valueChanged(int)),
73 lpreinitslider, SLOT(setNum(int))); 70 lpreinitslider, SLOT(setNum(int)));
74 l2->addWidget(lpreinitslider, 0); 71 l2->addWidget(lpreinitslider, 0);
75 l2->addWidget(preinitslider, 1); 72 l2->addWidget(preinitslider, 1);
76 73
77 lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); 74 lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this);
78 l1->addWidget(lpreinit, row++, 1); 75 l1->addWidget(lpreinit, row++, 1);
79 76
80 for(int i = 0; i < PPPData::NumInitStrings; i++) { 77 for(int i = 0; i < PPPData::NumInitStrings; i++) {
81 initstr[i] = new QLineEdit(this); 78 initstr[i] = new QLineEdit(this);
82 QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), 79 QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1),
83 this); 80 this);
84 ADJUSTEDIT(initstr[i]); 81 ADJUSTEDIT(initstr[i]);
85 l1->addWidget(initLabel, row, 1); 82 l1->addWidget(initLabel, row, 1);
86 l1->addWidget(initstr[i], row++, 2); 83 l1->addWidget(initstr[i], row++, 2);
87 } 84 }
88 85
89 QHBoxLayout *l3 = new QHBoxLayout; 86 QHBoxLayout *l3 = new QHBoxLayout;
90 l1->addLayout(l3, row, 2); 87 l1->addLayout(l3, row, 2);
91 linitslider = new QLabel("MMMM", this); 88 linitslider = new QLabel("MMMM", this);
92 FORMATSLIDERLABEL(linitslider); 89 FORMATSLIDERLABEL(linitslider);
93 QSlider *initslider = new QSlider(1, 300, 1, 0, 90 QSlider *initslider = new QSlider(1, 300, 1, 0,
94 QSlider::Horizontal, this); 91 QSlider::Horizontal, this);
95// initslider->setFixedHeight(initslider->sizeHint().height()); 92// initslider->setFixedHeight(initslider->sizeHint().height());
96 connect(initslider, SIGNAL(valueChanged(int)), 93 connect(initslider, SIGNAL(valueChanged(int)),
97 linitslider, SLOT(setNum(int))); 94 linitslider, SLOT(setNum(int)));
98 l3->addWidget(linitslider, 0); 95 l3->addWidget(linitslider, 0);
99 l3->addWidget(initslider, 1); 96 l3->addWidget(initslider, 1);
100 97
101 label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); 98 label3 = new QLabel(i18n("Post-init delay (sec/100):"), this);
102 l1->addWidget(label3, row++, 1); 99 l1->addWidget(label3, row++, 1);
103 100
104 /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ 101 /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */
105 QHBoxLayout *l4 = new QHBoxLayout; 102 QHBoxLayout *l4 = new QHBoxLayout;
106 l1->addLayout(l4, row, 2); 103 l1->addLayout(l4, row, 2);
107 ldurationslider = new QLabel("MMMM", this); 104 ldurationslider = new QLabel("MMMM", this);
108 FORMATSLIDERLABEL(ldurationslider); 105 FORMATSLIDERLABEL(ldurationslider);
109 QSlider *durationslider = new QSlider(1, 255, 1, 0, 106 QSlider *durationslider = new QSlider(1, 255, 1, 0,
110 QSlider::Horizontal, this); 107 QSlider::Horizontal, this);
111// durationslider->setFixedHeight(durationslider->sizeHint().height()); 108// durationslider->setFixedHeight(durationslider->sizeHint().height());
112 connect(durationslider, SIGNAL(valueChanged(int)), 109 connect(durationslider, SIGNAL(valueChanged(int)),
113 ldurationslider, SLOT(setNum(int))); 110 ldurationslider, SLOT(setNum(int)));
114 l4->addWidget(ldurationslider, 0); 111 l4->addWidget(ldurationslider, 0);
115 l4->addWidget(durationslider, 1); 112 l4->addWidget(durationslider, 1);
116 113
117 lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); 114 lduration = new QLabel(i18n("Dialing speed (sec/100):"), this);
118 l1->addWidget(lduration, row++, 1); 115 l1->addWidget(lduration, row++, 1);
119 116
120 117
121 initresp = new QLineEdit(this); 118 initresp = new QLineEdit(this);
122 label2 = new QLabel(i18n("Init response:"), this); 119 label2 = new QLabel(i18n("Init response:"), this);
123 ADJUSTEDIT(initresp); 120 ADJUSTEDIT(initresp);
124 l1->addWidget(label2, row, 1); 121 l1->addWidget(label2, row, 1);
125 l1->addWidget(initresp, row++, 2); 122 l1->addWidget(initresp, row++, 2);
126 123
127 nodetectdialtone = new QLineEdit(this); 124 nodetectdialtone = new QLineEdit(this);
128 lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); 125 lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this);
129 ADJUSTEDIT(nodetectdialtone); 126 ADJUSTEDIT(nodetectdialtone);
130 l1->addWidget(lnodetectdialtone, row, 1); 127 l1->addWidget(lnodetectdialtone, row, 1);
131 l1->addWidget(nodetectdialtone, row++, 2); 128 l1->addWidget(nodetectdialtone, row++, 2);
132 129
133 dialstr = new QLineEdit(this); 130 dialstr = new QLineEdit(this);
134 label4 = new QLabel(i18n("Dial string:"),this); 131 label4 = new QLabel(i18n("Dial string:"),this);
135 ADJUSTEDIT(dialstr); 132 ADJUSTEDIT(dialstr);
136 l1->addWidget(label4, row, 1); 133 l1->addWidget(label4, row, 1);
137 l1->addWidget(dialstr, row++, 2); 134 l1->addWidget(dialstr, row++, 2);
138 135
139 connectresp = new QLineEdit(this); 136 connectresp = new QLineEdit(this);
140 label5 = new QLabel(i18n("Connect response:"), this); 137 label5 = new QLabel(i18n("Connect response:"), this);
141 ADJUSTEDIT(connectresp); 138 ADJUSTEDIT(connectresp);
142 l1->addWidget(label5, row, 1); 139 l1->addWidget(label5, row, 1);
143 l1->addWidget(connectresp, row++, 2); 140 l1->addWidget(connectresp, row++, 2);
144 141
145 busyresp = new QLineEdit(this); 142 busyresp = new QLineEdit(this);
@@ -150,172 +147,172 @@ ModemCommands::ModemCommands(QWidget *parent, const char *name)
150 147
151 nocarrierresp = new QLineEdit(this); 148 nocarrierresp = new QLineEdit(this);
152 label7 = new QLabel(i18n("No carrier response:"), this); 149 label7 = new QLabel(i18n("No carrier response:"), this);
153 ADJUSTEDIT(nocarrierresp); 150 ADJUSTEDIT(nocarrierresp);
154 l1->addWidget(label7, row, 1); 151 l1->addWidget(label7, row, 1);
155 l1->addWidget(nocarrierresp, row++, 2); 152 l1->addWidget(nocarrierresp, row++, 2);
156 153
157 nodialtoneresp = new QLineEdit(this); 154 nodialtoneresp = new QLineEdit(this);
158 label8 = new QLabel(i18n("No dial tone response:"), this); 155 label8 = new QLabel(i18n("No dial tone response:"), this);
159 ADJUSTEDIT(nodialtoneresp); 156 ADJUSTEDIT(nodialtoneresp);
160 l1->addWidget(label8, row, 1); 157 l1->addWidget(label8, row, 1);
161 l1->addWidget(nodialtoneresp, row++, 2); 158 l1->addWidget(nodialtoneresp, row++, 2);
162 159
163 hangupstr = new QLineEdit(this); 160 hangupstr = new QLineEdit(this);
164 label9 = new QLabel(i18n("Hangup string:"), this); 161 label9 = new QLabel(i18n("Hangup string:"), this);
165 ADJUSTEDIT(hangupstr); 162 ADJUSTEDIT(hangupstr);
166 l1->addWidget(label9, row, 1); 163 l1->addWidget(label9, row, 1);
167 l1->addWidget(hangupstr, row++, 2); 164 l1->addWidget(hangupstr, row++, 2);
168 165
169 hangupresp = new QLineEdit(this); 166 hangupresp = new QLineEdit(this);
170 label10 = new QLabel(i18n("Hangup response:"), this); 167 label10 = new QLabel(i18n("Hangup response:"), this);
171 ADJUSTEDIT(hangupresp); 168 ADJUSTEDIT(hangupresp);
172 l1->addWidget(label10, row, 1); 169 l1->addWidget(label10, row, 1);
173 l1->addWidget(hangupresp, row++, 2); 170 l1->addWidget(hangupresp, row++, 2);
174 171
175 answerstr = new QLineEdit(this); 172 answerstr = new QLineEdit(this);
176 label11 = new QLabel(i18n("Answer string:"), this); 173 label11 = new QLabel(i18n("Answer string:"), this);
177 ADJUSTEDIT(answerstr); 174 ADJUSTEDIT(answerstr);
178 l1->addWidget(label11, row, 1); 175 l1->addWidget(label11, row, 1);
179 l1->addWidget(answerstr, row++, 2); 176 l1->addWidget(answerstr, row++, 2);
180 177
181 ringresp = new QLineEdit(this); 178 ringresp = new QLineEdit(this);
182 label12 = new QLabel(i18n("Ring response:"), this); 179 label12 = new QLabel(i18n("Ring response:"), this);
183 ADJUSTEDIT(ringresp); 180 ADJUSTEDIT(ringresp);
184 l1->addWidget(label12, row, 1); 181 l1->addWidget(label12, row, 1);
185 l1->addWidget(ringresp, row++, 2); 182 l1->addWidget(ringresp, row++, 2);
186 183
187 answerresp = new QLineEdit(this); 184 answerresp = new QLineEdit(this);
188 label13 = new QLabel(i18n("Answer response:"), this); 185 label13 = new QLabel(i18n("Answer response:"), this);
189 ADJUSTEDIT(answerresp); 186 ADJUSTEDIT(answerresp);
190 l1->addWidget(label13, row, 1); 187 l1->addWidget(label13, row, 1);
191 l1->addWidget(answerresp, row++, 2); 188 l1->addWidget(answerresp, row++, 2);
192 189
193 escapestr = new QLineEdit(this); 190 escapestr = new QLineEdit(this);
194 label14 = new QLabel(i18n("Escape string:"), this); 191 label14 = new QLabel(i18n("Escape string:"), this);
195 ADJUSTEDIT(escapestr); 192 ADJUSTEDIT(escapestr);
196 l1->addWidget(label14, row, 1); 193 l1->addWidget(label14, row, 1);
197 l1->addWidget(escapestr, row++, 2); 194 l1->addWidget(escapestr, row++, 2);
198 195
199 escaperesp = new QLineEdit(this); 196 escaperesp = new QLineEdit(this);
200 label15 = new QLabel(i18n("Escape response:"), this); 197 label15 = new QLabel(i18n("Escape response:"), this);
201 ADJUSTEDIT(escaperesp); 198 ADJUSTEDIT(escaperesp);
202 l1->addWidget(label15, row, 1); 199 l1->addWidget(label15, row, 1);
203 l1->addWidget(escaperesp, row++, 2); 200 l1->addWidget(escaperesp, row++, 2);
204 201
205 QHBoxLayout *l5 = new QHBoxLayout; 202 QHBoxLayout *l5 = new QHBoxLayout;
206 l1->addLayout(l5, row, 2); 203 l1->addLayout(l5, row, 2);
207 lslider = new QLabel("MMMM", this); 204 lslider = new QLabel("MMMM", this);
208 FORMATSLIDERLABEL(lslider); 205 FORMATSLIDERLABEL(lslider);
209 206
210 QSlider *slider = new QSlider(0, 255, 1, 0, 207 QSlider *slider = new QSlider(0, 255, 1, 0,
211 QSlider::Horizontal, this); 208 QSlider::Horizontal, this);
212// slider->setFixedHeight(slider->sizeHint().height()); 209// slider->setFixedHeight(slider->sizeHint().height());
213 connect(slider, SIGNAL(valueChanged(int)), 210 connect(slider, SIGNAL(valueChanged(int)),
214 lslider, SLOT(setNum(int))); 211 lslider, SLOT(setNum(int)));
215 l5->addWidget(lslider, 0); 212 l5->addWidget(lslider, 0);
216 l5->addWidget(slider, 1); 213 l5->addWidget(slider, 1);
217 214
218 label16 = new QLabel(i18n("Guard time (sec/50):"), this); 215 label16 = new QLabel(i18n("Guard time (sec/50):"), this);
219 l1->addWidget(label16, row++, 1); 216 l1->addWidget(label16, row++, 1);
220 217
221 QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); 218 QLabel *l = new QLabel(i18n("Volume off/low/high:"), this);
222 l1->addWidget(l, row, 1); 219 l1->addWidget(l, row, 1);
223 QHBoxLayout *l6 = new QHBoxLayout; 220 QHBoxLayout *l6 = new QHBoxLayout;
224 l1->addLayout(l6, row++, 2); 221 l1->addLayout(l6, row++, 2);
225 volume_off = new QLineEdit(this); 222 volume_off = new QLineEdit(this);
226// volume_off->setFixedHeight(volume_off->sizeHint().height()); 223// volume_off->setFixedHeight(volume_off->sizeHint().height());
227 // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); 224 // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2));
228 volume_medium = new QLineEdit(this); 225 volume_medium = new QLineEdit(this);
229// volume_medium->setFixedHeight(volume_medium->sizeHint().height()); 226// volume_medium->setFixedHeight(volume_medium->sizeHint().height());
230 // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); 227 // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2));
231 volume_high = new QLineEdit(this); 228 volume_high = new QLineEdit(this);
232 // volume_high->setFixedHeight(volume_high->sizeHint().height()); 229 // volume_high->setFixedHeight(volume_high->sizeHint().height());
233 // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); 230 // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2));
234 l6->addWidget(volume_off); 231 l6->addWidget(volume_off);
235 l6->addWidget(volume_medium); 232 l6->addWidget(volume_medium);
236 l6->addWidget(volume_high); 233 l6->addWidget(volume_high);
237 234
238 initstr[0]->setFocus(); 235 initstr[0]->setFocus();
239 236
240 l1->addColSpacing(0, 10); 237 l1->addColSpacing(0, 10);
241 l1->addColSpacing(3, 10); 238 l1->addColSpacing(3, 10);
242 l1->addRowSpacing(0, 5); 239 l1->addRowSpacing(0, 5);
243 l1->addRowSpacing(GRIDROWS, 5); 240 l1->addRowSpacing(GRIDROWS, 5);
244 241
245 //set stuff from gpppdata 242 //set stuff from gpppdata
246 preinitslider->setValue(gpppdata.modemPreInitDelay()); 243 preinitslider->setValue(PPPData::data()->modemPreInitDelay());
247 lpreinitslider->setNum(gpppdata.modemPreInitDelay()); 244 lpreinitslider->setNum(PPPData::data()->modemPreInitDelay());
248 for(int i = 0; i < PPPData::NumInitStrings; i++) 245 for(int i = 0; i < PPPData::NumInitStrings; i++)
249 initstr[i]->setText(gpppdata.modemInitStr(i)); 246 initstr[i]->setText(PPPData::data()->modemInitStr(i));
250 initslider->setValue(gpppdata.modemInitDelay()); 247 initslider->setValue(PPPData::data()->modemInitDelay());
251 linitslider->setNum(gpppdata.modemInitDelay()); 248 linitslider->setNum(PPPData::data()->modemInitDelay());
252 initresp->setText(gpppdata.modemInitResp()); 249 initresp->setText(PPPData::data()->modemInitResp());
253 250
254 durationslider->setValue(gpppdata.modemToneDuration()); 251 durationslider->setValue(PPPData::data()->modemToneDuration());
255 ldurationslider->setNum(gpppdata.modemToneDuration()); 252 ldurationslider->setNum(PPPData::data()->modemToneDuration());
256 253
257 nodetectdialtone->setText(gpppdata.modemNoDialToneDetectionStr()); 254 nodetectdialtone->setText(PPPData::data()->modemNoDialToneDetectionStr());
258 dialstr->setText(gpppdata.modemDialStr()); 255 dialstr->setText(PPPData::data()->modemDialStr());
259 connectresp->setText(gpppdata.modemConnectResp()); 256 connectresp->setText(PPPData::data()->modemConnectResp());
260 busyresp->setText(gpppdata.modemBusyResp()); 257 busyresp->setText(PPPData::data()->modemBusyResp());
261 nocarrierresp->setText(gpppdata.modemNoCarrierResp()); 258 nocarrierresp->setText(PPPData::data()->modemNoCarrierResp());
262 nodialtoneresp->setText(gpppdata.modemNoDialtoneResp()); 259 nodialtoneresp->setText(PPPData::data()->modemNoDialtoneResp());
263 260
264 escapestr->setText(gpppdata.modemEscapeStr()); 261 escapestr->setText(PPPData::data()->modemEscapeStr());
265 escaperesp->setText(gpppdata.modemEscapeResp()); 262 escaperesp->setText(PPPData::data()->modemEscapeResp());
266 263
267 hangupstr->setText(gpppdata.modemHangupStr()); 264 hangupstr->setText(PPPData::data()->modemHangupStr());
268 hangupresp->setText(gpppdata.modemHangupResp()); 265 hangupresp->setText(PPPData::data()->modemHangupResp());
269 266
270 answerstr->setText(gpppdata.modemAnswerStr()); 267 answerstr->setText(PPPData::data()->modemAnswerStr());
271 ringresp->setText(gpppdata.modemRingResp()); 268 ringresp->setText(PPPData::data()->modemRingResp());
272 answerresp->setText(gpppdata.modemAnswerResp()); 269 answerresp->setText(PPPData::data()->modemAnswerResp());
273 270
274 slider->setValue(gpppdata.modemEscapeGuardTime()); 271 slider->setValue(PPPData::data()->modemEscapeGuardTime());
275 lslider->setNum(gpppdata.modemEscapeGuardTime()); 272 lslider->setNum(PPPData::data()->modemEscapeGuardTime());
276 273
277 volume_off->setText(gpppdata.volumeOff()); 274 volume_off->setText(PPPData::data()->volumeOff());
278 volume_medium->setText(gpppdata.volumeMedium()); 275 volume_medium->setText(PPPData::data()->volumeMedium());
279 volume_high->setText(gpppdata.volumeHigh()); 276 volume_high->setText(PPPData::data()->volumeHigh());
280} 277}
281 278
282 279
283void ModemCommands::slotOk() { 280void ModemCommands::slotOk() {
284 gpppdata.setModemPreInitDelay(lpreinitslider->text().toInt()); 281 PPPData::data()->setModemPreInitDelay(lpreinitslider->text().toInt());
285 for(int i = 0; i < PPPData::NumInitStrings; i++) 282 for(int i = 0; i < PPPData::NumInitStrings; i++)
286 gpppdata.setModemInitStr(i, initstr[i]->text()); 283 PPPData::data()->setModemInitStr(i, initstr[i]->text());
287 gpppdata.setModemInitResp(initresp->text()); 284 PPPData::data()->setModemInitResp(initresp->text());
288 gpppdata.setModemInitDelay(linitslider->text().toInt()); 285 PPPData::data()->setModemInitDelay(linitslider->text().toInt());
289 286
290 gpppdata.setModemToneDuration(ldurationslider->text().toInt()); 287 PPPData::data()->setModemToneDuration(ldurationslider->text().toInt());
291 gpppdata.setModemNoDialToneDetectionStr(nodetectdialtone->text()); 288 PPPData::data()->setModemNoDialToneDetectionStr(nodetectdialtone->text());
292 gpppdata.setModemDialStr(dialstr->text()); 289 PPPData::data()->setModemDialStr(dialstr->text());
293 gpppdata.setModemConnectResp(connectresp->text()); 290 PPPData::data()->setModemConnectResp(connectresp->text());
294 gpppdata.setModemBusyResp(busyresp->text()); 291 PPPData::data()->setModemBusyResp(busyresp->text());
295 gpppdata.setModemNoCarrierResp(nocarrierresp->text()); 292 PPPData::data()->setModemNoCarrierResp(nocarrierresp->text());
296 gpppdata.setModemNoDialtoneResp(nodialtoneresp->text()); 293 PPPData::data()->setModemNoDialtoneResp(nodialtoneresp->text());
297 294
298 gpppdata.setModemEscapeStr(escapestr->text()); 295 PPPData::data()->setModemEscapeStr(escapestr->text());
299 gpppdata.setModemEscapeResp(escaperesp->text()); 296 PPPData::data()->setModemEscapeResp(escaperesp->text());
300 gpppdata.setModemEscapeGuardTime(lslider->text().toInt()); 297 PPPData::data()->setModemEscapeGuardTime(lslider->text().toInt());
301 gpppdata.setModemHangupStr(hangupstr->text()); 298 PPPData::data()->setModemHangupStr(hangupstr->text());
302 gpppdata.setModemHangupResp(hangupresp->text()); 299 PPPData::data()->setModemHangupResp(hangupresp->text());
303 300
304 gpppdata.setModemAnswerStr(answerstr->text()); 301 PPPData::data()->setModemAnswerStr(answerstr->text());
305 gpppdata.setModemRingResp(ringresp->text()); 302 PPPData::data()->setModemRingResp(ringresp->text());
306 gpppdata.setModemAnswerResp(answerresp->text()); 303 PPPData::data()->setModemAnswerResp(answerresp->text());
307 304
308 gpppdata.setVolumeHigh(volume_high->text()); 305 PPPData::data()->setVolumeHigh(volume_high->text());
309 gpppdata.setVolumeMedium(volume_medium->text()); 306 PPPData::data()->setVolumeMedium(volume_medium->text());
310 gpppdata.setVolumeOff(volume_off->text()); 307 PPPData::data()->setVolumeOff(volume_off->text());
311 308
312 gpppdata.save(); 309 PPPData::data()->save();
313 accept(); 310 accept();
314} 311}
315 312
316 313
317void ModemCommands::slotCancel() { 314void ModemCommands::slotCancel() {
318 reject(); 315 reject();
319} 316}
320 317
321//#include "modemcmds.moc" 318//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/newwidget.cpp b/noncore/settings/networksettings/ppp/newwidget.cpp
deleted file mode 100644
index d2182fb..0000000
--- a/noncore/settings/networksettings/ppp/newwidget.cpp
+++ b/dev/null
@@ -1,17 +0,0 @@
1/////////////////////////////////////////////////////////////////////////////
2//
3// functions generating layout-aware widgets
4//
5/////////////////////////////////////////////////////////////////////////////
6
7#include "newwidget.h"
8
9QLineEdit *newLineEdit(int visiblewidth, QWidget *parent) {
10 QLineEdit *l = new QLineEdit(parent);
11 if(visiblewidth == 0)
12 l->setMinimumWidth(l->sizeHint().width());
13 else
14 l->setFixedWidth(l->fontMetrics().width('H') * visiblewidth);
15
16 return l;
17}
diff --git a/noncore/settings/networksettings/ppp/newwidget.h b/noncore/settings/networksettings/ppp/newwidget.h
deleted file mode 100644
index 52f2ec7..0000000
--- a/noncore/settings/networksettings/ppp/newwidget.h
+++ b/dev/null
@@ -1,19 +0,0 @@
1/////////////////////////////////////////////////////////////////////////////
2//
3// functions generating layout-aware widgets
4//
5/////////////////////////////////////////////////////////////////////////////
6
7#ifndef __NEWWIDGET__H__
8#define __NEWWIDGET__H__
9
10#include <qwidget.h>
11#include <qlineedit.h>
12
13#define L_FIXEDW 1
14#define L_FIXEDH 2
15#define L_FIXED (L_FIXEDW | L_FIXEDH)
16
17QLineEdit *newLineEdit(int visiblewidth, QWidget *parent);
18
19#endif
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index a456427..ebfc713 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,18 +1,18 @@
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 knuminput.h knumvalidator.h kpppwidget.h conwindow.h debug.h accounts.h connect.h edit.h scriptedit.h pppdargs.h newwidget.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 knuminput.h knumvalidator.h kpppwidget.h conwindow.h debug.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
8 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp debug.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp newwidget.cpp iplined.cpp pwentry.cpp pppconfig.cpp 8 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp debug.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp
9 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 9 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
10 DEPENDPATH+= $(OPIEDIR)/include 10 DEPENDPATH+= $(OPIEDIR)/include
11LIBS += -lqpe -L../interfaces/ -linterfaces 11LIBS += -lqpe -L../interfaces/ -linterfaces
12 INTERFACES= 12 INTERFACES=
13 TARGET = pppplugin 13 TARGET = pppplugin
14 VERSION = 1.0.0 14 VERSION = 1.0.0
15 15
16 16
17 17
18include ( $(OPIEDIR)/include.pro ) 18include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index 7b2b21b..c0f1fef 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,62 +1,62 @@
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 "pppconfig.h" 8#include "pppconfig.h"
9#include "pppdata.h" 9#include "pppdata.h"
10#include "runtests.h" 10#include "runtests.h"
11#include "modem.h" 11#include "modem.h"
12 12
13PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name, 13PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name,
14 bool modal, WFlags fl ) 14 bool modal, WFlags fl )
15 : QDialog(parent, name, modal, fl) 15 : QDialog(parent, name, modal, fl)
16{ 16{
17 setCaption(tr("Configure Modem")); 17 setCaption(tr("Configure Modem"));
18 int result = runTests(); 18 int result = runTests();
19 if(result == TEST_CRITICAL){ 19 if(result == TEST_CRITICAL){
20 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); 20 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
21 return; 21 return;
22 } 22 }
23 23
24// setFixedSize(sizeHint()); 24// setFixedSize(sizeHint());
25 25
26 (void)new Modem; 26 (void)new Modem;
27 27
28 QVBoxLayout *layout = new QVBoxLayout( this ); 28 QVBoxLayout *layout = new QVBoxLayout( this );
29 layout->setSpacing( 0 ); 29 layout->setSpacing( 0 );
30 layout->setMargin( 1 ); 30 layout->setMargin( 1 );
31 tabWindow = new QTabWidget( this, "tabWidget" ); 31 tabWindow = new QTabWidget( this, "tabWidget" );
32 layout->addWidget( tabWindow ); 32 layout->addWidget( tabWindow );
33 33
34 accounts = new AccountWidget( tabWindow, "accounts" ); 34 accounts = new AccountWidget( tabWindow, "accounts" );
35 tabWindow->addTab( accounts, tr("&Accounts") ); 35 tabWindow->addTab( accounts, tr("&Accounts") );
36 modem1 = new ModemWidget( tabWindow, "modem1" ); 36 modem1 = new ModemWidget( tabWindow, "modem1" );
37 tabWindow->addTab( modem1, tr("&Device") ); 37 tabWindow->addTab( modem1, tr("&Device") );
38 modem2 = new ModemWidget2( tabWindow, "modem2" ); 38 modem2 = new ModemWidget2( tabWindow, "modem2" );
39 tabWindow->addTab( modem2, tr("&Modem") ); 39 tabWindow->addTab( modem2, tr("&Modem") );
40// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); 40// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
41// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); 41// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
42 42
43} 43}
44 44
45 45
46PPPConfigWidget::~PPPConfigWidget() 46PPPConfigWidget::~PPPConfigWidget()
47{ 47{
48 48
49} 49}
50 50
51void PPPConfigWidget::accept() 51void PPPConfigWidget::accept()
52{ 52{
53 gpppdata.save(); 53 PPPData::data()->save();
54 QDialog::accept(); 54 QDialog::accept();
55} 55}
56 56
57 57
58void PPPConfigWidget::reject() 58void PPPConfigWidget::reject()
59{ 59{
60 gpppdata.cancel(); 60 PPPData::data()->cancel();
61 QDialog::reject(); 61 QDialog::reject();
62} 62}
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 04d0dd0..b7fca3f 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -28,139 +28,139 @@
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(QWidget *parent, const char *name)
38 : QDialog(parent, name, TRUE) 38 : QDialog(parent, name, TRUE)
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);
51 l1->addLayout(l11); 51 l1->addLayout(l11);
52 52
53 argument_label = new QLabel(i18n("Argument:"), this); 53 argument_label = new QLabel(i18n("Argument:"), this);
54 l11->addWidget(argument_label); 54 l11->addWidget(argument_label);
55 55
56 argument = new QLineEdit(this); 56 argument = new QLineEdit(this);
57 connect(argument, SIGNAL(returnPressed()), 57 connect(argument, SIGNAL(returnPressed()),
58 SLOT(addbutton())); 58 SLOT(addbutton()));
59 l11->addWidget(argument); 59 l11->addWidget(argument);
60 connect(argument, SIGNAL(textChanged(const QString &)), 60 connect(argument, SIGNAL(textChanged(const QString &)),
61 this, SLOT(textChanged(const QString &))); 61 this, SLOT(textChanged(const QString &)));
62 62
63 arguments = new QListBox(this); 63 arguments = new QListBox(this);
64 arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); 64 arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10);
65 connect(arguments, SIGNAL(highlighted(int)), 65 connect(arguments, SIGNAL(highlighted(int)),
66 this, SLOT(itemSelected(int))); 66 this, SLOT(itemSelected(int)));
67 l1->addWidget(arguments, 1); 67 l1->addWidget(arguments, 1);
68 68
69 add = new QPushButton(i18n("Add"), this); 69 add = new QPushButton(i18n("Add"), this);
70 connect(add, SIGNAL(clicked()), SLOT(addbutton())); 70 connect(add, SIGNAL(clicked()), SLOT(addbutton()));
71 l2->addWidget(add); 71 l2->addWidget(add);
72 l2->addStretch(1); 72 l2->addStretch(1);
73 73
74 remove = new QPushButton(i18n("Remove"), this); 74 remove = new QPushButton(i18n("Remove"), this);
75 connect(remove, SIGNAL(clicked()), SLOT(removebutton())); 75 connect(remove, SIGNAL(clicked()), SLOT(removebutton()));
76 l2->addWidget(remove); 76 l2->addWidget(remove);
77 77
78 defaults = new QPushButton(i18n("Defaults"), this); 78 defaults = new QPushButton(i18n("Defaults"), this);
79 connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); 79 connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton()));
80 l2->addWidget(defaults); 80 l2->addWidget(defaults);
81 81
82 l->addSpacing(5); 82 l->addSpacing(5);
83 83
84 QButtonGroup *bbox = new QButtonGroup(this); 84 QButtonGroup *bbox = new QButtonGroup(this);
85// bbox->addStretch(1); 85// bbox->addStretch(1);
86 closebtn = new QPushButton( bbox, i18n("OK")); 86 closebtn = new QPushButton( bbox, i18n("OK"));
87 bbox->insert(closebtn); 87 bbox->insert(closebtn);
88 connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); 88 connect(closebtn, SIGNAL(clicked()), SLOT(closebutton()));
89 QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); 89 QPushButton *cancel = new QPushButton( bbox, i18n("Cancel"));
90 bbox->insert(cancel); 90 bbox->insert(cancel);
91 connect(cancel, SIGNAL(clicked()), 91 connect(cancel, SIGNAL(clicked()),
92 this, SLOT(reject())); 92 this, SLOT(reject()));
93 bbox->layout(); 93 bbox->layout();
94 l->addWidget(bbox); 94 l->addWidget(bbox);
95 95
96 setFixedSize(sizeHint()); 96 setFixedSize(sizeHint());
97 97
98 //load info from gpppdata 98 //load info from gpppdata
99 init(); 99 init();
100 100
101 add->setEnabled(false); 101 add->setEnabled(false);
102 remove->setEnabled(false); 102 remove->setEnabled(false);
103 argument->setFocus(); 103 argument->setFocus();
104} 104}
105 105
106 106
107void PPPdArguments::addbutton() { 107void PPPdArguments::addbutton() {
108 if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { 108 if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) {
109 arguments->insertItem(argument->text()); 109 arguments->insertItem(argument->text());
110 argument->setText(""); 110 argument->setText("");
111 } 111 }
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(gpppdata.pppdArgument()); 124 QStringList arglist(PPPData::data()->pppdArgument());
125 125
126 // get defaults 126 // get defaults
127 gpppdata.setpppdArgumentDefaults(); 127 PPPData::data()->setpppdArgumentDefaults();
128 init(); 128 init();
129 129
130 // restore old list 130 // restore old list
131 gpppdata.setpppdArgument(arglist); 131 PPPData::data()->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 gpppdata.setpppdArgument(arglist); 139 PPPData::data()->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 = gpppdata.pppdArgument(); 149 QStringList &arglist = PPPData::data()->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
162void PPPdArguments::itemSelected(int idx) { 162void PPPdArguments::itemSelected(int idx) {
163 remove->setEnabled(idx != -1); 163 remove->setEnabled(idx != -1);
164} 164}
165 165
166 166
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index f2386fc..646facd 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,232 +1,236 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "pppdata.h" 27#include "pppdata.h"
28#include "runtests.h" 28#include "runtests.h"
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 gpppdata; 41PPPData *PPPData::_data = 0;
42Config *PPPData::config = 0;
42 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}
43 56
44PPPData::PPPData() 57PPPData::PPPData()
45 : config(0L), 58 : //config(0L),
46 highcount(-1), // start out with no entries 59 highcount(-1), // start out with no entries
47 caccount(-1), // set the current account index also 60 caccount(-1), // set the current account index also
48 suidprocessid(-1), // process ID of setuid child 61 suidprocessid(-1), // process ID of setuid child
49 pppdisrunning(false), 62 pppdisrunning(false),
50 pppderror(0) 63 pppderror(0)
51{ 64{
52} 65}
53 66
54 67
55// 68//
56// open configuration file 69// open configuration file
57// 70//
58bool PPPData::open() { 71bool PPPData::open() {
59 72 qDebug("opening configfile NetworkSetupPPP");
60 config = new Config("NetworkSetup"); 73 if (config) return true;
61 /* 74 config = new Config("NetworkSetupPPP");
62 config = kapp->config();
63
64 if (config->getConfigState() == KConfig::NoAccess) {
65 KMessageBox::error(0L,
66 i18n("The application-specific config file could not "
67 "be opened in either read-write or read-only mode.\n"
68 "The superuser might have to change its ownership "
69 "by issuing the following command in your home directory:\n"
70 "chown {YourUsername} .kde/share/config/kppprc"),
71 kapp->name());
72 return false;
73 }
74
75 // don't expand shell variables
76 config->setDollarExpansion(false);
77 */
78 75
79 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 76 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
80 77
81 if (highcount > MAX_ACCOUNTS) 78 if (highcount > MAX_ACCOUNTS)
82 highcount = MAX_ACCOUNTS; 79 highcount = MAX_ACCOUNTS;
83 80
84 if(highcount >= 0 && defaultAccount().isEmpty()) { 81 if(highcount >= 0 && defaultAccount().isEmpty()) {
85 setAccountbyIndex(0); 82 setAccountbyIndex(0);
86 setDefaultAccount(accname()); 83 setDefaultAccount(accname());
87 } else if(!setAccount(defaultAccount())) 84 } else if(!setAccount(defaultAccount()))
88 setDefaultAccount(accname()); 85 setDefaultAccount(accname());
89 86
90 // start out with internal debugging disabled 87 // start out with internal debugging disabled
91 // the user is still free to specify `debug' on his own 88 // the user is still free to specify `debug' on his own
92 setPPPDebug(false); 89 setPPPDebug(false);
93 90
94 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); 91 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
95 92
96 return true; 93 return true;
97} 94}
98 95
99 96
100// 97//
101// save configuration 98// save configuration
102// 99//
103void PPPData::save() { 100void PPPData::save() {
104 101
105 if (config) { 102 if (config) {
106 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); 103 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
107// config->sync(); 104 delete config;
105 config = 0;
106 qDebug("worte confi NetworkSetupPPP");
107 }
108 if (_data){
109 delete _data;
110 _data = 0;
108 } 111 }
109 112
110} 113}
111 114
112 115
113// 116//
114// cancel changes 117// cancel changes
115// 118//
116void PPPData::cancel() { 119void PPPData::cancel() {
117 120
118// if (config) { 121// if (config) {
119// config->rollback(); 122// config->rollback();
120// config->reparseConfiguration(); 123// config->reparseConfiguration();
121// } 124// }
122 125
123} 126}
124 127
125 128
126// currently differentiates between READWRITE and NONE only 129// // currently differentiates between READWRITE and NONE only
127int PPPData::access() const { 130// int PPPData::access() const {
128 131
129 return 0;//config->getConfigState(); 132// return 1;//config->getConfigState();
130} 133// }
131 134
132 135
133// functions to read/write date to configuration file 136// functions to read/write date to configuration file
134QString PPPData::readConfig(const QString &group, const QString &key, 137QString PPPData::readConfig(const QString &group, const QString &key,
135 const QString &defvalue = "") 138 const QString &defvalue = "")
136{ 139{
140// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
137 if (config) { 141 if (config) {
138 config->setGroup(group); 142 config->setGroup(group);
139 return config->readEntry(key, defvalue); 143 return config->readEntry(key, defvalue);
140 } else 144 } else
141 return defvalue; 145 return defvalue;
142} 146}
143 147
144 148
145int PPPData::readNumConfig(const QString &group, const QString &key, 149int PPPData::readNumConfig(const QString &group, const QString &key,
146 int defvalue) { 150 int defvalue) {
147 if (config) { 151 if (config) {
148 config->setGroup(group); 152 config->setGroup(group);
149 return config->readNumEntry(key, defvalue); 153 return config->readNumEntry(key, defvalue);
150 } else 154 } else
151 return defvalue; 155 return defvalue;
152 156
153} 157}
154 158
155 159
156bool PPPData::readListConfig(const QString &group, const QString &key, 160bool PPPData::readListConfig(const QString &group, const QString &key,
157 QStringList &list, char sep) { 161 QStringList &list, char sep) {
158 list.clear(); 162 list.clear();
159 if (config) { 163 if (config) {
160 config->setGroup(group); 164 config->setGroup(group);
161 list = config->readListEntry(key, sep); 165 list = config->readListEntry(key, sep);
162 return true; 166 return true;
163 } else 167 } else
164 return false; 168 return false;
165} 169}
166 170
167 171
168void PPPData::writeConfig(const QString &group, const QString &key, 172void PPPData::writeConfig(const QString &group, const QString &key,
169 const QString &value) { 173 const QString &value) {
170 if (config) { 174 if (config) {
171 config->setGroup(group); 175 config->setGroup(group);
172 config->writeEntry(key, value); 176 config->writeEntry(key, value);
173 } 177 }
174} 178}
175 179
176 180
177void PPPData::writeConfig(const QString &group, const QString &key, int value) { 181void PPPData::writeConfig(const QString &group, const QString &key, int value) {
178 if (config) { 182 if (config) {
179 config->setGroup(group); 183 config->setGroup(group);
180 config->writeEntry(key, value); 184 config->writeEntry(key, value);
181 } 185 }
182} 186}
183 187
184 188
185void PPPData::writeListConfig(const QString &group, const QString &key, 189void PPPData::writeListConfig(const QString &group, const QString &key,
186 QStringList &list, char sep) { 190 QStringList &list, char sep) {
187 if (config) { 191 if (config) {
188 config->setGroup(group); 192 config->setGroup(group);
189 config->writeEntry(key, list, sep); 193 config->writeEntry(key, list, sep);
190 } 194 }
191} 195}
192 196
193 197
194// 198//
195// functions to set/return general information 199// functions to set/return general information
196// 200//
197QString PPPData::password() const { 201QString PPPData::password() const {
198 return passwd; 202 return passwd;
199} 203}
200 204
201 205
202void PPPData::setPassword(const QString &pw) { 206void PPPData::setPassword(const QString &pw) {
203 passwd = pw; 207 passwd = pw;
204} 208}
205 209
206 210
207const QString PPPData::defaultAccount() { 211const QString PPPData::defaultAccount() {
208 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); 212 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
209} 213}
210 214
211 215
212void PPPData::setDefaultAccount(const QString &n) { 216void PPPData::setDefaultAccount(const QString &n) {
213 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); 217 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n);
214 218
215 //now set the current account index to the default account 219 //now set the current account index to the default account
216 setAccount(defaultAccount()); 220 setAccount(defaultAccount());
217} 221}
218 222
219 223
220bool PPPData::get_show_clock_on_caption() { 224bool PPPData::get_show_clock_on_caption() {
221 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); 225 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true);
222} 226}
223 227
224 228
225void PPPData::set_show_clock_on_caption(bool set) { 229void PPPData::set_show_clock_on_caption(bool set) {
226 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); 230 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set);
227} 231}
228 232
229 233
230bool PPPData::get_xserver_exit_disconnect() { 234bool PPPData::get_xserver_exit_disconnect() {
231 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); 235 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true);
232} 236}
@@ -625,605 +629,606 @@ int PPPData::volume() {
625 629
626 630
627void PPPData::setVolume(int i) { 631void PPPData::setVolume(int i) {
628 writeConfig(MODEM_GRP, VOLUME_KEY, i); 632 writeConfig(MODEM_GRP, VOLUME_KEY, i);
629} 633}
630 634
631int PPPData::waitForDialTone() { 635int PPPData::waitForDialTone() {
632 return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1); 636 return readNumConfig(MODEM_GRP, DIALTONEWAIT_KEY, 1);
633} 637}
634 638
635void PPPData::setWaitForDialTone(int i) { 639void PPPData::setWaitForDialTone(int i) {
636 writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i); 640 writeConfig(MODEM_GRP, DIALTONEWAIT_KEY, i);
637} 641}
638 642
639void PPPData::setModemAnswerStr(const QString &n) { 643void PPPData::setModemAnswerStr(const QString &n) {
640 writeConfig(MODEM_GRP, ANSWERSTR_KEY, n); 644 writeConfig(MODEM_GRP, ANSWERSTR_KEY, n);
641} 645}
642 646
643 647
644const QString PPPData::modemRingResp() { 648const QString PPPData::modemRingResp() {
645 return readConfig(MODEM_GRP, RINGRESP_KEY, "RING"); 649 return readConfig(MODEM_GRP, RINGRESP_KEY, "RING");
646} 650}
647 651
648 652
649void PPPData::setModemRingResp(const QString &n) { 653void PPPData::setModemRingResp(const QString &n) {
650 writeConfig(MODEM_GRP, RINGRESP_KEY, n); 654 writeConfig(MODEM_GRP, RINGRESP_KEY, n);
651} 655}
652 656
653 657
654const QString PPPData::modemAnswerResp() { 658const QString PPPData::modemAnswerResp() {
655 return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT"); 659 return readConfig(MODEM_GRP, ANSWERRESP_KEY, "CONNECT");
656} 660}
657 661
658 662
659void PPPData::setModemAnswerResp(const QString &n) { 663void PPPData::setModemAnswerResp(const QString &n) {
660 writeConfig(MODEM_GRP, ANSWERRESP_KEY, n); 664 writeConfig(MODEM_GRP, ANSWERRESP_KEY, n);
661} 665}
662 666
663 667
664const QString PPPData::enter() { 668const QString PPPData::enter() {
665 return readConfig(MODEM_GRP, ENTER_KEY, "CR"); 669 return readConfig(MODEM_GRP, ENTER_KEY, "CR");
666} 670}
667 671
668 672
669void PPPData::setEnter(const QString &n) { 673void PPPData::setEnter(const QString &n) {
670 writeConfig(MODEM_GRP, ENTER_KEY, n); 674 writeConfig(MODEM_GRP, ENTER_KEY, n);
671} 675}
672 676
673 677
674// 678//
675// functions to set/return account information 679// functions to set/return account information
676// 680//
677 681
678//returns number of accounts 682//returns number of accounts
679int PPPData::count() const { 683int PPPData::count() const {
680 return highcount + 1; 684 return highcount + 1;
681} 685}
682 686
683 687
684bool PPPData::setAccount(const QString &aname) { 688bool PPPData::setAccount(const QString &aname) {
685 for(int i = 0; i <= highcount; i++) { 689 for(int i = 0; i <= highcount; i++) {
686 setAccountbyIndex(i); 690 setAccountbyIndex(i);
687 if(accname() == aname) { 691 if(accname() == aname) {
688 caccount = i; 692 caccount = i;
689 return true; 693 return true;
690 } 694 }
691 } 695 }
692 return false; 696 return false;
693} 697}
694 698
695 699
696bool PPPData::setAccountbyIndex(int i) { 700bool PPPData::setAccountbyIndex(int i) {
697 if(i >= 0 && i <= highcount) { 701 if(i >= 0 && i <= highcount) {
698 caccount = i; 702 caccount = i;
699 cgroup.sprintf("%s%i", ACCOUNT_GRP, i); 703 cgroup.sprintf("%s%i", ACCOUNT_GRP, i);
700 return true; 704 return true;
701 } 705 }
702 return false; 706 return false;
703} 707}
704 708
705 709
706bool PPPData::isUniqueAccname(const QString &n) { 710bool PPPData::isUniqueAccname(const QString &n) {
707 int current = caccount; 711 int current = caccount;
708 for(int i=0; i <= highcount; i++) { 712 for(int i=0; i <= highcount; i++) {
709 setAccountbyIndex(i); 713 setAccountbyIndex(i);
710 if(accname() == n && i != current) { 714 if(accname() == n && i != current) {
711 setAccountbyIndex(current); 715 setAccountbyIndex(current);
712 return false; 716 return false;
713 } 717 }
714 } 718 }
715 setAccountbyIndex(current); 719 setAccountbyIndex(current);
716 return true; 720 return true;
717} 721}
718 722
719 723
720bool PPPData::deleteAccount() { 724bool PPPData::deleteAccount() {
721 if(caccount < 0) 725 //FIXME:
722 return false; 726// if(caccount < 0)
727 return false;
723 728
724// QMap <QString, QString> map; 729// QMap <QString, QString> map;
725// QMap <QString, QString>::Iterator it; 730// QMap <QString, QString>::Iterator it;
726 731
727 // set all entries of the current account to "" 732// // set all entries of the current account to ""
728// tille: do not handle the accounts here... (?)
729// map = config->entryMap(cgroup); 733// map = config->entryMap(cgroup);
730// it = map.begin(); 734// it = map.begin();
731// while (it != map.end()) { 735// while (it != map.end()) {
732// config->writeEntry(it.key(), ""); 736// config->writeEntry(it.key(), "");
733// it++; 737// it++;
734// } 738// }
735 739
736// // shift the succeeding accounts 740// // shift the succeeding accounts
737// for(int i = caccount+1; i <= highcount; i++) { 741// for(int i = caccount+1; i <= highcount; i++) {
738// setAccountbyIndex(i); 742// setAccountbyIndex(i);
739// map = config->entryMap(cgroup); 743// map = config->entryMap(cgroup);
740// it = map.begin(); 744// it = map.begin();
741// setAccountbyIndex(i-1); 745// setAccountbyIndex(i-1);
742// config->setGroup(cgroup); 746// config->setGroup(cgroup);
743// while (it != map.end()) { 747// while (it != map.end()) {
744// config->writeEntry(it.key(), *it); 748// config->writeEntry(it.key(), *it);
745// it++; 749// it++;
746// } 750// }
747// } 751// }
748 752
749// // make sure the top account is cleared 753// // make sure the top account is cleared
750// setAccountbyIndex(highcount); 754// setAccountbyIndex(highcount);
751// map = config->entryMap(cgroup); 755// map = config->entryMap(cgroup);
752// it = map.begin(); 756// it = map.begin();
753// config->setGroup(cgroup); 757// config->setGroup(cgroup);
754// while (it.key() != QString::null) { 758// while (it.key() != QString::null) {
755// config->writeEntry(it.key(), ""); 759// config->writeEntry(it.key(), "");
756// it++; 760// it++;
757// } 761// }
758 762
759 highcount--; 763// highcount--;
760 if(caccount > highcount) 764// if(caccount > highcount)
761 caccount = highcount; 765// caccount = highcount;
762 766
763 setAccountbyIndex(caccount); 767// setAccountbyIndex(caccount);
764 768
765 return true; 769// return true;
766} 770}
767 771
768 772
769bool PPPData::deleteAccount(const QString &aname) { 773bool PPPData::deleteAccount(const QString &aname) {
770 if(!setAccount(aname)) 774 if(!setAccount(aname))
771 return false; 775 return false;
772 776
773 deleteAccount(); 777 deleteAccount();
774 778
775 return true; 779 return true;
776} 780}
777 781
778 782
779int PPPData::newaccount() { 783int PPPData::newaccount() {
780 784
781 if(!config || highcount >= MAX_ACCOUNTS) 785 qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
782 return -1; 786 if(!config) open();
787 if (highcount >= MAX_ACCOUNTS) return -1;
783 788
784 highcount++; 789 highcount++;
785 setAccountbyIndex(highcount); 790 setAccountbyIndex(highcount);
786 791
787 setpppdArgumentDefaults(); 792 setpppdArgumentDefaults();
788 793 qDebug("PPPData::newaccount -> %i",caccount);
789 return caccount; 794 return caccount;
790} 795}
791 796
792int PPPData::copyaccount(int i) { 797int PPPData::copyaccount(int i) {
793 798
794 if(highcount >= MAX_ACCOUNTS) 799// if(highcount >= MAX_ACCOUNTS)
795 return -1; 800 return -1;
796 801
797 setAccountbyIndex(i); 802// setAccountbyIndex(i);
798 803
799// QMap <QString, QString> map = config->entryMap(cgroup); 804// QMap <QString, QString> map = config->entryMap(cgroup);
800// QMap <QString, QString>::ConstIterator it = map.begin(); 805// QMap <QString, QString>::ConstIterator it = map.begin();
801 806
802 QString newname = i18n("%1_copy").arg(accname()); 807// QString newname = i18n("%1_copy").arg(accname());
803 808
804 newaccount(); 809// newaccount();
805 810
806// while (it != map.end()) { 811// while (it != map.end()) {
807// config->writeEntry(it.key(), *it); 812// config->writeEntry(it.key(), *it);
808// it++; 813// it++;
809// } 814// }
810 815
811 setAccname(newname); 816// setAccname(newname);
812 817
813 return caccount; 818// return caccount;
814} 819}
815 820
816 821
817const QString PPPData::accname() { 822const QString PPPData::accname() {
818 return readConfig(cgroup, NAME_KEY); 823 return readConfig(cgroup, NAME_KEY);
819} 824}
820 825
821void PPPData::setAccname(const QString &n) { 826void PPPData::setAccname(const QString &n) {
822 if(!cgroup.isNull()) { 827 if(!cgroup.isNull()) {
823 // are we manipulating the default account's name ? then change it, too. 828 // are we manipulating the default account's name ? then change it, too.
824 bool def = accname() == defaultAccount(); 829 bool def = accname() == defaultAccount();
825 writeConfig(cgroup, NAME_KEY, n); 830 writeConfig(cgroup, NAME_KEY, n);
826 if (def) 831 if (def)
827 setDefaultAccount(n); 832 setDefaultAccount(n);
828 } 833 }
829} 834}
830 835
831 836
832#define SEPARATOR_CHAR ':' 837#define SEPARATOR_CHAR '&'
833QStringList &PPPData::phonenumbers() { 838QStringList &PPPData::phonenumbers() {
834 839
835 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); 840 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR);
836 return phonelist; 841 return phonelist;
837 842
838} 843}
839 844
840 845
841const QString PPPData::phonenumber() { 846const QString PPPData::phonenumber() {
842 return readConfig(cgroup, PHONENUMBER_KEY); 847 return readConfig(cgroup, PHONENUMBER_KEY);
843} 848}
844 849
845 850
846void PPPData::setPhonenumber(const QString &n) { 851void PPPData::setPhonenumber(const QString &n) {
847 writeConfig(cgroup, PHONENUMBER_KEY, n); 852 writeConfig(cgroup, PHONENUMBER_KEY, n);
848} 853}
849 854
850 855
851const QString PPPData::dialPrefix() { 856const QString PPPData::dialPrefix() {
852 return readConfig(cgroup, DIAL_PREFIX_KEY, ""); 857 return readConfig(cgroup, DIAL_PREFIX_KEY, "");
853} 858}
854 859
855 860
856void PPPData::setDialPrefix(const QString &s) { 861void PPPData::setDialPrefix(const QString &s) {
857 writeConfig(cgroup, DIAL_PREFIX_KEY, s); 862 writeConfig(cgroup, DIAL_PREFIX_KEY, s);
858} 863}
859 864
860 865
861int PPPData::authMethod() { 866int PPPData::authMethod() {
862 return readNumConfig(cgroup, AUTH_KEY, 0); 867 return readNumConfig(cgroup, AUTH_KEY, 0);
863} 868}
864 869
865 870
866void PPPData::setAuthMethod(int value) { 871void PPPData::setAuthMethod(int value) {
867 writeConfig(cgroup, AUTH_KEY, value); 872 writeConfig(cgroup, AUTH_KEY, value);
868} 873}
869 874
870 875
871const QString PPPData::storedUsername() { 876const QString PPPData::storedUsername() {
872 return readConfig(cgroup, STORED_USERNAME_KEY, ""); 877 return readConfig(cgroup, STORED_USERNAME_KEY, "");
873} 878}
874 879
875 880
876void PPPData::setStoredUsername(const QString &b) { 881void PPPData::setStoredUsername(const QString &b) {
877 writeConfig(cgroup, STORED_USERNAME_KEY, b); 882 writeConfig(cgroup, STORED_USERNAME_KEY, b);
878} 883}
879 884
880 885
881const QString PPPData::storedPassword() { 886const QString PPPData::storedPassword() {
882 return readConfig(cgroup, STORED_PASSWORD_KEY, ""); 887 return readConfig(cgroup, STORED_PASSWORD_KEY, "");
883} 888}
884 889
885 890
886void PPPData::setStoredPassword(const QString &b) { 891void PPPData::setStoredPassword(const QString &b) {
887 writeConfig(cgroup, STORED_PASSWORD_KEY, b); 892 writeConfig(cgroup, STORED_PASSWORD_KEY, b);
888} 893}
889 894
890 895
891bool PPPData::storePassword() { 896bool PPPData::storePassword() {
892 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); 897 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1);
893} 898}
894 899
895 900
896const QString PPPData::command_before_connect() { 901const QString PPPData::command_before_connect() {
897 return readConfig(cgroup, BEFORE_CONNECT_KEY); 902 return readConfig(cgroup, BEFORE_CONNECT_KEY);
898} 903}
899 904
900 905
901void PPPData::setCommand_before_connect(const QString &n) { 906void PPPData::setCommand_before_connect(const QString &n) {
902 writeConfig(cgroup, BEFORE_CONNECT_KEY, n); 907 writeConfig(cgroup, BEFORE_CONNECT_KEY, n);
903} 908}
904 909
905 910
906void PPPData::setStorePassword(bool b) { 911void PPPData::setStorePassword(bool b) {
907 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); 912 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b);
908} 913}
909 914
910 915
911const QString PPPData::command_on_connect() { 916const QString PPPData::command_on_connect() {
912 return readConfig(cgroup, COMMAND_KEY); 917 return readConfig(cgroup, COMMAND_KEY);
913} 918}
914 919
915 920
916void PPPData::setCommand_on_connect(const QString &n) { 921void PPPData::setCommand_on_connect(const QString &n) {
917 writeConfig(cgroup, COMMAND_KEY, n); 922 writeConfig(cgroup, COMMAND_KEY, n);
918} 923}
919 924
920 925
921const QString PPPData::command_on_disconnect() { 926const QString PPPData::command_on_disconnect() {
922 return readConfig(cgroup, DISCONNECT_COMMAND_KEY); 927 return readConfig(cgroup, DISCONNECT_COMMAND_KEY);
923} 928}
924 929
925 930
926void PPPData::setCommand_on_disconnect(const QString &n) { 931void PPPData::setCommand_on_disconnect(const QString &n) {
927 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); 932 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n);
928} 933}
929 934
930 935
931const QString PPPData::command_before_disconnect() { 936const QString PPPData::command_before_disconnect() {
932 return readConfig(cgroup, BEFORE_DISCONNECT_KEY); 937 return readConfig(cgroup, BEFORE_DISCONNECT_KEY);
933} 938}
934 939
935 940
936void PPPData::setCommand_before_disconnect(const QString &n) { 941void PPPData::setCommand_before_disconnect(const QString &n) {
937 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); 942 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n);
938} 943}
939 944
940 945
941const QString PPPData::ipaddr() { 946const QString PPPData::ipaddr() {
942 return readConfig(cgroup, IPADDR_KEY); 947 return readConfig(cgroup, IPADDR_KEY);
943} 948}
944 949
945 950
946void PPPData::setIpaddr(const QString &n) { 951void PPPData::setIpaddr(const QString &n) {
947 writeConfig(cgroup, IPADDR_KEY, n); 952 writeConfig(cgroup, IPADDR_KEY, n);
948} 953}
949 954
950 955
951const QString PPPData::subnetmask() { 956const QString PPPData::subnetmask() {
952 return readConfig(cgroup, SUBNETMASK_KEY); 957 return readConfig(cgroup, SUBNETMASK_KEY);
953} 958}
954 959
955 960
956void PPPData::setSubnetmask(const QString &n) { 961void PPPData::setSubnetmask(const QString &n) {
957 writeConfig(cgroup, SUBNETMASK_KEY, n); 962 writeConfig(cgroup, SUBNETMASK_KEY, n);
958} 963}
959 964
960 965
961bool PPPData::autoname() { 966bool PPPData::autoname() {
962 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); 967 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false);
963} 968}
964 969
965 970
966void PPPData::setAutoname(bool set) { 971void PPPData::setAutoname(bool set) {
967 writeConfig(cgroup, AUTONAME_KEY, (int) set); 972 writeConfig(cgroup, AUTONAME_KEY, (int) set);
968} 973}
969 974
970 975
971bool PPPData::AcctEnabled() { 976bool PPPData::AcctEnabled() {
972 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); 977 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
973} 978}
974 979
975 980
976void PPPData::setAcctEnabled(bool set) { 981void PPPData::setAcctEnabled(bool set) {
977 writeConfig(cgroup, ACCTENABLED_KEY, (int) set); 982 writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
978} 983}
979 984
980 985
981int PPPData::VolAcctEnabled() { 986int PPPData::VolAcctEnabled() {
982 return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); 987 return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
983} 988}
984 989
985 990
986void PPPData::setVolAcctEnabled(int set) { 991void PPPData::setVolAcctEnabled(int set) {
987 writeConfig(cgroup, VOLACCTENABLED_KEY, set); 992 writeConfig(cgroup, VOLACCTENABLED_KEY, set);
988} 993}
989 994
990 995
991const QString PPPData::gateway() { 996const QString PPPData::gateway() {
992 return readConfig(cgroup, GATEWAY_KEY); 997 return readConfig(cgroup, GATEWAY_KEY);
993} 998}
994 999
995 1000
996void PPPData::setGateway(const QString &n ) { 1001void PPPData::setGateway(const QString &n ) {
997 writeConfig(cgroup, GATEWAY_KEY, n); 1002 writeConfig(cgroup, GATEWAY_KEY, n);
998} 1003}
999 1004
1000 1005
1001bool PPPData::defaultroute() { 1006bool PPPData::defaultroute() {
1002 // default route is by default 'on'. 1007 // default route is by default 'on'.
1003 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); 1008 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
1004} 1009}
1005 1010
1006 1011
1007void PPPData::setDefaultroute(bool set) { 1012void PPPData::setDefaultroute(bool set) {
1008 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); 1013 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
1009} 1014}
1010 1015
1011 1016
1012bool PPPData::autoDNS() { 1017bool PPPData::autoDNS() {
1013 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); 1018 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
1014 return (set && gpppdata.pppdVersionMin(2, 3, 7)); 1019 return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
1015} 1020}
1016 1021
1017 1022
1018void PPPData::setAutoDNS(bool set) { 1023void PPPData::setAutoDNS(bool set) {
1019 writeConfig(cgroup, AUTODNS_KEY, (int) set); 1024 writeConfig(cgroup, AUTODNS_KEY, (int) set);
1020} 1025}
1021 1026
1022 1027
1023void PPPData::setExDNSDisabled(bool set) { 1028void PPPData::setExDNSDisabled(bool set) {
1024 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); 1029 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
1025} 1030}
1026 1031
1027 1032
1028bool PPPData::exDNSDisabled() { 1033bool PPPData::exDNSDisabled() {
1029 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); 1034 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0);
1030} 1035}
1031 1036
1032 1037
1033QStringList &PPPData::dns() { 1038QStringList &PPPData::dns() {
1034 static QStringList dnslist; 1039 static QStringList dnslist;
1035 1040
1036 readListConfig(cgroup, DNS_KEY, dnslist); 1041 readListConfig(cgroup, DNS_KEY, dnslist);
1037 while(dnslist.count() > MAX_DNS_ENTRIES) 1042 while(dnslist.count() > MAX_DNS_ENTRIES)
1038 dnslist.remove(dnslist.last()); 1043 dnslist.remove(dnslist.last());
1039 1044
1040 return dnslist; 1045 return dnslist;
1041} 1046}
1042 1047
1043 1048
1044void PPPData::setDns(QStringList &list) { 1049void PPPData::setDns(QStringList &list) {
1045 writeListConfig(cgroup, DNS_KEY, list); 1050 writeListConfig(cgroup, DNS_KEY, list);
1046} 1051}
1047 1052
1048 1053
1049const QString PPPData::domain() { 1054const QString PPPData::domain() {
1050 return readConfig(cgroup, DOMAIN_KEY); 1055 return readConfig(cgroup, DOMAIN_KEY);
1051} 1056}
1052 1057
1053 1058
1054void PPPData::setDomain(const QString &n ) { 1059void PPPData::setDomain(const QString &n ) {
1055 writeConfig(cgroup, DOMAIN_KEY, n); 1060 writeConfig(cgroup, DOMAIN_KEY, n);
1056} 1061}
1057 1062
1058 1063
1059QStringList &PPPData::scriptType() { 1064QStringList &PPPData::scriptType() {
1060 static QStringList typelist; 1065 static QStringList typelist;
1061 1066
1062 readListConfig(cgroup, SCRIPTCOM_KEY, typelist); 1067 readListConfig(cgroup, SCRIPTCOM_KEY, typelist);
1063 while(typelist.count() > MAX_SCRIPT_ENTRIES) 1068 while(typelist.count() > MAX_SCRIPT_ENTRIES)
1064 typelist.remove(typelist.last()); 1069 typelist.remove(typelist.last());
1065 1070
1066 return typelist; 1071 return typelist;
1067} 1072}
1068 1073
1069 1074
1070void PPPData::setScriptType(QStringList &list) { 1075void PPPData::setScriptType(QStringList &list) {
1071 writeListConfig(cgroup, SCRIPTCOM_KEY, list); 1076 writeListConfig(cgroup, SCRIPTCOM_KEY, list);
1072} 1077}
1073 1078
1074 1079
1075QStringList &PPPData::script() { 1080QStringList &PPPData::script() {
1076 static QStringList scriptlist; 1081 static QStringList scriptlist;
1077 1082
1078 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); 1083 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist);
1079 while(scriptlist.count() > MAX_SCRIPT_ENTRIES) 1084 while(scriptlist.count() > MAX_SCRIPT_ENTRIES)
1080 scriptlist.remove(scriptlist.last()); 1085 scriptlist.remove(scriptlist.last());
1081 1086
1082 return scriptlist; 1087 return scriptlist;
1083} 1088}
1084 1089
1085 1090
1086void PPPData::setScript(QStringList &list) { 1091void PPPData::setScript(QStringList &list) {
1087 writeListConfig(cgroup, SCRIPTARG_KEY, list); 1092 writeListConfig(cgroup, SCRIPTARG_KEY, list);
1088} 1093}
1089 1094
1090 1095
1091const QString PPPData::accountingFile() { 1096const QString PPPData::accountingFile() {
1092 return readConfig(cgroup, ACCTFILE_KEY); 1097 return readConfig(cgroup, ACCTFILE_KEY);
1093} 1098}
1094 1099
1095 1100
1096void PPPData::setAccountingFile(const QString &n) { 1101void PPPData::setAccountingFile(const QString &n) {
1097 writeConfig(cgroup, ACCTFILE_KEY, n); 1102 writeConfig(cgroup, ACCTFILE_KEY, n);
1098} 1103}
1099 1104
1100 1105
1101const QString PPPData::totalCosts() { 1106const QString PPPData::totalCosts() {
1102 return readConfig(cgroup, TOTALCOSTS_KEY); 1107 return readConfig(cgroup, TOTALCOSTS_KEY);
1103} 1108}
1104 1109
1105 1110
1106void PPPData::setTotalCosts(const QString &n) { 1111void PPPData::setTotalCosts(const QString &n) {
1107 writeConfig(cgroup, TOTALCOSTS_KEY, n); 1112 writeConfig(cgroup, TOTALCOSTS_KEY, n);
1108} 1113}
1109 1114
1110 1115
1111int PPPData::totalBytes() { 1116int PPPData::totalBytes() {
1112 return readNumConfig(cgroup, TOTALBYTES_KEY, 0); 1117 return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
1113} 1118}
1114 1119
1115void PPPData::setTotalBytes(int n) { 1120void PPPData::setTotalBytes(int n) {
1116 writeConfig(cgroup, TOTALBYTES_KEY, n); 1121 writeConfig(cgroup, TOTALBYTES_KEY, n);
1117} 1122}
1118 1123
1119 1124
1120QStringList &PPPData::pppdArgument() { 1125QStringList &PPPData::pppdArgument() {
1121 static QStringList arglist; 1126 static QStringList arglist;
1122 1127
1123 while(arglist.count() > MAX_PPPD_ARGUMENTS) 1128 while(arglist.count() > MAX_PPPD_ARGUMENTS)
1124 arglist.remove(arglist.last()); 1129 arglist.remove(arglist.last());
1125 readListConfig(cgroup, PPPDARG_KEY, arglist); 1130 readListConfig(cgroup, PPPDARG_KEY, arglist);
1126 1131
1127 return arglist; 1132 return arglist;
1128} 1133}
1129 1134
1130 1135
1131void PPPData::setpppdArgument(QStringList &args) { 1136void PPPData::setpppdArgument(QStringList &args) {
1132 writeListConfig(cgroup, PPPDARG_KEY, args); 1137 writeListConfig(cgroup, PPPDARG_KEY, args);
1133} 1138}
1134 1139
1135 1140
1136void PPPData::setpppdArgumentDefaults() { 1141void PPPData::setpppdArgumentDefaults() {
1137 QStringList arg; 1142 QStringList arg;
1138 setpppdArgument(arg); 1143 setpppdArgument(arg);
1139} 1144}
1140 1145
1141 1146
1142// graphing widget 1147// // graphing widget
1143void PPPData::setGraphingOptions(bool enable, 1148// void PPPData::setGraphingOptions(bool enable,
1144 QColor bg, 1149 // QColor bg,
1145 QColor text, 1150 // QColor text,
1146 QColor in, 1151 // QColor in,
1147 QColor out) 1152 // QColor out)
1148{ 1153// {
1149 if(config) { 1154// if(config) {
1150 config->setGroup(GRAPH_GRP); 1155// config->setGroup(GRAPH_GRP);
1151 config->writeEntry(GENABLED, enable); 1156// config->writeEntry(GENABLED, enable);
1152// config->writeEntry(GCOLOR_BG, bg); 1157// // config->writeEntry(GCOLOR_BG, bg);
1153// config->writeEntry(GCOLOR_TEXT, text); 1158// // config->writeEntry(GCOLOR_TEXT, text);
1154// config->writeEntry(GCOLOR_IN, in); 1159// // config->writeEntry(GCOLOR_IN, in);
1155// config->writeEntry(GCOLOR_OUT, out); 1160// // config->writeEntry(GCOLOR_OUT, out);
1156 } 1161// }
1157} 1162// }
1158 1163
1159void PPPData::graphingOptions(bool &enable, 1164// void PPPData::graphingOptions(bool &enable,
1160 QColor &bg, 1165 // QColor &bg,
1161 QColor &text, 1166 // QColor &text,
1162 QColor &in, 1167 // QColor &in,
1163 QColor &out) 1168 // QColor &out)
1164{ 1169// {
1165 QColor c; 1170// QColor c;
1166 1171
1167 if(config) { 1172// if(config) {
1168 config->setGroup(GRAPH_GRP); 1173// config->setGroup(GRAPH_GRP);
1169 enable = config->readBoolEntry(GENABLED, true); 1174// enable = config->readBoolEntry(GENABLED, true);
1170 bg = Qt::white; 1175// bg = Qt::white;
1171 //bg = config->readColorEntry(GCOLOR_BG, &c); 1176// //bg = config->readColorEntry(GCOLOR_BG, &c);
1172 text = Qt::black; 1177// text = Qt::black;
1173 //text = config->readColorEntry(GCOLOR_TEXT, &c); 1178// //text = config->readColorEntry(GCOLOR_TEXT, &c);
1174 in = Qt::blue; 1179// in = Qt::blue;
1175 //in = config->readColorEntry(GCOLOR_IN, &c); 1180// //in = config->readColorEntry(GCOLOR_IN, &c);
1176 out = Qt::red; 1181// out = Qt::red;
1177 //out = config->readColorEntry(GCOLOR_OUT, &c); 1182// //out = config->readColorEntry(GCOLOR_OUT, &c);
1178 } 1183// }
1179} 1184// }
1180 1185
1181 1186
1182bool PPPData::graphingEnabled() { 1187// bool PPPData::graphingEnabled() {
1183 return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); 1188// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
1184} 1189// }
1185 1190
1186 1191
1187 1192
1188// 1193//
1189//functions to change/set the child pppd process info 1194//functions to change/set the child pppd process info
1190// 1195//
1191bool PPPData::pppdRunning() const { 1196bool PPPData::pppdRunning() const {
1192 return pppdisrunning; 1197 return pppdisrunning;
1193} 1198}
1194 1199
1195void PPPData::setpppdRunning(bool set) { 1200void PPPData::setpppdRunning(bool set) {
1196 pppdisrunning = set; 1201 pppdisrunning = set;
1197} 1202}
1198 1203
1199int PPPData::pppdError() const { 1204int PPPData::pppdError() const {
1200 return pppderror; 1205 return pppderror;
1201} 1206}
1202 1207
1203void PPPData::setpppdError(int err) { 1208void PPPData::setpppdError(int err) {
1204 pppderror = err; 1209 pppderror = err;
1205} 1210}
1206 1211
1207 1212
1208// 1213// //
1209// window position 1214// // window position
1210// 1215// //
1211void PPPData::winPosConWin(int& p_x, int& p_y) { 1216// void PPPData::winPosConWin(int& p_x, int& p_y) {
1212 p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160); 1217// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
1213 p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55); 1218// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
1214} 1219// }
1215 1220
1216void PPPData::setWinPosConWin(int p_x, int p_y) { 1221// void PPPData::setWinPosConWin(int p_x, int p_y) {
1217 writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x); 1222// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
1218 writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y); 1223// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
1219} 1224// }
1220 1225
1221void PPPData::winPosStatWin(int& p_x, int& p_y) { 1226// void PPPData::winPosStatWin(int& p_x, int& p_y) {
1222 p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160); 1227// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
1223 p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55); 1228// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
1224} 1229// }
1225 1230
1226void PPPData::setWinPosStatWin(int p_x, int p_y) { 1231// void PPPData::setWinPosStatWin(int p_x, int p_y) {
1227 writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x); 1232// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
1228 writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y); 1233// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
1229} 1234// }
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index e286b70..57ce2fd 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -1,267 +1,268 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 * 2 *
3 * kPPP: A pppd front end for the KDE project 3 * kPPP: A pppd front end for the KDE project
4 * 4 *
5 * $Id$ 5 * $Id$
6 * 6 *
7 * Copyright (C) 1997 Bernd Johannes Wuebben 7 * Copyright (C) 1997 Bernd Johannes Wuebben
8 * wuebben@math.cornell.edu 8 * wuebben@math.cornell.edu
9 * 9 *
10 * based on EzPPP: 10 * based on EzPPP:
11 * Copyright (C) 1997 Jay Painter 11 * Copyright (C) 1997 Jay Painter
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 16 * version 2 of the License, or (at your option) any later version.
17 * 17 *
18 * This program is distributed in the hope that it will be useful, 18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details. 21 * Library General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU Library General Public 23 * You should have received a copy of the GNU Library General Public
24 * License along with this program; if not, write to the Free 24 * License along with this program; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#ifndef _PPPDATA_H_ 28#ifndef _PPPDATA_H_
29#define _PPPDATA_H_ 29#define _PPPDATA_H_
30 30
31#include <unistd.h> 31#include <unistd.h>
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#include <qstring.h> 34#include <qstring.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <qcolor.h> 36#include <qcolor.h>
37 37
38#include "kpppconfig.h" 38#include "kpppconfig.h"
39 39
40class Config; 40class Config;
41 41
42// string lengths 42// string lengths
43 43
44#define PATH_SIZE 120 44#define PATH_SIZE 120
45#define MODEMSTR_SIZE 80 45#define MODEMSTR_SIZE 80
46#define ACCNAME_SIZE 50 46#define ACCNAME_SIZE 50
47#define PHONENUMBER_SIZE 60 47#define PHONENUMBER_SIZE 60
48#define COMMAND_SIZE 255 48#define COMMAND_SIZE 255
49#define IPADDR_SIZE 15 49#define IPADDR_SIZE 15
50#define DOMAIN_SIZE 50 50#define DOMAIN_SIZE 50
51#define TIMEOUT_SIZE 60 51#define TIMEOUT_SIZE 60
52 52
53// 53//
54// keys for config file 54// keys for config file
55// 55//
56 56
57// groups 57// groups
58#define GENERAL_GRP "General" 58#define GENERAL_GRP "PPP_General"
59#define MODEM_GRP "Modem" 59#define MODEM_GRP "PPP_Modem"
60#define ACCOUNT_GRP "Account" 60#define ACCOUNT_GRP "PPP_Account"
61#define GRAPH_GRP "Graph" 61//#define GRAPH_GRP "Graph"
62#define WINPOS_GRP "WindowPosition" 62//#define WINPOS_GRP "WindowPosition"
63 63
64// general 64// general
65#define DEFAULTACCOUNT_KEY "DefaultAccount" 65#define DEFAULTACCOUNT_KEY "DefaultAccount"
66#define PPPDVERSION_KEY "pppdVersion" 66#define PPPDVERSION_KEY "pppdVersion"
67#define PPPDTIMEOUT_KEY "pppdTimeout" 67#define PPPDTIMEOUT_KEY "pppdTimeout"
68#define SHOWCLOCK_KEY "ShowClock" 68#define SHOWCLOCK_KEY "ShowClock"
69#define SHOWLOGWIN_KEY "ShowLogWindow" 69#define SHOWLOGWIN_KEY "ShowLogWindow"
70#define AUTOREDIAL_KEY "AutomaticRedial" 70#define AUTOREDIAL_KEY "AutomaticRedial"
71#define DISCONNECT_KEY "DisconnectOnXServerExit" 71#define DISCONNECT_KEY "DisconnectOnXServerExit"
72#define QUITONDISCONNECT_KEY "QuitOnDisconnect" 72#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
73#define NUMACCOUNTS_KEY "NumberOfAccounts" 73#define NUMACCOUNTS_KEY "NumberOfAccounts"
74 #define ID_KEY "ID" 74 #define ID_KEY "ID"
75 75
76// modem 76// modem
77#define MODEMDEV_KEY "Device" 77#define MODEMDEV_KEY "Device"
78#define LOCKFILE_KEY "UseLockFile" 78#define LOCKFILE_KEY "UseLockFile"
79#define FLOWCONTROL_KEY "FlowControl" 79#define FLOWCONTROL_KEY "FlowControl"
80#define SPEED_KEY "Speed" 80#define SPEED_KEY "Speed"
81#define TIMEOUT_KEY "Timeout" 81#define TIMEOUT_KEY "Timeout"
82#define TONEDURATION_KEY "ToneDuration" 82#define TONEDURATION_KEY "ToneDuration"
83#define BUSYWAIT_KEY "BusyWait" 83#define BUSYWAIT_KEY "BusyWait"
84#define INITSTR_KEY "InitString" 84#define INITSTR_KEY "InitString"
85#define INITRESP_KEY "InitResponse" 85#define INITRESP_KEY "InitResponse"
86#define PREINITDELAY_KEY "PreInitDelay" 86#define PREINITDELAY_KEY "PreInitDelay"
87#define INITDELAY_KEY "InitDelay" 87#define INITDELAY_KEY "InitDelay"
88#define NODTDETECT_KEY "NoDialToneDetection" 88#define NODTDETECT_KEY "NoDialToneDetection"
89#define DIALTONEWAIT_KEY "WaitForDialTone" 89#define DIALTONEWAIT_KEY "WaitForDialTone"
90#define DIALSTR_KEY "DialString" 90#define DIALSTR_KEY "DialString"
91#define CONNECTRESP_KEY "ConnectResponse" 91#define CONNECTRESP_KEY "ConnectResponse"
92#define BUSYRESP_KEY "BusyResponse" 92#define BUSYRESP_KEY "BusyResponse"
93#define NOCARRIERRESP_KEY "NoCarrierResponse" 93#define NOCARRIERRESP_KEY "NoCarrierResponse"
94#define NODIALTONERESP_KEY "NoDialToneResp" 94#define NODIALTONERESP_KEY "NoDialToneResp"
95#define HANGUPSTR_KEY "HangupString" 95#define HANGUPSTR_KEY "HangupString"
96#define HANGUPRESP_KEY "HangUpResponse" 96#define HANGUPRESP_KEY "HangUpResponse"
97#define ANSWERSTR_KEY "AnswerString" 97#define ANSWERSTR_KEY "AnswerString"
98#define RINGRESP_KEY "RingResponse" 98#define RINGRESP_KEY "RingResponse"
99#define ANSWERRESP_KEY "AnswerResponse" 99#define ANSWERRESP_KEY "AnswerResponse"
100#define ENTER_KEY "Enter" 100#define ENTER_KEY "Enter"
101#define ESCAPESTR_KEY "EscapeString" 101#define ESCAPESTR_KEY "EscapeString"
102#define ESCAPERESP_KEY "EscapeResponse" 102#define ESCAPERESP_KEY "EscapeResponse"
103#define ESCAPEGUARDTIME_KEY "EscapeGuardTime" 103#define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
104#define USECDLINE_KEY "UseCDLine" 104#define USECDLINE_KEY "UseCDLine"
105#define VOLUME_HIGH "VolumeHigh" 105#define VOLUME_HIGH "VolumeHigh"
106#define VOLUME_MEDIUM "VolumeMedium" 106#define VOLUME_MEDIUM "VolumeMedium"
107#define VOLUME_OFF "VolumeOff" 107#define VOLUME_OFF "VolumeOff"
108#define VOLUME_KEY "Volume" 108#define VOLUME_KEY "Volume"
109 109
110// account 110// account
111#define NAME_KEY "Name" 111#define NAME_KEY "Name"
112#define PHONENUMBER_KEY "Phonenumber" 112#define PHONENUMBER_KEY "Phonenumber"
113#define DIAL_PREFIX_KEY "DialPrefix" 113#define DIAL_PREFIX_KEY "DialPrefix"
114#define AUTH_KEY "Authentication" 114#define AUTH_KEY "Authentication"
115#define STORED_PASSWORD_KEY "Password" 115#define STORED_PASSWORD_KEY "Password"
116#define STORED_USERNAME_KEY "Username" 116#define STORED_USERNAME_KEY "Username"
117#define STORE_PASSWORD_KEY "StorePassword" 117#define STORE_PASSWORD_KEY "StorePassword"
118#define BEFORE_CONNECT_KEY "BeforeConnect" 118#define BEFORE_CONNECT_KEY "BeforeConnect"
119#define COMMAND_KEY "Command" 119#define COMMAND_KEY "Command"
120#define DISCONNECT_COMMAND_KEY "DisconnectCommand" 120#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
121#define BEFORE_DISCONNECT_KEY "BeforeDisconnect" 121#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
122#define IPADDR_KEY "IPAddr" 122#define IPADDR_KEY "IPAddr"
123#define SUBNETMASK_KEY "SubnetMask" 123#define SUBNETMASK_KEY "SubnetMask"
124#define ACCTENABLED_KEY "AccountingEnabled" 124#define ACCTENABLED_KEY "AccountingEnabled"
125#define VOLACCTENABLED_KEY "VolumeAccountingEnabled" 125#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
126#define ACCTFILE_KEY "AccountingFile" 126#define ACCTFILE_KEY "AccountingFile"
127#define AUTONAME_KEY "AutoName" 127#define AUTONAME_KEY "AutoName"
128#define GATEWAY_KEY "Gateway" 128#define GATEWAY_KEY "Gateway"
129#define DEFAULTROUTE_KEY "DefaultRoute" 129#define DEFAULTROUTE_KEY "DefaultRoute"
130#define DOMAIN_KEY "Domain" 130#define DOMAIN_KEY "Domain"
131#define DNS_KEY "DNS" 131#define DNS_KEY "DNS"
132#define AUTODNS_KEY "AutoDNS" 132#define AUTODNS_KEY "AutoDNS"
133#define EXDNSDISABLED_KEY "ExDNSDisabled" 133#define EXDNSDISABLED_KEY "ExDNSDisabled"
134#define SCRIPTCOM_KEY "ScriptCommands" 134#define SCRIPTCOM_KEY "ScriptCommands"
135#define SCRIPTARG_KEY "ScriptArguments" 135#define SCRIPTARG_KEY "ScriptArguments"
136#define PPPDARG_KEY "pppdArguments" 136#define PPPDARG_KEY "pppdArguments"
137#define PPP_DEBUG_OPTION "PPPDebug" 137#define PPP_DEBUG_OPTION "PPPDebug"
138#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" 138#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
139#define DOCKING_KEY "DockIntoPanel" 139#define DOCKING_KEY "DockIntoPanel"
140#define TOTALCOSTS_KEY "TotalCosts" 140#define TOTALCOSTS_KEY "TotalCosts"
141#define TOTALBYTES_KEY "TotalBytes" 141#define TOTALBYTES_KEY "TotalBytes"
142 142
143// graph colors 143// graph colors
144#define GENABLED "Enabled" 144#define GENABLED "Enabled"
145#define GCOLOR_BG "Background" 145#define GCOLOR_BG "Background"
146#define GCOLOR_TEXT "Text" 146#define GCOLOR_TEXT "Text"
147#define GCOLOR_IN "InBytes" 147#define GCOLOR_IN "InBytes"
148#define GCOLOR_OUT "OutBytes" 148#define GCOLOR_OUT "OutBytes"
149 149
150// pppd errors 150// pppd errors
151#define E_IF_TIMEOUT 1 151#define E_IF_TIMEOUT 1
152#define E_PPPD_DIED 2 152#define E_PPPD_DIED 2
153 153
154// window position 154// window position
155#define WINPOS_CONWIN_X "WindowPositionConWinX" 155#define WINPOS_CONWIN_X "WindowPositionConWinX"
156#define WINPOS_CONWIN_Y "WindowPositionConWinY" 156#define WINPOS_CONWIN_Y "WindowPositionConWinY"
157#define WINPOS_STATWIN_X "WindowPositionStatWinX" 157#define WINPOS_STATWIN_X "WindowPositionStatWinX"
158#define WINPOS_STATWIN_Y "WindowPositionStatWinY" 158#define WINPOS_STATWIN_Y "WindowPositionStatWinY"
159 159
160class PPPData { 160class PPPData {
161public: 161public:
162 PPPData(); 162 PPPData();
163 ~PPPData() {}; 163 ~PPPData() {};
164 static PPPData* data();
164 165
165 enum { NumInitStrings = 2 }; 166 enum { NumInitStrings = 2 };
166 167
167 // general functions 168 // general functions
168 bool open(); 169 bool open();
169 void save(); 170 void save();
170 void cancel(); 171 void cancel();
171 int access() const; // read/write access 172// int access() const; // read/write access
172 173
173 // function to read/write date to configuration file 174 // function to read/write date to configuration file
174 QString readConfig(const QString &, const QString &, const QString &); 175 QString readConfig(const QString &, const QString &, const QString &);
175 int readNumConfig(const QString &, const QString &, int); 176 int readNumConfig(const QString &, const QString &, int);
176 bool readListConfig(const QString &, const QString &, 177 bool readListConfig(const QString &, const QString &,
177 QStringList &, char sep = ','); 178 QStringList &, char sep = ',');
178 void writeConfig(const QString &, const QString &, const QString &); 179 void writeConfig(const QString &, const QString &, const QString &);
179 void writeConfig(const QString &, const QString &, int); 180 void writeConfig(const QString &, const QString &, int);
180 void writeListConfig(const QString &, const QString &, 181 void writeListConfig(const QString &, const QString &,
181 QStringList &, char sep = ','); 182 QStringList &, char sep = ',');
182 183
183 // return the current account group 184 // return the current account group
184 QString currentGroup() { return cgroup; } 185 QString currentGroup() { return cgroup; }
185 186
186 // functions to set/get general kppp info 187 // functions to set/get general kppp info
187 QString password() const; 188 QString password() const;
188 void setPassword(const QString &); 189 void setPassword(const QString &);
189 190
190 const QString defaultAccount(); 191 const QString defaultAccount();
191 void setDefaultAccount(const QString &); 192 void setDefaultAccount(const QString &);
192 193
193 void set_xserver_exit_disconnect(bool set); 194 void set_xserver_exit_disconnect(bool set);
194 bool get_xserver_exit_disconnect(); 195 bool get_xserver_exit_disconnect();
195 196
196 void setPPPDebug(bool set); 197 void setPPPDebug(bool set);
197 bool getPPPDebug(); 198 bool getPPPDebug();
198 199
199 void set_quit_on_disconnect(bool); 200 void set_quit_on_disconnect(bool);
200 bool quit_on_disconnect(); 201 bool quit_on_disconnect();
201 202
202 void set_show_clock_on_caption(bool set); 203 void set_show_clock_on_caption(bool set);
203 bool get_show_clock_on_caption(); 204 bool get_show_clock_on_caption();
204 205
205 void set_show_log_window(bool set); 206 void set_show_log_window(bool set);
206 bool get_show_log_window(); 207 bool get_show_log_window();
207 208
208 void set_automatic_redial(bool set); 209 void set_automatic_redial(bool set);
209 bool automatic_redial(); 210 bool automatic_redial();
210 211
211 void set_iconify_on_connect(bool set); 212 void set_iconify_on_connect(bool set);
212 bool get_iconify_on_connect(); 213 bool get_iconify_on_connect();
213 214
214 void set_dock_into_panel(bool set); 215 void set_dock_into_panel(bool set);
215 bool get_dock_into_panel(); 216 bool get_dock_into_panel();
216 217
217 const QString enter(); 218 const QString enter();
218 void setEnter(const QString &); 219 void setEnter(const QString &);
219 220
220 QString pppdVersion(); 221 QString pppdVersion();
221 bool pppdVersionMin(int ver, int mod, int patch); 222 bool pppdVersionMin(int ver, int mod, int patch);
222 223
223 int pppdTimeout(); 224 int pppdTimeout();
224 void setpppdTimeout(int); 225 void setpppdTimeout(int);
225 226
226 int busyWait(); 227 int busyWait();
227 void setbusyWait(int); 228 void setbusyWait(int);
228 229
229 bool modemLockFile(); 230 bool modemLockFile();
230 void setModemLockFile(bool set); 231 void setModemLockFile(bool set);
231 232
232 int modemEscapeGuardTime(); 233 int modemEscapeGuardTime();
233 void setModemEscapeGuardTime(int i); 234 void setModemEscapeGuardTime(int i);
234 235
235 void setModemEscapeStr(const QString &); 236 void setModemEscapeStr(const QString &);
236 const QString modemEscapeStr(); 237 const QString modemEscapeStr();
237 238
238 void setModemEscapeResp(const QString &); 239 void setModemEscapeResp(const QString &);
239 const QString modemEscapeResp(); 240 const QString modemEscapeResp();
240 241
241 const QString modemDevice(); 242 const QString modemDevice();
242 void setModemDevice(const QString &); 243 void setModemDevice(const QString &);
243 244
244 const QString flowcontrol(); 245 const QString flowcontrol();
245 void setFlowcontrol(const QString &); 246 void setFlowcontrol(const QString &);
246 247
247 int modemTimeout(); 248 int modemTimeout();
248 void setModemTimeout(int); 249 void setModemTimeout(int);
249 250
250 int modemToneDuration(); 251 int modemToneDuration();
251 void setModemToneDuration(int); 252 void setModemToneDuration(int);
252 253
253 QString volumeInitString(); 254 QString volumeInitString();
254 int volume(); 255 int volume();
255 void setVolume(int); 256 void setVolume(int);
256 257
257 int waitForDialTone(); 258 int waitForDialTone();
258 void setWaitForDialTone(int i); 259 void setWaitForDialTone(int i);
259 260
260 // modem command strings/responses 261 // modem command strings/responses
261 const QString modemInitStr(int i); 262 const QString modemInitStr(int i);
262 void setModemInitStr(int i, const QString &); 263 void setModemInitStr(int i, const QString &);
263 264
264 const QString modemInitResp(); 265 const QString modemInitResp();
265 void setModemInitResp(const QString &); 266 void setModemInitResp(const QString &);
266 267
267 int modemPreInitDelay(); 268 int modemPreInitDelay();
@@ -333,133 +334,134 @@ public:
333 void setAccname(const QString &); 334 void setAccname(const QString &);
334 335
335 QStringList &phonenumbers(); 336 QStringList &phonenumbers();
336 const QString phonenumber(); 337 const QString phonenumber();
337 void setPhonenumber(const QString &); 338 void setPhonenumber(const QString &);
338 339
339 const QString dialPrefix(); 340 const QString dialPrefix();
340 void setDialPrefix(const QString &); 341 void setDialPrefix(const QString &);
341 342
342 int authMethod(); 343 int authMethod();
343 void setAuthMethod(int); 344 void setAuthMethod(int);
344 345
345 const QString storedUsername(); 346 const QString storedUsername();
346 void setStoredUsername(const QString &); 347 void setStoredUsername(const QString &);
347 348
348 const QString storedPassword(); 349 const QString storedPassword();
349 void setStoredPassword(const QString &); 350 void setStoredPassword(const QString &);
350 351
351 bool storePassword(); 352 bool storePassword();
352 void setStorePassword(bool); 353 void setStorePassword(bool);
353 354
354 const QString speed(); 355 const QString speed();
355 void setSpeed(const QString &); 356 void setSpeed(const QString &);
356 357
357 const QString command_before_connect(); 358 const QString command_before_connect();
358 void setCommand_before_connect(const QString &); 359 void setCommand_before_connect(const QString &);
359 360
360 const QString command_on_connect(); 361 const QString command_on_connect();
361 void setCommand_on_connect(const QString &); 362 void setCommand_on_connect(const QString &);
362 363
363 const QString command_on_disconnect(); 364 const QString command_on_disconnect();
364 void setCommand_on_disconnect(const QString &); 365 void setCommand_on_disconnect(const QString &);
365 366
366 const QString command_before_disconnect(); 367 const QString command_before_disconnect();
367 void setCommand_before_disconnect(const QString &); 368 void setCommand_before_disconnect(const QString &);
368 369
369 const QString ipaddr(); 370 const QString ipaddr();
370 void setIpaddr(const QString &); 371 void setIpaddr(const QString &);
371 372
372 const QString subnetmask(); 373 const QString subnetmask();
373 void setSubnetmask(const QString &); 374 void setSubnetmask(const QString &);
374 375
375 bool AcctEnabled(); 376 bool AcctEnabled();
376 void setAcctEnabled(bool set); 377 void setAcctEnabled(bool set);
377 378
378 int VolAcctEnabled(); 379 int VolAcctEnabled();
379 void setVolAcctEnabled(int set); 380 void setVolAcctEnabled(int set);
380 381
381 bool autoDNS(); 382 bool autoDNS();
382 void setAutoDNS(bool set); 383 void setAutoDNS(bool set);
383 384
384 bool exDNSDisabled(); 385 bool exDNSDisabled();
385 void setExDNSDisabled(bool set); 386 void setExDNSDisabled(bool set);
386 387
387 bool autoname(); 388 bool autoname();
388 void setAutoname(bool set); 389 void setAutoname(bool set);
389 390
390 const QString gateway(); 391 const QString gateway();
391 void setGateway(const QString &); 392 void setGateway(const QString &);
392 393
393 bool defaultroute(); 394 bool defaultroute();
394 void setDefaultroute(bool set); 395 void setDefaultroute(bool set);
395 396
396 QStringList &dns(); 397 QStringList &dns();
397 void setDns(QStringList &); 398 void setDns(QStringList &);
398 399
399 const QString domain(); 400 const QString domain();
400 void setDomain(const QString &); 401 void setDomain(const QString &);
401 402
402 QStringList &scriptType(); 403 QStringList &scriptType();
403 void setScriptType(QStringList &); 404 void setScriptType(QStringList &);
404 405
405 QStringList &script(); 406 QStringList &script();
406 void setScript(QStringList &); 407 void setScript(QStringList &);
407 408
408 QStringList &pppdArgument(); 409 QStringList &pppdArgument();
409 void setpppdArgumentDefaults(); 410 void setpppdArgumentDefaults();
410 void setpppdArgument(QStringList &); 411 void setpppdArgument(QStringList &);
411 412
412 //functions to change/set the child pppd process info 413 //functions to change/set the child pppd process info
413 bool pppdRunning() const; 414 bool pppdRunning() const;
414 void setpppdRunning(bool set); 415 void setpppdRunning(bool set);
415 416
416 int pppdError() const; 417 int pppdError() const;
417 void setpppdError(int err); 418 void setpppdError(int err);
418 419
419 // functions to set/query the accounting info 420 // functions to set/query the accounting info
420 const QString accountingFile(); 421 const QString accountingFile();
421 void setAccountingFile(const QString &); 422 void setAccountingFile(const QString &);
422 423
423 const QString totalCosts(); 424 const QString totalCosts();
424 void setTotalCosts(const QString &); 425 void setTotalCosts(const QString &);
425 426
426 int totalBytes(); 427 int totalBytes();
427 void setTotalBytes(int); 428 void setTotalBytes(int);
428 429
429 // graphing widget 430// // graphing widget
430 void setGraphingOptions(bool enabled, 431// void setGraphingOptions(bool enabled,
431 QColor bg, 432 // QColor bg,
432 QColor text, 433 // QColor text,
433 QColor in, 434 // QColor in,
434 QColor out); 435 // QColor out);
435 void graphingOptions(bool &enabled, 436// void graphingOptions(bool &enabled,
436 QColor &bg, 437 // QColor &bg,
437 QColor &text, 438 // QColor &text,
438 QColor &in, 439 // QColor &in,
439 QColor &out); 440 // QColor &out);
440 bool graphingEnabled(); 441// bool graphingEnabled();
441 442
442 // window positions 443// // window positions
443 void winPosConWin(int &, int &); 444// void winPosConWin(int &, int &);
444 void setWinPosConWin(int, int); 445// void setWinPosConWin(int, int);
445 void winPosStatWin(int &, int &); 446// void winPosStatWin(int &, int &);
446 void setWinPosStatWin(int, int); 447// void setWinPosStatWin(int, int);
447 448
448private: 449private:
449 QString passwd;
450 Config* config; // configuration object
451 int highcount; // index of highest account
452 int caccount; // index of the current account
453 QString cgroup; // name of current config group
454 pid_t suidprocessid; // process ID of setuid child
455 bool pppdisrunning; // pppd process
456 // daemon
457 int pppderror; // error encounterd running pppd
458 int pppdVer, pppdMod, pppdPatch; // pppd version
459
460 QStringList phonelist;
461};
462 450
463extern PPPData gpppdata; 451 static PPPData *_data;
452
453 QString passwd;
454 static Config* config; // configuration object
455 int highcount; // index of highest account
456 int caccount; // index of the current account
457 QString cgroup; // name of current config group
458 pid_t suidprocessid; // process ID of setuid child
459 bool pppdisrunning; // pppd process
460 // daemon
461 int pppderror; // error encounterd running pppd
462 int pppdVer, pppdMod, pppdPatch; // pppd version
463
464 QStringList phonelist;
465};
464 466
465#endif 467#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index d6ca88a..da17e26 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,120 +1,121 @@
1#include "pppconfig.h" 1#include "pppconfig.h"
2#include "pppmodule.h" 2#include "pppmodule.h"
3//#include "pppimp.h" 3#include "pppdata.h"
4#include "kpppwidget.h" 4#include "kpppwidget.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6//#include "devices.h" 6//#include "devices.h"
7 7
8/** 8/**
9 * Constructor, find all of the possible interfaces 9 * Constructor, find all of the possible interfaces
10 */ 10 */
11PPPModule::PPPModule() : Module() { 11PPPModule::PPPModule() : Module() {
12} 12}
13 13
14/** 14/**
15 * Delete any interfaces that we own. 15 * Delete any interfaces that we own.
16 */ 16 */
17PPPModule::~PPPModule(){ 17PPPModule::~PPPModule(){
18 Interface *i; 18 Interface *i;
19 for ( i=list.first(); i != 0; i=list.next() ) 19 for ( i=list.first(); i != 0; i=list.next() )
20 delete i; 20 delete i;
21} 21}
22 22
23/** 23/**
24 * Change the current profile 24 * Change the current profile
25 */ 25 */
26void PPPModule::setProfile(const QString &newProfile){ 26void PPPModule::setProfile(const QString &newProfile){
27 profile = newProfile; 27 profile = newProfile;
28} 28}
29 29
30/** 30/**
31 * get the icon name for this device. 31 * get the icon name for this device.
32 * @param Interface* can be used in determining the icon. 32 * @param Interface* can be used in determining the icon.
33 * @return QString the icon name (minus .png, .gif etc) 33 * @return QString the icon name (minus .png, .gif etc)
34 */ 34 */
35QString PPPModule::getPixmapName(Interface* ){ 35QString PPPModule::getPixmapName(Interface* ){
36 return "ppp"; 36 return "ppp";
37} 37}
38 38
39/** 39/**
40 * Check to see if the interface i is owned by this module. 40 * Check to see if the interface i is owned by this module.
41 * @param Interface* interface to check against 41 * @param Interface* interface to check against
42 * @return bool true if i is owned by this module, false otherwise. 42 * @return bool true if i is owned by this module, false otherwise.
43 */ 43 */
44bool PPPModule::isOwner(Interface *i){ 44bool PPPModule::isOwner(Interface *i){
45 if(!i->getInterfaceName().upper().contains("PPP")) 45 if(!i->getInterfaceName().upper().contains("PPP"))
46 return false; 46 return false;
47 47
48 i->setHardwareName("PPP"); 48 i->setHardwareName("PPP");
49 list.append(i); 49 list.append(i);
50 return true; 50 return true;
51} 51}
52 52
53/** 53/**
54 * Create, and return the WLANConfigure Module 54 * Create, and return the WLANConfigure Module
55 * @return QWidget* pointer to this modules configure. 55 * @return QWidget* pointer to this modules configure.
56 */ 56 */
57QWidget *PPPModule::configure(Interface *i){ 57QWidget *PPPModule::configure(Interface *i){
58 qDebug("return ModemWidget"); 58 qDebug("return ModemWidget");
59 PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose ); 59 PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, Qt::WDestructiveClose );
60// pppconfig->setProfile(profile); 60// pppconfig->setProfile(profile);
61 return pppconfig; 61 return pppconfig;
62} 62}
63 63
64/** 64/**
65 * Create, and return the Information Module 65 * Create, and return the Information Module
66 * @return QWidget* pointer to this modules info. 66 * @return QWidget* pointer to this modules info.
67 */ 67 */
68QWidget *PPPModule::information(Interface *i){ 68QWidget *PPPModule::information(Interface *i){
69 // We don't have any advanced pppd information widget yet :-D 69 // We don't have any advanced pppd information widget yet :-D
70 // TODO ^ 70 // TODO ^
71 qDebug("return PPPModule::information"); 71 qDebug("return PPPModule::information");
72 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); 72 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
73 return information; 73 return information;
74} 74}
75 75
76/** 76/**
77 * Get all active (up or down) interfaces 77 * Get all active (up or down) interfaces
78 * @return QList<Interface> A list of interfaces that exsist that havn't 78 * @return QList<Interface> A list of interfaces that exsist that havn't
79 * been called by isOwner() 79 * been called by isOwner()
80 */ 80 */
81QList<Interface> PPPModule::getInterfaces(){ 81QList<Interface> PPPModule::getInterfaces(){
82 // List all of the files in the peer directory 82 // List all of the files in the peer directory
83 return list; 83 return list;
84} 84}
85 85
86/** 86/**
87 * Attempt to add a new interface as defined by name 87 * Attempt to add a new interface as defined by name
88 * @param name the name of the type of interface that should be created given 88 * @param name the name of the type of interface that should be created given
89 * by possibleNewInterfaces(); 89 * by possibleNewInterfaces();
90 * @return Interface* NULL if it was unable to be created. 90 * @return Interface* NULL if it was unable to be created.
91 */ 91 */
92Interface *PPPModule::addNewInterface(const QString &newInterface){ 92Interface *PPPModule::addNewInterface(const QString &newInterface){
93 93
94 qDebug("try to add iface %s",newInterface.latin1()); 94 qDebug("try to add iface %s",newInterface.latin1());
95 95
96 PPPConfigWidget imp(0, "PPPConfigImp", true); 96 PPPConfigWidget imp(0, "PPPConfigImp", true);
97 imp.showMaximized(); 97 imp.showMaximized();
98 if(imp.exec() == QDialog::Accepted ){ 98 if(imp.exec() == QDialog::Accepted ){
99 qDebug("ACCEPTED"); 99 qDebug("ACCEPTED");
100 return new Interface( 0, newInterface ); 100 return new Interface( 0, newInterface );
101 PPPData::data()->save();
101 } 102 }
102 return NULL; 103 return NULL;
103} 104}
104 105
105/** 106/**
106 * Attempts to remove the interface, doesn't delete i 107 * Attempts to remove the interface, doesn't delete i
107 * @return bool true if successfull, false otherwise. 108 * @return bool true if successfull, false otherwise.
108 */ 109 */
109bool PPPModule::remove(Interface*){ 110bool PPPModule::remove(Interface*){
110 // Can't remove a hardware device, you can stop it though. 111 // Can't remove a hardware device, you can stop it though.
111 return false; 112 return false;
112} 113}
113 114
114void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 115void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
115{ 116{
116 qDebug("here"); 117 qDebug("here");
117 newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device")); 118 newIfaces.insert(QObject::tr("PPP") ,QObject::tr("generic ppp device"));
118} 119}
119 120
120 121