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 | |||
@@ -31,192 +31,193 @@ | |||
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(); |
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,295 +1,251 @@ | |||
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."); |
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,171 +1,168 @@ | |||
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; |
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 | |||
@@ -507,193 +507,193 @@ void KPPPWidget::sigPPPDDied() { | |||
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(); |
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,317 +1,319 @@ | |||
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 | ||
@@ -660,266 +662,266 @@ 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) { |
@@ -1183,116 +1185,118 @@ void PPPData::setpppdArgumentDefaults() { | |||
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 | |||
@@ -88,196 +88,196 @@ class Config; | |||
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(); |
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 | ||