Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (show whitespace changes)
29 files changed, 1541 insertions, 664 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 80fc5a6..14a1b3f 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,9 +1,3 @@ | |||
1 | - ask for password is non is set | 1 | - impl. PPPData::copyaccount |
2 | |||
3 | - stop pppd, i.e. fix interfaceinformationppp | ||
4 | |||
5 | - update modem attribute inputs when modem has changed | ||
6 | - impl. PPPData::copyaccount & PPPData::deleteAccount | ||
7 | |||
8 | - check if the same interface device combination allready exists | 2 | - check if the same interface device combination allready exists |
9 | - fix layout of edit account, i.e. get it shown maximised | 3 | - check if a deleted account or device exists in a config and ask the user |
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index fa1c43b..28d8732 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -35,185 +35,151 @@ | |||
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qvgroupbox.h> | 38 | #include <qvgroupbox.h> |
39 | 39 | ||
40 | #include "accounts.h" | 40 | #include "accounts.h" |
41 | #include "authwidget.h" | 41 | #include "authwidget.h" |
42 | #include "pppdata.h" | 42 | #include "pppdata.h" |
43 | #include "edit.h" | 43 | #include "edit.h" |
44 | 44 | ||
45 | void parseargs(char* buf, char** args); | 45 | void parseargs(char* buf, char** args); |
46 | 46 | ||
47 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) | 47 | |
48 | : QWidget( parent, name )//, _pppdata(pd) | 48 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) |
49 | : ChooserWidget( pd, parent, name, f ) | ||
49 | { | 50 | { |
50 | _pppdata = pd; | ||
51 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | ||
52 | accountlist_l = new QListBox(this); | ||
53 | |||
54 | connect(accountlist_l, SIGNAL(highlighted(int)), | ||
55 | this, SLOT(slotListBoxSelect(int))); | ||
56 | connect(accountlist_l, SIGNAL(selected(int)), | ||
57 | this, SLOT(editaccount())); | ||
58 | l1->addWidget(accountlist_l, 10); | ||
59 | |||
60 | edit_b = new QPushButton(tr("&Edit..."), this); | ||
61 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | ||
62 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); | ||
63 | l1->addWidget(edit_b); | ||
64 | 51 | ||
65 | new_b = new QPushButton(tr("&New..."), this); | 52 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); |
66 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); | ||
67 | l1->addWidget(new_b); | ||
68 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" | 53 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" |
69 | "to the Internet")); | 54 | "to the Internet")); |
70 | |||
71 | copy_b = new QPushButton(tr("Co&py"), this); | ||
72 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); | ||
73 | l1->addWidget(copy_b); | ||
74 | QWhatsThis::add(copy_b, | 55 | QWhatsThis::add(copy_b, |
75 | tr("Makes a copy of the selected account. All\n" | 56 | tr("Makes a copy of the selected account. All\n" |
76 | "settings of the selected account are copied\n" | 57 | "settings of the selected account are copied\n" |
77 | "to a new account, that you can modify to fit your\n" | 58 | "to a new account, that you can modify to fit your\n" |
78 | "needs")); | 59 | "needs")); |
79 | |||
80 | delete_b = new QPushButton(tr("De&lete"), this); | ||
81 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); | ||
82 | l1->addWidget(delete_b); | ||
83 | QWhatsThis::add(delete_b, | 60 | QWhatsThis::add(delete_b, |
84 | tr("<p>Deletes the selected account\n\n" | 61 | tr("<p>Deletes the selected account\n\n" |
85 | "<font color=\"red\"><b>Use with care!</b></font>")); | 62 | "<font color=\"red\"><b>Use with care!</b></font>")); |
86 | 63 | ||
87 | QHBoxLayout *l12 = new QHBoxLayout; | ||
88 | l1->addStretch(1); | ||
89 | l1->addLayout(l12); | ||
90 | 64 | ||
91 | int currAccId = _pppdata->currentAccountID(); | ||
92 | qDebug("currentAccountID %i", currAccId); | ||
93 | 65 | ||
94 | //load up account list from gppdata to the list box | 66 | copy_b->setEnabled( false ); //FIXME |
95 | if(_pppdata->count() > 0) { | 67 | // delete_b->setEnabled( false ); //FIXME |
96 | for(int i=0; i <= _pppdata->count()-1; i++) { | ||
97 | _pppdata->setAccountbyIndex(i); | ||
98 | accountlist_l->insertItem(_pppdata->accname()); | ||
99 | } | ||
100 | } | ||
101 | _pppdata->setAccountbyIndex( currAccId ); | ||
102 | 68 | ||
103 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); | 69 | listListbox->insertStringList(_pppdata->getAccountList()); |
104 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); | ||
105 | slotListBoxSelect( _pppdata->currentAccountID() ); | ||
106 | 70 | ||
107 | l1->activate(); | 71 | for (uint i = 0; i < listListbox->count(); i++){ |
72 | if ( listListbox->text(i) == _pppdata->accname() ) | ||
73 | listListbox->setCurrentItem( i ); | ||
74 | } | ||
108 | } | 75 | } |
109 | 76 | ||
110 | 77 | ||
111 | 78 | ||
112 | void AccountWidget::slotListBoxSelect(int idx) { | 79 | void AccountWidget::slotListBoxSelect(int idx) { |
113 | delete_b->setEnabled((bool)(idx != -1)); | 80 | bool ok = _pppdata->setAccount( listListbox->text(idx) ); |
114 | edit_b->setEnabled((bool)(idx != -1)); | 81 | ok = (bool)(idx != -1); |
115 | copy_b->setEnabled((bool)(idx != -1)); | 82 | delete_b->setEnabled(ok); |
116 | if(idx!=-1) { | 83 | edit_b->setEnabled(ok); |
117 | qDebug("setting account to %i", idx); | 84 | //FIXME copy_b->setEnabled(ok); |
118 | QString account = _pppdata->accname(); | ||
119 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); | ||
120 | } | ||
121 | } | 85 | } |
122 | 86 | ||
123 | void AccountWidget::editaccount() { | 87 | void AccountWidget::edit() { |
124 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 88 | _pppdata->setAccount(listListbox->text(listListbox->currentItem())); |
125 | 89 | ||
126 | int result = doTab(); | 90 | int result = doTab(); |
127 | 91 | ||
128 | if(result == QDialog::Accepted) { | 92 | if(result == QDialog::Accepted) { |
129 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); | 93 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); |
130 | // emit resetaccounts(); | 94 | // emit resetaccounts(); |
131 | _pppdata->save(); | 95 | _pppdata->save(); |
132 | } | 96 | } |
133 | } | 97 | } |
134 | 98 | ||
135 | 99 | ||
136 | void AccountWidget::newaccount() { | 100 | void AccountWidget::create() { |
137 | 101 | ||
138 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 102 | // if(listListbox->count() == MAX_ACCOUNTS) { |
139 | QMessageBox::information(this, "sorry", | 103 | // QMessageBox::information(this, "sorry", |
140 | tr("Maximum number of accounts reached.")); | 104 | // tr("Maximum number of accounts reached.")); |
141 | return; | 105 | // return; |
142 | } | 106 | // } |
143 | 107 | ||
144 | int result; | 108 | int result; |
145 | if (_pppdata->newaccount() == -1){ | 109 | if (_pppdata->newaccount() == -1){ |
146 | qDebug("_pppdata->newaccount() == -1"); | 110 | qDebug("_pppdata->newaccount() == -1"); |
147 | return; | 111 | return; |
148 | } | 112 | } |
149 | result = doTab(); | 113 | result = doTab(); |
150 | 114 | ||
151 | if(result == QDialog::Accepted) { | 115 | if(result == QDialog::Accepted) { |
152 | accountlist_l->insertItem(_pppdata->accname()); | 116 | listListbox->insertItem(_pppdata->accname()); |
153 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); | 117 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); |
154 | 118 | ||
155 | _pppdata->save(); | 119 | _pppdata->save(); |
156 | } else | 120 | } else |
157 | _pppdata->deleteAccount(); | 121 | _pppdata->deleteAccount(); |
158 | } | 122 | } |
159 | 123 | ||
160 | 124 | ||
161 | void AccountWidget::copyaccount() { | 125 | void AccountWidget::copy() { |
162 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 126 | // if(listListbox->count() == MAX_ACCOUNTS) { |
163 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 127 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
164 | return; | 128 | // return; |
165 | } | 129 | // } |
166 | 130 | ||
167 | if(accountlist_l->currentItem()<0) { | 131 | if(listListbox->currentItem()<0) { |
168 | QMessageBox::information(this, "sorry", tr("No account selected.")); | 132 | QMessageBox::information(this, "sorry", tr("No account selected.")); |
169 | return; | 133 | return; |
170 | } | 134 | } |
171 | 135 | ||
172 | _pppdata->copyaccount(accountlist_l->currentItem()); | 136 | _pppdata->copyaccount(listListbox->currentText()); |
173 | 137 | ||
174 | accountlist_l->insertItem(_pppdata->accname()); | 138 | listListbox->insertItem(_pppdata->accname()); |
175 | // emit resetaccounts(); | 139 | // emit resetaccounts(); |
176 | _pppdata->save(); | 140 | _pppdata->save(); |
177 | } | 141 | } |
178 | 142 | ||
179 | 143 | ||
180 | void AccountWidget::deleteaccount() { | 144 | void AccountWidget::remove() { |
181 | 145 | ||
182 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") | 146 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") |
183 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 147 | .arg(listListbox->text(listListbox->currentItem())); |
184 | 148 | ||
185 | if(QMessageBox::warning(this,tr("Confirm"),s, | 149 | if(QMessageBox::warning(this,tr("Confirm"),s, |
186 | QMessageBox::Yes,QMessageBox::No | 150 | QMessageBox::Yes,QMessageBox::No |
187 | ) != QMessageBox::Yes) | 151 | ) != QMessageBox::Yes) |
188 | return; | 152 | return; |
189 | 153 | ||
190 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 154 | if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) |
191 | accountlist_l->removeItem(accountlist_l->currentItem()); | 155 | listListbox->removeItem(listListbox->currentItem()); |
192 | 156 | ||
193 | emit resetaccounts(); | ||
194 | _pppdata->save(); | ||
195 | 157 | ||
196 | slotListBoxSelect(accountlist_l->currentItem()); | 158 | // emit resetaccounts(); |
159 | // _pppdata->save(); | ||
160 | |||
161 | |||
162 | slotListBoxSelect(listListbox->currentItem()); | ||
197 | 163 | ||
198 | } | 164 | } |
199 | 165 | ||
200 | 166 | ||
201 | int AccountWidget::doTab(){ | 167 | int AccountWidget::doTab(){ |
202 | QDialog *dlg = new QDialog( 0, "newAccount", true ); | 168 | QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); |
203 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 169 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
204 | layout->setSpacing( 0 ); | 170 | layout->setSpacing( 0 ); |
205 | layout->setMargin( 1 ); | 171 | layout->setMargin( 1 ); |
206 | 172 | ||
207 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 173 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); |
208 | layout->addWidget( tabWindow ); | 174 | layout->addWidget( tabWindow ); |
209 | 175 | ||
210 | bool isnewaccount; | 176 | bool isnewaccount; |
211 | 177 | ||
212 | if(_pppdata->accname().isEmpty()) { | 178 | if(_pppdata->accname().isEmpty()) { |
213 | dlg->setCaption(tr("New Account")); | 179 | dlg->setCaption(tr("New Account")); |
214 | isnewaccount = true; | 180 | isnewaccount = true; |
215 | } else { | 181 | } else { |
216 | QString tit = tr("Edit Account: "); | 182 | QString tit = tr("Edit Account: "); |
217 | tit += _pppdata->accname(); | 183 | tit += _pppdata->accname(); |
218 | dlg->setCaption(tit); | 184 | dlg->setCaption(tit); |
219 | isnewaccount = false; | 185 | isnewaccount = false; |
@@ -264,43 +230,43 @@ int AccountWidget::doTab(){ | |||
264 | auth_w->save(); | 230 | auth_w->save(); |
265 | exec_w->save(); | 231 | exec_w->save(); |
266 | } | 232 | } |
267 | } | 233 | } |
268 | } | 234 | } |
269 | 235 | ||
270 | delete dlg; | 236 | delete dlg; |
271 | 237 | ||
272 | return result; | 238 | return result; |
273 | } | 239 | } |
274 | 240 | ||
275 | 241 | ||
276 | QString AccountWidget::prettyPrintVolume(unsigned int n) { | 242 | // QString AccountWidget::prettyPrintVolume(unsigned int n) { |
277 | int idx = 0; | 243 | // int idx = 0; |
278 | const QString quant[] = {tr("Byte"), tr("KB"), | 244 | // const QString quant[] = {tr("Byte"), tr("KB"), |
279 | tr("MB"), tr("GB"), QString::null}; | 245 | // tr("MB"), tr("GB"), QString::null}; |
280 | 246 | ||
281 | float n1 = n; | 247 | // float n1 = n; |
282 | while(n >= 1024 && quant[idx] != QString::null) { | 248 | // while(n >= 1024 && quant[idx] != QString::null) { |
283 | idx++; | 249 | // idx++; |
284 | n /= 1024; | 250 | // n /= 1024; |
285 | } | 251 | // } |
286 | 252 | ||
287 | int i = idx; | 253 | // int i = idx; |
288 | while(i--) | 254 | // while(i--) |
289 | n1 = n1 / 1024.0; | 255 | // n1 = n1 / 1024.0; |
290 | 256 | ||
291 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); | 257 | // QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); |
292 | s += " " + quant[idx]; | 258 | // s += " " + quant[idx]; |
293 | return s; | 259 | // return s; |
294 | } | 260 | // } |
295 | 261 | ||
296 | 262 | ||
297 | ///////////////////////////////////////////////////////////////////////////// | 263 | ///////////////////////////////////////////////////////////////////////////// |
298 | // | 264 | // |
299 | // Queries the user what to reset: costs, volume or both | 265 | // Queries the user what to reset: costs, volume or both |
300 | // | 266 | // |
301 | ///////////////////////////////////////////////////////////////////////////// | 267 | ///////////////////////////////////////////////////////////////////////////// |
302 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { | 268 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { |
303 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 269 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
304 | // setCaption(tr("Reset Accounting")); | 270 | // setCaption(tr("Reset Accounting")); |
305 | 271 | ||
306 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 272 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h index 8c16a7c..7f31513 100644 --- a/noncore/settings/networksettings/ppp/accounts.h +++ b/noncore/settings/networksettings/ppp/accounts.h | |||
@@ -18,69 +18,63 @@ | |||
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> | ||
31 | #include <qdialog.h> | 30 | #include <qdialog.h> |
32 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
33 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
34 | //#include "acctselect.h" | 33 | #include "chooserwidget.h" |
35 | 34 | ||
36 | class QDialog; | ||
37 | class QCheckBox; | 35 | class QCheckBox; |
38 | class QLineEdit; | 36 | class QLineEdit; |
39 | class QTabWidget; | 37 | class QTabWidget; |
38 | class ModemWidget; | ||
39 | class ModemWidget2; | ||
40 | |||
41 | |||
40 | class DialWidget; | 42 | class DialWidget; |
41 | class AuthWidget; | 43 | class AuthWidget; |
42 | class IPWidget; | 44 | class IPWidget; |
43 | class DNSWidget; | 45 | class DNSWidget; |
44 | class GatewayWidget; | 46 | class GatewayWidget; |
45 | class PPPData; | 47 | class PPPData; |
46 | 48 | ||
47 | class AccountWidget : public QWidget { | 49 | |
50 | class AccountWidget : public ChooserWidget { | ||
51 | |||
48 | Q_OBJECT | 52 | Q_OBJECT |
49 | public: | 53 | public: |
50 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 ); | 54 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 ); |
51 | ~AccountWidget() {} | 55 | ~AccountWidget() {} |
52 | 56 | ||
53 | private slots: | ||
54 | void editaccount(); | ||
55 | void copyaccount(); | ||
56 | void newaccount(); | ||
57 | void deleteaccount(); | ||
58 | void slotListBoxSelect(int); | ||
59 | 57 | ||
60 | private: | 58 | private slots: |
59 | virtual void edit(); | ||
60 | virtual void copy(); | ||
61 | virtual void remove(); | ||
62 | virtual void create(); | ||
63 | virtual void slotListBoxSelect(int); | ||
61 | int doTab(); | 64 | int doTab(); |
62 | 65 | ||
63 | signals: | 66 | signals: |
64 | void resetaccounts(); | 67 | void resetaccounts(); |
65 | 68 | ||
66 | private: | 69 | private: |
67 | QString prettyPrintVolume(unsigned int); | ||
68 | |||
69 | PPPData *_pppdata; | ||
70 | QTabWidget *tabWindow; | ||
71 | DialWidget *dial_w; | 70 | DialWidget *dial_w; |
72 | IPWidget *ip_w; | 71 | IPWidget *ip_w; |
73 | DNSWidget *dns_w; | 72 | DNSWidget *dns_w; |
74 | GatewayWidget *gateway_w; | 73 | GatewayWidget *gateway_w; |
75 | AuthWidget *auth_w; | 74 | AuthWidget *auth_w; |
76 | 75 | ||
77 | QListBox *accountlist_l; | ||
78 | QPushButton *edit_b; | ||
79 | QPushButton *copy_b; | ||
80 | QPushButton *new_b; | ||
81 | QPushButton *delete_b; | ||
82 | }; | 76 | }; |
83 | 77 | ||
84 | 78 | ||
85 | #endif | 79 | #endif |
86 | 80 | ||
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.cpp b/noncore/settings/networksettings/ppp/chooserwidget.cpp new file mode 100644 index 0000000..a32b2b8 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/chooserwidget.cpp | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qdir.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qtabwidget.h> | ||
31 | #include <qtabdialog.h> | ||
32 | #include <qwhatsthis.h> | ||
33 | #include <qmessagebox.h> | ||
34 | |||
35 | #include <qapplication.h> | ||
36 | #include <qbuttongroup.h> | ||
37 | #include <qmessagebox.h> | ||
38 | #include <qvgroupbox.h> | ||
39 | #include <qwidget.h> | ||
40 | |||
41 | #include "accounts.h" | ||
42 | #include "authwidget.h" | ||
43 | #include "pppdata.h" | ||
44 | #include "edit.h" | ||
45 | |||
46 | void parseargs(char* buf, char** args); | ||
47 | |||
48 | ChooserWidget::ChooserWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) | ||
49 | : QWidget( parent, name, f ) | ||
50 | { | ||
51 | _pppdata = pd; | ||
52 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | ||
53 | listListbox = new QListBox(this); | ||
54 | |||
55 | connect(listListbox, SIGNAL(highlighted(int)), | ||
56 | this, SLOT(slotListBoxSelect(int))); | ||
57 | connect(listListbox, SIGNAL(selected(int)),this, SLOT(edit())); | ||
58 | l1->addWidget(listListbox, 10); | ||
59 | |||
60 | edit_b = new QPushButton(tr("&Edit..."), this); | ||
61 | connect(edit_b, SIGNAL(clicked()), SLOT(edit())); | ||
62 | l1->addWidget(edit_b); | ||
63 | |||
64 | new_b = new QPushButton(tr("&New..."), this); | ||
65 | connect(new_b, SIGNAL(clicked()), SLOT(create())); | ||
66 | l1->addWidget(new_b); | ||
67 | |||
68 | |||
69 | copy_b = new QPushButton(tr("Co&py"), this); | ||
70 | connect(copy_b, SIGNAL(clicked()), SLOT(copy())); | ||
71 | l1->addWidget(copy_b); | ||
72 | |||
73 | delete_b = new QPushButton(tr("De&lete"), this); | ||
74 | connect(delete_b, SIGNAL(clicked()), SLOT(remove())); | ||
75 | l1->addWidget(delete_b); | ||
76 | |||
77 | |||
78 | QHBoxLayout *l12 = new QHBoxLayout; | ||
79 | l1->addStretch(1); | ||
80 | l1->addLayout(l12); | ||
81 | |||
82 | l1->activate(); | ||
83 | |||
84 | } | ||
85 | |||
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.h b/noncore/settings/networksettings/ppp/chooserwidget.h new file mode 100644 index 0000000..ac3f4cb --- a/dev/null +++ b/noncore/settings/networksettings/ppp/chooserwidget.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* -*- C++ -*- | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #ifndef _CHOOSERWIDGET_H_ | ||
28 | #define _CHOOSERWIDGET_H_ | ||
29 | |||
30 | #include <qwidget.h> | ||
31 | #include <qdialog.h> | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qlistbox.h> | ||
34 | //#include "acctselect.h" | ||
35 | |||
36 | class QDialog; | ||
37 | class QCheckBox; | ||
38 | class QLineEdit; | ||
39 | class QTabWidget; | ||
40 | class DialWidget; | ||
41 | class AuthWidget; | ||
42 | class IPWidget; | ||
43 | class DNSWidget; | ||
44 | class GatewayWidget; | ||
45 | class PPPData; | ||
46 | |||
47 | class ChooserWidget : public QWidget { | ||
48 | Q_OBJECT | ||
49 | public: | ||
50 | ChooserWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 ); | ||
51 | ~ChooserWidget() {} | ||
52 | |||
53 | private slots: | ||
54 | virtual void edit() = 0; | ||
55 | virtual void copy() = 0; | ||
56 | virtual void create()= 0; | ||
57 | virtual void remove()= 0; | ||
58 | virtual void slotListBoxSelect(int) = 0; | ||
59 | |||
60 | |||
61 | protected: | ||
62 | PPPData *_pppdata; | ||
63 | |||
64 | QListBox *listListbox; | ||
65 | QPushButton *edit_b; | ||
66 | QPushButton *copy_b; | ||
67 | QPushButton *new_b; | ||
68 | QPushButton *delete_b; | ||
69 | }; | ||
70 | |||
71 | |||
72 | #endif | ||
73 | |||
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 2400d7b..e3fab24 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -23,25 +23,24 @@ | |||
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 | ||
36 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
38 | 37 | ||
39 | #include <unistd.h> | 38 | #include <unistd.h> |
40 | #include <stdlib.h> | 39 | #include <stdlib.h> |
41 | #include <string.h> | 40 | #include <string.h> |
42 | #include <fcntl.h> | 41 | #include <fcntl.h> |
43 | #include <netdb.h> | 42 | #include <netdb.h> |
44 | #include <sys/types.h> | 43 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 44 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 46 | #include <netinet/in.h> |
@@ -90,56 +89,56 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam | |||
90 | semaphore(false), | 89 | semaphore(false), |
91 | expecting(false), | 90 | expecting(false), |
92 | readbuffer(""), | 91 | readbuffer(""), |
93 | scanvar(""), | 92 | scanvar(""), |
94 | scanning(false), | 93 | scanning(false), |
95 | pausing(false), | 94 | pausing(false), |
96 | dialnumber(0), | 95 | dialnumber(0), |
97 | _ifaceppp(ifp) | 96 | _ifaceppp(ifp) |
98 | { | 97 | { |
99 | modified_hostname = false; | 98 | modified_hostname = false; |
100 | 99 | ||
101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 100 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
102 | QString tit = i18n("Connecting to: "); | 101 | QString tit = QObject::tr("Connecting to: "); |
103 | setCaption(tit); | 102 | setCaption(tit); |
104 | 103 | ||
105 | QHBoxLayout *l0 = new QHBoxLayout(10); | 104 | QHBoxLayout *l0 = new QHBoxLayout(10); |
106 | tl->addLayout(l0); | 105 | tl->addLayout(l0); |
107 | l0->addSpacing(10); | 106 | l0->addSpacing(10); |
108 | messg = new QLabel(this, "messg"); | 107 | messg = new QLabel(this, "messg"); |
109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 108 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | messg->setAlignment(AlignCenter); | 109 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 110 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 111 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | // int messw = (messg->sizeHint().width() * 12) / 10; | 112 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | // messw = QMAX(messw,280); | 113 | // messw = QMAX(messw,280); |
115 | // messg->setMinimumWidth(messw); | 114 | // messg->setMinimumWidth(messw); |
116 | if (_ifaceppp->getStatus()) | 115 | if (_ifaceppp->getStatus()) |
117 | messg->setText(i18n("Online")); | 116 | messg->setText(QObject::tr("Online")); |
118 | else | 117 | else |
119 | messg->setText(i18n("Offline")); | 118 | messg->setText(QObject::tr("Offline")); |
120 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
121 | l0->addWidget(messg); | 120 | l0->addWidget(messg); |
122 | l0->addSpacing(10); | 121 | l0->addSpacing(10); |
123 | 122 | ||
124 | QHBoxLayout *l1 = new QHBoxLayout(10); | 123 | QHBoxLayout *l1 = new QHBoxLayout(10); |
125 | tl->addLayout(l1); | 124 | tl->addLayout(l1); |
126 | l1->addStretch(1); | 125 | l1->addStretch(1); |
127 | 126 | ||
128 | debug = new QPushButton(i18n("Log"), this); | 127 | debug = new QPushButton(QObject::tr("Log"), this); |
129 | debug->setToggleButton(true); | 128 | debug->setToggleButton(true); |
130 | debug->setEnabled( false ); // FIXME: disable the log button | 129 | debug->setEnabled( false ); // FIXME: disable the log button |
131 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 130 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
132 | 131 | ||
133 | cancel = new QPushButton(i18n("Cancel"), this); | 132 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
134 | cancel->setFocus(); | 133 | cancel->setFocus(); |
135 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 134 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
136 | 135 | ||
137 | // int maxw = QMAX(cancel->sizeHint().width(), | 136 | // int maxw = QMAX(cancel->sizeHint().width(), |
138 | // debug->sizeHint().width()); | 137 | // debug->sizeHint().width()); |
139 | // maxw = QMAX(maxw,65); | 138 | // maxw = QMAX(maxw,65); |
140 | // debug->setFixedWidth(maxw); | 139 | // debug->setFixedWidth(maxw); |
141 | // cancel->setFixedWidth(maxw); | 140 | // cancel->setFixedWidth(maxw); |
142 | l1->addWidget(debug); | 141 | l1->addWidget(debug); |
143 | l1->addWidget(cancel); | 142 | l1->addWidget(cancel); |
144 | 143 | ||
145 | // setFixedSize(sizeHint()); | 144 | // setFixedSize(sizeHint()); |
@@ -164,25 +163,25 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam | |||
164 | if_timer = new QTimer(this); | 163 | if_timer = new QTimer(this); |
165 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 164 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
166 | } | 165 | } |
167 | 166 | ||
168 | 167 | ||
169 | ConnectWidget::~ConnectWidget() { | 168 | ConnectWidget::~ConnectWidget() { |
170 | } | 169 | } |
171 | 170 | ||
172 | 171 | ||
173 | void ConnectWidget::preinit() { | 172 | void ConnectWidget::preinit() { |
174 | // this is all just to keep the GUI nice and snappy .... | 173 | // this is all just to keep the GUI nice and snappy .... |
175 | // you have to see to believe ... | 174 | // you have to see to believe ... |
176 | messg->setText(i18n("Looking for modem...")); | 175 | messg->setText(QObject::tr("Looking for modem...")); |
177 | inittimer->start(100); | 176 | inittimer->start(100); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | void ConnectWidget::init() { | 180 | void ConnectWidget::init() { |
182 | _ifaceppp->data()->setpppdError(0); | 181 | _ifaceppp->data()->setpppdError(0); |
183 | inittimer->stop(); | 182 | inittimer->stop(); |
184 | vmain = 0; | 183 | vmain = 0; |
185 | substate = -1; | 184 | substate = -1; |
186 | expecting = false; | 185 | expecting = false; |
187 | pausing = false; | 186 | pausing = false; |
188 | scriptindex = 0; | 187 | scriptindex = 0; |
@@ -192,56 +191,56 @@ void ConnectWidget::init() { | |||
192 | firstrunID = true; | 191 | firstrunID = true; |
193 | firstrunPW = true; | 192 | firstrunPW = true; |
194 | // stats->totalbytes = 0; | 193 | // stats->totalbytes = 0; |
195 | dialnumber = 0; | 194 | dialnumber = 0; |
196 | 195 | ||
197 | // p_kppp->con_speed = ""; | 196 | // p_kppp->con_speed = ""; |
198 | 197 | ||
199 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); | 198 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
200 | 199 | ||
201 | comlist = &_ifaceppp->data()->scriptType(); | 200 | comlist = &_ifaceppp->data()->scriptType(); |
202 | arglist = &_ifaceppp->data()->script(); | 201 | arglist = &_ifaceppp->data()->script(); |
203 | 202 | ||
204 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); | 203 | QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
205 | setCaption(tit); | 204 | setCaption(tit); |
206 | 205 | ||
207 | qApp->processEvents(); | 206 | qApp->processEvents(); |
208 | 207 | ||
209 | // run the "before-connect" command | 208 | // run the "before-connect" command |
210 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { | 209 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
211 | messg->setText(i18n("Running pre-startup command...")); | 210 | messg->setText(QObject::tr("Running pre-startup command...")); |
212 | emit debugMessage(i18n("Running pre-startup command...")); | 211 | emit debugMessage(QObject::tr("Running pre-startup command...")); |
213 | 212 | ||
214 | qApp->processEvents(); | 213 | qApp->processEvents(); |
215 | QApplication::flushX(); | 214 | QApplication::flushX(); |
216 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); | 215 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
217 | // int i, status; | 216 | // int i, status; |
218 | 217 | ||
219 | // do { | 218 | // do { |
220 | // qApp->processEvents(); | 219 | // qApp->processEvents(); |
221 | // i = waitpid(id, &status, WNOHANG); | 220 | // i = waitpid(id, &status, WNOHANG); |
222 | // usleep(100000); | 221 | // usleep(100000); |
223 | // } while (i == 0 && errno == 0); | 222 | // } while (i == 0 && errno == 0); |
224 | } | 223 | } |
225 | 224 | ||
226 | int lock = _ifaceppp->modem()->lockdevice(); | 225 | int lock = _ifaceppp->modem()->lockdevice(); |
227 | 226 | ||
228 | if (lock == 1) { | 227 | if (lock == 1) { |
229 | messg->setText(i18n("Modem device is locked.")); | 228 | messg->setText(QObject::tr("Modem device is locked.")); |
230 | vmain = 20; // wait until cancel is pressed | 229 | vmain = 20; // wait until cancel is pressed |
231 | return; | 230 | return; |
232 | } | 231 | } |
233 | 232 | ||
234 | if (lock == -1) { | 233 | if (lock == -1) { |
235 | messg->setText(i18n("Unable to create modem lock file.")); | 234 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
236 | vmain = 20; // wait until cancel is pressed | 235 | vmain = 20; // wait until cancel is pressed |
237 | return; | 236 | return; |
238 | } | 237 | } |
239 | 238 | ||
240 | if(_ifaceppp->modem()->opentty()) { | 239 | if(_ifaceppp->modem()->opentty()) { |
241 | messg->setText(_ifaceppp->modem()->modemMessage()); | 240 | messg->setText(_ifaceppp->modem()->modemMessage()); |
242 | qApp->processEvents(); | 241 | qApp->processEvents(); |
243 | if(_ifaceppp->modem()->hangup()) { | 242 | if(_ifaceppp->modem()->hangup()) { |
244 | 243 | ||
245 | qApp->processEvents(); | 244 | qApp->processEvents(); |
246 | 245 | ||
247 | semaphore = false; | 246 | semaphore = false; |
@@ -270,26 +269,26 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
270 | if (semaphore || pausing) | 269 | if (semaphore || pausing) |
271 | return; | 270 | return; |
272 | 271 | ||
273 | if(vmain == 0) { | 272 | if(vmain == 0) { |
274 | #ifdef DEBUG_WO_DIALING | 273 | #ifdef DEBUG_WO_DIALING |
275 | vmain = 10; | 274 | vmain = 10; |
276 | return; | 275 | return; |
277 | #endif | 276 | #endif |
278 | 277 | ||
279 | assert(PPPData::NumInitStrings > 0); | 278 | assert(PPPData::NumInitStrings > 0); |
280 | // first init string ? | 279 | // first init string ? |
281 | if(substate == -1) { | 280 | if(substate == -1) { |
282 | messg->setText(i18n("Initializing modem...")); | 281 | messg->setText(QObject::tr("Initializing modem...")); |
283 | emit debugMessage(i18n("Initializing modem...")); | 282 | emit debugMessage(QObject::tr("Initializing modem...")); |
284 | substate = 0; | 283 | substate = 0; |
285 | } | 284 | } |
286 | 285 | ||
287 | QString initStr = _ifaceppp->data()->modemInitStr(substate); | 286 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
288 | if (!initStr.isEmpty()) { | 287 | if (!initStr.isEmpty()) { |
289 | // send a carriage return and then wait a bit so that the modem will | 288 | // send a carriage return and then wait a bit so that the modem will |
290 | // let us issue commands. | 289 | // let us issue commands. |
291 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { | 290 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
292 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 291 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
293 | writeline(""); | 292 | writeline(""); |
294 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 293 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
295 | } | 294 | } |
@@ -308,85 +307,85 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
308 | */ | 307 | */ |
309 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) | 308 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
310 | vmain = 5; | 309 | vmain = 5; |
311 | else | 310 | else |
312 | vmain = 3; | 311 | vmain = 3; |
313 | 312 | ||
314 | return; | 313 | return; |
315 | } | 314 | } |
316 | 315 | ||
317 | if (vmain == 5) { | 316 | if (vmain == 5) { |
318 | if(!expecting) { | 317 | if(!expecting) { |
319 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); | 318 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
320 | QString msg = i18n("Setting ") + sToneDuration; | 319 | QString msg = QObject::tr("Setting ") + sToneDuration; |
321 | messg->setText(msg); | 320 | messg->setText(msg); |
322 | emit debugMessage(msg); | 321 | emit debugMessage(msg); |
323 | setExpect(_ifaceppp->data()->modemInitResp()); | 322 | setExpect(_ifaceppp->data()->modemInitResp()); |
324 | writeline(sToneDuration); | 323 | writeline(sToneDuration); |
325 | } | 324 | } |
326 | vmain = 3; | 325 | vmain = 3; |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | 328 | ||
330 | if(vmain == 3) { | 329 | if(vmain == 3) { |
331 | if(!expecting) { | 330 | if(!expecting) { |
332 | // done with all init strings ? | 331 | // done with all init strings ? |
333 | if(substate < PPPData::NumInitStrings) { | 332 | if(substate < PPPData::NumInitStrings) { |
334 | vmain = 0; | 333 | vmain = 0; |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | substate = -1; | 336 | substate = -1; |
338 | // skip setting the volume if command is empty | 337 | // skip setting the volume if command is empty |
339 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { | 338 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
340 | vmain = 4; | 339 | vmain = 4; |
341 | return; | 340 | return; |
342 | } | 341 | } |
343 | messg->setText(i18n("Setting speaker volume...")); | 342 | messg->setText(QObject::tr("Setting speaker volume...")); |
344 | emit debugMessage(i18n("Setting speaker volume...")); | 343 | emit debugMessage(QObject::tr("Setting speaker volume...")); |
345 | 344 | ||
346 | setExpect(_ifaceppp->data()->modemInitResp()); | 345 | setExpect(_ifaceppp->data()->modemInitResp()); |
347 | QString vol("AT"); | 346 | QString vol("AT"); |
348 | vol += _ifaceppp->data()->volumeInitString(); | 347 | vol += _ifaceppp->data()->volumeInitString(); |
349 | writeline(vol); | 348 | writeline(vol); |
350 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 349 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
351 | vmain = 4; | 350 | vmain = 4; |
352 | return; | 351 | return; |
353 | } | 352 | } |
354 | } | 353 | } |
355 | 354 | ||
356 | if(vmain == 4) { | 355 | if(vmain == 4) { |
357 | if(!expecting) { | 356 | if(!expecting) { |
358 | if(!_ifaceppp->data()->waitForDialTone()) { | 357 | if(!_ifaceppp->data()->waitForDialTone()) { |
359 | QString msg = i18n("Turning off dial tone waiting..."); | 358 | QString msg = QObject::tr("Turning off dial tone waiting..."); |
360 | messg->setText(msg); | 359 | messg->setText(msg); |
361 | emit debugMessage(msg); | 360 | emit debugMessage(msg); |
362 | setExpect(_ifaceppp->data()->modemInitResp()); | 361 | setExpect(_ifaceppp->data()->modemInitResp()); |
363 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); | 362 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
364 | } | 363 | } |
365 | vmain = 1; | 364 | vmain = 1; |
366 | return; | 365 | return; |
367 | } | 366 | } |
368 | } | 367 | } |
369 | 368 | ||
370 | // dial the number and wait to connect | 369 | // dial the number and wait to connect |
371 | if(vmain == 1) { | 370 | if(vmain == 1) { |
372 | if(!expecting) { | 371 | if(!expecting) { |
373 | 372 | ||
374 | timeout_timer->stop(); | 373 | timeout_timer->stop(); |
375 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 374 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
376 | 375 | ||
377 | QStringList &plist = _ifaceppp->data()->phonenumbers(); | 376 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
378 | QString bmarg= _ifaceppp->data()->dialPrefix(); | 377 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
379 | bmarg += *plist.at(dialnumber); | 378 | bmarg += *plist.at(dialnumber); |
380 | QString bm = i18n("Dialing %1").arg(bmarg); | 379 | QString bm = QObject::tr("Dialing %1").arg(bmarg); |
381 | messg->setText(bm); | 380 | messg->setText(bm); |
382 | emit debugMessage(bm); | 381 | emit debugMessage(bm); |
383 | 382 | ||
384 | QString pn = _ifaceppp->data()->modemDialStr(); | 383 | QString pn = _ifaceppp->data()->modemDialStr(); |
385 | pn += _ifaceppp->data()->dialPrefix(); | 384 | pn += _ifaceppp->data()->dialPrefix(); |
386 | pn += *plist.at(dialnumber); | 385 | pn += *plist.at(dialnumber); |
387 | if(++dialnumber >= plist.count()) | 386 | if(++dialnumber >= plist.count()) |
388 | dialnumber = 0; | 387 | dialnumber = 0; |
389 | writeline(pn); | 388 | writeline(pn); |
390 | 389 | ||
391 | setExpect(_ifaceppp->data()->modemConnectResp()); | 390 | setExpect(_ifaceppp->data()->modemConnectResp()); |
392 | vmain = 100; | 391 | vmain = 100; |
@@ -399,58 +398,58 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
399 | if(vmain == 100) { | 398 | if(vmain == 100) { |
400 | if(!expecting) { | 399 | if(!expecting) { |
401 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); | 400 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
402 | setExpect("\n"); | 401 | setExpect("\n"); |
403 | vmain = 101; | 402 | vmain = 101; |
404 | return; | 403 | return; |
405 | } | 404 | } |
406 | 405 | ||
407 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { | 406 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
408 | timeout_timer->stop(); | 407 | timeout_timer->stop(); |
409 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 408 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
410 | 409 | ||
411 | messg->setText(i18n("Line busy. Hanging up...")); | 410 | messg->setText(QObject::tr("Line busy. Hanging up...")); |
412 | emit debugPutChar('\n'); | 411 | emit debugPutChar('\n'); |
413 | _ifaceppp->modem()->hangup(); | 412 | _ifaceppp->modem()->hangup(); |
414 | 413 | ||
415 | if(_ifaceppp->data()->busyWait() > 0) { | 414 | if(_ifaceppp->data()->busyWait() > 0) { |
416 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); | 415 | QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
417 | messg->setText(bm); | 416 | messg->setText(bm); |
418 | emit debugMessage(bm); | 417 | emit debugMessage(bm); |
419 | 418 | ||
420 | pausing = true; | 419 | pausing = true; |
421 | 420 | ||
422 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); | 421 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
423 | timeout_timer->stop(); | 422 | timeout_timer->stop(); |
424 | } | 423 | } |
425 | 424 | ||
426 | _ifaceppp->modem()->setDataMode(false); | 425 | _ifaceppp->modem()->setDataMode(false); |
427 | vmain = 0; | 426 | vmain = 0; |
428 | substate = -1; | 427 | substate = -1; |
429 | return; | 428 | return; |
430 | } | 429 | } |
431 | 430 | ||
432 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { | 431 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
433 | timeout_timer->stop(); | 432 | timeout_timer->stop(); |
434 | 433 | ||
435 | messg->setText(i18n("No Dialtone")); | 434 | messg->setText(QObject::tr("No Dialtone")); |
436 | vmain = 20; | 435 | vmain = 20; |
437 | _ifaceppp->modem()->unlockdevice(); | 436 | _ifaceppp->modem()->unlockdevice(); |
438 | return; | 437 | return; |
439 | } | 438 | } |
440 | 439 | ||
441 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { | 440 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
442 | timeout_timer->stop(); | 441 | timeout_timer->stop(); |
443 | 442 | ||
444 | messg->setText(i18n("No Carrier")); | 443 | messg->setText(QObject::tr("No Carrier")); |
445 | vmain = 20; | 444 | vmain = 20; |
446 | _ifaceppp->modem()->unlockdevice(); | 445 | _ifaceppp->modem()->unlockdevice(); |
447 | return; | 446 | return; |
448 | } | 447 | } |
449 | } | 448 | } |
450 | 449 | ||
451 | // wait for newline after CONNECT response (so we get the speed) | 450 | // wait for newline after CONNECT response (so we get the speed) |
452 | if(vmain == 101) { | 451 | if(vmain == 101) { |
453 | if(!expecting) { | 452 | if(!expecting) { |
454 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands | 453 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
455 | 454 | ||
456 | emit startAccounting(); | 455 | emit startAccounting(); |
@@ -470,144 +469,144 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
470 | timeout_timer->start(scriptTimeout); | 469 | timeout_timer->start(scriptTimeout); |
471 | 470 | ||
472 | if((unsigned) scriptindex < comlist->count()) { | 471 | if((unsigned) scriptindex < comlist->count()) { |
473 | scriptCommand = *(comlist->at(scriptindex)); | 472 | scriptCommand = *(comlist->at(scriptindex)); |
474 | scriptArgument = *(arglist->at(scriptindex)); | 473 | scriptArgument = *(arglist->at(scriptindex)); |
475 | } else { | 474 | } else { |
476 | qDebug( "End of script" ); | 475 | qDebug( "End of script" ); |
477 | vmain = 10; | 476 | vmain = 10; |
478 | return; | 477 | return; |
479 | } | 478 | } |
480 | 479 | ||
481 | if (scriptCommand == "Scan") { | 480 | if (scriptCommand == "Scan") { |
482 | QString bm = i18n("Scanning %1").arg(scriptArgument); | 481 | QString bm = QObject::tr("Scanning %1").arg(scriptArgument); |
483 | messg->setText(bm); | 482 | messg->setText(bm); |
484 | emit debugMessage(bm); | 483 | emit debugMessage(bm); |
485 | 484 | ||
486 | setScan(scriptArgument); | 485 | setScan(scriptArgument); |
487 | scriptindex++; | 486 | scriptindex++; |
488 | return; | 487 | return; |
489 | } | 488 | } |
490 | 489 | ||
491 | if (scriptCommand == "Save") { | 490 | if (scriptCommand == "Save") { |
492 | QString bm = i18n("Saving %1").arg(scriptArgument); | 491 | QString bm = QObject::tr("Saving %1").arg(scriptArgument); |
493 | messg->setText(bm); | 492 | messg->setText(bm); |
494 | emit debugMessage(bm); | 493 | emit debugMessage(bm); |
495 | 494 | ||
496 | if (scriptArgument.lower() == "password") { | 495 | if (scriptArgument.lower() == "password") { |
497 | _ifaceppp->data()->setPassword(scanvar); | 496 | _ifaceppp->data()->setPassword(scanvar); |
498 | // p_kppp->setPW_Edit(scanvar); | 497 | // p_kppp->setPW_Edit(scanvar); |
499 | if(_ifaceppp->data()->storePassword()) | 498 | if(_ifaceppp->data()->storePassword()) |
500 | _ifaceppp->data()->setStoredPassword(scanvar); | 499 | _ifaceppp->data()->setStoredPassword(scanvar); |
501 | firstrunPW = true; | 500 | firstrunPW = true; |
502 | } | 501 | } |
503 | 502 | ||
504 | scriptindex++; | 503 | scriptindex++; |
505 | return; | 504 | return; |
506 | } | 505 | } |
507 | 506 | ||
508 | 507 | ||
509 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { | 508 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { |
510 | QString bm = i18n("Sending %1"); | 509 | QString bm = QObject::tr("Sending %1"); |
511 | 510 | ||
512 | // replace %USERNAME% and %PASSWORD% | 511 | // replace %USERNAME% and %PASSWORD% |
513 | QString arg = scriptArgument; | 512 | QString arg = scriptArgument; |
514 | QRegExp re1("%USERNAME%"); | 513 | QRegExp re1("%USERNAME%"); |
515 | QRegExp re2("%PASSWORD%"); | 514 | QRegExp re2("%PASSWORD%"); |
516 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); | 515 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
517 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); | 516 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
518 | 517 | ||
519 | if (scriptCommand == "Send") | 518 | if (scriptCommand == "Send") |
520 | bm = bm.arg(scriptArgument); | 519 | bm = bm.arg(scriptArgument); |
521 | else { | 520 | else { |
522 | for(uint i = 0; i < scriptArgument.length(); i++) | 521 | for(uint i = 0; i < scriptArgument.length(); i++) |
523 | bm = bm.arg("*"); | 522 | bm = bm.arg("*"); |
524 | } | 523 | } |
525 | 524 | ||
526 | messg->setText(bm); | 525 | messg->setText(bm); |
527 | emit debugMessage(bm); | 526 | emit debugMessage(bm); |
528 | 527 | ||
529 | writeline(scriptArgument); | 528 | writeline(scriptArgument); |
530 | scriptindex++; | 529 | scriptindex++; |
531 | return; | 530 | return; |
532 | } | 531 | } |
533 | 532 | ||
534 | if (scriptCommand == "Expect") { | 533 | if (scriptCommand == "Expect") { |
535 | QString bm = i18n("Expecting %1").arg(scriptArgument); | 534 | QString bm = QObject::tr("Expecting %1").arg(scriptArgument); |
536 | messg->setText(bm); | 535 | messg->setText(bm); |
537 | emit debugMessage(bm); | 536 | emit debugMessage(bm); |
538 | 537 | ||
539 | // The incrementing of the scriptindex MUST be before the | 538 | // The incrementing of the scriptindex MUST be before the |
540 | // call to setExpect otherwise the expect will miss a string that is | 539 | // call to setExpect otherwise the expect will miss a string that is |
541 | // already in the buffer. | 540 | // already in the buffer. |
542 | scriptindex++; | 541 | scriptindex++; |
543 | setExpect(scriptArgument); | 542 | setExpect(scriptArgument); |
544 | return; | 543 | return; |
545 | } | 544 | } |
546 | 545 | ||
547 | 546 | ||
548 | if (scriptCommand == "Pause") { | 547 | if (scriptCommand == "Pause") { |
549 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); | 548 | QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); |
550 | messg->setText(bm); | 549 | messg->setText(bm); |
551 | emit debugMessage(bm); | 550 | emit debugMessage(bm); |
552 | 551 | ||
553 | pausing = true; | 552 | pausing = true; |
554 | 553 | ||
555 | pausetimer->start(scriptArgument.toInt()*1000, true); | 554 | pausetimer->start(scriptArgument.toInt()*1000, true); |
556 | timeout_timer->stop(); | 555 | timeout_timer->stop(); |
557 | 556 | ||
558 | scriptindex++; | 557 | scriptindex++; |
559 | return; | 558 | return; |
560 | } | 559 | } |
561 | 560 | ||
562 | if (scriptCommand == "Timeout") { | 561 | if (scriptCommand == "Timeout") { |
563 | 562 | ||
564 | timeout_timer->stop(); | 563 | timeout_timer->stop(); |
565 | 564 | ||
566 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); | 565 | QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); |
567 | messg->setText(bm); | 566 | messg->setText(bm); |
568 | emit debugMessage(bm); | 567 | emit debugMessage(bm); |
569 | 568 | ||
570 | scriptTimeout=scriptArgument.toInt()*1000; | 569 | scriptTimeout=scriptArgument.toInt()*1000; |
571 | timeout_timer->start(scriptTimeout); | 570 | timeout_timer->start(scriptTimeout); |
572 | 571 | ||
573 | scriptindex++; | 572 | scriptindex++; |
574 | return; | 573 | return; |
575 | } | 574 | } |
576 | 575 | ||
577 | if (scriptCommand == "Hangup") { | 576 | if (scriptCommand == "Hangup") { |
578 | messg->setText(i18n("Hangup")); | 577 | messg->setText(QObject::tr("Hangup")); |
579 | emit debugMessage(i18n("Hangup")); | 578 | emit debugMessage(QObject::tr("Hangup")); |
580 | 579 | ||
581 | writeline(_ifaceppp->data()->modemHangupStr()); | 580 | writeline(_ifaceppp->data()->modemHangupStr()); |
582 | setExpect(_ifaceppp->data()->modemHangupResp()); | 581 | setExpect(_ifaceppp->data()->modemHangupResp()); |
583 | 582 | ||
584 | scriptindex++; | 583 | scriptindex++; |
585 | return; | 584 | return; |
586 | } | 585 | } |
587 | 586 | ||
588 | if (scriptCommand == "Answer") { | 587 | if (scriptCommand == "Answer") { |
589 | 588 | ||
590 | timeout_timer->stop(); | 589 | timeout_timer->stop(); |
591 | 590 | ||
592 | messg->setText(i18n("Answer")); | 591 | messg->setText(QObject::tr("Answer")); |
593 | emit debugMessage(i18n("Answer")); | 592 | emit debugMessage(QObject::tr("Answer")); |
594 | 593 | ||
595 | setExpect(_ifaceppp->data()->modemRingResp()); | 594 | setExpect(_ifaceppp->data()->modemRingResp()); |
596 | vmain = 150; | 595 | vmain = 150; |
597 | return; | 596 | return; |
598 | } | 597 | } |
599 | 598 | ||
600 | if (scriptCommand == "ID") { | 599 | if (scriptCommand == "ID") { |
601 | QString bm = i18n("ID %1").arg(scriptArgument); | 600 | QString bm = QObject::tr("ID %1").arg(scriptArgument); |
602 | messg->setText(bm); | 601 | messg->setText(bm); |
603 | emit debugMessage(bm); | 602 | emit debugMessage(bm); |
604 | 603 | ||
605 | QString idstring = _ifaceppp->data()->password(); | 604 | QString idstring = _ifaceppp->data()->password(); |
606 | 605 | ||
607 | if(!idstring.isEmpty() && firstrunID) { | 606 | if(!idstring.isEmpty() && firstrunID) { |
608 | // the user entered an Id on the main kppp dialog | 607 | // the user entered an Id on the main kppp dialog |
609 | writeline(idstring); | 608 | writeline(idstring); |
610 | firstrunID = false; | 609 | firstrunID = false; |
611 | scriptindex++; | 610 | scriptindex++; |
612 | } | 611 | } |
613 | else { | 612 | else { |
@@ -625,25 +624,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
625 | if(!(prompt->isVisible())) { | 624 | if(!(prompt->isVisible())) { |
626 | writeline(prompt->text()); | 625 | writeline(prompt->text()); |
627 | prompt->setConsumed(); | 626 | prompt->setConsumed(); |
628 | scriptindex++; | 627 | scriptindex++; |
629 | return; | 628 | return; |
630 | } | 629 | } |
631 | /* replace timeout value */ | 630 | /* replace timeout value */ |
632 | } | 631 | } |
633 | } | 632 | } |
634 | } | 633 | } |
635 | 634 | ||
636 | if (scriptCommand == "Password") { | 635 | if (scriptCommand == "Password") { |
637 | QString bm = i18n("Password %1").arg(scriptArgument); | 636 | QString bm = QObject::tr("Password %1").arg(scriptArgument); |
638 | messg->setText(bm); | 637 | messg->setText(bm); |
639 | emit debugMessage(bm); | 638 | emit debugMessage(bm); |
640 | 639 | ||
641 | QString pwstring = _ifaceppp->data()->password(); | 640 | QString pwstring = _ifaceppp->data()->password(); |
642 | 641 | ||
643 | if(!pwstring.isEmpty() && firstrunPW) { | 642 | if(!pwstring.isEmpty() && firstrunPW) { |
644 | // the user entered a password on the main kppp dialog | 643 | // the user entered a password on the main kppp dialog |
645 | writeline(pwstring); | 644 | writeline(pwstring); |
646 | firstrunPW = false; | 645 | firstrunPW = false; |
647 | scriptindex++; | 646 | scriptindex++; |
648 | } | 647 | } |
649 | else { | 648 | else { |
@@ -662,25 +661,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
662 | // p_kppp->setPW_Edit(prompt->text()); | 661 | // p_kppp->setPW_Edit(prompt->text()); |
663 | writeline(prompt->text()); | 662 | writeline(prompt->text()); |
664 | prompt->setConsumed(); | 663 | prompt->setConsumed(); |
665 | scriptindex++; | 664 | scriptindex++; |
666 | return; | 665 | return; |
667 | } | 666 | } |
668 | /* replace timeout value */ | 667 | /* replace timeout value */ |
669 | } | 668 | } |
670 | } | 669 | } |
671 | } | 670 | } |
672 | 671 | ||
673 | if (scriptCommand == "Prompt") { | 672 | if (scriptCommand == "Prompt") { |
674 | QString bm = i18n("Prompting %1"); | 673 | QString bm = QObject::tr("Prompting %1"); |
675 | 674 | ||
676 | // if the scriptindex (aka the prompt text) includes a ## marker | 675 | // if the scriptindex (aka the prompt text) includes a ## marker |
677 | // this marker should get substituted with the contents of our stored | 676 | // this marker should get substituted with the contents of our stored |
678 | // variable (from the subsequent scan). | 677 | // variable (from the subsequent scan). |
679 | 678 | ||
680 | QString ts = scriptArgument; | 679 | QString ts = scriptArgument; |
681 | int vstart = ts.find( "##" ); | 680 | int vstart = ts.find( "##" ); |
682 | if( vstart != -1 ) { | 681 | if( vstart != -1 ) { |
683 | ts.remove( vstart, 2 ); | 682 | ts.remove( vstart, 2 ); |
684 | ts.insert( vstart, scanvar ); | 683 | ts.insert( vstart, scanvar ); |
685 | } | 684 | } |
686 | 685 | ||
@@ -699,77 +698,77 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
699 | /* if prompt withdrawn ... then, */ | 698 | /* if prompt withdrawn ... then, */ |
700 | if (!(prompt->isVisible())) { | 699 | if (!(prompt->isVisible())) { |
701 | writeline(prompt->text()); | 700 | writeline(prompt->text()); |
702 | prompt->setConsumed(); | 701 | prompt->setConsumed(); |
703 | scriptindex++; | 702 | scriptindex++; |
704 | return; | 703 | return; |
705 | } | 704 | } |
706 | /* replace timeout value */ | 705 | /* replace timeout value */ |
707 | } | 706 | } |
708 | } | 707 | } |
709 | 708 | ||
710 | if (scriptCommand == "PWPrompt") { | 709 | if (scriptCommand == "PWPrompt") { |
711 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); | 710 | QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); |
712 | messg->setText(bm); | 711 | messg->setText(bm); |
713 | emit debugMessage(bm); | 712 | emit debugMessage(bm); |
714 | 713 | ||
715 | /* if not around yet, then post window... */ | 714 | /* if not around yet, then post window... */ |
716 | if (prompt->Consumed()) { | 715 | if (prompt->Consumed()) { |
717 | if (!(prompt->isVisible())) { | 716 | if (!(prompt->isVisible())) { |
718 | prompt->setPrompt(scriptArgument); | 717 | prompt->setPrompt(scriptArgument); |
719 | prompt->setEchoModePassword(); | 718 | prompt->setEchoModePassword(); |
720 | prompt->show(); | 719 | prompt->show(); |
721 | } | 720 | } |
722 | } else { | 721 | } else { |
723 | /* if prompt withdrawn ... then, */ | 722 | /* if prompt withdrawn ... then, */ |
724 | if (!(prompt->isVisible())) { | 723 | if (!(prompt->isVisible())) { |
725 | writeline(prompt->text()); | 724 | writeline(prompt->text()); |
726 | prompt->setConsumed(); | 725 | prompt->setConsumed(); |
727 | scriptindex++; | 726 | scriptindex++; |
728 | return; | 727 | return; |
729 | } | 728 | } |
730 | /* replace timeout value */ | 729 | /* replace timeout value */ |
731 | } | 730 | } |
732 | } | 731 | } |
733 | 732 | ||
734 | if (scriptCommand == "LoopStart") { | 733 | if (scriptCommand == "LoopStart") { |
735 | 734 | ||
736 | QString bm = i18n("Loop Start %1").arg(scriptArgument); | 735 | QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); |
737 | 736 | ||
738 | // The incrementing of the scriptindex MUST be before the | 737 | // The incrementing of the scriptindex MUST be before the |
739 | // call to setExpect otherwise the expect will miss a string that is | 738 | // call to setExpect otherwise the expect will miss a string that is |
740 | // already in the buffer. | 739 | // already in the buffer. |
741 | scriptindex++; | 740 | scriptindex++; |
742 | 741 | ||
743 | if ( loopnest > (MAXLOOPNEST-2) ) { | 742 | if ( loopnest > (MAXLOOPNEST-2) ) { |
744 | bm += i18n("ERROR: Nested too deep, ignored."); | 743 | bm += QObject::tr("ERROR: Nested too deep, ignored."); |
745 | vmain=20; | 744 | vmain=20; |
746 | cancelbutton(); | 745 | cancelbutton(); |
747 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); | 746 | QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); |
748 | } else { | 747 | } else { |
749 | setExpect(scriptArgument); | 748 | setExpect(scriptArgument); |
750 | loopstartindex[loopnest] = scriptindex; | 749 | loopstartindex[loopnest] = scriptindex; |
751 | loopstr[loopnest] = scriptArgument; | 750 | loopstr[loopnest] = scriptArgument; |
752 | loopend = false; | 751 | loopend = false; |
753 | loopnest++; | 752 | loopnest++; |
754 | } | 753 | } |
755 | messg->setText(bm); | 754 | messg->setText(bm); |
756 | emit debugMessage(bm); | 755 | emit debugMessage(bm); |
757 | 756 | ||
758 | } | 757 | } |
759 | 758 | ||
760 | if (scriptCommand == "LoopEnd") { | 759 | if (scriptCommand == "LoopEnd") { |
761 | QString bm = i18n("Loop End %1").arg(scriptArgument); | 760 | QString bm = QObject::tr("Loop End %1").arg(scriptArgument); |
762 | if ( loopnest <= 0 ) { | 761 | if ( loopnest <= 0 ) { |
763 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); | 762 | bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); |
764 | vmain=20; | 763 | vmain=20; |
765 | cancelbutton(); | 764 | cancelbutton(); |
766 | QMessageBox::critical(0, "error", bm); | 765 | QMessageBox::critical(0, "error", bm); |
767 | return; | 766 | return; |
768 | } else { | 767 | } else { |
769 | // NB! The incrementing of the scriptindex MUST be before the | 768 | // NB! The incrementing of the scriptindex MUST be before the |
770 | // call to setExpect otherwise the expect will miss a string | 769 | // call to setExpect otherwise the expect will miss a string |
771 | // that is already in the buffer. | 770 | // that is already in the buffer. |
772 | scriptindex++; | 771 | scriptindex++; |
773 | setExpect(scriptArgument); | 772 | setExpect(scriptArgument); |
774 | loopnest--; | 773 | loopnest--; |
775 | loopend = true; | 774 | loopend = true; |
@@ -839,25 +838,25 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
839 | killTimer( main_timer_ID ); | 838 | killTimer( main_timer_ID ); |
840 | 839 | ||
841 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 840 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
842 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 841 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
843 | 842 | ||
844 | // find out PPP interface and notify the stats module | 843 | // find out PPP interface and notify the stats module |
845 | // stats->setUnit(pppInterfaceNumber()); | 844 | // stats->setUnit(pppInterfaceNumber()); |
846 | 845 | ||
847 | qApp->flushX(); | 846 | qApp->flushX(); |
848 | semaphore = true; | 847 | semaphore = true; |
849 | result = execppp(); | 848 | result = execppp(); |
850 | 849 | ||
851 | emit debugMessage(i18n("Starting pppd...")); | 850 | emit debugMessage(QObject::tr("Starting pppd...")); |
852 | qDebug("execppp() returned with return-code %i", result ); | 851 | qDebug("execppp() returned with return-code %i", result ); |
853 | 852 | ||
854 | if(result) { | 853 | if(result) { |
855 | if(!_ifaceppp->data()->autoDNS()) | 854 | if(!_ifaceppp->data()->autoDNS()) |
856 | adddns( _ifaceppp ); | 855 | adddns( _ifaceppp ); |
857 | 856 | ||
858 | // O.K we are done here, let's change over to the if_waiting loop | 857 | // O.K we are done here, let's change over to the if_waiting loop |
859 | // where we wait for the ppp if (interface) to come up. | 858 | // where we wait for the ppp if (interface) to come up. |
860 | 859 | ||
861 | emit if_waiting_signal(); | 860 | emit if_waiting_signal(); |
862 | } else { | 861 | } else { |
863 | 862 | ||
@@ -921,46 +920,46 @@ void ConnectWidget::checkBuffers() { | |||
921 | // Let's check if we are finished with scanning: | 920 | // Let's check if we are finished with scanning: |
922 | // The scanstring have to be in the buffer and the latest character | 921 | // The scanstring have to be in the buffer and the latest character |
923 | // was a carriage return or an linefeed (depending on modem setup) | 922 | // was a carriage return or an linefeed (depending on modem setup) |
924 | if( scanning && scanbuffer.contains(scanstr) && | 923 | if( scanning && scanbuffer.contains(scanstr) && |
925 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 924 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
926 | scanning = false; | 925 | scanning = false; |
927 | 926 | ||
928 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 927 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
929 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 928 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
930 | scanvar = scanvar.stripWhiteSpace(); | 929 | scanvar = scanvar.stripWhiteSpace(); |
931 | 930 | ||
932 | // Show the Variabel content in the debug window | 931 | // Show the Variabel content in the debug window |
933 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 932 | QString sv = QObject::tr("Scan Var: %1").arg(scanvar); |
934 | emit debugMessage(sv); | 933 | emit debugMessage(sv); |
935 | } | 934 | } |
936 | 935 | ||
937 | if(expecting) { | 936 | if(expecting) { |
938 | if(readbuffer.contains(expectstr)) { | 937 | if(readbuffer.contains(expectstr)) { |
939 | expecting = false; | 938 | expecting = false; |
940 | // keep everything after the expected string | 939 | // keep everything after the expected string |
941 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 940 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
942 | 941 | ||
943 | QString ts = i18n("Found: %1").arg(expectstr); | 942 | QString ts = QObject::tr("Found: %1").arg(expectstr); |
944 | emit debugMessage(ts); | 943 | emit debugMessage(ts); |
945 | 944 | ||
946 | if (loopend) { | 945 | if (loopend) { |
947 | loopend=false; | 946 | loopend=false; |
948 | } | 947 | } |
949 | } | 948 | } |
950 | 949 | ||
951 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 950 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
952 | expecting = false; | 951 | expecting = false; |
953 | readbuffer = ""; | 952 | readbuffer = ""; |
954 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 953 | QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); |
955 | emit debugMessage(ts); | 954 | emit debugMessage(ts); |
956 | scriptindex = loopstartindex[loopnest]; | 955 | scriptindex = loopstartindex[loopnest]; |
957 | loopend = false; | 956 | loopend = false; |
958 | loopnest++; | 957 | loopnest++; |
959 | } | 958 | } |
960 | // notify event loop if expected string was found | 959 | // notify event loop if expected string was found |
961 | if(!expecting) | 960 | if(!expecting) |
962 | timerEvent((QTimerEvent *) 0); | 961 | timerEvent((QTimerEvent *) 0); |
963 | } | 962 | } |
964 | } | 963 | } |
965 | 964 | ||
966 | 965 | ||
@@ -975,25 +974,25 @@ void ConnectWidget::cancelbutton() { | |||
975 | _ifaceppp->modem()->stop(); | 974 | _ifaceppp->modem()->stop(); |
976 | killTimer(main_timer_ID); | 975 | killTimer(main_timer_ID); |
977 | timeout_timer->stop(); | 976 | timeout_timer->stop(); |
978 | if_timer->stop(); | 977 | if_timer->stop(); |
979 | if_timeout_timer->stop(); | 978 | if_timeout_timer->stop(); |
980 | 979 | ||
981 | // if (termwindow) { | 980 | // if (termwindow) { |
982 | // delete termwindow; | 981 | // delete termwindow; |
983 | // termwindow = 0L; | 982 | // termwindow = 0L; |
984 | // this->show(); | 983 | // this->show(); |
985 | // } | 984 | // } |
986 | 985 | ||
987 | messg->setText(i18n("One moment please...")); | 986 | messg->setText(QObject::tr("One moment please...")); |
988 | 987 | ||
989 | // just to be sure | 988 | // just to be sure |
990 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 989 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
991 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 990 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
992 | removedns(_ifaceppp); | 991 | removedns(_ifaceppp); |
993 | 992 | ||
994 | qApp->processEvents(); | 993 | qApp->processEvents(); |
995 | 994 | ||
996 | _ifaceppp->modem()->killPPPDaemon(); | 995 | _ifaceppp->modem()->killPPPDaemon(); |
997 | _ifaceppp->modem()->hangup(); | 996 | _ifaceppp->modem()->hangup(); |
998 | 997 | ||
999 | 998 | ||
@@ -1001,65 +1000,68 @@ void ConnectWidget::cancelbutton() { | |||
1001 | // p_kppp->show(); | 1000 | // p_kppp->show(); |
1002 | // emit stopAccounting();// just to be sure | 1001 | // emit stopAccounting();// just to be sure |
1003 | // p_kppp->con_win->stopClock(); | 1002 | // p_kppp->con_win->stopClock(); |
1004 | _ifaceppp->modem()->closetty(); | 1003 | _ifaceppp->modem()->closetty(); |
1005 | _ifaceppp->modem()->unlockdevice(); | 1004 | _ifaceppp->modem()->unlockdevice(); |
1006 | 1005 | ||
1007 | //abort prompt window... | 1006 | //abort prompt window... |
1008 | if (prompt->isVisible()) { | 1007 | if (prompt->isVisible()) { |
1009 | prompt->hide(); | 1008 | prompt->hide(); |
1010 | } | 1009 | } |
1011 | prompt->setConsumed(); | 1010 | prompt->setConsumed(); |
1012 | 1011 | ||
1013 | messg->setText(tr("offline")); | 1012 | _ifaceppp->setStatus( false ); |
1013 | _ifaceppp->refresh(); | ||
1014 | // messg->setText(tr("offline")); | ||
1015 | refresh(); | ||
1014 | } | 1016 | } |
1015 | 1017 | ||
1016 | 1018 | ||
1017 | void ConnectWidget::script_timed_out() { | 1019 | void ConnectWidget::script_timed_out() { |
1018 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1020 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1019 | timeout_timer->stop(); | 1021 | timeout_timer->stop(); |
1020 | emit stopAccounting(); | 1022 | emit stopAccounting(); |
1021 | // p_kppp->con_win->stopClock(); | 1023 | // p_kppp->con_win->stopClock(); |
1022 | return; | 1024 | return; |
1023 | } | 1025 | } |
1024 | 1026 | ||
1025 | if (prompt->isVisible()) | 1027 | if (prompt->isVisible()) |
1026 | prompt->hide(); | 1028 | prompt->hide(); |
1027 | 1029 | ||
1028 | prompt->setConsumed(); | 1030 | prompt->setConsumed(); |
1029 | messg->setText(i18n("Script timed out!")); | 1031 | messg->setText(QObject::tr("Script timed out!")); |
1030 | _ifaceppp->modem()->hangup(); | 1032 | _ifaceppp->modem()->hangup(); |
1031 | emit stopAccounting(); | 1033 | emit stopAccounting(); |
1032 | // p_kppp->con_win->stopClock(); | 1034 | // p_kppp->con_win->stopClock(); |
1033 | 1035 | ||
1034 | vmain = 0; // let's try again. | 1036 | vmain = 0; // let's try again. |
1035 | substate = -1; | 1037 | substate = -1; |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | 1040 | ||
1039 | void ConnectWidget::setScan(const QString &n) { | 1041 | void ConnectWidget::setScan(const QString &n) { |
1040 | scanning = true; | 1042 | scanning = true; |
1041 | scanstr = n; | 1043 | scanstr = n; |
1042 | scanbuffer = ""; | 1044 | scanbuffer = ""; |
1043 | 1045 | ||
1044 | QString ts = i18n("Scanning: %1").arg(n); | 1046 | QString ts = QObject::tr("Scanning: %1").arg(n); |
1045 | emit debugMessage(ts); | 1047 | emit debugMessage(ts); |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | 1050 | ||
1049 | void ConnectWidget::setExpect(const QString &n) { | 1051 | void ConnectWidget::setExpect(const QString &n) { |
1050 | expecting = true; | 1052 | expecting = true; |
1051 | expectstr = n; | 1053 | expectstr = n; |
1052 | 1054 | ||
1053 | QString ts = i18n("Expecting: %1").arg(n); | 1055 | QString ts = QObject::tr("Expecting: %1").arg(n); |
1054 | ts.replace(QRegExp("\n"), "<LF>"); | 1056 | ts.replace(QRegExp("\n"), "<LF>"); |
1055 | emit debugMessage(ts); | 1057 | emit debugMessage(ts); |
1056 | 1058 | ||
1057 | // check if the expected string is in the read buffer already. | 1059 | // check if the expected string is in the read buffer already. |
1058 | checkBuffers(); | 1060 | checkBuffers(); |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | 1063 | ||
1062 | void ConnectWidget::if_waiting_timed_out() { | 1064 | void ConnectWidget::if_waiting_timed_out() { |
1063 | if_timer->stop(); | 1065 | if_timer->stop(); |
1064 | if_timeout_timer->stop(); | 1066 | if_timeout_timer->stop(); |
1065 | qDebug("if_waiting_timed_out()"); | 1067 | qDebug("if_waiting_timed_out()"); |
@@ -1076,25 +1078,25 @@ void ConnectWidget::if_waiting_timed_out() { | |||
1076 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1078 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1077 | // in main.cpp what happens next will depend on the boolean | 1079 | // in main.cpp what happens next will depend on the boolean |
1078 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1080 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1079 | } | 1081 | } |
1080 | 1082 | ||
1081 | void ConnectWidget::pppdDied() | 1083 | void ConnectWidget::pppdDied() |
1082 | { | 1084 | { |
1083 | if_timer->stop(); | 1085 | if_timer->stop(); |
1084 | if_timeout_timer->stop(); | 1086 | if_timeout_timer->stop(); |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | void ConnectWidget::if_waiting_slot() { | 1089 | void ConnectWidget::if_waiting_slot() { |
1088 | messg->setText(i18n("Logging on to network...")); | 1090 | messg->setText(QObject::tr("Logging on to network...")); |
1089 | 1091 | ||
1090 | // if(!stats->ifIsUp()) { | 1092 | // if(!stats->ifIsUp()) { |
1091 | 1093 | ||
1092 | // if(_ifaceppp->data()->pppdError() != 0) { | 1094 | // if(_ifaceppp->data()->pppdError() != 0) { |
1093 | // // we are here if pppd died immediately after starting it. | 1095 | // // we are here if pppd died immediately after starting it. |
1094 | // pppdDied(); | 1096 | // pppdDied(); |
1095 | // // error message handled in main.cpp: sigPPPDDied() | 1097 | // // error message handled in main.cpp: sigPPPDDied() |
1096 | // return; | 1098 | // return; |
1097 | // } | 1099 | // } |
1098 | 1100 | ||
1099 | // if_timer->start(100, TRUE); // single shot | 1101 | // if_timer->start(100, TRUE); // single shot |
1100 | // return; | 1102 | // return; |
@@ -1107,44 +1109,49 @@ void ConnectWidget::if_waiting_slot() { | |||
1107 | usleep(200000); | 1109 | usleep(200000); |
1108 | 1110 | ||
1109 | if(_ifaceppp->data()->autoDNS()) | 1111 | if(_ifaceppp->data()->autoDNS()) |
1110 | addpeerdns( _ifaceppp ); | 1112 | addpeerdns( _ifaceppp ); |
1111 | 1113 | ||
1112 | // Close the debugging window. If we are connected, we | 1114 | // Close the debugging window. If we are connected, we |
1113 | // are not really interested in debug output | 1115 | // are not really interested in debug output |
1114 | emit closeDebugWindow(); | 1116 | emit closeDebugWindow(); |
1115 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1117 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1116 | auto_hostname(_ifaceppp); | 1118 | auto_hostname(_ifaceppp); |
1117 | 1119 | ||
1118 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1120 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1119 | messg->setText(i18n("Running startup command...")); | 1121 | messg->setText(QObject::tr("Running startup command...")); |
1120 | 1122 | ||
1121 | // make sure that we don't get any async errors | 1123 | // make sure that we don't get any async errors |
1122 | qApp->flushX(); | 1124 | qApp->flushX(); |
1123 | execute_command(_ifaceppp->data()->command_on_connect()); | 1125 | execute_command(_ifaceppp->data()->command_on_connect()); |
1124 | messg->setText(i18n("Done")); | 1126 | messg->setText(QObject::tr("Done")); |
1125 | } | 1127 | } |
1126 | 1128 | ||
1127 | // remove the authentication file | 1129 | // remove the authentication file |
1128 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1130 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1129 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1131 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1130 | 1132 | ||
1131 | emit debugMessage(i18n("Done")); | 1133 | emit debugMessage(QObject::tr("Done")); |
1132 | set_con_speed_string(); | 1134 | set_con_speed_string(); |
1133 | 1135 | ||
1134 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1136 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1135 | this->hide(); | 1137 | // this->hide(); |
1136 | messg->setText(""); | 1138 | // messg->setText(""); |
1137 | 1139 | ||
1138 | _ifaceppp->setStatus( true ); | 1140 | _ifaceppp->setStatus( true ); |
1141 | |||
1142 | m_refreshTimer = new QTimer( this ); | ||
1143 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
1144 | m_refreshTimer->start( 3000 ); | ||
1145 | //_ifaceppp->refresh(); | ||
1139 | // emit _ifaceppp->updateInterface(_ifaceppp); | 1146 | // emit _ifaceppp->updateInterface(_ifaceppp); |
1140 | 1147 | ||
1141 | // prepare the con_win so as to have the right size for | 1148 | // prepare the con_win so as to have the right size for |
1142 | // accounting / non-accounting mode | 1149 | // accounting / non-accounting mode |
1143 | // if(p_kppp->acct != 0) | 1150 | // if(p_kppp->acct != 0) |
1144 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1151 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1145 | // else | 1152 | // else |
1146 | // p_kppp->con_win->accounting(false); | 1153 | // p_kppp->con_win->accounting(false); |
1147 | 1154 | ||
1148 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1155 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1149 | // // DockWidget::dock_widget->show(); | 1156 | // // DockWidget::dock_widget->show(); |
1150 | // // DockWidget::dock_widget->take_stats(); | 1157 | // // DockWidget::dock_widget->take_stats(); |
@@ -1152,24 +1159,33 @@ void ConnectWidget::if_waiting_slot() { | |||
1152 | // } | 1159 | // } |
1153 | // else { | 1160 | // else { |
1154 | // // p_kppp->con_win->show(); | 1161 | // // p_kppp->con_win->show(); |
1155 | 1162 | ||
1156 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1163 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1157 | // // p_kppp->con_win->showMinimized(); | 1164 | // // p_kppp->con_win->showMinimized(); |
1158 | // } | 1165 | // } |
1159 | // } | 1166 | // } |
1160 | 1167 | ||
1161 | _ifaceppp->modem()->closetty(); | 1168 | _ifaceppp->modem()->closetty(); |
1162 | } | 1169 | } |
1163 | 1170 | ||
1171 | void ConnectWidget::refresh() { | ||
1172 | _ifaceppp->refresh(); | ||
1173 | if ( _ifaceppp->getStatus() ) { | ||
1174 | messg->setText(QObject::tr("Online")); | ||
1175 | } else { | ||
1176 | messg->setText(QObject::tr("Offline")); | ||
1177 | } | ||
1178 | } | ||
1179 | |||
1164 | 1180 | ||
1165 | bool ConnectWidget::execppp() { | 1181 | bool ConnectWidget::execppp() { |
1166 | QString command; | 1182 | QString command; |
1167 | 1183 | ||
1168 | command = "pppd"; | 1184 | command = "pppd"; |
1169 | 1185 | ||
1170 | // as of version 2.3.6 pppd falls back to the real user rights when | 1186 | // as of version 2.3.6 pppd falls back to the real user rights when |
1171 | // opening a device given in a command line. To avoid permission conflicts | 1187 | // opening a device given in a command line. To avoid permission conflicts |
1172 | // we'll simply leave this argument away. pppd will then use the default tty | 1188 | // we'll simply leave this argument away. pppd will then use the default tty |
1173 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1189 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1174 | // command += " "; | 1190 | // command += " "; |
1175 | // command += _ifaceppp->data()->modemDevice(); | 1191 | // command += _ifaceppp->data()->modemDevice(); |
@@ -1201,63 +1217,71 @@ bool ConnectWidget::execppp() { | |||
1201 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1217 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1202 | command += " crtscts"; | 1218 | command += " crtscts"; |
1203 | else | 1219 | else |
1204 | command += " xonxoff"; | 1220 | command += " xonxoff"; |
1205 | } | 1221 | } |
1206 | 1222 | ||
1207 | if(_ifaceppp->data()->defaultroute()) | 1223 | if(_ifaceppp->data()->defaultroute()) |
1208 | command += " defaultroute"; | 1224 | command += " defaultroute"; |
1209 | 1225 | ||
1210 | if(_ifaceppp->data()->autoDNS()) | 1226 | if(_ifaceppp->data()->autoDNS()) |
1211 | command += " usepeerdns"; | 1227 | command += " usepeerdns"; |
1212 | 1228 | ||
1213 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1214 | for ( QStringList::Iterator it = arglist.begin(); | ||
1215 | it != arglist.end(); | ||
1216 | ++it ) | ||
1217 | { | ||
1218 | command += " " + *it; | ||
1219 | } | ||
1220 | 1229 | ||
1221 | // PAP settings | 1230 | // PAP settings |
1222 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { | 1231 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1223 | command += " -chap user "; | 1232 | command += " -chap user "; |
1224 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1233 | command = command + _ifaceppp->data()->storedUsername(); |
1225 | } | 1234 | } |
1226 | 1235 | ||
1227 | // CHAP settings | 1236 | // CHAP settings |
1228 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { | 1237 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1229 | command += " -pap user "; | 1238 | command += " -pap user "; |
1230 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1239 | command = command + _ifaceppp->data()->storedUsername(); |
1231 | } | 1240 | } |
1232 | 1241 | ||
1233 | // PAP/CHAP settings | 1242 | // PAP/CHAP settings |
1234 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { | 1243 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1244 | QString tmpName = _ifaceppp->data()->storedUsername(); | ||
1245 | if ( !tmpName.isEmpty() ) { | ||
1235 | command += " user "; | 1246 | command += " user "; |
1236 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1247 | command = command + tmpName; |
1248 | } | ||
1237 | } | 1249 | } |
1238 | 1250 | ||
1239 | // check for debug | 1251 | // check for debug |
1240 | if(_ifaceppp->data()->getPPPDebug()) | 1252 | if(_ifaceppp->data()->getPPPDebug()) |
1241 | command += " debug"; | 1253 | command += " debug"; |
1242 | 1254 | ||
1255 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1256 | for ( QStringList::Iterator it = arglist.begin(); | ||
1257 | it != arglist.end(); | ||
1258 | ++it ) | ||
1259 | { | ||
1260 | command += " " + *it; | ||
1261 | } | ||
1262 | |||
1263 | command += " call opie-kppp logfd 11"; | ||
1264 | |||
1243 | if (command.length() > MAX_CMDLEN) { | 1265 | if (command.length() > MAX_CMDLEN) { |
1244 | QMessageBox::critical(this, "error", i18n( | 1266 | QMessageBox::critical(this, "error", QObject::tr( |
1245 | "pppd command + command-line arguments exceed " | 1267 | "pppd command + command-line arguments exceed " |
1246 | "2024 characters in length." | 1268 | "2024 characters in length." |
1247 | )); | 1269 | )); |
1248 | 1270 | ||
1249 | return false; // nonsensically long command which would bust my buffer buf. | 1271 | return false; // nonsensically long command which would bust my buffer buf. |
1250 | } | 1272 | } |
1251 | 1273 | ||
1274 | qWarning("Command IS: %s",command.latin1() ); | ||
1275 | |||
1252 | qApp->flushX(); | 1276 | qApp->flushX(); |
1253 | 1277 | ||
1254 | return _ifaceppp->modem()->execPPPDaemon(command); | 1278 | return _ifaceppp->modem()->execPPPDaemon(command); |
1255 | } | 1279 | } |
1256 | 1280 | ||
1257 | 1281 | ||
1258 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1282 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1259 | e->ignore(); | 1283 | e->ignore(); |
1260 | emit cancelbutton(); | 1284 | emit cancelbutton(); |
1261 | } | 1285 | } |
1262 | 1286 | ||
1263 | 1287 | ||
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h index e7ae5e0..b225ff5 100644 --- a/noncore/settings/networksettings/ppp/connect.h +++ b/noncore/settings/networksettings/ppp/connect.h | |||
@@ -53,24 +53,25 @@ 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 | void refresh(); | ||
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | void init(); | 68 | void init(); |
68 | void preinit(); | 69 | void preinit(); |
69 | void script_timed_out(); | 70 | void script_timed_out(); |
70 | void if_waiting_timed_out(); | 71 | void if_waiting_timed_out(); |
71 | void cancelbutton(); | 72 | void cancelbutton(); |
72 | 73 | ||
73 | signals: | 74 | signals: |
74 | void if_waiting_signal(); | 75 | void if_waiting_signal(); |
75 | void debugMessage(const QString &); | 76 | void debugMessage(const QString &); |
76 | void toggleDebugWindow(); | 77 | void toggleDebugWindow(); |
@@ -118,24 +119,25 @@ private: | |||
118 | QString scanstr; | 119 | QString scanstr; |
119 | QString scanbuffer; | 120 | QString scanbuffer; |
120 | bool scanning; | 121 | bool scanning; |
121 | 122 | ||
122 | bool pausing; | 123 | bool pausing; |
123 | PWEntry *prompt; | 124 | PWEntry *prompt; |
124 | // LoginTerm *termwindow; | 125 | // LoginTerm *termwindow; |
125 | 126 | ||
126 | int scriptTimeout; | 127 | int scriptTimeout; |
127 | QTimer *pausetimer; | 128 | QTimer *pausetimer; |
128 | QTimer *if_timer; | 129 | QTimer *if_timer; |
129 | QTimer *if_timeout_timer; | 130 | QTimer *if_timeout_timer; |
131 | QTimer *m_refreshTimer; | ||
130 | 132 | ||
131 | QLabel *messg; | 133 | QLabel *messg; |
132 | QPushButton *cancel; | 134 | QPushButton *cancel; |
133 | 135 | ||
134 | bool firstrunID; | 136 | bool firstrunID; |
135 | bool firstrunPW; | 137 | bool firstrunPW; |
136 | 138 | ||
137 | unsigned int dialnumber; // the current number to dial | 139 | unsigned int dialnumber; // the current number to dial |
138 | 140 | ||
139 | InterfacePPP *_ifaceppp; | 141 | InterfacePPP *_ifaceppp; |
140 | }; | 142 | }; |
141 | 143 | ||
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp index 9136ca0..7641bbe 100644 --- a/noncore/settings/networksettings/ppp/conwindow.cpp +++ b/noncore/settings/networksettings/ppp/conwindow.cpp | |||
@@ -15,65 +15,60 @@ | |||
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" | ||
28 | #include "pppdata.h" | 27 | #include "pppdata.h" |
29 | // #include "pppstats.h" | ||
30 | // #include <klocale.h> | ||
31 | #define i18n QObject::tr | ||
32 | // #include <kglobal.h> | ||
33 | 28 | ||
34 | 29 | ||
35 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, | 30 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, |
36 | QDialog *mainwidget ) | 31 | QDialog *mainwidget ) |
37 | : QWidget(parent, name, 0), | 32 | : QWidget(parent, name, 0), |
38 | minutes(0), | 33 | minutes(0), |
39 | seconds(0), | 34 | seconds(0), |
40 | hours(0), | 35 | hours(0), |
41 | days(0), | 36 | days(0), |
42 | tl1(0), | 37 | tl1(0), |
43 | _pppdata(pd) | 38 | _pppdata(pd) |
44 | { | 39 | { |
45 | info1 = new QLabel(i18n("Connected at:"), this); | 40 | info1 = new QLabel(QObject::tr("Connected at:"), this); |
46 | info2 = new QLabel("", this); | 41 | info2 = new QLabel("", this); |
47 | 42 | ||
48 | timelabel1 = new QLabel(i18n("Time connected:"), this); | 43 | timelabel1 = new QLabel(QObject::tr("Time connected:"), this); |
49 | timelabel2 = new QLabel("000:00:00", this); | 44 | timelabel2 = new QLabel("000:00:00", this); |
50 | 45 | ||
51 | vollabel = new QLabel(i18n("Volume:"), this); | 46 | vollabel = new QLabel(QObject::tr("Volume:"), this); |
52 | volinfo = new QLabel("", this); | 47 | volinfo = new QLabel("", this); |
53 | 48 | ||
54 | // now the stuff for accounting | 49 | // now the stuff for accounting |
55 | session_bill_l = new QLabel(i18n("Session Bill:"), this); | 50 | session_bill_l = new QLabel(QObject::tr("Session Bill:"), this); |
56 | session_bill = new QLabel("", this); | 51 | session_bill = new QLabel("", this); |
57 | total_bill_l = new QLabel(i18n("Total Bill:"), this); | 52 | total_bill_l = new QLabel(QObject::tr("Total Bill:"), this); |
58 | total_bill = new QLabel("", this); | 53 | total_bill = new QLabel("", this); |
59 | 54 | ||
60 | this->setCaption("kppp"); | 55 | this->setCaption("kppp"); |
61 | 56 | ||
62 | cancelbutton = new QPushButton(this); | 57 | cancelbutton = new QPushButton(this); |
63 | cancelbutton->setText(i18n("Disconnect")); | 58 | cancelbutton->setText(QObject::tr("Disconnect")); |
64 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); | 59 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); |
65 | 60 | ||
66 | // statsbutton = new QPushButton(this); | 61 | // statsbutton = new QPushButton(this); |
67 | // statsbutton->setText(i18n("Details")); | 62 | // statsbutton->setText(QObject::tr("Details")); |
68 | // statsbutton->setFocus(); | 63 | // statsbutton->setFocus(); |
69 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); | 64 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); |
70 | 65 | ||
71 | clocktimer = new QTimer(this); | 66 | clocktimer = new QTimer(this); |
72 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); | 67 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); |
73 | 68 | ||
74 | // read window position from config file | 69 | // read window position from config file |
75 | // int p_x, p_y; | 70 | // int p_x, p_y; |
76 | // PPPData::data()->winPosConWin(p_x, p_y); | 71 | // PPPData::data()->winPosConWin(p_x, p_y); |
77 | // setGeometry(p_x, p_y, 320, 110); | 72 | // setGeometry(p_x, p_y, 320, 110); |
78 | } | 73 | } |
79 | 74 | ||
@@ -85,26 +80,26 @@ ConWindow::~ConWindow() { | |||
85 | bool ConWindow::event(QEvent *e) { | 80 | bool ConWindow::event(QEvent *e) { |
86 | if (e->type() == QEvent::Hide) | 81 | if (e->type() == QEvent::Hide) |
87 | { | 82 | { |
88 | // PPPData::data()->setWinPosConWin(x(), y()); | 83 | // PPPData::data()->setWinPosConWin(x(), y()); |
89 | return true; | 84 | return true; |
90 | } | 85 | } |
91 | else | 86 | else |
92 | return QWidget::event(e); | 87 | return QWidget::event(e); |
93 | } | 88 | } |
94 | 89 | ||
95 | QString ConWindow::prettyPrintVolume(unsigned int n) { | 90 | QString ConWindow::prettyPrintVolume(unsigned int n) { |
96 | int idx = 0; | 91 | int idx = 0; |
97 | const QString quant[] = {i18n("Byte"), i18n("KB"), | 92 | const QString quant[] = {QObject::tr("Byte"), QObject::tr("KB"), |
98 | i18n("MB"), i18n("GB"), QString::null}; | 93 | QObject::tr("MB"), QObject::tr("GB"), QString::null}; |
99 | 94 | ||
100 | float n1 = n; | 95 | float n1 = n; |
101 | while(n >= 1024 && quant[idx] != QString::null) { | 96 | while(n >= 1024 && quant[idx] != QString::null) { |
102 | idx++; | 97 | idx++; |
103 | n /= 1024; | 98 | n /= 1024; |
104 | } | 99 | } |
105 | 100 | ||
106 | int i = idx; | 101 | int i = idx; |
107 | while(i--) | 102 | while(i--) |
108 | n1 = n1 / 1024.0; | 103 | n1 = n1 / 1024.0; |
109 | 104 | ||
110 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); | 105 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); |
@@ -250,32 +245,32 @@ void ConWindow::startClock() { | |||
250 | 245 | ||
251 | void ConWindow::setConnectionSpeed(const QString &speed) { | 246 | void ConWindow::setConnectionSpeed(const QString &speed) { |
252 | info2->setText(speed); | 247 | info2->setText(speed); |
253 | } | 248 | } |
254 | 249 | ||
255 | 250 | ||
256 | void ConWindow::stopClock() { | 251 | void ConWindow::stopClock() { |
257 | clocktimer->stop(); | 252 | clocktimer->stop(); |
258 | } | 253 | } |
259 | 254 | ||
260 | 255 | ||
261 | void ConWindow::timeclick() { | 256 | void ConWindow::timeclick() { |
262 | // QString tooltip = i18n("Connection: %1\n" | 257 | // QString tooltip = QObject::tr("Connection: %1\n" |
263 | // "Connected at: %2\n" | 258 | // "Connected at: %2\n" |
264 | // "Time connected: %3") | 259 | // "Time connected: %3") |
265 | // .arg(_pppdata->accname()).arg(info2->text()) | 260 | // .arg(_pppdata->accname()).arg(info2->text()) |
266 | // .arg(time_string2); | 261 | // .arg(time_string2); |
267 | 262 | ||
268 | // if(accountingEnabled) | 263 | // if(accountingEnabled) |
269 | // tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") | 264 | // tooltip += QObject::tr("\nSession Bill: %1\nTotal Bill: %2") |
270 | // .arg(session_bill->text()).arg(total_bill->text()); | 265 | // .arg(session_bill->text()).arg(total_bill->text()); |
271 | // // volume accounting | 266 | // // volume accounting |
272 | // if(volumeAccountingEnabled) { | 267 | // if(volumeAccountingEnabled) { |
273 | 268 | ||
274 | // volinfo->setEnabled(TRUE); | 269 | // volinfo->setEnabled(TRUE); |
275 | // int bytes = _pppdata->totalBytes(); | 270 | // int bytes = _pppdata->totalBytes(); |
276 | // volinfo->setText(prettyPrintVolume(bytes)); | 271 | // volinfo->setText(prettyPrintVolume(bytes)); |
277 | // } | 272 | // } |
278 | 273 | ||
279 | // seconds++; | 274 | // seconds++; |
280 | 275 | ||
281 | // if(seconds >= 60 ) { | 276 | // if(seconds >= 60 ) { |
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp new file mode 100644 index 0000000..e94904b --- a/dev/null +++ b/noncore/settings/networksettings/ppp/devices.cpp | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qdir.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qtabwidget.h> | ||
31 | #include <qtabdialog.h> | ||
32 | #include <qwhatsthis.h> | ||
33 | #include <qmessagebox.h> | ||
34 | |||
35 | #include <qapplication.h> | ||
36 | #include <qbuttongroup.h> | ||
37 | #include <qmessagebox.h> | ||
38 | #include <qvgroupbox.h> | ||
39 | |||
40 | #include "interfaceppp.h" | ||
41 | #include "devices.h" | ||
42 | #include "authwidget.h" | ||
43 | #include "pppdata.h" | ||
44 | #include "edit.h" | ||
45 | #include "general.h" | ||
46 | |||
47 | void parseargs(char* buf, char** args); | ||
48 | |||
49 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) | ||
50 | : ChooserWidget(ip->data(), parent, name, f) | ||
51 | { | ||
52 | _ifaceppp = ip; | ||
53 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); | ||
54 | QWhatsThis::add(new_b, tr("Create a new device") ); | ||
55 | |||
56 | QWhatsThis::add(copy_b, | ||
57 | tr("Makes a copy of the selected device. All\n" | ||
58 | "settings of the selected device are copied\n" | ||
59 | "to a new device, that you can modify to fit your\n" | ||
60 | "needs")); | ||
61 | QWhatsThis::add(delete_b, | ||
62 | tr("<p>Deletes the selected device\n\n" | ||
63 | "<font color=\"red\"><b>Use with care!</b></font>")); | ||
64 | |||
65 | copy_b->setEnabled( false ); //FIXME | ||
66 | // delete_b->setEnabled( false ); //FIXME | ||
67 | |||
68 | QStringList tmp = _pppdata->getDevicesNamesList(); | ||
69 | qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1()); | ||
70 | listListbox->insertStringList(tmp); | ||
71 | |||
72 | for (uint i = 0; i < listListbox->count(); i++){ | ||
73 | qDebug("listListbox->text(i) %s == _pppdata->devname() %s",listListbox->text(i).latin1(), _pppdata->devname().latin1()); | ||
74 | if ( listListbox->text(i) == _pppdata->devname() ) | ||
75 | listListbox->setCurrentItem( i ); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | |||
80 | |||
81 | void DevicesWidget::slotListBoxSelect(int idx) { | ||
82 | bool ok = _pppdata->setDevice( listListbox->text(idx) ); | ||
83 | delete_b->setEnabled((bool)(idx != -1)); | ||
84 | edit_b->setEnabled((bool)(idx != -1)); | ||
85 | //FIXME copy_b->setEnabled((bool)(idx != -1)); | ||
86 | } | ||
87 | |||
88 | void DevicesWidget::edit() { | ||
89 | _pppdata->setDevice(listListbox->text(listListbox->currentItem())); | ||
90 | |||
91 | int result = doTab(); | ||
92 | |||
93 | if(result == QDialog::Accepted) { | ||
94 | listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); | ||
95 | _pppdata->save(); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | |||
100 | void DevicesWidget::create() { | ||
101 | |||
102 | // if(listListbox->count() == MAX_ACCOUNTS) { | ||
103 | // QMessageBox::information(this, "sorry", | ||
104 | // tr("Maximum number of accounts reached.")); | ||
105 | // return; | ||
106 | // } | ||
107 | |||
108 | int result; | ||
109 | if (_pppdata->newdevice() == -1){ | ||
110 | return; | ||
111 | } | ||
112 | result = doTab(); | ||
113 | |||
114 | if(result == QDialog::Accepted) { | ||
115 | listListbox->insertItem(_pppdata->devname()); | ||
116 | listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); | ||
117 | |||
118 | _pppdata->save(); | ||
119 | } else | ||
120 | _pppdata->deleteDevice(); | ||
121 | } | ||
122 | |||
123 | |||
124 | void DevicesWidget::copy() { | ||
125 | // if(listListbox->count() == MAX_ACCOUNTS) { | ||
126 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | ||
127 | // return; | ||
128 | // } | ||
129 | |||
130 | if(listListbox->currentItem()<0) { | ||
131 | QMessageBox::information(this, "sorry", tr("No devices selected.")); | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | _pppdata->copydevice(listListbox->currentText()); | ||
136 | |||
137 | listListbox->insertItem(_pppdata->devname()); | ||
138 | _pppdata->save(); | ||
139 | } | ||
140 | |||
141 | |||
142 | void DevicesWidget::remove() { | ||
143 | |||
144 | QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") | ||
145 | .arg(listListbox->text(listListbox->currentItem())); | ||
146 | |||
147 | if(QMessageBox::warning(this,tr("Confirm"),s, | ||
148 | QMessageBox::Yes,QMessageBox::No | ||
149 | ) != QMessageBox::Yes) | ||
150 | return; | ||
151 | |||
152 | if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) | ||
153 | listListbox->removeItem(listListbox->currentItem()); | ||
154 | |||
155 | |||
156 | // _pppdata->save(); | ||
157 | |||
158 | |||
159 | slotListBoxSelect(listListbox->currentItem()); | ||
160 | |||
161 | } | ||
162 | |||
163 | |||
164 | int DevicesWidget::doTab(){ | ||
165 | QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); | ||
166 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | ||
167 | layout->setSpacing( 0 ); | ||
168 | layout->setMargin( 1 ); | ||
169 | |||
170 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); | ||
171 | layout->addWidget( tabWindow ); | ||
172 | |||
173 | bool isnew; | ||
174 | |||
175 | if(_pppdata->devname().isEmpty()) { | ||
176 | dlg->setCaption(tr("New Device")); | ||
177 | isnew = true; | ||
178 | } else { | ||
179 | QString tit = tr("Edit Device: "); | ||
180 | tit += _pppdata->devname(); | ||
181 | dlg->setCaption(tit); | ||
182 | isnew = false; | ||
183 | } | ||
184 | |||
185 | modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); | ||
186 | tabWindow->addTab( modem1, tr("&Device") ); | ||
187 | modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); | ||
188 | tabWindow->addTab( modem2, tr("&Modem") ); | ||
189 | |||
190 | int result = 0; | ||
191 | bool ok = false; | ||
192 | |||
193 | while (!ok){ | ||
194 | dlg->showMaximized(); | ||
195 | result = dlg->exec(); | ||
196 | ok = true; | ||
197 | |||
198 | if(result == QDialog::Accepted) { | ||
199 | if (!modem1->save()){ | ||
200 | QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); | ||
201 | ok = false; | ||
202 | }else{ | ||
203 | modem2->save(); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | delete dlg; | ||
209 | |||
210 | return result; | ||
211 | } | ||
212 | |||
diff --git a/noncore/settings/networksettings/ppp/devices.h b/noncore/settings/networksettings/ppp/devices.h index d46d5b4..c2679c8 100644 --- a/noncore/settings/networksettings/ppp/devices.h +++ b/noncore/settings/networksettings/ppp/devices.h | |||
@@ -1,60 +1,51 @@ | |||
1 | #ifndef _DEVICES_H_ | 1 | #ifndef _DEVICES_H_ |
2 | #define _DEVICES_H_ | 2 | #define _DEVICES_H_ |
3 | 3 | ||
4 | #include "kpppconfig.h" | 4 | #include "kpppconfig.h" |
5 | 5 | ||
6 | static const char *devices[] = { | 6 | #include <qwidget.h> |
7 | #ifdef __FreeBSD__ | 7 | #include <qdialog.h> |
8 | "/dev/cuaa0", | 8 | #include <qpushbutton.h> |
9 | "/dev/cuaa1", | 9 | #include <qlistbox.h> |
10 | "/dev/cuaa2", | 10 | #include "chooserwidget.h" |
11 | "/dev/cuaa3", | 11 | |
12 | "/dev/cuaa4", | 12 | class QCheckBox; |
13 | #elif defined(__NetBSD__) | 13 | class QLineEdit; |
14 | "/dev/tty00", /* "normal" modem lines */ | 14 | class QTabWidget; |
15 | "/dev/tty01", | 15 | class DialWidget; |
16 | "/dev/tty02", | 16 | class AuthWidget; |
17 | "/dev/tty03", | 17 | class IPWidget; |
18 | "/dev/dty00", /* Dial out devices */ | 18 | class DNSWidget; |
19 | "/dev/dty01", | 19 | class GatewayWidget; |
20 | "/dev/dty02", | 20 | class InterfacePPP; |
21 | "/dev/dty03", | 21 | class PPPData; |
22 | "/dev/ttyU0", /* USB stuff modems */ | 22 | class ModemWidget; |
23 | "/dev/ttyU1", | 23 | class ModemWidget2; |
24 | "/dev/ttyU2", | 24 | |
25 | "/dev/ttyU3", | 25 | class DevicesWidget : public ChooserWidget { |
26 | "/dev/dtyU0", /* USB stuff, too (dial out device) */ | 26 | Q_OBJECT |
27 | "/dev/dtyU1", | 27 | public: |
28 | "/dev/dtyU2", | 28 | DevicesWidget( InterfacePPP* ip, QWidget *parent=0, const char *name=0, WFlags f=0 ); |
29 | "/dev/dtyU3", | 29 | ~DevicesWidget() {} |
30 | #elif defined (__linux__) | 30 | |
31 | "/dev/modem", | 31 | |
32 | "/dev/ttyS0", | 32 | private slots: |
33 | "/dev/ttyS1", | 33 | virtual void edit(); |
34 | "/dev/ttyS2", | 34 | virtual void copy(); |
35 | "/dev/ttyS3", | 35 | virtual void remove(); |
36 | #ifdef ISDNSUPPORT | 36 | virtual void create(); |
37 | "/dev/ttyI0", | 37 | virtual void slotListBoxSelect(int); |
38 | "/dev/ttyI1", | 38 | int doTab(); |
39 | "/dev/ttyI2", | 39 | |
40 | "/dev/ttyI3", | 40 | // signals: |
41 | #endif | 41 | // void resetaccounts(); |
42 | "/dev/usb/ttyACM0", /* USB stuff modems */ | 42 | |
43 | "/dev/usb/ttyACM1", | 43 | private: |
44 | "/dev/usb/ttyACM2", | 44 | ModemWidget *modem1; |
45 | "/dev/usb/ttyACM3", | 45 | ModemWidget2 *modem2; |
46 | "/dev/ircomm0", | 46 | InterfacePPP *_ifaceppp; |
47 | "/dev/rfcomm0", | 47 | |
48 | "/dev/rfcomm1", | 48 | }; |
49 | #elif defined(__svr4__) | ||
50 | "/dev/cua/a", | ||
51 | "/dev/cua/b", | ||
52 | "/dev/ttya", | ||
53 | "/dev/ttyb", | ||
54 | #endif | ||
55 | 0}; | ||
56 | 49 | ||
57 | // default device number from the list above | ||
58 | const int DEV_DEFAULT = 0; | ||
59 | 50 | ||
60 | #endif | 51 | #endif |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 0c96253..ceac90c 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -67,27 +67,27 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | |||
67 | 67 | ||
68 | QHBoxLayout *lpn = new QHBoxLayout(5); | 68 | QHBoxLayout *lpn = new QHBoxLayout(5); |
69 | tl->addLayout(lpn, 1, 1); | 69 | tl->addLayout(lpn, 1, 1); |
70 | numbers = new QListBox(this); | 70 | numbers = new QListBox(this); |
71 | // numbers->setMinimumSize(120, 70); | 71 | // numbers->setMinimumSize(120, 70); |
72 | lpn->addWidget(numbers); | 72 | lpn->addWidget(numbers); |
73 | QVBoxLayout *lpn1 = new QVBoxLayout; | 73 | QVBoxLayout *lpn1 = new QVBoxLayout; |
74 | lpn->addLayout(lpn1); | 74 | lpn->addLayout(lpn1); |
75 | add = new QPushButton(tr("&Add..."), this); | 75 | add = new QPushButton(tr("&Add..."), this); |
76 | del = new QPushButton(tr("&Remove"), this); | 76 | del = new QPushButton(tr("&Remove"), this); |
77 | 77 | ||
78 | up = new QPushButton(this); | 78 | up = new QPushButton(this); |
79 | up->setPixmap( Resource::loadPixmap("inline/up") ); | 79 | up->setPixmap( Resource::loadPixmap("up") ); |
80 | down = new QPushButton(this); | 80 | down = new QPushButton(this); |
81 | down->setPixmap( Resource::loadPixmap("inline/down") ); | 81 | down->setPixmap( Resource::loadPixmap("down") ); |
82 | lpn1->addWidget(add); | 82 | lpn1->addWidget(add); |
83 | lpn1->addWidget(del); | 83 | lpn1->addWidget(del); |
84 | lpn1->addStretch(1); | 84 | lpn1->addStretch(1); |
85 | lpn1->addWidget(up); | 85 | lpn1->addWidget(up); |
86 | lpn1->addWidget(down); | 86 | lpn1->addWidget(down); |
87 | connect(add, SIGNAL(clicked()), | 87 | connect(add, SIGNAL(clicked()), |
88 | this, SLOT(addNumber())); | 88 | this, SLOT(addNumber())); |
89 | connect(del, SIGNAL(clicked()), | 89 | connect(del, SIGNAL(clicked()), |
90 | this, SLOT(delNumber())); | 90 | this, SLOT(delNumber())); |
91 | connect(up, SIGNAL(clicked()), | 91 | connect(up, SIGNAL(clicked()), |
92 | this, SLOT(upNumber())); | 92 | this, SLOT(upNumber())); |
93 | connect(down, SIGNAL(clicked()), | 93 | connect(down, SIGNAL(clicked()), |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index f735e49..5540946 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -26,115 +26,134 @@ | |||
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 | #include <qpe/config.h> | |
39 | // #include <qgroupbox.h> | 39 | // #include <qgroupbox.h> |
40 | 40 | ||
41 | |||
41 | #include "general.h" | 42 | #include "general.h" |
42 | #include "interfaceppp.h" | 43 | #include "interfaceppp.h" |
43 | //#include "miniterm.h" | 44 | //#include "miniterm.h" |
44 | #include "modeminfo.h" | 45 | #include "modeminfo.h" |
45 | #include "modemcmds.h" | 46 | #include "modemcmds.h" |
46 | #include "devices.h" | 47 | //#include "devices.h" |
47 | #include "pppdata.h" | 48 | #include "pppdata.h" |
48 | //#include <klocale.h> | 49 | //#include <klocale.h> |
49 | #define i18n QObject::tr | ||
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name ) | 53 | |
54 | : QWidget(parent, name), _ifaceppp(ifppp) | 54 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) |
55 | : QWidget(parent, name), _pppdata(pd) | ||
55 | { | 56 | { |
56 | int k; | 57 | int k; |
57 | 58 | ||
58 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 59 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); |
59 | 60 | ||
60 | QLabel *label1; | 61 | QLabel *label1; |
61 | label1 = new QLabel(i18n("Modem de&vice:"), this); | 62 | |
63 | label1 = new QLabel(tr("Modem &name:"), this); | ||
62 | tl->addWidget(label1, 0, 0); | 64 | tl->addWidget(label1, 0, 0); |
63 | 65 | ||
66 | modemname = new QLineEdit(this, "modemName"); | ||
67 | modemname->setText( _pppdata->devname() ); | ||
68 | label1->setBuddy(modemname); | ||
69 | tl->addWidget(modemname, 0, 1); | ||
70 | |||
71 | label1 = new QLabel(tr("Modem de&vice:"), this); | ||
72 | tl->addWidget(label1, 1, 0); | ||
73 | |||
64 | modemdevice = new QComboBox(false, this); | 74 | modemdevice = new QComboBox(false, this); |
75 | modemdevice->setEditable( true ); | ||
76 | modemdevice->setDuplicatesEnabled ( false ); | ||
77 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | ||
65 | label1->setBuddy(modemdevice); | 78 | label1->setBuddy(modemdevice); |
66 | 79 | ||
67 | for(k = 0; devices[k]; k++) | 80 | Config cfg("NetworkSetupPPP"); |
68 | modemdevice->insertItem(devices[k]); | 81 | cfg.setGroup("Devices_General"); |
82 | QStringList devs = cfg.readListEntry("devices",','); | ||
83 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; | ||
84 | modemdevice->insertStringList( devs ); | ||
85 | tl->addWidget(modemdevice, 1, 1); | ||
86 | |||
87 | // connect(modemdevice, SIGNAL(activated(int)), | ||
88 | // SLOT(setmodemdc(int))); | ||
89 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), | ||
90 | // SLOT( setmodemdc( const QString &) ) ); | ||
69 | 91 | ||
70 | tl->addWidget(modemdevice, 0, 1); | 92 | QString tmp = tr("This specifies the serial port your modem is attached \n" |
71 | connect(modemdevice, SIGNAL(activated(int)), | ||
72 | SLOT(setmodemdc(int))); | ||
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" | 93 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
75 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 94 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
76 | "\n" | 95 | "\n" |
77 | "If you have an internal ISDN card with AT command\n" | 96 | "If you have an internal ISDN card with AT command\n" |
78 | "emulation (most cards under Linux support this), you\n" | 97 | "emulation (most cards under Linux support this), you\n" |
79 | "should select one of the /dev/ttyIx devices."); | 98 | "should select one of the /dev/ttyIx devices."); |
80 | 99 | ||
81 | QWhatsThis::add(label1,tmp); | 100 | QWhatsThis::add(label1,tmp); |
82 | QWhatsThis::add(modemdevice,tmp); | 101 | QWhatsThis::add(modemdevice,tmp); |
83 | 102 | ||
84 | 103 | ||
85 | label1 = new QLabel(i18n("&Flow control:"), this); | 104 | label1 = new QLabel(tr("&Flow control:"), this); |
86 | tl->addWidget(label1, 1, 0); | 105 | tl->addWidget(label1, 2, 0); |
87 | 106 | ||
88 | flowcontrol = new QComboBox(false, this); | 107 | flowcontrol = new QComboBox(false, this); |
89 | label1->setBuddy(flowcontrol); | 108 | label1->setBuddy(flowcontrol); |
90 | flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); | 109 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
91 | flowcontrol->insertItem(i18n("Software [XON/XOFF]")); | 110 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
92 | flowcontrol->insertItem(i18n("None")); | 111 | flowcontrol->insertItem(tr("None")); |
93 | tl->addWidget(flowcontrol, 1, 1); | 112 | tl->addWidget(flowcontrol, 2, 1); |
94 | connect(flowcontrol, SIGNAL(activated(int)), | 113 | // connect(flowcontrol, SIGNAL(activated(int)), |
95 | SLOT(setflowcontrol(int))); | 114 | // SLOT(setflowcontrol(int))); |
96 | 115 | ||
97 | tmp = i18n("<p>Specifies how the serial port and modem\n" | 116 | tmp = tr("<p>Specifies how the serial port and modem\n" |
98 | "communicate. You should not change this unless\n" | 117 | "communicate. You should not change this unless\n" |
99 | "you know what you are doing.\n" | 118 | "you know what you are doing.\n" |
100 | "\n" | 119 | "\n" |
101 | "<b>Default</b>: CRTSCTS"); | 120 | "<b>Default</b>: CRTSCTS"); |
102 | 121 | ||
103 | QWhatsThis::add(label1,tmp); | 122 | QWhatsThis::add(label1,tmp); |
104 | QWhatsThis::add(flowcontrol,tmp); | 123 | QWhatsThis::add(flowcontrol,tmp); |
105 | 124 | ||
106 | QLabel *labelenter = new QLabel(i18n("&Line termination:"), this); | 125 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
107 | tl->addWidget(labelenter, 2, 0); | 126 | tl->addWidget(labelenter, 3, 0); |
108 | 127 | ||
109 | enter = new QComboBox(false, this); | 128 | enter = new QComboBox(false, this); |
110 | labelenter->setBuddy(enter); | 129 | labelenter->setBuddy(enter); |
111 | enter->insertItem("CR"); | 130 | enter->insertItem("CR"); |
112 | enter->insertItem("LF"); | 131 | enter->insertItem("LF"); |
113 | enter->insertItem("CR/LF"); | 132 | enter->insertItem("CR/LF"); |
114 | tl->addWidget(enter, 2, 1); | 133 | tl->addWidget(enter, 3, 1); |
115 | connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 134 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
116 | tmp = i18n("<p>Specifies how AT commands are sent to your\n" | 135 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
117 | "modem. Most modems will work fine with the\n" | 136 | "modem. Most modems will work fine with the\n" |
118 | "default <i>CR/LF</i>. If your modem does not react\n" | 137 | "default <i>CR/LF</i>. If your modem does not react\n" |
119 | "to the init string, you should try different\n" | 138 | "to the init string, you should try different\n" |
120 | "settings here\n" | 139 | "settings here\n" |
121 | "\n" | 140 | "\n" |
122 | "<b>Default</b>: CR/LF"); | 141 | "<b>Default</b>: CR/LF"); |
123 | 142 | ||
124 | QWhatsThis::add(labelenter,tmp); | 143 | QWhatsThis::add(labelenter,tmp); |
125 | QWhatsThis::add(enter, tmp); | 144 | QWhatsThis::add(enter, tmp); |
126 | 145 | ||
127 | QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this); | 146 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
128 | tl->addWidget(baud_label, 3, 0); | 147 | tl->addWidget(baud_label, 4, 0); |
129 | baud_c = new QComboBox(this); | 148 | baud_c = new QComboBox(this); |
130 | baud_label->setBuddy(baud_c); | 149 | baud_label->setBuddy(baud_c); |
131 | 150 | ||
132 | static const char *baudrates[] = { | 151 | static const char *baudrates[] = { |
133 | 152 | ||
134 | #ifdef B460800 | 153 | #ifdef B460800 |
135 | "460800", | 154 | "460800", |
136 | #endif | 155 | #endif |
137 | 156 | ||
138 | #ifdef B230400 | 157 | #ifdef B230400 |
139 | "230400", | 158 | "230400", |
140 | #endif | 159 | #endif |
@@ -148,243 +167,293 @@ ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name | |||
148 | #endif | 167 | #endif |
149 | 168 | ||
150 | "38400", | 169 | "38400", |
151 | "19200", | 170 | "19200", |
152 | "9600", | 171 | "9600", |
153 | "2400", | 172 | "2400", |
154 | 0}; | 173 | 0}; |
155 | 174 | ||
156 | for(k = 0; baudrates[k]; k++) | 175 | for(k = 0; baudrates[k]; k++) |
157 | baud_c->insertItem(baudrates[k]); | 176 | baud_c->insertItem(baudrates[k]); |
158 | 177 | ||
159 | baud_c->setCurrentItem(3); | 178 | baud_c->setCurrentItem(3); |
160 | connect(baud_c, SIGNAL(activated(int)), | 179 | // connect(baud_c, SIGNAL(activated(int)), |
161 | this, SLOT(speed_selection(int))); | 180 | // this, SLOT(speed_selection(int))); |
162 | tl->addWidget(baud_c, 3, 1); | 181 | tl->addWidget(baud_c, 4, 1); |
163 | 182 | ||
164 | tmp = i18n("Specifies the speed your modem and the serial\n" | 183 | tmp = tr("Specifies the speed your modem and the serial\n" |
165 | "port talk to each other. You should begin with\n" | 184 | "port talk to each other. You should begin with\n" |
166 | "the default of 38400 bits/sec. If everything\n" | 185 | "the default of 38400 bits/sec. If everything\n" |
167 | "works you can try to increase this value, but to\n" | 186 | "works you can try to increase this value, but to\n" |
168 | "no more than 115200 bits/sec (unless you know\n" | 187 | "no more than 115200 bits/sec (unless you know\n" |
169 | "that your serial port supports higher speeds)."); | 188 | "that your serial port supports higher speeds)."); |
170 | 189 | ||
171 | QWhatsThis::add(baud_label,tmp); | 190 | QWhatsThis::add(baud_label,tmp); |
172 | QWhatsThis::add(baud_c,tmp); | 191 | QWhatsThis::add(baud_c,tmp); |
173 | 192 | ||
174 | for(int i=0; i <= enter->count()-1; i++) { | 193 | for(int i=0; i <= enter->count()-1; i++) { |
175 | if(_ifaceppp->data()->enter() == enter->text(i)) | 194 | if(_pppdata->enter() == enter->text(i)) |
176 | enter->setCurrentItem(i); | 195 | enter->setCurrentItem(i); |
177 | } | 196 | } |
178 | 197 | ||
179 | tl->addRowSpacing(4, 10); | 198 | tl->addRowSpacing(5, 10); |
180 | 199 | ||
181 | //Modem Lock File | 200 | //Modem Lock File |
182 | modemlockfile = new QCheckBox(i18n("&Use lock file"), this); | 201 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); |
183 | 202 | ||
184 | modemlockfile->setChecked(_ifaceppp->data()->modemLockFile()); | 203 | modemlockfile->setChecked(_pppdata->modemLockFile()); |
185 | connect(modemlockfile, SIGNAL(toggled(bool)), | 204 | // connect(modemlockfile, SIGNAL(toggled(bool)), |
186 | SLOT(modemlockfilechanged(bool))); | 205 | // SLOT(modemlockfilechanged(bool))); |
187 | tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); | 206 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); |
188 | // l12->addStretch(1); | 207 | // l12->addStretch(1); |
189 | QWhatsThis::add(modemlockfile, | 208 | QWhatsThis::add(modemlockfile, |
190 | i18n("<p>To prevent other programs from accessing the\n" | 209 | tr("<p>To prevent other programs from accessing the\n" |
191 | "modem while a connection is established, a\n" | 210 | "modem while a connection is established, a\n" |
192 | "file can be created to indicate that the modem\n" | 211 | "file can be created to indicate that the modem\n" |
193 | "is in use. On Linux an example file would be\n" | 212 | "is in use. On Linux an example file would be\n" |
194 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 213 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
195 | "Here you can select whether this locking will\n" | 214 | "Here you can select whether this locking will\n" |
196 | "be done.\n" | 215 | "be done.\n" |
197 | "\n" | 216 | "\n" |
198 | "<b>Default</b>: On")); | 217 | "<b>Default</b>: On")); |
199 | 218 | ||
200 | // Modem Timeout Line Edit Box | 219 | // Modem Timeout Line Edit Box |
201 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 220 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
202 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 221 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
203 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 222 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
204 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); | 223 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
205 | // modemtimeout->setLabel(i18n("Modem &timeout:")); | 224 | // modemtimeout->setLabel(tr("Modem &timeout:")); |
206 | // modemtimeout->setRange(1, 120, 1); | 225 | // modemtimeout->setRange(1, 120, 1); |
207 | modemtimeout->setSuffix(i18n(" sec")); | 226 | modemtimeout->setSuffix(tr(" sec")); |
208 | modemtimeout->setValue( _ifaceppp->data()->modemTimeout() ); | 227 | modemtimeout->setValue( _pppdata->modemTimeout() ); |
209 | connect(modemtimeout, SIGNAL(valueChanged(int)), | 228 | // connect(modemtimeout, SIGNAL(valueChanged(int)), |
210 | SLOT(modemtimeoutchanged(int))); | 229 | // SLOT(modemtimeoutchanged(int))); |
211 | timeoutLayout->addWidget(timeoutlabel); | 230 | timeoutLayout->addWidget(timeoutlabel); |
212 | timeoutLayout->addWidget(modemtimeout); | 231 | timeoutLayout->addWidget(modemtimeout); |
213 | tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); | 232 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); |
214 | 233 | ||
215 | QWhatsThis::add(modemtimeout, | 234 | QWhatsThis::add(modemtimeout, |
216 | i18n("This specifies how long <i>kppp</i> waits for a\n" | 235 | tr("This specifies how long <i>kppp</i> waits for a\n" |
217 | "<i>CONNECT</i> response from your modem. The\n" | 236 | "<i>CONNECT</i> response from your modem. The\n" |
218 | "recommended value is 30 seconds.")); | 237 | "recommended value is 30 seconds.")); |
219 | 238 | ||
220 | //set stuff from gpppdata | 239 | //set stuff from gpppdata |
221 | for(int i=0; i <= enter->count()-1; i++) { | 240 | for(int i=0; i <= enter->count()-1; i++) { |
222 | if(_ifaceppp->data()->enter() == enter->text(i)) | 241 | if(_pppdata->enter() == enter->text(i)) |
223 | enter->setCurrentItem(i); | 242 | enter->setCurrentItem(i); |
224 | } | 243 | } |
225 | 244 | ||
226 | for(int i=0; i <= modemdevice->count()-1; i++) { | 245 | for(int i=0; i <= modemdevice->count()-1; i++) { |
227 | if(_ifaceppp->data()->modemDevice() == modemdevice->text(i)) | 246 | if(_pppdata->modemDevice() == modemdevice->text(i)) |
228 | modemdevice->setCurrentItem(i); | 247 | modemdevice->setCurrentItem(i); |
229 | } | 248 | } |
230 | 249 | ||
231 | for(int i=0; i <= flowcontrol->count()-1; i++) { | 250 | for(int i=0; i <= flowcontrol->count()-1; i++) { |
232 | if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i)) | 251 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) |
233 | flowcontrol->setCurrentItem(i); | 252 | flowcontrol->setCurrentItem(i); |
234 | } | 253 | } |
235 | 254 | ||
236 | //set the modem speed | 255 | //set the modem speed |
237 | for(int i=0; i < baud_c->count(); i++) | 256 | for(int i=0; i < baud_c->count(); i++) |
238 | if(baud_c->text(i) == _ifaceppp->data()->speed()) | 257 | if(baud_c->text(i) == _pppdata->speed()) |
239 | baud_c->setCurrentItem(i); | 258 | baud_c->setCurrentItem(i); |
240 | 259 | ||
241 | tl->setRowStretch(7, 1); | 260 | tl->setRowStretch(1, 1); |
242 | } | 261 | } |
243 | 262 | ||
263 | ModemWidget::~ModemWidget() | ||
264 | { | ||
265 | QStringList devs; | ||
244 | 266 | ||
245 | void ModemWidget::speed_selection(int) { | 267 | for (int i=0;i<modemdevice->count();i++) |
246 | _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem())); | 268 | { |
269 | QString s = modemdevice->text(i); | ||
270 | s.simplifyWhiteSpace(); | ||
271 | if (! s.isEmpty() ) devs << s; | ||
247 | } | 272 | } |
248 | 273 | ||
249 | 274 | ||
250 | void ModemWidget::setenter(int ) { | 275 | QString edited = modemdevice->currentText(); |
251 | _ifaceppp->data()->setEnter(enter->text(enter->currentItem())); | 276 | if ( !( edited ).isEmpty() ) { |
277 | edited.simplifyWhiteSpace(); | ||
278 | if ( devs.contains( edited ) == 0 ) { | ||
279 | devs << edited; | ||
252 | } | 280 | } |
281 | _pppdata->setModemDevice( edited ); | ||
282 | } | ||
283 | |||
253 | 284 | ||
285 | Config cfg("NetworkSetupPPP"); | ||
286 | cfg.setGroup("Devices_General"); | ||
287 | cfg.writeEntry("devices",devs,','); | ||
254 | 288 | ||
255 | void ModemWidget::setmodemdc(int i) { | ||
256 | _ifaceppp->data()->setModemDevice(modemdevice->text(i)); | ||
257 | } | 289 | } |
258 | 290 | ||
291 | // void ModemWidget::speed_selection(int) { | ||
292 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); | ||
293 | // } | ||
259 | 294 | ||
260 | void ModemWidget::setflowcontrol(int i) { | ||
261 | _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i)); | ||
262 | } | ||
263 | 295 | ||
296 | // void ModemWidget::setenter(int ) { | ||
297 | // _pppdata->setEnter(enter->text(enter->currentItem())); | ||
298 | // } | ||
264 | 299 | ||
265 | void ModemWidget::modemlockfilechanged(bool set) { | ||
266 | _ifaceppp->data()->setModemLockFile(set); | ||
267 | } | ||
268 | 300 | ||
301 | // void ModemWidget::setmodemdc(int i) { | ||
302 | // _pppdata->setModemDevice(modemdevice->text(i)); | ||
303 | // } | ||
269 | 304 | ||
270 | void ModemWidget::modemtimeoutchanged(int n) { | 305 | // void ModemWidget::setmodemdc( const QString &string ) { |
271 | _ifaceppp->data()->setModemTimeout(n); | 306 | // _pppdata->setModemDevice( string ); |
272 | } | 307 | // } |
308 | |||
309 | // void ModemWidget::setflowcontrol(int i) { | ||
310 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); | ||
311 | // } | ||
273 | 312 | ||
274 | 313 | ||
275 | ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent, | 314 | // void ModemWidget::modemlockfilechanged(bool set) { |
315 | // _pppdata->setModemLockFile(set); | ||
316 | // } | ||
317 | |||
318 | |||
319 | // void ModemWidget::modemtimeoutchanged(int n) { | ||
320 | // _pppdata->setModemTimeout(n); | ||
321 | // } | ||
322 | |||
323 | |||
324 | |||
325 | bool ModemWidget::save() | ||
326 | { | ||
327 | //first check to make sure that the device name is unique! | ||
328 | if(modemname->text().isEmpty() || | ||
329 | !_pppdata->isUniqueDevname(modemname->text())) | ||
330 | return false; | ||
331 | |||
332 | qDebug("ModemWidget::save saving modem1 data"); | ||
333 | _pppdata->setDevname( modemname->text() ); | ||
334 | _pppdata->setModemDevice( modemdevice->currentText() ); | ||
335 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | ||
336 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | ||
337 | _pppdata->setSpeed(baud_c->currentText()); | ||
338 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | ||
339 | _pppdata->setModemTimeout( modemtimeout->value() ); | ||
340 | return true; | ||
341 | |||
342 | } | ||
343 | |||
344 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | ||
276 | const char *name) | 345 | const char *name) |
277 | : QWidget(parent, name), _ifaceppp(ifp) | 346 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
278 | { | 347 | { |
279 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 348 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
280 | 349 | ||
281 | 350 | ||
282 | waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); | 351 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
283 | waitfordt->setChecked(_ifaceppp->data()->waitForDialTone()); | 352 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
284 | connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 353 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
285 | l1->addWidget(waitfordt); | 354 | l1->addWidget(waitfordt); |
286 | QWhatsThis::add(waitfordt, | 355 | QWhatsThis::add(waitfordt, |
287 | i18n("<p>Normally the modem waits for a dial tone\n" | 356 | tr("<p>Normally the modem waits for a dial tone\n" |
288 | "from your phone line, indicating that it can\n" | 357 | "from your phone line, indicating that it can\n" |
289 | "start to dial a number. If your modem does not\n" | 358 | "start to dial a number. If your modem does not\n" |
290 | "recognize this sound, or your local phone system\n" | 359 | "recognize this sound, or your local phone system\n" |
291 | "does not emit such a tone, uncheck this option\n" | 360 | "does not emit such a tone, uncheck this option\n" |
292 | "\n" | 361 | "\n" |
293 | "<b>Default:</b>: On")); | 362 | "<b>Default:</b>: On")); |
294 | 363 | ||
295 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 364 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
296 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 365 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
297 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 366 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
298 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); | 367 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
299 | // busywait->setLabel(i18n("B&usy wait:")); | 368 | // busywait->setLabel(tr("B&usy wait:")); |
300 | // busywait->setRange(0, 300, 5, true); | 369 | // busywait->setRange(0, 300, 5, true); |
301 | busywait->setSuffix(i18n(" sec")); | 370 | busywait->setSuffix(tr(" sec")); |
302 | connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 371 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
303 | waitLayout->addWidget(waitLabel); | 372 | waitLayout->addWidget(waitLabel); |
304 | waitLayout->addWidget(busywait); | 373 | waitLayout->addWidget(busywait); |
305 | l1->addLayout( waitLayout ); | 374 | l1->addLayout( waitLayout ); |
306 | 375 | ||
307 | QWhatsThis::add(busywait, | 376 | QWhatsThis::add(busywait, |
308 | i18n("Specifies the number of seconds to wait before\n" | 377 | tr("Specifies the number of seconds to wait before\n" |
309 | "redial if all dialed numbers are busy. This is\n" | 378 | "redial if all dialed numbers are busy. This is\n" |
310 | "necessary because some modems get stuck if the\n" | 379 | "necessary because some modems get stuck if the\n" |
311 | "same number is busy too often.\n" | 380 | "same number is busy too often.\n" |
312 | "\n" | 381 | "\n" |
313 | "The default is 0 seconds, you should not change\n" | 382 | "The default is 0 seconds, you should not change\n" |
314 | "this unless you need to.")); | 383 | "this unless you need to.")); |
315 | 384 | ||
316 | l1->addSpacing(10); | 385 | l1->addSpacing(10); |
317 | 386 | ||
318 | QHBoxLayout *hbl = new QHBoxLayout; | 387 | QHBoxLayout *hbl = new QHBoxLayout; |
319 | hbl->setSpacing(2);//KDialog::spacingHint()); | 388 | hbl->setSpacing(2);//KDialog::spacingHint()); |
320 | 389 | ||
321 | QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); | 390 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); |
322 | hbl->addWidget(volumeLabel); | 391 | hbl->addWidget(volumeLabel); |
323 | volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(), | 392 | volume = new QSlider(0, 2, 1, _pppdata->volume(), |
324 | QSlider::Horizontal, this); | 393 | QSlider::Horizontal, this); |
325 | volumeLabel->setBuddy(volume); | 394 | volumeLabel->setBuddy(volume); |
326 | volume->setTickmarks(QSlider::Below); | 395 | volume->setTickmarks(QSlider::Below); |
327 | hbl->addWidget(volume); | 396 | hbl->addWidget(volume); |
328 | 397 | ||
329 | l1->addLayout(hbl); | 398 | l1->addLayout(hbl); |
330 | 399 | ||
331 | connect(volume, SIGNAL(valueChanged(int)), | 400 | // connect(volume, SIGNAL(valueChanged(int)), |
332 | this, SLOT(volumeChanged(int))); | 401 | // this, SLOT(volumeChanged(int))); |
333 | QString tmp = i18n("Most modems have a speaker which makes\n" | 402 | QString tmp = tr("Most modems have a speaker which makes\n" |
334 | "a lot of noise when dialing. Here you can\n" | 403 | "a lot of noise when dialing. Here you can\n" |
335 | "either turn this completely off or select a\n" | 404 | "either turn this completely off or select a\n" |
336 | "lower volume.\n" | 405 | "lower volume.\n" |
337 | "\n" | 406 | "\n" |
338 | "If this does not work for your modem,\n" | 407 | "If this does not work for your modem,\n" |
339 | "you must modify the modem volume command."); | 408 | "you must modify the modem volume command."); |
340 | 409 | ||
341 | QWhatsThis::add(volumeLabel,tmp); | 410 | QWhatsThis::add(volumeLabel,tmp); |
342 | QWhatsThis::add(volume, tmp); | 411 | QWhatsThis::add(volume, tmp); |
343 | 412 | ||
344 | l1->addSpacing(20); | 413 | l1->addSpacing(20); |
345 | 414 | ||
346 | #if 0 | 415 | #if 0 |
347 | chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); | 416 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); |
348 | chkbox1->setChecked(_ifaceppp->data()->UseCDLine()); | 417 | chkbox1->setChecked(_pppdata->UseCDLine()); |
349 | connect(chkbox1,SIGNAL(toggled(bool)), | 418 | connect(chkbox1,SIGNAL(toggled(bool)), |
350 | this,SLOT(use_cdline_toggled(bool))); | 419 | this,SLOT(use_cdline_toggled(bool))); |
351 | l12->addWidget(chkbox1); | 420 | l12->addWidget(chkbox1); |
352 | l12->addStretch(1); | 421 | l12->addStretch(1); |
353 | l1->addStretch(1); | 422 | l1->addStretch(1); |
354 | QWhatsThis::add(chkbox1, | 423 | QWhatsThis::add(chkbox1, |
355 | i18n("This controls how <i>kppp</i> detects that the modem\n" | 424 | tr("This controls how <i>kppp</i> detects that the modem\n" |
356 | "is not responding. Unless you are having\n" | 425 | "is not responding. Unless you are having\n" |
357 | "problems with this, do not modify this setting.\n" | 426 | "problems with this, do not modify this setting.\n" |
358 | "\n" | 427 | "\n" |
359 | "<b>Default</b>: Off")); | 428 | "<b>Default</b>: Off")); |
360 | #endif | 429 | #endif |
361 | 430 | ||
362 | modemcmds = new QPushButton(i18n("Mod&em Commands..."), this); | 431 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); |
363 | QWhatsThis::add(modemcmds, | 432 | QWhatsThis::add(modemcmds, |
364 | i18n("Allows you to change the AT command for\n" | 433 | tr("Allows you to change the AT command for\n" |
365 | "your modem.")); | 434 | "your modem.")); |
366 | 435 | ||
367 | modeminfo_button = new QPushButton(i18n("&Query Modem..."), this); | 436 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); |
368 | QWhatsThis::add(modeminfo_button, | 437 | QWhatsThis::add(modeminfo_button, |
369 | i18n("Most modems support the ATI command set to\n" | 438 | tr("Most modems support the ATI command set to\n" |
370 | "find out vendor and revision of your modem.\n" | 439 | "find out vendor and revision of your modem.\n" |
371 | "\n" | 440 | "\n" |
372 | "Press this button to query your modem for\n" | 441 | "Press this button to query your modem for\n" |
373 | "this information. It can be useful to help\n" | 442 | "this information. It can be useful to help\n" |
374 | "you setup the modem")); | 443 | "you setup the modem")); |
375 | 444 | ||
376 | // terminal_button = new QPushButton(i18n("&Terminal..."), this); | 445 | // terminal_button = new QPushButton(tr("&Terminal..."), this); |
377 | // QWhatsThis::add(terminal_button, | 446 | // QWhatsThis::add(terminal_button, |
378 | // i18n("Opens the built-in terminal program. You\n" | 447 | // tr("Opens the built-in terminal program. You\n" |
379 | // "can use this if you want to play around\n" | 448 | // "can use this if you want to play around\n" |
380 | // "with your modem's AT command set")); | 449 | // "with your modem's AT command set")); |
381 | 450 | ||
382 | QHBoxLayout *hbox = new QHBoxLayout(); | 451 | QHBoxLayout *hbox = new QHBoxLayout(); |
383 | l1->addLayout(hbox); | 452 | l1->addLayout(hbox); |
384 | hbox->addStretch(1); | 453 | hbox->addStretch(1); |
385 | QVBoxLayout *vbox = new QVBoxLayout(); | 454 | QVBoxLayout *vbox = new QVBoxLayout(); |
386 | hbox->addLayout(vbox); | 455 | hbox->addLayout(vbox); |
387 | 456 | ||
388 | vbox->addWidget(modemcmds); | 457 | vbox->addWidget(modemcmds); |
389 | vbox->addWidget(modeminfo_button); | 458 | vbox->addWidget(modeminfo_button); |
390 | // vbox->addWidget(terminal_button); | 459 | // vbox->addWidget(terminal_button); |
@@ -393,49 +462,57 @@ ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent, | |||
393 | l1->addStretch(1); | 462 | l1->addStretch(1); |
394 | 463 | ||
395 | connect(modemcmds, SIGNAL(clicked()), | 464 | connect(modemcmds, SIGNAL(clicked()), |
396 | SLOT(modemcmdsbutton())); | 465 | SLOT(modemcmdsbutton())); |
397 | connect(modeminfo_button, SIGNAL(clicked()), | 466 | connect(modeminfo_button, SIGNAL(clicked()), |
398 | SLOT(query_modem())); | 467 | SLOT(query_modem())); |
399 | // connect(terminal_button, SIGNAL(clicked()), | 468 | // connect(terminal_button, SIGNAL(clicked()), |
400 | // SLOT(terminal())); | 469 | // SLOT(terminal())); |
401 | } | 470 | } |
402 | 471 | ||
403 | 472 | ||
404 | void ModemWidget2::modemcmdsbutton() { | 473 | void ModemWidget2::modemcmdsbutton() { |
405 | ModemCommands mc(_ifaceppp->data(), this); | 474 | ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); |
406 | mc.showMaximized(); | 475 | mc.showMaximized(); |
407 | mc.exec(); | 476 | mc.exec(); |
408 | } | 477 | } |
409 | 478 | ||
410 | 479 | ||
411 | void ModemWidget2::query_modem() { | 480 | void ModemWidget2::query_modem() { |
412 | ModemTransfer mt(_ifaceppp->modem(), this); | 481 | ModemTransfer mt(_ifaceppp->modem(), this); |
413 | mt.exec(); | 482 | mt.exec(); |
414 | } | 483 | } |
415 | 484 | ||
416 | 485 | ||
417 | // void ModemWidget2::terminal() { | 486 | // void ModemWidget2::terminal() { |
418 | // MiniTerm terminal(NULL,NULL); | 487 | // MiniTerm terminal(NULL,NULL); |
419 | // terminal.exec(); | 488 | // terminal.exec(); |
420 | // } | 489 | // } |
421 | 490 | ||
422 | 491 | ||
423 | #if 0 | 492 | // #if 0 |
424 | void ModemWidget2::use_cdline_toggled(bool on) { | 493 | // void ModemWidget2::use_cdline_toggled(bool on) { |
425 | _ifaceppp->data()->setUseCDLine(on); | 494 | // _pppdata->setUseCDLine(on); |
426 | } | 495 | // } |
427 | #endif | 496 | // #endif |
428 | 497 | ||
429 | void ModemWidget2::waitfordtchanged(bool b) { | 498 | // void ModemWidget2::waitfordtchanged(bool b) { |
430 | _ifaceppp->data()->setWaitForDialTone((int)b); | 499 | // _pppdata->setWaitForDialTone((int)b); |
431 | } | 500 | // } |
432 | 501 | ||
433 | void ModemWidget2::busywaitchanged(int n) { | 502 | // void ModemWidget2::busywaitchanged(int n) { |
434 | _ifaceppp->data()->setbusyWait(n); | 503 | // _pppdata->setbusyWait(n); |
435 | } | 504 | // } |
436 | 505 | ||
437 | 506 | ||
438 | void ModemWidget2::volumeChanged(int v) { | 507 | // void ModemWidget2::volumeChanged(int v) { |
439 | _ifaceppp->data()->setVolume(v); | 508 | // _pppdata->setVolume(v); |
509 | // } | ||
510 | |||
511 | bool ModemWidget2::save() | ||
512 | { | ||
513 | _pppdata->setWaitForDialTone(waitfordt->isChecked()); | ||
514 | _pppdata->setbusyWait(busywait->value()); | ||
515 | _pppdata->setVolume(volume->value()); | ||
516 | return true; | ||
440 | } | 517 | } |
441 | 518 | ||
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index 3e59b46..f43f241 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h | |||
@@ -27,74 +27,82 @@ | |||
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 | class PPPData; | 37 | class PPPData; |
38 | class InterfacePPP; | 38 | class InterfacePPP; |
39 | class QLineEdit; | ||
39 | 40 | ||
40 | class ModemWidget : public QWidget { | 41 | class ModemWidget : public QWidget { |
41 | Q_OBJECT | 42 | Q_OBJECT |
42 | public: | 43 | public: |
43 | ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 ); | 44 | ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); |
45 | ~ModemWidget(); | ||
44 | 46 | ||
45 | private slots: | 47 | bool save(); |
46 | void setmodemdc(int); | 48 | |
47 | void setflowcontrol(int); | 49 | /* private slots: */ |
48 | void modemtimeoutchanged(int); | 50 | /* void setmodemdc(int); */ |
49 | void modemlockfilechanged(bool); | 51 | /* void setmodemdc(const QString &); */ |
50 | void setenter(int); | 52 | /* void setflowcontrol(int); */ |
51 | void speed_selection(int); | 53 | /* void modemtimeoutchanged(int); */ |
54 | /* void modemlockfilechanged(bool); */ | ||
55 | /* void setenter(int); */ | ||
56 | /* void speed_selection(int); */ | ||
52 | 57 | ||
53 | private: | 58 | private: |
54 | QComboBox *enter; | 59 | QComboBox *enter; |
55 | /* QLabel *label1; */ | 60 | /* QLabel *label1; */ |
56 | /* QLabel *label2; */ | 61 | /* QLabel *label2; */ |
57 | /* QLabel *labeltmp; */ | 62 | /* QLabel *labeltmp; */ |
58 | /* QLabel *labelenter; */ | 63 | /* QLabel *labelenter; */ |
64 | QLineEdit *modemname; | ||
59 | QComboBox *modemdevice; | 65 | QComboBox *modemdevice; |
60 | QComboBox *flowcontrol; | 66 | QComboBox *flowcontrol; |
61 | 67 | ||
62 | QComboBox *baud_c; | 68 | QComboBox *baud_c; |
63 | QLabel *baud_label; | 69 | QLabel *baud_label; |
64 | 70 | ||
65 | QSpinBox *modemtimeout; | 71 | QSpinBox *modemtimeout; |
66 | QCheckBox *modemlockfile; | 72 | QCheckBox *modemlockfile; |
67 | InterfacePPP *_ifaceppp; | 73 | PPPData *_pppdata; |
68 | }; | 74 | }; |
69 | 75 | ||
70 | 76 | ||
71 | class ModemWidget2 : public QWidget { | 77 | class ModemWidget2 : public QWidget { |
72 | Q_OBJECT | 78 | Q_OBJECT |
73 | public: | 79 | public: |
74 | ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 ); | 80 | ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); |
81 | bool save(); | ||
75 | 82 | ||
76 | private slots: | 83 | private slots: |
77 | void waitfordtchanged(bool); | 84 | /* void waitfordtchanged(bool); */ |
78 | void busywaitchanged(int); | 85 | /* void busywaitchanged(int); */ |
79 | // void use_cdline_toggled(bool); | 86 | // void use_cdline_toggled(bool); |
80 | void modemcmdsbutton(); | 87 | void modemcmdsbutton(); |
81 | // void terminal(); | 88 | // void terminal(); |
82 | void query_modem(); | 89 | void query_modem(); |
83 | void volumeChanged(int); | 90 | // void volumeChanged(int); |
84 | 91 | ||
85 | private: | 92 | private: |
86 | QLabel *labeltmp; | 93 | QLabel *labeltmp; |
87 | QPushButton *modemcmds; | 94 | QPushButton *modemcmds; |
88 | QPushButton *modeminfo_button; | 95 | QPushButton *modeminfo_button; |
89 | // QPushButton *terminal_button; | 96 | // QPushButton *terminal_button; |
90 | // QFrame *fline; | 97 | // QFrame *fline; |
91 | QCheckBox *waitfordt; | 98 | QCheckBox *waitfordt; |
92 | QSpinBox *busywait; | 99 | QSpinBox *busywait; |
93 | QCheckBox *chkbox1; | 100 | QCheckBox *chkbox1; |
94 | QSlider *volume; | 101 | QSlider *volume; |
102 | PPPData *_pppdata; | ||
95 | InterfacePPP *_ifaceppp; | 103 | InterfacePPP *_ifaceppp; |
96 | }; | 104 | }; |
97 | 105 | ||
98 | #endif | 106 | #endif |
99 | 107 | ||
100 | 108 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 553daa2..6b158b9 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -1,37 +1,41 @@ | |||
1 | #include "interfaceinformationppp.h" | 1 | #include "interfaceinformationppp.h" |
2 | 2 | ||
3 | |||
4 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
5 | #include <qlabel.h> | 4 | #include <qlabel.h> |
6 | //#include <qgroupbox.h> | ||
7 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
8 | #include <qabstractlayout.h> | 6 | #include <qabstractlayout.h> |
9 | 7 | ||
10 | #include "connect.h" | 8 | #include "connect.h" |
11 | #include "conwindow.h" | 9 | #include "conwindow.h" |
12 | 10 | ||
13 | #ifdef QWS | 11 | #ifdef QWS |
14 | #else | 12 | #else |
15 | #define showMaximized show | 13 | #define showMaximized show |
16 | #endif | 14 | #endif |
17 | 15 | ||
18 | /** | 16 | /** |
19 | * Constructor for the InterfaceInformationImp class. This class pretty much | 17 | * Constructor for the InterfaceInformationImp class. This class pretty much |
20 | * just display's information about the interface that is passed to it. | 18 | * just display's information about the interface that is passed to it. |
21 | */ | 19 | */ |
22 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 20 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
23 | :InterfaceInformationImp(parent, name, i, f) | 21 | :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) |
24 | { | 22 | { |
25 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); | 23 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP %s", name); |
26 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | 24 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); |
27 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, | 25 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, |
28 | QSizePolicy::Fixed) ); | 26 | QSizePolicy::Fixed) ); |
29 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); | 27 | |
30 | InterfaceInformationLayout->addItem( spacer, 7, 0 ); | 28 | macAddressLabel->hide(); |
31 | InterfaceInformationLayout->addMultiCellWidget( con, 8, 8, 0, 1 ); | 29 | subnetMaskLabel->hide(); |
32 | // InterfaceInformationLayout->addWidget( con, 7, 0 ); | 30 | broadcastLabel->hide(); |
31 | TextLabel23->hide(); | ||
32 | TextLabel21->hide(); | ||
33 | TextLabel24->hide(); | ||
34 | |||
35 | InterfaceInformationLayout->addWidget( con, 1, 0 ); | ||
33 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | 36 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); |
37 | connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); | ||
34 | } | 38 | } |
35 | 39 | ||
36 | 40 | ||
37 | 41 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index 9ec30bc..f443f3c 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,142 +1,174 @@ | |||
1 | 1 | ||
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #define i18n QObject::tr | 3 | #include <qlayout.h> |
4 | #include <qlineedit.h> | ||
5 | #include <qlabel.h> | ||
4 | 6 | ||
5 | #include "auth.h" | 7 | #include "auth.h" |
6 | #include "interfaceppp.h" | 8 | #include "interfaceppp.h" |
7 | #include "modem.h" | 9 | #include "modem.h" |
8 | #include "pppdata.h" | 10 | #include "pppdata.h" |
9 | 11 | ||
10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 12 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
11 | : Interface(parent, name, status), | 13 | : Interface(parent, name, status), |
12 | _modemPtr(0), | 14 | _modemPtr(0), |
13 | _dataPtr(0) | 15 | _dataPtr(0) |
14 | { | 16 | { |
15 | qDebug("InterfacePPP::InterfacePPP("); | 17 | qDebug("InterfacePPP::InterfacePPP("); |
16 | } | 18 | } |
17 | 19 | ||
18 | PPPData* InterfacePPP::data() | 20 | PPPData* InterfacePPP::data()const |
19 | { | 21 | { |
20 | if (!_dataPtr){ | 22 | if (!_dataPtr){ |
21 | qDebug("creating new Data obj"); | 23 | qDebug("creating new Data obj"); |
22 | _dataPtr = new PPPData(); | 24 | _dataPtr = new PPPData(); |
23 | _dataPtr->setModemDevice( getInterfaceName() ); | 25 | _dataPtr->setDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | 26 | _dataPtr->setAccount( getHardwareName() ); |
25 | } | 27 | } |
26 | return _dataPtr; | 28 | return _dataPtr; |
27 | } | 29 | } |
28 | 30 | ||
29 | Modem* InterfacePPP::modem() | 31 | Modem* InterfacePPP::modem()const |
30 | { | 32 | { |
31 | if (!_modemPtr){ | 33 | if (!_modemPtr){ |
32 | qDebug("creating new modem obj"); | 34 | qDebug("creating new modem obj"); |
33 | _modemPtr = new Modem( data() ); | 35 | _modemPtr = new Modem( data() ); |
34 | } | 36 | } |
35 | return _modemPtr; | 37 | return _modemPtr; |
36 | } | 38 | } |
37 | 39 | ||
38 | bool InterfacePPP::refresh() | 40 | bool InterfacePPP::refresh() |
39 | { | 41 | { |
40 | qDebug("InterfacePPP::refresh()"); | 42 | qDebug("InterfacePPP::refresh()"); |
41 | updateInterface(this); | 43 | QString old = getInterfaceName(); |
42 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | 44 | setInterfaceName( modem()->pppDevice() ); |
43 | return false; | 45 | |
46 | (void)Interface::refresh(); | ||
47 | |||
48 | setInterfaceName( old ); | ||
49 | emit updateInterface(this); | ||
50 | |||
51 | return true; | ||
44 | } | 52 | } |
45 | 53 | ||
46 | void InterfacePPP::start() | 54 | void InterfacePPP::start() |
47 | { | 55 | { |
48 | qDebug("InterfacePPP::start"); | 56 | qDebug("InterfacePPP::start"); |
49 | // should work... | ||
50 | // if (data()->password().isEmpty() ){ | ||
51 | // //FIXME: ask for password | ||
52 | // qDebug("using dummy password"); | ||
53 | // QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)"); | ||
54 | // } | ||
55 | 57 | ||
58 | if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { | ||
59 | |||
60 | QDialog mb( 0, "Dialog", true ); | ||
61 | mb.setCaption( tr( "No password" ) ); | ||
62 | QVBoxLayout layout( &mb ); | ||
63 | QLabel text ( &mb ); | ||
64 | text.setText( tr("Username defined but no password\n Please enter a password") ); | ||
65 | QLineEdit lineedit( &mb ); | ||
66 | lineedit.setEchoMode( QLineEdit::Password ); | ||
67 | layout.addWidget( &text ); | ||
68 | layout.addWidget( &lineedit ); | ||
69 | if ( mb.exec() == QDialog::Accepted ) { | ||
70 | data()->setPassword( lineedit.text() ); | ||
71 | } | ||
72 | } | ||
56 | 73 | ||
57 | QFileInfo info(pppdPath()); | 74 | QFileInfo info(pppdPath()); |
58 | 75 | ||
59 | if(!info.exists()){ | 76 | if(!info.exists()){ |
60 | QMessageBox::warning(0, tr("Error"), | 77 | QMessageBox::warning(0, tr("Error"), |
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | 78 | QObject::tr("<qt>Cannot find the PPP daemon!<br>" |
62 | "Make sure that pppd is installed and " | 79 | "Make sure that pppd is installed and " |
63 | "that you have entered the correct path.</qt>")); | 80 | "that you have entered the correct path.</qt>")); |
64 | return; | 81 | return; |
65 | } | 82 | } |
66 | //#if 0 | 83 | //#if 0 |
67 | if(!info.isExecutable()){ | 84 | if(!info.isExecutable()){ |
68 | 85 | ||
69 | QString string; | 86 | QString string; |
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | 87 | string = QObject::tr( "<qt>Cannot execute:<br> %1<br>" |
71 | "Please make sure that you have given " | 88 | "Please make sure that you have given " |
72 | "setuid permission and that " | 89 | "setuid permission and that " |
73 | "pppd is executable.<br>").arg(pppdPath()); | 90 | "pppd is executable.<br>").arg(pppdPath()); |
74 | QMessageBox::warning(0, tr("Error"), string); | 91 | QMessageBox::warning(0, tr("Error"), string); |
75 | return; | 92 | return; |
76 | 93 | ||
77 | } | 94 | } |
78 | //#endif | 95 | //#endif |
79 | 96 | ||
80 | QFileInfo info2(data()->modemDevice()); | 97 | QFileInfo info2(data()->modemDevice()); |
81 | 98 | ||
82 | if(!info2.exists()){ | 99 | if(!info2.exists()){ |
83 | QString string; | 100 | QString string; |
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | 101 | string = QObject::tr( "<qt>Cannot find:<br> %1<br>" |
85 | "Please make sure you have setup " | 102 | "Please make sure you have setup " |
86 | "your modem device properly " | 103 | "your modem device properly " |
87 | "and/or adjust the location of the modem device on " | 104 | "and/or adjust the location of the modem device on " |
88 | "the modem tab of " | 105 | "the modem tab of " |
89 | "the setup dialog.</qt>").arg(data()->modemDevice()); | 106 | "the setup dialog.</qt>").arg(data()->modemDevice()); |
90 | QMessageBox::warning(0, tr("Error"), string); | 107 | QMessageBox::warning(0, tr("Error"), string); |
91 | return; | 108 | return; |
92 | } | 109 | } |
93 | 110 | ||
94 | // if this is a PAP or CHAP account, ensure that username is | 111 | // if this is a PAP or CHAP account, ensure that username is |
95 | // supplied | 112 | // supplied |
96 | if(data()->authMethod() == AUTH_PAP || | 113 | if(data()->authMethod() == AUTH_PAP || |
97 | data()->authMethod() == AUTH_CHAP || | 114 | data()->authMethod() == AUTH_CHAP || |
98 | data()->authMethod() == AUTH_PAPCHAP ) { | 115 | data()->authMethod() == AUTH_PAPCHAP ) { |
99 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { | 116 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { |
100 | QMessageBox::warning(0,tr("Error"), | 117 | QMessageBox::warning(0,tr("Error"), |
101 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); | 118 | QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); |
102 | // FIXME: return; | 119 | // FIXME: return; |
103 | } else { | 120 | } else { |
104 | if(!modem()->setSecret(data()->authMethod(), | 121 | if(!modem()->setSecret(data()->authMethod(), |
105 | PPPData::encodeWord(data()->storedUsername()), | 122 | PPPData::encodeWord(data()->storedUsername()), |
106 | PPPData::encodeWord(data()->password())) | 123 | PPPData::encodeWord(data()->password())) |
107 | ) { | 124 | ) { |
108 | QString s; | 125 | QString s; |
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | 126 | s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" |
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | 127 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); |
111 | QMessageBox::warning(0, tr("Error"), s); | 128 | QMessageBox::warning(0, tr("Error"), s); |
112 | return; | 129 | return; |
113 | } | 130 | } |
114 | } | 131 | } |
115 | } | 132 | } |
116 | 133 | ||
117 | if (data()->phonenumber().isEmpty()) { | 134 | if (data()->phonenumber().isEmpty()) { |
118 | QString s = i18n("You must specify a telephone number!"); | 135 | QString s = QObject::tr("You must specify a telephone number!"); |
119 | QMessageBox::warning(0, tr("Error"), s); | 136 | QMessageBox::warning(0, tr("Error"), s); |
120 | return; | 137 | return; |
121 | } | 138 | } |
122 | 139 | ||
123 | // SEGFAULTS: | 140 | // SEGFAULTS: |
124 | // setStatus( true ); | 141 | // setStatus( true ); |
125 | // emit updateInterface((Interface*) this); | 142 | // emit updateInterface((Interface*) this); |
126 | 143 | ||
127 | emit begin_connect(); | 144 | emit begin_connect(); |
128 | 145 | ||
129 | qDebug("InterfacePPP::start END"); | 146 | qDebug("InterfacePPP::start END"); |
130 | } | 147 | } |
131 | 148 | ||
132 | void InterfacePPP::stop() | 149 | void InterfacePPP::stop() |
133 | { | 150 | { |
134 | qDebug("InterfacePPP::stop"); | 151 | qDebug("InterfacePPP::stop"); |
152 | // emit hangup_now(); | ||
153 | status = false; // not connected | ||
154 | setStatus( false ); | ||
155 | emit hangup_now(); | ||
156 | refresh(); | ||
135 | 157 | ||
136 | } | 158 | } |
137 | 159 | ||
138 | void InterfacePPP::save() | 160 | void InterfacePPP::save() |
139 | { | 161 | { |
140 | data()->save(); | 162 | data()->save(); |
141 | emit updateInterface((Interface*) this); | 163 | emit updateInterface((Interface*) this); |
142 | } | 164 | } |
165 | QString InterfacePPP::pppDev()const { | ||
166 | return modem()->pppDevice(); | ||
167 | } | ||
168 | pid_t InterfacePPP::pppPID()const{ | ||
169 | return modem()->pppPID(); | ||
170 | } | ||
171 | void InterfacePPP::setPPPDpid( pid_t pid) { | ||
172 | setStatus( true ); | ||
173 | modem()->setPPPDPid( pid ); | ||
174 | } | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h index 6eb6a69..39495c2 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.h +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -1,34 +1,40 @@ | |||
1 | #ifndef INTERFACEPPP_H | 1 | #ifndef INTERFACEPPP_H |
2 | #define INTERFACEPPP_H | 2 | #define INTERFACEPPP_H |
3 | 3 | ||
4 | #include <sys/types.h> | ||
5 | |||
4 | #include "interface.h" | 6 | #include "interface.h" |
5 | 7 | ||
6 | class PPPData; | 8 | class PPPData; |
7 | class Modem; | 9 | class Modem; |
8 | 10 | ||
9 | class InterfacePPP : public Interface | 11 | class InterfacePPP : public Interface |
10 | { | 12 | { |
11 | Q_OBJECT | 13 | Q_OBJECT |
12 | 14 | ||
13 | public: | 15 | public: |
14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); | 16 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); |
15 | 17 | ||
16 | PPPData* data(); | 18 | PPPData* data()const; |
17 | Modem* modem(); | 19 | Modem* modem()const; |
20 | QString pppDev()const; // returns the ppp device.... /dev/ppp0... | ||
21 | pid_t pppPID()const; | ||
18 | 22 | ||
19 | signals: | 23 | signals: |
20 | void begin_connect(); | 24 | void begin_connect(); |
25 | void hangup_now(); | ||
21 | 26 | ||
22 | public slots: | 27 | public slots: |
23 | virtual bool refresh(); | 28 | virtual bool refresh(); |
24 | virtual void start(); | 29 | virtual void start(); |
25 | virtual void stop(); | 30 | virtual void stop(); |
26 | void save(); | 31 | void save(); |
32 | void setPPPDpid( pid_t ); // sets the pppd pid for modem... | ||
27 | 33 | ||
28 | private: | 34 | private: |
29 | Modem *_modemPtr; | 35 | mutable Modem *_modemPtr; |
30 | PPPData *_dataPtr; | 36 | mutable PPPData *_dataPtr; |
31 | }; | 37 | }; |
32 | 38 | ||
33 | 39 | ||
34 | #endif | 40 | #endif |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index 7b5c74d..e466358 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -33,61 +33,50 @@ | |||
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | 41 | ||
42 | // #include <kaboutdata.h> | 42 | // #include <kaboutdata.h> |
43 | // #include <kapplication.h> | 43 | // #include <kapplication.h> |
44 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
45 | //#include <kcmdlineargs.h> | ||
46 | //#include <kconfig.h> | ||
47 | //#include <kdebug.h> | ||
48 | #define i18n QObject::tr | ||
49 | //#include <kiconloader.h> // For BarIcon | ||
50 | //#include <klocale.h> | ||
51 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
52 | // #include <kseparator.h> | ||
53 | // #include <kstandarddirs.h> | ||
54 | // #include <kwin.h> | ||
55 | // #include <khelpmenu.h> | ||
56 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
57 | //#include <kguiitem.h> | ||
58 | 47 | ||
59 | #include <stdlib.h> | 48 | #include <stdlib.h> |
60 | #include <errno.h> | 49 | #include <errno.h> |
61 | #include <signal.h> | 50 | #include <signal.h> |
62 | 51 | ||
63 | #include "runtests.h" | 52 | #include "runtests.h" |
64 | 53 | ||
65 | //#include "main.h" | 54 | //#include "main.h" |
66 | #include "auth.h" | 55 | #include "auth.h" |
67 | #include "modem.h" | 56 | #include "modem.h" |
68 | //#include "ppplog.h" | 57 | //#include "ppplog.h" |
69 | //#include "opener.h" | 58 | //#include "opener.h" |
70 | //#include "requester.h" | 59 | //#include "requester.h" |
71 | //#include "pppstats.h" | 60 | //#include "pppstats.h" |
72 | #include "pppdata.h" | 61 | #include "pppdata.h" |
73 | #include "general.h" | 62 | #include "general.h" |
74 | #include "interface.h" | 63 | #include "interface.h" |
75 | 64 | ||
76 | #define execute_command system | 65 | #define execute_command system |
77 | 66 | ||
78 | KPPPWidget *p_kppp = 0; | 67 | KPPPWidget *p_kppp = 0; |
79 | 68 | ||
80 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) | 69 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) |
81 | : QDialog(parent, name, modal, fl), _pppdata(pd) | 70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) |
82 | { | 71 | { |
83 | // tabWindow = 0; | 72 | // tabWindow = 0; |
84 | p_kppp = this; | 73 | p_kppp = this; |
85 | // before doing anything else, run a few tests | 74 | // before doing anything else, run a few tests |
86 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | 75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) |
87 | _pppdata->setModemDevice("/dev/modem"); | 76 | _pppdata->setModemDevice("/dev/modem"); |
88 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 77 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
89 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | 78 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); |
90 | if (!_pppdata->setAccount( i->getHardwareName() )) | 79 | if (!_pppdata->setAccount( i->getHardwareName() )) |
91 | _pppdata->setAccount( 0 ); | 80 | _pppdata->setAccount( 0 ); |
92 | 81 | ||
93 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | 82 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); |
@@ -99,130 +88,130 @@ KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *na | |||
99 | 88 | ||
100 | // installEventFilter(this); | 89 | // installEventFilter(this); |
101 | 90 | ||
102 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
103 | 92 | ||
104 | QGridLayout *l1 = new QGridLayout(3, 4); | 93 | QGridLayout *l1 = new QGridLayout(3, 4); |
105 | tl->addLayout(l1); | 94 | tl->addLayout(l1); |
106 | l1->addColSpacing(0, 10); | 95 | l1->addColSpacing(0, 10); |
107 | l1->addColSpacing(3, 10); | 96 | l1->addColSpacing(3, 10); |
108 | l1->setColStretch(1, 3); | 97 | l1->setColStretch(1, 3); |
109 | l1->setColStretch(2, 4); | 98 | l1->setColStretch(2, 4); |
110 | 99 | ||
111 | label1 = new QLabel(i18n("C&onnect to: "), this); | 100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); |
112 | l1->addWidget(label1, 0, 1); | 101 | l1->addWidget(label1, 0, 1); |
113 | 102 | ||
114 | connectto_c = new QComboBox(false, this); | 103 | connectto_c = new QComboBox(false, this); |
115 | label1->setBuddy(connectto_c); | 104 | label1->setBuddy(connectto_c); |
116 | 105 | ||
117 | connect(connectto_c, SIGNAL(activated(int)), | 106 | connect(connectto_c, SIGNAL(activated(int)), |
118 | SLOT(newdefaultaccount(int))); | 107 | SLOT(newdefaultaccount(int))); |
119 | l1->addWidget(connectto_c, 0, 2); | 108 | l1->addWidget(connectto_c, 0, 2); |
120 | 109 | ||
121 | ID_Label = new QLabel(i18n("&Login ID:"), this); | 110 | ID_Label = new QLabel(QObject::tr("&Login ID:"), this); |
122 | l1->addWidget(ID_Label, 1, 1); | 111 | l1->addWidget(ID_Label, 1, 1); |
123 | 112 | ||
124 | // the entry line for usernames | 113 | // the entry line for usernames |
125 | ID_Edit = new QLineEdit(this); | 114 | ID_Edit = new QLineEdit(this); |
126 | ID_Label->setBuddy(ID_Edit); | 115 | ID_Label->setBuddy(ID_Edit); |
127 | l1->addWidget(ID_Edit, 1, 2); | 116 | l1->addWidget(ID_Edit, 1, 2); |
128 | connect(ID_Edit, SIGNAL(returnPressed()), | 117 | connect(ID_Edit, SIGNAL(returnPressed()), |
129 | this, SLOT(enterPressedInID())); | 118 | this, SLOT(enterPressedInID())); |
130 | QString tmp = i18n("<p>Type in the username that you got from your\n" | 119 | QString tmp = QObject::tr("<p>Type in the username that you got from your\n" |
131 | "ISP. This is especially important for PAP\n" | 120 | "ISP. This is especially important for PAP\n" |
132 | "and CHAP. You may omit this when you use\n" | 121 | "and CHAP. You may omit this when you use\n" |
133 | "terminal-based or script-based authentication.\n" | 122 | "terminal-based or script-based authentication.\n" |
134 | "\n" | 123 | "\n" |
135 | "<b>Important</b>: case is important here:\n" | 124 | "<b>Important</b>: case is important here:\n" |
136 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); | 125 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); |
137 | 126 | ||
138 | QWhatsThis::add(ID_Label,tmp); | 127 | QWhatsThis::add(ID_Label,tmp); |
139 | QWhatsThis::add(ID_Edit,tmp); | 128 | QWhatsThis::add(ID_Edit,tmp); |
140 | 129 | ||
141 | PW_Label = new QLabel(i18n("&Password:"), this); | 130 | PW_Label = new QLabel(QObject::tr("&Password:"), this); |
142 | l1->addWidget(PW_Label, 2, 1); | 131 | l1->addWidget(PW_Label, 2, 1); |
143 | 132 | ||
144 | PW_Edit= new QLineEdit(this); | 133 | PW_Edit= new QLineEdit(this); |
145 | PW_Label->setBuddy(PW_Edit); | 134 | PW_Label->setBuddy(PW_Edit); |
146 | PW_Edit->setEchoMode(QLineEdit::Password); | 135 | PW_Edit->setEchoMode(QLineEdit::Password); |
147 | l1->addWidget(PW_Edit, 2, 2); | 136 | l1->addWidget(PW_Edit, 2, 2); |
148 | connect(PW_Edit, SIGNAL(returnPressed()), | 137 | connect(PW_Edit, SIGNAL(returnPressed()), |
149 | this, SLOT(enterPressedInPW())); | 138 | this, SLOT(enterPressedInPW())); |
150 | 139 | ||
151 | tmp = i18n("<p>Type in the password that you got from your\n" | 140 | tmp = QObject::tr("<p>Type in the password that you got from your\n" |
152 | "ISP. This is especially important for PAP\n" | 141 | "ISP. This is especially important for PAP\n" |
153 | "and CHAP. You may omit this when you use\n" | 142 | "and CHAP. You may omit this when you use\n" |
154 | "terminal-based or script-based authentication.\n" | 143 | "terminal-based or script-based authentication.\n" |
155 | "\n" | 144 | "\n" |
156 | "<b>Important</b>: case is important here:\n" | 145 | "<b>Important</b>: case is important here:\n" |
157 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); | 146 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); |
158 | 147 | ||
159 | QWhatsThis::add(PW_Label,tmp); | 148 | QWhatsThis::add(PW_Label,tmp); |
160 | QWhatsThis::add(PW_Edit,tmp); | 149 | QWhatsThis::add(PW_Edit,tmp); |
161 | 150 | ||
162 | QHBoxLayout *l3 = new QHBoxLayout; | 151 | QHBoxLayout *l3 = new QHBoxLayout; |
163 | tl->addSpacing(5); | 152 | tl->addSpacing(5); |
164 | tl->addLayout(l3); | 153 | tl->addLayout(l3); |
165 | tl->addSpacing(5); | 154 | tl->addSpacing(5); |
166 | l3->addSpacing(10); | 155 | l3->addSpacing(10); |
167 | log = new QCheckBox(i18n("Show lo&g window"), this); | 156 | log = new QCheckBox(QObject::tr("Show lo&g window"), this); |
168 | connect(log, SIGNAL(toggled(bool)), | 157 | connect(log, SIGNAL(toggled(bool)), |
169 | this, SLOT(log_window_toggled(bool))); | 158 | this, SLOT(log_window_toggled(bool))); |
170 | log->setChecked(_pppdata->get_show_log_window()); | 159 | log->setChecked(_pppdata->get_show_log_window()); |
171 | l3->addWidget(log); | 160 | l3->addWidget(log); |
172 | 161 | ||
173 | QWhatsThis::add(log, | 162 | QWhatsThis::add(log, |
174 | i18n("<p>This controls whether a log window is shown.\n" | 163 | QObject::tr("<p>This controls whether a log window is shown.\n" |
175 | "A log window shows the communication between\n" | 164 | "A log window shows the communication between\n" |
176 | "<i>kppp</i> and your modem. This will help you\n" | 165 | "<i>kppp</i> and your modem. This will help you\n" |
177 | "in tracking down problems.\n" | 166 | "in tracking down problems.\n" |
178 | "\n" | 167 | "\n" |
179 | "Turn it off if <i>kppp</i> routinely connects without\n" | 168 | "Turn it off if <i>kppp</i> routinely connects without\n" |
180 | "problems")); | 169 | "problems")); |
181 | 170 | ||
182 | // fline = new QSeparator( KSeparator::HLine, this); | 171 | // fline = new QSeparator( KSeparator::HLine, this); |
183 | // tl->addWidget(fline); | 172 | // tl->addWidget(fline); |
184 | 173 | ||
185 | QHBoxLayout *l2 = new QHBoxLayout(this); | 174 | QHBoxLayout *l2 = new QHBoxLayout(this); |
186 | tl->addLayout(l2); | 175 | tl->addLayout(l2); |
187 | 176 | ||
188 | int minw = 0; | 177 | int minw = 0; |
189 | quit_b = new QPushButton(i18n("&Quit"), this); | 178 | quit_b = new QPushButton(QObject::tr("&Quit"), this); |
190 | // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); | 179 | // quit_b-> setGuiItem (KGuiItem(QObject::tr("&Quit"), "exit" ) ); |
191 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); | 180 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); |
192 | if(quit_b->sizeHint().width() > minw) | 181 | if(quit_b->sizeHint().width() > minw) |
193 | minw = quit_b->sizeHint().width(); | 182 | minw = quit_b->sizeHint().width(); |
194 | 183 | ||
195 | setup_b = new QPushButton(i18n("&Setup..."), this); | 184 | setup_b = new QPushButton(QObject::tr("&Setup..."), this); |
196 | // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); | 185 | // setup_b->setGuiItem (KGuiItem(QObject::tr("&Setup...")) ); |
197 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); | 186 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); |
198 | if(setup_b->sizeHint().width() > minw) | 187 | if(setup_b->sizeHint().width() > minw) |
199 | minw = setup_b->sizeHint().width(); | 188 | minw = setup_b->sizeHint().width(); |
200 | 189 | ||
201 | 190 | ||
202 | 191 | ||
203 | // if(_pppdata->access() != KConfig::ReadWrite) | 192 | // if(_pppdata->access() != KConfig::ReadWrite) |
204 | // setup_b->setEnabled(false); | 193 | // setup_b->setEnabled(false); |
205 | 194 | ||
206 | // help_b = new QPushButton(i18n("&Help"), this); | 195 | // help_b = new QPushButton(QObject::tr("&Help"), this); |
207 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); | 196 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); |
208 | 197 | ||
209 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); | 198 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); |
210 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); | 199 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); |
211 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); | 200 | // help_b->setGuiItem (KGuiItem(QObject::tr("&Help"), "help" ) ); |
212 | 201 | ||
213 | // if(help_b->sizeHint().width() > minw) | 202 | // if(help_b->sizeHint().width() > minw) |
214 | // minw = help_b->sizeHint().width(); | 203 | // minw = help_b->sizeHint().width(); |
215 | 204 | ||
216 | connect_b = new QPushButton(i18n("&Connect"), this); | 205 | connect_b = new QPushButton(QObject::tr("&Connect"), this); |
217 | connect_b->setDefault(true); | 206 | connect_b->setDefault(true); |
218 | connect_b->setFocus(); | 207 | connect_b->setFocus(); |
219 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); | 208 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); |
220 | if(connect_b->sizeHint().width() > minw) | 209 | if(connect_b->sizeHint().width() > minw) |
221 | minw = connect_b->sizeHint().width(); | 210 | minw = connect_b->sizeHint().width(); |
222 | 211 | ||
223 | quit_b->setFixedWidth(minw); | 212 | quit_b->setFixedWidth(minw); |
224 | setup_b->setFixedWidth(minw); | 213 | setup_b->setFixedWidth(minw); |
225 | // help_b->setFixedWidth(help_b->sizeHint().width()); | 214 | // help_b->setFixedWidth(help_b->sizeHint().width()); |
226 | connect_b->setFixedWidth(minw); | 215 | connect_b->setFixedWidth(minw); |
227 | 216 | ||
228 | l2->addWidget(quit_b); | 217 | l2->addWidget(quit_b); |
@@ -277,25 +266,25 @@ KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *na | |||
277 | // m_strCmdlAccount = args->getOption("c"); | 266 | // m_strCmdlAccount = args->getOption("c"); |
278 | // m_bQuitOnDisconnect = args->isSet("q"); | 267 | // m_bQuitOnDisconnect = args->isSet("q"); |
279 | 268 | ||
280 | // if(!m_strCmdlAccount.isEmpty()) { | 269 | // if(!m_strCmdlAccount.isEmpty()) { |
281 | // m_bCmdlAccount = true; | 270 | // m_bCmdlAccount = true; |
282 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; | 271 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; |
283 | // } | 272 | // } |
284 | 273 | ||
285 | // if(m_bCmdlAccount){ | 274 | // if(m_bCmdlAccount){ |
286 | // bool result = _pppdata->setAccount(m_strCmdlAccount); | 275 | // bool result = _pppdata->setAccount(m_strCmdlAccount); |
287 | // if (!result){ | 276 | // if (!result){ |
288 | // QString string; | 277 | // QString string; |
289 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); | 278 | // string = QObject::tr("No such Account:\n%1").arg(m_strCmdlAccount); |
290 | // KMessageBox::error(this, string); | 279 | // KMessageBox::error(this, string); |
291 | // m_bCmdlAccount = false; | 280 | // m_bCmdlAccount = false; |
292 | // this->show(); | 281 | // this->show(); |
293 | // } else { | 282 | // } else { |
294 | // beginConnect(); | 283 | // beginConnect(); |
295 | // } | 284 | // } |
296 | // } else | 285 | // } else |
297 | // expandbutton(); | 286 | // expandbutton(); |
298 | // show(); | 287 | // show(); |
299 | 288 | ||
300 | 289 | ||
301 | //#define KPPP_SHOW_NEWS | 290 | //#define KPPP_SHOW_NEWS |
@@ -473,39 +462,39 @@ void KPPPWidget::sigPPPDDied() { | |||
473 | if(!_pppdata->automatic_redial()) { | 462 | if(!_pppdata->automatic_redial()) { |
474 | quit_b->setFocus(); | 463 | quit_b->setFocus(); |
475 | show(); | 464 | show(); |
476 | con_win->stopClock(); | 465 | con_win->stopClock(); |
477 | //stopAccounting(); | 466 | //stopAccounting(); |
478 | con_win->hide(); | 467 | con_win->hide(); |
479 | con->hide(); | 468 | con->hide(); |
480 | 469 | ||
481 | _pppdata->setpppdRunning(false); | 470 | _pppdata->setpppdRunning(false); |
482 | // // not in a signal handler !!! KNotifyClient::beep(); | 471 | // // not in a signal handler !!! KNotifyClient::beep(); |
483 | QString msg; | 472 | QString msg; |
484 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
485 | msg = i18n("Timeout expired while waiting for the PPP interface " | 474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " |
486 | "to come up!"); | 475 | "to come up!"); |
487 | else { | 476 | else { |
488 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); | 477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); |
489 | Modem::modem->pppdExitStatus(); | 478 | Modem::modem->pppdExitStatus(); |
490 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
491 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
492 | msg += i18n("</p><p>See 'man pppd' for an explanation of the error " | 481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " |
493 | "codes or take a look at the kppp FAQ on " | 482 | "codes or take a look at the kppp FAQ on " |
494 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
495 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
496 | } | 485 | } |
497 | } | 486 | } |
498 | 487 | ||
499 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) | 488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) |
500 | // // PPPL_ShowLog(); | 489 | // // PPPL_ShowLog(); |
501 | // } else { /* reconnect on disconnect */ | 490 | // } else { /* reconnect on disconnect */ |
502 | if (false){ | 491 | if (false){ |
503 | qDebug( "Trying to reconnect... " ); | 492 | qDebug( "Trying to reconnect... " ); |
504 | 493 | ||
505 | if(_pppdata->authMethod() == AUTH_PAP || | 494 | if(_pppdata->authMethod() == AUTH_PAP || |
506 | _pppdata->authMethod() == AUTH_CHAP || | 495 | _pppdata->authMethod() == AUTH_CHAP || |
507 | _pppdata->authMethod() == AUTH_PAPCHAP) | 496 | _pppdata->authMethod() == AUTH_PAPCHAP) |
508 | Modem::modem->setSecret(_pppdata->authMethod(), | 497 | Modem::modem->setSecret(_pppdata->authMethod(), |
509 | encodeWord(_pppdata->storedUsername()), | 498 | encodeWord(_pppdata->storedUsername()), |
510 | encodeWord(_pppdata->password())); | 499 | encodeWord(_pppdata->password())); |
511 | 500 | ||
@@ -518,25 +507,25 @@ void KPPPWidget::sigPPPDDied() { | |||
518 | } | 507 | } |
519 | } | 508 | } |
520 | _pppdata->setpppdError(0); | 509 | _pppdata->setpppdError(0); |
521 | } | 510 | } |
522 | } | 511 | } |
523 | 512 | ||
524 | // void KPPPWidget::sigChld() { | 513 | // void KPPPWidget::sigChld() { |
525 | // qDebug( "sigchld()" ); | 514 | // qDebug( "sigchld()" ); |
526 | // // pid_t id = wait(0L); | 515 | // // pid_t id = wait(0L); |
527 | // // if(id == helperPid && helperPid != -1) { | 516 | // // if(id == helperPid && helperPid != -1) { |
528 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
529 | // // helperPid = -1; | 518 | // // helperPid = -1; |
530 | // QString msg = i18n("kppp's helper process just died.\n" | 519 | // QString msg = QObject::tr("kppp's helper process just died.\n" |
531 | // "Since a further execution would be pointless, " | 520 | // "Since a further execution would be pointless, " |
532 | // "kppp will shut down now."); | 521 | // "kppp will shut down now."); |
533 | // QMessageBox::warning(0L,"error", msg); | 522 | // QMessageBox::warning(0L,"error", msg); |
534 | // //remove_pidfile(); | 523 | // //remove_pidfile(); |
535 | // exit(1); | 524 | // exit(1); |
536 | // // } | 525 | // // } |
537 | // } | 526 | // } |
538 | 527 | ||
539 | 528 | ||
540 | void KPPPWidget::newdefaultaccount(int i) { | 529 | void KPPPWidget::newdefaultaccount(int i) { |
541 | _pppdata->setDefaultAccount(connectto_c->text(i)); | 530 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
542 | _pppdata->save(); | 531 | _pppdata->save(); |
@@ -551,102 +540,102 @@ void KPPPWidget::beginConnect() { | |||
551 | // make sure to connect to the account that is selected in the combo box | 540 | // make sure to connect to the account that is selected in the combo box |
552 | // (exeption: an account given by a command line argument) | 541 | // (exeption: an account given by a command line argument) |
553 | // if(!m_bCmdlAccount) { | 542 | // if(!m_bCmdlAccount) { |
554 | // _pppdata->setAccount(connectto_c->currentText()); | 543 | // _pppdata->setAccount(connectto_c->currentText()); |
555 | // _pppdata->setPassword(PW_Edit->text()); | 544 | // _pppdata->setPassword(PW_Edit->text()); |
556 | // } else { | 545 | // } else { |
557 | _pppdata->setPassword(_pppdata->storedPassword()); | 546 | _pppdata->setPassword(_pppdata->storedPassword()); |
558 | // } | 547 | // } |
559 | 548 | ||
560 | QFileInfo info(pppdPath()); | 549 | QFileInfo info(pppdPath()); |
561 | 550 | ||
562 | if(!info.exists()){ | 551 | if(!info.exists()){ |
563 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" | 552 | QMessageBox::warning(this, "error", QObject::tr("Cannot find the PPP daemon!\n" |
564 | "Make sure that pppd is installed and " | 553 | "Make sure that pppd is installed and " |
565 | "that you have entered the correct path.")); | 554 | "that you have entered the correct path.")); |
566 | return; | 555 | return; |
567 | } | 556 | } |
568 | #if 0 | 557 | #if 0 |
569 | if(!info.isExecutable()){ | 558 | if(!info.isExecutable()){ |
570 | 559 | ||
571 | QString string; | 560 | QString string; |
572 | string = i18n("kppp cannot execute:\n %1\n" | 561 | string = QObject::tr("kppp cannot execute:\n %1\n" |
573 | "Please make sure that you have given kppp " | 562 | "Please make sure that you have given kppp " |
574 | "setuid permission and that " | 563 | "setuid permission and that " |
575 | "pppd is executable.").arg(_pppdata->pppdPath()); | 564 | "pppd is executable.").arg(_pppdata->pppdPath()); |
576 | KMessageBox::error(this, string); | 565 | KMessageBox::error(this, string); |
577 | return; | 566 | return; |
578 | 567 | ||
579 | } | 568 | } |
580 | #endif | 569 | #endif |
581 | 570 | ||
582 | QFileInfo info2(_pppdata->modemDevice()); | 571 | QFileInfo info2(_pppdata->modemDevice()); |
583 | 572 | ||
584 | if(!info2.exists()){ | 573 | if(!info2.exists()){ |
585 | QString string; | 574 | QString string; |
586 | string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " | 575 | string = QObject::tr("kppp can not find:\n %1\nPlease make sure you have setup " |
587 | "your modem device properly " | 576 | "your modem device properly " |
588 | "and/or adjust the location of the modem device on " | 577 | "and/or adjust the location of the modem device on " |
589 | "the modem tab of " | 578 | "the modem tab of " |
590 | "the setup dialog.").arg(_pppdata->modemDevice()); | 579 | "the setup dialog.").arg(_pppdata->modemDevice()); |
591 | QMessageBox::warning(this, "error", string); | 580 | QMessageBox::warning(this, "error", string); |
592 | return; | 581 | return; |
593 | } | 582 | } |
594 | 583 | ||
595 | // if this is a PAP or CHAP account, ensure that username is | 584 | // if this is a PAP or CHAP account, ensure that username is |
596 | // supplied | 585 | // supplied |
597 | if(_pppdata->authMethod() == AUTH_PAP || | 586 | if(_pppdata->authMethod() == AUTH_PAP || |
598 | _pppdata->authMethod() == AUTH_CHAP || | 587 | _pppdata->authMethod() == AUTH_CHAP || |
599 | _pppdata->authMethod() == AUTH_PAPCHAP ) { | 588 | _pppdata->authMethod() == AUTH_PAPCHAP ) { |
600 | if(ID_Edit->text().isEmpty()) { | 589 | if(ID_Edit->text().isEmpty()) { |
601 | QMessageBox::warning(this,"error", | 590 | QMessageBox::warning(this,"error", |
602 | i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); | 591 | QObject::tr("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); |
603 | return; | 592 | return; |
604 | } else { | 593 | } else { |
605 | if(!Modem::modem->setSecret(_pppdata->authMethod(), | 594 | if(!Modem::modem->setSecret(_pppdata->authMethod(), |
606 | encodeWord(_pppdata->storedUsername()), | 595 | encodeWord(_pppdata->storedUsername()), |
607 | encodeWord(_pppdata->password()))) { | 596 | encodeWord(_pppdata->password()))) { |
608 | QString s; | 597 | QString s; |
609 | s = i18n("Cannot create PAP/CHAP authentication\n" | 598 | s = QObject::tr("Cannot create PAP/CHAP authentication\n" |
610 | "file \"%1\"").arg(PAP_AUTH_FILE); | 599 | "file \"%1\"").arg(PAP_AUTH_FILE); |
611 | QMessageBox::warning(this, "error", s); | 600 | QMessageBox::warning(this, "error", s); |
612 | return; | 601 | return; |
613 | } | 602 | } |
614 | } | 603 | } |
615 | } | 604 | } |
616 | 605 | ||
617 | if (_pppdata->phonenumber().isEmpty()) { | 606 | if (_pppdata->phonenumber().isEmpty()) { |
618 | QString s = i18n("You must specify a telephone number!"); | 607 | QString s = QObject::tr("You must specify a telephone number!"); |
619 | QMessageBox::warning(this, "error", s); | 608 | QMessageBox::warning(this, "error", s); |
620 | return; | 609 | return; |
621 | } | 610 | } |
622 | 611 | ||
623 | this->hide(); | 612 | this->hide(); |
624 | 613 | ||
625 | QString tit = i18n("Connecting to: %1").arg(_pppdata->accname()); | 614 | QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname()); |
626 | // con->setCaption(tit); | 615 | // con->setCaption(tit); |
627 | 616 | ||
628 | // con->show(); | 617 | // con->show(); |
629 | 618 | ||
630 | 619 | ||
631 | emit begin_connect(); | 620 | emit begin_connect(); |
632 | } | 621 | } |
633 | 622 | ||
634 | 623 | ||
635 | void KPPPWidget::disconnect() { | 624 | void KPPPWidget::disconnect() { |
636 | if (!_pppdata->command_before_disconnect().isEmpty()) { | 625 | if (!_pppdata->command_before_disconnect().isEmpty()) { |
637 | con_win->hide(); | 626 | con_win->hide(); |
638 | con->show(); | 627 | con->show(); |
639 | con->setCaption(i18n("Disconnecting...")); | 628 | con->setCaption(QObject::tr("Disconnecting...")); |
640 | con->setMsg(i18n("Executing command before disconnection.")); | 629 | con->setMsg(QObject::tr("Executing command before disconnection.")); |
641 | 630 | ||
642 | qApp->processEvents(); | 631 | qApp->processEvents(); |
643 | QApplication::flushX(); | 632 | QApplication::flushX(); |
644 | // pid_t id = | 633 | // pid_t id = |
645 | execute_command(_pppdata->command_before_disconnect()); | 634 | execute_command(_pppdata->command_before_disconnect()); |
646 | // int i, status; | 635 | // int i, status; |
647 | 636 | ||
648 | // do { | 637 | // do { |
649 | // kapp->processEvents(); | 638 | // kapp->processEvents(); |
650 | // i = waitpid(id, &status, WNOHANG); | 639 | // i = waitpid(id, &status, WNOHANG); |
651 | // usleep(500000); | 640 | // usleep(500000); |
652 | // } while (i == 0 && errno == 0); | 641 | // } while (i == 0 && errno == 0); |
@@ -683,26 +672,26 @@ void KPPPWidget::disconnect() { | |||
683 | // } | 672 | // } |
684 | } | 673 | } |
685 | 674 | ||
686 | 675 | ||
687 | // void KPPPWidget::helpbutton() { | 676 | // void KPPPWidget::helpbutton() { |
688 | // kapp->invokeHelp(); | 677 | // kapp->invokeHelp(); |
689 | // } | 678 | // } |
690 | 679 | ||
691 | 680 | ||
692 | void KPPPWidget::quitbutton() { | 681 | void KPPPWidget::quitbutton() { |
693 | if(_pppdata->pppdRunning()) { | 682 | if(_pppdata->pppdRunning()) { |
694 | int ok = QMessageBox::warning(this, | 683 | int ok = QMessageBox::warning(this, |
695 | i18n("Exiting kPPP will close your PPP Session."), | 684 | QObject::tr("Exiting kPPP will close your PPP Session."), |
696 | i18n("Quit kPPP?")); | 685 | QObject::tr("Quit kPPP?")); |
697 | if(ok == QMessageBox::Yes) { | 686 | if(ok == QMessageBox::Yes) { |
698 | Modem::modem->killPPPDaemon(); | 687 | Modem::modem->killPPPDaemon(); |
699 | QApplication::flushX(); | 688 | QApplication::flushX(); |
700 | execute_command(_pppdata->command_on_disconnect()); | 689 | execute_command(_pppdata->command_on_disconnect()); |
701 | removedns(); | 690 | removedns(); |
702 | Modem::modem->unlockdevice(); | 691 | Modem::modem->unlockdevice(); |
703 | } | 692 | } |
704 | } else { | 693 | } else { |
705 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) | 694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
706 | _pppdata->setStoredPassword(""); | 695 | _pppdata->setStoredPassword(""); |
707 | } | 696 | } |
708 | _pppdata->save(); | 697 | _pppdata->save(); |
@@ -727,25 +716,25 @@ void KPPPWidget::quitbutton() { | |||
727 | 716 | ||
728 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); | 717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
729 | // // if(::access(d.data(), X_OK) != 0) | 718 | // // if(::access(d.data(), X_OK) != 0) |
730 | // acct = new Accounting(this, stats); | 719 | // acct = new Accounting(this, stats); |
731 | // // else | 720 | // // else |
732 | // // acct = new ExecutableAccounting(this); | 721 | // // acct = new ExecutableAccounting(this); |
733 | 722 | ||
734 | // // connect to the accounting object | 723 | // // connect to the accounting object |
735 | // connect(acct, SIGNAL(changed(QString, QString)), | 724 | // connect(acct, SIGNAL(changed(QString, QString)), |
736 | // con_win, SLOT(slotAccounting(QString, QString))); | 725 | // con_win, SLOT(slotAccounting(QString, QString))); |
737 | 726 | ||
738 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { | 727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
739 | // // QString s= i18n("Can not load the accounting " | 728 | // // QString s= QObject::tr("Can not load the accounting " |
740 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); | 729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
741 | 730 | ||
742 | // // starting the messagebox with a timer will prevent us | 731 | // // starting the messagebox with a timer will prevent us |
743 | // // from blocking the calling function ConnectWidget::timerEvent | 732 | // // from blocking the calling function ConnectWidget::timerEvent |
744 | // ruleset_load_errmsg = s; | 733 | // ruleset_load_errmsg = s; |
745 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
746 | // return; | 735 | // return; |
747 | // } | 736 | // } |
748 | // //else | 737 | // //else |
749 | // // acct->slotStart(); | 738 | // // acct->slotStart(); |
750 | // } | 739 | // } |
751 | 740 | ||
@@ -817,66 +806,66 @@ QString KPPPWidget::encodeWord(const QString &s) { | |||
817 | // { | 806 | // { |
818 | // m_bQuitOnDisconnect = b; | 807 | // m_bQuitOnDisconnect = b; |
819 | // } | 808 | // } |
820 | 809 | ||
821 | void KPPPWidget::showNews() { | 810 | void KPPPWidget::showNews() { |
822 | #ifdef KPPP_SHOW_NEWS | 811 | #ifdef KPPP_SHOW_NEWS |
823 | /* | 812 | /* |
824 | * Introduce the QuickHelp feature to new users of this version | 813 | * Introduce the QuickHelp feature to new users of this version |
825 | */ | 814 | */ |
826 | #define QUICKHELP_HINT "Hint_QuickHelp" | 815 | #define QUICKHELP_HINT "Hint_QuickHelp" |
827 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
828 | QDialog dlg(0, 0, true); | 817 | QDialog dlg(0, 0, true); |
829 | dlg.setCaption(i18n("Recent Changes in KPPP")); | 818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); |
830 | 819 | ||
831 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
832 | QHBoxLayout *l1 = new QHBoxLayout(10); | 821 | QHBoxLayout *l1 = new QHBoxLayout(10); |
833 | QVBoxLayout *l2 = new QVBoxLayout(10); | 822 | QVBoxLayout *l2 = new QVBoxLayout(10); |
834 | tl->addLayout(l1); | 823 | tl->addLayout(l1); |
835 | 824 | ||
836 | QLabel *icon = new QLabel(&dlg); | 825 | QLabel *icon = new QLabel(&dlg); |
837 | icon->setPixmap(BarIcon("exclamation")); | 826 | icon->setPixmap(BarIcon("exclamation")); |
838 | icon->setFixedSize(icon->sizeHint()); | 827 | icon->setFixedSize(icon->sizeHint()); |
839 | l1->addWidget(icon); | 828 | l1->addWidget(icon); |
840 | l1->addLayout(l2); | 829 | l1->addLayout(l2); |
841 | 830 | ||
842 | QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n" | 831 | QLabel *l = new QLabel(QObject::tr("From version 1.4.8 on, kppp has a new feature\n" |
843 | "called \"Quickhelp\". It's similar to a tooltip,\n" | 832 | "called \"Quickhelp\". It's similar to a tooltip,\n" |
844 | "but you can activate it whenever you want.\n" | 833 | "but you can activate it whenever you want.\n" |
845 | "\n" | 834 | "\n" |
846 | "To activate it, simply click on a control like\n" | 835 | "To activate it, simply click on a control like\n" |
847 | "a button or a label with the right mouse button.\n" | 836 | "a button or a label with the right mouse button.\n" |
848 | "If the item supports Quickhelp, a popup menu\n" | 837 | "If the item supports Quickhelp, a popup menu\n" |
849 | "will appear leading to Quickhelp.\n" | 838 | "will appear leading to Quickhelp.\n" |
850 | "\n" | 839 | "\n" |
851 | "To test it, right-click somewhere in this text."), | 840 | "To test it, right-click somewhere in this text."), |
852 | &dlg); | 841 | &dlg); |
853 | 842 | ||
854 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); | 843 | QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg); |
855 | cb->setFixedSize(cb->sizeHint()); | 844 | cb->setFixedSize(cb->sizeHint()); |
856 | 845 | ||
857 | KButtonBox *bbox = new KButtonBox(&dlg); | 846 | KButtonBox *bbox = new KButtonBox(&dlg); |
858 | bbox->addStretch(1); | 847 | bbox->addStretch(1); |
859 | QPushButton *ok = bbox->addButton(i18n("OK")); | 848 | QPushButton *ok = bbox->addButton(QObject::tr("OK")); |
860 | ok->setDefault(true); | 849 | ok->setDefault(true); |
861 | dlg.connect(ok, SIGNAL(clicked()), | 850 | dlg.connect(ok, SIGNAL(clicked()), |
862 | &dlg, SLOT(accept())); | 851 | &dlg, SLOT(accept())); |
863 | bbox->addStretch(1); | 852 | bbox->addStretch(1); |
864 | bbox->layout(); | 853 | bbox->layout(); |
865 | 854 | ||
866 | l2->addWidget(l); | 855 | l2->addWidget(l); |
867 | l2->addWidget(cb); | 856 | l2->addWidget(cb); |
868 | tl->addWidget(bbox); | 857 | tl->addWidget(bbox); |
869 | 858 | ||
870 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" | 859 | QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n" |
871 | "This window will stay open until you\n" | 860 | "This window will stay open until you\n" |
872 | "click a mouse button or a press a key.\n"); | 861 | "click a mouse button or a press a key.\n"); |
873 | 862 | ||
874 | QWhatsThis::add(cb,tmp); | 863 | QWhatsThis::add(cb,tmp); |
875 | QWhatsThis::add(l, tmp); | 864 | QWhatsThis::add(l, tmp); |
876 | 865 | ||
877 | dlg.exec(); | 866 | dlg.exec(); |
878 | if(cb->isChecked()) { | 867 | if(cb->isChecked()) { |
879 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); | 868 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); |
880 | _pppdata->save(); | 869 | _pppdata->save(); |
881 | } | 870 | } |
882 | } | 871 | } |
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index d23fee4..3dbc8c3 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -42,29 +42,26 @@ | |||
42 | # include <arpa/nameser.h> | 42 | # include <arpa/nameser.h> |
43 | # include <resolv.h> | 43 | # include <resolv.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifndef _PATH_RESCONF | 46 | #ifndef _PATH_RESCONF |
47 | #define _PATH_RESCONF "/etc/resolv.conf" | 47 | #define _PATH_RESCONF "/etc/resolv.conf" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #define strlcpy strcpy | 50 | #define strlcpy strcpy |
51 | #include "auth.h" | 51 | #include "auth.h" |
52 | #include "modem.h" | 52 | #include "modem.h" |
53 | #include "pppdata.h" | 53 | #include "pppdata.h" |
54 | //#include <klocale.h> | ||
55 | #define i18n QObject::tr | ||
56 | #define qError qDebug | 54 | #define qError qDebug |
57 | //#include <kdebug.h> | 55 | |
58 | //#include <config.h> | ||
59 | 56 | ||
60 | #define MY_ASSERT(x) if (!(x)) { \ | 57 | #define MY_ASSERT(x) if (!(x)) { \ |
61 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 58 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ |
62 | exit(1); } | 59 | exit(1); } |
63 | 60 | ||
64 | 61 | ||
65 | static sigjmp_buf jmp_buffer; | 62 | static sigjmp_buf jmp_buffer; |
66 | 63 | ||
67 | //Modem *Modem::modem = 0; | 64 | //Modem *Modem::modem = 0; |
68 | 65 | ||
69 | 66 | ||
70 | const char* pppdPath() { | 67 | const char* pppdPath() { |
@@ -90,25 +87,25 @@ const char* pppdPath() { | |||
90 | } | 87 | } |
91 | 88 | ||
92 | return pppdPath; | 89 | return pppdPath; |
93 | } | 90 | } |
94 | 91 | ||
95 | 92 | ||
96 | Modem::Modem( PPPData* pd ) | 93 | Modem::Modem( PPPData* pd ) |
97 | { | 94 | { |
98 | _pppdata = pd; | 95 | _pppdata = pd; |
99 | modemfd = -1; | 96 | modemfd = -1; |
100 | _pppdExitStatus = -1; | 97 | _pppdExitStatus = -1; |
101 | pppdPid = -1; | 98 | pppdPid = -1; |
102 | sn = 0L; | 99 | sn = m_modemDebug = 0L; |
103 | data_mode = false; | 100 | data_mode = false; |
104 | modem_is_locked = false; | 101 | modem_is_locked = false; |
105 | lockfile[0] = '\0'; | 102 | lockfile[0] = '\0'; |
106 | device = "/dev/modem"; | 103 | device = "/dev/modem"; |
107 | } | 104 | } |
108 | 105 | ||
109 | 106 | ||
110 | Modem::~Modem() | 107 | Modem::~Modem() |
111 | { | 108 | { |
112 | } | 109 | } |
113 | 110 | ||
114 | 111 | ||
@@ -160,56 +157,56 @@ speed_t Modem::modemspeed() { | |||
160 | break; | 157 | break; |
161 | } | 158 | } |
162 | } | 159 | } |
163 | 160 | ||
164 | bool Modem::opentty() { | 161 | bool Modem::opentty() { |
165 | // int flags; | 162 | // int flags; |
166 | 163 | ||
167 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
168 | close(modemfd); | 165 | close(modemfd); |
169 | device = _pppdata->modemDevice(); | 166 | device = _pppdata->modemDevice(); |
170 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
171 | qDebug("error opening modem device !"); | 168 | qDebug("error opening modem device !"); |
172 | errmsg = i18n("Unable to open modem."); | 169 | errmsg = QObject::tr("Unable to open modem."); |
173 | return false; | 170 | return false; |
174 | } | 171 | } |
175 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
176 | //} | 173 | //} |
177 | 174 | ||
178 | #if 0 | 175 | #if 0 |
179 | if(_pppdata->UseCDLine()) { | 176 | if(_pppdata->UseCDLine()) { |
180 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
181 | errmsg = i18n("Unable to detect state of CD line."); | 178 | errmsg = QObject::tr("Unable to detect state of CD line."); |
182 | ::close(modemfd); | 179 | ::close(modemfd); |
183 | modemfd = -1; | 180 | modemfd = -1; |
184 | return false; | 181 | return false; |
185 | } | 182 | } |
186 | if ((flags&TIOCM_CD) == 0) { | 183 | if ((flags&TIOCM_CD) == 0) { |
187 | errmsg = i18n("The modem is not ready."); | 184 | errmsg = QObject::tr("The modem is not ready."); |
188 | ::close(modemfd); | 185 | ::close(modemfd); |
189 | modemfd = -1; | 186 | modemfd = -1; |
190 | return false; | 187 | return false; |
191 | } | 188 | } |
192 | } | 189 | } |
193 | #endif | 190 | #endif |
194 | 191 | ||
195 | tcdrain (modemfd); | 192 | tcdrain (modemfd); |
196 | tcflush (modemfd, TCIOFLUSH); | 193 | tcflush (modemfd, TCIOFLUSH); |
197 | 194 | ||
198 | if(tcgetattr(modemfd, &tty) < 0){ | 195 | if(tcgetattr(modemfd, &tty) < 0){ |
199 | // this helps in some cases | 196 | // this helps in some cases |
200 | tcsendbreak(modemfd, 0); | 197 | tcsendbreak(modemfd, 0); |
201 | sleep(1); | 198 | sleep(1); |
202 | if(tcgetattr(modemfd, &tty) < 0){ | 199 | if(tcgetattr(modemfd, &tty) < 0){ |
203 | errmsg = i18n("The modem is busy."); | 200 | errmsg = QObject::tr("The modem is busy."); |
204 | ::close(modemfd); | 201 | ::close(modemfd); |
205 | modemfd = -1; | 202 | modemfd = -1; |
206 | return false; | 203 | return false; |
207 | } | 204 | } |
208 | } | 205 | } |
209 | 206 | ||
210 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 207 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
211 | 208 | ||
212 | initial_tty = tty; | 209 | initial_tty = tty; |
213 | 210 | ||
214 | tty.c_cc[VMIN] = 0; // nonblocking | 211 | tty.c_cc[VMIN] = 0; // nonblocking |
215 | tty.c_cc[VTIME] = 0; | 212 | tty.c_cc[VTIME] = 0; |
@@ -236,43 +233,43 @@ bool Modem::opentty() { | |||
236 | } | 233 | } |
237 | else { | 234 | else { |
238 | tty.c_cflag &= ~CRTSCTS; | 235 | tty.c_cflag &= ~CRTSCTS; |
239 | tty.c_iflag &= ~(IXON | IXOFF); | 236 | tty.c_iflag &= ~(IXON | IXOFF); |
240 | } | 237 | } |
241 | 238 | ||
242 | cfsetospeed(&tty, modemspeed()); | 239 | cfsetospeed(&tty, modemspeed()); |
243 | cfsetispeed(&tty, modemspeed()); | 240 | cfsetispeed(&tty, modemspeed()); |
244 | 241 | ||
245 | tcdrain(modemfd); | 242 | tcdrain(modemfd); |
246 | 243 | ||
247 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 244 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
248 | errmsg = i18n("The modem is busy."); | 245 | errmsg = QObject::tr("The modem is busy."); |
249 | ::close(modemfd); | 246 | ::close(modemfd); |
250 | modemfd=-1; | 247 | modemfd=-1; |
251 | return false; | 248 | return false; |
252 | } | 249 | } |
253 | 250 | ||
254 | errmsg = i18n("Modem Ready."); | 251 | errmsg = QObject::tr("Modem Ready."); |
255 | return true; | 252 | return true; |
256 | } | 253 | } |
257 | 254 | ||
258 | 255 | ||
259 | bool Modem::closetty() { | 256 | bool Modem::closetty() { |
260 | if(modemfd >=0 ) { | 257 | if(modemfd >=0 ) { |
261 | stop(); | 258 | stop(); |
262 | /* discard data not read or transmitted */ | 259 | /* discard data not read or transmitted */ |
263 | tcflush(modemfd, TCIOFLUSH); | 260 | tcflush(modemfd, TCIOFLUSH); |
264 | 261 | ||
265 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 262 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
266 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); | 263 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); |
267 | ::close(modemfd); | 264 | ::close(modemfd); |
268 | modemfd = -1; | 265 | modemfd = -1; |
269 | return false; | 266 | return false; |
270 | } | 267 | } |
271 | ::close(modemfd); | 268 | ::close(modemfd); |
272 | modemfd = -1; | 269 | modemfd = -1; |
273 | } | 270 | } |
274 | 271 | ||
275 | return true; | 272 | return true; |
276 | } | 273 | } |
277 | 274 | ||
278 | 275 | ||
@@ -404,25 +401,25 @@ bool Modem::hangup() { | |||
404 | signal(SIGALRM, alarm_handler); | 401 | signal(SIGALRM, alarm_handler); |
405 | alarm(2); | 402 | alarm(2); |
406 | 403 | ||
407 | tcsendbreak(modemfd, 0); | 404 | tcsendbreak(modemfd, 0); |
408 | 405 | ||
409 | alarm(0); | 406 | alarm(0); |
410 | signal(SIGALRM, SIG_IGN); | 407 | signal(SIGALRM, SIG_IGN); |
411 | } else { | 408 | } else { |
412 | // we reach this point if the alarm handler got called | 409 | // we reach this point if the alarm handler got called |
413 | closetty(); | 410 | closetty(); |
414 | close(modemfd); | 411 | close(modemfd); |
415 | modemfd = -1; | 412 | modemfd = -1; |
416 | errmsg = i18n("The modem does not respond."); | 413 | errmsg = QObject::tr("The modem does not respond."); |
417 | return false; | 414 | return false; |
418 | } | 415 | } |
419 | 416 | ||
420 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | 417 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. |
421 | tcgetattr(modemfd, &temptty); | 418 | tcgetattr(modemfd, &temptty); |
422 | cfsetospeed(&temptty, B0); | 419 | cfsetospeed(&temptty, B0); |
423 | cfsetispeed(&temptty, B0); | 420 | cfsetispeed(&temptty, B0); |
424 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 421 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
425 | #else | 422 | #else |
426 | int modemstat; | 423 | int modemstat; |
427 | ioctl(modemfd, TIOCMGET, &modemstat); | 424 | ioctl(modemfd, TIOCMGET, &modemstat); |
428 | modemstat &= ~TIOCM_DTR; | 425 | modemstat &= ~TIOCM_DTR; |
@@ -546,25 +543,25 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
546 | // len = rrx[RXMAX-1].matchedLength(); | 543 | // len = rrx[RXMAX-1].matchedLength(); |
547 | sub = sub.mid(idx, len); | 544 | sub = sub.mid(idx, len); |
548 | result = sub.toInt(); | 545 | result = sub.toInt(); |
549 | if(result > 0) { | 546 | if(result > 0) { |
550 | tx = result; | 547 | tx = result; |
551 | break; | 548 | break; |
552 | } | 549 | } |
553 | } | 550 | } |
554 | } | 551 | } |
555 | } | 552 | } |
556 | 553 | ||
557 | if(rx == -1 && tx == -1) | 554 | if(rx == -1 && tx == -1) |
558 | result = i18n("Unknown speed"); | 555 | result = QObject::tr("Unknown speed"); |
559 | else if(tx == -1) | 556 | else if(tx == -1) |
560 | result.setNum(rx); | 557 | result.setNum(rx); |
561 | else if(rx == -1) // should not happen | 558 | else if(rx == -1) // should not happen |
562 | result.setNum(tx); | 559 | result.setNum(tx); |
563 | else | 560 | else |
564 | result.sprintf("%d/%d", rx, tx); | 561 | result.sprintf("%d/%d", rx, tx); |
565 | 562 | ||
566 | qDebug( "The parsed result is: %s", result.latin1()); | 563 | qDebug( "The parsed result is: %s", result.latin1()); |
567 | 564 | ||
568 | return result; | 565 | return result; |
569 | } | 566 | } |
570 | 567 | ||
@@ -868,80 +865,108 @@ int checkForInterface() | |||
868 | } | 865 | } |
869 | 866 | ||
870 | bool Modem::execpppd(const char *arguments) { | 867 | bool Modem::execpppd(const char *arguments) { |
871 | char buf[MAX_CMDLEN]; | 868 | char buf[MAX_CMDLEN]; |
872 | char *args[MaxArgs]; | 869 | char *args[MaxArgs]; |
873 | pid_t pgrpid; | 870 | pid_t pgrpid; |
874 | 871 | ||
875 | if(modemfd<0) | 872 | if(modemfd<0) |
876 | return false; | 873 | return false; |
877 | 874 | ||
878 | _pppdExitStatus = -1; | 875 | _pppdExitStatus = -1; |
879 | 876 | ||
877 | (void)::pipe( m_pppdLOG ); | ||
878 | |||
880 | switch(pppdPid = fork()) | 879 | switch(pppdPid = fork()) |
881 | { | 880 | { |
882 | case -1: | 881 | case -1: |
883 | fprintf(stderr,"In parent: fork() failed\n"); | 882 | fprintf(stderr,"In parent: fork() failed\n"); |
883 | ::close( m_pppdLOG[0] ); | ||
884 | ::close( m_pppdLOG[1] ); | ||
884 | return false; | 885 | return false; |
885 | break; | 886 | break; |
886 | 887 | ||
887 | case 0: | 888 | case 0: |
888 | // let's parse the arguments the user supplied into UNIX suitable form | 889 | // let's parse the arguments the user supplied into UNIX suitable form |
889 | // that is a list of pointers each pointing to exactly one word | 890 | // that is a list of pointers each pointing to exactly one word |
890 | strlcpy(buf, arguments); | 891 | strlcpy(buf, arguments); |
891 | parseargs(buf, args); | 892 | parseargs(buf, args); |
892 | // become a session leader and let /dev/ttySx | 893 | // become a session leader and let /dev/ttySx |
893 | // be the controlling terminal. | 894 | // be the controlling terminal. |
894 | pgrpid = setsid(); | 895 | pgrpid = setsid(); |
895 | #ifdef TIOCSCTTY | 896 | #ifdef TIOCSCTTY |
896 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) | 897 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) |
897 | fprintf(stderr, "ioctl() failed.\n"); | 898 | fprintf(stderr, "ioctl() failed.\n"); |
898 | #elif defined (TIOCSPGRP) | 899 | #elif defined (TIOCSPGRP) |
899 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) | 900 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) |
900 | fprintf(stderr, "ioctl() failed.\n"); | 901 | fprintf(stderr, "ioctl() failed.\n"); |
901 | #endif | 902 | #endif |
902 | if(tcsetpgrp(modemfd, pgrpid)<0) | 903 | if(tcsetpgrp(modemfd, pgrpid)<0) |
903 | fprintf(stderr, "tcsetpgrp() failed.\n"); | 904 | fprintf(stderr, "tcsetpgrp() failed.\n"); |
904 | 905 | ||
906 | ::close( m_pppdLOG[0] ); | ||
907 | ::setenv( "LANG", "C", 1 ); // overwrite | ||
908 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 | ||
905 | dup2(modemfd, 0); | 909 | dup2(modemfd, 0); |
906 | dup2(modemfd, 1); | 910 | dup2(modemfd, 1); |
907 | 911 | ||
912 | |||
908 | switch (checkForInterface()) { | 913 | switch (checkForInterface()) { |
909 | case 1: | 914 | case 1: |
910 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | 915 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); |
911 | break; | 916 | break; |
912 | case -1: | 917 | case -1: |
913 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
914 | break; | 919 | break; |
915 | case 0: | 920 | case 0: |
916 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 921 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
917 | break; | 922 | break; |
918 | } | 923 | } |
919 | 924 | ||
920 | execve(pppdPath(), args, 0L); | 925 | execve(pppdPath(), args, 0L); |
921 | _exit(0); | 926 | _exit(0); |
922 | break; | 927 | break; |
923 | 928 | ||
924 | default: | 929 | default: |
925 | qDebug("In parent: pppd pid %d\n",pppdPid); | 930 | qDebug("In parent: pppd pid %d\n",pppdPid); |
926 | close(modemfd); | 931 | close(modemfd); |
932 | |||
933 | ::close( m_pppdLOG[1] ); | ||
934 | // set it to nonblocking io | ||
935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | ||
936 | |||
937 | if ( !(flag & O_NONBLOCK) ) { | ||
938 | qDebug("Setting nonblocking io"); | ||
939 | flag |= O_NONBLOCK; | ||
940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | ||
941 | } | ||
942 | |||
943 | delete m_modemDebug; | ||
944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | ||
945 | connect(m_modemDebug, SIGNAL(activated(int) ), | ||
946 | this, SLOT(slotModemDebug(int) ) ); | ||
947 | |||
927 | modemfd = -1; | 948 | modemfd = -1; |
949 | m_pppdDev = QString::fromLatin1("ppp0"); | ||
928 | return true; | 950 | return true; |
929 | break; | 951 | break; |
930 | } | 952 | } |
931 | } | 953 | } |
932 | 954 | ||
933 | 955 | ||
934 | bool Modem::killpppd() { | 956 | bool Modem::killpppd() { |
957 | qDebug("In killpppd and pid is %d", pppdPid ); | ||
935 | if(pppdPid > 0) { | 958 | if(pppdPid > 0) { |
959 | delete m_modemDebug; | ||
960 | m_modemDebug = 0; | ||
936 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | 961 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); |
937 | if(kill(pppdPid, SIGTERM) < 0) { | 962 | if(kill(pppdPid, SIGTERM) < 0) { |
938 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | 963 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); |
939 | if(kill(pppdPid, SIGKILL) < 0) { | 964 | if(kill(pppdPid, SIGKILL) < 0) { |
940 | qDebug("Error killing %d\n", pppdPid); | 965 | qDebug("Error killing %d\n", pppdPid); |
941 | return false; | 966 | return false; |
942 | } | 967 | } |
943 | } | 968 | } |
944 | } | 969 | } |
945 | return true; | 970 | return true; |
946 | } | 971 | } |
947 | 972 | ||
@@ -1012,12 +1037,44 @@ int Modem::openResolv(int flags) | |||
1012 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1013 | qDebug("error opening resolv.conf!"); | 1038 | qDebug("error opening resolv.conf!"); |
1014 | fd = open(DEVNULL, O_RDONLY); | 1039 | fd = open(DEVNULL, O_RDONLY); |
1015 | } | 1040 | } |
1016 | return fd; | 1041 | return fd; |
1017 | } | 1042 | } |
1018 | 1043 | ||
1019 | bool Modem::setHostname(const QString & name) | 1044 | bool Modem::setHostname(const QString & name) |
1020 | { | 1045 | { |
1021 | return sethostname(name, name.length()) == 0; | 1046 | return sethostname(name, name.length()) == 0; |
1022 | } | 1047 | } |
1023 | 1048 | ||
1049 | QString Modem::pppDevice()const { | ||
1050 | return m_pppdDev; | ||
1051 | } | ||
1052 | void Modem::setPPPDevice( const QString& dev ) { | ||
1053 | m_pppdDev = dev; | ||
1054 | } | ||
1055 | pid_t Modem::pppPID()const { | ||
1056 | return pppdPid; | ||
1057 | } | ||
1058 | void Modem::setPPPDPid( pid_t pid ) { | ||
1059 | qDebug("Modem setting pid"); | ||
1060 | _pppdExitStatus = -1; | ||
1061 | pppdPid = pid; | ||
1062 | modemfd = -1; | ||
1063 | } | ||
1064 | void Modem::slotModemDebug(int fd) { | ||
1065 | char buf[2049]; | ||
1066 | int len; | ||
1067 | |||
1068 | // read in pppd data look for Using interface | ||
1069 | // then read the interface | ||
1070 | // we limit to 10 device now 0-9 | ||
1071 | if((len = ::read(fd, buf, 2048)) > 0) { | ||
1072 | buf[len+1] = '\0'; | ||
1073 | char *found; | ||
1074 | if ( (found = ::strstr(buf, "Using interface ") ) ) { | ||
1075 | found += 16; | ||
1076 | m_pppdDev = QString::fromLatin1(found, 5 ); | ||
1077 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); | ||
1078 | } | ||
1079 | } | ||
1080 | } | ||
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h index 103cbeb..8ecc354 100644 --- a/noncore/settings/networksettings/ppp/modem.h +++ b/noncore/settings/networksettings/ppp/modem.h | |||
@@ -40,24 +40,26 @@ class PPPData; | |||
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(PPPData*); | 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 | void save(); | ||
53 | |||
52 | bool opentty(); | 54 | bool opentty(); |
53 | bool closetty(); | 55 | bool closetty(); |
54 | bool hangup(); | 56 | bool hangup(); |
55 | bool writeChar(unsigned char); | 57 | bool writeChar(unsigned char); |
56 | bool writeLine(const char *); | 58 | bool writeLine(const char *); |
57 | bool dataMode() const { return data_mode; } | 59 | bool dataMode() const { return data_mode; } |
58 | void setDataMode(bool set) { data_mode = set; } | 60 | void setDataMode(bool set) { data_mode = set; } |
59 | const QString modemMessage(); | 61 | const QString modemMessage(); |
60 | speed_t modemspeed(); | 62 | speed_t modemspeed(); |
61 | static QString parseModemSpeed(const QString &); | 63 | static QString parseModemSpeed(const QString &); |
62 | void notify(const QObject *, const char *); | 64 | void notify(const QObject *, const char *); |
63 | void stop(); | 65 | void stop(); |
@@ -65,56 +67,65 @@ public: | |||
65 | 67 | ||
66 | int lockdevice(); | 68 | int lockdevice(); |
67 | void unlockdevice(); | 69 | void unlockdevice(); |
68 | 70 | ||
69 | bool setSecret(int,const char*,const char*); | 71 | bool setSecret(int,const char*,const char*); |
70 | bool removeSecret(int); | 72 | bool removeSecret(int); |
71 | void killPPPDaemon(); | 73 | void killPPPDaemon(); |
72 | int pppdExitStatus(); | 74 | int pppdExitStatus(); |
73 | bool execPPPDaemon(const QString & arguments); | 75 | bool execPPPDaemon(const QString & arguments); |
74 | int openResolv(int flags); | 76 | int openResolv(int flags); |
75 | bool setHostname(const QString & name); | 77 | bool setHostname(const QString & name); |
76 | 78 | ||
79 | QString pppDevice()const; | ||
80 | void setPPPDevice( const QString& ); | ||
81 | pid_t pppPID()const; | ||
82 | void setPPPDPid( pid_t ); | ||
83 | |||
77 | public: | 84 | public: |
78 | enum Auth { PAP = 1, CHAP }; | 85 | enum Auth { PAP = 1, CHAP }; |
79 | // static Modem *modem; | 86 | // static Modem *modem; |
80 | int lastStatus; | 87 | int lastStatus; |
81 | 88 | ||
82 | signals: | 89 | signals: |
83 | void charWaiting(unsigned char); | 90 | void charWaiting(unsigned char); |
84 | 91 | ||
85 | private slots: | 92 | private slots: |
86 | void startNotifier(); | 93 | void startNotifier(); |
87 | void stopNotifier(); | 94 | void stopNotifier(); |
88 | void readtty(int); | 95 | void readtty(int); |
96 | void slotModemDebug(int); | ||
89 | 97 | ||
90 | private: | 98 | private: |
91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; | 99 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; |
92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; | 100 | enum { Original=0x100, New=0x200, Old=0x400 } Version; |
93 | 101 | ||
94 | const char* authFile(Auth method, int version = Original ); | 102 | const char* authFile(Auth method, int version = Original ); |
95 | bool createAuthFile(Auth method,const char *username,const char *password); | 103 | bool createAuthFile(Auth method,const char *username,const char *password); |
96 | bool removeAuthFile(Auth method); | 104 | bool removeAuthFile(Auth method); |
97 | bool execpppd(const char *arguments); | 105 | bool execpppd(const char *arguments); |
98 | bool killpppd(); | 106 | bool killpppd(); |
99 | void parseargs(char* buf, char** args); | 107 | void parseargs(char* buf, char** args); |
100 | void escape_to_command_mode(); | 108 | void escape_to_command_mode(); |
101 | int openLockfile(QString,int); | 109 | int openLockfile(QString,int); |
102 | 110 | ||
103 | private: | 111 | private: |
104 | QString device; | 112 | QString device; |
105 | QString lockfile; | 113 | QString lockfile; |
106 | int modemfd; | 114 | int modemfd; |
107 | int pppdPid; | 115 | int pppdPid; |
108 | int _pppdExitStatus; | 116 | int _pppdExitStatus; |
109 | QSocketNotifier *sn; | 117 | QSocketNotifier *sn; |
118 | QSocketNotifier *m_modemDebug; | ||
110 | bool data_mode; | 119 | bool data_mode; |
111 | QString errmsg; | 120 | QString errmsg; |
112 | struct termios initial_tty; | 121 | struct termios initial_tty; |
113 | struct termios tty; | 122 | struct termios tty; |
114 | bool modem_is_locked; | 123 | bool modem_is_locked; |
115 | PPPData *_pppdata; | 124 | PPPData *_pppdata; |
125 | int m_pppdLOG[2]; | ||
126 | QString m_pppdDev; | ||
116 | }; | 127 | }; |
117 | 128 | ||
118 | #endif | 129 | #endif |
119 | 130 | ||
120 | 131 | ||
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp index 1d9db6e..e797795 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.cpp +++ b/noncore/settings/networksettings/ppp/modemcmds.cpp | |||
@@ -18,223 +18,233 @@ | |||
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 <qscrollview.h> | ||
31 | #include <qapplication.h> | ||
30 | #include <stdlib.h> | 32 | #include <stdlib.h> |
31 | //#include <kapplication.h> // for getMiniIcon() | ||
32 | //#include <klocale.h> | ||
33 | #define i18n QObject::tr | ||
34 | #include "modemcmds.h" | 33 | #include "modemcmds.h" |
35 | #include "pppdata.h" | 34 | #include "pppdata.h" |
36 | //#include <kwin.h> | ||
37 | 35 | ||
38 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); | 36 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); |
39 | 37 | ||
40 | // a little trick to make the label look like a disabled lineedit | 38 | // 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); | 39 | #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 | 40 | ||
43 | ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name) | 41 | ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name , bool modal, WFlags f) |
44 | : QDialog(parent, name, true ), _pppdata(pd) | 42 | : QDialog( parent, name, modal, f ), _pppdata(pd) |
45 | { | 43 | { |
46 | setCaption(i18n("Edit Modem Commands")); | 44 | setCaption(QObject::tr("Edit Modem Commands")); |
47 | 45 | ||
48 | const int GRIDROWS = 22; | 46 | const int GRIDROWS = 22; |
49 | int row = 0; | 47 | int row = 0; |
50 | 48 | ||
49 | QVBoxLayout *main = new QVBoxLayout( this ); | ||
50 | QScrollView *sv = new QScrollView( this ); | ||
51 | QWidget *mainW = new QWidget( sv->viewport() ); | ||
52 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
53 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
54 | sv->setFrameShape( QFrame::NoFrame ); | ||
55 | sv->addChild( mainW ); | ||
56 | main->addWidget( sv ); | ||
57 | // evil hack | ||
58 | mainW->setMaximumWidth( QApplication::desktop()->width() - 10 ); | ||
59 | |||
51 | // toplevel layout | 60 | // toplevel layout |
52 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); | 61 | QVBoxLayout *tl = new QVBoxLayout( mainW, 10, 4); |
53 | 62 | ||
54 | // add grid + frame | 63 | // add grid + frame |
55 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); | 64 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); |
56 | tl->addLayout(l1); | 65 | tl->addLayout(l1); |
57 | box = new QGroupBox(this, "box"); | 66 | box = new QGroupBox(mainW, "box"); |
67 | box->setMargin( 0 ); | ||
58 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); | 68 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); |
59 | 69 | ||
60 | // put slider and label into a separate H-Box | 70 | // put slider and label into a separate H-Box |
61 | QHBoxLayout *l2 = new QHBoxLayout; | 71 | QHBoxLayout *l2 = new QHBoxLayout; |
62 | l1->addLayout(l2, row, 2); | 72 | l1->addLayout(l2, row, 2); |
63 | lpreinitslider = new QLabel("MMMM", this); | 73 | lpreinitslider = new QLabel("MMMM", mainW); |
64 | FORMATSLIDERLABEL(lpreinitslider); | 74 | FORMATSLIDERLABEL(lpreinitslider); |
65 | 75 | ||
66 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, | 76 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, |
67 | QSlider::Horizontal, this); | 77 | QSlider::Horizontal, mainW); |
68 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); | 78 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); |
69 | connect(preinitslider, SIGNAL(valueChanged(int)), | 79 | connect(preinitslider, SIGNAL(valueChanged(int)), |
70 | lpreinitslider, SLOT(setNum(int))); | 80 | lpreinitslider, SLOT(setNum(int))); |
71 | l2->addWidget(lpreinitslider, 0); | 81 | l2->addWidget(lpreinitslider, 0); |
72 | l2->addWidget(preinitslider, 1); | 82 | l2->addWidget(preinitslider, 1); |
73 | 83 | ||
74 | lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); | 84 | lpreinit = new QLabel(QObject::tr("Pre-init delay (sec/100):"), mainW); |
75 | l1->addWidget(lpreinit, row++, 1); | 85 | l1->addWidget(lpreinit, row++, 1); |
76 | 86 | ||
77 | for(int i = 0; i < PPPData::NumInitStrings; i++) { | 87 | for(int i = 0; i < PPPData::NumInitStrings; i++) { |
78 | initstr[i] = new QLineEdit(this); | 88 | initstr[i] = new QLineEdit(mainW); |
79 | QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), | 89 | QLabel *initLabel = new QLabel(QObject::tr("Initialization string %1:").arg(i + 1), |
80 | this); | 90 | mainW); |
81 | ADJUSTEDIT(initstr[i]); | 91 | ADJUSTEDIT(initstr[i]); |
82 | l1->addWidget(initLabel, row, 1); | 92 | l1->addWidget(initLabel, row, 1); |
83 | l1->addWidget(initstr[i], row++, 2); | 93 | l1->addWidget(initstr[i], row++, 2); |
84 | } | 94 | } |
85 | 95 | ||
86 | QHBoxLayout *l3 = new QHBoxLayout; | 96 | QHBoxLayout *l3 = new QHBoxLayout; |
87 | l1->addLayout(l3, row, 2); | 97 | l1->addLayout(l3, row, 2); |
88 | linitslider = new QLabel("MMMM", this); | 98 | linitslider = new QLabel("MMMM", mainW); |
89 | FORMATSLIDERLABEL(linitslider); | 99 | FORMATSLIDERLABEL(linitslider); |
90 | QSlider *initslider = new QSlider(1, 300, 1, 0, | 100 | QSlider *initslider = new QSlider(1, 300, 1, 0, |
91 | QSlider::Horizontal, this); | 101 | QSlider::Horizontal, mainW); |
92 | // initslider->setFixedHeight(initslider->sizeHint().height()); | 102 | // initslider->setFixedHeight(initslider->sizeHint().height()); |
93 | connect(initslider, SIGNAL(valueChanged(int)), | 103 | connect(initslider, SIGNAL(valueChanged(int)), |
94 | linitslider, SLOT(setNum(int))); | 104 | linitslider, SLOT(setNum(int))); |
95 | l3->addWidget(linitslider, 0); | 105 | l3->addWidget(linitslider, 0); |
96 | l3->addWidget(initslider, 1); | 106 | l3->addWidget(initslider, 1); |
97 | 107 | ||
98 | label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); | 108 | label3 = new QLabel(QObject::tr("Post-init delay (sec/100):"), mainW); |
99 | l1->addWidget(label3, row++, 1); | 109 | l1->addWidget(label3, row++, 1); |
100 | 110 | ||
101 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ | 111 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ |
102 | QHBoxLayout *l4 = new QHBoxLayout; | 112 | QHBoxLayout *l4 = new QHBoxLayout; |
103 | l1->addLayout(l4, row, 2); | 113 | l1->addLayout(l4, row, 2); |
104 | ldurationslider = new QLabel("MMMM", this); | 114 | ldurationslider = new QLabel("MMMM", mainW); |
105 | FORMATSLIDERLABEL(ldurationslider); | 115 | FORMATSLIDERLABEL(ldurationslider); |
106 | QSlider *durationslider = new QSlider(1, 255, 1, 0, | 116 | QSlider *durationslider = new QSlider(1, 255, 1, 0, |
107 | QSlider::Horizontal, this); | 117 | QSlider::Horizontal, mainW); |
108 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); | 118 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); |
109 | connect(durationslider, SIGNAL(valueChanged(int)), | 119 | connect(durationslider, SIGNAL(valueChanged(int)), |
110 | ldurationslider, SLOT(setNum(int))); | 120 | ldurationslider, SLOT(setNum(int))); |
111 | l4->addWidget(ldurationslider, 0); | 121 | l4->addWidget(ldurationslider, 0); |
112 | l4->addWidget(durationslider, 1); | 122 | l4->addWidget(durationslider, 1); |
113 | 123 | ||
114 | lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); | 124 | lduration = new QLabel(QObject::tr("Dialing speed (sec/100):"), mainW); |
115 | l1->addWidget(lduration, row++, 1); | 125 | l1->addWidget(lduration, row++, 1); |
116 | 126 | ||
117 | 127 | ||
118 | initresp = new QLineEdit(this); | 128 | initresp = new QLineEdit(mainW); |
119 | label2 = new QLabel(i18n("Init response:"), this); | 129 | label2 = new QLabel(QObject::tr("Init response:"), mainW); |
120 | ADJUSTEDIT(initresp); | 130 | ADJUSTEDIT(initresp); |
121 | l1->addWidget(label2, row, 1); | 131 | l1->addWidget(label2, row, 1); |
122 | l1->addWidget(initresp, row++, 2); | 132 | l1->addWidget(initresp, row++, 2); |
123 | 133 | ||
124 | nodetectdialtone = new QLineEdit(this); | 134 | nodetectdialtone = new QLineEdit(mainW); |
125 | lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); | 135 | lnodetectdialtone = new QLabel(QObject::tr("No dial tone detection:"), mainW); |
126 | ADJUSTEDIT(nodetectdialtone); | 136 | ADJUSTEDIT(nodetectdialtone); |
127 | l1->addWidget(lnodetectdialtone, row, 1); | 137 | l1->addWidget(lnodetectdialtone, row, 1); |
128 | l1->addWidget(nodetectdialtone, row++, 2); | 138 | l1->addWidget(nodetectdialtone, row++, 2); |
129 | 139 | ||
130 | dialstr = new QLineEdit(this); | 140 | dialstr = new QLineEdit(mainW); |
131 | label4 = new QLabel(i18n("Dial string:"),this); | 141 | label4 = new QLabel(QObject::tr("Dial string:"),mainW); |
132 | ADJUSTEDIT(dialstr); | 142 | ADJUSTEDIT(dialstr); |
133 | l1->addWidget(label4, row, 1); | 143 | l1->addWidget(label4, row, 1); |
134 | l1->addWidget(dialstr, row++, 2); | 144 | l1->addWidget(dialstr, row++, 2); |
135 | 145 | ||
136 | connectresp = new QLineEdit(this); | 146 | connectresp = new QLineEdit(mainW); |
137 | label5 = new QLabel(i18n("Connect response:"), this); | 147 | label5 = new QLabel(QObject::tr("Connect response:"), mainW); |
138 | ADJUSTEDIT(connectresp); | 148 | ADJUSTEDIT(connectresp); |
139 | l1->addWidget(label5, row, 1); | 149 | l1->addWidget(label5, row, 1); |
140 | l1->addWidget(connectresp, row++, 2); | 150 | l1->addWidget(connectresp, row++, 2); |
141 | 151 | ||
142 | busyresp = new QLineEdit(this); | 152 | busyresp = new QLineEdit(mainW); |
143 | label6 = new QLabel(i18n("Busy response:"), this); | 153 | label6 = new QLabel(QObject::tr("Busy response:"), mainW); |
144 | ADJUSTEDIT(busyresp); | 154 | ADJUSTEDIT(busyresp); |
145 | l1->addWidget(label6, row, 1); | 155 | l1->addWidget(label6, row, 1); |
146 | l1->addWidget(busyresp, row++, 2); | 156 | l1->addWidget(busyresp, row++, 2); |
147 | 157 | ||
148 | nocarrierresp = new QLineEdit(this); | 158 | nocarrierresp = new QLineEdit(mainW); |
149 | label7 = new QLabel(i18n("No carrier response:"), this); | 159 | label7 = new QLabel(QObject::tr("No carrier response:"), mainW); |
150 | ADJUSTEDIT(nocarrierresp); | 160 | ADJUSTEDIT(nocarrierresp); |
151 | l1->addWidget(label7, row, 1); | 161 | l1->addWidget(label7, row, 1); |
152 | l1->addWidget(nocarrierresp, row++, 2); | 162 | l1->addWidget(nocarrierresp, row++, 2); |
153 | 163 | ||
154 | nodialtoneresp = new QLineEdit(this); | 164 | nodialtoneresp = new QLineEdit(mainW); |
155 | label8 = new QLabel(i18n("No dial tone response:"), this); | 165 | label8 = new QLabel(QObject::tr("No dial tone response:"), mainW); |
156 | ADJUSTEDIT(nodialtoneresp); | 166 | ADJUSTEDIT(nodialtoneresp); |
157 | l1->addWidget(label8, row, 1); | 167 | l1->addWidget(label8, row, 1); |
158 | l1->addWidget(nodialtoneresp, row++, 2); | 168 | l1->addWidget(nodialtoneresp, row++, 2); |
159 | 169 | ||
160 | hangupstr = new QLineEdit(this); | 170 | hangupstr = new QLineEdit(mainW); |
161 | label9 = new QLabel(i18n("Hangup string:"), this); | 171 | label9 = new QLabel(QObject::tr("Hangup string:"), mainW); |
162 | ADJUSTEDIT(hangupstr); | 172 | ADJUSTEDIT(hangupstr); |
163 | l1->addWidget(label9, row, 1); | 173 | l1->addWidget(label9, row, 1); |
164 | l1->addWidget(hangupstr, row++, 2); | 174 | l1->addWidget(hangupstr, row++, 2); |
165 | 175 | ||
166 | hangupresp = new QLineEdit(this); | 176 | hangupresp = new QLineEdit(mainW); |
167 | label10 = new QLabel(i18n("Hangup response:"), this); | 177 | label10 = new QLabel(QObject::tr("Hangup response:"), mainW); |
168 | ADJUSTEDIT(hangupresp); | 178 | ADJUSTEDIT(hangupresp); |
169 | l1->addWidget(label10, row, 1); | 179 | l1->addWidget(label10, row, 1); |
170 | l1->addWidget(hangupresp, row++, 2); | 180 | l1->addWidget(hangupresp, row++, 2); |
171 | 181 | ||
172 | answerstr = new QLineEdit(this); | 182 | answerstr = new QLineEdit(mainW); |
173 | label11 = new QLabel(i18n("Answer string:"), this); | 183 | label11 = new QLabel(QObject::tr("Answer string:"), mainW); |
174 | ADJUSTEDIT(answerstr); | 184 | ADJUSTEDIT(answerstr); |
175 | l1->addWidget(label11, row, 1); | 185 | l1->addWidget(label11, row, 1); |
176 | l1->addWidget(answerstr, row++, 2); | 186 | l1->addWidget(answerstr, row++, 2); |
177 | 187 | ||
178 | ringresp = new QLineEdit(this); | 188 | ringresp = new QLineEdit(mainW); |
179 | label12 = new QLabel(i18n("Ring response:"), this); | 189 | label12 = new QLabel(QObject::tr("Ring response:"), mainW); |
180 | ADJUSTEDIT(ringresp); | 190 | ADJUSTEDIT(ringresp); |
181 | l1->addWidget(label12, row, 1); | 191 | l1->addWidget(label12, row, 1); |
182 | l1->addWidget(ringresp, row++, 2); | 192 | l1->addWidget(ringresp, row++, 2); |
183 | 193 | ||
184 | answerresp = new QLineEdit(this); | 194 | answerresp = new QLineEdit(mainW); |
185 | label13 = new QLabel(i18n("Answer response:"), this); | 195 | label13 = new QLabel(QObject::tr("Answer response:"), mainW); |
186 | ADJUSTEDIT(answerresp); | 196 | ADJUSTEDIT(answerresp); |
187 | l1->addWidget(label13, row, 1); | 197 | l1->addWidget(label13, row, 1); |
188 | l1->addWidget(answerresp, row++, 2); | 198 | l1->addWidget(answerresp, row++, 2); |
189 | 199 | ||
190 | escapestr = new QLineEdit(this); | 200 | escapestr = new QLineEdit(mainW); |
191 | label14 = new QLabel(i18n("Escape string:"), this); | 201 | label14 = new QLabel(QObject::tr("Escape string:"), mainW); |
192 | ADJUSTEDIT(escapestr); | 202 | ADJUSTEDIT(escapestr); |
193 | l1->addWidget(label14, row, 1); | 203 | l1->addWidget(label14, row, 1); |
194 | l1->addWidget(escapestr, row++, 2); | 204 | l1->addWidget(escapestr, row++, 2); |
195 | 205 | ||
196 | escaperesp = new QLineEdit(this); | 206 | escaperesp = new QLineEdit(mainW); |
197 | label15 = new QLabel(i18n("Escape response:"), this); | 207 | label15 = new QLabel(QObject::tr("Escape response:"), mainW); |
198 | ADJUSTEDIT(escaperesp); | 208 | ADJUSTEDIT(escaperesp); |
199 | l1->addWidget(label15, row, 1); | 209 | l1->addWidget(label15, row, 1); |
200 | l1->addWidget(escaperesp, row++, 2); | 210 | l1->addWidget(escaperesp, row++, 2); |
201 | 211 | ||
202 | QHBoxLayout *l5 = new QHBoxLayout; | 212 | QHBoxLayout *l5 = new QHBoxLayout; |
203 | l1->addLayout(l5, row, 2); | 213 | l1->addLayout(l5, row, 2); |
204 | lslider = new QLabel("MMMM", this); | 214 | lslider = new QLabel("MMMM", mainW); |
205 | FORMATSLIDERLABEL(lslider); | 215 | FORMATSLIDERLABEL(lslider); |
206 | 216 | ||
207 | QSlider *slider = new QSlider(0, 255, 1, 0, | 217 | QSlider *slider = new QSlider(0, 255, 1, 0, |
208 | QSlider::Horizontal, this); | 218 | QSlider::Horizontal, mainW); |
209 | // slider->setFixedHeight(slider->sizeHint().height()); | 219 | // slider->setFixedHeight(slider->sizeHint().height()); |
210 | connect(slider, SIGNAL(valueChanged(int)), | 220 | connect(slider, SIGNAL(valueChanged(int)), |
211 | lslider, SLOT(setNum(int))); | 221 | lslider, SLOT(setNum(int))); |
212 | l5->addWidget(lslider, 0); | 222 | l5->addWidget(lslider, 0); |
213 | l5->addWidget(slider, 1); | 223 | l5->addWidget(slider, 1); |
214 | 224 | ||
215 | label16 = new QLabel(i18n("Guard time (sec/50):"), this); | 225 | label16 = new QLabel(QObject::tr("Guard time (sec/50):"), mainW); |
216 | l1->addWidget(label16, row++, 1); | 226 | l1->addWidget(label16, row++, 1); |
217 | 227 | ||
218 | QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); | 228 | QLabel *l = new QLabel(QObject::tr("Volume off/low/high:"), mainW); |
219 | l1->addWidget(l, row, 1); | 229 | l1->addWidget(l, row, 1); |
220 | QHBoxLayout *l6 = new QHBoxLayout; | 230 | QHBoxLayout *l6 = new QHBoxLayout; |
221 | l1->addLayout(l6, row++, 2); | 231 | l1->addLayout(l6, row++, 2); |
222 | volume_off = new QLineEdit(this); | 232 | volume_off = new QLineEdit(mainW); |
223 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); | 233 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); |
224 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); | 234 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); |
225 | volume_medium = new QLineEdit(this); | 235 | volume_medium = new QLineEdit(mainW); |
226 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); | 236 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); |
227 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); | 237 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); |
228 | volume_high = new QLineEdit(this); | 238 | volume_high = new QLineEdit(mainW); |
229 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); | 239 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); |
230 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); | 240 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); |
231 | l6->addWidget(volume_off); | 241 | l6->addWidget(volume_off); |
232 | l6->addWidget(volume_medium); | 242 | l6->addWidget(volume_medium); |
233 | l6->addWidget(volume_high); | 243 | l6->addWidget(volume_high); |
234 | 244 | ||
235 | initstr[0]->setFocus(); | 245 | initstr[0]->setFocus(); |
236 | 246 | ||
237 | l1->addColSpacing(0, 10); | 247 | l1->addColSpacing(0, 10); |
238 | l1->addColSpacing(3, 10); | 248 | l1->addColSpacing(3, 10); |
239 | l1->addRowSpacing(0, 5); | 249 | l1->addRowSpacing(0, 5); |
240 | l1->addRowSpacing(GRIDROWS, 5); | 250 | l1->addRowSpacing(GRIDROWS, 5); |
@@ -298,21 +308,26 @@ void ModemCommands::slotOk() { | |||
298 | _pppdata->setModemHangupStr(hangupstr->text()); | 308 | _pppdata->setModemHangupStr(hangupstr->text()); |
299 | _pppdata->setModemHangupResp(hangupresp->text()); | 309 | _pppdata->setModemHangupResp(hangupresp->text()); |
300 | 310 | ||
301 | _pppdata->setModemAnswerStr(answerstr->text()); | 311 | _pppdata->setModemAnswerStr(answerstr->text()); |
302 | _pppdata->setModemRingResp(ringresp->text()); | 312 | _pppdata->setModemRingResp(ringresp->text()); |
303 | _pppdata->setModemAnswerResp(answerresp->text()); | 313 | _pppdata->setModemAnswerResp(answerresp->text()); |
304 | 314 | ||
305 | _pppdata->setVolumeHigh(volume_high->text()); | 315 | _pppdata->setVolumeHigh(volume_high->text()); |
306 | _pppdata->setVolumeMedium(volume_medium->text()); | 316 | _pppdata->setVolumeMedium(volume_medium->text()); |
307 | _pppdata->setVolumeOff(volume_off->text()); | 317 | _pppdata->setVolumeOff(volume_off->text()); |
308 | 318 | ||
309 | _pppdata->save(); | 319 | _pppdata->save(); |
310 | accept(); | 320 | QDialog::accept(); |
321 | } | ||
322 | |||
323 | void ModemCommands::accept() | ||
324 | { | ||
325 | slotOk(); | ||
311 | } | 326 | } |
312 | 327 | ||
313 | 328 | ||
314 | void ModemCommands::slotCancel() { | 329 | void ModemCommands::slotCancel() { |
315 | reject(); | 330 | reject(); |
316 | } | 331 | } |
317 | 332 | ||
318 | //#include "modemcmds.moc" | 333 | //#include "modemcmds.moc" |
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h index ef69fec..81d67f4 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.h +++ b/noncore/settings/networksettings/ppp/modemcmds.h | |||
@@ -35,28 +35,29 @@ | |||
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(PPPData*, QWidget *parent=0, const char *name=0); | 47 | ModemCommands(PPPData*, QWidget *parent=0, const char *name=0, bool modal=0, WFlags f = 0); |
48 | ~ModemCommands() {} | 48 | ~ModemCommands() {} |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | virtual void accept(); | ||
51 | void slotCancel(); | 52 | void slotCancel(); |
52 | void slotOk(); | 53 | void slotOk(); |
53 | 54 | ||
54 | private: | 55 | private: |
55 | PPPData *_pppdata; | 56 | PPPData *_pppdata; |
56 | 57 | ||
57 | QGroupBox *box; | 58 | QGroupBox *box; |
58 | 59 | ||
59 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; | 60 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; |
60 | 61 | ||
61 | QLineEdit *initresp; | 62 | QLineEdit *initresp; |
62 | QLabel *label2; | 63 | QLabel *label2; |
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp index 0bec186..dbb26db 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.cpp +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -25,59 +25,57 @@ | |||
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> | ||
38 | #define i18n QObject::tr | ||
39 | 37 | ||
40 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) | 38 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) |
41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), | 39 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), |
42 | _modem(mo) | 40 | _modem(mo) |
43 | { | 41 | { |
44 | setCaption(i18n("ATI Query")); | 42 | setCaption(QObject::tr("ATI Query")); |
45 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 43 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
46 | 44 | ||
47 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 45 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
48 | 46 | ||
49 | progressBar = new QProgressBar(this, "bar"); | 47 | progressBar = new QProgressBar(this, "bar"); |
50 | progressBar->setTotalSteps(8); | 48 | progressBar->setTotalSteps(8); |
51 | 49 | ||
52 | statusBar = new QLabel(this,"sBar"); | 50 | statusBar = new QLabel(this,"sBar"); |
53 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 51 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
54 | statusBar->setAlignment(AlignCenter); | 52 | statusBar->setAlignment(AlignCenter); |
55 | 53 | ||
56 | // This is a rather complicated case. Since we do not know which | 54 | // This is a rather complicated case. Since we do not know which |
57 | // message is the widest in the national language, we'd to | 55 | // message is the widest in the national language, we'd to |
58 | // search all these messages. This is a little overkill, so I take | 56 | // search all these messages. This is a little overkill, so I take |
59 | // the longest english message, translate it and give it additional | 57 | // the longest english message, translate it and give it additional |
60 | // 20 percent space. Hope this is enough. | 58 | // 20 percent space. Hope this is enough. |
61 | statusBar->setText(i18n("Unable to create modem lock file.")); | 59 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
62 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | 60 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); |
63 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | 61 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); |
64 | 62 | ||
65 | // set original text | 63 | // set original text |
66 | statusBar->setText(i18n("Looking for modem...")); | 64 | statusBar->setText(QObject::tr("Looking for modem...")); |
67 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | 65 | progressBar->setFixedHeight(statusBar->minimumSize().height()); |
68 | tl->addWidget(progressBar); | 66 | tl->addWidget(progressBar); |
69 | tl->addWidget(statusBar); | 67 | tl->addWidget(statusBar); |
70 | 68 | ||
71 | cancel = new QPushButton(i18n("Cancel"), this); | 69 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
72 | cancel->setFocus(); | 70 | cancel->setFocus(); |
73 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 71 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
74 | 72 | ||
75 | QHBoxLayout *l1 = new QHBoxLayout; | 73 | QHBoxLayout *l1 = new QHBoxLayout; |
76 | tl->addLayout(l1); | 74 | tl->addLayout(l1); |
77 | l1->addStretch(1); | 75 | l1->addStretch(1); |
78 | l1->addWidget(cancel); | 76 | l1->addWidget(cancel); |
79 | 77 | ||
80 | setFixedSize(sizeHint()); | 78 | setFixedSize(sizeHint()); |
81 | 79 | ||
82 | step = 0; | 80 | step = 0; |
83 | 81 | ||
@@ -109,53 +107,53 @@ void ModemTransfer::ati_done() { | |||
109 | mi->showMaximized(); | 107 | mi->showMaximized(); |
110 | mi->exec(); | 108 | mi->exec(); |
111 | delete mi; | 109 | delete mi; |
112 | 110 | ||
113 | accept(); | 111 | accept(); |
114 | } | 112 | } |
115 | 113 | ||
116 | 114 | ||
117 | void ModemTransfer::time_out_slot() { | 115 | void ModemTransfer::time_out_slot() { |
118 | timeout_timer->stop(); | 116 | timeout_timer->stop(); |
119 | scripttimer->stop(); | 117 | scripttimer->stop(); |
120 | 118 | ||
121 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); | 119 | QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); |
122 | reject(); | 120 | reject(); |
123 | } | 121 | } |
124 | 122 | ||
125 | 123 | ||
126 | void ModemTransfer::init() { | 124 | void ModemTransfer::init() { |
127 | 125 | ||
128 | qApp->processEvents(); | 126 | qApp->processEvents(); |
129 | 127 | ||
130 | int lock = _modem->lockdevice(); | 128 | int lock = _modem->lockdevice(); |
131 | if (lock == 1) { | 129 | if (lock == 1) { |
132 | 130 | ||
133 | statusBar->setText(i18n("Modem device is locked.")); | 131 | statusBar->setText(QObject::tr("Modem device is locked.")); |
134 | return; | 132 | return; |
135 | } | 133 | } |
136 | 134 | ||
137 | if (lock == -1) { | 135 | if (lock == -1) { |
138 | 136 | ||
139 | statusBar->setText(i18n("Unable to create modem lock file.")); | 137 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | 140 | ||
143 | 141 | ||
144 | if(_modem->opentty()) { | 142 | if(_modem->opentty()) { |
145 | if(_modem->hangup()) { | 143 | if(_modem->hangup()) { |
146 | usleep(100000); // wait 0.1 secs | 144 | usleep(100000); // wait 0.1 secs |
147 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | 145 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... |
148 | 146 | ||
149 | statusBar->setText(i18n("Modem Ready")); | 147 | statusBar->setText(QObject::tr("Modem Ready")); |
150 | qApp->processEvents(); | 148 | qApp->processEvents(); |
151 | usleep(100000); // wait 0.1 secs | 149 | usleep(100000); // wait 0.1 secs |
152 | qApp->processEvents(); | 150 | qApp->processEvents(); |
153 | scripttimer->start(1000); // this one does the ati query | 151 | scripttimer->start(1000); // this one does the ati query |
154 | 152 | ||
155 | // clear modem buffer | 153 | // clear modem buffer |
156 | _modem->flush(); | 154 | _modem->flush(); |
157 | 155 | ||
158 | _modem->notify(this, SLOT(readChar(unsigned char))); | 156 | _modem->notify(this, SLOT(readChar(unsigned char))); |
159 | return; | 157 | return; |
160 | } | 158 | } |
161 | } | 159 | } |
@@ -218,72 +216,72 @@ void ModemTransfer::readtty() { | |||
218 | if(step <= NUM_OF_ATI) | 216 | if(step <= NUM_OF_ATI) |
219 | ati_query_strings[step-1] = readbuffer.copy(); | 217 | ati_query_strings[step-1] = readbuffer.copy(); |
220 | 218 | ||
221 | readbuffer = ""; | 219 | readbuffer = ""; |
222 | } | 220 | } |
223 | 221 | ||
224 | 222 | ||
225 | void ModemTransfer::cancelbutton() { | 223 | void ModemTransfer::cancelbutton() { |
226 | scripttimer->stop(); | 224 | scripttimer->stop(); |
227 | _modem->stop(); | 225 | _modem->stop(); |
228 | timeout_timer->stop(); | 226 | timeout_timer->stop(); |
229 | 227 | ||
230 | statusBar->setText(i18n("One moment please...")); | 228 | statusBar->setText(QObject::tr("One moment please...")); |
231 | qApp->processEvents(); | 229 | qApp->processEvents(); |
232 | 230 | ||
233 | _modem->hangup(); | 231 | _modem->hangup(); |
234 | 232 | ||
235 | _modem->closetty(); | 233 | _modem->closetty(); |
236 | _modem->unlockdevice(); | 234 | _modem->unlockdevice(); |
237 | reject(); | 235 | reject(); |
238 | } | 236 | } |
239 | 237 | ||
240 | 238 | ||
241 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | 239 | void ModemTransfer::closeEvent( QCloseEvent *e ) { |
242 | cancelbutton(); | 240 | cancelbutton(); |
243 | e->accept(); | 241 | e->accept(); |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | 245 | ModemInfo::ModemInfo(QWidget *parent, const char* name) |
248 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | 246 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) |
249 | { | 247 | { |
250 | QString label_text; | 248 | QString label_text; |
251 | 249 | ||
252 | setCaption(i18n("Modem Query Results")); | 250 | setCaption(QObject::tr("Modem Query Results")); |
253 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 251 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
254 | 252 | ||
255 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 253 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
256 | 254 | ||
257 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | 255 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); |
258 | tl->addLayout(l1, 1); | 256 | tl->addLayout(l1, 1); |
259 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | 257 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { |
260 | 258 | ||
261 | label_text = ""; | 259 | label_text = ""; |
262 | if ( i == 0) | 260 | if ( i == 0) |
263 | label_text.sprintf("ATI :"); | 261 | label_text.sprintf("ATI :"); |
264 | else | 262 | else |
265 | label_text.sprintf("ATI %d:", i ); | 263 | label_text.sprintf("ATI %d:", i ); |
266 | 264 | ||
267 | ati_label[i] = new QLabel(label_text, this); | 265 | ati_label[i] = new QLabel(label_text, this); |
268 | l1->addWidget(ati_label[i], i, 0); | 266 | l1->addWidget(ati_label[i], i, 0); |
269 | 267 | ||
270 | ati_label_result[i] = new QLineEdit(this); | 268 | ati_label_result[i] = new QLineEdit(this); |
271 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | 269 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); |
272 | l1->addWidget(ati_label_result[i], i, 1); | 270 | l1->addWidget(ati_label_result[i], i, 1); |
273 | } | 271 | } |
274 | //tl->addSpacing(1); | 272 | //tl->addSpacing(1); |
275 | 273 | ||
276 | QHBoxLayout *l2 = new QHBoxLayout; | 274 | QHBoxLayout *l2 = new QHBoxLayout; |
277 | QPushButton *ok = new QPushButton(i18n("Close"), this); | 275 | QPushButton *ok = new QPushButton(QObject::tr("Close"), this); |
278 | ok->setDefault(TRUE); | 276 | ok->setDefault(TRUE); |
279 | ok->setFocus(); | 277 | ok->setFocus(); |
280 | 278 | ||
281 | tl->addLayout(l2); | 279 | tl->addLayout(l2); |
282 | l2->addStretch(1); | 280 | l2->addStretch(1); |
283 | 281 | ||
284 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | 282 | connect(ok, SIGNAL(clicked()), SLOT(accept())); |
285 | l2->addWidget(ok); | 283 | l2->addWidget(ok); |
286 | 284 | ||
287 | setMinimumSize(sizeHint()); | 285 | setMinimumSize(sizeHint()); |
288 | } | 286 | } |
289 | 287 | ||
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index fc89f35..84acd0e 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,18 +1,17 @@ | |||
1 | #TEMPLATE = app | 1 | #TEMPLATE = app |
2 | # | 2 | # |
3 | TEMPLATE = lib | 3 | TEMPLATE = lib |
4 | #CONFIG += qt warn_on release | 4 | #CONFIG += qt warn_on release |
5 | CONFIG += qt warn_on debug | 5 | CONFIG += qt warn_on debug |
6 | DESTDIR = $(OPIEDIR)/plugins/networksettings | 6 | DESTDIR = $(OPIEDIR)/plugins/networksettings |
7 | HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h | 7 | HEADERS = pppmodule.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h chooserwidget.h devices.h |
8 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp | 8 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp chooserwidget.cpp devices.cpp |
9 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 9 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
10 | DEPENDPATH+= $(OPIEDIR)/include | 10 | DEPENDPATH+= $(OPIEDIR)/include |
11 | LIBS += -lqpe -L../interfaces/ -linterfaces | 11 | LIBS += -lqpe -L../interfaces/ -linterfaces |
12 | INTERFACES= | ||
13 | TARGET = kppp | 12 | TARGET = kppp |
14 | VERSION = 1.0.0 | 13 | VERSION = 1.0.0 |
15 | 14 | ||
16 | 15 | ||
17 | 16 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index 5fa7d3f..97baf31 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp | |||
@@ -1,70 +1,75 @@ | |||
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 "devices.h" | ||
7 | #include "general.h" | 8 | #include "general.h" |
8 | #include "interfaceppp.h" | 9 | #include "interfaceppp.h" |
9 | #include "modem.h" | 10 | #include "modem.h" |
10 | #include "pppconfig.h" | 11 | #include "pppconfig.h" |
11 | #include "pppdata.h" | 12 | #include "pppdata.h" |
12 | #include "runtests.h" | 13 | #include "runtests.h" |
13 | 14 | ||
14 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, | 15 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, |
15 | const char *name, | 16 | const char *name, |
16 | bool modal, WFlags fl ) | 17 | bool modal, WFlags fl ) |
17 | : QDialog(parent, name, modal, fl) | 18 | : QDialog(parent, name, modal, fl) |
18 | { | 19 | { |
19 | setCaption(tr("Configure Modem")); | 20 | setCaption(tr("Configure Modem")); |
20 | int result = runTests(); | 21 | int result = runTests(); |
21 | if(result == TEST_CRITICAL){ | 22 | if(result == TEST_CRITICAL){ |
22 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); | 23 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); |
23 | return; | 24 | return; |
24 | } | 25 | } |
25 | 26 | ||
26 | interface = iface; | 27 | interface = iface; |
27 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 28 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
28 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 29 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
29 | 30 | ||
30 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 31 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
31 | qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID()); | 32 | |
32 | 33 | ||
33 | QVBoxLayout *layout = new QVBoxLayout( this ); | 34 | QVBoxLayout *layout = new QVBoxLayout( this ); |
34 | layout->setSpacing( 0 ); | 35 | layout->setSpacing( 0 ); |
35 | layout->setMargin( 1 ); | 36 | layout->setMargin( 1 ); |
36 | tabWindow = new QTabWidget( this, "tabWidget" ); | 37 | tabWindow = new QTabWidget( this, "tabWidget" ); |
37 | layout->addWidget( tabWindow ); | 38 | layout->addWidget( tabWindow ); |
38 | 39 | ||
39 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts" ); | 40 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp ); |
40 | tabWindow->addTab( accounts, tr("&Accounts") ); | 41 | tabWindow->addTab( accounts, tr("&Accounts") ); |
41 | modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | 42 | devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); |
42 | tabWindow->addTab( modem1, tr("&Device") ); | 43 | tabWindow->addTab( devices, tr("&Devices") ); |
43 | modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | 44 | |
44 | tabWindow->addTab( modem2, tr("&Modem") ); | 45 | //OLD: |
46 | // modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | ||
47 | // tabWindow->addTab( modem1, tr("&Device") ); | ||
48 | // modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | ||
49 | // tabWindow->addTab( modem2, tr("&Modem") ); | ||
45 | 50 | ||
46 | } | 51 | } |
47 | 52 | ||
48 | 53 | ||
49 | PPPConfigWidget::~PPPConfigWidget() | 54 | PPPConfigWidget::~PPPConfigWidget() |
50 | { | 55 | { |
51 | 56 | ||
52 | } | 57 | } |
53 | 58 | ||
54 | void PPPConfigWidget::accept() | 59 | void PPPConfigWidget::accept() |
55 | { | 60 | { |
56 | qDebug("PPPConfigWidget::accept"); | 61 | qDebug("PPPConfigWidget::accept"); |
57 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 62 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
58 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 63 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
59 | interface->setInterfaceName( interface->data()->modemDevice() ); | 64 | interface->setInterfaceName( interface->data()->devname() ); |
60 | interface->setHardwareName( interface->data()->accname() ); | 65 | interface->setHardwareName( interface->data()->accname() ); |
61 | interface->save(); | 66 | interface->save(); |
62 | QDialog::accept(); | 67 | QDialog::accept(); |
63 | } | 68 | } |
64 | 69 | ||
65 | 70 | ||
66 | void PPPConfigWidget::reject() | 71 | void PPPConfigWidget::reject() |
67 | { | 72 | { |
68 | interface->data()->cancel(); | 73 | interface->data()->cancel(); |
69 | QDialog::reject(); | 74 | QDialog::reject(); |
70 | } | 75 | } |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h index 9bab6fe..4d7912f 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.h +++ b/noncore/settings/networksettings/ppp/pppconfig.h | |||
@@ -1,37 +1,43 @@ | |||
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 InterfacePPP; |
9 | class AccountWidget; | 9 | class AccountWidget; |
10 | class GeneralWidget; | 10 | class GeneralWidget; |
11 | class DevicesWidget; | ||
12 | |||
13 | //OLD: | ||
11 | class ModemWidget; | 14 | class ModemWidget; |
12 | class ModemWidget2; | 15 | class ModemWidget2; |
13 | 16 | ||
14 | class PPPConfigWidget : public QDialog { | 17 | class PPPConfigWidget : public QDialog { |
15 | Q_OBJECT | 18 | Q_OBJECT |
16 | public: | 19 | public: |
17 | 20 | ||
18 | PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0, | 21 | PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0, |
19 | bool modal = false, WFlags fl = 0 ); | 22 | bool modal = false, WFlags fl = 0 ); |
20 | ~PPPConfigWidget(); | 23 | ~PPPConfigWidget(); |
21 | 24 | ||
22 | 25 | ||
23 | protected slots: | 26 | protected slots: |
24 | virtual void accept(); | 27 | virtual void accept(); |
25 | virtual void reject(); | 28 | virtual void reject(); |
26 | 29 | ||
27 | private: | 30 | private: |
28 | InterfacePPP *interface; | 31 | InterfacePPP *interface; |
29 | QTabWidget *tabWindow; | 32 | QTabWidget *tabWindow; |
30 | AccountWidget *accounts; | 33 | AccountWidget *accounts; |
31 | GeneralWidget *general; | 34 | GeneralWidget *general; |
35 | DevicesWidget* devices; | ||
36 | |||
37 | //OLD: | ||
32 | ModemWidget *modem1; | 38 | ModemWidget *modem1; |
33 | ModemWidget2 *modem2; | 39 | ModemWidget2 *modem2; |
34 | }; | 40 | }; |
35 | 41 | ||
36 | 42 | ||
37 | #endif | 43 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 8f45e54..f4727c1 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -17,110 +17,121 @@ | |||
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 | ||
32 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
33 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 33 | #include <qapplication.h> |
35 | // #include <klocale.h> | 34 | // #include <klocale.h> |
36 | // #include <kconfig.h> | 35 | // #include <kconfig.h> |
37 | // #include <kmessagebox.h> | 36 | // #include <kmessagebox.h> |
38 | // #include <kapplication.h> | 37 | // #include <kapplication.h> |
39 | #include <assert.h> | 38 | #include <assert.h> |
40 | 39 | ||
41 | #define SEPARATOR -sseepp- | 40 | #define SEPARATOR -sseepp- |
42 | #define SEP QString("%1SEPARATOR%1") | 41 | #define SEP QString("%1SEPARATOR%1") |
43 | 42 | ||
44 | PPPData::PPPData() | 43 | PPPData::PPPData() |
45 | : modemDeviceGroup(-1), | 44 | : passwd(""), |
46 | passwd(""), | 45 | _modemName(""), |
47 | highcount(-1), // start out with no entries | 46 | highcount(-1), // start out with no entries |
48 | caccount(-1), // set the current account index also | 47 | highcountdev(-1), // start out with no entries |
48 | // caccount(-1), // set the current account index also | ||
49 | suidprocessid(-1), // process ID of setuid child | 49 | suidprocessid(-1), // process ID of setuid child |
50 | pppdisrunning(false), | 50 | pppdisrunning(false), |
51 | pppderror(0) | 51 | pppderror(0) |
52 | { | 52 | { |
53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
54 | 54 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; | |
55 | if (highcount > MAX_ACCOUNTS) | 55 | Config cfg = config(); |
56 | highcount = MAX_ACCOUNTS; | 56 | cfg.setGroup(GENERAL_GRP); |
57 | 57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); | |
58 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); |
59 | setAccountbyIndex(0); | 59 | qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1()); |
60 | setDefaultAccount(accname()); | 60 | qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1()); |
61 | } else if(!setAccount(defaultAccount())) | 61 | |
62 | // if (highcount > MAX_ACCOUNTS) | ||
63 | // highcount = MAX_ACCOUNTS; | ||
64 | |||
65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { | ||
66 | // setAccountbyIndex(0); | ||
67 | // setDefaultAccount(accname()); | ||
68 | // } else if(!setAccount(defaultAccount())) | ||
62 | setDefaultAccount(accname()); | 69 | setDefaultAccount(accname()); |
63 | 70 | ||
64 | // start out with internal debugging disabled | 71 | // start out with internal debugging disabled |
65 | // the user is still free to specify `debug' on his own | 72 | // the user is still free to specify `debug' on his own |
66 | setPPPDebug(false); | 73 | setPPPDebug(false); |
67 | 74 | ||
68 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 75 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
69 | 76 | ||
70 | } | 77 | } |
71 | 78 | ||
72 | Config PPPData::config() | 79 | Config PPPData::config() |
73 | { | 80 | { |
74 | return Config("NetworkSetupPPP"); | 81 | return Config("NetworkSetupPPP"); |
75 | } | 82 | } |
76 | 83 | ||
77 | // | 84 | // |
78 | // save configuration | 85 | // save configuration |
79 | // | 86 | // |
80 | void PPPData::save() | 87 | void PPPData::save() |
81 | { | 88 | { |
82 | qDebug("PPPData saving data"); | 89 | qDebug("PPPData saving data"); |
83 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); | ||
84 | QString key; | 92 | QString key; |
85 | QStringList keys; | 93 | QStringList keys; |
86 | Config cfg = config(); | 94 | Config cfg = config(); |
95 | cfg.setGroup(GENERAL_GRP); | ||
96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); | ||
97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); | ||
98 | |||
87 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
88 | it != stringEntries.end(); ++it ){ | 100 | it != stringEntries.end(); ++it ){ |
89 | QString val = it.data(); | 101 | QString val = it.data(); |
90 | key = it.key(); | 102 | key = it.key(); |
91 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 103 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
92 | keys = QStringList::split( "SEPARATOR", key ); | 104 | keys = QStringList::split( "SEPARATOR", key ); |
93 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 105 | //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); |
94 | cfg.setGroup(keys[0]); | 106 | cfg.setGroup(keys[0]); |
95 | cfg.writeEntry(keys[1], val); | 107 | cfg.writeEntry(keys[1], val); |
96 | } | 108 | } |
97 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
98 | it != intEntries.end(); ++it ){ | 110 | it != intEntries.end(); ++it ){ |
99 | int val = it.data(); | 111 | int val = it.data(); |
100 | key = it.key(); | 112 | key = it.key(); |
101 | // qDebug("saving %s -> %i", key.latin1(), val ); | 113 | // qDebug("saving %s -> %i", key.latin1(), val ); |
102 | keys = QStringList::split( "SEPARATOR", key ); | 114 | keys = QStringList::split( "SEPARATOR", key ); |
103 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 115 | //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); |
104 | cfg.setGroup(keys[0]); | 116 | cfg.setGroup(keys[0]); |
105 | cfg.writeEntry(keys[1], val); | 117 | cfg.writeEntry(keys[1], val); |
106 | } | 118 | } |
107 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
108 | it != listEntries.end(); ++it ){ | 120 | it != listEntries.end(); ++it ){ |
109 | QStringList val = it.data(); | 121 | QStringList val = it.data(); |
110 | key = it.key(); | 122 | key = it.key(); |
111 | QChar sep = sepEntries[key]; | 123 | QChar sep = sepEntries[key]; |
112 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 124 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); |
113 | keys = QStringList::split( "SEPARATOR", key ); | 125 | keys = QStringList::split( "SEPARATOR", key ); |
114 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | ||
115 | cfg.setGroup(keys[0]); | 126 | cfg.setGroup(keys[0]); |
116 | cfg.writeEntry(keys[1], val, sep); | 127 | cfg.writeEntry(keys[1], val, sep); |
117 | } | 128 | } |
118 | } | 129 | } |
119 | 130 | ||
120 | 131 | ||
121 | // | 132 | // |
122 | // cancel changes | 133 | // cancel changes |
123 | // | 134 | // |
124 | void PPPData::cancel() { | 135 | void PPPData::cancel() { |
125 | stringEntries.clear(); | 136 | stringEntries.clear(); |
126 | intEntries.clear(); | 137 | intEntries.clear(); |
@@ -335,39 +346,51 @@ bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | |||
335 | 346 | ||
336 | int PPPData::pppdTimeout() { | 347 | int PPPData::pppdTimeout() { |
337 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 348 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
338 | } | 349 | } |
339 | 350 | ||
340 | 351 | ||
341 | void PPPData::setpppdTimeout(int n) { | 352 | void PPPData::setpppdTimeout(int n) { |
342 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 353 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
343 | } | 354 | } |
344 | 355 | ||
345 | 356 | ||
346 | const QString PPPData::modemDevice() { | 357 | const QString PPPData::modemDevice() { |
347 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); |
348 | } | 359 | } |
349 | 360 | ||
350 | 361 | ||
362 | // const QString PPPData::modemName() | ||
363 | // { | ||
364 | // return readConfig(modemGroup(), MODEMNAME_KEY); | ||
365 | // } | ||
366 | |||
367 | // bool PPPData::setModemName(const QString &n) { | ||
368 | // qDebug("Setting modem name to >%s<", n.latin1()); | ||
369 | // _modemName = n; | ||
370 | // writeConfig(cgroup, MODEMNAME_KEY, n); | ||
371 | // return true; //FIXME | ||
372 | // } | ||
373 | |||
374 | // bool PPPData::changeModemName(const QString &n) { | ||
375 | // qDebug("Setting modem name to >%s<", n.latin1()); | ||
376 | // _modemName = n; | ||
377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); | ||
378 | // return true; //FIXME | ||
379 | // } | ||
380 | |||
351 | bool PPPData::setModemDevice(const QString &n) { | 381 | bool PPPData::setModemDevice(const QString &n) { |
352 | qDebug("Setting modem dev to >%s<", n.latin1()); | 382 | qDebug("Setting modem dev to >%s<", n.latin1()); |
353 | bool ret = false; | ||
354 | for (int i = 0; devices[i]; i++) | ||
355 | if (devices[i] == n){ | ||
356 | modemDeviceGroup = i; | ||
357 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
358 | ret = true; | 384 | return true; //FIXME |
359 | } | ||
360 | qDebug(ret?"SUCCESS":"FAILURE"); | ||
361 | return ret; | ||
362 | } | 385 | } |
363 | 386 | ||
364 | 387 | ||
365 | const QString PPPData::flowcontrol() { | 388 | const QString PPPData::flowcontrol() { |
366 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
367 | } | 390 | } |
368 | 391 | ||
369 | 392 | ||
370 | void PPPData::setFlowcontrol(const QString &n) { | 393 | void PPPData::setFlowcontrol(const QString &n) { |
371 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
372 | } | 395 | } |
373 | 396 | ||
@@ -708,145 +731,169 @@ void PPPData::setEnter(const QString &n) { | |||
708 | // | 731 | // |
709 | // functions to set/return account information | 732 | // functions to set/return account information |
710 | // | 733 | // |
711 | 734 | ||
712 | //returns number of accounts | 735 | //returns number of accounts |
713 | int PPPData::count() const { | 736 | int PPPData::count() const { |
714 | return highcount + 1; | 737 | return highcount + 1; |
715 | } | 738 | } |
716 | 739 | ||
717 | 740 | ||
718 | bool PPPData::setAccount(const QString &aname) { | 741 | bool PPPData::setAccount(const QString &aname) { |
719 | qDebug("setting account to >%s<", aname.latin1()); | 742 | qDebug("setting account to >%s<", aname.latin1()); |
720 | for(int i = 0; i <= highcount; i++) { | 743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
721 | setAccountbyIndex(i); | 744 | cgroup = *it; |
745 | qDebug("PPPData::setAccount %s", cgroup.latin1()); | ||
746 | qDebug( "iterator %s", (*it).latin1() ); | ||
722 | if(accname() == aname) { | 747 | if(accname() == aname) { |
723 | caccount = i; | ||
724 | qDebug("SUCCESS"); | 748 | qDebug("SUCCESS"); |
725 | return true; | 749 | return true; |
726 | } | 750 | } |
751 | |||
727 | } | 752 | } |
728 | qDebug("FAILURE"); | 753 | qDebug("FAILURE"); |
729 | return false; | 754 | return false; |
730 | } | 755 | } |
731 | 756 | ||
732 | 757 | /* | |
733 | bool PPPData::setAccountbyIndex(int i) { | 758 | bool PPPData::setAccountbyIndex(int i) { |
734 | if(i >= 0 && i <= highcount) { | 759 | if(i >= 0 && i <= highcount) { |
760 | QString tmp; | ||
761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); | ||
762 | if (_deleted.find(tmp)!=_deleted.end()) return false; | ||
735 | caccount = i; | 763 | caccount = i; |
736 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 764 | cgroup = tmp; |
737 | return true; | 765 | return true; |
738 | } | 766 | } |
739 | return false; | 767 | return false; |
740 | } | 768 | } |
741 | 769 | */ | |
742 | 770 | ||
743 | bool PPPData::isUniqueAccname(const QString &n) { | 771 | bool PPPData::isUniqueAccname(const QString &n) { |
744 | int current = caccount; | 772 | QString save_cgroup = cgroup; |
745 | for(int i=0; i <= highcount; i++) { | 773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
746 | setAccountbyIndex(i); | 774 | cgroup = *it; |
747 | if(accname() == n && i != current) { | 775 | qDebug("PPPData::setAccount %s", cgroup.latin1()); |
748 | setAccountbyIndex(current); | 776 | qDebug( "%s \n", (*it).latin1() ); |
777 | if(accname() == n && cgroup != save_cgroup) { | ||
778 | cgroup = save_cgroup; | ||
779 | qDebug("SUCCESS"); | ||
749 | return false; | 780 | return false; |
750 | } | 781 | } |
782 | |||
751 | } | 783 | } |
752 | setAccountbyIndex(current); | 784 | cgroup = save_cgroup; |
753 | return true; | 785 | return true; |
754 | } | 786 | } |
755 | 787 | ||
756 | 788 | ||
757 | bool PPPData::deleteAccount() { | 789 | bool PPPData::isUniqueDevname(const QString &n) { |
758 | //FIXME: PPPData::deleteAccount | 790 | QString save_mName = _modemName; |
759 | // if(caccount < 0) | 791 | qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1()); |
792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | ||
793 | _modemName = *it; | ||
794 | qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1()); | ||
795 | if(devname() == n && _modemName != save_mName) { | ||
796 | _modemName = save_mName; | ||
797 | qDebug("NOT UNIQUE"); | ||
760 | return false; | 798 | return false; |
799 | } | ||
761 | 800 | ||
762 | // QMap <QString, QString> map; | 801 | } |
763 | // QMap <QString, QString>::Iterator it; | 802 | _modemName = save_mName; |
764 | 803 | return true; | |
765 | // // set all entries of the current account to "" | 804 | } |
766 | // map = config->entryMap(cgroup); | ||
767 | // it = map.begin(); | ||
768 | // while (it != map.end()) { | ||
769 | // config->writeEntry(it.key(), ""); | ||
770 | // it++; | ||
771 | // } | ||
772 | |||
773 | // // shift the succeeding accounts | ||
774 | // for(int i = caccount+1; i <= highcount; i++) { | ||
775 | // setAccountbyIndex(i); | ||
776 | // map = config->entryMap(cgroup); | ||
777 | // it = map.begin(); | ||
778 | // setAccountbyIndex(i-1); | ||
779 | // config->setGroup(cgroup); | ||
780 | // while (it != map.end()) { | ||
781 | // config->writeEntry(it.key(), *it); | ||
782 | // it++; | ||
783 | // } | ||
784 | // } | ||
785 | 805 | ||
786 | // // make sure the top account is cleared | ||
787 | // setAccountbyIndex(highcount); | ||
788 | // map = config->entryMap(cgroup); | ||
789 | // it = map.begin(); | ||
790 | // config->setGroup(cgroup); | ||
791 | // while (it.key() != QString::null) { | ||
792 | // config->writeEntry(it.key(), ""); | ||
793 | // it++; | ||
794 | // } | ||
795 | 806 | ||
796 | // highcount--; | 807 | bool PPPData::deleteAccount() { |
797 | // if(caccount > highcount) | 808 | // FIXME: check if this account exists in a config... |
798 | // caccount = highcount; | 809 | Config cfg = PPPData::config(); |
810 | cfg.setGroup(cgroup); | ||
811 | cfg.clearGroup(); | ||
812 | accountList.remove(cgroup); | ||
799 | 813 | ||
800 | // setAccountbyIndex(caccount); | 814 | QString key; |
815 | QStringList keys; | ||
816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | ||
817 | it != stringEntries.end(); ++it ){ | ||
818 | QString val = it.data(); | ||
819 | key = it.key(); | ||
820 | keys = QStringList::split( "SEPARATOR", key ); | ||
821 | if(keys[0]==cgroup){ | ||
822 | stringEntries.remove( it ); | ||
823 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | ||
824 | } | ||
825 | } | ||
826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | ||
827 | it != intEntries.end(); ++it ){ | ||
828 | int val = it.data(); | ||
829 | key = it.key(); | ||
830 | keys = QStringList::split( "SEPARATOR", key ); | ||
831 | if(keys[0]==cgroup){ | ||
832 | intEntries.remove( it ); | ||
833 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | ||
834 | } | ||
835 | } | ||
836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | ||
837 | it != listEntries.end(); ++it ){ | ||
838 | QStringList val = it.data(); | ||
839 | key = it.key(); | ||
840 | if(keys[0]==cgroup){ | ||
841 | listEntries.remove( it ); | ||
842 | sepEntries.remove( key ); | ||
843 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | ||
844 | } | ||
845 | } | ||
801 | 846 | ||
802 | // return true; | 847 | return true; |
803 | } | 848 | } |
804 | 849 | ||
805 | 850 | ||
806 | bool PPPData::deleteAccount(const QString &aname) { | 851 | bool PPPData::deleteAccount(const QString &aname) { |
807 | if(!setAccount(aname)) | 852 | if(!setAccount(aname)) |
808 | return false; | 853 | return false; |
809 | 854 | ||
810 | deleteAccount(); | 855 | deleteAccount(); |
811 | 856 | ||
812 | return true; | 857 | return true; |
813 | } | 858 | } |
814 | 859 | ||
815 | 860 | ||
816 | int PPPData::newaccount() { | 861 | int PPPData::newaccount() { |
817 | 862 | ||
818 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 863 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
819 | // if(!config) open(); | 864 | // if(!config) open(); |
820 | if (highcount >= MAX_ACCOUNTS) return -1; | 865 | // if (highcount >= MAX_ACCOUNTS) return -1; |
821 | 866 | ||
822 | highcount++; | ||
823 | setAccountbyIndex(highcount); | ||
824 | 867 | ||
868 | QString tmp; | ||
869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); | ||
870 | cgroup = QString(tmp); | ||
871 | accountList << tmp; | ||
872 | qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1()); | ||
825 | setpppdArgumentDefaults(); | 873 | setpppdArgumentDefaults(); |
826 | qDebug("PPPData::newaccount -> %i",caccount); | 874 | return highcount; |
827 | return caccount; | ||
828 | } | 875 | } |
829 | 876 | ||
830 | int PPPData::copyaccount(int i) { | 877 | int PPPData::copyaccount(const QString&) { |
831 | // FIXME: PPPData::copyaccount | 878 | // FIXME: PPPData::copyaccount |
832 | // if(highcount >= MAX_ACCOUNTS) | 879 | // if(highcount >= MAX_ACCOUNTS) |
833 | return -1; | 880 | return -1; |
834 | 881 | ||
835 | // setAccountbyIndex(i); | 882 | // setAccountbyIndex(i); |
836 | 883 | ||
837 | // QMap <QString, QString> map = config->entryMap(cgroup); | 884 | // QMap <QString, QString> map = config->entryMap(cgroup); |
838 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 885 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
839 | 886 | ||
840 | // QString newname = i18n("%1_copy").arg(accname()); | 887 | // QString newname = QObject::tr("%1_copy").arg(accname()); |
841 | 888 | ||
842 | // newaccount(); | 889 | // newaccount(); |
843 | 890 | ||
844 | // while (it != map.end()) { | 891 | // while (it != map.end()) { |
845 | // config->writeEntry(it.key(), *it); | 892 | // config->writeEntry(it.key(), *it); |
846 | // it++; | 893 | // it++; |
847 | // } | 894 | // } |
848 | 895 | ||
849 | // setAccname(newname); | 896 | // setAccname(newname); |
850 | 897 | ||
851 | // return caccount; | 898 | // return caccount; |
852 | } | 899 | } |
@@ -855,24 +902,25 @@ int PPPData::copyaccount(int i) { | |||
855 | const QString PPPData::accname() { | 902 | const QString PPPData::accname() { |
856 | return readConfig(cgroup, NAME_KEY); | 903 | return readConfig(cgroup, NAME_KEY); |
857 | } | 904 | } |
858 | 905 | ||
859 | void PPPData::setAccname(const QString &n) { | 906 | void PPPData::setAccname(const QString &n) { |
860 | if(!cgroup.isNull()) { | 907 | if(!cgroup.isNull()) { |
861 | // are we manipulating the default account's name ? then change it, too. | 908 | // are we manipulating the default account's name ? then change it, too. |
862 | bool def = accname() == defaultAccount(); | 909 | bool def = accname() == defaultAccount(); |
863 | writeConfig(cgroup, NAME_KEY, n); | 910 | writeConfig(cgroup, NAME_KEY, n); |
864 | if (def) | 911 | if (def) |
865 | setDefaultAccount(n); | 912 | setDefaultAccount(n); |
866 | } | 913 | } |
914 | writeConfig(cgroup, NAME_KEY, n); | ||
867 | } | 915 | } |
868 | 916 | ||
869 | 917 | ||
870 | #define SEPARATOR_CHAR '&' | 918 | #define SEPARATOR_CHAR '&' |
871 | QStringList &PPPData::phonenumbers() { | 919 | QStringList &PPPData::phonenumbers() { |
872 | 920 | ||
873 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 921 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
874 | return phonelist; | 922 | return phonelist; |
875 | 923 | ||
876 | } | 924 | } |
877 | 925 | ||
878 | 926 | ||
@@ -1167,24 +1215,25 @@ QStringList &PPPData::pppdArgument() { | |||
1167 | 1215 | ||
1168 | return arglist; | 1216 | return arglist; |
1169 | } | 1217 | } |
1170 | 1218 | ||
1171 | 1219 | ||
1172 | void PPPData::setpppdArgument(QStringList &args) { | 1220 | void PPPData::setpppdArgument(QStringList &args) { |
1173 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1221 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1174 | } | 1222 | } |
1175 | 1223 | ||
1176 | 1224 | ||
1177 | void PPPData::setpppdArgumentDefaults() { | 1225 | void PPPData::setpppdArgumentDefaults() { |
1178 | QStringList arg; | 1226 | QStringList arg; |
1227 | arg << "lcp-echo-failure 0"; | ||
1179 | setpppdArgument(arg); | 1228 | setpppdArgument(arg); |
1180 | } | 1229 | } |
1181 | 1230 | ||
1182 | 1231 | ||
1183 | // // graphing widget | 1232 | // // graphing widget |
1184 | // void PPPData::setGraphingOptions(bool enable, | 1233 | // void PPPData::setGraphingOptions(bool enable, |
1185 | // QColor bg, | 1234 | // QColor bg, |
1186 | // QColor text, | 1235 | // QColor text, |
1187 | // QColor in, | 1236 | // QColor in, |
1188 | // QColor out) | 1237 | // QColor out) |
1189 | // { | 1238 | // { |
1190 | // if(config) { | 1239 | // if(config) { |
@@ -1238,29 +1287,27 @@ void PPPData::setpppdRunning(bool set) { | |||
1238 | } | 1287 | } |
1239 | 1288 | ||
1240 | int PPPData::pppdError() const { | 1289 | int PPPData::pppdError() const { |
1241 | return pppderror; | 1290 | return pppderror; |
1242 | } | 1291 | } |
1243 | 1292 | ||
1244 | void PPPData::setpppdError(int err) { | 1293 | void PPPData::setpppdError(int err) { |
1245 | pppderror = err; | 1294 | pppderror = err; |
1246 | } | 1295 | } |
1247 | 1296 | ||
1248 | QString PPPData::modemGroup() | 1297 | QString PPPData::modemGroup() |
1249 | { | 1298 | { |
1250 | if (modemDeviceGroup<0){ | 1299 | if (_modemName.isEmpty()) |
1251 | qDebug("wrong modem %i\n using 0",modemDeviceGroup); | 1300 | _modemName = deviceList[0]; |
1252 | modemDeviceGroup = 0; //FIXME! | 1301 | return _modemName; |
1253 | } | ||
1254 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); | ||
1255 | } | 1302 | } |
1256 | 1303 | ||
1257 | 1304 | ||
1258 | QMap<QString,QString> PPPData::getConfiguredInterfaces() | 1305 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1259 | { | 1306 | { |
1260 | QMap<QString,QString> ifaces; | 1307 | QMap<QString,QString> ifaces; |
1261 | Config config = PPPData::config(); | 1308 | Config config = PPPData::config(); |
1262 | config.setGroup(ACCLIST_GRP); | 1309 | config.setGroup(ACCLIST_GRP); |
1263 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | 1310 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); |
1264 | QString accGrp, dev, acc; | 1311 | QString accGrp, dev, acc; |
1265 | for (int i = 0; i < count; i++){ | 1312 | for (int i = 0; i < count; i++){ |
1266 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1313 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
@@ -1291,12 +1338,158 @@ void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | |||
1291 | } | 1338 | } |
1292 | 1339 | ||
1293 | /** | 1340 | /** |
1294 | * pppd's getword() function knows about escape characters. | 1341 | * pppd's getword() function knows about escape characters. |
1295 | * If we write the username and password to the secrets file | 1342 | * If we write the username and password to the secrets file |
1296 | * we'll therefore have to escape back slashes. | 1343 | * we'll therefore have to escape back slashes. |
1297 | */ | 1344 | */ |
1298 | QString PPPData::encodeWord(const QString &s) { | 1345 | QString PPPData::encodeWord(const QString &s) { |
1299 | QString r = s; | 1346 | QString r = s; |
1300 | r.replace(QRegExp("\\"), "\\\\"); | 1347 | r.replace(QRegExp("\\"), "\\\\"); |
1301 | return r; | 1348 | return r; |
1302 | } | 1349 | } |
1350 | |||
1351 | QStringList PPPData::getDevicesList() | ||
1352 | { | ||
1353 | Config cfg("NetworkSetupPPP"); | ||
1354 | cfg.setGroup("Devices_General"); | ||
1355 | return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); | ||
1356 | } | ||
1357 | |||
1358 | QStringList PPPData::getAccountList() | ||
1359 | { | ||
1360 | QStringList list; | ||
1361 | QString save_cgroup; | ||
1362 | save_cgroup = cgroup; | ||
1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | ||
1364 | cgroup = *it; | ||
1365 | list << accname(); | ||
1366 | } | ||
1367 | cgroup = save_cgroup; | ||
1368 | return list; | ||
1369 | }; | ||
1370 | |||
1371 | |||
1372 | const QString PPPData::devname() | ||
1373 | { | ||
1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); | ||
1375 | qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1()); | ||
1376 | return tmp; | ||
1377 | } | ||
1378 | |||
1379 | void PPPData::setDevname(const QString &n) { | ||
1380 | // if(!cgroup.isNull()) { | ||
1381 | // // are we manipulating the default account's name ? then change it, too. | ||
1382 | // bool def = accname() == defaultAccount(); | ||
1383 | // writeConfig(cgroup, NAME_KEY, n); | ||
1384 | // if (def) | ||
1385 | // setDefaultAccount(n); | ||
1386 | // } | ||
1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); | ||
1388 | } | ||
1389 | |||
1390 | |||
1391 | bool PPPData::setDevice(const QString &dev ) | ||
1392 | { | ||
1393 | qDebug("setting device to >%s<", dev.latin1()); | ||
1394 | QString save_mName = _modemName; | ||
1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | ||
1396 | _modemName = *it; | ||
1397 | qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() ); | ||
1398 | qDebug( "iterator %s", (*it).latin1() ); | ||
1399 | if(devname() == dev) { | ||
1400 | qDebug("SUCCESS"); | ||
1401 | return true; | ||
1402 | } | ||
1403 | |||
1404 | } | ||
1405 | _modemName = save_mName; | ||
1406 | qDebug("FAILURE"); | ||
1407 | return false; | ||
1408 | } | ||
1409 | |||
1410 | bool PPPData::deleteDevice() | ||
1411 | { | ||
1412 | // FIXME: check if this account exists in a config... | ||
1413 | Config cfg = PPPData::config(); | ||
1414 | cfg.setGroup(modemGroup()); | ||
1415 | cfg.clearGroup(); | ||
1416 | deviceList.remove(modemGroup()); | ||
1417 | |||
1418 | QString key; | ||
1419 | QStringList keys; | ||
1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | ||
1421 | it != stringEntries.end(); ++it ){ | ||
1422 | QString val = it.data(); | ||
1423 | key = it.key(); | ||
1424 | keys = QStringList::split( "SEPARATOR", key ); | ||
1425 | if(keys[0]==modemGroup()){ | ||
1426 | stringEntries.remove( it ); | ||
1427 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | ||
1428 | } | ||
1429 | } | ||
1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | ||
1431 | it != intEntries.end(); ++it ){ | ||
1432 | int val = it.data(); | ||
1433 | key = it.key(); | ||
1434 | keys = QStringList::split( "SEPARATOR", key ); | ||
1435 | if(keys[0]==modemGroup()){ | ||
1436 | intEntries.remove( it ); | ||
1437 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | ||
1438 | } | ||
1439 | } | ||
1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | ||
1441 | it != listEntries.end(); ++it ){ | ||
1442 | QStringList val = it.data(); | ||
1443 | key = it.key(); | ||
1444 | if(keys[0]==modemGroup()){ | ||
1445 | listEntries.remove( it ); | ||
1446 | sepEntries.remove( key ); | ||
1447 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1451 | return true; | ||
1452 | |||
1453 | } | ||
1454 | |||
1455 | bool PPPData::deleteDevice(const QString &dev) | ||
1456 | { | ||
1457 | if(!setDevice(dev)) | ||
1458 | return false; | ||
1459 | |||
1460 | return deleteDevice(); | ||
1461 | } | ||
1462 | |||
1463 | int PPPData::newdevice() | ||
1464 | { | ||
1465 | |||
1466 | qDebug("PPPData::newdevice highcount %i",highcountdev); | ||
1467 | |||
1468 | |||
1469 | QString tmp; | ||
1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); | ||
1471 | _modemName = QString(tmp); | ||
1472 | deviceList << tmp; | ||
1473 | qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1()); | ||
1474 | return highcountdev; | ||
1475 | } | ||
1476 | |||
1477 | int PPPData::copydevice(const QString&) | ||
1478 | { | ||
1479 | return false; | ||
1480 | } | ||
1481 | |||
1482 | |||
1483 | QStringList PPPData::getDevicesNamesList() | ||
1484 | { | ||
1485 | QStringList list; | ||
1486 | QString save_mName = _modemName; | ||
1487 | qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1()); | ||
1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | ||
1489 | _modemName = *it; | ||
1490 | qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1()); | ||
1491 | list << devname(); | ||
1492 | } | ||
1493 | _modemName = save_mName; | ||
1494 | return list; | ||
1495 | }; | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index 6e1379d..d1cbeb5 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -55,36 +55,40 @@ class Config; | |||
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 ACCOUNT_LIST "AccountList" | ||
68 | #define DEVICE_LIST "DeviceList" | ||
67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | 69 | #define DEFAULTACCOUNT_KEY "DefaultAccount" |
68 | #define PPPDVERSION_KEY "pppdVersion" | 70 | #define PPPDVERSION_KEY "pppdVersion" |
69 | #define PPPDTIMEOUT_KEY "pppdTimeout" | 71 | #define PPPDTIMEOUT_KEY "pppdTimeout" |
70 | #define SHOWCLOCK_KEY "ShowClock" | 72 | #define SHOWCLOCK_KEY "ShowClock" |
71 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 73 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
72 | #define AUTOREDIAL_KEY "AutomaticRedial" | 74 | #define AUTOREDIAL_KEY "AutomaticRedial" |
73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 75 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 76 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | 77 | #define NUMACCOUNTS_KEY "HighcountAccounts" |
78 | #define NUMDEVICES_KEY "HighcountDevices" | ||
76 | #define ID_KEY "ID" | 79 | #define ID_KEY "ID" |
77 | 80 | ||
78 | // modem | 81 | // modem |
82 | #define MODEMNAME_KEY "Modem_Name" | ||
79 | #define MODEMDEV_KEY "Device" | 83 | #define MODEMDEV_KEY "Device" |
80 | #define LOCKFILE_KEY "UseLockFile" | 84 | #define LOCKFILE_KEY "UseLockFile" |
81 | #define FLOWCONTROL_KEY "FlowControl" | 85 | #define FLOWCONTROL_KEY "FlowControl" |
82 | #define SPEED_KEY "Speed" | 86 | #define SPEED_KEY "Speed" |
83 | #define TIMEOUT_KEY "Timeout" | 87 | #define TIMEOUT_KEY "Timeout" |
84 | #define TONEDURATION_KEY "ToneDuration" | 88 | #define TONEDURATION_KEY "ToneDuration" |
85 | #define BUSYWAIT_KEY "BusyWait" | 89 | #define BUSYWAIT_KEY "BusyWait" |
86 | #define INITSTR_KEY "InitString" | 90 | #define INITSTR_KEY "InitString" |
87 | #define INITRESP_KEY "InitResponse" | 91 | #define INITRESP_KEY "InitResponse" |
88 | #define PREINITDELAY_KEY "PreInitDelay" | 92 | #define PREINITDELAY_KEY "PreInitDelay" |
89 | #define INITDELAY_KEY "InitDelay" | 93 | #define INITDELAY_KEY "InitDelay" |
90 | #define NODTDETECT_KEY "NoDialToneDetection" | 94 | #define NODTDETECT_KEY "NoDialToneDetection" |
@@ -142,58 +146,64 @@ class Config; | |||
142 | #define TOTALCOSTS_KEY "TotalCosts" | 146 | #define TOTALCOSTS_KEY "TotalCosts" |
143 | #define TOTALBYTES_KEY "TotalBytes" | 147 | #define TOTALBYTES_KEY "TotalBytes" |
144 | 148 | ||
145 | // pppd errors | 149 | // pppd errors |
146 | #define E_IF_TIMEOUT 1 | 150 | #define E_IF_TIMEOUT 1 |
147 | #define E_PPPD_DIED 2 | 151 | #define E_PPPD_DIED 2 |
148 | 152 | ||
149 | // account list | 153 | // account list |
150 | #define ACCOUNTS_COUNT "Accounts_Count" | 154 | #define ACCOUNTS_COUNT "Accounts_Count" |
151 | #define ACOUNTS_DEV "Accounts_Modem" | 155 | #define ACOUNTS_DEV "Accounts_Modem" |
152 | #define ACOUNTS_ACC "Accounts_Account" | 156 | #define ACOUNTS_ACC "Accounts_Account" |
153 | 157 | ||
158 | #define DEVICESNAMES_LIST "DevicesNames_List" | ||
159 | #define DEVICES_LIST "Devices_List" | ||
160 | #define DEVICES_LIST_SEP ',' | ||
161 | |||
154 | class PPPData { | 162 | class PPPData { |
155 | public: | 163 | public: |
156 | PPPData(); | 164 | PPPData(); |
157 | ~PPPData() {}; | 165 | ~PPPData() {}; |
158 | 166 | ||
159 | enum { NumInitStrings = 2 }; | 167 | enum { NumInitStrings = 2 }; |
160 | 168 | ||
161 | // general functions | 169 | // general functions |
162 | void save(); | 170 | void save(); |
163 | void cancel(); | 171 | void cancel(); |
164 | 172 | ||
173 | QStringList getAccountList(); | ||
174 | |||
165 | static QMap<QString,QString> getConfiguredInterfaces(); | 175 | static QMap<QString,QString> getConfiguredInterfaces(); |
166 | static void setConfiguredInterfaces( QMap<QString,QString> ); | 176 | static void setConfiguredInterfaces( QMap<QString,QString> ); |
167 | 177 | ||
168 | // function to read/write date to configuration file | 178 | // function to read/write date to configuration file |
169 | static Config config(); | 179 | static Config config(); |
170 | QString readConfig(const QString &, const QString &, const QString &); | 180 | QString readConfig(const QString &, const QString &, const QString &); |
171 | int readNumConfig(const QString &, const QString &, int); | 181 | int readNumConfig(const QString &, const QString &, int); |
172 | bool readListConfig(const QString &, const QString &, | 182 | bool readListConfig(const QString &, const QString &, |
173 | QStringList &, char sep = ','); | 183 | QStringList &, char sep = ','); |
174 | void writeConfig(const QString &, const QString &, const QString &); | 184 | void writeConfig(const QString &, const QString &, const QString &); |
175 | void writeConfig(const QString &, const QString &, int); | 185 | void writeConfig(const QString &, const QString &, int); |
176 | void writeListConfig(const QString &, const QString &, | 186 | void writeListConfig(const QString &, const QString &, |
177 | QStringList &, char sep = ','); | 187 | QStringList &, char sep = ','); |
178 | 188 | ||
179 | // return the current account group | 189 | // return the current account group |
180 | QString currentGroup() { return cgroup; } | 190 | QString currentGroup() { return cgroup; } |
181 | QString modemGroup(); | 191 | QString modemGroup(); |
182 | 192 | ||
183 | // functions to set/get general kppp info | 193 | // functions to set/get general kppp info |
184 | QString password(); | 194 | QString password(); |
185 | void setPassword(const QString &); | 195 | void setPassword(const QString &); |
186 | 196 | ||
187 | int currentAccountID() { return caccount; }; | 197 | // int currentAccountID() { return caccount; }; |
188 | const QString defaultAccount(); | 198 | const QString defaultAccount(); |
189 | void setDefaultAccount(const QString &); | 199 | void setDefaultAccount(const QString &); |
190 | 200 | ||
191 | void set_xserver_exit_disconnect(bool set); | 201 | void set_xserver_exit_disconnect(bool set); |
192 | bool get_xserver_exit_disconnect(); | 202 | bool get_xserver_exit_disconnect(); |
193 | 203 | ||
194 | void setPPPDebug(bool set); | 204 | void setPPPDebug(bool set); |
195 | bool getPPPDebug(); | 205 | bool getPPPDebug(); |
196 | 206 | ||
197 | void set_quit_on_disconnect(bool); | 207 | void set_quit_on_disconnect(bool); |
198 | bool quit_on_disconnect(); | 208 | bool quit_on_disconnect(); |
199 | 209 | ||
@@ -227,24 +237,28 @@ public: | |||
227 | bool modemLockFile(); | 237 | bool modemLockFile(); |
228 | void setModemLockFile(bool set); | 238 | void setModemLockFile(bool set); |
229 | 239 | ||
230 | int modemEscapeGuardTime(); | 240 | int modemEscapeGuardTime(); |
231 | void setModemEscapeGuardTime(int i); | 241 | void setModemEscapeGuardTime(int i); |
232 | 242 | ||
233 | void setModemEscapeStr(const QString &); | 243 | void setModemEscapeStr(const QString &); |
234 | const QString modemEscapeStr(); | 244 | const QString modemEscapeStr(); |
235 | 245 | ||
236 | void setModemEscapeResp(const QString &); | 246 | void setModemEscapeResp(const QString &); |
237 | const QString modemEscapeResp(); | 247 | const QString modemEscapeResp(); |
238 | 248 | ||
249 | // const QString modemName(); | ||
250 | // bool setModemName(const QString &); | ||
251 | // bool changeModemName(const QString &); | ||
252 | |||
239 | const QString modemDevice(); | 253 | const QString modemDevice(); |
240 | bool setModemDevice(const QString &); | 254 | bool setModemDevice(const QString &); |
241 | 255 | ||
242 | const QString flowcontrol(); | 256 | const QString flowcontrol(); |
243 | void setFlowcontrol(const QString &); | 257 | void setFlowcontrol(const QString &); |
244 | 258 | ||
245 | int modemTimeout(); | 259 | int modemTimeout(); |
246 | void setModemTimeout(int); | 260 | void setModemTimeout(int); |
247 | 261 | ||
248 | int modemToneDuration(); | 262 | int modemToneDuration(); |
249 | void setModemToneDuration(int); | 263 | void setModemToneDuration(int); |
250 | 264 | ||
@@ -304,32 +318,33 @@ public: | |||
304 | QString volumeOff(); | 318 | QString volumeOff(); |
305 | void setVolumeOff(const QString &); | 319 | void setVolumeOff(const QString &); |
306 | 320 | ||
307 | QString volumeMedium(); | 321 | QString volumeMedium(); |
308 | void setVolumeMedium(const QString &); | 322 | void setVolumeMedium(const QString &); |
309 | 323 | ||
310 | QString volumeHigh(); | 324 | QString volumeHigh(); |
311 | void setVolumeHigh(const QString &); | 325 | void setVolumeHigh(const QString &); |
312 | 326 | ||
313 | // functions to set/get account information | 327 | // functions to set/get account information |
314 | int count() const; | 328 | int count() const; |
315 | bool setAccount(const QString &); | 329 | bool setAccount(const QString &); |
316 | bool setAccountbyIndex(int); | 330 | // bool setAccountbyIndex(int); |
317 | 331 | ||
318 | bool isUniqueAccname(const QString &); | 332 | bool isUniqueAccname(const QString &); |
333 | bool isUniqueDevname(const QString &); | ||
319 | 334 | ||
320 | bool deleteAccount(); | 335 | bool deleteAccount(); |
321 | bool deleteAccount(const QString &); | 336 | bool deleteAccount(const QString &); |
322 | int newaccount(); | 337 | int newaccount(); |
323 | int copyaccount(int i); | 338 | int copyaccount(const QString&); |
324 | 339 | ||
325 | const QString accname(); | 340 | const QString accname(); |
326 | void setAccname(const QString &); | 341 | void setAccname(const QString &); |
327 | 342 | ||
328 | QStringList &phonenumbers(); | 343 | QStringList &phonenumbers(); |
329 | const QString phonenumber(); | 344 | const QString phonenumber(); |
330 | void setPhonenumber(const QString &); | 345 | void setPhonenumber(const QString &); |
331 | 346 | ||
332 | const QString dialPrefix(); | 347 | const QString dialPrefix(); |
333 | void setDialPrefix(const QString &); | 348 | void setDialPrefix(const QString &); |
334 | 349 | ||
335 | int authMethod(); | 350 | int authMethod(); |
@@ -400,39 +415,53 @@ public: | |||
400 | 415 | ||
401 | QStringList &pppdArgument(); | 416 | QStringList &pppdArgument(); |
402 | void setpppdArgumentDefaults(); | 417 | void setpppdArgumentDefaults(); |
403 | void setpppdArgument(QStringList &); | 418 | void setpppdArgument(QStringList &); |
404 | 419 | ||
405 | //functions to change/set the child pppd process info | 420 | //functions to change/set the child pppd process info |
406 | bool pppdRunning() const; | 421 | bool pppdRunning() const; |
407 | void setpppdRunning(bool set); | 422 | void setpppdRunning(bool set); |
408 | 423 | ||
409 | int pppdError() const; | 424 | int pppdError() const; |
410 | void setpppdError(int err); | 425 | void setpppdError(int err); |
411 | 426 | ||
427 | QStringList getDevicesList(); | ||
412 | 428 | ||
413 | static QString encodeWord(const QString &s); | 429 | static QString encodeWord(const QString &s); |
414 | 430 | ||
431 | const QString devname(); | ||
432 | void setDevname(const QString &); | ||
433 | bool setDevice(const QString& ); | ||
434 | bool deleteDevice(); | ||
435 | bool deleteDevice(const QString &); | ||
436 | int newdevice(); | ||
437 | int copydevice(const QString&); | ||
438 | QStringList getDevicesNamesList(); | ||
439 | |||
415 | private: | 440 | private: |
416 | 441 | ||
417 | //static PPPData *_data; | 442 | //static PPPData *_data; |
418 | int modemDeviceGroup; | 443 | // int modemDeviceGroup; |
419 | QString passwd; | 444 | QString passwd; |
420 | // static Config* config; // configuration object | 445 | QString _modemName; |
421 | int highcount; // index of highest account | 446 | int highcount; // index of highest account |
422 | int caccount; // index of the current account | 447 | int highcountdev; // index of highest device |
448 | // int caccount; // index of the current account | ||
423 | QString cgroup; // name of current config group | 449 | QString cgroup; // name of current config group |
424 | pid_t suidprocessid; // process ID of setuid child | 450 | pid_t suidprocessid; // process ID of setuid child |
425 | bool pppdisrunning; // pppd process | 451 | bool pppdisrunning; // pppd process |
426 | // daemon | 452 | // daemon |
427 | int pppderror; // error encounterd running pppd | 453 | int pppderror; // error encounterd running pppd |
428 | int pppdVer, pppdMod, pppdPatch; // pppd version | 454 | int pppdVer, pppdMod, pppdPatch; // pppd version |
429 | 455 | ||
456 | |||
430 | QStringList phonelist; | 457 | QStringList phonelist; |
458 | QStringList accountList; | ||
459 | QStringList deviceList; | ||
431 | QMap<QString,QString> stringEntries; | 460 | QMap<QString,QString> stringEntries; |
432 | QMap<QString,int> intEntries; | 461 | QMap<QString,int> intEntries; |
433 | QMap<QString,QStringList> listEntries; | 462 | QMap<QString,QStringList> listEntries; |
434 | QMap<QString,QChar> sepEntries; | 463 | QMap<QString,QChar> sepEntries; |
435 | 464 | ||
436 | }; | 465 | }; |
437 | 466 | ||
438 | #endif | 467 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index d4c137b..af05eb7 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,44 +1,102 @@ | |||
1 | #include <errno.h> | ||
2 | #include <signal.h> | ||
1 | 3 | ||
4 | |||
5 | #include <qpe/config.h> | ||
6 | |||
7 | #include "modem.h" | ||
2 | #include "pppconfig.h" | 8 | #include "pppconfig.h" |
3 | #include "pppmodule.h" | 9 | #include "pppmodule.h" |
4 | #include "pppdata.h" | 10 | #include "pppdata.h" |
5 | #include "interfaceinformationppp.h" | 11 | #include "interfaceinformationppp.h" |
6 | #include "interfaceppp.h" | 12 | #include "interfaceppp.h" |
7 | 13 | ||
14 | // don't polute global namespace | ||
15 | namespace { | ||
16 | /* | ||
17 | * If network settings is qutting and we've ppp | ||
18 | * devices open we need to save the pid_t the PPData | ||
19 | * and the interface number | ||
20 | */ | ||
21 | struct Connection { | ||
22 | pid_t pid; | ||
23 | QString device; | ||
24 | QString name; | ||
25 | }; | ||
26 | class InterfaceKeeper { | ||
27 | public: | ||
28 | InterfaceKeeper(); | ||
29 | ~InterfaceKeeper(); | ||
30 | |||
31 | void addInterface( pid_t, const QString& pppDev, const QString& name ); | ||
32 | QMap<QString, Connection> interfaces()const; // will check if still available | ||
33 | private: | ||
34 | bool isAvailable( pid_t )const; | ||
35 | QMap<QString, Connection> m_interfaces; | ||
36 | }; | ||
37 | } | ||
38 | |||
8 | 39 | ||
9 | /** | 40 | /** |
10 | * Constructor, find all of the possible interfaces | 41 | * Constructor, find all of the possible interfaces |
42 | * We also need to restore the state.. it could be that | ||
43 | * an interface was up while closing the application | ||
44 | * we need to be able to shut it down... | ||
11 | */ | 45 | */ |
12 | PPPModule::PPPModule() : Module() | 46 | PPPModule::PPPModule() : Module() |
13 | { | 47 | { |
48 | InterfaceKeeper inFace; | ||
49 | QMap<QString,Connection> running = inFace.interfaces(); | ||
50 | QStringList handledInterfaceNames; | ||
51 | |||
14 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 52 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
15 | QMap<QString,QString>::Iterator it; | 53 | QMap<QString,QString>::Iterator it; |
16 | InterfacePPP *iface; | 54 | InterfacePPP *iface; |
17 | qDebug("getting interfaces"); | 55 | qDebug("getting interfaces"); |
18 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 56 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
19 | qDebug("ifaces %s", it.key().latin1()); | 57 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); |
20 | iface = new InterfacePPP( 0, it.key() ); | 58 | iface = new InterfacePPP( 0, it.key() ); |
21 | iface->setHardwareName( it.data() ); | 59 | iface->setHardwareName( it.data() ); |
22 | list.append( (Interface*)iface ); | 60 | list.append( (Interface*)iface ); |
61 | |||
62 | // check if (*it) is one of the running ifaces | ||
63 | if ( running.contains( it.data() ) ) { | ||
64 | qDebug("iface is running %s", it.key().latin1() ); | ||
65 | handledInterfaceNames << running[it.data()].device; | ||
66 | iface->setStatus( true ); | ||
67 | iface->setPPPDpid( running[it.data()].pid ); | ||
68 | iface->modem()->setPPPDevice( running[it.data()].device ); | ||
69 | iface->refresh(); | ||
70 | } | ||
23 | } | 71 | } |
72 | |||
73 | setHandledInterfaceNames( handledInterfaceNames ); | ||
24 | } | 74 | } |
25 | 75 | ||
26 | /** | 76 | /** |
27 | * Delete any interfaces that we own. | 77 | * Delete any interfaces that we own. |
28 | */ | 78 | */ |
29 | PPPModule::~PPPModule(){ | 79 | PPPModule::~PPPModule(){ |
80 | qDebug("PPPModule::~PPPModule() " ); | ||
30 | QMap<QString,QString> ifaces; | 81 | QMap<QString,QString> ifaces; |
82 | InterfaceKeeper keeper; | ||
31 | Interface *i; | 83 | Interface *i; |
32 | for ( i=list.first(); i != 0; i=list.next() ){ | 84 | for ( i=list.first(); i != 0; i=list.next() ){ |
85 | /* if online save the state */ | ||
86 | if ( i->getStatus() ) { | ||
87 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | ||
88 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | ||
89 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | ||
90 | } | ||
33 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 91 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
34 | delete i; | 92 | delete i; |
35 | } | 93 | } |
36 | PPPData::setConfiguredInterfaces( ifaces ); | 94 | PPPData::setConfiguredInterfaces( ifaces ); |
37 | } | 95 | } |
38 | 96 | ||
39 | /** | 97 | /** |
40 | * Change the current profile | 98 | * Change the current profile |
41 | */ | 99 | */ |
42 | void PPPModule::setProfile(const QString &newProfile){ | 100 | void PPPModule::setProfile(const QString &newProfile){ |
43 | profile = newProfile; | 101 | profile = newProfile; |
44 | } | 102 | } |
@@ -60,25 +118,25 @@ QString PPPModule::getPixmapName(Interface* ){ | |||
60 | bool PPPModule::isOwner(Interface *i){ | 118 | bool PPPModule::isOwner(Interface *i){ |
61 | return list.find( i ) != -1; | 119 | return list.find( i ) != -1; |
62 | } | 120 | } |
63 | 121 | ||
64 | /** | 122 | /** |
65 | * Create, and return the WLANConfigure Module | 123 | * Create, and return the WLANConfigure Module |
66 | * @return QWidget* pointer to this modules configure. | 124 | * @return QWidget* pointer to this modules configure. |
67 | */ | 125 | */ |
68 | QWidget *PPPModule::configure(Interface *i){ | 126 | QWidget *PPPModule::configure(Interface *i){ |
69 | qDebug("return ModemWidget"); | 127 | qDebug("return ModemWidget"); |
70 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 128 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
71 | 0, "PPPConfig", false, | 129 | 0, "PPPConfig", false, |
72 | Qt::WDestructiveClose ); | 130 | Qt::WDestructiveClose | Qt::WStyle_ContextHelp); |
73 | return pppconfig; | 131 | return pppconfig; |
74 | } | 132 | } |
75 | 133 | ||
76 | /** | 134 | /** |
77 | * Create, and return the Information Module | 135 | * Create, and return the Information Module |
78 | * @return QWidget* pointer to this modules info. | 136 | * @return QWidget* pointer to this modules info. |
79 | */ | 137 | */ |
80 | QWidget *PPPModule::information(Interface *i){ | 138 | QWidget *PPPModule::information(Interface *i){ |
81 | // We don't have any advanced pppd information widget yet :-D | 139 | // We don't have any advanced pppd information widget yet :-D |
82 | // TODO ^ | 140 | // TODO ^ |
83 | 141 | ||
84 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 142 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
@@ -126,12 +184,67 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){ | |||
126 | */ | 184 | */ |
127 | bool PPPModule::remove(Interface *i){ | 185 | bool PPPModule::remove(Interface *i){ |
128 | return list.remove(i); | 186 | return list.remove(i); |
129 | } | 187 | } |
130 | 188 | ||
131 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 189 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
132 | { | 190 | { |
133 | newIfaces.insert(QObject::tr("PPP") , | 191 | newIfaces.insert(QObject::tr("PPP") , |
134 | QObject::tr("generic ppp device")); | 192 | QObject::tr("generic ppp device")); |
135 | } | 193 | } |
136 | 194 | ||
137 | 195 | ||
196 | |||
197 | namespace { | ||
198 | InterfaceKeeper::InterfaceKeeper( ) { | ||
199 | } | ||
200 | InterfaceKeeper::~InterfaceKeeper() { | ||
201 | Config cfg("ppp_plugin_keeper"); | ||
202 | QStringList lst = cfg.groupList(); | ||
203 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
204 | Connection con; | ||
205 | cfg.setGroup( (*it) ); | ||
206 | cfg.clearGroup(); | ||
207 | } | ||
208 | |||
209 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { | ||
210 | Connection con = it.data(); | ||
211 | cfg.setGroup( con.name ); | ||
212 | cfg.writeEntry( "pid", con.pid ); | ||
213 | cfg.writeEntry( "device", con.device ); | ||
214 | } | ||
215 | } | ||
216 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { | ||
217 | Connection con; | ||
218 | con.pid = pid; | ||
219 | con.device = dev; | ||
220 | con.name = name; | ||
221 | m_interfaces.insert( name, con ); | ||
222 | } | ||
223 | QMap<QString, Connection> InterfaceKeeper::interfaces()const { | ||
224 | Config cfg("ppp_plugin_keeper"); | ||
225 | QMap<QString, Connection> ifaces; | ||
226 | QStringList lst = cfg.groupList(); | ||
227 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
228 | Connection con; | ||
229 | cfg.setGroup( (*it) ); | ||
230 | con.name = (*it); | ||
231 | con.pid = cfg.readNumEntry("pid"); | ||
232 | con.device = cfg.readEntry("device"); | ||
233 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); | ||
234 | |||
235 | if ( con.pid != -1 && isAvailable( con.pid ) ) | ||
236 | ifaces.insert( con.name, con ); | ||
237 | } | ||
238 | return ifaces; | ||
239 | } | ||
240 | bool InterfaceKeeper::isAvailable( pid_t p)const { | ||
241 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) { | ||
242 | qDebug("isAvailable %d", p); | ||
243 | return true; | ||
244 | } | ||
245 | |||
246 | qDebug("notAvailable %d", p); | ||
247 | return false; | ||
248 | } | ||
249 | |||
250 | } | ||
diff --git a/noncore/settings/networksettings/ppp/runtests.cpp b/noncore/settings/networksettings/ppp/runtests.cpp index 83ef2ea..5548601 100644 --- a/noncore/settings/networksettings/ppp/runtests.cpp +++ b/noncore/settings/networksettings/ppp/runtests.cpp | |||
@@ -35,26 +35,24 @@ | |||
35 | #include <pwd.h> | 35 | #include <pwd.h> |
36 | #include <netinet/in.h> | 36 | #include <netinet/in.h> |
37 | 37 | ||
38 | #ifdef HAVE_RESOLV_H | 38 | #ifdef HAVE_RESOLV_H |
39 | #include <arpa/nameser.h> | 39 | #include <arpa/nameser.h> |
40 | #include <resolv.h> | 40 | #include <resolv.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifndef _PATH_RESCONF | 43 | #ifndef _PATH_RESCONF |
44 | #define _PATH_RESCONF "/etc/resolv.conf" | 44 | #define _PATH_RESCONF "/etc/resolv.conf" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | //#include <klocale.h> | ||
48 | #define i18n QObject::tr | ||
49 | #include "pppdata.h" | 47 | #include "pppdata.h" |
50 | 48 | ||
51 | // initial effective uid (main.cpp) | 49 | // initial effective uid (main.cpp) |
52 | extern uid_t euid; | 50 | extern uid_t euid; |
53 | 51 | ||
54 | // secure pppd location (opener.cpp) | 52 | // secure pppd location (opener.cpp) |
55 | extern const char* pppdPath(); | 53 | extern const char* pppdPath(); |
56 | 54 | ||
57 | // shamelessly stolen from pppd-2.3.5 | 55 | // shamelessly stolen from pppd-2.3.5 |
58 | /******************************************************************** | 56 | /******************************************************************** |
59 | * | 57 | * |
60 | * Internal routine to decode the version.modification.patch level | 58 | * Internal routine to decode the version.modification.patch level |
@@ -208,71 +206,71 @@ int runTests() { | |||
208 | access = TRUE; | 206 | access = TRUE; |
209 | fclose(f); | 207 | fclose(f); |
210 | f = NULL; | 208 | f = NULL; |
211 | } | 209 | } |
212 | } | 210 | } |
213 | } | 211 | } |
214 | if(f) | 212 | if(f) |
215 | fclose(f); | 213 | fclose(f); |
216 | } | 214 | } |
217 | 215 | ||
218 | if(!access) { | 216 | if(!access) { |
219 | QMessageBox::warning(0,"error", | 217 | QMessageBox::warning(0,"error", |
220 | i18n("You're not allowed to dial out with " | 218 | QObject::tr("You're not allowed to dial out with " |
221 | "kppp.\nContact your system administrator.")); | 219 | "kppp.\nContact your system administrator.")); |
222 | return TEST_CRITICAL; | 220 | return TEST_CRITICAL; |
223 | } | 221 | } |
224 | } | 222 | } |
225 | 223 | ||
226 | // Test 1: search the pppd binary | 224 | // Test 1: search the pppd binary |
227 | const char *f = pppdPath(); | 225 | const char *f = pppdPath(); |
228 | 226 | ||
229 | if(!f) { | 227 | if(!f) { |
230 | QMessageBox::warning(0,"error", | 228 | QMessageBox::warning(0,"error", |
231 | i18n("Cannot find the PPP daemon!\n" | 229 | QObject::tr("Cannot find the PPP daemon!\n" |
232 | "Make sure that pppd is installed.")); | 230 | "Make sure that pppd is installed.")); |
233 | warning++; | 231 | warning++; |
234 | } | 232 | } |
235 | 233 | ||
236 | // Test 2: check access to the pppd binary | 234 | // Test 2: check access to the pppd binary |
237 | if(f) { | 235 | if(f) { |
238 | #if 0 | 236 | #if 0 |
239 | if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { | 237 | if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { |
240 | KMessageBox::warning(0, | 238 | KMessageBox::warning(0, |
241 | i18n("You do not have the permission " | 239 | QObject::tr("You do not have the permission " |
242 | "to start pppd!\n" | 240 | "to start pppd!\n" |
243 | "Contact your system administrator " | 241 | "Contact your system administrator " |
244 | "and ask to get access to pppd.")); | 242 | "and ask to get access to pppd.")); |
245 | return TEST_CRITICAL; | 243 | return TEST_CRITICAL; |
246 | } | 244 | } |
247 | #endif | 245 | #endif |
248 | 246 | ||
249 | if(geteuid() != 0) { | 247 | if(geteuid() != 0) { |
250 | struct stat st; | 248 | struct stat st; |
251 | stat(f, &st); | 249 | stat(f, &st); |
252 | if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { | 250 | if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { |
253 | QMessageBox::warning(0,"error", | 251 | QMessageBox::warning(0,"error", |
254 | i18n("You don't have sufficient permission to run\n" | 252 | QObject::tr("You don't have sufficient permission to run\n" |
255 | "%1\n" | 253 | "%1\n" |
256 | "Please make sure that kppp is owned by root " | 254 | "Please make sure that kppp is owned by root " |
257 | "and has the SUID bit set.").arg(f)); | 255 | "and has the SUID bit set.").arg(f)); |
258 | warning++; | 256 | warning++; |
259 | } | 257 | } |
260 | } | 258 | } |
261 | } | 259 | } |
262 | 260 | ||
263 | // Test 5: check for existence of /etc/resolv.conf | 261 | // Test 5: check for existence of /etc/resolv.conf |
264 | if (access(_PATH_RESCONF, R_OK) != 0) { | 262 | if (access(_PATH_RESCONF, R_OK) != 0) { |
265 | QString file = _PATH_RESCONF" "; | 263 | QString file = _PATH_RESCONF" "; |
266 | QString msgstr = i18n("%1 is missing or can't be read!\n" | 264 | QString msgstr = QObject::tr("%1 is missing or can't be read!\n" |
267 | "Ask your system administrator to create " | 265 | "Ask your system administrator to create " |
268 | "this file (can be empty) with appropriate " | 266 | "this file (can be empty) with appropriate " |
269 | "read and write permissions.").arg(file); | 267 | "read and write permissions.").arg(file); |
270 | QMessageBox::warning(0, "errror", msgstr); | 268 | QMessageBox::warning(0, "errror", msgstr); |
271 | warning ++; | 269 | warning ++; |
272 | } | 270 | } |
273 | 271 | ||
274 | if(warning == 0) | 272 | if(warning == 0) |
275 | return TEST_OK; | 273 | return TEST_OK; |
276 | else | 274 | else |
277 | return TEST_WARNING; | 275 | return TEST_WARNING; |
278 | } | 276 | } |