author | tille <tille> | 2003-06-03 14:08:04 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-03 14:08:04 (UTC) |
commit | 60d9f66d2b31c659ac652c15423ecaca89a5f312 (patch) (unidiff) | |
tree | bfda269b58eb1c72893057d9d7fae5a6a2e45abc | |
parent | aaf7709f64dda5a6cb81eeb96e421ba4189654d6 (diff) | |
download | opie-60d9f66d2b31c659ac652c15423ecaca89a5f312.zip opie-60d9f66d2b31c659ac652c15423ecaca89a5f312.tar.gz opie-60d9f66d2b31c659ac652c15423ecaca89a5f312.tar.bz2 |
authentication (except when passwd not stored)
and minor things
17 files changed, 313 insertions, 156 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 5635438..80fc5a6 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,7 +1,9 @@ | |||
1 | - add possibility to input username and password ;) | 1 | - ask for password is non is set |
2 | - impl. PPPData::copyaccount & PPPData::deleteAccount | 2 | |
3 | - stop pppd, i.e. fix interfaceinformationppp | ||
4 | |||
3 | - update modem attribute inputs when modem has changed | 5 | - update modem attribute inputs when modem has changed |
4 | - fix layout of edit account, i.e. get it shown maximised | 6 | - impl. PPPData::copyaccount & PPPData::deleteAccount |
5 | - popup configure modem with the correct account prselected | ||
6 | not quite shure why it does not work... IMHO it should work | ||
7 | 7 | ||
8 | - check if the same interface device combination allready exists | ||
9 | - fix layout of edit account, i.e. get it shown maximised | ||
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index f704c84..7760d5e 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -1,384 +1,355 @@ | |||
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 <qvgroupbox.h> | 38 | #include <qvgroupbox.h> |
39 | 39 | ||
40 | #include "pppdata.h" | ||
41 | #include "accounts.h" | 40 | #include "accounts.h" |
41 | #include "authwidget.h" | ||
42 | #include "pppdata.h" | ||
42 | #include "edit.h" | 43 | #include "edit.h" |
43 | 44 | ||
44 | void parseargs(char* buf, char** args); | 45 | void parseargs(char* buf, char** args); |
45 | 46 | ||
46 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) | 47 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) |
47 | : QWidget( parent, name ), _pppdata(pd) | 48 | : QWidget( parent, name )//, _pppdata(pd) |
48 | { | 49 | { |
50 | _pppdata = pd; | ||
49 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 51 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
50 | accountlist_l = new QListBox(this); | 52 | accountlist_l = new QListBox(this); |
51 | 53 | ||
52 | connect(accountlist_l, SIGNAL(highlighted(int)), | 54 | connect(accountlist_l, SIGNAL(highlighted(int)), |
53 | this, SLOT(slotListBoxSelect(int))); | 55 | this, SLOT(slotListBoxSelect(int))); |
54 | connect(accountlist_l, SIGNAL(selected(int)), | 56 | connect(accountlist_l, SIGNAL(selected(int)), |
55 | this, SLOT(editaccount())); | 57 | this, SLOT(editaccount())); |
56 | l1->addWidget(accountlist_l, 10); | 58 | l1->addWidget(accountlist_l, 10); |
57 | 59 | ||
58 | edit_b = new QPushButton(tr("&Edit..."), this); | 60 | edit_b = new QPushButton(tr("&Edit..."), this); |
59 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | 61 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); |
60 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); | 62 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); |
61 | l1->addWidget(edit_b); | 63 | l1->addWidget(edit_b); |
62 | 64 | ||
63 | new_b = new QPushButton(tr("&New..."), this); | 65 | new_b = new QPushButton(tr("&New..."), this); |
64 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); | 66 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); |
65 | l1->addWidget(new_b); | 67 | l1->addWidget(new_b); |
66 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" | 68 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" |
67 | "to the Internet")); | 69 | "to the Internet")); |
68 | 70 | ||
69 | copy_b = new QPushButton(tr("Co&py"), this); | 71 | copy_b = new QPushButton(tr("Co&py"), this); |
70 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); | 72 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); |
71 | l1->addWidget(copy_b); | 73 | l1->addWidget(copy_b); |
72 | QWhatsThis::add(copy_b, | 74 | QWhatsThis::add(copy_b, |
73 | tr("Makes a copy of the selected account. All\n" | 75 | tr("Makes a copy of the selected account. All\n" |
74 | "settings of the selected account are copied\n" | 76 | "settings of the selected account are copied\n" |
75 | "to a new account, that you can modify to fit your\n" | 77 | "to a new account, that you can modify to fit your\n" |
76 | "needs")); | 78 | "needs")); |
77 | 79 | ||
78 | delete_b = new QPushButton(tr("De&lete"), this); | 80 | delete_b = new QPushButton(tr("De&lete"), this); |
79 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); | 81 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); |
80 | l1->addWidget(delete_b); | 82 | l1->addWidget(delete_b); |
81 | QWhatsThis::add(delete_b, | 83 | QWhatsThis::add(delete_b, |
82 | tr("<p>Deletes the selected account\n\n" | 84 | tr("<p>Deletes the selected account\n\n" |
83 | "<font color=\"red\"><b>Use with care!</b></font>")); | 85 | "<font color=\"red\"><b>Use with care!</b></font>")); |
84 | 86 | ||
85 | QHBoxLayout *l12 = new QHBoxLayout; | 87 | QHBoxLayout *l12 = new QHBoxLayout; |
86 | l1->addStretch(1); | 88 | l1->addStretch(1); |
87 | l1->addLayout(l12); | 89 | l1->addLayout(l12); |
88 | 90 | ||
91 | int currAccId = _pppdata->currentAccountID(); | ||
92 | qDebug("currentAccountID %i", currAccId); | ||
93 | |||
89 | //load up account list from gppdata to the list box | 94 | //load up account list from gppdata to the list box |
90 | if(_pppdata->count() > 0) { | 95 | if(_pppdata->count() > 0) { |
91 | for(int i=0; i <= _pppdata->count()-1; i++) { | 96 | for(int i=0; i <= _pppdata->count()-1; i++) { |
92 | _pppdata->setAccountbyIndex(i); | 97 | _pppdata->setAccountbyIndex(i); |
93 | accountlist_l->insertItem(_pppdata->accname()); | 98 | accountlist_l->insertItem(_pppdata->accname()); |
94 | } | 99 | } |
95 | } | 100 | } |
96 | 101 | _pppdata->setAccountbyIndex( currAccId ); | |
97 | 102 | ||
98 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); | 103 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); |
99 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); | 104 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); |
100 | slotListBoxSelect( _pppdata->currentAccountID()); | 105 | slotListBoxSelect( _pppdata->currentAccountID() ); |
101 | 106 | ||
102 | l1->activate(); | 107 | l1->activate(); |
103 | } | 108 | } |
104 | 109 | ||
105 | 110 | ||
106 | 111 | ||
107 | void AccountWidget::slotListBoxSelect(int idx) { | 112 | void AccountWidget::slotListBoxSelect(int idx) { |
108 | delete_b->setEnabled((bool)(idx != -1)); | 113 | delete_b->setEnabled((bool)(idx != -1)); |
109 | edit_b->setEnabled((bool)(idx != -1)); | 114 | edit_b->setEnabled((bool)(idx != -1)); |
110 | copy_b->setEnabled((bool)(idx != -1)); | 115 | copy_b->setEnabled((bool)(idx != -1)); |
111 | if(idx!=-1) { | 116 | if(idx!=-1) { |
112 | qDebug("setting account to %i", idx); | 117 | qDebug("setting account to %i", idx); |
113 | QString account = _pppdata->accname(); | 118 | QString account = _pppdata->accname(); |
114 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); | 119 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); |
115 | // _pppdata->setAccount(account); | ||
116 | } | 120 | } |
117 | } | 121 | } |
118 | 122 | ||
119 | |||
120 | // void AccountWidget::viewLogClicked(){ | ||
121 | |||
122 | // QApplication::flushX(); | ||
123 | // if(fork() == 0) { | ||
124 | // setgid(getgid()); | ||
125 | // setuid(getuid()); | ||
126 | // system("kppplogview -kppp"); | ||
127 | // _exit(0); | ||
128 | // } | ||
129 | // } | ||
130 | |||
131 | |||
132 | // void AccountWidget::resetClicked(){ | ||
133 | // if(accountlist_l->currentItem() == -1) | ||
134 | // return; | ||
135 | |||
136 | // // QueryReset dlg(this); | ||
137 | // // int what = dlg.exec(); | ||
138 | |||
139 | // // if(what && QueryReset::COSTS) { | ||
140 | // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); | ||
141 | // // costedit->setText("0"); | ||
142 | // // } | ||
143 | |||
144 | // // if(what && QueryReset::VOLUME) { | ||
145 | // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); | ||
146 | // // voledit->setText(prettyPrintVolume(0)); | ||
147 | // // } | ||
148 | // } | ||
149 | |||
150 | |||
151 | void AccountWidget::editaccount() { | 123 | void AccountWidget::editaccount() { |
152 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 124 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); |
153 | 125 | ||
154 | int result = doTab(); | 126 | int result = doTab(); |
155 | 127 | ||
156 | if(result == QDialog::Accepted) { | 128 | if(result == QDialog::Accepted) { |
157 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); | 129 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); |
158 | // emit resetaccounts(); | 130 | // emit resetaccounts(); |
159 | _pppdata->save(); | 131 | _pppdata->save(); |
160 | } | 132 | } |
161 | } | 133 | } |
162 | 134 | ||
163 | 135 | ||
164 | void AccountWidget::newaccount() { | 136 | void AccountWidget::newaccount() { |
165 | 137 | ||
166 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 138 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
167 | QMessageBox::information(this, "sorry", | 139 | QMessageBox::information(this, "sorry", |
168 | tr("Maximum number of accounts reached.")); | 140 | tr("Maximum number of accounts reached.")); |
169 | return; | 141 | return; |
170 | } | 142 | } |
171 | 143 | ||
172 | int result; | 144 | int result; |
173 | if (_pppdata->newaccount() == -1){ | 145 | if (_pppdata->newaccount() == -1){ |
174 | qDebug("_pppdata->newaccount() == -1"); | 146 | qDebug("_pppdata->newaccount() == -1"); |
175 | return; | 147 | return; |
176 | } | 148 | } |
177 | result = doTab(); | 149 | result = doTab(); |
178 | 150 | ||
179 | if(result == QDialog::Accepted) { | 151 | if(result == QDialog::Accepted) { |
180 | accountlist_l->insertItem(_pppdata->accname()); | 152 | accountlist_l->insertItem(_pppdata->accname()); |
181 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); | 153 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); |
182 | 154 | ||
183 | _pppdata->save(); | 155 | _pppdata->save(); |
184 | } else | 156 | } else |
185 | _pppdata->deleteAccount(); | 157 | _pppdata->deleteAccount(); |
186 | } | 158 | } |
187 | 159 | ||
188 | 160 | ||
189 | void AccountWidget::copyaccount() { | 161 | void AccountWidget::copyaccount() { |
190 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 162 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
191 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 163 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
192 | return; | 164 | return; |
193 | } | 165 | } |
194 | 166 | ||
195 | if(accountlist_l->currentItem()<0) { | 167 | if(accountlist_l->currentItem()<0) { |
196 | QMessageBox::information(this, "sorry", tr("No account selected.")); | 168 | QMessageBox::information(this, "sorry", tr("No account selected.")); |
197 | return; | 169 | return; |
198 | } | 170 | } |
199 | 171 | ||
200 | _pppdata->copyaccount(accountlist_l->currentItem()); | 172 | _pppdata->copyaccount(accountlist_l->currentItem()); |
201 | 173 | ||
202 | accountlist_l->insertItem(_pppdata->accname()); | 174 | accountlist_l->insertItem(_pppdata->accname()); |
203 | // emit resetaccounts(); | 175 | // emit resetaccounts(); |
204 | _pppdata->save(); | 176 | _pppdata->save(); |
205 | } | 177 | } |
206 | 178 | ||
207 | 179 | ||
208 | void AccountWidget::deleteaccount() { | 180 | void AccountWidget::deleteaccount() { |
209 | 181 | ||
210 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") | 182 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") |
211 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 183 | .arg(accountlist_l->text(accountlist_l->currentItem())); |
212 | 184 | ||
213 | if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes) | 185 | if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes) |
214 | return; | 186 | return; |
215 | 187 | ||
216 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 188 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) |
217 | accountlist_l->removeItem(accountlist_l->currentItem()); | 189 | accountlist_l->removeItem(accountlist_l->currentItem()); |
218 | 190 | ||
219 | emit resetaccounts(); | 191 | emit resetaccounts(); |
220 | _pppdata->save(); | 192 | _pppdata->save(); |
221 | 193 | ||
222 | slotListBoxSelect(accountlist_l->currentItem()); | 194 | slotListBoxSelect(accountlist_l->currentItem()); |
223 | 195 | ||
224 | } | 196 | } |
225 | 197 | ||
226 | 198 | ||
227 | int AccountWidget::doTab(){ | 199 | int AccountWidget::doTab(){ |
228 | QDialog *dlg = new QDialog( 0, "newAccount", true ); | 200 | QDialog *dlg = new QDialog( 0, "newAccount", true ); |
229 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 201 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
230 | layout->setSpacing( 0 ); | 202 | layout->setSpacing( 0 ); |
231 | layout->setMargin( 1 ); | 203 | layout->setMargin( 1 ); |
232 | 204 | ||
233 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 205 | tabWindow = new QTabWidget( dlg, "tabWindow" ); |
234 | layout->addWidget( tabWindow ); | 206 | layout->addWidget( tabWindow ); |
235 | 207 | ||
236 | bool isnewaccount; | 208 | bool isnewaccount; |
237 | 209 | ||
238 | if(_pppdata->accname().isEmpty()) { | 210 | if(_pppdata->accname().isEmpty()) { |
239 | dlg->setCaption(tr("New Account")); | 211 | dlg->setCaption(tr("New Account")); |
240 | isnewaccount = true; | 212 | isnewaccount = true; |
241 | } else { | 213 | } else { |
242 | QString tit = tr("Edit Account: "); | 214 | QString tit = tr("Edit Account: "); |
243 | tit += _pppdata->accname(); | 215 | tit += _pppdata->accname(); |
244 | dlg->setCaption(tit); | 216 | dlg->setCaption(tit); |
245 | isnewaccount = false; | 217 | isnewaccount = false; |
246 | } | 218 | } |
247 | 219 | ||
248 | // // DIAL WIDGET | 220 | // // DIAL WIDGET |
249 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); | 221 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
250 | tabWindow->addTab( dial_w, tr("Dial") ); | 222 | tabWindow->addTab( dial_w, tr("Dial") ); |
251 | 223 | ||
224 | // // AUTH WIDGET | ||
225 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); | ||
226 | tabWindow->addTab( auth_w, tr("Authentication") ); | ||
227 | |||
252 | // // IP WIDGET | 228 | // // IP WIDGET |
253 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); | 229 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); |
254 | tabWindow->addTab( ip_w, tr("IP") ); | 230 | tabWindow->addTab( ip_w, tr("IP") ); |
255 | 231 | ||
256 | // // GATEWAY WIDGET | 232 | // // GATEWAY WIDGET |
257 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); | 233 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); |
258 | tabWindow->addTab( gateway_w, tr("Gateway") ); | 234 | tabWindow->addTab( gateway_w, tr("Gateway") ); |
259 | 235 | ||
260 | // // DNS WIDGET | 236 | // // DNS WIDGET |
261 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); | 237 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); |
262 | tabWindow->addTab( dns_w, tr("DNS") ); | 238 | tabWindow->addTab( dns_w, tr("DNS") ); |
263 | 239 | ||
264 | // // SCRIPT WIDGET | ||
265 | script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); | ||
266 | tabWindow->addTab( script_w, tr("Login Script") ); | ||
267 | |||
268 | // // EXECUTE WIDGET | 240 | // // EXECUTE WIDGET |
269 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); | 241 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); |
270 | tabWindow->addTab( exec_w, tr("Execute") ); | 242 | tabWindow->addTab( exec_w, tr("Execute") ); |
271 | 243 | ||
272 | int result = 0; | 244 | int result = 0; |
273 | bool ok = false; | 245 | bool ok = false; |
274 | 246 | ||
275 | while (!ok){ | 247 | while (!ok){ |
276 | // dlg->showMinimized(); | 248 | // dlg->showMinimized(); |
277 | result = dlg->exec(); | 249 | result = dlg->exec(); |
278 | ok = true; | 250 | ok = true; |
279 | 251 | ||
280 | if(result == QDialog::Accepted) { | 252 | if(result == QDialog::Accepted) { |
281 | if (!script_w->check()){ | 253 | if (!auth_w->check()){ |
282 | QMessageBox::critical(this, "error", tr("<qt>Login script has unbalanced loop Start/End<qt>")); | ||
283 | ok = false; | 254 | ok = false; |
284 | } else if(!dial_w->save()) { | 255 | } else if(!dial_w->save()) { |
285 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); | 256 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); |
286 | ok = false; | 257 | ok = false; |
287 | }else{ | 258 | }else{ |
288 | ip_w->save(); | 259 | ip_w->save(); |
289 | dns_w->save(); | 260 | dns_w->save(); |
290 | gateway_w->save(); | 261 | gateway_w->save(); |
291 | script_w->save(); | 262 | auth_w->save(); |
292 | exec_w->save(); | 263 | exec_w->save(); |
293 | } | 264 | } |
294 | } | 265 | } |
295 | } | 266 | } |
296 | 267 | ||
297 | delete dlg; | 268 | delete dlg; |
298 | 269 | ||
299 | return result; | 270 | return result; |
300 | } | 271 | } |
301 | 272 | ||
302 | 273 | ||
303 | QString AccountWidget::prettyPrintVolume(unsigned int n) { | 274 | QString AccountWidget::prettyPrintVolume(unsigned int n) { |
304 | int idx = 0; | 275 | int idx = 0; |
305 | const QString quant[] = {tr("Byte"), tr("KB"), | 276 | const QString quant[] = {tr("Byte"), tr("KB"), |
306 | tr("MB"), tr("GB"), QString::null}; | 277 | tr("MB"), tr("GB"), QString::null}; |
307 | 278 | ||
308 | float n1 = n; | 279 | float n1 = n; |
309 | while(n >= 1024 && quant[idx] != QString::null) { | 280 | while(n >= 1024 && quant[idx] != QString::null) { |
310 | idx++; | 281 | idx++; |
311 | n /= 1024; | 282 | n /= 1024; |
312 | } | 283 | } |
313 | 284 | ||
314 | int i = idx; | 285 | int i = idx; |
315 | while(i--) | 286 | while(i--) |
316 | n1 = n1 / 1024.0; | 287 | n1 = n1 / 1024.0; |
317 | 288 | ||
318 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); | 289 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); |
319 | s += " " + quant[idx]; | 290 | s += " " + quant[idx]; |
320 | return s; | 291 | return s; |
321 | } | 292 | } |
322 | 293 | ||
323 | 294 | ||
324 | ///////////////////////////////////////////////////////////////////////////// | 295 | ///////////////////////////////////////////////////////////////////////////// |
325 | // | 296 | // |
326 | // Queries the user what to reset: costs, volume or both | 297 | // Queries the user what to reset: costs, volume or both |
327 | // | 298 | // |
328 | ///////////////////////////////////////////////////////////////////////////// | 299 | ///////////////////////////////////////////////////////////////////////////// |
329 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { | 300 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { |
330 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 301 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
331 | // setCaption(tr("Reset Accounting")); | 302 | // setCaption(tr("Reset Accounting")); |
332 | 303 | ||
333 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 304 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
334 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); | 305 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); |
335 | 306 | ||
336 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 307 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
337 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); | 308 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); |
338 | // // costs->setChecked(true); | 309 | // // costs->setChecked(true); |
339 | // // l1->addWidget(costs); | 310 | // // l1->addWidget(costs); |
340 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" | 311 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" |
341 | // // "to zero. Typically you'll want to\n" | 312 | // // "to zero. Typically you'll want to\n" |
342 | // // "do this once a month.")); | 313 | // // "do this once a month.")); |
343 | 314 | ||
344 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); | 315 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); |
345 | // // volume->setChecked(true); | 316 | // // volume->setChecked(true); |
346 | // // l1->addWidget(volume); | 317 | // // l1->addWidget(volume); |
347 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" | 318 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" |
348 | // // "to zero. Typically you'll want to do this\n" | 319 | // // "to zero. Typically you'll want to do this\n" |
349 | // // "once a month.")); | 320 | // // "once a month.")); |
350 | 321 | ||
351 | // l1->activate(); | 322 | // l1->activate(); |
352 | 323 | ||
353 | // // this activates the f-layout and sets minimumSize() | 324 | // // this activates the f-layout and sets minimumSize() |
354 | // f->show(); | 325 | // f->show(); |
355 | 326 | ||
356 | // tl->addWidget(f); | 327 | // tl->addWidget(f); |
357 | 328 | ||
358 | // QButtonGroup *bbox = new QButtonGroup(this); | 329 | // QButtonGroup *bbox = new QButtonGroup(this); |
359 | // // bbox->addStretch(1); | 330 | // // bbox->addStretch(1); |
360 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); | 331 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); |
361 | // bbox->insert(ok); | 332 | // bbox->insert(ok); |
362 | // ok->setDefault(true); | 333 | // ok->setDefault(true); |
363 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); | 334 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); |
364 | // bbox->insert(cancel); | 335 | // bbox->insert(cancel); |
365 | 336 | ||
366 | // connect(ok, SIGNAL(clicked()), | 337 | // connect(ok, SIGNAL(clicked()), |
367 | // this, SLOT(accepted())); | 338 | // this, SLOT(accepted())); |
368 | // connect(cancel, SIGNAL(clicked()), | 339 | // connect(cancel, SIGNAL(clicked()), |
369 | // this, SLOT(reject())); | 340 | // this, SLOT(reject())); |
370 | 341 | ||
371 | // bbox->layout(); | 342 | // bbox->layout(); |
372 | // tl->addWidget(bbox); | 343 | // tl->addWidget(bbox); |
373 | 344 | ||
374 | // } | 345 | // } |
375 | 346 | ||
376 | 347 | ||
377 | // void QueryReset::accepted() { | 348 | // void QueryReset::accepted() { |
378 | // int result = costs->isChecked() ? COSTS : 0; | 349 | // int result = costs->isChecked() ? COSTS : 0; |
379 | // result += volume->isChecked() ? VOLUME : 0; | 350 | // result += volume->isChecked() ? VOLUME : 0; |
380 | 351 | ||
381 | // done(result); | 352 | // done(result); |
382 | // } | 353 | // } |
383 | 354 | ||
384 | 355 | ||
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h index eae3922..8c16a7c 100644 --- a/noncore/settings/networksettings/ppp/accounts.h +++ b/noncore/settings/networksettings/ppp/accounts.h | |||
@@ -1,100 +1,86 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
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 | #ifndef _ACCOUNTS_H_ | 27 | #ifndef _ACCOUNTS_H_ |
28 | #define _ACCOUNTS_H_ | 28 | #define _ACCOUNTS_H_ |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qlistbox.h> | 33 | #include <qlistbox.h> |
34 | //#include "acctselect.h" | 34 | //#include "acctselect.h" |
35 | 35 | ||
36 | class QDialog; | 36 | class QDialog; |
37 | class QCheckBox; | 37 | class QCheckBox; |
38 | class QLineEdit; | 38 | class QLineEdit; |
39 | class QTabWidget; | 39 | class QTabWidget; |
40 | class DialWidget; | 40 | class DialWidget; |
41 | class ScriptWidget; | 41 | class AuthWidget; |
42 | class IPWidget; | 42 | class IPWidget; |
43 | class DNSWidget; | 43 | class DNSWidget; |
44 | class GatewayWidget; | 44 | class GatewayWidget; |
45 | class PPPData; | 45 | class PPPData; |
46 | 46 | ||
47 | class AccountWidget : public QWidget { | 47 | class AccountWidget : public QWidget { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 ); | 50 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 ); |
51 | ~AccountWidget() {} | 51 | ~AccountWidget() {} |
52 | 52 | ||
53 | private slots: | 53 | private slots: |
54 | void editaccount(); | 54 | void editaccount(); |
55 | void copyaccount(); | 55 | void copyaccount(); |
56 | void newaccount(); | 56 | void newaccount(); |
57 | void deleteaccount(); | 57 | void deleteaccount(); |
58 | void slotListBoxSelect(int); | 58 | void slotListBoxSelect(int); |
59 | 59 | ||
60 | private: | 60 | private: |
61 | int doTab(); | 61 | int doTab(); |
62 | 62 | ||
63 | signals: | 63 | signals: |
64 | void resetaccounts(); | 64 | void resetaccounts(); |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QString prettyPrintVolume(unsigned int); | 67 | QString prettyPrintVolume(unsigned int); |
68 | 68 | ||
69 | PPPData *_pppdata; | 69 | PPPData *_pppdata; |
70 | QTabWidget *tabWindow; | 70 | QTabWidget *tabWindow; |
71 | DialWidget *dial_w; | 71 | DialWidget *dial_w; |
72 | IPWidget *ip_w; | 72 | IPWidget *ip_w; |
73 | DNSWidget *dns_w; | 73 | DNSWidget *dns_w; |
74 | GatewayWidget *gateway_w; | 74 | GatewayWidget *gateway_w; |
75 | ScriptWidget *script_w; | 75 | AuthWidget *auth_w; |
76 | 76 | ||
77 | QListBox *accountlist_l; | 77 | QListBox *accountlist_l; |
78 | QPushButton *edit_b; | 78 | QPushButton *edit_b; |
79 | QPushButton *copy_b; | 79 | QPushButton *copy_b; |
80 | QPushButton *new_b; | 80 | QPushButton *new_b; |
81 | QPushButton *delete_b; | 81 | QPushButton *delete_b; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | // class QueryReset : public QDialog { | ||
86 | // Q_OBJECT | ||
87 | // public: | ||
88 | // QueryReset(QWidget *parent); | ||
89 | |||
90 | // enum {COSTS=1, VOLUME=2}; | ||
91 | |||
92 | // private slots: | ||
93 | // void accepted(); | ||
94 | |||
95 | // private: | ||
96 | // QCheckBox *costs, *volume; | ||
97 | // }; | ||
98 | |||
99 | #endif | 85 | #endif |
100 | 86 | ||
diff --git a/noncore/settings/networksettings/ppp/authwidget.cpp b/noncore/settings/networksettings/ppp/authwidget.cpp new file mode 100644 index 0000000..86bea98 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/authwidget.cpp | |||
@@ -0,0 +1,195 @@ | |||
1 | |||
2 | #include <qlayout.h> | ||
3 | #include <qmessagebox.h> | ||
4 | #include <qtoolbutton.h> | ||
5 | #include <qwhatsthis.h> | ||
6 | |||
7 | #include "auth.h" | ||
8 | #include "authwidget.h" | ||
9 | #include "edit.h" | ||
10 | #include "pppdata.h" | ||
11 | |||
12 | |||
13 | static const char* const image0_data[] = { | ||
14 | "16 16 2 1", | ||
15 | ". c None", | ||
16 | "# c #000000", | ||
17 | "................", | ||
18 | "...#...###...##.", | ||
19 | "..#.#..#..#.##..", | ||
20 | "..###..###.##...", | ||
21 | ".#...#.#..##....", | ||
22 | ".#...#.#.##.....", | ||
23 | "........##.#..#.", | ||
24 | "..##...##...##..", | ||
25 | ".#..#.###...##..", | ||
26 | ".#...##..#.#..#.", | ||
27 | ".#..##..........", | ||
28 | ".#.##.#..#.#..#.", | ||
29 | "..##...##...##..", | ||
30 | ".##....##...##..", | ||
31 | ".#....#..#.#..#.", | ||
32 | "................"}; | ||
33 | |||
34 | |||
35 | AuthWidget::AuthWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | ||
36 | : QWidget( parent, name), | ||
37 | scriptWidget(0), | ||
38 | _pppdata(pd), | ||
39 | isNewAccount(isnewaccount) | ||
40 | { | ||
41 | layout = new QGridLayout(this); | ||
42 | |||
43 | auth_l = new QLabel(tr("Authentication: "), this); | ||
44 | layout->addWidget(auth_l, 0, 0); | ||
45 | |||
46 | auth = new QComboBox(this); | ||
47 | auth->insertItem(tr("Script-based")); | ||
48 | auth->insertItem(tr("PAP")); | ||
49 | auth->insertItem(tr("Terminal-based")); | ||
50 | auth->insertItem(tr("CHAP")); | ||
51 | auth->insertItem(tr("PAP/CHAP")); | ||
52 | layout->addWidget(auth, 0, 1); | ||
53 | |||
54 | connect( auth, SIGNAL(activated(const QString&)), | ||
55 | SLOT(authChanged(const QString&))); | ||
56 | |||
57 | QString tmp = tr("<p>Specifies the method used to identify yourself to\n" | ||
58 | "the PPP server. Most universities still use\n" | ||
59 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | ||
60 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | ||
61 | "unsure, contact your ISP.\n" | ||
62 | "\n" | ||
63 | "If you can choose between PAP and CHAP,\n" | ||
64 | "choose CHAP, because it's much safer. If you don't know\n" | ||
65 | "whether PAP or CHAP is right, choose PAP/CHAP."); | ||
66 | |||
67 | QWhatsThis::add(auth_l,tmp); | ||
68 | QWhatsThis::add(auth,tmp); | ||
69 | |||
70 | user_l = new QLabel( tr("Username: "), this); | ||
71 | layout->addWidget( user_l, 1, 0 ); | ||
72 | userName = new QLineEdit( this, "usernameEdit" ); | ||
73 | layout->addWidget( userName, 1, 1 ); | ||
74 | tmp = tr("Enter your username here..."); | ||
75 | QWhatsThis::add( user_l, tmp ); | ||
76 | QWhatsThis::add( userName, tmp ); | ||
77 | |||
78 | pw_l = new QLabel( tr("Password: "), this); | ||
79 | layout->addWidget( pw_l, 2, 0 ); | ||
80 | passWord = new QLineEdit( this, "pw" ); | ||
81 | passWord->setAutoMask( true ); | ||
82 | passWord->setEchoMode( QLineEdit::Password ); | ||
83 | layout->addWidget( passWord, 2, 1 ); | ||
84 | hidePw = new QToolButton( this ); | ||
85 | hidePw->setPixmap( QPixmap( ( const char** ) image0_data ) ); | ||
86 | hidePw->setToggleButton( true ); | ||
87 | layout->addWidget( hidePw, 2, 2 ); | ||
88 | |||
89 | connect(hidePw, SIGNAL(toggled(bool)), SLOT(toggleEchoMode(bool))); | ||
90 | |||
91 | tmp = tr("Enter your password here"); | ||
92 | QWhatsThis::add( pw_l, tmp ); | ||
93 | QWhatsThis::add( passWord, tmp ); | ||
94 | |||
95 | store_password = new QCheckBox(tr("Store password"), this); | ||
96 | layout->addMultiCellWidget(store_password, 3, 3, 0, 1, AlignRight); | ||
97 | QWhatsThis::add(store_password, | ||
98 | tr("<p>When this is turned on, your ISP password\n" | ||
99 | "will be saved in <i>kppp</i>'s config file, so\n" | ||
100 | "you do not need to type it in every time.\n" | ||
101 | "\n" | ||
102 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | ||
103 | "plain text in the config file, which is\n" | ||
104 | "readable only to you. Make sure nobody\n" | ||
105 | "gains access to this file!")); | ||
106 | |||
107 | if (isNewAccount){ | ||
108 | // select PAP/CHAP as default | ||
109 | auth->setCurrentItem(AUTH_PAPCHAP); | ||
110 | store_password->setChecked(true); | ||
111 | }else{ | ||
112 | auth->setCurrentItem(_pppdata->authMethod()); | ||
113 | authChanged( auth->currentText() ); | ||
114 | userName->setText( _pppdata->storedUsername() ); | ||
115 | store_password->setChecked(_pppdata->storePassword()); | ||
116 | if (store_password->isChecked()) | ||
117 | passWord->setText( _pppdata->storedPassword() ); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | bool AuthWidget::check() | ||
122 | { | ||
123 | bool ret = true; | ||
124 | if (scriptWidget){ | ||
125 | if (!scriptWidget->check()){ | ||
126 | QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>")); | ||
127 | ret = false; | ||
128 | } | ||
129 | } | ||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | void AuthWidget::save() | ||
134 | { | ||
135 | _pppdata->setAuthMethod(auth->currentItem()); | ||
136 | if (scriptWidget) scriptWidget->save(); | ||
137 | _pppdata->setStoredUsername( userName->text() ); | ||
138 | _pppdata->setStorePassword(store_password->isChecked()); | ||
139 | if (store_password->isChecked()) | ||
140 | _pppdata->setStoredPassword( passWord->text() ); | ||
141 | } | ||
142 | |||
143 | void AuthWidget::authChanged( const QString &authStr ) | ||
144 | { | ||
145 | qDebug("AuthWidget::authChanged( %s )", authStr.latin1() ); | ||
146 | if ( authStr.contains( tr("Script-based") ) ){ | ||
147 | showUsernamePassword( false ); | ||
148 | showScriptWindow( true ); | ||
149 | } else if ( authStr.contains( tr("PAP") ) || | ||
150 | authStr.contains( tr("CHAP") ) ){ | ||
151 | showUsernamePassword( true ); | ||
152 | showScriptWindow( false ); | ||
153 | } else { | ||
154 | qDebug("do not really know how to handle"); | ||
155 | showUsernamePassword( false ); | ||
156 | showScriptWindow( false ); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | |||
161 | void AuthWidget::showUsernamePassword( bool show ) | ||
162 | { | ||
163 | if (show){ | ||
164 | user_l->show(); | ||
165 | userName->show(); | ||
166 | pw_l->show(); | ||
167 | passWord->show(); | ||
168 | store_password->show(); | ||
169 | }else{//!show | ||
170 | user_l->hide(); | ||
171 | userName->hide(); | ||
172 | pw_l->hide(); | ||
173 | passWord->hide(); | ||
174 | store_password->hide(); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | void AuthWidget::showScriptWindow( bool show ) | ||
179 | { | ||
180 | if (show){ | ||
181 | if (!scriptWidget){ | ||
182 | scriptWidget = new ScriptWidget( _pppdata, this, isNewAccount, "scriptWid"); | ||
183 | layout->addMultiCellWidget( scriptWidget, 1, 4, 0, 1 ); | ||
184 | } | ||
185 | scriptWidget->show(); | ||
186 | }else{ // !show | ||
187 | if (scriptWidget) scriptWidget->hide(); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | void AuthWidget::toggleEchoMode( bool t ) | ||
192 | { | ||
193 | passWord->setEchoMode( t ? QLineEdit::Normal : QLineEdit::Password ); | ||
194 | } | ||
195 | |||
diff --git a/noncore/settings/networksettings/ppp/authwidget.h b/noncore/settings/networksettings/ppp/authwidget.h new file mode 100644 index 0000000..33ec4c2 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/authwidget.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef _AUTHWIDGET_H | ||
2 | #define _AUTHWIDGET_H | ||
3 | |||
4 | #include <qwidget.h> | ||
5 | |||
6 | class ScriptWidget; | ||
7 | class PPPData; | ||
8 | class QCheckBox; | ||
9 | class QComboBox; | ||
10 | class QLabel; | ||
11 | class QGridLayout; | ||
12 | class QLineEdit; | ||
13 | class QToolButton; | ||
14 | |||
15 | class AuthWidget : public QWidget { | ||
16 | Q_OBJECT | ||
17 | public: | ||
18 | AuthWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | ||
19 | ~AuthWidget() {}; | ||
20 | |||
21 | public slots: | ||
22 | bool check(); | ||
23 | void save(); | ||
24 | |||
25 | private slots: | ||
26 | void authChanged(const QString&); | ||
27 | void showUsernamePassword(bool); | ||
28 | void showScriptWindow(bool); | ||
29 | void toggleEchoMode(bool); | ||
30 | |||
31 | private: | ||
32 | ScriptWidget *scriptWidget; | ||
33 | PPPData *_pppdata; | ||
34 | bool isNewAccount; | ||
35 | QGridLayout *layout; | ||
36 | QComboBox *auth; | ||
37 | QLabel *auth_l; | ||
38 | QLabel *user_l; | ||
39 | QLineEdit *userName; | ||
40 | QLabel *pw_l; | ||
41 | QLineEdit *passWord; | ||
42 | QToolButton *hidePw; | ||
43 | QCheckBox *store_password; | ||
44 | }; | ||
45 | |||
46 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 89d9930..a93f93d 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1,1432 +1,1433 @@ | |||
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 | * | 4 | * |
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 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> | 7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> |
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 <config.h> | 27 | //#include <config.h> |
28 | 28 | ||
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qregexp.h> | 30 | #include <qregexp.h> |
31 | 31 | ||
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <kdebug.h> | 33 | //#include <kdebug.h> |
34 | //#include <klocale.h> | 34 | //#include <klocale.h> |
35 | #define i18n QObject::tr | 35 | #define i18n QObject::tr |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | 38 | ||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <fcntl.h> | 42 | #include <fcntl.h> |
43 | #include <netdb.h> | 43 | #include <netdb.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 47 | #include <netinet/in.h> |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #ifdef _XPG4_2 | 51 | #ifdef _XPG4_2 |
52 | #define __xnet_connectconnect | 52 | #define __xnet_connectconnect |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #include <errno.h> | 55 | #include <errno.h> |
56 | 56 | ||
57 | #ifdef HAVE_SYS_PARAM_H | 57 | #ifdef HAVE_SYS_PARAM_H |
58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #ifdef __linux__ | 61 | #ifdef __linux__ |
62 | #include "runtests.h" | 62 | #include "runtests.h" |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #include "auth.h" | 65 | #include "auth.h" |
66 | #include "connect.h" | 66 | #include "connect.h" |
67 | //#include "docking.h" | 67 | //#include "docking.h" |
68 | #include "interfaceppp.h" | 68 | #include "interfaceppp.h" |
69 | #include "modem.h" | 69 | #include "modem.h" |
70 | #include "kpppconfig.h" | 70 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 71 | #include "pppdata.h" |
72 | #include "kpppwidget.h" | 72 | #include "kpppwidget.h" |
73 | //#include "requester.h" | 73 | //#include "requester.h" |
74 | //#include "utils.h" | 74 | //#include "utils.h" |
75 | #define execute_command system | 75 | #define execute_command system |
76 | 76 | ||
77 | QString old_hostname; | 77 | QString old_hostname; |
78 | bool modified_hostname; | 78 | bool modified_hostname; |
79 | 79 | ||
80 | 80 | ||
81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) | 81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
82 | : QWidget(parent, name), | 82 | : QWidget(parent, name), |
83 | myreadbuffer(""), | 83 | myreadbuffer(""), |
84 | main_timer_ID(0), | 84 | main_timer_ID(0), |
85 | vmain(0), | 85 | vmain(0), |
86 | substate(-1), | 86 | substate(-1), |
87 | scriptindex(0), | 87 | scriptindex(0), |
88 | loopnest(0), | 88 | loopnest(0), |
89 | loopend(false), | 89 | loopend(false), |
90 | semaphore(false), | 90 | semaphore(false), |
91 | expecting(false), | 91 | expecting(false), |
92 | readbuffer(""), | 92 | readbuffer(""), |
93 | scanvar(""), | 93 | scanvar(""), |
94 | scanning(false), | 94 | scanning(false), |
95 | pausing(false), | 95 | pausing(false), |
96 | dialnumber(0), | 96 | dialnumber(0), |
97 | _ifaceppp(ifp) | 97 | _ifaceppp(ifp) |
98 | { | 98 | { |
99 | modified_hostname = false; | 99 | modified_hostname = false; |
100 | 100 | ||
101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
102 | QString tit = i18n("Connecting to: "); | 102 | QString tit = i18n("Connecting to: "); |
103 | setCaption(tit); | 103 | setCaption(tit); |
104 | 104 | ||
105 | QHBoxLayout *l0 = new QHBoxLayout(10); | 105 | QHBoxLayout *l0 = new QHBoxLayout(10); |
106 | tl->addLayout(l0); | 106 | tl->addLayout(l0); |
107 | l0->addSpacing(10); | 107 | l0->addSpacing(10); |
108 | messg = new QLabel(this, "messg"); | 108 | messg = new QLabel(this, "messg"); |
109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | messg->setAlignment(AlignCenter); | 110 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 111 | messg->setText(i18n("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | // int messw = (messg->sizeHint().width() * 12) / 10; | 113 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | // messw = QMAX(messw,280); | 114 | // messw = QMAX(messw,280); |
115 | // messg->setMinimumWidth(messw); | 115 | // messg->setMinimumWidth(messw); |
116 | messg->setText(i18n("Offline")); | 116 | messg->setText(i18n("Offline")); |
117 | l0->addSpacing(10); | 117 | l0->addSpacing(10); |
118 | l0->addWidget(messg); | 118 | l0->addWidget(messg); |
119 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
120 | 120 | ||
121 | QHBoxLayout *l1 = new QHBoxLayout(10); | 121 | QHBoxLayout *l1 = new QHBoxLayout(10); |
122 | tl->addLayout(l1); | 122 | tl->addLayout(l1); |
123 | l1->addStretch(1); | 123 | l1->addStretch(1); |
124 | 124 | ||
125 | debug = new QPushButton(i18n("Log"), this); | 125 | debug = new QPushButton(i18n("Log"), this); |
126 | debug->setToggleButton(true); | 126 | debug->setToggleButton(true); |
127 | debug->setEnabled( false ); // FIXME: disable the log button | ||
127 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 128 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
128 | 129 | ||
129 | cancel = new QPushButton(i18n("Cancel"), this); | 130 | cancel = new QPushButton(i18n("Cancel"), this); |
130 | cancel->setFocus(); | 131 | cancel->setFocus(); |
131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 132 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
132 | 133 | ||
133 | // int maxw = QMAX(cancel->sizeHint().width(), | 134 | // int maxw = QMAX(cancel->sizeHint().width(), |
134 | // debug->sizeHint().width()); | 135 | // debug->sizeHint().width()); |
135 | // maxw = QMAX(maxw,65); | 136 | // maxw = QMAX(maxw,65); |
136 | // debug->setFixedWidth(maxw); | 137 | // debug->setFixedWidth(maxw); |
137 | // cancel->setFixedWidth(maxw); | 138 | // cancel->setFixedWidth(maxw); |
138 | l1->addWidget(debug); | 139 | l1->addWidget(debug); |
139 | l1->addWidget(cancel); | 140 | l1->addWidget(cancel); |
140 | 141 | ||
141 | // setFixedSize(sizeHint()); | 142 | // setFixedSize(sizeHint()); |
142 | 143 | ||
143 | pausetimer = new QTimer(this); | 144 | pausetimer = new QTimer(this); |
144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 145 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
145 | 146 | ||
146 | qApp->processEvents(); | 147 | qApp->processEvents(); |
147 | 148 | ||
148 | timeout_timer = new QTimer(this); | 149 | timeout_timer = new QTimer(this); |
149 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); | 150 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); |
150 | 151 | ||
151 | inittimer = new QTimer(this); | 152 | inittimer = new QTimer(this); |
152 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); | 153 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); |
153 | 154 | ||
154 | if_timeout_timer = new QTimer(this); | 155 | if_timeout_timer = new QTimer(this); |
155 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); | 156 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); |
156 | 157 | ||
157 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); | 158 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); |
158 | 159 | ||
159 | prompt = new PWEntry( this, "pw" ); | 160 | prompt = new PWEntry( this, "pw" ); |
160 | if_timer = new QTimer(this); | 161 | if_timer = new QTimer(this); |
161 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 162 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
162 | } | 163 | } |
163 | 164 | ||
164 | 165 | ||
165 | ConnectWidget::~ConnectWidget() { | 166 | ConnectWidget::~ConnectWidget() { |
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | void ConnectWidget::preinit() { | 170 | void ConnectWidget::preinit() { |
170 | // this is all just to keep the GUI nice and snappy .... | 171 | // this is all just to keep the GUI nice and snappy .... |
171 | // you have to see to believe ... | 172 | // you have to see to believe ... |
172 | messg->setText(i18n("Looking for modem...")); | 173 | messg->setText(i18n("Looking for modem...")); |
173 | inittimer->start(100); | 174 | inittimer->start(100); |
174 | } | 175 | } |
175 | 176 | ||
176 | 177 | ||
177 | void ConnectWidget::init() { | 178 | void ConnectWidget::init() { |
178 | _ifaceppp->data()->setpppdError(0); | 179 | _ifaceppp->data()->setpppdError(0); |
179 | inittimer->stop(); | 180 | inittimer->stop(); |
180 | vmain = 0; | 181 | vmain = 0; |
181 | substate = -1; | 182 | substate = -1; |
182 | expecting = false; | 183 | expecting = false; |
183 | pausing = false; | 184 | pausing = false; |
184 | scriptindex = 0; | 185 | scriptindex = 0; |
185 | myreadbuffer = ""; | 186 | myreadbuffer = ""; |
186 | scanning = false; | 187 | scanning = false; |
187 | scanvar = ""; | 188 | scanvar = ""; |
188 | firstrunID = true; | 189 | firstrunID = true; |
189 | firstrunPW = true; | 190 | firstrunPW = true; |
190 | // stats->totalbytes = 0; | 191 | // stats->totalbytes = 0; |
191 | dialnumber = 0; | 192 | dialnumber = 0; |
192 | 193 | ||
193 | // p_kppp->con_speed = ""; | 194 | // p_kppp->con_speed = ""; |
194 | 195 | ||
195 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); | 196 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
196 | 197 | ||
197 | comlist = &_ifaceppp->data()->scriptType(); | 198 | comlist = &_ifaceppp->data()->scriptType(); |
198 | arglist = &_ifaceppp->data()->script(); | 199 | arglist = &_ifaceppp->data()->script(); |
199 | 200 | ||
200 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); | 201 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
201 | setCaption(tit); | 202 | setCaption(tit); |
202 | 203 | ||
203 | qApp->processEvents(); | 204 | qApp->processEvents(); |
204 | 205 | ||
205 | // run the "before-connect" command | 206 | // run the "before-connect" command |
206 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { | 207 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
207 | messg->setText(i18n("Running pre-startup command...")); | 208 | messg->setText(i18n("Running pre-startup command...")); |
208 | emit debugMessage(i18n("Running pre-startup command...")); | 209 | emit debugMessage(i18n("Running pre-startup command...")); |
209 | 210 | ||
210 | qApp->processEvents(); | 211 | qApp->processEvents(); |
211 | QApplication::flushX(); | 212 | QApplication::flushX(); |
212 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); | 213 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
213 | // int i, status; | 214 | // int i, status; |
214 | 215 | ||
215 | // do { | 216 | // do { |
216 | // qApp->processEvents(); | 217 | // qApp->processEvents(); |
217 | // i = waitpid(id, &status, WNOHANG); | 218 | // i = waitpid(id, &status, WNOHANG); |
218 | // usleep(100000); | 219 | // usleep(100000); |
219 | // } while (i == 0 && errno == 0); | 220 | // } while (i == 0 && errno == 0); |
220 | } | 221 | } |
221 | 222 | ||
222 | int lock = _ifaceppp->modem()->lockdevice(); | 223 | int lock = _ifaceppp->modem()->lockdevice(); |
223 | 224 | ||
224 | if (lock == 1) { | 225 | if (lock == 1) { |
225 | messg->setText(i18n("Modem device is locked.")); | 226 | messg->setText(i18n("Modem device is locked.")); |
226 | vmain = 20; // wait until cancel is pressed | 227 | vmain = 20; // wait until cancel is pressed |
227 | return; | 228 | return; |
228 | } | 229 | } |
229 | 230 | ||
230 | if (lock == -1) { | 231 | if (lock == -1) { |
231 | messg->setText(i18n("Unable to create modem lock file.")); | 232 | messg->setText(i18n("Unable to create modem lock file.")); |
232 | vmain = 20; // wait until cancel is pressed | 233 | vmain = 20; // wait until cancel is pressed |
233 | return; | 234 | return; |
234 | } | 235 | } |
235 | 236 | ||
236 | if(_ifaceppp->modem()->opentty()) { | 237 | if(_ifaceppp->modem()->opentty()) { |
237 | messg->setText(_ifaceppp->modem()->modemMessage()); | 238 | messg->setText(_ifaceppp->modem()->modemMessage()); |
238 | qApp->processEvents(); | 239 | qApp->processEvents(); |
239 | if(_ifaceppp->modem()->hangup()) { | 240 | if(_ifaceppp->modem()->hangup()) { |
240 | 241 | ||
241 | qApp->processEvents(); | 242 | qApp->processEvents(); |
242 | 243 | ||
243 | semaphore = false; | 244 | semaphore = false; |
244 | 245 | ||
245 | _ifaceppp->modem()->stop(); | 246 | _ifaceppp->modem()->stop(); |
246 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); | 247 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
247 | 248 | ||
248 | // if we are stuck anywhere we will time out | 249 | // if we are stuck anywhere we will time out |
249 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 250 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
250 | 251 | ||
251 | // this timer will run the script etc. | 252 | // this timer will run the script etc. |
252 | main_timer_ID = startTimer(10); | 253 | main_timer_ID = startTimer(10); |
253 | 254 | ||
254 | return; | 255 | return; |
255 | } | 256 | } |
256 | } | 257 | } |
257 | 258 | ||
258 | // initialization failed | 259 | // initialization failed |
259 | messg->setText(_ifaceppp->modem()->modemMessage()); | 260 | messg->setText(_ifaceppp->modem()->modemMessage()); |
260 | vmain = 20; // wait until cancel is pressed | 261 | vmain = 20; // wait until cancel is pressed |
261 | _ifaceppp->modem()->unlockdevice(); | 262 | _ifaceppp->modem()->unlockdevice(); |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void ConnectWidget::timerEvent(QTimerEvent *) { | 266 | void ConnectWidget::timerEvent(QTimerEvent *) { |
266 | if (semaphore || pausing) | 267 | if (semaphore || pausing) |
267 | return; | 268 | return; |
268 | 269 | ||
269 | if(vmain == 0) { | 270 | if(vmain == 0) { |
270 | #ifdef DEBUG_WO_DIALING | 271 | #ifdef DEBUG_WO_DIALING |
271 | vmain = 10; | 272 | vmain = 10; |
272 | return; | 273 | return; |
273 | #endif | 274 | #endif |
274 | 275 | ||
275 | assert(PPPData::NumInitStrings > 0); | 276 | assert(PPPData::NumInitStrings > 0); |
276 | // first init string ? | 277 | // first init string ? |
277 | if(substate == -1) { | 278 | if(substate == -1) { |
278 | messg->setText(i18n("Initializing modem...")); | 279 | messg->setText(i18n("Initializing modem...")); |
279 | emit debugMessage(i18n("Initializing modem...")); | 280 | emit debugMessage(i18n("Initializing modem...")); |
280 | substate = 0; | 281 | substate = 0; |
281 | } | 282 | } |
282 | 283 | ||
283 | QString initStr = _ifaceppp->data()->modemInitStr(substate); | 284 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
284 | if (!initStr.isEmpty()) { | 285 | if (!initStr.isEmpty()) { |
285 | // send a carriage return and then wait a bit so that the modem will | 286 | // send a carriage return and then wait a bit so that the modem will |
286 | // let us issue commands. | 287 | // let us issue commands. |
287 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { | 288 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
288 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 289 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
289 | writeline(""); | 290 | writeline(""); |
290 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 291 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
291 | } | 292 | } |
292 | setExpect(_ifaceppp->data()->modemInitResp()); | 293 | setExpect(_ifaceppp->data()->modemInitResp()); |
293 | writeline(initStr); | 294 | writeline(initStr); |
294 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 295 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
295 | } | 296 | } |
296 | 297 | ||
297 | substate++; | 298 | substate++; |
298 | 299 | ||
299 | /* | 300 | /* |
300 | * FIXME after 3.0: Make it possible to disable ATS11 since it | 301 | * FIXME after 3.0: Make it possible to disable ATS11 since it |
301 | * seems to be incompatible with some ISDN adapters (e.g. DataBox | 302 | * seems to be incompatible with some ISDN adapters (e.g. DataBox |
302 | * Speed Dragon). Even better would be to detect this when doing | 303 | * Speed Dragon). Even better would be to detect this when doing |
303 | * a "Modem Query" | 304 | * a "Modem Query" |
304 | */ | 305 | */ |
305 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) | 306 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
306 | vmain = 5; | 307 | vmain = 5; |
307 | else | 308 | else |
308 | vmain = 3; | 309 | vmain = 3; |
309 | 310 | ||
310 | return; | 311 | return; |
311 | } | 312 | } |
312 | 313 | ||
313 | if (vmain == 5) { | 314 | if (vmain == 5) { |
314 | if(!expecting) { | 315 | if(!expecting) { |
315 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); | 316 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
316 | QString msg = i18n("Setting ") + sToneDuration; | 317 | QString msg = i18n("Setting ") + sToneDuration; |
317 | messg->setText(msg); | 318 | messg->setText(msg); |
318 | emit debugMessage(msg); | 319 | emit debugMessage(msg); |
319 | setExpect(_ifaceppp->data()->modemInitResp()); | 320 | setExpect(_ifaceppp->data()->modemInitResp()); |
320 | writeline(sToneDuration); | 321 | writeline(sToneDuration); |
321 | } | 322 | } |
322 | vmain = 3; | 323 | vmain = 3; |
323 | return; | 324 | return; |
324 | } | 325 | } |
325 | 326 | ||
326 | if(vmain == 3) { | 327 | if(vmain == 3) { |
327 | if(!expecting) { | 328 | if(!expecting) { |
328 | // done with all init strings ? | 329 | // done with all init strings ? |
329 | if(substate < PPPData::NumInitStrings) { | 330 | if(substate < PPPData::NumInitStrings) { |
330 | vmain = 0; | 331 | vmain = 0; |
331 | return; | 332 | return; |
332 | } | 333 | } |
333 | substate = -1; | 334 | substate = -1; |
334 | // skip setting the volume if command is empty | 335 | // skip setting the volume if command is empty |
335 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { | 336 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
336 | vmain = 4; | 337 | vmain = 4; |
337 | return; | 338 | return; |
338 | } | 339 | } |
339 | messg->setText(i18n("Setting speaker volume...")); | 340 | messg->setText(i18n("Setting speaker volume...")); |
340 | emit debugMessage(i18n("Setting speaker volume...")); | 341 | emit debugMessage(i18n("Setting speaker volume...")); |
341 | 342 | ||
342 | setExpect(_ifaceppp->data()->modemInitResp()); | 343 | setExpect(_ifaceppp->data()->modemInitResp()); |
343 | QString vol("AT"); | 344 | QString vol("AT"); |
344 | vol += _ifaceppp->data()->volumeInitString(); | 345 | vol += _ifaceppp->data()->volumeInitString(); |
345 | writeline(vol); | 346 | writeline(vol); |
346 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 347 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
347 | vmain = 4; | 348 | vmain = 4; |
348 | return; | 349 | return; |
349 | } | 350 | } |
350 | } | 351 | } |
351 | 352 | ||
352 | if(vmain == 4) { | 353 | if(vmain == 4) { |
353 | if(!expecting) { | 354 | if(!expecting) { |
354 | if(!_ifaceppp->data()->waitForDialTone()) { | 355 | if(!_ifaceppp->data()->waitForDialTone()) { |
355 | QString msg = i18n("Turning off dial tone waiting..."); | 356 | QString msg = i18n("Turning off dial tone waiting..."); |
356 | messg->setText(msg); | 357 | messg->setText(msg); |
357 | emit debugMessage(msg); | 358 | emit debugMessage(msg); |
358 | setExpect(_ifaceppp->data()->modemInitResp()); | 359 | setExpect(_ifaceppp->data()->modemInitResp()); |
359 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); | 360 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
360 | } | 361 | } |
361 | vmain = 1; | 362 | vmain = 1; |
362 | return; | 363 | return; |
363 | } | 364 | } |
364 | } | 365 | } |
365 | 366 | ||
366 | // dial the number and wait to connect | 367 | // dial the number and wait to connect |
367 | if(vmain == 1) { | 368 | if(vmain == 1) { |
368 | if(!expecting) { | 369 | if(!expecting) { |
369 | 370 | ||
370 | timeout_timer->stop(); | 371 | timeout_timer->stop(); |
371 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 372 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
372 | 373 | ||
373 | QStringList &plist = _ifaceppp->data()->phonenumbers(); | 374 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
374 | QString bmarg= _ifaceppp->data()->dialPrefix(); | 375 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
375 | bmarg += *plist.at(dialnumber); | 376 | bmarg += *plist.at(dialnumber); |
376 | QString bm = i18n("Dialing %1").arg(bmarg); | 377 | QString bm = i18n("Dialing %1").arg(bmarg); |
377 | messg->setText(bm); | 378 | messg->setText(bm); |
378 | emit debugMessage(bm); | 379 | emit debugMessage(bm); |
379 | 380 | ||
380 | QString pn = _ifaceppp->data()->modemDialStr(); | 381 | QString pn = _ifaceppp->data()->modemDialStr(); |
381 | pn += _ifaceppp->data()->dialPrefix(); | 382 | pn += _ifaceppp->data()->dialPrefix(); |
382 | pn += *plist.at(dialnumber); | 383 | pn += *plist.at(dialnumber); |
383 | if(++dialnumber >= plist.count()) | 384 | if(++dialnumber >= plist.count()) |
384 | dialnumber = 0; | 385 | dialnumber = 0; |
385 | writeline(pn); | 386 | writeline(pn); |
386 | 387 | ||
387 | setExpect(_ifaceppp->data()->modemConnectResp()); | 388 | setExpect(_ifaceppp->data()->modemConnectResp()); |
388 | vmain = 100; | 389 | vmain = 100; |
389 | return; | 390 | return; |
390 | } | 391 | } |
391 | } | 392 | } |
392 | 393 | ||
393 | // wait for connect, but redial if BUSY or wait for user cancel | 394 | // wait for connect, but redial if BUSY or wait for user cancel |
394 | // if NO CARRIER or NO DIALTONE | 395 | // if NO CARRIER or NO DIALTONE |
395 | if(vmain == 100) { | 396 | if(vmain == 100) { |
396 | if(!expecting) { | 397 | if(!expecting) { |
397 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); | 398 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
398 | setExpect("\n"); | 399 | setExpect("\n"); |
399 | vmain = 101; | 400 | vmain = 101; |
400 | return; | 401 | return; |
401 | } | 402 | } |
402 | 403 | ||
403 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { | 404 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
404 | timeout_timer->stop(); | 405 | timeout_timer->stop(); |
405 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 406 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
406 | 407 | ||
407 | messg->setText(i18n("Line busy. Hanging up...")); | 408 | messg->setText(i18n("Line busy. Hanging up...")); |
408 | emit debugPutChar('\n'); | 409 | emit debugPutChar('\n'); |
409 | _ifaceppp->modem()->hangup(); | 410 | _ifaceppp->modem()->hangup(); |
410 | 411 | ||
411 | if(_ifaceppp->data()->busyWait() > 0) { | 412 | if(_ifaceppp->data()->busyWait() > 0) { |
412 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); | 413 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
413 | messg->setText(bm); | 414 | messg->setText(bm); |
414 | emit debugMessage(bm); | 415 | emit debugMessage(bm); |
415 | 416 | ||
416 | pausing = true; | 417 | pausing = true; |
417 | 418 | ||
418 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); | 419 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
419 | timeout_timer->stop(); | 420 | timeout_timer->stop(); |
420 | } | 421 | } |
421 | 422 | ||
422 | _ifaceppp->modem()->setDataMode(false); | 423 | _ifaceppp->modem()->setDataMode(false); |
423 | vmain = 0; | 424 | vmain = 0; |
424 | substate = -1; | 425 | substate = -1; |
425 | return; | 426 | return; |
426 | } | 427 | } |
427 | 428 | ||
428 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { | 429 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
429 | timeout_timer->stop(); | 430 | timeout_timer->stop(); |
430 | 431 | ||
431 | messg->setText(i18n("No Dialtone")); | 432 | messg->setText(i18n("No Dialtone")); |
432 | vmain = 20; | 433 | vmain = 20; |
433 | _ifaceppp->modem()->unlockdevice(); | 434 | _ifaceppp->modem()->unlockdevice(); |
434 | return; | 435 | return; |
435 | } | 436 | } |
436 | 437 | ||
437 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { | 438 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
438 | timeout_timer->stop(); | 439 | timeout_timer->stop(); |
439 | 440 | ||
440 | messg->setText(i18n("No Carrier")); | 441 | messg->setText(i18n("No Carrier")); |
441 | vmain = 20; | 442 | vmain = 20; |
442 | _ifaceppp->modem()->unlockdevice(); | 443 | _ifaceppp->modem()->unlockdevice(); |
443 | return; | 444 | return; |
444 | } | 445 | } |
445 | } | 446 | } |
446 | 447 | ||
447 | // wait for newline after CONNECT response (so we get the speed) | 448 | // wait for newline after CONNECT response (so we get the speed) |
448 | if(vmain == 101) { | 449 | if(vmain == 101) { |
449 | if(!expecting) { | 450 | if(!expecting) { |
450 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands | 451 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
451 | 452 | ||
452 | emit startAccounting(); | 453 | emit startAccounting(); |
453 | // p_kppp->con_win->startClock(); | 454 | // p_kppp->con_win->startClock(); |
454 | 455 | ||
455 | vmain = 2; | 456 | vmain = 2; |
456 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; | 457 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
457 | return; | 458 | return; |
458 | } | 459 | } |
459 | } | 460 | } |
460 | 461 | ||
461 | // execute the script | 462 | // execute the script |
462 | if(vmain == 2) { | 463 | if(vmain == 2) { |
463 | if(!expecting && !pausing && !scanning) { | 464 | if(!expecting && !pausing && !scanning) { |
464 | 465 | ||
465 | timeout_timer->stop(); | 466 | timeout_timer->stop(); |
466 | timeout_timer->start(scriptTimeout); | 467 | timeout_timer->start(scriptTimeout); |
467 | 468 | ||
468 | if((unsigned) scriptindex < comlist->count()) { | 469 | if((unsigned) scriptindex < comlist->count()) { |
469 | scriptCommand = *(comlist->at(scriptindex)); | 470 | scriptCommand = *(comlist->at(scriptindex)); |
470 | scriptArgument = *(arglist->at(scriptindex)); | 471 | scriptArgument = *(arglist->at(scriptindex)); |
471 | } else { | 472 | } else { |
472 | qDebug( "End of script" ); | 473 | qDebug( "End of script" ); |
473 | vmain = 10; | 474 | vmain = 10; |
474 | return; | 475 | return; |
475 | } | 476 | } |
476 | 477 | ||
477 | if (scriptCommand == "Scan") { | 478 | if (scriptCommand == "Scan") { |
478 | QString bm = i18n("Scanning %1").arg(scriptArgument); | 479 | QString bm = i18n("Scanning %1").arg(scriptArgument); |
479 | messg->setText(bm); | 480 | messg->setText(bm); |
480 | emit debugMessage(bm); | 481 | emit debugMessage(bm); |
481 | 482 | ||
482 | setScan(scriptArgument); | 483 | setScan(scriptArgument); |
483 | scriptindex++; | 484 | scriptindex++; |
484 | return; | 485 | return; |
485 | } | 486 | } |
486 | 487 | ||
487 | if (scriptCommand == "Save") { | 488 | if (scriptCommand == "Save") { |
488 | QString bm = i18n("Saving %1").arg(scriptArgument); | 489 | QString bm = i18n("Saving %1").arg(scriptArgument); |
489 | messg->setText(bm); | 490 | messg->setText(bm); |
490 | emit debugMessage(bm); | 491 | emit debugMessage(bm); |
491 | 492 | ||
492 | if (scriptArgument.lower() == "password") { | 493 | if (scriptArgument.lower() == "password") { |
493 | _ifaceppp->data()->setPassword(scanvar); | 494 | _ifaceppp->data()->setPassword(scanvar); |
494 | // p_kppp->setPW_Edit(scanvar); | 495 | // p_kppp->setPW_Edit(scanvar); |
495 | if(_ifaceppp->data()->storePassword()) | 496 | if(_ifaceppp->data()->storePassword()) |
496 | _ifaceppp->data()->setStoredPassword(scanvar); | 497 | _ifaceppp->data()->setStoredPassword(scanvar); |
497 | firstrunPW = true; | 498 | firstrunPW = true; |
498 | } | 499 | } |
499 | 500 | ||
500 | scriptindex++; | 501 | scriptindex++; |
501 | return; | 502 | return; |
502 | } | 503 | } |
503 | 504 | ||
504 | 505 | ||
505 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { | 506 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { |
506 | QString bm = i18n("Sending %1"); | 507 | QString bm = i18n("Sending %1"); |
507 | 508 | ||
508 | // replace %USERNAME% and %PASSWORD% | 509 | // replace %USERNAME% and %PASSWORD% |
509 | QString arg = scriptArgument; | 510 | QString arg = scriptArgument; |
510 | QRegExp re1("%USERNAME%"); | 511 | QRegExp re1("%USERNAME%"); |
511 | QRegExp re2("%PASSWORD%"); | 512 | QRegExp re2("%PASSWORD%"); |
512 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); | 513 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
513 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); | 514 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
514 | 515 | ||
515 | if (scriptCommand == "Send") | 516 | if (scriptCommand == "Send") |
516 | bm = bm.arg(scriptArgument); | 517 | bm = bm.arg(scriptArgument); |
517 | else { | 518 | else { |
518 | for(uint i = 0; i < scriptArgument.length(); i++) | 519 | for(uint i = 0; i < scriptArgument.length(); i++) |
519 | bm = bm.arg("*"); | 520 | bm = bm.arg("*"); |
520 | } | 521 | } |
521 | 522 | ||
522 | messg->setText(bm); | 523 | messg->setText(bm); |
523 | emit debugMessage(bm); | 524 | emit debugMessage(bm); |
524 | 525 | ||
525 | writeline(scriptArgument); | 526 | writeline(scriptArgument); |
526 | scriptindex++; | 527 | scriptindex++; |
527 | return; | 528 | return; |
528 | } | 529 | } |
529 | 530 | ||
530 | if (scriptCommand == "Expect") { | 531 | if (scriptCommand == "Expect") { |
531 | QString bm = i18n("Expecting %1").arg(scriptArgument); | 532 | QString bm = i18n("Expecting %1").arg(scriptArgument); |
532 | messg->setText(bm); | 533 | messg->setText(bm); |
533 | emit debugMessage(bm); | 534 | emit debugMessage(bm); |
534 | 535 | ||
535 | // The incrementing of the scriptindex MUST be before the | 536 | // The incrementing of the scriptindex MUST be before the |
536 | // call to setExpect otherwise the expect will miss a string that is | 537 | // call to setExpect otherwise the expect will miss a string that is |
537 | // already in the buffer. | 538 | // already in the buffer. |
538 | scriptindex++; | 539 | scriptindex++; |
539 | setExpect(scriptArgument); | 540 | setExpect(scriptArgument); |
540 | return; | 541 | return; |
541 | } | 542 | } |
542 | 543 | ||
543 | 544 | ||
544 | if (scriptCommand == "Pause") { | 545 | if (scriptCommand == "Pause") { |
545 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); | 546 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); |
546 | messg->setText(bm); | 547 | messg->setText(bm); |
547 | emit debugMessage(bm); | 548 | emit debugMessage(bm); |
548 | 549 | ||
549 | pausing = true; | 550 | pausing = true; |
550 | 551 | ||
551 | pausetimer->start(scriptArgument.toInt()*1000, true); | 552 | pausetimer->start(scriptArgument.toInt()*1000, true); |
552 | timeout_timer->stop(); | 553 | timeout_timer->stop(); |
553 | 554 | ||
554 | scriptindex++; | 555 | scriptindex++; |
555 | return; | 556 | return; |
556 | } | 557 | } |
557 | 558 | ||
558 | if (scriptCommand == "Timeout") { | 559 | if (scriptCommand == "Timeout") { |
559 | 560 | ||
560 | timeout_timer->stop(); | 561 | timeout_timer->stop(); |
561 | 562 | ||
562 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); | 563 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); |
563 | messg->setText(bm); | 564 | messg->setText(bm); |
564 | emit debugMessage(bm); | 565 | emit debugMessage(bm); |
565 | 566 | ||
566 | scriptTimeout=scriptArgument.toInt()*1000; | 567 | scriptTimeout=scriptArgument.toInt()*1000; |
567 | timeout_timer->start(scriptTimeout); | 568 | timeout_timer->start(scriptTimeout); |
568 | 569 | ||
569 | scriptindex++; | 570 | scriptindex++; |
570 | return; | 571 | return; |
571 | } | 572 | } |
572 | 573 | ||
573 | if (scriptCommand == "Hangup") { | 574 | if (scriptCommand == "Hangup") { |
574 | messg->setText(i18n("Hangup")); | 575 | messg->setText(i18n("Hangup")); |
575 | emit debugMessage(i18n("Hangup")); | 576 | emit debugMessage(i18n("Hangup")); |
576 | 577 | ||
577 | writeline(_ifaceppp->data()->modemHangupStr()); | 578 | writeline(_ifaceppp->data()->modemHangupStr()); |
578 | setExpect(_ifaceppp->data()->modemHangupResp()); | 579 | setExpect(_ifaceppp->data()->modemHangupResp()); |
579 | 580 | ||
580 | scriptindex++; | 581 | scriptindex++; |
581 | return; | 582 | return; |
582 | } | 583 | } |
583 | 584 | ||
584 | if (scriptCommand == "Answer") { | 585 | if (scriptCommand == "Answer") { |
585 | 586 | ||
586 | timeout_timer->stop(); | 587 | timeout_timer->stop(); |
587 | 588 | ||
588 | messg->setText(i18n("Answer")); | 589 | messg->setText(i18n("Answer")); |
589 | emit debugMessage(i18n("Answer")); | 590 | emit debugMessage(i18n("Answer")); |
590 | 591 | ||
591 | setExpect(_ifaceppp->data()->modemRingResp()); | 592 | setExpect(_ifaceppp->data()->modemRingResp()); |
592 | vmain = 150; | 593 | vmain = 150; |
593 | return; | 594 | return; |
594 | } | 595 | } |
595 | 596 | ||
596 | if (scriptCommand == "ID") { | 597 | if (scriptCommand == "ID") { |
597 | QString bm = i18n("ID %1").arg(scriptArgument); | 598 | QString bm = i18n("ID %1").arg(scriptArgument); |
598 | messg->setText(bm); | 599 | messg->setText(bm); |
599 | emit debugMessage(bm); | 600 | emit debugMessage(bm); |
600 | 601 | ||
601 | QString idstring = _ifaceppp->data()->storedUsername(); | 602 | QString idstring = _ifaceppp->data()->storedUsername(); |
602 | 603 | ||
603 | if(!idstring.isEmpty() && firstrunID) { | 604 | if(!idstring.isEmpty() && firstrunID) { |
604 | // the user entered an Id on the main kppp dialog | 605 | // the user entered an Id on the main kppp dialog |
605 | writeline(idstring); | 606 | writeline(idstring); |
606 | firstrunID = false; | 607 | firstrunID = false; |
607 | scriptindex++; | 608 | scriptindex++; |
608 | } | 609 | } |
609 | else { | 610 | else { |
610 | // the user didn't enter and Id on the main kppp dialog | 611 | // the user didn't enter and Id on the main kppp dialog |
611 | // let's query for an ID | 612 | // let's query for an ID |
612 | /* if not around yet, then post window... */ | 613 | /* if not around yet, then post window... */ |
613 | if (prompt->Consumed()) { | 614 | if (prompt->Consumed()) { |
614 | if (!(prompt->isVisible())) { | 615 | if (!(prompt->isVisible())) { |
615 | prompt->setPrompt(scriptArgument); | 616 | prompt->setPrompt(scriptArgument); |
616 | prompt->setEchoModeNormal(); | 617 | prompt->setEchoModeNormal(); |
617 | prompt->show(); | 618 | prompt->show(); |
618 | } | 619 | } |
619 | } else { | 620 | } else { |
620 | /* if prompt withdrawn ... then, */ | 621 | /* if prompt withdrawn ... then, */ |
621 | if(!(prompt->isVisible())) { | 622 | if(!(prompt->isVisible())) { |
622 | writeline(prompt->text()); | 623 | writeline(prompt->text()); |
623 | prompt->setConsumed(); | 624 | prompt->setConsumed(); |
624 | scriptindex++; | 625 | scriptindex++; |
625 | return; | 626 | return; |
626 | } | 627 | } |
627 | /* replace timeout value */ | 628 | /* replace timeout value */ |
628 | } | 629 | } |
629 | } | 630 | } |
630 | } | 631 | } |
631 | 632 | ||
632 | if (scriptCommand == "Password") { | 633 | if (scriptCommand == "Password") { |
633 | QString bm = i18n("Password %1").arg(scriptArgument); | 634 | QString bm = i18n("Password %1").arg(scriptArgument); |
634 | messg->setText(bm); | 635 | messg->setText(bm); |
635 | emit debugMessage(bm); | 636 | emit debugMessage(bm); |
636 | 637 | ||
637 | QString pwstring = _ifaceppp->data()->password(); | 638 | QString pwstring = _ifaceppp->data()->password(); |
638 | 639 | ||
639 | if(!pwstring.isEmpty() && firstrunPW) { | 640 | if(!pwstring.isEmpty() && firstrunPW) { |
640 | // the user entered a password on the main kppp dialog | 641 | // the user entered a password on the main kppp dialog |
641 | writeline(pwstring); | 642 | writeline(pwstring); |
642 | firstrunPW = false; | 643 | firstrunPW = false; |
643 | scriptindex++; | 644 | scriptindex++; |
644 | } | 645 | } |
645 | else { | 646 | else { |
646 | // the user didn't enter a password on the main kppp dialog | 647 | // the user didn't enter a password on the main kppp dialog |
647 | // let's query for a password | 648 | // let's query for a password |
648 | /* if not around yet, then post window... */ | 649 | /* if not around yet, then post window... */ |
649 | if (prompt->Consumed()) { | 650 | if (prompt->Consumed()) { |
650 | if (!(prompt->isVisible())) { | 651 | if (!(prompt->isVisible())) { |
651 | prompt->setPrompt(scriptArgument); | 652 | prompt->setPrompt(scriptArgument); |
652 | prompt->setEchoModePassword(); | 653 | prompt->setEchoModePassword(); |
653 | prompt->show(); | 654 | prompt->show(); |
654 | } | 655 | } |
655 | } else { | 656 | } else { |
656 | /* if prompt withdrawn ... then, */ | 657 | /* if prompt withdrawn ... then, */ |
657 | if(!(prompt->isVisible())) { | 658 | if(!(prompt->isVisible())) { |
658 | // p_kppp->setPW_Edit(prompt->text()); | 659 | // p_kppp->setPW_Edit(prompt->text()); |
659 | writeline(prompt->text()); | 660 | writeline(prompt->text()); |
660 | prompt->setConsumed(); | 661 | prompt->setConsumed(); |
661 | scriptindex++; | 662 | scriptindex++; |
662 | return; | 663 | return; |
663 | } | 664 | } |
664 | /* replace timeout value */ | 665 | /* replace timeout value */ |
665 | } | 666 | } |
666 | } | 667 | } |
667 | } | 668 | } |
668 | 669 | ||
669 | if (scriptCommand == "Prompt") { | 670 | if (scriptCommand == "Prompt") { |
670 | QString bm = i18n("Prompting %1"); | 671 | QString bm = i18n("Prompting %1"); |
671 | 672 | ||
672 | // if the scriptindex (aka the prompt text) includes a ## marker | 673 | // if the scriptindex (aka the prompt text) includes a ## marker |
673 | // this marker should get substituted with the contents of our stored | 674 | // this marker should get substituted with the contents of our stored |
674 | // variable (from the subsequent scan). | 675 | // variable (from the subsequent scan). |
675 | 676 | ||
676 | QString ts = scriptArgument; | 677 | QString ts = scriptArgument; |
677 | int vstart = ts.find( "##" ); | 678 | int vstart = ts.find( "##" ); |
678 | if( vstart != -1 ) { | 679 | if( vstart != -1 ) { |
679 | ts.remove( vstart, 2 ); | 680 | ts.remove( vstart, 2 ); |
680 | ts.insert( vstart, scanvar ); | 681 | ts.insert( vstart, scanvar ); |
681 | } | 682 | } |
682 | 683 | ||
683 | bm = bm.arg(ts); | 684 | bm = bm.arg(ts); |
684 | messg->setText(bm); | 685 | messg->setText(bm); |
685 | emit debugMessage(bm); | 686 | emit debugMessage(bm); |
686 | 687 | ||
687 | /* if not around yet, then post window... */ | 688 | /* if not around yet, then post window... */ |
688 | if (prompt->Consumed()) { | 689 | if (prompt->Consumed()) { |
689 | if (!(prompt->isVisible())) { | 690 | if (!(prompt->isVisible())) { |
690 | prompt->setPrompt( ts ); | 691 | prompt->setPrompt( ts ); |
691 | prompt->setEchoModeNormal(); | 692 | prompt->setEchoModeNormal(); |
692 | prompt->show(); | 693 | prompt->show(); |
693 | } | 694 | } |
694 | } else { | 695 | } else { |
695 | /* if prompt withdrawn ... then, */ | 696 | /* if prompt withdrawn ... then, */ |
696 | if (!(prompt->isVisible())) { | 697 | if (!(prompt->isVisible())) { |
697 | writeline(prompt->text()); | 698 | writeline(prompt->text()); |
698 | prompt->setConsumed(); | 699 | prompt->setConsumed(); |
699 | scriptindex++; | 700 | scriptindex++; |
700 | return; | 701 | return; |
701 | } | 702 | } |
702 | /* replace timeout value */ | 703 | /* replace timeout value */ |
703 | } | 704 | } |
704 | } | 705 | } |
705 | 706 | ||
706 | if (scriptCommand == "PWPrompt") { | 707 | if (scriptCommand == "PWPrompt") { |
707 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); | 708 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); |
708 | messg->setText(bm); | 709 | messg->setText(bm); |
709 | emit debugMessage(bm); | 710 | emit debugMessage(bm); |
710 | 711 | ||
711 | /* if not around yet, then post window... */ | 712 | /* if not around yet, then post window... */ |
712 | if (prompt->Consumed()) { | 713 | if (prompt->Consumed()) { |
713 | if (!(prompt->isVisible())) { | 714 | if (!(prompt->isVisible())) { |
714 | prompt->setPrompt(scriptArgument); | 715 | prompt->setPrompt(scriptArgument); |
715 | prompt->setEchoModePassword(); | 716 | prompt->setEchoModePassword(); |
716 | prompt->show(); | 717 | prompt->show(); |
717 | } | 718 | } |
718 | } else { | 719 | } else { |
719 | /* if prompt withdrawn ... then, */ | 720 | /* if prompt withdrawn ... then, */ |
720 | if (!(prompt->isVisible())) { | 721 | if (!(prompt->isVisible())) { |
721 | writeline(prompt->text()); | 722 | writeline(prompt->text()); |
722 | prompt->setConsumed(); | 723 | prompt->setConsumed(); |
723 | scriptindex++; | 724 | scriptindex++; |
724 | return; | 725 | return; |
725 | } | 726 | } |
726 | /* replace timeout value */ | 727 | /* replace timeout value */ |
727 | } | 728 | } |
728 | } | 729 | } |
729 | 730 | ||
730 | if (scriptCommand == "LoopStart") { | 731 | if (scriptCommand == "LoopStart") { |
731 | 732 | ||
732 | QString bm = i18n("Loop Start %1").arg(scriptArgument); | 733 | QString bm = i18n("Loop Start %1").arg(scriptArgument); |
733 | 734 | ||
734 | // The incrementing of the scriptindex MUST be before the | 735 | // The incrementing of the scriptindex MUST be before the |
735 | // call to setExpect otherwise the expect will miss a string that is | 736 | // call to setExpect otherwise the expect will miss a string that is |
736 | // already in the buffer. | 737 | // already in the buffer. |
737 | scriptindex++; | 738 | scriptindex++; |
738 | 739 | ||
739 | if ( loopnest > (MAXLOOPNEST-2) ) { | 740 | if ( loopnest > (MAXLOOPNEST-2) ) { |
740 | bm += i18n("ERROR: Nested too deep, ignored."); | 741 | bm += i18n("ERROR: Nested too deep, ignored."); |
741 | vmain=20; | 742 | vmain=20; |
742 | cancelbutton(); | 743 | cancelbutton(); |
743 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); | 744 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); |
744 | } else { | 745 | } else { |
745 | setExpect(scriptArgument); | 746 | setExpect(scriptArgument); |
746 | loopstartindex[loopnest] = scriptindex; | 747 | loopstartindex[loopnest] = scriptindex; |
747 | loopstr[loopnest] = scriptArgument; | 748 | loopstr[loopnest] = scriptArgument; |
748 | loopend = false; | 749 | loopend = false; |
749 | loopnest++; | 750 | loopnest++; |
750 | } | 751 | } |
751 | messg->setText(bm); | 752 | messg->setText(bm); |
752 | emit debugMessage(bm); | 753 | emit debugMessage(bm); |
753 | 754 | ||
754 | } | 755 | } |
755 | 756 | ||
756 | if (scriptCommand == "LoopEnd") { | 757 | if (scriptCommand == "LoopEnd") { |
757 | QString bm = i18n("Loop End %1").arg(scriptArgument); | 758 | QString bm = i18n("Loop End %1").arg(scriptArgument); |
758 | if ( loopnest <= 0 ) { | 759 | if ( loopnest <= 0 ) { |
759 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); | 760 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); |
760 | vmain=20; | 761 | vmain=20; |
761 | cancelbutton(); | 762 | cancelbutton(); |
762 | QMessageBox::critical(0, "error", bm); | 763 | QMessageBox::critical(0, "error", bm); |
763 | return; | 764 | return; |
764 | } else { | 765 | } else { |
765 | // NB! The incrementing of the scriptindex MUST be before the | 766 | // NB! The incrementing of the scriptindex MUST be before the |
766 | // call to setExpect otherwise the expect will miss a string | 767 | // call to setExpect otherwise the expect will miss a string |
767 | // that is already in the buffer. | 768 | // that is already in the buffer. |
768 | scriptindex++; | 769 | scriptindex++; |
769 | setExpect(scriptArgument); | 770 | setExpect(scriptArgument); |
770 | loopnest--; | 771 | loopnest--; |
771 | loopend = true; | 772 | loopend = true; |
772 | } | 773 | } |
773 | messg->setText(bm); | 774 | messg->setText(bm); |
774 | emit debugMessage(bm); | 775 | emit debugMessage(bm); |
775 | 776 | ||
776 | } | 777 | } |
777 | } | 778 | } |
778 | } | 779 | } |
779 | 780 | ||
780 | // this is a subroutine for the "Answer" script option | 781 | // this is a subroutine for the "Answer" script option |
781 | 782 | ||
782 | if(vmain == 150) { | 783 | if(vmain == 150) { |
783 | if(!expecting) { | 784 | if(!expecting) { |
784 | writeline(_ifaceppp->data()->modemAnswerStr()); | 785 | writeline(_ifaceppp->data()->modemAnswerStr()); |
785 | setExpect(_ifaceppp->data()->modemAnswerResp()); | 786 | setExpect(_ifaceppp->data()->modemAnswerResp()); |
786 | 787 | ||
787 | vmain = 2; | 788 | vmain = 2; |
788 | scriptindex++; | 789 | scriptindex++; |
789 | return; | 790 | return; |
790 | } | 791 | } |
791 | } | 792 | } |
792 | 793 | ||
793 | if(vmain == 30) { | 794 | if(vmain == 30) { |
794 | // if (termwindow->isVisible()) | 795 | // if (termwindow->isVisible()) |
795 | // return; | 796 | // return; |
796 | // if (termwindow->pressedContinue()) | 797 | // if (termwindow->pressedContinue()) |
797 | // vmain = 10; | 798 | // vmain = 10; |
798 | // else | 799 | // else |
799 | cancelbutton(); | 800 | cancelbutton(); |
800 | } | 801 | } |
801 | 802 | ||
802 | if(vmain == 10) { | 803 | if(vmain == 10) { |
803 | if(!expecting) { | 804 | if(!expecting) { |
804 | 805 | ||
805 | int result; | 806 | int result; |
806 | 807 | ||
807 | timeout_timer->stop(); | 808 | timeout_timer->stop(); |
808 | if_timeout_timer->stop(); // better be sure. | 809 | if_timeout_timer->stop(); // better be sure. |
809 | 810 | ||
810 | // stop reading of data | 811 | // stop reading of data |
811 | _ifaceppp->modem()->stop(); | 812 | _ifaceppp->modem()->stop(); |
812 | 813 | ||
813 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { | 814 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
814 | // if (termwindow) { | 815 | // if (termwindow) { |
815 | // delete termwindow; | 816 | // delete termwindow; |
816 | // termwindow = 0L; | 817 | // termwindow = 0L; |
817 | // this->show(); | 818 | // this->show(); |
818 | // } else { | 819 | // } else { |
819 | // termwindow = new LoginTerm(0L, 0L); | 820 | // termwindow = new LoginTerm(0L, 0L); |
820 | // hide(); | 821 | // hide(); |
821 | // termwindow->show(); | 822 | // termwindow->show(); |
822 | // vmain = 30; | 823 | // vmain = 30; |
823 | // return; | 824 | // return; |
824 | // } | 825 | // } |
825 | } | 826 | } |
826 | 827 | ||
827 | // Close the tty. This prevents the QTimer::singleShot() in | 828 | // Close the tty. This prevents the QTimer::singleShot() in |
828 | // Modem::readtty() from re-enabling the socket notifier. | 829 | // Modem::readtty() from re-enabling the socket notifier. |
829 | // The port is still held open by the helper process. | 830 | // The port is still held open by the helper process. |
830 | _ifaceppp->modem()->closetty(); | 831 | _ifaceppp->modem()->closetty(); |
831 | 832 | ||
832 | killTimer( main_timer_ID ); | 833 | killTimer( main_timer_ID ); |
833 | 834 | ||
834 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 835 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
835 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 836 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
836 | 837 | ||
837 | // find out PPP interface and notify the stats module | 838 | // find out PPP interface and notify the stats module |
838 | // stats->setUnit(pppInterfaceNumber()); | 839 | // stats->setUnit(pppInterfaceNumber()); |
839 | 840 | ||
840 | qApp->flushX(); | 841 | qApp->flushX(); |
841 | semaphore = true; | 842 | semaphore = true; |
842 | result = execppp(); | 843 | result = execppp(); |
843 | 844 | ||
844 | emit debugMessage(i18n("Starting pppd...")); | 845 | emit debugMessage(i18n("Starting pppd...")); |
845 | qDebug("execppp() returned with return-code %i", result ); | 846 | qDebug("execppp() returned with return-code %i", result ); |
846 | 847 | ||
847 | if(result) { | 848 | if(result) { |
848 | if(!_ifaceppp->data()->autoDNS()) | 849 | if(!_ifaceppp->data()->autoDNS()) |
849 | adddns( _ifaceppp ); | 850 | adddns( _ifaceppp ); |
850 | 851 | ||
851 | // O.K we are done here, let's change over to the if_waiting loop | 852 | // O.K we are done here, let's change over to the if_waiting loop |
852 | // where we wait for the ppp if (interface) to come up. | 853 | // where we wait for the ppp if (interface) to come up. |
853 | 854 | ||
854 | emit if_waiting_signal(); | 855 | emit if_waiting_signal(); |
855 | } else { | 856 | } else { |
856 | 857 | ||
857 | // starting pppd wasn't successful. Error messages were | 858 | // starting pppd wasn't successful. Error messages were |
858 | // handled by execppp(); | 859 | // handled by execppp(); |
859 | if_timeout_timer->stop(); | 860 | if_timeout_timer->stop(); |
860 | this->hide(); | 861 | this->hide(); |
861 | messg->setText(""); | 862 | messg->setText(""); |
862 | //p_kppp->quit_b->setFocus(); | 863 | //p_kppp->quit_b->setFocus(); |
863 | //p_kppp->show(); | 864 | //p_kppp->show(); |
864 | qApp->processEvents(); | 865 | qApp->processEvents(); |
865 | _ifaceppp->modem()->hangup(); | 866 | _ifaceppp->modem()->hangup(); |
866 | emit stopAccounting(); | 867 | emit stopAccounting(); |
867 | //p_kppp->con_win->stopClock(); | 868 | //p_kppp->con_win->stopClock(); |
868 | _ifaceppp->modem()->closetty(); | 869 | _ifaceppp->modem()->closetty(); |
869 | _ifaceppp->modem()->unlockdevice(); | 870 | _ifaceppp->modem()->unlockdevice(); |
870 | 871 | ||
871 | } | 872 | } |
872 | 873 | ||
873 | return; | 874 | return; |
874 | } | 875 | } |
875 | } | 876 | } |
876 | 877 | ||
877 | // this is a "wait until cancel" entry | 878 | // this is a "wait until cancel" entry |
878 | 879 | ||
879 | if(vmain == 20) { | 880 | if(vmain == 20) { |
880 | } | 881 | } |
881 | } | 882 | } |
882 | 883 | ||
883 | 884 | ||
884 | void ConnectWidget::set_con_speed_string() { | 885 | void ConnectWidget::set_con_speed_string() { |
885 | // Here we are trying to determine the speed at which we are connected. | 886 | // Here we are trying to determine the speed at which we are connected. |
886 | // Usually the modem responds after connect with something like | 887 | // Usually the modem responds after connect with something like |
887 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 888 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
888 | // or whatever the modemConnectResp() is. | 889 | // or whatever the modemConnectResp() is. |
889 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); | 890 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
890 | } | 891 | } |
891 | 892 | ||
892 | 893 | ||
893 | 894 | ||
894 | void ConnectWidget::readChar(unsigned char c) { | 895 | void ConnectWidget::readChar(unsigned char c) { |
895 | if(semaphore) | 896 | if(semaphore) |
896 | return; | 897 | return; |
897 | 898 | ||
898 | readbuffer += c; | 899 | readbuffer += c; |
899 | myreadbuffer += c; | 900 | myreadbuffer += c; |
900 | 901 | ||
901 | // While in scanning mode store each char to the scan buffer | 902 | // While in scanning mode store each char to the scan buffer |
902 | // for use in the prompt command | 903 | // for use in the prompt command |
903 | if( scanning ) | 904 | if( scanning ) |
904 | scanbuffer += c; | 905 | scanbuffer += c; |
905 | 906 | ||
906 | // add to debug window | 907 | // add to debug window |
907 | emit debugPutChar(c); | 908 | emit debugPutChar(c); |
908 | 909 | ||
909 | checkBuffers(); | 910 | checkBuffers(); |
910 | } | 911 | } |
911 | 912 | ||
912 | 913 | ||
913 | void ConnectWidget::checkBuffers() { | 914 | void ConnectWidget::checkBuffers() { |
914 | // Let's check if we are finished with scanning: | 915 | // Let's check if we are finished with scanning: |
915 | // The scanstring have to be in the buffer and the latest character | 916 | // The scanstring have to be in the buffer and the latest character |
916 | // was a carriage return or an linefeed (depending on modem setup) | 917 | // was a carriage return or an linefeed (depending on modem setup) |
917 | if( scanning && scanbuffer.contains(scanstr) && | 918 | if( scanning && scanbuffer.contains(scanstr) && |
918 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 919 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
919 | scanning = false; | 920 | scanning = false; |
920 | 921 | ||
921 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 922 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
922 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 923 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
923 | scanvar = scanvar.stripWhiteSpace(); | 924 | scanvar = scanvar.stripWhiteSpace(); |
924 | 925 | ||
925 | // Show the Variabel content in the debug window | 926 | // Show the Variabel content in the debug window |
926 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 927 | QString sv = i18n("Scan Var: %1").arg(scanvar); |
927 | emit debugMessage(sv); | 928 | emit debugMessage(sv); |
928 | } | 929 | } |
929 | 930 | ||
930 | if(expecting) { | 931 | if(expecting) { |
931 | if(readbuffer.contains(expectstr)) { | 932 | if(readbuffer.contains(expectstr)) { |
932 | expecting = false; | 933 | expecting = false; |
933 | // keep everything after the expected string | 934 | // keep everything after the expected string |
934 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 935 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
935 | 936 | ||
936 | QString ts = i18n("Found: %1").arg(expectstr); | 937 | QString ts = i18n("Found: %1").arg(expectstr); |
937 | emit debugMessage(ts); | 938 | emit debugMessage(ts); |
938 | 939 | ||
939 | if (loopend) { | 940 | if (loopend) { |
940 | loopend=false; | 941 | loopend=false; |
941 | } | 942 | } |
942 | } | 943 | } |
943 | 944 | ||
944 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 945 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
945 | expecting = false; | 946 | expecting = false; |
946 | readbuffer = ""; | 947 | readbuffer = ""; |
947 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 948 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); |
948 | emit debugMessage(ts); | 949 | emit debugMessage(ts); |
949 | scriptindex = loopstartindex[loopnest]; | 950 | scriptindex = loopstartindex[loopnest]; |
950 | loopend = false; | 951 | loopend = false; |
951 | loopnest++; | 952 | loopnest++; |
952 | } | 953 | } |
953 | // notify event loop if expected string was found | 954 | // notify event loop if expected string was found |
954 | if(!expecting) | 955 | if(!expecting) |
955 | timerEvent((QTimerEvent *) 0); | 956 | timerEvent((QTimerEvent *) 0); |
956 | } | 957 | } |
957 | } | 958 | } |
958 | 959 | ||
959 | 960 | ||
960 | 961 | ||
961 | void ConnectWidget::pause() { | 962 | void ConnectWidget::pause() { |
962 | pausing = false; | 963 | pausing = false; |
963 | pausetimer->stop(); | 964 | pausetimer->stop(); |
964 | } | 965 | } |
965 | 966 | ||
966 | 967 | ||
967 | void ConnectWidget::cancelbutton() { | 968 | void ConnectWidget::cancelbutton() { |
968 | _ifaceppp->modem()->stop(); | 969 | _ifaceppp->modem()->stop(); |
969 | killTimer(main_timer_ID); | 970 | killTimer(main_timer_ID); |
970 | timeout_timer->stop(); | 971 | timeout_timer->stop(); |
971 | if_timer->stop(); | 972 | if_timer->stop(); |
972 | if_timeout_timer->stop(); | 973 | if_timeout_timer->stop(); |
973 | 974 | ||
974 | // if (termwindow) { | 975 | // if (termwindow) { |
975 | // delete termwindow; | 976 | // delete termwindow; |
976 | // termwindow = 0L; | 977 | // termwindow = 0L; |
977 | // this->show(); | 978 | // this->show(); |
978 | // } | 979 | // } |
979 | 980 | ||
980 | messg->setText(i18n("One moment please...")); | 981 | messg->setText(i18n("One moment please...")); |
981 | 982 | ||
982 | // just to be sure | 983 | // just to be sure |
983 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 984 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
984 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 985 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
985 | removedns(_ifaceppp); | 986 | removedns(_ifaceppp); |
986 | 987 | ||
987 | qApp->processEvents(); | 988 | qApp->processEvents(); |
988 | 989 | ||
989 | _ifaceppp->modem()->killPPPDaemon(); | 990 | _ifaceppp->modem()->killPPPDaemon(); |
990 | _ifaceppp->modem()->hangup(); | 991 | _ifaceppp->modem()->hangup(); |
991 | 992 | ||
992 | 993 | ||
993 | // p_kppp->quit_b->setFocus(); | 994 | // p_kppp->quit_b->setFocus(); |
994 | // p_kppp->show(); | 995 | // p_kppp->show(); |
995 | // emit stopAccounting();// just to be sure | 996 | // emit stopAccounting();// just to be sure |
996 | // p_kppp->con_win->stopClock(); | 997 | // p_kppp->con_win->stopClock(); |
997 | _ifaceppp->modem()->closetty(); | 998 | _ifaceppp->modem()->closetty(); |
998 | _ifaceppp->modem()->unlockdevice(); | 999 | _ifaceppp->modem()->unlockdevice(); |
999 | 1000 | ||
1000 | //abort prompt window... | 1001 | //abort prompt window... |
1001 | if (prompt->isVisible()) { | 1002 | if (prompt->isVisible()) { |
1002 | prompt->hide(); | 1003 | prompt->hide(); |
1003 | } | 1004 | } |
1004 | prompt->setConsumed(); | 1005 | prompt->setConsumed(); |
1005 | 1006 | ||
1006 | messg->setText(tr("offline")); | 1007 | messg->setText(tr("offline")); |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | 1010 | ||
1010 | void ConnectWidget::script_timed_out() { | 1011 | void ConnectWidget::script_timed_out() { |
1011 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1012 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1012 | timeout_timer->stop(); | 1013 | timeout_timer->stop(); |
1013 | emit stopAccounting(); | 1014 | emit stopAccounting(); |
1014 | // p_kppp->con_win->stopClock(); | 1015 | // p_kppp->con_win->stopClock(); |
1015 | return; | 1016 | return; |
1016 | } | 1017 | } |
1017 | 1018 | ||
1018 | if (prompt->isVisible()) | 1019 | if (prompt->isVisible()) |
1019 | prompt->hide(); | 1020 | prompt->hide(); |
1020 | 1021 | ||
1021 | prompt->setConsumed(); | 1022 | prompt->setConsumed(); |
1022 | messg->setText(i18n("Script timed out!")); | 1023 | messg->setText(i18n("Script timed out!")); |
1023 | _ifaceppp->modem()->hangup(); | 1024 | _ifaceppp->modem()->hangup(); |
1024 | emit stopAccounting(); | 1025 | emit stopAccounting(); |
1025 | // p_kppp->con_win->stopClock(); | 1026 | // p_kppp->con_win->stopClock(); |
1026 | 1027 | ||
1027 | vmain = 0; // let's try again. | 1028 | vmain = 0; // let's try again. |
1028 | substate = -1; | 1029 | substate = -1; |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | 1032 | ||
1032 | void ConnectWidget::setScan(const QString &n) { | 1033 | void ConnectWidget::setScan(const QString &n) { |
1033 | scanning = true; | 1034 | scanning = true; |
1034 | scanstr = n; | 1035 | scanstr = n; |
1035 | scanbuffer = ""; | 1036 | scanbuffer = ""; |
1036 | 1037 | ||
1037 | QString ts = i18n("Scanning: %1").arg(n); | 1038 | QString ts = i18n("Scanning: %1").arg(n); |
1038 | emit debugMessage(ts); | 1039 | emit debugMessage(ts); |
1039 | } | 1040 | } |
1040 | 1041 | ||
1041 | 1042 | ||
1042 | void ConnectWidget::setExpect(const QString &n) { | 1043 | void ConnectWidget::setExpect(const QString &n) { |
1043 | expecting = true; | 1044 | expecting = true; |
1044 | expectstr = n; | 1045 | expectstr = n; |
1045 | 1046 | ||
1046 | QString ts = i18n("Expecting: %1").arg(n); | 1047 | QString ts = i18n("Expecting: %1").arg(n); |
1047 | ts.replace(QRegExp("\n"), "<LF>"); | 1048 | ts.replace(QRegExp("\n"), "<LF>"); |
1048 | emit debugMessage(ts); | 1049 | emit debugMessage(ts); |
1049 | 1050 | ||
1050 | // check if the expected string is in the read buffer already. | 1051 | // check if the expected string is in the read buffer already. |
1051 | checkBuffers(); | 1052 | checkBuffers(); |
1052 | } | 1053 | } |
1053 | 1054 | ||
1054 | 1055 | ||
1055 | void ConnectWidget::if_waiting_timed_out() { | 1056 | void ConnectWidget::if_waiting_timed_out() { |
1056 | if_timer->stop(); | 1057 | if_timer->stop(); |
1057 | if_timeout_timer->stop(); | 1058 | if_timeout_timer->stop(); |
1058 | qDebug("if_waiting_timed_out()"); | 1059 | qDebug("if_waiting_timed_out()"); |
1059 | 1060 | ||
1060 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); | 1061 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1061 | 1062 | ||
1062 | // let's kill the stuck pppd | 1063 | // let's kill the stuck pppd |
1063 | _ifaceppp->modem()->killPPPDaemon(); | 1064 | _ifaceppp->modem()->killPPPDaemon(); |
1064 | 1065 | ||
1065 | emit stopAccounting(); | 1066 | emit stopAccounting(); |
1066 | // p_kppp->con_win->stopClock(); | 1067 | // p_kppp->con_win->stopClock(); |
1067 | 1068 | ||
1068 | 1069 | ||
1069 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1070 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1070 | // in main.cpp what happens next will depend on the boolean | 1071 | // in main.cpp what happens next will depend on the boolean |
1071 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1072 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1072 | } | 1073 | } |
1073 | 1074 | ||
1074 | void ConnectWidget::pppdDied() | 1075 | void ConnectWidget::pppdDied() |
1075 | { | 1076 | { |
1076 | if_timer->stop(); | 1077 | if_timer->stop(); |
1077 | if_timeout_timer->stop(); | 1078 | if_timeout_timer->stop(); |
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | void ConnectWidget::if_waiting_slot() { | 1081 | void ConnectWidget::if_waiting_slot() { |
1081 | messg->setText(i18n("Logging on to network...")); | 1082 | messg->setText(i18n("Logging on to network...")); |
1082 | 1083 | ||
1083 | // if(!stats->ifIsUp()) { | 1084 | // if(!stats->ifIsUp()) { |
1084 | 1085 | ||
1085 | // if(_ifaceppp->data()->pppdError() != 0) { | 1086 | // if(_ifaceppp->data()->pppdError() != 0) { |
1086 | // // we are here if pppd died immediately after starting it. | 1087 | // // we are here if pppd died immediately after starting it. |
1087 | // pppdDied(); | 1088 | // pppdDied(); |
1088 | // // error message handled in main.cpp: sigPPPDDied() | 1089 | // // error message handled in main.cpp: sigPPPDDied() |
1089 | // return; | 1090 | // return; |
1090 | // } | 1091 | // } |
1091 | 1092 | ||
1092 | // if_timer->start(100, TRUE); // single shot | 1093 | // if_timer->start(100, TRUE); // single shot |
1093 | // return; | 1094 | // return; |
1094 | // } | 1095 | // } |
1095 | 1096 | ||
1096 | // O.K the ppp interface is up and running | 1097 | // O.K the ppp interface is up and running |
1097 | // give it a few time to come up completly (0.2 seconds) | 1098 | // give it a few time to come up completly (0.2 seconds) |
1098 | if_timeout_timer->stop(); | 1099 | if_timeout_timer->stop(); |
1099 | if_timer->stop(); | 1100 | if_timer->stop(); |
1100 | usleep(200000); | 1101 | usleep(200000); |
1101 | 1102 | ||
1102 | if(_ifaceppp->data()->autoDNS()) | 1103 | if(_ifaceppp->data()->autoDNS()) |
1103 | addpeerdns( _ifaceppp ); | 1104 | addpeerdns( _ifaceppp ); |
1104 | 1105 | ||
1105 | // Close the debugging window. If we are connected, we | 1106 | // Close the debugging window. If we are connected, we |
1106 | // are not really interested in debug output | 1107 | // are not really interested in debug output |
1107 | emit closeDebugWindow(); | 1108 | emit closeDebugWindow(); |
1108 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1109 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1109 | auto_hostname(_ifaceppp); | 1110 | auto_hostname(_ifaceppp); |
1110 | 1111 | ||
1111 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1112 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1112 | messg->setText(i18n("Running startup command...")); | 1113 | messg->setText(i18n("Running startup command...")); |
1113 | 1114 | ||
1114 | // make sure that we don't get any async errors | 1115 | // make sure that we don't get any async errors |
1115 | qApp->flushX(); | 1116 | qApp->flushX(); |
1116 | execute_command(_ifaceppp->data()->command_on_connect()); | 1117 | execute_command(_ifaceppp->data()->command_on_connect()); |
1117 | messg->setText(i18n("Done")); | 1118 | messg->setText(i18n("Done")); |
1118 | } | 1119 | } |
1119 | 1120 | ||
1120 | // remove the authentication file | 1121 | // remove the authentication file |
1121 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1122 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1122 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1123 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1123 | 1124 | ||
1124 | emit debugMessage(i18n("Done")); | 1125 | emit debugMessage(i18n("Done")); |
1125 | set_con_speed_string(); | 1126 | set_con_speed_string(); |
1126 | 1127 | ||
1127 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1128 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1128 | this->hide(); | 1129 | this->hide(); |
1129 | messg->setText(""); | 1130 | messg->setText(""); |
1130 | 1131 | ||
1131 | // prepare the con_win so as to have the right size for | 1132 | // prepare the con_win so as to have the right size for |
1132 | // accounting / non-accounting mode | 1133 | // accounting / non-accounting mode |
1133 | // if(p_kppp->acct != 0) | 1134 | // if(p_kppp->acct != 0) |
1134 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1135 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1135 | // else | 1136 | // else |
1136 | // p_kppp->con_win->accounting(false); | 1137 | // p_kppp->con_win->accounting(false); |
1137 | 1138 | ||
1138 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1139 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1139 | // // DockWidget::dock_widget->show(); | 1140 | // // DockWidget::dock_widget->show(); |
1140 | // // DockWidget::dock_widget->take_stats(); | 1141 | // // DockWidget::dock_widget->take_stats(); |
1141 | // // this->hide(); | 1142 | // // this->hide(); |
1142 | // } | 1143 | // } |
1143 | // else { | 1144 | // else { |
1144 | // // p_kppp->con_win->show(); | 1145 | // // p_kppp->con_win->show(); |
1145 | 1146 | ||
1146 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1147 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1147 | // // p_kppp->con_win->showMinimized(); | 1148 | // // p_kppp->con_win->showMinimized(); |
1148 | // } | 1149 | // } |
1149 | // } | 1150 | // } |
1150 | 1151 | ||
1151 | _ifaceppp->modem()->closetty(); | 1152 | _ifaceppp->modem()->closetty(); |
1152 | } | 1153 | } |
1153 | 1154 | ||
1154 | 1155 | ||
1155 | bool ConnectWidget::execppp() { | 1156 | bool ConnectWidget::execppp() { |
1156 | QString command; | 1157 | QString command; |
1157 | 1158 | ||
1158 | command = "pppd"; | 1159 | command = "pppd"; |
1159 | 1160 | ||
1160 | // as of version 2.3.6 pppd falls back to the real user rights when | 1161 | // as of version 2.3.6 pppd falls back to the real user rights when |
1161 | // opening a device given in a command line. To avoid permission conflicts | 1162 | // opening a device given in a command line. To avoid permission conflicts |
1162 | // we'll simply leave this argument away. pppd will then use the default tty | 1163 | // we'll simply leave this argument away. pppd will then use the default tty |
1163 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1164 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1164 | // command += " "; | 1165 | // command += " "; |
1165 | // command += _ifaceppp->data()->modemDevice(); | 1166 | // command += _ifaceppp->data()->modemDevice(); |
1166 | 1167 | ||
1167 | command += " " + _ifaceppp->data()->speed(); | 1168 | command += " " + _ifaceppp->data()->speed(); |
1168 | 1169 | ||
1169 | command += " -detach"; | 1170 | command += " -detach"; |
1170 | 1171 | ||
1171 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || | 1172 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1172 | _ifaceppp->data()->gateway() != "0.0.0.0") { | 1173 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1173 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { | 1174 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1174 | command += " "; | 1175 | command += " "; |
1175 | command += _ifaceppp->data()->ipaddr(); | 1176 | command += _ifaceppp->data()->ipaddr(); |
1176 | command += ":"; | 1177 | command += ":"; |
1177 | } | 1178 | } |
1178 | else { | 1179 | else { |
1179 | command += " "; | 1180 | command += " "; |
1180 | command += ":"; | 1181 | command += ":"; |
1181 | } | 1182 | } |
1182 | 1183 | ||
1183 | if(_ifaceppp->data()->gateway() != "0.0.0.0") | 1184 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1184 | command += _ifaceppp->data()->gateway(); | 1185 | command += _ifaceppp->data()->gateway(); |
1185 | } | 1186 | } |
1186 | 1187 | ||
1187 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") | 1188 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1188 | command += " netmask " + _ifaceppp->data()->subnetmask(); | 1189 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1189 | 1190 | ||
1190 | if(_ifaceppp->data()->flowcontrol() != "None") { | 1191 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1191 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1192 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1192 | command += " crtscts"; | 1193 | command += " crtscts"; |
1193 | else | 1194 | else |
1194 | command += " xonxoff"; | 1195 | command += " xonxoff"; |
1195 | } | 1196 | } |
1196 | 1197 | ||
1197 | if(_ifaceppp->data()->defaultroute()) | 1198 | if(_ifaceppp->data()->defaultroute()) |
1198 | command += " defaultroute"; | 1199 | command += " defaultroute"; |
1199 | 1200 | ||
1200 | if(_ifaceppp->data()->autoDNS()) | 1201 | if(_ifaceppp->data()->autoDNS()) |
1201 | command += " usepeerdns"; | 1202 | command += " usepeerdns"; |
1202 | 1203 | ||
1203 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | 1204 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); |
1204 | for ( QStringList::Iterator it = arglist.begin(); | 1205 | for ( QStringList::Iterator it = arglist.begin(); |
1205 | it != arglist.end(); | 1206 | it != arglist.end(); |
1206 | ++it ) | 1207 | ++it ) |
1207 | { | 1208 | { |
1208 | command += " " + *it; | 1209 | command += " " + *it; |
1209 | } | 1210 | } |
1210 | 1211 | ||
1211 | // PAP settings | 1212 | // PAP settings |
1212 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { | 1213 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1213 | command += " -chap user "; | 1214 | command += " -chap user "; |
1214 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1215 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1215 | } | 1216 | } |
1216 | 1217 | ||
1217 | // CHAP settings | 1218 | // CHAP settings |
1218 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { | 1219 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1219 | command += " -pap user "; | 1220 | command += " -pap user "; |
1220 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1221 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1221 | } | 1222 | } |
1222 | 1223 | ||
1223 | // PAP/CHAP settings | 1224 | // PAP/CHAP settings |
1224 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { | 1225 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1225 | command += " user "; | 1226 | command += " user "; |
1226 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1227 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1227 | } | 1228 | } |
1228 | 1229 | ||
1229 | // check for debug | 1230 | // check for debug |
1230 | if(_ifaceppp->data()->getPPPDebug()) | 1231 | if(_ifaceppp->data()->getPPPDebug()) |
1231 | command += " debug"; | 1232 | command += " debug"; |
1232 | 1233 | ||
1233 | if (command.length() > MAX_CMDLEN) { | 1234 | if (command.length() > MAX_CMDLEN) { |
1234 | QMessageBox::critical(this, "error", i18n( | 1235 | QMessageBox::critical(this, "error", i18n( |
1235 | "pppd command + command-line arguments exceed " | 1236 | "pppd command + command-line arguments exceed " |
1236 | "2024 characters in length." | 1237 | "2024 characters in length." |
1237 | )); | 1238 | )); |
1238 | 1239 | ||
1239 | return false; // nonsensically long command which would bust my buffer buf. | 1240 | return false; // nonsensically long command which would bust my buffer buf. |
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | qApp->flushX(); | 1243 | qApp->flushX(); |
1243 | 1244 | ||
1244 | return _ifaceppp->modem()->execPPPDaemon(command); | 1245 | return _ifaceppp->modem()->execPPPDaemon(command); |
1245 | } | 1246 | } |
1246 | 1247 | ||
1247 | 1248 | ||
1248 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1249 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1249 | e->ignore(); | 1250 | e->ignore(); |
1250 | emit cancelbutton(); | 1251 | emit cancelbutton(); |
1251 | } | 1252 | } |
1252 | 1253 | ||
1253 | 1254 | ||
1254 | void ConnectWidget::setMsg(const QString &msg) { | 1255 | void ConnectWidget::setMsg(const QString &msg) { |
1255 | messg->setText(msg); | 1256 | messg->setText(msg); |
1256 | } | 1257 | } |
1257 | 1258 | ||
1258 | void ConnectWidget::writeline(const QString &s) { | 1259 | void ConnectWidget::writeline(const QString &s) { |
1259 | _ifaceppp->modem()->writeLine(s.local8Bit()); | 1260 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1260 | } | 1261 | } |
1261 | 1262 | ||
1262 | // Set the hostname and domain from DNS Server | 1263 | // Set the hostname and domain from DNS Server |
1263 | void auto_hostname(InterfacePPP *_ifaceppp) { | 1264 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1264 | struct in_addr local_ip; | 1265 | struct in_addr local_ip; |
1265 | struct hostent *hostname_entry; | 1266 | struct hostent *hostname_entry; |
1266 | QString new_hostname; | 1267 | QString new_hostname; |
1267 | int dot; | 1268 | int dot; |
1268 | char tmp_str[100]; // buffer overflow safe | 1269 | char tmp_str[100]; // buffer overflow safe |
1269 | 1270 | ||
1270 | gethostname(tmp_str, sizeof(tmp_str)); | 1271 | gethostname(tmp_str, sizeof(tmp_str)); |
1271 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1272 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1272 | old_hostname=tmp_str; // copy to QString | 1273 | old_hostname=tmp_str; // copy to QString |
1273 | 1274 | ||
1274 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { | 1275 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1275 | if ( _ifaceppp->data()->autoname()) { | 1276 | if ( _ifaceppp->data()->autoname()) { |
1276 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); | 1277 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); |
1277 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); | 1278 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); |
1278 | 1279 | ||
1279 | if (hostname_entry != 0L) { | 1280 | if (hostname_entry != 0L) { |
1280 | new_hostname=hostname_entry->h_name; | 1281 | new_hostname=hostname_entry->h_name; |
1281 | dot=new_hostname.find('.'); | 1282 | dot=new_hostname.find('.'); |
1282 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); | 1283 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); |
1283 | _ifaceppp->modem()->setHostname(new_hostname); | 1284 | _ifaceppp->modem()->setHostname(new_hostname); |
1284 | modified_hostname = TRUE; | 1285 | modified_hostname = TRUE; |
1285 | 1286 | ||
1286 | new_hostname=hostname_entry->h_name; | 1287 | new_hostname=hostname_entry->h_name; |
1287 | new_hostname.remove(0,dot+1); | 1288 | new_hostname.remove(0,dot+1); |
1288 | 1289 | ||
1289 | add_domain(new_hostname, _ifaceppp); | 1290 | add_domain(new_hostname, _ifaceppp); |
1290 | } | 1291 | } |
1291 | } | 1292 | } |
1292 | 1293 | ||
1293 | } | 1294 | } |
1294 | 1295 | ||
1295 | // Replace the DNS domain entry in the /etc/resolv.conf file and | 1296 | // Replace the DNS domain entry in the /etc/resolv.conf file and |
1296 | // disable the nameserver entries if option is enabled | 1297 | // disable the nameserver entries if option is enabled |
1297 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { | 1298 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { |
1298 | 1299 | ||
1299 | int fd; | 1300 | int fd; |
1300 | char c; | 1301 | char c; |
1301 | QString resolv[MAX_RESOLVCONF_LINES]; | 1302 | QString resolv[MAX_RESOLVCONF_LINES]; |
1302 | 1303 | ||
1303 | if (domain.isEmpty()) | 1304 | if (domain.isEmpty()) |
1304 | return; | 1305 | return; |
1305 | 1306 | ||
1306 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { | 1307 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1307 | 1308 | ||
1308 | int i=0; | 1309 | int i=0; |
1309 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { | 1310 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { |
1310 | if(c == '\n') { | 1311 | if(c == '\n') { |
1311 | i++; | 1312 | i++; |
1312 | } | 1313 | } |
1313 | else { | 1314 | else { |
1314 | resolv[i] += c; | 1315 | resolv[i] += c; |
1315 | } | 1316 | } |
1316 | } | 1317 | } |
1317 | close(fd); | 1318 | close(fd); |
1318 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; | 1319 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; |
1319 | 1320 | ||
1320 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1321 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1321 | QCString tmp = "domain " + domain.local8Bit() + | 1322 | QCString tmp = "domain " + domain.local8Bit() + |
1322 | " \t\t#kppp temp entry\n"; | 1323 | " \t\t#kppp temp entry\n"; |
1323 | write(fd, tmp.data(), tmp.length()); | 1324 | write(fd, tmp.data(), tmp.length()); |
1324 | 1325 | ||
1325 | for(int j=0; j < i; j++) { | 1326 | for(int j=0; j < i; j++) { |
1326 | if((resolv[j].contains("domain") || | 1327 | if((resolv[j].contains("domain") || |
1327 | ( resolv[j].contains("nameserver") | 1328 | ( resolv[j].contains("nameserver") |
1328 | && !resolv[j].contains("#kppp temp entry") | 1329 | && !resolv[j].contains("#kppp temp entry") |
1329 | && _ifaceppp->data()->exDNSDisabled())) | 1330 | && _ifaceppp->data()->exDNSDisabled())) |
1330 | && !resolv[j].contains("#entry disabled by kppp")) { | 1331 | && !resolv[j].contains("#entry disabled by kppp")) { |
1331 | QCString tmp = "# " + resolv[j].local8Bit() + | 1332 | QCString tmp = "# " + resolv[j].local8Bit() + |
1332 | " \t#entry disabled by kppp\n"; | 1333 | " \t#entry disabled by kppp\n"; |
1333 | write(fd, tmp, tmp.length()); | 1334 | write(fd, tmp, tmp.length()); |
1334 | } | 1335 | } |
1335 | else { | 1336 | else { |
1336 | QCString tmp = resolv[j].local8Bit() + "\n"; | 1337 | QCString tmp = resolv[j].local8Bit() + "\n"; |
1337 | write(fd, tmp, tmp.length()); | 1338 | write(fd, tmp, tmp.length()); |
1338 | } | 1339 | } |
1339 | } | 1340 | } |
1340 | } | 1341 | } |
1341 | close(fd); | 1342 | close(fd); |
1342 | } | 1343 | } |
1343 | } | 1344 | } |
1344 | 1345 | ||
1345 | 1346 | ||
1346 | // adds the DNS entries in the /etc/resolv.conf file | 1347 | // adds the DNS entries in the /etc/resolv.conf file |
1347 | void adddns( InterfacePPP *_ifaceppp) | 1348 | void adddns( InterfacePPP *_ifaceppp) |
1348 | { | 1349 | { |
1349 | int fd; | 1350 | int fd; |
1350 | 1351 | ||
1351 | if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1352 | if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1352 | QStringList &dnslist = _ifaceppp->data()->dns(); | 1353 | QStringList &dnslist = _ifaceppp->data()->dns(); |
1353 | for ( QStringList::Iterator it = dnslist.begin(); | 1354 | for ( QStringList::Iterator it = dnslist.begin(); |
1354 | it != dnslist.end(); | 1355 | it != dnslist.end(); |
1355 | ++it ) | 1356 | ++it ) |
1356 | { | 1357 | { |
1357 | QCString dns = "nameserver " + (*it).local8Bit() + | 1358 | QCString dns = "nameserver " + (*it).local8Bit() + |
1358 | " \t#kppp temp entry\n"; | 1359 | " \t#kppp temp entry\n"; |
1359 | write(fd, dns.data(), dns.length()); | 1360 | write(fd, dns.data(), dns.length()); |
1360 | } | 1361 | } |
1361 | close(fd); | 1362 | close(fd); |
1362 | } | 1363 | } |
1363 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); | 1364 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1364 | } | 1365 | } |
1365 | 1366 | ||
1366 | void addpeerdns(InterfacePPP *_ifaceppp) { | 1367 | void addpeerdns(InterfacePPP *_ifaceppp) { |
1367 | int fd, fd2; | 1368 | int fd, fd2; |
1368 | 1369 | ||
1369 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1370 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1370 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { | 1371 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { |
1371 | char c; | 1372 | char c; |
1372 | int i = 0; | 1373 | int i = 0; |
1373 | while(i++ < 100 && read(fd2, &c, 1) == 1) { | 1374 | while(i++ < 100 && read(fd2, &c, 1) == 1) { |
1374 | if(c == '\n') | 1375 | if(c == '\n') |
1375 | write(fd, "\t#kppp temp entry\n", 18); | 1376 | write(fd, "\t#kppp temp entry\n", 18); |
1376 | else | 1377 | else |
1377 | write(fd, &c, 1); | 1378 | write(fd, &c, 1); |
1378 | } | 1379 | } |
1379 | close(fd2); | 1380 | close(fd2); |
1380 | } else | 1381 | } else |
1381 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); | 1382 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); |
1382 | close(fd); | 1383 | close(fd); |
1383 | } | 1384 | } |
1384 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); | 1385 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1385 | } | 1386 | } |
1386 | 1387 | ||
1387 | // remove the dns entries from the /etc/resolv.conf file | 1388 | // remove the dns entries from the /etc/resolv.conf file |
1388 | void removedns(InterfacePPP *_ifaceppp) { | 1389 | void removedns(InterfacePPP *_ifaceppp) { |
1389 | 1390 | ||
1390 | int fd; | 1391 | int fd; |
1391 | char c; | 1392 | char c; |
1392 | QString resolv[MAX_RESOLVCONF_LINES]; | 1393 | QString resolv[MAX_RESOLVCONF_LINES]; |
1393 | 1394 | ||
1394 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { | 1395 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1395 | 1396 | ||
1396 | int i=0; | 1397 | int i=0; |
1397 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { | 1398 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { |
1398 | if(c == '\n') { | 1399 | if(c == '\n') { |
1399 | i++; | 1400 | i++; |
1400 | } | 1401 | } |
1401 | else { | 1402 | else { |
1402 | resolv[i] += c; | 1403 | resolv[i] += c; |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | close(fd); | 1406 | close(fd); |
1406 | 1407 | ||
1407 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1408 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1408 | for(int j=0; j < i; j++) { | 1409 | for(int j=0; j < i; j++) { |
1409 | if(resolv[j].contains("#kppp temp entry")) continue; | 1410 | if(resolv[j].contains("#kppp temp entry")) continue; |
1410 | if(resolv[j].contains("#entry disabled by kppp")) { | 1411 | if(resolv[j].contains("#entry disabled by kppp")) { |
1411 | QCString tmp = resolv[j].local8Bit(); | 1412 | QCString tmp = resolv[j].local8Bit(); |
1412 | write(fd, tmp.data()+2, tmp.length() - 27); | 1413 | write(fd, tmp.data()+2, tmp.length() - 27); |
1413 | write(fd, "\n", 1); | 1414 | write(fd, "\n", 1); |
1414 | } | 1415 | } |
1415 | else { | 1416 | else { |
1416 | QCString tmp = resolv[j].local8Bit() + "\n"; | 1417 | QCString tmp = resolv[j].local8Bit() + "\n"; |
1417 | write(fd, tmp, tmp.length()); | 1418 | write(fd, tmp, tmp.length()); |
1418 | } | 1419 | } |
1419 | } | 1420 | } |
1420 | } | 1421 | } |
1421 | close(fd); | 1422 | close(fd); |
1422 | 1423 | ||
1423 | } | 1424 | } |
1424 | 1425 | ||
1425 | if ( modified_hostname ) { | 1426 | if ( modified_hostname ) { |
1426 | _ifaceppp->modem()->setHostname(old_hostname); | 1427 | _ifaceppp->modem()->setHostname(old_hostname); |
1427 | modified_hostname = FALSE; | 1428 | modified_hostname = FALSE; |
1428 | } | 1429 | } |
1429 | 1430 | ||
1430 | } | 1431 | } |
1431 | 1432 | ||
1432 | 1433 | ||
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 45d6e4f..b880978 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -1,1177 +1,1133 @@ | |||
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 <qbuttongroup.h> | 33 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 34 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qdialog.h> | 36 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | ||
37 | 38 | ||
38 | #include "edit.h" | 39 | #include "edit.h" |
39 | #include "pppdata.h" | 40 | #include "pppdata.h" |
40 | #include "iplined.h" | 41 | #include "iplined.h" |
41 | #include "auth.h" | 42 | #include "auth.h" |
42 | 43 | ||
43 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
44 | , const char *name ) | 45 | , const char *name ) |
45 | : QWidget(parent, name), _pppdata(pd) | 46 | : QWidget(parent, name), _pppdata(pd) |
46 | { | 47 | { |
47 | const int GRIDROWS = 6; | 48 | const int GRIDROWS = 6; |
48 | 49 | ||
49 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | 50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
50 | 51 | ||
51 | connect_label = new QLabel(tr("Connection name:"), this); | 52 | connect_label = new QLabel(tr("Connection name:"), this); |
52 | tl->addWidget(connect_label, 0, 0); | 53 | tl->addWidget(connect_label, 0, 0); |
53 | 54 | ||
54 | connectname_l = new QLineEdit(this); | 55 | connectname_l = new QLineEdit(this); |
55 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 56 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
56 | tl->addWidget(connectname_l, 0, 1); | 57 | tl->addWidget(connectname_l, 0, 1); |
57 | QString tmp = tr("Type in a unique name for this connection"); | 58 | QString tmp = tr("Type in a unique name for this connection"); |
58 | 59 | ||
59 | QWhatsThis::add(connect_label,tmp); | 60 | QWhatsThis::add(connect_label,tmp); |
60 | QWhatsThis::add(connectname_l,tmp); | 61 | QWhatsThis::add(connectname_l,tmp); |
61 | 62 | ||
62 | 63 | ||
63 | number_label = new QLabel(tr("Phone number:"), this); | 64 | number_label = new QLabel(tr("Phone number:"), this); |
64 | number_label->setAlignment(AlignTop|AlignLeft); | 65 | number_label->setAlignment(AlignTop|AlignLeft); |
65 | tl->addWidget(number_label, 1, 0); | 66 | tl->addWidget(number_label, 1, 0); |
66 | 67 | ||
67 | QHBoxLayout *lpn = new QHBoxLayout(5); | 68 | QHBoxLayout *lpn = new QHBoxLayout(5); |
68 | tl->addLayout(lpn, 1, 1); | 69 | tl->addLayout(lpn, 1, 1); |
69 | numbers = new QListBox(this); | 70 | numbers = new QListBox(this); |
70 | // numbers->setMinimumSize(120, 70); | 71 | // numbers->setMinimumSize(120, 70); |
71 | lpn->addWidget(numbers); | 72 | lpn->addWidget(numbers); |
72 | QVBoxLayout *lpn1 = new QVBoxLayout; | 73 | QVBoxLayout *lpn1 = new QVBoxLayout; |
73 | lpn->addLayout(lpn1); | 74 | lpn->addLayout(lpn1); |
74 | add = new QPushButton(tr("&Add..."), this); | 75 | add = new QPushButton(tr("&Add..."), this); |
75 | del = new QPushButton(tr("&Remove"), this); | 76 | del = new QPushButton(tr("&Remove"), this); |
76 | 77 | ||
77 | up = new QPushButton(this); | 78 | up = new QPushButton(this); |
78 | //FIXME: QPixmap pm = BarIcon("up"); | 79 | up->setPixmap( Resource::loadPixmap("inline/up") ); |
79 | // up->setPixmap(pm); | ||
80 | down = new QPushButton(this); | 80 | down = new QPushButton(this); |
81 | //FIXME: pm = BarIcon("down"); | 81 | down->setPixmap( Resource::loadPixmap("inline/down") ); |
82 | // down->setPixmap(pm); | ||
83 | lpn1->addWidget(add); | 82 | lpn1->addWidget(add); |
84 | lpn1->addWidget(del); | 83 | lpn1->addWidget(del); |
85 | lpn1->addStretch(1); | 84 | lpn1->addStretch(1); |
86 | lpn1->addWidget(up); | 85 | lpn1->addWidget(up); |
87 | lpn1->addWidget(down); | 86 | lpn1->addWidget(down); |
88 | connect(add, SIGNAL(clicked()), | 87 | connect(add, SIGNAL(clicked()), |
89 | this, SLOT(addNumber())); | 88 | this, SLOT(addNumber())); |
90 | connect(del, SIGNAL(clicked()), | 89 | connect(del, SIGNAL(clicked()), |
91 | this, SLOT(delNumber())); | 90 | this, SLOT(delNumber())); |
92 | connect(up, SIGNAL(clicked()), | 91 | connect(up, SIGNAL(clicked()), |
93 | this, SLOT(upNumber())); | 92 | this, SLOT(upNumber())); |
94 | connect(down, SIGNAL(clicked()), | 93 | connect(down, SIGNAL(clicked()), |
95 | this, SLOT(downNumber())); | 94 | this, SLOT(downNumber())); |
96 | connect(numbers, SIGNAL(highlighted(int)), | 95 | connect(numbers, SIGNAL(highlighted(int)), |
97 | this, SLOT(selectionChanged(int))); | 96 | this, SLOT(selectionChanged(int))); |
98 | numbersChanged(); | 97 | numbersChanged(); |
99 | 98 | ||
100 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 99 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
101 | "can supply multiple numbers here, simply\n" | 100 | "can supply multiple numbers here, simply\n" |
102 | "click on \"Add\". You can arrange the\n" | 101 | "click on \"Add\". You can arrange the\n" |
103 | "order the numbers are tried by using the\n" | 102 | "order the numbers are tried by using the\n" |
104 | "arrow buttons.\n\n" | 103 | "arrow buttons.\n\n" |
105 | "When a number is busy or fails, <i>kppp</i> will \n" | 104 | "When a number is busy or fails, <i>kppp</i> will \n" |
106 | "try the next number and so on"); | 105 | "try the next number and so on"); |
107 | 106 | ||
108 | QWhatsThis::add(number_label,tmp); | 107 | QWhatsThis::add(number_label,tmp); |
109 | QWhatsThis::add(numbers,tmp); | 108 | QWhatsThis::add(numbers,tmp); |
110 | 109 | ||
111 | auth_l = new QLabel(tr("Authentication:"), this); | ||
112 | tl->addWidget(auth_l, 3, 0); | ||
113 | |||
114 | auth = new QComboBox(this); | ||
115 | auth->insertItem(tr("Script-based")); | ||
116 | auth->insertItem(tr("PAP")); | ||
117 | auth->insertItem(tr("Terminal-based")); | ||
118 | auth->insertItem(tr("CHAP")); | ||
119 | auth->insertItem(tr("PAP/CHAP")); | ||
120 | tl->addWidget(auth, 3, 1); | ||
121 | tmp = tr("<p>Specifies the method used to identify yourself to\n" | ||
122 | "the PPP server. Most universities still use\n" | ||
123 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | ||
124 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | ||
125 | "unsure, contact your ISP.\n" | ||
126 | "\n" | ||
127 | "If you can choose between PAP and CHAP,\n" | ||
128 | "choose CHAP, because it's much safer. If you don't know\n" | ||
129 | "whether PAP or CHAP is right, choose PAP/CHAP."); | ||
130 | |||
131 | QWhatsThis::add(auth_l,tmp); | ||
132 | QWhatsThis::add(auth,tmp); | ||
133 | |||
134 | store_password = new QCheckBox(tr("Store password"), this); | ||
135 | store_password->setChecked(true); | ||
136 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); | ||
137 | QWhatsThis::add(store_password, | ||
138 | tr("<p>When this is turned on, your ISP password\n" | ||
139 | "will be saved in <i>kppp</i>'s config file, so\n" | ||
140 | "you do not need to type it in every time.\n" | ||
141 | "\n" | ||
142 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | ||
143 | "plain text in the config file, which is\n" | ||
144 | "readable only to you. Make sure nobody\n" | ||
145 | "gains access to this file!")); | ||
146 | |||
147 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
148 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
149 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
150 | 113 | ||
151 | // Set defaults if editing an existing connection | 114 | // Set defaults if editing an existing connection |
152 | if(!isnewaccount) { | 115 | if(!isnewaccount) { |
153 | connectname_l->setText(_pppdata->accname()); | 116 | connectname_l->setText(_pppdata->accname()); |
154 | 117 | ||
155 | // insert the phone numbers into the listbox | 118 | // insert the phone numbers into the listbox |
156 | QString n = _pppdata->phonenumber(); | 119 | QString n = _pppdata->phonenumber(); |
157 | QString tmp = ""; | 120 | QString tmp = ""; |
158 | uint idx = 0; | 121 | uint idx = 0; |
159 | while(idx != n.length()) { | 122 | while(idx != n.length()) { |
160 | if(n[idx] == ':') { | 123 | if(n[idx] == ':') { |
161 | if(tmp.length() > 0) | 124 | if(tmp.length() > 0) |
162 | numbers->insertItem(tmp); | 125 | numbers->insertItem(tmp); |
163 | tmp = ""; | 126 | tmp = ""; |
164 | } else | 127 | } else |
165 | tmp += n[idx]; | 128 | tmp += n[idx]; |
166 | idx++; | 129 | idx++; |
167 | } | 130 | } |
168 | if(tmp.length() > 0) | 131 | if(tmp.length() > 0) |
169 | numbers->insertItem(tmp); | 132 | numbers->insertItem(tmp); |
170 | 133 | ||
171 | auth->setCurrentItem(_pppdata->authMethod()); | ||
172 | store_password->setChecked(_pppdata->storePassword()); | ||
173 | } else { | ||
174 | // select PAP/CHAP as default | ||
175 | auth->setCurrentItem(AUTH_PAPCHAP); | ||
176 | } | 134 | } |
177 | 135 | ||
178 | numbersChanged(); | 136 | numbersChanged(); |
179 | tl->activate(); | 137 | tl->activate(); |
180 | } | 138 | } |
181 | 139 | ||
182 | bool DialWidget::save() { | 140 | bool DialWidget::save() { |
183 | //first check to make sure that the account name is unique! | 141 | //first check to make sure that the account name is unique! |
184 | if(connectname_l->text().isEmpty() || | 142 | if(connectname_l->text().isEmpty() || |
185 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 143 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
186 | return false; | 144 | return false; |
187 | } else { | 145 | } else { |
188 | _pppdata->setAccname(connectname_l->text()); | 146 | _pppdata->setAccname(connectname_l->text()); |
189 | 147 | ||
190 | QString number = ""; | 148 | QString number = ""; |
191 | for(uint i = 0; i < numbers->count(); i++) { | 149 | for(uint i = 0; i < numbers->count(); i++) { |
192 | if(i != 0) | 150 | if(i != 0) |
193 | number += ":"; | 151 | number += ":"; |
194 | number += numbers->text(i); | 152 | number += numbers->text(i); |
195 | } | 153 | } |
196 | 154 | ||
197 | _pppdata->setPhonenumber(number); | 155 | _pppdata->setPhonenumber(number); |
198 | _pppdata->setAuthMethod(auth->currentItem()); | ||
199 | _pppdata->setStorePassword(store_password->isChecked()); | ||
200 | return true; | 156 | return true; |
201 | } | 157 | } |
202 | } | 158 | } |
203 | 159 | ||
204 | 160 | ||
205 | void DialWidget::numbersChanged() { | 161 | void DialWidget::numbersChanged() { |
206 | int sel = numbers->currentItem(); | 162 | int sel = numbers->currentItem(); |
207 | 163 | ||
208 | del->setEnabled(sel != -1); | 164 | del->setEnabled(sel != -1); |
209 | up->setEnabled(sel != -1 && sel != 0); | 165 | up->setEnabled(sel != -1 && sel != 0); |
210 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
211 | } | 167 | } |
212 | 168 | ||
213 | 169 | ||
214 | void DialWidget::selectionChanged(int) { | 170 | void DialWidget::selectionChanged(int) { |
215 | numbersChanged(); | 171 | numbersChanged(); |
216 | } | 172 | } |
217 | 173 | ||
218 | 174 | ||
219 | void DialWidget::addNumber() { | 175 | void DialWidget::addNumber() { |
220 | PhoneNumberDialog dlg(this); | 176 | PhoneNumberDialog dlg(this); |
221 | if(dlg.exec()) { | 177 | if(dlg.exec()) { |
222 | numbers->insertItem(dlg.phoneNumber()); | 178 | numbers->insertItem(dlg.phoneNumber()); |
223 | numbersChanged(); | 179 | numbersChanged(); |
224 | } | 180 | } |
225 | } | 181 | } |
226 | 182 | ||
227 | 183 | ||
228 | void DialWidget::delNumber() { | 184 | void DialWidget::delNumber() { |
229 | if(numbers->currentItem() != -1) { | 185 | if(numbers->currentItem() != -1) { |
230 | numbers->removeItem(numbers->currentItem()); | 186 | numbers->removeItem(numbers->currentItem()); |
231 | numbersChanged(); | 187 | numbersChanged(); |
232 | } | 188 | } |
233 | } | 189 | } |
234 | 190 | ||
235 | 191 | ||
236 | void DialWidget::upNumber() { | 192 | void DialWidget::upNumber() { |
237 | int idx = numbers->currentItem(); | 193 | int idx = numbers->currentItem(); |
238 | if(idx != -1) { | 194 | if(idx != -1) { |
239 | QString item = numbers->text(idx); | 195 | QString item = numbers->text(idx); |
240 | numbers->removeItem(idx); | 196 | numbers->removeItem(idx); |
241 | numbers->insertItem(item, idx-1); | 197 | numbers->insertItem(item, idx-1); |
242 | numbers->setCurrentItem(idx-1); | 198 | numbers->setCurrentItem(idx-1); |
243 | numbersChanged(); | 199 | numbersChanged(); |
244 | } | 200 | } |
245 | } | 201 | } |
246 | 202 | ||
247 | 203 | ||
248 | void DialWidget::downNumber() { | 204 | void DialWidget::downNumber() { |
249 | int idx = numbers->currentItem(); | 205 | int idx = numbers->currentItem(); |
250 | if(idx != -1) { | 206 | if(idx != -1) { |
251 | QString item = numbers->text(idx); | 207 | QString item = numbers->text(idx); |
252 | numbers->removeItem(idx); | 208 | numbers->removeItem(idx); |
253 | numbers->insertItem(item, idx+1); | 209 | numbers->insertItem(item, idx+1); |
254 | numbers->setCurrentItem(idx+1); | 210 | numbers->setCurrentItem(idx+1); |
255 | numbersChanged(); | 211 | numbersChanged(); |
256 | } | 212 | } |
257 | } | 213 | } |
258 | 214 | ||
259 | 215 | ||
260 | void DialWidget::pppdargsbutton() { | 216 | void DialWidget::pppdargsbutton() { |
261 | PPPdArguments pa(_pppdata, this); | 217 | PPPdArguments pa(_pppdata, this); |
262 | pa.exec(); | 218 | pa.exec(); |
263 | } | 219 | } |
264 | 220 | ||
265 | 221 | ||
266 | 222 | ||
267 | ///////////////////////////////////////////////////////////////////////////// | 223 | ///////////////////////////////////////////////////////////////////////////// |
268 | // ExecWidget | 224 | // ExecWidget |
269 | ///////////////////////////////////////////////////////////////////////////// | 225 | ///////////////////////////////////////////////////////////////////////////// |
270 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 226 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
271 | QWidget(parent, name), _pppdata(pd) | 227 | QWidget(parent, name), _pppdata(pd) |
272 | { | 228 | { |
273 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 229 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
274 | 230 | ||
275 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); | 231 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); |
276 | 232 | ||
277 | tl->addWidget(l); | 233 | tl->addWidget(l); |
278 | tl->addStretch(1); | 234 | tl->addStretch(1); |
279 | 235 | ||
280 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 236 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
281 | tl->addLayout(l1); | 237 | tl->addLayout(l1); |
282 | l1->setColStretch(0, 0); | 238 | l1->setColStretch(0, 0); |
283 | l1->setColStretch(1, 1); | 239 | l1->setColStretch(1, 1); |
284 | 240 | ||
285 | before_connect_l = new QLabel(tr("Before connect:"), this); | 241 | before_connect_l = new QLabel(tr("Before connect:"), this); |
286 | before_connect_l->setAlignment(AlignVCenter); | 242 | before_connect_l->setAlignment(AlignVCenter); |
287 | l1->addWidget(before_connect_l, 0, 0); | 243 | l1->addWidget(before_connect_l, 0, 0); |
288 | before_connect = new QLineEdit(this); | 244 | before_connect = new QLineEdit(this); |
289 | // before_connect->setMaxLength(COMMAND_SIZE); | 245 | // before_connect->setMaxLength(COMMAND_SIZE); |
290 | l1->addWidget(before_connect, 0, 1); | 246 | l1->addWidget(before_connect, 0, 1); |
291 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 247 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
292 | "is established. It is called immediately before\n" | 248 | "is established. It is called immediately before\n" |
293 | "dialing has begun.\n\n" | 249 | "dialing has begun.\n\n" |
294 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 250 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
295 | "modem."); | 251 | "modem."); |
296 | 252 | ||
297 | QWhatsThis::add(before_connect_l,tmp); | 253 | QWhatsThis::add(before_connect_l,tmp); |
298 | QWhatsThis::add(before_connect,tmp); | 254 | QWhatsThis::add(before_connect,tmp); |
299 | 255 | ||
300 | command_label = new QLabel(tr("Upon connect:"), this); | 256 | command_label = new QLabel(tr("Upon connect:"), this); |
301 | command_label->setAlignment(AlignVCenter); | 257 | command_label->setAlignment(AlignVCenter); |
302 | l1->addWidget(command_label, 1, 0); | 258 | l1->addWidget(command_label, 1, 0); |
303 | command = new QLineEdit(this); | 259 | command = new QLineEdit(this); |
304 | // command->setMaxLength(COMMAND_SIZE); | 260 | // command->setMaxLength(COMMAND_SIZE); |
305 | l1->addWidget(command, 1, 1); | 261 | l1->addWidget(command, 1, 1); |
306 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 262 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
307 | "is established. When your program is called, all\n" | 263 | "is established. When your program is called, all\n" |
308 | "preparations for an Internet connection are finished.\n" | 264 | "preparations for an Internet connection are finished.\n" |
309 | "\n" | 265 | "\n" |
310 | "Very useful for fetching mail and news"); | 266 | "Very useful for fetching mail and news"); |
311 | 267 | ||
312 | QWhatsThis::add(command_label,tmp); | 268 | QWhatsThis::add(command_label,tmp); |
313 | QWhatsThis::add(command,tmp); | 269 | QWhatsThis::add(command,tmp); |
314 | 270 | ||
315 | predisconnect_label = new QLabel(tr("Before disconnect:"), | 271 | predisconnect_label = new QLabel(tr("Before disconnect:"), |
316 | this); | 272 | this); |
317 | predisconnect_label->setAlignment(AlignVCenter); | 273 | predisconnect_label->setAlignment(AlignVCenter); |
318 | l1->addWidget(predisconnect_label, 2, 0); | 274 | l1->addWidget(predisconnect_label, 2, 0); |
319 | predisconnect = new QLineEdit(this); | 275 | predisconnect = new QLineEdit(this); |
320 | // predisconnect->setMaxLength(COMMAND_SIZE); | 276 | // predisconnect->setMaxLength(COMMAND_SIZE); |
321 | l1->addWidget(predisconnect, 2, 1); | 277 | l1->addWidget(predisconnect, 2, 1); |
322 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 278 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
323 | "is closed. The connection will stay open until\n" | 279 | "is closed. The connection will stay open until\n" |
324 | "the program exits."); | 280 | "the program exits."); |
325 | 281 | ||
326 | QWhatsThis::add(predisconnect_label,tmp); | 282 | QWhatsThis::add(predisconnect_label,tmp); |
327 | QWhatsThis::add(predisconnect,tmp); | 283 | QWhatsThis::add(predisconnect,tmp); |
328 | 284 | ||
329 | discommand_label = new QLabel(tr("Upon disconnect:"), | 285 | discommand_label = new QLabel(tr("Upon disconnect:"), |
330 | this); | 286 | this); |
331 | discommand_label->setAlignment(AlignVCenter); | 287 | discommand_label->setAlignment(AlignVCenter); |
332 | l1->addWidget(discommand_label, 3, 0); | 288 | l1->addWidget(discommand_label, 3, 0); |
333 | 289 | ||
334 | discommand = new QLineEdit(this); | 290 | discommand = new QLineEdit(this); |
335 | // discommand->setMaxLength(COMMAND_SIZE); | 291 | // discommand->setMaxLength(COMMAND_SIZE); |
336 | l1->addWidget(discommand, 3, 1); | 292 | l1->addWidget(discommand, 3, 1); |
337 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 293 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
338 | "has been closed."); | 294 | "has been closed."); |
339 | 295 | ||
340 | QWhatsThis::add(discommand_label,tmp); | 296 | QWhatsThis::add(discommand_label,tmp); |
341 | QWhatsThis::add(discommand,tmp); | 297 | QWhatsThis::add(discommand,tmp); |
342 | 298 | ||
343 | // extra space between entries | 299 | // extra space between entries |
344 | l1->addRowSpacing(1, 5); | 300 | l1->addRowSpacing(1, 5); |
345 | l1->addRowSpacing(3, 5); | 301 | l1->addRowSpacing(3, 5); |
346 | 302 | ||
347 | tl->addStretch(1); | 303 | tl->addStretch(1); |
348 | tl->activate(); | 304 | tl->activate(); |
349 | 305 | ||
350 | // Set defaults if editing an existing connection | 306 | // Set defaults if editing an existing connection |
351 | if(!isnewaccount) { | 307 | if(!isnewaccount) { |
352 | before_connect->setText(_pppdata->command_before_connect()); | 308 | before_connect->setText(_pppdata->command_before_connect()); |
353 | command->setText(_pppdata->command_on_connect()); | 309 | command->setText(_pppdata->command_on_connect()); |
354 | discommand->setText(_pppdata->command_on_disconnect()); | 310 | discommand->setText(_pppdata->command_on_disconnect()); |
355 | predisconnect->setText(_pppdata->command_before_disconnect()); | 311 | predisconnect->setText(_pppdata->command_before_disconnect()); |
356 | } | 312 | } |
357 | } | 313 | } |
358 | 314 | ||
359 | 315 | ||
360 | bool ExecWidget::save() { | 316 | bool ExecWidget::save() { |
361 | _pppdata->setCommand_before_connect(before_connect->text()); | 317 | _pppdata->setCommand_before_connect(before_connect->text()); |
362 | _pppdata->setCommand_on_connect(command->text()); | 318 | _pppdata->setCommand_on_connect(command->text()); |
363 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 319 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
364 | _pppdata->setCommand_on_disconnect(discommand->text()); | 320 | _pppdata->setCommand_on_disconnect(discommand->text()); |
365 | return true; | 321 | return true; |
366 | } | 322 | } |
367 | 323 | ||
368 | 324 | ||
369 | 325 | ||
370 | ///////////////////////////////////////////////////////////////////////////// | 326 | ///////////////////////////////////////////////////////////////////////////// |
371 | // | 327 | // |
372 | // IPWidget | 328 | // IPWidget |
373 | // | 329 | // |
374 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
375 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 331 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
376 | : QWidget(parent, name), _pppdata(pd) | 332 | : QWidget(parent, name), _pppdata(pd) |
377 | { | 333 | { |
378 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 334 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
379 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 335 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
380 | 336 | ||
381 | box = new QVGroupBox(tr("Configuration"), this); | 337 | box = new QVGroupBox(tr("Configuration"), this); |
382 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 338 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
383 | 339 | ||
384 | rb = new QButtonGroup(this); | 340 | rb = new QButtonGroup(this); |
385 | rb->hide(); | 341 | rb->hide(); |
386 | connect(rb, SIGNAL(clicked(int)), | 342 | connect(rb, SIGNAL(clicked(int)), |
387 | SLOT(hitIPSelect(int))); | 343 | SLOT(hitIPSelect(int))); |
388 | 344 | ||
389 | dynamicadd_rb = new QRadioButton(box); | 345 | dynamicadd_rb = new QRadioButton(box); |
390 | dynamicadd_rb->setText(tr("Dynamic IP address")); | 346 | dynamicadd_rb->setText(tr("Dynamic IP address")); |
391 | QWhatsThis::add(dynamicadd_rb, | 347 | QWhatsThis::add(dynamicadd_rb, |
392 | tr("Select this option when your computer gets an\n" | 348 | tr("Select this option when your computer gets an\n" |
393 | "internet address (IP) every time a\n" | 349 | "internet address (IP) every time a\n" |
394 | "connection is made.\n" | 350 | "connection is made.\n" |
395 | "\n" | 351 | "\n" |
396 | "Almost every Internet Service Provider uses\n" | 352 | "Almost every Internet Service Provider uses\n" |
397 | "this method, so this should be turned on.")); | 353 | "this method, so this should be turned on.")); |
398 | 354 | ||
399 | staticadd_rb = new QRadioButton(box); | 355 | staticadd_rb = new QRadioButton(box); |
400 | staticadd_rb->setText(tr("Static IP address")); | 356 | staticadd_rb->setText(tr("Static IP address")); |
401 | rb->insert(dynamicadd_rb, 0); | 357 | rb->insert(dynamicadd_rb, 0); |
402 | rb->insert(staticadd_rb, 1); | 358 | rb->insert(staticadd_rb, 1); |
403 | QWhatsThis::add(staticadd_rb, | 359 | QWhatsThis::add(staticadd_rb, |
404 | tr("Select this option when your computer has a\n" | 360 | tr("Select this option when your computer has a\n" |
405 | "fixed internet address (IP). Most computers\n" | 361 | "fixed internet address (IP). Most computers\n" |
406 | "don't have this, so you should probably select\n" | 362 | "don't have this, so you should probably select\n" |
407 | "dynamic IP addressing unless you know what you\n" | 363 | "dynamic IP addressing unless you know what you\n" |
408 | "are doing.")); | 364 | "are doing.")); |
409 | 365 | ||
410 | QWidget *ipWidget = new QWidget(box); | 366 | QWidget *ipWidget = new QWidget(box); |
411 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 367 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
412 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 368 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
413 | 369 | ||
414 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); | 370 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); |
415 | QString tmp = tr("If your computer has a permanent internet\n" | 371 | QString tmp = tr("If your computer has a permanent internet\n" |
416 | "address, you must supply your IP address here."); | 372 | "address, you must supply your IP address here."); |
417 | ipLayout->addWidget(ipaddress_label, 0, 0); | 373 | ipLayout->addWidget(ipaddress_label, 0, 0); |
418 | 374 | ||
419 | ipaddress_l = new IPLineEdit(ipWidget); | 375 | ipaddress_l = new IPLineEdit(ipWidget); |
420 | ipLayout->addWidget(ipaddress_l, 0, 1); | 376 | ipLayout->addWidget(ipaddress_l, 0, 1); |
421 | 377 | ||
422 | QWhatsThis::add(ipaddress_label,tmp); | 378 | QWhatsThis::add(ipaddress_label,tmp); |
423 | QWhatsThis::add(ipaddress_l,tmp); | 379 | QWhatsThis::add(ipaddress_l,tmp); |
424 | 380 | ||
425 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); | 381 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); |
426 | tmp = tr("<p>If your computer has a static Internet address,\n" | 382 | tmp = tr("<p>If your computer has a static Internet address,\n" |
427 | "you must supply a network mask here. In almost\n" | 383 | "you must supply a network mask here. In almost\n" |
428 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 384 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
429 | "but your mileage may vary.\n" | 385 | "but your mileage may vary.\n" |
430 | "\n" | 386 | "\n" |
431 | "If unsure, contact your Internet Service Provider"); | 387 | "If unsure, contact your Internet Service Provider"); |
432 | ipLayout->addWidget(sub_label, 1, 0); | 388 | ipLayout->addWidget(sub_label, 1, 0); |
433 | 389 | ||
434 | subnetmask_l = new IPLineEdit(ipWidget); | 390 | subnetmask_l = new IPLineEdit(ipWidget); |
435 | ipLayout->addWidget(subnetmask_l, 1, 1); | 391 | ipLayout->addWidget(subnetmask_l, 1, 1); |
436 | 392 | ||
437 | QWhatsThis::add(sub_label,tmp); | 393 | QWhatsThis::add(sub_label,tmp); |
438 | QWhatsThis::add(subnetmask_l,tmp); | 394 | QWhatsThis::add(subnetmask_l,tmp); |
439 | 395 | ||
440 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); | 396 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); |
441 | autoname->setChecked(_pppdata->autoname()); | 397 | autoname->setChecked(_pppdata->autoname()); |
442 | connect(autoname,SIGNAL(toggled(bool)), | 398 | connect(autoname,SIGNAL(toggled(bool)), |
443 | this,SLOT(autoname_t(bool))); | 399 | this,SLOT(autoname_t(bool))); |
444 | 400 | ||
445 | QWhatsThis::add(autoname, | 401 | QWhatsThis::add(autoname, |
446 | tr("<p>Whenever you connect, this reconfigures\n" | 402 | tr("<p>Whenever you connect, this reconfigures\n" |
447 | "your hostname to match the IP address you\n" | 403 | "your hostname to match the IP address you\n" |
448 | "got from the PPP server. This may be useful\n" | 404 | "got from the PPP server. This may be useful\n" |
449 | "if you need to use a protocol which depends\n" | 405 | "if you need to use a protocol which depends\n" |
450 | "on this information, but it can also cause several\n" | 406 | "on this information, but it can also cause several\n" |
451 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 407 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
452 | "\n" | 408 | "\n" |
453 | "Don't enable this unless you really need it.")); | 409 | "Don't enable this unless you really need it.")); |
454 | 410 | ||
455 | topLayout->addWidget(box); | 411 | topLayout->addWidget(box); |
456 | topLayout->addWidget(autoname); | 412 | topLayout->addWidget(autoname); |
457 | topLayout->addStretch(); | 413 | topLayout->addStretch(); |
458 | 414 | ||
459 | //load info from gpppdata | 415 | //load info from gpppdata |
460 | if(!isnewaccount) { | 416 | if(!isnewaccount) { |
461 | if(_pppdata->ipaddr() == "0.0.0.0" && | 417 | if(_pppdata->ipaddr() == "0.0.0.0" && |
462 | _pppdata->subnetmask() == "0.0.0.0") { | 418 | _pppdata->subnetmask() == "0.0.0.0") { |
463 | dynamicadd_rb->setChecked(true); | 419 | dynamicadd_rb->setChecked(true); |
464 | hitIPSelect(0); | 420 | hitIPSelect(0); |
465 | autoname->setChecked(_pppdata->autoname()); | 421 | autoname->setChecked(_pppdata->autoname()); |
466 | } | 422 | } |
467 | else { | 423 | else { |
468 | ipaddress_l->setText(_pppdata->ipaddr()); | 424 | ipaddress_l->setText(_pppdata->ipaddr()); |
469 | subnetmask_l->setText(_pppdata->subnetmask()); | 425 | subnetmask_l->setText(_pppdata->subnetmask()); |
470 | staticadd_rb->setChecked(true); | 426 | staticadd_rb->setChecked(true); |
471 | autoname->setChecked(false); | 427 | autoname->setChecked(false); |
472 | } | 428 | } |
473 | } | 429 | } |
474 | else { | 430 | else { |
475 | dynamicadd_rb->setChecked(true); | 431 | dynamicadd_rb->setChecked(true); |
476 | hitIPSelect(0); | 432 | hitIPSelect(0); |
477 | } | 433 | } |
478 | 434 | ||
479 | } | 435 | } |
480 | 436 | ||
481 | void IPWidget::autoname_t(bool on) { | 437 | void IPWidget::autoname_t(bool on) { |
482 | static bool was_warned = false; | 438 | static bool was_warned = false; |
483 | 439 | ||
484 | // big-fat warning when selecting the auto configure hostname option | 440 | // big-fat warning when selecting the auto configure hostname option |
485 | if(on && !was_warned) { | 441 | if(on && !was_warned) { |
486 | QMessageBox::information(this, | 442 | QMessageBox::information(this, |
487 | tr("Selecting this option might cause some weird " | 443 | tr("Selecting this option might cause some weird " |
488 | "problems with the X-server and applications " | 444 | "problems with the X-server and applications " |
489 | "while kppp is connected. Don't use it until " | 445 | "while kppp is connected. Don't use it until " |
490 | "you know what you are doing!\n" | 446 | "you know what you are doing!\n" |
491 | "For more information take a look at the " | 447 | "For more information take a look at the " |
492 | "handbook (or help) in the section \"Frequently " | 448 | "handbook (or help) in the section \"Frequently " |
493 | "asked questions\"."), | 449 | "asked questions\"."), |
494 | tr("Warning")); | 450 | tr("Warning")); |
495 | was_warned = true; | 451 | was_warned = true; |
496 | } | 452 | } |
497 | } | 453 | } |
498 | 454 | ||
499 | 455 | ||
500 | void IPWidget::save() { | 456 | void IPWidget::save() { |
501 | if(dynamicadd_rb->isChecked()) { | 457 | if(dynamicadd_rb->isChecked()) { |
502 | _pppdata->setIpaddr("0.0.0.0"); | 458 | _pppdata->setIpaddr("0.0.0.0"); |
503 | _pppdata->setSubnetmask("0.0.0.0"); | 459 | _pppdata->setSubnetmask("0.0.0.0"); |
504 | } else { | 460 | } else { |
505 | _pppdata->setIpaddr(ipaddress_l->text()); | 461 | _pppdata->setIpaddr(ipaddress_l->text()); |
506 | _pppdata->setSubnetmask(subnetmask_l->text()); | 462 | _pppdata->setSubnetmask(subnetmask_l->text()); |
507 | } | 463 | } |
508 | _pppdata->setAutoname(autoname->isChecked()); | 464 | _pppdata->setAutoname(autoname->isChecked()); |
509 | } | 465 | } |
510 | 466 | ||
511 | 467 | ||
512 | void IPWidget::hitIPSelect( int i ) { | 468 | void IPWidget::hitIPSelect( int i ) { |
513 | if(i == 0) { | 469 | if(i == 0) { |
514 | ipaddress_label->setEnabled(false); | 470 | ipaddress_label->setEnabled(false); |
515 | sub_label->setEnabled(false); | 471 | sub_label->setEnabled(false); |
516 | ipaddress_l->setEnabled(false); | 472 | ipaddress_l->setEnabled(false); |
517 | subnetmask_l->setEnabled(false); | 473 | subnetmask_l->setEnabled(false); |
518 | } | 474 | } |
519 | else { | 475 | else { |
520 | ipaddress_label->setEnabled(true); | 476 | ipaddress_label->setEnabled(true); |
521 | sub_label->setEnabled(true); | 477 | sub_label->setEnabled(true); |
522 | ipaddress_l->setEnabled(true); | 478 | ipaddress_l->setEnabled(true); |
523 | subnetmask_l->setEnabled(true); | 479 | subnetmask_l->setEnabled(true); |
524 | } | 480 | } |
525 | } | 481 | } |
526 | 482 | ||
527 | 483 | ||
528 | 484 | ||
529 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 485 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
530 | : QWidget(parent, name), _pppdata(pd) | 486 | : QWidget(parent, name), _pppdata(pd) |
531 | { | 487 | { |
532 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 488 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
533 | 489 | ||
534 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 490 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
535 | tl->addWidget(dnsdomain_label, 0, 0); | 491 | tl->addWidget(dnsdomain_label, 0, 0); |
536 | 492 | ||
537 | dnsdomain = new QLineEdit(this); | 493 | dnsdomain = new QLineEdit(this); |
538 | 494 | ||
539 | tl->addWidget(dnsdomain, 0, 1); | 495 | tl->addWidget(dnsdomain, 0, 1); |
540 | QString tmp = tr("If you enter a domain name here, this domain\n" | 496 | QString tmp = tr("If you enter a domain name here, this domain\n" |
541 | "name is used for your computer while you are\n" | 497 | "name is used for your computer while you are\n" |
542 | "connected. When the connection is closed, the\n" | 498 | "connected. When the connection is closed, the\n" |
543 | "original domain name of your computer is\n" | 499 | "original domain name of your computer is\n" |
544 | "restored.\n" | 500 | "restored.\n" |
545 | "\n" | 501 | "\n" |
546 | "If you leave this field blank, no changes are\n" | 502 | "If you leave this field blank, no changes are\n" |
547 | "made to the domain name."); | 503 | "made to the domain name."); |
548 | 504 | ||
549 | QWhatsThis::add(dnsdomain_label,tmp); | 505 | QWhatsThis::add(dnsdomain_label,tmp); |
550 | QWhatsThis::add(dnsdomain,tmp); | 506 | QWhatsThis::add(dnsdomain,tmp); |
551 | 507 | ||
552 | conf_label = new QLabel(tr("Configuration:"), this); | 508 | conf_label = new QLabel(tr("Configuration:"), this); |
553 | tl->addWidget(conf_label, 1, 0); | 509 | tl->addWidget(conf_label, 1, 0); |
554 | 510 | ||
555 | bg = new QButtonGroup("Group", this); | 511 | bg = new QButtonGroup("Group", this); |
556 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 512 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
557 | bg->hide(); | 513 | bg->hide(); |
558 | 514 | ||
559 | autodns = new QRadioButton(tr("Automatic"), this); | 515 | autodns = new QRadioButton(tr("Automatic"), this); |
560 | bg->insert(autodns, 0); | 516 | bg->insert(autodns, 0); |
561 | tl->addWidget(autodns, 1, 1); | 517 | tl->addWidget(autodns, 1, 1); |
562 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 518 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
563 | autodns->setEnabled(false); | 519 | autodns->setEnabled(false); |
564 | 520 | ||
565 | mandns = new QRadioButton(tr("Manual"), this); | 521 | mandns = new QRadioButton(tr("Manual"), this); |
566 | bg->insert(mandns, 1); | 522 | bg->insert(mandns, 1); |
567 | tl->addWidget(mandns, 2, 1); | 523 | tl->addWidget(mandns, 2, 1); |
568 | 524 | ||
569 | dns_label = new QLabel(tr("DNS IP address:"), this); | 525 | dns_label = new QLabel(tr("DNS IP address:"), this); |
570 | tl->addWidget(dns_label, 3, 0); | 526 | tl->addWidget(dns_label, 3, 0); |
571 | 527 | ||
572 | QHBoxLayout *l2 = new QHBoxLayout; | 528 | QHBoxLayout *l2 = new QHBoxLayout; |
573 | tl->addLayout(l2, 3, 1); | 529 | tl->addLayout(l2, 3, 1); |
574 | dnsipaddr = new IPLineEdit(this); | 530 | dnsipaddr = new IPLineEdit(this); |
575 | connect(dnsipaddr, SIGNAL(returnPressed()), | 531 | connect(dnsipaddr, SIGNAL(returnPressed()), |
576 | SLOT(adddns())); | 532 | SLOT(adddns())); |
577 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 533 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), |
578 | SLOT(DNS_Edit_Changed(const QString &))); | 534 | SLOT(DNS_Edit_Changed(const QString &))); |
579 | l2->addWidget(dnsipaddr, 1); | 535 | l2->addWidget(dnsipaddr, 1); |
580 | l2->addStretch(1); | 536 | l2->addStretch(1); |
581 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" | 537 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" |
582 | "used while you are connected. When the\n" | 538 | "used while you are connected. When the\n" |
583 | "connection is closed, this DNS entry will be\n" | 539 | "connection is closed, this DNS entry will be\n" |
584 | "removed again.\n" | 540 | "removed again.\n" |
585 | "\n" | 541 | "\n" |
586 | "To add a DNS server, type in the IP address of\n" | 542 | "To add a DNS server, type in the IP address of\n" |
587 | "the DNS server here and click on <b>Add</b>"); | 543 | "the DNS server here and click on <b>Add</b>"); |
588 | 544 | ||
589 | QWhatsThis::add(dns_label, tmp); | 545 | QWhatsThis::add(dns_label, tmp); |
590 | QWhatsThis::add(dnsipaddr, tmp); | 546 | QWhatsThis::add(dnsipaddr, tmp); |
591 | 547 | ||
592 | QHBoxLayout *l1 = new QHBoxLayout; | 548 | QHBoxLayout *l1 = new QHBoxLayout; |
593 | tl->addLayout(l1, 4, 1); | 549 | tl->addLayout(l1, 4, 1); |
594 | add = new QPushButton(tr("Add"), this); | 550 | add = new QPushButton(tr("Add"), this); |
595 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 551 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
596 | l1->addWidget(add); | 552 | l1->addWidget(add); |
597 | // l1->addStretch(1); | 553 | // l1->addStretch(1); |
598 | QWhatsThis::add(add, | 554 | QWhatsThis::add(add, |
599 | tr("Click this button to add the DNS server\n" | 555 | tr("Click this button to add the DNS server\n" |
600 | "specified in the field above. The entry\n" | 556 | "specified in the field above. The entry\n" |
601 | "will then be added to the list below")); | 557 | "will then be added to the list below")); |
602 | 558 | ||
603 | remove = new QPushButton(tr("Remove"), this); | 559 | remove = new QPushButton(tr("Remove"), this); |
604 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 560 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
605 | l1->addWidget(remove); | 561 | l1->addWidget(remove); |
606 | QWhatsThis::add(remove, | 562 | QWhatsThis::add(remove, |
607 | tr("Click this button to remove the selected DNS\n" | 563 | tr("Click this button to remove the selected DNS\n" |
608 | "server entry from the list below")); | 564 | "server entry from the list below")); |
609 | 565 | ||
610 | servers_label = new QLabel(tr("DNS address list:"), this); | 566 | servers_label = new QLabel(tr("DNS address list:"), this); |
611 | servers_label->setAlignment(AlignTop|AlignLeft); | 567 | servers_label->setAlignment(AlignTop|AlignLeft); |
612 | tl->addWidget(servers_label, 5, 0); | 568 | tl->addWidget(servers_label, 5, 0); |
613 | 569 | ||
614 | dnsservers = new QListBox(this); | 570 | dnsservers = new QListBox(this); |
615 | dnsservers->setMinimumSize(150, 80); | 571 | dnsservers->setMinimumSize(150, 80); |
616 | connect(dnsservers, SIGNAL(highlighted(int)), | 572 | connect(dnsservers, SIGNAL(highlighted(int)), |
617 | SLOT(DNS_Entry_Selected(int))); | 573 | SLOT(DNS_Entry_Selected(int))); |
618 | tl->addWidget(dnsservers, 5, 1); | 574 | tl->addWidget(dnsservers, 5, 1); |
619 | tmp = tr("<p>This shows all defined DNS servers to use\n" | 575 | tmp = tr("<p>This shows all defined DNS servers to use\n" |
620 | "while you are connected. Use the <b>Add</b> and\n" | 576 | "while you are connected. Use the <b>Add</b> and\n" |
621 | "<b>Remove</b> buttons to modify the list"); | 577 | "<b>Remove</b> buttons to modify the list"); |
622 | 578 | ||
623 | QWhatsThis::add(servers_label,tmp); | 579 | QWhatsThis::add(servers_label,tmp); |
624 | QWhatsThis::add(dnsservers,tmp); | 580 | QWhatsThis::add(dnsservers,tmp); |
625 | 581 | ||
626 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 582 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
627 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); | 583 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); |
628 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 584 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
629 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 585 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
630 | QWhatsThis::add(exdnsdisabled_toggle, | 586 | QWhatsThis::add(exdnsdisabled_toggle, |
631 | tr("<p>When this option is selected, all DNS\n" | 587 | tr("<p>When this option is selected, all DNS\n" |
632 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 588 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
633 | "temporary disabled while the dialup connection\n" | 589 | "temporary disabled while the dialup connection\n" |
634 | "is established. After the connection is\n" | 590 | "is established. After the connection is\n" |
635 | "closed, the servers will be re-enabled\n" | 591 | "closed, the servers will be re-enabled\n" |
636 | "\n" | 592 | "\n" |
637 | "Typically, there is no reason to use this\n" | 593 | "Typically, there is no reason to use this\n" |
638 | "option, but it may become useful under \n" | 594 | "option, but it may become useful under \n" |
639 | "some circumstances.")); | 595 | "some circumstances.")); |
640 | 596 | ||
641 | 597 | ||
642 | // restore data if editing | 598 | // restore data if editing |
643 | if(!isnewaccount) { | 599 | if(!isnewaccount) { |
644 | dnsservers->insertStringList(_pppdata->dns()); | 600 | dnsservers->insertStringList(_pppdata->dns()); |
645 | dnsdomain->setText(_pppdata->domain()); | 601 | dnsdomain->setText(_pppdata->domain()); |
646 | } | 602 | } |
647 | 603 | ||
648 | int mode = _pppdata->autoDNS() ? 0 : 1; | 604 | int mode = _pppdata->autoDNS() ? 0 : 1; |
649 | bg->setButton(mode); | 605 | bg->setButton(mode); |
650 | DNS_Mode_Selected(mode); | 606 | DNS_Mode_Selected(mode); |
651 | 607 | ||
652 | tl->activate(); | 608 | tl->activate(); |
653 | } | 609 | } |
654 | 610 | ||
655 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 611 | void DNSWidget::DNS_Edit_Changed(const QString &text) { |
656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 612 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
657 | add->setEnabled(text.find(r) != -1); | 613 | add->setEnabled(text.find(r) != -1); |
658 | } | 614 | } |
659 | 615 | ||
660 | void DNSWidget::DNS_Entry_Selected(int) { | 616 | void DNSWidget::DNS_Entry_Selected(int) { |
661 | remove->setEnabled(true); | 617 | remove->setEnabled(true); |
662 | } | 618 | } |
663 | 619 | ||
664 | void DNSWidget::DNS_Mode_Selected(int mode) { | 620 | void DNSWidget::DNS_Mode_Selected(int mode) { |
665 | bool on = (mode == 1); | 621 | bool on = (mode == 1); |
666 | dns_label->setEnabled(on); | 622 | dns_label->setEnabled(on); |
667 | servers_label->setEnabled(on); | 623 | servers_label->setEnabled(on); |
668 | dnsipaddr->setText(""); | 624 | dnsipaddr->setText(""); |
669 | dnsipaddr->setEnabled(on); | 625 | dnsipaddr->setEnabled(on); |
670 | add->setEnabled(false); | 626 | add->setEnabled(false); |
671 | remove->setEnabled(dnsservers->count()>0 && on); | 627 | remove->setEnabled(dnsservers->count()>0 && on); |
672 | dnsservers->clearSelection(); | 628 | dnsservers->clearSelection(); |
673 | dnsservers->setEnabled(on); | 629 | dnsservers->setEnabled(on); |
674 | dnsservers->triggerUpdate(false); | 630 | dnsservers->triggerUpdate(false); |
675 | } | 631 | } |
676 | 632 | ||
677 | void DNSWidget::save() { | 633 | void DNSWidget::save() { |
678 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 634 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
679 | QStringList serverlist; | 635 | QStringList serverlist; |
680 | for(uint i=0; i < dnsservers->count(); i++) | 636 | for(uint i=0; i < dnsservers->count(); i++) |
681 | serverlist.append(dnsservers->text(i)); | 637 | serverlist.append(dnsservers->text(i)); |
682 | _pppdata->setDns(serverlist); | 638 | _pppdata->setDns(serverlist); |
683 | 639 | ||
684 | // strip leading dot | 640 | // strip leading dot |
685 | QString s(dnsdomain->text()); | 641 | QString s(dnsdomain->text()); |
686 | if(s.left(1) == ".") | 642 | if(s.left(1) == ".") |
687 | _pppdata->setDomain(s.mid(1)); | 643 | _pppdata->setDomain(s.mid(1)); |
688 | else | 644 | else |
689 | _pppdata->setDomain(dnsdomain->text()); | 645 | _pppdata->setDomain(dnsdomain->text()); |
690 | 646 | ||
691 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 647 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
692 | } | 648 | } |
693 | 649 | ||
694 | 650 | ||
695 | void DNSWidget::adddns() { | 651 | void DNSWidget::adddns() { |
696 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 652 | if(dnsservers->count() < MAX_DNS_ENTRIES) { |
697 | dnsservers->insertItem(dnsipaddr->text()); | 653 | dnsservers->insertItem(dnsipaddr->text()); |
698 | dnsipaddr->setText(""); | 654 | dnsipaddr->setText(""); |
699 | } | 655 | } |
700 | } | 656 | } |
701 | 657 | ||
702 | 658 | ||
703 | void DNSWidget::removedns() { | 659 | void DNSWidget::removedns() { |
704 | int i; | 660 | int i; |
705 | i = dnsservers->currentItem(); | 661 | i = dnsservers->currentItem(); |
706 | if(i != -1) | 662 | if(i != -1) |
707 | dnsservers->removeItem(i); | 663 | dnsservers->removeItem(i); |
708 | remove->setEnabled(dnsservers->count()>0); | 664 | remove->setEnabled(dnsservers->count()>0); |
709 | } | 665 | } |
710 | 666 | ||
711 | 667 | ||
712 | // | 668 | // |
713 | // GatewayWidget | 669 | // GatewayWidget |
714 | // | 670 | // |
715 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 671 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
716 | : QWidget(parent, name), _pppdata(pd) | 672 | : QWidget(parent, name), _pppdata(pd) |
717 | { | 673 | { |
718 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 674 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
719 | topLayout->setSpacing( 2 ); | 675 | topLayout->setSpacing( 2 ); |
720 | topLayout->setMargin( 0 ); | 676 | topLayout->setMargin( 0 ); |
721 | 677 | ||
722 | box = new QVGroupBox(tr("Configuration"), this); | 678 | box = new QVGroupBox(tr("Configuration"), this); |
723 | 679 | ||
724 | rb = new QButtonGroup(this); | 680 | rb = new QButtonGroup(this); |
725 | rb->hide(); | 681 | rb->hide(); |
726 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 682 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
727 | 683 | ||
728 | defaultgateway = new QRadioButton(box); | 684 | defaultgateway = new QRadioButton(box); |
729 | defaultgateway->setText(tr("Default gateway")); | 685 | defaultgateway->setText(tr("Default gateway")); |
730 | rb->insert(defaultgateway, 0); | 686 | rb->insert(defaultgateway, 0); |
731 | QWhatsThis::add(defaultgateway, | 687 | QWhatsThis::add(defaultgateway, |
732 | tr("This makes the PPP peer computer (the computer\n" | 688 | tr("This makes the PPP peer computer (the computer\n" |
733 | "you are connected to with your modem) to act as\n" | 689 | "you are connected to with your modem) to act as\n" |
734 | "a gateway. Your computer will send all packets not\n" | 690 | "a gateway. Your computer will send all packets not\n" |
735 | "going to a computer inside your local net to this\n" | 691 | "going to a computer inside your local net to this\n" |
736 | "computer, which will route these packets.\n" | 692 | "computer, which will route these packets.\n" |
737 | "\n" | 693 | "\n" |
738 | "This is the default for most ISPs, so you should\n" | 694 | "This is the default for most ISPs, so you should\n" |
739 | "probably leave this option on.")); | 695 | "probably leave this option on.")); |
740 | 696 | ||
741 | 697 | ||
742 | staticgateway = new QRadioButton(box); | 698 | staticgateway = new QRadioButton(box); |
743 | staticgateway->setText(tr("Static gateway")); | 699 | staticgateway->setText(tr("Static gateway")); |
744 | rb->insert(staticgateway, 1); | 700 | rb->insert(staticgateway, 1); |
745 | QWhatsThis::add(staticgateway, | 701 | QWhatsThis::add(staticgateway, |
746 | tr("<p>Allows you to specify which computer you want\n" | 702 | tr("<p>Allows you to specify which computer you want\n" |
747 | "to use as gateway (see <i>Default Gateway</i> above)")); | 703 | "to use as gateway (see <i>Default Gateway</i> above)")); |
748 | 704 | ||
749 | QHBox *gateBox = new QHBox(box); | 705 | QHBox *gateBox = new QHBox(box); |
750 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); | 706 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); |
751 | gatewayaddr = new IPLineEdit(gateBox); | 707 | gatewayaddr = new IPLineEdit(gateBox); |
752 | 708 | ||
753 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), | 709 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), |
754 | this); | 710 | this); |
755 | QWhatsThis::add(defaultroute, | 711 | QWhatsThis::add(defaultroute, |
756 | tr("If this option is enabled, all packets not\n" | 712 | tr("If this option is enabled, all packets not\n" |
757 | "going to the local net are routed through\n" | 713 | "going to the local net are routed through\n" |
758 | "the PPP connection.\n" | 714 | "the PPP connection.\n" |
759 | "\n" | 715 | "\n" |
760 | "Normally, you should turn this on")); | 716 | "Normally, you should turn this on")); |
761 | 717 | ||
762 | topLayout->addWidget(box); | 718 | topLayout->addWidget(box); |
763 | topLayout->addWidget(defaultroute); | 719 | topLayout->addWidget(defaultroute); |
764 | topLayout->addStretch(); | 720 | topLayout->addStretch(); |
765 | 721 | ||
766 | //load info from gpppdata | 722 | //load info from gpppdata |
767 | if(!isnewaccount) { | 723 | if(!isnewaccount) { |
768 | if(_pppdata->gateway() == "0.0.0.0") { | 724 | if(_pppdata->gateway() == "0.0.0.0") { |
769 | defaultgateway->setChecked(true); | 725 | defaultgateway->setChecked(true); |
770 | hitGatewaySelect(0); | 726 | hitGatewaySelect(0); |
771 | } | 727 | } |
772 | else { | 728 | else { |
773 | gatewayaddr->setText(_pppdata->gateway()); | 729 | gatewayaddr->setText(_pppdata->gateway()); |
774 | staticgateway->setChecked(true); | 730 | staticgateway->setChecked(true); |
775 | } | 731 | } |
776 | defaultroute->setChecked(_pppdata->defaultroute()); | 732 | defaultroute->setChecked(_pppdata->defaultroute()); |
777 | } | 733 | } |
778 | else { | 734 | else { |
779 | defaultgateway->setChecked(true); | 735 | defaultgateway->setChecked(true); |
780 | hitGatewaySelect(0); | 736 | hitGatewaySelect(0); |
781 | defaultroute->setChecked(true); | 737 | defaultroute->setChecked(true); |
782 | } | 738 | } |
783 | } | 739 | } |
784 | 740 | ||
785 | void GatewayWidget::save() { | 741 | void GatewayWidget::save() { |
786 | _pppdata->setGateway(gatewayaddr->text()); | 742 | _pppdata->setGateway(gatewayaddr->text()); |
787 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 743 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
788 | } | 744 | } |
789 | 745 | ||
790 | 746 | ||
791 | void GatewayWidget::hitGatewaySelect( int i ) { | 747 | void GatewayWidget::hitGatewaySelect( int i ) { |
792 | if(i == 0) { | 748 | if(i == 0) { |
793 | gatewayaddr->setText("0.0.0.0"); | 749 | gatewayaddr->setText("0.0.0.0"); |
794 | gatewayaddr->setEnabled(false); | 750 | gatewayaddr->setEnabled(false); |
795 | gate_label->setEnabled(false); | 751 | gate_label->setEnabled(false); |
796 | } | 752 | } |
797 | else { | 753 | else { |
798 | gatewayaddr->setEnabled(true); | 754 | gatewayaddr->setEnabled(true); |
799 | gatewayaddr->setText(""); | 755 | gatewayaddr->setText(""); |
800 | gate_label->setEnabled(true); | 756 | gate_label->setEnabled(true); |
801 | } | 757 | } |
802 | } | 758 | } |
803 | 759 | ||
804 | 760 | ||
805 | 761 | ||
806 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 762 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
807 | : QWidget(parent, name),_pppdata(pd) | 763 | : QWidget(parent, name),_pppdata(pd) |
808 | { | 764 | { |
809 | 765 | ||
810 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 766 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
811 | se = new ScriptEdit(this); | 767 | se = new ScriptEdit(this); |
812 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 768 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
813 | tl->addWidget(se); | 769 | tl->addWidget(se); |
814 | 770 | ||
815 | // insert equal-sized buttons | 771 | // insert equal-sized buttons |
816 | QHBoxLayout *hl = new QHBoxLayout( this ); | 772 | QHBoxLayout *hl = new QHBoxLayout( this ); |
817 | tl->addLayout( hl ); | 773 | tl->addLayout( hl ); |
818 | add = new QPushButton( tr("Add"), this ); | 774 | add = new QPushButton( tr("Add"), this ); |
819 | hl->addWidget( add ); | 775 | hl->addWidget( add ); |
820 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 776 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
821 | insert = new QPushButton( tr("Insert"), this ); | 777 | insert = new QPushButton( tr("Insert"), this ); |
822 | hl->addWidget( insert ); | 778 | hl->addWidget( insert ); |
823 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 779 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
824 | remove = new QPushButton( tr("Remove"), this ); | 780 | remove = new QPushButton( tr("Remove"), this ); |
825 | hl->addWidget( remove ); | 781 | hl->addWidget( remove ); |
826 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 782 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
827 | 783 | ||
828 | QHBoxLayout *l12 = new QHBoxLayout(0); | 784 | QHBoxLayout *l12 = new QHBoxLayout(0); |
829 | tl->addLayout(l12); | 785 | tl->addLayout(l12); |
830 | stl = new QListBox(this); | 786 | stl = new QListBox(this); |
831 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 787 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
832 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 788 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
833 | // stl->setMinimumSize(QSize(70, 140)); | 789 | // stl->setMinimumSize(QSize(70, 140)); |
834 | 790 | ||
835 | sl = new QListBox(this); | 791 | sl = new QListBox(this); |
836 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 792 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
837 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 793 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
838 | // sl->setMinimumSize(QSize(150, 140)); | 794 | // sl->setMinimumSize(QSize(150, 140)); |
839 | 795 | ||
840 | slb = new QScrollBar(this); | 796 | slb = new QScrollBar(this); |
841 | // slb->setFixedWidth(slb->sizeHint().width()); | 797 | // slb->setFixedWidth(slb->sizeHint().width()); |
842 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 798 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
843 | 799 | ||
844 | l12->addWidget(stl, 1); | 800 | l12->addWidget(stl, 1); |
845 | l12->addWidget(sl, 3); | 801 | l12->addWidget(sl, 3); |
846 | l12->addWidget(slb, 0); | 802 | l12->addWidget(slb, 0); |
847 | 803 | ||
848 | //load data from gpppdata | 804 | //load data from gpppdata |
849 | if(!isnewaccount) { | 805 | if(!isnewaccount) { |
850 | QStringList &comlist = _pppdata->scriptType(); | 806 | QStringList &comlist = _pppdata->scriptType(); |
851 | QStringList &arglist = _pppdata->script(); | 807 | QStringList &arglist = _pppdata->script(); |
852 | QStringList::Iterator itcom = comlist.begin(); | 808 | QStringList::Iterator itcom = comlist.begin(); |
853 | QStringList::Iterator itarg = arglist.begin(); | 809 | QStringList::Iterator itarg = arglist.begin(); |
854 | 810 | ||
855 | for ( ; | 811 | for ( ; |
856 | itcom != comlist.end() && itarg != arglist.end(); | 812 | itcom != comlist.end() && itarg != arglist.end(); |
857 | ++itcom, ++itarg ) | 813 | ++itcom, ++itarg ) |
858 | { | 814 | { |
859 | stl->insertItem(*itcom); | 815 | stl->insertItem(*itcom); |
860 | sl->insertItem(*itarg); | 816 | sl->insertItem(*itarg); |
861 | } | 817 | } |
862 | } | 818 | } |
863 | 819 | ||
864 | insert->setEnabled(false); | 820 | insert->setEnabled(false); |
865 | remove->setEnabled(false); | 821 | remove->setEnabled(false); |
866 | adjustScrollBar(); | 822 | adjustScrollBar(); |
867 | tl->activate(); | 823 | tl->activate(); |
868 | } | 824 | } |
869 | 825 | ||
870 | bool ScriptWidget::check() { | 826 | bool ScriptWidget::check() { |
871 | uint lstart = 0; | 827 | uint lstart = 0; |
872 | uint lend = 0; | 828 | uint lend = 0; |
873 | uint errcnt = 0; | 829 | uint errcnt = 0; |
874 | 830 | ||
875 | if(sl->count() > 0) { | 831 | if(sl->count() > 0) { |
876 | for( uint i=0; i <= sl->count()-1; i++) { | 832 | for( uint i=0; i <= sl->count()-1; i++) { |
877 | if(stl->text(i) == "LoopStart") { | 833 | if(stl->text(i) == "LoopStart") { |
878 | lstart++; | 834 | lstart++; |
879 | } | 835 | } |
880 | if (stl->text(i) == "LoopEnd") { | 836 | if (stl->text(i) == "LoopEnd") { |
881 | lend++; | 837 | lend++; |
882 | } | 838 | } |
883 | if ( lend > lstart ) errcnt++; | 839 | if ( lend > lstart ) errcnt++; |
884 | } | 840 | } |
885 | return ( (errcnt == 0 ) && (lstart == lend) ); | 841 | return ( (errcnt == 0 ) && (lstart == lend) ); |
886 | } | 842 | } |
887 | return true; | 843 | return true; |
888 | } | 844 | } |
889 | 845 | ||
890 | 846 | ||
891 | void ScriptWidget::save() { | 847 | void ScriptWidget::save() { |
892 | QStringList typelist, arglist; | 848 | QStringList typelist, arglist; |
893 | for(uint i=0; i < sl->count(); i++) { | 849 | for(uint i=0; i < sl->count(); i++) { |
894 | typelist.append(stl->text(i)); | 850 | typelist.append(stl->text(i)); |
895 | arglist.append(sl->text(i)); | 851 | arglist.append(sl->text(i)); |
896 | } | 852 | } |
897 | _pppdata->setScriptType(typelist); | 853 | _pppdata->setScriptType(typelist); |
898 | _pppdata->setScript(arglist); | 854 | _pppdata->setScript(arglist); |
899 | } | 855 | } |
900 | 856 | ||
901 | 857 | ||
902 | 858 | ||
903 | void ScriptWidget::adjustScrollBar() { | 859 | void ScriptWidget::adjustScrollBar() { |
904 | if((int)sl->count() <= sl->numItemsVisible()) | 860 | if((int)sl->count() <= sl->numItemsVisible()) |
905 | slb->setRange(0, 0); | 861 | slb->setRange(0, 0); |
906 | else | 862 | else |
907 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 863 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
908 | } | 864 | } |
909 | 865 | ||
910 | 866 | ||
911 | void ScriptWidget::scrolling(int i) { | 867 | void ScriptWidget::scrolling(int i) { |
912 | sl->setTopItem(i); | 868 | sl->setTopItem(i); |
913 | stl->setTopItem(i); | 869 | stl->setTopItem(i); |
914 | } | 870 | } |
915 | 871 | ||
916 | 872 | ||
917 | void ScriptWidget::slhighlighted(int i) { | 873 | void ScriptWidget::slhighlighted(int i) { |
918 | insert->setEnabled(true); | 874 | insert->setEnabled(true); |
919 | remove->setEnabled(true); | 875 | remove->setEnabled(true); |
920 | stl->setCurrentItem(i); | 876 | stl->setCurrentItem(i); |
921 | } | 877 | } |
922 | 878 | ||
923 | 879 | ||
924 | void ScriptWidget::stlhighlighted(int i) { | 880 | void ScriptWidget::stlhighlighted(int i) { |
925 | insert->setEnabled(true); | 881 | insert->setEnabled(true); |
926 | remove->setEnabled(true); | 882 | remove->setEnabled(true); |
927 | sl->setCurrentItem(i); | 883 | sl->setCurrentItem(i); |
928 | } | 884 | } |
929 | 885 | ||
930 | 886 | ||
931 | void ScriptWidget::addButton() { | 887 | void ScriptWidget::addButton() { |
932 | //don't allow more than the maximum script entries | 888 | //don't allow more than the maximum script entries |
933 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 889 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
934 | return; | 890 | return; |
935 | 891 | ||
936 | switch(se->type()) { | 892 | switch(se->type()) { |
937 | case ScriptEdit::Expect: | 893 | case ScriptEdit::Expect: |
938 | stl->insertItem("Expect"); | 894 | stl->insertItem("Expect"); |
939 | sl->insertItem(se->text()); | 895 | sl->insertItem(se->text()); |
940 | break; | 896 | break; |
941 | 897 | ||
942 | case ScriptEdit::Send: | 898 | case ScriptEdit::Send: |
943 | stl->insertItem("Send"); | 899 | stl->insertItem("Send"); |
944 | sl->insertItem(se->text()); | 900 | sl->insertItem(se->text()); |
945 | break; | 901 | break; |
946 | 902 | ||
947 | case ScriptEdit::SendNoEcho: | 903 | case ScriptEdit::SendNoEcho: |
948 | stl->insertItem("SendNoEcho"); | 904 | stl->insertItem("SendNoEcho"); |
949 | sl->insertItem(se->text()); | 905 | sl->insertItem(se->text()); |
950 | break; | 906 | break; |
951 | 907 | ||
952 | case ScriptEdit::Pause: | 908 | case ScriptEdit::Pause: |
953 | stl->insertItem("Pause"); | 909 | stl->insertItem("Pause"); |
954 | sl->insertItem(se->text()); | 910 | sl->insertItem(se->text()); |
955 | break; | 911 | break; |
956 | 912 | ||
957 | case ScriptEdit::Hangup: | 913 | case ScriptEdit::Hangup: |
958 | stl->insertItem("Hangup"); | 914 | stl->insertItem("Hangup"); |
959 | sl->insertItem(""); | 915 | sl->insertItem(""); |
960 | break; | 916 | break; |
961 | 917 | ||
962 | case ScriptEdit::Answer: | 918 | case ScriptEdit::Answer: |
963 | stl->insertItem("Answer"); | 919 | stl->insertItem("Answer"); |
964 | sl->insertItem(""); | 920 | sl->insertItem(""); |
965 | break; | 921 | break; |
966 | 922 | ||
967 | case ScriptEdit::Timeout: | 923 | case ScriptEdit::Timeout: |
968 | stl->insertItem("Timeout"); | 924 | stl->insertItem("Timeout"); |
969 | sl->insertItem(se->text()); | 925 | sl->insertItem(se->text()); |
970 | break; | 926 | break; |
971 | 927 | ||
972 | case ScriptEdit::Password: | 928 | case ScriptEdit::Password: |
973 | stl->insertItem("Password"); | 929 | stl->insertItem("Password"); |
974 | sl->insertItem(se->text()); | 930 | sl->insertItem(se->text()); |
975 | break; | 931 | break; |
976 | 932 | ||
977 | case ScriptEdit::ID: | 933 | case ScriptEdit::ID: |
978 | stl->insertItem("ID"); | 934 | stl->insertItem("ID"); |
979 | sl->insertItem(se->text()); | 935 | sl->insertItem(se->text()); |
980 | break; | 936 | break; |
981 | 937 | ||
982 | case ScriptEdit::Prompt: | 938 | case ScriptEdit::Prompt: |
983 | stl->insertItem("Prompt"); | 939 | stl->insertItem("Prompt"); |
984 | sl->insertItem(se->text()); | 940 | sl->insertItem(se->text()); |
985 | break; | 941 | break; |
986 | 942 | ||
987 | case ScriptEdit::PWPrompt: | 943 | case ScriptEdit::PWPrompt: |
988 | stl->insertItem("PWPrompt"); | 944 | stl->insertItem("PWPrompt"); |
989 | sl->insertItem(se->text()); | 945 | sl->insertItem(se->text()); |
990 | break; | 946 | break; |
991 | 947 | ||
992 | case ScriptEdit::LoopStart: | 948 | case ScriptEdit::LoopStart: |
993 | stl->insertItem("LoopStart"); | 949 | stl->insertItem("LoopStart"); |
994 | sl->insertItem(se->text()); | 950 | sl->insertItem(se->text()); |
995 | break; | 951 | break; |
996 | 952 | ||
997 | case ScriptEdit::LoopEnd: | 953 | case ScriptEdit::LoopEnd: |
998 | stl->insertItem("LoopEnd"); | 954 | stl->insertItem("LoopEnd"); |
999 | sl->insertItem(se->text()); | 955 | sl->insertItem(se->text()); |
1000 | break; | 956 | break; |
1001 | 957 | ||
1002 | case ScriptEdit::Scan: | 958 | case ScriptEdit::Scan: |
1003 | stl->insertItem("Scan"); | 959 | stl->insertItem("Scan"); |
1004 | sl->insertItem(se->text()); | 960 | sl->insertItem(se->text()); |
1005 | break; | 961 | break; |
1006 | 962 | ||
1007 | case ScriptEdit::Save: | 963 | case ScriptEdit::Save: |
1008 | stl->insertItem("Save"); | 964 | stl->insertItem("Save"); |
1009 | sl->insertItem(se->text()); | 965 | sl->insertItem(se->text()); |
1010 | break; | 966 | break; |
1011 | 967 | ||
1012 | default: | 968 | default: |
1013 | break; | 969 | break; |
1014 | } | 970 | } |
1015 | 971 | ||
1016 | //get the scrollbar adjusted, and scroll the list so we can see what | 972 | //get the scrollbar adjusted, and scroll the list so we can see what |
1017 | //we're adding to | 973 | //we're adding to |
1018 | adjustScrollBar(); | 974 | adjustScrollBar(); |
1019 | slb->setValue(slb->maxValue()); | 975 | slb->setValue(slb->maxValue()); |
1020 | 976 | ||
1021 | //clear the text in the entry box | 977 | //clear the text in the entry box |
1022 | se->setText(""); | 978 | se->setText(""); |
1023 | } | 979 | } |
1024 | 980 | ||
1025 | 981 | ||
1026 | void ScriptWidget::insertButton() { | 982 | void ScriptWidget::insertButton() { |
1027 | //exit if there is no highlighted item, or we've reached the | 983 | //exit if there is no highlighted item, or we've reached the |
1028 | //maximum entries in the script list | 984 | //maximum entries in the script list |
1029 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 985 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1030 | return; | 986 | return; |
1031 | 987 | ||
1032 | switch(se->type()) { | 988 | switch(se->type()) { |
1033 | case ScriptEdit::Expect: | 989 | case ScriptEdit::Expect: |
1034 | stl->insertItem("Expect", stl->currentItem()); | 990 | stl->insertItem("Expect", stl->currentItem()); |
1035 | sl->insertItem(se->text(), sl->currentItem()); | 991 | sl->insertItem(se->text(), sl->currentItem()); |
1036 | break; | 992 | break; |
1037 | 993 | ||
1038 | case ScriptEdit::Send: | 994 | case ScriptEdit::Send: |
1039 | stl->insertItem("Send", stl->currentItem()); | 995 | stl->insertItem("Send", stl->currentItem()); |
1040 | sl->insertItem(se->text(), sl->currentItem()); | 996 | sl->insertItem(se->text(), sl->currentItem()); |
1041 | break; | 997 | break; |
1042 | 998 | ||
1043 | case ScriptEdit::SendNoEcho: | 999 | case ScriptEdit::SendNoEcho: |
1044 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1000 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1045 | sl->insertItem(se->text(), sl->currentItem()); | 1001 | sl->insertItem(se->text(), sl->currentItem()); |
1046 | break; | 1002 | break; |
1047 | 1003 | ||
1048 | case ScriptEdit::Pause: | 1004 | case ScriptEdit::Pause: |
1049 | stl->insertItem("Pause", stl->currentItem()); | 1005 | stl->insertItem("Pause", stl->currentItem()); |
1050 | sl->insertItem(se->text(), sl->currentItem()); | 1006 | sl->insertItem(se->text(), sl->currentItem()); |
1051 | break; | 1007 | break; |
1052 | 1008 | ||
1053 | case ScriptEdit::Hangup: | 1009 | case ScriptEdit::Hangup: |
1054 | stl->insertItem("Hangup", stl->currentItem()); | 1010 | stl->insertItem("Hangup", stl->currentItem()); |
1055 | sl->insertItem("", sl->currentItem()); | 1011 | sl->insertItem("", sl->currentItem()); |
1056 | break; | 1012 | break; |
1057 | 1013 | ||
1058 | case ScriptEdit::Answer: | 1014 | case ScriptEdit::Answer: |
1059 | stl->insertItem("Answer", stl->currentItem()); | 1015 | stl->insertItem("Answer", stl->currentItem()); |
1060 | sl->insertItem("", sl->currentItem()); | 1016 | sl->insertItem("", sl->currentItem()); |
1061 | break; | 1017 | break; |
1062 | 1018 | ||
1063 | case ScriptEdit::Timeout: | 1019 | case ScriptEdit::Timeout: |
1064 | stl->insertItem("Timeout", stl->currentItem()); | 1020 | stl->insertItem("Timeout", stl->currentItem()); |
1065 | sl->insertItem(se->text(), sl->currentItem()); | 1021 | sl->insertItem(se->text(), sl->currentItem()); |
1066 | break; | 1022 | break; |
1067 | 1023 | ||
1068 | case ScriptEdit::Password: | 1024 | case ScriptEdit::Password: |
1069 | stl->insertItem("Password", stl->currentItem()); | 1025 | stl->insertItem("Password", stl->currentItem()); |
1070 | sl->insertItem(se->text(), sl->currentItem()); | 1026 | sl->insertItem(se->text(), sl->currentItem()); |
1071 | break; | 1027 | break; |
1072 | 1028 | ||
1073 | case ScriptEdit::ID: | 1029 | case ScriptEdit::ID: |
1074 | stl->insertItem("ID", stl->currentItem()); | 1030 | stl->insertItem("ID", stl->currentItem()); |
1075 | sl->insertItem(se->text(), sl->currentItem()); | 1031 | sl->insertItem(se->text(), sl->currentItem()); |
1076 | break; | 1032 | break; |
1077 | 1033 | ||
1078 | case ScriptEdit::Prompt: | 1034 | case ScriptEdit::Prompt: |
1079 | stl->insertItem("Prompt", stl->currentItem()); | 1035 | stl->insertItem("Prompt", stl->currentItem()); |
1080 | sl->insertItem(se->text(), sl->currentItem()); | 1036 | sl->insertItem(se->text(), sl->currentItem()); |
1081 | break; | 1037 | break; |
1082 | 1038 | ||
1083 | case ScriptEdit::PWPrompt: | 1039 | case ScriptEdit::PWPrompt: |
1084 | stl->insertItem("PWPrompt", stl->currentItem()); | 1040 | stl->insertItem("PWPrompt", stl->currentItem()); |
1085 | sl->insertItem(se->text(), sl->currentItem()); | 1041 | sl->insertItem(se->text(), sl->currentItem()); |
1086 | break; | 1042 | break; |
1087 | 1043 | ||
1088 | case ScriptEdit::LoopStart: | 1044 | case ScriptEdit::LoopStart: |
1089 | stl->insertItem("LoopStart", stl->currentItem()); | 1045 | stl->insertItem("LoopStart", stl->currentItem()); |
1090 | sl->insertItem(se->text(), sl->currentItem()); | 1046 | sl->insertItem(se->text(), sl->currentItem()); |
1091 | break; | 1047 | break; |
1092 | 1048 | ||
1093 | case ScriptEdit::LoopEnd: | 1049 | case ScriptEdit::LoopEnd: |
1094 | stl->insertItem("LoopEnd", stl->currentItem()); | 1050 | stl->insertItem("LoopEnd", stl->currentItem()); |
1095 | sl->insertItem(se->text(), sl->currentItem()); | 1051 | sl->insertItem(se->text(), sl->currentItem()); |
1096 | break; | 1052 | break; |
1097 | 1053 | ||
1098 | case ScriptEdit::Scan: | 1054 | case ScriptEdit::Scan: |
1099 | stl->insertItem("Scan", stl->currentItem()); | 1055 | stl->insertItem("Scan", stl->currentItem()); |
1100 | sl->insertItem(se->text(), sl->currentItem()); | 1056 | sl->insertItem(se->text(), sl->currentItem()); |
1101 | break; | 1057 | break; |
1102 | 1058 | ||
1103 | case ScriptEdit::Save: | 1059 | case ScriptEdit::Save: |
1104 | stl->insertItem("Save", stl->currentItem()); | 1060 | stl->insertItem("Save", stl->currentItem()); |
1105 | sl->insertItem(se->text(), sl->currentItem()); | 1061 | sl->insertItem(se->text(), sl->currentItem()); |
1106 | break; | 1062 | break; |
1107 | 1063 | ||
1108 | default: | 1064 | default: |
1109 | break; | 1065 | break; |
1110 | } | 1066 | } |
1111 | adjustScrollBar(); | 1067 | adjustScrollBar(); |
1112 | se->setText(""); | 1068 | se->setText(""); |
1113 | } | 1069 | } |
1114 | 1070 | ||
1115 | 1071 | ||
1116 | void ScriptWidget::removeButton() { | 1072 | void ScriptWidget::removeButton() { |
1117 | if(sl->currentItem() >= 0) { | 1073 | if(sl->currentItem() >= 0) { |
1118 | int stlc = stl->currentItem(); | 1074 | int stlc = stl->currentItem(); |
1119 | sl->removeItem(sl->currentItem()); | 1075 | sl->removeItem(sl->currentItem()); |
1120 | stl->removeItem(stlc); | 1076 | stl->removeItem(stlc); |
1121 | adjustScrollBar(); | 1077 | adjustScrollBar(); |
1122 | insert->setEnabled(sl->currentItem() != -1); | 1078 | insert->setEnabled(sl->currentItem() != -1); |
1123 | remove->setEnabled(sl->currentItem() != -1); | 1079 | remove->setEnabled(sl->currentItem() != -1); |
1124 | } | 1080 | } |
1125 | } | 1081 | } |
1126 | 1082 | ||
1127 | 1083 | ||
1128 | 1084 | ||
1129 | ///////////////////////////////////////////////////////////////////////////// | 1085 | ///////////////////////////////////////////////////////////////////////////// |
1130 | // | 1086 | // |
1131 | // Used to specify a new phone number | 1087 | // Used to specify a new phone number |
1132 | // | 1088 | // |
1133 | ///////////////////////////////////////////////////////////////////////////// | 1089 | ///////////////////////////////////////////////////////////////////////////// |
1134 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1090 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1135 | : QDialog(parent,"PhoneNumberDialog",true) | 1091 | : QDialog(parent,"PhoneNumberDialog",true) |
1136 | { | 1092 | { |
1137 | setCaption( tr("Add Phone Number") ); | 1093 | setCaption( tr("Add Phone Number") ); |
1138 | 1094 | ||
1139 | 1095 | ||
1140 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1096 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1141 | layout->setSpacing( 3 ); | 1097 | layout->setSpacing( 3 ); |
1142 | layout->setMargin( 3 ); | 1098 | layout->setMargin( 3 ); |
1143 | 1099 | ||
1144 | // QHBox *hbox = new QHBox(this); | 1100 | // QHBox *hbox = new QHBox(this); |
1145 | // setMainWidget(hbox); | 1101 | // setMainWidget(hbox); |
1146 | 1102 | ||
1147 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1103 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1148 | 1104 | ||
1149 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1105 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1150 | layout->addWidget( label ); | 1106 | layout->addWidget( label ); |
1151 | 1107 | ||
1152 | le = new QLineEdit(this, "lineEdit"); | 1108 | le = new QLineEdit(this, "lineEdit"); |
1153 | layout->addWidget( le ); | 1109 | layout->addWidget( le ); |
1154 | 1110 | ||
1155 | connect(le, SIGNAL(textChanged(const QString &)), | 1111 | connect(le, SIGNAL(textChanged(const QString &)), |
1156 | this, SLOT(textChanged(const QString &))); | 1112 | this, SLOT(textChanged(const QString &))); |
1157 | 1113 | ||
1158 | le->setFocus(); | 1114 | le->setFocus(); |
1159 | textChanged(""); | 1115 | textChanged(""); |
1160 | 1116 | ||
1161 | 1117 | ||
1162 | } | 1118 | } |
1163 | 1119 | ||
1164 | 1120 | ||
1165 | QString PhoneNumberDialog::phoneNumber() { | 1121 | QString PhoneNumberDialog::phoneNumber() { |
1166 | QString s = le->text(); | 1122 | QString s = le->text(); |
1167 | 1123 | ||
1168 | return s; | 1124 | return s; |
1169 | } | 1125 | } |
1170 | 1126 | ||
1171 | 1127 | ||
1172 | void PhoneNumberDialog::textChanged(const QString &s) { | 1128 | void PhoneNumberDialog::textChanged(const QString &s) { |
1173 | // enableButtonOK(s.length() > 0); | 1129 | // enableButtonOK(s.length() > 0); |
1174 | } | 1130 | } |
1175 | 1131 | ||
1176 | 1132 | ||
1177 | //#include "edit.moc" | 1133 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h index 2cc0fed..8b5ec03 100644 --- a/noncore/settings/networksettings/ppp/edit.h +++ b/noncore/settings/networksettings/ppp/edit.h | |||
@@ -1,259 +1,256 @@ | |||
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 | * 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 | * | 12 | * |
13 | * This library is free software; you can redistribute it and/or | 13 | * This library 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 library is distributed in the hope that it will be useful, | 18 | * This library 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 | 28 | ||
29 | #ifndef _EDIT_H_ | 29 | #ifndef _EDIT_H_ |
30 | #define _EDIT_H_ | 30 | #define _EDIT_H_ |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qgroupbox.h> | 34 | #include <qgroupbox.h> |
35 | #include <qvgroupbox.h> | 35 | #include <qvgroupbox.h> |
36 | #include <qscrollbar.h> | 36 | #include <qscrollbar.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistbox.h> | 39 | #include <qlistbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | //#include <kdialogbase.h> | 44 | //#include <kdialogbase.h> |
45 | #include "scriptedit.h" | 45 | #include "scriptedit.h" |
46 | #include "kpppconfig.h" | 46 | #include "kpppconfig.h" |
47 | #include "pppdargs.h" | 47 | #include "pppdargs.h" |
48 | 48 | ||
49 | class IPLineEdit; | 49 | class IPLineEdit; |
50 | class PPPData; | 50 | class PPPData; |
51 | 51 | ||
52 | class DialWidget : public QWidget { | 52 | class DialWidget : public QWidget { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 55 | DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
56 | ~DialWidget() {} | 56 | ~DialWidget() {} |
57 | 57 | ||
58 | public slots: | 58 | public slots: |
59 | bool save(); | 59 | bool save(); |
60 | void pppdargsbutton(); | 60 | void pppdargsbutton(); |
61 | void numbersChanged(); | 61 | void numbersChanged(); |
62 | void selectionChanged(int); | 62 | void selectionChanged(int); |
63 | void addNumber(); | 63 | void addNumber(); |
64 | void delNumber(); | 64 | void delNumber(); |
65 | void upNumber(); | 65 | void upNumber(); |
66 | void downNumber(); | 66 | void downNumber(); |
67 | 67 | ||
68 | private: | 68 | private: |
69 | QLineEdit *connectname_l; | 69 | QLineEdit *connectname_l; |
70 | QLabel *connect_label; | 70 | QLabel *connect_label; |
71 | QLabel *number_label; | 71 | QLabel *number_label; |
72 | QPushButton *pppdargs; | 72 | QPushButton *pppdargs; |
73 | QComboBox *auth; | ||
74 | QLabel *auth_l; | ||
75 | QCheckBox *store_password; | ||
76 | 73 | ||
77 | // for the phonenumber selection | 74 | // for the phonenumber selection |
78 | QPushButton *add, *del, *up, *down; | 75 | QPushButton *add, *del, *up, *down; |
79 | QListBox *numbers; | 76 | QListBox *numbers; |
80 | PPPData *_pppdata; | 77 | PPPData *_pppdata; |
81 | }; | 78 | }; |
82 | 79 | ||
83 | 80 | ||
84 | ///////////////////////////////////////////////////////////////////////////// | 81 | ///////////////////////////////////////////////////////////////////////////// |
85 | // | 82 | // |
86 | // tab-window to select what to execute when | 83 | // tab-window to select what to execute when |
87 | // | 84 | // |
88 | ///////////////////////////////////////////////////////////////////////////// | 85 | ///////////////////////////////////////////////////////////////////////////// |
89 | class ExecWidget : public QWidget { | 86 | class ExecWidget : public QWidget { |
90 | Q_OBJECT | 87 | Q_OBJECT |
91 | public: | 88 | public: |
92 | ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0); | 89 | ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0); |
93 | 90 | ||
94 | public slots: | 91 | public slots: |
95 | bool save(); | 92 | bool save(); |
96 | 93 | ||
97 | private: | 94 | private: |
98 | QLineEdit *before_connect; | 95 | QLineEdit *before_connect; |
99 | QLabel *before_connect_l; | 96 | QLabel *before_connect_l; |
100 | 97 | ||
101 | QLineEdit *command; | 98 | QLineEdit *command; |
102 | QLabel *command_label; | 99 | QLabel *command_label; |
103 | 100 | ||
104 | QLineEdit *predisconnect; | 101 | QLineEdit *predisconnect; |
105 | QLabel *predisconnect_label; | 102 | QLabel *predisconnect_label; |
106 | 103 | ||
107 | QLineEdit *discommand; | 104 | QLineEdit *discommand; |
108 | QLabel *discommand_label; | 105 | QLabel *discommand_label; |
109 | PPPData *_pppdata; | 106 | PPPData *_pppdata; |
110 | }; | 107 | }; |
111 | 108 | ||
112 | 109 | ||
113 | class IPWidget : public QWidget { | 110 | class IPWidget : public QWidget { |
114 | Q_OBJECT | 111 | Q_OBJECT |
115 | public: | 112 | public: |
116 | IPWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 113 | IPWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
117 | ~IPWidget() {} | 114 | ~IPWidget() {} |
118 | 115 | ||
119 | public slots: | 116 | public slots: |
120 | void save(); | 117 | void save(); |
121 | 118 | ||
122 | protected slots: | 119 | protected slots: |
123 | void hitIPSelect( int ); | 120 | void hitIPSelect( int ); |
124 | void autoname_t(bool on); | 121 | void autoname_t(bool on); |
125 | 122 | ||
126 | private: | 123 | private: |
127 | QLabel *ipaddress_label; | 124 | QLabel *ipaddress_label; |
128 | QLabel *sub_label; | 125 | QLabel *sub_label; |
129 | QGroupBox *box1; | 126 | QGroupBox *box1; |
130 | QVGroupBox *box; | 127 | QVGroupBox *box; |
131 | 128 | ||
132 | QButtonGroup *rb; | 129 | QButtonGroup *rb; |
133 | QRadioButton *dynamicadd_rb; | 130 | QRadioButton *dynamicadd_rb; |
134 | QRadioButton *staticadd_rb; | 131 | QRadioButton *staticadd_rb; |
135 | 132 | ||
136 | IPLineEdit *ipaddress_l; | 133 | IPLineEdit *ipaddress_l; |
137 | IPLineEdit *subnetmask_l; | 134 | IPLineEdit *subnetmask_l; |
138 | 135 | ||
139 | QCheckBox *autoname; | 136 | QCheckBox *autoname; |
140 | PPPData *_pppdata; | 137 | PPPData *_pppdata; |
141 | }; | 138 | }; |
142 | 139 | ||
143 | 140 | ||
144 | class DNSWidget : public QWidget { | 141 | class DNSWidget : public QWidget { |
145 | Q_OBJECT | 142 | Q_OBJECT |
146 | public: | 143 | public: |
147 | DNSWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 144 | DNSWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
148 | ~DNSWidget() {} | 145 | ~DNSWidget() {} |
149 | 146 | ||
150 | public slots: | 147 | public slots: |
151 | void save(); | 148 | void save(); |
152 | 149 | ||
153 | protected slots: | 150 | protected slots: |
154 | void adddns(); | 151 | void adddns(); |
155 | void removedns(); | 152 | void removedns(); |
156 | void DNS_Edit_Changed(const QString &); | 153 | void DNS_Edit_Changed(const QString &); |
157 | void DNS_Entry_Selected(int); | 154 | void DNS_Entry_Selected(int); |
158 | void DNS_Mode_Selected(int); | 155 | void DNS_Mode_Selected(int); |
159 | 156 | ||
160 | private: | 157 | private: |
161 | QLabel *conf_label; | 158 | QLabel *conf_label; |
162 | QButtonGroup *bg; | 159 | QButtonGroup *bg; |
163 | QRadioButton *autodns, *mandns; | 160 | QRadioButton *autodns, *mandns; |
164 | QLabel *dns_label; | 161 | QLabel *dns_label; |
165 | QLabel *servers_label; | 162 | QLabel *servers_label; |
166 | IPLineEdit *dnsipaddr; | 163 | IPLineEdit *dnsipaddr; |
167 | QPushButton *add; | 164 | QPushButton *add; |
168 | QPushButton *remove; | 165 | QPushButton *remove; |
169 | QListBox *dnsservers; | 166 | QListBox *dnsservers; |
170 | QLineEdit *dnsdomain; | 167 | QLineEdit *dnsdomain; |
171 | QLabel *dnsdomain_label; | 168 | QLabel *dnsdomain_label; |
172 | QCheckBox *exdnsdisabled_toggle; | 169 | QCheckBox *exdnsdisabled_toggle; |
173 | PPPData *_pppdata; | 170 | PPPData *_pppdata; |
174 | }; | 171 | }; |
175 | 172 | ||
176 | 173 | ||
177 | class GatewayWidget : public QWidget { | 174 | class GatewayWidget : public QWidget { |
178 | Q_OBJECT | 175 | Q_OBJECT |
179 | public: | 176 | public: |
180 | GatewayWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 177 | GatewayWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
181 | ~GatewayWidget() {} | 178 | ~GatewayWidget() {} |
182 | 179 | ||
183 | public slots: | 180 | public slots: |
184 | void save(); | 181 | void save(); |
185 | 182 | ||
186 | private slots: | 183 | private slots: |
187 | void hitGatewaySelect( int ); | 184 | void hitGatewaySelect( int ); |
188 | 185 | ||
189 | private: | 186 | private: |
190 | QGroupBox *box; | 187 | QGroupBox *box; |
191 | QLabel *gate_label; | 188 | QLabel *gate_label; |
192 | QGroupBox *box1; | 189 | QGroupBox *box1; |
193 | QButtonGroup *rb; | 190 | QButtonGroup *rb; |
194 | QRadioButton *defaultgateway; | 191 | QRadioButton *defaultgateway; |
195 | QRadioButton *staticgateway; | 192 | QRadioButton *staticgateway; |
196 | IPLineEdit *gatewayaddr; | 193 | IPLineEdit *gatewayaddr; |
197 | QCheckBox *defaultroute; | 194 | QCheckBox *defaultroute; |
198 | PPPData *_pppdata; | 195 | PPPData *_pppdata; |
199 | }; | 196 | }; |
200 | 197 | ||
201 | 198 | ||
202 | class ScriptWidget : public QWidget { | 199 | class ScriptWidget : public QWidget { |
203 | Q_OBJECT | 200 | Q_OBJECT |
204 | public: | 201 | public: |
205 | ScriptWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 202 | ScriptWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
206 | ~ScriptWidget() {} | 203 | ~ScriptWidget() {} |
207 | 204 | ||
208 | public slots: | 205 | public slots: |
209 | void save(); | 206 | void save(); |
210 | bool check(); | 207 | bool check(); |
211 | 208 | ||
212 | private slots: | 209 | private slots: |
213 | void addButton(); | 210 | void addButton(); |
214 | void insertButton(); | 211 | void insertButton(); |
215 | void removeButton(); | 212 | void removeButton(); |
216 | 213 | ||
217 | //signals linked to the scroll bar | 214 | //signals linked to the scroll bar |
218 | void scrolling(int); | 215 | void scrolling(int); |
219 | 216 | ||
220 | //signals to keep the two listboxes highlighted in sync | 217 | //signals to keep the two listboxes highlighted in sync |
221 | void slhighlighted(int); | 218 | void slhighlighted(int); |
222 | void stlhighlighted(int); | 219 | void stlhighlighted(int); |
223 | 220 | ||
224 | private: | 221 | private: |
225 | void adjustScrollBar(); | 222 | void adjustScrollBar(); |
226 | 223 | ||
227 | ScriptEdit *se; | 224 | ScriptEdit *se; |
228 | QPushButton *add; | 225 | QPushButton *add; |
229 | QPushButton *remove; | 226 | QPushButton *remove; |
230 | QPushButton *insert; | 227 | QPushButton *insert; |
231 | QListBox *sl, *stl; | 228 | QListBox *sl, *stl; |
232 | 229 | ||
233 | QScrollBar *slb; | 230 | QScrollBar *slb; |
234 | PPPData *_pppdata; | 231 | PPPData *_pppdata; |
235 | }; | 232 | }; |
236 | 233 | ||
237 | 234 | ||
238 | ///////////////////////////////////////////////////////////////////////////// | 235 | ///////////////////////////////////////////////////////////////////////////// |
239 | // | 236 | // |
240 | // Used to specify a new phone number | 237 | // Used to specify a new phone number |
241 | // | 238 | // |
242 | ///////////////////////////////////////////////////////////////////////////// | 239 | ///////////////////////////////////////////////////////////////////////////// |
243 | class PhoneNumberDialog : public QDialog { | 240 | class PhoneNumberDialog : public QDialog { |
244 | Q_OBJECT | 241 | Q_OBJECT |
245 | public: | 242 | public: |
246 | PhoneNumberDialog(QWidget *parent = 0); | 243 | PhoneNumberDialog(QWidget *parent = 0); |
247 | 244 | ||
248 | QString phoneNumber(); | 245 | QString phoneNumber(); |
249 | 246 | ||
250 | private slots: | 247 | private slots: |
251 | void textChanged(const QString &); | 248 | void textChanged(const QString &); |
252 | 249 | ||
253 | private: | 250 | private: |
254 | QLineEdit *le; | 251 | QLineEdit *le; |
255 | 252 | ||
256 | }; | 253 | }; |
257 | 254 | ||
258 | 255 | ||
259 | #endif | 256 | #endif |
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 3cf1167..553daa2 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -1,32 +1,37 @@ | |||
1 | #include "interfaceinformationppp.h" | 1 | #include "interfaceinformationppp.h" |
2 | 2 | ||
3 | 3 | ||
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | //#include <qgroupbox.h> | 6 | //#include <qgroupbox.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qabstractlayout.h> | ||
8 | 9 | ||
9 | #include "connect.h" | 10 | #include "connect.h" |
10 | #include "conwindow.h" | 11 | #include "conwindow.h" |
11 | 12 | ||
12 | #ifdef QWS | 13 | #ifdef QWS |
13 | #else | 14 | #else |
14 | #define showMaximized show | 15 | #define showMaximized show |
15 | #endif | 16 | #endif |
16 | 17 | ||
17 | /** | 18 | /** |
18 | * Constructor for the InterfaceInformationImp class. This class pretty much | 19 | * Constructor for the InterfaceInformationImp class. This class pretty much |
19 | * just display's information about the interface that is passed to it. | 20 | * just display's information about the interface that is passed to it. |
20 | */ | 21 | */ |
21 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 22 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
22 | :InterfaceInformationImp(parent, name, i, f) | 23 | :InterfaceInformationImp(parent, name, i, f) |
23 | { | 24 | { |
24 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); | 25 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); |
25 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | 26 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); |
26 | // InterfaceInformationLayout->addMultiCellWidget( con, 7, 7, 0, 1 ); | 27 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, |
27 | InterfaceInformationLayout->addWidget( con, 7, 0 ); | 28 | QSizePolicy::Fixed) ); |
29 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); | ||
30 | InterfaceInformationLayout->addItem( spacer, 7, 0 ); | ||
31 | InterfaceInformationLayout->addMultiCellWidget( con, 8, 8, 0, 1 ); | ||
32 | // InterfaceInformationLayout->addWidget( con, 7, 0 ); | ||
28 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | 33 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); |
29 | } | 34 | } |
30 | 35 | ||
31 | 36 | ||
32 | 37 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index dc24824..98bb4da 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,141 +1,140 @@ | |||
1 | 1 | ||
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #define i18n QObject::tr | 3 | #define i18n QObject::tr |
4 | 4 | ||
5 | #include "auth.h" | 5 | #include "auth.h" |
6 | #include "interfaceppp.h" | 6 | #include "interfaceppp.h" |
7 | #include "modem.h" | 7 | #include "modem.h" |
8 | #include "pppdata.h" | 8 | #include "pppdata.h" |
9 | 9 | ||
10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
11 | : Interface(parent, name, status), | 11 | : Interface(parent, name, status), |
12 | _modemPtr(0), | 12 | _modemPtr(0), |
13 | _dataPtr(0) | 13 | _dataPtr(0) |
14 | { | 14 | { |
15 | qDebug("InterfacePPP::InterfacePPP("); | 15 | qDebug("InterfacePPP::InterfacePPP("); |
16 | } | 16 | } |
17 | 17 | ||
18 | PPPData* InterfacePPP::data() | 18 | PPPData* InterfacePPP::data() |
19 | { | 19 | { |
20 | if (!_dataPtr){ | 20 | if (!_dataPtr){ |
21 | qDebug("creating new Data obj"); | 21 | qDebug("creating new Data obj"); |
22 | _dataPtr = new PPPData(); | 22 | _dataPtr = new PPPData(); |
23 | _dataPtr->setModemDevice( getInterfaceName() ); | 23 | _dataPtr->setModemDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | 24 | _dataPtr->setAccount( getHardwareName() ); |
25 | } | 25 | } |
26 | return _dataPtr; | 26 | return _dataPtr; |
27 | } | 27 | } |
28 | 28 | ||
29 | Modem* InterfacePPP::modem() | 29 | Modem* InterfacePPP::modem() |
30 | { | 30 | { |
31 | if (!_modemPtr){ | 31 | if (!_modemPtr){ |
32 | qDebug("creating new modem obj"); | 32 | qDebug("creating new modem obj"); |
33 | _modemPtr = new Modem( data() ); | 33 | _modemPtr = new Modem( data() ); |
34 | } | 34 | } |
35 | return _modemPtr; | 35 | return _modemPtr; |
36 | } | 36 | } |
37 | 37 | ||
38 | bool InterfacePPP::refresh() | 38 | bool InterfacePPP::refresh() |
39 | { | 39 | { |
40 | qDebug("InterfacePPP::refresh()"); | 40 | qDebug("InterfacePPP::refresh()"); |
41 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | 41 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); |
42 | return false; | 42 | return false; |
43 | } | 43 | } |
44 | 44 | ||
45 | void InterfacePPP::start() | 45 | void InterfacePPP::start() |
46 | { | 46 | { |
47 | qDebug("InterfacePPP::start"); | 47 | qDebug("InterfacePPP::start"); |
48 | if (data()->storedPassword() != "" ){ | 48 | if (data()->password().isEmpty() ){ |
49 | data()->setPassword(data()->storedPassword()); | 49 | //FIXME: ask for password |
50 | }else{ | ||
51 | //FIXME: | ||
52 | qDebug("using dummy password"); | 50 | qDebug("using dummy password"); |
53 | data()->setPassword( "dummy" ); | 51 | QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)"); |
54 | } | 52 | } |
55 | 53 | ||
56 | 54 | ||
57 | QFileInfo info(pppdPath()); | 55 | QFileInfo info(pppdPath()); |
58 | 56 | ||
59 | if(!info.exists()){ | 57 | if(!info.exists()){ |
60 | QMessageBox::warning(0, tr("Error"), | 58 | QMessageBox::warning(0, tr("Error"), |
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | 59 | i18n("<qt>Cannot find the PPP daemon!<br>" |
62 | "Make sure that pppd is installed and " | 60 | "Make sure that pppd is installed and " |
63 | "that you have entered the correct path.</qt>")); | 61 | "that you have entered the correct path.</qt>")); |
64 | return; | 62 | return; |
65 | } | 63 | } |
66 | //#if 0 | 64 | //#if 0 |
67 | if(!info.isExecutable()){ | 65 | if(!info.isExecutable()){ |
68 | 66 | ||
69 | QString string; | 67 | QString string; |
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | 68 | string = i18n( "<qt>Cannot execute:<br> %1<br>" |
71 | "Please make sure that you have given " | 69 | "Please make sure that you have given " |
72 | "setuid permission and that " | 70 | "setuid permission and that " |
73 | "pppd is executable.<br>").arg(pppdPath()); | 71 | "pppd is executable.<br>").arg(pppdPath()); |
74 | QMessageBox::warning(0, tr("Error"), string); | 72 | QMessageBox::warning(0, tr("Error"), string); |
75 | return; | 73 | return; |
76 | 74 | ||
77 | } | 75 | } |
78 | //#endif | 76 | //#endif |
79 | 77 | ||
80 | QFileInfo info2(data()->modemDevice()); | 78 | QFileInfo info2(data()->modemDevice()); |
81 | 79 | ||
82 | if(!info2.exists()){ | 80 | if(!info2.exists()){ |
83 | QString string; | 81 | QString string; |
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | 82 | string = i18n( "<qt>Cannot find:<br> %1<br>" |
85 | "Please make sure you have setup " | 83 | "Please make sure you have setup " |
86 | "your modem device properly " | 84 | "your modem device properly " |
87 | "and/or adjust the location of the modem device on " | 85 | "and/or adjust the location of the modem device on " |
88 | "the modem tab of " | 86 | "the modem tab of " |
89 | "the setup dialog.</qt>").arg(data()->modemDevice()); | 87 | "the setup dialog.</qt>").arg(data()->modemDevice()); |
90 | QMessageBox::warning(0, tr("Error"), string); | 88 | QMessageBox::warning(0, tr("Error"), string); |
91 | return; | 89 | return; |
92 | } | 90 | } |
93 | 91 | ||
94 | // if this is a PAP or CHAP account, ensure that username is | 92 | // if this is a PAP or CHAP account, ensure that username is |
95 | // supplied | 93 | // supplied |
96 | if(data()->authMethod() == AUTH_PAP || | 94 | if(data()->authMethod() == AUTH_PAP || |
97 | data()->authMethod() == AUTH_CHAP || | 95 | data()->authMethod() == AUTH_CHAP || |
98 | data()->authMethod() == AUTH_PAPCHAP ) { | 96 | data()->authMethod() == AUTH_PAPCHAP ) { |
99 | if(false){ //ID_Edit->text().isEmpty()) { | 97 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { |
100 | QMessageBox::warning(0,tr("Error"), | 98 | QMessageBox::warning(0,tr("Error"), |
101 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); | 99 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); |
102 | // FIXME: return; | 100 | // FIXME: return; |
103 | } else { | 101 | } else { |
104 | if(!modem()->setSecret(data()->authMethod(), | 102 | if(!modem()->setSecret(data()->authMethod(), |
105 | PPPData::encodeWord(data()->storedUsername()), | 103 | PPPData::encodeWord(data()->storedUsername()), |
106 | PPPData::encodeWord(data()->password())) | 104 | PPPData::encodeWord(data()->password())) |
107 | ) { | 105 | ) { |
108 | QString s; | 106 | QString s; |
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | 107 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" |
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | 108 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); |
111 | QMessageBox::warning(0, tr("Error"), s); | 109 | QMessageBox::warning(0, tr("Error"), s); |
112 | return; | 110 | return; |
113 | } | 111 | } |
114 | } | 112 | } |
115 | } | 113 | } |
116 | 114 | ||
117 | if (data()->phonenumber().isEmpty()) { | 115 | if (data()->phonenumber().isEmpty()) { |
118 | QString s = i18n("You must specify a telephone number!"); | 116 | QString s = i18n("You must specify a telephone number!"); |
119 | QMessageBox::warning(0, tr("Error"), s); | 117 | QMessageBox::warning(0, tr("Error"), s); |
120 | return; | 118 | return; |
121 | } | 119 | } |
122 | 120 | ||
123 | // this->hide(); | 121 | // SEGFAULTS: |
124 | 122 | // setStatus( true ); | |
125 | QString tit = i18n("Connecting to: %1").arg(data()->accname()); | 123 | // emit updateInterface((Interface*) this); |
126 | // con->setCaption(tit); | ||
127 | |||
128 | // con->show(); | ||
129 | |||
130 | 124 | ||
131 | emit begin_connect(); | 125 | emit begin_connect(); |
132 | 126 | ||
133 | qDebug("InterfacePPP::start END"); | 127 | qDebug("InterfacePPP::start END"); |
134 | } | 128 | } |
135 | 129 | ||
136 | void InterfacePPP::stop() | 130 | void InterfacePPP::stop() |
137 | { | 131 | { |
138 | qDebug("InterfacePPP::stop"); | 132 | qDebug("InterfacePPP::stop"); |
139 | 133 | ||
140 | } | 134 | } |
141 | 135 | ||
136 | void InterfacePPP::save() | ||
137 | { | ||
138 | data()->save(); | ||
139 | emit updateInterface((Interface*) this); | ||
140 | } | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h index 06a4dbf..6eb6a69 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.h +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -1,33 +1,34 @@ | |||
1 | #ifndef INTERFACEPPP_H | 1 | #ifndef INTERFACEPPP_H |
2 | #define INTERFACEPPP_H | 2 | #define INTERFACEPPP_H |
3 | 3 | ||
4 | #include "interface.h" | 4 | #include "interface.h" |
5 | 5 | ||
6 | class PPPData; | 6 | class PPPData; |
7 | class Modem; | 7 | class Modem; |
8 | 8 | ||
9 | class InterfacePPP : public Interface | 9 | class InterfacePPP : public Interface |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); | 14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); |
15 | 15 | ||
16 | PPPData* data(); | 16 | PPPData* data(); |
17 | Modem* modem(); | 17 | Modem* modem(); |
18 | 18 | ||
19 | signals: | 19 | signals: |
20 | void begin_connect(); | 20 | void begin_connect(); |
21 | 21 | ||
22 | public slots: | 22 | public slots: |
23 | virtual bool refresh(); | 23 | virtual bool refresh(); |
24 | virtual void start(); | 24 | virtual void start(); |
25 | virtual void stop(); | 25 | virtual void stop(); |
26 | void save(); | ||
26 | 27 | ||
27 | private: | 28 | private: |
28 | Modem *_modemPtr; | 29 | Modem *_modemPtr; |
29 | PPPData *_dataPtr; | 30 | PPPData *_dataPtr; |
30 | }; | 31 | }; |
31 | 32 | ||
32 | 33 | ||
33 | #endif | 34 | #endif |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index 289e9f5..7b5c74d 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -1,888 +1,888 @@ | |||
1 | /* | 1 | /* |
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 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> | 10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> |
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 "kpppwidget.h" | 27 | #include "kpppwidget.h" |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qevent.h> | 32 | #include <qevent.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | 41 | ||
42 | // #include <kaboutdata.h> | 42 | // #include <kaboutdata.h> |
43 | // #include <kapplication.h> | 43 | // #include <kapplication.h> |
44 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
45 | //#include <kcmdlineargs.h> | 45 | //#include <kcmdlineargs.h> |
46 | //#include <kconfig.h> | 46 | //#include <kconfig.h> |
47 | //#include <kdebug.h> | 47 | //#include <kdebug.h> |
48 | #define i18n QObject::tr | 48 | #define i18n QObject::tr |
49 | //#include <kiconloader.h> // For BarIcon | 49 | //#include <kiconloader.h> // For BarIcon |
50 | //#include <klocale.h> | 50 | //#include <klocale.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | // #include <kseparator.h> | 52 | // #include <kseparator.h> |
53 | // #include <kstandarddirs.h> | 53 | // #include <kstandarddirs.h> |
54 | // #include <kwin.h> | 54 | // #include <kwin.h> |
55 | // #include <khelpmenu.h> | 55 | // #include <khelpmenu.h> |
56 | #include <qpushbutton.h> | 56 | #include <qpushbutton.h> |
57 | //#include <kguiitem.h> | 57 | //#include <kguiitem.h> |
58 | 58 | ||
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | #include <errno.h> | 60 | #include <errno.h> |
61 | #include <signal.h> | 61 | #include <signal.h> |
62 | 62 | ||
63 | #include "runtests.h" | 63 | #include "runtests.h" |
64 | 64 | ||
65 | //#include "main.h" | 65 | //#include "main.h" |
66 | #include "auth.h" | 66 | #include "auth.h" |
67 | #include "modem.h" | 67 | #include "modem.h" |
68 | //#include "ppplog.h" | 68 | //#include "ppplog.h" |
69 | //#include "opener.h" | 69 | //#include "opener.h" |
70 | //#include "requester.h" | 70 | //#include "requester.h" |
71 | //#include "pppstats.h" | 71 | //#include "pppstats.h" |
72 | #include "pppdata.h" | 72 | #include "pppdata.h" |
73 | #include "general.h" | 73 | #include "general.h" |
74 | #include "interface.h" | 74 | #include "interface.h" |
75 | 75 | ||
76 | #define execute_command system | 76 | #define execute_command system |
77 | 77 | ||
78 | KPPPWidget *p_kppp = 0; | 78 | KPPPWidget *p_kppp = 0; |
79 | 79 | ||
80 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) | 80 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) |
81 | : QDialog(parent, name, modal, fl), _pppdata(pd) | 81 | : QDialog(parent, name, modal, fl), _pppdata(pd) |
82 | { | 82 | { |
83 | // tabWindow = 0; | 83 | // tabWindow = 0; |
84 | p_kppp = this; | 84 | p_kppp = this; |
85 | // before doing anything else, run a few tests | 85 | // before doing anything else, run a few tests |
86 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | 86 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) |
87 | _pppdata->setModemDevice("/dev/modem"); | 87 | _pppdata->setModemDevice("/dev/modem"); |
88 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 88 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
89 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | 89 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); |
90 | if (!_pppdata->setAccount( i->getHardwareName() )) | 90 | if (!_pppdata->setAccount( i->getHardwareName() )) |
91 | _pppdata->setAccount( 0 ); | 91 | _pppdata->setAccount( 0 ); |
92 | 92 | ||
93 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | 93 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); |
94 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); | 94 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); |
95 | 95 | ||
96 | int result = runTests(); | 96 | int result = runTests(); |
97 | if(result == TEST_CRITICAL) | 97 | if(result == TEST_CRITICAL) |
98 | exit(4); | 98 | exit(4); |
99 | 99 | ||
100 | // installEventFilter(this); | 100 | // installEventFilter(this); |
101 | 101 | ||
102 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 102 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
103 | 103 | ||
104 | QGridLayout *l1 = new QGridLayout(3, 4); | 104 | QGridLayout *l1 = new QGridLayout(3, 4); |
105 | tl->addLayout(l1); | 105 | tl->addLayout(l1); |
106 | l1->addColSpacing(0, 10); | 106 | l1->addColSpacing(0, 10); |
107 | l1->addColSpacing(3, 10); | 107 | l1->addColSpacing(3, 10); |
108 | l1->setColStretch(1, 3); | 108 | l1->setColStretch(1, 3); |
109 | l1->setColStretch(2, 4); | 109 | l1->setColStretch(2, 4); |
110 | 110 | ||
111 | label1 = new QLabel(i18n("C&onnect to: "), this); | 111 | label1 = new QLabel(i18n("C&onnect to: "), this); |
112 | l1->addWidget(label1, 0, 1); | 112 | l1->addWidget(label1, 0, 1); |
113 | 113 | ||
114 | connectto_c = new QComboBox(false, this); | 114 | connectto_c = new QComboBox(false, this); |
115 | label1->setBuddy(connectto_c); | 115 | label1->setBuddy(connectto_c); |
116 | 116 | ||
117 | connect(connectto_c, SIGNAL(activated(int)), | 117 | connect(connectto_c, SIGNAL(activated(int)), |
118 | SLOT(newdefaultaccount(int))); | 118 | SLOT(newdefaultaccount(int))); |
119 | l1->addWidget(connectto_c, 0, 2); | 119 | l1->addWidget(connectto_c, 0, 2); |
120 | 120 | ||
121 | ID_Label = new QLabel(i18n("&Login ID:"), this); | 121 | ID_Label = new QLabel(i18n("&Login ID:"), this); |
122 | l1->addWidget(ID_Label, 1, 1); | 122 | l1->addWidget(ID_Label, 1, 1); |
123 | 123 | ||
124 | // the entry line for usernames | 124 | // the entry line for usernames |
125 | ID_Edit = new QLineEdit(this); | 125 | ID_Edit = new QLineEdit(this); |
126 | ID_Label->setBuddy(ID_Edit); | 126 | ID_Label->setBuddy(ID_Edit); |
127 | l1->addWidget(ID_Edit, 1, 2); | 127 | l1->addWidget(ID_Edit, 1, 2); |
128 | connect(ID_Edit, SIGNAL(returnPressed()), | 128 | connect(ID_Edit, SIGNAL(returnPressed()), |
129 | this, SLOT(enterPressedInID())); | 129 | this, SLOT(enterPressedInID())); |
130 | QString tmp = i18n("<p>Type in the username that you got from your\n" | 130 | QString tmp = i18n("<p>Type in the username that you got from your\n" |
131 | "ISP. This is especially important for PAP\n" | 131 | "ISP. This is especially important for PAP\n" |
132 | "and CHAP. You may omit this when you use\n" | 132 | "and CHAP. You may omit this when you use\n" |
133 | "terminal-based or script-based authentication.\n" | 133 | "terminal-based or script-based authentication.\n" |
134 | "\n" | 134 | "\n" |
135 | "<b>Important</b>: case is important here:\n" | 135 | "<b>Important</b>: case is important here:\n" |
136 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); | 136 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); |
137 | 137 | ||
138 | QWhatsThis::add(ID_Label,tmp); | 138 | QWhatsThis::add(ID_Label,tmp); |
139 | QWhatsThis::add(ID_Edit,tmp); | 139 | QWhatsThis::add(ID_Edit,tmp); |
140 | 140 | ||
141 | PW_Label = new QLabel(i18n("&Password:"), this); | 141 | PW_Label = new QLabel(i18n("&Password:"), this); |
142 | l1->addWidget(PW_Label, 2, 1); | 142 | l1->addWidget(PW_Label, 2, 1); |
143 | 143 | ||
144 | PW_Edit= new QLineEdit(this); | 144 | PW_Edit= new QLineEdit(this); |
145 | PW_Label->setBuddy(PW_Edit); | 145 | PW_Label->setBuddy(PW_Edit); |
146 | PW_Edit->setEchoMode(QLineEdit::Password); | 146 | PW_Edit->setEchoMode(QLineEdit::Password); |
147 | l1->addWidget(PW_Edit, 2, 2); | 147 | l1->addWidget(PW_Edit, 2, 2); |
148 | connect(PW_Edit, SIGNAL(returnPressed()), | 148 | connect(PW_Edit, SIGNAL(returnPressed()), |
149 | this, SLOT(enterPressedInPW())); | 149 | this, SLOT(enterPressedInPW())); |
150 | 150 | ||
151 | tmp = i18n("<p>Type in the password that you got from your\n" | 151 | tmp = i18n("<p>Type in the password that you got from your\n" |
152 | "ISP. This is especially important for PAP\n" | 152 | "ISP. This is especially important for PAP\n" |
153 | "and CHAP. You may omit this when you use\n" | 153 | "and CHAP. You may omit this when you use\n" |
154 | "terminal-based or script-based authentication.\n" | 154 | "terminal-based or script-based authentication.\n" |
155 | "\n" | 155 | "\n" |
156 | "<b>Important</b>: case is important here:\n" | 156 | "<b>Important</b>: case is important here:\n" |
157 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); | 157 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); |
158 | 158 | ||
159 | QWhatsThis::add(PW_Label,tmp); | 159 | QWhatsThis::add(PW_Label,tmp); |
160 | QWhatsThis::add(PW_Edit,tmp); | 160 | QWhatsThis::add(PW_Edit,tmp); |
161 | 161 | ||
162 | QHBoxLayout *l3 = new QHBoxLayout; | 162 | QHBoxLayout *l3 = new QHBoxLayout; |
163 | tl->addSpacing(5); | 163 | tl->addSpacing(5); |
164 | tl->addLayout(l3); | 164 | tl->addLayout(l3); |
165 | tl->addSpacing(5); | 165 | tl->addSpacing(5); |
166 | l3->addSpacing(10); | 166 | l3->addSpacing(10); |
167 | log = new QCheckBox(i18n("Show lo&g window"), this); | 167 | log = new QCheckBox(i18n("Show lo&g window"), this); |
168 | connect(log, SIGNAL(toggled(bool)), | 168 | connect(log, SIGNAL(toggled(bool)), |
169 | this, SLOT(log_window_toggled(bool))); | 169 | this, SLOT(log_window_toggled(bool))); |
170 | log->setChecked(_pppdata->get_show_log_window()); | 170 | log->setChecked(_pppdata->get_show_log_window()); |
171 | l3->addWidget(log); | 171 | l3->addWidget(log); |
172 | 172 | ||
173 | QWhatsThis::add(log, | 173 | QWhatsThis::add(log, |
174 | i18n("<p>This controls whether a log window is shown.\n" | 174 | i18n("<p>This controls whether a log window is shown.\n" |
175 | "A log window shows the communication between\n" | 175 | "A log window shows the communication between\n" |
176 | "<i>kppp</i> and your modem. This will help you\n" | 176 | "<i>kppp</i> and your modem. This will help you\n" |
177 | "in tracking down problems.\n" | 177 | "in tracking down problems.\n" |
178 | "\n" | 178 | "\n" |
179 | "Turn it off if <i>kppp</i> routinely connects without\n" | 179 | "Turn it off if <i>kppp</i> routinely connects without\n" |
180 | "problems")); | 180 | "problems")); |
181 | 181 | ||
182 | // fline = new QSeparator( KSeparator::HLine, this); | 182 | // fline = new QSeparator( KSeparator::HLine, this); |
183 | // tl->addWidget(fline); | 183 | // tl->addWidget(fline); |
184 | 184 | ||
185 | QHBoxLayout *l2 = new QHBoxLayout(this); | 185 | QHBoxLayout *l2 = new QHBoxLayout(this); |
186 | tl->addLayout(l2); | 186 | tl->addLayout(l2); |
187 | 187 | ||
188 | int minw = 0; | 188 | int minw = 0; |
189 | quit_b = new QPushButton(i18n("&Quit"), this); | 189 | quit_b = new QPushButton(i18n("&Quit"), this); |
190 | // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); | 190 | // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); |
191 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); | 191 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); |
192 | if(quit_b->sizeHint().width() > minw) | 192 | if(quit_b->sizeHint().width() > minw) |
193 | minw = quit_b->sizeHint().width(); | 193 | minw = quit_b->sizeHint().width(); |
194 | 194 | ||
195 | setup_b = new QPushButton(i18n("&Setup..."), this); | 195 | setup_b = new QPushButton(i18n("&Setup..."), this); |
196 | // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); | 196 | // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); |
197 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); | 197 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); |
198 | if(setup_b->sizeHint().width() > minw) | 198 | if(setup_b->sizeHint().width() > minw) |
199 | minw = setup_b->sizeHint().width(); | 199 | minw = setup_b->sizeHint().width(); |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | // if(_pppdata->access() != KConfig::ReadWrite) | 203 | // if(_pppdata->access() != KConfig::ReadWrite) |
204 | // setup_b->setEnabled(false); | 204 | // setup_b->setEnabled(false); |
205 | 205 | ||
206 | // help_b = new QPushButton(i18n("&Help"), this); | 206 | // help_b = new QPushButton(i18n("&Help"), this); |
207 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); | 207 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); |
208 | 208 | ||
209 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); | 209 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); |
210 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); | 210 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); |
211 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); | 211 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); |
212 | 212 | ||
213 | // if(help_b->sizeHint().width() > minw) | 213 | // if(help_b->sizeHint().width() > minw) |
214 | // minw = help_b->sizeHint().width(); | 214 | // minw = help_b->sizeHint().width(); |
215 | 215 | ||
216 | connect_b = new QPushButton(i18n("&Connect"), this); | 216 | connect_b = new QPushButton(i18n("&Connect"), this); |
217 | connect_b->setDefault(true); | 217 | connect_b->setDefault(true); |
218 | connect_b->setFocus(); | 218 | connect_b->setFocus(); |
219 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); | 219 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); |
220 | if(connect_b->sizeHint().width() > minw) | 220 | if(connect_b->sizeHint().width() > minw) |
221 | minw = connect_b->sizeHint().width(); | 221 | minw = connect_b->sizeHint().width(); |
222 | 222 | ||
223 | quit_b->setFixedWidth(minw); | 223 | quit_b->setFixedWidth(minw); |
224 | setup_b->setFixedWidth(minw); | 224 | setup_b->setFixedWidth(minw); |
225 | // help_b->setFixedWidth(help_b->sizeHint().width()); | 225 | // help_b->setFixedWidth(help_b->sizeHint().width()); |
226 | connect_b->setFixedWidth(minw); | 226 | connect_b->setFixedWidth(minw); |
227 | 227 | ||
228 | l2->addWidget(quit_b); | 228 | l2->addWidget(quit_b); |
229 | l2->addWidget(setup_b); | 229 | l2->addWidget(setup_b); |
230 | // l2->addWidget(help_b); | 230 | // l2->addWidget(help_b); |
231 | l2->addSpacing(20); | 231 | l2->addSpacing(20); |
232 | l2->addWidget(connect_b); | 232 | l2->addWidget(connect_b); |
233 | 233 | ||
234 | setFixedSize(sizeHint()); | 234 | setFixedSize(sizeHint()); |
235 | 235 | ||
236 | (void)new Modem(_pppdata); | 236 | (void)new Modem(_pppdata); |
237 | 237 | ||
238 | // we also connect cmld_start to the beginConnect so that I can run | 238 | // we also connect cmld_start to the beginConnect so that I can run |
239 | // the dialer through a command line argument | 239 | // the dialer through a command line argument |
240 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); | 240 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); |
241 | 241 | ||
242 | // stats = new PPPStats; | 242 | // stats = new PPPStats; |
243 | 243 | ||
244 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 244 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
245 | 245 | ||
246 | // constructor of con_win reads position from config file | 246 | // constructor of con_win reads position from config file |
247 | con_win = new ConWindow(_pppdata, 0, "conw", this); | 247 | con_win = new ConWindow(_pppdata, 0, "conw", this); |
248 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); | 248 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); |
249 | 249 | ||
250 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); | 250 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); |
251 | // statdlg->hide(); | 251 | // statdlg->hide(); |
252 | 252 | ||
253 | // load up the accounts combo box | 253 | // load up the accounts combo box |
254 | 254 | ||
255 | // resetaccounts(); | 255 | // resetaccounts(); |
256 | con = new ConnectWidget(_pppdata, 0, "con"); | 256 | con = new ConnectWidget(_pppdata, 0, "con"); |
257 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); | 257 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); |
258 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); | 258 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); |
259 | // Is this the best we can do here? it's not right. | 259 | // Is this the best we can do here? it's not right. |
260 | // QRect desk = QApplication::desktop()->screenGeometry( | 260 | // QRect desk = QApplication::desktop()->screenGeometry( |
261 | // QApplication::desktop()->screenNumber(topLevelWidget())); | 261 | // QApplication::desktop()->screenNumber(topLevelWidget())); |
262 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); | 262 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); |
263 | 263 | ||
264 | // connect the ConnectWidgets various signals | 264 | // connect the ConnectWidgets various signals |
265 | connect(con, SIGNAL(startAccounting()), | 265 | connect(con, SIGNAL(startAccounting()), |
266 | this, SLOT(startAccounting())); | 266 | this, SLOT(startAccounting())); |
267 | connect(con, SIGNAL(stopAccounting()), | 267 | connect(con, SIGNAL(stopAccounting()), |
268 | this, SLOT(stopAccounting())); | 268 | this, SLOT(stopAccounting())); |
269 | connect(qApp, SIGNAL(saveYourself()), | 269 | connect(qApp, SIGNAL(saveYourself()), |
270 | this, SLOT(saveMyself())); | 270 | this, SLOT(saveMyself())); |
271 | connect(qApp, SIGNAL(shutDown()), | 271 | connect(qApp, SIGNAL(shutDown()), |
272 | this, SLOT(shutDown())); | 272 | this, SLOT(shutDown())); |
273 | 273 | ||
274 | 274 | ||
275 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 275 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
276 | 276 | ||
277 | // m_strCmdlAccount = args->getOption("c"); | 277 | // m_strCmdlAccount = args->getOption("c"); |
278 | // m_bQuitOnDisconnect = args->isSet("q"); | 278 | // m_bQuitOnDisconnect = args->isSet("q"); |
279 | 279 | ||
280 | // if(!m_strCmdlAccount.isEmpty()) { | 280 | // if(!m_strCmdlAccount.isEmpty()) { |
281 | // m_bCmdlAccount = true; | 281 | // m_bCmdlAccount = true; |
282 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; | 282 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; |
283 | // } | 283 | // } |
284 | 284 | ||
285 | // if(m_bCmdlAccount){ | 285 | // if(m_bCmdlAccount){ |
286 | // bool result = _pppdata->setAccount(m_strCmdlAccount); | 286 | // bool result = _pppdata->setAccount(m_strCmdlAccount); |
287 | // if (!result){ | 287 | // if (!result){ |
288 | // QString string; | 288 | // QString string; |
289 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); | 289 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); |
290 | // KMessageBox::error(this, string); | 290 | // KMessageBox::error(this, string); |
291 | // m_bCmdlAccount = false; | 291 | // m_bCmdlAccount = false; |
292 | // this->show(); | 292 | // this->show(); |
293 | // } else { | 293 | // } else { |
294 | // beginConnect(); | 294 | // beginConnect(); |
295 | // } | 295 | // } |
296 | // } else | 296 | // } else |
297 | // expandbutton(); | 297 | // expandbutton(); |
298 | // show(); | 298 | // show(); |
299 | 299 | ||
300 | 300 | ||
301 | //#define KPPP_SHOW_NEWS | 301 | //#define KPPP_SHOW_NEWS |
302 | #ifdef KPPP_SHOW_NEWS | 302 | #ifdef KPPP_SHOW_NEWS |
303 | // keep user informed about recent changes | 303 | // keep user informed about recent changes |
304 | if(!m_bCmdlAccount) | 304 | if(!m_bCmdlAccount) |
305 | showNews(); | 305 | showNews(); |
306 | #endif | 306 | #endif |
307 | } | 307 | } |
308 | 308 | ||
309 | KPPPWidget::~KPPPWidget() | 309 | KPPPWidget::~KPPPWidget() |
310 | { | 310 | { |
311 | p_kppp = 0; | 311 | p_kppp = 0; |
312 | // delete stats; | 312 | // delete stats; |
313 | } | 313 | } |
314 | 314 | ||
315 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 315 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
316 | // if(e->type() == QEvent::User) { | 316 | // if(e->type() == QEvent::User) { |
317 | // switch(((SignalEvent*)e)->sigType()) { | 317 | // switch(((SignalEvent*)e)->sigType()) { |
318 | // case SIGINT: | 318 | // case SIGINT: |
319 | // qDebug( "Received a SIGINT" ); | 319 | // qDebug( "Received a SIGINT" ); |
320 | // interruptConnection(); | 320 | // interruptConnection(); |
321 | // break; | 321 | // break; |
322 | // case SIGCHLD: | 322 | // case SIGCHLD: |
323 | // sigChld(); | 323 | // sigChld(); |
324 | // break; | 324 | // break; |
325 | // case SIGUSR1: | 325 | // case SIGUSR1: |
326 | // sigPPPDDied(); | 326 | // sigPPPDDied(); |
327 | // break; | 327 | // break; |
328 | // } | 328 | // } |
329 | // return true; | 329 | // return true; |
330 | // } | 330 | // } |
331 | 331 | ||
332 | // if(o == connect_b) { | 332 | // if(o == connect_b) { |
333 | // if(e->type() == QEvent::KeyPress) { | 333 | // if(e->type() == QEvent::KeyPress) { |
334 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 334 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
335 | // beginConnect(); | 335 | // beginConnect(); |
336 | // return true; | 336 | // return true; |
337 | // } | 337 | // } |
338 | // } | 338 | // } |
339 | // } | 339 | // } |
340 | 340 | ||
341 | // return false; | 341 | // return false; |
342 | // } | 342 | // } |
343 | 343 | ||
344 | 344 | ||
345 | 345 | ||
346 | 346 | ||
347 | void KPPPWidget::enterPressedInID() { | 347 | void KPPPWidget::enterPressedInID() { |
348 | PW_Edit->setFocus(); | 348 | PW_Edit->setFocus(); |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void KPPPWidget::enterPressedInPW() { | 352 | void KPPPWidget::enterPressedInPW() { |
353 | connect_b->setFocus(); | 353 | connect_b->setFocus(); |
354 | } | 354 | } |
355 | 355 | ||
356 | // triggered by the session manager | 356 | // triggered by the session manager |
357 | void KPPPWidget::saveMyself() { | 357 | void KPPPWidget::saveMyself() { |
358 | _pppdata->save(); | 358 | _pppdata->save(); |
359 | } | 359 | } |
360 | 360 | ||
361 | void KPPPWidget::shutDown() { | 361 | void KPPPWidget::shutDown() { |
362 | interruptConnection(); | 362 | interruptConnection(); |
363 | saveMyself(); | 363 | saveMyself(); |
364 | } | 364 | } |
365 | 365 | ||
366 | void KPPPWidget::log_window_toggled(bool on) { | 366 | void KPPPWidget::log_window_toggled(bool on) { |
367 | _pppdata->set_show_log_window(on); | 367 | _pppdata->set_show_log_window(on); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | 371 | ||
372 | 372 | ||
373 | // void KPPPWidget::resetaccounts() { | 373 | // void KPPPWidget::resetaccounts() { |
374 | // connectto_c->clear(); | 374 | // connectto_c->clear(); |
375 | 375 | ||
376 | // int count = _pppdata->count(); | 376 | // int count = _pppdata->count(); |
377 | 377 | ||
378 | // // enable/disable controls | 378 | // // enable/disable controls |
379 | // connectto_c->setEnabled(count > 0); | 379 | // connectto_c->setEnabled(count > 0); |
380 | // connect_b->setEnabled(count > 0); | 380 | // connect_b->setEnabled(count > 0); |
381 | // log->setEnabled(count > 0); | 381 | // log->setEnabled(count > 0); |
382 | // ID_Edit->setEnabled(count > 0); | 382 | // ID_Edit->setEnabled(count > 0); |
383 | // PW_Edit->setEnabled(count > 0); | 383 | // PW_Edit->setEnabled(count > 0); |
384 | 384 | ||
385 | // //load the accounts | 385 | // //load the accounts |
386 | // for(int i=0; i < count; i++) { | 386 | // for(int i=0; i < count; i++) { |
387 | // _pppdata->setAccountbyIndex(i); | 387 | // _pppdata->setAccountbyIndex(i); |
388 | // connectto_c->insertItem(_pppdata->accname()); | 388 | // connectto_c->insertItem(_pppdata->accname()); |
389 | // } | 389 | // } |
390 | 390 | ||
391 | // //set the default account | 391 | // //set the default account |
392 | // if(!_pppdata->defaultAccount().isEmpty()) { | 392 | // if(!_pppdata->defaultAccount().isEmpty()) { |
393 | // for(int i=0; i < count; i++) | 393 | // for(int i=0; i < count; i++) |
394 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { | 394 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { |
395 | // connectto_c->setCurrentItem(i); | 395 | // connectto_c->setCurrentItem(i); |
396 | // _pppdata->setAccountbyIndex(i); | 396 | // _pppdata->setAccountbyIndex(i); |
397 | 397 | ||
398 | // ID_Edit->setText(_pppdata->storedUsername()); | 398 | // ID_Edit->setText(_pppdata->storedUsername()); |
399 | // PW_Edit->setText(_pppdata->storedPassword()); | 399 | // PW_Edit->setText(_pppdata->storedPassword()); |
400 | // } | 400 | // } |
401 | // } | 401 | // } |
402 | // else | 402 | // else |
403 | // if(count > 0) { | 403 | // if(count > 0) { |
404 | // _pppdata->setDefaultAccount(connectto_c->text(0)); | 404 | // _pppdata->setDefaultAccount(connectto_c->text(0)); |
405 | // _pppdata->save(); | 405 | // _pppdata->save(); |
406 | // ID_Edit->setText(_pppdata->storedUsername()); | 406 | // ID_Edit->setText(_pppdata->storedUsername()); |
407 | // PW_Edit->setText(_pppdata->storedPassword()); | 407 | // PW_Edit->setText(_pppdata->storedPassword()); |
408 | // } | 408 | // } |
409 | 409 | ||
410 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), | 410 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), |
411 | // this, SLOT(usernameChanged(const QString &))); | 411 | // this, SLOT(usernameChanged(const QString &))); |
412 | 412 | ||
413 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), | 413 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), |
414 | // this, SLOT(passwordChanged(const QString &))); | 414 | // this, SLOT(passwordChanged(const QString &))); |
415 | 415 | ||
416 | // if (ID_Edit->text().isEmpty()) | 416 | // if (ID_Edit->text().isEmpty()) |
417 | // ID_Edit->setFocus(); | 417 | // ID_Edit->setFocus(); |
418 | // else if (PW_Edit->text().isEmpty()) | 418 | // else if (PW_Edit->text().isEmpty()) |
419 | // PW_Edit->setFocus(); | 419 | // PW_Edit->setFocus(); |
420 | // } | 420 | // } |
421 | 421 | ||
422 | 422 | ||
423 | void KPPPWidget::interruptConnection() { | 423 | void KPPPWidget::interruptConnection() { |
424 | // interrupt dial up | 424 | // interrupt dial up |
425 | // | 425 | // |
426 | 426 | ||
427 | if (con->isVisible()) | 427 | if (con->isVisible()) |
428 | emit con->cancelbutton(); | 428 | emit con->cancelbutton(); |
429 | 429 | ||
430 | // disconnect if online | 430 | // disconnect if online |
431 | if (_pppdata->pppdRunning()) | 431 | if (_pppdata->pppdRunning()) |
432 | emit disconnect(); | 432 | emit disconnect(); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void KPPPWidget::sigPPPDDied() { | 436 | void KPPPWidget::sigPPPDDied() { |
437 | qDebug( "Received a SIGUSR1" ); | 437 | qDebug( "Received a SIGUSR1" ); |
438 | 438 | ||
439 | // if we are not connected pppdpid is -1 so have have to check for that | 439 | // if we are not connected pppdpid is -1 so have have to check for that |
440 | // in the followin line to make sure that we don't raise a false alarm | 440 | // in the followin line to make sure that we don't raise a false alarm |
441 | // such as would be the case when the log file viewer exits. | 441 | // such as would be the case when the log file viewer exits. |
442 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { | 442 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
443 | qDebug( "It was pppd that died" ); | 443 | qDebug( "It was pppd that died" ); |
444 | 444 | ||
445 | // when we killpppd() on Cancel in ConnectWidget | 445 | // when we killpppd() on Cancel in ConnectWidget |
446 | // we set pppid to -1 so we won't | 446 | // we set pppid to -1 so we won't |
447 | // enter this block | 447 | // enter this block |
448 | 448 | ||
449 | // just to be sure | 449 | // just to be sure |
450 | 450 | ||
451 | Modem::modem->removeSecret(AUTH_PAP); | 451 | Modem::modem->removeSecret(AUTH_PAP); |
452 | Modem::modem->removeSecret(AUTH_CHAP); | 452 | Modem::modem->removeSecret(AUTH_CHAP); |
453 | 453 | ||
454 | _pppdata->setpppdRunning(false); | 454 | _pppdata->setpppdRunning(false); |
455 | 455 | ||
456 | qDebug( "Executing command on disconnect since pppd has died." ); | 456 | qDebug( "Executing command on disconnect since pppd has died." ); |
457 | QApplication::flushX(); | 457 | QApplication::flushX(); |
458 | execute_command(_pppdata->command_on_disconnect()); | 458 | execute_command(_pppdata->command_on_disconnect()); |
459 | 459 | ||
460 | // stopAccounting(); | 460 | // stopAccounting(); |
461 | 461 | ||
462 | con_win->stopClock(); | 462 | con_win->stopClock(); |
463 | // DockWidget::dock_widget->stop_stats(); | 463 | // DockWidget::dock_widget->stop_stats(); |
464 | // DockWidget::dock_widget->hide(); | 464 | // DockWidget::dock_widget->hide(); |
465 | 465 | ||
466 | if(!_pppdata->pppdError()) | 466 | if(!_pppdata->pppdError()) |
467 | _pppdata->setpppdError(E_PPPD_DIED); | 467 | _pppdata->setpppdError(E_PPPD_DIED); |
468 | removedns(); | 468 | removedns(); |
469 | Modem::modem->unlockdevice(); | 469 | Modem::modem->unlockdevice(); |
470 | // | 470 | // |
471 | con->pppdDied(); | 471 | con->pppdDied(); |
472 | 472 | ||
473 | if(!_pppdata->automatic_redial()) { | 473 | if(!_pppdata->automatic_redial()) { |
474 | quit_b->setFocus(); | 474 | quit_b->setFocus(); |
475 | show(); | 475 | show(); |
476 | con_win->stopClock(); | 476 | con_win->stopClock(); |
477 | //stopAccounting(); | 477 | //stopAccounting(); |
478 | con_win->hide(); | 478 | con_win->hide(); |
479 | con->hide(); | 479 | con->hide(); |
480 | 480 | ||
481 | _pppdata->setpppdRunning(false); | 481 | _pppdata->setpppdRunning(false); |
482 | // // not in a signal handler !!! KNotifyClient::beep(); | 482 | // // not in a signal handler !!! KNotifyClient::beep(); |
483 | QString msg; | 483 | QString msg; |
484 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 484 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
485 | msg = i18n("Timeout expired while waiting for the PPP interface " | 485 | msg = i18n("Timeout expired while waiting for the PPP interface " |
486 | "to come up!"); | 486 | "to come up!"); |
487 | else { | 487 | else { |
488 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); | 488 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); |
489 | Modem::modem->pppdExitStatus(); | 489 | Modem::modem->pppdExitStatus(); |
490 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 490 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
491 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 491 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
492 | msg += i18n("</p><p>See 'man pppd' for an explanation of the error " | 492 | msg += i18n("</p><p>See 'man pppd' for an explanation of the error " |
493 | "codes or take a look at the kppp FAQ on " | 493 | "codes or take a look at the kppp FAQ on " |
494 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 494 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
495 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 495 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) | 499 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) |
500 | // // PPPL_ShowLog(); | 500 | // // PPPL_ShowLog(); |
501 | // } else { /* reconnect on disconnect */ | 501 | // } else { /* reconnect on disconnect */ |
502 | if (false){ | 502 | if (false){ |
503 | qDebug( "Trying to reconnect... " ); | 503 | qDebug( "Trying to reconnect... " ); |
504 | 504 | ||
505 | if(_pppdata->authMethod() == AUTH_PAP || | 505 | if(_pppdata->authMethod() == AUTH_PAP || |
506 | _pppdata->authMethod() == AUTH_CHAP || | 506 | _pppdata->authMethod() == AUTH_CHAP || |
507 | _pppdata->authMethod() == AUTH_PAPCHAP) | 507 | _pppdata->authMethod() == AUTH_PAPCHAP) |
508 | Modem::modem->setSecret(_pppdata->authMethod(), | 508 | Modem::modem->setSecret(_pppdata->authMethod(), |
509 | encodeWord(_pppdata->storedUsername()), | 509 | encodeWord(_pppdata->storedUsername()), |
510 | encodeWord(_pppdata->password())); | 510 | encodeWord(_pppdata->password())); |
511 | 511 | ||
512 | con_win->hide(); | 512 | con_win->hide(); |
513 | con_win->stopClock(); | 513 | con_win->stopClock(); |
514 | //stopAccounting(); | 514 | //stopAccounting(); |
515 | _pppdata->setpppdRunning(false); | 515 | _pppdata->setpppdRunning(false); |
516 | // not in a signal handler !!!KNotifyClient::beep(); | 516 | // not in a signal handler !!!KNotifyClient::beep(); |
517 | emit cmdl_start(); | 517 | emit cmdl_start(); |
518 | } | 518 | } |
519 | } | 519 | } |
520 | _pppdata->setpppdError(0); | 520 | _pppdata->setpppdError(0); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | // void KPPPWidget::sigChld() { | 524 | // void KPPPWidget::sigChld() { |
525 | // qDebug( "sigchld()" ); | 525 | // qDebug( "sigchld()" ); |
526 | // // pid_t id = wait(0L); | 526 | // // pid_t id = wait(0L); |
527 | // // if(id == helperPid && helperPid != -1) { | 527 | // // if(id == helperPid && helperPid != -1) { |
528 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 528 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
529 | // // helperPid = -1; | 529 | // // helperPid = -1; |
530 | // QString msg = i18n("kppp's helper process just died.\n" | 530 | // QString msg = i18n("kppp's helper process just died.\n" |
531 | // "Since a further execution would be pointless, " | 531 | // "Since a further execution would be pointless, " |
532 | // "kppp will shut down now."); | 532 | // "kppp will shut down now."); |
533 | // QMessageBox::warning(0L,"error", msg); | 533 | // QMessageBox::warning(0L,"error", msg); |
534 | // //remove_pidfile(); | 534 | // //remove_pidfile(); |
535 | // exit(1); | 535 | // exit(1); |
536 | // // } | 536 | // // } |
537 | // } | 537 | // } |
538 | 538 | ||
539 | 539 | ||
540 | void KPPPWidget::newdefaultaccount(int i) { | 540 | void KPPPWidget::newdefaultaccount(int i) { |
541 | _pppdata->setDefaultAccount(connectto_c->text(i)); | 541 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
542 | _pppdata->save(); | 542 | _pppdata->save(); |
543 | ID_Edit->setText(_pppdata->storedUsername()); | 543 | ID_Edit->setText(_pppdata->storedUsername()); |
544 | PW_Edit->setText(_pppdata->storedPassword()); | 544 | PW_Edit->setText(_pppdata->storedPassword()); |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | 548 | ||
549 | 549 | ||
550 | void KPPPWidget::beginConnect() { | 550 | void KPPPWidget::beginConnect() { |
551 | // make sure to connect to the account that is selected in the combo box | 551 | // make sure to connect to the account that is selected in the combo box |
552 | // (exeption: an account given by a command line argument) | 552 | // (exeption: an account given by a command line argument) |
553 | // if(!m_bCmdlAccount) { | 553 | // if(!m_bCmdlAccount) { |
554 | // _pppdata->setAccount(connectto_c->currentText()); | 554 | // _pppdata->setAccount(connectto_c->currentText()); |
555 | // _pppdata->setPassword(PW_Edit->text()); | 555 | // _pppdata->setPassword(PW_Edit->text()); |
556 | // } else { | 556 | // } else { |
557 | _pppdata->setPassword(_pppdata->storedPassword()); | 557 | _pppdata->setPassword(_pppdata->storedPassword()); |
558 | // } | 558 | // } |
559 | 559 | ||
560 | QFileInfo info(pppdPath()); | 560 | QFileInfo info(pppdPath()); |
561 | 561 | ||
562 | if(!info.exists()){ | 562 | if(!info.exists()){ |
563 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" | 563 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" |
564 | "Make sure that pppd is installed and " | 564 | "Make sure that pppd is installed and " |
565 | "that you have entered the correct path.")); | 565 | "that you have entered the correct path.")); |
566 | return; | 566 | return; |
567 | } | 567 | } |
568 | #if 0 | 568 | #if 0 |
569 | if(!info.isExecutable()){ | 569 | if(!info.isExecutable()){ |
570 | 570 | ||
571 | QString string; | 571 | QString string; |
572 | string = i18n("kppp cannot execute:\n %1\n" | 572 | string = i18n("kppp cannot execute:\n %1\n" |
573 | "Please make sure that you have given kppp " | 573 | "Please make sure that you have given kppp " |
574 | "setuid permission and that " | 574 | "setuid permission and that " |
575 | "pppd is executable.").arg(_pppdata->pppdPath()); | 575 | "pppd is executable.").arg(_pppdata->pppdPath()); |
576 | KMessageBox::error(this, string); | 576 | KMessageBox::error(this, string); |
577 | return; | 577 | return; |
578 | 578 | ||
579 | } | 579 | } |
580 | #endif | 580 | #endif |
581 | 581 | ||
582 | QFileInfo info2(_pppdata->modemDevice()); | 582 | QFileInfo info2(_pppdata->modemDevice()); |
583 | 583 | ||
584 | if(!info2.exists()){ | 584 | if(!info2.exists()){ |
585 | QString string; | 585 | QString string; |
586 | string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " | 586 | string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " |
587 | "your modem device properly " | 587 | "your modem device properly " |
588 | "and/or adjust the location of the modem device on " | 588 | "and/or adjust the location of the modem device on " |
589 | "the modem tab of " | 589 | "the modem tab of " |
590 | "the setup dialog.").arg(_pppdata->modemDevice()); | 590 | "the setup dialog.").arg(_pppdata->modemDevice()); |
591 | QMessageBox::warning(this, "error", string); | 591 | QMessageBox::warning(this, "error", string); |
592 | return; | 592 | return; |
593 | } | 593 | } |
594 | 594 | ||
595 | // if this is a PAP or CHAP account, ensure that username is | 595 | // if this is a PAP or CHAP account, ensure that username is |
596 | // supplied | 596 | // supplied |
597 | if(_pppdata->authMethod() == AUTH_PAP || | 597 | if(_pppdata->authMethod() == AUTH_PAP || |
598 | _pppdata->authMethod() == AUTH_CHAP || | 598 | _pppdata->authMethod() == AUTH_CHAP || |
599 | _pppdata->authMethod() == AUTH_PAPCHAP ) { | 599 | _pppdata->authMethod() == AUTH_PAPCHAP ) { |
600 | if(ID_Edit->text().isEmpty()) { | 600 | if(ID_Edit->text().isEmpty()) { |
601 | QMessageBox::warning(this,"error", | 601 | QMessageBox::warning(this,"error", |
602 | i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); | 602 | i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); |
603 | // FIXME: return; | 603 | return; |
604 | } else { | 604 | } else { |
605 | if(!Modem::modem->setSecret(_pppdata->authMethod(), | 605 | if(!Modem::modem->setSecret(_pppdata->authMethod(), |
606 | encodeWord(_pppdata->storedUsername()), | 606 | encodeWord(_pppdata->storedUsername()), |
607 | encodeWord(_pppdata->password()))) { | 607 | encodeWord(_pppdata->password()))) { |
608 | QString s; | 608 | QString s; |
609 | s = i18n("Cannot create PAP/CHAP authentication\n" | 609 | s = i18n("Cannot create PAP/CHAP authentication\n" |
610 | "file \"%1\"").arg(PAP_AUTH_FILE); | 610 | "file \"%1\"").arg(PAP_AUTH_FILE); |
611 | QMessageBox::warning(this, "error", s); | 611 | QMessageBox::warning(this, "error", s); |
612 | return; | 612 | return; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | if (_pppdata->phonenumber().isEmpty()) { | 617 | if (_pppdata->phonenumber().isEmpty()) { |
618 | QString s = i18n("You must specify a telephone number!"); | 618 | QString s = i18n("You must specify a telephone number!"); |
619 | QMessageBox::warning(this, "error", s); | 619 | QMessageBox::warning(this, "error", s); |
620 | return; | 620 | return; |
621 | } | 621 | } |
622 | 622 | ||
623 | this->hide(); | 623 | this->hide(); |
624 | 624 | ||
625 | QString tit = i18n("Connecting to: %1").arg(_pppdata->accname()); | 625 | QString tit = i18n("Connecting to: %1").arg(_pppdata->accname()); |
626 | // con->setCaption(tit); | 626 | // con->setCaption(tit); |
627 | 627 | ||
628 | // con->show(); | 628 | // con->show(); |
629 | 629 | ||
630 | 630 | ||
631 | emit begin_connect(); | 631 | emit begin_connect(); |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
635 | void KPPPWidget::disconnect() { | 635 | void KPPPWidget::disconnect() { |
636 | if (!_pppdata->command_before_disconnect().isEmpty()) { | 636 | if (!_pppdata->command_before_disconnect().isEmpty()) { |
637 | con_win->hide(); | 637 | con_win->hide(); |
638 | con->show(); | 638 | con->show(); |
639 | con->setCaption(i18n("Disconnecting...")); | 639 | con->setCaption(i18n("Disconnecting...")); |
640 | con->setMsg(i18n("Executing command before disconnection.")); | 640 | con->setMsg(i18n("Executing command before disconnection.")); |
641 | 641 | ||
642 | qApp->processEvents(); | 642 | qApp->processEvents(); |
643 | QApplication::flushX(); | 643 | QApplication::flushX(); |
644 | // pid_t id = | 644 | // pid_t id = |
645 | execute_command(_pppdata->command_before_disconnect()); | 645 | execute_command(_pppdata->command_before_disconnect()); |
646 | // int i, status; | 646 | // int i, status; |
647 | 647 | ||
648 | // do { | 648 | // do { |
649 | // kapp->processEvents(); | 649 | // kapp->processEvents(); |
650 | // i = waitpid(id, &status, WNOHANG); | 650 | // i = waitpid(id, &status, WNOHANG); |
651 | // usleep(500000); | 651 | // usleep(500000); |
652 | // } while (i == 0 && errno == 0); | 652 | // } while (i == 0 && errno == 0); |
653 | 653 | ||
654 | con->hide(); | 654 | con->hide(); |
655 | } | 655 | } |
656 | 656 | ||
657 | qApp->processEvents(); | 657 | qApp->processEvents(); |
658 | 658 | ||
659 | // statdlg->stop_stats(); | 659 | // statdlg->stop_stats(); |
660 | Modem::modem->killPPPDaemon(); | 660 | Modem::modem->killPPPDaemon(); |
661 | 661 | ||
662 | QApplication::flushX(); | 662 | QApplication::flushX(); |
663 | execute_command(_pppdata->command_on_disconnect()); | 663 | execute_command(_pppdata->command_on_disconnect()); |
664 | 664 | ||
665 | Modem::modem->removeSecret(AUTH_PAP); | 665 | Modem::modem->removeSecret(AUTH_PAP); |
666 | Modem::modem->removeSecret(AUTH_CHAP); | 666 | Modem::modem->removeSecret(AUTH_CHAP); |
667 | 667 | ||
668 | removedns(); | 668 | removedns(); |
669 | Modem::modem->unlockdevice(); | 669 | Modem::modem->unlockdevice(); |
670 | 670 | ||
671 | con_win->stopClock(); | 671 | con_win->stopClock(); |
672 | // p_kppp->stopAccounting(); | 672 | // p_kppp->stopAccounting(); |
673 | con_win->hide(); | 673 | con_win->hide(); |
674 | 674 | ||
675 | // DockWidget::dock_widget->stop_stats(); | 675 | // DockWidget::dock_widget->stop_stats(); |
676 | // DockWidget::dock_widget->hide(); | 676 | // DockWidget::dock_widget->hide(); |
677 | 677 | ||
678 | // if(m_bQuitOnDisconnect) | 678 | // if(m_bQuitOnDisconnect) |
679 | // kapp->exit(0); | 679 | // kapp->exit(0); |
680 | // else { | 680 | // else { |
681 | this->quit_b->setFocus(); | 681 | this->quit_b->setFocus(); |
682 | this->show(); | 682 | this->show(); |
683 | // } | 683 | // } |
684 | } | 684 | } |
685 | 685 | ||
686 | 686 | ||
687 | // void KPPPWidget::helpbutton() { | 687 | // void KPPPWidget::helpbutton() { |
688 | // kapp->invokeHelp(); | 688 | // kapp->invokeHelp(); |
689 | // } | 689 | // } |
690 | 690 | ||
691 | 691 | ||
692 | void KPPPWidget::quitbutton() { | 692 | void KPPPWidget::quitbutton() { |
693 | if(_pppdata->pppdRunning()) { | 693 | if(_pppdata->pppdRunning()) { |
694 | int ok = QMessageBox::warning(this, | 694 | int ok = QMessageBox::warning(this, |
695 | i18n("Exiting kPPP will close your PPP Session."), | 695 | i18n("Exiting kPPP will close your PPP Session."), |
696 | i18n("Quit kPPP?")); | 696 | i18n("Quit kPPP?")); |
697 | if(ok == QMessageBox::Yes) { | 697 | if(ok == QMessageBox::Yes) { |
698 | Modem::modem->killPPPDaemon(); | 698 | Modem::modem->killPPPDaemon(); |
699 | QApplication::flushX(); | 699 | QApplication::flushX(); |
700 | execute_command(_pppdata->command_on_disconnect()); | 700 | execute_command(_pppdata->command_on_disconnect()); |
701 | removedns(); | 701 | removedns(); |
702 | Modem::modem->unlockdevice(); | 702 | Modem::modem->unlockdevice(); |
703 | } | 703 | } |
704 | } else { | 704 | } else { |
705 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) | 705 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
706 | _pppdata->setStoredPassword(""); | 706 | _pppdata->setStoredPassword(""); |
707 | } | 707 | } |
708 | _pppdata->save(); | 708 | _pppdata->save(); |
709 | qApp->quit(); | 709 | qApp->quit(); |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | // void KPPPWidget::rulesetLoadError() { | 713 | // void KPPPWidget::rulesetLoadError() { |
714 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); | 714 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); |
715 | // } | 715 | // } |
716 | 716 | ||
717 | 717 | ||
718 | // void KPPPWidget::startAccounting() { | 718 | // void KPPPWidget::startAccounting() { |
719 | // // volume accounting | 719 | // // volume accounting |
720 | // stats->totalbytes = 0; | 720 | // stats->totalbytes = 0; |
721 | 721 | ||
722 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; | 722 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; |
723 | 723 | ||
724 | // // load the ruleset | 724 | // // load the ruleset |
725 | // if(!_pppdata->AcctEnabled()) | 725 | // if(!_pppdata->AcctEnabled()) |
726 | // return; | 726 | // return; |
727 | 727 | ||
728 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); | 728 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
729 | // // if(::access(d.data(), X_OK) != 0) | 729 | // // if(::access(d.data(), X_OK) != 0) |
730 | // acct = new Accounting(this, stats); | 730 | // acct = new Accounting(this, stats); |
731 | // // else | 731 | // // else |
732 | // // acct = new ExecutableAccounting(this); | 732 | // // acct = new ExecutableAccounting(this); |
733 | 733 | ||
734 | // // connect to the accounting object | 734 | // // connect to the accounting object |
735 | // connect(acct, SIGNAL(changed(QString, QString)), | 735 | // connect(acct, SIGNAL(changed(QString, QString)), |
736 | // con_win, SLOT(slotAccounting(QString, QString))); | 736 | // con_win, SLOT(slotAccounting(QString, QString))); |
737 | 737 | ||
738 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { | 738 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
739 | // // QString s= i18n("Can not load the accounting " | 739 | // // QString s= i18n("Can not load the accounting " |
740 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); | 740 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
741 | 741 | ||
742 | // // starting the messagebox with a timer will prevent us | 742 | // // starting the messagebox with a timer will prevent us |
743 | // // from blocking the calling function ConnectWidget::timerEvent | 743 | // // from blocking the calling function ConnectWidget::timerEvent |
744 | // ruleset_load_errmsg = s; | 744 | // ruleset_load_errmsg = s; |
745 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 745 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
746 | // return; | 746 | // return; |
747 | // } | 747 | // } |
748 | // //else | 748 | // //else |
749 | // // acct->slotStart(); | 749 | // // acct->slotStart(); |
750 | // } | 750 | // } |
751 | 751 | ||
752 | // void KPPPWidget::stopAccounting() { | 752 | // void KPPPWidget::stopAccounting() { |
753 | // // store volume accounting | 753 | // // store volume accounting |
754 | // // if(stats->totalbytes != 0) | 754 | // // if(stats->totalbytes != 0) |
755 | // // _pppdata->setTotalBytes(stats->totalbytes); | 755 | // // _pppdata->setTotalBytes(stats->totalbytes); |
756 | 756 | ||
757 | // if(!_pppdata->AcctEnabled()) | 757 | // if(!_pppdata->AcctEnabled()) |
758 | // return; | 758 | // return; |
759 | 759 | ||
760 | // // if(acct != 0) { | 760 | // // if(acct != 0) { |
761 | // // acct->slotStop(); | 761 | // // acct->slotStop(); |
762 | // // delete acct; | 762 | // // delete acct; |
763 | // // acct = 0; | 763 | // // acct = 0; |
764 | // // } | 764 | // // } |
765 | // } | 765 | // } |
766 | 766 | ||
767 | 767 | ||
768 | // void KPPPWidget::showStats() { | 768 | // void KPPPWidget::showStats() { |
769 | // if(statdlg) { | 769 | // if(statdlg) { |
770 | // statdlg->show(); | 770 | // statdlg->show(); |
771 | // statdlg->raise(); | 771 | // statdlg->raise(); |
772 | // } | 772 | // } |
773 | // } | 773 | // } |
774 | 774 | ||
775 | 775 | ||
776 | void KPPPWidget::usernameChanged(const QString &) { | 776 | void KPPPWidget::usernameChanged(const QString &) { |
777 | // store username for later use | 777 | // store username for later use |
778 | _pppdata->setStoredUsername(ID_Edit->text()); | 778 | _pppdata->setStoredUsername(ID_Edit->text()); |
779 | } | 779 | } |
780 | 780 | ||
781 | 781 | ||
782 | void KPPPWidget::passwordChanged(const QString &) { | 782 | void KPPPWidget::passwordChanged(const QString &) { |
783 | // store the password if so requested | 783 | // store the password if so requested |
784 | if(_pppdata->storePassword()) | 784 | if(_pppdata->storePassword()) |
785 | _pppdata->setStoredPassword(PW_Edit->text()); | 785 | _pppdata->setStoredPassword(PW_Edit->text()); |
786 | else | 786 | else |
787 | _pppdata->setStoredPassword(""); | 787 | _pppdata->setStoredPassword(""); |
788 | } | 788 | } |
789 | 789 | ||
790 | 790 | ||
791 | void KPPPWidget::setPW_Edit(const QString &pw) { | 791 | void KPPPWidget::setPW_Edit(const QString &pw) { |
792 | PW_Edit->setText(pw); | 792 | PW_Edit->setText(pw); |
793 | } | 793 | } |
794 | 794 | ||
795 | 795 | ||
796 | // void KPPPWidget::resetCosts(const QString &s) { | 796 | // void KPPPWidget::resetCosts(const QString &s) { |
797 | // AccountingBase::resetCosts(s); | 797 | // AccountingBase::resetCosts(s); |
798 | // } | 798 | // } |
799 | 799 | ||
800 | 800 | ||
801 | // void KPPPWidget::resetVolume(const QString &s) { | 801 | // void KPPPWidget::resetVolume(const QString &s) { |
802 | // AccountingBase::resetVolume(s); | 802 | // AccountingBase::resetVolume(s); |
803 | // } | 803 | // } |
804 | 804 | ||
805 | /** | 805 | /** |
806 | * pppd's getword() function knows about escape characters. | 806 | * pppd's getword() function knows about escape characters. |
807 | * If we write the username and password to the secrets file | 807 | * If we write the username and password to the secrets file |
808 | * we'll therefore have to escape back slashes. | 808 | * we'll therefore have to escape back slashes. |
809 | */ | 809 | */ |
810 | QString KPPPWidget::encodeWord(const QString &s) { | 810 | QString KPPPWidget::encodeWord(const QString &s) { |
811 | QString r = s; | 811 | QString r = s; |
812 | r.replace(QRegExp("\\"), "\\\\"); | 812 | r.replace(QRegExp("\\"), "\\\\"); |
813 | return r; | 813 | return r; |
814 | } | 814 | } |
815 | 815 | ||
816 | // void KPPPWidget::setQuitOnDisconnect (bool b) | 816 | // void KPPPWidget::setQuitOnDisconnect (bool b) |
817 | // { | 817 | // { |
818 | // m_bQuitOnDisconnect = b; | 818 | // m_bQuitOnDisconnect = b; |
819 | // } | 819 | // } |
820 | 820 | ||
821 | void KPPPWidget::showNews() { | 821 | void KPPPWidget::showNews() { |
822 | #ifdef KPPP_SHOW_NEWS | 822 | #ifdef KPPP_SHOW_NEWS |
823 | /* | 823 | /* |
824 | * Introduce the QuickHelp feature to new users of this version | 824 | * Introduce the QuickHelp feature to new users of this version |
825 | */ | 825 | */ |
826 | #define QUICKHELP_HINT "Hint_QuickHelp" | 826 | #define QUICKHELP_HINT "Hint_QuickHelp" |
827 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 827 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
828 | QDialog dlg(0, 0, true); | 828 | QDialog dlg(0, 0, true); |
829 | dlg.setCaption(i18n("Recent Changes in KPPP")); | 829 | dlg.setCaption(i18n("Recent Changes in KPPP")); |
830 | 830 | ||
831 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 831 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
832 | QHBoxLayout *l1 = new QHBoxLayout(10); | 832 | QHBoxLayout *l1 = new QHBoxLayout(10); |
833 | QVBoxLayout *l2 = new QVBoxLayout(10); | 833 | QVBoxLayout *l2 = new QVBoxLayout(10); |
834 | tl->addLayout(l1); | 834 | tl->addLayout(l1); |
835 | 835 | ||
836 | QLabel *icon = new QLabel(&dlg); | 836 | QLabel *icon = new QLabel(&dlg); |
837 | icon->setPixmap(BarIcon("exclamation")); | 837 | icon->setPixmap(BarIcon("exclamation")); |
838 | icon->setFixedSize(icon->sizeHint()); | 838 | icon->setFixedSize(icon->sizeHint()); |
839 | l1->addWidget(icon); | 839 | l1->addWidget(icon); |
840 | l1->addLayout(l2); | 840 | l1->addLayout(l2); |
841 | 841 | ||
842 | QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" | 842 | QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" |
843 | "called \"Quickhelp\". It's similar to a tooltip,\n" | 843 | "called \"Quickhelp\". It's similar to a tooltip,\n" |
844 | "but you can activate it whenever you want.\n" | 844 | "but you can activate it whenever you want.\n" |
845 | "\n" | 845 | "\n" |
846 | "To activate it, simply click on a control like\n" | 846 | "To activate it, simply click on a control like\n" |
847 | "a button or a label with the right mouse button.\n" | 847 | "a button or a label with the right mouse button.\n" |
848 | "If the item supports Quickhelp, a popup menu\n" | 848 | "If the item supports Quickhelp, a popup menu\n" |
849 | "will appear leading to Quickhelp.\n" | 849 | "will appear leading to Quickhelp.\n" |
850 | "\n" | 850 | "\n" |
851 | "To test it, right-click somewhere in this text."), | 851 | "To test it, right-click somewhere in this text."), |
852 | &dlg); | 852 | &dlg); |
853 | 853 | ||
854 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); | 854 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); |
855 | cb->setFixedSize(cb->sizeHint()); | 855 | cb->setFixedSize(cb->sizeHint()); |
856 | 856 | ||
857 | KButtonBox *bbox = new KButtonBox(&dlg); | 857 | KButtonBox *bbox = new KButtonBox(&dlg); |
858 | bbox->addStretch(1); | 858 | bbox->addStretch(1); |
859 | QPushButton *ok = bbox->addButton(i18n("OK")); | 859 | QPushButton *ok = bbox->addButton(i18n("OK")); |
860 | ok->setDefault(true); | 860 | ok->setDefault(true); |
861 | dlg.connect(ok, SIGNAL(clicked()), | 861 | dlg.connect(ok, SIGNAL(clicked()), |
862 | &dlg, SLOT(accept())); | 862 | &dlg, SLOT(accept())); |
863 | bbox->addStretch(1); | 863 | bbox->addStretch(1); |
864 | bbox->layout(); | 864 | bbox->layout(); |
865 | 865 | ||
866 | l2->addWidget(l); | 866 | l2->addWidget(l); |
867 | l2->addWidget(cb); | 867 | l2->addWidget(cb); |
868 | tl->addWidget(bbox); | 868 | tl->addWidget(bbox); |
869 | 869 | ||
870 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" | 870 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" |
871 | "This window will stay open until you\n" | 871 | "This window will stay open until you\n" |
872 | "click a mouse button or a press a key.\n"); | 872 | "click a mouse button or a press a key.\n"); |
873 | 873 | ||
874 | QWhatsThis::add(cb,tmp); | 874 | QWhatsThis::add(cb,tmp); |
875 | QWhatsThis::add(l, tmp); | 875 | QWhatsThis::add(l, tmp); |
876 | 876 | ||
877 | dlg.exec(); | 877 | dlg.exec(); |
878 | if(cb->isChecked()) { | 878 | if(cb->isChecked()) { |
879 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); | 879 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); |
880 | _pppdata->save(); | 880 | _pppdata->save(); |
881 | } | 881 | } |
882 | } | 882 | } |
883 | #endif | 883 | #endif |
884 | } | 884 | } |
885 | 885 | ||
886 | 886 | ||
887 | //#include "kpppwidget.moc" | 887 | //#include "kpppwidget.moc" |
888 | 888 | ||
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index 483aa58..56a7ace 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,20 +1,18 @@ | |||
1 | #TEMPLATE = app | 1 | #TEMPLATE = app |
2 | # | 2 | # |
3 | TEMPLATE = lib | 3 | TEMPLATE = 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 |
6 | DESTDIR = $(OPIEDIR)/plugins/networksettings | 6 | DESTDIR = $(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 conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h | 7 | HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h |
8 | # kpppwidget.h | 8 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp |
9 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp | ||
10 | # kpppwidget.cpp | ||
11 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 9 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
12 | DEPENDPATH+= $(OPIEDIR)/include | 10 | DEPENDPATH+= $(OPIEDIR)/include |
13 | LIBS += -lqpe -L../interfaces/ -linterfaces | 11 | LIBS += -lqpe -L../interfaces/ -linterfaces |
14 | INTERFACES= | 12 | INTERFACES= |
15 | TARGET = pppplugin | 13 | TARGET = pppplugin |
16 | VERSION = 1.0.0 | 14 | VERSION = 1.0.0 |
17 | 15 | ||
18 | 16 | ||
19 | 17 | ||
20 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index 63f9335..5fa7d3f 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp | |||
@@ -1,72 +1,70 @@ | |||
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 "interfaceppp.h" | 8 | #include "interfaceppp.h" |
9 | #include "modem.h" | 9 | #include "modem.h" |
10 | #include "pppconfig.h" | 10 | #include "pppconfig.h" |
11 | #include "pppdata.h" | 11 | #include "pppdata.h" |
12 | #include "runtests.h" | 12 | #include "runtests.h" |
13 | 13 | ||
14 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, | 14 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, |
15 | const char *name, | 15 | const char *name, |
16 | bool modal, WFlags fl ) | 16 | bool modal, WFlags fl ) |
17 | : QDialog(parent, name, modal, fl) | 17 | : QDialog(parent, name, modal, fl) |
18 | { | 18 | { |
19 | setCaption(tr("Configure Modem")); | 19 | setCaption(tr("Configure Modem")); |
20 | int result = runTests(); | 20 | int result = runTests(); |
21 | if(result == TEST_CRITICAL){ | 21 | if(result == TEST_CRITICAL){ |
22 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); | 22 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); |
23 | return; | 23 | return; |
24 | } | 24 | } |
25 | 25 | ||
26 | interface = iface; | 26 | interface = iface; |
27 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 27 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
28 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 28 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
29 | 29 | ||
30 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 30 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
31 | qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID()); | 31 | qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID()); |
32 | 32 | ||
33 | QVBoxLayout *layout = new QVBoxLayout( this ); | 33 | QVBoxLayout *layout = new QVBoxLayout( this ); |
34 | layout->setSpacing( 0 ); | 34 | layout->setSpacing( 0 ); |
35 | layout->setMargin( 1 ); | 35 | layout->setMargin( 1 ); |
36 | tabWindow = new QTabWidget( this, "tabWidget" ); | 36 | tabWindow = new QTabWidget( this, "tabWidget" ); |
37 | layout->addWidget( tabWindow ); | 37 | layout->addWidget( tabWindow ); |
38 | 38 | ||
39 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts" ); | 39 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts" ); |
40 | tabWindow->addTab( accounts, tr("&Accounts") ); | 40 | tabWindow->addTab( accounts, tr("&Accounts") ); |
41 | modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | 41 | modem1 = new ModemWidget( interface, tabWindow, "modem1" ); |
42 | tabWindow->addTab( modem1, tr("&Device") ); | 42 | tabWindow->addTab( modem1, tr("&Device") ); |
43 | modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | 43 | modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); |
44 | tabWindow->addTab( modem2, tr("&Modem") ); | 44 | tabWindow->addTab( modem2, tr("&Modem") ); |
45 | // graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); | ||
46 | // general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); | ||
47 | 45 | ||
48 | } | 46 | } |
49 | 47 | ||
50 | 48 | ||
51 | PPPConfigWidget::~PPPConfigWidget() | 49 | PPPConfigWidget::~PPPConfigWidget() |
52 | { | 50 | { |
53 | 51 | ||
54 | } | 52 | } |
55 | 53 | ||
56 | void PPPConfigWidget::accept() | 54 | void PPPConfigWidget::accept() |
57 | { | 55 | { |
58 | qDebug("PPPConfigWidget::accept"); | 56 | qDebug("PPPConfigWidget::accept"); |
59 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 57 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
60 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 58 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
61 | interface->setInterfaceName( interface->data()->modemDevice() ); | 59 | interface->setInterfaceName( interface->data()->modemDevice() ); |
62 | interface->setHardwareName( interface->data()->accname() ); | 60 | interface->setHardwareName( interface->data()->accname() ); |
63 | interface->data()->save(); | 61 | interface->save(); |
64 | QDialog::accept(); | 62 | QDialog::accept(); |
65 | } | 63 | } |
66 | 64 | ||
67 | 65 | ||
68 | void PPPConfigWidget::reject() | 66 | void PPPConfigWidget::reject() |
69 | { | 67 | { |
70 | interface->data()->cancel(); | 68 | interface->data()->cancel(); |
71 | QDialog::reject(); | 69 | QDialog::reject(); |
72 | } | 70 | } |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 23db409..8f066ff 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -1,1298 +1,1302 @@ | |||
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 | ||
41 | #define SEPARATOR -sseepp- | 41 | #define SEPARATOR -sseepp- |
42 | #define SEP QString("%1SEPARATOR%1") | 42 | #define SEP QString("%1SEPARATOR%1") |
43 | 43 | ||
44 | PPPData::PPPData() | 44 | PPPData::PPPData() |
45 | : modemDeviceGroup(-1), | 45 | : modemDeviceGroup(-1), |
46 | highcount(-1), // start out with no entries | 46 | passwd(""), |
47 | caccount(-1), // set the current account index also | 47 | highcount(-1), // start out with no entries |
48 | suidprocessid(-1), // process ID of setuid child | 48 | caccount(-1), // set the current account index also |
49 | pppdisrunning(false), | 49 | suidprocessid(-1), // process ID of setuid child |
50 | pppderror(0) | 50 | pppdisrunning(false), |
51 | pppderror(0) | ||
51 | { | 52 | { |
52 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
53 | 54 | ||
54 | if (highcount > MAX_ACCOUNTS) | 55 | if (highcount > MAX_ACCOUNTS) |
55 | highcount = MAX_ACCOUNTS; | 56 | highcount = MAX_ACCOUNTS; |
56 | 57 | ||
57 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 58 | if(highcount >= 0 && defaultAccount().isEmpty()) { |
58 | setAccountbyIndex(0); | 59 | setAccountbyIndex(0); |
59 | setDefaultAccount(accname()); | 60 | setDefaultAccount(accname()); |
60 | } else if(!setAccount(defaultAccount())) | 61 | } else if(!setAccount(defaultAccount())) |
61 | setDefaultAccount(accname()); | 62 | setDefaultAccount(accname()); |
62 | 63 | ||
63 | // start out with internal debugging disabled | 64 | // start out with internal debugging disabled |
64 | // the user is still free to specify `debug' on his own | 65 | // the user is still free to specify `debug' on his own |
65 | setPPPDebug(false); | 66 | setPPPDebug(false); |
66 | 67 | ||
67 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 68 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
68 | 69 | ||
69 | } | 70 | } |
70 | 71 | ||
71 | Config PPPData::config() | 72 | Config PPPData::config() |
72 | { | 73 | { |
73 | return Config("NetworkSetupPPP"); | 74 | return Config("NetworkSetupPPP"); |
74 | } | 75 | } |
75 | 76 | ||
76 | // | 77 | // |
77 | // save configuration | 78 | // save configuration |
78 | // | 79 | // |
79 | void PPPData::save() | 80 | void PPPData::save() |
80 | { | 81 | { |
81 | qDebug("PPPData saving data"); | 82 | qDebug("PPPData saving data"); |
82 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 83 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
83 | QString key; | 84 | QString key; |
84 | QStringList keys; | 85 | QStringList keys; |
85 | Config cfg = config(); | 86 | Config cfg = config(); |
86 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 87 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
87 | it != stringEntries.end(); ++it ){ | 88 | it != stringEntries.end(); ++it ){ |
88 | QString val = it.data(); | 89 | QString val = it.data(); |
89 | key = it.key(); | 90 | key = it.key(); |
90 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 91 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
91 | keys = QStringList::split( "SEPARATOR", key ); | 92 | keys = QStringList::split( "SEPARATOR", key ); |
92 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 93 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); |
93 | cfg.setGroup(keys[0]); | 94 | cfg.setGroup(keys[0]); |
94 | cfg.writeEntry(keys[1], val); | 95 | cfg.writeEntry(keys[1], val); |
95 | } | 96 | } |
96 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 97 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
97 | it != intEntries.end(); ++it ){ | 98 | it != intEntries.end(); ++it ){ |
98 | int val = it.data(); | 99 | int val = it.data(); |
99 | key = it.key(); | 100 | key = it.key(); |
100 | // qDebug("saving %s -> %i", key.latin1(), val ); | 101 | // qDebug("saving %s -> %i", key.latin1(), val ); |
101 | keys = QStringList::split( "SEPARATOR", key ); | 102 | keys = QStringList::split( "SEPARATOR", key ); |
102 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 103 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); |
103 | cfg.setGroup(keys[0]); | 104 | cfg.setGroup(keys[0]); |
104 | cfg.writeEntry(keys[1], val); | 105 | cfg.writeEntry(keys[1], val); |
105 | } | 106 | } |
106 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 107 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
107 | it != listEntries.end(); ++it ){ | 108 | it != listEntries.end(); ++it ){ |
108 | QStringList val = it.data(); | 109 | QStringList val = it.data(); |
109 | key = it.key(); | 110 | key = it.key(); |
110 | QChar sep = sepEntries[key]; | 111 | QChar sep = sepEntries[key]; |
111 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 112 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); |
112 | keys = QStringList::split( "SEPARATOR", key ); | 113 | keys = QStringList::split( "SEPARATOR", key ); |
113 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | 114 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); |
114 | cfg.setGroup(keys[0]); | 115 | cfg.setGroup(keys[0]); |
115 | cfg.writeEntry(keys[1], val, sep); | 116 | cfg.writeEntry(keys[1], val, sep); |
116 | } | 117 | } |
117 | } | 118 | } |
118 | 119 | ||
119 | 120 | ||
120 | // | 121 | // |
121 | // cancel changes | 122 | // cancel changes |
122 | // | 123 | // |
123 | void PPPData::cancel() { | 124 | void PPPData::cancel() { |
124 | stringEntries.clear(); | 125 | stringEntries.clear(); |
125 | intEntries.clear(); | 126 | intEntries.clear(); |
126 | listEntries.clear(); | 127 | listEntries.clear(); |
127 | } | 128 | } |
128 | 129 | ||
129 | // functions to read/write date to configuration file | 130 | // functions to read/write date to configuration file |
130 | QString PPPData::readConfig(const QString &group, const QString &key, | 131 | QString PPPData::readConfig(const QString &group, const QString &key, |
131 | const QString &defvalue = "") | 132 | const QString &defvalue = "") |
132 | { | 133 | { |
133 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 134 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
134 | QString idx = SEP.arg(group).arg(key); | 135 | QString idx = SEP.arg(group).arg(key); |
135 | if (stringEntries.find(idx) != stringEntries.end()) | 136 | if (stringEntries.find(idx) != stringEntries.end()) |
136 | return stringEntries[idx]; | 137 | return stringEntries[idx]; |
137 | Config cfg = config(); | 138 | Config cfg = config(); |
138 | cfg.setGroup(group); | 139 | cfg.setGroup(group); |
139 | return cfg.readEntry(key, defvalue); | 140 | return cfg.readEntry(key, defvalue); |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | int PPPData::readNumConfig(const QString &group, const QString &key, | 144 | int PPPData::readNumConfig(const QString &group, const QString &key, |
144 | int defvalue) | 145 | int defvalue) |
145 | { | 146 | { |
146 | QString idx = SEP.arg(group).arg(key); | 147 | QString idx = SEP.arg(group).arg(key); |
147 | if (intEntries.find(idx) != intEntries.end()) | 148 | if (intEntries.find(idx) != intEntries.end()) |
148 | return intEntries[idx]; | 149 | return intEntries[idx]; |
149 | Config cfg = config(); | 150 | Config cfg = config(); |
150 | cfg.setGroup(group); | 151 | cfg.setGroup(group); |
151 | return cfg.readNumEntry(key, defvalue); | 152 | return cfg.readNumEntry(key, defvalue); |
152 | 153 | ||
153 | // if (config) { | 154 | // if (config) { |
154 | // config->setGroup(group); | 155 | // config->setGroup(group); |
155 | // return config->readNumEntry(key, defvalue); | 156 | // return config->readNumEntry(key, defvalue); |
156 | // } else | 157 | // } else |
157 | // return defvalue; | 158 | // return defvalue; |
158 | 159 | ||
159 | } | 160 | } |
160 | 161 | ||
161 | 162 | ||
162 | bool PPPData::readListConfig(const QString &group, const QString &key, | 163 | bool PPPData::readListConfig(const QString &group, const QString &key, |
163 | QStringList &list, char sep) { | 164 | QStringList &list, char sep) { |
164 | list.clear(); | 165 | list.clear(); |
165 | QString idx = SEP.arg(group).arg(key); | 166 | QString idx = SEP.arg(group).arg(key); |
166 | if (listEntries.find(idx) != listEntries.end()){ | 167 | if (listEntries.find(idx) != listEntries.end()){ |
167 | list = listEntries[idx]; | 168 | list = listEntries[idx]; |
168 | return true; | 169 | return true; |
169 | } | 170 | } |
170 | Config cfg = config(); | 171 | Config cfg = config(); |
171 | cfg.setGroup(group); | 172 | cfg.setGroup(group); |
172 | list = cfg.readListEntry(key, sep); | 173 | list = cfg.readListEntry(key, sep); |
173 | if (list.count() > 0) return true; | 174 | if (list.count() > 0) return true; |
174 | return false; | 175 | return false; |
175 | 176 | ||
176 | // if (config) { | 177 | // if (config) { |
177 | // config->setGroup(group); | 178 | // config->setGroup(group); |
178 | // list = config->readListEntry(key, sep); | 179 | // list = config->readListEntry(key, sep); |
179 | // return true; | 180 | // return true; |
180 | // } else | 181 | // } else |
181 | // return false; | 182 | // return false; |
182 | } | 183 | } |
183 | 184 | ||
184 | 185 | ||
185 | void PPPData::writeConfig(const QString &group, const QString &key, | 186 | void PPPData::writeConfig(const QString &group, const QString &key, |
186 | const QString &value) { | 187 | const QString &value) { |
187 | stringEntries.insert( SEP.arg(group).arg(key), value ); | 188 | stringEntries.insert( SEP.arg(group).arg(key), value ); |
188 | // if (config) { | 189 | // if (config) { |
189 | // config->setGroup(group); | 190 | // config->setGroup(group); |
190 | // config->writeEntry(key, value); | 191 | // config->writeEntry(key, value); |
191 | // } | 192 | // } |
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||
195 | void PPPData::writeConfig(const QString &group, const QString &key, int value) | 196 | void PPPData::writeConfig(const QString &group, const QString &key, int value) |
196 | { | 197 | { |
197 | intEntries.insert( SEP.arg(group).arg(key), value ); | 198 | intEntries.insert( SEP.arg(group).arg(key), value ); |
198 | // if (config) { | 199 | // if (config) { |
199 | // config->setGroup(group); | 200 | // config->setGroup(group); |
200 | // config->writeEntry(key, value); | 201 | // config->writeEntry(key, value); |
201 | // } | 202 | // } |
202 | } | 203 | } |
203 | 204 | ||
204 | 205 | ||
205 | void PPPData::writeListConfig(const QString &group, const QString &key, | 206 | void PPPData::writeListConfig(const QString &group, const QString &key, |
206 | QStringList &list, char sep) | 207 | QStringList &list, char sep) |
207 | { | 208 | { |
208 | listEntries.insert( SEP.arg(group).arg(key), list ); | 209 | listEntries.insert( SEP.arg(group).arg(key), list ); |
209 | sepEntries.insert( SEP.arg(group).arg(key), sep ); | 210 | sepEntries.insert( SEP.arg(group).arg(key), sep ); |
210 | // if (config) { | 211 | // if (config) { |
211 | // config->setGroup(group); | 212 | // config->setGroup(group); |
212 | // config->writeEntry(key, list, sep); | 213 | // config->writeEntry(key, list, sep); |
213 | // } | 214 | // } |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | // | 218 | // |
218 | // functions to set/return general information | 219 | // functions to set/return general information |
219 | // | 220 | // |
220 | QString PPPData::password() const { | 221 | QString PPPData::password(){ |
221 | return passwd; | 222 | if ( storePassword() ) return storedPassword(); |
223 | else return passwd; | ||
222 | } | 224 | } |
223 | 225 | ||
224 | 226 | ||
225 | void PPPData::setPassword(const QString &pw) { | 227 | void PPPData::setPassword(const QString &pw) { |
226 | passwd = pw; | 228 | passwd = pw; |
227 | } | 229 | } |
228 | 230 | ||
229 | 231 | ||
230 | const QString PPPData::defaultAccount() { | 232 | const QString PPPData::defaultAccount() { |
231 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | 233 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); |
232 | } | 234 | } |
233 | 235 | ||
234 | 236 | ||
235 | void PPPData::setDefaultAccount(const QString &n) { | 237 | void PPPData::setDefaultAccount(const QString &n) { |
236 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | 238 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); |
237 | 239 | ||
238 | //now set the current account index to the default account | 240 | //now set the current account index to the default account |
239 | setAccount(defaultAccount()); | 241 | setAccount(defaultAccount()); |
240 | } | 242 | } |
241 | 243 | ||
242 | 244 | ||
243 | bool PPPData::get_show_clock_on_caption() { | 245 | bool PPPData::get_show_clock_on_caption() { |
244 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | 246 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); |
245 | } | 247 | } |
246 | 248 | ||
247 | 249 | ||
248 | void PPPData::set_show_clock_on_caption(bool set) { | 250 | void PPPData::set_show_clock_on_caption(bool set) { |
249 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 251 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
250 | } | 252 | } |
251 | 253 | ||
252 | 254 | ||
253 | bool PPPData::get_xserver_exit_disconnect() { | 255 | bool PPPData::get_xserver_exit_disconnect() { |
254 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 256 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
255 | } | 257 | } |
256 | 258 | ||
257 | 259 | ||
258 | void PPPData::setPPPDebug(bool set) { | 260 | void PPPData::setPPPDebug(bool set) { |
259 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 261 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | bool PPPData::getPPPDebug() { | 265 | bool PPPData::getPPPDebug() { |
264 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 266 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
265 | } | 267 | } |
266 | 268 | ||
267 | 269 | ||
268 | void PPPData::set_xserver_exit_disconnect(bool set) { | 270 | void PPPData::set_xserver_exit_disconnect(bool set) { |
269 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 271 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
270 | } | 272 | } |
271 | 273 | ||
272 | 274 | ||
273 | bool PPPData::quit_on_disconnect() { | 275 | bool PPPData::quit_on_disconnect() { |
274 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 276 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
275 | } | 277 | } |
276 | 278 | ||
277 | 279 | ||
278 | void PPPData::set_quit_on_disconnect(bool set) { | 280 | void PPPData::set_quit_on_disconnect(bool set) { |
279 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 281 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
280 | } | 282 | } |
281 | 283 | ||
282 | 284 | ||
283 | bool PPPData::get_show_log_window() { | 285 | bool PPPData::get_show_log_window() { |
284 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 286 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | void PPPData::set_show_log_window(bool set) { | 290 | void PPPData::set_show_log_window(bool set) { |
289 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 291 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
290 | } | 292 | } |
291 | 293 | ||
292 | 294 | ||
293 | bool PPPData::automatic_redial() { | 295 | bool PPPData::automatic_redial() { |
294 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 296 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
295 | } | 297 | } |
296 | 298 | ||
297 | 299 | ||
298 | void PPPData::set_automatic_redial(bool set) { | 300 | void PPPData::set_automatic_redial(bool set) { |
299 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 301 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
300 | } | 302 | } |
301 | 303 | ||
302 | 304 | ||
303 | // bool PPPData::get_iconify_on_connect() { | 305 | // bool PPPData::get_iconify_on_connect() { |
304 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 306 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
305 | // } | 307 | // } |
306 | 308 | ||
307 | 309 | ||
308 | // void PPPData::set_iconify_on_connect(bool set) { | 310 | // void PPPData::set_iconify_on_connect(bool set) { |
309 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 311 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
310 | // } | 312 | // } |
311 | 313 | ||
312 | 314 | ||
313 | // bool PPPData::get_dock_into_panel() { | 315 | // bool PPPData::get_dock_into_panel() { |
314 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 316 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
315 | // } | 317 | // } |
316 | 318 | ||
317 | 319 | ||
318 | // void PPPData::set_dock_into_panel(bool set) { | 320 | // void PPPData::set_dock_into_panel(bool set) { |
319 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 321 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
320 | // } | 322 | // } |
321 | 323 | ||
322 | 324 | ||
323 | QString PPPData::pppdVersion() { | 325 | QString PPPData::pppdVersion() { |
324 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 326 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
325 | } | 327 | } |
326 | 328 | ||
327 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 329 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
328 | // check if pppd version fulfills minimum requirement | 330 | // check if pppd version fulfills minimum requirement |
329 | return (pppdVer > ver | 331 | return (pppdVer > ver |
330 | || (pppdVer == ver && pppdMod > mod) | 332 | || (pppdVer == ver && pppdMod > mod) |
331 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 333 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
332 | } | 334 | } |
333 | 335 | ||
334 | int PPPData::pppdTimeout() { | 336 | int PPPData::pppdTimeout() { |
335 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 337 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
336 | } | 338 | } |
337 | 339 | ||
338 | 340 | ||
339 | void PPPData::setpppdTimeout(int n) { | 341 | void PPPData::setpppdTimeout(int n) { |
340 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 342 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
341 | } | 343 | } |
342 | 344 | ||
343 | 345 | ||
344 | const QString PPPData::modemDevice() { | 346 | const QString PPPData::modemDevice() { |
345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 347 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
346 | } | 348 | } |
347 | 349 | ||
348 | 350 | ||
349 | bool PPPData::setModemDevice(const QString &n) { | 351 | bool PPPData::setModemDevice(const QString &n) { |
350 | qDebug("Setting modem dev to >%s<", n.latin1()); | 352 | qDebug("Setting modem dev to >%s<", n.latin1()); |
351 | bool ret = false; | 353 | bool ret = false; |
352 | for (int i = 0; devices[i]; i++) | 354 | for (int i = 0; devices[i]; i++) |
353 | if (devices[i] == n){ | 355 | if (devices[i] == n){ |
354 | modemDeviceGroup = i; | 356 | modemDeviceGroup = i; |
355 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 357 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
356 | ret = true; | 358 | ret = true; |
357 | } | 359 | } |
358 | qDebug(ret?"SUCCESS":"FAILURE"); | 360 | qDebug(ret?"SUCCESS":"FAILURE"); |
359 | return ret; | 361 | return ret; |
360 | } | 362 | } |
361 | 363 | ||
362 | 364 | ||
363 | const QString PPPData::flowcontrol() { | 365 | const QString PPPData::flowcontrol() { |
364 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 366 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
365 | } | 367 | } |
366 | 368 | ||
367 | 369 | ||
368 | void PPPData::setFlowcontrol(const QString &n) { | 370 | void PPPData::setFlowcontrol(const QString &n) { |
369 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 371 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
370 | } | 372 | } |
371 | 373 | ||
372 | 374 | ||
373 | const QString PPPData::speed() { | 375 | const QString PPPData::speed() { |
374 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 376 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
375 | // undo the damage of a bug in former versions. It left an empty Speed= | 377 | // undo the damage of a bug in former versions. It left an empty Speed= |
376 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 378 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
377 | // pppd wouldn't receive the speed via the command line. | 379 | // pppd wouldn't receive the speed via the command line. |
378 | if(s.toUInt() == 0) | 380 | if(s.toUInt() == 0) |
379 | s = "57600"; | 381 | s = "57600"; |
380 | return s; | 382 | return s; |
381 | } | 383 | } |
382 | 384 | ||
383 | 385 | ||
384 | void PPPData::setSpeed(const QString &n) { | 386 | void PPPData::setSpeed(const QString &n) { |
385 | writeConfig(modemGroup(), SPEED_KEY, n); | 387 | writeConfig(modemGroup(), SPEED_KEY, n); |
386 | } | 388 | } |
387 | 389 | ||
388 | 390 | ||
389 | #if 0 | 391 | #if 0 |
390 | void PPPData::setUseCDLine(const int n) { | 392 | void PPPData::setUseCDLine(const int n) { |
391 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 393 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
392 | } | 394 | } |
393 | 395 | ||
394 | 396 | ||
395 | int PPPData::UseCDLine() { | 397 | int PPPData::UseCDLine() { |
396 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 398 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
397 | } | 399 | } |
398 | #endif | 400 | #endif |
399 | 401 | ||
400 | const QString PPPData::modemEscapeStr() { | 402 | const QString PPPData::modemEscapeStr() { |
401 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 403 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
402 | } | 404 | } |
403 | 405 | ||
404 | 406 | ||
405 | void PPPData::setModemEscapeStr(const QString &n) { | 407 | void PPPData::setModemEscapeStr(const QString &n) { |
406 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 408 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
407 | } | 409 | } |
408 | 410 | ||
409 | 411 | ||
410 | const QString PPPData::modemEscapeResp() { | 412 | const QString PPPData::modemEscapeResp() { |
411 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 413 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
412 | } | 414 | } |
413 | 415 | ||
414 | 416 | ||
415 | void PPPData::setModemEscapeResp(const QString &n) { | 417 | void PPPData::setModemEscapeResp(const QString &n) { |
416 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 418 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
417 | } | 419 | } |
418 | 420 | ||
419 | 421 | ||
420 | int PPPData::modemEscapeGuardTime() { | 422 | int PPPData::modemEscapeGuardTime() { |
421 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 423 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
422 | } | 424 | } |
423 | 425 | ||
424 | 426 | ||
425 | void PPPData::setModemEscapeGuardTime(int n) { | 427 | void PPPData::setModemEscapeGuardTime(int n) { |
426 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 428 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
427 | } | 429 | } |
428 | 430 | ||
429 | 431 | ||
430 | bool PPPData::modemLockFile() { | 432 | bool PPPData::modemLockFile() { |
431 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 433 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
432 | } | 434 | } |
433 | 435 | ||
434 | 436 | ||
435 | void PPPData::setModemLockFile(bool set) { | 437 | void PPPData::setModemLockFile(bool set) { |
436 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 438 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
437 | } | 439 | } |
438 | 440 | ||
439 | 441 | ||
440 | int PPPData::modemTimeout() { | 442 | int PPPData::modemTimeout() { |
441 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 443 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
442 | } | 444 | } |
443 | 445 | ||
444 | 446 | ||
445 | void PPPData::setModemTimeout(int n) { | 447 | void PPPData::setModemTimeout(int n) { |
446 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 448 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
447 | } | 449 | } |
448 | 450 | ||
449 | 451 | ||
450 | int PPPData::modemToneDuration() { | 452 | int PPPData::modemToneDuration() { |
451 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 453 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
452 | } | 454 | } |
453 | 455 | ||
454 | 456 | ||
455 | void PPPData::setModemToneDuration(int n) { | 457 | void PPPData::setModemToneDuration(int n) { |
456 | writeConfig(modemGroup(), TONEDURATION_KEY, n); | 458 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
457 | } | 459 | } |
458 | 460 | ||
459 | 461 | ||
460 | int PPPData::busyWait() { | 462 | int PPPData::busyWait() { |
461 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); | 463 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
462 | } | 464 | } |
463 | 465 | ||
464 | 466 | ||
465 | void PPPData::setbusyWait(int n) { | 467 | void PPPData::setbusyWait(int n) { |
466 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); | 468 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); |
467 | } | 469 | } |
468 | 470 | ||
469 | 471 | ||
470 | // | 472 | // |
471 | //Advanced "Modem" dialog | 473 | //Advanced "Modem" dialog |
472 | // | 474 | // |
473 | // defaults: InitString=ATZ, InitString1="" etc. | 475 | // defaults: InitString=ATZ, InitString1="" etc. |
474 | const QString PPPData::modemInitStr(int i) { | 476 | const QString PPPData::modemInitStr(int i) { |
475 | assert(i >= 0 && i < NumInitStrings); | 477 | assert(i >= 0 && i < NumInitStrings); |
476 | if(i == 0) | 478 | if(i == 0) |
477 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); | 479 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); |
478 | else | 480 | else |
479 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); | 481 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); |
480 | } | 482 | } |
481 | 483 | ||
482 | 484 | ||
483 | void PPPData::setModemInitStr(int i, const QString &n) { | 485 | void PPPData::setModemInitStr(int i, const QString &n) { |
484 | assert(i >= 0 && i < NumInitStrings); | 486 | assert(i >= 0 && i < NumInitStrings); |
485 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | 487 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); |
486 | writeConfig(modemGroup(), k, n); | 488 | writeConfig(modemGroup(), k, n); |
487 | } | 489 | } |
488 | 490 | ||
489 | 491 | ||
490 | const QString PPPData::modemInitResp() { | 492 | const QString PPPData::modemInitResp() { |
491 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); | 493 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); |
492 | } | 494 | } |
493 | 495 | ||
494 | 496 | ||
495 | void PPPData::setModemInitResp(const QString &n) { | 497 | void PPPData::setModemInitResp(const QString &n) { |
496 | writeConfig(modemGroup(), INITRESP_KEY, n); | 498 | writeConfig(modemGroup(), INITRESP_KEY, n); |
497 | } | 499 | } |
498 | 500 | ||
499 | 501 | ||
500 | int PPPData::modemPreInitDelay() { | 502 | int PPPData::modemPreInitDelay() { |
501 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); | 503 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); |
502 | } | 504 | } |
503 | 505 | ||
504 | 506 | ||
505 | void PPPData::setModemPreInitDelay(int n) { | 507 | void PPPData::setModemPreInitDelay(int n) { |
506 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); | 508 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); |
507 | } | 509 | } |
508 | 510 | ||
509 | 511 | ||
510 | int PPPData::modemInitDelay() { | 512 | int PPPData::modemInitDelay() { |
511 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); | 513 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); |
512 | } | 514 | } |
513 | 515 | ||
514 | 516 | ||
515 | void PPPData::setModemInitDelay(int n) { | 517 | void PPPData::setModemInitDelay(int n) { |
516 | writeConfig(modemGroup(), INITDELAY_KEY, n); | 518 | writeConfig(modemGroup(), INITDELAY_KEY, n); |
517 | } | 519 | } |
518 | 520 | ||
519 | QString PPPData::modemNoDialToneDetectionStr() { | 521 | QString PPPData::modemNoDialToneDetectionStr() { |
520 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); | 522 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); |
521 | } | 523 | } |
522 | 524 | ||
523 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | 525 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { |
524 | writeConfig(modemGroup(), NODTDETECT_KEY, n); | 526 | writeConfig(modemGroup(), NODTDETECT_KEY, n); |
525 | } | 527 | } |
526 | 528 | ||
527 | const QString PPPData::modemDialStr() { | 529 | const QString PPPData::modemDialStr() { |
528 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); | 530 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); |
529 | } | 531 | } |
530 | 532 | ||
531 | 533 | ||
532 | void PPPData::setModemDialStr(const QString &n) { | 534 | void PPPData::setModemDialStr(const QString &n) { |
533 | writeConfig(modemGroup(), DIALSTR_KEY, n); | 535 | writeConfig(modemGroup(), DIALSTR_KEY, n); |
534 | } | 536 | } |
535 | 537 | ||
536 | 538 | ||
537 | const QString PPPData::modemConnectResp() { | 539 | const QString PPPData::modemConnectResp() { |
538 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); | 540 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); |
539 | } | 541 | } |
540 | 542 | ||
541 | 543 | ||
542 | void PPPData::setModemConnectResp(const QString &n) { | 544 | void PPPData::setModemConnectResp(const QString &n) { |
543 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); | 545 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); |
544 | } | 546 | } |
545 | 547 | ||
546 | 548 | ||
547 | const QString PPPData::modemBusyResp() { | 549 | const QString PPPData::modemBusyResp() { |
548 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); | 550 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); |
549 | } | 551 | } |
550 | 552 | ||
551 | 553 | ||
552 | void PPPData::setModemBusyResp(const QString &n) { | 554 | void PPPData::setModemBusyResp(const QString &n) { |
553 | writeConfig(modemGroup(), BUSYRESP_KEY, n); | 555 | writeConfig(modemGroup(), BUSYRESP_KEY, n); |
554 | } | 556 | } |
555 | 557 | ||
556 | 558 | ||
557 | const QString PPPData::modemNoCarrierResp() { | 559 | const QString PPPData::modemNoCarrierResp() { |
558 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); | 560 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); |
559 | } | 561 | } |
560 | 562 | ||
561 | 563 | ||
562 | void PPPData::setModemNoCarrierResp(const QString &n) { | 564 | void PPPData::setModemNoCarrierResp(const QString &n) { |
563 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); | 565 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); |
564 | } | 566 | } |
565 | 567 | ||
566 | 568 | ||
567 | const QString PPPData::modemNoDialtoneResp() { | 569 | const QString PPPData::modemNoDialtoneResp() { |
568 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); | 570 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); |
569 | } | 571 | } |
570 | 572 | ||
571 | 573 | ||
572 | void PPPData::setModemNoDialtoneResp(const QString &n) { | 574 | void PPPData::setModemNoDialtoneResp(const QString &n) { |
573 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); | 575 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); |
574 | } | 576 | } |
575 | 577 | ||
576 | 578 | ||
577 | const QString PPPData::modemHangupStr() { | 579 | const QString PPPData::modemHangupStr() { |
578 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); | 580 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); |
579 | } | 581 | } |
580 | 582 | ||
581 | void PPPData::setModemHangupStr(const QString &n) { | 583 | void PPPData::setModemHangupStr(const QString &n) { |
582 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); | 584 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); |
583 | } | 585 | } |
584 | 586 | ||
585 | 587 | ||
586 | const QString PPPData::modemHangupResp() { | 588 | const QString PPPData::modemHangupResp() { |
587 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); | 589 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); |
588 | } | 590 | } |
589 | 591 | ||
590 | void PPPData::setModemHangupResp(const QString &n) { | 592 | void PPPData::setModemHangupResp(const QString &n) { |
591 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); | 593 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); |
592 | } | 594 | } |
593 | 595 | ||
594 | 596 | ||
595 | const QString PPPData::modemAnswerStr() { | 597 | const QString PPPData::modemAnswerStr() { |
596 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); | 598 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); |
597 | } | 599 | } |
598 | 600 | ||
599 | 601 | ||
600 | QString PPPData::volumeOff() { | 602 | QString PPPData::volumeOff() { |
601 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); | 603 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
602 | } | 604 | } |
603 | 605 | ||
604 | 606 | ||
605 | void PPPData::setVolumeOff(const QString &s) { | 607 | void PPPData::setVolumeOff(const QString &s) { |
606 | writeConfig(modemGroup(), VOLUME_OFF, s); | 608 | writeConfig(modemGroup(), VOLUME_OFF, s); |
607 | } | 609 | } |
608 | 610 | ||
609 | 611 | ||
610 | QString PPPData::volumeMedium() { | 612 | QString PPPData::volumeMedium() { |
611 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); | 613 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
612 | } | 614 | } |
613 | 615 | ||
614 | 616 | ||
615 | void PPPData::setVolumeMedium(const QString &s) { | 617 | void PPPData::setVolumeMedium(const QString &s) { |
616 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); | 618 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
617 | } | 619 | } |
618 | 620 | ||
619 | 621 | ||
620 | QString PPPData::volumeHigh() { | 622 | QString PPPData::volumeHigh() { |
621 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); | 623 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
622 | if(tmp == "M1L4") | 624 | if(tmp == "M1L4") |
623 | tmp = "M1L3"; | 625 | tmp = "M1L3"; |
624 | return tmp; | 626 | return tmp; |
625 | } | 627 | } |
626 | 628 | ||
627 | 629 | ||
628 | void PPPData::setVolumeHigh(const QString &s) { | 630 | void PPPData::setVolumeHigh(const QString &s) { |
629 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 631 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
630 | } | 632 | } |
631 | 633 | ||
632 | 634 | ||
633 | QString PPPData::volumeInitString() { | 635 | QString PPPData::volumeInitString() { |
634 | QString s; | 636 | QString s; |
635 | 637 | ||
636 | switch(volume()) { | 638 | switch(volume()) { |
637 | case 0: | 639 | case 0: |
638 | s = volumeOff(); | 640 | s = volumeOff(); |
639 | break; | 641 | break; |
640 | case 1: | 642 | case 1: |
641 | s = volumeMedium(); | 643 | s = volumeMedium(); |
642 | break; | 644 | break; |
643 | case 2: | 645 | case 2: |
644 | s = volumeHigh(); | 646 | s = volumeHigh(); |
645 | break; | 647 | break; |
646 | default: | 648 | default: |
647 | s = volumeMedium(); | 649 | s = volumeMedium(); |
648 | } | 650 | } |
649 | 651 | ||
650 | return s; | 652 | return s; |
651 | } | 653 | } |
652 | 654 | ||
653 | 655 | ||
654 | int PPPData::volume() { | 656 | int PPPData::volume() { |
655 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 657 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
656 | } | 658 | } |
657 | 659 | ||
658 | 660 | ||
659 | void PPPData::setVolume(int i) { | 661 | void PPPData::setVolume(int i) { |
660 | writeConfig(modemGroup(), VOLUME_KEY, i); | 662 | writeConfig(modemGroup(), VOLUME_KEY, i); |
661 | } | 663 | } |
662 | 664 | ||
663 | int PPPData::waitForDialTone() { | 665 | int PPPData::waitForDialTone() { |
664 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 666 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
665 | } | 667 | } |
666 | 668 | ||
667 | void PPPData::setWaitForDialTone(int i) { | 669 | void PPPData::setWaitForDialTone(int i) { |
668 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 670 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
669 | } | 671 | } |
670 | 672 | ||
671 | void PPPData::setModemAnswerStr(const QString &n) { | 673 | void PPPData::setModemAnswerStr(const QString &n) { |
672 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 674 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
673 | } | 675 | } |
674 | 676 | ||
675 | 677 | ||
676 | const QString PPPData::modemRingResp() { | 678 | const QString PPPData::modemRingResp() { |
677 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 679 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
678 | } | 680 | } |
679 | 681 | ||
680 | 682 | ||
681 | void PPPData::setModemRingResp(const QString &n) { | 683 | void PPPData::setModemRingResp(const QString &n) { |
682 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 684 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
683 | } | 685 | } |
684 | 686 | ||
685 | 687 | ||
686 | const QString PPPData::modemAnswerResp() { | 688 | const QString PPPData::modemAnswerResp() { |
687 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 689 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
688 | } | 690 | } |
689 | 691 | ||
690 | 692 | ||
691 | void PPPData::setModemAnswerResp(const QString &n) { | 693 | void PPPData::setModemAnswerResp(const QString &n) { |
692 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 694 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
693 | } | 695 | } |
694 | 696 | ||
695 | 697 | ||
696 | const QString PPPData::enter() { | 698 | const QString PPPData::enter() { |
697 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 699 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
698 | } | 700 | } |
699 | 701 | ||
700 | 702 | ||
701 | void PPPData::setEnter(const QString &n) { | 703 | void PPPData::setEnter(const QString &n) { |
702 | writeConfig(modemGroup(), ENTER_KEY, n); | 704 | writeConfig(modemGroup(), ENTER_KEY, n); |
703 | } | 705 | } |
704 | 706 | ||
705 | 707 | ||
706 | // | 708 | // |
707 | // functions to set/return account information | 709 | // functions to set/return account information |
708 | // | 710 | // |
709 | 711 | ||
710 | //returns number of accounts | 712 | //returns number of accounts |
711 | int PPPData::count() const { | 713 | int PPPData::count() const { |
712 | return highcount + 1; | 714 | return highcount + 1; |
713 | } | 715 | } |
714 | 716 | ||
715 | 717 | ||
716 | bool PPPData::setAccount(const QString &aname) { | 718 | bool PPPData::setAccount(const QString &aname) { |
717 | qDebug("setting account to >%s<", aname.latin1()); | 719 | qDebug("setting account to >%s<", aname.latin1()); |
718 | for(int i = 0; i <= highcount; i++) { | 720 | for(int i = 0; i <= highcount; i++) { |
719 | setAccountbyIndex(i); | 721 | setAccountbyIndex(i); |
720 | if(accname() == aname) { | 722 | if(accname() == aname) { |
721 | caccount = i; | 723 | caccount = i; |
722 | qDebug("SUCCESS"); | 724 | qDebug("SUCCESS"); |
723 | return true; | 725 | return true; |
724 | } | 726 | } |
725 | } | 727 | } |
726 | qDebug("FAILURE"); | 728 | qDebug("FAILURE"); |
727 | return false; | 729 | return false; |
728 | } | 730 | } |
729 | 731 | ||
730 | 732 | ||
731 | bool PPPData::setAccountbyIndex(int i) { | 733 | bool PPPData::setAccountbyIndex(int i) { |
732 | if(i >= 0 && i <= highcount) { | 734 | if(i >= 0 && i <= highcount) { |
733 | caccount = i; | 735 | caccount = i; |
734 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 736 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
735 | return true; | 737 | return true; |
736 | } | 738 | } |
737 | return false; | 739 | return false; |
738 | } | 740 | } |
739 | 741 | ||
740 | 742 | ||
741 | bool PPPData::isUniqueAccname(const QString &n) { | 743 | bool PPPData::isUniqueAccname(const QString &n) { |
742 | int current = caccount; | 744 | int current = caccount; |
743 | for(int i=0; i <= highcount; i++) { | 745 | for(int i=0; i <= highcount; i++) { |
744 | setAccountbyIndex(i); | 746 | setAccountbyIndex(i); |
745 | if(accname() == n && i != current) { | 747 | if(accname() == n && i != current) { |
746 | setAccountbyIndex(current); | 748 | setAccountbyIndex(current); |
747 | return false; | 749 | return false; |
748 | } | 750 | } |
749 | } | 751 | } |
750 | setAccountbyIndex(current); | 752 | setAccountbyIndex(current); |
751 | return true; | 753 | return true; |
752 | } | 754 | } |
753 | 755 | ||
754 | 756 | ||
755 | bool PPPData::deleteAccount() { | 757 | bool PPPData::deleteAccount() { |
756 | //FIXME: | 758 | //FIXME: PPPData::deleteAccount |
757 | // if(caccount < 0) | 759 | // if(caccount < 0) |
758 | return false; | 760 | return false; |
759 | 761 | ||
760 | // QMap <QString, QString> map; | 762 | // QMap <QString, QString> map; |
761 | // QMap <QString, QString>::Iterator it; | 763 | // QMap <QString, QString>::Iterator it; |
762 | 764 | ||
763 | // // set all entries of the current account to "" | 765 | // // set all entries of the current account to "" |
764 | // map = config->entryMap(cgroup); | 766 | // map = config->entryMap(cgroup); |
765 | // it = map.begin(); | 767 | // it = map.begin(); |
766 | // while (it != map.end()) { | 768 | // while (it != map.end()) { |
767 | // config->writeEntry(it.key(), ""); | 769 | // config->writeEntry(it.key(), ""); |
768 | // it++; | 770 | // it++; |
769 | // } | 771 | // } |
770 | 772 | ||
771 | // // shift the succeeding accounts | 773 | // // shift the succeeding accounts |
772 | // for(int i = caccount+1; i <= highcount; i++) { | 774 | // for(int i = caccount+1; i <= highcount; i++) { |
773 | // setAccountbyIndex(i); | 775 | // setAccountbyIndex(i); |
774 | // map = config->entryMap(cgroup); | 776 | // map = config->entryMap(cgroup); |
775 | // it = map.begin(); | 777 | // it = map.begin(); |
776 | // setAccountbyIndex(i-1); | 778 | // setAccountbyIndex(i-1); |
777 | // config->setGroup(cgroup); | 779 | // config->setGroup(cgroup); |
778 | // while (it != map.end()) { | 780 | // while (it != map.end()) { |
779 | // config->writeEntry(it.key(), *it); | 781 | // config->writeEntry(it.key(), *it); |
780 | // it++; | 782 | // it++; |
781 | // } | 783 | // } |
782 | // } | 784 | // } |
783 | 785 | ||
784 | // // make sure the top account is cleared | 786 | // // make sure the top account is cleared |
785 | // setAccountbyIndex(highcount); | 787 | // setAccountbyIndex(highcount); |
786 | // map = config->entryMap(cgroup); | 788 | // map = config->entryMap(cgroup); |
787 | // it = map.begin(); | 789 | // it = map.begin(); |
788 | // config->setGroup(cgroup); | 790 | // config->setGroup(cgroup); |
789 | // while (it.key() != QString::null) { | 791 | // while (it.key() != QString::null) { |
790 | // config->writeEntry(it.key(), ""); | 792 | // config->writeEntry(it.key(), ""); |
791 | // it++; | 793 | // it++; |
792 | // } | 794 | // } |
793 | 795 | ||
794 | // highcount--; | 796 | // highcount--; |
795 | // if(caccount > highcount) | 797 | // if(caccount > highcount) |
796 | // caccount = highcount; | 798 | // caccount = highcount; |
797 | 799 | ||
798 | // setAccountbyIndex(caccount); | 800 | // setAccountbyIndex(caccount); |
799 | 801 | ||
800 | // return true; | 802 | // return true; |
801 | } | 803 | } |
802 | 804 | ||
803 | 805 | ||
804 | bool PPPData::deleteAccount(const QString &aname) { | 806 | bool PPPData::deleteAccount(const QString &aname) { |
805 | if(!setAccount(aname)) | 807 | if(!setAccount(aname)) |
806 | return false; | 808 | return false; |
807 | 809 | ||
808 | deleteAccount(); | 810 | deleteAccount(); |
809 | 811 | ||
810 | return true; | 812 | return true; |
811 | } | 813 | } |
812 | 814 | ||
813 | 815 | ||
814 | int PPPData::newaccount() { | 816 | int PPPData::newaccount() { |
815 | 817 | ||
816 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 818 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
817 | // if(!config) open(); | 819 | // if(!config) open(); |
818 | if (highcount >= MAX_ACCOUNTS) return -1; | 820 | if (highcount >= MAX_ACCOUNTS) return -1; |
819 | 821 | ||
820 | highcount++; | 822 | highcount++; |
821 | setAccountbyIndex(highcount); | 823 | setAccountbyIndex(highcount); |
822 | 824 | ||
823 | setpppdArgumentDefaults(); | 825 | setpppdArgumentDefaults(); |
824 | qDebug("PPPData::newaccount -> %i",caccount); | 826 | qDebug("PPPData::newaccount -> %i",caccount); |
825 | return caccount; | 827 | return caccount; |
826 | } | 828 | } |
827 | 829 | ||
828 | int PPPData::copyaccount(int i) { | 830 | int PPPData::copyaccount(int i) { |
829 | // FIXME | 831 | // FIXME: PPPData::copyaccount |
830 | // if(highcount >= MAX_ACCOUNTS) | 832 | // if(highcount >= MAX_ACCOUNTS) |
831 | return -1; | 833 | return -1; |
832 | 834 | ||
833 | // setAccountbyIndex(i); | 835 | // setAccountbyIndex(i); |
834 | 836 | ||
835 | // QMap <QString, QString> map = config->entryMap(cgroup); | 837 | // QMap <QString, QString> map = config->entryMap(cgroup); |
836 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 838 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
837 | 839 | ||
838 | // QString newname = i18n("%1_copy").arg(accname()); | 840 | // QString newname = i18n("%1_copy").arg(accname()); |
839 | 841 | ||
840 | // newaccount(); | 842 | // newaccount(); |
841 | 843 | ||
842 | // while (it != map.end()) { | 844 | // while (it != map.end()) { |
843 | // config->writeEntry(it.key(), *it); | 845 | // config->writeEntry(it.key(), *it); |
844 | // it++; | 846 | // it++; |
845 | // } | 847 | // } |
846 | 848 | ||
847 | // setAccname(newname); | 849 | // setAccname(newname); |
848 | 850 | ||
849 | // return caccount; | 851 | // return caccount; |
850 | } | 852 | } |
851 | 853 | ||
852 | 854 | ||
853 | const QString PPPData::accname() { | 855 | const QString PPPData::accname() { |
854 | return readConfig(cgroup, NAME_KEY); | 856 | return readConfig(cgroup, NAME_KEY); |
855 | } | 857 | } |
856 | 858 | ||
857 | void PPPData::setAccname(const QString &n) { | 859 | void PPPData::setAccname(const QString &n) { |
858 | if(!cgroup.isNull()) { | 860 | if(!cgroup.isNull()) { |
859 | // are we manipulating the default account's name ? then change it, too. | 861 | // are we manipulating the default account's name ? then change it, too. |
860 | bool def = accname() == defaultAccount(); | 862 | bool def = accname() == defaultAccount(); |
861 | writeConfig(cgroup, NAME_KEY, n); | 863 | writeConfig(cgroup, NAME_KEY, n); |
862 | if (def) | 864 | if (def) |
863 | setDefaultAccount(n); | 865 | setDefaultAccount(n); |
864 | } | 866 | } |
865 | } | 867 | } |
866 | 868 | ||
867 | 869 | ||
868 | #define SEPARATOR_CHAR '&' | 870 | #define SEPARATOR_CHAR '&' |
869 | QStringList &PPPData::phonenumbers() { | 871 | QStringList &PPPData::phonenumbers() { |
870 | 872 | ||
871 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 873 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
872 | return phonelist; | 874 | return phonelist; |
873 | 875 | ||
874 | } | 876 | } |
875 | 877 | ||
876 | 878 | ||
877 | const QString PPPData::phonenumber() { | 879 | const QString PPPData::phonenumber() { |
878 | return readConfig(cgroup, PHONENUMBER_KEY); | 880 | return readConfig(cgroup, PHONENUMBER_KEY); |
879 | } | 881 | } |
880 | 882 | ||
881 | 883 | ||
882 | void PPPData::setPhonenumber(const QString &n) { | 884 | void PPPData::setPhonenumber(const QString &n) { |
883 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 885 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
884 | } | 886 | } |
885 | 887 | ||
886 | 888 | ||
887 | const QString PPPData::dialPrefix() { | 889 | const QString PPPData::dialPrefix() { |
888 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 890 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
889 | } | 891 | } |
890 | 892 | ||
891 | 893 | ||
892 | void PPPData::setDialPrefix(const QString &s) { | 894 | void PPPData::setDialPrefix(const QString &s) { |
893 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 895 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
894 | } | 896 | } |
895 | 897 | ||
896 | 898 | ||
897 | int PPPData::authMethod() { | 899 | int PPPData::authMethod() { |
898 | return readNumConfig(cgroup, AUTH_KEY, 0); | 900 | return readNumConfig(cgroup, AUTH_KEY, 0); |
899 | } | 901 | } |
900 | 902 | ||
901 | 903 | ||
902 | void PPPData::setAuthMethod(int value) { | 904 | void PPPData::setAuthMethod(int value) { |
903 | writeConfig(cgroup, AUTH_KEY, value); | 905 | writeConfig(cgroup, AUTH_KEY, value); |
904 | } | 906 | } |
905 | 907 | ||
906 | 908 | ||
907 | const QString PPPData::storedUsername() { | 909 | const QString PPPData::storedUsername() { |
908 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 910 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
909 | } | 911 | } |
910 | 912 | ||
911 | 913 | ||
912 | void PPPData::setStoredUsername(const QString &b) { | 914 | void PPPData::setStoredUsername(const QString &b) { |
913 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 915 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
914 | } | 916 | } |
915 | 917 | ||
916 | 918 | ||
917 | const QString PPPData::storedPassword() { | 919 | const QString PPPData::storedPassword() { |
918 | qDebug("getting stored pw"); | 920 | qDebug("getting stored pw"); |
919 | qDebug("g %s", cgroup.latin1() ); | 921 | qDebug("g %s", cgroup.latin1() ); |
920 | qDebug("k %s", STORED_PASSWORD_KEY); | 922 | qDebug("k %s", STORED_PASSWORD_KEY); |
921 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 923 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
922 | } | 924 | } |
923 | 925 | ||
924 | 926 | ||
925 | void PPPData::setStoredPassword(const QString &b) { | 927 | void PPPData::setStoredPassword(const QString &b) { |
926 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 928 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
927 | } | 929 | } |
928 | 930 | ||
929 | 931 | ||
930 | bool PPPData::storePassword() { | 932 | bool PPPData::storePassword() { |
931 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 933 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
932 | } | 934 | } |
933 | 935 | ||
934 | 936 | ||
935 | const QString PPPData::command_before_connect() { | 937 | const QString PPPData::command_before_connect() { |
936 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 938 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
937 | } | 939 | } |
938 | 940 | ||
939 | 941 | ||
940 | void PPPData::setCommand_before_connect(const QString &n) { | 942 | void PPPData::setCommand_before_connect(const QString &n) { |
941 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 943 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
942 | } | 944 | } |
943 | 945 | ||
944 | 946 | ||
945 | void PPPData::setStorePassword(bool b) { | 947 | void PPPData::setStorePassword(bool b) { |
946 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | 948 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); |
947 | } | 949 | } |
948 | 950 | ||
949 | 951 | ||
950 | const QString PPPData::command_on_connect() { | 952 | const QString PPPData::command_on_connect() { |
951 | return readConfig(cgroup, COMMAND_KEY); | 953 | return readConfig(cgroup, COMMAND_KEY); |
952 | } | 954 | } |
953 | 955 | ||
954 | 956 | ||
955 | void PPPData::setCommand_on_connect(const QString &n) { | 957 | void PPPData::setCommand_on_connect(const QString &n) { |
956 | writeConfig(cgroup, COMMAND_KEY, n); | 958 | writeConfig(cgroup, COMMAND_KEY, n); |
957 | } | 959 | } |
958 | 960 | ||
959 | 961 | ||
960 | const QString PPPData::command_on_disconnect() { | 962 | const QString PPPData::command_on_disconnect() { |
961 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); | 963 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); |
962 | } | 964 | } |
963 | 965 | ||
964 | 966 | ||
965 | void PPPData::setCommand_on_disconnect(const QString &n) { | 967 | void PPPData::setCommand_on_disconnect(const QString &n) { |
966 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); | 968 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); |
967 | } | 969 | } |
968 | 970 | ||
969 | 971 | ||
970 | const QString PPPData::command_before_disconnect() { | 972 | const QString PPPData::command_before_disconnect() { |
971 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); | 973 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); |
972 | } | 974 | } |
973 | 975 | ||
974 | 976 | ||
975 | void PPPData::setCommand_before_disconnect(const QString &n) { | 977 | void PPPData::setCommand_before_disconnect(const QString &n) { |
976 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); | 978 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); |
977 | } | 979 | } |
978 | 980 | ||
979 | 981 | ||
980 | const QString PPPData::ipaddr() { | 982 | const QString PPPData::ipaddr() { |
981 | return readConfig(cgroup, IPADDR_KEY); | 983 | return readConfig(cgroup, IPADDR_KEY); |
982 | } | 984 | } |
983 | 985 | ||
984 | 986 | ||
985 | void PPPData::setIpaddr(const QString &n) { | 987 | void PPPData::setIpaddr(const QString &n) { |
986 | writeConfig(cgroup, IPADDR_KEY, n); | 988 | writeConfig(cgroup, IPADDR_KEY, n); |
987 | } | 989 | } |
988 | 990 | ||
989 | 991 | ||
990 | const QString PPPData::subnetmask() { | 992 | const QString PPPData::subnetmask() { |
991 | return readConfig(cgroup, SUBNETMASK_KEY); | 993 | return readConfig(cgroup, SUBNETMASK_KEY); |
992 | } | 994 | } |
993 | 995 | ||
994 | 996 | ||
995 | void PPPData::setSubnetmask(const QString &n) { | 997 | void PPPData::setSubnetmask(const QString &n) { |
996 | writeConfig(cgroup, SUBNETMASK_KEY, n); | 998 | writeConfig(cgroup, SUBNETMASK_KEY, n); |
997 | } | 999 | } |
998 | 1000 | ||
999 | 1001 | ||
1000 | bool PPPData::autoname() { | 1002 | bool PPPData::autoname() { |
1001 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); | 1003 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); |
1002 | } | 1004 | } |
1003 | 1005 | ||
1004 | 1006 | ||
1005 | void PPPData::setAutoname(bool set) { | 1007 | void PPPData::setAutoname(bool set) { |
1006 | writeConfig(cgroup, AUTONAME_KEY, (int) set); | 1008 | writeConfig(cgroup, AUTONAME_KEY, (int) set); |
1007 | } | 1009 | } |
1008 | 1010 | ||
1009 | 1011 | ||
1010 | bool PPPData::AcctEnabled() { | 1012 | bool PPPData::AcctEnabled() { |
1011 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); | 1013 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | 1016 | ||
1015 | void PPPData::setAcctEnabled(bool set) { | 1017 | void PPPData::setAcctEnabled(bool set) { |
1016 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); | 1018 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); |
1017 | } | 1019 | } |
1018 | 1020 | ||
1019 | 1021 | ||
1020 | // int PPPData::VolAcctEnabled() { | 1022 | // int PPPData::VolAcctEnabled() { |
1021 | // return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); | 1023 | // return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); |
1022 | // } | 1024 | // } |
1023 | 1025 | ||
1024 | 1026 | ||
1025 | // void PPPData::setVolAcctEnabled(int set) { | 1027 | // void PPPData::setVolAcctEnabled(int set) { |
1026 | // writeConfig(cgroup, VOLACCTENABLED_KEY, set); | 1028 | // writeConfig(cgroup, VOLACCTENABLED_KEY, set); |
1027 | // } | 1029 | // } |
1028 | 1030 | ||
1029 | 1031 | ||
1030 | const QString PPPData::gateway() { | 1032 | const QString PPPData::gateway() { |
1031 | return readConfig(cgroup, GATEWAY_KEY); | 1033 | return readConfig(cgroup, GATEWAY_KEY); |
1032 | } | 1034 | } |
1033 | 1035 | ||
1034 | 1036 | ||
1035 | void PPPData::setGateway(const QString &n ) { | 1037 | void PPPData::setGateway(const QString &n ) { |
1036 | writeConfig(cgroup, GATEWAY_KEY, n); | 1038 | writeConfig(cgroup, GATEWAY_KEY, n); |
1037 | } | 1039 | } |
1038 | 1040 | ||
1039 | 1041 | ||
1040 | bool PPPData::defaultroute() { | 1042 | bool PPPData::defaultroute() { |
1041 | // default route is by default 'on'. | 1043 | // default route is by default 'on'. |
1042 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); | 1044 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); |
1043 | } | 1045 | } |
1044 | 1046 | ||
1045 | 1047 | ||
1046 | void PPPData::setDefaultroute(bool set) { | 1048 | void PPPData::setDefaultroute(bool set) { |
1047 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); | 1049 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); |
1048 | } | 1050 | } |
1049 | 1051 | ||
1050 | 1052 | ||
1051 | bool PPPData::autoDNS() { | 1053 | bool PPPData::autoDNS() { |
1052 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); | 1054 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); |
1053 | return (set && pppdVersionMin(2, 3, 7)); | 1055 | return (set && pppdVersionMin(2, 3, 7)); |
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | 1058 | ||
1057 | void PPPData::setAutoDNS(bool set) { | 1059 | void PPPData::setAutoDNS(bool set) { |
1058 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | 1060 | writeConfig(cgroup, AUTODNS_KEY, (int) set); |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | 1063 | ||
1062 | void PPPData::setExDNSDisabled(bool set) { | 1064 | void PPPData::setExDNSDisabled(bool set) { |
1063 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | 1065 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); |
1064 | } | 1066 | } |
1065 | 1067 | ||
1066 | 1068 | ||
1067 | bool PPPData::exDNSDisabled() { | 1069 | bool PPPData::exDNSDisabled() { |
1068 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | 1070 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | 1073 | ||
1072 | QStringList &PPPData::dns() { | 1074 | QStringList &PPPData::dns() { |
1073 | static QStringList dnslist; | 1075 | static QStringList dnslist; |
1074 | 1076 | ||
1075 | readListConfig(cgroup, DNS_KEY, dnslist); | 1077 | readListConfig(cgroup, DNS_KEY, dnslist); |
1076 | while(dnslist.count() > MAX_DNS_ENTRIES) | 1078 | while(dnslist.count() > MAX_DNS_ENTRIES) |
1077 | dnslist.remove(dnslist.last()); | 1079 | dnslist.remove(dnslist.last()); |
1078 | 1080 | ||
1079 | return dnslist; | 1081 | return dnslist; |
1080 | } | 1082 | } |
1081 | 1083 | ||
1082 | 1084 | ||
1083 | void PPPData::setDns(QStringList &list) { | 1085 | void PPPData::setDns(QStringList &list) { |
1084 | writeListConfig(cgroup, DNS_KEY, list); | 1086 | writeListConfig(cgroup, DNS_KEY, list); |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | 1089 | ||
1088 | const QString PPPData::domain() { | 1090 | const QString PPPData::domain() { |
1089 | return readConfig(cgroup, DOMAIN_KEY); | 1091 | return readConfig(cgroup, DOMAIN_KEY); |
1090 | } | 1092 | } |
1091 | 1093 | ||
1092 | 1094 | ||
1093 | void PPPData::setDomain(const QString &n ) { | 1095 | void PPPData::setDomain(const QString &n ) { |
1094 | writeConfig(cgroup, DOMAIN_KEY, n); | 1096 | writeConfig(cgroup, DOMAIN_KEY, n); |
1095 | } | 1097 | } |
1096 | 1098 | ||
1097 | 1099 | ||
1098 | QStringList &PPPData::scriptType() { | 1100 | QStringList &PPPData::scriptType() { |
1099 | static QStringList typelist; | 1101 | static QStringList typelist; |
1100 | 1102 | ||
1101 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | 1103 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); |
1102 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | 1104 | while(typelist.count() > MAX_SCRIPT_ENTRIES) |
1103 | typelist.remove(typelist.last()); | 1105 | typelist.remove(typelist.last()); |
1104 | 1106 | ||
1105 | return typelist; | 1107 | return typelist; |
1106 | } | 1108 | } |
1107 | 1109 | ||
1108 | 1110 | ||
1109 | void PPPData::setScriptType(QStringList &list) { | 1111 | void PPPData::setScriptType(QStringList &list) { |
1110 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | 1112 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); |
1111 | } | 1113 | } |
1112 | 1114 | ||
1113 | 1115 | ||
1114 | QStringList &PPPData::script() { | 1116 | QStringList &PPPData::script() { |
1115 | static QStringList scriptlist; | 1117 | static QStringList scriptlist; |
1116 | 1118 | ||
1117 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | 1119 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); |
1118 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | 1120 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) |
1119 | scriptlist.remove(scriptlist.last()); | 1121 | scriptlist.remove(scriptlist.last()); |
1120 | 1122 | ||
1121 | return scriptlist; | 1123 | return scriptlist; |
1122 | } | 1124 | } |
1123 | 1125 | ||
1124 | 1126 | ||
1125 | void PPPData::setScript(QStringList &list) { | 1127 | void PPPData::setScript(QStringList &list) { |
1126 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | 1128 | writeListConfig(cgroup, SCRIPTARG_KEY, list); |
1127 | } | 1129 | } |
1128 | 1130 | ||
1129 | 1131 | ||
1130 | // const QString PPPData::accountingFile() { | 1132 | // const QString PPPData::accountingFile() { |
1131 | // return readConfig(cgroup, ACCTFILE_KEY); | 1133 | // return readConfig(cgroup, ACCTFILE_KEY); |
1132 | // } | 1134 | // } |
1133 | 1135 | ||
1134 | 1136 | ||
1135 | // void PPPData::setAccountingFile(const QString &n) { | 1137 | // void PPPData::setAccountingFile(const QString &n) { |
1136 | // writeConfig(cgroup, ACCTFILE_KEY, n); | 1138 | // writeConfig(cgroup, ACCTFILE_KEY, n); |
1137 | // } | 1139 | // } |
1138 | 1140 | ||
1139 | 1141 | ||
1140 | // const QString PPPData::totalCosts() { | 1142 | // const QString PPPData::totalCosts() { |
1141 | // return readConfig(cgroup, TOTALCOSTS_KEY); | 1143 | // return readConfig(cgroup, TOTALCOSTS_KEY); |
1142 | // } | 1144 | // } |
1143 | 1145 | ||
1144 | 1146 | ||
1145 | // void PPPData::setTotalCosts(const QString &n) { | 1147 | // void PPPData::setTotalCosts(const QString &n) { |
1146 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); | 1148 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); |
1147 | // } | 1149 | // } |
1148 | 1150 | ||
1149 | 1151 | ||
1150 | // int PPPData::totalBytes() { | 1152 | // int PPPData::totalBytes() { |
1151 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | 1153 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); |
1152 | // } | 1154 | // } |
1153 | 1155 | ||
1154 | // void PPPData::setTotalBytes(int n) { | 1156 | // void PPPData::setTotalBytes(int n) { |
1155 | // writeConfig(cgroup, TOTALBYTES_KEY, n); | 1157 | // writeConfig(cgroup, TOTALBYTES_KEY, n); |
1156 | // } | 1158 | // } |
1157 | 1159 | ||
1158 | 1160 | ||
1159 | QStringList &PPPData::pppdArgument() { | 1161 | QStringList &PPPData::pppdArgument() { |
1160 | static QStringList arglist; | 1162 | static QStringList arglist; |
1161 | 1163 | ||
1162 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1164 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1163 | arglist.remove(arglist.last()); | 1165 | arglist.remove(arglist.last()); |
1164 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1166 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1165 | 1167 | ||
1166 | return arglist; | 1168 | return arglist; |
1167 | } | 1169 | } |
1168 | 1170 | ||
1169 | 1171 | ||
1170 | void PPPData::setpppdArgument(QStringList &args) { | 1172 | void PPPData::setpppdArgument(QStringList &args) { |
1171 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1173 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1172 | } | 1174 | } |
1173 | 1175 | ||
1174 | 1176 | ||
1175 | void PPPData::setpppdArgumentDefaults() { | 1177 | void PPPData::setpppdArgumentDefaults() { |
1176 | QStringList arg; | 1178 | QStringList arg; |
1177 | setpppdArgument(arg); | 1179 | setpppdArgument(arg); |
1178 | } | 1180 | } |
1179 | 1181 | ||
1180 | 1182 | ||
1181 | // // graphing widget | 1183 | // // graphing widget |
1182 | // void PPPData::setGraphingOptions(bool enable, | 1184 | // void PPPData::setGraphingOptions(bool enable, |
1183 | // QColor bg, | 1185 | // QColor bg, |
1184 | // QColor text, | 1186 | // QColor text, |
1185 | // QColor in, | 1187 | // QColor in, |
1186 | // QColor out) | 1188 | // QColor out) |
1187 | // { | 1189 | // { |
1188 | // if(config) { | 1190 | // if(config) { |
1189 | // config->setGroup(GRAPH_GRP); | 1191 | // config->setGroup(GRAPH_GRP); |
1190 | // config->writeEntry(GENABLED, enable); | 1192 | // config->writeEntry(GENABLED, enable); |
1191 | // // config->writeEntry(GCOLOR_BG, bg); | 1193 | // // config->writeEntry(GCOLOR_BG, bg); |
1192 | // // config->writeEntry(GCOLOR_TEXT, text); | 1194 | // // config->writeEntry(GCOLOR_TEXT, text); |
1193 | // // config->writeEntry(GCOLOR_IN, in); | 1195 | // // config->writeEntry(GCOLOR_IN, in); |
1194 | // // config->writeEntry(GCOLOR_OUT, out); | 1196 | // // config->writeEntry(GCOLOR_OUT, out); |
1195 | // } | 1197 | // } |
1196 | // } | 1198 | // } |
1197 | 1199 | ||
1198 | // void PPPData::graphingOptions(bool &enable, | 1200 | // void PPPData::graphingOptions(bool &enable, |
1199 | // QColor &bg, | 1201 | // QColor &bg, |
1200 | // QColor &text, | 1202 | // QColor &text, |
1201 | // QColor &in, | 1203 | // QColor &in, |
1202 | // QColor &out) | 1204 | // QColor &out) |
1203 | // { | 1205 | // { |
1204 | // QColor c; | 1206 | // QColor c; |
1205 | 1207 | ||
1206 | // if(config) { | 1208 | // if(config) { |
1207 | // config->setGroup(GRAPH_GRP); | 1209 | // config->setGroup(GRAPH_GRP); |
1208 | // enable = config->readBoolEntry(GENABLED, true); | 1210 | // enable = config->readBoolEntry(GENABLED, true); |
1209 | // bg = Qt::white; | 1211 | // bg = Qt::white; |
1210 | // //bg = config->readColorEntry(GCOLOR_BG, &c); | 1212 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1211 | // text = Qt::black; | 1213 | // text = Qt::black; |
1212 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1214 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1213 | // in = Qt::blue; | 1215 | // in = Qt::blue; |
1214 | // //in = config->readColorEntry(GCOLOR_IN, &c); | 1216 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1215 | // out = Qt::red; | 1217 | // out = Qt::red; |
1216 | // //out = config->readColorEntry(GCOLOR_OUT, &c); | 1218 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1217 | // } | 1219 | // } |
1218 | // } | 1220 | // } |
1219 | 1221 | ||
1220 | 1222 | ||
1221 | // bool PPPData::graphingEnabled() { | 1223 | // bool PPPData::graphingEnabled() { |
1222 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1224 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1223 | // } | 1225 | // } |
1224 | 1226 | ||
1225 | 1227 | ||
1226 | 1228 | ||
1227 | // | 1229 | // |
1228 | //functions to change/set the child pppd process info | 1230 | //functions to change/set the child pppd process info |
1229 | // | 1231 | // |
1230 | bool PPPData::pppdRunning() const { | 1232 | bool PPPData::pppdRunning() const { |
1231 | return pppdisrunning; | 1233 | return pppdisrunning; |
1232 | } | 1234 | } |
1233 | 1235 | ||
1234 | void PPPData::setpppdRunning(bool set) { | 1236 | void PPPData::setpppdRunning(bool set) { |
1235 | pppdisrunning = set; | 1237 | pppdisrunning = set; |
1236 | } | 1238 | } |
1237 | 1239 | ||
1238 | int PPPData::pppdError() const { | 1240 | int PPPData::pppdError() const { |
1239 | return pppderror; | 1241 | return pppderror; |
1240 | } | 1242 | } |
1241 | 1243 | ||
1242 | void PPPData::setpppdError(int err) { | 1244 | void PPPData::setpppdError(int err) { |
1243 | pppderror = err; | 1245 | pppderror = err; |
1244 | } | 1246 | } |
1245 | 1247 | ||
1246 | QString PPPData::modemGroup() | 1248 | QString PPPData::modemGroup() |
1247 | { | 1249 | { |
1248 | if (modemDeviceGroup<0){ | 1250 | if (modemDeviceGroup<0){ |
1249 | qDebug("wrong modem %i\n using 0",modemDeviceGroup); | 1251 | qDebug("wrong modem %i\n using 0",modemDeviceGroup); |
1250 | modemDeviceGroup = 0; //FIXME! | 1252 | modemDeviceGroup = 0; //FIXME! |
1251 | } | 1253 | } |
1252 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); | 1254 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); |
1253 | } | 1255 | } |
1254 | 1256 | ||
1255 | 1257 | ||
1256 | QMap<QString,QString> PPPData::getConfiguredInterfaces() | 1258 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1257 | { | 1259 | { |
1258 | QMap<QString,QString> ifaces; | 1260 | QMap<QString,QString> ifaces; |
1259 | Config config = PPPData::config(); | 1261 | Config config = PPPData::config(); |
1260 | config.setGroup(ACCLIST_GRP); | 1262 | config.setGroup(ACCLIST_GRP); |
1261 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | 1263 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); |
1262 | QString accGrp, dev, acc; | 1264 | QString accGrp, dev, acc; |
1263 | for (int i = 0; i < count; i++){ | 1265 | for (int i = 0; i < count; i++){ |
1264 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1266 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
1265 | config.setGroup(accGrp); | 1267 | config.setGroup(accGrp); |
1266 | dev = config.readEntry( ACOUNTS_DEV, "error" ); | 1268 | dev = config.readEntry( ACOUNTS_DEV, "error" ); |
1267 | acc = config.readEntry( ACOUNTS_ACC, "error" ); | 1269 | acc = config.readEntry( ACOUNTS_ACC, "error" ); |
1268 | ifaces.insert( dev, acc ); | 1270 | ifaces.insert( dev, acc ); |
1269 | } | 1271 | } |
1270 | 1272 | ||
1271 | return ifaces; | 1273 | return ifaces; |
1272 | } | 1274 | } |
1273 | 1275 | ||
1274 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1276 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1275 | { | 1277 | { |
1276 | QMap<QString,QString>::Iterator it; | 1278 | QMap<QString,QString>::Iterator it; |
1277 | int i = 0; | 1279 | int i = 0; |
1278 | Config cfg = config(); | 1280 | Config cfg = config(); |
1279 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ | 1281 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
1280 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i)); | 1282 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); |
1281 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); | 1283 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1282 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1284 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1285 | qDebug("I %i",i); | ||
1283 | } | 1286 | } |
1284 | cfg.setGroup( ACCLIST_GRP ); | 1287 | cfg.setGroup( ACCLIST_GRP ); |
1288 | qDebug("saved %i account settings", i); | ||
1285 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1289 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1286 | 1290 | ||
1287 | } | 1291 | } |
1288 | 1292 | ||
1289 | /** | 1293 | /** |
1290 | * pppd's getword() function knows about escape characters. | 1294 | * pppd's getword() function knows about escape characters. |
1291 | * If we write the username and password to the secrets file | 1295 | * If we write the username and password to the secrets file |
1292 | * we'll therefore have to escape back slashes. | 1296 | * we'll therefore have to escape back slashes. |
1293 | */ | 1297 | */ |
1294 | QString PPPData::encodeWord(const QString &s) { | 1298 | QString PPPData::encodeWord(const QString &s) { |
1295 | QString r = s; | 1299 | QString r = s; |
1296 | r.replace(QRegExp("\\"), "\\\\"); | 1300 | r.replace(QRegExp("\\"), "\\\\"); |
1297 | return r; | 1301 | return r; |
1298 | } | 1302 | } |
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index c9cd482..6e1379d 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -1,438 +1,438 @@ | |||
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 <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | #include "kpppconfig.h" | 39 | #include "kpppconfig.h" |
40 | 40 | ||
41 | class Config; | 41 | class Config; |
42 | 42 | ||
43 | // string lengths | 43 | // string lengths |
44 | 44 | ||
45 | #define PATH_SIZE 120 | 45 | #define PATH_SIZE 120 |
46 | #define MODEMSTR_SIZE 80 | 46 | #define MODEMSTR_SIZE 80 |
47 | #define ACCNAME_SIZE 50 | 47 | #define ACCNAME_SIZE 50 |
48 | #define PHONENUMBER_SIZE 60 | 48 | #define PHONENUMBER_SIZE 60 |
49 | #define COMMAND_SIZE 255 | 49 | #define COMMAND_SIZE 255 |
50 | #define IPADDR_SIZE 15 | 50 | #define IPADDR_SIZE 15 |
51 | #define DOMAIN_SIZE 50 | 51 | #define DOMAIN_SIZE 50 |
52 | #define TIMEOUT_SIZE 60 | 52 | #define TIMEOUT_SIZE 60 |
53 | 53 | ||
54 | // | 54 | // |
55 | // keys for config file | 55 | // keys for config file |
56 | // | 56 | // |
57 | 57 | ||
58 | // groups | 58 | // groups |
59 | #define GENERAL_GRP "PPP_General" | 59 | #define GENERAL_GRP "PPP_General" |
60 | #define MODEM_GRP "PPP_Modem" | 60 | #define MODEM_GRP "PPP_Modem" |
61 | #define ACCOUNT_GRP "PPP_Account" | 61 | #define ACCOUNT_GRP "PPP_Account" |
62 | #define ACCLIST_GRP "PPP_Accounts_List" | 62 | #define ACCLIST_GRP "PPP_Accounts_List" |
63 | //#define GRAPH_GRP "Graph" | 63 | //#define GRAPH_GRP "Graph" |
64 | //#define WINPOS_GRP "WindowPosition" | 64 | //#define WINPOS_GRP "WindowPosition" |
65 | 65 | ||
66 | // general | 66 | // general |
67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | 67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" |
68 | #define PPPDVERSION_KEY "pppdVersion" | 68 | #define PPPDVERSION_KEY "pppdVersion" |
69 | #define PPPDTIMEOUT_KEY "pppdTimeout" | 69 | #define PPPDTIMEOUT_KEY "pppdTimeout" |
70 | #define SHOWCLOCK_KEY "ShowClock" | 70 | #define SHOWCLOCK_KEY "ShowClock" |
71 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 71 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
72 | #define AUTOREDIAL_KEY "AutomaticRedial" | 72 | #define AUTOREDIAL_KEY "AutomaticRedial" |
73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | 75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" |
76 | #define ID_KEY "ID" | 76 | #define ID_KEY "ID" |
77 | 77 | ||
78 | // modem | 78 | // modem |
79 | #define MODEMDEV_KEY "Device" | 79 | #define MODEMDEV_KEY "Device" |
80 | #define LOCKFILE_KEY "UseLockFile" | 80 | #define LOCKFILE_KEY "UseLockFile" |
81 | #define FLOWCONTROL_KEY "FlowControl" | 81 | #define FLOWCONTROL_KEY "FlowControl" |
82 | #define SPEED_KEY "Speed" | 82 | #define SPEED_KEY "Speed" |
83 | #define TIMEOUT_KEY "Timeout" | 83 | #define TIMEOUT_KEY "Timeout" |
84 | #define TONEDURATION_KEY "ToneDuration" | 84 | #define TONEDURATION_KEY "ToneDuration" |
85 | #define BUSYWAIT_KEY "BusyWait" | 85 | #define BUSYWAIT_KEY "BusyWait" |
86 | #define INITSTR_KEY "InitString" | 86 | #define INITSTR_KEY "InitString" |
87 | #define INITRESP_KEY "InitResponse" | 87 | #define INITRESP_KEY "InitResponse" |
88 | #define PREINITDELAY_KEY "PreInitDelay" | 88 | #define PREINITDELAY_KEY "PreInitDelay" |
89 | #define INITDELAY_KEY "InitDelay" | 89 | #define INITDELAY_KEY "InitDelay" |
90 | #define NODTDETECT_KEY "NoDialToneDetection" | 90 | #define NODTDETECT_KEY "NoDialToneDetection" |
91 | #define DIALTONEWAIT_KEY "WaitForDialTone" | 91 | #define DIALTONEWAIT_KEY "WaitForDialTone" |
92 | #define DIALSTR_KEY "DialString" | 92 | #define DIALSTR_KEY "DialString" |
93 | #define CONNECTRESP_KEY "ConnectResponse" | 93 | #define CONNECTRESP_KEY "ConnectResponse" |
94 | #define BUSYRESP_KEY "BusyResponse" | 94 | #define BUSYRESP_KEY "BusyResponse" |
95 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | 95 | #define NOCARRIERRESP_KEY "NoCarrierResponse" |
96 | #define NODIALTONERESP_KEY "NoDialToneResp" | 96 | #define NODIALTONERESP_KEY "NoDialToneResp" |
97 | #define HANGUPSTR_KEY "HangupString" | 97 | #define HANGUPSTR_KEY "HangupString" |
98 | #define HANGUPRESP_KEY "HangUpResponse" | 98 | #define HANGUPRESP_KEY "HangUpResponse" |
99 | #define ANSWERSTR_KEY "AnswerString" | 99 | #define ANSWERSTR_KEY "AnswerString" |
100 | #define RINGRESP_KEY "RingResponse" | 100 | #define RINGRESP_KEY "RingResponse" |
101 | #define ANSWERRESP_KEY "AnswerResponse" | 101 | #define ANSWERRESP_KEY "AnswerResponse" |
102 | #define ENTER_KEY "Enter" | 102 | #define ENTER_KEY "Enter" |
103 | #define ESCAPESTR_KEY "EscapeString" | 103 | #define ESCAPESTR_KEY "EscapeString" |
104 | #define ESCAPERESP_KEY "EscapeResponse" | 104 | #define ESCAPERESP_KEY "EscapeResponse" |
105 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | 105 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" |
106 | #define USECDLINE_KEY "UseCDLine" | 106 | #define USECDLINE_KEY "UseCDLine" |
107 | #define VOLUME_HIGH "VolumeHigh" | 107 | #define VOLUME_HIGH "VolumeHigh" |
108 | #define VOLUME_MEDIUM "VolumeMedium" | 108 | #define VOLUME_MEDIUM "VolumeMedium" |
109 | #define VOLUME_OFF "VolumeOff" | 109 | #define VOLUME_OFF "VolumeOff" |
110 | #define VOLUME_KEY "Volume" | 110 | #define VOLUME_KEY "Volume" |
111 | 111 | ||
112 | // account | 112 | // account |
113 | #define NAME_KEY "Name" | 113 | #define NAME_KEY "Name" |
114 | #define PHONENUMBER_KEY "Phonenumber" | 114 | #define PHONENUMBER_KEY "Phonenumber" |
115 | #define DIAL_PREFIX_KEY "DialPrefix" | 115 | #define DIAL_PREFIX_KEY "DialPrefix" |
116 | #define AUTH_KEY "Authentication" | 116 | #define AUTH_KEY "Authentication" |
117 | #define STORED_PASSWORD_KEY "Password" | 117 | #define STORED_PASSWORD_KEY "Password" |
118 | #define STORED_USERNAME_KEY "Username" | 118 | #define STORED_USERNAME_KEY "Username" |
119 | #define STORE_PASSWORD_KEY "StorePassword" | 119 | #define STORE_PASSWORD_KEY "StorePassword" |
120 | #define BEFORE_CONNECT_KEY "BeforeConnect" | 120 | #define BEFORE_CONNECT_KEY "BeforeConnect" |
121 | #define COMMAND_KEY "Command" | 121 | #define COMMAND_KEY "Command" |
122 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | 122 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" |
123 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | 123 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" |
124 | #define IPADDR_KEY "IPAddr" | 124 | #define IPADDR_KEY "IPAddr" |
125 | #define SUBNETMASK_KEY "SubnetMask" | 125 | #define SUBNETMASK_KEY "SubnetMask" |
126 | #define ACCTENABLED_KEY "AccountingEnabled" | 126 | #define ACCTENABLED_KEY "AccountingEnabled" |
127 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | 127 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" |
128 | #define ACCTFILE_KEY "AccountingFile" | 128 | #define ACCTFILE_KEY "AccountingFile" |
129 | #define AUTONAME_KEY "AutoName" | 129 | #define AUTONAME_KEY "AutoName" |
130 | #define GATEWAY_KEY "Gateway" | 130 | #define GATEWAY_KEY "Gateway" |
131 | #define DEFAULTROUTE_KEY "DefaultRoute" | 131 | #define DEFAULTROUTE_KEY "DefaultRoute" |
132 | #define DOMAIN_KEY "Domain" | 132 | #define DOMAIN_KEY "Domain" |
133 | #define DNS_KEY "DNS" | 133 | #define DNS_KEY "DNS" |
134 | #define AUTODNS_KEY "AutoDNS" | 134 | #define AUTODNS_KEY "AutoDNS" |
135 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | 135 | #define EXDNSDISABLED_KEY "ExDNSDisabled" |
136 | #define SCRIPTCOM_KEY "ScriptCommands" | 136 | #define SCRIPTCOM_KEY "ScriptCommands" |
137 | #define SCRIPTARG_KEY "ScriptArguments" | 137 | #define SCRIPTARG_KEY "ScriptArguments" |
138 | #define PPPDARG_KEY "pppdArguments" | 138 | #define PPPDARG_KEY "pppdArguments" |
139 | #define PPP_DEBUG_OPTION "PPPDebug" | 139 | #define PPP_DEBUG_OPTION "PPPDebug" |
140 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | 140 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" |
141 | #define DOCKING_KEY "DockIntoPanel" | 141 | #define DOCKING_KEY "DockIntoPanel" |
142 | #define TOTALCOSTS_KEY "TotalCosts" | 142 | #define TOTALCOSTS_KEY "TotalCosts" |
143 | #define TOTALBYTES_KEY "TotalBytes" | 143 | #define TOTALBYTES_KEY "TotalBytes" |
144 | 144 | ||
145 | // pppd errors | 145 | // pppd errors |
146 | #define E_IF_TIMEOUT 1 | 146 | #define E_IF_TIMEOUT 1 |
147 | #define E_PPPD_DIED 2 | 147 | #define E_PPPD_DIED 2 |
148 | 148 | ||
149 | // account list | 149 | // account list |
150 | #define ACCOUNTS_COUNT "Accounts_Count" | 150 | #define ACCOUNTS_COUNT "Accounts_Count" |
151 | #define ACOUNTS_DEV "Accounts_Modem" | 151 | #define ACOUNTS_DEV "Accounts_Modem" |
152 | #define ACOUNTS_ACC "Accounts_Account" | 152 | #define ACOUNTS_ACC "Accounts_Account" |
153 | 153 | ||
154 | class PPPData { | 154 | class PPPData { |
155 | public: | 155 | public: |
156 | PPPData(); | 156 | PPPData(); |
157 | ~PPPData() {}; | 157 | ~PPPData() {}; |
158 | 158 | ||
159 | enum { NumInitStrings = 2 }; | 159 | enum { NumInitStrings = 2 }; |
160 | 160 | ||
161 | // general functions | 161 | // general functions |
162 | void save(); | 162 | void save(); |
163 | void cancel(); | 163 | void cancel(); |
164 | 164 | ||
165 | static QMap<QString,QString> getConfiguredInterfaces(); | 165 | static QMap<QString,QString> getConfiguredInterfaces(); |
166 | static void setConfiguredInterfaces( QMap<QString,QString> ); | 166 | static void setConfiguredInterfaces( QMap<QString,QString> ); |
167 | 167 | ||
168 | // function to read/write date to configuration file | 168 | // function to read/write date to configuration file |
169 | static Config config(); | 169 | static Config config(); |
170 | QString readConfig(const QString &, const QString &, const QString &); | 170 | QString readConfig(const QString &, const QString &, const QString &); |
171 | int readNumConfig(const QString &, const QString &, int); | 171 | int readNumConfig(const QString &, const QString &, int); |
172 | bool readListConfig(const QString &, const QString &, | 172 | bool readListConfig(const QString &, const QString &, |
173 | QStringList &, char sep = ','); | 173 | QStringList &, char sep = ','); |
174 | void writeConfig(const QString &, const QString &, const QString &); | 174 | void writeConfig(const QString &, const QString &, const QString &); |
175 | void writeConfig(const QString &, const QString &, int); | 175 | void writeConfig(const QString &, const QString &, int); |
176 | void writeListConfig(const QString &, const QString &, | 176 | void writeListConfig(const QString &, const QString &, |
177 | QStringList &, char sep = ','); | 177 | QStringList &, char sep = ','); |
178 | 178 | ||
179 | // return the current account group | 179 | // return the current account group |
180 | QString currentGroup() { return cgroup; } | 180 | QString currentGroup() { return cgroup; } |
181 | QString modemGroup(); | 181 | QString modemGroup(); |
182 | 182 | ||
183 | // functions to set/get general kppp info | 183 | // functions to set/get general kppp info |
184 | QString password() const; | 184 | QString password(); |
185 | void setPassword(const QString &); | 185 | void setPassword(const QString &); |
186 | 186 | ||
187 | int currentAccountID() { return caccount; }; | 187 | int currentAccountID() { return caccount; }; |
188 | const QString defaultAccount(); | 188 | const QString defaultAccount(); |
189 | void setDefaultAccount(const QString &); | 189 | void setDefaultAccount(const QString &); |
190 | 190 | ||
191 | void set_xserver_exit_disconnect(bool set); | 191 | void set_xserver_exit_disconnect(bool set); |
192 | bool get_xserver_exit_disconnect(); | 192 | bool get_xserver_exit_disconnect(); |
193 | 193 | ||
194 | void setPPPDebug(bool set); | 194 | void setPPPDebug(bool set); |
195 | bool getPPPDebug(); | 195 | bool getPPPDebug(); |
196 | 196 | ||
197 | void set_quit_on_disconnect(bool); | 197 | void set_quit_on_disconnect(bool); |
198 | bool quit_on_disconnect(); | 198 | bool quit_on_disconnect(); |
199 | 199 | ||
200 | void set_show_clock_on_caption(bool set); | 200 | void set_show_clock_on_caption(bool set); |
201 | bool get_show_clock_on_caption(); | 201 | bool get_show_clock_on_caption(); |
202 | 202 | ||
203 | void set_show_log_window(bool set); | 203 | void set_show_log_window(bool set); |
204 | bool get_show_log_window(); | 204 | bool get_show_log_window(); |
205 | 205 | ||
206 | void set_automatic_redial(bool set); | 206 | void set_automatic_redial(bool set); |
207 | bool automatic_redial(); | 207 | bool automatic_redial(); |
208 | 208 | ||
209 | // void set_iconify_on_connect(bool set); | 209 | // void set_iconify_on_connect(bool set); |
210 | // bool get_iconify_on_connect(); | 210 | // bool get_iconify_on_connect(); |
211 | 211 | ||
212 | // void set_dock_into_panel(bool set); | 212 | // void set_dock_into_panel(bool set); |
213 | // bool get_dock_into_panel(); | 213 | // bool get_dock_into_panel(); |
214 | 214 | ||
215 | const QString enter(); | 215 | const QString enter(); |
216 | void setEnter(const QString &); | 216 | void setEnter(const QString &); |
217 | 217 | ||
218 | QString pppdVersion(); | 218 | QString pppdVersion(); |
219 | bool pppdVersionMin(int ver, int mod, int patch); | 219 | bool pppdVersionMin(int ver, int mod, int patch); |
220 | 220 | ||
221 | int pppdTimeout(); | 221 | int pppdTimeout(); |
222 | void setpppdTimeout(int); | 222 | void setpppdTimeout(int); |
223 | 223 | ||
224 | int busyWait(); | 224 | int busyWait(); |
225 | void setbusyWait(int); | 225 | void setbusyWait(int); |
226 | 226 | ||
227 | bool modemLockFile(); | 227 | bool modemLockFile(); |
228 | void setModemLockFile(bool set); | 228 | void setModemLockFile(bool set); |
229 | 229 | ||
230 | int modemEscapeGuardTime(); | 230 | int modemEscapeGuardTime(); |
231 | void setModemEscapeGuardTime(int i); | 231 | void setModemEscapeGuardTime(int i); |
232 | 232 | ||
233 | void setModemEscapeStr(const QString &); | 233 | void setModemEscapeStr(const QString &); |
234 | const QString modemEscapeStr(); | 234 | const QString modemEscapeStr(); |
235 | 235 | ||
236 | void setModemEscapeResp(const QString &); | 236 | void setModemEscapeResp(const QString &); |
237 | const QString modemEscapeResp(); | 237 | const QString modemEscapeResp(); |
238 | 238 | ||
239 | const QString modemDevice(); | 239 | const QString modemDevice(); |
240 | bool setModemDevice(const QString &); | 240 | bool setModemDevice(const QString &); |
241 | 241 | ||
242 | const QString flowcontrol(); | 242 | const QString flowcontrol(); |
243 | void setFlowcontrol(const QString &); | 243 | void setFlowcontrol(const QString &); |
244 | 244 | ||
245 | int modemTimeout(); | 245 | int modemTimeout(); |
246 | void setModemTimeout(int); | 246 | void setModemTimeout(int); |
247 | 247 | ||
248 | int modemToneDuration(); | 248 | int modemToneDuration(); |
249 | void setModemToneDuration(int); | 249 | void setModemToneDuration(int); |
250 | 250 | ||
251 | QString volumeInitString(); | 251 | QString volumeInitString(); |
252 | int volume(); | 252 | int volume(); |
253 | void setVolume(int); | 253 | void setVolume(int); |
254 | 254 | ||
255 | int waitForDialTone(); | 255 | int waitForDialTone(); |
256 | void setWaitForDialTone(int i); | 256 | void setWaitForDialTone(int i); |
257 | 257 | ||
258 | // modem command strings/responses | 258 | // modem command strings/responses |
259 | const QString modemInitStr(int i); | 259 | const QString modemInitStr(int i); |
260 | void setModemInitStr(int i, const QString &); | 260 | void setModemInitStr(int i, const QString &); |
261 | 261 | ||
262 | const QString modemInitResp(); | 262 | const QString modemInitResp(); |
263 | void setModemInitResp(const QString &); | 263 | void setModemInitResp(const QString &); |
264 | 264 | ||
265 | int modemPreInitDelay(); | 265 | int modemPreInitDelay(); |
266 | void setModemPreInitDelay(int); | 266 | void setModemPreInitDelay(int); |
267 | 267 | ||
268 | int modemInitDelay(); | 268 | int modemInitDelay(); |
269 | void setModemInitDelay(int); | 269 | void setModemInitDelay(int); |
270 | 270 | ||
271 | QString modemNoDialToneDetectionStr(); | 271 | QString modemNoDialToneDetectionStr(); |
272 | void setModemNoDialToneDetectionStr(const QString &); | 272 | void setModemNoDialToneDetectionStr(const QString &); |
273 | 273 | ||
274 | const QString modemDialStr(); | 274 | const QString modemDialStr(); |
275 | void setModemDialStr(const QString &); | 275 | void setModemDialStr(const QString &); |
276 | 276 | ||
277 | const QString modemConnectResp(); | 277 | const QString modemConnectResp(); |
278 | void setModemConnectResp(const QString &); | 278 | void setModemConnectResp(const QString &); |
279 | 279 | ||
280 | const QString modemBusyResp(); | 280 | const QString modemBusyResp(); |
281 | void setModemBusyResp(const QString &); | 281 | void setModemBusyResp(const QString &); |
282 | 282 | ||
283 | const QString modemNoCarrierResp(); | 283 | const QString modemNoCarrierResp(); |
284 | void setModemNoCarrierResp(const QString &); | 284 | void setModemNoCarrierResp(const QString &); |
285 | 285 | ||
286 | const QString modemNoDialtoneResp(); | 286 | const QString modemNoDialtoneResp(); |
287 | void setModemNoDialtoneResp(const QString &); | 287 | void setModemNoDialtoneResp(const QString &); |
288 | 288 | ||
289 | const QString modemHangupStr(); | 289 | const QString modemHangupStr(); |
290 | void setModemHangupStr(const QString &); | 290 | void setModemHangupStr(const QString &); |
291 | 291 | ||
292 | const QString modemHangupResp(); | 292 | const QString modemHangupResp(); |
293 | void setModemHangupResp(const QString &); | 293 | void setModemHangupResp(const QString &); |
294 | 294 | ||
295 | const QString modemAnswerStr(); | 295 | const QString modemAnswerStr(); |
296 | void setModemAnswerStr(const QString &); | 296 | void setModemAnswerStr(const QString &); |
297 | 297 | ||
298 | const QString modemRingResp(); | 298 | const QString modemRingResp(); |
299 | void setModemRingResp(const QString &); | 299 | void setModemRingResp(const QString &); |
300 | 300 | ||
301 | const QString modemAnswerResp(); | 301 | const QString modemAnswerResp(); |
302 | void setModemAnswerResp(const QString &); | 302 | void setModemAnswerResp(const QString &); |
303 | 303 | ||
304 | QString volumeOff(); | 304 | QString volumeOff(); |
305 | void setVolumeOff(const QString &); | 305 | void setVolumeOff(const QString &); |
306 | 306 | ||
307 | QString volumeMedium(); | 307 | QString volumeMedium(); |
308 | void setVolumeMedium(const QString &); | 308 | void setVolumeMedium(const QString &); |
309 | 309 | ||
310 | QString volumeHigh(); | 310 | QString volumeHigh(); |
311 | void setVolumeHigh(const QString &); | 311 | void setVolumeHigh(const QString &); |
312 | 312 | ||
313 | // functions to set/get account information | 313 | // functions to set/get account information |
314 | int count() const; | 314 | int count() const; |
315 | bool setAccount(const QString &); | 315 | bool setAccount(const QString &); |
316 | bool setAccountbyIndex(int); | 316 | bool setAccountbyIndex(int); |
317 | 317 | ||
318 | bool isUniqueAccname(const QString &); | 318 | bool isUniqueAccname(const QString &); |
319 | 319 | ||
320 | bool deleteAccount(); | 320 | bool deleteAccount(); |
321 | bool deleteAccount(const QString &); | 321 | bool deleteAccount(const QString &); |
322 | int newaccount(); | 322 | int newaccount(); |
323 | int copyaccount(int i); | 323 | int copyaccount(int i); |
324 | 324 | ||
325 | const QString accname(); | 325 | const QString accname(); |
326 | void setAccname(const QString &); | 326 | void setAccname(const QString &); |
327 | 327 | ||
328 | QStringList &phonenumbers(); | 328 | QStringList &phonenumbers(); |
329 | const QString phonenumber(); | 329 | const QString phonenumber(); |
330 | void setPhonenumber(const QString &); | 330 | void setPhonenumber(const QString &); |
331 | 331 | ||
332 | const QString dialPrefix(); | 332 | const QString dialPrefix(); |
333 | void setDialPrefix(const QString &); | 333 | void setDialPrefix(const QString &); |
334 | 334 | ||
335 | int authMethod(); | 335 | int authMethod(); |
336 | void setAuthMethod(int); | 336 | void setAuthMethod(int); |
337 | 337 | ||
338 | const QString storedUsername(); | 338 | const QString storedUsername(); |
339 | void setStoredUsername(const QString &); | 339 | void setStoredUsername(const QString &); |
340 | 340 | ||
341 | const QString storedPassword(); | 341 | const QString storedPassword(); |
342 | void setStoredPassword(const QString &); | 342 | void setStoredPassword(const QString &); |
343 | 343 | ||
344 | bool storePassword(); | 344 | bool storePassword(); |
345 | void setStorePassword(bool); | 345 | void setStorePassword(bool); |
346 | 346 | ||
347 | const QString speed(); | 347 | const QString speed(); |
348 | void setSpeed(const QString &); | 348 | void setSpeed(const QString &); |
349 | 349 | ||
350 | const QString command_before_connect(); | 350 | const QString command_before_connect(); |
351 | void setCommand_before_connect(const QString &); | 351 | void setCommand_before_connect(const QString &); |
352 | 352 | ||
353 | const QString command_on_connect(); | 353 | const QString command_on_connect(); |
354 | void setCommand_on_connect(const QString &); | 354 | void setCommand_on_connect(const QString &); |
355 | 355 | ||
356 | const QString command_on_disconnect(); | 356 | const QString command_on_disconnect(); |
357 | void setCommand_on_disconnect(const QString &); | 357 | void setCommand_on_disconnect(const QString &); |
358 | 358 | ||
359 | const QString command_before_disconnect(); | 359 | const QString command_before_disconnect(); |
360 | void setCommand_before_disconnect(const QString &); | 360 | void setCommand_before_disconnect(const QString &); |
361 | 361 | ||
362 | const QString ipaddr(); | 362 | const QString ipaddr(); |
363 | void setIpaddr(const QString &); | 363 | void setIpaddr(const QString &); |
364 | 364 | ||
365 | const QString subnetmask(); | 365 | const QString subnetmask(); |
366 | void setSubnetmask(const QString &); | 366 | void setSubnetmask(const QString &); |
367 | 367 | ||
368 | bool AcctEnabled(); | 368 | bool AcctEnabled(); |
369 | void setAcctEnabled(bool set); | 369 | void setAcctEnabled(bool set); |
370 | 370 | ||
371 | // int VolAcctEnabled(); | 371 | // int VolAcctEnabled(); |
372 | // void setVolAcctEnabled(int set); | 372 | // void setVolAcctEnabled(int set); |
373 | 373 | ||
374 | bool autoDNS(); | 374 | bool autoDNS(); |
375 | void setAutoDNS(bool set); | 375 | void setAutoDNS(bool set); |
376 | 376 | ||
377 | bool exDNSDisabled(); | 377 | bool exDNSDisabled(); |
378 | void setExDNSDisabled(bool set); | 378 | void setExDNSDisabled(bool set); |
379 | 379 | ||
380 | bool autoname(); | 380 | bool autoname(); |
381 | void setAutoname(bool set); | 381 | void setAutoname(bool set); |
382 | 382 | ||
383 | const QString gateway(); | 383 | const QString gateway(); |
384 | void setGateway(const QString &); | 384 | void setGateway(const QString &); |
385 | 385 | ||
386 | bool defaultroute(); | 386 | bool defaultroute(); |
387 | void setDefaultroute(bool set); | 387 | void setDefaultroute(bool set); |
388 | 388 | ||
389 | QStringList &dns(); | 389 | QStringList &dns(); |
390 | void setDns(QStringList &); | 390 | void setDns(QStringList &); |
391 | 391 | ||
392 | const QString domain(); | 392 | const QString domain(); |
393 | void setDomain(const QString &); | 393 | void setDomain(const QString &); |
394 | 394 | ||
395 | QStringList &scriptType(); | 395 | QStringList &scriptType(); |
396 | void setScriptType(QStringList &); | 396 | void setScriptType(QStringList &); |
397 | 397 | ||
398 | QStringList &script(); | 398 | QStringList &script(); |
399 | void setScript(QStringList &); | 399 | void setScript(QStringList &); |
400 | 400 | ||
401 | QStringList &pppdArgument(); | 401 | QStringList &pppdArgument(); |
402 | void setpppdArgumentDefaults(); | 402 | void setpppdArgumentDefaults(); |
403 | void setpppdArgument(QStringList &); | 403 | void setpppdArgument(QStringList &); |
404 | 404 | ||
405 | //functions to change/set the child pppd process info | 405 | //functions to change/set the child pppd process info |
406 | bool pppdRunning() const; | 406 | bool pppdRunning() const; |
407 | void setpppdRunning(bool set); | 407 | void setpppdRunning(bool set); |
408 | 408 | ||
409 | int pppdError() const; | 409 | int pppdError() const; |
410 | void setpppdError(int err); | 410 | void setpppdError(int err); |
411 | 411 | ||
412 | 412 | ||
413 | static QString encodeWord(const QString &s); | 413 | static QString encodeWord(const QString &s); |
414 | 414 | ||
415 | private: | 415 | private: |
416 | 416 | ||
417 | //static PPPData *_data; | 417 | //static PPPData *_data; |
418 | int modemDeviceGroup; | 418 | int modemDeviceGroup; |
419 | QString passwd; | 419 | QString passwd; |
420 | // static Config* config; // configuration object | 420 | // static Config* config; // configuration object |
421 | int highcount; // index of highest account | 421 | int highcount; // index of highest account |
422 | int caccount; // index of the current account | 422 | int caccount; // index of the current account |
423 | QString cgroup; // name of current config group | 423 | QString cgroup; // name of current config group |
424 | pid_t suidprocessid; // process ID of setuid child | 424 | pid_t suidprocessid; // process ID of setuid child |
425 | bool pppdisrunning; // pppd process | 425 | bool pppdisrunning; // pppd process |
426 | // daemon | 426 | // daemon |
427 | int pppderror; // error encounterd running pppd | 427 | int pppderror; // error encounterd running pppd |
428 | int pppdVer, pppdMod, pppdPatch; // pppd version | 428 | int pppdVer, pppdMod, pppdPatch; // pppd version |
429 | 429 | ||
430 | QStringList phonelist; | 430 | QStringList phonelist; |
431 | QMap<QString,QString> stringEntries; | 431 | QMap<QString,QString> stringEntries; |
432 | QMap<QString,int> intEntries; | 432 | QMap<QString,int> intEntries; |
433 | QMap<QString,QStringList> listEntries; | 433 | QMap<QString,QStringList> listEntries; |
434 | QMap<QString,QChar> sepEntries; | 434 | QMap<QString,QChar> sepEntries; |
435 | 435 | ||
436 | }; | 436 | }; |
437 | 437 | ||
438 | #endif | 438 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index 8c401a9..d4c137b 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,139 +1,137 @@ | |||
1 | 1 | ||
2 | #include "pppconfig.h" | 2 | #include "pppconfig.h" |
3 | #include "pppmodule.h" | 3 | #include "pppmodule.h" |
4 | #include "pppdata.h" | 4 | #include "pppdata.h" |
5 | #include "interfaceinformationppp.h" | 5 | #include "interfaceinformationppp.h" |
6 | #include "interfaceppp.h" | 6 | #include "interfaceppp.h" |
7 | 7 | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | PPPModule::PPPModule() : Module() | 12 | PPPModule::PPPModule() : Module() |
13 | { | 13 | { |
14 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 14 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
15 | QMap<QString,QString>::Iterator it; | 15 | QMap<QString,QString>::Iterator it; |
16 | InterfacePPP *iface; | 16 | InterfacePPP *iface; |
17 | qDebug("getting interfaces"); | 17 | qDebug("getting interfaces"); |
18 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 18 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
19 | qDebug("ifaces %s", it.key().latin1()); | 19 | qDebug("ifaces %s", it.key().latin1()); |
20 | iface = new InterfacePPP( 0, it.key() ); | 20 | iface = new InterfacePPP( 0, it.key() ); |
21 | iface->setHardwareName( it.data() ); | 21 | iface->setHardwareName( it.data() ); |
22 | list.append( (Interface*)iface ); | 22 | list.append( (Interface*)iface ); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Delete any interfaces that we own. | 27 | * Delete any interfaces that we own. |
28 | */ | 28 | */ |
29 | PPPModule::~PPPModule(){ | 29 | PPPModule::~PPPModule(){ |
30 | QMap<QString,QString> ifaces; | 30 | QMap<QString,QString> ifaces; |
31 | Interface *i; | 31 | Interface *i; |
32 | for ( i=list.first(); i != 0; i=list.next() ){ | 32 | for ( i=list.first(); i != 0; i=list.next() ){ |
33 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 33 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
34 | delete i; | 34 | delete i; |
35 | } | 35 | } |
36 | PPPData::setConfiguredInterfaces( ifaces ); | 36 | PPPData::setConfiguredInterfaces( ifaces ); |
37 | } | 37 | } |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Change the current profile | 40 | * Change the current profile |
41 | */ | 41 | */ |
42 | void PPPModule::setProfile(const QString &newProfile){ | 42 | void PPPModule::setProfile(const QString &newProfile){ |
43 | profile = newProfile; | 43 | profile = newProfile; |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * get the icon name for this device. | 47 | * get the icon name for this device. |
48 | * @param Interface* can be used in determining the icon. | 48 | * @param Interface* can be used in determining the icon. |
49 | * @return QString the icon name (minus .png, .gif etc) | 49 | * @return QString the icon name (minus .png, .gif etc) |
50 | */ | 50 | */ |
51 | QString PPPModule::getPixmapName(Interface* ){ | 51 | QString PPPModule::getPixmapName(Interface* ){ |
52 | return "ppp"; | 52 | return "ppp"; |
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Check to see if the interface i is owned by this module. | 56 | * Check to see if the interface i is owned by this module. |
57 | * @param Interface* interface to check against | 57 | * @param Interface* interface to check against |
58 | * @return bool true if i is owned by this module, false otherwise. | 58 | * @return bool true if i is owned by this module, false otherwise. |
59 | */ | 59 | */ |
60 | bool PPPModule::isOwner(Interface *i){ | 60 | bool PPPModule::isOwner(Interface *i){ |
61 | return list.find( i ) != -1; | 61 | return list.find( i ) != -1; |
62 | } | 62 | } |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Create, and return the WLANConfigure Module | 65 | * Create, and return the WLANConfigure Module |
66 | * @return QWidget* pointer to this modules configure. | 66 | * @return QWidget* pointer to this modules configure. |
67 | */ | 67 | */ |
68 | QWidget *PPPModule::configure(Interface *i){ | 68 | QWidget *PPPModule::configure(Interface *i){ |
69 | qDebug("return ModemWidget"); | 69 | qDebug("return ModemWidget"); |
70 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 70 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
71 | 0, "PPPConfig", false, | 71 | 0, "PPPConfig", false, |
72 | Qt::WDestructiveClose ); | 72 | Qt::WDestructiveClose ); |
73 | return pppconfig; | 73 | return pppconfig; |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Create, and return the Information Module | 77 | * Create, and return the Information Module |
78 | * @return QWidget* pointer to this modules info. | 78 | * @return QWidget* pointer to this modules info. |
79 | */ | 79 | */ |
80 | QWidget *PPPModule::information(Interface *i){ | 80 | QWidget *PPPModule::information(Interface *i){ |
81 | // We don't have any advanced pppd information widget yet :-D | 81 | // We don't have any advanced pppd information widget yet :-D |
82 | // TODO ^ | 82 | // TODO ^ |
83 | qDebug("return PPPModule::information"); | 83 | |
84 | // InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i); | 84 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
85 | InterfaceInformationPPP *information = new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | ||
86 | return information; | ||
87 | } | 85 | } |
88 | 86 | ||
89 | /** | 87 | /** |
90 | * Get all active (up or down) interfaces | 88 | * Get all active (up or down) interfaces |
91 | * @return QList<Interface> A list of interfaces that exsist that havn't | 89 | * @return QList<Interface> A list of interfaces that exsist that havn't |
92 | * been called by isOwner() | 90 | * been called by isOwner() |
93 | */ | 91 | */ |
94 | QList<Interface> PPPModule::getInterfaces(){ | 92 | QList<Interface> PPPModule::getInterfaces(){ |
95 | // List all of the files in the peer directory | 93 | // List all of the files in the peer directory |
96 | qDebug("PPPModule::getInterfaces"); | 94 | qDebug("PPPModule::getInterfaces"); |
97 | return list; | 95 | return list; |
98 | } | 96 | } |
99 | 97 | ||
100 | /** | 98 | /** |
101 | * Attempt to add a new interface as defined by name | 99 | * Attempt to add a new interface as defined by name |
102 | * @param name the name of the type of interface that should be created given | 100 | * @param name the name of the type of interface that should be created given |
103 | * by possibleNewInterfaces(); | 101 | * by possibleNewInterfaces(); |
104 | * @return Interface* NULL if it was unable to be created. | 102 | * @return Interface* NULL if it was unable to be created. |
105 | */ | 103 | */ |
106 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 104 | Interface *PPPModule::addNewInterface(const QString &newInterface){ |
107 | 105 | ||
108 | InterfacePPP *ifaceppp; | 106 | InterfacePPP *ifaceppp; |
109 | Interface *iface; | 107 | Interface *iface; |
110 | ifaceppp = new InterfacePPP(); | 108 | ifaceppp = new InterfacePPP(); |
111 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 109 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
112 | imp.showMaximized(); | 110 | imp.showMaximized(); |
113 | if(imp.exec() == QDialog::Accepted ){ | 111 | if(imp.exec() == QDialog::Accepted ){ |
114 | iface = (InterfacePPP*) ifaceppp; | 112 | iface = (InterfacePPP*) ifaceppp; |
115 | iface->setModuleOwner( this ); | 113 | iface->setModuleOwner( this ); |
116 | list.append( iface ); | 114 | list.append( iface ); |
117 | return iface; | 115 | return iface; |
118 | }else { | 116 | }else { |
119 | delete ifaceppp; | 117 | delete ifaceppp; |
120 | iface = NULL; | 118 | iface = NULL; |
121 | } | 119 | } |
122 | return iface; | 120 | return iface; |
123 | } | 121 | } |
124 | 122 | ||
125 | /** | 123 | /** |
126 | * Attempts to remove the interface, doesn't delete i | 124 | * Attempts to remove the interface, doesn't delete i |
127 | * @return bool true if successfull, false otherwise. | 125 | * @return bool true if successfull, false otherwise. |
128 | */ | 126 | */ |
129 | bool PPPModule::remove(Interface *i){ | 127 | bool PPPModule::remove(Interface *i){ |
130 | return list.remove(i); | 128 | return list.remove(i); |
131 | } | 129 | } |
132 | 130 | ||
133 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 131 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
134 | { | 132 | { |
135 | newIfaces.insert(QObject::tr("PPP") , | 133 | newIfaces.insert(QObject::tr("PPP") , |
136 | QObject::tr("generic ppp device")); | 134 | QObject::tr("generic ppp device")); |
137 | } | 135 | } |
138 | 136 | ||
139 | 137 | ||