30 files changed, 1125 insertions, 981 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index 11d4739..3fa2f84 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -1,469 +1,469 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qtabdialog.h> | 31 | #include <qtabdialog.h> |
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | 34 | ||
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | //#include <klocale.h> | 38 | //#include <klocale.h> |
39 | #define i18n QObject::tr | 39 | #define i18n QObject::tr |
40 | //#include <kglobal.h> | 40 | //#include <kglobal.h> |
41 | //#include <kwin.h> | 41 | //#include <kwin.h> |
42 | //#include <kdialogbase.h> | 42 | //#include <kdialogbase.h> |
43 | #include <qvgroupbox.h> | 43 | #include <qvgroupbox.h> |
44 | 44 | ||
45 | #include "pppdata.h" | 45 | #include "pppdata.h" |
46 | #include "accounts.h" | 46 | #include "accounts.h" |
47 | //#include "accounting.h" | 47 | //#include "accounting.h" |
48 | //#include "providerdb.h" | 48 | //#include "providerdb.h" |
49 | #include "edit.h" | 49 | #include "edit.h" |
50 | 50 | ||
51 | void parseargs(char* buf, char** args); | 51 | void parseargs(char* buf, char** args); |
52 | 52 | ||
53 | AccountWidget::AccountWidget( QWidget *parent, const char *name ) | 53 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ), _pppdata(pd) |
55 | { | 55 | { |
56 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 56 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
57 | accountlist_l = new QListBox(this); | 57 | accountlist_l = new QListBox(this); |
58 | 58 | ||
59 | connect(accountlist_l, SIGNAL(highlighted(int)), | 59 | connect(accountlist_l, SIGNAL(highlighted(int)), |
60 | this, SLOT(slotListBoxSelect(int))); | 60 | this, SLOT(slotListBoxSelect(int))); |
61 | connect(accountlist_l, SIGNAL(selected(int)), | 61 | connect(accountlist_l, SIGNAL(selected(int)), |
62 | this, SLOT(editaccount())); | 62 | this, SLOT(editaccount())); |
63 | l1->addWidget(accountlist_l, 10); | 63 | l1->addWidget(accountlist_l, 10); |
64 | 64 | ||
65 | edit_b = new QPushButton(i18n("&Edit..."), this); | 65 | edit_b = new QPushButton(i18n("&Edit..."), this); |
66 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | 66 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); |
67 | QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); | 67 | QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); |
68 | l1->addWidget(edit_b); | 68 | l1->addWidget(edit_b); |
69 | 69 | ||
70 | new_b = new QPushButton(i18n("&New..."), this); | 70 | new_b = new QPushButton(i18n("&New..."), this); |
71 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); | 71 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); |
72 | l1->addWidget(new_b); | 72 | l1->addWidget(new_b); |
73 | QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" | 73 | QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" |
74 | "to the Internet")); | 74 | "to the Internet")); |
75 | 75 | ||
76 | copy_b = new QPushButton(i18n("Co&py"), this); | 76 | copy_b = new QPushButton(i18n("Co&py"), this); |
77 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); | 77 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); |
78 | l1->addWidget(copy_b); | 78 | l1->addWidget(copy_b); |
79 | QWhatsThis::add(copy_b, | 79 | QWhatsThis::add(copy_b, |
80 | i18n("Makes a copy of the selected account. All\n" | 80 | i18n("Makes a copy of the selected account. All\n" |
81 | "settings of the selected account are copied\n" | 81 | "settings of the selected account are copied\n" |
82 | "to a new account, that you can modify to fit your\n" | 82 | "to a new account, that you can modify to fit your\n" |
83 | "needs")); | 83 | "needs")); |
84 | 84 | ||
85 | delete_b = new QPushButton(i18n("De&lete"), this); | 85 | delete_b = new QPushButton(i18n("De&lete"), this); |
86 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); | 86 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); |
87 | l1->addWidget(delete_b); | 87 | l1->addWidget(delete_b); |
88 | QWhatsThis::add(delete_b, | 88 | QWhatsThis::add(delete_b, |
89 | i18n("<p>Deletes the selected account\n\n" | 89 | i18n("<p>Deletes the selected account\n\n" |
90 | "<font color=\"red\"><b>Use with care!</b></font>")); | 90 | "<font color=\"red\"><b>Use with care!</b></font>")); |
91 | 91 | ||
92 | QHBoxLayout *l12 = new QHBoxLayout; | 92 | QHBoxLayout *l12 = new QHBoxLayout; |
93 | l1->addStretch(1); | 93 | l1->addStretch(1); |
94 | l1->addLayout(l12); | 94 | l1->addLayout(l12); |
95 | 95 | ||
96 | // QVBoxLayout *l121 = new QVBoxLayout; | 96 | // QVBoxLayout *l121 = new QVBoxLayout; |
97 | // l12->addLayout(l121); | 97 | // l12->addLayout(l121); |
98 | // l121->addStretch(1); | 98 | // l121->addStretch(1); |
99 | // costlabel = new QLabel(i18n("Phone costs:"), parent); | 99 | // costlabel = new QLabel(i18n("Phone costs:"), parent); |
100 | // costlabel->setEnabled(FALSE); | 100 | // costlabel->setEnabled(FALSE); |
101 | // l121->addWidget(costlabel); | 101 | // l121->addWidget(costlabel); |
102 | 102 | ||
103 | // costedit = new QLineEdit(parent); | 103 | // costedit = new QLineEdit(parent); |
104 | // costedit->setFocusPolicy(QWidget::NoFocus); | 104 | // costedit->setFocusPolicy(QWidget::NoFocus); |
105 | // costedit->setFixedHeight(costedit->sizeHint().height()); | 105 | // costedit->setFixedHeight(costedit->sizeHint().height()); |
106 | // costedit->setEnabled(FALSE); | 106 | // costedit->setEnabled(FALSE); |
107 | // l121->addWidget(costedit); | 107 | // l121->addWidget(costedit); |
108 | // l121->addStretch(1); | 108 | // l121->addStretch(1); |
109 | // QString tmp = i18n("<p>This shows the accumulated phone costs\n" | 109 | // QString tmp = i18n("<p>This shows the accumulated phone costs\n" |
110 | // "for the selected account.\n" | 110 | // "for the selected account.\n" |
111 | // "\n" | 111 | // "\n" |
112 | // "<b>Important</b>: If you have more than one \n" | 112 | // "<b>Important</b>: If you have more than one \n" |
113 | // "account - beware, this is <b>NOT</b> the sum \n" | 113 | // "account - beware, this is <b>NOT</b> the sum \n" |
114 | // "of the phone costs of all your accounts!"); | 114 | // "of the phone costs of all your accounts!"); |
115 | // QWhatsThis::add(costlabel, tmp); | 115 | // QWhatsThis::add(costlabel, tmp); |
116 | // QWhatsThis::add(costedit, tmp); | 116 | // QWhatsThis::add(costedit, tmp); |
117 | 117 | ||
118 | // vollabel = new QLabel(i18n("Volume:"), parent); | 118 | // vollabel = new QLabel(i18n("Volume:"), parent); |
119 | // vollabel->setEnabled(FALSE); | 119 | // vollabel->setEnabled(FALSE); |
120 | // l121->addWidget(vollabel); | 120 | // l121->addWidget(vollabel); |
121 | 121 | ||
122 | // voledit = new QLineEdit(parent,"voledit"); | 122 | // voledit = new QLineEdit(parent,"voledit"); |
123 | // voledit->setFocusPolicy(QWidget::NoFocus); | 123 | // voledit->setFocusPolicy(QWidget::NoFocus); |
124 | // voledit->setFixedHeight(voledit->sizeHint().height()); | 124 | // voledit->setFixedHeight(voledit->sizeHint().height()); |
125 | // voledit->setEnabled(FALSE); | 125 | // voledit->setEnabled(FALSE); |
126 | // l121->addWidget(voledit); | 126 | // l121->addWidget(voledit); |
127 | // tmp = i18n("<p>This shows the number of bytes transferred\n" | 127 | // tmp = i18n("<p>This shows the number of bytes transferred\n" |
128 | // "for the selected account (not for all of your\n" | 128 | // "for the selected account (not for all of your\n" |
129 | // "accounts. You can select what to display in\n" | 129 | // "accounts. You can select what to display in\n" |
130 | // "the accounting dialog.\n" | 130 | // "the accounting dialog.\n" |
131 | // "\n" | 131 | // "\n" |
132 | // "<a href=\"#volaccounting\">More on volume accounting</a>"); | 132 | // "<a href=\"#volaccounting\">More on volume accounting</a>"); |
133 | 133 | ||
134 | // QWhatsThis::add(vollabel,tmp); | 134 | // QWhatsThis::add(vollabel,tmp); |
135 | // QWhatsThis::add(voledit, tmp); | 135 | // QWhatsThis::add(voledit, tmp); |
136 | 136 | ||
137 | // QVBoxLayout *l122 = new QVBoxLayout; | 137 | // QVBoxLayout *l122 = new QVBoxLayout; |
138 | // l12->addStretch(1); | 138 | // l12->addStretch(1); |
139 | // l12->addLayout(l122); | 139 | // l12->addLayout(l122); |
140 | 140 | ||
141 | // l122->addStretch(1); | 141 | // l122->addStretch(1); |
142 | // reset = new QPushButton(i18n("&Reset..."), parent); | 142 | // reset = new QPushButton(i18n("&Reset..."), parent); |
143 | // reset->setEnabled(FALSE); | 143 | // reset->setEnabled(FALSE); |
144 | // connect(reset, SIGNAL(clicked()), | 144 | // connect(reset, SIGNAL(clicked()), |
145 | // this, SLOT(resetClicked())); | 145 | // this, SLOT(resetClicked())); |
146 | // l122->addWidget(reset); | 146 | // l122->addWidget(reset); |
147 | 147 | ||
148 | // log = new QPushButton(i18n("&View Logs"), this); | 148 | // log = new QPushButton(i18n("&View Logs"), this); |
149 | // connect(log, SIGNAL(clicked()), | 149 | // connect(log, SIGNAL(clicked()), |
150 | // this, SLOT(viewLogClicked())); | 150 | // this, SLOT(viewLogClicked())); |
151 | // l122->addWidget(log); | 151 | // l122->addWidget(log); |
152 | // l122->addStretch(1); | 152 | // l122->addStretch(1); |
153 | 153 | ||
154 | //load up account list from gppdata to the list box | 154 | //load up account list from gppdata to the list box |
155 | if(PPPData::data()->count() > 0) { | 155 | if(_pppdata->count() > 0) { |
156 | for(int i=0; i <= PPPData::data()->count()-1; i++) { | 156 | for(int i=0; i <= _pppdata->count()-1; i++) { |
157 | PPPData::data()->setAccountbyIndex(i); | 157 | _pppdata->setAccountbyIndex(i); |
158 | accountlist_l->insertItem(PPPData::data()->accname()); | 158 | accountlist_l->insertItem(_pppdata->accname()); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | // slotListBoxSelect(accountlist_l->currentItem()); | 162 | // slotListBoxSelect(accountlist_l->currentItem()); |
163 | qDebug("setting listview index to %i",PPPData::data()->currentAccountID() ); | 163 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); |
164 | accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() ); | 164 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); |
165 | // slotListBoxSelect( PPPData::data()->currentAccountID()); | 165 | // slotListBoxSelect( _pppdata->currentAccountID()); |
166 | 166 | ||
167 | l1->activate(); | 167 | l1->activate(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | void AccountWidget::slotListBoxSelect(int idx) { | 172 | void AccountWidget::slotListBoxSelect(int idx) { |
173 | delete_b->setEnabled((bool)(idx != -1)); | 173 | delete_b->setEnabled((bool)(idx != -1)); |
174 | edit_b->setEnabled((bool)(idx != -1)); | 174 | edit_b->setEnabled((bool)(idx != -1)); |
175 | copy_b->setEnabled((bool)(idx != -1)); | 175 | copy_b->setEnabled((bool)(idx != -1)); |
176 | if(idx!=-1) { | 176 | if(idx!=-1) { |
177 | qDebug("setting account to %i", idx); | 177 | qDebug("setting account to %i", idx); |
178 | QString account = PPPData::data()->accname(); | 178 | QString account = _pppdata->accname(); |
179 | PPPData::data()->setAccountbyIndex(accountlist_l->currentItem()); | 179 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); |
180 | // PPPData::data()->setAccount(account); | 180 | // _pppdata->setAccount(account); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | // void AccountWidget::viewLogClicked(){ | 185 | // void AccountWidget::viewLogClicked(){ |
186 | 186 | ||
187 | // QApplication::flushX(); | 187 | // QApplication::flushX(); |
188 | // if(fork() == 0) { | 188 | // if(fork() == 0) { |
189 | // setgid(getgid()); | 189 | // setgid(getgid()); |
190 | // setuid(getuid()); | 190 | // setuid(getuid()); |
191 | // system("kppplogview -kppp"); | 191 | // system("kppplogview -kppp"); |
192 | // _exit(0); | 192 | // _exit(0); |
193 | // } | 193 | // } |
194 | // } | 194 | // } |
195 | 195 | ||
196 | 196 | ||
197 | // void AccountWidget::resetClicked(){ | 197 | // void AccountWidget::resetClicked(){ |
198 | // if(accountlist_l->currentItem() == -1) | 198 | // if(accountlist_l->currentItem() == -1) |
199 | // return; | 199 | // return; |
200 | 200 | ||
201 | // // QueryReset dlg(this); | 201 | // // QueryReset dlg(this); |
202 | // // int what = dlg.exec(); | 202 | // // int what = dlg.exec(); |
203 | 203 | ||
204 | // // if(what && QueryReset::COSTS) { | 204 | // // if(what && QueryReset::COSTS) { |
205 | // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); | 205 | // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); |
206 | // // costedit->setText("0"); | 206 | // // costedit->setText("0"); |
207 | // // } | 207 | // // } |
208 | 208 | ||
209 | // // if(what && QueryReset::VOLUME) { | 209 | // // if(what && QueryReset::VOLUME) { |
210 | // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); | 210 | // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); |
211 | // // voledit->setText(prettyPrintVolume(0)); | 211 | // // voledit->setText(prettyPrintVolume(0)); |
212 | // // } | 212 | // // } |
213 | // } | 213 | // } |
214 | 214 | ||
215 | 215 | ||
216 | void AccountWidget::editaccount() { | 216 | void AccountWidget::editaccount() { |
217 | PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 217 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); |
218 | 218 | ||
219 | int result = doTab(); | 219 | int result = doTab(); |
220 | 220 | ||
221 | if(result == QDialog::Accepted) { | 221 | if(result == QDialog::Accepted) { |
222 | accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem()); | 222 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); |
223 | // emit resetaccounts(); | 223 | // emit resetaccounts(); |
224 | PPPData::data()->save(); | 224 | _pppdata->save(); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void AccountWidget::newaccount() { | 229 | void AccountWidget::newaccount() { |
230 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 230 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
231 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); | 231 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | 234 | ||
235 | int result; | 235 | int result; |
236 | // int query = QMessageBox::information(this, | 236 | // int query = QMessageBox::information(this, |
237 | // i18n("Do you want to use the wizard to create the new account or the " | 237 | // i18n("Do you want to use the wizard to create the new account or the " |
238 | // "standard, dialog-based setup?\n" | 238 | // "standard, dialog-based setup?\n" |
239 | // "The wizard is easier and sufficient in most cases. If you need " | 239 | // "The wizard is easier and sufficient in most cases. If you need " |
240 | // "very special settings, you might want to try the standard, " | 240 | // "very special settings, you might want to try the standard, " |
241 | // "dialog-based setup."), | 241 | // "dialog-based setup."), |
242 | // i18n("Create New Account"), | 242 | // i18n("Create New Account"), |
243 | // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); | 243 | // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); |
244 | 244 | ||
245 | // switch(query) { | 245 | // switch(query) { |
246 | // case QMessageBox::Yes: | 246 | // case QMessageBox::Yes: |
247 | // { | 247 | // { |
248 | // if (PPPData::data()->newaccount() == -1) | 248 | // if (_pppdata->newaccount() == -1) |
249 | // return; | 249 | // return; |
250 | // // ProviderDB pdb(this); | 250 | // // ProviderDB pdb(this); |
251 | // // result = pdb.exec(); | 251 | // // result = pdb.exec(); |
252 | // break; | 252 | // break; |
253 | // } | 253 | // } |
254 | // case QMessageBox::No: | 254 | // case QMessageBox::No: |
255 | if (PPPData::data()->newaccount() == -1){ | 255 | if (_pppdata->newaccount() == -1){ |
256 | qDebug("PPPData::data()->newaccount() == -1"); | 256 | qDebug("_pppdata->newaccount() == -1"); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | result = doTab(); | 259 | result = doTab(); |
260 | // break; | 260 | // break; |
261 | // default: | 261 | // default: |
262 | // return; | 262 | // return; |
263 | // } | 263 | // } |
264 | 264 | ||
265 | if(result == QDialog::Accepted) { | 265 | if(result == QDialog::Accepted) { |
266 | accountlist_l->insertItem(PPPData::data()->accname()); | 266 | accountlist_l->insertItem(_pppdata->accname()); |
267 | accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()), | 267 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()), |
268 | true); | 268 | true); |
269 | // emit resetaccounts(); | 269 | // emit resetaccounts(); |
270 | PPPData::data()->save(); | 270 | _pppdata->save(); |
271 | } else | 271 | } else |
272 | PPPData::data()->deleteAccount(); | 272 | _pppdata->deleteAccount(); |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | void AccountWidget::copyaccount() { | 276 | void AccountWidget::copyaccount() { |
277 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 277 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
278 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); | 278 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); |
279 | return; | 279 | return; |
280 | } | 280 | } |
281 | 281 | ||
282 | if(accountlist_l->currentItem()<0) { | 282 | if(accountlist_l->currentItem()<0) { |
283 | QMessageBox::information(this, "sorry", i18n("No account selected.")); | 283 | QMessageBox::information(this, "sorry", i18n("No account selected.")); |
284 | return; | 284 | return; |
285 | } | 285 | } |
286 | 286 | ||
287 | PPPData::data()->copyaccount(accountlist_l->currentItem()); | 287 | _pppdata->copyaccount(accountlist_l->currentItem()); |
288 | 288 | ||
289 | accountlist_l->insertItem(PPPData::data()->accname()); | 289 | accountlist_l->insertItem(_pppdata->accname()); |
290 | // emit resetaccounts(); | 290 | // emit resetaccounts(); |
291 | PPPData::data()->save(); | 291 | _pppdata->save(); |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | void AccountWidget::deleteaccount() { | 295 | void AccountWidget::deleteaccount() { |
296 | 296 | ||
297 | QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") | 297 | QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") |
298 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 298 | .arg(accountlist_l->text(accountlist_l->currentItem())); |
299 | 299 | ||
300 | if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) | 300 | if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) |
301 | return; | 301 | return; |
302 | 302 | ||
303 | if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 303 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) |
304 | accountlist_l->removeItem(accountlist_l->currentItem()); | 304 | accountlist_l->removeItem(accountlist_l->currentItem()); |
305 | 305 | ||
306 | emit resetaccounts(); | 306 | emit resetaccounts(); |
307 | PPPData::data()->save(); | 307 | _pppdata->save(); |
308 | 308 | ||
309 | slotListBoxSelect(accountlist_l->currentItem()); | 309 | slotListBoxSelect(accountlist_l->currentItem()); |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | int AccountWidget::doTab(){ | 314 | int AccountWidget::doTab(){ |
315 | QDialog *dlg = new QDialog( this, "newAccount", true ); | 315 | QDialog *dlg = new QDialog( this, "newAccount", true ); |
316 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 316 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
317 | layout->setSpacing( 0 ); | 317 | layout->setSpacing( 0 ); |
318 | layout->setMargin( 1 ); | 318 | layout->setMargin( 1 ); |
319 | 319 | ||
320 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 320 | tabWindow = new QTabWidget( dlg, "tabWindow" ); |
321 | layout->addWidget( tabWindow ); | 321 | layout->addWidget( tabWindow ); |
322 | 322 | ||
323 | bool isnewaccount; | 323 | bool isnewaccount; |
324 | 324 | ||
325 | if(PPPData::data()->accname().isEmpty()) { | 325 | if(_pppdata->accname().isEmpty()) { |
326 | dlg->setCaption(i18n("New Account")); | 326 | dlg->setCaption(i18n("New Account")); |
327 | isnewaccount = true; | 327 | isnewaccount = true; |
328 | } else { | 328 | } else { |
329 | QString tit = i18n("Edit Account: "); | 329 | QString tit = i18n("Edit Account: "); |
330 | tit += PPPData::data()->accname(); | 330 | tit += _pppdata->accname(); |
331 | dlg->setCaption(tit); | 331 | dlg->setCaption(tit); |
332 | isnewaccount = false; | 332 | isnewaccount = false; |
333 | } | 333 | } |
334 | 334 | ||
335 | dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup"); | 335 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
336 | tabWindow->addTab( dial_w, i18n("Dial") ); | 336 | tabWindow->addTab( dial_w, i18n("Dial") ); |
337 | ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup")); | 337 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup")); |
338 | tabWindow->addTab( ip_w, i18n("IP") ); | 338 | tabWindow->addTab( ip_w, i18n("IP") ); |
339 | gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup")); | 339 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup")); |
340 | tabWindow->addTab( gateway_w, i18n("Gateway") ); | 340 | tabWindow->addTab( gateway_w, i18n("Gateway") ); |
341 | dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") ); | 341 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") ); |
342 | tabWindow->addTab( dns_w, i18n("DNS") ); | 342 | tabWindow->addTab( dns_w, i18n("DNS") ); |
343 | script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script")); | 343 | script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script")); |
344 | tabWindow->addTab( script_w, i18n("Login Script") ); | 344 | tabWindow->addTab( script_w, i18n("Login Script") ); |
345 | ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs")); | 345 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs")); |
346 | tabWindow->addTab( exec_w, i18n("Execute") ); | 346 | tabWindow->addTab( exec_w, i18n("Execute") ); |
347 | // acct = new AccountingSelector( tabWindow, isnewaccount ); | 347 | // acct = new AccountingSelector( tabWindow, isnewaccount ); |
348 | // tabWindow->addTab( acct, i18n("Accounting")); | 348 | // tabWindow->addTab( acct, i18n("Accounting")); |
349 | 349 | ||
350 | int result = 0; | 350 | int result = 0; |
351 | bool ok = false; | 351 | bool ok = false; |
352 | qDebug("AccountWidget::doTab dlg->showMinimized"); | 352 | qDebug("AccountWidget::doTab dlg->showMinimized"); |
353 | dlg->showMinimized(); | 353 | dlg->showMinimized(); |
354 | while (!ok){ | 354 | while (!ok){ |
355 | 355 | ||
356 | result = dlg->exec(); | 356 | result = dlg->exec(); |
357 | ok = true; | 357 | ok = true; |
358 | 358 | ||
359 | if(result == QDialog::Accepted) { | 359 | if(result == QDialog::Accepted) { |
360 | if (script_w->check()) { | 360 | if (script_w->check()) { |
361 | if(dial_w->save()) { | 361 | if(dial_w->save()) { |
362 | ip_w->save(); | 362 | ip_w->save(); |
363 | dns_w->save(); | 363 | dns_w->save(); |
364 | gateway_w->save(); | 364 | gateway_w->save(); |
365 | script_w->save(); | 365 | script_w->save(); |
366 | exec_w->save(); | 366 | exec_w->save(); |
367 | // acct->save(); | 367 | // acct->save(); |
368 | } else { | 368 | } else { |
369 | QMessageBox::critical(this, "error", i18n( "You must enter a unique\n" | 369 | QMessageBox::critical(this, "error", i18n( "You must enter a unique\n" |
370 | "account name")); | 370 | "account name")); |
371 | ok = false; | 371 | ok = false; |
372 | } | 372 | } |
373 | } else { | 373 | } else { |
374 | QMessageBox::critical(this, "error", i18n("Login script has unbalanced " | 374 | QMessageBox::critical(this, "error", i18n("Login script has unbalanced " |
375 | "loop Start/End")); | 375 | "loop Start/End")); |
376 | ok = false; | 376 | ok = false; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | delete tabWindow; | 381 | delete tabWindow; |
382 | return result; | 382 | return result; |
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | QString AccountWidget::prettyPrintVolume(unsigned int n) { | 386 | QString AccountWidget::prettyPrintVolume(unsigned int n) { |
387 | int idx = 0; | 387 | int idx = 0; |
388 | const QString quant[] = {i18n("Byte"), i18n("KB"), | 388 | const QString quant[] = {i18n("Byte"), i18n("KB"), |
389 | i18n("MB"), i18n("GB"), QString::null}; | 389 | i18n("MB"), i18n("GB"), QString::null}; |
390 | 390 | ||
391 | float n1 = n; | 391 | float n1 = n; |
392 | while(n >= 1024 && quant[idx] != QString::null) { | 392 | while(n >= 1024 && quant[idx] != QString::null) { |
393 | idx++; | 393 | idx++; |
394 | n /= 1024; | 394 | n /= 1024; |
395 | } | 395 | } |
396 | 396 | ||
397 | int i = idx; | 397 | int i = idx; |
398 | while(i--) | 398 | while(i--) |
399 | n1 = n1 / 1024.0; | 399 | n1 = n1 / 1024.0; |
400 | 400 | ||
401 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); | 401 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); |
402 | s += " " + quant[idx]; | 402 | s += " " + quant[idx]; |
403 | return s; | 403 | return s; |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | ///////////////////////////////////////////////////////////////////////////// | 407 | ///////////////////////////////////////////////////////////////////////////// |
408 | // | 408 | // |
409 | // Queries the user what to reset: costs, volume or both | 409 | // Queries the user what to reset: costs, volume or both |
410 | // | 410 | // |
411 | ///////////////////////////////////////////////////////////////////////////// | 411 | ///////////////////////////////////////////////////////////////////////////// |
412 | QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { | 412 | QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { |
413 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 413 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
414 | setCaption(i18n("Reset Accounting")); | 414 | setCaption(i18n("Reset Accounting")); |
415 | 415 | ||
416 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 416 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
417 | QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this); | 417 | QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this); |
418 | 418 | ||
419 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 419 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
420 | // costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f); | 420 | // costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f); |
421 | // costs->setChecked(true); | 421 | // costs->setChecked(true); |
422 | // l1->addWidget(costs); | 422 | // l1->addWidget(costs); |
423 | // QWhatsThis::add(costs, i18n("Check this to set the phone costs\n" | 423 | // QWhatsThis::add(costs, i18n("Check this to set the phone costs\n" |
424 | // "to zero. Typically you'll want to\n" | 424 | // "to zero. Typically you'll want to\n" |
425 | // "do this once a month.")); | 425 | // "do this once a month.")); |
426 | 426 | ||
427 | // volume = new QCheckBox(i18n("Reset volume accounting"), f); | 427 | // volume = new QCheckBox(i18n("Reset volume accounting"), f); |
428 | // volume->setChecked(true); | 428 | // volume->setChecked(true); |
429 | // l1->addWidget(volume); | 429 | // l1->addWidget(volume); |
430 | // QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n" | 430 | // QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n" |
431 | // "to zero. Typically you'll want to do this\n" | 431 | // "to zero. Typically you'll want to do this\n" |
432 | // "once a month.")); | 432 | // "once a month.")); |
433 | 433 | ||
434 | l1->activate(); | 434 | l1->activate(); |
435 | 435 | ||
436 | // this activates the f-layout and sets minimumSize() | 436 | // this activates the f-layout and sets minimumSize() |
437 | f->show(); | 437 | f->show(); |
438 | 438 | ||
439 | tl->addWidget(f); | 439 | tl->addWidget(f); |
440 | 440 | ||
441 | QButtonGroup *bbox = new QButtonGroup(this); | 441 | QButtonGroup *bbox = new QButtonGroup(this); |
442 | // bbox->addStretch(1); | 442 | // bbox->addStretch(1); |
443 | QPushButton *ok = new QPushButton( bbox, i18n("OK") ); | 443 | QPushButton *ok = new QPushButton( bbox, i18n("OK") ); |
444 | bbox->insert(ok); | 444 | bbox->insert(ok); |
445 | ok->setDefault(true); | 445 | ok->setDefault(true); |
446 | QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") ); | 446 | QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") ); |
447 | bbox->insert(cancel); | 447 | bbox->insert(cancel); |
448 | 448 | ||
449 | connect(ok, SIGNAL(clicked()), | 449 | connect(ok, SIGNAL(clicked()), |
450 | this, SLOT(accepted())); | 450 | this, SLOT(accepted())); |
451 | connect(cancel, SIGNAL(clicked()), | 451 | connect(cancel, SIGNAL(clicked()), |
452 | this, SLOT(reject())); | 452 | this, SLOT(reject())); |
453 | 453 | ||
454 | bbox->layout(); | 454 | bbox->layout(); |
455 | tl->addWidget(bbox); | 455 | tl->addWidget(bbox); |
456 | 456 | ||
457 | // TODO: activate if KGroupBox is fixed | 457 | // TODO: activate if KGroupBox is fixed |
458 | // setFixedSize(sizeHint()); | 458 | // setFixedSize(sizeHint()); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | void QueryReset::accepted() { | 462 | void QueryReset::accepted() { |
463 | int result = costs->isChecked() ? COSTS : 0; | 463 | int result = costs->isChecked() ? COSTS : 0; |
464 | result += volume->isChecked() ? VOLUME : 0; | 464 | result += volume->isChecked() ? VOLUME : 0; |
465 | 465 | ||
466 | done(result); | 466 | done(result); |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h index 751a414..5e8509d 100644 --- a/noncore/settings/networksettings/ppp/accounts.h +++ b/noncore/settings/networksettings/ppp/accounts.h | |||
@@ -1,110 +1,112 @@ | |||
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 ScriptWidget; |
42 | class IPWidget; | 42 | class IPWidget; |
43 | class DNSWidget; | 43 | class DNSWidget; |
44 | class GatewayWidget; | 44 | class GatewayWidget; |
45 | class PPPData; | ||
45 | 46 | ||
46 | class AccountWidget : public QWidget { | 47 | class AccountWidget : public QWidget { |
47 | Q_OBJECT | 48 | Q_OBJECT |
48 | public: | 49 | public: |
49 | AccountWidget( QWidget *parent=0, const char *name=0 ); | 50 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 ); |
50 | ~AccountWidget() {} | 51 | ~AccountWidget() {} |
51 | 52 | ||
52 | private slots: | 53 | private slots: |
53 | void editaccount(); | 54 | void editaccount(); |
54 | void copyaccount(); | 55 | void copyaccount(); |
55 | void newaccount(); | 56 | void newaccount(); |
56 | void deleteaccount(); | 57 | void deleteaccount(); |
57 | void slotListBoxSelect(int); | 58 | void slotListBoxSelect(int); |
58 | // void resetClicked(); | 59 | // void resetClicked(); |
59 | // void viewLogClicked(); | 60 | // void viewLogClicked(); |
60 | 61 | ||
61 | private: | 62 | private: |
62 | int doTab(); | 63 | int doTab(); |
63 | 64 | ||
64 | signals: | 65 | signals: |
65 | void resetaccounts(); | 66 | void resetaccounts(); |
66 | // void resetCosts(const QString &); | 67 | // void resetCosts(const QString &); |
67 | // void resetVolume(const QString &); | 68 | // void resetVolume(const QString &); |
68 | 69 | ||
69 | private: | 70 | private: |
70 | QString prettyPrintVolume(unsigned int); | 71 | QString prettyPrintVolume(unsigned int); |
71 | 72 | ||
73 | PPPData *_pppdata; | ||
72 | QTabWidget *tabWindow; | 74 | QTabWidget *tabWindow; |
73 | DialWidget *dial_w; | 75 | DialWidget *dial_w; |
74 | // AccountingSelector *acct; | 76 | // AccountingSelector *acct; |
75 | IPWidget *ip_w; | 77 | IPWidget *ip_w; |
76 | DNSWidget *dns_w; | 78 | DNSWidget *dns_w; |
77 | GatewayWidget *gateway_w; | 79 | GatewayWidget *gateway_w; |
78 | ScriptWidget *script_w; | 80 | ScriptWidget *script_w; |
79 | 81 | ||
80 | // QPushButton *reset; | 82 | // QPushButton *reset; |
81 | // QPushButton *log; | 83 | // QPushButton *log; |
82 | // QLabel *costlabel; | 84 | // QLabel *costlabel; |
83 | // QLineEdit *costedit; | 85 | // QLineEdit *costedit; |
84 | // QLabel *vollabel; | 86 | // QLabel *vollabel; |
85 | // QLineEdit *voledit; | 87 | // QLineEdit *voledit; |
86 | 88 | ||
87 | QListBox *accountlist_l; | 89 | QListBox *accountlist_l; |
88 | QPushButton *edit_b; | 90 | QPushButton *edit_b; |
89 | QPushButton *copy_b; | 91 | QPushButton *copy_b; |
90 | QPushButton *new_b; | 92 | QPushButton *new_b; |
91 | QPushButton *delete_b; | 93 | QPushButton *delete_b; |
92 | }; | 94 | }; |
93 | 95 | ||
94 | 96 | ||
95 | class QueryReset : public QDialog { | 97 | class QueryReset : public QDialog { |
96 | Q_OBJECT | 98 | Q_OBJECT |
97 | public: | 99 | public: |
98 | QueryReset(QWidget *parent); | 100 | QueryReset(QWidget *parent); |
99 | 101 | ||
100 | enum {COSTS=1, VOLUME=2}; | 102 | enum {COSTS=1, VOLUME=2}; |
101 | 103 | ||
102 | private slots: | 104 | private slots: |
103 | void accepted(); | 105 | void accepted(); |
104 | 106 | ||
105 | private: | 107 | private: |
106 | QCheckBox *costs, *volume; | 108 | QCheckBox *costs, *volume; |
107 | }; | 109 | }; |
108 | 110 | ||
109 | #endif | 111 | #endif |
110 | 112 | ||
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index a3eda9d..2615b60 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1,1438 +1,1434 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> | 7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | //#include <config.h> | 27 | //#include <config.h> |
28 | 28 | ||
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qregexp.h> | 30 | #include <qregexp.h> |
31 | 31 | ||
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <kdebug.h> | 33 | //#include <kdebug.h> |
34 | //#include <klocale.h> | 34 | //#include <klocale.h> |
35 | #define i18n QObject::tr | 35 | #define i18n QObject::tr |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | 38 | ||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <fcntl.h> | 42 | #include <fcntl.h> |
43 | #include <netdb.h> | 43 | #include <netdb.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 47 | #include <netinet/in.h> |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #ifdef _XPG4_2 | 51 | #ifdef _XPG4_2 |
52 | #define __xnet_connectconnect | 52 | #define __xnet_connectconnect |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #include <errno.h> | 55 | #include <errno.h> |
56 | 56 | ||
57 | #ifdef HAVE_SYS_PARAM_H | 57 | #ifdef HAVE_SYS_PARAM_H |
58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #ifdef __linux__ | 61 | #ifdef __linux__ |
62 | #include "runtests.h" | 62 | #include "runtests.h" |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #include "auth.h" | 65 | #include "auth.h" |
66 | #include "connect.h" | 66 | #include "connect.h" |
67 | //#include "docking.h" | 67 | //#include "docking.h" |
68 | //#include "main.h" | 68 | #include "interfaceppp.h" |
69 | #include "modem.h" | 69 | #include "modem.h" |
70 | #include "kpppconfig.h" | 70 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 71 | #include "pppdata.h" |
72 | #include "kpppwidget.h" | 72 | #include "kpppwidget.h" |
73 | //#include "requester.h" | 73 | //#include "requester.h" |
74 | //#include "utils.h" | 74 | //#include "utils.h" |
75 | #define execute_command system | 75 | #define execute_command system |
76 | 76 | ||
77 | extern KPPPWidget *p_kppp; | ||
78 | |||
79 | QString old_hostname; | 77 | QString old_hostname; |
80 | bool modified_hostname; | 78 | bool modified_hostname; |
81 | 79 | ||
82 | 80 | ||
83 | ConnectWidget::ConnectWidget(QWidget *parent, const char *name) | 81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
84 | : QWidget(parent, name), | 82 | : QWidget(parent, name), |
85 | // initialize some important variables | ||
86 | myreadbuffer(""), | 83 | myreadbuffer(""), |
87 | main_timer_ID(0), | 84 | main_timer_ID(0), |
88 | vmain(0), | 85 | vmain(0), |
89 | substate(-1), | 86 | substate(-1), |
90 | scriptindex(0), | 87 | scriptindex(0), |
91 | loopnest(0), | 88 | loopnest(0), |
92 | loopend(false), | 89 | loopend(false), |
93 | semaphore(false), | 90 | semaphore(false), |
94 | expecting(false), | 91 | expecting(false), |
95 | readbuffer(""), | 92 | readbuffer(""), |
96 | scanvar(""), | 93 | scanvar(""), |
97 | scanning(false), | 94 | scanning(false), |
98 | pausing(false), | 95 | pausing(false), |
99 | // termwindow(0), | 96 | dialnumber(0), |
100 | // stats(st), | 97 | _ifaceppp(ifp) |
101 | dialnumber(0) | ||
102 | { | 98 | { |
103 | modified_hostname = false; | 99 | modified_hostname = false; |
104 | 100 | ||
105 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
106 | QString tit = i18n("Connecting to: "); | 102 | QString tit = i18n("Connecting to: "); |
107 | setCaption(tit); | 103 | setCaption(tit); |
108 | 104 | ||
109 | QHBoxLayout *l0 = new QHBoxLayout(10); | 105 | QHBoxLayout *l0 = new QHBoxLayout(10); |
110 | tl->addLayout(l0); | 106 | tl->addLayout(l0); |
111 | l0->addSpacing(10); | 107 | l0->addSpacing(10); |
112 | messg = new QLabel(this, "messg"); | 108 | messg = new QLabel(this, "messg"); |
113 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
114 | messg->setAlignment(AlignCenter); | 110 | messg->setAlignment(AlignCenter); |
115 | messg->setText(i18n("Unable to create modem lock file.")); | 111 | messg->setText(i18n("Unable to create modem lock file.")); |
116 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
117 | int messw = (messg->sizeHint().width() * 12) / 10; | 113 | int messw = (messg->sizeHint().width() * 12) / 10; |
118 | messw = QMAX(messw,280); | 114 | messw = QMAX(messw,280); |
119 | messg->setMinimumWidth(messw); | 115 | messg->setMinimumWidth(messw); |
120 | messg->setText(i18n("Looking for modem...")); | 116 | messg->setText(i18n("Looking for modem...")); |
121 | l0->addSpacing(10); | 117 | l0->addSpacing(10); |
122 | l0->addWidget(messg); | 118 | l0->addWidget(messg); |
123 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
124 | 120 | ||
125 | QHBoxLayout *l1 = new QHBoxLayout(10); | 121 | QHBoxLayout *l1 = new QHBoxLayout(10); |
126 | tl->addLayout(l1); | 122 | tl->addLayout(l1); |
127 | l1->addStretch(1); | 123 | l1->addStretch(1); |
128 | 124 | ||
129 | debug = new QPushButton(i18n("Log"), this); | 125 | debug = new QPushButton(i18n("Log"), this); |
130 | debug->setToggleButton(true); | 126 | debug->setToggleButton(true); |
131 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 127 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
132 | 128 | ||
133 | cancel = new QPushButton(i18n("Cancel"), this); | 129 | cancel = new QPushButton(i18n("Cancel"), this); |
134 | cancel->setFocus(); | 130 | cancel->setFocus(); |
135 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
136 | 132 | ||
137 | int maxw = QMAX(cancel->sizeHint().width(), | 133 | int maxw = QMAX(cancel->sizeHint().width(), |
138 | debug->sizeHint().width()); | 134 | debug->sizeHint().width()); |
139 | maxw = QMAX(maxw,65); | 135 | maxw = QMAX(maxw,65); |
140 | debug->setFixedWidth(maxw); | 136 | debug->setFixedWidth(maxw); |
141 | cancel->setFixedWidth(maxw); | 137 | cancel->setFixedWidth(maxw); |
142 | l1->addWidget(debug); | 138 | l1->addWidget(debug); |
143 | l1->addWidget(cancel); | 139 | l1->addWidget(cancel); |
144 | 140 | ||
145 | setFixedSize(sizeHint()); | 141 | setFixedSize(sizeHint()); |
146 | 142 | ||
147 | pausetimer = new QTimer(this); | 143 | pausetimer = new QTimer(this); |
148 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
149 | 145 | ||
150 | qApp->processEvents(); | 146 | qApp->processEvents(); |
151 | 147 | ||
152 | timeout_timer = new QTimer(this); | 148 | timeout_timer = new QTimer(this); |
153 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); | 149 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); |
154 | 150 | ||
155 | inittimer = new QTimer(this); | 151 | inittimer = new QTimer(this); |
156 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); | 152 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); |
157 | 153 | ||
158 | if_timeout_timer = new QTimer(this); | 154 | if_timeout_timer = new QTimer(this); |
159 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); | 155 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); |
160 | 156 | ||
161 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); | 157 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); |
162 | 158 | ||
163 | prompt = new PWEntry( this, "pw" ); | 159 | prompt = new PWEntry( this, "pw" ); |
164 | if_timer = new QTimer(this); | 160 | if_timer = new QTimer(this); |
165 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 161 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
166 | } | 162 | } |
167 | 163 | ||
168 | 164 | ||
169 | ConnectWidget::~ConnectWidget() { | 165 | ConnectWidget::~ConnectWidget() { |
170 | } | 166 | } |
171 | 167 | ||
172 | 168 | ||
173 | void ConnectWidget::preinit() { | 169 | void ConnectWidget::preinit() { |
174 | // this is all just to keep the GUI nice and snappy .... | 170 | // this is all just to keep the GUI nice and snappy .... |
175 | // you have to see to believe ... | 171 | // you have to see to believe ... |
176 | messg->setText(i18n("Looking for modem...")); | 172 | messg->setText(i18n("Looking for modem...")); |
177 | inittimer->start(100); | 173 | inittimer->start(100); |
178 | } | 174 | } |
179 | 175 | ||
180 | 176 | ||
181 | void ConnectWidget::init() { | 177 | void ConnectWidget::init() { |
182 | PPPData::data()->setpppdError(0); | 178 | _ifaceppp->data()->setpppdError(0); |
183 | inittimer->stop(); | 179 | inittimer->stop(); |
184 | vmain = 0; | 180 | vmain = 0; |
185 | substate = -1; | 181 | substate = -1; |
186 | expecting = false; | 182 | expecting = false; |
187 | pausing = false; | 183 | pausing = false; |
188 | scriptindex = 0; | 184 | scriptindex = 0; |
189 | myreadbuffer = ""; | 185 | myreadbuffer = ""; |
190 | scanning = false; | 186 | scanning = false; |
191 | scanvar = ""; | 187 | scanvar = ""; |
192 | firstrunID = true; | 188 | firstrunID = true; |
193 | firstrunPW = true; | 189 | firstrunPW = true; |
194 | // stats->totalbytes = 0; | 190 | // stats->totalbytes = 0; |
195 | dialnumber = 0; | 191 | dialnumber = 0; |
196 | 192 | ||
197 | p_kppp->con_speed = ""; | 193 | // p_kppp->con_speed = ""; |
198 | 194 | ||
199 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect()); | 195 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
200 | 196 | ||
201 | comlist = &PPPData::data()->scriptType(); | 197 | comlist = &_ifaceppp->data()->scriptType(); |
202 | arglist = &PPPData::data()->script(); | 198 | arglist = &_ifaceppp->data()->script(); |
203 | 199 | ||
204 | QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); | 200 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
205 | setCaption(tit); | 201 | setCaption(tit); |
206 | 202 | ||
207 | qApp->processEvents(); | 203 | qApp->processEvents(); |
208 | 204 | ||
209 | // run the "before-connect" command | 205 | // run the "before-connect" command |
210 | if (!PPPData::data()->command_before_connect().isEmpty()) { | 206 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
211 | messg->setText(i18n("Running pre-startup command...")); | 207 | messg->setText(i18n("Running pre-startup command...")); |
212 | emit debugMessage(i18n("Running pre-startup command...")); | 208 | emit debugMessage(i18n("Running pre-startup command...")); |
213 | 209 | ||
214 | qApp->processEvents(); | 210 | qApp->processEvents(); |
215 | QApplication::flushX(); | 211 | QApplication::flushX(); |
216 | pid_t id = execute_command(PPPData::data()->command_before_connect()); | 212 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
217 | // int i, status; | 213 | // int i, status; |
218 | 214 | ||
219 | // do { | 215 | // do { |
220 | // qApp->processEvents(); | 216 | // qApp->processEvents(); |
221 | // i = waitpid(id, &status, WNOHANG); | 217 | // i = waitpid(id, &status, WNOHANG); |
222 | // usleep(100000); | 218 | // usleep(100000); |
223 | // } while (i == 0 && errno == 0); | 219 | // } while (i == 0 && errno == 0); |
224 | } | 220 | } |
225 | 221 | ||
226 | int lock = Modem::modem->lockdevice(); | 222 | int lock = _ifaceppp->modem()->lockdevice(); |
227 | 223 | ||
228 | if (lock == 1) { | 224 | if (lock == 1) { |
229 | messg->setText(i18n("Modem device is locked.")); | 225 | messg->setText(i18n("Modem device is locked.")); |
230 | vmain = 20; // wait until cancel is pressed | 226 | vmain = 20; // wait until cancel is pressed |
231 | return; | 227 | return; |
232 | } | 228 | } |
233 | 229 | ||
234 | if (lock == -1) { | 230 | if (lock == -1) { |
235 | messg->setText(i18n("Unable to create modem lock file.")); | 231 | messg->setText(i18n("Unable to create modem lock file.")); |
236 | vmain = 20; // wait until cancel is pressed | 232 | vmain = 20; // wait until cancel is pressed |
237 | return; | 233 | return; |
238 | } | 234 | } |
239 | 235 | ||
240 | if(Modem::modem->opentty()) { | 236 | if(_ifaceppp->modem()->opentty()) { |
241 | messg->setText(Modem::modem->modemMessage()); | 237 | messg->setText(_ifaceppp->modem()->modemMessage()); |
242 | qApp->processEvents(); | 238 | qApp->processEvents(); |
243 | if(Modem::modem->hangup()) { | 239 | if(_ifaceppp->modem()->hangup()) { |
244 | 240 | ||
245 | qApp->processEvents(); | 241 | qApp->processEvents(); |
246 | 242 | ||
247 | semaphore = false; | 243 | semaphore = false; |
248 | 244 | ||
249 | Modem::modem->stop(); | 245 | _ifaceppp->modem()->stop(); |
250 | Modem::modem->notify(this, SLOT(readChar(unsigned char))); | 246 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
251 | 247 | ||
252 | // if we are stuck anywhere we will time out | 248 | // if we are stuck anywhere we will time out |
253 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 249 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
254 | 250 | ||
255 | // this timer will run the script etc. | 251 | // this timer will run the script etc. |
256 | main_timer_ID = startTimer(10); | 252 | main_timer_ID = startTimer(10); |
257 | 253 | ||
258 | return; | 254 | return; |
259 | } | 255 | } |
260 | } | 256 | } |
261 | 257 | ||
262 | // initialization failed | 258 | // initialization failed |
263 | messg->setText(Modem::modem->modemMessage()); | 259 | messg->setText(_ifaceppp->modem()->modemMessage()); |
264 | vmain = 20; // wait until cancel is pressed | 260 | vmain = 20; // wait until cancel is pressed |
265 | Modem::modem->unlockdevice(); | 261 | _ifaceppp->modem()->unlockdevice(); |
266 | } | 262 | } |
267 | 263 | ||
268 | 264 | ||
269 | void ConnectWidget::timerEvent(QTimerEvent *) { | 265 | void ConnectWidget::timerEvent(QTimerEvent *) { |
270 | if (semaphore || pausing) | 266 | if (semaphore || pausing) |
271 | return; | 267 | return; |
272 | 268 | ||
273 | if(vmain == 0) { | 269 | if(vmain == 0) { |
274 | #ifdef DEBUG_WO_DIALING | 270 | #ifdef DEBUG_WO_DIALING |
275 | vmain = 10; | 271 | vmain = 10; |
276 | return; | 272 | return; |
277 | #endif | 273 | #endif |
278 | 274 | ||
279 | assert(PPPData::NumInitStrings > 0); | 275 | assert(PPPData::NumInitStrings > 0); |
280 | // first init string ? | 276 | // first init string ? |
281 | if(substate == -1) { | 277 | if(substate == -1) { |
282 | messg->setText(i18n("Initializing modem...")); | 278 | messg->setText(i18n("Initializing modem...")); |
283 | emit debugMessage(i18n("Initializing modem...")); | 279 | emit debugMessage(i18n("Initializing modem...")); |
284 | substate = 0; | 280 | substate = 0; |
285 | } | 281 | } |
286 | 282 | ||
287 | QString initStr = PPPData::data()->modemInitStr(substate); | 283 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
288 | if (!initStr.isEmpty()) { | 284 | if (!initStr.isEmpty()) { |
289 | // send a carriage return and then wait a bit so that the modem will | 285 | // send a carriage return and then wait a bit so that the modem will |
290 | // let us issue commands. | 286 | // let us issue commands. |
291 | if(PPPData::data()->modemPreInitDelay() > 0) { | 287 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
292 | usleep(PPPData::data()->modemPreInitDelay() * 5000); | 288 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
293 | writeline(""); | 289 | writeline(""); |
294 | usleep(PPPData::data()->modemPreInitDelay() * 5000); | 290 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
295 | } | 291 | } |
296 | setExpect(PPPData::data()->modemInitResp()); | 292 | setExpect(_ifaceppp->data()->modemInitResp()); |
297 | writeline(initStr); | 293 | writeline(initStr); |
298 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 294 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
299 | } | 295 | } |
300 | 296 | ||
301 | substate++; | 297 | substate++; |
302 | 298 | ||
303 | /* | 299 | /* |
304 | * FIXME after 3.0: Make it possible to disable ATS11 since it | 300 | * FIXME after 3.0: Make it possible to disable ATS11 since it |
305 | * seems to be incompatible with some ISDN adapters (e.g. DataBox | 301 | * seems to be incompatible with some ISDN adapters (e.g. DataBox |
306 | * Speed Dragon). Even better would be to detect this when doing | 302 | * Speed Dragon). Even better would be to detect this when doing |
307 | * a "Modem Query" | 303 | * a "Modem Query" |
308 | */ | 304 | */ |
309 | if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration()) | 305 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
310 | vmain = 5; | 306 | vmain = 5; |
311 | else | 307 | else |
312 | vmain = 3; | 308 | vmain = 3; |
313 | 309 | ||
314 | return; | 310 | return; |
315 | } | 311 | } |
316 | 312 | ||
317 | if (vmain == 5) { | 313 | if (vmain == 5) { |
318 | if(!expecting) { | 314 | if(!expecting) { |
319 | QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration()); | 315 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
320 | QString msg = i18n("Setting ") + sToneDuration; | 316 | QString msg = i18n("Setting ") + sToneDuration; |
321 | messg->setText(msg); | 317 | messg->setText(msg); |
322 | emit debugMessage(msg); | 318 | emit debugMessage(msg); |
323 | setExpect(PPPData::data()->modemInitResp()); | 319 | setExpect(_ifaceppp->data()->modemInitResp()); |
324 | writeline(sToneDuration); | 320 | writeline(sToneDuration); |
325 | } | 321 | } |
326 | vmain = 3; | 322 | vmain = 3; |
327 | return; | 323 | return; |
328 | } | 324 | } |
329 | 325 | ||
330 | if(vmain == 3) { | 326 | if(vmain == 3) { |
331 | if(!expecting) { | 327 | if(!expecting) { |
332 | // done with all init strings ? | 328 | // done with all init strings ? |
333 | if(substate < PPPData::NumInitStrings) { | 329 | if(substate < PPPData::NumInitStrings) { |
334 | vmain = 0; | 330 | vmain = 0; |
335 | return; | 331 | return; |
336 | } | 332 | } |
337 | substate = -1; | 333 | substate = -1; |
338 | // skip setting the volume if command is empty | 334 | // skip setting the volume if command is empty |
339 | if(PPPData::data()->volumeInitString().isEmpty()) { | 335 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
340 | vmain = 4; | 336 | vmain = 4; |
341 | return; | 337 | return; |
342 | } | 338 | } |
343 | messg->setText(i18n("Setting speaker volume...")); | 339 | messg->setText(i18n("Setting speaker volume...")); |
344 | emit debugMessage(i18n("Setting speaker volume...")); | 340 | emit debugMessage(i18n("Setting speaker volume...")); |
345 | 341 | ||
346 | setExpect(PPPData::data()->modemInitResp()); | 342 | setExpect(_ifaceppp->data()->modemInitResp()); |
347 | QString vol("AT"); | 343 | QString vol("AT"); |
348 | vol += PPPData::data()->volumeInitString(); | 344 | vol += _ifaceppp->data()->volumeInitString(); |
349 | writeline(vol); | 345 | writeline(vol); |
350 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 346 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
351 | vmain = 4; | 347 | vmain = 4; |
352 | return; | 348 | return; |
353 | } | 349 | } |
354 | } | 350 | } |
355 | 351 | ||
356 | if(vmain == 4) { | 352 | if(vmain == 4) { |
357 | if(!expecting) { | 353 | if(!expecting) { |
358 | if(!PPPData::data()->waitForDialTone()) { | 354 | if(!_ifaceppp->data()->waitForDialTone()) { |
359 | QString msg = i18n("Turning off dial tone waiting..."); | 355 | QString msg = i18n("Turning off dial tone waiting..."); |
360 | messg->setText(msg); | 356 | messg->setText(msg); |
361 | emit debugMessage(msg); | 357 | emit debugMessage(msg); |
362 | setExpect(PPPData::data()->modemInitResp()); | 358 | setExpect(_ifaceppp->data()->modemInitResp()); |
363 | writeline(PPPData::data()->modemNoDialToneDetectionStr()); | 359 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
364 | } | 360 | } |
365 | vmain = 1; | 361 | vmain = 1; |
366 | return; | 362 | return; |
367 | } | 363 | } |
368 | } | 364 | } |
369 | 365 | ||
370 | // dial the number and wait to connect | 366 | // dial the number and wait to connect |
371 | if(vmain == 1) { | 367 | if(vmain == 1) { |
372 | if(!expecting) { | 368 | if(!expecting) { |
373 | 369 | ||
374 | timeout_timer->stop(); | 370 | timeout_timer->stop(); |
375 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 371 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
376 | 372 | ||
377 | QStringList &plist = PPPData::data()->phonenumbers(); | 373 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
378 | QString bmarg= PPPData::data()->dialPrefix(); | 374 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
379 | bmarg += *plist.at(dialnumber); | 375 | bmarg += *plist.at(dialnumber); |
380 | QString bm = i18n("Dialing %1").arg(bmarg); | 376 | QString bm = i18n("Dialing %1").arg(bmarg); |
381 | messg->setText(bm); | 377 | messg->setText(bm); |
382 | emit debugMessage(bm); | 378 | emit debugMessage(bm); |
383 | 379 | ||
384 | QString pn = PPPData::data()->modemDialStr(); | 380 | QString pn = _ifaceppp->data()->modemDialStr(); |
385 | pn += PPPData::data()->dialPrefix(); | 381 | pn += _ifaceppp->data()->dialPrefix(); |
386 | pn += *plist.at(dialnumber); | 382 | pn += *plist.at(dialnumber); |
387 | if(++dialnumber >= plist.count()) | 383 | if(++dialnumber >= plist.count()) |
388 | dialnumber = 0; | 384 | dialnumber = 0; |
389 | writeline(pn); | 385 | writeline(pn); |
390 | 386 | ||
391 | setExpect(PPPData::data()->modemConnectResp()); | 387 | setExpect(_ifaceppp->data()->modemConnectResp()); |
392 | vmain = 100; | 388 | vmain = 100; |
393 | return; | 389 | return; |
394 | } | 390 | } |
395 | } | 391 | } |
396 | 392 | ||
397 | // wait for connect, but redial if BUSY or wait for user cancel | 393 | // wait for connect, but redial if BUSY or wait for user cancel |
398 | // if NO CARRIER or NO DIALTONE | 394 | // if NO CARRIER or NO DIALTONE |
399 | if(vmain == 100) { | 395 | if(vmain == 100) { |
400 | if(!expecting) { | 396 | if(!expecting) { |
401 | myreadbuffer = PPPData::data()->modemConnectResp(); | 397 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
402 | setExpect("\n"); | 398 | setExpect("\n"); |
403 | vmain = 101; | 399 | vmain = 101; |
404 | return; | 400 | return; |
405 | } | 401 | } |
406 | 402 | ||
407 | if(readbuffer.contains(PPPData::data()->modemBusyResp())) { | 403 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
408 | timeout_timer->stop(); | 404 | timeout_timer->stop(); |
409 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 405 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
410 | 406 | ||
411 | messg->setText(i18n("Line busy. Hanging up...")); | 407 | messg->setText(i18n("Line busy. Hanging up...")); |
412 | emit debugPutChar('\n'); | 408 | emit debugPutChar('\n'); |
413 | Modem::modem->hangup(); | 409 | _ifaceppp->modem()->hangup(); |
414 | 410 | ||
415 | if(PPPData::data()->busyWait() > 0) { | 411 | if(_ifaceppp->data()->busyWait() > 0) { |
416 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait()); | 412 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
417 | messg->setText(bm); | 413 | messg->setText(bm); |
418 | emit debugMessage(bm); | 414 | emit debugMessage(bm); |
419 | 415 | ||
420 | pausing = true; | 416 | pausing = true; |
421 | 417 | ||
422 | pausetimer->start(PPPData::data()->busyWait()*1000, true); | 418 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
423 | timeout_timer->stop(); | 419 | timeout_timer->stop(); |
424 | } | 420 | } |
425 | 421 | ||
426 | Modem::modem->setDataMode(false); | 422 | _ifaceppp->modem()->setDataMode(false); |
427 | vmain = 0; | 423 | vmain = 0; |
428 | substate = -1; | 424 | substate = -1; |
429 | return; | 425 | return; |
430 | } | 426 | } |
431 | 427 | ||
432 | if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) { | 428 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
433 | timeout_timer->stop(); | 429 | timeout_timer->stop(); |
434 | 430 | ||
435 | messg->setText(i18n("No Dialtone")); | 431 | messg->setText(i18n("No Dialtone")); |
436 | vmain = 20; | 432 | vmain = 20; |
437 | Modem::modem->unlockdevice(); | 433 | _ifaceppp->modem()->unlockdevice(); |
438 | return; | 434 | return; |
439 | } | 435 | } |
440 | 436 | ||
441 | if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) { | 437 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
442 | timeout_timer->stop(); | 438 | timeout_timer->stop(); |
443 | 439 | ||
444 | messg->setText(i18n("No Carrier")); | 440 | messg->setText(i18n("No Carrier")); |
445 | vmain = 20; | 441 | vmain = 20; |
446 | Modem::modem->unlockdevice(); | 442 | _ifaceppp->modem()->unlockdevice(); |
447 | return; | 443 | return; |
448 | } | 444 | } |
449 | } | 445 | } |
450 | 446 | ||
451 | // wait for newline after CONNECT response (so we get the speed) | 447 | // wait for newline after CONNECT response (so we get the speed) |
452 | if(vmain == 101) { | 448 | if(vmain == 101) { |
453 | if(!expecting) { | 449 | if(!expecting) { |
454 | Modem::modem->setDataMode(true); // modem will no longer respond to AT commands | 450 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
455 | 451 | ||
456 | emit startAccounting(); | 452 | emit startAccounting(); |
457 | // p_kppp->con_win->startClock(); | 453 | // p_kppp->con_win->startClock(); |
458 | 454 | ||
459 | vmain = 2; | 455 | vmain = 2; |
460 | scriptTimeout=PPPData::data()->modemTimeout()*1000; | 456 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
461 | return; | 457 | return; |
462 | } | 458 | } |
463 | } | 459 | } |
464 | 460 | ||
465 | // execute the script | 461 | // execute the script |
466 | if(vmain == 2) { | 462 | if(vmain == 2) { |
467 | if(!expecting && !pausing && !scanning) { | 463 | if(!expecting && !pausing && !scanning) { |
468 | 464 | ||
469 | timeout_timer->stop(); | 465 | timeout_timer->stop(); |
470 | timeout_timer->start(scriptTimeout); | 466 | timeout_timer->start(scriptTimeout); |
471 | 467 | ||
472 | if((unsigned) scriptindex < comlist->count()) { | 468 | if((unsigned) scriptindex < comlist->count()) { |
473 | scriptCommand = *(comlist->at(scriptindex)); | 469 | scriptCommand = *(comlist->at(scriptindex)); |
474 | scriptArgument = *(arglist->at(scriptindex)); | 470 | scriptArgument = *(arglist->at(scriptindex)); |
475 | } else { | 471 | } else { |
476 | qDebug( "End of script" ); | 472 | qDebug( "End of script" ); |
477 | vmain = 10; | 473 | vmain = 10; |
478 | return; | 474 | return; |
479 | } | 475 | } |
480 | 476 | ||
481 | if (scriptCommand == "Scan") { | 477 | if (scriptCommand == "Scan") { |
482 | QString bm = i18n("Scanning %1").arg(scriptArgument); | 478 | QString bm = i18n("Scanning %1").arg(scriptArgument); |
483 | messg->setText(bm); | 479 | messg->setText(bm); |
484 | emit debugMessage(bm); | 480 | emit debugMessage(bm); |
485 | 481 | ||
486 | setScan(scriptArgument); | 482 | setScan(scriptArgument); |
487 | scriptindex++; | 483 | scriptindex++; |
488 | return; | 484 | return; |
489 | } | 485 | } |
490 | 486 | ||
491 | if (scriptCommand == "Save") { | 487 | if (scriptCommand == "Save") { |
492 | QString bm = i18n("Saving %1").arg(scriptArgument); | 488 | QString bm = i18n("Saving %1").arg(scriptArgument); |
493 | messg->setText(bm); | 489 | messg->setText(bm); |
494 | emit debugMessage(bm); | 490 | emit debugMessage(bm); |
495 | 491 | ||
496 | if (scriptArgument.lower() == "password") { | 492 | if (scriptArgument.lower() == "password") { |
497 | PPPData::data()->setPassword(scanvar); | 493 | _ifaceppp->data()->setPassword(scanvar); |
498 | p_kppp->setPW_Edit(scanvar); | 494 | // p_kppp->setPW_Edit(scanvar); |
499 | if(PPPData::data()->storePassword()) | 495 | if(_ifaceppp->data()->storePassword()) |
500 | PPPData::data()->setStoredPassword(scanvar); | 496 | _ifaceppp->data()->setStoredPassword(scanvar); |
501 | firstrunPW = true; | 497 | firstrunPW = true; |
502 | } | 498 | } |
503 | 499 | ||
504 | scriptindex++; | 500 | scriptindex++; |
505 | return; | 501 | return; |
506 | } | 502 | } |
507 | 503 | ||
508 | 504 | ||
509 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { | 505 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { |
510 | QString bm = i18n("Sending %1"); | 506 | QString bm = i18n("Sending %1"); |
511 | 507 | ||
512 | // replace %USERNAME% and %PASSWORD% | 508 | // replace %USERNAME% and %PASSWORD% |
513 | QString arg = scriptArgument; | 509 | QString arg = scriptArgument; |
514 | QRegExp re1("%USERNAME%"); | 510 | QRegExp re1("%USERNAME%"); |
515 | QRegExp re2("%PASSWORD%"); | 511 | QRegExp re2("%PASSWORD%"); |
516 | arg = arg.replace(re1, PPPData::data()->storedUsername()); | 512 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
517 | arg = arg.replace(re2, PPPData::data()->storedPassword()); | 513 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
518 | 514 | ||
519 | if (scriptCommand == "Send") | 515 | if (scriptCommand == "Send") |
520 | bm = bm.arg(scriptArgument); | 516 | bm = bm.arg(scriptArgument); |
521 | else { | 517 | else { |
522 | for(uint i = 0; i < scriptArgument.length(); i++) | 518 | for(uint i = 0; i < scriptArgument.length(); i++) |
523 | bm = bm.arg("*"); | 519 | bm = bm.arg("*"); |
524 | } | 520 | } |
525 | 521 | ||
526 | messg->setText(bm); | 522 | messg->setText(bm); |
527 | emit debugMessage(bm); | 523 | emit debugMessage(bm); |
528 | 524 | ||
529 | writeline(scriptArgument); | 525 | writeline(scriptArgument); |
530 | scriptindex++; | 526 | scriptindex++; |
531 | return; | 527 | return; |
532 | } | 528 | } |
533 | 529 | ||
534 | if (scriptCommand == "Expect") { | 530 | if (scriptCommand == "Expect") { |
535 | QString bm = i18n("Expecting %1").arg(scriptArgument); | 531 | QString bm = i18n("Expecting %1").arg(scriptArgument); |
536 | messg->setText(bm); | 532 | messg->setText(bm); |
537 | emit debugMessage(bm); | 533 | emit debugMessage(bm); |
538 | 534 | ||
539 | // The incrementing of the scriptindex MUST be before the | 535 | // The incrementing of the scriptindex MUST be before the |
540 | // call to setExpect otherwise the expect will miss a string that is | 536 | // call to setExpect otherwise the expect will miss a string that is |
541 | // already in the buffer. | 537 | // already in the buffer. |
542 | scriptindex++; | 538 | scriptindex++; |
543 | setExpect(scriptArgument); | 539 | setExpect(scriptArgument); |
544 | return; | 540 | return; |
545 | } | 541 | } |
546 | 542 | ||
547 | 543 | ||
548 | if (scriptCommand == "Pause") { | 544 | if (scriptCommand == "Pause") { |
549 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); | 545 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); |
550 | messg->setText(bm); | 546 | messg->setText(bm); |
551 | emit debugMessage(bm); | 547 | emit debugMessage(bm); |
552 | 548 | ||
553 | pausing = true; | 549 | pausing = true; |
554 | 550 | ||
555 | pausetimer->start(scriptArgument.toInt()*1000, true); | 551 | pausetimer->start(scriptArgument.toInt()*1000, true); |
556 | timeout_timer->stop(); | 552 | timeout_timer->stop(); |
557 | 553 | ||
558 | scriptindex++; | 554 | scriptindex++; |
559 | return; | 555 | return; |
560 | } | 556 | } |
561 | 557 | ||
562 | if (scriptCommand == "Timeout") { | 558 | if (scriptCommand == "Timeout") { |
563 | 559 | ||
564 | timeout_timer->stop(); | 560 | timeout_timer->stop(); |
565 | 561 | ||
566 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); | 562 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); |
567 | messg->setText(bm); | 563 | messg->setText(bm); |
568 | emit debugMessage(bm); | 564 | emit debugMessage(bm); |
569 | 565 | ||
570 | scriptTimeout=scriptArgument.toInt()*1000; | 566 | scriptTimeout=scriptArgument.toInt()*1000; |
571 | timeout_timer->start(scriptTimeout); | 567 | timeout_timer->start(scriptTimeout); |
572 | 568 | ||
573 | scriptindex++; | 569 | scriptindex++; |
574 | return; | 570 | return; |
575 | } | 571 | } |
576 | 572 | ||
577 | if (scriptCommand == "Hangup") { | 573 | if (scriptCommand == "Hangup") { |
578 | messg->setText(i18n("Hangup")); | 574 | messg->setText(i18n("Hangup")); |
579 | emit debugMessage(i18n("Hangup")); | 575 | emit debugMessage(i18n("Hangup")); |
580 | 576 | ||
581 | writeline(PPPData::data()->modemHangupStr()); | 577 | writeline(_ifaceppp->data()->modemHangupStr()); |
582 | setExpect(PPPData::data()->modemHangupResp()); | 578 | setExpect(_ifaceppp->data()->modemHangupResp()); |
583 | 579 | ||
584 | scriptindex++; | 580 | scriptindex++; |
585 | return; | 581 | return; |
586 | } | 582 | } |
587 | 583 | ||
588 | if (scriptCommand == "Answer") { | 584 | if (scriptCommand == "Answer") { |
589 | 585 | ||
590 | timeout_timer->stop(); | 586 | timeout_timer->stop(); |
591 | 587 | ||
592 | messg->setText(i18n("Answer")); | 588 | messg->setText(i18n("Answer")); |
593 | emit debugMessage(i18n("Answer")); | 589 | emit debugMessage(i18n("Answer")); |
594 | 590 | ||
595 | setExpect(PPPData::data()->modemRingResp()); | 591 | setExpect(_ifaceppp->data()->modemRingResp()); |
596 | vmain = 150; | 592 | vmain = 150; |
597 | return; | 593 | return; |
598 | } | 594 | } |
599 | 595 | ||
600 | if (scriptCommand == "ID") { | 596 | if (scriptCommand == "ID") { |
601 | QString bm = i18n("ID %1").arg(scriptArgument); | 597 | QString bm = i18n("ID %1").arg(scriptArgument); |
602 | messg->setText(bm); | 598 | messg->setText(bm); |
603 | emit debugMessage(bm); | 599 | emit debugMessage(bm); |
604 | 600 | ||
605 | QString idstring = PPPData::data()->storedUsername(); | 601 | QString idstring = _ifaceppp->data()->storedUsername(); |
606 | 602 | ||
607 | if(!idstring.isEmpty() && firstrunID) { | 603 | if(!idstring.isEmpty() && firstrunID) { |
608 | // the user entered an Id on the main kppp dialog | 604 | // the user entered an Id on the main kppp dialog |
609 | writeline(idstring); | 605 | writeline(idstring); |
610 | firstrunID = false; | 606 | firstrunID = false; |
611 | scriptindex++; | 607 | scriptindex++; |
612 | } | 608 | } |
613 | else { | 609 | else { |
614 | // the user didn't enter and Id on the main kppp dialog | 610 | // the user didn't enter and Id on the main kppp dialog |
615 | // let's query for an ID | 611 | // let's query for an ID |
616 | /* if not around yet, then post window... */ | 612 | /* if not around yet, then post window... */ |
617 | if (prompt->Consumed()) { | 613 | if (prompt->Consumed()) { |
618 | if (!(prompt->isVisible())) { | 614 | if (!(prompt->isVisible())) { |
619 | prompt->setPrompt(scriptArgument); | 615 | prompt->setPrompt(scriptArgument); |
620 | prompt->setEchoModeNormal(); | 616 | prompt->setEchoModeNormal(); |
621 | prompt->show(); | 617 | prompt->show(); |
622 | } | 618 | } |
623 | } else { | 619 | } else { |
624 | /* if prompt withdrawn ... then, */ | 620 | /* if prompt withdrawn ... then, */ |
625 | if(!(prompt->isVisible())) { | 621 | if(!(prompt->isVisible())) { |
626 | writeline(prompt->text()); | 622 | writeline(prompt->text()); |
627 | prompt->setConsumed(); | 623 | prompt->setConsumed(); |
628 | scriptindex++; | 624 | scriptindex++; |
629 | return; | 625 | return; |
630 | } | 626 | } |
631 | /* replace timeout value */ | 627 | /* replace timeout value */ |
632 | } | 628 | } |
633 | } | 629 | } |
634 | } | 630 | } |
635 | 631 | ||
636 | if (scriptCommand == "Password") { | 632 | if (scriptCommand == "Password") { |
637 | QString bm = i18n("Password %1").arg(scriptArgument); | 633 | QString bm = i18n("Password %1").arg(scriptArgument); |
638 | messg->setText(bm); | 634 | messg->setText(bm); |
639 | emit debugMessage(bm); | 635 | emit debugMessage(bm); |
640 | 636 | ||
641 | QString pwstring = PPPData::data()->password(); | 637 | QString pwstring = _ifaceppp->data()->password(); |
642 | 638 | ||
643 | if(!pwstring.isEmpty() && firstrunPW) { | 639 | if(!pwstring.isEmpty() && firstrunPW) { |
644 | // the user entered a password on the main kppp dialog | 640 | // the user entered a password on the main kppp dialog |
645 | writeline(pwstring); | 641 | writeline(pwstring); |
646 | firstrunPW = false; | 642 | firstrunPW = false; |
647 | scriptindex++; | 643 | scriptindex++; |
648 | } | 644 | } |
649 | else { | 645 | else { |
650 | // the user didn't enter a password on the main kppp dialog | 646 | // the user didn't enter a password on the main kppp dialog |
651 | // let's query for a password | 647 | // let's query for a password |
652 | /* if not around yet, then post window... */ | 648 | /* if not around yet, then post window... */ |
653 | if (prompt->Consumed()) { | 649 | if (prompt->Consumed()) { |
654 | if (!(prompt->isVisible())) { | 650 | if (!(prompt->isVisible())) { |
655 | prompt->setPrompt(scriptArgument); | 651 | prompt->setPrompt(scriptArgument); |
656 | prompt->setEchoModePassword(); | 652 | prompt->setEchoModePassword(); |
657 | prompt->show(); | 653 | prompt->show(); |
658 | } | 654 | } |
659 | } else { | 655 | } else { |
660 | /* if prompt withdrawn ... then, */ | 656 | /* if prompt withdrawn ... then, */ |
661 | if(!(prompt->isVisible())) { | 657 | if(!(prompt->isVisible())) { |
662 | p_kppp->setPW_Edit(prompt->text()); | 658 | // p_kppp->setPW_Edit(prompt->text()); |
663 | writeline(prompt->text()); | 659 | writeline(prompt->text()); |
664 | prompt->setConsumed(); | 660 | prompt->setConsumed(); |
665 | scriptindex++; | 661 | scriptindex++; |
666 | return; | 662 | return; |
667 | } | 663 | } |
668 | /* replace timeout value */ | 664 | /* replace timeout value */ |
669 | } | 665 | } |
670 | } | 666 | } |
671 | } | 667 | } |
672 | 668 | ||
673 | if (scriptCommand == "Prompt") { | 669 | if (scriptCommand == "Prompt") { |
674 | QString bm = i18n("Prompting %1"); | 670 | QString bm = i18n("Prompting %1"); |
675 | 671 | ||
676 | // if the scriptindex (aka the prompt text) includes a ## marker | 672 | // if the scriptindex (aka the prompt text) includes a ## marker |
677 | // this marker should get substituted with the contents of our stored | 673 | // this marker should get substituted with the contents of our stored |
678 | // variable (from the subsequent scan). | 674 | // variable (from the subsequent scan). |
679 | 675 | ||
680 | QString ts = scriptArgument; | 676 | QString ts = scriptArgument; |
681 | int vstart = ts.find( "##" ); | 677 | int vstart = ts.find( "##" ); |
682 | if( vstart != -1 ) { | 678 | if( vstart != -1 ) { |
683 | ts.remove( vstart, 2 ); | 679 | ts.remove( vstart, 2 ); |
684 | ts.insert( vstart, scanvar ); | 680 | ts.insert( vstart, scanvar ); |
685 | } | 681 | } |
686 | 682 | ||
687 | bm = bm.arg(ts); | 683 | bm = bm.arg(ts); |
688 | messg->setText(bm); | 684 | messg->setText(bm); |
689 | emit debugMessage(bm); | 685 | emit debugMessage(bm); |
690 | 686 | ||
691 | /* if not around yet, then post window... */ | 687 | /* if not around yet, then post window... */ |
692 | if (prompt->Consumed()) { | 688 | if (prompt->Consumed()) { |
693 | if (!(prompt->isVisible())) { | 689 | if (!(prompt->isVisible())) { |
694 | prompt->setPrompt( ts ); | 690 | prompt->setPrompt( ts ); |
695 | prompt->setEchoModeNormal(); | 691 | prompt->setEchoModeNormal(); |
696 | prompt->show(); | 692 | prompt->show(); |
697 | } | 693 | } |
698 | } else { | 694 | } else { |
699 | /* if prompt withdrawn ... then, */ | 695 | /* if prompt withdrawn ... then, */ |
700 | if (!(prompt->isVisible())) { | 696 | if (!(prompt->isVisible())) { |
701 | writeline(prompt->text()); | 697 | writeline(prompt->text()); |
702 | prompt->setConsumed(); | 698 | prompt->setConsumed(); |
703 | scriptindex++; | 699 | scriptindex++; |
704 | return; | 700 | return; |
705 | } | 701 | } |
706 | /* replace timeout value */ | 702 | /* replace timeout value */ |
707 | } | 703 | } |
708 | } | 704 | } |
709 | 705 | ||
710 | if (scriptCommand == "PWPrompt") { | 706 | if (scriptCommand == "PWPrompt") { |
711 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); | 707 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); |
712 | messg->setText(bm); | 708 | messg->setText(bm); |
713 | emit debugMessage(bm); | 709 | emit debugMessage(bm); |
714 | 710 | ||
715 | /* if not around yet, then post window... */ | 711 | /* if not around yet, then post window... */ |
716 | if (prompt->Consumed()) { | 712 | if (prompt->Consumed()) { |
717 | if (!(prompt->isVisible())) { | 713 | if (!(prompt->isVisible())) { |
718 | prompt->setPrompt(scriptArgument); | 714 | prompt->setPrompt(scriptArgument); |
719 | prompt->setEchoModePassword(); | 715 | prompt->setEchoModePassword(); |
720 | prompt->show(); | 716 | prompt->show(); |
721 | } | 717 | } |
722 | } else { | 718 | } else { |
723 | /* if prompt withdrawn ... then, */ | 719 | /* if prompt withdrawn ... then, */ |
724 | if (!(prompt->isVisible())) { | 720 | if (!(prompt->isVisible())) { |
725 | writeline(prompt->text()); | 721 | writeline(prompt->text()); |
726 | prompt->setConsumed(); | 722 | prompt->setConsumed(); |
727 | scriptindex++; | 723 | scriptindex++; |
728 | return; | 724 | return; |
729 | } | 725 | } |
730 | /* replace timeout value */ | 726 | /* replace timeout value */ |
731 | } | 727 | } |
732 | } | 728 | } |
733 | 729 | ||
734 | if (scriptCommand == "LoopStart") { | 730 | if (scriptCommand == "LoopStart") { |
735 | 731 | ||
736 | QString bm = i18n("Loop Start %1").arg(scriptArgument); | 732 | QString bm = i18n("Loop Start %1").arg(scriptArgument); |
737 | 733 | ||
738 | // The incrementing of the scriptindex MUST be before the | 734 | // The incrementing of the scriptindex MUST be before the |
739 | // call to setExpect otherwise the expect will miss a string that is | 735 | // call to setExpect otherwise the expect will miss a string that is |
740 | // already in the buffer. | 736 | // already in the buffer. |
741 | scriptindex++; | 737 | scriptindex++; |
742 | 738 | ||
743 | if ( loopnest > (MAXLOOPNEST-2) ) { | 739 | if ( loopnest > (MAXLOOPNEST-2) ) { |
744 | bm += i18n("ERROR: Nested too deep, ignored."); | 740 | bm += i18n("ERROR: Nested too deep, ignored."); |
745 | vmain=20; | 741 | vmain=20; |
746 | cancelbutton(); | 742 | cancelbutton(); |
747 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); | 743 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); |
748 | } else { | 744 | } else { |
749 | setExpect(scriptArgument); | 745 | setExpect(scriptArgument); |
750 | loopstartindex[loopnest] = scriptindex; | 746 | loopstartindex[loopnest] = scriptindex; |
751 | loopstr[loopnest] = scriptArgument; | 747 | loopstr[loopnest] = scriptArgument; |
752 | loopend = false; | 748 | loopend = false; |
753 | loopnest++; | 749 | loopnest++; |
754 | } | 750 | } |
755 | messg->setText(bm); | 751 | messg->setText(bm); |
756 | emit debugMessage(bm); | 752 | emit debugMessage(bm); |
757 | 753 | ||
758 | } | 754 | } |
759 | 755 | ||
760 | if (scriptCommand == "LoopEnd") { | 756 | if (scriptCommand == "LoopEnd") { |
761 | QString bm = i18n("Loop End %1").arg(scriptArgument); | 757 | QString bm = i18n("Loop End %1").arg(scriptArgument); |
762 | if ( loopnest <= 0 ) { | 758 | if ( loopnest <= 0 ) { |
763 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); | 759 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); |
764 | vmain=20; | 760 | vmain=20; |
765 | cancelbutton(); | 761 | cancelbutton(); |
766 | QMessageBox::critical(0, "error", bm); | 762 | QMessageBox::critical(0, "error", bm); |
767 | return; | 763 | return; |
768 | } else { | 764 | } else { |
769 | // NB! The incrementing of the scriptindex MUST be before the | 765 | // NB! The incrementing of the scriptindex MUST be before the |
770 | // call to setExpect otherwise the expect will miss a string | 766 | // call to setExpect otherwise the expect will miss a string |
771 | // that is already in the buffer. | 767 | // that is already in the buffer. |
772 | scriptindex++; | 768 | scriptindex++; |
773 | setExpect(scriptArgument); | 769 | setExpect(scriptArgument); |
774 | loopnest--; | 770 | loopnest--; |
775 | loopend = true; | 771 | loopend = true; |
776 | } | 772 | } |
777 | messg->setText(bm); | 773 | messg->setText(bm); |
778 | emit debugMessage(bm); | 774 | emit debugMessage(bm); |
779 | 775 | ||
780 | } | 776 | } |
781 | } | 777 | } |
782 | } | 778 | } |
783 | 779 | ||
784 | // this is a subroutine for the "Answer" script option | 780 | // this is a subroutine for the "Answer" script option |
785 | 781 | ||
786 | if(vmain == 150) { | 782 | if(vmain == 150) { |
787 | if(!expecting) { | 783 | if(!expecting) { |
788 | writeline(PPPData::data()->modemAnswerStr()); | 784 | writeline(_ifaceppp->data()->modemAnswerStr()); |
789 | setExpect(PPPData::data()->modemAnswerResp()); | 785 | setExpect(_ifaceppp->data()->modemAnswerResp()); |
790 | 786 | ||
791 | vmain = 2; | 787 | vmain = 2; |
792 | scriptindex++; | 788 | scriptindex++; |
793 | return; | 789 | return; |
794 | } | 790 | } |
795 | } | 791 | } |
796 | 792 | ||
797 | if(vmain == 30) { | 793 | if(vmain == 30) { |
798 | // if (termwindow->isVisible()) | 794 | // if (termwindow->isVisible()) |
799 | // return; | 795 | // return; |
800 | // if (termwindow->pressedContinue()) | 796 | // if (termwindow->pressedContinue()) |
801 | // vmain = 10; | 797 | // vmain = 10; |
802 | // else | 798 | // else |
803 | cancelbutton(); | 799 | cancelbutton(); |
804 | } | 800 | } |
805 | 801 | ||
806 | if(vmain == 10) { | 802 | if(vmain == 10) { |
807 | if(!expecting) { | 803 | if(!expecting) { |
808 | 804 | ||
809 | int result; | 805 | int result; |
810 | 806 | ||
811 | timeout_timer->stop(); | 807 | timeout_timer->stop(); |
812 | if_timeout_timer->stop(); // better be sure. | 808 | if_timeout_timer->stop(); // better be sure. |
813 | 809 | ||
814 | // stop reading of data | 810 | // stop reading of data |
815 | Modem::modem->stop(); | 811 | _ifaceppp->modem()->stop(); |
816 | 812 | ||
817 | if(PPPData::data()->authMethod() == AUTH_TERMINAL) { | 813 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
818 | // if (termwindow) { | 814 | // if (termwindow) { |
819 | // delete termwindow; | 815 | // delete termwindow; |
820 | // termwindow = 0L; | 816 | // termwindow = 0L; |
821 | // this->show(); | 817 | // this->show(); |
822 | // } else { | 818 | // } else { |
823 | // termwindow = new LoginTerm(0L, 0L); | 819 | // termwindow = new LoginTerm(0L, 0L); |
824 | // hide(); | 820 | // hide(); |
825 | // termwindow->show(); | 821 | // termwindow->show(); |
826 | // vmain = 30; | 822 | // vmain = 30; |
827 | // return; | 823 | // return; |
828 | // } | 824 | // } |
829 | } | 825 | } |
830 | 826 | ||
831 | // Close the tty. This prevents the QTimer::singleShot() in | 827 | // Close the tty. This prevents the QTimer::singleShot() in |
832 | // Modem::readtty() from re-enabling the socket notifier. | 828 | // Modem::readtty() from re-enabling the socket notifier. |
833 | // The port is still held open by the helper process. | 829 | // The port is still held open by the helper process. |
834 | Modem::modem->closetty(); | 830 | _ifaceppp->modem()->closetty(); |
835 | 831 | ||
836 | killTimer( main_timer_ID ); | 832 | killTimer( main_timer_ID ); |
837 | 833 | ||
838 | if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000); | 834 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
839 | qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000); | 835 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
840 | 836 | ||
841 | // find out PPP interface and notify the stats module | 837 | // find out PPP interface and notify the stats module |
842 | // stats->setUnit(pppInterfaceNumber()); | 838 | // stats->setUnit(pppInterfaceNumber()); |
843 | 839 | ||
844 | qApp->flushX(); | 840 | qApp->flushX(); |
845 | semaphore = true; | 841 | semaphore = true; |
846 | result = execppp(); | 842 | result = execppp(); |
847 | 843 | ||
848 | emit debugMessage(i18n("Starting pppd...")); | 844 | emit debugMessage(i18n("Starting pppd...")); |
849 | qDebug("execppp() returned with return-code %i", result ); | 845 | qDebug("execppp() returned with return-code %i", result ); |
850 | 846 | ||
851 | if(result) { | 847 | if(result) { |
852 | if(!PPPData::data()->autoDNS()) | 848 | if(!_ifaceppp->data()->autoDNS()) |
853 | adddns(); | 849 | adddns( _ifaceppp ); |
854 | 850 | ||
855 | // O.K we are done here, let's change over to the if_waiting loop | 851 | // O.K we are done here, let's change over to the if_waiting loop |
856 | // where we wait for the ppp if (interface) to come up. | 852 | // where we wait for the ppp if (interface) to come up. |
857 | 853 | ||
858 | emit if_waiting_signal(); | 854 | emit if_waiting_signal(); |
859 | } else { | 855 | } else { |
860 | 856 | ||
861 | // starting pppd wasn't successful. Error messages were | 857 | // starting pppd wasn't successful. Error messages were |
862 | // handled by execppp(); | 858 | // handled by execppp(); |
863 | if_timeout_timer->stop(); | 859 | if_timeout_timer->stop(); |
864 | this->hide(); | 860 | this->hide(); |
865 | messg->setText(""); | 861 | messg->setText(""); |
866 | p_kppp->quit_b->setFocus(); | 862 | //p_kppp->quit_b->setFocus(); |
867 | p_kppp->show(); | 863 | //p_kppp->show(); |
868 | qApp->processEvents(); | 864 | qApp->processEvents(); |
869 | Modem::modem->hangup(); | 865 | _ifaceppp->modem()->hangup(); |
870 | emit stopAccounting(); | 866 | emit stopAccounting(); |
871 | //p_kppp->con_win->stopClock(); | 867 | //p_kppp->con_win->stopClock(); |
872 | Modem::modem->closetty(); | 868 | _ifaceppp->modem()->closetty(); |
873 | Modem::modem->unlockdevice(); | 869 | _ifaceppp->modem()->unlockdevice(); |
874 | 870 | ||
875 | } | 871 | } |
876 | 872 | ||
877 | return; | 873 | return; |
878 | } | 874 | } |
879 | } | 875 | } |
880 | 876 | ||
881 | // this is a "wait until cancel" entry | 877 | // this is a "wait until cancel" entry |
882 | 878 | ||
883 | if(vmain == 20) { | 879 | if(vmain == 20) { |
884 | } | 880 | } |
885 | } | 881 | } |
886 | 882 | ||
887 | 883 | ||
888 | void ConnectWidget::set_con_speed_string() { | 884 | void ConnectWidget::set_con_speed_string() { |
889 | // Here we are trying to determine the speed at which we are connected. | 885 | // Here we are trying to determine the speed at which we are connected. |
890 | // Usually the modem responds after connect with something like | 886 | // Usually the modem responds after connect with something like |
891 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 887 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
892 | // or whatever the modemConnectResp() is. | 888 | // or whatever the modemConnectResp() is. |
893 | p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer); | 889 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
894 | } | 890 | } |
895 | 891 | ||
896 | 892 | ||
897 | 893 | ||
898 | void ConnectWidget::readChar(unsigned char c) { | 894 | void ConnectWidget::readChar(unsigned char c) { |
899 | if(semaphore) | 895 | if(semaphore) |
900 | return; | 896 | return; |
901 | 897 | ||
902 | readbuffer += c; | 898 | readbuffer += c; |
903 | myreadbuffer += c; | 899 | myreadbuffer += c; |
904 | 900 | ||
905 | // While in scanning mode store each char to the scan buffer | 901 | // While in scanning mode store each char to the scan buffer |
906 | // for use in the prompt command | 902 | // for use in the prompt command |
907 | if( scanning ) | 903 | if( scanning ) |
908 | scanbuffer += c; | 904 | scanbuffer += c; |
909 | 905 | ||
910 | // add to debug window | 906 | // add to debug window |
911 | emit debugPutChar(c); | 907 | emit debugPutChar(c); |
912 | 908 | ||
913 | checkBuffers(); | 909 | checkBuffers(); |
914 | } | 910 | } |
915 | 911 | ||
916 | 912 | ||
917 | void ConnectWidget::checkBuffers() { | 913 | void ConnectWidget::checkBuffers() { |
918 | // Let's check if we are finished with scanning: | 914 | // Let's check if we are finished with scanning: |
919 | // The scanstring have to be in the buffer and the latest character | 915 | // The scanstring have to be in the buffer and the latest character |
920 | // was a carriage return or an linefeed (depending on modem setup) | 916 | // was a carriage return or an linefeed (depending on modem setup) |
921 | if( scanning && scanbuffer.contains(scanstr) && | 917 | if( scanning && scanbuffer.contains(scanstr) && |
922 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 918 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
923 | scanning = false; | 919 | scanning = false; |
924 | 920 | ||
925 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 921 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
926 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 922 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
927 | scanvar = scanvar.stripWhiteSpace(); | 923 | scanvar = scanvar.stripWhiteSpace(); |
928 | 924 | ||
929 | // Show the Variabel content in the debug window | 925 | // Show the Variabel content in the debug window |
930 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 926 | QString sv = i18n("Scan Var: %1").arg(scanvar); |
931 | emit debugMessage(sv); | 927 | emit debugMessage(sv); |
932 | } | 928 | } |
933 | 929 | ||
934 | if(expecting) { | 930 | if(expecting) { |
935 | if(readbuffer.contains(expectstr)) { | 931 | if(readbuffer.contains(expectstr)) { |
936 | expecting = false; | 932 | expecting = false; |
937 | // keep everything after the expected string | 933 | // keep everything after the expected string |
938 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 934 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
939 | 935 | ||
940 | QString ts = i18n("Found: %1").arg(expectstr); | 936 | QString ts = i18n("Found: %1").arg(expectstr); |
941 | emit debugMessage(ts); | 937 | emit debugMessage(ts); |
942 | 938 | ||
943 | if (loopend) { | 939 | if (loopend) { |
944 | loopend=false; | 940 | loopend=false; |
945 | } | 941 | } |
946 | } | 942 | } |
947 | 943 | ||
948 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 944 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
949 | expecting = false; | 945 | expecting = false; |
950 | readbuffer = ""; | 946 | readbuffer = ""; |
951 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 947 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); |
952 | emit debugMessage(ts); | 948 | emit debugMessage(ts); |
953 | scriptindex = loopstartindex[loopnest]; | 949 | scriptindex = loopstartindex[loopnest]; |
954 | loopend = false; | 950 | loopend = false; |
955 | loopnest++; | 951 | loopnest++; |
956 | } | 952 | } |
957 | // notify event loop if expected string was found | 953 | // notify event loop if expected string was found |
958 | if(!expecting) | 954 | if(!expecting) |
959 | timerEvent((QTimerEvent *) 0); | 955 | timerEvent((QTimerEvent *) 0); |
960 | } | 956 | } |
961 | } | 957 | } |
962 | 958 | ||
963 | 959 | ||
964 | 960 | ||
965 | void ConnectWidget::pause() { | 961 | void ConnectWidget::pause() { |
966 | pausing = false; | 962 | pausing = false; |
967 | pausetimer->stop(); | 963 | pausetimer->stop(); |
968 | } | 964 | } |
969 | 965 | ||
970 | 966 | ||
971 | void ConnectWidget::cancelbutton() { | 967 | void ConnectWidget::cancelbutton() { |
972 | Modem::modem->stop(); | 968 | _ifaceppp->modem()->stop(); |
973 | killTimer(main_timer_ID); | 969 | killTimer(main_timer_ID); |
974 | timeout_timer->stop(); | 970 | timeout_timer->stop(); |
975 | if_timer->stop(); | 971 | if_timer->stop(); |
976 | if_timeout_timer->stop(); | 972 | if_timeout_timer->stop(); |
977 | 973 | ||
978 | // if (termwindow) { | 974 | // if (termwindow) { |
979 | // delete termwindow; | 975 | // delete termwindow; |
980 | // termwindow = 0L; | 976 | // termwindow = 0L; |
981 | // this->show(); | 977 | // this->show(); |
982 | // } | 978 | // } |
983 | 979 | ||
984 | messg->setText(i18n("One moment please...")); | 980 | messg->setText(i18n("One moment please...")); |
985 | 981 | ||
986 | // just to be sure | 982 | // just to be sure |
987 | Modem::modem->removeSecret(AUTH_PAP); | 983 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
988 | Modem::modem->removeSecret(AUTH_CHAP); | 984 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
989 | removedns(); | 985 | removedns(_ifaceppp); |
990 | 986 | ||
991 | qApp->processEvents(); | 987 | qApp->processEvents(); |
992 | 988 | ||
993 | Modem::modem->killPPPDaemon(); | 989 | _ifaceppp->modem()->killPPPDaemon(); |
994 | Modem::modem->hangup(); | 990 | _ifaceppp->modem()->hangup(); |
995 | 991 | ||
996 | this->hide(); | 992 | this->hide(); |
997 | messg->setText(""); | 993 | messg->setText(""); |
998 | p_kppp->quit_b->setFocus(); | 994 | // p_kppp->quit_b->setFocus(); |
999 | p_kppp->show(); | 995 | // p_kppp->show(); |
1000 | emit stopAccounting();// just to be sure | 996 | emit stopAccounting();// just to be sure |
1001 | // p_kppp->con_win->stopClock(); | 997 | // p_kppp->con_win->stopClock(); |
1002 | Modem::modem->closetty(); | 998 | _ifaceppp->modem()->closetty(); |
1003 | Modem::modem->unlockdevice(); | 999 | _ifaceppp->modem()->unlockdevice(); |
1004 | 1000 | ||
1005 | //abort prompt window... | 1001 | //abort prompt window... |
1006 | if (prompt->isVisible()) { | 1002 | if (prompt->isVisible()) { |
1007 | prompt->hide(); | 1003 | prompt->hide(); |
1008 | } | 1004 | } |
1009 | prompt->setConsumed(); | 1005 | prompt->setConsumed(); |
1010 | 1006 | ||
1011 | // if(p_kppp->quitOnDisconnect()) | 1007 | // if(p_kppp->quitOnDisconnect()) |
1012 | // qApp->exit(0); | 1008 | // qApp->exit(0); |
1013 | } | 1009 | } |
1014 | 1010 | ||
1015 | 1011 | ||
1016 | void ConnectWidget::script_timed_out() { | 1012 | void ConnectWidget::script_timed_out() { |
1017 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1013 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1018 | timeout_timer->stop(); | 1014 | timeout_timer->stop(); |
1019 | emit stopAccounting(); | 1015 | emit stopAccounting(); |
1020 | // p_kppp->con_win->stopClock(); | 1016 | // p_kppp->con_win->stopClock(); |
1021 | return; | 1017 | return; |
1022 | } | 1018 | } |
1023 | 1019 | ||
1024 | if (prompt->isVisible()) | 1020 | if (prompt->isVisible()) |
1025 | prompt->hide(); | 1021 | prompt->hide(); |
1026 | 1022 | ||
1027 | prompt->setConsumed(); | 1023 | prompt->setConsumed(); |
1028 | messg->setText(i18n("Script timed out!")); | 1024 | messg->setText(i18n("Script timed out!")); |
1029 | Modem::modem->hangup(); | 1025 | _ifaceppp->modem()->hangup(); |
1030 | emit stopAccounting(); | 1026 | emit stopAccounting(); |
1031 | // p_kppp->con_win->stopClock(); | 1027 | // p_kppp->con_win->stopClock(); |
1032 | 1028 | ||
1033 | vmain = 0; // let's try again. | 1029 | vmain = 0; // let's try again. |
1034 | substate = -1; | 1030 | substate = -1; |
1035 | } | 1031 | } |
1036 | 1032 | ||
1037 | 1033 | ||
1038 | void ConnectWidget::setScan(const QString &n) { | 1034 | void ConnectWidget::setScan(const QString &n) { |
1039 | scanning = true; | 1035 | scanning = true; |
1040 | scanstr = n; | 1036 | scanstr = n; |
1041 | scanbuffer = ""; | 1037 | scanbuffer = ""; |
1042 | 1038 | ||
1043 | QString ts = i18n("Scanning: %1").arg(n); | 1039 | QString ts = i18n("Scanning: %1").arg(n); |
1044 | emit debugMessage(ts); | 1040 | emit debugMessage(ts); |
1045 | } | 1041 | } |
1046 | 1042 | ||
1047 | 1043 | ||
1048 | void ConnectWidget::setExpect(const QString &n) { | 1044 | void ConnectWidget::setExpect(const QString &n) { |
1049 | expecting = true; | 1045 | expecting = true; |
1050 | expectstr = n; | 1046 | expectstr = n; |
1051 | 1047 | ||
1052 | QString ts = i18n("Expecting: %1").arg(n); | 1048 | QString ts = i18n("Expecting: %1").arg(n); |
1053 | ts.replace(QRegExp("\n"), "<LF>"); | 1049 | ts.replace(QRegExp("\n"), "<LF>"); |
1054 | emit debugMessage(ts); | 1050 | emit debugMessage(ts); |
1055 | 1051 | ||
1056 | // check if the expected string is in the read buffer already. | 1052 | // check if the expected string is in the read buffer already. |
1057 | checkBuffers(); | 1053 | checkBuffers(); |
1058 | } | 1054 | } |
1059 | 1055 | ||
1060 | 1056 | ||
1061 | void ConnectWidget::if_waiting_timed_out() { | 1057 | void ConnectWidget::if_waiting_timed_out() { |
1062 | if_timer->stop(); | 1058 | if_timer->stop(); |
1063 | if_timeout_timer->stop(); | 1059 | if_timeout_timer->stop(); |
1064 | qDebug("if_waiting_timed_out()"); | 1060 | qDebug("if_waiting_timed_out()"); |
1065 | 1061 | ||
1066 | PPPData::data()->setpppdError(E_IF_TIMEOUT); | 1062 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1067 | 1063 | ||
1068 | // let's kill the stuck pppd | 1064 | // let's kill the stuck pppd |
1069 | Modem::modem->killPPPDaemon(); | 1065 | _ifaceppp->modem()->killPPPDaemon(); |
1070 | 1066 | ||
1071 | emit stopAccounting(); | 1067 | emit stopAccounting(); |
1072 | // p_kppp->con_win->stopClock(); | 1068 | // p_kppp->con_win->stopClock(); |
1073 | 1069 | ||
1074 | 1070 | ||
1075 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1071 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1076 | // in main.cpp what happens next will depend on the boolean | 1072 | // in main.cpp what happens next will depend on the boolean |
1077 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1073 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1078 | } | 1074 | } |
1079 | 1075 | ||
1080 | void ConnectWidget::pppdDied() | 1076 | void ConnectWidget::pppdDied() |
1081 | { | 1077 | { |
1082 | if_timer->stop(); | 1078 | if_timer->stop(); |
1083 | if_timeout_timer->stop(); | 1079 | if_timeout_timer->stop(); |
1084 | } | 1080 | } |
1085 | 1081 | ||
1086 | void ConnectWidget::if_waiting_slot() { | 1082 | void ConnectWidget::if_waiting_slot() { |
1087 | messg->setText(i18n("Logging on to network...")); | 1083 | messg->setText(i18n("Logging on to network...")); |
1088 | 1084 | ||
1089 | // if(!stats->ifIsUp()) { | 1085 | // if(!stats->ifIsUp()) { |
1090 | 1086 | ||
1091 | // if(PPPData::data()->pppdError() != 0) { | 1087 | // if(_ifaceppp->data()->pppdError() != 0) { |
1092 | // // we are here if pppd died immediately after starting it. | 1088 | // // we are here if pppd died immediately after starting it. |
1093 | // pppdDied(); | 1089 | // pppdDied(); |
1094 | // // error message handled in main.cpp: sigPPPDDied() | 1090 | // // error message handled in main.cpp: sigPPPDDied() |
1095 | // return; | 1091 | // return; |
1096 | // } | 1092 | // } |
1097 | 1093 | ||
1098 | // if_timer->start(100, TRUE); // single shot | 1094 | // if_timer->start(100, TRUE); // single shot |
1099 | // return; | 1095 | // return; |
1100 | // } | 1096 | // } |
1101 | 1097 | ||
1102 | // O.K the ppp interface is up and running | 1098 | // O.K the ppp interface is up and running |
1103 | // give it a few time to come up completly (0.2 seconds) | 1099 | // give it a few time to come up completly (0.2 seconds) |
1104 | if_timeout_timer->stop(); | 1100 | if_timeout_timer->stop(); |
1105 | if_timer->stop(); | 1101 | if_timer->stop(); |
1106 | usleep(200000); | 1102 | usleep(200000); |
1107 | 1103 | ||
1108 | if(PPPData::data()->autoDNS()) | 1104 | if(_ifaceppp->data()->autoDNS()) |
1109 | addpeerdns(); | 1105 | addpeerdns( _ifaceppp ); |
1110 | 1106 | ||
1111 | // Close the debugging window. If we are connected, we | 1107 | // Close the debugging window. If we are connected, we |
1112 | // are not really interested in debug output | 1108 | // are not really interested in debug output |
1113 | emit closeDebugWindow(); | 1109 | emit closeDebugWindow(); |
1114 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1110 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1115 | auto_hostname(); | 1111 | auto_hostname(_ifaceppp); |
1116 | 1112 | ||
1117 | if(!PPPData::data()->command_on_connect().isEmpty()) { | 1113 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1118 | messg->setText(i18n("Running startup command...")); | 1114 | messg->setText(i18n("Running startup command...")); |
1119 | 1115 | ||
1120 | // make sure that we don't get any async errors | 1116 | // make sure that we don't get any async errors |
1121 | qApp->flushX(); | 1117 | qApp->flushX(); |
1122 | execute_command(PPPData::data()->command_on_connect()); | 1118 | execute_command(_ifaceppp->data()->command_on_connect()); |
1123 | messg->setText(i18n("Done")); | 1119 | messg->setText(i18n("Done")); |
1124 | } | 1120 | } |
1125 | 1121 | ||
1126 | // remove the authentication file | 1122 | // remove the authentication file |
1127 | Modem::modem->removeSecret(AUTH_PAP); | 1123 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1128 | Modem::modem->removeSecret(AUTH_CHAP); | 1124 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1129 | 1125 | ||
1130 | emit debugMessage(i18n("Done")); | 1126 | emit debugMessage(i18n("Done")); |
1131 | set_con_speed_string(); | 1127 | set_con_speed_string(); |
1132 | 1128 | ||
1133 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1129 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1134 | this->hide(); | 1130 | this->hide(); |
1135 | messg->setText(""); | 1131 | messg->setText(""); |
1136 | 1132 | ||
1137 | // prepare the con_win so as to have the right size for | 1133 | // prepare the con_win so as to have the right size for |
1138 | // accounting / non-accounting mode | 1134 | // accounting / non-accounting mode |
1139 | // if(p_kppp->acct != 0) | 1135 | // if(p_kppp->acct != 0) |
1140 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1136 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1141 | // else | 1137 | // else |
1142 | // p_kppp->con_win->accounting(false); | 1138 | // p_kppp->con_win->accounting(false); |
1143 | 1139 | ||
1144 | if (PPPData::data()->get_dock_into_panel()) { | 1140 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1145 | // DockWidget::dock_widget->show(); | 1141 | // // DockWidget::dock_widget->show(); |
1146 | // DockWidget::dock_widget->take_stats(); | 1142 | // // DockWidget::dock_widget->take_stats(); |
1147 | // this->hide(); | 1143 | // // this->hide(); |
1148 | } | 1144 | // } |
1149 | else { | 1145 | // else { |
1150 | // p_kppp->con_win->show(); | 1146 | // // p_kppp->con_win->show(); |
1151 | 1147 | ||
1152 | if(PPPData::data()->get_iconify_on_connect()) { | 1148 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1153 | // p_kppp->con_win->showMinimized(); | 1149 | // // p_kppp->con_win->showMinimized(); |
1154 | } | 1150 | // } |
1155 | } | 1151 | // } |
1156 | 1152 | ||
1157 | Modem::modem->closetty(); | 1153 | _ifaceppp->modem()->closetty(); |
1158 | } | 1154 | } |
1159 | 1155 | ||
1160 | 1156 | ||
1161 | bool ConnectWidget::execppp() { | 1157 | bool ConnectWidget::execppp() { |
1162 | QString command; | 1158 | QString command; |
1163 | 1159 | ||
1164 | command = "pppd"; | 1160 | command = "pppd"; |
1165 | 1161 | ||
1166 | // as of version 2.3.6 pppd falls back to the real user rights when | 1162 | // as of version 2.3.6 pppd falls back to the real user rights when |
1167 | // opening a device given in a command line. To avoid permission conflicts | 1163 | // opening a device given in a command line. To avoid permission conflicts |
1168 | // we'll simply leave this argument away. pppd will then use the default tty | 1164 | // we'll simply leave this argument away. pppd will then use the default tty |
1169 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1165 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1170 | // command += " "; | 1166 | // command += " "; |
1171 | // command += PPPData::data()->modemDevice(); | 1167 | // command += _ifaceppp->data()->modemDevice(); |
1172 | 1168 | ||
1173 | command += " " + PPPData::data()->speed(); | 1169 | command += " " + _ifaceppp->data()->speed(); |
1174 | 1170 | ||
1175 | command += " -detach"; | 1171 | command += " -detach"; |
1176 | 1172 | ||
1177 | if(PPPData::data()->ipaddr() != "0.0.0.0" || | 1173 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1178 | PPPData::data()->gateway() != "0.0.0.0") { | 1174 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1179 | if(PPPData::data()->ipaddr() != "0.0.0.0") { | 1175 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1180 | command += " "; | 1176 | command += " "; |
1181 | command += PPPData::data()->ipaddr(); | 1177 | command += _ifaceppp->data()->ipaddr(); |
1182 | command += ":"; | 1178 | command += ":"; |
1183 | } | 1179 | } |
1184 | else { | 1180 | else { |
1185 | command += " "; | 1181 | command += " "; |
1186 | command += ":"; | 1182 | command += ":"; |
1187 | } | 1183 | } |
1188 | 1184 | ||
1189 | if(PPPData::data()->gateway() != "0.0.0.0") | 1185 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1190 | command += PPPData::data()->gateway(); | 1186 | command += _ifaceppp->data()->gateway(); |
1191 | } | 1187 | } |
1192 | 1188 | ||
1193 | if(PPPData::data()->subnetmask() != "0.0.0.0") | 1189 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1194 | command += " netmask " + PPPData::data()->subnetmask(); | 1190 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1195 | 1191 | ||
1196 | if(PPPData::data()->flowcontrol() != "None") { | 1192 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1197 | if(PPPData::data()->flowcontrol() == "CRTSCTS") | 1193 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1198 | command += " crtscts"; | 1194 | command += " crtscts"; |
1199 | else | 1195 | else |
1200 | command += " xonxoff"; | 1196 | command += " xonxoff"; |
1201 | } | 1197 | } |
1202 | 1198 | ||
1203 | if(PPPData::data()->defaultroute()) | 1199 | if(_ifaceppp->data()->defaultroute()) |
1204 | command += " defaultroute"; | 1200 | command += " defaultroute"; |
1205 | 1201 | ||
1206 | if(PPPData::data()->autoDNS()) | 1202 | if(_ifaceppp->data()->autoDNS()) |
1207 | command += " usepeerdns"; | 1203 | command += " usepeerdns"; |
1208 | 1204 | ||
1209 | QStringList &arglist = PPPData::data()->pppdArgument(); | 1205 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); |
1210 | for ( QStringList::Iterator it = arglist.begin(); | 1206 | for ( QStringList::Iterator it = arglist.begin(); |
1211 | it != arglist.end(); | 1207 | it != arglist.end(); |
1212 | ++it ) | 1208 | ++it ) |
1213 | { | 1209 | { |
1214 | command += " " + *it; | 1210 | command += " " + *it; |
1215 | } | 1211 | } |
1216 | 1212 | ||
1217 | // PAP settings | 1213 | // PAP settings |
1218 | if(PPPData::data()->authMethod() == AUTH_PAP) { | 1214 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1219 | command += " -chap user "; | 1215 | command += " -chap user "; |
1220 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1216 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1221 | } | 1217 | } |
1222 | 1218 | ||
1223 | // CHAP settings | 1219 | // CHAP settings |
1224 | if(PPPData::data()->authMethod() == AUTH_CHAP) { | 1220 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1225 | command += " -pap user "; | 1221 | command += " -pap user "; |
1226 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1222 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1227 | } | 1223 | } |
1228 | 1224 | ||
1229 | // PAP/CHAP settings | 1225 | // PAP/CHAP settings |
1230 | if(PPPData::data()->authMethod() == AUTH_PAPCHAP) { | 1226 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1231 | command += " user "; | 1227 | command += " user "; |
1232 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1228 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1233 | } | 1229 | } |
1234 | 1230 | ||
1235 | // check for debug | 1231 | // check for debug |
1236 | if(PPPData::data()->getPPPDebug()) | 1232 | if(_ifaceppp->data()->getPPPDebug()) |
1237 | command += " debug"; | 1233 | command += " debug"; |
1238 | 1234 | ||
1239 | if (command.length() > MAX_CMDLEN) { | 1235 | if (command.length() > MAX_CMDLEN) { |
1240 | QMessageBox::critical(this, "error", i18n( | 1236 | QMessageBox::critical(this, "error", i18n( |
1241 | "pppd command + command-line arguments exceed " | 1237 | "pppd command + command-line arguments exceed " |
1242 | "2024 characters in length." | 1238 | "2024 characters in length." |
1243 | )); | 1239 | )); |
1244 | 1240 | ||
1245 | return false; // nonsensically long command which would bust my buffer buf. | 1241 | return false; // nonsensically long command which would bust my buffer buf. |
1246 | } | 1242 | } |
1247 | 1243 | ||
1248 | qApp->flushX(); | 1244 | qApp->flushX(); |
1249 | 1245 | ||
1250 | return Modem::modem->execPPPDaemon(command); | 1246 | return _ifaceppp->modem()->execPPPDaemon(command); |
1251 | } | 1247 | } |
1252 | 1248 | ||
1253 | 1249 | ||
1254 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1250 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1255 | e->ignore(); | 1251 | e->ignore(); |
1256 | emit cancelbutton(); | 1252 | emit cancelbutton(); |
1257 | } | 1253 | } |
1258 | 1254 | ||
1259 | 1255 | ||
1260 | void ConnectWidget::setMsg(const QString &msg) { | 1256 | void ConnectWidget::setMsg(const QString &msg) { |
1261 | messg->setText(msg); | 1257 | messg->setText(msg); |
1262 | } | 1258 | } |
1263 | 1259 | ||
1264 | void ConnectWidget::writeline(const QString &s) { | 1260 | void ConnectWidget::writeline(const QString &s) { |
1265 | Modem::modem->writeLine(s.local8Bit()); | 1261 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1266 | } | 1262 | } |
1267 | 1263 | ||
1268 | // Set the hostname and domain from DNS Server | 1264 | // Set the hostname and domain from DNS Server |
1269 | void auto_hostname() { | 1265 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1270 | struct in_addr local_ip; | 1266 | struct in_addr local_ip; |
1271 | struct hostent *hostname_entry; | 1267 | struct hostent *hostname_entry; |
1272 | QString new_hostname; | 1268 | QString new_hostname; |
1273 | int dot; | 1269 | int dot; |
1274 | char tmp_str[100]; // buffer overflow safe | 1270 | char tmp_str[100]; // buffer overflow safe |
1275 | 1271 | ||
1276 | gethostname(tmp_str, sizeof(tmp_str)); | 1272 | gethostname(tmp_str, sizeof(tmp_str)); |
1277 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1273 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1278 | old_hostname=tmp_str; // copy to QString | 1274 | old_hostname=tmp_str; // copy to QString |
1279 | 1275 | ||
1280 | // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) { | 1276 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1281 | if ( PPPData::data()->autoname()) { | 1277 | if ( _ifaceppp->data()->autoname()) { |
1282 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); | 1278 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); |
1283 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); | 1279 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); |
1284 | 1280 | ||
1285 | if (hostname_entry != 0L) { | 1281 | if (hostname_entry != 0L) { |
1286 | new_hostname=hostname_entry->h_name; | 1282 | new_hostname=hostname_entry->h_name; |
1287 | dot=new_hostname.find('.'); | 1283 | dot=new_hostname.find('.'); |
1288 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); | 1284 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); |
1289 | Modem::modem->setHostname(new_hostname); | 1285 | _ifaceppp->modem()->setHostname(new_hostname); |
1290 | modified_hostname = TRUE; | 1286 | modified_hostname = TRUE; |
1291 | 1287 | ||
1292 | new_hostname=hostname_entry->h_name; | 1288 | new_hostname=hostname_entry->h_name; |
1293 | new_hostname.remove(0,dot+1); | 1289 | new_hostname.remove(0,dot+1); |
1294 | 1290 | ||
1295 | add_domain(new_hostname); | 1291 | add_domain(new_hostname, _ifaceppp); |
1296 | } | 1292 | } |
1297 | } | 1293 | } |
1298 | 1294 | ||
1299 | } | 1295 | } |
1300 | 1296 | ||
1301 | // Replace the DNS domain entry in the /etc/resolv.conf file and | 1297 | // Replace the DNS domain entry in the /etc/resolv.conf file and |
1302 | // disable the nameserver entries if option is enabled | 1298 | // disable the nameserver entries if option is enabled |
1303 | void add_domain(const QString &domain) { | 1299 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { |
1304 | 1300 | ||
1305 | int fd; | 1301 | int fd; |
1306 | char c; | 1302 | char c; |
1307 | QString resolv[MAX_RESOLVCONF_LINES]; | 1303 | QString resolv[MAX_RESOLVCONF_LINES]; |
1308 | 1304 | ||
1309 | if (domain.isEmpty()) | 1305 | if (domain.isEmpty()) |
1310 | return; | 1306 | return; |
1311 | 1307 | ||
1312 | if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { | 1308 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1313 | 1309 | ||
1314 | int i=0; | 1310 | int i=0; |
1315 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { | 1311 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { |
1316 | if(c == '\n') { | 1312 | if(c == '\n') { |
1317 | i++; | 1313 | i++; |
1318 | } | 1314 | } |
1319 | else { | 1315 | else { |
1320 | resolv[i] += c; | 1316 | resolv[i] += c; |
1321 | } | 1317 | } |
1322 | } | 1318 | } |
1323 | close(fd); | 1319 | close(fd); |
1324 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; | 1320 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; |
1325 | 1321 | ||
1326 | if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1322 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1327 | QCString tmp = "domain " + domain.local8Bit() + | 1323 | QCString tmp = "domain " + domain.local8Bit() + |
1328 | " \t\t#kppp temp entry\n"; | 1324 | " \t\t#kppp temp entry\n"; |
1329 | write(fd, tmp.data(), tmp.length()); | 1325 | write(fd, tmp.data(), tmp.length()); |
1330 | 1326 | ||
1331 | for(int j=0; j < i; j++) { | 1327 | for(int j=0; j < i; j++) { |
1332 | if((resolv[j].contains("domain") || | 1328 | if((resolv[j].contains("domain") || |
1333 | ( resolv[j].contains("nameserver") | 1329 | ( resolv[j].contains("nameserver") |
1334 | && !resolv[j].contains("#kppp temp entry") | 1330 | && !resolv[j].contains("#kppp temp entry") |
1335 | && PPPData::data()->exDNSDisabled())) | 1331 | && _ifaceppp->data()->exDNSDisabled())) |
1336 | && !resolv[j].contains("#entry disabled by kppp")) { | 1332 | && !resolv[j].contains("#entry disabled by kppp")) { |
1337 | QCString tmp = "# " + resolv[j].local8Bit() + | 1333 | QCString tmp = "# " + resolv[j].local8Bit() + |
1338 | " \t#entry disabled by kppp\n"; | 1334 | " \t#entry disabled by kppp\n"; |
1339 | write(fd, tmp, tmp.length()); | 1335 | write(fd, tmp, tmp.length()); |
1340 | } | 1336 | } |
1341 | else { | 1337 | else { |
1342 | QCString tmp = resolv[j].local8Bit() + "\n"; | 1338 | QCString tmp = resolv[j].local8Bit() + "\n"; |
1343 | write(fd, tmp, tmp.length()); | 1339 | write(fd, tmp, tmp.length()); |
1344 | } | 1340 | } |
1345 | } | 1341 | } |
1346 | } | 1342 | } |
1347 | close(fd); | 1343 | close(fd); |
1348 | } | 1344 | } |
1349 | } | 1345 | } |
1350 | 1346 | ||
1351 | 1347 | ||
1352 | // adds the DNS entries in the /etc/resolv.conf file | 1348 | // adds the DNS entries in the /etc/resolv.conf file |
1353 | void adddns() | 1349 | void adddns( InterfacePPP *_ifaceppp) |
1354 | { | 1350 | { |
1355 | int fd; | 1351 | int fd; |
1356 | 1352 | ||
1357 | if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1353 | if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1358 | QStringList &dnslist = PPPData::data()->dns(); | 1354 | QStringList &dnslist = _ifaceppp->data()->dns(); |
1359 | for ( QStringList::Iterator it = dnslist.begin(); | 1355 | for ( QStringList::Iterator it = dnslist.begin(); |
1360 | it != dnslist.end(); | 1356 | it != dnslist.end(); |
1361 | ++it ) | 1357 | ++it ) |
1362 | { | 1358 | { |
1363 | QCString dns = "nameserver " + (*it).local8Bit() + | 1359 | QCString dns = "nameserver " + (*it).local8Bit() + |
1364 | " \t#kppp temp entry\n"; | 1360 | " \t#kppp temp entry\n"; |
1365 | write(fd, dns.data(), dns.length()); | 1361 | write(fd, dns.data(), dns.length()); |
1366 | } | 1362 | } |
1367 | close(fd); | 1363 | close(fd); |
1368 | } | 1364 | } |
1369 | add_domain(PPPData::data()->domain()); | 1365 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1370 | } | 1366 | } |
1371 | 1367 | ||
1372 | void addpeerdns() { | 1368 | void addpeerdns(InterfacePPP *_ifaceppp) { |
1373 | int fd, fd2; | 1369 | int fd, fd2; |
1374 | 1370 | ||
1375 | if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1371 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1376 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { | 1372 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { |
1377 | char c; | 1373 | char c; |
1378 | int i = 0; | 1374 | int i = 0; |
1379 | while(i++ < 100 && read(fd2, &c, 1) == 1) { | 1375 | while(i++ < 100 && read(fd2, &c, 1) == 1) { |
1380 | if(c == '\n') | 1376 | if(c == '\n') |
1381 | write(fd, "\t#kppp temp entry\n", 18); | 1377 | write(fd, "\t#kppp temp entry\n", 18); |
1382 | else | 1378 | else |
1383 | write(fd, &c, 1); | 1379 | write(fd, &c, 1); |
1384 | } | 1380 | } |
1385 | close(fd2); | 1381 | close(fd2); |
1386 | } else | 1382 | } else |
1387 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); | 1383 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); |
1388 | close(fd); | 1384 | close(fd); |
1389 | } | 1385 | } |
1390 | add_domain(PPPData::data()->domain()); | 1386 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1391 | } | 1387 | } |
1392 | 1388 | ||
1393 | // remove the dns entries from the /etc/resolv.conf file | 1389 | // remove the dns entries from the /etc/resolv.conf file |
1394 | void removedns() { | 1390 | void removedns(InterfacePPP *_ifaceppp) { |
1395 | 1391 | ||
1396 | int fd; | 1392 | int fd; |
1397 | char c; | 1393 | char c; |
1398 | QString resolv[MAX_RESOLVCONF_LINES]; | 1394 | QString resolv[MAX_RESOLVCONF_LINES]; |
1399 | 1395 | ||
1400 | if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { | 1396 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1401 | 1397 | ||
1402 | int i=0; | 1398 | int i=0; |
1403 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { | 1399 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { |
1404 | if(c == '\n') { | 1400 | if(c == '\n') { |
1405 | i++; | 1401 | i++; |
1406 | } | 1402 | } |
1407 | else { | 1403 | else { |
1408 | resolv[i] += c; | 1404 | resolv[i] += c; |
1409 | } | 1405 | } |
1410 | } | 1406 | } |
1411 | close(fd); | 1407 | close(fd); |
1412 | 1408 | ||
1413 | if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1409 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1414 | for(int j=0; j < i; j++) { | 1410 | for(int j=0; j < i; j++) { |
1415 | if(resolv[j].contains("#kppp temp entry")) continue; | 1411 | if(resolv[j].contains("#kppp temp entry")) continue; |
1416 | if(resolv[j].contains("#entry disabled by kppp")) { | 1412 | if(resolv[j].contains("#entry disabled by kppp")) { |
1417 | QCString tmp = resolv[j].local8Bit(); | 1413 | QCString tmp = resolv[j].local8Bit(); |
1418 | write(fd, tmp.data()+2, tmp.length() - 27); | 1414 | write(fd, tmp.data()+2, tmp.length() - 27); |
1419 | write(fd, "\n", 1); | 1415 | write(fd, "\n", 1); |
1420 | } | 1416 | } |
1421 | else { | 1417 | else { |
1422 | QCString tmp = resolv[j].local8Bit() + "\n"; | 1418 | QCString tmp = resolv[j].local8Bit() + "\n"; |
1423 | write(fd, tmp, tmp.length()); | 1419 | write(fd, tmp, tmp.length()); |
1424 | } | 1420 | } |
1425 | } | 1421 | } |
1426 | } | 1422 | } |
1427 | close(fd); | 1423 | close(fd); |
1428 | 1424 | ||
1429 | } | 1425 | } |
1430 | 1426 | ||
1431 | if ( modified_hostname ) { | 1427 | if ( modified_hostname ) { |
1432 | Modem::modem->setHostname(old_hostname); | 1428 | _ifaceppp->modem()->setHostname(old_hostname); |
1433 | modified_hostname = FALSE; | 1429 | modified_hostname = FALSE; |
1434 | } | 1430 | } |
1435 | 1431 | ||
1436 | } | 1432 | } |
1437 | 1433 | ||
1438 | 1434 | ||
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h index 3127236..e7ae5e0 100644 --- a/noncore/settings/networksettings/ppp/connect.h +++ b/noncore/settings/networksettings/ppp/connect.h | |||
@@ -1,152 +1,152 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * based on EzPPP: | 10 | * based on EzPPP: |
11 | * Copyright (C) 1997 Jay Painter | 11 | * Copyright (C) 1997 Jay Painter |
12 | * | 12 | * |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU Library General Public | 15 | * modify it under the terms of the GNU Library General Public |
16 | * License as published by the Free Software Foundation; either | 16 | * License as published by the Free Software Foundation; either |
17 | * version 2 of the License, or (at your option) any later version. | 17 | * version 2 of the License, or (at your option) any later version. |
18 | * | 18 | * |
19 | * This program is distributed in the hope that it will be useful, | 19 | * This program is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | * Library General Public License for more details. | 22 | * Library General Public License for more details. |
23 | * | 23 | * |
24 | * You should have received a copy of the GNU Library General Public | 24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with this program; if not, write to the Free | 25 | * License along with this program; if not, write to the Free |
26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef _CONNECT_H_ | 29 | #ifndef _CONNECT_H_ |
30 | #define _CONNECT_H_ | 30 | #define _CONNECT_H_ |
31 | 31 | ||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qevent.h> | 35 | #include <qevent.h> |
36 | 36 | ||
37 | #include "kpppconfig.h" | 37 | #include "kpppconfig.h" |
38 | #include "pwentry.h" | 38 | #include "pwentry.h" |
39 | //#include "docking.h" | 39 | |
40 | //#include "loginterm.h" | ||
41 | 40 | ||
42 | #define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2) | 41 | #define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2) |
43 | 42 | ||
44 | class PPPStats; | 43 | class InterfacePPP; |
44 | class PPPData; | ||
45 | 45 | ||
46 | class ConnectWidget : public QWidget { | 46 | class ConnectWidget : public QWidget { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | ConnectWidget(QWidget *parent, const char *name); | 49 | ConnectWidget(InterfacePPP*, QWidget *parent, const char *name); |
50 | ~ConnectWidget(); | 50 | ~ConnectWidget(); |
51 | 51 | ||
52 | public: | 52 | public: |
53 | void set_con_speed_string(); | 53 | void set_con_speed_string(); |
54 | void setMsg(const QString &); | 54 | void setMsg(const QString &); |
55 | void pppdDied(); | 55 | void pppdDied(); |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | void timerEvent(QTimerEvent *); | 58 | void timerEvent(QTimerEvent *); |
59 | void closeEvent( QCloseEvent *e ); | 59 | void closeEvent( QCloseEvent *e ); |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | void readChar(unsigned char); | 62 | void readChar(unsigned char); |
63 | void pause(); | 63 | void pause(); |
64 | void if_waiting_slot(); | 64 | void if_waiting_slot(); |
65 | 65 | ||
66 | public slots: | 66 | public slots: |
67 | void init(); | 67 | void init(); |
68 | void preinit(); | 68 | void preinit(); |
69 | void script_timed_out(); | 69 | void script_timed_out(); |
70 | void if_waiting_timed_out(); | 70 | void if_waiting_timed_out(); |
71 | void cancelbutton(); | 71 | void cancelbutton(); |
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void if_waiting_signal(); | 74 | void if_waiting_signal(); |
75 | void debugMessage(const QString &); | 75 | void debugMessage(const QString &); |
76 | void toggleDebugWindow(); | 76 | void toggleDebugWindow(); |
77 | void closeDebugWindow(); | 77 | void closeDebugWindow(); |
78 | void debugPutChar(unsigned char); | 78 | void debugPutChar(unsigned char); |
79 | void startAccounting(); | 79 | void startAccounting(); |
80 | void stopAccounting(); | 80 | void stopAccounting(); |
81 | 81 | ||
82 | public: | 82 | public: |
83 | QString myreadbuffer; // we want to keep every thing in order to fish for the | 83 | QString myreadbuffer; // we want to keep every thing in order to fish for the |
84 | 84 | ||
85 | // connection speed later on | 85 | // connection speed later on |
86 | QPushButton *debug; | 86 | QPushButton *debug; |
87 | int main_timer_ID; | 87 | int main_timer_ID; |
88 | 88 | ||
89 | private: | 89 | private: |
90 | int vmain; | 90 | int vmain; |
91 | int substate; | 91 | int substate; |
92 | int scriptindex; | 92 | int scriptindex; |
93 | QString scriptCommand, scriptArgument; | 93 | QString scriptCommand, scriptArgument; |
94 | QStringList *comlist, *arglist; | 94 | QStringList *comlist, *arglist; |
95 | 95 | ||
96 | // static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2); | 96 | // static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2); |
97 | int loopnest; | 97 | int loopnest; |
98 | int loopstartindex[MAXLOOPNEST]; | 98 | int loopstartindex[MAXLOOPNEST]; |
99 | bool loopend; | 99 | bool loopend; |
100 | QString loopstr[MAXLOOPNEST]; | 100 | QString loopstr[MAXLOOPNEST]; |
101 | 101 | ||
102 | bool semaphore; | 102 | bool semaphore; |
103 | QTimer *inittimer; | 103 | QTimer *inittimer; |
104 | 104 | ||
105 | QTimer *timeout_timer; | 105 | QTimer *timeout_timer; |
106 | bool execppp(); | 106 | bool execppp(); |
107 | void writeline(const QString &); | 107 | void writeline(const QString &); |
108 | void checkBuffers(); | 108 | void checkBuffers(); |
109 | 109 | ||
110 | void setExpect(const QString &); | 110 | void setExpect(const QString &); |
111 | bool expecting; | 111 | bool expecting; |
112 | QString expectstr; | 112 | QString expectstr; |
113 | 113 | ||
114 | QString readbuffer; | 114 | QString readbuffer; |
115 | 115 | ||
116 | void setScan(const QString &); | 116 | void setScan(const QString &); |
117 | QString scanvar; | 117 | QString scanvar; |
118 | QString scanstr; | 118 | QString scanstr; |
119 | QString scanbuffer; | 119 | QString scanbuffer; |
120 | bool scanning; | 120 | bool scanning; |
121 | 121 | ||
122 | bool pausing; | 122 | bool pausing; |
123 | PWEntry *prompt; | 123 | PWEntry *prompt; |
124 | // LoginTerm *termwindow; | 124 | // LoginTerm *termwindow; |
125 | 125 | ||
126 | int scriptTimeout; | 126 | int scriptTimeout; |
127 | QTimer *pausetimer; | 127 | QTimer *pausetimer; |
128 | QTimer *if_timer; | 128 | QTimer *if_timer; |
129 | QTimer *if_timeout_timer; | 129 | QTimer *if_timeout_timer; |
130 | 130 | ||
131 | QLabel *messg; | 131 | QLabel *messg; |
132 | QPushButton *cancel; | 132 | QPushButton *cancel; |
133 | 133 | ||
134 | bool firstrunID; | 134 | bool firstrunID; |
135 | bool firstrunPW; | 135 | bool firstrunPW; |
136 | 136 | ||
137 | unsigned int dialnumber; // the current number to dial | 137 | unsigned int dialnumber; // the current number to dial |
138 | 138 | ||
139 | // PPPStats *stats; | 139 | InterfacePPP *_ifaceppp; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | 142 | ||
143 | // non-member function to kill&wait on the pppd child process | 143 | // non-member function to kill&wait on the pppd child process |
144 | extern void killppp(); | 144 | extern void killppp(PPPData*); |
145 | void adddns(); | 145 | void adddns(InterfacePPP*); |
146 | void addpeerdns(); | 146 | void addpeerdns(InterfacePPP*); |
147 | void removedns(); | 147 | void removedns(InterfacePPP*); |
148 | void add_domain(const QString & newdomain); | 148 | void add_domain(const QString & newdomain, InterfacePPP*); |
149 | void auto_hostname(); | 149 | void auto_hostname(InterfacePPP*); |
150 | 150 | ||
151 | #endif | 151 | #endif |
152 | 152 | ||
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp index 20d705d..9136ca0 100644 --- a/noncore/settings/networksettings/ppp/conwindow.cpp +++ b/noncore/settings/networksettings/ppp/conwindow.cpp | |||
@@ -1,341 +1,338 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU Library General Public | 10 | * modify it under the terms of the GNU Library General Public |
11 | * License as published by the Free Software Foundation; either | 11 | * License as published by the Free Software Foundation; either |
12 | * version 2 of the License, or (at your option) any later version. | 12 | * version 2 of the License, or (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | * Library General Public License for more details. | 17 | * Library General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU Library General Public | 19 | * You should have received a copy of the GNU Library General Public |
20 | * License along with this program; if not, write to the Free | 20 | * License along with this program; if not, write to the Free |
21 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include "conwindow.h" | 26 | #include "conwindow.h" |
27 | //#include "docking.h" | 27 | //#include "docking.h" |
28 | #include "pppdata.h" | 28 | #include "pppdata.h" |
29 | // #include "pppstats.h" | 29 | // #include "pppstats.h" |
30 | // #include <klocale.h> | 30 | // #include <klocale.h> |
31 | #define i18n QObject::tr | 31 | #define i18n QObject::tr |
32 | // #include <kglobal.h> | 32 | // #include <kglobal.h> |
33 | 33 | ||
34 | extern PPPData gpppdata; | ||
35 | 34 | ||
36 | ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) | 35 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, |
37 | // PPPStats *st) | 36 | QDialog *mainwidget ) |
38 | : QWidget(parent, name, 0), | 37 | : QWidget(parent, name, 0), |
39 | minutes(0), | 38 | minutes(0), |
40 | seconds(0), | 39 | seconds(0), |
41 | hours(0), | 40 | hours(0), |
42 | days(0), | 41 | days(0), |
43 | tl1(0), | 42 | tl1(0), |
44 | // stats(st), | 43 | _pppdata(pd) |
45 | accountingEnabled(false), | ||
46 | volumeAccountingEnabled(false) | ||
47 | { | 44 | { |
48 | info1 = new QLabel(i18n("Connected at:"), this); | 45 | info1 = new QLabel(i18n("Connected at:"), this); |
49 | info2 = new QLabel("", this); | 46 | info2 = new QLabel("", this); |
50 | 47 | ||
51 | timelabel1 = new QLabel(i18n("Time connected:"), this); | 48 | timelabel1 = new QLabel(i18n("Time connected:"), this); |
52 | timelabel2 = new QLabel("000:00:00", this); | 49 | timelabel2 = new QLabel("000:00:00", this); |
53 | 50 | ||
54 | vollabel = new QLabel(i18n("Volume:"), this); | 51 | vollabel = new QLabel(i18n("Volume:"), this); |
55 | volinfo = new QLabel("", this); | 52 | volinfo = new QLabel("", this); |
56 | 53 | ||
57 | // now the stuff for accounting | 54 | // now the stuff for accounting |
58 | session_bill_l = new QLabel(i18n("Session Bill:"), this); | 55 | session_bill_l = new QLabel(i18n("Session Bill:"), this); |
59 | session_bill = new QLabel("", this); | 56 | session_bill = new QLabel("", this); |
60 | total_bill_l = new QLabel(i18n("Total Bill:"), this); | 57 | total_bill_l = new QLabel(i18n("Total Bill:"), this); |
61 | total_bill = new QLabel("", this); | 58 | total_bill = new QLabel("", this); |
62 | 59 | ||
63 | this->setCaption("kppp"); | 60 | this->setCaption("kppp"); |
64 | 61 | ||
65 | cancelbutton = new QPushButton(this); | 62 | cancelbutton = new QPushButton(this); |
66 | cancelbutton->setText(i18n("Disconnect")); | 63 | cancelbutton->setText(i18n("Disconnect")); |
67 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); | 64 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); |
68 | 65 | ||
69 | // statsbutton = new QPushButton(this); | 66 | // statsbutton = new QPushButton(this); |
70 | // statsbutton->setText(i18n("Details")); | 67 | // statsbutton->setText(i18n("Details")); |
71 | // statsbutton->setFocus(); | 68 | // statsbutton->setFocus(); |
72 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); | 69 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); |
73 | 70 | ||
74 | clocktimer = new QTimer(this); | 71 | clocktimer = new QTimer(this); |
75 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); | 72 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); |
76 | 73 | ||
77 | // read window position from config file | 74 | // read window position from config file |
78 | // int p_x, p_y; | 75 | // int p_x, p_y; |
79 | // PPPData::data()->winPosConWin(p_x, p_y); | 76 | // PPPData::data()->winPosConWin(p_x, p_y); |
80 | // setGeometry(p_x, p_y, 320, 110); | 77 | // setGeometry(p_x, p_y, 320, 110); |
81 | } | 78 | } |
82 | 79 | ||
83 | ConWindow::~ConWindow() { | 80 | ConWindow::~ConWindow() { |
84 | stopClock(); | 81 | stopClock(); |
85 | } | 82 | } |
86 | 83 | ||
87 | // save window position when window was closed | 84 | // save window position when window was closed |
88 | bool ConWindow::event(QEvent *e) { | 85 | bool ConWindow::event(QEvent *e) { |
89 | if (e->type() == QEvent::Hide) | 86 | if (e->type() == QEvent::Hide) |
90 | { | 87 | { |
91 | // PPPData::data()->setWinPosConWin(x(), y()); | 88 | // PPPData::data()->setWinPosConWin(x(), y()); |
92 | return true; | 89 | return true; |
93 | } | 90 | } |
94 | else | 91 | else |
95 | return QWidget::event(e); | 92 | return QWidget::event(e); |
96 | } | 93 | } |
97 | 94 | ||
98 | QString ConWindow::prettyPrintVolume(unsigned int n) { | 95 | QString ConWindow::prettyPrintVolume(unsigned int n) { |
99 | int idx = 0; | 96 | int idx = 0; |
100 | const QString quant[] = {i18n("Byte"), i18n("KB"), | 97 | const QString quant[] = {i18n("Byte"), i18n("KB"), |
101 | i18n("MB"), i18n("GB"), QString::null}; | 98 | i18n("MB"), i18n("GB"), QString::null}; |
102 | 99 | ||
103 | float n1 = n; | 100 | float n1 = n; |
104 | while(n >= 1024 && quant[idx] != QString::null) { | 101 | while(n >= 1024 && quant[idx] != QString::null) { |
105 | idx++; | 102 | idx++; |
106 | n /= 1024; | 103 | n /= 1024; |
107 | } | 104 | } |
108 | 105 | ||
109 | int i = idx; | 106 | int i = idx; |
110 | while(i--) | 107 | while(i--) |
111 | n1 = n1 / 1024.0; | 108 | n1 = n1 / 1024.0; |
112 | 109 | ||
113 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); | 110 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); |
114 | s += " " + quant[idx]; | 111 | s += " " + quant[idx]; |
115 | return s; | 112 | return s; |
116 | } | 113 | } |
117 | 114 | ||
118 | void ConWindow::accounting(bool on) { | 115 | // void ConWindow::accounting(bool on) { |
119 | // cache accounting settings | 116 | // // cache accounting settings |
120 | accountingEnabled = on; | 117 | // accountingEnabled = on; |
121 | volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); | 118 | // // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); |
122 | |||
123 | // delete old layout | ||
124 | if(tl1 != 0) | ||
125 | delete tl1; | ||
126 | |||
127 | // add layout now | ||
128 | tl1 = new QVBoxLayout(this, 10, 10); | ||
129 | tl1->addSpacing(5); | ||
130 | QHBoxLayout *tl = new QHBoxLayout; | ||
131 | tl1->addLayout(tl); | ||
132 | tl->addSpacing(20); | ||
133 | QGridLayout *l1; | ||
134 | |||
135 | int vol_lines = 0; | ||
136 | if(PPPData::data()->VolAcctEnabled()) | ||
137 | vol_lines = 1; | ||
138 | |||
139 | if(accountingEnabled) | ||
140 | l1 = new QGridLayout(4 + vol_lines, 2, 5); | ||
141 | else | ||
142 | l1 = new QGridLayout(2 + vol_lines, 2, 5); | ||
143 | tl->addLayout(l1); | ||
144 | l1->setColStretch(0, 0); | ||
145 | l1->setColStretch(1, 1); | ||
146 | |||
147 | info2->setAlignment(AlignRight|AlignVCenter); | ||
148 | timelabel2->setAlignment(AlignRight|AlignVCenter); | ||
149 | session_bill->setAlignment(AlignRight|AlignVCenter); | ||
150 | total_bill->setAlignment(AlignRight|AlignVCenter); | ||
151 | volinfo->setAlignment(AlignRight|AlignVCenter); | ||
152 | // make sure that there's enough space for the bills | ||
153 | QString s1 = session_bill->text(); | ||
154 | QString s2 = total_bill->text(); | ||
155 | QString s3 = volinfo->text(); | ||
156 | |||
157 | session_bill->setText("888888.88 XXX"); | ||
158 | total_bill->setText("888888.88 XXX"); | ||
159 | volinfo->setText("8888.8 MB"); | ||
160 | session_bill->setFixedSize(session_bill->sizeHint()); | ||
161 | total_bill->setFixedSize(total_bill->sizeHint()); | ||
162 | volinfo->setFixedSize(volinfo->sizeHint()); | ||
163 | session_bill->setText(s1); | ||
164 | total_bill->setText(s2); | ||
165 | volinfo->setText(s3); | ||
166 | |||
167 | l1->addWidget(info1, 0, 0); | ||
168 | l1->addWidget(info2, 0, 1); | ||
169 | l1->addWidget(timelabel1, 1, 0); | ||
170 | l1->addWidget(timelabel2, 1, 1); | ||
171 | if(accountingEnabled) { | ||
172 | session_bill_l->show(); | ||
173 | session_bill->show(); | ||
174 | total_bill_l->show(); | ||
175 | total_bill->show(); | ||
176 | l1->addWidget(session_bill_l, 2, 0); | ||
177 | l1->addWidget(session_bill, 2, 1); | ||
178 | l1->addWidget(total_bill_l, 3, 0); | ||
179 | l1->addWidget(total_bill, 3, 1); | ||
180 | |||
181 | if(volumeAccountingEnabled) { | ||
182 | vollabel->show(); | ||
183 | volinfo->show(); | ||
184 | l1->addWidget(vollabel, 4, 0); | ||
185 | l1->addWidget(volinfo, 4, 1); | ||
186 | } else { | ||
187 | vollabel->hide(); | ||
188 | volinfo->hide(); | ||
189 | } | ||
190 | |||
191 | } else { | ||
192 | session_bill_l->hide(); | ||
193 | session_bill->hide(); | ||
194 | total_bill_l->hide(); | ||
195 | total_bill->hide(); | ||
196 | |||
197 | if(volumeAccountingEnabled) { | ||
198 | vollabel->show(); | ||
199 | volinfo->show(); | ||
200 | l1->addWidget(vollabel, 2, 0); | ||
201 | l1->addWidget(volinfo, 2, 1); | ||
202 | } else { | ||
203 | vollabel->hide(); | ||
204 | volinfo->hide(); | ||
205 | } | ||
206 | } | ||
207 | 119 | ||
208 | tl->addSpacing(10); | 120 | // // delete old layout |
209 | QVBoxLayout *l2 = new QVBoxLayout(5); | 121 | // if(tl1 != 0) |
210 | tl->addLayout(l2); | 122 | // delete tl1; |
211 | l2->addStretch(1); | ||
212 | // l2->addWidget(statsbutton); | ||
213 | l2->addWidget(cancelbutton); | ||
214 | 123 | ||
215 | l2->addStretch(1); | 124 | // // add layout now |
125 | // tl1 = new QVBoxLayout(this, 10, 10); | ||
126 | // tl1->addSpacing(5); | ||
127 | // QHBoxLayout *tl = new QHBoxLayout; | ||
128 | // tl1->addLayout(tl); | ||
129 | // tl->addSpacing(20); | ||
130 | // QGridLayout *l1; | ||
216 | 131 | ||
217 | tl1->addSpacing(5); | 132 | // int vol_lines = 0; |
133 | // // if(_pppdata->VolAcctEnabled()) | ||
134 | // // vol_lines = 1; | ||
218 | 135 | ||
219 | setFixedSize(sizeHint()); | 136 | // if(accountingEnabled) |
220 | /* | 137 | // l1 = new QGridLayout(4 + vol_lines, 2, 5); |
221 | do not overwrite position read from config | 138 | // else |
222 | setGeometry((QApplication::desktop()->width() - width()) / 2, | 139 | // l1 = new QGridLayout(2 + vol_lines, 2, 5); |
223 | (QApplication::desktop()->height() - height())/2, | 140 | // tl->addLayout(l1); |
224 | width(), | 141 | // l1->setColStretch(0, 0); |
225 | height()); | 142 | // l1->setColStretch(1, 1); |
226 | */ | 143 | |
227 | } | 144 | // info2->setAlignment(AlignRight|AlignVCenter); |
145 | // timelabel2->setAlignment(AlignRight|AlignVCenter); | ||
146 | // session_bill->setAlignment(AlignRight|AlignVCenter); | ||
147 | // total_bill->setAlignment(AlignRight|AlignVCenter); | ||
148 | // volinfo->setAlignment(AlignRight|AlignVCenter); | ||
149 | // // make sure that there's enough space for the bills | ||
150 | // QString s1 = session_bill->text(); | ||
151 | // QString s2 = total_bill->text(); | ||
152 | // QString s3 = volinfo->text(); | ||
153 | |||
154 | // session_bill->setText("888888.88 XXX"); | ||
155 | // total_bill->setText("888888.88 XXX"); | ||
156 | // volinfo->setText("8888.8 MB"); | ||
157 | // session_bill->setFixedSize(session_bill->sizeHint()); | ||
158 | // total_bill->setFixedSize(total_bill->sizeHint()); | ||
159 | // volinfo->setFixedSize(volinfo->sizeHint()); | ||
160 | // session_bill->setText(s1); | ||
161 | // total_bill->setText(s2); | ||
162 | // volinfo->setText(s3); | ||
163 | |||
164 | // l1->addWidget(info1, 0, 0); | ||
165 | // l1->addWidget(info2, 0, 1); | ||
166 | // l1->addWidget(timelabel1, 1, 0); | ||
167 | // l1->addWidget(timelabel2, 1, 1); | ||
168 | // if(accountingEnabled) { | ||
169 | // session_bill_l->show(); | ||
170 | // session_bill->show(); | ||
171 | // total_bill_l->show(); | ||
172 | // total_bill->show(); | ||
173 | // l1->addWidget(session_bill_l, 2, 0); | ||
174 | // l1->addWidget(session_bill, 2, 1); | ||
175 | // l1->addWidget(total_bill_l, 3, 0); | ||
176 | // l1->addWidget(total_bill, 3, 1); | ||
177 | |||
178 | // if(volumeAccountingEnabled) { | ||
179 | // vollabel->show(); | ||
180 | // volinfo->show(); | ||
181 | // l1->addWidget(vollabel, 4, 0); | ||
182 | // l1->addWidget(volinfo, 4, 1); | ||
183 | // } else { | ||
184 | // vollabel->hide(); | ||
185 | // volinfo->hide(); | ||
186 | // } | ||
187 | |||
188 | // } else { | ||
189 | // session_bill_l->hide(); | ||
190 | // session_bill->hide(); | ||
191 | // total_bill_l->hide(); | ||
192 | // total_bill->hide(); | ||
193 | |||
194 | // if(volumeAccountingEnabled) { | ||
195 | // vollabel->show(); | ||
196 | // volinfo->show(); | ||
197 | // l1->addWidget(vollabel, 2, 0); | ||
198 | // l1->addWidget(volinfo, 2, 1); | ||
199 | // } else { | ||
200 | // vollabel->hide(); | ||
201 | // volinfo->hide(); | ||
202 | // } | ||
203 | // } | ||
228 | 204 | ||
205 | // tl->addSpacing(10); | ||
206 | // QVBoxLayout *l2 = new QVBoxLayout(5); | ||
207 | // tl->addLayout(l2); | ||
208 | // l2->addStretch(1); | ||
209 | // // l2->addWidget(statsbutton); | ||
210 | // l2->addWidget(cancelbutton); | ||
229 | 211 | ||
230 | void ConWindow::dock() { | 212 | // l2->addStretch(1); |
231 | // DockWidget::dock_widget->show(); | 213 | |
232 | this->hide(); | 214 | // tl1->addSpacing(5); |
233 | } | 215 | |
216 | // setFixedSize(sizeHint()); | ||
217 | // /* | ||
218 | // do not overwrite position read from config | ||
219 | // setGeometry((QApplication::desktop()->width() - width()) / 2, | ||
220 | // (QApplication::desktop()->height() - height())/2, | ||
221 | // width(), | ||
222 | // height()); | ||
223 | // */ | ||
224 | // } | ||
225 | |||
226 | |||
227 | // void ConWindow::dock() { | ||
228 | // // DockWidget::dock_widget->show(); | ||
229 | // this->hide(); | ||
230 | // } | ||
234 | 231 | ||
235 | 232 | ||
236 | void ConWindow::startClock() { | 233 | void ConWindow::startClock() { |
237 | minutes = 0; | 234 | minutes = 0; |
238 | seconds = 0; | 235 | seconds = 0; |
239 | hours = 0; | 236 | hours = 0; |
240 | QString title ; | 237 | QString title ; |
241 | 238 | ||
242 | title = PPPData::data()->accname(); | 239 | title = _pppdata->accname(); |
243 | 240 | ||
244 | if(PPPData::data()->get_show_clock_on_caption()){ | 241 | if(_pppdata->get_show_clock_on_caption()){ |
245 | title += " 00:00" ; | 242 | title += " 00:00" ; |
246 | } | 243 | } |
247 | this->setCaption(title); | 244 | this->setCaption(title); |
248 | 245 | ||
249 | timelabel2->setText("00:00:00"); | 246 | timelabel2->setText("00:00:00"); |
250 | clocktimer->start(1000); | 247 | clocktimer->start(1000); |
251 | } | 248 | } |
252 | 249 | ||
253 | 250 | ||
254 | void ConWindow::setConnectionSpeed(const QString &speed) { | 251 | void ConWindow::setConnectionSpeed(const QString &speed) { |
255 | info2->setText(speed); | 252 | info2->setText(speed); |
256 | } | 253 | } |
257 | 254 | ||
258 | 255 | ||
259 | void ConWindow::stopClock() { | 256 | void ConWindow::stopClock() { |
260 | clocktimer->stop(); | 257 | clocktimer->stop(); |
261 | } | 258 | } |
262 | 259 | ||
263 | 260 | ||
264 | void ConWindow::timeclick() { | 261 | void ConWindow::timeclick() { |
265 | // QString tooltip = i18n("Connection: %1\n" | 262 | // QString tooltip = i18n("Connection: %1\n" |
266 | // "Connected at: %2\n" | 263 | // "Connected at: %2\n" |
267 | // "Time connected: %3") | 264 | // "Time connected: %3") |
268 | // .arg(PPPData::data()->accname()).arg(info2->text()) | 265 | // .arg(_pppdata->accname()).arg(info2->text()) |
269 | // .arg(time_string2); | 266 | // .arg(time_string2); |
270 | 267 | ||
271 | // if(accountingEnabled) | 268 | // if(accountingEnabled) |
272 | // tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") | 269 | // tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") |
273 | // .arg(session_bill->text()).arg(total_bill->text()); | 270 | // .arg(session_bill->text()).arg(total_bill->text()); |
274 | // // volume accounting | 271 | // // volume accounting |
275 | // if(volumeAccountingEnabled) { | 272 | // if(volumeAccountingEnabled) { |
276 | 273 | ||
277 | // volinfo->setEnabled(TRUE); | 274 | // volinfo->setEnabled(TRUE); |
278 | // int bytes = PPPData::data()->totalBytes(); | 275 | // int bytes = _pppdata->totalBytes(); |
279 | // volinfo->setText(prettyPrintVolume(bytes)); | 276 | // volinfo->setText(prettyPrintVolume(bytes)); |
280 | // } | 277 | // } |
281 | 278 | ||
282 | // seconds++; | 279 | // seconds++; |
283 | 280 | ||
284 | // if(seconds >= 60 ) { | 281 | // if(seconds >= 60 ) { |
285 | // minutes ++; | 282 | // minutes ++; |
286 | // seconds = 0; | 283 | // seconds = 0; |
287 | // } | 284 | // } |
288 | 285 | ||
289 | // if (minutes >= 60){ | 286 | // if (minutes >= 60){ |
290 | // minutes = 0; | 287 | // minutes = 0; |
291 | // hours ++; | 288 | // hours ++; |
292 | // } | 289 | // } |
293 | 290 | ||
294 | // if( hours >= 24){ | 291 | // if( hours >= 24){ |
295 | // days ++; | 292 | // days ++; |
296 | // hours = 0; | 293 | // hours = 0; |
297 | // } | 294 | // } |
298 | 295 | ||
299 | // time_string.sprintf("%02d:%02d",hours,minutes); | 296 | // time_string.sprintf("%02d:%02d",hours,minutes); |
300 | // time_string2 = ""; | 297 | // time_string2 = ""; |
301 | // if (days) | 298 | // if (days) |
302 | // time_string2.sprintf("%d d %02d:%02d:%02d", | 299 | // time_string2.sprintf("%d d %02d:%02d:%02d", |
303 | // days,hours,minutes,seconds); | 300 | // days,hours,minutes,seconds); |
304 | 301 | ||
305 | // else | 302 | // else |
306 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); | 303 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); |
307 | 304 | ||
308 | // caption_string = PPPData::data()->accname(); | 305 | // caption_string = _pppdata->accname(); |
309 | // caption_string += " "; | 306 | // caption_string += " "; |
310 | // caption_string += time_string; | 307 | // caption_string += time_string; |
311 | 308 | ||
312 | 309 | ||
313 | // timelabel2->setText(time_string2); | 310 | // timelabel2->setText(time_string2); |
314 | 311 | ||
315 | // if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){ | 312 | // if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){ |
316 | // // we update the Caption only once per minute not every second | 313 | // // we update the Caption only once per minute not every second |
317 | // // otherwise I get a flickering icon | 314 | // // otherwise I get a flickering icon |
318 | // this->setCaption(caption_string); | 315 | // this->setCaption(caption_string); |
319 | // } | 316 | // } |
320 | 317 | ||
321 | // QToolTip::add(DockWidget::dock_widget, tooltip); | 318 | // QToolTip::add(DockWidget::dock_widget, tooltip); |
322 | } | 319 | } |
323 | 320 | ||
324 | 321 | ||
325 | void ConWindow::closeEvent( QCloseEvent *e ){ | 322 | void ConWindow::closeEvent( QCloseEvent *e ){ |
326 | // we don't want to lose the | 323 | // we don't want to lose the |
327 | // conwindow since this is our last connection kppp. | 324 | // conwindow since this is our last connection kppp. |
328 | // if we lost it we could only kill the program by hand to get on with life. | 325 | // if we lost it we could only kill the program by hand to get on with life. |
329 | e->ignore(); | 326 | e->ignore(); |
330 | 327 | ||
331 | if(PPPData::data()->get_dock_into_panel()) | 328 | // if(_pppdata->get_dock_into_panel()) |
332 | dock(); | 329 | // dock(); |
333 | } | 330 | } |
334 | 331 | ||
335 | 332 | ||
336 | void ConWindow::slotAccounting(QString total, QString session) { | 333 | void ConWindow::slotAccounting(QString total, QString session) { |
337 | total_bill->setText(total); | 334 | total_bill->setText(total); |
338 | session_bill->setText(session); | 335 | session_bill->setText(session); |
339 | } | 336 | } |
340 | 337 | ||
341 | 338 | ||
diff --git a/noncore/settings/networksettings/ppp/conwindow.h b/noncore/settings/networksettings/ppp/conwindow.h index 20d3579..42c6f35 100644 --- a/noncore/settings/networksettings/ppp/conwindow.h +++ b/noncore/settings/networksettings/ppp/conwindow.h | |||
@@ -1,96 +1,94 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU Library General Public | 11 | * modify it under the terms of the GNU Library General Public |
12 | * License as published by the Free Software Foundation; either | 12 | * License as published by the Free Software Foundation; either |
13 | * version 2 of the License, or (at your option) any later version. | 13 | * version 2 of the License, or (at your option) any later version. |
14 | * | 14 | * |
15 | * This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | * Library General Public License for more details. | 18 | * Library General Public License for more details. |
19 | * | 19 | * |
20 | * You should have received a copy of the GNU Library General Public | 20 | * You should have received a copy of the GNU Library General Public |
21 | * License along with this program; if not, write to the Free | 21 | * License along with this program; if not, write to the Free |
22 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef _CONWINDOW_H_ | 25 | #ifndef _CONWINDOW_H_ |
26 | #define _CONWINDOW_H_ | 26 | #define _CONWINDOW_H_ |
27 | 27 | ||
28 | 28 | ||
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qframe.h> | 33 | #include <qframe.h> |
34 | #include <qevent.h> | 34 | #include <qevent.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | 36 | ||
37 | //class PPPStats; | 37 | class PPPData; |
38 | 38 | ||
39 | class ConWindow : public QWidget { | 39 | class ConWindow : public QWidget { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | 41 | ||
42 | public: | 42 | public: |
43 | ConWindow(QWidget *parent, const char *name, QDialog* ); | 43 | ConWindow(PPPData*, QWidget *parent, const char *name, QDialog* ); |
44 | ~ConWindow(); | 44 | ~ConWindow(); |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | void closeEvent( QCloseEvent *e ); | 47 | void closeEvent( QCloseEvent *e ); |
48 | bool event( QEvent *e ); | 48 | bool event( QEvent *e ); |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void timeclick(); | 51 | void timeclick(); |
52 | void dock(); | 52 | // void dock(); |
53 | 53 | ||
54 | public: | 54 | public: |
55 | void setConnectionSpeed(const QString&); | 55 | void setConnectionSpeed(const QString&); |
56 | void startClock(); | 56 | void startClock(); |
57 | void stopClock(); | 57 | void stopClock(); |
58 | void accounting(bool); // show/ hide accounting info | 58 | // void accounting(bool); // show/ hide accounting info |
59 | 59 | ||
60 | public slots: | 60 | public slots: |
61 | void slotAccounting(QString, QString); | 61 | void slotAccounting(QString, QString); |
62 | 62 | ||
63 | private: | 63 | private: |
64 | QLabel *info1; | 64 | QLabel *info1; |
65 | QLabel *info2; | 65 | QLabel *info2; |
66 | QPushButton *cancelbutton; | 66 | QPushButton *cancelbutton; |
67 | QPushButton *statsbutton; | 67 | QPushButton *statsbutton; |
68 | QString prettyPrintVolume(unsigned int); | 68 | QString prettyPrintVolume(unsigned int); |
69 | int minutes; | 69 | int minutes; |
70 | int seconds; | 70 | int seconds; |
71 | int hours; | 71 | int hours; |
72 | int days; | 72 | int days; |
73 | QFrame *fline; | 73 | QFrame *fline; |
74 | QLabel *timelabel1; | 74 | QLabel *timelabel1; |
75 | QLabel *timelabel2; | 75 | QLabel *timelabel2; |
76 | QLabel *total_bill, *total_bill_l; | 76 | QLabel *total_bill, *total_bill_l; |
77 | QLabel *session_bill, *session_bill_l; | 77 | QLabel *session_bill, *session_bill_l; |
78 | QString caption_string; | 78 | QString caption_string; |
79 | QString time_string2; | 79 | QString time_string2; |
80 | QString time_string; | 80 | QString time_string; |
81 | QTimer *clocktimer; | 81 | QTimer *clocktimer; |
82 | QVBoxLayout *tl1; | 82 | QVBoxLayout *tl1; |
83 | QLabel *vollabel; | 83 | QLabel *vollabel; |
84 | QLabel *volinfo; | 84 | QLabel *volinfo; |
85 | // PPPStats *stats; | 85 | PPPData *_pppdata; |
86 | bool accountingEnabled; | ||
87 | bool volumeAccountingEnabled; | ||
88 | }; | 86 | }; |
89 | 87 | ||
90 | 88 | ||
91 | #endif | 89 | #endif |
92 | 90 | ||
93 | 91 | ||
94 | 92 | ||
95 | 93 | ||
96 | 94 | ||
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index eee643d..8ae714e 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -1,1197 +1,1198 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * | 7 | * |
8 | * based on EzPPP: | 8 | * based on EzPPP: |
9 | * Copyright (C) 1997 Jay Painter | 9 | * Copyright (C) 1997 Jay Painter |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <termios.h> | 27 | #include <termios.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <kiconloader.h> | 33 | //#include <kiconloader.h> |
34 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
35 | //#include <klocale.h> | 35 | //#include <klocale.h> |
36 | #define i18n QObject::tr | 36 | #define i18n QObject::tr |
37 | #include <qvgroupbox.h> | 37 | #include <qvgroupbox.h> |
38 | #include <qhbox.h> | 38 | #include <qhbox.h> |
39 | #include <qdialog.h> | 39 | #include <qdialog.h> |
40 | //#include <kwin.h> | 40 | //#include <kwin.h> |
41 | 41 | ||
42 | #include "edit.h" | 42 | #include "edit.h" |
43 | #include "pppdata.h" | 43 | #include "pppdata.h" |
44 | //#include "newwidget.h" | 44 | //#include "newwidget.h" |
45 | #include "iplined.h" | 45 | #include "iplined.h" |
46 | #include "auth.h" | 46 | #include "auth.h" |
47 | 47 | ||
48 | DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) | 48 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
49 | : QWidget(parent, name) | 49 | , const char *name ) |
50 | : QWidget(parent, name), _pppdata(pd) | ||
50 | { | 51 | { |
51 | const int GRIDROWS = 6; | 52 | const int GRIDROWS = 6; |
52 | 53 | ||
53 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | 54 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); |
54 | 55 | ||
55 | connect_label = new QLabel(i18n("Connection name:"), this); | 56 | connect_label = new QLabel(i18n("Connection name:"), this); |
56 | tl->addWidget(connect_label, 0, 0); | 57 | tl->addWidget(connect_label, 0, 0); |
57 | 58 | ||
58 | connectname_l = new QLineEdit(this); | 59 | connectname_l = new QLineEdit(this); |
59 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 60 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
60 | tl->addWidget(connectname_l, 0, 1); | 61 | tl->addWidget(connectname_l, 0, 1); |
61 | QString tmp = i18n("Type in a unique name for this connection"); | 62 | QString tmp = i18n("Type in a unique name for this connection"); |
62 | 63 | ||
63 | QWhatsThis::add(connect_label,tmp); | 64 | QWhatsThis::add(connect_label,tmp); |
64 | QWhatsThis::add(connectname_l,tmp); | 65 | QWhatsThis::add(connectname_l,tmp); |
65 | 66 | ||
66 | 67 | ||
67 | number_label = new QLabel(i18n("Phone number:"), this); | 68 | number_label = new QLabel(i18n("Phone number:"), this); |
68 | number_label->setAlignment(AlignTop|AlignLeft); | 69 | number_label->setAlignment(AlignTop|AlignLeft); |
69 | tl->addWidget(number_label, 1, 0); | 70 | tl->addWidget(number_label, 1, 0); |
70 | 71 | ||
71 | QHBoxLayout *lpn = new QHBoxLayout(5); | 72 | QHBoxLayout *lpn = new QHBoxLayout(5); |
72 | tl->addLayout(lpn, 1, 1); | 73 | tl->addLayout(lpn, 1, 1); |
73 | numbers = new QListBox(this); | 74 | numbers = new QListBox(this); |
74 | // numbers->setMinimumSize(120, 70); | 75 | // numbers->setMinimumSize(120, 70); |
75 | lpn->addWidget(numbers); | 76 | lpn->addWidget(numbers); |
76 | QVBoxLayout *lpn1 = new QVBoxLayout; | 77 | QVBoxLayout *lpn1 = new QVBoxLayout; |
77 | lpn->addLayout(lpn1); | 78 | lpn->addLayout(lpn1); |
78 | add = new QPushButton(i18n("&Add..."), this); | 79 | add = new QPushButton(i18n("&Add..."), this); |
79 | del = new QPushButton(i18n("&Remove"), this); | 80 | del = new QPushButton(i18n("&Remove"), this); |
80 | 81 | ||
81 | up = new QPushButton(this); | 82 | up = new QPushButton(this); |
82 | //FIXME: QPixmap pm = BarIcon("up"); | 83 | //FIXME: QPixmap pm = BarIcon("up"); |
83 | // up->setPixmap(pm); | 84 | // up->setPixmap(pm); |
84 | down = new QPushButton(this); | 85 | down = new QPushButton(this); |
85 | //FIXME: pm = BarIcon("down"); | 86 | //FIXME: pm = BarIcon("down"); |
86 | // down->setPixmap(pm); | 87 | // down->setPixmap(pm); |
87 | lpn1->addWidget(add); | 88 | lpn1->addWidget(add); |
88 | lpn1->addWidget(del); | 89 | lpn1->addWidget(del); |
89 | lpn1->addStretch(1); | 90 | lpn1->addStretch(1); |
90 | lpn1->addWidget(up); | 91 | lpn1->addWidget(up); |
91 | lpn1->addWidget(down); | 92 | lpn1->addWidget(down); |
92 | connect(add, SIGNAL(clicked()), | 93 | connect(add, SIGNAL(clicked()), |
93 | this, SLOT(addNumber())); | 94 | this, SLOT(addNumber())); |
94 | connect(del, SIGNAL(clicked()), | 95 | connect(del, SIGNAL(clicked()), |
95 | this, SLOT(delNumber())); | 96 | this, SLOT(delNumber())); |
96 | connect(up, SIGNAL(clicked()), | 97 | connect(up, SIGNAL(clicked()), |
97 | this, SLOT(upNumber())); | 98 | this, SLOT(upNumber())); |
98 | connect(down, SIGNAL(clicked()), | 99 | connect(down, SIGNAL(clicked()), |
99 | this, SLOT(downNumber())); | 100 | this, SLOT(downNumber())); |
100 | connect(numbers, SIGNAL(highlighted(int)), | 101 | connect(numbers, SIGNAL(highlighted(int)), |
101 | this, SLOT(selectionChanged(int))); | 102 | this, SLOT(selectionChanged(int))); |
102 | numbersChanged(); | 103 | numbersChanged(); |
103 | 104 | ||
104 | tmp = i18n("<p>Specifies the phone numbers to dial. You\n" | 105 | tmp = i18n("<p>Specifies the phone numbers to dial. You\n" |
105 | "can supply multiple numbers here, simply\n" | 106 | "can supply multiple numbers here, simply\n" |
106 | "click on \"Add\". You can arrange the\n" | 107 | "click on \"Add\". You can arrange the\n" |
107 | "order the numbers are tried by using the\n" | 108 | "order the numbers are tried by using the\n" |
108 | "arrow buttons.\n\n" | 109 | "arrow buttons.\n\n" |
109 | "When a number is busy or fails, <i>kppp</i> will \n" | 110 | "When a number is busy or fails, <i>kppp</i> will \n" |
110 | "try the next number and so on"); | 111 | "try the next number and so on"); |
111 | 112 | ||
112 | QWhatsThis::add(number_label,tmp); | 113 | QWhatsThis::add(number_label,tmp); |
113 | QWhatsThis::add(numbers,tmp); | 114 | QWhatsThis::add(numbers,tmp); |
114 | 115 | ||
115 | auth_l = new QLabel(i18n("Authentication:"), this); | 116 | auth_l = new QLabel(i18n("Authentication:"), this); |
116 | tl->addWidget(auth_l, 3, 0); | 117 | tl->addWidget(auth_l, 3, 0); |
117 | 118 | ||
118 | auth = new QComboBox(this); | 119 | auth = new QComboBox(this); |
119 | auth->insertItem(i18n("Script-based")); | 120 | auth->insertItem(i18n("Script-based")); |
120 | auth->insertItem(i18n("PAP")); | 121 | auth->insertItem(i18n("PAP")); |
121 | auth->insertItem(i18n("Terminal-based")); | 122 | auth->insertItem(i18n("Terminal-based")); |
122 | auth->insertItem(i18n("CHAP")); | 123 | auth->insertItem(i18n("CHAP")); |
123 | auth->insertItem(i18n("PAP/CHAP")); | 124 | auth->insertItem(i18n("PAP/CHAP")); |
124 | tl->addWidget(auth, 3, 1); | 125 | tl->addWidget(auth, 3, 1); |
125 | tmp = i18n("<p>Specifies the method used to identify yourself to\n" | 126 | tmp = i18n("<p>Specifies the method used to identify yourself to\n" |
126 | "the PPP server. Most universities still use\n" | 127 | "the PPP server. Most universities still use\n" |
127 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | 128 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" |
128 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | 129 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" |
129 | "unsure, contact your ISP.\n" | 130 | "unsure, contact your ISP.\n" |
130 | "\n" | 131 | "\n" |
131 | "If you can choose between PAP and CHAP,\n" | 132 | "If you can choose between PAP and CHAP,\n" |
132 | "choose CHAP, because it's much safer. If you don't know\n" | 133 | "choose CHAP, because it's much safer. If you don't know\n" |
133 | "whether PAP or CHAP is right, choose PAP/CHAP."); | 134 | "whether PAP or CHAP is right, choose PAP/CHAP."); |
134 | 135 | ||
135 | QWhatsThis::add(auth_l,tmp); | 136 | QWhatsThis::add(auth_l,tmp); |
136 | QWhatsThis::add(auth,tmp); | 137 | QWhatsThis::add(auth,tmp); |
137 | 138 | ||
138 | store_password = new QCheckBox(i18n("Store password"), this); | 139 | store_password = new QCheckBox(i18n("Store password"), this); |
139 | store_password->setChecked(true); | 140 | store_password->setChecked(true); |
140 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); | 141 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); |
141 | QWhatsThis::add(store_password, | 142 | QWhatsThis::add(store_password, |
142 | i18n("<p>When this is turned on, your ISP password\n" | 143 | i18n("<p>When this is turned on, your ISP password\n" |
143 | "will be saved in <i>kppp</i>'s config file, so\n" | 144 | "will be saved in <i>kppp</i>'s config file, so\n" |
144 | "you do not need to type it in every time.\n" | 145 | "you do not need to type it in every time.\n" |
145 | "\n" | 146 | "\n" |
146 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | 147 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" |
147 | "plain text in the config file, which is\n" | 148 | "plain text in the config file, which is\n" |
148 | "readable only to you. Make sure nobody\n" | 149 | "readable only to you. Make sure nobody\n" |
149 | "gains access to this file!")); | 150 | "gains access to this file!")); |
150 | 151 | ||
151 | pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this); | 152 | pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this); |
152 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 153 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
153 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 154 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
154 | 155 | ||
155 | // Set defaults if editing an existing connection | 156 | // Set defaults if editing an existing connection |
156 | if(!isnewaccount) { | 157 | if(!isnewaccount) { |
157 | connectname_l->setText(PPPData::data()->accname()); | 158 | connectname_l->setText(_pppdata->accname()); |
158 | 159 | ||
159 | // insert the phone numbers into the listbox | 160 | // insert the phone numbers into the listbox |
160 | QString n = PPPData::data()->phonenumber(); | 161 | QString n = _pppdata->phonenumber(); |
161 | QString tmp = ""; | 162 | QString tmp = ""; |
162 | uint idx = 0; | 163 | uint idx = 0; |
163 | while(idx != n.length()) { | 164 | while(idx != n.length()) { |
164 | if(n[idx] == ':') { | 165 | if(n[idx] == ':') { |
165 | if(tmp.length() > 0) | 166 | if(tmp.length() > 0) |
166 | numbers->insertItem(tmp); | 167 | numbers->insertItem(tmp); |
167 | tmp = ""; | 168 | tmp = ""; |
168 | } else | 169 | } else |
169 | tmp += n[idx]; | 170 | tmp += n[idx]; |
170 | idx++; | 171 | idx++; |
171 | } | 172 | } |
172 | if(tmp.length() > 0) | 173 | if(tmp.length() > 0) |
173 | numbers->insertItem(tmp); | 174 | numbers->insertItem(tmp); |
174 | 175 | ||
175 | auth->setCurrentItem(PPPData::data()->authMethod()); | 176 | auth->setCurrentItem(_pppdata->authMethod()); |
176 | store_password->setChecked(PPPData::data()->storePassword()); | 177 | store_password->setChecked(_pppdata->storePassword()); |
177 | } else { | 178 | } else { |
178 | // select PAP/CHAP as default | 179 | // select PAP/CHAP as default |
179 | auth->setCurrentItem(AUTH_PAPCHAP); | 180 | auth->setCurrentItem(AUTH_PAPCHAP); |
180 | } | 181 | } |
181 | 182 | ||
182 | numbersChanged(); | 183 | numbersChanged(); |
183 | tl->activate(); | 184 | tl->activate(); |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | bool DialWidget::save() { | 188 | bool DialWidget::save() { |
188 | //first check to make sure that the account name is unique! | 189 | //first check to make sure that the account name is unique! |
189 | if(connectname_l->text().isEmpty() || | 190 | if(connectname_l->text().isEmpty() || |
190 | !PPPData::data()->isUniqueAccname(connectname_l->text())) { | 191 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
191 | return false; | 192 | return false; |
192 | } else { | 193 | } else { |
193 | PPPData::data()->setAccname(connectname_l->text()); | 194 | _pppdata->setAccname(connectname_l->text()); |
194 | 195 | ||
195 | QString number = ""; | 196 | QString number = ""; |
196 | for(uint i = 0; i < numbers->count(); i++) { | 197 | for(uint i = 0; i < numbers->count(); i++) { |
197 | if(i != 0) | 198 | if(i != 0) |
198 | number += ":"; | 199 | number += ":"; |
199 | number += numbers->text(i); | 200 | number += numbers->text(i); |
200 | } | 201 | } |
201 | 202 | ||
202 | PPPData::data()->setPhonenumber(number); | 203 | _pppdata->setPhonenumber(number); |
203 | PPPData::data()->setAuthMethod(auth->currentItem()); | 204 | _pppdata->setAuthMethod(auth->currentItem()); |
204 | PPPData::data()->setStorePassword(store_password->isChecked()); | 205 | _pppdata->setStorePassword(store_password->isChecked()); |
205 | return true; | 206 | return true; |
206 | } | 207 | } |
207 | } | 208 | } |
208 | 209 | ||
209 | 210 | ||
210 | void DialWidget::numbersChanged() { | 211 | void DialWidget::numbersChanged() { |
211 | int sel = numbers->currentItem(); | 212 | int sel = numbers->currentItem(); |
212 | 213 | ||
213 | del->setEnabled(sel != -1); | 214 | del->setEnabled(sel != -1); |
214 | up->setEnabled(sel != -1 && sel != 0); | 215 | up->setEnabled(sel != -1 && sel != 0); |
215 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 216 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
216 | } | 217 | } |
217 | 218 | ||
218 | 219 | ||
219 | void DialWidget::selectionChanged(int) { | 220 | void DialWidget::selectionChanged(int) { |
220 | numbersChanged(); | 221 | numbersChanged(); |
221 | } | 222 | } |
222 | 223 | ||
223 | 224 | ||
224 | void DialWidget::addNumber() { | 225 | void DialWidget::addNumber() { |
225 | PhoneNumberDialog dlg(this); | 226 | PhoneNumberDialog dlg(this); |
226 | if(dlg.exec()) { | 227 | if(dlg.exec()) { |
227 | numbers->insertItem(dlg.phoneNumber()); | 228 | numbers->insertItem(dlg.phoneNumber()); |
228 | numbersChanged(); | 229 | numbersChanged(); |
229 | } | 230 | } |
230 | } | 231 | } |
231 | 232 | ||
232 | 233 | ||
233 | void DialWidget::delNumber() { | 234 | void DialWidget::delNumber() { |
234 | if(numbers->currentItem() != -1) { | 235 | if(numbers->currentItem() != -1) { |
235 | numbers->removeItem(numbers->currentItem()); | 236 | numbers->removeItem(numbers->currentItem()); |
236 | numbersChanged(); | 237 | numbersChanged(); |
237 | } | 238 | } |
238 | } | 239 | } |
239 | 240 | ||
240 | 241 | ||
241 | void DialWidget::upNumber() { | 242 | void DialWidget::upNumber() { |
242 | int idx = numbers->currentItem(); | 243 | int idx = numbers->currentItem(); |
243 | if(idx != -1) { | 244 | if(idx != -1) { |
244 | QString item = numbers->text(idx); | 245 | QString item = numbers->text(idx); |
245 | numbers->removeItem(idx); | 246 | numbers->removeItem(idx); |
246 | numbers->insertItem(item, idx-1); | 247 | numbers->insertItem(item, idx-1); |
247 | numbers->setCurrentItem(idx-1); | 248 | numbers->setCurrentItem(idx-1); |
248 | numbersChanged(); | 249 | numbersChanged(); |
249 | } | 250 | } |
250 | } | 251 | } |
251 | 252 | ||
252 | 253 | ||
253 | void DialWidget::downNumber() { | 254 | void DialWidget::downNumber() { |
254 | int idx = numbers->currentItem(); | 255 | int idx = numbers->currentItem(); |
255 | if(idx != -1) { | 256 | if(idx != -1) { |
256 | QString item = numbers->text(idx); | 257 | QString item = numbers->text(idx); |
257 | numbers->removeItem(idx); | 258 | numbers->removeItem(idx); |
258 | numbers->insertItem(item, idx+1); | 259 | numbers->insertItem(item, idx+1); |
259 | numbers->setCurrentItem(idx+1); | 260 | numbers->setCurrentItem(idx+1); |
260 | numbersChanged(); | 261 | numbersChanged(); |
261 | } | 262 | } |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void DialWidget::pppdargsbutton() { | 266 | void DialWidget::pppdargsbutton() { |
266 | PPPdArguments pa(this); | 267 | PPPdArguments pa(_pppdata, this); |
267 | pa.exec(); | 268 | pa.exec(); |
268 | } | 269 | } |
269 | 270 | ||
270 | 271 | ||
271 | 272 | ||
272 | ///////////////////////////////////////////////////////////////////////////// | 273 | ///////////////////////////////////////////////////////////////////////////// |
273 | // ExecWidget | 274 | // ExecWidget |
274 | ///////////////////////////////////////////////////////////////////////////// | 275 | ///////////////////////////////////////////////////////////////////////////// |
275 | ExecWidget::ExecWidget(QWidget *parent, bool isnewaccount, const char *name) : | 276 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
276 | QWidget(parent, name) | 277 | QWidget(parent, name), _pppdata(pd) |
277 | { | 278 | { |
278 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 279 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
279 | 280 | ||
280 | QLabel *l = new QLabel(\ | 281 | QLabel *l = new QLabel(\ |
281 | i18n("Here you can select commands to run at certain stages of the\n" | 282 | i18n("Here you can select commands to run at certain stages of the\n" |
282 | "connection. The commands are run with your real user id, so\n" | 283 | "connection. The commands are run with your real user id, so\n" |
283 | "you cannot run any commands here requiring root permissions\n" | 284 | "you cannot run any commands here requiring root permissions\n" |
284 | "(unless, of course, you are root).\n\n" | 285 | "(unless, of course, you are root).\n\n" |
285 | "Be sure to supply the whole path to the program otherwise\n" | 286 | "Be sure to supply the whole path to the program otherwise\n" |
286 | "kppp might be unable to find it."), this); | 287 | "kppp might be unable to find it."), this); |
287 | // l->setMinimumHeight(l->sizeHint().height()); | 288 | // l->setMinimumHeight(l->sizeHint().height()); |
288 | tl->addWidget(l); | 289 | tl->addWidget(l); |
289 | tl->addStretch(1); | 290 | tl->addStretch(1); |
290 | 291 | ||
291 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 292 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
292 | tl->addLayout(l1); | 293 | tl->addLayout(l1); |
293 | l1->setColStretch(0, 0); | 294 | l1->setColStretch(0, 0); |
294 | l1->setColStretch(1, 1); | 295 | l1->setColStretch(1, 1); |
295 | 296 | ||
296 | before_connect_l = new QLabel(i18n("Before connect:"), this); | 297 | before_connect_l = new QLabel(i18n("Before connect:"), this); |
297 | before_connect_l->setAlignment(AlignVCenter); | 298 | before_connect_l->setAlignment(AlignVCenter); |
298 | l1->addWidget(before_connect_l, 0, 0); | 299 | l1->addWidget(before_connect_l, 0, 0); |
299 | before_connect = new QLineEdit(this); | 300 | before_connect = new QLineEdit(this); |
300 | // before_connect->setMaxLength(COMMAND_SIZE); | 301 | // before_connect->setMaxLength(COMMAND_SIZE); |
301 | l1->addWidget(before_connect, 0, 1); | 302 | l1->addWidget(before_connect, 0, 1); |
302 | QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n" | 303 | QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n" |
303 | "is established. It is called immediately before\n" | 304 | "is established. It is called immediately before\n" |
304 | "dialing has begun.\n\n" | 305 | "dialing has begun.\n\n" |
305 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 306 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
306 | "modem."); | 307 | "modem."); |
307 | 308 | ||
308 | QWhatsThis::add(before_connect_l,tmp); | 309 | QWhatsThis::add(before_connect_l,tmp); |
309 | QWhatsThis::add(before_connect,tmp); | 310 | QWhatsThis::add(before_connect,tmp); |
310 | 311 | ||
311 | command_label = new QLabel(i18n("Upon connect:"), this); | 312 | command_label = new QLabel(i18n("Upon connect:"), this); |
312 | command_label->setAlignment(AlignVCenter); | 313 | command_label->setAlignment(AlignVCenter); |
313 | l1->addWidget(command_label, 1, 0); | 314 | l1->addWidget(command_label, 1, 0); |
314 | command = new QLineEdit(this); | 315 | command = new QLineEdit(this); |
315 | // command->setMaxLength(COMMAND_SIZE); | 316 | // command->setMaxLength(COMMAND_SIZE); |
316 | l1->addWidget(command, 1, 1); | 317 | l1->addWidget(command, 1, 1); |
317 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" | 318 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" |
318 | "is established. When your program is called, all\n" | 319 | "is established. When your program is called, all\n" |
319 | "preparations for an Internet connection are finished.\n" | 320 | "preparations for an Internet connection are finished.\n" |
320 | "\n" | 321 | "\n" |
321 | "Very useful for fetching mail and news"); | 322 | "Very useful for fetching mail and news"); |
322 | 323 | ||
323 | QWhatsThis::add(command_label,tmp); | 324 | QWhatsThis::add(command_label,tmp); |
324 | QWhatsThis::add(command,tmp); | 325 | QWhatsThis::add(command,tmp); |
325 | 326 | ||
326 | predisconnect_label = new QLabel(i18n("Before disconnect:"), | 327 | predisconnect_label = new QLabel(i18n("Before disconnect:"), |
327 | this); | 328 | this); |
328 | predisconnect_label->setAlignment(AlignVCenter); | 329 | predisconnect_label->setAlignment(AlignVCenter); |
329 | l1->addWidget(predisconnect_label, 2, 0); | 330 | l1->addWidget(predisconnect_label, 2, 0); |
330 | predisconnect = new QLineEdit(this); | 331 | predisconnect = new QLineEdit(this); |
331 | // predisconnect->setMaxLength(COMMAND_SIZE); | 332 | // predisconnect->setMaxLength(COMMAND_SIZE); |
332 | l1->addWidget(predisconnect, 2, 1); | 333 | l1->addWidget(predisconnect, 2, 1); |
333 | tmp = i18n("Allows you to run a program <b>before</b> a connection\n" | 334 | tmp = i18n("Allows you to run a program <b>before</b> a connection\n" |
334 | "is closed. The connection will stay open until\n" | 335 | "is closed. The connection will stay open until\n" |
335 | "the program exits."); | 336 | "the program exits."); |
336 | 337 | ||
337 | QWhatsThis::add(predisconnect_label,tmp); | 338 | QWhatsThis::add(predisconnect_label,tmp); |
338 | QWhatsThis::add(predisconnect,tmp); | 339 | QWhatsThis::add(predisconnect,tmp); |
339 | 340 | ||
340 | discommand_label = new QLabel(i18n("Upon disconnect:"), | 341 | discommand_label = new QLabel(i18n("Upon disconnect:"), |
341 | this); | 342 | this); |
342 | discommand_label->setAlignment(AlignVCenter); | 343 | discommand_label->setAlignment(AlignVCenter); |
343 | l1->addWidget(discommand_label, 3, 0); | 344 | l1->addWidget(discommand_label, 3, 0); |
344 | 345 | ||
345 | discommand = new QLineEdit(this); | 346 | discommand = new QLineEdit(this); |
346 | // discommand->setMaxLength(COMMAND_SIZE); | 347 | // discommand->setMaxLength(COMMAND_SIZE); |
347 | l1->addWidget(discommand, 3, 1); | 348 | l1->addWidget(discommand, 3, 1); |
348 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" | 349 | tmp = i18n("Allows you to run a program <b>after</b> a connection\n" |
349 | "has been closed."); | 350 | "has been closed."); |
350 | 351 | ||
351 | QWhatsThis::add(discommand_label,tmp); | 352 | QWhatsThis::add(discommand_label,tmp); |
352 | QWhatsThis::add(discommand,tmp); | 353 | QWhatsThis::add(discommand,tmp); |
353 | 354 | ||
354 | // extra space between entries | 355 | // extra space between entries |
355 | l1->addRowSpacing(1, 5); | 356 | l1->addRowSpacing(1, 5); |
356 | l1->addRowSpacing(3, 5); | 357 | l1->addRowSpacing(3, 5); |
357 | 358 | ||
358 | tl->addStretch(1); | 359 | tl->addStretch(1); |
359 | tl->activate(); | 360 | tl->activate(); |
360 | 361 | ||
361 | // Set defaults if editing an existing connection | 362 | // Set defaults if editing an existing connection |
362 | if(!isnewaccount) { | 363 | if(!isnewaccount) { |
363 | before_connect->setText(PPPData::data()->command_before_connect()); | 364 | before_connect->setText(_pppdata->command_before_connect()); |
364 | command->setText(PPPData::data()->command_on_connect()); | 365 | command->setText(_pppdata->command_on_connect()); |
365 | discommand->setText(PPPData::data()->command_on_disconnect()); | 366 | discommand->setText(_pppdata->command_on_disconnect()); |
366 | predisconnect->setText(PPPData::data()->command_before_disconnect()); | 367 | predisconnect->setText(_pppdata->command_before_disconnect()); |
367 | } | 368 | } |
368 | } | 369 | } |
369 | 370 | ||
370 | 371 | ||
371 | bool ExecWidget::save() { | 372 | bool ExecWidget::save() { |
372 | PPPData::data()->setCommand_before_connect(before_connect->text()); | 373 | _pppdata->setCommand_before_connect(before_connect->text()); |
373 | PPPData::data()->setCommand_on_connect(command->text()); | 374 | _pppdata->setCommand_on_connect(command->text()); |
374 | PPPData::data()->setCommand_before_disconnect(predisconnect->text()); | 375 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
375 | PPPData::data()->setCommand_on_disconnect(discommand->text()); | 376 | _pppdata->setCommand_on_disconnect(discommand->text()); |
376 | return true; | 377 | return true; |
377 | } | 378 | } |
378 | 379 | ||
379 | 380 | ||
380 | 381 | ||
381 | ///////////////////////////////////////////////////////////////////////////// | 382 | ///////////////////////////////////////////////////////////////////////////// |
382 | // | 383 | // |
383 | // IPWidget | 384 | // IPWidget |
384 | // | 385 | // |
385 | ///////////////////////////////////////////////////////////////////////////// | 386 | ///////////////////////////////////////////////////////////////////////////// |
386 | IPWidget::IPWidget( QWidget *parent, bool isnewaccount, const char *name ) | 387 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
387 | : QWidget(parent, name) | 388 | : QWidget(parent, name), _pppdata(pd) |
388 | { | 389 | { |
389 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 390 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
390 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 391 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
391 | 392 | ||
392 | box = new QVGroupBox(i18n("Configuration"), this); | 393 | box = new QVGroupBox(i18n("Configuration"), this); |
393 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 394 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
394 | 395 | ||
395 | rb = new QButtonGroup(this); | 396 | rb = new QButtonGroup(this); |
396 | rb->hide(); | 397 | rb->hide(); |
397 | connect(rb, SIGNAL(clicked(int)), | 398 | connect(rb, SIGNAL(clicked(int)), |
398 | SLOT(hitIPSelect(int))); | 399 | SLOT(hitIPSelect(int))); |
399 | 400 | ||
400 | dynamicadd_rb = new QRadioButton(box); | 401 | dynamicadd_rb = new QRadioButton(box); |
401 | dynamicadd_rb->setText(i18n("Dynamic IP address")); | 402 | dynamicadd_rb->setText(i18n("Dynamic IP address")); |
402 | QWhatsThis::add(dynamicadd_rb, | 403 | QWhatsThis::add(dynamicadd_rb, |
403 | i18n("Select this option when your computer gets an\n" | 404 | i18n("Select this option when your computer gets an\n" |
404 | "internet address (IP) every time a\n" | 405 | "internet address (IP) every time a\n" |
405 | "connection is made.\n" | 406 | "connection is made.\n" |
406 | "\n" | 407 | "\n" |
407 | "Almost every Internet Service Provider uses\n" | 408 | "Almost every Internet Service Provider uses\n" |
408 | "this method, so this should be turned on.")); | 409 | "this method, so this should be turned on.")); |
409 | 410 | ||
410 | staticadd_rb = new QRadioButton(box); | 411 | staticadd_rb = new QRadioButton(box); |
411 | staticadd_rb->setText(i18n("Static IP address")); | 412 | staticadd_rb->setText(i18n("Static IP address")); |
412 | rb->insert(dynamicadd_rb, 0); | 413 | rb->insert(dynamicadd_rb, 0); |
413 | rb->insert(staticadd_rb, 1); | 414 | rb->insert(staticadd_rb, 1); |
414 | QWhatsThis::add(staticadd_rb, | 415 | QWhatsThis::add(staticadd_rb, |
415 | i18n("Select this option when your computer has a\n" | 416 | i18n("Select this option when your computer has a\n" |
416 | "fixed internet address (IP). Most computers\n" | 417 | "fixed internet address (IP). Most computers\n" |
417 | "don't have this, so you should probably select\n" | 418 | "don't have this, so you should probably select\n" |
418 | "dynamic IP addressing unless you know what you\n" | 419 | "dynamic IP addressing unless you know what you\n" |
419 | "are doing.")); | 420 | "are doing.")); |
420 | 421 | ||
421 | QWidget *ipWidget = new QWidget(box); | 422 | QWidget *ipWidget = new QWidget(box); |
422 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 423 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
423 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 424 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
424 | 425 | ||
425 | ipaddress_label = new QLabel(i18n("IP address:"), ipWidget); | 426 | ipaddress_label = new QLabel(i18n("IP address:"), ipWidget); |
426 | QString tmp = i18n("If your computer has a permanent internet\n" | 427 | QString tmp = i18n("If your computer has a permanent internet\n" |
427 | "address, you must supply your IP address here."); | 428 | "address, you must supply your IP address here."); |
428 | ipLayout->addWidget(ipaddress_label, 0, 0); | 429 | ipLayout->addWidget(ipaddress_label, 0, 0); |
429 | 430 | ||
430 | ipaddress_l = new IPLineEdit(ipWidget); | 431 | ipaddress_l = new IPLineEdit(ipWidget); |
431 | ipLayout->addWidget(ipaddress_l, 0, 1); | 432 | ipLayout->addWidget(ipaddress_l, 0, 1); |
432 | 433 | ||
433 | QWhatsThis::add(ipaddress_label,tmp); | 434 | QWhatsThis::add(ipaddress_label,tmp); |
434 | QWhatsThis::add(ipaddress_l,tmp); | 435 | QWhatsThis::add(ipaddress_l,tmp); |
435 | 436 | ||
436 | sub_label = new QLabel(i18n("Subnet mask:"), ipWidget); | 437 | sub_label = new QLabel(i18n("Subnet mask:"), ipWidget); |
437 | tmp = i18n("<p>If your computer has a static Internet address,\n" | 438 | tmp = i18n("<p>If your computer has a static Internet address,\n" |
438 | "you must supply a network mask here. In almost\n" | 439 | "you must supply a network mask here. In almost\n" |
439 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 440 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
440 | "but your mileage may vary.\n" | 441 | "but your mileage may vary.\n" |
441 | "\n" | 442 | "\n" |
442 | "If unsure, contact your Internet Service Provider"); | 443 | "If unsure, contact your Internet Service Provider"); |
443 | ipLayout->addWidget(sub_label, 1, 0); | 444 | ipLayout->addWidget(sub_label, 1, 0); |
444 | 445 | ||
445 | subnetmask_l = new IPLineEdit(ipWidget); | 446 | subnetmask_l = new IPLineEdit(ipWidget); |
446 | ipLayout->addWidget(subnetmask_l, 1, 1); | 447 | ipLayout->addWidget(subnetmask_l, 1, 1); |
447 | 448 | ||
448 | QWhatsThis::add(sub_label,tmp); | 449 | QWhatsThis::add(sub_label,tmp); |
449 | QWhatsThis::add(subnetmask_l,tmp); | 450 | QWhatsThis::add(subnetmask_l,tmp); |
450 | 451 | ||
451 | autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this); | 452 | autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this); |
452 | autoname->setChecked(PPPData::data()->autoname()); | 453 | autoname->setChecked(_pppdata->autoname()); |
453 | connect(autoname,SIGNAL(toggled(bool)), | 454 | connect(autoname,SIGNAL(toggled(bool)), |
454 | this,SLOT(autoname_t(bool))); | 455 | this,SLOT(autoname_t(bool))); |
455 | 456 | ||
456 | QWhatsThis::add(autoname, | 457 | QWhatsThis::add(autoname, |
457 | i18n("<p>Whenever you connect, this reconfigures\n" | 458 | i18n("<p>Whenever you connect, this reconfigures\n" |
458 | "your hostname to match the IP address you\n" | 459 | "your hostname to match the IP address you\n" |
459 | "got from the PPP server. This may be useful\n" | 460 | "got from the PPP server. This may be useful\n" |
460 | "if you need to use a protocol which depends\n" | 461 | "if you need to use a protocol which depends\n" |
461 | "on this information, but it can also cause several\n" | 462 | "on this information, but it can also cause several\n" |
462 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 463 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
463 | "\n" | 464 | "\n" |
464 | "Don't enable this unless you really need it.")); | 465 | "Don't enable this unless you really need it.")); |
465 | 466 | ||
466 | topLayout->addWidget(box); | 467 | topLayout->addWidget(box); |
467 | topLayout->addWidget(autoname); | 468 | topLayout->addWidget(autoname); |
468 | topLayout->addStretch(); | 469 | topLayout->addStretch(); |
469 | 470 | ||
470 | //load info from gpppdata | 471 | //load info from gpppdata |
471 | if(!isnewaccount) { | 472 | if(!isnewaccount) { |
472 | if(PPPData::data()->ipaddr() == "0.0.0.0" && | 473 | if(_pppdata->ipaddr() == "0.0.0.0" && |
473 | PPPData::data()->subnetmask() == "0.0.0.0") { | 474 | _pppdata->subnetmask() == "0.0.0.0") { |
474 | dynamicadd_rb->setChecked(true); | 475 | dynamicadd_rb->setChecked(true); |
475 | hitIPSelect(0); | 476 | hitIPSelect(0); |
476 | autoname->setChecked(PPPData::data()->autoname()); | 477 | autoname->setChecked(_pppdata->autoname()); |
477 | } | 478 | } |
478 | else { | 479 | else { |
479 | ipaddress_l->setText(PPPData::data()->ipaddr()); | 480 | ipaddress_l->setText(_pppdata->ipaddr()); |
480 | subnetmask_l->setText(PPPData::data()->subnetmask()); | 481 | subnetmask_l->setText(_pppdata->subnetmask()); |
481 | staticadd_rb->setChecked(true); | 482 | staticadd_rb->setChecked(true); |
482 | autoname->setChecked(false); | 483 | autoname->setChecked(false); |
483 | } | 484 | } |
484 | } | 485 | } |
485 | else { | 486 | else { |
486 | dynamicadd_rb->setChecked(true); | 487 | dynamicadd_rb->setChecked(true); |
487 | hitIPSelect(0); | 488 | hitIPSelect(0); |
488 | } | 489 | } |
489 | 490 | ||
490 | } | 491 | } |
491 | 492 | ||
492 | void IPWidget::autoname_t(bool on) { | 493 | void IPWidget::autoname_t(bool on) { |
493 | static bool was_warned = false; | 494 | static bool was_warned = false; |
494 | 495 | ||
495 | // big-fat warning when selecting the auto configure hostname option | 496 | // big-fat warning when selecting the auto configure hostname option |
496 | if(on && !was_warned) { | 497 | if(on && !was_warned) { |
497 | QMessageBox::information(this, | 498 | QMessageBox::information(this, |
498 | i18n("Selecting this option might cause some weird " | 499 | i18n("Selecting this option might cause some weird " |
499 | "problems with the X-server and applications " | 500 | "problems with the X-server and applications " |
500 | "while kppp is connected. Don't use it until " | 501 | "while kppp is connected. Don't use it until " |
501 | "you know what you are doing!\n" | 502 | "you know what you are doing!\n" |
502 | "For more information take a look at the " | 503 | "For more information take a look at the " |
503 | "handbook (or help) in the section \"Frequently " | 504 | "handbook (or help) in the section \"Frequently " |
504 | "asked questions\"."), | 505 | "asked questions\"."), |
505 | i18n("Warning")); | 506 | i18n("Warning")); |
506 | was_warned = true; | 507 | was_warned = true; |
507 | } | 508 | } |
508 | } | 509 | } |
509 | 510 | ||
510 | 511 | ||
511 | void IPWidget::save() { | 512 | void IPWidget::save() { |
512 | if(dynamicadd_rb->isChecked()) { | 513 | if(dynamicadd_rb->isChecked()) { |
513 | PPPData::data()->setIpaddr("0.0.0.0"); | 514 | _pppdata->setIpaddr("0.0.0.0"); |
514 | PPPData::data()->setSubnetmask("0.0.0.0"); | 515 | _pppdata->setSubnetmask("0.0.0.0"); |
515 | } else { | 516 | } else { |
516 | PPPData::data()->setIpaddr(ipaddress_l->text()); | 517 | _pppdata->setIpaddr(ipaddress_l->text()); |
517 | PPPData::data()->setSubnetmask(subnetmask_l->text()); | 518 | _pppdata->setSubnetmask(subnetmask_l->text()); |
518 | } | 519 | } |
519 | PPPData::data()->setAutoname(autoname->isChecked()); | 520 | _pppdata->setAutoname(autoname->isChecked()); |
520 | } | 521 | } |
521 | 522 | ||
522 | 523 | ||
523 | void IPWidget::hitIPSelect( int i ) { | 524 | void IPWidget::hitIPSelect( int i ) { |
524 | if(i == 0) { | 525 | if(i == 0) { |
525 | ipaddress_label->setEnabled(false); | 526 | ipaddress_label->setEnabled(false); |
526 | sub_label->setEnabled(false); | 527 | sub_label->setEnabled(false); |
527 | ipaddress_l->setEnabled(false); | 528 | ipaddress_l->setEnabled(false); |
528 | subnetmask_l->setEnabled(false); | 529 | subnetmask_l->setEnabled(false); |
529 | } | 530 | } |
530 | else { | 531 | else { |
531 | ipaddress_label->setEnabled(true); | 532 | ipaddress_label->setEnabled(true); |
532 | sub_label->setEnabled(true); | 533 | sub_label->setEnabled(true); |
533 | ipaddress_l->setEnabled(true); | 534 | ipaddress_l->setEnabled(true); |
534 | subnetmask_l->setEnabled(true); | 535 | subnetmask_l->setEnabled(true); |
535 | } | 536 | } |
536 | } | 537 | } |
537 | 538 | ||
538 | 539 | ||
539 | 540 | ||
540 | DNSWidget::DNSWidget( QWidget *parent, bool isnewaccount, const char *name ) | 541 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
541 | : QWidget(parent, name) | 542 | : QWidget(parent, name), _pppdata(pd) |
542 | { | 543 | { |
543 | // box = new QGroupBox(this); | 544 | // box = new QGroupBox(this); |
544 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint()); | 545 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint()); |
545 | 546 | ||
546 | dnsdomain_label = new QLabel(i18n("Domain name:"), this); | 547 | dnsdomain_label = new QLabel(i18n("Domain name:"), this); |
547 | tl->addWidget(dnsdomain_label, 0, 0); | 548 | tl->addWidget(dnsdomain_label, 0, 0); |
548 | 549 | ||
549 | dnsdomain = new QLineEdit(this); | 550 | dnsdomain = new QLineEdit(this); |
550 | // dnsdomain->setMaxLength(DOMAIN_SIZE); | 551 | // dnsdomain->setMaxLength(DOMAIN_SIZE); |
551 | tl->addWidget(dnsdomain, 0, 1); | 552 | tl->addWidget(dnsdomain, 0, 1); |
552 | QString tmp = i18n("If you enter a domain name here, this domain\n" | 553 | QString tmp = i18n("If you enter a domain name here, this domain\n" |
553 | "name is used for your computer while you are\n" | 554 | "name is used for your computer while you are\n" |
554 | "connected. When the connection is closed, the\n" | 555 | "connected. When the connection is closed, the\n" |
555 | "original domain name of your computer is\n" | 556 | "original domain name of your computer is\n" |
556 | "restored.\n" | 557 | "restored.\n" |
557 | "\n" | 558 | "\n" |
558 | "If you leave this field blank, no changes are\n" | 559 | "If you leave this field blank, no changes are\n" |
559 | "made to the domain name."); | 560 | "made to the domain name."); |
560 | 561 | ||
561 | QWhatsThis::add(dnsdomain_label,tmp); | 562 | QWhatsThis::add(dnsdomain_label,tmp); |
562 | QWhatsThis::add(dnsdomain,tmp); | 563 | QWhatsThis::add(dnsdomain,tmp); |
563 | 564 | ||
564 | conf_label = new QLabel(i18n("Configuration:"), this); | 565 | conf_label = new QLabel(i18n("Configuration:"), this); |
565 | tl->addWidget(conf_label, 1, 0); | 566 | tl->addWidget(conf_label, 1, 0); |
566 | 567 | ||
567 | bg = new QButtonGroup("Group", this); | 568 | bg = new QButtonGroup("Group", this); |
568 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 569 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
569 | bg->hide(); | 570 | bg->hide(); |
570 | 571 | ||
571 | autodns = new QRadioButton(i18n("Automatic"), this); | 572 | autodns = new QRadioButton(i18n("Automatic"), this); |
572 | bg->insert(autodns, 0); | 573 | bg->insert(autodns, 0); |
573 | tl->addWidget(autodns, 1, 1); | 574 | tl->addWidget(autodns, 1, 1); |
574 | // no automatic DNS detection for pppd < 2.3.7 | 575 | // no automatic DNS detection for pppd < 2.3.7 |
575 | if(!PPPData::data()->pppdVersionMin(2, 3, 7)) | 576 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
576 | autodns->setEnabled(false); | 577 | autodns->setEnabled(false); |
577 | 578 | ||
578 | mandns = new QRadioButton(i18n("Manual"), this); | 579 | mandns = new QRadioButton(i18n("Manual"), this); |
579 | bg->insert(mandns, 1); | 580 | bg->insert(mandns, 1); |
580 | tl->addWidget(mandns, 2, 1); | 581 | tl->addWidget(mandns, 2, 1); |
581 | 582 | ||
582 | dns_label = new QLabel(i18n("DNS IP address:"), this); | 583 | dns_label = new QLabel(i18n("DNS IP address:"), this); |
583 | tl->addWidget(dns_label, 3, 0); | 584 | tl->addWidget(dns_label, 3, 0); |
584 | 585 | ||
585 | QHBoxLayout *l2 = new QHBoxLayout; | 586 | QHBoxLayout *l2 = new QHBoxLayout; |
586 | tl->addLayout(l2, 3, 1); | 587 | tl->addLayout(l2, 3, 1); |
587 | dnsipaddr = new IPLineEdit(this); | 588 | dnsipaddr = new IPLineEdit(this); |
588 | connect(dnsipaddr, SIGNAL(returnPressed()), | 589 | connect(dnsipaddr, SIGNAL(returnPressed()), |
589 | SLOT(adddns())); | 590 | SLOT(adddns())); |
590 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 591 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), |
591 | SLOT(DNS_Edit_Changed(const QString &))); | 592 | SLOT(DNS_Edit_Changed(const QString &))); |
592 | l2->addWidget(dnsipaddr, 1); | 593 | l2->addWidget(dnsipaddr, 1); |
593 | l2->addStretch(1); | 594 | l2->addStretch(1); |
594 | tmp = i18n("<p>Allows you to specify a new DNS server to be\n" | 595 | tmp = i18n("<p>Allows you to specify a new DNS server to be\n" |
595 | "used while you are connected. When the\n" | 596 | "used while you are connected. When the\n" |
596 | "connection is closed, this DNS entry will be\n" | 597 | "connection is closed, this DNS entry will be\n" |
597 | "removed again.\n" | 598 | "removed again.\n" |
598 | "\n" | 599 | "\n" |
599 | "To add a DNS server, type in the IP address of\n" | 600 | "To add a DNS server, type in the IP address of\n" |
600 | "the DNS server here and click on <b>Add</b>"); | 601 | "the DNS server here and click on <b>Add</b>"); |
601 | 602 | ||
602 | QWhatsThis::add(dns_label, tmp); | 603 | QWhatsThis::add(dns_label, tmp); |
603 | QWhatsThis::add(dnsipaddr, tmp); | 604 | QWhatsThis::add(dnsipaddr, tmp); |
604 | 605 | ||
605 | QHBoxLayout *l1 = new QHBoxLayout; | 606 | QHBoxLayout *l1 = new QHBoxLayout; |
606 | tl->addLayout(l1, 4, 1); | 607 | tl->addLayout(l1, 4, 1); |
607 | add = new QPushButton(i18n("Add"), this); | 608 | add = new QPushButton(i18n("Add"), this); |
608 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 609 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
609 | // int width = add->sizeHint().width(); | 610 | // int width = add->sizeHint().width(); |
610 | // width = QMAX(width,60); | 611 | // width = QMAX(width,60); |
611 | // add->setMinimumWidth(width); | 612 | // add->setMinimumWidth(width); |
612 | l1->addWidget(add); | 613 | l1->addWidget(add); |
613 | l1->addStretch(1); | 614 | l1->addStretch(1); |
614 | QWhatsThis::add(add, | 615 | QWhatsThis::add(add, |
615 | i18n("Click this button to add the DNS server\n" | 616 | i18n("Click this button to add the DNS server\n" |
616 | "specified in the field above. The entry\n" | 617 | "specified in the field above. The entry\n" |
617 | "will then be added to the list below")); | 618 | "will then be added to the list below")); |
618 | 619 | ||
619 | remove = new QPushButton(i18n("Remove"), this); | 620 | remove = new QPushButton(i18n("Remove"), this); |
620 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 621 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
621 | // width = remove->sizeHint().width(); | 622 | // width = remove->sizeHint().width(); |
622 | // width = QMAX(width,60); | 623 | // width = QMAX(width,60); |
623 | // remove->setMinimumWidth(width); | 624 | // remove->setMinimumWidth(width); |
624 | l1->addWidget(remove); | 625 | l1->addWidget(remove); |
625 | QWhatsThis::add(remove, | 626 | QWhatsThis::add(remove, |
626 | i18n("Click this button to remove the selected DNS\n" | 627 | i18n("Click this button to remove the selected DNS\n" |
627 | "server entry from the list below")); | 628 | "server entry from the list below")); |
628 | 629 | ||
629 | servers_label = new QLabel(i18n("DNS address list:"), this); | 630 | servers_label = new QLabel(i18n("DNS address list:"), this); |
630 | servers_label->setAlignment(AlignTop|AlignLeft); | 631 | servers_label->setAlignment(AlignTop|AlignLeft); |
631 | tl->addWidget(servers_label, 5, 0); | 632 | tl->addWidget(servers_label, 5, 0); |
632 | 633 | ||
633 | dnsservers = new QListBox(this); | 634 | dnsservers = new QListBox(this); |
634 | dnsservers->setMinimumSize(150, 80); | 635 | dnsservers->setMinimumSize(150, 80); |
635 | connect(dnsservers, SIGNAL(highlighted(int)), | 636 | connect(dnsservers, SIGNAL(highlighted(int)), |
636 | SLOT(DNS_Entry_Selected(int))); | 637 | SLOT(DNS_Entry_Selected(int))); |
637 | tl->addWidget(dnsservers, 5, 1); | 638 | tl->addWidget(dnsservers, 5, 1); |
638 | tmp = i18n("<p>This shows all defined DNS servers to use\n" | 639 | tmp = i18n("<p>This shows all defined DNS servers to use\n" |
639 | "while you are connected. Use the <b>Add</b> and\n" | 640 | "while you are connected. Use the <b>Add</b> and\n" |
640 | "<b>Remove</b> buttons to modify the list"); | 641 | "<b>Remove</b> buttons to modify the list"); |
641 | 642 | ||
642 | QWhatsThis::add(servers_label,tmp); | 643 | QWhatsThis::add(servers_label,tmp); |
643 | QWhatsThis::add(dnsservers,tmp); | 644 | QWhatsThis::add(dnsservers,tmp); |
644 | 645 | ||
645 | exdnsdisabled_toggle = new QCheckBox(i18n( \ | 646 | exdnsdisabled_toggle = new QCheckBox(i18n( \ |
646 | "Disable existing DNS servers during connection"), | 647 | "Disable existing DNS servers during connection"), |
647 | this); | 648 | this); |
648 | exdnsdisabled_toggle->setChecked(PPPData::data()->exDNSDisabled()); | 649 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
649 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 650 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
650 | QWhatsThis::add(exdnsdisabled_toggle, | 651 | QWhatsThis::add(exdnsdisabled_toggle, |
651 | i18n("<p>When this option is selected, all DNS\n" | 652 | i18n("<p>When this option is selected, all DNS\n" |
652 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 653 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
653 | "temporary disabled while the dialup connection\n" | 654 | "temporary disabled while the dialup connection\n" |
654 | "is established. After the connection is\n" | 655 | "is established. After the connection is\n" |
655 | "closed, the servers will be re-enabled\n" | 656 | "closed, the servers will be re-enabled\n" |
656 | "\n" | 657 | "\n" |
657 | "Typically, there is no reason to use this\n" | 658 | "Typically, there is no reason to use this\n" |
658 | "option, but it may become useful under \n" | 659 | "option, but it may become useful under \n" |
659 | "some circumstances.")); | 660 | "some circumstances.")); |
660 | 661 | ||
661 | 662 | ||
662 | // restore data if editing | 663 | // restore data if editing |
663 | if(!isnewaccount) { | 664 | if(!isnewaccount) { |
664 | dnsservers->insertStringList(PPPData::data()->dns()); | 665 | dnsservers->insertStringList(_pppdata->dns()); |
665 | dnsdomain->setText(PPPData::data()->domain()); | 666 | dnsdomain->setText(_pppdata->domain()); |
666 | } | 667 | } |
667 | 668 | ||
668 | int mode = PPPData::data()->autoDNS() ? 0 : 1; | 669 | int mode = _pppdata->autoDNS() ? 0 : 1; |
669 | bg->setButton(mode); | 670 | bg->setButton(mode); |
670 | DNS_Mode_Selected(mode); | 671 | DNS_Mode_Selected(mode); |
671 | 672 | ||
672 | tl->activate(); | 673 | tl->activate(); |
673 | } | 674 | } |
674 | 675 | ||
675 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 676 | void DNSWidget::DNS_Edit_Changed(const QString &text) { |
676 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 677 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
677 | add->setEnabled(text.find(r) != -1); | 678 | add->setEnabled(text.find(r) != -1); |
678 | } | 679 | } |
679 | 680 | ||
680 | void DNSWidget::DNS_Entry_Selected(int) { | 681 | void DNSWidget::DNS_Entry_Selected(int) { |
681 | remove->setEnabled(true); | 682 | remove->setEnabled(true); |
682 | } | 683 | } |
683 | 684 | ||
684 | void DNSWidget::DNS_Mode_Selected(int mode) { | 685 | void DNSWidget::DNS_Mode_Selected(int mode) { |
685 | bool on = (mode == 1); | 686 | bool on = (mode == 1); |
686 | dns_label->setEnabled(on); | 687 | dns_label->setEnabled(on); |
687 | servers_label->setEnabled(on); | 688 | servers_label->setEnabled(on); |
688 | dnsipaddr->setText(""); | 689 | dnsipaddr->setText(""); |
689 | dnsipaddr->setEnabled(on); | 690 | dnsipaddr->setEnabled(on); |
690 | add->setEnabled(false); | 691 | add->setEnabled(false); |
691 | remove->setEnabled(dnsservers->count()>0 && on); | 692 | remove->setEnabled(dnsservers->count()>0 && on); |
692 | dnsservers->clearSelection(); | 693 | dnsservers->clearSelection(); |
693 | dnsservers->setEnabled(on); | 694 | dnsservers->setEnabled(on); |
694 | dnsservers->triggerUpdate(false); | 695 | dnsservers->triggerUpdate(false); |
695 | } | 696 | } |
696 | 697 | ||
697 | void DNSWidget::save() { | 698 | void DNSWidget::save() { |
698 | PPPData::data()->setAutoDNS(bg->id(bg->selected()) == 0); | 699 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
699 | QStringList serverlist; | 700 | QStringList serverlist; |
700 | for(uint i=0; i < dnsservers->count(); i++) | 701 | for(uint i=0; i < dnsservers->count(); i++) |
701 | serverlist.append(dnsservers->text(i)); | 702 | serverlist.append(dnsservers->text(i)); |
702 | PPPData::data()->setDns(serverlist); | 703 | _pppdata->setDns(serverlist); |
703 | 704 | ||
704 | // strip leading dot | 705 | // strip leading dot |
705 | QString s(dnsdomain->text()); | 706 | QString s(dnsdomain->text()); |
706 | if(s.left(1) == ".") | 707 | if(s.left(1) == ".") |
707 | PPPData::data()->setDomain(s.mid(1)); | 708 | _pppdata->setDomain(s.mid(1)); |
708 | else | 709 | else |
709 | PPPData::data()->setDomain(dnsdomain->text()); | 710 | _pppdata->setDomain(dnsdomain->text()); |
710 | 711 | ||
711 | PPPData::data()->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 712 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
712 | } | 713 | } |
713 | 714 | ||
714 | 715 | ||
715 | void DNSWidget::adddns() { | 716 | void DNSWidget::adddns() { |
716 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 717 | if(dnsservers->count() < MAX_DNS_ENTRIES) { |
717 | dnsservers->insertItem(dnsipaddr->text()); | 718 | dnsservers->insertItem(dnsipaddr->text()); |
718 | dnsipaddr->setText(""); | 719 | dnsipaddr->setText(""); |
719 | } | 720 | } |
720 | } | 721 | } |
721 | 722 | ||
722 | 723 | ||
723 | void DNSWidget::removedns() { | 724 | void DNSWidget::removedns() { |
724 | int i; | 725 | int i; |
725 | i = dnsservers->currentItem(); | 726 | i = dnsservers->currentItem(); |
726 | if(i != -1) | 727 | if(i != -1) |
727 | dnsservers->removeItem(i); | 728 | dnsservers->removeItem(i); |
728 | remove->setEnabled(dnsservers->count()>0); | 729 | remove->setEnabled(dnsservers->count()>0); |
729 | } | 730 | } |
730 | 731 | ||
731 | 732 | ||
732 | // | 733 | // |
733 | // GatewayWidget | 734 | // GatewayWidget |
734 | // | 735 | // |
735 | GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) | 736 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
736 | : QWidget(parent, name) | 737 | : QWidget(parent, name), _pppdata(pd) |
737 | { | 738 | { |
738 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 739 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
739 | topLayout->setSpacing( 2 );//KDialog::spacingHint()); | 740 | topLayout->setSpacing( 2 );//KDialog::spacingHint()); |
740 | 741 | ||
741 | box = new QVGroupBox(i18n("Configuration"), this); | 742 | box = new QVGroupBox(i18n("Configuration"), this); |
742 | // box->setInsideSpacing( 2 );//KDialog::spacingHint()); | 743 | // box->setInsideSpacing( 2 );//KDialog::spacingHint()); |
743 | 744 | ||
744 | rb = new QButtonGroup(this); | 745 | rb = new QButtonGroup(this); |
745 | rb->hide(); | 746 | rb->hide(); |
746 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 747 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
747 | 748 | ||
748 | defaultgateway = new QRadioButton(box); | 749 | defaultgateway = new QRadioButton(box); |
749 | defaultgateway->setText(i18n("Default gateway")); | 750 | defaultgateway->setText(i18n("Default gateway")); |
750 | rb->insert(defaultgateway, 0); | 751 | rb->insert(defaultgateway, 0); |
751 | QWhatsThis::add(defaultgateway, | 752 | QWhatsThis::add(defaultgateway, |
752 | i18n("This makes the PPP peer computer (the computer\n" | 753 | i18n("This makes the PPP peer computer (the computer\n" |
753 | "you are connected to with your modem) to act as\n" | 754 | "you are connected to with your modem) to act as\n" |
754 | "a gateway. Your computer will send all packets not\n" | 755 | "a gateway. Your computer will send all packets not\n" |
755 | "going to a computer inside your local net to this\n" | 756 | "going to a computer inside your local net to this\n" |
756 | "computer, which will route these packets.\n" | 757 | "computer, which will route these packets.\n" |
757 | "\n" | 758 | "\n" |
758 | "This is the default for most ISPs, so you should\n" | 759 | "This is the default for most ISPs, so you should\n" |
759 | "probably leave this option on.")); | 760 | "probably leave this option on.")); |
760 | 761 | ||
761 | 762 | ||
762 | staticgateway = new QRadioButton(box); | 763 | staticgateway = new QRadioButton(box); |
763 | staticgateway->setText(i18n("Static gateway")); | 764 | staticgateway->setText(i18n("Static gateway")); |
764 | rb->insert(staticgateway, 1); | 765 | rb->insert(staticgateway, 1); |
765 | QWhatsThis::add(staticgateway, | 766 | QWhatsThis::add(staticgateway, |
766 | i18n("<p>Allows you to specify which computer you want\n" | 767 | i18n("<p>Allows you to specify which computer you want\n" |
767 | "to use as gateway (see <i>Default Gateway</i> above)")); | 768 | "to use as gateway (see <i>Default Gateway</i> above)")); |
768 | 769 | ||
769 | QHBox *gateBox = new QHBox(box); | 770 | QHBox *gateBox = new QHBox(box); |
770 | gate_label = new QLabel(i18n("Gateway IP address:"), gateBox); | 771 | gate_label = new QLabel(i18n("Gateway IP address:"), gateBox); |
771 | gatewayaddr = new IPLineEdit(gateBox); | 772 | gatewayaddr = new IPLineEdit(gateBox); |
772 | 773 | ||
773 | defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"), | 774 | defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"), |
774 | this); | 775 | this); |
775 | QWhatsThis::add(defaultroute, | 776 | QWhatsThis::add(defaultroute, |
776 | i18n("If this option is enabled, all packets not\n" | 777 | i18n("If this option is enabled, all packets not\n" |
777 | "going to the local net are routed through\n" | 778 | "going to the local net are routed through\n" |
778 | "the PPP connection.\n" | 779 | "the PPP connection.\n" |
779 | "\n" | 780 | "\n" |
780 | "Normally, you should turn this on")); | 781 | "Normally, you should turn this on")); |
781 | 782 | ||
782 | topLayout->addWidget(box); | 783 | topLayout->addWidget(box); |
783 | topLayout->addWidget(defaultroute); | 784 | topLayout->addWidget(defaultroute); |
784 | topLayout->addStretch(); | 785 | topLayout->addStretch(); |
785 | 786 | ||
786 | //load info from gpppdata | 787 | //load info from gpppdata |
787 | if(!isnewaccount) { | 788 | if(!isnewaccount) { |
788 | if(PPPData::data()->gateway() == "0.0.0.0") { | 789 | if(_pppdata->gateway() == "0.0.0.0") { |
789 | defaultgateway->setChecked(true); | 790 | defaultgateway->setChecked(true); |
790 | hitGatewaySelect(0); | 791 | hitGatewaySelect(0); |
791 | } | 792 | } |
792 | else { | 793 | else { |
793 | gatewayaddr->setText(PPPData::data()->gateway()); | 794 | gatewayaddr->setText(_pppdata->gateway()); |
794 | staticgateway->setChecked(true); | 795 | staticgateway->setChecked(true); |
795 | } | 796 | } |
796 | defaultroute->setChecked(PPPData::data()->defaultroute()); | 797 | defaultroute->setChecked(_pppdata->defaultroute()); |
797 | } | 798 | } |
798 | else { | 799 | else { |
799 | defaultgateway->setChecked(true); | 800 | defaultgateway->setChecked(true); |
800 | hitGatewaySelect(0); | 801 | hitGatewaySelect(0); |
801 | defaultroute->setChecked(true); | 802 | defaultroute->setChecked(true); |
802 | } | 803 | } |
803 | } | 804 | } |
804 | 805 | ||
805 | void GatewayWidget::save() { | 806 | void GatewayWidget::save() { |
806 | PPPData::data()->setGateway(gatewayaddr->text()); | 807 | _pppdata->setGateway(gatewayaddr->text()); |
807 | PPPData::data()->setDefaultroute(defaultroute->isChecked()); | 808 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
808 | } | 809 | } |
809 | 810 | ||
810 | 811 | ||
811 | void GatewayWidget::hitGatewaySelect( int i ) { | 812 | void GatewayWidget::hitGatewaySelect( int i ) { |
812 | if(i == 0) { | 813 | if(i == 0) { |
813 | gatewayaddr->setText("0.0.0.0"); | 814 | gatewayaddr->setText("0.0.0.0"); |
814 | gatewayaddr->setEnabled(false); | 815 | gatewayaddr->setEnabled(false); |
815 | gate_label->setEnabled(false); | 816 | gate_label->setEnabled(false); |
816 | } | 817 | } |
817 | else { | 818 | else { |
818 | gatewayaddr->setEnabled(true); | 819 | gatewayaddr->setEnabled(true); |
819 | gatewayaddr->setText(""); | 820 | gatewayaddr->setText(""); |
820 | gate_label->setEnabled(true); | 821 | gate_label->setEnabled(true); |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | 825 | ||
825 | 826 | ||
826 | ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) | 827 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
827 | : QWidget(parent, name) | 828 | : QWidget(parent, name),_pppdata(pd) |
828 | { | 829 | { |
829 | 830 | ||
830 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 831 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
831 | se = new ScriptEdit(this); | 832 | se = new ScriptEdit(this); |
832 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 833 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
833 | tl->addWidget(se); | 834 | tl->addWidget(se); |
834 | 835 | ||
835 | // insert equal-sized buttons | 836 | // insert equal-sized buttons |
836 | QHBoxLayout *hl = new QHBoxLayout( this ); | 837 | QHBoxLayout *hl = new QHBoxLayout( this ); |
837 | tl->addLayout( hl ); | 838 | tl->addLayout( hl ); |
838 | add = new QPushButton( i18n("Add"), this ); | 839 | add = new QPushButton( i18n("Add"), this ); |
839 | hl->addWidget( add ); | 840 | hl->addWidget( add ); |
840 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 841 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
841 | insert = new QPushButton( i18n("Insert"), this ); | 842 | insert = new QPushButton( i18n("Insert"), this ); |
842 | hl->addWidget( insert ); | 843 | hl->addWidget( insert ); |
843 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 844 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
844 | remove = new QPushButton( i18n("Remove"), this ); | 845 | remove = new QPushButton( i18n("Remove"), this ); |
845 | hl->addWidget( remove ); | 846 | hl->addWidget( remove ); |
846 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 847 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
847 | 848 | ||
848 | QHBoxLayout *l12 = new QHBoxLayout(0); | 849 | QHBoxLayout *l12 = new QHBoxLayout(0); |
849 | tl->addLayout(l12); | 850 | tl->addLayout(l12); |
850 | stl = new QListBox(this); | 851 | stl = new QListBox(this); |
851 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 852 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
852 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 853 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
853 | // stl->setMinimumSize(QSize(70, 140)); | 854 | // stl->setMinimumSize(QSize(70, 140)); |
854 | 855 | ||
855 | sl = new QListBox(this); | 856 | sl = new QListBox(this); |
856 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 857 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
857 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 858 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
858 | // sl->setMinimumSize(QSize(150, 140)); | 859 | // sl->setMinimumSize(QSize(150, 140)); |
859 | 860 | ||
860 | slb = new QScrollBar(this); | 861 | slb = new QScrollBar(this); |
861 | // slb->setFixedWidth(slb->sizeHint().width()); | 862 | // slb->setFixedWidth(slb->sizeHint().width()); |
862 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 863 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
863 | 864 | ||
864 | l12->addWidget(stl, 1); | 865 | l12->addWidget(stl, 1); |
865 | l12->addWidget(sl, 3); | 866 | l12->addWidget(sl, 3); |
866 | l12->addWidget(slb, 0); | 867 | l12->addWidget(slb, 0); |
867 | 868 | ||
868 | //load data from gpppdata | 869 | //load data from gpppdata |
869 | if(!isnewaccount) { | 870 | if(!isnewaccount) { |
870 | QStringList &comlist = PPPData::data()->scriptType(); | 871 | QStringList &comlist = _pppdata->scriptType(); |
871 | QStringList &arglist = PPPData::data()->script(); | 872 | QStringList &arglist = _pppdata->script(); |
872 | QStringList::Iterator itcom = comlist.begin(); | 873 | QStringList::Iterator itcom = comlist.begin(); |
873 | QStringList::Iterator itarg = arglist.begin(); | 874 | QStringList::Iterator itarg = arglist.begin(); |
874 | 875 | ||
875 | for ( ; | 876 | for ( ; |
876 | itcom != comlist.end() && itarg != arglist.end(); | 877 | itcom != comlist.end() && itarg != arglist.end(); |
877 | ++itcom, ++itarg ) | 878 | ++itcom, ++itarg ) |
878 | { | 879 | { |
879 | stl->insertItem(*itcom); | 880 | stl->insertItem(*itcom); |
880 | sl->insertItem(*itarg); | 881 | sl->insertItem(*itarg); |
881 | } | 882 | } |
882 | } | 883 | } |
883 | 884 | ||
884 | insert->setEnabled(false); | 885 | insert->setEnabled(false); |
885 | remove->setEnabled(false); | 886 | remove->setEnabled(false); |
886 | adjustScrollBar(); | 887 | adjustScrollBar(); |
887 | tl->activate(); | 888 | tl->activate(); |
888 | } | 889 | } |
889 | 890 | ||
890 | bool ScriptWidget::check() { | 891 | bool ScriptWidget::check() { |
891 | uint lstart = 0; | 892 | uint lstart = 0; |
892 | uint lend = 0; | 893 | uint lend = 0; |
893 | uint errcnt = 0; | 894 | uint errcnt = 0; |
894 | 895 | ||
895 | if(sl->count() > 0) { | 896 | if(sl->count() > 0) { |
896 | for( uint i=0; i <= sl->count()-1; i++) { | 897 | for( uint i=0; i <= sl->count()-1; i++) { |
897 | if(stl->text(i) == "LoopStart") { | 898 | if(stl->text(i) == "LoopStart") { |
898 | lstart++; | 899 | lstart++; |
899 | } | 900 | } |
900 | if (stl->text(i) == "LoopEnd") { | 901 | if (stl->text(i) == "LoopEnd") { |
901 | lend++; | 902 | lend++; |
902 | } | 903 | } |
903 | if ( lend > lstart ) errcnt++; | 904 | if ( lend > lstart ) errcnt++; |
904 | } | 905 | } |
905 | return ( (errcnt == 0 ) && (lstart == lend) ); | 906 | return ( (errcnt == 0 ) && (lstart == lend) ); |
906 | } | 907 | } |
907 | return true; | 908 | return true; |
908 | } | 909 | } |
909 | 910 | ||
910 | 911 | ||
911 | void ScriptWidget::save() { | 912 | void ScriptWidget::save() { |
912 | QStringList typelist, arglist; | 913 | QStringList typelist, arglist; |
913 | for(uint i=0; i < sl->count(); i++) { | 914 | for(uint i=0; i < sl->count(); i++) { |
914 | typelist.append(stl->text(i)); | 915 | typelist.append(stl->text(i)); |
915 | arglist.append(sl->text(i)); | 916 | arglist.append(sl->text(i)); |
916 | } | 917 | } |
917 | PPPData::data()->setScriptType(typelist); | 918 | _pppdata->setScriptType(typelist); |
918 | PPPData::data()->setScript(arglist); | 919 | _pppdata->setScript(arglist); |
919 | } | 920 | } |
920 | 921 | ||
921 | 922 | ||
922 | 923 | ||
923 | void ScriptWidget::adjustScrollBar() { | 924 | void ScriptWidget::adjustScrollBar() { |
924 | if((int)sl->count() <= sl->numItemsVisible()) | 925 | if((int)sl->count() <= sl->numItemsVisible()) |
925 | slb->setRange(0, 0); | 926 | slb->setRange(0, 0); |
926 | else | 927 | else |
927 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 928 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
928 | } | 929 | } |
929 | 930 | ||
930 | 931 | ||
931 | void ScriptWidget::scrolling(int i) { | 932 | void ScriptWidget::scrolling(int i) { |
932 | sl->setTopItem(i); | 933 | sl->setTopItem(i); |
933 | stl->setTopItem(i); | 934 | stl->setTopItem(i); |
934 | } | 935 | } |
935 | 936 | ||
936 | 937 | ||
937 | void ScriptWidget::slhighlighted(int i) { | 938 | void ScriptWidget::slhighlighted(int i) { |
938 | insert->setEnabled(true); | 939 | insert->setEnabled(true); |
939 | remove->setEnabled(true); | 940 | remove->setEnabled(true); |
940 | stl->setCurrentItem(i); | 941 | stl->setCurrentItem(i); |
941 | } | 942 | } |
942 | 943 | ||
943 | 944 | ||
944 | void ScriptWidget::stlhighlighted(int i) { | 945 | void ScriptWidget::stlhighlighted(int i) { |
945 | insert->setEnabled(true); | 946 | insert->setEnabled(true); |
946 | remove->setEnabled(true); | 947 | remove->setEnabled(true); |
947 | sl->setCurrentItem(i); | 948 | sl->setCurrentItem(i); |
948 | } | 949 | } |
949 | 950 | ||
950 | 951 | ||
951 | void ScriptWidget::addButton() { | 952 | void ScriptWidget::addButton() { |
952 | //don't allow more than the maximum script entries | 953 | //don't allow more than the maximum script entries |
953 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 954 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
954 | return; | 955 | return; |
955 | 956 | ||
956 | switch(se->type()) { | 957 | switch(se->type()) { |
957 | case ScriptEdit::Expect: | 958 | case ScriptEdit::Expect: |
958 | stl->insertItem("Expect"); | 959 | stl->insertItem("Expect"); |
959 | sl->insertItem(se->text()); | 960 | sl->insertItem(se->text()); |
960 | break; | 961 | break; |
961 | 962 | ||
962 | case ScriptEdit::Send: | 963 | case ScriptEdit::Send: |
963 | stl->insertItem("Send"); | 964 | stl->insertItem("Send"); |
964 | sl->insertItem(se->text()); | 965 | sl->insertItem(se->text()); |
965 | break; | 966 | break; |
966 | 967 | ||
967 | case ScriptEdit::SendNoEcho: | 968 | case ScriptEdit::SendNoEcho: |
968 | stl->insertItem("SendNoEcho"); | 969 | stl->insertItem("SendNoEcho"); |
969 | sl->insertItem(se->text()); | 970 | sl->insertItem(se->text()); |
970 | break; | 971 | break; |
971 | 972 | ||
972 | case ScriptEdit::Pause: | 973 | case ScriptEdit::Pause: |
973 | stl->insertItem("Pause"); | 974 | stl->insertItem("Pause"); |
974 | sl->insertItem(se->text()); | 975 | sl->insertItem(se->text()); |
975 | break; | 976 | break; |
976 | 977 | ||
977 | case ScriptEdit::Hangup: | 978 | case ScriptEdit::Hangup: |
978 | stl->insertItem("Hangup"); | 979 | stl->insertItem("Hangup"); |
979 | sl->insertItem(""); | 980 | sl->insertItem(""); |
980 | break; | 981 | break; |
981 | 982 | ||
982 | case ScriptEdit::Answer: | 983 | case ScriptEdit::Answer: |
983 | stl->insertItem("Answer"); | 984 | stl->insertItem("Answer"); |
984 | sl->insertItem(""); | 985 | sl->insertItem(""); |
985 | break; | 986 | break; |
986 | 987 | ||
987 | case ScriptEdit::Timeout: | 988 | case ScriptEdit::Timeout: |
988 | stl->insertItem("Timeout"); | 989 | stl->insertItem("Timeout"); |
989 | sl->insertItem(se->text()); | 990 | sl->insertItem(se->text()); |
990 | break; | 991 | break; |
991 | 992 | ||
992 | case ScriptEdit::Password: | 993 | case ScriptEdit::Password: |
993 | stl->insertItem("Password"); | 994 | stl->insertItem("Password"); |
994 | sl->insertItem(se->text()); | 995 | sl->insertItem(se->text()); |
995 | break; | 996 | break; |
996 | 997 | ||
997 | case ScriptEdit::ID: | 998 | case ScriptEdit::ID: |
998 | stl->insertItem("ID"); | 999 | stl->insertItem("ID"); |
999 | sl->insertItem(se->text()); | 1000 | sl->insertItem(se->text()); |
1000 | break; | 1001 | break; |
1001 | 1002 | ||
1002 | case ScriptEdit::Prompt: | 1003 | case ScriptEdit::Prompt: |
1003 | stl->insertItem("Prompt"); | 1004 | stl->insertItem("Prompt"); |
1004 | sl->insertItem(se->text()); | 1005 | sl->insertItem(se->text()); |
1005 | break; | 1006 | break; |
1006 | 1007 | ||
1007 | case ScriptEdit::PWPrompt: | 1008 | case ScriptEdit::PWPrompt: |
1008 | stl->insertItem("PWPrompt"); | 1009 | stl->insertItem("PWPrompt"); |
1009 | sl->insertItem(se->text()); | 1010 | sl->insertItem(se->text()); |
1010 | break; | 1011 | break; |
1011 | 1012 | ||
1012 | case ScriptEdit::LoopStart: | 1013 | case ScriptEdit::LoopStart: |
1013 | stl->insertItem("LoopStart"); | 1014 | stl->insertItem("LoopStart"); |
1014 | sl->insertItem(se->text()); | 1015 | sl->insertItem(se->text()); |
1015 | break; | 1016 | break; |
1016 | 1017 | ||
1017 | case ScriptEdit::LoopEnd: | 1018 | case ScriptEdit::LoopEnd: |
1018 | stl->insertItem("LoopEnd"); | 1019 | stl->insertItem("LoopEnd"); |
1019 | sl->insertItem(se->text()); | 1020 | sl->insertItem(se->text()); |
1020 | break; | 1021 | break; |
1021 | 1022 | ||
1022 | case ScriptEdit::Scan: | 1023 | case ScriptEdit::Scan: |
1023 | stl->insertItem("Scan"); | 1024 | stl->insertItem("Scan"); |
1024 | sl->insertItem(se->text()); | 1025 | sl->insertItem(se->text()); |
1025 | break; | 1026 | break; |
1026 | 1027 | ||
1027 | case ScriptEdit::Save: | 1028 | case ScriptEdit::Save: |
1028 | stl->insertItem("Save"); | 1029 | stl->insertItem("Save"); |
1029 | sl->insertItem(se->text()); | 1030 | sl->insertItem(se->text()); |
1030 | break; | 1031 | break; |
1031 | 1032 | ||
1032 | default: | 1033 | default: |
1033 | break; | 1034 | break; |
1034 | } | 1035 | } |
1035 | 1036 | ||
1036 | //get the scrollbar adjusted, and scroll the list so we can see what | 1037 | //get the scrollbar adjusted, and scroll the list so we can see what |
1037 | //we're adding to | 1038 | //we're adding to |
1038 | adjustScrollBar(); | 1039 | adjustScrollBar(); |
1039 | slb->setValue(slb->maxValue()); | 1040 | slb->setValue(slb->maxValue()); |
1040 | 1041 | ||
1041 | //clear the text in the entry box | 1042 | //clear the text in the entry box |
1042 | se->setText(""); | 1043 | se->setText(""); |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | 1046 | ||
1046 | void ScriptWidget::insertButton() { | 1047 | void ScriptWidget::insertButton() { |
1047 | //exit if there is no highlighted item, or we've reached the | 1048 | //exit if there is no highlighted item, or we've reached the |
1048 | //maximum entries in the script list | 1049 | //maximum entries in the script list |
1049 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1050 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1050 | return; | 1051 | return; |
1051 | 1052 | ||
1052 | switch(se->type()) { | 1053 | switch(se->type()) { |
1053 | case ScriptEdit::Expect: | 1054 | case ScriptEdit::Expect: |
1054 | stl->insertItem("Expect", stl->currentItem()); | 1055 | stl->insertItem("Expect", stl->currentItem()); |
1055 | sl->insertItem(se->text(), sl->currentItem()); | 1056 | sl->insertItem(se->text(), sl->currentItem()); |
1056 | break; | 1057 | break; |
1057 | 1058 | ||
1058 | case ScriptEdit::Send: | 1059 | case ScriptEdit::Send: |
1059 | stl->insertItem("Send", stl->currentItem()); | 1060 | stl->insertItem("Send", stl->currentItem()); |
1060 | sl->insertItem(se->text(), sl->currentItem()); | 1061 | sl->insertItem(se->text(), sl->currentItem()); |
1061 | break; | 1062 | break; |
1062 | 1063 | ||
1063 | case ScriptEdit::SendNoEcho: | 1064 | case ScriptEdit::SendNoEcho: |
1064 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1065 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1065 | sl->insertItem(se->text(), sl->currentItem()); | 1066 | sl->insertItem(se->text(), sl->currentItem()); |
1066 | break; | 1067 | break; |
1067 | 1068 | ||
1068 | case ScriptEdit::Pause: | 1069 | case ScriptEdit::Pause: |
1069 | stl->insertItem("Pause", stl->currentItem()); | 1070 | stl->insertItem("Pause", stl->currentItem()); |
1070 | sl->insertItem(se->text(), sl->currentItem()); | 1071 | sl->insertItem(se->text(), sl->currentItem()); |
1071 | break; | 1072 | break; |
1072 | 1073 | ||
1073 | case ScriptEdit::Hangup: | 1074 | case ScriptEdit::Hangup: |
1074 | stl->insertItem("Hangup", stl->currentItem()); | 1075 | stl->insertItem("Hangup", stl->currentItem()); |
1075 | sl->insertItem("", sl->currentItem()); | 1076 | sl->insertItem("", sl->currentItem()); |
1076 | break; | 1077 | break; |
1077 | 1078 | ||
1078 | case ScriptEdit::Answer: | 1079 | case ScriptEdit::Answer: |
1079 | stl->insertItem("Answer", stl->currentItem()); | 1080 | stl->insertItem("Answer", stl->currentItem()); |
1080 | sl->insertItem("", sl->currentItem()); | 1081 | sl->insertItem("", sl->currentItem()); |
1081 | break; | 1082 | break; |
1082 | 1083 | ||
1083 | case ScriptEdit::Timeout: | 1084 | case ScriptEdit::Timeout: |
1084 | stl->insertItem("Timeout", stl->currentItem()); | 1085 | stl->insertItem("Timeout", stl->currentItem()); |
1085 | sl->insertItem(se->text(), sl->currentItem()); | 1086 | sl->insertItem(se->text(), sl->currentItem()); |
1086 | break; | 1087 | break; |
1087 | 1088 | ||
1088 | case ScriptEdit::Password: | 1089 | case ScriptEdit::Password: |
1089 | stl->insertItem("Password", stl->currentItem()); | 1090 | stl->insertItem("Password", stl->currentItem()); |
1090 | sl->insertItem(se->text(), sl->currentItem()); | 1091 | sl->insertItem(se->text(), sl->currentItem()); |
1091 | break; | 1092 | break; |
1092 | 1093 | ||
1093 | case ScriptEdit::ID: | 1094 | case ScriptEdit::ID: |
1094 | stl->insertItem("ID", stl->currentItem()); | 1095 | stl->insertItem("ID", stl->currentItem()); |
1095 | sl->insertItem(se->text(), sl->currentItem()); | 1096 | sl->insertItem(se->text(), sl->currentItem()); |
1096 | break; | 1097 | break; |
1097 | 1098 | ||
1098 | case ScriptEdit::Prompt: | 1099 | case ScriptEdit::Prompt: |
1099 | stl->insertItem("Prompt", stl->currentItem()); | 1100 | stl->insertItem("Prompt", stl->currentItem()); |
1100 | sl->insertItem(se->text(), sl->currentItem()); | 1101 | sl->insertItem(se->text(), sl->currentItem()); |
1101 | break; | 1102 | break; |
1102 | 1103 | ||
1103 | case ScriptEdit::PWPrompt: | 1104 | case ScriptEdit::PWPrompt: |
1104 | stl->insertItem("PWPrompt", stl->currentItem()); | 1105 | stl->insertItem("PWPrompt", stl->currentItem()); |
1105 | sl->insertItem(se->text(), sl->currentItem()); | 1106 | sl->insertItem(se->text(), sl->currentItem()); |
1106 | break; | 1107 | break; |
1107 | 1108 | ||
1108 | case ScriptEdit::LoopStart: | 1109 | case ScriptEdit::LoopStart: |
1109 | stl->insertItem("LoopStart", stl->currentItem()); | 1110 | stl->insertItem("LoopStart", stl->currentItem()); |
1110 | sl->insertItem(se->text(), sl->currentItem()); | 1111 | sl->insertItem(se->text(), sl->currentItem()); |
1111 | break; | 1112 | break; |
1112 | 1113 | ||
1113 | case ScriptEdit::LoopEnd: | 1114 | case ScriptEdit::LoopEnd: |
1114 | stl->insertItem("LoopEnd", stl->currentItem()); | 1115 | stl->insertItem("LoopEnd", stl->currentItem()); |
1115 | sl->insertItem(se->text(), sl->currentItem()); | 1116 | sl->insertItem(se->text(), sl->currentItem()); |
1116 | break; | 1117 | break; |
1117 | 1118 | ||
1118 | case ScriptEdit::Scan: | 1119 | case ScriptEdit::Scan: |
1119 | stl->insertItem("Scan", stl->currentItem()); | 1120 | stl->insertItem("Scan", stl->currentItem()); |
1120 | sl->insertItem(se->text(), sl->currentItem()); | 1121 | sl->insertItem(se->text(), sl->currentItem()); |
1121 | break; | 1122 | break; |
1122 | 1123 | ||
1123 | case ScriptEdit::Save: | 1124 | case ScriptEdit::Save: |
1124 | stl->insertItem("Save", stl->currentItem()); | 1125 | stl->insertItem("Save", stl->currentItem()); |
1125 | sl->insertItem(se->text(), sl->currentItem()); | 1126 | sl->insertItem(se->text(), sl->currentItem()); |
1126 | break; | 1127 | break; |
1127 | 1128 | ||
1128 | default: | 1129 | default: |
1129 | break; | 1130 | break; |
1130 | } | 1131 | } |
1131 | adjustScrollBar(); | 1132 | adjustScrollBar(); |
1132 | se->setText(""); | 1133 | se->setText(""); |
1133 | } | 1134 | } |
1134 | 1135 | ||
1135 | 1136 | ||
1136 | void ScriptWidget::removeButton() { | 1137 | void ScriptWidget::removeButton() { |
1137 | if(sl->currentItem() >= 0) { | 1138 | if(sl->currentItem() >= 0) { |
1138 | int stlc = stl->currentItem(); | 1139 | int stlc = stl->currentItem(); |
1139 | sl->removeItem(sl->currentItem()); | 1140 | sl->removeItem(sl->currentItem()); |
1140 | stl->removeItem(stlc); | 1141 | stl->removeItem(stlc); |
1141 | adjustScrollBar(); | 1142 | adjustScrollBar(); |
1142 | insert->setEnabled(sl->currentItem() != -1); | 1143 | insert->setEnabled(sl->currentItem() != -1); |
1143 | remove->setEnabled(sl->currentItem() != -1); | 1144 | remove->setEnabled(sl->currentItem() != -1); |
1144 | } | 1145 | } |
1145 | } | 1146 | } |
1146 | 1147 | ||
1147 | 1148 | ||
1148 | 1149 | ||
1149 | ///////////////////////////////////////////////////////////////////////////// | 1150 | ///////////////////////////////////////////////////////////////////////////// |
1150 | // | 1151 | // |
1151 | // Used to specify a new phone number | 1152 | // Used to specify a new phone number |
1152 | // | 1153 | // |
1153 | ///////////////////////////////////////////////////////////////////////////// | 1154 | ///////////////////////////////////////////////////////////////////////////// |
1154 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1155 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1155 | : QDialog(parent,"PhoneNumberDialog",true) | 1156 | : QDialog(parent,"PhoneNumberDialog",true) |
1156 | { | 1157 | { |
1157 | setCaption( i18n("Add Phone Number") ); | 1158 | setCaption( i18n("Add Phone Number") ); |
1158 | 1159 | ||
1159 | 1160 | ||
1160 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1161 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1161 | layout->setSpacing( 3 ); | 1162 | layout->setSpacing( 3 ); |
1162 | layout->setMargin( 3 ); | 1163 | layout->setMargin( 3 ); |
1163 | 1164 | ||
1164 | // QHBox *hbox = new QHBox(this); | 1165 | // QHBox *hbox = new QHBox(this); |
1165 | // setMainWidget(hbox); | 1166 | // setMainWidget(hbox); |
1166 | 1167 | ||
1167 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1168 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1168 | 1169 | ||
1169 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1170 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1170 | layout->addWidget( label ); | 1171 | layout->addWidget( label ); |
1171 | 1172 | ||
1172 | le = new QLineEdit(this, "lineEdit"); | 1173 | le = new QLineEdit(this, "lineEdit"); |
1173 | layout->addWidget( le ); | 1174 | layout->addWidget( le ); |
1174 | 1175 | ||
1175 | connect(le, SIGNAL(textChanged(const QString &)), | 1176 | connect(le, SIGNAL(textChanged(const QString &)), |
1176 | this, SLOT(textChanged(const QString &))); | 1177 | this, SLOT(textChanged(const QString &))); |
1177 | 1178 | ||
1178 | le->setFocus(); | 1179 | le->setFocus(); |
1179 | textChanged(""); | 1180 | textChanged(""); |
1180 | 1181 | ||
1181 | 1182 | ||
1182 | } | 1183 | } |
1183 | 1184 | ||
1184 | 1185 | ||
1185 | QString PhoneNumberDialog::phoneNumber() { | 1186 | QString PhoneNumberDialog::phoneNumber() { |
1186 | QString s = le->text(); | 1187 | QString s = le->text(); |
1187 | 1188 | ||
1188 | return s; | 1189 | return s; |
1189 | } | 1190 | } |
1190 | 1191 | ||
1191 | 1192 | ||
1192 | void PhoneNumberDialog::textChanged(const QString &s) { | 1193 | void PhoneNumberDialog::textChanged(const QString &s) { |
1193 | // enableButtonOK(s.length() > 0); | 1194 | // enableButtonOK(s.length() > 0); |
1194 | } | 1195 | } |
1195 | 1196 | ||
1196 | 1197 | ||
1197 | //#include "edit.moc" | 1198 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h index cd0161f..2cc0fed 100644 --- a/noncore/settings/networksettings/ppp/edit.h +++ b/noncore/settings/networksettings/ppp/edit.h | |||
@@ -1,251 +1,259 @@ | |||
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 | 51 | ||
51 | class DialWidget : public QWidget { | 52 | class DialWidget : public QWidget { |
52 | Q_OBJECT | 53 | Q_OBJECT |
53 | public: | 54 | public: |
54 | DialWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 55 | DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
55 | ~DialWidget() {} | 56 | ~DialWidget() {} |
56 | 57 | ||
57 | public slots: | 58 | public slots: |
58 | bool save(); | 59 | bool save(); |
59 | void pppdargsbutton(); | 60 | void pppdargsbutton(); |
60 | void numbersChanged(); | 61 | void numbersChanged(); |
61 | void selectionChanged(int); | 62 | void selectionChanged(int); |
62 | void addNumber(); | 63 | void addNumber(); |
63 | void delNumber(); | 64 | void delNumber(); |
64 | void upNumber(); | 65 | void upNumber(); |
65 | void downNumber(); | 66 | void downNumber(); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | QLineEdit *connectname_l; | 69 | QLineEdit *connectname_l; |
69 | QLabel *connect_label; | 70 | QLabel *connect_label; |
70 | QLabel *number_label; | 71 | QLabel *number_label; |
71 | QPushButton *pppdargs; | 72 | QPushButton *pppdargs; |
72 | QComboBox *auth; | 73 | QComboBox *auth; |
73 | QLabel *auth_l; | 74 | QLabel *auth_l; |
74 | QCheckBox *store_password; | 75 | QCheckBox *store_password; |
75 | 76 | ||
76 | // for the phonenumber selection | 77 | // for the phonenumber selection |
77 | QPushButton *add, *del, *up, *down; | 78 | QPushButton *add, *del, *up, *down; |
78 | QListBox *numbers; | 79 | QListBox *numbers; |
80 | PPPData *_pppdata; | ||
79 | }; | 81 | }; |
80 | 82 | ||
81 | 83 | ||
82 | ///////////////////////////////////////////////////////////////////////////// | 84 | ///////////////////////////////////////////////////////////////////////////// |
83 | // | 85 | // |
84 | // tab-window to select what to execute when | 86 | // tab-window to select what to execute when |
85 | // | 87 | // |
86 | ///////////////////////////////////////////////////////////////////////////// | 88 | ///////////////////////////////////////////////////////////////////////////// |
87 | class ExecWidget : public QWidget { | 89 | class ExecWidget : public QWidget { |
88 | Q_OBJECT | 90 | Q_OBJECT |
89 | public: | 91 | public: |
90 | ExecWidget(QWidget *parent=0, bool isnewaccount=true, const char *name=0); | 92 | ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0); |
91 | 93 | ||
92 | public slots: | 94 | public slots: |
93 | bool save(); | 95 | bool save(); |
94 | 96 | ||
95 | private: | 97 | private: |
96 | QLineEdit *before_connect; | 98 | QLineEdit *before_connect; |
97 | QLabel *before_connect_l; | 99 | QLabel *before_connect_l; |
98 | 100 | ||
99 | QLineEdit *command; | 101 | QLineEdit *command; |
100 | QLabel *command_label; | 102 | QLabel *command_label; |
101 | 103 | ||
102 | QLineEdit *predisconnect; | 104 | QLineEdit *predisconnect; |
103 | QLabel *predisconnect_label; | 105 | QLabel *predisconnect_label; |
104 | 106 | ||
105 | QLineEdit *discommand; | 107 | QLineEdit *discommand; |
106 | QLabel *discommand_label; | 108 | QLabel *discommand_label; |
109 | PPPData *_pppdata; | ||
107 | }; | 110 | }; |
108 | 111 | ||
109 | 112 | ||
110 | class IPWidget : public QWidget { | 113 | class IPWidget : public QWidget { |
111 | Q_OBJECT | 114 | Q_OBJECT |
112 | public: | 115 | public: |
113 | IPWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 116 | IPWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
114 | ~IPWidget() {} | 117 | ~IPWidget() {} |
115 | 118 | ||
116 | public slots: | 119 | public slots: |
117 | void save(); | 120 | void save(); |
118 | 121 | ||
119 | protected slots: | 122 | protected slots: |
120 | void hitIPSelect( int ); | 123 | void hitIPSelect( int ); |
121 | void autoname_t(bool on); | 124 | void autoname_t(bool on); |
122 | 125 | ||
123 | private: | 126 | private: |
124 | QLabel *ipaddress_label; | 127 | QLabel *ipaddress_label; |
125 | QLabel *sub_label; | 128 | QLabel *sub_label; |
126 | QGroupBox *box1; | 129 | QGroupBox *box1; |
127 | QVGroupBox *box; | 130 | QVGroupBox *box; |
128 | 131 | ||
129 | QButtonGroup *rb; | 132 | QButtonGroup *rb; |
130 | QRadioButton *dynamicadd_rb; | 133 | QRadioButton *dynamicadd_rb; |
131 | QRadioButton *staticadd_rb; | 134 | QRadioButton *staticadd_rb; |
132 | 135 | ||
133 | IPLineEdit *ipaddress_l; | 136 | IPLineEdit *ipaddress_l; |
134 | IPLineEdit *subnetmask_l; | 137 | IPLineEdit *subnetmask_l; |
135 | 138 | ||
136 | QCheckBox *autoname; | 139 | QCheckBox *autoname; |
140 | PPPData *_pppdata; | ||
137 | }; | 141 | }; |
138 | 142 | ||
139 | 143 | ||
140 | class DNSWidget : public QWidget { | 144 | class DNSWidget : public QWidget { |
141 | Q_OBJECT | 145 | Q_OBJECT |
142 | public: | 146 | public: |
143 | DNSWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 147 | DNSWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
144 | ~DNSWidget() {} | 148 | ~DNSWidget() {} |
145 | 149 | ||
146 | public slots: | 150 | public slots: |
147 | void save(); | 151 | void save(); |
148 | 152 | ||
149 | protected slots: | 153 | protected slots: |
150 | void adddns(); | 154 | void adddns(); |
151 | void removedns(); | 155 | void removedns(); |
152 | void DNS_Edit_Changed(const QString &); | 156 | void DNS_Edit_Changed(const QString &); |
153 | void DNS_Entry_Selected(int); | 157 | void DNS_Entry_Selected(int); |
154 | void DNS_Mode_Selected(int); | 158 | void DNS_Mode_Selected(int); |
155 | 159 | ||
156 | private: | 160 | private: |
157 | QLabel *conf_label; | 161 | QLabel *conf_label; |
158 | QButtonGroup *bg; | 162 | QButtonGroup *bg; |
159 | QRadioButton *autodns, *mandns; | 163 | QRadioButton *autodns, *mandns; |
160 | QLabel *dns_label; | 164 | QLabel *dns_label; |
161 | QLabel *servers_label; | 165 | QLabel *servers_label; |
162 | IPLineEdit *dnsipaddr; | 166 | IPLineEdit *dnsipaddr; |
163 | QPushButton *add; | 167 | QPushButton *add; |
164 | QPushButton *remove; | 168 | QPushButton *remove; |
165 | QListBox *dnsservers; | 169 | QListBox *dnsservers; |
166 | QLineEdit *dnsdomain; | 170 | QLineEdit *dnsdomain; |
167 | QLabel *dnsdomain_label; | 171 | QLabel *dnsdomain_label; |
168 | QCheckBox *exdnsdisabled_toggle; | 172 | QCheckBox *exdnsdisabled_toggle; |
173 | PPPData *_pppdata; | ||
169 | }; | 174 | }; |
170 | 175 | ||
171 | 176 | ||
172 | class GatewayWidget : public QWidget { | 177 | class GatewayWidget : public QWidget { |
173 | Q_OBJECT | 178 | Q_OBJECT |
174 | public: | 179 | public: |
175 | GatewayWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 180 | GatewayWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
176 | ~GatewayWidget() {} | 181 | ~GatewayWidget() {} |
177 | 182 | ||
178 | public slots: | 183 | public slots: |
179 | void save(); | 184 | void save(); |
180 | 185 | ||
181 | private slots: | 186 | private slots: |
182 | void hitGatewaySelect( int ); | 187 | void hitGatewaySelect( int ); |
183 | 188 | ||
184 | private: | 189 | private: |
185 | QGroupBox *box; | 190 | QGroupBox *box; |
186 | QLabel *gate_label; | 191 | QLabel *gate_label; |
187 | QGroupBox *box1; | 192 | QGroupBox *box1; |
188 | QButtonGroup *rb; | 193 | QButtonGroup *rb; |
189 | QRadioButton *defaultgateway; | 194 | QRadioButton *defaultgateway; |
190 | QRadioButton *staticgateway; | 195 | QRadioButton *staticgateway; |
191 | IPLineEdit *gatewayaddr; | 196 | IPLineEdit *gatewayaddr; |
192 | QCheckBox *defaultroute; | 197 | QCheckBox *defaultroute; |
198 | PPPData *_pppdata; | ||
193 | }; | 199 | }; |
194 | 200 | ||
195 | 201 | ||
196 | class ScriptWidget : public QWidget { | 202 | class ScriptWidget : public QWidget { |
197 | Q_OBJECT | 203 | Q_OBJECT |
198 | public: | 204 | public: |
199 | ScriptWidget( QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); | 205 | ScriptWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 ); |
200 | ~ScriptWidget() {} | 206 | ~ScriptWidget() {} |
201 | 207 | ||
202 | public slots: | 208 | public slots: |
203 | void save(); | 209 | void save(); |
204 | bool check(); | 210 | bool check(); |
205 | 211 | ||
206 | private slots: | 212 | private slots: |
207 | void addButton(); | 213 | void addButton(); |
208 | void insertButton(); | 214 | void insertButton(); |
209 | void removeButton(); | 215 | void removeButton(); |
210 | 216 | ||
211 | //signals linked to the scroll bar | 217 | //signals linked to the scroll bar |
212 | void scrolling(int); | 218 | void scrolling(int); |
213 | 219 | ||
214 | //signals to keep the two listboxes highlighted in sync | 220 | //signals to keep the two listboxes highlighted in sync |
215 | void slhighlighted(int); | 221 | void slhighlighted(int); |
216 | void stlhighlighted(int); | 222 | void stlhighlighted(int); |
217 | 223 | ||
218 | private: | 224 | private: |
219 | void adjustScrollBar(); | 225 | void adjustScrollBar(); |
220 | 226 | ||
221 | ScriptEdit *se; | 227 | ScriptEdit *se; |
222 | QPushButton *add; | 228 | QPushButton *add; |
223 | QPushButton *remove; | 229 | QPushButton *remove; |
224 | QPushButton *insert; | 230 | QPushButton *insert; |
225 | QListBox *sl, *stl; | 231 | QListBox *sl, *stl; |
226 | 232 | ||
227 | QScrollBar *slb; | 233 | QScrollBar *slb; |
234 | PPPData *_pppdata; | ||
228 | }; | 235 | }; |
229 | 236 | ||
230 | 237 | ||
231 | ///////////////////////////////////////////////////////////////////////////// | 238 | ///////////////////////////////////////////////////////////////////////////// |
232 | // | 239 | // |
233 | // Used to specify a new phone number | 240 | // Used to specify a new phone number |
234 | // | 241 | // |
235 | ///////////////////////////////////////////////////////////////////////////// | 242 | ///////////////////////////////////////////////////////////////////////////// |
236 | class PhoneNumberDialog : public QDialog { | 243 | class PhoneNumberDialog : public QDialog { |
237 | Q_OBJECT | 244 | Q_OBJECT |
238 | public: | 245 | public: |
239 | PhoneNumberDialog(QWidget *parent = 0); | 246 | PhoneNumberDialog(QWidget *parent = 0); |
240 | 247 | ||
241 | QString phoneNumber(); | 248 | QString phoneNumber(); |
242 | 249 | ||
243 | private slots: | 250 | private slots: |
244 | void textChanged(const QString &); | 251 | void textChanged(const QString &); |
245 | 252 | ||
246 | private: | 253 | private: |
247 | QLineEdit *le; | 254 | QLineEdit *le; |
255 | |||
248 | }; | 256 | }; |
249 | 257 | ||
250 | 258 | ||
251 | #endif | 259 | #endif |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 98e035b..f735e49 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -1,438 +1,441 @@ | |||
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 <termios.h> | 27 | #include <termios.h> |
28 | #include <string.h> | 28 | #include <string.h> |
29 | 29 | ||
30 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qwhatsthis.h> | 37 | #include <qwhatsthis.h> |
38 | 38 | ||
39 | // #include <qgroupbox.h> | 39 | // #include <qgroupbox.h> |
40 | 40 | ||
41 | #include "general.h" | 41 | #include "general.h" |
42 | //#include "version.h" | 42 | #include "interfaceppp.h" |
43 | //#include "miniterm.h" | 43 | //#include "miniterm.h" |
44 | #include "modeminfo.h" | 44 | #include "modeminfo.h" |
45 | #include "modemcmds.h" | 45 | #include "modemcmds.h" |
46 | #include "devices.h" | 46 | #include "devices.h" |
47 | #include "pppdata.h" | 47 | #include "pppdata.h" |
48 | //#include <klocale.h> | 48 | //#include <klocale.h> |
49 | #define i18n QObject::tr | 49 | #define i18n QObject::tr |
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | ModemWidget::ModemWidget( QWidget *parent, const char *name) | 53 | ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name ) |
54 | : QWidget(parent, name) | 54 | : QWidget(parent, name), _ifaceppp(ifppp) |
55 | { | 55 | { |
56 | int k; | 56 | int k; |
57 | 57 | ||
58 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 58 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); |
59 | 59 | ||
60 | QLabel *label1; | 60 | QLabel *label1; |
61 | label1 = new QLabel(i18n("Modem de&vice:"), this); | 61 | label1 = new QLabel(i18n("Modem de&vice:"), this); |
62 | tl->addWidget(label1, 0, 0); | 62 | tl->addWidget(label1, 0, 0); |
63 | 63 | ||
64 | modemdevice = new QComboBox(false, this); | 64 | modemdevice = new QComboBox(false, this); |
65 | label1->setBuddy(modemdevice); | 65 | label1->setBuddy(modemdevice); |
66 | 66 | ||
67 | for(k = 0; devices[k]; k++) | 67 | for(k = 0; devices[k]; k++) |
68 | modemdevice->insertItem(devices[k]); | 68 | modemdevice->insertItem(devices[k]); |
69 | 69 | ||
70 | tl->addWidget(modemdevice, 0, 1); | 70 | tl->addWidget(modemdevice, 0, 1); |
71 | connect(modemdevice, SIGNAL(activated(int)), | 71 | connect(modemdevice, SIGNAL(activated(int)), |
72 | SLOT(setmodemdc(int))); | 72 | SLOT(setmodemdc(int))); |
73 | QString tmp = i18n("This specifies the serial port your modem is attached \n" | 73 | QString tmp = i18n("This specifies the serial port your modem is attached \n" |
74 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" | 74 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
75 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 75 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
76 | "\n" | 76 | "\n" |
77 | "If you have an internal ISDN card with AT command\n" | 77 | "If you have an internal ISDN card with AT command\n" |
78 | "emulation (most cards under Linux support this), you\n" | 78 | "emulation (most cards under Linux support this), you\n" |
79 | "should select one of the /dev/ttyIx devices."); | 79 | "should select one of the /dev/ttyIx devices."); |
80 | 80 | ||
81 | QWhatsThis::add(label1,tmp); | 81 | QWhatsThis::add(label1,tmp); |
82 | QWhatsThis::add(modemdevice,tmp); | 82 | QWhatsThis::add(modemdevice,tmp); |
83 | 83 | ||
84 | 84 | ||
85 | label1 = new QLabel(i18n("&Flow control:"), this); | 85 | label1 = new QLabel(i18n("&Flow control:"), this); |
86 | tl->addWidget(label1, 1, 0); | 86 | tl->addWidget(label1, 1, 0); |
87 | 87 | ||
88 | flowcontrol = new QComboBox(false, this); | 88 | flowcontrol = new QComboBox(false, this); |
89 | label1->setBuddy(flowcontrol); | 89 | label1->setBuddy(flowcontrol); |
90 | flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); | 90 | flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); |
91 | flowcontrol->insertItem(i18n("Software [XON/XOFF]")); | 91 | flowcontrol->insertItem(i18n("Software [XON/XOFF]")); |
92 | flowcontrol->insertItem(i18n("None")); | 92 | flowcontrol->insertItem(i18n("None")); |
93 | tl->addWidget(flowcontrol, 1, 1); | 93 | tl->addWidget(flowcontrol, 1, 1); |
94 | connect(flowcontrol, SIGNAL(activated(int)), | 94 | connect(flowcontrol, SIGNAL(activated(int)), |
95 | SLOT(setflowcontrol(int))); | 95 | SLOT(setflowcontrol(int))); |
96 | 96 | ||
97 | tmp = i18n("<p>Specifies how the serial port and modem\n" | 97 | tmp = i18n("<p>Specifies how the serial port and modem\n" |
98 | "communicate. You should not change this unless\n" | 98 | "communicate. You should not change this unless\n" |
99 | "you know what you are doing.\n" | 99 | "you know what you are doing.\n" |
100 | "\n" | 100 | "\n" |
101 | "<b>Default</b>: CRTSCTS"); | 101 | "<b>Default</b>: CRTSCTS"); |
102 | 102 | ||
103 | QWhatsThis::add(label1,tmp); | 103 | QWhatsThis::add(label1,tmp); |
104 | QWhatsThis::add(flowcontrol,tmp); | 104 | QWhatsThis::add(flowcontrol,tmp); |
105 | 105 | ||
106 | QLabel *labelenter = new QLabel(i18n("&Line termination:"), this); | 106 | QLabel *labelenter = new QLabel(i18n("&Line termination:"), this); |
107 | tl->addWidget(labelenter, 2, 0); | 107 | tl->addWidget(labelenter, 2, 0); |
108 | 108 | ||
109 | enter = new QComboBox(false, this); | 109 | enter = new QComboBox(false, this); |
110 | labelenter->setBuddy(enter); | 110 | labelenter->setBuddy(enter); |
111 | enter->insertItem("CR"); | 111 | enter->insertItem("CR"); |
112 | enter->insertItem("LF"); | 112 | enter->insertItem("LF"); |
113 | enter->insertItem("CR/LF"); | 113 | enter->insertItem("CR/LF"); |
114 | tl->addWidget(enter, 2, 1); | 114 | tl->addWidget(enter, 2, 1); |
115 | connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 115 | connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
116 | tmp = i18n("<p>Specifies how AT commands are sent to your\n" | 116 | tmp = i18n("<p>Specifies how AT commands are sent to your\n" |
117 | "modem. Most modems will work fine with the\n" | 117 | "modem. Most modems will work fine with the\n" |
118 | "default <i>CR/LF</i>. If your modem does not react\n" | 118 | "default <i>CR/LF</i>. If your modem does not react\n" |
119 | "to the init string, you should try different\n" | 119 | "to the init string, you should try different\n" |
120 | "settings here\n" | 120 | "settings here\n" |
121 | "\n" | 121 | "\n" |
122 | "<b>Default</b>: CR/LF"); | 122 | "<b>Default</b>: CR/LF"); |
123 | 123 | ||
124 | QWhatsThis::add(labelenter,tmp); | 124 | QWhatsThis::add(labelenter,tmp); |
125 | QWhatsThis::add(enter, tmp); | 125 | QWhatsThis::add(enter, tmp); |
126 | 126 | ||
127 | QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this); | 127 | QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this); |
128 | tl->addWidget(baud_label, 3, 0); | 128 | tl->addWidget(baud_label, 3, 0); |
129 | baud_c = new QComboBox(this); | 129 | baud_c = new QComboBox(this); |
130 | baud_label->setBuddy(baud_c); | 130 | baud_label->setBuddy(baud_c); |
131 | 131 | ||
132 | static const char *baudrates[] = { | 132 | static const char *baudrates[] = { |
133 | 133 | ||
134 | #ifdef B460800 | 134 | #ifdef B460800 |
135 | "460800", | 135 | "460800", |
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | #ifdef B230400 | 138 | #ifdef B230400 |
139 | "230400", | 139 | "230400", |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | #ifdef B115200 | 142 | #ifdef B115200 |
143 | "115200", | 143 | "115200", |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | #ifdef B57600 | 146 | #ifdef B57600 |
147 | "57600", | 147 | "57600", |
148 | #endif | 148 | #endif |
149 | 149 | ||
150 | "38400", | 150 | "38400", |
151 | "19200", | 151 | "19200", |
152 | "9600", | 152 | "9600", |
153 | "2400", | 153 | "2400", |
154 | 0}; | 154 | 0}; |
155 | 155 | ||
156 | for(k = 0; baudrates[k]; k++) | 156 | for(k = 0; baudrates[k]; k++) |
157 | baud_c->insertItem(baudrates[k]); | 157 | baud_c->insertItem(baudrates[k]); |
158 | 158 | ||
159 | baud_c->setCurrentItem(3); | 159 | baud_c->setCurrentItem(3); |
160 | connect(baud_c, SIGNAL(activated(int)), | 160 | connect(baud_c, SIGNAL(activated(int)), |
161 | this, SLOT(speed_selection(int))); | 161 | this, SLOT(speed_selection(int))); |
162 | tl->addWidget(baud_c, 3, 1); | 162 | tl->addWidget(baud_c, 3, 1); |
163 | 163 | ||
164 | tmp = i18n("Specifies the speed your modem and the serial\n" | 164 | tmp = i18n("Specifies the speed your modem and the serial\n" |
165 | "port talk to each other. You should begin with\n" | 165 | "port talk to each other. You should begin with\n" |
166 | "the default of 38400 bits/sec. If everything\n" | 166 | "the default of 38400 bits/sec. If everything\n" |
167 | "works you can try to increase this value, but to\n" | 167 | "works you can try to increase this value, but to\n" |
168 | "no more than 115200 bits/sec (unless you know\n" | 168 | "no more than 115200 bits/sec (unless you know\n" |
169 | "that your serial port supports higher speeds)."); | 169 | "that your serial port supports higher speeds)."); |
170 | 170 | ||
171 | QWhatsThis::add(baud_label,tmp); | 171 | QWhatsThis::add(baud_label,tmp); |
172 | QWhatsThis::add(baud_c,tmp); | 172 | QWhatsThis::add(baud_c,tmp); |
173 | 173 | ||
174 | for(int i=0; i <= enter->count()-1; i++) { | 174 | for(int i=0; i <= enter->count()-1; i++) { |
175 | if(PPPData::data()->enter() == enter->text(i)) | 175 | if(_ifaceppp->data()->enter() == enter->text(i)) |
176 | enter->setCurrentItem(i); | 176 | enter->setCurrentItem(i); |
177 | } | 177 | } |
178 | 178 | ||
179 | tl->addRowSpacing(4, 10); | 179 | tl->addRowSpacing(4, 10); |
180 | 180 | ||
181 | //Modem Lock File | 181 | //Modem Lock File |
182 | modemlockfile = new QCheckBox(i18n("&Use lock file"), this); | 182 | modemlockfile = new QCheckBox(i18n("&Use lock file"), this); |
183 | 183 | ||
184 | modemlockfile->setChecked(PPPData::data()->modemLockFile()); | 184 | modemlockfile->setChecked(_ifaceppp->data()->modemLockFile()); |
185 | connect(modemlockfile, SIGNAL(toggled(bool)), | 185 | connect(modemlockfile, SIGNAL(toggled(bool)), |
186 | SLOT(modemlockfilechanged(bool))); | 186 | SLOT(modemlockfilechanged(bool))); |
187 | tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); | 187 | tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); |
188 | // l12->addStretch(1); | 188 | // l12->addStretch(1); |
189 | QWhatsThis::add(modemlockfile, | 189 | QWhatsThis::add(modemlockfile, |
190 | i18n("<p>To prevent other programs from accessing the\n" | 190 | i18n("<p>To prevent other programs from accessing the\n" |
191 | "modem while a connection is established, a\n" | 191 | "modem while a connection is established, a\n" |
192 | "file can be created to indicate that the modem\n" | 192 | "file can be created to indicate that the modem\n" |
193 | "is in use. On Linux an example file would be\n" | 193 | "is in use. On Linux an example file would be\n" |
194 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 194 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
195 | "Here you can select whether this locking will\n" | 195 | "Here you can select whether this locking will\n" |
196 | "be done.\n" | 196 | "be done.\n" |
197 | "\n" | 197 | "\n" |
198 | "<b>Default</b>: On")); | 198 | "<b>Default</b>: On")); |
199 | 199 | ||
200 | // Modem Timeout Line Edit Box | 200 | // Modem Timeout Line Edit Box |
201 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 201 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
202 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 202 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
203 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 203 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
204 | // modemtimeout = new KIntNumInput(PPPData::data()->modemTimeout(), this); | 204 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
205 | // modemtimeout->setLabel(i18n("Modem &timeout:")); | 205 | // modemtimeout->setLabel(i18n("Modem &timeout:")); |
206 | // modemtimeout->setRange(1, 120, 1); | 206 | // modemtimeout->setRange(1, 120, 1); |
207 | modemtimeout->setSuffix(i18n(" sec")); | 207 | modemtimeout->setSuffix(i18n(" sec")); |
208 | modemtimeout->setValue( _ifaceppp->data()->modemTimeout() ); | ||
208 | connect(modemtimeout, SIGNAL(valueChanged(int)), | 209 | connect(modemtimeout, SIGNAL(valueChanged(int)), |
209 | SLOT(modemtimeoutchanged(int))); | 210 | SLOT(modemtimeoutchanged(int))); |
210 | timeoutLayout->addWidget(timeoutlabel); | 211 | timeoutLayout->addWidget(timeoutlabel); |
211 | timeoutLayout->addWidget(modemtimeout); | 212 | timeoutLayout->addWidget(modemtimeout); |
212 | tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); | 213 | tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); |
213 | 214 | ||
214 | QWhatsThis::add(modemtimeout, | 215 | QWhatsThis::add(modemtimeout, |
215 | i18n("This specifies how long <i>kppp</i> waits for a\n" | 216 | i18n("This specifies how long <i>kppp</i> waits for a\n" |
216 | "<i>CONNECT</i> response from your modem. The\n" | 217 | "<i>CONNECT</i> response from your modem. The\n" |
217 | "recommended value is 30 seconds.")); | 218 | "recommended value is 30 seconds.")); |
218 | 219 | ||
219 | //set stuff from gpppdata | 220 | //set stuff from gpppdata |
220 | for(int i=0; i <= enter->count()-1; i++) { | 221 | for(int i=0; i <= enter->count()-1; i++) { |
221 | if(PPPData::data()->enter() == enter->text(i)) | 222 | if(_ifaceppp->data()->enter() == enter->text(i)) |
222 | enter->setCurrentItem(i); | 223 | enter->setCurrentItem(i); |
223 | } | 224 | } |
224 | 225 | ||
225 | for(int i=0; i <= modemdevice->count()-1; i++) { | 226 | for(int i=0; i <= modemdevice->count()-1; i++) { |
226 | if(PPPData::data()->modemDevice() == modemdevice->text(i)) | 227 | if(_ifaceppp->data()->modemDevice() == modemdevice->text(i)) |
227 | modemdevice->setCurrentItem(i); | 228 | modemdevice->setCurrentItem(i); |
228 | } | 229 | } |
229 | 230 | ||
230 | for(int i=0; i <= flowcontrol->count()-1; i++) { | 231 | for(int i=0; i <= flowcontrol->count()-1; i++) { |
231 | if(PPPData::data()->flowcontrol() == flowcontrol->text(i)) | 232 | if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i)) |
232 | flowcontrol->setCurrentItem(i); | 233 | flowcontrol->setCurrentItem(i); |
233 | } | 234 | } |
234 | 235 | ||
235 | //set the modem speed | 236 | //set the modem speed |
236 | for(int i=0; i < baud_c->count(); i++) | 237 | for(int i=0; i < baud_c->count(); i++) |
237 | if(baud_c->text(i) == PPPData::data()->speed()) | 238 | if(baud_c->text(i) == _ifaceppp->data()->speed()) |
238 | baud_c->setCurrentItem(i); | 239 | baud_c->setCurrentItem(i); |
239 | 240 | ||
240 | tl->setRowStretch(7, 1); | 241 | tl->setRowStretch(7, 1); |
241 | } | 242 | } |
242 | 243 | ||
243 | 244 | ||
244 | void ModemWidget::speed_selection(int) { | 245 | void ModemWidget::speed_selection(int) { |
245 | PPPData::data()->setSpeed(baud_c->text(baud_c->currentItem())); | 246 | _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem())); |
246 | } | 247 | } |
247 | 248 | ||
248 | 249 | ||
249 | void ModemWidget::setenter(int ) { | 250 | void ModemWidget::setenter(int ) { |
250 | PPPData::data()->setEnter(enter->text(enter->currentItem())); | 251 | _ifaceppp->data()->setEnter(enter->text(enter->currentItem())); |
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | void ModemWidget::setmodemdc(int i) { | 255 | void ModemWidget::setmodemdc(int i) { |
255 | PPPData::data()->setModemDevice(modemdevice->text(i)); | 256 | _ifaceppp->data()->setModemDevice(modemdevice->text(i)); |
256 | } | 257 | } |
257 | 258 | ||
258 | 259 | ||
259 | void ModemWidget::setflowcontrol(int i) { | 260 | void ModemWidget::setflowcontrol(int i) { |
260 | PPPData::data()->setFlowcontrol(flowcontrol->text(i)); | 261 | _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i)); |
261 | } | 262 | } |
262 | 263 | ||
263 | 264 | ||
264 | void ModemWidget::modemlockfilechanged(bool set) { | 265 | void ModemWidget::modemlockfilechanged(bool set) { |
265 | PPPData::data()->setModemLockFile(set); | 266 | _ifaceppp->data()->setModemLockFile(set); |
266 | } | 267 | } |
267 | 268 | ||
268 | 269 | ||
269 | void ModemWidget::modemtimeoutchanged(int n) { | 270 | void ModemWidget::modemtimeoutchanged(int n) { |
270 | PPPData::data()->setModemTimeout(n); | 271 | _ifaceppp->data()->setModemTimeout(n); |
271 | } | 272 | } |
272 | 273 | ||
273 | 274 | ||
274 | ModemWidget2::ModemWidget2( QWidget *parent, const char *name) | 275 | ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent, |
275 | : QWidget(parent, name) | 276 | const char *name) |
277 | : QWidget(parent, name), _ifaceppp(ifp) | ||
276 | { | 278 | { |
277 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 279 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
278 | 280 | ||
279 | 281 | ||
280 | waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); | 282 | waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); |
281 | waitfordt->setChecked(PPPData::data()->waitForDialTone()); | 283 | waitfordt->setChecked(_ifaceppp->data()->waitForDialTone()); |
282 | connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 284 | connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
283 | l1->addWidget(waitfordt); | 285 | l1->addWidget(waitfordt); |
284 | QWhatsThis::add(waitfordt, | 286 | QWhatsThis::add(waitfordt, |
285 | i18n("<p>Normally the modem waits for a dial tone\n" | 287 | i18n("<p>Normally the modem waits for a dial tone\n" |
286 | "from your phone line, indicating that it can\n" | 288 | "from your phone line, indicating that it can\n" |
287 | "start to dial a number. If your modem does not\n" | 289 | "start to dial a number. If your modem does not\n" |
288 | "recognize this sound, or your local phone system\n" | 290 | "recognize this sound, or your local phone system\n" |
289 | "does not emit such a tone, uncheck this option\n" | 291 | "does not emit such a tone, uncheck this option\n" |
290 | "\n" | 292 | "\n" |
291 | "<b>Default:</b>: On")); | 293 | "<b>Default:</b>: On")); |
292 | 294 | ||
293 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 295 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
294 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 296 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
295 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 297 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
296 | // busywait = new KIntNumInput(PPPData::data()->busyWait(), this); | 298 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
297 | // busywait->setLabel(i18n("B&usy wait:")); | 299 | // busywait->setLabel(i18n("B&usy wait:")); |
298 | // busywait->setRange(0, 300, 5, true); | 300 | // busywait->setRange(0, 300, 5, true); |
299 | busywait->setSuffix(i18n(" sec")); | 301 | busywait->setSuffix(i18n(" sec")); |
300 | connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 302 | connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
301 | waitLayout->addWidget(waitLabel); | 303 | waitLayout->addWidget(waitLabel); |
302 | waitLayout->addWidget(busywait); | 304 | waitLayout->addWidget(busywait); |
303 | l1->addLayout( waitLayout ); | 305 | l1->addLayout( waitLayout ); |
304 | 306 | ||
305 | QWhatsThis::add(busywait, | 307 | QWhatsThis::add(busywait, |
306 | i18n("Specifies the number of seconds to wait before\n" | 308 | i18n("Specifies the number of seconds to wait before\n" |
307 | "redial if all dialed numbers are busy. This is\n" | 309 | "redial if all dialed numbers are busy. This is\n" |
308 | "necessary because some modems get stuck if the\n" | 310 | "necessary because some modems get stuck if the\n" |
309 | "same number is busy too often.\n" | 311 | "same number is busy too often.\n" |
310 | "\n" | 312 | "\n" |
311 | "The default is 0 seconds, you should not change\n" | 313 | "The default is 0 seconds, you should not change\n" |
312 | "this unless you need to.")); | 314 | "this unless you need to.")); |
313 | 315 | ||
314 | l1->addSpacing(10); | 316 | l1->addSpacing(10); |
315 | 317 | ||
316 | QHBoxLayout *hbl = new QHBoxLayout; | 318 | QHBoxLayout *hbl = new QHBoxLayout; |
317 | hbl->setSpacing(2);//KDialog::spacingHint()); | 319 | hbl->setSpacing(2);//KDialog::spacingHint()); |
318 | 320 | ||
319 | QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); | 321 | QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); |
320 | hbl->addWidget(volumeLabel); | 322 | hbl->addWidget(volumeLabel); |
321 | volume = new QSlider(0, 2, 1, PPPData::data()->volume(), QSlider::Horizontal, this); | 323 | volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(), |
324 | QSlider::Horizontal, this); | ||
322 | volumeLabel->setBuddy(volume); | 325 | volumeLabel->setBuddy(volume); |
323 | volume->setTickmarks(QSlider::Below); | 326 | volume->setTickmarks(QSlider::Below); |
324 | hbl->addWidget(volume); | 327 | hbl->addWidget(volume); |
325 | 328 | ||
326 | l1->addLayout(hbl); | 329 | l1->addLayout(hbl); |
327 | 330 | ||
328 | connect(volume, SIGNAL(valueChanged(int)), | 331 | connect(volume, SIGNAL(valueChanged(int)), |
329 | this, SLOT(volumeChanged(int))); | 332 | this, SLOT(volumeChanged(int))); |
330 | QString tmp = i18n("Most modems have a speaker which makes\n" | 333 | QString tmp = i18n("Most modems have a speaker which makes\n" |
331 | "a lot of noise when dialing. Here you can\n" | 334 | "a lot of noise when dialing. Here you can\n" |
332 | "either turn this completely off or select a\n" | 335 | "either turn this completely off or select a\n" |
333 | "lower volume.\n" | 336 | "lower volume.\n" |
334 | "\n" | 337 | "\n" |
335 | "If this does not work for your modem,\n" | 338 | "If this does not work for your modem,\n" |
336 | "you must modify the modem volume command."); | 339 | "you must modify the modem volume command."); |
337 | 340 | ||
338 | QWhatsThis::add(volumeLabel,tmp); | 341 | QWhatsThis::add(volumeLabel,tmp); |
339 | QWhatsThis::add(volume, tmp); | 342 | QWhatsThis::add(volume, tmp); |
340 | 343 | ||
341 | l1->addSpacing(20); | 344 | l1->addSpacing(20); |
342 | 345 | ||
343 | #if 0 | 346 | #if 0 |
344 | chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); | 347 | chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); |
345 | chkbox1->setChecked(PPPData::data()->UseCDLine()); | 348 | chkbox1->setChecked(_ifaceppp->data()->UseCDLine()); |
346 | connect(chkbox1,SIGNAL(toggled(bool)), | 349 | connect(chkbox1,SIGNAL(toggled(bool)), |
347 | this,SLOT(use_cdline_toggled(bool))); | 350 | this,SLOT(use_cdline_toggled(bool))); |
348 | l12->addWidget(chkbox1); | 351 | l12->addWidget(chkbox1); |
349 | l12->addStretch(1); | 352 | l12->addStretch(1); |
350 | l1->addStretch(1); | 353 | l1->addStretch(1); |
351 | QWhatsThis::add(chkbox1, | 354 | QWhatsThis::add(chkbox1, |
352 | i18n("This controls how <i>kppp</i> detects that the modem\n" | 355 | i18n("This controls how <i>kppp</i> detects that the modem\n" |
353 | "is not responding. Unless you are having\n" | 356 | "is not responding. Unless you are having\n" |
354 | "problems with this, do not modify this setting.\n" | 357 | "problems with this, do not modify this setting.\n" |
355 | "\n" | 358 | "\n" |
356 | "<b>Default</b>: Off")); | 359 | "<b>Default</b>: Off")); |
357 | #endif | 360 | #endif |
358 | 361 | ||
359 | modemcmds = new QPushButton(i18n("Mod&em Commands..."), this); | 362 | modemcmds = new QPushButton(i18n("Mod&em Commands..."), this); |
360 | QWhatsThis::add(modemcmds, | 363 | QWhatsThis::add(modemcmds, |
361 | i18n("Allows you to change the AT command for\n" | 364 | i18n("Allows you to change the AT command for\n" |
362 | "your modem.")); | 365 | "your modem.")); |
363 | 366 | ||
364 | modeminfo_button = new QPushButton(i18n("&Query Modem..."), this); | 367 | modeminfo_button = new QPushButton(i18n("&Query Modem..."), this); |
365 | QWhatsThis::add(modeminfo_button, | 368 | QWhatsThis::add(modeminfo_button, |
366 | i18n("Most modems support the ATI command set to\n" | 369 | i18n("Most modems support the ATI command set to\n" |
367 | "find out vendor and revision of your modem.\n" | 370 | "find out vendor and revision of your modem.\n" |
368 | "\n" | 371 | "\n" |
369 | "Press this button to query your modem for\n" | 372 | "Press this button to query your modem for\n" |
370 | "this information. It can be useful to help\n" | 373 | "this information. It can be useful to help\n" |
371 | "you setup the modem")); | 374 | "you setup the modem")); |
372 | 375 | ||
373 | // terminal_button = new QPushButton(i18n("&Terminal..."), this); | 376 | // terminal_button = new QPushButton(i18n("&Terminal..."), this); |
374 | // QWhatsThis::add(terminal_button, | 377 | // QWhatsThis::add(terminal_button, |
375 | // i18n("Opens the built-in terminal program. You\n" | 378 | // i18n("Opens the built-in terminal program. You\n" |
376 | // "can use this if you want to play around\n" | 379 | // "can use this if you want to play around\n" |
377 | // "with your modem's AT command set")); | 380 | // "with your modem's AT command set")); |
378 | 381 | ||
379 | QHBoxLayout *hbox = new QHBoxLayout(); | 382 | QHBoxLayout *hbox = new QHBoxLayout(); |
380 | l1->addLayout(hbox); | 383 | l1->addLayout(hbox); |
381 | hbox->addStretch(1); | 384 | hbox->addStretch(1); |
382 | QVBoxLayout *vbox = new QVBoxLayout(); | 385 | QVBoxLayout *vbox = new QVBoxLayout(); |
383 | hbox->addLayout(vbox); | 386 | hbox->addLayout(vbox); |
384 | 387 | ||
385 | vbox->addWidget(modemcmds); | 388 | vbox->addWidget(modemcmds); |
386 | vbox->addWidget(modeminfo_button); | 389 | vbox->addWidget(modeminfo_button); |
387 | // vbox->addWidget(terminal_button); | 390 | // vbox->addWidget(terminal_button); |
388 | 391 | ||
389 | hbox->addStretch(1); | 392 | hbox->addStretch(1); |
390 | l1->addStretch(1); | 393 | l1->addStretch(1); |
391 | 394 | ||
392 | connect(modemcmds, SIGNAL(clicked()), | 395 | connect(modemcmds, SIGNAL(clicked()), |
393 | SLOT(modemcmdsbutton())); | 396 | SLOT(modemcmdsbutton())); |
394 | connect(modeminfo_button, SIGNAL(clicked()), | 397 | connect(modeminfo_button, SIGNAL(clicked()), |
395 | SLOT(query_modem())); | 398 | SLOT(query_modem())); |
396 | // connect(terminal_button, SIGNAL(clicked()), | 399 | // connect(terminal_button, SIGNAL(clicked()), |
397 | // SLOT(terminal())); | 400 | // SLOT(terminal())); |
398 | } | 401 | } |
399 | 402 | ||
400 | 403 | ||
401 | void ModemWidget2::modemcmdsbutton() { | 404 | void ModemWidget2::modemcmdsbutton() { |
402 | ModemCommands mc(this); | 405 | ModemCommands mc(_ifaceppp->data(), this); |
403 | mc.showMaximized(); | 406 | mc.showMaximized(); |
404 | mc.exec(); | 407 | mc.exec(); |
405 | } | 408 | } |
406 | 409 | ||
407 | 410 | ||
408 | void ModemWidget2::query_modem() { | 411 | void ModemWidget2::query_modem() { |
409 | ModemTransfer mt(this); | 412 | ModemTransfer mt(_ifaceppp->modem(), this); |
410 | mt.exec(); | 413 | mt.exec(); |
411 | } | 414 | } |
412 | 415 | ||
413 | 416 | ||
414 | // void ModemWidget2::terminal() { | 417 | // void ModemWidget2::terminal() { |
415 | // MiniTerm terminal(NULL,NULL); | 418 | // MiniTerm terminal(NULL,NULL); |
416 | // terminal.exec(); | 419 | // terminal.exec(); |
417 | // } | 420 | // } |
418 | 421 | ||
419 | 422 | ||
420 | #if 0 | 423 | #if 0 |
421 | void ModemWidget2::use_cdline_toggled(bool on) { | 424 | void ModemWidget2::use_cdline_toggled(bool on) { |
422 | PPPData::data()->setUseCDLine(on); | 425 | _ifaceppp->data()->setUseCDLine(on); |
423 | } | 426 | } |
424 | #endif | 427 | #endif |
425 | 428 | ||
426 | void ModemWidget2::waitfordtchanged(bool b) { | 429 | void ModemWidget2::waitfordtchanged(bool b) { |
427 | PPPData::data()->setWaitForDialTone((int)b); | 430 | _ifaceppp->data()->setWaitForDialTone((int)b); |
428 | } | 431 | } |
429 | 432 | ||
430 | void ModemWidget2::busywaitchanged(int n) { | 433 | void ModemWidget2::busywaitchanged(int n) { |
431 | PPPData::data()->setbusyWait(n); | 434 | _ifaceppp->data()->setbusyWait(n); |
432 | } | 435 | } |
433 | 436 | ||
434 | 437 | ||
435 | void ModemWidget2::volumeChanged(int v) { | 438 | void ModemWidget2::volumeChanged(int v) { |
436 | PPPData::data()->setVolume(v); | 439 | _ifaceppp->data()->setVolume(v); |
437 | } | 440 | } |
438 | 441 | ||
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index 4869f6c..3e59b46 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h | |||
@@ -1,98 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * | 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 | #ifndef _GENERAL_H_ | 26 | #ifndef _GENERAL_H_ |
27 | #define _GENERAL_H_ | 27 | #define _GENERAL_H_ |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | 30 | ||
31 | class QSlider; | 31 | class QSlider; |
32 | class QSpinBox; | 32 | class QSpinBox; |
33 | class QCombobox; | 33 | class QCombobox; |
34 | class QLabel; | 34 | class QLabel; |
35 | class QCheckBox; | 35 | class QCheckBox; |
36 | class QComboBox; | 36 | class QComboBox; |
37 | 37 | class PPPData; | |
38 | 38 | class InterfacePPP; | |
39 | 39 | ||
40 | class ModemWidget : public QWidget { | 40 | class ModemWidget : public QWidget { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | ModemWidget( QWidget *parent=0, const char *name=0 ); | 43 | ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 ); |
44 | 44 | ||
45 | private slots: | 45 | private slots: |
46 | void setmodemdc(int); | 46 | void setmodemdc(int); |
47 | void setflowcontrol(int); | 47 | void setflowcontrol(int); |
48 | void modemtimeoutchanged(int); | 48 | void modemtimeoutchanged(int); |
49 | void modemlockfilechanged(bool); | 49 | void modemlockfilechanged(bool); |
50 | void setenter(int); | 50 | void setenter(int); |
51 | void speed_selection(int); | 51 | void speed_selection(int); |
52 | 52 | ||
53 | private: | 53 | private: |
54 | QComboBox *enter; | 54 | QComboBox *enter; |
55 | /* QLabel *label1; */ | 55 | /* QLabel *label1; */ |
56 | /* QLabel *label2; */ | 56 | /* QLabel *label2; */ |
57 | /* QLabel *labeltmp; */ | 57 | /* QLabel *labeltmp; */ |
58 | /* QLabel *labelenter; */ | 58 | /* QLabel *labelenter; */ |
59 | QComboBox *modemdevice; | 59 | QComboBox *modemdevice; |
60 | QComboBox *flowcontrol; | 60 | QComboBox *flowcontrol; |
61 | 61 | ||
62 | QComboBox *baud_c; | 62 | QComboBox *baud_c; |
63 | QLabel *baud_label; | 63 | QLabel *baud_label; |
64 | 64 | ||
65 | QSpinBox *modemtimeout; | 65 | QSpinBox *modemtimeout; |
66 | QCheckBox *modemlockfile; | 66 | QCheckBox *modemlockfile; |
67 | InterfacePPP *_ifaceppp; | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | 70 | ||
70 | class ModemWidget2 : public QWidget { | 71 | class ModemWidget2 : public QWidget { |
71 | Q_OBJECT | 72 | Q_OBJECT |
72 | public: | 73 | public: |
73 | ModemWidget2( QWidget *parent=0, const char *name=0 ); | 74 | ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 ); |
74 | 75 | ||
75 | private slots: | 76 | private slots: |
76 | void waitfordtchanged(bool); | 77 | void waitfordtchanged(bool); |
77 | void busywaitchanged(int); | 78 | void busywaitchanged(int); |
78 | // void use_cdline_toggled(bool); | 79 | // void use_cdline_toggled(bool); |
79 | void modemcmdsbutton(); | 80 | void modemcmdsbutton(); |
80 | // void terminal(); | 81 | // void terminal(); |
81 | void query_modem(); | 82 | void query_modem(); |
82 | void volumeChanged(int); | 83 | void volumeChanged(int); |
83 | 84 | ||
84 | private: | 85 | private: |
85 | QLabel *labeltmp; | 86 | QLabel *labeltmp; |
86 | QPushButton *modemcmds; | 87 | QPushButton *modemcmds; |
87 | QPushButton *modeminfo_button; | 88 | QPushButton *modeminfo_button; |
88 | // QPushButton *terminal_button; | 89 | // QPushButton *terminal_button; |
89 | // QFrame *fline; | 90 | // QFrame *fline; |
90 | QCheckBox *waitfordt; | 91 | QCheckBox *waitfordt; |
91 | QSpinBox *busywait; | 92 | QSpinBox *busywait; |
92 | QCheckBox *chkbox1; | 93 | QCheckBox *chkbox1; |
93 | QSlider *volume; | 94 | QSlider *volume; |
95 | InterfacePPP *_ifaceppp; | ||
94 | }; | 96 | }; |
95 | 97 | ||
96 | #endif | 98 | #endif |
97 | 99 | ||
98 | 100 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp new file mode 100644 index 0000000..a58858c --- a/dev/null +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -0,0 +1,24 @@ | |||
1 | #include "interfaceinformationppp.h" | ||
2 | |||
3 | |||
4 | #include <qpushbutton.h> | ||
5 | #include <qlabel.h> | ||
6 | //#include <qgroupbox.h> | ||
7 | #include <qmessagebox.h> | ||
8 | |||
9 | #ifdef QWS | ||
10 | #else | ||
11 | #define showMaximized show | ||
12 | #endif | ||
13 | |||
14 | /** | ||
15 | * Constructor for the InterfaceInformationImp class. This class pretty much | ||
16 | * just display's information about the interface that is passed to it. | ||
17 | */ | ||
18 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | ||
19 | :InterfaceInformationImp(parent, name, i, f) | ||
20 | { | ||
21 | } | ||
22 | |||
23 | |||
24 | |||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.h b/noncore/settings/networksettings/ppp/interfaceinformationppp.h new file mode 100644 index 0000000..8c6fc0b --- a/dev/null +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef INTERFACEINFORMATIONPPP_H | ||
2 | #define INTERFACEINFORMATIONPPP_H | ||
3 | |||
4 | #include "interfaceinformationimp.h" | ||
5 | //#include "interface.h" | ||
6 | |||
7 | class QWidget; | ||
8 | class Interface; | ||
9 | |||
10 | class InterfaceInformationPPP : public InterfaceInformationImp { | ||
11 | |||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | |||
16 | InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | ||
17 | ~InterfaceInformationPPP(){}; | ||
18 | |||
19 | |||
20 | }; | ||
21 | |||
22 | #endif | ||
23 | |||
24 | // addserviceimp.h | ||
25 | |||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp new file mode 100644 index 0000000..d9ee3ff --- a/dev/null +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -0,0 +1,48 @@ | |||
1 | #include "interfaceppp.h" | ||
2 | #include "modem.h" | ||
3 | #include "pppdata.h" | ||
4 | |||
5 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | ||
6 | : Interface(parent, name, status), | ||
7 | _modem(0), | ||
8 | _pppdata(0) | ||
9 | { | ||
10 | qDebug("InterfacePPP::InterfacePPP("); | ||
11 | } | ||
12 | |||
13 | PPPData* InterfacePPP::data() | ||
14 | { | ||
15 | if (!_pppdata){ | ||
16 | _pppdata = new PPPData(); | ||
17 | _pppdata->setModemDevice( getInterfaceName() ); | ||
18 | _pppdata->setAccount( getHardwareName() ); | ||
19 | } | ||
20 | return _pppdata; | ||
21 | } | ||
22 | |||
23 | Modem* InterfacePPP::modem() | ||
24 | { | ||
25 | if (!_modem){ | ||
26 | _modem = new Modem( data() ); | ||
27 | } | ||
28 | return _modem; | ||
29 | } | ||
30 | |||
31 | bool InterfacePPP::refresh() | ||
32 | { | ||
33 | qDebug("InterfacePPP::refresh()"); | ||
34 | return false; | ||
35 | } | ||
36 | |||
37 | void InterfacePPP::start() | ||
38 | { | ||
39 | qDebug("InterfacePPP::start"); | ||
40 | |||
41 | } | ||
42 | |||
43 | void InterfacePPP::stop() | ||
44 | { | ||
45 | qDebug("InterfacePPP::stop"); | ||
46 | |||
47 | } | ||
48 | |||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h new file mode 100644 index 0000000..b7477c9 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef INTERFACEPPP_H | ||
2 | #define INTERFACEPPP_H | ||
3 | |||
4 | #include "interface.h" | ||
5 | |||
6 | class PPPData; | ||
7 | class Modem; | ||
8 | |||
9 | class InterfacePPP : public Interface | ||
10 | { | ||
11 | Q_OBJECT | ||
12 | |||
13 | public: | ||
14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); | ||
15 | |||
16 | PPPData* data(); | ||
17 | Modem* modem(); | ||
18 | |||
19 | public slots: | ||
20 | virtual bool refresh(); | ||
21 | virtual void start(); | ||
22 | virtual void stop(); | ||
23 | |||
24 | private: | ||
25 | Modem *_modem; | ||
26 | PPPData *_pppdata; | ||
27 | }; | ||
28 | |||
29 | |||
30 | #endif | ||
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index f8a8dc3..289e9f5 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -1,879 +1,888 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> | 10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "kpppwidget.h" | 27 | #include "kpppwidget.h" |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qevent.h> | 32 | #include <qevent.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | #include <qcheckbox.h> | ||
40 | 41 | ||
41 | // #include <kaboutdata.h> | 42 | // #include <kaboutdata.h> |
42 | // #include <kapplication.h> | 43 | // #include <kapplication.h> |
43 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
44 | //#include <kcmdlineargs.h> | 45 | //#include <kcmdlineargs.h> |
45 | //#include <kconfig.h> | 46 | //#include <kconfig.h> |
46 | //#include <kdebug.h> | 47 | //#include <kdebug.h> |
47 | #define i18n QObject::tr | 48 | #define i18n QObject::tr |
48 | //#include <kiconloader.h> // For BarIcon | 49 | //#include <kiconloader.h> // For BarIcon |
49 | //#include <klocale.h> | 50 | //#include <klocale.h> |
50 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
51 | // #include <kseparator.h> | 52 | // #include <kseparator.h> |
52 | // #include <kstandarddirs.h> | 53 | // #include <kstandarddirs.h> |
53 | // #include <kwin.h> | 54 | // #include <kwin.h> |
54 | // #include <khelpmenu.h> | 55 | // #include <khelpmenu.h> |
55 | #include <qpushbutton.h> | 56 | #include <qpushbutton.h> |
56 | //#include <kguiitem.h> | 57 | //#include <kguiitem.h> |
57 | 58 | ||
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
59 | #include <errno.h> | 60 | #include <errno.h> |
60 | #include <signal.h> | 61 | #include <signal.h> |
61 | 62 | ||
62 | #include "runtests.h" | 63 | #include "runtests.h" |
63 | 64 | ||
64 | //#include "main.h" | 65 | //#include "main.h" |
65 | #include "auth.h" | 66 | #include "auth.h" |
66 | #include "modem.h" | 67 | #include "modem.h" |
67 | //#include "ppplog.h" | 68 | //#include "ppplog.h" |
68 | //#include "opener.h" | 69 | //#include "opener.h" |
69 | //#include "requester.h" | 70 | //#include "requester.h" |
70 | //#include "pppstats.h" | 71 | //#include "pppstats.h" |
71 | #include "pppdata.h" | 72 | #include "pppdata.h" |
72 | #include "general.h" | 73 | #include "general.h" |
74 | #include "interface.h" | ||
73 | 75 | ||
74 | #define execute_command system | 76 | #define execute_command system |
75 | 77 | ||
76 | KPPPWidget *p_kppp = 0; | 78 | KPPPWidget *p_kppp = 0; |
77 | 79 | ||
78 | KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl ) | 80 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) |
79 | : QDialog(parent, name, modal, fl) | 81 | : QDialog(parent, name, modal, fl), _pppdata(pd) |
80 | // , acct(0) | ||
81 | // , m_bCmdlAccount (false) | ||
82 | { | 82 | { |
83 | // tabWindow = 0; | 83 | // tabWindow = 0; |
84 | p_kppp = this; | 84 | p_kppp = this; |
85 | // before doing anything else, run a few tests | 85 | // before doing anything else, run a few tests |
86 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | ||
87 | _pppdata->setModemDevice("/dev/modem"); | ||
88 | qDebug("PPPConfigWidget::PPPConfigWidget"); | ||
89 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | ||
90 | if (!_pppdata->setAccount( i->getHardwareName() )) | ||
91 | _pppdata->setAccount( 0 ); | ||
92 | |||
93 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | ||
94 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); | ||
86 | 95 | ||
87 | int result = runTests(); | 96 | int result = runTests(); |
88 | if(result == TEST_CRITICAL) | 97 | if(result == TEST_CRITICAL) |
89 | exit(4); | 98 | exit(4); |
90 | 99 | ||
91 | // installEventFilter(this); | 100 | // installEventFilter(this); |
92 | 101 | ||
93 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 102 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
94 | 103 | ||
95 | // QGridLayout *l1 = new QGridLayout(3, 4); | 104 | QGridLayout *l1 = new QGridLayout(3, 4); |
96 | // tl->addLayout(l1); | 105 | tl->addLayout(l1); |
97 | // l1->addColSpacing(0, 10); | 106 | l1->addColSpacing(0, 10); |
98 | // l1->addColSpacing(3, 10); | 107 | l1->addColSpacing(3, 10); |
99 | // l1->setColStretch(1, 3); | 108 | l1->setColStretch(1, 3); |
100 | // l1->setColStretch(2, 4); | 109 | l1->setColStretch(2, 4); |
101 | 110 | ||
102 | // label1 = new QLabel(i18n("C&onnect to: "), this); | 111 | label1 = new QLabel(i18n("C&onnect to: "), this); |
103 | // l1->addWidget(label1, 0, 1); | 112 | l1->addWidget(label1, 0, 1); |
104 | 113 | ||
105 | // connectto_c = new QComboBox(false, this); | 114 | connectto_c = new QComboBox(false, this); |
106 | // label1->setBuddy(connectto_c); | 115 | label1->setBuddy(connectto_c); |
107 | 116 | ||
108 | // connect(connectto_c, SIGNAL(activated(int)), | 117 | connect(connectto_c, SIGNAL(activated(int)), |
109 | // SLOT(newdefaultaccount(int))); | 118 | SLOT(newdefaultaccount(int))); |
110 | // l1->addWidget(connectto_c, 0, 2); | 119 | l1->addWidget(connectto_c, 0, 2); |
111 | 120 | ||
112 | // ID_Label = new QLabel(i18n("&Login ID:"), this); | 121 | ID_Label = new QLabel(i18n("&Login ID:"), this); |
113 | // l1->addWidget(ID_Label, 1, 1); | 122 | l1->addWidget(ID_Label, 1, 1); |
114 | 123 | ||
115 | // // the entry line for usernames | 124 | // the entry line for usernames |
116 | // ID_Edit = new QLineEdit(this); | 125 | ID_Edit = new QLineEdit(this); |
117 | // ID_Label->setBuddy(ID_Edit); | 126 | ID_Label->setBuddy(ID_Edit); |
118 | // l1->addWidget(ID_Edit, 1, 2); | 127 | l1->addWidget(ID_Edit, 1, 2); |
119 | // connect(ID_Edit, SIGNAL(returnPressed()), | 128 | connect(ID_Edit, SIGNAL(returnPressed()), |
120 | // this, SLOT(enterPressedInID())); | 129 | this, SLOT(enterPressedInID())); |
121 | // QString tmp = i18n("<p>Type in the username that you got from your\n" | 130 | QString tmp = i18n("<p>Type in the username that you got from your\n" |
122 | // "ISP. This is especially important for PAP\n" | 131 | "ISP. This is especially important for PAP\n" |
123 | // "and CHAP. You may omit this when you use\n" | 132 | "and CHAP. You may omit this when you use\n" |
124 | // "terminal-based or script-based authentication.\n" | 133 | "terminal-based or script-based authentication.\n" |
125 | // "\n" | 134 | "\n" |
126 | // "<b>Important</b>: case is important here:\n" | 135 | "<b>Important</b>: case is important here:\n" |
127 | // "<i>myusername</i> is not the same as <i>MyUserName</i>!"); | 136 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); |
128 | 137 | ||
129 | // QWhatsThis::add(ID_Label,tmp); | 138 | QWhatsThis::add(ID_Label,tmp); |
130 | // QWhatsThis::add(ID_Edit,tmp); | 139 | QWhatsThis::add(ID_Edit,tmp); |
131 | 140 | ||
132 | // PW_Label = new QLabel(i18n("&Password:"), this); | 141 | PW_Label = new QLabel(i18n("&Password:"), this); |
133 | // l1->addWidget(PW_Label, 2, 1); | 142 | l1->addWidget(PW_Label, 2, 1); |
134 | 143 | ||
135 | // PW_Edit= new QLineEdit(this); | 144 | PW_Edit= new QLineEdit(this); |
136 | // PW_Label->setBuddy(PW_Edit); | 145 | PW_Label->setBuddy(PW_Edit); |
137 | // PW_Edit->setEchoMode(QLineEdit::Password); | 146 | PW_Edit->setEchoMode(QLineEdit::Password); |
138 | // l1->addWidget(PW_Edit, 2, 2); | 147 | l1->addWidget(PW_Edit, 2, 2); |
139 | // connect(PW_Edit, SIGNAL(returnPressed()), | 148 | connect(PW_Edit, SIGNAL(returnPressed()), |
140 | // this, SLOT(enterPressedInPW())); | 149 | this, SLOT(enterPressedInPW())); |
141 | 150 | ||
142 | // tmp = i18n("<p>Type in the password that you got from your\n" | 151 | tmp = i18n("<p>Type in the password that you got from your\n" |
143 | // "ISP. This is especially important for PAP\n" | 152 | "ISP. This is especially important for PAP\n" |
144 | // "and CHAP. You may omit this when you use\n" | 153 | "and CHAP. You may omit this when you use\n" |
145 | // "terminal-based or script-based authentication.\n" | 154 | "terminal-based or script-based authentication.\n" |
146 | // "\n" | 155 | "\n" |
147 | // "<b>Important</b>: case is important here:\n" | 156 | "<b>Important</b>: case is important here:\n" |
148 | // "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); | 157 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); |
149 | 158 | ||
150 | // QWhatsThis::add(PW_Label,tmp); | 159 | QWhatsThis::add(PW_Label,tmp); |
151 | // QWhatsThis::add(PW_Edit,tmp); | 160 | QWhatsThis::add(PW_Edit,tmp); |
152 | 161 | ||
153 | // QHBoxLayout *l3 = new QHBoxLayout; | 162 | QHBoxLayout *l3 = new QHBoxLayout; |
154 | // tl->addSpacing(5); | 163 | tl->addSpacing(5); |
155 | // tl->addLayout(l3); | 164 | tl->addLayout(l3); |
156 | // tl->addSpacing(5); | 165 | tl->addSpacing(5); |
157 | // l3->addSpacing(10); | 166 | l3->addSpacing(10); |
158 | // log = new QCheckBox(i18n("Show lo&g window"), this); | 167 | log = new QCheckBox(i18n("Show lo&g window"), this); |
159 | // connect(log, SIGNAL(toggled(bool)), | 168 | connect(log, SIGNAL(toggled(bool)), |
160 | // this, SLOT(log_window_toggled(bool))); | 169 | this, SLOT(log_window_toggled(bool))); |
161 | // log->setChecked(PPPData::data()->get_show_log_window()); | 170 | log->setChecked(_pppdata->get_show_log_window()); |
162 | // l3->addWidget(log); | 171 | l3->addWidget(log); |
163 | 172 | ||
164 | // QWhatsThis::add(log, | 173 | QWhatsThis::add(log, |
165 | // i18n("<p>This controls whether a log window is shown.\n" | 174 | i18n("<p>This controls whether a log window is shown.\n" |
166 | // "A log window shows the communication between\n" | 175 | "A log window shows the communication between\n" |
167 | // "<i>kppp</i> and your modem. This will help you\n" | 176 | "<i>kppp</i> and your modem. This will help you\n" |
168 | // "in tracking down problems.\n" | 177 | "in tracking down problems.\n" |
169 | // "\n" | 178 | "\n" |
170 | // "Turn it off if <i>kppp</i> routinely connects without\n" | 179 | "Turn it off if <i>kppp</i> routinely connects without\n" |
171 | // "problems")); | 180 | "problems")); |
172 | 181 | ||
173 | // // fline = new QSeparator( KSeparator::HLine, this); | 182 | // fline = new QSeparator( KSeparator::HLine, this); |
174 | // // tl->addWidget(fline); | 183 | // tl->addWidget(fline); |
175 | 184 | ||
176 | // QHBoxLayout *l2 = new QHBoxLayout(this); | 185 | QHBoxLayout *l2 = new QHBoxLayout(this); |
177 | // tl->addLayout(l2); | 186 | tl->addLayout(l2); |
178 | 187 | ||
179 | // int minw = 0; | 188 | int minw = 0; |
180 | // quit_b = new QPushButton(i18n("&Quit"), this); | 189 | quit_b = new QPushButton(i18n("&Quit"), this); |
181 | // // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); | 190 | // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); |
182 | // connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); | 191 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); |
183 | // if(quit_b->sizeHint().width() > minw) | 192 | if(quit_b->sizeHint().width() > minw) |
184 | // minw = quit_b->sizeHint().width(); | 193 | minw = quit_b->sizeHint().width(); |
185 | 194 | ||
186 | // setup_b = new QPushButton(i18n("&Setup..."), this); | 195 | setup_b = new QPushButton(i18n("&Setup..."), this); |
187 | // // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); | 196 | // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); |
188 | // connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); | 197 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); |
189 | // if(setup_b->sizeHint().width() > minw) | 198 | if(setup_b->sizeHint().width() > minw) |
190 | // minw = setup_b->sizeHint().width(); | 199 | minw = setup_b->sizeHint().width(); |
191 | 200 | ||
192 | 201 | ||
193 | 202 | ||
194 | // if(PPPData::data()->access() != KConfig::ReadWrite) | 203 | // if(_pppdata->access() != KConfig::ReadWrite) |
195 | // setup_b->setEnabled(false); | 204 | // setup_b->setEnabled(false); |
196 | 205 | ||
197 | // help_b = new QPushButton(i18n("&Help"), this); | 206 | // help_b = new QPushButton(i18n("&Help"), this); |
198 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); | 207 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); |
199 | 208 | ||
200 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); | 209 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); |
201 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); | 210 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); |
202 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); | 211 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); |
203 | 212 | ||
204 | // if(help_b->sizeHint().width() > minw) | 213 | // if(help_b->sizeHint().width() > minw) |
205 | // minw = help_b->sizeHint().width(); | 214 | // minw = help_b->sizeHint().width(); |
206 | 215 | ||
207 | // connect_b = new QPushButton(i18n("&Connect"), this); | 216 | connect_b = new QPushButton(i18n("&Connect"), this); |
208 | // connect_b->setDefault(true); | 217 | connect_b->setDefault(true); |
209 | // connect_b->setFocus(); | 218 | connect_b->setFocus(); |
210 | // connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); | 219 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); |
211 | // if(connect_b->sizeHint().width() > minw) | 220 | if(connect_b->sizeHint().width() > minw) |
212 | // minw = connect_b->sizeHint().width(); | 221 | minw = connect_b->sizeHint().width(); |
213 | 222 | ||
214 | // quit_b->setFixedWidth(minw); | 223 | quit_b->setFixedWidth(minw); |
215 | // setup_b->setFixedWidth(minw); | 224 | setup_b->setFixedWidth(minw); |
216 | // // help_b->setFixedWidth(help_b->sizeHint().width()); | 225 | // help_b->setFixedWidth(help_b->sizeHint().width()); |
217 | // connect_b->setFixedWidth(minw); | 226 | connect_b->setFixedWidth(minw); |
218 | 227 | ||
219 | // l2->addWidget(quit_b); | 228 | l2->addWidget(quit_b); |
220 | // l2->addWidget(setup_b); | 229 | l2->addWidget(setup_b); |
221 | // // l2->addWidget(help_b); | 230 | // l2->addWidget(help_b); |
222 | // l2->addSpacing(20); | 231 | l2->addSpacing(20); |
223 | // l2->addWidget(connect_b); | 232 | l2->addWidget(connect_b); |
224 | 233 | ||
225 | setFixedSize(sizeHint()); | 234 | setFixedSize(sizeHint()); |
226 | 235 | ||
227 | (void)new Modem; | 236 | (void)new Modem(_pppdata); |
228 | 237 | ||
229 | // we also connect cmld_start to the beginConnect so that I can run | 238 | // we also connect cmld_start to the beginConnect so that I can run |
230 | // the dialer through a command line argument | 239 | // the dialer through a command line argument |
231 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); | 240 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); |
232 | 241 | ||
233 | // stats = new PPPStats; | 242 | // stats = new PPPStats; |
234 | 243 | ||
235 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 244 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
236 | 245 | ||
237 | // constructor of con_win reads position from config file | 246 | // constructor of con_win reads position from config file |
238 | // con_win = new ConWindow(0, "conw", this); | 247 | con_win = new ConWindow(_pppdata, 0, "conw", this); |
239 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); | 248 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); |
240 | 249 | ||
241 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); | 250 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); |
242 | // statdlg->hide(); | 251 | // statdlg->hide(); |
243 | 252 | ||
244 | // load up the accounts combo box | 253 | // load up the accounts combo box |
245 | 254 | ||
246 | // resetaccounts(); | 255 | // resetaccounts(); |
247 | // con = new ConnectWidget(0, "con"); | 256 | con = new ConnectWidget(_pppdata, 0, "con"); |
248 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); | 257 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); |
249 | // connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); | 258 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); |
250 | // Is this the best we can do here? it's not right. | 259 | // Is this the best we can do here? it's not right. |
251 | // QRect desk = QApplication::desktop()->screenGeometry( | 260 | // QRect desk = QApplication::desktop()->screenGeometry( |
252 | // QApplication::desktop()->screenNumber(topLevelWidget())); | 261 | // QApplication::desktop()->screenNumber(topLevelWidget())); |
253 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); | 262 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); |
254 | 263 | ||
255 | // connect the ConnectWidgets various signals | 264 | // connect the ConnectWidgets various signals |
256 | // // connect(con, SIGNAL(startAccounting()), | 265 | connect(con, SIGNAL(startAccounting()), |
257 | // // this, SLOT(startAccounting())); | 266 | this, SLOT(startAccounting())); |
258 | // // connect(con, SIGNAL(stopAccounting()), | 267 | connect(con, SIGNAL(stopAccounting()), |
259 | // // this, SLOT(stopAccounting())); | 268 | this, SLOT(stopAccounting())); |
260 | // connect(qApp, SIGNAL(saveYourself()), | 269 | connect(qApp, SIGNAL(saveYourself()), |
261 | // this, SLOT(saveMyself())); | 270 | this, SLOT(saveMyself())); |
262 | // connect(qApp, SIGNAL(shutDown()), | 271 | connect(qApp, SIGNAL(shutDown()), |
263 | // this, SLOT(shutDown())); | 272 | this, SLOT(shutDown())); |
264 | 273 | ||
265 | 274 | ||
266 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 275 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
267 | 276 | ||
268 | // m_strCmdlAccount = args->getOption("c"); | 277 | // m_strCmdlAccount = args->getOption("c"); |
269 | // m_bQuitOnDisconnect = args->isSet("q"); | 278 | // m_bQuitOnDisconnect = args->isSet("q"); |
270 | 279 | ||
271 | // if(!m_strCmdlAccount.isEmpty()) { | 280 | // if(!m_strCmdlAccount.isEmpty()) { |
272 | // m_bCmdlAccount = true; | 281 | // m_bCmdlAccount = true; |
273 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; | 282 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; |
274 | // } | 283 | // } |
275 | 284 | ||
276 | // if(m_bCmdlAccount){ | 285 | // if(m_bCmdlAccount){ |
277 | // bool result = PPPData::data()->setAccount(m_strCmdlAccount); | 286 | // bool result = _pppdata->setAccount(m_strCmdlAccount); |
278 | // if (!result){ | 287 | // if (!result){ |
279 | // QString string; | 288 | // QString string; |
280 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); | 289 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); |
281 | // KMessageBox::error(this, string); | 290 | // KMessageBox::error(this, string); |
282 | // m_bCmdlAccount = false; | 291 | // m_bCmdlAccount = false; |
283 | // this->show(); | 292 | // this->show(); |
284 | // } else { | 293 | // } else { |
285 | // beginConnect(); | 294 | // beginConnect(); |
286 | // } | 295 | // } |
287 | // } else | 296 | // } else |
288 | // expandbutton(); | 297 | // expandbutton(); |
289 | // show(); | 298 | // show(); |
290 | 299 | ||
291 | 300 | ||
292 | //#define KPPP_SHOW_NEWS | 301 | //#define KPPP_SHOW_NEWS |
293 | #ifdef KPPP_SHOW_NEWS | 302 | #ifdef KPPP_SHOW_NEWS |
294 | // keep user informed about recent changes | 303 | // keep user informed about recent changes |
295 | if(!m_bCmdlAccount) | 304 | if(!m_bCmdlAccount) |
296 | showNews(); | 305 | showNews(); |
297 | #endif | 306 | #endif |
298 | } | 307 | } |
299 | 308 | ||
300 | KPPPWidget::~KPPPWidget() | 309 | KPPPWidget::~KPPPWidget() |
301 | { | 310 | { |
302 | p_kppp = 0; | 311 | p_kppp = 0; |
303 | // delete stats; | 312 | // delete stats; |
304 | } | 313 | } |
305 | 314 | ||
306 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 315 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
307 | // if(e->type() == QEvent::User) { | 316 | // if(e->type() == QEvent::User) { |
308 | // switch(((SignalEvent*)e)->sigType()) { | 317 | // switch(((SignalEvent*)e)->sigType()) { |
309 | // case SIGINT: | 318 | // case SIGINT: |
310 | // qDebug( "Received a SIGINT" ); | 319 | // qDebug( "Received a SIGINT" ); |
311 | // interruptConnection(); | 320 | // interruptConnection(); |
312 | // break; | 321 | // break; |
313 | // case SIGCHLD: | 322 | // case SIGCHLD: |
314 | // sigChld(); | 323 | // sigChld(); |
315 | // break; | 324 | // break; |
316 | // case SIGUSR1: | 325 | // case SIGUSR1: |
317 | // sigPPPDDied(); | 326 | // sigPPPDDied(); |
318 | // break; | 327 | // break; |
319 | // } | 328 | // } |
320 | // return true; | 329 | // return true; |
321 | // } | 330 | // } |
322 | 331 | ||
323 | // if(o == connect_b) { | 332 | // if(o == connect_b) { |
324 | // if(e->type() == QEvent::KeyPress) { | 333 | // if(e->type() == QEvent::KeyPress) { |
325 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 334 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
326 | // beginConnect(); | 335 | // beginConnect(); |
327 | // return true; | 336 | // return true; |
328 | // } | 337 | // } |
329 | // } | 338 | // } |
330 | // } | 339 | // } |
331 | 340 | ||
332 | // return false; | 341 | // return false; |
333 | // } | 342 | // } |
334 | 343 | ||
335 | 344 | ||
336 | 345 | ||
337 | 346 | ||
338 | void KPPPWidget::enterPressedInID() { | 347 | void KPPPWidget::enterPressedInID() { |
339 | PW_Edit->setFocus(); | 348 | PW_Edit->setFocus(); |
340 | } | 349 | } |
341 | 350 | ||
342 | 351 | ||
343 | void KPPPWidget::enterPressedInPW() { | 352 | void KPPPWidget::enterPressedInPW() { |
344 | connect_b->setFocus(); | 353 | connect_b->setFocus(); |
345 | } | 354 | } |
346 | 355 | ||
347 | // triggered by the session manager | 356 | // triggered by the session manager |
348 | void KPPPWidget::saveMyself() { | 357 | void KPPPWidget::saveMyself() { |
349 | PPPData::data()->save(); | 358 | _pppdata->save(); |
350 | } | 359 | } |
351 | 360 | ||
352 | void KPPPWidget::shutDown() { | 361 | void KPPPWidget::shutDown() { |
353 | interruptConnection(); | 362 | interruptConnection(); |
354 | saveMyself(); | 363 | saveMyself(); |
355 | } | 364 | } |
356 | 365 | ||
357 | void KPPPWidget::log_window_toggled(bool on) { | 366 | void KPPPWidget::log_window_toggled(bool on) { |
358 | PPPData::data()->set_show_log_window(on); | 367 | _pppdata->set_show_log_window(on); |
359 | } | 368 | } |
360 | 369 | ||
361 | 370 | ||
362 | 371 | ||
363 | 372 | ||
364 | // void KPPPWidget::resetaccounts() { | 373 | // void KPPPWidget::resetaccounts() { |
365 | // connectto_c->clear(); | 374 | // connectto_c->clear(); |
366 | 375 | ||
367 | // int count = PPPData::data()->count(); | 376 | // int count = _pppdata->count(); |
368 | 377 | ||
369 | // // enable/disable controls | 378 | // // enable/disable controls |
370 | // connectto_c->setEnabled(count > 0); | 379 | // connectto_c->setEnabled(count > 0); |
371 | // connect_b->setEnabled(count > 0); | 380 | // connect_b->setEnabled(count > 0); |
372 | // log->setEnabled(count > 0); | 381 | // log->setEnabled(count > 0); |
373 | // ID_Edit->setEnabled(count > 0); | 382 | // ID_Edit->setEnabled(count > 0); |
374 | // PW_Edit->setEnabled(count > 0); | 383 | // PW_Edit->setEnabled(count > 0); |
375 | 384 | ||
376 | // //load the accounts | 385 | // //load the accounts |
377 | // for(int i=0; i < count; i++) { | 386 | // for(int i=0; i < count; i++) { |
378 | // PPPData::data()->setAccountbyIndex(i); | 387 | // _pppdata->setAccountbyIndex(i); |
379 | // connectto_c->insertItem(PPPData::data()->accname()); | 388 | // connectto_c->insertItem(_pppdata->accname()); |
380 | // } | 389 | // } |
381 | 390 | ||
382 | // //set the default account | 391 | // //set the default account |
383 | // if(!PPPData::data()->defaultAccount().isEmpty()) { | 392 | // if(!_pppdata->defaultAccount().isEmpty()) { |
384 | // for(int i=0; i < count; i++) | 393 | // for(int i=0; i < count; i++) |
385 | // if(PPPData::data()->defaultAccount() == connectto_c->text(i)) { | 394 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { |
386 | // connectto_c->setCurrentItem(i); | 395 | // connectto_c->setCurrentItem(i); |
387 | // PPPData::data()->setAccountbyIndex(i); | 396 | // _pppdata->setAccountbyIndex(i); |
388 | 397 | ||
389 | // ID_Edit->setText(PPPData::data()->storedUsername()); | 398 | // ID_Edit->setText(_pppdata->storedUsername()); |
390 | // PW_Edit->setText(PPPData::data()->storedPassword()); | 399 | // PW_Edit->setText(_pppdata->storedPassword()); |
391 | // } | 400 | // } |
392 | // } | 401 | // } |
393 | // else | 402 | // else |
394 | // if(count > 0) { | 403 | // if(count > 0) { |
395 | // PPPData::data()->setDefaultAccount(connectto_c->text(0)); | 404 | // _pppdata->setDefaultAccount(connectto_c->text(0)); |
396 | // PPPData::data()->save(); | 405 | // _pppdata->save(); |
397 | // ID_Edit->setText(PPPData::data()->storedUsername()); | 406 | // ID_Edit->setText(_pppdata->storedUsername()); |
398 | // PW_Edit->setText(PPPData::data()->storedPassword()); | 407 | // PW_Edit->setText(_pppdata->storedPassword()); |
399 | // } | 408 | // } |
400 | 409 | ||
401 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), | 410 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), |
402 | // this, SLOT(usernameChanged(const QString &))); | 411 | // this, SLOT(usernameChanged(const QString &))); |
403 | 412 | ||
404 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), | 413 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), |
405 | // this, SLOT(passwordChanged(const QString &))); | 414 | // this, SLOT(passwordChanged(const QString &))); |
406 | 415 | ||
407 | // if (ID_Edit->text().isEmpty()) | 416 | // if (ID_Edit->text().isEmpty()) |
408 | // ID_Edit->setFocus(); | 417 | // ID_Edit->setFocus(); |
409 | // else if (PW_Edit->text().isEmpty()) | 418 | // else if (PW_Edit->text().isEmpty()) |
410 | // PW_Edit->setFocus(); | 419 | // PW_Edit->setFocus(); |
411 | // } | 420 | // } |
412 | 421 | ||
413 | 422 | ||
414 | void KPPPWidget::interruptConnection() { | 423 | void KPPPWidget::interruptConnection() { |
415 | // interrupt dial up | 424 | // interrupt dial up |
416 | // if (con->isVisible()) | 425 | // |
417 | // emit con->cancelbutton(); | 426 | |
427 | if (con->isVisible()) | ||
428 | emit con->cancelbutton(); | ||
418 | 429 | ||
419 | // disconnect if online | 430 | // disconnect if online |
420 | if (PPPData::data()->pppdRunning()) | 431 | if (_pppdata->pppdRunning()) |
421 | emit disconnect(); | 432 | emit disconnect(); |
422 | } | 433 | } |
423 | 434 | ||
424 | 435 | ||
425 | void KPPPWidget::sigPPPDDied() { | 436 | void KPPPWidget::sigPPPDDied() { |
426 | qDebug( "Received a SIGUSR1" ); | 437 | qDebug( "Received a SIGUSR1" ); |
427 | 438 | ||
428 | // if we are not connected pppdpid is -1 so have have to check for that | 439 | // if we are not connected pppdpid is -1 so have have to check for that |
429 | // in the followin line to make sure that we don't raise a false alarm | 440 | // in the followin line to make sure that we don't raise a false alarm |
430 | // such as would be the case when the log file viewer exits. | 441 | // such as would be the case when the log file viewer exits. |
431 | if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) { | 442 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
432 | qDebug( "It was pppd that died" ); | 443 | qDebug( "It was pppd that died" ); |
433 | 444 | ||
434 | // when we killpppd() on Cancel in ConnectWidget | 445 | // when we killpppd() on Cancel in ConnectWidget |
435 | // we set pppid to -1 so we won't | 446 | // we set pppid to -1 so we won't |
436 | // enter this block | 447 | // enter this block |
437 | 448 | ||
438 | // just to be sure | 449 | // just to be sure |
439 | 450 | ||
440 | Modem::modem->removeSecret(AUTH_PAP); | 451 | Modem::modem->removeSecret(AUTH_PAP); |
441 | Modem::modem->removeSecret(AUTH_CHAP); | 452 | Modem::modem->removeSecret(AUTH_CHAP); |
442 | 453 | ||
443 | PPPData::data()->setpppdRunning(false); | 454 | _pppdata->setpppdRunning(false); |
444 | 455 | ||
445 | qDebug( "Executing command on disconnect since pppd has died." ); | 456 | qDebug( "Executing command on disconnect since pppd has died." ); |
446 | QApplication::flushX(); | 457 | QApplication::flushX(); |
447 | execute_command(PPPData::data()->command_on_disconnect()); | 458 | execute_command(_pppdata->command_on_disconnect()); |
448 | 459 | ||
449 | // stopAccounting(); | 460 | // stopAccounting(); |
450 | 461 | ||
451 | // con_win->stopClock(); | 462 | con_win->stopClock(); |
452 | // DockWidget::dock_widget->stop_stats(); | 463 | // DockWidget::dock_widget->stop_stats(); |
453 | // DockWidget::dock_widget->hide(); | 464 | // DockWidget::dock_widget->hide(); |
454 | 465 | ||
455 | if(!PPPData::data()->pppdError()) | 466 | if(!_pppdata->pppdError()) |
456 | PPPData::data()->setpppdError(E_PPPD_DIED); | 467 | _pppdata->setpppdError(E_PPPD_DIED); |
457 | removedns(); | 468 | removedns(); |
458 | Modem::modem->unlockdevice(); | 469 | Modem::modem->unlockdevice(); |
459 | // con->pppdDied(); | 470 | // |
471 | con->pppdDied(); | ||
460 | 472 | ||
461 | if(!PPPData::data()->automatic_redial()) { | 473 | if(!_pppdata->automatic_redial()) { |
462 | quit_b->setFocus(); | 474 | quit_b->setFocus(); |
463 | show(); | 475 | show(); |
464 | // con_win->stopClock(); | 476 | con_win->stopClock(); |
465 | //stopAccounting(); | 477 | //stopAccounting(); |
466 | // con_win->hide(); | 478 | con_win->hide(); |
467 | // con->hide(); | 479 | con->hide(); |
468 | 480 | ||
469 | PPPData::data()->setpppdRunning(false); | 481 | _pppdata->setpppdRunning(false); |
470 | // // not in a signal handler !!! KNotifyClient::beep(); | 482 | // // not in a signal handler !!! KNotifyClient::beep(); |
471 | QString msg; | 483 | QString msg; |
472 | if (PPPData::data()->pppdError() == E_IF_TIMEOUT) | 484 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
473 | msg = i18n("Timeout expired while waiting for the PPP interface " | 485 | msg = i18n("Timeout expired while waiting for the PPP interface " |
474 | "to come up!"); | 486 | "to come up!"); |
475 | else { | 487 | else { |
476 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); | 488 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); |
477 | Modem::modem->pppdExitStatus(); | 489 | Modem::modem->pppdExitStatus(); |
478 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 490 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
479 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 491 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
480 | msg += i18n("</p><p>See 'man pppd' for an explanation of the error " | 492 | msg += i18n("</p><p>See 'man pppd' for an explanation of the error " |
481 | "codes or take a look at the kppp FAQ on " | 493 | "codes or take a look at the kppp FAQ on " |
482 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 494 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
483 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 495 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
484 | } | 496 | } |
485 | } | 497 | } |
486 | 498 | ||
487 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) | 499 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) |
488 | // // PPPL_ShowLog(); | 500 | // // PPPL_ShowLog(); |
489 | // } else { /* reconnect on disconnect */ | 501 | // } else { /* reconnect on disconnect */ |
490 | if (false){ | 502 | if (false){ |
491 | qDebug( "Trying to reconnect... " ); | 503 | qDebug( "Trying to reconnect... " ); |
492 | 504 | ||
493 | if(PPPData::data()->authMethod() == AUTH_PAP || | 505 | if(_pppdata->authMethod() == AUTH_PAP || |
494 | PPPData::data()->authMethod() == AUTH_CHAP || | 506 | _pppdata->authMethod() == AUTH_CHAP || |
495 | PPPData::data()->authMethod() == AUTH_PAPCHAP) | 507 | _pppdata->authMethod() == AUTH_PAPCHAP) |
496 | Modem::modem->setSecret(PPPData::data()->authMethod(), | 508 | Modem::modem->setSecret(_pppdata->authMethod(), |
497 | encodeWord(PPPData::data()->storedUsername()), | 509 | encodeWord(_pppdata->storedUsername()), |
498 | encodeWord(PPPData::data()->password())); | 510 | encodeWord(_pppdata->password())); |
499 | 511 | ||
500 | // con_win->hide(); | 512 | con_win->hide(); |
501 | // con_win->stopClock(); | 513 | con_win->stopClock(); |
502 | //stopAccounting(); | 514 | //stopAccounting(); |
503 | PPPData::data()->setpppdRunning(false); | 515 | _pppdata->setpppdRunning(false); |
504 | // not in a signal handler !!!KNotifyClient::beep(); | 516 | // not in a signal handler !!!KNotifyClient::beep(); |
505 | emit cmdl_start(); | 517 | emit cmdl_start(); |
506 | } | 518 | } |
507 | } | 519 | } |
508 | PPPData::data()->setpppdError(0); | 520 | _pppdata->setpppdError(0); |
509 | } | 521 | } |
510 | } | 522 | } |
511 | 523 | ||
512 | // void KPPPWidget::sigChld() { | 524 | // void KPPPWidget::sigChld() { |
513 | // qDebug( "sigchld()" ); | 525 | // qDebug( "sigchld()" ); |
514 | // // pid_t id = wait(0L); | 526 | // // pid_t id = wait(0L); |
515 | // // if(id == helperPid && helperPid != -1) { | 527 | // // if(id == helperPid && helperPid != -1) { |
516 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 528 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
517 | // // helperPid = -1; | 529 | // // helperPid = -1; |
518 | // QString msg = i18n("kppp's helper process just died.\n" | 530 | // QString msg = i18n("kppp's helper process just died.\n" |
519 | // "Since a further execution would be pointless, " | 531 | // "Since a further execution would be pointless, " |
520 | // "kppp will shut down now."); | 532 | // "kppp will shut down now."); |
521 | // QMessageBox::warning(0L,"error", msg); | 533 | // QMessageBox::warning(0L,"error", msg); |
522 | // //remove_pidfile(); | 534 | // //remove_pidfile(); |
523 | // exit(1); | 535 | // exit(1); |
524 | // // } | 536 | // // } |
525 | // } | 537 | // } |
526 | 538 | ||
527 | 539 | ||
528 | void KPPPWidget::newdefaultaccount(int i) { | 540 | void KPPPWidget::newdefaultaccount(int i) { |
529 | PPPData::data()->setDefaultAccount(connectto_c->text(i)); | 541 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
530 | PPPData::data()->save(); | 542 | _pppdata->save(); |
531 | ID_Edit->setText(PPPData::data()->storedUsername()); | 543 | ID_Edit->setText(_pppdata->storedUsername()); |
532 | PW_Edit->setText(PPPData::data()->storedPassword()); | 544 | PW_Edit->setText(_pppdata->storedPassword()); |
533 | } | 545 | } |
534 | 546 | ||
535 | 547 | ||
536 | 548 | ||
537 | 549 | ||
538 | void KPPPWidget::beginConnect() { | 550 | void KPPPWidget::beginConnect() { |
539 | // make sure to connect to the account that is selected in the combo box | 551 | // make sure to connect to the account that is selected in the combo box |
540 | // (exeption: an account given by a command line argument) | 552 | // (exeption: an account given by a command line argument) |
541 | // if(!m_bCmdlAccount) { | 553 | // if(!m_bCmdlAccount) { |
542 | // PPPData::data()->setAccount(connectto_c->currentText()); | 554 | // _pppdata->setAccount(connectto_c->currentText()); |
543 | // PPPData::data()->setPassword(PW_Edit->text()); | 555 | // _pppdata->setPassword(PW_Edit->text()); |
544 | // } else { | 556 | // } else { |
545 | PPPData::data()->setPassword(PPPData::data()->storedPassword()); | 557 | _pppdata->setPassword(_pppdata->storedPassword()); |
546 | // } | 558 | // } |
547 | 559 | ||
548 | QFileInfo info(pppdPath()); | 560 | QFileInfo info(pppdPath()); |
549 | 561 | ||
550 | if(!info.exists()){ | 562 | if(!info.exists()){ |
551 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" | 563 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" |
552 | "Make sure that pppd is installed and " | 564 | "Make sure that pppd is installed and " |
553 | "that you have entered the correct path.")); | 565 | "that you have entered the correct path.")); |
554 | return; | 566 | return; |
555 | } | 567 | } |
556 | #if 0 | 568 | #if 0 |
557 | if(!info.isExecutable()){ | 569 | if(!info.isExecutable()){ |
558 | 570 | ||
559 | QString string; | 571 | QString string; |
560 | string = i18n("kppp cannot execute:\n %1\n" | 572 | string = i18n("kppp cannot execute:\n %1\n" |
561 | "Please make sure that you have given kppp " | 573 | "Please make sure that you have given kppp " |
562 | "setuid permission and that " | 574 | "setuid permission and that " |
563 | "pppd is executable.").arg(PPPData::data()->pppdPath()); | 575 | "pppd is executable.").arg(_pppdata->pppdPath()); |
564 | KMessageBox::error(this, string); | 576 | KMessageBox::error(this, string); |
565 | return; | 577 | return; |
566 | 578 | ||
567 | } | 579 | } |
568 | #endif | 580 | #endif |
569 | 581 | ||
570 | QFileInfo info2(PPPData::data()->modemDevice()); | 582 | QFileInfo info2(_pppdata->modemDevice()); |
571 | 583 | ||
572 | if(!info2.exists()){ | 584 | if(!info2.exists()){ |
573 | QString string; | 585 | QString string; |
574 | string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " | 586 | string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " |
575 | "your modem device properly " | 587 | "your modem device properly " |
576 | "and/or adjust the location of the modem device on " | 588 | "and/or adjust the location of the modem device on " |
577 | "the modem tab of " | 589 | "the modem tab of " |
578 | "the setup dialog.").arg(PPPData::data()->modemDevice()); | 590 | "the setup dialog.").arg(_pppdata->modemDevice()); |
579 | QMessageBox::warning(this, "error", string); | 591 | QMessageBox::warning(this, "error", string); |
580 | return; | 592 | return; |
581 | } | 593 | } |
582 | 594 | ||
583 | // if this is a PAP or CHAP account, ensure that username is | 595 | // if this is a PAP or CHAP account, ensure that username is |
584 | // supplied | 596 | // supplied |
585 | if(PPPData::data()->authMethod() == AUTH_PAP || | 597 | if(_pppdata->authMethod() == AUTH_PAP || |
586 | PPPData::data()->authMethod() == AUTH_CHAP || | 598 | _pppdata->authMethod() == AUTH_CHAP || |
587 | PPPData::data()->authMethod() == AUTH_PAPCHAP ) { | 599 | _pppdata->authMethod() == AUTH_PAPCHAP ) { |
588 | if(ID_Edit->text().isEmpty()) { | 600 | if(ID_Edit->text().isEmpty()) { |
589 | QMessageBox::warning(this,"error", | 601 | QMessageBox::warning(this,"error", |
590 | i18n( | 602 | i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); |
591 | "You have selected the authentication " | 603 | // FIXME: return; |
592 | "method PAP or CHAP. This requires that you " | ||
593 | "supply a username and a password!")); | ||
594 | return; | ||
595 | } else { | 604 | } else { |
596 | if(!Modem::modem->setSecret(PPPData::data()->authMethod(), | 605 | if(!Modem::modem->setSecret(_pppdata->authMethod(), |
597 | encodeWord(PPPData::data()->storedUsername()), | 606 | encodeWord(_pppdata->storedUsername()), |
598 | encodeWord(PPPData::data()->password()))) { | 607 | encodeWord(_pppdata->password()))) { |
599 | QString s; | 608 | QString s; |
600 | s = i18n("Cannot create PAP/CHAP authentication\n" | 609 | s = i18n("Cannot create PAP/CHAP authentication\n" |
601 | "file \"%1\"").arg(PAP_AUTH_FILE); | 610 | "file \"%1\"").arg(PAP_AUTH_FILE); |
602 | QMessageBox::warning(this, "error", s); | 611 | QMessageBox::warning(this, "error", s); |
603 | return; | 612 | return; |
604 | } | 613 | } |
605 | } | 614 | } |
606 | } | 615 | } |
607 | 616 | ||
608 | if (PPPData::data()->phonenumber().isEmpty()) { | 617 | if (_pppdata->phonenumber().isEmpty()) { |
609 | QString s = i18n("You must specify a telephone number!"); | 618 | QString s = i18n("You must specify a telephone number!"); |
610 | QMessageBox::warning(this, "error", s); | 619 | QMessageBox::warning(this, "error", s); |
611 | return; | 620 | return; |
612 | } | 621 | } |
613 | 622 | ||
614 | this->hide(); | 623 | this->hide(); |
615 | 624 | ||
616 | QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); | 625 | QString tit = i18n("Connecting to: %1").arg(_pppdata->accname()); |
617 | // con->setCaption(tit); | 626 | // con->setCaption(tit); |
618 | 627 | ||
619 | // con->show(); | 628 | // con->show(); |
620 | 629 | ||
621 | 630 | ||
622 | emit begin_connect(); | 631 | emit begin_connect(); |
623 | } | 632 | } |
624 | 633 | ||
625 | 634 | ||
626 | void KPPPWidget::disconnect() { | 635 | void KPPPWidget::disconnect() { |
627 | if (!PPPData::data()->command_before_disconnect().isEmpty()) { | 636 | if (!_pppdata->command_before_disconnect().isEmpty()) { |
628 | // con_win->hide(); | 637 | con_win->hide(); |
629 | // con->show(); | 638 | con->show(); |
630 | // con->setCaption(i18n("Disconnecting...")); | 639 | con->setCaption(i18n("Disconnecting...")); |
631 | // con->setMsg(i18n("Executing command before disconnection.")); | 640 | con->setMsg(i18n("Executing command before disconnection.")); |
632 | 641 | ||
633 | qApp->processEvents(); | 642 | qApp->processEvents(); |
634 | QApplication::flushX(); | 643 | QApplication::flushX(); |
635 | // pid_t id = | 644 | // pid_t id = |
636 | execute_command(PPPData::data()->command_before_disconnect()); | 645 | execute_command(_pppdata->command_before_disconnect()); |
637 | // int i, status; | 646 | // int i, status; |
638 | 647 | ||
639 | // do { | 648 | // do { |
640 | // kapp->processEvents(); | 649 | // kapp->processEvents(); |
641 | // i = waitpid(id, &status, WNOHANG); | 650 | // i = waitpid(id, &status, WNOHANG); |
642 | // usleep(500000); | 651 | // usleep(500000); |
643 | // } while (i == 0 && errno == 0); | 652 | // } while (i == 0 && errno == 0); |
644 | 653 | ||
645 | // con->hide(); | 654 | con->hide(); |
646 | } | 655 | } |
647 | 656 | ||
648 | qApp->processEvents(); | 657 | qApp->processEvents(); |
649 | 658 | ||
650 | // statdlg->stop_stats(); | 659 | // statdlg->stop_stats(); |
651 | Modem::modem->killPPPDaemon(); | 660 | Modem::modem->killPPPDaemon(); |
652 | 661 | ||
653 | QApplication::flushX(); | 662 | QApplication::flushX(); |
654 | execute_command(PPPData::data()->command_on_disconnect()); | 663 | execute_command(_pppdata->command_on_disconnect()); |
655 | 664 | ||
656 | Modem::modem->removeSecret(AUTH_PAP); | 665 | Modem::modem->removeSecret(AUTH_PAP); |
657 | Modem::modem->removeSecret(AUTH_CHAP); | 666 | Modem::modem->removeSecret(AUTH_CHAP); |
658 | 667 | ||
659 | removedns(); | 668 | removedns(); |
660 | Modem::modem->unlockdevice(); | 669 | Modem::modem->unlockdevice(); |
661 | 670 | ||
662 | // con_win->stopClock(); | 671 | con_win->stopClock(); |
663 | // p_kppp->stopAccounting(); | 672 | // p_kppp->stopAccounting(); |
664 | // con_win->hide(); | 673 | con_win->hide(); |
665 | 674 | ||
666 | // DockWidget::dock_widget->stop_stats(); | 675 | // DockWidget::dock_widget->stop_stats(); |
667 | // DockWidget::dock_widget->hide(); | 676 | // DockWidget::dock_widget->hide(); |
668 | 677 | ||
669 | // if(m_bQuitOnDisconnect) | 678 | // if(m_bQuitOnDisconnect) |
670 | // kapp->exit(0); | 679 | // kapp->exit(0); |
671 | // else { | 680 | // else { |
672 | this->quit_b->setFocus(); | 681 | this->quit_b->setFocus(); |
673 | this->show(); | 682 | this->show(); |
674 | // } | 683 | // } |
675 | } | 684 | } |
676 | 685 | ||
677 | 686 | ||
678 | // void KPPPWidget::helpbutton() { | 687 | // void KPPPWidget::helpbutton() { |
679 | // kapp->invokeHelp(); | 688 | // kapp->invokeHelp(); |
680 | // } | 689 | // } |
681 | 690 | ||
682 | 691 | ||
683 | void KPPPWidget::quitbutton() { | 692 | void KPPPWidget::quitbutton() { |
684 | if(PPPData::data()->pppdRunning()) { | 693 | if(_pppdata->pppdRunning()) { |
685 | int ok = QMessageBox::warning(this, | 694 | int ok = QMessageBox::warning(this, |
686 | i18n("Exiting kPPP will close your PPP Session."), | 695 | i18n("Exiting kPPP will close your PPP Session."), |
687 | i18n("Quit kPPP?")); | 696 | i18n("Quit kPPP?")); |
688 | if(ok == QMessageBox::Yes) { | 697 | if(ok == QMessageBox::Yes) { |
689 | Modem::modem->killPPPDaemon(); | 698 | Modem::modem->killPPPDaemon(); |
690 | QApplication::flushX(); | 699 | QApplication::flushX(); |
691 | execute_command(PPPData::data()->command_on_disconnect()); | 700 | execute_command(_pppdata->command_on_disconnect()); |
692 | removedns(); | 701 | removedns(); |
693 | Modem::modem->unlockdevice(); | 702 | Modem::modem->unlockdevice(); |
694 | } | 703 | } |
695 | } else { | 704 | } else { |
696 | if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword()) | 705 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
697 | PPPData::data()->setStoredPassword(""); | 706 | _pppdata->setStoredPassword(""); |
698 | } | 707 | } |
699 | PPPData::data()->save(); | 708 | _pppdata->save(); |
700 | qApp->quit(); | 709 | qApp->quit(); |
701 | } | 710 | } |
702 | 711 | ||
703 | 712 | ||
704 | // void KPPPWidget::rulesetLoadError() { | 713 | // void KPPPWidget::rulesetLoadError() { |
705 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); | 714 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); |
706 | // } | 715 | // } |
707 | 716 | ||
708 | 717 | ||
709 | // void KPPPWidget::startAccounting() { | 718 | // void KPPPWidget::startAccounting() { |
710 | // // volume accounting | 719 | // // volume accounting |
711 | // stats->totalbytes = 0; | 720 | // stats->totalbytes = 0; |
712 | 721 | ||
713 | // kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl; | 722 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; |
714 | 723 | ||
715 | // // load the ruleset | 724 | // // load the ruleset |
716 | // if(!PPPData::data()->AcctEnabled()) | 725 | // if(!_pppdata->AcctEnabled()) |
717 | // return; | 726 | // return; |
718 | 727 | ||
719 | // QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile()); | 728 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
720 | // // if(::access(d.data(), X_OK) != 0) | 729 | // // if(::access(d.data(), X_OK) != 0) |
721 | // acct = new Accounting(this, stats); | 730 | // acct = new Accounting(this, stats); |
722 | // // else | 731 | // // else |
723 | // // acct = new ExecutableAccounting(this); | 732 | // // acct = new ExecutableAccounting(this); |
724 | 733 | ||
725 | // // connect to the accounting object | 734 | // // connect to the accounting object |
726 | // connect(acct, SIGNAL(changed(QString, QString)), | 735 | // connect(acct, SIGNAL(changed(QString, QString)), |
727 | // con_win, SLOT(slotAccounting(QString, QString))); | 736 | // con_win, SLOT(slotAccounting(QString, QString))); |
728 | 737 | ||
729 | // // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) { | 738 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
730 | // // QString s= i18n("Can not load the accounting " | 739 | // // QString s= i18n("Can not load the accounting " |
731 | // // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile()); | 740 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
732 | 741 | ||
733 | // // starting the messagebox with a timer will prevent us | 742 | // // starting the messagebox with a timer will prevent us |
734 | // // from blocking the calling function ConnectWidget::timerEvent | 743 | // // from blocking the calling function ConnectWidget::timerEvent |
735 | // ruleset_load_errmsg = s; | 744 | // ruleset_load_errmsg = s; |
736 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 745 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
737 | // return; | 746 | // return; |
738 | // } | 747 | // } |
739 | // //else | 748 | // //else |
740 | // // acct->slotStart(); | 749 | // // acct->slotStart(); |
741 | // } | 750 | // } |
742 | 751 | ||
743 | // void KPPPWidget::stopAccounting() { | 752 | // void KPPPWidget::stopAccounting() { |
744 | // // store volume accounting | 753 | // // store volume accounting |
745 | // // if(stats->totalbytes != 0) | 754 | // // if(stats->totalbytes != 0) |
746 | // // PPPData::data()->setTotalBytes(stats->totalbytes); | 755 | // // _pppdata->setTotalBytes(stats->totalbytes); |
747 | 756 | ||
748 | // if(!PPPData::data()->AcctEnabled()) | 757 | // if(!_pppdata->AcctEnabled()) |
749 | // return; | 758 | // return; |
750 | 759 | ||
751 | // // if(acct != 0) { | 760 | // // if(acct != 0) { |
752 | // // acct->slotStop(); | 761 | // // acct->slotStop(); |
753 | // // delete acct; | 762 | // // delete acct; |
754 | // // acct = 0; | 763 | // // acct = 0; |
755 | // // } | 764 | // // } |
756 | // } | 765 | // } |
757 | 766 | ||
758 | 767 | ||
759 | // void KPPPWidget::showStats() { | 768 | // void KPPPWidget::showStats() { |
760 | // if(statdlg) { | 769 | // if(statdlg) { |
761 | // statdlg->show(); | 770 | // statdlg->show(); |
762 | // statdlg->raise(); | 771 | // statdlg->raise(); |
763 | // } | 772 | // } |
764 | // } | 773 | // } |
765 | 774 | ||
766 | 775 | ||
767 | void KPPPWidget::usernameChanged(const QString &) { | 776 | void KPPPWidget::usernameChanged(const QString &) { |
768 | // store username for later use | 777 | // store username for later use |
769 | PPPData::data()->setStoredUsername(ID_Edit->text()); | 778 | _pppdata->setStoredUsername(ID_Edit->text()); |
770 | } | 779 | } |
771 | 780 | ||
772 | 781 | ||
773 | void KPPPWidget::passwordChanged(const QString &) { | 782 | void KPPPWidget::passwordChanged(const QString &) { |
774 | // store the password if so requested | 783 | // store the password if so requested |
775 | if(PPPData::data()->storePassword()) | 784 | if(_pppdata->storePassword()) |
776 | PPPData::data()->setStoredPassword(PW_Edit->text()); | 785 | _pppdata->setStoredPassword(PW_Edit->text()); |
777 | else | 786 | else |
778 | PPPData::data()->setStoredPassword(""); | 787 | _pppdata->setStoredPassword(""); |
779 | } | 788 | } |
780 | 789 | ||
781 | 790 | ||
782 | void KPPPWidget::setPW_Edit(const QString &pw) { | 791 | void KPPPWidget::setPW_Edit(const QString &pw) { |
783 | PW_Edit->setText(pw); | 792 | PW_Edit->setText(pw); |
784 | } | 793 | } |
785 | 794 | ||
786 | 795 | ||
787 | // void KPPPWidget::resetCosts(const QString &s) { | 796 | // void KPPPWidget::resetCosts(const QString &s) { |
788 | // AccountingBase::resetCosts(s); | 797 | // AccountingBase::resetCosts(s); |
789 | // } | 798 | // } |
790 | 799 | ||
791 | 800 | ||
792 | // void KPPPWidget::resetVolume(const QString &s) { | 801 | // void KPPPWidget::resetVolume(const QString &s) { |
793 | // AccountingBase::resetVolume(s); | 802 | // AccountingBase::resetVolume(s); |
794 | // } | 803 | // } |
795 | 804 | ||
796 | /** | 805 | /** |
797 | * pppd's getword() function knows about escape characters. | 806 | * pppd's getword() function knows about escape characters. |
798 | * If we write the username and password to the secrets file | 807 | * If we write the username and password to the secrets file |
799 | * we'll therefore have to escape back slashes. | 808 | * we'll therefore have to escape back slashes. |
800 | */ | 809 | */ |
801 | QString KPPPWidget::encodeWord(const QString &s) { | 810 | QString KPPPWidget::encodeWord(const QString &s) { |
802 | QString r = s; | 811 | QString r = s; |
803 | r.replace(QRegExp("\\"), "\\\\"); | 812 | r.replace(QRegExp("\\"), "\\\\"); |
804 | return r; | 813 | return r; |
805 | } | 814 | } |
806 | 815 | ||
807 | // void KPPPWidget::setQuitOnDisconnect (bool b) | 816 | // void KPPPWidget::setQuitOnDisconnect (bool b) |
808 | // { | 817 | // { |
809 | // m_bQuitOnDisconnect = b; | 818 | // m_bQuitOnDisconnect = b; |
810 | // } | 819 | // } |
811 | 820 | ||
812 | void KPPPWidget::showNews() { | 821 | void KPPPWidget::showNews() { |
813 | #ifdef KPPP_SHOW_NEWS | 822 | #ifdef KPPP_SHOW_NEWS |
814 | /* | 823 | /* |
815 | * Introduce the QuickHelp feature to new users of this version | 824 | * Introduce the QuickHelp feature to new users of this version |
816 | */ | 825 | */ |
817 | #define QUICKHELP_HINT "Hint_QuickHelp" | 826 | #define QUICKHELP_HINT "Hint_QuickHelp" |
818 | if(PPPData::data()->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 827 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
819 | QDialog dlg(0, 0, true); | 828 | QDialog dlg(0, 0, true); |
820 | dlg.setCaption(i18n("Recent Changes in KPPP")); | 829 | dlg.setCaption(i18n("Recent Changes in KPPP")); |
821 | 830 | ||
822 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 831 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
823 | QHBoxLayout *l1 = new QHBoxLayout(10); | 832 | QHBoxLayout *l1 = new QHBoxLayout(10); |
824 | QVBoxLayout *l2 = new QVBoxLayout(10); | 833 | QVBoxLayout *l2 = new QVBoxLayout(10); |
825 | tl->addLayout(l1); | 834 | tl->addLayout(l1); |
826 | 835 | ||
827 | QLabel *icon = new QLabel(&dlg); | 836 | QLabel *icon = new QLabel(&dlg); |
828 | icon->setPixmap(BarIcon("exclamation")); | 837 | icon->setPixmap(BarIcon("exclamation")); |
829 | icon->setFixedSize(icon->sizeHint()); | 838 | icon->setFixedSize(icon->sizeHint()); |
830 | l1->addWidget(icon); | 839 | l1->addWidget(icon); |
831 | l1->addLayout(l2); | 840 | l1->addLayout(l2); |
832 | 841 | ||
833 | QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" | 842 | QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" |
834 | "called \"Quickhelp\". It's similar to a tooltip,\n" | 843 | "called \"Quickhelp\". It's similar to a tooltip,\n" |
835 | "but you can activate it whenever you want.\n" | 844 | "but you can activate it whenever you want.\n" |
836 | "\n" | 845 | "\n" |
837 | "To activate it, simply click on a control like\n" | 846 | "To activate it, simply click on a control like\n" |
838 | "a button or a label with the right mouse button.\n" | 847 | "a button or a label with the right mouse button.\n" |
839 | "If the item supports Quickhelp, a popup menu\n" | 848 | "If the item supports Quickhelp, a popup menu\n" |
840 | "will appear leading to Quickhelp.\n" | 849 | "will appear leading to Quickhelp.\n" |
841 | "\n" | 850 | "\n" |
842 | "To test it, right-click somewhere in this text."), | 851 | "To test it, right-click somewhere in this text."), |
843 | &dlg); | 852 | &dlg); |
844 | 853 | ||
845 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); | 854 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); |
846 | cb->setFixedSize(cb->sizeHint()); | 855 | cb->setFixedSize(cb->sizeHint()); |
847 | 856 | ||
848 | KButtonBox *bbox = new KButtonBox(&dlg); | 857 | KButtonBox *bbox = new KButtonBox(&dlg); |
849 | bbox->addStretch(1); | 858 | bbox->addStretch(1); |
850 | QPushButton *ok = bbox->addButton(i18n("OK")); | 859 | QPushButton *ok = bbox->addButton(i18n("OK")); |
851 | ok->setDefault(true); | 860 | ok->setDefault(true); |
852 | dlg.connect(ok, SIGNAL(clicked()), | 861 | dlg.connect(ok, SIGNAL(clicked()), |
853 | &dlg, SLOT(accept())); | 862 | &dlg, SLOT(accept())); |
854 | bbox->addStretch(1); | 863 | bbox->addStretch(1); |
855 | bbox->layout(); | 864 | bbox->layout(); |
856 | 865 | ||
857 | l2->addWidget(l); | 866 | l2->addWidget(l); |
858 | l2->addWidget(cb); | 867 | l2->addWidget(cb); |
859 | tl->addWidget(bbox); | 868 | tl->addWidget(bbox); |
860 | 869 | ||
861 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" | 870 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" |
862 | "This window will stay open until you\n" | 871 | "This window will stay open until you\n" |
863 | "click a mouse button or a press a key.\n"); | 872 | "click a mouse button or a press a key.\n"); |
864 | 873 | ||
865 | QWhatsThis::add(cb,tmp); | 874 | QWhatsThis::add(cb,tmp); |
866 | QWhatsThis::add(l, tmp); | 875 | QWhatsThis::add(l, tmp); |
867 | 876 | ||
868 | dlg.exec(); | 877 | dlg.exec(); |
869 | if(cb->isChecked()) { | 878 | if(cb->isChecked()) { |
870 | PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); | 879 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); |
871 | PPPData::data()->save(); | 880 | _pppdata->save(); |
872 | } | 881 | } |
873 | } | 882 | } |
874 | #endif | 883 | #endif |
875 | } | 884 | } |
876 | 885 | ||
877 | 886 | ||
878 | //#include "kpppwidget.moc" | 887 | //#include "kpppwidget.moc" |
879 | 888 | ||
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h index d7e74af..b958862 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.h +++ b/noncore/settings/networksettings/ppp/kpppwidget.h | |||
@@ -1,114 +1,115 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> | 10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef __KPPPWIDGET_H__ | 27 | #ifndef __KPPPWIDGET_H__ |
28 | #define __KPPPWIDGET_H__ | 28 | #define __KPPPWIDGET_H__ |
29 | 29 | ||
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | 31 | ||
32 | #include "conwindow.h" | 32 | #include "conwindow.h" |
33 | #include "accounts.h" | 33 | #include "accounts.h" |
34 | #include "connect.h" | 34 | #include "connect.h" |
35 | 35 | ||
36 | class QPushButton; | 36 | class QPushButton; |
37 | 37 | class Interface; | |
38 | class PPPData; | ||
38 | 39 | ||
39 | class KPPPWidget : public QDialog { | 40 | class KPPPWidget : public QDialog { |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | public: | 42 | public: |
42 | 43 | ||
43 | KPPPWidget( QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 ); | 44 | KPPPWidget(PPPData*, Interface*, QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 ); |
44 | ~KPPPWidget(); | 45 | ~KPPPWidget(); |
45 | 46 | ||
46 | void setPW_Edit(const QString &); | 47 | void setPW_Edit(const QString &); |
47 | 48 | ||
48 | 49 | ||
49 | private slots: | 50 | private slots: |
50 | void newdefaultaccount(int); | 51 | void newdefaultaccount(int); |
51 | void beginConnect(); | 52 | void beginConnect(); |
52 | void quitbutton(); | 53 | void quitbutton(); |
53 | void usernameChanged(const QString &); | 54 | void usernameChanged(const QString &); |
54 | void passwordChanged(const QString &); | 55 | void passwordChanged(const QString &); |
55 | void enterPressedInID(); | 56 | void enterPressedInID(); |
56 | void enterPressedInPW(); | 57 | void enterPressedInPW(); |
57 | void saveMyself(); | 58 | void saveMyself(); |
58 | void shutDown(); | 59 | void shutDown(); |
59 | 60 | ||
60 | 61 | ||
61 | public slots: | 62 | public slots: |
62 | void disconnect(); | 63 | void disconnect(); |
63 | void log_window_toggled(bool on); | 64 | void log_window_toggled(bool on); |
64 | 65 | ||
65 | signals: | 66 | signals: |
66 | void begin_connect(); | 67 | void begin_connect(); |
67 | void cmdl_start(); | 68 | void cmdl_start(); |
68 | 69 | ||
69 | public: | 70 | public: |
70 | QCheckBox *log; | 71 | QCheckBox *log; |
71 | bool connected; | 72 | bool connected; |
72 | QString con_speed; | 73 | QString con_speed; |
73 | // ConnectWidget *con; | 74 | ConnectWidget *con; |
74 | // ConWindow *con_win; | 75 | ConWindow *con_win; |
75 | // PPPStatsDlg *statdlg; | 76 | // PPPStatsDlg *statdlg; |
76 | // AccountingBase *acct; | 77 | // AccountingBase *acct; |
77 | QPushButton *quit_b; | 78 | QPushButton *quit_b; |
78 | //PPPStats *stats; | 79 | //PPPStats *stats; |
79 | 80 | ||
80 | private: | 81 | private: |
81 | // void prepareSetupDialog(); | 82 | // void prepareSetupDialog(); |
82 | void interruptConnection(); | 83 | void interruptConnection(); |
83 | void sigChld(); | 84 | void sigChld(); |
84 | void sigPPPDDied(); | 85 | void sigPPPDDied(); |
85 | QString encodeWord(const QString &s); | 86 | QString encodeWord(const QString &s); |
86 | void showNews (); | 87 | void showNews (); |
87 | 88 | ||
88 | QString ruleset_load_errmsg; | 89 | QString ruleset_load_errmsg; |
89 | 90 | PPPData *_pppdata; | |
90 | QPushButton *setup_b; | 91 | QPushButton *setup_b; |
91 | QFrame *fline; | 92 | QFrame *fline; |
92 | QFrame *fline1; | 93 | QFrame *fline1; |
93 | QPushButton *connect_b; | 94 | QPushButton *connect_b; |
94 | QComboBox *connectto_c; | 95 | QComboBox *connectto_c; |
95 | QLabel *ID_Label; | 96 | QLabel *ID_Label; |
96 | QLabel *PW_Label; | 97 | QLabel *PW_Label; |
97 | QLineEdit *ID_Edit; | 98 | QLineEdit *ID_Edit; |
98 | QLineEdit *PW_Edit; | 99 | QLineEdit *PW_Edit; |
99 | QLabel *label1; | 100 | QLabel *label1; |
100 | QLabel *label2; | 101 | QLabel *label2; |
101 | QLabel *label3; | 102 | QLabel *label3; |
102 | QLabel *label4; | 103 | QLabel *label4; |
103 | QLabel *label5; | 104 | QLabel *label5; |
104 | QLabel *label6; | 105 | QLabel *label6; |
105 | QLabel *radio_label; | 106 | QLabel *radio_label; |
106 | 107 | ||
107 | /* QString m_strCmdlAccount; */ | 108 | /* QString m_strCmdlAccount; */ |
108 | /* bool m_bQuitOnDisconnect; */ | 109 | /* bool m_bQuitOnDisconnect; */ |
109 | /* bool m_bCmdlAccount; */ | 110 | /* bool m_bCmdlAccount; */ |
110 | }; | 111 | }; |
111 | 112 | ||
112 | 113 | ||
113 | #endif | 114 | #endif |
114 | 115 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 5139482..002c8e7 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -1,1022 +1,1021 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <fcntl.h> | 30 | #include <fcntl.h> |
31 | #include <signal.h> | 31 | #include <signal.h> |
32 | #include <sys/ioctl.h> | 32 | #include <sys/ioctl.h> |
33 | #include <setjmp.h> | 33 | #include <setjmp.h> |
34 | #include <regex.h> | 34 | #include <regex.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <assert.h> | 36 | #include <assert.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | 38 | ||
39 | #ifdef HAVE_RESOLV_H | 39 | #ifdef HAVE_RESOLV_H |
40 | # include <arpa/nameser.h> | 40 | # include <arpa/nameser.h> |
41 | # include <resolv.h> | 41 | # include <resolv.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #ifndef _PATH_RESCONF | 44 | #ifndef _PATH_RESCONF |
45 | #define _PATH_RESCONF "/etc/resolv.conf" | 45 | #define _PATH_RESCONF "/etc/resolv.conf" |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #define strlcpy strcpy | 48 | #define strlcpy strcpy |
49 | #include "auth.h" | 49 | #include "auth.h" |
50 | #include "modem.h" | 50 | #include "modem.h" |
51 | #include "pppdata.h" | 51 | #include "pppdata.h" |
52 | //#include <klocale.h> | 52 | //#include <klocale.h> |
53 | #define i18n QObject::tr | 53 | #define i18n QObject::tr |
54 | #define qError qDebug | 54 | #define qError qDebug |
55 | //#include <kdebug.h> | 55 | //#include <kdebug.h> |
56 | //#include <config.h> | 56 | //#include <config.h> |
57 | 57 | ||
58 | #define MY_ASSERT(x) if (!(x)) { \ | 58 | #define MY_ASSERT(x) if (!(x)) { \ |
59 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 59 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ |
60 | exit(1); } | 60 | exit(1); } |
61 | 61 | ||
62 | 62 | ||
63 | static sigjmp_buf jmp_buffer; | 63 | static sigjmp_buf jmp_buffer; |
64 | 64 | ||
65 | Modem *Modem::modem = 0; | 65 | //Modem *Modem::modem = 0; |
66 | 66 | ||
67 | 67 | ||
68 | const char* pppdPath() { | 68 | const char* pppdPath() { |
69 | // wasting a few bytes | 69 | // wasting a few bytes |
70 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 70 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
71 | static char *pppdPath = 0L; | 71 | static char *pppdPath = 0L; |
72 | char *p; | 72 | char *p; |
73 | 73 | ||
74 | if(pppdPath == 0L) { | 74 | if(pppdPath == 0L) { |
75 | const char *c = PPPDSEARCHPATH; | 75 | const char *c = PPPDSEARCHPATH; |
76 | while(*c != '\0') { | 76 | while(*c != '\0') { |
77 | while(*c == ':') | 77 | while(*c == ':') |
78 | c++; | 78 | c++; |
79 | p = buffer; | 79 | p = buffer; |
80 | while(*c != '\0' && *c != ':') | 80 | while(*c != '\0' && *c != ':') |
81 | *p++ = *c++; | 81 | *p++ = *c++; |
82 | *p = '\0'; | 82 | *p = '\0'; |
83 | strcat(p, "/"); | 83 | strcat(p, "/"); |
84 | strcat(p, PPPDNAME); | 84 | strcat(p, PPPDNAME); |
85 | if(access(buffer, F_OK) == 0) | 85 | if(access(buffer, F_OK) == 0) |
86 | return (pppdPath = buffer); | 86 | return (pppdPath = buffer); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | return pppdPath; | 90 | return pppdPath; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | Modem::Modem() | 94 | Modem::Modem( PPPData* pd ) |
95 | { | 95 | { |
96 | if (Modem::modem != 0) return; //CORRECT? | 96 | _pppdata = pd; |
97 | modemfd = -1; | 97 | modemfd = -1; |
98 | _pppdExitStatus = -1; | 98 | _pppdExitStatus = -1; |
99 | pppdPid = -1; | 99 | pppdPid = -1; |
100 | sn = 0L; | 100 | sn = 0L; |
101 | data_mode = false; | 101 | data_mode = false; |
102 | modem_is_locked = false; | 102 | modem_is_locked = false; |
103 | lockfile[0] = '\0'; | 103 | lockfile[0] = '\0'; |
104 | device = "/dev/modem"; | 104 | device = "/dev/modem"; |
105 | modem = this; | ||
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | Modem::~Modem() { | 108 | Modem::~Modem() |
110 | modem = 0; | 109 | { |
111 | } | 110 | } |
112 | 111 | ||
113 | 112 | ||
114 | speed_t Modem::modemspeed() { | 113 | speed_t Modem::modemspeed() { |
115 | // convert the string modem speed int the gpppdata object to a t_speed type | 114 | // convert the string modem speed int the gpppdata object to a t_speed type |
116 | // to set the modem. The constants here should all be ifdef'd because | 115 | // to set the modem. The constants here should all be ifdef'd because |
117 | // other systems may not have them | 116 | // other systems may not have them |
118 | int i = PPPData::data()->speed().toInt()/100; | 117 | int i = _pppdata->speed().toInt()/100; |
119 | 118 | ||
120 | switch(i) { | 119 | switch(i) { |
121 | case 24: | 120 | case 24: |
122 | return B2400; | 121 | return B2400; |
123 | break; | 122 | break; |
124 | case 96: | 123 | case 96: |
125 | return B9600; | 124 | return B9600; |
126 | break; | 125 | break; |
127 | case 192: | 126 | case 192: |
128 | return B19200; | 127 | return B19200; |
129 | break; | 128 | break; |
130 | case 384: | 129 | case 384: |
131 | return B38400; | 130 | return B38400; |
132 | break; | 131 | break; |
133 | #ifdef B57600 | 132 | #ifdef B57600 |
134 | case 576: | 133 | case 576: |
135 | return B57600; | 134 | return B57600; |
136 | break; | 135 | break; |
137 | #endif | 136 | #endif |
138 | 137 | ||
139 | #ifdef B115200 | 138 | #ifdef B115200 |
140 | case 1152: | 139 | case 1152: |
141 | return B115200; | 140 | return B115200; |
142 | break; | 141 | break; |
143 | #endif | 142 | #endif |
144 | 143 | ||
145 | #ifdef B230400 | 144 | #ifdef B230400 |
146 | case 2304: | 145 | case 2304: |
147 | return B230400; | 146 | return B230400; |
148 | break; | 147 | break; |
149 | #endif | 148 | #endif |
150 | 149 | ||
151 | #ifdef B460800 | 150 | #ifdef B460800 |
152 | case 4608: | 151 | case 4608: |
153 | return B460800; | 152 | return B460800; |
154 | break; | 153 | break; |
155 | #endif | 154 | #endif |
156 | 155 | ||
157 | default: | 156 | default: |
158 | return B38400; | 157 | return B38400; |
159 | break; | 158 | break; |
160 | } | 159 | } |
161 | } | 160 | } |
162 | 161 | ||
163 | bool Modem::opentty() { | 162 | bool Modem::opentty() { |
164 | // int flags; | 163 | // int flags; |
165 | 164 | ||
166 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 165 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
167 | close(modemfd); | 166 | close(modemfd); |
168 | device = PPPData::data()->modemDevice(); | 167 | device = _pppdata->modemDevice(); |
169 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 168 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
170 | qDebug("error opening modem device !"); | 169 | qDebug("error opening modem device !"); |
171 | errmsg = i18n("Unable to open modem."); | 170 | errmsg = i18n("Unable to open modem."); |
172 | return false; | 171 | return false; |
173 | } | 172 | } |
174 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 173 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
175 | //} | 174 | //} |
176 | 175 | ||
177 | #if 0 | 176 | #if 0 |
178 | if(PPPData::data()->UseCDLine()) { | 177 | if(_pppdata->UseCDLine()) { |
179 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 178 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
180 | errmsg = i18n("Unable to detect state of CD line."); | 179 | errmsg = i18n("Unable to detect state of CD line."); |
181 | ::close(modemfd); | 180 | ::close(modemfd); |
182 | modemfd = -1; | 181 | modemfd = -1; |
183 | return false; | 182 | return false; |
184 | } | 183 | } |
185 | if ((flags&TIOCM_CD) == 0) { | 184 | if ((flags&TIOCM_CD) == 0) { |
186 | errmsg = i18n("The modem is not ready."); | 185 | errmsg = i18n("The modem is not ready."); |
187 | ::close(modemfd); | 186 | ::close(modemfd); |
188 | modemfd = -1; | 187 | modemfd = -1; |
189 | return false; | 188 | return false; |
190 | } | 189 | } |
191 | } | 190 | } |
192 | #endif | 191 | #endif |
193 | 192 | ||
194 | tcdrain (modemfd); | 193 | tcdrain (modemfd); |
195 | tcflush (modemfd, TCIOFLUSH); | 194 | tcflush (modemfd, TCIOFLUSH); |
196 | 195 | ||
197 | if(tcgetattr(modemfd, &tty) < 0){ | 196 | if(tcgetattr(modemfd, &tty) < 0){ |
198 | // this helps in some cases | 197 | // this helps in some cases |
199 | tcsendbreak(modemfd, 0); | 198 | tcsendbreak(modemfd, 0); |
200 | sleep(1); | 199 | sleep(1); |
201 | if(tcgetattr(modemfd, &tty) < 0){ | 200 | if(tcgetattr(modemfd, &tty) < 0){ |
202 | errmsg = i18n("The modem is busy."); | 201 | errmsg = i18n("The modem is busy."); |
203 | ::close(modemfd); | 202 | ::close(modemfd); |
204 | modemfd = -1; | 203 | modemfd = -1; |
205 | return false; | 204 | return false; |
206 | } | 205 | } |
207 | } | 206 | } |
208 | 207 | ||
209 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 208 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
210 | 209 | ||
211 | initial_tty = tty; | 210 | initial_tty = tty; |
212 | 211 | ||
213 | tty.c_cc[VMIN] = 0; // nonblocking | 212 | tty.c_cc[VMIN] = 0; // nonblocking |
214 | tty.c_cc[VTIME] = 0; | 213 | tty.c_cc[VTIME] = 0; |
215 | tty.c_oflag = 0; | 214 | tty.c_oflag = 0; |
216 | tty.c_lflag = 0; | 215 | tty.c_lflag = 0; |
217 | 216 | ||
218 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 217 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
219 | tty.c_cflag |= CS8 | CREAD; | 218 | tty.c_cflag |= CS8 | CREAD; |
220 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 219 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
221 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 220 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
222 | tty.c_lflag &= ~ICANON; // non-canonical mode | 221 | tty.c_lflag &= ~ICANON; // non-canonical mode |
223 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 222 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
224 | 223 | ||
225 | 224 | ||
226 | if(PPPData::data()->flowcontrol() != "None") { | 225 | if(_pppdata->flowcontrol() != "None") { |
227 | if(PPPData::data()->flowcontrol() == "CRTSCTS") { | 226 | if(_pppdata->flowcontrol() == "CRTSCTS") { |
228 | tty.c_cflag |= CRTSCTS; | 227 | tty.c_cflag |= CRTSCTS; |
229 | } | 228 | } |
230 | else { | 229 | else { |
231 | tty.c_iflag |= IXON | IXOFF; | 230 | tty.c_iflag |= IXON | IXOFF; |
232 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 231 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
233 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 232 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
234 | } | 233 | } |
235 | } | 234 | } |
236 | else { | 235 | else { |
237 | tty.c_cflag &= ~CRTSCTS; | 236 | tty.c_cflag &= ~CRTSCTS; |
238 | tty.c_iflag &= ~(IXON | IXOFF); | 237 | tty.c_iflag &= ~(IXON | IXOFF); |
239 | } | 238 | } |
240 | 239 | ||
241 | cfsetospeed(&tty, modemspeed()); | 240 | cfsetospeed(&tty, modemspeed()); |
242 | cfsetispeed(&tty, modemspeed()); | 241 | cfsetispeed(&tty, modemspeed()); |
243 | 242 | ||
244 | tcdrain(modemfd); | 243 | tcdrain(modemfd); |
245 | 244 | ||
246 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 245 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
247 | errmsg = i18n("The modem is busy."); | 246 | errmsg = i18n("The modem is busy."); |
248 | ::close(modemfd); | 247 | ::close(modemfd); |
249 | modemfd=-1; | 248 | modemfd=-1; |
250 | return false; | 249 | return false; |
251 | } | 250 | } |
252 | 251 | ||
253 | errmsg = i18n("Modem Ready."); | 252 | errmsg = i18n("Modem Ready."); |
254 | return true; | 253 | return true; |
255 | } | 254 | } |
256 | 255 | ||
257 | 256 | ||
258 | bool Modem::closetty() { | 257 | bool Modem::closetty() { |
259 | if(modemfd >=0 ) { | 258 | if(modemfd >=0 ) { |
260 | stop(); | 259 | stop(); |
261 | /* discard data not read or transmitted */ | 260 | /* discard data not read or transmitted */ |
262 | tcflush(modemfd, TCIOFLUSH); | 261 | tcflush(modemfd, TCIOFLUSH); |
263 | 262 | ||
264 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 263 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
265 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); | 264 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); |
266 | ::close(modemfd); | 265 | ::close(modemfd); |
267 | modemfd = -1; | 266 | modemfd = -1; |
268 | return false; | 267 | return false; |
269 | } | 268 | } |
270 | ::close(modemfd); | 269 | ::close(modemfd); |
271 | modemfd = -1; | 270 | modemfd = -1; |
272 | } | 271 | } |
273 | 272 | ||
274 | return true; | 273 | return true; |
275 | } | 274 | } |
276 | 275 | ||
277 | 276 | ||
278 | void Modem::readtty(int) { | 277 | void Modem::readtty(int) { |
279 | char buffer[200]; | 278 | char buffer[200]; |
280 | unsigned char c; | 279 | unsigned char c; |
281 | int len; | 280 | int len; |
282 | 281 | ||
283 | // read data in chunks of up to 200 bytes | 282 | // read data in chunks of up to 200 bytes |
284 | if((len = ::read(modemfd, buffer, 200)) > 0) { | 283 | if((len = ::read(modemfd, buffer, 200)) > 0) { |
285 | // split buffer into single characters for further processing | 284 | // split buffer into single characters for further processing |
286 | for(int i = 0; i < len; i++) { | 285 | for(int i = 0; i < len; i++) { |
287 | c = buffer[i] & 0x7F; | 286 | c = buffer[i] & 0x7F; |
288 | emit charWaiting(c); | 287 | emit charWaiting(c); |
289 | } | 288 | } |
290 | } | 289 | } |
291 | } | 290 | } |
292 | 291 | ||
293 | 292 | ||
294 | void Modem::notify(const QObject *receiver, const char *member) { | 293 | void Modem::notify(const QObject *receiver, const char *member) { |
295 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | 294 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); |
296 | startNotifier(); | 295 | startNotifier(); |
297 | } | 296 | } |
298 | 297 | ||
299 | 298 | ||
300 | void Modem::stop() { | 299 | void Modem::stop() { |
301 | disconnect(SIGNAL(charWaiting(unsigned char))); | 300 | disconnect(SIGNAL(charWaiting(unsigned char))); |
302 | stopNotifier(); | 301 | stopNotifier(); |
303 | } | 302 | } |
304 | 303 | ||
305 | 304 | ||
306 | void Modem::startNotifier() { | 305 | void Modem::startNotifier() { |
307 | if(modemfd >= 0) { | 306 | if(modemfd >= 0) { |
308 | if(sn == 0) { | 307 | if(sn == 0) { |
309 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 308 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
310 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 309 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
311 | qDebug("QSocketNotifier started!"); | 310 | qDebug("QSocketNotifier started!"); |
312 | } else { | 311 | } else { |
313 | qDebug("QSocketNotifier re-enabled!"); | 312 | qDebug("QSocketNotifier re-enabled!"); |
314 | sn->setEnabled(true); | 313 | sn->setEnabled(true); |
315 | } | 314 | } |
316 | } | 315 | } |
317 | } | 316 | } |
318 | 317 | ||
319 | 318 | ||
320 | void Modem::stopNotifier() { | 319 | void Modem::stopNotifier() { |
321 | if(sn != 0) { | 320 | if(sn != 0) { |
322 | sn->setEnabled(false); | 321 | sn->setEnabled(false); |
323 | disconnect(sn); | 322 | disconnect(sn); |
324 | delete sn; | 323 | delete sn; |
325 | sn = 0; | 324 | sn = 0; |
326 | qDebug( "QSocketNotifier stopped!" ); | 325 | qDebug( "QSocketNotifier stopped!" ); |
327 | } | 326 | } |
328 | } | 327 | } |
329 | 328 | ||
330 | 329 | ||
331 | void Modem::flush() { | 330 | void Modem::flush() { |
332 | char c; | 331 | char c; |
333 | while(read(modemfd, &c, 1) == 1); | 332 | while(read(modemfd, &c, 1) == 1); |
334 | } | 333 | } |
335 | 334 | ||
336 | 335 | ||
337 | bool Modem::writeChar(unsigned char c) { | 336 | bool Modem::writeChar(unsigned char c) { |
338 | int s; | 337 | int s; |
339 | do { | 338 | do { |
340 | s = write(modemfd, &c, 1); | 339 | s = write(modemfd, &c, 1); |
341 | if (s < 0) { | 340 | if (s < 0) { |
342 | qError( "write() in Modem::writeChar failed" ); | 341 | qError( "write() in Modem::writeChar failed" ); |
343 | return false; | 342 | return false; |
344 | } | 343 | } |
345 | } while(s == 0); | 344 | } while(s == 0); |
346 | 345 | ||
347 | return true; | 346 | return true; |
348 | } | 347 | } |
349 | 348 | ||
350 | 349 | ||
351 | bool Modem::writeLine(const char *buf) { | 350 | bool Modem::writeLine(const char *buf) { |
352 | int len = strlen(buf); | 351 | int len = strlen(buf); |
353 | char *b = new char[len+2]; | 352 | char *b = new char[len+2]; |
354 | memcpy(b, buf, len); | 353 | memcpy(b, buf, len); |
355 | // different modems seem to need different line terminations | 354 | // different modems seem to need different line terminations |
356 | QString term = PPPData::data()->enter(); | 355 | QString term = _pppdata->enter(); |
357 | if(term == "LF") | 356 | if(term == "LF") |
358 | b[len++]='\n'; | 357 | b[len++]='\n'; |
359 | else if(term == "CR") | 358 | else if(term == "CR") |
360 | b[len++]='\r'; | 359 | b[len++]='\r'; |
361 | else if(term == "CR/LF") { | 360 | else if(term == "CR/LF") { |
362 | b[len++]='\r'; | 361 | b[len++]='\r'; |
363 | b[len++]='\n'; | 362 | b[len++]='\n'; |
364 | } | 363 | } |
365 | int l = len; | 364 | int l = len; |
366 | while(l) { | 365 | while(l) { |
367 | int wr = write(modemfd, &b[len-l], l); | 366 | int wr = write(modemfd, &b[len-l], l); |
368 | if(wr < 0) { | 367 | if(wr < 0) { |
369 | // TODO do something meaningful with the error code (or ignore it | 368 | // TODO do something meaningful with the error code (or ignore it |
370 | qError( "write() in Modem::writeLine failed" ); | 369 | qError( "write() in Modem::writeLine failed" ); |
371 | delete[] b; | 370 | delete[] b; |
372 | return false; | 371 | return false; |
373 | } | 372 | } |
374 | l -= wr; | 373 | l -= wr; |
375 | } | 374 | } |
376 | delete[] b; | 375 | delete[] b; |
377 | return true; | 376 | return true; |
378 | } | 377 | } |
379 | 378 | ||
380 | 379 | ||
381 | bool Modem::hangup() { | 380 | bool Modem::hangup() { |
382 | // this should really get the modem to hang up and go into command mode | 381 | // this should really get the modem to hang up and go into command mode |
383 | // If anyone sees a fault in the following please let me know, since | 382 | // If anyone sees a fault in the following please let me know, since |
384 | // this is probably the most imporant snippet of code in the whole of | 383 | // this is probably the most imporant snippet of code in the whole of |
385 | // kppp. If people complain about kppp being stuck, this piece of code | 384 | // kppp. If people complain about kppp being stuck, this piece of code |
386 | // is most likely the reason. | 385 | // is most likely the reason. |
387 | struct termios temptty; | 386 | struct termios temptty; |
388 | 387 | ||
389 | if(modemfd >= 0) { | 388 | if(modemfd >= 0) { |
390 | 389 | ||
391 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 390 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
392 | 391 | ||
393 | if (data_mode) escape_to_command_mode(); | 392 | if (data_mode) escape_to_command_mode(); |
394 | 393 | ||
395 | // Then hangup command | 394 | // Then hangup command |
396 | writeLine(PPPData::data()->modemHangupStr().local8Bit()); | 395 | writeLine(_pppdata->modemHangupStr().local8Bit()); |
397 | 396 | ||
398 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 397 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
399 | 398 | ||
400 | #ifndef DEBUG_WO_DIALING | 399 | #ifndef DEBUG_WO_DIALING |
401 | if (sigsetjmp(jmp_buffer, 1) == 0) { | 400 | if (sigsetjmp(jmp_buffer, 1) == 0) { |
402 | // set alarm in case tcsendbreak() hangs | 401 | // set alarm in case tcsendbreak() hangs |
403 | signal(SIGALRM, alarm_handler); | 402 | signal(SIGALRM, alarm_handler); |
404 | alarm(2); | 403 | alarm(2); |
405 | 404 | ||
406 | tcsendbreak(modemfd, 0); | 405 | tcsendbreak(modemfd, 0); |
407 | 406 | ||
408 | alarm(0); | 407 | alarm(0); |
409 | signal(SIGALRM, SIG_IGN); | 408 | signal(SIGALRM, SIG_IGN); |
410 | } else { | 409 | } else { |
411 | // we reach this point if the alarm handler got called | 410 | // we reach this point if the alarm handler got called |
412 | closetty(); | 411 | closetty(); |
413 | close(modemfd); | 412 | close(modemfd); |
414 | modemfd = -1; | 413 | modemfd = -1; |
415 | errmsg = i18n("The modem does not respond."); | 414 | errmsg = i18n("The modem does not respond."); |
416 | return false; | 415 | return false; |
417 | } | 416 | } |
418 | 417 | ||
419 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | 418 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. |
420 | tcgetattr(modemfd, &temptty); | 419 | tcgetattr(modemfd, &temptty); |
421 | cfsetospeed(&temptty, B0); | 420 | cfsetospeed(&temptty, B0); |
422 | cfsetispeed(&temptty, B0); | 421 | cfsetispeed(&temptty, B0); |
423 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 422 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
424 | #else | 423 | #else |
425 | int modemstat; | 424 | int modemstat; |
426 | ioctl(modemfd, TIOCMGET, &modemstat); | 425 | ioctl(modemfd, TIOCMGET, &modemstat); |
427 | modemstat &= ~TIOCM_DTR; | 426 | modemstat &= ~TIOCM_DTR; |
428 | ioctl(modemfd, TIOCMSET, &modemstat); | 427 | ioctl(modemfd, TIOCMSET, &modemstat); |
429 | ioctl(modemfd, TIOCMGET, &modemstat); | 428 | ioctl(modemfd, TIOCMGET, &modemstat); |
430 | modemstat |= TIOCM_DTR; | 429 | modemstat |= TIOCM_DTR; |
431 | ioctl(modemfd, TIOCMSET, &modemstat); | 430 | ioctl(modemfd, TIOCMSET, &modemstat); |
432 | #endif | 431 | #endif |
433 | 432 | ||
434 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs | 433 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs |
435 | 434 | ||
436 | cfsetospeed(&temptty, modemspeed()); | 435 | cfsetospeed(&temptty, modemspeed()); |
437 | cfsetispeed(&temptty, modemspeed()); | 436 | cfsetispeed(&temptty, modemspeed()); |
438 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 437 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
439 | #endif | 438 | #endif |
440 | return true; | 439 | return true; |
441 | } else | 440 | } else |
442 | return false; | 441 | return false; |
443 | } | 442 | } |
444 | 443 | ||
445 | 444 | ||
446 | void Modem::escape_to_command_mode() { | 445 | void Modem::escape_to_command_mode() { |
447 | // Send Properly bracketed escape code to put the modem back into command state. | 446 | // Send Properly bracketed escape code to put the modem back into command state. |
448 | // A modem will accept AT commands only when it is in command state. | 447 | // A modem will accept AT commands only when it is in command state. |
449 | // When a modem sends the host the CONNECT string, that signals | 448 | // When a modem sends the host the CONNECT string, that signals |
450 | // that the modem is now in the connect state (no long accepts AT commands.) | 449 | // that the modem is now in the connect state (no long accepts AT commands.) |
451 | // Need to send properly timed escape sequence to put modem in command state. | 450 | // Need to send properly timed escape sequence to put modem in command state. |
452 | // Escape codes and guard times are controlled by S2 and S12 values. | 451 | // Escape codes and guard times are controlled by S2 and S12 values. |
453 | // | 452 | // |
454 | tcflush(modemfd, TCIOFLUSH); | 453 | tcflush(modemfd, TCIOFLUSH); |
455 | 454 | ||
456 | // +3 because quiet time must be greater than guard time. | 455 | // +3 because quiet time must be greater than guard time. |
457 | usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); | 456 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
458 | QCString tmp = PPPData::data()->modemEscapeStr().local8Bit(); | 457 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); |
459 | write(modemfd, tmp.data(), tmp.length()); | 458 | write(modemfd, tmp.data(), tmp.length()); |
460 | tcflush(modemfd, TCIOFLUSH); | 459 | tcflush(modemfd, TCIOFLUSH); |
461 | usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); | 460 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
462 | 461 | ||
463 | data_mode = false; | 462 | data_mode = false; |
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
467 | const QString Modem::modemMessage() { | 466 | const QString Modem::modemMessage() { |
468 | return errmsg; | 467 | return errmsg; |
469 | } | 468 | } |
470 | 469 | ||
471 | 470 | ||
472 | QString Modem::parseModemSpeed(const QString &s) { | 471 | QString Modem::parseModemSpeed(const QString &s) { |
473 | // this is a small (and bad) parser for modem speeds | 472 | // this is a small (and bad) parser for modem speeds |
474 | int rx = -1; | 473 | int rx = -1; |
475 | int tx = -1; | 474 | int tx = -1; |
476 | int i; | 475 | int i; |
477 | QString result; | 476 | QString result; |
478 | 477 | ||
479 | qDebug( "Modem reported result string: %s", s.latin1()); | 478 | qDebug( "Modem reported result string: %s", s.latin1()); |
480 | 479 | ||
481 | const int RXMAX = 7; | 480 | const int RXMAX = 7; |
482 | const int TXMAX = 2; | 481 | const int TXMAX = 2; |
483 | QRegExp rrx[RXMAX] = { | 482 | QRegExp rrx[RXMAX] = { |
484 | QRegExp("[0-9]+[:/ ]RX", false), | 483 | QRegExp("[0-9]+[:/ ]RX", false), |
485 | QRegExp("[0-9]+RX", false), | 484 | QRegExp("[0-9]+RX", false), |
486 | QRegExp("[/: -][0-9]+[/: ]", false), | 485 | QRegExp("[/: -][0-9]+[/: ]", false), |
487 | QRegExp("[/: -][0-9]+$", false), | 486 | QRegExp("[/: -][0-9]+$", false), |
488 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 487 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
489 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 488 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
490 | QRegExp("[0-9]+") // panic mode | 489 | QRegExp("[0-9]+") // panic mode |
491 | }; | 490 | }; |
492 | 491 | ||
493 | QRegExp trx[TXMAX] = { | 492 | QRegExp trx[TXMAX] = { |
494 | QRegExp("[0-9]+[:/ ]TX", false), | 493 | QRegExp("[0-9]+[:/ ]TX", false), |
495 | QRegExp("[0-9]+TX", false) | 494 | QRegExp("[0-9]+TX", false) |
496 | }; | 495 | }; |
497 | 496 | ||
498 | for(i = 0; i < RXMAX; i++) { | 497 | for(i = 0; i < RXMAX; i++) { |
499 | int len, idx, result; | 498 | int len, idx, result; |
500 | if((idx = rrx[i].match(s,0,&len)) > -1) { | 499 | if((idx = rrx[i].match(s,0,&len)) > -1) { |
501 | // if((idx = rrx[i].search(s)) > -1) { | 500 | // if((idx = rrx[i].search(s)) > -1) { |
502 | // len = rrx[i].matchedLength(); | 501 | // len = rrx[i].matchedLength(); |
503 | 502 | ||
504 | // | 503 | // |
505 | // rrx[i] has been matched, idx contains the start of the match | 504 | // rrx[i] has been matched, idx contains the start of the match |
506 | // and len contains how long the match is. Extract the match. | 505 | // and len contains how long the match is. Extract the match. |
507 | // | 506 | // |
508 | QString sub = s.mid(idx, len); | 507 | QString sub = s.mid(idx, len); |
509 | 508 | ||
510 | // | 509 | // |
511 | // Now extract the digits only from the match, which will | 510 | // Now extract the digits only from the match, which will |
512 | // then be converted to an int. | 511 | // then be converted to an int. |
513 | // | 512 | // |
514 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { | 513 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { |
515 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { | 514 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { |
516 | // len = rrx[RXMAX-1].matchedLength(); | 515 | // len = rrx[RXMAX-1].matchedLength(); |
517 | sub = sub.mid(idx, len); | 516 | sub = sub.mid(idx, len); |
518 | result = sub.toInt(); | 517 | result = sub.toInt(); |
519 | if(result > 0) { | 518 | if(result > 0) { |
520 | rx = result; | 519 | rx = result; |
521 | break; | 520 | break; |
522 | } | 521 | } |
523 | } | 522 | } |
524 | } | 523 | } |
525 | } | 524 | } |
526 | 525 | ||
527 | for(i = 0; i < TXMAX; i++) { | 526 | for(i = 0; i < TXMAX; i++) { |
528 | int len, idx, result; | 527 | int len, idx, result; |
529 | if((idx = trx[i].match(s,0,&len)) > -1) { | 528 | if((idx = trx[i].match(s,0,&len)) > -1) { |
530 | // if((idx = trx[i].search(s)) > -1) { | 529 | // if((idx = trx[i].search(s)) > -1) { |
531 | // len = trx[i].matchedLength(); | 530 | // len = trx[i].matchedLength(); |
532 | 531 | ||
533 | // | 532 | // |
534 | // trx[i] has been matched, idx contains the start of the match | 533 | // trx[i] has been matched, idx contains the start of the match |
535 | // and len contains how long the match is. Extract the match. | 534 | // and len contains how long the match is. Extract the match. |
536 | // | 535 | // |
537 | QString sub = s.mid(idx, len); | 536 | QString sub = s.mid(idx, len); |
538 | 537 | ||
539 | // | 538 | // |
540 | // Now extract the digits only from the match, which will then | 539 | // Now extract the digits only from the match, which will then |
541 | // be converted to an int. | 540 | // be converted to an int. |
542 | // | 541 | // |
543 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { | 542 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { |
544 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { | 543 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { |
545 | // len = rrx[RXMAX-1].matchedLength(); | 544 | // len = rrx[RXMAX-1].matchedLength(); |
546 | sub = sub.mid(idx, len); | 545 | sub = sub.mid(idx, len); |
547 | result = sub.toInt(); | 546 | result = sub.toInt(); |
548 | if(result > 0) { | 547 | if(result > 0) { |
549 | tx = result; | 548 | tx = result; |
550 | break; | 549 | break; |
551 | } | 550 | } |
552 | } | 551 | } |
553 | } | 552 | } |
554 | } | 553 | } |
555 | 554 | ||
556 | if(rx == -1 && tx == -1) | 555 | if(rx == -1 && tx == -1) |
557 | result = i18n("Unknown speed"); | 556 | result = i18n("Unknown speed"); |
558 | else if(tx == -1) | 557 | else if(tx == -1) |
559 | result.setNum(rx); | 558 | result.setNum(rx); |
560 | else if(rx == -1) // should not happen | 559 | else if(rx == -1) // should not happen |
561 | result.setNum(tx); | 560 | result.setNum(tx); |
562 | else | 561 | else |
563 | result.sprintf("%d/%d", rx, tx); | 562 | result.sprintf("%d/%d", rx, tx); |
564 | 563 | ||
565 | qDebug( "The parsed result is: %s", result.latin1()); | 564 | qDebug( "The parsed result is: %s", result.latin1()); |
566 | 565 | ||
567 | return result; | 566 | return result; |
568 | } | 567 | } |
569 | 568 | ||
570 | 569 | ||
571 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 570 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
572 | // a lock file can't be created ( permission problem ) | 571 | // a lock file can't be created ( permission problem ) |
573 | int Modem::lockdevice() { | 572 | int Modem::lockdevice() { |
574 | int fd; | 573 | int fd; |
575 | char newlock[80]=""; // safe | 574 | char newlock[80]=""; // safe |
576 | 575 | ||
577 | if(!PPPData::data()->modemLockFile()) { | 576 | if(!_pppdata->modemLockFile()) { |
578 | qDebug("The user doesn't want a lockfile."); | 577 | qDebug("The user doesn't want a lockfile."); |
579 | return 0; | 578 | return 0; |
580 | } | 579 | } |
581 | 580 | ||
582 | if (modem_is_locked) | 581 | if (modem_is_locked) |
583 | return 1; | 582 | return 1; |
584 | 583 | ||
585 | QString lockfile = LOCK_DIR"/LCK.."; | 584 | QString lockfile = LOCK_DIR"/LCK.."; |
586 | lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ | 585 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
587 | 586 | ||
588 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 587 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
589 | // if ((fd = Requester::rq-> | 588 | // if ((fd = Requester::rq-> |
590 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 589 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
591 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 590 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
592 | // file has more than 32 bytes, skip the rest | 591 | // file has more than 32 bytes, skip the rest |
593 | char oldlock[33]; // safe | 592 | char oldlock[33]; // safe |
594 | int sz = read(fd, &oldlock, 32); | 593 | int sz = read(fd, &oldlock, 32); |
595 | close (fd); | 594 | close (fd); |
596 | if (sz <= 0) | 595 | if (sz <= 0) |
597 | return 1; | 596 | return 1; |
598 | oldlock[sz] = '\0'; | 597 | oldlock[sz] = '\0'; |
599 | 598 | ||
600 | qDebug( "Device is locked by: %s", oldlock); | 599 | qDebug( "Device is locked by: %s", oldlock); |
601 | 600 | ||
602 | int oldpid; | 601 | int oldpid; |
603 | int match = sscanf(oldlock, "%d", &oldpid); | 602 | int match = sscanf(oldlock, "%d", &oldpid); |
604 | 603 | ||
605 | // found a pid in lockfile ? | 604 | // found a pid in lockfile ? |
606 | if (match < 1 || oldpid <= 0) | 605 | if (match < 1 || oldpid <= 0) |
607 | return 1; | 606 | return 1; |
608 | 607 | ||
609 | // check if process exists | 608 | // check if process exists |
610 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 609 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
611 | return 1; | 610 | return 1; |
612 | 611 | ||
613 | qDebug( "lockfile is stale" ); | 612 | qDebug( "lockfile is stale" ); |
614 | } | 613 | } |
615 | } | 614 | } |
616 | 615 | ||
617 | fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 616 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
618 | if(fd >= 0) { | 617 | if(fd >= 0) { |
619 | sprintf(newlock,"%010d\n", getpid()); | 618 | sprintf(newlock,"%010d\n", getpid()); |
620 | qDebug("Locking Device: %s", newlock); | 619 | qDebug("Locking Device: %s", newlock); |
621 | 620 | ||
622 | write(fd, newlock, strlen(newlock)); | 621 | write(fd, newlock, strlen(newlock)); |
623 | close(fd); | 622 | close(fd); |
624 | modem_is_locked=true; | 623 | modem_is_locked=true; |
625 | 624 | ||
626 | return 0; | 625 | return 0; |
627 | } | 626 | } |
628 | 627 | ||
629 | return -1; | 628 | return -1; |
630 | 629 | ||
631 | } | 630 | } |
632 | 631 | ||
633 | 632 | ||
634 | // UnLock modem device | 633 | // UnLock modem device |
635 | void Modem::unlockdevice() { | 634 | void Modem::unlockdevice() { |
636 | if (modem_is_locked) { | 635 | if (modem_is_locked) { |
637 | qDebug( "UnLocking Modem Device" ); | 636 | qDebug( "UnLocking Modem Device" ); |
638 | close(modemfd); | 637 | close(modemfd); |
639 | modemfd = -1; | 638 | modemfd = -1; |
640 | unlink(lockfile); | 639 | unlink(lockfile); |
641 | lockfile[0] = '\0'; | 640 | lockfile[0] = '\0'; |
642 | modem_is_locked=false; | 641 | modem_is_locked=false; |
643 | } | 642 | } |
644 | } | 643 | } |
645 | 644 | ||
646 | int Modem::openLockfile( QString lockfile, int flags) | 645 | int Modem::openLockfile( QString lockfile, int flags) |
647 | { | 646 | { |
648 | int fd; | 647 | int fd; |
649 | int mode; | 648 | int mode; |
650 | flags = O_RDONLY; | 649 | flags = O_RDONLY; |
651 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 650 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
652 | mode = 0644; | 651 | mode = 0644; |
653 | else | 652 | else |
654 | mode = 0; | 653 | mode = 0; |
655 | 654 | ||
656 | lockfile = LOCK_DIR; | 655 | lockfile = LOCK_DIR; |
657 | lockfile += "/LCK.."; | 656 | lockfile += "/LCK.."; |
658 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 657 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
659 | qDebug("lockfile >%s<",lockfile.latin1()); | 658 | qDebug("lockfile >%s<",lockfile.latin1()); |
660 | // TODO: | 659 | // TODO: |
661 | // struct stat st; | 660 | // struct stat st; |
662 | // if(stat(lockfile.data(), &st) == -1) { | 661 | // if(stat(lockfile.data(), &st) == -1) { |
663 | // if(errno == EBADF) | 662 | // if(errno == EBADF) |
664 | // return -1; | 663 | // return -1; |
665 | // } else { | 664 | // } else { |
666 | // // make sure that this is a regular file | 665 | // // make sure that this is a regular file |
667 | // if(!S_ISREG(st.st_mode)) | 666 | // if(!S_ISREG(st.st_mode)) |
668 | // return -1; | 667 | // return -1; |
669 | // } | 668 | // } |
670 | if ((fd = open(lockfile, flags, mode)) == -1) { | 669 | if ((fd = open(lockfile, flags, mode)) == -1) { |
671 | qDebug("error opening lockfile!"); | 670 | qDebug("error opening lockfile!"); |
672 | lockfile = QString::null; | 671 | lockfile = QString::null; |
673 | fd = open(DEVNULL, O_RDONLY); | 672 | fd = open(DEVNULL, O_RDONLY); |
674 | } else | 673 | } else |
675 | fchown(fd, 0, 0); | 674 | fchown(fd, 0, 0); |
676 | return fd; | 675 | return fd; |
677 | } | 676 | } |
678 | 677 | ||
679 | 678 | ||
680 | 679 | ||
681 | void alarm_handler(int) { | 680 | void alarm_handler(int) { |
682 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 681 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
683 | 682 | ||
684 | // jump | 683 | // jump |
685 | siglongjmp(jmp_buffer, 1); | 684 | siglongjmp(jmp_buffer, 1); |
686 | } | 685 | } |
687 | 686 | ||
688 | 687 | ||
689 | const char* Modem::authFile(Auth method, int version) { | 688 | const char* Modem::authFile(Auth method, int version) { |
690 | switch(method|version) { | 689 | switch(method|version) { |
691 | case PAP|Original: | 690 | case PAP|Original: |
692 | return PAP_AUTH_FILE; | 691 | return PAP_AUTH_FILE; |
693 | break; | 692 | break; |
694 | case PAP|New: | 693 | case PAP|New: |
695 | return PAP_AUTH_FILE".new"; | 694 | return PAP_AUTH_FILE".new"; |
696 | break; | 695 | break; |
697 | case PAP|Old: | 696 | case PAP|Old: |
698 | return PAP_AUTH_FILE".old"; | 697 | return PAP_AUTH_FILE".old"; |
699 | break; | 698 | break; |
700 | case CHAP|Original: | 699 | case CHAP|Original: |
701 | return CHAP_AUTH_FILE; | 700 | return CHAP_AUTH_FILE; |
702 | break; | 701 | break; |
703 | case CHAP|New: | 702 | case CHAP|New: |
704 | return CHAP_AUTH_FILE".new"; | 703 | return CHAP_AUTH_FILE".new"; |
705 | break; | 704 | break; |
706 | case CHAP|Old: | 705 | case CHAP|Old: |
707 | return CHAP_AUTH_FILE".old"; | 706 | return CHAP_AUTH_FILE".old"; |
708 | break; | 707 | break; |
709 | default: | 708 | default: |
710 | return 0L; | 709 | return 0L; |
711 | } | 710 | } |
712 | } | 711 | } |
713 | 712 | ||
714 | 713 | ||
715 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { | 714 | bool Modem::createAuthFile(Auth method, const char *username, const char *password) { |
716 | const char *authfile, *oldName, *newName; | 715 | const char *authfile, *oldName, *newName; |
717 | char line[100]; | 716 | char line[100]; |
718 | char regexp[2*MaxStrLen+30]; | 717 | char regexp[2*MaxStrLen+30]; |
719 | regex_t preg; | 718 | regex_t preg; |
720 | 719 | ||
721 | if(!(authfile = authFile(method))) | 720 | if(!(authfile = authFile(method))) |
722 | return false; | 721 | return false; |
723 | 722 | ||
724 | if(!(newName = authFile(method, New))) | 723 | if(!(newName = authFile(method, New))) |
725 | return false; | 724 | return false; |
726 | 725 | ||
727 | // look for username, "username" or 'username' | 726 | // look for username, "username" or 'username' |
728 | // if you modify this RE you have to adapt regexp's size above | 727 | // if you modify this RE you have to adapt regexp's size above |
729 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", | 728 | snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", |
730 | username,username); | 729 | username,username); |
731 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); | 730 | MY_ASSERT(regcomp(&preg, regexp, 0) == 0); |
732 | 731 | ||
733 | // copy to new file pap- or chap-secrets | 732 | // copy to new file pap- or chap-secrets |
734 | int old_umask = umask(0077); | 733 | int old_umask = umask(0077); |
735 | FILE *fout = fopen(newName, "w"); | 734 | FILE *fout = fopen(newName, "w"); |
736 | if(fout) { | 735 | if(fout) { |
737 | // copy old file | 736 | // copy old file |
738 | FILE *fin = fopen(authfile, "r"); | 737 | FILE *fin = fopen(authfile, "r"); |
739 | if(fin) { | 738 | if(fin) { |
740 | while(fgets(line, sizeof(line), fin)) { | 739 | while(fgets(line, sizeof(line), fin)) { |
741 | if(regexec(&preg, line, 0, 0L, 0) == 0) | 740 | if(regexec(&preg, line, 0, 0L, 0) == 0) |
742 | continue; | 741 | continue; |
743 | fputs(line, fout); | 742 | fputs(line, fout); |
744 | } | 743 | } |
745 | fclose(fin); | 744 | fclose(fin); |
746 | } | 745 | } |
747 | 746 | ||
748 | // append user/pass pair | 747 | // append user/pass pair |
749 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); | 748 | fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); |
750 | fclose(fout); | 749 | fclose(fout); |
751 | } | 750 | } |
752 | 751 | ||
753 | // restore umask | 752 | // restore umask |
754 | umask(old_umask); | 753 | umask(old_umask); |
755 | 754 | ||
756 | // free memory allocated by regcomp | 755 | // free memory allocated by regcomp |
757 | regfree(&preg); | 756 | regfree(&preg); |
758 | 757 | ||
759 | if(!(oldName = authFile(method, Old))) | 758 | if(!(oldName = authFile(method, Old))) |
760 | return false; | 759 | return false; |
761 | 760 | ||
762 | // delete old file if any | 761 | // delete old file if any |
763 | unlink(oldName); | 762 | unlink(oldName); |
764 | 763 | ||
765 | rename(authfile, oldName); | 764 | rename(authfile, oldName); |
766 | rename(newName, authfile); | 765 | rename(newName, authfile); |
767 | 766 | ||
768 | return true; | 767 | return true; |
769 | } | 768 | } |
770 | 769 | ||
771 | 770 | ||
772 | bool Modem::removeAuthFile(Auth method) { | 771 | bool Modem::removeAuthFile(Auth method) { |
773 | const char *authfile, *oldName; | 772 | const char *authfile, *oldName; |
774 | 773 | ||
775 | if(!(authfile = authFile(method))) | 774 | if(!(authfile = authFile(method))) |
776 | return false; | 775 | return false; |
777 | if(!(oldName = authFile(method, Old))) | 776 | if(!(oldName = authFile(method, Old))) |
778 | return false; | 777 | return false; |
779 | 778 | ||
780 | if(access(oldName, F_OK) == 0) { | 779 | if(access(oldName, F_OK) == 0) { |
781 | unlink(authfile); | 780 | unlink(authfile); |
782 | return (rename(oldName, authfile) == 0); | 781 | return (rename(oldName, authfile) == 0); |
783 | } else | 782 | } else |
784 | return false; | 783 | return false; |
785 | } | 784 | } |
786 | 785 | ||
787 | 786 | ||
788 | bool Modem::setSecret(int method, const char* name, const char* password) | 787 | bool Modem::setSecret(int method, const char* name, const char* password) |
789 | { | 788 | { |
790 | 789 | ||
791 | Auth auth; | 790 | Auth auth; |
792 | if(method == AUTH_PAPCHAP) | 791 | if(method == AUTH_PAPCHAP) |
793 | return setSecret(AUTH_PAP, name, password) && | 792 | return setSecret(AUTH_PAP, name, password) && |
794 | setSecret(AUTH_CHAP, name, password); | 793 | setSecret(AUTH_CHAP, name, password); |
795 | 794 | ||
796 | switch(method) { | 795 | switch(method) { |
797 | case AUTH_PAP: | 796 | case AUTH_PAP: |
798 | auth = Modem::PAP; | 797 | auth = Modem::PAP; |
799 | break; | 798 | break; |
800 | case AUTH_CHAP: | 799 | case AUTH_CHAP: |
801 | auth = Modem::CHAP; | 800 | auth = Modem::CHAP; |
802 | break; | 801 | break; |
803 | default: | 802 | default: |
804 | return false; | 803 | return false; |
805 | } | 804 | } |
806 | 805 | ||
807 | return createAuthFile(auth, name, password); | 806 | return createAuthFile(auth, name, password); |
808 | 807 | ||
809 | } | 808 | } |
810 | 809 | ||
811 | bool Modem::removeSecret(int method) | 810 | bool Modem::removeSecret(int method) |
812 | { | 811 | { |
813 | Auth auth; | 812 | Auth auth; |
814 | 813 | ||
815 | switch(method) { | 814 | switch(method) { |
816 | case AUTH_PAP: | 815 | case AUTH_PAP: |
817 | auth = Modem::PAP; | 816 | auth = Modem::PAP; |
818 | break; | 817 | break; |
819 | case AUTH_CHAP: | 818 | case AUTH_CHAP: |
820 | auth = Modem::CHAP; | 819 | auth = Modem::CHAP; |
821 | break; | 820 | break; |
822 | default: | 821 | default: |
823 | return false; | 822 | return false; |
824 | } | 823 | } |
825 | return removeAuthFile( auth ); | 824 | return removeAuthFile( auth ); |
826 | } | 825 | } |
827 | 826 | ||
828 | int checkForInterface() | 827 | int checkForInterface() |
829 | { | 828 | { |
830 | // I don't know if Linux needs more initialization to get the ioctl to | 829 | // I don't know if Linux needs more initialization to get the ioctl to |
831 | // work, pppd seems to hint it does. But BSD doesn't, and the following | 830 | // work, pppd seems to hint it does. But BSD doesn't, and the following |
832 | // code should compile. | 831 | // code should compile. |
833 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) | 832 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) |
834 | int s, ok; | 833 | int s, ok; |
835 | struct ifreq ifr; | 834 | struct ifreq ifr; |
836 | // extern char *no_ppp_msg; | 835 | // extern char *no_ppp_msg; |
837 | 836 | ||
838 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | 837 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) |
839 | return 1; /* can't tell */ | 838 | return 1; /* can't tell */ |
840 | 839 | ||
841 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); | 840 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); |
842 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; | 841 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; |
843 | close(s); | 842 | close(s); |
844 | 843 | ||
845 | if (ok == -1) { | 844 | if (ok == -1) { |
846 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports | 845 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports |
847 | // KLDs, the old LKM interface couldn't handle loading devices | 846 | // KLDs, the old LKM interface couldn't handle loading devices |
848 | // dynamically, and thus can't load ppp support on the fly | 847 | // dynamically, and thus can't load ppp support on the fly |
849 | #ifdef __FreeBSD__ | 848 | #ifdef __FreeBSD__ |
850 | // If we failed to load ppp support and don't have it already. | 849 | // If we failed to load ppp support and don't have it already. |
851 | if (kldload("if_ppp") == -1) { | 850 | if (kldload("if_ppp") == -1) { |
852 | return -1; | 851 | return -1; |
853 | } | 852 | } |
854 | return 0; | 853 | return 0; |
855 | #else | 854 | #else |
856 | return -1; | 855 | return -1; |
857 | #endif | 856 | #endif |
858 | } | 857 | } |
859 | return 0; | 858 | return 0; |
860 | #else | 859 | #else |
861 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp | 860 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp |
862 | struct stat buf; | 861 | struct stat buf; |
863 | 862 | ||
864 | memset(&buf, 0, sizeof(buf)); | 863 | memset(&buf, 0, sizeof(buf)); |
865 | return stat("/dev/ppp", &buf); | 864 | return stat("/dev/ppp", &buf); |
866 | #endif | 865 | #endif |
867 | } | 866 | } |
868 | 867 | ||
869 | bool Modem::execpppd(const char *arguments) { | 868 | bool Modem::execpppd(const char *arguments) { |
870 | char buf[MAX_CMDLEN]; | 869 | char buf[MAX_CMDLEN]; |
871 | char *args[MaxArgs]; | 870 | char *args[MaxArgs]; |
872 | pid_t pgrpid; | 871 | pid_t pgrpid; |
873 | 872 | ||
874 | if(modemfd<0) | 873 | if(modemfd<0) |
875 | return false; | 874 | return false; |
876 | 875 | ||
877 | _pppdExitStatus = -1; | 876 | _pppdExitStatus = -1; |
878 | 877 | ||
879 | switch(pppdPid = fork()) | 878 | switch(pppdPid = fork()) |
880 | { | 879 | { |
881 | case -1: | 880 | case -1: |
882 | fprintf(stderr,"In parent: fork() failed\n"); | 881 | fprintf(stderr,"In parent: fork() failed\n"); |
883 | return false; | 882 | return false; |
884 | break; | 883 | break; |
885 | 884 | ||
886 | case 0: | 885 | case 0: |
887 | // let's parse the arguments the user supplied into UNIX suitable form | 886 | // let's parse the arguments the user supplied into UNIX suitable form |
888 | // that is a list of pointers each pointing to exactly one word | 887 | // that is a list of pointers each pointing to exactly one word |
889 | strlcpy(buf, arguments); | 888 | strlcpy(buf, arguments); |
890 | parseargs(buf, args); | 889 | parseargs(buf, args); |
891 | // become a session leader and let /dev/ttySx | 890 | // become a session leader and let /dev/ttySx |
892 | // be the controlling terminal. | 891 | // be the controlling terminal. |
893 | pgrpid = setsid(); | 892 | pgrpid = setsid(); |
894 | #ifdef TIOCSCTTY | 893 | #ifdef TIOCSCTTY |
895 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) | 894 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) |
896 | fprintf(stderr, "ioctl() failed.\n"); | 895 | fprintf(stderr, "ioctl() failed.\n"); |
897 | #elif defined (TIOCSPGRP) | 896 | #elif defined (TIOCSPGRP) |
898 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) | 897 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) |
899 | fprintf(stderr, "ioctl() failed.\n"); | 898 | fprintf(stderr, "ioctl() failed.\n"); |
900 | #endif | 899 | #endif |
901 | if(tcsetpgrp(modemfd, pgrpid)<0) | 900 | if(tcsetpgrp(modemfd, pgrpid)<0) |
902 | fprintf(stderr, "tcsetpgrp() failed.\n"); | 901 | fprintf(stderr, "tcsetpgrp() failed.\n"); |
903 | 902 | ||
904 | dup2(modemfd, 0); | 903 | dup2(modemfd, 0); |
905 | dup2(modemfd, 1); | 904 | dup2(modemfd, 1); |
906 | 905 | ||
907 | switch (checkForInterface()) { | 906 | switch (checkForInterface()) { |
908 | case 1: | 907 | case 1: |
909 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | 908 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); |
910 | break; | 909 | break; |
911 | case -1: | 910 | case -1: |
912 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 911 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
913 | break; | 912 | break; |
914 | case 0: | 913 | case 0: |
915 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 914 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
916 | break; | 915 | break; |
917 | } | 916 | } |
918 | 917 | ||
919 | execve(pppdPath(), args, 0L); | 918 | execve(pppdPath(), args, 0L); |
920 | _exit(0); | 919 | _exit(0); |
921 | break; | 920 | break; |
922 | 921 | ||
923 | default: | 922 | default: |
924 | qDebug("In parent: pppd pid %d\n",pppdPid); | 923 | qDebug("In parent: pppd pid %d\n",pppdPid); |
925 | close(modemfd); | 924 | close(modemfd); |
926 | modemfd = -1; | 925 | modemfd = -1; |
927 | return true; | 926 | return true; |
928 | break; | 927 | break; |
929 | } | 928 | } |
930 | } | 929 | } |
931 | 930 | ||
932 | 931 | ||
933 | bool Modem::killpppd() { | 932 | bool Modem::killpppd() { |
934 | if(pppdPid > 0) { | 933 | if(pppdPid > 0) { |
935 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | 934 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); |
936 | if(kill(pppdPid, SIGTERM) < 0) { | 935 | if(kill(pppdPid, SIGTERM) < 0) { |
937 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | 936 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); |
938 | if(kill(pppdPid, SIGKILL) < 0) { | 937 | if(kill(pppdPid, SIGKILL) < 0) { |
939 | qDebug("Error killing %d\n", pppdPid); | 938 | qDebug("Error killing %d\n", pppdPid); |
940 | return false; | 939 | return false; |
941 | } | 940 | } |
942 | } | 941 | } |
943 | } | 942 | } |
944 | return true; | 943 | return true; |
945 | } | 944 | } |
946 | 945 | ||
947 | 946 | ||
948 | void Modem::parseargs(char* buf, char** args) { | 947 | void Modem::parseargs(char* buf, char** args) { |
949 | int nargs = 0; | 948 | int nargs = 0; |
950 | int quotes; | 949 | int quotes; |
951 | 950 | ||
952 | while(nargs < MaxArgs-1 && *buf != '\0') { | 951 | while(nargs < MaxArgs-1 && *buf != '\0') { |
953 | 952 | ||
954 | quotes = 0; | 953 | quotes = 0; |
955 | 954 | ||
956 | // Strip whitespace. Use nulls, so that the previous argument is | 955 | // Strip whitespace. Use nulls, so that the previous argument is |
957 | // terminated automatically. | 956 | // terminated automatically. |
958 | 957 | ||
959 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) | 958 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) |
960 | *buf++ = '\0'; | 959 | *buf++ = '\0'; |
961 | 960 | ||
962 | // detect begin of quoted argument | 961 | // detect begin of quoted argument |
963 | if (*buf == '"' || *buf == '\'') { | 962 | if (*buf == '"' || *buf == '\'') { |
964 | quotes = *buf; | 963 | quotes = *buf; |
965 | *buf++ = '\0'; | 964 | *buf++ = '\0'; |
966 | } | 965 | } |
967 | 966 | ||
968 | // save the argument | 967 | // save the argument |
969 | if(*buf != '\0') { | 968 | if(*buf != '\0') { |
970 | *args++ = buf; | 969 | *args++ = buf; |
971 | nargs++; | 970 | nargs++; |
972 | } | 971 | } |
973 | 972 | ||
974 | if (!quotes) | 973 | if (!quotes) |
975 | while ((*buf != '\0') && (*buf != '\n') && | 974 | while ((*buf != '\0') && (*buf != '\n') && |
976 | (*buf != '\t') && (*buf != ' ')) | 975 | (*buf != '\t') && (*buf != ' ')) |
977 | buf++; | 976 | buf++; |
978 | else { | 977 | else { |
979 | while ((*buf != '\0') && (*buf != quotes)) | 978 | while ((*buf != '\0') && (*buf != quotes)) |
980 | buf++; | 979 | buf++; |
981 | *buf++ = '\0'; | 980 | *buf++ = '\0'; |
982 | } | 981 | } |
983 | } | 982 | } |
984 | 983 | ||
985 | *args = 0L; | 984 | *args = 0L; |
986 | } | 985 | } |
987 | 986 | ||
988 | bool Modem::execPPPDaemon(const QString & arguments) | 987 | bool Modem::execPPPDaemon(const QString & arguments) |
989 | { | 988 | { |
990 | if(execpppd(arguments)==0) { | 989 | if(execpppd(arguments)==0) { |
991 | PPPData::data()->setpppdRunning(true); | 990 | _pppdata->setpppdRunning(true); |
992 | return true; | 991 | return true; |
993 | } else | 992 | } else |
994 | return false; | 993 | return false; |
995 | } | 994 | } |
996 | 995 | ||
997 | void Modem::killPPPDaemon() | 996 | void Modem::killPPPDaemon() |
998 | { | 997 | { |
999 | PPPData::data()->setpppdRunning(false); | 998 | _pppdata->setpppdRunning(false); |
1000 | killpppd(); | 999 | killpppd(); |
1001 | } | 1000 | } |
1002 | 1001 | ||
1003 | int Modem::pppdExitStatus() | 1002 | int Modem::pppdExitStatus() |
1004 | { | 1003 | { |
1005 | return _pppdExitStatus; | 1004 | return _pppdExitStatus; |
1006 | } | 1005 | } |
1007 | 1006 | ||
1008 | int Modem::openResolv(int flags) | 1007 | int Modem::openResolv(int flags) |
1009 | { | 1008 | { |
1010 | int fd; | 1009 | int fd; |
1011 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1010 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1012 | qDebug("error opening resolv.conf!"); | 1011 | qDebug("error opening resolv.conf!"); |
1013 | fd = open(DEVNULL, O_RDONLY); | 1012 | fd = open(DEVNULL, O_RDONLY); |
1014 | } | 1013 | } |
1015 | return fd; | 1014 | return fd; |
1016 | } | 1015 | } |
1017 | 1016 | ||
1018 | bool Modem::setHostname(const QString & name) | 1017 | bool Modem::setHostname(const QString & name) |
1019 | { | 1018 | { |
1020 | return sethostname(name, name.length()) == 0; | 1019 | return sethostname(name, name.length()) == 0; |
1021 | } | 1020 | } |
1022 | 1021 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h index b494977..103cbeb 100644 --- a/noncore/settings/networksettings/ppp/modem.h +++ b/noncore/settings/networksettings/ppp/modem.h | |||
@@ -1,119 +1,120 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _MODEM_H_ | 27 | #ifndef _MODEM_H_ |
28 | #define _MODEM_H_ | 28 | #define _MODEM_H_ |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | 31 | ||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <termios.h> | 33 | #include <termios.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | 35 | ||
36 | #include <qsocketnotifier.h> | 36 | #include <qsocketnotifier.h> |
37 | 37 | ||
38 | //#include <config.h> | 38 | class PPPData; |
39 | 39 | ||
40 | void alarm_handler(int); | 40 | void alarm_handler(int); |
41 | const char *pppdPath(); | 41 | const char *pppdPath(); |
42 | 42 | ||
43 | class Modem : public QObject { | 43 | class Modem : public QObject { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | Modem(); | 46 | Modem(PPPData*); |
47 | ~Modem(); | 47 | ~Modem(); |
48 | 48 | ||
49 | const QString getDevice() {return device;}; | 49 | const QString getDevice() {return device;}; |
50 | void setDevice(const QString dev) {device = dev;}; | 50 | void setDevice(const QString dev) {device = dev;}; |
51 | 51 | ||
52 | bool opentty(); | 52 | bool opentty(); |
53 | bool closetty(); | 53 | bool closetty(); |
54 | bool hangup(); | 54 | bool hangup(); |
55 | bool writeChar(unsigned char); | 55 | bool writeChar(unsigned char); |
56 | bool writeLine(const char *); | 56 | bool writeLine(const char *); |
57 | bool dataMode() const { return data_mode; } | 57 | bool dataMode() const { return data_mode; } |
58 | void setDataMode(bool set) { data_mode = set; } | 58 | void setDataMode(bool set) { data_mode = set; } |
59 | const QString modemMessage(); | 59 | const QString modemMessage(); |
60 | speed_t modemspeed(); | 60 | speed_t modemspeed(); |
61 | static QString parseModemSpeed(const QString &); | 61 | static QString parseModemSpeed(const QString &); |
62 | void notify(const QObject *, const char *); | 62 | void notify(const QObject *, const char *); |
63 | void stop(); | 63 | void stop(); |
64 | void flush(); | 64 | void flush(); |
65 | 65 | ||
66 | int lockdevice(); | 66 | int lockdevice(); |
67 | void unlockdevice(); | 67 | void unlockdevice(); |
68 | 68 | ||
69 | bool setSecret(int,const char*,const char*); | 69 | bool setSecret(int,const char*,const char*); |
70 | bool removeSecret(int); | 70 | bool removeSecret(int); |
71 | void killPPPDaemon(); | 71 | void killPPPDaemon(); |
72 | int pppdExitStatus(); | 72 | int pppdExitStatus(); |
73 | bool execPPPDaemon(const QString & arguments); | 73 | bool execPPPDaemon(const QString & arguments); |
74 | int openResolv(int flags); | 74 | int openResolv(int flags); |
75 | bool setHostname(const QString & name); | 75 | bool setHostname(const QString & name); |
76 | 76 | ||
77 | public: | 77 | public: |
78 | enum Auth { PAP = 1, CHAP }; | 78 | enum Auth { PAP = 1, CHAP }; |
79 | static Modem *modem; | 79 | // static Modem *modem; |
80 | int lastStatus; | 80 | int lastStatus; |
81 | 81 | ||
82 | signals: | 82 | signals: |
83 | void charWaiting(unsigned char); | 83 | void charWaiting(unsigned char); |
84 | 84 | ||
85 | private slots: | 85 | private slots: |
86 | void startNotifier(); | 86 | void startNotifier(); |
87 | void stopNotifier(); | 87 | void stopNotifier(); |
88 | void readtty(int); | 88 | void readtty(int); |
89 | 89 | ||
90 | private: | 90 | private: |
91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; | 91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; |
92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; | 92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; |
93 | 93 | ||
94 | const char* authFile(Auth method, int version = Original ); | 94 | const char* authFile(Auth method, int version = Original ); |
95 | bool createAuthFile(Auth method,const char *username,const char *password); | 95 | bool createAuthFile(Auth method,const char *username,const char *password); |
96 | bool removeAuthFile(Auth method); | 96 | bool removeAuthFile(Auth method); |
97 | bool execpppd(const char *arguments); | 97 | bool execpppd(const char *arguments); |
98 | bool killpppd(); | 98 | bool killpppd(); |
99 | void parseargs(char* buf, char** args); | 99 | void parseargs(char* buf, char** args); |
100 | void escape_to_command_mode(); | 100 | void escape_to_command_mode(); |
101 | int openLockfile(QString,int); | 101 | int openLockfile(QString,int); |
102 | 102 | ||
103 | private: | 103 | private: |
104 | QString device; | 104 | QString device; |
105 | QString lockfile; | 105 | QString lockfile; |
106 | int modemfd; | 106 | int modemfd; |
107 | int pppdPid; | 107 | int pppdPid; |
108 | int _pppdExitStatus; | 108 | int _pppdExitStatus; |
109 | QSocketNotifier *sn; | 109 | QSocketNotifier *sn; |
110 | bool data_mode; | 110 | bool data_mode; |
111 | QString errmsg; | 111 | QString errmsg; |
112 | struct termios initial_tty; | 112 | struct termios initial_tty; |
113 | struct termios tty; | 113 | struct termios tty; |
114 | bool modem_is_locked; | 114 | bool modem_is_locked; |
115 | PPPData *_pppdata; | ||
115 | }; | 116 | }; |
116 | 117 | ||
117 | #endif | 118 | #endif |
118 | 119 | ||
119 | 120 | ||
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp index 65032e8..1d9db6e 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.cpp +++ b/noncore/settings/networksettings/ppp/modemcmds.cpp | |||
@@ -1,318 +1,318 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A front end for pppd for the KDE project | 2 | * kPPP: A front end for pppd for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This library is free software; you can redistribute it and/or | 12 | * This library is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This library is distributed in the hope that it will be useful, | 17 | * This library is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with dummyWidget program; if not, write to the Free | 23 | * License along with dummyWidget program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qslider.h> | 28 | #include <qslider.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | //#include <kapplication.h> // for getMiniIcon() | 31 | //#include <kapplication.h> // for getMiniIcon() |
32 | //#include <klocale.h> | 32 | //#include <klocale.h> |
33 | #define i18n QObject::tr | 33 | #define i18n QObject::tr |
34 | #include "modemcmds.h" | 34 | #include "modemcmds.h" |
35 | #include "pppdata.h" | 35 | #include "pppdata.h" |
36 | //#include <kwin.h> | 36 | //#include <kwin.h> |
37 | 37 | ||
38 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); | 38 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); |
39 | 39 | ||
40 | // a little trick to make the label look like a disabled lineedit | 40 | // a little trick to make the label look like a disabled lineedit |
41 | #define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); | 41 | #define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); |
42 | 42 | ||
43 | ModemCommands::ModemCommands(QWidget *parent, const char *name) | 43 | ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name) |
44 | : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel) | 44 | : QDialog(parent, name, true ), _pppdata(pd) |
45 | { | 45 | { |
46 | setCaption(i18n("Edit Modem Commands")); | 46 | setCaption(i18n("Edit Modem Commands")); |
47 | 47 | ||
48 | const int GRIDROWS = 22; | 48 | const int GRIDROWS = 22; |
49 | int row = 0; | 49 | int row = 0; |
50 | 50 | ||
51 | // toplevel layout | 51 | // toplevel layout |
52 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); | 52 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); |
53 | 53 | ||
54 | // add grid + frame | 54 | // add grid + frame |
55 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); | 55 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); |
56 | tl->addLayout(l1); | 56 | tl->addLayout(l1); |
57 | box = new QGroupBox(this, "box"); | 57 | box = new QGroupBox(this, "box"); |
58 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); | 58 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); |
59 | 59 | ||
60 | // put slider and label into a separate H-Box | 60 | // put slider and label into a separate H-Box |
61 | QHBoxLayout *l2 = new QHBoxLayout; | 61 | QHBoxLayout *l2 = new QHBoxLayout; |
62 | l1->addLayout(l2, row, 2); | 62 | l1->addLayout(l2, row, 2); |
63 | lpreinitslider = new QLabel("MMMM", this); | 63 | lpreinitslider = new QLabel("MMMM", this); |
64 | FORMATSLIDERLABEL(lpreinitslider); | 64 | FORMATSLIDERLABEL(lpreinitslider); |
65 | 65 | ||
66 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, | 66 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, |
67 | QSlider::Horizontal, this); | 67 | QSlider::Horizontal, this); |
68 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); | 68 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); |
69 | connect(preinitslider, SIGNAL(valueChanged(int)), | 69 | connect(preinitslider, SIGNAL(valueChanged(int)), |
70 | lpreinitslider, SLOT(setNum(int))); | 70 | lpreinitslider, SLOT(setNum(int))); |
71 | l2->addWidget(lpreinitslider, 0); | 71 | l2->addWidget(lpreinitslider, 0); |
72 | l2->addWidget(preinitslider, 1); | 72 | l2->addWidget(preinitslider, 1); |
73 | 73 | ||
74 | lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); | 74 | lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); |
75 | l1->addWidget(lpreinit, row++, 1); | 75 | l1->addWidget(lpreinit, row++, 1); |
76 | 76 | ||
77 | for(int i = 0; i < PPPData::NumInitStrings; i++) { | 77 | for(int i = 0; i < PPPData::NumInitStrings; i++) { |
78 | initstr[i] = new QLineEdit(this); | 78 | initstr[i] = new QLineEdit(this); |
79 | QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), | 79 | QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), |
80 | this); | 80 | this); |
81 | ADJUSTEDIT(initstr[i]); | 81 | ADJUSTEDIT(initstr[i]); |
82 | l1->addWidget(initLabel, row, 1); | 82 | l1->addWidget(initLabel, row, 1); |
83 | l1->addWidget(initstr[i], row++, 2); | 83 | l1->addWidget(initstr[i], row++, 2); |
84 | } | 84 | } |
85 | 85 | ||
86 | QHBoxLayout *l3 = new QHBoxLayout; | 86 | QHBoxLayout *l3 = new QHBoxLayout; |
87 | l1->addLayout(l3, row, 2); | 87 | l1->addLayout(l3, row, 2); |
88 | linitslider = new QLabel("MMMM", this); | 88 | linitslider = new QLabel("MMMM", this); |
89 | FORMATSLIDERLABEL(linitslider); | 89 | FORMATSLIDERLABEL(linitslider); |
90 | QSlider *initslider = new QSlider(1, 300, 1, 0, | 90 | QSlider *initslider = new QSlider(1, 300, 1, 0, |
91 | QSlider::Horizontal, this); | 91 | QSlider::Horizontal, this); |
92 | // initslider->setFixedHeight(initslider->sizeHint().height()); | 92 | // initslider->setFixedHeight(initslider->sizeHint().height()); |
93 | connect(initslider, SIGNAL(valueChanged(int)), | 93 | connect(initslider, SIGNAL(valueChanged(int)), |
94 | linitslider, SLOT(setNum(int))); | 94 | linitslider, SLOT(setNum(int))); |
95 | l3->addWidget(linitslider, 0); | 95 | l3->addWidget(linitslider, 0); |
96 | l3->addWidget(initslider, 1); | 96 | l3->addWidget(initslider, 1); |
97 | 97 | ||
98 | label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); | 98 | label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); |
99 | l1->addWidget(label3, row++, 1); | 99 | l1->addWidget(label3, row++, 1); |
100 | 100 | ||
101 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ | 101 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ |
102 | QHBoxLayout *l4 = new QHBoxLayout; | 102 | QHBoxLayout *l4 = new QHBoxLayout; |
103 | l1->addLayout(l4, row, 2); | 103 | l1->addLayout(l4, row, 2); |
104 | ldurationslider = new QLabel("MMMM", this); | 104 | ldurationslider = new QLabel("MMMM", this); |
105 | FORMATSLIDERLABEL(ldurationslider); | 105 | FORMATSLIDERLABEL(ldurationslider); |
106 | QSlider *durationslider = new QSlider(1, 255, 1, 0, | 106 | QSlider *durationslider = new QSlider(1, 255, 1, 0, |
107 | QSlider::Horizontal, this); | 107 | QSlider::Horizontal, this); |
108 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); | 108 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); |
109 | connect(durationslider, SIGNAL(valueChanged(int)), | 109 | connect(durationslider, SIGNAL(valueChanged(int)), |
110 | ldurationslider, SLOT(setNum(int))); | 110 | ldurationslider, SLOT(setNum(int))); |
111 | l4->addWidget(ldurationslider, 0); | 111 | l4->addWidget(ldurationslider, 0); |
112 | l4->addWidget(durationslider, 1); | 112 | l4->addWidget(durationslider, 1); |
113 | 113 | ||
114 | lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); | 114 | lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); |
115 | l1->addWidget(lduration, row++, 1); | 115 | l1->addWidget(lduration, row++, 1); |
116 | 116 | ||
117 | 117 | ||
118 | initresp = new QLineEdit(this); | 118 | initresp = new QLineEdit(this); |
119 | label2 = new QLabel(i18n("Init response:"), this); | 119 | label2 = new QLabel(i18n("Init response:"), this); |
120 | ADJUSTEDIT(initresp); | 120 | ADJUSTEDIT(initresp); |
121 | l1->addWidget(label2, row, 1); | 121 | l1->addWidget(label2, row, 1); |
122 | l1->addWidget(initresp, row++, 2); | 122 | l1->addWidget(initresp, row++, 2); |
123 | 123 | ||
124 | nodetectdialtone = new QLineEdit(this); | 124 | nodetectdialtone = new QLineEdit(this); |
125 | lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); | 125 | lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); |
126 | ADJUSTEDIT(nodetectdialtone); | 126 | ADJUSTEDIT(nodetectdialtone); |
127 | l1->addWidget(lnodetectdialtone, row, 1); | 127 | l1->addWidget(lnodetectdialtone, row, 1); |
128 | l1->addWidget(nodetectdialtone, row++, 2); | 128 | l1->addWidget(nodetectdialtone, row++, 2); |
129 | 129 | ||
130 | dialstr = new QLineEdit(this); | 130 | dialstr = new QLineEdit(this); |
131 | label4 = new QLabel(i18n("Dial string:"),this); | 131 | label4 = new QLabel(i18n("Dial string:"),this); |
132 | ADJUSTEDIT(dialstr); | 132 | ADJUSTEDIT(dialstr); |
133 | l1->addWidget(label4, row, 1); | 133 | l1->addWidget(label4, row, 1); |
134 | l1->addWidget(dialstr, row++, 2); | 134 | l1->addWidget(dialstr, row++, 2); |
135 | 135 | ||
136 | connectresp = new QLineEdit(this); | 136 | connectresp = new QLineEdit(this); |
137 | label5 = new QLabel(i18n("Connect response:"), this); | 137 | label5 = new QLabel(i18n("Connect response:"), this); |
138 | ADJUSTEDIT(connectresp); | 138 | ADJUSTEDIT(connectresp); |
139 | l1->addWidget(label5, row, 1); | 139 | l1->addWidget(label5, row, 1); |
140 | l1->addWidget(connectresp, row++, 2); | 140 | l1->addWidget(connectresp, row++, 2); |
141 | 141 | ||
142 | busyresp = new QLineEdit(this); | 142 | busyresp = new QLineEdit(this); |
143 | label6 = new QLabel(i18n("Busy response:"), this); | 143 | label6 = new QLabel(i18n("Busy response:"), this); |
144 | ADJUSTEDIT(busyresp); | 144 | ADJUSTEDIT(busyresp); |
145 | l1->addWidget(label6, row, 1); | 145 | l1->addWidget(label6, row, 1); |
146 | l1->addWidget(busyresp, row++, 2); | 146 | l1->addWidget(busyresp, row++, 2); |
147 | 147 | ||
148 | nocarrierresp = new QLineEdit(this); | 148 | nocarrierresp = new QLineEdit(this); |
149 | label7 = new QLabel(i18n("No carrier response:"), this); | 149 | label7 = new QLabel(i18n("No carrier response:"), this); |
150 | ADJUSTEDIT(nocarrierresp); | 150 | ADJUSTEDIT(nocarrierresp); |
151 | l1->addWidget(label7, row, 1); | 151 | l1->addWidget(label7, row, 1); |
152 | l1->addWidget(nocarrierresp, row++, 2); | 152 | l1->addWidget(nocarrierresp, row++, 2); |
153 | 153 | ||
154 | nodialtoneresp = new QLineEdit(this); | 154 | nodialtoneresp = new QLineEdit(this); |
155 | label8 = new QLabel(i18n("No dial tone response:"), this); | 155 | label8 = new QLabel(i18n("No dial tone response:"), this); |
156 | ADJUSTEDIT(nodialtoneresp); | 156 | ADJUSTEDIT(nodialtoneresp); |
157 | l1->addWidget(label8, row, 1); | 157 | l1->addWidget(label8, row, 1); |
158 | l1->addWidget(nodialtoneresp, row++, 2); | 158 | l1->addWidget(nodialtoneresp, row++, 2); |
159 | 159 | ||
160 | hangupstr = new QLineEdit(this); | 160 | hangupstr = new QLineEdit(this); |
161 | label9 = new QLabel(i18n("Hangup string:"), this); | 161 | label9 = new QLabel(i18n("Hangup string:"), this); |
162 | ADJUSTEDIT(hangupstr); | 162 | ADJUSTEDIT(hangupstr); |
163 | l1->addWidget(label9, row, 1); | 163 | l1->addWidget(label9, row, 1); |
164 | l1->addWidget(hangupstr, row++, 2); | 164 | l1->addWidget(hangupstr, row++, 2); |
165 | 165 | ||
166 | hangupresp = new QLineEdit(this); | 166 | hangupresp = new QLineEdit(this); |
167 | label10 = new QLabel(i18n("Hangup response:"), this); | 167 | label10 = new QLabel(i18n("Hangup response:"), this); |
168 | ADJUSTEDIT(hangupresp); | 168 | ADJUSTEDIT(hangupresp); |
169 | l1->addWidget(label10, row, 1); | 169 | l1->addWidget(label10, row, 1); |
170 | l1->addWidget(hangupresp, row++, 2); | 170 | l1->addWidget(hangupresp, row++, 2); |
171 | 171 | ||
172 | answerstr = new QLineEdit(this); | 172 | answerstr = new QLineEdit(this); |
173 | label11 = new QLabel(i18n("Answer string:"), this); | 173 | label11 = new QLabel(i18n("Answer string:"), this); |
174 | ADJUSTEDIT(answerstr); | 174 | ADJUSTEDIT(answerstr); |
175 | l1->addWidget(label11, row, 1); | 175 | l1->addWidget(label11, row, 1); |
176 | l1->addWidget(answerstr, row++, 2); | 176 | l1->addWidget(answerstr, row++, 2); |
177 | 177 | ||
178 | ringresp = new QLineEdit(this); | 178 | ringresp = new QLineEdit(this); |
179 | label12 = new QLabel(i18n("Ring response:"), this); | 179 | label12 = new QLabel(i18n("Ring response:"), this); |
180 | ADJUSTEDIT(ringresp); | 180 | ADJUSTEDIT(ringresp); |
181 | l1->addWidget(label12, row, 1); | 181 | l1->addWidget(label12, row, 1); |
182 | l1->addWidget(ringresp, row++, 2); | 182 | l1->addWidget(ringresp, row++, 2); |
183 | 183 | ||
184 | answerresp = new QLineEdit(this); | 184 | answerresp = new QLineEdit(this); |
185 | label13 = new QLabel(i18n("Answer response:"), this); | 185 | label13 = new QLabel(i18n("Answer response:"), this); |
186 | ADJUSTEDIT(answerresp); | 186 | ADJUSTEDIT(answerresp); |
187 | l1->addWidget(label13, row, 1); | 187 | l1->addWidget(label13, row, 1); |
188 | l1->addWidget(answerresp, row++, 2); | 188 | l1->addWidget(answerresp, row++, 2); |
189 | 189 | ||
190 | escapestr = new QLineEdit(this); | 190 | escapestr = new QLineEdit(this); |
191 | label14 = new QLabel(i18n("Escape string:"), this); | 191 | label14 = new QLabel(i18n("Escape string:"), this); |
192 | ADJUSTEDIT(escapestr); | 192 | ADJUSTEDIT(escapestr); |
193 | l1->addWidget(label14, row, 1); | 193 | l1->addWidget(label14, row, 1); |
194 | l1->addWidget(escapestr, row++, 2); | 194 | l1->addWidget(escapestr, row++, 2); |
195 | 195 | ||
196 | escaperesp = new QLineEdit(this); | 196 | escaperesp = new QLineEdit(this); |
197 | label15 = new QLabel(i18n("Escape response:"), this); | 197 | label15 = new QLabel(i18n("Escape response:"), this); |
198 | ADJUSTEDIT(escaperesp); | 198 | ADJUSTEDIT(escaperesp); |
199 | l1->addWidget(label15, row, 1); | 199 | l1->addWidget(label15, row, 1); |
200 | l1->addWidget(escaperesp, row++, 2); | 200 | l1->addWidget(escaperesp, row++, 2); |
201 | 201 | ||
202 | QHBoxLayout *l5 = new QHBoxLayout; | 202 | QHBoxLayout *l5 = new QHBoxLayout; |
203 | l1->addLayout(l5, row, 2); | 203 | l1->addLayout(l5, row, 2); |
204 | lslider = new QLabel("MMMM", this); | 204 | lslider = new QLabel("MMMM", this); |
205 | FORMATSLIDERLABEL(lslider); | 205 | FORMATSLIDERLABEL(lslider); |
206 | 206 | ||
207 | QSlider *slider = new QSlider(0, 255, 1, 0, | 207 | QSlider *slider = new QSlider(0, 255, 1, 0, |
208 | QSlider::Horizontal, this); | 208 | QSlider::Horizontal, this); |
209 | // slider->setFixedHeight(slider->sizeHint().height()); | 209 | // slider->setFixedHeight(slider->sizeHint().height()); |
210 | connect(slider, SIGNAL(valueChanged(int)), | 210 | connect(slider, SIGNAL(valueChanged(int)), |
211 | lslider, SLOT(setNum(int))); | 211 | lslider, SLOT(setNum(int))); |
212 | l5->addWidget(lslider, 0); | 212 | l5->addWidget(lslider, 0); |
213 | l5->addWidget(slider, 1); | 213 | l5->addWidget(slider, 1); |
214 | 214 | ||
215 | label16 = new QLabel(i18n("Guard time (sec/50):"), this); | 215 | label16 = new QLabel(i18n("Guard time (sec/50):"), this); |
216 | l1->addWidget(label16, row++, 1); | 216 | l1->addWidget(label16, row++, 1); |
217 | 217 | ||
218 | QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); | 218 | QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); |
219 | l1->addWidget(l, row, 1); | 219 | l1->addWidget(l, row, 1); |
220 | QHBoxLayout *l6 = new QHBoxLayout; | 220 | QHBoxLayout *l6 = new QHBoxLayout; |
221 | l1->addLayout(l6, row++, 2); | 221 | l1->addLayout(l6, row++, 2); |
222 | volume_off = new QLineEdit(this); | 222 | volume_off = new QLineEdit(this); |
223 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); | 223 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); |
224 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); | 224 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); |
225 | volume_medium = new QLineEdit(this); | 225 | volume_medium = new QLineEdit(this); |
226 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); | 226 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); |
227 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); | 227 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); |
228 | volume_high = new QLineEdit(this); | 228 | volume_high = new QLineEdit(this); |
229 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); | 229 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); |
230 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); | 230 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); |
231 | l6->addWidget(volume_off); | 231 | l6->addWidget(volume_off); |
232 | l6->addWidget(volume_medium); | 232 | l6->addWidget(volume_medium); |
233 | l6->addWidget(volume_high); | 233 | l6->addWidget(volume_high); |
234 | 234 | ||
235 | initstr[0]->setFocus(); | 235 | initstr[0]->setFocus(); |
236 | 236 | ||
237 | l1->addColSpacing(0, 10); | 237 | l1->addColSpacing(0, 10); |
238 | l1->addColSpacing(3, 10); | 238 | l1->addColSpacing(3, 10); |
239 | l1->addRowSpacing(0, 5); | 239 | l1->addRowSpacing(0, 5); |
240 | l1->addRowSpacing(GRIDROWS, 5); | 240 | l1->addRowSpacing(GRIDROWS, 5); |
241 | 241 | ||
242 | //set stuff from gpppdata | 242 | //set stuff from gpppdata |
243 | preinitslider->setValue(PPPData::data()->modemPreInitDelay()); | 243 | preinitslider->setValue(_pppdata->modemPreInitDelay()); |
244 | lpreinitslider->setNum(PPPData::data()->modemPreInitDelay()); | 244 | lpreinitslider->setNum(_pppdata->modemPreInitDelay()); |
245 | for(int i = 0; i < PPPData::NumInitStrings; i++) | 245 | for(int i = 0; i < PPPData::NumInitStrings; i++) |
246 | initstr[i]->setText(PPPData::data()->modemInitStr(i)); | 246 | initstr[i]->setText(_pppdata->modemInitStr(i)); |
247 | initslider->setValue(PPPData::data()->modemInitDelay()); | 247 | initslider->setValue(_pppdata->modemInitDelay()); |
248 | linitslider->setNum(PPPData::data()->modemInitDelay()); | 248 | linitslider->setNum(_pppdata->modemInitDelay()); |
249 | initresp->setText(PPPData::data()->modemInitResp()); | 249 | initresp->setText(_pppdata->modemInitResp()); |
250 | 250 | ||
251 | durationslider->setValue(PPPData::data()->modemToneDuration()); | 251 | durationslider->setValue(_pppdata->modemToneDuration()); |
252 | ldurationslider->setNum(PPPData::data()->modemToneDuration()); | 252 | ldurationslider->setNum(_pppdata->modemToneDuration()); |
253 | 253 | ||
254 | nodetectdialtone->setText(PPPData::data()->modemNoDialToneDetectionStr()); | 254 | nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr()); |
255 | dialstr->setText(PPPData::data()->modemDialStr()); | 255 | dialstr->setText(_pppdata->modemDialStr()); |
256 | connectresp->setText(PPPData::data()->modemConnectResp()); | 256 | connectresp->setText(_pppdata->modemConnectResp()); |
257 | busyresp->setText(PPPData::data()->modemBusyResp()); | 257 | busyresp->setText(_pppdata->modemBusyResp()); |
258 | nocarrierresp->setText(PPPData::data()->modemNoCarrierResp()); | 258 | nocarrierresp->setText(_pppdata->modemNoCarrierResp()); |
259 | nodialtoneresp->setText(PPPData::data()->modemNoDialtoneResp()); | 259 | nodialtoneresp->setText(_pppdata->modemNoDialtoneResp()); |
260 | 260 | ||
261 | escapestr->setText(PPPData::data()->modemEscapeStr()); | 261 | escapestr->setText(_pppdata->modemEscapeStr()); |
262 | escaperesp->setText(PPPData::data()->modemEscapeResp()); | 262 | escaperesp->setText(_pppdata->modemEscapeResp()); |
263 | 263 | ||
264 | hangupstr->setText(PPPData::data()->modemHangupStr()); | 264 | hangupstr->setText(_pppdata->modemHangupStr()); |
265 | hangupresp->setText(PPPData::data()->modemHangupResp()); | 265 | hangupresp->setText(_pppdata->modemHangupResp()); |
266 | 266 | ||
267 | answerstr->setText(PPPData::data()->modemAnswerStr()); | 267 | answerstr->setText(_pppdata->modemAnswerStr()); |
268 | ringresp->setText(PPPData::data()->modemRingResp()); | 268 | ringresp->setText(_pppdata->modemRingResp()); |
269 | answerresp->setText(PPPData::data()->modemAnswerResp()); | 269 | answerresp->setText(_pppdata->modemAnswerResp()); |
270 | 270 | ||
271 | slider->setValue(PPPData::data()->modemEscapeGuardTime()); | 271 | slider->setValue(_pppdata->modemEscapeGuardTime()); |
272 | lslider->setNum(PPPData::data()->modemEscapeGuardTime()); | 272 | lslider->setNum(_pppdata->modemEscapeGuardTime()); |
273 | 273 | ||
274 | volume_off->setText(PPPData::data()->volumeOff()); | 274 | volume_off->setText(_pppdata->volumeOff()); |
275 | volume_medium->setText(PPPData::data()->volumeMedium()); | 275 | volume_medium->setText(_pppdata->volumeMedium()); |
276 | volume_high->setText(PPPData::data()->volumeHigh()); | 276 | volume_high->setText(_pppdata->volumeHigh()); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | void ModemCommands::slotOk() { | 280 | void ModemCommands::slotOk() { |
281 | PPPData::data()->setModemPreInitDelay(lpreinitslider->text().toInt()); | 281 | _pppdata->setModemPreInitDelay(lpreinitslider->text().toInt()); |
282 | for(int i = 0; i < PPPData::NumInitStrings; i++) | 282 | for(int i = 0; i < PPPData::NumInitStrings; i++) |
283 | PPPData::data()->setModemInitStr(i, initstr[i]->text()); | 283 | _pppdata->setModemInitStr(i, initstr[i]->text()); |
284 | PPPData::data()->setModemInitResp(initresp->text()); | 284 | _pppdata->setModemInitResp(initresp->text()); |
285 | PPPData::data()->setModemInitDelay(linitslider->text().toInt()); | 285 | _pppdata->setModemInitDelay(linitslider->text().toInt()); |
286 | 286 | ||
287 | PPPData::data()->setModemToneDuration(ldurationslider->text().toInt()); | 287 | _pppdata->setModemToneDuration(ldurationslider->text().toInt()); |
288 | PPPData::data()->setModemNoDialToneDetectionStr(nodetectdialtone->text()); | 288 | _pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text()); |
289 | PPPData::data()->setModemDialStr(dialstr->text()); | 289 | _pppdata->setModemDialStr(dialstr->text()); |
290 | PPPData::data()->setModemConnectResp(connectresp->text()); | 290 | _pppdata->setModemConnectResp(connectresp->text()); |
291 | PPPData::data()->setModemBusyResp(busyresp->text()); | 291 | _pppdata->setModemBusyResp(busyresp->text()); |
292 | PPPData::data()->setModemNoCarrierResp(nocarrierresp->text()); | 292 | _pppdata->setModemNoCarrierResp(nocarrierresp->text()); |
293 | PPPData::data()->setModemNoDialtoneResp(nodialtoneresp->text()); | 293 | _pppdata->setModemNoDialtoneResp(nodialtoneresp->text()); |
294 | 294 | ||
295 | PPPData::data()->setModemEscapeStr(escapestr->text()); | 295 | _pppdata->setModemEscapeStr(escapestr->text()); |
296 | PPPData::data()->setModemEscapeResp(escaperesp->text()); | 296 | _pppdata->setModemEscapeResp(escaperesp->text()); |
297 | PPPData::data()->setModemEscapeGuardTime(lslider->text().toInt()); | 297 | _pppdata->setModemEscapeGuardTime(lslider->text().toInt()); |
298 | PPPData::data()->setModemHangupStr(hangupstr->text()); | 298 | _pppdata->setModemHangupStr(hangupstr->text()); |
299 | PPPData::data()->setModemHangupResp(hangupresp->text()); | 299 | _pppdata->setModemHangupResp(hangupresp->text()); |
300 | 300 | ||
301 | PPPData::data()->setModemAnswerStr(answerstr->text()); | 301 | _pppdata->setModemAnswerStr(answerstr->text()); |
302 | PPPData::data()->setModemRingResp(ringresp->text()); | 302 | _pppdata->setModemRingResp(ringresp->text()); |
303 | PPPData::data()->setModemAnswerResp(answerresp->text()); | 303 | _pppdata->setModemAnswerResp(answerresp->text()); |
304 | 304 | ||
305 | PPPData::data()->setVolumeHigh(volume_high->text()); | 305 | _pppdata->setVolumeHigh(volume_high->text()); |
306 | PPPData::data()->setVolumeMedium(volume_medium->text()); | 306 | _pppdata->setVolumeMedium(volume_medium->text()); |
307 | PPPData::data()->setVolumeOff(volume_off->text()); | 307 | _pppdata->setVolumeOff(volume_off->text()); |
308 | 308 | ||
309 | PPPData::data()->save(); | 309 | _pppdata->save(); |
310 | accept(); | 310 | accept(); |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | void ModemCommands::slotCancel() { | 314 | void ModemCommands::slotCancel() { |
315 | reject(); | 315 | reject(); |
316 | } | 316 | } |
317 | 317 | ||
318 | //#include "modemcmds.moc" | 318 | //#include "modemcmds.moc" |
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h index 9d078ec..ef69fec 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.h +++ b/noncore/settings/networksettings/ppp/modemcmds.h | |||
@@ -1,119 +1,120 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | * | 3 | * |
4 | * kPPP: A front end for pppd for the KDE project | 4 | * kPPP: A front end for pppd for the KDE project |
5 | * | 5 | * |
6 | * $Id$ | 6 | * $Id$ |
7 | * | 7 | * |
8 | * Copyright (C) 1997 Bernd Johannes Wuebben | 8 | * Copyright (C) 1997 Bernd Johannes Wuebben |
9 | * wuebben@math.cornell.edu | 9 | * wuebben@math.cornell.edu |
10 | * | 10 | * |
11 | * based on EzPPP: | 11 | * based on EzPPP: |
12 | * Copyright (C) 1997 Jay Painter | 12 | * Copyright (C) 1997 Jay Painter |
13 | * | 13 | * |
14 | * This library is free software; you can redistribute it and/or | 14 | * This library is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU Library General Public | 15 | * modify it under the terms of the GNU Library General Public |
16 | * License as published by the Free Software Foundation; either | 16 | * License as published by the Free Software Foundation; either |
17 | * version 2 of the License, or (at your option) any later version. | 17 | * version 2 of the License, or (at your option) any later version. |
18 | * | 18 | * |
19 | * This library is distributed in the hope that it will be useful, | 19 | * This library is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | * Library General Public License for more details. | 22 | * Library General Public License for more details. |
23 | * | 23 | * |
24 | * You should have received a copy of the GNU Library General Public | 24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with this program; if not, write to the Free | 25 | * License along with this program; if not, write to the Free |
26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #ifndef _MODEMCMDS_H_ | 31 | #ifndef _MODEMCMDS_H_ |
32 | #define _MODEMCMDS_H_ | 32 | #define _MODEMCMDS_H_ |
33 | 33 | ||
34 | #include <qgroupbox.h> | 34 | #include <qgroupbox.h> |
35 | #include <qdialog.h> | 35 | #include <qdialog.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include "pppdata.h" | 39 | #include "pppdata.h" |
40 | 40 | ||
41 | class ModemCommands : public QDialog { | 41 | class ModemCommands : public QDialog { |
42 | 42 | ||
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | 46 | ||
47 | ModemCommands(QWidget *parent=0, const char *name=0); | 47 | ModemCommands(PPPData*, QWidget *parent=0, const char *name=0); |
48 | ~ModemCommands() {} | 48 | ~ModemCommands() {} |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void slotCancel(); | 51 | void slotCancel(); |
52 | void slotOk(); | 52 | void slotOk(); |
53 | 53 | ||
54 | private: | 54 | private: |
55 | PPPData *_pppdata; | ||
55 | 56 | ||
56 | QGroupBox *box; | 57 | QGroupBox *box; |
57 | 58 | ||
58 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; | 59 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; |
59 | 60 | ||
60 | QLineEdit *initresp; | 61 | QLineEdit *initresp; |
61 | QLabel *label2; | 62 | QLabel *label2; |
62 | 63 | ||
63 | QLabel *lpreinitslider; | 64 | QLabel *lpreinitslider; |
64 | QLabel *lpreinit; | 65 | QLabel *lpreinit; |
65 | 66 | ||
66 | QLabel *linitslider; | 67 | QLabel *linitslider; |
67 | QLabel *label3; | 68 | QLabel *label3; |
68 | 69 | ||
69 | QLabel *ldurationslider; | 70 | QLabel *ldurationslider; |
70 | QLabel *lduration; | 71 | QLabel *lduration; |
71 | 72 | ||
72 | QLineEdit *nodetectdialtone; | 73 | QLineEdit *nodetectdialtone; |
73 | QLabel *lnodetectdialtone; | 74 | QLabel *lnodetectdialtone; |
74 | 75 | ||
75 | QLineEdit *dialstr; | 76 | QLineEdit *dialstr; |
76 | QLabel *label4; | 77 | QLabel *label4; |
77 | 78 | ||
78 | QLineEdit *connectresp; | 79 | QLineEdit *connectresp; |
79 | QLabel *label5; | 80 | QLabel *label5; |
80 | 81 | ||
81 | QLineEdit *busyresp; | 82 | QLineEdit *busyresp; |
82 | QLabel *label6; | 83 | QLabel *label6; |
83 | 84 | ||
84 | QLineEdit *nocarrierresp; | 85 | QLineEdit *nocarrierresp; |
85 | QLabel *label7; | 86 | QLabel *label7; |
86 | 87 | ||
87 | QLineEdit *nodialtoneresp; | 88 | QLineEdit *nodialtoneresp; |
88 | QLabel *label8; | 89 | QLabel *label8; |
89 | 90 | ||
90 | QLineEdit *hangupstr; | 91 | QLineEdit *hangupstr; |
91 | QLabel *label9; | 92 | QLabel *label9; |
92 | 93 | ||
93 | QLineEdit *hangupresp; | 94 | QLineEdit *hangupresp; |
94 | QLabel *label10; | 95 | QLabel *label10; |
95 | 96 | ||
96 | QLineEdit *answerstr; | 97 | QLineEdit *answerstr; |
97 | QLabel *label11; | 98 | QLabel *label11; |
98 | 99 | ||
99 | QLineEdit *ringresp; | 100 | QLineEdit *ringresp; |
100 | QLabel *label12; | 101 | QLabel *label12; |
101 | 102 | ||
102 | QLineEdit *answerresp; | 103 | QLineEdit *answerresp; |
103 | QLabel *label13; | 104 | QLabel *label13; |
104 | 105 | ||
105 | QLineEdit *escapestr; | 106 | QLineEdit *escapestr; |
106 | QLabel *label14; | 107 | QLabel *label14; |
107 | 108 | ||
108 | QLineEdit *escaperesp; | 109 | QLineEdit *escaperesp; |
109 | QLabel *label15; | 110 | QLabel *label15; |
110 | 111 | ||
111 | QLabel *lslider; | 112 | QLabel *lslider; |
112 | QLabel *label16; | 113 | QLabel *label16; |
113 | 114 | ||
114 | QLineEdit *volume_off, *volume_medium, *volume_high; | 115 | QLineEdit *volume_off, *volume_medium, *volume_high; |
115 | }; | 116 | }; |
116 | #endif | 117 | #endif |
117 | 118 | ||
118 | 119 | ||
119 | 120 | ||
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp index 4dbbcf5..0bec186 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.cpp +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -1,295 +1,296 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A front end for pppd for the KDE project | 2 | * kPPP: A front end for pppd for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de | 9 | * This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This library is free software; you can redistribute it and/or | 12 | * This library is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This library is distributed in the hope that it will be useful, | 17 | * This library is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with 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 <unistd.h> | 27 | #include <unistd.h> |
28 | #include <qregexp.h> | 28 | #include <qregexp.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | // #include <kwin.h> | 30 | // #include <kwin.h> |
31 | // #include <kmessagebox.h> | 31 | // #include <kmessagebox.h> |
32 | // #include <kapplication.h> | 32 | // #include <kapplication.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include "modeminfo.h" | 35 | #include "modeminfo.h" |
36 | #include "modem.h" | 36 | #include "modem.h" |
37 | //#include <klocale.h> | 37 | //#include <klocale.h> |
38 | #define i18n QObject::tr | 38 | #define i18n QObject::tr |
39 | 39 | ||
40 | ModemTransfer::ModemTransfer(QWidget *parent, const char *name) | 40 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) |
41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder) | 41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), |
42 | _modem(mo) | ||
42 | { | 43 | { |
43 | setCaption(i18n("ATI Query")); | 44 | setCaption(i18n("ATI Query")); |
44 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 45 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
45 | 46 | ||
46 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 47 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
47 | 48 | ||
48 | progressBar = new QProgressBar(this, "bar"); | 49 | progressBar = new QProgressBar(this, "bar"); |
49 | progressBar->setTotalSteps(8); | 50 | progressBar->setTotalSteps(8); |
50 | 51 | ||
51 | statusBar = new QLabel(this,"sBar"); | 52 | statusBar = new QLabel(this,"sBar"); |
52 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 53 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
53 | statusBar->setAlignment(AlignCenter); | 54 | statusBar->setAlignment(AlignCenter); |
54 | 55 | ||
55 | // This is a rather complicated case. Since we do not know which | 56 | // This is a rather complicated case. Since we do not know which |
56 | // message is the widest in the national language, we'd to | 57 | // message is the widest in the national language, we'd to |
57 | // search all these messages. This is a little overkill, so I take | 58 | // search all these messages. This is a little overkill, so I take |
58 | // the longest english message, translate it and give it additional | 59 | // the longest english message, translate it and give it additional |
59 | // 20 percent space. Hope this is enough. | 60 | // 20 percent space. Hope this is enough. |
60 | statusBar->setText(i18n("Unable to create modem lock file.")); | 61 | statusBar->setText(i18n("Unable to create modem lock file.")); |
61 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | 62 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); |
62 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | 63 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); |
63 | 64 | ||
64 | // set original text | 65 | // set original text |
65 | statusBar->setText(i18n("Looking for modem...")); | 66 | statusBar->setText(i18n("Looking for modem...")); |
66 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | 67 | progressBar->setFixedHeight(statusBar->minimumSize().height()); |
67 | tl->addWidget(progressBar); | 68 | tl->addWidget(progressBar); |
68 | tl->addWidget(statusBar); | 69 | tl->addWidget(statusBar); |
69 | 70 | ||
70 | cancel = new QPushButton(i18n("Cancel"), this); | 71 | cancel = new QPushButton(i18n("Cancel"), this); |
71 | cancel->setFocus(); | 72 | cancel->setFocus(); |
72 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 73 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
73 | 74 | ||
74 | QHBoxLayout *l1 = new QHBoxLayout; | 75 | QHBoxLayout *l1 = new QHBoxLayout; |
75 | tl->addLayout(l1); | 76 | tl->addLayout(l1); |
76 | l1->addStretch(1); | 77 | l1->addStretch(1); |
77 | l1->addWidget(cancel); | 78 | l1->addWidget(cancel); |
78 | 79 | ||
79 | setFixedSize(sizeHint()); | 80 | setFixedSize(sizeHint()); |
80 | 81 | ||
81 | step = 0; | 82 | step = 0; |
82 | 83 | ||
83 | //////////////////////////////////////////////// | 84 | //////////////////////////////////////////////// |
84 | 85 | ||
85 | timeout_timer = new QTimer(this); | 86 | timeout_timer = new QTimer(this); |
86 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); | 87 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); |
87 | 88 | ||
88 | scripttimer = new QTimer(this); | 89 | scripttimer = new QTimer(this); |
89 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); | 90 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); |
90 | 91 | ||
91 | timeout_timer->start(15000,TRUE); // 15 secs single shot | 92 | timeout_timer->start(15000,TRUE); // 15 secs single shot |
92 | QTimer::singleShot(500, this, SLOT(init())); | 93 | QTimer::singleShot(500, this, SLOT(init())); |
93 | 94 | ||
94 | } | 95 | } |
95 | 96 | ||
96 | 97 | ||
97 | void ModemTransfer::ati_done() { | 98 | void ModemTransfer::ati_done() { |
98 | scripttimer->stop(); | 99 | scripttimer->stop(); |
99 | timeout_timer->stop(); | 100 | timeout_timer->stop(); |
100 | Modem::modem->closetty(); | 101 | _modem->closetty(); |
101 | Modem::modem->unlockdevice(); | 102 | _modem->unlockdevice(); |
102 | hide(); | 103 | hide(); |
103 | 104 | ||
104 | // open the result window | 105 | // open the result window |
105 | ModemInfo *mi = new ModemInfo(this); | 106 | ModemInfo *mi = new ModemInfo(this); |
106 | for(int i = 0; i < NUM_OF_ATI; i++) | 107 | for(int i = 0; i < NUM_OF_ATI; i++) |
107 | mi->setAtiString(i, ati_query_strings[i]); | 108 | mi->setAtiString(i, ati_query_strings[i]); |
108 | mi->showMaximized(); | 109 | mi->showMaximized(); |
109 | mi->exec(); | 110 | mi->exec(); |
110 | delete mi; | 111 | delete mi; |
111 | 112 | ||
112 | accept(); | 113 | accept(); |
113 | } | 114 | } |
114 | 115 | ||
115 | 116 | ||
116 | void ModemTransfer::time_out_slot() { | 117 | void ModemTransfer::time_out_slot() { |
117 | timeout_timer->stop(); | 118 | timeout_timer->stop(); |
118 | scripttimer->stop(); | 119 | scripttimer->stop(); |
119 | 120 | ||
120 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); | 121 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); |
121 | reject(); | 122 | reject(); |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
125 | void ModemTransfer::init() { | 126 | void ModemTransfer::init() { |
126 | 127 | ||
127 | qApp->processEvents(); | 128 | qApp->processEvents(); |
128 | 129 | ||
129 | int lock = Modem::modem->lockdevice(); | 130 | int lock = _modem->lockdevice(); |
130 | if (lock == 1) { | 131 | if (lock == 1) { |
131 | 132 | ||
132 | statusBar->setText(i18n("Modem device is locked.")); | 133 | statusBar->setText(i18n("Modem device is locked.")); |
133 | return; | 134 | return; |
134 | } | 135 | } |
135 | 136 | ||
136 | if (lock == -1) { | 137 | if (lock == -1) { |
137 | 138 | ||
138 | statusBar->setText(i18n("Unable to create modem lock file.")); | 139 | statusBar->setText(i18n("Unable to create modem lock file.")); |
139 | return; | 140 | return; |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | if(Modem::modem->opentty()) { | 144 | if(_modem->opentty()) { |
144 | if(Modem::modem->hangup()) { | 145 | if(_modem->hangup()) { |
145 | usleep(100000); // wait 0.1 secs | 146 | usleep(100000); // wait 0.1 secs |
146 | Modem::modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | 147 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... |
147 | 148 | ||
148 | statusBar->setText(i18n("Modem Ready")); | 149 | statusBar->setText(i18n("Modem Ready")); |
149 | qApp->processEvents(); | 150 | qApp->processEvents(); |
150 | usleep(100000); // wait 0.1 secs | 151 | usleep(100000); // wait 0.1 secs |
151 | qApp->processEvents(); | 152 | qApp->processEvents(); |
152 | scripttimer->start(1000); // this one does the ati query | 153 | scripttimer->start(1000); // this one does the ati query |
153 | 154 | ||
154 | // clear modem buffer | 155 | // clear modem buffer |
155 | Modem::modem->flush(); | 156 | _modem->flush(); |
156 | 157 | ||
157 | Modem::modem->notify(this, SLOT(readChar(unsigned char))); | 158 | _modem->notify(this, SLOT(readChar(unsigned char))); |
158 | return; | 159 | return; |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | // opentty() or hangup() failed | 163 | // opentty() or hangup() failed |
163 | statusBar->setText(Modem::modem->modemMessage()); | 164 | statusBar->setText(_modem->modemMessage()); |
164 | step = 99; // wait until cancel is pressed | 165 | step = 99; // wait until cancel is pressed |
165 | Modem::modem->unlockdevice(); | 166 | _modem->unlockdevice(); |
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | void ModemTransfer::do_script() { | 170 | void ModemTransfer::do_script() { |
170 | QString msg; | 171 | QString msg; |
171 | QString query; | 172 | QString query; |
172 | 173 | ||
173 | switch(step) { | 174 | switch(step) { |
174 | case 0: | 175 | case 0: |
175 | readtty(); | 176 | readtty(); |
176 | statusBar->setText("ATI..."); | 177 | statusBar->setText("ATI..."); |
177 | progressBar->setProgress( progressBar->progress() + 1); | 178 | progressBar->setProgress( progressBar->progress() + 1); |
178 | Modem::modem->writeLine("ATI\n"); | 179 | _modem->writeLine("ATI\n"); |
179 | break; | 180 | break; |
180 | 181 | ||
181 | case 1: | 182 | case 1: |
182 | case 2: | 183 | case 2: |
183 | case 3: | 184 | case 3: |
184 | case 4: | 185 | case 4: |
185 | case 5: | 186 | case 5: |
186 | case 6: | 187 | case 6: |
187 | case 7: | 188 | case 7: |
188 | readtty(); | 189 | readtty(); |
189 | msg.sprintf("ATI %d ...", step); | 190 | msg.sprintf("ATI %d ...", step); |
190 | query.sprintf("ATI%d\n", step); | 191 | query.sprintf("ATI%d\n", step); |
191 | statusBar->setText(msg); | 192 | statusBar->setText(msg); |
192 | progressBar->setProgress( progressBar->progress() + 1); | 193 | progressBar->setProgress( progressBar->progress() + 1); |
193 | Modem::modem->writeLine(query.local8Bit()); | 194 | _modem->writeLine(query.local8Bit()); |
194 | break; | 195 | break; |
195 | 196 | ||
196 | default: | 197 | default: |
197 | readtty(); | 198 | readtty(); |
198 | ati_done(); | 199 | ati_done(); |
199 | } | 200 | } |
200 | step++; | 201 | step++; |
201 | } | 202 | } |
202 | 203 | ||
203 | void ModemTransfer::readChar(unsigned char c) { | 204 | void ModemTransfer::readChar(unsigned char c) { |
204 | if(readbuffer.length() < 255) | 205 | if(readbuffer.length() < 255) |
205 | readbuffer += c; | 206 | readbuffer += c; |
206 | } | 207 | } |
207 | 208 | ||
208 | void ModemTransfer::readtty() { | 209 | void ModemTransfer::readtty() { |
209 | 210 | ||
210 | if (step == 0) | 211 | if (step == 0) |
211 | return; | 212 | return; |
212 | 213 | ||
213 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r | 214 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r |
214 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white | 215 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white |
215 | // space | 216 | // space |
216 | 217 | ||
217 | if(step <= NUM_OF_ATI) | 218 | if(step <= NUM_OF_ATI) |
218 | ati_query_strings[step-1] = readbuffer.copy(); | 219 | ati_query_strings[step-1] = readbuffer.copy(); |
219 | 220 | ||
220 | readbuffer = ""; | 221 | readbuffer = ""; |
221 | } | 222 | } |
222 | 223 | ||
223 | 224 | ||
224 | void ModemTransfer::cancelbutton() { | 225 | void ModemTransfer::cancelbutton() { |
225 | scripttimer->stop(); | 226 | scripttimer->stop(); |
226 | Modem::modem->stop(); | 227 | _modem->stop(); |
227 | timeout_timer->stop(); | 228 | timeout_timer->stop(); |
228 | 229 | ||
229 | statusBar->setText(i18n("One moment please...")); | 230 | statusBar->setText(i18n("One moment please...")); |
230 | qApp->processEvents(); | 231 | qApp->processEvents(); |
231 | 232 | ||
232 | Modem::modem->hangup(); | 233 | _modem->hangup(); |
233 | 234 | ||
234 | Modem::modem->closetty(); | 235 | _modem->closetty(); |
235 | Modem::modem->unlockdevice(); | 236 | _modem->unlockdevice(); |
236 | reject(); | 237 | reject(); |
237 | } | 238 | } |
238 | 239 | ||
239 | 240 | ||
240 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | 241 | void ModemTransfer::closeEvent( QCloseEvent *e ) { |
241 | cancelbutton(); | 242 | cancelbutton(); |
242 | e->accept(); | 243 | e->accept(); |
243 | } | 244 | } |
244 | 245 | ||
245 | 246 | ||
246 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | 247 | ModemInfo::ModemInfo(QWidget *parent, const char* name) |
247 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | 248 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) |
248 | { | 249 | { |
249 | QString label_text; | 250 | QString label_text; |
250 | 251 | ||
251 | setCaption(i18n("Modem Query Results")); | 252 | setCaption(i18n("Modem Query Results")); |
252 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 253 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
253 | 254 | ||
254 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 255 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
255 | 256 | ||
256 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | 257 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); |
257 | tl->addLayout(l1, 1); | 258 | tl->addLayout(l1, 1); |
258 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | 259 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { |
259 | 260 | ||
260 | label_text = ""; | 261 | label_text = ""; |
261 | if ( i == 0) | 262 | if ( i == 0) |
262 | label_text.sprintf("ATI :"); | 263 | label_text.sprintf("ATI :"); |
263 | else | 264 | else |
264 | label_text.sprintf("ATI %d:", i ); | 265 | label_text.sprintf("ATI %d:", i ); |
265 | 266 | ||
266 | ati_label[i] = new QLabel(label_text, this); | 267 | ati_label[i] = new QLabel(label_text, this); |
267 | l1->addWidget(ati_label[i], i, 0); | 268 | l1->addWidget(ati_label[i], i, 0); |
268 | 269 | ||
269 | ati_label_result[i] = new QLineEdit(this); | 270 | ati_label_result[i] = new QLineEdit(this); |
270 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | 271 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); |
271 | l1->addWidget(ati_label_result[i], i, 1); | 272 | l1->addWidget(ati_label_result[i], i, 1); |
272 | } | 273 | } |
273 | //tl->addSpacing(1); | 274 | //tl->addSpacing(1); |
274 | 275 | ||
275 | QHBoxLayout *l2 = new QHBoxLayout; | 276 | QHBoxLayout *l2 = new QHBoxLayout; |
276 | QPushButton *ok = new QPushButton(i18n("Close"), this); | 277 | QPushButton *ok = new QPushButton(i18n("Close"), this); |
277 | ok->setDefault(TRUE); | 278 | ok->setDefault(TRUE); |
278 | ok->setFocus(); | 279 | ok->setFocus(); |
279 | 280 | ||
280 | tl->addLayout(l2); | 281 | tl->addLayout(l2); |
281 | l2->addStretch(1); | 282 | l2->addStretch(1); |
282 | 283 | ||
283 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | 284 | connect(ok, SIGNAL(clicked()), SLOT(accept())); |
284 | l2->addWidget(ok); | 285 | l2->addWidget(ok); |
285 | 286 | ||
286 | setMinimumSize(sizeHint()); | 287 | setMinimumSize(sizeHint()); |
287 | } | 288 | } |
288 | 289 | ||
289 | 290 | ||
290 | void ModemInfo::setAtiString(int i, QString s) { | 291 | void ModemInfo::setAtiString(int i, QString s) { |
291 | if(i < NUM_OF_ATI) | 292 | if(i < NUM_OF_ATI) |
292 | ati_label_result[i]->setText(s); | 293 | ati_label_result[i]->setText(s); |
293 | } | 294 | } |
294 | 295 | ||
295 | //#include "modeminfo.moc" | 296 | //#include "modeminfo.moc" |
diff --git a/noncore/settings/networksettings/ppp/modeminfo.h b/noncore/settings/networksettings/ppp/modeminfo.h index 7aa2cc0..dfcc841 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.h +++ b/noncore/settings/networksettings/ppp/modeminfo.h | |||
@@ -1,89 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A front end for pppd for the KDE project | 3 | * kPPP: A front end for pppd for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * | 10 | * |
11 | * This library is free software; you can redistribute it and/or | 11 | * This library 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 library is distributed in the hope that it will be useful, | 16 | * This library 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 | 26 | ||
27 | 27 | ||
28 | #ifndef _MODEMINFO_H_ | 28 | #ifndef _MODEMINFO_H_ |
29 | #define _MODEMINFO_H_ | 29 | #define _MODEMINFO_H_ |
30 | 30 | ||
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qevent.h> | 35 | #include <qevent.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | //#include <kprogress.h> | 37 | //#include <kprogress.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | 39 | ||
40 | class Modem; | ||
41 | |||
40 | const int NUM_OF_ATI = 8; | 42 | const int NUM_OF_ATI = 8; |
41 | 43 | ||
42 | 44 | ||
43 | class ModemTransfer : public QDialog { | 45 | class ModemTransfer : public QDialog { |
44 | Q_OBJECT | 46 | Q_OBJECT |
45 | public: | 47 | public: |
46 | ModemTransfer(QWidget *parent=0, const char *name=0); | 48 | ModemTransfer(Modem*, QWidget *parent=0, const char *name=0); |
47 | 49 | ||
48 | public slots: | 50 | public slots: |
49 | void init(); | 51 | void init(); |
50 | void readtty(); | 52 | void readtty(); |
51 | void do_script(); | 53 | void do_script(); |
52 | void time_out_slot(); | 54 | void time_out_slot(); |
53 | void cancelbutton(); | 55 | void cancelbutton(); |
54 | void readChar(unsigned char); | 56 | void readChar(unsigned char); |
55 | 57 | ||
56 | private: | 58 | private: |
57 | void ati_done(); | 59 | void ati_done(); |
58 | 60 | ||
59 | protected: | 61 | protected: |
60 | void closeEvent(QCloseEvent *e); | 62 | void closeEvent(QCloseEvent *e); |
61 | 63 | ||
62 | private: | 64 | private: |
65 | Modem *_modem; | ||
63 | int step; | 66 | int step; |
64 | QString readbuffer; | 67 | QString readbuffer; |
65 | 68 | ||
66 | QPushButton *cancel; | 69 | QPushButton *cancel; |
67 | QProgressBar *progressBar; | 70 | QProgressBar *progressBar; |
68 | QLabel *statusBar; | 71 | QLabel *statusBar; |
69 | 72 | ||
70 | QTimer *timeout_timer; | 73 | QTimer *timeout_timer; |
71 | QTimer *scripttimer; | 74 | QTimer *scripttimer; |
72 | QString ati_query_strings[NUM_OF_ATI]; | 75 | QString ati_query_strings[NUM_OF_ATI]; |
73 | }; | 76 | }; |
74 | 77 | ||
75 | 78 | ||
76 | class ModemInfo : public QDialog { | 79 | class ModemInfo : public QDialog { |
77 | Q_OBJECT | 80 | Q_OBJECT |
78 | public: | 81 | public: |
79 | ModemInfo(QWidget *parent=0, const char *name=0); | 82 | ModemInfo(QWidget *parent=0, const char *name=0); |
80 | 83 | ||
81 | public: | 84 | public: |
82 | void setAtiString(int num, QString s); | 85 | void setAtiString(int num, QString s); |
83 | 86 | ||
84 | private: | 87 | private: |
85 | QLabel *ati_label[NUM_OF_ATI]; | 88 | QLabel *ati_label[NUM_OF_ATI]; |
86 | QLineEdit *ati_label_result[NUM_OF_ATI]; | 89 | QLineEdit *ati_label_result[NUM_OF_ATI]; |
87 | }; | 90 | }; |
88 | 91 | ||
89 | #endif | 92 | #endif |
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index ac438dd..483aa58 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,20 +1,20 @@ | |||
1 | #TEMPLATE = app | 1 | #TEMPLATE = app |
2 | # | 2 | # |
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 kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h | 7 | HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h |
8 | # | 8 | # kpppwidget.h |
9 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp | 9 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp |
10 | # | 10 | # kpppwidget.cpp |
11 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 11 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
12 | DEPENDPATH+= $(OPIEDIR)/include | 12 | DEPENDPATH+= $(OPIEDIR)/include |
13 | LIBS += -lqpe -L../interfaces/ -linterfaces | 13 | LIBS += -lqpe -L../interfaces/ -linterfaces |
14 | INTERFACES= | 14 | INTERFACES= |
15 | TARGET = pppplugin | 15 | TARGET = pppplugin |
16 | VERSION = 1.0.0 | 16 | VERSION = 1.0.0 |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | include ( $(OPIEDIR)/include.pro ) | 20 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index 4c5f7aa..63f9335 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp | |||
@@ -1,77 +1,72 @@ | |||
1 | 1 | ||
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | #include <qtabwidget.h> | 4 | #include <qtabwidget.h> |
5 | 5 | ||
6 | #include "accounts.h" | 6 | #include "accounts.h" |
7 | #include "general.h" | 7 | #include "general.h" |
8 | #include "interface.h" | 8 | #include "interfaceppp.h" |
9 | #include "modem.h" | 9 | #include "modem.h" |
10 | #include "pppconfig.h" | 10 | #include "pppconfig.h" |
11 | #include "pppdata.h" | 11 | #include "pppdata.h" |
12 | #include "runtests.h" | 12 | #include "runtests.h" |
13 | 13 | ||
14 | PPPConfigWidget::PPPConfigWidget( Interface* 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 | if (!PPPData::data()->setModemDevice( interface->getInterfaceName() )) | ||
28 | PPPData::data()->setModemDevice("/dev/modem"); | ||
29 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 27 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
30 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 28 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
31 | if (!PPPData::data()->setAccount( interface->getHardwareName() )) | ||
32 | PPPData::data()->setAccount( 0 ); | ||
33 | 29 | ||
34 | qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); | 30 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
35 | qDebug(" PPPData::data()->currentAccountID() >%i<",PPPData::data()->currentAccountID()); | 31 | qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID()); |
36 | (void)new Modem; | ||
37 | 32 | ||
38 | QVBoxLayout *layout = new QVBoxLayout( this ); | 33 | QVBoxLayout *layout = new QVBoxLayout( this ); |
39 | layout->setSpacing( 0 ); | 34 | layout->setSpacing( 0 ); |
40 | layout->setMargin( 1 ); | 35 | layout->setMargin( 1 ); |
41 | tabWindow = new QTabWidget( this, "tabWidget" ); | 36 | tabWindow = new QTabWidget( this, "tabWidget" ); |
42 | layout->addWidget( tabWindow ); | 37 | layout->addWidget( tabWindow ); |
43 | 38 | ||
44 | accounts = new AccountWidget( tabWindow, "accounts" ); | 39 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts" ); |
45 | tabWindow->addTab( accounts, tr("&Accounts") ); | 40 | tabWindow->addTab( accounts, tr("&Accounts") ); |
46 | modem1 = new ModemWidget( tabWindow, "modem1" ); | 41 | modem1 = new ModemWidget( interface, tabWindow, "modem1" ); |
47 | tabWindow->addTab( modem1, tr("&Device") ); | 42 | tabWindow->addTab( modem1, tr("&Device") ); |
48 | modem2 = new ModemWidget2( tabWindow, "modem2" ); | 43 | modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); |
49 | tabWindow->addTab( modem2, tr("&Modem") ); | 44 | tabWindow->addTab( modem2, tr("&Modem") ); |
50 | // graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); | 45 | // graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) ); |
51 | // general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); | 46 | // general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) ); |
52 | 47 | ||
53 | } | 48 | } |
54 | 49 | ||
55 | 50 | ||
56 | PPPConfigWidget::~PPPConfigWidget() | 51 | PPPConfigWidget::~PPPConfigWidget() |
57 | { | 52 | { |
58 | 53 | ||
59 | } | 54 | } |
60 | 55 | ||
61 | void PPPConfigWidget::accept() | 56 | void PPPConfigWidget::accept() |
62 | { | 57 | { |
63 | qDebug("PPPConfigWidget::accept"); | 58 | qDebug("PPPConfigWidget::accept"); |
64 | qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); | 59 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
65 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 60 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
66 | interface->setInterfaceName( PPPData::data()->modemDevice() ); | 61 | interface->setInterfaceName( interface->data()->modemDevice() ); |
67 | interface->setHardwareName( PPPData::data()->accname() ); | 62 | interface->setHardwareName( interface->data()->accname() ); |
68 | PPPData::data()->save(); | 63 | interface->data()->save(); |
69 | QDialog::accept(); | 64 | QDialog::accept(); |
70 | } | 65 | } |
71 | 66 | ||
72 | 67 | ||
73 | void PPPConfigWidget::reject() | 68 | void PPPConfigWidget::reject() |
74 | { | 69 | { |
75 | PPPData::data()->cancel(); | 70 | interface->data()->cancel(); |
76 | QDialog::reject(); | 71 | QDialog::reject(); |
77 | } | 72 | } |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h index b324b6d..9bab6fe 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.h +++ b/noncore/settings/networksettings/ppp/pppconfig.h | |||
@@ -1,36 +1,37 @@ | |||
1 | #ifndef _PPPCONFIG_H_ | 1 | #ifndef _PPPCONFIG_H_ |
2 | #define _PPPCONFIG_H_ | 2 | #define _PPPCONFIG_H_ |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | class QTabWidget; | 6 | class QTabWidget; |
7 | class Interface; | 7 | //class Interface; |
8 | class InterfacePPP; | ||
8 | class AccountWidget; | 9 | class AccountWidget; |
9 | class GeneralWidget; | 10 | class GeneralWidget; |
10 | class ModemWidget; | 11 | class ModemWidget; |
11 | class ModemWidget2; | 12 | class ModemWidget2; |
12 | 13 | ||
13 | class PPPConfigWidget : public QDialog { | 14 | class PPPConfigWidget : public QDialog { |
14 | Q_OBJECT | 15 | Q_OBJECT |
15 | public: | 16 | public: |
16 | 17 | ||
17 | PPPConfigWidget( Interface*, QWidget *parent=0, const char *name=0, | 18 | PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0, |
18 | bool modal = false, WFlags fl = 0 ); | 19 | bool modal = false, WFlags fl = 0 ); |
19 | ~PPPConfigWidget(); | 20 | ~PPPConfigWidget(); |
20 | 21 | ||
21 | 22 | ||
22 | protected slots: | 23 | protected slots: |
23 | virtual void accept(); | 24 | virtual void accept(); |
24 | virtual void reject(); | 25 | virtual void reject(); |
25 | 26 | ||
26 | private: | 27 | private: |
27 | Interface *interface; | 28 | InterfacePPP *interface; |
28 | QTabWidget *tabWindow; | 29 | QTabWidget *tabWindow; |
29 | AccountWidget *accounts; | 30 | AccountWidget *accounts; |
30 | GeneralWidget *general; | 31 | GeneralWidget *general; |
31 | ModemWidget *modem1; | 32 | ModemWidget *modem1; |
32 | ModemWidget2 *modem2; | 33 | ModemWidget2 *modem2; |
33 | }; | 34 | }; |
34 | 35 | ||
35 | 36 | ||
36 | #endif | 37 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp index 4039939..d1143cf 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.cpp +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp | |||
@@ -1,166 +1,166 @@ | |||
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 | * | 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 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | //#include <kwin.h> | 30 | //#include <kwin.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include "pppdargs.h" | 32 | #include "pppdargs.h" |
33 | #include "pppdata.h" | 33 | #include "pppdata.h" |
34 | //#include <klocale.h> | 34 | //#include <klocale.h> |
35 | #define i18n QObject::tr | 35 | #define i18n QObject::tr |
36 | 36 | ||
37 | PPPdArguments::PPPdArguments(QWidget *parent, const char *name) | 37 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) |
38 | : QDialog(parent, name, TRUE) | 38 | : QDialog(parent, name, TRUE), _pppdata(pd) |
39 | { | 39 | { |
40 | setCaption(i18n("Customize pppd Arguments")); | 40 | setCaption(i18n("Customize pppd Arguments")); |
41 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 41 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
42 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); | 42 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); |
43 | QHBoxLayout *tl = new QHBoxLayout(10); | 43 | QHBoxLayout *tl = new QHBoxLayout(10); |
44 | l->addLayout(tl); | 44 | l->addLayout(tl); |
45 | QVBoxLayout *l1 = new QVBoxLayout(); | 45 | QVBoxLayout *l1 = new QVBoxLayout(); |
46 | QVBoxLayout *l2 = new QVBoxLayout(); | 46 | QVBoxLayout *l2 = new QVBoxLayout(); |
47 | tl->addLayout(l1, 1); | 47 | tl->addLayout(l1, 1); |
48 | tl->addLayout(l2, 0); | 48 | tl->addLayout(l2, 0); |
49 | 49 | ||
50 | QHBoxLayout *l11 = new QHBoxLayout(10); | 50 | QHBoxLayout *l11 = new QHBoxLayout(10); |
51 | l1->addLayout(l11); | 51 | l1->addLayout(l11); |
52 | 52 | ||
53 | argument_label = new QLabel(i18n("Argument:"), this); | 53 | argument_label = new QLabel(i18n("Argument:"), this); |
54 | l11->addWidget(argument_label); | 54 | l11->addWidget(argument_label); |
55 | 55 | ||
56 | argument = new QLineEdit(this); | 56 | argument = new QLineEdit(this); |
57 | connect(argument, SIGNAL(returnPressed()), | 57 | connect(argument, SIGNAL(returnPressed()), |
58 | SLOT(addbutton())); | 58 | SLOT(addbutton())); |
59 | l11->addWidget(argument); | 59 | l11->addWidget(argument); |
60 | connect(argument, SIGNAL(textChanged(const QString &)), | 60 | connect(argument, SIGNAL(textChanged(const QString &)), |
61 | this, SLOT(textChanged(const QString &))); | 61 | this, SLOT(textChanged(const QString &))); |
62 | 62 | ||
63 | arguments = new QListBox(this); | 63 | arguments = new QListBox(this); |
64 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); | 64 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); |
65 | connect(arguments, SIGNAL(highlighted(int)), | 65 | connect(arguments, SIGNAL(highlighted(int)), |
66 | this, SLOT(itemSelected(int))); | 66 | this, SLOT(itemSelected(int))); |
67 | l1->addWidget(arguments, 1); | 67 | l1->addWidget(arguments, 1); |
68 | 68 | ||
69 | add = new QPushButton(i18n("Add"), this); | 69 | add = new QPushButton(i18n("Add"), this); |
70 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); | 70 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); |
71 | l2->addWidget(add); | 71 | l2->addWidget(add); |
72 | l2->addStretch(1); | 72 | l2->addStretch(1); |
73 | 73 | ||
74 | remove = new QPushButton(i18n("Remove"), this); | 74 | remove = new QPushButton(i18n("Remove"), this); |
75 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); | 75 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); |
76 | l2->addWidget(remove); | 76 | l2->addWidget(remove); |
77 | 77 | ||
78 | defaults = new QPushButton(i18n("Defaults"), this); | 78 | defaults = new QPushButton(i18n("Defaults"), this); |
79 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); | 79 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); |
80 | l2->addWidget(defaults); | 80 | l2->addWidget(defaults); |
81 | 81 | ||
82 | l->addSpacing(5); | 82 | l->addSpacing(5); |
83 | 83 | ||
84 | // QButtonGroup *bbox = new QButtonGroup(this); | 84 | // QButtonGroup *bbox = new QButtonGroup(this); |
85 | // // bbox->addStretch(1); | 85 | // // bbox->addStretch(1); |
86 | // closebtn = new QPushButton( bbox, i18n("OK")); | 86 | // closebtn = new QPushButton( bbox, i18n("OK")); |
87 | // bbox->insert(closebtn); | 87 | // bbox->insert(closebtn); |
88 | // connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); | 88 | // connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); |
89 | // QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); | 89 | // QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); |
90 | // bbox->insert(cancel); | 90 | // bbox->insert(cancel); |
91 | // connect(cancel, SIGNAL(clicked()), | 91 | // connect(cancel, SIGNAL(clicked()), |
92 | // this, SLOT(reject())); | 92 | // this, SLOT(reject())); |
93 | // bbox->layout(); | 93 | // bbox->layout(); |
94 | // l->addWidget(bbox); | 94 | // l->addWidget(bbox); |
95 | 95 | ||
96 | // setFixedSize(sizeHint()); | 96 | // setFixedSize(sizeHint()); |
97 | 97 | ||
98 | //load info from gpppdata | 98 | //load info from gpppdata |
99 | init(); | 99 | init(); |
100 | 100 | ||
101 | add->setEnabled(false); | 101 | add->setEnabled(false); |
102 | remove->setEnabled(false); | 102 | remove->setEnabled(false); |
103 | argument->setFocus(); | 103 | argument->setFocus(); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void PPPdArguments::addbutton() { | 107 | void PPPdArguments::addbutton() { |
108 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { | 108 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { |
109 | arguments->insertItem(argument->text()); | 109 | arguments->insertItem(argument->text()); |
110 | argument->setText(""); | 110 | argument->setText(""); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | void PPPdArguments::removebutton() { | 115 | void PPPdArguments::removebutton() { |
116 | if(arguments->currentItem() >= 0) | 116 | if(arguments->currentItem() >= 0) |
117 | arguments->removeItem(arguments->currentItem()); | 117 | arguments->removeItem(arguments->currentItem()); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | void PPPdArguments::defaultsbutton() { | 121 | void PPPdArguments::defaultsbutton() { |
122 | // all of this is a hack | 122 | // all of this is a hack |
123 | // save current list | 123 | // save current list |
124 | QStringList arglist(PPPData::data()->pppdArgument()); | 124 | QStringList arglist(_pppdata->pppdArgument()); |
125 | 125 | ||
126 | // get defaults | 126 | // get defaults |
127 | PPPData::data()->setpppdArgumentDefaults(); | 127 | _pppdata->setpppdArgumentDefaults(); |
128 | init(); | 128 | init(); |
129 | 129 | ||
130 | // restore old list | 130 | // restore old list |
131 | PPPData::data()->setpppdArgument(arglist); | 131 | _pppdata->setpppdArgument(arglist); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void PPPdArguments::closebutton() { | 135 | void PPPdArguments::closebutton() { |
136 | QStringList arglist; | 136 | QStringList arglist; |
137 | for(uint i=0; i < arguments->count(); i++) | 137 | for(uint i=0; i < arguments->count(); i++) |
138 | arglist.append(arguments->text(i)); | 138 | arglist.append(arguments->text(i)); |
139 | PPPData::data()->setpppdArgument(arglist); | 139 | _pppdata->setpppdArgument(arglist); |
140 | 140 | ||
141 | done(0); | 141 | done(0); |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | void PPPdArguments::init() { | 145 | void PPPdArguments::init() { |
146 | while(arguments->count()) | 146 | while(arguments->count()) |
147 | arguments->removeItem(0); | 147 | arguments->removeItem(0); |
148 | 148 | ||
149 | QStringList &arglist = PPPData::data()->pppdArgument(); | 149 | QStringList &arglist = _pppdata->pppdArgument(); |
150 | for ( QStringList::Iterator it = arglist.begin(); | 150 | for ( QStringList::Iterator it = arglist.begin(); |
151 | it != arglist.end(); | 151 | it != arglist.end(); |
152 | ++it ) | 152 | ++it ) |
153 | arguments->insertItem(*it); | 153 | arguments->insertItem(*it); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void PPPdArguments::textChanged(const QString &s) { | 157 | void PPPdArguments::textChanged(const QString &s) { |
158 | add->setEnabled(s.length() > 0); | 158 | add->setEnabled(s.length() > 0); |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void PPPdArguments::itemSelected(int idx) { | 162 | void PPPdArguments::itemSelected(int idx) { |
163 | remove->setEnabled(idx != -1); | 163 | remove->setEnabled(idx != -1); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdargs.h b/noncore/settings/networksettings/ppp/pppdargs.h index c1cd28d..75f0c9d 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.h +++ b/noncore/settings/networksettings/ppp/pppdargs.h | |||
@@ -1,76 +1,78 @@ | |||
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 | * | 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 | #ifndef _PPPDARGS_H_ | 28 | #ifndef _PPPDARGS_H_ |
29 | #define _PPPDARGS_H_ | 29 | #define _PPPDARGS_H_ |
30 | 30 | ||
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qlistbox.h> | 34 | #include <qlistbox.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | class PPPData; | ||
36 | 37 | ||
37 | class PPPdArguments : public QDialog { | 38 | class PPPdArguments : public QDialog { |
38 | Q_OBJECT | 39 | Q_OBJECT |
39 | public: | 40 | public: |
40 | PPPdArguments(QWidget *parent=0, const char *name=0); | 41 | PPPdArguments(PPPData*,QWidget *parent=0, const char *name=0); |
41 | ~PPPdArguments() {} | 42 | ~PPPdArguments() {} |
42 | 43 | ||
43 | private slots: | 44 | private slots: |
44 | void addbutton(); | 45 | void addbutton(); |
45 | void removebutton(); | 46 | void removebutton(); |
46 | void defaultsbutton(); | 47 | void defaultsbutton(); |
47 | void closebutton(); | 48 | void closebutton(); |
48 | void textChanged(const QString &); | 49 | void textChanged(const QString &); |
49 | void itemSelected(int); | 50 | void itemSelected(int); |
50 | 51 | ||
51 | private: | 52 | private: |
52 | void init(); | 53 | void init(); |
53 | 54 | ||
54 | QLabel *argument_label; | 55 | QLabel *argument_label; |
55 | 56 | ||
56 | QLineEdit *argument; | 57 | QLineEdit *argument; |
57 | 58 | ||
58 | QPushButton *add; | 59 | QPushButton *add; |
59 | QPushButton *remove; | 60 | QPushButton *remove; |
60 | QPushButton *defaults; | 61 | QPushButton *defaults; |
61 | 62 | ||
62 | QListBox *arguments; | 63 | QListBox *arguments; |
63 | 64 | ||
64 | QPushButton *closebtn; | 65 | QPushButton *closebtn; |
66 | PPPData *_pppdata; | ||
65 | }; | 67 | }; |
66 | #endif | 68 | #endif |
67 | 69 | ||
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | 73 | ||
72 | 74 | ||
73 | 75 | ||
74 | 76 | ||
75 | 77 | ||
76 | 78 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 3f1675c..59d68c9 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -1,1252 +1,1276 @@ | |||
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 | PPPData *PPPData::_data = 0; | 41 | #define SEPARATOR -sseepp- |
42 | Config *PPPData::config = 0; | 42 | #define SEP QString("%1SEPARATOR%1") |
43 | |||
44 | PPPData* PPPData::data() | ||
45 | { | ||
46 | if (!_data){ | ||
47 | qDebug("PPPData::data() creates new Instance"); | ||
48 | _data = new PPPData(); | ||
49 | } | ||
50 | if (!_data->config){ | ||
51 | qDebug("PPPData::data() opens conffile"); | ||
52 | _data->open(); | ||
53 | } | ||
54 | return _data; | ||
55 | } | ||
56 | 43 | ||
57 | PPPData::PPPData() | 44 | PPPData::PPPData() |
58 | : modemDeviceGroup(-1), | 45 | : modemDeviceGroup(-1), |
59 | highcount(-1), // start out with no entries | 46 | highcount(-1), // start out with no entries |
60 | caccount(-1), // set the current account index also | 47 | caccount(-1), // set the current account index also |
61 | suidprocessid(-1), // process ID of setuid child | 48 | suidprocessid(-1), // process ID of setuid child |
62 | pppdisrunning(false), | 49 | pppdisrunning(false), |
63 | pppderror(0) | 50 | pppderror(0) |
64 | { | 51 | { |
65 | } | ||
66 | |||
67 | |||
68 | // | ||
69 | // open configuration file | ||
70 | // | ||
71 | bool PPPData::open() { | ||
72 | qDebug("opening configfile NetworkSetupPPP"); | ||
73 | if (config) return true; | ||
74 | config = new Config("NetworkSetupPPP"); | ||
75 | |||
76 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 52 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
77 | 53 | ||
78 | if (highcount > MAX_ACCOUNTS) | 54 | if (highcount > MAX_ACCOUNTS) |
79 | highcount = MAX_ACCOUNTS; | 55 | highcount = MAX_ACCOUNTS; |
80 | 56 | ||
81 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 57 | if(highcount >= 0 && defaultAccount().isEmpty()) { |
82 | setAccountbyIndex(0); | 58 | setAccountbyIndex(0); |
83 | setDefaultAccount(accname()); | 59 | setDefaultAccount(accname()); |
84 | } else if(!setAccount(defaultAccount())) | 60 | } else if(!setAccount(defaultAccount())) |
85 | setDefaultAccount(accname()); | 61 | setDefaultAccount(accname()); |
86 | 62 | ||
87 | // start out with internal debugging disabled | 63 | // start out with internal debugging disabled |
88 | // the user is still free to specify `debug' on his own | 64 | // the user is still free to specify `debug' on his own |
89 | setPPPDebug(false); | 65 | setPPPDebug(false); |
90 | 66 | ||
91 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 67 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
92 | 68 | ||
93 | return true; | ||
94 | } | 69 | } |
95 | 70 | ||
71 | Config PPPData::config() | ||
72 | { | ||
73 | return Config("NetworkSetupPPP"); | ||
74 | } | ||
96 | 75 | ||
97 | // | 76 | // |
98 | // save configuration | 77 | // save configuration |
99 | // | 78 | // |
100 | void PPPData::save() { | 79 | void PPPData::save() |
101 | 80 | { | |
102 | if (config) { | 81 | qDebug("PPPData saving data"); |
103 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 82 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
104 | delete config; | 83 | QString key; |
105 | config = 0; | 84 | QStringList keys; |
106 | qDebug("worte confi NetworkSetupPPP"); | 85 | Config cfg = config(); |
107 | } | 86 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
108 | if (_data){ | 87 | it != stringEntries.end(); ++it ){ |
109 | delete _data; | 88 | QString val = it.data(); |
110 | _data = 0; | 89 | key = it.key(); |
111 | } | 90 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
112 | 91 | keys = QStringList::split( "SEPARATOR", key ); | |
92 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | ||
93 | cfg.setGroup(keys[0]); | ||
94 | cfg.writeEntry(keys[1], val); | ||
95 | } | ||
96 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | ||
97 | it != intEntries.end(); ++it ){ | ||
98 | int val = it.data(); | ||
99 | key = it.key(); | ||
100 | // qDebug("saving %s -> %i", key.latin1(), val ); | ||
101 | keys = QStringList::split( "SEPARATOR", key ); | ||
102 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | ||
103 | cfg.setGroup(keys[0]); | ||
104 | cfg.writeEntry(keys[1], val); | ||
105 | } | ||
106 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | ||
107 | it != listEntries.end(); ++it ){ | ||
108 | QStringList val = it.data(); | ||
109 | key = it.key(); | ||
110 | QChar sep = sepEntries[key]; | ||
111 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | ||
112 | keys = QStringList::split( "SEPARATOR", key ); | ||
113 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | ||
114 | cfg.setGroup(keys[0]); | ||
115 | cfg.writeEntry(keys[1], val, sep); | ||
116 | } | ||
113 | } | 117 | } |
114 | 118 | ||
115 | 119 | ||
116 | // | 120 | // |
117 | // cancel changes | 121 | // cancel changes |
118 | // | 122 | // |
119 | void PPPData::cancel() { | 123 | void PPPData::cancel() { |
120 | 124 | stringEntries.clear(); | |
121 | // if (config) { | 125 | intEntries.clear(); |
122 | // config->rollback(); | 126 | listEntries.clear(); |
123 | // config->reparseConfiguration(); | ||
124 | // } | ||
125 | |||
126 | } | 127 | } |
127 | 128 | ||
128 | |||
129 | // // currently differentiates between READWRITE and NONE only | ||
130 | // int PPPData::access() const { | ||
131 | |||
132 | // return 1;//config->getConfigState(); | ||
133 | // } | ||
134 | |||
135 | |||
136 | // functions to read/write date to configuration file | 129 | // functions to read/write date to configuration file |
137 | QString PPPData::readConfig(const QString &group, const QString &key, | 130 | QString PPPData::readConfig(const QString &group, const QString &key, |
138 | const QString &defvalue = "") | 131 | const QString &defvalue = "") |
139 | { | 132 | { |
140 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 133 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
141 | if (config) { | 134 | QString idx = SEP.arg(group).arg(key); |
142 | config->setGroup(group); | 135 | if (stringEntries.find(idx) != stringEntries.end()) |
143 | return config->readEntry(key, defvalue); | 136 | return stringEntries[idx]; |
144 | } else | 137 | Config cfg = config(); |
145 | return defvalue; | 138 | cfg.setGroup(group); |
139 | return cfg.readEntry(key, defvalue); | ||
146 | } | 140 | } |
147 | 141 | ||
148 | 142 | ||
149 | int PPPData::readNumConfig(const QString &group, const QString &key, | 143 | int PPPData::readNumConfig(const QString &group, const QString &key, |
150 | int defvalue) { | 144 | int defvalue) |
151 | if (config) { | 145 | { |
152 | config->setGroup(group); | 146 | QString idx = SEP.arg(group).arg(key); |
153 | return config->readNumEntry(key, defvalue); | 147 | if (intEntries.find(idx) != intEntries.end()) |
154 | } else | 148 | return intEntries[idx]; |
155 | return defvalue; | 149 | Config cfg = config(); |
150 | cfg.setGroup(group); | ||
151 | return cfg.readNumEntry(key, defvalue); | ||
152 | |||
153 | // if (config) { | ||
154 | // config->setGroup(group); | ||
155 | // return config->readNumEntry(key, defvalue); | ||
156 | // } else | ||
157 | // return defvalue; | ||
156 | 158 | ||
157 | } | 159 | } |
158 | 160 | ||
159 | 161 | ||
160 | bool PPPData::readListConfig(const QString &group, const QString &key, | 162 | bool PPPData::readListConfig(const QString &group, const QString &key, |
161 | QStringList &list, char sep) { | 163 | QStringList &list, char sep) { |
162 | list.clear(); | 164 | list.clear(); |
163 | if (config) { | 165 | QString idx = SEP.arg(group).arg(key); |
164 | config->setGroup(group); | 166 | if (listEntries.find(idx) != listEntries.end()){ |
165 | list = config->readListEntry(key, sep); | 167 | list = listEntries[idx]; |
166 | return true; | 168 | return true; |
167 | } else | 169 | } |
168 | return false; | 170 | Config cfg = config(); |
171 | cfg.setGroup(group); | ||
172 | list = cfg.readListEntry(key, sep); | ||
173 | if (list.count() > 0) return true; | ||
174 | return false; | ||
175 | |||
176 | // if (config) { | ||
177 | // config->setGroup(group); | ||
178 | // list = config->readListEntry(key, sep); | ||
179 | // return true; | ||
180 | // } else | ||
181 | // return false; | ||
169 | } | 182 | } |
170 | 183 | ||
171 | 184 | ||
172 | void PPPData::writeConfig(const QString &group, const QString &key, | 185 | void PPPData::writeConfig(const QString &group, const QString &key, |
173 | const QString &value) { | 186 | const QString &value) { |
174 | if (config) { | 187 | stringEntries.insert( SEP.arg(group).arg(key), value ); |
175 | config->setGroup(group); | 188 | // if (config) { |
176 | config->writeEntry(key, value); | 189 | // config->setGroup(group); |
177 | } | 190 | // config->writeEntry(key, value); |
191 | // } | ||
178 | } | 192 | } |
179 | 193 | ||
180 | 194 | ||
181 | void PPPData::writeConfig(const QString &group, const QString &key, int value) { | 195 | void PPPData::writeConfig(const QString &group, const QString &key, int value) |
182 | if (config) { | 196 | { |
183 | config->setGroup(group); | 197 | intEntries.insert( SEP.arg(group).arg(key), value ); |
184 | config->writeEntry(key, value); | 198 | // if (config) { |
185 | } | 199 | // config->setGroup(group); |
200 | // config->writeEntry(key, value); | ||
201 | // } | ||
186 | } | 202 | } |
187 | 203 | ||
188 | 204 | ||
189 | void PPPData::writeListConfig(const QString &group, const QString &key, | 205 | void PPPData::writeListConfig(const QString &group, const QString &key, |
190 | QStringList &list, char sep) { | 206 | QStringList &list, char sep) |
191 | if (config) { | 207 | { |
192 | config->setGroup(group); | 208 | listEntries.insert( SEP.arg(group).arg(key), list ); |
193 | config->writeEntry(key, list, sep); | 209 | sepEntries.insert( SEP.arg(group).arg(key), sep ); |
194 | } | 210 | // if (config) { |
211 | // config->setGroup(group); | ||
212 | // config->writeEntry(key, list, sep); | ||
213 | // } | ||
195 | } | 214 | } |
196 | 215 | ||
197 | 216 | ||
198 | // | 217 | // |
199 | // functions to set/return general information | 218 | // functions to set/return general information |
200 | // | 219 | // |
201 | QString PPPData::password() const { | 220 | QString PPPData::password() const { |
202 | return passwd; | 221 | return passwd; |
203 | } | 222 | } |
204 | 223 | ||
205 | 224 | ||
206 | void PPPData::setPassword(const QString &pw) { | 225 | void PPPData::setPassword(const QString &pw) { |
207 | passwd = pw; | 226 | passwd = pw; |
208 | } | 227 | } |
209 | 228 | ||
210 | 229 | ||
211 | const QString PPPData::defaultAccount() { | 230 | const QString PPPData::defaultAccount() { |
212 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); | 231 | return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); |
213 | } | 232 | } |
214 | 233 | ||
215 | 234 | ||
216 | void PPPData::setDefaultAccount(const QString &n) { | 235 | void PPPData::setDefaultAccount(const QString &n) { |
217 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); | 236 | writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); |
218 | 237 | ||
219 | //now set the current account index to the default account | 238 | //now set the current account index to the default account |
220 | setAccount(defaultAccount()); | 239 | setAccount(defaultAccount()); |
221 | } | 240 | } |
222 | 241 | ||
223 | 242 | ||
224 | bool PPPData::get_show_clock_on_caption() { | 243 | bool PPPData::get_show_clock_on_caption() { |
225 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); | 244 | return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); |
226 | } | 245 | } |
227 | 246 | ||
228 | 247 | ||
229 | void PPPData::set_show_clock_on_caption(bool set) { | 248 | void PPPData::set_show_clock_on_caption(bool set) { |
230 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 249 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
231 | } | 250 | } |
232 | 251 | ||
233 | 252 | ||
234 | bool PPPData::get_xserver_exit_disconnect() { | 253 | bool PPPData::get_xserver_exit_disconnect() { |
235 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 254 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
236 | } | 255 | } |
237 | 256 | ||
238 | 257 | ||
239 | void PPPData::setPPPDebug(bool set) { | 258 | void PPPData::setPPPDebug(bool set) { |
240 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 259 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
241 | } | 260 | } |
242 | 261 | ||
243 | 262 | ||
244 | bool PPPData::getPPPDebug() { | 263 | bool PPPData::getPPPDebug() { |
245 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 264 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
246 | } | 265 | } |
247 | 266 | ||
248 | 267 | ||
249 | void PPPData::set_xserver_exit_disconnect(bool set) { | 268 | void PPPData::set_xserver_exit_disconnect(bool set) { |
250 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 269 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
251 | } | 270 | } |
252 | 271 | ||
253 | 272 | ||
254 | bool PPPData::quit_on_disconnect() { | 273 | bool PPPData::quit_on_disconnect() { |
255 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 274 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
256 | } | 275 | } |
257 | 276 | ||
258 | 277 | ||
259 | void PPPData::set_quit_on_disconnect(bool set) { | 278 | void PPPData::set_quit_on_disconnect(bool set) { |
260 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 279 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
261 | } | 280 | } |
262 | 281 | ||
263 | 282 | ||
264 | bool PPPData::get_show_log_window() { | 283 | bool PPPData::get_show_log_window() { |
265 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 284 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
266 | } | 285 | } |
267 | 286 | ||
268 | 287 | ||
269 | void PPPData::set_show_log_window(bool set) { | 288 | void PPPData::set_show_log_window(bool set) { |
270 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 289 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
271 | } | 290 | } |
272 | 291 | ||
273 | 292 | ||
274 | bool PPPData::automatic_redial() { | 293 | bool PPPData::automatic_redial() { |
275 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 294 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
276 | } | 295 | } |
277 | 296 | ||
278 | 297 | ||
279 | void PPPData::set_automatic_redial(bool set) { | 298 | void PPPData::set_automatic_redial(bool set) { |
280 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 299 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
281 | } | 300 | } |
282 | 301 | ||
283 | 302 | ||
284 | bool PPPData::get_iconify_on_connect() { | 303 | // bool PPPData::get_iconify_on_connect() { |
285 | return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 304 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
286 | } | 305 | // } |
287 | 306 | ||
288 | 307 | ||
289 | void PPPData::set_iconify_on_connect(bool set) { | 308 | // void PPPData::set_iconify_on_connect(bool set) { |
290 | writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 309 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
291 | } | 310 | // } |
292 | 311 | ||
293 | 312 | ||
294 | bool PPPData::get_dock_into_panel() { | 313 | // bool PPPData::get_dock_into_panel() { |
295 | return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 314 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
296 | } | 315 | // } |
297 | 316 | ||
298 | 317 | ||
299 | void PPPData::set_dock_into_panel(bool set) { | 318 | // void PPPData::set_dock_into_panel(bool set) { |
300 | writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 319 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
301 | } | 320 | // } |
302 | 321 | ||
303 | 322 | ||
304 | QString PPPData::pppdVersion() { | 323 | QString PPPData::pppdVersion() { |
305 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 324 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
306 | } | 325 | } |
307 | 326 | ||
308 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 327 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
309 | // check if pppd version fulfills minimum requirement | 328 | // check if pppd version fulfills minimum requirement |
310 | return (pppdVer > ver | 329 | return (pppdVer > ver |
311 | || (pppdVer == ver && pppdMod > mod) | 330 | || (pppdVer == ver && pppdMod > mod) |
312 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 331 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
313 | } | 332 | } |
314 | 333 | ||
315 | int PPPData::pppdTimeout() { | 334 | int PPPData::pppdTimeout() { |
316 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 335 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
317 | } | 336 | } |
318 | 337 | ||
319 | 338 | ||
320 | void PPPData::setpppdTimeout(int n) { | 339 | void PPPData::setpppdTimeout(int n) { |
321 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 340 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
322 | } | 341 | } |
323 | 342 | ||
324 | 343 | ||
325 | const QString PPPData::modemDevice() { | 344 | const QString PPPData::modemDevice() { |
326 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 345 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); |
327 | } | 346 | } |
328 | 347 | ||
329 | 348 | ||
330 | bool PPPData::setModemDevice(const QString &n) { | 349 | bool PPPData::setModemDevice(const QString &n) { |
331 | bool ret = false; | 350 | bool ret = false; |
332 | for (int i = 0; devices[i]; i++) | 351 | for (int i = 0; devices[i]; i++) |
333 | if (devices[i] == n){ | 352 | if (devices[i] == n){ |
334 | modemDeviceGroup = i; | 353 | modemDeviceGroup = i; |
335 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 354 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
336 | ret = true; | 355 | ret = true; |
337 | } | 356 | } |
338 | return ret; | 357 | return ret; |
339 | } | 358 | } |
340 | 359 | ||
341 | 360 | ||
342 | const QString PPPData::flowcontrol() { | 361 | const QString PPPData::flowcontrol() { |
343 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 362 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
344 | } | 363 | } |
345 | 364 | ||
346 | 365 | ||
347 | void PPPData::setFlowcontrol(const QString &n) { | 366 | void PPPData::setFlowcontrol(const QString &n) { |
348 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 367 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
349 | } | 368 | } |
350 | 369 | ||
351 | 370 | ||
352 | const QString PPPData::speed() { | 371 | const QString PPPData::speed() { |
353 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 372 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
354 | // undo the damage of a bug in former versions. It left an empty Speed= | 373 | // undo the damage of a bug in former versions. It left an empty Speed= |
355 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 374 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
356 | // pppd wouldn't receive the speed via the command line. | 375 | // pppd wouldn't receive the speed via the command line. |
357 | if(s.toUInt() == 0) | 376 | if(s.toUInt() == 0) |
358 | s = "57600"; | 377 | s = "57600"; |
359 | return s; | 378 | return s; |
360 | } | 379 | } |
361 | 380 | ||
362 | 381 | ||
363 | void PPPData::setSpeed(const QString &n) { | 382 | void PPPData::setSpeed(const QString &n) { |
364 | writeConfig(modemGroup(), SPEED_KEY, n); | 383 | writeConfig(modemGroup(), SPEED_KEY, n); |
365 | } | 384 | } |
366 | 385 | ||
367 | 386 | ||
368 | #if 0 | 387 | #if 0 |
369 | void PPPData::setUseCDLine(const int n) { | 388 | void PPPData::setUseCDLine(const int n) { |
370 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 389 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
371 | } | 390 | } |
372 | 391 | ||
373 | 392 | ||
374 | int PPPData::UseCDLine() { | 393 | int PPPData::UseCDLine() { |
375 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 394 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
376 | } | 395 | } |
377 | #endif | 396 | #endif |
378 | 397 | ||
379 | const QString PPPData::modemEscapeStr() { | 398 | const QString PPPData::modemEscapeStr() { |
380 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 399 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
381 | } | 400 | } |
382 | 401 | ||
383 | 402 | ||
384 | void PPPData::setModemEscapeStr(const QString &n) { | 403 | void PPPData::setModemEscapeStr(const QString &n) { |
385 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 404 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
386 | } | 405 | } |
387 | 406 | ||
388 | 407 | ||
389 | const QString PPPData::modemEscapeResp() { | 408 | const QString PPPData::modemEscapeResp() { |
390 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 409 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
391 | } | 410 | } |
392 | 411 | ||
393 | 412 | ||
394 | void PPPData::setModemEscapeResp(const QString &n) { | 413 | void PPPData::setModemEscapeResp(const QString &n) { |
395 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 414 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
396 | } | 415 | } |
397 | 416 | ||
398 | 417 | ||
399 | int PPPData::modemEscapeGuardTime() { | 418 | int PPPData::modemEscapeGuardTime() { |
400 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 419 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
401 | } | 420 | } |
402 | 421 | ||
403 | 422 | ||
404 | void PPPData::setModemEscapeGuardTime(int n) { | 423 | void PPPData::setModemEscapeGuardTime(int n) { |
405 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 424 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
406 | } | 425 | } |
407 | 426 | ||
408 | 427 | ||
409 | bool PPPData::modemLockFile() { | 428 | bool PPPData::modemLockFile() { |
410 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 429 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
411 | } | 430 | } |
412 | 431 | ||
413 | 432 | ||
414 | void PPPData::setModemLockFile(bool set) { | 433 | void PPPData::setModemLockFile(bool set) { |
415 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 434 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
416 | } | 435 | } |
417 | 436 | ||
418 | 437 | ||
419 | int PPPData::modemTimeout() { | 438 | int PPPData::modemTimeout() { |
420 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 439 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
421 | } | 440 | } |
422 | 441 | ||
423 | 442 | ||
424 | void PPPData::setModemTimeout(int n) { | 443 | void PPPData::setModemTimeout(int n) { |
425 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 444 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
426 | } | 445 | } |
427 | 446 | ||
428 | 447 | ||
429 | int PPPData::modemToneDuration() { | 448 | int PPPData::modemToneDuration() { |
430 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 449 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
431 | } | 450 | } |
432 | 451 | ||
433 | 452 | ||
434 | void PPPData::setModemToneDuration(int n) { | 453 | void PPPData::setModemToneDuration(int n) { |
435 | writeConfig(modemGroup(), TONEDURATION_KEY, n); | 454 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
436 | } | 455 | } |
437 | 456 | ||
438 | 457 | ||
439 | int PPPData::busyWait() { | 458 | int PPPData::busyWait() { |
440 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); | 459 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
441 | } | 460 | } |
442 | 461 | ||
443 | 462 | ||
444 | void PPPData::setbusyWait(int n) { | 463 | void PPPData::setbusyWait(int n) { |
445 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); | 464 | writeConfig(modemGroup(), BUSYWAIT_KEY, n); |
446 | } | 465 | } |
447 | 466 | ||
448 | 467 | ||
449 | // | 468 | // |
450 | //Advanced "Modem" dialog | 469 | //Advanced "Modem" dialog |
451 | // | 470 | // |
452 | // defaults: InitString=ATZ, InitString1="" etc. | 471 | // defaults: InitString=ATZ, InitString1="" etc. |
453 | const QString PPPData::modemInitStr(int i) { | 472 | const QString PPPData::modemInitStr(int i) { |
454 | assert(i >= 0 && i < NumInitStrings); | 473 | assert(i >= 0 && i < NumInitStrings); |
455 | if(i == 0) | 474 | if(i == 0) |
456 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); | 475 | return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); |
457 | else | 476 | else |
458 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); | 477 | return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); |
459 | } | 478 | } |
460 | 479 | ||
461 | 480 | ||
462 | void PPPData::setModemInitStr(int i, const QString &n) { | 481 | void PPPData::setModemInitStr(int i, const QString &n) { |
463 | assert(i >= 0 && i < NumInitStrings); | 482 | assert(i >= 0 && i < NumInitStrings); |
464 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); | 483 | QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); |
465 | writeConfig(modemGroup(), k, n); | 484 | writeConfig(modemGroup(), k, n); |
466 | } | 485 | } |
467 | 486 | ||
468 | 487 | ||
469 | const QString PPPData::modemInitResp() { | 488 | const QString PPPData::modemInitResp() { |
470 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); | 489 | return readConfig(modemGroup(), INITRESP_KEY, "OK"); |
471 | } | 490 | } |
472 | 491 | ||
473 | 492 | ||
474 | void PPPData::setModemInitResp(const QString &n) { | 493 | void PPPData::setModemInitResp(const QString &n) { |
475 | writeConfig(modemGroup(), INITRESP_KEY, n); | 494 | writeConfig(modemGroup(), INITRESP_KEY, n); |
476 | } | 495 | } |
477 | 496 | ||
478 | 497 | ||
479 | int PPPData::modemPreInitDelay() { | 498 | int PPPData::modemPreInitDelay() { |
480 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); | 499 | return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); |
481 | } | 500 | } |
482 | 501 | ||
483 | 502 | ||
484 | void PPPData::setModemPreInitDelay(int n) { | 503 | void PPPData::setModemPreInitDelay(int n) { |
485 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); | 504 | writeConfig(modemGroup(), PREINITDELAY_KEY, n); |
486 | } | 505 | } |
487 | 506 | ||
488 | 507 | ||
489 | int PPPData::modemInitDelay() { | 508 | int PPPData::modemInitDelay() { |
490 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); | 509 | return readNumConfig(modemGroup(), INITDELAY_KEY, 50); |
491 | } | 510 | } |
492 | 511 | ||
493 | 512 | ||
494 | void PPPData::setModemInitDelay(int n) { | 513 | void PPPData::setModemInitDelay(int n) { |
495 | writeConfig(modemGroup(), INITDELAY_KEY, n); | 514 | writeConfig(modemGroup(), INITDELAY_KEY, n); |
496 | } | 515 | } |
497 | 516 | ||
498 | QString PPPData::modemNoDialToneDetectionStr() { | 517 | QString PPPData::modemNoDialToneDetectionStr() { |
499 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); | 518 | return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); |
500 | } | 519 | } |
501 | 520 | ||
502 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { | 521 | void PPPData::setModemNoDialToneDetectionStr(const QString &n) { |
503 | writeConfig(modemGroup(), NODTDETECT_KEY, n); | 522 | writeConfig(modemGroup(), NODTDETECT_KEY, n); |
504 | } | 523 | } |
505 | 524 | ||
506 | const QString PPPData::modemDialStr() { | 525 | const QString PPPData::modemDialStr() { |
507 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); | 526 | return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); |
508 | } | 527 | } |
509 | 528 | ||
510 | 529 | ||
511 | void PPPData::setModemDialStr(const QString &n) { | 530 | void PPPData::setModemDialStr(const QString &n) { |
512 | writeConfig(modemGroup(), DIALSTR_KEY, n); | 531 | writeConfig(modemGroup(), DIALSTR_KEY, n); |
513 | } | 532 | } |
514 | 533 | ||
515 | 534 | ||
516 | const QString PPPData::modemConnectResp() { | 535 | const QString PPPData::modemConnectResp() { |
517 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); | 536 | return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); |
518 | } | 537 | } |
519 | 538 | ||
520 | 539 | ||
521 | void PPPData::setModemConnectResp(const QString &n) { | 540 | void PPPData::setModemConnectResp(const QString &n) { |
522 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); | 541 | writeConfig(modemGroup(), CONNECTRESP_KEY, n); |
523 | } | 542 | } |
524 | 543 | ||
525 | 544 | ||
526 | const QString PPPData::modemBusyResp() { | 545 | const QString PPPData::modemBusyResp() { |
527 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); | 546 | return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); |
528 | } | 547 | } |
529 | 548 | ||
530 | 549 | ||
531 | void PPPData::setModemBusyResp(const QString &n) { | 550 | void PPPData::setModemBusyResp(const QString &n) { |
532 | writeConfig(modemGroup(), BUSYRESP_KEY, n); | 551 | writeConfig(modemGroup(), BUSYRESP_KEY, n); |
533 | } | 552 | } |
534 | 553 | ||
535 | 554 | ||
536 | const QString PPPData::modemNoCarrierResp() { | 555 | const QString PPPData::modemNoCarrierResp() { |
537 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); | 556 | return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); |
538 | } | 557 | } |
539 | 558 | ||
540 | 559 | ||
541 | void PPPData::setModemNoCarrierResp(const QString &n) { | 560 | void PPPData::setModemNoCarrierResp(const QString &n) { |
542 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); | 561 | writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); |
543 | } | 562 | } |
544 | 563 | ||
545 | 564 | ||
546 | const QString PPPData::modemNoDialtoneResp() { | 565 | const QString PPPData::modemNoDialtoneResp() { |
547 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); | 566 | return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); |
548 | } | 567 | } |
549 | 568 | ||
550 | 569 | ||
551 | void PPPData::setModemNoDialtoneResp(const QString &n) { | 570 | void PPPData::setModemNoDialtoneResp(const QString &n) { |
552 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); | 571 | writeConfig(modemGroup(), NODIALTONERESP_KEY, n); |
553 | } | 572 | } |
554 | 573 | ||
555 | 574 | ||
556 | const QString PPPData::modemHangupStr() { | 575 | const QString PPPData::modemHangupStr() { |
557 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); | 576 | return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); |
558 | } | 577 | } |
559 | 578 | ||
560 | void PPPData::setModemHangupStr(const QString &n) { | 579 | void PPPData::setModemHangupStr(const QString &n) { |
561 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); | 580 | writeConfig(modemGroup(), HANGUPSTR_KEY, n); |
562 | } | 581 | } |
563 | 582 | ||
564 | 583 | ||
565 | const QString PPPData::modemHangupResp() { | 584 | const QString PPPData::modemHangupResp() { |
566 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); | 585 | return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); |
567 | } | 586 | } |
568 | 587 | ||
569 | void PPPData::setModemHangupResp(const QString &n) { | 588 | void PPPData::setModemHangupResp(const QString &n) { |
570 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); | 589 | writeConfig(modemGroup(), HANGUPRESP_KEY, n); |
571 | } | 590 | } |
572 | 591 | ||
573 | 592 | ||
574 | const QString PPPData::modemAnswerStr() { | 593 | const QString PPPData::modemAnswerStr() { |
575 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); | 594 | return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); |
576 | } | 595 | } |
577 | 596 | ||
578 | 597 | ||
579 | QString PPPData::volumeOff() { | 598 | QString PPPData::volumeOff() { |
580 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); | 599 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
581 | } | 600 | } |
582 | 601 | ||
583 | 602 | ||
584 | void PPPData::setVolumeOff(const QString &s) { | 603 | void PPPData::setVolumeOff(const QString &s) { |
585 | writeConfig(modemGroup(), VOLUME_OFF, s); | 604 | writeConfig(modemGroup(), VOLUME_OFF, s); |
586 | } | 605 | } |
587 | 606 | ||
588 | 607 | ||
589 | QString PPPData::volumeMedium() { | 608 | QString PPPData::volumeMedium() { |
590 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); | 609 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
591 | } | 610 | } |
592 | 611 | ||
593 | 612 | ||
594 | void PPPData::setVolumeMedium(const QString &s) { | 613 | void PPPData::setVolumeMedium(const QString &s) { |
595 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); | 614 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
596 | } | 615 | } |
597 | 616 | ||
598 | 617 | ||
599 | QString PPPData::volumeHigh() { | 618 | QString PPPData::volumeHigh() { |
600 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); | 619 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
601 | if(tmp == "M1L4") | 620 | if(tmp == "M1L4") |
602 | tmp = "M1L3"; | 621 | tmp = "M1L3"; |
603 | return tmp; | 622 | return tmp; |
604 | } | 623 | } |
605 | 624 | ||
606 | 625 | ||
607 | void PPPData::setVolumeHigh(const QString &s) { | 626 | void PPPData::setVolumeHigh(const QString &s) { |
608 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 627 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
609 | } | 628 | } |
610 | 629 | ||
611 | 630 | ||
612 | QString PPPData::volumeInitString() { | 631 | QString PPPData::volumeInitString() { |
613 | QString s; | 632 | QString s; |
614 | 633 | ||
615 | switch(volume()) { | 634 | switch(volume()) { |
616 | case 0: | 635 | case 0: |
617 | s = volumeOff(); | 636 | s = volumeOff(); |
618 | break; | 637 | break; |
619 | case 1: | 638 | case 1: |
620 | s = volumeMedium(); | 639 | s = volumeMedium(); |
621 | break; | 640 | break; |
622 | case 2: | 641 | case 2: |
623 | s = volumeHigh(); | 642 | s = volumeHigh(); |
624 | break; | 643 | break; |
625 | default: | 644 | default: |
626 | s = volumeMedium(); | 645 | s = volumeMedium(); |
627 | } | 646 | } |
628 | 647 | ||
629 | return s; | 648 | return s; |
630 | } | 649 | } |
631 | 650 | ||
632 | 651 | ||
633 | int PPPData::volume() { | 652 | int PPPData::volume() { |
634 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 653 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
635 | } | 654 | } |
636 | 655 | ||
637 | 656 | ||
638 | void PPPData::setVolume(int i) { | 657 | void PPPData::setVolume(int i) { |
639 | writeConfig(modemGroup(), VOLUME_KEY, i); | 658 | writeConfig(modemGroup(), VOLUME_KEY, i); |
640 | } | 659 | } |
641 | 660 | ||
642 | int PPPData::waitForDialTone() { | 661 | int PPPData::waitForDialTone() { |
643 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 662 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
644 | } | 663 | } |
645 | 664 | ||
646 | void PPPData::setWaitForDialTone(int i) { | 665 | void PPPData::setWaitForDialTone(int i) { |
647 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 666 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
648 | } | 667 | } |
649 | 668 | ||
650 | void PPPData::setModemAnswerStr(const QString &n) { | 669 | void PPPData::setModemAnswerStr(const QString &n) { |
651 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 670 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
652 | } | 671 | } |
653 | 672 | ||
654 | 673 | ||
655 | const QString PPPData::modemRingResp() { | 674 | const QString PPPData::modemRingResp() { |
656 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 675 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
657 | } | 676 | } |
658 | 677 | ||
659 | 678 | ||
660 | void PPPData::setModemRingResp(const QString &n) { | 679 | void PPPData::setModemRingResp(const QString &n) { |
661 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 680 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
662 | } | 681 | } |
663 | 682 | ||
664 | 683 | ||
665 | const QString PPPData::modemAnswerResp() { | 684 | const QString PPPData::modemAnswerResp() { |
666 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 685 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
667 | } | 686 | } |
668 | 687 | ||
669 | 688 | ||
670 | void PPPData::setModemAnswerResp(const QString &n) { | 689 | void PPPData::setModemAnswerResp(const QString &n) { |
671 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 690 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
672 | } | 691 | } |
673 | 692 | ||
674 | 693 | ||
675 | const QString PPPData::enter() { | 694 | const QString PPPData::enter() { |
676 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 695 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
677 | } | 696 | } |
678 | 697 | ||
679 | 698 | ||
680 | void PPPData::setEnter(const QString &n) { | 699 | void PPPData::setEnter(const QString &n) { |
681 | writeConfig(modemGroup(), ENTER_KEY, n); | 700 | writeConfig(modemGroup(), ENTER_KEY, n); |
682 | } | 701 | } |
683 | 702 | ||
684 | 703 | ||
685 | // | 704 | // |
686 | // functions to set/return account information | 705 | // functions to set/return account information |
687 | // | 706 | // |
688 | 707 | ||
689 | //returns number of accounts | 708 | //returns number of accounts |
690 | int PPPData::count() const { | 709 | int PPPData::count() const { |
691 | return highcount + 1; | 710 | return highcount + 1; |
692 | } | 711 | } |
693 | 712 | ||
694 | 713 | ||
695 | bool PPPData::setAccount(const QString &aname) { | 714 | bool PPPData::setAccount(const QString &aname) { |
696 | for(int i = 0; i <= highcount; i++) { | 715 | for(int i = 0; i <= highcount; i++) { |
697 | setAccountbyIndex(i); | 716 | setAccountbyIndex(i); |
698 | if(accname() == aname) { | 717 | if(accname() == aname) { |
699 | caccount = i; | 718 | caccount = i; |
700 | return true; | 719 | return true; |
701 | } | 720 | } |
702 | } | 721 | } |
703 | return false; | 722 | return false; |
704 | } | 723 | } |
705 | 724 | ||
706 | 725 | ||
707 | bool PPPData::setAccountbyIndex(int i) { | 726 | bool PPPData::setAccountbyIndex(int i) { |
708 | if(i >= 0 && i <= highcount) { | 727 | if(i >= 0 && i <= highcount) { |
709 | caccount = i; | 728 | caccount = i; |
710 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 729 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); |
711 | return true; | 730 | return true; |
712 | } | 731 | } |
713 | return false; | 732 | return false; |
714 | } | 733 | } |
715 | 734 | ||
716 | 735 | ||
717 | bool PPPData::isUniqueAccname(const QString &n) { | 736 | bool PPPData::isUniqueAccname(const QString &n) { |
718 | int current = caccount; | 737 | int current = caccount; |
719 | for(int i=0; i <= highcount; i++) { | 738 | for(int i=0; i <= highcount; i++) { |
720 | setAccountbyIndex(i); | 739 | setAccountbyIndex(i); |
721 | if(accname() == n && i != current) { | 740 | if(accname() == n && i != current) { |
722 | setAccountbyIndex(current); | 741 | setAccountbyIndex(current); |
723 | return false; | 742 | return false; |
724 | } | 743 | } |
725 | } | 744 | } |
726 | setAccountbyIndex(current); | 745 | setAccountbyIndex(current); |
727 | return true; | 746 | return true; |
728 | } | 747 | } |
729 | 748 | ||
730 | 749 | ||
731 | bool PPPData::deleteAccount() { | 750 | bool PPPData::deleteAccount() { |
732 | //FIXME: | 751 | //FIXME: |
733 | // if(caccount < 0) | 752 | // if(caccount < 0) |
734 | return false; | 753 | return false; |
735 | 754 | ||
736 | // QMap <QString, QString> map; | 755 | // QMap <QString, QString> map; |
737 | // QMap <QString, QString>::Iterator it; | 756 | // QMap <QString, QString>::Iterator it; |
738 | 757 | ||
739 | // // set all entries of the current account to "" | 758 | // // set all entries of the current account to "" |
740 | // map = config->entryMap(cgroup); | 759 | // map = config->entryMap(cgroup); |
741 | // it = map.begin(); | 760 | // it = map.begin(); |
742 | // while (it != map.end()) { | 761 | // while (it != map.end()) { |
743 | // config->writeEntry(it.key(), ""); | 762 | // config->writeEntry(it.key(), ""); |
744 | // it++; | 763 | // it++; |
745 | // } | 764 | // } |
746 | 765 | ||
747 | // // shift the succeeding accounts | 766 | // // shift the succeeding accounts |
748 | // for(int i = caccount+1; i <= highcount; i++) { | 767 | // for(int i = caccount+1; i <= highcount; i++) { |
749 | // setAccountbyIndex(i); | 768 | // setAccountbyIndex(i); |
750 | // map = config->entryMap(cgroup); | 769 | // map = config->entryMap(cgroup); |
751 | // it = map.begin(); | 770 | // it = map.begin(); |
752 | // setAccountbyIndex(i-1); | 771 | // setAccountbyIndex(i-1); |
753 | // config->setGroup(cgroup); | 772 | // config->setGroup(cgroup); |
754 | // while (it != map.end()) { | 773 | // while (it != map.end()) { |
755 | // config->writeEntry(it.key(), *it); | 774 | // config->writeEntry(it.key(), *it); |
756 | // it++; | 775 | // it++; |
757 | // } | 776 | // } |
758 | // } | 777 | // } |
759 | 778 | ||
760 | // // make sure the top account is cleared | 779 | // // make sure the top account is cleared |
761 | // setAccountbyIndex(highcount); | 780 | // setAccountbyIndex(highcount); |
762 | // map = config->entryMap(cgroup); | 781 | // map = config->entryMap(cgroup); |
763 | // it = map.begin(); | 782 | // it = map.begin(); |
764 | // config->setGroup(cgroup); | 783 | // config->setGroup(cgroup); |
765 | // while (it.key() != QString::null) { | 784 | // while (it.key() != QString::null) { |
766 | // config->writeEntry(it.key(), ""); | 785 | // config->writeEntry(it.key(), ""); |
767 | // it++; | 786 | // it++; |
768 | // } | 787 | // } |
769 | 788 | ||
770 | // highcount--; | 789 | // highcount--; |
771 | // if(caccount > highcount) | 790 | // if(caccount > highcount) |
772 | // caccount = highcount; | 791 | // caccount = highcount; |
773 | 792 | ||
774 | // setAccountbyIndex(caccount); | 793 | // setAccountbyIndex(caccount); |
775 | 794 | ||
776 | // return true; | 795 | // return true; |
777 | } | 796 | } |
778 | 797 | ||
779 | 798 | ||
780 | bool PPPData::deleteAccount(const QString &aname) { | 799 | bool PPPData::deleteAccount(const QString &aname) { |
781 | if(!setAccount(aname)) | 800 | if(!setAccount(aname)) |
782 | return false; | 801 | return false; |
783 | 802 | ||
784 | deleteAccount(); | 803 | deleteAccount(); |
785 | 804 | ||
786 | return true; | 805 | return true; |
787 | } | 806 | } |
788 | 807 | ||
789 | 808 | ||
790 | int PPPData::newaccount() { | 809 | int PPPData::newaccount() { |
791 | 810 | ||
792 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 811 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
793 | if(!config) open(); | 812 | // if(!config) open(); |
794 | if (highcount >= MAX_ACCOUNTS) return -1; | 813 | if (highcount >= MAX_ACCOUNTS) return -1; |
795 | 814 | ||
796 | highcount++; | 815 | highcount++; |
797 | setAccountbyIndex(highcount); | 816 | setAccountbyIndex(highcount); |
798 | 817 | ||
799 | setpppdArgumentDefaults(); | 818 | setpppdArgumentDefaults(); |
800 | qDebug("PPPData::newaccount -> %i",caccount); | 819 | qDebug("PPPData::newaccount -> %i",caccount); |
801 | return caccount; | 820 | return caccount; |
802 | } | 821 | } |
803 | 822 | ||
804 | int PPPData::copyaccount(int i) { | 823 | int PPPData::copyaccount(int i) { |
805 | // FIXME | 824 | // FIXME |
806 | // if(highcount >= MAX_ACCOUNTS) | 825 | // if(highcount >= MAX_ACCOUNTS) |
807 | return -1; | 826 | return -1; |
808 | 827 | ||
809 | // setAccountbyIndex(i); | 828 | // setAccountbyIndex(i); |
810 | 829 | ||
811 | // QMap <QString, QString> map = config->entryMap(cgroup); | 830 | // QMap <QString, QString> map = config->entryMap(cgroup); |
812 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 831 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
813 | 832 | ||
814 | // QString newname = i18n("%1_copy").arg(accname()); | 833 | // QString newname = i18n("%1_copy").arg(accname()); |
815 | 834 | ||
816 | // newaccount(); | 835 | // newaccount(); |
817 | 836 | ||
818 | // while (it != map.end()) { | 837 | // while (it != map.end()) { |
819 | // config->writeEntry(it.key(), *it); | 838 | // config->writeEntry(it.key(), *it); |
820 | // it++; | 839 | // it++; |
821 | // } | 840 | // } |
822 | 841 | ||
823 | // setAccname(newname); | 842 | // setAccname(newname); |
824 | 843 | ||
825 | // return caccount; | 844 | // return caccount; |
826 | } | 845 | } |
827 | 846 | ||
828 | 847 | ||
829 | const QString PPPData::accname() { | 848 | const QString PPPData::accname() { |
830 | return readConfig(cgroup, NAME_KEY); | 849 | return readConfig(cgroup, NAME_KEY); |
831 | } | 850 | } |
832 | 851 | ||
833 | void PPPData::setAccname(const QString &n) { | 852 | void PPPData::setAccname(const QString &n) { |
834 | if(!cgroup.isNull()) { | 853 | if(!cgroup.isNull()) { |
835 | // are we manipulating the default account's name ? then change it, too. | 854 | // are we manipulating the default account's name ? then change it, too. |
836 | bool def = accname() == defaultAccount(); | 855 | bool def = accname() == defaultAccount(); |
837 | writeConfig(cgroup, NAME_KEY, n); | 856 | writeConfig(cgroup, NAME_KEY, n); |
838 | if (def) | 857 | if (def) |
839 | setDefaultAccount(n); | 858 | setDefaultAccount(n); |
840 | } | 859 | } |
841 | } | 860 | } |
842 | 861 | ||
843 | 862 | ||
844 | #define SEPARATOR_CHAR '&' | 863 | #define SEPARATOR_CHAR '&' |
845 | QStringList &PPPData::phonenumbers() { | 864 | QStringList &PPPData::phonenumbers() { |
846 | 865 | ||
847 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 866 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
848 | return phonelist; | 867 | return phonelist; |
849 | 868 | ||
850 | } | 869 | } |
851 | 870 | ||
852 | 871 | ||
853 | const QString PPPData::phonenumber() { | 872 | const QString PPPData::phonenumber() { |
854 | return readConfig(cgroup, PHONENUMBER_KEY); | 873 | return readConfig(cgroup, PHONENUMBER_KEY); |
855 | } | 874 | } |
856 | 875 | ||
857 | 876 | ||
858 | void PPPData::setPhonenumber(const QString &n) { | 877 | void PPPData::setPhonenumber(const QString &n) { |
859 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 878 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
860 | } | 879 | } |
861 | 880 | ||
862 | 881 | ||
863 | const QString PPPData::dialPrefix() { | 882 | const QString PPPData::dialPrefix() { |
864 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 883 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
865 | } | 884 | } |
866 | 885 | ||
867 | 886 | ||
868 | void PPPData::setDialPrefix(const QString &s) { | 887 | void PPPData::setDialPrefix(const QString &s) { |
869 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 888 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
870 | } | 889 | } |
871 | 890 | ||
872 | 891 | ||
873 | int PPPData::authMethod() { | 892 | int PPPData::authMethod() { |
874 | return readNumConfig(cgroup, AUTH_KEY, 0); | 893 | return readNumConfig(cgroup, AUTH_KEY, 0); |
875 | } | 894 | } |
876 | 895 | ||
877 | 896 | ||
878 | void PPPData::setAuthMethod(int value) { | 897 | void PPPData::setAuthMethod(int value) { |
879 | writeConfig(cgroup, AUTH_KEY, value); | 898 | writeConfig(cgroup, AUTH_KEY, value); |
880 | } | 899 | } |
881 | 900 | ||
882 | 901 | ||
883 | const QString PPPData::storedUsername() { | 902 | const QString PPPData::storedUsername() { |
884 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 903 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
885 | } | 904 | } |
886 | 905 | ||
887 | 906 | ||
888 | void PPPData::setStoredUsername(const QString &b) { | 907 | void PPPData::setStoredUsername(const QString &b) { |
889 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 908 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
890 | } | 909 | } |
891 | 910 | ||
892 | 911 | ||
893 | const QString PPPData::storedPassword() { | 912 | const QString PPPData::storedPassword() { |
894 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 913 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
895 | } | 914 | } |
896 | 915 | ||
897 | 916 | ||
898 | void PPPData::setStoredPassword(const QString &b) { | 917 | void PPPData::setStoredPassword(const QString &b) { |
899 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 918 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
900 | } | 919 | } |
901 | 920 | ||
902 | 921 | ||
903 | bool PPPData::storePassword() { | 922 | bool PPPData::storePassword() { |
904 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 923 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
905 | } | 924 | } |
906 | 925 | ||
907 | 926 | ||
908 | const QString PPPData::command_before_connect() { | 927 | const QString PPPData::command_before_connect() { |
909 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 928 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
910 | } | 929 | } |
911 | 930 | ||
912 | 931 | ||
913 | void PPPData::setCommand_before_connect(const QString &n) { | 932 | void PPPData::setCommand_before_connect(const QString &n) { |
914 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 933 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
915 | } | 934 | } |
916 | 935 | ||
917 | 936 | ||
918 | void PPPData::setStorePassword(bool b) { | 937 | void PPPData::setStorePassword(bool b) { |
919 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | 938 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); |
920 | } | 939 | } |
921 | 940 | ||
922 | 941 | ||
923 | const QString PPPData::command_on_connect() { | 942 | const QString PPPData::command_on_connect() { |
924 | return readConfig(cgroup, COMMAND_KEY); | 943 | return readConfig(cgroup, COMMAND_KEY); |
925 | } | 944 | } |
926 | 945 | ||
927 | 946 | ||
928 | void PPPData::setCommand_on_connect(const QString &n) { | 947 | void PPPData::setCommand_on_connect(const QString &n) { |
929 | writeConfig(cgroup, COMMAND_KEY, n); | 948 | writeConfig(cgroup, COMMAND_KEY, n); |
930 | } | 949 | } |
931 | 950 | ||
932 | 951 | ||
933 | const QString PPPData::command_on_disconnect() { | 952 | const QString PPPData::command_on_disconnect() { |
934 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); | 953 | return readConfig(cgroup, DISCONNECT_COMMAND_KEY); |
935 | } | 954 | } |
936 | 955 | ||
937 | 956 | ||
938 | void PPPData::setCommand_on_disconnect(const QString &n) { | 957 | void PPPData::setCommand_on_disconnect(const QString &n) { |
939 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); | 958 | writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); |
940 | } | 959 | } |
941 | 960 | ||
942 | 961 | ||
943 | const QString PPPData::command_before_disconnect() { | 962 | const QString PPPData::command_before_disconnect() { |
944 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); | 963 | return readConfig(cgroup, BEFORE_DISCONNECT_KEY); |
945 | } | 964 | } |
946 | 965 | ||
947 | 966 | ||
948 | void PPPData::setCommand_before_disconnect(const QString &n) { | 967 | void PPPData::setCommand_before_disconnect(const QString &n) { |
949 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); | 968 | writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); |
950 | } | 969 | } |
951 | 970 | ||
952 | 971 | ||
953 | const QString PPPData::ipaddr() { | 972 | const QString PPPData::ipaddr() { |
954 | return readConfig(cgroup, IPADDR_KEY); | 973 | return readConfig(cgroup, IPADDR_KEY); |
955 | } | 974 | } |
956 | 975 | ||
957 | 976 | ||
958 | void PPPData::setIpaddr(const QString &n) { | 977 | void PPPData::setIpaddr(const QString &n) { |
959 | writeConfig(cgroup, IPADDR_KEY, n); | 978 | writeConfig(cgroup, IPADDR_KEY, n); |
960 | } | 979 | } |
961 | 980 | ||
962 | 981 | ||
963 | const QString PPPData::subnetmask() { | 982 | const QString PPPData::subnetmask() { |
964 | return readConfig(cgroup, SUBNETMASK_KEY); | 983 | return readConfig(cgroup, SUBNETMASK_KEY); |
965 | } | 984 | } |
966 | 985 | ||
967 | 986 | ||
968 | void PPPData::setSubnetmask(const QString &n) { | 987 | void PPPData::setSubnetmask(const QString &n) { |
969 | writeConfig(cgroup, SUBNETMASK_KEY, n); | 988 | writeConfig(cgroup, SUBNETMASK_KEY, n); |
970 | } | 989 | } |
971 | 990 | ||
972 | 991 | ||
973 | bool PPPData::autoname() { | 992 | bool PPPData::autoname() { |
974 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); | 993 | return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); |
975 | } | 994 | } |
976 | 995 | ||
977 | 996 | ||
978 | void PPPData::setAutoname(bool set) { | 997 | void PPPData::setAutoname(bool set) { |
979 | writeConfig(cgroup, AUTONAME_KEY, (int) set); | 998 | writeConfig(cgroup, AUTONAME_KEY, (int) set); |
980 | } | 999 | } |
981 | 1000 | ||
982 | 1001 | ||
983 | bool PPPData::AcctEnabled() { | 1002 | bool PPPData::AcctEnabled() { |
984 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); | 1003 | return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); |
985 | } | 1004 | } |
986 | 1005 | ||
987 | 1006 | ||
988 | void PPPData::setAcctEnabled(bool set) { | 1007 | void PPPData::setAcctEnabled(bool set) { |
989 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); | 1008 | writeConfig(cgroup, ACCTENABLED_KEY, (int) set); |
990 | } | 1009 | } |
991 | 1010 | ||
992 | 1011 | ||
993 | int PPPData::VolAcctEnabled() { | 1012 | // int PPPData::VolAcctEnabled() { |
994 | return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); | 1013 | // return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); |
995 | } | 1014 | // } |
996 | 1015 | ||
997 | 1016 | ||
998 | void PPPData::setVolAcctEnabled(int set) { | 1017 | // void PPPData::setVolAcctEnabled(int set) { |
999 | writeConfig(cgroup, VOLACCTENABLED_KEY, set); | 1018 | // writeConfig(cgroup, VOLACCTENABLED_KEY, set); |
1000 | } | 1019 | // } |
1001 | 1020 | ||
1002 | 1021 | ||
1003 | const QString PPPData::gateway() { | 1022 | const QString PPPData::gateway() { |
1004 | return readConfig(cgroup, GATEWAY_KEY); | 1023 | return readConfig(cgroup, GATEWAY_KEY); |
1005 | } | 1024 | } |
1006 | 1025 | ||
1007 | 1026 | ||
1008 | void PPPData::setGateway(const QString &n ) { | 1027 | void PPPData::setGateway(const QString &n ) { |
1009 | writeConfig(cgroup, GATEWAY_KEY, n); | 1028 | writeConfig(cgroup, GATEWAY_KEY, n); |
1010 | } | 1029 | } |
1011 | 1030 | ||
1012 | 1031 | ||
1013 | bool PPPData::defaultroute() { | 1032 | bool PPPData::defaultroute() { |
1014 | // default route is by default 'on'. | 1033 | // default route is by default 'on'. |
1015 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); | 1034 | return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); |
1016 | } | 1035 | } |
1017 | 1036 | ||
1018 | 1037 | ||
1019 | void PPPData::setDefaultroute(bool set) { | 1038 | void PPPData::setDefaultroute(bool set) { |
1020 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); | 1039 | writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); |
1021 | } | 1040 | } |
1022 | 1041 | ||
1023 | 1042 | ||
1024 | bool PPPData::autoDNS() { | 1043 | bool PPPData::autoDNS() { |
1025 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); | 1044 | bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); |
1026 | return (set && PPPData::data()->pppdVersionMin(2, 3, 7)); | 1045 | return (set && pppdVersionMin(2, 3, 7)); |
1027 | } | 1046 | } |
1028 | 1047 | ||
1029 | 1048 | ||
1030 | void PPPData::setAutoDNS(bool set) { | 1049 | void PPPData::setAutoDNS(bool set) { |
1031 | writeConfig(cgroup, AUTODNS_KEY, (int) set); | 1050 | writeConfig(cgroup, AUTODNS_KEY, (int) set); |
1032 | } | 1051 | } |
1033 | 1052 | ||
1034 | 1053 | ||
1035 | void PPPData::setExDNSDisabled(bool set) { | 1054 | void PPPData::setExDNSDisabled(bool set) { |
1036 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); | 1055 | writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); |
1037 | } | 1056 | } |
1038 | 1057 | ||
1039 | 1058 | ||
1040 | bool PPPData::exDNSDisabled() { | 1059 | bool PPPData::exDNSDisabled() { |
1041 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); | 1060 | return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); |
1042 | } | 1061 | } |
1043 | 1062 | ||
1044 | 1063 | ||
1045 | QStringList &PPPData::dns() { | 1064 | QStringList &PPPData::dns() { |
1046 | static QStringList dnslist; | 1065 | static QStringList dnslist; |
1047 | 1066 | ||
1048 | readListConfig(cgroup, DNS_KEY, dnslist); | 1067 | readListConfig(cgroup, DNS_KEY, dnslist); |
1049 | while(dnslist.count() > MAX_DNS_ENTRIES) | 1068 | while(dnslist.count() > MAX_DNS_ENTRIES) |
1050 | dnslist.remove(dnslist.last()); | 1069 | dnslist.remove(dnslist.last()); |
1051 | 1070 | ||
1052 | return dnslist; | 1071 | return dnslist; |
1053 | } | 1072 | } |
1054 | 1073 | ||
1055 | 1074 | ||
1056 | void PPPData::setDns(QStringList &list) { | 1075 | void PPPData::setDns(QStringList &list) { |
1057 | writeListConfig(cgroup, DNS_KEY, list); | 1076 | writeListConfig(cgroup, DNS_KEY, list); |
1058 | } | 1077 | } |
1059 | 1078 | ||
1060 | 1079 | ||
1061 | const QString PPPData::domain() { | 1080 | const QString PPPData::domain() { |
1062 | return readConfig(cgroup, DOMAIN_KEY); | 1081 | return readConfig(cgroup, DOMAIN_KEY); |
1063 | } | 1082 | } |
1064 | 1083 | ||
1065 | 1084 | ||
1066 | void PPPData::setDomain(const QString &n ) { | 1085 | void PPPData::setDomain(const QString &n ) { |
1067 | writeConfig(cgroup, DOMAIN_KEY, n); | 1086 | writeConfig(cgroup, DOMAIN_KEY, n); |
1068 | } | 1087 | } |
1069 | 1088 | ||
1070 | 1089 | ||
1071 | QStringList &PPPData::scriptType() { | 1090 | QStringList &PPPData::scriptType() { |
1072 | static QStringList typelist; | 1091 | static QStringList typelist; |
1073 | 1092 | ||
1074 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | 1093 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); |
1075 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | 1094 | while(typelist.count() > MAX_SCRIPT_ENTRIES) |
1076 | typelist.remove(typelist.last()); | 1095 | typelist.remove(typelist.last()); |
1077 | 1096 | ||
1078 | return typelist; | 1097 | return typelist; |
1079 | } | 1098 | } |
1080 | 1099 | ||
1081 | 1100 | ||
1082 | void PPPData::setScriptType(QStringList &list) { | 1101 | void PPPData::setScriptType(QStringList &list) { |
1083 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | 1102 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); |
1084 | } | 1103 | } |
1085 | 1104 | ||
1086 | 1105 | ||
1087 | QStringList &PPPData::script() { | 1106 | QStringList &PPPData::script() { |
1088 | static QStringList scriptlist; | 1107 | static QStringList scriptlist; |
1089 | 1108 | ||
1090 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | 1109 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); |
1091 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | 1110 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) |
1092 | scriptlist.remove(scriptlist.last()); | 1111 | scriptlist.remove(scriptlist.last()); |
1093 | 1112 | ||
1094 | return scriptlist; | 1113 | return scriptlist; |
1095 | } | 1114 | } |
1096 | 1115 | ||
1097 | 1116 | ||
1098 | void PPPData::setScript(QStringList &list) { | 1117 | void PPPData::setScript(QStringList &list) { |
1099 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | 1118 | writeListConfig(cgroup, SCRIPTARG_KEY, list); |
1100 | } | 1119 | } |
1101 | 1120 | ||
1102 | 1121 | ||
1103 | // const QString PPPData::accountingFile() { | 1122 | // const QString PPPData::accountingFile() { |
1104 | // return readConfig(cgroup, ACCTFILE_KEY); | 1123 | // return readConfig(cgroup, ACCTFILE_KEY); |
1105 | // } | 1124 | // } |
1106 | 1125 | ||
1107 | 1126 | ||
1108 | // void PPPData::setAccountingFile(const QString &n) { | 1127 | // void PPPData::setAccountingFile(const QString &n) { |
1109 | // writeConfig(cgroup, ACCTFILE_KEY, n); | 1128 | // writeConfig(cgroup, ACCTFILE_KEY, n); |
1110 | // } | 1129 | // } |
1111 | 1130 | ||
1112 | 1131 | ||
1113 | // const QString PPPData::totalCosts() { | 1132 | // const QString PPPData::totalCosts() { |
1114 | // return readConfig(cgroup, TOTALCOSTS_KEY); | 1133 | // return readConfig(cgroup, TOTALCOSTS_KEY); |
1115 | // } | 1134 | // } |
1116 | 1135 | ||
1117 | 1136 | ||
1118 | // void PPPData::setTotalCosts(const QString &n) { | 1137 | // void PPPData::setTotalCosts(const QString &n) { |
1119 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); | 1138 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); |
1120 | // } | 1139 | // } |
1121 | 1140 | ||
1122 | 1141 | ||
1123 | // int PPPData::totalBytes() { | 1142 | // int PPPData::totalBytes() { |
1124 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | 1143 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); |
1125 | // } | 1144 | // } |
1126 | 1145 | ||
1127 | // void PPPData::setTotalBytes(int n) { | 1146 | // void PPPData::setTotalBytes(int n) { |
1128 | // writeConfig(cgroup, TOTALBYTES_KEY, n); | 1147 | // writeConfig(cgroup, TOTALBYTES_KEY, n); |
1129 | // } | 1148 | // } |
1130 | 1149 | ||
1131 | 1150 | ||
1132 | QStringList &PPPData::pppdArgument() { | 1151 | QStringList &PPPData::pppdArgument() { |
1133 | static QStringList arglist; | 1152 | static QStringList arglist; |
1134 | 1153 | ||
1135 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1154 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1136 | arglist.remove(arglist.last()); | 1155 | arglist.remove(arglist.last()); |
1137 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1156 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1138 | 1157 | ||
1139 | return arglist; | 1158 | return arglist; |
1140 | } | 1159 | } |
1141 | 1160 | ||
1142 | 1161 | ||
1143 | void PPPData::setpppdArgument(QStringList &args) { | 1162 | void PPPData::setpppdArgument(QStringList &args) { |
1144 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1163 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1145 | } | 1164 | } |
1146 | 1165 | ||
1147 | 1166 | ||
1148 | void PPPData::setpppdArgumentDefaults() { | 1167 | void PPPData::setpppdArgumentDefaults() { |
1149 | QStringList arg; | 1168 | QStringList arg; |
1150 | setpppdArgument(arg); | 1169 | setpppdArgument(arg); |
1151 | } | 1170 | } |
1152 | 1171 | ||
1153 | 1172 | ||
1154 | // // graphing widget | 1173 | // // graphing widget |
1155 | // void PPPData::setGraphingOptions(bool enable, | 1174 | // void PPPData::setGraphingOptions(bool enable, |
1156 | // QColor bg, | 1175 | // QColor bg, |
1157 | // QColor text, | 1176 | // QColor text, |
1158 | // QColor in, | 1177 | // QColor in, |
1159 | // QColor out) | 1178 | // QColor out) |
1160 | // { | 1179 | // { |
1161 | // if(config) { | 1180 | // if(config) { |
1162 | // config->setGroup(GRAPH_GRP); | 1181 | // config->setGroup(GRAPH_GRP); |
1163 | // config->writeEntry(GENABLED, enable); | 1182 | // config->writeEntry(GENABLED, enable); |
1164 | // // config->writeEntry(GCOLOR_BG, bg); | 1183 | // // config->writeEntry(GCOLOR_BG, bg); |
1165 | // // config->writeEntry(GCOLOR_TEXT, text); | 1184 | // // config->writeEntry(GCOLOR_TEXT, text); |
1166 | // // config->writeEntry(GCOLOR_IN, in); | 1185 | // // config->writeEntry(GCOLOR_IN, in); |
1167 | // // config->writeEntry(GCOLOR_OUT, out); | 1186 | // // config->writeEntry(GCOLOR_OUT, out); |
1168 | // } | 1187 | // } |
1169 | // } | 1188 | // } |
1170 | 1189 | ||
1171 | // void PPPData::graphingOptions(bool &enable, | 1190 | // void PPPData::graphingOptions(bool &enable, |
1172 | // QColor &bg, | 1191 | // QColor &bg, |
1173 | // QColor &text, | 1192 | // QColor &text, |
1174 | // QColor &in, | 1193 | // QColor &in, |
1175 | // QColor &out) | 1194 | // QColor &out) |
1176 | // { | 1195 | // { |
1177 | // QColor c; | 1196 | // QColor c; |
1178 | 1197 | ||
1179 | // if(config) { | 1198 | // if(config) { |
1180 | // config->setGroup(GRAPH_GRP); | 1199 | // config->setGroup(GRAPH_GRP); |
1181 | // enable = config->readBoolEntry(GENABLED, true); | 1200 | // enable = config->readBoolEntry(GENABLED, true); |
1182 | // bg = Qt::white; | 1201 | // bg = Qt::white; |
1183 | // //bg = config->readColorEntry(GCOLOR_BG, &c); | 1202 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1184 | // text = Qt::black; | 1203 | // text = Qt::black; |
1185 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1204 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1186 | // in = Qt::blue; | 1205 | // in = Qt::blue; |
1187 | // //in = config->readColorEntry(GCOLOR_IN, &c); | 1206 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1188 | // out = Qt::red; | 1207 | // out = Qt::red; |
1189 | // //out = config->readColorEntry(GCOLOR_OUT, &c); | 1208 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1190 | // } | 1209 | // } |
1191 | // } | 1210 | // } |
1192 | 1211 | ||
1193 | 1212 | ||
1194 | // bool PPPData::graphingEnabled() { | 1213 | // bool PPPData::graphingEnabled() { |
1195 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1214 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1196 | // } | 1215 | // } |
1197 | 1216 | ||
1198 | 1217 | ||
1199 | 1218 | ||
1200 | // | 1219 | // |
1201 | //functions to change/set the child pppd process info | 1220 | //functions to change/set the child pppd process info |
1202 | // | 1221 | // |
1203 | bool PPPData::pppdRunning() const { | 1222 | bool PPPData::pppdRunning() const { |
1204 | return pppdisrunning; | 1223 | return pppdisrunning; |
1205 | } | 1224 | } |
1206 | 1225 | ||
1207 | void PPPData::setpppdRunning(bool set) { | 1226 | void PPPData::setpppdRunning(bool set) { |
1208 | pppdisrunning = set; | 1227 | pppdisrunning = set; |
1209 | } | 1228 | } |
1210 | 1229 | ||
1211 | int PPPData::pppdError() const { | 1230 | int PPPData::pppdError() const { |
1212 | return pppderror; | 1231 | return pppderror; |
1213 | } | 1232 | } |
1214 | 1233 | ||
1215 | void PPPData::setpppdError(int err) { | 1234 | void PPPData::setpppdError(int err) { |
1216 | pppderror = err; | 1235 | pppderror = err; |
1217 | } | 1236 | } |
1218 | 1237 | ||
1219 | QString PPPData::modemGroup() | 1238 | QString PPPData::modemGroup() |
1220 | { | 1239 | { |
1221 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); | 1240 | if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); |
1222 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); | 1241 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); |
1223 | } | 1242 | } |
1224 | 1243 | ||
1225 | 1244 | ||
1226 | QMap<QString,QString> PPPData::getConfiguredInterfaces() | 1245 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1227 | { | 1246 | { |
1228 | QMap<QString,QString> ifaces; | 1247 | QMap<QString,QString> ifaces; |
1229 | int count = readNumConfig( ACCLIST_GRP, ACCOUNTS_COUNT, -1 ); | 1248 | Config config = PPPData::config(); |
1230 | QString accGrp; | 1249 | config.setGroup(ACCLIST_GRP); |
1250 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | ||
1251 | QString accGrp, dev, acc; | ||
1231 | for (int i = 0; i < count; i++){ | 1252 | for (int i = 0; i < count; i++){ |
1232 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1253 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
1233 | ifaces.insert( readConfig( accGrp, ACOUNTS_DEV, "error" ), | 1254 | config.setGroup(accGrp); |
1234 | readConfig( accGrp, ACOUNTS_ACC, "error" ) ); | 1255 | dev = config.readEntry( ACOUNTS_DEV, "error" ); |
1256 | acc = config.readEntry( ACOUNTS_ACC, "error" ); | ||
1257 | ifaces.insert( dev, acc ); | ||
1235 | } | 1258 | } |
1236 | 1259 | ||
1237 | return ifaces; | 1260 | return ifaces; |
1238 | } | 1261 | } |
1239 | 1262 | ||
1240 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1263 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1241 | { | 1264 | { |
1242 | QMap<QString,QString>::Iterator it; | 1265 | QMap<QString,QString>::Iterator it; |
1243 | QString accGrp; | ||
1244 | int i = 0; | 1266 | int i = 0; |
1267 | Config cfg = config(); | ||
1245 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ | 1268 | for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ |
1246 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1269 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i)); |
1247 | writeConfig( accGrp, ACOUNTS_DEV, it.key() ); | 1270 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1248 | writeConfig( accGrp, ACOUNTS_ACC, it.data() ); | 1271 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1249 | } | 1272 | } |
1250 | writeConfig( ACCLIST_GRP, ACCOUNTS_COUNT, i ); | 1273 | cfg.setGroup( ACCLIST_GRP ); |
1274 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | ||
1251 | 1275 | ||
1252 | } | 1276 | } |
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index c1c7e69..af960c6 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -1,465 +1,435 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * based on EzPPP: | 10 | * based on EzPPP: |
11 | * Copyright (C) 1997 Jay Painter | 11 | * Copyright (C) 1997 Jay Painter |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or | 13 | * This program is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This program is distributed in the hope that it will be useful, | 18 | * This program is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 23 | * You should have received a copy of the GNU Library General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef _PPPDATA_H_ | 28 | #ifndef _PPPDATA_H_ |
29 | #define _PPPDATA_H_ | 29 | #define _PPPDATA_H_ |
30 | 30 | ||
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | 33 | ||
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | #include "kpppconfig.h" | 39 | #include "kpppconfig.h" |
40 | 40 | ||
41 | class Config; | 41 | class Config; |
42 | 42 | ||
43 | // string lengths | 43 | // string lengths |
44 | 44 | ||
45 | #define PATH_SIZE 120 | 45 | #define PATH_SIZE 120 |
46 | #define MODEMSTR_SIZE 80 | 46 | #define MODEMSTR_SIZE 80 |
47 | #define ACCNAME_SIZE 50 | 47 | #define ACCNAME_SIZE 50 |
48 | #define PHONENUMBER_SIZE 60 | 48 | #define PHONENUMBER_SIZE 60 |
49 | #define COMMAND_SIZE 255 | 49 | #define COMMAND_SIZE 255 |
50 | #define IPADDR_SIZE 15 | 50 | #define IPADDR_SIZE 15 |
51 | #define DOMAIN_SIZE 50 | 51 | #define DOMAIN_SIZE 50 |
52 | #define TIMEOUT_SIZE 60 | 52 | #define TIMEOUT_SIZE 60 |
53 | 53 | ||
54 | // | 54 | // |
55 | // keys for config file | 55 | // keys for config file |
56 | // | 56 | // |
57 | 57 | ||
58 | // groups | 58 | // groups |
59 | #define GENERAL_GRP "PPP_General" | 59 | #define GENERAL_GRP "PPP_General" |
60 | #define MODEM_GRP "PPP_Modem" | 60 | #define MODEM_GRP "PPP_Modem" |
61 | #define ACCOUNT_GRP "PPP_Account" | 61 | #define ACCOUNT_GRP "PPP_Account" |
62 | #define ACCLIST_GRP "PPP_Accounts_List" | 62 | #define ACCLIST_GRP "PPP_Accounts_List" |
63 | //#define GRAPH_GRP "Graph" | 63 | //#define GRAPH_GRP "Graph" |
64 | //#define WINPOS_GRP "WindowPosition" | 64 | //#define WINPOS_GRP "WindowPosition" |
65 | 65 | ||
66 | // general | 66 | // general |
67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | 67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" |
68 | #define PPPDVERSION_KEY "pppdVersion" | 68 | #define PPPDVERSION_KEY "pppdVersion" |
69 | #define PPPDTIMEOUT_KEY "pppdTimeout" | 69 | #define PPPDTIMEOUT_KEY "pppdTimeout" |
70 | #define SHOWCLOCK_KEY "ShowClock" | 70 | #define SHOWCLOCK_KEY "ShowClock" |
71 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 71 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
72 | #define AUTOREDIAL_KEY "AutomaticRedial" | 72 | #define AUTOREDIAL_KEY "AutomaticRedial" |
73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | 75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" |
76 | #define ID_KEY "ID" | 76 | #define ID_KEY "ID" |
77 | 77 | ||
78 | // modem | 78 | // modem |
79 | #define MODEMDEV_KEY "Device" | 79 | #define MODEMDEV_KEY "Device" |
80 | #define LOCKFILE_KEY "UseLockFile" | 80 | #define LOCKFILE_KEY "UseLockFile" |
81 | #define FLOWCONTROL_KEY "FlowControl" | 81 | #define FLOWCONTROL_KEY "FlowControl" |
82 | #define SPEED_KEY "Speed" | 82 | #define SPEED_KEY "Speed" |
83 | #define TIMEOUT_KEY "Timeout" | 83 | #define TIMEOUT_KEY "Timeout" |
84 | #define TONEDURATION_KEY "ToneDuration" | 84 | #define TONEDURATION_KEY "ToneDuration" |
85 | #define BUSYWAIT_KEY "BusyWait" | 85 | #define BUSYWAIT_KEY "BusyWait" |
86 | #define INITSTR_KEY "InitString" | 86 | #define INITSTR_KEY "InitString" |
87 | #define INITRESP_KEY "InitResponse" | 87 | #define INITRESP_KEY "InitResponse" |
88 | #define PREINITDELAY_KEY "PreInitDelay" | 88 | #define PREINITDELAY_KEY "PreInitDelay" |
89 | #define INITDELAY_KEY "InitDelay" | 89 | #define INITDELAY_KEY "InitDelay" |
90 | #define NODTDETECT_KEY "NoDialToneDetection" | 90 | #define NODTDETECT_KEY "NoDialToneDetection" |
91 | #define DIALTONEWAIT_KEY "WaitForDialTone" | 91 | #define DIALTONEWAIT_KEY "WaitForDialTone" |
92 | #define DIALSTR_KEY "DialString" | 92 | #define DIALSTR_KEY "DialString" |
93 | #define CONNECTRESP_KEY "ConnectResponse" | 93 | #define CONNECTRESP_KEY "ConnectResponse" |
94 | #define BUSYRESP_KEY "BusyResponse" | 94 | #define BUSYRESP_KEY "BusyResponse" |
95 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | 95 | #define NOCARRIERRESP_KEY "NoCarrierResponse" |
96 | #define NODIALTONERESP_KEY "NoDialToneResp" | 96 | #define NODIALTONERESP_KEY "NoDialToneResp" |
97 | #define HANGUPSTR_KEY "HangupString" | 97 | #define HANGUPSTR_KEY "HangupString" |
98 | #define HANGUPRESP_KEY "HangUpResponse" | 98 | #define HANGUPRESP_KEY "HangUpResponse" |
99 | #define ANSWERSTR_KEY "AnswerString" | 99 | #define ANSWERSTR_KEY "AnswerString" |
100 | #define RINGRESP_KEY "RingResponse" | 100 | #define RINGRESP_KEY "RingResponse" |
101 | #define ANSWERRESP_KEY "AnswerResponse" | 101 | #define ANSWERRESP_KEY "AnswerResponse" |
102 | #define ENTER_KEY "Enter" | 102 | #define ENTER_KEY "Enter" |
103 | #define ESCAPESTR_KEY "EscapeString" | 103 | #define ESCAPESTR_KEY "EscapeString" |
104 | #define ESCAPERESP_KEY "EscapeResponse" | 104 | #define ESCAPERESP_KEY "EscapeResponse" |
105 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | 105 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" |
106 | #define USECDLINE_KEY "UseCDLine" | 106 | #define USECDLINE_KEY "UseCDLine" |
107 | #define VOLUME_HIGH "VolumeHigh" | 107 | #define VOLUME_HIGH "VolumeHigh" |
108 | #define VOLUME_MEDIUM "VolumeMedium" | 108 | #define VOLUME_MEDIUM "VolumeMedium" |
109 | #define VOLUME_OFF "VolumeOff" | 109 | #define VOLUME_OFF "VolumeOff" |
110 | #define VOLUME_KEY "Volume" | 110 | #define VOLUME_KEY "Volume" |
111 | 111 | ||
112 | // account | 112 | // account |
113 | #define NAME_KEY "Name" | 113 | #define NAME_KEY "Name" |
114 | #define PHONENUMBER_KEY "Phonenumber" | 114 | #define PHONENUMBER_KEY "Phonenumber" |
115 | #define DIAL_PREFIX_KEY "DialPrefix" | 115 | #define DIAL_PREFIX_KEY "DialPrefix" |
116 | #define AUTH_KEY "Authentication" | 116 | #define AUTH_KEY "Authentication" |
117 | #define STORED_PASSWORD_KEY "Password" | 117 | #define STORED_PASSWORD_KEY "Password" |
118 | #define STORED_USERNAME_KEY "Username" | 118 | #define STORED_USERNAME_KEY "Username" |
119 | #define STORE_PASSWORD_KEY "StorePassword" | 119 | #define STORE_PASSWORD_KEY "StorePassword" |
120 | #define BEFORE_CONNECT_KEY "BeforeConnect" | 120 | #define BEFORE_CONNECT_KEY "BeforeConnect" |
121 | #define COMMAND_KEY "Command" | 121 | #define COMMAND_KEY "Command" |
122 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | 122 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" |
123 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | 123 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" |
124 | #define IPADDR_KEY "IPAddr" | 124 | #define IPADDR_KEY "IPAddr" |
125 | #define SUBNETMASK_KEY "SubnetMask" | 125 | #define SUBNETMASK_KEY "SubnetMask" |
126 | #define ACCTENABLED_KEY "AccountingEnabled" | 126 | #define ACCTENABLED_KEY "AccountingEnabled" |
127 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | 127 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" |
128 | #define ACCTFILE_KEY "AccountingFile" | 128 | #define ACCTFILE_KEY "AccountingFile" |
129 | #define AUTONAME_KEY "AutoName" | 129 | #define AUTONAME_KEY "AutoName" |
130 | #define GATEWAY_KEY "Gateway" | 130 | #define GATEWAY_KEY "Gateway" |
131 | #define DEFAULTROUTE_KEY "DefaultRoute" | 131 | #define DEFAULTROUTE_KEY "DefaultRoute" |
132 | #define DOMAIN_KEY "Domain" | 132 | #define DOMAIN_KEY "Domain" |
133 | #define DNS_KEY "DNS" | 133 | #define DNS_KEY "DNS" |
134 | #define AUTODNS_KEY "AutoDNS" | 134 | #define AUTODNS_KEY "AutoDNS" |
135 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | 135 | #define EXDNSDISABLED_KEY "ExDNSDisabled" |
136 | #define SCRIPTCOM_KEY "ScriptCommands" | 136 | #define SCRIPTCOM_KEY "ScriptCommands" |
137 | #define SCRIPTARG_KEY "ScriptArguments" | 137 | #define SCRIPTARG_KEY "ScriptArguments" |
138 | #define PPPDARG_KEY "pppdArguments" | 138 | #define PPPDARG_KEY "pppdArguments" |
139 | #define PPP_DEBUG_OPTION "PPPDebug" | 139 | #define PPP_DEBUG_OPTION "PPPDebug" |
140 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | 140 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" |
141 | #define DOCKING_KEY "DockIntoPanel" | 141 | #define DOCKING_KEY "DockIntoPanel" |
142 | #define TOTALCOSTS_KEY "TotalCosts" | 142 | #define TOTALCOSTS_KEY "TotalCosts" |
143 | #define TOTALBYTES_KEY "TotalBytes" | 143 | #define TOTALBYTES_KEY "TotalBytes" |
144 | 144 | ||
145 | // pppd errors | 145 | // pppd errors |
146 | #define E_IF_TIMEOUT 1 | 146 | #define E_IF_TIMEOUT 1 |
147 | #define E_PPPD_DIED 2 | 147 | #define E_PPPD_DIED 2 |
148 | 148 | ||
149 | // account list | 149 | // account list |
150 | #define ACCOUNTS_COUNT "Accounts_Count" | 150 | #define ACCOUNTS_COUNT "Accounts_Count" |
151 | #define ACOUNTS_DEV "Accounts_Modem" | 151 | #define ACOUNTS_DEV "Accounts_Modem" |
152 | #define ACOUNTS_ACC "Accounts_Account" | 152 | #define ACOUNTS_ACC "Accounts_Account" |
153 | 153 | ||
154 | class PPPData { | 154 | class PPPData { |
155 | public: | 155 | public: |
156 | PPPData(); | 156 | PPPData(); |
157 | ~PPPData() {}; | 157 | ~PPPData() {}; |
158 | static PPPData* data(); | ||
159 | 158 | ||
160 | enum { NumInitStrings = 2 }; | 159 | enum { NumInitStrings = 2 }; |
161 | 160 | ||
162 | // general functions | 161 | // general functions |
163 | bool open(); | ||
164 | void save(); | 162 | void save(); |
165 | void cancel(); | 163 | void cancel(); |
166 | 164 | ||
167 | QMap<QString,QString> getConfiguredInterfaces(); | 165 | static QMap<QString,QString> getConfiguredInterfaces(); |
168 | void setConfiguredInterfaces( QMap<QString,QString> ); | 166 | static void setConfiguredInterfaces( QMap<QString,QString> ); |
169 | 167 | ||
170 | // function to read/write date to configuration file | 168 | // function to read/write date to configuration file |
169 | static Config config(); | ||
171 | QString readConfig(const QString &, const QString &, const QString &); | 170 | QString readConfig(const QString &, const QString &, const QString &); |
172 | int readNumConfig(const QString &, const QString &, int); | 171 | int readNumConfig(const QString &, const QString &, int); |
173 | bool readListConfig(const QString &, const QString &, | 172 | bool readListConfig(const QString &, const QString &, |
174 | QStringList &, char sep = ','); | 173 | QStringList &, char sep = ','); |
175 | void writeConfig(const QString &, const QString &, const QString &); | 174 | void writeConfig(const QString &, const QString &, const QString &); |
176 | void writeConfig(const QString &, const QString &, int); | 175 | void writeConfig(const QString &, const QString &, int); |
177 | void writeListConfig(const QString &, const QString &, | 176 | void writeListConfig(const QString &, const QString &, |
178 | QStringList &, char sep = ','); | 177 | QStringList &, char sep = ','); |
179 | 178 | ||
180 | // return the current account group | 179 | // return the current account group |
181 | QString currentGroup() { return cgroup; } | 180 | QString currentGroup() { return cgroup; } |
182 | QString modemGroup(); | 181 | QString modemGroup(); |
183 | 182 | ||
184 | // functions to set/get general kppp info | 183 | // functions to set/get general kppp info |
185 | QString password() const; | 184 | QString password() const; |
186 | void setPassword(const QString &); | 185 | void setPassword(const QString &); |
187 | 186 | ||
188 | int currentAccountID() { return caccount; }; | 187 | int currentAccountID() { return caccount; }; |
189 | const QString defaultAccount(); | 188 | const QString defaultAccount(); |
190 | void setDefaultAccount(const QString &); | 189 | void setDefaultAccount(const QString &); |
191 | 190 | ||
192 | void set_xserver_exit_disconnect(bool set); | 191 | void set_xserver_exit_disconnect(bool set); |
193 | bool get_xserver_exit_disconnect(); | 192 | bool get_xserver_exit_disconnect(); |
194 | 193 | ||
195 | void setPPPDebug(bool set); | 194 | void setPPPDebug(bool set); |
196 | bool getPPPDebug(); | 195 | bool getPPPDebug(); |
197 | 196 | ||
198 | void set_quit_on_disconnect(bool); | 197 | void set_quit_on_disconnect(bool); |
199 | bool quit_on_disconnect(); | 198 | bool quit_on_disconnect(); |
200 | 199 | ||
201 | void set_show_clock_on_caption(bool set); | 200 | void set_show_clock_on_caption(bool set); |
202 | bool get_show_clock_on_caption(); | 201 | bool get_show_clock_on_caption(); |
203 | 202 | ||
204 | void set_show_log_window(bool set); | 203 | void set_show_log_window(bool set); |
205 | bool get_show_log_window(); | 204 | bool get_show_log_window(); |
206 | 205 | ||
207 | void set_automatic_redial(bool set); | 206 | void set_automatic_redial(bool set); |
208 | bool automatic_redial(); | 207 | bool automatic_redial(); |
209 | 208 | ||
210 | void set_iconify_on_connect(bool set); | 209 | // void set_iconify_on_connect(bool set); |
211 | bool get_iconify_on_connect(); | 210 | // bool get_iconify_on_connect(); |
212 | 211 | ||
213 | void set_dock_into_panel(bool set); | 212 | // void set_dock_into_panel(bool set); |
214 | bool get_dock_into_panel(); | 213 | // bool get_dock_into_panel(); |
215 | 214 | ||
216 | const QString enter(); | 215 | const QString enter(); |
217 | void setEnter(const QString &); | 216 | void setEnter(const QString &); |
218 | 217 | ||
219 | QString pppdVersion(); | 218 | QString pppdVersion(); |
220 | bool pppdVersionMin(int ver, int mod, int patch); | 219 | bool pppdVersionMin(int ver, int mod, int patch); |
221 | 220 | ||
222 | int pppdTimeout(); | 221 | int pppdTimeout(); |
223 | void setpppdTimeout(int); | 222 | void setpppdTimeout(int); |
224 | 223 | ||
225 | int busyWait(); | 224 | int busyWait(); |
226 | void setbusyWait(int); | 225 | void setbusyWait(int); |
227 | 226 | ||
228 | bool modemLockFile(); | 227 | bool modemLockFile(); |
229 | void setModemLockFile(bool set); | 228 | void setModemLockFile(bool set); |
230 | 229 | ||
231 | int modemEscapeGuardTime(); | 230 | int modemEscapeGuardTime(); |
232 | void setModemEscapeGuardTime(int i); | 231 | void setModemEscapeGuardTime(int i); |
233 | 232 | ||
234 | void setModemEscapeStr(const QString &); | 233 | void setModemEscapeStr(const QString &); |
235 | const QString modemEscapeStr(); | 234 | const QString modemEscapeStr(); |
236 | 235 | ||
237 | void setModemEscapeResp(const QString &); | 236 | void setModemEscapeResp(const QString &); |
238 | const QString modemEscapeResp(); | 237 | const QString modemEscapeResp(); |
239 | 238 | ||
240 | const QString modemDevice(); | 239 | const QString modemDevice(); |
241 | bool setModemDevice(const QString &); | 240 | bool setModemDevice(const QString &); |
242 | 241 | ||
243 | const QString flowcontrol(); | 242 | const QString flowcontrol(); |
244 | void setFlowcontrol(const QString &); | 243 | void setFlowcontrol(const QString &); |
245 | 244 | ||
246 | int modemTimeout(); | 245 | int modemTimeout(); |
247 | void setModemTimeout(int); | 246 | void setModemTimeout(int); |
248 | 247 | ||
249 | int modemToneDuration(); | 248 | int modemToneDuration(); |
250 | void setModemToneDuration(int); | 249 | void setModemToneDuration(int); |
251 | 250 | ||
252 | QString volumeInitString(); | 251 | QString volumeInitString(); |
253 | int volume(); | 252 | int volume(); |
254 | void setVolume(int); | 253 | void setVolume(int); |
255 | 254 | ||
256 | int waitForDialTone(); | 255 | int waitForDialTone(); |
257 | void setWaitForDialTone(int i); | 256 | void setWaitForDialTone(int i); |
258 | 257 | ||
259 | // modem command strings/responses | 258 | // modem command strings/responses |
260 | const QString modemInitStr(int i); | 259 | const QString modemInitStr(int i); |
261 | void setModemInitStr(int i, const QString &); | 260 | void setModemInitStr(int i, const QString &); |
262 | 261 | ||
263 | const QString modemInitResp(); | 262 | const QString modemInitResp(); |
264 | void setModemInitResp(const QString &); | 263 | void setModemInitResp(const QString &); |
265 | 264 | ||
266 | int modemPreInitDelay(); | 265 | int modemPreInitDelay(); |
267 | void setModemPreInitDelay(int); | 266 | void setModemPreInitDelay(int); |
268 | 267 | ||
269 | int modemInitDelay(); | 268 | int modemInitDelay(); |
270 | void setModemInitDelay(int); | 269 | void setModemInitDelay(int); |
271 | 270 | ||
272 | QString modemNoDialToneDetectionStr(); | 271 | QString modemNoDialToneDetectionStr(); |
273 | void setModemNoDialToneDetectionStr(const QString &); | 272 | void setModemNoDialToneDetectionStr(const QString &); |
274 | 273 | ||
275 | const QString modemDialStr(); | 274 | const QString modemDialStr(); |
276 | void setModemDialStr(const QString &); | 275 | void setModemDialStr(const QString &); |
277 | 276 | ||
278 | const QString modemConnectResp(); | 277 | const QString modemConnectResp(); |
279 | void setModemConnectResp(const QString &); | 278 | void setModemConnectResp(const QString &); |
280 | 279 | ||
281 | const QString modemBusyResp(); | 280 | const QString modemBusyResp(); |
282 | void setModemBusyResp(const QString &); | 281 | void setModemBusyResp(const QString &); |
283 | 282 | ||
284 | const QString modemNoCarrierResp(); | 283 | const QString modemNoCarrierResp(); |
285 | void setModemNoCarrierResp(const QString &); | 284 | void setModemNoCarrierResp(const QString &); |
286 | 285 | ||
287 | const QString modemNoDialtoneResp(); | 286 | const QString modemNoDialtoneResp(); |
288 | void setModemNoDialtoneResp(const QString &); | 287 | void setModemNoDialtoneResp(const QString &); |
289 | 288 | ||
290 | const QString modemHangupStr(); | 289 | const QString modemHangupStr(); |
291 | void setModemHangupStr(const QString &); | 290 | void setModemHangupStr(const QString &); |
292 | 291 | ||
293 | const QString modemHangupResp(); | 292 | const QString modemHangupResp(); |
294 | void setModemHangupResp(const QString &); | 293 | void setModemHangupResp(const QString &); |
295 | 294 | ||
296 | const QString modemAnswerStr(); | 295 | const QString modemAnswerStr(); |
297 | void setModemAnswerStr(const QString &); | 296 | void setModemAnswerStr(const QString &); |
298 | 297 | ||
299 | const QString modemRingResp(); | 298 | const QString modemRingResp(); |
300 | void setModemRingResp(const QString &); | 299 | void setModemRingResp(const QString &); |
301 | 300 | ||
302 | const QString modemAnswerResp(); | 301 | const QString modemAnswerResp(); |
303 | void setModemAnswerResp(const QString &); | 302 | void setModemAnswerResp(const QString &); |
304 | 303 | ||
305 | QString volumeOff(); | 304 | QString volumeOff(); |
306 | void setVolumeOff(const QString &); | 305 | void setVolumeOff(const QString &); |
307 | 306 | ||
308 | QString volumeMedium(); | 307 | QString volumeMedium(); |
309 | void setVolumeMedium(const QString &); | 308 | void setVolumeMedium(const QString &); |
310 | 309 | ||
311 | QString volumeHigh(); | 310 | QString volumeHigh(); |
312 | void setVolumeHigh(const QString &); | 311 | void setVolumeHigh(const QString &); |
313 | 312 | ||
314 | #if 0 | ||
315 | void setUseCDLine(const int n); | ||
316 | int UseCDLine(); | ||
317 | #endif | ||
318 | |||
319 | // functions to set/get account information | 313 | // functions to set/get account information |
320 | int count() const; | 314 | int count() const; |
321 | bool setAccount(const QString &); | 315 | bool setAccount(const QString &); |
322 | bool setAccountbyIndex(int); | 316 | bool setAccountbyIndex(int); |
323 | 317 | ||
324 | bool isUniqueAccname(const QString &); | 318 | bool isUniqueAccname(const QString &); |
325 | 319 | ||
326 | bool deleteAccount(); | 320 | bool deleteAccount(); |
327 | bool deleteAccount(const QString &); | 321 | bool deleteAccount(const QString &); |
328 | int newaccount(); | 322 | int newaccount(); |
329 | int copyaccount(int i); | 323 | int copyaccount(int i); |
330 | 324 | ||
331 | const QString accname(); | 325 | const QString accname(); |
332 | void setAccname(const QString &); | 326 | void setAccname(const QString &); |
333 | 327 | ||
334 | QStringList &phonenumbers(); | 328 | QStringList &phonenumbers(); |
335 | const QString phonenumber(); | 329 | const QString phonenumber(); |
336 | void setPhonenumber(const QString &); | 330 | void setPhonenumber(const QString &); |
337 | 331 | ||
338 | const QString dialPrefix(); | 332 | const QString dialPrefix(); |
339 | void setDialPrefix(const QString &); | 333 | void setDialPrefix(const QString &); |
340 | 334 | ||
341 | int authMethod(); | 335 | int authMethod(); |
342 | void setAuthMethod(int); | 336 | void setAuthMethod(int); |
343 | 337 | ||
344 | const QString storedUsername(); | 338 | const QString storedUsername(); |
345 | void setStoredUsername(const QString &); | 339 | void setStoredUsername(const QString &); |
346 | 340 | ||
347 | const QString storedPassword(); | 341 | const QString storedPassword(); |
348 | void setStoredPassword(const QString &); | 342 | void setStoredPassword(const QString &); |
349 | 343 | ||
350 | bool storePassword(); | 344 | bool storePassword(); |
351 | void setStorePassword(bool); | 345 | void setStorePassword(bool); |
352 | 346 | ||
353 | const QString speed(); | 347 | const QString speed(); |
354 | void setSpeed(const QString &); | 348 | void setSpeed(const QString &); |
355 | 349 | ||
356 | const QString command_before_connect(); | 350 | const QString command_before_connect(); |
357 | void setCommand_before_connect(const QString &); | 351 | void setCommand_before_connect(const QString &); |
358 | 352 | ||
359 | const QString command_on_connect(); | 353 | const QString command_on_connect(); |
360 | void setCommand_on_connect(const QString &); | 354 | void setCommand_on_connect(const QString &); |
361 | 355 | ||
362 | const QString command_on_disconnect(); | 356 | const QString command_on_disconnect(); |
363 | void setCommand_on_disconnect(const QString &); | 357 | void setCommand_on_disconnect(const QString &); |
364 | 358 | ||
365 | const QString command_before_disconnect(); | 359 | const QString command_before_disconnect(); |
366 | void setCommand_before_disconnect(const QString &); | 360 | void setCommand_before_disconnect(const QString &); |
367 | 361 | ||
368 | const QString ipaddr(); | 362 | const QString ipaddr(); |
369 | void setIpaddr(const QString &); | 363 | void setIpaddr(const QString &); |
370 | 364 | ||
371 | const QString subnetmask(); | 365 | const QString subnetmask(); |
372 | void setSubnetmask(const QString &); | 366 | void setSubnetmask(const QString &); |
373 | 367 | ||
374 | bool AcctEnabled(); | 368 | bool AcctEnabled(); |
375 | void setAcctEnabled(bool set); | 369 | void setAcctEnabled(bool set); |
376 | 370 | ||
377 | int VolAcctEnabled(); | 371 | // int VolAcctEnabled(); |
378 | void setVolAcctEnabled(int set); | 372 | // void setVolAcctEnabled(int set); |
379 | 373 | ||
380 | bool autoDNS(); | 374 | bool autoDNS(); |
381 | void setAutoDNS(bool set); | 375 | void setAutoDNS(bool set); |
382 | 376 | ||
383 | bool exDNSDisabled(); | 377 | bool exDNSDisabled(); |
384 | void setExDNSDisabled(bool set); | 378 | void setExDNSDisabled(bool set); |
385 | 379 | ||
386 | bool autoname(); | 380 | bool autoname(); |
387 | void setAutoname(bool set); | 381 | void setAutoname(bool set); |
388 | 382 | ||
389 | const QString gateway(); | 383 | const QString gateway(); |
390 | void setGateway(const QString &); | 384 | void setGateway(const QString &); |
391 | 385 | ||
392 | bool defaultroute(); | 386 | bool defaultroute(); |
393 | void setDefaultroute(bool set); | 387 | void setDefaultroute(bool set); |
394 | 388 | ||
395 | QStringList &dns(); | 389 | QStringList &dns(); |
396 | void setDns(QStringList &); | 390 | void setDns(QStringList &); |
397 | 391 | ||
398 | const QString domain(); | 392 | const QString domain(); |
399 | void setDomain(const QString &); | 393 | void setDomain(const QString &); |
400 | 394 | ||
401 | QStringList &scriptType(); | 395 | QStringList &scriptType(); |
402 | void setScriptType(QStringList &); | 396 | void setScriptType(QStringList &); |
403 | 397 | ||
404 | QStringList &script(); | 398 | QStringList &script(); |
405 | void setScript(QStringList &); | 399 | void setScript(QStringList &); |
406 | 400 | ||
407 | QStringList &pppdArgument(); | 401 | QStringList &pppdArgument(); |
408 | void setpppdArgumentDefaults(); | 402 | void setpppdArgumentDefaults(); |
409 | void setpppdArgument(QStringList &); | 403 | void setpppdArgument(QStringList &); |
410 | 404 | ||
411 | //functions to change/set the child pppd process info | 405 | //functions to change/set the child pppd process info |
412 | bool pppdRunning() const; | 406 | bool pppdRunning() const; |
413 | void setpppdRunning(bool set); | 407 | void setpppdRunning(bool set); |
414 | 408 | ||
415 | int pppdError() const; | 409 | int pppdError() const; |
416 | void setpppdError(int err); | 410 | void setpppdError(int err); |
417 | 411 | ||
418 | // functions to set/query the accounting info | ||
419 | // const QString accountingFile(); | ||
420 | // void setAccountingFile(const QString &); | ||
421 | |||
422 | // const QString totalCosts(); | ||
423 | // void setTotalCosts(const QString &); | ||
424 | |||
425 | // int totalBytes(); | ||
426 | // void setTotalBytes(int); | ||
427 | |||
428 | // // graphing widget | ||
429 | // void setGraphingOptions(bool enabled, | ||
430 | // QColor bg, | ||
431 | // QColor text, | ||
432 | // QColor in, | ||
433 | // QColor out); | ||
434 | // void graphingOptions(bool &enabled, | ||
435 | // QColor &bg, | ||
436 | // QColor &text, | ||
437 | // QColor &in, | ||
438 | // QColor &out); | ||
439 | // bool graphingEnabled(); | ||
440 | |||
441 | // // window positions | ||
442 | // void winPosConWin(int &, int &); | ||
443 | // void setWinPosConWin(int, int); | ||
444 | // void winPosStatWin(int &, int &); | ||
445 | // void setWinPosStatWin(int, int); | ||
446 | |||
447 | private: | 412 | private: |
448 | 413 | ||
449 | static PPPData *_data; | 414 | //static PPPData *_data; |
450 | int modemDeviceGroup; | 415 | int modemDeviceGroup; |
451 | QString passwd; | 416 | QString passwd; |
452 | static Config* config; // configuration object | 417 | // static Config* config; // configuration object |
453 | int highcount; // index of highest account | 418 | int highcount; // index of highest account |
454 | int caccount; // index of the current account | 419 | int caccount; // index of the current account |
455 | QString cgroup; // name of current config group | 420 | QString cgroup; // name of current config group |
456 | pid_t suidprocessid; // process ID of setuid child | 421 | pid_t suidprocessid; // process ID of setuid child |
457 | bool pppdisrunning; // pppd process | 422 | bool pppdisrunning; // pppd process |
458 | // daemon | 423 | // daemon |
459 | int pppderror; // error encounterd running pppd | 424 | int pppderror; // error encounterd running pppd |
460 | int pppdVer, pppdMod, pppdPatch; // pppd version | 425 | int pppdVer, pppdMod, pppdPatch; // pppd version |
461 | 426 | ||
462 | QStringList phonelist; | 427 | QStringList phonelist; |
428 | QMap<QString,QString> stringEntries; | ||
429 | QMap<QString,int> intEntries; | ||
430 | QMap<QString,QStringList> listEntries; | ||
431 | QMap<QString,QChar> sepEntries; | ||
432 | |||
463 | }; | 433 | }; |
464 | 434 | ||
465 | #endif | 435 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index 7cbccc2..95df068 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,139 +1,142 @@ | |||
1 | |||
1 | #include "pppconfig.h" | 2 | #include "pppconfig.h" |
2 | #include "pppmodule.h" | 3 | #include "pppmodule.h" |
3 | #include "pppdata.h" | 4 | #include "pppdata.h" |
4 | #include "kpppwidget.h" | 5 | #include "interfaceinformationppp.h" |
5 | #include "interfaceinformationimp.h" | 6 | #include "interfaceppp.h" |
6 | //#include "devices.h" | 7 | |
7 | 8 | ||
8 | /** | 9 | /** |
9 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
10 | */ | 11 | */ |
11 | PPPModule::PPPModule() : Module() | 12 | PPPModule::PPPModule() : Module() |
12 | { | 13 | { |
13 | QMap<QString,QString> ifaces = PPPData::data()->getConfiguredInterfaces(); | 14 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
14 | QMap<QString,QString>::Iterator it; | 15 | QMap<QString,QString>::Iterator it; |
15 | Interface *iface; | 16 | InterfacePPP *iface; |
16 | qDebug("getting interfaces"); | 17 | qDebug("getting interfaces"); |
17 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 18 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
18 | qDebug("ifaces %s", it.key().latin1()); | 19 | qDebug("ifaces %s", it.key().latin1()); |
19 | iface = new Interface( 0, it.key() ); | 20 | iface = new InterfacePPP( 0, it.key() ); |
20 | iface->setHardwareName( it.data() ); | 21 | iface->setHardwareName( it.data() ); |
21 | list.append( iface ); | 22 | list.append( (Interface*)iface ); |
22 | } | 23 | } |
23 | } | 24 | } |
24 | 25 | ||
25 | /** | 26 | /** |
26 | * Delete any interfaces that we own. | 27 | * Delete any interfaces that we own. |
27 | */ | 28 | */ |
28 | PPPModule::~PPPModule(){ | 29 | PPPModule::~PPPModule(){ |
29 | QMap<QString,QString> ifaces; | 30 | QMap<QString,QString> ifaces; |
30 | Interface *i; | 31 | Interface *i; |
31 | for ( i=list.first(); i != 0; i=list.next() ){ | 32 | for ( i=list.first(); i != 0; i=list.next() ){ |
32 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 33 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
33 | delete i; | 34 | delete i; |
34 | } | 35 | } |
35 | PPPData::data()->setConfiguredInterfaces( ifaces ); | 36 | PPPData::setConfiguredInterfaces( ifaces ); |
36 | PPPData::data()->save(); | ||
37 | } | 37 | } |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Change the current profile | 40 | * Change the current profile |
41 | */ | 41 | */ |
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( i, 0, "PPPConfig", | 70 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
71 | false, | 71 | 0, "PPPConfig", false, |
72 | Qt::WDestructiveClose ); | 72 | Qt::WDestructiveClose ); |
73 | return pppconfig; | 73 | return pppconfig; |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Create, and return the Information Module | 77 | * Create, and return the Information Module |
78 | * @return QWidget* pointer to this modules info. | 78 | * @return QWidget* pointer to this modules info. |
79 | */ | 79 | */ |
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 | qDebug("return PPPModule::information"); |
84 | InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i); | 84 | // InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i); |
85 | InterfaceInformationPPP *information = new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | ||
85 | return information; | 86 | return information; |
86 | } | 87 | } |
87 | 88 | ||
88 | /** | 89 | /** |
89 | * Get all active (up or down) interfaces | 90 | * Get all active (up or down) interfaces |
90 | * @return QList<Interface> A list of interfaces that exsist that havn't | 91 | * @return QList<Interface> A list of interfaces that exsist that havn't |
91 | * been called by isOwner() | 92 | * been called by isOwner() |
92 | */ | 93 | */ |
93 | QList<Interface> PPPModule::getInterfaces(){ | 94 | QList<Interface> PPPModule::getInterfaces(){ |
94 | // List all of the files in the peer directory | 95 | // List all of the files in the peer directory |
95 | qDebug("PPPModule::getInterfaces"); | 96 | qDebug("PPPModule::getInterfaces"); |
96 | return list; | 97 | return list; |
97 | } | 98 | } |
98 | 99 | ||
99 | /** | 100 | /** |
100 | * Attempt to add a new interface as defined by name | 101 | * Attempt to add a new interface as defined by name |
101 | * @param name the name of the type of interface that should be created given | 102 | * @param name the name of the type of interface that should be created given |
102 | * by possibleNewInterfaces(); | 103 | * by possibleNewInterfaces(); |
103 | * @return Interface* NULL if it was unable to be created. | 104 | * @return Interface* NULL if it was unable to be created. |
104 | */ | 105 | */ |
105 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 106 | Interface *PPPModule::addNewInterface(const QString &newInterface){ |
106 | 107 | ||
107 | qDebug("try to add iface %s",newInterface.latin1()); | 108 | qDebug("try to add iface %s",newInterface.latin1()); |
108 | 109 | ||
110 | InterfacePPP *ifaceppp; | ||
109 | Interface *iface; | 111 | Interface *iface; |
110 | iface = new Interface(); | 112 | ifaceppp = new InterfacePPP(); |
111 | PPPConfigWidget imp(iface, 0, "PPPConfigImp", true); | 113 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
112 | imp.showMaximized(); | 114 | imp.showMaximized(); |
113 | if(imp.exec() == QDialog::Accepted ){ | 115 | if(imp.exec() == QDialog::Accepted ){ |
114 | iface->setModuleOwner( this ); | 116 | iface->setModuleOwner( this ); |
117 | iface = ifaceppp; | ||
115 | list.append( iface ); | 118 | list.append( iface ); |
116 | return iface; | 119 | return iface; |
117 | }else { | 120 | }else { |
118 | delete iface; | 121 | delete iface; |
119 | iface = NULL; | 122 | iface = NULL; |
120 | } | 123 | } |
121 | return iface; | 124 | return iface; |
122 | } | 125 | } |
123 | 126 | ||
124 | /** | 127 | /** |
125 | * Attempts to remove the interface, doesn't delete i | 128 | * Attempts to remove the interface, doesn't delete i |
126 | * @return bool true if successfull, false otherwise. | 129 | * @return bool true if successfull, false otherwise. |
127 | */ | 130 | */ |
128 | bool PPPModule::remove(Interface*){ | 131 | bool PPPModule::remove(Interface*){ |
129 | // Can't remove a hardware device, you can stop it though. | 132 | // Can't remove a hardware device, you can stop it though. |
130 | return false; | 133 | return false; |
131 | } | 134 | } |
132 | 135 | ||
133 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 136 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
134 | { | 137 | { |
135 | newIfaces.insert(QObject::tr("PPP") , | 138 | newIfaces.insert(QObject::tr("PPP") , |
136 | QObject::tr("generic ppp device")); | 139 | QObject::tr("generic ppp device")); |
137 | } | 140 | } |
138 | 141 | ||
139 | 142 | ||